summaryrefslogtreecommitdiff
path: root/drivers/spmi/spmi-devres.c
diff options
context:
space:
mode:
authorNĂ­colas F. R. A. Prado <nfraprado@collabora.com>2023-12-07 02:17:24 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-12-15 19:27:04 +0300
commitf200fff8d019f2754f91f5d715652e3e3fdf3604 (patch)
treea75d3ee68adae3b182afa29189d5a909c5f33be9 /drivers/spmi/spmi-devres.c
parent117cc0efb02374fb84bd546e2e706637db167bd6 (diff)
downloadlinux-f200fff8d019f2754f91f5d715652e3e3fdf3604.tar.xz
spmi: mtk-pmif: Serialize PMIF status check and command submission
Before writing the read or write command to the SPMI arbiter through the PMIF interface, the current status of the channel is checked to ensure it is idle. However, since the status only changes from idle when the command is written, it is possible for two concurrent calls to determine that the channel is idle and simultaneously send their commands. At this point the PMIF interface hangs, with the status register no longer being updated, and thus causing all subsequent operations to time out. This was observed on the mt8195-cherry-tomato-r2 machine, particularly after commit 46600ab142f8 ("regulator: Set PROBE_PREFER_ASYNCHRONOUS for drivers between 5.10 and 5.15") was applied, since then the two MT6315 devices present on the SPMI bus would probe assynchronously and sometimes (during probe or at a later point) read the bus simultaneously, breaking the PMIF interface and consequently slowing down the whole system. To fix the issue at its root cause, introduce locking around the channel status check and the command write, so that both become an atomic operation, preventing race conditions between two (or more) SPMI bus read/write operations. A spinlock is used since this is a fast bus, as indicated by the usage of the atomic variant of readl_poll, and '.fast_io = true' being used in the mt6315 driver, so spinlocks are already used for the regmap access. Fixes: b45b3ccef8c0 ("spmi: mediatek: Add support for MT6873/8192") Signed-off-by: NĂ­colas F. R. A. Prado <nfraprado@collabora.com> Link: https://lore.kernel.org/r/20230724154739.493724-1-nfraprado@collabora.com Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com> Signed-off-by: Stephen Boyd <sboyd@kernel.org> Link: https://lore.kernel.org/r/20231206231733.4031901-2-sboyd@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/spmi/spmi-devres.c')
0 files changed, 0 insertions, 0 deletions