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 61052a92d670aba70974ee3b3c1e2abd05542f2c..86c3de4e455d9cf86fe69d34aee400b9c7c59cd9 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 b7b0a13ca12ec456ce6045346c9094ba2fedf161..67d47199aa4c8d1dd6060f7ff2a663aa0c038eba 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 43e8691a93a65a9cfe8245849654a6313d788809..dfcb6fd698122d4f38174f4d75dff465c57043f5 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 9414f5f692618e637261d9682e98eaab464cd146..aa8cdff84082995a7e6c820ab52d9c4c345e72c6 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 04b604fa2c9dc85035a87139d13e17752f2e0281..1e6fc6c66839c844aaaf1c808633ba020b085fa2 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 e91a5f7b24bfb2f293283ca784212cbde10e4363..5249c553987112e07a61e925b18ce2fe73641c24 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 925f0c2555446021ff24fca47f685273e2764acf..980b38d2a1ca7f54796f69c8daad47ba8d4a698b 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 1f87f0cb28ad74cb13b5b8089b9f2e62e7ca3131..bd1d89ec8393493cafc838318f238d43d18100f6 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 54fc9b5b396e017742b80ee58815c28d3ef88021..2527bb8b1c850e01c76d13a1d5f9b0c5e15ded6e 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 ee5d561bfd195f620f68d6bb93fe9250b59224f5..a0e709a11e90736ca313fa7f2020edcbb4ac6ea8 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 1b54d1880f93aa51723a86ebefad36d4abc3f6e1..dd3e511fc91d65f378fc2edd4e741cb343f50638 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 bdb5adb2a46a80ff71807a3c6195d0aadb978762..39bd40e68be106580e5269bb1d721eab70edafce 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 6106c1f9ec83429b063c2d29b83e07dc82b9ca02..a357b00d28785eb07490d2126ddbbfa7cfbca31f 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 dbb853735fbee2c3a82fdff9c862b5c5bed3b1e8..b3dad77aa28c21b2ae9494549e96366dbc869a3e 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 ce26d2bd155c0b66b923e2844239e7839018609e..7e4cd6c4b49b4d9dbe59b2096a337bd356f6b488 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 e586c18cf032c06b2727abe71c2a66dda4adb651..7e4e6d36b863c9d4f9c805a76ded6687da1a8ce6 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 af3c755f96311a66657152313a745805daec462b..ee6ad9c9e593a532627446c57f2cc6dff2183ab0 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 6fd97e2502f217eef6c9a1f075f019e309b684c5..7ead73e6b7fd9401d5d8b0bd7b87238e12310450 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 ba73978e259176729ec50260f6f2453a70e583c8..84600b12014bea12c17e885192a797d4ce74f792 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 2a5f256184f2c195ed0088a211f31ca59540ab8c..12512f65782c76ddf7d5ed31e468a7095c1b794b 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 faea6d4c995d3376eed1a11cd59beacca1b0e397..e3160cf1bd76104ea45b92b9a37cae53c1d8879a 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 b1534981f8cc4488e5df0b555b516253145ba162..c934d5f25a6792f6582911f2cf9d58ac08f78808 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 5dfc6171eb542c33a0e65ba4f3aeda4fba6850ab..c972f1e9af5f8fa9d4a6fcd0ae2b3e72f8b687b1 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 66e02d5689d09ddc052b3d184c008a5b384ac50e..31b43ee88dd7ed7857b200cae5ab9ee345bb5ff7 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 cead3c62f5a144bce78913037441faf4cc4ad839..1be777bd3bb8b7d1bd1144ab9e833c9a6efdc291 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 f689015b4ae7e96ebaf128802a821bdfc142bb7d..7e486a68ffc9c067595d161af185d2c857cebb8a 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