Sat Sep 22 14:27:24 2012 UTC ()
Fix PR kern/46828 (6.0_BETA2 and 6.0_RC1 won't start on DL320/G5p):
 In ehci_get_ownership(), don't explicitly clear EHCI_LEG_HC_BIOS_OWNED
 semaphore bit in the driver before asking BIOS to give up ownership.
 The EHCI spec implies that the semaphore should not be changed by
 the other agent and actually the previous one (introduced in rev 1.53
 after 5.x) caused hangup during probe on at least two HP machines
 as mentioned in the PR.  Analyzed and patch provided by Ryo ONODERA.

Should be pulled up to netbsd-6 (fatal hangup during boot).


(tsutsui)
diff -r1.56 -r1.57 src/sys/dev/pci/ehci_pci.c

cvs diff -r1.56 -r1.57 src/sys/dev/pci/ehci_pci.c (expand / switch to unified diff)

--- src/sys/dev/pci/ehci_pci.c 2012/07/20 01:26:19 1.56
+++ src/sys/dev/pci/ehci_pci.c 2012/09/22 14:27:24 1.57
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ehci_pci.c,v 1.56 2012/07/20 01:26:19 uwe Exp $ */ 1/* $NetBSD: ehci_pci.c,v 1.57 2012/09/22 14:27:24 tsutsui Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc. 4 * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Lennart Augustsson (lennart@augustsson.net). 8 * by Lennart Augustsson (lennart@augustsson.net).
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -20,27 +20,27 @@ @@ -20,27 +20,27 @@
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33__KERNEL_RCSID(0, "$NetBSD: ehci_pci.c,v 1.56 2012/07/20 01:26:19 uwe Exp $"); 33__KERNEL_RCSID(0, "$NetBSD: ehci_pci.c,v 1.57 2012/09/22 14:27:24 tsutsui Exp $");
34 34
35#include <sys/param.h> 35#include <sys/param.h>
36#include <sys/systm.h> 36#include <sys/systm.h>
37#include <sys/kernel.h> 37#include <sys/kernel.h>
38#include <sys/device.h> 38#include <sys/device.h>
39#include <sys/proc.h> 39#include <sys/proc.h>
40#include <sys/queue.h> 40#include <sys/queue.h>
41 41
42#include <sys/bus.h> 42#include <sys/bus.h>
43 43
44#include <dev/pci/pcidevs.h> 44#include <dev/pci/pcidevs.h>
45#include <dev/pci/pcivar.h> 45#include <dev/pci/pcivar.h>
46#include <dev/pci/usb_pci.h> 46#include <dev/pci/usb_pci.h>
@@ -385,30 +385,28 @@ ehci_get_ownership(ehci_softc_t *sc, pci @@ -385,30 +385,28 @@ ehci_get_ownership(ehci_softc_t *sc, pci
385#ifdef EHCI_DEBUG 385#ifdef EHCI_DEBUG
386 if (ehcidebug) 386 if (ehcidebug)
387 ehci_dump_caps(sc, pc, tag); 387 ehci_dump_caps(sc, pc, tag);
388#endif 388#endif
389 cparams = EREAD4(sc, EHCI_HCCPARAMS); 389 cparams = EREAD4(sc, EHCI_HCCPARAMS);
390 addr = EHCI_HCC_EECP(cparams); 390 addr = EHCI_HCC_EECP(cparams);
391 while (addr != 0) { 391 while (addr != 0) {
392 cap = pci_conf_read(pc, tag, addr); 392 cap = pci_conf_read(pc, tag, addr);
393 if (EHCI_CAP_GET_ID(cap) != EHCI_CAP_ID_LEGACY) 393 if (EHCI_CAP_GET_ID(cap) != EHCI_CAP_ID_LEGACY)
394 goto next; 394 goto next;
395 legsup = pci_conf_read(pc, tag, addr + PCI_EHCI_USBLEGSUP); 395 legsup = pci_conf_read(pc, tag, addr + PCI_EHCI_USBLEGSUP);
396 if (legsup & EHCI_LEG_HC_BIOS_OWNED) { 396 if (legsup & EHCI_LEG_HC_BIOS_OWNED) {
397 /* Ask BIOS to give up ownership */ 397 /* Ask BIOS to give up ownership */
398 legsup &= ~EHCI_LEG_HC_BIOS_OWNED; 
399 legsup |= EHCI_LEG_HC_OS_OWNED; 
400 pci_conf_write(pc, tag, addr + PCI_EHCI_USBLEGSUP, 398 pci_conf_write(pc, tag, addr + PCI_EHCI_USBLEGSUP,
401 legsup); 399 legsup | EHCI_LEG_HC_OS_OWNED);
402 for (ms = 0; ms < EHCI_MAX_BIOS_WAIT; ms++) { 400 for (ms = 0; ms < EHCI_MAX_BIOS_WAIT; ms++) {
403 legsup = pci_conf_read(pc, tag, 401 legsup = pci_conf_read(pc, tag,
404 addr + PCI_EHCI_USBLEGSUP); 402 addr + PCI_EHCI_USBLEGSUP);
405 if (!(legsup & EHCI_LEG_HC_BIOS_OWNED)) 403 if (!(legsup & EHCI_LEG_HC_BIOS_OWNED))
406 break; 404 break;
407 delay(10000); 405 delay(10000);
408 } 406 }
409 if (ms == EHCI_MAX_BIOS_WAIT) { 407 if (ms == EHCI_MAX_BIOS_WAIT) {
410 aprint_normal("%s: BIOS refuses to give up " 408 aprint_normal("%s: BIOS refuses to give up "
411 "ownership, using force\n", devname); 409 "ownership, using force\n", devname);
412 pci_conf_write(pc, tag, 410 pci_conf_write(pc, tag,
413 addr + PCI_EHCI_USBLEGSUP, 0); 411 addr + PCI_EHCI_USBLEGSUP, 0);
414 } else 412 } else