From ad0e8048437e776e687a977a84494852a64f4693 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Wed, 24 Oct 2018 06:36:33 -0700 Subject: [PATCH] pinctrl: Remove DM_FLAG_PRE_RELOC flag in various drivers When a driver declares DM_FLAG_PRE_RELOC flag, it wishes to be bound before relocation. However due to a bug in the DM core, the flag only takes effect when devices are statically declared via U_BOOT_DEVICE(). This bug has been fixed recently by commit "dm: core: Respect drivers with the DM_FLAG_PRE_RELOC flag in lists_bind_fdt()", but with the fix, it has a side effect that all existing drivers that declared DM_FLAG_PRE_RELOC flag will be bound before relocation now. This may expose potential boot failure on some boards due to insufficient memory during the pre-relocation stage. To mitigate this potential impact, the following changes are implemented: - Remove DM_FLAG_PRE_RELOC flag in the driver, if the driver only supports configuration from device tree (OF_CONTROL) - Keep DM_FLAG_PRE_RELOC flag in the driver only if the device is statically declared via U_BOOT_DEVICE() - Surround DM_FLAG_PRE_RELOC flag with OF_CONTROL check, for drivers that support both statically declared devices and configuration from device tree Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- drivers/pinctrl/broadcom/pinctrl-bcm283x.c | 2 ++ drivers/pinctrl/exynos/pinctrl-exynos7420.c | 1 - drivers/pinctrl/nxp/pinctrl-imx5.c | 2 ++ drivers/pinctrl/nxp/pinctrl-imx6.c | 2 ++ drivers/pinctrl/nxp/pinctrl-imx7.c | 2 ++ drivers/pinctrl/nxp/pinctrl-imx7ulp.c | 2 ++ drivers/pinctrl/pinctrl-single.c | 1 - drivers/pinctrl/uniphier/pinctrl-uniphier-pro4.c | 2 ++ drivers/pinctrl/uniphier/pinctrl-uniphier-pro5.c | 2 ++ 9 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/pinctrl/broadcom/pinctrl-bcm283x.c b/drivers/pinctrl/broadcom/pinctrl-bcm283x.c index 891b4c25fd..3be080d29e 100644 --- a/drivers/pinctrl/broadcom/pinctrl-bcm283x.c +++ b/drivers/pinctrl/broadcom/pinctrl-bcm283x.c @@ -148,5 +148,7 @@ U_BOOT_DRIVER(pinctrl_bcm283x) = { .priv_auto_alloc_size = sizeof(struct bcm283x_pinctrl_priv), .ops = &bcm283x_pinctrl_ops, .probe = bcm283x_pinctl_probe, +#if !CONFIG_IS_ENABLED(OF_CONTROL) .flags = DM_FLAG_PRE_RELOC, +#endif }; diff --git a/drivers/pinctrl/exynos/pinctrl-exynos7420.c b/drivers/pinctrl/exynos/pinctrl-exynos7420.c index cb5975b252..ff6d6c4143 100644 --- a/drivers/pinctrl/exynos/pinctrl-exynos7420.c +++ b/drivers/pinctrl/exynos/pinctrl-exynos7420.c @@ -113,5 +113,4 @@ U_BOOT_DRIVER(pinctrl_exynos7420) = { .priv_auto_alloc_size = sizeof(struct exynos_pinctrl_priv), .ops = &exynos7420_pinctrl_ops, .probe = exynos_pinctrl_probe, - .flags = DM_FLAG_PRE_RELOC }; diff --git a/drivers/pinctrl/nxp/pinctrl-imx5.c b/drivers/pinctrl/nxp/pinctrl-imx5.c index 5d17380919..4e831b6f39 100644 --- a/drivers/pinctrl/nxp/pinctrl-imx5.c +++ b/drivers/pinctrl/nxp/pinctrl-imx5.c @@ -40,5 +40,7 @@ U_BOOT_DRIVER(imx5_pinctrl) = { .remove = imx_pinctrl_remove, .priv_auto_alloc_size = sizeof(struct imx_pinctrl_priv), .ops = &imx_pinctrl_ops, +#if !CONFIG_IS_ENABLED(OF_CONTROL) .flags = DM_FLAG_PRE_RELOC, +#endif }; diff --git a/drivers/pinctrl/nxp/pinctrl-imx6.c b/drivers/pinctrl/nxp/pinctrl-imx6.c index e63ecbdee6..d7c95bb738 100644 --- a/drivers/pinctrl/nxp/pinctrl-imx6.c +++ b/drivers/pinctrl/nxp/pinctrl-imx6.c @@ -49,5 +49,7 @@ U_BOOT_DRIVER(imx6_pinctrl) = { .remove = imx_pinctrl_remove, .priv_auto_alloc_size = sizeof(struct imx_pinctrl_priv), .ops = &imx_pinctrl_ops, +#if !CONFIG_IS_ENABLED(OF_CONTROL) .flags = DM_FLAG_PRE_RELOC, +#endif }; diff --git a/drivers/pinctrl/nxp/pinctrl-imx7.c b/drivers/pinctrl/nxp/pinctrl-imx7.c index 769d428dda..8776fd9650 100644 --- a/drivers/pinctrl/nxp/pinctrl-imx7.c +++ b/drivers/pinctrl/nxp/pinctrl-imx7.c @@ -37,5 +37,7 @@ U_BOOT_DRIVER(imx7_pinctrl) = { .remove = imx_pinctrl_remove, .priv_auto_alloc_size = sizeof(struct imx_pinctrl_priv), .ops = &imx_pinctrl_ops, +#if !CONFIG_IS_ENABLED(OF_CONTROL) .flags = DM_FLAG_PRE_RELOC, +#endif }; diff --git a/drivers/pinctrl/nxp/pinctrl-imx7ulp.c b/drivers/pinctrl/nxp/pinctrl-imx7ulp.c index 598bbfaf35..d778f82aac 100644 --- a/drivers/pinctrl/nxp/pinctrl-imx7ulp.c +++ b/drivers/pinctrl/nxp/pinctrl-imx7ulp.c @@ -41,5 +41,7 @@ U_BOOT_DRIVER(imx7ulp_pinctrl) = { .remove = imx_pinctrl_remove, .priv_auto_alloc_size = sizeof(struct imx_pinctrl_priv), .ops = &imx_pinctrl_ops, +#if !CONFIG_IS_ENABLED(OF_CONTROL) .flags = DM_FLAG_PRE_RELOC, +#endif }; diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c index d80c6eda70..9dec88c1aa 100644 --- a/drivers/pinctrl/pinctrl-single.c +++ b/drivers/pinctrl/pinctrl-single.c @@ -136,7 +136,6 @@ U_BOOT_DRIVER(single_pinctrl) = { .id = UCLASS_PINCTRL, .of_match = single_pinctrl_match, .ops = &single_pinctrl_ops, - .flags = DM_FLAG_PRE_RELOC, .platdata_auto_alloc_size = sizeof(struct single_pdata), .ofdata_to_platdata = single_ofdata_to_platdata, }; diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-pro4.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-pro4.c index a1da90baa4..eb5978a166 100644 --- a/drivers/pinctrl/uniphier/pinctrl-uniphier-pro4.c +++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-pro4.c @@ -171,5 +171,7 @@ U_BOOT_DRIVER(uniphier_pro4_pinctrl) = { .probe = uniphier_pro4_pinctrl_probe, .priv_auto_alloc_size = sizeof(struct uniphier_pinctrl_priv), .ops = &uniphier_pinctrl_ops, +#if !CONFIG_IS_ENABLED(OF_CONTROL) .flags = DM_FLAG_PRE_RELOC, +#endif }; diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-pro5.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-pro5.c index 0ba2052b29..685d8be80c 100644 --- a/drivers/pinctrl/uniphier/pinctrl-uniphier-pro5.c +++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-pro5.c @@ -153,5 +153,7 @@ U_BOOT_DRIVER(uniphier_pro5_pinctrl) = { .probe = uniphier_pro5_pinctrl_probe, .priv_auto_alloc_size = sizeof(struct uniphier_pinctrl_priv), .ops = &uniphier_pinctrl_ops, +#if !CONFIG_IS_ENABLED(OF_CONTROL) .flags = DM_FLAG_PRE_RELOC, +#endif }; -- 2.25.1