aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2016-08-05 05:14:21 -0400
committerChris Wilson <chris@chris-wilson.co.uk>2016-08-05 05:54:42 -0400
commit9ad3676148511d6af72be6f3638e361fd86e1f7b (patch)
treec7e32698c73443ae1de563d0d342e121b910c4c4
parente883d73503205d1eaaf049b835bf135b46738f57 (diff)
drm/i915: Remove locking for get_tiling
Since we are not concerned with userspace racing itself with set-tiling (the order is indeterminant even if we take a lock), then we can safely read back the single obj->tiling_mode and do the static lookup of swizzle mode without having to take a lock. get-tiling is reasonably frequent due to the back-channel passing around of tiling parameters in DRI2/DRI3. v2: Make tiling_mode a full unsigned int so that we can trivially use it with READ_ONCE(). Separating it out into manual control over the flags field was too noisy for a simple patch. Note that we could use the lower bits of obj->stride for the tiling mode. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/1470388464-28458-16-git-send-email-chris@chris-wilson.co.uk
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h15
-rw-r--r--drivers/gpu/drm/i915/i915_gem_tiling.c10
2 files changed, 11 insertions, 14 deletions
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 31a614fe9ed7..f18d8761305c 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2183,10 +2183,6 @@ struct drm_i915_gem_object {
2183 unsigned int madv:2; 2183 unsigned int madv:2;
2184 2184
2185 /** 2185 /**
2186 * Current tiling mode for the object.
2187 */
2188 unsigned int tiling_mode:2;
2189 /**
2190 * Whether the tiling parameters for the currently associated fence 2186 * Whether the tiling parameters for the currently associated fence
2191 * register have changed. Note that for the purposes of tracking 2187 * register have changed. Note that for the purposes of tracking
2192 * tiling changes we also treat the unfenced register, the register 2188 * tiling changes we also treat the unfenced register, the register
@@ -2218,6 +2214,14 @@ struct drm_i915_gem_object {
2218 2214
2219 atomic_t frontbuffer_bits; 2215 atomic_t frontbuffer_bits;
2220 2216
2217 /**
2218 * Current tiling mode for the object.
2219 */
2220 unsigned int tiling_mode;
2221
2222 /** Current tiling stride for the object, if it's tiled. */
2223 uint32_t stride;
2224
2221 unsigned int has_wc_mmap; 2225 unsigned int has_wc_mmap;
2222 /** Count of VMA actually bound by this object */ 2226 /** Count of VMA actually bound by this object */
2223 unsigned int bind_count; 2227 unsigned int bind_count;
@@ -2245,9 +2249,6 @@ struct drm_i915_gem_object {
2245 struct i915_gem_active last_write; 2249 struct i915_gem_active last_write;
2246 struct i915_gem_active last_fence; 2250 struct i915_gem_active last_fence;
2247 2251
2248 /** Current tiling stride for the object, if it's tiled. */
2249 uint32_t stride;
2250
2251 /** References from framebuffers, locks out tiling changes. */ 2252 /** References from framebuffers, locks out tiling changes. */
2252 unsigned long framebuffer_references; 2253 unsigned long framebuffer_references;
2253 2254
diff --git a/drivers/gpu/drm/i915/i915_gem_tiling.c b/drivers/gpu/drm/i915/i915_gem_tiling.c
index b7f9875f69b4..c0e01333bddf 100644
--- a/drivers/gpu/drm/i915/i915_gem_tiling.c
+++ b/drivers/gpu/drm/i915/i915_gem_tiling.c
@@ -303,10 +303,8 @@ i915_gem_get_tiling(struct drm_device *dev, void *data,
303 if (!obj) 303 if (!obj)
304 return -ENOENT; 304 return -ENOENT;
305 305
306 mutex_lock(&dev->struct_mutex); 306 args->tiling_mode = READ_ONCE(obj->tiling_mode);
307 307 switch (args->tiling_mode) {
308 args->tiling_mode = obj->tiling_mode;
309 switch (obj->tiling_mode) {
310 case I915_TILING_X: 308 case I915_TILING_X:
311 args->swizzle_mode = dev_priv->mm.bit_6_swizzle_x; 309 args->swizzle_mode = dev_priv->mm.bit_6_swizzle_x;
312 break; 310 break;
@@ -330,8 +328,6 @@ i915_gem_get_tiling(struct drm_device *dev, void *data,
330 if (args->swizzle_mode == I915_BIT_6_SWIZZLE_9_10_17) 328 if (args->swizzle_mode == I915_BIT_6_SWIZZLE_9_10_17)
331 args->swizzle_mode = I915_BIT_6_SWIZZLE_9_10; 329 args->swizzle_mode = I915_BIT_6_SWIZZLE_9_10;
332 330
333 i915_gem_object_put(obj); 331 i915_gem_object_put_unlocked(obj);
334 mutex_unlock(&dev->struct_mutex);
335
336 return 0; 332 return 0;
337} 333}