]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/xe: Use the filelist from drm for ccs_mode change
authorBalasubramani Vivekanandan <balasubramani.vivekanandan@intel.com>
Tue, 8 Oct 2024 07:36:28 +0000 (13:06 +0530)
committerLucas De Marchi <lucas.demarchi@intel.com>
Mon, 4 Nov 2024 16:12:30 +0000 (08:12 -0800)
Drop the exclusive client count tracking and use the filelist from the
drm to track the active clients. This also ensures the clients created
internally by the driver won't block changing the ccs mode.

Fixes: ce8c161cbad4 ("drm/xe: Add ref counting for xe_file")
Signed-off-by: Balasubramani Vivekanandan <balasubramani.vivekanandan@intel.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20241008073628.377433-3-balasubramani.vivekanandan@intel.com
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
(cherry picked from commit 1c35f1ed1fe3c649f8c16214d0d3dd828b5265d9)
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
drivers/gpu/drm/xe/xe_device.c
drivers/gpu/drm/xe/xe_device_types.h
drivers/gpu/drm/xe/xe_gt_ccs_mode.c

index 10fd4601b9f2a4ed546717e939dc37c87fb6ca8a..a1987b554a8d2aa42b29301f2853edddfda7fda5 100644 (file)
@@ -87,10 +87,6 @@ static int xe_file_open(struct drm_device *dev, struct drm_file *file)
        mutex_init(&xef->exec_queue.lock);
        xa_init_flags(&xef->exec_queue.xa, XA_FLAGS_ALLOC1);
 
-       spin_lock(&xe->clients.lock);
-       xe->clients.count++;
-       spin_unlock(&xe->clients.lock);
-
        file->driver_priv = xef;
        kref_init(&xef->refcount);
 
@@ -107,17 +103,12 @@ static int xe_file_open(struct drm_device *dev, struct drm_file *file)
 static void xe_file_destroy(struct kref *ref)
 {
        struct xe_file *xef = container_of(ref, struct xe_file, refcount);
-       struct xe_device *xe = xef->xe;
 
        xa_destroy(&xef->exec_queue.xa);
        mutex_destroy(&xef->exec_queue.lock);
        xa_destroy(&xef->vm.xa);
        mutex_destroy(&xef->vm.lock);
 
-       spin_lock(&xe->clients.lock);
-       xe->clients.count--;
-       spin_unlock(&xe->clients.lock);
-
        xe_drm_client_put(xef->client);
        kfree(xef->process_name);
        kfree(xef);
@@ -333,7 +324,6 @@ struct xe_device *xe_device_create(struct pci_dev *pdev,
        xe->info.force_execlist = xe_modparam.force_execlist;
 
        spin_lock_init(&xe->irq.lock);
-       spin_lock_init(&xe->clients.lock);
 
        init_waitqueue_head(&xe->ufence_wq);
 
index 09d731a9125cecfa6577eb5f406572f74777806a..687f3a9039bb1fb362fa9ee8c6cebd0a948d45eb 100644 (file)
@@ -353,15 +353,6 @@ struct xe_device {
                struct workqueue_struct *wq;
        } sriov;
 
-       /** @clients: drm clients info */
-       struct {
-               /** @clients.lock: Protects drm clients info */
-               spinlock_t lock;
-
-               /** @clients.count: number of drm clients */
-               u64 count;
-       } clients;
-
        /** @usm: unified memory state */
        struct {
                /** @usm.asid: convert a ASID to VM */
index b8d832c8f9078df4f3f925c9078edddeb2147a72..ffcbd05671fc0f6b78edd52915b50367aa1510a3 100644 (file)
@@ -139,9 +139,10 @@ ccs_mode_store(struct device *kdev, struct device_attribute *attr,
        }
 
        /* 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);
+       mutex_lock(&xe->drm.filelist_mutex);
+       if (!list_empty(&xe->drm.filelist)) {
+               mutex_unlock(&xe->drm.filelist_mutex);
+               xe_gt_dbg(gt, "Rejecting compute mode change as there are active drm clients\n");
                return -EBUSY;
        }
 
@@ -152,7 +153,7 @@ ccs_mode_store(struct device *kdev, struct device_attribute *attr,
                xe_gt_reset_async(gt);
        }
 
-       spin_unlock(&xe->clients.lock);
+       mutex_unlock(&xe->drm.filelist_mutex);
 
        return count;
 }