This is an automated email from the ASF dual-hosted git repository. acassis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 77cb20f041dc1830de88b68ee06549d74958e512 Author: guanyi3 <[email protected]> AuthorDate: Fri Mar 6 11:31:51 2026 +0800 drivers/devfreq: add conflict_policy to devfreq_driver_s When multiple QoS requests have no overlapping frequency range (min > max), the previous behavior always clamped to the lower frequency. Add a conflict_policy field to devfreq_driver_s so callers can choose between DEVFREQ_CONFLICT_PREFER_HIGH (default, choose higher freq) and DEVFREQ_CONFLICT_PREFER_LOW (choose lower freq) at registration. Signed-off-by: guanyi3 <[email protected]> --- drivers/devfreq/devfreq.c | 9 ++++++++- include/nuttx/devfreq.h | 6 ++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 906fac4c5c6..5fad5626549 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -355,7 +355,14 @@ static void devfreq_refresh_limit(FAR struct devfreq_s *devfreq) if (min > max) { - min = max; + if (devfreq->driver->conflict_policy == DEVFREQ_CONFLICT_PREFER_HIGH) + { + max = min; + } + else + { + min = max; + } } idx = devfreq_table_find_freq(devfreq, min, DEVFREQ_RELATION_L); diff --git a/include/nuttx/devfreq.h b/include/nuttx/devfreq.h index 5189e6e1895..e17044be4ec 100644 --- a/include/nuttx/devfreq.h +++ b/include/nuttx/devfreq.h @@ -45,6 +45,11 @@ #define DEVFREQ_RELATION_L 0 /* lowest frequency at or above target */ #define DEVFREQ_RELATION_H 1 /* highest frequency below or at target */ +/* QoS conflict policy when min > max (no overlap between requests) */ + +#define DEVFREQ_CONFLICT_PREFER_HIGH 0 /* clamp to min, choose higher freq */ +#define DEVFREQ_CONFLICT_PREFER_LOW 1 /* clamp to max, choose lower freq */ + /**************************************************************************** * Public Types ****************************************************************************/ @@ -90,6 +95,7 @@ struct devfreq_governor_s struct devfreq_driver_s { + int conflict_policy; /* DEVFREQ_CONFLICT_PREFER_HIGH or LOW */ CODE FAR const uint32_t * (*get_table)(FAR struct devfreq_s *devfreq); CODE int (*target_index)(FAR struct devfreq_s *devfreq,
