* [PATCH 0/7] MIPS DMA coherence fixes
@ 2023-02-21 12:46 Jiaxun Yang
2023-02-21 12:46 ` [PATCH 1/7] MIPS: Remove DMA_PERDEV_COHERENT Jiaxun Yang
` (7 more replies)
0 siblings, 8 replies; 23+ messages in thread
From: Jiaxun Yang @ 2023-02-21 12:46 UTC (permalink / raw)
To: linux-mips
Cc: linux-kernel, linuxppc-dev, tsbogend, mpe, paul.walmsley, palmer,
robh+dt, hch, m.szyprowski, robin.murphy, Jiaxun Yang
Jiaxun Yang (7):
MIPS: Remove DMA_PERDEV_COHERENT
MIPS: Always select ARCH_HAS_SYNC_DMA_FOR_CPU for noncoherent
platforms
MIPS: c-r4k: Always install dma flush functions
dma-mapping: Always provide dma_default_coherent
dma-mapping: Provide CONFIG_ARCH_DMA_DEFAULT_COHERENT
riscv: Select ARCH_DMA_DEFAULT_COHERENT
of: address: Use dma_default_coherent to determine default coherency
arch/mips/Kconfig | 16 ++--------------
arch/mips/mm/c-r4k.c | 12 +++---------
arch/powerpc/Kconfig | 1 -
arch/riscv/Kconfig | 2 +-
drivers/of/Kconfig | 4 ----
drivers/of/address.c | 2 +-
include/linux/dma-map-ops.h | 1 +
kernel/dma/Kconfig | 3 +++
kernel/dma/mapping.c | 6 +++++-
9 files changed, 16 insertions(+), 31 deletions(-)
--
2.37.1 (Apple Git-137.1)
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 1/7] MIPS: Remove DMA_PERDEV_COHERENT
2023-02-21 12:46 [PATCH 0/7] MIPS DMA coherence fixes Jiaxun Yang
@ 2023-02-21 12:46 ` Jiaxun Yang
2023-02-21 17:56 ` Christoph Hellwig
2023-02-21 12:46 ` [PATCH 2/7] MIPS: Always select ARCH_HAS_SYNC_DMA_FOR_CPU for noncoherent platforms Jiaxun Yang
` (6 subsequent siblings)
7 siblings, 1 reply; 23+ messages in thread
From: Jiaxun Yang @ 2023-02-21 12:46 UTC (permalink / raw)
To: linux-mips
Cc: linux-kernel, linuxppc-dev, tsbogend, mpe, paul.walmsley, palmer,
robh+dt, hch, m.szyprowski, robin.murphy, Jiaxun Yang
As now we are always managing DMA coherence on per dev bias,
there is no need to have such option. And it's not selected
by any platform.
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
arch/mips/Kconfig | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 15cb692b0a09..c6f3ad51f741 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -134,7 +134,6 @@ choice
config MIPS_GENERIC_KERNEL
bool "Generic board-agnostic MIPS kernel"
- select ARCH_HAS_SETUP_DMA_OPS
select MIPS_GENERIC
select BOOT_RAW
select BUILTIN_DTB
@@ -1079,11 +1078,6 @@ config FW_CFE
config ARCH_SUPPORTS_UPROBES
bool
-config DMA_PERDEV_COHERENT
- bool
- select ARCH_HAS_SETUP_DMA_OPS
- select DMA_NONCOHERENT
-
config DMA_NONCOHERENT
bool
#
@@ -1097,6 +1091,7 @@ config DMA_NONCOHERENT
select ARCH_HAS_DMA_PREP_COHERENT
select ARCH_HAS_SYNC_DMA_FOR_DEVICE
select ARCH_HAS_DMA_SET_UNCACHED
+ select ARCH_HAS_SETUP_DMA_OPS
select DMA_NONCOHERENT_MMAP
select NEED_DMA_MAP_STATE
--
2.37.1 (Apple Git-137.1)
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 2/7] MIPS: Always select ARCH_HAS_SYNC_DMA_FOR_CPU for noncoherent platforms
2023-02-21 12:46 [PATCH 0/7] MIPS DMA coherence fixes Jiaxun Yang
2023-02-21 12:46 ` [PATCH 1/7] MIPS: Remove DMA_PERDEV_COHERENT Jiaxun Yang
@ 2023-02-21 12:46 ` Jiaxun Yang
2023-02-21 12:46 ` [PATCH 3/7] MIPS: c-r4k: Always install dma flush functions Jiaxun Yang
` (5 subsequent siblings)
7 siblings, 0 replies; 23+ messages in thread
From: Jiaxun Yang @ 2023-02-21 12:46 UTC (permalink / raw)
To: linux-mips
Cc: linux-kernel, linuxppc-dev, tsbogend, mpe, paul.walmsley, palmer,
robh+dt, hch, m.szyprowski, robin.murphy, Jiaxun Yang
As now we are telling the necessity of post DMA flush per CPU type,
there is no need to select ARCH_HAS_SYNC_DMA_FOR_CPU on per platform
bias, just select it unconditionally and we can sort it at runtime.
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
arch/mips/Kconfig | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index c6f3ad51f741..8da52863da4e 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -115,7 +115,6 @@ config MACH_INGENIC
select SYS_SUPPORTS_LITTLE_ENDIAN
select SYS_SUPPORTS_ZBOOT
select DMA_NONCOHERENT
- select ARCH_HAS_SYNC_DMA_FOR_CPU
select IRQ_MIPS_CPU
select PINCTRL
select GPIOLIB
@@ -1089,6 +1088,7 @@ config DMA_NONCOHERENT
#
select ARCH_HAS_DMA_WRITE_COMBINE
select ARCH_HAS_DMA_PREP_COHERENT
+ select ARCH_HAS_SYNC_DMA_FOR_CPU
select ARCH_HAS_SYNC_DMA_FOR_DEVICE
select ARCH_HAS_DMA_SET_UNCACHED
select ARCH_HAS_SETUP_DMA_OPS
@@ -1853,11 +1853,9 @@ config SYS_HAS_CPU_MIPS32_R3_5
config SYS_HAS_CPU_MIPS32_R5
bool
- select ARCH_HAS_SYNC_DMA_FOR_CPU if DMA_NONCOHERENT
config SYS_HAS_CPU_MIPS32_R6
bool
- select ARCH_HAS_SYNC_DMA_FOR_CPU if DMA_NONCOHERENT
config SYS_HAS_CPU_MIPS64_R1
bool
@@ -1867,15 +1865,12 @@ config SYS_HAS_CPU_MIPS64_R2
config SYS_HAS_CPU_MIPS64_R5
bool
- select ARCH_HAS_SYNC_DMA_FOR_CPU if DMA_NONCOHERENT
config SYS_HAS_CPU_MIPS64_R6
bool
- select ARCH_HAS_SYNC_DMA_FOR_CPU if DMA_NONCOHERENT
config SYS_HAS_CPU_P5600
bool
- select ARCH_HAS_SYNC_DMA_FOR_CPU if DMA_NONCOHERENT
config SYS_HAS_CPU_R3000
bool
@@ -1900,7 +1895,6 @@ config SYS_HAS_CPU_NEVADA
config SYS_HAS_CPU_R10000
bool
- select ARCH_HAS_SYNC_DMA_FOR_CPU if DMA_NONCOHERENT
config SYS_HAS_CPU_RM7000
bool
@@ -1929,7 +1923,6 @@ config SYS_HAS_CPU_BMIPS4380
config SYS_HAS_CPU_BMIPS5000
bool
select SYS_HAS_CPU_BMIPS
- select ARCH_HAS_SYNC_DMA_FOR_CPU
#
# CPU may reorder R->R, R->W, W->R, W->W
--
2.37.1 (Apple Git-137.1)
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 3/7] MIPS: c-r4k: Always install dma flush functions
2023-02-21 12:46 [PATCH 0/7] MIPS DMA coherence fixes Jiaxun Yang
2023-02-21 12:46 ` [PATCH 1/7] MIPS: Remove DMA_PERDEV_COHERENT Jiaxun Yang
2023-02-21 12:46 ` [PATCH 2/7] MIPS: Always select ARCH_HAS_SYNC_DMA_FOR_CPU for noncoherent platforms Jiaxun Yang
@ 2023-02-21 12:46 ` Jiaxun Yang
2023-02-21 12:46 ` [PATCH 4/7] dma-mapping: Always provide dma_default_coherent Jiaxun Yang
` (4 subsequent siblings)
7 siblings, 0 replies; 23+ messages in thread
From: Jiaxun Yang @ 2023-02-21 12:46 UTC (permalink / raw)
To: linux-mips
Cc: linux-kernel, linuxppc-dev, tsbogend, mpe, paul.walmsley, palmer,
robh+dt, hch, m.szyprowski, robin.murphy, Jiaxun Yang
As nowadays DMA coherence is managed per device, it is possible
to have a system that is defaulted to coherent dma but still
have noncoherent device that needs to use those flush functions.
Just install them unconditionally.
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
arch/mips/mm/c-r4k.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/arch/mips/mm/c-r4k.c b/arch/mips/mm/c-r4k.c
index a549fa98c2f4..7d447050a20b 100644
--- a/arch/mips/mm/c-r4k.c
+++ b/arch/mips/mm/c-r4k.c
@@ -1867,15 +1867,9 @@ void r4k_cache_init(void)
__local_flush_icache_user_range = local_r4k_flush_icache_user_range;
#ifdef CONFIG_DMA_NONCOHERENT
- if (dma_default_coherent) {
- _dma_cache_wback_inv = (void *)cache_noop;
- _dma_cache_wback = (void *)cache_noop;
- _dma_cache_inv = (void *)cache_noop;
- } else {
- _dma_cache_wback_inv = r4k_dma_cache_wback_inv;
- _dma_cache_wback = r4k_dma_cache_wback_inv;
- _dma_cache_inv = r4k_dma_cache_inv;
- }
+ _dma_cache_wback_inv = r4k_dma_cache_wback_inv;
+ _dma_cache_wback = r4k_dma_cache_wback_inv;
+ _dma_cache_inv = r4k_dma_cache_inv;
#endif /* CONFIG_DMA_NONCOHERENT */
build_clear_page();
--
2.37.1 (Apple Git-137.1)
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 4/7] dma-mapping: Always provide dma_default_coherent
2023-02-21 12:46 [PATCH 0/7] MIPS DMA coherence fixes Jiaxun Yang
` (2 preceding siblings ...)
2023-02-21 12:46 ` [PATCH 3/7] MIPS: c-r4k: Always install dma flush functions Jiaxun Yang
@ 2023-02-21 12:46 ` Jiaxun Yang
2023-02-21 17:58 ` Christoph Hellwig
2023-02-21 12:46 ` [PATCH 5/7] dma-mapping: Provide CONFIG_ARCH_DMA_DEFAULT_COHERENT Jiaxun Yang
` (3 subsequent siblings)
7 siblings, 1 reply; 23+ messages in thread
From: Jiaxun Yang @ 2023-02-21 12:46 UTC (permalink / raw)
To: linux-mips
Cc: linux-kernel, linuxppc-dev, tsbogend, mpe, paul.walmsley, palmer,
robh+dt, hch, m.szyprowski, robin.murphy, Jiaxun Yang
dma_default_coherent can be useful for determine default coherency
even on arches without noncoherent support.
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 d678afeb8a13..3c6cd17f87c3 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 c026a5a5e046..e0b005c8ffce 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] 23+ messages in thread
* [PATCH 5/7] dma-mapping: Provide CONFIG_ARCH_DMA_DEFAULT_COHERENT
2023-02-21 12:46 [PATCH 0/7] MIPS DMA coherence fixes Jiaxun Yang
` (3 preceding siblings ...)
2023-02-21 12:46 ` [PATCH 4/7] dma-mapping: Always provide dma_default_coherent Jiaxun Yang
@ 2023-02-21 12:46 ` Jiaxun Yang
2023-02-21 17:58 ` Christoph Hellwig
2023-02-21 12:46 ` [PATCH 6/7] riscv: Select ARCH_DMA_DEFAULT_COHERENT Jiaxun Yang
` (2 subsequent siblings)
7 siblings, 1 reply; 23+ messages in thread
From: Jiaxun Yang @ 2023-02-21 12:46 UTC (permalink / raw)
To: linux-mips
Cc: linux-kernel, linuxppc-dev, tsbogend, mpe, paul.walmsley, palmer,
robh+dt, hch, m.szyprowski, robin.murphy, Jiaxun Yang
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 e0b005c8ffce..3d4a2ca15b5a 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] 23+ messages in thread
* [PATCH 6/7] riscv: Select ARCH_DMA_DEFAULT_COHERENT
2023-02-21 12:46 [PATCH 0/7] MIPS DMA coherence fixes Jiaxun Yang
` (4 preceding siblings ...)
2023-02-21 12:46 ` [PATCH 5/7] dma-mapping: Provide CONFIG_ARCH_DMA_DEFAULT_COHERENT Jiaxun Yang
@ 2023-02-21 12:46 ` Jiaxun Yang
2023-02-21 18:14 ` Conor Dooley
2023-02-21 12:46 ` [PATCH 7/7] of: address: Use dma_default_coherent to determine default coherency Jiaxun Yang
2023-02-21 17:54 ` [PATCH 0/7] MIPS DMA coherence fixes Christoph Hellwig
7 siblings, 1 reply; 23+ messages in thread
From: Jiaxun Yang @ 2023-02-21 12:46 UTC (permalink / raw)
To: linux-mips
Cc: linux-kernel, linuxppc-dev, tsbogend, mpe, paul.walmsley, palmer,
robh+dt, hch, m.szyprowski, robin.murphy, Jiaxun Yang
For RISCV we always assume devices are DMA coherent.
Select ARCH_DMA_DEFAULT_COHERENT to ensure dev->dma_conherent
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 8b1dbd23dbd6..c1327309e0f6 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -13,6 +13,7 @@ config 32BIT
config RISCV
def_bool y
select ARCH_CLOCKSOURCE_INIT
+ select ARCH_DMA_DEFAULT_COHERENT
select ARCH_ENABLE_HUGEPAGE_MIGRATION if HUGETLB_PAGE && MIGRATION
select ARCH_ENABLE_SPLIT_PMD_PTLOCK if PGTABLE_LEVELS > 2
select ARCH_HAS_BINFMT_FLAT
--
2.37.1 (Apple Git-137.1)
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 7/7] of: address: Use dma_default_coherent to determine default coherency
2023-02-21 12:46 [PATCH 0/7] MIPS DMA coherence fixes Jiaxun Yang
` (5 preceding siblings ...)
2023-02-21 12:46 ` [PATCH 6/7] riscv: Select ARCH_DMA_DEFAULT_COHERENT Jiaxun Yang
@ 2023-02-21 12:46 ` Jiaxun Yang
2023-02-21 17:54 ` [PATCH 0/7] MIPS DMA coherence fixes Christoph Hellwig
7 siblings, 0 replies; 23+ messages in thread
From: Jiaxun Yang @ 2023-02-21 12:46 UTC (permalink / raw)
To: linux-mips
Cc: linux-kernel, linuxppc-dev, tsbogend, mpe, paul.walmsley, palmer,
robh+dt, hch, m.szyprowski, robin.murphy, Jiaxun Yang
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.
This also fixes a case that for some MIPS platforms, coherency information
is not carried in devicetree and kernel will override dma_default_coherent
at early boot.
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 ture, so we don't need to select CONFIG_ARCH_DMA_DEFAULT_COHERENT for
PowerPC.
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 | 2 +-
4 files changed, 1 insertion(+), 7 deletions(-)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index a27fea39413e..2cfee7ba2e6a 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -271,7 +271,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 c1327309e0f6..e69e69b9cfd4 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -120,7 +120,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 80b5fd44ab1c..e040837e5537 100644
--- a/drivers/of/Kconfig
+++ b/drivers/of/Kconfig
@@ -90,8 +90,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 c34ac33b7338..8e17adb10f20 100644
--- a/drivers/of/address.c
+++ b/drivers/of/address.c
@@ -1053,7 +1053,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);
+ bool is_coherent = dma_default_coherent;
node = of_node_get(np);
--
2.37.1 (Apple Git-137.1)
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH 0/7] MIPS DMA coherence fixes
2023-02-21 12:46 [PATCH 0/7] MIPS DMA coherence fixes Jiaxun Yang
` (6 preceding siblings ...)
2023-02-21 12:46 ` [PATCH 7/7] of: address: Use dma_default_coherent to determine default coherency Jiaxun Yang
@ 2023-02-21 17:54 ` Christoph Hellwig
2023-02-21 18:15 ` Jiaxun Yang
7 siblings, 1 reply; 23+ messages in thread
From: Christoph Hellwig @ 2023-02-21 17:54 UTC (permalink / raw)
To: Jiaxun Yang
Cc: linux-mips, linux-kernel, linuxppc-dev, tsbogend, mpe,
paul.walmsley, palmer, robh+dt, hch, m.szyprowski, robin.murphy
Can you explain the motivation here? Also why riscv patches are at
the end of a mips fіxes series?
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 1/7] MIPS: Remove DMA_PERDEV_COHERENT
2023-02-21 12:46 ` [PATCH 1/7] MIPS: Remove DMA_PERDEV_COHERENT Jiaxun Yang
@ 2023-02-21 17:56 ` Christoph Hellwig
0 siblings, 0 replies; 23+ messages in thread
From: Christoph Hellwig @ 2023-02-21 17:56 UTC (permalink / raw)
To: Jiaxun Yang
Cc: linux-mips, linux-kernel, linuxppc-dev, tsbogend, mpe,
paul.walmsley, palmer, robh+dt, hch, m.szyprowski, robin.murphy
On Tue, Feb 21, 2023 at 12:46:07PM +0000, Jiaxun Yang wrote:
> As now we are always managing DMA coherence on per dev bias,
> there is no need to have such option. And it's not selected
> by any platform.
I think the real point here is that this is dead code, so it can
obviously go away, but:
> config MIPS_GENERIC_KERNEL
> bool "Generic board-agnostic MIPS kernel"
> - select ARCH_HAS_SETUP_DMA_OPS
> select MIPS_GENERIC
> select BOOT_RAW
> select BUILTIN_DTB
> @@ -1079,11 +1078,6 @@ config FW_CFE
> config ARCH_SUPPORTS_UPROBES
> bool
> @@ -1097,6 +1091,7 @@ config DMA_NONCOHERENT
> select ARCH_HAS_DMA_PREP_COHERENT
> select ARCH_HAS_SYNC_DMA_FOR_DEVICE
> select ARCH_HAS_DMA_SET_UNCACHED
> + select ARCH_HAS_SETUP_DMA_OPS
This is an unrelated und undocument change. If you want to do it,
please do that as a separate patch with a commit log documenting
the rationale.
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 4/7] dma-mapping: Always provide dma_default_coherent
2023-02-21 12:46 ` [PATCH 4/7] dma-mapping: Always provide dma_default_coherent Jiaxun Yang
@ 2023-02-21 17:58 ` Christoph Hellwig
2023-02-21 19:35 ` Robin Murphy
2023-02-21 19:56 ` Jiaxun Yang
0 siblings, 2 replies; 23+ messages in thread
From: Christoph Hellwig @ 2023-02-21 17:58 UTC (permalink / raw)
To: Jiaxun Yang
Cc: linux-mips, linux-kernel, linuxppc-dev, tsbogend, mpe,
paul.walmsley, palmer, robh+dt, hch, m.szyprowski, robin.murphy
On Tue, Feb 21, 2023 at 12:46:10PM +0000, Jiaxun Yang wrote:
> dma_default_coherent can be useful for determine default coherency
> even on arches without noncoherent support.
How?
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 5/7] dma-mapping: Provide CONFIG_ARCH_DMA_DEFAULT_COHERENT
2023-02-21 12:46 ` [PATCH 5/7] dma-mapping: Provide CONFIG_ARCH_DMA_DEFAULT_COHERENT Jiaxun Yang
@ 2023-02-21 17:58 ` Christoph Hellwig
2023-02-21 18:18 ` Jiaxun Yang
0 siblings, 1 reply; 23+ messages in thread
From: Christoph Hellwig @ 2023-02-21 17:58 UTC (permalink / raw)
To: Jiaxun Yang
Cc: linux-mips, linux-kernel, linuxppc-dev, tsbogend, mpe,
paul.walmsley, palmer, robh+dt, hch, m.szyprowski, robin.murphy
On Tue, Feb 21, 2023 at 12:46:11PM +0000, Jiaxun Yang wrote:
> Provide a kconfig option to allow arches to manipulate default
> value of dma_default_coherent in Kconfig.
I don't see the win over just doing this by setting dma_default_coherent
in the early boot code.
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 6/7] riscv: Select ARCH_DMA_DEFAULT_COHERENT
2023-02-21 12:46 ` [PATCH 6/7] riscv: Select ARCH_DMA_DEFAULT_COHERENT Jiaxun Yang
@ 2023-02-21 18:14 ` Conor Dooley
2023-02-21 18:20 ` Jiaxun Yang
0 siblings, 1 reply; 23+ messages in thread
From: Conor Dooley @ 2023-02-21 18:14 UTC (permalink / raw)
To: Jiaxun Yang
Cc: linux-mips, linux-kernel, linuxppc-dev, tsbogend, mpe,
paul.walmsley, palmer, robh+dt, hch, m.szyprowski, robin.murphy
[-- Attachment #1: Type: text/plain, Size: 713 bytes --]
On Tue, Feb 21, 2023 at 12:46:12PM +0000, Jiaxun Yang wrote:
> For RISCV we always assume devices are DMA coherent.
"Always assume", I'm not keen on that wording as it is unclear as to
whether you are suggesting that a) we always take devices to be DMA
coherent, or b) unless a device states it is non-coherent, we take it to
be DMA coherent.
I think you mean b, but being exact would be appreciated, thanks.
> Select ARCH_DMA_DEFAULT_COHERENT to ensure dev->dma_conherent
> is always initialized to true.
>
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Why was this not sent to the riscv list?
When (or if) you send v2, can you please make sure that you do cc it?
Thanks,
Conor.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 0/7] MIPS DMA coherence fixes
2023-02-21 17:54 ` [PATCH 0/7] MIPS DMA coherence fixes Christoph Hellwig
@ 2023-02-21 18:15 ` Jiaxun Yang
2023-02-21 19:46 ` Robin Murphy
0 siblings, 1 reply; 23+ messages in thread
From: Jiaxun Yang @ 2023-02-21 18:15 UTC (permalink / raw)
To: Christoph Hellwig
Cc: linux-mips, linux-kernel, linuxppc-dev, Thomas Bogendoerfer, mpe,
paul.walmsley, palmer, Rob Herring, m.szyprowski, robin.murphy
> 2023年2月21日 17:54,Christoph Hellwig <hch@lst.de> 写道:
>
> Can you explain the motivation here? Also why riscv patches are at
> the end of a mips fіxes series?
Ah sorry for any confusion.
So the main purpose of this patch is to fix MIPS’s broken per-device coherency.
To be more precise, we want to be able to control the default coherency for all devices probed from
devicetree in early boot code.
To achieve that I decided to reuse dma_default_coherent to set default coherency for devicetree.
And all later patches are severing for this purpose.
Thanks
- Jiaxun
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 5/7] dma-mapping: Provide CONFIG_ARCH_DMA_DEFAULT_COHERENT
2023-02-21 17:58 ` Christoph Hellwig
@ 2023-02-21 18:18 ` Jiaxun Yang
0 siblings, 0 replies; 23+ messages in thread
From: Jiaxun Yang @ 2023-02-21 18:18 UTC (permalink / raw)
To: Christoph Hellwig
Cc: linux-mips, linux-kernel, linuxppc-dev, Thomas Bogendoerfer, mpe,
paul.walmsley, palmer, Rob Herring, m.szyprowski, robin.murphy
> 2023年2月21日 17:58,Christoph Hellwig <hch@lst.de> 写道:
>
> On Tue, Feb 21, 2023 at 12:46:11PM +0000, Jiaxun Yang wrote:
>> Provide a kconfig option to allow arches to manipulate default
>> value of dma_default_coherent in Kconfig.
>
> I don't see the win over just doing this by setting dma_default_coherent
> in the early boot code.
I just don’t want to dig into every archs’ early boot code to decide a good
timing for setting this variable.
Also as we do have a OF_DMA_DEFAULT_COHERENT before it makes more
sense to me.
Thanks
- Jiaxun
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 6/7] riscv: Select ARCH_DMA_DEFAULT_COHERENT
2023-02-21 18:14 ` Conor Dooley
@ 2023-02-21 18:20 ` Jiaxun Yang
0 siblings, 0 replies; 23+ messages in thread
From: Jiaxun Yang @ 2023-02-21 18:20 UTC (permalink / raw)
To: Conor Dooley
Cc: linux-mips, linux-kernel, linuxppc-dev, Thomas Bogendoerfer, mpe,
paul.walmsley, palmer, Rob Herring, Christoph Hellwig,
m.szyprowski, robin.murphy
> 2023年2月21日 18:14,Conor Dooley <conor@kernel.org> 写道:
>
> On Tue, Feb 21, 2023 at 12:46:12PM +0000, Jiaxun Yang wrote:
>> For RISCV we always assume devices are DMA coherent.
>
> "Always assume", I'm not keen on that wording as it is unclear as to
> whether you are suggesting that a) we always take devices to be DMA
> coherent, or b) unless a device states it is non-coherent, we take it to
> be DMA coherent.
> I think you mean b, but being exact would be appreciated, thanks.
Yep I meant option b, thanks for the point.
>
>> Select ARCH_DMA_DEFAULT_COHERENT to ensure dev->dma_conherent
>> is always initialized to true.
>>
>> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
>
> Why was this not sent to the riscv list?
> When (or if) you send v2, can you please make sure that you do cc it?
Will do.
Thanks
- Jiaxun
>
> Thanks,
> Conor.
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 4/7] dma-mapping: Always provide dma_default_coherent
2023-02-21 17:58 ` Christoph Hellwig
@ 2023-02-21 19:35 ` Robin Murphy
2023-02-21 19:56 ` Jiaxun Yang
1 sibling, 0 replies; 23+ messages in thread
From: Robin Murphy @ 2023-02-21 19:35 UTC (permalink / raw)
To: Christoph Hellwig, Jiaxun Yang
Cc: linux-mips, linux-kernel, linuxppc-dev, tsbogend, mpe,
paul.walmsley, palmer, robh+dt, m.szyprowski
On 2023-02-21 17:58, Christoph Hellwig wrote:
> On Tue, Feb 21, 2023 at 12:46:10PM +0000, Jiaxun Yang wrote:
>> dma_default_coherent can be useful for determine default coherency
>> even on arches without noncoherent support.
>
> How?
Indeed, "default" is conceptually meaningless when there is no possible
alternative :/
Robin.
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 0/7] MIPS DMA coherence fixes
2023-02-21 18:15 ` Jiaxun Yang
@ 2023-02-21 19:46 ` Robin Murphy
2023-02-21 19:55 ` Jiaxun Yang
0 siblings, 1 reply; 23+ messages in thread
From: Robin Murphy @ 2023-02-21 19:46 UTC (permalink / raw)
To: Jiaxun Yang, Christoph Hellwig
Cc: linux-mips, linux-kernel, linuxppc-dev, Thomas Bogendoerfer, mpe,
paul.walmsley, palmer, Rob Herring, m.szyprowski
On 2023-02-21 18:15, Jiaxun Yang wrote:
>
>
>> 2023年2月21日 17:54,Christoph Hellwig <hch@lst.de> 写道:
>>
>> Can you explain the motivation here? Also why riscv patches are at
>> the end of a mips fіxes series?
>
> Ah sorry for any confusion.
>
> So the main purpose of this patch is to fix MIPS’s broken per-device coherency.
> To be more precise, we want to be able to control the default coherency for all devices probed from
> devicetree in early boot code.
Including the patch which actually does that would be helpful. As it is,
patches 4-7 here just appear to be moving an option around for no
practical effect.
Robin.
> To achieve that I decided to reuse dma_default_coherent to set default coherency for devicetree.
> And all later patches are severing for this purpose.
>
> Thanks
> - Jiaxun
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 0/7] MIPS DMA coherence fixes
2023-02-21 19:46 ` Robin Murphy
@ 2023-02-21 19:55 ` Jiaxun Yang
2023-02-22 12:55 ` Robin Murphy
0 siblings, 1 reply; 23+ messages in thread
From: Jiaxun Yang @ 2023-02-21 19:55 UTC (permalink / raw)
To: Robin Murphy
Cc: Christoph Hellwig, linux-mips, linux-kernel, linuxppc-dev,
Thomas Bogendoerfer, mpe, paul.walmsley, palmer, Rob Herring,
m.szyprowski
> 2023年2月21日 19:46,Robin Murphy <robin.murphy@arm.com> 写道:
>
> On 2023-02-21 18:15, Jiaxun Yang wrote:
>>> 2023年2月21日 17:54,Christoph Hellwig <hch@lst.de> 写道:
>>>
>>> Can you explain the motivation here? Also why riscv patches are at
>>> the end of a mips fіxes series?
>> Ah sorry for any confusion.
>> So the main purpose of this patch is to fix MIPS’s broken per-device coherency.
>> To be more precise, we want to be able to control the default coherency for all devices probed from
>> devicetree in early boot code.
>
> Including the patch which actually does that would be helpful. As it is, patches 4-7 here just appear to be moving an option around for no practical effect.
Well the affect is default coherency of devicetree probed devices are now following dma_default_coherent
instead of a static Kconfig option. For MIPS platform, dma_default_coherent will be determined by boot code.
Thanks
- Jiaxun
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 4/7] dma-mapping: Always provide dma_default_coherent
2023-02-21 17:58 ` Christoph Hellwig
2023-02-21 19:35 ` Robin Murphy
@ 2023-02-21 19:56 ` Jiaxun Yang
1 sibling, 0 replies; 23+ messages in thread
From: Jiaxun Yang @ 2023-02-21 19:56 UTC (permalink / raw)
To: Christoph Hellwig
Cc: linux-mips, linux-kernel, linuxppc-dev, Thomas Bogendoerfer, mpe,
paul.walmsley, palmer, Rob Herring, m.szyprowski, robin.murphy
> 2023年2月21日 17:58,Christoph Hellwig <hch@lst.de> 写道:
>
> On Tue, Feb 21, 2023 at 12:46:10PM +0000, Jiaxun Yang wrote:
>> dma_default_coherent can be useful for determine default coherency
>> even on arches without noncoherent support.
>
> How?
I just want to make this symbol always available so OF code can reference it on all arches.
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 0/7] MIPS DMA coherence fixes
2023-02-21 19:55 ` Jiaxun Yang
@ 2023-02-22 12:55 ` Robin Murphy
2023-02-22 13:04 ` Jiaxun Yang
0 siblings, 1 reply; 23+ messages in thread
From: Robin Murphy @ 2023-02-22 12:55 UTC (permalink / raw)
To: Jiaxun Yang
Cc: Christoph Hellwig, linux-mips, linux-kernel, linuxppc-dev,
Thomas Bogendoerfer, mpe, paul.walmsley, palmer, Rob Herring,
m.szyprowski
On 2023-02-21 19:55, Jiaxun Yang wrote:
>
>
>> 2023年2月21日 19:46,Robin Murphy <robin.murphy@arm.com> 写道:
>>
>> On 2023-02-21 18:15, Jiaxun Yang wrote:
>>>> 2023年2月21日 17:54,Christoph Hellwig <hch@lst.de> 写道:
>>>>
>>>> Can you explain the motivation here? Also why riscv patches are at
>>>> the end of a mips fіxes series?
>>> Ah sorry for any confusion.
>>> So the main purpose of this patch is to fix MIPS’s broken per-device coherency.
>>> To be more precise, we want to be able to control the default coherency for all devices probed from
>>> devicetree in early boot code.
>>
>> Including the patch which actually does that would be helpful. As it is, patches 4-7 here just appear to be moving an option around for no practical effect.
>
> Well the affect is default coherency of devicetree probed devices are now following dma_default_coherent
> instead of a static Kconfig option. For MIPS platform, dma_default_coherent will be determined by boot code.
"Will be" is the issue I'm getting at. We can't review some future
promise of a patch, we can only review actual patches. And it's hard to
meaningfully review preparatory patches for some change without the full
context of that change.
Thanks,
Robin.
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 0/7] MIPS DMA coherence fixes
2023-02-22 12:55 ` Robin Murphy
@ 2023-02-22 13:04 ` Jiaxun Yang
2023-02-22 14:22 ` Robin Murphy
0 siblings, 1 reply; 23+ messages in thread
From: Jiaxun Yang @ 2023-02-22 13:04 UTC (permalink / raw)
To: Robin Murphy
Cc: Christoph Hellwig, linux-mips, linux-kernel, linuxppc-dev,
Thomas Bogendoerfer, mpe, paul.walmsley, palmer, Rob Herring,
m.szyprowski
> 2023年2月22日 12:55,Robin Murphy <robin.murphy@arm.com> 写道:
>
> On 2023-02-21 19:55, Jiaxun Yang wrote:
>>> 2023年2月21日 19:46,Robin Murphy <robin.murphy@arm.com> 写道:
>>>
>>> On 2023-02-21 18:15, Jiaxun Yang wrote:
>>>>> 2023年2月21日 17:54,Christoph Hellwig <hch@lst.de> 写道:
>>>>>
>>>>> Can you explain the motivation here? Also why riscv patches are at
>>>>> the end of a mips fіxes series?
>>>> Ah sorry for any confusion.
>>>> So the main purpose of this patch is to fix MIPS’s broken per-device coherency.
>>>> To be more precise, we want to be able to control the default coherency for all devices probed from
>>>> devicetree in early boot code.
>>>
>>> Including the patch which actually does that would be helpful. As it is, patches 4-7 here just appear to be moving an option around for no practical effect.
>> Well the affect is default coherency of devicetree probed devices are now following dma_default_coherent
>> instead of a static Kconfig option. For MIPS platform, dma_default_coherent will be determined by boot code.
>
> "Will be" is the issue I'm getting at. We can't review some future promise of a patch, we can only review actual patches. And it's hard to meaningfully review preparatory patches for some change without the full context of that change.
Actually this already present in current MIPS platform code.
arch/mips/mti-malta is setting dma_default_coherent on boot, and it’s devicetree does not explicitly specify coherency.
Thanks
- Jiaxun
>
> Thanks,
> Robin.
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 0/7] MIPS DMA coherence fixes
2023-02-22 13:04 ` Jiaxun Yang
@ 2023-02-22 14:22 ` Robin Murphy
0 siblings, 0 replies; 23+ messages in thread
From: Robin Murphy @ 2023-02-22 14:22 UTC (permalink / raw)
To: Jiaxun Yang
Cc: Christoph Hellwig, linux-mips, linux-kernel, linuxppc-dev,
Thomas Bogendoerfer, mpe, paul.walmsley, palmer, Rob Herring,
m.szyprowski
On 2023-02-22 13:04, Jiaxun Yang wrote:
>
>
>> 2023年2月22日 12:55,Robin Murphy <robin.murphy@arm.com> 写道:
>>
>> On 2023-02-21 19:55, Jiaxun Yang wrote:
>>>> 2023年2月21日 19:46,Robin Murphy <robin.murphy@arm.com> 写道:
>>>>
>>>> On 2023-02-21 18:15, Jiaxun Yang wrote:
>>>>>> 2023年2月21日 17:54,Christoph Hellwig <hch@lst.de> 写道:
>>>>>>
>>>>>> Can you explain the motivation here? Also why riscv patches are at
>>>>>> the end of a mips fіxes series?
>>>>> Ah sorry for any confusion.
>>>>> So the main purpose of this patch is to fix MIPS’s broken per-device coherency.
>>>>> To be more precise, we want to be able to control the default coherency for all devices probed from
>>>>> devicetree in early boot code.
>>>>
>>>> Including the patch which actually does that would be helpful. As it is, patches 4-7 here just appear to be moving an option around for no practical effect.
>>> Well the affect is default coherency of devicetree probed devices are now following dma_default_coherent
>>> instead of a static Kconfig option. For MIPS platform, dma_default_coherent will be determined by boot code.
>>
>> "Will be" is the issue I'm getting at. We can't review some future promise of a patch, we can only review actual patches. And it's hard to meaningfully review preparatory patches for some change without the full context of that change.
>
> Actually this already present in current MIPS platform code.
>
> arch/mips/mti-malta is setting dma_default_coherent on boot, and it’s devicetree does not explicitly specify coherency.
OK, this really needs to be explained much more clearly. I read this
series as 3 actual fix patches, then 3 patches adding a new option to
replace an existing one on the grounds that it "can be useful" for
unspecified purposes, then a final cleanup patch removing the old option
that has now been superseded.
Going back and looking closely I see there is actually a brief mention
in the cleanup patch that it also happens to fix some issue, but even
then it doesn't clearly explain what the issue really is or how and why
the fix works and is appropriate.
Ideally, functional fixes and cleanup should be in distinct patches
whenever that is reasonable. Sometimes the best fix is inherently a
cleanup, but in such cases the patch should always be presented as the
fix being its primary purpose. Please also use the cover letter to give
reviewers an overview of the whole series if it's not merely a set of
loosely-related patches that just happened to be convenient so send all
together.
I think I do at least now understand the underlying problem well enough
to have a think about whether this is the best way to address it.
Thanks,
Robin.
^ permalink raw reply [flat|nested] 23+ messages in thread
end of thread, other threads:[~2023-02-22 14:23 UTC | newest]
Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-21 12:46 [PATCH 0/7] MIPS DMA coherence fixes Jiaxun Yang
2023-02-21 12:46 ` [PATCH 1/7] MIPS: Remove DMA_PERDEV_COHERENT Jiaxun Yang
2023-02-21 17:56 ` Christoph Hellwig
2023-02-21 12:46 ` [PATCH 2/7] MIPS: Always select ARCH_HAS_SYNC_DMA_FOR_CPU for noncoherent platforms Jiaxun Yang
2023-02-21 12:46 ` [PATCH 3/7] MIPS: c-r4k: Always install dma flush functions Jiaxun Yang
2023-02-21 12:46 ` [PATCH 4/7] dma-mapping: Always provide dma_default_coherent Jiaxun Yang
2023-02-21 17:58 ` Christoph Hellwig
2023-02-21 19:35 ` Robin Murphy
2023-02-21 19:56 ` Jiaxun Yang
2023-02-21 12:46 ` [PATCH 5/7] dma-mapping: Provide CONFIG_ARCH_DMA_DEFAULT_COHERENT Jiaxun Yang
2023-02-21 17:58 ` Christoph Hellwig
2023-02-21 18:18 ` Jiaxun Yang
2023-02-21 12:46 ` [PATCH 6/7] riscv: Select ARCH_DMA_DEFAULT_COHERENT Jiaxun Yang
2023-02-21 18:14 ` Conor Dooley
2023-02-21 18:20 ` Jiaxun Yang
2023-02-21 12:46 ` [PATCH 7/7] of: address: Use dma_default_coherent to determine default coherency Jiaxun Yang
2023-02-21 17:54 ` [PATCH 0/7] MIPS DMA coherence fixes Christoph Hellwig
2023-02-21 18:15 ` Jiaxun Yang
2023-02-21 19:46 ` Robin Murphy
2023-02-21 19:55 ` Jiaxun Yang
2023-02-22 12:55 ` Robin Murphy
2023-02-22 13:04 ` Jiaxun Yang
2023-02-22 14:22 ` Robin Murphy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).