pvr: drop master for the display FD if it's not needed
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

Currently the display FD is opened twice because of pvr_winsys_create()
being called twice, however the WSI (which will do modeset on the
display FD in case of VK_KHR_display) is registered against the winsys
created at PhysicalDevice enumeration time, and the display FD opened at
Device creation time will only be used for allocating dumb buffer (which
does not require master privilege).

Add a parameter to pvr_winsys_create() to indicate whether the master
privilege is desired on the display FD, and pass true only when creating
the winsys for PhysicalDevice initialization.

Fixes VK_KHR_display operation on PowerVR driver, which is broken after
the WSI code starts to drop master in commit 870e233ca5
("vulkan/wsi/display: Avoid holding drm master for the device's fd.").

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/15161
Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
Reviewed-by: Frank Binns <frank.binns@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40640>
This commit is contained in:
Icenowy Zheng 2026-03-26 15:35:41 +08:00
parent 44fa9c8326
commit 441bb8b947
4 changed files with 11 additions and 2 deletions

View file

@ -703,7 +703,7 @@ VkResult PVR_PER_ARCH(create_device)(struct pvr_physical_device *pdevice,
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO);
result = pvr_winsys_create(pdevice->render_path,
pdevice->display_path,
pdevice->display_path, false,
pAllocator ? pAllocator : &instance->vk.alloc,
&ws);
if (result != VK_SUCCESS)

View file

@ -1031,7 +1031,8 @@ VkResult pvr_physical_device_init(struct pvr_physical_device *pdevice,
pdevice->render_devid = render_stat.st_rdev;
result =
pvr_winsys_create(render_path, display_path, &instance->vk.alloc, &ws);
pvr_winsys_create(render_path, display_path, true,
&instance->vk.alloc, &ws);
if (result != VK_SUCCESS)
goto err_vk_free_display_path;

View file

@ -50,6 +50,7 @@ void pvr_winsys_destroy(struct pvr_winsys *ws)
VkResult pvr_winsys_create(const char *render_path,
const char *display_path,
bool keep_display_master,
const VkAllocationCallbacks *alloc,
struct pvr_winsys **const ws_out)
{
@ -76,6 +77,12 @@ VkResult pvr_winsys_create(const char *render_path,
display_path);
goto err_close_render_fd;
}
if (!keep_display_master) {
/* Try to drop master for the display FD if it's not meant to be
* kept, but not to fail if it's not the master at opening time.
*/
drmDropMaster(display_fd);
}
} else {
display_fd = -1;
}

View file

@ -476,6 +476,7 @@ struct pvr_winsys {
void pvr_winsys_destroy(struct pvr_winsys *ws);
VkResult pvr_winsys_create(const char *render_path,
const char *display_path,
bool keep_display_master,
const VkAllocationCallbacks *alloc,
struct pvr_winsys **ws_out);