From: Finn Thain <fthain@telegraphics.com.au>
To: Ondrej Zary <linux@rainbow-software.org>
Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Michael Schmitz <schmitzmic@gmail.com>,
linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: g_NCR5380 PDMA, was Re: [PATCH 0/6] ncr5380: Miscellaneous minor patches
Date: Tue, 31 Jan 2017 12:31:45 +1100 (AEDT) [thread overview]
Message-ID: <alpine.LNX.2.00.1701311203001.16154@nippy.intranet> (raw)
In-Reply-To: <201701302252.13124.linux@rainbow-software.org>
On Mon, 30 Jan 2017, Ondrej Zary wrote:
>
> Also tested two CD-ROM drives and they didn't work (machine hangs). They
> didn't work before and looks like they never worked with PDMA.
>
> The fundamental problem of PDMA is that it either transfers all required
> data or it breaks horribly. Even when I added timeouts to the possibly
> infinite loops (to avoid hangs), the chip remained in some bad state.
> Sometimes the 53C80 gated IRQ check triggers. This can be hopefully
> fixed but there is a HW limitation: if less than 128 bytes were read
> from SCSI device, they get lost in chip buffer (the 128B buffers don't
> swap until full).
>
The core driver allows wrapper drivers to inhibit PDMA e.g. for inbound
transfers smaller than 128 bytes. This is used by atari_scsi and sun3_scsi
(as you probably realize). For example, atari_scsi now uses
cmd->sc_data_direction to find out the direction of the DMA transfer.
> Fortunately, most of the requests for too much data are bogus. The
> problem is that generic_NCR5380_dma_xfer_len() uses cmd->transfersize
> which seems to be wrong. All other NCR5380 drivers use
> cmd->SCp.this_residual.
>
Yes, this always looked wrong to me. Much of the logic in
generic_NCR5380_dma_xfer_len() looks suspicious but I see you've addressed
this below. Thanks for looking into this.
> This is also why rescan-scsi-bus hangs (cmd->transfersize is 8192 but
> cmd->SCp.this_residual is only 96).
>
Great, that resolves that mystery.
> This quick fix allows CD-ROM and also rescan-scsi-bus to work.
> But it's not complete. Seems that we need:
> - fix pread and pwrite to terminate gracefully
mac_scsi.c probably offers a reasonable example of a PDMA transfer
algorithm that is resiliant to timeouts.
See also the cmd->device->borken logic in the core driver. This way,
generic_NCR5380_pread() or generic_NCR5380_pwrite() can inhibit further
PDMA to that device if need be.
> - something like atari_scsi_dma_xfer_len to allow DMA only for block
> commands
>
Are you trying to figure out which commands are going to disconnect during
a transfer? This is really a function of the firmware in the target; there
are no good heuristics AFAICT, so the PDMA algorithm has to be robust.
mac_scsi has to cope with this too.
Does the problem go away when you assign no IRQ? When instance->irq ==
NO_IRQ, the core driver will inhibit disconnect privileges.
> @@ -588,22 +619,19 @@ static inline int generic_NCR5380_pwrite(struct NCR5380_hostdata *hostdata,
> static int generic_NCR5380_dma_xfer_len(struct NCR5380_hostdata *hostdata,
> struct scsi_cmnd *cmd)
> {
> - int transfersize = cmd->transfersize;
> + int transfersize = cmd->SCp.this_residual;
>
> if (hostdata->flags & FLAG_NO_PSEUDO_DMA)
> return 0;
>
> - /* Limit transfers to 32K, for xx400 & xx406
> - * pseudoDMA that transfers in 128 bytes blocks.
> - */
> - if (transfersize > 32 * 1024 && cmd->SCp.this_residual &&
> - !(cmd->SCp.this_residual % transfersize))
> - transfersize = 32 * 1024;
> -
> /* 53C400 datasheet: non-modulo-128-byte transfers should use PIO */
> if (transfersize % 128)
> transfersize = 0;
>
> + /* Limit transfers to 32K */
> + if (transfersize > 32 * 1024)
> + transfersize = 32 * 1024;
> +
> return transfersize;
I would prefer to see,
#define G_NCR5380_DMA_MAX_SIZE 32768
...
return min(transfersize, G_NCR5380_DMA_MAX_SIZE);
Thanks.
--
> }
>
>
>
>
>
next prev parent reply other threads:[~2017-01-31 1:30 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-15 23:50 Finn Thain
2017-01-15 23:50 ` [PATCH 6/6] atari_scsi: Reset DMA during bus reset only under ST-DMA lock Finn Thain
2017-01-15 23:50 ` [PATCH 3/6] ncr5380: Reduce #include files Finn Thain
2017-01-15 23:50 ` [PATCH 2/6] ncr5380: Clean up dead code and redundant macro usage Finn Thain
2017-01-15 23:50 ` [PATCH 4/6] ncr5380: Resolve various static checker warnings Finn Thain
2017-01-15 23:50 ` [PATCH 5/6] ncr5380: Improve target selection robustness Finn Thain
2017-01-15 23:50 ` [PATCH 1/6] ncr5380: Shorten host info string by removing unused option macros Finn Thain
2017-01-25 23:25 ` [PATCH 0/6] ncr5380: Miscellaneous minor patches Martin K. Petersen
2017-01-26 3:00 ` Michael Schmitz
2017-01-26 3:31 ` Martin K. Petersen
2017-01-28 21:44 ` Ondrej Zary
2017-01-29 1:05 ` Finn Thain
2017-01-30 21:52 ` Ondrej Zary
2017-01-31 1:31 ` Finn Thain [this message]
2017-02-16 22:18 ` g_NCR5380 PDMA, was " Ondrej Zary
2017-02-17 22:38 ` Finn Thain
2017-02-18 11:10 ` Ondrej Zary
2017-02-18 23:27 ` Finn Thain
2017-02-19 11:19 ` Ondrej Zary
2017-02-19 23:19 ` Finn Thain
2017-01-30 3:15 ` Michael Schmitz
2017-01-30 4:06 ` Finn Thain
2017-02-01 2:40 ` Martin K. Petersen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LNX.2.00.1701311203001.16154@nippy.intranet \
--to=fthain@telegraphics.com.au \
--cc=jejb@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=linux@rainbow-software.org \
--cc=martin.petersen@oracle.com \
--cc=schmitzmic@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®