[PATCH 5/8] pci: allow for overriding the list of advertised BAR sizes
Darren Salt
devspam at moreofthesa.me.uk
Sun Dec 13 22:53:20 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 c6495a86b280..ce3b8f8fea0c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -995,7 +995,7 @@ int amdgpu_device_resize_fb_bar(struct amdgpu_device *adev)
rbar_size >= 0;
rbar_size = fls(available_sizes & ~(-1 << rbar_size)) - 1
) {
- r = pci_resize_resource(adev->pdev, 0, rbar_size);
+ r = pci_resize_resource(adev->pdev, 0, rbar_size, false);
if (r == 0) {
break;
} else if (r == -ENOTSUPP) {
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 dca2778c1738..c7d687370562 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1234,7 +1234,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