Re: [PATCH v4 2/7] OPP: Move refcount and key update for readability in _opp_table_find_key()

From: Marek Szyprowski
Date: Tue Aug 26 2025 - 03:27:05 EST


On 26.08.2025 08:06, Viresh Kumar wrote:
> Marek,
>
> Thanks for the detailed logs. I would need a little more help from
> you.
>
> Can you give this a try over your failing branch (I have already
> dropped the patch from my tree for now):
>
> diff --git a/drivers/opp/core.c b/drivers/opp/core.c
> index 81fb7dd7f323..5b24255733b5 100644
> --- a/drivers/opp/core.c
> +++ b/drivers/opp/core.c
> @@ -554,10 +554,10 @@ static struct dev_pm_opp *_opp_table_find_key(struct opp_table *opp_table,
> list_for_each_entry(temp_opp, &opp_table->opp_list, node) {
> if (temp_opp->available == available) {
> if (compare(&opp, temp_opp, read(temp_opp, index), *key)) {
> - *key = read(opp, index);
> -
> - /* Increment the reference count of OPP */
> - dev_pm_opp_get(opp);
> + if (!IS_ERR(opp)) {
> + *key = read(opp, index);
> + dev_pm_opp_get(opp);
> + }
> break;
> }
> }

This doesn't help. I've stared a bit at that code and did some tests
and it looks that the issue is caused by _opp_table_find_key() returning
the last opp from opp_list without updating the *key and calling
opp_get() for it (happens when compare() returns false).

> ...

Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland