/* * Release all the BARs that could influence/block LMEMBAR resizing, i.e. * assigned IORESOURCE_MEM_64 BARs
*/ staticvoid release_bars(struct pci_dev *pdev)
{ struct resource *res; int i;
pci_dev_for_each_resource(pdev, res, i) { /* Resource already un-assigned, do not reset it */ if (!res->parent) continue;
/* No need to release unrelated BARs */ if (!(res->flags & IORESOURCE_MEM_64)) continue;
pci_release_resource(pdev, i);
}
}
staticvoid resize_bar(struct xe_device *xe, int resno, resource_size_t size)
{ struct pci_dev *pdev = to_pci_dev(xe->drm.dev); int bar_size = pci_rebar_bytes_to_size(size); int ret;
release_bars(pdev);
ret = pci_resize_resource(pdev, resno, bar_size); if (ret) {
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)); return;
}
drm_info(&xe->drm, "BAR%d resized to %dM\n", resno, 1 << bar_size);
}
/* * if force_vram_bar_size is set, attempt to set to the requested size * else set to maximum possible size
*/ void xe_vram_resize_bar(struct xe_device *xe)
{ int force_vram_bar_size = xe_modparam.force_vram_bar_size; struct pci_dev *pdev = to_pci_dev(xe->drm.dev); struct pci_bus *root = pdev->bus;
resource_size_t current_size;
resource_size_t rebar_size; struct resource *root_res;
u32 bar_size_mask;
u32 pci_cmd; int i;
/* gather some relevant info */
current_size = pci_resource_len(pdev, LMEM_BAR);
bar_size_mask = pci_rebar_get_possible_sizes(pdev, LMEM_BAR);
if (!bar_size_mask) return;
if (force_vram_bar_size < 0) return;
/* set to a specific size? */ if (force_vram_bar_size) {
u32 bar_size_bit;
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"); return;
}
/* We don't expect any holes */
xe_assert_msg(xe, offset == (xe_mmio_read64_2x32(>_to_tile(gt)->mmio, GSMBASE) -
ccs_size), "Hole between CCS and GSM.\n");
} else {
reg = xe_gt_mcr_unicast_read_any(gt, XEHP_FLAT_CCS_BASE_ADDR);
offset = (u64)REG_FIELD_GET(XEHP_FLAT_CCS_PTR, reg) * SZ_64K;
}
return offset;
}
/* * tile_vram_size() - Collect vram size and offset information * @tile: tile to get info for * @vram_size: available vram (size - device reserved portions) * @tile_size: actual vram size * @tile_offset: physical start point in the vram address space * * There are 4 places for size information: * - io size (from pci_resource_len of LMEM bar) (only used for small bar and DG1) * - TILEx size (actual vram size) * - GSMBASE offset (TILEx - "stolen") * - CSSBASE offset (TILEx - CSS space necessary) * * CSSBASE is always a lower/smaller offset then GSMBASE. * * The actual available size of memory is to the CCS or GSM base. * NOTE: multi-tile bases will include the tile offset. *
*/ staticint tile_vram_size(struct xe_tile *tile, u64 *vram_size,
u64 *tile_size, u64 *tile_offset)
{ struct xe_device *xe = tile_to_xe(tile); struct xe_gt *gt = tile->primary_gt; unsignedint fw_ref;
u64 offset;
u32 reg;
/** * xe_vram_region_io_start - Get the IO start of a VRAM region * @vram: the VRAM region * * Return: the IO start of the VRAM region, or 0 if not valid
*/
resource_size_t xe_vram_region_io_start(conststruct xe_vram_region *vram)
{ return vram ? vram->io_start : 0;
}
/** * xe_vram_region_io_size - Get the IO size of a VRAM region * @vram: the VRAM region * * Return: the IO size of the VRAM region, or 0 if not valid
*/
resource_size_t xe_vram_region_io_size(conststruct xe_vram_region *vram)
{ return vram ? vram->io_size : 0;
}
/** * xe_vram_region_dpa_base - Get the DPA base of a VRAM region * @vram: the VRAM region * * Return: the DPA base of the VRAM region, or 0 if not valid
*/
resource_size_t xe_vram_region_dpa_base(conststruct xe_vram_region *vram)
{ return vram ? vram->dpa_base : 0;
}
/** * xe_vram_region_usable_size - Get the usable size of a VRAM region * @vram: the VRAM region * * Return: the usable size of the VRAM region, or 0 if not valid
*/
resource_size_t xe_vram_region_usable_size(conststruct xe_vram_region *vram)
{ return vram ? vram->usable_size : 0;
}
/** * xe_vram_region_actual_physical_size - Get the actual physical size of a VRAM region * @vram: the VRAM region * * Return: the actual physical size of the VRAM region, or 0 if not valid
*/
resource_size_t xe_vram_region_actual_physical_size(conststruct xe_vram_region *vram)
{ return vram ? vram->actual_physical_size : 0;
}
EXPORT_SYMBOL_IF_KUNIT(xe_vram_region_actual_physical_size);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.