linux/drivers/gpu/drm
Jon Hunter 280dc0e145 drm/tegra: Fix crash caused by reference count imbalance
Commit d2307dea14 ("drm/atomic: use connector references (v3)") added
reference counting for DRM connectors and this caused a crash when
exercising system suspend on Tegra114 Dalmore.

The Tegra DSI driver implements a Tegra specific function,
tegra_dsi_connector_duplicate_state(), to duplicate the connector state
and destroys the state using the generic helper function,
drm_atomic_helper_connector_destroy_state(). Following commit
d2307dea14 ("drm/atomic: use connector references (v3)") there is
now an imbalance in the connector reference count because the Tegra
function to duplicate state does not take a reference when duplicating
the state information. However, the generic helper function to destroy
the state information assumes a reference has been taken and during
system suspend, when the connector state is destroyed, this leads to a
crash because we attempt to put the reference for an object that has
already been freed.

Fix this by calling __drm_atomic_helper_connector_duplicate_state() from
tegra_dsi_connector_duplicate_state() to ensure that we take a reference
on a connector if crtc is set. Note that this will also copy the
connector state a 2nd time, but this should be harmless.

By fixing tegra_dsi_connector_duplicate_state() to take a reference,
although a crash was no longer seen, it was then observed that after
each system suspend-resume cycle, the reference would be one greater
than before the suspend-resume cycle. Following commit d2307dea14
("drm/atomic: use connector references (v3)"), it was found that we
also need to put the reference when calling the function
tegra_dsi_connector_reset() before freeing the state. Fix this by
updating tegra_dsi_connector_reset() to call the function
__drm_atomic_helper_connector_destroy_state() in order to put the
reference for the connector.

Fixes: d2307dea14 ("drm/atomic: use connector references (v3)")

Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1463585856-16606-1-git-send-email-jonathanh@nvidia.com
2016-05-18 18:03:33 +02:00
..
amd drm: Remove unused drm_device from drm_gem_object_lookup() 2016-05-17 08:47:30 +02:00
arc drm/arcpgu: use dedicated memory area for frame buffer 2016-04-29 14:22:32 +03:00
arm drm/arm/hdlcd: Rename async to nonblock. 2016-05-02 16:36:09 +02:00
armada drm: Remove unused drm_device from drm_gem_object_lookup() 2016-05-17 08:47:30 +02:00
ast drm: Remove unused drm_device from drm_gem_object_lookup() 2016-05-17 08:47:30 +02:00
atmel-hlcdc drm: Drop crtc argument from __drm_atomic_helper_crtc_destroy_state 2016-05-17 08:56:41 +02:00
bochs drm: Remove unused drm_device from drm_gem_object_lookup() 2016-05-17 08:47:30 +02:00
bridge drm/bridge: Add Analogix anx78xx support 2016-05-12 11:32:14 +02:00
cirrus drm: Remove unused drm_device from drm_gem_object_lookup() 2016-05-17 08:47:30 +02:00
etnaviv drm: Remove unused drm_device from drm_gem_object_lookup() 2016-05-17 08:47:30 +02:00
exynos drm/exynos/hdmi: add a missing tab 2016-05-17 09:10:22 +02:00
fsl-dcu drm/fsl-dcu: use bus_flags for pixel clock polarity 2016-05-05 10:09:06 -07:00
gma500 drm: Remove unused drm_device from drm_gem_object_lookup() 2016-05-17 08:47:30 +02:00
hisilicon drm/hisilicon: Fix DRM_INFO printed issue 2016-05-11 19:05:36 +08:00
i2c Merge drm-fixes into drm-next. 2016-03-14 09:46:02 +10:00
i810
i915 drm/i915/fbdev: Fix num_connector references in intel_fb_initial_config() 2016-05-17 15:42:35 +02:00
imx drm/imx: Use lockless gem BO free callback 2016-05-04 12:27:54 +02:00
mediatek drm: Drop plane argument from __drm_atomic_helper_plane_destroy_state 2016-05-17 08:56:55 +02:00
mga
mgag200 drm: Remove unused drm_device from drm_gem_object_lookup() 2016-05-17 08:47:30 +02:00
msm drm: Remove unused drm_device from drm_gem_object_lookup() 2016-05-17 08:47:30 +02:00
nouveau drm: Remove unused drm_device from drm_gem_object_lookup() 2016-05-17 08:47:30 +02:00
omapdrm drm: Drop plane argument from __drm_atomic_helper_plane_destroy_state 2016-05-17 08:56:55 +02:00
panel drm/panel: simple: Add support for TPK U.S.A. LLC Fusion 7" and 10.1" panels 2016-05-12 11:32:14 +02:00
qxl qxl: catch qxlfb_create_pinned_object failures 2016-05-17 09:11:23 +02:00
r128
radeon drm: Remove unused drm_device from drm_gem_object_lookup() 2016-05-17 08:47:30 +02:00
rcar-du drm: Drop plane argument from __drm_atomic_helper_plane_destroy_state 2016-05-17 08:56:55 +02:00
rockchip drm: Drop plane argument from __drm_atomic_helper_plane_destroy_state 2016-05-17 08:56:55 +02:00
savage
shmobile drm/shmobile: use drm_crtc_send_vblank_event() 2016-05-02 17:04:50 +02:00
sis
sti drm/sti: include linux/seq_file.h where needed 2016-05-11 09:47:05 +02:00
sun4i drm: sun4i: tv: Add NTSC output standard 2016-04-28 10:30:05 +02:00
tdfx
tegra drm/tegra: Fix crash caused by reference count imbalance 2016-05-18 18:03:33 +02:00
tilcdc drm/tilcdc: use drm_crtc_send_vblank_event() 2016-05-02 17:04:59 +02:00
ttm Linux 4.6-rc7 2016-05-09 13:49:56 +10:00
udl drm: Remove unused drm_device from drm_gem_object_lookup() 2016-05-17 08:47:30 +02:00
vc4 drm: Drop plane argument from __drm_atomic_helper_plane_destroy_state 2016-05-17 08:56:55 +02:00
vgem drm: Remove unused drm_device from drm_gem_object_lookup() 2016-05-17 08:47:30 +02:00
via mm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macros 2016-04-04 10:41:08 -07:00
virtio drm: Remove unused drm_device from drm_gem_object_lookup() 2016-05-17 08:47:30 +02:00
vmwgfx Linux 4.6-rc7 2016-05-09 13:49:56 +10:00
ati_pcigart.c
drm_agpsupport.c drm: Give drm_agp_clear drm_legacy_ prefix 2016-04-27 08:41:34 +02:00
drm_atomic_helper.c drm: Drop connector argument from __drm_atomic_helper_connector_destroy_state 2016-05-17 08:57:05 +02:00
drm_atomic.c drm: Avoid connector reference imbalance on error path 2016-05-18 10:42:01 +02:00
drm_auth.c
drm_bridge.c drm: bridge: Make (pre/post) enable/disable callbacks optional 2016-03-29 08:34:05 +02:00
drm_bufs.c drm: Hide master MAP cleanup in drm_bufs.c 2016-04-27 10:14:17 +02:00
drm_cache.c
drm_context.c
drm_crtc_helper.c drm: Make drm_encoder_helper_funcs optional 2016-05-10 08:54:09 +02:00
drm_crtc_internal.h drm/mode: rework drm_mode_object_put to drm_mode_object_unregister. 2016-04-22 10:26:37 +10:00
drm_crtc.c drm: Fix error handling in drm_connector_register 2016-05-18 12:24:51 +02:00
drm_debugfs.c
drm_dma.c
drm_dp_aux_dev.c drm/dp: Allow signals to interrupt drm_aux-dev reads/writes 2016-04-28 11:48:09 +02:00
drm_dp_helper.c drm/dp_helper: Perform throw-away read before actual read in drm_dp_dpcd_read() 2016-04-22 18:52:24 +02:00
drm_dp_mst_topology.c Linux 4.6-rc7 2016-05-09 13:49:56 +10:00
drm_drv.c drm: Protect dev->filelist with its own mutex 2016-04-27 10:16:17 +02:00
drm_edid_load.c drm/edid: convert to use match_string() helper 2016-03-17 15:09:34 -07:00
drm_edid.c Linux 4.6-rc7 2016-05-09 13:49:56 +10:00
drm_encoder_slave.c
drm_fb_cma_helper.c drm/fb-cma-helper: Add function drm_fb_cma_create_with_funcs() 2016-05-17 09:08:32 +02:00
drm_fb_helper.c drm/fb_helper: Fix references to dev->mode_config.num_connector 2016-05-17 15:44:41 +02:00
drm_flip_work.c
drm_fops.c drm: Protect dev->filelist with its own mutex 2016-04-27 10:16:17 +02:00
drm_gem_cma_helper.c drm: Remove unused drm_device from drm_gem_object_lookup() 2016-05-17 08:47:30 +02:00
drm_gem.c drm: Remove unused drm_device from drm_gem_object_lookup() 2016-05-17 08:47:30 +02:00
drm_global.c
drm_hashtab.c
drm_info.c drm: Protect dev->filelist with its own mutex 2016-04-27 10:16:17 +02:00
drm_internal.h drm: Make drm_vm_open/close_locked private to drm_vm.c 2016-04-27 10:15:56 +02:00
drm_ioc32.c
drm_ioctl.c drm: Move drm_getmap into drm_bufs.c and give it a legacy prefix 2016-04-27 08:42:48 +02:00
drm_irq.c Merge tag 'topic/drm-misc-2016-04-01' of git://anongit.freedesktop.org/drm-intel into drm-next 2016-04-06 09:39:01 +10:00
drm_kms_helper_common.c
drm_legacy.h drm: Move drm_getmap into drm_bufs.c and give it a legacy prefix 2016-04-27 08:42:48 +02:00
drm_lock.c
drm_memory.c
drm_mipi_dsi.c
drm_mm.c
drm_modes.c drm/mode: rework drm_mode_object_put to drm_mode_object_unregister. 2016-04-22 10:26:37 +10:00
drm_modeset_lock.c
drm_of.c
drm_panel.c drm/panel: Flesh out kerneldoc 2016-05-06 16:04:48 +02:00
drm_pci.c drm: Give drm_agp_clear drm_legacy_ prefix 2016-04-27 08:41:34 +02:00
drm_plane_helper.c
drm_platform.c
drm_prime.c drm: Remove unused drm_device from drm_gem_object_lookup() 2016-05-17 08:47:30 +02:00
drm_probe_helper.c drm: probe_helper: Hide ugly ifdef 2016-04-20 13:35:14 +02:00
drm_rect.c
drm_scatter.c
drm_sysfs.c drm/sysfs: Annote lockless show functions with READ_ONCE 2016-04-26 13:23:24 +02:00
drm_trace_points.c
drm_trace.h
drm_vm.c drm: Make drm_vm_open/close_locked private to drm_vm.c 2016-04-27 10:15:56 +02:00
drm_vma_manager.c
Kconfig drm/mediatek: Add DRM Driver for Mediatek SoC MT8173. 2016-05-06 17:47:35 +02:00
Makefile drm/mediatek: Add DRM Driver for Mediatek SoC MT8173. 2016-05-06 17:47:35 +02:00