# Re: \[PATCH V2 18/22\] LoongArch: Add PCI controller support

- From: Arnd Bergmann \<arnd@arndb.de\>
- Date: 2021-09-09 14:39:08 
- List: linux-arch
- Page: https://ratatoskr.run/linux-arch/2021/09/8526810
- Thread: https://ratatoskr.run/linux-arch/2021/09/8526764/t.md

```text
On Thu, Sep 9, 2021 at 4:10 PM Rob Herring [ref] wrote:
> On Wed, Sep 8, 2021 at 11:39 AM Arnd Bergmann [ref] wrote:
> >
> > > It might be time for default implementations here that can be shared
> > > with arm64. The functions look the same or similar to the arm64
> > > version in many cases and why they are different isn't that clear to me
> > > not being all that familar with the ACPI code.
> >
> > I think it can be simplified quite a bit if we restructure the acpi pci
> > code to behave like a normal pci host bridge driver.
>
> That is exactly what I want to see happen! I'm not that familiar with
> the ACPI device probing piece of it or I probably would have done that
> by now. I gather there's not a normal acpi_device (or platform_device
> with ACPI matching?) so we'd have to create the device(s) based on the
> MCFG table.

I have a patch that I did as part of a longer series to modernize
some of the more unusual pci host bridges, it's only a small step
but should help follow up for the rest:

https://git.kernel.org/pub/scm/linux/kernel/git/arnd/playground.git/commit/?h=pci-probe-rework-20210320&id=7346fbf1938e547833726ebdf25dfe0ef185cbff

What I noticed is that there are a couple of data structures that each
exist for every acpi host bridge:

struct acpi_pci_root
struct acpi_pci_root_ops
struct acpi_pci_root_info
struct acpi_pci_generic_root_info
struct pci_sysdata (arch specific, but includes data used by acpi)
struct pci_host_bridge

I think we can pretty much move all the struct members from those
into the generic pci_host_bridge, removing the duplicates and
adding #ifdef CONFIG_ACPI for some of them.

Similarly, for the global functions from arch/arm64/kernel/pci.c etc,
I think they should mostly get turned into callback handlers that
get set by the probe function, replacing the __weak defaults.

       Arnd
```
