Skip to content

Commit e7737b6

Browse files
committed
drm/i915/uapi: reject caching ioctls for discrete
It's a noop on DG1, and in the future when need to support other devices which let us control the coherency, then it should be an immutable creation time property for the BO. This will likely be controlled through a new gem_create_ext extension. v2: add some kernel doc for the discrete changes, and document the implicit rules Suggested-by: Daniel Vetter <daniel@ffwll.ch> Signed-off-by: Matthew Auld <matthew.auld@intel.com> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> Cc: Jordan Justen <jordan.l.justen@intel.com> Cc: Kenneth Graunke <kenneth@whitecape.org> Cc: Jason Ekstrand <jason@jlekstrand.net> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Cc: Ramalingam C <ramalingam.c@intel.com> Reviewed-by: Ramalingam C <ramalingam.c@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Link: https://patchwork.freedesktop.org/patch/msgid/20210715101536.2606307-2-matthew.auld@intel.com
1 parent 0c6609b commit e7737b6

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

‎drivers/gpu/drm/i915/gem/i915_gem_domain.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,9 @@ int i915_gem_get_caching_ioctl(struct drm_device *dev, void *data,
268268
struct drm_i915_gem_object *obj;
269269
int err = 0;
270270

271+
if (IS_DGFX(to_i915(dev)))
272+
return -ENODEV;
273+
271274
rcu_read_lock();
272275
obj = i915_gem_object_lookup_rcu(file, args->handle);
273276
if (!obj) {
@@ -303,6 +306,9 @@ int i915_gem_set_caching_ioctl(struct drm_device *dev, void *data,
303306
enum i915_cache_level level;
304307
int ret = 0;
305308

309+
if (IS_DGFX(i915))
310+
return -ENODEV;
311+
306312
switch (args->caching) {
307313
case I915_CACHING_NONE:
308314
level = I915_CACHE_NONE;

‎include/uapi/drm/i915_drm.h‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,6 +1395,35 @@ struct drm_i915_gem_busy {
13951395
* ppGTT support, or if the object is used for scanout). Note that this might
13961396
* require unbinding the object from the GTT first, if its current caching value
13971397
* doesn't match.
1398+
*
1399+
* Note that this all changes on discrete platforms, starting from DG1, the
1400+
* set/get caching is no longer supported, and is now rejected. Instead the CPU
1401+
* caching attributes(WB vs WC) will become an immutable creation time property
1402+
* for the object, along with the GTT caching level. For now we don't expose any
1403+
* new uAPI for this, instead on DG1 this is all implicit, although this largely
1404+
* shouldn't matter since DG1 is coherent by default(without any way of
1405+
* controlling it).
1406+
*
1407+
* Implicit caching rules, starting from DG1:
1408+
*
1409+
* - If any of the object placements (see &drm_i915_gem_create_ext_memory_regions)
1410+
* contain I915_MEMORY_CLASS_DEVICE then the object will be allocated and
1411+
* mapped as write-combined only.
1412+
*
1413+
* - Everything else is always allocated and mapped as write-back, with the
1414+
* guarantee that everything is also coherent with the GPU.
1415+
*
1416+
* Note that this is likely to change in the future again, where we might need
1417+
* more flexibility on future devices, so making this all explicit as part of a
1418+
* new &drm_i915_gem_create_ext extension is probable.
1419+
*
1420+
* Side note: Part of the reason for this is that changing the at-allocation-time CPU
1421+
* caching attributes for the pages might be required(and is expensive) if we
1422+
* need to then CPU map the pages later with different caching attributes. This
1423+
* inconsistent caching behaviour, while supported on x86, is not universally
1424+
* supported on other architectures. So for simplicity we opt for setting
1425+
* everything at creation time, whilst also making it immutable, on discrete
1426+
* platforms.
13981427
*/
13991428
struct drm_i915_gem_caching {
14001429
/**

0 commit comments

Comments
 (0)