Skip to content

Commit 4b468a9

Browse files
baluviveklucasdemarchi
authored andcommitted
drm/xe: Use the filelist from drm for ccs_mode change
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: ce8c161 ("drm/xe: Add ref counting for xe_file") Signed-off-by: Balasubramani Vivekanandan <[email protected]> Reviewed-by: Lucas De Marchi <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Lucas De Marchi <[email protected]> (cherry picked from commit 1c35f1e) Signed-off-by: Lucas De Marchi <[email protected]>
1 parent 7fd3fa0 commit 4b468a9

File tree

3 files changed

+5
-23
lines changed

3 files changed

+5
-23
lines changed

drivers/gpu/drm/xe/xe_device.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,6 @@ static int xe_file_open(struct drm_device *dev, struct drm_file *file)
8787
mutex_init(&xef->exec_queue.lock);
8888
xa_init_flags(&xef->exec_queue.xa, XA_FLAGS_ALLOC1);
8989

90-
spin_lock(&xe->clients.lock);
91-
xe->clients.count++;
92-
spin_unlock(&xe->clients.lock);
93-
9490
file->driver_priv = xef;
9591
kref_init(&xef->refcount);
9692

@@ -107,17 +103,12 @@ static int xe_file_open(struct drm_device *dev, struct drm_file *file)
107103
static void xe_file_destroy(struct kref *ref)
108104
{
109105
struct xe_file *xef = container_of(ref, struct xe_file, refcount);
110-
struct xe_device *xe = xef->xe;
111106

112107
xa_destroy(&xef->exec_queue.xa);
113108
mutex_destroy(&xef->exec_queue.lock);
114109
xa_destroy(&xef->vm.xa);
115110
mutex_destroy(&xef->vm.lock);
116111

117-
spin_lock(&xe->clients.lock);
118-
xe->clients.count--;
119-
spin_unlock(&xe->clients.lock);
120-
121112
xe_drm_client_put(xef->client);
122113
kfree(xef->process_name);
123114
kfree(xef);
@@ -333,7 +324,6 @@ struct xe_device *xe_device_create(struct pci_dev *pdev,
333324
xe->info.force_execlist = xe_modparam.force_execlist;
334325

335326
spin_lock_init(&xe->irq.lock);
336-
spin_lock_init(&xe->clients.lock);
337327

338328
init_waitqueue_head(&xe->ufence_wq);
339329

drivers/gpu/drm/xe/xe_device_types.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -353,15 +353,6 @@ struct xe_device {
353353
struct workqueue_struct *wq;
354354
} sriov;
355355

356-
/** @clients: drm clients info */
357-
struct {
358-
/** @clients.lock: Protects drm clients info */
359-
spinlock_t lock;
360-
361-
/** @clients.count: number of drm clients */
362-
u64 count;
363-
} clients;
364-
365356
/** @usm: unified memory state */
366357
struct {
367358
/** @usm.asid: convert a ASID to VM */

drivers/gpu/drm/xe/xe_gt_ccs_mode.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,10 @@ ccs_mode_store(struct device *kdev, struct device_attribute *attr,
139139
}
140140

141141
/* CCS mode can only be updated when there are no drm clients */
142-
spin_lock(&xe->clients.lock);
143-
if (xe->clients.count) {
144-
spin_unlock(&xe->clients.lock);
142+
mutex_lock(&xe->drm.filelist_mutex);
143+
if (!list_empty(&xe->drm.filelist)) {
144+
mutex_unlock(&xe->drm.filelist_mutex);
145+
xe_gt_dbg(gt, "Rejecting compute mode change as there are active drm clients\n");
145146
return -EBUSY;
146147
}
147148

@@ -152,7 +153,7 @@ ccs_mode_store(struct device *kdev, struct device_attribute *attr,
152153
xe_gt_reset_async(gt);
153154
}
154155

155-
spin_unlock(&xe->clients.lock);
156+
mutex_unlock(&xe->drm.filelist_mutex);
156157

157158
return count;
158159
}

0 commit comments

Comments
 (0)