android_kernel_oneplus_msm8998/drivers/gpu/drm
Chris Wilson 1b3ec39d3b drm: Defer disabling the vblank IRQ until the next interrupt (for instant-off)
[ Upstream commit 608b20506941969ea30d8c08dc9ae02bb87dbf7d ]

On vblank instant-off systems, we can get into a situation where the cost
of enabling and disabling the vblank IRQ around a drmWaitVblank query
dominates. And with the advent of even deeper hardware sleep state,
touching registers becomes ever more expensive.  However, we know that if
the user wants the current vblank counter, they are also very likely to
immediately queue a vblank wait and so we can keep the interrupt around
and only turn it off if we have no further vblank requests queued within
the interrupt interval.

After vblank event delivery, this patch adds a shadow of one vblank where
the interrupt is kept alive for the user to query and queue another vblank
event. Similarly, if the user is using blocking drmWaitVblanks, the
interrupt will be disabled on the IRQ following the wait completion.
However, if the user is simply querying the current vblank counter and
timestamp, the interrupt will be disabled after every IRQ and the user
will enabled it again on the first query following the IRQ.

v2: Mario Kleiner -
After testing this, one more thing that would make sense is to move
the disable block at the end of drm_handle_vblank() instead of at the
top.

Turns out that if high precision timestaming is disabled or doesn't
work for some reason (as can be simulated by echo 0 >
/sys/module/drm/parameters/timestamp_precision_usec), then with your
delayed disable code at its current place, the vblank counter won't
increment anymore at all for instant queries, ie. with your other
"instant query" patches. Clients which repeatedly query the counter
and wait for it to progress will simply hang, spinning in an endless
query loop. There's that comment in vblank_disable_and_save:

"* Skip this step if there isn't any high precision timestamp
 * available. In that case we can't account for this and just
 * hope for the best.
 */

With the disable happening after leading edge of vblank (== hw counter
increment already happened) but before the vblank counter/timestamp
handling in drm_handle_vblank, that step is needed to keep the counter
progressing, so skipping it is bad.

Now without high precision timestamping support, a kms driver must not
set dev->vblank_disable_immediate = true, as this would cause problems
for clients, so this shouldn't matter, but it would be good to still
make this robust against a future kms driver which might have
unreliable high precision timestamping, e.g., high precision
timestamping that intermittently doesn't work.

v3: Patch before coffee needs extra coffee.

Testcase: igt/kms_vblank
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Michel Dänzer <michel@daenzer.net>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Dave Airlie <airlied@redhat.com>,
Cc: Mario Kleiner <mario.kleiner.de@gmail.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20170315204027.20160-1-chris@chris-wilson.co.uk
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-22 09:23:20 +01:00
..
amd drm/amdgpu: fix KV harvesting 2018-03-18 11:17:49 +01:00
armada drm/armada: fix leak of crtc structure 2018-02-25 11:03:41 +01:00
ast drm/ast: Handle configuration without P2A bridge 2017-07-05 14:37:15 +02:00
atmel-hlcdc drm: atmel-hlcdc: Fix vertical scaling 2016-09-24 10:07:42 +02:00
bochs
bridge drm/panel: Changes for v4.4-rc1 2015-11-05 11:07:13 +10:00
cirrus
exynos drm/exynos: gem: Drop NONCONTIG flag for buffers allocated without IOMMU 2017-12-16 10:33:49 +01:00
fsl-dcu drm: Stop using drm_vblank_count() as the hw frame counter 2015-10-07 16:13:52 +02:00
gma500 drm/gma500: remove helper function 2018-02-25 11:03:52 +01:00
i2c drm/bridge: adv7511: Re-write the i2c address before EDID probing 2017-09-13 14:09:46 -07:00
i810
i915 drm/i915: Prevent zero length "index" write 2017-12-05 11:22:52 +01:00
imx drm/imx: Match imx-ipuv3-crtc components using device node in platform data 2016-06-07 18:14:37 -07:00
mga drm/irq: Use unsigned int pipe in public API 2015-10-06 12:57:47 +02:00
mgag200 gpu: drm: mgag200: mgag200_main:- Handle error from pci_iomap 2017-11-21 09:21:21 +01:00
msm drm/msm: fix an integer overflow test 2017-11-08 10:06:28 +01:00
nouveau drm/nouveau: Fix deadlock on runtime suspend 2018-03-18 11:17:48 +01:00
omapdrm drm/omap: Fix error handling path in 'omap_dmm_probe()' 2018-02-03 17:04:29 +01:00
panel drm/panel: simple: Add missing panel_simple_unprepare() calls 2017-12-05 11:22:51 +01:00
qxl drm: qxl: Don't alloc fbdev if emulation is not supported 2018-03-22 09:23:19 +01:00
r128 drm/irq: Use unsigned int pipe in public API 2015-10-06 12:57:47 +02:00
radeon drm/radeon: fix KV harvesting 2018-03-18 11:17:49 +01:00
rcar-du drm: rcar-du: Fix race condition when disabling planes at CRTC stop 2018-02-16 20:09:37 +01:00
rockchip drm/rockchip: Use CRTC vblank event interface 2015-12-02 10:22:21 +08:00
savage
shmobile drm: Stop using drm_vblank_count() as the hw frame counter 2015-10-07 16:13:52 +02:00
sis include/uapi/drm/sis_drm.h: move sis_file_private to drivers/gpu/drm/sis/sis_drv.h 2015-10-16 11:27:46 +10:00
sti drm/sti: sti_vtg: Handle return NULL error from devm_ioremap_nocache 2017-11-21 09:21:19 +01:00
tdfx
tegra Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux 2015-11-10 09:33:06 -08:00
tilcdc drm: Stop using drm_vblank_count() as the hw frame counter 2015-10-07 16:13:52 +02:00
ttm drm/ttm: check the return value of kzalloc 2018-03-03 10:19:44 +01:00
udl drm/udl: Use unlocked gem unreferencing 2016-04-20 15:41:55 +09:00
vc4 drm/vc4: Make sure that planes aren't scaled. 2015-11-17 12:27:03 -08:00
vgem drm/vgem: Drop vgem_drm_gem_mmap 2015-10-19 11:00:44 +02:00
via via_drm.h: move struct via_file_private definition to drivers/gpu/drm/via/via_drv.h 2015-10-16 11:27:49 +10:00
virtio drm/virtio: fix framebuffer sparse warning 2017-08-11 09:08:58 -07:00
vmwgfx drm/vmwgfx: use *_32_bits() macros 2018-02-25 11:03:48 +01:00
ati_pcigart.c
drm_agpsupport.c drm: Remove __OS_HAS_AGP 2015-09-30 10:44:48 +02:00
drm_atomic.c drm/atomic: If the atomic check fails, return its value first 2017-08-30 10:19:23 +02:00
drm_atomic_helper.c drm/atomic: fix an error code in mode_fixup() 2017-03-15 09:57:15 +08:00
drm_auth.c
drm_bridge.c
drm_bufs.c drm: Remove __OS_HAS_AGP 2015-09-30 10:44:48 +02:00
drm_cache.c drm: Restore double clflush on the last partial cacheline 2016-08-20 18:09:23 +02:00
drm_context.c
drm_crtc.c drm: Reject page_flip for !DRIVER_MODESET 2016-09-15 08:27:51 +02:00
drm_crtc_helper.c
drm_crtc_internal.h
drm_debugfs.c
drm_dma.c
drm_dp_helper.c drm/dp: move hw_mutex up the call stack 2016-04-20 15:41:55 +09:00
drm_dp_mst_topology.c drm/dp/mst: save vcpi with payloads 2017-10-21 17:09:01 +02:00
drm_drv.c drm: drm_minor_register(): Clean up debugfs on failure 2017-11-15 17:13:09 +01:00
drm_edid.c drm/edid: Add 6 bpc quirk for CPT panel in Asus UX303LA 2018-02-28 10:17:23 +01:00
drm_edid_load.c
drm_encoder_slave.c
drm_fb_cma_helper.c
drm_fb_helper.c drm/fb_helper: Fix references to dev->mode_config.num_connector 2016-06-07 18:14:36 -07:00
drm_flip_work.c
drm_fops.c drm: Fix an unwanted master inheritance v2 2015-12-04 12:28:14 +10:00
drm_gem.c drm: Release driver tracking before making the object available again 2017-08-30 10:19:23 +02:00
drm_gem_cma_helper.c Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux 2015-11-10 09:33:06 -08:00
drm_global.c
drm_hashtab.c
drm_info.c
drm_internal.h
drm_ioc32.c drm: Only use compat ioctl for addfb2 on X86/IA64 2016-09-24 10:07:43 +02:00
drm_ioctl.c drm: Enforce unlocked ioctl operation for kms driver ioctls 2015-10-16 15:50:54 +02:00
drm_irq.c drm: Defer disabling the vblank IRQ until the next interrupt (for instant-off) 2018-03-22 09:23:20 +01:00
drm_legacy.h
drm_lock.c signals: kill block_all_signals() and unblock_all_signals() 2015-11-06 17:50:42 -08:00
drm_memory.c drm: Remove __OS_HAS_AGP 2015-09-30 10:44:48 +02:00
drm_mipi_dsi.c
drm_mm.c drm: Apply range restriction after color adjustment when allocation 2017-11-30 08:37:27 +00:00
drm_modes.c drm: Fix broken VT switch with video=1366x768 option 2017-02-01 08:30:52 +01:00
drm_modeset_lock.c drm: Require __GFP_NOFAIL for the legacy drm_modeset_lock_all 2018-02-25 11:03:35 +01:00
drm_of.c drm: Introduce generic probe function for component based masters. 2015-10-20 12:01:29 +02:00
drm_panel.c
drm_pci.c
drm_plane_helper.c
drm_platform.c
drm_prime.c drm/prime: Pass the right module owner through to dma_buf_export() 2016-10-31 04:13:57 -06:00
drm_probe_helper.c drm: Allow determining if current task is output poll worker 2018-03-18 11:17:48 +01:00
drm_rect.c drm: Use DRM_ROTATE_MASK and DRM_REFLECT_MASK 2015-10-05 15:32:51 +02:00
drm_scatter.c
drm_sysfs.c Merge commit '06d1ee32a4d25356a710b49d5e95dbdd68bdf505' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux into drm-next 2015-10-16 10:25:28 +10:00
drm_trace.h
drm_trace_points.c
drm_vm.c drm: Remove __OS_HAS_AGP 2015-09-30 10:44:48 +02:00
drm_vma_manager.c drm/gem: Use kref_get_unless_zero for the weak mmap references 2015-10-19 11:00:44 +02:00
Kconfig drm/vc4: Add KMS support for Raspberry Pi. 2015-10-21 10:33:12 +01:00
Makefile Merge tag 'drm-vc4-next-2015-10-21' of http://github.com/anholt/linux into drm-next 2015-10-22 10:31:17 +10:00