Skip to contentSkip to conversation

drivers: serial: probe all serial devices

PATCH New Vabhav Sharma 5 participants 15 messages Oct 15, 2018 – Nov 2, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers: serial: probe all serial devices

Serial subsystem search and probe only one first serial device and unable to use remaining available UART devices

This patch changes the logic to probe all available serial devices using platform data or device tree in DM model in order to use all UART devices

---
 drivers/serial/Kconfig         | 12 ++++++++++++
 drivers/serial/serial-uclass.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+)
drivers/serial/Kconfig +12 -0
index 597db4b..d6451b1 100644
@@ -133,6 +133,18 @@ config SERIAL_SEARCH_ALL
 
 	  If unsure, say N.
 
+config SERIAL_PROBE_ALL
+	bool "Probe all available serial devices"
+	depends on DM_SERIAL
+	help
+	 The serial subsystem only probe for single serial device, but does
+	 not probe for remaining available devices.
+	 With this option set,we make probing for all available devices
+	 mandatory.
+
+	 If probing is not required for all remaining available
+	 devices other than default current console device, say N.
+
 config SPL_DM_SERIAL
 	bool "Enable Driver Model for serial drivers in SPL"
 	depends on DM_SERIAL && SPL_DM
drivers/serial/serial-uclass.c +42 -0

77 lines not on this page · raw message

Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 drivers: serial: probe all serial devices

Quoted 8 lines · Vabhav Sharma

Serial subsystem search and probe only one first serial device and unable to use remaining available UART devices

This patch changes the logic to probe all available serial devices using platform data or device tree in DM model in order to use all UART devices

Quoted 6 lines
---
 drivers/serial/Kconfig         | 12 ++++++++++++
 drivers/serial/serial-uclass.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+)

Looks more and more devices have requirement to be probed during boot. Guess we should handle such in a unified way?

Regards,
Bin

#2 lore raw

PATCH 1/1 drivers: serial: probe all serial devices

Quoted 29 lines

-----Original Message-----
From: Bin Meng <[email protected]>
Sent: Monday, October 15, 2018 5:58 PM
To: Vabhav Sharma <[email protected]>
Cc: U-Boot Mailing List <[email protected]>; u-boot-dm at lists.denx.de; Simon Glass <[email protected]>; dannenberg at ti.com; Masahiro Yamada <[email protected]>; Stefan Roese <[email protected]>
Subject: Re: [PATCH] drivers: serial: probe all serial devices

Quoted 8 lines · Vabhav Sharma

Serial subsystem search and probe only one first serial device and unable to use remaining available UART devices

This patch changes the logic to probe all available serial devices using platform data or device tree in DM model in order to use all UART devices

Quoted 7 lines
---
 drivers/serial/Kconfig         | 12 ++++++++++++
 drivers/serial/serial-uclass.c | 42
++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+)
Quoted 2 lines

Looks more and more devices have requirement to be probed during boot. Guess we should handle such in a unified way?

I understand, For serial devices config is included to make it optional Generic way might make it mandatory which also increase boot time.

Quoted 3 lines

Regards,
Bin

#3 lore raw

PATCH 1/1 drivers: serial: probe all serial devices

In reply to Bin Meng

Hi Bin,

Quoted 16 lines · Bin Meng
Quoted 8 lines · Vabhav Sharma

Serial subsystem search and probe only one first serial device and unable to use remaining available UART devices

This patch changes the logic to probe all available serial devices using platform data or device tree in DM model in order to use all UART devices

Quoted 6 lines
---
 drivers/serial/Kconfig         | 12 ++++++++++++
 drivers/serial/serial-uclass.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+)
Quoted 2 lines

Looks more and more devices have requirement to be probed during boot. Guess we should handle such in a unified way?

How about:

- in dm_init(), after binding, we move on to an auto-probe step
- a uclass flag indicates that all devices in that uclass must be probed (that will be useful for PCI)

- a way to tell DM to probe all devices in a particular uclass (e.g. a call to dm_set_uclass_autoprobe(enum uclass_id, bool)
(that will be useful for this serial case)

Regards,
Simon

#4 lore raw

PATCH 1/1 drivers: serial: probe all serial devices

Quoted 33 lines

-----Original Message-----
From: sjg at google.com <[email protected]> On Behalf Of Simon Glass
Sent: Friday, October 19, 2018 8:56 AM
To: Bin Meng <[email protected]>
Cc: Vabhav Sharma <[email protected]>; U-Boot Mailing List <u- boot at lists.denx.de>; u-boot-dm at lists.denx.de; Andreas Dannenberg <[email protected]>; Masahiro Yamada <[email protected]>; Stefan Roese <[email protected]>
Subject: Re: [PATCH] drivers: serial: probe all serial devices

Hi Bin,

Quoted 1 line · Bin Meng

On Mon, Oct 15, 2018 at 8:15 PM Vabhav Sharma

Quoted 16 lines · <[email protected]> wrote:
Quoted 15 lines

Serial subsystem search and probe only one first serial device and unable to use remaining available UART devices

This patch changes the logic to probe all available serial devices using platform data or device tree in DM model in order to use all UART devices

---
 drivers/serial/Kconfig         | 12 ++++++++++++
 drivers/serial/serial-uclass.c | 42
++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+)
Quoted 8 lines
Quoted 2 lines

Looks more and more devices have requirement to be probed during boot. Guess we should handle such in a unified way?

How about:

- in dm_init(), after binding, we move on to an auto-probe step
- a uclass flag indicates that all devices in that uclass must be probed (that will be useful for PCI)

For devices class respective UCLASS to be provided with auto-probe, How many class to be included?

Quoted 4 lines

- a way to tell DM to probe all devices in a particular uclass (e.g. a call to dm_set_uclass_autoprobe(enum uclass_id, bool)
(that will be useful for this serial case)

Do you mean to verify and send patch for serial uclass with this approach after device_probe in dm_init

Quoted 3 lines

Regards,
Simon

#5 lore raw

PATCH 1/1 drivers: serial: probe all serial devices

In reply to Simon Glass

Hi Simon,

Quoted 25 lines · Simon Glass

Hi Bin,

Quoted 16 lines · Bin Meng
Quoted 8 lines · Vabhav Sharma

Serial subsystem search and probe only one first serial device and unable to use remaining available UART devices

This patch changes the logic to probe all available serial devices using platform data or device tree in DM model in order to use all UART devices

Quoted 6 lines
---
 drivers/serial/Kconfig         | 12 ++++++++++++
 drivers/serial/serial-uclass.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+)
Quoted 2 lines

Looks more and more devices have requirement to be probed during boot. Guess we should handle such in a unified way?

How about:

Quoted 7 lines

- in dm_init(), after binding, we move on to an auto-probe step
- a uclass flag indicates that all devices in that uclass must be probed (that will be useful for PCI)

- a way to tell DM to probe all devices in a particular uclass (e.g. a call to dm_set_uclass_autoprobe(enum uclass_id, bool)
(that will be useful for this serial case)

Sounds good to me. Thanks for checking.

Regards,
Bin

#6 lore raw

PATCH 1/1 drivers: serial: probe all serial devices

In reply to Vabhav Sharma
Quoted 2 lines · Vabhav Sharma

Serial subsystem search and probe only one first serial device and unable to use remaining available UART devices

The serial devices are bound and you can switch to them. What is the real problem ?

Quoted 3 lines

This patch changes the logic to probe all available serial devices using platform data or device tree in DM model in order to use all UART devices

Get rid of the ifdeffery and copied code please.

Quoted 116 lines
---
 drivers/serial/Kconfig         | 12 ++++++++++++
 drivers/serial/serial-uclass.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+)
drivers/serial/Kconfig +12 -0
index 597db4b..d6451b1 100644
@@ -133,6 +133,18 @@ config SERIAL_SEARCH_ALL
 
 	  If unsure, say N.
 
+config SERIAL_PROBE_ALL
+	bool "Probe all available serial devices"
+	depends on DM_SERIAL
+	help
+	 The serial subsystem only probe for single serial device, but does
+	 not probe for remaining available devices.
+	 With this option set,we make probing for all available devices
+	 mandatory.
+
+	 If probing is not required for all remaining available
+	 devices other than default current console device, say N.
+
 config SPL_DM_SERIAL
 	bool "Enable Driver Model for serial drivers in SPL"
 	depends on DM_SERIAL && SPL_DM
drivers/serial/serial-uclass.c +42 -0
index e50f0aa..405e60e 100644
@@ -82,6 +82,13 @@ static void serial_find_console_or_panic(void)
 		uclass_first_device(UCLASS_SERIAL, &dev);
 		if (dev) {
 			gd->cur_serial_dev = dev;
+#ifdef CONFIG_SERIAL_PROBE_ALL
+			/* Scanning uclass to probe all devices */
+			for (;
+			     dev;
+			     uclass_next_device(&dev))
+				;
+#endif
 			return;
 		}
 	} else if (CONFIG_IS_ENABLED(OF_CONTROL) && blob) {
@@ -92,11 +99,25 @@ static void serial_find_console_or_panic(void)
 			if (np && !uclass_get_device_by_ofnode(UCLASS_SERIAL,
 					np_to_ofnode(np), &dev)) {
 				gd->cur_serial_dev = dev;
+#ifdef CONFIG_SERIAL_PROBE_ALL
+				/* Scanning uclass to probe all devices */
+				for (;
+				     dev;
+				     uclass_next_device(&dev))
+					;
+#endif
 				return;
 			}
 		} else {
 			if (!serial_check_stdout(blob, &dev)) {
 				gd->cur_serial_dev = dev;
+#ifdef CONFIG_SERIAL_PROBE_ALL
+				/* Scanning uclass to probe all devices */
+				for (;
+				     dev;
+				     uclass_next_device(&dev))
+					;
+#endif
 				return;
 			}
 		}
@@ -121,6 +142,13 @@ static void serial_find_console_or_panic(void)
 		    !uclass_get_device(UCLASS_SERIAL, INDEX, &dev)) {
 			if (dev->flags & DM_FLAG_ACTIVATED) {
 				gd->cur_serial_dev = dev;
+#ifdef CONFIG_SERIAL_PROBE_ALL
+				/* Scanning uclass to probe all devices */
+				for (;
+				     dev;
+				     uclass_next_device(&dev))
+					;
+#endif
 				return;
 			}
 		}
@@ -132,6 +160,13 @@ static void serial_find_console_or_panic(void)
 			if (!ret) {
 				/* Device did succeed probing */
 				gd->cur_serial_dev = dev;
+#ifdef CONFIG_SERIAL_PROBE_ALL
+				/* Scanning uclass to probe all devices */
+				for (;
+				     dev;
+				     uclass_next_device(&dev))
+					;
+#endif
 				return;
 			}
 		}
@@ -140,6 +175,13 @@ static void serial_find_console_or_panic(void)
 		    !uclass_get_device(UCLASS_SERIAL, INDEX, &dev) ||
 		    (!uclass_first_device(UCLASS_SERIAL, &dev) && dev)) {
 			gd->cur_serial_dev = dev;
+#ifdef CONFIG_SERIAL_PROBE_ALL
+			/* Scanning uclass to probe all devices */
+			for (;
+			     dev;
+			     uclass_next_device(&dev))
+				;
+#endif
 			return;
 		}
 #endif
Signature · 2 lines
Best regards,
Marek Vasut
#7 lore raw

PATCH 1/1 drivers: serial: probe all serial devices

Quoted 10 lines

-----Original Message-----
From: Marek Vasut <[email protected]>
Sent: Tuesday, October 16, 2018 12:29 PM
To: Vabhav Sharma <[email protected]>; u-boot at lists.denx.de; u-boot- dm at lists.denx.de; sjg at chromium.org
Cc: yamada.masahiro at socionext.com; bmeng.cn at gmail.com
Subject: Re: [U-Boot-DM] [PATCH] drivers: serial: probe all serial devices

Quoted 6 lines
Quoted 2 lines · Vabhav Sharma

Serial subsystem search and probe only one first serial device and unable to use remaining available UART devices

The serial devices are bound and you can switch to them. What is the real problem ?

Yes, I understand switch is possible with change in DTS or platform data for choosing UART device to be used as boot console(e.g. UART0) with gd->cur_serial_dev is updated to chosen UART device. The problem was stated in email(attached 23 may) " [U-Boot-DM] QUERY:U-boot DM:SERIAL:Multiple On-chip UART Controller Support" with suggested solution from Simon which is sent as patch for review. Similar issue was faced by Andreas

Quoted 6 lines
Quoted 4 lines

This patch changes the logic to probe all available serial devices using platform data or device tree in DM model in order to use all UART devices

Get rid of the ifdeffery and copied code please.

This is case for using uclass_next_device() to iterate through them, Having CONFIG option doesn't make it mandatory for every platform to probe all serial devices.

Quoted 125 lines
Quoted 39 lines
---
 drivers/serial/Kconfig         | 12 ++++++++++++
 drivers/serial/serial-uclass.c | 42
++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+)
drivers/serial/Kconfig index renamed from drivers/serial/Kconfig +0 -0

597db4b..d6451b1 100644

drivers/serial/Kconfig +12 -0
@@ -133,6 +133,18 @@ config SERIAL_SEARCH_ALL
 
 	  If unsure, say N.
 
+config SERIAL_PROBE_ALL
+	bool "Probe all available serial devices"
+	depends on DM_SERIAL
+	help
+	 The serial subsystem only probe for single serial device, but does
+	 not probe for remaining available devices.
+	 With this option set,we make probing for all available devices
+	 mandatory.
+
+	 If probing is not required for all remaining available
+	 devices other than default current console device, say N.
+
 config SPL_DM_SERIAL
 	bool "Enable Driver Model for serial drivers in SPL"
 	depends on DM_SERIAL && SPL_DM
(quoted diff) +0 -0

b/drivers/serial/serial-uclass.c index e50f0aa..405e60e 100644

drivers/serial/serial-uclass.c +0 -0
@@ -82,6 +82,13 @@ static void serial_find_console_or_panic(void)
 		uclass_first_device(UCLASS_SERIAL, &dev);
 		if (dev) {
 			gd->cur_serial_dev = dev;

drivers/serial/serial-uclass.c static void serial_find_console_or_panic(void) · line 94

Quoted 10 lines
drivers/serial/serial-uclass.c +7 -0
+#ifdef CONFIG_SERIAL_PROBE_ALL
+			/* Scanning uclass to probe all devices */
+			for (;
+			     dev;
+			     uclass_next_device(&dev))
+				;
+#endif
 			return;
 		}
 	} else if (CONFIG_IS_ENABLED(OF_CONTROL) && blob) { @@ -92,11

+99,25

Quoted 2 lines

@@ static void serial_find_console_or_panic(void)
if (np

&& !uclass_get_device_by_ofnode(UCLASS_SERIAL,

Quoted 57 lines
drivers/serial/serial-uclass.c +28 -0
 					np_to_ofnode(np), &dev)) {
 				gd->cur_serial_dev = dev;
+#ifdef CONFIG_SERIAL_PROBE_ALL
+				/* Scanning uclass to probe all devices */
+				for (;
+				     dev;
+				     uclass_next_device(&dev))
+					;
+#endif
 				return;
 			}
 		} else {
 			if (!serial_check_stdout(blob, &dev)) {
 				gd->cur_serial_dev = dev;
+#ifdef CONFIG_SERIAL_PROBE_ALL
+				/* Scanning uclass to probe all devices */
+				for (;
+				     dev;
+				     uclass_next_device(&dev))
+					;
+#endif
 				return;
 			}
 		}
@@ -121,6 +142,13 @@ static void serial_find_console_or_panic(void)
 		    !uclass_get_device(UCLASS_SERIAL, INDEX, &dev)) {
 			if (dev->flags & DM_FLAG_ACTIVATED) {
 				gd->cur_serial_dev = dev;
+#ifdef CONFIG_SERIAL_PROBE_ALL
+				/* Scanning uclass to probe all devices */
+				for (;
+				     dev;
+				     uclass_next_device(&dev))
+					;
+#endif
 				return;
 			}
 		}
@@ -132,6 +160,13 @@ static void serial_find_console_or_panic(void)
 			if (!ret) {
 				/* Device did succeed probing */
 				gd->cur_serial_dev = dev;
+#ifdef CONFIG_SERIAL_PROBE_ALL
+				/* Scanning uclass to probe all devices */
+				for (;
+				     dev;
+				     uclass_next_device(&dev))
+					;
+#endif
 				return;
 			}
 		}
@@ -140,6 +175,13 @@ static void serial_find_console_or_panic(void)
 		    !uclass_get_device(UCLASS_SERIAL, INDEX, &dev) ||
 		    (!uclass_first_device(UCLASS_SERIAL, &dev) && dev)) {
 			gd->cur_serial_dev = dev;

drivers/serial/serial-uclass.c static void serial_find_console_or_panic(void) · line 187

Quoted 10 lines
drivers/serial/serial-uclass.c +7 -0
+#ifdef CONFIG_SERIAL_PROBE_ALL
+			/* Scanning uclass to probe all devices */
+			for (;
+			     dev;
+			     uclass_next_device(&dev))
+				;
+#endif
 			return;
 		}
 #endif

--
Best regards,
Marek Vasut

#8 lore raw

PATCH 1/1 drivers: serial: probe all serial devices

Quoted 11 lines · Vabhav Sharma
Quoted 11 lines

-----Original Message-----
From: Marek Vasut <[email protected]>
Sent: Tuesday, October 16, 2018 12:29 PM
To: Vabhav Sharma <[email protected]>; u-boot at lists.denx.de; u-boot- dm at lists.denx.de; sjg at chromium.org
Cc: yamada.masahiro at socionext.com; bmeng.cn at gmail.com
Subject: Re: [U-Boot-DM] [PATCH] drivers: serial: probe all serial devices

On 10/15/2018 02:09 AM, Vabhav Sharma wrote:

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Serial subsystem search and probe only one first serial device and unable to use remaining available UART devices

The serial devices are bound and you can switch to them. What is the real problem ?

Yes, I understand switch is possible with change in DTS or platform data for choosing UART device to be used as boot console(e.g. UART0) with gd->cur_serial_dev is updated to chosen UART device. The problem was stated in email(attached 23 may) " [U-Boot-DM] QUERY:U-boot DM:SERIAL:Multiple On-chip UART Controller Support" with suggested solution from Simon which is sent as patch for review. Similar issue was faced by Andreas

You can also use setenv stdin/stdout/stderr to alternate between stdio devices. So what is the problem ?

Quoted 6 lines
Quoted 5 lines
Quoted 3 lines

This patch changes the logic to probe all available serial devices using platform data or device tree in DM model in order to use all UART devices

Get rid of the ifdeffery and copied code please.

This is case for using uclass_next_device() to iterate through them, Having CONFIG option doesn't make it mandatory for every platform to probe all serial devices.

Is this also the case for having 6 copies of exactly the same code ? You can turn it into a function if needed.

Quoted 124 lines
Quoted 124 lines
Quoted 38 lines
---
 drivers/serial/Kconfig         | 12 ++++++++++++
 drivers/serial/serial-uclass.c | 42
++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+)
drivers/serial/Kconfig index renamed from drivers/serial/Kconfig +0 -0

597db4b..d6451b1 100644

drivers/serial/Kconfig +12 -0
@@ -133,6 +133,18 @@ config SERIAL_SEARCH_ALL
 
 	  If unsure, say N.
 
+config SERIAL_PROBE_ALL
+	bool "Probe all available serial devices"
+	depends on DM_SERIAL
+	help
+	 The serial subsystem only probe for single serial device, but does
+	 not probe for remaining available devices.
+	 With this option set,we make probing for all available devices
+	 mandatory.
+
+	 If probing is not required for all remaining available
+	 devices other than default current console device, say N.
+
 config SPL_DM_SERIAL
 	bool "Enable Driver Model for serial drivers in SPL"
 	depends on DM_SERIAL && SPL_DM
(quoted diff) +0 -0

b/drivers/serial/serial-uclass.c index e50f0aa..405e60e 100644

drivers/serial/serial-uclass.c +0 -0
@@ -82,6 +82,13 @@ static void serial_find_console_or_panic(void)
 		uclass_first_device(UCLASS_SERIAL, &dev);
 		if (dev) {
 			gd->cur_serial_dev = dev;

drivers/serial/serial-uclass.c static void serial_find_console_or_panic(void) · line 94

Quoted 10 lines
drivers/serial/serial-uclass.c +7 -0
+#ifdef CONFIG_SERIAL_PROBE_ALL
+			/* Scanning uclass to probe all devices */
+			for (;
+			     dev;
+			     uclass_next_device(&dev))
+				;
+#endif
 			return;
 		}
 	} else if (CONFIG_IS_ENABLED(OF_CONTROL) && blob) { @@ -92,11

+99,25

Quoted 2 lines

@@ static void serial_find_console_or_panic(void)
if (np

&& !uclass_get_device_by_ofnode(UCLASS_SERIAL,

Quoted 57 lines
drivers/serial/serial-uclass.c +28 -0
 					np_to_ofnode(np), &dev)) {
 				gd->cur_serial_dev = dev;
+#ifdef CONFIG_SERIAL_PROBE_ALL
+				/* Scanning uclass to probe all devices */
+				for (;
+				     dev;
+				     uclass_next_device(&dev))
+					;
+#endif
 				return;
 			}
 		} else {
 			if (!serial_check_stdout(blob, &dev)) {
 				gd->cur_serial_dev = dev;
+#ifdef CONFIG_SERIAL_PROBE_ALL
+				/* Scanning uclass to probe all devices */
+				for (;
+				     dev;
+				     uclass_next_device(&dev))
+					;
+#endif
 				return;
 			}
 		}
@@ -121,6 +142,13 @@ static void serial_find_console_or_panic(void)
 		    !uclass_get_device(UCLASS_SERIAL, INDEX, &dev)) {
 			if (dev->flags & DM_FLAG_ACTIVATED) {
 				gd->cur_serial_dev = dev;
+#ifdef CONFIG_SERIAL_PROBE_ALL
+				/* Scanning uclass to probe all devices */
+				for (;
+				     dev;
+				     uclass_next_device(&dev))
+					;
+#endif
 				return;
 			}
 		}
@@ -132,6 +160,13 @@ static void serial_find_console_or_panic(void)
 			if (!ret) {
 				/* Device did succeed probing */
 				gd->cur_serial_dev = dev;
+#ifdef CONFIG_SERIAL_PROBE_ALL
+				/* Scanning uclass to probe all devices */
+				for (;
+				     dev;
+				     uclass_next_device(&dev))
+					;
+#endif
 				return;
 			}
 		}
@@ -140,6 +175,13 @@ static void serial_find_console_or_panic(void)
 		    !uclass_get_device(UCLASS_SERIAL, INDEX, &dev) ||
 		    (!uclass_first_device(UCLASS_SERIAL, &dev) && dev)) {
 			gd->cur_serial_dev = dev;

drivers/serial/serial-uclass.c static void serial_find_console_or_panic(void) · line 187

Quoted 10 lines
drivers/serial/serial-uclass.c +7 -0
+#ifdef CONFIG_SERIAL_PROBE_ALL
+			/* Scanning uclass to probe all devices */
+			for (;
+			     dev;
+			     uclass_next_device(&dev))
+				;
+#endif
 			return;
 		}
 #endif

--
Best regards,
Marek Vasut

Signature · 2 lines
Best regards,
Marek Vasut
#9 lore raw

PATCH 1/1 drivers: serial: probe all serial devices

Hi Marek Vasut,
Apology for delayed reply, Occupied with other work

Quoted 29 lines

-----Original Message-----
From: Marek Vasut <[email protected]>
Sent: Tuesday, October 16, 2018 2:39 PM
To: Vabhav Sharma <[email protected]>; u-boot at lists.denx.de; u- boot-dm at lists.denx.de; sjg at chromium.org
Cc: yamada.masahiro at socionext.com; bmeng.cn at gmail.com; Andreas Dannenberg <[email protected]>
Subject: Re: [U-Boot-DM] [PATCH] drivers: serial: probe all serial devices

Quoted 11 lines · Vabhav Sharma
Quoted 11 lines

-----Original Message-----
From: Marek Vasut <[email protected]>
Sent: Tuesday, October 16, 2018 12:29 PM
To: Vabhav Sharma <[email protected]>; u-boot at lists.denx.de; u-boot- dm at lists.denx.de; sjg at chromium.org
Cc: yamada.masahiro at socionext.com; bmeng.cn at gmail.com
Subject: Re: [U-Boot-DM] [PATCH] drivers: serial: probe all serial devices

Quoted 7 lines
Quoted 6 lines · Vabhav Sharma
Quoted 2 lines

Serial subsystem search and probe only one first serial device and unable to use remaining available UART devices

The serial devices are bound and you can switch to them. What is the real problem ?

Yes, I understand switch is possible with change in DTS or platform data for

choosing UART device to be used as boot console(e.g. UART0) with gd-

Quoted 8 lines
Quoted 2 lines

cur_serial_dev is updated to chosen UART device.
The problem was stated in email(attached 23 may) " [U-Boot-DM]

QUERY:U-boot DM:SERIAL:Multiple On-chip UART Controller Support" with suggested solution from Simon which is sent as patch for review.

Quoted 1 line

Similar issue was faced by Andreas

You can also use setenv stdin/stdout/stderr to alternate between stdio devices. So what is the problem ?

Problem is seen with PL011 driver using DM model, Only boot console baud rate is set.
Tried modifying the environment variable but seems readonly (## Error inserting "stdout" variable, errno=22) Multiple UART enablement is required to use all console.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

This patch changes the logic to probe all available serial devices using platform data or device tree in DM model in order to use all UART devices

Quoted 7 lines
Quoted 2 lines
Quoted 1 line

Get rid of the ifdeffery and copied code please.

This is case for using uclass_next_device() to iterate through them, Having

CONFIG option doesn't make it mandatory for every platform to probe all serial devices.

Is this also the case for having 6 copies of exactly the same code ? You can turn it into a function if needed.

Ok, I understand

Quoted 130 lines
Quoted 117 lines
Quoted 117 lines
Quoted 39 lines
---
 drivers/serial/Kconfig         | 12 ++++++++++++
 drivers/serial/serial-uclass.c | 42
++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+)
drivers/serial/Kconfig index renamed from drivers/serial/Kconfig +0 -0

597db4b..d6451b1 100644

drivers/serial/Kconfig +12 -0
@@ -133,6 +133,18 @@ config SERIAL_SEARCH_ALL
 
 	  If unsure, say N.
 
+config SERIAL_PROBE_ALL
+	bool "Probe all available serial devices"
+	depends on DM_SERIAL
+	help
+	 The serial subsystem only probe for single serial device, but does
+	 not probe for remaining available devices.
+	 With this option set,we make probing for all available devices
+	 mandatory.
+
+	 If probing is not required for all remaining available
+	 devices other than default current console device, say N.
+
 config SPL_DM_SERIAL
 	bool "Enable Driver Model for serial drivers in SPL"
 	depends on DM_SERIAL && SPL_DM
(quoted diff) +0 -0

b/drivers/serial/serial-uclass.c index e50f0aa..405e60e 100644

drivers/serial/serial-uclass.c +0 -0
@@ -82,6 +82,13 @@ static void serial_find_console_or_panic(void)
 		uclass_first_device(UCLASS_SERIAL, &dev);
 		if (dev) {
 			gd->cur_serial_dev = dev;

drivers/serial/serial-uclass.c static void serial_find_console_or_panic(void) · line 94

Quoted 10 lines
drivers/serial/serial-uclass.c +7 -0
+#ifdef CONFIG_SERIAL_PROBE_ALL
+			/* Scanning uclass to probe all devices */
+			for (;
+			     dev;
+			     uclass_next_device(&dev))
+				;
+#endif
 			return;
 		}
 	} else if (CONFIG_IS_ENABLED(OF_CONTROL) && blob) { @@ -92,11

+99,25

Quoted 2 lines

@@ static void serial_find_console_or_panic(void)
if (np

&& !uclass_get_device_by_ofnode(UCLASS_SERIAL,

Quoted 64 lines
drivers/serial/serial-uclass.c +35 -0
 					np_to_ofnode(np), &dev)) {
 				gd->cur_serial_dev = dev;
+#ifdef CONFIG_SERIAL_PROBE_ALL
+				/* Scanning uclass to probe all devices */
+				for (;
+				     dev;
+				     uclass_next_device(&dev))
+					;
+#endif
 				return;
 			}
 		} else {
 			if (!serial_check_stdout(blob, &dev)) {
 				gd->cur_serial_dev = dev;
+#ifdef CONFIG_SERIAL_PROBE_ALL
+				/* Scanning uclass to probe all devices */
+				for (;
+				     dev;
+				     uclass_next_device(&dev))
+					;
+#endif
 				return;
 			}
 		}
@@ -121,6 +142,13 @@ static void serial_find_console_or_panic(void)
 		    !uclass_get_device(UCLASS_SERIAL, INDEX, &dev)) {
 			if (dev->flags & DM_FLAG_ACTIVATED) {
 				gd->cur_serial_dev = dev;
+#ifdef CONFIG_SERIAL_PROBE_ALL
+				/* Scanning uclass to probe all devices */
+				for (;
+				     dev;
+				     uclass_next_device(&dev))
+					;
+#endif
 				return;
 			}
 		}
@@ -132,6 +160,13 @@ static void serial_find_console_or_panic(void)
 			if (!ret) {
 				/* Device did succeed probing */
 				gd->cur_serial_dev = dev;
+#ifdef CONFIG_SERIAL_PROBE_ALL
+				/* Scanning uclass to probe all devices */
+				for (;
+				     dev;
+				     uclass_next_device(&dev))
+					;
+#endif
 				return;
 			}
 		}
@@ -140,6 +175,13 @@ static void serial_find_console_or_panic(void)
 		    !uclass_get_device(UCLASS_SERIAL, INDEX, &dev) ||
 		    (!uclass_first_device(UCLASS_SERIAL, &dev) && dev)) {
 			gd->cur_serial_dev = dev;
+#ifdef CONFIG_SERIAL_PROBE_ALL
+			/* Scanning uclass to probe all devices */
+			for (;
+			     dev;
+			     uclass_next_device(&dev))
+				;
+#endif
 			return;
Quoted 8 lines
Quoted 8 lines

drivers/serial/serial-uclass.c static void serial_find_console_or_panic(void) · line 187

Quoted 3 lines
drivers/serial/serial-uclass.c +0 -0
 		}
 #endif

--
Best regards,
Marek Vasut

--
Best regards,
Marek Vasut

#10 lore raw

PATCH 1/1 drivers: serial: probe all serial devices

Dear Vabhav,

Quoted 4 lines · In message <VI1PR04MB48001E65CD3F477EC8CE6EB9F3F70@VI1PR04MB4800.eurprd04.prod.…
Quoted 3 lines

You can also use setenv stdin/stdout/stderr to alternate between stdio devices. So what is the problem ?

Problem is seen with PL011 driver using DM model, Only boot console baud rate is set.

U-Boot can talk to only one serial device at a time anyway, so why should it intiaalize othe rports than the one used for the (then current) console?

U-Boot does lazy initializationintentionally. It is wrong to initialize devices which are not actually used.

Quoted 2 lines

Tried modifying the environment variable but seems readonly (## Error inserting "stdout" variable, errno=22)

How exactly did you try to do that?

Quoted 1 line

Multiple UART enablement is required to use all console.

I have a feeling that you attempt to do the Wong Thing.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
I am an atheist, thank God!
#11 lore raw

PATCH 1/1 drivers: serial: probe all serial devices

Quoted 20 lines

-----Original Message-----
From: Wolfgang Denk <[email protected]>
Sent: Thursday, October 25, 2018 7:35 PM
To: Vabhav Sharma <[email protected]>
Cc: Marek Vasut <[email protected]>; u-boot at lists.denx.de; u-boot- dm at lists.denx.de; sjg at chromium.org; yamada.masahiro at socionext.com; bmeng.cn at gmail.com
Subject: Re: [U-Boot-DM] [PATCH] drivers: serial: probe all serial devices

Dear Vabhav,

In message <[email protected].

Quoted 4 lines · prod.outlook.com> you wrote:
Quoted 3 lines

You can also use setenv stdin/stdout/stderr to alternate between stdio devices. So what is the problem ?

Problem is seen with PL011 driver using DM model, Only boot console

Quoted 8 lines

baud rate is set.

U-Boot can talk to only one serial device at a time anyway, so why should it intiaalize othe rports than the one used for the (then
current) console?

U-Boot does lazy initializationintentionally. It is wrong to initialize devices which are not actually used.

There is configuration option to enable the device using platform data or device tree using DM model.
For e.g: 2 UART controllers are enabled in device tree but DM model initialized only one, This is limitation
My suggestion is to initialize all devices which are enabled, E.g. use case is using UART1 for uboot consoled and UART2 for linux boot On NXP SoC, We also use UART3 for ethernet firmware logging but using DM model all enabled devices are not probed posing limitation

Quoted 5 lines
Quoted 3 lines

Tried modifying the environment variable but seems readonly (## Error inserting "stdout" variable, errno=22)

How exactly did you try to do that?

#editenv stdout

Quoted 4 lines
Quoted 2 lines

Multiple UART enablement is required to use all console.

I have a feeling that you attempt to do the Wong Thing.

I quoted the reason above and also discussed on in email(23 may) " [U-Boot-DM] QUERY:U-boot DM:SERIAL:Multiple On-chip UART Controller Support" with suggested solution from Simon which is sent as patch for review. Similar issue was faced by Andreas

Quoted 10 lines

Best regards,

Wolfgang Denk

--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de I am an atheist, thank God!

#12 lore raw

PATCH 1/1 drivers: serial: probe all serial devices

Dear Vabhav,

Quoted 6 lines · In message <VI1PR04MB48005B3CB205F14C4670CC2BF3F70@VI1PR04MB4800.eurprd04.prod.…
Quoted 3 lines

U-Boot does lazy initialization intentionally. It is wrong to initialize devices which are not actually used.

There is configuration option to enable the device using platform data or device tree using DM model.

"enable" means we have all required information needed to initialize them, if we need them. The need arises only when someone wants to transfer data over that UART. If nobody uses the UArt, there is no need to ever initialize it.

Lazy initialization is a good thing - it saves resources, especially memory and time. Think for example of boot time optimizations...

Quoted 2 lines

For e.g: 2 UART controllers are enabled in device tree but DM model initialized only one, This is limitation

In which way is this a limitation? We use only one UART (for the serial console), so it works as supposed: only the used devices are fully initialized.

Quoted 2 lines

My suggestion is to initialize all devices which are enabled, E.g. use case is using UART1 for uboot consoled and UART2 for linux boot

What do you mean "for Linux boot"? If Linux needs the UART, it will initialize it itself in the Linux dvice driver.

Quoted 3 lines

On NXP SoC, We also use UART3 for ethernet firmware logging but using DM model all enabled devices are not probed posing limitation.

Again, this is intentional, and not a limitation.

And what exactly do you mean by "UART3 for ethernet firmware logging"?

Maybe you should rethink your software concept. We don't want to have a zillion of ports in used if not really necessary. Either you use standard channels (STDOUT, STDERR) for logging. Also, there used to be a syslog compatible logging driver.

Quoted 6 lines
Quoted 1 line

I have a feeling that you attempt to do the Wong Thing.

I quoted the reason above and also discussed on in email(23 may) " [U-Boot-DM] QUERY:U-boot DM:SERIAL:Multiple On-chip UART Controller Support" with suggested solution from Simon which is sent as patch for review.

But Simon also explained "U-Boot only probes things in a 'lazy' manner so far", and there should be really good reasons for deviating from this principle. In no way should a "probe all devices" be made the default.

And Andreas also wrote how to solve this issue in a board-specific way if it is really, really needed on some board.

However, you still fail to explain why you ned multiple serial ports in U-Boot running in parallel.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Well, the way I see it, logic is only a way of being ignorant by num-
bers.                                 - Terry Pratchett, _Small Gods_
#13 lore raw

PATCH 1/1 drivers: serial: probe all serial devices

Quoted 20 lines

-----Original Message-----
From: Wolfgang Denk <[email protected]>
Sent: Friday, October 26, 2018 4:57 PM
To: Vabhav Sharma <[email protected]>
Cc: Marek Vasut <[email protected]>; u-boot at lists.denx.de; u-boot- dm at lists.denx.de; sjg at chromium.org; yamada.masahiro at socionext.com; bmeng.cn at gmail.com
Subject: Re: [U-Boot-DM] [PATCH] drivers: serial: probe all serial devices

Dear Vabhav,

In message <[email protected].

Quoted 3 lines · prod.outlook.com> you wrote:
Quoted 3 lines

U-Boot does lazy initialization intentionally. It is wrong to initialize devices which are not actually used.

Quoted 7 lines
Quoted 2 lines

There is configuration option to enable the device using platform data or device tree using DM model.

"enable" means we have all required information needed to initialize them, if we need them. The need arises only when someone wants to transfer data over that UART. If nobody uses the UArt, there is no need to ever initialize it.

On u-boot, only one console is used
There is need to use multiple console for network firmware logging, linux boot

Quoted 3 lines

Lazy initialization is a good thing - it saves resources, especially memory and time. Think for example of boot time optimizations...

I understand

Quoted 6 lines
Quoted 3 lines

For e.g: 2 UART controllers are enabled in device tree but DM model initialized only one, This is limitation

In which way is this a limitation? We use only one UART (for the serial console), so it works as supposed: only the used devices are fully initialized.

Limitation for aforesaid example

Quoted 7 lines
Quoted 4 lines

My suggestion is to initialize all devices which are enabled, E.g. use case is using UART1 for uboot consoled and UART2 for linux boot

What do you mean "for Linux boot"? If Linux needs the UART, it will initialize it itself in the Linux dvice driver.

Example is PL011 UART linux driver which expect initialization(integer and fractional baud date) done by bootloader

Quoted 7 lines
Quoted 3 lines

On NXP SoC, We also use UART3 for ethernet firmware logging but using DM model all enabled devices are not probed posing limitation.

Again, this is intentional, and not a limitation.

And what exactly do you mean by "UART3 for ethernet firmware logging"?

Different console than linux boot console.

Quoted 5 lines

Maybe you should rethink your software concept. We don't want to have a zillion of ports in used if not really necessary. Either you use standard channels (STDOUT, STDERR) for logging. Also, there used to be a syslog compatible logging driver.

Agree

Quoted 11 lines
Quoted 7 lines
Quoted 2 lines

I have a feeling that you attempt to do the Wong Thing.

I quoted the reason above and also discussed on in email(23 may) " [U-Boot-DM] QUERY:U-boot DM:SERIAL:Multiple On-chip UART Controller Support" with suggested solution from Simon which is sent as patch for review.

But Simon also explained "U-Boot only probes things in a 'lazy' manner so far", and there should be really good reasons for deviating from this principle. In no way should a "probe all devices" be made the default.

I see.
Not default and config will be selected as required Sent patch has config option

Quoted 6 lines

And Andreas also wrote how to solve this issue in a board-specific way if it is really, really needed on some board.

However, you still fail to explain why you ned multiple serial ports in U-Boot running in parallel.

I am trying to convince you for the discussed problem faced recently in DM model

Quoted 11 lines

Best regards,

Wolfgang Denk

--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Well, the way I see it, logic is only a way of being ignorant by num-
bers. - Terry Pratchett, _Small Gods_

#14 lore raw

PATCH 1/1 drivers: serial: probe all serial devices

Dear Vabhav,

Quoted 6 lines · In message <VI1PR04MB480032AF6B3C36FACA4318B6F3CF0@VI1PR04MB4800.eurprd04.prod.…
Quoted 5 lines

"enable" means we have all required information needed to initialize them, if we need them. The need arises only when someone wants to transfer data over that UART. If nobody uses the UArt, there is no need to ever initialize it.

On u-boot, only one console is used

Right. And in any case, you can ALWAYS use only one serial driver at a time, as U-Boot is strictly single-tasking. It does not make a difference whether you initialize one or twenty UARTS - you can use always exactly one at any point of time.

Quoted 1 line

There is need to use multiple console for network firmware logging, linux boot

Yes, you repeat that. But you don't explain why you think this is needed.

For example, why would you need a UART for "network logging"? Why would LInux need a different console port than U-Boot?

This all makes no sense to me...

Quoted 3 lines
Quoted 2 lines

In which way is this a limitation? We use only one UART (for the serial console), so it works as supposed: only the used devices are fully initialized.

Limitation for aforesaid example

You give no comprehensible example. You say you need it, but don't explain why, or how you would actually use it with only one serial port active at any time.

Quoted 3 lines
Quoted 2 lines

What do you mean "for Linux boot"? If Linux needs the UART, it will initialize it itself in the Linux dvice driver.

Example is PL011 UART linux driver which expect initialization(integer and fractional baud date) done by bootloader

In this case the Linux driver is broken and needs to be fixed.

Alternatively, just _use_ this port in U-Boot before booting. No need to initialize other ports, though.

Quoted 2 lines
Quoted 1 line

And what exactly do you mean by "UART3 for ethernet firmware logging"?

Different console than linux boot console.

I don't see why this would make sense. But as metioned several times before, you can always only use a single port at any time in U-Boot.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
In an organization, each person rises to the level of his own  incom-
petency                                         - The Peter Principle