cxlflash: Miscellaneous fixes
cover cxlflash: Miscellaneous fixes
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(-)
Signature · 1 line
2.1.0
PATCH 1/3 cxlflash: Remove unnecessary existence check
From: "Matthew R. Ochs" <[email protected]>
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().
--- drivers/scsi/cxlflash/main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/cxlflash/main.c +1 -2
@@ -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);
Signature · 1 line
2.1.0
PATCH 2/3 cxlflash: Avoid double mutex unlock
In reply to Uma KrishnanFrom: "Matthew R. Ochs" <[email protected]>
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.
--- drivers/scsi/cxlflash/superpipe.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/scsi/cxlflash/superpipe.c +10 -3
@@ -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; }
Signature · 1 line
2.1.0
PATCH 3/3 cxlflash: Fix vlun resize failure in the shrink path
In reply to Uma KrishnanThe 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.
--- drivers/scsi/cxlflash/vlun.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/scsi/cxlflash/vlun.c +1 -5
@@ -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);
Signature · 1 line
2.1.0
Martin K. Petersen
AppliedUma,
Quoted 4 lines
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").
Applied to 4.14/scsi-queue. Thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering