Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8396012f authored by Matthew R. Ochs's avatar Matthew R. Ochs Committed by James Bottomley
Browse files

cxlflash: Fix location of setting resid



The resid is incorrectly set which can lead to unnecessary retry
attempts by the stack. This is due to resid _always_ being set
using a value returned from the adapter. Instead, the value
should only be interpreted and set when in an underrun scenario.

Signed-off-by: default avatarMatthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: default avatarManoj N. Kumar <manoj@linux.vnet.ibm.com>
Reviewed-by: default avatarBrian King <brking@linux.vnet.ibm.com>
Reviewed-by: default avatarTomas Henzl <thenzl@redhat.com>
Signed-off-by: default avatarJames Bottomley <JBottomley@Odin.com>
parent 018d1dc9
Loading
Loading
Loading
Loading
+8 −12
Original line number Original line Diff line number Diff line
@@ -107,6 +107,7 @@ static void process_cmd_err(struct afu_cmd *cmd, struct scsi_cmnd *scp)
{
{
	struct sisl_ioarcb *ioarcb;
	struct sisl_ioarcb *ioarcb;
	struct sisl_ioasa *ioasa;
	struct sisl_ioasa *ioasa;
	u32 resid;


	if (unlikely(!cmd))
	if (unlikely(!cmd))
		return;
		return;
@@ -115,9 +116,10 @@ static void process_cmd_err(struct afu_cmd *cmd, struct scsi_cmnd *scp)
	ioasa = &(cmd->sa);
	ioasa = &(cmd->sa);


	if (ioasa->rc.flags & SISL_RC_FLAGS_UNDERRUN) {
	if (ioasa->rc.flags & SISL_RC_FLAGS_UNDERRUN) {
		pr_debug("%s: cmd underrun cmd = %p scp = %p\n",
		resid = ioasa->resid;
			 __func__, cmd, scp);
		scsi_set_resid(scp, resid);
		scp->result = (DID_ERROR << 16);
		pr_debug("%s: cmd underrun cmd = %p scp = %p, resid = %d\n",
			 __func__, cmd, scp, resid);
	}
	}


	if (ioasa->rc.flags & SISL_RC_FLAGS_OVERRUN) {
	if (ioasa->rc.flags & SISL_RC_FLAGS_OVERRUN) {
@@ -158,8 +160,7 @@ static void process_cmd_err(struct afu_cmd *cmd, struct scsi_cmnd *scp)
				/* If the SISL_RC_FLAGS_OVERRUN flag was set,
				/* If the SISL_RC_FLAGS_OVERRUN flag was set,
				 * then we will handle this error else where.
				 * then we will handle this error else where.
				 * If not then we must handle it here.
				 * If not then we must handle it here.
				 * This is probably an AFU bug. We will
				 * This is probably an AFU bug.
				 * attempt a retry to see if that resolves it.
				 */
				 */
				scp->result = (DID_ERROR << 16);
				scp->result = (DID_ERROR << 16);
			}
			}
@@ -183,7 +184,7 @@ static void process_cmd_err(struct afu_cmd *cmd, struct scsi_cmnd *scp)
		/* We have an AFU error */
		/* We have an AFU error */
		switch (ioasa->rc.afu_rc) {
		switch (ioasa->rc.afu_rc) {
		case SISL_AFU_RC_NO_CHANNELS:
		case SISL_AFU_RC_NO_CHANNELS:
			scp->result = (DID_MEDIUM_ERROR << 16);
			scp->result = (DID_NO_CONNECT << 16);
			break;
			break;
		case SISL_AFU_RC_DATA_DMA_ERR:
		case SISL_AFU_RC_DATA_DMA_ERR:
			switch (ioasa->afu_extra) {
			switch (ioasa->afu_extra) {
@@ -217,7 +218,6 @@ static void process_cmd_err(struct afu_cmd *cmd, struct scsi_cmnd *scp)
static void cmd_complete(struct afu_cmd *cmd)
static void cmd_complete(struct afu_cmd *cmd)
{
{
	struct scsi_cmnd *scp;
	struct scsi_cmnd *scp;
	u32 resid;
	ulong lock_flags;
	ulong lock_flags;
	struct afu *afu = cmd->parent;
	struct afu *afu = cmd->parent;
	struct cxlflash_cfg *cfg = afu->parent;
	struct cxlflash_cfg *cfg = afu->parent;
@@ -229,14 +229,11 @@ static void cmd_complete(struct afu_cmd *cmd)


	if (cmd->rcb.scp) {
	if (cmd->rcb.scp) {
		scp = cmd->rcb.scp;
		scp = cmd->rcb.scp;
		if (unlikely(cmd->sa.rc.afu_rc ||
		if (unlikely(cmd->sa.ioasc))
			     cmd->sa.rc.scsi_rc ||
			     cmd->sa.rc.fc_rc))
			process_cmd_err(cmd, scp);
			process_cmd_err(cmd, scp);
		else
		else
			scp->result = (DID_OK << 16);
			scp->result = (DID_OK << 16);


		resid = cmd->sa.resid;
		cmd_is_tmf = cmd->cmd_tmf;
		cmd_is_tmf = cmd->cmd_tmf;
		cmd_checkin(cmd); /* Don't use cmd after here */
		cmd_checkin(cmd); /* Don't use cmd after here */


@@ -244,7 +241,6 @@ static void cmd_complete(struct afu_cmd *cmd)
				     "ioasc=%d\n", __func__, scp, scp->result,
				     "ioasc=%d\n", __func__, scp, scp->result,
				     cmd->sa.ioasc);
				     cmd->sa.ioasc);


		scsi_set_resid(scp, resid);
		scsi_dma_unmap(scp);
		scsi_dma_unmap(scp);
		scp->scsi_done(scp);
		scp->scsi_done(scp);