mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 18:18:06 +02:00
glx: Keep display fd open for prime
Keep the display fd open for creating DRI screen on display gpu in
case of prime.
v2: initialize psc->fd_display_gpu early (Michel Dänzer)
fix display gpu fd leakage (Michel Dänzer)
v3: fix more display gpu fd leakage (Michel Dänzer)
Signed-off-by: Yogesh Mohanmarimuthu <yogesh.mohanmarimuthu@amd.com>
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10595>
This commit is contained in:
parent
41eaa07823
commit
dac2c210d6
2 changed files with 13 additions and 0 deletions
|
|
@ -607,6 +607,8 @@ dri3_destroy_screen(struct glx_screen *base)
|
|||
struct dri3_screen *psc = (struct dri3_screen *) base;
|
||||
|
||||
/* Free the direct rendering per screen data */
|
||||
if (psc->is_different_gpu)
|
||||
close(psc->fd_display_gpu);
|
||||
loader_dri3_close_screen(psc->driScreen);
|
||||
(*psc->core->destroyScreen) (psc->driScreen);
|
||||
driDestroyConfigs(psc->driver_configs);
|
||||
|
|
@ -842,6 +844,7 @@ dri3_create_screen(int screen, struct glx_display * priv)
|
|||
return NULL;
|
||||
|
||||
psc->fd = -1;
|
||||
psc->fd_display_gpu = -1;
|
||||
|
||||
if (!glx_screen_init(&psc->base, screen, priv)) {
|
||||
free(psc);
|
||||
|
|
@ -862,7 +865,12 @@ dri3_create_screen(int screen, struct glx_display * priv)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
psc->fd_display_gpu = fcntl(psc->fd, F_DUPFD_CLOEXEC, 3);
|
||||
psc->fd = loader_get_user_preferred_fd(psc->fd, &psc->is_different_gpu);
|
||||
if (!psc->is_different_gpu) {
|
||||
close(psc->fd_display_gpu);
|
||||
psc->fd_display_gpu = -1;
|
||||
}
|
||||
|
||||
driverName = loader_get_driver_for_fd(psc->fd);
|
||||
if (!driverName) {
|
||||
|
|
@ -1013,6 +1021,8 @@ handle_error:
|
|||
psc->driScreen = NULL;
|
||||
if (psc->fd >= 0)
|
||||
close(psc->fd);
|
||||
if (psc->fd_display_gpu >= 0)
|
||||
close(psc->fd_display_gpu);
|
||||
if (psc->driver)
|
||||
dlclose(psc->driver);
|
||||
|
||||
|
|
|
|||
|
|
@ -103,6 +103,9 @@ struct dri3_screen {
|
|||
int fd;
|
||||
bool is_different_gpu;
|
||||
|
||||
/* fd for display GPU in case of prime */
|
||||
int fd_display_gpu;
|
||||
|
||||
int show_fps_interval;
|
||||
|
||||
struct loader_dri3_extensions loader_dri3_ext;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue