Commit 9e77f500 authored by Xiaolin Zhang's avatar Xiaolin Zhang Committed by Rodrigo Vivi

drm/i915: to make vgpu ppgtt notificaiton as atomic operation

vgpu ppgtt notification was split into 2 steps, the first step is to
update PVINFO's pdp register and then write PVINFO's g2v_notify register
with action code to tirgger ppgtt notification to GVT side.

currently these steps were not atomic operations due to no any protection,
so it is easy to enter race condition state during the MTBF, stress and
IGT test to cause GPU hang.

the solution is to add a lock to make vgpu ppgtt notication as atomic
operation.

Cc: stable@vger.kernel.org
Signed-off-by: default avatarXiaolin Zhang <xiaolin.zhang@intel.com>
Acked-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/1566543451-13955-1-git-send-email-xiaolin.zhang@intel.com
(cherry picked from commit 52988009)
Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
parent 29326a16
...@@ -961,6 +961,7 @@ struct i915_frontbuffer_tracking { ...@@ -961,6 +961,7 @@ struct i915_frontbuffer_tracking {
}; };
struct i915_virtual_gpu { struct i915_virtual_gpu {
struct mutex lock; /* serialises sending of g2v_notify command pkts */
bool active; bool active;
u32 caps; u32 caps;
}; };
......
...@@ -827,10 +827,9 @@ static void mark_tlbs_dirty(struct i915_ppgtt *ppgtt) ...@@ -827,10 +827,9 @@ static void mark_tlbs_dirty(struct i915_ppgtt *ppgtt)
ppgtt->pd_dirty_engines = ALL_ENGINES; ppgtt->pd_dirty_engines = ALL_ENGINES;
} }
static int gen8_ppgtt_notify_vgt(struct i915_ppgtt *ppgtt, bool create) static void gen8_ppgtt_notify_vgt(struct i915_ppgtt *ppgtt, bool create)
{ {
struct i915_address_space *vm = &ppgtt->vm; struct drm_i915_private *dev_priv = ppgtt->vm.i915;
struct drm_i915_private *dev_priv = vm->i915;
enum vgt_g2v_type msg; enum vgt_g2v_type msg;
int i; int i;
...@@ -839,7 +838,9 @@ static int gen8_ppgtt_notify_vgt(struct i915_ppgtt *ppgtt, bool create) ...@@ -839,7 +838,9 @@ static int gen8_ppgtt_notify_vgt(struct i915_ppgtt *ppgtt, bool create)
else else
atomic_dec(px_used(ppgtt->pd)); atomic_dec(px_used(ppgtt->pd));
if (i915_vm_is_4lvl(vm)) { mutex_lock(&dev_priv->vgpu.lock);
if (i915_vm_is_4lvl(&ppgtt->vm)) {
const u64 daddr = px_dma(ppgtt->pd); const u64 daddr = px_dma(ppgtt->pd);
I915_WRITE(vgtif_reg(pdp[0].lo), lower_32_bits(daddr)); I915_WRITE(vgtif_reg(pdp[0].lo), lower_32_bits(daddr));
...@@ -859,9 +860,10 @@ static int gen8_ppgtt_notify_vgt(struct i915_ppgtt *ppgtt, bool create) ...@@ -859,9 +860,10 @@ static int gen8_ppgtt_notify_vgt(struct i915_ppgtt *ppgtt, bool create)
VGT_G2V_PPGTT_L3_PAGE_TABLE_DESTROY); VGT_G2V_PPGTT_L3_PAGE_TABLE_DESTROY);
} }
/* g2v_notify atomically (via hv trap) consumes the message packet. */
I915_WRITE(vgtif_reg(g2v_notify), msg); I915_WRITE(vgtif_reg(g2v_notify), msg);
return 0; mutex_unlock(&dev_priv->vgpu.lock);
} }
/* Index shifts into the pagetable are offset by GEN8_PTE_SHIFT [12] */ /* Index shifts into the pagetable are offset by GEN8_PTE_SHIFT [12] */
......
...@@ -94,6 +94,7 @@ void i915_detect_vgpu(struct drm_i915_private *dev_priv) ...@@ -94,6 +94,7 @@ void i915_detect_vgpu(struct drm_i915_private *dev_priv)
dev_priv->vgpu.caps = readl(shared_area + vgtif_offset(vgt_caps)); dev_priv->vgpu.caps = readl(shared_area + vgtif_offset(vgt_caps));
dev_priv->vgpu.active = true; dev_priv->vgpu.active = true;
mutex_init(&dev_priv->vgpu.lock);
DRM_INFO("Virtual GPU for Intel GVT-g detected.\n"); DRM_INFO("Virtual GPU for Intel GVT-g detected.\n");
out: out:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment