drm/rockchip: vop2: Fix integer underflow for power domain ref_count

If the PD has already been turned off, and the value of
vop2_power_domain.ref_count is zero at this time, calling
vop2_power_domain_put() again will cause ref_count to underflow.
This underflow will be interpreted as if the PD has been turned on.

Fixes: aa3aee14d0 ("drm/rockchip: vop2: Add vop2 internal pd support for rk3588")
Change-Id: Ia814c5907072cd1aee785734e36053cba7382b23
Signed-off-by: Chaoyi Chen <chaoyi.chen@rock-chips.com>
This commit is contained in:
Chaoyi Chen
2025-02-20 11:05:36 +00:00
committed by Tao Huang
parent 8d47fabe2f
commit 8b2e37f03c

View File

@@ -2067,11 +2067,14 @@ static void vop2_power_domain_put(struct vop2_power_domain *pd)
*
* So we have a check here
*/
if (--pd->ref_count == 0 && vop2_power_domain_can_off_by_vsync(pd)) {
if (pd->vop2->data->delayed_pd)
schedule_delayed_work(&pd->power_off_work, msecs_to_jiffies(2500));
else
vop2_power_domain_off(pd);
if (pd->ref_count) {
pd->ref_count--;
if (pd->ref_count == 0 && vop2_power_domain_can_off_by_vsync(pd)) {
if (pd->vop2->data->delayed_pd)
schedule_delayed_work(&pd->power_off_work, msecs_to_jiffies(2500));
else
vop2_power_domain_off(pd);
}
}
spin_unlock(&pd->lock);