diff options
author | Clément Viel <clement.viel@qorvo.com> | 2022-09-29 10:42:02 +0200 |
---|---|---|
committer | TreeHugger Robot <treehugger-gerrit@google.com> | 2022-11-15 00:20:51 +0000 |
commit | ab4fdd982b6db8788706ebbf2172b61fe5662b2b (patch) | |
tree | dd60a65ceeb9f585d158a55166b9444fef6c4f3a | |
parent | ab28ff91f6c6cbafadccf9d93b73f1b6e0d1437a (diff) | |
download | uwb-ab4fdd982b6db8788706ebbf2172b61fe5662b2b.tar.gz |
dw3000: min_clamp_value
Allow new values to be set during module load for testing
Set min value per uwb testing as described in bug
Bug: 248112166
Signed-off-by: Clément Viel <clement.viel@qorvo.com>
Change-Id: Ib47aad151a47b188becd8550ce4530348e0b517a
-rw-r--r-- | kernel/drivers/net/ieee802154/dw3000.h | 3 | ||||
-rw-r--r-- | kernel/drivers/net/ieee802154/dw3000_stm.c | 38 |
2 files changed, 36 insertions, 5 deletions
diff --git a/kernel/drivers/net/ieee802154/dw3000.h b/kernel/drivers/net/ieee802154/dw3000.h index e21ef8e..4495a2d 100644 --- a/kernel/drivers/net/ieee802154/dw3000.h +++ b/kernel/drivers/net/ieee802154/dw3000.h @@ -714,7 +714,8 @@ struct dw3000 { /* Buffer for queued transfers */ char *msg_queue_buf; char *msg_queue_buf_pos; - + /* dw3000 thread clamp value */ + int min_clamp_value; /* Insert new fields before this line */ /* Shared message protected by a mutex */ diff --git a/kernel/drivers/net/ieee802154/dw3000_stm.c b/kernel/drivers/net/ieee802154/dw3000_stm.c index 5eee5cf..5b85643 100644 --- a/kernel/drivers/net/ieee802154/dw3000_stm.c +++ b/kernel/drivers/net/ieee802154/dw3000_stm.c @@ -21,21 +21,50 @@ * Qorvo. Please contact Qorvo to inquire about licensing terms. */ #include <linux/version.h> +#include <linux/module.h> #include <linux/workqueue.h> #include <linux/sched.h> #include <linux/mutex.h> +#include <linux/of.h> #include "dw3000.h" #include "dw3000_core.h" -#define DW3000_MIN_CLAMP_VALUE 170 +#define DW3000_MIN_CLAMP_VALUE 460 /* First version with sched_setattr_nocheck: v4.16-rc1~164^2~5 */ #if (KERNEL_VERSION(4, 11, 0) <= LINUX_VERSION_CODE) #include <uapi/linux/sched/types.h> #endif -static inline int dw3000_set_sched_attr(struct task_struct *p) +static int dw3000_min_clamp_value = 0; + +module_param_named(min_clamp_value, dw3000_min_clamp_value, int, 0644); +MODULE_PARM_DESC(min_clamp_value, "Sets the minimum cpu frequency the dw3000 thread must run at"); + + +static void dw3000_get_clamp_from_dt(struct dw3000 *dw) { + int dt_clamp = DW3000_MIN_CLAMP_VALUE; + int ret; + + if (!dw->dev->of_node) + return; + /* debug value is priority */ + if (dw3000_min_clamp_value) { + dw->min_clamp_value = dw3000_min_clamp_value; + dev_info(dw->dev, "using debug min clamp=%d\n", dw->min_clamp_value); + return; + } + + ret = of_property_read_u32(dw->dev->of_node, "min_clamp", &dt_clamp); + if (ret) { + dev_err(dw->dev, "error reading dt_clamp ret=%d\n", ret); + } + dw->min_clamp_value = dt_clamp; + dev_info(dw->dev, "dt_clamp=%d\n", dw->min_clamp_value); +} + +static inline int dw3000_set_sched_attr(struct dw3000 *dw, struct task_struct *p) { #if (KERNEL_VERSION(5, 9, 0) > LINUX_VERSION_CODE) struct sched_param sched_par = { .sched_priority = MAX_RT_PRIO - 2 }; @@ -45,7 +74,7 @@ static inline int dw3000_set_sched_attr(struct task_struct *p) struct sched_attr attr = { .sched_policy = SCHED_FIFO, .sched_priority = MAX_RT_PRIO - 2, .sched_flags = SCHED_FLAG_UTIL_CLAMP_MIN, - .sched_util_min = DW3000_MIN_CLAMP_VALUE }; + .sched_util_min = dw->min_clamp_value }; return sched_setattr_nocheck(p, &attr); #endif } @@ -312,7 +341,8 @@ int dw3000_state_init(struct dw3000 *dw, int cpu) dw->dw3000_pid = stm->mthread->pid; /* Increase thread priority */ - rc = dw3000_set_sched_attr(stm->mthread); + dw3000_get_clamp_from_dt(dw); + rc = dw3000_set_sched_attr(dw, stm->mthread); if (rc) dev_err(dw->dev, "dw3000_set_sched_attr failed: %d\n", rc); return 0; |