1 |
From 0f201366b80bb62665636fab69f508842946161c Mon Sep 17 00:00:00 2001 |
2 |
From: Finn Thain <fthain@telegraphics.com.au> |
3 |
Date: Tue, 16 Oct 2018 16:31:25 +1100 |
4 |
Subject: [PATCH 091/145] scsi: esp_scsi: Track residual for PIO transfers |
5 |
|
6 |
[ Upstream commit fd47d919d0c336e7c22862b51ee94927ffea227a ] |
7 |
|
8 |
If a target disconnects during a PIO data transfer the command may fail |
9 |
when the target reconnects: |
10 |
|
11 |
scsi host1: DMA length is zero! |
12 |
scsi host1: cur adr[04380000] len[00000000] |
13 |
|
14 |
The scsi bus is then reset. This happens because the residual reached |
15 |
zero before the transfer was completed. |
16 |
|
17 |
The usual residual calculation relies on the Transfer Count registers. |
18 |
That works for DMA transfers but not for PIO transfers. Fix the problem |
19 |
by storing the PIO transfer residual and using that to correctly |
20 |
calculate bytes_sent. |
21 |
|
22 |
Fixes: 6fe07aaffbf0 ("[SCSI] m68k: new mac_esp scsi driver") |
23 |
Tested-by: Stan Johnson <userm57@yahoo.com> |
24 |
Signed-off-by: Finn Thain <fthain@telegraphics.com.au> |
25 |
Tested-by: Michael Schmitz <schmitzmic@gmail.com> |
26 |
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> |
27 |
Signed-off-by: Sasha Levin <sashal@kernel.org> |
28 |
--- |
29 |
drivers/scsi/esp_scsi.c | 1 + |
30 |
drivers/scsi/esp_scsi.h | 2 ++ |
31 |
drivers/scsi/mac_esp.c | 2 ++ |
32 |
3 files changed, 5 insertions(+) |
33 |
|
34 |
diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c |
35 |
index c3fc34b9964d..9e5d3f7d29ae 100644 |
36 |
--- a/drivers/scsi/esp_scsi.c |
37 |
+++ b/drivers/scsi/esp_scsi.c |
38 |
@@ -1338,6 +1338,7 @@ static int esp_data_bytes_sent(struct esp *esp, struct esp_cmd_entry *ent, |
39 |
|
40 |
bytes_sent = esp->data_dma_len; |
41 |
bytes_sent -= ecount; |
42 |
+ bytes_sent -= esp->send_cmd_residual; |
43 |
|
44 |
/* |
45 |
* The am53c974 has a DMA 'pecularity'. The doc states: |
46 |
diff --git a/drivers/scsi/esp_scsi.h b/drivers/scsi/esp_scsi.h |
47 |
index 8163dca2071b..a77772777a30 100644 |
48 |
--- a/drivers/scsi/esp_scsi.h |
49 |
+++ b/drivers/scsi/esp_scsi.h |
50 |
@@ -540,6 +540,8 @@ struct esp { |
51 |
|
52 |
void *dma; |
53 |
int dmarev; |
54 |
+ |
55 |
+ u32 send_cmd_residual; |
56 |
}; |
57 |
|
58 |
/* A front-end driver for the ESP chip should do the following in |
59 |
diff --git a/drivers/scsi/mac_esp.c b/drivers/scsi/mac_esp.c |
60 |
index eb551f3cc471..71879f2207e0 100644 |
61 |
--- a/drivers/scsi/mac_esp.c |
62 |
+++ b/drivers/scsi/mac_esp.c |
63 |
@@ -427,6 +427,8 @@ static void mac_esp_send_pio_cmd(struct esp *esp, u32 addr, u32 esp_count, |
64 |
scsi_esp_cmd(esp, ESP_CMD_TI); |
65 |
} |
66 |
} |
67 |
+ |
68 |
+ esp->send_cmd_residual = esp_count; |
69 |
} |
70 |
|
71 |
static int mac_esp_irq_pending(struct esp *esp) |
72 |
-- |
73 |
2.19.1 |
74 |
|