From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88595C10F13 for ; Mon, 8 Apr 2019 19:45:18 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 56CA620863 for ; Mon, 8 Apr 2019 19:45:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="FI9U7eva" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 56CA620863 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=atomide.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=4NBVstshEKrweoxT1V6c2BQY7u+1N0XzU2Wn+UlxL5I=; b=FI9U7evaZAkNwF N9wif+yiNs4+50GV3dF/rdN8TCZFvLFabnzF4hElchRiMVZ6Ry61Bfh7tmEYV5/peQ+/35oPGm83l zVb2iQU7afrA0ZsybvRB8Mwz7lfE6eigopMIwnROHhEEKOWQRul3SXyvo+CKIpBbMN8DafArDANvT BmN6SqPmrHnYcg8gyem7nhSOhAMxDtDG1n8H3frw89GZN45HwZgShrfL8QCL1PX7uxLBwt6uRNHvL vg/zBbFVBYFjHcOia6/VkDAl+tZzwCcnK7+a+S4EY5t7CWE2CedzFUWs5yNvyt5O5fOWzpZ//3NPa w9/9cPPcBSWAZ6RqjFeA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hDaCg-0005G9-Ez; Mon, 08 Apr 2019 19:45:14 +0000 Received: from muru.com ([72.249.23.125]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hDaCe-0005FP-09 for linux-arm-kernel@lists.infradead.org; Mon, 08 Apr 2019 19:45:13 +0000 Received: from hillo.muru.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTP id 4EBAA80AA; Mon, 8 Apr 2019 19:45:25 +0000 (UTC) From: Tony Lindgren To: Linus Walleij , Bartosz Golaszewski Subject: [PATCH] gpio: gpio-omap: take pm_runtime usage while IRQs are claimed Date: Mon, 8 Apr 2019 12:45:06 -0700 Message-Id: <20190408194506.25821-1-tony@atomide.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190408_124512_082973_F2F95F88 X-CRM114-Status: GOOD ( 12.51 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tero Kristo , Grygorii Strashko , Aaro Koskinen , Keerthy , Peter Ujfalusi , linux-gpio@vger.kernel.org, Russell King , linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Russell King Commit b764a5863fd8 ("gpio: omap: Remove custom PM calls and use cpu_pm instead") moved interrupt using GPIO banks to idle with cpu_pm in order to drop the use of pm_runtime_irq_safe() in a later patch. The GPIO banks with no interrupts claimed are still being idled based on PM runtime calls. However this caused a regression for am437x suspend for rtc+ddr idle mode as reported by Keerthy . The fix to this is: Bump the pm_runtime usage count while interrupts are in use, rather than failing the pm_runtime callbacks. The logic here is a little non-obvious - the calling order will be: omap_gpio_irq_bus_lock() (optionally) raw_spin_lock_irqsave(desc->lock) omap_gpio_irq_startup() (optionally) raw_spin_unlock_irqrestore(desc->lock) gpio_irq_bus_sync_unlock() As the irq_startup method may be called with interrupts disabled, we must not use pm_runtime_get() here, so as the bus lock takes an initial pm reference count us, use pm_runtime_get_if_in_use() which will merely increment the use count. Cc: Aaro Koskinen Cc: Grygorii Strashko Cc: Keerthy Cc: Peter Ujfalusi Cc: Tero Kristo Fixes: b764a5863fd8 ("gpio: omap: Remove custom PM calls and use cpu_pm instead") Reported-by: Keerthy Signed-off-by: Russell King [tony@atomide.com: updated patch description for regression fix] Signed-off-by: Tony Lindgren --- AFAIK this is only needed with patches heading to v5.2, so this is based on Linux next. We can always backport as needed. --- drivers/gpio/gpio-omap.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c --- a/drivers/gpio/gpio-omap.c +++ b/drivers/gpio/gpio-omap.c @@ -811,6 +811,9 @@ static unsigned int omap_gpio_irq_startup(struct irq_data *d) unsigned long flags; unsigned offset = d->hwirq; + /* Take a reference on the runtime PM to prevent RPM suspends */ + WARN_ON(pm_runtime_get_if_in_use(bank->chip.parent) == 0); + raw_spin_lock_irqsave(&bank->lock, flags); if (!LINE_USED(bank->mod_usage, offset)) @@ -844,6 +847,8 @@ static void omap_gpio_irq_shutdown(struct irq_data *d) omap_clear_gpio_debounce(bank, offset); omap_disable_gpio_module(bank, offset); raw_spin_unlock_irqrestore(&bank->lock, flags); + + pm_runtime_put(bank->chip.parent); } static void omap_gpio_irq_bus_lock(struct irq_data *data) @@ -1719,40 +1724,26 @@ static int __maybe_unused omap_gpio_runtime_suspend(struct device *dev) { struct gpio_bank *bank = dev_get_drvdata(dev); unsigned long flags; - int error = 0; raw_spin_lock_irqsave(&bank->lock, flags); - /* Must be idled only by CPU_CLUSTER_PM_ENTER? */ - if (bank->irq_usage) { - error = -EBUSY; - goto unlock; - } omap_gpio_idle(bank, true); bank->is_suspended = true; -unlock: raw_spin_unlock_irqrestore(&bank->lock, flags); - return error; + return 0; } static int __maybe_unused omap_gpio_runtime_resume(struct device *dev) { struct gpio_bank *bank = dev_get_drvdata(dev); unsigned long flags; - int error = 0; raw_spin_lock_irqsave(&bank->lock, flags); - /* Must be unidled only by CPU_CLUSTER_PM_ENTER? */ - if (bank->irq_usage) { - error = -EBUSY; - goto unlock; - } omap_gpio_unidle(bank); bank->is_suspended = false; -unlock: raw_spin_unlock_irqrestore(&bank->lock, flags); - return error; + return 0; } static const struct dev_pm_ops gpio_pm_ops = { -- 2.21.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel