Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp19248pxb; Wed, 29 Sep 2021 23:31:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypw3tLCQbYWMzx/3NFs9tqQuLjhn6nb3+wfGaf1dgPBP9m3FmI/pFJ1NHxgwblb6gvYd2y X-Received: by 2002:a17:90a:4091:: with SMTP id l17mr4625408pjg.138.1632983498362; Wed, 29 Sep 2021 23:31:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632983498; cv=none; d=google.com; s=arc-20160816; b=vSJNhMza0LXN2DnxkdwNKCYC2kW85kI+eOf8ya9hfPfQac8BtEhIUA1WKtKXBcvu2V gl6go/3eBTuk4X1GUK/NZ8ksx/iyjjnjg0IfdMShCEcV1YSFhnuGftURe6ra6IbORIwA uPcDRdpgo1DxUTSfAW6C1c4568qoqaILeQPcrlg1PBptfy0wE3TDQLhwgnjn3N0TMzuz wRkbsdXyt8nr/M5P3gwoyDOXmyialOQE+tuKL18MV9BpGXKytfNX6HWZSrHINcYtgpM+ X9Aoq5o076aW1TfLy0oW1ICUoJ8cBYOrCa4dgffKznHexPrnDH6AfU+x5YFD30qGDVhG vaoA== 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=uQy5viTJtw0+6GorlvDGUVtqv9391MMW2jXUbnIbNyE=; b=0bzPSi4Jqic0dLY/y8OPyDBtswrbwybTuWdDGUKJfX+Puj0863IvUf7HTcCXXSF+Cz wcIzgxUrN61cL4V+J/S9BCs+C60rp77d6ZfmqlgO0GQbbKW5H43hnPPEg9HksFwEOj1R ZVZXs9F6b9/BryN8oEX1z/l79i47FMNIZZQ95p5XcigdrOgKuyQXVbMn7FW14fKXHzjL EKy0D4WduV559eiT8AfjguFiGaHLPK2qztMqUmK3a5owhNkPzSN9E+/+GPVyjlx0lqXb ZgUNR+UBKZcMfRkX9oDKOyDB0f+bV/lOmpZe+IrmHLiuMLMJkRt4OamEvppUX4SXGE0+ 7uYw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n11si2475558pff.5.2021.09.29.23.31.24; Wed, 29 Sep 2021 23:31:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348341AbhI3GbJ (ORCPT + 99 others); Thu, 30 Sep 2021 02:31:09 -0400 Received: from muru.com ([72.249.23.125]:38888 "EHLO muru.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348320AbhI3GbG (ORCPT ); Thu, 30 Sep 2021 02:31:06 -0400 Received: from hillo.muru.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTP id B00D78150; Thu, 30 Sep 2021 06:29:51 +0000 (UTC) From: Tony Lindgren To: Greg Kroah-Hartman Cc: Andy Shevchenko , Jiri Slaby , Johan Hovold , Vignesh Raghavendra , linux-serial@vger.kernel.org, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] serial: 8250_omap: Drop the use of pm_runtime_irq_safe() Date: Thu, 30 Sep 2021 09:29:06 +0300 Message-Id: <20210930062906.58937-5-tony@atomide.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210930062906.58937-1-tony@atomide.com> References: <20210930062906.58937-1-tony@atomide.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We can finally drop the pm_runtime_irq_safe() usage for 8250_omap driver. We already have the serial layer RX wake path fixed for power management. We no longer allow deeper idle states unless the kernel console has been detached, and we require that the RX wakeirq is configured. For TX path, we now use the prep_tx() and uart_flush_tx() calls. To drop pm_runtime_irq_safe(), we remove all PM runtime calls from the interrupt context. If we ever see an interrupt for an idled port, we just bail out. We now also need to restore the port context with interrupts disabled to prevent interrupts from happening while restoring the port. Signed-off-by: Tony Lindgren --- drivers/tty/serial/8250/8250_omap.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 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 @@ -621,6 +621,9 @@ static irqreturn_t omap8250_irq(int irq, void *dev_id) unsigned int iir, lsr; int ret; + if (atomic_read(&port->runtime_suspended)) + return IRQ_NONE; + #ifdef CONFIG_SERIAL_8250_DMA if (up->dma) { ret = omap_8250_dma_handle_irq(port); @@ -628,7 +631,6 @@ static irqreturn_t omap8250_irq(int irq, void *dev_id) } #endif - serial8250_rpm_get(up); lsr = serial_port_in(port, UART_LSR); iir = serial_port_in(port, UART_IIR); ret = serial8250_handle_irq(port, iir); @@ -662,8 +664,6 @@ static irqreturn_t omap8250_irq(int irq, void *dev_id) schedule_delayed_work(&up->overrun_backoff, delay); } - serial8250_rpm_put(up); - return IRQ_RETVAL(ret); } @@ -1191,13 +1191,9 @@ static int omap_8250_dma_handle_irq(struct uart_port *port) unsigned char status; u8 iir; - serial8250_rpm_get(up); - iir = serial_port_in(port, UART_IIR); - if (iir & UART_IIR_NO_INT) { - serial8250_rpm_put(up); + if (iir & UART_IIR_NO_INT) return IRQ_HANDLED; - } spin_lock(&port->lock); @@ -1226,7 +1222,6 @@ static int omap_8250_dma_handle_irq(struct uart_port *port) uart_unlock_and_check_sysrq(port); - serial8250_rpm_put(up); return 1; } @@ -1420,8 +1415,6 @@ static int omap8250_probe(struct platform_device *pdev) if (!of_get_available_child_count(pdev->dev.of_node)) pm_runtime_set_autosuspend_delay(&pdev->dev, -1); - pm_runtime_irq_safe(&pdev->dev); - pm_runtime_get_sync(&pdev->dev); omap_serial_fill_features_erratas(&up, priv); @@ -1652,6 +1645,7 @@ static int omap8250_runtime_resume(struct device *dev) struct omap8250_priv *priv = dev_get_drvdata(dev); struct uart_8250_port *up; struct uart_port *port; + unsigned long flags; /* In case runtime-pm tries this before we are setup */ if (!priv) @@ -1660,6 +1654,8 @@ static int omap8250_runtime_resume(struct device *dev) up = serial8250_get_port(priv->line); port = &up->port; + /* Restore state with interrupts disabled */ + spin_lock_irqsave(&port->lock, flags); if (omap8250_lost_context(up)) omap8250_restore_regs(up); @@ -1671,6 +1667,8 @@ static int omap8250_runtime_resume(struct device *dev) atomic_set(&port->runtime_suspended, 0); + spin_unlock_irqrestore(&port->lock, flags); + uart_start_pending_tx(port); return 0; -- 2.33.0