Message ID | 20230806062052.47737-1-tony@atomide.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp786440vqr; Sat, 5 Aug 2023 23:24:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IED4GpTc7ZJRQVYmvP36JnC3fTEXkNgNbt8cN9ufjHT0uOJkJhet/QQfbPIBuUeTvvvE5jK X-Received: by 2002:a05:6402:104a:b0:522:b112:6254 with SMTP id e10-20020a056402104a00b00522b1126254mr4578602edu.4.1691303070602; Sat, 05 Aug 2023 23:24:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691303070; cv=none; d=google.com; s=arc-20160816; b=Hg8bAQrUA9I5MV1e5dzHp45pWl0oGbt8zbVJAdn+MnHPs+hvLGuryc6Y6sSEoAa39b 1izYVeF2vl/XUdzc3FrB/tGSbLb9TpypSSnJC7Ftow0kiobzDqtjU0vZY/aqfUOiUjBX PYW1PGHQwlWrwpVc5Za2qJ7UfWpQ5lKF1FAjjkFw3A/ue/hH4Ruetz9f4oY6W4EDaGvU G1yeVsF51J7JEH1hl8EpjHlZmbWI8Z0Fg680b5vwjVZglUTlk/7qne1htcLg8d7vs/Jh WDXfQOPpm/L/ic26vNtmTenEWU2UYPsH9p1DxhZZZgwPIJjnJHiTir7nrusjqzQiwcm4 K/4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=u94z/KwztownUlkNEwaA6LJqkKu81gvscsuMNIW0e2w=; fh=9vvjMImc+CdpIXDXFkpgV6wGtjCqyXV1Lpr5uI9P1wc=; b=jvpq2DZLsISQB0yMYAmpjBS1pVcgGomGZQEi9H6FGG36olP/jMfz+gO3lpFVVAk/A6 udOHl+zU80Jp6q81XYbRcfqp54LFw2RC3VteacDizJw1I3Mso8qQjknaD9+VrZnWtbDn R87tZEPdtopB64E6d2NSdjxd2uJKwdt2SgARMmBI8HOGs2JKe3IZ1aVMb465T37gtdrB QsC4Mz0UuWSmMT6FcDQNqWomfxnkLaVoizj9qIC2j8VbeXFAISvPNZKjj18eVrUyoaHC dGPAB8kk17uW3pYdIJUAtf9k2JemxHwfvT/9vPUaWKNEbsnWrpV02NX7wBBCQSvbxw7P bP0A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l14-20020aa7c30e000000b0052335100b2bsi560663edq.477.2023.08.05.23.24.04; Sat, 05 Aug 2023 23:24:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229544AbjHFGVH (ORCPT <rfc822;david.simonyants@gmail.com> + 99 others); Sun, 6 Aug 2023 02:21:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbjHFGVG (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 6 Aug 2023 02:21:06 -0400 Received: from muru.com (muru.com [72.249.23.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3028A1FCF; Sat, 5 Aug 2023 23:21:02 -0700 (PDT) Received: from hillo.muru.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTP id 50ECA80A0; Sun, 6 Aug 2023 06:20:59 +0000 (UTC) From: Tony Lindgren <tony@atomide.com> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Jiri Slaby <jirislaby@kernel.org>, Andy Shevchenko <andriy.shevchenko@linux.intel.com> Cc: Andy Shevchenko <andriy.shevchenko@intel.com>, Dhruva Gole <d-gole@ti.com>, =?utf-8?q?Ilpo_J=C3=A4rvinen?= <ilpo.jarvinen@linux.intel.com>, John Ogness <john.ogness@linutronix.de>, Johan Hovold <johan@kernel.org>, Sebastian Andrzej Siewior <bigeasy@linutronix.de>, Vignesh Raghavendra <vigneshr@ti.com>, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Guenter Roeck <groeck7@gmail.com> Subject: [PATCH] serial: core: Revert port_id use Date: Sun, 6 Aug 2023 09:20:50 +0300 Message-ID: <20230806062052.47737-1-tony@atomide.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773459808544188304 X-GMAIL-MSGID: 1773459808544188304 |
Series |
serial: core: Revert port_id use
|
|
Commit Message
Tony Lindgren
Aug. 6, 2023, 6:20 a.m. UTC
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(-)
Comments
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
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); }
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
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
* 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
* 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
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); > } >
* 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
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;