Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4475136imm; Mon, 8 Oct 2018 23:34:50 -0700 (PDT) X-Google-Smtp-Source: ACcGV61+x08wa6tlgQgSWfcrtj2ZL8zCBQGqO6XxQa7Zh8W3IqGR8z20juFhhw1pw/rZ085xAQPo X-Received: by 2002:a63:5f03:: with SMTP id t3-v6mr24594878pgb.68.1539066890342; Mon, 08 Oct 2018 23:34:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539066890; cv=none; d=google.com; s=arc-20160816; b=A87e+DpqyCpWNbI6OK49klYcikUim69cq2DzzoSM5YRyX0J1KSFqNslkaiFGMA8Px+ 0qRFaQEponoWKE30yTB3iGJrfcO1/i4iUCCGGe1iFtmHgfWrhjjFwUqHIXq9GClcrQgA BIrM/NNbB84D9EXjgjH9fTDySEj9TttOuGjJ0TmbW13e3KaYR3ZPNGLFnbxZMkegKkox 9GZpzb1WpD5zcKS3dFfKPnmBzrY/sNOs9PR5gjTA1BY36U4/UWnGDnjxJW5zj4uW2csU haT8THwDiADtOkntWJSXyoogc5MtqzazCPFjyJ0GP5mEwLR5rvjJ3ueUuuukkaJsZ3ml ZwKA== 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; bh=l2Hw+kRVc7h4aPm4XNxXTXYYQHPQcFTfCROAnfJL5CA=; b=tGy/d8E93IRQM0gRyBckk/YvGmXAHj7X49FDZKFIgCNHmJB/dfKn9ADUliYQSzEZbT V5ye+rYAgCuuhcKpvrIh/HRYT4nQvWjCFzn7vrmbgnSLJyFI1NpoEt/Y0NVvYiO6Mkn/ YbADWqoNCC31MZx7j+wVWz9e6cqH0y/ZeFBgzYMEmC8PycdFKXvZZaebS37mLbmhXRAK rLapunN9/BIoIjSuqE4S6j8JhGMMVMzGQieS9NDU0YdOVV/3Au6cdmWYB5dnds5WFqn4 J3ihYIn4JT7aHs9NXnKcRODMQwwd6Cq89clvPDttILbHTglPows+ysMeUaqEtf3D7/7s Vdrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mFI+7rly; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b7-v6si14175243pfj.49.2018.10.08.23.34.35; Mon, 08 Oct 2018 23:34:50 -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=@gmail.com header.s=20161025 header.b=mFI+7rly; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726701AbeJINtF (ORCPT + 99 others); Tue, 9 Oct 2018 09:49:05 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:54290 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725835AbeJINtE (ORCPT ); Tue, 9 Oct 2018 09:49:04 -0400 Received: by mail-wm1-f66.google.com with SMTP id r63-v6so581745wma.4; Mon, 08 Oct 2018 23:33:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=l2Hw+kRVc7h4aPm4XNxXTXYYQHPQcFTfCROAnfJL5CA=; b=mFI+7rlyCPW63rGjNVAy3xE4jd69CJROhWDVFHFOgtQlcdkXHe+Umj81t1GiXlR7JT tgSwiWg3CRGoKThMi9kQfW6XO4/ELiEVlB7WdIjiOsZQ8pMQB4g8MnZA8jOWSw7PsqFM u6TOEUKbK7Isf1w9zCPo4Tjn+KVkix72LEiyYMNBWnDDEbB4KwsZj4iP8sh04Y1JfjS7 ey5stjyNqJ+dh+3yl3edJww75C6nf+yAZHncrjAeeEJEzmaGoRIIYTjB3nNsDcyjdkm+ zms1lwFFfVXSwRBZy0UvoFweb81FDFQGRDQn0LrvKoESO5iQLtZfFtlPwSoR3Jfi68fk k2SQ== 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=l2Hw+kRVc7h4aPm4XNxXTXYYQHPQcFTfCROAnfJL5CA=; b=Af6seAvu27aAfKf0ZX0K5P3TgjCafu7CywH7S1eKBTEwWGzwtYGsNlr8s+u538KDzN yrwyTCeYyjGi3iMC1/vgdFBi5Q+rN2GdfP3F6crO/osw6W9WU5jRX48K/X2XCl9aRvfl t2mnEenSe2Gh6aibLwaYY0O9hcn7YV533xLoqPNHefyTko3sSClXaSWJijustNCwS+mk DgB+9LS3vW8Jp36822YQQJBo7nqzYxhW6h/3rqM7g0CxSNRwaU+iwAk/N+Y4tldcYC9x U/n/8GllleBsAPXq5PnW19HZq11MLVA2bA0zU0Zz+o2hQIIqoUEmZgsFh4h2oWwZP6Zf K2mg== X-Gm-Message-State: ABuFfoiTTPDz/+Hj1oyVzUMyuA18srZmY195KIUPREC+EKPzvJSABg3F uLWwXxaRg16UqgkD2OXWw3w= X-Received: by 2002:a1c:80d4:: with SMTP id b203-v6mr800925wmd.100.1539066821092; Mon, 08 Oct 2018 23:33:41 -0700 (PDT) Received: from flashbox ([2a01:4f8:10b:24a5::2]) by smtp.gmail.com with ESMTPSA id u76-v6sm25328508wmd.10.2018.10.08.23.33.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 Oct 2018 23:33:40 -0700 (PDT) Date: Mon, 8 Oct 2018 23:33:38 -0700 From: Nathan Chancellor To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Stephen Boyd , Douglas Anderson , Bjorn Andersson , Linus Walleij , Sasha Levin Subject: Re: [PATCH 4.4 093/113] pinctrl: msm: Really mask level interrupts to prevent latching Message-ID: <20181009063338.GA22218@flashbox> References: <20181008175530.864641368@linuxfoundation.org> <20181008175536.405502473@linuxfoundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181008175536.405502473@linuxfoundation.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 Mon, Oct 08, 2018 at 08:31:34PM +0200, Greg Kroah-Hartman wrote: > 4.4-stable review patch. If anyone has any objections, please let me know. > > ------------------ > > From: Stephen Boyd > > [ Upstream commit b55326dc969ea2d704a008d9a97583b128f54f4f ] > > 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. > > Signed-off-by: Stephen Boyd > Reviewed-by: Douglas Anderson > Reviewed-by: Bjorn Andersson > Signed-off-by: Linus Walleij > Signed-off-by: Sasha Levin > Signed-off-by: Greg Kroah-Hartman > --- > drivers/pinctrl/qcom/pinctrl-msm.c | 24 ++++++++++++++++++++++++ > 1 file changed, 24 insertions(+) > > --- a/drivers/pinctrl/qcom/pinctrl-msm.c > +++ b/drivers/pinctrl/qcom/pinctrl-msm.c > @@ -577,6 +577,29 @@ static void msm_gpio_irq_mask(struct irq > 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); > > @@ -598,6 +621,7 @@ static void msm_gpio_irq_unmask(struct i > 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); > > > Sigh, sorry, I caught this after I sent my initial all good email but this commit breaks NFC on my Pixel 2 XL (toggle becomes greyed out and apps that want to use it ask to enable it). I can't say why, I'm more than happy to debug but I'm assuming it's some voodoo that Qualcomm has done out of tree. I'll leave it up to you how to proceed given that I can't run mainline :( Nathan