* [PATCH 1/3] cxlflash: Remove unnecessary existence check
2017-08-25 22:17 [PATCH 0/3] cxlflash: Miscellaneous fixes Uma Krishnan
@ 2017-08-25 22:17 ` Uma Krishnan
2017-08-25 22:18 ` [PATCH 2/3] cxlflash: Avoid double mutex unlock Uma Krishnan
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Uma Krishnan @ 2017-08-25 22:17 UTC (permalink / raw)
To: linux-scsi, James Bottomley, Martin K. Petersen, Matthew R. Ochs,
Manoj N. Kumar
Cc: linuxppc-dev, Andrew Donnellan, Frederic Barrat,
Christophe Lombard
From: "Matthew R. Ochs" <mrochs@linux.vnet.ibm.com>
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 <mrochs@linux.vnet.ibm.com>
Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
---
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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/3] cxlflash: Avoid double mutex unlock
2017-08-25 22:17 [PATCH 0/3] cxlflash: Miscellaneous fixes Uma Krishnan
2017-08-25 22:17 ` [PATCH 1/3] cxlflash: Remove unnecessary existence check Uma Krishnan
@ 2017-08-25 22:18 ` Uma Krishnan
2017-08-25 22:18 ` [PATCH 3/3] cxlflash: Fix vlun resize failure in the shrink path Uma Krishnan
2017-08-25 22:24 ` [PATCH 0/3] cxlflash: Miscellaneous fixes Martin K. Petersen
3 siblings, 0 replies; 7+ messages in thread
From: Uma Krishnan @ 2017-08-25 22:18 UTC (permalink / raw)
To: linux-scsi, James Bottomley, Martin K. Petersen, Matthew R. Ochs,
Manoj N. Kumar
Cc: linuxppc-dev, Andrew Donnellan, Frederic Barrat,
Christophe Lombard
From: "Matthew R. Ochs" <mrochs@linux.vnet.ibm.com>
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 <mrochs@linux.vnet.ibm.com>
Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
---
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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/3] cxlflash: Fix vlun resize failure in the shrink path
2017-08-25 22:17 [PATCH 0/3] cxlflash: Miscellaneous fixes Uma Krishnan
2017-08-25 22:17 ` [PATCH 1/3] cxlflash: Remove unnecessary existence check Uma Krishnan
2017-08-25 22:18 ` [PATCH 2/3] cxlflash: Avoid double mutex unlock Uma Krishnan
@ 2017-08-25 22:18 ` Uma Krishnan
2017-08-25 22:24 ` [PATCH 0/3] cxlflash: Miscellaneous fixes Martin K. Petersen
3 siblings, 0 replies; 7+ messages in thread
From: Uma Krishnan @ 2017-08-25 22:18 UTC (permalink / raw)
To: linux-scsi, James Bottomley, Martin K. Petersen, Matthew R. Ochs,
Manoj N. Kumar
Cc: linuxppc-dev, Andrew Donnellan, Frederic Barrat,
Christophe Lombard
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 <ukrishn@linux.vnet.ibm.com>
---
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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 0/3] cxlflash: Miscellaneous fixes
2017-08-25 22:17 [PATCH 0/3] cxlflash: Miscellaneous fixes Uma Krishnan
` (2 preceding siblings ...)
2017-08-25 22:18 ` [PATCH 3/3] cxlflash: Fix vlun resize failure in the shrink path Uma Krishnan
@ 2017-08-25 22:24 ` Martin K. Petersen
3 siblings, 0 replies; 7+ messages in thread
From: Martin K. Petersen @ 2017-08-25 22:24 UTC (permalink / raw)
To: Uma Krishnan
Cc: linux-scsi, James Bottomley, Martin K. Petersen, Matthew R. Ochs,
Manoj N. Kumar, linuxppc-dev, Andrew Donnellan, Frederic Barrat,
Christophe Lombard
Uma,
> 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!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 7+ messages in thread