scsi: esp_scsi: Track residual for PIO transfers
authorFinn Thain <fthain@telegraphics.com.au>
Tue, 16 Oct 2018 05:31:25 +0000 (16:31 +1100)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 18 Oct 2018 01:34:20 +0000 (21:34 -0400)
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: 6fe07aaffbf0 ("[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>
drivers/scsi/esp_scsi.c
drivers/scsi/esp_scsi.h
drivers/scsi/mac_esp.c

index 5cd97d2..cba58cf 100644 (file)
@@ -1352,6 +1352,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:
index 3b1b501..8062b53 100644 (file)
@@ -524,6 +524,8 @@ struct esp {
 
        void                    *dma;
        int                     dmarev;
+
+       u32                     send_cmd_residual;
 };
 
 /* A front-end driver for the ESP chip should do the following in
index 2769df5..c92b6c1 100644 (file)
@@ -394,6 +394,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)