aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNirmoy Das <nirmoy.das@amd.com>2021-01-07 15:15:10 +0100
committerChristian König <christian.koenig@amd.com>2021-01-14 21:20:53 +0100
commit453f617a30aa1298fe19728026e9d24098fdae03 (patch)
tree45fbf0285a0f459ca426e38707d48e5c76ccda46
parentPCI: Add a REBAR size quirk for Sapphire RX 5600 XT Pulse (diff)
downloadlinux-dev-453f617a30aa1298fe19728026e9d24098fdae03.tar.xz
linux-dev-453f617a30aa1298fe19728026e9d24098fdae03.zip
drm/amdgpu: Resize BAR0 to the maximum available size, even if it doesn't cover VRAM
This allows BAR0 resizing to be done for cards which don't advertise support for a size large enough to cover the VRAM but which do advertise at least one size larger than the default. For example, my RX 5600 XT, which advertises 256MB, 512MB and 1GB. Signed-off-by: Darren Salt <devspam@moreofthesa.me.uk> Signed-off-by: Christian König <christian.koenig@amd.com> Signed-off-by: Nirmoy Das <nirmoy.das@amd.com> Reviewed-by: Nirmoy Das <nirmoy.das@amd.com> Link: https://patchwork.kernel.org/project/dri-devel/patch/20210107175017.15893-4-nirmoy.das@amd.com
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_device.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 8f451e809127..348ac678a230 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1107,7 +1107,7 @@ void amdgpu_device_wb_free(struct amdgpu_device *adev, u32 wb)
int amdgpu_device_resize_fb_bar(struct amdgpu_device *adev)
{
u64 space_needed = roundup_pow_of_two(adev->gmc.real_vram_size);
- u32 rbar_size = order_base_2(((space_needed >> 20) | 1)) - 1;
+ int rbar_size = pci_rebar_bytes_to_size(adev->gmc.real_vram_size);
struct pci_bus *root;
struct resource *res;
unsigned i;
@@ -1138,6 +1138,10 @@ int amdgpu_device_resize_fb_bar(struct amdgpu_device *adev)
if (!res)
return 0;
+ /* Limit the BAR size to what is available */
+ rbar_size = min(fls(pci_rebar_get_possible_sizes(adev->pdev, 0)) - 1,
+ rbar_size);
+
/* Disable memory decoding while we change the BAR addresses and size */
pci_read_config_word(adev->pdev, PCI_COMMAND, &cmd);
pci_write_config_word(adev->pdev, PCI_COMMAND,