From nobody Wed Sep 3 06:09:23 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 25A07C38A2D for ; Mon, 24 Oct 2022 12:41:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232259AbiJXMlD (ORCPT ); Mon, 24 Oct 2022 08:41:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232456AbiJXMhC (ORCPT ); Mon, 24 Oct 2022 08:37:02 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09C836686E; Mon, 24 Oct 2022 05:06:19 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 12DE261252; Mon, 24 Oct 2022 12:02:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 25D6BC433C1; Mon, 24 Oct 2022 12:02:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612964; bh=OFe+RVcm/duytjcmCEfORAPp9ogoeTNcHx8fd2aVeYI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KA0/3VGhaBv0Yuf4S75XvBM2nu+zgyYU12tLgq3AvsZP7pX6bRd2QNM8meEknK6bd /OnVYDnYxKQsHvr4REZ7bE/jEZo+iM+XDHhEQoIXvSUXU3LqwC64XJmYbowIgHBeH4 l1CEoXNhauWG/KV8Vn76SnLag+fOZ5r6bCUKoKgQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Collins , Fenglin Wu , Stephen Boyd , Sasha Levin Subject: [PATCH 4.19 155/229] spmi: pmic-arb: correct duplicate APID to PPID mapping logic Date: Mon, 24 Oct 2022 13:31:14 +0200 Message-Id: <20221024113004.025723586@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112959.085534368@linuxfoundation.org> References: <20221024112959.085534368@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: David Collins [ Upstream commit 1f1693118c2476cb1666ad357edcf3cf48bf9b16 ] 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 =3D 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 Link: https://lore.kernel.org/r/1655004286-11493-7-git-send-email-quic_feng= linw@quicinc.com Signed-off-by: Stephen Boyd Link: https://lore.kernel.org/r/20220930005019.2663064-8-sboyd@kernel.org Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- 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 360b8218f322..0eb156aa4975 100644 --- a/drivers/spmi/spmi-pmic-arb.c +++ b/drivers/spmi/spmi-pmic-arb.c @@ -867,7 +867,8 @@ static int pmic_arb_read_apid_map_v5(struct spmi_pmic_a= rb *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 =3D 0; ; i++, apidd++) { offset =3D pmic_arb->ver_ops->apid_map_offset(i); @@ -890,16 +891,16 @@ static int pmic_arb_read_apid_map_v5(struct spmi_pmic= _arb *pmic_arb) apid =3D pmic_arb->ppid_to_apid[ppid] & ~PMIC_ARB_APID_VALID; prev_apidd =3D &pmic_arb->apid_data[apid]; =20 - if (valid && is_irq_ee && - prev_apidd->write_ee =3D=3D pmic_arb->ee) { + if (!valid || apidd->write_ee =3D=3D pmic_arb->ee) { + /* First PPID mapping or one for this EE */ + pmic_arb->ppid_to_apid[ppid] =3D i | PMIC_ARB_APID_VALID; + } else if (valid && is_irq_ee && + prev_apidd->write_ee =3D=3D pmic_arb->ee) { /* * Duplicate PPID mapping after the one for this EE; * override the irq owner */ prev_apidd->irq_ee =3D apidd->irq_ee; - } else if (!valid || is_irq_ee) { - /* First PPID mapping or duplicate for another EE */ - pmic_arb->ppid_to_apid[ppid] =3D i | PMIC_ARB_APID_VALID; } =20 apidd->ppid =3D ppid; --=20 2.35.1