drm/xe: Rework multi tile device memory initialization
Subsystems (2)
v2 cover drm/xe: Rework multi tile device memory initialization
The vram initialization path does not take into account each tile's actual memory size.
While updating this, simplify the rebar algorithm and clarify some helper functions.
v2: Address review comments
- separate tile sizing to the initial patch
Michael J. Ruhl (4):
drm/xe: Rework size helper to be a little more correct drm/xe: Simplify rebar sizing
drm/xe: Size GT device memory correctly drm/xe: Rename GPU offset helper to reflect true usage
drivers/gpu/drm/xe/regs/xe_gt_regs.h | 3 +- drivers/gpu/drm/xe/xe_bo.c | 8 +- drivers/gpu/drm/xe/xe_bo.h | 2 +- drivers/gpu/drm/xe/xe_device_types.h | 18 +- drivers/gpu/drm/xe/xe_gt_types.h | 14 +- drivers/gpu/drm/xe/xe_migrate.c | 6 +- drivers/gpu/drm/xe/xe_mmio.c | 272 ++++++++++++++----------- drivers/gpu/drm/xe/xe_mmio.h | 4 +- drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c | 30 +-- 9 files changed, 201 insertions(+), 156 deletions(-)
Signature · 1 line
2.39.2
PATCH v2 1/4 drm/xe: Rework size helper to be a little more correct
The _total_vram_size helper is device based and is not complete.
Teach the helper to be tile aware and add the ability to size DG1 correctly.
--- drivers/gpu/drm/xe/regs/xe_gt_regs.h | 3 +- drivers/gpu/drm/xe/xe_mmio.c | 72 +++++++++++++++++--------- drivers/gpu/drm/xe/xe_mmio.h | 2 +- drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c | 28 +++++----- 4 files changed, 65 insertions(+), 40 deletions(-)
drivers/gpu/drm/xe/regs/xe_gt_regs.h +2 -1
@@ -75,7 +75,8 @@#define GEN12_VE1_AUX_NV _MMIO(0x42b8)#define AUX_INV REG_BIT(0) -#define XEHP_TILE0_ADDR_RANGE MCR_REG(0x4900) +#define XEHP_TILE_ADDR_RANGE (_idx) MCR_REG(0x4900 + (_idx) * 4) +#define XEHP_FLAT_CCS_BASE_ADDR MCR_REG(0x4910)#define CHICKEN_RASTER_1 MCR_REG(0x6204)
drivers/gpu/drm/xe/xe_mmio.c +48 -24
117 lines not on this page · raw message
drivers/gpu/drm/xe/xe_mmio.h +1 -1
@@ -120,6 +120,6 @@ static inline bool xe_mmio_in_range(const struct xe_mmio_range *range, u32 reg) }int xe_mmio_probe_vram (struct xe_device *xe); -int xe_mmio_total_vram_size (struct xe_device *xe,u64 *vram_size,u64 *flat_ccs_base); +int xe_mmio_tile_vram_size (struct xe_gt *gt,u64 *vram_size,u64 *tile_size,u64 *tile_base);#endif
drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c +14 -14
@@ -51,27 +51,27 @@ bool xe_ttm_stolen_cpu_access_needs_ggtt(struct xe_device *xe)return GRAPHICS_VERx100 (xe) <1270 && !IS_DGFX (xe); } -static s64 detect_bar2_dgfx (struct xe_device *xe,struct xe_ttm_stolen_mgr *mgr) +static s64 detect_bar2_dgfx (struct xe_gt *gt,struct xe_ttm_stolen_mgr *mgr) { -struct pci_dev *pdev =to_pci_dev (xe->drm.dev); -struct xe_gt *gt =to_gt (xe); -u64 vram_size, stolen_size; -int err; +u64 stolen_size; +u64 tile_offset; +u64 tile_size; +u64 vram_size; - err =xe_mmio_total_vram_size (xe, &vram_size,NULL ); -if (err) { -drm_info (&xe->drm,"Querying total vram size failed\n" ); +if (xe_mmio_tile_vram_size (gt, &vram_size, &tile_size, &tile_offset)) { +drm_info (>->xe->drm,"Querying total vram size failed\n" );return 0 ; }/* Use DSM base address instead for stolen memory */ - mgr->stolen_base =xe_mmio_read64 (gt,GEN12_DSMBASE .reg) &GEN12_BDSM_MASK ; -if (drm_WARN_ON (&xe->drm, vram_size < mgr->stolen_base)) + mgr->stolen_base = (xe_mmio_read64 (gt,GEN12_DSMBASE .reg) &GEN12_BDSM_MASK ) - tile_offset; +if (drm_WARN_ON (>->xe->drm, tile_size < mgr->stolen_base))return 0 ; - stolen_size = vram_size - mgr->stolen_base; -if (mgr->stolen_base + stolen_size <=pci_resource_len (pdev,2 )) - mgr->io_base =pci_resource_start (pdev,2 ) + mgr->stolen_base; + stolen_size = tile_size - mgr->stolen_base; + +if (mgr->stolen_base + stolen_size <= tile_size) + mgr->io_base = gt->mem.vram.io_start + mgr->stolen_base;/* * There may be few KB of platform dependent reserved memory at the end
@@ -139,7 +139,7 @@ void xe_ttm_stolen_mgr_init(struct xe_device *xe)int err;if (IS_DGFX (xe)) - stolen_size =detect_bar2_dgfx (xe, mgr); + stolen_size =detect_bar2_dgfx (to_gt (xe), mgr);else if (GRAPHICS_VERx100 (xe) >=1270 ) stolen_size =detect_bar2_integrated (xe, mgr);else
Signature · 1 line
2.39.2
PATCH v2 2/4 drm/xe: Simplify rebar sizing
In reply to Michael J. Ruhl"Right sizing" the PCI BAR is not necessary. If rebar is needed size to the maximum available.
Preserve the force_vram_bar_size sizing.
Update associated code for consistency.
--- drivers/gpu/drm/xe/xe_device_types.h | 14 +-- drivers/gpu/drm/xe/xe_migrate.c | 2 +- drivers/gpu/drm/xe/xe_mmio.c | 136 ++++++++++++++------------- 3 files changed, 77 insertions(+), 75 deletions(-)
drivers/gpu/drm/xe/xe_device_types.h +7 -7
@@ -193,15 +193,15 @@ struct xe_device {/** * @io_size: IO size of VRAM. * -* This represents how much of VRAM we can access via -* the CPU through the VRAM BAR. This can be smaller -* than @size, in which case only part of VRAM is CPU -* accessible (typically the first 256M). This -* configuration is known as small-bar. +* This represents how much of VRAM the CPU can access +* via the VRAM BAR. +* On systems that do not support large BAR IO space, +* this can be smaller than the actual memory size, in +* which case only part of VRAM is CPU accessible +* (typically the first 256M). This configuration is +* known as small-bar. */ resource_size_t io_size; -/** @size: Total size of VRAM */ -resource_size_t size;/** @mapping: pointer to VRAM mappable space */ void *__iomem mapping; } vram;
drivers/gpu/drm/xe/xe_migrate.c +1 -1
@@ -270,7 +270,7 @@ static int xe_migrate_prepare_vm(struct xe_gt *gt, struct xe_migrate *m,* Use 1GB pages, it shouldn't matter the physical amount of * vram is less, when we don't access it. */ -for (pos =0 ; pos < xe->mem.vram.size; pos +=SZ_1G , ofs +=8 ) +for (pos =0 ; pos < xe->mem.vram.io_size; pos +=SZ_1G , ofs +=8 )xe_map_wr (xe, &bo->vmap, ofs, u64, pos | flags); }
drivers/gpu/drm/xe/xe_mmio.c +69 -67
210 lines not on this page · raw message
Signature · 1 line
2.39.2
PATCH v2 3/4 drm/xe: Size GT device memory correctly
In reply to Michael J. RuhlThe current method of sizing GT device memory is not quite right.
Update the algorithm to use the relevant HW information and offsets to set up the sizing correctly.
Update the stolen memory sizing to reflect the changes, and to be GT specific.
--- drivers/gpu/drm/xe/xe_device_types.h | 4 +- drivers/gpu/drm/xe/xe_gt_types.h | 14 ++-- drivers/gpu/drm/xe/xe_mmio.c | 102 ++++++++++++++----------- drivers/gpu/drm/xe/xe_mmio.h | 2 +- drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c | 2 + 5 files changed, 71 insertions(+), 53 deletions(-)
drivers/gpu/drm/xe/xe_device_types.h +3 -1
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: MIT */ /* -* Copyright © 2022 Intel Corporation +* Copyright © 2022-2023 Intel Corporation */ #ifndef _XE_DEVICE_TYPES_H_
@@ -202,6 +202,8 @@ struct xe_device {* known as small-bar. */ resource_size_t io_size; +/** @base: Offset to apply for Device Physical Address control */ +resource_size_t base;/** @mapping: pointer to VRAM mappable space */ void *__iomem mapping; } vram;
drivers/gpu/drm/xe/xe_gt_types.h +8 -6
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: MIT */ /* -* Copyright © 2022 Intel Corporation +* Copyright © 2022-2023 Intel Corporation */ #ifndef _XE_GT_TYPES_H_
@@ -148,13 +148,15 @@ struct xe_gt {/** * @io_size: IO size of this VRAM instance * -* This represents how much of this VRAM we can access -* via the CPU through the VRAM BAR. This can be smaller -* than @size, in which case only part of VRAM is CPU -* accessible (typically the first 256M). This -* configuration is known as small-bar. +* This represents how much of the VRAM the CPU can access +* via the VRAM BAR. +* This can be smaller than the actual @size, in which +* case only part of VRAM is CPU accessible (typically +* the first 256M). This configuration is known as small-bar. */ resource_size_t io_size; +/** @base: offset of VRAM starting base */ +resource_size_t base;/** @size: size of VRAM. */ resource_size_t size;/** @mapping: pointer to VRAM mappable space */
drivers/gpu/drm/xe/xe_mmio.c +57 -45
148 lines not on this page · raw message
drivers/gpu/drm/xe/xe_mmio.h +1 -1
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: MIT */ /* -* Copyright © 2021 Intel Corporation +* Copyright © 2021-2023 Intel Corporation */ #ifndef _XE_MMIO_H_
drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c +2 -0
@@ -12,9 +12,11 @@#include <drm/ttm/ttm_range_manager.h> #include "regs/xe_regs.h" +#include "regs/xe_gt_regs.h" #include "xe_bo.h" #include "xe_device.h" #include "xe_gt.h" +#include "xe_gt_mcr.h" #include "xe_mmio.h" #include "xe_res_cursor.h" #include "xe_ttm_stolen_mgr.h"
Signature · 1 line
2.39.2
PATCH v2 4/4 drm/xe: Rename GPU offset helper to reflect true usage
In reply to Michael J. RuhlThe _io_offset helper function is returning an offset into the GPU address space. Using the CPU address offset (io_) is not correct.
Rename to reflect usage.
Update to use GPU offset information.
--- drivers/gpu/drm/xe/xe_bo.c | 8 ++++---- drivers/gpu/drm/xe/xe_bo.h | 2 +- drivers/gpu/drm/xe/xe_migrate.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-)
drivers/gpu/drm/xe/xe_bo.c +4 -4
@@ -1335,7 +1335,7 @@ struct xe_bo *xe_bo_create_from_data(struct xe_device *xe, struct xe_gt *gt,* XXX: This is in the VM bind data path, likely should calculate this once and * store, with a recalculation if the BO is moved. */ -uint64_t vram_region_io_offset (struct ttm_resource *res) +uint64_t vram_region_gpu_offset (struct ttm_resource *res) {struct xe_device *xe =ttm_to_xe_device (res->bo->bdev);struct xe_gt *gt =mem_type_to_gt (xe, res->mem_type);
@@ -1343,7 +1343,7 @@ uint64_t vram_region_io_offset(struct ttm_resource *res)if (res->mem_type ==XE_PL_STOLEN )return xe_ttm_stolen_gpu_offset (xe); -return gt->mem.vram.io_start - xe->mem.vram.io_start; +return gt->mem.vram.base; }/**
@@ -1427,7 +1427,7 @@ int xe_bo_pin(struct xe_bo *bo)XE_BUG_ON (!(place->flags &TTM_PL_FLAG_CONTIGUOUS )); place->fpfn = (xe_bo_addr (bo,0 ,PAGE_SIZE , &vram) - -vram_region_io_offset (bo->ttm.resource)) >>PAGE_SHIFT ; +vram_region_gpu_offset (bo->ttm.resource)) >>PAGE_SHIFT ; place->lpfn = place->fpfn + (bo->size >>PAGE_SHIFT );spin_lock (&xe->pinned.lock);
@@ -1571,7 +1571,7 @@ dma_addr_t xe_bo_addr(struct xe_bo *bo, u64 offset,xe_res_first (bo->ttm.resource, page <<PAGE_SHIFT , page_size, &cur); -return cur.start + offset +vram_region_io_offset (bo->ttm.resource); +return cur.start + offset +vram_region_gpu_offset (bo->ttm.resource); } }
drivers/gpu/drm/xe/xe_bo.h +1 -1
@@ -224,7 +224,7 @@ void xe_bo_vunmap(struct xe_bo *bo);bool mem_type_is_vram (u32 mem_type);bool xe_bo_is_vram (struct xe_bo *bo);bool xe_bo_is_stolen (struct xe_bo *bo); -uint64_t vram_region_io_offset (struct ttm_resource *res); +uint64_t vram_region_gpu_offset (struct ttm_resource *res);bool xe_bo_can_migrate (struct xe_bo *bo,u32 mem_type);
drivers/gpu/drm/xe/xe_migrate.c +2 -2
@@ -419,7 +419,7 @@ static u32 pte_update_size(struct xe_migrate *m, }else {/* Offset into identity map. */ *L0_ofs =xe_migrate_vram_ofs (cur->start + -vram_region_io_offset (res)); +vram_region_gpu_offset (res)); cmds += cmd_size; }
@@ -469,7 +469,7 @@ static void emit_pte(struct xe_migrate *m, addr |=XE_PTE_PS64 ; } - addr +=vram_region_io_offset (bo->ttm.resource); + addr +=vram_region_gpu_offset (bo->ttm.resource); addr |=XE_PPGTT_PTE_LM ; } addr |=PPAT_CACHED |XE_PAGE_PRESENT |XE_PAGE_RW ;
Signature · 1 line
2.39.2
Patchwork
CI[Intel-xe] ✗ CI.Patch_applied: failure for drm/xe: Rework multi tile device memory initialization
In reply to Michael J. Ruhl== Series Details ==
== Series Details ==
Series: drm/xe: Rework multi tile device memory initialization
URL : https://patchwork.freedesktop.org/series/117126/
State : failure
== Summary ==
=== Applying kernel patches on branch 'drm-xe-next' with base: === Base commit: f7b51a4d5 drm/xe: Fix media detection for pre-GMD_ID platforms === git am output follows ===
error: patch failed: drivers/gpu/drm/xe/regs/xe_gt_regs.h:75
error: drivers/gpu/drm/xe/regs/xe_gt_regs.h: patch does not apply
error: patch failed: drivers/gpu/drm/xe/xe_mmio.c:148
error: drivers/gpu/drm/xe/xe_mmio.c: patch does not apply
error: patch failed: drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c:51
error: drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch
Applying: drm/xe: Rework size helper to be a little more correct Patch failed at 0001 drm/xe: Rework size helper to be a little more correct When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".