* [PATCH] serial: core: Revert port_id use
@ 2023-08-06 6:20 Tony Lindgren
2023-08-06 13:19 ` Guenter Roeck
0 siblings, 1 reply; 9+ messages in thread
From: Tony Lindgren @ 2023-08-06 6:20 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby, Andy Shevchenko
Cc: Andy Shevchenko, Dhruva Gole, Ilpo Järvinen, John Ogness,
Johan Hovold, Sebastian Andrzej Siewior, Vignesh Raghavendra,
linux-kernel, linux-serial, Guenter Roeck
Guenter reports boot issues with duplicate sysfs entries for multiport
drivers. Let's go back to using port->line for now to fix the regression.
With this change, the serial core port device names are not correct for the
hardware specific 8250 single port drivers, but that's a cosmetic issue for
now.
Fixes: d962de6ae51f ("serial: core: Fix serial core port id to not use port->line")
Reported-by: Guenter Roeck <groeck7@gmail.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
drivers/tty/serial/serial_base_bus.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/tty/serial/serial_base_bus.c b/drivers/tty/serial/serial_base_bus.c
--- a/drivers/tty/serial/serial_base_bus.c
+++ b/drivers/tty/serial/serial_base_bus.c
@@ -151,7 +151,7 @@ struct serial_port_device *serial_base_port_add(struct uart_port *port,
err = serial_base_device_init(port, &port_dev->dev,
&ctrl_dev->dev, &serial_port_type,
serial_base_port_release,
- port->ctrl_id, port->port_id);
+ port->ctrl_id, port->line);
if (err)
goto err_put_device;
--
2.41.0
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH] serial: core: Revert port_id use 2023-08-06 6:20 [PATCH] serial: core: Revert port_id use Tony Lindgren @ 2023-08-06 13:19 ` Guenter Roeck 2023-08-09 5:26 ` Tony Lindgren 0 siblings, 1 reply; 9+ messages in thread From: Guenter Roeck @ 2023-08-06 13:19 UTC (permalink / raw) To: Tony Lindgren Cc: Greg Kroah-Hartman, Jiri Slaby, Andy Shevchenko, Andy Shevchenko, Dhruva Gole, Ilpo Järvinen, John Ogness, Johan Hovold, Sebastian Andrzej Siewior, Vignesh Raghavendra, linux-kernel, linux-serial, Guenter Roeck On Sun, Aug 06, 2023 at 09:20:50AM +0300, Tony Lindgren wrote: > Guenter reports boot issues with duplicate sysfs entries for multiport > drivers. Let's go back to using port->line for now to fix the regression. > > With this change, the serial core port device names are not correct for the > hardware specific 8250 single port drivers, but that's a cosmetic issue for > now. > > Fixes: d962de6ae51f ("serial: core: Fix serial core port id to not use port->line") > Reported-by: Guenter Roeck <groeck7@gmail.com> > Signed-off-by: Tony Lindgren <tony@atomide.com> Tested-by: Guenter Roeck <linux@roeck-us.net> Guenter ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] serial: core: Revert port_id use 2023-08-06 13:19 ` Guenter Roeck @ 2023-08-09 5:26 ` Tony Lindgren 2023-08-09 5:33 ` Dhruva Gole ` (2 more replies) 0 siblings, 3 replies; 9+ messages in thread From: Tony Lindgren @ 2023-08-09 5:26 UTC (permalink / raw) To: Guenter Roeck Cc: Greg Kroah-Hartman, Jiri Slaby, Andy Shevchenko, Andy Shevchenko, Dhruva Gole, Ilpo Järvinen, John Ogness, Johan Hovold, Sebastian Andrzej Siewior, Vignesh Raghavendra, linux-kernel, linux-serial, Guenter Roeck Hi, * Guenter Roeck <linux@roeck-us.net> [230806 13:19]: > On Sun, Aug 06, 2023 at 09:20:50AM +0300, Tony Lindgren wrote: > > Guenter reports boot issues with duplicate sysfs entries for multiport > > drivers. Let's go back to using port->line for now to fix the regression. > > > > With this change, the serial core port device names are not correct for the > > hardware specific 8250 single port drivers, but that's a cosmetic issue for > > now. > > > > Fixes: d962de6ae51f ("serial: core: Fix serial core port id to not use port->line") > > Reported-by: Guenter Roeck <groeck7@gmail.com> > > Signed-off-by: Tony Lindgren <tony@atomide.com> > > Tested-by: Guenter Roeck <linux@roeck-us.net> Thanks for testing. Guenter, care to also test the patch below on top of this fix and see if things still behave for you? I'll send a proper patch assuming things test fine. Regagrds, Tony 8< -------------------- diff --git a/drivers/tty/serial/serial_base.h b/drivers/tty/serial/serial_base.h --- a/drivers/tty/serial/serial_base.h +++ b/drivers/tty/serial/serial_base.h @@ -16,6 +16,7 @@ struct device; struct serial_ctrl_device { struct device dev; + struct ida ida; }; struct serial_port_device { diff --git a/drivers/tty/serial/serial_base_bus.c b/drivers/tty/serial/serial_base_bus.c --- a/drivers/tty/serial/serial_base_bus.c +++ b/drivers/tty/serial/serial_base_bus.c @@ -10,6 +10,7 @@ #include <linux/container_of.h> #include <linux/device.h> +#include <linux/idr.h> #include <linux/module.h> #include <linux/serial_core.h> #include <linux/slab.h> @@ -112,6 +113,8 @@ struct serial_ctrl_device *serial_base_ctrl_add(struct uart_port *port, if (!ctrl_dev) return ERR_PTR(-ENOMEM); + ida_init(&ctrl_dev->ida); + err = serial_base_device_init(port, &ctrl_dev->dev, parent, &serial_ctrl_type, serial_base_ctrl_release, @@ -142,16 +145,31 @@ struct serial_port_device *serial_base_port_add(struct uart_port *port, struct serial_ctrl_device *ctrl_dev) { struct serial_port_device *port_dev; + unsigned int min = 0, max = ~0U; int err; port_dev = kzalloc(sizeof(*port_dev), GFP_KERNEL); if (!port_dev) return ERR_PTR(-ENOMEM); + /* Device driver specified port_id vs automatic assignment? */ + if (port->port_id) { + min = port->port_id; + max = port->port_id; + } + + err = ida_alloc_range(&ctrl_dev->ida, min, max, GFP_KERNEL); + if (err < 0) { + kfree(port_dev); + return ERR_PTR(err); + } + + port->port_id = err; + err = serial_base_device_init(port, &port_dev->dev, &ctrl_dev->dev, &serial_port_type, serial_base_port_release, - port->ctrl_id, port->line); + port->ctrl_id, port->port_id); if (err) goto err_put_device; @@ -165,16 +183,24 @@ struct serial_port_device *serial_base_port_add(struct uart_port *port, err_put_device: put_device(&port_dev->dev); + ida_free(&ctrl_dev->ida, port->port_id); return ERR_PTR(err); } void serial_base_port_device_remove(struct serial_port_device *port_dev) { + struct serial_ctrl_device *ctrl_dev; + struct device *parent; + if (!port_dev) return; + parent = port_dev->dev.parent; + ctrl_dev = to_serial_base_ctrl_device(parent); + device_del(&port_dev->dev); + ida_free(&ctrl_dev->ida, port_dev->port->port_id); put_device(&port_dev->dev); } -- 2.41.0 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] serial: core: Revert port_id use 2023-08-09 5:26 ` Tony Lindgren @ 2023-08-09 5:33 ` Dhruva Gole 2023-08-09 5:41 ` Tony Lindgren 2023-08-09 5:36 ` Guenter Roeck 2023-08-09 21:16 ` Guenter Roeck 2 siblings, 1 reply; 9+ messages in thread From: Dhruva Gole @ 2023-08-09 5:33 UTC (permalink / raw) To: Tony Lindgren Cc: Guenter Roeck, Greg Kroah-Hartman, Jiri Slaby, Andy Shevchenko, Andy Shevchenko, Ilpo Järvinen, John Ogness, Johan Hovold, Sebastian Andrzej Siewior, Vignesh Raghavendra, linux-kernel, linux-serial, Guenter Roeck On Aug 09, 2023 at 08:26:50 +0300, Tony Lindgren wrote: > Hi, > > * Guenter Roeck <linux@roeck-us.net> [230806 13:19]: > > On Sun, Aug 06, 2023 at 09:20:50AM +0300, Tony Lindgren wrote: > > > Guenter reports boot issues with duplicate sysfs entries for multiport > > > drivers. Let's go back to using port->line for now to fix the regression. > > > > > > With this change, the serial core port device names are not correct for the > > > hardware specific 8250 single port drivers, but that's a cosmetic issue for > > > now. > > > > > > Fixes: d962de6ae51f ("serial: core: Fix serial core port id to not use port->line") > > > Reported-by: Guenter Roeck <groeck7@gmail.com> > > > Signed-off-by: Tony Lindgren <tony@atomide.com> > > > > Tested-by: Guenter Roeck <linux@roeck-us.net> > > Thanks for testing. > > Guenter, care to also test the patch below on top of this fix and > see if things still behave for you? > > I'll send a proper patch assuming things test fine. > > Regagrds, > > Tony > > 8< -------------------- > diff --git a/drivers/tty/serial/serial_base.h b/drivers/tty/serial/serial_base.h > --- a/drivers/tty/serial/serial_base.h > +++ b/drivers/tty/serial/serial_base.h > @@ -16,6 +16,7 @@ struct device; > > struct serial_ctrl_device { > struct device dev; > + struct ida ida; When you send the proper patch, might want to change variable name to something other than ida? [...] > > -- > 2.41.0 -- Best regards, Dhruva Gole <d-gole@ti.com> ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] serial: core: Revert port_id use 2023-08-09 5:33 ` Dhruva Gole @ 2023-08-09 5:41 ` Tony Lindgren 0 siblings, 0 replies; 9+ messages in thread From: Tony Lindgren @ 2023-08-09 5:41 UTC (permalink / raw) To: Dhruva Gole Cc: Guenter Roeck, Greg Kroah-Hartman, Jiri Slaby, Andy Shevchenko, Andy Shevchenko, Ilpo Järvinen, John Ogness, Johan Hovold, Sebastian Andrzej Siewior, Vignesh Raghavendra, linux-kernel, linux-serial, Guenter Roeck * Dhruva Gole <d-gole@ti.com> [230809 05:33]: > On Aug 09, 2023 at 08:26:50 +0300, Tony Lindgren wrote: > > --- a/drivers/tty/serial/serial_base.h > > +++ b/drivers/tty/serial/serial_base.h > > @@ -16,6 +16,7 @@ struct device; > > > > struct serial_ctrl_device { > > struct device dev; > > + struct ida ida; > > When you send the proper patch, might want to change variable name to > something other than ida? OK I'll change it to port_ida. Tony ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] serial: core: Revert port_id use 2023-08-09 5:26 ` Tony Lindgren 2023-08-09 5:33 ` Dhruva Gole @ 2023-08-09 5:36 ` Guenter Roeck 2023-08-09 5:37 ` Tony Lindgren 2023-08-09 21:16 ` Guenter Roeck 2 siblings, 1 reply; 9+ messages in thread From: Guenter Roeck @ 2023-08-09 5:36 UTC (permalink / raw) To: Tony Lindgren Cc: Greg Kroah-Hartman, Jiri Slaby, Andy Shevchenko, Andy Shevchenko, Dhruva Gole, Ilpo Järvinen, John Ogness, Johan Hovold, Sebastian Andrzej Siewior, Vignesh Raghavendra, linux-kernel, linux-serial, Guenter Roeck On 8/8/23 22:26, Tony Lindgren wrote: > Hi, > > * Guenter Roeck <linux@roeck-us.net> [230806 13:19]: >> On Sun, Aug 06, 2023 at 09:20:50AM +0300, Tony Lindgren wrote: >>> Guenter reports boot issues with duplicate sysfs entries for multiport >>> drivers. Let's go back to using port->line for now to fix the regression. >>> >>> With this change, the serial core port device names are not correct for the >>> hardware specific 8250 single port drivers, but that's a cosmetic issue for >>> now. >>> >>> Fixes: d962de6ae51f ("serial: core: Fix serial core port id to not use port->line") >>> Reported-by: Guenter Roeck <groeck7@gmail.com> >>> Signed-off-by: Tony Lindgren <tony@atomide.com> >> >> Tested-by: Guenter Roeck <linux@roeck-us.net> > > Thanks for testing. > > Guenter, care to also test the patch below on top of this fix and > see if things still behave for you? > Queued. We should have test results sometime tomorrow. Guenter ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] serial: core: Revert port_id use 2023-08-09 5:36 ` Guenter Roeck @ 2023-08-09 5:37 ` Tony Lindgren 0 siblings, 0 replies; 9+ messages in thread From: Tony Lindgren @ 2023-08-09 5:37 UTC (permalink / raw) To: Guenter Roeck Cc: Greg Kroah-Hartman, Jiri Slaby, Andy Shevchenko, Andy Shevchenko, Dhruva Gole, Ilpo Järvinen, John Ogness, Johan Hovold, Sebastian Andrzej Siewior, Vignesh Raghavendra, linux-kernel, linux-serial, Guenter Roeck * Guenter Roeck <linux@roeck-us.net> [230809 05:36]: > On 8/8/23 22:26, Tony Lindgren wrote: > > Hi, > > > > * Guenter Roeck <linux@roeck-us.net> [230806 13:19]: > > > On Sun, Aug 06, 2023 at 09:20:50AM +0300, Tony Lindgren wrote: > > > > Guenter reports boot issues with duplicate sysfs entries for multiport > > > > drivers. Let's go back to using port->line for now to fix the regression. > > > > > > > > With this change, the serial core port device names are not correct for the > > > > hardware specific 8250 single port drivers, but that's a cosmetic issue for > > > > now. > > > > > > > > Fixes: d962de6ae51f ("serial: core: Fix serial core port id to not use port->line") > > > > Reported-by: Guenter Roeck <groeck7@gmail.com> > > > > Signed-off-by: Tony Lindgren <tony@atomide.com> > > > > > > Tested-by: Guenter Roeck <linux@roeck-us.net> > > > > Thanks for testing. > > > > Guenter, care to also test the patch below on top of this fix and > > see if things still behave for you? > > > > Queued. We should have test results sometime tomorrow. OK great. Thanks, Tony ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] serial: core: Revert port_id use 2023-08-09 5:26 ` Tony Lindgren 2023-08-09 5:33 ` Dhruva Gole 2023-08-09 5:36 ` Guenter Roeck @ 2023-08-09 21:16 ` Guenter Roeck 2023-08-10 7:00 ` Tony Lindgren 2 siblings, 1 reply; 9+ messages in thread From: Guenter Roeck @ 2023-08-09 21:16 UTC (permalink / raw) To: Tony Lindgren Cc: Greg Kroah-Hartman, Jiri Slaby, Andy Shevchenko, Andy Shevchenko, Dhruva Gole, Ilpo Järvinen, John Ogness, Johan Hovold, Sebastian Andrzej Siewior, Vignesh Raghavendra, linux-kernel, linux-serial, Guenter Roeck On 8/8/23 22:26, Tony Lindgren wrote: > Hi, > > * Guenter Roeck <linux@roeck-us.net> [230806 13:19]: >> On Sun, Aug 06, 2023 at 09:20:50AM +0300, Tony Lindgren wrote: >>> Guenter reports boot issues with duplicate sysfs entries for multiport >>> drivers. Let's go back to using port->line for now to fix the regression. >>> >>> With this change, the serial core port device names are not correct for the >>> hardware specific 8250 single port drivers, but that's a cosmetic issue for >>> now. >>> >>> Fixes: d962de6ae51f ("serial: core: Fix serial core port id to not use port->line") >>> Reported-by: Guenter Roeck <groeck7@gmail.com> >>> Signed-off-by: Tony Lindgren <tony@atomide.com> >> >> Tested-by: Guenter Roeck <linux@roeck-us.net> > > Thanks for testing. > > Guenter, care to also test the patch below on top of this fix and > see if things still behave for you? > > I'll send a proper patch assuming things test fine. > Patch below works for me. Tested-by: Guenter Roeck <linux@roeck-us.net> Guenter > Regagrds, > > Tony > > 8< -------------------- > diff --git a/drivers/tty/serial/serial_base.h b/drivers/tty/serial/serial_base.h > --- a/drivers/tty/serial/serial_base.h > +++ b/drivers/tty/serial/serial_base.h > @@ -16,6 +16,7 @@ struct device; > > struct serial_ctrl_device { > struct device dev; > + struct ida ida; > }; > > struct serial_port_device { > diff --git a/drivers/tty/serial/serial_base_bus.c b/drivers/tty/serial/serial_base_bus.c > --- a/drivers/tty/serial/serial_base_bus.c > +++ b/drivers/tty/serial/serial_base_bus.c > @@ -10,6 +10,7 @@ > > #include <linux/container_of.h> > #include <linux/device.h> > +#include <linux/idr.h> > #include <linux/module.h> > #include <linux/serial_core.h> > #include <linux/slab.h> > @@ -112,6 +113,8 @@ struct serial_ctrl_device *serial_base_ctrl_add(struct uart_port *port, > if (!ctrl_dev) > return ERR_PTR(-ENOMEM); > > + ida_init(&ctrl_dev->ida); > + > err = serial_base_device_init(port, &ctrl_dev->dev, > parent, &serial_ctrl_type, > serial_base_ctrl_release, > @@ -142,16 +145,31 @@ struct serial_port_device *serial_base_port_add(struct uart_port *port, > struct serial_ctrl_device *ctrl_dev) > { > struct serial_port_device *port_dev; > + unsigned int min = 0, max = ~0U; > int err; > > port_dev = kzalloc(sizeof(*port_dev), GFP_KERNEL); > if (!port_dev) > return ERR_PTR(-ENOMEM); > > + /* Device driver specified port_id vs automatic assignment? */ > + if (port->port_id) { > + min = port->port_id; > + max = port->port_id; > + } > + > + err = ida_alloc_range(&ctrl_dev->ida, min, max, GFP_KERNEL); > + if (err < 0) { > + kfree(port_dev); > + return ERR_PTR(err); > + } > + > + port->port_id = err; > + > err = serial_base_device_init(port, &port_dev->dev, > &ctrl_dev->dev, &serial_port_type, > serial_base_port_release, > - port->ctrl_id, port->line); > + port->ctrl_id, port->port_id); > if (err) > goto err_put_device; > > @@ -165,16 +183,24 @@ struct serial_port_device *serial_base_port_add(struct uart_port *port, > > err_put_device: > put_device(&port_dev->dev); > + ida_free(&ctrl_dev->ida, port->port_id); > > return ERR_PTR(err); > } > > void serial_base_port_device_remove(struct serial_port_device *port_dev) > { > + struct serial_ctrl_device *ctrl_dev; > + struct device *parent; > + > if (!port_dev) > return; > > + parent = port_dev->dev.parent; > + ctrl_dev = to_serial_base_ctrl_device(parent); > + > device_del(&port_dev->dev); > + ida_free(&ctrl_dev->ida, port_dev->port->port_id); > put_device(&port_dev->dev); > } > ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] serial: core: Revert port_id use 2023-08-09 21:16 ` Guenter Roeck @ 2023-08-10 7:00 ` Tony Lindgren 0 siblings, 0 replies; 9+ messages in thread From: Tony Lindgren @ 2023-08-10 7:00 UTC (permalink / raw) To: Guenter Roeck Cc: Greg Kroah-Hartman, Jiri Slaby, Andy Shevchenko, Andy Shevchenko, Dhruva Gole, Ilpo Järvinen, John Ogness, Johan Hovold, Sebastian Andrzej Siewior, Vignesh Raghavendra, linux-kernel, linux-serial, Guenter Roeck * Guenter Roeck <linux@roeck-us.net> [230809 21:17]: > On 8/8/23 22:26, Tony Lindgren wrote: > > Guenter, care to also test the patch below on top of this fix and > > see if things still behave for you? > > > > I'll send a proper patch assuming things test fine. > > > > Patch below works for me. OK good to hear thanks, patch posted at [0] below. Regards, Tony [0] https://lore.kernel.org/linux-serial/20230810065737.47294-1-tony@atomide.com/T/#u ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2023-08-10 7:00 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-08-06 6:20 [PATCH] serial: core: Revert port_id use Tony Lindgren 2023-08-06 13:19 ` Guenter Roeck 2023-08-09 5:26 ` Tony Lindgren 2023-08-09 5:33 ` Dhruva Gole 2023-08-09 5:41 ` Tony Lindgren 2023-08-09 5:36 ` Guenter Roeck 2023-08-09 5:37 ` Tony Lindgren 2023-08-09 21:16 ` Guenter Roeck 2023-08-10 7:00 ` Tony Lindgren
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).