From 0ee304d5802dc62746f13f12d4cb4ec4ed285f66 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Sat, 25 Feb 2006 13:52:30 +0900 Subject: [PATCH] sata_sil: add board ID for 3512 3512 is slightly different from 3112 errata-wise. Differentiate it. Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- drivers/scsi/sata_sil.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/sata_sil.c b/drivers/scsi/sata_sil.c index 17f74d3c10e..510c2e0bd90 100644 --- a/drivers/scsi/sata_sil.c +++ b/drivers/scsi/sata_sil.c @@ -53,7 +53,8 @@ enum { sil_3112 = 0, sil_3112_m15w = 1, - sil_3114 = 2, + sil_3512 = 2, + sil_3114 = 3, SIL_FIFO_R0 = 0x40, SIL_FIFO_W0 = 0x41, @@ -90,7 +91,7 @@ static void sil_post_set_mode (struct ata_port *ap); static const struct pci_device_id sil_pci_tbl[] = { { 0x1095, 0x3112, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_m15w }, { 0x1095, 0x0240, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_m15w }, - { 0x1095, 0x3512, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 }, + { 0x1095, 0x3512, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3512 }, { 0x1095, 0x3114, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3114 }, { 0x1002, 0x436e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_m15w }, { 0x1002, 0x4379, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_m15w }, @@ -185,7 +186,8 @@ static const struct ata_port_info sil_port_info[] = { .mwdma_mask = 0x07, /* mwdma0-2 */ .udma_mask = 0x3f, /* udma0-5 */ .port_ops = &sil_ops, - }, /* sil_3112_15w - keep it sync'd w/ sil_3112 */ + }, + /* sil_3112_15w - keep it sync'd w/ sil_3112 */ { .sht = &sil_sht, .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | @@ -195,7 +197,18 @@ static const struct ata_port_info sil_port_info[] = { .mwdma_mask = 0x07, /* mwdma0-2 */ .udma_mask = 0x3f, /* udma0-5 */ .port_ops = &sil_ops, - }, /* sil_3114 */ + }, + /* sil_3512 */ + { + .sht = &sil_sht, + .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | + ATA_FLAG_SRST | ATA_FLAG_MMIO, + .pio_mask = 0x1f, /* pio0-4 */ + .mwdma_mask = 0x07, /* mwdma0-2 */ + .udma_mask = 0x3f, /* udma0-5 */ + .port_ops = &sil_ops, + }, + /* sil_3114 */ { .sht = &sil_sht, .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | -- cgit v1.2.3 From e4e10e3e7995f5bd481d2720bf30d3a661d110ca Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Sat, 25 Feb 2006 13:52:30 +0900 Subject: [PATCH] sata_sil: implement R_ERR on DMA activate FIS errata fix Silicon Image has disclosed a new sil3114/3152 errata and workaround which causes the controller to return R_ERR on DMA activate FIS if the FIS is received while the next PRD is being fetched. This patch implements the workaround. This errata results in lock up and doesn't trigger if m15w workaround is in effect. We stopped applying m15w to 3512 and 3114 in 2.6.14-rc1 which makes 3512/3114 lock up with some drives on all kernel versions since 2.6.14-rc1 upto now (2.6.16-rc4). This patch should fix the regression. Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- drivers/scsi/sata_sil.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/sata_sil.c b/drivers/scsi/sata_sil.c index 510c2e0bd90..9face3c6aa2 100644 --- a/drivers/scsi/sata_sil.c +++ b/drivers/scsi/sata_sil.c @@ -49,6 +49,7 @@ #define DRV_VERSION "0.9" enum { + SIL_FLAG_RERR_ON_DMA_ACT = (1 << 29), SIL_FLAG_MOD15WRITE = (1 << 30), sil_3112 = 0, @@ -202,7 +203,8 @@ static const struct ata_port_info sil_port_info[] = { { .sht = &sil_sht, .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | - ATA_FLAG_SRST | ATA_FLAG_MMIO, + ATA_FLAG_SRST | ATA_FLAG_MMIO | + SIL_FLAG_RERR_ON_DMA_ACT, .pio_mask = 0x1f, /* pio0-4 */ .mwdma_mask = 0x07, /* mwdma0-2 */ .udma_mask = 0x3f, /* udma0-5 */ @@ -212,7 +214,8 @@ static const struct ata_port_info sil_port_info[] = { { .sht = &sil_sht, .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | - ATA_FLAG_SRST | ATA_FLAG_MMIO, + ATA_FLAG_SRST | ATA_FLAG_MMIO | + SIL_FLAG_RERR_ON_DMA_ACT, .pio_mask = 0x1f, /* pio0-4 */ .mwdma_mask = 0x07, /* mwdma0-2 */ .udma_mask = 0x3f, /* udma0-5 */ @@ -229,12 +232,13 @@ static const struct { unsigned long scr; /* SATA control register block */ unsigned long sien; /* SATA Interrupt Enable register */ unsigned long xfer_mode;/* data transfer mode register */ + unsigned long sfis_cfg; /* SATA FIS reception config register */ } sil_port[] = { /* port 0 ... */ - { 0x80, 0x8A, 0x00, 0x100, 0x148, 0xb4 }, - { 0xC0, 0xCA, 0x08, 0x180, 0x1c8, 0xf4 }, - { 0x280, 0x28A, 0x200, 0x300, 0x348, 0x2b4 }, - { 0x2C0, 0x2CA, 0x208, 0x380, 0x3c8, 0x2f4 }, + { 0x80, 0x8A, 0x00, 0x100, 0x148, 0xb4, 0x14c }, + { 0xC0, 0xCA, 0x08, 0x180, 0x1c8, 0xf4, 0x1cc }, + { 0x280, 0x28A, 0x200, 0x300, 0x348, 0x2b4, 0x34c }, + { 0x2C0, 0x2CA, 0x208, 0x380, 0x3c8, 0x2f4, 0x3cc }, /* ... port 3 */ }; @@ -484,6 +488,23 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) dev_printk(KERN_WARNING, &pdev->dev, "cache line size not set. Driver may not function\n"); + /* Apply R_ERR on DMA activate FIS errata workaround */ + if (probe_ent->host_flags & SIL_FLAG_RERR_ON_DMA_ACT) { + int cnt; + + for (i = 0, cnt = 0; i < probe_ent->n_ports; i++) { + tmp = readl(mmio_base + sil_port[i].sfis_cfg); + if ((tmp & 0x3) != 0x01) + continue; + if (!cnt) + dev_printk(KERN_INFO, &pdev->dev, + "Applying R_ERR on DMA activate " + "FIS errata fix\n"); + writel(tmp & ~0x3, mmio_base + sil_port[i].sfis_cfg); + cnt++; + } + } + if (ent->driver_data == sil_3114) { irq_mask = SIL_MASK_4PORT; -- cgit v1.2.3 From eca7be5e1899626db01ae42b0123458d6fb34930 Mon Sep 17 00:00:00 2001 From: Brian King Date: Tue, 14 Feb 2006 12:42:24 -0600 Subject: [SCSI] sg: Remove aha1542 hack Remove a hack in the sg driver that alters the total buffer length for SG_IO commands to ensure buffers are not odd byte lengths. This breaks on the ipr driver since it requires the request_bufflen to equal the length specified in the cdb. The block layer SG_IO code does not appear to have this hack. Signed-off-by: Douglas Gilbert Signed-off-by: Brian King Signed-off-by: James Bottomley --- drivers/scsi/sg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 2a547538d44..5a0a19322d0 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -2162,7 +2162,7 @@ sg_link_reserve(Sg_fd * sfp, Sg_request * srp, int size) srp->res_used = 1; SCSI_LOG_TIMEOUT(4, printk("sg_link_reserve: size=%d\n", size)); - rem = size = (size + 1) & (~1); /* round to even for aha1542 */ + rem = size; for (k = 0; k < rsv_schp->k_use_sg; ++k, ++sg) { num = sg->length; -- cgit v1.2.3 From 8b097a67264ba3e10620b268979de3be6fe5e3cd Mon Sep 17 00:00:00 2001 From: Andrew Vasquez Date: Tue, 14 Feb 2006 14:22:14 -0800 Subject: [SCSI] fc_transport: stop creating duplicate rport entries. Current fc_transport consumers initially register rports with an UNKNOWN role-state and follow-up with a call to fc_remote_port_rolechg(). Modify code in fc_remote_port_add() to scan the fc_host_rport_bindings() array for consistent bindings regardless of role-type. Original code would only scan bindings array for targets, causing duplicate fc_remote_ports/rport-X:Y-Z entries to be created for the yet-to-be-role-changed rports. Signed-off-by: Andrew Vasquez Signed-off-by: James Bottomley --- drivers/scsi/scsi_transport_fc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c index f2c9acf11bd..929032e370d 100644 --- a/drivers/scsi/scsi_transport_fc.c +++ b/drivers/scsi/scsi_transport_fc.c @@ -1498,8 +1498,7 @@ fc_remote_port_add(struct Scsi_Host *shost, int channel, } /* Search the bindings array */ - if (likely((ids->roles & FC_RPORT_ROLE_FCP_TARGET) && - (fc_host_tgtid_bind_type(shost) != FC_TGTID_BIND_NONE))) { + if (fc_host_tgtid_bind_type(shost) != FC_TGTID_BIND_NONE) { /* search for a matching consistent binding */ -- cgit v1.2.3 From 938050916f57f08e20595b1fa1c1e57c2fbf7243 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Fri, 17 Feb 2006 12:11:29 +0100 Subject: [SCSI] scsi: handle ->slave_configure return value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When ­>slave_configure fails the scsi midlayer should handle it. Signed-off-by: James Bottomley --- drivers/scsi/scsi_scan.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 5acb83ca5ae..f9ecc3dea7d 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -752,8 +752,20 @@ static int scsi_add_lun(struct scsi_device *sdev, char *inq_result, int *bflags) transport_configure_device(&sdev->sdev_gendev); - if (sdev->host->hostt->slave_configure) - sdev->host->hostt->slave_configure(sdev); + if (sdev->host->hostt->slave_configure) { + int ret = sdev->host->hostt->slave_configure(sdev); + if (ret) { + /* + * if LLDD reports slave not present, don't clutter + * console with alloc failure messages + */ + if (ret != -ENXIO) { + sdev_printk(KERN_ERR, sdev, + "failed to configure device\n"); + } + return SCSI_SCAN_NO_RESPONSE; + } + } /* * Ok, the device is now all set up, we can -- cgit v1.2.3 From c3c013a2c218cdede2d2e73df01ed4f813538941 Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Mon, 27 Feb 2006 22:31:19 -0500 Subject: [libata] Disable FUA Until problems are sorted. --- drivers/scsi/libata-core.c | 4 ++++ drivers/scsi/libata-scsi.c | 2 ++ drivers/scsi/libata.h | 1 + 3 files changed, 7 insertions(+) (limited to 'drivers/scsi') diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 5f1d7580218..4f91b0dc572 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c @@ -82,6 +82,10 @@ int atapi_enabled = 0; module_param(atapi_enabled, int, 0444); MODULE_PARM_DESC(atapi_enabled, "Enable discovery of ATAPI devices (0=off, 1=on)"); +int libata_fua = 0; +module_param_named(fua, libata_fua, int, 0444); +MODULE_PARM_DESC(fua, "FUA support (0=off, 1=on)"); + MODULE_AUTHOR("Jeff Garzik"); MODULE_DESCRIPTION("Library module for ATA devices"); MODULE_LICENSE("GPL"); diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c index 07b1e7cc61d..59503c9ccac 100644 --- a/drivers/scsi/libata-scsi.c +++ b/drivers/scsi/libata-scsi.c @@ -1708,6 +1708,8 @@ static int ata_dev_supports_fua(u16 *id) { unsigned char model[41], fw[9]; + if (!libata_fua) + return 0; if (!ata_id_has_fua(id)) return 0; diff --git a/drivers/scsi/libata.h b/drivers/scsi/libata.h index e03ce48b7b4..fddaf479a54 100644 --- a/drivers/scsi/libata.h +++ b/drivers/scsi/libata.h @@ -41,6 +41,7 @@ struct ata_scsi_args { /* libata-core.c */ extern int atapi_enabled; +extern int libata_fua; extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, struct ata_device *dev); extern int ata_rwcmd_protocol(struct ata_queued_cmd *qc); -- cgit v1.2.3 From 147aab6aa22ce7775be944f8fb9932aa000dda61 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Fri, 17 Feb 2006 12:13:48 +0100 Subject: [SCSI] megaraid_sas: fix physical disk handling This patch hides the devices completely from the midlayer instead. It requires the patch to handle the slave_configure failure I posted earlier. Signed-off-by: Christoph Hellwig Signed-off-by: James Bottomley --- drivers/scsi/megaraid/megaraid_sas.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/megaraid/megaraid_sas.c b/drivers/scsi/megaraid/megaraid_sas.c index 7de267e1445..4f39dd01936 100644 --- a/drivers/scsi/megaraid/megaraid_sas.c +++ b/drivers/scsi/megaraid/megaraid_sas.c @@ -793,6 +793,20 @@ megasas_queue_command(struct scsi_cmnd *scmd, void (*done) (struct scsi_cmnd *)) return 0; } +static int megasas_slave_configure(struct scsi_device *sdev) +{ + /* + * Don't export physical disk devices to the disk driver. + * + * FIXME: Currently we don't export them to the midlayer at all. + * That will be fixed once LSI engineers have audited the + * firmware for possible issues. + */ + if (sdev->channel < MEGASAS_MAX_PD_CHANNELS && sdev->type == TYPE_DISK) + return -ENXIO; + return 0; +} + /** * megasas_wait_for_outstanding - Wait for all outstanding cmds * @instance: Adapter soft state @@ -943,6 +957,7 @@ static struct scsi_host_template megasas_template = { .module = THIS_MODULE, .name = "LSI Logic SAS based MegaRAID driver", .proc_name = "megaraid_sas", + .slave_configure = megasas_slave_configure, .queuecommand = megasas_queue_command, .eh_device_reset_handler = megasas_reset_device, .eh_bus_reset_handler = megasas_reset_bus_host, @@ -1071,20 +1086,6 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd, break; } - /* - * Don't export physical disk devices to mid-layer. - */ - if (!MEGASAS_IS_LOGICAL(cmd->scmd) && - (hdr->cmd_status == MFI_STAT_OK) && - (cmd->scmd->cmnd[0] == INQUIRY)) { - - if (((*(u8 *) cmd->scmd->request_buffer) & 0x1F) == - TYPE_DISK) { - cmd->scmd->result = DID_BAD_TARGET << 16; - exception = 1; - } - } - case MFI_CMD_LD_READ: case MFI_CMD_LD_WRITE: -- cgit v1.2.3 From 8884efab1516613215816d48132dd724508970bf Mon Sep 17 00:00:00 2001 From: Brian King Date: Fri, 24 Feb 2006 17:10:04 -0600 Subject: [SCSI] scsi: scsi command retries off by one fix Fix up an off by one error in calculating retries for scsi commands. This bug was discovered when an SG_IO request was sent to scsi core with retries = 0, causing the overall timeout check to go off in scsi_softirq_done. Signed-off-by: Brian King Signed-off-by: James Bottomley --- drivers/scsi/scsi_error.c | 4 ++-- drivers/scsi/scsi_lib.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 5cc97b72166..ff82ccfbb10 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -1308,7 +1308,7 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd) * the request was not marked fast fail. Note that above, * even if the request is marked fast fail, we still requeue * for queue congestion conditions (QUEUE_FULL or BUSY) */ - if ((++scmd->retries) < scmd->allowed + if ((++scmd->retries) <= scmd->allowed && !blk_noretry_request(scmd->request)) { return NEEDS_RETRY; } else { @@ -1433,7 +1433,7 @@ static void scsi_eh_flush_done_q(struct list_head *done_q) list_del_init(&scmd->eh_entry); if (scsi_device_online(scmd->device) && !blk_noretry_request(scmd->request) && - (++scmd->retries < scmd->allowed)) { + (++scmd->retries <= scmd->allowed)) { SCSI_LOG_ERROR_RECOVERY(3, printk("%s: flush" " retry cmd: %p\n", current->comm, diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 4362dcde74a..701a328f7be 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1498,7 +1498,7 @@ static void scsi_kill_request(struct request *req, request_queue_t *q) static void scsi_softirq_done(struct request *rq) { struct scsi_cmnd *cmd = rq->completion_data; - unsigned long wait_for = cmd->allowed * cmd->timeout_per_command; + unsigned long wait_for = (cmd->allowed + 1) * cmd->timeout_per_command; int disposition; INIT_LIST_HEAD(&cmd->eh_entry); -- cgit v1.2.3 From 123fc7fd6f609a000061f586a794c89d1122ede1 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Thu, 9 Feb 2006 11:16:38 -0500 Subject: [SCSI] Delete duplicate driver template. Stuborn as compilers are they don't like duplicate definitions. Signed-off-by: Ralf Baechle Signed-off-by: James Bottomley --- drivers/scsi/jazz_esp.c | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/jazz_esp.c b/drivers/scsi/jazz_esp.c index 23728d1c980..fcd304e11c2 100644 --- a/drivers/scsi/jazz_esp.c +++ b/drivers/scsi/jazz_esp.c @@ -65,27 +65,6 @@ static int jazz_esp_release(struct Scsi_Host *shost) return 0; } -static struct scsi_host_template driver_template = { - .proc_name = "jazz_esp", - .proc_info = &esp_proc_info, - .name = "ESP 100/100a/200", - .detect = jazz_esp_detect, - .slave_alloc = esp_slave_alloc, - .slave_destroy = esp_slave_destroy, - .release = jazz_esp_release, - .info = esp_info, - .queuecommand = esp_queue, - .eh_abort_handler = esp_abort, - .eh_bus_reset_handler = esp_reset, - .can_queue = 7, - .this_id = 7, - .sg_tablesize = SG_ALL, - .cmd_per_lun = 1, - .use_clustering = DISABLE_CLUSTERING, -}; - -#include "scsi_module.c" - /***************************************************************** Detection */ static int jazz_esp_detect(struct scsi_host_template *tpnt) { -- cgit v1.2.3 From 23ff51e9fe24f98c1053ac1cdded434012eee342 Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Tue, 28 Feb 2006 06:28:15 -0700 Subject: [SCSI] Fix uninitialised width and speed in sym2 sym2 boards without NVRAM currently negotiate narrow due to this missed initialisation Signed-off-by: Matthew Wilcox Signed-off-by: James Bottomley --- drivers/scsi/sym53c8xx_2/sym_hipd.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/scsi') diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c index f4854c33f48..2627000ca65 100644 --- a/drivers/scsi/sym53c8xx_2/sym_hipd.c +++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c @@ -919,6 +919,8 @@ static int sym_prepare_setting(struct Scsi_Host *shost, struct sym_hcb *np, stru tp->usrflags |= (SYM_DISC_ENABLED | SYM_TAGS_ENABLED); tp->usrtags = SYM_SETUP_MAX_TAG; + tp->usr_width = np->maxwide; + tp->usr_period = 9; sym_nvram_setup_target(tp, i, nvram); -- cgit v1.2.3 From e2482fa16e9eef88344a4dca1a390d29432d4add Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=FCrgen=20E=2E=20Fischer?= Date: Sun, 19 Feb 2006 00:31:51 +0100 Subject: [SCSI] aha152x: fix variable use before initialisation and other bugs - change interface of the reset functions from Scsi_Cmnd to Scsi_Host. - add functions with the original interface and rename the new functions to reflect the new interface. - call these from the pcmcia driver, thereby avoiding the need to construct a (broken) Scsi_Cmnd from a Scsi_Host. - just run the bh if the interrupt is from the controller and if so ensure that it's only called once per interrupt. Signed-off-by: Juergen E. Fischer Signed-off-by: James Bottomley --- drivers/scsi/aha152x.c | 85 +++++++++++++++++++++++--------------- drivers/scsi/aha152x.h | 2 +- drivers/scsi/pcmcia/aha152x_stub.c | 4 +- 3 files changed, 54 insertions(+), 37 deletions(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c index cb2ee25f213..531a1f9ceb5 100644 --- a/drivers/scsi/aha152x.c +++ b/drivers/scsi/aha152x.c @@ -1260,16 +1260,15 @@ static void free_hard_reset_SCs(struct Scsi_Host *shpnt, Scsi_Cmnd **SCs) * Reset the bus * */ -static int aha152x_bus_reset(Scsi_Cmnd *SCpnt) +static int aha152x_bus_reset_host(struct Scsi_Host *shpnt) { - struct Scsi_Host *shpnt = SCpnt->device->host; unsigned long flags; DO_LOCK(flags); #if defined(AHA152X_DEBUG) if(HOSTDATA(shpnt)->debug & debug_eh) { - printk(DEBUG_LEAD "aha152x_bus_reset(%p)", CMDINFO(SCpnt), SCpnt); + printk(KERN_DEBUG "scsi%d: bus reset", shpnt->host_no); show_queues(shpnt); } #endif @@ -1277,14 +1276,14 @@ static int aha152x_bus_reset(Scsi_Cmnd *SCpnt) free_hard_reset_SCs(shpnt, &ISSUE_SC); free_hard_reset_SCs(shpnt, &DISCONNECTED_SC); - DPRINTK(debug_eh, DEBUG_LEAD "resetting bus\n", CMDINFO(SCpnt)); + DPRINTK(debug_eh, KERN_DEBUG "scsi%d: resetting bus\n", shpnt->host_no); SETPORT(SCSISEQ, SCSIRSTO); mdelay(256); SETPORT(SCSISEQ, 0); mdelay(DELAY); - DPRINTK(debug_eh, DEBUG_LEAD "bus resetted\n", CMDINFO(SCpnt)); + DPRINTK(debug_eh, KERN_DEBUG "scsi%d: bus resetted\n", shpnt->host_no); setup_expected_interrupts(shpnt); if(HOSTDATA(shpnt)->commands==0) @@ -1295,6 +1294,14 @@ static int aha152x_bus_reset(Scsi_Cmnd *SCpnt) return SUCCESS; } +/* + * Reset the bus + * + */ +static int aha152x_bus_reset(Scsi_Cmnd *SCpnt) +{ + return aha152x_bus_reset_host(SCpnt->device->host); +} /* * Restore default values to the AIC-6260 registers and reset the fifos @@ -1337,22 +1344,27 @@ static void reset_ports(struct Scsi_Host *shpnt) * Reset the host (bus and controller) * */ -int aha152x_host_reset(Scsi_Cmnd * SCpnt) +int aha152x_host_reset_host(struct Scsi_Host *shpnt) { -#if defined(AHA152X_DEBUG) - struct Scsi_Host *shpnt = SCpnt->device->host; -#endif - - DPRINTK(debug_eh, DEBUG_LEAD "aha152x_host_reset(%p)\n", CMDINFO(SCpnt), SCpnt); + DPRINTK(debug_eh, KERN_DEBUG "scsi%d: host reset\n", shpnt->host_no); - aha152x_bus_reset(SCpnt); + aha152x_bus_reset_host(shpnt); - DPRINTK(debug_eh, DEBUG_LEAD "resetting ports\n", CMDINFO(SCpnt)); - reset_ports(SCpnt->device->host); + DPRINTK(debug_eh, KERN_DEBUG "scsi%d: resetting ports\n", shpnt->host_no); + reset_ports(shpnt); return SUCCESS; } +/* + * Reset the host (bus and controller) + * + */ +static int aha152x_host_reset(Scsi_Cmnd *SCpnt) +{ + return aha152x_host_reset_host(SCpnt->device->host); +} + /* * Return the "logical geometry" * @@ -1431,22 +1443,18 @@ static void run(void) { int i; for (i = 0; iservice) { - HOSTDATA(shpnt)->service=0; - is_complete(shpnt); - } + is_complete(aha152x_host[i]); } } /* - * Interrupts handler + * Interrupt handler * */ - static irqreturn_t intr(int irqno, void *dev_id, struct pt_regs *regs) { struct Scsi_Host *shpnt = lookup_irq(irqno); + unsigned long flags; unsigned char rev, dmacntrl0; if (!shpnt) { @@ -1472,23 +1480,23 @@ static irqreturn_t intr(int irqno, void *dev_id, struct pt_regs *regs) if ((rev == 0xFF) && (dmacntrl0 == 0xFF)) return IRQ_NONE; + if( TESTLO(DMASTAT, INTSTAT) ) + return IRQ_NONE; + /* no more interrupts from the controller, while we're busy. INTEN is restored by the BH handler */ CLRBITS(DMACNTRL0, INTEN); -#if 0 - /* check if there is already something to be - serviced; should not happen */ - if(HOSTDATA(shpnt)->service) { - printk(KERN_ERR "aha152x%d: lost interrupt (%d)\n", HOSTNO, HOSTDATA(shpnt)->service); - show_queues(shpnt); + DO_LOCK(flags); + if( HOSTDATA(shpnt)->service==0 ) { + HOSTDATA(shpnt)->service=1; + + /* Poke the BH handler */ + INIT_WORK(&aha152x_tq, (void *) run, NULL); + schedule_work(&aha152x_tq); } -#endif - - /* Poke the BH handler */ - HOSTDATA(shpnt)->service++; - INIT_WORK(&aha152x_tq, (void *) run, NULL); - schedule_work(&aha152x_tq); + DO_UNLOCK(flags); + return IRQ_HANDLED; } @@ -2527,7 +2535,18 @@ static void is_complete(struct Scsi_Host *shpnt) unsigned long flags; int pending; + if(!shpnt) + return; + DO_LOCK(flags); + + if( HOSTDATA(shpnt)->service==0 ) { + DO_UNLOCK(flags); + return; + } + + HOSTDATA(shpnt)->service = 0; + if(HOSTDATA(shpnt)->in_intr) { DO_UNLOCK(flags); /* aha152x_error never returns.. */ diff --git a/drivers/scsi/aha152x.h b/drivers/scsi/aha152x.h index d277613af29..d2add24d02a 100644 --- a/drivers/scsi/aha152x.h +++ b/drivers/scsi/aha152x.h @@ -332,6 +332,6 @@ struct aha152x_setup { struct Scsi_Host *aha152x_probe_one(struct aha152x_setup *); void aha152x_release(struct Scsi_Host *); -int aha152x_host_reset(Scsi_Cmnd *); +int aha152x_host_reset_host(struct Scsi_Host *); #endif /* _AHA152X_H */ diff --git a/drivers/scsi/pcmcia/aha152x_stub.c b/drivers/scsi/pcmcia/aha152x_stub.c index 0c9edb7051f..5609847e254 100644 --- a/drivers/scsi/pcmcia/aha152x_stub.c +++ b/drivers/scsi/pcmcia/aha152x_stub.c @@ -275,10 +275,8 @@ static int aha152x_resume(struct pcmcia_device *dev) link->state &= ~DEV_SUSPEND; if (link->state & DEV_CONFIG) { - Scsi_Cmnd tmp; pcmcia_request_configuration(link->handle, &link->conf); - tmp.device->host = info->host; - aha152x_host_reset(&tmp); + aha152x_host_reset_host(info->host); } return 0; -- cgit v1.2.3 From f716d8303345698728d9f8ce76a82a795a5be275 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Mon, 6 Mar 2006 17:41:44 -0800 Subject: Allocate 96 bytes for SCSI sense data reply The SCSI layer uses SCSI_SENSE_BUFFERSIZE (96) for the sense buffer size, even though some other code uses "sizeof(struct request_sense)" (which is 64 bytes). Allocate the buffer using the bigger of the two for safety. Signed-off-by: Linus Torvalds --- drivers/scsi/sr_ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c index 5d02ff4db6c..b65462f7648 100644 --- a/drivers/scsi/sr_ioctl.c +++ b/drivers/scsi/sr_ioctl.c @@ -192,7 +192,7 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc) SDev = cd->device; if (!sense) { - sense = kmalloc(sizeof(*sense), GFP_KERNEL); + sense = kmalloc(SCSI_SENSE_BUFFERSIZE, GFP_KERNEL); if (!sense) { err = -ENOMEM; goto out; -- cgit v1.2.3 From 6971ed1fbbc80cae54e082aae153d5b063885d0a Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Sat, 11 Mar 2006 12:47:54 +0900 Subject: [PATCH] ahci: fix NULL pointer dereference detected by Coverity Fix NULL pointer dereference detected by the Coverity checker. Kill dev -> pdev -> dev conversion while at it. Signed-off-by: Tejun Heo Cc: Adrian Bunk Signed-off-by: Jeff Garzik --- drivers/scsi/ahci.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c index a800fb51168..559ff7aae3f 100644 --- a/drivers/scsi/ahci.c +++ b/drivers/scsi/ahci.c @@ -742,23 +742,17 @@ static irqreturn_t ahci_interrupt (int irq, void *dev_instance, struct pt_regs * struct ata_queued_cmd *qc; qc = ata_qc_from_tag(ap, ap->active_tag); if (!ahci_host_intr(ap, qc)) - if (ata_ratelimit()) { - struct pci_dev *pdev = - to_pci_dev(ap->host_set->dev); - dev_printk(KERN_WARNING, &pdev->dev, + if (ata_ratelimit()) + dev_printk(KERN_WARNING, host_set->dev, "unhandled interrupt on port %u\n", i); - } VPRINTK("port %u\n", i); } else { VPRINTK("port %u (no irq)\n", i); - if (ata_ratelimit()) { - struct pci_dev *pdev = - to_pci_dev(ap->host_set->dev); - dev_printk(KERN_WARNING, &pdev->dev, + if (ata_ratelimit()) + dev_printk(KERN_WARNING, host_set->dev, "interrupt on disabled port %u\n", i); - } } irq_ack |= (1 << i); -- cgit v1.2.3