Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp4036123rwr; Mon, 8 May 2023 01:41:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4WuPBN7MANWnQt5Ksu251d/ZGEqULdsHgYBNMnJtjAm3EGT59ZfdJL7qUDKY/Fl3n9WrzN X-Received: by 2002:a17:90a:94cc:b0:24e:edd:4d63 with SMTP id j12-20020a17090a94cc00b0024e0edd4d63mr9714482pjw.5.1683535314888; Mon, 08 May 2023 01:41:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683535314; cv=none; d=google.com; s=arc-20160816; b=G0aPjHmSQf1LnCrlEoO2mAjdiv90qOsVVOGgZuAY24FHTTotXg+rAk2AsPGTHGuxEX UjKz8KUedRg0TGjeEU86NA3X6RXPRY2n3RWkZkGGM13/k6tKN42qxEQC/bNbnpGu0MBn PkdbdVeaAlo1UH3Zh1NiGvDmz5g8RSsXvv/ycPdjgNkxrPo5tyc9Z9X2ern2v0oiNYlS 8PQvkxmIY9TwI+vaHUDBeOvhio6cIfvX6Q3RNnJQos0IDuBgUeleax72Hb85jl83wrup fhlFhkjyvgdQNxFJjJFwK2IKGI84EyijaxnpwRv0h9TlfpLGcBdBRZDLWuLGV+a+BPUW oizQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=B4+aNI0SCkXZcK6Id3izAzVpgvcl3s/FEZagJxjkNX8=; b=lOo3WlZIh1ZMIbKcFDhd/lMwIc18pwld7PRKWv6JgEQaC5rcI43jncGexsES5d4W2r XDNt2f2ceSwIlN+htjNqI2ZT8OZYlxZzM7lak+e7pr9Yiyxi1TsyUZVeUhxidkUSnz4J NXB5W1Ynea5MGA/5Pu9DpwAexLzzh9zuaQ6uHvHx6rM3nmOwFWY/Ai3SCKBhfD7dn6Lz ZwKRwdHiv3dY7uw2EX5WND6NpdRZ6Xvb62GsgFtcHZnySJl4q7l79FceFE7GfWHGH09n yeAoub8eIYcU2Uw9aAQQtY5H2opQ6Ry2n6GAzPVO3eGkYIK7hgGsrxq0sK3u5SqoomSJ ARbA== 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 m9-20020a654389000000b00524da606618si303494pgp.227.2023.05.08.01.41.43; Mon, 08 May 2023 01:41:54 -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 S232645AbjEHIUx (ORCPT + 99 others); Mon, 8 May 2023 04:20:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233658AbjEHIUn (ORCPT ); Mon, 8 May 2023 04:20:43 -0400 Received: from muru.com (muru.com [72.249.23.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 49C0E1E98E; Mon, 8 May 2023 01:20:41 -0700 (PDT) Received: from hillo.muru.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTP id 198178111; Mon, 8 May 2023 08:20:38 +0000 (UTC) From: Tony Lindgren To: Greg Kroah-Hartman , Jiri Slaby Cc: Andy Shevchenko , Dhruva Gole , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Johan Hovold , Sebastian Andrzej Siewior , Vignesh Raghavendra , linux-omap@vger.kernel.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] serial: 8250: omap: Fix life cycle issues for interrupt handlers Date: Mon, 8 May 2023 11:20:13 +0300 Message-Id: <20230508082014.23083-4-tony@atomide.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230508082014.23083-1-tony@atomide.com> References: <20230508082014.23083-1-tony@atomide.com> 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,T_SCC_BODY_TEXT_LINE 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 We have the struct uart_8250_port instance recycled on device rebind while the struct omap8250_priv instance is not. For the console uart, __tty_hangup() does not call tty->ops->hangup() as cons_filp stays open, and uart shutdown won't get called. This means we have a stale priv->wakeirq handler around after unbind, and port->irq is not freed on unbind. There's no need to claim the interrupts on startup. We can fix this and simplify the driver a bit by claiming the interrupts in probe, and clearing them on remove. For the device interrupt, we can use devm_request_irq(). To do this, we change omap8250_irq() to use struct omap8250_priv data directly so we don't have to wait for the assigned port from serial8250_register_8250_port(). We must also drop IRQF_SHARED to set IRQ_NOAUTOEN to avoid spurious interrupts until the port has been registered. There's no need for IRQF_SHARED for 8250_omap, the serial port interrupt lines are dedicated lines. Signed-off-by: Tony Lindgren --- drivers/tty/serial/8250/8250_omap.c | 33 ++++++++++++++--------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c --- a/drivers/tty/serial/8250/8250_omap.c +++ b/drivers/tty/serial/8250/8250_omap.c @@ -623,9 +623,9 @@ static int omap_8250_dma_handle_irq(struct uart_port *port); static irqreturn_t omap8250_irq(int irq, void *dev_id) { - struct uart_port *port = dev_id; - struct omap8250_priv *priv = port->private_data; - struct uart_8250_port *up = up_to_u8250p(port); + struct omap8250_priv *priv = dev_id; + struct uart_8250_port *up = serial8250_get_port(priv->line); + struct uart_port *port = &up->port; unsigned int iir, lsr; int ret; @@ -709,11 +709,6 @@ static int omap_8250_startup(struct uart_port *port) } } - ret = request_irq(port->irq, omap8250_irq, IRQF_SHARED, - dev_name(port->dev), port); - if (ret < 0) - goto err; - up->ier = UART_IER_RLSI | UART_IER_RDI; serial_out(up, UART_IER, up->ier); @@ -730,14 +725,11 @@ static int omap_8250_startup(struct uart_port *port) if (up->dma && !(priv->habit & UART_HAS_EFR2)) up->dma->rx_dma(up); + enable_irq(up->port.irq); + pm_runtime_mark_last_busy(port->dev); pm_runtime_put_autosuspend(port->dev); return 0; -err: - pm_runtime_mark_last_busy(port->dev); - pm_runtime_put_autosuspend(port->dev); - dev_pm_clear_wake_irq(port->dev); - return ret; } static void omap_8250_shutdown(struct uart_port *port) @@ -757,6 +749,8 @@ static void omap_8250_shutdown(struct uart_port *port) up->ier = 0; serial_out(up, UART_IER, 0); + disable_irq_nosync(up->port.irq); + dev_pm_clear_wake_irq(port->dev); if (up->dma) serial8250_release_dma(up); @@ -770,8 +764,6 @@ static void omap_8250_shutdown(struct uart_port *port) pm_runtime_mark_last_busy(port->dev); pm_runtime_put_autosuspend(port->dev); - free_irq(port->irq, port); - dev_pm_clear_wake_irq(port->dev); } static void omap_8250_throttle(struct uart_port *port) @@ -1451,8 +1443,6 @@ static int omap8250_probe(struct platform_device *pdev) &up.overrun_backoff_time_ms) != 0) up.overrun_backoff_time_ms = 0; - priv->wakeirq = irq_of_parse_and_map(np, 1); - pdata = of_device_get_match_data(&pdev->dev); if (pdata) priv->habit |= pdata->habit; @@ -1530,6 +1520,15 @@ static int omap8250_probe(struct platform_device *pdev) } } #endif + + irq_set_status_flags(irq, IRQ_NOAUTOEN); + ret = devm_request_irq(&pdev->dev, irq, omap8250_irq, 0, + dev_name(&pdev->dev), priv); + if (ret < 0) + return ret; + + priv->wakeirq = irq_of_parse_and_map(np, 1); + ret = serial8250_register_8250_port(&up); if (ret < 0) { dev_err(&pdev->dev, "unable to register 8250 port\n"); -- 2.40.1