Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5432201imm; Sun, 26 Aug 2018 20:04:45 -0700 (PDT) X-Google-Smtp-Source: ANB0VdalnIw7jnPmGYtfYRwZGcEMhk/QwnDGBLdiAtaiAMeAYN64ufeHTc44QteHykbVpjhmcq9i X-Received: by 2002:a17:902:20ca:: with SMTP id v10-v6mr11325833plg.156.1535339085676; Sun, 26 Aug 2018 20:04:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535339085; cv=none; d=google.com; s=arc-20160816; b=ofA5jXhOPw6zhvXN2W66GSO3KzRik/3nOsxeHT+5E5/ho8x8jzDkcbVMtA8CqGwqk1 NZguAy09guTn1mrbwODMo1jSMY8nNF/XMkfI3beWtDHgzMmWliDZhDgfKV6STy8B3980 1X3d2XFTes3WkydhHwrxpLowOcHawc+gWMc9diIsky005Mi29gj+oRcrNFGA1w5wkBNP b4FuBcGNhvm2IMJpr61YGDgoQ0x3lYeiPT4baIVJB54fYNmao/+b83lsnZUwB/y1h2iU QzpiTXeqjSuLUBGZJzRlc3mbFEbvi+NpXWdIp1AgYZn3pvhcCwJhx4T86RUaGXjTN7xe k8Gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=Vn/sueEXlDG6TAs/DSlJ4uHiMKebwBJrqHfStchyCO8=; b=XC/n+bKXXAxJiw+sjK0TGqZVYqt2SVAeyl1ZFXsZrqJuTFZDnBEfBx45aZCzxZcm0Y iqry1+xHVzzvCo8zYN331WP3S0tl8D1R8SqWnRNDiPPO3F3fF7iCZqvpVwwf1En2MHVI c1lj6ddTcMnlIkODnGEnmFGkMrPJZligwF7o8K9OkxebnySfTMCZ54XHlbwoJmjPdiWO dTG12IBRhFlCb2leW2nqseeT6McDowRnzJrxbWDfiejGZR7gsp798EeRZ+EiBFVdeSzA OaXw9XWH9/jwK+wzunDFnk+Jl6qsSkh5jKj5Ck0cg6+Bvui+0dfUZhvjmLfNvc4HfdZG 380Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KrtOu6Iv; 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 l15-v6si11171817pgh.593.2018.08.26.20.04.30; Sun, 26 Aug 2018 20:04:45 -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=KrtOu6Iv; 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 S1727158AbeH0Gq2 (ORCPT + 99 others); Mon, 27 Aug 2018 02:46:28 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:39397 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726971AbeH0Gq2 (ORCPT ); Mon, 27 Aug 2018 02:46:28 -0400 Received: by mail-pl1-f194.google.com with SMTP id w14-v6so3472750plp.6 for ; Sun, 26 Aug 2018 20:01:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Vn/sueEXlDG6TAs/DSlJ4uHiMKebwBJrqHfStchyCO8=; b=KrtOu6IvEsR5t5j7/cAGC7Wuz5FMqGbKfKkx0uRRuD5g5i+0GMhswvcznIBq/N1CKf H9AtfWmlx+3QmyjXllGuwQim40rVdDNwcuAtZXDTeFMMhA7G3X99fGwvRLzlINqTWnWS PANVbmx0tSk+CEcXarcv/xdVs4gm8oBinVvVM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Vn/sueEXlDG6TAs/DSlJ4uHiMKebwBJrqHfStchyCO8=; b=aWh1ab4sTu4Z/Eo53UeJhputOdNbntrf3ftTjH2S+6Gz6Z4YfS1Hu0PWdQaBOH7qrz AbbBPXgqsAy5o48KN9cFRHAgaYD1KxlOjzQ8FWGDeUmPP8FxKhe2ebN6Xfqm+hbXlazu 8FN/uFzt5mN6S3ogDiCjQz8SvAYc32mH6of7jlszb+XXbotyEu2DrDKT8ESh/ERknYp2 aoNaPShdVFfCcEhYS6ngw7w+dC3H3tw9iYL3RUtDj4ekzpwXX2is4HSw31bP976R4Eeo AsjnkQW8ajSXP4HOKaXHH0DI/lpLsiQcbhJq2nzcTMTyrWxDLRLtcTNf+We4PzcleYic NthA== X-Gm-Message-State: APzg51AvfIpqQONFD+8tpX+Fedom3agV74tpNMi2/sqU4hSmdtmR3B8J mx0Kb1V5QqZ0aJQAlJjNErn4eA== X-Received: by 2002:a17:902:561:: with SMTP id 88-v6mr11126659plf.320.1535338908822; Sun, 26 Aug 2018 20:01:48 -0700 (PDT) Received: from tuxbook-pro (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id z11-v6sm19681362pff.162.2018.08.26.20.01.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 26 Aug 2018 20:01:48 -0700 (PDT) Date: Sun, 26 Aug 2018 20:05:26 -0700 From: Bjorn Andersson To: Stephen Boyd Cc: Linus Walleij , linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, linux-arm-msm@vger.kernel.org, Doug Anderson Subject: Re: [PATCH v3 1/3] pinctrl: msm: Really mask level interrupts to prevent latching Message-ID: <20180827030526.GH3048@tuxbook-pro> References: <20180816200648.90458-1-swboyd@chromium.org> <20180816200648.90458-2-swboyd@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180816200648.90458-2-swboyd@chromium.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 16 Aug 13:06 PDT 2018, Stephen Boyd wrote: > The interrupt controller hardware in this pin controller has two status > enable bits. The first "normal" status enable bit enables or disables > the summary interrupt line being raised when a gpio interrupt triggers > and the "raw" status enable bit allows or prevents the hardware from > latching an interrupt into the status register for a gpio interrupt. > Currently we just toggle the "normal" status enable bit in the mask and > unmask ops so that the summary irq interrupt going to the CPU's > interrupt controller doesn't trigger for the masked gpio interrupt. > > For a level triggered interrupt, the flow would be as follows: the pin > controller sees the interrupt, latches the status into the status > register, raises the summary irq to the CPU, summary irq handler runs > and calls handle_level_irq(), handle_level_irq() masks and acks the gpio > interrupt, the interrupt handler runs, and finally unmask the interrupt. > When the interrupt handler completes, we expect that the interrupt line > level will go back to the deasserted state so the genirq code can unmask > the interrupt without it triggering again. > > If we only mask the interrupt by clearing the "normal" status enable bit > then we'll ack the interrupt but it will continue to show up as pending > in the status register because the raw status bit is enabled, the > hardware hasn't deasserted the line, and thus the asserted state latches > into the status register again. When the hardware deasserts the > interrupt the pin controller still thinks there is a pending unserviced > level interrupt because it latched it earlier. This behavior causes > software to see an extra interrupt for level type interrupts each time > the interrupt is handled. > > Let's fix this by clearing the raw status enable bit for level type > interrupts so that the hardware stops latching the status of the > interrupt after we ack it. We don't do this for edge type interrupts > because it seems that toggling the raw status enable bit for edge type > interrupts causes spurious edge interrupts. > > Cc: Bjorn Andersson > Cc: Doug Anderson > Signed-off-by: Stephen Boyd Reviewed-by: Bjorn Andersson Regards, Bjorn > --- > drivers/pinctrl/qcom/pinctrl-msm.c | 24 ++++++++++++++++++++++++ > 1 file changed, 24 insertions(+) > > diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c > index 2155a30c282b..5d72ffad32c2 100644 > --- a/drivers/pinctrl/qcom/pinctrl-msm.c > +++ b/drivers/pinctrl/qcom/pinctrl-msm.c > @@ -634,6 +634,29 @@ static void msm_gpio_irq_mask(struct irq_data *d) > raw_spin_lock_irqsave(&pctrl->lock, flags); > > val = readl(pctrl->regs + g->intr_cfg_reg); > + /* > + * There are two bits that control interrupt forwarding to the CPU. The > + * RAW_STATUS_EN bit causes the level or edge sensed on the line to be > + * latched into the interrupt status register when the hardware detects > + * an irq that it's configured for (either edge for edge type or level > + * for level type irq). The 'non-raw' status enable bit causes the > + * hardware to assert the summary interrupt to the CPU if the latched > + * status bit is set. There's a bug though, the edge detection logic > + * seems to have a problem where toggling the RAW_STATUS_EN bit may > + * cause the status bit to latch spuriously when there isn't any edge > + * so we can't touch that bit for edge type irqs and we have to keep > + * the bit set anyway so that edges are latched while the line is masked. > + * > + * To make matters more complicated, leaving the RAW_STATUS_EN bit > + * enabled all the time causes level interrupts to re-latch into the > + * status register because the level is still present on the line after > + * we ack it. We clear the raw status enable bit during mask here and > + * set the bit on unmask so the interrupt can't latch into the hardware > + * while it's masked. > + */ > + if (irqd_get_trigger_type(d) & IRQ_TYPE_LEVEL_MASK) > + val &= ~BIT(g->intr_raw_status_bit); > + > val &= ~BIT(g->intr_enable_bit); > writel(val, pctrl->regs + g->intr_cfg_reg); > > @@ -655,6 +678,7 @@ static void msm_gpio_irq_unmask(struct irq_data *d) > raw_spin_lock_irqsave(&pctrl->lock, flags); > > val = readl(pctrl->regs + g->intr_cfg_reg); > + val |= BIT(g->intr_raw_status_bit); > val |= BIT(g->intr_enable_bit); > writel(val, pctrl->regs + g->intr_cfg_reg); > > -- > Sent by a computer through tubes >