Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1006858ybi; Fri, 2 Aug 2019 07:52:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqzUZjYfa82GDWVOGjGKNqR5+nT3DmeUKh63t8jp+r75MfiLEeZTTsz15UM7IpA+U7tkWKVq X-Received: by 2002:a63:dd16:: with SMTP id t22mr93350235pgg.140.1564757537373; Fri, 02 Aug 2019 07:52:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564757537; cv=none; d=google.com; s=arc-20160816; b=g2wkIqDacYy2vExXxSGIIEW9z1XrTMYr4zouggMIv0/wrjUrZcceRYkxn2DSmo031g 2RtS4ym00Gxm9Sq5gKdvBzrvqnl29p+MRCm4rR/S6mwUk/zPPD+XjQYkMo/7Il/hoJ2Z yJHyXViR3BHL9iEZgkD3h8f87M2QCR3t5KYl4kijWLhAWfkS3Wwvd3PpiMiPhqJJOdU5 AmNR8/KXz62jVIV1g9Q3XxW+v8c9M9C0BvzM5AE9JFJbI15kWnvAhE9rCxlqNFCgOwku LZvZ/nc0hCcboQogNGGUphGhPZJdQGdnk7o1vUnTm+v6otuHDY9P70hzRkhIrARuqpIW w7Xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=gop1V3r1N2NvvGlYpn/nHgvn4XbzhZQHRog55n/fLyA=; b=O3rRF4EZloLThi73St3IPfzgt8UDYWe+PcpFUKELsXupoPtBAUZUrLj7WLa6f5q3Gc CI9GB+uB1scwesQGE1vD7lYjFdhq/MlQW0c2zakAUyxVBHGno5jwbOZaQCbfLhPaEkI9 OofkMHUnoWynrEYFZ4KfDQ0LOHyTAqNbpFfjBaUFCA3DE7s8E1meLA7z1XXI+wyuvjkF UETrHLX2CRJP3CJigbd4RzWLiICkc7/i9tSyM9tAhpnD8oCy33gOeLTc2qoypOn4odw1 vt5BqTmLgm4CaqumF3yoOU9IhNDnpeWNbMNTj23ci933UuVPt7B/ajRJtj1I0oTlvL0I 08gQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JUiy0cWw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a33si38877657pgl.436.2019.08.02.07.52.02; Fri, 02 Aug 2019 07:52:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JUiy0cWw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390923AbfHBJar (ORCPT + 99 others); Fri, 2 Aug 2019 05:30:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:56374 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389860AbfHBJap (ORCPT ); Fri, 2 Aug 2019 05:30:45 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7646B21773; Fri, 2 Aug 2019 09:30:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564738244; bh=ycUDnsQKkWThdZ5y5ZpWalnox5FAaBuUuHXK3gz8thw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JUiy0cWwHwGApattfwU0cT8k21U4PN/28a/tgCHX5P3ZU/O6iI/bEq7T6qr9rOvyv M1SdrqslfwPy45ABSWHwYD+1WodSkc2ILZfsrolRh5HJzYXvCUwieDpSmsyQyFWBml aP5D8EXE7BdUzrncyE4kI4E8LGnYhEohLRDzXNRU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Russell King , Grygorii Strashko , Tony Lindgren , Linus Walleij , Sasha Levin Subject: [PATCH 4.4 028/158] gpio: omap: ensure irq is enabled before wakeup Date: Fri, 2 Aug 2019 11:27:29 +0200 Message-Id: <20190802092209.368323286@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802092203.671944552@linuxfoundation.org> References: <20190802092203.671944552@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit c859e0d479b3b4f6132fc12637c51e01492f31f6 ] Documentation states: NOTE: There must be a correlation between the wake-up enable and interrupt-enable registers. If a GPIO pin has a wake-up configured on it, it must also have the corresponding interrupt enabled (on one of the two interrupt lines). Ensure that this condition is always satisfied by enabling the detection events after enabling the interrupt, and disabling the detection before disabling the interrupt. This ensures interrupt/wakeup events can not happen until both the wakeup and interrupt enables correlate. If we do any clearing, clear between the interrupt enable/disable and trigger setting. Signed-off-by: Russell King Signed-off-by: Grygorii Strashko Tested-by: Tony Lindgren Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin --- drivers/gpio/gpio-omap.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c index f23136825a6e..6e65c02baad1 100644 --- a/drivers/gpio/gpio-omap.c +++ b/drivers/gpio/gpio-omap.c @@ -821,9 +821,9 @@ static void omap_gpio_irq_shutdown(struct irq_data *d) raw_spin_lock_irqsave(&bank->lock, flags); bank->irq_usage &= ~(BIT(offset)); - omap_set_gpio_irqenable(bank, offset, 0); - omap_clear_gpio_irqstatus(bank, offset); omap_set_gpio_triggering(bank, offset, IRQ_TYPE_NONE); + omap_clear_gpio_irqstatus(bank, offset); + omap_set_gpio_irqenable(bank, offset, 0); if (!LINE_USED(bank->mod_usage, offset)) omap_clear_gpio_debounce(bank, offset); omap_disable_gpio_module(bank, offset); @@ -865,8 +865,8 @@ static void omap_gpio_mask_irq(struct irq_data *d) unsigned long flags; raw_spin_lock_irqsave(&bank->lock, flags); - omap_set_gpio_irqenable(bank, offset, 0); omap_set_gpio_triggering(bank, offset, IRQ_TYPE_NONE); + omap_set_gpio_irqenable(bank, offset, 0); raw_spin_unlock_irqrestore(&bank->lock, flags); } @@ -878,9 +878,6 @@ static void omap_gpio_unmask_irq(struct irq_data *d) unsigned long flags; raw_spin_lock_irqsave(&bank->lock, flags); - if (trigger) - omap_set_gpio_triggering(bank, offset, trigger); - omap_set_gpio_irqenable(bank, offset, 1); /* @@ -888,9 +885,13 @@ static void omap_gpio_unmask_irq(struct irq_data *d) * is cleared, thus after the handler has run. OMAP4 needs this done * after enabing the interrupt to clear the wakeup status. */ - if (bank->level_mask & BIT(offset)) + if (bank->regs->leveldetect0 && bank->regs->wkup_en && + trigger & (IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW)) omap_clear_gpio_irqstatus(bank, offset); + if (trigger) + omap_set_gpio_triggering(bank, offset, trigger); + raw_spin_unlock_irqrestore(&bank->lock, flags); } -- 2.20.1