linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] serial: core: Fix serial core port id to not use port->line
@ 2023-07-19  5:12 Tony Lindgren
  2023-07-19  5:26 ` Jiri Slaby
  2023-07-19  5:28 ` Andy Shevchenko
  0 siblings, 2 replies; 6+ messages in thread
From: Tony Lindgren @ 2023-07-19  5:12 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-omap, linux-serial, linux-kernel

The serial core port id should be serial core controller specific port
instance, which is not always the port->line index.

For example, 8250 driver maps a number of legacy ports, and when a
hardware specific device driver takes over, we typically have one
driver instance for each port. Let's instead add port->port_id to
keep track serial ports mapped to each serial core controller instance.

Currently this is only a cosmetic issue for the serial core port device
names. The issue can be noticed looking at /sys/bus/serial-base/devices
for example though. Let's fix the issue to avoid port addressing issues
later on.

Fixes: 84a9582fd203 ("serial: core: Start managing serial controllers to enable runtime PM")
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/tty/serial/8250/8250_core.c  | 2 ++
 drivers/tty/serial/serial_base_bus.c | 2 +-
 include/linux/serial_core.h          | 1 +
 3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -497,6 +497,7 @@ static struct uart_8250_port *serial8250_setup_port(int index)
 
 	up = &serial8250_ports[index];
 	up->port.line = index;
+	up->port.port_id = index;
 
 	serial8250_init_port(up);
 	if (!base_ops)
@@ -1040,6 +1041,7 @@ int serial8250_register_8250_port(const struct uart_8250_port *up)
 			uart_remove_one_port(&serial8250_reg, &uart->port);
 
 		uart->port.ctrl_id	= up->port.ctrl_id;
+		uart->port.port_id	= up->port.port_id;
 		uart->port.iobase       = up->port.iobase;
 		uart->port.membase      = up->port.membase;
 		uart->port.irq          = up->port.irq;
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
@@ -136,7 +136,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->line);
+				      port->port_id);
 	if (err)
 		goto err_put_device;
 
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -460,6 +460,7 @@ struct uart_port {
 	int			(*iso7816_config)(struct uart_port *,
 						  struct serial_iso7816 *iso7816);
 	int			ctrl_id;		/* optional serial core controller id */
+	int			port_id;		/* optional serial core port id */
 	unsigned int		irq;			/* irq number */
 	unsigned long		irqflags;		/* irq flags  */
 	unsigned int		uartclk;		/* base uart clock */
-- 
2.41.0

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] serial: core: Fix serial core port id to not use port->line
  2023-07-19  5:12 [PATCH] serial: core: Fix serial core port id to not use port->line Tony Lindgren
@ 2023-07-19  5:26 ` Jiri Slaby
  2023-07-19  5:34   ` Andy Shevchenko
  2023-07-19  5:28 ` Andy Shevchenko
  1 sibling, 1 reply; 6+ messages in thread
From: Jiri Slaby @ 2023-07-19  5:26 UTC (permalink / raw)
  To: Tony Lindgren, Greg Kroah-Hartman, Andy Shevchenko
  Cc: Andy Shevchenko, Dhruva Gole, Ilpo Järvinen, John Ogness,
	Johan Hovold, Sebastian Andrzej Siewior, Vignesh Raghavendra,
	linux-omap, linux-serial, linux-kernel

On 19. 07. 23, 7:12, Tony Lindgren wrote:
> The serial core port id should be serial core controller specific port
> instance, which is not always the port->line index.
> 
> For example, 8250 driver maps a number of legacy ports, and when a
> hardware specific device driver takes over, we typically have one
> driver instance for each port. Let's instead add port->port_id to
> keep track serial ports mapped to each serial core controller instance.
> 
> Currently this is only a cosmetic issue for the serial core port device
> names. The issue can be noticed looking at /sys/bus/serial-base/devices
> for example though. Let's fix the issue to avoid port addressing issues
> later on.

...
> --- a/include/linux/serial_core.h
> +++ b/include/linux/serial_core.h
> @@ -460,6 +460,7 @@ struct uart_port {
>   	int			(*iso7816_config)(struct uart_port *,
>   						  struct serial_iso7816 *iso7816);
>   	int			ctrl_id;		/* optional serial core controller id */
> +	int			port_id;		/* optional serial core port id */

Can the id be negative? If not, please use uint.

thanks,
-- 
js
suse labs


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] serial: core: Fix serial core port id to not use port->line
  2023-07-19  5:12 [PATCH] serial: core: Fix serial core port id to not use port->line Tony Lindgren
  2023-07-19  5:26 ` Jiri Slaby
@ 2023-07-19  5:28 ` Andy Shevchenko
  1 sibling, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2023-07-19  5:28 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Greg Kroah-Hartman, Jiri Slaby, Dhruva Gole, Ilpo Järvinen,
	John Ogness, Johan Hovold, Sebastian Andrzej Siewior,
	Vignesh Raghavendra, linux-omap, linux-serial, linux-kernel

On Wed, Jul 19, 2023 at 08:12:33AM +0300, Tony Lindgren wrote:
> The serial core port id should be serial core controller specific port
> instance, which is not always the port->line index.
> 
> For example, 8250 driver maps a number of legacy ports, and when a
> hardware specific device driver takes over, we typically have one
> driver instance for each port. Let's instead add port->port_id to
> keep track serial ports mapped to each serial core controller instance.
> 
> Currently this is only a cosmetic issue for the serial core port device
> names. The issue can be noticed looking at /sys/bus/serial-base/devices
> for example though. Let's fix the issue to avoid port addressing issues
> later on.

Good catch!
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> Fixes: 84a9582fd203 ("serial: core: Start managing serial controllers to enable runtime PM")
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---
>  drivers/tty/serial/8250/8250_core.c  | 2 ++
>  drivers/tty/serial/serial_base_bus.c | 2 +-
>  include/linux/serial_core.h          | 1 +
>  3 files changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
> --- a/drivers/tty/serial/8250/8250_core.c
> +++ b/drivers/tty/serial/8250/8250_core.c
> @@ -497,6 +497,7 @@ static struct uart_8250_port *serial8250_setup_port(int index)
>  
>  	up = &serial8250_ports[index];
>  	up->port.line = index;
> +	up->port.port_id = index;
>  
>  	serial8250_init_port(up);
>  	if (!base_ops)
> @@ -1040,6 +1041,7 @@ int serial8250_register_8250_port(const struct uart_8250_port *up)
>  			uart_remove_one_port(&serial8250_reg, &uart->port);
>  
>  		uart->port.ctrl_id	= up->port.ctrl_id;
> +		uart->port.port_id	= up->port.port_id;
>  		uart->port.iobase       = up->port.iobase;
>  		uart->port.membase      = up->port.membase;
>  		uart->port.irq          = up->port.irq;
> 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
> @@ -136,7 +136,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->line);
> +				      port->port_id);
>  	if (err)
>  		goto err_put_device;
>  
> diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
> --- a/include/linux/serial_core.h
> +++ b/include/linux/serial_core.h
> @@ -460,6 +460,7 @@ struct uart_port {
>  	int			(*iso7816_config)(struct uart_port *,
>  						  struct serial_iso7816 *iso7816);
>  	int			ctrl_id;		/* optional serial core controller id */
> +	int			port_id;		/* optional serial core port id */
>  	unsigned int		irq;			/* irq number */
>  	unsigned long		irqflags;		/* irq flags  */
>  	unsigned int		uartclk;		/* base uart clock */
> -- 
> 2.41.0

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] serial: core: Fix serial core port id to not use port->line
  2023-07-19  5:26 ` Jiri Slaby
@ 2023-07-19  5:34   ` Andy Shevchenko
  2023-07-19  5:37     ` Jiri Slaby
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2023-07-19  5:34 UTC (permalink / raw)
  To: Jiri Slaby
  Cc: Tony Lindgren, Greg Kroah-Hartman, Dhruva Gole,
	Ilpo Järvinen, John Ogness, Johan Hovold,
	Sebastian Andrzej Siewior, Vignesh Raghavendra, linux-omap,
	linux-serial, linux-kernel

On Wed, Jul 19, 2023 at 07:26:41AM +0200, Jiri Slaby wrote:
> On 19. 07. 23, 7:12, Tony Lindgren wrote:

...

> >   	int			ctrl_id;		/* optional serial core controller id */
> > +	int			port_id;		/* optional serial core port id */
> 
> Can the id be negative? If not, please use uint.

Does this suggestion apply to ctrl_id as well?

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] serial: core: Fix serial core port id to not use port->line
  2023-07-19  5:34   ` Andy Shevchenko
@ 2023-07-19  5:37     ` Jiri Slaby
  2023-07-19  5:50       ` Tony Lindgren
  0 siblings, 1 reply; 6+ messages in thread
From: Jiri Slaby @ 2023-07-19  5:37 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Tony Lindgren, Greg Kroah-Hartman, Dhruva Gole,
	Ilpo Järvinen, John Ogness, Johan Hovold,
	Sebastian Andrzej Siewior, Vignesh Raghavendra, linux-omap,
	linux-serial, linux-kernel

On 19. 07. 23, 7:34, Andy Shevchenko wrote:
> On Wed, Jul 19, 2023 at 07:26:41AM +0200, Jiri Slaby wrote:
>> On 19. 07. 23, 7:12, Tony Lindgren wrote:
> 
> ...
> 
>>>    	int			ctrl_id;		/* optional serial core controller id */
>>> +	int			port_id;		/* optional serial core port id */
>>
>> Can the id be negative? If not, please use uint.
> 
> Does this suggestion apply to ctrl_id as well?

Sure, but he hasn't added it in this series ;). So it should go to 
someone's todo :P.

-- 
js
suse labs


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] serial: core: Fix serial core port id to not use port->line
  2023-07-19  5:37     ` Jiri Slaby
@ 2023-07-19  5:50       ` Tony Lindgren
  0 siblings, 0 replies; 6+ messages in thread
From: Tony Lindgren @ 2023-07-19  5:50 UTC (permalink / raw)
  To: Jiri Slaby
  Cc: Andy Shevchenko, Greg Kroah-Hartman, Dhruva Gole,
	Ilpo Järvinen, John Ogness, Johan Hovold,
	Sebastian Andrzej Siewior, Vignesh Raghavendra, linux-omap,
	linux-serial, linux-kernel

* Jiri Slaby <jirislaby@kernel.org> [230719 05:37]:
> On 19. 07. 23, 7:34, Andy Shevchenko wrote:
> > On Wed, Jul 19, 2023 at 07:26:41AM +0200, Jiri Slaby wrote:
> > > On 19. 07. 23, 7:12, Tony Lindgren wrote:
> > 
> > ...
> > 
> > > >    	int			ctrl_id;		/* optional serial core controller id */
> > > > +	int			port_id;		/* optional serial core port id */
> > > 
> > > Can the id be negative? If not, please use uint.
> > 
> > Does this suggestion apply to ctrl_id as well?
> 
> Sure, but he hasn't added it in this series ;). So it should go to someone's
> todo :P.

Yes it can be uint, that's left over from some earlier revision where -ENODEV
was used, will fix that too.

Regards,

Tony

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-07-19  5:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-19  5:12 [PATCH] serial: core: Fix serial core port id to not use port->line Tony Lindgren
2023-07-19  5:26 ` Jiri Slaby
2023-07-19  5:34   ` Andy Shevchenko
2023-07-19  5:37     ` Jiri Slaby
2023-07-19  5:50       ` Tony Lindgren
2023-07-19  5:28 ` Andy Shevchenko

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).