Hi Chaoyi, On Tue, Nov 24, 2026 at 11:54:03AM +0800, Chaoyi Chen wrote: > Hi Maxime, > > For a long time, we have implemented something similar through our own > hack. Thank you very much for this series. I'm glad it's useful :) > Please see below: > > On 11/20/2026 8:55 PM, Maxime Ripard wrote: > > In order to enable drivers to read their initial state from the > > hardware, each KMS object needs a hook to fill a pre-allocated state > > from the hardware registers. > > > > Introduce the atomic_sro_readout_state hook in every KMS object funcs > > vtable: drm_crtc_funcs, drm_plane_funcs, drm_connector_funcs, > > drm_bridge_funcs, and drm_private_state_funcs. > > > > Also introduce the drm_mode_config_funcs.atomic_sro_readout_state and > > drm_mode_config_helper_funcs.atomic_sro_build_state hooks, which are the > > top-level entry points for drivers and helpers respectively. > > > > The states read out aren't the current states of the objects yet, so > > they also need to be installed. Introduce the > > drm_mode_config_helper_funcs.atomic_sro_install_state hook to install a > > whole drm_atomic_sro_state, and an optional atomic_sro_install_state > > hook in drm_crtc_funcs, drm_plane_funcs, drm_connector_funcs and > > drm_private_state_funcs. The latter is called before the state of an > > object is replaced, so that drivers can acquire the resources needed to > > keep the hardware state active. > > > > Finally, add drm_atomic_sro_can_readout() to verify that all objects on > > a device implement the readout hook, and wire it into > > drm_atomic_sro_device_can_readout(). > > > > Reviewed-by: Maarten Lankhorst > > Signed-off-by: Maxime Ripard > > --- > > [...] > > > + > > + /** > > + * @atomic_sro_install_state: > > + * > > + * This optional hook is called when a state read out from > > + * hardware is about to be installed as the plane's current > > + * state. > > + * > > + * It allows drivers to acquire the resources needed to keep > > + * the current hardware state active, such as power domains, > > + * clocks, or interrupts. > > + * > > + * This hook cannot fail. It is called by the > > + * &drm_mode_config_helper_funcs.atomic_sro_install_state > > + * implementation, which is part of the hardware state readout > > + * initialization sequence. > > + */ > > + void (*atomic_sro_install_state)(struct drm_plane *plane, > > + struct drm_plane_state *plane_state); > > + > > Due to the presence of clk_disable_unused(), the relevant clk is likely > to be disabled prematurely, which may cause symptoms such as a black > screen. > > How does atomic_sro_install_state() ensure that it is called early enough, > thereby enabling the driver to turn on the corresponding clock? > > Or is this something that driver implementers need to consider, and should > the DRM core provide some kind of helper? Thank you. I guess you have mainly three options, depending on what your preferred setup is: - If your display driver is compiled as a built-in, it's a non-issue since the read-out will have been done before clk_disable_unused() runs. - The typical "distro" setup is that simpledrm will be builtin, grab the clock, we'll then load the driver as a module, do the readout, call install_state to get a clock reference and then drop simpledrm and its clock reference. In such a case, you always have a prepare / enable count > 1 so the clock never gets disabled by clk_disable_unused(). - If you don't want to have simpledrm but have the display driver as a module, and thus need to keep the clock running even though clk_disable_unused runs, I guess your best bet is to look into the sync_state Brian has been working on: https://lore.kernel.org/linux-clk/20260626-clk-sync-state-v1-0-4156d8196dc8@redhat.com/ Maxime