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 <jordan.l.justen@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4956>
This commit is contained in:
Rafael Antognolli 2020-06-03 17:19:50 +00:00 committed by Jordan Justen
parent 86617c08cc
commit 762e601f77
2 changed files with 29 additions and 0 deletions

View file

@ -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;
}

View file

@ -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