CVS commit: [netbsd-9] src/sys/dev/ic
Module Name:src Committed By: martin Date: Sat Jul 3 10:18:16 UTC 2021 Modified Files: src/sys/dev/ic [netbsd-9]: ax88190.c dl10019.c dp8390.c Log Message: Pull up following revision(s) (requested by thorpej in ticket #1311): sys/dev/ic/dp8390.c: revision 1.99 sys/dev/ic/dl10019.c: revision 1.17 sys/dev/ic/ax88190.c: revision 1.18 Make sure the media / mii members in struct ethercom are initialized so that the media-related ioctls work. Problem reported by Bj�rn Johannesson on current-users@. XXX pullup-9 To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.15.2.1 src/sys/dev/ic/ax88190.c cvs rdiff -u -r1.14 -r1.14.2.1 src/sys/dev/ic/dl10019.c cvs rdiff -u -r1.95 -r1.95.2.1 src/sys/dev/ic/dp8390.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/ic/ax88190.c diff -u src/sys/dev/ic/ax88190.c:1.15 src/sys/dev/ic/ax88190.c:1.15.2.1 --- src/sys/dev/ic/ax88190.c:1.15 Wed May 29 06:17:28 2019 +++ src/sys/dev/ic/ax88190.c Sat Jul 3 10:18:16 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ax88190.c,v 1.15 2019/05/29 06:17:28 msaitoh Exp $ */ +/* $NetBSD: ax88190.c,v 1.15.2.1 2021/07/03 10:18:16 martin Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ax88190.c,v 1.15 2019/05/29 06:17:28 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ax88190.c,v 1.15.2.1 2021/07/03 10:18:16 martin Exp $"); #include #include @@ -86,6 +86,8 @@ ax88190_media_init(struct dp8390_softc * struct ifnet *ifp = >sc_ec.ec_if; struct mii_data *mii = >sc_mii; + sc->sc_ec.ec_mii = mii; + mii->mii_ifp = ifp; mii->mii_readreg = ax88190_mii_readreg; mii->mii_writereg = ax88190_mii_writereg; Index: src/sys/dev/ic/dl10019.c diff -u src/sys/dev/ic/dl10019.c:1.14 src/sys/dev/ic/dl10019.c:1.14.2.1 --- src/sys/dev/ic/dl10019.c:1.14 Wed May 29 06:17:28 2019 +++ src/sys/dev/ic/dl10019.c Sat Jul 3 10:18:16 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: dl10019.c,v 1.14 2019/05/29 06:17:28 msaitoh Exp $ */ +/* $NetBSD: dl10019.c,v 1.14.2.1 2021/07/03 10:18:16 martin Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: dl10019.c,v 1.14 2019/05/29 06:17:28 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dl10019.c,v 1.14.2.1 2021/07/03 10:18:16 martin Exp $"); #include #include @@ -119,6 +119,8 @@ dl10019_media_init(struct dp8390_softc * struct ifnet *ifp = >sc_ec.ec_if; struct mii_data *mii = >sc_mii; + sc->sc_ec.ec_mii = mii; + mii->mii_ifp = ifp; mii->mii_readreg = dl10019_mii_readreg; mii->mii_writereg = dl10019_mii_writereg; Index: src/sys/dev/ic/dp8390.c diff -u src/sys/dev/ic/dp8390.c:1.95 src/sys/dev/ic/dp8390.c:1.95.2.1 --- src/sys/dev/ic/dp8390.c:1.95 Wed May 29 10:07:29 2019 +++ src/sys/dev/ic/dp8390.c Sat Jul 3 10:18:16 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: dp8390.c,v 1.95 2019/05/29 10:07:29 msaitoh Exp $ */ +/* $NetBSD: dp8390.c,v 1.95.2.1 2021/07/03 10:18:16 martin Exp $ */ /* * Device driver for National Semiconductor DS8390/WD83C690 based ethernet @@ -14,7 +14,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: dp8390.c,v 1.95 2019/05/29 10:07:29 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dp8390.c,v 1.95.2.1 2021/07/03 10:18:16 martin Exp $"); #include "opt_inet.h" @@ -66,7 +66,6 @@ void dp8390_media_init(struct dp8390_softc *sc) { - sc->sc_ec.ec_ifmedia = >sc_media; ifmedia_init(>sc_media, 0, dp8390_mediachange, dp8390_mediastatus); ifmedia_add(>sc_media, IFM_ETHER | IFM_MANUAL, 0, NULL); ifmedia_set(>sc_media, IFM_ETHER | IFM_MANUAL); @@ -131,7 +130,13 @@ dp8390_config(struct dp8390_softc *sc) aprint_normal_dev(sc->sc_dev, "Ethernet address %s\n", ether_sprintf(sc->sc_enaddr)); - /* Initialize media goo. */ + /* + * Initialize media structures. We'll default to pointing ec_ifmedia + * at our embedded media structure. A card front-end can initialize + * ec_mii if it has an MII interface. (Note that sc_media is an + * alias of sc_mii.mii_media in dp8390_softc.) + */ + sc->sc_ec.ec_ifmedia = >sc_media; (*sc->sc_media_init)(sc); /* We can support 802.1Q VLAN-sized frames. */
CVS commit: [netbsd-9] src/sys/dev/ic
Module Name:src Committed By: martin Date: Tue Mar 9 15:47:07 UTC 2021 Modified Files: src/sys/dev/ic [netbsd-9]: mb89352.c Log Message: Pull up following revision(s) (requested by tsutsui in ticket #1228): sys/dev/ic/mb89352.c: revision 1.58 Fix a possible race condition in spc_msgin() in NO_MANUAL_XFER case. To avoid the race, check SSTS and INTS after XFR command as spc_pio_datain() does. Reported from isaki@, observed on nono emulator. To generate a diff of this commit: cvs rdiff -u -r1.57 -r1.57.4.1 src/sys/dev/ic/mb89352.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/ic/mb89352.c diff -u src/sys/dev/ic/mb89352.c:1.57 src/sys/dev/ic/mb89352.c:1.57.4.1 --- src/sys/dev/ic/mb89352.c:1.57 Mon Sep 3 16:29:31 2018 +++ src/sys/dev/ic/mb89352.c Tue Mar 9 15:47:07 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: mb89352.c,v 1.57 2018/09/03 16:29:31 riastradh Exp $ */ +/* $NetBSD: mb89352.c,v 1.57.4.1 2021/03/09 15:47:07 martin Exp $ */ /* NecBSD: mb89352.c,v 1.4 1998/03/14 07:31:20 kmatsuda Exp */ /*- @@ -77,7 +77,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mb89352.c,v 1.57 2018/09/03 16:29:31 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mb89352.c,v 1.57.4.1 2021/03/09 15:47:07 martin Exp $"); #ifdef DDB #define integrate @@ -932,6 +932,7 @@ nextbyte: */ for (;;) { #ifdef NO_MANUAL_XFER /* XXX */ + uint8_t intstat; if (bus_space_read_1(iot, ioh, INTS) != 0) { /* * Target left MESSAGE IN, probably because it @@ -960,12 +961,18 @@ nextbyte: #else bus_space_write_1(iot, ioh, SCMD, SCMD_XFR | SCMD_PROG_XFR); #endif + intstat = 0; for (;;) { if ((bus_space_read_1(iot, ioh, SSTS) & SSTS_DREG_EMPTY) == 0) break; - if (bus_space_read_1(iot, ioh, INTS) != 0) + /* + * We have to read INTS before checking SSTS to avoid + * race between SSTS_DREG_EMPTY and INTS_CMD_DONE. + */ + if (intstat != 0) goto out; + intstat = bus_space_read_1(iot, ioh, INTS); } msg = bus_space_read_1(iot, ioh, DREG); #else
CVS commit: [netbsd-9] src/sys/dev/ic
Module Name:src Committed By: martin Date: Mon Dec 7 20:04:07 UTC 2020 Modified Files: src/sys/dev/ic [netbsd-9]: nvme.c Log Message: Pull up following revision(s) (requested by kardel in ticket #1144): sys/dev/ic/nvme.c: revision 1.53 PR kern/55839: handle multiple nvme_rescan()s correctly by doing the name-space identify only once per nsid. fixes issue where modloading triggers multiple rescans. To generate a diff of this commit: cvs rdiff -u -r1.44.2.4 -r1.44.2.5 src/sys/dev/ic/nvme.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/ic/nvme.c diff -u src/sys/dev/ic/nvme.c:1.44.2.4 src/sys/dev/ic/nvme.c:1.44.2.5 --- src/sys/dev/ic/nvme.c:1.44.2.4 Sun Sep 27 10:30:16 2020 +++ src/sys/dev/ic/nvme.c Mon Dec 7 20:04:07 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: nvme.c,v 1.44.2.4 2020/09/27 10:30:16 martin Exp $ */ +/* $NetBSD: nvme.c,v 1.44.2.5 2020/12/07 20:04:07 martin Exp $ */ /* $OpenBSD: nvme.c,v 1.49 2016/04/18 05:59:50 dlg Exp $ */ /* @@ -18,7 +18,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.44.2.4 2020/09/27 10:30:16 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.44.2.5 2020/12/07 20:04:07 martin Exp $"); #include #include @@ -628,6 +628,12 @@ nvme_ns_identify(struct nvme_softc *sc, KASSERT(nsid > 0); + ns = nvme_ns_get(sc, nsid); + KASSERT(ns); + + if (ns->ident != NULL) + return 0; + ccb = nvme_ccb_get(sc->sc_admin_q, false); KASSERT(ccb != NULL); /* it's a bug if we don't have spare ccb here */ @@ -665,9 +671,6 @@ nvme_ns_identify(struct nvme_softc *sc, /* Convert data to host endian */ nvme_identify_namespace_swapbytes(identify); - ns = nvme_ns_get(sc, nsid); - KASSERT(ns); - KASSERT(ns->ident == NULL); ns->ident = identify; done:
CVS commit: [netbsd-9] src/sys/dev/ic
Module Name:src Committed By: martin Date: Sun Sep 27 10:30:16 UTC 2020 Modified Files: src/sys/dev/ic [netbsd-9]: ld_nvme.c nvme.c Log Message: Pull up following revision(s) (requested by kardel in ticket #1094): sys/dev/ic/ld_nvme.c: revision 1.24 sys/dev/ic/nvme.c: revision 1.50 PR kern/55674: move name space availability check from ld_nvme.c:ld_nvme_attach() to nvme.c:nvme_rescan(). this avoids allocation of ld(4) instances for every possible name space, even if it is not usable. it also reduces the device node flood generated from that strategy. To generate a diff of this commit: cvs rdiff -u -r1.22.2.1 -r1.22.2.2 src/sys/dev/ic/ld_nvme.c cvs rdiff -u -r1.44.2.3 -r1.44.2.4 src/sys/dev/ic/nvme.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/ic/ld_nvme.c diff -u src/sys/dev/ic/ld_nvme.c:1.22.2.1 src/sys/dev/ic/ld_nvme.c:1.22.2.2 --- src/sys/dev/ic/ld_nvme.c:1.22.2.1 Mon Oct 28 18:30:43 2019 +++ src/sys/dev/ic/ld_nvme.c Sun Sep 27 10:30:16 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ld_nvme.c,v 1.22.2.1 2019/10/28 18:30:43 martin Exp $ */ +/* $NetBSD: ld_nvme.c,v 1.22.2.2 2020/09/27 10:30:16 martin Exp $ */ /*- * Copyright (C) 2016 NONAKA Kimihiro @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ld_nvme.c,v 1.22.2.1 2019/10/28 18:30:43 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ld_nvme.c,v 1.22.2.2 2020/09/27 10:30:16 martin Exp $"); #include #include @@ -86,7 +86,6 @@ ld_nvme_attach(device_t parent, device_t struct nvme_attach_args *naa = aux; struct nvme_namespace *ns; struct nvm_namespace_format *f; - int error; ld->sc_dv = self; sc->sc_nvme = nsc; @@ -95,28 +94,11 @@ ld_nvme_attach(device_t parent, device_t aprint_naive("\n"); aprint_normal("\n"); - error = nvme_ns_identify(sc->sc_nvme, sc->sc_nsid); - if (error) { - aprint_error_dev(self, "couldn't identify namespace\n"); - return; - } - ns = nvme_ns_get(sc->sc_nvme, sc->sc_nsid); KASSERT(ns); - f = >ident->lbaf[NVME_ID_NS_FLBAS(ns->ident->flbas)]; - /* - * NVME1.0e 6.11 Identify command - * - * LBADS values smaller than 9 are not supported, a value - * of zero means that the format is not used. - */ - if (f->lbads < 9) { - if (f->lbads > 0) - aprint_error_dev(self, - "unsupported logical data size %u\n", f->lbads); - return; - } + f = >ident->lbaf[NVME_ID_NS_FLBAS(ns->ident->flbas)]; + KASSERT(f->lbads >= 9); /* only valid LBS data sizes allowed here */ ld->sc_secsize = 1 << f->lbads; ld->sc_secperunit = ns->ident->nsze; Index: src/sys/dev/ic/nvme.c diff -u src/sys/dev/ic/nvme.c:1.44.2.3 src/sys/dev/ic/nvme.c:1.44.2.4 --- src/sys/dev/ic/nvme.c:1.44.2.3 Mon Nov 11 17:15:42 2019 +++ src/sys/dev/ic/nvme.c Sun Sep 27 10:30:16 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: nvme.c,v 1.44.2.3 2019/11/11 17:15:42 martin Exp $ */ +/* $NetBSD: nvme.c,v 1.44.2.4 2020/09/27 10:30:16 martin Exp $ */ /* $OpenBSD: nvme.c,v 1.49 2016/04/18 05:59:50 dlg Exp $ */ /* @@ -18,7 +18,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.44.2.3 2019/11/11 17:15:42 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.44.2.4 2020/09/27 10:30:16 martin Exp $"); #include #include @@ -471,23 +471,52 @@ nvme_rescan(device_t self, const char *a { struct nvme_softc *sc = device_private(self); struct nvme_attach_args naa; + struct nvm_namespace_format *f; + struct nvme_namespace *ns; uint64_t cap; int ioq_entries = nvme_ioq_size; int i; + int error; cap = nvme_read8(sc, NVME_CAP); if (ioq_entries > NVME_CAP_MQES(cap)) ioq_entries = NVME_CAP_MQES(cap); - for (i = 0; i < sc->sc_nn; i++) { - if (sc->sc_namespaces[i].dev) + for (i = 1; i <= sc->sc_nn; i++) { + if (sc->sc_namespaces[i - 1].dev) + continue; + + /* identify to check for availability */ + error = nvme_ns_identify(sc, i); + if (error) { + aprint_error_dev(self, "couldn't identify namespace #%d\n", i); + continue; + } + + ns = nvme_ns_get(sc, i); + KASSERT(ns); + + f = >ident->lbaf[NVME_ID_NS_FLBAS(ns->ident->flbas)]; + + /* + * NVME1.0e 6.11 Identify command + * + * LBADS values smaller than 9 are not supported, a value + * of zero means that the format is not used. + */ + if (f->lbads < 9) { + if (f->lbads > 0) +aprint_error_dev(self, + "unsupported logical data size %u\n", f->lbads); continue; + } + memset(, 0, sizeof(naa)); - naa.naa_nsid = i + 1; + naa.naa_nsid = i; naa.naa_qentries = (ioq_entries - 1) * sc->sc_nq; naa.naa_maxphys = sc->sc_mdts; naa.naa_typename = sc->sc_modelname; - sc->sc_namespaces[i].dev = config_found(sc->sc_dev, , + sc->sc_namespaces[i - 1].dev = config_found(sc->sc_dev, , nvme_print); } return 0;
CVS commit: [netbsd-9] src/sys/dev/ic
Module Name:src Committed By: martin Date: Wed Sep 16 13:29:53 UTC 2020 Modified Files: src/sys/dev/ic [netbsd-9]: mpt_netbsd.c Log Message: Pull up following revision(s) (requested by mlelstv in ticket #1085): sys/dev/ic/mpt_netbsd.c: revision 1.37 max_devices is a 8bit value and zero is interpreted as 256. This value can be reported by an mpt device emulated by VMware ESXi. To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.36.2.1 src/sys/dev/ic/mpt_netbsd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/ic/mpt_netbsd.c diff -u src/sys/dev/ic/mpt_netbsd.c:1.36 src/sys/dev/ic/mpt_netbsd.c:1.36.2.1 --- src/sys/dev/ic/mpt_netbsd.c:1.36 Wed May 8 06:32:01 2019 +++ src/sys/dev/ic/mpt_netbsd.c Wed Sep 16 13:29:53 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: mpt_netbsd.c,v 1.36 2019/05/08 06:32:01 cnst Exp $ */ +/* $NetBSD: mpt_netbsd.c,v 1.36.2.1 2020/09/16 13:29:53 martin Exp $ */ /* * Copyright (c) 2003 Wasabi Systems, Inc. @@ -77,7 +77,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mpt_netbsd.c,v 1.36 2019/05/08 06:32:01 cnst Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mpt_netbsd.c,v 1.36.2.1 2020/09/16 13:29:53 martin Exp $"); #include "bio.h" @@ -150,7 +150,7 @@ mpt_scsipi_attach(mpt_softc_t *mpt) chan->chan_channel = 0; chan->chan_flags = 0; chan->chan_nluns = 8; - chan->chan_ntargets = mpt->mpt_max_devices; + chan->chan_ntargets = mpt->mpt_max_devices ? mpt->mpt_max_devices : 256; chan->chan_id = mpt->mpt_ini_id; /*
CVS commit: [netbsd-9] src/sys/dev/ic
Module Name:src Committed By: martin Date: Tue Apr 14 17:02:28 UTC 2020 Modified Files: src/sys/dev/ic [netbsd-9]: spdmem.c spdmemvar.h Log Message: Pull up following revision(s) (requested by msaitoh in ticket #832): sys/dev/ic/spdmemvar.h: revision 1.15 sys/dev/ic/spdmemvar.h: revision 1.16 sys/dev/ic/spdmem.c: revision 1.32 sys/dev/ic/spdmem.c: revision 1.33 sys/dev/ic/spdmem.c: revision 1.34 sys/dev/ic/spdmem.c: revision 1.35 Print DDR3's row and column correctly. KNF. No functional change. - Define some new parameters of DDR3 SPD ROM. - Use fine timebase parameters for time calculation on DDR3. This change makes PC3- value more correctly on newer DDR3. Calculate DDR3's tRAS correctly. Fix unused area size found by pgoyette@. To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.31.4.1 src/sys/dev/ic/spdmem.c cvs rdiff -u -r1.14 -r1.14.4.1 src/sys/dev/ic/spdmemvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/ic/spdmem.c diff -u src/sys/dev/ic/spdmem.c:1.31 src/sys/dev/ic/spdmem.c:1.31.4.1 --- src/sys/dev/ic/spdmem.c:1.31 Sun Apr 7 01:39:12 2019 +++ src/sys/dev/ic/spdmem.c Tue Apr 14 17:02:28 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: spdmem.c,v 1.31 2019/04/07 01:39:12 pgoyette Exp $ */ +/* $NetBSD: spdmem.c,v 1.31.4.1 2020/04/14 17:02:28 martin Exp $ */ /* * Copyright (c) 2007 Nicolas Joly @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: spdmem.c,v 1.31 2019/04/07 01:39:12 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: spdmem.c,v 1.31.4.1 2020/04/14 17:02:28 martin Exp $"); #include #include @@ -340,12 +340,12 @@ spdmem_common_attach(struct spdmem_softc device_xname(self), NULL, NULL, 0, NULL, 0, CTL_HW, CTL_CREATE, CTL_EOL); if (node != NULL && spd_len != 0) -sysctl_createv(>sc_sysctl_log, 0, NULL, NULL, -0, -CTLTYPE_STRUCT, "spd_data", + sysctl_createv(>sc_sysctl_log, 0, NULL, NULL, + 0, + CTLTYPE_STRUCT, "spd_data", SYSCTL_DESCR("raw spd data"), NULL, -0, s, spd_len, -CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL); + 0, s, spd_len, + CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL); /* * Decode and print key SPD contents @@ -411,7 +411,7 @@ spdmem_common_attach(struct spdmem_softc strlcat(sc->sc_type, " NVDIMM hybrid", SPDMEM_TYPE_MAXLEN); } - + if (node != NULL) sysctl_createv(>sc_sysctl_log, 0, NULL, NULL, 0, @@ -615,7 +615,7 @@ decode_sdram(const struct sysctlnode *no freq = 0; switch (freq) { /* - * Must check cycle time since some PC-133 DIMMs + * Must check cycle time since some PC-133 DIMMs * actually report PC-100 */ case 100: @@ -756,6 +756,30 @@ print_part(const char *part, size_t pnsi aprint_normal(": %.*s\n", (int)(p - part), part); } +static u_int +ddr3_value_pico(struct spdmem *s, uint8_t txx_mtb, uint8_t txx_ftb) +{ + u_int mtb, ftb; /* in picoseconds */ + intmax_t signed_txx_ftb; + u_int val; + + mtb = (u_int)s->sm_ddr3.ddr3_mtb_dividend * 1000 / + s->sm_ddr3.ddr3_mtb_divisor; + ftb = (u_int)s->sm_ddr3.ddr3_ftb_dividend * 1000 / + s->sm_ddr3.ddr3_ftb_divisor; + + /* tXX_ftb is signed value */ + signed_txx_ftb = (int8_t)txx_ftb; + val = txx_mtb * mtb + + ((txx_ftb > 127) ? signed_txx_ftb : txx_ftb) * ftb / 1000; + + return val; +} + +#define __DDR3_VALUE_PICO(s, field)\ + ddr3_value_pico(s, s->sm_ddr3.ddr3_##field##_mtb, \ + s->sm_ddr3.ddr3_##field##_ftb) + static void decode_ddr3(const struct sysctlnode *node, device_t self, struct spdmem *s) { @@ -786,10 +810,7 @@ decode_ddr3(const struct sysctlnode *nod (s->sm_ddr3.ddr3_chipwidth + 2); dimm_size = (1 << dimm_size) * (s->sm_ddr3.ddr3_physbanks + 1); - cycle_time = (1000 * s->sm_ddr3.ddr3_mtb_dividend + - (s->sm_ddr3.ddr3_mtb_divisor / 2)) / - s->sm_ddr3.ddr3_mtb_divisor; - cycle_time *= s->sm_ddr3.ddr3_tCKmin; + cycle_time = __DDR3_VALUE_PICO(s, tCKmin); bits = 1 << (s->sm_ddr3.ddr3_datawidth + 3); decode_size_speed(self, node, dimm_size, cycle_time, 2, bits, FALSE, "PC3", 0); @@ -797,17 +818,21 @@ decode_ddr3(const struct sysctlnode *nod aprint_verbose_dev(self, "%d rows, %d cols, %d log. banks, %d phys. banks, " "%d.%03dns cycle time\n", - s->sm_ddr3.ddr3_rows + 9, s->sm_ddr3.ddr3_cols + 12, + s->sm_ddr3.ddr3_rows + 12, s->sm_ddr3.ddr3_cols + 9, 1 << (s->sm_ddr3.ddr3_logbanks + 3), s->sm_ddr3.ddr3_physbanks + 1, cycle_time/1000, cycle_time % 1000); -#define __DDR3_CYCLES(field) (s->sm_ddr3.field / s->sm_ddr3.ddr3_tCKmin) +#define __DDR3_CYCLES(val) \ + ((val / cycle_time) + ((val % cycle_time) ? 1 : 0)) - aprint_verbose_dev(self, LATENCY, __DDR3_CYCLES(ddr3_tAAmin), - __DDR3_CYCLES(ddr3_tRCDmin),
CVS commit: [netbsd-9] src/sys/dev/ic
Module Name:src Committed By: martin Date: Sat Mar 21 20:24:36 UTC 2020 Modified Files: src/sys/dev/ic [netbsd-9]: dwc_mmc.c dwc_mmc_reg.h dwc_mmc_var.h Log Message: Pull up following revision(s) (requested by skrll in ticket #800): sys/dev/ic/dwc_mmc_var.h: revision 1.14 sys/dev/ic/dwc_mmc_reg.h: revision 1.10 sys/dev/ic/dwc_mmc.c: revision 1.23 sys/dev/ic/dwc_mmc.c: revision 1.24 sys/dev/ic/dwc_mmc.c: revision 1.25 sys/dev/ic/dwc_mmc.c: revision 1.26 Release the sc_intr_lock on error Trailing whitespace Add DWC_MMC_VERID_280A Remember / use sc_verid Disable thrctrl or now and note why To generate a diff of this commit: cvs rdiff -u -r1.17.2.2 -r1.17.2.3 src/sys/dev/ic/dwc_mmc.c cvs rdiff -u -r1.7.8.1 -r1.7.8.2 src/sys/dev/ic/dwc_mmc_reg.h cvs rdiff -u -r1.8.2.2 -r1.8.2.3 src/sys/dev/ic/dwc_mmc_var.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/ic/dwc_mmc.c diff -u src/sys/dev/ic/dwc_mmc.c:1.17.2.2 src/sys/dev/ic/dwc_mmc.c:1.17.2.3 --- src/sys/dev/ic/dwc_mmc.c:1.17.2.2 Tue Feb 25 18:40:43 2020 +++ src/sys/dev/ic/dwc_mmc.c Sat Mar 21 20:24:36 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dwc_mmc.c,v 1.17.2.2 2020/02/25 18:40:43 martin Exp $ */ +/* $NetBSD: dwc_mmc.c,v 1.17.2.3 2020/03/21 20:24:36 martin Exp $ */ /*- * Copyright (c) 2014-2017 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: dwc_mmc.c,v 1.17.2.2 2020/02/25 18:40:43 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dwc_mmc.c,v 1.17.2.3 2020/03/21 20:24:36 martin Exp $"); #include #include @@ -439,7 +439,7 @@ dwc_mmc_bus_width(sdmmc_chipset_handle_t } sc->sc_mmc_width = width; - + return 0; } @@ -662,11 +662,21 @@ dwc_mmc_exec_command(sdmmc_chipset_handl MMC_WRITE(sc, DWC_MMC_BLKSZ, cmd->c_blklen); MMC_WRITE(sc, DWC_MMC_BYTECNT, nblks > 1 ? nblks * cmd->c_blklen : cmd->c_datalen); + +#if 0 + /* + * The following doesn't work on the 250a verid IP in Odroid-XU4. + * + * thrctl should only be used for UHS/HS200 and faster timings on + * >=240a + */ + if (ISSET(cmd->c_flags, SCF_CMD_READ)) { MMC_WRITE(sc, DWC_MMC_CARDTHRCTL, __SHIFTIN(cmd->c_blklen, DWC_MMC_CARDTHRCTL_RDTHR) | DWC_MMC_CARDTHRCTL_RDTHREN); } +#endif } MMC_WRITE(sc, DWC_MMC_IMASK, imask | sc->sc_intr_card); @@ -717,6 +727,7 @@ dwc_mmc_exec_command(sdmmc_chipset_handl if (error != 0) { cmd->c_error = error; SET(cmd->c_flags, SCF_ITSDONE); + mutex_exit(>sc_intr_lock); goto done; } } @@ -806,11 +817,11 @@ dwc_mmc_init(struct dwc_mmc_softc *sc) { uint32_t val; - if (sc->sc_fifo_reg == 0) { - val = MMC_READ(sc, DWC_MMC_VERID); - const u_int id = __SHIFTOUT(val, DWC_MMC_VERID_ID); + val = MMC_READ(sc, DWC_MMC_VERID); + sc->sc_verid = __SHIFTOUT(val, DWC_MMC_VERID_ID); - if (id < DWC_MMC_VERID_240A) + if (sc->sc_fifo_reg == 0) { + if (sc->sc_verid < DWC_MMC_VERID_240A) sc->sc_fifo_reg = 0x100; else sc->sc_fifo_reg = 0x200; Index: src/sys/dev/ic/dwc_mmc_reg.h diff -u src/sys/dev/ic/dwc_mmc_reg.h:1.7.8.1 src/sys/dev/ic/dwc_mmc_reg.h:1.7.8.2 --- src/sys/dev/ic/dwc_mmc_reg.h:1.7.8.1 Tue Feb 25 18:40:43 2020 +++ src/sys/dev/ic/dwc_mmc_reg.h Sat Mar 21 20:24:36 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dwc_mmc_reg.h,v 1.7.8.1 2020/02/25 18:40:43 martin Exp $ */ +/* $NetBSD: dwc_mmc_reg.h,v 1.7.8.2 2020/03/21 20:24:36 martin Exp $ */ /*- * Copyright (c) 2014-2017 Jared McNeill @@ -153,6 +153,7 @@ #define DWC_MMC_VERID_ID __BITS(15,0) #define DWC_MMC_VERID_240A 0x240a +#define DWC_MMC_VERID_280A 0x280a #define DWC_MMC_IDST_HOST_ABT __BIT(10) #define DWC_MMC_IDST_ABNORMAL_INT_SUM __BIT(9) Index: src/sys/dev/ic/dwc_mmc_var.h diff -u src/sys/dev/ic/dwc_mmc_var.h:1.8.2.2 src/sys/dev/ic/dwc_mmc_var.h:1.8.2.3 --- src/sys/dev/ic/dwc_mmc_var.h:1.8.2.2 Tue Feb 25 18:40:43 2020 +++ src/sys/dev/ic/dwc_mmc_var.h Sat Mar 21 20:24:36 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dwc_mmc_var.h,v 1.8.2.2 2020/02/25 18:40:43 martin Exp $ */ +/* $NetBSD: dwc_mmc_var.h,v 1.8.2.3 2020/03/21 20:24:36 martin Exp $ */ /*- * Copyright (c) 2014-2017 Jared McNeill @@ -45,6 +45,7 @@ struct dwc_mmc_softc { u_int sc_clock_freq; u_int sc_bus_width; bool sc_card_inited; + u_int sc_verid; void *sc_ih; kmutex_t sc_lock;
CVS commit: [netbsd-9] src/sys/dev/ic
Module Name:src Committed By: martin Date: Tue Feb 11 08:41:28 UTC 2020 Modified Files: src/sys/dev/ic [netbsd-9]: elinkxl.c Log Message: Pull up following revision(s) (requested by msaitoh in ticket #695): sys/dev/ic/elinkxl.c: revision 1.137 Restore an register read for RX_FRAMES_OK which was removed in rev. 1.133. All statistics registers should be read to ACK the interrupt. Fixes PR#54920. XXX pullup-[89] To generate a diff of this commit: cvs rdiff -u -r1.131.2.1 -r1.131.2.2 src/sys/dev/ic/elinkxl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/ic/elinkxl.c diff -u src/sys/dev/ic/elinkxl.c:1.131.2.1 src/sys/dev/ic/elinkxl.c:1.131.2.2 --- src/sys/dev/ic/elinkxl.c:1.131.2.1 Wed Nov 6 09:59:38 2019 +++ src/sys/dev/ic/elinkxl.c Tue Feb 11 08:41:27 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: elinkxl.c,v 1.131.2.1 2019/11/06 09:59:38 martin Exp $ */ +/* $NetBSD: elinkxl.c,v 1.131.2.2 2020/02/11 08:41:27 martin Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: elinkxl.c,v 1.131.2.1 2019/11/06 09:59:38 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: elinkxl.c,v 1.131.2.2 2020/02/11 08:41:27 martin Exp $"); #include #include @@ -1514,6 +1514,7 @@ ex_getstats(struct ex_softc *sc) (void)bus_space_read_1(iot, ioh, TX_AFTER_1_COLLISION); (void)bus_space_read_1(iot, ioh, TX_NO_SQE); (void)bus_space_read_1(iot, ioh, TX_CD_LOST); + (void)bus_space_read_1(iot, ioh, RX_FRAMES_OK); GO_WINDOW(4); (void)bus_space_read_1(iot, ioh, ELINK_W4_BADSSD); GO_WINDOW(1);
CVS commit: [netbsd-9] src/sys/dev/ic
Module Name:src Committed By: martin Date: Tue Jan 28 11:12:30 UTC 2020 Modified Files: src/sys/dev/ic [netbsd-9]: rtl8169.c rtl81x9.c rtl81x9reg.h rtl81x9var.h Log Message: Pull up following revision(s) (requested by msaitoh in ticket #667): sys/dev/ic/rtl81x9var.h: revision 1.57 sys/dev/ic/rtl81x9.c: revision 1.107 sys/dev/ic/rtl81x9reg.h: revision 1.51 sys/dev/ic/rtl8169.c: revision 1.160 sys/dev/ic/rtl81x9reg.h: revision 1.52 sys/dev/ic/rtl8169.c: revision 1.161 Use unsigned in rtk_setmulti() to avoid undefined behavior. Found bk kUBSan. 8168H model didn't link up well. some models seems to require to enable TX/RX after configuration. RTKQ_TXRXEN_LATER quirk flag added. it may be able to unify with RTKQ_RXDV_GATED flag? Sort RTK_HWREV_* by value. Improve some chip revisions support: - Add 8168FP, 8411, 8168G, 8401E, 8105E, 8105E_SPIN1, 8106E and 8402 from {Free,Open}BSD. - Renumber RTK_HWREV_8103E from 0x24C0 to 0x34c0. 0x24C0 is newly used as RTK_HWREV_8102EL_SPIN1. Same as {Free,Open}BSD. To generate a diff of this commit: cvs rdiff -u -r1.159 -r1.159.2.1 src/sys/dev/ic/rtl8169.c cvs rdiff -u -r1.106 -r1.106.2.1 src/sys/dev/ic/rtl81x9.c cvs rdiff -u -r1.50 -r1.50.4.1 src/sys/dev/ic/rtl81x9reg.h cvs rdiff -u -r1.56 -r1.56.18.1 src/sys/dev/ic/rtl81x9var.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/ic/rtl8169.c diff -u src/sys/dev/ic/rtl8169.c:1.159 src/sys/dev/ic/rtl8169.c:1.159.2.1 --- src/sys/dev/ic/rtl8169.c:1.159 Thu May 30 02:32:18 2019 +++ src/sys/dev/ic/rtl8169.c Tue Jan 28 11:12:30 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: rtl8169.c,v 1.159 2019/05/30 02:32:18 msaitoh Exp $ */ +/* $NetBSD: rtl8169.c,v 1.159.2.1 2020/01/28 11:12:30 martin Exp $ */ /* * Copyright (c) 1997, 1998-2003 @@ -33,7 +33,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: rtl8169.c,v 1.159 2019/05/30 02:32:18 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rtl8169.c,v 1.159.2.1 2020/01/28 11:12:30 martin Exp $"); /* $FreeBSD: /repoman/r/ncvs/src/sys/dev/re/if_re.c,v 1.20 2004/04/11 20:34:08 ru Exp $ */ /* @@ -607,17 +607,24 @@ re_attach(struct rtk_softc *sc) sc->sc_quirk |= RTKQ_NOJUMBO; break; case RTK_HWREV_8168E: - case RTK_HWREV_8168H: case RTK_HWREV_8168H_SPIN1: sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD | RTKQ_MACSTAT | RTKQ_CMDSTOP | RTKQ_PHYWAKE_PM | RTKQ_NOJUMBO; break; + case RTK_HWREV_8168H: + case RTK_HWREV_8168FP: + sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD | + RTKQ_MACSTAT | RTKQ_CMDSTOP | RTKQ_PHYWAKE_PM | + RTKQ_NOJUMBO | RTKQ_RXDV_GATED | RTKQ_TXRXEN_LATER; + break; case RTK_HWREV_8168E_VL: case RTK_HWREV_8168F: + case RTK_HWREV_8411: sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD | RTKQ_MACSTAT | RTKQ_CMDSTOP | RTKQ_NOJUMBO; break; + case RTK_HWREV_8168EP: case RTK_HWREV_8168G: case RTK_HWREV_8168G_SPIN1: case RTK_HWREV_8168G_SPIN2: @@ -633,10 +640,27 @@ re_attach(struct rtk_softc *sc) break; case RTK_HWREV_8102E: case RTK_HWREV_8102EL: - case RTK_HWREV_8103E: + case RTK_HWREV_8102EL_SPIN1: sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD | RTKQ_MACSTAT | RTKQ_CMDSTOP | RTKQ_NOJUMBO; break; + case RTK_HWREV_8103E: + sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD | + RTKQ_MACSTAT | RTKQ_CMDSTOP; + break; + case RTK_HWREV_8401E: + case RTK_HWREV_8105E: + case RTK_HWREV_8105E_SPIN1: + case RTK_HWREV_8106E: + sc->sc_quirk |= RTKQ_PHYWAKE_PM | + RTKQ_DESCV2 | RTKQ_NOEECMD | RTKQ_MACSTAT | + RTKQ_CMDSTOP; + break; + case RTK_HWREV_8402: + sc->sc_quirk |= RTKQ_PHYWAKE_PM | + RTKQ_DESCV2 | RTKQ_NOEECMD | RTKQ_MACSTAT | + RTKQ_CMDSTOP; /* CMDSTOP_WAIT_TXQ */ + break; default: aprint_normal_dev(sc->sc_dev, "Unknown revision (0x%08x)\n", hwrev); @@ -1873,7 +1897,8 @@ re_init(struct ifnet *ifp) /* * Enable transmit and receive. */ - CSR_WRITE_1(sc, RTK_COMMAND, RTK_CMD_TX_ENB | RTK_CMD_RX_ENB); + if ((sc->sc_quirk & RTKQ_TXRXEN_LATER) == 0) + CSR_WRITE_1(sc, RTK_COMMAND, RTK_CMD_TX_ENB | RTK_CMD_RX_ENB); /* * Set the initial TX and RX configuration. @@ -1915,6 +1940,12 @@ re_init(struct ifnet *ifp) rtk_setmulti(sc); /* + * some chips require to enable TX/RX *AFTER* TX/RX configuration + */ + if ((sc->sc_quirk & RTKQ_TXRXEN_LATER) != 0) + CSR_WRITE_1(sc, RTK_COMMAND, RTK_CMD_TX_ENB | RTK_CMD_RX_ENB); + + /* * Enable interrupts. */ if (sc->re_testmode) Index: src/sys/dev/ic/rtl81x9.c diff -u src/sys/dev/ic/rtl81x9.c:1.106 src/sys/dev/ic/rtl81x9.c:1.106.2.1 --- src/sys/dev/ic/rtl81x9.c:1.106 Tue May 28 07:41:48 2019 +++ src/sys/dev/ic/rtl81x9.c Tue Jan 28 11:12:30 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: rtl81x9.c,v 1.106 2019/05/28 07:41:48 msaitoh Exp $ */ +/* $NetBSD: rtl81x9.c,v 1.106.2.1 2020/01/28
CVS commit: [netbsd-9] src/sys/dev/ic
Module Name:src Committed By: martin Date: Wed Jan 8 11:50:58 UTC 2020 Modified Files: src/sys/dev/ic [netbsd-9]: gem.c Log Message: Pull up following revision(s) (requested by msaitoh in ticket #610): sys/dev/ic/gem.c: revision 1.124 Fix error path in gem(4)'s TX checksum offload. - Avoid accessing free'd m0 on error. Use m_freem() instead of m_free(). Reported by maxv@. - Tested by martin@, macallan@ and jdc@. To generate a diff of this commit: cvs rdiff -u -r1.120 -r1.120.2.1 src/sys/dev/ic/gem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/ic/gem.c diff -u src/sys/dev/ic/gem.c:1.120 src/sys/dev/ic/gem.c:1.120.2.1 --- src/sys/dev/ic/gem.c:1.120 Tue May 28 08:59:34 2019 +++ src/sys/dev/ic/gem.c Wed Jan 8 11:50:57 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: gem.c,v 1.120 2019/05/28 08:59:34 msaitoh Exp $ */ +/* $NetBSD: gem.c,v 1.120.2.1 2020/01/08 11:50:57 martin Exp $ */ /* * @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: gem.c,v 1.120 2019/05/28 08:59:34 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gem.c,v 1.120.2.1 2020/01/08 11:50:57 martin Exp $"); #include "opt_inet.h" @@ -1389,6 +1389,7 @@ gem_start(struct ifnet *ifp) * until we drain the queue, or use up all available transmit * descriptors. */ +next: while ((txs = SIMPLEQ_FIRST(>sc_txfreeq)) != NULL && sc->sc_txfree != 0) { /* @@ -1498,16 +1499,9 @@ gem_start(struct ifnet *ifp) * and the checksum stuff if we want the hardware * to do it. */ - sc->sc_txdescs[nexttx].gd_addr = - GEM_DMA_WRITE(sc, dmamap->dm_segs[seg].ds_addr); flags = dmamap->dm_segs[seg].ds_len & GEM_TD_BUFSIZE; if (nexttx == firsttx) { flags |= GEM_TD_START_OF_PACKET; -if (++sc->sc_txwin > GEM_NTXSEGS * 2 / 3) { - sc->sc_txwin = 0; - flags |= GEM_TD_INTERRUPT_ME; -} - #ifdef INET /* h/w checksum */ if (ifp->if_csum_flags_tx & M_CSUM_TCPv4 && @@ -1526,8 +1520,10 @@ gem_start(struct ifnet *ifp) break; default: /* unsupported, drop it */ - m_free(m0); - continue; + bus_dmamap_unload(sc->sc_dmatag, + dmamap); + m_freem(m0); + goto next; } start += M_CSUM_DATA_IPv4_IPHL(m0->m_pkthdr.csum_data); offset = M_CSUM_DATA_IPv4_OFFSET(m0->m_pkthdr.csum_data) + start; @@ -1538,7 +1534,13 @@ gem_start(struct ifnet *ifp) GEM_TD_CXSUM_ENABLE; } #endif +if (++sc->sc_txwin > GEM_NTXSEGS * 2 / 3) { + sc->sc_txwin = 0; + flags |= GEM_TD_INTERRUPT_ME; +} } + sc->sc_txdescs[nexttx].gd_addr = + GEM_DMA_WRITE(sc, dmamap->dm_segs[seg].ds_addr); if (seg == dmamap->dm_nsegs - 1) { flags |= GEM_TD_END_OF_PACKET; } else {
CVS commit: [netbsd-9] src/sys/dev/ic
Module Name:src Committed By: martin Date: Tue Dec 24 17:34:33 UTC 2019 Modified Files: src/sys/dev/ic [netbsd-9]: ahcisata_core.c Log Message: Pull up following revision(s) (requested by jmcneill in ticket #576): sys/dev/ic/ahcisata_core.c: revision 1.79 When resetting a drive, if the command list is running and CLO is not supported, attempt to stop the drive first and fail gracefully if that fails instead of triggering a KASSERT on DIAGNOSTIC kernels. To generate a diff of this commit: cvs rdiff -u -r1.75.4.1 -r1.75.4.2 src/sys/dev/ic/ahcisata_core.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/ic/ahcisata_core.c diff -u src/sys/dev/ic/ahcisata_core.c:1.75.4.1 src/sys/dev/ic/ahcisata_core.c:1.75.4.2 --- src/sys/dev/ic/ahcisata_core.c:1.75.4.1 Wed Oct 23 18:06:46 2019 +++ src/sys/dev/ic/ahcisata_core.c Tue Dec 24 17:34:33 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ahcisata_core.c,v 1.75.4.1 2019/10/23 18:06:46 martin Exp $ */ +/* $NetBSD: ahcisata_core.c,v 1.75.4.2 2019/12/24 17:34:33 martin Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.75.4.1 2019/10/23 18:06:46 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.75.4.2 2019/12/24 17:34:33 martin Exp $"); #include #include @@ -807,7 +807,7 @@ ahci_do_reset_drive(struct ata_channel * struct ahci_cmd_tbl *cmd_tbl; struct ahci_cmd_header *cmd_h; int i, error = 0; - uint32_t sig; + uint32_t sig, cmd; int noclo_retry = 0; ata_channel_lock_owned(chp); @@ -825,6 +825,19 @@ again: ahci_channel_start(sc, chp, flags, 1); } else { /* Can't handle command still running without CLO */ + cmd = AHCI_READ(sc, AHCI_P_CMD(chp->ch_channel)); + if ((cmd & AHCI_P_CMD_CR) != 0) { + ahci_channel_stop(sc, chp, flags); + cmd = AHCI_READ(sc, AHCI_P_CMD(chp->ch_channel)); + if ((cmd & AHCI_P_CMD_CR) != 0) { +aprint_error("%s port %d: DMA engine busy " +"for drive %d\n", AHCINAME(sc), +chp->ch_channel, drive); +error = EBUSY; +goto end; + } + } + KASSERT((AHCI_READ(sc, AHCI_P_CMD(chp->ch_channel)) & AHCI_P_CMD_CR) == 0); ahci_channel_start(sc, chp, flags, 0);