[PATCH v4] DRM: add drm gem CMA helper

Lars-Peter Clausen lars at metafoo.de
Wed Aug 8 09:25:30 PDT 2012


On 08/08/2012 04:44 PM, Laurent Pinchart wrote:
> Hi Sascha,
> 
> On Wednesday 27 June 2012 15:30:18 Sascha Hauer wrote:
>> Many embedded drm devices do not have a IOMMU and no dedicated
>> memory for graphics. These devices use CMA (Contiguous Memory
>> Allocator) backed graphics memory. This patch provides helper
>> functions to be able to share the code. The code technically does
>> not depend on CMA as the backend allocator, the name has been chosen
>> because cma makes for a nice, short but still descriptive function
>> prefix.
>>
>> Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
>> ---
>>
>> changes since v3:
>> - *really* use DIV_ROUND_UP(args->width * args->bpp, 8) to calculate the
>> pitch changes since v2:
>> - make drm_gem_cma_create_with_handle static
>> - use DIV_ROUND_UP(args->width * args->bpp, 8) to calculate the pitch
>> - make drm_gem_cma_vm_ops const
>> - add missing #include <linux/export.h>
>> changes since v1:
>> - map whole buffer at mmap time, not page by page at fault time
>> - several cleanups as suggested by Lars-Peter Clausen and Laurent Pinchart
>>
>>  drivers/gpu/drm/Kconfig              |    6 +
>>  drivers/gpu/drm/Makefile             |    1 +
>>  drivers/gpu/drm/drm_gem_cma_helper.c |  251 +++++++++++++++++++++++++++++++
>>  include/drm/drm_gem_cma_helper.h     |   44 ++++++
>>  4 files changed, 302 insertions(+)
>>  create mode 100644 drivers/gpu/drm/drm_gem_cma_helper.c
>>  create mode 100644 include/drm/drm_gem_cma_helper.h
>>
>> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
>> index dc5df12..8f362ec 100644
>> --- a/drivers/gpu/drm/Kconfig
>> +++ b/drivers/gpu/drm/Kconfig
>> @@ -53,6 +53,12 @@ config DRM_TTM
>>  	  GPU memory types. Will be enabled automatically if a device driver
>>  	  uses it.
>>
>> +config DRM_GEM_CMA_HELPER
>> +	tristate
>> +	depends on DRM
>> +	help
>> +	  Choose this if you need the GEM CMA helper functions
>> +
>>  config DRM_TDFX
>>  	tristate "3dfx Banshee/Voodoo3+"
>>  	depends on DRM && PCI
>> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
>> index 0487ff6..8759cda 100644
>> --- a/drivers/gpu/drm/Makefile
>> +++ b/drivers/gpu/drm/Makefile
>> @@ -15,6 +15,7 @@ drm-y       :=	drm_auth.o drm_buffer.o drm_bufs.o
>> drm_cache.o \ drm_trace_points.o drm_global.o drm_prime.o
>>
>>  drm-$(CONFIG_COMPAT) += drm_ioc32.o
>> +drm-$(CONFIG_DRM_GEM_CMA_HELPER) += drm_gem_cma_helper.o
> 
> This results in a built failure for me with
> 
> CONFIG_DRM=y
> CONFIG_DRM_KMS_HELPER=m
> # CONFIG_DRM_LOAD_EDID_FIRMWARE is not set
> CONFIG_DRM_GEM_CMA_HELPER=m
> CONFIG_DRM_KMS_CMA_HELPER=m
> 
> drm_gem_cma_helper.o isn't compiled at all. Can you reproduce the problem ?

The Kconfig entry needs to be bool instead of tristate.

- Lars



More information about the dri-devel mailing list