From: Aswin Murugan Date: Wed, 7 Jan 2026 15:35:04 +0000 (+0530) Subject: spmi: msm: refine handling of multiple APID mappings X-Git-Tag: v2026.04-rc1~31^2~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7966d35b1fee1a3f4032379b08af7440a79c763b;p=thirdparty%2Fu-boot.git spmi: msm: refine handling of multiple APID mappings PMIC Arbiter may expose multiple owned and non-owned APIDs per SID/PID. - Keep current mapping if it is OWNED and a NON-OWNED appears. - Always update when a NEW OWNED APID appears (make writable). - If current is NON-OWNED and a new NON-OWNED appears, update to it (remain read-only). This avoids write-access violations when not using the newly discovered owned channels. Signed-off-by: Aswin Murugan Link: https://patch.msgid.link/20260107153504.550450-1-aswin.murugan@oss.qualcomm.com Signed-off-by: Casey Connolly --- diff --git a/drivers/spmi/spmi-msm.c b/drivers/spmi/spmi-msm.c index faae54e9fef..f3cd98c3db8 100644 --- a/drivers/spmi/spmi-msm.c +++ b/drivers/spmi/spmi-msm.c @@ -274,10 +274,25 @@ static void msm_spmi_channel_map_v5(struct msm_spmi_priv *priv, unsigned int i, priv->channel_map[slave_id][pid] = i | SPMI_CHANNEL_VALID; if (owner != priv->owner) priv->channel_map[slave_id][pid] |= SPMI_CHANNEL_READ_ONLY; - } else if ((owner == priv->owner) && prev_read_only) { - /* Read only and we found one we own, switch */ + + } else if (owner == priv->owner) { + /* + * Found a channel owned by our EE - ALWAYS switch to it! + * even if we already have a mapping, we must prefer the one + * owned by our EE to avoid hardware access violations. + */ priv->channel_map[slave_id][pid] = i | SPMI_CHANNEL_VALID; + /* Clear READ_ONLY flag since we own this channel */ + + } else if (prev_read_only) { + /* + * Previous mapping was read-only and this one is also not ours. + * Update to this channel. + */ + priv->channel_map[slave_id][pid] = i | SPMI_CHANNEL_VALID | SPMI_CHANNEL_READ_ONLY; + } + /* else: Previous was writable and owned by us, this one isn't - keep previous */ } static int msm_spmi_probe(struct udevice *dev)