28d1987a9c70ba0030c8010ca24a11fff0e2336f
[openwrt/staging/neocturne.git] /
1 From 39f5d9e883393e32938eac45b564f74afde8a942 Mon Sep 17 00:00:00 2001
2 From: Rob Herring <robh@kernel.org>
3 Date: Wed, 4 Sep 2019 11:43:30 +0100
4 Subject: [PATCH] of/address: Translate 'dma-ranges' for parent nodes
5 missing 'dma-ranges'
6
7 commit 81db12ee15cb83926e290a8a3654a2dfebc80935 upstream.
8
9 'dma-ranges' frequently exists without parent nodes having 'dma-ranges'.
10 While this is an error for 'ranges', this is fine because DMA capable
11 devices always have a translatable DMA address. Also, with no
12 'dma-ranges' at all, the assumption is that DMA addresses are 1:1 with
13 no restrictions unless perhaps the device itself has implicit
14 restrictions.
15
16 Cc: Robin Murphy <robin.murphy@arm.com>
17 Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
18 Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
19 Signed-off-by: Rob Herring <robh@kernel.org>
20 ---
21 drivers/of/address.c | 6 +++++-
22 1 file changed, 5 insertions(+), 1 deletion(-)
23
24 --- a/drivers/of/address.c
25 +++ b/drivers/of/address.c
26 @@ -519,9 +519,13 @@ static int of_translate_one(struct devic
27 *
28 * As far as we know, this damage only exists on Apple machines, so
29 * This code is only enabled on powerpc. --gcl
30 + *
31 + * This quirk also applies for 'dma-ranges' which frequently exist in
32 + * child nodes without 'dma-ranges' in the parent nodes. --RobH
33 */
34 ranges = of_get_property(parent, rprop, &rlen);
35 - if (ranges == NULL && !of_empty_ranges_quirk(parent)) {
36 + if (ranges == NULL && !of_empty_ranges_quirk(parent) &&
37 + strcmp(rprop, "dma-ranges")) {
38 pr_debug("no ranges; cannot translate\n");
39 return 1;
40 }