NetBSD Problem Report #24883

Received: (qmail 2782 invoked by uid 605); 22 Mar 2004 20:21:49 -0000
Message-Id: <20040322202147.907C411159@narn.netbsd.org>
Date: Mon, 22 Mar 2004 20:21:47 +0000 (UTC)
From: mrz5149@acm.org
Sender: gnats-bugs-owner@NetBSD.org
Reply-To: mrz5149@acm.org
To: gnats-bugs@gnats.NetBSD.org
Subject: Patch for DMA SCSI on Quadra AV's
X-Send-Pr-Version: www-1.0

>Number:         24883
>Category:       port-mac68k
>Synopsis:       Patch for DMA SCSI on Quadra AV's
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    port-mac68k-maintainer
>State:          closed
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Mon Mar 22 20:22:00 +0000 2004
>Closed-Date:    Thu Aug 15 00:32:56 +0000 2019
>Last-Modified:  Thu Aug 15 00:32:56 +0000 2019
>Originator:     Michael Zucca
>Release:        -current
>Organization:
>Environment:
Not really important
>Description:

A while ago I posted a patch to the port-mac68k mailing list that
enables the use of the DMA engine on the Quadra AV machines to push
data to and from the SCSI chip.

The link to the email with the code attached is here:
http://mail-index.netbsd.org/port-mac68k/2003/06/08/0000.html

I'm submitting this PR in the hopes that the code gets added to the
source tree. It appears that little attention was paid to my initial
email.

This patch is merely preliminary and only gives minor performance
improvements. There is room for a lot of improvement. Namely, the SCSI
chip stays in asynchronous transfer mode because sync negotiation in
the generic NCR SCSI driver happens using unaligned and odd sized
buffers. In such cases the new DMA code falls back to using PIO. I
think the NCR doesn't like to do sync negotiation through PIO and
falls back to async mode. Thus, we're losing out on a lot of
performance. Another area of performance improvement is interrupt
handling. Right now, the code is simple and just pushes a single dma
map entry on the NCR chip's interrupt. It would be better to use the
SCSI DMA interrupt to DMA an entire dma map. It also appears that the
DMA engine is setup so that two transfers can be programmed in
initially, and then, at interrupt, one transfer can run in the
background while the just finished transfer can be updated with the
next transfer segment. I don't know how to do that yet, but it can't
be that difficult and would help tremendously with transfer speed
since we would be able to keep the NCR and DMA engine pushing or
pulling as much data to/from the disk as the system can.

Other things to contemplate:
* Separating out the PSC's DMA channels into a device.
   Sort of like the DMA engine on other m68k platforms.
* Using this code as the basis to DMA-ify the serial driver.

Anyway, the patch I submitted is a good start. If there are any
questions, feel free to email me.

>How-To-Repeat:
See above.
>Fix:
See above.
>Release-Note:
>Audit-Trail:
From: Rin Okuyama <rokuyama@rk.phys.keio.ac.jp>
To: "gnats-bugs@NetBSD.org" <gnats-bugs@NetBSD.org>, mrz5149@acm.org
Cc: 
Subject: Re: port-mac68k/24883 Patch for DMA SCSI on Quadra AV's
Date: Tue, 16 Oct 2018 20:36:54 +0900

 I updated the patch to catch up with -current as of today, which
 improves disk IO performance by nearly one order of magnitude for
 AV Mac (Quadra / Centris 660AV / 840AV).

 http://www.netbsd.org/~rin/avdma_20181002.patch

 Currently, DMA transfer for internal SCSI adapter of AV Mac is not
 supported. This results in not only miserable disk IO performance,
 loss of clock interrupts as well due to heavy SCSI PIO.

 Michael Zucca, the submitter of this PR, analyzed the DMA engine for
 AV Mac to implement DMA support for internal SCSI adapter. In the PR,
 IMO, he was too pessimistic to its performance. And he did not show
 any quantitative benchmarks. These may be why this PR has been left
 untouched unfortunately over 10 years.

 I found that his efforts succeeded more than he expected. Benchmarks
 attached below show that the disk performance improves nearly one
 order of magnitude. And clock interrupts are not lost anymore as far
 as I can see. It may be not perfect, as the original submitter
 pointed out, however the disk IO gets faster at least than NFS via
 mc(4) (for which DMA is already enabled).

 I made minimum changes to his patch to catch up with -current, as
 well as some KNF. Also, an off by one bug for PIO was fixed, and
 sc->sc_minsync was changed to zero. Both are necessary in order to
 attach one of my disks. Otherwise, I observed the following errors:

 sd0 at scsibus0 target 0 lun 0: <QUANTUM, ATLAS_V__9_WLS, 0230> disk fixed
 sd0: 8755 MB, 20907 cyl, 2 head, 428 sec, 512 bytes/sect x 17930694 sectors
 esp0: !TC on MSG OUT [intr 10, stat 83, step 1] prevphase 6, resid 4
 sd0(esp0:0:0:0):  Check Condition on CDB: 0x00 00 00 00 00 00
 SENSE KEY:  Aborted Command
 ASC/ASCQ:  Invalid Message Error

 Although I have not fully understood the patch and more works may be
 necessary before committing, the patch works fine without problem
 nearly two weeks on my 840AV. Any comments and suggestions are
 welcomed because I'm not familiar to SCSI, DMA, nor esp(4) driver,
 i.e., everything ;-). I hope someone still has AV Mac especially
 660AV in the working condition.

 BENCHMARKS
 ----------

 (1) 64KB block read/write (x 1024) to raw device
 (time dd if/of=/dev/rsd2b of/if=/dev/zero bs=64k count=1024)

 * before enabling DMA

 - RD 6:15 -> 175KB/s
 - WR 6:35 -> 166KB/s

 Here, time(1) reports wrong elapsed times (b/w 1:30 to 2:00) because
 significant parts of clock interrupts are lost due to heavy SCSI PIO.

 * after enabling DMA

 - RD 0:57 --> 1150KB/s
 - WR 0:53 --> 1240KB/s

 Now, time(1) reports sane elapsed times.

 (2) read/write to filesystem by using pkgsrc/benchmarks/bonnie

 * after enabling DMA

                -------Sequential Output-------- ---Sequential Input-- --Random--
                -Per Char- --Block--- -Rewrite-- -Per Char- --Block--- --Seeks---
 Machine    MB K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU  /sec %CPU
            100   822 93.8  1155 48.7   729 53.8   744 87.7  1374 49.0 148.8 84.9

 * c.f. tmpfs

                -------Sequential Output-------- ---Sequential Input-- --Random--
                -Per Char- --Block--- -Rewrite-- -Per Char- --Block--- --Seeks---
 Machine    MB K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU  /sec %CPU
             50   854 99.1  2726 99.2  2162 99.3   887 99.2  3793 99.3 212.7 98.9

 * c.f. NFS (UDPv4) via mc(4)

                -------Sequential Output-------- ---Sequential Input-- --Random--
                -Per Char- --Block--- -Rewrite-- -Per Char- --Block--- --Seeks---
 Machine    MB K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU  /sec %CPU
            100   438 55.5   558 21.7   288 24.3   435 50.5   661 26.6  62.0 64.5

From: "Rin Okuyama" <rin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/24883 CVS commit: src/sys/arch/mac68k
Date: Tue, 23 Jul 2019 07:52:53 +0000

 Module Name:	src
 Committed By:	rin
 Date:		Tue Jul 23 07:52:53 UTC 2019

 Modified Files:
 	src/sys/arch/mac68k/include: bus.h
 	src/sys/arch/mac68k/obio: esp.c espvar.h

 Log Message:
 PR port-mac68k/24883

 Style-only changes in preparation to import AV DMA code:

 - G/C unused from esp_softc
 - clean up headers:
     - prefer <sys/bus.h> over <machine/bus.h>
     - G/C unused
     - sort
 - staticify private functions and variables
 - stop using inline qualifier for functions called via function pointers
 - use C99 initializer
 - provide bus_space_vaddr(9) and use it, instead of using member of
   bus_handle_t directly
 - use uint*_t:
     - u_char --> uint8_t
     - u_int*_t --> uint*_t
 - use proper names from ncr53c9xreg.h instead of magic numbers
 - and some KNF, and etc.

 No functional changes intended.


 To generate a diff of this commit:
 cvs rdiff -u -r1.26 -r1.27 src/sys/arch/mac68k/include/bus.h
 cvs rdiff -u -r1.56 -r1.57 src/sys/arch/mac68k/obio/esp.c
 cvs rdiff -u -r1.7 -r1.8 src/sys/arch/mac68k/obio/espvar.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Rin Okuyama" <rin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/24883 CVS commit: src/sys/arch/mac68k
Date: Tue, 23 Jul 2019 15:19:07 +0000

 Module Name:	src
 Committed By:	rin
 Date:		Tue Jul 23 15:19:07 UTC 2019

 Modified Files:
 	src/sys/arch/mac68k/include: psc.h
 	src/sys/arch/mac68k/mac68k: psc.c
 	src/sys/arch/mac68k/obio: esp.c espvar.h

 Log Message:
 PR port-mac68k/24883

 Support DMA xfer for SCSI adapter of AV Mac (660/840AV), written by
 Michael Zucca.

 This improves disk I/O performance by nearly one order of magnitude.
 In addition, interrupt storm due to heavy disk PIO is resolved.

 I'm deeply grateful to Michael Zucca for his analysis of DMA engine
 and submission of PR. I also thank Izumi Tsutsui (useful comments on
 port-mac68k@) and Martin Husemann (test on 660AV).


 To generate a diff of this commit:
 cvs rdiff -u -r1.7 -r1.8 src/sys/arch/mac68k/include/psc.h
 cvs rdiff -u -r1.10 -r1.11 src/sys/arch/mac68k/mac68k/psc.c
 cvs rdiff -u -r1.57 -r1.58 src/sys/arch/mac68k/obio/esp.c
 cvs rdiff -u -r1.8 -r1.9 src/sys/arch/mac68k/obio/espvar.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: rin@NetBSD.org
State-Changed-When: Thu, 15 Aug 2019 00:32:56 +0000
State-Changed-Why:
Committed. Will be shipped with NetBSD 9.0. Thank you very much for
analysis of DMA engine and submitting the PR. And we are so sorry for
not being able to respond at that time.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.