Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1147502pxb; Thu, 19 Aug 2021 22:03:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPqxWsvZ4y9Nxmz30WH01lnJpw5x0Xu6HZFRGPboCKche70MPhPT7PBQIg7Ir2HXwJvX+D X-Received: by 2002:a17:906:c252:: with SMTP id bl18mr19732504ejb.519.1629435800990; Thu, 19 Aug 2021 22:03:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629435800; cv=none; d=google.com; s=arc-20160816; b=S8uJVkrGMo/iWHv8u9cK2WQ72/ySjTPgDkNMkC5zo1K3WluaTVdJAH2Bge5oMayMPO whK0bATKi5TX9B/ros0A5qdU/kE/+ZvKk7FDdxb2It13RxS1goIuW330Ll/WWcZZbcTx K6YDzDGSCsm+5lp9GLj2GMbTqLIt/aCk9DCtytel9h+z4VySEALNr1X18w0ag3FLXvTJ Edxe1JMUEF+l9hJfG7jYTKhlIvnnH1xVlc07SQK8eBqEEv5NAmwDdba3SO6uYi8bKWXJ Ymu7LF7L2X6bGZvGujmDodKcE9ZdrZLo5w89Gji4c1eR5vRByFlVIPj5UEt+Q2nX4X9o EAhQ== 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=wOLlR4NeiCJCY1Qd/mx88Za/lLJ/1HHbmWvfw3680vLPtA1xj1w7wFGwH9Lzz/lD8G CqCuh/vCm0dkUVhi+WeRRrD99JrKAF92ZlclJxK4ioVAPLlAlxvx+qag+PMqk/GVBQwC 1WOkiIOLFnb17AeYtY0k19hUvaAe+sxwEYcgV3szl+CN1WK8faSlpwohDvMwJLqEVvAx I9GoZ9mPj2qB7nTNzPXAQC4Xftku1qx1xUwQIcvTHn1Ya6i4IfPOyXf5Mt7c/WshSoAP yWFRVsIyBZuEGTP7gQWB/s1G0L9NXbKsHgm47qmprCtgVtgR5FMidMVayhOeQZCMgWx3 zqnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@quicinc.com header.s=qcdkim header.b="a/W9O1jD"; 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 nc1si5924646ejc.377.2021.08.19.22.02.55; Thu, 19 Aug 2021 22:03: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="a/W9O1jD"; 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 S238410AbhHTE73 (ORCPT + 99 others); Fri, 20 Aug 2021 00:59:29 -0400 Received: from alexa-out-sd-01.qualcomm.com ([199.106.114.38]:43416 "EHLO alexa-out-sd-01.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238197AbhHTE7Y (ORCPT ); Fri, 20 Aug 2021 00:59:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1629435527; x=1660971527; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=n/S+LJRQQv3dedKcJxXMUgsmPE3AiNWUiTT/M7t323w=; b=a/W9O1jDUmM8+XCEdfntSmcth2CpvymDIA1zo0RjydaapkYTI0EjNKPU MPUCseix5h6t9YfKSHkqo7Gk+e/aalYWbmKvHTQFl1m/pTkETPV7ZfVTh K5HmWu3SoKXrosI6C0riExxGYrILLdjwAyPUnMyhELfATMKjJFtLoTmpc M=; Received: from unknown (HELO ironmsg03-sd.qualcomm.com) ([10.53.140.143]) by alexa-out-sd-01.qualcomm.com with ESMTP; 19 Aug 2021 21:58:46 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg03-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2021 21:58:46 -0700 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.858.15; Thu, 19 Aug 2021 21:58:46 -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_CBC_SHA384) id 15.2.858.15; Thu, 19 Aug 2021 21:58:44 -0700 From: Fenglin Wu To: , , CC: , , Subject: [PATCH V1 5/9] spmi: pmic-arb: correct duplicate APID to PPID mapping logic Date: Fri, 20 Aug 2021 12:58:00 +0800 Message-ID: <1629435488-10228-6-git-send-email-quic_fenglinw@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1629435488-10228-1-git-send-email-quic_fenglinw@quicinc.com> References: <1629435488-10228-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: nasanexm03h.na.qualcomm.com (10.85.0.50) 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; -- Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.