[Mesa-dev] [PATCH] gbm/dri: Flush after unmap

Thomas Hellstrom thellstrom at vmware.com
Wed Mar 29 07:36:52 UTC 2017


On 03/28/2017 10:36 PM, Eric Anholt wrote:
> Thomas Hellstrom <thellstrom at vmware.com> writes:
>
>> Drivers may queue dma operations on the context at unmap time so we need
>> to flush to make sure the data gets to the bo. Ideally the application
>> would take care of this, but since there appears to be no exported gbm
>> flush functionality we need to explicitly flush at unmap time.
>>
>> This fixes a problem where kmscube on vmwgfx in rgba textured mode would
>> render using an uninitialized texture rather than the intended
>> rgba pattern.
>>
>> Signed-off-by: Thomas Hellstrom <thellstrom at vmware.com>
>> ---
>>  src/gbm/backends/dri/gbm_dri.c | 9 ++++++++-
>>  1 file changed, 8 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
>> index ac7ede8..6c2244c 100644
>> --- a/src/gbm/backends/dri/gbm_dri.c
>> +++ b/src/gbm/backends/dri/gbm_dri.c
>> @@ -243,7 +243,7 @@ struct dri_extension_match {
>>  };
>>  
>>  static struct dri_extension_match dri_core_extensions[] = {
>> -   { __DRI2_FLUSH, 1, offsetof(struct gbm_dri_device, flush) },
>> +   { __DRI2_FLUSH, 4, offsetof(struct gbm_dri_device, flush) },
>>     { __DRI_IMAGE, 1, offsetof(struct gbm_dri_device, image) },
>>     { __DRI2_FENCE, 1, offsetof(struct gbm_dri_device, fence), 1 },
>>     { __DRI2_INTEROP, 1, offsetof(struct gbm_dri_device, interop), 1 },
>> @@ -992,6 +992,13 @@ gbm_dri_bo_unmap(struct gbm_bo *_bo, void *map_data)
>>        return;
>>  
>>     dri->image->unmapImage(dri->context, bo->image, map_data);
>> +
>> +   /*
>> +    * Not all DRI drivers use direct maps. They may queue up DMA operations
>> +    * on the mapping context. Since there is no explicit gbm flush
>> +    * mechanism. We need to flush here.
> With the following change:
>
> s/mechanism. We/mechanism, we/
>
> Reviewed-by: Eric Anholt <eric at anholt.net>
>
> Reminder for anyone else looking at this patch: The context being
> flushed here isn't some main GL context made by the app, it's this
> little dummy context that was created internally in gbm so that these
> kinds of GPU transfers could be done for the image mapping functions.

Thanks for reviewing. Suggested change incorporated.

/Thomas





>> +    */
>> +   dri->flush->flush_with_flags(dri->context, NULL, __DRI2_FLUSH_CONTEXT, 0);
>>  }





More information about the mesa-dev mailing list