blob: 4f83e331f5981da49a7e173876b11a7f733d13e2 [file] [log] [blame]
Eric Anholt673a3942008-07-30 12:06:12 -07001/*
2 * Copyright © 2008 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 *
23 * Authors:
24 * Eric Anholt <eric@anholt.net>
25 *
26 */
27
David Howells760285e2012-10-02 18:01:07 +010028#include <linux/string.h>
29#include <linux/bitops.h>
30#include <drm/drmP.h>
31#include <drm/i915_drm.h>
Eric Anholt673a3942008-07-30 12:06:12 -070032#include "i915_drv.h"
33
Daniel Vetter3271dca2015-07-24 17:40:15 +020034/**
35 * DOC: buffer object tiling
Eric Anholt673a3942008-07-30 12:06:12 -070036 *
Chris Wilson111dbca2017-01-10 12:10:44 +000037 * i915_gem_set_tiling_ioctl() and i915_gem_get_tiling_ioctl() is the userspace
38 * interface to declare fence register requirements.
Eric Anholt673a3942008-07-30 12:06:12 -070039 *
Daniel Vetter3271dca2015-07-24 17:40:15 +020040 * In principle GEM doesn't care at all about the internal data layout of an
41 * object, and hence it also doesn't care about tiling or swizzling. There's two
42 * exceptions:
Eric Anholt673a3942008-07-30 12:06:12 -070043 *
Daniel Vetter3271dca2015-07-24 17:40:15 +020044 * - For X and Y tiling the hardware provides detilers for CPU access, so called
45 * fences. Since there's only a limited amount of them the kernel must manage
46 * these, and therefore userspace must tell the kernel the object tiling if it
47 * wants to use fences for detiling.
48 * - On gen3 and gen4 platforms have a swizzling pattern for tiled objects which
49 * depends upon the physical page frame number. When swapping such objects the
50 * page frame number might change and the kernel must be able to fix this up
51 * and hence now the tiling. Note that on a subset of platforms with
52 * asymmetric memory channel population the swizzling pattern changes in an
53 * unknown way, and for those the kernel simply forbids swapping completely.
Eric Anholt673a3942008-07-30 12:06:12 -070054 *
Daniel Vetter3271dca2015-07-24 17:40:15 +020055 * Since neither of this applies for new tiling layouts on modern platforms like
56 * W, Ys and Yf tiling GEM only allows object tiling to be set to X or Y tiled.
57 * Anything else can be handled in userspace entirely without the kernel's
58 * invovlement.
Eric Anholt673a3942008-07-30 12:06:12 -070059 */
60
Chris Wilson91d4e0aa2017-01-09 16:16:13 +000061/**
62 * i915_gem_fence_size - required global GTT size for a fence
63 * @i915: i915 device
64 * @size: object size
65 * @tiling: tiling mode
66 * @stride: tiling stride
67 *
68 * Return the required global GTT size for a fence (view of a tiled object),
69 * taking into account potential fence register mapping.
70 */
71u32 i915_gem_fence_size(struct drm_i915_private *i915,
72 u32 size, unsigned int tiling, unsigned int stride)
73{
74 u32 ggtt_size;
75
76 GEM_BUG_ON(!size);
77
78 if (tiling == I915_TILING_NONE)
79 return size;
80
81 GEM_BUG_ON(!stride);
82
83 if (INTEL_GEN(i915) >= 4) {
84 stride *= i915_gem_tile_height(tiling);
85 GEM_BUG_ON(stride & 4095);
86 return roundup(size, stride);
87 }
88
89 /* Previous chips need a power-of-two fence region when tiling */
90 if (IS_GEN3(i915))
91 ggtt_size = 1024*1024;
92 else
93 ggtt_size = 512*1024;
94
95 while (ggtt_size < size)
96 ggtt_size <<= 1;
97
98 return ggtt_size;
99}
100
101/**
102 * i915_gem_fence_alignment - required global GTT alignment for a fence
103 * @i915: i915 device
104 * @size: object size
105 * @tiling: tiling mode
106 * @stride: tiling stride
107 *
108 * Return the required global GTT alignment for a fence (a view of a tiled
109 * object), taking into account potential fence register mapping.
110 */
111u32 i915_gem_fence_alignment(struct drm_i915_private *i915, u32 size,
112 unsigned int tiling, unsigned int stride)
113{
114 GEM_BUG_ON(!size);
115
116 /*
117 * Minimum alignment is 4k (GTT page size), but might be greater
118 * if a fence register is needed for the object.
119 */
120 if (INTEL_GEN(i915) >= 4 || tiling == I915_TILING_NONE)
121 return 4096;
122
123 /*
124 * Previous chips need to be aligned to the size of the smallest
125 * fence register that can contain the object.
126 */
127 return i915_gem_fence_size(i915, size, tiling, stride);
128}
129
Jesse Barnes0f973f22009-01-26 17:10:45 -0800130/* Check pitch constriants for all chips & tiling formats */
Chris Wilsona00b10c2010-09-24 21:15:47 +0100131static bool
Chris Wilson957870f2017-01-10 12:10:45 +0000132i915_tiling_ok(struct drm_i915_gem_object *obj,
133 unsigned int tiling, unsigned int stride)
Jesse Barnes0f973f22009-01-26 17:10:45 -0800134{
Chris Wilson957870f2017-01-10 12:10:45 +0000135 struct drm_i915_private *i915 = to_i915(obj->base.dev);
136 unsigned int tile_width;
Jesse Barnes0f973f22009-01-26 17:10:45 -0800137
138 /* Linear is always fine */
Chris Wilson957870f2017-01-10 12:10:45 +0000139 if (tiling == I915_TILING_NONE)
Jesse Barnes0f973f22009-01-26 17:10:45 -0800140 return true;
141
Chris Wilson957870f2017-01-10 12:10:45 +0000142 if (tiling > I915_TILING_LAST)
Chris Wilsondeeb1512016-08-05 10:14:22 +0100143 return false;
144
Daniel Vetter8d7773a2009-03-29 14:09:41 +0200145 /* check maximum stride & object size */
Ville Syrjälä3a062472013-04-09 11:45:05 +0300146 /* i965+ stores the end address of the gtt mapping in the fence
147 * reg, so dont bother to check the size */
Chris Wilson957870f2017-01-10 12:10:45 +0000148 if (INTEL_GEN(i915) >= 7) {
Ville Syrjälä3a062472013-04-09 11:45:05 +0300149 if (stride / 128 > GEN7_FENCE_MAX_PITCH_VAL)
150 return false;
Chris Wilson957870f2017-01-10 12:10:45 +0000151 } else if (INTEL_GEN(i915) >= 4) {
Daniel Vetter8d7773a2009-03-29 14:09:41 +0200152 if (stride / 128 > I965_FENCE_MAX_PITCH_VAL)
153 return false;
Chris Wilsona6c45cf2010-09-17 00:32:17 +0100154 } else {
Daniel Vetterc36a2a62010-04-17 15:12:03 +0200155 if (stride > 8192)
Daniel Vetter8d7773a2009-03-29 14:09:41 +0200156 return false;
Eric Anholte76a16d2009-05-26 17:44:56 -0700157
Chris Wilson957870f2017-01-10 12:10:45 +0000158 if (IS_GEN3(i915)) {
159 if (obj->base.size > I830_FENCE_MAX_SIZE_VAL << 20)
Daniel Vetterc36a2a62010-04-17 15:12:03 +0200160 return false;
161 } else {
Chris Wilson957870f2017-01-10 12:10:45 +0000162 if (obj->base.size > I830_FENCE_MAX_SIZE_VAL << 19)
Daniel Vetterc36a2a62010-04-17 15:12:03 +0200163 return false;
164 }
Daniel Vetter8d7773a2009-03-29 14:09:41 +0200165 }
166
Chris Wilson957870f2017-01-10 12:10:45 +0000167 if (IS_GEN2(i915) ||
168 (tiling == I915_TILING_Y && HAS_128_BYTE_Y_TILING(i915)))
169 tile_width = 128;
170 else
171 tile_width = 512;
172
173 if (stride & (tile_width - 1))
Ville Syrjäläfe48d8d2013-04-09 20:09:13 +0300174 return false;
175
Jesse Barnes0f973f22009-01-26 17:10:45 -0800176 /* 965+ just needs multiples of tile width */
Chris Wilson957870f2017-01-10 12:10:45 +0000177 if (INTEL_GEN(i915) >= 4)
Jesse Barnes0f973f22009-01-26 17:10:45 -0800178 return true;
Jesse Barnes0f973f22009-01-26 17:10:45 -0800179
180 /* Pre-965 needs power of two tile widths */
Chris Wilson957870f2017-01-10 12:10:45 +0000181 return is_power_of_2(stride);
Jesse Barnes0f973f22009-01-26 17:10:45 -0800182}
183
Chris Wilson5b306942017-01-09 16:16:09 +0000184static bool i915_vma_fence_prepare(struct i915_vma *vma,
185 int tiling_mode, unsigned int stride)
Chris Wilson49ef5292016-08-18 17:17:00 +0100186{
Chris Wilson944397f2017-01-09 16:16:11 +0000187 struct drm_i915_private *i915 = vma->vm->i915;
188 u32 size, alignment;
Chris Wilson49ef5292016-08-18 17:17:00 +0100189
190 if (!i915_vma_is_map_and_fenceable(vma))
191 return true;
192
Chris Wilson91d4e0aa2017-01-09 16:16:13 +0000193 size = i915_gem_fence_size(i915, vma->size, tiling_mode, stride);
Chris Wilson49ef5292016-08-18 17:17:00 +0100194 if (vma->node.size < size)
195 return false;
196
Chris Wilson91d4e0aa2017-01-09 16:16:13 +0000197 alignment = i915_gem_fence_alignment(i915, vma->size, tiling_mode, stride);
Chris Wilson944397f2017-01-09 16:16:11 +0000198 if (vma->node.start & (alignment - 1))
Chris Wilson49ef5292016-08-18 17:17:00 +0100199 return false;
200
201 return true;
202}
203
Chris Wilsonf23eda82016-08-15 10:48:53 +0100204/* Make the current GTT allocation valid for the change in tiling. */
205static int
Chris Wilson5b306942017-01-09 16:16:09 +0000206i915_gem_object_fence_prepare(struct drm_i915_gem_object *obj,
207 int tiling_mode, unsigned int stride)
Chris Wilson52dc7d32009-06-06 09:46:01 +0100208{
Chris Wilsonf23eda82016-08-15 10:48:53 +0100209 struct i915_vma *vma;
Chris Wilson49ef5292016-08-18 17:17:00 +0100210 int ret;
Chris Wilson52dc7d32009-06-06 09:46:01 +0100211
212 if (tiling_mode == I915_TILING_NONE)
Chris Wilsonf23eda82016-08-15 10:48:53 +0100213 return 0;
Chris Wilson52dc7d32009-06-06 09:46:01 +0100214
Chris Wilson49ef5292016-08-18 17:17:00 +0100215 list_for_each_entry(vma, &obj->vma_list, obj_link) {
Chris Wilson944397f2017-01-09 16:16:11 +0000216 if (!i915_vma_is_ggtt(vma))
217 break;
218
Chris Wilson5b306942017-01-09 16:16:09 +0000219 if (i915_vma_fence_prepare(vma, tiling_mode, stride))
Chris Wilson49ef5292016-08-18 17:17:00 +0100220 continue;
Chris Wilsonf23eda82016-08-15 10:48:53 +0100221
Chris Wilson49ef5292016-08-18 17:17:00 +0100222 ret = i915_vma_unbind(vma);
223 if (ret)
224 return ret;
Chris Wilsondf153152010-11-15 05:25:58 +0000225 }
226
Chris Wilsonf23eda82016-08-15 10:48:53 +0100227 return 0;
Chris Wilson52dc7d32009-06-06 09:46:01 +0100228}
229
Chris Wilson957870f2017-01-10 12:10:45 +0000230int
231i915_gem_object_set_tiling(struct drm_i915_gem_object *obj,
232 unsigned int tiling, unsigned int stride)
233{
234 struct drm_i915_private *i915 = to_i915(obj->base.dev);
235 struct i915_vma *vma;
236 int err;
237
238 /* Make sure we don't cross-contaminate obj->tiling_and_stride */
239 BUILD_BUG_ON(I915_TILING_LAST & STRIDE_MASK);
240
241 GEM_BUG_ON(!i915_tiling_ok(obj, tiling, stride));
242 GEM_BUG_ON(!stride ^ (tiling == I915_TILING_NONE));
243 lockdep_assert_held(&i915->drm.struct_mutex);
244
245 if ((tiling | stride) == obj->tiling_and_stride)
246 return 0;
247
248 if (obj->framebuffer_references)
249 return -EBUSY;
250
251 /* We need to rebind the object if its current allocation
252 * no longer meets the alignment restrictions for its new
253 * tiling mode. Otherwise we can just leave it alone, but
254 * need to ensure that any fence register is updated before
255 * the next fenced (either through the GTT or by the BLT unit
256 * on older GPUs) access.
257 *
258 * After updating the tiling parameters, we then flag whether
259 * we need to update an associated fence register. Note this
260 * has to also include the unfenced register the GPU uses
261 * whilst executing a fenced command for an untiled object.
262 */
263
264 err = i915_gem_object_fence_prepare(obj, tiling, stride);
265 if (err)
266 return err;
267
268 /* If the memory has unknown (i.e. varying) swizzling, we pin the
269 * pages to prevent them being swapped out and causing corruption
270 * due to the change in swizzling.
271 */
272 mutex_lock(&obj->mm.lock);
273 if (obj->mm.pages &&
274 obj->mm.madv == I915_MADV_WILLNEED &&
275 i915->quirks & QUIRK_PIN_SWIZZLED_PAGES) {
276 if (tiling == I915_TILING_NONE) {
277 GEM_BUG_ON(!obj->mm.quirked);
278 __i915_gem_object_unpin_pages(obj);
279 obj->mm.quirked = false;
280 }
281 if (!i915_gem_object_is_tiled(obj)) {
282 GEM_BUG_ON(!obj->mm.quirked);
283 __i915_gem_object_pin_pages(obj);
284 obj->mm.quirked = true;
285 }
286 }
287 mutex_unlock(&obj->mm.lock);
288
289 list_for_each_entry(vma, &obj->vma_list, obj_link) {
290 if (!i915_vma_is_ggtt(vma))
291 break;
292
293 vma->fence_size =
294 i915_gem_fence_size(i915, vma->size, tiling, stride);
295 vma->fence_alignment =
296 i915_gem_fence_alignment(i915,
297 vma->size, tiling, stride);
298
299 if (vma->fence)
300 vma->fence->dirty = true;
301 }
302
303 obj->tiling_and_stride = tiling | stride;
304
305 /* Force the fence to be reacquired for GTT access */
306 i915_gem_release_mmap(obj);
307
308 /* Try to preallocate memory required to save swizzling on put-pages */
309 if (i915_gem_object_needs_bit17_swizzle(obj)) {
310 if (!obj->bit_17) {
311 obj->bit_17 = kcalloc(BITS_TO_LONGS(obj->base.size >> PAGE_SHIFT),
312 sizeof(long), GFP_KERNEL);
313 }
314 } else {
315 kfree(obj->bit_17);
316 obj->bit_17 = NULL;
317 }
318
319 return 0;
320}
321
Eric Anholt673a3942008-07-30 12:06:12 -0700322/**
Chris Wilson111dbca2017-01-10 12:10:44 +0000323 * i915_gem_set_tiling_ioctl - IOCTL handler to set tiling mode
Daniel Vetter3271dca2015-07-24 17:40:15 +0200324 * @dev: DRM device
325 * @data: data pointer for the ioctl
326 * @file: DRM file for the ioctl call
327 *
Eric Anholt673a3942008-07-30 12:06:12 -0700328 * Sets the tiling mode of an object, returning the required swizzling of
329 * bit 6 of addresses in the object.
Daniel Vetter3271dca2015-07-24 17:40:15 +0200330 *
331 * Called by the user via ioctl.
332 *
333 * Returns:
334 * Zero on success, negative errno on failure.
Eric Anholt673a3942008-07-30 12:06:12 -0700335 */
336int
Chris Wilson111dbca2017-01-10 12:10:44 +0000337i915_gem_set_tiling_ioctl(struct drm_device *dev, void *data,
338 struct drm_file *file)
Eric Anholt673a3942008-07-30 12:06:12 -0700339{
340 struct drm_i915_gem_set_tiling *args = data;
Chris Wilson05394f32010-11-08 19:18:58 +0000341 struct drm_i915_gem_object *obj;
Chris Wilson957870f2017-01-10 12:10:45 +0000342 int err;
Chris Wilson3e510a82016-08-05 10:14:23 +0100343
Chris Wilson03ac0642016-07-20 13:31:51 +0100344 obj = i915_gem_object_lookup(file, args->handle);
345 if (!obj)
Chris Wilsonbf79cb92010-08-04 14:19:46 +0100346 return -ENOENT;
Eric Anholt673a3942008-07-30 12:06:12 -0700347
Chris Wilson957870f2017-01-10 12:10:45 +0000348 if (!i915_tiling_ok(obj, args->tiling_mode, args->stride)) {
349 err = -EINVAL;
Chris Wilson6c31a612015-02-12 07:53:18 +0000350 goto err;
Daniel Vetter31770bd2010-04-23 23:01:01 +0200351 }
352
Eric Anholt673a3942008-07-30 12:06:12 -0700353 if (args->tiling_mode == I915_TILING_NONE) {
Eric Anholt673a3942008-07-30 12:06:12 -0700354 args->swizzle_mode = I915_BIT_6_SWIZZLE_NONE;
Chris Wilson52dc7d32009-06-06 09:46:01 +0100355 args->stride = 0;
Eric Anholt673a3942008-07-30 12:06:12 -0700356 } else {
357 if (args->tiling_mode == I915_TILING_X)
Chris Wilson957870f2017-01-10 12:10:45 +0000358 args->swizzle_mode = to_i915(dev)->mm.bit_6_swizzle_x;
Eric Anholt673a3942008-07-30 12:06:12 -0700359 else
Chris Wilson957870f2017-01-10 12:10:45 +0000360 args->swizzle_mode = to_i915(dev)->mm.bit_6_swizzle_y;
Eric Anholt280b7132009-03-12 16:56:27 -0700361
362 /* Hide bit 17 swizzling from the user. This prevents old Mesa
363 * from aborting the application on sw fallbacks to bit 17,
364 * and we use the pread/pwrite bit17 paths to swizzle for it.
365 * If there was a user that was relying on the swizzle
366 * information for drm_intel_bo_map()ed reads/writes this would
367 * break it, but we don't have any of those.
368 */
369 if (args->swizzle_mode == I915_BIT_6_SWIZZLE_9_17)
370 args->swizzle_mode = I915_BIT_6_SWIZZLE_9;
371 if (args->swizzle_mode == I915_BIT_6_SWIZZLE_9_10_17)
372 args->swizzle_mode = I915_BIT_6_SWIZZLE_9_10;
373
Eric Anholt673a3942008-07-30 12:06:12 -0700374 /* If we can't handle the swizzling, make it untiled. */
375 if (args->swizzle_mode == I915_BIT_6_SWIZZLE_UNKNOWN) {
376 args->tiling_mode = I915_TILING_NONE;
377 args->swizzle_mode = I915_BIT_6_SWIZZLE_NONE;
Chris Wilson52dc7d32009-06-06 09:46:01 +0100378 args->stride = 0;
Eric Anholt673a3942008-07-30 12:06:12 -0700379 }
380 }
Jesse Barnes0f973f22009-01-26 17:10:45 -0800381
Chris Wilson957870f2017-01-10 12:10:45 +0000382 err = mutex_lock_interruptible(&dev->struct_mutex);
383 if (err)
384 goto err;
Chris Wilson467cffb2011-03-07 10:42:03 +0000385
Chris Wilson957870f2017-01-10 12:10:45 +0000386 err = i915_gem_object_set_tiling(obj, args->tiling_mode, args->stride);
387 mutex_unlock(&dev->struct_mutex);
Chris Wilson49ef5292016-08-18 17:17:00 +0100388
Chris Wilson957870f2017-01-10 12:10:45 +0000389 /* We have to maintain this existing ABI... */
Chris Wilson3e510a82016-08-05 10:14:23 +0100390 args->stride = i915_gem_object_get_stride(obj);
391 args->tiling_mode = i915_gem_object_get_tiling(obj);
Chris Wilsone9b73c62012-12-03 21:03:14 +0000392
Chris Wilson6c31a612015-02-12 07:53:18 +0000393err:
Chris Wilsonf8c417c2016-07-20 13:31:53 +0100394 i915_gem_object_put(obj);
Chris Wilsonf23eda82016-08-15 10:48:53 +0100395 return err;
Eric Anholt673a3942008-07-30 12:06:12 -0700396}
397
398/**
Chris Wilson111dbca2017-01-10 12:10:44 +0000399 * i915_gem_get_tiling_ioctl - IOCTL handler to get tiling mode
Daniel Vetter3271dca2015-07-24 17:40:15 +0200400 * @dev: DRM device
401 * @data: data pointer for the ioctl
402 * @file: DRM file for the ioctl call
403 *
Eric Anholt673a3942008-07-30 12:06:12 -0700404 * Returns the current tiling mode and required bit 6 swizzling for the object.
Daniel Vetter3271dca2015-07-24 17:40:15 +0200405 *
406 * Called by the user via ioctl.
407 *
408 * Returns:
409 * Zero on success, negative errno on failure.
Eric Anholt673a3942008-07-30 12:06:12 -0700410 */
411int
Chris Wilson111dbca2017-01-10 12:10:44 +0000412i915_gem_get_tiling_ioctl(struct drm_device *dev, void *data,
413 struct drm_file *file)
Eric Anholt673a3942008-07-30 12:06:12 -0700414{
415 struct drm_i915_gem_get_tiling *args = data;
Chris Wilsonfac5e232016-07-04 11:34:36 +0100416 struct drm_i915_private *dev_priv = to_i915(dev);
Chris Wilson05394f32010-11-08 19:18:58 +0000417 struct drm_i915_gem_object *obj;
Chris Wilsonfbbd37b2016-10-28 13:58:42 +0100418 int err = -ENOENT;
Eric Anholt673a3942008-07-30 12:06:12 -0700419
Chris Wilsonfbbd37b2016-10-28 13:58:42 +0100420 rcu_read_lock();
421 obj = i915_gem_object_lookup_rcu(file, args->handle);
422 if (obj) {
423 args->tiling_mode =
424 READ_ONCE(obj->tiling_and_stride) & TILING_MASK;
425 err = 0;
426 }
427 rcu_read_unlock();
428 if (unlikely(err))
429 return err;
Eric Anholt673a3942008-07-30 12:06:12 -0700430
Chris Wilson9ad36762016-08-05 10:14:21 +0100431 switch (args->tiling_mode) {
Eric Anholt673a3942008-07-30 12:06:12 -0700432 case I915_TILING_X:
433 args->swizzle_mode = dev_priv->mm.bit_6_swizzle_x;
434 break;
435 case I915_TILING_Y:
436 args->swizzle_mode = dev_priv->mm.bit_6_swizzle_y;
437 break;
Chris Wilsonfbbd37b2016-10-28 13:58:42 +0100438 default:
Eric Anholt673a3942008-07-30 12:06:12 -0700439 case I915_TILING_NONE:
440 args->swizzle_mode = I915_BIT_6_SWIZZLE_NONE;
441 break;
Eric Anholt673a3942008-07-30 12:06:12 -0700442 }
443
Eric Anholt280b7132009-03-12 16:56:27 -0700444 /* Hide bit 17 from the user -- see comment in i915_gem_set_tiling */
Chris Wilson5eb3e5a2015-06-28 09:19:26 +0100445 if (dev_priv->quirks & QUIRK_PIN_SWIZZLED_PAGES)
446 args->phys_swizzle_mode = I915_BIT_6_SWIZZLE_UNKNOWN;
447 else
448 args->phys_swizzle_mode = args->swizzle_mode;
Eric Anholt280b7132009-03-12 16:56:27 -0700449 if (args->swizzle_mode == I915_BIT_6_SWIZZLE_9_17)
450 args->swizzle_mode = I915_BIT_6_SWIZZLE_9;
451 if (args->swizzle_mode == I915_BIT_6_SWIZZLE_9_10_17)
452 args->swizzle_mode = I915_BIT_6_SWIZZLE_9_10;
453
Eric Anholt673a3942008-07-30 12:06:12 -0700454 return 0;
455}