Skip to content

Commit dabf6b3

Browse files
mperobherring
authored andcommitted
of: Add OF_DMA_DEFAULT_COHERENT & select it on powerpc
There's an OF helper called of_dma_is_coherent(), which checks if a device has a "dma-coherent" property to see if the device is coherent for DMA. But on some platforms devices are coherent by default, and on some platforms it's not possible to update existing device trees to add the "dma-coherent" property. So add a Kconfig symbol to allow arch code to tell of_dma_is_coherent() that devices are coherent by default, regardless of the presence of the property. Select that symbol on powerpc when NOT_COHERENT_CACHE is not set, ie. when the system has a coherent cache. Fixes: 92ea637 ("of: introduce of_dma_is_coherent() helper") Cc: [email protected] # v3.16+ Reported-by: Christian Zigotzky <[email protected]> Tested-by: Christian Zigotzky <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Reviewed-by: Ulf Hansson <[email protected]> Signed-off-by: Rob Herring <[email protected]>
1 parent 9243f29 commit dabf6b3

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

arch/powerpc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ config PPC
238238
select NEED_DMA_MAP_STATE if PPC64 || NOT_COHERENT_CACHE
239239
select NEED_SG_DMA_LENGTH
240240
select OF
241+
select OF_DMA_DEFAULT_COHERENT if !NOT_COHERENT_CACHE
241242
select OF_EARLY_FLATTREE
242243
select OLD_SIGACTION if PPC32
243244
select OLD_SIGSUSPEND

drivers/of/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,8 @@ config OF_OVERLAY
103103
config OF_NUMA
104104
bool
105105

106+
config OF_DMA_DEFAULT_COHERENT
107+
# arches should select this if DMA is coherent by default for OF devices
108+
bool
109+
106110
endif # OF

drivers/of/address.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -995,12 +995,16 @@ int of_dma_get_range(struct device_node *np, u64 *dma_addr, u64 *paddr, u64 *siz
995995
* @np: device node
996996
*
997997
* It returns true if "dma-coherent" property was found
998-
* for this device in DT.
998+
* for this device in the DT, or if DMA is coherent by
999+
* default for OF devices on the current platform.
9991000
*/
10001001
bool of_dma_is_coherent(struct device_node *np)
10011002
{
10021003
struct device_node *node = of_node_get(np);
10031004

1005+
if (IS_ENABLED(CONFIG_OF_DMA_DEFAULT_COHERENT))
1006+
return true;
1007+
10041008
while (node) {
10051009
if (of_property_read_bool(node, "dma-coherent")) {
10061010
of_node_put(node);

0 commit comments

Comments
 (0)