1. 08 7月, 2014 1 次提交
  2. 07 7月, 2014 1 次提交
    • V
      drm/i915: Unpin last_context at reset · 4bfad3dd
      Ville Syrjälä 提交于
      We're forgetting to unpin the last_context from the ggtt at GPU reset
      time. This leads to the vma pin_count leaking at every reset if the
      last context wasn't the ring default context. Further use of the same
      context will trigger the pin_count check in i915_gem_object_pin() and
      userspace will be faced with EBUSY as a result.
      
      This plaques kms_flip rather badly since it performs lots of resets,
      and every fd has its own default context these days.
      
      Fix the problem by properly unpinning the last context at reset.
      
      This regression seems to back to
      
      commit acce9ffa
      Author: Ben Widawsky <ben@bwidawsk.net>
      Date:   Fri Dec 6 14:11:03 2013 -0800
      
         drm/i915: Better reset handling for contexts
      
      Testcase: igt/gem_ctx_exec/reset-pin-leak
      Signed-off-by: NVille Syrjälä <ville.syrjala@linux.intel.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      4bfad3dd
  3. 24 6月, 2014 1 次提交
  4. 19 6月, 2014 1 次提交
    • O
      drm/i915: Remove ctx->last_ring · 14d8ec54
      Oscar Mateo 提交于
      The original comment that introduced it said:
      
      commit 0009e46c
      Author: Ben Widawsky <ben@bwidawsk.net>
      Date:   Fri Dec 6 14:11:02 2013 -0800
      
          drm/i915: Track which ring a context ran on
      
          Previously we dropped the association of a context to a ring. It is
          however very important to know which ring a context ran on (we could
          have reused the other member, but I was nitpicky).
      
          This is very important when we switch address spaces, which unlike
          context objects, do change per ring.
      
          As an example, if we have:
      
                  RCS   BCS
          ctx            A
          ctx      A
          ctx      B
          ctx            B
      
          Without tracking the last ring B ran on, we wouldn't know to switch the
          address space on BCS in the last row.
      
      But this is not really true, because we are already checking to != from (with
      "from" being = ring->last_context) and that should be enough to make sure we
      switch to the right address space.
      
      We would have a problem if we switched the context object for every ring (since
      then we would fail to do it in some situations) but we only switch it for the
      render ring, so we don't care.
      Signed-off-by: NOscar Mateo <oscar.mateo@intel.com>
      Reviewed-by: NChris Wilson <chris@chris-wilson.co.uk>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      14d8ec54
  5. 23 5月, 2014 3 次提交
  6. 22 5月, 2014 1 次提交
    • M
      drm/i915: Add null state batch to active list · 46470fc9
      Mika Kuoppala 提交于
      for proper refcounting to take place as we use
      i915_add_request() for it.
      
      i915_add_request() also takes the context for the request
      from ring->last_context so move the null state batch
      submission after the ring context has been set.
      
      v2: we need to check for correct ring now (Ville Syrjälä)
      v3: no need to expose i915_gem_move_object_to_active (Chris Wilson)
      v4: cargoculted vma/active/inactive error handling removed (Chris Wilson)
      
      Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
      Cc: Chris Wilson <chris@chris-wilson.co.uk>
      Cc: Damien Lespiau <damien.lespiau@intel.com>
      Signed-off-by: NMika Kuoppala <mika.kuoppala@intel.com>
      Reviewed-by: NChris Wilson <chris@chris-wilson.co.uk>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      46470fc9
  7. 20 5月, 2014 1 次提交
  8. 17 5月, 2014 1 次提交
  9. 15 5月, 2014 1 次提交
  10. 11 4月, 2014 1 次提交
  11. 09 4月, 2014 1 次提交
  12. 03 4月, 2014 1 次提交
    • B
      drm/i915: Invariably invalidate before ctx switch · 057f6a8a
      Ben Widawsky 提交于
      We have been setting the bit which was originally BIOS dependent since:
      commit f05bb0c7
      Author: Chris Wilson <chris@chris-wilson.co.uk>
      Date:   Sun Jan 20 16:33:32 2013 +0000
      
          drm/i915: GFX_MODE Flush TLB Invalidate Mode must be '1' for scanline waits
      
      Therefore, we do not need to try to figure it out dynamically and we can
      just always invalidate the TLBs.
      
      It's a partial revert of:
      commit 12b0286f
      Author: Ben Widawsky <ben@bwidawsk.net>
      Date:   Mon Jun 4 14:42:50 2012 -0700
      
          drm/i915: possibly invalidate TLB before context switch
      
      The original commit attempted to only invalidate when necessary
      (very much a relic from the old days). Now, we can just always invalidate.
      
      I guess the old TODO still exists. Since we seem to have abandoned ILK
      contexts however, there isn't much point in even remembering.
      
      Cc: Chris Wilson <chris@chris-wilson.co.uk>
      Signed-off-by: NBen Widawsky <ben@bwidawsk.net>
      Reviewed-by: NChris Wilson <chris@chris-wilson.co.uk>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      057f6a8a
  13. 02 4月, 2014 1 次提交
  14. 20 3月, 2014 1 次提交
  15. 18 3月, 2014 1 次提交
    • M
      drm/i915: Switch to fake context on older gens · a95f6a00
      Mika Kuoppala 提交于
      We used to have per file descriptor hang stats for the
      i915_get_reset_stats_ioctl() and for default context banning.
      
      commit 0eea67eb
      Author: Ben Widawsky <ben@bwidawsk.net>
      Date:   Fri Dec 6 14:11:19 2013 -0800
      
          drm/i915: Create a per file_priv default context
      
      made having separate hangstats in file_private redundant
      as i915_hw_context already contained hangstats. So
      
      commit c482972a
      Author: Ben Widawsky <benjamin.widawsky@intel.com>
      Date:   Fri Dec 6 14:11:20 2013 -0800
      
          drm/i915: Piggy back hangstats off of contexts
      
      consolidated the hangstats and enabled further improvements.
      
      commit 44e2c070
      Author: Mika Kuoppala <mika.kuoppala@linux.intel.com>
      Date:   Thu Jan 30 16:01:15 2014 +0200
      
          drm/i915: Use i915_hw_context to set reset stats
      
      tried to reap full benefits of consolidation but fell short
      as we never 'switch' to the fake private context on gens
      that don't have hw_contexts, so request->ctx remained NULL
      on those.
      
      Fix this by 'switching' to fake context so that when
      request is submitted to ring, proper context gets assigned
      to it.
      
      Testcase: igt/drv_hangman
      Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=76055Signed-off-by: NMika Kuoppala <mika.kuoppala@intel.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      a95f6a00
  16. 06 3月, 2014 1 次提交
  17. 04 3月, 2014 3 次提交
  18. 14 2月, 2014 1 次提交
    • D
      drm/i915: Consolidate binding parameters into flags · 1ec9e26d
      Daniel Vetter 提交于
      Anything more than just one bool parameter is just a pain to read,
      symbolic constants are much better.
      
      Split out from Chris' vma-binding rework patch.
      
      v2: Undo the behaviour change in object_pin that Chris spotted.
      
      v3: Split out misplaced hunk to handle set_cache_level errors,
      spotted by Jani.
      
      v4: Keep the current over-zealous binding logic in the execbuffer code
      working with a quick hack while the overall binding code gets shuffled
      around.
      
      v5: Reorder the PIN_ flags for more natural patch splitup.
      
      v6: Pull out the PIN_GLOBAL split-up again.
      
      Cc: Chris Wilson <chris@chris-wilson.co.uk>
      Cc: Ben Widawsky <benjamin.widawsky@intel.com>
      Reviewed-by: NChris Wilson <chris@chris-wilson.co.uk>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      1ec9e26d
  19. 04 2月, 2014 1 次提交
  20. 31 1月, 2014 1 次提交
  21. 28 1月, 2014 3 次提交
    • B
      drm/i915: Create a USES_PPGTT macro · c5dc5cec
      Ben Widawsky 提交于
      There are cases where we want to know if there is a full, or aliased
      PPGTT. Currently, in fact the only distinction we ever need to make is
      when we're using full PPGTT.
      
      This patch is simply to promote readability and clarify for the
      confusing existing usage where "aliasing" meant aliasing and full.
      
      v2: Remove USES_ALIASING_PPGTT since there are currently no cases where
      we need to check if we're using aliasing, but not full PPGTT. (Daniel)
      
      Cc: Daniel Vetter <daniel@ffwll.ch>
      Signed-off-by: NBen Widawsky <ben@bwidawsk.net>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      c5dc5cec
    • V
      drm/i915: We implement WaMiSetContext_Hang · 2b7e8082
      Ville Syrjälä 提交于
      WaMiSetContext_Hang tells us that a MI_NOOP must follow MI_SET_CONTEXT.
      
      The other thing WaMiSetContext_Hang seems to say is that URB_FENCE isn't
      allowed to straddle two cachelines. But we don't issue those from the
      kernel so we don't care.
      Signed-off-by: NVille Syrjälä <ville.syrjala@linux.intel.com>
      Reviewed-by: NRodrigo Vivi <rodrigo.vivi@gmail.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      2b7e8082
    • C
      drm/i915: Always pin the default context · 42c3b603
      Chris Wilson 提交于
      Through a twisty and circuituous path it is possible to currently trick
      the code into creating a default context and forgetting to pin it
      immediately into the GGTT. (This requires a system using contexts without
      an aliasing ppgtt, which is currently restricted to Baytrails machines
      manually specifying a module parameter to force enable contexts, or
      on Sandybridge and later that manually disable the aliasing ppgtt.) The
      consequence is that during module unload we attempt to unpin the default
      context twice and encounter a BUG remonstrating that we attempt to unpin
      an unbound object.
      
      [  161.002869] Kernel BUG at f84861f8 [verbose debug info unavailable]
      [  161.002875] invalid opcode: 0000 [#1] SMP
      [  161.002882] Modules linked in: coretemp kvm_intel kvm crc32_pclmul aesni_intel aes_i586 xts lrw gf128mul ablk_helper cryptd hid_sensor_accel_3d hid_sensor_gyro_3d hid_sensor_magn_3d hid_sensor_trigger industrialio_triggered_buffer kfifo_buf industrialio hid_sensor_iio_common snd_hda_codec_hdmi snd_hda_codec_realtek snd_hda_intel snd_hda_codec snd_hwdep snd_pcm snd_page_alloc snd_seq_midi snd_seq_midi_event dm_multipath scsi_dh asix ppdev usbnet snd_rawmidi mii hid_sensor_hub microcode snd_seq rfcomm bnep snd_seq_device bluetooth snd_timer snd parport_pc binfmt_misc soundcore dw_dmac_pci dw_dmac_core mac_hid lp parport dm_mirror dm_region_hash dm_log hid_generic usbhid hid i915(O-) drm_kms_helper(O) igb dca ptp pps_core i2c_algo_bit drm(O) ahci libahci video
      [  161.002991] CPU: 0 PID: 2114 Comm: rmmod Tainted: G        W  O 3.13.0-rc8+ #2
      [  161.002997] Hardware name: NEXCOM VTC1010/Aptio CRB, BIOS 5.6.5 09/24/2013
      [  161.003004] task: dbdd6800 ti: dbe0e000 task.ti: dbe0e000
      [  161.003010] EIP: 0060:[<f84861f8>] EFLAGS: 00010246 CPU: 0
      [  161.003044] EIP is at i915_gem_object_ggtt_unpin+0x88/0x90 [i915]
      [  161.003050] EAX: dfce3840 EBX: 00000000 ECX: dfafd690 EDX: dfce3874
      [  161.003056] ESI: c0086b40 EDI: df962e00 EBP: dbe0fe1c ESP: dbe0fe0c
      [  161.003062]  DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
      [  161.003068] CR0: 8005003b CR2: b7718000 CR3: 1bec0000 CR4: 001007f0
      [  161.003076] Stack:
      [  161.003081]  00afc014 00000004 c0086b40 dfafc000 dbe0fe38 f8487e5a dfaa5400 c0086b40
      [  161.003099]  dfafc000 dfaa5400 dfaa5414 dbe0fe58 f84741aa 00000000 f89c34b9 dfaa5414
      [  161.003117]  dfaa5400 dfaa5400 f644b000 dbe0fe6c f89a5443 dfaa5400 f8505000 f644b000
      [  161.003134] Call Trace:
      [  161.003169]  [<f8487e5a>] i915_gem_context_fini+0xba/0x1c0 [i915]
      [  161.003202]  [<f84741aa>] i915_driver_unload+0x1fa/0x2f0 [i915]
      [  161.003232]  [<f89a5443>] drm_dev_unregister+0x23/0x90 [drm]
      [  161.003259]  [<f89a54ed>] drm_put_dev+0x3d/0x70 [drm]
      [  161.003294]  [<f8470615>] i915_pci_remove+0x15/0x20 [i915]
      [  161.003306]  [<c1338a6f>] pci_device_remove+0x2f/0xa0
      [  161.003317]  [<c140c871>] __device_release_driver+0x61/0xc0
      [  161.003328]  [<c140d12f>] driver_detach+0x8f/0xa0
      [  161.003341]  [<c140c54f>] bus_remove_driver+0x4f/0xc0
      [  161.003353]  [<c140d708>] driver_unregister+0x28/0x60
      [  161.003362]  [<c10cee42>] ? stop_cpus+0x32/0x40
      [  161.003372]  [<c10bd510>] ? module_refcount+0x90/0x90
      [  161.003383]  [<c13378c5>] pci_unregister_driver+0x15/0x60
      [  161.003413]  [<f89a739f>] drm_pci_exit+0x9f/0xb0 [drm]
      [  161.003458]  [<f84e624a>] i915_exit+0x1b/0x1d [i915]
      [  161.003468]  [<c10bf8a8>] SyS_delete_module+0x158/0x1f0
      [  161.003480]  [<c1173d5d>] ? ____fput+0xd/0x10
      [  161.003488]  [<c106f0fe>] ? task_work_run+0x7e/0xb0
      [  161.003499]  [<c165a68d>] sysenter_do_call+0x12/0x28
      [  161.003505] Code: 0f b6 4d f3 8d 51 0f 83 e1 f0 83 e2 0f 09 d1 84 d2 88 48 54 75 07 80 a7 91 00 00 00 7f 83 c4 04 5b 5e 5f 5d c3 8d b6 00 00 00 00 <0f> 0b 8d b6 00 00 00 00 55 89 e5 57 56 53 83 ec 64 3e 8d 74 26
      [  161.003586] EIP: [<f84861f8>] i915_gem_object_ggtt_unpin+0x88/0x90 [i915] SS:ESP 0068:dbe0fe0c
      
      v2: Rename the local variable (is_default_ctx) to avoid confusion with
      the function is_default_ctx(). And correct Jesse's email address.
      Reported-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=73985Signed-off-by: NChris Wilson <chris@chris-wilson.co.uk>
      Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
      Cc: Ben Widawsky <benjamin.widawsky@intel.com>
      Tested-by: NJesse Barnes <jbarnes@virtuousgeek.org>
      Reviewed-by: NBen Widawsky <benjamin.widawsky@intel.com>
      [danvet: Fix up the rebase fail from my first attempt, thankfully
      pointed out by Ville.]
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      42c3b603
  22. 10 1月, 2014 2 次提交
    • B
      drm/i915: set ctx->initialized only after RCS · ad1d2199
      Ben Widawsky 提交于
      The initialized flag is used to specify a context has been initialized
      and it's context is safe to load, ie. the 3d state is setup properly.
      With full PPGTT, we emit the address space loads during context switch
      and this currently marks a context as initialized. With full PPGTT
      patches, if a client first emits a batch to !RCS, then later, RCS, the
      code will mistake the context as initialized and try to reload an
      uninitialized context.
      
      1. context 1 blit // context marked as initialized, but isn't
      2. context 1 render // loads random state from step 2
      
      It is really easy to hit this with a planned upcoming patch which makes
      default context reuse possible.
      
      NOTE: This should only effect full PPGTT branches, ie. current
      drm-intel-nightly.
      
      Thanks to Chris for helping me track this down.
      
      Cc: Chris Wilson <chris@chris-wilson.co.uk>
      Signed-off-by: NBen Widawsky <ben@bwidawsk.net>
      Reviewed-by: NChris Wilson <chris@chris-wilson.co.uk>
      [danvet: Simplify the failure scenario in the commit message according
      to Chris' review a bit.]
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      ad1d2199
    • B
      drm/i915/bdw: Return -ENONENT on default ctx destroy · c2cf2416
      Ben Widawsky 提交于
      This was an accidental "ABI" change introduced during PPGTT:
      
      commit 0eea67eb
      Author: Ben Widawsky <ben@bwidawsk.net>
      Date:   Fri Dec 6 14:11:19 2013 -0800
      
          drm/i915: Create a per file_priv default context
      
      The failure test application actually tests the return type. The other
      option is to simply change the test.
      Signed-off-by: NBen Widawsky <ben@bwidawsk.net>
      Reviewed-by: NChris Wilson <chris@chris-wilson.co.uk>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      c2cf2416
  23. 07 1月, 2014 1 次提交
  24. 18 12月, 2013 10 次提交
    • B
      drm/i915: Use multiple VMs -- the point of no return · 7e0d96bc
      Ben Widawsky 提交于
      As with processes which run on the CPU, the goal of multiple VMs is to
      provide process isolation. Specific to GEN, there is also the ability to
      map more objects per process (2GB each instead of 2Gb-2k total).
      
      For the most part, all the pipes have been laid, and all we need to do
      is remove asserts and actually start changing address spaces with the
      context switch. Since prior to this we've converted the setting of the
      page tables to a streamed version, this is quite easy.
      
      One important thing to point out (since it'd been hotly contested) is
      that with this patch, every context created will have it's own address
      space (provided the HW can do it).
      
      v2: Disable BDW on rebase
      
      NOTE: I tried to make this commit as small as possible. I needed one
      place where I could "turn everything on" and that is here. It could be
      split into finer commits, but I didn't really see much point.
      
      Cc: Eric Anholt <eric@anholt.net>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: NBen Widawsky <ben@bwidawsk.net>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      7e0d96bc
    • B
      drm/i915: Get context early in execbuf · 41bde553
      Ben Widawsky 提交于
      We need to have the address space when reserving space for the objects.
      Since the address space and context are tied together, and reserve
      occurs before context switch (for good reason), we must lookup our
      context earlier in the process.
      
      This leaves some room for optimizations where we no longer need to use
      ctx_id in certain places. This will be addressed in a subsequent patch.
      
      Important tricky bit:
      Because slow relocations during execbuffer drop struct_mutex
      
      Perhaps it would be best to acquire the reference when we get the
      context, but I'll save that for another day (note I have written the
      patch before, and I found the changes required to be uglier than this).
      
      Note that since we currently access everything via context id, and not
      the data structure this is fine, though not desirable. The next change
      attempts to get the context only once via the context ID idr lookup, and
      as such, the following can happen:
      
      CTX-A is created, refcount = 1
      CTX-A execbuf, mutex dropped
      close IOCTL called on CTX-A, refcount = 0
      CTX-A resumes in execbuf.
      
      v2: Rebased on top of
      commit b6359918
      Author: Mika Kuoppala <mika.kuoppala@linux.intel.com>
      Date:   Wed Oct 30 15:44:16 2013 +0200
      
          drm/i915: add i915_get_reset_stats_ioctl
      
      v3: Rebased on top of
      commit 25b3dfc8
      Author: Mika Westerberg <mika.westerberg@linux.intel.com>
      Date:   Tue Nov 12 11:57:30 2013 +0200
      
      Author: Mika Kuoppala <mika.kuoppala@linux.intel.com>
      Date:   Tue Nov 26 16:14:33 2013 +0200
      
          drm/i915: check context reset stats before relocations
      Signed-off-by: NBen Widawsky <ben@bwidawsk.net>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      41bde553
    • B
      drm/i915: Piggy back hangstats off of contexts · c482972a
      Ben Widawsky 提交于
      To simplify the codepaths somewhat, we can simply always create a
      context. Contexts already keep hangstat information. This prevents us
      from having to differentiate at other parts in the code.
      
      There is allocation overhead, but it should not be measurable.
      Signed-off-by: NBen Widawsky <ben@bwidawsk.net>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      c482972a
    • B
      drm/i915: Create a per file_priv default context · 0eea67eb
      Ben Widawsky 提交于
      Every file will get it's own context, and we use this context instead of
      the default context. The default context still exists for future
      shrinker usage as well as reset handling.
      
      v2: Updated to address Mika's recent context guilty changes
      Some more changes around this come up in later patches as well.
      
      v3: Use a fake context to avoid allocation for the !HAS_HW_CONTEXT case.
      I've tried the alternatives. This looks the best to me.
      Removed hangstat stuff from v2 - for a separate patch
      Demote failed PPGTT set to DRM_DEBUG_DRIVER since it can now be invoked
      easily from userspace.
      Signed-off-by: NBen Widawsky <ben@bwidawsk.net>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      0eea67eb
    • B
      drm/i915: Do aliasing PPGTT init with contexts · bdf4fd7e
      Ben Widawsky 提交于
      We have a default context which suits the aliasing PPGTT well. Tie them
      together so it looks like any other context/PPGTT pair. This makes the
      code cleaner as it won't have to special case aliasing as often.
      
      The patch has one slightly tricky part in the default context creation
      function. In the future (and on aliased setup) we create a new VM for a
      context (potentially). However, if we have aliasing PPGTT, which occurs
      at this point in time for all platforms GEN6+, we can simply manage the
      refcounting to allow things to behave as normal. Now is a good time to
      recall that the aliasing_ppgtt doesn't have a real VM, it uses the GGTT
      drm_mm.
      Signed-off-by: NBen Widawsky <ben@bwidawsk.net>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      bdf4fd7e
    • B
      drm/i915: Add VM to context · c7c48dfd
      Ben Widawsky 提交于
      Pretty straightforward so far except for the bit about the refcounting.
      The PPGTT will potentially be shared amongst multiple contexts. Because
      contexts themselves have a refcounted lifecycle, the easiest way to
      manage this will be to refcount the PPGTT. To acheive this, we piggy
      back off of the existing context refcount, and will increment and
      decrement the PPGTT refcount with context creation, and destruction.
      
      To put it more clearly, if context A, and context B both use PPGTT 0, we
      can't free the PPGTT until both A, and B are destroyed.
      
      Note that because the PPGTT is permanently pinned (for now), it really
      just matters for the PPGTT destruction, as opposed to making space under
      memory pressure.
      Signed-off-by: NBen Widawsky <ben@bwidawsk.net>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      c7c48dfd
    • B
      drm/i915: Generalize default context setup · a45d0f6a
      Ben Widawsky 提交于
      The plan to to make every file descriptor have a default context. To
      accommodate this, generalize out default context setup function so it
      can be used at file open time.
      Signed-off-by: NBen Widawsky <ben@bwidawsk.net>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      a45d0f6a
    • B
      drm/i915: Split context enabling from init · 2fa48d8d
      Ben Widawsky 提交于
      We **need** to do this for exactly 1 reason, because we want to embed a
      PPGTT into the context, but we don't want to special case the default
      context.
      
      To achieve that, we must be able to initialize contexts after the GTT is
      setup (so we can allocate and pin the default context's BO), but before
      the PPGTT and rings are initialized. This is because, currently, context
      initialization requires ring usage. We don't have rings until after the
      GTT is setup. If we split the enabling part of context initialization,
      the part requiring the ringbuffer, we can untangle this, and then later
      embed the PPGTT
      
      Incidentally this allows us to also adhere to the original design of
      context init/fini in future patches: they were only ever meant to be
      called at driver load and unload.
      
      v2: Move hw_contexts_disabled test in i915_gem_context_enable() (Chris)
      
      v3: BUG_ON after checking for disabled contexts. Or else it blows up pre
      gen6 (Ben)
      
      v4: Forward port
      Modified enable for each ring, since that patch is earlier in the series
      Dropped ring arg from create_default_context so it can be used by others
      Signed-off-by: NBen Widawsky <ben@bwidawsk.net>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      2fa48d8d
    • B
      drm/i915: Better reset handling for contexts · acce9ffa
      Ben Widawsky 提交于
      This patch adds to changes for contexts on reset:
      Sets last context to default - this will prevent the context switch
      happening after a reset. That switch is not possible because the
      rings are hung during reset and context switch requires reset. This
      behavior will need to be reworked in the future, but this is what we
      want for now.
      
      In the future, we'll also want to reset the guilty context to
      uninitialized. We should wait for ARB_Robustness related code to land
      for that.
      
      This is somewhat for paranoia.  Because we really don't know what the
      GPU was doing when it hung, or the state it was in (mid context write,
      for example), later restoring the context is a bad idea. By setting the
      flag to not initialized, the next load of that context will not restore
      the state, and thus on the subsequent switch away from the context will
      overwrite the old data.
      
      NOTE: This code needs a fixup when we actually have multiple VMs. The
      issue that can occur is inactive objects in a VM will need to be
      destroyed before the last context unref. This can now happen via the
      fake switch introduced in this patch (and it other ways in the future)
      Signed-off-by: NBen Widawsky <ben@bwidawsk.net>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      acce9ffa
    • B
      drm/i915: Track which ring a context ran on · 0009e46c
      Ben Widawsky 提交于
      Previously we dropped the association of a context to a ring. It is
      however very important to know which ring a context ran on (we could
      have reused the other member, but I was nitpicky).
      
      This is very important when we switch address spaces, which unlike
      context objects, do change per ring.
      
      As an example, if we have:
      
              RCS   BCS
      ctx            A
      ctx      A
      ctx      B
      ctx            B
      
      Without tracking the last ring B ran on, we wouldn't know to switch the
      address space on BCS in the last row.
      
      As a result, we no longer need to track which ring a context "belongs"
      to, as it never really made much sense anyway.
      Signed-off-by: NBen Widawsky <ben@bwidawsk.net>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      0009e46c