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 <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
		
							parent
							
								
									d7a184d4a7
								
							
						
					
					
						commit
						4687919684
					
				|  | @ -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 | ||||
|  |  | |||
|  | @ -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 | ||||
|  |  | |||
|  | @ -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 | ||||
|  |  | |||
|  | @ -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 | ||||
|  |  | |||
|  | @ -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 */ | ||||
|  |  | |||
|  | @ -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 | ||||
|  |  | |||
|  | @ -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 | ||||
|  |  | |||
|  | @ -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), | ||||
| }; | ||||
|  |  | |||
|  | @ -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), | ||||
| }; | ||||
|  |  | |||
|  | @ -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 | ||||
|  |  | |||
|  | @ -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, | ||||
| }; | ||||
|  |  | |||
|  | @ -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, | ||||
| }; | ||||
|  |  | |||
|  | @ -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, | ||||
| }; | ||||
|  |  | |||
|  | @ -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), | ||||
| }; | ||||
|  |  | |||
|  | @ -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 | ||||
|  |  | |||
|  | @ -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 | ||||
| 
 | ||||
|  |  | |||
|  | @ -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 */ | ||||
|  |  | |||
|  | @ -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, | ||||
| }; | ||||
|  |  | |||
|  | @ -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), | ||||
| }; | ||||
| 
 | ||||
|  |  | |||
|  | @ -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), | ||||
| }; | ||||
| 
 | ||||
|  |  | |||
|  | @ -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 | ||||
| 
 | ||||
|  |  | |||
|  | @ -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), | ||||
| }; | ||||
| 
 | ||||
|  |  | |||
|  | @ -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, | ||||
| }; | ||||
| 
 | ||||
|  |  | |||
|  | @ -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 | ||||
|  |  | |||
|  | @ -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 | ||||
|  |  | |||
|  | @ -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 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue