• Imre Deak's avatar
    fbdev/efifb: Release PCI device's runtime PM ref during FB destroy · 55285e21
    Imre Deak authored
    Atm the EFI FB platform driver gets a runtime PM reference for the
    associated GFX PCI device during probing the EFI FB platform device and
    releases it only when the platform device gets unbound.
    
    When fbcon switches to the FB provided by the PCI device's driver (for
    instance i915/drmfb), the EFI FB will get only unregistered without the
    EFI FB platform device getting unbound, keeping the runtime PM reference
    acquired during the platform device probing. This reference will prevent
    the PCI driver from runtime suspending the device.
    
    Fix this by releasing the RPM reference from the EFI FB's destroy hook,
    called when the FB gets unregistered.
    
    While at it assert that pm_runtime_get_sync() didn't fail.
    
    v2:
    - Move pm_runtime_get_sync() before register_framebuffer() to avoid its
      race wrt. efifb_destroy()->pm_runtime_put(). (Daniel)
    - Assert that pm_runtime_get_sync() didn't fail.
    - Clarify commit message wrt. platform/PCI device/driver and driver
      removal vs. device unbinding.
    
    Fixes: a6c0fd3d ("efifb: Ensure graphics device for efifb stays at PCI D0")
    Cc: Kai-Heng Feng <kai.heng.feng@canonical.com>
    Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
    Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> (v1)
    Acked-by: default avatarAlex Deucher <alexander.deucher@amd.com>
    Acked-by: default avatarKai-Heng Feng <kai.heng.feng@canonical.com>
    Signed-off-by: default avatarImre Deak <imre.deak@intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20210809133146.2478382-1-imre.deak@intel.com
    55285e21
efifb.c 18.5 KB