On 5/28/2024 2:55 PM, Bjorn Andersson wrote:
On Fri, May 24, 2024 at 06:26:42PM GMT, Chris Lew wrote:
Add qcom_smem_bust_hwspin_lock_by_host to enable remoteproc to bust the
hwspin_lock owned by smem. In the event the remoteproc crashes
unexpectedly, the remoteproc driver can invoke this API to try and bust
the hwspin_lock and release the lock if still held by the remoteproc
device.
Signed-off-by: Chris Lew <quic_clew@xxxxxxxxxxx>
---
drivers/soc/qcom/smem.c | 28 ++++++++++++++++++++++++++++
include/linux/soc/qcom/smem.h | 2 ++
2 files changed, 30 insertions(+)
diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c
index 7191fa0c087f..683599990387 100644
--- a/drivers/soc/qcom/smem.c
+++ b/drivers/soc/qcom/smem.c
...
+ *
+ * Context: Process context.
+ *
+ * Returns: 0 on success, otherwise negative errno.
+ */
+int qcom_smem_bust_hwspin_lock_by_host(unsigned host)
+{
+ if (!__smem)
+ return -EPROBE_DEFER;
This would be called at a time where -EPROBE_DEFER isn't appropriate,
the client should invoke qcom_smem_is_available() at probe time to guard
against this.
Should we keep the null pointer check to prevent null pointer
dereference and return 0? Or would it be better to allow the null
pointer deference to go through so we can catch misuse of the API and
ask clients to use qcom_smem_is_available()?