Merge branch 'drm-intel-next-queued' into gvt-next
[muen/linux.git] / drivers / gpu / drm / i915 / gvt / cmd_parser.c
index a294427088d85e75b3b1208c093bfaca047b01a5..718ca08f95751af6303f1eb1b651f14cafe3ddc4 100644 (file)
@@ -813,15 +813,31 @@ static inline bool is_force_nonpriv_mmio(unsigned int offset)
 }
 
 static int force_nonpriv_reg_handler(struct parser_exec_state *s,
 }
 
 static int force_nonpriv_reg_handler(struct parser_exec_state *s,
-                                    unsigned int offset, unsigned int index)
+               unsigned int offset, unsigned int index, char *cmd)
 {
        struct intel_gvt *gvt = s->vgpu->gvt;
 {
        struct intel_gvt *gvt = s->vgpu->gvt;
-       unsigned int data = cmd_val(s, index + 1);
+       unsigned int data;
+       u32 ring_base;
+       u32 nopid;
+       struct drm_i915_private *dev_priv = s->vgpu->gvt->dev_priv;
+
+       if (!strcmp(cmd, "lri"))
+               data = cmd_val(s, index + 1);
+       else {
+               gvt_err("Unexpected forcenonpriv 0x%x write from cmd %s\n",
+                       offset, cmd);
+               return -EINVAL;
+       }
 
 
-       if (!intel_gvt_in_force_nonpriv_whitelist(gvt, data)) {
+       ring_base = dev_priv->engine[s->ring_id]->mmio_base;
+       nopid = i915_mmio_reg_offset(RING_NOPID(ring_base));
+
+       if (!intel_gvt_in_force_nonpriv_whitelist(gvt, data) &&
+                       data != nopid) {
                gvt_err("Unexpected forcenonpriv 0x%x LRI write, value=0x%x\n",
                        offset, data);
                gvt_err("Unexpected forcenonpriv 0x%x LRI write, value=0x%x\n",
                        offset, data);
-               return -EPERM;
+               patch_value(s, cmd_ptr(s, index), nopid);
+               return 0;
        }
        return 0;
 }
        }
        return 0;
 }
@@ -869,7 +885,7 @@ static int cmd_reg_handler(struct parser_exec_state *s,
                return -EINVAL;
 
        if (is_force_nonpriv_mmio(offset) &&
                return -EINVAL;
 
        if (is_force_nonpriv_mmio(offset) &&
-               force_nonpriv_reg_handler(s, offset, index))
+               force_nonpriv_reg_handler(s, offset, index, cmd))
                return -EPERM;
 
        if (offset == i915_mmio_reg_offset(DERRMR) ||
                return -EPERM;
 
        if (offset == i915_mmio_reg_offset(DERRMR) ||