Module Name:    src
Committed By:   macallan
Date:           Thu Apr  5 04:04:05 UTC 2012

Modified Files:
        src/sys/dev/pci: ohci_pci.c

Log Message:
abort attach if memory access is not enabled
this avoids a panic later on when trying to attach to an unconfigured ohci
found for example in later iBooks when DIAGNOSTIC is set


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/dev/pci/ohci_pci.c

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/ohci_pci.c
diff -u src/sys/dev/pci/ohci_pci.c:1.48 src/sys/dev/pci/ohci_pci.c:1.49
--- src/sys/dev/pci/ohci_pci.c:1.48	Mon Jan 30 19:41:22 2012
+++ src/sys/dev/pci/ohci_pci.c	Thu Apr  5 04:04:05 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ohci_pci.c,v 1.48 2012/01/30 19:41:22 drochner Exp $	*/
+/*	$NetBSD: ohci_pci.c,v 1.49 2012/04/05 04:04:05 macallan Exp $	*/
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ohci_pci.c,v 1.48 2012/01/30 19:41:22 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci_pci.c,v 1.49 2012/04/05 04:04:05 macallan Exp $");
 
 #include "ehci.h"
 
@@ -96,6 +96,16 @@ ohci_pci_attach(device_t parent, device_
 
 	pci_aprint_devinfo(pa, "USB Controller");
 
+	/* check if memory space access is enabled */
+	csr = pci_conf_read(pc, tag, PCI_COMMAND_STATUS_REG);
+#ifdef DEBUG
+	printf("csr: %08x\n", csr);
+#endif
+	if ((csr & PCI_COMMAND_MEM_ENABLE) == 0) {
+		aprint_error_dev(self, "memory access is disabled\n");
+		return;
+	}
+
 	/* Map I/O registers */
 	if (pci_mapreg_map(pa, PCI_CBMEM, PCI_MAPREG_TYPE_MEM, 0,
 			   &sc->sc.iot, &sc->sc.ioh, NULL, &sc->sc.sc_size)) {
@@ -113,7 +123,6 @@ ohci_pci_attach(device_t parent, device_
 	sc->sc.sc_bus.dmatag = pa->pa_dmat;
 
 	/* Enable the device. */
-	csr = pci_conf_read(pc, tag, PCI_COMMAND_STATUS_REG);
 	pci_conf_write(pc, tag, PCI_COMMAND_STATUS_REG,
 		       csr | PCI_COMMAND_MASTER_ENABLE);
 

Reply via email to