intel: Add and use intel_gem_can_render_on_fd()

Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19425>
This commit is contained in:
José Roberto de Souza 2022-10-06 09:42:41 -07:00 committed by Marge Bot
parent 29550bc50a
commit 41ee836c9a
4 changed files with 11 additions and 10 deletions

View File

@ -260,3 +260,9 @@ intel_gem_get_param(int fd, uint32_t param, int *value)
};
return intel_ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp) == 0;
}
bool intel_gem_can_render_on_fd(int fd)
{
int val;
return intel_gem_get_param(fd, I915_PARAM_CHIPSET_ID, &val) && val > 0;
}

View File

@ -175,6 +175,7 @@ intel_gem_get_context_param(int fd, uint32_t context, uint32_t param,
bool intel_gem_read_render_timestamp(int fd, uint64_t *value);
bool intel_gem_get_param(int fd, uint32_t param, int *value);
bool intel_gem_can_render_on_fd(int fd);
#ifdef __cplusplus
}

View File

@ -968,11 +968,8 @@ anv_physical_device_try_create(struct vk_instance *vk_instance,
if (instance->vk.enabled_extensions.KHR_display) {
master_fd = open(primary_path, O_RDWR | O_CLOEXEC);
if (master_fd >= 0) {
int val;
/* prod the device with a GETPARAM call which will fail if
* we don't have permission to even render on this device
*/
if (!intel_gem_get_param(master_fd, I915_PARAM_CHIPSET_ID, &val) || !val) {
/* fail if we don't have permission to even render on this device */
if (!intel_gem_can_render_on_fd(master_fd)) {
close(master_fd);
master_fd = -1;
}

View File

@ -902,11 +902,8 @@ anv_physical_device_try_create(struct vk_instance *vk_instance,
if (instance->vk.enabled_extensions.KHR_display) {
master_fd = open(primary_path, O_RDWR | O_CLOEXEC);
if (master_fd >= 0) {
int val;
/* prod the device with a GETPARAM call which will fail if
* we don't have permission to even render on this device
*/
if (!intel_gem_get_param(master_fd, I915_PARAM_CHIPSET_ID, &val) || !val) {
/* fail if we don't have permission to even render on this device */
if (!intel_gem_can_render_on_fd(master_fd)) {
close(master_fd);
master_fd = -1;
}