aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorJonathan Corbet <corbet@lwn.net>2008-07-14 17:29:34 -0400
committerJonathan Corbet <corbet@lwn.net>2008-07-14 17:29:34 -0400
commit2fceef397f9880b212a74c418290ce69e7ac00eb (patch)
treed9cc09ab992825ef7fede4a688103503e3caf655 /drivers/scsi
parentfeae1ef116ed381625d3731c5ae4f4ebcb3fa302 (diff)
parentbce7f793daec3e65ec5c5705d2457b81fe7b5725 (diff)
Merge commit 'v2.6.26' into bkl-removal
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/3w-9xxx.c6
-rw-r--r--drivers/scsi/aha152x.c4
-rw-r--r--drivers/scsi/atp870u.c2
-rw-r--r--drivers/scsi/ch.c7
-rw-r--r--drivers/scsi/dpt/dptsig.h3
-rw-r--r--drivers/scsi/esp_scsi.c22
-rw-r--r--drivers/scsi/hosts.c9
-rw-r--r--drivers/scsi/hptiop.c12
-rw-r--r--drivers/scsi/ibmvscsi/ibmvscsi.c2
-rw-r--r--drivers/scsi/ibmvscsi/viosrp.h3
-rw-r--r--drivers/scsi/ipr.c6
-rw-r--r--drivers/scsi/mac_esp.c2
-rw-r--r--drivers/scsi/osst.c3
-rw-r--r--drivers/scsi/qla1280.c2
-rw-r--r--drivers/scsi/qla2xxx/qla_attr.c13
-rw-r--r--drivers/scsi/qla2xxx/qla_def.h2
-rw-r--r--drivers/scsi/qla2xxx/qla_gbl.h3
-rw-r--r--drivers/scsi/qla2xxx/qla_inline.h4
-rw-r--r--drivers/scsi/qla2xxx/qla_isr.c63
-rw-r--r--drivers/scsi/qla2xxx/qla_mbx.c12
-rw-r--r--drivers/scsi/qla2xxx/qla_mid.c19
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c30
-rw-r--r--drivers/scsi/qla2xxx/qla_version.h2
-rw-r--r--drivers/scsi/scsi_lib.c9
-rw-r--r--drivers/scsi/scsi_sysfs.c7
-rw-r--r--drivers/scsi/ses.c2
-rw-r--r--drivers/scsi/sg.c11
-rw-r--r--drivers/scsi/sr.c3
-rw-r--r--drivers/scsi/st.c12
29 files changed, 151 insertions, 124 deletions
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
index eaa805df5b00..7045511f9ad2 100644
--- a/drivers/scsi/3w-9xxx.c
+++ b/drivers/scsi/3w-9xxx.c
@@ -1281,7 +1281,7 @@ static irqreturn_t twa_interrupt(int irq, void *dev_instance)
1281 error = 0; 1281 error = 0;
1282 /* Check for command packet errors */ 1282 /* Check for command packet errors */
1283 if (full_command_packet->command.newcommand.status != 0) { 1283 if (full_command_packet->command.newcommand.status != 0) {
1284 if (tw_dev->srb[request_id] != 0) { 1284 if (tw_dev->srb[request_id] != NULL) {
1285 error = twa_fill_sense(tw_dev, request_id, 1, 1); 1285 error = twa_fill_sense(tw_dev, request_id, 1, 1);
1286 } else { 1286 } else {
1287 /* Skip ioctl error prints */ 1287 /* Skip ioctl error prints */
@@ -1293,7 +1293,7 @@ static irqreturn_t twa_interrupt(int irq, void *dev_instance)
1293 1293
1294 /* Check for correct state */ 1294 /* Check for correct state */
1295 if (tw_dev->state[request_id] != TW_S_POSTED) { 1295 if (tw_dev->state[request_id] != TW_S_POSTED) {
1296 if (tw_dev->srb[request_id] != 0) { 1296 if (tw_dev->srb[request_id] != NULL) {
1297 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1a, "Received a request id that wasn't posted"); 1297 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1a, "Received a request id that wasn't posted");
1298 TW_CLEAR_ALL_INTERRUPTS(tw_dev); 1298 TW_CLEAR_ALL_INTERRUPTS(tw_dev);
1299 goto twa_interrupt_bail; 1299 goto twa_interrupt_bail;
@@ -1301,7 +1301,7 @@ static irqreturn_t twa_interrupt(int irq, void *dev_instance)
1301 } 1301 }
1302 1302
1303 /* Check for internal command completion */ 1303 /* Check for internal command completion */
1304 if (tw_dev->srb[request_id] == 0) { 1304 if (tw_dev->srb[request_id] == NULL) {
1305 if (request_id != tw_dev->chrdev_request_id) { 1305 if (request_id != tw_dev->chrdev_request_id) {
1306 if (twa_aen_complete(tw_dev, request_id)) 1306 if (twa_aen_complete(tw_dev, request_id))
1307 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1b, "Error completing AEN during attention interrupt"); 1307 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1b, "Error completing AEN during attention interrupt");
diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
index 1dca1775f4b1..0899cb61e3dd 100644
--- a/drivers/scsi/aha152x.c
+++ b/drivers/scsi/aha152x.c
@@ -3582,7 +3582,7 @@ static int checksetup(struct aha152x_setup *setup)
3582 if (i == ARRAY_SIZE(ports)) 3582 if (i == ARRAY_SIZE(ports))
3583 return 0; 3583 return 0;
3584 3584
3585 if ( request_region(setup->io_port, IO_RANGE, "aha152x")==0 ) { 3585 if (!request_region(setup->io_port, IO_RANGE, "aha152x")) {
3586 printk(KERN_ERR "aha152x: io port 0x%x busy.\n", setup->io_port); 3586 printk(KERN_ERR "aha152x: io port 0x%x busy.\n", setup->io_port);
3587 return 0; 3587 return 0;
3588 } 3588 }
@@ -3842,7 +3842,7 @@ static int __init aha152x_init(void)
3842 if ((setup_count == 1) && (setup[0].io_port == ports[i])) 3842 if ((setup_count == 1) && (setup[0].io_port == ports[i]))
3843 continue; 3843 continue;
3844 3844
3845 if ( request_region(ports[i], IO_RANGE, "aha152x")==0 ) { 3845 if (!request_region(ports[i], IO_RANGE, "aha152x")) {
3846 printk(KERN_ERR "aha152x: io port 0x%x busy.\n", ports[i]); 3846 printk(KERN_ERR "aha152x: io port 0x%x busy.\n", ports[i]);
3847 continue; 3847 continue;
3848 } 3848 }
diff --git a/drivers/scsi/atp870u.c b/drivers/scsi/atp870u.c
index db6de5e6afb3..7d311541c76c 100644
--- a/drivers/scsi/atp870u.c
+++ b/drivers/scsi/atp870u.c
@@ -747,7 +747,7 @@ static void send_s870(struct atp_unit *dev,unsigned char c)
747 dev->quhd[c] = 0; 747 dev->quhd[c] = 0;
748 } 748 }
749 workreq = dev->quereq[c][dev->quhd[c]]; 749 workreq = dev->quereq[c][dev->quhd[c]];
750 if (dev->id[c][scmd_id(workreq)].curr_req == 0) { 750 if (dev->id[c][scmd_id(workreq)].curr_req == NULL) {
751 dev->id[c][scmd_id(workreq)].curr_req = workreq; 751 dev->id[c][scmd_id(workreq)].curr_req = workreq;
752 dev->last_cmd[c] = scmd_id(workreq); 752 dev->last_cmd[c] = scmd_id(workreq);
753 goto cmd_subp; 753 goto cmd_subp;
diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
index 8e821be380f4..aa2011b64683 100644
--- a/drivers/scsi/ch.c
+++ b/drivers/scsi/ch.c
@@ -914,9 +914,9 @@ static int ch_probe(struct device *dev)
914 ch->minor = minor; 914 ch->minor = minor;
915 sprintf(ch->name,"ch%d",ch->minor); 915 sprintf(ch->name,"ch%d",ch->minor);
916 916
917 class_dev = device_create(ch_sysfs_class, dev, 917 class_dev = device_create_drvdata(ch_sysfs_class, dev,
918 MKDEV(SCSI_CHANGER_MAJOR,ch->minor), 918 MKDEV(SCSI_CHANGER_MAJOR, ch->minor),
919 "s%s", ch->name); 919 ch, "s%s", ch->name);
920 if (IS_ERR(class_dev)) { 920 if (IS_ERR(class_dev)) {
921 printk(KERN_WARNING "ch%d: device_create failed\n", 921 printk(KERN_WARNING "ch%d: device_create failed\n",
922 ch->minor); 922 ch->minor);
@@ -930,7 +930,6 @@ static int ch_probe(struct device *dev)
930 if (init) 930 if (init)
931 ch_init_elem(ch); 931 ch_init_elem(ch);
932 932
933 dev_set_drvdata(dev, ch);
934 sdev_printk(KERN_INFO, sd, "Attached scsi changer %s\n", ch->name); 933 sdev_printk(KERN_INFO, sd, "Attached scsi changer %s\n", ch->name);
935 934
936 return 0; 935 return 0;
diff --git a/drivers/scsi/dpt/dptsig.h b/drivers/scsi/dpt/dptsig.h
index 72c8992fdf21..a6644b332b53 100644
--- a/drivers/scsi/dpt/dptsig.h
+++ b/drivers/scsi/dpt/dptsig.h
@@ -85,7 +85,7 @@ typedef unsigned int sigINT;
85/* ------------------------------------------------------------------ */ 85/* ------------------------------------------------------------------ */
86/* What type of processor the file is meant to run on. */ 86/* What type of processor the file is meant to run on. */
87/* This will let us know whether to read sigWORDs as high/low or low/high. */ 87/* This will let us know whether to read sigWORDs as high/low or low/high. */
88#define PROC_INTEL 0x00 /* Intel 80x86 */ 88#define PROC_INTEL 0x00 /* Intel 80x86/ia64 */
89#define PROC_MOTOROLA 0x01 /* Motorola 68K */ 89#define PROC_MOTOROLA 0x01 /* Motorola 68K */
90#define PROC_MIPS4000 0x02 /* MIPS RISC 4000 */ 90#define PROC_MIPS4000 0x02 /* MIPS RISC 4000 */
91#define PROC_ALPHA 0x03 /* DEC Alpha */ 91#define PROC_ALPHA 0x03 /* DEC Alpha */
@@ -104,6 +104,7 @@ typedef unsigned int sigINT;
104#define PROC_486 0x08 /* Intel 80486 */ 104#define PROC_486 0x08 /* Intel 80486 */
105#define PROC_PENTIUM 0x10 /* Intel 586 aka P5 aka Pentium */ 105#define PROC_PENTIUM 0x10 /* Intel 586 aka P5 aka Pentium */
106#define PROC_SEXIUM 0x20 /* Intel 686 aka P6 aka Pentium Pro or MMX */ 106#define PROC_SEXIUM 0x20 /* Intel 686 aka P6 aka Pentium Pro or MMX */
107#define PROC_IA64 0x40 /* Intel IA64 processor */
107 108
108/* PROC_i960: */ 109/* PROC_i960: */
109#define PROC_960RX 0x01 /* Intel 80960RC/RD */ 110#define PROC_960RX 0x01 /* Intel 80960RC/RD */
diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c
index a0b6d414953d..59fbef08d690 100644
--- a/drivers/scsi/esp_scsi.c
+++ b/drivers/scsi/esp_scsi.c
@@ -2359,6 +2359,24 @@ void scsi_esp_unregister(struct esp *esp)
2359} 2359}
2360EXPORT_SYMBOL(scsi_esp_unregister); 2360EXPORT_SYMBOL(scsi_esp_unregister);
2361 2361
2362static int esp_target_alloc(struct scsi_target *starget)
2363{
2364 struct esp *esp = shost_priv(dev_to_shost(&starget->dev));
2365 struct esp_target_data *tp = &esp->target[starget->id];
2366
2367 tp->starget = starget;
2368
2369 return 0;
2370}
2371
2372static void esp_target_destroy(struct scsi_target *starget)
2373{
2374 struct esp *esp = shost_priv(dev_to_shost(&starget->dev));
2375 struct esp_target_data *tp = &esp->target[starget->id];
2376
2377 tp->starget = NULL;
2378}
2379
2362static int esp_slave_alloc(struct scsi_device *dev) 2380static int esp_slave_alloc(struct scsi_device *dev)
2363{ 2381{
2364 struct esp *esp = shost_priv(dev->host); 2382 struct esp *esp = shost_priv(dev->host);
@@ -2370,8 +2388,6 @@ static int esp_slave_alloc(struct scsi_device *dev)
2370 return -ENOMEM; 2388 return -ENOMEM;
2371 dev->hostdata = lp; 2389 dev->hostdata = lp;
2372 2390
2373 tp->starget = dev->sdev_target;
2374
2375 spi_min_period(tp->starget) = esp->min_period; 2391 spi_min_period(tp->starget) = esp->min_period;
2376 spi_max_offset(tp->starget) = 15; 2392 spi_max_offset(tp->starget) = 15;
2377 2393
@@ -2608,6 +2624,8 @@ struct scsi_host_template scsi_esp_template = {
2608 .name = "esp", 2624 .name = "esp",
2609 .info = esp_info, 2625 .info = esp_info,
2610 .queuecommand = esp_queuecommand, 2626 .queuecommand = esp_queuecommand,
2627 .target_alloc = esp_target_alloc,
2628 .target_destroy = esp_target_destroy,
2611 .slave_alloc = esp_slave_alloc, 2629 .slave_alloc = esp_slave_alloc,
2612 .slave_configure = esp_slave_configure, 2630 .slave_configure = esp_slave_configure,
2613 .slave_destroy = esp_slave_destroy, 2631 .slave_destroy = esp_slave_destroy,
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 3690360d7a79..c6457bfc8a49 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -456,6 +456,10 @@ static int __scsi_host_match(struct device *dev, void *data)
456 * 456 *
457 * Return value: 457 * Return value:
458 * A pointer to located Scsi_Host or NULL. 458 * A pointer to located Scsi_Host or NULL.
459 *
460 * The caller must do a scsi_host_put() to drop the reference
461 * that scsi_host_get() took. The put_device() below dropped
462 * the reference from class_find_device().
459 **/ 463 **/
460struct Scsi_Host *scsi_host_lookup(unsigned short hostnum) 464struct Scsi_Host *scsi_host_lookup(unsigned short hostnum)
461{ 465{
@@ -463,9 +467,10 @@ struct Scsi_Host *scsi_host_lookup(unsigned short hostnum)
463 struct Scsi_Host *shost = ERR_PTR(-ENXIO); 467 struct Scsi_Host *shost = ERR_PTR(-ENXIO);
464 468
465 cdev = class_find_device(&shost_class, &hostnum, __scsi_host_match); 469 cdev = class_find_device(&shost_class, &hostnum, __scsi_host_match);
466 if (cdev) 470 if (cdev) {
467 shost = scsi_host_get(class_to_shost(cdev)); 471 shost = scsi_host_get(class_to_shost(cdev));
468 472 put_device(cdev);
473 }
469 return shost; 474 return shost;
470} 475}
471EXPORT_SYMBOL(scsi_host_lookup); 476EXPORT_SYMBOL(scsi_host_lookup);
diff --git a/drivers/scsi/hptiop.c b/drivers/scsi/hptiop.c
index aaa48e0c8ed0..da876d3924be 100644
--- a/drivers/scsi/hptiop.c
+++ b/drivers/scsi/hptiop.c
@@ -444,7 +444,7 @@ static void __iomem *hptiop_map_pci_bar(struct hptiop_hba *hba, int index)
444 if (!(pci_resource_flags(pcidev, index) & IORESOURCE_MEM)) { 444 if (!(pci_resource_flags(pcidev, index) & IORESOURCE_MEM)) {
445 printk(KERN_ERR "scsi%d: pci resource invalid\n", 445 printk(KERN_ERR "scsi%d: pci resource invalid\n",
446 hba->host->host_no); 446 hba->host->host_no);
447 return 0; 447 return NULL;
448 } 448 }
449 449
450 mem_base_phy = pci_resource_start(pcidev, index); 450 mem_base_phy = pci_resource_start(pcidev, index);
@@ -454,7 +454,7 @@ static void __iomem *hptiop_map_pci_bar(struct hptiop_hba *hba, int index)
454 if (!mem_base_virt) { 454 if (!mem_base_virt) {
455 printk(KERN_ERR "scsi%d: Fail to ioremap memory space\n", 455 printk(KERN_ERR "scsi%d: Fail to ioremap memory space\n",
456 hba->host->host_no); 456 hba->host->host_no);
457 return 0; 457 return NULL;
458 } 458 }
459 return mem_base_virt; 459 return mem_base_virt;
460} 460}
@@ -476,11 +476,11 @@ static void hptiop_unmap_pci_bar_itl(struct hptiop_hba *hba)
476static int hptiop_map_pci_bar_mv(struct hptiop_hba *hba) 476static int hptiop_map_pci_bar_mv(struct hptiop_hba *hba)
477{ 477{
478 hba->u.mv.regs = hptiop_map_pci_bar(hba, 0); 478 hba->u.mv.regs = hptiop_map_pci_bar(hba, 0);
479 if (hba->u.mv.regs == 0) 479 if (hba->u.mv.regs == NULL)
480 return -1; 480 return -1;
481 481
482 hba->u.mv.mu = hptiop_map_pci_bar(hba, 2); 482 hba->u.mv.mu = hptiop_map_pci_bar(hba, 2);
483 if (hba->u.mv.mu == 0) { 483 if (hba->u.mv.mu == NULL) {
484 iounmap(hba->u.mv.regs); 484 iounmap(hba->u.mv.regs);
485 return -1; 485 return -1;
486 } 486 }
@@ -1210,8 +1210,8 @@ static void hptiop_remove(struct pci_dev *pcidev)
1210 1210
1211static struct hptiop_adapter_ops hptiop_itl_ops = { 1211static struct hptiop_adapter_ops hptiop_itl_ops = {
1212 .iop_wait_ready = iop_wait_ready_itl, 1212 .iop_wait_ready = iop_wait_ready_itl,
1213 .internal_memalloc = 0, 1213 .internal_memalloc = NULL,
1214 .internal_memfree = 0, 1214 .internal_memfree = NULL,
1215 .map_pci_bar = hptiop_map_pci_bar_itl, 1215 .map_pci_bar = hptiop_map_pci_bar_itl,
1216 .unmap_pci_bar = hptiop_unmap_pci_bar_itl, 1216 .unmap_pci_bar = hptiop_unmap_pci_bar_itl,
1217 .enable_intr = hptiop_enable_intr_itl, 1217 .enable_intr = hptiop_enable_intr_itl,
diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
index ccfd8aca3765..5d23368a1bce 100644
--- a/drivers/scsi/ibmvscsi/ibmvscsi.c
+++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
@@ -1348,7 +1348,7 @@ void ibmvscsi_handle_crq(struct viosrp_crq *crq,
1348 1348
1349 del_timer(&evt_struct->timer); 1349 del_timer(&evt_struct->timer);
1350 1350
1351 if (crq->status != VIOSRP_OK && evt_struct->cmnd) 1351 if ((crq->status != VIOSRP_OK && crq->status != VIOSRP_OK2) && evt_struct->cmnd)
1352 evt_struct->cmnd->result = DID_ERROR << 16; 1352 evt_struct->cmnd->result = DID_ERROR << 16;
1353 if (evt_struct->done) 1353 if (evt_struct->done)
1354 evt_struct->done(evt_struct); 1354 evt_struct->done(evt_struct);
diff --git a/drivers/scsi/ibmvscsi/viosrp.h b/drivers/scsi/ibmvscsi/viosrp.h
index 4c4aadb3e405..204604501ad8 100644
--- a/drivers/scsi/ibmvscsi/viosrp.h
+++ b/drivers/scsi/ibmvscsi/viosrp.h
@@ -65,7 +65,8 @@ enum viosrp_crq_status {
65 VIOSRP_VIOLATES_MAX_XFER = 0x2, 65 VIOSRP_VIOLATES_MAX_XFER = 0x2,
66 VIOSRP_PARTNER_PANIC = 0x3, 66 VIOSRP_PARTNER_PANIC = 0x3,
67 VIOSRP_DEVICE_BUSY = 0x8, 67 VIOSRP_DEVICE_BUSY = 0x8,
68 VIOSRP_ADAPTER_FAIL = 0x10 68 VIOSRP_ADAPTER_FAIL = 0x10,
69 VIOSRP_OK2 = 0x99,
69}; 70};
70 71
71struct viosrp_crq { 72struct viosrp_crq {
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index 999e91ea7451..e7a3a6554425 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -71,6 +71,7 @@
71#include <linux/module.h> 71#include <linux/module.h>
72#include <linux/moduleparam.h> 72#include <linux/moduleparam.h>
73#include <linux/libata.h> 73#include <linux/libata.h>
74#include <linux/hdreg.h>
74#include <asm/io.h> 75#include <asm/io.h>
75#include <asm/irq.h> 76#include <asm/irq.h>
76#include <asm/processor.h> 77#include <asm/processor.h>
@@ -4913,8 +4914,11 @@ static int ipr_ioctl(struct scsi_device *sdev, int cmd, void __user *arg)
4913 struct ipr_resource_entry *res; 4914 struct ipr_resource_entry *res;
4914 4915
4915 res = (struct ipr_resource_entry *)sdev->hostdata; 4916 res = (struct ipr_resource_entry *)sdev->hostdata;
4916 if (res && ipr_is_gata(res)) 4917 if (res && ipr_is_gata(res)) {
4918 if (cmd == HDIO_GET_IDENTITY)
4919 return -ENOTTY;
4917 return ata_scsi_ioctl(sdev, cmd, arg); 4920 return ata_scsi_ioctl(sdev, cmd, arg);
4921 }
4918 4922
4919 return -EINVAL; 4923 return -EINVAL;
4920} 4924}
diff --git a/drivers/scsi/mac_esp.c b/drivers/scsi/mac_esp.c
index cd37bd69a115..887682a24e36 100644
--- a/drivers/scsi/mac_esp.c
+++ b/drivers/scsi/mac_esp.c
@@ -650,7 +650,7 @@ static void __exit mac_esp_exit(void)
650 650
651MODULE_DESCRIPTION("Mac ESP SCSI driver"); 651MODULE_DESCRIPTION("Mac ESP SCSI driver");
652MODULE_AUTHOR("Finn Thain <fthain@telegraphics.com.au>"); 652MODULE_AUTHOR("Finn Thain <fthain@telegraphics.com.au>");
653MODULE_LICENSE("GPLv2"); 653MODULE_LICENSE("GPL v2");
654MODULE_VERSION(DRV_VERSION); 654MODULE_VERSION(DRV_VERSION);
655 655
656module_init(mac_esp_init); 656module_init(mac_esp_init);
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
index 24ad89a649ce..1c79f9794f4e 100644
--- a/drivers/scsi/osst.c
+++ b/drivers/scsi/osst.c
@@ -5708,13 +5708,12 @@ static int osst_sysfs_add(dev_t dev, struct device *device, struct osst_tape * S
5708 struct device *osst_member; 5708 struct device *osst_member;
5709 int err; 5709 int err;
5710 5710
5711 osst_member = device_create(osst_sysfs_class, device, dev, "%s", name); 5711 osst_member = device_create_drvdata(osst_sysfs_class, device, dev, STp, "%s", name);
5712 if (IS_ERR(osst_member)) { 5712 if (IS_ERR(osst_member)) {
5713 printk(KERN_WARNING "osst :W: Unable to add sysfs class member %s\n", name); 5713 printk(KERN_WARNING "osst :W: Unable to add sysfs class member %s\n", name);
5714 return PTR_ERR(osst_member); 5714 return PTR_ERR(osst_member);
5715 } 5715 }
5716 5716
5717 dev_set_drvdata(osst_member, STp);
5718 err = device_create_file(osst_member, &dev_attr_ADR_rev); 5717 err = device_create_file(osst_member, &dev_attr_ADR_rev);
5719 if (err) 5718 if (err)
5720 goto err_out; 5719 goto err_out;
diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
index 51e2f299dbbb..3754ab87f89a 100644
--- a/drivers/scsi/qla1280.c
+++ b/drivers/scsi/qla1280.c
@@ -2811,7 +2811,7 @@ qla1280_64bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp)
2811 2811
2812 /* Check for room in outstanding command list. */ 2812 /* Check for room in outstanding command list. */
2813 for (cnt = 0; cnt < MAX_OUTSTANDING_COMMANDS && 2813 for (cnt = 0; cnt < MAX_OUTSTANDING_COMMANDS &&
2814 ha->outstanding_cmds[cnt] != 0; cnt++); 2814 ha->outstanding_cmds[cnt] != NULL; cnt++);
2815 2815
2816 if (cnt >= MAX_OUTSTANDING_COMMANDS) { 2816 if (cnt >= MAX_OUTSTANDING_COMMANDS) {
2817 status = 1; 2817 status = 1;
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index 287690853caf..8dd88fc1244a 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -70,6 +70,9 @@ qla2x00_sysfs_write_fw_dump(struct kobject *kobj,
70 case 2: 70 case 2:
71 qla2x00_alloc_fw_dump(ha); 71 qla2x00_alloc_fw_dump(ha);
72 break; 72 break;
73 case 3:
74 qla2x00_system_error(ha);
75 break;
73 } 76 }
74 return (count); 77 return (count);
75} 78}
@@ -886,9 +889,13 @@ qla2x00_get_host_speed(struct Scsi_Host *shost)
886static void 889static void
887qla2x00_get_host_port_type(struct Scsi_Host *shost) 890qla2x00_get_host_port_type(struct Scsi_Host *shost)
888{ 891{
889 scsi_qla_host_t *ha = to_qla_parent(shost_priv(shost)); 892 scsi_qla_host_t *ha = shost_priv(shost);
890 uint32_t port_type = FC_PORTTYPE_UNKNOWN; 893 uint32_t port_type = FC_PORTTYPE_UNKNOWN;
891 894
895 if (ha->parent) {
896 fc_host_port_type(shost) = FC_PORTTYPE_NPIV;
897 return;
898 }
892 switch (ha->current_topology) { 899 switch (ha->current_topology) {
893 case ISP_CFG_NL: 900 case ISP_CFG_NL:
894 port_type = FC_PORTTYPE_LPORT; 901 port_type = FC_PORTTYPE_LPORT;
@@ -1172,10 +1179,10 @@ qla24xx_vport_delete(struct fc_vport *fc_vport)
1172 qla24xx_disable_vp(vha); 1179 qla24xx_disable_vp(vha);
1173 qla24xx_deallocate_vp_id(vha); 1180 qla24xx_deallocate_vp_id(vha);
1174 1181
1175 down(&ha->vport_sem); 1182 mutex_lock(&ha->vport_lock);
1176 ha->cur_vport_count--; 1183 ha->cur_vport_count--;
1177 clear_bit(vha->vp_idx, ha->vp_idx_map); 1184 clear_bit(vha->vp_idx, ha->vp_idx_map);
1178 up(&ha->vport_sem); 1185 mutex_unlock(&ha->vport_lock);
1179 1186
1180 kfree(vha->node_name); 1187 kfree(vha->node_name);
1181 kfree(vha->port_name); 1188 kfree(vha->port_name);
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 299eccf6cabd..8dd600013bd1 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -2457,7 +2457,7 @@ typedef struct scsi_qla_host {
2457#define MBX_INTR_WAIT 2 2457#define MBX_INTR_WAIT 2
2458#define MBX_UPDATE_FLASH_ACTIVE 3 2458#define MBX_UPDATE_FLASH_ACTIVE 3
2459 2459
2460 struct semaphore vport_sem; /* Virtual port synchronization */ 2460 struct mutex vport_lock; /* Virtual port synchronization */
2461 struct completion mbx_cmd_comp; /* Serialize mbx access */ 2461 struct completion mbx_cmd_comp; /* Serialize mbx access */
2462 struct completion mbx_intr_comp; /* Used for completion notification */ 2462 struct completion mbx_intr_comp; /* Used for completion notification */
2463 2463
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index f8827068d30f..9b4bebee6879 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -228,6 +228,9 @@ extern int qla24xx_abort_target(struct fc_port *, unsigned int);
228extern int qla24xx_lun_reset(struct fc_port *, unsigned int); 228extern int qla24xx_lun_reset(struct fc_port *, unsigned int);
229 229
230extern int 230extern int
231qla2x00_system_error(scsi_qla_host_t *);
232
233extern int
231qla2x00_set_serdes_params(scsi_qla_host_t *, uint16_t, uint16_t, uint16_t); 234qla2x00_set_serdes_params(scsi_qla_host_t *, uint16_t, uint16_t, uint16_t);
232 235
233extern int 236extern int
diff --git a/drivers/scsi/qla2xxx/qla_inline.h b/drivers/scsi/qla2xxx/qla_inline.h
index e9bae27737d1..92fafbdbbaab 100644
--- a/drivers/scsi/qla2xxx/qla_inline.h
+++ b/drivers/scsi/qla2xxx/qla_inline.h
@@ -34,7 +34,11 @@ qla2x00_debounce_register(volatile uint16_t __iomem *addr)
34static inline void 34static inline void
35qla2x00_poll(scsi_qla_host_t *ha) 35qla2x00_poll(scsi_qla_host_t *ha)
36{ 36{
37 unsigned long flags;
38
39 local_irq_save(flags);
37 ha->isp_ops->intr_handler(0, ha); 40 ha->isp_ops->intr_handler(0, ha);
41 local_irq_restore(flags);
38} 42}
39 43
40static __inline__ scsi_qla_host_t * 44static __inline__ scsi_qla_host_t *
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 5d9a64a7879b..ec63b79f900a 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -272,8 +272,6 @@ qla2x00_async_event(scsi_qla_host_t *ha, uint16_t *mb)
272 uint32_t rscn_entry, host_pid; 272 uint32_t rscn_entry, host_pid;
273 uint8_t rscn_queue_index; 273 uint8_t rscn_queue_index;
274 unsigned long flags; 274 unsigned long flags;
275 scsi_qla_host_t *vha;
276 int i;
277 275
278 /* Setup to process RIO completion. */ 276 /* Setup to process RIO completion. */
279 handle_cnt = 0; 277 handle_cnt = 0;
@@ -544,18 +542,10 @@ qla2x00_async_event(scsi_qla_host_t *ha, uint16_t *mb)
544 break; 542 break;
545 543
546 case MBA_PORT_UPDATE: /* Port database update */ 544 case MBA_PORT_UPDATE: /* Port database update */
547 if ((ha->flags.npiv_supported) && (ha->num_vhosts)) { 545 /* Only handle SCNs for our Vport index. */
548 for_each_mapped_vp_idx(ha, i) { 546 if (ha->parent && ha->vp_idx != (mb[3] & 0xff))
549 list_for_each_entry(vha, &ha->vp_list, 547 break;
550 vp_list) { 548
551 if ((mb[3] & 0xff)
552 == vha->vp_idx) {
553 ha = vha;
554 break;
555 }
556 }
557 }
558 }
559 /* 549 /*
560 * If PORT UPDATE is global (recieved LIP_OCCURED/LIP_RESET 550 * If PORT UPDATE is global (recieved LIP_OCCURED/LIP_RESET
561 * event etc. earlier indicating loop is down) then process 551 * event etc. earlier indicating loop is down) then process
@@ -590,18 +580,12 @@ qla2x00_async_event(scsi_qla_host_t *ha, uint16_t *mb)
590 break; 580 break;
591 581
592 case MBA_RSCN_UPDATE: /* State Change Registration */ 582 case MBA_RSCN_UPDATE: /* State Change Registration */
593 if ((ha->flags.npiv_supported) && (ha->num_vhosts)) { 583 /* Check if the Vport has issued a SCR */
594 for_each_mapped_vp_idx(ha, i) { 584 if (ha->parent && test_bit(VP_SCR_NEEDED, &ha->vp_flags))
595 list_for_each_entry(vha, &ha->vp_list, 585 break;
596 vp_list) { 586 /* Only handle SCNs for our Vport index. */
597 if ((mb[3] & 0xff) 587 if (ha->parent && ha->vp_idx != (mb[3] & 0xff))
598 == vha->vp_idx) { 588 break;
599 ha = vha;
600 break;
601 }
602 }
603 }
604 }
605 589
606 DEBUG2(printk("scsi(%ld): Asynchronous RSCR UPDATE.\n", 590 DEBUG2(printk("scsi(%ld): Asynchronous RSCR UPDATE.\n",
607 ha->host_no)); 591 ha->host_no));
@@ -1132,25 +1116,6 @@ qla2x00_status_entry(scsi_qla_host_t *ha, void *pkt)
1132 break; 1116 break;
1133 1117
1134 qla2x00_handle_sense(sp, sense_data, sense_len); 1118 qla2x00_handle_sense(sp, sense_data, sense_len);
1135
1136 /*
1137 * In case of a Underrun condition, set both the lscsi
1138 * status and the completion status to appropriate
1139 * values.
1140 */
1141 if (resid &&
1142 ((unsigned)(scsi_bufflen(cp) - resid) <
1143 cp->underflow)) {
1144 DEBUG2(qla_printk(KERN_INFO, ha,
1145 "scsi(%ld:%d:%d:%d): Mid-layer underflow "
1146 "detected (%x of %x bytes)...returning "
1147 "error status.\n", ha->host_no,
1148 cp->device->channel, cp->device->id,
1149 cp->device->lun, resid,
1150 scsi_bufflen(cp)));
1151
1152 cp->result = DID_ERROR << 16 | lscsi_status;
1153 }
1154 } else { 1119 } else {
1155 /* 1120 /*
1156 * If RISC reports underrun and target does not report 1121 * If RISC reports underrun and target does not report
@@ -1639,12 +1604,12 @@ qla24xx_msix_rsp_q(int irq, void *dev_id)
1639 ha = dev_id; 1604 ha = dev_id;
1640 reg = &ha->iobase->isp24; 1605 reg = &ha->iobase->isp24;
1641 1606
1642 spin_lock(&ha->hardware_lock); 1607 spin_lock_irq(&ha->hardware_lock);
1643 1608
1644 qla24xx_process_response_queue(ha); 1609 qla24xx_process_response_queue(ha);
1645 WRT_REG_DWORD(&reg->hccr, HCCRX_CLR_RISC_INT); 1610 WRT_REG_DWORD(&reg->hccr, HCCRX_CLR_RISC_INT);
1646 1611
1647 spin_unlock(&ha->hardware_lock); 1612 spin_unlock_irq(&ha->hardware_lock);
1648 1613
1649 return IRQ_HANDLED; 1614 return IRQ_HANDLED;
1650} 1615}
@@ -1663,7 +1628,7 @@ qla24xx_msix_default(int irq, void *dev_id)
1663 reg = &ha->iobase->isp24; 1628 reg = &ha->iobase->isp24;
1664 status = 0; 1629 status = 0;
1665 1630
1666 spin_lock(&ha->hardware_lock); 1631 spin_lock_irq(&ha->hardware_lock);
1667 do { 1632 do {
1668 stat = RD_REG_DWORD(&reg->host_status); 1633 stat = RD_REG_DWORD(&reg->host_status);
1669 if (stat & HSRX_RISC_PAUSED) { 1634 if (stat & HSRX_RISC_PAUSED) {
@@ -1716,7 +1681,7 @@ qla24xx_msix_default(int irq, void *dev_id)
1716 } 1681 }
1717 WRT_REG_DWORD(&reg->hccr, HCCRX_CLR_RISC_INT); 1682 WRT_REG_DWORD(&reg->hccr, HCCRX_CLR_RISC_INT);
1718 } while (0); 1683 } while (0);
1719 spin_unlock(&ha->hardware_lock); 1684 spin_unlock_irq(&ha->hardware_lock);
1720 1685
1721 if (test_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags) && 1686 if (test_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags) &&
1722 (status & MBX_INTERRUPT) && ha->flags.mbox_int) { 1687 (status & MBX_INTERRUPT) && ha->flags.mbox_int) {
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index 210060420809..250d2f604397 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -2303,8 +2303,6 @@ qla24xx_lun_reset(struct fc_port *fcport, unsigned int l)
2303 return __qla24xx_issue_tmf("Lun", TCF_LUN_RESET, fcport, l); 2303 return __qla24xx_issue_tmf("Lun", TCF_LUN_RESET, fcport, l);
2304} 2304}
2305 2305
2306#if 0
2307
2308int 2306int
2309qla2x00_system_error(scsi_qla_host_t *ha) 2307qla2x00_system_error(scsi_qla_host_t *ha)
2310{ 2308{
@@ -2312,7 +2310,7 @@ qla2x00_system_error(scsi_qla_host_t *ha)
2312 mbx_cmd_t mc; 2310 mbx_cmd_t mc;
2313 mbx_cmd_t *mcp = &mc; 2311 mbx_cmd_t *mcp = &mc;
2314 2312
2315 if (!IS_FWI2_CAPABLE(ha)) 2313 if (!IS_QLA23XX(ha) && !IS_FWI2_CAPABLE(ha))
2316 return QLA_FUNCTION_FAILED; 2314 return QLA_FUNCTION_FAILED;
2317 2315
2318 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2316 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
@@ -2334,8 +2332,6 @@ qla2x00_system_error(scsi_qla_host_t *ha)
2334 return rval; 2332 return rval;
2335} 2333}
2336 2334
2337#endif /* 0 */
2338
2339/** 2335/**
2340 * qla2x00_set_serdes_params() - 2336 * qla2x00_set_serdes_params() -
2341 * @ha: HA context 2337 * @ha: HA context
@@ -2508,7 +2504,7 @@ qla2x00_enable_fce_trace(scsi_qla_host_t *ha, dma_addr_t fce_dma,
2508 if (mb) 2504 if (mb)
2509 memcpy(mb, mcp->mb, 8 * sizeof(*mb)); 2505 memcpy(mb, mcp->mb, 8 * sizeof(*mb));
2510 if (dwords) 2506 if (dwords)
2511 *dwords = mcp->mb[6]; 2507 *dwords = buffers;
2512 } 2508 }
2513 2509
2514 return rval; 2510 return rval;
@@ -2807,9 +2803,9 @@ qla24xx_control_vp(scsi_qla_host_t *vha, int cmd)
2807 */ 2803 */
2808 map = (vp_index - 1) / 8; 2804 map = (vp_index - 1) / 8;
2809 pos = (vp_index - 1) & 7; 2805 pos = (vp_index - 1) & 7;
2810 down(&ha->vport_sem); 2806 mutex_lock(&ha->vport_lock);
2811 vce->vp_idx_map[map] |= 1 << pos; 2807 vce->vp_idx_map[map] |= 1 << pos;
2812 up(&ha->vport_sem); 2808 mutex_unlock(&ha->vport_lock);
2813 2809
2814 rval = qla2x00_issue_iocb(ha, vce, vce_dma, 0); 2810 rval = qla2x00_issue_iocb(ha, vce, vce_dma, 0);
2815 if (rval != QLA_SUCCESS) { 2811 if (rval != QLA_SUCCESS) {
diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c
index f2b04979e5f0..62a3ad6e8ecb 100644
--- a/drivers/scsi/qla2xxx/qla_mid.c
+++ b/drivers/scsi/qla2xxx/qla_mid.c
@@ -32,12 +32,12 @@ qla24xx_allocate_vp_id(scsi_qla_host_t *vha)
32 scsi_qla_host_t *ha = vha->parent; 32 scsi_qla_host_t *ha = vha->parent;
33 33
34 /* Find an empty slot and assign an vp_id */ 34 /* Find an empty slot and assign an vp_id */
35 down(&ha->vport_sem); 35 mutex_lock(&ha->vport_lock);
36 vp_id = find_first_zero_bit(ha->vp_idx_map, ha->max_npiv_vports + 1); 36 vp_id = find_first_zero_bit(ha->vp_idx_map, ha->max_npiv_vports + 1);
37 if (vp_id > ha->max_npiv_vports) { 37 if (vp_id > ha->max_npiv_vports) {
38 DEBUG15(printk ("vp_id %d is bigger than max-supported %d.\n", 38 DEBUG15(printk ("vp_id %d is bigger than max-supported %d.\n",
39 vp_id, ha->max_npiv_vports)); 39 vp_id, ha->max_npiv_vports));
40 up(&ha->vport_sem); 40 mutex_unlock(&ha->vport_lock);
41 return vp_id; 41 return vp_id;
42 } 42 }
43 43
@@ -45,7 +45,7 @@ qla24xx_allocate_vp_id(scsi_qla_host_t *vha)
45 ha->num_vhosts++; 45 ha->num_vhosts++;
46 vha->vp_idx = vp_id; 46 vha->vp_idx = vp_id;
47 list_add_tail(&vha->vp_list, &ha->vp_list); 47 list_add_tail(&vha->vp_list, &ha->vp_list);
48 up(&ha->vport_sem); 48 mutex_unlock(&ha->vport_lock);
49 return vp_id; 49 return vp_id;
50} 50}
51 51
@@ -55,12 +55,12 @@ qla24xx_deallocate_vp_id(scsi_qla_host_t *vha)
55 uint16_t vp_id; 55 uint16_t vp_id;
56 scsi_qla_host_t *ha = vha->parent; 56 scsi_qla_host_t *ha = vha->parent;
57 57
58 down(&ha->vport_sem); 58 mutex_lock(&ha->vport_lock);
59 vp_id = vha->vp_idx; 59 vp_id = vha->vp_idx;
60 ha->num_vhosts--; 60 ha->num_vhosts--;
61 clear_bit(vp_id, ha->vp_idx_map); 61 clear_bit(vp_id, ha->vp_idx_map);
62 list_del(&vha->vp_list); 62 list_del(&vha->vp_list);
63 up(&ha->vport_sem); 63 mutex_unlock(&ha->vport_lock);
64} 64}
65 65
66static scsi_qla_host_t * 66static scsi_qla_host_t *
@@ -145,9 +145,9 @@ qla24xx_enable_vp(scsi_qla_host_t *vha)
145 } 145 }
146 146
147 /* Initialize the new vport unless it is a persistent port */ 147 /* Initialize the new vport unless it is a persistent port */
148 down(&ha->vport_sem); 148 mutex_lock(&ha->vport_lock);
149 ret = qla24xx_modify_vp_config(vha); 149 ret = qla24xx_modify_vp_config(vha);
150 up(&ha->vport_sem); 150 mutex_unlock(&ha->vport_lock);
151 151
152 if (ret != QLA_SUCCESS) { 152 if (ret != QLA_SUCCESS) {
153 fc_vport_set_state(vha->fc_vport, FC_VPORT_FAILED); 153 fc_vport_set_state(vha->fc_vport, FC_VPORT_FAILED);
@@ -406,6 +406,7 @@ qla24xx_create_vhost(struct fc_vport *fc_vport)
406 INIT_LIST_HEAD(&vha->list); 406 INIT_LIST_HEAD(&vha->list);
407 INIT_LIST_HEAD(&vha->fcports); 407 INIT_LIST_HEAD(&vha->fcports);
408 INIT_LIST_HEAD(&vha->vp_fcports); 408 INIT_LIST_HEAD(&vha->vp_fcports);
409 INIT_LIST_HEAD(&vha->work_list);
409 410
410 vha->dpc_flags = 0L; 411 vha->dpc_flags = 0L;
411 set_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags); 412 set_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags);
@@ -437,10 +438,10 @@ qla24xx_create_vhost(struct fc_vport *fc_vport)
437 vha->flags.init_done = 1; 438 vha->flags.init_done = 1;
438 num_hosts++; 439 num_hosts++;
439 440
440 down(&ha->vport_sem); 441 mutex_lock(&ha->vport_lock);
441 set_bit(vha->vp_idx, ha->vp_idx_map); 442 set_bit(vha->vp_idx, ha->vp_idx_map);
442 ha->cur_vport_count++; 443 ha->cur_vport_count++;
443 up(&ha->vport_sem); 444 mutex_unlock(&ha->vport_lock);
444 445
445 return vha; 446 return vha;
446 447
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 3223fd16bcfe..48eaa3bb5433 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -10,6 +10,7 @@
10#include <linux/vmalloc.h> 10#include <linux/vmalloc.h>
11#include <linux/delay.h> 11#include <linux/delay.h>
12#include <linux/kthread.h> 12#include <linux/kthread.h>
13#include <linux/mutex.h>
13 14
14#include <scsi/scsi_tcq.h> 15#include <scsi/scsi_tcq.h>
15#include <scsi/scsicam.h> 16#include <scsi/scsicam.h>
@@ -1631,7 +1632,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1631 /* load the F/W, read paramaters, and init the H/W */ 1632 /* load the F/W, read paramaters, and init the H/W */
1632 ha->instance = num_hosts; 1633 ha->instance = num_hosts;
1633 1634
1634 init_MUTEX(&ha->vport_sem); 1635 mutex_init(&ha->vport_lock);
1635 init_completion(&ha->mbx_cmd_comp); 1636 init_completion(&ha->mbx_cmd_comp);
1636 complete(&ha->mbx_cmd_comp); 1637 complete(&ha->mbx_cmd_comp);
1637 init_completion(&ha->mbx_intr_comp); 1638 init_completion(&ha->mbx_intr_comp);
@@ -2156,13 +2157,14 @@ static int
2156qla2x00_post_work(struct scsi_qla_host *ha, struct qla_work_evt *e, int locked) 2157qla2x00_post_work(struct scsi_qla_host *ha, struct qla_work_evt *e, int locked)
2157{ 2158{
2158 unsigned long flags; 2159 unsigned long flags;
2160 scsi_qla_host_t *pha = to_qla_parent(ha);
2159 2161
2160 if (!locked) 2162 if (!locked)
2161 spin_lock_irqsave(&ha->hardware_lock, flags); 2163 spin_lock_irqsave(&pha->hardware_lock, flags);
2162 list_add_tail(&e->list, &ha->work_list); 2164 list_add_tail(&e->list, &ha->work_list);
2163 qla2xxx_wake_dpc(ha); 2165 qla2xxx_wake_dpc(ha);
2164 if (!locked) 2166 if (!locked)
2165 spin_unlock_irqrestore(&ha->hardware_lock, flags); 2167 spin_unlock_irqrestore(&pha->hardware_lock, flags);
2166 return QLA_SUCCESS; 2168 return QLA_SUCCESS;
2167} 2169}
2168 2170
@@ -2202,12 +2204,13 @@ static void
2202qla2x00_do_work(struct scsi_qla_host *ha) 2204qla2x00_do_work(struct scsi_qla_host *ha)
2203{ 2205{
2204 struct qla_work_evt *e; 2206 struct qla_work_evt *e;
2207 scsi_qla_host_t *pha = to_qla_parent(ha);
2205 2208
2206 spin_lock_irq(&ha->hardware_lock); 2209 spin_lock_irq(&pha->hardware_lock);
2207 while (!list_empty(&ha->work_list)) { 2210 while (!list_empty(&ha->work_list)) {
2208 e = list_entry(ha->work_list.next, struct qla_work_evt, list); 2211 e = list_entry(ha->work_list.next, struct qla_work_evt, list);
2209 list_del_init(&e->list); 2212 list_del_init(&e->list);
2210 spin_unlock_irq(&ha->hardware_lock); 2213 spin_unlock_irq(&pha->hardware_lock);
2211 2214
2212 switch (e->type) { 2215 switch (e->type) {
2213 case QLA_EVT_AEN: 2216 case QLA_EVT_AEN:
@@ -2221,9 +2224,9 @@ qla2x00_do_work(struct scsi_qla_host *ha)
2221 } 2224 }
2222 if (e->flags & QLA_EVT_FLAG_FREE) 2225 if (e->flags & QLA_EVT_FLAG_FREE)
2223 kfree(e); 2226 kfree(e);
2224 spin_lock_irq(&ha->hardware_lock); 2227 spin_lock_irq(&pha->hardware_lock);
2225 } 2228 }
2226 spin_unlock_irq(&ha->hardware_lock); 2229 spin_unlock_irq(&pha->hardware_lock);
2227} 2230}
2228 2231
2229/************************************************************************** 2232/**************************************************************************
@@ -2634,7 +2637,7 @@ qla2x00_timer(scsi_qla_host_t *ha)
2634#define FW_FILE_ISP24XX "ql2400_fw.bin" 2637#define FW_FILE_ISP24XX "ql2400_fw.bin"
2635#define FW_FILE_ISP25XX "ql2500_fw.bin" 2638#define FW_FILE_ISP25XX "ql2500_fw.bin"
2636 2639
2637static DECLARE_MUTEX(qla_fw_lock); 2640static DEFINE_MUTEX(qla_fw_lock);
2638 2641
2639static struct fw_blob qla_fw_blobs[FW_BLOBS] = { 2642static struct fw_blob qla_fw_blobs[FW_BLOBS] = {
2640 { .name = FW_FILE_ISP21XX, .segs = { 0x1000, 0 }, }, 2643 { .name = FW_FILE_ISP21XX, .segs = { 0x1000, 0 }, },
@@ -2665,7 +2668,7 @@ qla2x00_request_firmware(scsi_qla_host_t *ha)
2665 blob = &qla_fw_blobs[FW_ISP25XX]; 2668 blob = &qla_fw_blobs[FW_ISP25XX];
2666 } 2669 }
2667 2670
2668 down(&qla_fw_lock); 2671 mutex_lock(&qla_fw_lock);
2669 if (blob->fw) 2672 if (blob->fw)
2670 goto out; 2673 goto out;
2671 2674
@@ -2678,7 +2681,7 @@ qla2x00_request_firmware(scsi_qla_host_t *ha)
2678 } 2681 }
2679 2682
2680out: 2683out:
2681 up(&qla_fw_lock); 2684 mutex_unlock(&qla_fw_lock);
2682 return blob; 2685 return blob;
2683} 2686}
2684 2687
@@ -2687,11 +2690,11 @@ qla2x00_release_firmware(void)
2687{ 2690{
2688 int idx; 2691 int idx;
2689 2692
2690 down(&qla_fw_lock); 2693 mutex_lock(&qla_fw_lock);
2691 for (idx = 0; idx < FW_BLOBS; idx++) 2694 for (idx = 0; idx < FW_BLOBS; idx++)
2692 if (qla_fw_blobs[idx].fw) 2695 if (qla_fw_blobs[idx].fw)
2693 release_firmware(qla_fw_blobs[idx].fw); 2696 release_firmware(qla_fw_blobs[idx].fw);
2694 up(&qla_fw_lock); 2697 mutex_unlock(&qla_fw_lock);
2695} 2698}
2696 2699
2697static pci_ers_result_t 2700static pci_ers_result_t
@@ -2864,7 +2867,8 @@ qla2x00_module_init(void)
2864 return -ENODEV; 2867 return -ENODEV;
2865 } 2868 }
2866 2869
2867 printk(KERN_INFO "QLogic Fibre Channel HBA Driver\n"); 2870 printk(KERN_INFO "QLogic Fibre Channel HBA Driver: %s\n",
2871 qla2x00_version_str);
2868 ret = pci_register_driver(&qla2xxx_pci_driver); 2872 ret = pci_register_driver(&qla2xxx_pci_driver);
2869 if (ret) { 2873 if (ret) {
2870 kmem_cache_destroy(srb_cachep); 2874 kmem_cache_destroy(srb_cachep);
diff --git a/drivers/scsi/qla2xxx/qla_version.h b/drivers/scsi/qla2xxx/qla_version.h
index afeae2bfe7eb..d058c8862b35 100644
--- a/drivers/scsi/qla2xxx/qla_version.h
+++ b/drivers/scsi/qla2xxx/qla_version.h
@@ -7,7 +7,7 @@
7/* 7/*
8 * Driver version 8 * Driver version
9 */ 9 */
10#define QLA2XXX_VERSION "8.02.01-k2" 10#define QLA2XXX_VERSION "8.02.01-k4"
11 11
12#define QLA_DRIVER_MAJOR_VER 8 12#define QLA_DRIVER_MAJOR_VER 8
13#define QLA_DRIVER_MINOR_VER 2 13#define QLA_DRIVER_MINOR_VER 2
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index a82d2fe80fb5..cbf55d59a54c 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -207,6 +207,15 @@ int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
207 */ 207 */
208 blk_execute_rq(req->q, NULL, req, 1); 208 blk_execute_rq(req->q, NULL, req, 1);
209 209
210 /*
211 * Some devices (USB mass-storage in particular) may transfer
212 * garbage data together with a residue indicating that the data
213 * is invalid. Prevent the garbage from being misinterpreted
214 * and prevent security leaks by zeroing out the excess data.
215 */
216 if (unlikely(req->data_len > 0 && req->data_len <= bufflen))
217 memset(buffer + (bufflen - req->data_len), 0, req->data_len);
218
210 ret = req->errors; 219 ret = req->errors;
211 out: 220 out:
212 blk_put_request(req); 221 blk_put_request(req);
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 049103f1d16f..93d2b6714453 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -359,7 +359,12 @@ static int scsi_bus_match(struct device *dev, struct device_driver *gendrv)
359 359
360static int scsi_bus_uevent(struct device *dev, struct kobj_uevent_env *env) 360static int scsi_bus_uevent(struct device *dev, struct kobj_uevent_env *env)
361{ 361{
362 struct scsi_device *sdev = to_scsi_device(dev); 362 struct scsi_device *sdev;
363
364 if (dev->type != &scsi_dev_type)
365 return 0;
366
367 sdev = to_scsi_device(dev);
363 368
364 add_uevent_var(env, "MODALIAS=" SCSI_DEVICE_MODALIAS_FMT, sdev->type); 369 add_uevent_var(env, "MODALIAS=" SCSI_DEVICE_MODALIAS_FMT, sdev->type);
365 return 0; 370 return 0;
diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c
index 45df83b9d847..0fe031f003e7 100644
--- a/drivers/scsi/ses.c
+++ b/drivers/scsi/ses.c
@@ -61,7 +61,7 @@ static int ses_probe(struct device *dev)
61 return err; 61 return err;
62} 62}
63 63
64#define SES_TIMEOUT 30 64#define SES_TIMEOUT (30 * HZ)
65#define SES_RETRIES 3 65#define SES_RETRIES 3
66 66
67static int ses_recv_diag(struct scsi_device *sdev, int page_code, 67static int ses_recv_diag(struct scsi_device *sdev, int page_code,
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 4284625ed035..cee1e4c6d83c 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1451,17 +1451,18 @@ sg_add(struct device *cl_dev, struct class_interface *cl_intf)
1451 if (sg_sysfs_valid) { 1451 if (sg_sysfs_valid) {
1452 struct device *sg_class_member; 1452 struct device *sg_class_member;
1453 1453
1454 sg_class_member = device_create(sg_sysfs_class, cl_dev->parent, 1454 sg_class_member = device_create_drvdata(sg_sysfs_class,
1455 MKDEV(SCSI_GENERIC_MAJOR, 1455 cl_dev->parent,
1456 sdp->index), 1456 MKDEV(SCSI_GENERIC_MAJOR,
1457 "%s", disk->disk_name); 1457 sdp->index),
1458 sdp,
1459 "%s", disk->disk_name);
1458 if (IS_ERR(sg_class_member)) { 1460 if (IS_ERR(sg_class_member)) {
1459 printk(KERN_ERR "sg_add: " 1461 printk(KERN_ERR "sg_add: "
1460 "device_create failed\n"); 1462 "device_create failed\n");
1461 error = PTR_ERR(sg_class_member); 1463 error = PTR_ERR(sg_class_member);
1462 goto cdev_add_err; 1464 goto cdev_add_err;
1463 } 1465 }
1464 dev_set_drvdata(sg_class_member, sdp);
1465 error = sysfs_create_link(&scsidp->sdev_gendev.kobj, 1466 error = sysfs_create_link(&scsidp->sdev_gendev.kobj,
1466 &sg_class_member->kobj, "generic"); 1467 &sg_class_member->kobj, "generic");
1467 if (error) 1468 if (error)
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index 7ee86d4a7618..c82df8bd4d89 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -178,6 +178,9 @@ int sr_test_unit_ready(struct scsi_device *sdev, struct scsi_sense_hdr *sshdr)
178 the_result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 178 the_result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL,
179 0, sshdr, SR_TIMEOUT, 179 0, sshdr, SR_TIMEOUT,
180 retries--); 180 retries--);
181 if (scsi_sense_valid(sshdr) &&
182 sshdr->sense_key == UNIT_ATTENTION)
183 sdev->changed = 1;
181 184
182 } while (retries > 0 && 185 } while (retries > 0 &&
183 (!scsi_status_is_good(the_result) || 186 (!scsi_status_is_good(the_result) ||
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index e93544dd81bf..4684cc716aa4 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -4431,17 +4431,19 @@ static int do_create_class_files(struct scsi_tape *STp, int dev_num, int mode)
4431 snprintf(name, 10, "%s%s%s", rew ? "n" : "", 4431 snprintf(name, 10, "%s%s%s", rew ? "n" : "",
4432 STp->disk->disk_name, st_formats[i]); 4432 STp->disk->disk_name, st_formats[i]);
4433 st_class_member = 4433 st_class_member =
4434 device_create(st_sysfs_class, &STp->device->sdev_gendev, 4434 device_create_drvdata(st_sysfs_class,
4435 MKDEV(SCSI_TAPE_MAJOR, 4435 &STp->device->sdev_gendev,
4436 TAPE_MINOR(dev_num, mode, rew)), 4436 MKDEV(SCSI_TAPE_MAJOR,
4437 "%s", name); 4437 TAPE_MINOR(dev_num,
4438 mode, rew)),
4439 &STp->modes[mode],
4440 "%s", name);
4438 if (IS_ERR(st_class_member)) { 4441 if (IS_ERR(st_class_member)) {
4439 printk(KERN_WARNING "st%d: device_create failed\n", 4442 printk(KERN_WARNING "st%d: device_create failed\n",
4440 dev_num); 4443 dev_num);
4441 error = PTR_ERR(st_class_member); 4444 error = PTR_ERR(st_class_member);
4442 goto out; 4445 goto out;
4443 } 4446 }
4444 dev_set_drvdata(st_class_member, &STp->modes[mode]);
4445 4447
4446 error = device_create_file(st_class_member, 4448 error = device_create_file(st_class_member,
4447 &dev_attr_defined); 4449 &dev_attr_defined);