diff options
author | David Herrmann <dh.herrmann@gmail.com> | 2014-07-23 03:01:12 -0400 |
---|---|---|
committer | David Herrmann <dh.herrmann@gmail.com> | 2014-08-05 10:07:45 -0400 |
commit | 9f8d21ea276177547725a60cefc1b6da742f14d3 (patch) | |
tree | 1511b996ef09915f43246b7ecf145b2bd2ac349b /drivers/gpu/drm/drm_context.c | |
parent | a91576d7916f6cce76d30303e60e1ac47cf4a76d (diff) |
drm: extract legacy ctxbitmap flushing
The ctxbitmap code is only used by legacy drivers so lets try to keep it
as separated as possible. Furthermore, the locking is non-obvious and
kinda weird with ctxlist_mutex *and* struct_mutex. Keeping all ctxbitmap
access in one file is much easier to review and makes drm_release() more
readable.
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Diffstat (limited to 'drivers/gpu/drm/drm_context.c')
-rw-r--r-- | drivers/gpu/drm/drm_context.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_context.c b/drivers/gpu/drm/drm_context.c index a4b017b6849e..c045505978f1 100644 --- a/drivers/gpu/drm/drm_context.c +++ b/drivers/gpu/drm/drm_context.c | |||
@@ -111,6 +111,36 @@ void drm_ctxbitmap_cleanup(struct drm_device * dev) | |||
111 | mutex_unlock(&dev->struct_mutex); | 111 | mutex_unlock(&dev->struct_mutex); |
112 | } | 112 | } |
113 | 113 | ||
114 | /** | ||
115 | * drm_ctxbitmap_flush() - Flush all contexts owned by a file | ||
116 | * @dev: DRM device to operate on | ||
117 | * @file: Open file to flush contexts for | ||
118 | * | ||
119 | * This iterates over all contexts on @dev and drops them if they're owned by | ||
120 | * @file. Note that after this call returns, new contexts might be added if | ||
121 | * the file is still alive. | ||
122 | */ | ||
123 | void drm_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file) | ||
124 | { | ||
125 | struct drm_ctx_list *pos, *tmp; | ||
126 | |||
127 | mutex_lock(&dev->ctxlist_mutex); | ||
128 | |||
129 | list_for_each_entry_safe(pos, tmp, &dev->ctxlist, head) { | ||
130 | if (pos->tag == file && | ||
131 | pos->handle != DRM_KERNEL_CONTEXT) { | ||
132 | if (dev->driver->context_dtor) | ||
133 | dev->driver->context_dtor(dev, pos->handle); | ||
134 | |||
135 | drm_ctxbitmap_free(dev, pos->handle); | ||
136 | list_del(&pos->head); | ||
137 | kfree(pos); | ||
138 | } | ||
139 | } | ||
140 | |||
141 | mutex_unlock(&dev->ctxlist_mutex); | ||
142 | } | ||
143 | |||
114 | /*@}*/ | 144 | /*@}*/ |
115 | 145 | ||
116 | /******************************************************************/ | 146 | /******************************************************************/ |