Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp696940iob; Thu, 28 Apr 2022 09:52:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdfcFI/0mk7AfpHczrdDZ3ryhu9nfaxHJltUk1fsp++mY4YPMU2ery8y1ZvfVI7AgEBOfT X-Received: by 2002:a2e:9d06:0:b0:24f:144f:e640 with SMTP id t6-20020a2e9d06000000b0024f144fe640mr12743846lji.211.1651164763946; Thu, 28 Apr 2022 09:52:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651164763; cv=none; d=google.com; s=arc-20160816; b=tvupFYy85QiAsxbzN0WVw+SEb0aD7TSQ2lFQpHer36seWBHiNYy80Qx4UGcQ838z0l ZCv8tSnXwO3KZ1677jlsh/3x2B7uP3fJ39nrK8pbSFOWTUB4Tf8ViQGrpHYbsc/osqrZ kvZzm2tOZXdbVNu3dmXEpKQg4QJrPWGcxRmXbVEweLDm4hx6KF+sHa/m8RUxt/fGEcFL VjG6wgFi8gaP/CJgEG+s5DaEcAgVsjlyrEzmK/G8wMG51tFTh2ZR8lNScmIdutEvpw2Z N56f0dZ+MegNHb3/5kF4BB3AUBepFGa9CFgAp2ukH8qiiJTa8yg/FEqo/rfumUbMHuh4 R7bg== 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=HlBrxxqz8GrpwuEBJfdNjgmehq5A3syFPfEQuqOMWpg=; b=nJZPK24Zr5+3qnFp9me2DxNdJuOBg4z9Z6GzvUMHTrQ2xkfmftKCdtLfp0+OwGI+Av /5QpCYqT35MN04Fuirapu46KvX6zghFh8CKzlCgVQ8luT+sBZlJpW8M3ZBokN+YLsRON ybNg5AU0zgOXZiKHYcTxBG/f7L9Q1tXP+ea5lU3kTgfXFvcz6Bd96khzihpBLJ7UuSOQ AyK3cq1QEDlRQsmm/ziQK05Cv4Ryg8MRio8v9BlIpWB1nRy4Kayk3MMfzmtKmiuguWEi cflsn4x0CnCnqyfRsdIdrULt7/ZYdDUkpKuaGM/TGukVdcsSu0D9CD+iioVUKint7H1a JFXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=mJkrpELB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r16-20020a2eb890000000b0024f06c92effsi5458550ljp.458.2022.04.28.09.52.15; Thu, 28 Apr 2022 09:52:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=mJkrpELB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S240598AbiD1BQq (ORCPT + 99 others); Wed, 27 Apr 2022 21:16:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240482AbiD1BQh (ORCPT ); Wed, 27 Apr 2022 21:16:37 -0400 Received: from alexa-out-sd-01.qualcomm.com (alexa-out-sd-01.qualcomm.com [199.106.114.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 632EB7E0A5; Wed, 27 Apr 2022 18:13:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1651108399; x=1682644399; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=HlBrxxqz8GrpwuEBJfdNjgmehq5A3syFPfEQuqOMWpg=; b=mJkrpELBtocUWjs/Ppt9DRK3aMvk6C9XeXVFWfa7OACym/kMJLd/HKBb rchWk+TxuBXFeqCQYDBepo8skOchNUu7kiI93AuInfAKFymkUTSVc7D/K kgkh10NnQT3lxl7yTuXeLfwXrS0AIGZGkwpf8qjdtc/3iHplbySuubQFP I=; Received: from unknown (HELO ironmsg01-sd.qualcomm.com) ([10.53.140.141]) by alexa-out-sd-01.qualcomm.com with ESMTP; 27 Apr 2022 18:13:19 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg01-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2022 18:13:18 -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.986.22; Wed, 27 Apr 2022 18:13:18 -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.986.22; Wed, 27 Apr 2022 18:13:15 -0700 From: Fenglin Wu To: , , , David Collins , Kiran Gunda , Greg Kroah-Hartman CC: , , , , Subject: [RESEND PATCH V6 06/10] spmi: pmic-arb: correct duplicate APID to PPID mapping logic Date: Thu, 28 Apr 2022 09:12:45 +0800 Message-ID: <1651108369-11059-7-git-send-email-quic_fenglinw@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1651108369-11059-1-git-send-email-quic_fenglinw@quicinc.com> References: <1651108369-11059-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) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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. Fixes: 40f318f0ed67 ("spmi: pmic-arb: add support for HW version 5") 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 56f2294..cf92abc 100644 --- a/drivers/spmi/spmi-pmic-arb.c +++ b/drivers/spmi/spmi-pmic-arb.c @@ -1031,7 +1031,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); @@ -1054,16 +1055,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