Skip to contentSkip to conversation

smartpqi updates

PATCH Applied Don Brace 2 participants 15 messages Apr 28, 2023 – May 17, 2023

Subsystems (2)
lore
Share & tools
lore

Don Brace

author maintainer
#0 lore raw

cover smartpqi updates

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

This set of changes consists of:

* Map entire BAR 0.
The driver was mapping up to and including the controller registers, but not all of BAR 0.
* Add PCI IDs to support new controllers.
* Clean up some code by removing unnecessary NULL checks.
This cleanup is a result of a Coverity report.
* Correct a rare memory leak whenever pqi_sas_port_add_rhpy() returns an error. This was Suggested by: Yang Yingliang <[email protected]>
* Remove atomic operations on variable raid_bypass_cnt. Accuracy is not required for driver operation. Change type from atomic_t to unsigned int.
* Correct a rare drive hot-plug removal issue where we get a NULL io_request. We added a check for this condition.
* Turn on NCQ priority for AIO requests to disks comprising RAID devices.
* Correct byte aligned writew() operations on some ARM servers. Changed the writew() to two writeb() operations.
* Change how the driver checks for a sanitize operation in progress. We were using TEST UNIT READY. We removed the TEST UNIT READY code and are now using the controller's firmware information in order to avoid issues caused by drives failing to complete TEST UNIT READY.
* Some customers have been requesting that we add the NUMA node to /sys/block/sd<scsi device>/device like the nvme driver does.
* Update the copyright information to match the current year.
* Bump the driver version to 2.1.22-040.

---

David Strahan (1):
smartpqi: Add new controller PCI IDs

Don Brace (5):
smartpqi: fix-rare-sas-transport-mem-leak
smartpqi: fix byte aligned writew for ARM servers
smartpqi: Add sysfs entry for numa node in /sys/block/sdX/device.
smartpqi: update copyright to 2023
smartpqi: update version to 2.1.22-040

Gilbert Wu (1):
smartpqi: Add support for RAID NCQ priority

Kevin Barnett (2):
smartpqi: remove null pointer check
smartpqi: stop sending driver initiated TURs

Mike McGowen (2):
smartpqi: map full length of PCI BAR 0
smartpqi: Remove contention for raid_bypass_cnt

Murthy Bhat (1):
smartpqi: validate block layer host tag

 drivers/scsi/smartpqi/Kconfig                 |   2 +-
 drivers/scsi/smartpqi/smartpqi.h              |   6 +-
 drivers/scsi/smartpqi/smartpqi_init.c         | 284 ++++++++++--------
 .../scsi/smartpqi/smartpqi_sas_transport.c    |  34 +--
 drivers/scsi/smartpqi/smartpqi_sis.c          |   2 +-
 drivers/scsi/smartpqi/smartpqi_sis.h          |   2 +-
 6 files changed, 178 insertions(+), 152 deletions(-)
Signature · 1 line
2.40.1.375.g9ce9dea4e1
author maintainer
#1 lore raw

PATCH 1/12 smartpqi: map full length of PCI BAR 0

From: Mike McGowen <[email protected]>

Map full length of PCI BAR 0 at driver init.

During driver initialization, the driver must make a kernel call to map the controller registers into kernel address space. A parameter to this call is the length of the memory to be mapped. The driver is specifying the wrong length.

---
 drivers/scsi/smartpqi/smartpqi_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/smartpqi/smartpqi_init.c +1 -1
index 03de97cd72c2..29370757b07b 100644
@@ -8560,7 +8560,7 @@ static int pqi_pci_init(struct pqi_ctrl_info *ctrl_info)
 
 	ctrl_info->iomem_base = ioremap(pci_resource_start(
 		ctrl_info->pci_dev, 0),
-		sizeof(struct pqi_ctrl_registers));
+		pci_resource_len(ctrl_info->pci_dev, 0));
 	if (!ctrl_info->iomem_base) {
 		dev_err(&ctrl_info->pci_dev->dev,
 			"failed to map memory for controller registers\n");
Signature · 1 line
2.40.1.375.g9ce9dea4e1
author maintainer
#2 lore raw

PATCH 2/12 smartpqi: Add new controller PCI IDs

In reply to Don Brace

From: David Strahan <[email protected]>

All PCI ID entries in Hex.

Add PCI IDs for ZTE controllers:

                                            VID  / DID  / SVID / SDID
                                            ----   ----   ----   ----
    ZTE SmartROC3200 RS344-16i 4G           9005 / 028f / 1cf2 / 0804
    ZTE SmartROC3200 RS345-16i 8G           9005 / 028f / 1cf2 / 0805
    ZTE SmartIOC2200 RS346-16i              9005 / 028f / 1cf2 / 0806
    ZTE SmartROC3200 RM344-16i 4G           9005 / 028f / 1cf2 / 54da
    ZTE SmartROC3200 RM345-16i 8G           9005 / 028f / 1cf2 / 54db
    ZTE SmartIOC2200 RM346-16i              9005 / 028f / 1cf2 / 54dc

Add PCI IDs for ByteDance controllers:

                                            VID  / DID  / SVID / SDID
                                            ----   ----   ----   ----
    ByteHBA JGH43014-8                      9005 / 028f / 1e93 / 1005

Add PCI IDs for IBM controllers:

                                            VID  / DID  / SVID / SDID
                                            ----   ----   ----   ----
    IBM 4-Port 24G SAS                      9005 / 028f / 1014 / 0718

Add PCI IDs for Cloudnine controllers:

                                            VID  / DID  / SVID / SDID
                                            ----   ----   ----   ----
    SmartHBA P6600-8i                       9005 / 028f / 1f51 / 1001
    SmartRAID P7604-8i                      9005 / 028f / 1f51 / 1002
    SmartHBA P6600-8e                       9005 / 028f / 1f51 / 1003
    SmartRAID P7604-8e                      9005 / 028f / 1f51 / 1004
    SmartHBA P6600-16i                      9005 / 028f / 1f51 / 1005
    SmartRAID P7608-16i                     9005 / 028f / 1f51 / 1006
    SmartHBA P6600-8i8e                     9005 / 028f / 1f51 / 1007
    SmartRAID P7608-8i8e                    9005 / 028f / 1f51 / 1008
    SmartHBA P6600-16e                      9005 / 028f / 1f51 / 1009
    SmartRAID P7608-16e                     9005 / 028f / 1f51 / 100a
---
 drivers/scsi/smartpqi/smartpqi_init.c | 72 +++++++++++++++++++++++++++
 1 file changed, 72 insertions(+)
drivers/scsi/smartpqi/smartpqi_init.c +72 -0
index 29370757b07b..3daad878bafa 100644
@@ -9927,6 +9927,18 @@ static const struct pci_device_id pqi_pci_id_table[] = {
 		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
 			       0x1f0c, 0x3161)
 	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+			       0x1cf2, 0x0804)
+	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+			       0x1cf2, 0x0805)
+	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+			       0x1cf2, 0x0806)
+	},
 	{
 		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
 			       0x1cf2, 0x5445)
@@ -9963,6 +9975,18 @@ static const struct pci_device_id pqi_pci_id_table[] = {
 		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
 			       0x1cf2, 0x544f)
 	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+			       0x1cf2, 0x54da)
+	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+			       0x1cf2, 0x54db)
+	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+			       0x1cf2, 0x54dc)
+	},
 	{
 		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
 			       0x1cf2, 0x0b27)
@@ -10015,6 +10039,10 @@ static const struct pci_device_id pqi_pci_id_table[] = {
 		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
 			       PCI_VENDOR_ID_LENOVO, 0x0623)
 	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+				0x1014, 0x0718)
+	},
 	{
 		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
 				0x1e93, 0x1000)
@@ -10027,6 +10055,50 @@ static const struct pci_device_id pqi_pci_id_table[] = {
 		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
 				0x1e93, 0x1002)
 	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+				0x1e93, 0x1005)
+	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+				0x1f51, 0x1001)
+	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+				0x1f51, 0x1002)
+	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+				0x1f51, 0x1003)
+	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+				0x1f51, 0x1004)
+	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+				0x1f51, 0x1005)
+	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+				0x1f51, 0x1006)
+	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+				0x1f51, 0x1007)
+	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+				0x1f51, 0x1008)
+	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+				0x1f51, 0x1009)
+	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+				0x1f51, 0x100a)
+	},
 	{
 		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
 			       PCI_ANY_ID, PCI_ANY_ID)
Signature · 1 line
2.40.1.375.g9ce9dea4e1
author maintainer
#3 lore raw

PATCH 3/12 smartpqi: remove null pointer check

In reply to Don Brace

From: Kevin Barnett <[email protected]>

Remove an unnecessary check for a null pointer. This unnecessary check was flagged by Coverity.

---
 .../scsi/smartpqi/smartpqi_sas_transport.c    | 28 +++++++++----------
 1 file changed, 13 insertions(+), 15 deletions(-)
drivers/scsi/smartpqi/smartpqi_sas_transport.c +13 -15
index 13e8c539010e..52dbe37364bf 100644
@@ -92,25 +92,23 @@ static int pqi_sas_port_add_rphy(struct pqi_sas_port *pqi_sas_port,
 
 	identify = &rphy->identify;
 	identify->sas_address = pqi_sas_port->sas_address;
+	identify->phy_identifier = pqi_sas_port->device->phy_id;
 
 	identify->initiator_port_protocols = SAS_PROTOCOL_ALL;
 	identify->target_port_protocols = SAS_PROTOCOL_STP;
 
-	if (pqi_sas_port->device) {
-		identify->phy_identifier = pqi_sas_port->device->phy_id;
-		switch (pqi_sas_port->device->device_type) {
-		case SA_DEVICE_TYPE_SAS:
-		case SA_DEVICE_TYPE_SES:
-		case SA_DEVICE_TYPE_NVME:
-			identify->target_port_protocols = SAS_PROTOCOL_SSP;
-			break;
-		case SA_DEVICE_TYPE_EXPANDER_SMP:
-			identify->target_port_protocols = SAS_PROTOCOL_SMP;
-			break;
-		case SA_DEVICE_TYPE_SATA:
-		default:
-			break;
-		}
+	switch (pqi_sas_port->device->device_type) {
+	case SA_DEVICE_TYPE_SAS:
+	case SA_DEVICE_TYPE_SES:
+	case SA_DEVICE_TYPE_NVME:
+		identify->target_port_protocols = SAS_PROTOCOL_SSP;
+		break;
+	case SA_DEVICE_TYPE_EXPANDER_SMP:
+		identify->target_port_protocols = SAS_PROTOCOL_SMP;
+		break;
+	case SA_DEVICE_TYPE_SATA:
+	default:
+		break;
 	}
 
 	return sas_rphy_add(rphy);
Signature · 1 line
2.40.1.375.g9ce9dea4e1
author maintainer
#4 lore raw

PATCH 4/12 smartpqi: fix-rare-sas-transport-mem-leak

In reply to Don Brace

Free rphy when pqi_sas_port_add_rphy() returns an error.

If pqi_sas_port_add_rphy() returns an error, the 'rphy' allocated in sas_end_device_alloc() needs to be freed.

It should be noted that no issues were ever reported.

---
 drivers/scsi/smartpqi/smartpqi_sas_transport.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/scsi/smartpqi/smartpqi_sas_transport.c +3 -1
index 52dbe37364bf..36b90b55cf5f 100644
@@ -293,10 +293,12 @@ int pqi_add_sas_device(struct pqi_sas_node *pqi_sas_node,
 
 	rc = pqi_sas_port_add_rphy(pqi_sas_port, rphy);
 	if (rc)
-		goto free_sas_port;
+		goto free_sas_rphy;
 
 	return 0;
 
+free_sas_rphy:
+	sas_rphy_free(rphy);
 free_sas_port:
 	pqi_free_sas_port(pqi_sas_port);
 	device->sas_port = NULL;
Signature · 1 line
2.40.1.375.g9ce9dea4e1
author maintainer
#5 lore raw

PATCH 5/12 smartpqi: Remove contention for raid_bypass_cnt

In reply to Don Brace

From: Mike McGowen <[email protected]>

Reduce CPU contention when incrementing variable raid_bypass_cnt.

Remove the atomic operations for this variable by changing the atomic to an unsigned int and replace atomic operations with standard operations. The value is only checked that it is increasing and accuracy is not required.

---
 drivers/scsi/smartpqi/smartpqi.h      | 2 +-
 drivers/scsi/smartpqi/smartpqi_init.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/scsi/smartpqi/smartpqi.h +1 -1
index 228838eb3686..659a087a0e52 100644
@@ -1147,7 +1147,7 @@ struct pqi_scsi_dev {
 
 	struct pqi_stream_data stream_data[NUM_STREAMS_PER_LUN];
 	atomic_t scsi_cmds_outstanding[PQI_MAX_LUNS_PER_DEVICE];
-	atomic_t raid_bypass_cnt;
+	unsigned int raid_bypass_cnt;
 };
 
 /* VPD inquiry pages */
drivers/scsi/smartpqi/smartpqi_init.c +3 -3
index 3daad878bafa..7fe80bef1a15 100644
@@ -6052,7 +6052,7 @@ static int pqi_scsi_queue_command(struct Scsi_Host *shost, struct scsi_cmnd *scm
 			rc = pqi_raid_bypass_submit_scsi_cmd(ctrl_info, device, scmd, queue_group);
 			if (rc == 0 || rc == SCSI_MLQUEUE_HOST_BUSY) {
 				raid_bypassed = true;
-				atomic_inc(&device->raid_bypass_cnt);
+				device->raid_bypass_cnt++;
 			}
 		}
 		if (!raid_bypassed)
@@ -7288,7 +7288,7 @@ static ssize_t pqi_raid_bypass_cnt_show(struct device *dev,
 	struct scsi_device *sdev;
 	struct pqi_scsi_dev *device;
 	unsigned long flags;
-	int raid_bypass_cnt;
+	unsigned int raid_bypass_cnt;
 
 	sdev = to_scsi_device(dev);
 	ctrl_info = shost_to_hba(sdev->host);
@@ -7304,7 +7304,7 @@ static ssize_t pqi_raid_bypass_cnt_show(struct device *dev,
 		return -ENODEV;
 	}
 
-	raid_bypass_cnt = atomic_read(&device->raid_bypass_cnt);
+	raid_bypass_cnt = device->raid_bypass_cnt;
 
 	spin_unlock_irqrestore(&ctrl_info->scsi_device_list_lock, flags);
 
Signature · 1 line
2.40.1.375.g9ce9dea4e1
author maintainer
#6 lore raw

PATCH 6/12 smartpqi: validate block layer host tag

In reply to Don Brace

From: Murthy Bhat <[email protected]>

Prevent OS crashes when a drive is hot removed during IO stress test.

IO request pointer can be invalid if block layer provides incorrect multi-queue host tag. This can lead to invalid IO request pointer dereference.

---
 drivers/scsi/smartpqi/smartpqi_init.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/smartpqi/smartpqi_init.c +2 -1
index 7fe80bef1a15..f76b5a3e0fd1 100644
@@ -708,7 +708,8 @@ static inline struct pqi_io_request *pqi_alloc_io_request(struct pqi_ctrl_info *
 		}
 	}
 
-	pqi_reinit_io_request(io_request);
+	if (io_request)
+		pqi_reinit_io_request(io_request);
 
 	return io_request;
 }
Signature · 1 line
2.40.1.375.g9ce9dea4e1
author maintainer
#7 lore raw

PATCH 7/12 smartpqi: Add support for RAID NCQ priority

In reply to Don Brace

From: Gilbert Wu <[email protected]>

Enable NCQ priority feature for the RAID path when AIO path is disabled.

Move function pqi_is_io_high_priority() up to avoid adding a prototype. Remove unused argument ctrl_info.

---
 drivers/scsi/smartpqi/smartpqi_init.c | 89 ++++++++++++++-------------
 1 file changed, 45 insertions(+), 44 deletions(-)
drivers/scsi/smartpqi/smartpqi_init.c +45 -44
index f76b5a3e0fd1..19a97bbf89b5 100644
@@ -519,6 +519,36 @@ static inline void pqi_clear_soft_reset_status(struct pqi_ctrl_info *ctrl_info)
 	writeb(status, ctrl_info->soft_reset_status);
 }
 
+static inline bool pqi_is_io_high_priority(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 commands. */
+			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;
+			}
+		}
+	}
+
+	return io_high_prio;
+}
+
 static int pqi_map_single(struct pci_dev *pci_dev,
 	struct pqi_sg_descriptor *sg_descriptor, void *buffer,
 	size_t buffer_length, enum dma_data_direction data_direction)
@@ -5505,15 +5535,19 @@ static void pqi_raid_io_complete(struct pqi_io_request *io_request,
 	pqi_scsi_done(scmd);
 }
 
-static int pqi_raid_submit_scsi_cmd_with_io_request(
-	struct pqi_ctrl_info *ctrl_info, struct pqi_io_request *io_request,
+static int pqi_raid_submit_io(struct pqi_ctrl_info *ctrl_info,
 	struct pqi_scsi_dev *device, struct scsi_cmnd *scmd,
-	struct pqi_queue_group *queue_group)
+	struct pqi_queue_group *queue_group, bool io_high_prio)
 {
 	int rc;
 	size_t cdb_length;
+	struct pqi_io_request *io_request;
 	struct pqi_raid_path_request *request;
 
+	io_request = pqi_alloc_io_request(ctrl_info, scmd);
+	if (!io_request)
+		return SCSI_MLQUEUE_HOST_BUSY;
+
 	io_request->io_complete_callback = pqi_raid_io_complete;
 	io_request->scmd = scmd;
 
@@ -5523,6 +5557,7 @@ static int pqi_raid_submit_scsi_cmd_with_io_request(
 	request->header.iu_type = PQI_REQUEST_IU_RAID_PATH_IO;
 	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;
 	memcpy(request->lun_number, device->scsi3addr, sizeof(request->lun_number));
@@ -5588,14 +5623,11 @@ static inline int pqi_raid_submit_scsi_cmd(struct pqi_ctrl_info *ctrl_info,
 	struct pqi_scsi_dev *device, struct scsi_cmnd *scmd,
 	struct pqi_queue_group *queue_group)
 {
-	struct pqi_io_request *io_request;
+	bool io_high_prio;
 
-	io_request = pqi_alloc_io_request(ctrl_info, scmd);
-	if (!io_request)
-		return SCSI_MLQUEUE_HOST_BUSY;
+	io_high_prio = pqi_is_io_high_priority(device, scmd);
 
-	return pqi_raid_submit_scsi_cmd_with_io_request(ctrl_info, io_request,
-		device, scmd, queue_group);
+	return pqi_raid_submit_io(ctrl_info, device, scmd, queue_group, io_high_prio);
 }
 
 static bool pqi_raid_bypass_retry_needed(struct pqi_io_request *io_request)
@@ -5640,44 +5672,13 @@ static void pqi_aio_io_complete(struct pqi_io_request *io_request,
 	pqi_scsi_done(scmd);
 }
 
-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 commands. */
-			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;
-			}
-		}
-	}
-
-	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_priority(ctrl_info, device, scmd);
+	io_high_prio = pqi_is_io_high_priority(device, scmd);
 
 	return pqi_aio_submit_io(ctrl_info, scmd, device->aio_handle,
 		scmd->cmnd, scmd->cmd_len, queue_group, NULL,
@@ -5695,10 +5696,10 @@ static int pqi_aio_submit_io(struct pqi_ctrl_info *ctrl_info,
 	struct pqi_aio_path_request *request;
 	struct pqi_scsi_dev *device;
 
-	device = scmd->device->hostdata;
 	io_request = pqi_alloc_io_request(ctrl_info, scmd);
 	if (!io_request)
 		return SCSI_MLQUEUE_HOST_BUSY;
+
 	io_request->io_complete_callback = pqi_aio_io_complete;
 	io_request->scmd = scmd;
 	io_request->raid_bypass = raid_bypass;
@@ -5713,6 +5714,7 @@ static int pqi_aio_submit_io(struct pqi_ctrl_info *ctrl_info,
 	request->command_priority = io_high_prio;
 	put_unaligned_le16(io_request->index, &request->request_id);
 	request->error_index = request->request_id;
+	device = scmd->device->hostdata;
 	if (!pqi_is_logical_device(device) && ctrl_info->multi_lun_device_supported)
 		put_unaligned_le64(((scmd->device->lun) << 8), &request->lun_number);
 	if (cdb_length > sizeof(request->cdb))
@@ -7367,8 +7369,7 @@ static ssize_t pqi_sas_ncq_prio_enable_store(struct device *dev,
 		return -ENODEV;
 	}
 
-	if (!device->ncq_prio_support ||
-		!device->is_physical_device) {
+	if (!device->ncq_prio_support) {
 		spin_unlock_irqrestore(&ctrl_info->scsi_device_list_lock, flags);
 		return -EINVAL;
 	}
Signature · 1 line
2.40.1.375.g9ce9dea4e1
author maintainer
#8 lore raw

PATCH 8/12 smartpqi: fix byte aligned writew for ARM servers

In reply to Don Brace

Correct OOPs on ARM servers during driver init.

Driver attempts to update FW with max_feature_supported value using a writew() kernel call using a byte aligned address.

This fails on some ARM systems.

Change the writew() to two writeb() calls to update this value.

---
 drivers/scsi/smartpqi/smartpqi_init.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/smartpqi/smartpqi_init.c +2 -2
index 19a97bbf89b5..d3d4fc90dcae 100644
@@ -7718,8 +7718,8 @@ static int pqi_enable_firmware_features(struct pqi_ctrl_info *ctrl_info,
 			features_requested_iomem_addr +
 			(le16_to_cpu(firmware_features->num_elements) * 2) +
 			sizeof(__le16);
-		writew(PQI_FIRMWARE_FEATURE_MAXIMUM,
-			host_max_known_feature_iomem_addr);
+		writeb(PQI_FIRMWARE_FEATURE_MAXIMUM & 0xFF, host_max_known_feature_iomem_addr);
+		writeb((PQI_FIRMWARE_FEATURE_MAXIMUM & 0xFF00) >> 8, host_max_known_feature_iomem_addr + 1);
 	}
 
 	return pqi_config_table_update(ctrl_info,
Signature · 1 line
2.40.1.375.g9ce9dea4e1
author maintainer
#9 lore raw

PATCH 9/12 smartpqi: stop sending driver initiated TURs

In reply to Don Brace

From: Kevin Barnett <[email protected]>

Stop sending driver initiated TURs to physical devices during driver load/rescan.

Note: Patch does not affect SML initiated TURs.

Some Linux kernels can cause lengthy delays in OS boot if the kernel detects that a drive is being sanitized/erased. We were using TURs to detect if a sanitize/erase was in progress.

Some devices do not return the TUR in a timely manner, causing driver load/rescan stalls.

---
 drivers/scsi/smartpqi/smartpqi.h      |  1 +
 drivers/scsi/smartpqi/smartpqi_init.c | 85 ++++-----------------------
 2 files changed, 11 insertions(+), 75 deletions(-)
drivers/scsi/smartpqi/smartpqi.h +1 -0
index 659a087a0e52..6883526db93c 100644
@@ -1108,6 +1108,7 @@ struct pqi_scsi_dev {
 	u8	volume_offline : 1;
 	u8	rescan : 1;
 	u8	ignore_device : 1;
+	u8	erase_in_progress : 1;
 	bool	aio_enabled;		/* only valid for physical disks */
 	bool	in_remove;
 	bool	device_offline;
drivers/scsi/smartpqi/smartpqi_init.c +10 -75

128 lines not on this page · raw message

Signature · 1 line
2.40.1.375.g9ce9dea4e1
author maintainer
#10 lore raw

PATCH 10/12 smartpqi: Add sysfs entry for numa node in /sys/block/sdX/device.

In reply to Don Brace

Although numa node is a PCIe device level attribute, it was requested the numa node be added for each exposed device similar to NVMe disks.

Example for NVME:
/sys/block/nvme1c1n1/device/numa_node

Example for smartpqi:
/sys/block/sdh/device/numa_node

cat /sys/block/sdh/device/numa_node
0

---
 drivers/scsi/smartpqi/smartpqi.h      |  1 +
 drivers/scsi/smartpqi/smartpqi_init.c | 15 +++++++++++++++
 2 files changed, 16 insertions(+)
drivers/scsi/smartpqi/smartpqi.h +1 -0
index 6883526db93c..0817dfa5a039 100644
@@ -1358,6 +1358,7 @@ struct pqi_ctrl_info {
 	u32		max_write_raid_5_6;
 	u32		max_write_raid_1_10_2drive;
 	u32		max_write_raid_1_10_3drive;
+	int		numa_node;
 
 	struct list_head scsi_device_list;
 	spinlock_t	scsi_device_list_lock;
drivers/scsi/smartpqi/smartpqi_init.c +15 -0
index 324870477bae..ec5506a00cc2 100644
@@ -7316,6 +7316,18 @@ static ssize_t pqi_sas_ncq_prio_enable_store(struct device *dev,
 	return  strlen(buf);
 }
 
+static ssize_t pqi_numa_node_show(struct device *dev,
+	struct device_attribute *attr, char *buffer)
+{
+	struct scsi_device *sdev;
+	struct pqi_ctrl_info *ctrl_info;
+
+	sdev = to_scsi_device(dev);
+	ctrl_info = shost_to_hba(sdev->host);
+
+	return scnprintf(buffer, PAGE_SIZE, "%d\n", ctrl_info->numa_node);
+}
+
 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);
@@ -7325,6 +7337,7 @@ 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 DEVICE_ATTR(numa_node, 0444, pqi_numa_node_show, NULL);
 
 static struct attribute *pqi_sdev_attrs[] = {
 	&dev_attr_lunid.attr,
@@ -7335,6 +7348,7 @@ static struct attribute *pqi_sdev_attrs[] = {
 	&dev_attr_raid_level.attr,
 	&dev_attr_raid_bypass_cnt.attr,
 	&dev_attr_sas_ncq_prio_enable.attr,
+	&dev_attr_numa_node.attr,
 	NULL
 };
 
@@ -8955,6 +8969,7 @@ static int pqi_pci_probe(struct pci_dev *pci_dev,
 			"failed to allocate controller info block\n");
 		return -ENOMEM;
 	}
+	ctrl_info->numa_node = node;
 
 	ctrl_info->pci_dev = pci_dev;
 
Signature · 1 line
2.40.1.375.g9ce9dea4e1
author maintainer
#11 lore raw

PATCH 11/12 smartpqi: update copyright to 2023

In reply to Don Brace

Update copyright to current year.

---
 drivers/scsi/smartpqi/Kconfig                  | 2 +-
 drivers/scsi/smartpqi/smartpqi.h               | 2 +-
 drivers/scsi/smartpqi/smartpqi_init.c          | 2 +-
 drivers/scsi/smartpqi/smartpqi_sas_transport.c | 2 +-
 drivers/scsi/smartpqi/smartpqi_sis.c           | 2 +-
 drivers/scsi/smartpqi/smartpqi_sis.h           | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)
drivers/scsi/smartpqi/Kconfig +1 -1
index 973d240649ab..789460b0a342 100644
@@ -1,7 +1,7 @@
 #
 # Kernel configuration file for the SMARTPQI
 #
-# Copyright (c) 2019-2022 Microchip Technology Inc. and its subsidiaries
+# Copyright (c) 2019-2023 Microchip Technology Inc. and its subsidiaries
 # Copyright (c) 2017-2018 Microsemi Corporation
 # Copyright (c) 2016 Microsemi Corporation
 # Copyright (c) 2016 PMC-Sierra, Inc.
drivers/scsi/smartpqi/smartpqi.h +1 -1
index 0817dfa5a039..f960b5095d09 100644
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /*
  *    driver for Microchip PQI-based storage controllers
- *    Copyright (c) 2019-2022 Microchip Technology Inc. and its subsidiaries
+ *    Copyright (c) 2019-2023 Microchip Technology Inc. and its subsidiaries
  *    Copyright (c) 2016-2018 Microsemi Corporation
  *    Copyright (c) 2016 PMC-Sierra, Inc.
  *
drivers/scsi/smartpqi/smartpqi_init.c +1 -1
index ec5506a00cc2..0740bec5d9ae 100644
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
  *    driver for Microchip PQI-based storage controllers
- *    Copyright (c) 2019-2022 Microchip Technology Inc. and its subsidiaries
+ *    Copyright (c) 2019-2023 Microchip Technology Inc. and its subsidiaries
  *    Copyright (c) 2016-2018 Microsemi Corporation
  *    Copyright (c) 2016 PMC-Sierra, Inc.
  *
drivers/scsi/smartpqi/smartpqi_sas_transport.c +1 -1
index 36b90b55cf5f..a981d0377948 100644
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
  *    driver for Microchip PQI-based storage controllers
- *    Copyright (c) 2019-2022 Microchip Technology Inc. and its subsidiaries
+ *    Copyright (c) 2019-2023 Microchip Technology Inc. and its subsidiaries
  *    Copyright (c) 2016-2018 Microsemi Corporation
  *    Copyright (c) 2016 PMC-Sierra, Inc.
  *
drivers/scsi/smartpqi/smartpqi_sis.c +1 -1
index 5811fb3c22a9..673437c7152b 100644
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
  *    driver for Microchip PQI-based storage controllers
- *    Copyright (c) 2019-2022 Microchip Technology Inc. and its subsidiaries
+ *    Copyright (c) 2019-2023 Microchip Technology Inc. and its subsidiaries
  *    Copyright (c) 2016-2018 Microsemi Corporation
  *    Copyright (c) 2016 PMC-Sierra, Inc.
  *
drivers/scsi/smartpqi/smartpqi_sis.h +1 -1
index 9dcbae96a5c6..0c97626d87d4 100644
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /*
  *    driver for Microchip PQI-based storage controllers
- *    Copyright (c) 2019-2022 Microchip Technology Inc. and its subsidiaries
+ *    Copyright (c) 2019-2023 Microchip Technology Inc. and its subsidiaries
  *    Copyright (c) 2016-2018 Microsemi Corporation
  *    Copyright (c) 2016 PMC-Sierra, Inc.
  *
Signature · 1 line
2.40.1.375.g9ce9dea4e1
author maintainer
#12 lore raw

PATCH 12/12 smartpqi: update version to 2.1.22-040

In reply to Don Brace
---
 drivers/scsi/smartpqi/smartpqi_init.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/smartpqi/smartpqi_init.c +3 -3
index 0740bec5d9ae..3669affd114b 100644
@@ -33,11 +33,11 @@
 #define BUILD_TIMESTAMP
 #endif
 
-#define DRIVER_VERSION		"2.1.20-035"
+#define DRIVER_VERSION		"2.1.22-040"
 #define DRIVER_MAJOR		2
 #define DRIVER_MINOR		1
-#define DRIVER_RELEASE		20
-#define DRIVER_REVISION		35
+#define DRIVER_RELEASE		22
+#define DRIVER_REVISION		40
 
 #define DRIVER_NAME		"Microchip SmartPQI Driver (v" \
 				DRIVER_VERSION BUILD_TIMESTAMP ")"
Signature · 1 line
2.40.1.375.g9ce9dea4e1
#13 lore raw
In reply to Don Brace

Don,

Quoted 17 lines

This set of changes consists of:

* Map entire BAR 0.
The driver was mapping up to and including the controller registers, but not all of BAR 0.
* Add PCI IDs to support new controllers.
* Clean up some code by removing unnecessary NULL checks.
This cleanup is a result of a Coverity report.
* Correct a rare memory leak whenever pqi_sas_port_add_rhpy() returns an error. This was Suggested by: Yang Yingliang <[email protected]>
* Remove atomic operations on variable raid_bypass_cnt. Accuracy is not required for driver operation. Change type from atomic_t to unsigned int.
* Correct a rare drive hot-plug removal issue where we get a NULL io_request. We added a check for this condition.
* Turn on NCQ priority for AIO requests to disks comprising RAID devices.
* Correct byte aligned writew() operations on some ARM servers. Changed the writew() to two writeb() operations.

Quoted 8 lines

* Change how the driver checks for a sanitize operation in progress. We were using TEST UNIT READY. We removed the TEST UNIT READY code and are now using the controller's firmware information in order to avoid issues caused by drives failing to complete TEST UNIT READY.
* Some customers have been requesting that we add the NUMA node to /sys/block/sd<scsi device>/device like the nvme driver does.
* Update the copyright information to match the current year.
* Bump the driver version to 2.1.22-040.

Applied to 6.5/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
#14 lore raw
In reply to Don Brace
Quoted 30 lines · Don Brace

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

This set of changes consists of:

* Map entire BAR 0.
The driver was mapping up to and including the controller registers, but not all of BAR 0.
* Add PCI IDs to support new controllers.
* Clean up some code by removing unnecessary NULL checks.
This cleanup is a result of a Coverity report.
* Correct a rare memory leak whenever pqi_sas_port_add_rhpy() returns an error. This was Suggested by: Yang Yingliang <[email protected]>
* Remove atomic operations on variable raid_bypass_cnt. Accuracy is not required for driver operation. Change type from atomic_t to unsigned int.
* Correct a rare drive hot-plug removal issue where we get a NULL io_request. We added a check for this condition.
* Turn on NCQ priority for AIO requests to disks comprising RAID devices.
* Correct byte aligned writew() operations on some ARM servers. Changed the writew() to two writeb() operations.
* Change how the driver checks for a sanitize operation in progress. We were using TEST UNIT READY. We removed the TEST UNIT READY code and are now using the controller's firmware information in order to avoid issues caused by drives failing to complete TEST UNIT READY.
* Some customers have been requesting that we add the NUMA node to /sys/block/sd<scsi device>/device like the nvme driver does.
* Update the copyright information to match the current year.
* Bump the driver version to 2.1.22-040.

Quoted 1 line

[...]

Applied to 6.5/scsi-queue, thanks!

[01/12] smartpqi: map full length of PCI BAR 0

        https://git.kernel.org/mkp/scsi/c/3e7e55aa3df2
[02/12] smartpqi: Add new controller PCI IDs
        https://git.kernel.org/mkp/scsi/c/fe0375d48513
[03/12] smartpqi: remove null pointer check
        https://git.kernel.org/mkp/scsi/c/889cda36db99
[04/12] smartpqi: fix-rare-sas-transport-mem-leak
        https://git.kernel.org/mkp/scsi/c/2312e844dc8d
[05/12] smartpqi: Remove contention for raid_bypass_cnt
        https://git.kernel.org/mkp/scsi/c/80d560d94fa9
[06/12] smartpqi: validate block layer host tag
        https://git.kernel.org/mkp/scsi/c/5c9e3c1c5276
[07/12] smartpqi: Add support for RAID NCQ priority
        https://git.kernel.org/mkp/scsi/c/68f7920492be
[08/12] smartpqi: fix byte aligned writew for ARM servers
        https://git.kernel.org/mkp/scsi/c/c23efd9eadd8
[09/12] smartpqi: stop sending driver initiated TURs
        https://git.kernel.org/mkp/scsi/c/2eddf98d0152
[10/12] smartpqi: Add sysfs entry for numa node in /sys/block/sdX/device.
        https://git.kernel.org/mkp/scsi/c/d2c7583f27cc
[11/12] smartpqi: update copyright to 2023
        https://git.kernel.org/mkp/scsi/c/49fd52d4991f
[12/12] smartpqi: update version to 2.1.22-040
        https://git.kernel.org/mkp/scsi/c/fcb405111a24
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering