mbox series

[00/10] drm: Hide import_attach from GEM code and helpers

Message ID 20250226172457.217725-1-tzimmermann@suse.de (mailing list archive)
Headers show
Series drm: Hide import_attach from GEM code and helpers | expand

Message

Thomas Zimmermann Feb. 26, 2025, 5:03 p.m. UTC
Do not use struct drm_gem_object.import_attach unnecessarily. The
field is set by the PRIME import helpers. GEM and other helpers use
it for testing for imported dma-bufs and retrieving the respective
dma-buf instance.

Replace all tests for import_attach with the new GEM helper function
drm_gem_is_imported(). The helper avoids import_attach in favor of
testing the imported dma-buf's object against the provided GEM object.

Also replace references to import_attach.dmabuf. The imported dma-buf
is also available in the GEM object's dma_buf field.

This series cleans up the GEM core and helpers. Drivers also use
import_attach and should later be updated as well.

There's a TODO item for making import_attach entirely optional. This
series is a first step towards this goal.

Thomas Zimmermann (10):
  drm/gem: Test for imported GEM buffers with helper
  drm/gem-dma: Test for imported buffers with drm_gem_is_imported()
  drm/gem-dma: Use dma_buf from GEM object instance
  drm/gem-shmem: Test for imported buffers with drm_gem_is_imported()
  drm/gem-shmem: Use dma_buf from GEM object instance
  drm/gem-framebuffer: Test for imported buffers with
    drm_gem_is_imported()
  drm/gem-framebuffer: Use dma_buf from GEM object instance
  drm/fb-dma-helper: Test for imported buffers with
    drm_gem_is_imported()
  drm/mipi-dbi: Test for imported buffers with drm_gem_is_imported()
  drm/prime: Use dma_buf from GEM object instance

 drivers/gpu/drm/drm_fb_dma_helper.c          |  2 +-
 drivers/gpu/drm/drm_gem.c                    |  4 +--
 drivers/gpu/drm/drm_gem_dma_helper.c         |  4 +--
 drivers/gpu/drm/drm_gem_framebuffer_helper.c | 12 +++-----
 drivers/gpu/drm/drm_gem_shmem_helper.c       | 30 ++++++++++----------
 drivers/gpu/drm/drm_mipi_dbi.c               |  2 +-
 drivers/gpu/drm/drm_prime.c                  |  8 +-----
 include/drm/drm_gem.h                        | 14 +++++++++
 include/drm/drm_gem_shmem_helper.h           |  2 +-
 9 files changed, 41 insertions(+), 37 deletions(-)

Comments

Christian König March 5, 2025, 3:38 p.m. UTC | #1
Reviewed-by: Christian König <christian.koenig@amd.com> for the entire series.

Regards,
Christian.

Am 26.02.25 um 18:03 schrieb Thomas Zimmermann:
> Do not use struct drm_gem_object.import_attach unnecessarily. The
> field is set by the PRIME import helpers. GEM and other helpers use
> it for testing for imported dma-bufs and retrieving the respective
> dma-buf instance.
>
> Replace all tests for import_attach with the new GEM helper function
> drm_gem_is_imported(). The helper avoids import_attach in favor of
> testing the imported dma-buf's object against the provided GEM object.
>
> Also replace references to import_attach.dmabuf. The imported dma-buf
> is also available in the GEM object's dma_buf field.
>
> This series cleans up the GEM core and helpers. Drivers also use
> import_attach and should later be updated as well.
>
> There's a TODO item for making import_attach entirely optional. This
> series is a first step towards this goal.
>
> Thomas Zimmermann (10):
>   drm/gem: Test for imported GEM buffers with helper
>   drm/gem-dma: Test for imported buffers with drm_gem_is_imported()
>   drm/gem-dma: Use dma_buf from GEM object instance
>   drm/gem-shmem: Test for imported buffers with drm_gem_is_imported()
>   drm/gem-shmem: Use dma_buf from GEM object instance
>   drm/gem-framebuffer: Test for imported buffers with
>     drm_gem_is_imported()
>   drm/gem-framebuffer: Use dma_buf from GEM object instance
>   drm/fb-dma-helper: Test for imported buffers with
>     drm_gem_is_imported()
>   drm/mipi-dbi: Test for imported buffers with drm_gem_is_imported()
>   drm/prime: Use dma_buf from GEM object instance
>
>  drivers/gpu/drm/drm_fb_dma_helper.c          |  2 +-
>  drivers/gpu/drm/drm_gem.c                    |  4 +--
>  drivers/gpu/drm/drm_gem_dma_helper.c         |  4 +--
>  drivers/gpu/drm/drm_gem_framebuffer_helper.c | 12 +++-----
>  drivers/gpu/drm/drm_gem_shmem_helper.c       | 30 ++++++++++----------
>  drivers/gpu/drm/drm_mipi_dbi.c               |  2 +-
>  drivers/gpu/drm/drm_prime.c                  |  8 +-----
>  include/drm/drm_gem.h                        | 14 +++++++++
>  include/drm/drm_gem_shmem_helper.h           |  2 +-
>  9 files changed, 41 insertions(+), 37 deletions(-)
>
Thomas Zimmermann March 5, 2025, 4:37 p.m. UTC | #2
Am 05.03.25 um 16:38 schrieb Christian König:
> Reviewed-by: Christian König <christian.koenig@amd.com> for the entire series.

Thanks. I have equivalent patches for drivers as well. I'll send them 
out once this series has propagated through the trees.

Best regards
Thomas

>
> Regards,
> Christian.
>
> Am 26.02.25 um 18:03 schrieb Thomas Zimmermann:
>> Do not use struct drm_gem_object.import_attach unnecessarily. The
>> field is set by the PRIME import helpers. GEM and other helpers use
>> it for testing for imported dma-bufs and retrieving the respective
>> dma-buf instance.
>>
>> Replace all tests for import_attach with the new GEM helper function
>> drm_gem_is_imported(). The helper avoids import_attach in favor of
>> testing the imported dma-buf's object against the provided GEM object.
>>
>> Also replace references to import_attach.dmabuf. The imported dma-buf
>> is also available in the GEM object's dma_buf field.
>>
>> This series cleans up the GEM core and helpers. Drivers also use
>> import_attach and should later be updated as well.
>>
>> There's a TODO item for making import_attach entirely optional. This
>> series is a first step towards this goal.
>>
>> Thomas Zimmermann (10):
>>    drm/gem: Test for imported GEM buffers with helper
>>    drm/gem-dma: Test for imported buffers with drm_gem_is_imported()
>>    drm/gem-dma: Use dma_buf from GEM object instance
>>    drm/gem-shmem: Test for imported buffers with drm_gem_is_imported()
>>    drm/gem-shmem: Use dma_buf from GEM object instance
>>    drm/gem-framebuffer: Test for imported buffers with
>>      drm_gem_is_imported()
>>    drm/gem-framebuffer: Use dma_buf from GEM object instance
>>    drm/fb-dma-helper: Test for imported buffers with
>>      drm_gem_is_imported()
>>    drm/mipi-dbi: Test for imported buffers with drm_gem_is_imported()
>>    drm/prime: Use dma_buf from GEM object instance
>>
>>   drivers/gpu/drm/drm_fb_dma_helper.c          |  2 +-
>>   drivers/gpu/drm/drm_gem.c                    |  4 +--
>>   drivers/gpu/drm/drm_gem_dma_helper.c         |  4 +--
>>   drivers/gpu/drm/drm_gem_framebuffer_helper.c | 12 +++-----
>>   drivers/gpu/drm/drm_gem_shmem_helper.c       | 30 ++++++++++----------
>>   drivers/gpu/drm/drm_mipi_dbi.c               |  2 +-
>>   drivers/gpu/drm/drm_prime.c                  |  8 +-----
>>   include/drm/drm_gem.h                        | 14 +++++++++
>>   include/drm/drm_gem_shmem_helper.h           |  2 +-
>>   9 files changed, 41 insertions(+), 37 deletions(-)
>>