hwspinlock: Add support to parse spin lock id

The current implementation will use hard coded spin lock id
which will cause conflicts when gvm want to access hardware
spink lock while communicating with remote host over dedicated
smem partition area.

Adding support to parse spin lock id from dt entry. This will
help to configure unique spin lock id for gvm.

Change-Id: I8001c6339a2d823109177dedbfceef9a5bdc2d51
Signed-off-by: Arun Prakash <app@codeaurora.org>
This commit is contained in:
Arun Prakash 2020-05-17 13:12:21 +05:30
parent 3aa681b633
commit 84248bd660

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, The Linux Foundation. All rights reserved.
* Copyright (c) 2013,2020, The Linux Foundation. All rights reserved.
* Copyright (c) 2015, Sony Mobile Communications AB
*
* This software is licensed under the terms of the GNU General Public
@ -28,13 +28,19 @@
#define QCOM_MUTEX_APPS_PROC_ID 1
#define QCOM_MUTEX_NUM_LOCKS 32
/**
* setting default mutex id as QCOM_MUTEX_APPS_PROC_ID
* and will override this value if dt entry is found
*/
static u32 qcom_mutex_lock_id = QCOM_MUTEX_APPS_PROC_ID;
static int qcom_hwspinlock_trylock(struct hwspinlock *lock)
{
struct regmap_field *field = lock->priv;
u32 lock_owner;
int ret;
ret = regmap_field_write(field, QCOM_MUTEX_APPS_PROC_ID);
ret = regmap_field_write(field, qcom_mutex_lock_id);
if (ret)
return ret;
@ -42,7 +48,7 @@ static int qcom_hwspinlock_trylock(struct hwspinlock *lock)
if (ret)
return ret;
return lock_owner == QCOM_MUTEX_APPS_PROC_ID;
return lock_owner == qcom_mutex_lock_id;
}
static void qcom_hwspinlock_unlock(struct hwspinlock *lock)
@ -57,7 +63,7 @@ static void qcom_hwspinlock_unlock(struct hwspinlock *lock)
return;
}
if (lock_owner != QCOM_MUTEX_APPS_PROC_ID) {
if (lock_owner != qcom_mutex_lock_id) {
pr_err("%s: spinlock not owned by us (actual owner is %d)\n",
__func__, lock_owner);
}
@ -88,6 +94,7 @@ static int qcom_hwspinlock_probe(struct platform_device *pdev)
size_t array_size;
u32 stride;
u32 base;
u32 mutex_id;
int ret;
int i;
@ -114,6 +121,10 @@ static int qcom_hwspinlock_probe(struct platform_device *pdev)
return -EINVAL;
}
ret = of_property_read_u32(pdev->dev.of_node, "mutex-id", &mutex_id);
if (!ret)
qcom_mutex_lock_id = mutex_id;
array_size = QCOM_MUTEX_NUM_LOCKS * sizeof(struct hwspinlock);
bank = devm_kzalloc(&pdev->dev, sizeof(*bank) + array_size, GFP_KERNEL);
if (!bank)