]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
firmware: qcom: scm: take struct device as argument in SHM bridge enable
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Mon, 30 Jun 2025 12:12:03 +0000 (14:12 +0200)
committerBjorn Andersson <andersson@kernel.org>
Thu, 17 Jul 2025 03:50:55 +0000 (22:50 -0500)
commitdc3f4e75c54c19bad9a70419afae00ce6baf3ebf
treedb7a4624f360774d28ec4ab242b3a6755bc43bfe
parent23972da96e1eee7f10c8ef641d56202ab9af8ba7
firmware: qcom: scm: take struct device as argument in SHM bridge enable

qcom_scm_shm_bridge_enable() is used early in the SCM initialization
routine. It makes an SCM call and so expects the internal __scm pointer
in the SCM driver to be assigned. For this reason the tzmem memory pool
is allocated *after* this pointer is assigned. However, this can lead to
a crash if another consumer of the SCM API makes a call using the memory
pool between the assignment of the __scm pointer and the initialization
of the tzmem memory pool.

As qcom_scm_shm_bridge_enable() is a special case, not meant to be
called by ordinary users, pull it into the local SCM header. Make it
take struct device as argument. This is the device that will be used to
make the SCM call as opposed to the global __scm pointer. This will
allow us to move the tzmem initialization *before* the __scm assignment
in the core SCM driver.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20250630-qcom-scm-race-v2-2-fa3851c98611@linaro.org
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
drivers/firmware/qcom/qcom_scm.c
drivers/firmware/qcom/qcom_scm.h
drivers/firmware/qcom/qcom_tzmem.c
include/linux/firmware/qcom/qcom_scm.h