mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-26 14:45:11 +07:00
215be713d0
The driver currently uses runtime PM to perform some of the module
initialization and cleanup. This has three problems:
1) There is no Kconfig dependency on CONFIG_PM, so if runtime PM is
disabled, the driver will not work at all, since the module will
never be initialized.
2) The driver does not ensure that the device is suspended when
sun6i_dsi_probe() fails or when sun6i_dsi_remove() is called. It
simply disables runtime PM. From the docs of pm_runtime_disable():
The device can be either active or suspended after its runtime PM
has been disabled.
And indeed, the device will likely still be active if sun6i_dsi_probe
fails. For example, if the panel driver is not yet loaded, we have
the following sequence:
sun6i_dsi_probe()
pm_runtime_enable()
mipi_dsi_host_register()
of_mipi_dsi_device_add(child)
...device_add()...
__device_attach()
pm_runtime_get_sync(dev->parent) -> Causes resume
bus_for_each_drv()
__device_attach_driver() -> No match for panel
pm_runtime_put(dev->parent) -> Async idle request
component_add()
__component_add()
try_to_bring_up_masters()
try_to_bring_up_master()
sun4i_drv_bind()
component_bind_all()
component_bind()
sun6i_dsi_bind() -> Fails with -EPROBE_DEFER
mipi_dsi_host_unregister()
pm_runtime_disable()
__pm_runtime_disable()
__pm_runtime_barrier() -> Idle request is still pending
cancel_work_sync() -> DSI host is *not* suspended!
Since the device is not suspended, the clock and regulator are never
disabled. The imbalance causes a WARN at devres free time.
3) The driver relies on being suspended when sun6i_dsi_encoder_enable()
is called. The resume callback has a comment that says:
Some part of it can only be done once we get a number of
lanes, see sun6i_dsi_inst_init
And then part of the resume callback only runs if dsi->device is not
NULL (that is, if sun6i_dsi_attach() has been called). However, as
the above call graph shows, the resume callback is guaranteed to be
called before sun6i_dsi_attach(); it is called before child devices
get their drivers attached.
Therefore, part of the controller initialization will only run if the
device is suspended between the calls to mipi_dsi_host_register() and
component_add() (which ends up calling sun6i_dsi_encoder_enable()).
Again, as shown by the above call graph, this is not the case. It
appears that the controller happens to work because it is still
initialized by the bootloader.
Because the connector is hardcoded to always be connected, the
device's runtime PM reference is not dropped until system suspend,
when sun4i_drv_drm_sys_suspend() ends up calling
sun6i_dsi_encoder_disable(). However, that is done as a system sleep
PM hook, and at that point the system PM core has already taken
another runtime PM reference, so sun6i_dsi_runtime_suspend() is
not called. Likewise, by the time the PM core releases its reference,
sun4i_drv_drm_sys_resume() has already re-enabled the encoder.
So after system suspend and resume, we have *still never called*
sun6i_dsi_inst_init(), and now that the rest of the display pipeline
has been reset, the DSI host is unable to communicate with the panel,
causing VBLANK timeouts.
Fix all of these issues by inlining the runtime PM hooks into the
encoder enable/disable functions, which are guaranteed to run after a
panel is attached. This allows sun6i_dsi_inst_init() to be called
unconditionally. Furthermore, this causes the hardware to be turned off
during system suspend and reinitialized on resume, which was not
happening before.
Fixes:
|
||
---|---|---|
.. | ||
amd | ||
arc | ||
arm | ||
armada | ||
aspeed | ||
ast | ||
atmel-hlcdc | ||
bochs | ||
bridge | ||
cirrus | ||
etnaviv | ||
exynos | ||
fsl-dcu | ||
gma500 | ||
hisilicon | ||
i2c | ||
i810 | ||
i915 | ||
imx | ||
ingenic | ||
lib | ||
lima | ||
mcde | ||
mediatek | ||
meson | ||
mga | ||
mgag200 | ||
msm | ||
mxsfb | ||
nouveau | ||
omapdrm | ||
panel | ||
panfrost | ||
pl111 | ||
qxl | ||
r128 | ||
radeon | ||
rcar-du | ||
rockchip | ||
savage | ||
scheduler | ||
selftests | ||
shmobile | ||
sis | ||
sti | ||
stm | ||
sun4i | ||
tdfx | ||
tegra | ||
tidss | ||
tilcdc | ||
tiny | ||
ttm | ||
tve200 | ||
udl | ||
v3d | ||
vboxvideo | ||
vc4 | ||
vgem | ||
via | ||
virtio | ||
vkms | ||
vmwgfx | ||
xen | ||
zte | ||
drm_agpsupport.c | ||
drm_atomic_helper.c | ||
drm_atomic_state_helper.c | ||
drm_atomic_uapi.c | ||
drm_atomic.c | ||
drm_auth.c | ||
drm_blend.c | ||
drm_bridge.c | ||
drm_bufs.c | ||
drm_cache.c | ||
drm_client_modeset.c | ||
drm_client.c | ||
drm_color_mgmt.c | ||
drm_connector.c | ||
drm_context.c | ||
drm_crtc_helper_internal.h | ||
drm_crtc_helper.c | ||
drm_crtc_internal.h | ||
drm_crtc.c | ||
drm_damage_helper.c | ||
drm_debugfs_crc.c | ||
drm_debugfs.c | ||
drm_dma.c | ||
drm_dp_aux_dev.c | ||
drm_dp_cec.c | ||
drm_dp_dual_mode_helper.c | ||
drm_dp_helper.c | ||
drm_dp_mst_topology_internal.h | ||
drm_dp_mst_topology.c | ||
drm_drv.c | ||
drm_dsc.c | ||
drm_dumb_buffers.c | ||
drm_edid_load.c | ||
drm_edid.c | ||
drm_encoder_slave.c | ||
drm_encoder.c | ||
drm_fb_cma_helper.c | ||
drm_fb_helper.c | ||
drm_file.c | ||
drm_flip_work.c | ||
drm_format_helper.c | ||
drm_fourcc.c | ||
drm_framebuffer.c | ||
drm_gem_cma_helper.c | ||
drm_gem_framebuffer_helper.c | ||
drm_gem_shmem_helper.c | ||
drm_gem_ttm_helper.c | ||
drm_gem_vram_helper.c | ||
drm_gem.c | ||
drm_hashtab.c | ||
drm_hdcp.c | ||
drm_internal.h | ||
drm_ioc32.c | ||
drm_ioctl.c | ||
drm_irq.c | ||
drm_kms_helper_common.c | ||
drm_lease.c | ||
drm_legacy_misc.c | ||
drm_legacy.h | ||
drm_lock.c | ||
drm_memory.c | ||
drm_mipi_dbi.c | ||
drm_mipi_dsi.c | ||
drm_mm.c | ||
drm_mode_config.c | ||
drm_mode_object.c | ||
drm_modes.c | ||
drm_modeset_helper.c | ||
drm_modeset_lock.c | ||
drm_of.c | ||
drm_panel_orientation_quirks.c | ||
drm_panel.c | ||
drm_pci.c | ||
drm_plane_helper.c | ||
drm_plane.c | ||
drm_prime.c | ||
drm_print.c | ||
drm_probe_helper.c | ||
drm_property.c | ||
drm_rect.c | ||
drm_scatter.c | ||
drm_scdc_helper.c | ||
drm_self_refresh_helper.c | ||
drm_simple_kms_helper.c | ||
drm_syncobj.c | ||
drm_sysfs.c | ||
drm_trace_points.c | ||
drm_trace.h | ||
drm_vblank.c | ||
drm_vm.c | ||
drm_vma_manager.c | ||
drm_vram_helper_common.c | ||
drm_writeback.c | ||
Kconfig | ||
Makefile |