Skip to contentSkip to conversation

of: addr: Translate 'dma-ranges' for parent nodes missing 'dma-ranges'

PATCH In review Bin Meng 2 participants 9 messages Apr 30, 2021 – Jun 5, 2021

lore
Share & tools
lore

Bin Meng

author
#0 lore raw

PATCH v2 1/2 of: addr: Translate 'dma-ranges' for parent nodes missing 'dma-ranges'

'dma-ranges' frequently exists without parent nodes having 'dma-ranges'. While this is an error for 'ranges', this is fine because DMA capable devices always have a translatable DMA address. Also, with no 'dma-ranges' at all, the assumption is that DMA addresses are 1:1 with no restrictions unless perhaps the device itself has implicit restrictions.

This keeps in sync with Linux kernel commit:

81db12ee15cb: of/address: Translate 'dma-ranges' for parent nodes missing 'dma-ranges'

---

Changes in v2:
- rebase on top of Dario's revert patch:
http://patchwork.ozlabs.org/project/uboot/patch/20210425141746.19115-6-dariobin at libero.it/
- drop commit "of: addr: Abort address translation for parent nodes missing 'ranges'", as the revert patch restores the abort behavior

 drivers/core/of_addr.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/core/of_addr.c +5 -1
index 9b77308182..a3af48fd88 100644
@@ -192,9 +192,13 @@ static int of_translate_one(const struct device_node *parent,
 	 *
 	 * As far as we know, this damage only exists on Apple machines, so
 	 * This code is only enabled on powerpc. --gcl
+	 *
+	 * This quirk also applies for 'dma-ranges' which frequently exist in
+	 * child nodes without 'dma-ranges' in the parent nodes. --RobH
 	 */
 	ranges = of_get_property(parent, rprop, &rlen);
-	if (ranges == NULL && !of_empty_ranges_quirk(parent)) {
+	if (ranges == NULL && !of_empty_ranges_quirk(parent) &&
+	    strcmp(rprop, "dma-ranges")) {
 		debug("no ranges; cannot translate\n");
 		return 1;
 	}
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH v2 1/2 of: addr: Translate 'dma-ranges' for parent nodes missing 'dma-ranges'

Hi Simon,

Quoted 12 lines · Bin Meng

'dma-ranges' frequently exists without parent nodes having 'dma-ranges'. While this is an error for 'ranges', this is fine because DMA capable devices always have a translatable DMA address. Also, with no 'dma-ranges' at all, the assumption is that DMA addresses are 1:1 with no restrictions unless perhaps the device itself has implicit restrictions.

This keeps in sync with Linux kernel commit:

81db12ee15cb: of/address: Translate 'dma-ranges' for parent nodes missing 'dma-ranges'

Quoted 8 lines

---

Changes in v2:
- rebase on top of Dario's revert patch:
http://patchwork.ozlabs.org/project/uboot/patch/20210425141746.19115-6-dariobin at libero.it/

The above dependent patch is now in u-boot/master.

Could you please apply this series?

Quoted 6 lines

- drop commit "of: addr: Abort address translation for parent nodes missing 'ranges'", as the revert patch restores the abort behavior

 drivers/core/of_addr.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Regards,
Bin

author
#2 lore raw
Quoted 21 lines · Bin Meng

Hi Simon,

Quoted 17 lines · Bin Meng

'dma-ranges' frequently exists without parent nodes having 'dma-ranges'. While this is an error for 'ranges', this is fine because DMA capable devices always have a translatable DMA address. Also, with no 'dma-ranges' at all, the assumption is that DMA addresses are 1:1 with no restrictions unless perhaps the device itself has implicit restrictions.

This keeps in sync with Linux kernel commit:

81db12ee15cb: of/address: Translate 'dma-ranges' for parent nodes missing 'dma-ranges'

---

Quoted 8 lines
Quoted 3 lines

Changes in v2:
- rebase on top of Dario's revert patch:
http://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

The above dependent patch is now in u-boot/master.

Could you please apply this series?

Ping?

#3 lore raw

Hi Bin,

Quoted 27 lines · Bin Meng
Quoted 25 lines · Bin Meng

Hi Simon,

Quoted 20 lines · Bin Meng

'dma-ranges' frequently exists without parent nodes having 'dma-ranges'. While this is an error for 'ranges', this is fine because DMA capable devices always have a translatable DMA address. Also, with no 'dma-ranges' at all, the assumption is that DMA addresses are 1:1 with no restrictions unless perhaps the device itself has implicit restrictions.

This keeps in sync with Linux kernel commit:

81db12ee15cb: of/address: Translate 'dma-ranges' for parent nodes missing 'dma-ranges'

---

Changes in v2:
- rebase on top of Dario's revert patch:
http://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

Quoted 6 lines
Quoted 4 lines

The above dependent patch is now in u-boot/master.

Could you please apply this series?

Ping?

OK I am taking a look.

Regards,
Simon

#4 lore raw

Hi Bin,

Quoted 27 lines · Bin Meng
Quoted 25 lines · Bin Meng

Hi Simon,

Quoted 20 lines · Bin Meng

'dma-ranges' frequently exists without parent nodes having 'dma-ranges'. While this is an error for 'ranges', this is fine because DMA capable devices always have a translatable DMA address. Also, with no 'dma-ranges' at all, the assumption is that DMA addresses are 1:1 with no restrictions unless perhaps the device itself has implicit restrictions.

This keeps in sync with Linux kernel commit:

81db12ee15cb: of/address: Translate 'dma-ranges' for parent nodes missing 'dma-ranges'

---

Changes in v2:
- rebase on top of Dario's revert patch:
http://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

Quoted 6 lines
Quoted 4 lines

The above dependent patch is now in u-boot/master.

Could you please apply this series?

Ping?

OK I am taking a look.

Regards,
Simon

Applied to u-boot-dm, thanks!

author
#5 lore raw

PATCH v2 2/2 of: addr: Remove call to dev_count_cells() in of_get_address()

In reply to Bin Meng

In of_get_address(), there is:

  dev_count_cells(dev, &na, &ns);

followed by:

  bus->count_cells(dev, &na, &ns);

but no codes in between use na/ns, hence the first call is useless. By dropping the first call, dev_count_cells() is now useless too.

---

Changes in v2:
- new patch: of: addr: Remove call to dev_count_cells() in of_get_address()

 drivers/core/of_addr.c | 6 ------
 1 file changed, 6 deletions(-)
drivers/core/of_addr.c +0 -6
index a3af48fd88..3fbc0a7afa 100644
@@ -118,11 +118,6 @@ static struct of_bus *of_match_bus(struct device_node *np)
 	return NULL;
 }
 
-static void dev_count_cells(const struct device_node *np, int *nap, int *nsp)
-{
-	of_bus_default_count_cells(np, nap, nsp);
-}
-
 const __be32 *of_get_address(const struct device_node *dev, int index,
 			     u64 *size, unsigned int *flags)
 {
@@ -136,7 +131,6 @@ const __be32 *of_get_address(const struct device_node *dev, int index,
 	parent = of_get_parent(dev);
 	if (parent == NULL)
 		return NULL;
-	dev_count_cells(dev, &na, &ns);
 	bus = of_match_bus(parent);
 	bus->count_cells(dev, &na, &ns);
 	of_node_put(parent);
Signature · 1 line
2.25.1
#6 lore raw

PATCH v2 2/2 of: addr: Remove call to dev_count_cells() in of_get_address()

Quoted 14 lines · Bin Meng

In of_get_address(), there is:

  dev_count_cells(dev, &na, &ns);

followed by:

  bus->count_cells(dev, &na, &ns);

but no codes in between use na/ns, hence the first call is useless. By dropping the first call, dev_count_cells() is now useless too.

Quoted 7 lines

---

Changes in v2:
- new patch: of: addr: Remove call to dev_count_cells() in of_get_address()

 drivers/core/of_addr.c | 6 ------
 1 file changed, 6 deletions(-)

I wonder why this is now different from linux?

author
#7 lore raw

PATCH v2 2/2 of: addr: Remove call to dev_count_cells() in of_get_address()

Hi Simon,

Quoted 21 lines · Simon Glass
Quoted 19 lines · Bin Meng

In of_get_address(), there is:

  dev_count_cells(dev, &na, &ns);

followed by:

  bus->count_cells(dev, &na, &ns);

but no codes in between use na/ns, hence the first call is useless. By dropping the first call, dev_count_cells() is now useless too.

---

Changes in v2:
- new patch: of: addr: Remove call to dev_count_cells() in of_get_address()

Quoted 6 lines
Quoted 2 lines
 drivers/core/of_addr.c | 6 ------
 1 file changed, 6 deletions(-)

I wonder why this is now different from linux?

With this patch, the code flow is the same as Linux.

Regards,
Bin

#8 lore raw

Re: [PATCH v2 2/2] of: addr: Remove call to dev_count_cells() in of_get_address()

Hi Simon,

Quoted 21 lines · Simon Glass
Quoted 19 lines · Bin Meng

In of_get_address(), there is:

  dev_count_cells(dev, &na, &ns);

followed by:

  bus->count_cells(dev, &na, &ns);

but no codes in between use na/ns, hence the first call is useless. By dropping the first call, dev_count_cells() is now useless too.

---

Changes in v2:
- new patch: of: addr: Remove call to dev_count_cells() in of_get_address()

Quoted 6 lines
Quoted 2 lines
 drivers/core/of_addr.c | 6 ------
 1 file changed, 6 deletions(-)

I wonder why this is now different from linux?

With this patch, the code flow is the same as Linux.

Regards,
Bin

Applied to u-boot-dm, thanks!