Re: [PATCH v4 22/23] mac_scsi: Fix pseudo DMA implementation

From: Geert Uytterhoeven
Date: Thu May 19 2016 - 05:00:18 EST


Hi Finn,

On Wed, Mar 23, 2016 at 11:10 AM, Finn Thain <fthain@xxxxxxxxxxxxxxxxxxx> wrote:
> Fix various issues: Comments about bus errors are incorrect. The
> PDMA asm must return the size of the memory access that faulted so the
> transfer count can be adjusted accordingly. A phase change may cause a
> bus error but should not be treated as failure. A bus error does not
> always imply a phase change and generally the transfer may continue.
> Scatter/gather doesn't seem to work with PDMA due to overruns. This is
> a pity because peak throughput seems to double with SG_ALL.
> Tested on a Mac LC III and a PowerBook 520.
>
> Signed-off-by: Finn Thain <fthain@xxxxxxxxxxxxxxxxxxx>
> Reviewed-by: Hannes Reinecke <hare@xxxxxxxx>

> --- linux.orig/drivers/scsi/mac_scsi.c 2016-03-23 21:09:53.000000000 +1100
> +++ linux/drivers/scsi/mac_scsi.c 2016-03-23 21:10:05.000000000 +1100

> @@ -104,18 +105,9 @@ static int __init mac_scsi_setup(char *s

> static int macscsi_pread(struct Scsi_Host *instance,
> unsigned char *dst, int len)
> {
> struct NCR5380_hostdata *hostdata = shost_priv(instance);
> - unsigned char *d;
> - unsigned char *s;
> -
> - s = hostdata->pdma_base + (INPUT_DATA_REG << 4);
> - d = dst;
> -
> - /* These conditions are derived from MacOS */
> -
> - while (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ) &&
> - !(NCR5380_read(STATUS_REG) & SR_REQ))
> - ;
> -
> - if (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ) &&
> - (NCR5380_read(BUS_AND_STATUS_REG) & BASR_PHASE_MATCH)) {
> - pr_err("Error in macscsi_pread\n");
> - return -1;
> - }
> -
> - CP_IO_TO_MEM(s, d, len);
> -
> - if (len != 0) {
> - pr_notice("Bus error in macscsi_pread\n");
> - return -1;
> + unsigned char *s = hostdata->pdma_base + (INPUT_DATA_REG << 4);
> + unsigned char *d = dst;
> + int n = len;
> + int transferred;
> +
> + while (!NCR5380_poll_politely(instance, BUS_AND_STATUS_REG,
> + BASR_DRQ | BASR_PHASE_MATCH,
> + BASR_DRQ | BASR_PHASE_MATCH, HZ / 64)) {
> + CP_IO_TO_MEM(s, d, n);

This is now before the inclusion of NCR5380.c, causing

In file included from drivers/scsi/mac_scsi.c:335:
drivers/scsi/NCR5380.h:295: warning: âNCR5380_poll_politelyâ declared
inline after being called
drivers/scsi/NCR5380.h:295: warning: previous declaration of
âNCR5380_poll_politelyâ was here

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds