Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci Make ehci deal with pci devices that have multip...



details:   https://anonhg.NetBSD.org/src/rev/5caf3436a0e9
branches:  trunk
changeset: 759490:5caf3436a0e9
user:      matt <matt%NetBSD.org@localhost>
date:      Sat Dec 11 17:58:41 2010 +0000

description:
Make ehci deal with pci devices that have multiple companion functions and
ehci functions.  We can't assume that there will only be one ehci per device.
The existing code could not deal with:

Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 0 not configured
Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 1 not configured
Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 2 not configured
Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 3 not configured
Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 4 not configured
Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 5 not configured
Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x10) at pci1 dev 0 function 6 not configured
Netmos MCS9990 Quad USB 2.0 Port (USB serial bus, interface 0x20) at pci1 dev 0 function 7 not configured

diffstat:

 sys/dev/pci/ehci_pci.c |  12 ++++++++----
 sys/dev/pci/usb_pci.h  |   3 ++-
 2 files changed, 10 insertions(+), 5 deletions(-)

diffs (55 lines):

diff -r 3a70da09ca01 -r 5caf3436a0e9 sys/dev/pci/ehci_pci.c
--- a/sys/dev/pci/ehci_pci.c    Sat Dec 11 17:46:58 2010 +0000
+++ b/sys/dev/pci/ehci_pci.c    Sat Dec 11 17:58:41 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ehci_pci.c,v 1.49 2010/05/25 08:37:10 pgoyette Exp $   */
+/*     $NetBSD: ehci_pci.c,v 1.50 2010/12/11 17:58:41 matt Exp $       */
 
 /*
  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ehci_pci.c,v 1.49 2010/05/25 08:37:10 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci_pci.c,v 1.50 2010/12/11 17:58:41 matt Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -231,13 +231,17 @@
         * Find companion controllers.  According to the spec they always
         * have lower function numbers so they should be enumerated already.
         */
+       const u_int maxncomp = EHCI_HCS_N_CC(EREAD4(&sc->sc, EHCI_HCSPARAMS));
+       KASSERT(maxncomp <= EHCI_COMPANION_MAX);
        ncomp = 0;
        TAILQ_FOREACH(up, &ehci_pci_alldevs, next) {
-               if (up->bus == pa->pa_bus && up->device == pa->pa_device) {
+               if (up->bus == pa->pa_bus && up->device == pa->pa_device
+                   && !up->claimed) {
                        DPRINTF(("ehci_pci_attach: companion %s\n",
                                 device_xname(up->usb)));
                        sc->sc.sc_comps[ncomp++] = up->usb;
-                       if (ncomp >= EHCI_COMPANION_MAX)
+                       up->claimed = true;
+                       if (ncomp == maxncomp)
                                break;
                }
        }
diff -r 3a70da09ca01 -r 5caf3436a0e9 sys/dev/pci/usb_pci.h
--- a/sys/dev/pci/usb_pci.h     Sat Dec 11 17:46:58 2010 +0000
+++ b/sys/dev/pci/usb_pci.h     Sat Dec 11 17:58:41 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usb_pci.h,v 1.5 2008/04/28 20:23:55 martin Exp $       */
+/*     $NetBSD: usb_pci.h,v 1.6 2010/12/11 17:58:41 matt Exp $ */
 
 /*
  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -41,6 +41,7 @@
        u_int           device;
        u_int           function;
        device_t        usb;
+       bool            claimed;
 };
 
 TAILQ_HEAD(usb_pci_alldevs, usb_pci);



Home | Main Index | Thread Index | Old Index