Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1146217pxb; Thu, 19 Aug 2021 22:01:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyimEHO7mwtxK8lhkIwSJ8M980ww5HeZkPp5qDUOMS7/KWIOWn/IHEGFpj3nzTE8b5n6IXI X-Received: by 2002:aa7:d05a:: with SMTP id n26mr20724721edo.272.1629435684463; Thu, 19 Aug 2021 22:01:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629435684; cv=none; d=google.com; s=arc-20160816; b=HuXAQ8pGt92z7ha9c2fIJ0oYmeBDkNMsYMsL5Mpgifol0tmQ/UaH9GV5mQK2jpZohG wJ/a48lghQl78V2/0ZxIJFwQPUG1tC2werHe8thYUYukONH5ptUdfKH0L3Xzf2fwjAyp 34v01SxpzZNPG6bvU8wWpkyl3enCmx57egxT9hVYxGHYzMn/fGcYOagRDM19GvErSI4M psLz+fw/7nkbljEgXtVEi6V5aI+LR2vYws1O1DeJd3rQUa/ffIT4SpDI6NWkSvkHwhSB Y+aeTStt459BLf6U1f/CGOxVHDZHdYT6Nj9uQ35szEDf+6mq8AQV8z0oBoc61PSMfgUP luIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=w3eqHGMGnZrc4/+v+wtfBYqAmtbWxOwgb0eJIVdMEG0=; b=GZMUM5G4EqLNwourEGH3Sq5XjtBRzxJZwuUfNlPliwkTaeQfpwwfn3c3clok/H34Y2 pODFynpNg0KgTPy2nJU8ZZj0H4Mrz3y/YdLsgPUQQEL8NbpIkc5I9eS0+DlAXvGrwRJg rwMlWf9ClXyh0Ro0mCtoWjLdU9WxiG0rA7fWosQJlIofPSSb9jBmn4nEyOVkeAWuwZoC O30k5daWl03XnlLxb/pnHrknWAyFwGia3t4qfSn3qJZvSITJGrqv2D9fdvvUrn+eyVSq PFoHwJXrXnTYoLZ6e3aKR2gZHKk674Ag9DtRGZRkcL8mE33Uw6V9h6ikGkVbM5h1KH2j LhVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@quicinc.com header.s=qcdkim header.b=QiQIWy5I; 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=fail (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l14si4230456edb.467.2021.08.19.22.00.59; Thu, 19 Aug 2021 22:01:24 -0700 (PDT) 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=fail header.i=@quicinc.com header.s=qcdkim header.b=QiQIWy5I; 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=fail (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234483AbhHTE7V (ORCPT + 99 others); Fri, 20 Aug 2021 00:59:21 -0400 Received: from alexa-out-sd-01.qualcomm.com ([199.106.114.38]:43399 "EHLO alexa-out-sd-01.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233395AbhHTE7R (ORCPT ); Fri, 20 Aug 2021 00:59:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1629435520; x=1660971520; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=Q9cKJpllo1DhhME1a3XXJiNfVwTF4UKgzs2i3F4Z3Zw=; b=QiQIWy5I9PySA2KhUKj07MpiedDcXRCP/kcabo+pdQNIHfcRnLZyAQkC 8ZHttV0ahnHFcdBvN1Wm7ljWKVQbv0xZ60bTpVB9tM/3jLkzi6mDTTFOm hes9n8BXEWU4dGNp6INV7rKTsgV0ISHaSs6VUYe4EOhVGIknpZWA5Xw2N E=; Received: from unknown (HELO ironmsg02-sd.qualcomm.com) ([10.53.140.142]) by alexa-out-sd-01.qualcomm.com with ESMTP; 19 Aug 2021 21:58:39 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg02-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2021 21:58:39 -0700 Received: from nalasex01c.na.qualcomm.com (10.47.97.35) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.858.15; Thu, 19 Aug 2021 21:58:39 -0700 Received: from fenglinw-gv.qualcomm.com (10.80.80.8) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.858.15; Thu, 19 Aug 2021 21:58:37 -0700 From: Fenglin Wu To: , , CC: , , Subject: [PATCH V1 2/9] spmi: pmic-arb: do not ack and clear peripheral interrupts in cleanup_irq Date: Fri, 20 Aug 2021 12:57:57 +0800 Message-ID: <1629435488-10228-3-git-send-email-quic_fenglinw@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1629435488-10228-1-git-send-email-quic_fenglinw@quicinc.com> References: <1629435488-10228-1-git-send-email-quic_fenglinw@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanexm03h.na.qualcomm.com (10.85.0.50) To nalasex01c.na.qualcomm.com (10.47.97.35) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Subbaraman Narayanamurthy Currently, cleanup_irq() is invoked when a peripheral's interrupt fires and there is no mapping present in the interrupt domain of spmi interrupt controller. The cleanup_irq clears the arbiter bit, clears the pmic interrupt and disables it at the pmic in that order. The last disable in cleanup_irq races with request_irq() in that it stomps over the enable issued by request_irq. Fix this by not writing to the pmic in cleanup_irq. The latched bit will be left set in the pmic, which will not send us more interrupts even if the enable bit stays enabled. When a client wants to request an interrupt, use the activate callback on the irq_domain to clear latched bit. This ensures that the latched, if set due to the above changes in cleanup_irq or when the bootloader leaves it set, gets cleaned up, paving way for upcoming interrupts to trigger. With this, there is a possibility of unwanted triggering of interrupt right after the latched bit is cleared - the interrupt may be left enabled too. To avoid that, clear the enable first followed by clearing the latched bit in the activate callback. Signed-off-by: Subbaraman Narayanamurthy [collinsd@codeaurora.org: fix merge conflict] Signed-off-by: David Collins Signed-off-by: Fenglin Wu --- drivers/spmi/spmi-pmic-arb.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/spmi/spmi-pmic-arb.c b/drivers/spmi/spmi-pmic-arb.c index 295e19f..4d7ad004 100644 --- a/drivers/spmi/spmi-pmic-arb.c +++ b/drivers/spmi/spmi-pmic-arb.c @@ -492,16 +492,6 @@ static void cleanup_irq(struct spmi_pmic_arb *pmic_arb, u16 apid, int id) dev_err_ratelimited(&pmic_arb->spmic->dev, "%s apid=%d sid=0x%x per=0x%x irq=%d\n", __func__, apid, sid, per, id); writel_relaxed(irq_mask, pmic_arb->ver_ops->irq_clear(pmic_arb, apid)); - - if (pmic_arb_write_cmd(pmic_arb->spmic, SPMI_CMD_EXT_WRITEL, sid, - (per << 8) + QPNPINT_REG_LATCHED_CLR, &irq_mask, 1)) - dev_err_ratelimited(&pmic_arb->spmic->dev, "failed to ack irq_mask = 0x%x for ppid = %x\n", - irq_mask, ppid); - - if (pmic_arb_write_cmd(pmic_arb->spmic, SPMI_CMD_EXT_WRITEL, sid, - (per << 8) + QPNPINT_REG_EN_CLR, &irq_mask, 1)) - dev_err_ratelimited(&pmic_arb->spmic->dev, "failed to ack irq_mask = 0x%x for ppid = %x\n", - irq_mask, ppid); } static void periph_interrupt(struct spmi_pmic_arb *pmic_arb, u16 apid) @@ -667,6 +657,7 @@ static int qpnpint_irq_domain_activate(struct irq_domain *domain, u16 apid = hwirq_to_apid(d->hwirq); u16 sid = hwirq_to_sid(d->hwirq); u16 irq = hwirq_to_irq(d->hwirq); + u8 buf; if (pmic_arb->apid_data[apid].irq_ee != pmic_arb->ee) { dev_err(&pmic_arb->spmic->dev, "failed to xlate sid = %#x, periph = %#x, irq = %u: ee=%u but owner=%u\n", @@ -675,6 +666,10 @@ static int qpnpint_irq_domain_activate(struct irq_domain *domain, return -ENODEV; } + buf = BIT(irq); + qpnpint_spmi_write(d, QPNPINT_REG_EN_CLR, &buf, 1); + qpnpint_spmi_write(d, QPNPINT_REG_LATCHED_CLR, &buf, 1); + return 0; } -- Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.