Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp1951639ybd; Thu, 27 Jun 2019 04:24:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqz80KEFcDWhsXheYCg/Sr1TK6ZqUWw6Buj0IUf42L3hUtQ3EXQU23loNch1oFteSWPjzdig X-Received: by 2002:a63:2e46:: with SMTP id u67mr3263658pgu.259.1561634668460; Thu, 27 Jun 2019 04:24:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561634668; cv=none; d=google.com; s=arc-20160816; b=dOy8AWVVzoL7WP33pdmOUpo3UeTZJzEC0BvbOSYeYURgIxZZ7pk7zgAhqmmnsvKUzR LMj9DgT1sIcqV1XDRCahHBpzASQ7YkijB4TAvphFTY1uCjy0OpT2gHNHvYcRgTA3xDEj A1X1x5HaQmUGlk6Bth9GS9vPFFtbasgW+6Qw/g99aYwCtiQvtsZlZsHcpukVMbNErTPJ +yxmb91BAAJn6v/5xzT2nsNWdLuG9hD9pkMggJwghu9gsiub1IMxxPEuYNw0qzhxGMIX QHpFG4i9aj1KuM20adrUuQc6ksW8S4t5OanoFTnRPBf42nA12Sm5st6SXL/IvWjdBi1/ gnmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=F4KskJ1NAl/aeAMSSANWZVmj0vaROvOll7pDHlQvKrE=; b=AQWKhWX1XfOYdJ7/iPxJrOsmrJmt7gut1JnBPSGMZzr19UYVh8819TaAg96yd3n/OZ 2XiMHr5F6CVyQGOSfQDQGTpj3LQR6DN3gHgcgtRP0nYnLJmlku8L5ClH3hXbyPtWcvE+ 4lomwbtku1u4RP+BfspEe906X4HOC9Z/p0HcAE9JimdCnpvvfPuJ5ukM6ct2iUPrHWkt WofbhbbzerS8v1sj0LtD1vLglYnoaWxZFu/LtSmhrsrIXqZzgFztGp9ipJwty0JK/FCr BRlgHkrAz2ZC53elQhAFjt9hsBk6eGnd8rUIb6iHCIvdG3Lt+w/Pfv76nYczVIUZ2EVy sxMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="nENRI+O/"; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 64si2028901pld.334.2019.06.27.04.24.12; Thu, 27 Jun 2019 04:24:28 -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=@linaro.org header.s=google header.b="nENRI+O/"; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726632AbfF0LYD (ORCPT + 99 others); Thu, 27 Jun 2019 07:24:03 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:41333 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726308AbfF0LYD (ORCPT ); Thu, 27 Jun 2019 07:24:03 -0400 Received: by mail-lf1-f67.google.com with SMTP id 136so1306080lfa.8 for ; Thu, 27 Jun 2019 04:24:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=F4KskJ1NAl/aeAMSSANWZVmj0vaROvOll7pDHlQvKrE=; b=nENRI+O/Sos7OKNBFX4fcuIjQJRwvWzpnQUI823OhuXy+g5L/2I06M0BvsD+EPBkBU jnMzz/8KF3lE8zGW4CZDHMmVSPuFkrs5D4b92ModrlnG7TNh9x/cgwb45aONOdqKlEec qS39kC+nzP1BDmIUzDeRmazx/dGoP61W2XHfSAtWn3ha5bU5t+BZA1+MNUIR4nBz4tOl NAX57XZMuQsMyPqhE+DroIbq+/20QvpPbo+0VMKO0XfCbCXNeQGCCgQ1pIrfPwdKeTta XzBI5e2tKYh0r3WdeMUnXmSkKv+DdJ5WiGWdmeTlnDcanzuEXZ+F1JSocegrhnetAmjw IkyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=F4KskJ1NAl/aeAMSSANWZVmj0vaROvOll7pDHlQvKrE=; b=m3w7ow8YJlwdCLTgoWR4H0xtTpX1ilf+65A66oG1RysTZvTt/DwJG9TBBB4J4sWROQ IkcXxgCom5H6MGBF/njuAYkhYi4JI2TGj2qtPwPGmIDEU2U2RmQN6nO9vouEuJSPOEYH M+lC1wQKOKWp+vfHx45idtv6DnBdva5OPERs3DJcr/zzq87KGs8Bfx7WaHOhI+kQIcLC hu+I9AnFpMcvC2XM1bTC/4SKqfFKXpDyiHkOcXtLtLKGSo3EcwfuWEHmkjk6Pnt8UPQX Jx1iwfH/pvq/ACE/jkCIQrLiuX3gLs5sdxPIcJtS4yiXi0wvPRlLh2F7eJQjUsLCflcL FMuw== X-Gm-Message-State: APjAAAUiC6Y/7zCHlGeL8qboJ6YIokEVZvKh4u91cS7nvAcxBNlCLMVX CtzPEmcpjUtQp3vEAfBvgyWwb3TzRFN46IGCx7uuSw== X-Received: by 2002:a19:6a01:: with SMTP id u1mr1788889lfu.141.1561634640859; Thu, 27 Jun 2019 04:24:00 -0700 (PDT) MIME-Version: 1.0 References: <20190626035445.236406-1-drinkcat@chromium.org> In-Reply-To: <20190626035445.236406-1-drinkcat@chromium.org> From: Linus Walleij Date: Thu, 27 Jun 2019 12:23:49 +0100 Message-ID: Subject: Re: [PATCH v2] pinctrl: mediatek: Update cur_mask in mask/mask ops To: Nicolas Boichat Cc: Sean Wang , Matthias Brugger , "moderated list:ARM/Mediatek SoC support" , "open list:GPIO SUBSYSTEM" , Linux ARM , "linux-kernel@vger.kernel.org" , Chuanjia Liu , Evan Green , Stephen Boyd Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 26, 2019 at 4:54 AM Nicolas Boichat wrote: > 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). > > Step by step, for a line that has both wake and interrupt enabled: > 1. cur_mask[irq] = 1; wake_mask[irq] = 1; EINT_EN[irq] = 1 (interrupt > enabled at hardware level) > 2. System suspends, resumes due to that line (at this stage EINT_EN > == wake_mask) > 3. irq_pm_check_wakeup is called, and disables the interrupt => > EINT_EN[irq] = 0, but we still have cur_mask[irq] = 1 > 4. mtk_eint_do_resume is called, and restores EINT_EN = cur_mask, so > it reenables EINT_EN[irq] = 1 => interrupt storm as the driver > is not yet ready to handle the interrupt. > > This patch fixes the issue in step 3, by recording all 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. > > The interrupt will be re-enabled properly later on, sometimes after > mtk_eint_do_resume, when the driver is ready to handle it. > > Fixes: 58a5e1b64b ("pinctrl: mediatek: Implement wake handler and suspend resume") > Signed-off-by: Nicolas Boichat > Acked-by: Sean Wang Patch applied after extending the has for Fixes: to 12 digits. Yours, Linus Walleij