Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp874082pxb; Wed, 1 Sep 2021 11:50:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxO/KOrZa4Vno5PHI1RL3ETDQsggQ5Jj2EsJRKmegutJFtJO72OcpdC0tPEM+jygI0FqVW5 X-Received: by 2002:a05:6e02:1288:: with SMTP id y8mr662848ilq.206.1630522204425; Wed, 01 Sep 2021 11:50:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630522204; cv=none; d=google.com; s=arc-20160816; b=qVt9UyQOcb8ea6hJVmyxgT8Gr62eSmo6S++m11LPtlFOgTZWWHNDKRT5qc5w4hVnz3 CvEVA5ot088TsoYvAJf2m2yD7cLUGG6PtD/TcyNUkSsdQGy40ZeWIMk0+O5KbAetrW0B 8wyeDbnaN2edUzKHAr1P1Hl5UqlB79L29m8mIb2vZvqtCCeDxlFqJIHbnZM2218XUTEn Z+EVaIo+k+0t1H/Qwzukn7n2mGzWrWAiMz3pAGE1Sqj9VfqnXPhlLseNCNTKx0+TeGql dZS4iu5LwJHuHvAXp9U+Keu0IFznKayAtgexZ3vRaLLr/z680/37z0pnAUzfAnAXJ6NB dTYA== 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=AGWMaalv3hYdkfZgpUkx6u8T+6dZ6beZveyHaDJGYIfpx0/QPaQalz5Jtc91Vm9SUh SQccYTfTFrOWqN0FKFjVrDQm9LUVrwvvTQtoAvEnY1A6ALerFPxrjsyd1l9HT3esfnyT BFLauzM5XPYHFxJMsgda19c9xdL4amAAL2wPORps6zdVSijPnhW91srx7SsFAeZJ/vI9 ToNAwp2FtqjeAWk43G2DXcGxnIQyMRH8OWT+PO9pekJMoMEqUdM1EXAGNbVv+GK/Y7ii YDNEAWqEG9YNnXan0BdpPO4cVRU+7scMmPfmYE5oRUaFUSEFxbEL/J1/WyiACMxK41yB tnfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=uJSoz7N4; 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 m46si201980jaf.118.2021.09.01.11.49.52; Wed, 01 Sep 2021 11:50:04 -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=uJSoz7N4; 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 S243158AbhIAIU3 (ORCPT + 99 others); Wed, 1 Sep 2021 04:20:29 -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 S243123AbhIAIUT (ORCPT ); Wed, 1 Sep 2021 04:20:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1630484363; x=1662020363; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=kUnSUC/8VBwiIC+PWxEBDggi0X6pA5u756A7g/HYUYs=; b=uJSoz7N4X9TqHpWRCs7JzlRZw3u40bkTtJHuLnIh/A1NWBbsiOFM+fwu KaKby9zg3/tJDmyuslvhf6RK49MP6Swu4kHOmpUFmvwUm22OhdRMMo7S+ wWU7tw+qQRSBnTZBm7UR1tE5MEqKC3v1r3KrF2NztGU1Fls4J04O8hLDs M=; Received: from ironmsg-lv-alpha.qualcomm.com ([10.47.202.13]) by alexa-out.qualcomm.com with ESMTP; 01 Sep 2021 01:19:23 -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:22 -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:20 -0700 From: Fenglin Wu To: , , CC: , , Subject: [RESEND PATCH v1 5/9] spmi: pmic-arb: correct duplicate APID to PPID mapping logic Date: Wed, 1 Sep 2021 16:18:06 +0800 Message-ID: <1630484290-28190-6-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: 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