mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-30 10:00:03 -04:00
firmware: qcom: scm: Fix tzmem state on probe retry
qcom_tzmem_enable() returns -EBUSY if called a second time, but this
causes probe retries to fail permanently if a later step in
qcom_scm_probe() defers after qcom_tzmem_enable() has already succeeded.
Use DO_ONCE() to ensure qcom_tzmem_init() runs exactly once across all
calls in a thread-safe manner. qcom_tzmem_dev is set on every call since
probe retries use the same device pointer. The result of the first
initialisation is cached and returned to every subsequent caller.
Fixes: 40289e35ca ("firmware: qcom: scm: enable the TZ mem allocator")
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20260724094939.613844-4-mukesh.ojha@oss.qualcomm.com
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
This commit is contained in:
committed by
Bjorn Andersson
parent
b697b20cea
commit
9941fe8a04
@@ -15,6 +15,7 @@
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/mm.h>
|
||||
#include <linux/once.h>
|
||||
#include <linux/radix-tree.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/spinlock.h>
|
||||
@@ -507,14 +508,18 @@ phys_addr_t qcom_tzmem_to_phys(void *vaddr)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(qcom_tzmem_to_phys);
|
||||
|
||||
static void qcom_tzmem_do_init(int *result)
|
||||
{
|
||||
*result = qcom_tzmem_init();
|
||||
}
|
||||
|
||||
int qcom_tzmem_enable(struct device *dev)
|
||||
{
|
||||
if (qcom_tzmem_dev)
|
||||
return -EBUSY;
|
||||
static int result;
|
||||
|
||||
qcom_tzmem_dev = dev;
|
||||
|
||||
return qcom_tzmem_init();
|
||||
DO_ONCE(qcom_tzmem_do_init, &result);
|
||||
return result;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(qcom_tzmem_enable);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user