linux/drivers/gpu/drm
Linus Torvalds 39cb2c9a31 drm/i915: Check for NULL i915_vma in intel_unpin_fb_obj()
I've seen this trigger twice now, where the i915_gem_object_to_ggtt()
call in intel_unpin_fb_obj() returns NULL, resulting in an oops
immediately afterwards as the (inlined) call to i915_vma_unpin_fence()
tries to dereference it.

It seems to be some race condition where the object is going away at
shutdown time, since both times happened when shutting down the X
server.  The call chains were different:

 - VT ioctl(KDSETMODE, KD_TEXT):

    intel_cleanup_plane_fb+0x5b/0xa0 [i915]
    drm_atomic_helper_cleanup_planes+0x6f/0x90 [drm_kms_helper]
    intel_atomic_commit_tail+0x749/0xfe0 [i915]
    intel_atomic_commit+0x3cb/0x4f0 [i915]
    drm_atomic_commit+0x4b/0x50 [drm]
    restore_fbdev_mode+0x14c/0x2a0 [drm_kms_helper]
    drm_fb_helper_restore_fbdev_mode_unlocked+0x34/0x80 [drm_kms_helper]
    drm_fb_helper_set_par+0x2d/0x60 [drm_kms_helper]
    intel_fbdev_set_par+0x18/0x70 [i915]
    fb_set_var+0x236/0x460
    fbcon_blank+0x30f/0x350
    do_unblank_screen+0xd2/0x1a0
    vt_ioctl+0x507/0x12a0
    tty_ioctl+0x355/0xc30
    do_vfs_ioctl+0xa3/0x5e0
    SyS_ioctl+0x79/0x90
    entry_SYSCALL_64_fastpath+0x13/0x94

 - i915 unpin_work workqueue:

    intel_unpin_work_fn+0x58/0x140 [i915]
    process_one_work+0x1f1/0x480
    worker_thread+0x48/0x4d0
    kthread+0x101/0x140

and this patch purely papers over the issue by adding a NULL pointer
check and a WARN_ON_ONCE() to avoid the oops that would then generally
make the machine unresponsive.

Other callers of i915_gem_object_to_ggtt() seem to also check for the
returned pointer being NULL and warn about it, so this clearly has
happened before in other places.

[ Reported it originally to the i915 developers on Jan 8, applying the
  ugly workaround on my own now after triggering the problem for the
  second time with no feedback.

  This is likely to be the same bug reported as

     https://bugs.freedesktop.org/show_bug.cgi?id=98829
     https://bugs.freedesktop.org/show_bug.cgi?id=99134

  which has a patch for the underlying problem, but it hasn't gotten to
  me, so I'm applying the workaround. ]

Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Imre Deak <imre.deak@intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-01-29 13:50:06 -08:00
..
amd drm/amdgpu: fix unload driver issue for virtual display 2017-01-23 16:47:18 -05:00
arc Merge remote-tracking branch 'airlied/drm-next' into drm-misc-next 2016-12-06 10:26:48 +01:00
arm Linux 4.9-rc8 2016-12-05 17:11:48 +10:00
armada mm: use vmf->address instead of of vmf->virtual_address 2016-12-14 16:04:09 -08:00
ast drm/ast: Fixed system hanged if disable P2A 2017-01-27 10:40:03 +10:00
atmel-hlcdc drm: define drm_compat_ioctl NULL on CONFIG_COMPAT=n and reduce #ifdefs 2016-11-02 11:33:47 -04:00
bochs drm: Make the connector .detect() callback optional 2016-12-01 10:05:53 -05:00
bridge drm/bridge: analogix dp: Fix runtime PM state on driver bind 2017-01-09 13:30:37 +05:30
cirrus drm: flip cirrus driver status to "obsolete". 2017-01-10 14:00:40 +01:00
etnaviv drm/etnaviv: trick drm_mm into giving out a low IOVA 2017-01-11 10:38:45 +01:00
exynos drm/exynos/decon5433: set STANDALONE_UPDATE_F on output enablement 2017-01-20 16:17:12 +09:00
fsl-dcu Merge tag 'drm-fsl-dcu-for-next' of http://git.agner.ch/git/linux-drm-fsl-dcu into drm-next 2016-12-09 12:43:17 +10:00
gma500 mm: use vmf->address instead of of vmf->virtual_address 2016-12-14 16:04:09 -08:00
hisilicon drm: Make the connector .detect() callback optional 2016-12-01 10:05:53 -05:00
i2c drm/i2c: tda998x: fix spelling mistake 2016-11-18 00:00:40 +00:00
i810 drm: define drm_compat_ioctl NULL on CONFIG_COMPAT=n and reduce #ifdefs 2016-11-02 11:33:47 -04:00
i915 drm/i915: Check for NULL i915_vma in intel_unpin_fb_obj() 2017-01-29 13:50:06 -08:00
imx Merge remote-tracking branch 'airlied/drm-next' into drm-misc-next 2016-12-06 10:26:48 +01:00
mediatek Merge remote-tracking branch 'airlied/drm-next' into drm-misc-next 2016-12-06 10:26:48 +01:00
meson drm/meson: Fix CVBS VDAC disable 2017-01-04 12:09:30 +01:00
mga
mgag200 drm: Make the connector .detect() callback optional 2016-12-01 10:05:53 -05:00
msm drm/msm: fix potential null ptr issue in non-iommu case 2017-01-13 10:23:00 -05:00
mxsfb drm: mxsfb: Select DRM_PANEL 2016-12-08 10:25:37 +10:00
nouveau drm/nouveau: Handle fbcon suspend/resume in seperate worker 2017-01-27 10:50:35 +10:00
omapdrm mm: use vmf->address instead of of vmf->virtual_address 2016-12-14 16:04:09 -08:00
panel drm/panel: simple: Add support for AUO G185HAN01 2016-12-06 17:06:32 +01:00
qxl Merge remote-tracking branch 'airlied/drm-next' into drm-misc-next 2016-12-06 10:26:48 +01:00
r128
radeon Revert "drm/radeon: always apply pci shutdown callbacks" 2017-01-25 16:54:50 -05:00
rcar-du drm: Make the connector .detect() callback optional 2016-12-01 10:05:53 -05:00
rockchip drm: Make the connector .detect() callback optional 2016-12-01 10:05:53 -05:00
savage drm: define drm_compat_ioctl NULL on CONFIG_COMPAT=n and reduce #ifdefs 2016-11-02 11:33:47 -04:00
shmobile drm: Make the connector .detect() callback optional 2016-12-01 10:05:53 -05:00
sis drm: define drm_compat_ioctl NULL on CONFIG_COMPAT=n and reduce #ifdefs 2016-11-02 11:33:47 -04:00
sti drm: Make the connector .detect() callback optional 2016-12-01 10:05:53 -05:00
sun4i Merge remote-tracking branch 'airlied/drm-next' into drm-misc-next 2016-12-06 10:26:48 +01:00
tdfx drm: define drm_compat_ioctl NULL on CONFIG_COMPAT=n and reduce #ifdefs 2016-11-02 11:33:47 -04:00
tegra mm: use vmf->address instead of of vmf->virtual_address 2016-12-14 16:04:09 -08:00
tilcdc tilcdc fixes for v4.10. 2017-01-09 09:13:06 +10:00
ttm mm: use vmf->address instead of of vmf->virtual_address 2016-12-14 16:04:09 -08:00
udl mm: use vmf->address instead of of vmf->virtual_address 2016-12-14 16:04:09 -08:00
vc4 drm/vc4: Return -EINVAL on the overflow checks failing. 2017-01-17 22:06:01 +11:00
vgem mm: use vmf->address instead of of vmf->virtual_address 2016-12-14 16:04:09 -08:00
via drm: define drm_compat_ioctl NULL on CONFIG_COMPAT=n and reduce #ifdefs 2016-11-02 11:33:47 -04:00
virtio drm/virtio: fix framebuffer sparse warning 2017-01-10 13:58:20 +01:00
vmwgfx drm/vmwgfx: Switch to mode_cmd2 2016-12-02 17:15:20 +01:00
zte drm: zte: checking for NULL instead of IS_ERR() 2016-11-15 11:00:42 +01:00
Kconfig Add support for the Amlogic Meson Video Processing Unit 2016-12-08 10:35:52 +10:00
Makefile Add support for the Amlogic Meson Video Processing Unit 2016-12-08 10:35:52 +10:00
ati_pcigart.c
drm_agpsupport.c
drm_atomic.c drm/fence: fix memory overwrite when setting out_fence fd 2017-01-16 20:00:54 -02:00
drm_atomic_helper.c drm: Clean up planes in atomic commit helper failure path 2017-01-04 11:08:13 +01:00
drm_auth.c
drm_blend.c drm: RIP mode_config->rotation_property 2016-10-22 10:42:11 +02:00
drm_bridge.c
drm_bufs.c
drm_cache.c
drm_color_mgmt.c drm/color: document NULL values and default settings better 2016-11-15 22:39:48 +01:00
drm_connector.c drm: document standard connector properties 2016-11-18 09:45:07 +01:00
drm_context.c
drm_crtc.c drm/fence: add drm_crtc_create_fence() 2016-12-07 11:16:55 -02:00
drm_crtc_helper.c
drm_crtc_helper_internal.h
drm_crtc_internal.h drm/fence: add drm_crtc_create_fence() 2016-12-07 11:16:55 -02:00
drm_debugfs.c drm/atomic: cleanup debugfs entries on un-registering the driver. 2016-11-21 13:22:08 -05:00
drm_debugfs_crc.c drm: fix sparse warnings on undeclared symbols in crc debugfs 2016-10-19 14:10:29 +03:00
drm_dma.c
drm_dp_aux_dev.c
drm_dp_dual_mode_helper.c drm: Print some debug/error info during DP dual mode detect 2016-10-26 15:57:11 -04:00
drm_dp_helper.c
drm_dp_mst_topology.c drm/dp/mst: Check peer device type before attempting EDID read 2016-10-26 18:53:44 +02:00
drm_drv.c drm: Add fake controlD* symlinks for backwards compat 2016-12-10 22:46:19 +01:00
drm_dumb_buffers.c drm: Consolidate dumb buffer docs 2016-11-15 12:51:49 +01:00
drm_edid.c Merge tag 'drm-misc-next-2016-11-29' of git://anongit.freedesktop.org/git/drm-misc into drm-next 2016-11-30 14:28:20 +10:00
drm_edid_load.c
drm_encoder.c drm: Fix locking cargo-cult in encoder/plane init/cleanup 2016-11-29 23:34:36 +01:00
drm_encoder_slave.c
drm_fb_cma_helper.c drm/fb_cma_helper: Add drm_fb_cma_prepare_fb() helper 2016-11-14 12:43:58 +01:00
drm_fb_helper.c drm: Protect fb_helper list manipulation with a mutex 2016-11-29 15:52:32 -05:00
drm_flip_work.c
drm_fops.c drm: define drm_compat_ioctl NULL on CONFIG_COMPAT=n and reduce #ifdefs 2016-11-02 11:33:47 -04:00
drm_fourcc.c drm: move allocation out of drm_get_format_name() 2016-11-12 14:19:38 +01:00
drm_framebuffer.c drm: Nuke modifier[1-3] 2016-11-17 11:58:09 +01:00
drm_gem.c
drm_gem_cma_helper.c
drm_global.c
drm_hashtab.c
drm_info.c
drm_internal.h drm: drm_irq.h header cleanup 2016-11-15 23:33:48 +01:00
drm_ioc32.c
drm_ioctl.c drm: Allow CAP_PRIME on !MODESET 2016-12-08 10:00:15 +01:00
drm_irq.c drm/irq: Unexport drm_vblank_on/off 2016-11-15 23:33:48 +01:00
drm_kms_helper_common.c
drm_legacy.h
drm_lock.c drm: Avoid NULL dereference for DRM_LEGACY debug message 2016-11-28 08:39:41 +01:00
drm_memory.c
drm_mipi_dsi.c
drm_mm.c drm: Initialise drm_mm.head_node.allocated 2016-12-01 10:35:45 +01:00
drm_mode_config.c drm/fence: add out-fences support 2016-11-16 14:36:27 +01:00
drm_mode_object.c
drm_modes.c drm: Fix broken VT switch with video=1366x768 option 2017-01-11 18:46:07 +02:00
drm_modeset_helper.c drm: also move DSI panels to the front of the connector list 2016-11-17 11:59:26 +01:00
drm_modeset_lock.c drm/doc: Fix indenting in drm_modeset_lock.c comment 2016-11-29 23:34:36 +01:00
drm_of.c drm: convert DT component matching to component_match_add_release() 2016-10-25 11:52:38 -04:00
drm_panel.c
drm_pci.c
drm_plane.c Merge tag 'drm-misc-next-2016-12-08' of git://anongit.freedesktop.org/git/drm-misc into drm-next 2016-12-09 12:29:10 +10:00
drm_plane_helper.c drm: add helpers to go from plane state to drm_rect 2016-11-08 16:38:03 -05:00
drm_platform.c
drm_prime.c drm: Take ownership of the dmabuf->obj when exporting 2016-12-08 10:29:22 +01:00
drm_print.c drm/print: Move kerneldoc next to definition 2016-11-15 12:55:24 +01:00
drm_probe_helper.c Revert "drm/probe-helpers: Drop locking from poll_enable" 2017-01-26 06:44:03 +10:00
drm_property.c drm: Use u64_to_user_ptr() helper for blob ioctls 2016-11-28 08:12:18 +01:00
drm_rect.c drm: helper macros to print composite types 2016-11-08 16:38:03 -05:00
drm_scatter.c
drm_simple_kms_helper.c
drm_sysfs.c
drm_trace.h
drm_trace_points.c
drm_vm.c mm: use vmf->address instead of of vmf->virtual_address 2016-12-14 16:04:09 -08:00
drm_vma_manager.c