Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5444512pxb; Wed, 26 Jan 2022 12:07:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJyJsIspDYbAuX95Op69dz+DplRHeSchVJSgAcpNPicNNsz35NGOfR7B74p2ZVx7Bb+dcMqL X-Received: by 2002:a17:902:bc4a:: with SMTP id t10mr215167plz.125.1643227646539; Wed, 26 Jan 2022 12:07:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643227646; cv=none; d=google.com; s=arc-20160816; b=dpTaKMI9n2yzN5V6XeU6HMtG1lDe+ogrbErimqd8UF1NOyPadXJnMJ4eQlVOYVGzJ+ J2tSAsqAcZIzGi4k5ilDm3RKSqpHoky/Z3EmU8PaBglYlT3snGieb3Zs62CjiT89T64B 1XLwnx8wjlhV1CGMllkIWM7k7N/qinDI6vFbPbzdJ0CGWP5e3Wjtz+66j8OQJi8Lb3dt YwRJ2USBorYe1jdHhDSFVN8VuRAvDDOiBCXTj4ob7ItylAj8gyq6Cqhh3lR+c9C5rPLN CFKLos4vVrWW7uBAuhdNJTAA7D3JFsoWBT+1ZC7JYixovktg+9RWWPFEiX+mdG1kdZmT GV+Q== 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=WeVviO3b/eQ/o/+e3R2BwXM41X1RUQB/FN17l8jZ4IhEJxM2t8NNwScN6QFqT3FOW9 NWEAO+3D8lrWsA82sc805MLbT0652ZV8nPi40EmFpflHey/XG+/qr4+/laidg1gtvtar wxIQN8Z6E8E4WD9HVMZoaqdApHCDN9qQVM82sXdhFIgnC7p3N5O2e7uRZQSUwtovau82 AownqScP3fAA53Ra5q8CNbEx0J80icykjNOqPc46icA/kikrQSYkAV+SH1rzflthf8UA OvnCvtpocr7n9iJqXGh8oly1Y1m9mwvDvdQ3R4Koby9o83dvtLPMcUYY5Yd1HHat1q9/ jFDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=xPbRHdCz; 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 t69si220555pgd.56.2022.01.26.12.07.04; Wed, 26 Jan 2022 12:07:26 -0800 (PST) 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=xPbRHdCz; 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 S236334AbiAZGdJ (ORCPT + 99 others); Wed, 26 Jan 2022 01:33:09 -0500 Received: from alexa-out-sd-01.qualcomm.com ([199.106.114.38]:26860 "EHLO alexa-out-sd-01.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230400AbiAZGcz (ORCPT ); Wed, 26 Jan 2022 01:32:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1643178775; x=1674714775; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=HlBrxxqz8GrpwuEBJfdNjgmehq5A3syFPfEQuqOMWpg=; b=xPbRHdCz8OZCPJv3pm05MP4tonf12341eWXWENDHNgWGV3AJcfrt1bJb 6i+HLHgjqkdNwayEmK9++wlWshtlYoebJytiZzHemlyKQ+nrHX4wMy5qZ wXaGe/FgCAow30jmE8WygM8JUQ2YdECgZKVboSvMmk5QxjKPKWhh6PDgn M=; Received: from unknown (HELO ironmsg03-sd.qualcomm.com) ([10.53.140.143]) by alexa-out-sd-01.qualcomm.com with ESMTP; 25 Jan 2022 22:32:54 -0800 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; 25 Jan 2022 22:32:53 -0800 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.922.19; Tue, 25 Jan 2022 22:32:53 -0800 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.19; Tue, 25 Jan 2022 22:32:50 -0800 From: Fenglin Wu To: , , , Kiran Gunda , Greg Kroah-Hartman , David Collins CC: , , , Subject: [PATCH v5 06/10] spmi: pmic-arb: correct duplicate APID to PPID mapping logic Date: Wed, 26 Jan 2022 14:31:48 +0800 Message-ID: <1643178713-17178-7-git-send-email-quic_fenglinw@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1643178713-17178-1-git-send-email-quic_fenglinw@quicinc.com> References: <1643178713-17178-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) 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