> Date: Fri, 21 Sep 2012 13:48:48 +0200
> From: Christian Ehrhardt <ehrha...@genua.de>
> 
> Hi,
> 
> thanks to Mark, we have enough PCI bus number accounting, now to allow us
> to attach ACPI bus numbers via ACPI. A patch to do this is below.
> 
>     regards   Christian

Hi Christian,

Any chance of having a diff with the amd64 bits as well?

Also:

> Index: arch/i386/i386/mainbus.c
> ===================================================================
> RCS file: /cvs/src/sys/arch/i386/i386/mainbus.c,v
> retrieving revision 1.49
> diff -u -r1.49 mainbus.c
> --- arch/i386/i386/mainbus.c  19 Sep 2012 23:03:12 -0000      1.49
> +++ arch/i386/i386/mainbus.c  21 Sep 2012 11:36:59 -0000
> @@ -245,6 +245,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: dev/acpi/acpi.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/acpi/acpi.c,v
> retrieving revision 1.239
> diff -u -r1.239 acpi.c
> --- dev/acpi/acpi.c   7 Sep 2012 19:19:59 -0000       1.239
> +++ dev/acpi/acpi.c   21 Sep 2012 11:37:01 -0000
> @@ -394,6 +394,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);
> @@ -482,6 +484,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;
> @@ -600,6 +603,25 @@
>       }
>  
>       return PCI_PMCSR_STATE_D3;
> +}
> +
> +void
> +acpi_pciroots_attach(struct device *dev, void *aux, cfprint_t pr)
> +{
> +     struct acpi_pci                 *pdev;
> +     struct pcibus_attach_args       *pba = aux;
> +
> +     if (pba->pba_busex == NULL) {
> +             printf("cannot attach ACPI discovered busses\n");
> +             return;
> +     }

Instead of doing a printf here, I think you should just do a

    KASSERT(pba->pba_busex != NULL);

here.  If somebody changes the code such that they call
acpi_pciroots_attach() without having initialized the busex they
deserve to get a panic!

Reply via email to