Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] Runtime PM initialized without matching active hardware state, causing clocks to remain permanently enabled. - [High] Using devm_pm_runtime_enable() in a component bind callback ties PM lifecycle incorrectly, causing Use-After-Free and devres leaks. --
commit 77c03b774daaa80f329daaa791a8229e9e24ad9e Author: Sebastian Reichel <[email protected]> drm/rockchip: dw_dp: Add runtime PM support Add support for runtime PM to the Rockchip RK3576/3588 Synopsys DesignWare DisplayPort driver. > diff --git a/drivers/gpu/drm/rockchip/dw_dp-rockchip.c > b/drivers/gpu/drm/rockchip/dw_dp-rockchip.c > index 9c53f1d2c29ab..1f53228e56d9f 100644 > --- a/drivers/gpu/drm/rockchip/dw_dp-rockchip.c > +++ b/drivers/gpu/drm/rockchip/dw_dp-rockchip.c [ ... ] > @@ -213,6 +218,12 @@ static int dw_dp_rockchip_bind(struct device *dev, > struct device *master, void * > if (IS_ERR(dp->base)) > return PTR_ERR(dp->base); > > + pm_runtime_use_autosuspend(dev); > + pm_runtime_set_autosuspend_delay(dev, 500); [Severity: High] Since dw_dp_bind() enables the clocks (via devm_clk_get_enabled() when setting up the base dw_dp struct), shouldn't we call pm_runtime_set_active() before enabling runtime PM here? Without it, the PM core assumes the device starts in RPM_SUSPENDED state. When the device resumes, dw_dp_runtime_resume() will enable the clocks again (incrementing the enable count to 2). When autosuspend fires, dw_dp_runtime_suspend() will disable them (decrementing the count back to 1), meaning the hardware clocks are never physically disabled. > + ret = devm_pm_runtime_enable(dev); [Severity: High] Does using devm_pm_runtime_enable() here tie the PM lifecycle to the component platform device instead of the DRM master? The rockchip_dw_dp structure is allocated using drmm_kzalloc() earlier in this function, which binds its lifetime to the DRM master device. However, devm_pm_runtime_enable() attaches the devres action to the component device, whose lifetime spans the full probe/remove cycle. If the DRM master is unbound, dw_dp_rockchip_unbind() will execute but it does not disable PM runtime or flush the autosuspend timer. The DRM core will then free the drmm-managed memory. Could an autosuspend timer firing after unbind cause a use-after-free regression in dw_dp_rockchip_runtime_suspend() when it tries to access the freed dp pointer? Repeated bind/unbind cycles might also endlessly leak devres actions on the platform device. > + if (ret) > + return dev_err_probe(dev, ret, "failed to enable runtime PM\n"); > + > connector = drm_bridge_connector_init(drm_dev, encoder); -- Sashiko AI review ยท https://sashiko.dev/#/patchset/20260612-synopsys-dw-dp-improvements-v3-0-dc61e6352...@collabora.com?part=8
