[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 11:32:44 UTC 2018
Hey Eric!
On 05/07/18 12:35, Eric Engestrom wrote:
> 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`?
From my understanding during dri2_initialize_android(), droid_open_device[1]
will always allocate an FD or fail, before a screen is created in
dri2_create_screen[2].
But maybe there is some part I don't quite understand.
[1]
https://gitlab.collabora.com/robertfoss/mesa/blob/9e5f456fee2cd3f8b8dd70cc313d0ad56166ecb0/src/egl/drivers/dri2/platform_android.c#L1385
[2]
https://gitlab.collabora.com/robertfoss/mesa/blob/9e5f456fee2cd3f8b8dd70cc313d0ad56166ecb0/src/egl/drivers/dri2/platform_android.c#L1396
>
>> @@ -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