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

Configure Feed

Select the types of activity you want to include in your feed.

drm/xe: Mutual exclusivity between CCS-mode and PF

Due to SLA agreement between PF and VFs, currently we block CCS
mode changes if driver is running as PF, even if there are no VFs
enabled yet. Use lockdown mechanism provided by the PF to relax
that limitation and still enforce above VFs related requirements.

Reviewed-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Signed-off-by: Nareshkumar Gollakoti <naresh.kumar.g@intel.com>
Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Link: https://patch.msgid.link/20260202170810.1393147-6-naresh.kumar.g@intel.com

authored by

Nareshkumar Gollakoti and committed by
Michal Wajdeczko
9b5e995e 4e8f602a

+28 -14
+28 -14
drivers/gpu/drm/xe/xe_gt_ccs_mode.c
··· 13 13 #include "xe_gt_sysfs.h" 14 14 #include "xe_mmio.h" 15 15 #include "xe_sriov.h" 16 + #include "xe_sriov_pf.h" 16 17 17 18 static void __xe_gt_apply_ccs_mode(struct xe_gt *gt, u32 num_engines) 18 19 { ··· 89 88 __xe_gt_apply_ccs_mode(gt, gt->ccs_mode); 90 89 } 91 90 91 + static bool gt_ccs_mode_default(struct xe_gt *gt) 92 + { 93 + return gt->ccs_mode == 1; 94 + } 95 + 92 96 static ssize_t 93 97 num_cslices_show(struct device *kdev, 94 98 struct device_attribute *attr, char *buf) ··· 123 117 u32 num_engines, num_slices; 124 118 int ret; 125 119 126 - if (IS_SRIOV(xe)) { 127 - xe_gt_dbg(gt, "Can't change compute mode when running as %s\n", 128 - xe_sriov_mode_to_string(xe_device_sriov_mode(xe))); 129 - return -EOPNOTSUPP; 130 - } 131 - 132 120 ret = kstrtou32(buff, 0, &num_engines); 133 121 if (ret) 134 122 return ret; ··· 139 139 } 140 140 141 141 /* CCS mode can only be updated when there are no drm clients */ 142 - mutex_lock(&xe->drm.filelist_mutex); 142 + guard(mutex)(&xe->drm.filelist_mutex); 143 143 if (!list_empty(&xe->drm.filelist)) { 144 - mutex_unlock(&xe->drm.filelist_mutex); 145 144 xe_gt_dbg(gt, "Rejecting compute mode change as there are active drm clients\n"); 146 145 return -EBUSY; 147 146 } 148 147 149 - if (gt->ccs_mode != num_engines) { 150 - xe_gt_info(gt, "Setting compute mode to %d\n", num_engines); 151 - gt->ccs_mode = num_engines; 152 - xe_gt_record_user_engines(gt); 153 - xe_gt_reset(gt); 148 + if (gt->ccs_mode == num_engines) 149 + return count; 150 + 151 + /* 152 + * Changing default CCS mode is only allowed when there 153 + * are no VFs. Try to lockdown PF to find out. 154 + */ 155 + if (gt_ccs_mode_default(gt) && IS_SRIOV_PF(xe)) { 156 + ret = xe_sriov_pf_lockdown(xe); 157 + if (ret) { 158 + xe_gt_dbg(gt, "Can't change CCS Mode: VFs are enabled\n"); 159 + return ret; 160 + } 154 161 } 155 162 156 - mutex_unlock(&xe->drm.filelist_mutex); 163 + xe_gt_info(gt, "Setting compute mode to %d\n", num_engines); 164 + gt->ccs_mode = num_engines; 165 + xe_gt_record_user_engines(gt); 166 + xe_gt_reset(gt); 167 + 168 + /* We may end PF lockdown once CCS mode is default again */ 169 + if (gt_ccs_mode_default(gt) && IS_SRIOV_PF(xe)) 170 + xe_sriov_pf_end_lockdown(xe); 157 171 158 172 return count; 159 173 }