Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Merge support for SATA NCQ (Native Command Queueing) fro...



details:   https://anonhg.NetBSD.org/src/rev/46f172e3907c
branches:  trunk
changeset: 826953:46f172e3907c
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Sat Oct 07 16:05:31 2017 +0000

description:
Merge support for SATA NCQ (Native Command Queueing) from jdolecek-ncq branch

ATA subsystem was changed to support several outstanding commands, and use
NCQ xfers if supported by both the controller and the disk, including NCQ
error recovery. Set NCQ high priority for BPRIO_TIMECRITICAL xfers
if supported. Added FUA support.

Done some work towards MP-safe, all ATA code tsleep()/wakeup() replaced
by condvars, and switched most code from spl* to mutexes (separate
wd(4) and ata channel lock).

Introduced new option WD_CHAOS_MONKEY to facilitate testing of error
handling, fixed several uncovered issues. Also fixed several problems
with kernel dump to wd(4) disk.

Tested with ahcisata(4), mvsata(4), siisata(4), piixide(4) on amd64,
with and without port multiplier, both disk and ATAPI devices; other
drivers and archs mechanically adjusted and compile-tested. NCQ is
supported for ahcisata(4) and siisata(4) for any controller, for
mvsata(4) only Gen IIe ones for now. Also enabled ATAPI support in
mvsata(4).

Thanks to Matt Thomas for initial ATA infrastructure patch, and
Jonathan A.Kollasch for siisata(4) NCQ changes and general testing.

Also fixes PR kern/43169 (wd(4)); and PR kern/11811, PR kern/47041,
PR kern/51979 (kernel dump)

diffstat:

 sys/arch/acorn32/eb7500atx/rside.c     |     9 +-
 sys/arch/acorn32/mainbus/wdc_pioc.c    |    20 +-
 sys/arch/acorn32/podulebus/icside.c    |     9 +-
 sys/arch/acorn32/podulebus/rapide.c    |     9 +-
 sys/arch/acorn32/podulebus/simide.c    |     9 +-
 sys/arch/amiga/dev/efa.c               |     8 +-
 sys/arch/amiga/dev/efavar.h            |     3 +-
 sys/arch/amiga/dev/wdc_acafh.c         |     9 +-
 sys/arch/amiga/dev/wdc_amiga.c         |     9 +-
 sys/arch/amiga/dev/wdc_buddha.c        |     7 +-
 sys/arch/amiga/dev/wdc_xsurf.c         |     7 +-
 sys/arch/arm/allwinner/awin_wdc.c      |     3 +-
 sys/arch/atari/dev/atari5380.c         |     8 +-
 sys/arch/atari/dev/dma.c               |     9 +-
 sys/arch/atari/dev/fd.c                |    15 +-
 sys/arch/atari/dev/wdc_mb.c            |    24 +-
 sys/arch/atari/include/dma.h           |     4 +-
 sys/arch/i386/pnpbios/pciide_pnpbios.c |     9 +-
 sys/arch/landisk/dev/wdc_obio.c        |    20 +-
 sys/arch/mac68k/obio/wdc_obio.c        |    20 +-
 sys/arch/macppc/dev/kauai.c            |     9 +-
 sys/arch/macppc/dev/wdc_obio.c         |     9 +-
 sys/arch/mips/adm5120/dev/wdc_extio.c  |     7 +-
 sys/arch/playstation2/dev/wdc_spd.c    |    29 +-
 sys/arch/prep/pnpbus/wdc_pnpbus.c      |     9 +-
 sys/dev/ata/TODO.ncq                   |    43 +
 sys/dev/ata/ata.c                      |  1287 ++++++++++++++++++++---
 sys/dev/ata/ata_wdc.c                  |   300 +++--
 sys/dev/ata/atareg.h                   |    24 +-
 sys/dev/ata/atavar.h                   |   451 +++++---
 sys/dev/ata/files.ata                  |     5 +-
 sys/dev/ata/sata_subr.c                |    22 +-
 sys/dev/ata/satafis_subr.c             |    30 +-
 sys/dev/ata/satafisvar.h               |     4 +-
 sys/dev/ata/satapmp_subr.c             |   178 ++-
 sys/dev/ata/satapmpvar.h               |     4 +-
 sys/dev/ata/wd.c                       |   830 ++++++++++-----
 sys/dev/ata/wdvar.h                    |    35 +-
 sys/dev/ic/ahcisata_core.c             |   963 +++++++++++------
 sys/dev/ic/ahcisatareg.h               |    21 +-
 sys/dev/ic/ahcisatavar.h               |     7 +-
 sys/dev/ic/mvsata.c                    |  1689 ++++++++++++++++++-------------
 sys/dev/ic/mvsatareg.h                 |     4 +-
 sys/dev/ic/mvsatavar.h                 |    29 +-
 sys/dev/ic/ninjaata32.c                |    10 +-
 sys/dev/ic/ninjaata32var.h             |     3 +-
 sys/dev/ic/siisata.c                   |   985 ++++++++++++------
 sys/dev/ic/siisatareg.h                |    10 +-
 sys/dev/ic/siisatavar.h                |     8 +-
 sys/dev/ic/wdc.c                       |   479 ++++----
 sys/dev/ic/wdcvar.h                    |    22 +-
 sys/dev/isa/wdc_isa.c                  |    20 +-
 sys/dev/pci/acardide.c                 |    42 +-
 sys/dev/pci/artsata.c                  |     8 +-
 sys/dev/pci/cmdide.c                   |    11 +-
 sys/dev/pci/cypide.c                   |     8 +-
 sys/dev/pci/pciide_common.c            |    21 +-
 sys/dev/pci/pdcsata.c                  |    10 +-
 sys/dev/pci/satalink.c                 |     9 +-
 sys/dev/pci/svwsata.c                  |     6 +-
 sys/dev/pci/viaide.c                   |    10 +-
 sys/dev/pcmcia/wdc_pcmcia.c            |     9 +-
 sys/dev/scsipi/atapi_wdc.c             |   296 +++--
 sys/dev/usb/umass.c                    |    19 +-
 sys/dev/usb/umass_isdata.c             |   187 ++-
 sys/dev/usb/umass_isdata.h             |     3 +-
 66 files changed, 5345 insertions(+), 3031 deletions(-)

diffs (truncated from 15839 to 300 lines):

diff -r 4855117bee04 -r 46f172e3907c sys/arch/acorn32/eb7500atx/rside.c
--- a/sys/arch/acorn32/eb7500atx/rside.c        Sat Oct 07 15:13:00 2017 +0000
+++ b/sys/arch/acorn32/eb7500atx/rside.c        Sat Oct 07 16:05:31 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rside.c,v 1.14 2012/07/31 15:50:31 bouyer Exp $        */
+/*     $NetBSD: rside.c,v 1.15 2017/10/07 16:05:31 jdolecek Exp $      */
 
 /*
  * Copyright (c) 2004 Christopher Gilbert
@@ -56,7 +56,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rside.c,v 1.14 2012/07/31 15:50:31 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rside.c,v 1.15 2017/10/07 16:05:31 jdolecek Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -115,7 +115,6 @@
        struct bus_space        sc_tag;                 /* custom tag */
        struct rside_channel {
                struct ata_channel rc_channel;          /* generic part */
-               struct ata_queue rc_chqueue;            /* channel queue */
                irqhandler_t *rc_ih;                    /* irq handler */
        } rside_channels[2];
        struct wdc_regs sc_wdc_regs[2];
@@ -199,7 +198,7 @@
 
                cp->ch_channel = channel;
                cp->ch_atac = &sc->sc_wdcdev.sc_atac;
-               cp->ch_queue = &scp->rc_chqueue;
+               cp->ch_queue = ata_queue_alloc(1);
                wdr->cmd_iot = wdr->ctl_iot = &sc->sc_tag;
                if (bus_space_map(wdr->cmd_iot,
                    rside_info[channel].drive_registers,
@@ -218,7 +217,7 @@
                                continue;
                        }
                }
-               wdc_init_shadow_regs(cp);
+               wdc_init_shadow_regs(wdr);
 
                if (bus_space_map(wdr->ctl_iot,
                    rside_info[channel].aux_register, 0x4, 0, &wdr->ctl_ioh))
diff -r 4855117bee04 -r 46f172e3907c sys/arch/acorn32/mainbus/wdc_pioc.c
--- a/sys/arch/acorn32/mainbus/wdc_pioc.c       Sat Oct 07 15:13:00 2017 +0000
+++ b/sys/arch/acorn32/mainbus/wdc_pioc.c       Sat Oct 07 16:05:31 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wdc_pioc.c,v 1.28 2012/07/31 15:50:31 bouyer Exp $     */
+/*     $NetBSD: wdc_pioc.c,v 1.29 2017/10/07 16:05:31 jdolecek Exp $   */
 
 /*
  * Copyright (c) 1997-1998 Mark Brinicombe.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wdc_pioc.c,v 1.28 2012/07/31 15:50:31 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wdc_pioc.c,v 1.29 2017/10/07 16:05:31 jdolecek Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -60,7 +60,6 @@
        struct  wdc_softc sc_wdcdev;
        struct  ata_channel *sc_chanlist[1];
        struct  ata_channel sc_channel;
-       struct  ata_queue sc_chqueue;
        struct  wdc_regs sc_wdc_regs;
        void    *sc_ih;
 };
@@ -84,8 +83,6 @@
 wdc_pioc_probe(device_t parent, cfdata_t cf, void *aux)
 {
        struct pioc_attach_args *pa = aux;
-       struct ata_channel ch;
-       struct wdc_softc wdc;
        struct wdc_regs wdr;
        int res, i;
        u_int iobase;
@@ -97,11 +94,6 @@
        if (pa->pa_offset == PIOCCF_OFFSET_DEFAULT)
                return(0);
 
-       memset(&wdc, 0, sizeof(wdc));
-       memset(&ch, 0, sizeof(ch));
-       ch.ch_atac = &wdc.sc_atac;
-       wdc.regs = &wdr;
-
        iobase = pa->pa_iobase + pa->pa_offset;
        wdr.cmd_iot = pa->pa_iot;
        wdr.ctl_iot = pa->pa_iot;
@@ -117,7 +109,7 @@
                        return 0;
                }
        }
-       wdc_init_shadow_regs(&ch);
+       wdc_init_shadow_regs(&wdr);
 
        if (bus_space_map(wdr.ctl_iot, iobase + WDC_PIOC_AUXREG_OFFSET,
            WDC_PIOC_AUXREG_NPORTS, 0, &wdr.ctl_ioh)) {
@@ -126,7 +118,7 @@
                return(0);
        }
 
-       res = wdcprobe(&ch);
+       res = wdcprobe(&wdr);
 
        bus_space_unmap(wdr.ctl_iot, wdr.ctl_ioh, WDC_PIOC_AUXREG_NPORTS);
        bus_space_unmap(wdr.cmd_iot, wdr.cmd_baseioh, WDC_PIOC_REG_NPORTS);
@@ -187,9 +179,9 @@
        sc->sc_wdcdev.sc_atac.atac_nchannels = 1;
        sc->sc_wdcdev.wdc_maxdrives = 2;
        sc->sc_channel.ch_channel = 0;
-       sc->sc_channel.ch_queue = &sc->sc_chqueue;
+       sc->sc_channel.ch_queue = ata_queue_alloc(1);
 
-       wdc_init_shadow_regs(&sc->sc_channel);
+       wdc_init_shadow_regs(wdr);
 
        wdcattach(&sc->sc_channel);
 }
diff -r 4855117bee04 -r 46f172e3907c sys/arch/acorn32/podulebus/icside.c
--- a/sys/arch/acorn32/podulebus/icside.c       Sat Oct 07 15:13:00 2017 +0000
+++ b/sys/arch/acorn32/podulebus/icside.c       Sat Oct 07 16:05:31 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: icside.c,v 1.32 2012/07/31 15:50:31 bouyer Exp $       */
+/*     $NetBSD: icside.c,v 1.33 2017/10/07 16:05:31 jdolecek Exp $     */
 
 /*
  * Copyright (c) 1997-1998 Mark Brinicombe
@@ -42,7 +42,7 @@
 
 #include <sys/param.h>
 
-__KERNEL_RCSID(0, "$NetBSD: icside.c,v 1.32 2012/07/31 15:50:31 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: icside.c,v 1.33 2017/10/07 16:05:31 jdolecek Exp $");
 
 #include <sys/systm.h>
 #include <sys/conf.h>
@@ -86,7 +86,6 @@
        struct ata_channel *sc_chp[ICSIDE_MAX_CHANNELS];
        struct icside_channel {
                struct ata_channel      ic_channel;     /* generic part */
-               struct ata_queue        ic_chqueue;     /* channel queue */
                void                    *ic_ih;         /* interrupt handler */
                struct evcnt            ic_intrcnt;     /* interrupt count */
                u_int                   ic_irqaddr;     /* interrupt flag */
@@ -270,7 +269,7 @@
 
                cp->ch_channel = channel;
                cp->ch_atac = &sc->sc_wdcdev.sc_atac;
-               cp->ch_queue = &icp->ic_chqueue;
+               cp->ch_queue = ata_queue_alloc(1);
                wdr->cmd_iot = &sc->sc_tag;
                wdr->ctl_iot = &sc->sc_tag;
                if (ide->modspace)
@@ -286,7 +285,7 @@
                                i, i == 0 ? 4 : 1, &wdr->cmd_iohs[i]) != 0)
                                return;
                }
-               wdc_init_shadow_regs(cp);
+               wdc_init_shadow_regs(wdr);
                if (bus_space_map(iot, iobase + ide->auxregs[channel],
                    AUX_REGISTER_SPACE, 0, &wdr->ctl_ioh))
                        return;
diff -r 4855117bee04 -r 46f172e3907c sys/arch/acorn32/podulebus/rapide.c
--- a/sys/arch/acorn32/podulebus/rapide.c       Sat Oct 07 15:13:00 2017 +0000
+++ b/sys/arch/acorn32/podulebus/rapide.c       Sat Oct 07 16:05:31 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rapide.c,v 1.30 2012/07/31 15:50:31 bouyer Exp $       */
+/*     $NetBSD: rapide.c,v 1.31 2017/10/07 16:05:31 jdolecek Exp $     */
 
 /*
  * Copyright (c) 1997-1998 Mark Brinicombe
@@ -68,7 +68,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rapide.c,v 1.30 2012/07/31 15:50:31 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rapide.c,v 1.31 2017/10/07 16:05:31 jdolecek Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -119,7 +119,6 @@
        bus_space_handle_t      sc_ctlioh;              /* control handler */
        struct rapide_channel {
                struct ata_channel rc_channel;  /* generic part */
-               struct ata_queue rc_chqueue;            /* channel queue */
                irqhandler_t    rc_ih;                  /* interrupt handler */
                int             rc_irqmask;     /* IRQ mask for this channel */
        } rapide_channels[2];
@@ -259,7 +258,7 @@
 
                cp->ch_channel = channel;
                cp->ch_atac = &sc->sc_wdcdev.sc_atac;
-               cp->ch_queue = &rcp->rc_chqueue;
+               cp->ch_queue = ata_queue_alloc(1);
                wdr->cmd_iot = iot;
                wdr->ctl_iot = iot;
                wdr->data32iot = iot;
@@ -275,7 +274,7 @@
                                continue;
                        }
                }
-               wdc_init_shadow_regs(cp);
+               wdc_init_shadow_regs(wdr);
                if (bus_space_map(iot, iobase +
                    rapide_info[channel].aux_register, 4, 0, &wdr->ctl_ioh)) {
                        bus_space_unmap(iot, wdr->cmd_baseioh,
diff -r 4855117bee04 -r 46f172e3907c sys/arch/acorn32/podulebus/simide.c
--- a/sys/arch/acorn32/podulebus/simide.c       Sat Oct 07 15:13:00 2017 +0000
+++ b/sys/arch/acorn32/podulebus/simide.c       Sat Oct 07 16:05:31 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: simide.c,v 1.29 2012/07/31 15:50:31 bouyer Exp $       */
+/*     $NetBSD: simide.c,v 1.30 2017/10/07 16:05:31 jdolecek Exp $     */
 
 /*
  * Copyright (c) 1997-1998 Mark Brinicombe
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: simide.c,v 1.29 2012/07/31 15:50:31 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: simide.c,v 1.30 2017/10/07 16:05:31 jdolecek Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -89,7 +89,6 @@
        struct bus_space        sc_tag;                 /* custom tag */
        struct simide_channel {
                struct ata_channel sc_channel;  /* generic part */
-               struct ata_queue sc_chqueue;            /* channel queue */
                irqhandler_t    sc_ih;                  /* interrupt handler */
                int             sc_irqmask;     /* IRQ mask for this channel */
        } simide_channels[2];
@@ -258,7 +257,7 @@
 
                cp->ch_channel = channel;
                cp->ch_atac = &sc->sc_wdcdev.sc_atac;
-               cp->ch_queue = &scp->sc_chqueue;
+               cp->ch_queue = ata_queue_alloc(1);
                wdr->cmd_iot = wdr->ctl_iot = &sc->sc_tag;
                iobase = pa->pa_podule->mod_base;
                if (bus_space_map(wdr->cmd_iot, iobase +
@@ -273,7 +272,7 @@
                                continue;
                        }
                }
-               wdc_init_shadow_regs(cp);
+               wdc_init_shadow_regs(wdr);
                if (bus_space_map(wdr->ctl_iot, iobase +
                    simide_info[channel].aux_register, 4, 0, &wdr->ctl_ioh)) {
                        bus_space_unmap(wdr->cmd_iot, wdr->cmd_baseioh,
diff -r 4855117bee04 -r 46f172e3907c sys/arch/amiga/dev/efa.c
--- a/sys/arch/amiga/dev/efa.c  Sat Oct 07 15:13:00 2017 +0000
+++ b/sys/arch/amiga/dev/efa.c  Sat Oct 07 16:05:31 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: efa.c,v 1.13 2017/09/04 17:26:06 phx Exp $ */
+/*     $NetBSD: efa.c,v 1.14 2017/10/07 16:05:31 jdolecek Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -208,14 +208,14 @@
 
        sc->sc_ports[chnum].chan.ch_channel = chnum;
        sc->sc_ports[chnum].chan.ch_atac = &sc->sc_wdcdev.sc_atac;
-       sc->sc_ports[chnum].chan.ch_queue = &sc->sc_ports[chnum].queue;
+       sc->sc_ports[chnum].chan.ch_queue = ata_queue_alloc(1);
 
        if (!sc->sc_32bit_io)
                efa_select_regset(sc, chnum, 0); /* Start in PIO0. */
        else
                efa_select_regset(sc, chnum, 3); 
 
-       wdc_init_shadow_regs(&sc->sc_ports[chnum].chan);
+       wdc_init_shadow_regs(CHAN_TO_WDC_REGS(&sc->sc_ports[chnum].chan));
 
        wdcattach(&sc->sc_ports[chnum].chan);   
 
@@ -525,7 +525,7 @@
        /* Change FastATA register set. */
        efa_select_regset(sc, chnum, mode);
        /* re-init shadow regs */
-       wdc_init_shadow_regs(&sc->sc_ports[chnum].chan);
+       wdc_init_shadow_regs(CHAN_TO_WDC_REGS(&sc->sc_ports[chnum].chan));
 
        splx(ipl);
 }
diff -r 4855117bee04 -r 46f172e3907c sys/arch/amiga/dev/efavar.h
--- a/sys/arch/amiga/dev/efavar.h       Sat Oct 07 15:13:00 2017 +0000
+++ b/sys/arch/amiga/dev/efavar.h       Sat Oct 07 16:05:31 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: efavar.h,v 1.2 2017/09/04 17:26:06 phx Exp $ */
+/*     $NetBSD: efavar.h,v 1.3 2017/10/07 16:05:31 jdolecek Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -37,7 +37,6 @@
 
 struct efa_port {



Home | Main Index | Thread Index | Old Index