Re: [RFC PATCH v1 3/5] media: tegra-video: Move PM runtime handle to streaming

From: Dmitry Osipenko
Date: Thu Apr 30 2020 - 09:24:26 EST


28.04.2020 19:04, Dmitry Osipenko ÐÐÑÐÑ:
...
>>>>>>>> +ÂÂÂÂÂÂÂÂÂÂÂÂ ret = pm_runtime_get_sync(csi->dev);
>>>>>>>> +ÂÂÂÂÂÂÂÂÂÂÂÂ if (ret < 0) {
>>>>>>>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ dev_err(csi->dev,
>>>>>>>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ "failed to get runtime PM: %d\n",
>>>>>>>> ret);
>>>>>>>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ pm_runtime_put_noidle(csi->dev);
>>> Why this pm_runtime_put_noidle() is needed? This should be wrong, please
>>> remove it.
>>
>> pm_runtime_get_sync() increments power.usage_count prior to rpm_resume
>>
>> if rpm_resume fails it does not decrement usage_count.
>>
>> So to balance count on failure, calling pm_runtime_put_noidle()
>
> Hmm.. maybe you're right. I'll need to take a more detailed look.
>

I checked the RPM's use-count after error condition and yours variant is
correct. Perhaps we should start correcting all other Tegra drivers that
do not handle the RPM error properly.