Skip to content

Commit ce35a81

Browse files
author
Linus Torvalds
committed
Merge master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-rc-fixes-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-rc-fixes-2.6: [SCSI] sd: udev accessing an uninitialized scsi_disk field results in a crash [SCSI] st: A MTIOCTOP/MTWEOF within the early warning will cause the file number to be incorrect [SCSI] qla4xxx: bug fixes [SCSI] Fix scsi_add_device() for async scanning
2 parents 259886a + 017f2e3 commit ce35a81

10 files changed

Lines changed: 100 additions & 70 deletions

File tree

‎drivers/scsi/qla4xxx/ql4_def.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,6 @@ struct scsi_qla_host {
418418
* concurrently.
419419
*/
420420
struct mutex mbox_sem;
421-
wait_queue_head_t mailbox_wait_queue;
422421

423422
/* temporary mailbox status registers */
424423
volatile uint8_t mbox_status_count;

‎drivers/scsi/qla4xxx/ql4_glbl.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,5 @@ int qla4xxx_process_ddb_changed(struct scsi_qla_host * ha,
7676
extern int ql4xextended_error_logging;
7777
extern int ql4xdiscoverywait;
7878
extern int ql4xdontresethba;
79+
extern int ql4_mod_unload;
7980
#endif /* _QLA4x_GBL_H */

‎drivers/scsi/qla4xxx/ql4_init.c‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -958,25 +958,25 @@ static int qla4xxx_start_firmware_from_flash(struct scsi_qla_host *ha)
958958
return status;
959959
}
960960

961-
int ql4xxx_lock_drvr_wait(struct scsi_qla_host *a)
961+
int ql4xxx_lock_drvr_wait(struct scsi_qla_host *ha)
962962
{
963-
#define QL4_LOCK_DRVR_WAIT 300
964-
#define QL4_LOCK_DRVR_SLEEP 100
963+
#define QL4_LOCK_DRVR_WAIT 30
964+
#define QL4_LOCK_DRVR_SLEEP 1
965965

966966
int drvr_wait = QL4_LOCK_DRVR_WAIT;
967967
while (drvr_wait) {
968-
if (ql4xxx_lock_drvr(a) == 0) {
969-
msleep(QL4_LOCK_DRVR_SLEEP);
968+
if (ql4xxx_lock_drvr(ha) == 0) {
969+
ssleep(QL4_LOCK_DRVR_SLEEP);
970970
if (drvr_wait) {
971971
DEBUG2(printk("scsi%ld: %s: Waiting for "
972-
"Global Init Semaphore...n",
973-
a->host_no,
974-
__func__));
972+
"Global Init Semaphore(%d)...n",
973+
ha->host_no,
974+
__func__, drvr_wait));
975975
}
976976
drvr_wait -= QL4_LOCK_DRVR_SLEEP;
977977
} else {
978978
DEBUG2(printk("scsi%ld: %s: Global Init Semaphore "
979-
"acquired.n", a->host_no, __func__));
979+
"acquired.n", ha->host_no, __func__));
980980
return QLA_SUCCESS;
981981
}
982982
}

‎drivers/scsi/qla4xxx/ql4_isr.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,6 @@ static void qla4xxx_isr_decode_mailbox(struct scsi_qla_host * ha,
433433
readl(&ha->reg->mailbox[i]);
434434

435435
set_bit(AF_MBOX_COMMAND_DONE, &ha->flags);
436-
wake_up(&ha->mailbox_wait_queue);
437436
}
438437
} else if (mbox_status >> 12 == MBOX_ASYNC_EVENT_STATUS) {
439438
/* Immediately process the AENs that don't require much work.
@@ -686,7 +685,8 @@ irqreturn_t qla4xxx_intr_handler(int irq, void *dev_id)
686685
&ha->reg->ctrl_status);
687686
readl(&ha->reg->ctrl_status);
688687

689-
set_bit(DPC_RESET_HA_INTR, &ha->dpc_flags);
688+
if (!ql4_mod_unload)
689+
set_bit(DPC_RESET_HA_INTR, &ha->dpc_flags);
690690

691691
break;
692692
} else if (intr_status & INTR_PENDING) {

‎drivers/scsi/qla4xxx/ql4_mbx.c‎

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,30 @@ int qla4xxx_mailbox_command(struct scsi_qla_host *ha, uint8_t inCount,
2929
u_long wait_count;
3030
uint32_t intr_status;
3131
unsigned long flags = 0;
32-
DECLARE_WAITQUEUE(wait, current);
33-
34-
mutex_lock(&ha->mbox_sem);
35-
36-
/* Mailbox code active */
37-
set_bit(AF_MBOX_COMMAND, &ha->flags);
3832

3933
/* Make sure that pointers are valid */
4034
if (!mbx_cmd || !mbx_sts) {
4135
DEBUG2(printk("scsi%ld: %s: Invalid mbx_cmd or mbx_sts "
4236
"pointer\n", ha->host_no, __func__));
43-
goto mbox_exit;
37+
return status;
38+
}
39+
/* Mailbox code active */
40+
wait_count = MBOX_TOV * 100;
41+
42+
while (wait_count--) {
43+
mutex_lock(&ha->mbox_sem);
44+
if (!test_bit(AF_MBOX_COMMAND, &ha->flags)) {
45+
set_bit(AF_MBOX_COMMAND, &ha->flags);
46+
mutex_unlock(&ha->mbox_sem);
47+
break;
48+
}
49+
mutex_unlock(&ha->mbox_sem);
50+
if (!wait_count) {
51+
DEBUG2(printk("scsi%ld: %s: mbox_sem failed\n",
52+
ha->host_no, __func__));
53+
return status;
54+
}
55+
msleep(10);
4456
}
4557

4658
/* To prevent overwriting mailbox registers for a command that has
@@ -73,8 +85,6 @@ int qla4xxx_mailbox_command(struct scsi_qla_host *ha, uint8_t inCount,
7385
spin_unlock_irqrestore(&ha->hardware_lock, flags);
7486

7587
/* Wait for completion */
76-
set_current_state(TASK_UNINTERRUPTIBLE);
77-
add_wait_queue(&ha->mailbox_wait_queue, &wait);
7888

7989
/*
8090
* If we don't want status, don't wait for the mailbox command to
@@ -83,8 +93,6 @@ int qla4xxx_mailbox_command(struct scsi_qla_host *ha, uint8_t inCount,
8393
*/
8494
if (outCount == 0) {
8595
status = QLA_SUCCESS;
86-
set_current_state(TASK_RUNNING);
87-
remove_wait_queue(&ha->mailbox_wait_queue, &wait);
8896
goto mbox_exit;
8997
}
9098
/* Wait for command to complete */
@@ -108,8 +116,6 @@ int qla4xxx_mailbox_command(struct scsi_qla_host *ha, uint8_t inCount,
108116
spin_unlock_irqrestore(&ha->hardware_lock, flags);
109117
msleep(10);
110118
}
111-
set_current_state(TASK_RUNNING);
112-
remove_wait_queue(&ha->mailbox_wait_queue, &wait);
113119

114120
/* Check for mailbox timeout. */
115121
if (!test_bit(AF_MBOX_COMMAND_DONE, &ha->flags)) {
@@ -155,9 +161,10 @@ int qla4xxx_mailbox_command(struct scsi_qla_host *ha, uint8_t inCount,
155161
spin_unlock_irqrestore(&ha->hardware_lock, flags);
156162

157163
mbox_exit:
164+
mutex_lock(&ha->mbox_sem);
158165
clear_bit(AF_MBOX_COMMAND, &ha->flags);
159-
clear_bit(AF_MBOX_COMMAND_DONE, &ha->flags);
160166
mutex_unlock(&ha->mbox_sem);
167+
clear_bit(AF_MBOX_COMMAND_DONE, &ha->flags);
161168

162169
return status;
163170
}

‎drivers/scsi/qla4xxx/ql4_os.c‎

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ MODULE_PARM_DESC(ql4xextended_error_logging,
4040
"Option to enable extended error logging, "
4141
"Default is 0 - no logging, 1 - debug logging");
4242

43+
int ql4_mod_unload = 0;
44+
4345
/*
4446
* SCSI host template entry points
4547
*/
@@ -422,6 +424,9 @@ static int qla4xxx_queuecommand(struct scsi_cmnd *cmd,
422424
goto qc_host_busy;
423425
}
424426

427+
if (test_bit(DPC_RESET_HA_INTR, &ha->dpc_flags))
428+
goto qc_host_busy;
429+
425430
spin_unlock_irq(ha->host->host_lock);
426431

427432
srb = qla4xxx_get_new_srb(ha, ddb_entry, cmd, done);
@@ -707,16 +712,12 @@ static int qla4xxx_cmd_wait(struct scsi_qla_host *ha)
707712
return stat;
708713
}
709714

710-
/**
711-
* qla4xxx_soft_reset - performs soft reset.
712-
* @ha: Pointer to host adapter structure.
713-
**/
714-
int qla4xxx_soft_reset(struct scsi_qla_host *ha)
715+
static void qla4xxx_hw_reset(struct scsi_qla_host *ha)
715716
{
716-
uint32_t max_wait_time;
717-
unsigned long flags = 0;
718-
int status = QLA_ERROR;
719717
uint32_t ctrl_status;
718+
unsigned long flags = 0;
719+
720+
DEBUG2(printk(KERN_ERR "scsi%ld: %s\n", ha->host_no, __func__));
720721

721722
spin_lock_irqsave(&ha->hardware_lock, flags);
722723

@@ -733,6 +734,20 @@ int qla4xxx_soft_reset(struct scsi_qla_host *ha)
733734
readl(&ha->reg->ctrl_status);
734735

735736
spin_unlock_irqrestore(&ha->hardware_lock, flags);
737+
}
738+
739+
/**
740+
* qla4xxx_soft_reset - performs soft reset.
741+
* @ha: Pointer to host adapter structure.
742+
**/
743+
int qla4xxx_soft_reset(struct scsi_qla_host *ha)
744+
{
745+
uint32_t max_wait_time;
746+
unsigned long flags = 0;
747+
int status = QLA_ERROR;
748+
uint32_t ctrl_status;
749+
750+
qla4xxx_hw_reset(ha);
736751

737752
/* Wait until the Network Reset Intr bit is cleared */
738753
max_wait_time = RESET_INTR_TOV;
@@ -966,10 +981,12 @@ static void qla4xxx_do_dpc(struct work_struct *work)
966981
struct scsi_qla_host *ha =
967982
container_of(work, struct scsi_qla_host, dpc_work);
968983
struct ddb_entry *ddb_entry, *dtemp;
984+
int status = QLA_ERROR;
969985

970986
DEBUG2(printk("scsi%ld: %s: DPC handler waking up."
971-
"flags = 0x%08lx, dpc_flags = 0x%08lx\n",
972-
ha->host_no, __func__, ha->flags, ha->dpc_flags));
987+
"flags = 0x%08lx, dpc_flags = 0x%08lx ctrl_stat = 0x%08x\n",
988+
ha->host_no, __func__, ha->flags, ha->dpc_flags,
989+
readw(&ha->reg->ctrl_status)));
973990

974991
/* Initialization not yet finished. Don't do anything yet. */
975992
if (!test_bit(AF_INIT_DONE, &ha->flags))
@@ -983,31 +1000,28 @@ static void qla4xxx_do_dpc(struct work_struct *work)
9831000
test_bit(DPC_RESET_HA, &ha->dpc_flags))
9841001
qla4xxx_recover_adapter(ha, PRESERVE_DDB_LIST);
9851002

986-
if (test_and_clear_bit(DPC_RESET_HA_INTR, &ha->dpc_flags)) {
1003+
if (test_bit(DPC_RESET_HA_INTR, &ha->dpc_flags)) {
9871004
uint8_t wait_time = RESET_INTR_TOV;
988-
unsigned long flags = 0;
989-
990-
qla4xxx_flush_active_srbs(ha);
9911005

992-
spin_lock_irqsave(&ha->hardware_lock, flags);
9931006
while ((readw(&ha->reg->ctrl_status) &
9941007
(CSR_SOFT_RESET | CSR_FORCE_SOFT_RESET)) != 0) {
9951008
if (--wait_time == 0)
9961009
break;
997-
998-
spin_unlock_irqrestore(&ha->hardware_lock,
999-
flags);
1000-
10011010
msleep(1000);
1002-
1003-
spin_lock_irqsave(&ha->hardware_lock, flags);
10041011
}
1005-
spin_unlock_irqrestore(&ha->hardware_lock, flags);
1006-
10071012
if (wait_time == 0)
10081013
DEBUG2(printk("scsi%ld: %s: SR|FSR "
10091014
"bit not cleared-- resetting\n",
10101015
ha->host_no, __func__));
1016+
qla4xxx_flush_active_srbs(ha);
1017+
if (ql4xxx_lock_drvr_wait(ha) == QLA_SUCCESS) {
1018+
qla4xxx_process_aen(ha, FLUSH_DDB_CHANGED_AENS);
1019+
status = qla4xxx_initialize_adapter(ha,
1020+
PRESERVE_DDB_LIST);
1021+
}
1022+
clear_bit(DPC_RESET_HA_INTR, &ha->dpc_flags);
1023+
if (status == QLA_SUCCESS)
1024+
qla4xxx_enable_intrs(ha);
10111025
}
10121026
}
10131027

@@ -1062,7 +1076,7 @@ static void qla4xxx_free_adapter(struct scsi_qla_host *ha)
10621076

10631077
/* Issue Soft Reset to put firmware in unknown state */
10641078
if (ql4xxx_lock_drvr_wait(ha) == QLA_SUCCESS)
1065-
qla4xxx_soft_reset(ha);
1079+
qla4xxx_hw_reset(ha);
10661080

10671081
/* Remove timer thread, if present */
10681082
if (ha->timer_active)
@@ -1198,7 +1212,6 @@ static int __devinit qla4xxx_probe_adapter(struct pci_dev *pdev,
11981212
INIT_LIST_HEAD(&ha->free_srb_q);
11991213

12001214
mutex_init(&ha->mbox_sem);
1201-
init_waitqueue_head(&ha->mailbox_wait_queue);
12021215

12031216
spin_lock_init(&ha->hardware_lock);
12041217

@@ -1665,6 +1678,7 @@ static int __init qla4xxx_module_init(void)
16651678

16661679
static void __exit qla4xxx_module_exit(void)
16671680
{
1681+
ql4_mod_unload = 1;
16681682
pci_unregister_driver(&qla4xxx_pci_driver);
16691683
iscsi_unregister_transport(&qla4xxx_iscsi_transport);
16701684
kmem_cache_destroy(srb_cachep);

‎drivers/scsi/qla4xxx/ql4_version.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
* See LICENSE.qla4xxx for copyright and licensing details.
66
*/
77

8-
#define QLA4XXX_DRIVER_VERSION "5.00.07-k"
8+
#define QLA4XXX_DRIVER_VERSION "5.00.07-k1"

‎drivers/scsi/scsi_scan.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,6 +1453,12 @@ struct scsi_device *__scsi_add_device(struct Scsi_Host *shost, uint channel,
14531453
struct device *parent = &shost->shost_gendev;
14541454
struct scsi_target *starget;
14551455

1456+
if (strncmp(scsi_scan_type, "none", 4) == 0)
1457+
return ERR_PTR(-ENODEV);
1458+
1459+
if (!shost->async_scan)
1460+
scsi_complete_async_scans();
1461+
14561462
starget = scsi_alloc_target(parent, channel, id);
14571463
if (!starget)
14581464
return ERR_PTR(-ENOMEM);

‎drivers/scsi/sd.c‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,16 +1647,6 @@ static int sd_probe(struct device *dev)
16471647
if (error)
16481648
goto out_put;
16491649

1650-
class_device_initialize(&sdkp->cdev);
1651-
sdkp->cdev.dev = &sdp->sdev_gendev;
1652-
sdkp->cdev.class = &sd_disk_class;
1653-
strncpy(sdkp->cdev.class_id, sdp->sdev_gendev.bus_id, BUS_ID_SIZE);
1654-
1655-
if (class_device_add(&sdkp->cdev))
1656-
goto out_put;
1657-
1658-
get_device(&sdp->sdev_gendev);
1659-
16601650
sdkp->device = sdp;
16611651
sdkp->driver = &sd_template;
16621652
sdkp->disk = gd;
@@ -1670,6 +1660,16 @@ static int sd_probe(struct device *dev)
16701660
sdp->timeout = SD_MOD_TIMEOUT;
16711661
}
16721662

1663+
class_device_initialize(&sdkp->cdev);
1664+
sdkp->cdev.dev = &sdp->sdev_gendev;
1665+
sdkp->cdev.class = &sd_disk_class;
1666+
strncpy(sdkp->cdev.class_id, sdp->sdev_gendev.bus_id, BUS_ID_SIZE);
1667+
1668+
if (class_device_add(&sdkp->cdev))
1669+
goto out_put;
1670+
1671+
get_device(&sdp->sdev_gendev);
1672+
16731673
gd->major = sd_major((index & 0xf0) >> 4);
16741674
gd->first_minor = ((index & 0xf) << 4) | (index & 0xfff00);
16751675
gd->minors = 16;

‎drivers/scsi/st.c‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2816,15 +2816,18 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon
28162816

28172817
if (cmd_in == MTWEOF &&
28182818
cmdstatp->have_sense &&
2819-
(cmdstatp->flags & SENSE_EOM) &&
2820-
(cmdstatp->sense_hdr.sense_key == NO_SENSE ||
2821-
cmdstatp->sense_hdr.sense_key == RECOVERED_ERROR) &&
2822-
undone == 0) {
2823-
ioctl_result = 0; /* EOF written successfully at EOM */
2824-
if (fileno >= 0)
2825-
fileno++;
2819+
(cmdstatp->flags & SENSE_EOM)) {
2820+
if (cmdstatp->sense_hdr.sense_key == NO_SENSE ||
2821+
cmdstatp->sense_hdr.sense_key == RECOVERED_ERROR) {
2822+
ioctl_result = 0; /* EOF(s) written successfully at EOM */
2823+
STps->eof = ST_NOEOF;
2824+
} else { /* Writing EOF(s) failed */
2825+
if (fileno >= 0)
2826+
fileno -= undone;
2827+
if (undone < arg)
2828+
STps->eof = ST_NOEOF;
2829+
}
28262830
STps->drv_file = fileno;
2827-
STps->eof = ST_NOEOF;
28282831
} else if ((cmd_in == MTFSF) || (cmd_in == MTFSFM)) {
28292832
if (fileno >= 0)
28302833
STps->drv_file = fileno - undone;

0 commit comments

Comments
 (0)