kernel_samsung_a53x/drivers/gpu/drm
Tomi Valkeinen 5fb3faa4f0 drm/mipi-dsi: Fix detach call without attach
[ Upstream commit 90d50b8d85834e73536fdccd5aa913b30494fef0 ]

It's been reported that DSI host driver's detach can be called without
the attach ever happening:

https://lore.kernel.org/all/20230412073954.20601-1-tony@atomide.com/

After reading the code, I think this is what happens:

We have a DSI host defined in the device tree and a DSI peripheral under
that host (i.e. an i2c device using the DSI as data bus doesn't exhibit
this behavior).

The host driver calls mipi_dsi_host_register(), which causes (via a few
functions) mipi_dsi_device_add() to be called for the DSI peripheral. So
now we have a DSI device under the host, but attach hasn't been called.

Normally the probing of the devices continues, and eventually the DSI
peripheral's driver will call mipi_dsi_attach(), attaching the
peripheral.

However, if the host driver's probe encounters an error after calling
mipi_dsi_host_register(), and before the peripheral has called
mipi_dsi_attach(), the host driver will do cleanups and return an error
from its probe function. The cleanups include calling
mipi_dsi_host_unregister().

mipi_dsi_host_unregister() will call two functions for all its DSI
peripheral devices: mipi_dsi_detach() and mipi_dsi_device_unregister().
The latter makes sense, as the device exists, but the former may be
wrong as attach has not necessarily been done.

To fix this, track the attached state of the peripheral, and only detach
from mipi_dsi_host_unregister() if the peripheral was attached.

Note that I have only tested this with a board with an i2c DSI
peripheral, not with a "pure" DSI peripheral.

However, slightly related, the unregister machinery still seems broken.
E.g. if the DSI host driver is unbound, it'll detach and unregister the
DSI peripherals. After that, when the DSI peripheral driver unbound
it'll call detach either directly or using the devm variant, leading to
a crash. And probably the driver will crash if it happens, for some
reason, to try to send a message via the DSI bus.

But that's another topic.

Tested-by: H. Nikolaus Schaller <hns@goldelico.com>
Acked-by: Maxime Ripard <mripard@kernel.org>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Tested-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230921-dsi-detach-fix-v1-1-d0de2d1621d9@ideasonboard.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-18 12:13:18 +01:00
..
amd drm/amd/display: Fix tiled display misalignment 2024-11-18 12:13:17 +01:00
arc Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
arm drm/komeda: drop all currently held locks if deadlock happens 2024-11-18 11:43:13 +01:00
armada Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
aspeed Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ast Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
atmel-hlcdc Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
bochs Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
bridge drm/bridge: nxp-ptn3460: simplify some error checking 2024-11-18 12:13:03 +01:00
etnaviv Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
exynos drm/exynos: gsc: minor fix for loop iteration in gsc_runtime_resume 2024-11-18 12:13:07 +01:00
fsl-dcu Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
gma500 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
hisilicon Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
i2c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
i810 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
i915 drm/i915/dp: Fix passing the correct DPCD_REV for drm_dp_set_phy_test_pattern 2024-11-18 12:12:06 +01:00
imx Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ingenic Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
lib Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
lima Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mcde Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mediatek drm/mediatek: Add spinlock for setting vblank event in atomic_begin 2024-11-18 12:11:56 +01:00
meson Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mga Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mgag200 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
msm drm/msm/dsi: Use pm_runtime_resume_and_get to prevent refcnt leaks 2024-11-18 12:12:40 +01:00
mxsfb Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
nouveau nouveau/vmm: don't set addr on the fail path to avoid warning 2024-11-18 12:12:59 +01:00
omapdrm Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
panel drm: panel-simple: add missing bus flags for Tianma tm070jvhg[30/33] 2024-11-18 12:13:07 +01:00
panfrost Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pl111 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
qxl drm/qxl: fix UAF on handle creation 2024-11-18 12:12:11 +01:00
r128 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
radeon gpu/drm/radeon: fix two memleaks in radeon_vm_init 2024-11-18 12:12:41 +01:00
rcar-du Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
rockchip drm/rockchip: vop: Fix color for RGB888/BGR888 format on VOP full 2024-11-18 12:10:54 +01:00
samsung exynos_gpu: Don't allow userspace to control freqs 2024-06-15 16:28:49 -03:00
savage Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
scheduler Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
selftests Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
shmobile Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sis Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sti Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
stm Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sun4i Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tdfx Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tegra Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tidss drm/tidss: Fix atomic_flush check 2024-11-18 12:13:03 +01:00
tilcdc Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tiny Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ttm Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tve200 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
udl Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
v3d Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
vboxvideo Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
vc4 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
vgem Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
via Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
virtio Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
vkms Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
vmwgfx drm/vmwgfx: fix typo of sizeof argument 2024-11-08 11:25:46 +01:00
xen Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
xlnx Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
zte Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_agpsupport.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_atomic.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_atomic_helper.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_atomic_state_helper.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_atomic_uapi.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_auth.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_blend.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_bridge.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_bridge_connector.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_bufs.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_cache.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_client.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_client_modeset.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_color_mgmt.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_connector.c drm/connector: Add support for out-of-band hotplug notification (v3) 2024-11-08 11:26:15 +01:00
drm_context.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_crtc.c drm/crtc: fix uninitialized variable use 2024-11-18 12:12:18 +01:00
drm_crtc_helper.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_crtc_helper_internal.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_crtc_internal.h drm/connector: Add drm_connector_find_by_fwnode() function (v3) 2024-11-08 11:26:15 +01:00
drm_damage_helper.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_debugfs.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_debugfs_crc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_dma.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_dp_aux_dev.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_dp_cec.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_dp_dual_mode_helper.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_dp_helper.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_dp_mst_topology.c drm/dp_mst: Fix NULL deref in get_mst_branch_device_by_guid_helper() 2024-11-18 10:58:29 +01:00
drm_dp_mst_topology_internal.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_drv.c drm/drv: propagate errors from drm_modeset_register_all() 2024-11-18 12:12:40 +01:00
drm_dsc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_dumb_buffers.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_edid.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_edid_load.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_encoder.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_encoder_slave.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_fb_cma_helper.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_fb_helper.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_file.c drm/drm_file: fix use of uninitialized variable 2024-11-18 12:13:17 +01:00
drm_flip_work.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_format_helper.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_fourcc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_framebuffer.c drm/framebuffer: Fix use of uninitialized variable 2024-11-18 12:13:18 +01:00
drm_gem.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_gem_cma_helper.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_gem_framebuffer_helper.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_gem_shmem_helper.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_gem_ttm_helper.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_gem_vram_helper.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_hashtab.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_hdcp.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_internal.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_ioc32.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_ioctl.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_irq.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_kms_helper_common.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_lease.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_legacy.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_legacy_misc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_lock.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_managed.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_memory.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_mipi_dbi.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_mipi_dsi.c drm/mipi-dsi: Fix detach call without attach 2024-11-18 12:13:18 +01:00
drm_mm.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_mode_config.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_mode_object.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_modes.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_modeset_helper.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_modeset_lock.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_of.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_panel.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_panel_orientation_quirks.c drm: panel-orientation-quirks: Add quirk for One Mix 2S 2024-11-08 11:26:17 +01:00
drm_pci.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_plane.c drm: Don't unref the same fb many times by mistake due to deadlock handling 2024-11-18 12:13:03 +01:00
drm_plane_helper.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_prime.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_print.c drm: Stub out debug prints 2024-11-17 17:45:26 +01:00
drm_probe_helper.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_property.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_rect.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_scatter.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_scdc_helper.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_self_refresh_helper.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_simple_kms_helper.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_syncobj.c drm/syncobj: fix DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE 2024-11-18 11:43:11 +01:00
drm_sysfs.c drm/connector: Add a fwnode pointer to drm_connector and register with ACPI (v2) 2024-11-08 11:26:14 +01:00
drm_trace.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_trace_points.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_vblank.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_vblank_work.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_vm.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_vma_manager.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
drm_writeback.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Kconfig Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Makefile Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00