From efbbbb10235a218119573e95968f1042ffda2972 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Wed, 15 Nov 2017 16:53:41 +0000 Subject: scsi: aacraid: remove unused variable managed_request_id Variable managed_request_id is being assigned but it is never read, hence it is redundant and can be removed. Cleans up clang warning: drivers/scsi/aacraid/linit.c:706:5: warning: Value stored to 'managed_request_id' is never read Signed-off-by: Colin Ian King Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/linit.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index c9252b138c1f..3677beff9c17 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -690,7 +690,6 @@ static int aac_eh_abort(struct scsi_cmnd* cmd) struct aac_hba_tm_req *tmf; int status; u64 address; - __le32 managed_request_id; pr_err("%s: Host adapter abort request (%d,%d,%d,%d)\n", AAC_DRIVERNAME, @@ -703,8 +702,6 @@ static int aac_eh_abort(struct scsi_cmnd* cmd) (fib->flags & FIB_CONTEXT_FLAG_NATIVE_HBA) && (fib->callback_data == cmd)) { found = 1; - managed_request_id = ((struct aac_hba_cmd_req *) - fib->hw_fib_va)->request_id; break; } } -- cgit v1.2.3 From f4e8708d3104437fd7716e957f38c265b0c509ef Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Tue, 26 Dec 2017 20:34:22 -0800 Subject: scsi: aacraid: Fix udev inquiry race condition When udev requests for a devices inquiry string, it might create multiple threads causing a race condition on the shared inquiry resource string. Created a buffer with the string for each thread. Cc: Fixes: 3bc8070fb75b3315 ([SCSI] aacraid: SMC vendor identification) Signed-off-by: Raghava Aditya Renukunta Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/aachba.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index af3e4d3f9735..548a3e73f10a 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -913,8 +913,16 @@ static void setinqstr(struct aac_dev *dev, void *data, int tindex) memset(str, ' ', sizeof(*str)); if (sup_adap_info->adapter_type_text[0]) { - char *cp = sup_adap_info->adapter_type_text; int c; + char *cp; + char *cname = kmemdup(sup_adap_info->adapter_type_text, + sizeof(sup_adap_info->adapter_type_text), + GFP_ATOMIC); + + if (!cname) + return; + + cp = cname; if ((cp[0] == 'A') && (cp[1] == 'O') && (cp[2] == 'C')) inqstrcpy("SMC", str->vid); else { @@ -923,7 +931,7 @@ static void setinqstr(struct aac_dev *dev, void *data, int tindex) ++cp; c = *cp; *cp = '\0'; - inqstrcpy(sup_adap_info->adapter_type_text, str->vid); + inqstrcpy(cname, str->vid); *cp = c; while (*cp && *cp != ' ') ++cp; @@ -937,8 +945,8 @@ static void setinqstr(struct aac_dev *dev, void *data, int tindex) cp[sizeof(str->pid)] = '\0'; } inqstrcpy (cp, str->pid); - if (c) - cp[sizeof(str->pid)] = c; + + kfree(cname); } else { struct aac_driver_ident *mp = aac_get_driver_ident(dev->cardtype); -- cgit v1.2.3 From dfb92a1f93345f51851f76d567a608da09eb2347 Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Tue, 26 Dec 2017 20:34:23 -0800 Subject: scsi: aacraid: Do not attempt abort when Fw panicked Check if the adapter can receive abort requests, before sending aborts Signed-off-by: Raghava Aditya Renukunta Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/linit.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index 3677beff9c17..5eb07223087b 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -683,6 +683,9 @@ static int aac_eh_abort(struct scsi_cmnd* cmd) u32 bus, cid; int ret = FAILED; + if (aac_adapter_check_health(aac)) + return ret; + bus = aac_logical_to_phys(scmd_channel(cmd)); cid = scmd_id(cmd); if (aac->hba_map[bus][cid].devtype == AAC_DEVTYPE_NATIVE_RAW) { -- cgit v1.2.3 From c5313ae8e4e037bfaf5e56cb8d6efdb8e92ce437 Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Tue, 26 Dec 2017 20:34:24 -0800 Subject: scsi: aacraid: Fix hang in kdump Driver attempts to perform a device scan and device add after coming out of reset. At times when the kdump kernel loads and it tries to perform eh recovery, the device scan hangs since its commands are blocked because of the eh recovery. This should have shown up in normal eh recovery path (Should have been obvious) Remove the code that performs scanning.I can live without the rescanning support in the stable kernels but a hanging kdump/eh recovery needs to be fixed. Fixes: a2d0321dd532901e (scsi: aacraid: Reload offlined drives after controller reset) Cc: Reported-by: Douglas Miller Tested-by: Guilherme G. Piccoli Fixes: a2d0321dd532901e (scsi: aacraid: Reload offlined drives after controller reset) Signed-off-by: Raghava Aditya Renukunta Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/aachba.c | 1 - drivers/scsi/aacraid/commsup.c | 9 +-------- 2 files changed, 1 insertion(+), 9 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index 548a3e73f10a..7173ae53c526 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -918,7 +918,6 @@ static void setinqstr(struct aac_dev *dev, void *data, int tindex) char *cname = kmemdup(sup_adap_info->adapter_type_text, sizeof(sup_adap_info->adapter_type_text), GFP_ATOMIC); - if (!cname) return; diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c index 525a652dab48..ffbfd042be08 100644 --- a/drivers/scsi/aacraid/commsup.c +++ b/drivers/scsi/aacraid/commsup.c @@ -1672,14 +1672,7 @@ static int _aac_reset_adapter(struct aac_dev *aac, int forced, u8 reset_type) out: aac->in_reset = 0; scsi_unblock_requests(host); - /* - * Issue bus rescan to catch any configuration that might have - * occurred - */ - if (!retval) { - dev_info(&aac->pdev->dev, "Issuing bus rescan\n"); - scsi_scan_host(host); - } + if (jafo) { spin_lock_irq(host->host_lock); } -- cgit v1.2.3 From 95900629fa7dd0af7be5e9a8fdbc9d902fa3c8c7 Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Tue, 26 Dec 2017 20:34:25 -0800 Subject: scsi: aacraid: Do not remove offlined devices As part of the recovery process, the drivers removes offline devices ( done by the kernel) and then tries to add them back in the rescan code. Removing the device is like taking a sledgehammer to a nail. Set the device as running if it is marked offline. Signed-off-by: Raghava Aditya Renukunta Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/commsup.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c index ffbfd042be08..32b8bdb97c18 100644 --- a/drivers/scsi/aacraid/commsup.c +++ b/drivers/scsi/aacraid/commsup.c @@ -1658,14 +1658,12 @@ static int _aac_reset_adapter(struct aac_dev *aac, int forced, u8 reset_type) command->scsi_done(command); } /* - * Any Device that was already marked offline needs to be cleaned up + * Any Device that was already marked offline needs to be marked + * running */ __shost_for_each_device(dev, host) { - if (!scsi_device_online(dev)) { - sdev_printk(KERN_INFO, dev, "Removing offline device\n"); - scsi_remove_device(dev); - scsi_device_put(dev); - } + if (!scsi_device_online(dev)) + scsi_device_set_state(dev, SDEV_RUNNING); } retval = 0; -- cgit v1.2.3 From f3a2327725b4f922dabb89e46ff66713cfa461c2 Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Tue, 26 Dec 2017 20:34:26 -0800 Subject: scsi: aacraid: Fix ioctl reset hang Driver would hang when attempting to send reset from the ioctl interface, since it would wait to retrieve the ioctl mutex at send shutdown. Set adapter shutdown and unlock mutex before sending down reset request. Signed-off-by: Raghava Aditya Renukunta Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/commctrl.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c index 9ab0fa959d83..a2b3430072c7 100644 --- a/drivers/scsi/aacraid/commctrl.c +++ b/drivers/scsi/aacraid/commctrl.c @@ -1052,9 +1052,13 @@ static int aac_send_reset_adapter(struct aac_dev *dev, void __user *arg) if (copy_from_user((void *)&reset, arg, sizeof(struct aac_reset_iop))) return -EFAULT; + dev->adapter_shutdown = 1; + + mutex_unlock(&dev->ioctl_mutex); retval = aac_reset_adapter(dev, 0, reset.reset_type); - return retval; + mutex_lock(&dev->ioctl_mutex); + return retval; } int aac_do_ioctl(struct aac_dev * dev, int cmd, void __user *arg) -- cgit v1.2.3 From d1471eb0faef9edd65cd44c1a3c1ff13c251fead Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Tue, 26 Dec 2017 20:34:27 -0800 Subject: scsi: aacraid: Allow reset_host sysfs var to recover Panicked Fw It is possible to restart the controller via the use of the reset_host sysfs variable. This does work for controllers that can no longer respond, since driver will attempt to send down a shutdown in this path. Check if the controller is able to receive commands before sending down a shutdown Signed-off-by: Raghava Aditya Renukunta Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/comminit.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c index 1bc623ad3faf..9eff246ba3a3 100644 --- a/drivers/scsi/aacraid/comminit.c +++ b/drivers/scsi/aacraid/comminit.c @@ -295,12 +295,10 @@ int aac_send_shutdown(struct aac_dev * dev) { struct fib * fibctx; struct aac_close *cmd; - int status; + int status = 0; - fibctx = aac_fib_alloc(dev); - if (!fibctx) - return -ENOMEM; - aac_fib_init(fibctx); + if (aac_adapter_check_health(dev)) + return status; if (!dev->adapter_shutdown) { mutex_lock(&dev->ioctl_mutex); @@ -308,6 +306,11 @@ int aac_send_shutdown(struct aac_dev * dev) mutex_unlock(&dev->ioctl_mutex); } + fibctx = aac_fib_alloc(dev); + if (!fibctx) + return -ENOMEM; + aac_fib_init(fibctx); + cmd = (struct aac_close *) fib_data(fibctx); cmd->command = cpu_to_le32(VM_CloseAll); cmd->cid = cpu_to_le32(0xfffffffe); -- cgit v1.2.3 From 97a4e8ac3f8a90fbec56bd3611d3e9dafffcdf2d Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Tue, 26 Dec 2017 20:34:28 -0800 Subject: scsi: aacraid: Refactor reset_host store function Refactored the reset_host store function to make consistent across code bases Signed-off-by: Raghava Aditya Renukunta Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/linit.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index 5eb07223087b..b2273e3cba62 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -1375,18 +1375,15 @@ static ssize_t aac_store_reset_adapter(struct device *device, const char *buf, size_t count) { int retval = -EACCES; - int bled = 0; - struct aac_dev *aac; - if (!capable(CAP_SYS_ADMIN)) return retval; - aac = (struct aac_dev *)class_to_shost(device)->hostdata; - bled = buf[0] == '!' ? 1:0; - retval = aac_reset_adapter(aac, bled, IOP_HWSOFT_RESET); + retval = aac_reset_adapter(shost_priv(class_to_shost(device)), + buf[0] == '!', IOP_HWSOFT_RESET); if (retval >= 0) retval = count; + return retval; } -- cgit v1.2.3 From 216ced02fa1638088d7908149d6500627b79b9f0 Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Tue, 26 Dec 2017 20:34:29 -0800 Subject: scsi: aacraid: Move code to wait for IO completion to shutdown func Ideally driver needs to wait for IO to be submitted or responded to before shutdown. Move code to wait for IO completion into shutdown path Signed-off-by: Raghava Aditya Renukunta Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/comminit.c | 36 ++++++++++++++++++++++++++++++++++++ drivers/scsi/aacraid/commsup.c | 25 ------------------------- 2 files changed, 36 insertions(+), 25 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c index 9eff246ba3a3..0dc7b5a4fea2 100644 --- a/drivers/scsi/aacraid/comminit.c +++ b/drivers/scsi/aacraid/comminit.c @@ -42,6 +42,8 @@ #include #include #include +#include +#include #include "aacraid.h" @@ -284,6 +286,38 @@ static void aac_queue_init(struct aac_dev * dev, struct aac_queue * q, u32 *mem, q->entries = qsize; } +static void aac_wait_for_io_completion(struct aac_dev *aac) +{ + unsigned long flagv = 0; + int i = 0; + + for (i = 60; i; --i) { + struct scsi_device *dev; + struct scsi_cmnd *command; + int active = 0; + + __shost_for_each_device(dev, aac->scsi_host_ptr) { + spin_lock_irqsave(&dev->list_lock, flagv); + list_for_each_entry(command, &dev->cmd_list, list) { + if (command->SCp.phase == AAC_OWNER_FIRMWARE) { + active++; + break; + } + } + spin_unlock_irqrestore(&dev->list_lock, flagv); + if (active) + break; + + } + /* + * We can exit If all the commands are complete + */ + if (active == 0) + break; + ssleep(1); + } +} + /** * aac_send_shutdown - shutdown an adapter * @dev: Adapter to shutdown @@ -306,6 +340,8 @@ int aac_send_shutdown(struct aac_dev * dev) mutex_unlock(&dev->ioctl_mutex); } + aac_wait_for_io_completion(dev); + fibctx = aac_fib_alloc(dev); if (!fibctx) return -ENOMEM; diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c index 32b8bdb97c18..9840bd3aee6c 100644 --- a/drivers/scsi/aacraid/commsup.c +++ b/drivers/scsi/aacraid/commsup.c @@ -1701,31 +1701,6 @@ int aac_reset_adapter(struct aac_dev *aac, int forced, u8 reset_type) */ host = aac->scsi_host_ptr; scsi_block_requests(host); - if (forced < 2) for (retval = 60; retval; --retval) { - struct scsi_device * dev; - struct scsi_cmnd * command; - int active = 0; - - __shost_for_each_device(dev, host) { - spin_lock_irqsave(&dev->list_lock, flagv); - list_for_each_entry(command, &dev->cmd_list, list) { - if (command->SCp.phase == AAC_OWNER_FIRMWARE) { - active++; - break; - } - } - spin_unlock_irqrestore(&dev->list_lock, flagv); - if (active) - break; - - } - /* - * We can exit If all the commands are complete - */ - if (active == 0) - break; - ssleep(1); - } /* Quiesce build, flush cache, write through mode */ if (forced < 2) -- cgit v1.2.3 From 8fb391827f57e5aea4157f7e1b8b005cd126545a Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Tue, 26 Dec 2017 20:34:30 -0800 Subject: scsi: aacraid: Create bmic submission function from bmic identify safw command submission is duplicated across many functions. Move the safw submission code from bmic identify into its own function for common use Signed-off-by: Raghava Aditya Renukunta Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/aachba.c | 147 +++++++++++++++++++++++++++-------------- drivers/scsi/aacraid/aacraid.h | 7 +- 2 files changed, 105 insertions(+), 49 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index 7173ae53c526..e02158d9cf65 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -1667,60 +1667,116 @@ static int aac_adapter_hba(struct fib *fib, struct scsi_cmnd *cmd) (void *) cmd); } -int aac_issue_bmic_identify(struct aac_dev *dev, u32 bus, u32 target) +static int aac_send_safw_bmic_cmd(struct aac_dev *dev, + struct aac_srb_unit *srbu, void *xfer_buf, int xfer_len) { - struct fib *fibptr; - struct aac_srb *srbcmd; - struct sgmap64 *sg64; - struct aac_ciss_identify_pd *identify_resp; - dma_addr_t addr; - u32 vbus, vid; - u16 fibsize, datasize; - int rcode = -ENOMEM; - + struct fib *fibptr; + dma_addr_t addr; + int rcode; + int fibsize; + struct aac_srb *srb; + struct aac_srb_reply *srb_reply; + struct sgmap64 *sg64; + u32 vbus; + u32 vid; + + if (!dev->sa_firmware) + return 0; + /* allocate FIB */ fibptr = aac_fib_alloc(dev); if (!fibptr) - goto out; + return -ENOMEM; - fibsize = sizeof(struct aac_srb) - - sizeof(struct sgentry) + sizeof(struct sgentry64); - datasize = sizeof(struct aac_ciss_identify_pd); + aac_fib_init(fibptr); + fibptr->hw_fib_va->header.XferState &= + ~cpu_to_le32(FastResponseCapable); - identify_resp = dma_alloc_coherent(&dev->pdev->dev, datasize, &addr, - GFP_KERNEL); - if (!identify_resp) - goto fib_free_ptr; + fibsize = sizeof(struct aac_srb) - sizeof(struct sgentry) + + sizeof(struct sgentry64); - vbus = (u32)le16_to_cpu(dev->supplement_adapter_info.virt_device_bus); - vid = (u32)le16_to_cpu(dev->supplement_adapter_info.virt_device_target); + /* allocate DMA buffer for response */ + addr = dma_map_single(&dev->pdev->dev, xfer_buf, xfer_len, + DMA_BIDIRECTIONAL); + if (dma_mapping_error(&dev->pdev->dev, addr)) { + rcode = -ENOMEM; + goto fib_error; + } - aac_fib_init(fibptr); + srb = fib_data(fibptr); + memcpy(srb, &srbu->srb, sizeof(struct aac_srb)); - srbcmd = (struct aac_srb *) fib_data(fibptr); - srbcmd->function = cpu_to_le32(SRBF_ExecuteScsi); - srbcmd->channel = cpu_to_le32(vbus); - srbcmd->id = cpu_to_le32(vid); - srbcmd->lun = 0; - srbcmd->flags = cpu_to_le32(SRB_DataIn); - srbcmd->timeout = cpu_to_le32(10); - srbcmd->retry_limit = 0; - srbcmd->cdb_size = cpu_to_le32(12); - srbcmd->count = cpu_to_le32(datasize); + vbus = (u32)le16_to_cpu( + dev->supplement_adapter_info.virt_device_bus); + vid = (u32)le16_to_cpu( + dev->supplement_adapter_info.virt_device_target); - memset(srbcmd->cdb, 0, sizeof(srbcmd->cdb)); - srbcmd->cdb[0] = 0x26; - srbcmd->cdb[2] = (u8)((AAC_MAX_LUN + target) & 0x00FF); - srbcmd->cdb[6] = CISS_IDENTIFY_PHYSICAL_DEVICE; + /* set the common request fields */ + srb->channel = cpu_to_le32(vbus); + srb->id = cpu_to_le32(vid); + srb->lun = 0; + srb->function = cpu_to_le32(SRBF_ExecuteScsi); + srb->timeout = 0; + srb->retry_limit = 0; + srb->cdb_size = cpu_to_le32(16); + srb->count = cpu_to_le32(xfer_len); + + sg64 = (struct sgmap64 *)&srb->sg; + sg64->count = cpu_to_le32(1); + sg64->sg[0].addr[1] = cpu_to_le32(upper_32_bits(addr)); + sg64->sg[0].addr[0] = cpu_to_le32(lower_32_bits(addr)); + sg64->sg[0].count = cpu_to_le32(xfer_len); - sg64 = (struct sgmap64 *)&srbcmd->sg; - sg64->count = cpu_to_le32(1); - sg64->sg[0].addr[1] = cpu_to_le32((u32)(((addr) >> 16) >> 16)); - sg64->sg[0].addr[0] = cpu_to_le32((u32)(addr & 0xffffffff)); - sg64->sg[0].count = cpu_to_le32(datasize); + /* + * Copy the updated data for other dumping or other usage if needed + */ + memcpy(&srbu->srb, srb, sizeof(struct aac_srb)); + + /* issue request to the controller */ + rcode = aac_fib_send(ScsiPortCommand64, fibptr, fibsize, FsaNormal, + 1, 1, NULL, NULL); + + if (rcode == -ERESTARTSYS) + rcode = -ERESTART; + + if (unlikely(rcode < 0)) + goto bmic_error; + + srb_reply = (struct aac_srb_reply *)fib_data(fibptr); + memcpy(&srbu->srb_reply, srb_reply, sizeof(struct aac_srb_reply)); + +bmic_error: + dma_unmap_single(&dev->pdev->dev, addr, xfer_len, DMA_BIDIRECTIONAL); +fib_error: + aac_fib_complete(fibptr); + aac_fib_free(fibptr); + return rcode; +} + +static int aac_issue_bmic_identify(struct aac_dev *dev, u32 bus, u32 target) +{ + int rcode = -ENOMEM; + u16 datasize; + struct aac_srb_unit srbu; + struct aac_srb *srbcmd; + struct aac_ciss_identify_pd *identify_resp; + + datasize = sizeof(struct aac_ciss_identify_pd); + identify_resp = kmalloc(datasize, GFP_KERNEL); + if (!identify_resp) + goto out; + + memset(&srbu, 0, sizeof(struct aac_srb_unit)); - rcode = aac_fib_send(ScsiPortCommand64, - fibptr, fibsize, FsaNormal, 1, 1, NULL, NULL); + srbcmd = &srbu.srb; + srbcmd->flags = cpu_to_le32(SRB_DataIn); + srbcmd->cdb[0] = 0x26; + srbcmd->cdb[2] = (u8)((AAC_MAX_LUN + target) & 0x00FF); + srbcmd->cdb[6] = CISS_IDENTIFY_PHYSICAL_DEVICE; + + rcode = aac_send_safw_bmic_cmd(dev, &srbu, identify_resp, datasize); + if (unlikely(rcode < 0)) + goto out; if (identify_resp->current_queue_depth_limit <= 0 || identify_resp->current_queue_depth_limit > 32) @@ -1729,12 +1785,7 @@ int aac_issue_bmic_identify(struct aac_dev *dev, u32 bus, u32 target) dev->hba_map[bus][target].qd_limit = identify_resp->current_queue_depth_limit; - dma_free_coherent(&dev->pdev->dev, datasize, identify_resp, addr); - - aac_fib_complete(fibptr); - -fib_free_ptr: - aac_fib_free(fibptr); + kfree(identify_resp); out: return rcode; } diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index 403a639574e5..bc2a0bc31540 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -2021,6 +2021,12 @@ struct aac_srb_reply __le32 sense_data_size; u8 sense_data[AAC_SENSE_BUFFERSIZE]; // Can this be SCSI_SENSE_BUFFERSIZE }; + +struct aac_srb_unit { + struct aac_srb srb; + struct aac_srb_reply srb_reply; +}; + /* * SRB Flags */ @@ -2634,7 +2640,6 @@ static inline int aac_adapter_check_health(struct aac_dev *dev) int aac_acquire_irq(struct aac_dev *dev); void aac_free_irq(struct aac_dev *dev); int aac_report_phys_luns(struct aac_dev *dev, struct fib *fibptr, int rescan); -int aac_issue_bmic_identify(struct aac_dev *dev, u32 bus, u32 target); const char *aac_driverinfo(struct Scsi_Host *); void aac_fib_vector_assign(struct aac_dev *dev); struct fib *aac_fib_alloc(struct aac_dev *dev); -- cgit v1.2.3 From 5480aa18375e6f1b42ec6029c23a57600b5b1c08 Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Tue, 26 Dec 2017 20:34:31 -0800 Subject: scsi: aacraid: Change phy luns function to use common bmic function Edit function that retrieves phy lun information to use common bmic function Signed-off-by: Raghava Aditya Renukunta Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/aachba.c | 75 +++++++++++++----------------------------- drivers/scsi/aacraid/aacraid.h | 2 +- drivers/scsi/aacraid/commsup.c | 11 +------ 3 files changed, 25 insertions(+), 63 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index e02158d9cf65..1853bd28e3f3 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -1853,66 +1853,37 @@ update_devtype: /** * aac_report_phys_luns() Process topology change * @dev: aac_dev structure - * @fibptr: fib pointer + * @rescan: Indicates rescan * * Execute a CISS REPORT PHYS LUNS and process the results into * the current hba_map. */ -int aac_report_phys_luns(struct aac_dev *dev, struct fib *fibptr, int rescan) +int aac_report_phys_luns(struct aac_dev *dev, int rescan) { - int fibsize, datasize; - struct aac_ciss_phys_luns_resp *phys_luns; + int rcode = -ENOMEM; + int datasize; struct aac_srb *srbcmd; - struct sgmap64 *sg64; - dma_addr_t addr; - u32 vbus, vid; - int rcode = 0; - - /* Thor SA Firmware -> CISS_REPORT_PHYSICAL_LUNS */ - fibsize = sizeof(struct aac_srb) - sizeof(struct sgentry) - + sizeof(struct sgentry64); - datasize = sizeof(struct aac_ciss_phys_luns_resp) - + (AAC_MAX_TARGETS - 1) * sizeof(struct _ciss_lun); - - phys_luns = dma_alloc_coherent(&dev->pdev->dev, datasize, &addr, - GFP_KERNEL); - if (phys_luns == NULL) { - rcode = -ENOMEM; - goto err_out; - } - - vbus = (u32) le16_to_cpu( - dev->supplement_adapter_info.virt_device_bus); - vid = (u32) le16_to_cpu( - dev->supplement_adapter_info.virt_device_target); - - aac_fib_init(fibptr); + struct aac_srb_unit srbu; + struct aac_ciss_phys_luns_resp *phys_luns; - srbcmd = (struct aac_srb *) fib_data(fibptr); - srbcmd->function = cpu_to_le32(SRBF_ExecuteScsi); - srbcmd->channel = cpu_to_le32(vbus); - srbcmd->id = cpu_to_le32(vid); - srbcmd->lun = 0; - srbcmd->flags = cpu_to_le32(SRB_DataIn); - srbcmd->timeout = cpu_to_le32(10); - srbcmd->retry_limit = 0; - srbcmd->cdb_size = cpu_to_le32(12); - srbcmd->count = cpu_to_le32(datasize); + datasize = sizeof(struct aac_ciss_phys_luns_resp) + + (AAC_MAX_TARGETS - 1) * sizeof(struct _ciss_lun); + phys_luns = kmalloc(datasize, GFP_KERNEL); + if (phys_luns == NULL) + goto err_out; - memset(srbcmd->cdb, 0, sizeof(srbcmd->cdb)); - srbcmd->cdb[0] = CISS_REPORT_PHYSICAL_LUNS; - srbcmd->cdb[1] = 2; /* extended reporting */ - srbcmd->cdb[8] = (u8)(datasize >> 8); - srbcmd->cdb[9] = (u8)(datasize); + memset(&srbu, 0, sizeof(struct aac_srb_unit)); - sg64 = (struct sgmap64 *) &srbcmd->sg; - sg64->count = cpu_to_le32(1); - sg64->sg[0].addr[1] = cpu_to_le32(upper_32_bits(addr)); - sg64->sg[0].addr[0] = cpu_to_le32(lower_32_bits(addr)); - sg64->sg[0].count = cpu_to_le32(datasize); + srbcmd = &srbu.srb; + srbcmd->flags = cpu_to_le32(SRB_DataIn); + srbcmd->cdb[0] = CISS_REPORT_PHYSICAL_LUNS; + srbcmd->cdb[1] = 2; /* extended reporting */ + srbcmd->cdb[8] = (u8)(datasize >> 8); + srbcmd->cdb[9] = (u8)(datasize); - rcode = aac_fib_send(ScsiPortCommand64, fibptr, fibsize, - FsaNormal, 1, 1, NULL, NULL); + rcode = aac_send_safw_bmic_cmd(dev, &srbu, phys_luns, datasize); + if (unlikely(rcode < 0)) + goto err_out; /* analyse data */ if (rcode >= 0 && phys_luns->resp_flag == 2) { @@ -1920,7 +1891,7 @@ int aac_report_phys_luns(struct aac_dev *dev, struct fib *fibptr, int rescan) aac_update_hba_map(dev, phys_luns, rescan); } - dma_free_coherent(&dev->pdev->dev, datasize, phys_luns, addr); + kfree(phys_luns); err_out: return rcode; } @@ -2030,7 +2001,7 @@ int aac_get_adapter_info(struct aac_dev* dev) if (!dev->sync_mode && dev->sa_firmware && dev->supplement_adapter_info.virt_device_bus != 0xffff) { /* Thor SA Firmware -> CISS_REPORT_PHYSICAL_LUNS */ - rcode = aac_report_phys_luns(dev, fibptr, AAC_INIT); + rcode = aac_report_phys_luns(dev, AAC_INIT); } if (!dev->in_reset) { diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index bc2a0bc31540..3a201681852b 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -2639,7 +2639,7 @@ static inline int aac_adapter_check_health(struct aac_dev *dev) int aac_acquire_irq(struct aac_dev *dev); void aac_free_irq(struct aac_dev *dev); -int aac_report_phys_luns(struct aac_dev *dev, struct fib *fibptr, int rescan); +int aac_report_phys_luns(struct aac_dev *dev, int rescan); const char *aac_driverinfo(struct Scsi_Host *); void aac_fib_vector_assign(struct aac_dev *dev); struct fib *aac_fib_alloc(struct aac_dev *dev); diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c index 9840bd3aee6c..f70f1122b474 100644 --- a/drivers/scsi/aacraid/commsup.c +++ b/drivers/scsi/aacraid/commsup.c @@ -1919,7 +1919,6 @@ static void aac_handle_sa_aif(struct aac_dev *dev, struct fib *fibptr) { int i, bus, target, container, rcode = 0; u32 events = 0; - struct fib *fib; struct scsi_device *sdev; if (fibptr->hbacmd_size & SA_AIF_HOTPLUG) @@ -1942,19 +1941,11 @@ static void aac_handle_sa_aif(struct aac_dev *dev, struct fib *fibptr) case SA_AIF_LDEV_CHANGE: case SA_AIF_BPCFG_CHANGE: - fib = aac_fib_alloc(dev); - if (!fib) { - pr_err("aac_handle_sa_aif: out of memory\n"); - return; - } for (bus = 0; bus < AAC_MAX_BUSES; bus++) for (target = 0; target < AAC_MAX_TARGETS; target++) dev->hba_map[bus][target].new_devtype = 0; - rcode = aac_report_phys_luns(dev, fib, AAC_RESCAN); - - if (rcode != -ERESTARTSYS) - aac_fib_free(fib); + rcode = aac_report_phys_luns(dev, AAC_RESCAN); aac_resolve_luns(dev); -- cgit v1.2.3 From b5a475e944447faa6a2110eea0419a7d2a156a0c Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Tue, 26 Dec 2017 20:34:32 -0800 Subject: scsi: aacraid: Refactor and rename to make mirror existing changes Rename variables and functions to make bmic identify, report phy luns to make them consistent across code internal existing code bases Signed-off-by: Raghava Aditya Renukunta Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/aachba.c | 36 +++++++++++++++++++----------------- drivers/scsi/aacraid/aacraid.h | 2 +- drivers/scsi/aacraid/commsup.c | 2 +- 3 files changed, 21 insertions(+), 19 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index 1853bd28e3f3..801aff0ba7ce 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -1753,17 +1753,18 @@ fib_error: return rcode; } -static int aac_issue_bmic_identify(struct aac_dev *dev, u32 bus, u32 target) +static int aac_issue_safw_bmic_identify(struct aac_dev *dev, + u32 bus, u32 target) { int rcode = -ENOMEM; - u16 datasize; + int datasize; struct aac_srb_unit srbu; struct aac_srb *srbcmd; - struct aac_ciss_identify_pd *identify_resp; + struct aac_ciss_identify_pd *identify_reply; datasize = sizeof(struct aac_ciss_identify_pd); - identify_resp = kmalloc(datasize, GFP_KERNEL); - if (!identify_resp) + identify_reply = kmalloc(datasize, GFP_KERNEL); + if (!identify_reply) goto out; memset(&srbu, 0, sizeof(struct aac_srb_unit)); @@ -1774,30 +1775,31 @@ static int aac_issue_bmic_identify(struct aac_dev *dev, u32 bus, u32 target) srbcmd->cdb[2] = (u8)((AAC_MAX_LUN + target) & 0x00FF); srbcmd->cdb[6] = CISS_IDENTIFY_PHYSICAL_DEVICE; - rcode = aac_send_safw_bmic_cmd(dev, &srbu, identify_resp, datasize); + rcode = aac_send_safw_bmic_cmd(dev, &srbu, identify_reply, datasize); if (unlikely(rcode < 0)) goto out; - if (identify_resp->current_queue_depth_limit <= 0 || - identify_resp->current_queue_depth_limit > 32) + if (identify_reply->current_queue_depth_limit <= 0 || + identify_reply->current_queue_depth_limit > 32) dev->hba_map[bus][target].qd_limit = 32; else dev->hba_map[bus][target].qd_limit = - identify_resp->current_queue_depth_limit; + identify_reply->current_queue_depth_limit; - kfree(identify_resp); + kfree(identify_reply); out: return rcode; } /** - * aac_update hba_map()- update current hba map with data from FW + * aac_set_safw_attr_all_targets- update current hba map with data from FW * @dev: aac_dev structure * @phys_luns: FW information from report phys luns + * @rescan: Indicates scan type * * Update our hba map with the information gathered from the FW */ -void aac_update_hba_map(struct aac_dev *dev, +static void aac_set_safw_attr_all_targets(struct aac_dev *dev, struct aac_ciss_phys_luns_resp *phys_luns, int rescan) { /* ok and extended reporting */ @@ -1839,7 +1841,7 @@ void aac_update_hba_map(struct aac_dev *dev, if (devtype != AAC_DEVTYPE_NATIVE_RAW) goto update_devtype; - if (aac_issue_bmic_identify(dev, bus, target) < 0) + if (aac_issue_safw_bmic_identify(dev, bus, target) < 0) dev->hba_map[bus][target].qd_limit = 32; update_devtype: @@ -1851,14 +1853,14 @@ update_devtype: } /** - * aac_report_phys_luns() Process topology change + * aac_get_safw_ciss_luns() Process topology change * @dev: aac_dev structure * @rescan: Indicates rescan * * Execute a CISS REPORT PHYS LUNS and process the results into * the current hba_map. */ -int aac_report_phys_luns(struct aac_dev *dev, int rescan) +int aac_get_safw_ciss_luns(struct aac_dev *dev, int rescan) { int rcode = -ENOMEM; int datasize; @@ -1888,7 +1890,7 @@ int aac_report_phys_luns(struct aac_dev *dev, int rescan) /* analyse data */ if (rcode >= 0 && phys_luns->resp_flag == 2) { /* ok and extended reporting */ - aac_update_hba_map(dev, phys_luns, rescan); + aac_set_safw_attr_all_targets(dev, phys_luns, rescan); } kfree(phys_luns); @@ -2001,7 +2003,7 @@ int aac_get_adapter_info(struct aac_dev* dev) if (!dev->sync_mode && dev->sa_firmware && dev->supplement_adapter_info.virt_device_bus != 0xffff) { /* Thor SA Firmware -> CISS_REPORT_PHYSICAL_LUNS */ - rcode = aac_report_phys_luns(dev, AAC_INIT); + rcode = aac_get_safw_ciss_luns(dev, AAC_INIT); } if (!dev->in_reset) { diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index 3a201681852b..d81d0aac3ad4 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -2639,7 +2639,7 @@ static inline int aac_adapter_check_health(struct aac_dev *dev) int aac_acquire_irq(struct aac_dev *dev); void aac_free_irq(struct aac_dev *dev); -int aac_report_phys_luns(struct aac_dev *dev, int rescan); +int aac_get_safw_ciss_luns(struct aac_dev *dev, int rescan); const char *aac_driverinfo(struct Scsi_Host *); void aac_fib_vector_assign(struct aac_dev *dev); struct fib *aac_fib_alloc(struct aac_dev *dev); diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c index f70f1122b474..82ddc7449518 100644 --- a/drivers/scsi/aacraid/commsup.c +++ b/drivers/scsi/aacraid/commsup.c @@ -1945,7 +1945,7 @@ static void aac_handle_sa_aif(struct aac_dev *dev, struct fib *fibptr) for (target = 0; target < AAC_MAX_TARGETS; target++) dev->hba_map[bus][target].new_devtype = 0; - rcode = aac_report_phys_luns(dev, AAC_RESCAN); + rcode = aac_get_safw_ciss_luns(dev, AAC_RESCAN); aac_resolve_luns(dev); -- cgit v1.2.3 From fc0fdd9abcc60bd207151b2c8a82dc5ee4b45226 Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Tue, 26 Dec 2017 20:34:33 -0800 Subject: scsi: aacraid: Add target setup helper function Add helper function to setup targets devices and create the base for the upcoming patches Signed-off-by: Raghava Aditya Renukunta Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/aachba.c | 18 +++++++++++++----- drivers/scsi/aacraid/aacraid.h | 2 +- drivers/scsi/aacraid/commsup.c | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index 801aff0ba7ce..5a95883794c1 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -1860,7 +1860,7 @@ update_devtype: * Execute a CISS REPORT PHYS LUNS and process the results into * the current hba_map. */ -int aac_get_safw_ciss_luns(struct aac_dev *dev, int rescan) +static int aac_get_safw_ciss_luns(struct aac_dev *dev, int rescan) { int rcode = -ENOMEM; int datasize; @@ -1898,6 +1898,16 @@ err_out: return rcode; } +static int aac_setup_safw_targets(struct aac_dev *dev, int rescan) +{ + return aac_get_safw_ciss_luns(dev, rescan); +} + +int aac_setup_safw_adapter(struct aac_dev *dev, int rescan) +{ + return aac_setup_safw_targets(dev, rescan); +} + int aac_get_adapter_info(struct aac_dev* dev) { struct fib* fibptr; @@ -2001,10 +2011,8 @@ int aac_get_adapter_info(struct aac_dev* dev) } if (!dev->sync_mode && dev->sa_firmware && - dev->supplement_adapter_info.virt_device_bus != 0xffff) { - /* Thor SA Firmware -> CISS_REPORT_PHYSICAL_LUNS */ - rcode = aac_get_safw_ciss_luns(dev, AAC_INIT); - } + dev->supplement_adapter_info.virt_device_bus != 0xffff) + rcode = aac_setup_safw_adapter(dev, AAC_INIT); if (!dev->in_reset) { char buffer[16]; diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index d81d0aac3ad4..569076715070 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -2639,7 +2639,7 @@ static inline int aac_adapter_check_health(struct aac_dev *dev) int aac_acquire_irq(struct aac_dev *dev); void aac_free_irq(struct aac_dev *dev); -int aac_get_safw_ciss_luns(struct aac_dev *dev, int rescan); +int aac_setup_safw_adapter(struct aac_dev *dev, int rescan); const char *aac_driverinfo(struct Scsi_Host *); void aac_fib_vector_assign(struct aac_dev *dev); struct fib *aac_fib_alloc(struct aac_dev *dev); diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c index 82ddc7449518..f3077b37bea1 100644 --- a/drivers/scsi/aacraid/commsup.c +++ b/drivers/scsi/aacraid/commsup.c @@ -1945,7 +1945,7 @@ static void aac_handle_sa_aif(struct aac_dev *dev, struct fib *fibptr) for (target = 0; target < AAC_MAX_TARGETS; target++) dev->hba_map[bus][target].new_devtype = 0; - rcode = aac_get_safw_ciss_luns(dev, AAC_RESCAN); + rcode = aac_setup_safw_adapter(dev, AAC_RESCAN); aac_resolve_luns(dev); -- cgit v1.2.3 From 3edfb8b2e20b30456359718805bea052bf1b0895 Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Tue, 26 Dec 2017 20:34:34 -0800 Subject: scsi: aacraid: Untangle targets setup from report phy luns Remove function call to process targets from the report phy luns function and make it a function in its own right. This will help understand the flow of the code. Signed-off-by: Raghava Aditya Renukunta Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/aachba.c | 44 +++++++++++++++++++++++++++++++----------- drivers/scsi/aacraid/aacraid.h | 1 + 2 files changed, 34 insertions(+), 11 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index 5a95883794c1..629a04d90e5c 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -1799,14 +1799,16 @@ out: * * Update our hba map with the information gathered from the FW */ -static void aac_set_safw_attr_all_targets(struct aac_dev *dev, - struct aac_ciss_phys_luns_resp *phys_luns, int rescan) +static void aac_set_safw_attr_all_targets(struct aac_dev *dev, int rescan) { /* ok and extended reporting */ u32 lun_count, nexus; u32 i, bus, target; u8 expose_flag, attribs; u8 devtype; + struct aac_ciss_phys_luns_resp *phys_luns; + + phys_luns = dev->safw_phys_luns; lun_count = ((phys_luns->list_length[0] << 24) + (phys_luns->list_length[1] << 16) @@ -1852,6 +1854,12 @@ update_devtype: } } +static inline void aac_free_safw_ciss_luns(struct aac_dev *dev) +{ + kfree(dev->safw_phys_luns); + dev->safw_phys_luns = NULL; +} + /** * aac_get_safw_ciss_luns() Process topology change * @dev: aac_dev structure @@ -1872,7 +1880,7 @@ static int aac_get_safw_ciss_luns(struct aac_dev *dev, int rescan) (AAC_MAX_TARGETS - 1) * sizeof(struct _ciss_lun); phys_luns = kmalloc(datasize, GFP_KERNEL); if (phys_luns == NULL) - goto err_out; + goto out; memset(&srbu, 0, sizeof(struct aac_srb_unit)); @@ -1885,22 +1893,36 @@ static int aac_get_safw_ciss_luns(struct aac_dev *dev, int rescan) rcode = aac_send_safw_bmic_cmd(dev, &srbu, phys_luns, datasize); if (unlikely(rcode < 0)) - goto err_out; + goto mem_free_all; - /* analyse data */ - if (rcode >= 0 && phys_luns->resp_flag == 2) { - /* ok and extended reporting */ - aac_set_safw_attr_all_targets(dev, phys_luns, rescan); + if (phys_luns->resp_flag != 2) { + rcode = -ENOMSG; + goto mem_free_all; } - kfree(phys_luns); -err_out: + dev->safw_phys_luns = phys_luns; + +out: return rcode; +mem_free_all: + kfree(phys_luns); + goto out; + } static int aac_setup_safw_targets(struct aac_dev *dev, int rescan) { - return aac_get_safw_ciss_luns(dev, rescan); + int rcode = 0; + + rcode = aac_get_safw_ciss_luns(dev, rescan); + if (unlikely(rcode < 0)) + goto out; + + aac_set_safw_attr_all_targets(dev, rescan); + + aac_free_safw_ciss_luns(dev); +out: + return rcode; } int aac_setup_safw_adapter(struct aac_dev *dev, int rescan) diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index 569076715070..19af4d971be1 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -1671,6 +1671,7 @@ struct aac_dev struct msix_entry msixentry[AAC_MAX_MSIX]; struct aac_msix_ctx aac_msix[AAC_MAX_MSIX]; /* context */ struct aac_hba_map_info hba_map[AAC_MAX_BUSES][AAC_MAX_TARGETS]; + struct aac_ciss_phys_luns_resp *safw_phys_luns; u8 adapter_shutdown; u32 handle_pci_error; }; -- cgit v1.2.3 From a25b6ca1a9225610671cb850432eade5e057edc1 Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Tue, 26 Dec 2017 20:34:35 -0800 Subject: scsi: aacraid: Move function around to match existing code Move the function to get phy luns information to the top of function to set target information Signed-off-by: Raghava Aditya Renukunta Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/aachba.c | 112 +++++++++++++++++++++--------------------- 1 file changed, 56 insertions(+), 56 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index 629a04d90e5c..43a3c1192282 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -1791,6 +1791,62 @@ out: return rcode; } +static inline void aac_free_safw_ciss_luns(struct aac_dev *dev) +{ + kfree(dev->safw_phys_luns); + dev->safw_phys_luns = NULL; +} + +/** + * aac_get_safw_ciss_luns() Process topology change + * @dev: aac_dev structure + * @rescan: Indicates rescan + * + * Execute a CISS REPORT PHYS LUNS and process the results into + * the current hba_map. + */ +static int aac_get_safw_ciss_luns(struct aac_dev *dev, int rescan) +{ + int rcode = -ENOMEM; + int datasize; + struct aac_srb *srbcmd; + struct aac_srb_unit srbu; + struct aac_ciss_phys_luns_resp *phys_luns; + + datasize = sizeof(struct aac_ciss_phys_luns_resp) + + (AAC_MAX_TARGETS - 1) * sizeof(struct _ciss_lun); + phys_luns = kmalloc(datasize, GFP_KERNEL); + if (phys_luns == NULL) + goto out; + + memset(&srbu, 0, sizeof(struct aac_srb_unit)); + + srbcmd = &srbu.srb; + srbcmd->flags = cpu_to_le32(SRB_DataIn); + srbcmd->cdb[0] = CISS_REPORT_PHYSICAL_LUNS; + srbcmd->cdb[1] = 2; /* extended reporting */ + srbcmd->cdb[8] = (u8)(datasize >> 8); + srbcmd->cdb[9] = (u8)(datasize); + + rcode = aac_send_safw_bmic_cmd(dev, &srbu, phys_luns, datasize); + if (unlikely(rcode < 0)) + goto mem_free_all; + + if (phys_luns->resp_flag != 2) { + rcode = -ENOMSG; + goto mem_free_all; + } + + dev->safw_phys_luns = phys_luns; + +out: + return rcode; +mem_free_all: + kfree(phys_luns); + goto out; + +} + /** * aac_set_safw_attr_all_targets- update current hba map with data from FW * @dev: aac_dev structure @@ -1854,62 +1910,6 @@ update_devtype: } } -static inline void aac_free_safw_ciss_luns(struct aac_dev *dev) -{ - kfree(dev->safw_phys_luns); - dev->safw_phys_luns = NULL; -} - -/** - * aac_get_safw_ciss_luns() Process topology change - * @dev: aac_dev structure - * @rescan: Indicates rescan - * - * Execute a CISS REPORT PHYS LUNS and process the results into - * the current hba_map. - */ -static int aac_get_safw_ciss_luns(struct aac_dev *dev, int rescan) -{ - int rcode = -ENOMEM; - int datasize; - struct aac_srb *srbcmd; - struct aac_srb_unit srbu; - struct aac_ciss_phys_luns_resp *phys_luns; - - datasize = sizeof(struct aac_ciss_phys_luns_resp) + - (AAC_MAX_TARGETS - 1) * sizeof(struct _ciss_lun); - phys_luns = kmalloc(datasize, GFP_KERNEL); - if (phys_luns == NULL) - goto out; - - memset(&srbu, 0, sizeof(struct aac_srb_unit)); - - srbcmd = &srbu.srb; - srbcmd->flags = cpu_to_le32(SRB_DataIn); - srbcmd->cdb[0] = CISS_REPORT_PHYSICAL_LUNS; - srbcmd->cdb[1] = 2; /* extended reporting */ - srbcmd->cdb[8] = (u8)(datasize >> 8); - srbcmd->cdb[9] = (u8)(datasize); - - rcode = aac_send_safw_bmic_cmd(dev, &srbu, phys_luns, datasize); - if (unlikely(rcode < 0)) - goto mem_free_all; - - if (phys_luns->resp_flag != 2) { - rcode = -ENOMSG; - goto mem_free_all; - } - - dev->safw_phys_luns = phys_luns; - -out: - return rcode; -mem_free_all: - kfree(phys_luns); - goto out; - -} - static int aac_setup_safw_targets(struct aac_dev *dev, int rescan) { int rcode = 0; -- cgit v1.2.3 From 4b000227535500550547313bf20e3be9083dc724 Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Tue, 26 Dec 2017 20:34:36 -0800 Subject: scsi: aacraid: Create helper functions to get lun info Created inline function to retrieve lun info for each device from the phy luns structure. Signed-off-by: Raghava Aditya Renukunta Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/aachba.c | 54 +++++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 12 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index 43a3c1192282..fa0132bcd2f3 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -42,6 +42,8 @@ #include /* For flush_kernel_dcache_page */ #include +#include + #include #include #include @@ -1844,7 +1846,41 @@ out: mem_free_all: kfree(phys_luns); goto out; +} + +static inline u32 aac_get_safw_phys_lun_count(struct aac_dev *dev) +{ + return get_unaligned_be32(&dev->safw_phys_luns->list_length[0]); +} + +static inline u32 aac_get_safw_phys_bus(struct aac_dev *dev, int lun) +{ + return dev->safw_phys_luns->lun[lun].level2[1] & 0x3f; +} + +static inline u32 aac_get_safw_phys_target(struct aac_dev *dev, int lun) +{ + return dev->safw_phys_luns->lun[lun].level2[0]; +} +static inline u32 aac_get_safw_phys_expose_flag(struct aac_dev *dev, int lun) +{ + return dev->safw_phys_luns->lun[lun].bus >> 6; +} + +static inline u32 aac_get_safw_phys_attribs(struct aac_dev *dev, int lun) +{ + return dev->safw_phys_luns->lun[lun].node_ident[9]; +} + +static inline u32 aac_get_safw_phys_nexus(struct aac_dev *dev, int lun) +{ + return *((u32 *)&dev->safw_phys_luns->lun[lun].node_ident[12]); +} + +static inline u32 aac_get_safw_phys_device_type(struct aac_dev *dev, int lun) +{ + return dev->safw_phys_luns->lun[lun].node_ident[8]; } /** @@ -1862,22 +1898,16 @@ static void aac_set_safw_attr_all_targets(struct aac_dev *dev, int rescan) u32 i, bus, target; u8 expose_flag, attribs; u8 devtype; - struct aac_ciss_phys_luns_resp *phys_luns; - - phys_luns = dev->safw_phys_luns; - lun_count = ((phys_luns->list_length[0] << 24) - + (phys_luns->list_length[1] << 16) - + (phys_luns->list_length[2] << 8) - + (phys_luns->list_length[3])) / 24; + lun_count = aac_get_safw_phys_lun_count(dev); for (i = 0; i < lun_count; ++i) { - bus = phys_luns->lun[i].level2[1] & 0x3f; - target = phys_luns->lun[i].level2[0]; - expose_flag = phys_luns->lun[i].bus >> 6; - attribs = phys_luns->lun[i].node_ident[9]; - nexus = *((u32 *) &phys_luns->lun[i].node_ident[12]); + bus = aac_get_safw_phys_bus(dev, i); + target = aac_get_safw_phys_target(dev, i); + expose_flag = aac_get_safw_phys_expose_flag(dev, i); + attribs = aac_get_safw_phys_attribs(dev, i); + nexus = aac_get_safw_phys_nexus(dev, i); if (bus >= AAC_MAX_BUSES || target >= AAC_MAX_TARGETS) continue; -- cgit v1.2.3 From e2ee8c948010bdb6c4ce26fd7408065495f51fad Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Tue, 26 Dec 2017 20:34:37 -0800 Subject: scsi: aacraid: Save bmic phy information for each phy Save the bmic information for each phy, so that it can processed in target setup function. Signed-off-by: Raghava Aditya Renukunta Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/aachba.c | 84 +++++++++++++++++++++++++++++++++++++++--- drivers/scsi/aacraid/aacraid.h | 1 + 2 files changed, 79 insertions(+), 6 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index fa0132bcd2f3..baa3de5dd8df 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -1756,7 +1756,7 @@ fib_error: } static int aac_issue_safw_bmic_identify(struct aac_dev *dev, - u32 bus, u32 target) + struct aac_ciss_identify_pd **identify_resp, u32 bus, u32 target) { int rcode = -ENOMEM; int datasize; @@ -1779,7 +1779,7 @@ static int aac_issue_safw_bmic_identify(struct aac_dev *dev, rcode = aac_send_safw_bmic_cmd(dev, &srbu, identify_reply, datasize); if (unlikely(rcode < 0)) - goto out; + goto mem_free_all; if (identify_reply->current_queue_depth_limit <= 0 || identify_reply->current_queue_depth_limit > 32) @@ -1788,9 +1788,13 @@ static int aac_issue_safw_bmic_identify(struct aac_dev *dev, dev->hba_map[bus][target].qd_limit = identify_reply->current_queue_depth_limit; - kfree(identify_reply); + *identify_resp = identify_reply; + out: return rcode; +mem_free_all: + kfree(identify_reply); + goto out; } static inline void aac_free_safw_ciss_luns(struct aac_dev *dev) @@ -1883,6 +1887,71 @@ static inline u32 aac_get_safw_phys_device_type(struct aac_dev *dev, int lun) return dev->safw_phys_luns->lun[lun].node_ident[8]; } +static inline void aac_free_safw_identify_resp(struct aac_dev *dev, + int bus, int target) +{ + kfree(dev->hba_map[bus][target].safw_identify_resp); + dev->hba_map[bus][target].safw_identify_resp = NULL; +} + +static inline void aac_free_safw_all_identify_resp(struct aac_dev *dev, + int lun_count) +{ + int luns; + int i; + u32 bus; + u32 target; + + luns = aac_get_safw_phys_lun_count(dev); + + if (luns < lun_count) + lun_count = luns; + else if (lun_count < 0) + lun_count = luns; + + for (i = 0; i < lun_count; i++) { + bus = aac_get_safw_phys_bus(dev, i); + target = aac_get_safw_phys_target(dev, i); + + aac_free_safw_identify_resp(dev, bus, target); + } +} + +static int aac_get_safw_attr_all_targets(struct aac_dev *dev, int rescan) +{ + int i; + int rcode = 0; + u32 lun_count; + u32 bus; + u32 target; + struct aac_ciss_identify_pd *identify_resp = NULL; + + lun_count = aac_get_safw_phys_lun_count(dev); + + for (i = 0; i < lun_count; ++i) { + + bus = aac_get_safw_phys_bus(dev, i); + target = aac_get_safw_phys_target(dev, i); + + rcode = aac_issue_safw_bmic_identify(dev, + &identify_resp, bus, target); + + if (unlikely(rcode < 0)) { + dev->hba_map[bus][target].qd_limit = 32; + goto free_identify_resp; + } + + dev->hba_map[bus][target].safw_identify_resp = identify_resp; + } + +out: + return rcode; + +free_identify_resp: + aac_free_safw_all_identify_resp(dev, i); + goto out; +} + /** * aac_set_safw_attr_all_targets- update current hba map with data from FW * @dev: aac_dev structure @@ -1929,9 +1998,6 @@ static void aac_set_safw_attr_all_targets(struct aac_dev *dev, int rescan) if (devtype != AAC_DEVTYPE_NATIVE_RAW) goto update_devtype; - if (aac_issue_safw_bmic_identify(dev, bus, target) < 0) - dev->hba_map[bus][target].qd_limit = 32; - update_devtype: if (rescan == AAC_INIT) dev->hba_map[bus][target].devtype = devtype; @@ -1948,8 +2014,14 @@ static int aac_setup_safw_targets(struct aac_dev *dev, int rescan) if (unlikely(rcode < 0)) goto out; + rcode = aac_get_safw_attr_all_targets(dev, rescan); + if (unlikely(rcode < 0)) + goto free_ciss_luns; + aac_set_safw_attr_all_targets(dev, rescan); + aac_free_safw_all_identify_resp(dev, -1); +free_ciss_luns: aac_free_safw_ciss_luns(dev); out: return rcode; diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index 19af4d971be1..b1a6045b1425 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -1345,6 +1345,7 @@ struct aac_hba_map_info { /* after xth TM LUN reset */ u16 qd_limit; u8 expose; /*checks if to expose or not*/ + struct aac_ciss_identify_pd *safw_identify_resp; }; /* -- cgit v1.2.3 From 0bcb45fb20c2195fe0ae175d4775241e672a5fd3 Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Tue, 26 Dec 2017 20:34:38 -0800 Subject: scsi: aacraid: Add helper function to set queue depth Add helper function to set queue depth from information retrieved from the bmic phy structure. Signed-off-by: Raghava Aditya Renukunta Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/aachba.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index baa3de5dd8df..67ca5af32e02 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -1755,6 +1755,28 @@ fib_error: return rcode; } +static void aac_set_safw_target_qd(struct aac_dev *dev, int bus, int target) +{ + + struct aac_ciss_identify_pd *identify_resp; + + if (dev->hba_map[bus][target].devtype != AAC_DEVTYPE_NATIVE_RAW) + return; + + identify_resp = dev->hba_map[bus][target].safw_identify_resp; + if (identify_resp == NULL) { + dev->hba_map[bus][target].qd_limit = 32; + return; + } + + if (identify_resp->current_queue_depth_limit <= 0 || + identify_resp->current_queue_depth_limit > 255) + dev->hba_map[bus][target].qd_limit = 32; + else + dev->hba_map[bus][target].qd_limit = + identify_resp->current_queue_depth_limit; +} + static int aac_issue_safw_bmic_identify(struct aac_dev *dev, struct aac_ciss_identify_pd **identify_resp, u32 bus, u32 target) { @@ -1781,13 +1803,6 @@ static int aac_issue_safw_bmic_identify(struct aac_dev *dev, if (unlikely(rcode < 0)) goto mem_free_all; - if (identify_reply->current_queue_depth_limit <= 0 || - identify_reply->current_queue_depth_limit > 32) - dev->hba_map[bus][target].qd_limit = 32; - else - dev->hba_map[bus][target].qd_limit = - identify_reply->current_queue_depth_limit; - *identify_resp = identify_reply; out: @@ -1936,17 +1951,14 @@ static int aac_get_safw_attr_all_targets(struct aac_dev *dev, int rescan) rcode = aac_issue_safw_bmic_identify(dev, &identify_resp, bus, target); - if (unlikely(rcode < 0)) { - dev->hba_map[bus][target].qd_limit = 32; + if (unlikely(rcode < 0)) goto free_identify_resp; - } dev->hba_map[bus][target].safw_identify_resp = identify_resp; } out: return rcode; - free_identify_resp: aac_free_safw_all_identify_resp(dev, i); goto out; @@ -1995,8 +2007,7 @@ static void aac_set_safw_attr_all_targets(struct aac_dev *dev, int rescan) } else devtype = AAC_DEVTYPE_ARC_RAW; - if (devtype != AAC_DEVTYPE_NATIVE_RAW) - goto update_devtype; + aac_set_safw_target_qd(dev, bus, target); update_devtype: if (rescan == AAC_INIT) -- cgit v1.2.3 From 1d1fec53dc13d56c80b02d391c7d593d9a502d6d Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Tue, 26 Dec 2017 20:34:39 -0800 Subject: scsi: aacraid: Merge func to get container information Merge aac_get_containers to setup target function, so that information about all the present devices can be retrieved in one shot. Signed-off-by: Raghava Aditya Renukunta Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/aachba.c | 4 ++++ drivers/scsi/aacraid/commsup.c | 34 +++++++++++++++------------------- 2 files changed, 19 insertions(+), 19 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index 67ca5af32e02..c30f7da1937f 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -2021,6 +2021,10 @@ static int aac_setup_safw_targets(struct aac_dev *dev, int rescan) { int rcode = 0; + rcode = aac_get_containers(dev); + if (unlikely(rcode < 0)) + goto out; + rcode = aac_get_safw_ciss_luns(dev, rescan); if (unlikely(rcode < 0)) goto out; diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c index f3077b37bea1..9625eb0d7a51 100644 --- a/drivers/scsi/aacraid/commsup.c +++ b/drivers/scsi/aacraid/commsup.c @@ -1949,26 +1949,22 @@ static void aac_handle_sa_aif(struct aac_dev *dev, struct fib *fibptr) aac_resolve_luns(dev); - if (events == SA_AIF_LDEV_CHANGE || - events == SA_AIF_BPCFG_CHANGE) { - aac_get_containers(dev); - for (container = 0; container < + for (container = 0; container < dev->maximum_num_containers; ++container) { - sdev = scsi_device_lookup(dev->scsi_host_ptr, - CONTAINER_CHANNEL, - container, 0); - if (dev->fsa_dev[container].valid && !sdev) { - scsi_add_device(dev->scsi_host_ptr, - CONTAINER_CHANNEL, - container, 0); - } else if (!dev->fsa_dev[container].valid && - sdev) { - scsi_remove_device(sdev); - scsi_device_put(sdev); - } else if (sdev) { - scsi_rescan_device(&sdev->sdev_gendev); - scsi_device_put(sdev); - } + sdev = scsi_device_lookup(dev->scsi_host_ptr, + CONTAINER_CHANNEL, + container, 0); + if (dev->fsa_dev[container].valid && !sdev) { + scsi_add_device(dev->scsi_host_ptr, + CONTAINER_CHANNEL, + container, 0); + } else if (!dev->fsa_dev[container].valid && + sdev) { + scsi_remove_device(sdev); + scsi_device_put(sdev); + } else if (sdev) { + scsi_rescan_device(&sdev->sdev_gendev); + scsi_device_put(sdev); } } break; -- cgit v1.2.3 From f2d2cabadba00f13786a5962a9813079a3767ce4 Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Tue, 26 Dec 2017 20:34:40 -0800 Subject: scsi: aacraid: Process hba and container hot plug events in single function The hotplug handler code is duplicated for hba handling and container handling. Merged function to handle hba and container hot plug events into the resolve luns functions. Added a bunch of helper functions to check the validity of a given target and to check if bus, target is container device. Signed-off-by: Raghava Aditya Renukunta Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/aachba.c | 9 ++++--- drivers/scsi/aacraid/aacraid.h | 3 ++- drivers/scsi/aacraid/commsup.c | 59 ++++++++++++++++-------------------------- 3 files changed, 30 insertions(+), 41 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index c30f7da1937f..4ad9d3f017af 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -1982,6 +1982,8 @@ static void aac_set_safw_attr_all_targets(struct aac_dev *dev, int rescan) lun_count = aac_get_safw_phys_lun_count(dev); + dev->scan_counter++; + for (i = 0; i < lun_count; ++i) { bus = aac_get_safw_phys_bus(dev, i); @@ -2007,13 +2009,12 @@ static void aac_set_safw_attr_all_targets(struct aac_dev *dev, int rescan) } else devtype = AAC_DEVTYPE_ARC_RAW; + dev->hba_map[bus][target].scan_counter = dev->scan_counter; + aac_set_safw_target_qd(dev, bus, target); update_devtype: - if (rescan == AAC_INIT) - dev->hba_map[bus][target].devtype = devtype; - else - dev->hba_map[bus][target].new_devtype = devtype; + dev->hba_map[bus][target].devtype = devtype; } } diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index b1a6045b1425..17c6cdd52806 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -1340,11 +1340,11 @@ struct fib { struct aac_hba_map_info { __le32 rmw_nexus; /* nexus for native HBA devices */ u8 devtype; /* device type */ - u8 new_devtype; u8 reset_state; /* 0 - no reset, 1..x - */ /* after xth TM LUN reset */ u16 qd_limit; u8 expose; /*checks if to expose or not*/ + u32 scan_counter; struct aac_ciss_identify_pd *safw_identify_resp; }; @@ -1669,6 +1669,7 @@ struct aac_dev u32 vector_cap; /* MSI-X vector capab.*/ int msi_enabled; /* MSI/MSI-X enabled */ atomic_t msix_counter; + u32 scan_counter; struct msix_entry msixentry[AAC_MAX_MSIX]; struct aac_msix_ctx aac_msix[AAC_MAX_MSIX]; /* context */ struct aac_hba_map_info hba_map[AAC_MAX_BUSES][AAC_MAX_TARGETS]; diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c index 9625eb0d7a51..ed79159db752 100644 --- a/drivers/scsi/aacraid/commsup.c +++ b/drivers/scsi/aacraid/commsup.c @@ -1869,13 +1869,29 @@ out: return BlinkLED; } +static inline int is_safw_raid_volume(struct aac_dev *aac, int bus, int target) +{ + return bus == CONTAINER_CHANNEL && target < aac->maximum_num_containers; +} + +static inline int aac_is_safw_scan_count_equal(struct aac_dev *dev, + int bus, int target) +{ + return dev->hba_map[bus][target].scan_counter == dev->scan_counter; +} + +static int aac_is_safw_target_valid(struct aac_dev *dev, int bus, int target) +{ + if (is_safw_raid_volume(dev, bus, target)) + return dev->fsa_dev[target].valid; + else + return aac_is_safw_scan_count_equal(dev, bus, target); +} static void aac_resolve_luns(struct aac_dev *dev) { int bus, target, channel; struct scsi_device *sdev; - u8 devtype; - u8 new_devtype; for (bus = 0; bus < AAC_MAX_BUSES; bus++) { for (target = 0; target < AAC_MAX_TARGETS; target++) { @@ -1885,24 +1901,19 @@ static void aac_resolve_luns(struct aac_dev *dev) else channel = aac_phys_to_logical(bus); - devtype = dev->hba_map[bus][target].devtype; - new_devtype = dev->hba_map[bus][target].new_devtype; - sdev = scsi_device_lookup(dev->scsi_host_ptr, channel, target, 0); - if (!sdev && new_devtype) + if (!sdev && aac_is_safw_target_valid(dev, bus, target)) scsi_add_device(dev->scsi_host_ptr, channel, target, 0); - else if (sdev && new_devtype != devtype) + else if (sdev && aac_is_safw_target_valid(dev, + bus, target)) scsi_remove_device(sdev); - else if (sdev && new_devtype == devtype) - scsi_rescan_device(&sdev->sdev_gendev); if (sdev) scsi_device_put(sdev); - dev->hba_map[bus][target].devtype = new_devtype; } } } @@ -1917,9 +1928,8 @@ static void aac_resolve_luns(struct aac_dev *dev) */ static void aac_handle_sa_aif(struct aac_dev *dev, struct fib *fibptr) { - int i, bus, target, container, rcode = 0; + int i; u32 events = 0; - struct scsi_device *sdev; if (fibptr->hbacmd_size & SA_AIF_HOTPLUG) events = SA_AIF_HOTPLUG; @@ -1941,32 +1951,9 @@ static void aac_handle_sa_aif(struct aac_dev *dev, struct fib *fibptr) case SA_AIF_LDEV_CHANGE: case SA_AIF_BPCFG_CHANGE: - for (bus = 0; bus < AAC_MAX_BUSES; bus++) - for (target = 0; target < AAC_MAX_TARGETS; target++) - dev->hba_map[bus][target].new_devtype = 0; - - rcode = aac_setup_safw_adapter(dev, AAC_RESCAN); + aac_setup_safw_adapter(dev, AAC_RESCAN); aac_resolve_luns(dev); - - for (container = 0; container < - dev->maximum_num_containers; ++container) { - sdev = scsi_device_lookup(dev->scsi_host_ptr, - CONTAINER_CHANNEL, - container, 0); - if (dev->fsa_dev[container].valid && !sdev) { - scsi_add_device(dev->scsi_host_ptr, - CONTAINER_CHANNEL, - container, 0); - } else if (!dev->fsa_dev[container].valid && - sdev) { - scsi_remove_device(sdev); - scsi_device_put(sdev); - } else if (sdev) { - scsi_rescan_device(&sdev->sdev_gendev); - scsi_device_put(sdev); - } - } break; case SA_AIF_BPSTAT_CHANGE: -- cgit v1.2.3 From 2290678fed775194ef84d65949d93a4f524765b0 Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Tue, 26 Dec 2017 20:34:41 -0800 Subject: scsi: aacraid: Added macros to help loop through known buses and targets Added macros to loop through the MAX SUPPORTED Buses and Targets. This will make the code a bit easier to read. Signed-off-by: Raghava Aditya Renukunta Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/aacraid.h | 4 ++++ drivers/scsi/aacraid/commsup.c | 34 +++++++++++++++++----------------- 2 files changed, 21 insertions(+), 17 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index 17c6cdd52806..a8fe1e1272c1 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -117,9 +117,13 @@ enum { /* Thor: 5 phys. buses: #0: empty, 1-4: 256 targets each */ #define AAC_MAX_BUSES 5 #define AAC_MAX_TARGETS 256 +#define AAC_BUS_TARGET_LOOP (AAC_MAX_BUSES * AAC_MAX_TARGETS) #define AAC_MAX_NATIVE_SIZE 2048 #define FW_ERROR_BUFFER_SIZE 512 +#define get_bus_number(x) (x/AAC_MAX_TARGETS) +#define get_target_number(x) (x%AAC_MAX_TARGETS) + /* Thor AIF events */ #define SA_AIF_HOTPLUG (1<<1) #define SA_AIF_HARDWARE (1<<2) diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c index ed79159db752..8966371ec103 100644 --- a/drivers/scsi/aacraid/commsup.c +++ b/drivers/scsi/aacraid/commsup.c @@ -1890,31 +1890,31 @@ static int aac_is_safw_target_valid(struct aac_dev *dev, int bus, int target) static void aac_resolve_luns(struct aac_dev *dev) { + int i; int bus, target, channel; struct scsi_device *sdev; - for (bus = 0; bus < AAC_MAX_BUSES; bus++) { - for (target = 0; target < AAC_MAX_TARGETS; target++) { + for (i = 0; i < AAC_BUS_TARGET_LOOP; i++) { - if (bus == CONTAINER_CHANNEL) - channel = CONTAINER_CHANNEL; - else - channel = aac_phys_to_logical(bus); + bus = get_bus_number(i); + target = get_target_number(i); - sdev = scsi_device_lookup(dev->scsi_host_ptr, channel, - target, 0); + if (bus == CONTAINER_CHANNEL) + channel = CONTAINER_CHANNEL; + else + channel = aac_phys_to_logical(bus); - if (!sdev && aac_is_safw_target_valid(dev, bus, target)) - scsi_add_device(dev->scsi_host_ptr, channel, - target, 0); - else if (sdev && aac_is_safw_target_valid(dev, - bus, target)) - scsi_remove_device(sdev); + sdev = scsi_device_lookup(dev->scsi_host_ptr, channel, + target, 0); - if (sdev) - scsi_device_put(sdev); + if (!sdev && aac_is_safw_target_valid(dev, bus, target)) + scsi_add_device(dev->scsi_host_ptr, channel, + target, 0); + else if (sdev && aac_is_safw_target_valid(dev, bus, target)) + scsi_remove_device(sdev); - } + if (sdev) + scsi_device_put(sdev); } } -- cgit v1.2.3 From 3031c6565f04d4d6d1d4a04788c394a68b1d285b Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Tue, 26 Dec 2017 20:34:42 -0800 Subject: scsi: aacraid: Refactor resolve luns code and scsi functions Resolve luns checks the if a sdev is already present in the os to figure out if it needs to be removed. Internally the driver exposes HBA on bus 2 even though its bus 1 in the fw. Its mildly confusing. Refactor out the sdev lookup into its function to check if sdev has been added to the kernel or not. Add helper functions to add, remove and put devices based on their fw bus and target number. Signed-off-by: Raghava Aditya Renukunta Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/commsup.c | 71 ++++++++++++++++++++++++++++++++---------- 1 file changed, 54 insertions(+), 17 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c index 8966371ec103..5b7a4f559227 100644 --- a/drivers/scsi/aacraid/commsup.c +++ b/drivers/scsi/aacraid/commsup.c @@ -1874,6 +1874,39 @@ static inline int is_safw_raid_volume(struct aac_dev *aac, int bus, int target) return bus == CONTAINER_CHANNEL && target < aac->maximum_num_containers; } +static struct scsi_device *aac_lookup_safw_scsi_device(struct aac_dev *dev, + int bus, + int target) +{ + if (bus != CONTAINER_CHANNEL) + bus = aac_phys_to_logical(bus); + + return scsi_device_lookup(dev->scsi_host_ptr, bus, target, 0); +} + +static int aac_add_safw_device(struct aac_dev *dev, int bus, int target) +{ + if (bus != CONTAINER_CHANNEL) + bus = aac_phys_to_logical(bus); + + return scsi_add_device(dev->scsi_host_ptr, bus, target, 0); +} + +static void aac_put_safw_scsi_device(struct scsi_device *sdev) +{ + if (sdev) + scsi_device_put(sdev); +} + +static void aac_remove_safw_device(struct aac_dev *dev, int bus, int target) +{ + struct scsi_device *sdev; + + sdev = aac_lookup_safw_scsi_device(dev, bus, target); + scsi_remove_device(sdev); + aac_put_safw_scsi_device(sdev); +} + static inline int aac_is_safw_scan_count_equal(struct aac_dev *dev, int bus, int target) { @@ -1888,33 +1921,37 @@ static int aac_is_safw_target_valid(struct aac_dev *dev, int bus, int target) return aac_is_safw_scan_count_equal(dev, bus, target); } +static int aac_is_safw_device_exposed(struct aac_dev *dev, int bus, int target) +{ + int is_exposed = 0; + struct scsi_device *sdev; + + sdev = aac_lookup_safw_scsi_device(dev, bus, target); + if (sdev) + is_exposed = 1; + aac_put_safw_scsi_device(sdev); + + return is_exposed; +} + static void aac_resolve_luns(struct aac_dev *dev) { int i; - int bus, target, channel; - struct scsi_device *sdev; + int bus, target; + int is_exposed = 0; for (i = 0; i < AAC_BUS_TARGET_LOOP; i++) { bus = get_bus_number(i); target = get_target_number(i); - if (bus == CONTAINER_CHANNEL) - channel = CONTAINER_CHANNEL; - else - channel = aac_phys_to_logical(bus); - - sdev = scsi_device_lookup(dev->scsi_host_ptr, channel, - target, 0); - - if (!sdev && aac_is_safw_target_valid(dev, bus, target)) - scsi_add_device(dev->scsi_host_ptr, channel, - target, 0); - else if (sdev && aac_is_safw_target_valid(dev, bus, target)) - scsi_remove_device(sdev); + is_exposed = aac_is_safw_device_exposed(dev, bus, target); - if (sdev) - scsi_device_put(sdev); + if (aac_is_safw_target_valid(dev, bus, target) && !is_exposed) + aac_add_safw_device(dev, bus, target); + else if (!aac_is_safw_target_valid(dev, bus, target) && + is_exposed) + aac_remove_safw_device(dev, bus, target); } } -- cgit v1.2.3 From 6f44a22b2c96acd018b407ee28407e1730370169 Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Tue, 26 Dec 2017 20:34:43 -0800 Subject: scsi: aacraid: Merge adapter setup with resolve luns The device hotplug events are processed only after retrieving the updated lun information from the fw. Does not make sense to keep them separate. Merge both the hotplug handling and safw adapter setup code into single function. Signed-off-by: Raghava Aditya Renukunta Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/commsup.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c index 5b7a4f559227..34155b1aa83e 100644 --- a/drivers/scsi/aacraid/commsup.c +++ b/drivers/scsi/aacraid/commsup.c @@ -1934,11 +1934,18 @@ static int aac_is_safw_device_exposed(struct aac_dev *dev, int bus, int target) return is_exposed; } -static void aac_resolve_luns(struct aac_dev *dev) +static int aac_update_safw_host_devices(struct aac_dev *dev, int rescan) { int i; - int bus, target; + int bus; + int target; int is_exposed = 0; + int rcode = 0; + + rcode = aac_setup_safw_adapter(dev, rescan); + if (unlikely(rcode < 0)) { + goto out; + } for (i = 0; i < AAC_BUS_TARGET_LOOP; i++) { @@ -1953,6 +1960,8 @@ static void aac_resolve_luns(struct aac_dev *dev) is_exposed) aac_remove_safw_device(dev, bus, target); } +out: + return rcode; } /** @@ -1988,9 +1997,7 @@ static void aac_handle_sa_aif(struct aac_dev *dev, struct fib *fibptr) case SA_AIF_LDEV_CHANGE: case SA_AIF_BPCFG_CHANGE: - aac_setup_safw_adapter(dev, AAC_RESCAN); - - aac_resolve_luns(dev); + aac_update_safw_host_devices(dev, AAC_RESCAN); break; case SA_AIF_BPSTAT_CHANGE: -- cgit v1.2.3 From 3395614e48e26c6b05f87662ef354bca38999d2a Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Tue, 26 Dec 2017 20:34:44 -0800 Subject: scsi: aacraid: Block concurrent hotplug event handling Currently driver will attempt to process hotplug events concurrently based on the FW interrupt. Protect safw update function with a scan mutex. Signed-off-by: Raghava Aditya Renukunta Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/aacraid.h | 1 + drivers/scsi/aacraid/commsup.c | 2 ++ drivers/scsi/aacraid/linit.c | 1 + 3 files changed, 4 insertions(+) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index a8fe1e1272c1..c70c998743ac 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -1565,6 +1565,7 @@ struct aac_dev spinlock_t fib_lock; struct mutex ioctl_mutex; + struct mutex scan_mutex; struct aac_queue_block *queues; /* * The user API will use an IOCTL to register itself to receive diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c index 34155b1aa83e..491e6338c483 100644 --- a/drivers/scsi/aacraid/commsup.c +++ b/drivers/scsi/aacraid/commsup.c @@ -1997,7 +1997,9 @@ static void aac_handle_sa_aif(struct aac_dev *dev, struct fib *fibptr) case SA_AIF_LDEV_CHANGE: case SA_AIF_BPCFG_CHANGE: + mutex_lock(&dev->scan_mutex); aac_update_safw_host_devices(dev, AAC_RESCAN); + mutex_unlock(&dev->scan_mutex); break; case SA_AIF_BPSTAT_CHANGE: diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index b2273e3cba62..2c862cd26a21 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -1683,6 +1683,7 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) spin_lock_init(&aac->fib_lock); mutex_init(&aac->ioctl_mutex); + mutex_init(&aac->scan_mutex); /* * Map in the registers from the adapter. */ -- cgit v1.2.3 From 8ebaa67fc23a09bcf2b285ae4130508256b31923 Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Tue, 26 Dec 2017 20:34:45 -0800 Subject: scsi: aacraid: Use hotplug handling function in place of scsi_scan_host Driver uses scsi_scan_host to add new devices in the driver init path, which adds all the fw exposed devices. The drivers resorts to queue command checks to block out commands to _hidden_ devices. Use the hotplug handler code to add new devices during driver init and other areas, this is only for safw. For ARC scsi_scan_host will still apply. Signed-off-by: Raghava Aditya Renukunta Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/aachba.c | 4 ---- drivers/scsi/aacraid/aacraid.h | 1 + drivers/scsi/aacraid/commsup.c | 18 +++++++++++++++--- drivers/scsi/aacraid/linit.c | 5 +++-- 4 files changed, 19 insertions(+), 9 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index 4ad9d3f017af..426c61a28926 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -2150,10 +2150,6 @@ int aac_get_adapter_info(struct aac_dev* dev) dev->maximum_num_channels = le32_to_cpu(bus_info->BusCount); } - if (!dev->sync_mode && dev->sa_firmware && - dev->supplement_adapter_info.virt_device_bus != 0xffff) - rcode = aac_setup_safw_adapter(dev, AAC_INIT); - if (!dev->in_reset) { char buffer[16]; tmp = le32_to_cpu(dev->adapter_info.kernelrev); diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index c70c998743ac..ba84d9985ce7 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -2719,6 +2719,7 @@ static inline int aac_supports_2T(struct aac_dev *dev) return (dev->adapter_info.options & AAC_OPT_NEW_COMM_64); } +int aac_scan_host(struct aac_dev *dev, int rescan); char * get_container_type(unsigned type); extern int numacb; extern char aac_driver_version[]; diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c index 491e6338c483..4e2687ce2456 100644 --- a/drivers/scsi/aacraid/commsup.c +++ b/drivers/scsi/aacraid/commsup.c @@ -1964,6 +1964,19 @@ out: return rcode; } +int aac_scan_host(struct aac_dev *dev, int rescan) +{ + int rcode = 0; + + mutex_lock(&dev->scan_mutex); + if (dev->sa_firmware) + rcode = aac_update_safw_host_devices(dev, rescan); + else + scsi_scan_host(dev->scsi_host_ptr); + mutex_unlock(&dev->scan_mutex); + return rcode; +} + /** * aac_handle_sa_aif Handle a message from the firmware * @dev: Which adapter this fib is from @@ -1997,9 +2010,8 @@ static void aac_handle_sa_aif(struct aac_dev *dev, struct fib *fibptr) case SA_AIF_LDEV_CHANGE: case SA_AIF_BPCFG_CHANGE: - mutex_lock(&dev->scan_mutex); - aac_update_safw_host_devices(dev, AAC_RESCAN); - mutex_unlock(&dev->scan_mutex); + aac_scan_host(dev, AAC_RESCAN); + break; case SA_AIF_BPSTAT_CHANGE: diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index 2c862cd26a21..7ea7b2cc86bb 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -1787,7 +1787,8 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) error = scsi_add_host(shost, &pdev->dev); if (error) goto out_deinit; - scsi_scan_host(shost); + + aac_scan_host(aac, AAC_INIT); pci_enable_pcie_error_reporting(pdev); pci_save_state(pdev); @@ -2071,7 +2072,7 @@ static void aac_pci_resume(struct pci_dev *pdev) if (sdev->sdev_state == SDEV_OFFLINE) sdev->sdev_state = SDEV_RUNNING; scsi_unblock_requests(aac->scsi_host_ptr); - scsi_scan_host(aac->scsi_host_ptr); + aac_scan_host(aac, AAC_RESCAN); pci_save_state(pdev); dev_err(&pdev->dev, "aacraid: PCI error - resume\n"); -- cgit v1.2.3 From a1367e4adee207fee7f14fdf2166022461fe76c4 Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Tue, 26 Dec 2017 20:34:46 -0800 Subject: scsi: aacraid: Reschedule host scan in case of failure If the driver fails to retrieve information from the fw (could happen when the fw is not fully in its senses), the driver does nothing and change is not processed correctly by the driver Schedule host rescan in case of failure. This is only for SAFW, since the information retrieval failure will happen on SAFW devices. Signed-off-by: Raghava Aditya Renukunta Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/aacraid.h | 27 ++++++++++++++++++++++++++- drivers/scsi/aacraid/commsup.c | 14 +++++++++++++- drivers/scsi/aacraid/linit.c | 5 +++++ 3 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 ba84d9985ce7..54078bf8ab67 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -1341,6 +1341,8 @@ struct fib { #define AAC_EXPOSE_DISK 0 #define AAC_HIDE_DISK 3 +#define AAC_SAFW_RESCAN_DELAY 10 + struct aac_hba_map_info { __le32 rmw_nexus; /* nexus for native HBA devices */ u8 devtype; /* device type */ @@ -1611,6 +1613,7 @@ struct aac_dev int maximum_num_channels; struct fsa_dev_info *fsa_dev; struct task_struct *thread; + struct delayed_work safw_rescan_work; int cardtype; /* *This lock will protect the two 32-bit @@ -2639,12 +2642,35 @@ static inline int aac_adapter_check_health(struct aac_dev *dev) return (dev)->a_ops.adapter_check_health(dev); } + +int aac_scan_host(struct aac_dev *dev, int rescan); + +static inline void aac_schedule_safw_scan_worker(struct aac_dev *dev) +{ + schedule_delayed_work(&dev->safw_rescan_work, AAC_SAFW_RESCAN_DELAY); +} + +static inline void aac_safw_rescan_worker(struct work_struct *work) +{ + struct aac_dev *dev = container_of(to_delayed_work(work), + struct aac_dev, safw_rescan_work); + + aac_scan_host(dev, AAC_RESCAN); +} + +static inline void aac_cancel_safw_rescan_worker(struct aac_dev *dev) +{ + if (dev->sa_firmware) + cancel_delayed_work_sync(&dev->safw_rescan_work); +} + /* SCp.phase values */ #define AAC_OWNER_MIDLEVEL 0x101 #define AAC_OWNER_LOWLEVEL 0x102 #define AAC_OWNER_ERROR_HANDLER 0x103 #define AAC_OWNER_FIRMWARE 0x106 +void aac_safw_rescan_worker(struct work_struct *work); int aac_acquire_irq(struct aac_dev *dev); void aac_free_irq(struct aac_dev *dev); int aac_setup_safw_adapter(struct aac_dev *dev, int rescan); @@ -2719,7 +2745,6 @@ static inline int aac_supports_2T(struct aac_dev *dev) return (dev->adapter_info.options & AAC_OPT_NEW_COMM_64); } -int aac_scan_host(struct aac_dev *dev, int rescan); char * get_container_type(unsigned type); extern int numacb; extern char aac_driver_version[]; diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c index 4e2687ce2456..d562053f14d7 100644 --- a/drivers/scsi/aacraid/commsup.c +++ b/drivers/scsi/aacraid/commsup.c @@ -1964,16 +1964,28 @@ out: return rcode; } +static int aac_scan_safw_host(struct aac_dev *dev, int rescan) +{ + int rcode = 0; + + rcode = aac_update_safw_host_devices(dev, rescan); + if (rcode) + aac_schedule_safw_scan_worker(dev); + + return rcode; +} + int aac_scan_host(struct aac_dev *dev, int rescan) { int rcode = 0; mutex_lock(&dev->scan_mutex); if (dev->sa_firmware) - rcode = aac_update_safw_host_devices(dev, rescan); + rcode = aac_scan_safw_host(dev, rescan); else scsi_scan_host(dev->scsi_host_ptr); mutex_unlock(&dev->scan_mutex); + return rcode; } diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index 7ea7b2cc86bb..bf9d2b72da62 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -1684,6 +1684,8 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) mutex_init(&aac->ioctl_mutex); mutex_init(&aac->scan_mutex); + + INIT_DELAYED_WORK(&aac->safw_rescan_work, aac_safw_rescan_worker); /* * Map in the registers from the adapter. */ @@ -1873,6 +1875,7 @@ static int aac_suspend(struct pci_dev *pdev, pm_message_t state) struct aac_dev *aac = (struct aac_dev *)shost->hostdata; scsi_block_requests(shost); + aac_cancel_safw_rescan_worker(aac); aac_send_shutdown(aac); aac_release_resources(aac); @@ -1931,6 +1934,7 @@ static void aac_remove_one(struct pci_dev *pdev) struct Scsi_Host *shost = pci_get_drvdata(pdev); struct aac_dev *aac = (struct aac_dev *)shost->hostdata; + aac_cancel_safw_rescan_worker(aac); scsi_remove_host(shost); __aac_shutdown(aac); @@ -1988,6 +1992,7 @@ static pci_ers_result_t aac_pci_error_detected(struct pci_dev *pdev, aac->handle_pci_error = 1; scsi_block_requests(aac->scsi_host_ptr); + aac_cancel_safw_rescan_worker(aac); aac_flush_ios(aac); aac_release_resources(aac); -- cgit v1.2.3 From 8a30e50b72ca08c78474db514531ce5d9ae00fa4 Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Tue, 26 Dec 2017 20:34:47 -0800 Subject: scsi: aacraid: Fix hang while scanning in eh recovery Add back the ability to scan for hotplug changes while eh was in progress. Schedule a rescan for a later time in the eh recovery code and wait for eh to complete in the rescan worker. Signed-off-by: Raghava Aditya Renukunta Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/aacraid.h | 4 ++++ drivers/scsi/aacraid/commsup.c | 9 +++++++++ 2 files changed, 13 insertions(+) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index 54078bf8ab67..4cefc47dfd5e 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -41,6 +41,7 @@ #include #include +#include /*------------------------------------------------------------------------------ * D E F I N E S @@ -2655,6 +2656,9 @@ static inline void aac_safw_rescan_worker(struct work_struct *work) struct aac_dev *dev = container_of(to_delayed_work(work), struct aac_dev, safw_rescan_work); + wait_event(dev->scsi_host_ptr->host_wait, + !scsi_host_in_recovery(dev->scsi_host_ptr)); + aac_scan_host(dev, AAC_RESCAN); } diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c index d562053f14d7..706aba0ed726 100644 --- a/drivers/scsi/aacraid/commsup.c +++ b/drivers/scsi/aacraid/commsup.c @@ -1671,6 +1671,15 @@ out: aac->in_reset = 0; scsi_unblock_requests(host); + /* + * Issue bus rescan to catch any configuration that might have + * occurred + */ + if (!retval) { + dev_info(&aac->pdev->dev, "Scheduling bus rescan\n"); + aac_schedule_safw_scan_worker(aac); + } + if (jafo) { spin_lock_irq(host->host_lock); } -- cgit v1.2.3 From fe5237590bb033ad6b7312b0ef62a2d7d5c4141f Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Tue, 26 Dec 2017 20:34:48 -0800 Subject: scsi: aacraid: Skip schedule rescan in case of kdump There is a chance of the driver to be stuck in kdump if drives start acting up in kdump discovery process and the kernel decides to send eh resets, which would prompt rescan to be scheduled. Do not perform a rescan in kdump context, since we do not expect a hotplug event during kdump and all the devices are going to go away anyway. Signed-off-by: Raghava Aditya Renukunta Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/commsup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c index 706aba0ed726..f0c3e7dbf60a 100644 --- a/drivers/scsi/aacraid/commsup.c +++ b/drivers/scsi/aacraid/commsup.c @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -1675,7 +1676,7 @@ out: * Issue bus rescan to catch any configuration that might have * occurred */ - if (!retval) { + if (!retval && !is_kdump_kernel()) { dev_info(&aac->pdev->dev, "Scheduling bus rescan\n"); aac_schedule_safw_scan_worker(aac); } -- cgit v1.2.3 From 75be67cd155d95658507b15ffe905c36243526ae Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Tue, 26 Dec 2017 20:34:49 -0800 Subject: scsi: aacraid: Remove unused rescan variable Remove unused rescan variable. Signed-off-by: Raghava Aditya Renukunta Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/aachba.c | 19 +++++++++---------- drivers/scsi/aacraid/aacraid.h | 6 +++--- drivers/scsi/aacraid/commsup.c | 14 +++++++------- drivers/scsi/aacraid/linit.c | 4 ++-- 4 files changed, 21 insertions(+), 22 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index 426c61a28926..f498bed93cc9 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -1821,12 +1821,11 @@ static inline void aac_free_safw_ciss_luns(struct aac_dev *dev) /** * aac_get_safw_ciss_luns() Process topology change * @dev: aac_dev structure - * @rescan: Indicates rescan * * Execute a CISS REPORT PHYS LUNS and process the results into * the current hba_map. */ -static int aac_get_safw_ciss_luns(struct aac_dev *dev, int rescan) +static int aac_get_safw_ciss_luns(struct aac_dev *dev) { int rcode = -ENOMEM; int datasize; @@ -1932,7 +1931,7 @@ static inline void aac_free_safw_all_identify_resp(struct aac_dev *dev, } } -static int aac_get_safw_attr_all_targets(struct aac_dev *dev, int rescan) +static int aac_get_safw_attr_all_targets(struct aac_dev *dev) { int i; int rcode = 0; @@ -1972,7 +1971,7 @@ free_identify_resp: * * Update our hba map with the information gathered from the FW */ -static void aac_set_safw_attr_all_targets(struct aac_dev *dev, int rescan) +static void aac_set_safw_attr_all_targets(struct aac_dev *dev) { /* ok and extended reporting */ u32 lun_count, nexus; @@ -2018,7 +2017,7 @@ update_devtype: } } -static int aac_setup_safw_targets(struct aac_dev *dev, int rescan) +static int aac_setup_safw_targets(struct aac_dev *dev) { int rcode = 0; @@ -2026,15 +2025,15 @@ static int aac_setup_safw_targets(struct aac_dev *dev, int rescan) if (unlikely(rcode < 0)) goto out; - rcode = aac_get_safw_ciss_luns(dev, rescan); + rcode = aac_get_safw_ciss_luns(dev); if (unlikely(rcode < 0)) goto out; - rcode = aac_get_safw_attr_all_targets(dev, rescan); + rcode = aac_get_safw_attr_all_targets(dev); if (unlikely(rcode < 0)) goto free_ciss_luns; - aac_set_safw_attr_all_targets(dev, rescan); + aac_set_safw_attr_all_targets(dev); aac_free_safw_all_identify_resp(dev, -1); free_ciss_luns: @@ -2043,9 +2042,9 @@ out: return rcode; } -int aac_setup_safw_adapter(struct aac_dev *dev, int rescan) +int aac_setup_safw_adapter(struct aac_dev *dev) { - return aac_setup_safw_targets(dev, rescan); + return aac_setup_safw_targets(dev); } int aac_get_adapter_info(struct aac_dev* dev) diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index 4cefc47dfd5e..3e8a44c58728 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -2644,7 +2644,7 @@ static inline int aac_adapter_check_health(struct aac_dev *dev) } -int aac_scan_host(struct aac_dev *dev, int rescan); +int aac_scan_host(struct aac_dev *dev); static inline void aac_schedule_safw_scan_worker(struct aac_dev *dev) { @@ -2659,7 +2659,7 @@ static inline void aac_safw_rescan_worker(struct work_struct *work) wait_event(dev->scsi_host_ptr->host_wait, !scsi_host_in_recovery(dev->scsi_host_ptr)); - aac_scan_host(dev, AAC_RESCAN); + aac_scan_host(dev); } static inline void aac_cancel_safw_rescan_worker(struct aac_dev *dev) @@ -2677,7 +2677,7 @@ static inline void aac_cancel_safw_rescan_worker(struct aac_dev *dev) void aac_safw_rescan_worker(struct work_struct *work); int aac_acquire_irq(struct aac_dev *dev); void aac_free_irq(struct aac_dev *dev); -int aac_setup_safw_adapter(struct aac_dev *dev, int rescan); +int aac_setup_safw_adapter(struct aac_dev *dev); const char *aac_driverinfo(struct Scsi_Host *); void aac_fib_vector_assign(struct aac_dev *dev); struct fib *aac_fib_alloc(struct aac_dev *dev); diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c index f0c3e7dbf60a..fbf8b7ebd654 100644 --- a/drivers/scsi/aacraid/commsup.c +++ b/drivers/scsi/aacraid/commsup.c @@ -1944,7 +1944,7 @@ static int aac_is_safw_device_exposed(struct aac_dev *dev, int bus, int target) return is_exposed; } -static int aac_update_safw_host_devices(struct aac_dev *dev, int rescan) +static int aac_update_safw_host_devices(struct aac_dev *dev) { int i; int bus; @@ -1952,7 +1952,7 @@ static int aac_update_safw_host_devices(struct aac_dev *dev, int rescan) int is_exposed = 0; int rcode = 0; - rcode = aac_setup_safw_adapter(dev, rescan); + rcode = aac_setup_safw_adapter(dev); if (unlikely(rcode < 0)) { goto out; } @@ -1974,24 +1974,24 @@ out: return rcode; } -static int aac_scan_safw_host(struct aac_dev *dev, int rescan) +static int aac_scan_safw_host(struct aac_dev *dev) { int rcode = 0; - rcode = aac_update_safw_host_devices(dev, rescan); + rcode = aac_update_safw_host_devices(dev); if (rcode) aac_schedule_safw_scan_worker(dev); return rcode; } -int aac_scan_host(struct aac_dev *dev, int rescan) +int aac_scan_host(struct aac_dev *dev) { int rcode = 0; mutex_lock(&dev->scan_mutex); if (dev->sa_firmware) - rcode = aac_scan_safw_host(dev, rescan); + rcode = aac_scan_safw_host(dev); else scsi_scan_host(dev->scsi_host_ptr); mutex_unlock(&dev->scan_mutex); @@ -2032,7 +2032,7 @@ static void aac_handle_sa_aif(struct aac_dev *dev, struct fib *fibptr) case SA_AIF_LDEV_CHANGE: case SA_AIF_BPCFG_CHANGE: - aac_scan_host(dev, AAC_RESCAN); + aac_scan_host(dev); break; diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index bf9d2b72da62..ad6ec573cc87 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -1790,7 +1790,7 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) if (error) goto out_deinit; - aac_scan_host(aac, AAC_INIT); + aac_scan_host(aac); pci_enable_pcie_error_reporting(pdev); pci_save_state(pdev); @@ -2077,7 +2077,7 @@ static void aac_pci_resume(struct pci_dev *pdev) if (sdev->sdev_state == SDEV_OFFLINE) sdev->sdev_state = SDEV_RUNNING; scsi_unblock_requests(aac->scsi_host_ptr); - aac_scan_host(aac, AAC_RESCAN); + aac_scan_host(aac); pci_save_state(pdev); dev_err(&pdev->dev, "aacraid: PCI error - resume\n"); -- cgit v1.2.3 From e51c4d703d22ba9590c9d538ccc567835a23caaf Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Tue, 26 Dec 2017 20:34:50 -0800 Subject: scsi: aacraid: Remove AAC_HIDE_DISK check in queue command Earlier driver would scan throgh all supported buses and targets and add devices that responded. It would add devices that were _hidden_ by the fw. Driver would invalidate commands sent to _hidden_ devices via the AAC_HIDE_DISK check. Since the driver now adds only the devices that are supposed to be exposed, this code can be removed. Signed-off-by: Raghava Aditya Renukunta Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/aachba.c | 10 ---------- drivers/scsi/aacraid/aacraid.h | 3 --- 2 files changed, 13 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index f498bed93cc9..a2bdd7931cf1 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -1994,8 +1994,6 @@ static void aac_set_safw_attr_all_targets(struct aac_dev *dev) if (bus >= AAC_MAX_BUSES || target >= AAC_MAX_TARGETS) continue; - dev->hba_map[bus][target].expose = expose_flag; - if (expose_flag != 0) { devtype = AAC_DEVTYPE_RAID_MEMBER; goto update_devtype; @@ -2913,14 +2911,6 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) } } else { /* check for physical non-dasd devices */ bus = aac_logical_to_phys(scmd_channel(scsicmd)); - if (bus < AAC_MAX_BUSES && cid < AAC_MAX_TARGETS && - (dev->hba_map[bus][cid].expose - == AAC_HIDE_DISK)){ - if (scsicmd->cmnd[0] == INQUIRY) { - scsicmd->result = DID_NO_CONNECT << 16; - goto scsi_done_ret; - } - } if (bus < AAC_MAX_BUSES && cid < AAC_MAX_TARGETS && dev->hba_map[bus][cid].devtype diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index 3e8a44c58728..4d3536d9f646 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -1339,8 +1339,6 @@ struct fib { #define AAC_DEVTYPE_RAID_MEMBER 1 #define AAC_DEVTYPE_ARC_RAW 2 #define AAC_DEVTYPE_NATIVE_RAW 3 -#define AAC_EXPOSE_DISK 0 -#define AAC_HIDE_DISK 3 #define AAC_SAFW_RESCAN_DELAY 10 @@ -1350,7 +1348,6 @@ struct aac_hba_map_info { u8 reset_state; /* 0 - no reset, 1..x - */ /* after xth TM LUN reset */ u16 qd_limit; - u8 expose; /*checks if to expose or not*/ u32 scan_counter; struct aac_ciss_identify_pd *safw_identify_resp; }; -- cgit v1.2.3 From 1cdb74b80f93343d7b44b5d99b28d9b0c46375ba Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Tue, 26 Dec 2017 20:34:51 -0800 Subject: scsi: aacraid: Update driver version to 50877 Update driver Version to 50877 Signed-off-by: Raghava Aditya Renukunta 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 4d3536d9f646..3e8bfcf6d0cb 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -98,7 +98,7 @@ enum { #define PMC_GLOBAL_INT_BIT0 0x00000001 #ifndef AAC_DRIVER_BUILD -# define AAC_DRIVER_BUILD 50834 +# define AAC_DRIVER_BUILD 50877 # define AAC_DRIVER_BRANCH "-custom" #endif #define MAXIMUM_NUM_CONTAINERS 32 -- cgit v1.2.3 From bef4e68830a102142fc4cb0c0ad4f1877d2ee557 Mon Sep 17 00:00:00 2001 From: Meelis Roos Date: Wed, 3 Jan 2018 11:11:09 +0200 Subject: scsi: aacraid: Fix driver oops with dead battery The battery in my HP NetRAID-4M died of old age, and the aacraid driver started oopsing with NULL pointer dereference on startup after that. Fix it by reordering the init sequence to fill in function pointers before ioremapping memory, or dev->a_ops.adapter_ioremap pointer will be NULL. Other subtypes of aacraid seem to have the order already correct. This was the call trace: ? aac_probe_one+0x7a5/0xb30 [aacraid] pci_device_probe+0xc0/0x1a0 driver_probe_device+0x1df/0x3b0 __driver_attach+0xa9/0xe0 ? driver_probe_device+0x3b0/0x3b0 bus_for_each_dev+0x4c/0x90 driver_attach+0x1d/0x40 ? driver_probe_device+0x3b0/0x3b0 bus_add_driver+0x1a7/0x2a0 driver_register+0x6e/0x130 __pci_register_driver+0x54/0x90 ? 0xf81f4000 aac_init+0x2b/0x1000 [aacraid] do_one_initcall+0x45/0x1e0 ? kfree_skbmem+0x74/0xa0 ? kfree+0x16d/0x240 ? kvfree+0x45/0x50 ? kvfree+0x45/0x50 ? __vunmap+0x99/0x120 ? do_init_module+0x1a/0x245 do_init_module+0x83/0x245 load_module+0x2764/0x34a0 ? kernel_read_file+0x150/0x320 SyS_finit_module+0x82/0xa0 do_fast_syscall_32+0xba/0x340 Signed-off-by: Meelis Roos Reviewed-by: Raghava Aditya Renukunta Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/sa.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/sa.c b/drivers/scsi/aacraid/sa.c index 553922fed524..882f40353b96 100644 --- a/drivers/scsi/aacraid/sa.c +++ b/drivers/scsi/aacraid/sa.c @@ -329,6 +329,22 @@ int aac_sa_init(struct aac_dev *dev) instance = dev->id; name = dev->name; + /* + * Fill in the function dispatch table. + */ + + dev->a_ops.adapter_interrupt = aac_sa_interrupt_adapter; + dev->a_ops.adapter_disable_int = aac_sa_disable_interrupt; + dev->a_ops.adapter_enable_int = aac_sa_enable_interrupt; + dev->a_ops.adapter_notify = aac_sa_notify_adapter; + dev->a_ops.adapter_sync_cmd = sa_sync_cmd; + dev->a_ops.adapter_check_health = aac_sa_check_health; + dev->a_ops.adapter_restart = aac_sa_restart_adapter; + dev->a_ops.adapter_start = aac_sa_start_adapter; + dev->a_ops.adapter_intr = aac_sa_intr; + dev->a_ops.adapter_deliver = aac_rx_deliver_producer; + dev->a_ops.adapter_ioremap = aac_sa_ioremap; + if (aac_sa_ioremap(dev, dev->base_size)) { printk(KERN_WARNING "%s: unable to map adapter.\n", name); goto error_iounmap; @@ -362,22 +378,6 @@ int aac_sa_init(struct aac_dev *dev) msleep(1); } - /* - * Fill in the function dispatch table. - */ - - dev->a_ops.adapter_interrupt = aac_sa_interrupt_adapter; - dev->a_ops.adapter_disable_int = aac_sa_disable_interrupt; - dev->a_ops.adapter_enable_int = aac_sa_enable_interrupt; - dev->a_ops.adapter_notify = aac_sa_notify_adapter; - dev->a_ops.adapter_sync_cmd = sa_sync_cmd; - dev->a_ops.adapter_check_health = aac_sa_check_health; - dev->a_ops.adapter_restart = aac_sa_restart_adapter; - dev->a_ops.adapter_start = aac_sa_start_adapter; - dev->a_ops.adapter_intr = aac_sa_intr; - dev->a_ops.adapter_deliver = aac_rx_deliver_producer; - dev->a_ops.adapter_ioremap = aac_sa_ioremap; - /* * First clear out all interrupts. Then enable the one's that * we can handle. -- cgit v1.2.3 From 91814744646351a470f256fbcb853fb5a7229a9f Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Fri, 5 Jan 2018 15:31:06 +0000 Subject: scsi: aacraid: remove redundant setting of variable c A previous commit no longer stores the contents of c, so we now have a situation where c is being updated but the value is never read. Clean up the code by removing the now redundant setting of variable c. Cleans up clang warning: drivers/scsi/aacraid/aachba.c:943:3: warning: Value stored to 'c' is never read Fixes: f4e8708d3104 ("scsi: aacraid: Fix udev inquiry race condition") Signed-off-by: Colin Ian King Reviewed-by: Raghava Aditya Renukunta Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/aachba.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index a2bdd7931cf1..525d72fcbf3e 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -940,11 +940,8 @@ static void setinqstr(struct aac_dev *dev, void *data, int tindex) while (*cp == ' ') ++cp; /* last six chars reserved for vol type */ - c = 0; - if (strlen(cp) > sizeof(str->pid)) { - c = cp[sizeof(str->pid)]; + if (strlen(cp) > sizeof(str->pid)) cp[sizeof(str->pid)] = '\0'; - } inqstrcpy (cp, str->pid); kfree(cname); -- cgit v1.2.3 From bbd16d96d1ec531f6ad950d01b542422040033b8 Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Wed, 10 Jan 2018 13:13:09 -0800 Subject: scsi: aacraid: Get correct lun count The correct lun count needs to be divided by 24, missed it in the previous patch set. Fixes: 4b00022753550055 (scsi: aacraid: Create helper functions to get lun info) Signed-off-by: Raghava Aditya Renukunta Signed-off-by: Martin K. Petersen --- drivers/scsi/aacraid/aachba.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/scsi/aacraid') diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index 525d72fcbf3e..e7961cbd2c55 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -1865,7 +1865,7 @@ mem_free_all: static inline u32 aac_get_safw_phys_lun_count(struct aac_dev *dev) { - return get_unaligned_be32(&dev->safw_phys_luns->list_length[0]); + return get_unaligned_be32(&dev->safw_phys_luns->list_length[0])/24; } static inline u32 aac_get_safw_phys_bus(struct aac_dev *dev, int lun) -- cgit v1.2.3 From cfc350ab0efb932f456436d65db65f0e77993148 Mon Sep 17 00:00:00 2001 From: Raghava Aditya Renukunta Date: Wed, 10 Jan 2018 13:13:10 -0800 Subject: scsi: aacraid: Delay for rescan worker needs to be 10 seconds The delay for the rescan worker needs to 10 seconds, missed the HZ in there. Fixes: a1367e4adee207fe (scsi: aacraid: Reschedule host scan in case of failure) Signed-off-by: Raghava Aditya Renukunta 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 3e8bfcf6d0cb..3ab323198fb2 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -1340,7 +1340,7 @@ struct fib { #define AAC_DEVTYPE_ARC_RAW 2 #define AAC_DEVTYPE_NATIVE_RAW 3 -#define AAC_SAFW_RESCAN_DELAY 10 +#define AAC_SAFW_RESCAN_DELAY (10 * HZ) struct aac_hba_map_info { __le32 rmw_nexus; /* nexus for native HBA devices */ -- cgit v1.2.3