Module Name:    src
Committed By:   martin
Date:           Wed Apr 11 14:53:51 UTC 2018

Modified Files:
        src/sys/arch/x86/pci [netbsd-8]: pci_machdep.c

Log Message:
Pull up following revision(s) (requested by nonaka in ticket #740):

        sys/arch/x86/pci/pci_machdep.c: revision 1.80

efiboot reports parent ppb bus/device/function of booted network inteface.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.79.2.1 src/sys/arch/x86/pci/pci_machdep.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/arch/x86/pci/pci_machdep.c
diff -u src/sys/arch/x86/pci/pci_machdep.c:1.79 src/sys/arch/x86/pci/pci_machdep.c:1.79.2.1
--- src/sys/arch/x86/pci/pci_machdep.c:1.79	Thu Jun  1 02:45:08 2017
+++ src/sys/arch/x86/pci/pci_machdep.c	Wed Apr 11 14:53:50 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_machdep.c,v 1.79 2017/06/01 02:45:08 chs Exp $	*/
+/*	$NetBSD: pci_machdep.c,v 1.79.2.1 2018/04/11 14:53:50 martin Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.79 2017/06/01 02:45:08 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.79.2.1 2018/04/11 14:53:50 martin Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -98,6 +98,7 @@ __KERNEL_RCSID(0, "$NetBSD: pci_machdep.
 #include <dev/pci/pcireg.h>
 #include <dev/pci/pccbbreg.h>
 #include <dev/pci/pcidevs.h>
+#include <dev/pci/ppbvar.h>
 #include <dev/pci/genfb_pcivar.h>
 
 #include <dev/wsfb/genfbvar.h>
@@ -149,6 +150,10 @@ __KERNEL_RCSID(0, "$NetBSD: pci_machdep.
 #include <dev/pci/puccn.h>
 #endif
 
+#ifndef XEN
+#include <x86/efi.h>
+#endif
+
 #include "opt_pci_conf_mode.h"
 
 #ifdef PCI_CONF_MODE
@@ -1016,6 +1021,7 @@ device_t
 device_pci_register(device_t dev, void *aux)
 {
 	static bool found_console = false;
+	device_t parent = device_parent(dev);
 
 	device_pci_props_register(dev, aux);
 
@@ -1037,8 +1043,7 @@ device_pci_register(device_t dev, void *
 		 * information (checked below) must be sufficient to
 		 * identify the device.
 		 */
-		if (bin->bus == BI_BUS_PCI &&
-		    device_is_a(device_parent(dev), "pci")) {
+		if (bin->bus == BI_BUS_PCI && device_is_a(parent, "pci")) {
 			struct pci_attach_args *paa = aux;
 			int b, d, f;
 
@@ -1052,9 +1057,23 @@ device_pci_register(device_t dev, void *
 			pci_decompose_tag(paa->pa_pc, paa->pa_tag, &b, &d, &f);
 			if (bin->addr.tag == ((b << 8) | (d << 3) | f))
 				return dev;
+
+#ifndef XEN
+			/*
+			 * efiboot reports parent ppb bus/device/function.
+			 */
+			device_t grand = device_parent(parent);
+			if (efi_probe() && grand && device_is_a(grand, "ppb")) {
+				struct ppb_softc *ppb_sc = device_private(grand);
+				pci_decompose_tag(ppb_sc->sc_pc, ppb_sc->sc_tag,
+				    &b, &d, &f);
+				if (bin->addr.tag == ((b << 8) | (d << 3) | f))
+					return dev;
+			}
+#endif
 		}
 	}
-	if (device_parent(dev) && device_is_a(device_parent(dev), "pci") &&
+	if (parent && device_is_a(parent, "pci") &&
 	    found_console == false) {
 		struct btinfo_framebuffer *fbinfo;
 		struct pci_attach_args *pa = aux;

Reply via email to