Skip to content

Commit c8ae045

Browse files
Finn Thainsmb49
authored andcommitted
scsi: esp_scsi: Track residual for PIO transfers
BugLink: http://bugs.launchpad.net/bugs/1810820 [ Upstream commit fd47d91 ] 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. That 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: 6fe07aa ("[SCSI] m68k: new mac_esp scsi driver") Tested-by: Stan Johnson <userm57@yahoo.com> Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Tested-by: Michael Schmitz <schmitzmic@gmail.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Kamal Mostafa <kamal@canonical.com> Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
1 parent c444c42 commit c8ae045

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

drivers/scsi/esp_scsi.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,6 +1338,7 @@ static int esp_data_bytes_sent(struct esp *esp, struct esp_cmd_entry *ent,
13381338

13391339
bytes_sent = esp->data_dma_len;
13401340
bytes_sent -= ecount;
1341+
bytes_sent -= esp->send_cmd_residual;
13411342

13421343
/*
13431344
* The am53c974 has a DMA 'pecularity'. The doc states:

drivers/scsi/esp_scsi.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,8 @@ struct esp {
540540

541541
void *dma;
542542
int dmarev;
543+
544+
u32 send_cmd_residual;
543545
};
544546

545547
/* A front-end driver for the ESP chip should do the following in

drivers/scsi/mac_esp.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,8 @@ static void mac_esp_send_pio_cmd(struct esp *esp, u32 addr, u32 esp_count,
427427
scsi_esp_cmd(esp, ESP_CMD_TI);
428428
}
429429
}
430+
431+
esp->send_cmd_residual = esp_count;
430432
}
431433

432434
static int mac_esp_irq_pending(struct esp *esp)

0 commit comments

Comments
 (0)