From patchwork Fri Aug 4 12:35:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Lindgren X-Patchwork-Id: 131168 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:44a:b0:3f2:4152:657d with SMTP id ez10csp255486vqb; Fri, 4 Aug 2023 06:17:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFOtrCaVA1NbVru8IBWDKIoX+3+rbri2k52dqmmUMC5g/xIQBm0w8Sgmy4jbmLcuIigXxIA X-Received: by 2002:aa7:da95:0:b0:522:37ca:a51c with SMTP id q21-20020aa7da95000000b0052237caa51cmr1236759eds.40.1691155021409; Fri, 04 Aug 2023 06:17:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691155021; cv=none; d=google.com; s=arc-20160816; b=HmWFUwWS7t/fWS73lmhlBxxVU/1nIjI8yCl9XoUptCNbHhOUTxq7dtkcQYo/oUvb/y hG1PWo9JToIBtuzap+xJZwZLeUTMm1kS1uWv9xpQTyscgRvDYHzekQNG+md9co4vZDLs B2J8rmh7NsPlFFUkyqqbm4Fz1mnDS5Y3Pz5xfGEuIp4AqLBjx5hqvX8413O95W/53GdL nIjoclnzHq4YtgzCD8iKqtUWC285MHcF23mK0nL8/qhXDNiAqbncgFJ7Qqm5C08N3tD7 oYnduFqTxU9w3abSw/Znc23mAU9SqR+wmOUBE0Ah2SWE7eTojCD3MA9VqjFhVIoBKVPG blzw== 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=+9Cz22BQmxcJSvvLidHSCoBB61UhzhsmMF2lEUg6rcU=; fh=wxWR7S7XHVlqVIuoke4G1/IBIqVMAhyap/qryV8BrCQ=; b=x9acQ2pLnS+d+i+N3UUm12g8UkWZf0H9NZjD0u/QYc4T4o7Ee3AZ/mEvXyIlCVX9l9 AmgEkX3drkNWamA7WOfBdYGo6zmihM9iXPz0FoBKNP3Y3+ejdCMbND1KdBgLvekzjV/z hdshyBHXeEnBs06tUohq66l4Gxze/yCTMJHhXXfpIy6R2kQuTv9+Xp53ozs3f44pHXCr JFr3/1vHoPborRgjUPvqhiYRGPRvMSajFF2Vfazz0HHatJYbxVzoU+TJkUOEfZat3zCY CMKciyjeths4NwDmKIbrsfOzhJnfMkZqxZY4JoB3XPm41z+PJnsJvOhw9awdmRHkqP3D jHcw== 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 w1-20020a056402128100b0052239439e90si1572722edv.484.2023.08.04.06.16.21; Fri, 04 Aug 2023 06:17:01 -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 S229471AbjHDMgB (ORCPT + 99 others); Fri, 4 Aug 2023 08:36:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229476AbjHDMgA (ORCPT ); Fri, 4 Aug 2023 08:36:00 -0400 Received: from muru.com (muru.com [72.249.23.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DB41546B3; Fri, 4 Aug 2023 05:35:55 -0700 (PDT) Received: from hillo.muru.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTP id C0E8880F7; Fri, 4 Aug 2023 12:35:52 +0000 (UTC) From: Tony Lindgren To: Greg Kroah-Hartman , Jiri Slaby , Andy Shevchenko Cc: Andy Shevchenko , Dhruva Gole , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , John Ogness , Johan Hovold , Sebastian Andrzej Siewior , Vignesh Raghavendra , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Subject: [PATCH] serial: 8250: Reinit port_id when adding back serial8250_isa_devs Date: Fri, 4 Aug 2023 15:35:44 +0300 Message-ID: <20230804123546.25293-1-tony@atomide.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773304567725904649 X-GMAIL-MSGID: 1773304567725904649 After fixing the serial core port device to use port->port_id instead of port->line, unloading a hardware specific 8250 port driver started producing an error for "sysfs: cannot create duplicate filename". This is happening as we are wrongly initializing port->port_id to zero when adding back serial8250_isa_devs instances, and the serial8250:0.0 sysfs entry may already exist. For serial8250 devices, we typically have multiple devices mapped to a single driver instance. For the serial8250_isa_devs instances, the port->port_id is the same as port->line. Let's fix the issue by re-initializing port_id when adding back the serial8250_isa_devs instances in serial8250_unregister_port(). Fixes: d962de6ae51f ("serial: core: Fix serial core port id to not use port->line") Signed-off-by: Tony Lindgren Reviewed-by: Andy Shevchenko --- drivers/tty/serial/8250/8250_core.c | 1 + 1 file changed, 1 insertion(+) 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 @@ -1204,6 +1204,7 @@ void serial8250_unregister_port(int line) uart->port.flags &= ~UPF_BOOT_AUTOCONF; uart->port.type = PORT_UNKNOWN; uart->port.dev = &serial8250_isa_devs->dev; + uart->port.port_id = line; uart->capabilities = 0; serial8250_init_port(uart); serial8250_apply_quirks(uart);