Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1689234ybi; Wed, 17 Jul 2019 20:10:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqz8TZ8pDDbz37VeTTl5F+MsFTXD6TKo4wbHv0J6R3DDnPt218ZOwp5qU8qwBDE/NqErUhlE X-Received: by 2002:a63:5945:: with SMTP id j5mr44935198pgm.452.1563419423259; Wed, 17 Jul 2019 20:10:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563419423; cv=none; d=google.com; s=arc-20160816; b=F4rGdyNHYWL0XOmzqyZcwhdXO9B+DUNvPs8Z7lsRWxyrLsHbWhS9JWkkRMjbaa5uFN N8GL2n4SkMCQ3fBtd4/hOISgenRIvqsrytgw8hZhm5OVMbHhAfV4c8ewmiKPVuFFTV5i nHZgTm40ugIJ6dSpCbANWA76vM9VAMZDMqkgez/rNS6+4+czuM/DzCAurWyOuoy4NOqA wXIY6e4CNKaTFnH2ygOu3NhDWQpAh6UDChqvYPQMLNAh1DoakxcBFEj0zUFIcoQhIfJu +XwbcCYPSPUmAju5ETNAxKxKu+VmEd3mosoMTLuDWfalCqFHdNkNwLn35cghudQtVRxL PalA== 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=5eZ5+zqwkRhR6EvZpIwhuyqIALAHHnYEOZD0ajYbsZ8=; b=FL5yvFOxqVzKNw6oaJbj3L9PNAgW2kMpnjOfdyu65XTzS1EUbNo2vQc/KSfB806K1L elTexK8VSEAsnxUjtSAr4I9Ha5A2/W4v41D1myBvFmfyx61AOdIupZSGhYn2vKYqNJiX jy38GQyHMI01cqqogwfTZ03FZ2Jd2yz2mt0toCsOd9PaBhZsqGwCwOkTbEULLf4M0HZR gIQHxj6BShUthlRS4feUsIiqWMqhsmrl3b9hvxxxWcZZhjlczN2SJrn+hq3R0nMKU9xY +B+mmZ1QGvDBYj5pZAbIw7AV3tQjbZ6cQjdayquj5naMO+fF7tMmSbtMfMMyNixYUf7q DiMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IV9lm1Cj; 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 c1si784235plr.405.2019.07.17.20.10.07; Wed, 17 Jul 2019 20:10:23 -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=IV9lm1Cj; 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 S2390530AbfGRDHo (ORCPT + 99 others); Wed, 17 Jul 2019 23:07:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:39316 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390497AbfGRDHh (ORCPT ); Wed, 17 Jul 2019 23:07:37 -0400 Received: from localhost (115.42.148.210.bf.2iij.net [210.148.42.115]) (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 61A87205F4; Thu, 18 Jul 2019 03:07:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563419256; bh=oQTMkE1+zoSRVg+pGvhFFLdoarOEEcliVK9Ncjgenwo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IV9lm1CjS9I4GRqHcy8xWHhcaNyiTPFdDM8TL28h82zHLE9/T6XBIeftrEG3Pemzo BFD8/2/bxeVFy3z1xbWrxCzx1ntJoufxQ7e+MLKcWW29IfZxgdRDyQHTCT9q02UoEK YWxXHMhBZzqfdsXsGF7I6kmQGr7Hdh/bjF3gtqlk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicolas Boichat , Sean Wang , Linus Walleij , Sasha Levin Subject: [PATCH 4.19 26/47] pinctrl: mediatek: Ignore interrupts that are wake only during resume Date: Thu, 18 Jul 2019 12:01:40 +0900 Message-Id: <20190718030050.943825318@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190718030045.780672747@linuxfoundation.org> References: <20190718030045.780672747@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 35594bc7cecf3a78504b590e350570e8f4d7779e ] Before suspending, mtk-eint would set the interrupt mask to the one in wake_mask. However, some of these interrupts may not have a corresponding interrupt handler, or the interrupt may be disabled. On resume, the eint irq handler would trigger nevertheless, and irq/pm.c:irq_pm_check_wakeup would be called, which would try to call irq_disable. However, if the interrupt is not enabled (irqd_irq_disabled(&desc->irq_data) is true), the call does nothing, and the interrupt is left enabled in the eint driver. Especially for level-sensitive interrupts, this will lead to an interrupt storm on resume. If we detect that an interrupt is only in wake_mask, but not in cur_mask, we can just mask it out immediately (as mtk_eint_resume would do anyway at a later stage in the resume sequence, when restoring cur_mask). Fixes: bf22ff45bed6 ("genirq: Avoid unnecessary low level irq function calls") Signed-off-by: Nicolas Boichat Acked-by: Sean Wang Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin --- drivers/pinctrl/mediatek/mtk-eint.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/pinctrl/mediatek/mtk-eint.c b/drivers/pinctrl/mediatek/mtk-eint.c index a613e546717a..b9f3c02ba59d 100644 --- a/drivers/pinctrl/mediatek/mtk-eint.c +++ b/drivers/pinctrl/mediatek/mtk-eint.c @@ -318,7 +318,7 @@ static void mtk_eint_irq_handler(struct irq_desc *desc) struct irq_chip *chip = irq_desc_get_chip(desc); struct mtk_eint *eint = irq_desc_get_handler_data(desc); unsigned int status, eint_num; - int offset, index, virq; + int offset, mask_offset, index, virq; void __iomem *reg = mtk_eint_get_offset(eint, 0, eint->regs->stat); int dual_edge, start_level, curr_level; @@ -328,10 +328,24 @@ static void mtk_eint_irq_handler(struct irq_desc *desc) status = readl(reg); while (status) { offset = __ffs(status); + mask_offset = eint_num >> 5; index = eint_num + offset; virq = irq_find_mapping(eint->domain, index); status &= ~BIT(offset); + /* + * If we get an interrupt on pin that was only required + * for wake (but no real interrupt requested), mask the + * interrupt (as would mtk_eint_resume do anyway later + * in the resume sequence). + */ + if (eint->wake_mask[mask_offset] & BIT(offset) && + !(eint->cur_mask[mask_offset] & BIT(offset))) { + writel_relaxed(BIT(offset), reg - + eint->regs->stat + + eint->regs->mask_set); + } + dual_edge = eint->dual_edge[index]; if (dual_edge) { /* -- 2.20.1