mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: mol@pengutronix.de, Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 6/6] ARM: report probe error at arm_add_mem_device() callsites on failure
Date: Mon, 31 May 2021 09:12:39 +0200	[thread overview]
Message-ID: <20210531071239.30653-7-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20210531071239.30653-1-a.fatoum@pengutronix.de>

Failure to add one memory bank shouldn't prevent the driver from trying
to add other memory banks, but the user should be informed as this
points at a misconfiguration. Have the probe functions eventually fail
with -EBUSY in such a case.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/arm/mach-at91/ddramc.c      |  4 +--
 arch/arm/mach-imx/esdctl.c       | 56 ++++++++++++++++----------------
 arch/arm/mach-omap/am33xx_scrm.c |  4 +--
 arch/arm/mach-stm32mp/ddrctrl.c  |  4 +--
 4 files changed, 31 insertions(+), 37 deletions(-)

diff --git a/arch/arm/mach-at91/ddramc.c b/arch/arm/mach-at91/ddramc.c
index 0aece5345f72..8f70b4ada2a1 100644
--- a/arch/arm/mach-at91/ddramc.c
+++ b/arch/arm/mach-at91/ddramc.c
@@ -44,9 +44,7 @@ static int sama5_ddr_probe(struct device_d *dev)
 		return PTR_ERR(iores);
 	base = IOMEM(iores->start);
 
-	arm_add_mem_device("ram0", SAMA5_DDRCS, sama5_ramsize(base));
-
-	return 0;
+	return arm_add_mem_device("ram0", SAMA5_DDRCS, sama5_ramsize(base));
 }
 
 static struct of_device_id sama5_ddr_dt_ids[] = {
diff --git a/arch/arm/mach-imx/esdctl.c b/arch/arm/mach-imx/esdctl.c
index f297cd35d540..5355f55c6f33 100644
--- a/arch/arm/mach-imx/esdctl.c
+++ b/arch/arm/mach-imx/esdctl.c
@@ -32,7 +32,7 @@
 struct imx_esdctl_data {
 	unsigned long base0;
 	unsigned long base1;
-	void (*add_mem)(void *esdctlbase, struct imx_esdctl_data *);
+	int (*add_mem)(void *esdctlbase, struct imx_esdctl_data *);
 };
 
 static int imx_esdctl_disabled;
@@ -182,9 +182,11 @@ static inline u64 __imx6_mmdc_sdram_size(void __iomem *mmdcbase, int cs)
 	return memory_sdram_size(cols, rows, banks, width);
 }
 
-static void add_mem(unsigned long base0, unsigned long size0,
+static int add_mem(unsigned long base0, unsigned long size0,
 		unsigned long base1, unsigned long size1)
 {
+	int ret0 = 0, ret1 = 0;
+
 	debug("%s: cs0 base: 0x%08lx cs0 size: 0x%08lx\n", __func__, base0, size0);
 	debug("%s: cs1 base: 0x%08lx cs1 size: 0x%08lx\n", __func__, base1, size1);
 
@@ -192,16 +194,16 @@ static void add_mem(unsigned long base0, unsigned long size0,
 		/*
 		 * concatenate both chip selects to a single bank
 		 */
-		arm_add_mem_device("ram0", base0, size0 + size1);
-
-		return;
+		return arm_add_mem_device("ram0", base0, size0 + size1);
 	}
 
 	if (size0)
-		arm_add_mem_device("ram0", base0, size0);
+		ret0 = arm_add_mem_device("ram0", base0, size0);
 
 	if (size1)
-		arm_add_mem_device(size0 ? "ram1" : "ram0", base1, size1);
+		ret1 = arm_add_mem_device(size0 ? "ram1" : "ram0", base1, size1);
+
+	return ret0 ? ret0 : ret1;
 }
 
 /*
@@ -224,35 +226,35 @@ static inline void imx_esdctl_v2_disable_default(void __iomem *esdctlbase)
 	}
 }
 
-static void imx_esdctl_v1_add_mem(void *esdctlbase, struct imx_esdctl_data *data)
+static int imx_esdctl_v1_add_mem(void *esdctlbase, struct imx_esdctl_data *data)
 {
-	add_mem(data->base0, imx_v1_sdram_size(esdctlbase, 0),
+	return add_mem(data->base0, imx_v1_sdram_size(esdctlbase, 0),
 			data->base1, imx_v1_sdram_size(esdctlbase, 1));
 }
 
-static void imx_esdctl_v2_add_mem(void *esdctlbase, struct imx_esdctl_data *data)
+static int imx_esdctl_v2_add_mem(void *esdctlbase, struct imx_esdctl_data *data)
 {
-	add_mem(data->base0, imx_v2_sdram_size(esdctlbase, 0),
+	return add_mem(data->base0, imx_v2_sdram_size(esdctlbase, 0),
 			data->base1, imx_v2_sdram_size(esdctlbase, 1));
 }
 
-static void imx_esdctl_v2_bug_add_mem(void *esdctlbase, struct imx_esdctl_data *data)
+static int imx_esdctl_v2_bug_add_mem(void *esdctlbase, struct imx_esdctl_data *data)
 {
 	imx_esdctl_v2_disable_default(esdctlbase);
 
-	add_mem(data->base0, imx_v2_sdram_size(esdctlbase, 0),
+	return add_mem(data->base0, imx_v2_sdram_size(esdctlbase, 0),
 			data->base1, imx_v2_sdram_size(esdctlbase, 1));
 }
 
-static void imx_esdctl_v3_add_mem(void *esdctlbase, struct imx_esdctl_data *data)
+static int imx_esdctl_v3_add_mem(void *esdctlbase, struct imx_esdctl_data *data)
 {
-	add_mem(data->base0, imx_v3_sdram_size(esdctlbase, 0),
+	return add_mem(data->base0, imx_v3_sdram_size(esdctlbase, 0),
 			data->base1, imx_v3_sdram_size(esdctlbase, 1));
 }
 
-static void imx_esdctl_v4_add_mem(void *esdctlbase, struct imx_esdctl_data *data)
+static int imx_esdctl_v4_add_mem(void *esdctlbase, struct imx_esdctl_data *data)
 {
-	add_mem(data->base0, imx_v4_sdram_size(esdctlbase, 0),
+	return add_mem(data->base0, imx_v4_sdram_size(esdctlbase, 0),
 			data->base1, imx_v4_sdram_size(esdctlbase, 1));
 }
 
@@ -281,9 +283,9 @@ static inline resource_size_t imx6_mmdc_sdram_size(void __iomem *mmdcbase)
 	return size;
 }
 
-static void imx6_mmdc_add_mem(void *mmdcbase, struct imx_esdctl_data *data)
+static int imx6_mmdc_add_mem(void *mmdcbase, struct imx_esdctl_data *data)
 {
-	arm_add_mem_device("ram0", data->base0,
+	return arm_add_mem_device("ram0", data->base0,
 			   imx6_mmdc_sdram_size(mmdcbase));
 }
 
@@ -303,9 +305,9 @@ static inline resource_size_t vf610_ddrmc_sdram_size(void __iomem *ddrmc)
 	return memory_sdram_size(cols, rows, banks, width);
 }
 
-static void vf610_ddrmc_add_mem(void *mmdcbase, struct imx_esdctl_data *data)
+static int vf610_ddrmc_add_mem(void *mmdcbase, struct imx_esdctl_data *data)
 {
-	arm_add_mem_device("ram0", data->base0,
+	return arm_add_mem_device("ram0", data->base0,
 			   vf610_ddrmc_sdram_size(mmdcbase));
 }
 
@@ -467,9 +469,9 @@ static resource_size_t imx8m_ddrc_sdram_size(void __iomem *ddrc)
 				   reduced_adress_space);
 }
 
-static void imx8m_ddrc_add_mem(void *mmdcbase, struct imx_esdctl_data *data)
+static int imx8m_ddrc_add_mem(void *mmdcbase, struct imx_esdctl_data *data)
 {
-	arm_add_mem_device("ram0", data->base0,
+	return arm_add_mem_device("ram0", data->base0,
 			   imx8m_ddrc_sdram_size(mmdcbase));
 }
 
@@ -509,9 +511,9 @@ static resource_size_t imx7d_ddrc_sdram_size(void __iomem *ddrc)
 				   reduced_adress_space);
 }
 
-static void imx7d_ddrc_add_mem(void *mmdcbase, struct imx_esdctl_data *data)
+static int imx7d_ddrc_add_mem(void *mmdcbase, struct imx_esdctl_data *data)
 {
-	arm_add_mem_device("ram0", data->base0,
+	return arm_add_mem_device("ram0", data->base0,
 			   imx7d_ddrc_sdram_size(mmdcbase));
 }
 
@@ -534,9 +536,7 @@ static int imx_esdctl_probe(struct device_d *dev)
 	if (imx_esdctl_disabled)
 		return 0;
 
-	data->add_mem(base, data);
-
-	return 0;
+	return data->add_mem(base, data);
 }
 
 static __maybe_unused struct imx_esdctl_data imx1_data = {
diff --git a/arch/arm/mach-omap/am33xx_scrm.c b/arch/arm/mach-omap/am33xx_scrm.c
index 80510cf5b423..0f13a9deb6af 100644
--- a/arch/arm/mach-omap/am33xx_scrm.c
+++ b/arch/arm/mach-omap/am33xx_scrm.c
@@ -24,9 +24,7 @@
 
 static int am33xx_scrm_probe(struct device_d *dev)
 {
-	arm_add_mem_device("ram0", 0x80000000, am335x_sdram_size());
-
-	return 0;
+	return arm_add_mem_device("ram0", 0x80000000, am335x_sdram_size());
 }
 
 static __maybe_unused struct of_device_id am33xx_scrm_dt_ids[] = {
diff --git a/arch/arm/mach-stm32mp/ddrctrl.c b/arch/arm/mach-stm32mp/ddrctrl.c
index 646fe4401acf..43486c57c56a 100644
--- a/arch/arm/mach-stm32mp/ddrctrl.c
+++ b/arch/arm/mach-stm32mp/ddrctrl.c
@@ -132,9 +132,7 @@ static int stm32mp1_ddr_probe(struct device_d *dev)
 		return PTR_ERR(iores);
 	base = IOMEM(iores->start);
 
-	arm_add_mem_device("ram0", STM32_DDR_BASE, ddrctrl_ramsize(base));
-
-	return 0;
+	return arm_add_mem_device("ram0", STM32_DDR_BASE, ddrctrl_ramsize(base));
 }
 
 static __maybe_unused struct of_device_id stm32mp1_ddr_dt_ids[] = {
-- 
2.29.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


  parent reply	other threads:[~2021-05-31  7:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-31  7:12 [PATCH 0/6] memory: fuse overlapping memory banks Ahmad Fatoum
2021-05-31  7:12 ` [PATCH 1/6] common: memory: allocate all memory devices at once Ahmad Fatoum
2021-05-31  7:12 ` [PATCH 2/6] memory: fuse overlapping memory banks Ahmad Fatoum
2021-05-31  7:12 ` [PATCH 3/6] of: propagate errors inside barebox_register_{of, fdt} into initcalls Ahmad Fatoum
2021-05-31  7:12 ` [PATCH 4/6] of: warn about of_add_memory_bank errors Ahmad Fatoum
2021-05-31  7:12 ` [PATCH 5/6] ARM: <asm/memory.h>: propagate error codes from arm_add_mem_device() Ahmad Fatoum
2021-05-31  7:12 ` Ahmad Fatoum [this message]
2021-06-02  6:38 ` [PATCH 0/6] memory: fuse overlapping memory banks Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210531071239.30653-7-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=mol@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox