[PATCH RESEND 0/4] drm/gem-dma: Support dedicated DMA device for allocation

Chen-Yu Tsai posted 4 patches 1 month ago
There is a newer version of this series
drivers/gpu/drm/drm_gem_dma_helper.c   |  21 ++-
drivers/gpu/drm/drm_prime.c            |   2 +-
drivers/gpu/drm/mediatek/mtk_crtc.c    |   1 -
drivers/gpu/drm/mediatek/mtk_drm_drv.c |  21 +--
drivers/gpu/drm/mediatek/mtk_drm_drv.h |   1 -
drivers/gpu/drm/mediatek/mtk_gem.c     | 231 -------------------------
drivers/gpu/drm/mediatek/mtk_gem.h     |  17 --
drivers/gpu/drm/sun4i/sun4i_backend.c  |  27 +--
drivers/gpu/drm/sun4i/sun8i_mixer.c    |  27 +--
9 files changed, 46 insertions(+), 302 deletions(-)
delete mode 100644 drivers/gpu/drm/mediatek/mtk_gem.c
delete mode 100644 drivers/gpu/drm/mediatek/mtk_gem.h
[PATCH RESEND 0/4] drm/gem-dma: Support dedicated DMA device for allocation
Posted by Chen-Yu Tsai 1 month ago
(resent with Samuel's email address fixed)

Hi folks,

This series expands the "dedicated DMA device" support in DRM to the GEM
DMA helpers, and converts the MediaTek DRM driver to setting the DMA
device and dropping the custom GEM helpers that implemented this
function.

Various display drivers implement the "dedicated DMA device" support
with custom GEM helpers. These include Exynos, MediaTek, and Rockchip
to name a few. Allwinner does something entirely different, calling
of_dma_configure() on the virtual display device using the OF node of
the actual DMA device. Recently this causes a warning if IOMMUs are
involved.

This series intends to allow the core helpers to deal with it, and not
have every driver implement it in slightly different ways, duplicating
code.

Patch 1 adds dedicated DMA device support to drm_prime_pages_to_sg().
I believe this was missing from the original change that added dedicated
DMA devices for PRIME.

Patch 2 adds support for dedicated DMA device to the GEM DMA helpers
for GEM buffer allocation and mmap.

Patch 3 converts the MediaTek DRM driver to use the dedicated DMA device
support, and drop all the remaining custom GEM callbacks that deal with
it.

Patch 4 converts the Allwinner sun4i DRM driver to use the dedicated DMA
device support, instead of the of_dma_configure() hack it currently has.

The series should be merged through drm-misc-next so that other drivers
can take advantage of the change.

I also intend to try to convert the Exynos and Rockchip drivers, however
both also have options to set DMA_ATTR_NO_KERNEL_MAPPING when using
dma_alloc_attrs() to allocate memory for the buffers. I intend to
resurrect the DRM_MODE_DUMB_KERNEL_MAP work from Rob Herring [1]
to handle this. The Rockchip driver also has custom IOMMU attachment
that I'm still trying to understand.


Thanks
ChenYu


Chen-Yu Tsai (4):
  drm/prime: Limit scatter list size with dedicated DMA device
  drm/gem-dma: Support dedicated DMA device for allocation and mapping
  drm/mediatek: Set dedicated DMA device and drop custom GEM callbacks
  drm/sun4i: Use backend/mixer as dedicated DMA device

 drivers/gpu/drm/drm_gem_dma_helper.c   |  21 ++-
 drivers/gpu/drm/drm_prime.c            |   2 +-
 drivers/gpu/drm/mediatek/mtk_crtc.c    |   1 -
 drivers/gpu/drm/mediatek/mtk_drm_drv.c |  21 +--
 drivers/gpu/drm/mediatek/mtk_drm_drv.h |   1 -
 drivers/gpu/drm/mediatek/mtk_gem.c     | 231 -------------------------
 drivers/gpu/drm/mediatek/mtk_gem.h     |  17 --
 drivers/gpu/drm/sun4i/sun4i_backend.c  |  27 +--
 drivers/gpu/drm/sun4i/sun8i_mixer.c    |  27 +--
 9 files changed, 46 insertions(+), 302 deletions(-)
 delete mode 100644 drivers/gpu/drm/mediatek/mtk_gem.c
 delete mode 100644 drivers/gpu/drm/mediatek/mtk_gem.h

-- 
2.53.0.473.g4a7958ca14-goog
Re: [PATCH RESEND 0/4] drm/gem-dma: Support dedicated DMA device for allocation
Posted by Thomas Zimmermann 4 weeks, 1 day ago
Hi

Am 10.03.26 um 04:25 schrieb Chen-Yu Tsai:
> (resent with Samuel's email address fixed)
>
> Hi folks,
>
> This series expands the "dedicated DMA device" support in DRM to the GEM
> DMA helpers, and converts the MediaTek DRM driver to setting the DMA
> device and dropping the custom GEM helpers that implemented this
> function.

I wanted to do this myself at some point. So thanks a lot for picking up 
the task. Happy to see this series.

>
> Various display drivers implement the "dedicated DMA device" support
> with custom GEM helpers. These include Exynos, MediaTek, and Rockchip
> to name a few. Allwinner does something entirely different, calling
> of_dma_configure() on the virtual display device using the OF node of
> the actual DMA device. Recently this causes a warning if IOMMUs are
> involved.
>
> This series intends to allow the core helpers to deal with it, and not
> have every driver implement it in slightly different ways, duplicating
> code.
>
> Patch 1 adds dedicated DMA device support to drm_prime_pages_to_sg().
> I believe this was missing from the original change that added dedicated
> DMA devices for PRIME.

We originally added the dedicated DMA device for supporting PRIME on USB 
graphics adapters, where the DMA buffer has to be allocated wrt to the 
USB controller. We left out anything that wasn't necessary.

>
> Patch 2 adds support for dedicated DMA device to the GEM DMA helpers
> for GEM buffer allocation and mmap.
>
> Patch 3 converts the MediaTek DRM driver to use the dedicated DMA device
> support, and drop all the remaining custom GEM callbacks that deal with
> it.
>
> Patch 4 converts the Allwinner sun4i DRM driver to use the dedicated DMA
> device support, instead of the of_dma_configure() hack it currently has.
>
> The series should be merged through drm-misc-next so that other drivers
> can take advantage of the change.

Yes.

Best regards
Thomas

>
> I also intend to try to convert the Exynos and Rockchip drivers, however
> both also have options to set DMA_ATTR_NO_KERNEL_MAPPING when using
> dma_alloc_attrs() to allocate memory for the buffers. I intend to
> resurrect the DRM_MODE_DUMB_KERNEL_MAP work from Rob Herring [1]
> to handle this. The Rockchip driver also has custom IOMMU attachment
> that I'm still trying to understand.
>
>
> Thanks
> ChenYu
>
>
> Chen-Yu Tsai (4):
>    drm/prime: Limit scatter list size with dedicated DMA device
>    drm/gem-dma: Support dedicated DMA device for allocation and mapping
>    drm/mediatek: Set dedicated DMA device and drop custom GEM callbacks
>    drm/sun4i: Use backend/mixer as dedicated DMA device
>
>   drivers/gpu/drm/drm_gem_dma_helper.c   |  21 ++-
>   drivers/gpu/drm/drm_prime.c            |   2 +-
>   drivers/gpu/drm/mediatek/mtk_crtc.c    |   1 -
>   drivers/gpu/drm/mediatek/mtk_drm_drv.c |  21 +--
>   drivers/gpu/drm/mediatek/mtk_drm_drv.h |   1 -
>   drivers/gpu/drm/mediatek/mtk_gem.c     | 231 -------------------------
>   drivers/gpu/drm/mediatek/mtk_gem.h     |  17 --
>   drivers/gpu/drm/sun4i/sun4i_backend.c  |  27 +--
>   drivers/gpu/drm/sun4i/sun8i_mixer.c    |  27 +--
>   9 files changed, 46 insertions(+), 302 deletions(-)
>   delete mode 100644 drivers/gpu/drm/mediatek/mtk_gem.c
>   delete mode 100644 drivers/gpu/drm/mediatek/mtk_gem.h
>

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)