Skip to content

Commit 4fedb1f

Browse files
Merge branch '6.10/scsi-queue' into 6.10/scsi-fixes
Pull in remaining commits from 6.10/scsi-queue. Signed-off-by: Martin K. Petersen <[email protected]>
2 parents 1613e60 + d09c05a commit 4fedb1f

File tree

10 files changed

+85
-20
lines changed

10 files changed

+85
-20
lines changed

Documentation/cdrom/cdrom-standard.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ current *struct* is::
217217
int (*media_changed)(struct cdrom_device_info *, int);
218218
int (*tray_move)(struct cdrom_device_info *, int);
219219
int (*lock_door)(struct cdrom_device_info *, int);
220-
int (*select_speed)(struct cdrom_device_info *, int);
220+
int (*select_speed)(struct cdrom_device_info *, unsigned long);
221221
int (*get_last_session) (struct cdrom_device_info *,
222222
struct cdrom_multisession *);
223223
int (*get_mcn)(struct cdrom_device_info *, struct cdrom_mcn *);
@@ -396,7 +396,7 @@ action need be taken, and the return value should be 0.
396396

397397
::
398398

399-
int select_speed(struct cdrom_device_info *cdi, int speed)
399+
int select_speed(struct cdrom_device_info *cdi, unsigned long speed)
400400

401401
Some CD-ROM drives are capable of changing their head-speed. There
402402
are several reasons for changing the speed of a CD-ROM drive. Badly

drivers/scsi/device_handler/scsi_dh_alua.c

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -414,28 +414,40 @@ static char print_alua_state(unsigned char state)
414414
}
415415
}
416416

417-
static enum scsi_disposition alua_check_sense(struct scsi_device *sdev,
418-
struct scsi_sense_hdr *sense_hdr)
417+
static void alua_handle_state_transition(struct scsi_device *sdev)
419418
{
420419
struct alua_dh_data *h = sdev->handler_data;
421420
struct alua_port_group *pg;
422421

422+
rcu_read_lock();
423+
pg = rcu_dereference(h->pg);
424+
if (pg)
425+
pg->state = SCSI_ACCESS_STATE_TRANSITIONING;
426+
rcu_read_unlock();
427+
alua_check(sdev, false);
428+
}
429+
430+
static enum scsi_disposition alua_check_sense(struct scsi_device *sdev,
431+
struct scsi_sense_hdr *sense_hdr)
432+
{
423433
switch (sense_hdr->sense_key) {
424434
case NOT_READY:
425435
if (sense_hdr->asc == 0x04 && sense_hdr->ascq == 0x0a) {
426436
/*
427437
* LUN Not Accessible - ALUA state transition
428438
*/
429-
rcu_read_lock();
430-
pg = rcu_dereference(h->pg);
431-
if (pg)
432-
pg->state = SCSI_ACCESS_STATE_TRANSITIONING;
433-
rcu_read_unlock();
434-
alua_check(sdev, false);
439+
alua_handle_state_transition(sdev);
435440
return NEEDS_RETRY;
436441
}
437442
break;
438443
case UNIT_ATTENTION:
444+
if (sense_hdr->asc == 0x04 && sense_hdr->ascq == 0x0a) {
445+
/*
446+
* LUN Not Accessible - ALUA state transition
447+
*/
448+
alua_handle_state_transition(sdev);
449+
return NEEDS_RETRY;
450+
}
439451
if (sense_hdr->asc == 0x29 && sense_hdr->ascq == 0x00) {
440452
/*
441453
* Power On, Reset, or Bus Device Reset.
@@ -502,7 +514,8 @@ static int alua_tur(struct scsi_device *sdev)
502514

503515
retval = scsi_test_unit_ready(sdev, ALUA_FAILOVER_TIMEOUT * HZ,
504516
ALUA_FAILOVER_RETRIES, &sense_hdr);
505-
if (sense_hdr.sense_key == NOT_READY &&
517+
if ((sense_hdr.sense_key == NOT_READY ||
518+
sense_hdr.sense_key == UNIT_ATTENTION) &&
506519
sense_hdr.asc == 0x04 && sense_hdr.ascq == 0x0a)
507520
return SCSI_DH_RETRY;
508521
else if (retval)

drivers/scsi/mpi3mr/mpi3mr_transport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1364,7 +1364,7 @@ static struct mpi3mr_sas_port *mpi3mr_sas_port_add(struct mpi3mr_ioc *mrioc,
13641364
continue;
13651365

13661366
if (i > sizeof(mr_sas_port->phy_mask) * 8) {
1367-
ioc_warn(mrioc, "skipping port %u, max allowed value is %lu\n",
1367+
ioc_warn(mrioc, "skipping port %u, max allowed value is %zu\n",
13681368
i, sizeof(mr_sas_port->phy_mask) * 8);
13691369
goto out_fail;
13701370
}

drivers/scsi/mpt3sas/mpt3sas_scsih.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,8 @@ struct _scsi_io_transfer {
302302

303303
/**
304304
* _scsih_set_debug_level - global setting of ioc->logging_level.
305-
* @val: ?
306-
* @kp: ?
305+
* @val: value of the parameter to be set
306+
* @kp: pointer to kernel_param structure
307307
*
308308
* Note: The logging levels are defined in mpt3sas_debug.h.
309309
*/

drivers/scsi/qedf/qedf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ struct qedf_ctx {
363363
#define QEDF_IN_RECOVERY 5
364364
#define QEDF_DBG_STOP_IO 6
365365
#define QEDF_PROBING 8
366+
#define QEDF_STAG_IN_PROGRESS 9
366367
unsigned long flags; /* Miscellaneous state flags */
367368
int fipvlan_retries;
368369
u8 num_queues;

drivers/scsi/qedf/qedf_main.c

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,11 +318,18 @@ static struct fc_seq *qedf_elsct_send(struct fc_lport *lport, u32 did,
318318
*/
319319
if (resp == fc_lport_flogi_resp) {
320320
qedf->flogi_cnt++;
321+
qedf->flogi_pending++;
322+
323+
if (test_bit(QEDF_UNLOADING, &qedf->flags)) {
324+
QEDF_ERR(&qedf->dbg_ctx, "Driver unloading\n");
325+
qedf->flogi_pending = 0;
326+
}
327+
321328
if (qedf->flogi_pending >= QEDF_FLOGI_RETRY_CNT) {
322329
schedule_delayed_work(&qedf->stag_work, 2);
323330
return NULL;
324331
}
325-
qedf->flogi_pending++;
332+
326333
return fc_elsct_send(lport, did, fp, op, qedf_flogi_resp,
327334
arg, timeout);
328335
}
@@ -912,13 +919,14 @@ void qedf_ctx_soft_reset(struct fc_lport *lport)
912919
struct qedf_ctx *qedf;
913920
struct qed_link_output if_link;
914921

922+
qedf = lport_priv(lport);
923+
915924
if (lport->vport) {
925+
clear_bit(QEDF_STAG_IN_PROGRESS, &qedf->flags);
916926
printk_ratelimited("Cannot issue host reset on NPIV port.\n");
917927
return;
918928
}
919929

920-
qedf = lport_priv(lport);
921-
922930
qedf->flogi_pending = 0;
923931
/* For host reset, essentially do a soft link up/down */
924932
atomic_set(&qedf->link_state, QEDF_LINK_DOWN);
@@ -938,6 +946,7 @@ void qedf_ctx_soft_reset(struct fc_lport *lport)
938946
if (!if_link.link_up) {
939947
QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_DISC,
940948
"Physical link is not up.\n");
949+
clear_bit(QEDF_STAG_IN_PROGRESS, &qedf->flags);
941950
return;
942951
}
943952
/* Flush and wait to make sure link down is processed */
@@ -950,6 +959,7 @@ void qedf_ctx_soft_reset(struct fc_lport *lport)
950959
"Queue link up work.\n");
951960
queue_delayed_work(qedf->link_update_wq, &qedf->link_update,
952961
0);
962+
clear_bit(QEDF_STAG_IN_PROGRESS, &qedf->flags);
953963
}
954964

955965
/* Reset the host by gracefully logging out and then logging back in */
@@ -3463,6 +3473,7 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
34633473
}
34643474

34653475
/* Start the Slowpath-process */
3476+
memset(&slowpath_params, 0, sizeof(struct qed_slowpath_params));
34663477
slowpath_params.int_mode = QED_INT_MODE_MSIX;
34673478
slowpath_params.drv_major = QEDF_DRIVER_MAJOR_VER;
34683479
slowpath_params.drv_minor = QEDF_DRIVER_MINOR_VER;
@@ -3721,6 +3732,7 @@ static void __qedf_remove(struct pci_dev *pdev, int mode)
37213732
{
37223733
struct qedf_ctx *qedf;
37233734
int rc;
3735+
int cnt = 0;
37243736

37253737
if (!pdev) {
37263738
QEDF_ERR(NULL, "pdev is NULL.\n");
@@ -3738,6 +3750,17 @@ static void __qedf_remove(struct pci_dev *pdev, int mode)
37383750
return;
37393751
}
37403752

3753+
stag_in_prog:
3754+
if (test_bit(QEDF_STAG_IN_PROGRESS, &qedf->flags)) {
3755+
QEDF_ERR(&qedf->dbg_ctx, "Stag in progress, cnt=%d.\n", cnt);
3756+
cnt++;
3757+
3758+
if (cnt < 5) {
3759+
msleep(500);
3760+
goto stag_in_prog;
3761+
}
3762+
}
3763+
37413764
if (mode != QEDF_MODE_RECOVERY)
37423765
set_bit(QEDF_UNLOADING, &qedf->flags);
37433766

@@ -3997,6 +4020,24 @@ void qedf_stag_change_work(struct work_struct *work)
39974020
struct qedf_ctx *qedf =
39984021
container_of(work, struct qedf_ctx, stag_work.work);
39994022

4023+
if (!qedf) {
4024+
QEDF_ERR(&qedf->dbg_ctx, "qedf is NULL");
4025+
return;
4026+
}
4027+
4028+
if (test_bit(QEDF_IN_RECOVERY, &qedf->flags)) {
4029+
QEDF_ERR(&qedf->dbg_ctx,
4030+
"Already is in recovery, hence not calling software context reset.\n");
4031+
return;
4032+
}
4033+
4034+
if (test_bit(QEDF_UNLOADING, &qedf->flags)) {
4035+
QEDF_ERR(&qedf->dbg_ctx, "Driver unloading\n");
4036+
return;
4037+
}
4038+
4039+
set_bit(QEDF_STAG_IN_PROGRESS, &qedf->flags);
4040+
40004041
printk_ratelimited("[%s]:[%s:%d]:%d: Performing software context reset.",
40014042
dev_name(&qedf->pdev->dev), __func__, __LINE__,
40024043
qedf->dbg_ctx.host_no);

drivers/scsi/scsi.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,13 @@ static int scsi_get_vpd_size(struct scsi_device *sdev, u8 page)
350350
if (result < SCSI_VPD_HEADER_SIZE)
351351
return 0;
352352

353+
if (result > sizeof(vpd)) {
354+
dev_warn_once(&sdev->sdev_gendev,
355+
"%s: long VPD page 0 length: %d bytes\n",
356+
__func__, result);
357+
result = sizeof(vpd);
358+
}
359+
353360
result -= SCSI_VPD_HEADER_SIZE;
354361
if (!memchr(&vpd[SCSI_VPD_HEADER_SIZE], page, result))
355362
return 0;

drivers/scsi/sr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ int sr_disk_status(struct cdrom_device_info *);
6565
int sr_get_last_session(struct cdrom_device_info *, struct cdrom_multisession *);
6666
int sr_get_mcn(struct cdrom_device_info *, struct cdrom_mcn *);
6767
int sr_reset(struct cdrom_device_info *);
68-
int sr_select_speed(struct cdrom_device_info *cdi, int speed);
68+
int sr_select_speed(struct cdrom_device_info *cdi, unsigned long speed);
6969
int sr_audio_ioctl(struct cdrom_device_info *, unsigned int, void *);
7070

7171
int sr_is_xa(Scsi_CD *);

drivers/scsi/sr_ioctl.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,11 +425,14 @@ int sr_reset(struct cdrom_device_info *cdi)
425425
return 0;
426426
}
427427

428-
int sr_select_speed(struct cdrom_device_info *cdi, int speed)
428+
int sr_select_speed(struct cdrom_device_info *cdi, unsigned long speed)
429429
{
430430
Scsi_CD *cd = cdi->handle;
431431
struct packet_command cgc;
432432

433+
/* avoid exceeding the max speed or overflowing integer bounds */
434+
speed = clamp(0, speed, 0xffff / 177);
435+
433436
if (speed == 0)
434437
speed = 0xffff; /* set to max */
435438
else

include/linux/cdrom.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ struct cdrom_device_ops {
7777
unsigned int clearing, int slot);
7878
int (*tray_move) (struct cdrom_device_info *, int);
7979
int (*lock_door) (struct cdrom_device_info *, int);
80-
int (*select_speed) (struct cdrom_device_info *, int);
80+
int (*select_speed) (struct cdrom_device_info *, unsigned long);
8181
int (*get_last_session) (struct cdrom_device_info *,
8282
struct cdrom_multisession *);
8383
int (*get_mcn) (struct cdrom_device_info *,

0 commit comments

Comments
 (0)