Re: [PATCH v2] PCI: Add DMA alias quirk for PLX PEX NTB

From: Christoph Hellwig
Date: Tue Nov 26 2019 - 12:38:36 EST


> +int _pci_add_dma_alias_range(struct pci_dev *dev, u8 devfn_from, int len)

This should be mrked static. Also single underscore prefixes are rather
unusual in Linux. Either use two or use a more descriptive name.


> @@ -5875,18 +5887,21 @@ int pci_set_vga_state(struct pci_dev *dev, bool decode,
> */
> void pci_add_dma_alias(struct pci_dev *dev, u8 devfn)
> {
> - if (!dev->dma_alias_mask)
> - dev->dma_alias_mask = bitmap_zalloc(U8_MAX, GFP_KERNEL);
> - if (!dev->dma_alias_mask) {
> - pci_warn(dev, "Unable to allocate DMA alias mask\n");
> + if (_pci_add_dma_alias_range(dev, devfn, 1) != 0)
> return;
> - }
> -
> - set_bit(devfn, dev->dma_alias_mask);
> pci_info(dev, "Enabling fixed DMA alias to %02x.%d\n",
> PCI_SLOT(devfn), PCI_FUNC(devfn));
> }
>
> +void pci_add_dma_alias_range(struct pci_dev *dev, u8 devfn_from, int len)
> +{
> + int devfn_to = devfn_from + len - 1;
> + if (_pci_add_dma_alias_range(dev, devfn_from, len) != 0)
> + return;
> + pci_info(dev, "Enabling fixed DMA alias for devfn range from %02x.%d to %02x.%d\n",
> + PCI_SLOT(devfn_from), PCI_FUNC(devfn_from), PCI_SLOT(devfn_to), PCI_FUNC(devfn_to));
> +}

This adds a non-string constant line over 80 chars that should be fixed
up.

But can't you just add the len argument (which really should be
nr_devfns or so) to pci_add_dma_alias and switch the 8 existing
callers over?