stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] drm/i915/gvt: update vgpu workload head pointer correctly
@ 2019-08-27  8:39 Xiaolin Zhang
  2019-08-28  6:07 ` Zhenyu Wang
  0 siblings, 1 reply; 2+ messages in thread
From: Xiaolin Zhang @ 2019-08-27  8:39 UTC (permalink / raw)
  To: intel-gvt-dev; +Cc: Xiaolin Zhang, stable

when creating a vGPU workload, the guest context head pointer should
be updated correctly by comparing with the exsiting workload in the
guest worklod queue including the current running context.

in some situation, there is a running context A and then received 2 new
vGPU workload context B and A. in the new workload context A, it's head
pointer should be updated with the running context A's tail.

Fixes: 09975b861aa0 ("drm/i915/execlists: Disable preemption under GVT")
Fixes: 22b7a426bbe1 ("drm/i915/execlists: Preempt-to-busy")

v2: walk through guest workload list in backward way.

Cc: stable@vger.kernel.org
Signed-off-by: Xiaolin Zhang <xiaolin.zhang@intel.com>
---
 drivers/gpu/drm/i915/gvt/scheduler.c | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/i915/gvt/scheduler.c b/drivers/gpu/drm/i915/gvt/scheduler.c
index 8940fa8..166b998 100644
--- a/drivers/gpu/drm/i915/gvt/scheduler.c
+++ b/drivers/gpu/drm/i915/gvt/scheduler.c
@@ -1438,9 +1438,6 @@ static int prepare_mm(struct intel_vgpu_workload *workload)
 #define same_context(a, b) (((a)->context_id == (b)->context_id) && \
 		((a)->lrca == (b)->lrca))
 
-#define get_last_workload(q) \
-	(list_empty(q) ? NULL : container_of(q->prev, \
-	struct intel_vgpu_workload, list))
 /**
  * intel_vgpu_create_workload - create a vGPU workload
  * @vgpu: a vGPU
@@ -1460,7 +1457,7 @@ intel_vgpu_create_workload(struct intel_vgpu *vgpu, int ring_id,
 {
 	struct intel_vgpu_submission *s = &vgpu->submission;
 	struct list_head *q = workload_q_head(vgpu, ring_id);
-	struct intel_vgpu_workload *last_workload = get_last_workload(q);
+	struct intel_vgpu_workload *last_workload = NULL;
 	struct intel_vgpu_workload *workload = NULL;
 	struct drm_i915_private *dev_priv = vgpu->gvt->dev_priv;
 	u64 ring_context_gpa;
@@ -1486,15 +1483,20 @@ intel_vgpu_create_workload(struct intel_vgpu *vgpu, int ring_id,
 	head &= RB_HEAD_OFF_MASK;
 	tail &= RB_TAIL_OFF_MASK;
 
-	if (last_workload && same_context(&last_workload->ctx_desc, desc)) {
-		gvt_dbg_el("ring id %d cur workload == last\n", ring_id);
-		gvt_dbg_el("ctx head %x real head %lx\n", head,
-				last_workload->rb_tail);
-		/*
-		 * cannot use guest context head pointer here,
-		 * as it might not be updated at this time
-		 */
-		head = last_workload->rb_tail;
+	list_for_each_entry_reverse(last_workload, q, list) {
+
+		if (same_context(&last_workload->ctx_desc, desc)) {
+			gvt_dbg_el("ring id %d cur workload == last\n",
+					ring_id);
+			gvt_dbg_el("ctx head %x real head %lx\n", head,
+					last_workload->rb_tail);
+			/*
+			 * cannot use guest context head pointer here,
+			 * as it might not be updated at this time
+			 */
+			head = last_workload->rb_tail;
+			break;
+		}
 	}
 
 	gvt_dbg_el("ring id %d begin a new workload\n", ring_id);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] drm/i915/gvt: update vgpu workload head pointer correctly
  2019-08-27  8:39 [PATCH v2] drm/i915/gvt: update vgpu workload head pointer correctly Xiaolin Zhang
@ 2019-08-28  6:07 ` Zhenyu Wang
  0 siblings, 0 replies; 2+ messages in thread
From: Zhenyu Wang @ 2019-08-28  6:07 UTC (permalink / raw)
  To: Xiaolin Zhang; +Cc: intel-gvt-dev, stable

[-- Attachment #1: Type: text/plain, Size: 3495 bytes --]

On 2019.08.27 16:39:23 +0800, Xiaolin Zhang wrote:
> when creating a vGPU workload, the guest context head pointer should
> be updated correctly by comparing with the exsiting workload in the
> guest worklod queue including the current running context.
> 
> in some situation, there is a running context A and then received 2 new
> vGPU workload context B and A. in the new workload context A, it's head
> pointer should be updated with the running context A's tail.
> 
> Fixes: 09975b861aa0 ("drm/i915/execlists: Disable preemption under GVT")
> Fixes: 22b7a426bbe1 ("drm/i915/execlists: Preempt-to-busy")
> 
> v2: walk through guest workload list in backward way.
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: Xiaolin Zhang <xiaolin.zhang@intel.com>
> ---

Reviewed-by: Zhenyu Wang <zhenyuw@linux.intel.com>

Thanks for the fix!

>  drivers/gpu/drm/i915/gvt/scheduler.c | 28 +++++++++++++++-------------
>  1 file changed, 15 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gvt/scheduler.c b/drivers/gpu/drm/i915/gvt/scheduler.c
> index 8940fa8..166b998 100644
> --- a/drivers/gpu/drm/i915/gvt/scheduler.c
> +++ b/drivers/gpu/drm/i915/gvt/scheduler.c
> @@ -1438,9 +1438,6 @@ static int prepare_mm(struct intel_vgpu_workload *workload)
>  #define same_context(a, b) (((a)->context_id == (b)->context_id) && \
>  		((a)->lrca == (b)->lrca))
>  
> -#define get_last_workload(q) \
> -	(list_empty(q) ? NULL : container_of(q->prev, \
> -	struct intel_vgpu_workload, list))
>  /**
>   * intel_vgpu_create_workload - create a vGPU workload
>   * @vgpu: a vGPU
> @@ -1460,7 +1457,7 @@ intel_vgpu_create_workload(struct intel_vgpu *vgpu, int ring_id,
>  {
>  	struct intel_vgpu_submission *s = &vgpu->submission;
>  	struct list_head *q = workload_q_head(vgpu, ring_id);
> -	struct intel_vgpu_workload *last_workload = get_last_workload(q);
> +	struct intel_vgpu_workload *last_workload = NULL;
>  	struct intel_vgpu_workload *workload = NULL;
>  	struct drm_i915_private *dev_priv = vgpu->gvt->dev_priv;
>  	u64 ring_context_gpa;
> @@ -1486,15 +1483,20 @@ intel_vgpu_create_workload(struct intel_vgpu *vgpu, int ring_id,
>  	head &= RB_HEAD_OFF_MASK;
>  	tail &= RB_TAIL_OFF_MASK;
>  
> -	if (last_workload && same_context(&last_workload->ctx_desc, desc)) {
> -		gvt_dbg_el("ring id %d cur workload == last\n", ring_id);
> -		gvt_dbg_el("ctx head %x real head %lx\n", head,
> -				last_workload->rb_tail);
> -		/*
> -		 * cannot use guest context head pointer here,
> -		 * as it might not be updated at this time
> -		 */
> -		head = last_workload->rb_tail;
> +	list_for_each_entry_reverse(last_workload, q, list) {
> +
> +		if (same_context(&last_workload->ctx_desc, desc)) {
> +			gvt_dbg_el("ring id %d cur workload == last\n",
> +					ring_id);
> +			gvt_dbg_el("ctx head %x real head %lx\n", head,
> +					last_workload->rb_tail);
> +			/*
> +			 * cannot use guest context head pointer here,
> +			 * as it might not be updated at this time
> +			 */
> +			head = last_workload->rb_tail;
> +			break;
> +		}
>  	}
>  
>  	gvt_dbg_el("ring id %d begin a new workload\n", ring_id);
> -- 
> 2.7.4
> 
> _______________________________________________
> intel-gvt-dev mailing list
> intel-gvt-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gvt-dev

-- 
Open Source Technology Center, Intel ltd.

$gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-08-28  6:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-27  8:39 [PATCH v2] drm/i915/gvt: update vgpu workload head pointer correctly Xiaolin Zhang
2019-08-28  6:07 ` Zhenyu Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).