linux/drivers/gpu/drm/i915
Chris Wilson 172ae5b4c8 drm/i915: Fix i915_gem_evict_for_vma (soft-pinning)
Soft-pinning depends upon being able to check for availabilty of an
interval and evict overlapping object from a drm_mm range manager very
quickly. Currently it uses a linear list, and so performance is dire and
not suitable as a general replacement. Worse, the current code will oops
if it tries to evict an active buffer.

It also helps if the routine reports the correct error codes as expected
by its callers and emits a tracepoint upon use.

For posterity since the wrong patch was pushed (i.e. that missed these
key points and had known bugs), this is the changelog that should have
been on commit 506a8e87d8 ("drm/i915: Add soft-pinning API for
execbuffer"):

Userspace can pass in an offset that it presumes the object is located
at. The kernel will then do its utmost to fit the object into that
location. The assumption is that userspace is handling its own object
locations (for example along with full-ppgtt) and that the kernel will
rarely have to make space for the user's requests.

This extends the DRM_IOCTL_I915_GEM_EXECBUFFER2 to do the following:
* if the user supplies a virtual address via the execobject->offset
  *and* sets the EXEC_OBJECT_PINNED flag in execobject->flags, then
  that object is placed at that offset in the address space selected
  by the context specifier in execbuffer.
* the location must be aligned to the GTT page size, 4096 bytes
* as the object is placed exactly as specified, it may be used by this
  execbuffer call without relocations pointing to it

It may fail to do so if:
* EINVAL is returned if the object does not have a 4096 byte aligned
  address
* the object conflicts with another pinned object (either pinned by
  hardware in that address space, e.g. scanouts in the aliasing ppgtt)
  or within the same batch.
  EBUSY is returned if the location is pinned by hardware
  EINVAL is returned if the location is already in use by the batch
* EINVAL is returned if the object conflicts with its own alignment (as meets
  the hardware requirements) or if the placement of the object does not fit
  within the address space

All other execbuffer errors apply.

Presence of this execbuf extension may be queried by passing
I915_PARAM_HAS_EXEC_SOFTPIN to DRM_IOCTL_I915_GETPARAM and checking for
a reported value of 1 (or greater).

v2: Combine the hole/adjusted-hole ENOSPC checks
v3: More color, more splitting, more blurb.

Fixes: 506a8e87d8 ("drm/i915: Add soft-pinning API for execbuffer")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20161205142941.21965-2-chris@chris-wilson.co.uk
2016-12-05 20:49:17 +00:00
..
gvt drm/i915: Mark all non-vma being inserted into the address spaces 2016-12-05 20:49:17 +00:00
Kconfig drm/i915: rename preliminary_hw_support to alpha_support 2016-11-14 15:33:27 +02:00
Kconfig.debug drm/i915: Add I2C and DP-AUX char devices to debug kconfig 2016-12-05 13:17:34 +02:00
Makefile drm/i915/guc: Move guc_{send,recv}() to intel_uc.c 2016-11-25 21:42:32 +00:00
dvo.h
dvo_ch7xxx.c
dvo_ch7017.c
dvo_ivch.c
dvo_ns2501.c
dvo_sil164.c
dvo_tfp410.c
i915_cmd_parser.c drm/i915: Use the precomputed value for whether to enable command parsing 2016-11-24 13:52:34 +00:00
i915_debugfs.c Merge remote-tracking branch 'airlied/drm-next' into drm-intel-next-queued 2016-12-05 09:52:17 +01:00
i915_drv.c drm/i915: make i915_suspend_switcheroo static 2016-12-02 11:26:51 +00:00
i915_drv.h drm/i915: Fix i915_gem_evict_for_vma (soft-pinning) 2016-12-05 20:49:17 +00:00
i915_gem.c drm/i915: Mark all non-vma being inserted into the address spaces 2016-12-05 20:49:17 +00:00
i915_gem.h drm/i915: avoid harmless empty-body warning 2016-11-08 17:33:47 +01:00
i915_gem_batch_pool.c drm/i915: Move GEM activity tracking into a common struct reservation_object 2016-10-28 20:53:50 +01:00
i915_gem_batch_pool.h drm/i915: Double check the active status on the batch pool 2016-08-04 20:19:50 +01:00
i915_gem_context.c drm/i915: More GEM init dev_priv cleanup 2016-12-01 18:01:16 +00:00
i915_gem_dmabuf.c drm/i915: Make GEM object alloc/free and stolen created take dev_priv 2016-12-01 18:00:15 +00:00
i915_gem_evict.c drm/i915: Fix i915_gem_evict_for_vma (soft-pinning) 2016-12-05 20:49:17 +00:00
i915_gem_execbuffer.c drm/i915: Fix i915_gem_evict_for_vma (soft-pinning) 2016-12-05 20:49:17 +00:00
i915_gem_fence_reg.c drm/i915: Convert vm->dev backpointer to vm->i915 2016-11-29 11:38:00 +00:00
i915_gem_fence_reg.h drm/i915: Split out i915_vma.c 2016-11-11 14:34:54 +02:00
i915_gem_gtt.c drm/i915: Mark all non-vma being inserted into the address spaces 2016-12-05 20:49:17 +00:00
i915_gem_gtt.h drm/i915: Convert vm->dev backpointer to vm->i915 2016-11-29 11:38:00 +00:00
i915_gem_internal.c drm/i915: Make GEM object alloc/free and stolen created take dev_priv 2016-12-01 18:00:15 +00:00
i915_gem_object.h drm/i915: Move frontbuffer CS write tracking from ggtt vma to object 2016-11-18 11:15:59 +00:00
i915_gem_render_state.c drm/i915: Introduce HAS_64BIT_RELOC 2016-11-03 12:45:57 +02:00
i915_gem_render_state.h drm/i915: Reuse the active golden render state batch 2016-10-28 20:53:44 +01:00
i915_gem_request.c drm/i915: Integrate i915_sw_fence with debugobjects 2016-11-25 13:49:26 +00:00
i915_gem_request.h drm/i915/scheduler: Execute requests in order of priorities 2016-11-14 21:01:21 +00:00
i915_gem_shrinker.c drm/i915: Unify global_list into global_link 2016-11-02 15:17:13 +02:00
i915_gem_stolen.c drm/i915: Make GEM object alloc/free and stolen created take dev_priv 2016-12-01 18:00:15 +00:00
i915_gem_tiling.c drm/i915: Convert vm->dev backpointer to vm->i915 2016-11-29 11:38:00 +00:00
i915_gem_timeline.c drm/i915: Create distinct lockclasses for execution vs user timelines 2016-11-14 21:00:21 +00:00
i915_gem_timeline.h drm/i915: Rename i915_gem_timeline.next_seqno to .seqno 2016-11-25 07:01:11 +00:00
i915_gem_userptr.c drm/i915: Make GEM object alloc/free and stolen created take dev_priv 2016-12-01 18:00:15 +00:00
i915_gpu_error.c drm/i915: Make i915_destroy_error_state take dev_priv 2016-12-01 18:01:23 +00:00
i915_guc_reg.h drm/i915/guc: Drop guc2host/host2guc from names 2016-11-25 21:28:57 +00:00
i915_guc_submission.c drm/i915: Make various init functions take dev_priv 2016-12-01 18:01:15 +00:00
i915_ioc32.c
i915_irq.c drm/i915/glk: Reuse broxton code for geminilake 2016-12-02 16:38:56 +02:00
i915_memcpy.c drm/i915: Mark the static key for movntqda as static 2016-08-17 12:36:07 +01:00
i915_mm.c drm/i915: Use remap_io_mapping() to prefault all PTE in a single pass 2016-08-19 17:13:36 +01:00
i915_oa_hsw.c drm/i915: Add more Haswell OA metric sets 2016-11-22 14:40:00 +01:00
i915_oa_hsw.h drm/i915: advertise available metrics via sysfs 2016-11-22 14:38:51 +01:00
i915_params.c drm/i915: Use the precomputed value for whether to enable command parsing 2016-11-24 13:52:34 +00:00
i915_params.h drm/i915: Use the precomputed value for whether to enable command parsing 2016-11-24 13:52:34 +00:00
i915_pci.c drm/i915/glk: Add a IS_GEN9_LP() macro 2016-12-01 13:41:27 +02:00
i915_perf.c drm/i915: Make GEM object create and create from data take dev_priv 2016-12-01 18:01:08 +00:00
i915_pvinfo.h
i915_reg.h drm/i915/glk: Update Port PLL enable sequence for Geminilkae 2016-12-02 16:41:47 +02:00
i915_suspend.c drm/i915: Make i915_save/restore_state and intel_i2c_reset take dev_priv 2016-12-01 18:01:23 +00:00
i915_sw_fence.c drm/i915: Integrate i915_sw_fence with debugobjects 2016-11-25 13:49:26 +00:00
i915_sw_fence.h drm/i915: Integrate i915_sw_fence with debugobjects 2016-11-25 13:49:26 +00:00
i915_sysfs.c drm/i915: Make i915_destroy_error_state take dev_priv 2016-12-01 18:01:23 +00:00
i915_trace.h drm/i915: Fix i915_gem_evict_for_vma (soft-pinning) 2016-12-05 20:49:17 +00:00
i915_trace_points.c
i915_vgpu.c Merge tag 'drm-intel-next-2016-09-19' of git://anongit.freedesktop.org/drm-intel into drm-next 2016-09-20 06:23:22 +10:00
i915_vgpu.h
i915_vma.c drm/i915: Fix i915_gem_evict_for_vma (soft-pinning) 2016-12-05 20:49:17 +00:00
i915_vma.h drm/i915: Convert vm->dev backpointer to vm->i915 2016-11-29 11:38:00 +00:00
intel_acpi.c
intel_atomic.c
intel_atomic_plane.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
intel_audio.c drm/i915/audio: extend audio sync rate support for DP MST 2016-12-02 16:20:48 +02:00
intel_bios.c drm/i915/glk: Reuse broxton code for geminilake 2016-12-02 16:38:56 +02:00
intel_bios.h
intel_breadcrumbs.c drm/i915: Add a warning on shutdown if signal threads still active 2016-11-21 11:49:06 +00:00
intel_color.c drm/i915: Assorted INTEL_INFO(dev) cleanups 2016-11-17 13:56:35 +00:00
intel_crt.c drm/i915: Pass dev_priv to intel_setup_outputs() 2016-11-25 16:43:24 +02:00
intel_csr.c drm/i915: fix compilation warnings on maybe uninitialized pointers 2016-11-29 11:31:01 +01:00
intel_ddi.c drm/i915/glk: Reuse broxton code for geminilake 2016-12-02 16:38:56 +02:00
intel_device_info.c drm/i915/glk: Configure number of sprite planes properly 2016-12-02 16:42:36 +02:00
intel_display.c drm/i915: Skip vblank wait if cxsr was already off 2016-12-05 16:23:27 +02:00
intel_dp.c drm/i915: Validate mode against max. link data rate for DP MST 2016-12-05 16:23:18 +02:00
intel_dp_aux_backlight.c
intel_dp_link_training.c drm/i915/skl: drop workarounds for A0 and B0 revisions 2016-09-26 12:08:22 +03:00
intel_dp_mst.c drm/i915: Validate mode against max. link data rate for DP MST 2016-12-05 16:23:18 +02:00
intel_dpio_phy.c drm/i915: Only poll DW3_A when init DDI PHY for ports B and C. 2016-12-02 12:16:25 -08:00
intel_dpll_mgr.c drm/i915/glk: Update Port PLL enable sequence for Geminilkae 2016-12-02 16:41:47 +02:00
intel_dpll_mgr.h drm/i915/dp: Add a standalone function to obtain shared dpll for HSW/BDW/SKL/BXT 2016-09-09 14:53:18 -07:00
intel_drv.h drm/i915: Validate mode against max. link data rate for DP MST 2016-12-05 16:23:18 +02:00
intel_dsi.c drm/i915/glk: Reuse broxton code for geminilake 2016-12-02 16:38:56 +02:00
intel_dsi.h
intel_dsi_dcs_backlight.c drm/i915: Mass convert dev->dev_private to to_i915(dev) 2016-07-04 12:54:07 +01:00
intel_dsi_panel_vbt.c drm/i915: Introduce enableddisabled helper 2016-11-17 15:00:36 +00:00
intel_dsi_pll.c drm/i915/glk: Reuse broxton code for geminilake 2016-12-02 16:38:56 +02:00
intel_dvo.c drm/i915: Pass dev_priv to intel_setup_outputs() 2016-11-25 16:43:24 +02:00
intel_engine_cs.c drm/i915: Make various init functions take dev_priv 2016-12-01 18:01:15 +00:00
intel_fbc.c drm/i915/fbc: convert intel_fbc.c to use INTEL_GEN() 2016-11-14 14:00:29 -02:00
intel_fbdev.c Merge remote-tracking branch 'airlied/drm-next' into drm-intel-next-queued 2016-12-05 09:52:17 +01:00
intel_fifo_underrun.c drm/i915: Always use intel_get_crtc_for_pipe() 2016-11-01 16:40:38 +02:00
intel_frontbuffer.c drm/i915: Use dev_priv consistently through the intel_frontbuffer interface 2016-08-04 20:20:03 +01:00
intel_frontbuffer.h drm/i915: Move frontbuffer CS write tracking from ggtt vma to object 2016-11-18 11:15:59 +00:00
intel_guc_fwif.h drm/i915/guc: Drop guc2host/host2guc from names 2016-11-25 21:28:57 +00:00
intel_guc_loader.c drm/i915: Fix kerneldoc for intel_guc_fini 2016-12-02 09:55:46 +00:00
intel_gvt.c Documentation/gpu: Add section for Intel GVT-g host support 2016-10-20 17:18:39 +08:00
intel_gvt.h drm/i915/gvt: clean up intel_gvt.h as interface for i915 core 2016-10-20 17:18:30 +08:00
intel_hangcheck.c drm/i915: Disable hangcheck when wedged 2016-11-22 17:42:17 +00:00
intel_hdmi.c drm/i915/glk: Reuse broxton code for geminilake 2016-12-02 16:38:56 +02:00
intel_hotplug.c drm/i915: More assorted dev_priv cleanups 2016-11-11 14:58:26 +00:00
intel_i2c.c drm/i915/glk: Reuse broxton code for geminilake 2016-12-02 16:38:56 +02:00
intel_lrc.c drm/i915: Make GEM object create and create from data take dev_priv 2016-12-01 18:01:08 +00:00
intel_lrc.h drm/i915: Make various init functions take dev_priv 2016-12-01 18:01:15 +00:00
intel_lspcon.c drm/i915/lspcon: Remove unused force change mode parameter 2016-11-23 13:32:01 +02:00
intel_lvds.c drm/i915: Pass dev_priv to intel_setup_outputs() 2016-11-25 16:43:24 +02:00
intel_mocs.c drm/i915/glk: Reuse broxton code for geminilake 2016-12-02 16:38:56 +02:00
intel_mocs.h drm/i915: Make various init functions take dev_priv 2016-12-01 18:01:15 +00:00
intel_modes.c drm: Remove superflous linux/fb.h includes 2016-08-12 10:41:39 +02:00
intel_opregion.c drm/i915/opregion: fill in the CADL from connector list, not DIDL 2016-11-17 12:45:59 +02:00
intel_overlay.c drm/i915: Make GEM object create and create from data take dev_priv 2016-12-01 18:01:08 +00:00
intel_panel.c drm/i915/glk: Reuse broxton code for geminilake 2016-12-02 16:38:56 +02:00
intel_pm.c drm/i915: Pass crtc state to vlv_compute_wm_level() 2016-12-05 16:23:28 +02:00
intel_psr.c drm/i915: Fix intel_psr_init() kerneldoc 2016-12-02 09:54:05 +02:00
intel_renderstate.h drm/i915: Remove duplicate golden render state init from execlists 2016-08-02 22:58:30 +01:00
intel_renderstate_gen6.c
intel_renderstate_gen7.c
intel_renderstate_gen8.c
intel_renderstate_gen9.c
intel_ringbuffer.c drm/i915: Make GEM object create and create from data take dev_priv 2016-12-01 18:01:08 +00:00
intel_ringbuffer.h drm/i915: Decouple hang detection from hangcheck period 2016-11-21 14:36:40 +02:00
intel_runtime_pm.c drm/i915/dsi: Do not clear DPOUNIT_CLOCK_GATE_DISABLE from vlv_init_display_clock_gating 2016-12-05 20:45:58 +02:00
intel_sdvo.c drm/i915: Pass dev_priv to intel_setup_outputs() 2016-11-25 16:43:24 +02:00
intel_sdvo_regs.h
intel_sideband.c drm/i915: Convert wait_for(I915_READ(reg)) to intel_wait_for_register() 2016-06-30 15:42:33 +01:00
intel_sprite.c Merge remote-tracking branch 'airlied/drm-next' into drm-intel-next-queued 2016-12-05 09:52:17 +01:00
intel_tv.c drm/i915: Pass dev_priv to intel_setup_outputs() 2016-11-25 16:43:24 +02:00
intel_uc.c drm/i915/guc: Init send_mutex in intel_uc_init_early() 2016-11-25 21:42:36 +00:00
intel_uc.h drm/i915: Make various init functions take dev_priv 2016-12-01 18:01:15 +00:00
intel_uncore.c drm/i915: Don't sanitize has_decoupled_mmio if platform is not broxton 2016-11-25 16:43:45 +02:00
intel_vbt_defs.h drm/i915: Assume non-DP++ port if dvo_port is HDMI and there's no AUX ch specified in the VBT 2016-11-16 10:06:14 +02:00