Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/xe: Move migration support to device-level struct

Upcoming changes will allow users to control VF state and obtain its
migration data with a device-level granularity (not tile/gt).
Change the data structures to reflect that and move the GT-level
migration init to happen after device-level init.

Reviewed-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Link: https://patch.msgid.link/20251112132220.516975-3-michal.winiarski@intel.com
Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>

+88 -13
+1
drivers/gpu/drm/xe/Makefile
··· 177 177 xe_sriov_pf.o \ 178 178 xe_sriov_pf_control.o \ 179 179 xe_sriov_pf_debugfs.o \ 180 + xe_sriov_pf_migration.o \ 180 181 xe_sriov_pf_provision.o \ 181 182 xe_sriov_pf_service.o \ 182 183 xe_sriov_pf_sysfs.o \
+2 -10
drivers/gpu/drm/xe/xe_gt_sriov_pf_migration.c
··· 13 13 #include "xe_guc.h" 14 14 #include "xe_guc_ct.h" 15 15 #include "xe_sriov.h" 16 + #include "xe_sriov_pf_migration.h" 16 17 17 18 /* Return: number of dwords saved/restored/required or a negative error code on failure */ 18 19 static int guc_action_vf_save_restore(struct xe_guc *guc, u32 vfid, u32 opcode, ··· 116 115 117 116 static bool pf_migration_supported(struct xe_gt *gt) 118 117 { 119 - xe_gt_assert(gt, IS_SRIOV_PF(gt_to_xe(gt))); 120 - return gt->sriov.pf.migration.supported; 118 + return xe_sriov_pf_migration_supported(gt_to_xe(gt)); 121 119 } 122 120 123 121 static struct mutex *pf_migration_mutex(struct xe_gt *gt) ··· 382 382 } 383 383 #endif /* CONFIG_DEBUG_FS */ 384 384 385 - static bool pf_check_migration_support(struct xe_gt *gt) 386 - { 387 - /* XXX: for now this is for feature enabling only */ 388 - return IS_ENABLED(CONFIG_DRM_XE_DEBUG); 389 - } 390 - 391 385 /** 392 386 * xe_gt_sriov_pf_migration_init() - Initialize support for VF migration. 393 387 * @gt: the &xe_gt ··· 396 402 int err; 397 403 398 404 xe_gt_assert(gt, IS_SRIOV_PF(xe)); 399 - 400 - gt->sriov.pf.migration.supported = pf_check_migration_support(gt); 401 405 402 406 if (!pf_migration_supported(gt)) 403 407 return 0;
-3
drivers/gpu/drm/xe/xe_gt_sriov_pf_migration_types.h
··· 30 30 * Used by the PF driver to maintain non-VF specific per-GT data. 31 31 */ 32 32 struct xe_gt_sriov_pf_migration { 33 - /** @supported: indicates whether the feature is supported */ 34 - bool supported; 35 - 36 33 /** @snapshot_lock: protects all VFs snapshots */ 37 34 struct mutex snapshot_lock; 38 35 };
+5
drivers/gpu/drm/xe/xe_sriov_pf.c
··· 15 15 #include "xe_sriov.h" 16 16 #include "xe_sriov_pf.h" 17 17 #include "xe_sriov_pf_helpers.h" 18 + #include "xe_sriov_pf_migration.h" 18 19 #include "xe_sriov_pf_service.h" 19 20 #include "xe_sriov_pf_sysfs.h" 20 21 #include "xe_sriov_printk.h" ··· 100 99 return -ENOMEM; 101 100 102 101 err = drmm_mutex_init(&xe->drm, &xe->sriov.pf.master_lock); 102 + if (err) 103 + return err; 104 + 105 + err = xe_sriov_pf_migration_init(xe); 103 106 if (err) 104 107 return err; 105 108
+41
drivers/gpu/drm/xe/xe_sriov_pf_migration.c
··· 1 + // SPDX-License-Identifier: MIT 2 + /* 3 + * Copyright © 2025 Intel Corporation 4 + */ 5 + 6 + #include "xe_sriov.h" 7 + #include "xe_sriov_pf_migration.h" 8 + 9 + /** 10 + * xe_sriov_pf_migration_supported() - Check if SR-IOV VF migration is supported by the device 11 + * @xe: the &xe_device 12 + * 13 + * Return: true if migration is supported, false otherwise 14 + */ 15 + bool xe_sriov_pf_migration_supported(struct xe_device *xe) 16 + { 17 + xe_assert(xe, IS_SRIOV_PF(xe)); 18 + 19 + return xe->sriov.pf.migration.supported; 20 + } 21 + 22 + static bool pf_check_migration_support(struct xe_device *xe) 23 + { 24 + /* XXX: for now this is for feature enabling only */ 25 + return IS_ENABLED(CONFIG_DRM_XE_DEBUG); 26 + } 27 + 28 + /** 29 + * xe_sriov_pf_migration_init() - Initialize support for SR-IOV VF migration. 30 + * @xe: the &xe_device 31 + * 32 + * Return: 0 on success or a negative error code on failure. 33 + */ 34 + int xe_sriov_pf_migration_init(struct xe_device *xe) 35 + { 36 + xe_assert(xe, IS_SRIOV_PF(xe)); 37 + 38 + xe->sriov.pf.migration.supported = pf_check_migration_support(xe); 39 + 40 + return 0; 41 + }
+16
drivers/gpu/drm/xe/xe_sriov_pf_migration.h
··· 1 + /* SPDX-License-Identifier: MIT */ 2 + /* 3 + * Copyright © 2025 Intel Corporation 4 + */ 5 + 6 + #ifndef _XE_SRIOV_PF_MIGRATION_H_ 7 + #define _XE_SRIOV_PF_MIGRATION_H_ 8 + 9 + #include <linux/types.h> 10 + 11 + struct xe_device; 12 + 13 + int xe_sriov_pf_migration_init(struct xe_device *xe); 14 + bool xe_sriov_pf_migration_supported(struct xe_device *xe); 15 + 16 + #endif
+19
drivers/gpu/drm/xe/xe_sriov_pf_migration_types.h
··· 1 + /* SPDX-License-Identifier: MIT */ 2 + /* 3 + * Copyright © 2025 Intel Corporation 4 + */ 5 + 6 + #ifndef _XE_SRIOV_PF_MIGRATION_TYPES_H_ 7 + #define _XE_SRIOV_PF_MIGRATION_TYPES_H_ 8 + 9 + #include <linux/types.h> 10 + 11 + /** 12 + * struct xe_sriov_pf_migration - Xe device level VF migration data 13 + */ 14 + struct xe_sriov_pf_migration { 15 + /** @supported: indicates whether VF migration feature is supported */ 16 + bool supported; 17 + }; 18 + 19 + #endif
+4
drivers/gpu/drm/xe/xe_sriov_pf_types.h
··· 10 10 #include <linux/types.h> 11 11 12 12 #include "xe_guard.h" 13 + #include "xe_sriov_pf_migration_types.h" 13 14 #include "xe_sriov_pf_provision_types.h" 14 15 #include "xe_sriov_pf_service_types.h" 15 16 ··· 48 47 49 48 /** @provision: device level provisioning data. */ 50 49 struct xe_sriov_pf_provision provision; 50 + 51 + /** @migration: device level migration data. */ 52 + struct xe_sriov_pf_migration migration; 51 53 52 54 /** @service: device level service data. */ 53 55 struct xe_sriov_pf_service service;