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, aacraid@microsemi.com,
tom.white@microsemi.com,
"Guilherme G . Piccoli" <gpiccoli@linux.vnet.ibm.com>
Subject: [PATCH 19/29] scsi: aacraid: Process hba and container hot plug events in single function
Date: Thu, 21 Dec 2017 09:34:10 -0800 [thread overview]
Message-ID: <20171221173420.8213-20-RaghavaAditya.Renukunta@microsemi.com> (raw)
In-Reply-To: <20171221173420.8213-1-RaghavaAditya.Renukunta@microsemi.com>
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
next prev parent reply other threads:[~2017-12-21 17:34 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Raghava Aditya Renukunta [this message]
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
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=20171221173420.8213-20-RaghavaAditya.Renukunta@microsemi.com \
--to=raghavaaditya.renukunta@microsemi.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox