* [PATCH v2 1/5] of: address: Fix default coherency for MIPS
2023-02-23 11:36 [PATCH v2 0/5] Use dma_default_coherent for devicetree default coherency Jiaxun Yang
@ 2023-02-23 11:36 ` Jiaxun Yang
2023-02-23 11:36 ` [PATCH v2 2/5] dma-mapping: Provide a fallback dma_default_coherent Jiaxun Yang
` (3 subsequent siblings)
4 siblings, 0 replies; 13+ messages in thread
From: Jiaxun Yang @ 2023-02-23 11:36 UTC (permalink / raw)
To: linux-mips
Cc: tsbogend, linux-kernel, Jiaxun Yang, robh+dt, palmer,
paul.walmsley, robin.murphy, linux-riscv, linuxppc-dev, hch,
m.szyprowski
DT-based MIPS doesn't use OF_DMA_DEFAULT_COHERENT, but
might override the system-wide default at runtime.
Use dma_default_coherent to override default coherence for
MIPS.
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
drivers/of/address.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/of/address.c b/drivers/of/address.c
index 4c0b169ef9bf..c105d66a1fa4 100644
--- a/drivers/of/address.c
+++ b/drivers/of/address.c
@@ -1105,6 +1105,14 @@ bool of_dma_is_coherent(struct device_node *np)
struct device_node *node;
bool is_coherent = IS_ENABLED(CONFIG_OF_DMA_DEFAULT_COHERENT);
+ /*
+ * DT-based MIPS doesn't use OF_DMA_DEFAULT_COHERENT, but
+ * might override the system-wide default at runtime.
+ */
+#if defined(CONFIG_MIPS) && defined(CONFIG_DMA_NONCOHERENT)
+ is_coherent = dma_default_coherent;
+#endif
+
node = of_node_get(np);
while (node) {
--
2.37.1 (Apple Git-137.1)
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH v2 2/5] dma-mapping: Provide a fallback dma_default_coherent
2023-02-23 11:36 [PATCH v2 0/5] Use dma_default_coherent for devicetree default coherency Jiaxun Yang
2023-02-23 11:36 ` [PATCH v2 1/5] of: address: Fix default coherency for MIPS Jiaxun Yang
@ 2023-02-23 11:36 ` Jiaxun Yang
2023-03-01 13:03 ` Christoph Hellwig
2023-02-23 11:36 ` [PATCH v2 3/5] dma-mapping: Provide CONFIG_ARCH_DMA_DEFAULT_COHERENT Jiaxun Yang
` (2 subsequent siblings)
4 siblings, 1 reply; 13+ messages in thread
From: Jiaxun Yang @ 2023-02-23 11:36 UTC (permalink / raw)
To: linux-mips
Cc: tsbogend, linux-kernel, Jiaxun Yang, robh+dt, palmer,
paul.walmsley, robin.murphy, linux-riscv, linuxppc-dev, hch,
m.szyprowski
dma_default_coherent was decleared unconditionally at kernel/dma/mapping.c
but only decleared when any of non-coherent options is enabled in dma-map-ops.h.
Guard the declaration in mapping.c with non-coherent options and provide
a fallback definition.
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
include/linux/dma-map-ops.h | 1 +
kernel/dma/mapping.c | 4 ++++
2 files changed, 5 insertions(+)
diff --git a/include/linux/dma-map-ops.h b/include/linux/dma-map-ops.h
index 41bf4bdb117a..0a1aaf7163b3 100644
--- a/include/linux/dma-map-ops.h
+++ b/include/linux/dma-map-ops.h
@@ -269,6 +269,7 @@ static inline bool dev_is_dma_coherent(struct device *dev)
return dev->dma_coherent;
}
#else
+#define dma_default_coherent true
static inline bool dev_is_dma_coherent(struct device *dev)
{
return true;
diff --git a/kernel/dma/mapping.c b/kernel/dma/mapping.c
index 68106e3791f6..80f9663ffe26 100644
--- a/kernel/dma/mapping.c
+++ b/kernel/dma/mapping.c
@@ -17,7 +17,11 @@
#include "debug.h"
#include "direct.h"
+#if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \
+ defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \
+ defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL)
bool dma_default_coherent;
+#endif
/*
* Managed DMA API
--
2.37.1 (Apple Git-137.1)
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH v2 2/5] dma-mapping: Provide a fallback dma_default_coherent
2023-02-23 11:36 ` [PATCH v2 2/5] dma-mapping: Provide a fallback dma_default_coherent Jiaxun Yang
@ 2023-03-01 13:03 ` Christoph Hellwig
0 siblings, 0 replies; 13+ messages in thread
From: Christoph Hellwig @ 2023-03-01 13:03 UTC (permalink / raw)
To: Jiaxun Yang
Cc: tsbogend, linux-mips, linux-kernel, robh+dt, palmer,
paul.walmsley, robin.murphy, linux-riscv, linuxppc-dev, hch,
m.szyprowski
On Thu, Feb 23, 2023 at 11:36:41AM +0000, Jiaxun Yang wrote:
> dma_default_coherent was decleared unconditionally at kernel/dma/mapping.c
> but only decleared when any of non-coherent options is enabled in dma-map-ops.h.
Overly lone line here.
> }
> #else
> +#define dma_default_coherent true
> static inline bool dev_is_dma_coherent(struct device *dev)
Please keep an empty line before the function declaration.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 3/5] dma-mapping: Provide CONFIG_ARCH_DMA_DEFAULT_COHERENT
2023-02-23 11:36 [PATCH v2 0/5] Use dma_default_coherent for devicetree default coherency Jiaxun Yang
2023-02-23 11:36 ` [PATCH v2 1/5] of: address: Fix default coherency for MIPS Jiaxun Yang
2023-02-23 11:36 ` [PATCH v2 2/5] dma-mapping: Provide a fallback dma_default_coherent Jiaxun Yang
@ 2023-02-23 11:36 ` Jiaxun Yang
2023-03-01 13:03 ` Christoph Hellwig
2023-02-23 11:36 ` [PATCH v2 4/5] riscv: Select ARCH_DMA_DEFAULT_COHERENT Jiaxun Yang
2023-02-23 11:36 ` [PATCH v2 5/5] of: address: Always use dma_default_coherent for default coherency Jiaxun Yang
4 siblings, 1 reply; 13+ messages in thread
From: Jiaxun Yang @ 2023-02-23 11:36 UTC (permalink / raw)
To: linux-mips
Cc: tsbogend, linux-kernel, Jiaxun Yang, robh+dt, palmer,
paul.walmsley, robin.murphy, linux-riscv, linuxppc-dev, hch,
m.szyprowski
Provide a kconfig option to allow arches to manipulate default
value of dma_default_coherent in Kconfig.
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
kernel/dma/Kconfig | 3 +++
kernel/dma/mapping.c | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/kernel/dma/Kconfig b/kernel/dma/Kconfig
index 56866aaa2ae1..968108fdf9bf 100644
--- a/kernel/dma/Kconfig
+++ b/kernel/dma/Kconfig
@@ -76,6 +76,9 @@ config ARCH_HAS_DMA_PREP_COHERENT
config ARCH_HAS_FORCE_DMA_UNENCRYPTED
bool
+config ARCH_DMA_DEFAULT_COHERENT
+ bool
+
config SWIOTLB
bool
select NEED_DMA_MAP_STATE
diff --git a/kernel/dma/mapping.c b/kernel/dma/mapping.c
index 80f9663ffe26..9a4db5cce600 100644
--- a/kernel/dma/mapping.c
+++ b/kernel/dma/mapping.c
@@ -20,7 +20,7 @@
#if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \
defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \
defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL)
-bool dma_default_coherent;
+bool dma_default_coherent = IS_ENABLED(CONFIG_ARCH_DMA_DEFAULT_COHERENT);
#endif
/*
--
2.37.1 (Apple Git-137.1)
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v2 3/5] dma-mapping: Provide CONFIG_ARCH_DMA_DEFAULT_COHERENT
2023-02-23 11:36 ` [PATCH v2 3/5] dma-mapping: Provide CONFIG_ARCH_DMA_DEFAULT_COHERENT Jiaxun Yang
@ 2023-03-01 13:03 ` Christoph Hellwig
0 siblings, 0 replies; 13+ messages in thread
From: Christoph Hellwig @ 2023-03-01 13:03 UTC (permalink / raw)
To: Jiaxun Yang
Cc: tsbogend, linux-mips, linux-kernel, robh+dt, palmer,
paul.walmsley, robin.murphy, linux-riscv, linuxppc-dev, hch,
m.szyprowski
> +config ARCH_DMA_DEFAULT_COHERENT
> + bool
Please add a comment here explaining when an architecture should
ѕelect this symbol.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 4/5] riscv: Select ARCH_DMA_DEFAULT_COHERENT
2023-02-23 11:36 [PATCH v2 0/5] Use dma_default_coherent for devicetree default coherency Jiaxun Yang
` (2 preceding siblings ...)
2023-02-23 11:36 ` [PATCH v2 3/5] dma-mapping: Provide CONFIG_ARCH_DMA_DEFAULT_COHERENT Jiaxun Yang
@ 2023-02-23 11:36 ` Jiaxun Yang
2023-02-23 22:20 ` Conor Dooley
2023-02-23 11:36 ` [PATCH v2 5/5] of: address: Always use dma_default_coherent for default coherency Jiaxun Yang
4 siblings, 1 reply; 13+ messages in thread
From: Jiaxun Yang @ 2023-02-23 11:36 UTC (permalink / raw)
To: linux-mips
Cc: tsbogend, linux-kernel, Jiaxun Yang, robh+dt, palmer,
paul.walmsley, robin.murphy, linux-riscv, linuxppc-dev, hch,
m.szyprowski
For riscv our assumption is unless a device states it is non-coherent,
we take it to be DMA coherent.
Select ARCH_DMA_DEFAULT_COHERENT to ensure dma_default_coherent
is always initialized to true.
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
arch/riscv/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 1d46a268ce16..b71ce992c0c0 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -233,6 +233,7 @@ config LOCKDEP_SUPPORT
config RISCV_DMA_NONCOHERENT
bool
+ select ARCH_DMA_DEFAULT_COHERENT
select ARCH_HAS_DMA_PREP_COHERENT
select ARCH_HAS_SETUP_DMA_OPS
select ARCH_HAS_SYNC_DMA_FOR_CPU
--
2.37.1 (Apple Git-137.1)
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH v2 4/5] riscv: Select ARCH_DMA_DEFAULT_COHERENT
2023-02-23 11:36 ` [PATCH v2 4/5] riscv: Select ARCH_DMA_DEFAULT_COHERENT Jiaxun Yang
@ 2023-02-23 22:20 ` Conor Dooley
2023-03-15 2:07 ` Palmer Dabbelt
0 siblings, 1 reply; 13+ messages in thread
From: Conor Dooley @ 2023-02-23 22:20 UTC (permalink / raw)
To: Jiaxun Yang
Cc: tsbogend, linux-mips, linux-kernel, robh+dt, palmer,
paul.walmsley, robin.murphy, linux-riscv, linuxppc-dev, hch,
m.szyprowski
[-- Attachment #1: Type: text/plain, Size: 1095 bytes --]
On Thu, Feb 23, 2023 at 11:36:43AM +0000, Jiaxun Yang wrote:
> For riscv our assumption is unless a device states it is non-coherent,
> we take it to be DMA coherent.
>
> Select ARCH_DMA_DEFAULT_COHERENT to ensure dma_default_coherent
> is always initialized to true.
>
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> ---
> arch/riscv/Kconfig | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index 1d46a268ce16..b71ce992c0c0 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -233,6 +233,7 @@ config LOCKDEP_SUPPORT
>
> config RISCV_DMA_NONCOHERENT
> bool
> + select ARCH_DMA_DEFAULT_COHERENT
Since we are always coherent by default, I feel like you should put this
in the main "config RISCV" section, where OF_DMA_DEFAULT_COHERENT
currently is, no?
Wouldn't bother respinning for that unless the dma folk have comments
for you.
> select ARCH_HAS_DMA_PREP_COHERENT
> select ARCH_HAS_SETUP_DMA_OPS
> select ARCH_HAS_SYNC_DMA_FOR_CPU
> --
> 2.37.1 (Apple Git-137.1)
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 4/5] riscv: Select ARCH_DMA_DEFAULT_COHERENT
2023-02-23 22:20 ` Conor Dooley
@ 2023-03-15 2:07 ` Palmer Dabbelt
0 siblings, 0 replies; 13+ messages in thread
From: Palmer Dabbelt @ 2023-03-15 2:07 UTC (permalink / raw)
To: Conor Dooley
Cc: tsbogend, linux-mips, jiaxun.yang, linux-kernel, robh+dt,
Paul Walmsley, robin.murphy, linux-riscv, linuxppc-dev,
Christoph Hellwig, m.szyprowski
On Thu, 23 Feb 2023 14:20:27 PST (-0800), Conor Dooley wrote:
> On Thu, Feb 23, 2023 at 11:36:43AM +0000, Jiaxun Yang wrote:
>> For riscv our assumption is unless a device states it is non-coherent,
>> we take it to be DMA coherent.
>>
>> Select ARCH_DMA_DEFAULT_COHERENT to ensure dma_default_coherent
>> is always initialized to true.
>>
>> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
>> ---
>> arch/riscv/Kconfig | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
>> index 1d46a268ce16..b71ce992c0c0 100644
>> --- a/arch/riscv/Kconfig
>> +++ b/arch/riscv/Kconfig
>> @@ -233,6 +233,7 @@ config LOCKDEP_SUPPORT
>>
>> config RISCV_DMA_NONCOHERENT
>> bool
>> + select ARCH_DMA_DEFAULT_COHERENT
>
> Since we are always coherent by default, I feel like you should put this
> in the main "config RISCV" section, where OF_DMA_DEFAULT_COHERENT
> currently is, no?
Seems reasonable to me. With that
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
as I'm assuming these should all stay together.
Thanks!
>
> Wouldn't bother respinning for that unless the dma folk have comments
> for you.
>
>> select ARCH_HAS_DMA_PREP_COHERENT
>> select ARCH_HAS_SETUP_DMA_OPS
>> select ARCH_HAS_SYNC_DMA_FOR_CPU
>> --
>> 2.37.1 (Apple Git-137.1)
>>
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 5/5] of: address: Always use dma_default_coherent for default coherency
2023-02-23 11:36 [PATCH v2 0/5] Use dma_default_coherent for devicetree default coherency Jiaxun Yang
` (3 preceding siblings ...)
2023-02-23 11:36 ` [PATCH v2 4/5] riscv: Select ARCH_DMA_DEFAULT_COHERENT Jiaxun Yang
@ 2023-02-23 11:36 ` Jiaxun Yang
2023-03-01 13:06 ` Christoph Hellwig
4 siblings, 1 reply; 13+ messages in thread
From: Jiaxun Yang @ 2023-02-23 11:36 UTC (permalink / raw)
To: linux-mips
Cc: tsbogend, linux-kernel, Jiaxun Yang, robh+dt, palmer,
paul.walmsley, robin.murphy, linux-riscv, linuxppc-dev, hch,
m.szyprowski
As for now all arches have dma_default_coherent matched with default
DMA coherency for of devices, so there is no need to have a standalone
config option.
Note for PowerPC: CONFIG_OF_DMA_DEFUALT_COHERENT was only selected when
CONFIG_NOT_COHERENT_CACHE is false, in this case dma_default_coherent will
be true, so it still matches present behavior.
Note for RISCV: dma_default_coherent is set to true in this series.
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
arch/powerpc/Kconfig | 1 -
arch/riscv/Kconfig | 1 -
drivers/of/Kconfig | 4 ----
drivers/of/address.c | 10 +---------
4 files changed, 1 insertion(+), 15 deletions(-)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 2c9cdf1d8761..c67e5da714f7 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -272,7 +272,6 @@ config PPC
select NEED_PER_CPU_PAGE_FIRST_CHUNK if PPC64
select NEED_SG_DMA_LENGTH
select OF
- select OF_DMA_DEFAULT_COHERENT if !NOT_COHERENT_CACHE
select OF_EARLY_FLATTREE
select OLD_SIGACTION if PPC32
select OLD_SIGSUSPEND
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index b71ce992c0c0..a79663191228 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -119,7 +119,6 @@ config RISCV
select MODULES_USE_ELF_RELA if MODULES
select MODULE_SECTIONS if MODULES
select OF
- select OF_DMA_DEFAULT_COHERENT
select OF_EARLY_FLATTREE
select OF_IRQ
select PCI_DOMAINS_GENERIC if PCI
diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
index 644386833a7b..e40f10bf2ba4 100644
--- a/drivers/of/Kconfig
+++ b/drivers/of/Kconfig
@@ -102,8 +102,4 @@ config OF_OVERLAY
config OF_NUMA
bool
-config OF_DMA_DEFAULT_COHERENT
- # arches should select this if DMA is coherent by default for OF devices
- bool
-
endif # OF
diff --git a/drivers/of/address.c b/drivers/of/address.c
index c105d66a1fa4..23ade4919853 100644
--- a/drivers/of/address.c
+++ b/drivers/of/address.c
@@ -1103,15 +1103,7 @@ phys_addr_t __init of_dma_get_max_cpu_address(struct device_node *np)
bool of_dma_is_coherent(struct device_node *np)
{
struct device_node *node;
- bool is_coherent = IS_ENABLED(CONFIG_OF_DMA_DEFAULT_COHERENT);
-
- /*
- * DT-based MIPS doesn't use OF_DMA_DEFAULT_COHERENT, but
- * might override the system-wide default at runtime.
- */
-#if defined(CONFIG_MIPS) && defined(CONFIG_DMA_NONCOHERENT)
- is_coherent = dma_default_coherent;
-#endif
+ bool is_coherent = dma_default_coherent;
node = of_node_get(np);
--
2.37.1 (Apple Git-137.1)
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH v2 5/5] of: address: Always use dma_default_coherent for default coherency
2023-02-23 11:36 ` [PATCH v2 5/5] of: address: Always use dma_default_coherent for default coherency Jiaxun Yang
@ 2023-03-01 13:06 ` Christoph Hellwig
2023-03-01 14:18 ` Jiaxun Yang
0 siblings, 1 reply; 13+ messages in thread
From: Christoph Hellwig @ 2023-03-01 13:06 UTC (permalink / raw)
To: Jiaxun Yang
Cc: tsbogend, linux-mips, linux-kernel, robh+dt, palmer,
paul.walmsley, robin.murphy, linux-riscv, linuxppc-dev, hch,
m.szyprowski
> - select OF_DMA_DEFAULT_COHERENT if !NOT_COHERENT_CACHE
Doesn't powerpc need to select CONFIG_ARCH_DMA_DEFAULT_COHERENT now,
or even better should be doing that in the patch adding that
symbol?
In fact I wonder if adding CONFIG_ARCH_DMA_DEFAULT_COHERENT and removing
OF_DMA_DEFAULT_COHERENT should be one patch, as that seems to bring
over the intent a little better I'd say.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 5/5] of: address: Always use dma_default_coherent for default coherency
2023-03-01 13:06 ` Christoph Hellwig
@ 2023-03-01 14:18 ` Jiaxun Yang
2023-03-03 0:11 ` Michael Ellerman
0 siblings, 1 reply; 13+ messages in thread
From: Jiaxun Yang @ 2023-03-01 14:18 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Thomas Bogendoerfer, linux-mips@vger.kernel.org, linux-kernel,
Rob Herring, palmer, paul.walmsley, robin.murphy, linux-riscv,
linuxppc-dev, m.szyprowski
> 2023年3月1日 13:06,Christoph Hellwig <hch@lst.de> 写道:
>
>> - select OF_DMA_DEFAULT_COHERENT if !NOT_COHERENT_CACHE
>
> Doesn't powerpc need to select CONFIG_ARCH_DMA_DEFAULT_COHERENT now,
> or even better should be doing that in the patch adding that
> symbol?
If I read the code correctly for powerpc OF_DMA_DEFAULT_COHERENT is only selected
with !NOT_COHERENT_CACHE, which means non-coherent dma support is disabled….
>
> In fact I wonder if adding CONFIG_ARCH_DMA_DEFAULT_COHERENT and removing
> OF_DMA_DEFAULT_COHERENT should be one patch, as that seems to bring
> over the intent a little better I'd say.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 5/5] of: address: Always use dma_default_coherent for default coherency
2023-03-01 14:18 ` Jiaxun Yang
@ 2023-03-03 0:11 ` Michael Ellerman
0 siblings, 0 replies; 13+ messages in thread
From: Michael Ellerman @ 2023-03-03 0:11 UTC (permalink / raw)
To: Jiaxun Yang, Christoph Hellwig
Cc: Thomas Bogendoerfer, robin.murphy, linux-mips@vger.kernel.org,
linux-kernel, Rob Herring, palmer, paul.walmsley, linux-riscv,
linuxppc-dev, m.szyprowski
Jiaxun Yang <jiaxun.yang@flygoat.com> writes:
>> 2023年3月1日 13:06,Christoph Hellwig <hch@lst.de> 写道:
>>
>>> - select OF_DMA_DEFAULT_COHERENT if !NOT_COHERENT_CACHE
>>
>> Doesn't powerpc need to select CONFIG_ARCH_DMA_DEFAULT_COHERENT now,
>> or even better should be doing that in the patch adding that
>> symbol?
>
> If I read the code correctly for powerpc OF_DMA_DEFAULT_COHERENT is only selected
> with !NOT_COHERENT_CACHE, which means non-coherent dma support is disabled….
I think you're right, but it's not easy to understand.
powerpc's NOT_COHERENT_CACHE selects:
select ARCH_HAS_DMA_PREP_COHERENT
select ARCH_HAS_SYNC_DMA_FOR_DEVICE
select ARCH_HAS_SYNC_DMA_FOR_CPU
Then in your patch 3 you do:
#if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \
defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \
defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL)
-bool dma_default_coherent;
+bool dma_default_coherent = IS_ENABLED(CONFIG_ARCH_DMA_DEFAULT_COHERENT);
#endif
So for powerpc if NOT_COHERENT_CACHE=n, then none of those ARCH_HAS
symbols are defined, and so CONFIG_ARCH_DMA_DEFAULT_COHERENT is never used.
But like I said it's not very obvious, and it also seems fragile to
future changes.
So it seems it would be more future proof, and self documenting for
powerpc to just have:
select ARCH_DMA_DEFAULT_COHERENT if !NOT_COHERENT_CACHE
cheers
^ permalink raw reply [flat|nested] 13+ messages in thread