All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes
@ 2017-12-21 17:33 Raghava Aditya Renukunta
  2017-12-21 17:33 ` [PATCH 01/29] scsi: aacraid: Fix udev inquiry race condition Raghava Aditya Renukunta
                   ` (29 more replies)
  0 siblings, 30 replies; 49+ messages in thread
From: Raghava Aditya Renukunta @ 2017-12-21 17:33 UTC (permalink / raw)
  To: jejb, martin.petersen, linux-scsi
  Cc: Scott.Benesh, aacraid, tom.white, Guilherme G . Piccoli

This patchset primarily lays the foundation for adding sas transport
support to the aacraid driver. Being said these patches are mainly code
refactors, bug fixes and improvements.

 - Fixed a udev inquiry race condition
 - Fixed a kdump hang issue which occurs in case of error recovery in kdump
 - Made improvements to ioctl reset and reset_host sysfs reset paths
 - Changed the code to retrieve lun information into stand alone functions.
 - Merged container and hba hotplug event processing (device addition and
   and removal into single function)
 - Removed scsi_scan_host for safw devices and now explicitly add devices
   retrieved from the fw.
 - Reschedule scan in driver fails to retrieve lun information from fw.
   (usually works in a few attempts)
 - Rescan worker waits for any pending EH recovery before rescanning
 - Do not trigger rescan worker in kdump kernel

Raghava Aditya Renukunta (29):
  scsi: aacraid: Fix udev inquiry race condition
  scsi: aacraid: Do not attempt abort when Fw panicked
  scsi: aacraid: Fix hang in kdump
  scsi: aacraid: Do not remove offlined devices
  scsi: aacraid: Fix ioctl reset hang
  scsi: aacraid: Allow reset_host sysfs var to recover Panicked Fw
  scsi: aacraid: Refactor reset_host store function
  scsi: aacraid: Move code to wait for IO completion to shutdown func
  scsi: aacraid: Create bmic submission function from bmic identify
  scsi: aacraid: Change phy luns function to use common bmic function
  scsi: aacraid: Refactor and rename to make mirror existing changes
  scsi: aacraid: Add target setup helper function
  scsi: aacraid: Untangle targets setup from report phy luns
  scsi: aacraid: Move function around to match existing code
  scsi: aacraid: Create helper functions to get lun info
  scsi: aacraid: Save bmic phy information for each phy
  scsi: aacraid: Add helper function to set queue depth
  scsi: aacraid: Merge func to get container information
  scsi: aacraid: Process hba and container hot plug events in single
		function
  scsi: aacraid: Added macros to help loop through known buses and targets
  scsi: aacraid: Refactor resolve luns code and scsi functions
  scsi: aacraid: Merge adapter setup with resolve luns
  scsi: aacraid: Block concurrent hotplug event handling
  scsi: aacraid: Use hotplug handling function in place of scsi_scan_host
  scsi: aacraid: Reschedule host scan in case of failure
  scsi: aacraid: Fix hang while scanning in eh recovery
  scsi: aacraid: Skip schedule rescan in case of kdump
  scsi: aacraid: Remove unused rescan variable
  scsi: aacraid: Remove AAC_HIDE_DISK check in queue command

 drivers/scsi/aacraid/aachba.c   | 479 +++++++++++++++++++++++++++-------------
 drivers/scsi/aacraid/aacraid.h  |  52 ++++-
 drivers/scsi/aacraid/commctrl.c |   6 +-
 drivers/scsi/aacraid/comminit.c |  49 +++-
 drivers/scsi/aacraid/commsup.c  | 224 ++++++++++---------
 drivers/scsi/aacraid/linit.c    |  23 +-
 6 files changed, 561 insertions(+), 272 deletions(-)

-- 
2.9.4

^ permalink raw reply	[flat|nested] 49+ messages in thread

* [PATCH 01/29] scsi: aacraid: Fix udev inquiry race condition
  2017-12-21 17:33 [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes Raghava Aditya Renukunta
@ 2017-12-21 17:33 ` Raghava Aditya Renukunta
  2017-12-21 17:54   ` Bart Van Assche
  2017-12-21 17:33 ` [PATCH 02/29] scsi: aacraid: Do not attempt abort when Fw panicked Raghava Aditya Renukunta
                   ` (28 subsequent siblings)
  29 siblings, 1 reply; 49+ messages in thread
From: Raghava Aditya Renukunta @ 2017-12-21 17:33 UTC (permalink / raw)
  To: jejb, martin.petersen, linux-scsi
  Cc: Scott.Benesh, aacraid, tom.white, Guilherme G . Piccoli

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: <stable@vger.kernel.org>
Fixes: 3bc8070fb75b3315 ([SCSI] aacraid: SMC vendor identification)
Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
---
 drivers/scsi/aacraid/aachba.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index af3e4d3..f264515 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -913,8 +913,18 @@ 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 = kmalloc(sizeof(sup_adap_info->adapter_type_text),
+								GFP_ATOMIC);
+
+		if (!cname)
+			return;
+
+		cp = cname;
+		memcpy(cname, sup_adap_info->adapter_type_text,
+			sizeof(sup_adap_info->adapter_type_text));
+
 		if ((cp[0] == 'A') && (cp[1] == 'O') && (cp[2] == 'C'))
 			inqstrcpy("SMC", str->vid);
 		else {
@@ -923,7 +933,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 +947,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);
 
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 02/29] scsi: aacraid: Do not attempt abort when Fw panicked
  2017-12-21 17:33 [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes Raghava Aditya Renukunta
  2017-12-21 17:33 ` [PATCH 01/29] scsi: aacraid: Fix udev inquiry race condition Raghava Aditya Renukunta
@ 2017-12-21 17:33 ` Raghava Aditya Renukunta
  2017-12-21 17:33 ` [PATCH 03/29] scsi: aacraid: Fix hang in kdump Raghava Aditya Renukunta
                   ` (27 subsequent siblings)
  29 siblings, 0 replies; 49+ messages in thread
From: Raghava Aditya Renukunta @ 2017-12-21 17:33 UTC (permalink / raw)
  To: jejb, martin.petersen, linux-scsi
  Cc: Scott.Benesh, aacraid, tom.white, Guilherme G . Piccoli

Check if the adapter can receive abort requests, before sending aborts

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
---
 drivers/scsi/aacraid/linit.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index 3677bef..5eb0722 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) {
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 03/29] scsi: aacraid: Fix hang in kdump
  2017-12-21 17:33 [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes Raghava Aditya Renukunta
  2017-12-21 17:33 ` [PATCH 01/29] scsi: aacraid: Fix udev inquiry race condition Raghava Aditya Renukunta
  2017-12-21 17:33 ` [PATCH 02/29] scsi: aacraid: Do not attempt abort when Fw panicked Raghava Aditya Renukunta
@ 2017-12-21 17:33 ` Raghava Aditya Renukunta
  2017-12-21 19:15   ` Guilherme G. Piccoli
  2017-12-22 15:13   ` Guilherme G. Piccoli
  2017-12-21 17:33 ` [PATCH 04/29] scsi: aacraid: Do not remove offlined devices Raghava Aditya Renukunta
                   ` (26 subsequent siblings)
  29 siblings, 2 replies; 49+ messages in thread
From: Raghava Aditya Renukunta @ 2017-12-21 17:33 UTC (permalink / raw)
  To: jejb, martin.petersen, linux-scsi
  Cc: Scott.Benesh, aacraid, tom.white, Guilherme G . Piccoli

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: <stable@vger.kernel.org>
Reported-by: Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>
Tested-by: Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>
Fixes: a2d0321dd532901e (scsi: aacraid: Reload offlined drives after controller reset)
Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
---
 drivers/scsi/aacraid/commsup.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c
index 525a652..ffbfd04 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);
 	}
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 04/29] scsi: aacraid: Do not remove offlined devices
  2017-12-21 17:33 [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes Raghava Aditya Renukunta
                   ` (2 preceding siblings ...)
  2017-12-21 17:33 ` [PATCH 03/29] scsi: aacraid: Fix hang in kdump Raghava Aditya Renukunta
@ 2017-12-21 17:33 ` Raghava Aditya Renukunta
  2017-12-21 17:33 ` [PATCH 05/29] scsi: aacraid: Fix ioctl reset hang Raghava Aditya Renukunta
                   ` (25 subsequent siblings)
  29 siblings, 0 replies; 49+ messages in thread
From: Raghava Aditya Renukunta @ 2017-12-21 17:33 UTC (permalink / raw)
  To: jejb, martin.petersen, linux-scsi
  Cc: Scott.Benesh, aacraid, tom.white, Guilherme G . Piccoli

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 <RaghavaAditya.Renukunta@microsemi.com>
---
 drivers/scsi/aacraid/commsup.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c
index ffbfd04..32b8bdb 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;
 
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 05/29] scsi: aacraid: Fix ioctl reset hang
  2017-12-21 17:33 [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes Raghava Aditya Renukunta
                   ` (3 preceding siblings ...)
  2017-12-21 17:33 ` [PATCH 04/29] scsi: aacraid: Do not remove offlined devices Raghava Aditya Renukunta
@ 2017-12-21 17:33 ` Raghava Aditya Renukunta
  2017-12-21 17:33 ` [PATCH 06/29] scsi: aacraid: Allow reset_host sysfs var to recover Panicked Fw Raghava Aditya Renukunta
                   ` (24 subsequent siblings)
  29 siblings, 0 replies; 49+ messages in thread
From: Raghava Aditya Renukunta @ 2017-12-21 17:33 UTC (permalink / raw)
  To: jejb, martin.petersen, linux-scsi
  Cc: Scott.Benesh, aacraid, tom.white, Guilherme G . Piccoli

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 <RaghavaAditya.Renukunta@microsemi.com>
---
 drivers/scsi/aacraid/commctrl.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c
index 9ab0fa9..a2b3430 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)
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 06/29] scsi: aacraid: Allow reset_host sysfs var to recover Panicked Fw
  2017-12-21 17:33 [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes Raghava Aditya Renukunta
                   ` (4 preceding siblings ...)
  2017-12-21 17:33 ` [PATCH 05/29] scsi: aacraid: Fix ioctl reset hang Raghava Aditya Renukunta
@ 2017-12-21 17:33 ` Raghava Aditya Renukunta
  2017-12-21 17:33 ` [PATCH 07/29] scsi: aacraid: Refactor reset_host store function Raghava Aditya Renukunta
                   ` (23 subsequent siblings)
  29 siblings, 0 replies; 49+ messages in thread
From: Raghava Aditya Renukunta @ 2017-12-21 17:33 UTC (permalink / raw)
  To: jejb, martin.petersen, linux-scsi
  Cc: Scott.Benesh, aacraid, tom.white, Guilherme G . Piccoli

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 <RaghavaAditya.Renukunta@microsemi.com>
---
 drivers/scsi/aacraid/comminit.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c
index 1bc623a..9eff246 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);
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 07/29] scsi: aacraid: Refactor reset_host store function
  2017-12-21 17:33 [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes Raghava Aditya Renukunta
                   ` (5 preceding siblings ...)
  2017-12-21 17:33 ` [PATCH 06/29] scsi: aacraid: Allow reset_host sysfs var to recover Panicked Fw Raghava Aditya Renukunta
@ 2017-12-21 17:33 ` Raghava Aditya Renukunta
  2017-12-21 17:33 ` [PATCH 08/29] scsi: aacraid: Move code to wait for IO completion to shutdown func Raghava Aditya Renukunta
                   ` (22 subsequent siblings)
  29 siblings, 0 replies; 49+ messages in thread
From: Raghava Aditya Renukunta @ 2017-12-21 17:33 UTC (permalink / raw)
  To: jejb, martin.petersen, linux-scsi
  Cc: Scott.Benesh, aacraid, tom.white, Guilherme G . Piccoli

Refactored the reset_host store function to make consistent across code
bases.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
---
 drivers/scsi/aacraid/linit.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index 5eb0722..b2273e3 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;
 }
 
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 08/29] scsi: aacraid: Move code to wait for IO completion to shutdown func
  2017-12-21 17:33 [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes Raghava Aditya Renukunta
                   ` (6 preceding siblings ...)
  2017-12-21 17:33 ` [PATCH 07/29] scsi: aacraid: Refactor reset_host store function Raghava Aditya Renukunta
@ 2017-12-21 17:33 ` Raghava Aditya Renukunta
  2017-12-21 17:59   ` Bart Van Assche
  2017-12-21 17:34 ` [PATCH 09/29] scsi: aacraid: Create bmic submission function from bmic identify Raghava Aditya Renukunta
                   ` (21 subsequent siblings)
  29 siblings, 1 reply; 49+ messages in thread
From: Raghava Aditya Renukunta @ 2017-12-21 17:33 UTC (permalink / raw)
  To: jejb, martin.petersen, linux-scsi
  Cc: Scott.Benesh, aacraid, tom.white, Guilherme G . Piccoli

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 <RaghavaAditya.Renukunta@microsemi.com>
---
 drivers/scsi/aacraid/comminit.c | 36 ++++++++++++++++++++++++++++++++++++
 drivers/scsi/aacraid/commsup.c  | 25 -------------------------
 2 files changed, 36 insertions(+), 25 deletions(-)

diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c
index 9eff246..0dc7b5a 100644
--- a/drivers/scsi/aacraid/comminit.c
+++ b/drivers/scsi/aacraid/comminit.c
@@ -42,6 +42,8 @@
 #include <linux/completion.h>
 #include <linux/mm.h>
 #include <scsi/scsi_host.h>
+#include <scsi/scsi_device.h>
+#include <scsi/scsi_cmnd.h>
 
 #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 32b8bdb..9840bd3 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)
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 09/29] scsi: aacraid: Create bmic submission function from bmic identify
  2017-12-21 17:33 [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes Raghava Aditya Renukunta
                   ` (7 preceding siblings ...)
  2017-12-21 17:33 ` [PATCH 08/29] scsi: aacraid: Move code to wait for IO completion to shutdown func Raghava Aditya Renukunta
@ 2017-12-21 17:34 ` Raghava Aditya Renukunta
  2017-12-21 17:34 ` [PATCH 10/29] scsi: aacraid: Change phy luns function to use common bmic function Raghava Aditya Renukunta
                   ` (20 subsequent siblings)
  29 siblings, 0 replies; 49+ messages in thread
From: Raghava Aditya Renukunta @ 2017-12-21 17:34 UTC (permalink / raw)
  To: jejb, martin.petersen, linux-scsi
  Cc: Scott.Benesh, aacraid, tom.white, Guilherme G . Piccoli

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 <RaghavaAditya.Renukunta@microsemi.com>
---
 drivers/scsi/aacraid/aachba.c  | 147 +++++++++++++++++++++++++++--------------
 drivers/scsi/aacraid/aacraid.h |   7 +-
 2 files changed, 105 insertions(+), 49 deletions(-)

diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index f264515..8d119e1 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -1670,60 +1670,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)
@@ -1732,12 +1788,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 403a639..bc2a0bc 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);
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 10/29] scsi: aacraid: Change phy luns function to use common bmic function
  2017-12-21 17:33 [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes Raghava Aditya Renukunta
                   ` (8 preceding siblings ...)
  2017-12-21 17:34 ` [PATCH 09/29] scsi: aacraid: Create bmic submission function from bmic identify Raghava Aditya Renukunta
@ 2017-12-21 17:34 ` Raghava Aditya Renukunta
  2017-12-21 17:34 ` [PATCH 11/29] scsi: aacraid: Refactor and rename to make mirror existing changes Raghava Aditya Renukunta
                   ` (19 subsequent siblings)
  29 siblings, 0 replies; 49+ messages in thread
From: Raghava Aditya Renukunta @ 2017-12-21 17:34 UTC (permalink / raw)
  To: jejb, martin.petersen, linux-scsi
  Cc: Scott.Benesh, aacraid, tom.white, Guilherme G . Piccoli

Edit function that retrieves phy lun information to use common
bmic function

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
---
 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(-)

diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index 8d119e1..8fb0da7 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -1856,66 +1856,37 @@ void aac_update_hba_map(struct aac_dev *dev,
 /**
  *	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) {
@@ -1923,7 +1894,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;
 }
@@ -2033,7 +2004,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 bc2a0bc..3a20168 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 9840bd3..f70f112 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);
 
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 11/29] scsi: aacraid: Refactor and rename to make mirror existing changes
  2017-12-21 17:33 [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes Raghava Aditya Renukunta
                   ` (9 preceding siblings ...)
  2017-12-21 17:34 ` [PATCH 10/29] scsi: aacraid: Change phy luns function to use common bmic function Raghava Aditya Renukunta
@ 2017-12-21 17:34 ` Raghava Aditya Renukunta
  2017-12-21 17:34 ` [PATCH 12/29] scsi: aacraid: Add target setup helper function Raghava Aditya Renukunta
                   ` (18 subsequent siblings)
  29 siblings, 0 replies; 49+ messages in thread
From: Raghava Aditya Renukunta @ 2017-12-21 17:34 UTC (permalink / raw)
  To: jejb, martin.petersen, linux-scsi
  Cc: Scott.Benesh, aacraid, tom.white, Guilherme G . Piccoli

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 <RaghavaAditya.Renukunta@microsemi.com>
---
 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(-)

diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index 8fb0da7..d6b626d 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -1756,17 +1756,18 @@ static int aac_send_safw_bmic_cmd(struct aac_dev *dev,
 	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));
@@ -1777,30 +1778,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 */
@@ -1842,7 +1844,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:
@@ -1854,14 +1856,14 @@ void aac_update_hba_map(struct aac_dev *dev,
 }
 
 /**
- *	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;
@@ -1891,7 +1893,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);
@@ -2004,7 +2006,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 3a20168..d81d0aa 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 f70f112..82ddc74 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);
 
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 12/29] scsi: aacraid: Add target setup helper function
  2017-12-21 17:33 [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes Raghava Aditya Renukunta
                   ` (10 preceding siblings ...)
  2017-12-21 17:34 ` [PATCH 11/29] scsi: aacraid: Refactor and rename to make mirror existing changes Raghava Aditya Renukunta
@ 2017-12-21 17:34 ` Raghava Aditya Renukunta
  2017-12-21 17:34 ` [PATCH 13/29] scsi: aacraid: Untangle targets setup from report phy luns Raghava Aditya Renukunta
                   ` (17 subsequent siblings)
  29 siblings, 0 replies; 49+ messages in thread
From: Raghava Aditya Renukunta @ 2017-12-21 17:34 UTC (permalink / raw)
  To: jejb, martin.petersen, linux-scsi
  Cc: Scott.Benesh, aacraid, tom.white, Guilherme G . Piccoli

Add helper function to setup targets devices and create the base for the
upcoming patches

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
---
 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(-)

diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index d6b626d..90377b1 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -1863,7 +1863,7 @@ static void aac_set_safw_attr_all_targets(struct aac_dev *dev,
  *	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;
@@ -1901,6 +1901,16 @@ int aac_get_safw_ciss_luns(struct aac_dev *dev, int rescan)
 	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;
@@ -2004,10 +2014,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 d81d0aa..5690767 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 82ddc74..f3077b3 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);
 
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 13/29] scsi: aacraid: Untangle targets setup from report phy luns
  2017-12-21 17:33 [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes Raghava Aditya Renukunta
                   ` (11 preceding siblings ...)
  2017-12-21 17:34 ` [PATCH 12/29] scsi: aacraid: Add target setup helper function Raghava Aditya Renukunta
@ 2017-12-21 17:34 ` Raghava Aditya Renukunta
  2017-12-21 17:34 ` [PATCH 14/29] scsi: aacraid: Move function around to match existing code Raghava Aditya Renukunta
                   ` (16 subsequent siblings)
  29 siblings, 0 replies; 49+ messages in thread
From: Raghava Aditya Renukunta @ 2017-12-21 17:34 UTC (permalink / raw)
  To: jejb, martin.petersen, linux-scsi
  Cc: Scott.Benesh, aacraid, tom.white, Guilherme G . Piccoli

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 <RaghavaAditya.Renukunta@microsemi.com>
---
 drivers/scsi/aacraid/aachba.c  | 44 +++++++++++++++++++++++++++++++-----------
 drivers/scsi/aacraid/aacraid.h |  1 +
 2 files changed, 34 insertions(+), 11 deletions(-)

diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index 90377b1..cf02910 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -1802,14 +1802,16 @@ static int aac_issue_safw_bmic_identify(struct aac_dev *dev,
  *
  *	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)
@@ -1855,6 +1857,12 @@ static void aac_set_safw_attr_all_targets(struct aac_dev *dev,
 	}
 }
 
+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
@@ -1875,7 +1883,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));
 
@@ -1888,22 +1896,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 5690767..19af4d9 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;
 };
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 14/29] scsi: aacraid: Move function around to match existing code
  2017-12-21 17:33 [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes Raghava Aditya Renukunta
                   ` (12 preceding siblings ...)
  2017-12-21 17:34 ` [PATCH 13/29] scsi: aacraid: Untangle targets setup from report phy luns Raghava Aditya Renukunta
@ 2017-12-21 17:34 ` Raghava Aditya Renukunta
  2017-12-21 18:39   ` Bart Van Assche
  2017-12-21 17:34 ` [PATCH 15/29] scsi: aacraid: Create helper functions to get lun info Raghava Aditya Renukunta
                   ` (15 subsequent siblings)
  29 siblings, 1 reply; 49+ messages in thread
From: Raghava Aditya Renukunta @ 2017-12-21 17:34 UTC (permalink / raw)
  To: jejb, martin.petersen, linux-scsi
  Cc: Scott.Benesh, aacraid, tom.white, Guilherme G . Piccoli

Move the function to get phy luns information to the top of function
to set target information

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
---
 drivers/scsi/aacraid/aachba.c | 112 +++++++++++++++++++++---------------------
 1 file changed, 56 insertions(+), 56 deletions(-)

diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index cf02910..affa2f1 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -1794,6 +1794,62 @@ static int aac_issue_safw_bmic_identify(struct aac_dev *dev,
 	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
@@ -1857,62 +1913,6 @@ static void aac_set_safw_attr_all_targets(struct aac_dev *dev, int rescan)
 	}
 }
 
-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;
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 15/29] scsi: aacraid: Create helper functions to get lun info
  2017-12-21 17:33 [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes Raghava Aditya Renukunta
                   ` (13 preceding siblings ...)
  2017-12-21 17:34 ` [PATCH 14/29] scsi: aacraid: Move function around to match existing code Raghava Aditya Renukunta
@ 2017-12-21 17:34 ` Raghava Aditya Renukunta
  2017-12-21 18:40   ` Bart Van Assche
  2017-12-21 17:34 ` [PATCH 16/29] scsi: aacraid: Save bmic phy information for each phy Raghava Aditya Renukunta
                   ` (14 subsequent siblings)
  29 siblings, 1 reply; 49+ messages in thread
From: Raghava Aditya Renukunta @ 2017-12-21 17:34 UTC (permalink / raw)
  To: jejb, martin.petersen, linux-scsi
  Cc: Scott.Benesh, aacraid, tom.white, Guilherme G . Piccoli

Created inline function to retrieve lun info for each device from the
phy luns structure.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
---
 drivers/scsi/aacraid/aachba.c | 59 ++++++++++++++++++++++++++++++++++---------
 1 file changed, 47 insertions(+), 12 deletions(-)

diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index affa2f1..83d2576 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -1847,7 +1847,48 @@ static int aac_get_safw_ciss_luns(struct aac_dev *dev, int rescan)
 mem_free_all:
 	kfree(phys_luns);
 	goto out;
+}
+
+static inline u32 aac_get_safw_phys_lun_count(struct aac_dev *dev)
+{
+	struct aac_ciss_phys_luns_resp *phys_luns;
+
+	phys_luns = dev->safw_phys_luns;
+
+	return ((phys_luns->list_length[0]<<24) +
+			(phys_luns->list_length[1]<<16) +
+			(phys_luns->list_length[2]<<8) +
+			(phys_luns->list_length[3])) / 24;
+}
 
+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];
 }
 
 /**
@@ -1865,22 +1906,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;
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 16/29] scsi: aacraid: Save bmic phy information for each phy
  2017-12-21 17:33 [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes Raghava Aditya Renukunta
                   ` (14 preceding siblings ...)
  2017-12-21 17:34 ` [PATCH 15/29] scsi: aacraid: Create helper functions to get lun info Raghava Aditya Renukunta
@ 2017-12-21 17:34 ` Raghava Aditya Renukunta
  2017-12-21 17:34 ` [PATCH 17/29] scsi: aacraid: Add helper function to set queue depth Raghava Aditya Renukunta
                   ` (13 subsequent siblings)
  29 siblings, 0 replies; 49+ messages in thread
From: Raghava Aditya Renukunta @ 2017-12-21 17:34 UTC (permalink / raw)
  To: jejb, martin.petersen, linux-scsi
  Cc: Scott.Benesh, aacraid, tom.white, Guilherme G . Piccoli

Save the bmic information for each phy, so that it can processed in
target setup function.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
---
 drivers/scsi/aacraid/aachba.c  | 87 +++++++++++++++++++++++++++++++++++++++---
 drivers/scsi/aacraid/aacraid.h |  1 +
 2 files changed, 82 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index 83d2576..a29c8fb 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -1757,7 +1757,7 @@ static int aac_send_safw_bmic_cmd(struct aac_dev *dev,
 }
 
 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;
@@ -1780,7 +1780,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)
@@ -1789,9 +1789,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)
@@ -1891,6 +1895,74 @@ 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_phys_luns_resp *phys_luns;
+	struct aac_ciss_identify_pd *identify_resp = NULL;
+
+	phys_luns = dev->safw_phys_luns;
+
+	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
@@ -1937,9 +2009,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;
@@ -1956,8 +2025,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 19af4d9..b1a6045 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;
 };
 
 /*
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 17/29] scsi: aacraid: Add helper function to set queue depth
  2017-12-21 17:33 [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes Raghava Aditya Renukunta
                   ` (15 preceding siblings ...)
  2017-12-21 17:34 ` [PATCH 16/29] scsi: aacraid: Save bmic phy information for each phy Raghava Aditya Renukunta
@ 2017-12-21 17:34 ` Raghava Aditya Renukunta
  2017-12-21 17:34 ` [PATCH 18/29] scsi: aacraid: Merge func to get container information Raghava Aditya Renukunta
                   ` (12 subsequent siblings)
  29 siblings, 0 replies; 49+ messages in thread
From: Raghava Aditya Renukunta @ 2017-12-21 17:34 UTC (permalink / raw)
  To: jejb, martin.petersen, linux-scsi
  Cc: Scott.Benesh, aacraid, tom.white, Guilherme G . Piccoli

Add helper function to set queue depth from information retrieved from
the bmic phy structure.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
---
 drivers/scsi/aacraid/aachba.c | 37 ++++++++++++++++++++++++-------------
 1 file changed, 24 insertions(+), 13 deletions(-)

diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index a29c8fb..01cb825 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -1756,6 +1756,28 @@ static int aac_send_safw_bmic_cmd(struct aac_dev *dev,
 	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)
 {
@@ -1782,13 +1804,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:
@@ -1947,17 +1962,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;
@@ -2006,8 +2018,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)
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 18/29] scsi: aacraid: Merge func to get container information
  2017-12-21 17:33 [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes Raghava Aditya Renukunta
                   ` (16 preceding siblings ...)
  2017-12-21 17:34 ` [PATCH 17/29] scsi: aacraid: Add helper function to set queue depth Raghava Aditya Renukunta
@ 2017-12-21 17:34 ` Raghava Aditya Renukunta
  2017-12-21 17:34 ` [PATCH 19/29] scsi: aacraid: Process hba and container hot plug events in single function Raghava Aditya Renukunta
                   ` (11 subsequent siblings)
  29 siblings, 0 replies; 49+ messages in thread
From: Raghava Aditya Renukunta @ 2017-12-21 17:34 UTC (permalink / raw)
  To: jejb, martin.petersen, linux-scsi
  Cc: Scott.Benesh, aacraid, tom.white, Guilherme G . Piccoli

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 <RaghavaAditya.Renukunta@microsemi.com>
---
 drivers/scsi/aacraid/aachba.c  |  4 ++++
 drivers/scsi/aacraid/commsup.c | 34 +++++++++++++++-------------------
 2 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index 01cb825..7f6036c 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -2032,6 +2032,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 f3077b3..9625eb0 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;
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 19/29] scsi: aacraid: Process hba and container hot plug events in single function
  2017-12-21 17:33 [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes Raghava Aditya Renukunta
                   ` (17 preceding siblings ...)
  2017-12-21 17:34 ` [PATCH 18/29] scsi: aacraid: Merge func to get container information Raghava Aditya Renukunta
@ 2017-12-21 17:34 ` Raghava Aditya Renukunta
  2017-12-21 17:34 ` [PATCH 20/29] scsi: aacraid: Added macros to help loop through known buses and targets Raghava Aditya Renukunta
                   ` (10 subsequent siblings)
  29 siblings, 0 replies; 49+ messages in thread
From: Raghava Aditya Renukunta @ 2017-12-21 17:34 UTC (permalink / raw)
  To: jejb, martin.petersen, linux-scsi
  Cc: Scott.Benesh, aacraid, tom.white, Guilherme G . Piccoli

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 <RaghavaAditya.Renukunta@microsemi.com>
---
 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(-)

diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index 7f6036c..74f1dd2 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -1993,6 +1993,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);
@@ -2018,13 +2020,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 b1a6045..17c6cdd 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 9625eb0..ed79159 100644
--- a/drivers/scsi/aacraid/commsup.c
+++ b/drivers/scsi/aacraid/commsup.c
@@ -1869,13 +1869,29 @@ int aac_check_health(struct aac_dev * aac)
 	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:
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 20/29] scsi: aacraid: Added macros to help loop through known buses and targets
  2017-12-21 17:33 [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes Raghava Aditya Renukunta
                   ` (18 preceding siblings ...)
  2017-12-21 17:34 ` [PATCH 19/29] scsi: aacraid: Process hba and container hot plug events in single function Raghava Aditya Renukunta
@ 2017-12-21 17:34 ` Raghava Aditya Renukunta
  2017-12-21 17:34 ` [PATCH 21/29] scsi: aacraid: Refactor resolve luns code and scsi functions Raghava Aditya Renukunta
                   ` (9 subsequent siblings)
  29 siblings, 0 replies; 49+ messages in thread
From: Raghava Aditya Renukunta @ 2017-12-21 17:34 UTC (permalink / raw)
  To: jejb, martin.petersen, linux-scsi
  Cc: Scott.Benesh, aacraid, tom.white, Guilherme G . Piccoli

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 <RaghavaAditya.Renukunta@microsemi.com>
---
 drivers/scsi/aacraid/aacraid.h |  4 ++++
 drivers/scsi/aacraid/commsup.c | 34 +++++++++++++++++-----------------
 2 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h
index 17c6cdd..a8fe1e1 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 ed79159..8966371 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);
 	}
 }
 
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 21/29] scsi: aacraid: Refactor resolve luns code and scsi functions
  2017-12-21 17:33 [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes Raghava Aditya Renukunta
                   ` (19 preceding siblings ...)
  2017-12-21 17:34 ` [PATCH 20/29] scsi: aacraid: Added macros to help loop through known buses and targets Raghava Aditya Renukunta
@ 2017-12-21 17:34 ` Raghava Aditya Renukunta
  2017-12-21 18:42   ` Bart Van Assche
  2017-12-21 17:34 ` [PATCH 22/29] scsi: aacraid: Merge adapter setup with resolve luns Raghava Aditya Renukunta
                   ` (8 subsequent siblings)
  29 siblings, 1 reply; 49+ messages in thread
From: Raghava Aditya Renukunta @ 2017-12-21 17:34 UTC (permalink / raw)
  To: jejb, martin.petersen, linux-scsi
  Cc: Scott.Benesh, aacraid, tom.white, Guilherme G . Piccoli

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 <RaghavaAditya.Renukunta@microsemi.com>
---
 drivers/scsi/aacraid/commsup.c | 75 ++++++++++++++++++++++++++++++++----------
 1 file changed, 58 insertions(+), 17 deletions(-)

diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c
index 8966371..2cd880f 100644
--- a/drivers/scsi/aacraid/commsup.c
+++ b/drivers/scsi/aacraid/commsup.c
@@ -1874,6 +1874,43 @@ 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 = CONTAINER_CHANNEL;
+	else
+		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 = CONTAINER_CHANNEL;
+	else
+		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 +1925,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);
 	}
 }
 
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 22/29] scsi: aacraid: Merge adapter setup with resolve luns
  2017-12-21 17:33 [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes Raghava Aditya Renukunta
                   ` (20 preceding siblings ...)
  2017-12-21 17:34 ` [PATCH 21/29] scsi: aacraid: Refactor resolve luns code and scsi functions Raghava Aditya Renukunta
@ 2017-12-21 17:34 ` Raghava Aditya Renukunta
  2017-12-21 17:34 ` [PATCH 23/29] scsi: aacraid: Block concurrent hotplug event handling Raghava Aditya Renukunta
                   ` (7 subsequent siblings)
  29 siblings, 0 replies; 49+ messages in thread
From: Raghava Aditya Renukunta @ 2017-12-21 17:34 UTC (permalink / raw)
  To: jejb, martin.petersen, linux-scsi
  Cc: Scott.Benesh, aacraid, tom.white, Guilherme G . Piccoli

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 <RaghavaAditya.Renukunta@microsemi.com>
---
 drivers/scsi/aacraid/commsup.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c
index 2cd880f..f781076 100644
--- a/drivers/scsi/aacraid/commsup.c
+++ b/drivers/scsi/aacraid/commsup.c
@@ -1938,11 +1938,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++) {
 
@@ -1957,6 +1964,8 @@ static void aac_resolve_luns(struct aac_dev *dev)
 								is_exposed)
 			aac_remove_safw_device(dev, bus, target);
 	}
+out:
+	return rcode;
 }
 
 /**
@@ -1992,9 +2001,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:
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 23/29] scsi: aacraid: Block concurrent hotplug event handling
  2017-12-21 17:33 [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes Raghava Aditya Renukunta
                   ` (21 preceding siblings ...)
  2017-12-21 17:34 ` [PATCH 22/29] scsi: aacraid: Merge adapter setup with resolve luns Raghava Aditya Renukunta
@ 2017-12-21 17:34 ` Raghava Aditya Renukunta
  2017-12-21 17:34 ` [PATCH 24/29] scsi: aacraid: Use hotplug handling function in place of scsi_scan_host Raghava Aditya Renukunta
                   ` (6 subsequent siblings)
  29 siblings, 0 replies; 49+ messages in thread
From: Raghava Aditya Renukunta @ 2017-12-21 17:34 UTC (permalink / raw)
  To: jejb, martin.petersen, linux-scsi
  Cc: Scott.Benesh, aacraid, tom.white, Guilherme G . Piccoli

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 <RaghavaAditya.Renukunta@microsemi.com>
---
 drivers/scsi/aacraid/aacraid.h | 1 +
 drivers/scsi/aacraid/commsup.c | 2 ++
 drivers/scsi/aacraid/linit.c   | 1 +
 3 files changed, 4 insertions(+)

diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h
index a8fe1e1..c70c998 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 f781076..698c049 100644
--- a/drivers/scsi/aacraid/commsup.c
+++ b/drivers/scsi/aacraid/commsup.c
@@ -2001,7 +2001,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 b2273e3..2c862cd 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.
 	 */
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 24/29] scsi: aacraid: Use hotplug handling function in place of scsi_scan_host
  2017-12-21 17:33 [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes Raghava Aditya Renukunta
                   ` (22 preceding siblings ...)
  2017-12-21 17:34 ` [PATCH 23/29] scsi: aacraid: Block concurrent hotplug event handling Raghava Aditya Renukunta
@ 2017-12-21 17:34 ` Raghava Aditya Renukunta
  2017-12-21 17:34 ` [PATCH 25/29] scsi: aacraid: Reschedule host scan in case of failure Raghava Aditya Renukunta
                   ` (5 subsequent siblings)
  29 siblings, 0 replies; 49+ messages in thread
From: Raghava Aditya Renukunta @ 2017-12-21 17:34 UTC (permalink / raw)
  To: jejb, martin.petersen, linux-scsi
  Cc: Scott.Benesh, aacraid, tom.white, Guilherme G . Piccoli

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 <RaghavaAditya.Renukunta@microsemi.com>
---
 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(-)

diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index 74f1dd2..eef7322 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -2161,10 +2161,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 c70c998..ba84d99 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 698c049..46ee7ba 100644
--- a/drivers/scsi/aacraid/commsup.c
+++ b/drivers/scsi/aacraid/commsup.c
@@ -1968,6 +1968,19 @@ static int aac_update_safw_host_devices(struct aac_dev *dev, int rescan)
 	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
@@ -2001,9 +2014,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 2c862cd..7ea7b2c 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");
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 25/29] scsi: aacraid: Reschedule host scan in case of failure
  2017-12-21 17:33 [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes Raghava Aditya Renukunta
                   ` (23 preceding siblings ...)
  2017-12-21 17:34 ` [PATCH 24/29] scsi: aacraid: Use hotplug handling function in place of scsi_scan_host Raghava Aditya Renukunta
@ 2017-12-21 17:34 ` Raghava Aditya Renukunta
  2017-12-21 18:44   ` Bart Van Assche
  2017-12-21 17:34 ` [PATCH 26/29] scsi: aacraid: Fix hang while scanning in eh recovery Raghava Aditya Renukunta
                   ` (4 subsequent siblings)
  29 siblings, 1 reply; 49+ messages in thread
From: Raghava Aditya Renukunta @ 2017-12-21 17:34 UTC (permalink / raw)
  To: jejb, martin.petersen, linux-scsi
  Cc: Scott.Benesh, aacraid, tom.white, Guilherme G . Piccoli

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 <RaghavaAditya.Renukunta@microsemi.com>
---
 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(-)

diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h
index ba84d99..70e03ed 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_worker;
 	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_worker, 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_worker);
+
+	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_worker);
+}
+
 /* 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 46ee7ba..48b5234 100644
--- a/drivers/scsi/aacraid/commsup.c
+++ b/drivers/scsi/aacraid/commsup.c
@@ -1968,16 +1968,28 @@ static int aac_update_safw_host_devices(struct aac_dev *dev, int rescan)
 	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 7ea7b2c..d39dc5e 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_worker, 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);
 
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 26/29] scsi: aacraid: Fix hang while scanning in eh recovery
  2017-12-21 17:33 [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes Raghava Aditya Renukunta
                   ` (24 preceding siblings ...)
  2017-12-21 17:34 ` [PATCH 25/29] scsi: aacraid: Reschedule host scan in case of failure Raghava Aditya Renukunta
@ 2017-12-21 17:34 ` Raghava Aditya Renukunta
  2017-12-21 17:34 ` [PATCH 27/29] scsi: aacraid: Skip schedule rescan in case of kdump Raghava Aditya Renukunta
                   ` (3 subsequent siblings)
  29 siblings, 0 replies; 49+ messages in thread
From: Raghava Aditya Renukunta @ 2017-12-21 17:34 UTC (permalink / raw)
  To: jejb, martin.petersen, linux-scsi
  Cc: Scott.Benesh, aacraid, tom.white, Guilherme G . Piccoli

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 <RaghavaAditya.Renukunta@microsemi.com>
---
 drivers/scsi/aacraid/aacraid.h | 4 ++++
 drivers/scsi/aacraid/commsup.c | 9 +++++++++
 2 files changed, 13 insertions(+)

diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h
index 70e03ed..9b678f7 100644
--- a/drivers/scsi/aacraid/aacraid.h
+++ b/drivers/scsi/aacraid/aacraid.h
@@ -41,6 +41,7 @@
 
 #include <linux/interrupt.h>
 #include <linux/pci.h>
+#include <scsi/scsi_host.h>
 
 /*------------------------------------------------------------------------------
  *              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_worker);
 
+	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 48b5234..adebf2e 100644
--- a/drivers/scsi/aacraid/commsup.c
+++ b/drivers/scsi/aacraid/commsup.c
@@ -1671,6 +1671,15 @@ static int _aac_reset_adapter(struct aac_dev *aac, int forced, u8 reset_type)
 	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);
 	}
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 27/29] scsi: aacraid: Skip schedule rescan in case of kdump
  2017-12-21 17:33 [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes Raghava Aditya Renukunta
                   ` (25 preceding siblings ...)
  2017-12-21 17:34 ` [PATCH 26/29] scsi: aacraid: Fix hang while scanning in eh recovery Raghava Aditya Renukunta
@ 2017-12-21 17:34 ` Raghava Aditya Renukunta
  2017-12-21 17:34 ` [PATCH 28/29] scsi: aacraid: Remove unused rescan variable Raghava Aditya Renukunta
                   ` (2 subsequent siblings)
  29 siblings, 0 replies; 49+ messages in thread
From: Raghava Aditya Renukunta @ 2017-12-21 17:34 UTC (permalink / raw)
  To: jejb, martin.petersen, linux-scsi
  Cc: Scott.Benesh, aacraid, tom.white, Guilherme G . Piccoli

There is a chance of the driver being 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 <RaghavaAditya.Renukunta@microsemi.com>
---
 drivers/scsi/aacraid/commsup.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c
index adebf2e..6f5dfc9 100644
--- a/drivers/scsi/aacraid/commsup.c
+++ b/drivers/scsi/aacraid/commsup.c
@@ -33,6 +33,7 @@
 
 #include <linux/kernel.h>
 #include <linux/init.h>
+#include <linux/crash_dump.h>
 #include <linux/types.h>
 #include <linux/sched.h>
 #include <linux/pci.h>
@@ -1675,7 +1676,7 @@ static int _aac_reset_adapter(struct aac_dev *aac, int forced, u8 reset_type)
 	 * 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);
 	}
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 28/29] scsi: aacraid: Remove unused rescan variable
  2017-12-21 17:33 [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes Raghava Aditya Renukunta
                   ` (26 preceding siblings ...)
  2017-12-21 17:34 ` [PATCH 27/29] scsi: aacraid: Skip schedule rescan in case of kdump Raghava Aditya Renukunta
@ 2017-12-21 17:34 ` Raghava Aditya Renukunta
  2017-12-21 17:34 ` [PATCH 29/29] scsi: aacraid: Remove AAC_HIDE_DISK check in queue command Raghava Aditya Renukunta
  2017-12-22 15:06 ` [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes Guilherme G. Piccoli
  29 siblings, 0 replies; 49+ messages in thread
From: Raghava Aditya Renukunta @ 2017-12-21 17:34 UTC (permalink / raw)
  To: jejb, martin.petersen, linux-scsi
  Cc: Scott.Benesh, aacraid, tom.white, Guilherme G . Piccoli

Remove unused rescan variable.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
---
 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(-)

diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index eef7322..aabbefd 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -1822,12 +1822,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;
@@ -1940,7 +1939,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;
@@ -1983,7 +1982,7 @@ static int aac_get_safw_attr_all_targets(struct aac_dev *dev, int rescan)
  *
  *	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;
@@ -2029,7 +2028,7 @@ static void aac_set_safw_attr_all_targets(struct aac_dev *dev, int rescan)
 	}
 }
 
-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;
 
@@ -2037,15 +2036,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:
@@ -2054,9 +2053,9 @@ static int aac_setup_safw_targets(struct aac_dev *dev, int rescan)
 	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 9b678f7..9804d3c 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 6f5dfc9..019558f 100644
--- a/drivers/scsi/aacraid/commsup.c
+++ b/drivers/scsi/aacraid/commsup.c
@@ -1948,7 +1948,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;
@@ -1956,7 +1956,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;
 	}
@@ -1978,24 +1978,24 @@ static int aac_update_safw_host_devices(struct aac_dev *dev, int rescan)
 	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);
@@ -2036,7 +2036,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 d39dc5e..8aa818b 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");
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 29/29] scsi: aacraid: Remove AAC_HIDE_DISK check in queue command
  2017-12-21 17:33 [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes Raghava Aditya Renukunta
                   ` (27 preceding siblings ...)
  2017-12-21 17:34 ` [PATCH 28/29] scsi: aacraid: Remove unused rescan variable Raghava Aditya Renukunta
@ 2017-12-21 17:34 ` Raghava Aditya Renukunta
  2017-12-22 15:06 ` [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes Guilherme G. Piccoli
  29 siblings, 0 replies; 49+ messages in thread
From: Raghava Aditya Renukunta @ 2017-12-21 17:34 UTC (permalink / raw)
  To: jejb, martin.petersen, linux-scsi
  Cc: Scott.Benesh, aacraid, tom.white, Guilherme G . Piccoli

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 <RaghavaAditya.Renukunta@microsemi.com>
---
 drivers/scsi/aacraid/aachba.c  | 10 ----------
 drivers/scsi/aacraid/aacraid.h |  3 ---
 2 files changed, 13 deletions(-)

diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index aabbefd..43f9813 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -2005,8 +2005,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;
@@ -2924,14 +2922,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 9804d3c..ff1f55f 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;
 };
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* Re: [PATCH 01/29] scsi: aacraid: Fix udev inquiry race condition
  2017-12-21 17:33 ` [PATCH 01/29] scsi: aacraid: Fix udev inquiry race condition Raghava Aditya Renukunta
@ 2017-12-21 17:54   ` Bart Van Assche
  2017-12-27  1:22     ` Raghava Aditya Renukunta
  0 siblings, 1 reply; 49+ messages in thread
From: Bart Van Assche @ 2017-12-21 17:54 UTC (permalink / raw)
  To: jejb, RaghavaAditya.Renukunta, linux-scsi, martin.petersen
  Cc: aacraid, gpiccoli, tom.white, Scott.Benesh

On Thu, 2017-12-21 at 09:33 -0800, Raghava Aditya Renukunta wrote:
> +		char *cp;
> +		char *cname = kmalloc(sizeof(sup_adap_info->adapter_type_text),
> +								GFP_ATOMIC);

Why did you choose to use GFP_ATOMIC instead of GFP_KERNEL in the above
kmalloc() call?

> +
> +		if (!cname)
> +			return;
> +
> +		cp = cname;
> +		memcpy(cname, sup_adap_info->adapter_type_text,
> +			sizeof(sup_adap_info->adapter_type_text));

Is the sup_adap_info->adapter_type_text a string that is \0-terminated? If so,
have you considered to use kmemdup() instead of kmalloc() + memcpy()?

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 08/29] scsi: aacraid: Move code to wait for IO completion to shutdown func
  2017-12-21 17:33 ` [PATCH 08/29] scsi: aacraid: Move code to wait for IO completion to shutdown func Raghava Aditya Renukunta
@ 2017-12-21 17:59   ` Bart Van Assche
  2017-12-22 16:26     ` Bart Van Assche
  0 siblings, 1 reply; 49+ messages in thread
From: Bart Van Assche @ 2017-12-21 17:59 UTC (permalink / raw)
  To: jejb, RaghavaAditya.Renukunta, linux-scsi, martin.petersen
  Cc: aacraid, gpiccoli, tom.white, Scott.Benesh

On Thu, 2017-12-21 at 09:33 -0800, Raghava Aditya Renukunta wrote:
> +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);
> +	}
> +}

Have you considered to call scsi_target_block() and scsi_target_unblock() instead
of implementing functionality like the above in a SCSI LLD?

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 14/29] scsi: aacraid: Move function around to match existing code
  2017-12-21 17:34 ` [PATCH 14/29] scsi: aacraid: Move function around to match existing code Raghava Aditya Renukunta
@ 2017-12-21 18:39   ` Bart Van Assche
  2017-12-27  1:23     ` Raghava Aditya Renukunta
  0 siblings, 1 reply; 49+ messages in thread
From: Bart Van Assche @ 2017-12-21 18:39 UTC (permalink / raw)
  To: jejb, RaghavaAditya.Renukunta, linux-scsi, martin.petersen
  Cc: aacraid, gpiccoli, tom.white, Scott.Benesh

On Thu, 2017-12-21 at 09:34 -0800, Raghava Aditya Renukunta wrote:
> +/**
> + *	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.
> + */

The above function header is not following the kernel-doc syntax: a colon is
missing. Have you tried to build your driver with W=1? That should be sufficient
with kernel version v4.15-rc1 or later to report kernel-doc header issues.

Bart.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 15/29] scsi: aacraid: Create helper functions to get lun info
  2017-12-21 17:34 ` [PATCH 15/29] scsi: aacraid: Create helper functions to get lun info Raghava Aditya Renukunta
@ 2017-12-21 18:40   ` Bart Van Assche
  2017-12-27  1:24     ` Raghava Aditya Renukunta
  0 siblings, 1 reply; 49+ messages in thread
From: Bart Van Assche @ 2017-12-21 18:40 UTC (permalink / raw)
  To: jejb, RaghavaAditya.Renukunta, linux-scsi, martin.petersen
  Cc: aacraid, gpiccoli, tom.white, Scott.Benesh

On Thu, 2017-12-21 at 09:34 -0800, Raghava Aditya Renukunta wrote:
> +	return ((phys_luns->list_length[0]<<24) +
> +			(phys_luns->list_length[1]<<16) +
> +			(phys_luns->list_length[2]<<8) +
> +			(phys_luns->list_length[3])) / 24;

Please use get_unaligned_be32() instead of open-coding it.

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 21/29] scsi: aacraid: Refactor resolve luns code and scsi functions
  2017-12-21 17:34 ` [PATCH 21/29] scsi: aacraid: Refactor resolve luns code and scsi functions Raghava Aditya Renukunta
@ 2017-12-21 18:42   ` Bart Van Assche
  2017-12-27  1:25     ` Raghava Aditya Renukunta
  0 siblings, 1 reply; 49+ messages in thread
From: Bart Van Assche @ 2017-12-21 18:42 UTC (permalink / raw)
  To: jejb, RaghavaAditya.Renukunta, linux-scsi, martin.petersen
  Cc: aacraid, gpiccoli, tom.white, Scott.Benesh

On Thu, 2017-12-21 at 09:34 -0800, Raghava Aditya Renukunta wrote:
> +	if (bus == CONTAINER_CHANNEL)
> +		bus = CONTAINER_CHANNEL;

Sorry but I don't see how the above code can be useful?

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 25/29] scsi: aacraid: Reschedule host scan in case of failure
  2017-12-21 17:34 ` [PATCH 25/29] scsi: aacraid: Reschedule host scan in case of failure Raghava Aditya Renukunta
@ 2017-12-21 18:44   ` Bart Van Assche
  2017-12-27  1:25     ` Raghava Aditya Renukunta
  0 siblings, 1 reply; 49+ messages in thread
From: Bart Van Assche @ 2017-12-21 18:44 UTC (permalink / raw)
  To: jejb, RaghavaAditya.Renukunta, linux-scsi, martin.petersen
  Cc: aacraid, gpiccoli, tom.white, Scott.Benesh

On Thu, 2017-12-21 at 09:34 -0800, Raghava Aditya Renukunta wrote:
> +	struct delayed_work	safw_rescan_worker;

Please make the name of this member variable consistent with other kernel code. That
means either using e.g. the name "safw_rescan_work" or "safw_rescan".

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 03/29] scsi: aacraid: Fix hang in kdump
  2017-12-21 17:33 ` [PATCH 03/29] scsi: aacraid: Fix hang in kdump Raghava Aditya Renukunta
@ 2017-12-21 19:15   ` Guilherme G. Piccoli
  2017-12-22 15:13   ` Guilherme G. Piccoli
  1 sibling, 0 replies; 49+ messages in thread
From: Guilherme G. Piccoli @ 2017-12-21 19:15 UTC (permalink / raw)
  To: Raghava Aditya Renukunta, linux-scsi
  Cc: jejb, martin.petersen, Scott.Benesh, aacraid, tom.white

On 12/21/2017 03:33 PM, Raghava Aditya Renukunta wrote:
> 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: <stable@vger.kernel.org>
> Reported-by: Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>
> Tested-by: Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>
> Fixes: a2d0321dd532901e (scsi: aacraid: Reload offlined drives after controller reset)
> Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

Thanks a lot Raghava =)

> ---
>  drivers/scsi/aacraid/commsup.c | 9 +--------
>  1 file changed, 1 insertion(+), 8 deletions(-)
> 
> diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c
> index 525a652..ffbfd04 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);
>  	}
> 

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes
  2017-12-21 17:33 [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes Raghava Aditya Renukunta
                   ` (28 preceding siblings ...)
  2017-12-21 17:34 ` [PATCH 29/29] scsi: aacraid: Remove AAC_HIDE_DISK check in queue command Raghava Aditya Renukunta
@ 2017-12-22 15:06 ` Guilherme G. Piccoli
  2017-12-27  1:27   ` Raghava Aditya Renukunta
  29 siblings, 1 reply; 49+ messages in thread
From: Guilherme G. Piccoli @ 2017-12-22 15:06 UTC (permalink / raw)
  To: Raghava Aditya Renukunta, linux-scsi
  Cc: jejb, martin.petersen, Scott.Benesh, aacraid, tom.white

On 12/21/2017 03:33 PM, Raghava Aditya Renukunta wrote:
> This patchset primarily lays the foundation for adding sas transport
> support to the aacraid driver. Being said these patches are mainly code
> refactors, bug fixes and improvements.

I was thinking...if possible, and just in case you plan to send a V2
after Bart's comments (or any other future reviews this patchset gets),
how about splitting in 2 patchsets, one for bug fixes and the other for
improvements/foundation of sas support?

It could help to speed-up the merge of bug fixes.

Thanks,


Guilherme
> 
>  - Fixed a udev inquiry race condition
>  - Fixed a kdump hang issue which occurs in case of error recovery in kdump
>  - Made improvements to ioctl reset and reset_host sysfs reset paths
>  - Changed the code to retrieve lun information into stand alone functions.
>  - Merged container and hba hotplug event processing (device addition and
>    and removal into single function)
>  - Removed scsi_scan_host for safw devices and now explicitly add devices
>    retrieved from the fw.
>  - Reschedule scan in driver fails to retrieve lun information from fw.
>    (usually works in a few attempts)
>  - Rescan worker waits for any pending EH recovery before rescanning
>  - Do not trigger rescan worker in kdump kernel
> 
> Raghava Aditya Renukunta (29):
>   scsi: aacraid: Fix udev inquiry race condition
>   scsi: aacraid: Do not attempt abort when Fw panicked
>   scsi: aacraid: Fix hang in kdump
>   scsi: aacraid: Do not remove offlined devices
>   scsi: aacraid: Fix ioctl reset hang
>   scsi: aacraid: Allow reset_host sysfs var to recover Panicked Fw
>   scsi: aacraid: Refactor reset_host store function
>   scsi: aacraid: Move code to wait for IO completion to shutdown func
>   scsi: aacraid: Create bmic submission function from bmic identify
>   scsi: aacraid: Change phy luns function to use common bmic function
>   scsi: aacraid: Refactor and rename to make mirror existing changes
>   scsi: aacraid: Add target setup helper function
>   scsi: aacraid: Untangle targets setup from report phy luns
>   scsi: aacraid: Move function around to match existing code
>   scsi: aacraid: Create helper functions to get lun info
>   scsi: aacraid: Save bmic phy information for each phy
>   scsi: aacraid: Add helper function to set queue depth
>   scsi: aacraid: Merge func to get container information
>   scsi: aacraid: Process hba and container hot plug events in single
> 		function
>   scsi: aacraid: Added macros to help loop through known buses and targets
>   scsi: aacraid: Refactor resolve luns code and scsi functions
>   scsi: aacraid: Merge adapter setup with resolve luns
>   scsi: aacraid: Block concurrent hotplug event handling
>   scsi: aacraid: Use hotplug handling function in place of scsi_scan_host
>   scsi: aacraid: Reschedule host scan in case of failure
>   scsi: aacraid: Fix hang while scanning in eh recovery
>   scsi: aacraid: Skip schedule rescan in case of kdump
>   scsi: aacraid: Remove unused rescan variable
>   scsi: aacraid: Remove AAC_HIDE_DISK check in queue command
> 
>  drivers/scsi/aacraid/aachba.c   | 479 +++++++++++++++++++++++++++-------------
>  drivers/scsi/aacraid/aacraid.h  |  52 ++++-
>  drivers/scsi/aacraid/commctrl.c |   6 +-
>  drivers/scsi/aacraid/comminit.c |  49 +++-
>  drivers/scsi/aacraid/commsup.c  | 224 ++++++++++---------
>  drivers/scsi/aacraid/linit.c    |  23 +-
>  6 files changed, 561 insertions(+), 272 deletions(-)
> 

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 03/29] scsi: aacraid: Fix hang in kdump
  2017-12-21 17:33 ` [PATCH 03/29] scsi: aacraid: Fix hang in kdump Raghava Aditya Renukunta
  2017-12-21 19:15   ` Guilherme G. Piccoli
@ 2017-12-22 15:13   ` Guilherme G. Piccoli
  2017-12-27  1:28     ` Raghava Aditya Renukunta
  1 sibling, 1 reply; 49+ messages in thread
From: Guilherme G. Piccoli @ 2017-12-22 15:13 UTC (permalink / raw)
  To: Raghava Aditya Renukunta, jejb, martin.petersen, linux-scsi
  Cc: Scott.Benesh, aacraid, tom.white, dougmill

On 12/21/2017 03:33 PM, Raghava Aditya Renukunta wrote:
> 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: <stable@vger.kernel.org>
> Reported-by: Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>

(Sorry in advance for flooding the thread heheh)
I guess it'd be more appropriate to:

Reported-by: Douglas Miller <dougmill@linux.vnet.ibm.com>

Although I've tested it, Doug isolated the race condition based on code
analysis...

Thanks,


Guilherme

> Tested-by: Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>
> Fixes: a2d0321dd532901e (scsi: aacraid: Reload offlined drives after controller reset)
> Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
> ---
>  drivers/scsi/aacraid/commsup.c | 9 +--------
>  1 file changed, 1 insertion(+), 8 deletions(-)
> 
> diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c
> index 525a652..ffbfd04 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);
>  	}
> 

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 08/29] scsi: aacraid: Move code to wait for IO completion to shutdown func
  2017-12-21 17:59   ` Bart Van Assche
@ 2017-12-22 16:26     ` Bart Van Assche
  2017-12-27  1:38       ` Raghava Aditya Renukunta
  0 siblings, 1 reply; 49+ messages in thread
From: Bart Van Assche @ 2017-12-22 16:26 UTC (permalink / raw)
  To: jejb, RaghavaAditya.Renukunta, linux-scsi, martin.petersen
  Cc: aacraid, gpiccoli, tom.white, Scott.Benesh

On Thu, 2017-12-21 at 17:59 +0000, Bart Van Assche wrote:
> On Thu, 2017-12-21 at 09:33 -0800, Raghava Aditya Renukunta wrote:
> > +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);
> > +	}
> > +}
> 
> Have you considered to call scsi_target_block() and scsi_target_unblock() instead
> of implementing functionality like the above in a SCSI LLD?

(replying to my own e-mail)

It seems like I misread your code - calling scsi_target_block() and
scsi_target_unblock() would not be sufficient. But calling blk_mq_freeze_queue()
and blk_mq_unfreeze_queue() should be sufficient. The following commit made these
functions work not only for scsi-mq but also for legacy scsi queues: commit
055f6e18e08f ("block: Make q_usage_counter also track legacy requests").

Bart.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* RE: [PATCH 01/29] scsi: aacraid: Fix udev inquiry race condition
  2017-12-21 17:54   ` Bart Van Assche
@ 2017-12-27  1:22     ` Raghava Aditya Renukunta
  0 siblings, 0 replies; 49+ messages in thread
From: Raghava Aditya Renukunta @ 2017-12-27  1:22 UTC (permalink / raw)
  To: Bart Van Assche, jejb, linux-scsi, martin.petersen
  Cc: dl-esc-Aacraid Linux Driver, gpiccoli, Tom White, Scott Benesh



> -----Original Message-----
> From: Bart Van Assche [mailto:Bart.VanAssche@wdc.com]
> Sent: Thursday, December 21, 2017 9:54 AM
> To: jejb@linux.vnet.ibm.com; Raghava Aditya Renukunta
> <RaghavaAditya.Renukunta@microsemi.com>; linux-scsi@vger.kernel.org;
> martin.petersen@oracle.com
> Cc: dl-esc-Aacraid Linux Driver <aacraid@microsemi.com>;
> gpiccoli@linux.vnet.ibm.com; Tom White <tom.white@microsemi.com>;
> Scott Benesh <scott.benesh@microsemi.com>
> Subject: Re: [PATCH 01/29] scsi: aacraid: Fix udev inquiry race condition
> 
> EXTERNAL EMAIL
> 
> 
> On Thu, 2017-12-21 at 09:33 -0800, Raghava Aditya Renukunta wrote:
> > +             char *cp;
> > +             char *cname = kmalloc(sizeof(sup_adap_info-
> >adapter_type_text),
> > +                                                             GFP_ATOMIC);
> 
> Why did you choose to use GFP_ATOMIC instead of GFP_KERNEL in the
> above
> kmalloc() call?

It was mainly because of a trace call that cut thru the kmalloc call. 
 
> > +
> > +             if (!cname)
> > +                     return;
> > +
> > +             cp = cname;
> > +             memcpy(cname, sup_adap_info->adapter_type_text,
> > +                     sizeof(sup_adap_info->adapter_type_text));
> 
> Is the sup_adap_info->adapter_type_text a string that is \0-terminated? If
> so,
> have you considered to use kmemdup() instead of kmalloc() + memcpy()?

I will take that into consideration Bart.

Thank you 
Raghava Aditya

> Thanks,
> 
> Bart.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* RE: [PATCH 14/29] scsi: aacraid: Move function around to match existing code
  2017-12-21 18:39   ` Bart Van Assche
@ 2017-12-27  1:23     ` Raghava Aditya Renukunta
  0 siblings, 0 replies; 49+ messages in thread
From: Raghava Aditya Renukunta @ 2017-12-27  1:23 UTC (permalink / raw)
  To: Bart Van Assche, jejb, linux-scsi, martin.petersen
  Cc: dl-esc-Aacraid Linux Driver, gpiccoli, Tom White, Scott Benesh



> -----Original Message-----
> From: Bart Van Assche [mailto:Bart.VanAssche@wdc.com]
> Sent: Thursday, December 21, 2017 10:40 AM
> To: jejb@linux.vnet.ibm.com; Raghava Aditya Renukunta
> <RaghavaAditya.Renukunta@microsemi.com>; linux-scsi@vger.kernel.org;
> martin.petersen@oracle.com
> Cc: dl-esc-Aacraid Linux Driver <aacraid@microsemi.com>;
> gpiccoli@linux.vnet.ibm.com; Tom White <tom.white@microsemi.com>;
> Scott Benesh <scott.benesh@microsemi.com>
> Subject: Re: [PATCH 14/29] scsi: aacraid: Move function around to match
> existing code
> 
> EXTERNAL EMAIL
> 
> 
> On Thu, 2017-12-21 at 09:34 -0800, Raghava Aditya Renukunta wrote:
> > +/**
> > + *   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.
> > + */
> 
> The above function header is not following the kernel-doc syntax: a colon is
> missing. Have you tried to build your driver with W=1? That should be
> sufficient
> with kernel version v4.15-rc1 or later to report kernel-doc header issues.
> 
> Bart.

I was not aware of that option I will fix it in the my next version.
Regards,
Raghava Aditya

^ permalink raw reply	[flat|nested] 49+ messages in thread

* RE: [PATCH 15/29] scsi: aacraid: Create helper functions to get lun info
  2017-12-21 18:40   ` Bart Van Assche
@ 2017-12-27  1:24     ` Raghava Aditya Renukunta
  0 siblings, 0 replies; 49+ messages in thread
From: Raghava Aditya Renukunta @ 2017-12-27  1:24 UTC (permalink / raw)
  To: Bart Van Assche, jejb, linux-scsi, martin.petersen
  Cc: dl-esc-Aacraid Linux Driver, gpiccoli, Tom White, Scott Benesh



> -----Original Message-----
> From: Bart Van Assche [mailto:Bart.VanAssche@wdc.com]
> Sent: Thursday, December 21, 2017 10:41 AM
> To: jejb@linux.vnet.ibm.com; Raghava Aditya Renukunta
> <RaghavaAditya.Renukunta@microsemi.com>; linux-scsi@vger.kernel.org;
> martin.petersen@oracle.com
> Cc: dl-esc-Aacraid Linux Driver <aacraid@microsemi.com>;
> gpiccoli@linux.vnet.ibm.com; Tom White <tom.white@microsemi.com>;
> Scott Benesh <scott.benesh@microsemi.com>
> Subject: Re: [PATCH 15/29] scsi: aacraid: Create helper functions to get lun
> info
> 
> EXTERNAL EMAIL
> 
> 
> On Thu, 2017-12-21 at 09:34 -0800, Raghava Aditya Renukunta wrote:
> > +     return ((phys_luns->list_length[0]<<24) +
> > +                     (phys_luns->list_length[1]<<16) +
> > +                     (phys_luns->list_length[2]<<8) +
> > +                     (phys_luns->list_length[3])) / 24;
> 
> Please use get_unaligned_be32() instead of open-coding it.

Yes Will do Bart.
Thank you
Raghava Aditya
 

> Thanks,
> 
> Bart.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* RE: [PATCH 21/29] scsi: aacraid: Refactor resolve luns code and scsi functions
  2017-12-21 18:42   ` Bart Van Assche
@ 2017-12-27  1:25     ` Raghava Aditya Renukunta
  0 siblings, 0 replies; 49+ messages in thread
From: Raghava Aditya Renukunta @ 2017-12-27  1:25 UTC (permalink / raw)
  To: Bart Van Assche, jejb, linux-scsi, martin.petersen
  Cc: dl-esc-Aacraid Linux Driver, gpiccoli, Tom White, Scott Benesh



> -----Original Message-----
> From: Bart Van Assche [mailto:Bart.VanAssche@wdc.com]
> Sent: Thursday, December 21, 2017 10:43 AM
> To: jejb@linux.vnet.ibm.com; Raghava Aditya Renukunta
> <RaghavaAditya.Renukunta@microsemi.com>; linux-scsi@vger.kernel.org;
> martin.petersen@oracle.com
> Cc: dl-esc-Aacraid Linux Driver <aacraid@microsemi.com>;
> gpiccoli@linux.vnet.ibm.com; Tom White <tom.white@microsemi.com>;
> Scott Benesh <scott.benesh@microsemi.com>
> Subject: Re: [PATCH 21/29] scsi: aacraid: Refactor resolve luns code and scsi
> functions
> 
> EXTERNAL EMAIL
> 
> 
> On Thu, 2017-12-21 at 09:34 -0800, Raghava Aditya Renukunta wrote:
> > +     if (bus == CONTAINER_CHANNEL)
> > +             bus = CONTAINER_CHANNEL;
> 
> Sorry but I don't see how the above code can be useful?

I agree, I did not want to change legacy code a bit too much. I will refactor this in the next iteration.

> Thanks,
> 
> Bart.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* RE: [PATCH 25/29] scsi: aacraid: Reschedule host scan in case of failure
  2017-12-21 18:44   ` Bart Van Assche
@ 2017-12-27  1:25     ` Raghava Aditya Renukunta
  0 siblings, 0 replies; 49+ messages in thread
From: Raghava Aditya Renukunta @ 2017-12-27  1:25 UTC (permalink / raw)
  To: Bart Van Assche, jejb, linux-scsi, martin.petersen
  Cc: dl-esc-Aacraid Linux Driver, gpiccoli, Tom White, Scott Benesh



> -----Original Message-----
> From: Bart Van Assche [mailto:Bart.VanAssche@wdc.com]
> Sent: Thursday, December 21, 2017 10:45 AM
> To: jejb@linux.vnet.ibm.com; Raghava Aditya Renukunta
> <RaghavaAditya.Renukunta@microsemi.com>; linux-scsi@vger.kernel.org;
> martin.petersen@oracle.com
> Cc: dl-esc-Aacraid Linux Driver <aacraid@microsemi.com>;
> gpiccoli@linux.vnet.ibm.com; Tom White <tom.white@microsemi.com>;
> Scott Benesh <scott.benesh@microsemi.com>
> Subject: Re: [PATCH 25/29] scsi: aacraid: Reschedule host scan in case of
> failure
> 
> EXTERNAL EMAIL
> 
> 
> On Thu, 2017-12-21 at 09:34 -0800, Raghava Aditya Renukunta wrote:
> > +     struct delayed_work     safw_rescan_worker;
> 
> Please make the name of this member variable consistent with other kernel
> code. That
> means either using e.g. the name "safw_rescan_work" or "safw_rescan".

Yes, Will Do,

Regards,
Raghava Aditya

> Thanks,
> 
> Bart.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* RE: [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes
  2017-12-22 15:06 ` [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes Guilherme G. Piccoli
@ 2017-12-27  1:27   ` Raghava Aditya Renukunta
  2017-12-27 12:24     ` Guilherme G. Piccoli
  0 siblings, 1 reply; 49+ messages in thread
From: Raghava Aditya Renukunta @ 2017-12-27  1:27 UTC (permalink / raw)
  To: Guilherme G. Piccoli, linux-scsi
  Cc: jejb, martin.petersen, Scott Benesh, dl-esc-Aacraid Linux Driver,
	Tom White



> -----Original Message-----
> From: Guilherme G. Piccoli [mailto:gpiccoli@linux.vnet.ibm.com]
> Sent: Friday, December 22, 2017 7:07 AM
> To: Raghava Aditya Renukunta
> <RaghavaAditya.Renukunta@microsemi.com>; linux-scsi@vger.kernel.org
> Cc: jejb@linux.vnet.ibm.com; martin.petersen@oracle.com; Scott Benesh
> <scott.benesh@microsemi.com>; dl-esc-Aacraid Linux Driver
> <aacraid@microsemi.com>; Tom White <tom.white@microsemi.com>
> Subject: Re: [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes
> 
> EXTERNAL EMAIL
> 
> 
> On 12/21/2017 03:33 PM, Raghava Aditya Renukunta wrote:
> > This patchset primarily lays the foundation for adding sas transport
> > support to the aacraid driver. Being said these patches are mainly code
> > refactors, bug fixes and improvements.
> 
> I was thinking...if possible, and just in case you plan to send a V2
> after Bart's comments (or any other future reviews this patchset gets),
> how about splitting in 2 patchsets, one for bug fixes and the other for
> improvements/foundation of sas support?
> 
> It could help to speed-up the merge of bug fixes.

Hi Guilherme,
It did cross my mind, but I wanted to get the sas transport and bug fixes in by 4.16. I thought
that breaking the patches into 3 patch sets might not help with it.

Regards,
Raghava Aditya

 
> Thanks,
>
> 
> Guilherme
> >
> >  - Fixed a udev inquiry race condition
> >  - Fixed a kdump hang issue which occurs in case of error recovery in kdump
> >  - Made improvements to ioctl reset and reset_host sysfs reset paths
> >  - Changed the code to retrieve lun information into stand alone functions.
> >  - Merged container and hba hotplug event processing (device addition and
> >    and removal into single function)
> >  - Removed scsi_scan_host for safw devices and now explicitly add devices
> >    retrieved from the fw.
> >  - Reschedule scan in driver fails to retrieve lun information from fw.
> >    (usually works in a few attempts)
> >  - Rescan worker waits for any pending EH recovery before rescanning
> >  - Do not trigger rescan worker in kdump kernel
> >
> > Raghava Aditya Renukunta (29):
> >   scsi: aacraid: Fix udev inquiry race condition
> >   scsi: aacraid: Do not attempt abort when Fw panicked
> >   scsi: aacraid: Fix hang in kdump
> >   scsi: aacraid: Do not remove offlined devices
> >   scsi: aacraid: Fix ioctl reset hang
> >   scsi: aacraid: Allow reset_host sysfs var to recover Panicked Fw
> >   scsi: aacraid: Refactor reset_host store function
> >   scsi: aacraid: Move code to wait for IO completion to shutdown func
> >   scsi: aacraid: Create bmic submission function from bmic identify
> >   scsi: aacraid: Change phy luns function to use common bmic function
> >   scsi: aacraid: Refactor and rename to make mirror existing changes
> >   scsi: aacraid: Add target setup helper function
> >   scsi: aacraid: Untangle targets setup from report phy luns
> >   scsi: aacraid: Move function around to match existing code
> >   scsi: aacraid: Create helper functions to get lun info
> >   scsi: aacraid: Save bmic phy information for each phy
> >   scsi: aacraid: Add helper function to set queue depth
> >   scsi: aacraid: Merge func to get container information
> >   scsi: aacraid: Process hba and container hot plug events in single
> >               function
> >   scsi: aacraid: Added macros to help loop through known buses and targets
> >   scsi: aacraid: Refactor resolve luns code and scsi functions
> >   scsi: aacraid: Merge adapter setup with resolve luns
> >   scsi: aacraid: Block concurrent hotplug event handling
> >   scsi: aacraid: Use hotplug handling function in place of scsi_scan_host
> >   scsi: aacraid: Reschedule host scan in case of failure
> >   scsi: aacraid: Fix hang while scanning in eh recovery
> >   scsi: aacraid: Skip schedule rescan in case of kdump
> >   scsi: aacraid: Remove unused rescan variable
> >   scsi: aacraid: Remove AAC_HIDE_DISK check in queue command
> >
> >  drivers/scsi/aacraid/aachba.c   | 479 +++++++++++++++++++++++++++----
> ---------
> >  drivers/scsi/aacraid/aacraid.h  |  52 ++++-
> >  drivers/scsi/aacraid/commctrl.c |   6 +-
> >  drivers/scsi/aacraid/comminit.c |  49 +++-
> >  drivers/scsi/aacraid/commsup.c  | 224 ++++++++++---------
> >  drivers/scsi/aacraid/linit.c    |  23 +-
> >  6 files changed, 561 insertions(+), 272 deletions(-)
> >


^ permalink raw reply	[flat|nested] 49+ messages in thread

* RE: [PATCH 03/29] scsi: aacraid: Fix hang in kdump
  2017-12-22 15:13   ` Guilherme G. Piccoli
@ 2017-12-27  1:28     ` Raghava Aditya Renukunta
  0 siblings, 0 replies; 49+ messages in thread
From: Raghava Aditya Renukunta @ 2017-12-27  1:28 UTC (permalink / raw)
  To: Guilherme G. Piccoli, jejb, martin.petersen, linux-scsi
  Cc: Scott Benesh, dl-esc-Aacraid Linux Driver, Tom White, dougmill



> -----Original Message-----
> From: Guilherme G. Piccoli [mailto:gpiccoli@linux.vnet.ibm.com]
> Sent: Friday, December 22, 2017 7:14 AM
> To: Raghava Aditya Renukunta
> <RaghavaAditya.Renukunta@microsemi.com>; jejb@linux.vnet.ibm.com;
> martin.petersen@oracle.com; linux-scsi@vger.kernel.org
> Cc: Scott Benesh <scott.benesh@microsemi.com>; dl-esc-Aacraid Linux
> Driver <aacraid@microsemi.com>; Tom White
> <tom.white@microsemi.com>; dougmill@linux.vnet.ibm.com
> Subject: Re: [PATCH 03/29] scsi: aacraid: Fix hang in kdump
> 
> EXTERNAL EMAIL
> 
> 
> On 12/21/2017 03:33 PM, Raghava Aditya Renukunta wrote:
> > 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: <stable@vger.kernel.org>
> > Reported-by: Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>
> 
> (Sorry in advance for flooding the thread heheh)
> I guess it'd be more appropriate to:
> 
> Reported-by: Douglas Miller <dougmill@linux.vnet.ibm.com>
> 
> Although I've tested it, Doug isolated the race condition based on code
> analysis...

Thank you pointing that out, I will fix it in the next iteration.

Regards,
Raghava Aditya

> Thanks,
> 
> 
> Guilherme
> 
> > Tested-by: Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>
> > Fixes: a2d0321dd532901e (scsi: aacraid: Reload offlined drives after
> controller reset)
> > Signed-off-by: Raghava Aditya Renukunta
> <RaghavaAditya.Renukunta@microsemi.com>
> > ---
> >  drivers/scsi/aacraid/commsup.c | 9 +--------
> >  1 file changed, 1 insertion(+), 8 deletions(-)
> >
> > diff --git a/drivers/scsi/aacraid/commsup.c
> b/drivers/scsi/aacraid/commsup.c
> > index 525a652..ffbfd04 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);
> >       }
> >


^ permalink raw reply	[flat|nested] 49+ messages in thread

* RE: [PATCH 08/29] scsi: aacraid: Move code to wait for IO completion to shutdown func
  2017-12-22 16:26     ` Bart Van Assche
@ 2017-12-27  1:38       ` Raghava Aditya Renukunta
  0 siblings, 0 replies; 49+ messages in thread
From: Raghava Aditya Renukunta @ 2017-12-27  1:38 UTC (permalink / raw)
  To: Bart Van Assche, jejb, linux-scsi, martin.petersen
  Cc: dl-esc-Aacraid Linux Driver, gpiccoli, Tom White, Scott Benesh



> -----Original Message-----
> From: Bart Van Assche [mailto:Bart.VanAssche@wdc.com]
> Sent: Friday, December 22, 2017 8:27 AM
> To: jejb@linux.vnet.ibm.com; Raghava Aditya Renukunta
> <RaghavaAditya.Renukunta@microsemi.com>; linux-scsi@vger.kernel.org;
> martin.petersen@oracle.com
> Cc: dl-esc-Aacraid Linux Driver <aacraid@microsemi.com>;
> gpiccoli@linux.vnet.ibm.com; Tom White <tom.white@microsemi.com>;
> Scott Benesh <scott.benesh@microsemi.com>
> Subject: Re: [PATCH 08/29] scsi: aacraid: Move code to wait for IO completion
> to shutdown func
> 
> EXTERNAL EMAIL
> 
> 
> On Thu, 2017-12-21 at 17:59 +0000, Bart Van Assche wrote:
> > On Thu, 2017-12-21 at 09:33 -0800, Raghava Aditya Renukunta wrote:
> > > +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);
> > > +   }
> > > +}
> >
> > Have you considered to call scsi_target_block() and scsi_target_unblock()
> instead
> > of implementing functionality like the above in a SCSI LLD?
> 
> (replying to my own e-mail)
> 
> It seems like I misread your code - calling scsi_target_block() and
> scsi_target_unblock() would not be sufficient. But calling
> blk_mq_freeze_queue()
> and blk_mq_unfreeze_queue() should be sufficient. The following commit
> made these
> functions work not only for scsi-mq but also for legacy scsi queues: commit
> 055f6e18e08f ("block: Make q_usage_counter also track legacy requests").

Hi Bart,
That piece of code is very much legacy  that I removed and placed in a function that would benefit all code paths that shutdown the controller. The 2 functions you mentioned are a god send but I think I will hold off on this patchset and do a full refactor with them in the next patchset. ( I suspect that I will have to touch a bunch of different code paths and perform extensive testing to be fully confident)

Regards,
Raghava Aditya

> Bart.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes
  2017-12-27  1:27   ` Raghava Aditya Renukunta
@ 2017-12-27 12:24     ` Guilherme G. Piccoli
  0 siblings, 0 replies; 49+ messages in thread
From: Guilherme G. Piccoli @ 2017-12-27 12:24 UTC (permalink / raw)
  To: Raghava Aditya Renukunta, linux-scsi
  Cc: jejb, martin.petersen, Scott Benesh, dl-esc-Aacraid Linux Driver,
	Tom White

On 12/26/2017 11:27 PM, Raghava Aditya Renukunta wrote:
> [...]
>> I was thinking...if possible, and just in case you plan to send a V2
>> after Bart's comments (or any other future reviews this patchset gets),
>> how about splitting in 2 patchsets, one for bug fixes and the other for
>> improvements/foundation of sas support?
>>
>> It could help to speed-up the merge of bug fixes.
> 
> Hi Guilherme,
> It did cross my mind, but I wanted to get the sas transport and bug fixes in by 4.16. I thought
> that breaking the patches into 3 patch sets might not help with it.
> 

Yeah, makes sense in this case! Thanks for considering it :)
Cheers,


Guilherme

> Regards,
> Raghava Aditya
> 
>  
>> Thanks,
>>
>>
>> Guilherme
>>>
>>>  - Fixed a udev inquiry race condition
>>>  - Fixed a kdump hang issue which occurs in case of error recovery in kdump
>>>  - Made improvements to ioctl reset and reset_host sysfs reset paths
>>>  - Changed the code to retrieve lun information into stand alone functions.
>>>  - Merged container and hba hotplug event processing (device addition and
>>>    and removal into single function)
>>>  - Removed scsi_scan_host for safw devices and now explicitly add devices
>>>    retrieved from the fw.
>>>  - Reschedule scan in driver fails to retrieve lun information from fw.
>>>    (usually works in a few attempts)
>>>  - Rescan worker waits for any pending EH recovery before rescanning
>>>  - Do not trigger rescan worker in kdump kernel
>>>
>>> Raghava Aditya Renukunta (29):
>>>   scsi: aacraid: Fix udev inquiry race condition
>>>   scsi: aacraid: Do not attempt abort when Fw panicked
>>>   scsi: aacraid: Fix hang in kdump
>>>   scsi: aacraid: Do not remove offlined devices
>>>   scsi: aacraid: Fix ioctl reset hang
>>>   scsi: aacraid: Allow reset_host sysfs var to recover Panicked Fw
>>>   scsi: aacraid: Refactor reset_host store function
>>>   scsi: aacraid: Move code to wait for IO completion to shutdown func
>>>   scsi: aacraid: Create bmic submission function from bmic identify
>>>   scsi: aacraid: Change phy luns function to use common bmic function
>>>   scsi: aacraid: Refactor and rename to make mirror existing changes
>>>   scsi: aacraid: Add target setup helper function
>>>   scsi: aacraid: Untangle targets setup from report phy luns
>>>   scsi: aacraid: Move function around to match existing code
>>>   scsi: aacraid: Create helper functions to get lun info
>>>   scsi: aacraid: Save bmic phy information for each phy
>>>   scsi: aacraid: Add helper function to set queue depth
>>>   scsi: aacraid: Merge func to get container information
>>>   scsi: aacraid: Process hba and container hot plug events in single
>>>               function
>>>   scsi: aacraid: Added macros to help loop through known buses and targets
>>>   scsi: aacraid: Refactor resolve luns code and scsi functions
>>>   scsi: aacraid: Merge adapter setup with resolve luns
>>>   scsi: aacraid: Block concurrent hotplug event handling
>>>   scsi: aacraid: Use hotplug handling function in place of scsi_scan_host
>>>   scsi: aacraid: Reschedule host scan in case of failure
>>>   scsi: aacraid: Fix hang while scanning in eh recovery
>>>   scsi: aacraid: Skip schedule rescan in case of kdump
>>>   scsi: aacraid: Remove unused rescan variable
>>>   scsi: aacraid: Remove AAC_HIDE_DISK check in queue command
>>>
>>>  drivers/scsi/aacraid/aachba.c   | 479 +++++++++++++++++++++++++++----
>> ---------
>>>  drivers/scsi/aacraid/aacraid.h  |  52 ++++-
>>>  drivers/scsi/aacraid/commctrl.c |   6 +-
>>>  drivers/scsi/aacraid/comminit.c |  49 +++-
>>>  drivers/scsi/aacraid/commsup.c  | 224 ++++++++++---------
>>>  drivers/scsi/aacraid/linit.c    |  23 +-
>>>  6 files changed, 561 insertions(+), 272 deletions(-)
>>>
> 

^ permalink raw reply	[flat|nested] 49+ messages in thread

end of thread, other threads:[~2017-12-27 12:24 UTC | newest]

Thread overview: 49+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-21 17:33 [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes Raghava Aditya Renukunta
2017-12-21 17:33 ` [PATCH 01/29] scsi: aacraid: Fix udev inquiry race condition Raghava Aditya Renukunta
2017-12-21 17:54   ` Bart Van Assche
2017-12-27  1:22     ` Raghava Aditya Renukunta
2017-12-21 17:33 ` [PATCH 02/29] scsi: aacraid: Do not attempt abort when Fw panicked Raghava Aditya Renukunta
2017-12-21 17:33 ` [PATCH 03/29] scsi: aacraid: Fix hang in kdump Raghava Aditya Renukunta
2017-12-21 19:15   ` Guilherme G. Piccoli
2017-12-22 15:13   ` Guilherme G. Piccoli
2017-12-27  1:28     ` Raghava Aditya Renukunta
2017-12-21 17:33 ` [PATCH 04/29] scsi: aacraid: Do not remove offlined devices Raghava Aditya Renukunta
2017-12-21 17:33 ` [PATCH 05/29] scsi: aacraid: Fix ioctl reset hang Raghava Aditya Renukunta
2017-12-21 17:33 ` [PATCH 06/29] scsi: aacraid: Allow reset_host sysfs var to recover Panicked Fw Raghava Aditya Renukunta
2017-12-21 17:33 ` [PATCH 07/29] scsi: aacraid: Refactor reset_host store function Raghava Aditya Renukunta
2017-12-21 17:33 ` [PATCH 08/29] scsi: aacraid: Move code to wait for IO completion to shutdown func Raghava Aditya Renukunta
2017-12-21 17:59   ` Bart Van Assche
2017-12-22 16:26     ` Bart Van Assche
2017-12-27  1:38       ` Raghava Aditya Renukunta
2017-12-21 17:34 ` [PATCH 09/29] scsi: aacraid: Create bmic submission function from bmic identify Raghava Aditya Renukunta
2017-12-21 17:34 ` [PATCH 10/29] scsi: aacraid: Change phy luns function to use common bmic function Raghava Aditya Renukunta
2017-12-21 17:34 ` [PATCH 11/29] scsi: aacraid: Refactor and rename to make mirror existing changes Raghava Aditya Renukunta
2017-12-21 17:34 ` [PATCH 12/29] scsi: aacraid: Add target setup helper function Raghava Aditya Renukunta
2017-12-21 17:34 ` [PATCH 13/29] scsi: aacraid: Untangle targets setup from report phy luns Raghava Aditya Renukunta
2017-12-21 17:34 ` [PATCH 14/29] scsi: aacraid: Move function around to match existing code Raghava Aditya Renukunta
2017-12-21 18:39   ` Bart Van Assche
2017-12-27  1:23     ` Raghava Aditya Renukunta
2017-12-21 17:34 ` [PATCH 15/29] scsi: aacraid: Create helper functions to get lun info Raghava Aditya Renukunta
2017-12-21 18:40   ` Bart Van Assche
2017-12-27  1:24     ` Raghava Aditya Renukunta
2017-12-21 17:34 ` [PATCH 16/29] scsi: aacraid: Save bmic phy information for each phy Raghava Aditya Renukunta
2017-12-21 17:34 ` [PATCH 17/29] scsi: aacraid: Add helper function to set queue depth Raghava Aditya Renukunta
2017-12-21 17:34 ` [PATCH 18/29] scsi: aacraid: Merge func to get container information Raghava Aditya Renukunta
2017-12-21 17:34 ` [PATCH 19/29] scsi: aacraid: Process hba and container hot plug events in single function Raghava Aditya Renukunta
2017-12-21 17:34 ` [PATCH 20/29] scsi: aacraid: Added macros to help loop through known buses and targets Raghava Aditya Renukunta
2017-12-21 17:34 ` [PATCH 21/29] scsi: aacraid: Refactor resolve luns code and scsi functions Raghava Aditya Renukunta
2017-12-21 18:42   ` Bart Van Assche
2017-12-27  1:25     ` Raghava Aditya Renukunta
2017-12-21 17:34 ` [PATCH 22/29] scsi: aacraid: Merge adapter setup with resolve luns Raghava Aditya Renukunta
2017-12-21 17:34 ` [PATCH 23/29] scsi: aacraid: Block concurrent hotplug event handling Raghava Aditya Renukunta
2017-12-21 17:34 ` [PATCH 24/29] scsi: aacraid: Use hotplug handling function in place of scsi_scan_host Raghava Aditya Renukunta
2017-12-21 17:34 ` [PATCH 25/29] scsi: aacraid: Reschedule host scan in case of failure Raghava Aditya Renukunta
2017-12-21 18:44   ` Bart Van Assche
2017-12-27  1:25     ` Raghava Aditya Renukunta
2017-12-21 17:34 ` [PATCH 26/29] scsi: aacraid: Fix hang while scanning in eh recovery Raghava Aditya Renukunta
2017-12-21 17:34 ` [PATCH 27/29] scsi: aacraid: Skip schedule rescan in case of kdump Raghava Aditya Renukunta
2017-12-21 17:34 ` [PATCH 28/29] scsi: aacraid: Remove unused rescan variable Raghava Aditya Renukunta
2017-12-21 17:34 ` [PATCH 29/29] scsi: aacraid: Remove AAC_HIDE_DISK check in queue command Raghava Aditya Renukunta
2017-12-22 15:06 ` [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes Guilherme G. Piccoli
2017-12-27  1:27   ` Raghava Aditya Renukunta
2017-12-27 12:24     ` Guilherme G. Piccoli

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.