From 73a9619b85497d19b74e6a023aa9ce0e88a1143d Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 31 May 2021 09:12:39 +0200 Subject: ARM: report probe error at arm_add_mem_device() callsites on failure 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 Link: https://lore.barebox.org/20210531071239.30653-7-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer --- 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 0aece5345f..8f70b4ada2 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 135a16d111..f23dbf51d7 100644 --- a/arch/arm/mach-imx/esdctl.c +++ b/arch/arm/mach-imx/esdctl.c @@ -42,7 +42,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; @@ -192,9 +192,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); @@ -202,16 +204,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; } /* @@ -234,35 +236,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)); } @@ -291,9 +293,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)); } @@ -313,9 +315,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)); } @@ -477,9 +479,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)); } @@ -519,9 +521,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)); } @@ -544,9 +546,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 80510cf5b4..0f13a9deb6 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 646fe4401a..43486c57c5 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[] = { -- cgit v1.2.3