Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915: Disable pread/pwrite ioctl's for future platforms (v3)

The rationale for this change is roughly as follows:

1. The functionality can be done entirely in userspace with a
combination of mmap + memcpy

2. The only reason anyone in userspace is still using it is because
someone implemented bo_subdata that way in libdrm ages ago and
they're all too lazy to write the 5 lines of code to do a map.

3. This falls cleanly into the category of things which will only get
more painful with local memory support.

These ioctls aren't used much anymore by "real" userspace drivers.
Vulkan has never used them and neither has the iris GL driver. The old
i965 GL driver does use PWRITE for glBufferSubData but it only supports
up through Gen11; Gen12 was never enabled in i965. The compute driver
has never used PREAD/PWRITE. The only remaining user is the media
driver which uses it exactly twice and they're easily removed [1] so
expecting them to drop it going forward is reasonable.

IGT changes which handle this kernel change have also been submitted [2].

[1] https://github.com/intel/media-driver/pull/1160
[2] https://patchwork.freedesktop.org/series/81384/

v2 (Jason Ekstrand):
- Improved commit message with the status of all usermode drivers
- A more future-proof platform check

v3 (Jason Ekstrand):
- Drop the HAS_LMEM checks as they're already covered by the version
checks

Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210317234014.2271006-4-jason@jlekstrand.net

authored by

Ashutosh Dixit and committed by
Daniel Vetter
f8d1ff10 2eb8e1a6

+14
+14
drivers/gpu/drm/i915/i915_gem.c
··· 378 378 i915_gem_pread_ioctl(struct drm_device *dev, void *data, 379 379 struct drm_file *file) 380 380 { 381 + struct drm_i915_private *i915 = to_i915(dev); 381 382 struct drm_i915_gem_pread *args = data; 382 383 struct drm_i915_gem_object *obj; 383 384 int ret; 385 + 386 + /* PREAD is disallowed for all platforms after TGL-LP. This also 387 + * covers all platforms with local memory. 388 + */ 389 + if (INTEL_GEN(i915) >= 12 && !IS_TIGERLAKE(i915)) 390 + return -EOPNOTSUPP; 384 391 385 392 if (args->size == 0) 386 393 return 0; ··· 690 683 i915_gem_pwrite_ioctl(struct drm_device *dev, void *data, 691 684 struct drm_file *file) 692 685 { 686 + struct drm_i915_private *i915 = to_i915(dev); 693 687 struct drm_i915_gem_pwrite *args = data; 694 688 struct drm_i915_gem_object *obj; 695 689 int ret; 690 + 691 + /* PWRITE is disallowed for all platforms after TGL-LP. This also 692 + * covers all platforms with local memory. 693 + */ 694 + if (INTEL_GEN(i915) >= 12 && !IS_TIGERLAKE(i915)) 695 + return -EOPNOTSUPP; 696 696 697 697 if (args->size == 0) 698 698 return 0;