From 450c9460c641807a66ce1017c0c8a1aec94c243d Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Wed, 17 Apr 2024 09:40:40 -0700 Subject: [PATCH] freedreno/loader: Switch over to probe_nctx Unwind the hacks that were previously used for freedreno to probe on virtgpu, and switch over to the new mechanism. Signed-off-by: Rob Clark Part-of: --- .../auxiliary/target-helpers/drm_helper.h | 19 +++++++++-------- src/gallium/drivers/virgl/virgl_driinfo.h.in | 15 ------------- .../freedreno/drm/freedreno_drm_public.h | 6 ++++++ .../freedreno/drm/freedreno_drm_winsys.c | 21 +++++++++++++++++++ 4 files changed, 37 insertions(+), 24 deletions(-) diff --git a/src/gallium/auxiliary/target-helpers/drm_helper.h b/src/gallium/auxiliary/target-helpers/drm_helper.h index 87f58ea8e24..4ca5972eb59 100644 --- a/src/gallium/auxiliary/target-helpers/drm_helper.h +++ b/src/gallium/auxiliary/target-helpers/drm_helper.h @@ -248,19 +248,26 @@ pipe_msm_create_screen(int fd, const struct pipe_screen_config *config) return screen ? debug_screen_wrap(screen) : NULL; } +static bool +pipe_msm_probe_nctx(int fd, const struct virgl_renderer_capset_drm *caps) +{ + return fd_drm_probe_nctx(fd, caps); +} + const driOptionDescription msm_driconf[] = { #ifdef GALLIUM_FREEDRENO #include "freedreno/driinfo_freedreno.h" #endif }; -DRM_DRIVER_DESCRIPTOR(msm, msm_driconf, ARRAY_SIZE(msm_driconf)) +DRM_DRIVER_DESCRIPTOR(msm, msm_driconf, ARRAY_SIZE(msm_driconf), + .probe_nctx = pipe_msm_probe_nctx) DRM_DRIVER_DESCRIPTOR_ALIAS(msm, kgsl, msm_driconf, ARRAY_SIZE(msm_driconf)) #else DRM_DRIVER_DESCRIPTOR_STUB(msm) DRM_DRIVER_DESCRIPTOR_STUB(kgsl) #endif -#if defined(GALLIUM_VIRGL) || (defined(GALLIUM_FREEDRENO) && !defined(PIPE_LOADER_DYNAMIC)) +#if defined(GALLIUM_VIRGL) #include "virgl/drm/virgl_drm_public.h" #include "virgl/virgl_public.h" @@ -269,15 +276,9 @@ pipe_virtio_gpu_create_screen(int fd, const struct pipe_screen_config *config) { struct pipe_screen *screen = NULL; - /* Try native guest driver(s) first, and then fallback to virgl: */ -#ifdef GALLIUM_FREEDRENO - if (!screen) - screen = fd_drm_screen_create_renderonly(fd, NULL, config); -#endif -#ifdef GALLIUM_VIRGL if (!screen) screen = virgl_drm_screen_create(fd, config); -#endif + return screen ? debug_screen_wrap(screen) : NULL; } diff --git a/src/gallium/drivers/virgl/virgl_driinfo.h.in b/src/gallium/drivers/virgl/virgl_driinfo.h.in index 39a5a17f7be..86bc9b4b0e7 100644 --- a/src/gallium/drivers/virgl/virgl_driinfo.h.in +++ b/src/gallium/drivers/virgl/virgl_driinfo.h.in @@ -11,20 +11,5 @@ DRI_CONF_SECTION_MISCELLANEOUS DRI_CONF_GLES_EMULATE_BGRA(true) DRI_CONF_GLES_APPLY_BGRA_DEST_SWIZZLE(true) DRI_CONF_GLES_SAMPLES_PASSED_VALUE(1024, 1, 400000000) - - /* - * Native-context drivers also (can) bind to the some virtio_gpu guest - * kernel device. Because drm_helper ties the driconf config to the - * drm device name, we also need to include config options for any - * possible drm-native-context guest driver: - */ - DRI_CONF_DISABLE_CONSERVATIVE_LRZ(false) - DRI_CONF_VIRGL_SHADER_SYNC(false) DRI_CONF_SECTION_END - -DRI_CONF_SECTION_DEBUG - /* Also needed for native-context drivers (freedreno) */ - DRI_CONF_DISABLE_THROTTLING(false) - DRI_CONF_DUAL_COLOR_BLEND_BY_LOCATION(false) -DRI_CONF_SECTION_END diff --git a/src/gallium/winsys/freedreno/drm/freedreno_drm_public.h b/src/gallium/winsys/freedreno/drm/freedreno_drm_public.h index 24f45d0c815..c7bc407d3c2 100644 --- a/src/gallium/winsys/freedreno/drm/freedreno_drm_public.h +++ b/src/gallium/winsys/freedreno/drm/freedreno_drm_public.h @@ -2,6 +2,8 @@ #ifndef __FREEDRENO_DRM_PUBLIC_H__ #define __FREEDRENO_DRM_PUBLIC_H__ +#include + struct pipe_screen; struct renderonly; @@ -9,4 +11,8 @@ struct pipe_screen *fd_drm_screen_create_renderonly(int drmFD, struct renderonly *ro, const struct pipe_screen_config *config); +struct virgl_renderer_capset_drm; + +bool fd_drm_probe_nctx(int fd, const struct virgl_renderer_capset_drm *caps); + #endif diff --git a/src/gallium/winsys/freedreno/drm/freedreno_drm_winsys.c b/src/gallium/winsys/freedreno/drm/freedreno_drm_winsys.c index 074951f9a3f..c9759f1ae4a 100644 --- a/src/gallium/winsys/freedreno/drm/freedreno_drm_winsys.c +++ b/src/gallium/winsys/freedreno/drm/freedreno_drm_winsys.c @@ -31,9 +31,30 @@ #include "freedreno/freedreno_screen.h" +#include "virtio/virtio-gpu/drm_hw.h" + struct pipe_screen * fd_drm_screen_create_renderonly(int fd, struct renderonly *ro, const struct pipe_screen_config *config) { return u_pipe_screen_lookup_or_create(fd, config, ro, fd_screen_create); } + +/** + * Check if the native-context type exposed by virtgpu is one we + * support, and that we support the underlying device. + */ +bool +fd_drm_probe_nctx(int fd, const struct virgl_renderer_capset_drm *caps) +{ + if (caps->context_type != VIRTGPU_DRM_CONTEXT_MSM) + return false; + + struct fd_dev_id dev_id = { + .gpu_id = caps->u.msm.gpu_id, + .chip_id = caps->u.msm.chip_id, + }; + const struct fd_dev_info info = fd_dev_info(&dev_id); + + return info.chip != 0; +}