Re: [PATCH 6/6] OPP: Use mutex locking guards

From: David Lechner

Date: Sun Feb 22 2026 - 19:01:42 EST


On 4/24/25 5:36 AM, Viresh Kumar wrote:
> Use mutex locking guard in the OPP core.
>
> No intentional functional impact.

There is an unintentional functional change here.

>
> Signed-off-by: Viresh Kumar <viresh.kumar@xxxxxxxxxx>
> ---

...

> @@ -2660,17 +2632,16 @@ struct dev_pm_opp *dev_pm_opp_xlate_required_opp(struct opp_table *src_table,
> return ERR_PTR(-EBUSY);
>
> for (i = 0; i < src_table->required_opp_count; i++) {
> - if (src_table->required_opp_tables[i] == dst_table) {
> - mutex_lock(&src_table->lock);
> + if (src_table->required_opp_tables[i] != dst_table)
> + continue;
>
> + scoped_guard(mutex, &src_table->lock) {
> list_for_each_entry(opp, &src_table->opp_list, node) {
> if (opp == src_opp) {
> dest_opp = dev_pm_opp_get(opp->required_opps[i]);
> break;
> }
> }
> -
> - mutex_unlock(&src_table->lock);
> break;
> }
> }

scoped_guard() is implemented as a for loop. So now this break statement
breaks out out the scoped_guard() and not out of the outer for loop. Now
the outer loop always iterates to completion.

Assuming each item in src_table->required_opp_tables is unique, this doesn't
look like a bug. Rather it is just doing unnecessary extra iterations.

To preserve the logic, the break should be moved out of the scoped_guard().