• Maxime Ripard's avatar
    drm/vc4: v3d: Rework the runtime_pm setup · 266cff37
    Maxime Ripard authored
    At bind time, vc4_v3d_bind() will read a register to retrieve the v3d
    version and make sure it's a version we're compatible with.
    
    However, the v3d has an optional clock that is enabled only after the
    register read-out and a power domain that wasn't enabled at all in the bind
    implementation. This was working fine at boot because both were enabled,
    but resulted in the version check failing if we were unbinding and
    rebinding the driver because the unbinding would have turned them off.
    
    The fix isn't as easy as calling pm_runtime_resume_and_get() prior to the
    register access to power up the power domain though.
    
    Indeed, the runtime_resume implementation will enable the clock mentioned
    above, call vc4_v3d_init_hw() and then vc4_irq_enable().
    
    Prior to the previous patch, vc4_irq_enable() needed to occur after our
    call to platform_get_irq() and vc4_irq_install(), since vc4_irq_enable()
    used to call enable_irq() and vc4_irq_install() will call request_irq().
    
    vc4_irq_install() will also do some register access, so needs the power
    domain to be on. So we ended up in a situation where
    vc4_v3d_runtime_resume() needed vc4_irq_install() to have been called
    before, and vc4_irq_install() needed vc4_v3d_runtime_resume().
    
    The previous patch removed the enable_irq() call in vc4_irq_enable() and
    thus removed the dependency of vc4_v3d_runtime_resume() on
    vc4_irq_install().
    
    Thus, we can now rework our bind implementation to call
    pm_runtime_resume_and_get() before our register access to make sure the
    power domain is on. vc4_v3d_runtime_resume() also takes care of turning the
    clock on and calling vc4_v3d_init_hw() so we can remove them from bind.
    Acked-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
    Signed-off-by: default avatarMaxime Ripard <maxime@cerno.tech>
    Link: https://lore.kernel.org/r/20220711173939.1132294-69-maxime@cerno.tech
    266cff37
vc4_v3d.c 13.2 KB