Re: [PATCH 6/7] MIPS: SGI-IP27: use generic PCI driver

From: Christoph Hellwig
Date: Mon Jan 28 2019 - 08:32:21 EST


On Thu, Jan 24, 2019 at 06:47:27PM +0100, Thomas Bogendoerfer wrote:
> Converted bridge code to a platform driver using the PCI generic driver
> framework and use adding platform devices during xtalk scan. This allows
> easier sharing bridge drvier for other SGI platforms like IP30 (Octane) and

Typo: s/drvier/driver/.

In theory this would also have allowed sharing the code with ia64/SN,
except that instead of porting the old mess to Linux 2.6 and cleaning it
up SGI moved the support into the firmware hidden behind PAL calls :(

> +#ifdef CONFIG_NUMA
> +int pcibus_to_node(struct pci_bus *bus)
> +{
> + struct bridge_controller *bc = BRIDGE_CONTROLLER(bus);
> +
> + return bc->nasid;
> +}
> +EXPORT_SYMBOL(pcibus_to_node);
> +#endif /* CONFIG_NUMA */

>From an abstraction point of view this doesn't really belong into
a bridge driver as it is a global exported function. I guess we can
keep it here with a fixme comment, but we should probably move this
into a method call instead.

> +dma_addr_t __phys_to_dma(struct device *dev, phys_addr_t paddr)
> +{
> + struct pci_dev *pdev = to_pci_dev(dev);
> + struct bridge_controller *bc = BRIDGE_CONTROLLER(pdev->bus);
> +
> + return bc->baddr + paddr;
> +}
> +
> +phys_addr_t __dma_to_phys(struct device *dev, dma_addr_t dma_addr)
> +{
> + return dma_addr & ~(0xffUL << 56);
> +}

Similarly here - these are global platform-wide hooks, so having them
in a pci bridge driver is not the proper abstraction level.

Note that we could probably fix these by just switching IP27 and
other users of the bridge chip to use the dma_pfn_offset field
in struct device and stop overriding these functions.