Re: [PATCH/RFC 4/4] common: dma-mapping: Move dma_common_*() to<linux/dma-mapping.h>

From: Marek Szyprowski
Date: Wed Jan 02 2013 - 09:22:33 EST


On 12/28/2012 8:23 PM, Geert Uytterhoeven wrote:
dma_common_mmap() and dma_common_get_sgtable() are defined in
drivers/base/dma-mapping.c, and always compiled if CONFIG_HAS_DMA=y.

However, their forward declarations and the inline functions defined on top
of them (dma_mmap_attrs(), dma_mmap_coherent(), dma_mmap_writecombine(),
dma_get_sgtable_attrs()), dma_get_sgtable()) are in
<asm-generic/dma-mapping-common.h>, which is not included by all
architectures supporting CONFIG_HAS_DMA=y. There exist no alternative

Hence for e.g. m68k allmodconfig, I get:

drivers/media/v4l2-core/videobuf2-dma-contig.c: In function âvb2_dc_mmapâ:
drivers/media/v4l2-core/videobuf2-dma-contig.c:204: error: implicit declaration of function âdma_mmap_coherentâ
drivers/media/v4l2-core/videobuf2-dma-contig.c: In function âvb2_dc_get_base_sgtâ:
drivers/media/v4l2-core/videobuf2-dma-contig.c:387: error: implicit declaration of function âdma_get_sgtableâ

To fix this
- Move the forward declarations and inline definitions to
<linux/dma-mapping.h>, so all CONFIG_HAS_DMA=y architectures can use
- Replace the hard "BUG_ON(!ops)" checks for dma_map_ops by soft checks,
so architectures can fall back to the common code by returning NULL
from their get_dma_ops(). Note that there are no "BUG_ON(!ops)" checks
in other functions in <asm-generic/dma-mapping-common.h>,
- Make "struct dma_map_ops *ops" const while we're at it.

I think that more appropriate way of handling it is to avoid dma_map_ops based
calls (those archs probably have some reasons why they don't use it at all) and
provide static inline stubs which call dma_common_mmap and dma_common_get_sgtable.

It is definitely my fault that I missed the case of non-dma-map-ops based archs
while I was adding support for dma_mmap_coherent and dma_get_sgt calls...

> (snipped)

Best regards
Marek Szyprowski
Samsung Poland R&D Center

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at