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

Configure Feed

Select the types of activity you want to include in your feed.

drm/xe/vram: Use PCI rebar helpers in resize_vram_bar()

PCI core provides pci_rebar_size_supported() and pci_rebar_size_to_bytes();
use them in resize_vram_bar() to simplify code.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Christian König <christian.koenig@amd.com>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patch.msgid.link/20251113180053.27944-8-ilpo.jarvinen@linux.intel.com

authored by

Ilpo Järvinen and committed by
Bjorn Helgaas
2987a64d c59038d3

+7 -12
+7 -12
drivers/gpu/drm/xe/xe_vram.c
··· 24 24 #include "xe_vram.h" 25 25 #include "xe_vram_types.h" 26 26 27 - #define BAR_SIZE_SHIFT 20 28 - 29 27 static void 30 28 _resize_bar(struct xe_device *xe, int resno, resource_size_t size) 31 29 { ··· 69 71 70 72 /* set to a specific size? */ 71 73 if (force_vram_bar_size) { 72 - u32 bar_size_bit; 74 + rebar_size = pci_rebar_bytes_to_size(force_vram_bar_size * 75 + (resource_size_t)SZ_1M); 73 76 74 - rebar_size = force_vram_bar_size * (resource_size_t)SZ_1M; 75 - 76 - bar_size_bit = bar_size_mask & BIT(pci_rebar_bytes_to_size(rebar_size)); 77 - 78 - if (!bar_size_bit) { 77 + if (!pci_rebar_size_supported(pdev, LMEM_BAR, rebar_size)) { 79 78 drm_info(&xe->drm, 80 79 "Requested size: %lluMiB is not supported by rebar sizes: 0x%x. Leaving default: %lluMiB\n", 81 - (u64)rebar_size >> 20, bar_size_mask, (u64)current_size >> 20); 80 + (u64)pci_rebar_size_to_bytes(rebar_size) >> 20, 81 + bar_size_mask, (u64)current_size >> 20); 82 82 return; 83 83 } 84 84 85 - rebar_size = 1ULL << (__fls(bar_size_bit) + BAR_SIZE_SHIFT); 86 - 85 + rebar_size = pci_rebar_size_to_bytes(rebar_size); 87 86 if (rebar_size == current_size) 88 87 return; 89 88 } else { 90 - rebar_size = 1ULL << (__fls(bar_size_mask) + BAR_SIZE_SHIFT); 89 + rebar_size = pci_rebar_size_to_bytes(__fls(bar_size_mask)); 91 90 92 91 /* only resize if larger than current */ 93 92 if (rebar_size <= current_size)