Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2242666pxb; Fri, 17 Sep 2021 05:42:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/UW5LKTLr/2lniRgKzpfXXNrF6I8/BiK+sfcRgz4ecv59J/Z8oVJDJhCyeqD0n9zI5/M/ X-Received: by 2002:a05:6402:2913:: with SMTP id ee19mr12124414edb.332.1631882570176; Fri, 17 Sep 2021 05:42:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631882570; cv=none; d=google.com; s=arc-20160816; b=DKYkxBLKTnhl5yPYgcTojGWX2eh7tQs7auzOwxdrIm3XtsnGA7gcSE5TfACnp4/ZCp ibq+aXSI83y2gh26NHRyDrkYEjiKexv/EWeh/G1If/KroewLM2JnxAv7TglGEcm5EGDG 508CzW6ZfGirw2lnRVHimg7CQZHJIkuBn1LND+Ow7Y884voOT/5X8la3gnwhg2WBto2s Hit+n9kl23epMP8Rv2CbA3J6839ocmSauYPXMMtAnCLQmVYfgFnaOj/Bbkwaec6dLzl7 70mDamu5c5mYUqdTsyLLfWDGw3kmjvDXtf+YhLkP9iVwjF1+Rq4RpWqv5HvXP+4W4YKQ iEdw== 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=kUnSUC/8VBwiIC+PWxEBDggi0X6pA5u756A7g/HYUYs=; b=dHao5QTOmiv61/vjsRyjzFgqSJEoE5v8KoU5yaCb6uEJkPGT5HOzhcpKrNQB5trDoT 1Kv3AHAQuA5iZ7BjxzJJTgZEwJsARp+temB4UDumCH/Zw/UEVd2A7NQhS5GuV0qmiNwR ie8hSJ3hPJZN07+k0/vXr0ZRegqjJUAlSXSYTHhZg9OWRZ+egpvsV7ac63Ss/2rmZTgo H8jOiXmEFKAMFeqxHj7PKpfLeY5XW02T+VYzXjW7hjTctfbTPd+sbxpAkFuIbc01Ewly ElQTE8RPpxc7ZQn7DVoX+QNO9HDHWho1SI9CXArKZZ4mJnOJJCBbxA3M5La9hueIl57U XmNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b="Wdxy/ol0"; 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 v4si8076996edb.319.2021.09.17.05.42.24; Fri, 17 Sep 2021 05:42:50 -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="Wdxy/ol0"; 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 S241803AbhIQGew (ORCPT + 99 others); Fri, 17 Sep 2021 02:34:52 -0400 Received: from alexa-out.qualcomm.com ([129.46.98.28]:60418 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236090AbhIQGeq (ORCPT ); Fri, 17 Sep 2021 02:34:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1631860405; x=1663396405; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=kUnSUC/8VBwiIC+PWxEBDggi0X6pA5u756A7g/HYUYs=; b=Wdxy/ol0V0Zgbs0Q1JrWkNu0SeKRmPlkUeedUjUrc0CDR3ia3JuP1u1D RKMX3cv3KYLJihmZP2Ua7MrHXGjG5bu2eRUkCA3LKFmpT9RD43C/ercbL wt4Aq/L7Wx/Ceeie7fMbzYA51g1nNUNak3FR1oGaABK7k3Tg/SS3rPUjw 4=; Received: from ironmsg07-lv.qualcomm.com ([10.47.202.151]) by alexa-out.qualcomm.com with ESMTP; 16 Sep 2021 23:33:24 -0700 X-QCInternal: smtphost Received: from nalasex01a.na.qualcomm.com ([10.47.209.196]) by ironmsg07-lv.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2021 23:33:24 -0700 Received: from fenglinw-gv.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.7; Thu, 16 Sep 2021 23:33:22 -0700 From: Fenglin Wu To: , , CC: , , Subject: [RESEND PATCH v1 5/9] spmi: pmic-arb: correct duplicate APID to PPID mapping logic Date: Fri, 17 Sep 2021 14:33:00 +0800 Message-ID: <1631860384-26608-6-git-send-email-quic_fenglinw@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1631860384-26608-1-git-send-email-quic_fenglinw@quicinc.com> References: <1631860384-26608-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 nalasex01a.na.qualcomm.com (10.47.209.196) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Collins Correct the way that duplicate PPID mappings are handled for PMIC arbiter v5. The final APID mapped to a given PPID should be the one which has write owner = APPS EE, if it exists, or if not that, then the first APID mapped to the PPID, if it exists. Signed-off-by: David Collins Signed-off-by: Fenglin Wu --- drivers/spmi/spmi-pmic-arb.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/spmi/spmi-pmic-arb.c b/drivers/spmi/spmi-pmic-arb.c index 59c445b..f1b72d8 100644 --- a/drivers/spmi/spmi-pmic-arb.c +++ b/drivers/spmi/spmi-pmic-arb.c @@ -918,7 +918,8 @@ static int pmic_arb_read_apid_map_v5(struct spmi_pmic_arb *pmic_arb) * version 5, there is more than one APID mapped to each PPID. * The owner field for each of these mappings specifies the EE which is * allowed to write to the APID. The owner of the last (highest) APID - * for a given PPID will receive interrupts from the PPID. + * which has the IRQ owner bit set for a given PPID will receive + * interrupts from the PPID. */ for (i = 0; ; i++, apidd++) { offset = pmic_arb->ver_ops->apid_map_offset(i); @@ -941,16 +942,16 @@ static int pmic_arb_read_apid_map_v5(struct spmi_pmic_arb *pmic_arb) apid = pmic_arb->ppid_to_apid[ppid] & ~PMIC_ARB_APID_VALID; prev_apidd = &pmic_arb->apid_data[apid]; - if (valid && is_irq_ee && - prev_apidd->write_ee == pmic_arb->ee) { + if (!valid || apidd->write_ee == pmic_arb->ee) { + /* First PPID mapping or one for this EE */ + pmic_arb->ppid_to_apid[ppid] = i | PMIC_ARB_APID_VALID; + } else if (valid && is_irq_ee && + prev_apidd->write_ee == pmic_arb->ee) { /* * Duplicate PPID mapping after the one for this EE; * override the irq owner */ prev_apidd->irq_ee = apidd->irq_ee; - } else if (!valid || is_irq_ee) { - /* First PPID mapping or duplicate for another EE */ - pmic_arb->ppid_to_apid[ppid] = i | PMIC_ARB_APID_VALID; } apidd->ppid = ppid; -- 2.7.4