Skip to content
  1. Dec 08, 2019
  2. Dec 07, 2019
    • Chris Wilson's avatar
      drm/i915/gem: Pin gen6_ppgtt prior to constructing the request · aef82079
      Chris Wilson authored
      
      
      All pinning must be done prior to i915_request_create, to avoid
      timeline->mutex inversions.
      
      Here we slightly abuse the context_barrier_task stages to utilise the
      'skip' decision as an opportunity to acquire the pin on the new ppgtt.
      Consider it s/skip/prepare/. At the moment, we only have on user of
      context_barrier_task, so it might be worth breaking it down for the
      specific task of set-vm and refactor it later if we find a second
      purpose.
      
      <4> [402.377487] WARNING: possible circular locking dependency detected
      <4> [402.377493] 5.4.0-rc8-CI-CI_DRM_7491+ #1 Tainted: G     U
      <4> [402.377497] ------------------------------------------------------
      <4> [402.377502] gem_exec_parall/2506 is trying to acquire lock:
      <4> [402.377507] ffff888403cdac70 (&kernel#2){+.+.}, at: i915_request_create+0x16/0x1c0 [i915]
      <4> [402.377593]
      but task is already holding lock:
      <4> [402.377597] ffff88835efad550 (&ppgtt->pin_mutex){+.+.}, at: gen6_ppgtt_pin+0x4d/0x110 [i915]
      <4> [402.377660]
      which lock already depends on the new lock.
      
      <4> [402.377664]
      the existing dependency chain (in reverse order) is:
      <4> [402.377668]
      -> #1 (&ppgtt->pin_mutex){+.+.}:
      <4> [402.377674]        __mutex_lock+0x9a/0x9d0
      <4> [402.377713]        gen6_ppgtt_pin+0x4d/0x110 [i915]
      <4> [402.377756]        emit_ppgtt_update+0x1dc/0x370 [i915]
      <4> [402.377801]        context_barrier_task+0x176/0x310 [i915]
      <4> [402.377844]        ctx_setparam+0x400/0xb10 [i915]
      <4> [402.377886]        i915_gem_context_setparam_ioctl+0xc8/0x160 [i915]
      <4> [402.377891]        drm_ioctl_kernel+0xa7/0xf0
      <4> [402.377895]        drm_ioctl+0x2e1/0x390
      <4> [402.377899]        do_vfs_ioctl+0xa0/0x6f0
      <4> [402.377903]        ksys_ioctl+0x35/0x60
      <4> [402.377906]        __x64_sys_ioctl+0x11/0x20
      <4> [402.377910]        do_syscall_64+0x4f/0x210
      <4> [402.377914]        entry_SYSCALL_64_after_hwframe+0x49/0xbe
      <4> [402.377917]
      -> #0 (&kernel#2){+.+.}:
      <4> [402.377923]        __lock_acquire+0x1328/0x15d0
      <4> [402.377926]        lock_acquire+0xa7/0x1c0
      <4> [402.377930]        __mutex_lock+0x9a/0x9d0
      <4> [402.377977]        i915_request_create+0x16/0x1c0 [i915]
      <4> [402.378013]        intel_engine_flush_barriers+0x4c/0x100 [i915]
      <4> [402.378062]        i915_ggtt_pin+0x7d/0x130 [i915]
      <4> [402.378108]        gen6_ppgtt_pin+0x9c/0x110 [i915]
      <4> [402.378148]        ring_context_pin+0x2e/0xc0 [i915]
      <4> [402.378183]        __intel_context_do_pin+0x6b/0x190 [i915]
      <4> [402.378226]        i915_gem_do_execbuffer+0x180c/0x26b0 [i915]
      <4> [402.378268]        i915_gem_execbuffer2_ioctl+0x11b/0x460 [i915]
      <4> [402.378272]        drm_ioctl_kernel+0xa7/0xf0
      <4> [402.378275]        drm_ioctl+0x2e1/0x390
      <4> [402.378279]        do_vfs_ioctl+0xa0/0x6f0
      <4> [402.378282]        ksys_ioctl+0x35/0x60
      <4> [402.378286]        __x64_sys_ioctl+0x11/0x20
      <4> [402.378289]        do_syscall_64+0x4f/0x210
      <4> [402.378292]        entry_SYSCALL_64_after_hwframe+0x49/0xbe
      <4> [402.378295]
      other info that might help us debug this:
      
      <4> [402.378299]  Possible unsafe locking scenario:
      
      <4> [402.378302]        CPU0                    CPU1
      <4> [402.378305]        ----                    ----
      <4> [402.378307]   lock(&ppgtt->pin_mutex);
      <4> [402.378310]                                lock(&kernel#2);
      <4> [402.378314]                                lock(&ppgtt->pin_mutex);
      <4> [402.378317]   lock(&kernel#2);
      <4> [402.378320]
      
      Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Reviewed-by: default avatarAndi Shyti <andi.shyti@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191206105527.1130413-4-chris@chris-wilson.co.uk
      aef82079
    • Andi Shyti's avatar
      drm/i915/gt: Replace I915_WRITE with its uncore counterpart · 795a4aea
      Andi Shyti authored
      
      
      Get rid of the last remaining I915_WRITEs and replace them with
      intel_uncore_write().
      
      Signed-off-by: default avatarAndi Shyti <andi.shyti@intel.com>
      Reviewed-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191206212417.20178-1-andi@etezian.org
      795a4aea
    • José Roberto de Souza's avatar
      drm/i915/display: Refactor intel_commit_modeset_disables() · ad457191
      José Roberto de Souza authored
      Commit 9c722e17
      
       ("drm/i915: Disable pipes in reverse order")
      reverted the order that pipes gets disabled because of TGL
      master/slave relationship between transcoders in MST mode.
      
      But as stated in a comment in skl_commit_modeset_enables() the
      enabling order is not always crescent, possibly causing previously
      selected slave transcoder being enabled before master so another
      approach will be needed to select a transcoder to master in MST mode.
      It will be similar to the approach taken in port sync.
      
      But instead of implement something like
      intel_trans_port_sync_modeset_disables() to MST lets simply it and
      iterate over all pipes 2 times, the first one disabling any slave and
      then disabling everything else.
      The MST bits will be added in another patch.
      
      v2:
      Not using crtc->active as it is deprecated
      
      v3:
      Removing is_trans_port_sync_mode() check, just check for
      is_trans_port_sync_master() is enough
      
      v4:
      Adding and using is_trans_port_sync_slave(), otherwise non-port sync
      pipes will be disabled in the first loop, what is not wrong but is
      not what patch description promises
      
      Cc: Lucas De Marchi <lucas.demarchi@intel.com>
      Cc: Manasi Navare <manasi.d.navare@intel.com>
      Cc: Matt Roper <matthew.d.roper@intel.com>
      Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
      Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com> (v2)
      Signed-off-by: default avatarJosé Roberto de Souza <jose.souza@intel.com>
      Reviewed-by: default avatarMatt Roper <matthew.d.roper@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191205210350.96795-3-jose.souza@intel.com
      ad457191
    • José Roberto de Souza's avatar
      drm/i915/display/tgl: Fix the order of the step to turn transcoder clock off · 3ca8f191
      José Roberto de Souza authored
      
      
      For TGL the step to turn off the transcoder clock was moved to after
      the complete shutdown of DDI. Only the MST slave transcoders should
      disable the clock before that.
      
      v2:
      - Adding last_mst_stream to intel_mst_post_disable_dp, make code more
      easy to read and is similar to first_mst_stream in
      intel_mst_pre_enable_dp()(Ville's idea)
      - Calling intel_ddi_disable_pipe_clock() for GEN12+ right
      intel_disable_ddi_buf() as stated in BSpec(Ville)
      
      BSpec: 49190
      Cc: Lucas De Marchi <lucas.demarchi@intel.com>
      Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
      Reviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Signed-off-by: default avatarJosé Roberto de Souza <jose.souza@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191205210350.96795-2-jose.souza@intel.com
      3ca8f191
    • José Roberto de Souza's avatar
      drm/i915/display: Do not check for the ddb allocations of turned off pipes · 1ac87297
      José Roberto de Souza authored
      
      
      It should not care about DDB allocations of pipes going through
      a fullmodeset, as at this point those pipes are disabled.
      The comment in the code also points to that but that was not what
      was being executed.
      
      Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
      Reviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Signed-off-by: default avatarJosé Roberto de Souza <jose.souza@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191205210350.96795-1-jose.souza@intel.com
      1ac87297
    • José Roberto de Souza's avatar
      drm/i915: Add new EHL/JSL PCI ids · 651cc835
      José Roberto de Souza authored
      
      
      Adding the recently added EHL/JSL PCI ids.
      
      BSpec: 29153
      Cc: James Ausmus <james.ausmus@intel.com>
      Cc: Matt Roper <matthew.d.roper@intel.com>
      Signed-off-by: default avatarJosé Roberto de Souza <jose.souza@intel.com>
      Reviewed-by: default avatarMatt Roper <matthew.d.roper@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191203211308.109703-1-jose.souza@intel.com
      651cc835
    • Chris Wilson's avatar
      drm/i915: Propagate errors on awaiting already signaled dma-fences · cbab8d87
      Chris Wilson authored
      
      
      If we see an already signaled dma-fence that we want to await on, we skip
      adding to the i915_sw_fence. However, we should pay attention to whether
      there was an error on that fence and if so propagate it for our future
      request.
      
      Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Reviewed-by: default avatarMatthew Auld <matthew.auld@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191206160428.1503343-3-chris@chris-wilson.co.uk
      cbab8d87
    • Chris Wilson's avatar
      drm/i915: Propagate errors on awaiting already signaled fences · 9e31c1fe
      Chris Wilson authored
      
      
      If we see an already signaled fence that we want to await on, we skip
      adding to the i915_sw_fence. However, we should pay attention to whether
      there was an error on that fence and if so propagate it for our future
      request.
      
      Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Reviewed-by: default avatarMatthew Auld <matthew.auld@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191206160428.1503343-2-chris@chris-wilson.co.uk
      9e31c1fe
    • Chris Wilson's avatar
      drm/i915: Check for error before calling cmpxchg() · 5e6a9471
      Chris Wilson authored
      
      
      Only do the locked compare of the existing fence->error if we actually
      need to set an error. As we tend to call i915_sw_fence_set_error_once()
      unconditionally, it saves on typing to put the common has-error check
      into the inline.
      
      Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Reviewed-by: default avatarMatthew Auld <matthew.auld@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191206160428.1503343-1-chris@chris-wilson.co.uk
      5e6a9471
  3. Dec 06, 2019
    • Tvrtko Ursulin's avatar
      drm/i915/pmu: Report frequency as zero while GPU is sleeping · b66ecd04
      Tvrtko Ursulin authored
      
      
      We used to report the minimum possible frequency as both requested and
      active while GPU was in sleep state. This was a consequence of sampling
      the value from the "current frequency" field in our software tracking.
      
      This was strictly speaking wrong, but given that until recently the
      current frequency in sleeping state used to be equal to minimum, it did
      not stand out sufficiently to be noticed as such.
      
      After some recent changes have made the current frequency be reported
      as last active before GPU went to sleep, meaning both requested and active
      frequencies could end up being reported at their maximum values for the
      duration of the GPU idle state, it became much more obvious that this does
      not make sense.
      
      To fix this we will now sample the frequency counters only when the GPU is
      awake. As a consequence reported frequencies could be reported as below
      the GPU reported minimum but that should be much less confusing that the
      current situation.
      
      v2:
       * Split out early exit conditions for readability. (Chris)
      
      Signed-off-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
      Reviewed-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Closes: https://gitlab.freedesktop.org/drm/intel/issues/675
      Link: https://patchwork.freedesktop.org/patch/msgid/20191129105436.20100-1-tvrtko.ursulin@linux.intel.com
      b66ecd04
    • Chris Wilson's avatar
      drm/i915/gem: Flush the pwrite through the chipset before signaling · 1a74934b
      Chris Wilson authored
      
      
      Before we signal the fence to indicate completion, ensure the pwrite
      through the indirect GGTT is coherent (as best as we know) in memory.
      Any listeners to the fence may start immediately and sample from the
      backing store prior to the writes being posted, thus seeing stale data.
      
      Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Reviewed-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191206105527.1130413-1-chris@chris-wilson.co.uk
      1a74934b
    • Chris Wilson's avatar
      drm/i915/gt: Acquire a GT wakeref for the breadcrumb interrupt · 045d1fb7
      Chris Wilson authored
      
      
      Take a wakeref on the intel_gt specifically for the enabled breadcrumb
      interrupt so that we can safely process the mmio. If the intel_gt is
      already asleep by the time we try and setup the breadcrumb interrupt, by
      a process of elimination we know the request must have been completed
      and we can skip its enablement!
      
      <4> [1518.350005] Unclaimed write to register 0x220a8
      <4> [1518.350323] WARNING: CPU: 2 PID: 3685 at drivers/gpu/drm/i915/intel_uncore.c:1163 __unclaimed_reg_debug+0x40/0x50 [i915]
      <4> [1518.350393] Modules linked in: vgem snd_hda_codec_hdmi x86_pkg_temp_thermal i915 coretemp crct10dif_pclmul crc32_pclmul ghash_clmulni_intel snd_hda_intel snd_intel_dspcfg snd_hda_codec snd_hwdep snd_hda_core btusb cdc_ether btrtl usbnet btbcm btintel r8152 snd_pcm mii bluetooth ecdh_generic ecc i2c_hid pinctrl_sunrisepoint pinctrl_intel intel_lpss_pci prime_numbers [last unloaded: vgem]
      <4> [1518.350646] CPU: 2 PID: 3685 Comm: gem_exec_parse_ Tainted: G     U            5.4.0-rc8-CI-CI_DRM_7490+ #1
      <4> [1518.350708] Hardware name: Google Caroline/Caroline, BIOS MrChromebox 08/27/2018
      <4> [1518.350946] RIP: 0010:__unclaimed_reg_debug+0x40/0x50 [i915]
      <4> [1518.350992] Code: 74 05 5b 5d 41 5c c3 45 84 e4 48 c7 c0 95 8d 47 a0 48 c7 c6 8b 8d 47 a0 48 0f 44 f0 89 ea 48 c7 c7 9e 8d 47 a0 e8 40 45 e3 e0 <0f> 0b 83 2d 27 4f 2a 00 01 5b 5d 41 5c c3 66 90 41 55 41 54 55 53
      <4> [1518.351100] RSP: 0018:ffffc900007f39c8 EFLAGS: 00010086
      <4> [1518.351140] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000006
      <4> [1518.351202] RDX: 0000000080000006 RSI: 0000000000000000 RDI: 00000000ffffffff
      <4> [1518.351249] RBP: 00000000000220a8 R08: 0000000000000000 R09: 0000000000000000
      <4> [1518.351296] R10: ffffc900007f3990 R11: ffffc900007f3868 R12: 0000000000000000
      <4> [1518.351342] R13: 00000000fefeffff R14: 0000000000000092 R15: ffff888155fea000
      <4> [1518.351391] FS:  00007fc255abfe40(0000) GS:ffff88817ab00000(0000) knlGS:0000000000000000
      <4> [1518.351445] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      <4> [1518.351485] CR2: 00007fc2554882d0 CR3: 0000000168ca2005 CR4: 00000000003606e0
      <4> [1518.351529] Call Trace:
      <4> [1518.351746]  fwtable_write32+0x114/0x1d0 [i915]
      <4> [1518.351795]  ? sync_file_alloc+0x80/0x80
      <4> [1518.352039]  gen8_logical_ring_enable_irq+0x30/0x50 [i915]
      <4> [1518.352295]  irq_enable.part.10+0x23/0x40 [i915]
      <4> [1518.352523]  i915_request_enable_breadcrumb+0xb5/0x330 [i915]
      <4> [1518.352575]  ? sync_file_alloc+0x80/0x80
      <4> [1518.352612]  __dma_fence_enable_signaling+0x60/0x160
      <4> [1518.352653]  ? sync_file_alloc+0x80/0x80
      <4> [1518.352685]  dma_fence_add_callback+0x44/0xd0
      <4> [1518.352726]  sync_file_poll+0x95/0xc0
      <4> [1518.352767]  do_sys_poll+0x24d/0x570
      
      Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Reviewed-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191205215842.862750-1-chris@chris-wilson.co.uk
      045d1fb7
    • Chris Wilson's avatar
      drm/i915: Claim vma while under closed_lock in i915_vma_parked() · 77853186
      Chris Wilson authored
      Remove the vma we wish to destroy from the gt->closed_list to avoid
      having two i915_vma_parked() try and free it.
      
      Fixes: aa5e4453 ("drm/i915/gem: Try to flush pending unbind events")
      References: 2850748e
      
       ("drm/i915: Pull i915_vma_pin under the vm->mutex")
      Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Reviewed-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191205214159.829727-1-chris@chris-wilson.co.uk
      77853186
    • Chris Wilson's avatar
      drm/i915/gt: Trim gen6 ppgtt updates to PD cachelines · d315fe8b
      Chris Wilson authored
      
      
      It appears now that we have the ring TLB invalidation in place, we need
      only update the page directory cachelines that we have altered. A great
      reduction from rewriting the whole 2MiB ppgtt on every update.
      
      Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Acked-by: default avatarMika Kuoppala <mika.kuoppala@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191205234059.1010030-1-chris@chris-wilson.co.uk
      d315fe8b
    • Chris Wilson's avatar
      drm/i915: Serialise i915_active_acquire() with __active_retire() · bbca083d
      Chris Wilson authored
      
      
      As __active_retire() does it's final atomic_dec() under the
      ref->tree_lock spinlock, in order to prevent ourselves from reusing the
      ref->cache and ref->tree as they are being destroyed, we need to
      serialise with the retirement during i915_active_acquire().
      
      [  +0.000005] kernel BUG at drivers/gpu/drm/i915/i915_active.c:157!
      [  +0.000011] invalid opcode: 0000 [#1] SMP
      [  +0.000004] CPU: 7 PID: 188 Comm: kworker/u16:4 Not tainted 5.4.0-rc8-03070-gac5e57322614 #89
      [  +0.000002] Hardware name: Razer Razer Blade Stealth 13 Late 2019/LY320, BIOS 1.02 09/10/2019
      [  +0.000082] Workqueue: events_unbound active_work [i915]
      [  +0.000059] RIP: 0010:__active_retire+0x115/0x120 [i915]
      [  +0.000003] Code: 75 28 48 8b 3d 8c 6e 1a 00 48 89 ee e8 e4 5f a5 c0 48 8b 44 24 10 65 48 33 04 25 28 00 00 00 75 0f 48 83 c4 18 5b 5d 41 5c c3 <0f> 0b 0f 0b 0f 0b e8 a0 90 87 c0 0f 1f 44 00 00 48 8b 3d 54 6e 1a
      [  +0.000002] RSP: 0018:ffffb833003f7e48 EFLAGS: 00010286
      [  +0.000003] RAX: ffff8d6e8d726d00 RBX: ffff8d6f9db4e840 RCX: 0000000000000000
      [  +0.000001] RDX: ffffffff82605930 RSI: ffff8d6f9adc4908 RDI: ffff8d6e96cefe28
      [  +0.000002] RBP: ffff8d6e96cefe00 R08: 0000000000000000 R09: ffff8d6f9ffe9a50
      [  +0.000002] R10: 0000000000000048 R11: 0000000000000018 R12: ffff8d6f9adc4930
      [  +0.000001] R13: ffff8d6f9e04fb00 R14: 0000000000000000 R15: ffff8d6f9adc4988
      [  +0.000002] FS:  0000000000000000(0000) GS:ffff8d6f9ffc0000(0000) knlGS:0000000000000000
      [  +0.000002] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [  +0.000002] CR2: 000055eb5a34cf10 CR3: 000000018d609002 CR4: 0000000000760ee0
      [  +0.000002] PKRU: 55555554
      [  +0.000001] Call Trace:
      [  +0.000010]  process_one_work+0x1aa/0x350
      [  +0.000004]  worker_thread+0x4d/0x3a0
      [  +0.000004]  kthread+0xfb/0x130
      [  +0.000004]  ? process_one_work+0x350/0x350
      [  +0.000003]  ? kthread_park+0x90/0x90
      [  +0.000005]  ret_from_fork+0x1f/0x40
      
      Reported-by: default avatarKenneth Graunke <kenneth@whitecape.org>
      Fixes: c9ad602f
      
       ("drm/i915: Split i915_active.mutex into an irq-safe spinlock for the rbtree")
      Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
      Cc: Kenneth Graunke <kenneth@whitecape.org>
      Cc: Matthew Auld <matthew.auld@intel.com>
      Tested-by: default avatarKenneth Graunke <kenneth@whitecape.org>
      Reviewed-by: default avatarKenneth Graunke <kenneth@whitecape.org>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191205183332.801237-1-chris@chris-wilson.co.uk
      bbca083d
    • Andi Shyti's avatar
      drm/i915/gt: Replace I915_READ with intel_uncore_read · 92c964ca
      Andi Shyti authored
      
      
      Get rid of the last remaining I915_READ in gt/ and make gt-land
      the first I915_READ-free happy island.
      
      Suggested-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Signed-off-by: default avatarAndi Shyti <andi.shyti@intel.com>
      Reviewed-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191205164422.727968-1-chris@chris-wilson.co.uk
      92c964ca
    • Chris Wilson's avatar
      drm/i915/gt: Save irqstate around virtual_context_destroy · 6f7ac828
      Chris Wilson authored
      As virtual_context_destroy() may be called from a request signal, it may
      be called from inside an irq-off section, and so we need to do a full
      save/restore of the irq state rather than blindly re-enable irqs upon
      unlocking.
      
      <4> [110.024262] WARNING: inconsistent lock state
      <4> [110.024277] 5.4.0-rc8-CI-CI_DRM_7489+ #1 Tainted: G     U
      <4> [110.024292] --------------------------------
      <4> [110.024305] inconsistent {IN-HARDIRQ-W} -> {HARDIRQ-ON-W} usage.
      <4> [110.024323] kworker/0:0/5 [HC0[0]:SC0[0]:HE1:SE1] takes:
      <4> [110.024338] ffff88826a0c7a18 (&(&rq->lock)->rlock){?.-.}, at: i915_request_retire+0x221/0x930 [i915]
      <4> [110.024592] {IN-HARDIRQ-W} state was registered at:
      <4> [110.024612]   lock_acquire+0xa7/0x1c0
      <4> [110.024627]   _raw_spin_lock_irqsave+0x33/0x50
      <4> [110.024788]   intel_engine_breadcrumbs_irq+0x38c/0x600 [i915]
      <4> [110.024808]   irq_work_run_list+0x49/0x70
      <4> [110.024824]   irq_work_run+0x26/0x50
      <4> [110.024839]   smp_irq_work_interrupt+0x44/0x1e0
      <4> [110.024855]   irq_work_interrupt+0xf/0x20
      <4> [110.024871]   __do_softirq+0xb7/0x47f
      <4> [110.024885]   irq_exit+0xba/0xc0
      <4> [110.024898]   do_IRQ+0x83/0x160
      <4> [110.024910]   ret_from_intr+0x0/0x1d
      <4> [110.024922] irq event stamp: 172864
      <4> [110.024938] hardirqs last  enabled at (172863): [<ffffffff819ea214>] _raw_spin_unlock_irq+0x24/0x50
      <4> [110.024963] hardirqs last disabled at (172864): [<ffffffff819e9fba>] _raw_spin_lock_irq+0xa/0x40
      <4> [110.024988] softirqs last  enabled at (172812): [<ffffffff81c00385>] __do_softirq+0x385/0x47f
      <4> [110.025012] softirqs last disabled at (172797): [<ffffffff810b829a>] irq_exit+0xba/0xc0
      <4> [110.025031]
      other info that might help us debug this:
      <4> [110.025049]  Possible unsafe locking scenario:
      
      <4> [110.025065]        CPU0
      <4> [110.025075]        ----
      <4> [110.025084]   lock(&(&rq->lock)->rlock);
      <4> [110.025099]   <Interrupt>
      <4> [110.025109]     lock(&(&rq->lock)->rlock);
      <4> [110.025124]
       *** DEADLOCK ***
      
      <4> [110.025144] 4 locks held by kworker/0:0/5:
      <4> [110.025156]  #0: ffff88827588f528 ((wq_completion)events){+.+.}, at: process_one_work+0x1de/0x620
      <4> [110.025187]  #1: ffffc9000006fe78 ((work_completion)(&engine->retire_work)){+.+.}, at: process_one_work+0x1de/0x620
      <4> [110.025219]  #2: ffff88825605e270 (&kernel#2){+.+.}, at: engine_retire+0x57/0xe0 [i915]
      <4> [110.025405]  #3: ffff88826a0c7a18 (&(&rq->lock)->rlock){?.-.}, at: i915_request_retire+0x221/0x930 [i915]
      <4> [110.025634]
      stack backtrace:
      <4> [110.025653] CPU: 0 PID: 5 Comm: kworker/0:0 Tainted: G     U            5.4.0-rc8-CI-CI_DRM_7489+ #1
      <4> [110.025675] Hardware name:  /NUC7i5BNB, BIOS BNKBL357.86A.0054.2017.1025.1822 10/25/2017
      <4> [110.025856] Workqueue: events engine_retire [i915]
      <4> [110.025872] Call Trace:
      <4> [110.025891]  dump_stack+0x71/0x9b
      <4> [110.025907]  mark_lock+0x49a/0x500
      <4> [110.025926]  ? print_shortest_lock_dependencies+0x200/0x200
      <4> [110.025946]  mark_held_locks+0x49/0x70
      <4> [110.025962]  ? _raw_spin_unlock_irq+0x24/0x50
      <4> [110.025978]  lockdep_hardirqs_on+0xa2/0x1c0
      <4> [110.025995]  _raw_spin_unlock_irq+0x24/0x50
      <4> [110.026171]  virtual_context_destroy+0xc5/0x2e0 [i915]
      <4> [110.026376]  __active_retire+0xb4/0x290 [i915]
      <4> [110.026396]  dma_fence_signal_locked+0x9e/0x1b0
      <4> [110.026613]  i915_request_retire+0x451/0x930 [i915]
      <4> [110.026766]  retire_requests+0x4d/0x60 [i915]
      <4> [110.026919]  engine_retire+0x63/0xe0 [i915]
      
      Fixes: b1e3177b ("drm/i915: Coordinate i915_active with its own mutex")
      Fixes: 6d06779e
      
       ("drm/i915: Load balancing across a virtual engine")
      Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
      Reviewed-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191205145934.663183-1-chris@chris-wilson.co.uk
      6f7ac828
  4. Dec 05, 2019
  5. Dec 04, 2019
    • Abdiel Janulgue's avatar
      drm/i915: Introduce DRM_I915_GEM_MMAP_OFFSET · cc662126
      Abdiel Janulgue authored
      
      
      This is really just an alias of mmap_gtt. The 'mmap offset' nomenclature
      comes from the value returned by this ioctl which is the offset into the
      device fd which userpace uses with mmap(2).
      
      mmap_gtt was our initial mmap_offset implementation, this extends
      our CPU mmap support to allow additional fault handlers that depends on
      the object's backing pages.
      
      Note that we multiplex mmap_gtt and mmap_offset through the same ioctl,
      and use the zero extending behaviour of drm to differentiate between
      them, when we inspect the flags.
      
      To support multiple mmap types on an object we need to support multiple
      mmap_offsets for an object (each offset in the global device address
      space corresponding to a unique instance of the object for a file + mmap
      type). As we drop the simplified drm core idea of a single mmap_offset,
      we need to provide replacement hooks for the dumb mmap interface as
      well.
      
      Link: https://gitlab.freedesktop.org/mesa/mesa/merge_requests/1675
      Testcase: igt/gem_mmap_offset
      Signed-off-by: default avatarAbdiel Janulgue <abdiel.janulgue@linux.intel.com>
      Signed-off-by: default avatarMatthew Auld <matthew.auld@intel.com>
      Reviewed-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191204120032.3682839-1-chris@chris-wilson.co.uk
      cc662126
    • Mao Wenan's avatar
      drm/i915/perf: drop pointless static qualifier in i915_perf_add_config_ioctl() · c415ef2a
      Mao Wenan authored
      
      
      There is no need to have the 'T *v' variable static
      since new value always be assigned before use it.
      
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarMao Wenan <maowenan@huawei.com>
      Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191204010154.152396-1-maowenan@huawei.com
      c415ef2a
    • Ville Syrjälä's avatar
      drm/i915: Make intel_crtc_arm_fifo_underrun() functional on gen2 · cfdd1747
      Ville Syrjälä authored
      
      
      Assuming intel_crtc_arm_fifo_underrun() only gets called when
      there's no pending plane updates we can utilize it on gen2 by
      checking the active_planes bitmask so that we only re-enable
      underrun reporting if some planes are active.
      i915_fifo_underrun_reset_write() seems to have the necessary
      hw_done/flip_done waits in place.
      
      Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191127190556.1574-8-ville.syrjala@linux.intel.com
      Reviewed-by: default avatarJosé Roberto de Souza <jose.souza@intel.com>
      cfdd1747
    • Ville Syrjälä's avatar
      drm/i915: Nuke intel_pre_disable_primary_noatomic() · 23526249
      Ville Syrjälä authored
      
      
      Let's just inline intel_pre_disable_primary_noatomic() into
      intel_plane_disable_noatomic(). The CxSR disable we can do
      regardless of which plane we're disabling, and while at it we can
      make the gen2 underrun w/a accurate by consulting the active_planes
      bitmask.
      
      Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191127190556.1574-7-ville.syrjala@linux.intel.com
      Reviewed-by: default avatarJosé Roberto de Souza <jose.souza@intel.com>
      23526249
    • Ville Syrjälä's avatar
      drm/i915: Clean up the gen2 "no planes -> underrun" workaround · 7181f5c5
      Ville Syrjälä authored
      
      
      We have the active_planes bitmask now so use it to properly
      determine when some planes are visible for the gen2 underrun
      workaround.
      
      This let's us almost eliminate intel_post_enable_primary().
      The manual underrun checks we can simply move into
      intel_atomic_commit_tail() since they loop over all the pipes
      already. No point in repeating the checks multiple times when
      there are multiple pipes in the commit.
      
      Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191127190556.1574-6-ville.syrjala@linux.intel.com
      Reviewed-by: default avatarJosé Roberto de Souza <jose.souza@intel.com>
      7181f5c5
    • Ville Syrjälä's avatar
      drm/i915: Clean up intel_{pre,post}_plane_update() · bee43ca4
      Ville Syrjälä authored
      
      
      Change the calling convention to just pass the state+crtc and
      switch to intel_ types throughout.
      
      We'll also do a quick s/if (old_primary_state)/if (new_primary_state)/
      so that we'll be able to eliminate old_primary_state later. This
      is fine since we always have either both old and new state or neither.
      
      Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191127190556.1574-5-ville.syrjala@linux.intel.com
      Reviewed-by: default avatarJosé Roberto de Souza <jose.souza@intel.com>
      bee43ca4
    • Ville Syrjälä's avatar
      drm/i915: s/pipe_config/new_crtc_state/ intel_{pre,post}_plane_update() · 0e75fb8c
      Ville Syrjälä authored
      
      
      Replace the old world 'pipe_config' variable name with the new thing.
      
      Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191127190556.1574-4-ville.syrjala@linux.intel.com
      Reviewed-by: default avatarJosé Roberto de Souza <jose.souza@intel.com>
      0e75fb8c
    • Ville Syrjälä's avatar
      drm/i915: Pass dev_priv to ilk_disable_lp_wm() · 60aca574
      Ville Syrjälä authored
      
      
      Get rid of another 'dev' usage by passing dev_priv instead.
      
      Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191127190556.1574-3-ville.syrjala@linux.intel.com
      Reviewed-by: default avatarJosé Roberto de Souza <jose.souza@intel.com>
      60aca574
    • Ville Syrjälä's avatar
      drm/i915: Clean up arguments to nv12/scaler w/a funcs · d2432796
      Ville Syrjälä authored
      
      
      Don't pass the redundant dev_priv to needs_nv12_wa() and
      needs_scalerclk_wa().
      
      Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191127190556.1574-2-ville.syrjala@linux.intel.com
      Reviewed-by: default avatarJosé Roberto de Souza <jose.souza@intel.com>
      d2432796
    • Chris Wilson's avatar
      drm/i915/gt: Set the PD again for Haswell · 13bb5b99
      Chris Wilson authored
      
      
      And Haswell still occasionally forgets it is meant to be using a new
      page directory, so repeat ourselves a little louder.
      
      <7> [509.919864] heartbeat rcs0 heartbeat {prio:-2147483645} not ticking
      <7> [509.919895] heartbeat 	Awake? 8
      <7> [509.919903] heartbeat 	Barriers?: no
      <7> [509.919912] heartbeat 	Heartbeat: 3008 ms ago
      <7> [509.919930] heartbeat 	Reset count: 0 (global 0)
      <7> [509.919937] heartbeat 	Requests:
      <7> [509.921008] heartbeat 		active  a7eb:56e1*  @ 5847ms:
      <7> [509.921157] heartbeat 		ring->start:  0x00001000
      <7> [509.921164] heartbeat 		ring->head:   0x00001610
      <7> [509.921170] heartbeat 		ring->tail:   0x000023d8
      <7> [509.921176] heartbeat 		ring->emit:   0x000023d8
      <7> [509.921182] heartbeat 		ring->space:  0x00002570
      <7> [509.921189] heartbeat 		ring->hwsp:   0x7fffe100
      <7> [509.921197] heartbeat [head 1628, postfix 1738, tail 1750, batch 0xffffffff_ffffffff]:
      <7> [509.921289] heartbeat [0000] 7a000002 00100002 00000000 00000000 7a000002 01154c1e 7ffff080 00000000
      <7> [509.921299] heartbeat [0020] 11000001 00002220 ffffffff 12400001 00002220 7ffff000 00000000 11000001
      <7> [509.921308] heartbeat [0040] 00002228 6e900000 7a000002 00100002 00000000 00000000 7a000002 01154c1e
      <7> [509.921317] heartbeat [0060] 7ffff080 00000000 12400001 00002228 7ffff000 00000000 7a000002 00100002
      <7> [509.921326] heartbeat [0080] 00000000 00000000 7a000002 01154c1e 7ffff080 00000000 7a000002 001010a1
      <7> [509.921335] heartbeat [00a0] 7ffff080 00000000 04000000 11000005 00022050 00010001 00012050 00010001
      <7> [509.921345] heartbeat [00c0] 0001a050 00010001 00000000 0c000000 459a110c 00000000 11000005 00022050
      <7> [509.921354] heartbeat [00e0] 00010000 00012050 00010000 0001a050 00010000 12400001 0001a050 7ffff000
      <7> [509.921363] heartbeat [0100] 00000000 04000001 18802100 00000000 7a000002 011050a1 7fffe100 000056e1
      <7> [509.921370] heartbeat [0120] 01000000 00000000
      <7> [509.921538] heartbeat 	MMIO base:  0x00002000
      <7> [509.921682] heartbeat 	CCID: 0x3fa0110d
      <7> [509.922342] heartbeat 	RING_START: 0x00001000
      <7> [509.922353] heartbeat 	RING_HEAD:  0x00001628
      <7> [509.922366] heartbeat 	RING_TAIL:  0x000023d8
      <7> [509.922381] heartbeat 	RING_CTL:   0x00003001
      <7> [509.922396] heartbeat 	RING_MODE:  0x00004000
      <7> [509.922408] heartbeat 	RING_IMR: ffffffde
      <7> [509.922421] heartbeat 	ACTHD:  0x00000000_30e01628
      <7> [509.922434] heartbeat 	BBADDR: 0x00000000_00004004
      <7> [509.922446] heartbeat 	DMA_FADDR: 0x00000000_00002800
      <7> [509.922458] heartbeat 	IPEIR: 0x00000000
      <7> [509.922470] heartbeat 	IPEHR: 0x780c0000
      <7> [509.922642] heartbeat 	PP_DIR_BASE: 0x6e700000
      <7> [509.922652] heartbeat 	PP_DIR_BASE_READ: 0x00000000
      <7> [509.922662] heartbeat 	PP_DIR_DCLV: 0xffffffff
      <7> [509.922678] heartbeat 		E  a7eb:56e1*  @ 5849ms:
      <7> [509.922689] heartbeat 		E  a7eb:56e2-  @ 5849ms:
      <7> [509.922698] heartbeat 		E  a7eb:56e3  @ 5848ms:
      <7> [509.922707] heartbeat 		E  a7eb:56e4  @ 5848ms:
      <7> [509.922715] heartbeat 		E  a7eb:56e5  @ 5847ms:
      <7> [509.922724] heartbeat 		E  a7eb:56e6  @ 5846ms:
      <7> [509.922735] heartbeat 		E  a7eb:56e7  @ 5846ms:
      <7> [509.922744] heartbeat 		...skipping 4 executing requests...
      <7> [509.922754] heartbeat 		E  a7eb:56ec  @ 3010ms:
      <7> [509.922796] heartbeat HWSP:
      <7> [509.922807] heartbeat [0000] 00000001 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      <7> [509.922817] heartbeat [0020] 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      <7> [509.922826] heartbeat *
      <7> [509.922836] heartbeat [0100] 000056e0 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      <7> [509.922845] heartbeat [0120] 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      <7> [509.922851] heartbeat *
      <7> [509.922870] heartbeat Idle? no
      <7> [509.922878] heartbeat Signals:
      <7> [509.923000] heartbeat 	[a7eb:56e2] @ 5850ms
      
      Here, we have a failed context restore after the PD switch, but note
      that the PP_DIR_BASE register does not match the LRI in the ring.
      
      Bump it to 8^W 4 loops, and with that Baytrail starts passing the sanity
      checks.
      
      Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Acked-by: default avatarMika Kuoppala <mika.kuoppala@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191203211631.3167430-1-chris@chris-wilson.co.uk
      13bb5b99
    • Chris Wilson's avatar
      drm/i915/gem: Avoid parking the vma as we unbind · cb6c3d45
      Chris Wilson authored
      
      
      In order to avoid keeping a reference on the i915_vma (which is long
      overdue!) we have to coordinate all the possible lifetimes and only use
      the vma while we know it is alive. In this episode, we are reminded that
      while idle, the closed vma are destroyed. So if the GT idles while we are
      working with the vma, the vma itself becomes invalid.
      
      First class i915_vma here we come, but in the meantime keep piling on
      the straw.
      
      Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Reviewed-by: default avatarMatthew Auld <matthew.auld@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191203155032.3137263-1-chris@chris-wilson.co.uk
      cb6c3d45
    • José Roberto de Souza's avatar
      drm/i915/display/mst: Move DPMS_OFF call to post_disable · 78eaaba3
      José Roberto de Souza authored
      
      
      Moving just to simplify handling as there is no change in behavior.
      
      Cc: Lucas De Marchi <lucas.demarchi@intel.com>
      Reviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Signed-off-by: default avatarJosé Roberto de Souza <jose.souza@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191202222513.337777-3-jose.souza@intel.com
      78eaaba3
    • José Roberto de Souza's avatar
      drm/i915/dp: Power down sink before disable pipe/transcoder clock · 50a7efb2
      José Roberto de Souza authored
      
      
      Disabling pipe/transcoder clock before power down sink could cause
      sink lost signal, causing it to trigger a hotplug to notify source
      that link signal was lost.
      
      Cc: Lucas De Marchi <lucas.demarchi@intel.com>
      Reviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Signed-off-by: default avatarJosé Roberto de Souza <jose.souza@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191202222513.337777-2-jose.souza@intel.com
      50a7efb2
    • José Roberto de Souza's avatar
      drm/i915/display: Check the old state to find port sync slave · e815aff5
      José Roberto de Souza authored
      
      
      If the CRTC is going from enabled to disabled and it is a port sync
      slave, it needs to check to the old state to be disabled before the
      port sync master.
      
      Cc: Manasi Navare <manasi.d.navare@intel.com>
      Cc: Matt Roper <matthew.d.roper@intel.com>
      Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
      Reviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Signed-off-by: default avatarJosé Roberto de Souza <jose.souza@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191202222513.337777-1-jose.souza@intel.com
      e815aff5