Skip to content

Commit 46ba95b

Browse files
ij-intelbjorn-helgaas
authored andcommitted
drm/xe/vram: Use pci_rebar_get_max_size()
Use pci_rebar_get_max_size() from PCI core 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-10-ilpo.jarvinen@linux.intel.com
1 parent 1c680f2 commit 46ba95b

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

drivers/gpu/drm/xe/xe_vram.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,11 @@ static void resize_vram_bar(struct xe_device *xe)
5353
resource_size_t current_size;
5454
resource_size_t rebar_size;
5555
struct resource *root_res;
56-
u32 bar_size_mask;
56+
int max_size, i;
5757
u32 pci_cmd;
58-
int i;
5958

6059
/* gather some relevant info */
6160
current_size = pci_resource_len(pdev, LMEM_BAR);
62-
bar_size_mask = pci_rebar_get_possible_sizes(pdev, LMEM_BAR);
63-
64-
if (!bar_size_mask)
65-
return;
6661

6762
if (force_vram_bar_size < 0)
6863
return;
@@ -76,15 +71,19 @@ static void resize_vram_bar(struct xe_device *xe)
7671
drm_info(&xe->drm,
7772
"Requested size: %lluMiB is not supported by rebar sizes: 0x%x. Leaving default: %lluMiB\n",
7873
(u64)pci_rebar_size_to_bytes(rebar_size) >> 20,
79-
bar_size_mask, (u64)current_size >> 20);
74+
pci_rebar_get_possible_sizes(pdev, LMEM_BAR),
75+
(u64)current_size >> 20);
8076
return;
8177
}
8278

8379
rebar_size = pci_rebar_size_to_bytes(rebar_size);
8480
if (rebar_size == current_size)
8581
return;
8682
} else {
87-
rebar_size = pci_rebar_size_to_bytes(__fls(bar_size_mask));
83+
max_size = pci_rebar_get_max_size(pdev, LMEM_BAR);
84+
if (max_size < 0)
85+
return;
86+
rebar_size = pci_rebar_size_to_bytes(max_size);
8887

8988
/* only resize if larger than current */
9089
if (rebar_size <= current_size)

0 commit comments

Comments
 (0)