Skip to content

Commit 12b8277

Browse files
mmindpalmer-dabbelt
authored andcommitted
of: also handle dma-noncoherent in of_dma_is_coherent()
of_dma_is_coherent() currently expects the architecture to be non-coherent and some devices being coherent getting marked as such with the dma-coherent devicetree property. For PowerPC CONFIG_OF_DMA_DEFAULT_COHERENT was added which currently makes of_dma_is_coherent() always return true but doesn't handle the case of the architecture being coherent but some devices not. So modify the function to also check for dma-noncoherent and set a suitable default return value. If CONFIG_OF_DMA_DEFAULT_COHERENT is set the value starts with true and finding dma-noncoherent will set it to false and without CONFIG_OF_DMA_DEFAULT_COHERENT, the behaviour is reversed. Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Rob Herring <[email protected]> Reviewed-by: Guo Ren <[email protected]> Signed-off-by: Heiko Stuebner <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 73448ae commit 12b8277

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

drivers/of/address.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,26 +1045,29 @@ phys_addr_t __init of_dma_get_max_cpu_address(struct device_node *np)
10451045
*
10461046
* It returns true if "dma-coherent" property was found
10471047
* for this device in the DT, or if DMA is coherent by
1048-
* default for OF devices on the current platform.
1048+
* default for OF devices on the current platform and no
1049+
* "dma-noncoherent" property was found for this device.
10491050
*/
10501051
bool of_dma_is_coherent(struct device_node *np)
10511052
{
10521053
struct device_node *node;
1053-
1054-
if (IS_ENABLED(CONFIG_OF_DMA_DEFAULT_COHERENT))
1055-
return true;
1054+
bool is_coherent = IS_ENABLED(CONFIG_OF_DMA_DEFAULT_COHERENT);
10561055

10571056
node = of_node_get(np);
10581057

10591058
while (node) {
10601059
if (of_property_read_bool(node, "dma-coherent")) {
1061-
of_node_put(node);
1062-
return true;
1060+
is_coherent = true;
1061+
break;
1062+
}
1063+
if (of_property_read_bool(node, "dma-noncoherent")) {
1064+
is_coherent = false;
1065+
break;
10631066
}
10641067
node = of_get_next_dma_parent(node);
10651068
}
10661069
of_node_put(node);
1067-
return false;
1070+
return is_coherent;
10681071
}
10691072
EXPORT_SYMBOL_GPL(of_dma_is_coherent);
10701073

0 commit comments

Comments
 (0)