Source-Changes-HG archive

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

[src/trunk]: src Register eight vHCI buses, and use separate KCOV mailboxes f...



details:   https://anonhg.NetBSD.org/src/rev/2a788f142c77
branches:  trunk
changeset: 1010769:2a788f142c77
user:      maxv <maxv%NetBSD.org@localhost>
date:      Fri Jun 05 17:20:56 2020 +0000

description:
Register eight vHCI buses, and use separate KCOV mailboxes for them.

diffstat:

 etc/MAKEDEV.tmpl       |   7 ++++---
 sys/dev/usb/uhub.c     |  16 ++++++++++------
 sys/dev/usb/usbdivar.h |   3 ++-
 sys/dev/usb/vhci.c     |  33 +++++++++++++++++++++------------
 sys/sys/kcov.h         |   4 +++-
 5 files changed, 40 insertions(+), 23 deletions(-)

diffs (201 lines):

diff -r a0833a63d976 -r 2a788f142c77 etc/MAKEDEV.tmpl
--- a/etc/MAKEDEV.tmpl  Fri Jun 05 17:10:44 2020 +0000
+++ b/etc/MAKEDEV.tmpl  Fri Jun 05 17:20:56 2020 +0000
@@ -1,5 +1,5 @@
 #!/bin/sh -
-#      $NetBSD: MAKEDEV.tmpl,v 1.218 2020/04/04 16:04:36 jdolecek Exp $
+#      $NetBSD: MAKEDEV.tmpl,v 1.219 2020/06/05 17:20:56 maxv Exp $
 #
 # Copyright (c) 2003,2007,2008 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -1785,8 +1785,9 @@
        mkdev veriexec c %veriexec_chr% 0 600
        ;;
 
-vhci)
-       mkdev vhci c %vhci_chr% 0
+vhci[0-7]*)
+       unit=${i#vhci}
+       mkdev vhci$unit c %vhci_chr% $unit
        ;;
 
 ttyv[0-9]*)
diff -r a0833a63d976 -r 2a788f142c77 sys/dev/usb/uhub.c
--- a/sys/dev/usb/uhub.c        Fri Jun 05 17:10:44 2020 +0000
+++ b/sys/dev/usb/uhub.c        Fri Jun 05 17:20:56 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uhub.c,v 1.146 2020/05/31 08:05:30 maxv Exp $  */
+/*     $NetBSD: uhub.c,v 1.147 2020/06/05 17:20:56 maxv Exp $  */
 /*     $FreeBSD: src/sys/dev/usb/uhub.c,v 1.18 1999/11/17 22:33:43 n_hibma Exp $       */
 /*     $OpenBSD: uhub.c,v 1.86 2015/06/29 18:27:40 mpi Exp $ */
 
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.146 2020/05/31 08:05:30 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.147 2020/06/05 17:20:56 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -754,15 +754,19 @@
                                    port);
                }
 
-               if (dev->ud_bus->ub_hctype == USBHCTYPE_VHCI)
-                       kcov_remote_enter(KCOV_REMOTE_VHCI, port);
+               if (dev->ud_bus->ub_hctype == USBHCTYPE_VHCI) {
+                       kcov_remote_enter(KCOV_REMOTE_VHCI,
+                           KCOV_REMOTE_VHCI_ID(dev->ud_bus->ub_busnum, port));
+               }
 
                /* Get device info and set its address. */
                err = usbd_new_device(sc->sc_dev, dev->ud_bus,
                          dev->ud_depth + 1, speed, port, up);
 
-               if (dev->ud_bus->ub_hctype == USBHCTYPE_VHCI)
-                       kcov_remote_leave(KCOV_REMOTE_VHCI, port);
+               if (dev->ud_bus->ub_hctype == USBHCTYPE_VHCI) {
+                       kcov_remote_leave(KCOV_REMOTE_VHCI,
+                           KCOV_REMOTE_VHCI_ID(dev->ud_bus->ub_busnum, port));
+               }
 
                /* XXX retry a few times? */
                if (err) {
diff -r a0833a63d976 -r 2a788f142c77 sys/dev/usb/usbdivar.h
--- a/sys/dev/usb/usbdivar.h    Fri Jun 05 17:10:44 2020 +0000
+++ b/sys/dev/usb/usbdivar.h    Fri Jun 05 17:20:56 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usbdivar.h,v 1.123 2020/05/15 12:34:52 maxv Exp $      */
+/*     $NetBSD: usbdivar.h,v 1.124 2020/06/05 17:20:56 maxv Exp $      */
 
 /*
  * Copyright (c) 1998, 2012 The NetBSD Foundation, Inc.
@@ -165,6 +165,7 @@
 #define USBHCTYPE_EHCI         4
 #define USBHCTYPE_XHCI         5
 #define USBHCTYPE_VHCI         6
+       int                     ub_busnum;
        const struct usbd_bus_methods
                               *ub_methods;
        uint32_t                ub_pipesize;    /* size of a pipe struct */
diff -r a0833a63d976 -r 2a788f142c77 sys/dev/usb/vhci.c
--- a/sys/dev/usb/vhci.c        Fri Jun 05 17:10:44 2020 +0000
+++ b/sys/dev/usb/vhci.c        Fri Jun 05 17:20:56 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vhci.c,v 1.19 2020/05/31 07:53:38 maxv Exp $ */
+/*     $NetBSD: vhci.c,v 1.20 2020/06/05 17:20:56 maxv Exp $ */
 
 /*
  * Copyright (c) 2019-2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vhci.c,v 1.19 2020/05/31 07:53:38 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vhci.c,v 1.20 2020/06/05 17:20:56 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -239,6 +239,7 @@
 
 #define VHCI_INDEX2PORT(idx)   (idx)
 #define VHCI_NPORTS            8       /* above 8, update TODO-bitmap */
+#define VHCI_NBUSES            8
 
 typedef struct {
        device_t sc_dev;
@@ -1021,12 +1022,15 @@
 static int
 vhci_fd_open(dev_t dev, int flags, int type, struct lwp *l)
 {
+       vhci_softc_t *sc;
        vhci_fd_t *vfd;
        struct file *fp;
        int error, fd;
 
-       if (minor(dev) != 0)
+       sc = device_lookup_private(&vhci_cd, minor(dev));
+       if (sc == NULL)
                return EXDEV;
+
        error = fd_allocfile(&fp, &fd);
        if (error)
                return error;
@@ -1034,7 +1038,7 @@
        vfd = kmem_alloc(sizeof(*vfd), KM_SLEEP);
        vfd->port = 1;
        vfd->addr = 0;
-       vfd->softc = device_lookup_private(&vhci_cd, minor(dev));
+       vfd->softc = sc;
 
        return fd_clone(fp, fd, flags, &vhci_fileops, vfd);
 }
@@ -1242,13 +1246,9 @@
 void
 vhciattach(int nunits)
 {
-       static struct cfdata vhci_cfdata = {
-               .cf_name = "vhci",
-               .cf_atname = "vhci",
-               .cf_unit = 0,
-               .cf_fstate = FSTATE_STAR,
-       };
+       struct cfdata *cf;
        int error;
+       size_t i;
 
        error = config_cfattach_attach(vhci_cd.cd_name, &vhci_ca);
        if (error) {
@@ -1258,7 +1258,14 @@
                return;
        }
 
-       config_attach_pseudo(&vhci_cfdata);
+       for (i = 0; i < VHCI_NBUSES; i++) {
+               cf = kmem_alloc(sizeof(*cf), KM_SLEEP);
+               cf->cf_name = vhci_cd.cd_name;
+               cf->cf_atname = vhci_cd.cd_name;
+               cf->cf_unit = i;
+               cf->cf_fstate = FSTATE_STAR;
+               config_attach_pseudo(cf);
+       }
 }
 
 static int
@@ -1292,6 +1299,7 @@
        sc->sc_dev = self;
        sc->sc_bus.ub_revision = USBREV_2_0;
        sc->sc_bus.ub_hctype = USBHCTYPE_VHCI;
+       sc->sc_bus.ub_busnum = self->dv_unit;
        sc->sc_bus.ub_usedma = false;
        sc->sc_bus.ub_methods = &vhci_bus_methods;
        sc->sc_bus.ub_pipesize = sizeof(vhci_pipe_t);
@@ -1307,7 +1315,8 @@
                        TAILQ_INIT(&port->endpoints[addr].usb_to_host);
                        TAILQ_INIT(&port->endpoints[addr].host_to_usb);
                }
-               kcov_remote_register(KCOV_REMOTE_VHCI, i);
+               kcov_remote_register(KCOV_REMOTE_VHCI,
+                   KCOV_REMOTE_VHCI_ID(sc->sc_bus.ub_busnum, i));
        }
 
        sc->sc_child = config_found(self, &sc->sc_bus, usbctlprint);
diff -r a0833a63d976 -r 2a788f142c77 sys/sys/kcov.h
--- a/sys/sys/kcov.h    Fri Jun 05 17:10:44 2020 +0000
+++ b/sys/sys/kcov.h    Fri Jun 05 17:20:56 2020 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: kcov.h,v 1.9 2020/05/15 13:09:02 maxv Exp $        */
+/*      $NetBSD: kcov.h,v 1.10 2020/06/05 17:20:57 maxv Exp $        */
 
 /*
  * Copyright (c) 2019-2020 The NetBSD Foundation, Inc.
@@ -53,6 +53,8 @@
 };
 
 #define KCOV_REMOTE_VHCI       0
+#define KCOV_REMOTE_VHCI_ID(bus, port) \
+       (((uint64_t)bus << 32ULL) | ((uint64_t)port & 0xFFFFFFFFULL))
 
 #define KCOV_MODE_NONE         0
 #define KCOV_MODE_TRACE_PC     1



Home | Main Index | Thread Index | Old Index