Re: [PATCH v3 1/4] cxlflash: Updates to legacy I/O

2015-08-05 Thread Matthew R. Ochs
 On Aug 5, 2015, at 10:44 AM, Brian King brk...@linux.vnet.ibm.com wrote:
 
 Hi Matt,
 
 Can you break this up into separate patches for these separate logical bug 
 fixes / changes?
 There is too much bundled all into a single patch here from my perspective.

Sure, I can do that for v4.

 
 Thanks,
 
 Brian
 
 -- 
 Brian King
 Power Linux I/O
 IBM Linux Technology Center
 
 

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 1/4] cxlflash: Updates to legacy I/O

2015-08-02 Thread Matthew R. Ochs
This patch addresses several issues found since originally submitting
support for legacy I/O on the IBM CXLflash adapter.

These include:
 - proper TMF handling
 - reworking sysfs attributes/handler as suggested by Shane Seymour
 - fixing cleanup bugs and potential memory leaks
 - spelling fixes
 - parameter/comment updates
 - making functions static
 - supporting host rescan
 - refining prints, using dev_* prints

Signed-off-by: Matthew R. Ochs mro...@linux.vnet.ibm.com
Signed-off-by: Manoj N. Kumar ma...@linux.vnet.ibm.com
---
 drivers/scsi/cxlflash/common.h  |9 +-
 drivers/scsi/cxlflash/main.c| 1329 ---
 drivers/scsi/cxlflash/main.h|1 +
 drivers/scsi/cxlflash/sislite.h |6 +-
 4 files changed, 684 insertions(+), 661 deletions(-)

diff --git a/drivers/scsi/cxlflash/common.h b/drivers/scsi/cxlflash/common.h
index fe86bfe..ba070a5 100644
--- a/drivers/scsi/cxlflash/common.h
+++ b/drivers/scsi/cxlflash/common.h
@@ -97,13 +97,13 @@ struct cxlflash_cfg {
enum cxlflash_init_state init_state;
enum cxlflash_lr_state lr_state;
int lr_port;
+   atomic_t scan_host_needed;
 
struct cxl_afu *cxl_afu;
-
-   struct pci_pool *cxlflash_cmd_pool;
struct pci_dev *parent_dev;
 
wait_queue_head_t tmf_waitq;
+   spinlock_t tmf_slock;
bool tmf_active;
u8 err_recovery_active:1;
 };
@@ -171,11 +171,6 @@ static inline u64 lun_to_lunid(u64 lun)
return swab64(lun_id);
 }
 
-int cxlflash_send_cmd(struct afu *, struct afu_cmd *);
-void cxlflash_wait_resp(struct afu *, struct afu_cmd *);
-int cxlflash_afu_reset(struct cxlflash_cfg *);
-struct afu_cmd *cxlflash_cmd_checkout(struct afu *);
-void cxlflash_cmd_checkin(struct afu_cmd *);
 int cxlflash_afu_sync(struct afu *, ctx_hndl_t, res_hndl_t, u8);
 #endif /* ifndef _CXLFLASH_COMMON_H */
 
diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c
index 76a7286..ae2351a 100644
--- a/drivers/scsi/cxlflash/main.c
+++ b/drivers/scsi/cxlflash/main.c
@@ -33,9 +33,8 @@ MODULE_AUTHOR(Manoj N. Kumar ma...@linux.vnet.ibm.com);
 MODULE_AUTHOR(Matthew R. Ochs mro...@linux.vnet.ibm.com);
 MODULE_LICENSE(GPL);
 
-
 /**
- * cxlflash_cmd_checkout() - checks out an AFU command
+ * cmd_checkout() - checks out an AFU command
  * @afu:   AFU to checkout from.
  *
  * Commands are checked out in a round-robin fashion. Note that since
@@ -46,7 +45,7 @@ MODULE_LICENSE(GPL);
  *
  * Return: The checked out command or NULL when command pool is empty.
  */
-struct afu_cmd *cxlflash_cmd_checkout(struct afu *afu)
+static struct afu_cmd *cmd_checkout(struct afu *afu)
 {
int k, dec = CXLFLASH_NUM_CMDS;
struct afu_cmd *cmd;
@@ -57,8 +56,8 @@ struct afu_cmd *cxlflash_cmd_checkout(struct afu *afu)
cmd = afu-cmd[k];
 
if (!atomic_dec_if_positive(cmd-free)) {
-   pr_debug(%s: returning found index=%d\n,
-__func__, cmd-slot);
+   pr_devel(%s: returning found index=%d cmd=%p\n,
+__func__, cmd-slot, cmd);
memset(cmd-buf, 0, CMD_BUFSIZE);
memset(cmd-rcb.cdb, 0, sizeof(cmd-rcb.cdb));
return cmd;
@@ -69,7 +68,7 @@ struct afu_cmd *cxlflash_cmd_checkout(struct afu *afu)
 }
 
 /**
- * cxlflash_cmd_checkin() - checks in an AFU command
+ * cmd_checkin() - checks in an AFU command
  * @cmd:   AFU command to checkin.
  *
  * Safe to pass commands that have already been checked in. Several
@@ -78,7 +77,7 @@ struct afu_cmd *cxlflash_cmd_checkout(struct afu *afu)
  * to avoid clobbering values in the event that the command is checked
  * out right away.
  */
-void cxlflash_cmd_checkin(struct afu_cmd *cmd)
+static void cmd_checkin(struct afu_cmd *cmd)
 {
cmd-rcb.scp = NULL;
cmd-rcb.timeout = 0;
@@ -92,7 +91,7 @@ void cxlflash_cmd_checkin(struct afu_cmd *cmd)
return;
}
 
-   pr_debug(%s: released cmd %p index=%d\n, __func__, cmd, cmd-slot);
+   pr_devel(%s: released cmd %p index=%d\n, __func__, cmd, cmd-slot);
 }
 
 /**
@@ -106,6 +105,7 @@ static void process_cmd_err(struct afu_cmd *cmd, struct 
scsi_cmnd *scp)
 {
struct sisl_ioarcb *ioarcb;
struct sisl_ioasa *ioasa;
+   u32 resid;
 
if (unlikely(!cmd))
return;
@@ -114,9 +114,10 @@ static void process_cmd_err(struct afu_cmd *cmd, struct 
scsi_cmnd *scp)
ioasa = (cmd-sa);
 
if (ioasa-rc.flags  SISL_RC_FLAGS_UNDERRUN) {
-   pr_debug(%s: cmd underrun cmd = %p scp = %p\n,
-__func__, cmd, scp);
-   scp-result = (DID_ERROR  16);
+   resid = ioasa-resid;
+   scsi_set_resid(scp, resid);
+   pr_debug(%s: cmd underrun cmd = %p scp = %p, resid = %d\n,
+__func__, cmd, scp, resid);
}
 
if