]> www.infradead.org Git - users/hch/misc.git/commitdiff
drm/xe/vf: Move VF CCS data to xe_device
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Mon, 8 Sep 2025 12:30:23 +0000 (14:30 +0200)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Tue, 9 Sep 2025 09:27:50 +0000 (11:27 +0200)
We only need single set of VF CCS contexts, they are not per-tile
as initial implementation might suggest. Move all VF CCS data from
xe_tile.sriov.vf to xe_device.sriov.vf. Also rename some structs to
align with the usage and fix their kernel-doc.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Satyanarayana K V P <satyanarayana.k.v.p@intel.com>
Reviewed-by: Satyanarayana K V P <satyanarayana.k.v.p@intel.com>
Link: https://lore.kernel.org/r/20250908123025.747-7-michal.wajdeczko@intel.com
drivers/gpu/drm/xe/xe_bb.c
drivers/gpu/drm/xe/xe_device_types.h
drivers/gpu/drm/xe/xe_gt_debugfs.c
drivers/gpu/drm/xe/xe_sriov_vf_ccs.c
drivers/gpu/drm/xe/xe_sriov_vf_ccs_types.h
drivers/gpu/drm/xe/xe_sriov_vf_types.h

index feb6e013dc3811ce34561c00e14ca65189bee547..6d20229c11de6fed1c4c044e0b40f1f68d36e01f 100644 (file)
@@ -64,7 +64,7 @@ struct xe_bb *xe_bb_ccs_new(struct xe_gt *gt, u32 dwords,
                            enum xe_sriov_vf_ccs_rw_ctxs ctx_id)
 {
        struct xe_bb *bb = kmalloc(sizeof(*bb), GFP_KERNEL);
-       struct xe_tile *tile = gt_to_tile(gt);
+       struct xe_device *xe = gt_to_xe(gt);
        struct xe_sa_manager *bb_pool;
        int err;
 
@@ -78,7 +78,7 @@ struct xe_bb *xe_bb_ccs_new(struct xe_gt *gt, u32 dwords,
         * So, this extra DW acts as a guard here.
         */
 
-       bb_pool = tile->sriov.vf.ccs[ctx_id].mem.ccs_bb_pool;
+       bb_pool = xe->sriov.vf.ccs.contexts[ctx_id].mem.ccs_bb_pool;
        bb->bo = xe_sa_bo_new(bb_pool, 4 * (dwords + 1));
 
        if (IS_ERR(bb->bo)) {
index 9e30dc7d6e5822b66d3e975715a02176a68d0e42..a6ba880e41814597ef04a087f5e4359151d516ef 100644 (file)
@@ -183,9 +183,6 @@ struct xe_tile {
                struct {
                        /** @sriov.vf.ggtt_balloon: GGTT regions excluded from use. */
                        struct xe_ggtt_node *ggtt_balloon[2];
-
-                       /** @sriov.vf.ccs: CCS read and write contexts for VF. */
-                       struct xe_tile_vf_ccs ccs[XE_SRIOV_VF_CCS_CTX_COUNT];
                } vf;
        } sriov;
 
index f6f2c14b642dc5e8928f32318c8b72c943480b55..a9d960de0e5e958a5eacb790147961dec23c29de 100644 (file)
@@ -126,7 +126,7 @@ static int powergate_info(struct xe_gt *gt, struct drm_printer *p)
 
 static int sa_info_vf_ccs(struct xe_gt *gt, struct drm_printer *p)
 {
-       struct xe_tile *tile = gt_to_tile(gt);
+       struct xe_device *xe = gt_to_xe(gt);
        struct xe_sa_manager *bb_pool;
        enum xe_sriov_vf_ccs_rw_ctxs ctx_id;
 
@@ -136,7 +136,7 @@ static int sa_info_vf_ccs(struct xe_gt *gt, struct drm_printer *p)
        xe_pm_runtime_get(gt_to_xe(gt));
 
        for_each_ccs_rw_ctx(ctx_id) {
-               bb_pool = tile->sriov.vf.ccs[ctx_id].mem.ccs_bb_pool;
+               bb_pool = xe->sriov.vf.ccs.contexts[ctx_id].mem.ccs_bb_pool;
                if (!bb_pool)
                        break;
 
index eb8436e44ca4743cacc93b45d5ec50e86dd89f74..c5c60f05073dc2537b8f383e7470f99708cac4c8 100644 (file)
@@ -136,7 +136,7 @@ static u64 get_ccs_bb_pool_size(struct xe_device *xe)
        return round_up(bb_pool_size * 2, SZ_1M);
 }
 
-static int alloc_bb_pool(struct xe_tile *tile, struct xe_tile_vf_ccs *ctx)
+static int alloc_bb_pool(struct xe_tile *tile, struct xe_sriov_vf_ccs_ctx *ctx)
 {
        struct xe_device *xe = tile_to_xe(tile);
        struct xe_sa_manager *sa_manager;
@@ -168,7 +168,7 @@ static int alloc_bb_pool(struct xe_tile *tile, struct xe_tile_vf_ccs *ctx)
        return 0;
 }
 
-static void ccs_rw_update_ring(struct xe_tile_vf_ccs *ctx)
+static void ccs_rw_update_ring(struct xe_sriov_vf_ccs_ctx *ctx)
 {
        u64 addr = xe_sa_manager_gpu_addr(ctx->mem.ccs_bb_pool);
        struct xe_lrc *lrc = xe_exec_queue_lrc(ctx->mig_q);
@@ -185,7 +185,7 @@ static void ccs_rw_update_ring(struct xe_tile_vf_ccs *ctx)
        xe_lrc_set_ring_tail(lrc, lrc->ring.tail);
 }
 
-static int register_save_restore_context(struct xe_tile_vf_ccs *ctx)
+static int register_save_restore_context(struct xe_sriov_vf_ccs_ctx *ctx)
 {
        int ctx_type;
 
@@ -215,15 +215,14 @@ static int register_save_restore_context(struct xe_tile_vf_ccs *ctx)
  */
 int xe_sriov_vf_ccs_register_context(struct xe_device *xe)
 {
-       struct xe_tile *tile = xe_device_get_root_tile(xe);
        enum xe_sriov_vf_ccs_rw_ctxs ctx_id;
-       struct xe_tile_vf_ccs *ctx;
+       struct xe_sriov_vf_ccs_ctx *ctx;
        int err;
 
        xe_assert(xe, IS_VF_CCS_READY(xe));
 
        for_each_ccs_rw_ctx(ctx_id) {
-               ctx = &tile->sriov.vf.ccs[ctx_id];
+               ctx = &xe->sriov.vf.ccs.contexts[ctx_id];
                err = register_save_restore_context(ctx);
                if (err)
                        return err;
@@ -234,7 +233,7 @@ int xe_sriov_vf_ccs_register_context(struct xe_device *xe)
 
 static void xe_sriov_vf_ccs_fini(void *arg)
 {
-       struct xe_tile_vf_ccs *ctx = arg;
+       struct xe_sriov_vf_ccs_ctx *ctx = arg;
        struct xe_lrc *lrc = xe_exec_queue_lrc(ctx->mig_q);
 
        /*
@@ -258,7 +257,7 @@ int xe_sriov_vf_ccs_init(struct xe_device *xe)
 {
        struct xe_tile *tile = xe_device_get_root_tile(xe);
        enum xe_sriov_vf_ccs_rw_ctxs ctx_id;
-       struct xe_tile_vf_ccs *ctx;
+       struct xe_sriov_vf_ccs_ctx *ctx;
        struct xe_exec_queue *q;
        u32 flags;
        int err;
@@ -270,7 +269,7 @@ int xe_sriov_vf_ccs_init(struct xe_device *xe)
                return 0;
 
        for_each_ccs_rw_ctx(ctx_id) {
-               ctx = &tile->sriov.vf.ccs[ctx_id];
+               ctx = &xe->sriov.vf.ccs.contexts[ctx_id];
                ctx->ctx_id = ctx_id;
 
                flags = EXEC_QUEUE_FLAG_KERNEL |
@@ -325,7 +324,7 @@ int xe_sriov_vf_ccs_attach_bo(struct xe_bo *bo)
 {
        struct xe_device *xe = xe_bo_device(bo);
        enum xe_sriov_vf_ccs_rw_ctxs ctx_id;
-       struct xe_tile_vf_ccs *ctx;
+       struct xe_sriov_vf_ccs_ctx *ctx;
        struct xe_tile *tile;
        struct xe_bb *bb;
        int err = 0;
@@ -339,7 +338,7 @@ int xe_sriov_vf_ccs_attach_bo(struct xe_bo *bo)
                /* bb should be NULL here. Assert if not NULL */
                xe_assert(xe, !bb);
 
-               ctx = &tile->sriov.vf.ccs[ctx_id];
+               ctx = &xe->sriov.vf.ccs.contexts[ctx_id];
                err = xe_migrate_ccs_rw_copy(tile, ctx->mig_q, bo, ctx_id);
        }
        return err;
index 4d3c10907135dd744ef48997b43db0c5e18eeaa0..22c499943d2a39a2b1d768befb9488059bc71662 100644 (file)
@@ -6,6 +6,8 @@
 #ifndef _XE_SRIOV_VF_CCS_TYPES_H_
 #define _XE_SRIOV_VF_CCS_TYPES_H_
 
+#include <linux/types.h>
+
 #define for_each_ccs_rw_ctx(id__) \
        for ((id__) = 0; (id__) < XE_SRIOV_VF_CCS_CTX_COUNT; (id__)++)
 
@@ -18,16 +20,32 @@ enum xe_sriov_vf_ccs_rw_ctxs {
 struct xe_migrate;
 struct xe_sa_manager;
 
-struct xe_tile_vf_ccs {
-       /** @id: Id to which context it belongs to */
+/**
+ * struct xe_sriov_vf_ccs_ctx - VF CCS migration context data.
+ */
+struct xe_sriov_vf_ccs_ctx {
+       /** @ctx_id: Id to which context it belongs to */
        enum xe_sriov_vf_ccs_rw_ctxs ctx_id;
+
        /** @mig_q: exec queues used for migration */
        struct xe_exec_queue *mig_q;
 
+       /** @mem: memory data */
        struct {
-               /** @ccs_bb_pool: Pool from which batch buffers are allocated. */
+               /** @mem.ccs_bb_pool: Pool from which batch buffers are allocated. */
                struct xe_sa_manager *ccs_bb_pool;
        } mem;
 };
 
+/**
+ * struct xe_sriov_vf_ccs - The VF CCS migration support data.
+ */
+struct xe_sriov_vf_ccs {
+       /** @contexts: CCS read and write contexts for VF. */
+       struct xe_sriov_vf_ccs_ctx contexts[XE_SRIOV_VF_CCS_CTX_COUNT];
+
+       /** @initialized: Initialization of VF CCS is completed or not. */
+       bool initialized;
+};
+
 #endif
index 2c94d1f92187fa37e6cebd17111a8549da76b7e7..426cc58419588832fbc4f19b6f89f9bafdc91340 100644 (file)
@@ -9,6 +9,8 @@
 #include <linux/types.h>
 #include <linux/workqueue_types.h>
 
+#include "xe_sriov_vf_ccs_types.h"
+
 /**
  * struct xe_sriov_vf_relay_version - PF ABI version details.
  */
@@ -43,10 +45,7 @@ struct xe_device_vf {
        } migration;
 
        /** @ccs: VF CCS state data */
-       struct {
-               /** @ccs.initialized: Initilalization of VF CCS is completed or not */
-               bool initialized;
-       } ccs;
+       struct xe_sriov_vf_ccs ccs;
 };
 
 #endif