serial: Remove DM_FLAG_PRE_RELOC flag in various drivers
authorBin Meng <bmeng.cn@gmail.com>
Wed, 24 Oct 2018 13:36:36 +0000 (06:36 -0700)
committerSimon Glass <sjg@chromium.org>
Wed, 14 Nov 2018 17:16:28 +0000 (09:16 -0800)
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 <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
26 files changed:
drivers/serial/altera_jtag_uart.c
drivers/serial/altera_uart.c
drivers/serial/arm_dcc.c
drivers/serial/atmel_usart.c
drivers/serial/ns16550.c
drivers/serial/serial_ar933x.c
drivers/serial/serial_arc.c
drivers/serial/serial_bcm283x_mu.c
drivers/serial/serial_bcm283x_pl011.c
drivers/serial/serial_bcm6345.c
drivers/serial/serial_efi.c
drivers/serial/serial_intel_mid.c
drivers/serial/serial_lpuart.c
drivers/serial/serial_meson.c
drivers/serial/serial_mvebu_a3700.c
drivers/serial/serial_mxc.c
drivers/serial/serial_omap.c
drivers/serial/serial_owl.c
drivers/serial/serial_pic32.c
drivers/serial/serial_pl01x.c
drivers/serial/serial_s5p.c
drivers/serial/serial_sh.c
drivers/serial/serial_sti_asc.c
drivers/serial/serial_stm32.c
drivers/serial/serial_xuartlite.c
drivers/serial/serial_zynq.c

index 61052a9..86c3de4 100644 (file)
@@ -121,7 +121,6 @@ U_BOOT_DRIVER(altera_jtaguart) = {
        .platdata_auto_alloc_size = sizeof(struct altera_jtaguart_platdata),
        .probe = altera_jtaguart_probe,
        .ops    = &altera_jtaguart_ops,
-       .flags = DM_FLAG_PRE_RELOC,
 };
 
 #ifdef CONFIG_DEBUG_UART_ALTERA_JTAGUART
index b7b0a13..67d4719 100644 (file)
@@ -117,7 +117,6 @@ U_BOOT_DRIVER(altera_uart) = {
        .platdata_auto_alloc_size = sizeof(struct altera_uart_platdata),
        .probe = altera_uart_probe,
        .ops    = &altera_uart_ops,
-       .flags = DM_FLAG_PRE_RELOC,
 };
 
 #ifdef CONFIG_DEBUG_UART_ALTERA_UART
index 43e8691..dfcb6fd 100644 (file)
@@ -155,7 +155,6 @@ U_BOOT_DRIVER(serial_dcc) = {
        .id     = UCLASS_SERIAL,
        .of_match = arm_dcc_ids,
        .ops    = &arm_dcc_ops,
-       .flags = DM_FLAG_PRE_RELOC,
 };
 
 #ifdef CONFIG_DEBUG_UART_ARM_DCC
index 9414f5f..aa8cdff 100644 (file)
@@ -294,7 +294,9 @@ U_BOOT_DRIVER(serial_atmel) = {
 #endif
        .probe = atmel_serial_probe,
        .ops    = &atmel_serial_ops,
+#if !CONFIG_IS_ENABLED(OF_CONTROL)
        .flags = DM_FLAG_PRE_RELOC,
+#endif
        .priv_auto_alloc_size   = sizeof(struct atmel_serial_priv),
 };
 #endif
index 04b604f..1e6fc6c 100644 (file)
@@ -487,7 +487,9 @@ U_BOOT_DRIVER(ns16550_serial) = {
        .priv_auto_alloc_size = sizeof(struct NS16550),
        .probe = ns16550_serial_probe,
        .ops    = &ns16550_serial_ops,
+#if !CONFIG_IS_ENABLED(OF_CONTROL)
        .flags  = DM_FLAG_PRE_RELOC,
+#endif
 };
 #endif
 #endif /* SERIAL_PRESENT */
index e91a5f7..5249c55 100644 (file)
@@ -189,7 +189,6 @@ U_BOOT_DRIVER(serial_ar933x) = {
        .priv_auto_alloc_size = sizeof(struct ar933x_serial_priv),
        .probe = ar933x_serial_probe,
        .ops    = &ar933x_serial_ops,
-       .flags = DM_FLAG_PRE_RELOC,
 };
 
 #ifdef CONFIG_DEBUG_UART_AR933X
index 925f0c2..980b38d 100644 (file)
@@ -128,7 +128,6 @@ U_BOOT_DRIVER(serial_arc) = {
        .ofdata_to_platdata = arc_serial_ofdata_to_platdata,
        .probe = arc_serial_probe,
        .ops    = &arc_serial_ops,
-       .flags = DM_FLAG_PRE_RELOC,
 };
 
 #ifdef CONFIG_DEBUG_ARC_SERIAL
index 1f87f0c..bd1d89e 100644 (file)
@@ -199,6 +199,8 @@ U_BOOT_DRIVER(serial_bcm283x_mu) = {
        .platdata_auto_alloc_size = sizeof(struct bcm283x_mu_serial_platdata),
        .probe = bcm283x_mu_serial_probe,
        .ops = &bcm283x_mu_serial_ops,
+#if !CONFIG_IS_ENABLED(OF_CONTROL)
        .flags = DM_FLAG_PRE_RELOC,
+#endif
        .priv_auto_alloc_size = sizeof(struct bcm283x_mu_priv),
 };
index 54fc9b5..2527bb8 100644 (file)
@@ -90,6 +90,8 @@ U_BOOT_DRIVER(bcm283x_pl011_uart) = {
        .platdata_auto_alloc_size = sizeof(struct pl01x_serial_platdata),
        .probe  = pl01x_serial_probe,
        .ops    = &bcm283x_pl011_serial_ops,
+#if !CONFIG_IS_ENABLED(OF_CONTROL)
        .flags  = DM_FLAG_PRE_RELOC,
+#endif
        .priv_auto_alloc_size = sizeof(struct pl01x_priv),
 };
index ee5d561..a0e709a 100644 (file)
@@ -264,7 +264,6 @@ U_BOOT_DRIVER(bcm6345_serial) = {
        .probe = bcm6345_serial_probe,
        .priv_auto_alloc_size = sizeof(struct bcm6345_serial_priv),
        .ops = &bcm6345_serial_ops,
-       .flags = DM_FLAG_PRE_RELOC,
 };
 
 #ifdef CONFIG_DEBUG_UART_BCM6345
index 1b54d18..dd3e511 100644 (file)
@@ -152,5 +152,4 @@ U_BOOT_DRIVER(serial_efi) = {
        .priv_auto_alloc_size = sizeof(struct serial_efi_priv),
        .probe = serial_efi_probe,
        .ops    = &serial_efi_ops,
-       .flags = DM_FLAG_PRE_RELOC,
 };
index bdb5adb..39bd40e 100644 (file)
@@ -64,5 +64,4 @@ U_BOOT_DRIVER(serial_intel_mid) = {
        .priv_auto_alloc_size = sizeof(struct NS16550),
        .probe  = mid_serial_probe,
        .ops    = &ns16550_serial_ops,
-       .flags  = DM_FLAG_PRE_RELOC,
 };
index 6106c1f..a357b00 100644 (file)
@@ -540,5 +540,4 @@ U_BOOT_DRIVER(serial_lpuart) = {
        .platdata_auto_alloc_size = sizeof(struct lpuart_serial_platdata),
        .probe = lpuart_serial_probe,
        .ops    = &lpuart_serial_ops,
-       .flags = DM_FLAG_PRE_RELOC,
 };
index dbb8537..b3dad77 100644 (file)
@@ -132,7 +132,6 @@ U_BOOT_DRIVER(serial_meson) = {
        .of_match       = meson_serial_ids,
        .probe          = meson_serial_probe,
        .ops            = &meson_serial_ops,
-       .flags          = DM_FLAG_PRE_RELOC,
        .ofdata_to_platdata = meson_serial_ofdata_to_platdata,
        .platdata_auto_alloc_size = sizeof(struct meson_serial_platdata),
 };
index ce26d2b..7e4cd6c 100644 (file)
@@ -129,7 +129,6 @@ U_BOOT_DRIVER(serial_mvebu) = {
        .platdata_auto_alloc_size = sizeof(struct mvebu_platdata),
        .probe  = mvebu_serial_probe,
        .ops    = &mvebu_serial_ops,
-       .flags  = DM_FLAG_PRE_RELOC,
 };
 
 #ifdef CONFIG_DEBUG_MVEBU_A3700_UART
index e586c18..7e4e6d3 100644 (file)
@@ -354,7 +354,9 @@ U_BOOT_DRIVER(serial_mxc) = {
 #endif
        .probe = mxc_serial_probe,
        .ops    = &mxc_serial_ops,
+#if !CONFIG_IS_ENABLED(OF_CONTROL)
        .flags = DM_FLAG_PRE_RELOC,
+#endif
 };
 #endif
 
index af3c755..ee6ad9c 100644 (file)
@@ -121,7 +121,9 @@ U_BOOT_DRIVER(omap_serial) = {
        .priv_auto_alloc_size = sizeof(struct NS16550),
        .probe = ns16550_serial_probe,
        .ops    = &ns16550_serial_ops,
+#if !CONFIG_IS_ENABLED(OF_CONTROL)
        .flags  = DM_FLAG_PRE_RELOC,
+#endif
 };
 #endif
 #endif /* DM_SERIAL */
index 6fd97e2..7ead73e 100644 (file)
@@ -132,5 +132,4 @@ U_BOOT_DRIVER(serial_owl) = {
        .priv_auto_alloc_size = sizeof(struct owl_serial_priv),
        .probe = owl_serial_probe,
        .ops = &owl_serial_ops,
-       .flags = DM_FLAG_PRE_RELOC,
 };
index ba73978..84600b1 100644 (file)
@@ -176,7 +176,6 @@ U_BOOT_DRIVER(pic32_serial) = {
        .of_match       = pic32_uart_ids,
        .probe          = pic32_uart_probe,
        .ops            = &pic32_uart_ops,
-       .flags          = DM_FLAG_PRE_RELOC,
        .priv_auto_alloc_size = sizeof(struct pic32_uart_priv),
 };
 
index 2a5f256..12512f6 100644 (file)
@@ -363,7 +363,9 @@ U_BOOT_DRIVER(serial_pl01x) = {
        .platdata_auto_alloc_size = sizeof(struct pl01x_serial_platdata),
        .probe = pl01x_serial_probe,
        .ops    = &pl01x_serial_ops,
+#if !CONFIG_IS_ENABLED(OF_CONTROL)
        .flags = DM_FLAG_PRE_RELOC,
+#endif
        .priv_auto_alloc_size = sizeof(struct pl01x_priv),
 };
 
index faea6d4..e3160cf 100644 (file)
@@ -211,7 +211,6 @@ U_BOOT_DRIVER(serial_s5p) = {
        .platdata_auto_alloc_size = sizeof(struct s5p_serial_platdata),
        .probe = s5p_serial_probe,
        .ops    = &s5p_serial_ops,
-       .flags = DM_FLAG_PRE_RELOC,
 };
 #endif
 
index b153498..c934d5f 100644 (file)
@@ -247,7 +247,9 @@ U_BOOT_DRIVER(serial_sh) = {
        .platdata_auto_alloc_size = sizeof(struct sh_serial_platdata),
        .probe  = sh_serial_probe,
        .ops    = &sh_serial_ops,
+#if !CONFIG_IS_ENABLED(OF_CONTROL)
        .flags  = DM_FLAG_PRE_RELOC,
+#endif
        .priv_auto_alloc_size = sizeof(struct uart_port),
 };
 
index 5dfc617..c972f1e 100644 (file)
@@ -205,6 +205,5 @@ U_BOOT_DRIVER(serial_sti_asc) = {
        .ops = &sti_asc_serial_ops,
        .probe = sti_asc_serial_probe,
        .priv_auto_alloc_size = sizeof(struct sti_asc_serial),
-       .flags = DM_FLAG_PRE_RELOC,
 };
 
index 66e02d5..31b43ee 100644 (file)
@@ -230,7 +230,9 @@ U_BOOT_DRIVER(serial_stm32) = {
        .platdata_auto_alloc_size = sizeof(struct stm32x7_serial_platdata),
        .ops = &stm32_serial_ops,
        .probe = stm32_serial_probe,
+#if !CONFIG_IS_ENABLED(OF_CONTROL)
        .flags = DM_FLAG_PRE_RELOC,
+#endif
 };
 
 #ifdef CONFIG_DEBUG_UART_STM32
index cead3c6..1be777b 100644 (file)
@@ -109,7 +109,6 @@ U_BOOT_DRIVER(serial_uartlite) = {
        .platdata_auto_alloc_size = sizeof(struct uartlite_platdata),
        .probe = uartlite_serial_probe,
        .ops    = &uartlite_serial_ops,
-       .flags = DM_FLAG_PRE_RELOC,
 };
 
 #ifdef CONFIG_DEBUG_UART_UARTLITE
index f689015..7e486a6 100644 (file)
@@ -210,7 +210,6 @@ U_BOOT_DRIVER(serial_zynq) = {
        .platdata_auto_alloc_size = sizeof(struct zynq_uart_platdata),
        .probe = zynq_serial_probe,
        .ops    = &zynq_serial_ops,
-       .flags = DM_FLAG_PRE_RELOC,
 };
 
 #ifdef CONFIG_DEBUG_UART_ZYNQ