Commit 433002ca authored by Michael J. Ruhl's avatar Michael J. Ruhl Committed by Rodrigo Vivi

drm/xe: REBAR resize should be best effort

The resizing of the PCI BAR is a best effort feature.  If it is
not available, it should not fail the driver probe.

Rework the resize to not exit on failure.

Fixes: 7f075300 ("drm/xe: Simplify rebar sizing")
Acked-by: default avatarLucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: default avatarMatthew Auld <matthew.auld@intel.com>
Signed-off-by: default avatarMichael J. Ruhl <michael.j.ruhl@intel.com>
Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
parent 1fce9a6f
...@@ -47,7 +47,7 @@ static int xe_set_dma_info(struct xe_device *xe) ...@@ -47,7 +47,7 @@ static int xe_set_dma_info(struct xe_device *xe)
return err; return err;
} }
static int static void
_resize_bar(struct xe_device *xe, int resno, resource_size_t size) _resize_bar(struct xe_device *xe, int resno, resource_size_t size)
{ {
struct pci_dev *pdev = to_pci_dev(xe->drm.dev); struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
...@@ -61,18 +61,17 @@ _resize_bar(struct xe_device *xe, int resno, resource_size_t size) ...@@ -61,18 +61,17 @@ _resize_bar(struct xe_device *xe, int resno, resource_size_t size)
if (ret) { if (ret) {
drm_info(&xe->drm, "Failed to resize BAR%d to %dM (%pe). Consider enabling 'Resizable BAR' support in your BIOS\n", drm_info(&xe->drm, "Failed to resize BAR%d to %dM (%pe). Consider enabling 'Resizable BAR' support in your BIOS\n",
resno, 1 << bar_size, ERR_PTR(ret)); resno, 1 << bar_size, ERR_PTR(ret));
return ret; return;
} }
drm_info(&xe->drm, "BAR%d resized to %dM\n", resno, 1 << bar_size); drm_info(&xe->drm, "BAR%d resized to %dM\n", resno, 1 << bar_size);
return ret;
} }
/* /*
* if force_vram_bar_size is set, attempt to set to the requested size * if force_vram_bar_size is set, attempt to set to the requested size
* else set to maximum possible size * else set to maximum possible size
*/ */
static int xe_resize_vram_bar(struct xe_device *xe) static void xe_resize_vram_bar(struct xe_device *xe)
{ {
u64 force_vram_bar_size = xe_force_vram_bar_size; u64 force_vram_bar_size = xe_force_vram_bar_size;
struct pci_dev *pdev = to_pci_dev(xe->drm.dev); struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
...@@ -83,14 +82,13 @@ static int xe_resize_vram_bar(struct xe_device *xe) ...@@ -83,14 +82,13 @@ static int xe_resize_vram_bar(struct xe_device *xe)
u32 bar_size_mask; u32 bar_size_mask;
u32 pci_cmd; u32 pci_cmd;
int i; int i;
int ret;
/* gather some relevant info */ /* gather some relevant info */
current_size = pci_resource_len(pdev, GEN12_LMEM_BAR); current_size = pci_resource_len(pdev, GEN12_LMEM_BAR);
bar_size_mask = pci_rebar_get_possible_sizes(pdev, GEN12_LMEM_BAR); bar_size_mask = pci_rebar_get_possible_sizes(pdev, GEN12_LMEM_BAR);
if (!bar_size_mask) if (!bar_size_mask)
return 0; return;
/* set to a specific size? */ /* set to a specific size? */
if (force_vram_bar_size) { if (force_vram_bar_size) {
...@@ -104,22 +102,22 @@ static int xe_resize_vram_bar(struct xe_device *xe) ...@@ -104,22 +102,22 @@ static int xe_resize_vram_bar(struct xe_device *xe)
drm_info(&xe->drm, drm_info(&xe->drm,
"Requested size: %lluMiB is not supported by rebar sizes: 0x%x. Leaving default: %lluMiB\n", "Requested size: %lluMiB is not supported by rebar sizes: 0x%x. Leaving default: %lluMiB\n",
(u64)rebar_size >> 20, bar_size_mask, (u64)current_size >> 20); (u64)rebar_size >> 20, bar_size_mask, (u64)current_size >> 20);
return 0; return;
} }
rebar_size = 1ULL << (__fls(bar_size_bit) + BAR_SIZE_SHIFT); rebar_size = 1ULL << (__fls(bar_size_bit) + BAR_SIZE_SHIFT);
if (rebar_size == current_size) if (rebar_size == current_size)
return 0; return;
} else { } else {
rebar_size = 1ULL << (__fls(bar_size_mask) + BAR_SIZE_SHIFT); rebar_size = 1ULL << (__fls(bar_size_mask) + BAR_SIZE_SHIFT);
/* only resize if larger than current */ /* only resize if larger than current */
if (rebar_size <= current_size) if (rebar_size <= current_size)
return 0; return;
} }
drm_info(&xe->drm, "Resizing bar from %lluMiB -> %lluMiB\n", drm_info(&xe->drm, "Attempting to resize bar from %lluMiB -> %lluMiB\n",
(u64)current_size >> 20, (u64)rebar_size >> 20); (u64)current_size >> 20, (u64)rebar_size >> 20);
while (root->parent) while (root->parent)
...@@ -133,17 +131,16 @@ static int xe_resize_vram_bar(struct xe_device *xe) ...@@ -133,17 +131,16 @@ static int xe_resize_vram_bar(struct xe_device *xe)
if (!root_res) { if (!root_res) {
drm_info(&xe->drm, "Can't resize VRAM BAR - platform support is missing. Consider enabling 'Resizable BAR' support in your BIOS\n"); drm_info(&xe->drm, "Can't resize VRAM BAR - platform support is missing. Consider enabling 'Resizable BAR' support in your BIOS\n");
return -1; return;
} }
pci_read_config_dword(pdev, PCI_COMMAND, &pci_cmd); pci_read_config_dword(pdev, PCI_COMMAND, &pci_cmd);
pci_write_config_dword(pdev, PCI_COMMAND, pci_cmd & ~PCI_COMMAND_MEMORY); pci_write_config_dword(pdev, PCI_COMMAND, pci_cmd & ~PCI_COMMAND_MEMORY);
ret = _resize_bar(xe, GEN12_LMEM_BAR, rebar_size); _resize_bar(xe, GEN12_LMEM_BAR, rebar_size);
pci_assign_unassigned_bus_resources(pdev->bus); pci_assign_unassigned_bus_resources(pdev->bus);
pci_write_config_dword(pdev, PCI_COMMAND, pci_cmd); pci_write_config_dword(pdev, PCI_COMMAND, pci_cmd);
return ret;
} }
static bool xe_pci_resource_valid(struct pci_dev *pdev, int bar) static bool xe_pci_resource_valid(struct pci_dev *pdev, int bar)
...@@ -163,16 +160,13 @@ static bool xe_pci_resource_valid(struct pci_dev *pdev, int bar) ...@@ -163,16 +160,13 @@ static bool xe_pci_resource_valid(struct pci_dev *pdev, int bar)
static int xe_determine_lmem_bar_size(struct xe_device *xe) static int xe_determine_lmem_bar_size(struct xe_device *xe)
{ {
struct pci_dev *pdev = to_pci_dev(xe->drm.dev); struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
int err;
if (!xe_pci_resource_valid(pdev, GEN12_LMEM_BAR)) { if (!xe_pci_resource_valid(pdev, GEN12_LMEM_BAR)) {
drm_err(&xe->drm, "pci resource is not valid\n"); drm_err(&xe->drm, "pci resource is not valid\n");
return -ENXIO; return -ENXIO;
} }
err = xe_resize_vram_bar(xe); xe_resize_vram_bar(xe);
if (err)
return err;
xe->mem.vram.io_start = pci_resource_start(pdev, GEN12_LMEM_BAR); xe->mem.vram.io_start = pci_resource_start(pdev, GEN12_LMEM_BAR);
xe->mem.vram.io_size = pci_resource_len(pdev, GEN12_LMEM_BAR); xe->mem.vram.io_size = pci_resource_len(pdev, GEN12_LMEM_BAR);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment