Skip to contentSkip to conversation

soc: fsl: qbman: Remove RESERVEDMEM_OF_DECLARE usage

PATCH In review Rob Herring 2 participants 3 messages Feb 1, 2024 – Mar 5, 2024 Freescale SoC drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 soc: fsl: qbman: Remove RESERVEDMEM_OF_DECLARE usage

There is no reason to use RESERVEDMEM_OF_DECLARE() as the initialization hook just saves off the base address and size. Use of RESERVEDMEM_OF_DECLARE() is reserved for non-driver code and initialization which must be done early. For qbman, retrieving the address and size can be done in probe just as easily.

---
 drivers/soc/fsl/qbman/bman_ccsr.c | 27 +++---------
 drivers/soc/fsl/qbman/dpaa_sys.c  | 12 +++--
 drivers/soc/fsl/qbman/dpaa_sys.h  |  4 +-
 drivers/soc/fsl/qbman/qman_ccsr.c | 73 ++++++++++---------------------
 4 files changed, 38 insertions(+), 78 deletions(-)
drivers/soc/fsl/qbman/bman_ccsr.c +5 -22
index cb24a08be084..b0f26f6f731e 100644
@@ -144,17 +144,6 @@ static int bm_set_memory(u64 ba, u32 size)
 static dma_addr_t fbpr_a;
 static size_t fbpr_sz;
 
-static int bman_fbpr(struct reserved_mem *rmem)
-{
-	fbpr_a = rmem->base;
-	fbpr_sz = rmem->size;
-
-	WARN_ON(!(fbpr_a && fbpr_sz));
-
-	return 0;
-}
-RESERVEDMEM_OF_DECLARE(bman_fbpr, "fsl,bman-fbpr", bman_fbpr);
-
 static irqreturn_t bman_isr(int irq, void *ptr)
 {
 	u32 isr_val, ier_val, ecsr_val, isr_mask, i;
@@ -242,17 +231,11 @@ static int fsl_bman_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	/*
-	 * If FBPR memory wasn't defined using the qbman compatible string
-	 * try using the of_reserved_mem_device method
-	 */
-	if (!fbpr_a) {
-		ret = qbman_init_private_mem(dev, 0, &fbpr_a, &fbpr_sz);
-		if (ret) {
-			dev_err(dev, "qbman_init_private_mem() failed 0x%x\n",
-				ret);
-			return -ENODEV;
-		}
+	ret = qbman_init_private_mem(dev, 0, "fsl,bman-fbpr", &fbpr_a, &fbpr_sz);
+	if (ret) {
+		dev_err(dev, "qbman_init_private_mem() failed 0x%x\n",
+			ret);
+		return -ENODEV;
 	}
 
 	dev_dbg(dev, "Allocated FBPR 0x%llx 0x%zx\n", fbpr_a, fbpr_sz);
drivers/soc/fsl/qbman/dpaa_sys.c +8 -4
index 33751450047e..e1d7b79cc450 100644
@@ -34,8 +34,8 @@
 /*
  * Initialize a devices private memory region
  */
-int qbman_init_private_mem(struct device *dev, int idx, dma_addr_t *addr,
-				size_t *size)
+int qbman_init_private_mem(struct device *dev, int idx, const char *compat,
+			   dma_addr_t *addr, size_t *size)
 {
 	struct device_node *mem_node;
 	struct reserved_mem *rmem;
@@ -44,8 +44,12 @@ int qbman_init_private_mem(struct device *dev, int idx, dma_addr_t *addr,
 
 	mem_node = of_parse_phandle(dev->of_node, "memory-region", idx);
 	if (!mem_node) {
-		dev_err(dev, "No memory-region found for index %d\n", idx);
-		return -ENODEV;
+		mem_node = of_find_compatible_node(NULL, NULL, compat);
+		if (!mem_node) {
+			dev_err(dev, "No memory-region found for index %d or compatible '%s'\n",
+				idx, compat);
+			return -ENODEV;
+		}
 	}
 
 	rmem = of_reserved_mem_lookup(mem_node);
drivers/soc/fsl/qbman/dpaa_sys.h +2 -2
index ae8afa552b1e..16485bde9636 100644
@@ -101,8 +101,8 @@ static inline u8 dpaa_cyc_diff(u8 ringsize, u8 first, u8 last)
 #define DPAA_GENALLOC_OFF	0x80000000
 
 /* Initialize the devices private memory region */
-int qbman_init_private_mem(struct device *dev, int idx, dma_addr_t *addr,
-				size_t *size);
+int qbman_init_private_mem(struct device *dev, int idx, const char *compat,
+			   dma_addr_t *addr, size_t *size);
 
 /* memremap() attributes for different platforms */
 #ifdef CONFIG_PPC
drivers/soc/fsl/qbman/qman_ccsr.c +23 -50

90 lines not on this page · raw message

Signature · 1 line
2.43.0
#1 lore raw
Quoted 6 lines · Rob Herring

There is no reason to use RESERVEDMEM_OF_DECLARE() as the initialization hook just saves off the base address and size. Use of RESERVEDMEM_OF_DECLARE() is reserved for non-driver code and initialization which must be done early. For qbman, retrieving the address and size can be done in probe just as easily.

Quoted 8 lines
---
 drivers/soc/fsl/qbman/bman_ccsr.c | 27 +++---------
 drivers/soc/fsl/qbman/dpaa_sys.c  | 12 +++--
 drivers/soc/fsl/qbman/dpaa_sys.h  |  4 +-
 drivers/soc/fsl/qbman/qman_ccsr.c | 73 ++++++++++---------------------
 4 files changed, 38 insertions(+), 78 deletions(-)

No one is going to pick this up? I applied to the DT tree.

Rob

#2 lore raw
Quoted 17 lines · Rob Herring
Quoted 6 lines · Rob Herring

There is no reason to use RESERVEDMEM_OF_DECLARE() as the initialization hook just saves off the base address and size. Use of RESERVEDMEM_OF_DECLARE() is reserved for non-driver code and initialization which must be done early. For qbman, retrieving the address and size can be done in probe just as easily.

Quoted 8 lines
---
 drivers/soc/fsl/qbman/bman_ccsr.c | 27 +++---------
 drivers/soc/fsl/qbman/dpaa_sys.c  | 12 +++--
 drivers/soc/fsl/qbman/dpaa_sys.h  |  4 +-
 drivers/soc/fsl/qbman/qman_ccsr.c | 73 ++++++++++---------------------
 4 files changed, 38 insertions(+), 78 deletions(-)
Quoted 1 line

No one is going to pick this up? I applied to the DT tree.

As discussed in [1], this driver is currently orphaned.

--Sean

[1] https://lore.kernel.org/all/20240219153016.ntltc76bphwrv6hn@skbuf/

[Embedded World 2024, SECO SpA]<https://www.messe-ticket.de/Nuernberg/embeddedworld2024/Register/ew24517689>