Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

authored by

Nirmoy Das and committed by
Christian König
453f617a 907830b0

+5 -1
+5 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
··· 1107 1107 int amdgpu_device_resize_fb_bar(struct amdgpu_device *adev) 1108 1108 { 1109 1109 u64 space_needed = roundup_pow_of_two(adev->gmc.real_vram_size); 1110 - u32 rbar_size = order_base_2(((space_needed >> 20) | 1)) - 1; 1110 + int rbar_size = pci_rebar_bytes_to_size(adev->gmc.real_vram_size); 1111 1111 struct pci_bus *root; 1112 1112 struct resource *res; 1113 1113 unsigned i; ··· 1137 1137 /* Trying to resize is pointless without a root hub window above 4GB */ 1138 1138 if (!res) 1139 1139 return 0; 1140 + 1141 + /* Limit the BAR size to what is available */ 1142 + rbar_size = min(fls(pci_rebar_get_possible_sizes(adev->pdev, 0)) - 1, 1143 + rbar_size); 1140 1144 1141 1145 /* Disable memory decoding while we change the BAR addresses and size */ 1142 1146 pci_read_config_word(adev->pdev, PCI_COMMAND, &cmd);