Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4920843pxv; Tue, 27 Jul 2021 21:33:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyi4MwUTLGPYNnhRjSrXmDbAnCVg+uaSoYbZadEAdE2ym5jmW96cc7oGlaThG5tTfq+hjTG X-Received: by 2002:a17:906:d287:: with SMTP id ay7mr8548582ejb.360.1627446800191; Tue, 27 Jul 2021 21:33:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627446800; cv=none; d=google.com; s=arc-20160816; b=lnXT7F1L6eKBvELaGtIjfKlZWPRhzzz/XkA+oPuqfqRVPGsaTIZttS6NLrvX+rLhaa xDV7cWPQ36k7J8X16zpItvDLV/w5wN/o4IJQFIkbq/zqRVRPaGtIYalguhZ1iNjCNZTy BCkAMvb8KWGqc29DFoNkRfkUpjRVu6upiE86jZHtH7+kPjOeZzGQezf0OYraJiHBgCNG TT8kLaMAJARQa90STxSvTe3I8itfhSpD4OjYTfqZgmTqctIlB1+9+Q5Z4j0s2V9BDsfd QpbHxJu1BLXn2MGskRqtOjkr+dHYKLBBnpDVoNxiYkwzWhZgggtp7KMytCB460yPVysu ItnQ== 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=NUSDTi1jwpCODvqF0mIsTO5Xd+xgLhnRZeE6FbDOJSs=; b=Bzf6RlecM4yHEClMmSRRvan0uSdQm/qpmrPP7luGjmNKAV9J9HswaK440vlF57mjBn hHb7ulnYMZ2wfnk2/0ZeDY1onTAwZrI/PMMhnEmxJNXFgnfCR3Fkde3DnNq4Q+Jcfrlh j3Fr3JhJ7fFiJwcy6LHq+tjz9rsLPBCw3q+jUVMIGuByJ/9b4GuGiXHSQU1AEplIGT67 Vv2CByZF3Xf+6PDyauoi8PAOMiCSv1fH+BJ2/Z+ZUkZd8Ak/KVL6bPKAytBPzlPYqAJZ cpLN1xRF5gW7n+ar4YJoqMjoplpJps///zLtEFdajXvAbrzuZxW/7qBPNnwrSExbahBg XWxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@quicinc.com header.s=qcdkim header.b=FPNGzrdV; 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 z18si5195823edd.282.2021.07.27.21.32.57; Tue, 27 Jul 2021 21:33:20 -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=FPNGzrdV; 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 S234525AbhG1Ea6 (ORCPT + 99 others); Wed, 28 Jul 2021 00:30:58 -0400 Received: from alexa-out-sd-01.qualcomm.com ([199.106.114.38]:35713 "EHLO alexa-out-sd-01.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234401AbhG1Eaw (ORCPT ); Wed, 28 Jul 2021 00:30:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1627446651; x=1658982651; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=n/S+LJRQQv3dedKcJxXMUgsmPE3AiNWUiTT/M7t323w=; b=FPNGzrdVhFlxmQw66WETlvhAfRNQwUGCzbhzVjFItD/FGCTWHvIELlvd XqFxTlV42gb0Hn6ovwHKF8gYx3EK1T9BW2vLVCkBHtb/CBrJ4scOs6Yv5 7MGCkcnLld64t1IMXoiAw7GRF9zKwyOpUOnR7z6GDAWnzQC9lXvNa9Oql 8=; Received: from unknown (HELO ironmsg05-sd.qualcomm.com) ([10.53.140.145]) by alexa-out-sd-01.qualcomm.com with ESMTP; 27 Jul 2021 21:30:51 -0700 X-QCInternal: smtphost Received: from nasanexm03e.na.qualcomm.com ([10.85.0.48]) by ironmsg05-sd.qualcomm.com with ESMTP/TLS/AES256-SHA; 27 Jul 2021 21:30:51 -0700 Received: from fenglinw-gv.qualcomm.com (10.80.80.8) by nasanexm03e.na.qualcomm.com (10.85.0.48) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Tue, 27 Jul 2021 21:30:49 -0700 From: Fenglin Wu To: , , "Stephen Boyd" CC: , , Subject: [spmi-pmic-arb fixes and optimization patches V1 5/9] spmi: pmic-arb: correct duplicate APID to PPID mapping logic Date: Wed, 28 Jul 2021 12:30:05 +0800 Message-ID: <1627446609-9064-6-git-send-email-quic_fenglinw@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1627446609-9064-1-git-send-email-quic_fenglinw@quicinc.com> References: <1627446609-9064-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: nasanexm03g.na.qualcomm.com (10.85.0.49) To nasanexm03e.na.qualcomm.com (10.85.0.48) 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; -- Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.