2014-10-19 16:10:19

by Stefan Hengelein

[permalink] [raw]
Subject: [PATCH] arm: dma-mapping: fix compilation error when CONFIG_MMU is not present

When CONFIG_MMU is not present, the variable 'atomic_pool' and the
function '__in_atomic_pool' are undeclared but used in part of the
code. Therefore, the compilation breaks.
Now, they are defined to dummy values when CONFIG_MMU is undefined.

This error was found with vampyr.

Signed-off-by: Stefan Hengelein <[email protected]>
---
arch/arm/mm/dma-mapping.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index c245d90..7d04cf7 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -573,12 +573,14 @@ static inline pgprot_t __get_dma_pgprot(struct dma_attrs *attrs, pgprot_t prot)
#else /* !CONFIG_MMU */

#define nommu() 1
+#define atomic_pool 0

#define __get_dma_pgprot(attrs, prot) __pgprot(0)
#define __alloc_remap_buffer(dev, size, gfp, prot, ret, c) NULL
#define __alloc_from_pool(size, ret_page) NULL
#define __alloc_from_contiguous(dev, size, prot, ret, c) NULL
#define __free_from_pool(cpu_addr, size) 0
+#define __in_atomic_pool(start, size) 0
#define __free_from_contiguous(dev, page, cpu_addr, size) do { } while (0)
#define __dma_free_remap(cpu_addr, size) do { } while (0)

--
1.9.1


2014-10-20 07:43:04

by Marek Szyprowski

[permalink] [raw]
Subject: Re: [PATCH] arm: dma-mapping: fix compilation error when CONFIG_MMU is not present

Hello,

On 2014-10-19 17:59, Stefan Hengelein wrote:
> When CONFIG_MMU is not present, the variable 'atomic_pool' and the
> function '__in_atomic_pool' are undeclared but used in part of the
> code. Therefore, the compilation breaks.
> Now, they are defined to dummy values when CONFIG_MMU is undefined.
>
> This error was found with vampyr.

Frankly, those variables are used only when CONFIG_MMU or
CONFIG_ARM_DMA_USE_IOMMU are set. The latter imho makes only sense
together with CONFIG_MMU, so the issue reported here doesn't really
happen in real world.

> Signed-off-by: Stefan Hengelein <[email protected]>
> ---
> arch/arm/mm/dma-mapping.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
> index c245d90..7d04cf7 100644
> --- a/arch/arm/mm/dma-mapping.c
> +++ b/arch/arm/mm/dma-mapping.c
> @@ -573,12 +573,14 @@ static inline pgprot_t __get_dma_pgprot(struct dma_attrs *attrs, pgprot_t prot)
> #else /* !CONFIG_MMU */
>
> #define nommu() 1
> +#define atomic_pool 0
>
> #define __get_dma_pgprot(attrs, prot) __pgprot(0)
> #define __alloc_remap_buffer(dev, size, gfp, prot, ret, c) NULL
> #define __alloc_from_pool(size, ret_page) NULL
> #define __alloc_from_contiguous(dev, size, prot, ret, c) NULL
> #define __free_from_pool(cpu_addr, size) 0
> +#define __in_atomic_pool(start, size) 0
> #define __free_from_contiguous(dev, page, cpu_addr, size) do { } while (0)
> #define __dma_free_remap(cpu_addr, size) do { } while (0)
>

Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland

2014-10-20 13:50:30

by Stefan Hengelein

[permalink] [raw]
Subject: Re: [PATCH] arm: dma-mapping: fix compilation error when CONFIG_MMU is not present

Well,

arch/arm/mm/dma-mapping.c: In function ‘__atomic_get_pages’:
arch/arm/mm/dma-mapping.c:1265:31: error: ‘atomic_pool’ undeclared
(first use in this function)

arch/arm/mm/dma-mapping.c: In function ‘__iommu_get_pages’:
arch/arm/mm/dma-mapping.c:1275:2: error: implicit declaration of
function ‘__in_atomic_pool’ [-Werror=implicit-function-declaration]


others:
arch/arm/mm/dma-mapping.c: In function ‘__iommu_alloc_remap’:
arch/arm/mm/dma-mapping.c:1200:4: error: ‘VM_ARM_DMA_CONSISTENT’
undeclared (first use in this function)
arch/arm/mm/dma-mapping.c:1200:4: note: each undeclared identifier is
reported only once for each function it appears in

arch/arm/mm/dma-mapping.c: In function ‘__iommu_get_pages’:
arch/arm/mm/dma-mapping.c:1282:29: error: ‘VM_ARM_DMA_CONSISTENT’
undeclared (first use in this function)
arch/arm/mm/dma-mapping.c: In function ‘arm_iommu_free_attrs’:
arch/arm/mm/dma-mapping.c:1411:4: error: ‘VM_ARM_DMA_CONSISTENT’
undeclared (first use in this function)


i've attached a configuration where it happens.
when you place the configuration in your tree and compile the file,
the errors should show up.

However, within the configuration CONFIG_ARM_DMA_USE_IOMMU is defined
and CONFIG_MMU is not. AFAIUI, if both should be enabled together, it
should be mapped in Kconfig somewhere, right?

Best Regards,
Stefan

2014-10-20 9:42 GMT+02:00 Marek Szyprowski <[email protected]>:
> Hello,
>
> On 2014-10-19 17:59, Stefan Hengelein wrote:
>>
>> When CONFIG_MMU is not present, the variable 'atomic_pool' and the
>> function '__in_atomic_pool' are undeclared but used in part of the
>> code. Therefore, the compilation breaks.
>> Now, they are defined to dummy values when CONFIG_MMU is undefined.
>>
>> This error was found with vampyr.
>
>
> Frankly, those variables are used only when CONFIG_MMU or
> CONFIG_ARM_DMA_USE_IOMMU are set. The latter imho makes only sense
> together with CONFIG_MMU, so the issue reported here doesn't really
> happen in real world.
>
>> Signed-off-by: Stefan Hengelein <[email protected]>
>> ---
>> arch/arm/mm/dma-mapping.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
>> index c245d90..7d04cf7 100644
>> --- a/arch/arm/mm/dma-mapping.c
>> +++ b/arch/arm/mm/dma-mapping.c
>> @@ -573,12 +573,14 @@ static inline pgprot_t __get_dma_pgprot(struct
>> dma_attrs *attrs, pgprot_t prot)
>> #else /* !CONFIG_MMU */
>> #define nommu() 1
>> +#define atomic_pool 0
>> #define __get_dma_pgprot(attrs, prot) __pgprot(0)
>> #define __alloc_remap_buffer(dev, size, gfp, prot, ret, c) NULL
>> #define __alloc_from_pool(size, ret_page) NULL
>> #define __alloc_from_contiguous(dev, size, prot, ret, c) NULL
>> #define __free_from_pool(cpu_addr, size) 0
>> +#define __in_atomic_pool(start, size) 0
>> #define __free_from_contiguous(dev, page, cpu_addr, size) do { }
>> while (0)
>> #define __dma_free_remap(cpu_addr, size) do { }
>> while (0)
>>
>
>
> Best regards
> --
> Marek Szyprowski, PhD
> Samsung R&D Institute Poland
>


Attachments:
.config (141.69 kB)

2014-10-21 00:05:29

by Laura Abbott

[permalink] [raw]
Subject: Re: [PATCH] arm: dma-mapping: fix compilation error when CONFIG_MMU is not present

On 10/20/2014 6:50 AM, Stefan Hengelein wrote:
> Well,
>
> arch/arm/mm/dma-mapping.c: In function ‘__atomic_get_pages’:
> arch/arm/mm/dma-mapping.c:1265:31: error: ‘atomic_pool’ undeclared
> (first use in this function)
>
> arch/arm/mm/dma-mapping.c: In function ‘__iommu_get_pages’:
> arch/arm/mm/dma-mapping.c:1275:2: error: implicit declaration of
> function ‘__in_atomic_pool’ [-Werror=implicit-function-declaration]
>
>
> others:
> arch/arm/mm/dma-mapping.c: In function ‘__iommu_alloc_remap’:
> arch/arm/mm/dma-mapping.c:1200:4: error: ‘VM_ARM_DMA_CONSISTENT’
> undeclared (first use in this function)
> arch/arm/mm/dma-mapping.c:1200:4: note: each undeclared identifier is
> reported only once for each function it appears in
>
> arch/arm/mm/dma-mapping.c: In function ‘__iommu_get_pages’:
> arch/arm/mm/dma-mapping.c:1282:29: error: ‘VM_ARM_DMA_CONSISTENT’
> undeclared (first use in this function)
> arch/arm/mm/dma-mapping.c: In function ‘arm_iommu_free_attrs’:
> arch/arm/mm/dma-mapping.c:1411:4: error: ‘VM_ARM_DMA_CONSISTENT’
> undeclared (first use in this function)
>
>
> i've attached a configuration where it happens.
> when you place the configuration in your tree and compile the file,
> the errors should show up.
>
> However, within the configuration CONFIG_ARM_DMA_USE_IOMMU is defined
> and CONFIG_MMU is not. AFAIUI, if both should be enabled together, it
> should be mapped in Kconfig somewhere, right?
>
> Best Regards,
> Stefan
>

There isn't a nice way to fixup the dma consistent flags so I would
say this option should just depend on MMU.

Thanks,
Laura

--
Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a
Linux Foundation Collaborative Project

2014-10-23 08:15:53

by Marek Szyprowski

[permalink] [raw]
Subject: Re: [PATCH] arm: dma-mapping: fix compilation error when CONFIG_MMU is not present

Hello,

On 2014-10-21 02:05, Laura Abbott wrote:
> On 10/20/2014 6:50 AM, Stefan Hengelein wrote:
>> Well,
>>
>> arch/arm/mm/dma-mapping.c: In function ‘__atomic_get_pages’:
>> arch/arm/mm/dma-mapping.c:1265:31: error: ‘atomic_pool’ undeclared
>> (first use in this function)
>>
>> arch/arm/mm/dma-mapping.c: In function ‘__iommu_get_pages’:
>> arch/arm/mm/dma-mapping.c:1275:2: error: implicit declaration of
>> function ‘__in_atomic_pool’ [-Werror=implicit-function-declaration]
>>
>>
>> others:
>> arch/arm/mm/dma-mapping.c: In function ‘__iommu_alloc_remap’:
>> arch/arm/mm/dma-mapping.c:1200:4: error: ‘VM_ARM_DMA_CONSISTENT’
>> undeclared (first use in this function)
>> arch/arm/mm/dma-mapping.c:1200:4: note: each undeclared identifier is
>> reported only once for each function it appears in
>>
>> arch/arm/mm/dma-mapping.c: In function ‘__iommu_get_pages’:
>> arch/arm/mm/dma-mapping.c:1282:29: error: ‘VM_ARM_DMA_CONSISTENT’
>> undeclared (first use in this function)
>> arch/arm/mm/dma-mapping.c: In function ‘arm_iommu_free_attrs’:
>> arch/arm/mm/dma-mapping.c:1411:4: error: ‘VM_ARM_DMA_CONSISTENT’
>> undeclared (first use in this function)
>>
>>
>> i've attached a configuration where it happens.
>> when you place the configuration in your tree and compile the file,
>> the errors should show up.
>>
>> However, within the configuration CONFIG_ARM_DMA_USE_IOMMU is defined
>> and CONFIG_MMU is not. AFAIUI, if both should be enabled together, it
>> should be mapped in Kconfig somewhere, right?
>
> There isn't a nice way to fixup the dma consistent flags so I would
> say this option should just depend on MMU.

The question is which option should depend on MMU? Making
CONFIG_ARM_DMA_USE_IOMMU
to depend on MMU doesn't solve this case. It only gives following
warning with the
mentioned .config:
warning: (VIDEO_OMAP3 && EXYNOS_IOMMU && SHMOBILE_IOMMU && IPMMU_VMSA &&
ARM_SMMU) selects ARM_DMA_USE_IOMMU which has unmet direct dependencies
(MMU)

IMHO the best solution will be to either make the whole IOMMU subsystem
to depend
on MMU or alternatively, add this dependency to all IOMMU drivers which
can be
enabled by COMPILE_TEST option (here the issue is caused by
SHMOBILE_IOMMU, which
otherwise cannot be enabled when no-mmu systems are selected).

Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland

2014-10-24 13:15:09

by Stefan Hengelein

[permalink] [raw]
Subject: Re: [PATCH] arm: dma-mapping: fix compilation error when CONFIG_MMU is not present

Hello,

adding a dependency to CONFIG_ARM_DMA_USE_IOMMU is probably not a good
idea anyways.
If you read the Documentation/kbuild/kconfig-language.txt, you will see that:
1. in general, selected options should have no prompt and no dependencies
2. giving ARM_DMA_USE_IOMMU a dependency on MMU will and cannot solve
the problem, since ARM_DMA_USE_IOMMU itself is selected by several
sources and select will not enforce dependencies to be resolved (to be
precise, it will simply ignore them). Thus, CONFIG_MMU will not be
enabled (as you can see in your warning).
If you want to ensure CONFIG_MMU is enabled when
CONFIG_ARM_DMA_USE_IOMMU is selected, the selecting options (e.g.
SHMOBILE_IOMMU) should have a dependency on MMU.
However, i'm not sure if that's the right way to solve it, since it
will hide these options when MMU is not enabled.

Making the whole IOMMU subsystem depend on MMU would probably also
solve the problem. Is there any situation where it would make sense to
use an IOMMU without an MMU?

Best Regards,
Stefan Hengelein

2014-10-23 10:15 GMT+02:00 Marek Szyprowski <[email protected]>:
> Hello,
>
>
> On 2014-10-21 02:05, Laura Abbott wrote:
>>
>> On 10/20/2014 6:50 AM, Stefan Hengelein wrote:
>>>
>>> Well,
>>>
>>> arch/arm/mm/dma-mapping.c: In function ‘__atomic_get_pages’:
>>> arch/arm/mm/dma-mapping.c:1265:31: error: ‘atomic_pool’ undeclared
>>> (first use in this function)
>>>
>>> arch/arm/mm/dma-mapping.c: In function ‘__iommu_get_pages’:
>>> arch/arm/mm/dma-mapping.c:1275:2: error: implicit declaration of
>>> function ‘__in_atomic_pool’ [-Werror=implicit-function-declaration]
>>>
>>>
>>> others:
>>> arch/arm/mm/dma-mapping.c: In function ‘__iommu_alloc_remap’:
>>> arch/arm/mm/dma-mapping.c:1200:4: error: ‘VM_ARM_DMA_CONSISTENT’
>>> undeclared (first use in this function)
>>> arch/arm/mm/dma-mapping.c:1200:4: note: each undeclared identifier is
>>> reported only once for each function it appears in
>>>
>>> arch/arm/mm/dma-mapping.c: In function ‘__iommu_get_pages’:
>>> arch/arm/mm/dma-mapping.c:1282:29: error: ‘VM_ARM_DMA_CONSISTENT’
>>> undeclared (first use in this function)
>>> arch/arm/mm/dma-mapping.c: In function ‘arm_iommu_free_attrs’:
>>> arch/arm/mm/dma-mapping.c:1411:4: error: ‘VM_ARM_DMA_CONSISTENT’
>>> undeclared (first use in this function)
>>>
>>>
>>> i've attached a configuration where it happens.
>>> when you place the configuration in your tree and compile the file,
>>> the errors should show up.
>>>
>>> However, within the configuration CONFIG_ARM_DMA_USE_IOMMU is defined
>>> and CONFIG_MMU is not. AFAIUI, if both should be enabled together, it
>>> should be mapped in Kconfig somewhere, right?
>>
>>
>> There isn't a nice way to fixup the dma consistent flags so I would
>> say this option should just depend on MMU.
>
>
> The question is which option should depend on MMU? Making
> CONFIG_ARM_DMA_USE_IOMMU
> to depend on MMU doesn't solve this case. It only gives following warning
> with the
> mentioned .config:
> warning: (VIDEO_OMAP3 && EXYNOS_IOMMU && SHMOBILE_IOMMU && IPMMU_VMSA &&
> ARM_SMMU) selects ARM_DMA_USE_IOMMU which has unmet direct dependencies
> (MMU)
>
> IMHO the best solution will be to either make the whole IOMMU subsystem to
> depend
> on MMU or alternatively, add this dependency to all IOMMU drivers which can
> be
> enabled by COMPILE_TEST option (here the issue is caused by SHMOBILE_IOMMU,
> which
> otherwise cannot be enabled when no-mmu systems are selected).
>
>
> Best regards
> --
> Marek Szyprowski, PhD
> Samsung R&D Institute Poland
>

2014-10-27 11:59:50

by Marek Szyprowski

[permalink] [raw]
Subject: Re: [PATCH] arm: dma-mapping: fix compilation error when CONFIG_MMU is not present

Hello,

On 2014-10-24 15:15, Stefan Hengelein wrote:
> Hello,
>
> adding a dependency to CONFIG_ARM_DMA_USE_IOMMU is probably not a good
> idea anyways.
> If you read the Documentation/kbuild/kconfig-language.txt, you will see that:
> 1. in general, selected options should have no prompt and no dependencies
> 2. giving ARM_DMA_USE_IOMMU a dependency on MMU will and cannot solve
> the problem, since ARM_DMA_USE_IOMMU itself is selected by several
> sources and select will not enforce dependencies to be resolved (to be
> precise, it will simply ignore them). Thus, CONFIG_MMU will not be
> enabled (as you can see in your warning).
> If you want to ensure CONFIG_MMU is enabled when
> CONFIG_ARM_DMA_USE_IOMMU is selected, the selecting options (e.g.
> SHMOBILE_IOMMU) should have a dependency on MMU.
> However, i'm not sure if that's the right way to solve it, since it
> will hide these options when MMU is not enabled.
>
> Making the whole IOMMU subsystem depend on MMU would probably also
> solve the problem. Is there any situation where it would make sense to
> use an IOMMU without an MMU?

IMHO such configuration doesn't make sense and hiding IOMMU section
completely when non-MMU systems are enabled is the right approach.

Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland