]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
drm/xe: Move struct xe_vram_region to a dedicated header
authorPiotr Piórkowski <piotr.piorkowski@intel.com>
Mon, 14 Jul 2025 18:48:16 +0000 (20:48 +0200)
committerLucas De Marchi <lucas.demarchi@intel.com>
Wed, 16 Jul 2025 19:12:36 +0000 (12:12 -0700)
Let's move the xe_vram_region structure to a new header dedicated to VRAM
to improve modularity and avoid unnecessary dependencies when only
VRAM-related structures are needed.

v2: Fix build if CONFIG_DRM_XE_DEVMEM_MIRROR is enabled
v3: Fix build if CONFIG_DRM_XE_DISPLAY is enabled
v4: Move helper to get tile dpagemap to xe_svm.c

Signed-off-by: Piotr Piórkowski <piotr.piorkowski@intel.com>
Suggested-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Satyanarayana K V P <satyanarayana.k.v.p@intel.com> # rev3
Acked-by: Matthew Brost <matthew.brost@intel.com>
Link: https://lore.kernel.org/r/20250714184818.89201-4-piotr.piorkowski@intel.com
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
13 files changed:
drivers/gpu/drm/xe/display/xe_fb_pin.c
drivers/gpu/drm/xe/display/xe_plane_initial.c
drivers/gpu/drm/xe/xe_bo.c
drivers/gpu/drm/xe/xe_bo_types.h
drivers/gpu/drm/xe/xe_device.c
drivers/gpu/drm/xe/xe_device_types.h
drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
drivers/gpu/drm/xe/xe_svm.c
drivers/gpu/drm/xe/xe_tile.c
drivers/gpu/drm/xe/xe_tile.h
drivers/gpu/drm/xe/xe_ttm_vram_mgr.c
drivers/gpu/drm/xe/xe_vram.c
drivers/gpu/drm/xe/xe_vram_types.h [new file with mode: 0644]

index a1b203f403907b2789f0d557eee7518203436616..3f0362453e7371d0ece970a3b81f57fbe76733f1 100644 (file)
@@ -16,6 +16,7 @@
 #include "xe_device.h"
 #include "xe_ggtt.h"
 #include "xe_pm.h"
+#include "xe_vram_types.h"
 
 static void
 write_dpt_rotated(struct xe_bo *bo, struct iosys_map *map, u32 *dpt_ofs, u32 bo_ofs,
index 30a341c96e76ff6051be16e96c344b00d866888e..54ff70ea2d25f7c3c91a45e5b4bcb08ca5e51615 100644 (file)
@@ -21,6 +21,7 @@
 #include "intel_frontbuffer.h"
 #include "intel_plane_initial.h"
 #include "xe_bo.h"
+#include "xe_vram_types.h"
 #include "xe_wa.h"
 
 #include <generated/xe_wa_oob.h>
index 18f27da47a3634b366d3c4f42546d90b1cf1ae28..00ce067d5fd3bfbc290cb57edd6d59a1acc56be4 100644 (file)
@@ -36,6 +36,7 @@
 #include "xe_trace_bo.h"
 #include "xe_ttm_stolen_mgr.h"
 #include "xe_vm.h"
+#include "xe_vram_types.h"
 
 const char *const xe_mem_type_to_name[TTM_NUM_MEM_TYPES]  = {
        [XE_PL_SYSTEM] = "system",
index ff560d82496ff4c228bdef009598100540048d73..57d34698139ee20b190da065d6af147995116e57 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/iosys-map.h>
 
 #include <drm/drm_gpusvm.h>
+#include <drm/drm_pagemap.h>
 #include <drm/ttm/ttm_bo.h>
 #include <drm/ttm/ttm_device.h>
 #include <drm/ttm/ttm_placement.h>
index df6f1790d6a6c75d32a84d14e48ca1c3b6a32953..08f45777f797b83a25e45d8e37d1769bc1f4de70 100644 (file)
@@ -64,6 +64,7 @@
 #include "xe_ttm_sys_mgr.h"
 #include "xe_vm.h"
 #include "xe_vram.h"
+#include "xe_vram_types.h"
 #include "xe_vsec.h"
 #include "xe_wait_user_fence.h"
 #include "xe_wa.h"
index 6299f4571c4c0b1529bc562a5aac727678929104..eb6105523f233cf58caa42da1963f7816adeeac5 100644 (file)
@@ -10,7 +10,6 @@
 
 #include <drm/drm_device.h>
 #include <drm/drm_file.h>
-#include <drm/drm_pagemap.h>
 #include <drm/ttm/ttm_device.h>
 
 #include "xe_devcoredump_types.h"
@@ -26,7 +25,6 @@
 #include "xe_sriov_vf_types.h"
 #include "xe_step_types.h"
 #include "xe_survivability_mode_types.h"
-#include "xe_ttm_vram_mgr_types.h"
 
 #if IS_ENABLED(CONFIG_DRM_XE_DEBUG)
 #define TEST_VM_OPS_ERROR
@@ -39,6 +37,7 @@ struct xe_ggtt;
 struct xe_i2c;
 struct xe_pat_ops;
 struct xe_pxp;
+struct xe_vram_region;
 
 #define XE_BO_INVALID_OFFSET   LONG_MAX
 
@@ -71,63 +70,6 @@ struct xe_pxp;
                 const struct xe_tile * : (const struct xe_device *)((tile__)->xe),     \
                 struct xe_tile * : (tile__)->xe)
 
-/**
- * struct xe_vram_region - memory region structure
- * This is used to describe a memory region in xe
- * device, such as HBM memory or CXL extension memory.
- */
-struct xe_vram_region {
-       /** @tile: Back pointer to tile */
-       struct xe_tile *tile;
-       /** @io_start: IO start address of this VRAM instance */
-       resource_size_t io_start;
-       /**
-        * @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 @usable_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;
-       /** @dpa_base: This memory regions's DPA (device physical address) base */
-       resource_size_t dpa_base;
-       /**
-        * @usable_size: usable size of VRAM
-        *
-        * Usable size of VRAM excluding reserved portions
-        * (e.g stolen mem)
-        */
-       resource_size_t usable_size;
-       /**
-        * @actual_physical_size: Actual VRAM size
-        *
-        * Actual VRAM size including reserved portions
-        * (e.g stolen mem)
-        */
-       resource_size_t actual_physical_size;
-       /** @mapping: pointer to VRAM mappable space */
-       void __iomem *mapping;
-       /** @ttm: VRAM TTM manager */
-       struct xe_ttm_vram_mgr ttm;
-#if IS_ENABLED(CONFIG_DRM_XE_PAGEMAP)
-       /** @pagemap: Used to remap device memory as ZONE_DEVICE */
-       struct dev_pagemap pagemap;
-       /**
-        * @dpagemap: The struct drm_pagemap of the ZONE_DEVICE memory
-        * pages of this tile.
-        */
-       struct drm_pagemap dpagemap;
-       /**
-        * @hpa_base: base host physical address
-        *
-        * This is generated when remap device memory as ZONE_DEVICE
-        */
-       resource_size_t hpa_base;
-#endif
-};
-
 /**
  * struct xe_mmio - register mmio structure
  *
index 86889df04011de491b7f19aa95c650388bcf8119..f00cce81f1ff5f72e78c1c59ac1f013e29807aa7 100644 (file)
@@ -33,6 +33,7 @@
 #include "xe_migrate.h"
 #include "xe_sriov.h"
 #include "xe_ttm_vram_mgr.h"
+#include "xe_vram_types.h"
 #include "xe_wopcm.h"
 
 #define make_u64_from_u32(hi, lo) ((u64)((u64)(u32)(hi) << 32 | (u32)(lo)))
index e6871734ffa98a63470da4fd6aae67f733d65b79..901f9a0268e641b81259bbdc86d8ffee5f65f79a 100644 (file)
@@ -17,6 +17,7 @@
 #include "xe_ttm_vram_mgr.h"
 #include "xe_vm.h"
 #include "xe_vm_types.h"
+#include "xe_vram_types.h"
 
 static bool xe_svm_range_in_vram(struct xe_svm_range *range)
 {
@@ -989,6 +990,11 @@ int xe_svm_range_get_pages(struct xe_vm *vm, struct xe_svm_range *range,
 
 #if IS_ENABLED(CONFIG_DRM_XE_PAGEMAP)
 
+static struct drm_pagemap *tile_local_pagemap(struct xe_tile *tile)
+{
+       return &tile->mem.vram->dpagemap;
+}
+
 /**
  * xe_svm_alloc_vram()- Allocate device memory pages for range,
  * migrating existing data.
@@ -1006,7 +1012,7 @@ int xe_svm_alloc_vram(struct xe_tile *tile, struct xe_svm_range *range,
        xe_assert(tile_to_xe(tile), range->base.flags.migrate_devmem);
        range_debug(range, "ALLOCATE VRAM");
 
-       dpagemap = xe_tile_local_pagemap(tile);
+       dpagemap = tile_local_pagemap(tile);
        return drm_pagemap_populate_mm(dpagemap, xe_svm_range_start(range),
                                       xe_svm_range_end(range),
                                       range->base.gpusvm->mm,
index 858ce0183aaae24bfc691457f3ac7bf1a9dae047..bd2ff91a7d1c06694ea59e07658f145e9d933aad 100644 (file)
@@ -20,6 +20,7 @@
 #include "xe_ttm_vram_mgr.h"
 #include "xe_wa.h"
 #include "xe_vram.h"
+#include "xe_vram_types.h"
 
 /**
  * DOC: Multi-tile Design
index 440bc9e11c8b47e0d00927a710acf87265cd11e7..dceb6297aa01df08579e475bea59e5946d7dcffb 100644 (file)
@@ -18,18 +18,6 @@ int xe_tile_alloc_vram(struct xe_tile *tile);
 
 void xe_tile_migrate_wait(struct xe_tile *tile);
 
-#if IS_ENABLED(CONFIG_DRM_XE_PAGEMAP)
-static inline struct drm_pagemap *xe_tile_local_pagemap(struct xe_tile *tile)
-{
-       return &tile->mem.vram->dpagemap;
-}
-#else
-static inline struct drm_pagemap *xe_tile_local_pagemap(struct xe_tile *tile)
-{
-       return NULL;
-}
-#endif
-
 static inline bool xe_tile_is_root(struct xe_tile *tile)
 {
        return tile->id == 0;
index 3de2df47959b70f3d161fa79e63635dcfeca1e08..8f9b8a1d2c05875f1ce59815cdb0139abba547d5 100644 (file)
@@ -15,6 +15,7 @@
 #include "xe_gt.h"
 #include "xe_res_cursor.h"
 #include "xe_ttm_vram_mgr.h"
+#include "xe_vram_types.h"
 
 static inline struct drm_buddy_block *
 xe_ttm_vram_mgr_first_block(struct list_head *list)
index c93e9b96354bc0521e0024ee2e330ceadfe739a8..366e5d8a85cac021961eb038db4d41cf86222328 100644 (file)
@@ -21,6 +21,7 @@
 #include "xe_module.h"
 #include "xe_sriov.h"
 #include "xe_vram.h"
+#include "xe_vram_types.h"
 
 #define BAR_SIZE_SHIFT 20
 
diff --git a/drivers/gpu/drm/xe/xe_vram_types.h b/drivers/gpu/drm/xe/xe_vram_types.h
new file mode 100644 (file)
index 0000000..a018382
--- /dev/null
@@ -0,0 +1,74 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2025 Intel Corporation
+ */
+
+#ifndef _XE_VRAM_TYPES_H_
+#define _XE_VRAM_TYPES_H_
+
+#if IS_ENABLED(CONFIG_DRM_XE_PAGEMAP)
+#include <drm/drm_pagemap.h>
+#endif
+
+#include "xe_ttm_vram_mgr_types.h"
+
+struct xe_tile;
+
+/**
+ * struct xe_vram_region - memory region structure
+ * This is used to describe a memory region in xe
+ * device, such as HBM memory or CXL extension memory.
+ */
+struct xe_vram_region {
+       /** @tile: Back pointer to tile */
+       struct xe_tile *tile;
+       /** @io_start: IO start address of this VRAM instance */
+       resource_size_t io_start;
+       /**
+        * @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 @usable_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;
+       /** @dpa_base: This memory regions's DPA (device physical address) base */
+       resource_size_t dpa_base;
+       /**
+        * @usable_size: usable size of VRAM
+        *
+        * Usable size of VRAM excluding reserved portions
+        * (e.g stolen mem)
+        */
+       resource_size_t usable_size;
+       /**
+        * @actual_physical_size: Actual VRAM size
+        *
+        * Actual VRAM size including reserved portions
+        * (e.g stolen mem)
+        */
+       resource_size_t actual_physical_size;
+       /** @mapping: pointer to VRAM mappable space */
+       void __iomem *mapping;
+       /** @ttm: VRAM TTM manager */
+       struct xe_ttm_vram_mgr ttm;
+#if IS_ENABLED(CONFIG_DRM_XE_PAGEMAP)
+       /** @pagemap: Used to remap device memory as ZONE_DEVICE */
+       struct dev_pagemap pagemap;
+       /**
+        * @dpagemap: The struct drm_pagemap of the ZONE_DEVICE memory
+        * pages of this tile.
+        */
+       struct drm_pagemap dpagemap;
+       /**
+        * @hpa_base: base host physical address
+        *
+        * This is generated when remap device memory as ZONE_DEVICE
+        */
+       resource_size_t hpa_base;
+#endif
+};
+
+#endif