Skip to content

Commit fd47d91

Browse files
Finn Thainmartinkpetersen
authored andcommitted
scsi: esp_scsi: Track residual for PIO transfers
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 <[email protected]> Signed-off-by: Finn Thain <[email protected]> Tested-by: Michael Schmitz <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent b7ded0e commit fd47d91

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
@@ -1352,6 +1352,7 @@ static int esp_data_bytes_sent(struct esp *esp, struct esp_cmd_entry *ent,
13521352

13531353
bytes_sent = esp->data_dma_len;
13541354
bytes_sent -= ecount;
1355+
bytes_sent -= esp->send_cmd_residual;
13551356

13561357
/*
13571358
* 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
@@ -524,6 +524,8 @@ struct esp {
524524

525525
void *dma;
526526
int dmarev;
527+
528+
u32 send_cmd_residual;
527529
};
528530

529531
/* 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
@@ -394,6 +394,8 @@ static void mac_esp_send_pio_cmd(struct esp *esp, u32 addr, u32 esp_count,
394394
scsi_esp_cmd(esp, ESP_CMD_TI);
395395
}
396396
}
397+
398+
esp->send_cmd_residual = esp_count;
397399
}
398400

399401
static int mac_esp_irq_pending(struct esp *esp)

0 commit comments

Comments
 (0)