[Mesa-dev] [PATCH 1/2] gbm/dri2: propagate errors when creating a DMA-BUF fd
Nicholas Bishop
nbishop at neverware.com
Wed Sep 21 21:39:09 UTC 2016
Bump, could someone push this?
Thanks,
-Nicholas
On Wed, Sep 14, 2016 at 1:06 PM, Nicholas Bishop <nbishop at neverware.com> wrote:
> Thanks for review. Could someone with commit access push this for me?
>
> On Wed, Sep 14, 2016 at 8:48 AM, Eric Engestrom
> <eric.engestrom at imgtec.com> wrote:
>> On Thu, Sep 08, 2016 at 03:55:02PM -0400, Nicholas Bishop wrote:
>>> Changed dri2_query_image to check the return value of
>>> resource_get_handle and return GL_FALSE if an error occurs. Similarly
>>> changed gbm_dri_bo_get_fd to check the return value of queryImage and
>>> return -1 (an invalid file descriptor) if an error occurs.
>>>
>>> Updated the comment for gbm_bo_get_fd to say that -1 is returned if
>>> an error occurs.
>>>
>>> For reference this is an example callstack that should propagate the
>>> error back to the user:
>>>
>>> i915_drm_buffer_get_handle
>>> i915_texture_get_handle
>>> u_resource_get_handle_vtbl
>>> dri2_query_image
>>> gbm_dri_bo_get_fd
>>> gbm_bo_get_fd
>>>
>>> Signed-off-by: Nicholas Bishop <nbishop at neverware.com>
>>
>> Looks good to me
>> Reviewed-by: Eric Engestrom <eric.engestrom at imgtec.com>
>>
>>> ---
>>> src/gallium/state_trackers/dri/dri2.c | 11 +++++++----
>>> src/gbm/backends/dri/gbm_dri.c | 8 +++++---
>>> src/gbm/main/gbm.c | 3 ++-
>>> 3 files changed, 14 insertions(+), 8 deletions(-)
>>>
>>> diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
>>> index 28f8078..c6260ba 100644
>>> --- a/src/gallium/state_trackers/dri/dri2.c
>>> +++ b/src/gallium/state_trackers/dri/dri2.c
>>> @@ -979,10 +979,13 @@ dri2_query_image(__DRIimage *image, int attrib, int *value)
>>> return GL_TRUE;
>>> case __DRI_IMAGE_ATTRIB_FD:
>>> whandle.type= DRM_API_HANDLE_TYPE_FD;
>>> - image->texture->screen->resource_get_handle(image->texture->screen,
>>> - image->texture, &whandle, usage);
>>> - *value = whandle.handle;
>>> - return GL_TRUE;
>>> + if (image->texture->screen->resource_get_handle(image->texture->screen,
>>> + image->texture, &whandle, usage)) {
>>> + *value = whandle.handle;
>>> + return GL_TRUE;
>>> + } else {
>>> + return GL_FALSE;
>>> + }
>>> case __DRI_IMAGE_ATTRIB_FORMAT:
>>> *value = image->dri_format;
>>> return GL_TRUE;
>>> diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
>>> index c3626e3..54b293a 100644
>>> --- a/src/gbm/backends/dri/gbm_dri.c
>>> +++ b/src/gbm/backends/dri/gbm_dri.c
>>> @@ -589,9 +589,11 @@ gbm_dri_bo_get_fd(struct gbm_bo *_bo)
>>> if (bo->image == NULL)
>>> return -1;
>>>
>>> - dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_FD, &fd);
>>> -
>>> - return fd;
>>> + if (dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_FD, &fd)) {
>>> + return fd;
>>> + } else {
>>> + return -1;
>>> + }
>>> }
>>>
>>> static void
>>> diff --git a/src/gbm/main/gbm.c b/src/gbm/main/gbm.c
>>> index 95b4c2c..c3a2ec33 100644
>>> --- a/src/gbm/main/gbm.c
>>> +++ b/src/gbm/main/gbm.c
>>> @@ -242,7 +242,8 @@ gbm_bo_get_handle(struct gbm_bo *bo)
>>> * descriptor.
>>>
>>> * \param bo The buffer object
>>> - * \return Returns a file descriptor referring to the underlying buffer
>>> + * \return Returns a file descriptor referring to the underlying buffer or -1
>>> + * if an error occurs.
>>> */
>>> GBM_EXPORT int
>>> gbm_bo_get_fd(struct gbm_bo *bo)
>>> --
>>> 2.7.4
More information about the mesa-dev
mailing list