[PATCH 5/8] pci: allow for overriding the list of advertised BAR sizes
Darren Salt
devspam at moreofthesa.me.uk
Tue Dec 15 01:08:59 UTC 2020
This is intended for devices which are known to work with BAR sizes other
than those which they advertise; usually larger.
---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +-
drivers/pci/setup-res.c | 4 ++--
include/linux/pci.h | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index fde5aaf97dc6..125aca52e25d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1188,7 +1188,7 @@ int amdgpu_device_resize_fb_bar(struct amdgpu_device *adev)
pci_release_resource(adev->pdev, 0);
- r = pci_resize_resource(adev->pdev, 0, rbar_size);
+ r = pci_resize_resource(adev->pdev, 0, rbar_size, false);
if (r == -ENOTSUPP) {
dev_info(adev->dev, "BAR resizing not supported.");
} else if (r == -ENOSPC) {
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
index 43eda101fcf4..3651754de433 100644
--- a/drivers/pci/setup-res.c
+++ b/drivers/pci/setup-res.c
@@ -407,7 +407,7 @@ void pci_release_resource(struct pci_dev *dev, int resno)
}
EXPORT_SYMBOL(pci_release_resource);
-int pci_resize_resource(struct pci_dev *dev, int resno, int size)
+int pci_resize_resource(struct pci_dev *dev, int resno, int size, bool forced)
{
struct resource *res = dev->resource + resno;
int old, ret;
@@ -426,7 +426,7 @@ int pci_resize_resource(struct pci_dev *dev, int resno, int size)
if (!sizes)
return -ENOTSUPP;
- if (!(sizes & BIT(size)))
+ if (!forced && !(sizes & BIT(size)))
return -EINVAL;
old = pci_rebar_get_current_size(dev, resno);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 41e93ea9756b..badad6df4e16 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1236,7 +1236,7 @@ static __always_inline u64 pci_rebar_size_to_bytes(int size)
return 1ULL << (size + 20);
}
u32 pci_rebar_get_possible_sizes(struct pci_dev *pdev, int bar);
-int __must_check pci_resize_resource(struct pci_dev *dev, int i, int size);
+int __must_check pci_resize_resource(struct pci_dev *dev, int i, int size, bool forced);
int pci_select_bars(struct pci_dev *dev, unsigned long flags);
bool pci_device_is_present(struct pci_dev *pdev);
void pci_ignore_hotplug(struct pci_dev *dev);
--
2.20.1
More information about the amd-gfx
mailing list