Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp994129yba; Thu, 4 Apr 2019 02:00:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqwBC1Z1QR+mCu0d68nQFxD5rS5uojUy3q6CkuN5yCH3auj8Ypsl5mER7UMeKop+8BDJq6UU X-Received: by 2002:a17:902:8d8b:: with SMTP id v11mr5113209plo.133.1554368413924; Thu, 04 Apr 2019 02:00:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554368413; cv=none; d=google.com; s=arc-20160816; b=jZKewDb3b67CXYInbXzPyhsif4lVGXBMCvHdx9X+5xIvYcigXF/x7BFeOMRH/8lC1J HrggD0miXnvTJd+iXX2HCRCeDG5BRH9tAlFgBbJQQmXXvUemdS1Redc78Z4AnJ66U63A jix9Q5NyehAvuHoNrKhqskAcEN/Umy2JeoDUsl+Joa0netPRE/2ptodMLQ7Lkwrrt4sU LY/7MnbQQu2qbI/k6OryIiA1QMFMWZJP3bRxl6d9ERbwEpUZYWR8+ZujpfhBN11xFNaW vF3Fkgobz5pcy12n8yuI2kCOEeTCSG7qK8tWJjFYaw6bPDvZClSYLZdi0XHAX8GIHAr2 L4aQ== 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=d3WNRcYMEMUiukKEChUXLAHAyQBpgtP2VQC0m4Rids4=; b=uAiv0Pb3Bha+KFIJqpL2b2Wei2RhBqDTRxUrC+NwwHM6Oez81ZQh2A2GeoMlpQ+1ML Xxnt4fD67GXEnu8Ol8czijLh5qdCD1QAv4YlawovZrPt2F9aFImjpDzB55WIPWlcnGDF LI2NGrl+N3681JixgcB3IT97d7586hUq1LQuXFmv+SYCHqMNL+zljjDlbuKsUPpzSMQN 4uR4QTjq9IaREImtnuG7gTVYQeoFq/n7FehPOUc6iEU3xY0/w7yKQpD3+x3OdaWLEnjN T5rRb7mIYxgnSHeU54badFHiJu+bnebkTFh083PCT4NFwQp02JKvd835EN43w+x4N5p1 NjKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=m3sx1+4x; 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 5si16185016pfv.74.2019.04.04.01.59.58; Thu, 04 Apr 2019 02:00:13 -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=m3sx1+4x; 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 S1731084AbfDDI70 (ORCPT + 99 others); Thu, 4 Apr 2019 04:59:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:35662 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730084AbfDDI7Y (ORCPT ); Thu, 4 Apr 2019 04:59:24 -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 9EB81217D9; Thu, 4 Apr 2019 08:59:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554368363; bh=S0PI6G2OXK7kYB9p2bV8NWZ5GF39qE2vPS7OTU2bhZg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m3sx1+4xw0NRtpNNq9PsNrh/6+3YdH2/gxlYlj7vEs0+N4vN0tCYjUTP1Njc0DZE9 kGJfFR/8yjCKiLHYrvG+nFvB07zzgUAUTvhgurPht/o7wg7+/uikmrBbnElQ9z14Ii ytBE8Zku2IH/tromyoqdo9EgHg3hXr+45uD+NHYM= 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.19 012/187] gpio: gpio-omap: fix level interrupt idling Date: Thu, 4 Apr 2019 10:45:49 +0200 Message-Id: <20190404084603.677724843@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084603.119654039@linuxfoundation.org> References: <20190404084603.119654039@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ [ 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 e81008678a38..6c1acf642c8e 100644 --- a/drivers/gpio/gpio-omap.c +++ b/drivers/gpio/gpio-omap.c @@ -888,14 +888,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