Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ic Also fix shift values for SCT constants.



details:   https://anonhg.NetBSD.org/src/rev/8533e939eea8
branches:  trunk
changeset: 368740:8533e939eea8
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Mon Aug 01 07:34:28 2022 +0000

description:
Also fix shift values for SCT constants.

diffstat:

 sys/dev/ic/ahcisata_core.c |  28 +++++++++++++++++++++++-----
 sys/dev/ic/bcmgenet.c      |  12 +++++++-----
 sys/dev/ic/nslm7x.c        |  10 +++++++---
 sys/dev/ic/nvmereg.h       |  10 +++++-----
 sys/dev/ic/nvmevar.h       |  32 +++++++++++++++++++++-----------
 sys/dev/ic/rtl8169.c       |   8 ++++----
 sys/dev/ic/tulip.c         |   6 +++---
 sys/dev/ic/tulipreg.h      |   8 ++++----
 8 files changed, 74 insertions(+), 40 deletions(-)

diffs (truncated from 321 to 300 lines):

diff -r a4833396b738 -r 8533e939eea8 sys/dev/ic/ahcisata_core.c
--- a/sys/dev/ic/ahcisata_core.c        Mon Aug 01 01:32:15 2022 +0000
+++ b/sys/dev/ic/ahcisata_core.c        Mon Aug 01 07:34:28 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ahcisata_core.c,v 1.105 2021/11/19 23:46:55 rin Exp $  */
+/*     $NetBSD: ahcisata_core.c,v 1.106 2022/08/01 07:34:28 mlelstv Exp $      */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.105 2021/11/19 23:46:55 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.106 2022/08/01 07:34:28 mlelstv Exp $");
 
 #include <sys/types.h>
 #include <sys/malloc.h>
@@ -828,8 +828,8 @@
                                 */
                                return ERROR;
                        }
-                       aprint_debug("%s port %d: error 0x%x sending FIS\n",
-                           AHCINAME(sc), chp->ch_channel, is);
+                       aprint_debug("%s port %d: error 0x%x sending FIS, t %d\n",
+                           AHCINAME(sc), chp->ch_channel, is, timeout);
                        return ERR_DF;
                }
                ata_delay(chp, 10, "ahcifis", flags);
@@ -1635,9 +1635,27 @@
                /* XXX controller reset ? */
                return;
        }
-
        if (sc->sc_channel_stop)
                sc->sc_channel_stop(sc, chp);
+       if ((AHCI_READ(sc, AHCI_P_CMD(chp->ch_channel)) & AHCI_P_CMD_FRE) == 0)
+               return;
+
+       AHCI_WRITE(sc, AHCI_P_CMD(chp->ch_channel),
+           AHCI_READ(sc, AHCI_P_CMD(chp->ch_channel)) & ~AHCI_P_CMD_FRE);
+       /* wait 1s for FIS receive to stop */
+       for (i = 0; i <100; i++) {
+               if ((AHCI_READ(sc, AHCI_P_CMD(chp->ch_channel)) & AHCI_P_CMD_FR)
+                   == 0)
+                       break;
+               if (flags & AT_WAIT)
+                       tsleep(&sc, PRIBIO, "ahcistop", mstohz(10));
+               else
+                       delay(10000);
+       }
+       if (AHCI_READ(sc, AHCI_P_CMD(chp->ch_channel)) & AHCI_P_CMD_FR) {
+               printf("%s: channel FIS receive wouldn't stop\n", AHCINAME(sc));
+               /* XXX controller reset ? */
+       }
 }
 
 static void
diff -r a4833396b738 -r 8533e939eea8 sys/dev/ic/bcmgenet.c
--- a/sys/dev/ic/bcmgenet.c     Mon Aug 01 01:32:15 2022 +0000
+++ b/sys/dev/ic/bcmgenet.c     Mon Aug 01 07:34:28 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bcmgenet.c,v 1.11 2021/12/31 14:25:22 riastradh Exp $ */
+/* $NetBSD: bcmgenet.c,v 1.12 2022/08/01 07:34:28 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 2020 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -34,7 +34,7 @@
 #include "opt_ddb.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bcmgenet.c,v 1.11 2021/12/31 14:25:22 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcmgenet.c,v 1.12 2022/08/01 07:34:28 mlelstv Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -730,7 +730,8 @@
                        bus_dmamap_sync(sc->sc_rx.buf_tag, sc->sc_rx.buf_map[index].map,
                            0, sc->sc_rx.buf_map[index].map->dm_mapsize,
                            BUS_DMASYNC_POSTREAD);
-               }
+               } else
+                       device_printf(sc->sc_dev, "RXINTR empty %d\n",index);
                bus_dmamap_unload(sc->sc_rx.buf_tag, sc->sc_rx.buf_map[index].map);
                sc->sc_rx.buf_map[index].mbuf = NULL;
 
@@ -784,18 +785,19 @@
                                bus_dmamap_sync(sc->sc_tx.buf_tag, bmap->map,
                                    0, bmap->map->dm_mapsize,
                                    BUS_DMASYNC_POSTWRITE);
-                       }
+                       } else
+                               device_printf(sc->sc_dev, "TXINTR empty %d\n",i);
                        bus_dmamap_unload(sc->sc_tx.buf_tag, bmap->map);
                        m_freem(bmap->mbuf);
                        bmap->mbuf = NULL;
                        ++pkts;
                }
 
-               ifp->if_flags &= ~IFF_OACTIVE;
                i = TX_NEXT(i);
                sc->sc_tx.cidx = (sc->sc_tx.cidx + 1) & 0xffff;
        }
 
+       ifp->if_flags &= ~IFF_OACTIVE;
        if_statadd(ifp, if_opackets, pkts);
 
        if (pkts != 0)
diff -r a4833396b738 -r 8533e939eea8 sys/dev/ic/nslm7x.c
--- a/sys/dev/ic/nslm7x.c       Mon Aug 01 01:32:15 2022 +0000
+++ b/sys/dev/ic/nslm7x.c       Mon Aug 01 07:34:28 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nslm7x.c,v 1.74 2020/09/07 00:32:28 mrg Exp $ */
+/*     $NetBSD: nslm7x.c,v 1.75 2022/08/01 07:34:28 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nslm7x.c,v 1.74 2020/09/07 00:32:28 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nslm7x.c,v 1.75 2022/08/01 07:34:28 mlelstv Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -2247,6 +2247,7 @@
                if ((rv = sysmon_envsys_sensor_attach(lmsc->sc_sme,
                            &lmsc->sensors[i])) != 0) {
                        sysmon_envsys_destroy(lmsc->sc_sme);
+                       lmsc->sc_sme = NULL;
                        aprint_error_dev(lmsc->sc_dev,
                            "sysmon_envsys_sensor_attach() returned %d\n", rv);
                        return;
@@ -2270,6 +2271,7 @@
                aprint_error_dev(lmsc->sc_dev,
                    "unable to register with sysmon\n");
                sysmon_envsys_destroy(lmsc->sc_sme);
+               lmsc->sc_sme = NULL;
        }
        if (!pmf_device_register(lmsc->sc_dev, NULL, NULL))
                aprint_error_dev(lmsc->sc_dev,
@@ -2285,7 +2287,9 @@
 {
        callout_halt(&lmsc->sc_callout, NULL);
        callout_destroy(&lmsc->sc_callout);
-       sysmon_envsys_unregister(lmsc->sc_sme);
+
+       if (lmsc->sc_sme != NULL)
+               sysmon_envsys_unregister(lmsc->sc_sme);
        pmf_device_deregister(lmsc->sc_dev);
 }
 
diff -r a4833396b738 -r 8533e939eea8 sys/dev/ic/nvmereg.h
--- a/sys/dev/ic/nvmereg.h      Mon Aug 01 01:32:15 2022 +0000
+++ b/sys/dev/ic/nvmereg.h      Mon Aug 01 07:34:28 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nvmereg.h,v 1.17 2022/07/31 11:58:37 mlelstv Exp $     */
+/*     $NetBSD: nvmereg.h,v 1.18 2022/08/01 07:34:28 mlelstv Exp $     */
 /*     $OpenBSD: nvmereg.h,v 1.10 2016/04/14 11:18:32 dlg Exp $ */
 
 /*
@@ -242,10 +242,10 @@
 #define NVME_CQE_M             __BIT(14)
 #define NVME_CQE_SCT_MASK      __BITS(9, 11)
 #define NVME_CQE_SCT(_f)       ((_f) & NVME_CQE_SCT_MASK)
-#define  NVME_CQE_SCT_GENERIC          (0x00 << 8)
-#define  NVME_CQE_SCT_COMMAND          (0x01 << 8)
-#define  NVME_CQE_SCT_MEDIAERR         (0x02 << 8)
-#define  NVME_CQE_SCT_VENDOR           (0x07 << 8)
+#define  NVME_CQE_SCT_GENERIC          (0x00 << 9)
+#define  NVME_CQE_SCT_COMMAND          (0x01 << 9)
+#define  NVME_CQE_SCT_MEDIAERR         (0x02 << 9)
+#define  NVME_CQE_SCT_VENDOR           (0x07 << 9)
 #define NVME_CQE_SC_MASK       __BITS(1, 8)
 #define NVME_CQE_SC(_f)                ((_f) & NVME_CQE_SC_MASK)
 /* generic command status codes */
diff -r a4833396b738 -r 8533e939eea8 sys/dev/ic/nvmevar.h
--- a/sys/dev/ic/nvmevar.h      Mon Aug 01 01:32:15 2022 +0000
+++ b/sys/dev/ic/nvmevar.h      Mon Aug 01 07:34:28 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nvmevar.h,v 1.24 2022/05/07 08:20:04 skrll Exp $       */
+/*     $NetBSD: nvmevar.h,v 1.25 2022/08/01 07:34:28 mlelstv Exp $     */
 /*     $OpenBSD: nvmevar.h,v 1.8 2016/04/14 11:18:32 dlg Exp $ */
 
 /*
@@ -23,7 +23,6 @@
 #include <sys/mutex.h>
 #include <sys/pool.h>
 #include <sys/queue.h>
-#include <sys/buf.h>
 
 struct nvme_dmamem {
        bus_dmamap_t            ndm_map;
@@ -199,18 +198,29 @@
 static __inline struct nvme_queue *
 nvme_get_q(struct nvme_softc *sc, struct buf *bp, bool waitok)
 {
-       struct cpu_info *ci = (bp && bp->b_ci) ? bp->b_ci : curcpu();
+       struct nvme_queue *q;
+       u_int cpunum;
+
+       cpunum = cpu_index(curcpu());
 
-       /*
-        * Find a queue with available ccbs, preferring the originating CPU's queue.
-        */
+       /* try own queue */
+       q = sc->sc_q[cpunum % sc->sc_nq];
+       if (waitok)
+               return q;
 
-       for (u_int qoff = 0; qoff < sc->sc_nq; qoff++) {
-               struct nvme_queue *q = sc->sc_q[(cpu_index(ci) + qoff) % sc->sc_nq];
-               if (!SIMPLEQ_EMPTY(&q->q_ccb_list) || waitok)
-                       return q;
+       /* if busy, search for an idle queue */
+       if (SIMPLEQ_EMPTY(&q->q_ccb_list)) {
+               for (u_int qoff = 1; qoff < sc->sc_nq; qoff++) {
+                       struct nvme_queue *t;
+                       t = sc->sc_q[(cpunum + qoff) % sc->sc_nq];
+                       if (t->q_sq_tail == t->q_cq_head) {
+                               q = t;
+                               break;
+                       }
+               }
        }
-       return NULL;
+
+       return q;
 }
 
 /*
diff -r a4833396b738 -r 8533e939eea8 sys/dev/ic/rtl8169.c
--- a/sys/dev/ic/rtl8169.c      Mon Aug 01 01:32:15 2022 +0000
+++ b/sys/dev/ic/rtl8169.c      Mon Aug 01 07:34:28 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rtl8169.c,v 1.172 2022/06/25 02:46:15 tsutsui Exp $    */
+/*     $NetBSD: rtl8169.c,v 1.173 2022/08/01 07:34:28 mlelstv Exp $    */
 
 /*
  * Copyright (c) 1997, 1998-2003
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtl8169.c,v 1.172 2022/06/25 02:46:15 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtl8169.c,v 1.173 2022/08/01 07:34:28 mlelstv Exp $");
 /* $FreeBSD: /repoman/r/ncvs/src/sys/dev/re/if_re.c,v 1.20 2004/04/11 20:34:08 ru Exp $ */
 
 /*
@@ -682,8 +682,8 @@
                case RTK_HWREV_8168H:
                case RTK_HWREV_8411B:
                        sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD |
-                           RTKQ_MACSTAT | RTKQ_CMDSTOP | RTKQ_NOJUMBO | 
-                           RTKQ_RXDV_GATED | RTKQ_TXRXEN_LATER;
+                           RTKQ_MACSTAT | RTKQ_CMDSTOP | RTKQ_PHYWAKE_PM |
+                           RTKQ_NOJUMBO | RTKQ_RXDV_GATED | RTKQ_TXRXEN_LATER;
                        break;
                case RTK_HWREV_8100E:
                case RTK_HWREV_8100E_SPIN2:
diff -r a4833396b738 -r 8533e939eea8 sys/dev/ic/tulip.c
--- a/sys/dev/ic/tulip.c        Mon Aug 01 01:32:15 2022 +0000
+++ b/sys/dev/ic/tulip.c        Mon Aug 01 07:34:28 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tulip.c,v 1.205 2022/06/25 02:46:15 tsutsui Exp $      */
+/*     $NetBSD: tulip.c,v 1.206 2022/08/01 07:34:28 mlelstv Exp $      */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2002 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tulip.c,v 1.205 2022/06/25 02:46:15 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tulip.c,v 1.206 2022/08/01 07:34:28 mlelstv Exp $");
 
 
 #include <sys/param.h>
@@ -4394,7 +4394,7 @@
         */
 
        /* XXX This should be auto-sense. */
-       ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_10_T);
+       ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_10_5);
 
        tlp_print_media(sc);
 }
diff -r a4833396b738 -r 8533e939eea8 sys/dev/ic/tulipreg.h
--- a/sys/dev/ic/tulipreg.h     Mon Aug 01 01:32:15 2022 +0000
+++ b/sys/dev/ic/tulipreg.h     Mon Aug 01 07:34:28 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tulipreg.h,v 1.41 2021/08/19 20:43:58 andvar Exp $     */
+/*     $NetBSD: tulipreg.h,v 1.42 2022/08/01 07:34:28 mlelstv Exp $    */
 
 /*-
  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -938,19 +938,19 @@
 



Home | Main Index | Thread Index | Old Index