Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3821504ybi; Mon, 29 Jul 2019 13:17:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqxES4/G6DKgJl4u9UFrbxaanNMiArRCo1GmYEAe9RjBmVXSMcsQIH3oNSw80JP4cu3EYite X-Received: by 2002:a62:3283:: with SMTP id y125mr39016941pfy.83.1564431424358; Mon, 29 Jul 2019 13:17:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564431424; cv=none; d=google.com; s=arc-20160816; b=MZBe2NYJ7v3FVv/FNeda3sg0TWpOWN5lW8aAHpXPj1s7IylgLHZRbgwA5LpDePx6o7 fFNAHVSreipgJDbDFCeSK5hPjVX5r+KH3Wbw2LwVjlHTsMMa4aHhN7DIIAU+fEqDPDNn EZr6DJWeMja2S0NsjqqRIv7MrX+6PFFWt3ilvYAdpNIUjF6S8QBz3SVq5rvRhWn8VKlC VcgZSRoQZ72AR5ZQ7kH4piu7vVDom83pcNRfgaGw1Ok2n4IFpFu26grGLzRWZfkVWg/3 rbAH5aYUAAOE235/Jd/5e5vXu4pL5+qMDPejzKyOhdS/VkuKU0xZXztZRPeIPOCGfyLD WTTA== 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=Ct62gu+2E85itNr721siVzwUdRTlelG1eY/oGzwr4LI=; b=J38A7XA50qcIJT9nvq4FyRvqqOCqElC563rYz6/IfKUWuoedDUAb9rsU2ugDn93ZEo 5gEA6qhjDI09wXsPP5JH1ed6e964Qk5qWovY1lKyzaX6BE9kbNvhdwfVjWytcYZHZf9W bF80EEMzilX8DvI8A7XOilrI7xk+npKj4JZE8w1/JJ8twpLH2Idvikq+fpYZJBFZtu/b r5A3J/CFKPWoqtcTYVIcXDA+VGGn6Pyt0kUBS0Xe0VTpJ+A6Z1AI3kiJQ6hj/fIAHq8y qrdhCLjo8e/hzRX1TZAuDGsdJrOWdlMl28oURq4UbSni5gsuLQFnOZr4nkHvrUoRM3Wx 48rA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hPQ4g4cw; 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 b20si28158604pfo.108.2019.07.29.13.16.49; Mon, 29 Jul 2019 13:17:04 -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=hPQ4g4cw; 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 S1729710AbfG2TZu (ORCPT + 99 others); Mon, 29 Jul 2019 15:25:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:38178 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729705AbfG2TZt (ORCPT ); Mon, 29 Jul 2019 15:25:49 -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 B48DE2070B; Mon, 29 Jul 2019 19:25:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428348; bh=nETW6lw05mogaAuQ8KkanzR+4Plgo6SGxN/On0n4BBg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hPQ4g4cweXz08ME2XsqaCXhBwdVgIsPyUtkSxNbTDk8guH5ETMBFe2OcnVfES3L0f rzMMBkGVmQ/i9oNDqElyMs4n9FUGlvdcfqrIBhJxW923tYJOhb4Tw8JAx6RtdeWYty nT3x5W/hzhOFHB+ya1JfLq7vbWzf1Y/AGIIAchuI= 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.14 046/293] gpio: omap: ensure irq is enabled before wakeup Date: Mon, 29 Jul 2019 21:18:57 +0200 Message-Id: <20190729190826.591999920@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@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 abe54659b1f4..47e537a91dd8 100644 --- a/drivers/gpio/gpio-omap.c +++ b/drivers/gpio/gpio-omap.c @@ -790,9 +790,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); @@ -834,8 +834,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); } @@ -847,9 +847,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); /* @@ -857,9 +854,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