All of lore.kernel.org
 help / color / mirror / Atom feed
From: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
To: jejb@linux.vnet.ibm.com, martin.petersen@oracle.com,
	linux-scsi@vger.kernel.org
Cc: Scott.Benesh@microsemi.com, tom.white@microsemi.com,
	aacraid@microsemi.com,
	"Guilherme G . Piccoli" <gpiccoli@linux.vnet.ibm.com>,
	Bart Van Assche <Bart.VanAssche@wdc.com>
Subject: [PATCH v2 16/30] scsi: aacraid: Save bmic phy information for each phy
Date: Tue, 26 Dec 2017 20:34:37 -0800	[thread overview]
Message-ID: <20171227043451.27813-17-RaghavaAditya.Renukunta@microsemi.com> (raw)
In-Reply-To: <20171227043451.27813-1-RaghavaAditya.Renukunta@microsemi.com>

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>

---
Changes in V2:
Removed unused phy_luns variable

 drivers/scsi/aacraid/aachba.c  | 84 +++++++++++++++++++++++++++++++++++++++---
 drivers/scsi/aacraid/aacraid.h |  1 +
 2 files changed, 79 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index fa0132b..baa3de5 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -1756,7 +1756,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;
@@ -1779,7 +1779,7 @@ static int aac_issue_safw_bmic_identify(struct aac_dev *dev,
 
 	rcode = aac_send_safw_bmic_cmd(dev, &srbu, identify_reply, datasize);
 	if (unlikely(rcode < 0))
-		goto out;
+		goto mem_free_all;
 
 	if (identify_reply->current_queue_depth_limit <= 0 ||
 		identify_reply->current_queue_depth_limit > 32)
@@ -1788,9 +1788,13 @@ static int aac_issue_safw_bmic_identify(struct aac_dev *dev,
 		dev->hba_map[bus][target].qd_limit =
 			identify_reply->current_queue_depth_limit;
 
-	kfree(identify_reply);
+	*identify_resp = identify_reply;
+
 out:
 	return rcode;
+mem_free_all:
+	kfree(identify_reply);
+	goto out;
 }
 
 static inline void aac_free_safw_ciss_luns(struct aac_dev *dev)
@@ -1883,6 +1887,71 @@ static inline u32 aac_get_safw_phys_device_type(struct aac_dev *dev, int lun)
 	return dev->safw_phys_luns->lun[lun].node_ident[8];
 }
 
+static inline void aac_free_safw_identify_resp(struct aac_dev *dev,
+						int bus, int target)
+{
+	kfree(dev->hba_map[bus][target].safw_identify_resp);
+	dev->hba_map[bus][target].safw_identify_resp = NULL;
+}
+
+static inline void aac_free_safw_all_identify_resp(struct aac_dev *dev,
+	int lun_count)
+{
+	int luns;
+	int i;
+	u32 bus;
+	u32 target;
+
+	luns = aac_get_safw_phys_lun_count(dev);
+
+	if (luns < lun_count)
+		lun_count = luns;
+	else if (lun_count < 0)
+		lun_count = luns;
+
+	for (i = 0; i < lun_count; i++) {
+		bus = aac_get_safw_phys_bus(dev, i);
+		target = aac_get_safw_phys_target(dev, i);
+
+		aac_free_safw_identify_resp(dev, bus, target);
+	}
+}
+
+static int aac_get_safw_attr_all_targets(struct aac_dev *dev, int rescan)
+{
+	int i;
+	int rcode = 0;
+	u32 lun_count;
+	u32 bus;
+	u32 target;
+	struct aac_ciss_identify_pd *identify_resp = NULL;
+
+	lun_count = aac_get_safw_phys_lun_count(dev);
+
+	for (i = 0; i < lun_count; ++i) {
+
+		bus = aac_get_safw_phys_bus(dev, i);
+		target = aac_get_safw_phys_target(dev, i);
+
+		rcode = aac_issue_safw_bmic_identify(dev,
+						&identify_resp, bus, target);
+
+		if (unlikely(rcode < 0)) {
+			dev->hba_map[bus][target].qd_limit = 32;
+			goto free_identify_resp;
+		}
+
+		dev->hba_map[bus][target].safw_identify_resp = identify_resp;
+	}
+
+out:
+	return rcode;
+
+free_identify_resp:
+	aac_free_safw_all_identify_resp(dev, i);
+	goto out;
+}
+
 /**
  *	aac_set_safw_attr_all_targets-	update current hba map with data from FW
  *	@dev:	aac_dev structure
@@ -1929,9 +1998,6 @@ static void aac_set_safw_attr_all_targets(struct aac_dev *dev, int rescan)
 		if (devtype != AAC_DEVTYPE_NATIVE_RAW)
 			goto update_devtype;
 
-		if (aac_issue_safw_bmic_identify(dev, bus, target) < 0)
-			dev->hba_map[bus][target].qd_limit = 32;
-
 update_devtype:
 		if (rescan == AAC_INIT)
 			dev->hba_map[bus][target].devtype = devtype;
@@ -1948,8 +2014,14 @@ static int aac_setup_safw_targets(struct aac_dev *dev, int rescan)
 	if (unlikely(rcode < 0))
 		goto out;
 
+	rcode = aac_get_safw_attr_all_targets(dev, rescan);
+	if (unlikely(rcode < 0))
+		goto free_ciss_luns;
+
 	aac_set_safw_attr_all_targets(dev, rescan);
 
+	aac_free_safw_all_identify_resp(dev, -1);
+free_ciss_luns:
 	aac_free_safw_ciss_luns(dev);
 out:
 	return rcode;
diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h
index 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

  parent reply	other threads:[~2017-12-27  4:35 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-27  4:34 [PATCH 00/30] aacraid: Refactor for sas transport and bug fixes Raghava Aditya Renukunta
2017-12-27  4:34 ` [PATCH v2 01/30] scsi: aacraid: Fix udev inquiry race condition Raghava Aditya Renukunta
2017-12-27  4:34 ` [PATCH v2 02/30] scsi: aacraid: Do not attempt abort when Fw panicked Raghava Aditya Renukunta
2017-12-27  4:34 ` [PATCH v2 03/30] scsi: aacraid: Fix hang in kdump Raghava Aditya Renukunta
2017-12-27  4:34 ` [PATCH v2 04/30] scsi: aacraid: Do not remove offlined devices Raghava Aditya Renukunta
2017-12-27  4:34 ` [PATCH v2 05/30] scsi: aacraid: Fix ioctl reset hang Raghava Aditya Renukunta
2017-12-27  4:34 ` [PATCH v2 06/30] scsi: aacraid: Allow reset_host sysfs var to recover Panicked Fw Raghava Aditya Renukunta
2017-12-27  4:34 ` [PATCH v2 07/30] scsi: aacraid: Refactor reset_host store function Raghava Aditya Renukunta
2017-12-27  4:34 ` [PATCH v2 08/30] scsi: aacraid: Move code to wait for IO completion to shutdown func Raghava Aditya Renukunta
2017-12-27  4:34 ` [PATCH v2 09/30] scsi: aacraid: Create bmic submission function from bmic identify Raghava Aditya Renukunta
2017-12-27  4:34 ` [PATCH v2 10/30] scsi: aacraid: Change phy luns function to use common bmic function Raghava Aditya Renukunta
2017-12-27  4:34 ` [PATCH v2 11/30] scsi: aacraid: Refactor and rename to make mirror existing changes Raghava Aditya Renukunta
2017-12-27  4:34 ` [PATCH v2 12/30] scsi: aacraid: Add target setup helper function Raghava Aditya Renukunta
2017-12-27  4:34 ` [PATCH v2 13/30] scsi: aacraid: Untangle targets setup from report phy luns Raghava Aditya Renukunta
2017-12-27  4:34 ` [PATCH v2 14/30] scsi: aacraid: Move function around to match existing code Raghava Aditya Renukunta
2017-12-27  4:34 ` [PATCH v2 15/30] scsi: aacraid: Create helper functions to get lun info Raghava Aditya Renukunta
2017-12-27  4:34 ` Raghava Aditya Renukunta [this message]
2017-12-27  4:34 ` [PATCH v2 17/30] scsi: aacraid: Add helper function to set queue depth Raghava Aditya Renukunta
2017-12-27  4:34 ` [PATCH v2 18/30] scsi: aacraid: Merge func to get container information Raghava Aditya Renukunta
2017-12-27  4:34 ` [PATCH v2 19/30] scsi: aacraid: Process hba and container hot plug events in single function Raghava Aditya Renukunta
2017-12-27  4:34 ` [PATCH v2 20/30] scsi: aacraid: Added macros to help loop through known buses and targets Raghava Aditya Renukunta
2017-12-27  4:34 ` [PATCH v2 21/30] scsi: aacraid: Refactor resolve luns code and scsi functions Raghava Aditya Renukunta
2017-12-27  4:34 ` [PATCH v2 22/30] scsi: aacraid: Merge adapter setup with resolve luns Raghava Aditya Renukunta
2018-01-03 10:02   ` Nikola Pajkovsky
2018-01-03 17:00     ` Raghava Aditya Renukunta
2018-01-04 12:36       ` Nikola Pajkovsky
2017-12-27  4:34 ` [PATCH v2 23/30] scsi: aacraid: Block concurrent hotplug event handling Raghava Aditya Renukunta
2017-12-27  4:34 ` [PATCH v2 24/30] scsi: aacraid: Use hotplug handling function in place of scsi_scan_host Raghava Aditya Renukunta
2017-12-27  4:34 ` [PATCH v2 25/30] scsi: aacraid: Reschedule host scan in case of failure Raghava Aditya Renukunta
2017-12-27  4:34 ` [PATCH v2 26/30] scsi: aacraid: Fix hang while scanning in eh recovery Raghava Aditya Renukunta
2017-12-27  4:34 ` [PATCH v2 27/30] scsi: aacraid: Skip schedule rescan in case of kdump Raghava Aditya Renukunta
2017-12-27  4:34 ` [PATCH v2 28/30] scsi: aacraid: Remove unused rescan variable Raghava Aditya Renukunta
2017-12-27  4:34 ` [PATCH v2 29/30] scsi: aacraid: Remove AAC_HIDE_DISK check in queue command Raghava Aditya Renukunta
2017-12-27  4:34 ` [PATCH v2 30/30] scsi: aacraid: Update driver version to 50877 Raghava Aditya Renukunta
2018-01-04  4:28 ` [PATCH 00/30] aacraid: Refactor for sas transport and bug fixes Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171227043451.27813-17-RaghavaAditya.Renukunta@microsemi.com \
    --to=raghavaaditya.renukunta@microsemi.com \
    --cc=Bart.VanAssche@wdc.com \
    --cc=Scott.Benesh@microsemi.com \
    --cc=aacraid@microsemi.com \
    --cc=gpiccoli@linux.vnet.ibm.com \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=tom.white@microsemi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.