From c831a4a08636d5462a0f9eb479771e2f65ad0378 Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Wed, 10 May 2017 09:39:35 -0700 Subject: scsi: aacraid: Remove __GFP_DMA for raw srb memory The raw srb commands do not requires memory that in the ZONE_DMA memory space. For 32bit srb commands use GFP_DMA32 to limit the memory to 32bit memory range (4GB). Signed-off-by: Raghava Aditya Renukunta Reviewed-by: Dave Carroll Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/commctrl.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c index d2f8d5954840..106b9332f718 100644 --- a/drivers/scsi/aacraid/commctrl.c +++ b/drivers/scsi/aacraid/commctrl.c @@ -668,7 +668,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) goto cleanup; } - p = kmalloc(sg_count[i], GFP_KERNEL|__GFP_DMA); + p = kmalloc(sg_count[i], GFP_KERNEL); if (!p) { rcode = -ENOMEM; goto cleanup; @@ -732,8 +732,8 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) rcode = -EINVAL; goto cleanup; } - /* Does this really need to be GFP_DMA? */ - p = kmalloc(sg_count[i], GFP_KERNEL|__GFP_DMA); + + p = kmalloc(sg_count[i], GFP_KERNEL); if(!p) { dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n", sg_count[i], i, upsg->count)); @@ -788,8 +788,8 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) rcode = -EINVAL; goto cleanup; } - /* Does this really need to be GFP_DMA? */ - p = kmalloc(sg_count[i], GFP_KERNEL|__GFP_DMA); + + p = kmalloc(sg_count[i], GFP_KERNEL); if(!p) { dprintk((KERN_DEBUG "aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n", sg_count[i], i, usg->count)); @@ -845,8 +845,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) rcode = -EINVAL; goto cleanup; } - /* Does this really need to be GFP_DMA? */ - p = kmalloc(sg_count[i], GFP_KERNEL|__GFP_DMA); + p = kmalloc(sg_count[i], GFP_KERNEL|GFP_DMA32); if (!p) { dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n", sg_count[i], i, usg->count)); @@ -887,7 +886,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) rcode = -EINVAL; goto cleanup; } - p = kmalloc(sg_count[i], GFP_KERNEL); + p = kmalloc(sg_count[i], GFP_KERNEL|GFP_DMA32); if (!p) { dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n", sg_count[i], i, upsg->count)); -- cgit v1.2.3 From 8105d39d0e7600ebbcce5827c11f15bf77c73af5 Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Wed, 10 May 2017 09:39:36 -0700 Subject: scsi: aacraid: Fix DMAR issues with iommu=pt The driver changed the DMA consistent map after consistent memory was allocated, this invalidated the IOMMU identity mapping. The fix was to make sure that we set the DMA consistent mask setting once depending on the controller card. Signed-off-by: Raghava Aditya Renukunta Reviewed-by: Dave Carroll Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/aachba.c | 17 ++++++----------- drivers/scsi/aacraid/commsup.c | 29 ++++++++++++++++++----------- drivers/scsi/aacraid/linit.c | 32 +++++++++++++++++++------------- 3 files changed, 43 insertions(+), 35 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index 43d88389e899..707ee2f5954d 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -2071,20 +2071,15 @@ int aac_get_adapter_info(struct aac_dev* dev) expose_physicals = 0; } - if(dev->dac_support != 0) { - if (!pci_set_dma_mask(dev->pdev, DMA_BIT_MASK(64)) && - !pci_set_consistent_dma_mask(dev->pdev, DMA_BIT_MASK(64))) { + if (dev->dac_support) { + if (!pci_set_dma_mask(dev->pdev, DMA_BIT_MASK(64))) { if (!dev->in_reset) - printk(KERN_INFO"%s%d: 64 Bit DAC enabled\n", - dev->name, dev->id); - } else if (!pci_set_dma_mask(dev->pdev, DMA_BIT_MASK(32)) && - !pci_set_consistent_dma_mask(dev->pdev, DMA_BIT_MASK(32))) { - printk(KERN_INFO"%s%d: DMA mask set failed, 64 Bit DAC disabled\n", - dev->name, dev->id); + dev_info(&dev->pdev->dev, "64 Bit DAC enabled\n"); + } else if (!pci_set_dma_mask(dev->pdev, DMA_BIT_MASK(32))) { + dev_info(&dev->pdev->dev, "DMA mask set failed, 64 Bit DAC disabled\n"); dev->dac_support = 0; } else { - printk(KERN_WARNING"%s%d: No suitable DMA available.\n", - dev->name, dev->id); + dev_info(&dev->pdev->dev, "No suitable DMA available\n"); rcode = -ENOMEM; } } diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c index 7a1b8a2ce658..45de9b5cc42d 100644 --- a/drivers/scsi/aacraid/commsup.c +++ b/drivers/scsi/aacraid/commsup.c @@ -1513,6 +1513,7 @@ static int _aac_reset_adapter(struct aac_dev *aac, int forced, u8 reset_type) struct scsi_cmnd *command_list; int jafo = 0; int bled; + u64 dmamask; /* * Assumptions: @@ -1580,21 +1581,27 @@ static int _aac_reset_adapter(struct aac_dev *aac, int forced, u8 reset_type) aac_free_irq(aac); kfree(aac->fsa_dev); aac->fsa_dev = NULL; + + dmamask = DMA_BIT_MASK(32); quirks = aac_get_driver_ident(index)->quirks; - if (quirks & AAC_QUIRK_31BIT) { - if (((retval = pci_set_dma_mask(aac->pdev, DMA_BIT_MASK(31)))) || - ((retval = pci_set_consistent_dma_mask(aac->pdev, DMA_BIT_MASK(31))))) - goto out; - } else { - if (((retval = pci_set_dma_mask(aac->pdev, DMA_BIT_MASK(32)))) || - ((retval = pci_set_consistent_dma_mask(aac->pdev, DMA_BIT_MASK(32))))) - goto out; + if (quirks & AAC_QUIRK_31BIT) + retval = pci_set_dma_mask(aac->pdev, dmamask); + else if (!(quirks & AAC_QUIRK_SRC)) + retval = pci_set_dma_mask(aac->pdev, dmamask); + else + retval = pci_set_consistent_dma_mask(aac->pdev, dmamask); + + if (quirks & AAC_QUIRK_31BIT && !retval) { + dmamask = DMA_BIT_MASK(31); + retval = pci_set_consistent_dma_mask(aac->pdev, dmamask); } + + if (retval) + goto out; + if ((retval = (*(aac_get_driver_ident(index)->init))(aac))) goto out; - if (quirks & AAC_QUIRK_31BIT) - if ((retval = pci_set_dma_mask(aac->pdev, DMA_BIT_MASK(32)))) - goto out; + if (jafo) { aac->thread = kthread_run(aac_command_thread, aac, "%s", aac->name); diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index 372a07533026..5a201da93250 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -1403,6 +1403,7 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) int error = -ENODEV; int unique_id = 0; u64 dmamask; + int mask_bits = 0; extern int aac_sync_mode; /* @@ -1426,18 +1427,32 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) goto out; error = -ENODEV; + if (!(aac_drivers[index].quirks & AAC_QUIRK_SRC)) { + error = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); + if (error) { + dev_err(&pdev->dev, "PCI 32 BIT dma mask set failed"); + goto out_disable_pdev; + } + } + /* * If the quirk31 bit is set, the adapter needs adapter * to driver communication memory to be allocated below 2gig */ - if (aac_drivers[index].quirks & AAC_QUIRK_31BIT) + if (aac_drivers[index].quirks & AAC_QUIRK_31BIT) { dmamask = DMA_BIT_MASK(31); - else + mask_bits = 31; + } else { dmamask = DMA_BIT_MASK(32); + mask_bits = 32; + } - if (pci_set_dma_mask(pdev, dmamask) || - pci_set_consistent_dma_mask(pdev, dmamask)) + error = pci_set_consistent_dma_mask(pdev, dmamask); + if (error) { + dev_err(&pdev->dev, "PCI %d B consistent dma mask set failed\n" + , mask_bits); goto out_disable_pdev; + } pci_set_master(pdev); @@ -1501,15 +1516,6 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) goto out_deinit; } - /* - * If we had set a smaller DMA mask earlier, set it to 4gig - * now since the adapter can dma data to at least a 4gig - * address space. - */ - if (aac_drivers[index].quirks & AAC_QUIRK_31BIT) - if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) - goto out_deinit; - aac->maximum_num_channels = aac_drivers[index].channels; error = aac_get_adapter_info(aac); if (error < 0) -- cgit v1.2.3 From d58129c96b3cde4821763b08b5f1bba17f031138 Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Wed, 10 May 2017 09:39:37 -0700 Subject: scsi: aacraid: Added 32 and 64 queue depth for arc natives The qd for ARC Native disks is calculated by dividing the max IO 1024 by the number of disks or 256 which ever is lower. This causes poor disk IO performance. The fix is set the qd based on the type of disk (SAS - 64 and SATA - 32). Signed-off-by: Raghava Aditya Renukunta Reviewed-by: David Carroll Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/aacraid.h | 1 + drivers/scsi/aacraid/linit.c | 11 +++++++++++ 2 files changed, 12 insertions(+) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index d281492009fb..cb7d69939a34 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -415,6 +415,7 @@ struct aac_ciss_identify_pd { * These macros convert from physical channels to virtual channels */ #define CONTAINER_CHANNEL (0) +#define NATIVE_CHANNEL (1) #define CONTAINER_TO_CHANNEL(cont) (CONTAINER_CHANNEL) #define CONTAINER_TO_ID(cont) (cont) #define CONTAINER_TO_LUN(cont) (0) diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index 5a201da93250..5e1a2d67d90c 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -466,6 +466,17 @@ static int aac_slave_configure(struct scsi_device *sdev) ++num_lsu; depth = (host->can_queue - num_one) / num_lsu; + + if (sdev_channel(sdev) != NATIVE_CHANNEL) + goto common_config; + + /* + * Check if SATA drive + */ + if (strncmp(sdev->vendor, "ATA", 3) == 0) + depth = 32; + else + depth = 64; } common_config: -- cgit v1.2.3 From 58eaffe54bca77fbf1a1bad7703265950a758cd1 Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Wed, 10 May 2017 09:39:38 -0700 Subject: scsi: aacraid: Set correct Queue Depth for HBA1000 RAW disks The default queue depth for non NATIVE RAW disks is calculated from the number of fibs and number of disks or a max of 256. This causes poor disk IO performance. The fix is to set default qd based on the type of disks (SATA -32 and SAS -64) Signed-off-by: Raghava Aditya Renukunta Reviewed-by: David Carroll Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/linit.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index 5e1a2d67d90c..9ef98e40d81a 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -405,17 +405,23 @@ static int aac_slave_configure(struct scsi_device *sdev) int chn, tid; unsigned int depth = 0; unsigned int set_timeout = 0; + bool set_qd_dev_type = false; + u8 devtype = 0; chn = aac_logical_to_phys(sdev_channel(sdev)); tid = sdev_id(sdev); - if (chn < AAC_MAX_BUSES && tid < AAC_MAX_TARGETS && - aac->hba_map[chn][tid].devtype == AAC_DEVTYPE_NATIVE_RAW) { - depth = aac->hba_map[chn][tid].qd_limit; + if (chn < AAC_MAX_BUSES && tid < AAC_MAX_TARGETS && aac->sa_firmware) { + devtype = aac->hba_map[chn][tid].devtype; + + if (devtype == AAC_DEVTYPE_NATIVE_RAW) + depth = aac->hba_map[chn][tid].qd_limit; + else if (devtype == AAC_DEVTYPE_ARC_RAW) + set_qd_dev_type = true; + set_timeout = 1; goto common_config; } - if (aac->jbod && (sdev->type == TYPE_DISK)) sdev->removable = 1; @@ -470,16 +476,22 @@ static int aac_slave_configure(struct scsi_device *sdev) if (sdev_channel(sdev) != NATIVE_CHANNEL) goto common_config; - /* - * Check if SATA drive - */ + set_qd_dev_type = true; + + } + +common_config: + + /* + * Check if SATA drive + */ + if (set_qd_dev_type) { if (strncmp(sdev->vendor, "ATA", 3) == 0) depth = 32; else depth = 64; } -common_config: /* * Firmware has an individual device recovery time typically * of 35 seconds, give us a margin. -- cgit v1.2.3 From fed820073f647f4ecb4f4ae310d698520a802891 Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Wed, 10 May 2017 09:39:39 -0700 Subject: scsi: aacraid: Remove reset support from check_health Check health does not need to reset the ctrl but just return the controller health status. Signed-off-by: Raghava Aditya Renukunta Reviewed-by: David Carroll Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/commsup.c | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c index 45de9b5cc42d..aa4f47bf10b1 100644 --- a/drivers/scsi/aacraid/commsup.c +++ b/drivers/scsi/aacraid/commsup.c @@ -1775,8 +1775,6 @@ int aac_check_health(struct aac_dev * aac) int BlinkLED; unsigned long time_now, flagv = 0; struct list_head * entry; - struct Scsi_Host * host; - int bled; /* Extending the scope of fib_lock slightly to protect aac->in_reset */ if (spin_trylock_irqsave(&aac->fib_lock, flagv) == 0) @@ -1888,19 +1886,6 @@ int aac_check_health(struct aac_dev * aac) printk(KERN_ERR "%s: Host adapter BLINK LED 0x%x\n", aac->name, BlinkLED); - if (!aac_check_reset || ((aac_check_reset == 1) && - (aac->supplement_adapter_info.supported_options2 & - AAC_OPTION_IGNORE_RESET))) - goto out; - host = aac->scsi_host_ptr; - if (aac->thread->pid != current->pid) - spin_lock_irqsave(host->host_lock, flagv); - bled = aac_check_reset != 1 ? 1 : 0; - _aac_reset_adapter(aac, bled, IOP_HWSOFT_RESET); - if (aac->thread->pid != current->pid) - spin_unlock_irqrestore(host->host_lock, flagv); - return BlinkLED; - out: aac->in_reset = 0; return BlinkLED; -- cgit v1.2.3 From 2a4a62c03fd0b5f2e361fbda85e043b2c1ff197d Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Wed, 10 May 2017 09:39:40 -0700 Subject: scsi: aacraid: Change wait time for fib completion Change the completion wait time for the fibs in the reset and abort callback from 2 minutes to 15 seconds. 2 minutes is too long for waiting for completion. Signed-off-by: Raghava Aditya Renukunta Reviewed-by: David Carroll Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/linit.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index 9ef98e40d81a..f6a11af0432b 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -684,8 +684,8 @@ static int aac_eh_abort(struct scsi_cmnd* cmd) (fib_callback) aac_hba_callback, (void *) cmd); - /* Wait up to 2 minutes for completion */ - for (count = 0; count < 120; ++count) { + /* Wait up to 15 secs for completion */ + for (count = 0; count < 15; ++count) { if (cmd->SCp.sent_command) { ret = SUCCESS; break; @@ -840,8 +840,8 @@ static int aac_eh_reset(struct scsi_cmnd* cmd) (fib_callback) aac_hba_callback, (void *) cmd); - /* Wait up to 2 minutes for completion */ - for (count = 0; count < 120; ++count) { + /* Wait up to 15 seconds for completion */ + for (count = 0; count < 15; ++count) { if (cmd->SCp.sent_command) { ret = SUCCESS; break; -- cgit v1.2.3 From 895dc759cf3996a56ca64e3e09cbea64e2a7ff62 Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Wed, 10 May 2017 09:39:41 -0700 Subject: scsi: aacraid: Log count info of scsi cmds before reset Log the location of the scsi cmds before triggering a reset. This information is useful for debugging. Signed-off-by: Raghava Aditya Renukunta Reviewed-by: David Carroll Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/linit.c | 90 ++++++++++++++++++++++++++------------------ 1 file changed, 53 insertions(+), 37 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index f6a11af0432b..0a8d303c8bc9 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -624,6 +624,56 @@ static int aac_ioctl(struct scsi_device *sdev, int cmd, void __user * arg) return aac_do_ioctl(dev, cmd, arg); } +static int get_num_of_incomplete_fibs(struct aac_dev *aac) +{ + + unsigned long flags; + struct scsi_device *sdev = NULL; + struct Scsi_Host *shost = aac->scsi_host_ptr; + struct scsi_cmnd *scmnd = NULL; + struct device *ctrl_dev; + + int mlcnt = 0; + int llcnt = 0; + int ehcnt = 0; + int fwcnt = 0; + int krlcnt = 0; + + __shost_for_each_device(sdev, shost) { + spin_lock_irqsave(&sdev->list_lock, flags); + list_for_each_entry(scmnd, &sdev->cmd_list, list) { + switch (scmnd->SCp.phase) { + case AAC_OWNER_FIRMWARE: + fwcnt++; + break; + case AAC_OWNER_ERROR_HANDLER: + ehcnt++; + break; + case AAC_OWNER_LOWLEVEL: + llcnt++; + break; + case AAC_OWNER_MIDLEVEL: + mlcnt++; + break; + default: + krlcnt++; + break; + } + } + spin_unlock_irqrestore(&sdev->list_lock, flags); + } + + ctrl_dev = &aac->pdev->dev; + + dev_info(ctrl_dev, "outstanding cmd: midlevel-%d\n", mlcnt); + dev_info(ctrl_dev, "outstanding cmd: lowlevel-%d\n", llcnt); + dev_info(ctrl_dev, "outstanding cmd: error handler-%d\n", ehcnt); + dev_info(ctrl_dev, "outstanding cmd: firmware-%d\n", fwcnt); + dev_info(ctrl_dev, "outstanding cmd: kernel-%d\n", krlcnt); + + return mlcnt + llcnt + ehcnt + fwcnt; +} + static int aac_eh_abort(struct scsi_cmnd* cmd) { struct scsi_device * dev = cmd->device; @@ -853,8 +903,6 @@ static int aac_eh_reset(struct scsi_cmnd* cmd) pr_err("%s: Host adapter reset request timed out\n", AAC_DRIVERNAME); } else { - struct scsi_cmnd *command; - unsigned long flags; /* Mark the assoc. FIB to not complete, eh handler does this */ for (count = 0; @@ -873,41 +921,9 @@ static int aac_eh_reset(struct scsi_cmnd* cmd) pr_err("%s: Host adapter reset request. SCSI hang ?\n", AAC_DRIVERNAME); - count = aac_check_health(aac); - if (count) - return count; - /* - * Wait for all commands to complete to this specific - * target (block maximum 60 seconds). - */ - for (count = 60; count; --count) { - int active = aac->in_reset; - - if (active == 0) - __shost_for_each_device(dev, host) { - spin_lock_irqsave(&dev->list_lock, flags); - list_for_each_entry(command, &dev->cmd_list, - list) { - if ((command != cmd) && - (command->SCp.phase == - AAC_OWNER_FIRMWARE)) { - active++; - break; - } - } - spin_unlock_irqrestore(&dev->list_lock, flags); - if (active) - break; - - } - /* - * We can exit If all the commands are complete - */ - if (active == 0) - return SUCCESS; - ssleep(1); - } - pr_err("%s: SCSI bus appears hung\n", AAC_DRIVERNAME); + count = get_num_of_incomplete_fibs(aac); + if (count == 0) + return SUCCESS; /* * This adapter needs a blind reset, only do so for -- cgit v1.2.3 From 144ecd41f0f43600f0c103cb6d0d2f1619d70e96 Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Wed, 10 May 2017 09:39:42 -0700 Subject: scsi: aacraid: Print ctrl status before eh reset Log the status of the controller before issuing a reset. Signed-off-by: Raghava Aditya Renukunta Reviewed-by: David Carroll Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/linit.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index 0a8d303c8bc9..3dea4384489d 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -827,6 +827,7 @@ static int aac_eh_reset(struct scsi_cmnd* cmd) int count; u32 bus, cid; int ret = FAILED; + int status = 0; bus = aac_logical_to_phys(scmd_channel(cmd)); cid = scmd_id(cmd); @@ -921,6 +922,14 @@ static int aac_eh_reset(struct scsi_cmnd* cmd) pr_err("%s: Host adapter reset request. SCSI hang ?\n", AAC_DRIVERNAME); + /* + * Check the health of the controller + */ + status = aac_adapter_check_health(aac); + if (status) + dev_err(&aac->pdev->dev, "Adapter health - %d\n", + status); + count = get_num_of_incomplete_fibs(aac); if (count == 0) return SUCCESS; -- cgit v1.2.3 From 6b24d425881792b16ccf2189b43d57b4aff2a4e6 Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Wed, 10 May 2017 09:39:43 -0700 Subject: scsi: aacraid: Using single reset mask for IOP reset The driver can now trigger IOP reset with a single reset mask. Removed code that retrieves a reset_mask from the firmware. Signed-off-by: Raghava Aditya Renukunta Reviewed-by: David Carroll Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/aacraid.h | 5 ++++- drivers/scsi/aacraid/src.c | 16 ++-------------- 2 files changed, 6 insertions(+), 15 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index cb7d69939a34..c74e1aa18a20 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -2378,6 +2378,7 @@ struct revision #define SOFT_RESET_TIME 60 + struct aac_common { /* @@ -2488,7 +2489,9 @@ struct aac_hba_info { #define IOP_RESET_FW_FIB_DUMP 0x00000034 #define IOP_RESET 0x00001000 #define IOP_RESET_ALWAYS 0x00001001 -#define RE_INIT_ADAPTER 0x000000ee +#define RE_INIT_ADAPTER 0x000000ee + +#define IOP_SRC_RESET_MASK 0x00000100 /* * Adapter Status Register diff --git a/drivers/scsi/aacraid/src.c b/drivers/scsi/aacraid/src.c index 7b0410e0f569..f278a21c86db 100644 --- a/drivers/scsi/aacraid/src.c +++ b/drivers/scsi/aacraid/src.c @@ -704,22 +704,10 @@ static void aac_send_iop_reset(struct aac_dev *dev, int bled) 0, 0, 0, 0, 0, 0, &var, &reset_mask, NULL, NULL, NULL); - if ((bled || var != 0x00000001) && !dev->doorbell_mask) - bled = -EINVAL; - else if (dev->doorbell_mask) { - reset_mask = dev->doorbell_mask; - bled = 0; - var = 0x00000001; - } - aac_set_intx_mode(dev); - if (!bled && (dev->supplement_adapter_info.supported_options2 & - AAC_OPTION_DOORBELL_RESET)) { - src_writel(dev, MUnit.IDR, reset_mask); - } else { - src_writel(dev, MUnit.IDR, 0x100); - } + src_writel(dev, MUnit.IDR, IOP_SRC_RESET_MASK); + msleep(30000); } -- cgit v1.2.3 From 80c7d8a5cffa7187c3b3b78eb67705dae91e9a1a Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Wed, 10 May 2017 09:39:44 -0700 Subject: scsi: aacraid: Rework IOP reset Reworked IOP reset to remove unneeded variable and created a helper function to notify fw of an imminent IOP reset. Signed-off-by: Raghava Aditya Renukunta Reviewed-by: David Carroll Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/src.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/src.c b/drivers/scsi/aacraid/src.c index f278a21c86db..39ecb58762a7 100644 --- a/drivers/scsi/aacraid/src.c +++ b/drivers/scsi/aacraid/src.c @@ -694,15 +694,17 @@ static void aac_dump_fw_fib_iop_reset(struct aac_dev *dev) 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL); } -static void aac_send_iop_reset(struct aac_dev *dev, int bled) +static void aac_notify_fw_of_iop_reset(struct aac_dev *dev) { - u32 var, reset_mask; + aac_adapter_sync_cmd(dev, IOP_RESET_ALWAYS, 0, 0, 0, 0, 0, 0, NULL, + NULL, NULL, NULL, NULL); +} +static void aac_send_iop_reset(struct aac_dev *dev) +{ aac_dump_fw_fib_iop_reset(dev); - bled = aac_adapter_sync_cmd(dev, IOP_RESET_ALWAYS, - 0, 0, 0, 0, 0, 0, &var, - &reset_mask, NULL, NULL, NULL); + aac_notify_fw_of_iop_reset(dev); aac_set_intx_mode(dev); @@ -742,7 +744,7 @@ static int aac_src_restart_adapter(struct aac_dev *dev, int bled, u8 reset_type) switch (reset_type) { case IOP_HWSOFT_RESET: - aac_send_iop_reset(dev, bled); + aac_send_iop_reset(dev); /* * Check to see if KERNEL_UP_AND_RUNNING * Wait for the adapter to be up and running. @@ -769,7 +771,7 @@ static int aac_src_restart_adapter(struct aac_dev *dev, int bled, u8 reset_type) } break; default: - aac_send_iop_reset(dev, bled); + aac_send_iop_reset(dev); break; } -- cgit v1.2.3 From 0e9973ed3382652b324971753745cfe08488bb9f Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Wed, 10 May 2017 09:39:45 -0700 Subject: scsi: aacraid: Add periodic checks to see IOP reset status Added function that waits with a timeout for the ctrl to be up and running after triggering an IOP reset. Also removed 30 sec sleep as it is not needed. Signed-off-by: Raghava Aditya Renukunta Reviewed-by: David Carroll Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/aacraid.h | 1 + drivers/scsi/aacraid/src.c | 45 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 2 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index c74e1aa18a20..bd0afdd7f2e4 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -2516,6 +2516,7 @@ struct aac_hba_info { #define SELF_TEST_FAILED 0x00000004 #define MONITOR_PANIC 0x00000020 +#define KERNEL_BOOTING 0x00000040 #define KERNEL_UP_AND_RUNNING 0x00000080 #define KERNEL_PANIC 0x00000100 #define FLASH_UPD_PENDING 0x00002000 diff --git a/drivers/scsi/aacraid/src.c b/drivers/scsi/aacraid/src.c index 39ecb58762a7..cde4160c3e47 100644 --- a/drivers/scsi/aacraid/src.c +++ b/drivers/scsi/aacraid/src.c @@ -694,6 +694,37 @@ static void aac_dump_fw_fib_iop_reset(struct aac_dev *dev) 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL); } +static bool aac_is_ctrl_up_and_running(struct aac_dev *dev) +{ + bool ctrl_up = true; + unsigned long status, start; + bool is_up = false; + + start = jiffies; + do { + schedule(); + status = src_readl(dev, MUnit.OMR); + + if (status == 0xffffffff) + status = 0; + + if (status & KERNEL_BOOTING) { + start = jiffies; + continue; + } + + if (time_after(jiffies, start+HZ*SOFT_RESET_TIME)) { + ctrl_up = false; + break; + } + + is_up = status & KERNEL_UP_AND_RUNNING; + + } while (!is_up); + + return ctrl_up; +} + static void aac_notify_fw_of_iop_reset(struct aac_dev *dev) { aac_adapter_sync_cmd(dev, IOP_RESET_ALWAYS, 0, 0, 0, 0, 0, 0, NULL, @@ -709,8 +740,6 @@ static void aac_send_iop_reset(struct aac_dev *dev) aac_set_intx_mode(dev); src_writel(dev, MUnit.IDR, IOP_SRC_RESET_MASK); - - msleep(30000); } static void aac_send_hardware_soft_reset(struct aac_dev *dev) @@ -726,6 +755,7 @@ static void aac_send_hardware_soft_reset(struct aac_dev *dev) static int aac_src_restart_adapter(struct aac_dev *dev, int bled, u8 reset_type) { unsigned long status, start; + bool is_ctrl_up; if (bled < 0) goto invalid_out; @@ -745,6 +775,16 @@ static int aac_src_restart_adapter(struct aac_dev *dev, int bled, u8 reset_type) switch (reset_type) { case IOP_HWSOFT_RESET: aac_send_iop_reset(dev); + + /* + * Creates a delay or wait till up and running comes thru + */ + is_ctrl_up = aac_is_ctrl_up_and_running(dev); + if (!is_ctrl_up) + dev_err(&dev->pdev->dev, "IOP reset failed\n"); + else + goto set_startup; + /* * Check to see if KERNEL_UP_AND_RUNNING * Wait for the adapter to be up and running. @@ -780,6 +820,7 @@ invalid_out: if (src_readl(dev, MUnit.OMR) & KERNEL_PANIC) return -ENODEV; +set_startup: if (startup_timeout < 300) startup_timeout = 300; -- cgit v1.2.3 From 77cb6d5ea6033e5d477947aa682728959d6c3f8f Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Wed, 10 May 2017 09:39:46 -0700 Subject: scsi: aacraid: Rework SOFT reset code Now the driver issues a soft reset and waits for the controller to be up and running by periodically checking on the status of the controller health registers. Also prevents ARC adapters from issuing soft reset if IOP resets failed. Signed-off-by: Raghava Aditya Renukunta Reviewed-by: David Carroll Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/src.c | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/src.c b/drivers/scsi/aacraid/src.c index cde4160c3e47..9ad60d63586d 100644 --- a/drivers/scsi/aacraid/src.c +++ b/drivers/scsi/aacraid/src.c @@ -754,8 +754,8 @@ static void aac_send_hardware_soft_reset(struct aac_dev *dev) static int aac_src_restart_adapter(struct aac_dev *dev, int bled, u8 reset_type) { - unsigned long status, start; bool is_ctrl_up; + int ret = 0; if (bled < 0) goto invalid_out; @@ -785,24 +785,21 @@ static int aac_src_restart_adapter(struct aac_dev *dev, int bled, u8 reset_type) else goto set_startup; - /* - * Check to see if KERNEL_UP_AND_RUNNING - * Wait for the adapter to be up and running. - * If !KERNEL_UP_AND_RUNNING issue HW Soft Reset - */ - status = src_readl(dev, MUnit.OMR); - if (dev->sa_firmware - && !(status & KERNEL_UP_AND_RUNNING)) { - start = jiffies; - do { - status = src_readl(dev, MUnit.OMR); - if (time_after(jiffies, - start+HZ*SOFT_RESET_TIME)) { - aac_send_hardware_soft_reset(dev); - start = jiffies; - } - } while (!(status & KERNEL_UP_AND_RUNNING)); + if (!dev->sa_firmware) { + ret = -ENODEV; + goto out; } + + aac_send_hardware_soft_reset(dev); + dev->msi_enabled = 0; + + is_ctrl_up = aac_is_ctrl_up_and_running(dev); + if (!is_ctrl_up) { + dev_err(&dev->pdev->dev, "SOFT reset failed\n"); + ret = -ENODEV; + goto out; + } + break; case HW_SOFT_RESET: if (dev->sa_firmware) { @@ -818,13 +815,14 @@ static int aac_src_restart_adapter(struct aac_dev *dev, int bled, u8 reset_type) invalid_out: if (src_readl(dev, MUnit.OMR) & KERNEL_PANIC) - return -ENODEV; + ret = -ENODEV; set_startup: if (startup_timeout < 300) startup_timeout = 300; - return 0; +out: + return ret; } /** -- cgit v1.2.3 From 5aa60732520dd0476ed9e20047b837780bbb7799 Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Wed, 10 May 2017 09:39:47 -0700 Subject: scsi: aacraid: Rework aac_src_restart Removed switch case and replaced with if mask checks. Moved KERNEL_PANIC check to when bled is less than 0. Signed-off-by: Raghava Aditya Renukunta Reviewed-by: David Carroll Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/src.c | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/src.c b/drivers/scsi/aacraid/src.c index 9ad60d63586d..e7b4c0782806 100644 --- a/drivers/scsi/aacraid/src.c +++ b/drivers/scsi/aacraid/src.c @@ -772,8 +772,7 @@ static int aac_src_restart_adapter(struct aac_dev *dev, int bled, u8 reset_type) dev->a_ops.adapter_enable_int = aac_src_disable_interrupt; - switch (reset_type) { - case IOP_HWSOFT_RESET: + if (reset_type & HW_IOP_RESET) { aac_send_iop_reset(dev); /* @@ -784,12 +783,14 @@ static int aac_src_restart_adapter(struct aac_dev *dev, int bled, u8 reset_type) dev_err(&dev->pdev->dev, "IOP reset failed\n"); else goto set_startup; + } - if (!dev->sa_firmware) { - ret = -ENODEV; - goto out; - } + if (!dev->sa_firmware) { + ret = -ENODEV; + goto out; + } + if (reset_type & HW_SOFT_RESET) { aac_send_hardware_soft_reset(dev); dev->msi_enabled = 0; @@ -799,30 +800,19 @@ static int aac_src_restart_adapter(struct aac_dev *dev, int bled, u8 reset_type) ret = -ENODEV; goto out; } - - break; - case HW_SOFT_RESET: - if (dev->sa_firmware) { - aac_send_hardware_soft_reset(dev); - aac_set_intx_mode(dev); - } - break; - default: - aac_send_iop_reset(dev); - break; } -invalid_out: - - if (src_readl(dev, MUnit.OMR) & KERNEL_PANIC) - ret = -ENODEV; - set_startup: if (startup_timeout < 300) startup_timeout = 300; out: return ret; + +invalid_out: + if (src_readl(dev, MUnit.OMR) & KERNEL_PANIC) + ret = -ENODEV; +goto out; } /** -- cgit v1.2.3 From 9473ddb2b037161b0bf16b60b37694f961fd6d48 Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Wed, 10 May 2017 09:39:48 -0700 Subject: scsi: aacraid: Use correct function to get ctrl health The command thread checks the ctrl health periodically before sending updates to the controller. The function that it uses is aac_check_health which does more than get the health status. Signed-off-by: Raghava Aditya Renukunta Reviewed-by: David Carroll Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/commsup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c index aa4f47bf10b1..c48a245a6d47 100644 --- a/drivers/scsi/aacraid/commsup.c +++ b/drivers/scsi/aacraid/commsup.c @@ -2475,7 +2475,7 @@ int aac_command_thread(void *data) if ((time_before(next_check_jiffies,next_jiffies)) && ((difference = next_check_jiffies - jiffies) <= 0)) { next_check_jiffies = next_jiffies; - if (aac_check_health(dev) == 0) { + if (aac_adapter_check_health(dev) == 0) { difference = ((long)(unsigned)check_interval) * HZ; next_check_jiffies = jiffies + difference; @@ -2488,7 +2488,7 @@ int aac_command_thread(void *data) int ret; /* Don't even try to talk to adapter if its sick */ - ret = aac_check_health(dev); + ret = aac_adapter_check_health(dev); if (ret || !dev->queues) break; next_check_jiffies = jiffies -- cgit v1.2.3 From 8c41b9b7987e404b3c922cf9d8ff941112051837 Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Wed, 10 May 2017 09:39:49 -0700 Subject: scsi: aacraid: Make sure ioctl returns on controller reset Made sure that ioctl commands return in case of a controller reset. Signed-off-by: Raghava Aditya Renukunta Reviewed-by: Dave Carroll Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/commsup.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c index c48a245a6d47..1541ebc1efa2 100644 --- a/drivers/scsi/aacraid/commsup.c +++ b/drivers/scsi/aacraid/commsup.c @@ -803,11 +803,11 @@ int aac_hba_send(u8 command, struct fib *fibptr, fib_callback callback, if (aac_check_eeh_failure(dev)) return -EFAULT; - /* Only set for first known interruptable command */ - if (down_interruptible(&fibptr->event_wait)) { + fibptr->flags |= FIB_CONTEXT_FLAG_WAIT; + if (down_interruptible(&fibptr->event_wait)) fibptr->done = 2; - up(&fibptr->event_wait); - } + fibptr->flags &= ~(FIB_CONTEXT_FLAG_WAIT); + spin_lock_irqsave(&fibptr->event_lock, flags); if ((fibptr->done == 0) || (fibptr->done == 2)) { fibptr->done = 2; /* Tell interrupt we aborted */ @@ -1514,6 +1514,7 @@ static int _aac_reset_adapter(struct aac_dev *aac, int forced, u8 reset_type) int jafo = 0; int bled; u64 dmamask; + int num_of_fibs = 0; /* * Assumptions: @@ -1547,10 +1548,20 @@ static int _aac_reset_adapter(struct aac_dev *aac, int forced, u8 reset_type) /* * Loop through the fibs, close the synchronous FIBS */ - for (retval = 1, index = 0; index < (aac->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB); index++) { + retval = 1; + num_of_fibs = aac->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB; + for (index = 0; index < num_of_fibs; index++) { + struct fib *fib = &aac->fibs[index]; - if (!(fib->hw_fib_va->header.XferState & cpu_to_le32(NoResponseExpected | Async)) && - (fib->hw_fib_va->header.XferState & cpu_to_le32(ResponseExpected))) { + __le32 XferState = fib->hw_fib_va->header.XferState; + bool is_response_expected = false; + + if (!(XferState & cpu_to_le32(NoResponseExpected | Async)) && + (XferState & cpu_to_le32(ResponseExpected))) + is_response_expected = true; + + if (is_response_expected + || fib->flags & FIB_CONTEXT_FLAG_WAIT) { unsigned long flagv; spin_lock_irqsave(&fib->event_lock, flagv); up(&fib->event_wait); -- cgit v1.2.3 From 786e898c86ee532b76ca5e2ec0b8c2d464d553db Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Wed, 10 May 2017 09:39:50 -0700 Subject: scsi: aacraid: Enable ctrl reset for both hba and arc Make sure that IOP and SOFT reset are enabled for both for both arc and hba1000 controllers. Signed-off-by: Raghava Aditya Renukunta Reviewed-by: David Carroll Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/linit.c | 77 +++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 37 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index 3dea4384489d..d933d2f93ed7 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -828,6 +828,11 @@ static int aac_eh_reset(struct scsi_cmnd* cmd) u32 bus, cid; int ret = FAILED; int status = 0; + __le32 supported_options2 = 0; + bool is_mu_reset; + bool is_ignore_reset; + bool is_doorbell_reset; + bus = aac_logical_to_phys(scmd_channel(cmd)); cid = scmd_id(cmd); @@ -900,9 +905,9 @@ static int aac_eh_reset(struct scsi_cmnd* cmd) msleep(1000); } - if (ret != SUCCESS) - pr_err("%s: Host adapter reset request timed out\n", - AAC_DRIVERNAME); + if (ret == SUCCESS) + goto out; + } else { /* Mark the assoc. FIB to not complete, eh handler does this */ @@ -918,44 +923,42 @@ static int aac_eh_reset(struct scsi_cmnd* cmd) cmd->SCp.phase = AAC_OWNER_ERROR_HANDLER; } } + } - pr_err("%s: Host adapter reset request. SCSI hang ?\n", - AAC_DRIVERNAME); + pr_err("%s: Host adapter reset request. SCSI hang ?\n", AAC_DRIVERNAME); + + /* + * Check the health of the controller + */ + status = aac_adapter_check_health(aac); + if (status) + dev_err(&aac->pdev->dev, "Adapter health - %d\n", status); + + count = get_num_of_incomplete_fibs(aac); + if (count == 0) + return SUCCESS; - /* - * Check the health of the controller - */ - status = aac_adapter_check_health(aac); - if (status) - dev_err(&aac->pdev->dev, "Adapter health - %d\n", - status); - - count = get_num_of_incomplete_fibs(aac); - if (count == 0) - return SUCCESS; - - /* - * This adapter needs a blind reset, only do so for - * Adapters that support a register, instead of a commanded, - * reset. - */ - if (((aac->supplement_adapter_info.supported_options2 & - AAC_OPTION_MU_RESET) || - (aac->supplement_adapter_info.supported_options2 & - AAC_OPTION_DOORBELL_RESET)) && - aac_check_reset && - ((aac_check_reset != 1) || - !(aac->supplement_adapter_info.supported_options2 & - AAC_OPTION_IGNORE_RESET))) { - /* Bypass wait for command quiesce */ - aac_reset_adapter(aac, 2, IOP_HWSOFT_RESET); - } - ret = SUCCESS; - } /* - * Cause an immediate retry of the command with a ten second delay - * after successful tur + * Check if reset is supported by the firmware */ + supported_options2 = aac->supplement_adapter_info.supported_options2; + is_mu_reset = supported_options2 & AAC_OPTION_MU_RESET; + is_doorbell_reset = supported_options2 & AAC_OPTION_DOORBELL_RESET; + is_ignore_reset = supported_options2 & AAC_OPTION_IGNORE_RESET; + /* + * This adapter needs a blind reset, only do so for + * Adapters that support a register, instead of a commanded, + * reset. + */ + if ((is_mu_reset || is_doorbell_reset) + && aac_check_reset + && (aac_check_reset != -1 || !is_ignore_reset)) { + /* Bypass wait for command quiesce */ + aac_reset_adapter(aac, 2, IOP_HWSOFT_RESET); + } + ret = SUCCESS; + +out: return ret; } -- cgit v1.2.3 From 4a76be0dc53a2d725ee126a806e5988135952a05 Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Wed, 10 May 2017 09:39:51 -0700 Subject: scsi: aacraid: Add reset debugging statements Added info and error messages in controller reset function to log information about the status of the IOP/SOFT reset. Signed-off-by: Raghava Aditya Renukunta Reviewed-by: David Carroll Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/src.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/src.c b/drivers/scsi/aacraid/src.c index e7b4c0782806..48c2b2b34b72 100644 --- a/drivers/scsi/aacraid/src.c +++ b/drivers/scsi/aacraid/src.c @@ -761,8 +761,7 @@ static int aac_src_restart_adapter(struct aac_dev *dev, int bled, u8 reset_type) goto invalid_out; if (bled) - pr_err("%s%d: adapter kernel panic'd %x.\n", - dev->name, dev->id, bled); + dev_err(&dev->pdev->dev, "adapter kernel panic'd %x.\n", bled); /* * When there is a BlinkLED, IOP_RESET has not effect @@ -772,7 +771,10 @@ static int aac_src_restart_adapter(struct aac_dev *dev, int bled, u8 reset_type) dev->a_ops.adapter_enable_int = aac_src_disable_interrupt; + dev_err(&dev->pdev->dev, "Controller reset type is %d\n", reset_type); + if (reset_type & HW_IOP_RESET) { + dev_info(&dev->pdev->dev, "Issuing IOP reset\n"); aac_send_iop_reset(dev); /* @@ -781,16 +783,20 @@ static int aac_src_restart_adapter(struct aac_dev *dev, int bled, u8 reset_type) is_ctrl_up = aac_is_ctrl_up_and_running(dev); if (!is_ctrl_up) dev_err(&dev->pdev->dev, "IOP reset failed\n"); - else + else { + dev_info(&dev->pdev->dev, "IOP reset succeded\n"); goto set_startup; + } } if (!dev->sa_firmware) { + dev_err(&dev->pdev->dev, "ARC Reset attempt failed\n"); ret = -ENODEV; goto out; } if (reset_type & HW_SOFT_RESET) { + dev_info(&dev->pdev->dev, "Issuing SOFT reset\n"); aac_send_hardware_soft_reset(dev); dev->msi_enabled = 0; @@ -799,7 +805,8 @@ static int aac_src_restart_adapter(struct aac_dev *dev, int bled, u8 reset_type) dev_err(&dev->pdev->dev, "SOFT reset failed\n"); ret = -ENODEV; goto out; - } + } else + dev_info(&dev->pdev->dev, "SOFT reset succeded\n"); } set_startup: -- cgit v1.2.3 From 395e5df79a9588abf1099ea746f11872c9086252 Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Wed, 10 May 2017 09:39:52 -0700 Subject: scsi: aacraid: Remove reference to Series-9 Remove reference to Series-9 HBA and created arc ctrl check function. Signed-off-by: Prasad B Munirathnam Signed-off-by: Raghava Aditya Renukunta Reviewed-by: David Carroll Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/aacraid.h | 13 ++++++++++++- drivers/scsi/aacraid/comminit.c | 18 ++++-------------- drivers/scsi/aacraid/commsup.c | 5 +---- drivers/scsi/aacraid/linit.c | 9 ++------- 4 files changed, 19 insertions(+), 26 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index bd0afdd7f2e4..861a35c77c01 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -424,7 +424,6 @@ struct aac_ciss_identify_pd { #define PMC_DEVICE_S6 0x28b #define PMC_DEVICE_S7 0x28c #define PMC_DEVICE_S8 0x28d -#define PMC_DEVICE_S9 0x28f #define aac_phys_to_logical(x) ((x)+1) #define aac_logical_to_phys(x) ((x)?(x)-1:0) @@ -2689,6 +2688,18 @@ int aac_probe_container(struct aac_dev *dev, int cid); int _aac_rx_init(struct aac_dev *dev); int aac_rx_select_comm(struct aac_dev *dev, int comm); int aac_rx_deliver_producer(struct fib * fib); + +static inline int aac_is_src(struct aac_dev *dev) +{ + u16 device = dev->pdev->device; + + if (device == PMC_DEVICE_S6 || + device == PMC_DEVICE_S7 || + device == PMC_DEVICE_S8) + return 1; + return 0; +} + char * get_container_type(unsigned type); extern int numacb; extern char aac_driver_version[]; diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c index 1151505853cf..9ee025b1d0e0 100644 --- a/drivers/scsi/aacraid/comminit.c +++ b/drivers/scsi/aacraid/comminit.c @@ -53,11 +53,8 @@ static inline int aac_is_msix_mode(struct aac_dev *dev) { u32 status = 0; - if (dev->pdev->device == PMC_DEVICE_S6 || - dev->pdev->device == PMC_DEVICE_S7 || - dev->pdev->device == PMC_DEVICE_S8) { + if (aac_is_src(dev)) status = src_readl(dev, MUnit.OMR); - } return (status & AAC_INT_MODE_MSIX); } @@ -325,9 +322,7 @@ int aac_send_shutdown(struct aac_dev * dev) /* FIB should be freed only after getting the response from the F/W */ if (status != -ERESTARTSYS) aac_fib_free(fibctx); - if ((dev->pdev->device == PMC_DEVICE_S7 || - dev->pdev->device == PMC_DEVICE_S8 || - dev->pdev->device == PMC_DEVICE_S9) && + if (aac_is_src(dev) && dev->msi_enabled) aac_set_intx_mode(dev); return status; @@ -583,9 +578,7 @@ struct aac_dev *aac_init_adapter(struct aac_dev *dev) dev->max_fib_size = status[1] & 0xFFE0; host->sg_tablesize = status[2] >> 16; dev->sg_tablesize = status[2] & 0xFFFF; - if (dev->pdev->device == PMC_DEVICE_S7 || - dev->pdev->device == PMC_DEVICE_S8 || - dev->pdev->device == PMC_DEVICE_S9) { + if (aac_is_src(dev)) { if (host->can_queue > (status[3] >> 16) - AAC_NUM_MGT_FIB) host->can_queue = (status[3] >> 16) - @@ -604,10 +597,7 @@ struct aac_dev *aac_init_adapter(struct aac_dev *dev) pr_warn("numacb=%d ignored\n", numacb); } - if (dev->pdev->device == PMC_DEVICE_S6 || - dev->pdev->device == PMC_DEVICE_S7 || - dev->pdev->device == PMC_DEVICE_S8 || - dev->pdev->device == PMC_DEVICE_S9) + if (aac_is_src(dev)) aac_define_int_mode(dev); /* * Ok now init the communication subsystem diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c index 1541ebc1efa2..1c617ccfaf12 100644 --- a/drivers/scsi/aacraid/commsup.c +++ b/drivers/scsi/aacraid/commsup.c @@ -2591,10 +2591,7 @@ void aac_free_irq(struct aac_dev *dev) int cpu; cpu = cpumask_first(cpu_online_mask); - if (dev->pdev->device == PMC_DEVICE_S6 || - dev->pdev->device == PMC_DEVICE_S7 || - dev->pdev->device == PMC_DEVICE_S8 || - dev->pdev->device == PMC_DEVICE_S9) { + if (aac_is_src(dev)) { if (dev->max_msix > 1) { for (i = 0; i < dev->max_msix; i++) free_irq(pci_irq_vector(dev->pdev, i), diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index d933d2f93ed7..0f277df73af0 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -1416,10 +1416,7 @@ static void __aac_shutdown(struct aac_dev * aac) kthread_stop(aac->thread); } aac_adapter_disable_int(aac); - if (aac->pdev->device == PMC_DEVICE_S6 || - aac->pdev->device == PMC_DEVICE_S7 || - aac->pdev->device == PMC_DEVICE_S8 || - aac->pdev->device == PMC_DEVICE_S9) { + if (aac_is_src(aac)) { if (aac->max_msix > 1) { for (i = 0; i < aac->max_msix; i++) { free_irq(pci_irq_vector(aac->pdev, i), @@ -1684,9 +1681,7 @@ static int aac_acquire_resources(struct aac_dev *dev) aac_adapter_enable_int(dev); - if ((dev->pdev->device == PMC_DEVICE_S7 || - dev->pdev->device == PMC_DEVICE_S8 || - dev->pdev->device == PMC_DEVICE_S9)) + if (aac_is_src(dev)) aac_define_int_mode(dev); if (dev->msi_enabled) -- cgit v1.2.3 From 216e80ff78cd2fe1a92c9e4565d578e540e35cc8 Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Wed, 10 May 2017 09:39:53 -0700 Subject: scsi: aacraid: Update driver version to 50834 Update the driver version to 50834 Signed-off-by: Raghava Aditya Renukunta Reviewed-by: David Carroll Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/aacraid.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index 861a35c77c01..d31a9bc2ba69 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -97,7 +97,7 @@ enum { #define PMC_GLOBAL_INT_BIT0 0x00000001 #ifndef AAC_DRIVER_BUILD -# define AAC_DRIVER_BUILD 50792 +# define AAC_DRIVER_BUILD 50834 # define AAC_DRIVER_BRANCH "-custom" #endif #define MAXIMUM_NUM_CONTAINERS 32 -- cgit v1.2.3 From 5cc973f09e21b5a2f746307641879bc9f1da623b Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Mon, 15 May 2017 15:56:05 +0100 Subject: scsi: aacraid: fix leak of data from stack back to userspace The fields sense_data_size and sense_data are unitialized garbage from the stack and are being copied back to userspace. Fix this leak of stack information by ensuring they are zero'd. Detected by CoverityScan, CID#1435473 ("Uninitialized scalar variable") Fixes: 423400e64d377 ("scsi: aacraid: Include HBA direct interface") Signed-off-by: Colin Ian King Acked-by: Dave Carroll Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/commctrl.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c index 106b9332f718..6bb6ed48e31d 100644 --- a/drivers/scsi/aacraid/commctrl.c +++ b/drivers/scsi/aacraid/commctrl.c @@ -955,6 +955,8 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) reply.srb_status = SRB_STATUS_SUCCESS; reply.scsi_status = 0; reply.data_xfer_length = byte_count; + reply.sense_data_size = 0; + memset(reply.sense_data, 0, AAC_SENSE_BUFFERSIZE); } else { reply.srb_status = err->service_response; reply.scsi_status = err->status; -- cgit v1.2.3 From 342ffc26693b528648bdc9377e51e4f2450b4860 Mon Sep 17 00:00:00 2001 From: Seth Forshee Date: Fri, 23 Jun 2017 09:04:22 -0500 Subject: scsi: aacraid: Don't copy uninitialized stack memory to userspace Both aac_send_raw_srb() and aac_get_hba_info() may copy stack allocated structs to userspace without initializing all members of these structs. Clear out this memory to prevent information leaks. Fixes: 423400e64d377 ("scsi: aacraid: Include HBA direct interface") Fixes: c799d519bf088 ("scsi: aacraid: Retrieve HBA host information ioctl") Signed-off-by: Seth Forshee Reviewed-by: Johannes Thumshirn Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/commctrl.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c index 6bb6ed48e31d..9ab0fa959d83 100644 --- a/drivers/scsi/aacraid/commctrl.c +++ b/drivers/scsi/aacraid/commctrl.c @@ -949,6 +949,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) &((struct aac_native_hba *)srbfib->hw_fib_va)->resp.err; struct aac_srb_reply reply; + memset(&reply, 0, sizeof(reply)); reply.status = ST_OK; if (srbfib->flags & FIB_CONTEXT_FLAG_FASTRESP) { /* fast response */ @@ -1020,6 +1021,7 @@ static int aac_get_hba_info(struct aac_dev *dev, void __user *arg) { struct aac_hba_info hbainfo; + memset(&hbainfo, 0, sizeof(hbainfo)); hbainfo.adapter_number = (u8) dev->id; hbainfo.system_io_bus_number = dev->pdev->bus->number; hbainfo.device_number = (dev->pdev->devfn >> 3); -- cgit v1.2.3