Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp955471pxu; Wed, 16 Dec 2020 20:56:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJyKP+YXbZyLPDTpNdeMjScMIRNt6mjuFAkMr6fRRS03k+ooOckOLUZ2eCEeoR4igVbFRQOy X-Received: by 2002:a17:907:373:: with SMTP id rs19mr32067775ejb.298.1608180984702; Wed, 16 Dec 2020 20:56:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608180984; cv=none; d=google.com; s=arc-20160816; b=by5/zcBOcXa4RFeIEuvbZNhaH3VWCWsVICaJ54WXdYbY0EqiqSTYrJoUXTPiIGFxOq uvdoHjQdyhk47oMAtHbk+WZnAfBC7MwvyV7RoUAPghwDaBgHAHm/UmrKXnSDNWmWiFLG ME/7s6xNxKEM6wp9nOqPZQEVw4AvxF0K6PeXAAHe7T2FxH6YuU6VGWzRfiW/47MKxXLy jQEmFwXz2FdVZZZoSyEXyG17owNa37KARt613rc3Hufo7arOa0qqzPyAwJQuZ/wjdH5I MjwvTwHqn6r/d0KwY7RcPDXYn6IlXFgPe903kwt6TjbKwkuTclELmYvZUJEEMamndZCG ferg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:message-id:date:to:cc:from:subject :references:in-reply-to:content-transfer-encoding:mime-version :dkim-signature; bh=RGWsO2xASpBiXhZOz0Bm5x2XJu6xcytDBXU8vp0kbtY=; b=zvBKclSwh9e51xtEa4Xn0ilzyyND6dPNJnJz/rB1OJafGU9Q1AiBJUeBMP1TKXfua0 MrHOqL8rmYmJinUXS32TxHaAvXWjVw4by0Ngk+5Tkpds+/JYNbPk8a+7odPAE8/Qkg4d Af2qyQyijnAhTsE4JseJ1hnmum0nESgwXtT9v+kbpwtfqRyIS4rT2Iy4MTZr7fiTJaqY tzLlLhcNrnpFMeO/Z1AqBc31/5FXtlCsMM9MaBsf/SlEcx2gwALQZuOw3Tg9cp65rTqo nFXCW1NP+7jQquzfC+lgKvRDbU/+vAaI0jq9ZkIjdImNnITjtt0UtmIBfP76yT8pzwz3 uYhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=P2i13ZvY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id q4si3574396edn.338.2020.12.16.20.56.00; Wed, 16 Dec 2020 20:56:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=P2i13ZvY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726644AbgLQEzd (ORCPT + 99 others); Wed, 16 Dec 2020 23:55:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726536AbgLQEzb (ORCPT ); Wed, 16 Dec 2020 23:55:31 -0500 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EECCC0617A7 for ; Wed, 16 Dec 2020 20:54:51 -0800 (PST) Received: by mail-pg1-x52a.google.com with SMTP id c22so4062167pgg.13 for ; Wed, 16 Dec 2020 20:54:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:content-transfer-encoding:in-reply-to:references :subject:from:cc:to:date:message-id:user-agent; bh=RGWsO2xASpBiXhZOz0Bm5x2XJu6xcytDBXU8vp0kbtY=; b=P2i13ZvYTtEMG+HaAg5v6BDYs4ilVIzVLiyIU6d4UlHfThAGlK5l4UW+rM//rFLebJ 7+kdK2YwrVdr9McAUw1Qd7Doik5GUQCK3y0fXEG5apfnKAHZVMb5w7Jchf0wcgwFGlfp F1aKbR4IKmtsEyyUMw0dq5puhhIKp5M5Jx8KE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:content-transfer-encoding :in-reply-to:references:subject:from:cc:to:date:message-id :user-agent; bh=RGWsO2xASpBiXhZOz0Bm5x2XJu6xcytDBXU8vp0kbtY=; b=OV3EVluCo8opgIhDCbljHNR3Qtuj/v5PE89mhnZd8iLBzvAbUvnNWe2oH4eT1ACaoF mUPjteChGb3Z67gEuZH5cUThXqMXJimjO/w3jWwwdLKtubs/o34sjvJu5ErX2Z32w2sk 0/cX3CQl0J72GRO+2d3RkgDD9JkI69lHQE3QgCgk7BckQ2J1tu6coQ/webOUoqKO0bfA V0+wBxEAJdrfYh7+AfAm7OQU1I+AG97481fECFYHpIL6beaeujsysFTZPV0TdRtwxqxe HTFcYhoA28+yeH/C38gR1Ra5i9iMItd9EHdsMJTDCmWhNYq+Ztt3HVRjJqNCW7TPffuQ GzXA== X-Gm-Message-State: AOAM532EbSwPx1B7vHJloLGKqwDXA6bzBf/MpyyLpzQkwd8n7vdhrz/p vKXPY45BU/xJyVzpsfyd6t6BdA== X-Received: by 2002:a63:5866:: with SMTP id i38mr4288937pgm.26.1608180890551; Wed, 16 Dec 2020 20:54:50 -0800 (PST) Received: from chromium.org ([2620:15c:202:201:3e52:82ff:fe6c:83ab]) by smtp.gmail.com with ESMTPSA id z20sm3397734pjq.16.2020.12.16.20.54.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Dec 2020 20:54:49 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <20201211141514.v4.3.I7cf3019783720feb57b958c95c2b684940264cd1@changeid> References: <20201211141514.v4.1.I2702919afc253e2a451bebc3b701b462b2d22344@changeid> <20201211141514.v4.3.I7cf3019783720feb57b958c95c2b684940264cd1@changeid> Subject: Re: [PATCH v4 3/4] pinctrl: qcom: Don't clear pending interrupts when enabling From: Stephen Boyd Cc: Bjorn Andersson , Rajendra Nayak , Maulik Shah , linux-arm-msm@vger.kernel.org, Srinivas Ramana , Neeraj Upadhyay , linux-gpio@vger.kernel.org, Douglas Anderson , Andy Gross , linux-kernel@vger.kernel.org To: Douglas Anderson , Jason Cooper , Linus Walleij , Marc Zyngier , Thomas Gleixner Date: Wed, 16 Dec 2020 20:54:47 -0800 Message-ID: <160818088793.1580929.1672018770454181938@swboyd.mtv.corp.google.com> User-Agent: alot/0.9.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Douglas Anderson (2020-12-11 14:15:37) > In Linux, if a driver does disable_irq() and later does enable_irq() > on its interrupt, I believe it's expecting these properties: > * If an interrupt was pending when the driver disabled then it will > still be pending after the driver re-enables. > * If an edge-triggered interrupt comes in while an interrupt is > disabled it should assert when the interrupt is re-enabled. >=20 > If you think that the above sounds a lot like the disable_irq() and > enable_irq() are supposed to be masking/unmasking the interrupt > instead of disabling/enabling it then you've made an astute > observation. Specifically when talking about interrupts, "mask" > usually means to stop posting interrupts but keep tracking them and > "disable" means to fully shut off interrupt detection. It's > unfortunate that this is so confusing, but presumably this is all the > way it is for historical reasons. >=20 > Perhaps more confusing than the above is that, even though clients of > IRQs themselves don't have a way to request mask/unmask > vs. disable/enable calls, IRQ chips themselves can implement both. > ...and yet more confusing is that if an IRQ chip implements > disable/enable then they will be called when a client driver calls > disable_irq() / enable_irq(). >=20 > It does feel like some of the above could be cleared up. However, > without any other core interrupt changes it should be clear that when > an IRQ chip gets a request to "disable" an IRQ that it has to treat it > like a mask of that IRQ. >=20 > In any case, after that long interlude you can see that the "unmask > and clear" can break things. Maulik tried to fix it so that we no > longer did "unmask and clear" in commit 71266d9d3936 ("pinctrl: qcom: > Move clearing pending IRQ to .irq_request_resources callback"), but it > only handled the PDC case (it also had problems, but that's the > subject of another patch). Let's fix this for the non-PDC case. >=20 > From my understanding the source of the phantom interrupt in the > non-PDC case was the one that could have been introduced in > msm_gpio_irq_set_type(). Let's handle that one and then get rid of > the clear. >=20 > Fixes: 4b7618fdc7e6 ("pinctrl: qcom: Add irq_enable callback for msm gpio= ") > Signed-off-by: Douglas Anderson > --- Reviewed-by: Stephen Boyd One comment clarification below. > I don't have lots of good test cases here, so hopefully someone from > Qualcomm can confirm that this works well for them and there isn't > some other phantom interrupt source that I'm not aware of. >=20 > Changes in v4: > - ("pinctrl: qcom: Don't clear pending interrupts when enabling") split f= or v4. >=20 > drivers/pinctrl/qcom/pinctrl-msm.c | 32 +++++++++++++----------------- > 1 file changed, 14 insertions(+), 18 deletions(-) >=20 > diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pi= nctrl-msm.c > index 588df91274e2..f785646d1df7 100644 > --- a/drivers/pinctrl/qcom/pinctrl-msm.c > +++ b/drivers/pinctrl/qcom/pinctrl-msm.c > @@ -1046,6 +1032,16 @@ static int msm_gpio_irq_set_type(struct irq_data *= d, unsigned int type) > } > msm_writel_intr_cfg(val, pctrl, g); > =20 > + /* > + * The first time we set RAW_STATUS_EN it could trigger an interr= upt. > + * Clear it. This is safe because we have IRQCHIP_SET_TYPE_MASKE= D. Clear the interrupt? 'it' is ambiguous. > + */ > + if (!was_enabled) { > + val =3D msm_readl_intr_status(pctrl, g); > + val &=3D ~BIT(g->intr_status_bit); > + msm_writel_intr_status(val, pctrl, g); > + } > + > if (test_bit(d->hwirq, pctrl->dual_edge_irqs)) > msm_gpio_update_dual_edge_pos(pctrl, g, d); >