Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3227725yba; Sun, 28 Apr 2019 20:58:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqzMmB8Y5nTfWhAj1H2dL7POFEtmTPbPCp9PJET0QX8n9m43s+EyAkjeNvv8KMQ6YlKTTXAN X-Received: by 2002:a65:50c2:: with SMTP id s2mr57425508pgp.112.1556510287596; Sun, 28 Apr 2019 20:58:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556510287; cv=none; d=google.com; s=arc-20160816; b=L3s8U86flc4/ASIjmrGTCLV8ViHbVB/xJiUeJYHxYM+dOTcu8NppDX94f3xkQB51nM 2yMImv+YILbmAOQkFumVMLkPK2gsp8JSj9h0HG4MmQfN/LQMRLQTP4c6ufC9SML1hhBZ BQhsRSA6gwiWmmV/9STSK13bZ23YSFmF0Wgu3Ru5FZe9TL2U/G6598Xcwb20kA9PqsUa xwILPmjvvNtQFn1RLb3QLiQnHEiIlp5ft1RzLDzFC1y/0TS7UDoEsWl+neOzkDGhAsBW H5kSgaa3Vl3XII7kHNmuRjaqWZx4oRIU2S/JiE4M3S3m+ouB7hGX7s8iJLSXvIewsX0t 4vjA== 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=WAZlyDzGKVIdVMC388n6S7o0DOasFYjgOEfAKf4uteY=; b=0USvESvLj3u7tE9rQkay0Ch9CUOCDVgg3bD+SSkLWg+22sMPqndTw3PuR88b4S0Ljs c3n0AUHXj/9ZE+NagqRQ7vsV8xVGwa7VRzJxTdVl+RReV9Qe9MFXIv5D0TFdYXkKvjpW mLENai5cHrPdtdbMKxVausCUROiQIfakuzS3RZs7jWgXqDO7+hdJiX0KmBX/AHkYzekt zVXVMofkCDA+C3YA+ZVf8Gs08ZbR3banESbOSU0WvgHkXq+vt2mvTRbTMUc0rc+nPHd9 maifKznGH79GH+th7F8q16awT7A374Mq+5AoPU4DE4sEp7JumOxqhWb0I/YMBqwKmm9W lVAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=nSEa1MJ4; 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 w67si34663561pfb.20.2019.04.28.20.57.52; Sun, 28 Apr 2019 20:58:07 -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=nSEa1MJ4; 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 S1727289AbfD2Dzf (ORCPT + 99 others); Sun, 28 Apr 2019 23:55:35 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:37045 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727230AbfD2Dzc (ORCPT ); Sun, 28 Apr 2019 23:55:32 -0400 Received: by mail-pf1-f193.google.com with SMTP id g3so4647864pfi.4 for ; Sun, 28 Apr 2019 20:55:32 -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=WAZlyDzGKVIdVMC388n6S7o0DOasFYjgOEfAKf4uteY=; b=nSEa1MJ4YGhP7t6ZTTKWFurbopRUMivjdQCEUKmamdRbDSTbxUQbmsdw/JeTlHj47P e9Rjsu7YKOeUFG6lZbHcj2EFQJ2rW7yuNvBuXJVi0gyadnS0GlwtOvda8IRiGsZRqzsr tU5oaOTdgfubtwUJH0ZWA4QUdgzfJLmwUBugM= 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=WAZlyDzGKVIdVMC388n6S7o0DOasFYjgOEfAKf4uteY=; b=W7wy3R45ZYdMIqUT/c3WIvmRVVncQtp6N2ntNbepmmmlgDaHpqEUKXH+sc/TEHKgNg 8pDQFgytAo620Uez9CX850OoGtXRLcOof62Al+1cZCReiEAD8Y4RQdHaOTbjU/SlAQB4 TeGv1URUM9XP6V+M3Mf9cz3ZGCFYOB0LF7QB82oACeJ/QZg9zqr0eomVUirbWG9HEAbQ QMoYqQ9sPUUQPIGIkUMqzmBg1MCpo2hkA7lleBLumrngLIBNCtbQJuXhC/MBzuulOoM0 cOhho8k5DoKgLbm6uedmEjmODbb4h8WWRVEWunZlQxHQIAjSTTSH6a5ZDvtrq0GLO5/X R+6A== X-Gm-Message-State: APjAAAV8RZZDiC5Yu9dH0XXefR2nymXTtE+6jCWb/hOM/vkpkm8YhX6K 7W3GQaeJmqSznkZX1mhA/LWmuw== X-Received: by 2002:a62:a219:: with SMTP id m25mr60974348pff.197.1556510131833; Sun, 28 Apr 2019 20:55:31 -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.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 28 Apr 2019 20:55:31 -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 2/2] pinctrl: mediatek: Update cur_mask in mask/mask ops Date: Mon, 29 Apr 2019 11:55:15 +0800 Message-Id: <20190429035515.73611-3-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 During suspend/resume, mtk_eint_mask may be called while wake_mask is active. For example, this happens if a wake-source with an active interrupt handler wakes the system: irq/pm.c:irq_pm_check_wakeup would disable the interrupt, so that it can be handled later on in the resume flow. However, this may happen before mtk_eint_do_resume is called: in this case, wake_mask is loaded, and cur_mask is restored from an older copy, re-enabling the interrupt, and causing an interrupt storm (especially for level interrupts). Instead, we just record mask/unmask changes in cur_mask. This also avoids the need to read the current mask in eint_do_suspend, and we can remove mtk_eint_chip_read_mask function. Signed-off-by: Nicolas Boichat --- drivers/pinctrl/mediatek/mtk-eint.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/drivers/pinctrl/mediatek/mtk-eint.c b/drivers/pinctrl/mediatek/mtk-eint.c index 737385e86beb807..7e526bcf5e0b55c 100644 --- a/drivers/pinctrl/mediatek/mtk-eint.c +++ b/drivers/pinctrl/mediatek/mtk-eint.c @@ -113,6 +113,8 @@ static void mtk_eint_mask(struct irq_data *d) void __iomem *reg = mtk_eint_get_offset(eint, d->hwirq, eint->regs->mask_set); + eint->cur_mask[d->hwirq >> 5] &= ~mask; + writel(mask, reg); } @@ -123,6 +125,8 @@ static void mtk_eint_unmask(struct irq_data *d) void __iomem *reg = mtk_eint_get_offset(eint, d->hwirq, eint->regs->mask_clr); + eint->cur_mask[d->hwirq >> 5] |= mask; + writel(mask, reg); if (eint->dual_edge[d->hwirq]) @@ -217,19 +221,6 @@ static void mtk_eint_chip_write_mask(const struct mtk_eint *eint, } } -static void mtk_eint_chip_read_mask(const struct mtk_eint *eint, - void __iomem *base, u32 *buf) -{ - int port; - void __iomem *reg; - - for (port = 0; port < eint->hw->ports; port++) { - reg = base + eint->regs->mask + (port << 2); - buf[port] = ~readl_relaxed(reg); - /* Mask is 0 when irq is enabled, and 1 when disabled. */ - } -} - static int mtk_eint_irq_request_resources(struct irq_data *d) { struct mtk_eint *eint = irq_data_get_irq_chip_data(d); @@ -384,7 +375,6 @@ static void mtk_eint_irq_handler(struct irq_desc *desc) int mtk_eint_do_suspend(struct mtk_eint *eint) { - mtk_eint_chip_read_mask(eint, eint->base, eint->cur_mask); mtk_eint_chip_write_mask(eint, eint->base, eint->wake_mask); return 0; -- 2.21.0.593.g511ec345e18-goog