Skip to contentSkip to conversation

serial: core: Move tty and serdev to be children of serial core port device

RFC PATCH Superseded Tony Lindgren 4 participants 15 messages Oct 24, 2023 – Oct 25, 2023

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/2 serial: core: Move tty and serdev to be children of serial core port device

Let's move tty and serdev controller to be children of the serial core port device. This way the runtime PM usage count of a child device propagates to the serial hardware device.

The tty and serdev devices are associated with a specific serial port of a serial hardware controller device, and we now have serial core hierarchy of controllers and ports.

The tty device moves happily with just a change of the parent device. The serdev device init needs some changes to separate the serial hardware controller device from the parent device.

---

AFAIK no urgent need to for these, will repost after the merge window

---
 drivers/tty/serdev/core.c           | 15 +++++++++------
 drivers/tty/serdev/serdev-ttyport.c |  3 ++-
 drivers/tty/serial/serial_core.c    |  3 ++-
 drivers/tty/tty_port.c              | 16 +++++++++-------
 include/linux/serdev.h              |  8 +++++++-
 include/linux/tty_port.h            |  4 ++--
 6 files changed, 31 insertions(+), 18 deletions(-)
drivers/tty/serdev/core.c +9 -6
@@ -476,6 +476,7 @@ EXPORT_SYMBOL_GPL(serdev_device_alloc);
 
 /**
  * serdev_controller_alloc() - Allocate a new serdev controller
+ * @host:	serial port hardware controller device
  * @parent:	parent device
  * @size:	size of private data
  *
@@ -484,8 +485,9 @@ EXPORT_SYMBOL_GPL(serdev_device_alloc);
  * The allocated private data region may be accessed via
  * serdev_controller_get_drvdata()
  */
-struct serdev_controller *serdev_controller_alloc(struct device *parent,
-					      size_t size)
+struct serdev_controller *serdev_controller_alloc(struct device *host,
+						  struct device *parent,
+						  size_t size)
 {
 	struct serdev_controller *ctrl;
 	int id;
@@ -510,7 +512,8 @@ struct serdev_controller *serdev_controller_alloc(struct device *parent,
 	ctrl->dev.type = &serdev_ctrl_type;
 	ctrl->dev.bus = &serdev_bus_type;
 	ctrl->dev.parent = parent;
-	ctrl->dev.of_node = parent->of_node;
+	ctrl->host = host;
+	ctrl->dev.of_node = host->of_node;
 	serdev_controller_set_drvdata(ctrl, &ctrl[1]);
 
 	dev_set_name(&ctrl->dev, "serial%d", id);
@@ -673,7 +676,7 @@ static int acpi_serdev_check_resources(struct serdev_controller *ctrl,
 		acpi_get_parent(adev->handle, &lookup.controller_handle);
 
 	/* Make sure controller and ResourceSource handle match */
-	if (ACPI_HANDLE(ctrl->dev.parent) != lookup.controller_handle)
+	if (ACPI_HANDLE(ctrl->host) != lookup.controller_handle)
 		return -ENODEV;
 
 	return 0;
@@ -738,7 +741,7 @@ static int acpi_serdev_register_devices(struct serdev_controller *ctrl)
 	bool skip;
 	int ret;
 
-	if (!has_acpi_companion(ctrl->dev.parent))
+	if (!has_acpi_companion(ctrl->host))
 		return -ENODEV;
 
 	/*
@@ -747,7 +750,7 @@ static int acpi_serdev_register_devices(struct serdev_controller *ctrl)
 	 * succeed in this case, so that the proper serdev devices can be
 	 * added "manually" later.
 	 */
-	ret = acpi_quirk_skip_serdev_enumeration(ctrl->dev.parent, &skip);
+	ret = acpi_quirk_skip_serdev_enumeration(ctrl->host, &skip);
 	if (ret)
 		return ret;
 	if (skip)
drivers/tty/serdev/serdev-ttyport.c +2 -1
@@ -274,6 +274,7 @@ static const struct serdev_controller_ops ctrl_ops = {
 };
 
 struct device *serdev_tty_port_register(struct tty_port *port,
+					struct device *host,
 					struct device *parent,
 					struct tty_driver *drv, int idx)
 {
@@ -284,7 +285,7 @@ struct device *serdev_tty_port_register(struct tty_port *port,
 	if (!port || !drv || !parent)
 		return ERR_PTR(-ENODEV);
 
-	ctrl = serdev_controller_alloc(parent, sizeof(struct serport));
+	ctrl = serdev_controller_alloc(host, parent, sizeof(struct serport));
 	if (!ctrl)
 		return ERR_PTR(-ENOMEM);
 	serport = serdev_controller_get_drvdata(ctrl);
drivers/tty/serial/serial_core.c +2 -1
@@ -3153,7 +3153,8 @@ static int serial_core_add_one_port(struct uart_driver *drv, struct uart_port *u
 	 * setserial to be used to alter this port's parameters.
 	 */
 	tty_dev = tty_port_register_device_attr_serdev(port, drv->tty_driver,
-			uport->line, uport->dev, port, uport->tty_groups);
+			uport->line, uport->dev, &uport->port_dev->dev, port,
+			uport->tty_groups);
 	if (!IS_ERR(tty_dev)) {
 		device_set_wakeup_capable(tty_dev, 1);
 	} else {
drivers/tty/tty_port.c +9 -7
@@ -171,7 +171,8 @@ EXPORT_SYMBOL_GPL(tty_port_register_device_attr);
  * @port: tty_port of the device
  * @driver: tty_driver for this device
  * @index: index of the tty
- * @device: parent if exists, otherwise NULL
+ * @host: serial port hardware device
+ * @parent: parent if exists, otherwise NULL
  * @drvdata: driver data for the device
  * @attr_grp: attribute group for the device
  *
@@ -180,20 +181,20 @@ EXPORT_SYMBOL_GPL(tty_port_register_device_attr);
  */
 struct device *tty_port_register_device_attr_serdev(struct tty_port *port,
 		struct tty_driver *driver, unsigned index,
-		struct device *device, void *drvdata,
+		struct device *host, struct device *parent, void *drvdata,
 		const struct attribute_group **attr_grp)
 {
 	struct device *dev;
 
 	tty_port_link_device(port, driver, index);
 
-	dev = serdev_tty_port_register(port, device, driver, index);
+	dev = serdev_tty_port_register(port, host, parent, driver, index);
 	if (PTR_ERR(dev) != -ENODEV) {
 		/* Skip creating cdev if we registered a serdev device */
 		return dev;
 	}
 
-	return tty_register_device_attr(driver, index, device, drvdata,
+	return tty_register_device_attr(driver, index, parent, drvdata,
 			attr_grp);
 }
 EXPORT_SYMBOL_GPL(tty_port_register_device_attr_serdev);
@@ -203,17 +204,18 @@ EXPORT_SYMBOL_GPL(tty_port_register_device_attr_serdev);
  * @port: tty_port of the device
  * @driver: tty_driver for this device
  * @index: index of the tty
- * @device: parent if exists, otherwise NULL
+ * @host: serial port hardware controller device
+ * @parent: parent if exists, otherwise NULL
  *
  * Register a serdev or tty device depending on if the parent device has any
  * defined serdev clients or not.
  */
 struct device *tty_port_register_device_serdev(struct tty_port *port,
 		struct tty_driver *driver, unsigned index,
-		struct device *device)
+		struct device *host, struct device *parent)
 {
 	return tty_port_register_device_attr_serdev(port, driver, index,
-			device, NULL, NULL);
+			host, parent, NULL, NULL);
 }
 EXPORT_SYMBOL_GPL(tty_port_register_device_serdev);
 
include/linux/serdev.h +7 -1
@@ -99,12 +99,14 @@ struct serdev_controller_ops {
 /**
  * struct serdev_controller - interface to the serdev controller
  * @dev:	Driver model representation of the device.
+ * @host:	Serial port hardware controller device
  * @nr:		number identifier for this controller/bus.
  * @serdev:	Pointer to slave device for this controller.
  * @ops:	Controller operations.
  */
 struct serdev_controller {
 	struct device		dev;
+	struct device		*host;
 	unsigned int		nr;
 	struct serdev_device	*serdev;
 	const struct serdev_controller_ops *ops;
@@ -167,7 +169,9 @@ struct serdev_device *serdev_device_alloc(struct serdev_controller *);
 int serdev_device_add(struct serdev_device *);
 void serdev_device_remove(struct serdev_device *);
 
-struct serdev_controller *serdev_controller_alloc(struct device *, size_t);
+struct serdev_controller *serdev_controller_alloc(struct device *host,
+						  struct device *parent,
+						  size_t);
 int serdev_controller_add(struct serdev_controller *);
 void serdev_controller_remove(struct serdev_controller *);
 
@@ -311,11 +315,13 @@ struct tty_driver;
 
 #ifdef CONFIG_SERIAL_DEV_CTRL_TTYPORT
 struct device *serdev_tty_port_register(struct tty_port *port,
+					struct device *host,
 					struct device *parent,
 					struct tty_driver *drv, int idx);
 int serdev_tty_port_unregister(struct tty_port *port);
 #else
 static inline struct device *serdev_tty_port_register(struct tty_port *port,
+					   struct device *host,
 					   struct device *parent,
 					   struct tty_driver *drv, int idx)
 {
include/linux/tty_port.h +2 -2
@@ -149,10 +149,10 @@ struct device *tty_port_register_device_attr(struct tty_port *port,
 		const struct attribute_group **attr_grp);
 struct device *tty_port_register_device_serdev(struct tty_port *port,
 		struct tty_driver *driver, unsigned index,
-		struct device *device);
+		struct device *host, struct device *parent);
 struct device *tty_port_register_device_attr_serdev(struct tty_port *port,
 		struct tty_driver *driver, unsigned index,
-		struct device *device, void *drvdata,
+		struct device *host, struct device *parent, void *drvdata,
 		const struct attribute_group **attr_grp);
 void tty_port_unregister_device(struct tty_port *port,
 		struct tty_driver *driver, unsigned index);

base-commit: 6f699743aebf07538e506a46c5965eb8bdd2c716

Signature · 1 line
2.42.0
#1 lore raw

RFC PATCH 2/2 serial: core: Revert checks for tx runtime PM state

This reverts commit 81a61051e0ce5fd7e09225c0d5985da08c7954a7.

With tty and serdev controller moved to be children of the serial core port device, runtime PM usage count of the serdev controller now propagates to the serial hardware controller parent device as expected.

Cc Maximilian Luz <[email protected]>
Cc Rob Herring <[email protected]>
---
 drivers/tty/serial/serial_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/serial_core.c +1 -1
@@ -156,7 +156,7 @@ static void __uart_start(struct uart_state *state)
 	 * enabled, serial_port_runtime_resume() calls start_tx() again
 	 * after enabling the device.
 	 */
-	if (!pm_runtime_enabled(port->dev) || pm_runtime_active(port->dev))
+	if (pm_runtime_active(&port_dev->dev))
 		port->ops->start_tx(port);
 	pm_runtime_mark_last_busy(&port_dev->dev);
 	pm_runtime_put_autosuspend(&port_dev->dev);
Signature · 1 line
2.42.0
#2 lore raw
In reply to Tony Lindgren
Quoted 4 lines · Tony Lindgren

Let's move tty and serdev controller to be children of the serial core port device. This way the runtime PM usage count of a child device propagates to the serial hardware device.

Quoted 8 lines

The tty and serdev devices are associated with a specific serial port of a serial hardware controller device, and we now have serial core hierarchy of controllers and ports.

The tty device moves happily with just a change of the parent device. The serdev device init needs some changes to separate the serial hardware controller device from the parent device.

What does this change the sysfs tree to look like?

No objection from me, just curious.

thanks,

greg k-h

#10 lore raw
In reply to Tony Lindgren
Quoted 11 lines · Tony Lindgren

Let's move tty and serdev controller to be children of the serial core port device. This way the runtime PM usage count of a child device propagates to the serial hardware device.

The tty and serdev devices are associated with a specific serial port of a serial hardware controller device, and we now have serial core hierarchy of controllers and ports.

The tty device moves happily with just a change of the parent device. The serdev device init needs some changes to separate the serial hardware controller device from the parent device.

...

drivers/tty/serdev/core.c struct serdev_controller *serdev_controller_alloc(struct device *parent, · line 516

Quoted 2 lines
drivers/tty/serdev/core.c +1 -1
-	ctrl->dev.of_node = parent->of_node;
+	ctrl->dev.of_node = host->of_node;

Even above should have been using device_set_node(&ctrl->dev, dev_fwnode(host)).

...

drivers/tty/serdev/core.c static int acpi_serdev_check_resources(struct serdev_controller *ctrl, · line 679

Quoted 3 lines
drivers/tty/serdev/core.c +1 -1
 	/* Make sure controller and ResourceSource handle match */
-	if (ACPI_HANDLE(ctrl->dev.parent) != lookup.controller_handle)
+	if (ACPI_HANDLE(ctrl->host) != lookup.controller_handle)

This can be changed to use device_match_acpi_handle().

Quoted 1 line

return -ENODEV;

...

drivers/tty/serdev/core.c static int acpi_serdev_register_devices(struct serdev_controller *ctrl) · line 744

Quoted 2 lines
drivers/tty/serdev/core.c +1 -1
-	if (!has_acpi_companion(ctrl->dev.parent))
+	if (!has_acpi_companion(ctrl->host))

I prefer is_acpi_device_node(dev_fwnode(...)) check, but here seems no other use for fwnode (haven't checked the full context, though).

Quoted 1 line

return -ENODEV;

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw
In reply to Greg Kroah-Hartman
Quoted 1 line · Greg Kroah-Hartman

What does this change the sysfs tree to look like?

On x86 qemu for the ttys:

# find /sys -name tty
/sys/class/tty
/sys/class/tty/tty
/sys/devices/pnp0/00:04/00:04:0/00:04:0.0/tty
/sys/devices/platform/serial8250/serial8250:0/serial8250:0.3/tty
/sys/devices/platform/serial8250/serial8250:0/serial8250:0.1/tty
/sys/devices/platform/serial8250/serial8250:0/serial8250:0.2/tty
/sys/devices/virtual/tty
/sys/devices/virtual/tty/tty

Regards,

Tony

#4 lore raw
Quoted 5 lines · Tony Lindgren
Quoted 1 line · Greg Kroah-Hartman

What does this change the sysfs tree to look like?

On x86 qemu for the ttys:

Quoted 9 lines
# find /sys -name tty
/sys/class/tty
/sys/class/tty/tty
/sys/devices/pnp0/00:04/00:04:0/00:04:0.0/tty
/sys/devices/platform/serial8250/serial8250:0/serial8250:0.3/tty
/sys/devices/platform/serial8250/serial8250:0/serial8250:0.1/tty
/sys/devices/platform/serial8250/serial8250:0/serial8250:0.2/tty
/sys/devices/virtual/tty
/sys/devices/virtual/tty/tty

I believe the question was how serdev device will move it's location in the hierarchy.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#11 lore raw
In reply to Andy Shevchenko
Quoted 1 line · Andy Shevchenko

On Tue, Oct 24, 2023 at 02:36:18PM +0300, Tony Lindgren wrote:

...

Quoted 4 lines

drivers/tty/serdev/core.c struct serdev_controller *serdev_controller_alloc(struct device *parent, · line 516

Quoted 2 lines
drivers/tty/serdev/core.c +1 -1
-	ctrl->dev.of_node = parent->of_node;
+	ctrl->dev.of_node = host->of_node;

Even above should have been using device_set_node(&ctrl->dev, dev_fwnode(host)).

...

Quoted 7 lines

drivers/tty/serdev/core.c static int acpi_serdev_check_resources(struct serdev_controller *ctrl, · line 679

Quoted 3 lines
drivers/tty/serdev/core.c +1 -1
 	/* Make sure controller and ResourceSource handle match */
-	if (ACPI_HANDLE(ctrl->dev.parent) != lookup.controller_handle)
+	if (ACPI_HANDLE(ctrl->host) != lookup.controller_handle)

This can be changed to use device_match_acpi_handle().

Quoted 1 line

return -ENODEV;

...

Quoted 7 lines

drivers/tty/serdev/core.c static int acpi_serdev_register_devices(struct serdev_controller *ctrl) · line 744

Quoted 2 lines
drivers/tty/serdev/core.c +1 -1
-	if (!has_acpi_companion(ctrl->dev.parent))
+	if (!has_acpi_companion(ctrl->host))

I prefer is_acpi_device_node(dev_fwnode(...)) check, but here seems no other use for fwnode (haven't checked the full context, though).

Quoted 1 line

return -ENODEV;

...

I have just sent a little series based on these comments.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#5 lore raw
In reply to Andy Shevchenko
Quoted 16 lines · Andy Shevchenko
Quoted 5 lines · Tony Lindgren
Quoted 1 line · Greg Kroah-Hartman

What does this change the sysfs tree to look like?

On x86 qemu for the ttys:

Quoted 9 lines
# find /sys -name tty
/sys/class/tty
/sys/class/tty/tty
/sys/devices/pnp0/00:04/00:04:0/00:04:0.0/tty
/sys/devices/platform/serial8250/serial8250:0/serial8250:0.3/tty
/sys/devices/platform/serial8250/serial8250:0/serial8250:0.1/tty
/sys/devices/platform/serial8250/serial8250:0/serial8250:0.2/tty
/sys/devices/virtual/tty
/sys/devices/virtual/tty/tty
Quoted 2 lines

I believe the question was how serdev device will move it's location in the hierarchy.

If used, a serdev device serial0 will appear instead of the tty in the same location.

Regards,

Tony

#13 lore raw
In reply to Tony Lindgren
Quoted 28 lines · Tony Lindgren

Let's move tty and serdev controller to be children of the serial core port device. This way the runtime PM usage count of a child device propagates to the serial hardware device.

The tty device moves happily with just a change of the parent device.

drivers/tty/serial/serial_core.c +2 -1
@@ -3153,7 +3153,8 @@ static int serial_core_add_one_port(struct uart_driver *drv, struct uart_port *u
 	 * setserial to be used to alter this port's parameters.
 	 */
 	tty_dev = tty_port_register_device_attr_serdev(port, drv->tty_driver,
-			uport->line, uport->dev, port, uport->tty_groups);
+			uport->line, uport->dev, &uport->port_dev->dev, port,
+			uport->tty_groups);
 	if (!IS_ERR(tty_dev)) {
 		device_set_wakeup_capable(tty_dev, 1);
 	} else {

struct device *tty_port_register_device_attr_serdev(struct tty_port *port,
struct tty_driver *driver, unsigned index,

drivers/tty/tty_port.c +1 -2
-               struct device *device, void *drvdata,
+               struct device *host, struct device *parent, void *drvdata,
                const struct attribute_group **attr_grp)
 {
        struct device *dev;
 
        tty_port_link_device(port, driver, index);
 
-       dev = serdev_tty_port_register(port, device, driver, index);

drivers/tty/tty_port.c EXPORT_SYMBOL_GPL(tty_port_register_device_attr); · line 199

Quoted 10 lines
drivers/tty/tty_port.c +2 -1
+       dev = serdev_tty_port_register(port, host, parent, driver, index);
        if (PTR_ERR(dev) != -ENODEV) {
                /* Skip creating cdev if we registered a serdev device */
                return dev;
        }
 
-       return tty_register_device_attr(driver, index, device, drvdata,
+       return tty_register_device_attr(driver, index, parent, drvdata,
                        attr_grp);
 }

Looks like this patch breaks the wakeup-irq hack in uart_suspend_port():

	tty_dev = device_find_child(uport->dev, &match, serial_match_port);
	if (tty_dev && device_may_wakeup(tty_dev)) {
		enable_irq_wake(uport->irq);
		put_device(tty_dev);
		mutex_unlock(&port->mutex);
		return 0;
	}

There may be more of these hard-coded assumptions, this one I happened to be aware of.

Johan

#14 lore raw
Quoted 10 lines · Johan Hovold

Looks like this patch breaks the wakeup-irq hack in uart_suspend_port():

	tty_dev = device_find_child(uport->dev, &match, serial_match_port);
	if (tty_dev && device_may_wakeup(tty_dev)) {
		enable_irq_wake(uport->irq);
		put_device(tty_dev);
		mutex_unlock(&port->mutex);
		return 0;
	}
Quoted 2 lines

There may be more of these hard-coded assumptions, this one I happened to be aware of.

OK thanks I'll take a look.

Regards,

Tony

#6 lore raw
In reply to Tony Lindgren
Quoted 5 lines · Tony Lindgren
Quoted 1 line · Greg Kroah-Hartman

What does this change the sysfs tree to look like?

On x86 qemu for the ttys:

Quoted 9 lines
# find /sys -name tty
/sys/class/tty
/sys/class/tty/tty
/sys/devices/pnp0/00:04/00:04:0/00:04:0.0/tty
/sys/devices/platform/serial8250/serial8250:0/serial8250:0.3/tty
/sys/devices/platform/serial8250/serial8250:0/serial8250:0.1/tty
/sys/devices/platform/serial8250/serial8250:0/serial8250:0.2/tty
/sys/devices/virtual/tty
/sys/devices/virtual/tty/tty

A diff of before vs. after would make more sense for those of us who don't have your same system configuration :)

thanks,

greg k-h

#7 lore raw
Quoted 16 lines · Greg Kroah-Hartman
Quoted 5 lines · Tony Lindgren
Quoted 1 line · Greg Kroah-Hartman

What does this change the sysfs tree to look like?

On x86 qemu for the ttys:

Quoted 9 lines
# find /sys -name tty
/sys/class/tty
/sys/class/tty/tty
/sys/devices/pnp0/00:04/00:04:0/00:04:0.0/tty
/sys/devices/platform/serial8250/serial8250:0/serial8250:0.3/tty
/sys/devices/platform/serial8250/serial8250:0/serial8250:0.1/tty
/sys/devices/platform/serial8250/serial8250:0/serial8250:0.2/tty
/sys/devices/virtual/tty
/sys/devices/virtual/tty/tty
Quoted 2 lines

A diff of before vs. after would make more sense for those of us who don't have your same system configuration :)

Here's the diff of the same command before and after:

tmp/after 2023-10-25 09:43:30.681797899 +0300 renamed from tmp/before 2023-10-25 09:45:12.197283690 +0300 +4 -2
@@ -1,7 +1,9 @@
 # find /sys -name tty
 /sys/class/tty
 /sys/class/tty/tty
-/sys/devices/pnp0/00:04/tty
-/sys/devices/platform/serial8250/tty
+/sys/devices/pnp0/00:04/00:04:0/00:04:0.0/tty
+/sys/devices/platform/serial8250/serial8250:0/serial8250:0.3/tty
+/sys/devices/platform/serial8250/serial8250:0/serial8250:0.1/tty
+/sys/devices/platform/serial8250/serial8250:0/serial8250:0.2/tty
 /sys/devices/virtual/tty
 /sys/devices/virtual/tty/tty

There are multiple ports claimed by serial8250. So I think the new sysfs output is correct showing more ttys. If there's some reason why serial8250 should only have one tty and this output is not correct let me know too..

Regards,

Tony

#8 lore raw
In reply to Tony Lindgren
Quoted 10 lines · Tony Lindgren
Quoted 1 line · Greg Kroah-Hartman
Quoted 1 line
Quoted 1 line

What does this change the sysfs tree to look like?

Here's the diff of the same command before and after:

tmp/after 2023-10-25 09:43:30.681797899 +0300 renamed from tmp/before 2023-10-25 09:45:12.197283690 +0300 +0 -0
@@ -1,7 +1,9 @@
 # find /sys -name tty

tmp/after 2023-10-25 09:43:30.681797899 +0300 line 9

Quoted 10 lines
tmp/after 2023-10-25 09:43:30.681797899 +0300 renamed from tmp/before 2023-10-25 09:45:12.197283690 +0300 +4 -2
 /sys/class/tty
 /sys/class/tty/tty
-/sys/devices/pnp0/00:04/tty
-/sys/devices/platform/serial8250/tty
+/sys/devices/pnp0/00:04/00:04:0/00:04:0.0/tty
+/sys/devices/platform/serial8250/serial8250:0/serial8250:0.3/tty
+/sys/devices/platform/serial8250/serial8250:0/serial8250:0.1/tty
+/sys/devices/platform/serial8250/serial8250:0/serial8250:0.2/tty
 /sys/devices/virtual/tty
 /sys/devices/virtual/tty/tty

Your diff is missing the actual tty devices. 'tty' is just the class directory.

And can you post the equivalent diff for serdev as well for completeness?

Quoted 3 lines

There are multiple ports claimed by serial8250. So I think the new sysfs output is correct showing more ttys. If there's some reason why serial8250 should only have one tty and this output is not correct let me know too..

There should not be more class devices, you've just moved them and thus there are more class directories (with one device per directory).

Johan

#9 lore raw
Quoted 2 lines · Johan Hovold

Your diff is missing the actual tty devices. 'tty' is just the class directory.

Ah right, that explains :) The find must be for ttyS* in this case, here's the diff for qemu x86 for command:

# find /sys -name ttyS*
tmp/after 2023-10-25 10:52:52.770393075 +0300 renamed from tmp/before 2023-10-25 10:50:29.870083012 +0300 +4 -4
@@ -3,7 +3,7 @@
 /sys/class/tty/ttyS0
 /sys/class/tty/ttyS3
 /sys/class/tty/ttyS1
-/sys/devices/pnp0/00:04/tty/ttyS0
-/sys/devices/platform/serial8250/tty/ttyS2
-/sys/devices/platform/serial8250/tty/ttyS3
-/sys/devices/platform/serial8250/tty/ttyS1
+/sys/devices/pnp0/00:04/00:04:0/00:04:0.0/tty/ttyS0
+/sys/devices/platform/serial8250/serial8250:0/serial8250:0.3/tty/ttyS3
+/sys/devices/platform/serial8250/serial8250:0/serial8250:0.1/tty/ttyS1
+/sys/devices/platform/serial8250/serial8250:0/serial8250:0.2/tty/ttyS2
Quoted 1 line

And can you post the equivalent diff for serdev as well for completeness?

I don't have an x86 or arm64 testcase for serdev, but here's a armv7 wlcore hci-uart serdev diff for command:

# find /sys -name ttyS* -o -name serial0
tmp/after 2023-10-25 08:23:15.468382112 +0000 renamed from tmp/before 2023-10-25 08:23:15.468382112 +0000 +6 -7
@@ -1,10 +1,9 @@
-# find /sys -name ttyS* -o -name serial0
-/sys/devices/platform/ocp/48000000.interconnect/48000000.interconnect:segment@0/4806e050.target-module/4806e000.serial/serial0
-/sys/devices/platform/ocp/48000000.interconnect/48000000.interconnect:segment@0/48020050.target-module/48020000.serial/tty/ttyS2
-/sys/devices/platform/ocp/48000000.interconnect/48000000.interconnect:segment@0/4806a050.target-module/4806a000.serial/tty/ttyS0
-/sys/devices/platform/ocp/48000000.interconnect/48000000.interconnect:segment@0/4806c050.target-module/4806c000.serial/tty/ttyS1
-/sys/devices/platform/serial8250/tty/ttyS4
-/sys/devices/platform/serial8250/tty/ttyS5
+/sys/devices/platform/ocp/48000000.interconnect/48000000.interconnect:segment@0/4806e050.target-module/4806e000.serial/4806e000.serial:0/4806e000.serial:0.0/serial0
+/sys/devices/platform/ocp/48000000.interconnect/48000000.interconnect:segment@0/48020050.target-module/48020000.serial/48020000.serial:0/48020000.serial:0.0/tty/ttyS2
+/sys/devices/platform/ocp/48000000.interconnect/48000000.interconnect:segment@0/4806a050.target-module/4806a000.serial/4806a000.serial:0/4806a000.serial:0.0/tty/ttyS0
+/sys/devices/platform/ocp/48000000.interconnect/48000000.interconnect:segment@0/4806c050.target-module/4806c000.serial/4806c000.serial:0/4806c000.serial:0.0/tty/ttyS1
+/sys/devices/platform/serial8250/serial8250:0/serial8250:0.5/tty/ttyS5
+/sys/devices/platform/serial8250/serial8250:0/serial8250:0.4/tty/ttyS4
 /sys/class/tty/ttyS4
 /sys/class/tty/ttyS2
 /sys/class/tty/ttyS0
Quoted 6 lines
Quoted 3 lines

There are multiple ports claimed by serial8250. So I think the new sysfs output is correct showing more ttys. If there's some reason why serial8250 should only have one tty and this output is not correct let me know too..

There should not be more class devices, you've just moved them and thus there are more class directories (with one device per directory).

OK makes sense.

Thanks,

Tony