drm: Support DMA per allocation kernel mappings
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v3 Latest3 patches 6 repliesIn review
- v24 patches 8 repliesSuperseded
Changes in v3 from the cover letter
- Dropped rcar-du patch in favor of just using dma_get_sgtable_attrs() in patch 2
- Patch 1
- Switched to drm_warn_once()
- Moved flag definition from include/uapi/ to include/drm/drm_dumb_buffers.h
- Reworded commit message
- Patch 2
- Added change for rcar-du: s/dma_get_sgtable()/dma_get_sgtable_attrs()/
- Patch 3
- Added back DRM_MODE_DUMB_KERNEL_MAP flag to all drivers calling drm_gem_dma_dumb_create_internal()
- Expanded commit message to cover display drivers needing the kernel mapping to do scan out
Patches in v3 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | drm: Introduce DRM_MODE_DUMB_KERNEL_MAP flagdrivers/ drivers/ include/ | +9 | 3 replies | |
| 2/3 | drm/gem-dma: Use the dma_*_attr API variantdrivers/ drivers/ drivers/ +1 more | +22 | 1 reply | |
| 3/3 | drm/gem-dma: Support DRM_MODE_DUMB_KERNEL_MAP flagdrivers/ drivers/ drivers/ +11 more | +63 | 2 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.
Cover letter [PATCH v3 0/3] drm: Support DMA per allocation kernel mappings
Hi everyone,
This is v3 of the "DMA per allocation kernel mappings" series.
Changes since v2:
- Dropped rcar-du patch in favor of just using dma_get_sgtable_attrs() in patch 2
- Patch 1
- Switched to drm_warn_once()
- Moved flag definition from include/uapi/ to include/drm/drm_dumb_buffers.h
- Reworded commit message
- Patch 2
- Added change for rcar-du: s/dma_get_sgtable()/dma_get_sgtable_attrs()/
- Patch 3
- Added back DRM_MODE_DUMB_KERNEL_MAP flag to all drivers calling drm_gem_dma_dumb_create_internal()
- Expanded commit message to cover display drivers needing the kernel mapping to do scan out
This is an attempt to revive Rob Herring's "DMA per allocation kernel mappings" [1] series from 2019. This series stacks on top of my recent "drm/gem-dma: Support dedicated DMA device for allocation" series [2]. Many of the allocation paths are touched by both.
The 3 driver conversions from the original series are not included, as the changes have landed in some other form.
Patch 1 adds the kernel internal DRM_MODE_DUMB_KERNEL_MAP flag.
Patch 2 adds the dma_attr field to drm_gem_dma_object, and converts the GEM DMA helpers to use the dma_*_attrs() variant of the DMA API.
Patch 3 adds support for DRM_MODE_DUMB_KERNEL_MAP to the GEM DMA helpers by setting the DMA_ATTR_NO_KERNEL_MAPING attribute for requests without the DRM_MODE_DUMB_KERNEL_MAP flag.
All existing callers of drm_gem_dma_dumb_create_internal() will have DRM_MODE_DUMB_KERNEL_MAP set to maintain existing behavior.
I have also started to convert the exynos driver to use the GEM DMA helpers. I also plan on looking into the rockchip driver, but that one has a separate IOMMU path that needs to be handled. I might copy the approach used in the exynos driver to deal with it.
Changes compared to the original version from Rob (v1):
- Link to original v1:
https://lore.kernel.org/dri-devel/[email protected]/
- Rebased onto renamed GEM DMA helpers
- New patch for rcar-du
- Patch 2
- Make drm_mode_create_dumb_ioctl() emit warning if args->flags is not zero
- Patch 3
- Made vc4_bo_purge() use dma_free_attrs(); this is the other location of DMA API used with drm_gem_dma_object outside the helpers
- Expanded commit message
- Patch 4
- Added kernal mapping check in drm_fb_dma_get_scanout_buffer() and
drm_gem_dma_vmap().
- Made drm_gem_dma_print_info() show "vaddr=(no mapping)" for objects allocated without kernel mapping
- Dropped existing DRM_MODE_DUMB_KERNEL_MAP flag addition in various drivers
- Added DRM_MODE_DUMB_KERNEL_MAP flag to adp_drm_gem_dumb_create()
- Added flags field kerneldoc for drm_gem_dma_create_with_handle()
I dropped all the original Reviewed-by tags, as it's been 5 years since the changes were first posted, and also because the code has changed a lot.
Please have a look.
Thanks
ChenYu
Original cover letter from Rob:
This series adds support for CMA/DMA users to skip kernel mappings for GEM allocations. The DMA API only guarantees a kernel mapping at allocation time. Creating mappings with vmap() after allocation may or may not work as not all allocations have a struct page. As virtual memory space is limited on 32-bit systems some drivers will skip kernel mappings when possible. This prevents those drivers from using CMA helpers and the generic fbdev emulation which results in a lot of duplicated code.
In order to distinguish between kernel and userspace allocations, a new flag, DRM_MODE_DUMB_KERNEL_MAP, for drm_mode_create_dumb() is introduced. This allows drivers to override the default behavior for CMA helpers of always creating a kernel mapping.
Mediatek is converted to CMA helpers and Rockchip is converted to generic fbdev support. I also have patches to convert Rockchip to CMA and shmem helpers, but they need a bit more work. Exynos can also probably be converted to use CMA helpers.
Compile tested only. I did test fbdev on Rockchip, but the h/w I have has an IOMMU, so the CMA code path doesn't get tested.
- end quote -
[1] https://lore.kernel.org/dri-devel/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
Rob Herring (3):
drm: Introduce DRM_MODE_DUMB_KERNEL_MAP flag drm/gem-dma: Use the dma_*_attr API variant drm/gem-dma: Support DRM_MODE_DUMB_KERNEL_MAP flag
drivers/gpu/drm/adp/adp_drv.c | 1 + .../gpu/drm/arm/display/komeda/komeda_kms.c | 1 + drivers/gpu/drm/arm/malidp_drv.c | 1 + drivers/gpu/drm/drm_client.c | 2 + drivers/gpu/drm/drm_dumb_buffers.c | 4 + drivers/gpu/drm/drm_fb_dma_helper.c | 4 + drivers/gpu/drm/drm_gem_dma_helper.c | 93 ++++++++++++------- drivers/gpu/drm/logicvc/logicvc_drm.c | 1 + drivers/gpu/drm/meson/meson_drv.c | 1 + drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c | 2 + drivers/gpu/drm/renesas/rcar-du/rcar_du_vsp.c | 5 +- drivers/gpu/drm/renesas/rz-du/rzg2l_du_kms.c | 1 + drivers/gpu/drm/stm/drv.c | 3 +- drivers/gpu/drm/sun4i/sun4i_drv.c | 1 + drivers/gpu/drm/vc4/vc4_bo.c | 2 +- drivers/gpu/drm/vc4/vc4_drv.c | 2 + drivers/gpu/drm/verisilicon/vs_drm.c | 2 + drivers/gpu/drm/xlnx/zynqmp_kms.c | 2 + include/drm/drm_dumb_buffers.h | 3 + include/drm/drm_gem_dma_helper.h | 3 + 20 files changed, 94 insertions(+), 40 deletions(-)
Signature · 1 line
2.53.0.1018.g2bb0e51243-goog