Hi,
On Mon, Sep 10, 2012 at 01:22:35PM +0200, Christian Ehrhardt wrote:
> > Yup. Since we have code to detect additional host bridges some of
> > them may already have been attached. And it would be a good way to
> > defend against ACPI lying to us. However, please keep the ACPI hooks
> > out of the MI PCI code. It'd be better if you used pci_attach_hook(),
> > which lives in arch/pci/pci_machdep.c.
>
> Ok, will do that.
Updated version of the patch is below. regards Christian
Index: arch/i386/i386/mainbus.c
===================================================================
RCS file: /cvs/src/sys/arch/i386/i386/mainbus.c,v
retrieving revision 1.48
diff -u -r1.48 mainbus.c
--- arch/i386/i386/mainbus.c 3 Nov 2010 10:15:23 -0000 1.48
+++ arch/i386/i386/mainbus.c 12 Sep 2012 13:39:19 -0000
@@ -244,6 +244,9 @@
mba.mba_pba.pba_domain = pci_ndomains++;
mba.mba_pba.pba_bus = 0;
config_found(self, &mba.mba_pba, mainbus_print);
+#if NACPI > 0
+ acpi_pciroots_attach(self, &mba.mba_pba, mainbus_print);
+#endif
}
#endif
Index: arch/i386/pci/pci_machdep.c
===================================================================
RCS file: /cvs/src/sys/arch/i386/pci/pci_machdep.c,v
retrieving revision 1.68
diff -u -r1.68 pci_machdep.c
--- arch/i386/pci/pci_machdep.c 4 Dec 2011 20:08:09 -0000 1.68
+++ arch/i386/pci/pci_machdep.c 12 Sep 2012 13:39:19 -0000
@@ -208,6 +208,9 @@
printf(": configuration mode %d", pci_mode);
#endif
+#if NACPI > 0
+ acpi_pciroot_match(self, pba->pba_bus);
+#endif
if (pba->pba_bus != 0)
return;
Index: dev/acpi/acpi.c
===================================================================
RCS file: /cvs/src/sys/dev/acpi/acpi.c,v
retrieving revision 1.238
diff -u -r1.238 acpi.c
--- dev/acpi/acpi.c 13 Jul 2012 11:51:41 -0000 1.238
+++ dev/acpi/acpi.c 12 Sep 2012 13:39:20 -0000
@@ -392,6 +392,8 @@
TAILQ_HEAD(, acpi_pci) acpi_pcidevs =
TAILQ_HEAD_INITIALIZER(acpi_pcidevs);
+TAILQ_HEAD(, acpi_pci) acpi_pcirootdevs =
+ TAILQ_HEAD_INITIALIZER(acpi_pcirootdevs);
int acpi_getpci(struct aml_node *node, void *arg);
int acpi_getminbus(union acpi_resource *crs, void *arg);
@@ -480,6 +482,7 @@
node->pci = pci;
dnprintf(10, "found PCI root: %s %d\n",
aml_nodename(node), pci->bus);
+ TAILQ_INSERT_TAIL(&acpi_pcirootdevs, pci, next);
}
aml_freevalue(&res);
return 0;
@@ -548,6 +551,31 @@
dev->dv_xname, aml_nodename(pdev->node));
pdev->device = dev;
}
+ }
+}
+
+void
+acpi_pciroot_match(struct device *dev, int bus)
+{
+ struct acpi_pci *pdev;
+
+ TAILQ_FOREACH(pdev, &acpi_pcirootdevs, next) {
+ if (pdev->bus == bus)
+ pdev->device = dev;
+ }
+}
+
+void
+acpi_pciroots_attach(struct device *dev, void *aux, cfprint_t pr)
+{
+ struct acpi_pci *pdev;
+ struct pcibus_attach_args *pba = aux;
+
+ TAILQ_FOREACH(pdev, &acpi_pcirootdevs, next) {
+ if (pdev->device) /* Already attached */
+ continue;
+ pba->pba_bus = pdev->bus;
+ config_found(dev, pba, pr);
}
}
Index: dev/acpi/acpivar.h
===================================================================
RCS file: /cvs/src/sys/dev/acpi/acpivar.h,v
retrieving revision 1.71
diff -u -r1.71 acpivar.h
--- dev/acpi/acpivar.h 15 Apr 2011 17:34:51 -0000 1.71
+++ dev/acpi/acpivar.h 12 Sep 2012 13:39:20 -0000
@@ -322,6 +322,9 @@
void acpi_powerdown_task(void *, int);
void acpi_sleep_task(void *, int);
+void acpi_pciroot_match(struct device *, int);
+void acpi_pciroots_attach(struct device *, void *, cfprint_t);
+
#endif
#endif /* !_ACPI_WAKECODE */