Module Name:    src
Committed By:   matt
Date:           Sat Dec 11 17:58:41 UTC 2010

Modified Files:
        src/sys/dev/pci: ehci_pci.c usb_pci.h

Log Message:
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


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/dev/pci/ehci_pci.c
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/pci/usb_pci.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/pci/ehci_pci.c
diff -u src/sys/dev/pci/ehci_pci.c:1.49 src/sys/dev/pci/ehci_pci.c:1.50
--- src/sys/dev/pci/ehci_pci.c:1.49	Tue May 25 08:37:10 2010
+++ src/sys/dev/pci/ehci_pci.c	Sat Dec 11 17:58:41 2010
@@ -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;
 		}
 	}

Index: src/sys/dev/pci/usb_pci.h
diff -u src/sys/dev/pci/usb_pci.h:1.5 src/sys/dev/pci/usb_pci.h:1.6
--- src/sys/dev/pci/usb_pci.h:1.5	Mon Apr 28 20:23:55 2008
+++ src/sys/dev/pci/usb_pci.h	Sat Dec 11 17:58:41 2010
@@ -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);

Reply via email to