Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp128720pxb; Mon, 18 Oct 2021 22:34:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylNWJDcJeUA6ZlrpSPIrV3dnpbJ72Ekq6F83qBIteOIFKhW3zvOWyVkMcqJZv3Kpl6tRDK X-Received: by 2002:a17:906:5ac8:: with SMTP id x8mr35123790ejs.132.1634621699149; Mon, 18 Oct 2021 22:34:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634621699; cv=none; d=google.com; s=arc-20160816; b=KncN4X8DAaHaYSs6uKu1ksDdAkN5DZaHcYAAY+EkHd5ex7HVw5emK4I8sBAP/k/r7t Jya2j917z+RthyMKo1XcB/J8N8bI3oNpn3QnU+asaIqrA6sBPXb434ubMyZei0PNQHhw ExhSdNLSesvqxHHdiO90Ipv0vN+3cnovJFYuF171C9Q34Jx6cADBfB6kfMq4XOqh5daB doySj7WaAEWc1lteFeS+RgZsJqdQGYiK40ZaVE/Oqlne/NUCqR5QPenzDKtoz4KHCpWf Im99e0bYtupeOgwylGZ7S9QvLdDWY/b7EZGwbIRqB3mmxnXVCOxGOJZjEGcl6JyJCOAK u77w== 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=QtKWRKRPIDZsG/mIHa8J1aT+7Ucf+KbAml0KGOxYzrU=; b=ISRmTLsm3hpI9HmQ7rV5PyjhBnDBZTY+oe+AEBg26hFbgJwh/bnvia1YnicZPOD2fC hvIVj5G/EMWnBYix3uffW7C3flU1zUjdAAngxx2eisNrOHcj4JR7Kyg983AtrYZdNytj no8hd6KO2wN2t6Xu1xfcnC9IxZueE5MOzHhzSyNcKWzMqQH2ebMzJvi+y7RTSEv1E3Y4 3py44W58BQx5xF2iQLaPugSF8k6mr2sJavIHp4ynR240MDk2xBlneVMCrLfCNlARliSx 2ovKg2WI94Dfp4i8K1YQXohYpL0V0ms/GjMPLhCPwGye1l6kFEDypC7Ho9w8dIgBWiDF J9aQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=h7qHFzTw; 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 bc27si21271571edb.455.2021.10.18.22.34.36; Mon, 18 Oct 2021 22:34:59 -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=h7qHFzTw; 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 S233736AbhJSFcZ (ORCPT + 99 others); Tue, 19 Oct 2021 01:32:25 -0400 Received: from alexa-out.qualcomm.com ([129.46.98.28]:26015 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233614AbhJSFcV (ORCPT ); Tue, 19 Oct 2021 01:32:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1634621409; x=1666157409; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=QtKWRKRPIDZsG/mIHa8J1aT+7Ucf+KbAml0KGOxYzrU=; b=h7qHFzTwjVModD424keZ7qTqbOkKXnE05wnstPzo1/uQku0O/zASTpuj zNCZjrRQioQ8JfQrM5c3TNygY7T4Xeg0RCo4O31USIKZ2Kz8R4/+L7kzq 9KTq1tYZX6DLmxoVtrNrGC6x/TmsALaJzRJ3y1GLYF6epryq4sz8c2IyF A=; Received: from ironmsg07-lv.qualcomm.com ([10.47.202.151]) by alexa-out.qualcomm.com with ESMTP; 18 Oct 2021 22:30:09 -0700 X-QCInternal: smtphost Received: from nalasex01c.na.qualcomm.com ([10.47.97.35]) by ironmsg07-lv.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2021 22:30:09 -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; Mon, 18 Oct 2021 22:30:06 -0700 From: Fenglin Wu To: , , , Kiran Gunda , David Collins , Greg Kroah-Hartman CC: , , , Subject: [PATCH v2 05/10] spmi: pmic-arb: correct duplicate APID to PPID mapping logic Date: Tue, 19 Oct 2021 13:29:16 +0800 Message-ID: <1634621361-17155-6-git-send-email-quic_fenglinw@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1634621361-17155-1-git-send-email-quic_fenglinw@quicinc.com> References: <1634621361-17155-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. 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 127a427..011044e 100644 --- a/drivers/spmi/spmi-pmic-arb.c +++ b/drivers/spmi/spmi-pmic-arb.c @@ -925,7 +925,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); @@ -948,16 +949,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