[Mesa-dev] [RFC 1/5] st/dri: Allow kms_swrast to work without a device FD

Robert Foss robert.foss at collabora.com
Thu Jul 5 10:07:36 UTC 2018


From: Tomeu Vizoso <tomeu.vizoso at collabora.com>

A KMS device isn't strictly needed for the kms_swrast to work, so stop
failing to init if the FD is -1. Also don't call DRM_IOCTL_GET_CAP in
that case.

This allows the driver to be used in machines where no KMS device at all
is present.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso at collabora.com>
---
 src/gallium/state_trackers/dri/dri2.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
index 58a6757f037..c262c0ca118 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -2189,7 +2189,8 @@ dri_kms_init_screen(__DRIscreen * sPriv)
 
    sPriv->driverPrivate = (void *)screen;
 
-   if (screen->fd < 0 || (fd = fcntl(screen->fd, F_DUPFD_CLOEXEC, 3)) < 0)
+   /* We don't really need a device FD if we are soft-rendering */
+   if (screen->fd >= 0 && (fd = fcntl(screen->fd, F_DUPFD_CLOEXEC, 3)) < 0)
       goto free_screen;
 
    if (pipe_loader_sw_probe_kms(&screen->dev, fd)) {
@@ -2204,7 +2205,8 @@ dri_kms_init_screen(__DRIscreen * sPriv)
       dri2ImageExtension.createImageWithModifiers =
          dri2_create_image_with_modifiers;
 
-   if (drmGetCap(sPriv->fd, DRM_CAP_PRIME, &cap) == 0 &&
+   if (sPriv->fd >= 0 &&
+          drmGetCap(sPriv->fd, DRM_CAP_PRIME, &cap) == 0 &&
           (cap & DRM_PRIME_CAP_IMPORT)) {
       dri2ImageExtension.createImageFromFds = dri2_from_fds;
       dri2ImageExtension.createImageFromDmaBufs = dri2_from_dma_bufs;
-- 
2.17.1



More information about the mesa-dev mailing list