Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3227897yba; Sun, 28 Apr 2019 20:58:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqwLOhREz8wPpoBIHGcRxwdDpiJtYMnApXh6J81ZGOKiX3ryDMF47LGvpcGYpUX/rDZY3e52 X-Received: by 2002:a17:902:904a:: with SMTP id w10mr1709079plz.156.1556510303500; Sun, 28 Apr 2019 20:58:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556510303; cv=none; d=google.com; s=arc-20160816; b=yElyyS2l4XruUYhx3Ormo43GwTcKqgOYZqQ39dT+rZFMvRDAbJqVn3mbQi6CleRefi y51hWD16WR3MWFnPHzVKez10XaDQ3ajpMiqsjVp6f3N7xfBMM4yhYrGy9fDSEj719hA8 pPkuYIL+zuQiwXIy5DAAgrRIqpMebZqDSa0DRjI4bReqMs1ln2L/y143+3/rmkMqyLFY mAmJNdRSTYUyNGlmzPMGM9tdghPW0yYYR9wAFa7mDu95xNDC+ghZREpec3JTq4Hsa/nb QqEwztkpC1F55yUuOM1QlCBQuFbY1K8ZlhCosiKsMphMY1/HrlKhV4xD245/LprUi/sr G+fw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7lsB7l68Q2QXqBhtOyTwuTtF7RZuXTpMIg50jCRbpi0=; b=nuBBP4G1mFdYxrxsRqsoJqazRnG8GwfTGSuT5kJo4LKT74swqzKH8D37QZ0xDfK6rC 3gG1X97s1rR4h51dISGAaHg1uNI3SEDZTk5mhX3HvfLarwhISsp/PmXBu+XXaXN6P1zz 8RtEEbFgxsqmrcULH9Gx3FLwL1xbziXxx7yVMOdS4SOCMlhABWV0bj9h2FiZMSPAjgvB /7OeGIhqnzO1NJ6ByrXziZAXVR1qlWrKO7M9Z9L/6fYdglMt2GuwwK2vfcWddzQuaE5V zArGypqzrrjl1JT2y/vCT28tL0+WAG8K2CPPbZOKMzjH9d3VIIWjUYqI4HosvqPJeE7z jKXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=e6r9RTIN; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c22si17338048pfr.15.2019.04.28.20.58.08; Sun, 28 Apr 2019 20:58: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=@chromium.org header.s=google header.b=e6r9RTIN; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727261AbfD2Dze (ORCPT + 99 others); Sun, 28 Apr 2019 23:55:34 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:34769 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727231AbfD2Dza (ORCPT ); Sun, 28 Apr 2019 23:55:30 -0400 Received: by mail-pf1-f196.google.com with SMTP id b3so4652935pfd.1 for ; Sun, 28 Apr 2019 20:55:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7lsB7l68Q2QXqBhtOyTwuTtF7RZuXTpMIg50jCRbpi0=; b=e6r9RTINdTkzBfmhCn0Zd/uS9VD+tKpBrRTZLnWJRhIaRQGsTalHikdiV1rFz9XJwT YG3UGzwrhVYHjCSpiCl9rA2tJ6OfZ4pgofHmyQ36rynN9F8Rqzjt+iFzzoZfg2lklROm 8z/efRXO4gc+tbSEyy5VY+144Yd6nv2H+fBoM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7lsB7l68Q2QXqBhtOyTwuTtF7RZuXTpMIg50jCRbpi0=; b=nLHrCpRfJTrteoRQ4mkTJ92+Hj48JVoGTSe53HSJVQYfMEchhpLDVS0FfXq3WrVAAF WreoIcfTjVouOxitXqNyrp8kvrL+8DDRoGysYB/3JaEdVIOSZVMpMqenI80OemYCa4rf h7TO2jV3tysDULCVTYXTXnXy9RmM3UKDWbY1zIV8+GUI6eyGZLCyyUVC/ovALzgn/ZoH YwNdn+UqD4JZMt1x6ts51gbb/oODCEfvdtpm/3GRpkRrssOZ7NgxHWtiqI+SXE8aUIM0 AoSNe1YKgcFBE1y9Q+IfNq2v76MCFU4G/N5pabchumKsFUVoBKxXmj4OcDblZFX7c774 zyew== X-Gm-Message-State: APjAAAXCSxBI9DwQAHzHtrBgMB9poEjgH+XCXCNMB4rr9ZlG/I4iMONl rpmgSTNpFdr8vP8nRa+M+bp7KQ== X-Received: by 2002:aa7:9116:: with SMTP id 22mr53588470pfh.165.1556510129598; Sun, 28 Apr 2019 20:55:29 -0700 (PDT) Received: from drinkcat2.tpe.corp.google.com ([2401:fa00:1:b:d8b7:33af:adcb:b648]) by smtp.gmail.com with ESMTPSA id x128sm55433585pfx.103.2019.04.28.20.55.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 28 Apr 2019 20:55:29 -0700 (PDT) From: Nicolas Boichat To: linux-mediatek@lists.infradead.org Cc: Sean Wang , Linus Walleij , Matthias Brugger , linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Chuanjia Liu , evgreen@chromium.org, swboyd@chromium.org Subject: [PATCH 1/2] pinctrl: mediatek: Ignore interrupts that are wake only during resume Date: Mon, 29 Apr 2019 11:55:14 +0800 Message-Id: <20190429035515.73611-2-drinkcat@chromium.org> X-Mailer: git-send-email 2.21.0.593.g511ec345e18-goog In-Reply-To: <20190429035515.73611-1-drinkcat@chromium.org> References: <20190429035515.73611-1-drinkcat@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: bf22ff45bed ("genirq: Avoid unnecessary low level irq function calls") Signed-off-by: Nicolas Boichat --- 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 f464f8cd274b75c..737385e86beb807 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.21.0.593.g511ec345e18-goog