From 78e2701a2614720d8c47b3a8490bf61c29718e8a Mon Sep 17 00:00:00 2001 From: Niranjana Vishwanathapura Date: Wed, 1 Nov 2023 19:02:53 +0000 Subject: drm/xe: Avoid any races around ccs_mode update Ensure that there are no drm clients when changing CCS mode. Allow exec_queue creation only with enabled CCS engines. v2: Rebase Reviewed-by: Andi Shyti Signed-off-by: Niranjana Vishwanathapura Signed-off-by: Rodrigo Vivi --- drivers/gpu/drm/xe/xe_gt_ccs_mode.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'drivers/gpu/drm/xe/xe_gt_ccs_mode.c') diff --git a/drivers/gpu/drm/xe/xe_gt_ccs_mode.c b/drivers/gpu/drm/xe/xe_gt_ccs_mode.c index 723cf77c830a..529fc286cd06 100644 --- a/drivers/gpu/drm/xe/xe_gt_ccs_mode.c +++ b/drivers/gpu/drm/xe/xe_gt_ccs_mode.c @@ -105,6 +105,7 @@ ccs_mode_store(struct device *kdev, struct device_attribute *attr, const char *buff, size_t count) { struct xe_gt *gt = kobj_to_gt(&kdev->kobj); + struct xe_device *xe = gt_to_xe(gt); u32 num_engines, num_slices; int ret; @@ -123,12 +124,21 @@ ccs_mode_store(struct device *kdev, struct device_attribute *attr, return -EINVAL; } + /* CCS mode can only be updated when there are no drm clients */ + spin_lock(&xe->clients.lock); + if (xe->clients.count) { + spin_unlock(&xe->clients.lock); + return -EBUSY; + } + if (gt->ccs_mode != num_engines) { xe_gt_info(gt, "Setting compute mode to %d\n", num_engines); gt->ccs_mode = num_engines; xe_gt_reset_async(gt); } + spin_unlock(&xe->clients.lock); + return count; } -- cgit v1.2.3