linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Finn Thain <fthain@telegraphics.com.au>
To: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Michael Schmitz <schmitzmic@gmail.com>,
	Hannes Reinecke <hare@suse.de>,
	linux-scsi@vger.kernel.org, linux-m68k@lists.linux-m68k.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 2/6] esp_scsi: Track residual for PIO transfers
Date: Sat, 13 Oct 2018 11:51:16 +1100	[thread overview]
Message-ID: <bfcbc04b25b4baa99bb7434a237c555908e36bd9.1539391876.git.fthain@telegraphics.com.au> (raw)
In-Reply-To: <cover.1539391876.git.fthain@telegraphics.com.au>

If a target disconnects during a PIO data transfer the command may
fail when the target reconnects:

scsi host1: DMA length is zero!
scsi host1: cur adr[04380000] len[00000000]

The scsi bus is then reset. This happens because the residual reached
zero before the transfer was completed.

The usual residual calculation relies on the Transfer Count registers
which works for DMA transfers but not for PIO transfers. Fix the problem
by storing the PIO transfer residual and using that to correctly
calculate bytes_sent.

Fixes: 6fe07aaffbf0
Tested-by: Stan Johnson <userm57@yahoo.com>
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
---
 drivers/scsi/esp_scsi.c | 1 +
 drivers/scsi/esp_scsi.h | 2 ++
 drivers/scsi/mac_esp.c  | 2 ++
 3 files changed, 5 insertions(+)

diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c
index c3fc34b9964d..9e5d3f7d29ae 100644
--- a/drivers/scsi/esp_scsi.c
+++ b/drivers/scsi/esp_scsi.c
@@ -1338,6 +1338,7 @@ static int esp_data_bytes_sent(struct esp *esp, struct esp_cmd_entry *ent,
 
 	bytes_sent = esp->data_dma_len;
 	bytes_sent -= ecount;
+	bytes_sent -= esp->send_cmd_residual;
 
 	/*
 	 * The am53c974 has a DMA 'pecularity'. The doc states:
diff --git a/drivers/scsi/esp_scsi.h b/drivers/scsi/esp_scsi.h
index 8163dca2071b..db4b6ea94caa 100644
--- a/drivers/scsi/esp_scsi.h
+++ b/drivers/scsi/esp_scsi.h
@@ -540,6 +540,8 @@ struct esp {
 
 	void			*dma;
 	int			dmarev;
+
+	int			send_cmd_residual;
 };
 
 /* A front-end driver for the ESP chip should do the following in
diff --git a/drivers/scsi/mac_esp.c b/drivers/scsi/mac_esp.c
index eb551f3cc471..71879f2207e0 100644
--- a/drivers/scsi/mac_esp.c
+++ b/drivers/scsi/mac_esp.c
@@ -427,6 +427,8 @@ static void mac_esp_send_pio_cmd(struct esp *esp, u32 addr, u32 esp_count,
 			scsi_esp_cmd(esp, ESP_CMD_TI);
 		}
 	}
+
+	esp->send_cmd_residual = esp_count;
 }
 
 static int mac_esp_irq_pending(struct esp *esp)
-- 
2.16.4


  parent reply	other threads:[~2018-10-13  1:11 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-13  0:51 [PATCH 0/6] mac_esp, zorro_esp, esp_scsi: Various improvements Finn Thain
2018-10-13  0:51 ` [PATCH 3/6] esp_scsi: Grant disconnect privilege for untagged commands Finn Thain
2018-10-13  0:51 ` Finn Thain [this message]
2018-10-13  0:51 ` [PATCH 1/6] zorro_esp: Limit DMA transfers to 65535 bytes Finn Thain
2018-10-13  0:51 ` [PATCH 5/6] esp_scsi: De-duplicate PIO routines Finn Thain
2018-10-13  7:05   ` Christoph Hellwig
2018-10-13  7:22     ` Finn Thain
2018-10-13  7:52       ` Christoph Hellwig
2018-10-15  5:54   ` Hannes Reinecke
2018-10-15  6:17     ` Finn Thain
2018-10-13  0:51 ` [PATCH 6/6] esp_scsi: Optimize PIO loops Finn Thain
2018-10-13  4:02   ` Michael Schmitz
2018-10-13  4:09     ` Finn Thain
2018-10-13  4:18       ` Michael Schmitz
2018-10-13  0:51 ` [PATCH 4/6] esp_scsi: Eliminate ESP_FLAG_DOING_SLOWCMD Finn Thain
2018-10-14  1:36 ` [PATCH 0/6] mac_esp, zorro_esp, esp_scsi: Various improvements Michael Schmitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bfcbc04b25b4baa99bb7434a237c555908e36bd9.1539391876.git.fthain@telegraphics.com.au \
    --to=fthain@telegraphics.com.au \
    --cc=hare@suse.de \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@lists.linux-m68k.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=schmitzmic@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).