Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp996157pxb; Wed, 1 Sep 2021 14:50:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpliPZW9sQCgZ2m9vvo9GPS0D/RaUgtIkoVNkG7mOrje4M+wUjv7MAP4X1bVq0ZW/qC9qf X-Received: by 2002:a17:906:369a:: with SMTP id a26mr1697052ejc.539.1630533007610; Wed, 01 Sep 2021 14:50:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630533007; cv=none; d=google.com; s=arc-20160816; b=Y7AP4m+dfznrkSzS3/JTNQiQJy+aEBfDHkK++keSAfRe3eYmzgMzM1AhuiPm98EU/M UWVJnId8T3chmXSMqTPaF4QVuUw7arYs9R2eDrCcYQ05UZ0ps+G72gk2iCOH91jt2A5X erxSqzi5gZdhD7PFXuie0QHg4c7RjB9+F1ctHnRhcMUnLKqRBHoxCjRY2p+jUhEjZFQn mvlQTIKW/hHWl3+fQMPZnK+FiPkpDRM7tiOuoogG271iUzp1g8sW1Q7Z1tpRcwr10VWj WELAueC6Sr9Tpp+fUV+3LwZHbRc+DZiMjeZ2KAeCll0TD+7ZhnyIczQ712ieOF//upTZ /Ing== 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=UFm4lH1VdjgBOuPIWDR8+t74A8qgSRQhFYsN706Pxow=; b=cTk4lKeenuWdxGpYQryum1sxhYJfIEtvIPAG4/NudScnlUPYdgIXKpSCLsr8z4lrHu 2tRz2+478YDJ9G2yYu3/y8y2nj5jPwcXkJr4AhGfndi2O7r8Srp39oDrJupvrehlizi6 5aGkULiGiEvnLb8gyThAq1j+A4rNIhxM0+vMEwPJ2WcqvSM70YO452WF9pvk8ABhP312 rJSSDs+fAvWI1f+zp2kGMll87mDcp2Tpcj8zlIDyerzPbv1Th3afW0HmSpa7jPD08lC+ 3mQOj1iMU33x0gpSjeHLCJxmCeleTpVNM0kwQ+qDOzGDqHNxA4li+/aarOmNuNVDntAQ Gnlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=KTWiVFXf; 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=quicinc.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a9si793000edj.313.2021.09.01.14.49.44; Wed, 01 Sep 2021 14:50:07 -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=pass header.i=@quicinc.com header.s=qcdkim header.b=KTWiVFXf; 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=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243121AbhIAIUS (ORCPT + 99 others); Wed, 1 Sep 2021 04:20:18 -0400 Received: from alexa-out.qualcomm.com ([129.46.98.28]:17574 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243060AbhIAIUL (ORCPT ); Wed, 1 Sep 2021 04:20:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1630484356; x=1662020356; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=UFm4lH1VdjgBOuPIWDR8+t74A8qgSRQhFYsN706Pxow=; b=KTWiVFXfdCZZQX5B8YDprZjabWANu4texfsKTJj7+ZmLkIEpHrcwJw3C DH/VDyU5gBnqUZGsi9OdP4fJzEwR6+rN5x/d1rc6lbuUnNgeZ65h3zBo/ 91EYmVgk1i9Q07AIHrAp4c0twQVMwgCUYkPbhyrELE1mckSg0ITMusgXt A=; Received: from ironmsg-lv-alpha.qualcomm.com ([10.47.202.13]) by alexa-out.qualcomm.com with ESMTP; 01 Sep 2021 01:19:15 -0700 X-QCInternal: smtphost Received: from nalasex01c.na.qualcomm.com ([10.47.97.35]) by ironmsg-lv-alpha.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Sep 2021 01:19:15 -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_GCM_SHA384) id 15.2.922.7; Wed, 1 Sep 2021 01:19:13 -0700 From: Fenglin Wu To: , , CC: , , Subject: [RESEND PATCH v1 2/9] spmi: pmic-arb: do not ack and clear peripheral interrupts in cleanup_irq Date: Wed, 1 Sep 2021 16:18:03 +0800 Message-ID: <1630484290-28190-3-git-send-email-quic_fenglinw@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1630484290-28190-1-git-send-email-quic_fenglinw@quicinc.com> References: <1630484290-28190-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: nasanex01b.na.qualcomm.com (10.46.141.250) 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; } -- 2.7.4