From patchwork Fri Dec 23 04:23:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dominique Martinet X-Patchwork-Id: 636668 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ACAA6C4332F for ; Fri, 23 Dec 2022 04:24:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229989AbiLWEY3 (ORCPT ); Thu, 22 Dec 2022 23:24:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229851AbiLWEY2 (ORCPT ); Thu, 22 Dec 2022 23:24:28 -0500 Received: from gw.atmark-techno.com (gw.atmark-techno.com [13.115.124.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 041BD2331D for ; Thu, 22 Dec 2022 20:24:26 -0800 (PST) Received: from gw.atmark-techno.com (localhost [127.0.0.1]) by gw.atmark-techno.com (Postfix) with ESMTP id 9649C60111 for ; Fri, 23 Dec 2022 13:24:25 +0900 (JST) Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by gw.atmark-techno.com (Postfix) with ESMTPS id 7DEC460110 for ; Fri, 23 Dec 2022 13:24:24 +0900 (JST) Received: by mail-pj1-f70.google.com with SMTP id ep17-20020a17090ae65100b00219702c495cso2021421pjb.2 for ; Thu, 22 Dec 2022 20:24:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=mExlhL7podYny/5Su2GhXq0PviBDirh1lFZQGtUWeyw=; b=UbN+Y4/MJXxFCHGlEZFrnCeStxVsBrVA1pbZ4jyi86A5B2U2FgA5pDmw3KZ2uxHOB8 Kq3eUCDcAy3u6hdb6+vSmbjPMTvNkRRELKbEAzrzY/C1vJhXexBzkamfC3OTNatbBAgZ w6QSFnUz43nlYU+2lUK5Z7M5Hz7IA90P1cyTsmBDJKwHBpwph96H8HG8A0MORnvbmlya v9TW4BY9c/NXNlkANl9f4G4NqBBfOM3UC5E1PR2xh7Krp707g9tzRDxHTg7EIp2Am63y dG5UoOpm13SIcn7ITlDxCZboPiUd9okvGA72aYmSKRXD/b9ONKRbJcVLNnfGWWgwpLoz IU2w== X-Gm-Message-State: AFqh2kqgJ/SycXym2y0i0s4f8RqCnEUy9h0crK2BN36wUis50SDTtQOH 0Ig+NPDOCI/a7SCOHWfw6k28371b+Z0RJQUJPhemA7tGbpi+YF+C3BThtYiByIX3MM7cd7UvMSK lPIEi51roMw0aUPtTAGbajAFuQzaa X-Received: by 2002:a05:6a21:3a81:b0:af:767a:a7e1 with SMTP id zv1-20020a056a213a8100b000af767aa7e1mr29379254pzb.23.1671769463576; Thu, 22 Dec 2022 20:24:23 -0800 (PST) X-Google-Smtp-Source: AMrXdXt1FlZ3C2VhMVo3r2Yd9v3knmgxG7GjVVoybR1hniJopWb0sU07FLDVGTOADDndnQLYyBIFEg== X-Received: by 2002:a05:6a21:3a81:b0:af:767a:a7e1 with SMTP id zv1-20020a056a213a8100b000af767aa7e1mr29379229pzb.23.1671769463288; Thu, 22 Dec 2022 20:24:23 -0800 (PST) Received: from pc-zest.atmarktech (103.131.189.35.bc.googleusercontent.com. [35.189.131.103]) by smtp.gmail.com with ESMTPSA id c7-20020a63da07000000b004827ef5f0cdsm1459999pgh.50.2022.12.22.20.24.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Dec 2022 20:24:22 -0800 (PST) Received: from martinet by pc-zest.atmarktech with local (Exim 4.96) (envelope-from ) id 1p8ZbZ-00H7dA-2Q; Fri, 23 Dec 2022 13:24:21 +0900 From: Dominique Martinet To: Greg Kroah-Hartman , Jiri Slaby , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Lukas Wunner , Rasmus Villemoes Cc: Daisuke Mizobuchi , stable@vger.kernel.org, linux-serial@vger.kernel.org, Indan Zupancic , Dominique Martinet Subject: [PATCH 5.10 1/2] fsl_lpuart: Don't enable interrupts too early Date: Fri, 23 Dec 2022 13:23:53 +0900 Message-Id: <20221223042354.4080724-1-dominique.martinet@atmark-techno.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org From: Indan Zupancic [ Upstream commit 401fb66a355eb0f22096cf26864324f8e63c7d78 ] If an irq is pending when devm_request_irq() is called, the irq handler will cause a NULL pointer access because initialisation is not done yet. Fixes: 9d7ee0e28da59 ("tty: serial: lpuart: avoid report NULL interrupt") Cc: stable Signed-off-by: Indan Zupancic Link: https://lore.kernel.org/r/20220505114750.45423-1-Indan.Zupancic@mep-info.com Signed-off-by: Greg Kroah-Hartman [5.10 did not have lpuart_global_reset or anything after uart_add_one_port(), so add the remove call in cleanup manually] Signed-off-by: Dominique Martinet --- This was originally intended as a prerequirement to backport the patch submitted in [1] for 5.10, but even with that part of the patch gone it makes sense as a fix on its own. [1] https://lkml.kernel.org/r/20221222114414.1886632-1-linux@rasmusvillemoes.dk drivers/tty/serial/fsl_lpuart.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c index 43aca5a2ef0f..223695947b65 100644 --- a/drivers/tty/serial/fsl_lpuart.c +++ b/drivers/tty/serial/fsl_lpuart.c @@ -2586,6 +2586,7 @@ static int lpuart_probe(struct platform_device *pdev) struct device_node *np = pdev->dev.of_node; struct lpuart_port *sport; struct resource *res; + irq_handler_t handler; int ret; sport = devm_kzalloc(&pdev->dev, sizeof(*sport), GFP_KERNEL); @@ -2658,17 +2659,12 @@ static int lpuart_probe(struct platform_device *pdev) if (lpuart_is_32(sport)) { lpuart_reg.cons = LPUART32_CONSOLE; - ret = devm_request_irq(&pdev->dev, sport->port.irq, lpuart32_int, 0, - DRIVER_NAME, sport); + handler = lpuart32_int; } else { lpuart_reg.cons = LPUART_CONSOLE; - ret = devm_request_irq(&pdev->dev, sport->port.irq, lpuart_int, 0, - DRIVER_NAME, sport); + handler = lpuart_int; } - if (ret) - goto failed_irq_request; - ret = uart_get_rs485_mode(&sport->port); if (ret) goto failed_get_rs485; @@ -2684,11 +2680,17 @@ static int lpuart_probe(struct platform_device *pdev) if (ret) goto failed_attach_port; + ret = devm_request_irq(&pdev->dev, sport->port.irq, handler, 0, + DRIVER_NAME, sport); + if (ret) + goto failed_irq_request; + return 0; +failed_irq_request: + uart_remove_one_port(&lpuart_reg, &sport->port); failed_get_rs485: failed_attach_port: -failed_irq_request: lpuart_disable_clks(sport); return ret; } From patchwork Fri Dec 23 04:23:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dominique Martinet X-Patchwork-Id: 636572 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 590CEC4332F for ; Fri, 23 Dec 2022 04:24:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235699AbiLWEYj (ORCPT ); Thu, 22 Dec 2022 23:24:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229851AbiLWEYc (ORCPT ); Thu, 22 Dec 2022 23:24:32 -0500 Received: from gw.atmark-techno.com (gw.atmark-techno.com [13.115.124.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FDE82CCBD for ; Thu, 22 Dec 2022 20:24:29 -0800 (PST) Received: from gw.atmark-techno.com (localhost [127.0.0.1]) by gw.atmark-techno.com (Postfix) with ESMTP id EC6F760111 for ; Fri, 23 Dec 2022 13:24:28 +0900 (JST) Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by gw.atmark-techno.com (Postfix) with ESMTPS id 75ADB6010E for ; Fri, 23 Dec 2022 13:24:28 +0900 (JST) Received: by mail-pg1-f200.google.com with SMTP id g1-20020a636b01000000b00479222d9875so2136516pgc.12 for ; Thu, 22 Dec 2022 20:24:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tBDC9ChAeeQBia/ZUlsALV6hFzA+pCEINYLDDXbpoLE=; b=iA4ZjC6dRCgCjJXlfo0aeb64MlctBSrMCY3/UAJUKObfTs7CVulzoHF8fbZEeBDSAY JUzEnVuyRlQbSm8Ttib7YUDMU7gnLDPe+H4dqpai4T8Cm2sXTgcVxZoESaI1nmUT1Xmi qMxYyR1wO7IRcPnscINV8jFt7YXffhmeV54lyF7dTVbQVeR6QekvYltGhJsRmJUkNH9x b71q1Zxedhney9LQaRm7/A4Kr9T0IQ8k1EUiMZ4JKA2hr5cL/IIDBGiN6rqJzV2IgzEq lrOrCo90bTPY8x1o7wYdpX9mafYYigj8SeGWKUwtgIZxps9BPHD2PJ1p+Onsx5nXEcaJ l7xA== X-Gm-Message-State: AFqh2koxNxT2ZNcl5kT+RFS5BR3/KWfKH75ZBCLeYDcvCpiggr6mhweq 6/hKuOnubLkDduuPfQTCiSSeIcEsfpxCJ2JqU6GwE7ZBtc28Ee4n00SqrIGC7bW1WMvxOBqI808 usgigehAWEPXdAS86uWgcgv5CJKaJ X-Received: by 2002:a17:90b:1989:b0:219:f1a2:b665 with SMTP id mv9-20020a17090b198900b00219f1a2b665mr9786154pjb.5.1671769467527; Thu, 22 Dec 2022 20:24:27 -0800 (PST) X-Google-Smtp-Source: AMrXdXv7B5arxTkr0s2RS7gyNogNZ7TKCvV+Zp4rTfz1L9JK8wCUpHA+itk2hYbI0HMM53TWY+Hy2g== X-Received: by 2002:a17:90b:1989:b0:219:f1a2:b665 with SMTP id mv9-20020a17090b198900b00219f1a2b665mr9786138pjb.5.1671769467304; Thu, 22 Dec 2022 20:24:27 -0800 (PST) Received: from pc-zest.atmarktech (162.198.187.35.bc.googleusercontent.com. [35.187.198.162]) by smtp.gmail.com with ESMTPSA id b8-20020a17090a8c8800b00213c7cf21c0sm1350295pjo.5.2022.12.22.20.24.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Dec 2022 20:24:26 -0800 (PST) Received: from martinet by pc-zest.atmarktech with local (Exim 4.96) (envelope-from ) id 1p8Zbd-00H7dX-0o; Fri, 23 Dec 2022 13:24:25 +0900 From: Dominique Martinet To: Greg Kroah-Hartman , Jiri Slaby , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Lukas Wunner , Rasmus Villemoes Cc: Daisuke Mizobuchi , stable@vger.kernel.org, linux-serial@vger.kernel.org, Dominique Martinet Subject: [PATCH 5.10 2/2] serial: fixup backport of "serial: Deassert Transmit Enable on probe in driver-specific way" Date: Fri, 23 Dec 2022 13:23:54 +0900 Message-Id: <20221223042354.4080724-2-dominique.martinet@atmark-techno.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221223042354.4080724-1-dominique.martinet@atmark-techno.com> References: <20221223042354.4080724-1-dominique.martinet@atmark-techno.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org From: Rasmus Villemoes When 7c7f9bc986e6 ("serial: Deassert Transmit Enable on probe in driver-specific way") got backported to 5.10.y, there known as 26a2b9c468de, some hunks were accidentally left out. In serial_core.c, it is possible that the omission in uart_suspend_port() is harmless, but the backport did have the corresponding hunk in uart_resume_port(), it runs counter to the original commit's intention of Skip any invocation of ->set_mctrl() if RS485 is enabled. and it's certainly better to be aligned with upstream. Link: https://lkml.kernel.org/r/20221222114414.1886632-1-linux@rasmusvillemoes.dk Fixes: 26a2b9c468de ("serial: Deassert Transmit Enable on probe in driver-specific way") Signed-off-by: Rasmus Villemoes [the fsl_lpuart part of the 5.15 patch is not required on 5.10, because the code before 26a2b9c468de was incorrectly not calling uart_remove_one_port on failed_get_rs485] Signed-off-by: Dominique Martinet --- The part in v2 of the patch still makes sense, so here's just that for 5.10. (I've kept Rasmus as author for the 5.10 version as well, thanks again!) drivers/tty/serial/serial_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 605f928f0636..40fff38588d4 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -2254,7 +2254,8 @@ int uart_suspend_port(struct uart_driver *drv, struct uart_port *uport) spin_lock_irq(&uport->lock); ops->stop_tx(uport); - ops->set_mctrl(uport, 0); + if (!(uport->rs485.flags & SER_RS485_ENABLED)) + ops->set_mctrl(uport, 0); ops->stop_rx(uport); spin_unlock_irq(&uport->lock);