linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/6] cxlflash: Miscellaneous fixes and updates
@ 2015-12-14 20:51 Uma Krishnan
  2015-12-14 20:55 ` Uma Krishnan
                   ` (6 more replies)
  0 siblings, 7 replies; 15+ messages in thread
From: Uma Krishnan @ 2015-12-14 20:51 UTC (permalink / raw)
  To: linux-scsi, James Bottomley, Martin K. Petersen, Matthew R. Ochs,
	Manoj N. Kumar, Brian King
  Cc: linuxppc-dev, Ian Munsie, Andrew Donnellan, Daniel Axtens

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(-)

-- 
2.1.0

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

* [PATCH v2 0/6] cxlflash: Miscellaneous fixes and updates
  2015-12-14 20:51 [PATCH v2 0/6] cxlflash: Miscellaneous fixes and updates Uma Krishnan
@ 2015-12-14 20:55 ` Uma Krishnan
  2015-12-14 20:55   ` [PATCH v2 1/6] cxlflash: Fix to escalate LINK_RESET also on port 1 Uma Krishnan
  2015-12-14 20:55 ` [PATCH v2 0/6] cxlflash: Miscellaneous fixes and updates Uma Krishnan
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 15+ messages in thread
From: Uma Krishnan @ 2015-12-14 20:55 UTC (permalink / raw)
  To: linux-scsi, James Bottomley, Martin K. Petersen, Matthew R. Ochs,
	Manoj N. Kumar, Brian King
  Cc: linuxppc-dev, Ian Munsie, Andrew Donnellan, Daniel Axtens

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(-)

-- 
2.1.0

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

* [PATCH v2 1/6] cxlflash: Fix to escalate LINK_RESET also on port 1
  2015-12-14 20:55 ` Uma Krishnan
@ 2015-12-14 20:55   ` Uma Krishnan
  0 siblings, 0 replies; 15+ messages in thread
From: Uma Krishnan @ 2015-12-14 20:55 UTC (permalink / raw)
  To: linux-scsi, James Bottomley, Martin K. Petersen, Matthew R. Ochs,
	Manoj N. Kumar, Brian King
  Cc: linuxppc-dev, Ian Munsie, Andrew Donnellan, Daniel Axtens

From: Manoj Kumar <manoj@linux.vnet.ibm.com>

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).

Signed-off-by: Manoj N. Kumar <manoj@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
---
 drivers/scsi/cxlflash/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c
index 1e5bf0c..09fe252 100644
--- a/drivers/scsi/cxlflash/main.c
+++ b/drivers/scsi/cxlflash/main.c
@@ -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},
-- 
2.1.0

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

* [PATCH v2 0/6] cxlflash: Miscellaneous fixes and updates
  2015-12-14 20:51 [PATCH v2 0/6] cxlflash: Miscellaneous fixes and updates Uma Krishnan
  2015-12-14 20:55 ` Uma Krishnan
@ 2015-12-14 20:55 ` Uma Krishnan
  2015-12-14 20:55   ` [PATCH v2 2/6] cxlflash: Fix to avoid virtual LUN failover failure Uma Krishnan
  2015-12-14 21:06 ` [PATCH v2 3/6] cxlflash: Removed driver date print Uma Krishnan
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 15+ messages in thread
From: Uma Krishnan @ 2015-12-14 20:55 UTC (permalink / raw)
  To: linux-scsi, James Bottomley, Martin K. Petersen, Matthew R. Ochs,
	Manoj N. Kumar, Brian King
  Cc: linuxppc-dev, Ian Munsie, Andrew Donnellan, Daniel Axtens

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(-)

-- 
2.1.0

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

* [PATCH v2 2/6] cxlflash: Fix to avoid virtual LUN failover failure
  2015-12-14 20:55 ` [PATCH v2 0/6] cxlflash: Miscellaneous fixes and updates Uma Krishnan
@ 2015-12-14 20:55   ` Uma Krishnan
  0 siblings, 0 replies; 15+ messages in thread
From: Uma Krishnan @ 2015-12-14 20:55 UTC (permalink / raw)
  To: linux-scsi, James Bottomley, Martin K. Petersen, Matthew R. Ochs,
	Manoj N. Kumar, Brian King
  Cc: linuxppc-dev, Ian Munsie, Andrew Donnellan, Daniel Axtens

From: "Matthew R. Ochs" <mrochs@linux.vnet.ibm.com>

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.

Signed-off-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Acked-by: Manoj Kumar <manoj@linux.vnet.ibm.com>
---
 drivers/scsi/cxlflash/vlun.c       |  2 ++
 include/uapi/scsi/cxlflash_ioctl.h | 10 ++++++++++
 2 files changed, 12 insertions(+)

diff --git a/drivers/scsi/cxlflash/vlun.c b/drivers/scsi/cxlflash/vlun.c
index a53f583..50f8e93 100644
--- a/drivers/scsi/cxlflash/vlun.c
+++ b/drivers/scsi/cxlflash/vlun.c
@@ -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);
diff --git a/include/uapi/scsi/cxlflash_ioctl.h b/include/uapi/scsi/cxlflash_ioctl.h
index 831351b..2302f3c 100644
--- a/include/uapi/scsi/cxlflash_ioctl.h
+++ b/include/uapi/scsi/cxlflash_ioctl.h
@@ -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
-- 
2.1.0

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

* [PATCH v2 3/6] cxlflash: Removed driver date print
  2015-12-14 20:51 [PATCH v2 0/6] cxlflash: Miscellaneous fixes and updates Uma Krishnan
  2015-12-14 20:55 ` Uma Krishnan
  2015-12-14 20:55 ` [PATCH v2 0/6] cxlflash: Miscellaneous fixes and updates Uma Krishnan
@ 2015-12-14 21:06 ` Uma Krishnan
  2015-12-14 23:45   ` Matthew R. Ochs
                     ` (2 more replies)
  2015-12-14 21:07 ` [PATCH v2 4/6] cxlflash: Fix to resolve cmd leak after host reset Uma Krishnan
                   ` (3 subsequent siblings)
  6 siblings, 3 replies; 15+ messages in thread
From: Uma Krishnan @ 2015-12-14 21:06 UTC (permalink / raw)
  To: linux-scsi, James Bottomley, Martin K. Petersen, Matthew R. Ochs,
	Manoj N. Kumar, Brian King
  Cc: linuxppc-dev, Ian Munsie, Andrew Donnellan, Daniel Axtens

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.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
---
 drivers/scsi/cxlflash/main.c | 3 +--
 drivers/scsi/cxlflash/main.h | 1 -
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c
index 09fe252..35a3202 100644
--- a/drivers/scsi/cxlflash/main.c
+++ b/drivers/scsi/cxlflash/main.c
@@ -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();
 
diff --git a/drivers/scsi/cxlflash/main.h b/drivers/scsi/cxlflash/main.h
index 6032456..7e2d0e1 100644
--- a/drivers/scsi/cxlflash/main.h
+++ b/drivers/scsi/cxlflash/main.h
@@ -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
-- 
2.1.0

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

* [PATCH v2 4/6] cxlflash: Fix to resolve cmd leak after host reset
  2015-12-14 20:51 [PATCH v2 0/6] cxlflash: Miscellaneous fixes and updates Uma Krishnan
                   ` (2 preceding siblings ...)
  2015-12-14 21:06 ` [PATCH v2 3/6] cxlflash: Removed driver date print Uma Krishnan
@ 2015-12-14 21:07 ` Uma Krishnan
  2015-12-15  2:45   ` Andrew Donnellan
  2015-12-14 21:07 ` [PATCH v2 5/6] cxlflash: Resolve oops in wait_port_offline Uma Krishnan
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 15+ messages in thread
From: Uma Krishnan @ 2015-12-14 21:07 UTC (permalink / raw)
  To: linux-scsi, James Bottomley, Martin K. Petersen, Matthew R. Ochs,
	Manoj N. Kumar, Brian King
  Cc: linuxppc-dev, Ian Munsie, Andrew Donnellan, Daniel Axtens

From: Manoj Kumar <manoj@linux.vnet.ibm.com>

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.

Signed-off-by: Manoj N. Kumar <manoj@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
---
 drivers/scsi/cxlflash/main.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c
index 35a3202..ac39856 100644
--- a/drivers/scsi/cxlflash/main.c
+++ b/drivers/scsi/cxlflash/main.c
@@ -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);
-- 
2.1.0

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

* [PATCH v2 5/6] cxlflash: Resolve oops in wait_port_offline
  2015-12-14 20:51 [PATCH v2 0/6] cxlflash: Miscellaneous fixes and updates Uma Krishnan
                   ` (3 preceding siblings ...)
  2015-12-14 21:07 ` [PATCH v2 4/6] cxlflash: Fix to resolve cmd leak after host reset Uma Krishnan
@ 2015-12-14 21:07 ` Uma Krishnan
  2015-12-14 21:07 ` [PATCH v2 6/6] cxlflash: Enable device id for future IBM CXL adapter Uma Krishnan
  2016-01-07  2:01 ` [PATCH v2 0/6] cxlflash: Miscellaneous fixes and updates Martin K. Petersen
  6 siblings, 0 replies; 15+ messages in thread
From: Uma Krishnan @ 2015-12-14 21:07 UTC (permalink / raw)
  To: linux-scsi, James Bottomley, Martin K. Petersen, Matthew R. Ochs,
	Manoj N. Kumar, Brian King
  Cc: linuxppc-dev, Ian Munsie, Andrew Donnellan, Daniel Axtens

From: Manoj Kumar <manoj@linux.vnet.ibm.com>

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.

Signed-off-by: Manoj N. Kumar <manoj@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
---
 drivers/scsi/cxlflash/common.h |  2 ++
 drivers/scsi/cxlflash/main.c   | 27 ++++++++++++++++++++++++---
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/cxlflash/common.h b/drivers/scsi/cxlflash/common.h
index c11cd19..5ada926 100644
--- a/drivers/scsi/cxlflash/common.h
+++ b/drivers/scsi/cxlflash/common.h
@@ -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;
diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c
index ac39856..30542ca 100644
--- a/drivers/scsi/cxlflash/main.c
+++ b/drivers/scsi/cxlflash/main.c
@@ -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);
 }
 
 /**
-- 
2.1.0

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

* [PATCH v2 6/6] cxlflash: Enable device id for future IBM CXL adapter
  2015-12-14 20:51 [PATCH v2 0/6] cxlflash: Miscellaneous fixes and updates Uma Krishnan
                   ` (4 preceding siblings ...)
  2015-12-14 21:07 ` [PATCH v2 5/6] cxlflash: Resolve oops in wait_port_offline Uma Krishnan
@ 2015-12-14 21:07 ` Uma Krishnan
  2015-12-15  3:11   ` Andrew Donnellan
  2016-01-07  2:01 ` [PATCH v2 0/6] cxlflash: Miscellaneous fixes and updates Martin K. Petersen
  6 siblings, 1 reply; 15+ messages in thread
From: Uma Krishnan @ 2015-12-14 21:07 UTC (permalink / raw)
  To: linux-scsi, James Bottomley, Martin K. Petersen, Matthew R. Ochs,
	Manoj N. Kumar, Brian King
  Cc: linuxppc-dev, Ian Munsie, Andrew Donnellan, Daniel Axtens

From: Manoj Kumar <manoj@linux.vnet.ibm.com>

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.

Signed-off-by: Manoj N. Kumar <manoj@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
---
 drivers/scsi/cxlflash/main.c | 3 +++
 drivers/scsi/cxlflash/main.h | 4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c
index 30542ca..f6d90ce 100644
--- a/drivers/scsi/cxlflash/main.c
+++ b/drivers/scsi/cxlflash/main.c
@@ -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},
 	{}
 };
 
diff --git a/drivers/scsi/cxlflash/main.h b/drivers/scsi/cxlflash/main.h
index 7e2d0e1..0faed42 100644
--- a/drivers/scsi/cxlflash/main.h
+++ b/drivers/scsi/cxlflash/main.h
@@ -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
-- 
2.1.0

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

* Re: [PATCH v2 3/6] cxlflash: Removed driver date print
  2015-12-14 21:06 ` [PATCH v2 3/6] cxlflash: Removed driver date print Uma Krishnan
@ 2015-12-14 23:45   ` Matthew R. Ochs
  2015-12-15  0:20   ` Andrew Donnellan
  2015-12-15 21:04   ` Manoj Kumar
  2 siblings, 0 replies; 15+ messages in thread
From: Matthew R. Ochs @ 2015-12-14 23:45 UTC (permalink / raw)
  To: Uma Krishnan
  Cc: linux-scsi, James Bottomley, Martin K. Petersen, Manoj N. Kumar,
	Brian King, linuxppc-dev, Ian Munsie, Andrew Donnellan,
	Daniel Axtens

Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>

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

* Re: [PATCH v2 3/6] cxlflash: Removed driver date print
  2015-12-14 21:06 ` [PATCH v2 3/6] cxlflash: Removed driver date print Uma Krishnan
  2015-12-14 23:45   ` Matthew R. Ochs
@ 2015-12-15  0:20   ` Andrew Donnellan
  2015-12-15 21:04   ` Manoj Kumar
  2 siblings, 0 replies; 15+ messages in thread
From: Andrew Donnellan @ 2015-12-15  0:20 UTC (permalink / raw)
  To: Uma Krishnan, linux-scsi, James Bottomley, Martin K. Petersen,
	Matthew R. Ochs, Manoj N. Kumar, Brian King
  Cc: linuxppc-dev, Ian Munsie, Daniel Axtens

On 15/12/15 08:06, Uma Krishnan wrote:
> 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.
>
> Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>

Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>

-- 
Andrew Donnellan              Software Engineer, OzLabs
andrew.donnellan@au1.ibm.com  Australia Development Lab, Canberra
+61 2 6201 8874 (work)        IBM Australia Limited

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

* Re: [PATCH v2 4/6] cxlflash: Fix to resolve cmd leak after host reset
  2015-12-14 21:07 ` [PATCH v2 4/6] cxlflash: Fix to resolve cmd leak after host reset Uma Krishnan
@ 2015-12-15  2:45   ` Andrew Donnellan
  0 siblings, 0 replies; 15+ messages in thread
From: Andrew Donnellan @ 2015-12-15  2:45 UTC (permalink / raw)
  To: Uma Krishnan, linux-scsi, James Bottomley, Martin K. Petersen,
	Matthew R. Ochs, Manoj N. Kumar, Brian King
  Cc: linuxppc-dev, Ian Munsie, Daniel Axtens

On 15/12/15 08:07, Uma Krishnan wrote:
> From: Manoj Kumar <manoj@linux.vnet.ibm.com>
>
> 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.
>
> Signed-off-by: Manoj N. Kumar <manoj@linux.vnet.ibm.com>
> Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>

Looks reasonable.

Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>

-- 
Andrew Donnellan              Software Engineer, OzLabs
andrew.donnellan@au1.ibm.com  Australia Development Lab, Canberra
+61 2 6201 8874 (work)        IBM Australia Limited

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

* Re: [PATCH v2 6/6] cxlflash: Enable device id for future IBM CXL adapter
  2015-12-14 21:07 ` [PATCH v2 6/6] cxlflash: Enable device id for future IBM CXL adapter Uma Krishnan
@ 2015-12-15  3:11   ` Andrew Donnellan
  0 siblings, 0 replies; 15+ messages in thread
From: Andrew Donnellan @ 2015-12-15  3:11 UTC (permalink / raw)
  To: Uma Krishnan, linux-scsi, James Bottomley, Martin K. Petersen,
	Matthew R. Ochs, Manoj N. Kumar, Brian King
  Cc: Daniel Axtens, linuxppc-dev, Ian Munsie

On 15/12/15 08:07, Uma Krishnan wrote:
> From: Manoj Kumar <manoj@linux.vnet.ibm.com>
>
> 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."

>
> 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.
>
> Signed-off-by: Manoj N. Kumar <manoj@linux.vnet.ibm.com>
> Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>

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

Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>

-- 
Andrew Donnellan              Software Engineer, OzLabs
andrew.donnellan@au1.ibm.com  Australia Development Lab, Canberra
+61 2 6201 8874 (work)        IBM Australia Limited

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

* Re: [PATCH v2 3/6] cxlflash: Removed driver date print
  2015-12-14 21:06 ` [PATCH v2 3/6] cxlflash: Removed driver date print Uma Krishnan
  2015-12-14 23:45   ` Matthew R. Ochs
  2015-12-15  0:20   ` Andrew Donnellan
@ 2015-12-15 21:04   ` Manoj Kumar
  2 siblings, 0 replies; 15+ messages in thread
From: Manoj Kumar @ 2015-12-15 21:04 UTC (permalink / raw)
  To: Uma Krishnan, linux-scsi, James Bottomley, Martin K. Petersen,
	Matthew R. Ochs, Brian King
  Cc: linuxppc-dev, Ian Munsie, Andrew Donnellan, Daniel Axtens

On 12/14/2015 3:06 PM, Uma Krishnan wrote:
> 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.
>
> Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
> ---

Acked-by: Manoj N. Kumar <manoj@linux.vnet.ibm.com>

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

* Re: [PATCH v2 0/6] cxlflash: Miscellaneous fixes and updates
  2015-12-14 20:51 [PATCH v2 0/6] cxlflash: Miscellaneous fixes and updates Uma Krishnan
                   ` (5 preceding siblings ...)
  2015-12-14 21:07 ` [PATCH v2 6/6] cxlflash: Enable device id for future IBM CXL adapter Uma Krishnan
@ 2016-01-07  2:01 ` Martin K. Petersen
  6 siblings, 0 replies; 15+ messages in thread
From: Martin K. Petersen @ 2016-01-07  2:01 UTC (permalink / raw)
  To: Uma Krishnan
  Cc: linux-scsi, James Bottomley, Martin K. Petersen, Matthew R. Ochs,
	Manoj N. Kumar, Brian King, linuxppc-dev, Ian Munsie,
	Andrew Donnellan, Daniel Axtens

>>>>> "Uma" == Uma Krishnan <ukrishn@linux.vnet.ibm.com> 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.

-- 
Martin K. Petersen	Oracle Linux Engineering

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

end of thread, other threads:[~2016-01-07  2:02 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-14 20:51 [PATCH v2 0/6] cxlflash: Miscellaneous fixes and updates Uma Krishnan
2015-12-14 20:55 ` Uma Krishnan
2015-12-14 20:55   ` [PATCH v2 1/6] cxlflash: Fix to escalate LINK_RESET also on port 1 Uma Krishnan
2015-12-14 20:55 ` [PATCH v2 0/6] cxlflash: Miscellaneous fixes and updates Uma Krishnan
2015-12-14 20:55   ` [PATCH v2 2/6] cxlflash: Fix to avoid virtual LUN failover failure Uma Krishnan
2015-12-14 21:06 ` [PATCH v2 3/6] cxlflash: Removed driver date print Uma Krishnan
2015-12-14 23:45   ` Matthew R. Ochs
2015-12-15  0:20   ` Andrew Donnellan
2015-12-15 21:04   ` Manoj Kumar
2015-12-14 21:07 ` [PATCH v2 4/6] cxlflash: Fix to resolve cmd leak after host reset Uma Krishnan
2015-12-15  2:45   ` Andrew Donnellan
2015-12-14 21:07 ` [PATCH v2 5/6] cxlflash: Resolve oops in wait_port_offline Uma Krishnan
2015-12-14 21:07 ` [PATCH v2 6/6] cxlflash: Enable device id for future IBM CXL adapter Uma Krishnan
2015-12-15  3:11   ` Andrew Donnellan
2016-01-07  2:01 ` [PATCH v2 0/6] cxlflash: Miscellaneous fixes and updates Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).