Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5442877pxb; Wed, 26 Jan 2022 12:05:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJwQXXCX8ChO35b/IZZxSIukuM1DD+f7RWl7r/POwlUpayAQQfOJCZdT3ulAI4fpAhCi5yAo X-Received: by 2002:a17:90a:7e10:: with SMTP id i16mr10360743pjl.188.1643227525789; Wed, 26 Jan 2022 12:05:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643227525; cv=none; d=google.com; s=arc-20160816; b=FWx5oyMtaa7M7MKxMAYO6LKeZ/sEhRtkD9rS7Sj7DPVF2irtAgLwu0j664gqwCv+kP Jt50YrYbPRuwc63Dl+I/DUGqKHunWGs8WG5oORj60OseEfuMXnWC13Omr2OS60iGKB8n Ba/YQqBWQ18jKl0CrCsCjpgqsxxNpiEGRC7Qp/dKOz992kGGZ3YI8HwtiUmwIGby6PCX F0uLZx+djBO33FKzyfIuitQNvy5pOMKqMlq9EI8N9vCyw9Q9v2c4A36cNLkffKWR9P+d GtKCAao+2YPfuVuEy9sPxBsbnKkkY8TlFKCVw8WULlKuCHsJm/0Ayqxq4gts1umZIe/S rxmw== 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=OhR72xqFkzDx/cOjDRLsolT9JZibeLMb3xt2MB4DjB8=; b=woVnIu4AAlE26s1c3AQXHZqEXn1g5hKa77KDN7X3Wt2K5UVS2jR4psBWl0fxiQSICA n2LmeDGSAWfd2rLCWtQq7KDAc3qQ66OkckDiMSTUPNtzb5eI/Pm2eEQ1QDmHfneIdiYg l4Z2zu4BxBuY4RNGpWev/EA0gZXAktbyvx10JeLq4nc9WYlkz6+7+xkzvb9fbnesOWSP fe+saSawcsT6OW4d3rRuY91jLfwMMIH7tkNKA7xJJ161AisvegpsAqhSnZIL2DNF5nj4 MiyBbjVz+rH8WHOXxQsghjFzAPzZczByaanRugErVsStTeUROyOoqJBZsdaWwR2DoCiS 5NRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=oQgELEbJ; 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 n12si196423plc.233.2022.01.26.12.05.12; Wed, 26 Jan 2022 12:05:25 -0800 (PST) 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=oQgELEbJ; 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 S236045AbiAZGcv (ORCPT + 99 others); Wed, 26 Jan 2022 01:32:51 -0500 Received: from alexa-out.qualcomm.com ([129.46.98.28]:58122 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236133AbiAZGco (ORCPT ); Wed, 26 Jan 2022 01:32:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1643178764; x=1674714764; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=OhR72xqFkzDx/cOjDRLsolT9JZibeLMb3xt2MB4DjB8=; b=oQgELEbJGUze6ZGwODX+s3cvV6GofdiARP5Cr14bHD4eE/peP6MyChjc WPTUXamME4I5X+nbapSjxv7whJNIMXdDTCBDCiyQpXfZg4+/kUrGbfuG0 b42TSYNqXoxRJjguDX21IPttoMx0r05/MMlbqPNBDF4dLSqduqljxbJgX 8=; Received: from ironmsg08-lv.qualcomm.com ([10.47.202.152]) by alexa-out.qualcomm.com with ESMTP; 25 Jan 2022 22:32:44 -0800 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg08-lv.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2022 22:32:44 -0800 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.922.19; Tue, 25 Jan 2022 22:32:43 -0800 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.19; Tue, 25 Jan 2022 22:32:41 -0800 From: Fenglin Wu To: , , , Kiran Gunda , Greg Kroah-Hartman , Abhijeet Dharmapurikar CC: , , , , Subject: [PATCH v5 03/10] spmi: pmic-arb: do not ack and clear peripheral interrupts in cleanup_irq Date: Wed, 26 Jan 2022 14:31:45 +0800 Message-ID: <1643178713-17178-4-git-send-email-quic_fenglinw@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1643178713-17178-1-git-send-email-quic_fenglinw@quicinc.com> References: <1643178713-17178-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: nasanex01a.na.qualcomm.com (10.52.223.231) 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. Fixes: 6bc546e71e50 ("spmi: pmic-arb: cleanup unrequested irqs") Fixes: 02abec3616c1 ("spmi: pmic-arb: rename pa_xx to pmic_arb_xx and other cleanup") 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 719bd73..2bc3b88 100644 --- a/drivers/spmi/spmi-pmic-arb.c +++ b/drivers/spmi/spmi-pmic-arb.c @@ -593,16 +593,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) @@ -780,6 +770,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", @@ -788,6 +779,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