[PATCH RFC v4 09/21] PCI: Mark immovable BARs with PCI_FIXED

Bjorn Helgaas helgaas at kernel.org
Wed Mar 27 07:28:38 AEDT 2019


On Mon, Mar 11, 2019 at 04:31:10PM +0300, Sergey Miroshnichenko wrote:
> If a PCIe device driver doesn't yet have support for movable BARs,
> mark device's BARs with IORESOURCE_PCI_FIXED.

I'm hesitant about using IORESOURCE_PCI_FIXED for this purpose.  That
was originally added to describe resources that can not be changed
because they're hardwired in the device, e.g., legacy resources and
Enhanced Allocation resources.

In general, I think the bits in res->flags should tell us things about
the hardware.  This particular use would be something about the
*driver*, and I think we should figure that out by looking at
dev->driver.

> Signed-off-by: Sergey Miroshnichenko <s.miroshnichenko at yadro.com>
> ---
>  drivers/pci/probe.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index dc935f82a595..1cf6ec960236 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -3262,6 +3262,21 @@ static void pci_bus_rescan_prepare(struct pci_bus *bus)
>  		} else if (dev->driver &&
>  			   dev->driver->rescan_prepare) {
>  			dev->driver->rescan_prepare(dev);
> +		} else if (dev->driver || ((dev->class >> 8) == PCI_CLASS_DISPLAY_VGA)) {
> +			int i;
> +
> +			for (i = 0; i < PCI_NUM_RESOURCES; i++) {
> +				struct resource *r = &dev->resource[i];
> +
> +				if (!r->flags || !r->parent ||
> +				    (r->flags & IORESOURCE_UNSET) ||
> +				    (r->flags & IORESOURCE_PCI_FIXED))
> +					continue;
> +
> +				r->flags |= IORESOURCE_PCI_FIXED;
> +				pci_warn(dev, "%s: no support for movable BARs, mark BAR %d (%pR) as fixed\n",
> +					 __func__, i, r);
> +			}
>  		}
>  	}
>  }
> -- 
> 2.20.1
> 


More information about the Linuxppc-dev mailing list