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

Eric Engestrom eric.engestrom at intel.com
Thu Jul 5 10:35:57 UTC 2018


On Thursday, 2018-07-05 12:07:36 +0200, Robert Foss wrote:
> 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)) {

Aren't you going to use an uninitialised `fd` here if `screen->fd < 0`?

> @@ -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
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list