Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp5164085rwb; Tue, 8 Aug 2023 22:47:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHWscBTpAiY8vK9/RL3Ia96SVDkSCIre4HWQAh8+FNCWOHIQIXzvbKPLh5g7gMCleSFYFdt X-Received: by 2002:a17:902:8308:b0:1bb:c7e1:b43 with SMTP id bd8-20020a170902830800b001bbc7e10b43mr1557737plb.14.1691560052279; Tue, 08 Aug 2023 22:47:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691560052; cv=none; d=google.com; s=arc-20160816; b=tC5fGqXcMw8SLUG25uywAWPH0ot8yfMwO5XprGU5TBbTBkuJ0GLwYhy6lzqEsX1UIi Tj7MNF/2WacoS56K7qaOoEmCpLdEXx1egQjmXKpk4l7m9+EVW0I2J0Pb6mTZf+34QEeb 4C48+uhOgUWqUrCGvb0xjp+MIl3d1pFF0lQpJ/v099NcTnniFLX8W71hfhnQIoEr9ZtG r9DvDOXzvXZTB/iA2x2CE0bwMc0wJkpItY65o5r7rr4/+/NFUe0F2moWR+8HYDf+isHA 9Q4Tt1U9GhiTH/ZDS/gDxInJDvQe0LtKMhd/svV3ocuTQUVDN8gSakbujEknVD4aWsk6 IcyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=MvUcbk2XVqvWNgLisQGI8SXkscpdWHVXPKMKnSMvqwU=; fh=cJEgGxM+CunKPJZSE0rUPcdmFXWhZFdzxwqqqL6eWMQ=; b=rS8HxdmKQ8MIT1H/gAtOafidguYu1vf8kLWuilMBr84cJiUVYUZQYWGPLXpibWo4XO kqOIsem9ONqzM/CBYjB5T3fyC4ZYkyDVppp2pMra56geY+Hvm8AuoXJeIrPnLbz9GItn rysnt/PK72cB3j+/YgPwKkS0D3p+l+M9iAVbyQQiNvIMc9hoCxs2/0MnXsuBP69QJkDL X+RapQ7vzoh+9rGKRP+ye7dKVPAnO1foNZFgoLSYeOg22bYSVsyP5rWbIApAZEpceP6+ vME6uZtfJlF1KixRZJNqr4W9SfqapsZ0aEj1TlBDb1nydjpX1b9ApW69ONeTHoSBHmHh D8yQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c4-20020a170902d90400b001bba53994acsi5879369plz.243.2023.08.08.22.47.20; Tue, 08 Aug 2023 22:47:32 -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 S229545AbjHIF05 (ORCPT + 99 others); Wed, 9 Aug 2023 01:26:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229459AbjHIF0y (ORCPT ); Wed, 9 Aug 2023 01:26:54 -0400 Received: from muru.com (muru.com [72.249.23.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 41C621BCE; Tue, 8 Aug 2023 22:26:53 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTPS id 51B6A80AF; Wed, 9 Aug 2023 05:26:52 +0000 (UTC) Date: Wed, 9 Aug 2023 08:26:50 +0300 From: Tony Lindgren To: Guenter Roeck Cc: Greg Kroah-Hartman , Jiri Slaby , Andy Shevchenko , Andy Shevchenko , Dhruva Gole , Ilpo =?utf-8?B?SsOkcnZpbmVu?= , John Ogness , Johan Hovold , Sebastian Andrzej Siewior , Vignesh Raghavendra , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Guenter Roeck Subject: Re: [PATCH] serial: core: Revert port_id use Message-ID: <20230809052650.GT14799@atomide.com> References: <20230806062052.47737-1-tony@atomide.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,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: X-Mailing-List: linux-kernel@vger.kernel.org Hi, * Guenter Roeck [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 > > Signed-off-by: Tony Lindgren > > Tested-by: Guenter Roeck 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 #include +#include #include #include #include @@ -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