All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/18] smartpqi updates
@ 2022-02-01 21:47 Don Brace
  2022-02-01 21:47 ` [PATCH 01/18] smartpqi: fix rmmod stack trace Don Brace
                   ` (19 more replies)
  0 siblings, 20 replies; 21+ messages in thread
From: Don Brace @ 2022-02-01 21:47 UTC (permalink / raw)
  To: Kevin.Barnett, scott.teel, Justin.Lindley, scott.benesh,
	gerry.morong, mahesh.rajashekhara, mike.mcgowen, murthy.bhat,
	hch, jejb, joseph.szczypek, POSWALD
  Cc: linux-scsi

These patches are based on Martin Petersen's 5.18/scsi-queue tree
  https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git
  5.18/scsi-queue

This set of changes consist of:
 * Correcting a stack trace when the driver is unloaded. The driver was
   holding a spin lock when calling scsi_remove_device. 
 * Adding in new PCI device IDs and aligning the device order with our
   out-of-box driver. No functional changes.
 * Allow NCQ to be enabled for SATA disks. The controller firmware has
   to have support for this feature.
 * Enhance reboot performance by now issuing disk spin-downs during
   reboots. This eliminates spin-up time required doing the boot up.
 * Speed up multipath failover detection by returning DID_NO_CONNECT
   when the controller returns a path failure. Previously, the driver was
   waiting on an internal re-scan to detect the path failure.
 * Change function name pqi_is_io_high_priority() to
   pqi_is_io_high_priority() for better readability. Remove some white
   spaces from the same function.
 * Correct the structure used for AIO command submission. The structure
   used was pqi_raid_path_request, but needs to be pqi_aio_path_request.
   Both structure are the same size and have the same member offsets,
   so no issues were reported.
 * A PQI_HZ MACRO was introduced some time ago to resolve some timing
   issues. This definition is not needed. Switch back to using HZ.
 * For certain controllers, there was a request to avoid a drive
   spin-down for suspend (S3) state transitions.
 * For small drive expansions, the driver was not detecting the new
   size changes. We added a rescan whenever the driver receives an
   event from the controller.
 * In some rare cases, the controller can be locked up when a kdump
   is requested. When this occurs, the kdump is failed. This helps
   in debugging the cause of the lockup.
 * For RAID 10 disks, only one set of disks were used for read
   operations. Now we spread out I/O to all volumes. This resolves
   some inconsistent performance issues.
 * Export SAS addresses for all disks instead of only SAS disks.
 * Correct NUMA node association during pci_probe. A small typo
   was causing a different NUMA node to be set.
 * Not all structures were checked with BUILD_BUG_ON.
 * Correct some rare Hibernate/Suspend issues. Newer controllers
   may boot up with different timings.
 * Correct WWID output for lsscsi -t. The wrong part of the 16-byte WWID
   was used for the SAS address field.
 * Bump the driver version to 2.1.14-035

---

Balsundar P (1):
      smartpqi: resolve delay issue with PQI_HZ value

Don Brace (3):
      smartpqi: fix rmmod stack trace
      smartpqi: add PCI IDs
      smartpqi: update version to 2.1.14-035

Gilbert Wu (1):
      smartpqi: enable SATA NCQ priority in sysfs

Kevin Barnett (5):
      smartpqi: fix a name typo and cleanup code
      smartpqi: fix a typo in func pqi_aio_submit_io
      smartpqi: expose SAS address for SATA drives
      smartpqi: fix hibernate and suspend
      smartpqi: fix lsscsi-t SAS addresses

Mahesh Rajashekhara (2):
      smartpqi: update volume size after expansion
      smartpqi: fix kdump issue when ctrl is locked up

Mike McGowen (3):
      smartpqi: speed up RAID 10 sequential reads
      smartpqi: fix NUMA node not updated during init
      smartpqi: fix BUILD_BUG_ON() statements

Murthy Bhat (1):
      smartpqi: propagate path failures to SML quickly

Sagar Biradar (2):
      smartpqi: eliminate drive spin down on warm boot
      smartpqi: avoid drive spin-down during suspend


 drivers/scsi/smartpqi/smartpqi.h      |  16 +-
 drivers/scsi/smartpqi/smartpqi_init.c | 541 +++++++++++++++++++-------
 drivers/scsi/smartpqi/smartpqi_sis.c  |  10 +-
 drivers/scsi/smartpqi/smartpqi_sis.h  |   1 +
 4 files changed, 414 insertions(+), 154 deletions(-)

--
Signature


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

* [PATCH 01/18] smartpqi: fix rmmod stack trace
  2022-02-01 21:47 [PATCH 00/18] smartpqi updates Don Brace
@ 2022-02-01 21:47 ` Don Brace
  2022-02-01 21:47 ` [PATCH 02/18] smartpqi: add PCI IDs Don Brace
                   ` (18 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Don Brace @ 2022-02-01 21:47 UTC (permalink / raw)
  To: Kevin.Barnett, scott.teel, Justin.Lindley, scott.benesh,
	gerry.morong, mahesh.rajashekhara, mike.mcgowen, murthy.bhat,
	hch, jejb, joseph.szczypek, POSWALD
  Cc: linux-scsi

Prevent "BUG: scheduling while atomic: rmmod" stack trace.

Stop setting spin_locks before calling OS functions to remove devices.

Reviewed-by: Scott Benesh <scott.benesh@microchip.com>
Reviewed-by: Scott Teel <scott.teel@microchip.com>
Reviewed-by: Kevin Barnett <kevin.barnett@microchip.com>
Signed-off-by: Don Brace <don.brace@microchip.com>
---
 drivers/scsi/smartpqi/smartpqi_init.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index f0897d587454..2db9f874cc51 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -2513,17 +2513,15 @@ static void pqi_remove_all_scsi_devices(struct pqi_ctrl_info *ctrl_info)
 	struct pqi_scsi_dev *device;
 	struct pqi_scsi_dev *next;
 
-	spin_lock_irqsave(&ctrl_info->scsi_device_list_lock, flags);
-
 	list_for_each_entry_safe(device, next, &ctrl_info->scsi_device_list,
 		scsi_device_list_entry) {
 		if (pqi_is_device_added(device))
 			pqi_remove_device(ctrl_info, device);
+		spin_lock_irqsave(&ctrl_info->scsi_device_list_lock, flags);
 		list_del(&device->scsi_device_list_entry);
 		pqi_free_device(device);
+		spin_unlock_irqrestore(&ctrl_info->scsi_device_list_lock, flags);
 	}
-
-	spin_unlock_irqrestore(&ctrl_info->scsi_device_list_lock, flags);
 }
 
 static int pqi_scan_scsi_devices(struct pqi_ctrl_info *ctrl_info)



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

* [PATCH 02/18] smartpqi: add PCI IDs
  2022-02-01 21:47 [PATCH 00/18] smartpqi updates Don Brace
  2022-02-01 21:47 ` [PATCH 01/18] smartpqi: fix rmmod stack trace Don Brace
@ 2022-02-01 21:47 ` Don Brace
  2022-02-01 21:48 ` [PATCH 03/18] smartpqi: enable SATA NCQ priority in sysfs Don Brace
                   ` (17 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Don Brace @ 2022-02-01 21:47 UTC (permalink / raw)
  To: Kevin.Barnett, scott.teel, Justin.Lindley, scott.benesh,
	gerry.morong, mahesh.rajashekhara, mike.mcgowen, murthy.bhat,
	hch, jejb, joseph.szczypek, POSWALD
  Cc: linux-scsi

Add in new ZTE controllers:
                                    VID  / DID  / SVID / SDID
                                    ----   ----   ----   ----
ZTE SmartROC3100 RS241-18i 2G       9005 / 028F / 1CF2 / 5449
ZTE SmartROC3100 RS242-18i 4G       9005 / 028F / 1CF2 / 544A
ZTE SmartIOC2100 RS243-18i          9005 / 028F / 1CF2 / 544B
ZTE SmartROC3100 RM241B-18i 2G      9005 / 028F / 1CF2 / 544D
ZTE SmartROC3100 RM242B-18i 4G      9005 / 028F / 1CF2 / 544E
ZTE SmartIOC2100 RM243B-18i         9005 / 028F / 1CF2 / 544F

Add PCI ID for 1100-24i controller:
                                    VID  / DID  / SVID / SDID
                                    ----   ----   ----   ----
HBA 1100-24i                        9005 / 028F / 9005 / 1304

Add PCI IDs for HPE and Adaptec devices:
                                    VID  / DID  / SVID / SDID
                                    ----   ----   ----   ----
Adaptec Smart HBA 2200-8io /e       9005 / 028F / 9005 / 1463
Adaptec Smart HBA 2200-16io /e      9005 / 028F / 9005 / 14C2
HPE SR308i-p Gen11                  9005 / 028F / 1590 / 0382
HPE SR308i-o Gen11                  9005 / 028F / 1590 / 0383
HPE SR932i-p Gen11                  9005 / 028F / 1590 / 0381

Add PCI IDs for Inspur controllers:
                                    VID  / DID  / SVID / SDID
                                    ----   ----   ----   ----
INSPUR RS0800M5H24i                 9005 / 028F / 1BD4 / 006B
INSPUR RS0800M5E8I                  9005 / 028F / 1BD4 / 006C
INSPUR RS0800M5H8I                  9005 / 028F / 1BD4 / 006D
INSPUR RS0804M5R16i                 9005 / 028F / 1BD4 / 006F
INSPUR RS0800M5E16i                 9005 / 028F / 1BD4 / 0070
INSPUR RS0800M5H16i                 9005 / 028F / 1BD4 / 0071
INSPUR RS0800M5E16i                 9005 / 028F / 1BD4 / 0072
NT RAID 3100-24i                    9005 / 028F / 1F0C / 3161

Add HPE and Adaptec OROC PCI IDs:
                                    VID  / DID  / SVID / SDID
                                    ----   ----   ----   ----
HPE SR216i-o Gen11                  9005 / 028F / 9005 / 036F
Adaptec SmartRAID 3284-16io /e/uC   9005 / 028F / 9005 / 1473
Adaptec SmartRAID 3254-16io /e      9005 / 028F / 9005 / 1474

Add PCI IDs for new channel controllers:
                                    VID  / DID  / SVID / SDID
                                    ----   ----   ----   ----
Adaptec SmartRAID 3254-8i /e        9005 / 028F / 9005 / 14A4
Adaptec SmartRAID 3252-8i /e        9005 / 028F / 9005 / 14A5
Adaptec SmartRAID 3204-8i /e        9005 / 028F / 9005 / 14A6

Align PCI IDs with OOB driver
Realign the PCI ID table with our Out of Box driver.
Easier to check for differences.

Reviewed-by: Scott Benesh <scott.benesh@microchip.com>
Reviewed-by: Scott Teel <scott.teel@microchip.com>
Signed-off-by: Mike McGowen <Mike.McGowen@microchip.com>
Signed-off-by: Murthy Bhat <Murthy.Bhat@microchip.com>
Signed-off-by: Sagar Biradar <sagar.biradar@microchip.com>
Signed-off-by: Don Brace <don.brace@microchip.com>
---
 drivers/scsi/smartpqi/smartpqi_init.c |  108 ++++++++++++++++++++++++++++++++-
 1 file changed, 104 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index 2db9f874cc51..d34e49caa3f3 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -8941,10 +8941,6 @@ static const struct pci_device_id pqi_pci_id_table[] = {
 		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
 			       0x152d, 0x8a37)
 	},
-	{
-		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
-			       0x193d, 0x8460)
-	},
 	{
 		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
 			       0x193d, 0x1104)
@@ -9041,6 +9037,34 @@ static const struct pci_device_id pqi_pci_id_table[] = {
 		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
 			       0x1bd4, 0x0054)
 	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+			       0x1bd4, 0x006b)
+	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+			       0x1bd4, 0x006c)
+	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+			       0x1bd4, 0x006d)
+	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+			       0x1bd4, 0x006f)
+	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+			       0x1bd4, 0x0070)
+	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+			       0x1bd4, 0x0071)
+	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+			       0x1bd4, 0x0072)
+	},
 	{
 		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
 			       0x19e5, 0xd227)
@@ -9197,6 +9221,10 @@ static const struct pci_device_id pqi_pci_id_table[] = {
 		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
 			       PCI_VENDOR_ID_ADAPTEC2, 0x1303)
 	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+			       PCI_VENDOR_ID_ADAPTEC2, 0x1304)
+	},
 	{
 		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
 			       PCI_VENDOR_ID_ADAPTEC2, 0x1380)
@@ -9257,6 +9285,10 @@ static const struct pci_device_id pqi_pci_id_table[] = {
 		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
 			       PCI_VENDOR_ID_ADAPTEC2, 0x1462)
 	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+			       PCI_VENDOR_ID_ADAPTEC2, 0x1463)
+	},
 	{
 		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
 			       PCI_VENDOR_ID_ADAPTEC2, 0x1470)
@@ -9269,6 +9301,14 @@ static const struct pci_device_id pqi_pci_id_table[] = {
 		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
 			       PCI_VENDOR_ID_ADAPTEC2, 0x1472)
 	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+			       PCI_VENDOR_ID_ADAPTEC2, 0x1473)
+	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+			       PCI_VENDOR_ID_ADAPTEC2, 0x1474)
+	},
 	{
 		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
 			       PCI_VENDOR_ID_ADAPTEC2, 0x1480)
@@ -9293,6 +9333,18 @@ static const struct pci_device_id pqi_pci_id_table[] = {
 		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
 			       PCI_VENDOR_ID_ADAPTEC2, 0x14a2)
 	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+			       PCI_VENDOR_ID_ADAPTEC2, 0x14a4)
+	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+			       PCI_VENDOR_ID_ADAPTEC2, 0x14a5)
+	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+			       PCI_VENDOR_ID_ADAPTEC2, 0x14a6)
+	},
 	{
 		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
 			       PCI_VENDOR_ID_ADAPTEC2, 0x14b0)
@@ -9309,6 +9361,10 @@ static const struct pci_device_id pqi_pci_id_table[] = {
 		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
 			       PCI_VENDOR_ID_ADAPTEC2, 0x14c1)
 	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+			       PCI_VENDOR_ID_ADAPTEC2, 0x14c2)
+	},
 	{
 		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
 			       PCI_VENDOR_ID_ADAPTEC2, 0x14d0)
@@ -9413,6 +9469,22 @@ static const struct pci_device_id pqi_pci_id_table[] = {
 		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
 			       0x1590, 0x032e)
 	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+			       0x1590, 0x036f)
+	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+			       0x1590, 0x0381)
+	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+			       0x1590, 0x0382)
+	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+			       0x1590, 0x0383)
+	},
 	{
 		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
 			       0x1d8d, 0x0800)
@@ -9437,6 +9509,10 @@ static const struct pci_device_id pqi_pci_id_table[] = {
 		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
 			       0x1dfc, 0x3161)
 	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+			       0x1f0c, 0x3161)
+	},
 	{
 		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
 			       0x1cf2, 0x5445)
@@ -9449,6 +9525,30 @@ static const struct pci_device_id pqi_pci_id_table[] = {
 		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
 			       0x1cf2, 0x5447)
 	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+			       0x1cf2, 0x5449)
+	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+			       0x1cf2, 0x544a)
+	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+			       0x1cf2, 0x544b)
+	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+			       0x1cf2, 0x544d)
+	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+			       0x1cf2, 0x544e)
+	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+			       0x1cf2, 0x544f)
+	},
 	{
 		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
 			       0x1cf2, 0x0b27)



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

* [PATCH 03/18] smartpqi: enable SATA NCQ priority in sysfs
  2022-02-01 21:47 [PATCH 00/18] smartpqi updates Don Brace
  2022-02-01 21:47 ` [PATCH 01/18] smartpqi: fix rmmod stack trace Don Brace
  2022-02-01 21:47 ` [PATCH 02/18] smartpqi: add PCI IDs Don Brace
@ 2022-02-01 21:48 ` Don Brace
  2022-02-01 21:48 ` [PATCH 04/18] smartpqi: eliminate drive spin down on warm boot Don Brace
                   ` (16 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Don Brace @ 2022-02-01 21:48 UTC (permalink / raw)
  To: Kevin.Barnett, scott.teel, Justin.Lindley, scott.benesh,
	gerry.morong, mahesh.rajashekhara, mike.mcgowen, murthy.bhat,
	hch, jejb, joseph.szczypek, POSWALD
  Cc: linux-scsi

From: Gilbert Wu <Gilbert.Wu@microchip.com>

Add device attribute sas_ncq_prio_enable for IO utility
to enable SATA NCQ priority support and recognize IO priority in SCSI
command and then pass IO priority information to controller firmware.

This device attribute works only when device has NCQ priority support
and controller firmware can handle IO with NCQ priority attribute.

Reviewed-by: Mike McGowen <mike.mcgowen@microchip.com>
Reviewed-by: Scott Teel <scott.teel@microchip.com>
Signed-off-by: Gilbert Wu <Gilbert.Wu@microchip.com>
Signed-off-by: Don Brace <don.brace@microchip.com>
---
 drivers/scsi/smartpqi/smartpqi.h      |    2 +
 drivers/scsi/smartpqi/smartpqi_init.c |  119 ++++++++++++++++++++++++++++++++-
 2 files changed, 117 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/smartpqi/smartpqi.h b/drivers/scsi/smartpqi/smartpqi.h
index aac88ac0a0b7..f192745ee488 100644
--- a/drivers/scsi/smartpqi/smartpqi.h
+++ b/drivers/scsi/smartpqi/smartpqi.h
@@ -1127,6 +1127,8 @@ struct pqi_scsi_dev {
 	u8	box[8];
 	u16	phys_connector[8];
 	u8	phy_id;
+	u8	ncq_prio_enable;
+	u8	ncq_prio_support;
 	bool	raid_bypass_configured;	/* RAID bypass configured */
 	bool	raid_bypass_enabled;	/* RAID bypass enabled */
 	u32	next_bypass_group;
diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index d34e49caa3f3..ad9fa1628a69 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -68,7 +68,7 @@ static int pqi_submit_raid_request_synchronous(struct pqi_ctrl_info *ctrl_info,
 static int pqi_aio_submit_io(struct pqi_ctrl_info *ctrl_info,
 	struct scsi_cmnd *scmd, u32 aio_handle, u8 *cdb,
 	unsigned int cdb_length, struct pqi_queue_group *queue_group,
-	struct pqi_encryption_info *encryption_info, bool raid_bypass);
+	struct pqi_encryption_info *encryption_info, bool raid_bypass, bool io_high_prio);
 static  int pqi_aio_submit_r1_write_io(struct pqi_ctrl_info *ctrl_info,
 	struct scsi_cmnd *scmd, struct pqi_queue_group *queue_group,
 	struct pqi_encryption_info *encryption_info, struct pqi_scsi_dev *device,
@@ -1549,6 +1549,7 @@ static void pqi_get_volume_status(struct pqi_ctrl_info *ctrl_info,
 	device->volume_offline = volume_offline;
 }
 
+#define PQI_DEVICE_NCQ_PRIO_SUPPORTED	0x01
 #define PQI_DEVICE_PHY_MAP_SUPPORTED	0x10
 
 static int pqi_get_physical_device_info(struct pqi_ctrl_info *ctrl_info,
@@ -1597,6 +1598,10 @@ static int pqi_get_physical_device_info(struct pqi_ctrl_info *ctrl_info,
 	else
 		device->phy_id = 0xFF;
 
+	device->ncq_prio_support =
+		((get_unaligned_le32(&id_phys->misc_drive_flags) >> 16) &
+		PQI_DEVICE_NCQ_PRIO_SUPPORTED);
+
 	return 0;
 }
 
@@ -3007,7 +3012,7 @@ static int pqi_raid_bypass_submit_scsi_cmd(struct pqi_ctrl_info *ctrl_info,
 
 	return pqi_aio_submit_io(ctrl_info, scmd, rmd.aio_handle,
 		rmd.cdb, rmd.cdb_length, queue_group,
-		encryption_info_ptr, true);
+		encryption_info_ptr, true, false);
 }
 
 #define PQI_STATUS_IDLE		0x0
@@ -5560,18 +5565,55 @@ static void pqi_aio_io_complete(struct pqi_io_request *io_request,
 	pqi_scsi_done(scmd);
 }
 
+static inline bool pqi_is_io_high_prioity(struct pqi_ctrl_info *ctrl_info,
+	struct pqi_scsi_dev *device, struct scsi_cmnd *scmd)
+{
+	bool io_high_prio;
+	int priority_class;
+
+	io_high_prio = false;
+	if (device->ncq_prio_enable) {
+		priority_class =
+			IOPRIO_PRIO_CLASS(req_get_ioprio(scsi_cmd_to_rq(scmd)));
+		if (priority_class == IOPRIO_CLASS_RT) {
+			/* set NCQ priority for read/write command */
+			switch (scmd->cmnd[0]) {
+			case WRITE_16:
+			case READ_16:
+			case WRITE_12:
+			case READ_12:
+			case WRITE_10:
+			case READ_10:
+			case WRITE_6:
+			case READ_6:
+				io_high_prio = true;
+				break;
+			default:
+				break;
+			}
+		}
+	}
+
+	return io_high_prio;
+}
+
 static inline int pqi_aio_submit_scsi_cmd(struct pqi_ctrl_info *ctrl_info,
 	struct pqi_scsi_dev *device, struct scsi_cmnd *scmd,
 	struct pqi_queue_group *queue_group)
 {
+	bool io_high_prio;
+
+	io_high_prio = pqi_is_io_high_prioity(ctrl_info, device, scmd);
 	return pqi_aio_submit_io(ctrl_info, scmd, device->aio_handle,
-		scmd->cmnd, scmd->cmd_len, queue_group, NULL, false);
+		scmd->cmnd, scmd->cmd_len, queue_group, NULL,
+		false, io_high_prio);
 }
 
 static int pqi_aio_submit_io(struct pqi_ctrl_info *ctrl_info,
 	struct scsi_cmnd *scmd, u32 aio_handle, u8 *cdb,
 	unsigned int cdb_length, struct pqi_queue_group *queue_group,
-	struct pqi_encryption_info *encryption_info, bool raid_bypass)
+	struct pqi_encryption_info *encryption_info, bool raid_bypass,
+	bool io_high_prio)
 {
 	int rc;
 	struct pqi_io_request *io_request;
@@ -5589,6 +5631,7 @@ static int pqi_aio_submit_io(struct pqi_ctrl_info *ctrl_info,
 	put_unaligned_le32(aio_handle, &request->nexus_id);
 	put_unaligned_le32(scsi_bufflen(scmd), &request->buffer_length);
 	request->task_attribute = SOP_TASK_ATTRIBUTE_SIMPLE;
+	request->command_priority = io_high_prio;
 	put_unaligned_le16(io_request->index, &request->request_id);
 	request->error_index = request->request_id;
 	if (cdb_length > sizeof(request->cdb))
@@ -7121,6 +7164,71 @@ static ssize_t pqi_raid_bypass_cnt_show(struct device *dev,
 	return scnprintf(buffer, PAGE_SIZE, "0x%x\n", raid_bypass_cnt);
 }
 
+static ssize_t pqi_sas_ncq_prio_enable_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct pqi_ctrl_info *ctrl_info;
+	struct scsi_device *sdev;
+	struct pqi_scsi_dev *device;
+	unsigned long flags;
+	int output_len = 0;
+
+	sdev = to_scsi_device(dev);
+	ctrl_info = shost_to_hba(sdev->host);
+
+	spin_lock_irqsave(&ctrl_info->scsi_device_list_lock, flags);
+
+	device = sdev->hostdata;
+	if (!device) {
+		spin_unlock_irqrestore(&ctrl_info->scsi_device_list_lock, flags);
+		return -ENODEV;
+	}
+
+	output_len = snprintf(buf, PAGE_SIZE, "%d\n",
+				device->ncq_prio_enable);
+	spin_unlock_irqrestore(&ctrl_info->scsi_device_list_lock, flags);
+
+	return output_len;
+}
+
+static ssize_t pqi_sas_ncq_prio_enable_store(struct device *dev,
+			struct device_attribute *attr,
+			const char *buf, size_t count)
+{
+	struct pqi_ctrl_info *ctrl_info;
+	struct scsi_device *sdev;
+	struct pqi_scsi_dev *device;
+	unsigned long flags;
+	u8 ncq_prio_enable = 0;
+
+	if (kstrtou8(buf, 0, &ncq_prio_enable))
+		return -EINVAL;
+
+	sdev = to_scsi_device(dev);
+	ctrl_info = shost_to_hba(sdev->host);
+
+	spin_lock_irqsave(&ctrl_info->scsi_device_list_lock, flags);
+
+	device = sdev->hostdata;
+
+	if (!device) {
+		spin_unlock_irqrestore(&ctrl_info->scsi_device_list_lock, flags);
+		return -ENODEV;
+	}
+
+	if (!device->ncq_prio_support ||
+		!device->is_physical_device) {
+		spin_unlock_irqrestore(&ctrl_info->scsi_device_list_lock, flags);
+		return -EINVAL;
+	}
+
+	device->ncq_prio_enable = ncq_prio_enable;
+
+	spin_unlock_irqrestore(&ctrl_info->scsi_device_list_lock, flags);
+
+	return  strlen(buf);
+}
+
 static DEVICE_ATTR(lunid, 0444, pqi_lunid_show, NULL);
 static DEVICE_ATTR(unique_id, 0444, pqi_unique_id_show, NULL);
 static DEVICE_ATTR(path_info, 0444, pqi_path_info_show, NULL);
@@ -7128,6 +7236,8 @@ static DEVICE_ATTR(sas_address, 0444, pqi_sas_address_show, NULL);
 static DEVICE_ATTR(ssd_smart_path_enabled, 0444, pqi_ssd_smart_path_enabled_show, NULL);
 static DEVICE_ATTR(raid_level, 0444, pqi_raid_level_show, NULL);
 static DEVICE_ATTR(raid_bypass_cnt, 0444, pqi_raid_bypass_cnt_show, NULL);
+static DEVICE_ATTR(sas_ncq_prio_enable, 0644,
+		pqi_sas_ncq_prio_enable_show, pqi_sas_ncq_prio_enable_store);
 
 static struct attribute *pqi_sdev_attrs[] = {
 	&dev_attr_lunid.attr,
@@ -7137,6 +7247,7 @@ static struct attribute *pqi_sdev_attrs[] = {
 	&dev_attr_ssd_smart_path_enabled.attr,
 	&dev_attr_raid_level.attr,
 	&dev_attr_raid_bypass_cnt.attr,
+	&dev_attr_sas_ncq_prio_enable.attr,
 	NULL
 };
 



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

* [PATCH 04/18] smartpqi: eliminate drive spin down on warm boot
  2022-02-01 21:47 [PATCH 00/18] smartpqi updates Don Brace
                   ` (2 preceding siblings ...)
  2022-02-01 21:48 ` [PATCH 03/18] smartpqi: enable SATA NCQ priority in sysfs Don Brace
@ 2022-02-01 21:48 ` Don Brace
  2022-02-01 21:48 ` [PATCH 05/18] smartpqi: propagate path failures to SML quickly Don Brace
                   ` (15 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Don Brace @ 2022-02-01 21:48 UTC (permalink / raw)
  To: Kevin.Barnett, scott.teel, Justin.Lindley, scott.benesh,
	gerry.morong, mahesh.rajashekhara, mike.mcgowen, murthy.bhat,
	hch, jejb, joseph.szczypek, POSWALD
  Cc: linux-scsi

From: Sagar Biradar <sagar.biradar@microchip.com>

Avoid drive spin down during a warm boot on Linux.

Call the BMIC Flush Cache command (0xc2) to indicate the reason for
the flush cache (shutdown, hibernate, suspend, or restart).

Reviewed-by: Mike McGowen <mike.mcgowen@microchip.com>
Reviewed-by: Scott Benesh <scott.benesh@microchip.com>
Reviewed-by: Scott Teel <scott.teel@microchip.com>
Signed-off-by: Sagar Biradar <sagar.biradar@microchip.com>
Signed-off-by: Don Brace <don.brace@microchip.com>
---
 drivers/scsi/smartpqi/smartpqi_init.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index ad9fa1628a69..f51605cd098c 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -8902,6 +8902,7 @@ static void pqi_shutdown(struct pci_dev *pci_dev)
 {
 	int rc;
 	struct pqi_ctrl_info *ctrl_info;
+	enum bmic_flush_cache_shutdown_event shutdown_event;
 
 	ctrl_info = pci_get_drvdata(pci_dev);
 	if (!ctrl_info) {
@@ -8917,11 +8918,16 @@ static void pqi_shutdown(struct pci_dev *pci_dev)
 	pqi_ctrl_block_requests(ctrl_info);
 	pqi_ctrl_wait_until_quiesced(ctrl_info);
 
+	if (system_state == SYSTEM_RESTART)
+		shutdown_event = RESTART;
+	else
+		shutdown_event = SHUTDOWN;
+
 	/*
 	 * Write all data in the controller's battery-backed cache to
 	 * storage.
 	 */
-	rc = pqi_flush_cache(ctrl_info, SHUTDOWN);
+	rc = pqi_flush_cache(ctrl_info, shutdown_event);
 	if (rc)
 		dev_err(&pci_dev->dev,
 			"unable to flush controller cache\n");



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

* [PATCH 05/18] smartpqi: propagate path failures to SML quickly
  2022-02-01 21:47 [PATCH 00/18] smartpqi updates Don Brace
                   ` (3 preceding siblings ...)
  2022-02-01 21:48 ` [PATCH 04/18] smartpqi: eliminate drive spin down on warm boot Don Brace
@ 2022-02-01 21:48 ` Don Brace
  2022-02-01 21:48 ` [PATCH 06/18] smartpqi: fix a name typo and cleanup code Don Brace
                   ` (14 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Don Brace @ 2022-02-01 21:48 UTC (permalink / raw)
  To: Kevin.Barnett, scott.teel, Justin.Lindley, scott.benesh,
	gerry.morong, mahesh.rajashekhara, mike.mcgowen, murthy.bhat,
	hch, jejb, joseph.szczypek, POSWALD
  Cc: linux-scsi

From: Murthy Bhat <Murthy.Bhat@microchip.com>

Return DID_NO_CONNECT when a path failure is detected.
  When a path fails during IO and AIO path gets disabled for a
  multipath device, the IO was retried in the RAID path slowing
  down path fail detection. Returning DID_NO_CONNECT allows multipath
  to switch paths more quickly.

Reviewed-by: Scott Benesh <scott.benesh@microchip.com>
Reviewed-by: Scott Teel <scott.teel@microchip.com>
Reviewed-by: Sagar Biradar <sagar.biradar@microchip.com>
Signed-off-by: Murthy Bhat <Murthy.Bhat@microchip.com>
Signed-off-by: Don Brace <don.brace@microchip.com>
---
 drivers/scsi/smartpqi/smartpqi_init.c |   20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index f51605cd098c..9bc2987e280f 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -2291,6 +2291,14 @@ static inline bool pqi_is_device_with_sas_address(struct pqi_scsi_dev *device)
 	return false;
 }
 
+static inline bool pqi_is_multipath_device(struct pqi_scsi_dev *device)
+{
+	if (pqi_is_logical_device(device))
+		return false;
+
+	return (device->path_map & (device->path_map - 1)) != 0;
+}
+
 static inline bool pqi_expose_device(struct pqi_scsi_dev *device)
 {
 	return !device->is_physical_device || !pqi_skip_device(device->scsi3addr);
@@ -3216,12 +3224,14 @@ static void pqi_process_aio_io_error(struct pqi_io_request *io_request)
 	int residual_count;
 	int xfer_count;
 	bool device_offline;
+	struct pqi_scsi_dev *device;
 
 	scmd = io_request->scmd;
 	error_info = io_request->error_info;
 	host_byte = DID_OK;
 	sense_data_length = 0;
 	device_offline = false;
+	device = scmd->device->hostdata;
 
 	switch (error_info->service_response) {
 	case PQI_AIO_SERV_RESPONSE_COMPLETE:
@@ -3246,8 +3256,14 @@ static void pqi_process_aio_io_error(struct pqi_io_request *io_request)
 			break;
 		case PQI_AIO_STATUS_AIO_PATH_DISABLED:
 			pqi_aio_path_disabled(io_request);
-			scsi_status = SAM_STAT_GOOD;
-			io_request->status = -EAGAIN;
+			if (pqi_is_multipath_device(device)) {
+				pqi_device_remove_start(device);
+				host_byte = DID_NO_CONNECT;
+				scsi_status = SAM_STAT_CHECK_CONDITION;
+			} else {
+				scsi_status = SAM_STAT_GOOD;
+				io_request->status = -EAGAIN;
+			}
 			break;
 		case PQI_AIO_STATUS_NO_PATH_TO_DEVICE:
 		case PQI_AIO_STATUS_INVALID_DEVICE:



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

* [PATCH 06/18] smartpqi: fix a name typo and cleanup code
  2022-02-01 21:47 [PATCH 00/18] smartpqi updates Don Brace
                   ` (4 preceding siblings ...)
  2022-02-01 21:48 ` [PATCH 05/18] smartpqi: propagate path failures to SML quickly Don Brace
@ 2022-02-01 21:48 ` Don Brace
  2022-02-01 21:48 ` [PATCH 07/18] smartpqi: fix a typo in func pqi_aio_submit_io Don Brace
                   ` (13 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Don Brace @ 2022-02-01 21:48 UTC (permalink / raw)
  To: Kevin.Barnett, scott.teel, Justin.Lindley, scott.benesh,
	gerry.morong, mahesh.rajashekhara, mike.mcgowen, murthy.bhat,
	hch, jejb, joseph.szczypek, POSWALD
  Cc: linux-scsi

From: Kevin Barnett <kevin.barnett@microchip.com>

Rename the function pqi_is_io_high_priority() to
pqi_is_io_high_priority(), removed 2 unnecessary lines from the
function, and adjusted the white space.

Reviewed-by: Mike McGowen <mike.mcgowen@microchip.com>
Reviewed-by: Scott Benesh <scott.benesh@microchip.com>
Reviewed-by: Scott Teel <scott.teel@microchip.com>
Signed-off-by: Kevin Barnett <kevin.barnett@microchip.com>
Signed-off-by: Don Brace <don.brace@microchip.com>
---
 drivers/scsi/smartpqi/smartpqi_init.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index 9bc2987e280f..8ff38e3ecd09 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -5581,18 +5581,19 @@ static void pqi_aio_io_complete(struct pqi_io_request *io_request,
 	pqi_scsi_done(scmd);
 }
 
-static inline bool pqi_is_io_high_prioity(struct pqi_ctrl_info *ctrl_info,
+static inline bool pqi_is_io_high_priority(struct pqi_ctrl_info *ctrl_info,
 	struct pqi_scsi_dev *device, struct scsi_cmnd *scmd)
 {
 	bool io_high_prio;
 	int priority_class;
 
 	io_high_prio = false;
+
 	if (device->ncq_prio_enable) {
 		priority_class =
 			IOPRIO_PRIO_CLASS(req_get_ioprio(scsi_cmd_to_rq(scmd)));
 		if (priority_class == IOPRIO_CLASS_RT) {
-			/* set NCQ priority for read/write command */
+			/* Set NCQ priority for read/write commands. */
 			switch (scmd->cmnd[0]) {
 			case WRITE_16:
 			case READ_16:
@@ -5604,8 +5605,6 @@ static inline bool pqi_is_io_high_prioity(struct pqi_ctrl_info *ctrl_info,
 			case READ_6:
 				io_high_prio = true;
 				break;
-			default:
-				break;
 			}
 		}
 	}
@@ -5619,7 +5618,8 @@ static inline int pqi_aio_submit_scsi_cmd(struct pqi_ctrl_info *ctrl_info,
 {
 	bool io_high_prio;
 
-	io_high_prio = pqi_is_io_high_prioity(ctrl_info, device, scmd);
+	io_high_prio = pqi_is_io_high_priority(ctrl_info, device, scmd);
+
 	return pqi_aio_submit_io(ctrl_info, scmd, device->aio_handle,
 		scmd->cmnd, scmd->cmd_len, queue_group, NULL,
 		false, io_high_prio);



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

* [PATCH 07/18] smartpqi: fix a typo in func pqi_aio_submit_io
  2022-02-01 21:47 [PATCH 00/18] smartpqi updates Don Brace
                   ` (5 preceding siblings ...)
  2022-02-01 21:48 ` [PATCH 06/18] smartpqi: fix a name typo and cleanup code Don Brace
@ 2022-02-01 21:48 ` Don Brace
  2022-02-01 21:48 ` [PATCH 08/18] smartpqi: resolve delay issue with PQI_HZ value Don Brace
                   ` (12 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Don Brace @ 2022-02-01 21:48 UTC (permalink / raw)
  To: Kevin.Barnett, scott.teel, Justin.Lindley, scott.benesh,
	gerry.morong, mahesh.rajashekhara, mike.mcgowen, murthy.bhat,
	hch, jejb, joseph.szczypek, POSWALD
  Cc: linux-scsi

From: Kevin Barnett <kevin.barnett@microchip.com>

Use correct pqi_aio_path_request structure to calculate the offset to
sg_descriptors.

The function pqi_aio_submit_io() uses the pqi_raid_path_request
structure to calculate the offset of the structure member
sg_descriptors.  This is incorrect.  It should be using the
pqi_aio_path_request structure instead.

This typo is benign because the offsets are the same in both
structures.

Reviewed-by: Mike McGowen <mike.mcgowen@microchip.com>
Reviewed-by: Scott Teel <scott.teel@microchip.com>
Signed-off-by: Kevin Barnett <kevin.barnett@microchip.com>
Signed-off-by: Don Brace <don.brace@microchip.com>
---
 drivers/scsi/smartpqi/smartpqi_init.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index 8ff38e3ecd09..075e41b5ceaa 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -5641,7 +5641,7 @@ static int pqi_aio_submit_io(struct pqi_ctrl_info *ctrl_info,
 	io_request->raid_bypass = raid_bypass;
 
 	request = io_request->iu;
-	memset(request, 0, offsetof(struct pqi_raid_path_request, sg_descriptors));
+	memset(request, 0, offsetof(struct pqi_aio_path_request, sg_descriptors));
 
 	request->header.iu_type = PQI_REQUEST_IU_AIO_PATH_IO;
 	put_unaligned_le32(aio_handle, &request->nexus_id);



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

* [PATCH 08/18] smartpqi: resolve delay issue with PQI_HZ value
  2022-02-01 21:47 [PATCH 00/18] smartpqi updates Don Brace
                   ` (6 preceding siblings ...)
  2022-02-01 21:48 ` [PATCH 07/18] smartpqi: fix a typo in func pqi_aio_submit_io Don Brace
@ 2022-02-01 21:48 ` Don Brace
  2022-02-01 21:48 ` [PATCH 09/18] smartpqi: avoid drive spin-down during suspend Don Brace
                   ` (11 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Don Brace @ 2022-02-01 21:48 UTC (permalink / raw)
  To: Kevin.Barnett, scott.teel, Justin.Lindley, scott.benesh,
	gerry.morong, mahesh.rajashekhara, mike.mcgowen, murthy.bhat,
	hch, jejb, joseph.szczypek, POSWALD
  Cc: linux-scsi

From: Balsundar P <balsundar.p@microchip.com>

Change PQI_HZ to HZ.

PQI_HZ macro was set to 1000 when HZ value is less than 1000.
By default, PQI_HZ will result into a delay of 10 seconds(for kernel,
which has HZ = 100). So in this case when firmware raises an event,
rescan worker will be scheduled after a delay of (10 x PQI_HZ) = 100
seconds instead of 10 seconds.

Also driver uses PQI_HZ at many instances, which might result in some
other issues with respect to delay.

Align driver with our out-of-box driver for timeout values.

Reviewed-by: Kevin Barnett <kevin.barnett@microchip.com>
Reviewed-by: Mike McGowen <mike.mcgowen@microchip.com>
Reviewed-by: Scott Benesh <scott.benesh@microchip.com>
Reviewed-by: Scott Teel <scott.teel@microchip.com>
Signed-off-by: Balsundar P <balsundar.p@microchip.com>
Signed-off-by: Don Brace <don.brace@microchip.com>
---
 drivers/scsi/smartpqi/smartpqi.h      |    6 ------
 drivers/scsi/smartpqi/smartpqi_init.c |   32 ++++++++++++++++----------------
 drivers/scsi/smartpqi/smartpqi_sis.c  |    8 ++++----
 3 files changed, 20 insertions(+), 26 deletions(-)

diff --git a/drivers/scsi/smartpqi/smartpqi.h b/drivers/scsi/smartpqi/smartpqi.h
index f192745ee488..81ec5fbf570a 100644
--- a/drivers/scsi/smartpqi/smartpqi.h
+++ b/drivers/scsi/smartpqi/smartpqi.h
@@ -96,12 +96,6 @@ struct pqi_ctrl_registers {
 	struct pqi_device_registers pqi_registers;	/* 4000h */
 };
 
-#if ((HZ) < 1000)
-#define PQI_HZ  1000
-#else
-#define PQI_HZ  (HZ)
-#endif
-
 #define PQI_DEVICE_REGISTERS_OFFSET	0x4000
 
 /* shutdown reasons for taking the controller offline */
diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index 075e41b5ceaa..b32a5a5a5c21 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -376,7 +376,7 @@ static inline void pqi_ctrl_wait_until_quiesced(struct pqi_ctrl_info *ctrl_info)
 
 	displayed_warning = false;
 	start_jiffies = jiffies;
-	warning_timeout = (PQI_QUIESCE_WARNING_TIMEOUT_SECS * PQI_HZ) + start_jiffies;
+	warning_timeout = (PQI_QUIESCE_WARNING_TIMEOUT_SECS * HZ) + start_jiffies;
 
 	while (atomic_read(&ctrl_info->num_busy_threads) >
 		atomic_read(&ctrl_info->num_blocked_threads)) {
@@ -385,7 +385,7 @@ static inline void pqi_ctrl_wait_until_quiesced(struct pqi_ctrl_info *ctrl_info)
 				"waiting %u seconds for driver activity to quiesce\n",
 				jiffies_to_msecs(jiffies - start_jiffies) / 1000);
 			displayed_warning = true;
-			warning_timeout = (PQI_QUIESCE_WARNING_TIMEOUT_SECS * PQI_HZ) + jiffies;
+			warning_timeout = (PQI_QUIESCE_WARNING_TIMEOUT_SECS * HZ) + jiffies;
 		}
 		usleep_range(1000, 2000);
 	}
@@ -462,7 +462,7 @@ static inline void pqi_schedule_rescan_worker(struct pqi_ctrl_info *ctrl_info)
 	pqi_schedule_rescan_worker_with_delay(ctrl_info, 0);
 }
 
-#define PQI_RESCAN_WORK_DELAY	(10 * PQI_HZ)
+#define PQI_RESCAN_WORK_DELAY	(10 * HZ)
 
 static inline void pqi_schedule_rescan_worker_delayed(struct pqi_ctrl_info *ctrl_info)
 {
@@ -1038,7 +1038,7 @@ static int pqi_write_current_time_to_host_wellness(
 	return rc;
 }
 
-#define PQI_UPDATE_TIME_WORK_INTERVAL	(24UL * 60 * 60 * PQI_HZ)
+#define PQI_UPDATE_TIME_WORK_INTERVAL	(24UL * 60 * 60 * HZ)
 
 static void pqi_update_time_worker(struct work_struct *work)
 {
@@ -3045,7 +3045,7 @@ static int pqi_wait_for_pqi_mode_ready(struct pqi_ctrl_info *ctrl_info)
 	u8 status;
 
 	pqi_registers = ctrl_info->pqi_registers;
-	timeout = (PQI_MODE_READY_TIMEOUT_SECS * PQI_HZ) + jiffies;
+	timeout = (PQI_MODE_READY_TIMEOUT_SECS * HZ) + jiffies;
 
 	while (1) {
 		signature = readq(&pqi_registers->signature);
@@ -3539,7 +3539,7 @@ static enum pqi_soft_reset_status pqi_poll_for_soft_reset_status(
 	u8 status;
 	unsigned long timeout;
 
-	timeout = (PQI_SOFT_RESET_STATUS_TIMEOUT_SECS * PQI_HZ) + jiffies;
+	timeout = (PQI_SOFT_RESET_STATUS_TIMEOUT_SECS * HZ) + jiffies;
 
 	while (1) {
 		status = pqi_read_soft_reset_status(ctrl_info);
@@ -3717,7 +3717,7 @@ static void pqi_event_worker(struct work_struct *work)
 	pqi_ctrl_unbusy(ctrl_info);
 }
 
-#define PQI_HEARTBEAT_TIMER_INTERVAL	(10 * PQI_HZ)
+#define PQI_HEARTBEAT_TIMER_INTERVAL	(10 * HZ)
 
 static void pqi_heartbeat_timer_handler(struct timer_list *t)
 {
@@ -4264,7 +4264,7 @@ static int pqi_alloc_admin_queues(struct pqi_ctrl_info *ctrl_info)
 	return 0;
 }
 
-#define PQI_ADMIN_QUEUE_CREATE_TIMEOUT_JIFFIES		PQI_HZ
+#define PQI_ADMIN_QUEUE_CREATE_TIMEOUT_JIFFIES		HZ
 #define PQI_ADMIN_QUEUE_CREATE_POLL_INTERVAL_MSECS	1
 
 static int pqi_create_admin_queues(struct pqi_ctrl_info *ctrl_info)
@@ -4358,7 +4358,7 @@ static int pqi_poll_for_admin_response(struct pqi_ctrl_info *ctrl_info,
 	admin_queues = &ctrl_info->admin_queues;
 	oq_ci = admin_queues->oq_ci_copy;
 
-	timeout = (PQI_ADMIN_REQUEST_TIMEOUT_SECS * PQI_HZ) + jiffies;
+	timeout = (PQI_ADMIN_REQUEST_TIMEOUT_SECS * HZ) + jiffies;
 
 	while (1) {
 		oq_pi = readl(admin_queues->oq_pi);
@@ -4473,7 +4473,7 @@ static int pqi_wait_for_completion_io(struct pqi_ctrl_info *ctrl_info,
 
 	while (1) {
 		if (wait_for_completion_io_timeout(wait,
-			PQI_WAIT_FOR_COMPLETION_IO_TIMEOUT_SECS * PQI_HZ)) {
+			PQI_WAIT_FOR_COMPLETION_IO_TIMEOUT_SECS * HZ)) {
 			rc = 0;
 			break;
 		}
@@ -6065,7 +6065,7 @@ static int pqi_wait_until_inbound_queues_empty(struct pqi_ctrl_info *ctrl_info)
 
 	displayed_warning = false;
 	start_jiffies = jiffies;
-	warning_timeout = (PQI_INBOUND_QUEUES_NONEMPTY_WARNING_TIMEOUT_SECS * PQI_HZ) + start_jiffies;
+	warning_timeout = (PQI_INBOUND_QUEUES_NONEMPTY_WARNING_TIMEOUT_SECS * HZ) + start_jiffies;
 
 	while (1) {
 		queued_io_count = pqi_queued_io_count(ctrl_info);
@@ -6080,7 +6080,7 @@ static int pqi_wait_until_inbound_queues_empty(struct pqi_ctrl_info *ctrl_info)
 				"waiting %u seconds for queued I/O to drain (queued I/O count: %u; non-empty inbound queue count: %u)\n",
 				jiffies_to_msecs(jiffies - start_jiffies) / 1000, queued_io_count, nonempty_inbound_queue_count);
 			displayed_warning = true;
-			warning_timeout = (PQI_INBOUND_QUEUES_NONEMPTY_WARNING_TIMEOUT_SECS * PQI_HZ) + jiffies;
+			warning_timeout = (PQI_INBOUND_QUEUES_NONEMPTY_WARNING_TIMEOUT_SECS * HZ) + jiffies;
 		}
 		usleep_range(1000, 2000);
 	}
@@ -6148,7 +6148,7 @@ static int pqi_device_wait_for_pending_io(struct pqi_ctrl_info *ctrl_info,
 	unsigned long msecs_waiting;
 
 	start_jiffies = jiffies;
-	warning_timeout = (PQI_PENDING_IO_WARNING_TIMEOUT_SECS * PQI_HZ) + start_jiffies;
+	warning_timeout = (PQI_PENDING_IO_WARNING_TIMEOUT_SECS * HZ) + start_jiffies;
 
 	while ((cmds_outstanding = atomic_read(&device->scsi_cmds_outstanding)) > 0) {
 		pqi_check_ctrl_health(ctrl_info);
@@ -6167,7 +6167,7 @@ static int pqi_device_wait_for_pending_io(struct pqi_ctrl_info *ctrl_info,
 				"scsi %d:%d:%d:%d: waiting %lu seconds for %d outstanding command(s)\n",
 				ctrl_info->scsi_host->host_no, device->bus, device->target,
 				device->lun, msecs_waiting / 1000, cmds_outstanding);
-			warning_timeout = (PQI_PENDING_IO_WARNING_TIMEOUT_SECS * PQI_HZ) + jiffies;
+			warning_timeout = (PQI_PENDING_IO_WARNING_TIMEOUT_SECS * HZ) + jiffies;
 		}
 		usleep_range(1000, 2000);
 	}
@@ -6196,7 +6196,7 @@ static int pqi_wait_for_lun_reset_completion(struct pqi_ctrl_info *ctrl_info,
 
 	while (1) {
 		if (wait_for_completion_io_timeout(wait,
-			PQI_LUN_RESET_POLL_COMPLETION_SECS * PQI_HZ)) {
+			PQI_LUN_RESET_POLL_COMPLETION_SECS * HZ)) {
 			rc = 0;
 			break;
 		}
@@ -7994,7 +7994,7 @@ static int pqi_ctrl_init(struct pqi_ctrl_info *ctrl_info)
 				return rc;
 		}
 		sis_soft_reset(ctrl_info);
-		msleep(PQI_POST_RESET_DELAY_SECS * PQI_HZ);
+		ssleep(PQI_POST_RESET_DELAY_SECS);
 	} else {
 		rc = pqi_force_sis_mode(ctrl_info);
 		if (rc)
diff --git a/drivers/scsi/smartpqi/smartpqi_sis.c b/drivers/scsi/smartpqi/smartpqi_sis.c
index d66eb8ea161c..e176a1a0534d 100644
--- a/drivers/scsi/smartpqi/smartpqi_sis.c
+++ b/drivers/scsi/smartpqi/smartpqi_sis.c
@@ -92,7 +92,7 @@ static int sis_wait_for_ctrl_ready_with_timeout(struct pqi_ctrl_info *ctrl_info,
 	unsigned long timeout;
 	u32 status;
 
-	timeout = (timeout_secs * PQI_HZ) + jiffies;
+	timeout = (timeout_secs * HZ) + jiffies;
 
 	while (1) {
 		status = readl(&ctrl_info->registers->sis_firmware_status);
@@ -209,7 +209,7 @@ static int sis_send_sync_cmd(struct pqi_ctrl_info *ctrl_info,
 	 * the top of the loop in order to give the controller time to start
 	 * processing the command before we start polling.
 	 */
-	timeout = (SIS_CMD_COMPLETE_TIMEOUT_SECS * PQI_HZ) + jiffies;
+	timeout = (SIS_CMD_COMPLETE_TIMEOUT_SECS * HZ) + jiffies;
 	while (1) {
 		msleep(SIS_CMD_COMPLETE_POLL_INTERVAL_MSECS);
 		doorbell = readl(&registers->sis_ctrl_to_host_doorbell);
@@ -355,7 +355,7 @@ static int sis_wait_for_doorbell_bit_to_clear(
 	u32 doorbell_register;
 	unsigned long timeout;
 
-	timeout = (SIS_DOORBELL_BIT_CLEAR_TIMEOUT_SECS * PQI_HZ) + jiffies;
+	timeout = (SIS_DOORBELL_BIT_CLEAR_TIMEOUT_SECS * HZ) + jiffies;
 
 	while (1) {
 		doorbell_register =
@@ -452,7 +452,7 @@ int sis_wait_for_fw_triage_completion(struct pqi_ctrl_info *ctrl_info)
 	enum sis_fw_triage_status status;
 	unsigned long timeout;
 
-	timeout = (SIS_FW_TRIAGE_STATUS_TIMEOUT_SECS * PQI_HZ) + jiffies;
+	timeout = (SIS_FW_TRIAGE_STATUS_TIMEOUT_SECS * HZ) + jiffies;
 	while (1) {
 		status = sis_read_firmware_triage_status(ctrl_info);
 		if (status == FW_TRIAGE_COND_INVALID) {



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

* [PATCH 09/18] smartpqi: avoid drive spin-down during suspend
  2022-02-01 21:47 [PATCH 00/18] smartpqi updates Don Brace
                   ` (7 preceding siblings ...)
  2022-02-01 21:48 ` [PATCH 08/18] smartpqi: resolve delay issue with PQI_HZ value Don Brace
@ 2022-02-01 21:48 ` Don Brace
  2022-02-01 21:48 ` [PATCH 10/18] smartpqi: update volume size after expansion Don Brace
                   ` (10 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Don Brace @ 2022-02-01 21:48 UTC (permalink / raw)
  To: Kevin.Barnett, scott.teel, Justin.Lindley, scott.benesh,
	gerry.morong, mahesh.rajashekhara, mike.mcgowen, murthy.bhat,
	hch, jejb, joseph.szczypek, POSWALD
  Cc: linux-scsi

From: Sagar Biradar <sagar.biradar@microchip.com>

Avoid drive spin-down during system RESTARTs.

On certain systems (based on PCI IDs), when the OS transitions the
system into the suspend (S3) state, the BMIC flush cache command
will indicate a system RESTART instead of SUSPEND.

This avoids drive spin-down.

Reviewed-by: Kevin Barnett <kevin.barnett@microchip.com>
Reviewed-by: Scott Benesh <scott.benesh@microchip.com>
Reviewed-by: Scott Teel <scott.teel@microchip.com>
Signed-off-by: Sagar Biradar <sagar.biradar@microchip.com>
Signed-off-by: Don Brace <don.brace@microchip.com>
---
 drivers/scsi/smartpqi/smartpqi_init.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index b32a5a5a5c21..ab12507da436 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -8976,10 +8976,19 @@ static void pqi_process_module_params(void)
 	pqi_process_lockup_action_param();
 }
 
+static inline enum bmic_flush_cache_shutdown_event pqi_get_flush_cache_shutdown_event(struct pci_dev *pci_dev)
+{
+	if (pci_dev->subsystem_vendor == PCI_VENDOR_ID_ADAPTEC2 && pci_dev->subsystem_device == 0x1304)
+		return RESTART;
+	return SUSPEND;
+}
+
 static __maybe_unused int pqi_suspend(struct pci_dev *pci_dev, pm_message_t state)
 {
 	struct pqi_ctrl_info *ctrl_info;
+	enum bmic_flush_cache_shutdown_event shutdown_event;
 
+	shutdown_event = pqi_get_flush_cache_shutdown_event(pci_dev);
 	ctrl_info = pci_get_drvdata(pci_dev);
 
 	pqi_wait_until_ofa_finished(ctrl_info);
@@ -8989,7 +8998,7 @@ static __maybe_unused int pqi_suspend(struct pci_dev *pci_dev, pm_message_t stat
 	pqi_ctrl_block_device_reset(ctrl_info);
 	pqi_ctrl_block_requests(ctrl_info);
 	pqi_ctrl_wait_until_quiesced(ctrl_info);
-	pqi_flush_cache(ctrl_info, SUSPEND);
+	pqi_flush_cache(ctrl_info, shutdown_event);
 	pqi_stop_heartbeat_timer(ctrl_info);
 
 	pqi_crash_if_pending_command(ctrl_info);



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

* [PATCH 10/18] smartpqi: update volume size after expansion
  2022-02-01 21:47 [PATCH 00/18] smartpqi updates Don Brace
                   ` (8 preceding siblings ...)
  2022-02-01 21:48 ` [PATCH 09/18] smartpqi: avoid drive spin-down during suspend Don Brace
@ 2022-02-01 21:48 ` Don Brace
  2022-02-01 21:48 ` [PATCH 11/18] smartpqi: fix kdump issue when ctrl is locked up Don Brace
                   ` (9 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Don Brace @ 2022-02-01 21:48 UTC (permalink / raw)
  To: Kevin.Barnett, scott.teel, Justin.Lindley, scott.benesh,
	gerry.morong, mahesh.rajashekhara, mike.mcgowen, murthy.bhat,
	hch, jejb, joseph.szczypek, POSWALD
  Cc: linux-scsi

From: Mahesh Rajashekhara <mahesh.rajashekhara@microchip.com>

Rescan devices after volume expansion.

After modifying logical volume size, lsblk command still shows up
previous size of logical volume.

When driver gets any event from f/w, driver schedules rescan worker
with delay of 10 seconds.

If array expansion is so quick and gets complete in a second,
driver could not catch logical volume expansion due to worker delay.

Since driver does not detect volume expansion, driver would not call
rescan device to update new size to the OS.

Reviewed-by: Kevin Barnett <kevin.barnett@microchip.com>
Reviewed-by: Mike McGowen <mike.mcgowen@microchip.com>
Reviewed-by: Scott Benesh <scott.benesh@microchip.com>
Reviewed-by: Scott Teel <scott.teel@microchip.com>
Signed-off-by: Mahesh Rajashekhara <mahesh.rajashekhara@microchip.com>
Signed-off-by: Don Brace <don.brace@microchip.com>
---
 drivers/scsi/smartpqi/smartpqi.h      |    1 +
 drivers/scsi/smartpqi/smartpqi_init.c |   20 ++++++++++++--------
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/smartpqi/smartpqi.h b/drivers/scsi/smartpqi/smartpqi.h
index 81ec5fbf570a..4f6e48854c66 100644
--- a/drivers/scsi/smartpqi/smartpqi.h
+++ b/drivers/scsi/smartpqi/smartpqi.h
@@ -1322,6 +1322,7 @@ struct pqi_ctrl_info {
 	bool		controller_online;
 	bool		block_requests;
 	bool		scan_blocked;
+	u8		logical_volume_rescan_needed : 1;
 	u8		inbound_spanning_supported : 1;
 	u8		outbound_spanning_supported : 1;
 	u8		pqi_mode_enabled : 1;
diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index ab12507da436..de53180fab9c 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -2015,8 +2015,8 @@ static void pqi_dev_info(struct pqi_ctrl_info *ctrl_info,
 
 /* Assumes the SCSI device list lock is held. */
 
-static void pqi_scsi_update_device(struct pqi_scsi_dev *existing_device,
-	struct pqi_scsi_dev *new_device)
+static void pqi_scsi_update_device(struct pqi_ctrl_info *ctrl_info,
+	struct pqi_scsi_dev *existing_device, struct pqi_scsi_dev *new_device)
 {
 	existing_device->device_type = new_device->device_type;
 	existing_device->bus = new_device->bus;
@@ -2026,9 +2026,8 @@ static void pqi_scsi_update_device(struct pqi_scsi_dev *existing_device,
 		existing_device->target_lun_valid = true;
 	}
 
-	if ((existing_device->volume_status == CISS_LV_QUEUED_FOR_EXPANSION ||
-		existing_device->volume_status == CISS_LV_UNDERGOING_EXPANSION) &&
-		new_device->volume_status == CISS_LV_OK)
+	if (pqi_is_logical_device(existing_device) &&
+		ctrl_info->logical_volume_rescan_needed)
 		existing_device->rescan = true;
 
 	/* By definition, the scsi3addr and wwid fields are already the same. */
@@ -2146,7 +2145,7 @@ static void pqi_update_device_list(struct pqi_ctrl_info *ctrl_info,
 			 */
 			device->new_device = false;
 			matching_device->device_gone = false;
-			pqi_scsi_update_device(matching_device, device);
+			pqi_scsi_update_device(ctrl_info, matching_device, device);
 			break;
 		case DEVICE_NOT_FOUND:
 			/*
@@ -2218,8 +2217,8 @@ static void pqi_update_device_list(struct pqi_ctrl_info *ctrl_info,
 	}
 
 	/*
-	 * Notify the SCSI ML if the queue depth of any existing device has
-	 * changed.
+	 * Notify the SML of any existing device changes such as;
+	 * queue depth, device size.
 	 */
 	list_for_each_entry(device, &ctrl_info->scsi_device_list, scsi_device_list_entry) {
 		if (device->sdev && device->queue_depth != device->advertised_queue_depth) {
@@ -2248,6 +2247,9 @@ static void pqi_update_device_list(struct pqi_ctrl_info *ctrl_info,
 			}
 		}
 	}
+
+	ctrl_info->logical_volume_rescan_needed = false;
+
 }
 
 static inline bool pqi_is_supported_device(struct pqi_scsi_dev *device)
@@ -3703,6 +3705,8 @@ static void pqi_event_worker(struct work_struct *work)
 			} else {
 				ack_event = true;
 				rescan_needed = true;
+				if (event->event_type == PQI_EVENT_TYPE_LOGICAL_DEVICE)
+					ctrl_info->logical_volume_rescan_needed = true;
 			}
 			if (ack_event)
 				pqi_acknowledge_event(ctrl_info, event);



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

* [PATCH 11/18] smartpqi: fix kdump issue when ctrl is locked up
  2022-02-01 21:47 [PATCH 00/18] smartpqi updates Don Brace
                   ` (9 preceding siblings ...)
  2022-02-01 21:48 ` [PATCH 10/18] smartpqi: update volume size after expansion Don Brace
@ 2022-02-01 21:48 ` Don Brace
  2022-02-01 21:48 ` [PATCH 12/18] smartpqi: speed up RAID 10 sequential reads Don Brace
                   ` (8 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Don Brace @ 2022-02-01 21:48 UTC (permalink / raw)
  To: Kevin.Barnett, scott.teel, Justin.Lindley, scott.benesh,
	gerry.morong, mahesh.rajashekhara, mike.mcgowen, murthy.bhat,
	hch, jejb, joseph.szczypek, POSWALD
  Cc: linux-scsi

From: Mahesh Rajashekhara <mahesh.rajashekhara@microchip.com>

Avoid dropping into shell if the controller is in locked up state.

Driver issues SIS soft reset to bring back the controller to SIS mode
while OS boots into kdump mode.

If the controller is in lockup state, SIS soft reset does not work.

Since the controller lockup code has not been cleared, driver considers
the firmware is no longer up and running. Driver returns back an error
code to OS and the kdump fails.

Reviewed-by: Kevin Barnett <kevin.barnett@microchip.com>
Reviewed-by: Scott Benesh <scott.benesh@microchip.com>
Reviewed-by: Scott Teel <scott.teel@microchip.com>
Signed-off-by: Mahesh Rajashekhara <mahesh.rajashekhara@microchip.com>
Signed-off-by: Don Brace <don.brace@microchip.com>
---
 drivers/scsi/smartpqi/smartpqi_init.c |   39 +++++++++++++++++++--------------
 1 file changed, 23 insertions(+), 16 deletions(-)

diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index de53180fab9c..8bd4de6306db 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -7986,6 +7986,21 @@ static int pqi_force_sis_mode(struct pqi_ctrl_info *ctrl_info)
 	return pqi_revert_to_sis_mode(ctrl_info);
 }
 
+static void pqi_perform_lockup_action(void)
+{
+	switch (pqi_lockup_action) {
+	case PANIC:
+		panic("FATAL: Smart Family Controller lockup detected");
+		break;
+	case REBOOT:
+		emergency_restart();
+		break;
+	case NONE:
+	default:
+		break;
+	}
+}
+
 static int pqi_ctrl_init(struct pqi_ctrl_info *ctrl_info)
 {
 	int rc;
@@ -8010,8 +8025,15 @@ static int pqi_ctrl_init(struct pqi_ctrl_info *ctrl_info)
 	 * commands.
 	 */
 	rc = sis_wait_for_ctrl_ready(ctrl_info);
-	if (rc)
+	if (rc) {
+		if (reset_devices) {
+			dev_err(&ctrl_info->pci_dev->dev,
+				"kdump init failed with error %d\n", rc);
+			pqi_lockup_action = REBOOT;
+			pqi_perform_lockup_action();
+		}
 		return rc;
+	}
 
 	/*
 	 * Get the controller properties.  This allows us to determine
@@ -8736,21 +8758,6 @@ static int pqi_ofa_ctrl_restart(struct pqi_ctrl_info *ctrl_info, unsigned int de
 	return pqi_ctrl_init_resume(ctrl_info);
 }
 
-static void pqi_perform_lockup_action(void)
-{
-	switch (pqi_lockup_action) {
-	case PANIC:
-		panic("FATAL: Smart Family Controller lockup detected");
-		break;
-	case REBOOT:
-		emergency_restart();
-		break;
-	case NONE:
-	default:
-		break;
-	}
-}
-
 static struct pqi_raid_error_info pqi_ctrl_offline_raid_error_info = {
 	.data_out_result = PQI_DATA_IN_OUT_HARDWARE_ERROR,
 	.status = SAM_STAT_CHECK_CONDITION,



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

* [PATCH 12/18] smartpqi: speed up RAID 10 sequential reads
  2022-02-01 21:47 [PATCH 00/18] smartpqi updates Don Brace
                   ` (10 preceding siblings ...)
  2022-02-01 21:48 ` [PATCH 11/18] smartpqi: fix kdump issue when ctrl is locked up Don Brace
@ 2022-02-01 21:48 ` Don Brace
  2022-02-01 21:48 ` [PATCH 13/18] smartpqi: expose SAS address for SATA drives Don Brace
                   ` (7 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Don Brace @ 2022-02-01 21:48 UTC (permalink / raw)
  To: Kevin.Barnett, scott.teel, Justin.Lindley, scott.benesh,
	gerry.morong, mahesh.rajashekhara, mike.mcgowen, murthy.bhat,
	hch, jejb, joseph.szczypek, POSWALD
  Cc: linux-scsi

From: Mike McGowen <Mike.McGowen@microchip.com>

Use all data disks for sequential read operations.

Testing discovered inconsistent performance on RAID 10 volumes
when performing 256K sequential reads.

The driver was only using a single tracker to determine which physical
drive to send a request to for AIO requests.

Change the single tracker (next_bypass_group) to an array of trackers
based on the number of data disks in a row of the RAID map.

Reviewed-by: Kevin Barnett <kevin.barnett@microchip.com>
Reviewed-by: Mike McGowen <mike.mcgowen@microchip.com>
Reviewed-by: Scott Benesh <scott.benesh@microchip.com>
Reviewed-by: Scott Teel <scott.teel@microchip.com>
Signed-off-by: Mike McGowen <Mike.McGowen@microchip.com>
Signed-off-by: Don Brace <don.brace@microchip.com>
---
 drivers/scsi/smartpqi/smartpqi.h      |    5 +++--
 drivers/scsi/smartpqi/smartpqi_init.c |    6 +++---
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/smartpqi/smartpqi.h b/drivers/scsi/smartpqi/smartpqi.h
index 4f6e48854c66..826c4001bac2 100644
--- a/drivers/scsi/smartpqi/smartpqi.h
+++ b/drivers/scsi/smartpqi/smartpqi.h
@@ -918,7 +918,8 @@ union pqi_reset_register {
 #define PQI_MAX_TRANSFER_SIZE			(1024U * 1024U)
 #define PQI_MAX_TRANSFER_SIZE_KDUMP		(512 * 1024U)
 
-#define RAID_MAP_MAX_ENTRIES		1024
+#define RAID_MAP_MAX_ENTRIES			1024
+#define RAID_MAP_MAX_DATA_DISKS_PER_ROW		128
 
 #define PQI_PHYSICAL_DEVICE_BUS		0
 #define PQI_RAID_VOLUME_BUS		1
@@ -1125,7 +1126,7 @@ struct pqi_scsi_dev {
 	u8	ncq_prio_support;
 	bool	raid_bypass_configured;	/* RAID bypass configured */
 	bool	raid_bypass_enabled;	/* RAID bypass enabled */
-	u32	next_bypass_group;
+	u32	next_bypass_group[RAID_MAP_MAX_DATA_DISKS_PER_ROW];
 	struct raid_map *raid_map;	/* RAID bypass map */
 	u32	max_transfer_encrypted;
 
diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index 8bd4de6306db..18c695202c52 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -2058,7 +2058,7 @@ static void pqi_scsi_update_device(struct pqi_ctrl_info *ctrl_info,
 		sizeof(existing_device->box));
 	memcpy(existing_device->phys_connector, new_device->phys_connector,
 		sizeof(existing_device->phys_connector));
-	existing_device->next_bypass_group = 0;
+	memset(existing_device->next_bypass_group, 0, sizeof(existing_device->next_bypass_group));
 	kfree(existing_device->raid_map);
 	existing_device->raid_map = new_device->raid_map;
 	existing_device->raid_bypass_configured =
@@ -2963,11 +2963,11 @@ static int pqi_raid_bypass_submit_scsi_cmd(struct pqi_ctrl_info *ctrl_info,
 		if (rmd.is_write) {
 			pqi_calc_aio_r1_nexus(raid_map, &rmd);
 		} else {
-			group = device->next_bypass_group;
+			group = device->next_bypass_group[rmd.map_index];
 			next_bypass_group = group + 1;
 			if (next_bypass_group >= rmd.layout_map_count)
 				next_bypass_group = 0;
-			device->next_bypass_group = next_bypass_group;
+			device->next_bypass_group[rmd.map_index] = next_bypass_group;
 			rmd.map_index += group * rmd.data_disks_per_row;
 		}
 	} else if ((device->raid_level == SA_RAID_5 ||



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

* [PATCH 13/18] smartpqi: expose SAS address for SATA drives
  2022-02-01 21:47 [PATCH 00/18] smartpqi updates Don Brace
                   ` (11 preceding siblings ...)
  2022-02-01 21:48 ` [PATCH 12/18] smartpqi: speed up RAID 10 sequential reads Don Brace
@ 2022-02-01 21:48 ` Don Brace
  2022-02-01 21:48 ` [PATCH 14/18] smartpqi: fix NUMA node not updated during init Don Brace
                   ` (6 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Don Brace @ 2022-02-01 21:48 UTC (permalink / raw)
  To: Kevin.Barnett, scott.teel, Justin.Lindley, scott.benesh,
	gerry.morong, mahesh.rajashekhara, mike.mcgowen, murthy.bhat,
	hch, jejb, joseph.szczypek, POSWALD
  Cc: linux-scsi

From: Kevin Barnett <kevin.barnett@microchip.com>

Remove UNIQUE_WWID_IN_REPORT_PHYS_LUN PQI feature.

This feature was originally added to solve a problem with NVMe drives,
but this problem has since been solved a different way, so this
PQI feature is no longer required for any type of drive.

Linux kernel was not creating symbolic links in sysfs between SATA
drives and their enclosure.

The driver was enabling the UNIQUE_WWID_IN_REPORT_PHYS_LUN PQI feature,
which causes the FW to return a WWID for SATA drives that is derived
from a unique ID read from the SATA drive itself. The driver was
exposing this WWID as the drive's SAS address. However, because this
SAS address does not match the SAS address returned by an enclosure's
SES Page 0xA data, the Linux kernel was not able to match a SATA
drive with its enclosure.

Reviewed-by: Mike McGowen <mike.mcgowen@microchip.com>
Reviewed-by: Scott Benesh <scott.benesh@microchip.com>
Reviewed-by: Scott Teel <scott.teel@microchip.com>
Signed-off-by: Kevin Barnett <kevin.barnett@microchip.com>
Signed-off-by: Don Brace <don.brace@microchip.com>
---
 drivers/scsi/smartpqi/smartpqi.h      |    2 --
 drivers/scsi/smartpqi/smartpqi_init.c |   43 ++-------------------------------
 2 files changed, 3 insertions(+), 42 deletions(-)

diff --git a/drivers/scsi/smartpqi/smartpqi.h b/drivers/scsi/smartpqi/smartpqi.h
index 826c4001bac2..c4c48272d8ad 100644
--- a/drivers/scsi/smartpqi/smartpqi.h
+++ b/drivers/scsi/smartpqi/smartpqi.h
@@ -1141,7 +1141,6 @@ struct pqi_scsi_dev {
 	struct pqi_stream_data stream_data[NUM_STREAMS_PER_LUN];
 	atomic_t scsi_cmds_outstanding;
 	atomic_t raid_bypass_cnt;
-	u8	page_83_identifier[16];
 };
 
 /* VPD inquiry pages */
@@ -1331,7 +1330,6 @@ struct pqi_ctrl_info {
 	u8		soft_reset_handshake_supported : 1;
 	u8		raid_iu_timeout_supported : 1;
 	u8		tmf_iu_timeout_supported : 1;
-	u8		unique_wwid_in_report_phys_lun_supported : 1;
 	u8		firmware_triage_supported : 1;
 	u8		rpl_extended_format_4_5_supported : 1;
 	u8		enable_r1_writes : 1;
diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index 18c695202c52..76ad919b0812 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -1588,9 +1588,6 @@ static int pqi_get_physical_device_info(struct pqi_ctrl_info *ctrl_info,
 		sizeof(device->phys_connector));
 	device->bay = id_phys->phys_bay_in_box;
 
-	memcpy(&device->page_83_identifier, &id_phys->page_83_identifier,
-		sizeof(device->page_83_identifier));
-
 	if ((id_phys->even_more_flags & PQI_DEVICE_PHY_MAP_SUPPORTED) &&
 		id_phys->phy_count)
 		device->phy_id =
@@ -2281,18 +2278,6 @@ static inline void pqi_mask_device(u8 *scsi3addr)
 	scsi3addr[3] |= 0xc0;
 }
 
-static inline bool pqi_is_device_with_sas_address(struct pqi_scsi_dev *device)
-{
-	switch (device->device_type) {
-	case SA_DEVICE_TYPE_SAS:
-	case SA_DEVICE_TYPE_EXPANDER_SMP:
-	case SA_DEVICE_TYPE_SES:
-		return true;
-	}
-
-	return false;
-}
-
 static inline bool pqi_is_multipath_device(struct pqi_scsi_dev *device)
 {
 	if (pqi_is_logical_device(device))
@@ -2306,17 +2291,6 @@ static inline bool pqi_expose_device(struct pqi_scsi_dev *device)
 	return !device->is_physical_device || !pqi_skip_device(device->scsi3addr);
 }
 
-static inline void pqi_set_physical_device_wwid(struct pqi_ctrl_info *ctrl_info,
-	struct pqi_scsi_dev *device, struct report_phys_lun_16byte_wwid *phys_lun)
-{
-	if (ctrl_info->unique_wwid_in_report_phys_lun_supported ||
-		ctrl_info->rpl_extended_format_4_5_supported ||
-		pqi_is_device_with_sas_address(device))
-		memcpy(device->wwid, phys_lun->wwid, sizeof(device->wwid));
-	else
-		memcpy(&device->wwid[8], device->page_83_identifier, 8);
-}
-
 static int pqi_update_scsi_devices(struct pqi_ctrl_info *ctrl_info)
 {
 	int i;
@@ -2484,7 +2458,7 @@ static int pqi_update_scsi_devices(struct pqi_ctrl_info *ctrl_info)
 		pqi_assign_bus_target_lun(device);
 
 		if (device->is_physical_device) {
-			pqi_set_physical_device_wwid(ctrl_info, device, phys_lun);
+			memcpy(device->wwid, phys_lun->wwid, sizeof(device->wwid));
 			if ((phys_lun->device_flags &
 				CISS_REPORT_PHYS_DEV_FLAG_AIO_ENABLED) &&
 				phys_lun->aio_handle) {
@@ -2497,8 +2471,7 @@ static int pqi_update_scsi_devices(struct pqi_ctrl_info *ctrl_info)
 				sizeof(device->volume_id));
 		}
 
-		if (pqi_is_device_with_sas_address(device))
-			device->sas_address = get_unaligned_be64(&device->wwid[8]);
+		device->sas_address = get_unaligned_be64(&device->wwid[8]);
 
 		new_device_list[num_valid_devices++] = device;
 	}
@@ -7087,7 +7060,7 @@ static ssize_t pqi_sas_address_show(struct device *dev,
 	spin_lock_irqsave(&ctrl_info->scsi_device_list_lock, flags);
 
 	device = sdev->hostdata;
-	if (!device || !pqi_is_device_with_sas_address(device)) {
+	if (!device) {
 		spin_unlock_irqrestore(&ctrl_info->scsi_device_list_lock, flags);
 		return -ENODEV;
 	}
@@ -7643,10 +7616,6 @@ static void pqi_ctrl_update_feature_flags(struct pqi_ctrl_info *ctrl_info,
 	case PQI_FIRMWARE_FEATURE_TMF_IU_TIMEOUT:
 		ctrl_info->tmf_iu_timeout_supported = firmware_feature->enabled;
 		break;
-	case PQI_FIRMWARE_FEATURE_UNIQUE_WWID_IN_REPORT_PHYS_LUN:
-		ctrl_info->unique_wwid_in_report_phys_lun_supported =
-			firmware_feature->enabled;
-		break;
 	case PQI_FIRMWARE_FEATURE_FW_TRIAGE:
 		ctrl_info->firmware_triage_supported = firmware_feature->enabled;
 		pqi_save_fw_triage_setting(ctrl_info, firmware_feature->enabled);
@@ -7744,11 +7713,6 @@ static struct pqi_firmware_feature pqi_firmware_features[] = {
 		.feature_bit = PQI_FIRMWARE_FEATURE_RAID_BYPASS_ON_ENCRYPTED_NVME,
 		.feature_status = pqi_firmware_feature_status,
 	},
-	{
-		.feature_name = "Unique WWID in Report Physical LUN",
-		.feature_bit = PQI_FIRMWARE_FEATURE_UNIQUE_WWID_IN_REPORT_PHYS_LUN,
-		.feature_status = pqi_ctrl_update_feature_flags,
-	},
 	{
 		.feature_name = "Firmware Triage",
 		.feature_bit = PQI_FIRMWARE_FEATURE_FW_TRIAGE,
@@ -7858,7 +7822,6 @@ static void pqi_ctrl_reset_config(struct pqi_ctrl_info *ctrl_info)
 	ctrl_info->enable_r6_writes = false;
 	ctrl_info->raid_iu_timeout_supported = false;
 	ctrl_info->tmf_iu_timeout_supported = false;
-	ctrl_info->unique_wwid_in_report_phys_lun_supported = false;
 	ctrl_info->firmware_triage_supported = false;
 	ctrl_info->rpl_extended_format_4_5_supported = false;
 }



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

* [PATCH 14/18] smartpqi: fix NUMA node not updated during init
  2022-02-01 21:47 [PATCH 00/18] smartpqi updates Don Brace
                   ` (12 preceding siblings ...)
  2022-02-01 21:48 ` [PATCH 13/18] smartpqi: expose SAS address for SATA drives Don Brace
@ 2022-02-01 21:48 ` Don Brace
  2022-02-01 21:49 ` [PATCH 15/18] smartpqi: fix BUILD_BUG_ON() statements Don Brace
                   ` (5 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Don Brace @ 2022-02-01 21:48 UTC (permalink / raw)
  To: Kevin.Barnett, scott.teel, Justin.Lindley, scott.benesh,
	gerry.morong, mahesh.rajashekhara, mike.mcgowen, murthy.bhat,
	hch, jejb, joseph.szczypek, POSWALD
  Cc: linux-scsi

From: Mike McGowen <Mike.McGowen@microchip.com>

Correct NUMA node association when calling pqi_pci_probe().

In the function pqi_pci_probe(), the driver makes an OS call to
get the NUMA node associated with a controller. If the call returns
that there is no associated node, the driver attempts to set it to
node 0. The problem is that a different local variable (cp_node)
was being used to do this, but the original local variable (node)
was still being used in the call to pqi_alloc_ctrl_info().

The value of "node" is not updated if the conditional after
the call to dev_to_node() evaluates to TRUE.

Reviewed-by: Kevin Barnett <kevin.barnett@microchip.com>
Reviewed-by: Scott Teel <scott.teel@microchip.com>
Signed-off-by: Mike McGowen <Mike.McGowen@microchip.com>
Signed-off-by: Don Brace <don.brace@microchip.com>
---
 drivers/scsi/smartpqi/smartpqi_init.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index 76ad919b0812..d886a9c860af 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -8811,7 +8811,7 @@ static int pqi_pci_probe(struct pci_dev *pci_dev,
 	const struct pci_device_id *id)
 {
 	int rc;
-	int node, cp_node;
+	int node;
 	struct pqi_ctrl_info *ctrl_info;
 
 	pqi_print_ctrl_info(pci_dev, id);
@@ -8830,10 +8830,10 @@ static int pqi_pci_probe(struct pci_dev *pci_dev,
 
 	node = dev_to_node(&pci_dev->dev);
 	if (node == NUMA_NO_NODE) {
-		cp_node = cpu_to_node(0);
-		if (cp_node == NUMA_NO_NODE)
-			cp_node = 0;
-		set_dev_node(&pci_dev->dev, cp_node);
+		node = cpu_to_node(0);
+		if (node == NUMA_NO_NODE)
+			node = 0;
+		set_dev_node(&pci_dev->dev, node);
 	}
 
 	ctrl_info = pqi_alloc_ctrl_info(node);



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

* [PATCH 15/18] smartpqi: fix BUILD_BUG_ON() statements
  2022-02-01 21:47 [PATCH 00/18] smartpqi updates Don Brace
                   ` (13 preceding siblings ...)
  2022-02-01 21:48 ` [PATCH 14/18] smartpqi: fix NUMA node not updated during init Don Brace
@ 2022-02-01 21:49 ` Don Brace
  2022-02-01 21:49 ` [PATCH 16/18] smartpqi: fix hibernate and suspend Don Brace
                   ` (4 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Don Brace @ 2022-02-01 21:49 UTC (permalink / raw)
  To: Kevin.Barnett, scott.teel, Justin.Lindley, scott.benesh,
	gerry.morong, mahesh.rajashekhara, mike.mcgowen, murthy.bhat,
	hch, jejb, joseph.szczypek, POSWALD
  Cc: linux-scsi

From: Mike McGowen <Mike.McGowen@microchip.com>

Add calls to the functions at the beginning driver initialization.

The BUILD_BUG_ON() statements that are currently in functions named
verify_structures() in the modules smartpqi_init.c and smartpqi_sis.c
do not work as currently implemented.

Reviewed-by: Kevin Barnett <kevin.barnett@microchip.com>
Reviewed-by: Scott Teel <scott.teel@microchip.com>
Reviewed-by: Scott Benesh <scott.benesh@microchip.com>
Signed-off-by: Mike McGowen <Mike.McGowen@microchip.com>
Signed-off-by: Don Brace <don.brace@microchip.com>
---
 drivers/scsi/smartpqi/smartpqi_init.c |    5 ++++-
 drivers/scsi/smartpqi/smartpqi_sis.c  |    2 +-
 drivers/scsi/smartpqi/smartpqi_sis.h  |    1 +
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index d886a9c860af..29cef682bde9 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -54,6 +54,7 @@ MODULE_DESCRIPTION("Driver for Microchip Smart Family Controller version "
 MODULE_VERSION(DRIVER_VERSION);
 MODULE_LICENSE("GPL");
 
+static void pqi_verify_structures(void);
 static void pqi_take_ctrl_offline(struct pqi_ctrl_info *ctrl_info,
 	enum pqi_ctrl_shutdown_reason ctrl_shutdown_reason);
 static void pqi_ctrl_offline_worker(struct work_struct *work);
@@ -9703,6 +9704,8 @@ static int __init pqi_init(void)
 	int rc;
 
 	pr_info(DRIVER_NAME "\n");
+	pqi_verify_structures();
+	sis_verify_structures();
 
 	pqi_sas_transport_template = sas_attach_transport(&pqi_sas_transport_functions);
 	if (!pqi_sas_transport_template)
@@ -9726,7 +9729,7 @@ static void __exit pqi_cleanup(void)
 module_init(pqi_init);
 module_exit(pqi_cleanup);
 
-static void __attribute__((unused)) verify_structures(void)
+static void pqi_verify_structures(void)
 {
 	BUILD_BUG_ON(offsetof(struct pqi_ctrl_registers,
 		sis_host_to_ctrl_doorbell) != 0x20);
diff --git a/drivers/scsi/smartpqi/smartpqi_sis.c b/drivers/scsi/smartpqi/smartpqi_sis.c
index e176a1a0534d..afc27adf68e9 100644
--- a/drivers/scsi/smartpqi/smartpqi_sis.c
+++ b/drivers/scsi/smartpqi/smartpqi_sis.c
@@ -479,7 +479,7 @@ int sis_wait_for_fw_triage_completion(struct pqi_ctrl_info *ctrl_info)
 	return rc;
 }
 
-static void __attribute__((unused)) verify_structures(void)
+void sis_verify_structures(void)
 {
 	BUILD_BUG_ON(offsetof(struct sis_base_struct,
 		revision) != 0x0);
diff --git a/drivers/scsi/smartpqi/smartpqi_sis.h b/drivers/scsi/smartpqi/smartpqi_sis.h
index bd92ff49f385..5f3575261a8e 100644
--- a/drivers/scsi/smartpqi/smartpqi_sis.h
+++ b/drivers/scsi/smartpqi/smartpqi_sis.h
@@ -12,6 +12,7 @@
 #if !defined(_SMARTPQI_SIS_H)
 #define _SMARTPQI_SIS_H
 
+void sis_verify_structures(void);
 int sis_wait_for_ctrl_ready(struct pqi_ctrl_info *ctrl_info);
 int sis_wait_for_ctrl_ready_resume(struct pqi_ctrl_info *ctrl_info);
 bool sis_is_firmware_running(struct pqi_ctrl_info *ctrl_info);



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

* [PATCH 16/18] smartpqi: fix hibernate and suspend
  2022-02-01 21:47 [PATCH 00/18] smartpqi updates Don Brace
                   ` (14 preceding siblings ...)
  2022-02-01 21:49 ` [PATCH 15/18] smartpqi: fix BUILD_BUG_ON() statements Don Brace
@ 2022-02-01 21:49 ` Don Brace
  2022-02-01 21:49 ` [PATCH 17/18] smartpqi: fix lsscsi-t SAS addresses Don Brace
                   ` (3 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Don Brace @ 2022-02-01 21:49 UTC (permalink / raw)
  To: Kevin.Barnett, scott.teel, Justin.Lindley, scott.benesh,
	gerry.morong, mahesh.rajashekhara, mike.mcgowen, murthy.bhat,
	hch, jejb, joseph.szczypek, POSWALD
  Cc: linux-scsi

From: Kevin Barnett <kevin.barnett@microchip.com>

Restructure the hibernate/suspend code to allow work-arounds for the
controller boot differences.

Newer controllers have subtle differences in the way that they bootup.

Reviewed-by: Mike McGowen <mike.mcgowen@microchip.com>
Reviewed-by: Scott Benesh <scott.benesh@microchip.com>
Reviewed-by: Scott Teel <scott.teel@microchip.com>
Signed-off-by: Kevin Barnett <kevin.barnett@microchip.com>
Signed-off-by: Don Brace <don.brace@microchip.com>
---
 drivers/scsi/smartpqi/smartpqi_init.c |  116 +++++++++++++++++++++++----------
 1 file changed, 81 insertions(+), 35 deletions(-)

diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index 29cef682bde9..3c3749fcb78c 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -8955,15 +8955,16 @@ static inline enum bmic_flush_cache_shutdown_event pqi_get_flush_cache_shutdown_
 {
 	if (pci_dev->subsystem_vendor == PCI_VENDOR_ID_ADAPTEC2 && pci_dev->subsystem_device == 0x1304)
 		return RESTART;
+
 	return SUSPEND;
 }
 
-static __maybe_unused int pqi_suspend(struct pci_dev *pci_dev, pm_message_t state)
+static int pqi_suspend_or_freeze(struct device *dev, bool suspend)
 {
+	struct pci_dev *pci_dev;
 	struct pqi_ctrl_info *ctrl_info;
-	enum bmic_flush_cache_shutdown_event shutdown_event;
 
-	shutdown_event = pqi_get_flush_cache_shutdown_event(pci_dev);
+	pci_dev = to_pci_dev(dev);
 	ctrl_info = pci_get_drvdata(pci_dev);
 
 	pqi_wait_until_ofa_finished(ctrl_info);
@@ -8973,16 +8974,17 @@ static __maybe_unused int pqi_suspend(struct pci_dev *pci_dev, pm_message_t stat
 	pqi_ctrl_block_device_reset(ctrl_info);
 	pqi_ctrl_block_requests(ctrl_info);
 	pqi_ctrl_wait_until_quiesced(ctrl_info);
-	pqi_flush_cache(ctrl_info, shutdown_event);
-	pqi_stop_heartbeat_timer(ctrl_info);
 
-	pqi_crash_if_pending_command(ctrl_info);
+	if (suspend) {
+		enum bmic_flush_cache_shutdown_event shutdown_event;
 
-	if (state.event == PM_EVENT_FREEZE)
-		return 0;
+		shutdown_event = pqi_get_flush_cache_shutdown_event(pci_dev);
+		pqi_flush_cache(ctrl_info, shutdown_event);
+	}
 
-	pci_save_state(pci_dev);
-	pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state));
+	pqi_stop_heartbeat_timer(ctrl_info);
+	pqi_crash_if_pending_command(ctrl_info);
+	pqi_free_irqs(ctrl_info);
 
 	ctrl_info->controller_online = false;
 	ctrl_info->pqi_mode_enabled = false;
@@ -8990,44 +8992,87 @@ static __maybe_unused int pqi_suspend(struct pci_dev *pci_dev, pm_message_t stat
 	return 0;
 }
 
-static __maybe_unused int pqi_resume(struct pci_dev *pci_dev)
+static __maybe_unused int pqi_suspend(struct device *dev)
+{
+	return pqi_suspend_or_freeze(dev, true);
+}
+
+static int pqi_resume_or_restore(struct device *dev)
 {
 	int rc;
+	struct pci_dev *pci_dev;
 	struct pqi_ctrl_info *ctrl_info;
 
+	pci_dev = to_pci_dev(dev);
 	ctrl_info = pci_get_drvdata(pci_dev);
 
-	if (pci_dev->current_state != PCI_D0) {
-		ctrl_info->max_hw_queue_index = 0;
-		pqi_free_interrupts(ctrl_info);
-		pqi_change_irq_mode(ctrl_info, IRQ_MODE_INTX);
-		rc = request_irq(pci_irq_vector(pci_dev, 0), pqi_irq_handler,
-			IRQF_SHARED, DRIVER_NAME_SHORT,
-			&ctrl_info->queue_groups[0]);
-		if (rc) {
-			dev_err(&ctrl_info->pci_dev->dev,
-				"irq %u init failed with error %d\n",
-				pci_dev->irq, rc);
-			return rc;
-		}
-		pqi_ctrl_unblock_device_reset(ctrl_info);
-		pqi_ctrl_unblock_requests(ctrl_info);
-		pqi_scsi_unblock_requests(ctrl_info);
-		pqi_ctrl_unblock_scan(ctrl_info);
-		return 0;
-	}
-
-	pci_set_power_state(pci_dev, PCI_D0);
-	pci_restore_state(pci_dev);
+	rc = pqi_request_irqs(ctrl_info);
+	if (rc)
+		return rc;
 
 	pqi_ctrl_unblock_device_reset(ctrl_info);
 	pqi_ctrl_unblock_requests(ctrl_info);
 	pqi_scsi_unblock_requests(ctrl_info);
 	pqi_ctrl_unblock_scan(ctrl_info);
 
+	ssleep(PQI_POST_RESET_DELAY_SECS);
+
 	return pqi_ctrl_init_resume(ctrl_info);
 }
 
+static int pqi_freeze(struct device *dev)
+{
+	return pqi_suspend_or_freeze(dev, false);
+}
+
+static int pqi_thaw(struct device *dev)
+{
+	int rc;
+	struct pci_dev *pci_dev;
+	struct pqi_ctrl_info *ctrl_info;
+
+	pci_dev = to_pci_dev(dev);
+	ctrl_info = pci_get_drvdata(pci_dev);
+
+	rc = pqi_request_irqs(ctrl_info);
+	if (rc)
+		return rc;
+
+	ctrl_info->controller_online = true;
+	ctrl_info->pqi_mode_enabled = true;
+
+	pqi_ctrl_unblock_device_reset(ctrl_info);
+	pqi_ctrl_unblock_requests(ctrl_info);
+	pqi_scsi_unblock_requests(ctrl_info);
+	pqi_ctrl_unblock_scan(ctrl_info);
+
+	return 0;
+}
+
+static int pqi_poweroff(struct device *dev)
+{
+	struct pci_dev *pci_dev;
+	struct pqi_ctrl_info *ctrl_info;
+	enum bmic_flush_cache_shutdown_event shutdown_event;
+
+	pci_dev = to_pci_dev(dev);
+	ctrl_info = pci_get_drvdata(pci_dev);
+
+	shutdown_event = pqi_get_flush_cache_shutdown_event(pci_dev);
+	pqi_flush_cache(ctrl_info, shutdown_event);
+
+	return 0;
+}
+
+static const struct dev_pm_ops pqi_pm_ops = {
+	.suspend = pqi_suspend,
+	.resume = pqi_resume_or_restore,
+	.freeze = pqi_freeze,
+	.thaw = pqi_thaw,
+	.poweroff = pqi_poweroff,
+	.restore = pqi_resume_or_restore,
+};
+
 /* Define the PCI IDs for the controllers that we support. */
 static const struct pci_device_id pqi_pci_id_table[] = {
 	{
@@ -9694,8 +9739,9 @@ static struct pci_driver pqi_pci_driver = {
 	.remove = pqi_pci_remove,
 	.shutdown = pqi_shutdown,
 #if defined(CONFIG_PM)
-	.suspend = pqi_suspend,
-	.resume = pqi_resume,
+	.driver = {
+		.pm = &pqi_pm_ops
+	},
 #endif
 };
 



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

* [PATCH 17/18] smartpqi: fix lsscsi-t SAS addresses
  2022-02-01 21:47 [PATCH 00/18] smartpqi updates Don Brace
                   ` (15 preceding siblings ...)
  2022-02-01 21:49 ` [PATCH 16/18] smartpqi: fix hibernate and suspend Don Brace
@ 2022-02-01 21:49 ` Don Brace
  2022-02-01 21:49 ` [PATCH 18/18] smartpqi: update version to 2.1.14-035 Don Brace
                   ` (2 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Don Brace @ 2022-02-01 21:49 UTC (permalink / raw)
  To: Kevin.Barnett, scott.teel, Justin.Lindley, scott.benesh,
	gerry.morong, mahesh.rajashekhara, mike.mcgowen, murthy.bhat,
	hch, jejb, joseph.szczypek, POSWALD
  Cc: linux-scsi

From: Kevin Barnett <kevin.barnett@microchip.com>

Correct lsscsi -t output for newer controllers that support
16-byte WWID in the SAS address field.

lsscsi -t was displaying all zeros for SAS addresses.

When we added support to smartpqi for 16-byte WWIDs in the RPL data for
newer controllers, we were copying the wrong part of the 16-byte WWID
to the SAS address field.

Reviewed-by: Scott Benesh <scott.benesh@microchip.com>
Reviewed-by: Scott Teel <scott.teel@microchip.com>
Reviewed-by: Mike McGowen <mike.mcgowen@microchip.com>
Signed-off-by: Kevin Barnett <kevin.barnett@microchip.com>
Signed-off-by: Don Brace <don.brace@microchip.com>
---
 drivers/scsi/smartpqi/smartpqi_init.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index 3c3749fcb78c..be4e91aaaa52 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -1182,8 +1182,8 @@ static inline int pqi_report_phys_luns(struct pqi_ctrl_info *ctrl_info, void **b
 
 	for (i = 0; i < num_physicals; i++) {
 		memcpy(&rpl_16byte_wwid_list->lun_entries[i].lunid, &rpl_8byte_wwid_list->lun_entries[i].lunid, sizeof(rpl_8byte_wwid_list->lun_entries[i].lunid));
-		memset(&rpl_16byte_wwid_list->lun_entries[i].wwid, 0, 8);
-		memcpy(&rpl_16byte_wwid_list->lun_entries[i].wwid[8], &rpl_8byte_wwid_list->lun_entries[i].wwid, sizeof(rpl_8byte_wwid_list->lun_entries[i].wwid));
+		memcpy(&rpl_16byte_wwid_list->lun_entries[i].wwid[0], &rpl_8byte_wwid_list->lun_entries[i].wwid, sizeof(rpl_8byte_wwid_list->lun_entries[i].wwid));
+		memset(&rpl_16byte_wwid_list->lun_entries[i].wwid[8], 0, 8);
 		rpl_16byte_wwid_list->lun_entries[i].device_type = rpl_8byte_wwid_list->lun_entries[i].device_type;
 		rpl_16byte_wwid_list->lun_entries[i].device_flags = rpl_8byte_wwid_list->lun_entries[i].device_flags;
 		rpl_16byte_wwid_list->lun_entries[i].lun_count = rpl_8byte_wwid_list->lun_entries[i].lun_count;
@@ -2472,7 +2472,7 @@ static int pqi_update_scsi_devices(struct pqi_ctrl_info *ctrl_info)
 				sizeof(device->volume_id));
 		}
 
-		device->sas_address = get_unaligned_be64(&device->wwid[8]);
+		device->sas_address = get_unaligned_be64(&device->wwid[0]);
 
 		new_device_list[num_valid_devices++] = device;
 	}



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

* [PATCH 18/18] smartpqi: update version to 2.1.14-035
  2022-02-01 21:47 [PATCH 00/18] smartpqi updates Don Brace
                   ` (16 preceding siblings ...)
  2022-02-01 21:49 ` [PATCH 17/18] smartpqi: fix lsscsi-t SAS addresses Don Brace
@ 2022-02-01 21:49 ` Don Brace
  2022-02-08  4:40 ` [PATCH 00/18] smartpqi updates Martin K. Petersen
  2022-02-11 23:25 ` Martin K. Petersen
  19 siblings, 0 replies; 21+ messages in thread
From: Don Brace @ 2022-02-01 21:49 UTC (permalink / raw)
  To: Kevin.Barnett, scott.teel, Justin.Lindley, scott.benesh,
	gerry.morong, mahesh.rajashekhara, mike.mcgowen, murthy.bhat,
	hch, jejb, joseph.szczypek, POSWALD
  Cc: linux-scsi

Reviewed-by: Kevin Barnett <kevin.barnett@microchip.com>
Reviewed-by: Scott Benesh <scott.benesh@microchip.com>
Reviewed-by: Scott Teel <scott.teel@microchip.com>
Reviewed-by: Gerry Morong <gerry.morong@microchip.com>
Signed-off-by: Don Brace <don.brace@microchip.com>
---
 drivers/scsi/smartpqi/smartpqi_init.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index be4e91aaaa52..61366642ea95 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -33,11 +33,11 @@
 #define BUILD_TIMESTAMP
 #endif
 
-#define DRIVER_VERSION		"2.1.12-055"
+#define DRIVER_VERSION		"2.1.14-035"
 #define DRIVER_MAJOR		2
 #define DRIVER_MINOR		1
-#define DRIVER_RELEASE		12
-#define DRIVER_REVISION		55
+#define DRIVER_RELEASE		14
+#define DRIVER_REVISION		35
 
 #define DRIVER_NAME		"Microchip SmartPQI Driver (v" \
 				DRIVER_VERSION BUILD_TIMESTAMP ")"



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

* Re: [PATCH 00/18] smartpqi updates
  2022-02-01 21:47 [PATCH 00/18] smartpqi updates Don Brace
                   ` (17 preceding siblings ...)
  2022-02-01 21:49 ` [PATCH 18/18] smartpqi: update version to 2.1.14-035 Don Brace
@ 2022-02-08  4:40 ` Martin K. Petersen
  2022-02-11 23:25 ` Martin K. Petersen
  19 siblings, 0 replies; 21+ messages in thread
From: Martin K. Petersen @ 2022-02-08  4:40 UTC (permalink / raw)
  To: Don Brace
  Cc: Kevin.Barnett, scott.teel, Justin.Lindley, scott.benesh,
	gerry.morong, mahesh.rajashekhara, mike.mcgowen, murthy.bhat,
	hch, jejb, joseph.szczypek, POSWALD, linux-scsi


Don,

>  * Bump the driver version to 2.1.14-035

Applied to 5.18/scsi-staging, thanks!

Next time please run checkpatch!

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH 00/18] smartpqi updates
  2022-02-01 21:47 [PATCH 00/18] smartpqi updates Don Brace
                   ` (18 preceding siblings ...)
  2022-02-08  4:40 ` [PATCH 00/18] smartpqi updates Martin K. Petersen
@ 2022-02-11 23:25 ` Martin K. Petersen
  19 siblings, 0 replies; 21+ messages in thread
From: Martin K. Petersen @ 2022-02-11 23:25 UTC (permalink / raw)
  To: scott.teel, scott.benesh, jejb, POSWALD, joseph.szczypek,
	murthy.bhat, gerry.morong, Don Brace, mahesh.rajashekhara,
	Justin.Lindley, hch, mike.mcgowen, Kevin.Barnett
  Cc: Martin K . Petersen, linux-scsi

On Tue, 1 Feb 2022 15:47:47 -0600, Don Brace wrote:

> These patches are based on Martin Petersen's 5.18/scsi-queue tree
>   https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git
>   5.18/scsi-queue
> 
> This set of changes consist of:
>  * Correcting a stack trace when the driver is unloaded. The driver was
>    holding a spin lock when calling scsi_remove_device.
>  * Adding in new PCI device IDs and aligning the device order with our
>    out-of-box driver. No functional changes.
>  * Allow NCQ to be enabled for SATA disks. The controller firmware has
>    to have support for this feature.
>  * Enhance reboot performance by now issuing disk spin-downs during
>    reboots. This eliminates spin-up time required doing the boot up.
>  * Speed up multipath failover detection by returning DID_NO_CONNECT
>    when the controller returns a path failure. Previously, the driver was
>    waiting on an internal re-scan to detect the path failure.
>  * Change function name pqi_is_io_high_priority() to
>    pqi_is_io_high_priority() for better readability. Remove some white
>    spaces from the same function.
>  * Correct the structure used for AIO command submission. The structure
>    used was pqi_raid_path_request, but needs to be pqi_aio_path_request.
>    Both structure are the same size and have the same member offsets,
>    so no issues were reported.
>  * A PQI_HZ MACRO was introduced some time ago to resolve some timing
>    issues. This definition is not needed. Switch back to using HZ.
>  * For certain controllers, there was a request to avoid a drive
>    spin-down for suspend (S3) state transitions.
>  * For small drive expansions, the driver was not detecting the new
>    size changes. We added a rescan whenever the driver receives an
>    event from the controller.
>  * In some rare cases, the controller can be locked up when a kdump
>    is requested. When this occurs, the kdump is failed. This helps
>    in debugging the cause of the lockup.
>  * For RAID 10 disks, only one set of disks were used for read
>    operations. Now we spread out I/O to all volumes. This resolves
>    some inconsistent performance issues.
>  * Export SAS addresses for all disks instead of only SAS disks.
>  * Correct NUMA node association during pci_probe. A small typo
>    was causing a different NUMA node to be set.
>  * Not all structures were checked with BUILD_BUG_ON.
>  * Correct some rare Hibernate/Suspend issues. Newer controllers
>    may boot up with different timings.
>  * Correct WWID output for lsscsi -t. The wrong part of the 16-byte WWID
>    was used for the SAS address field.
>  * Bump the driver version to 2.1.14-035
> 
> [...]

Applied to 5.18/scsi-queue, thanks!

[01/18] smartpqi: fix rmmod stack trace
        https://git.kernel.org/mkp/scsi/c/c4ff687d25c0
[02/18] smartpqi: add PCI IDs
        https://git.kernel.org/mkp/scsi/c/c57ee4ccb358
[03/18] smartpqi: enable SATA NCQ priority in sysfs
        https://git.kernel.org/mkp/scsi/c/2a47834d9452
[04/18] smartpqi: eliminate drive spin down on warm boot
        https://git.kernel.org/mkp/scsi/c/70ba20be4bb1
[05/18] smartpqi: propagate path failures to SML quickly
        https://git.kernel.org/mkp/scsi/c/94a68c814328
[06/18] smartpqi: fix a name typo and cleanup code
        https://git.kernel.org/mkp/scsi/c/b4dc06a9070e
[07/18] smartpqi: fix a typo in func pqi_aio_submit_io
        https://git.kernel.org/mkp/scsi/c/9e98e60bfca3
[08/18] smartpqi: resolve delay issue with PQI_HZ value
        https://git.kernel.org/mkp/scsi/c/42dc0426fbbb
[09/18] smartpqi: avoid drive spin-down during suspend
        https://git.kernel.org/mkp/scsi/c/b73357a1fd39
[10/18] smartpqi: update volume size after expansion
        https://git.kernel.org/mkp/scsi/c/27655e9db479
[11/18] smartpqi: fix kdump issue when ctrl is locked up
        https://git.kernel.org/mkp/scsi/c/3ada501d602a
[12/18] smartpqi: speed up RAID 10 sequential reads
        https://git.kernel.org/mkp/scsi/c/5d8fbce04d36
[13/18] smartpqi: expose SAS address for SATA drives
        https://git.kernel.org/mkp/scsi/c/00598b056aa6
[14/18] smartpqi: fix NUMA node not updated during init
        https://git.kernel.org/mkp/scsi/c/c52efc923856
[15/18] smartpqi: fix BUILD_BUG_ON() statements
        https://git.kernel.org/mkp/scsi/c/5e6935864d81
[16/18] smartpqi: fix hibernate and suspend
        https://git.kernel.org/mkp/scsi/c/c66e078ad89e
[17/18] smartpqi: fix lsscsi-t SAS addresses
        https://git.kernel.org/mkp/scsi/c/291c2e0071ef
[18/18] smartpqi: update version to 2.1.14-035
        https://git.kernel.org/mkp/scsi/c/62ed6622aaf0

-- 
Martin K. Petersen	Oracle Linux Engineering

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

end of thread, other threads:[~2022-02-11 23:25 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-01 21:47 [PATCH 00/18] smartpqi updates Don Brace
2022-02-01 21:47 ` [PATCH 01/18] smartpqi: fix rmmod stack trace Don Brace
2022-02-01 21:47 ` [PATCH 02/18] smartpqi: add PCI IDs Don Brace
2022-02-01 21:48 ` [PATCH 03/18] smartpqi: enable SATA NCQ priority in sysfs Don Brace
2022-02-01 21:48 ` [PATCH 04/18] smartpqi: eliminate drive spin down on warm boot Don Brace
2022-02-01 21:48 ` [PATCH 05/18] smartpqi: propagate path failures to SML quickly Don Brace
2022-02-01 21:48 ` [PATCH 06/18] smartpqi: fix a name typo and cleanup code Don Brace
2022-02-01 21:48 ` [PATCH 07/18] smartpqi: fix a typo in func pqi_aio_submit_io Don Brace
2022-02-01 21:48 ` [PATCH 08/18] smartpqi: resolve delay issue with PQI_HZ value Don Brace
2022-02-01 21:48 ` [PATCH 09/18] smartpqi: avoid drive spin-down during suspend Don Brace
2022-02-01 21:48 ` [PATCH 10/18] smartpqi: update volume size after expansion Don Brace
2022-02-01 21:48 ` [PATCH 11/18] smartpqi: fix kdump issue when ctrl is locked up Don Brace
2022-02-01 21:48 ` [PATCH 12/18] smartpqi: speed up RAID 10 sequential reads Don Brace
2022-02-01 21:48 ` [PATCH 13/18] smartpqi: expose SAS address for SATA drives Don Brace
2022-02-01 21:48 ` [PATCH 14/18] smartpqi: fix NUMA node not updated during init Don Brace
2022-02-01 21:49 ` [PATCH 15/18] smartpqi: fix BUILD_BUG_ON() statements Don Brace
2022-02-01 21:49 ` [PATCH 16/18] smartpqi: fix hibernate and suspend Don Brace
2022-02-01 21:49 ` [PATCH 17/18] smartpqi: fix lsscsi-t SAS addresses Don Brace
2022-02-01 21:49 ` [PATCH 18/18] smartpqi: update version to 2.1.14-035 Don Brace
2022-02-08  4:40 ` [PATCH 00/18] smartpqi updates Martin K. Petersen
2022-02-11 23:25 ` Martin K. Petersen

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.