Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3922475imm; Mon, 8 Oct 2018 11:44:29 -0700 (PDT) X-Google-Smtp-Source: ACcGV60t8EyWsgCnaN96b5w5FY6XROSOM4WKjpS7TKKJIfokp/guua1lIV1qJjapD5KnK8aNOy1Z X-Received: by 2002:a17:902:82c9:: with SMTP id u9-v6mr24875296plz.320.1539024269754; Mon, 08 Oct 2018 11:44:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539024269; cv=none; d=google.com; s=arc-20160816; b=A155MoNoXzi/71rfrVEBGPkYpRQe+ThtJuFM4ofOyv8c7hithJtiStpUoCVt/qeTt9 2JdjhJxZp2XHzS7IYE/gbONZWOXFxY3lm2scFadYfBd4U02vBDBLHksFRvBYUim2IDRm Q3/WtnAQpgNn9aYNPyZ/EDcA014gEHlasO6+OxyrTrhiNTjIS5UyDGu75EUgWkER3YbV 3mOzk+ahAz6tuy2kZ8VliqJ2HJvN4io7BAkkwHE6nGn7q/UzskmV7Mc9WB1gN6xm4Ljt X5zlNlFdK0FvigUwp7emxjmPuEF46H8rO6Cnc+FLvwYrnje/WUgOT1FwEsGoey6xwoSc e+Dg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VkKPPOJIuUiaVcMTvGsq8ShAQLpdH/Tx36PXUA/6Fnc=; b=OuRJI+EyPeudVkjjJz9ZeAoqBrXHm5KpqzDYilFpe8K8yaBb1X01iK54+PtUaVL+N1 LuFtIujy9MnimAQgAweEeO+BnQpNKYatFRwtbxL61DzC3eBlusnkW/idABfY9j0z1Jxc ymYHf+8tf9v2mLqEznlMie6T/azQDqcTOlLn/zWQrGS+WuUaVKieXcExB3mRGyACM8FY WxAgmZ6lXk858pqcjIbvpi4p4pQi6RBZB3pEwSminRc2vhpAjPuHIzJfxjH2wGehLYv8 riAjSBurWqbvkXtFgVrdZc4AwQ1OYJzZTlEeSuvgp1+q60/YD0L3s8ioQnKv0B/5LPaU +3EQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="cY/tHOO6"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k9-v6si19043559pfg.57.2018.10.08.11.44.14; Mon, 08 Oct 2018 11:44:29 -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=@kernel.org header.s=default header.b="cY/tHOO6"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730349AbeJIBz6 (ORCPT + 99 others); Mon, 8 Oct 2018 21:55:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:43694 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726672AbeJIBz6 (ORCPT ); Mon, 8 Oct 2018 21:55:58 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 487FD2087D; Mon, 8 Oct 2018 18:42:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539024172; bh=sqn/I/7VYEI6yC7hlj1koY5iiU2Qqk9qrlFYf75R8M0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cY/tHOO65F4vtuubCZZc5zE+LD5DaajrxE+AhyTY+qldVFzR7a2ve+Wo/nqitPUf1 LAxsf2uHw4F8c2H1UPlvCQKI7MqNMdHyR1hXMlTWLb+gxiAI0b09uVoG0BXAfbXkby z8q/oQzM9uHuZDbcNd9RaLqMC63Y2MvVxyslghXk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stephen Boyd , Douglas Anderson , Bjorn Andersson , Linus Walleij , Sasha Levin Subject: [PATCH 4.14 45/94] pinctrl: msm: Really mask level interrupts to prevent latching Date: Mon, 8 Oct 2018 20:31:26 +0200 Message-Id: <20181008175607.131565543@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181008175605.067676667@linuxfoundation.org> References: <20181008175605.067676667@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-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 @@ -610,6 +610,29 @@ static void msm_gpio_irq_mask(struct irq 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); @@ -631,6 +654,7 @@ static void msm_gpio_irq_unmask(struct i 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);