[PATCH 0/3] cxlflash: Miscellaneous fixes

STALE3292d

Revision v1 of 3 in this series.

4 messages, 1 author, 2017-08-25 · open the first message on its own page

[PATCH 0/3] cxlflash: Miscellaneous fixes

From: Uma Krishnan <hidden>
Date: 2017-08-25 22:17:32

This patch series contains miscellaneous fixes. The first two address
issues that were identified by smatch and the last patch fixes a regression
introduced by Commit 565180723294 ("scsi: cxlflash: SISlite updates to
support 4 ports").

This series is intended for 4.14 and is bisectable.

Matthew R. Ochs (2):
  cxlflash: Remove unnecessary existence check
  cxlflash: Avoid double mutex unlock

Uma Krishnan (1):
  cxlflash: Fix vlun resize failure in the shrink path

 drivers/scsi/cxlflash/main.c      |  3 +--
 drivers/scsi/cxlflash/superpipe.c | 13 ++++++++++---
 drivers/scsi/cxlflash/vlun.c      |  6 +-----
 3 files changed, 12 insertions(+), 10 deletions(-)

-- 
2.1.0

[PATCH 1/3] cxlflash: Remove unnecessary existence check

From: Uma Krishnan <hidden>
Date: 2017-08-25 22:18:02

From: "Matthew R. Ochs" <redacted>

The AFU termination sequence has been refactored over time such that
the main tear down routine, term_afu(), can no longer can be invoked
with a NULL AFU pointer. Remove the unnecessary existence check from
term_afu().

Signed-off-by: Matthew R. Ochs <redacted>
Signed-off-by: Uma Krishnan <redacted>
---
 drivers/scsi/cxlflash/main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c
index 6a4367c..76b8b7ee 100644
--- a/drivers/scsi/cxlflash/main.c
+++ b/drivers/scsi/cxlflash/main.c
@@ -820,8 +820,7 @@ static void term_afu(struct cxlflash_cfg *cfg)
 	for (k = cfg->afu->num_hwqs - 1; k >= 0; k--)
 		term_intr(cfg, UNMAP_THREE, k);
 
-	if (cfg->afu)
-		stop_afu(cfg);
+	stop_afu(cfg);
 
 	for (k = cfg->afu->num_hwqs - 1; k >= 0; k--)
 		term_mc(cfg, k);
-- 
2.1.0

[PATCH 2/3] cxlflash: Avoid double mutex unlock

From: Uma Krishnan <hidden>
Date: 2017-08-25 22:18:11

From: "Matthew R. Ochs" <redacted>

The AFU recovery routine uses an interruptible mutex to control the
flow of in-flight recoveries. Upon receiving an interruptible signal
the code branches to a common exit path which wrongly assumes the
mutex is held. Add a local variable to track when the mutex should be
unlocked.

Signed-off-by: Matthew R. Ochs <redacted>
Signed-off-by: Uma Krishnan <redacted>
---
 drivers/scsi/cxlflash/superpipe.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/scsi/cxlflash/superpipe.c b/drivers/scsi/cxlflash/superpipe.c
index ad0f996..e9ee1d9 100644
--- a/drivers/scsi/cxlflash/superpipe.c
+++ b/drivers/scsi/cxlflash/superpipe.c
@@ -1650,6 +1650,7 @@ static int cxlflash_afu_recover(struct scsi_device *sdev,
 	u64 ctxid = DECODE_CTXID(recover->context_id),
 	    rctxid = recover->context_id;
 	long reg;
+	bool locked = true;
 	int lretry = 20; /* up to 2 seconds */
 	int new_adap_fd = -1;
 	int rc = 0;
@@ -1658,8 +1659,11 @@ static int cxlflash_afu_recover(struct scsi_device *sdev,
 	up_read(&cfg->ioctl_rwsem);
 	rc = mutex_lock_interruptible(mutex);
 	down_read(&cfg->ioctl_rwsem);
-	if (rc)
+	if (rc) {
+		locked = false;
 		goto out;
+	}
+
 	rc = check_state(cfg);
 	if (rc) {
 		dev_err(dev, "%s: Failed state rc=%d\n", __func__, rc);
@@ -1693,8 +1697,10 @@ static int cxlflash_afu_recover(struct scsi_device *sdev,
 				mutex_unlock(mutex);
 				msleep(100);
 				rc = mutex_lock_interruptible(mutex);
-				if (rc)
+				if (rc) {
+					locked = false;
 					goto out;
+				}
 				goto retry_recover;
 			}
 
@@ -1738,7 +1744,8 @@ static int cxlflash_afu_recover(struct scsi_device *sdev,
 out:
 	if (likely(ctxi))
 		put_context(ctxi);
-	mutex_unlock(mutex);
+	if (locked)
+		mutex_unlock(mutex);
 	atomic_dec_if_positive(&cfg->recovery_threads);
 	return rc;
 }
-- 
2.1.0

[PATCH 3/3] cxlflash: Fix vlun resize failure in the shrink path

From: Uma Krishnan <hidden>
Date: 2017-08-25 22:18:20

The ioctl DK_CAPI_VLUN_RESIZE can fail if the allocated vlun size is
reduced from almost maximum capacity and then increased again.

The shrink_lxt() routine is currently using the SISL_ASTATUS_MASK to mask
the higher 48 bits of the lxt entry. This is unnecessary and incorrect as
it uses a mask designed for the asynchronous interrupt status register.
When the 4 port support was added to cxlflash, the SISL_ASTATUS_MASK was
updated to reflect the status bits for all 4 ports. This change indirectly
affected the shrink_lxt() code path.

To extract the base, simply shift the bits without masking.

Fixes: 565180723294 ("scsi: cxlflash: SISlite updates to support 4 ports")

Signed-off-by: Uma Krishnan <redacted>
---
 drivers/scsi/cxlflash/vlun.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/scsi/cxlflash/vlun.c b/drivers/scsi/cxlflash/vlun.c
index bdfb930..703bf1e 100644
--- a/drivers/scsi/cxlflash/vlun.c
+++ b/drivers/scsi/cxlflash/vlun.c
@@ -694,11 +694,7 @@ static int shrink_lxt(struct afu *afu,
 	/* Free LBAs allocated to freed chunks */
 	mutex_lock(&blka->mutex);
 	for (i = delta - 1; i >= 0; i--) {
-		/* Mask the higher 48 bits before shifting, even though
-		 * it is a noop
-		 */
-		aun = (lxt_old[my_new_size + i].rlba_base & SISL_ASTATUS_MASK);
-		aun = (aun >> MC_CHUNK_SHIFT);
+		aun = lxt_old[my_new_size + i].rlba_base >> MC_CHUNK_SHIFT;
 		if (needs_ws)
 			write_same16(sdev, aun, MC_CHUNK_SIZE);
 		ba_free(&blka->ba_lun, aun);
-- 
2.1.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help