Skip to content

Commit

Permalink
drm/gem: rename GEM CMA helpers to GEM DMA helpers
Browse files Browse the repository at this point in the history
Rename "GEM CMA" helpers to "GEM DMA" helpers - considering the
hierarchy of APIs (mm/cma -> dma -> gem dma) calling them "GEM
DMA" seems to be more applicable.

Besides that, commit e57924d ("drm/doc: Task to rename CMA helpers")
requests to rename the CMA helpers and implies that people seem to be
confused about the naming.

In order to do this renaming the following script was used:

```
	#!/bin/bash

	DIRS="drivers/gpu include/drm Documentation/gpu"

	REGEX_SYM_UPPER="[0-9A-Z_\-]"
	REGEX_SYM_LOWER="[0-9a-z_\-]"

	REGEX_GREP_UPPER="(${REGEX_SYM_UPPER}*)(GEM)_CMA_(${REGEX_SYM_UPPER}*)"
	REGEX_GREP_LOWER="(${REGEX_SYM_LOWER}*)(gem)_cma_(${REGEX_SYM_LOWER}*)"

	REGEX_SED_UPPER="s/${REGEX_GREP_UPPER}/\1\2_DMA_\3/g"
	REGEX_SED_LOWER="s/${REGEX_GREP_LOWER}/\1\2_dma_\3/g"

	# Find all upper case 'CMA' symbols and replace them with 'DMA'.
	for ff in $(grep -REHl "${REGEX_GREP_UPPER}" $DIRS)
	do
	       sed -i -E "$REGEX_SED_UPPER" $ff
	done

	# Find all lower case 'cma' symbols and replace them with 'dma'.
	for ff in $(grep -REHl "${REGEX_GREP_LOWER}" $DIRS)
	do
	       sed -i -E "$REGEX_SED_LOWER" $ff
	done

	# Replace all occurrences of 'CMA' / 'cma' in comments and
	# documentation files with 'DMA' / 'dma'.
	for ff in $(grep -RiHl " cma " $DIRS)
	do
		sed -i -E "s/ cma / dma /g" $ff
		sed -i -E "s/ CMA / DMA /g" $ff
	done

	# Rename all 'cma_obj's to 'dma_obj'.
	for ff in $(grep -RiHl "cma_obj" $DIRS)
	do
		sed -i -E "s/cma_obj/dma_obj/g" $ff
	done
```

Only a few more manual modifications were needed, e.g. reverting the
following modifications in some DRM Kconfig files

    -       select CMA if HAVE_DMA_CONTIGUOUS
    +       select DMA if HAVE_DMA_CONTIGUOUS

as well as manually picking the occurrences of 'CMA'/'cma' in comments and
documentation which relate to "GEM CMA", but not "FB CMA".

Also drivers/gpu/drm/Makefile was fixed up manually after renaming
drm_gem_cma_helper.c to drm_gem_dma_helper.c.

This patch is compile-time tested building a x86_64 kernel with
`make allyesconfig && make drivers/gpu/drm`.

Acked-by: Sam Ravnborg <[email protected]>
Acked-by: Thomas Zimmermann <[email protected]>
Reviewed-by: Laurent Pinchart <[email protected]>
Signed-off-by: Danilo Krummrich <[email protected]>
Reviewed-by: Liviu Dudau <[email protected]> #drivers/gpu/drm/arm
Signed-off-by: Sam Ravnborg <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
  • Loading branch information
dakr authored and sravnborg committed Aug 3, 2022
1 parent 6bcfe8e commit 4a83c26
Show file tree
Hide file tree
Showing 143 changed files with 639 additions and 642 deletions.
16 changes: 8 additions & 8 deletions Documentation/gpu/drm-mm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,12 @@ Drivers that want to map the GEM object upfront instead of handling page
faults can implement their own mmap file operation handler.

For platforms without MMU the GEM core provides a helper method
drm_gem_cma_get_unmapped_area(). The mmap() routines will call this to get a
drm_gem_dma_get_unmapped_area(). The mmap() routines will call this to get a
proposed address for the mapping.

To use drm_gem_cma_get_unmapped_area(), drivers must fill the struct
To use drm_gem_dma_get_unmapped_area(), drivers must fill the struct
:c:type:`struct file_operations <file_operations>` get_unmapped_area field with
a pointer on drm_gem_cma_get_unmapped_area().
a pointer on drm_gem_dma_get_unmapped_area().

More detailed information about get_unmapped_area can be found in
Documentation/admin-guide/mm/nommu-mmap.rst
Expand Down Expand Up @@ -355,16 +355,16 @@ GEM Function Reference
.. kernel-doc:: drivers/gpu/drm/drm_gem.c
:export:

GEM CMA Helper Functions Reference
GEM DMA Helper Functions Reference
----------------------------------

.. kernel-doc:: drivers/gpu/drm/drm_gem_cma_helper.c
:doc: cma helpers
.. kernel-doc:: drivers/gpu/drm/drm_gem_dma_helper.c
:doc: dma helpers

.. kernel-doc:: include/drm/drm_gem_cma_helper.h
.. kernel-doc:: include/drm/drm_gem_dma_helper.h
:internal:

.. kernel-doc:: drivers/gpu/drm/drm_gem_cma_helper.c
.. kernel-doc:: drivers/gpu/drm/drm_gem_dma_helper.c
:export:

GEM SHMEM Helper Function Reference
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,11 @@ config DRM_TTM_HELPER
help
Helpers for ttm-based gem objects

config DRM_GEM_CMA_HELPER
config DRM_GEM_DMA_HELPER
tristate
depends on DRM
help
Choose this if you need the GEM CMA helper functions
Choose this if you need the GEM DMA helper functions

config DRM_GEM_SHMEM_HELPER
tristate
Expand Down
6 changes: 3 additions & 3 deletions drivers/gpu/drm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ obj-$(CONFIG_DRM_PANEL_ORIENTATION_QUIRKS) += drm_panel_orientation_quirks.o

obj-$(CONFIG_DRM_BUDDY) += drm_buddy.o

drm_cma_helper-y := drm_gem_cma_helper.o
drm_cma_helper-$(CONFIG_DRM_KMS_HELPER) += drm_fb_dma_helper.o
obj-$(CONFIG_DRM_GEM_CMA_HELPER) += drm_cma_helper.o
drm_dma_helper-y := drm_gem_dma_helper.o
drm_dma_helper-$(CONFIG_DRM_KMS_HELPER) += drm_fb_dma_helper.o
obj-$(CONFIG_DRM_GEM_DMA_HELPER) += drm_dma_helper.o

drm_shmem_helper-y := drm_gem_shmem_helper.o
obj-$(CONFIG_DRM_GEM_SHMEM_HELPER) += drm_shmem_helper.o
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/arm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ config DRM_HDLCD
depends on DRM && OF && (ARM || ARM64 || COMPILE_TEST)
depends on COMMON_CLK
select DRM_KMS_HELPER
select DRM_GEM_CMA_HELPER
select DRM_GEM_DMA_HELPER
help
Choose this option if you have an ARM High Definition Colour LCD
controller.
Expand All @@ -27,7 +27,7 @@ config DRM_MALI_DISPLAY
depends on DRM && OF && (ARM || ARM64 || COMPILE_TEST)
depends on COMMON_CLK
select DRM_KMS_HELPER
select DRM_GEM_CMA_HELPER
select DRM_GEM_DMA_HELPER
select VIDEOMODE_HELPERS
help
Choose this option if you want to compile the ARM Mali Display
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/arm/display/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ config DRM_KOMEDA
depends on DRM && OF
depends on COMMON_CLK
select DRM_KMS_HELPER
select DRM_GEM_CMA_HELPER
select DRM_GEM_DMA_HELPER
select VIDEOMODE_HELPERS
help
Choose this option if you want to compile the ARM Komeda display
Expand Down
6 changes: 3 additions & 3 deletions drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <drm/drm_device.h>
#include <drm/drm_fb_dma_helper.h>
#include <drm/drm_gem.h>
#include <drm/drm_gem_cma_helper.h>
#include <drm/drm_gem_dma_helper.h>
#include <drm/drm_gem_framebuffer_helper.h>

#include "komeda_framebuffer.h"
Expand Down Expand Up @@ -137,7 +137,7 @@ komeda_fb_none_afbc_size_check(struct komeda_dev *mdev, struct komeda_fb *kfb,
}

min_size = komeda_fb_get_pixel_addr(kfb, 0, fb->height, i)
- to_drm_gem_cma_obj(obj)->paddr;
- to_drm_gem_dma_obj(obj)->paddr;
if (obj->size < min_size) {
DRM_DEBUG_KMS("The fb->obj[%d] size: 0x%zx lower than the minimum requirement: 0x%llx.\n",
i, obj->size, min_size);
Expand Down Expand Up @@ -239,7 +239,7 @@ dma_addr_t
komeda_fb_get_pixel_addr(struct komeda_fb *kfb, int x, int y, int plane)
{
struct drm_framebuffer *fb = &kfb->base;
const struct drm_gem_cma_object *obj;
const struct drm_gem_dma_object *obj;
u32 offset, plane_x, plane_y, block_w, block_sz;

if (plane >= fb->format->num_planes) {
Expand Down
10 changes: 5 additions & 5 deletions drivers/gpu/drm/arm/display/komeda/komeda_kms.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <drm/drm_atomic_helper.h>
#include <drm/drm_drv.h>
#include <drm/drm_fb_helper.h>
#include <drm/drm_gem_cma_helper.h>
#include <drm/drm_gem_dma_helper.h>
#include <drm/drm_gem_framebuffer_helper.h>
#include <drm/drm_managed.h>
#include <drm/drm_probe_helper.h>
Expand All @@ -21,9 +21,9 @@
#include "komeda_framebuffer.h"
#include "komeda_kms.h"

DEFINE_DRM_GEM_CMA_FOPS(komeda_cma_fops);
DEFINE_DRM_GEM_DMA_FOPS(komeda_cma_fops);

static int komeda_gem_cma_dumb_create(struct drm_file *file,
static int komeda_gem_dma_dumb_create(struct drm_file *file,
struct drm_device *dev,
struct drm_mode_create_dumb *args)
{
Expand All @@ -32,7 +32,7 @@ static int komeda_gem_cma_dumb_create(struct drm_file *file,

args->pitch = ALIGN(pitch, mdev->chip.bus_width);

return drm_gem_cma_dumb_create_internal(file, dev, args);
return drm_gem_dma_dumb_create_internal(file, dev, args);
}

static irqreturn_t komeda_kms_irq_handler(int irq, void *data)
Expand Down Expand Up @@ -60,7 +60,7 @@ static irqreturn_t komeda_kms_irq_handler(int irq, void *data)
static const struct drm_driver komeda_kms_driver = {
.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
.lastclose = drm_fb_helper_lastclose,
DRM_GEM_CMA_DRIVER_OPS_WITH_DUMB_CREATE(komeda_gem_cma_dumb_create),
DRM_GEM_DMA_DRIVER_OPS_WITH_DUMB_CREATE(komeda_gem_dma_dumb_create),
.fops = &komeda_cma_fops,
.name = "komeda",
.desc = "Arm Komeda Display Processor driver",
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/arm/hdlcd_crtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <drm/drm_fb_dma_helper.h>
#include <drm/drm_fb_helper.h>
#include <drm/drm_framebuffer.h>
#include <drm/drm_gem_cma_helper.h>
#include <drm/drm_gem_dma_helper.h>
#include <drm/drm_of.h>
#include <drm/drm_probe_helper.h>
#include <drm/drm_vblank.h>
Expand Down
6 changes: 3 additions & 3 deletions drivers/gpu/drm/arm/hdlcd_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <drm/drm_debugfs.h>
#include <drm/drm_drv.h>
#include <drm/drm_fb_helper.h>
#include <drm/drm_gem_cma_helper.h>
#include <drm/drm_gem_dma_helper.h>
#include <drm/drm_gem_framebuffer_helper.h>
#include <drm/drm_modeset_helper.h>
#include <drm/drm_module.h>
Expand Down Expand Up @@ -225,11 +225,11 @@ static void hdlcd_debugfs_init(struct drm_minor *minor)
}
#endif

DEFINE_DRM_GEM_CMA_FOPS(fops);
DEFINE_DRM_GEM_DMA_FOPS(fops);

static const struct drm_driver hdlcd_driver = {
.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
DRM_GEM_CMA_DRIVER_OPS,
DRM_GEM_DMA_DRIVER_OPS,
#ifdef CONFIG_DEBUG_FS
.debugfs_init = hdlcd_debugfs_init,
#endif
Expand Down
8 changes: 4 additions & 4 deletions drivers/gpu/drm/arm/malidp_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <drm/drm_drv.h>
#include <drm/drm_fb_helper.h>
#include <drm/drm_fourcc.h>
#include <drm/drm_gem_cma_helper.h>
#include <drm/drm_gem_dma_helper.h>
#include <drm/drm_gem_framebuffer_helper.h>
#include <drm/drm_modeset_helper.h>
#include <drm/drm_module.h>
Expand Down Expand Up @@ -456,7 +456,7 @@ static int malidp_irq_init(struct platform_device *pdev)
return 0;
}

DEFINE_DRM_GEM_CMA_FOPS(fops);
DEFINE_DRM_GEM_DMA_FOPS(fops);

static int malidp_dumb_create(struct drm_file *file_priv,
struct drm_device *drm,
Expand All @@ -468,7 +468,7 @@ static int malidp_dumb_create(struct drm_file *file_priv,

args->pitch = ALIGN(DIV_ROUND_UP(args->width * args->bpp, 8), alignment);

return drm_gem_cma_dumb_create_internal(file_priv, drm, args);
return drm_gem_dma_dumb_create_internal(file_priv, drm, args);
}

#ifdef CONFIG_DEBUG_FS
Expand Down Expand Up @@ -565,7 +565,7 @@ static void malidp_debugfs_init(struct drm_minor *minor)

static const struct drm_driver malidp_driver = {
.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
DRM_GEM_CMA_DRIVER_OPS_WITH_DUMB_CREATE(malidp_dumb_create),
DRM_GEM_DMA_DRIVER_OPS_WITH_DUMB_CREATE(malidp_dumb_create),
#ifdef CONFIG_DEBUG_FS
.debugfs_init = malidp_debugfs_init,
#endif
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/arm/malidp_mw.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <drm/drm_fb_dma_helper.h>
#include <drm/drm_fourcc.h>
#include <drm/drm_framebuffer.h>
#include <drm/drm_gem_cma_helper.h>
#include <drm/drm_gem_dma_helper.h>
#include <drm/drm_probe_helper.h>
#include <drm/drm_writeback.h>

Expand Down Expand Up @@ -160,7 +160,7 @@ malidp_mw_encoder_atomic_check(struct drm_encoder *encoder,

n_planes = fb->format->num_planes;
for (i = 0; i < n_planes; i++) {
struct drm_gem_cma_object *obj = drm_fb_dma_get_gem_obj(fb, i);
struct drm_gem_dma_object *obj = drm_fb_dma_get_gem_obj(fb, i);
/* memory write buffers are never rotated */
u8 alignment = malidp_hw_get_pitch_align(malidp->dev, 0);

Expand Down
16 changes: 8 additions & 8 deletions drivers/gpu/drm/arm/malidp_planes.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <drm/drm_fb_dma_helper.h>
#include <drm/drm_fourcc.h>
#include <drm/drm_framebuffer.h>
#include <drm/drm_gem_cma_helper.h>
#include <drm/drm_gem_dma_helper.h>
#include <drm/drm_gem_framebuffer_helper.h>
#include <drm/drm_print.h>

Expand Down Expand Up @@ -333,15 +333,15 @@ static bool malidp_check_pages_threshold(struct malidp_plane_state *ms,

for (i = 0; i < ms->n_planes; i++) {
struct drm_gem_object *obj;
struct drm_gem_cma_object *cma_obj;
struct drm_gem_dma_object *dma_obj;
struct sg_table *sgt;
struct scatterlist *sgl;

obj = drm_gem_fb_get_obj(ms->base.fb, i);
cma_obj = to_drm_gem_cma_obj(obj);
dma_obj = to_drm_gem_dma_obj(obj);

if (cma_obj->sgt)
sgt = cma_obj->sgt;
if (dma_obj->sgt)
sgt = dma_obj->sgt;
else
sgt = obj->funcs->get_sg_table(obj);

Expand All @@ -352,14 +352,14 @@ static bool malidp_check_pages_threshold(struct malidp_plane_state *ms,

while (sgl) {
if (sgl->length < pgsize) {
if (!cma_obj->sgt)
if (!dma_obj->sgt)
kfree(sgt);
return false;
}

sgl = sg_next(sgl);
}
if (!cma_obj->sgt)
if (!dma_obj->sgt)
kfree(sgt);
}

Expand Down Expand Up @@ -732,7 +732,7 @@ static void malidp_set_plane_base_addr(struct drm_framebuffer *fb,
paddr = drm_fb_dma_get_gem_addr(fb, plane->state,
plane_index);
} else {
struct drm_gem_cma_object *obj;
struct drm_gem_dma_object *obj;

obj = drm_fb_dma_get_gem_obj(fb, plane_index);

Expand Down
6 changes: 3 additions & 3 deletions drivers/gpu/drm/armada/armada_gem.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ armada_gem_linear_back(struct drm_device *dev, struct armada_gem_object *obj)
}

/*
* We could grab something from CMA if it's enabled, but that
* We could grab something from DMA if it's enabled, but that
* involves building in a problem:
*
* CMA's interface uses dma_alloc_coherent(), which provides us
* with an CPU virtual address and a device address.
* GEM DMA helper interface uses dma_alloc_coherent(), which provides
* us with an CPU virtual address and a device address.
*
* The CPU virtual address may be either an address in the kernel
* direct mapped region (for example, as it would be on x86) or
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/aspeed/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ config DRM_ASPEED_GFX
depends on (COMPILE_TEST || ARCH_ASPEED)
depends on MMU
select DRM_KMS_HELPER
select DRM_GEM_CMA_HELPER
select DRM_GEM_DMA_HELPER
select DMA_CMA if HAVE_DMA_CONTIGUOUS
select CMA if HAVE_DMA_CONTIGUOUS
select MFD_SYSCON
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <drm/drm_fourcc.h>
#include <drm/drm_framebuffer.h>
#include <drm/drm_gem_atomic_helper.h>
#include <drm/drm_gem_cma_helper.h>
#include <drm/drm_gem_dma_helper.h>
#include <drm/drm_panel.h>
#include <drm/drm_simple_kms_helper.h>
#include <drm/drm_vblank.h>
Expand Down Expand Up @@ -168,7 +168,7 @@ static void aspeed_gfx_pipe_update(struct drm_simple_display_pipe *pipe,
struct drm_crtc *crtc = &pipe->crtc;
struct drm_framebuffer *fb = pipe->plane.state->fb;
struct drm_pending_vblank_event *event;
struct drm_gem_cma_object *gem;
struct drm_gem_dma_object *gem;

spin_lock_irq(&crtc->dev->event_lock);
event = crtc->state->event;
Expand Down
6 changes: 3 additions & 3 deletions drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <drm/drm_crtc_helper.h>
#include <drm/drm_device.h>
#include <drm/drm_fb_helper.h>
#include <drm/drm_gem_cma_helper.h>
#include <drm/drm_gem_dma_helper.h>
#include <drm/drm_gem_framebuffer_helper.h>
#include <drm/drm_module.h>
#include <drm/drm_probe_helper.h>
Expand Down Expand Up @@ -245,11 +245,11 @@ static void aspeed_gfx_unload(struct drm_device *drm)
drm_kms_helper_poll_fini(drm);
}

DEFINE_DRM_GEM_CMA_FOPS(fops);
DEFINE_DRM_GEM_DMA_FOPS(fops);

static const struct drm_driver aspeed_gfx_driver = {
.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
DRM_GEM_CMA_DRIVER_OPS,
DRM_GEM_DMA_DRIVER_OPS,
.fops = &fops,
.name = "aspeed-gfx-drm",
.desc = "ASPEED GFX DRM",
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/atmel-hlcdc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
config DRM_ATMEL_HLCDC
tristate "DRM Support for ATMEL HLCDC Display Controller"
depends on DRM && OF && COMMON_CLK && MFD_ATMEL_HLCDC && ARM
select DRM_GEM_CMA_HELPER
select DRM_GEM_DMA_HELPER
select DRM_KMS_HELPER
select DRM_PANEL
help
Expand Down
6 changes: 3 additions & 3 deletions drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <drm/drm_atomic_helper.h>
#include <drm/drm_drv.h>
#include <drm/drm_fb_helper.h>
#include <drm/drm_gem_cma_helper.h>
#include <drm/drm_gem_dma_helper.h>
#include <drm/drm_gem_framebuffer_helper.h>
#include <drm/drm_module.h>
#include <drm/drm_probe_helper.h>
Expand Down Expand Up @@ -730,11 +730,11 @@ static void atmel_hlcdc_dc_unload(struct drm_device *dev)
clk_disable_unprepare(dc->hlcdc->periph_clk);
}

DEFINE_DRM_GEM_CMA_FOPS(fops);
DEFINE_DRM_GEM_DMA_FOPS(fops);

static const struct drm_driver atmel_hlcdc_dc_driver = {
.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
DRM_GEM_CMA_DRIVER_OPS,
DRM_GEM_DMA_DRIVER_OPS,
.fops = &fops,
.name = "atmel-hlcdc",
.desc = "Atmel HLCD Controller DRM",
Expand Down
Loading

0 comments on commit 4a83c26

Please sign in to comment.