kernel: bump 5.10 to 5.10.103
[openwrt/staging/mkresin.git] / target / linux / at91 / patches-5.10 / 223-ARM-at91-pm-do-not-panic-if-ram-controllers-are-not-.patch
1 From 76dbc56ad65350d78d12bd9b36b00c36fb27addf Mon Sep 17 00:00:00 2001
2 From: Claudiu Beznea <claudiu.beznea@microchip.com>
3 Date: Mon, 23 Aug 2021 16:19:12 +0300
4 Subject: [PATCH 223/247] ARM: at91: pm: do not panic if ram controllers are
5 not enabled
6
7 In case PM is enabled but there is no RAM controller information
8 in DT the code will panic. Avoid such scenarios by not initializing
9 platform specific PM code in case RAM controller is not provided
10 via DT.
11
12 Reported-by: Eugen Hristev <eugen.hristev@microchip.com>
13 Fixes: 827de1f123ba0 ("ARM: at91: remove at91_dt_initialize and machine init_early()")
14 Fixes: 892e1f4a3ae58 ("ARM: at91: pm: add sama7g5 ddr phy controller")
15 Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
16 Signed-off-by: Nicolas Ferre <nicolas.ferre@microchip.com>
17 Link: https://lore.kernel.org/r/20210823131915.23857-2-claudiu.beznea@microchip.com
18 ---
19 arch/arm/mach-at91/pm.c | 22 ++++++++++++++++------
20 1 file changed, 16 insertions(+), 6 deletions(-)
21
22 --- a/arch/arm/mach-at91/pm.c
23 +++ b/arch/arm/mach-at91/pm.c
24 @@ -589,7 +589,7 @@ static const struct of_device_id ramc_ph
25 { /* Sentinel. */ },
26 };
27
28 -static __init void at91_dt_ramc(bool phy_mandatory)
29 +static __init int at91_dt_ramc(bool phy_mandatory)
30 {
31 struct device_node *np;
32 const struct of_device_id *of_id;
33 @@ -625,12 +625,18 @@ static __init void at91_dt_ramc(bool phy
34 /* Lookup for DDR PHY node, if any. */
35 for_each_matching_node_and_match(np, ramc_phy_ids, &of_id) {
36 soc_pm.data.ramc_phy = of_iomap(np, 0);
37 - if (!soc_pm.data.ramc_phy)
38 - panic(pr_fmt("unable to map ramc phy cpu registers\n"));
39 + if (!soc_pm.data.ramc_phy) {
40 + pr_err("unable to map ramc phy cpu registers\n");
41 + ret = -ENOMEM;
42 + goto unmap_ramc;
43 + }
44 }
45
46 - if (phy_mandatory && !soc_pm.data.ramc_phy)
47 - panic(pr_fmt("DDR PHY is mandatory!\n"));
48 + if (phy_mandatory && !soc_pm.data.ramc_phy) {
49 + pr_err("DDR PHY is mandatory!\n");
50 + ret = -ENODEV;
51 + goto unmap_ramc;
52 + }
53
54 if (!standby) {
55 pr_warn("ramc no standby function available\n");
56 @@ -1163,13 +1169,17 @@ void __init sama7_pm_init(void)
57 [AT91_PM_BACKUP] = AT91_PM_IOMAP(SFRBU) |
58 AT91_PM_IOMAP(SHDWC),
59 };
60 + int ret;
61
62 if (!IS_ENABLED(CONFIG_SOC_SAMA7))
63 return;
64
65 at91_pm_modes_validate(modes, ARRAY_SIZE(modes));
66
67 - at91_dt_ramc(true);
68 + ret = at91_dt_ramc(true);
69 + if (ret)
70 + return;
71 +
72 at91_pm_modes_init(iomaps, ARRAY_SIZE(iomaps));
73 at91_pm_init(NULL);
74