Skip to contentSkip to conversation

cxlflash: Miscellaneous fixes and updates

PATCH Applied Uma Krishnan 5 participants 15 messages Dec 14, 2015 – Jan 7, 2016 SCSI

lore
Share & tools
lore
#0 lore raw

v2 cover cxlflash: Miscellaneous fixes and updates

This patch set contains miscellaneous fixes and adds support for a future IBM CXL adapter. This series is intended for 4.5 and is bisectable. Please reference the changelog below for details on what has been altered from previous versions of this patch set.

v2 Changes:
- Incorporate comments from Daniel Axtens
- Incorporate comments from Andrew Donnellan
- Removed driver date and simplified driver load print
- Clarified driver behavior for the future adapter

Manoj Kumar (4):
cxlflash: Fix to escalate LINK_RESET also on port 1
cxlflash: Fix to resolve cmd leak after host reset
cxlflash: Resolve oops in wait_port_offline
cxlflash: Enable device id for future IBM CXL adapter

Matthew R. Ochs (1):
cxlflash: Fix to avoid virtual LUN failover failure

Uma Krishnan (1):
cxlflash: Removed driver date print

 drivers/scsi/cxlflash/common.h     |  2 ++
 drivers/scsi/cxlflash/main.c       | 54 ++++++++++++++++++++++++++++++++------
 drivers/scsi/cxlflash/main.h       |  5 ++--
 drivers/scsi/cxlflash/vlun.c       |  2 ++
 include/uapi/scsi/cxlflash_ioctl.h | 10 +++++++
 5 files changed, 62 insertions(+), 11 deletions(-)
Signature · 1 line
2.1.0
#1 lore raw

v2 cover cxlflash: Miscellaneous fixes and updates

This patch set contains miscellaneous fixes and adds support for a future IBM CXL adapter. This series is intended for 4.5 and is bisectable. Please reference the changelog below for details on what has been altered from previous versions of this patch set.

v2 Changes:
- Incorporate comments from Daniel Axtens
- Incorporate comments from Andrew Donnellan
- Removed driver date and simplified driver load print
- Clarified driver behavior for the future adapter

Manoj Kumar (4):
cxlflash: Fix to escalate LINK_RESET also on port 1
cxlflash: Fix to resolve cmd leak after host reset
cxlflash: Resolve oops in wait_port_offline
cxlflash: Enable device id for future IBM CXL adapter

Matthew R. Ochs (1):
cxlflash: Fix to avoid virtual LUN failover failure

Uma Krishnan (1):
cxlflash: Removed driver date print

 drivers/scsi/cxlflash/common.h     |  2 ++
 drivers/scsi/cxlflash/main.c       | 54 ++++++++++++++++++++++++++++++++------
 drivers/scsi/cxlflash/main.h       |  5 ++--
 drivers/scsi/cxlflash/vlun.c       |  2 ++
 include/uapi/scsi/cxlflash_ioctl.h | 10 +++++++
 5 files changed, 62 insertions(+), 11 deletions(-)
Signature · 1 line
2.1.0
#2 lore raw

PATCH v2 1/6 cxlflash: Fix to escalate LINK_RESET also on port 1

From: Manoj Kumar <[email protected]>

The original fix to escalate a 'login timed out' error to a LINK_RESET was only made for one of the two ports on the card. This fix resolves the same issue for the second port (port 1).

---
 drivers/scsi/cxlflash/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/cxlflash/main.c +1 -1
index 1e5bf0c..09fe252 100644
@@ -1108,7 +1108,7 @@ static const struct asyc_intr_info ainfo[] = {
 	{SISL_ASTATUS_FC1_OTHER, "other error", 1, CLR_FC_ERROR | LINK_RESET},
 	{SISL_ASTATUS_FC1_LOGO, "target initiated LOGO", 1, 0},
 	{SISL_ASTATUS_FC1_CRC_T, "CRC threshold exceeded", 1, LINK_RESET},
-	{SISL_ASTATUS_FC1_LOGI_R, "login timed out, retrying", 1, 0},
+	{SISL_ASTATUS_FC1_LOGI_R, "login timed out, retrying", 1, LINK_RESET},
 	{SISL_ASTATUS_FC1_LOGI_F, "login failed", 1, CLR_FC_ERROR},
 	{SISL_ASTATUS_FC1_LOGI_S, "login succeeded", 1, SCAN_HOST},
 	{SISL_ASTATUS_FC1_LINK_DN, "link down", 1, 0},
Signature · 1 line
2.1.0
#3 lore raw

v2 cover cxlflash: Miscellaneous fixes and updates

In reply to Uma Krishnan

This patch set contains miscellaneous fixes and adds support for a future IBM CXL adapter. This series is intended for 4.5 and is bisectable. Please reference the changelog below for details on what has been altered from previous versions of this patch set.

v2 Changes:
- Incorporate comments from Daniel Axtens
- Incorporate comments from Andrew Donnellan
- Removed driver date and simplified driver load print
- Clarified driver behavior for the future adapter

Manoj Kumar (4):
cxlflash: Fix to escalate LINK_RESET also on port 1
cxlflash: Fix to resolve cmd leak after host reset
cxlflash: Resolve oops in wait_port_offline
cxlflash: Enable device id for future IBM CXL adapter

Matthew R. Ochs (1):
cxlflash: Fix to avoid virtual LUN failover failure

Uma Krishnan (1):
cxlflash: Removed driver date print

 drivers/scsi/cxlflash/common.h     |  2 ++
 drivers/scsi/cxlflash/main.c       | 54 ++++++++++++++++++++++++++++++++------
 drivers/scsi/cxlflash/main.h       |  5 ++--
 drivers/scsi/cxlflash/vlun.c       |  2 ++
 include/uapi/scsi/cxlflash_ioctl.h | 10 +++++++
 5 files changed, 62 insertions(+), 11 deletions(-)
Signature · 1 line
2.1.0
#4 lore raw

PATCH v2 2/6 cxlflash: Fix to avoid virtual LUN failover failure

From: "Matthew R. Ochs" <[email protected]>

Applications which use virtual LUN's that are backed by a physical LUN over both adapter ports may experience an I/O failure in the event of a link loss (e.g. cable pull).

Virtual LUNs may be accessed through one or both ports of the adapter. This access is encoded in the translation entries that comprise the virtual LUN and used by the AFU for load-balancing I/O and handling failover scenarios. In a link loss scenario, even though the AFU is able to maintain connectivity to the LUN, it is up to the application to retry the failed I/O. When applications are unaware of the virtual LUN's underlying topology, they are unable to make a sound decision of when to retry an I/O and therefore are forced to make their reaction to a failed I/O absolute. The result is either a failure to retry I/O or increased latency for scenarios where a retry is pointless.

To remedy this scenario, provide feedback back to the application on virtual LUN creation as to which ports the LUN may be accessed. LUN's spanning both ports are candidates for a retry in a presence of an I/O failure.

---
 drivers/scsi/cxlflash/vlun.c       |  2 ++
 include/uapi/scsi/cxlflash_ioctl.h | 10 ++++++++++
 2 files changed, 12 insertions(+)
drivers/scsi/cxlflash/vlun.c +2 -0
index a53f583..50f8e93 100644
@@ -1008,6 +1008,8 @@ int cxlflash_disk_virtual_open(struct scsi_device *sdev, void *arg)
 	virt->last_lba = last_lba;
 	virt->rsrc_handle = rsrc_handle;
 
+	if (lli->port_sel == BOTH_PORTS)
+		virt->hdr.return_flags |= DK_CXLFLASH_ALL_PORTS_ACTIVE;
 out:
 	if (likely(ctxi))
 		put_context(ctxi);
include/uapi/scsi/cxlflash_ioctl.h +10 -0
index 831351b..2302f3c 100644
@@ -31,6 +31,16 @@ struct dk_cxlflash_hdr {
 };
 
 /*
+ * Return flag definitions available to all ioctls
+ *
+ * Similar to the input flags, these are grown from the bottom-up with the
+ * intention that ioctl-specific return flag definitions would grow from the
+ * top-down, allowing the two sets to co-exist. While not required/enforced
+ * at this time, this provides future flexibility.
+ */
+#define DK_CXLFLASH_ALL_PORTS_ACTIVE	0x0000000000000001ULL
+
+/*
  * Notes:
  * -----
  * The 'context_id' field of all ioctl structures contains the context
Signature · 1 line
2.1.0
#5 lore raw

PATCH v2 3/6 cxlflash: Removed driver date print

In reply to Uma Krishnan

Having a date for the driver requires it to be updated quite often. Removing the date which is not necessary. Also made use of the existing symbol to print the driver name.

---
 drivers/scsi/cxlflash/main.c | 3 +--
 drivers/scsi/cxlflash/main.h | 1 -
 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/scsi/cxlflash/main.c +1 -2
index 09fe252..35a3202 100644
@@ -2585,8 +2585,7 @@ static struct pci_driver cxlflash_driver = {
  */
 static int __init init_cxlflash(void)
 {
-	pr_info("%s: IBM Power CXL Flash Adapter: %s\n",
-		__func__, CXLFLASH_DRIVER_DATE);
+	pr_info("%s: %s\n", __func__, CXLFLASH_ADAPTER_NAME);
 
 	cxlflash_list_init();
 
drivers/scsi/cxlflash/main.h +0 -1
index 6032456..7e2d0e1 100644
@@ -22,7 +22,6 @@
 
 #define CXLFLASH_NAME		"cxlflash"
 #define CXLFLASH_ADAPTER_NAME	"IBM POWER CXL Flash Adapter"
-#define CXLFLASH_DRIVER_DATE	"(August 13, 2015)"
 
 #define PCI_DEVICE_ID_IBM_CORSA	0x04F0
 #define CXLFLASH_SUBS_DEV_ID	0x04F0
Signature · 1 line
2.1.0
Reviewed-by on v2 3/6
#7 lore raw

Re: [PATCH v2 3/6] cxlflash: Removed driver date print

In reply to Uma Krishnan
Quoted 5 lines · Uma Krishnan

Having a date for the driver requires it to be updated quite often. Removing the date which is not necessary. Also made use of the existing symbol to print the driver name.

Signature · 3 lines
Andrew Donnellan              Software Engineer, OzLabs
[email protected]  Australia Development Lab, Canberra
+61 2 6201 8874 (work)        IBM Australia Limited
#9 lore raw

PATCH v2 4/6 cxlflash: Fix to resolve cmd leak after host reset

In reply to Uma Krishnan

From: Manoj Kumar <[email protected]>

After a few iterations of resetting the card, either during EEH recovery, or a host_reset the following is seen in the logs. cxlflash 0008:00: cxlflash_queuecommand: could not get a free command

At every reset of the card, the commands that are outstanding are being leaked. No effort is being made to reap these commands. A few more resets later, the above error message floods the logs and the card is rendered totally unusable as no free commands are available.

Iterated through the 'cmd' queue and printed out the 'free' counter and found that on each reset certain commands were in-use and stayed in-use through subsequent resets.

To resolve this issue, when the card is reset, reap all the commands that are active/outstanding.

---
 drivers/scsi/cxlflash/main.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
drivers/scsi/cxlflash/main.c +17 -2
index 35a3202..ac39856 100644
@@ -632,15 +632,30 @@ static void free_mem(struct cxlflash_cfg *cfg)
  * @cfg:	Internal structure associated with the host.
  *
  * Safe to call with AFU in a partially allocated/initialized state.
+ *
+ * Cleans up all state associated with the command queue, and unmaps
+ * the MMIO space.
+ *
+ *  - complete() will take care of commands we initiated (they'll be checked
+ *  in as part of the cleanup that occurs after the completion)
+ *
+ *  - cmd_checkin() will take care of entries that we did not initiate and that
+ *  have not (and will not) complete because they are sitting on a [now stale]
+ *  hardware queue
  */
 static void stop_afu(struct cxlflash_cfg *cfg)
 {
 	int i;
 	struct afu *afu = cfg->afu;
+	struct afu_cmd *cmd;
 
 	if (likely(afu)) {
-		for (i = 0; i < CXLFLASH_NUM_CMDS; i++)
-			complete(&afu->cmd[i].cevent);
+		for (i = 0; i < CXLFLASH_NUM_CMDS; i++) {
+			cmd = &afu->cmd[i];
+			complete(&cmd->cevent);
+			if (!atomic_read(&cmd->free))
+				cmd_checkin(cmd);
+		}
 
 		if (likely(afu->afu_map)) {
 			cxl_psa_unmap((void __iomem *)afu->afu_map);
Signature · 1 line
2.1.0
Reviewed-by on v2 4/6
#10 lore raw

Re: [PATCH v2 4/6] cxlflash: Fix to resolve cmd leak after host reset

Quoted 15 lines · Uma Krishnan

From: Manoj Kumar <[email protected]>

After a few iterations of resetting the card, either during EEH recovery, or a host_reset the following is seen in the logs. cxlflash 0008:00: cxlflash_queuecommand: could not get a free command

At every reset of the card, the commands that are outstanding are being leaked. No effort is being made to reap these commands. A few more resets later, the above error message floods the logs and the card is rendered totally unusable as no free commands are available.

Iterated through the 'cmd' queue and printed out the 'free' counter and found that on each reset certain commands were in-use and stayed in-use through subsequent resets.

Quoted 5 lines

To resolve this issue, when the card is reset, reap all the commands that are active/outstanding.

Looks reasonable.

Signature · 3 lines
Andrew Donnellan              Software Engineer, OzLabs
[email protected]  Australia Development Lab, Canberra
+61 2 6201 8874 (work)        IBM Australia Limited
#11 lore raw

PATCH v2 5/6 cxlflash: Resolve oops in wait_port_offline

In reply to Uma Krishnan

From: Manoj Kumar <[email protected]>

If an async error interrupt is generated, and the error requires the FC link to be reset, it cannot be performed in the interrupt context. So a work element is scheduled to complete the link reset in a process context. If either an EEH event or an escalation occurs in between when the interrupt is generated and the scheduled work is started, the MMIO space may no longer be available. This will cause an oops in the worker thread.

[  606.806583] NIP kthread_data+0x28/0x40
[  606.806633] LR wq_worker_sleeping+0x30/0x100
[  606.806694] Call Trace:
[  606.806721] 0x50 (unreliable)
[  606.806796] wq_worker_sleeping+0x30/0x100
[  606.806884] __schedule+0x69c/0x8a0
[  606.806959] schedule+0x44/0xc0
[  606.807034] do_exit+0x770/0xb90
[  606.807109] die+0x300/0x460
[  606.807185] bad_page_fault+0xd8/0x150
[  606.807259] handle_page_fault+0x2c/0x30
[  606.807338] wait_port_offline.constprop.12+0x60/0x130 [cxlflash]

To prevent the problem space area from being unmapped, when there is pending work, a mapcount (using the kref mechanism) is held. The mapcount is released only when the work is completed. The last reference release is tied to the unmapping service.

---
 drivers/scsi/cxlflash/common.h |  2 ++
 drivers/scsi/cxlflash/main.c   | 27 ++++++++++++++++++++++++---
 2 files changed, 26 insertions(+), 3 deletions(-)
drivers/scsi/cxlflash/common.h +2 -0
index c11cd19..5ada926 100644
@@ -165,6 +165,8 @@ struct afu {
 	struct sisl_host_map __iomem *host_map;		/* MC host map */
 	struct sisl_ctrl_map __iomem *ctrl_map;		/* MC control map */
 
+	struct kref mapcount;
+
 	ctx_hndl_t ctx_hndl;	/* master's context handle */
 	u64 *hrrq_start;
 	u64 *hrrq_end;
drivers/scsi/cxlflash/main.c +24 -3
index ac39856..30542ca 100644
@@ -368,6 +368,7 @@ out:
 
 no_room:
 	afu->read_room = true;
+	kref_get(&cfg->afu->mapcount);
 	schedule_work(&cfg->work_q);
 	rc = SCSI_MLQUEUE_HOST_BUSY;
 	goto out;
@@ -473,6 +474,16 @@ out:
 	return rc;
 }
 
+static void afu_unmap(struct kref *ref)
+{
+	struct afu *afu = container_of(ref, struct afu, mapcount);
+
+	if (likely(afu->afu_map)) {
+		cxl_psa_unmap((void __iomem *)afu->afu_map);
+		afu->afu_map = NULL;
+	}
+}
+
 /**
  * cxlflash_driver_info() - information handler for this host driver
  * @host:	SCSI host associated with device.
@@ -503,6 +514,7 @@ static int cxlflash_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scp)
 	ulong lock_flags;
 	short lflag = 0;
 	int rc = 0;
+	int kref_got = 0;
 
 	dev_dbg_ratelimited(dev, "%s: (scp=%p) %d/%d/%d/%llu "
 			    "cdb=(%08X-%08X-%08X-%08X)\n",
@@ -547,6 +559,9 @@ static int cxlflash_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scp)
 		goto out;
 	}
 
+	kref_get(&cfg->afu->mapcount);
+	kref_got = 1;
+
 	cmd->rcb.ctx_id = afu->ctx_hndl;
 	cmd->rcb.port_sel = port_sel;
 	cmd->rcb.lun_id = lun_to_lunid(scp->device->lun);
@@ -587,6 +602,8 @@ static int cxlflash_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scp)
 	}
 
 out:
+	if (kref_got)
+		kref_put(&afu->mapcount, afu_unmap);
 	pr_devel("%s: returning rc=%d\n", __func__, rc);
 	return rc;
 }
@@ -661,6 +678,7 @@ static void stop_afu(struct cxlflash_cfg *cfg)
 			cxl_psa_unmap((void __iomem *)afu->afu_map);
 			afu->afu_map = NULL;
 		}
+		kref_put(&afu->mapcount, afu_unmap);
 	}
 }
 
@@ -746,8 +764,8 @@ static void cxlflash_remove(struct pci_dev *pdev)
 		scsi_remove_host(cfg->host);
 		/* fall through */
 	case INIT_STATE_AFU:
-		term_afu(cfg);
 		cancel_work_sync(&cfg->work_q);
+		term_afu(cfg);
 	case INIT_STATE_PCI:
 		pci_release_regions(cfg->dev);
 		pci_disable_device(pdev);
@@ -1331,6 +1349,7 @@ static irqreturn_t cxlflash_async_err_irq(int irq, void *data)
 				__func__, port);
 			cfg->lr_state = LINK_RESET_REQUIRED;
 			cfg->lr_port = port;
+			kref_get(&cfg->afu->mapcount);
 			schedule_work(&cfg->work_q);
 		}
 
@@ -1351,6 +1370,7 @@ static irqreturn_t cxlflash_async_err_irq(int irq, void *data)
 
 		if (info->action & SCAN_HOST) {
 			atomic_inc(&cfg->scan_host_needed);
+			kref_get(&cfg->afu->mapcount);
 			schedule_work(&cfg->work_q);
 		}
 	}
@@ -1746,6 +1766,7 @@ static int init_afu(struct cxlflash_cfg *cfg)
 		rc = -ENOMEM;
 		goto err1;
 	}
+	kref_init(&afu->mapcount);
 
 	/* No byte reverse on reading afu_version or string will be backwards */
 	reg = readq(&afu->afu_map->global.regs.afu_version);
@@ -1780,8 +1801,7 @@ out:
 	return rc;
 
 err2:
-	cxl_psa_unmap((void __iomem *)afu->afu_map);
-	afu->afu_map = NULL;
+	kref_put(&afu->mapcount, afu_unmap);
 err1:
 	term_mc(cfg, UNDO_START);
 	goto out;
@@ -2354,6 +2374,7 @@ static void cxlflash_worker_thread(struct work_struct *work)
 
 	if (atomic_dec_if_positive(&cfg->scan_host_needed) >= 0)
 		scsi_scan_host(cfg->host);
+	kref_put(&afu->mapcount, afu_unmap);
 }
 
 /**
Signature · 1 line
2.1.0
#12 lore raw

PATCH v2 6/6 cxlflash: Enable device id for future IBM CXL adapter

In reply to Uma Krishnan

From: Manoj Kumar <[email protected]>

This drop enables a future card with a device id of 0x0600 to be recognized by the cxlflash driver.

As per the design, the Accelerator Function Unit (AFU) for this new IBM CXL Flash Adapter retains the same host interface as the previous generation. For the early prototypes of the new card, the driver with this change behaves exactly as the driver prior to this behaved with the earlier generation card. Therefore, no card specific programming has been added. These card specific changes can be staged in later if needed.

---
 drivers/scsi/cxlflash/main.c | 3 +++
 drivers/scsi/cxlflash/main.h | 4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/scsi/cxlflash/main.c +3 -0
index 30542ca..f6d90ce 100644
@@ -2309,6 +2309,7 @@ static struct scsi_host_template driver_template = {
  * Device dependent values
  */
 static struct dev_dependent_vals dev_corsa_vals = { CXLFLASH_MAX_SECTORS };
+static struct dev_dependent_vals dev_flash_gt_vals = { CXLFLASH_MAX_SECTORS };
 
 /*
  * PCI device binding table
@@ -2316,6 +2317,8 @@ static struct dev_dependent_vals dev_corsa_vals = { CXLFLASH_MAX_SECTORS };
 static struct pci_device_id cxlflash_pci_table[] = {
 	{PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CORSA,
 	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, (kernel_ulong_t)&dev_corsa_vals},
+	{PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_FLASH_GT,
+	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, (kernel_ulong_t)&dev_flash_gt_vals},
 	{}
 };
 
drivers/scsi/cxlflash/main.h +2 -2
index 7e2d0e1..0faed42 100644
@@ -23,8 +23,8 @@
 #define CXLFLASH_NAME		"cxlflash"
 #define CXLFLASH_ADAPTER_NAME	"IBM POWER CXL Flash Adapter"
 
-#define PCI_DEVICE_ID_IBM_CORSA	0x04F0
-#define CXLFLASH_SUBS_DEV_ID	0x04F0
+#define PCI_DEVICE_ID_IBM_CORSA		0x04F0
+#define PCI_DEVICE_ID_IBM_FLASH_GT	0x0600
 
 /* Since there is only one target, make it 0 */
 #define CXLFLASH_TARGET		0
Signature · 1 line
2.1.0
Reviewed-by on v2 6/6
#13 lore raw

Re: [PATCH v2 6/6] cxlflash: Enable device id for future IBM CXL adapter

Quoted 4 lines · Uma Krishnan

From: Manoj Kumar <[email protected]>

This drop enables a future card with a device id of 0x0600 to be recognized by the cxlflash driver.

If you do a V3 - this could be better worded in the imperative mood as: "Add a new device ID (0x0600) for a future IBM CXL Flash Adapter card."

Quoted 10 lines

As per the design, the Accelerator Function Unit (AFU) for this new IBM CXL Flash Adapter retains the same host interface as the previous generation. For the early prototypes of the new card, the driver with this change behaves exactly as the driver prior to this behaved with the earlier generation card. Therefore, no card specific programming has been added. These card specific changes can be staged in later if needed.

Quoted 2 lines

Assuming that the final card won't break in a particularly nasty way in the absence of later code changes, all looks good.

Signature · 3 lines
Andrew Donnellan              Software Engineer, OzLabs
[email protected]  Australia Development Lab, Canberra
+61 2 6201 8874 (work)        IBM Australia Limited
#14 lore raw
In reply to Uma Krishnan
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Uma" == Uma Krishnan <[email protected]> writes:

Uma> This patch set contains miscellaneous fixes and adds support for a Uma> future IBM CXL adapter. This series is intended for 4.5 and is Uma> bisectable. Please reference the changelog below for details on Uma> what has been altered from previous versions of this patch set.

Applied to 4.5/scsi-queue.

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering