From: Rafael Antognolli Date: Wed, 3 Jun 2020 17:19:50 +0000 (+0000) Subject: intel/devinfo: Add function to check for DRM_I915_GEM_GET_TILING. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=762e601f776e7d692f49c328e526e6e2c3b14345;p=mesa.git intel/devinfo: Add function to check for DRM_I915_GEM_GET_TILING. Future (discrete) platforms won't have support for get/set tiling. This function allows our drivers to query for that, by simply trying to get the tiling from a dummy buffer. Reviewed-by: Jordan Justen Part-of: --- diff --git a/src/intel/dev/gen_device_info.c b/src/intel/dev/gen_device_info.c index 8fd87b5d53d..917f493a672 100644 --- a/src/intel/dev/gen_device_info.c +++ b/src/intel/dev/gen_device_info.c @@ -1408,6 +1408,33 @@ gen_get_aperture_size(int fd, uint64_t *size) return ret; } +static bool +gen_has_get_tiling(int fd) +{ + int ret; + + struct drm_i915_gem_create gem_create = { + .size = 4096, + }; + + if (gen_ioctl(fd, DRM_IOCTL_I915_GEM_CREATE, &gem_create)) { + unreachable("Failed to create GEM BO"); + return false; + } + + struct drm_i915_gem_get_tiling get_tiling = { + .handle = gem_create.handle, + }; + ret = gen_ioctl(fd, DRM_IOCTL_I915_GEM_SET_TILING, &get_tiling); + + struct drm_gem_close close = { + .handle = gem_create.handle, + }; + gen_ioctl(fd, DRM_IOCTL_GEM_CLOSE, &close); + + return ret == 0; +} + bool gen_get_device_info_from_fd(int fd, struct gen_device_info *devinfo) { @@ -1476,6 +1503,7 @@ gen_get_device_info_from_fd(int fd, struct gen_device_info *devinfo) } gen_get_aperture_size(fd, &devinfo->aperture_bytes); + devinfo->has_tiling_uapi = gen_has_get_tiling(fd); return true; } diff --git a/src/intel/dev/gen_device_info.h b/src/intel/dev/gen_device_info.h index 37e9c4231fa..d3514a195e7 100644 --- a/src/intel/dev/gen_device_info.h +++ b/src/intel/dev/gen_device_info.h @@ -80,6 +80,7 @@ struct gen_device_info bool has_resource_streamer; bool disable_ccs_repack; bool has_aux_map; + bool has_tiling_uapi; /** * \name Intel hardware quirks