From: Bin Meng Date: Wed, 24 Oct 2018 13:36:36 +0000 (-0700) Subject: serial: Remove DM_FLAG_PRE_RELOC flag in various drivers X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=4687919684e0e4390b9fc20d1809ecaa9dc3cb81;p=u-boot.git serial: 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 --- diff --git a/drivers/serial/altera_jtag_uart.c b/drivers/serial/altera_jtag_uart.c index 61052a92d6..86c3de4e45 100644 --- a/drivers/serial/altera_jtag_uart.c +++ b/drivers/serial/altera_jtag_uart.c @@ -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 diff --git a/drivers/serial/altera_uart.c b/drivers/serial/altera_uart.c index b7b0a13ca1..67d47199aa 100644 --- a/drivers/serial/altera_uart.c +++ b/drivers/serial/altera_uart.c @@ -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 diff --git a/drivers/serial/arm_dcc.c b/drivers/serial/arm_dcc.c index 43e8691a93..dfcb6fd698 100644 --- a/drivers/serial/arm_dcc.c +++ b/drivers/serial/arm_dcc.c @@ -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 diff --git a/drivers/serial/atmel_usart.c b/drivers/serial/atmel_usart.c index 9414f5f692..aa8cdff840 100644 --- a/drivers/serial/atmel_usart.c +++ b/drivers/serial/atmel_usart.c @@ -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 diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c index 04b604fa2c..1e6fc6c668 100644 --- a/drivers/serial/ns16550.c +++ b/drivers/serial/ns16550.c @@ -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 */ diff --git a/drivers/serial/serial_ar933x.c b/drivers/serial/serial_ar933x.c index e91a5f7b24..5249c55398 100644 --- a/drivers/serial/serial_ar933x.c +++ b/drivers/serial/serial_ar933x.c @@ -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 diff --git a/drivers/serial/serial_arc.c b/drivers/serial/serial_arc.c index 925f0c2555..980b38d2a1 100644 --- a/drivers/serial/serial_arc.c +++ b/drivers/serial/serial_arc.c @@ -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 diff --git a/drivers/serial/serial_bcm283x_mu.c b/drivers/serial/serial_bcm283x_mu.c index 1f87f0cb28..bd1d89ec83 100644 --- a/drivers/serial/serial_bcm283x_mu.c +++ b/drivers/serial/serial_bcm283x_mu.c @@ -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), }; diff --git a/drivers/serial/serial_bcm283x_pl011.c b/drivers/serial/serial_bcm283x_pl011.c index 54fc9b5b39..2527bb8b1c 100644 --- a/drivers/serial/serial_bcm283x_pl011.c +++ b/drivers/serial/serial_bcm283x_pl011.c @@ -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), }; diff --git a/drivers/serial/serial_bcm6345.c b/drivers/serial/serial_bcm6345.c index ee5d561bfd..a0e709a11e 100644 --- a/drivers/serial/serial_bcm6345.c +++ b/drivers/serial/serial_bcm6345.c @@ -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 diff --git a/drivers/serial/serial_efi.c b/drivers/serial/serial_efi.c index 1b54d1880f..dd3e511fc9 100644 --- a/drivers/serial/serial_efi.c +++ b/drivers/serial/serial_efi.c @@ -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, }; diff --git a/drivers/serial/serial_intel_mid.c b/drivers/serial/serial_intel_mid.c index bdb5adb2a4..39bd40e68b 100644 --- a/drivers/serial/serial_intel_mid.c +++ b/drivers/serial/serial_intel_mid.c @@ -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, }; diff --git a/drivers/serial/serial_lpuart.c b/drivers/serial/serial_lpuart.c index 6106c1f9ec..a357b00d28 100644 --- a/drivers/serial/serial_lpuart.c +++ b/drivers/serial/serial_lpuart.c @@ -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, }; diff --git a/drivers/serial/serial_meson.c b/drivers/serial/serial_meson.c index dbb853735f..b3dad77aa2 100644 --- a/drivers/serial/serial_meson.c +++ b/drivers/serial/serial_meson.c @@ -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), }; diff --git a/drivers/serial/serial_mvebu_a3700.c b/drivers/serial/serial_mvebu_a3700.c index ce26d2bd15..7e4cd6c4b4 100644 --- a/drivers/serial/serial_mvebu_a3700.c +++ b/drivers/serial/serial_mvebu_a3700.c @@ -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 diff --git a/drivers/serial/serial_mxc.c b/drivers/serial/serial_mxc.c index e586c18cf0..7e4e6d36b8 100644 --- a/drivers/serial/serial_mxc.c +++ b/drivers/serial/serial_mxc.c @@ -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 diff --git a/drivers/serial/serial_omap.c b/drivers/serial/serial_omap.c index af3c755f96..ee6ad9c9e5 100644 --- a/drivers/serial/serial_omap.c +++ b/drivers/serial/serial_omap.c @@ -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 */ diff --git a/drivers/serial/serial_owl.c b/drivers/serial/serial_owl.c index 6fd97e2502..7ead73e6b7 100644 --- a/drivers/serial/serial_owl.c +++ b/drivers/serial/serial_owl.c @@ -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, }; diff --git a/drivers/serial/serial_pic32.c b/drivers/serial/serial_pic32.c index ba73978e25..84600b1201 100644 --- a/drivers/serial/serial_pic32.c +++ b/drivers/serial/serial_pic32.c @@ -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), }; diff --git a/drivers/serial/serial_pl01x.c b/drivers/serial/serial_pl01x.c index 2a5f256184..12512f6578 100644 --- a/drivers/serial/serial_pl01x.c +++ b/drivers/serial/serial_pl01x.c @@ -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), }; diff --git a/drivers/serial/serial_s5p.c b/drivers/serial/serial_s5p.c index faea6d4c99..e3160cf1bd 100644 --- a/drivers/serial/serial_s5p.c +++ b/drivers/serial/serial_s5p.c @@ -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 diff --git a/drivers/serial/serial_sh.c b/drivers/serial/serial_sh.c index b1534981f8..c934d5f25a 100644 --- a/drivers/serial/serial_sh.c +++ b/drivers/serial/serial_sh.c @@ -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), }; diff --git a/drivers/serial/serial_sti_asc.c b/drivers/serial/serial_sti_asc.c index 5dfc6171eb..c972f1e9af 100644 --- a/drivers/serial/serial_sti_asc.c +++ b/drivers/serial/serial_sti_asc.c @@ -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, }; diff --git a/drivers/serial/serial_stm32.c b/drivers/serial/serial_stm32.c index 66e02d5689..31b43ee88d 100644 --- a/drivers/serial/serial_stm32.c +++ b/drivers/serial/serial_stm32.c @@ -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 diff --git a/drivers/serial/serial_xuartlite.c b/drivers/serial/serial_xuartlite.c index cead3c62f5..1be777bd3b 100644 --- a/drivers/serial/serial_xuartlite.c +++ b/drivers/serial/serial_xuartlite.c @@ -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 diff --git a/drivers/serial/serial_zynq.c b/drivers/serial/serial_zynq.c index f689015b4a..7e486a68ff 100644 --- a/drivers/serial/serial_zynq.c +++ b/drivers/serial/serial_zynq.c @@ -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