Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2330117rdh; Tue, 26 Sep 2023 22:06:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEHACRRTzuNm48+ZLJGTjW6tRtYXTAQGumg59uDatDWNaFxYSCuO0G7KpEbzkbh46Hj3M6z X-Received: by 2002:a17:90a:fa10:b0:277:3379:ce04 with SMTP id cm16-20020a17090afa1000b002773379ce04mr7390386pjb.18.1695791210300; Tue, 26 Sep 2023 22:06:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695791210; cv=none; d=google.com; s=arc-20160816; b=xtKwkII9Wq5EuJmP2sTD4ZaewPePx/+v6of+4ajQonhg+7xV1kuhPiUQ54yX7K438f rZDR/qU85ifPvH6uHIuQMMveC6t0oHiVSOZDCCZuGPm9wnpfRJ+suj/PXBs/7G0hTY8N rWgv+LlhyWa1x6yEZdqtAGmd2+xgwnUjGiuijqC65x/rk0YC5mJ2Hl1n04Z50nm7OE5h BNjTSy3z9cISdhQdTbTD4cHTcs4E0ajALeQzzaty0doEBo0NIJWRQZIjaFUg1u6/oh+J eh6JqJlarDKZfdMGBPixEsl6iByJT5t68cItoYJnlMZY7jF/ennzZvE1TNnPGf7+8DAw HRBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=1ucom2467L7mhGW3QAJ/ADo2Vlq2cwTf50bIm5+DhY4=; fh=C/qq+cxYdiKVdOsR+HE3AID1Rx9SgVEWMDsSHurLJ1Q=; b=bZS0cBk5+0Dfq8yP0cF/d+CodqlOw4imPKRp1GatPA8AUXSuX8Svmc98Zq6GLJj6X5 rXMY/mjVDHUuNeCY8JplCkDNgtK8RuxNG766SFp7Yp0QPEJ1pOml3cHEgS/9RYzI/fCy nIylDw6vVNDjmEafl+qu25aCrOa+uxfXaTs2W43UFXlhyaglUyIH21vJhy3tBjOsyRkg xvDqPH4gZwYG+LlFxleydhp+RMfzT4MsbFctnzngPCzZXRCQQY1v2mr80GqMfDOIWRlb D/ChrR+nrY7Jo8xMiSYxgLRCWeh5tzEPUiIPWLIR3Fqnt5FnSOuLx1rvWS7lo9debTtV IPDQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id r203-20020a632bd4000000b00573f7e9d75asi15162763pgr.646.2023.09.26.22.06.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 22:06:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id B11868070652; Tue, 26 Sep 2023 22:02:14 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229803AbjI0FCJ (ORCPT + 99 others); Wed, 27 Sep 2023 01:02:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229827AbjI0FBX (ORCPT ); Wed, 27 Sep 2023 01:01:23 -0400 Received: from muru.com (muru.com [72.249.23.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9234D1D28A; Tue, 26 Sep 2023 21:29:55 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTPS id C86C680A3; Wed, 27 Sep 2023 04:29:51 +0000 (UTC) Date: Wed, 27 Sep 2023 07:29:50 +0300 From: Tony Lindgren To: Andy Shevchenko Cc: Greg Kroah-Hartman , Jiri Slaby , Dhruva Gole , Ilpo =?utf-8?B?SsOkcnZpbmVu?= , John Ogness , Johan Hovold , Sebastian Andrzej Siewior , Vignesh Raghavendra , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Udit Kumar , Thomas Richard Subject: Re: [PATCH] serial: 8250_omap: Fix errors with no_console_suspend Message-ID: <20230927042950.GB5285@atomide.com> References: <20230926061319.15140-1-tony@atomide.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 26 Sep 2023 22:02:14 -0700 (PDT) * Andy Shevchenko [230926 11:59]: > Btw, how close are we to getting rid the pm_runtime_irq_safe() call? Very close, I think still doable for v6.7 merge window.. Below is what I'm testing with, there's one error that I've seen that may or may not be related. Regards, Tony 8< --------------------------- 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 @@ -8,6 +8,7 @@ * */ +#include #include #include #include @@ -130,6 +131,7 @@ struct omap8250_priv { u8 tx_trigger; u8 rx_trigger; + atomic_t active; bool is_suspending; int wakeirq; int wakeups_enabled; @@ -632,14 +634,21 @@ static irqreturn_t omap8250_irq(int irq, void *dev_id) unsigned int iir, lsr; int ret; + pm_runtime_get_noresume(port->dev); + + /* Shallow idle state wake-up to an IO interrupt? */ + if (atomic_add_unless(&priv->active, 1, 1)) { + priv->latency = priv->calc_latency; + schedule_work(&priv->qos_work); + } + #ifdef CONFIG_SERIAL_8250_DMA if (up->dma) { ret = omap_8250_dma_handle_irq(port); - return IRQ_RETVAL(ret); + goto out_runtime_put; } #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); @@ -676,7 +685,9 @@ static irqreturn_t omap8250_irq(int irq, void *dev_id) schedule_delayed_work(&up->overrun_backoff, delay); } - serial8250_rpm_put(up); +out_runtime_put: + pm_runtime_mark_last_busy(port->dev); + pm_runtime_put(port->dev); return IRQ_RETVAL(ret); } @@ -1270,11 +1281,8 @@ static int omap_8250_dma_handle_irq(struct uart_port *port) u16 status; u8 iir; - serial8250_rpm_get(up); - iir = serial_port_in(port, UART_IIR); if (iir & UART_IIR_NO_INT) { - serial8250_rpm_put(up); return IRQ_HANDLED; } @@ -1305,7 +1313,6 @@ static int omap_8250_dma_handle_irq(struct uart_port *port) uart_unlock_and_check_sysrq(port); - serial8250_rpm_put(up); return 1; } @@ -1500,8 +1507,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); @@ -1740,6 +1745,7 @@ static int omap8250_runtime_suspend(struct device *dev) priv->latency = PM_QOS_CPU_LATENCY_DEFAULT_VALUE; schedule_work(&priv->qos_work); + atomic_set(&priv->active, 0); return 0; } @@ -1749,6 +1755,10 @@ static int omap8250_runtime_resume(struct device *dev) struct omap8250_priv *priv = dev_get_drvdata(dev); struct uart_8250_port *up = NULL; + /* Did the hardware wake to a device IO interrupt before a wakeirq? */ + if (atomic_read(&priv->active)) + return 0; + if (priv->line >= 0) up = serial8250_get_port(priv->line); @@ -1764,8 +1774,10 @@ static int omap8250_runtime_resume(struct device *dev) spin_unlock_irq(&up->port.lock); } + atomic_set(&priv->active, 1); priv->latency = priv->calc_latency; schedule_work(&priv->qos_work); + return 0; } -- 2.42.0