Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp127113pxb; Mon, 18 Oct 2021 22:32:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLYP1cmeZFy7JU9JV4Ns2CNGBVN2gzgCr+IRQeLscjXFTuI2t6hqaYOPVv4MGA4pr9xdX7 X-Received: by 2002:a50:d085:: with SMTP id v5mr50584466edd.75.1634621541120; Mon, 18 Oct 2021 22:32:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634621541; cv=none; d=google.com; s=arc-20160816; b=RXZM3Yx52vyyXzI8gDRtZURrSsiML6kb0q7nhqcbrIoSOmEbs1KObewpTjTeYqIF8f VjlmS2jhXFkL6b95+x7+cJuTWMbCzyblqIw+supaT++ylmtZB6BkFS7HT4AaGkEPzk4n 8/1GDsqVfYM55KyIvV1wyY2i24/hLW0rvxNeCPqu1bo79C1bSkcpZbz19CkrcLOX1TWp xU+KQR6FRgJbJptaD4D2C4AcU8RNPnDwoNOmz4R9GteX+KRgMSoS0c1tsOQRze5hhnRy jY2OWGTsoaqAJcuGprQQHiIjA1lnC2QwwMCXqygJrBAlI5H5GBCb+Q1f7O1nNZVSNUeM IQdA== 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=axw472bSu3K2vJfwD04DHUB95b3LnBR9ZXFqiqsqQQg=; b=nML6Jpa4KiMBBbbaOO9MqPqEVunYtp78qihGMtVMOjbcuiUR3XVeivoDzj6fSGQxZJ bSVInYnjoepWfj2B46MWnZxYn673SvxfpzRx8KMnPDEeVhgFtXFl0x+cgyXQVdvBGUc5 oCZW92oiiwO2y4QkMIzBIy31/9yfVgVdz+aFhceidHYJvXq8CA2BkMIyc3222ECmDeSk pVNNDECMt7nLSKmQm9x5St55b5uQCPYDjzlE6joCwTi5dl2lXbR20EbX8wJRByG1cO4k OkbKVeJjdU/ihg8Iq+l4pSEZjVLr69wuWnQIeKHR+hbBj7fs5aMWBkFrO1HiOxVCwVpG Z0aA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=rD61y1qJ; 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 nc12si28503776ejc.696.2021.10.18.22.31.56; Mon, 18 Oct 2021 22:32:21 -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=rD61y1qJ; 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 S233326AbhJSFcP (ORCPT + 99 others); Tue, 19 Oct 2021 01:32:15 -0400 Received: from alexa-out.qualcomm.com ([129.46.98.28]:40351 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233218AbhJSFcN (ORCPT ); Tue, 19 Oct 2021 01:32:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1634621402; x=1666157402; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=axw472bSu3K2vJfwD04DHUB95b3LnBR9ZXFqiqsqQQg=; b=rD61y1qJfHZKIu5MKCn8PqzxGdauwHE+gdI/yoSThT6uWn/PA3pk+N3p g5ZNlcKZjcvIAWTSaGdyUszfMn++c3hLZgphpn6EMbv0kY0T88l74ly8m 3V9xBNtb2fsQlR6q1X7rllF+Ys+0GVNP6Di7bj81xKPXtxOyWAhul33hk I=; Received: from ironmsg-lv-alpha.qualcomm.com ([10.47.202.13]) by alexa-out.qualcomm.com with ESMTP; 18 Oct 2021 22:30:01 -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; 18 Oct 2021 22:30:01 -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; Mon, 18 Oct 2021 22:29:58 -0700 From: Fenglin Wu To: , , CC: , , , , Subject: [PATCH v2 02/10] spmi: pmic-arb: do not ack and clear peripheral interrupts in cleanup_irq Date: Tue, 19 Oct 2021 13:29:13 +0800 Message-ID: <1634621361-17155-3-git-send-email-quic_fenglinw@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1634621361-17155-1-git-send-email-quic_fenglinw@quicinc.com> References: <1634621361-17155-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 da629cc..ce7ae99 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 int periph_interrupt(struct spmi_pmic_arb *pmic_arb, u16 apid) @@ -674,6 +664,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", @@ -682,6 +673,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