From patchwork Mon Aug 7 21:45:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hugo Villeneuve X-Patchwork-Id: 132456 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp1765193vqr; Mon, 7 Aug 2023 16:15:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE5rQMsF7Je729Tzu1+c933FGYWqduiWFxJaZsQGVkRoE7GSaYLC4UYs4PDhLloZiCaqXd5 X-Received: by 2002:a17:906:3286:b0:99b:c1af:17ea with SMTP id 6-20020a170906328600b0099bc1af17eamr10087573ejw.15.1691450141182; Mon, 07 Aug 2023 16:15:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691450141; cv=none; d=google.com; s=arc-20160816; b=Y4qIftkXN095nizqRKfmHBrWRTFEJ9dqbheKtfoJVgNYgPO4v0JQAMlbkoVrC8AhSZ r2pVEI5M94S/+kp9Ak2x50tu+LHab60nW6IEP++mcvamKnIe24nJwRlK/V/Ns1J2mHCq eiL344na5C5ZrL7esm5Hx1smk8DHBlifIU9IuG54LKW3Dgv6ZPY1pQZEyF5CrxymOWvn eQKCymnxgOZJsq9aqaQZr1uLC0cHw5NTdXiwzFKN/ltWJxxNVSH4TMwkYzO3SqR9fnyf AEHvTNVN9up/7HhEfMLi6v609lSrv/BaOyL9CTpCjLY3EtE1C9jphYhfVFdpSDg5TqBi RSwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:cc:to:from:dkim-signature; bh=GoDQfDkJ+cbhbljlT8yvH1LI+rTJZfA1Q3+3WKSspk0=; fh=rA5ZL3pE2Nx+AQMYlYgPGmEcJAxlI2Jmd7haO+z+CXk=; b=naxFv8nwpMWHRvjsU+yCyTTq4fMtXrHsfcaPc+k6gGelPO/w3FWUYlUy8IX8sUsK7z bNg3RBwKr6mENL7iNMA54zDqHwQvrsodM0uMFRy+/i7CYlMPF6y3Lc8oOo0EYZi1rjJR 9M49mFiibz5WTIzHJlxjfNd+C0y5fCxNvq0zX1vfJ047lu1hDrAesZNK02kGiLIUZXFN msrGQVClueYAYeB3HPUej51hLgkTvSOvrtPyuxbYGb0AtiaLtJYDIG8mIAuhdJ1lsOcU CKtYNhAFbxBtdFOrgQhHSxukQ2483lUMYXygdg/+Clp0VCkeKe4BLiRNxidG8BpA8aE1 Vo1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=KC9CGPIk; 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 la15-20020a170906ad8f00b009889cad765dsi4999024ejb.352.2023.08.07.16.15.15; Mon, 07 Aug 2023 16:15:41 -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; dkim=pass header.i=@hugovil.com header.s=x header.b=KC9CGPIk; 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 S230142AbjHGVqX (ORCPT + 99 others); Mon, 7 Aug 2023 17:46:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229615AbjHGVqQ (ORCPT ); Mon, 7 Aug 2023 17:46:16 -0400 Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FE2B10DE; Mon, 7 Aug 2023 14:46:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=hugovil.com ; s=x; h=Subject:Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Cc:To :From:subject:date:message-id:reply-to; bh=GoDQfDkJ+cbhbljlT8yvH1LI+rTJZfA1Q3+3WKSspk0=; b=KC9CGPIkwT2wAQfn1E+rHnTdmI VEydOVp2Cy6KSoy1nKw23Ql29LiaGW96iw/BRjK7BFvLuiSt32aHFC0fsLcAU08jb63m05DPVCOaO aAgtaV6SB635nqMRDYyQPp/oamN03u0VUNfEjMmLuSL6zIPmQrfBTeM1ha89ay8ejhsU=; Received: from modemcable061.19-161-184.mc.videotron.ca ([184.161.19.61]:47088 helo=localhost.localdomain) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1qT83E-0000hD-Av; Mon, 07 Aug 2023 17:46:09 -0400 From: Hugo Villeneuve To: gregkh@linuxfoundation.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, jirislaby@kernel.org, jringle@gridpoint.com, tomasz.mon@camlingroup.com, l.perczak@camlintechnologies.com Cc: linux-serial@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, hugo@hugovil.com, linux-gpio@vger.kernel.org, Hugo Villeneuve , stable@vger.kernel.org, =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Lech Perczak Date: Mon, 7 Aug 2023 17:45:51 -0400 Message-Id: <20230807214556.540627-2-hugo@hugovil.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230807214556.540627-1-hugo@hugovil.com> References: <20230807214556.540627-1-hugo@hugovil.com> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 184.161.19.61 X-SA-Exim-Mail-From: hugo@hugovil.com X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 Subject: [PATCH v10 1/6] serial: sc16is7xx: fix broken port 0 uart init X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.hugovil.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773614023044726736 X-GMAIL-MSGID: 1773614023044726736 From: Hugo Villeneuve The sc16is7xx_config_rs485() function is called only for the second port (index 1, channel B), causing initialization problems for the first port. For the sc16is7xx driver, port->membase and port->mapbase are not set, and their default values are 0. And we set port->iobase to the device index. This means that when the first device is registered using the uart_add_one_port() function, the following values will be in the port structure: port->membase = 0 port->mapbase = 0 port->iobase = 0 Therefore, the function uart_configure_port() in serial_core.c will exit early because of the following check: /* * If there isn't a port here, don't do anything further. */ if (!port->iobase && !port->mapbase && !port->membase) return; Typically, I2C and SPI drivers do not set port->membase and port->mapbase. The max310x driver sets port->membase to ~0 (all ones). By implementing the same change in this driver, uart_configure_port() is now correctly executed for all ports. Fixes: dfeae619d781 ("serial: sc16is7xx") Cc: Signed-off-by: Hugo Villeneuve Reviewed-by: Ilpo Järvinen Reviewed-by: Lech Perczak Tested-by: Lech Perczak --- drivers/tty/serial/sc16is7xx.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index 18a48ce052c2..ffe817309413 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -1438,6 +1438,12 @@ static int sc16is7xx_probe(struct device *dev, s->p[i].port.fifosize = SC16IS7XX_FIFO_SIZE; s->p[i].port.flags = UPF_FIXED_TYPE | UPF_LOW_LATENCY; s->p[i].port.iobase = i; + /* + * Use all ones as membase to make sure uart_configure_port() in + * serial_core.c does not abort for SPI/I2C devices where the + * membase address is not applicable. + */ + s->p[i].port.membase = (void __iomem *)~0; s->p[i].port.iotype = UPIO_PORT; s->p[i].port.uartclk = freq; s->p[i].port.rs485_config = sc16is7xx_config_rs485;