Commit 7640d91d authored by Finn Thain's avatar Finn Thain Committed by Martin K. Petersen

scsi: mac_esp: Fix PIO transfers for MESSAGE IN phase

When in MESSAGE IN phase, the ESP device does not automatically
acknowledge each byte that is transferred by PIO. The mac_esp driver
neglects to explicitly ack them, which causes a timeout during messages
larger than one byte (e.g. tag bytes during reconnect). Fix this with an
ESP_CMD_MOK command after each byte.

The MESSAGE IN phase is also different in that each byte transferred
raises ESP_INTR_FDONE. So don't exit the transfer loop for this interrupt,
for this phase.

That resolves the "Reconnect IRQ2 timeout" error on those Macs which use
PIO transfers instead of PDMA. This patch also improves on the weak tests
for unexpected interrupts and phase changes during PIO transfers.
Tested-by: default avatarStan Johnson <userm57@yahoo.com>
Fixes: 02507a80 ("[PATCH] [SCSI] mac_esp: fix PIO mode, take 2")
Signed-off-by: default avatarFinn Thain <fthain@telegraphics.com.au>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent b36c7db9
...@@ -349,25 +349,23 @@ static void mac_esp_send_pio_cmd(struct esp *esp, u32 addr, u32 esp_count, ...@@ -349,25 +349,23 @@ static void mac_esp_send_pio_cmd(struct esp *esp, u32 addr, u32 esp_count,
{ {
struct mac_esp_priv *mep = MAC_ESP_GET_PRIV(esp); struct mac_esp_priv *mep = MAC_ESP_GET_PRIV(esp);
u8 __iomem *fifo = esp->regs + ESP_FDATA * 16; u8 __iomem *fifo = esp->regs + ESP_FDATA * 16;
u8 phase = esp->sreg & ESP_STAT_PMASK;
cmd &= ~ESP_CMD_DMA; cmd &= ~ESP_CMD_DMA;
mep->error = 0; mep->error = 0;
if (write) { if (write) {
u8 *dst = (u8 *)addr;
u8 mask = ~(phase == ESP_MIP ? ESP_INTR_FDONE : ESP_INTR_BSERV);
scsi_esp_cmd(esp, cmd); scsi_esp_cmd(esp, cmd);
while (1) { while (1) {
unsigned int n; if (!mac_esp_wait_for_fifo(esp))
n = mac_esp_wait_for_fifo(esp);
if (!n)
break; break;
if (n > esp_count) *dst++ = esp_read8(ESP_FDATA);
n = esp_count; --esp_count;
esp_count -= n;
MAC_ESP_PIO_LOOP("%2@,%0@+", n);
if (!esp_count) if (!esp_count)
break; break;
...@@ -375,14 +373,17 @@ static void mac_esp_send_pio_cmd(struct esp *esp, u32 addr, u32 esp_count, ...@@ -375,14 +373,17 @@ static void mac_esp_send_pio_cmd(struct esp *esp, u32 addr, u32 esp_count,
if (mac_esp_wait_for_intr(esp)) if (mac_esp_wait_for_intr(esp))
break; break;
if (((esp->sreg & ESP_STAT_PMASK) != ESP_DIP) && if ((esp->sreg & ESP_STAT_PMASK) != phase)
((esp->sreg & ESP_STAT_PMASK) != ESP_MIP))
break; break;
esp->ireg = esp_read8(ESP_INTRPT); esp->ireg = esp_read8(ESP_INTRPT);
if ((esp->ireg & (ESP_INTR_DC | ESP_INTR_BSERV)) != if (esp->ireg & mask) {
ESP_INTR_BSERV) mep->error = 1;
break; break;
}
if (phase == ESP_MIP)
scsi_esp_cmd(esp, ESP_CMD_MOK);
scsi_esp_cmd(esp, ESP_CMD_TI); scsi_esp_cmd(esp, ESP_CMD_TI);
} }
...@@ -402,14 +403,14 @@ static void mac_esp_send_pio_cmd(struct esp *esp, u32 addr, u32 esp_count, ...@@ -402,14 +403,14 @@ static void mac_esp_send_pio_cmd(struct esp *esp, u32 addr, u32 esp_count,
if (mac_esp_wait_for_intr(esp)) if (mac_esp_wait_for_intr(esp))
break; break;
if (((esp->sreg & ESP_STAT_PMASK) != ESP_DOP) && if ((esp->sreg & ESP_STAT_PMASK) != phase)
((esp->sreg & ESP_STAT_PMASK) != ESP_MOP))
break; break;
esp->ireg = esp_read8(ESP_INTRPT); esp->ireg = esp_read8(ESP_INTRPT);
if ((esp->ireg & (ESP_INTR_DC | ESP_INTR_BSERV)) != if (esp->ireg & ~ESP_INTR_BSERV) {
ESP_INTR_BSERV) mep->error = 1;
break; break;
}
n = MAC_ESP_FIFO_SIZE - n = MAC_ESP_FIFO_SIZE -
(esp_read8(ESP_FFLAGS) & ESP_FF_FBYTES); (esp_read8(ESP_FFLAGS) & ESP_FF_FBYTES);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment