Skip to contentSkip to conversation

Aspeed: xdma: Switch to reserved memory node

PATCH In review Eddie James 2 participants 6 messages Mar 26, 2020 – Mar 30, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Aspeed: xdma: Switch to reserved memory node

Switch the XDMA driver and devicetree bindings over to use a reserved memory node for the memory used by the XDMA engine.

Eddie James (4):
soc: aspeed: xdma: Switch to reserved memory
dt-bindings: soc: xdma: Switch to reserved memory node
ARM: dts: Aspeed: Tacoma: Add reserved memory for XDMA
ARM: dts: Aspeed: Witherspoon: Add reserved memory for XDMA

 .../devicetree/bindings/soc/aspeed/xdma.txt        |  6 ++---
 arch/arm/boot/dts/aspeed-bmc-opp-tacoma.dts        |  8 +++++--
 arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts   |  8 +++++--
 drivers/soc/aspeed/aspeed-xdma.c                   | 26 ++++++++++++++--------
 4 files changed, 32 insertions(+), 16 deletions(-)
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/4 soc: aspeed: xdma: Switch to reserved memory

Use a reserved memory node with no-map for the memory used by the XDMA engine. This replaces the memory property previously used to access the reserved VGA memory space.

---
 drivers/soc/aspeed/aspeed-xdma.c | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)
drivers/soc/aspeed/aspeed-xdma.c +17 -9
index 5d97919..470fe6d 100644
@@ -17,6 +17,7 @@
 #include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/of_device.h>
+#include <linux/of_reserved_mem.h>
 #include <linux/platform_device.h>
 #include <linux/poll.h>
 #include <linux/regmap.h>
@@ -845,10 +846,11 @@ static int aspeed_xdma_probe(struct platform_device *pdev)
 	int rc;
 	int irq;
 	int pcie_irq;
-	u32 memory[2];
 	struct regmap *sdmc;
 	struct aspeed_xdma *ctx;
+	struct reserved_mem *mem;
 	struct device *dev = &pdev->dev;
+	struct device_node *memory_region;
 	const void *md = of_device_get_match_data(dev);
 
 	if (!md)
@@ -910,19 +912,25 @@ static int aspeed_xdma_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
-	rc = of_property_read_u32_array(dev->of_node, "memory", memory, 2);
-	if (rc) {
-		dev_err(dev, "Unable to get memory space.\n");
-		return rc;
+	memory_region = of_parse_phandle(dev->of_node, "memory-region", 0);
+	if (!memory_region) {
+		dev_err(dev, "Unable to get memory-region.\n");
+		return -ENOMEM;
 	}
 
-	ctx->mem_phys = memory[0];
-	ctx->mem_size = memory[1];
+	mem = of_reserved_mem_lookup(memory_region);
+	if (!mem) {
+		dev_err(dev, "Unable to find reserved memory.\n");
+		return -ENOMEM;
+	}
+
+	ctx->mem_phys = mem->base;
+	ctx->mem_size = mem->size;
 
 	ctx->mem_virt = devm_ioremap(dev, ctx->mem_phys, ctx->mem_size);
-	if (IS_ERR(ctx->mem_virt)) {
+	if (!ctx->mem_virt) {
 		dev_err(dev, "Failed to map memory space.\n");
-		return PTR_ERR(ctx->mem_virt);
+		return -ENOMEM;
 	}
 
 	rc = gen_pool_add_virt(ctx->pool, (unsigned long)ctx->mem_virt,
Signature · 1 line
1.8.3.1
#3 lore raw

PATCH 2/4 dt-bindings: soc: xdma: Switch to reserved memory node

In reply to Eddie James

Change the memory property to the more standard memory-region node.

---
 Documentation/devicetree/bindings/soc/aspeed/xdma.txt | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/soc/aspeed/xdma.txt +3 -3
index 074bda5..da62975 100644
@@ -17,8 +17,8 @@ Required properties:
 			  specifies the PCI-E reset or PERST interrupt.
  - aspeed,scu		: a phandle to the syscon node for the system control
 			  unit of the SOC
- - memory		: contains the address and size of the memory area to
-			  be used by the XDMA engine for DMA operations
+ - memory-region	: a phandle to the reserved memory region to be used by
+			  the XDMA engine for DMA operations
 
 Optional properties:
  - pcie-device		: should be either "bmc" or "vga", corresponding to
@@ -36,5 +36,5 @@ Example:
         interrupts-extended = <&vic 6>, <&scu_ic ASPEED_AST2500_SCU_IC_PCIE_RESET_LO_TO_HI>;
         aspeed,scu = <&syscon>;
         pcie-device = "bmc";
-        memory = <0x9f000000 0x01000000>;
+        memory-region = <&vga_memory>;
     };
Signature · 1 line
1.8.3.1
#4 lore raw

PATCH 3/4 ARM: dts: Aspeed: Tacoma: Add reserved memory for XDMA

In reply to Eddie James

Use a no-map reserved memory node for use by the XDMA engine.

---
 arch/arm/boot/dts/aspeed-bmc-opp-tacoma.dts | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
arch/arm/boot/dts/aspeed-bmc-opp-tacoma.dts +6 -2
index 194a482..2cd903f 100644
@@ -29,6 +29,11 @@
 			no-map;
 			reg = <0xb8000000 0x4000000>; /* 64M */
 		};
+
+		vga_memory: region@bf000000 {
+			no-map;
+			reg = <0xbf000000 0x01000000>;	/* 16M */
+		};
 	};
 
 	gpio-keys {
@@ -807,6 +812,5 @@
 
 &xdma {
 	status = "okay";
-	/* 1G DRAM with 8M VRAM which is reserved at the top. */
-	memory = <0xbf800000 0x00800000>;
+	memory-region = <&vga_memory>;
 };
Signature · 1 line
1.8.3.1
#5 lore raw

PATCH 4/4 ARM: dts: Aspeed: Witherspoon: Add reserved memory for XDMA

In reply to Eddie James

Use a no-map reserved memory node for use by the XDMA engine.

---
 arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +6 -2
index da9e379..ce445fe 100644
@@ -27,6 +27,11 @@
 			reg = <0x98000000 0x04000000>; /* 64M */
 		};
 
+		vga_memory: region@9f000000 {
+			no-map;
+			reg = <0x9f000000 0x01000000>; /* 16M */
+		};
+
 		gfx_memory: framebuffer {
 			size = <0x01000000>;
 			alignment = <0x01000000>;
@@ -746,8 +751,7 @@
 
 &xdma {
 	status = "okay";
-	/* 512M DRAM with 16M VRAM which is reserved at the top. */
-	memory = <0x9f000000 0x01000000>;
+	memory-region = <&vga_memory>;
 };
 
 #include "ibm-power9-dual.dtsi"
Signature · 1 line
1.8.3.1
Acked-by on v1 1/4
#2 lore raw

Re: [PATCH linux dev-5.4 1/4] soc: aspeed: xdma: Switch to reserved memory

In reply to Eddie James
Quoted 3 lines · Eddie James

Use a reserved memory node with no-map for the memory used by the XDMA engine. This replaces the memory property previously used to access the reserved VGA memory space.

Great. Can you refresh the upstream patch series (apologies if you already have)?