Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp885837yba; Wed, 24 Apr 2019 11:11:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqwfb8CsWIqXaSnsm4/ngWvm2MVYFAudKX185i81y4YdU+f1Ce2TBGk/DOLHo8Ivtz0wtRuM X-Received: by 2002:a17:902:e793:: with SMTP id cp19mr28092370plb.65.1556129491239; Wed, 24 Apr 2019 11:11:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556129491; cv=none; d=google.com; s=arc-20160816; b=sMv2St10dUlWOE1Gx9bkiWKhaoVoNKp55PaVbUCywuBJCoBv+T3OwOj31D5sTR0gYh iHnnh069a8Jl9Jx6xKvYfdSTQbjWqWLfYse41DZo+plElfBLFyin+frGLWP/iAq/+piX NgG7YEhWkcmILLmbZn7y12gA3rtSna1SkstQnq7MPNpcwu3F1F6XjBxe5/eReB9gP+cQ eVl1M+xbA0T2S5UiVflC1K2Mm7N0GQJaSIwmqq4fT2MDGODjikf4soWuhMoijQhA6tyI km3x7SPrkAt1NB9OQ209qFv6VXXqvu1cH3KowxeHbV88ZaVYtY9g4KHDTLgFfff5W5MA CWDA== 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=4JdwyL/Kmb37gDMmC9dTl96XfcqsFwOoDevsoGRrwfE=; b=Wt271hqkX2liW39Nv/6ozPOBmi3kTcBXM9eA5byz9ZYX3eExh402EixcJbJybAZRvk sAWYAW3UFYPjiAyfZGj5S2ClgpX/kIsU7dq/uX51oKXop+e6kyZpmrOSchRK433FpH1u ORhvm7Xo3V5yQ76quchl4qYmHZUPYF4rVqBWj+/8K5ZhSBRJ6Ct5169HqDLhuYXeVqLm Uz+J+/xhc3Km2E11IvY/t7QALfVaK3QG2VOql+ROA+pPPVjCNb+XmYx9wZJrBCLBHdI2 8UQy7fGcdRH+fKq6AV6Wid0h0GIBrM4d8FYnF9Wh3sXAG5tMQXdDDwvCIPB99C+ekj6z zKqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YkAQz2Bv; 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 c9si17334144pgq.50.2019.04.24.11.11.16; Wed, 24 Apr 2019 11:11:31 -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=YkAQz2Bv; 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 S2389013AbfDXSI1 (ORCPT + 99 others); Wed, 24 Apr 2019 14:08:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:40520 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387960AbfDXRQE (ORCPT ); Wed, 24 Apr 2019 13:16:04 -0400 Received: from localhost (62-193-50-229.as16211.net [62.193.50.229]) (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 A16D021900; Wed, 24 Apr 2019 17:16:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556126163; bh=jppdBaj1GdT/cWL8QwqapJqdZ8m0suDqJ2qVXcbx0m4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YkAQz2BvuMSDNXexJA2J3/ZM/ouKr/puRQjhRjsj/JeiIC+XBv8dLx4woCDbrq0w8 t9nFJi4HcorKA6ExkjoYyJgT+pC9XcR6uXLg/Y6rUwZi01U2xaWwnqUPLaR0BJsccB HMK6nxs7RpL/LR9dG6lyxm07RYShDoMHcGdq5F4k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Aaro Koskinen , Keerthy , Peter Ujfalusi , Russell King , Tony Lindgren , Grygorii Strashko , Linus Walleij , Sasha Levin Subject: [PATCH 4.4 013/168] gpio: gpio-omap: fix level interrupt idling Date: Wed, 24 Apr 2019 19:07:37 +0200 Message-Id: <20190424170924.317926137@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190424170923.452349382@linuxfoundation.org> References: <20190424170923.452349382@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 d01849f7deba81f4959fd9e51bf20dbf46987d1c ] Tony notes that the GPIO module does not idle when level interrupts are in use, as the wakeup appears to get stuck. After extensive investigation, it appears that the wakeup will only be cleared if the interrupt status register is cleared while the interrupt is enabled. However, we are currently clearing it with the interrupt disabled for level-based interrupts. It is acknowledged that this observed behaviour conflicts with a statement in the TRM: CAUTION After servicing the interrupt, the status bit in the interrupt status register (GPIOi.GPIO_IRQSTATUS_0 or GPIOi.GPIO_IRQSTATUS_1) must be reset and the interrupt line released (by setting the corresponding bit of the interrupt status register to 1) before enabling an interrupt for the GPIO channel in the interrupt-enable register (GPIOi.GPIO_IRQSTATUS_SET_0 or GPIOi.GPIO_IRQSTATUS_SET_1) to prevent the occurrence of unexpected interrupts when enabling an interrupt for the GPIO channel. However, this does not appear to be a practical problem. Further, as reported by Grygorii Strashko , the TI Android kernel tree has an earlier similar patch as "GPIO: OMAP: Fix the sequence to clear the IRQ status" saying: if the status is cleared after disabling the IRQ then sWAKEUP will not be cleared and gates the module transition When we unmask the level interrupt after the interrupt has been handled, enable the interrupt and only then clear the interrupt. If the interrupt is still pending, the hardware will re-assert the interrupt status. Should the caution note in the TRM prove to be a problem, we could use a clear-enable-clear sequence instead. Cc: Aaro Koskinen Cc: Keerthy Cc: Peter Ujfalusi Signed-off-by: Russell King [tony@atomide.com: updated comments based on an earlier TI patch] Signed-off-by: Tony Lindgren Acked-by: Grygorii Strashko Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin --- drivers/gpio/gpio-omap.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c index f7fbb46d5d79..9943273ec981 100644 --- a/drivers/gpio/gpio-omap.c +++ b/drivers/gpio/gpio-omap.c @@ -872,14 +872,16 @@ static void omap_gpio_unmask_irq(struct irq_data *d) if (trigger) omap_set_gpio_triggering(bank, offset, trigger); - /* For level-triggered GPIOs, the clearing must be done after - * the HW source is cleared, thus after the handler has run */ - if (bank->level_mask & BIT(offset)) { - omap_set_gpio_irqenable(bank, offset, 0); + omap_set_gpio_irqenable(bank, offset, 1); + + /* + * For level-triggered GPIOs, clearing must be done after the source + * 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)) omap_clear_gpio_irqstatus(bank, offset); - } - omap_set_gpio_irqenable(bank, offset, 1); raw_spin_unlock_irqrestore(&bank->lock, flags); } -- 2.19.1