Skip to content

Commit 2e3f0d6

Browse files
quic-clewandersson
authored andcommitted
soc: qcom: smem: Add qcom_smem_bust_hwspin_lock_by_host()
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 <[email protected]> Reviewed-by: Bjorn Andersson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bjorn Andersson <[email protected]>
1 parent 855cf56 commit 2e3f0d6

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

drivers/soc/qcom/smem.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,32 @@ static struct qcom_smem *__smem;
359359
/* Timeout (ms) for the trylock of remote spinlocks */
360360
#define HWSPINLOCK_TIMEOUT 1000
361361

362+
/* The qcom hwspinlock id is always plus one from the smem host id */
363+
#define SMEM_HOST_ID_TO_HWSPINLOCK_ID(__x) ((__x) + 1)
364+
365+
/**
366+
* qcom_smem_bust_hwspin_lock_by_host() - bust the smem hwspinlock for a host
367+
* @host: remote processor id
368+
*
369+
* Busts the hwspin_lock for the given smem host id. This helper is intended
370+
* for remoteproc drivers that manage remoteprocs with an equivalent smem
371+
* driver instance in the remote firmware. Drivers can force a release of the
372+
* smem hwspin_lock if the rproc unexpectedly goes into a bad state.
373+
*
374+
* Context: Process context.
375+
*
376+
* Returns: 0 on success, otherwise negative errno.
377+
*/
378+
int qcom_smem_bust_hwspin_lock_by_host(unsigned int host)
379+
{
380+
/* This function is for remote procs, so ignore SMEM_HOST_APPS */
381+
if (host == SMEM_HOST_APPS || host >= SMEM_HOST_COUNT)
382+
return -EINVAL;
383+
384+
return hwspin_lock_bust(__smem->hwlock, SMEM_HOST_ID_TO_HWSPINLOCK_ID(host));
385+
}
386+
EXPORT_SYMBOL_GPL(qcom_smem_bust_hwspin_lock_by_host);
387+
362388
/**
363389
* qcom_smem_is_available() - Check if SMEM is available
364390
*

include/linux/soc/qcom/smem.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ phys_addr_t qcom_smem_virt_to_phys(void *p);
1414

1515
int qcom_smem_get_soc_id(u32 *id);
1616

17+
int qcom_smem_bust_hwspin_lock_by_host(unsigned int host);
18+
1719
#endif

0 commit comments

Comments
 (0)