Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2074746ybp; Thu, 10 Oct 2019 01:43:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqywtM4IjPqolzBk1HAXZBtB8+gyGoy4WwwGL6MZNRK+2RDgxntt4oAXwLswYgkl7NfQFTQk X-Received: by 2002:a17:906:cd11:: with SMTP id oz17mr7022078ejb.71.1570697030279; Thu, 10 Oct 2019 01:43:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570697030; cv=none; d=google.com; s=arc-20160816; b=wCkU2vqO6ICNPeUvuxT7u/7vLa+DHgAGm+IDT0Y8lWKa19mKIizCFUih+rNfqNUg6F pgCzvgUkgYj/LC8e2MVFym7g1Tc/39x9X4PlyHrWnhG/F+4a7oWh4+1UqtI1LJTEDcOA hD6d4hjbRal3yg/tPIR2/JoHRxYqKBaJG5S/SdexNtrwkzWQb9gogk4NVb6UO0CCaF2r vHLGErYZp0mZkf+aeLCelulc7iaS6wM5FeXLPNrUDYL0vjIUZrbHPWGttsjrfWqbd3fF 31tJvftwk0hVkjOiZnOwKRqQgaSaZGstyw8RMXmwbrc8GEmHmt0fdviTou5ADdNBA6Wh OBxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=U3paWF47joUVYZgKJ3d7c43DxUjaCaITlW4q9Evg/Kg=; b=k9T445kS9Smxe4ROIzsW1GstxKbNwDjXDXskCX92u9g76r7kth6TSG3qsxiQKaAMvD IeN9YGMGNFBK7ybgHmOAlvMtgrIOG5BSf0Ue85HxePnpxhPUuTHo211jnQrjIKYvBw/r CtHP96IF1UqscSCYahuHMK9njayIVci5z9kOCo82iswTkfqKyyO9vxfGtTNBWdFjbXYn ZL8zF0YAVB11Uorev8eJTawuQPibUpQUrk+S6V0lgeMKGouofJqNYztLoKJ2HpQp1sLZ KTZePE565VpcwWs1ZWfvugfcLU/wFnD7LeKj45AqTQwSTo7T88LcdDGagwy8iGmtth1b 0Z+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=A1lUSkjQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k9si3260427edb.56.2019.10.10.01.43.26; Thu, 10 Oct 2019 01:43:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=A1lUSkjQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387547AbfJJIkl (ORCPT + 99 others); Thu, 10 Oct 2019 04:40:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:44762 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388148AbfJJIkj (ORCPT ); Thu, 10 Oct 2019 04:40:39 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E53A020B7C; Thu, 10 Oct 2019 08:40:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570696838; bh=96FtM7irNPIaBVtqL8BGe3vDnYg8ARuZ5kTyXkvGf70=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A1lUSkjQLmZlziq1h8htFjfldpf0R/Y3FMXxafAxRCVqdaadBU79YIr0aC01lhNw7 uekkgkWg9XGqkcMQSlQ7X7DnX+xOjPr7yeXN9WIw1gWLRSCb3JhO4CYXNIVGQKUW3w wJhjhHTuRbfMoV1AfS1mSluSsckWYgIYTpayGBd8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiaolin Zhang , Zhenyu Wang Subject: [PATCH 5.3 070/148] drm/i915/gvt: update vgpu workload head pointer correctly Date: Thu, 10 Oct 2019 10:35:31 +0200 Message-Id: <20191010083615.656859584@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191010083609.660878383@linuxfoundation.org> References: <20191010083609.660878383@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiaolin Zhang commit 0a3242bdb47713e09cb004a0ba4947d3edf82d8a upstream. 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. v2: walk through guest workload list in backward way. Cc: stable@vger.kernel.org Signed-off-by: Xiaolin Zhang Reviewed-by: Zhenyu Wang Signed-off-by: Zhenyu Wang Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/i915/gvt/scheduler.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) --- a/drivers/gpu/drm/i915/gvt/scheduler.c +++ b/drivers/gpu/drm/i915/gvt/scheduler.c @@ -1424,9 +1424,6 @@ static int prepare_mm(struct intel_vgpu_ #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 @@ -1446,7 +1443,7 @@ intel_vgpu_create_workload(struct intel_ { 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; @@ -1472,15 +1469,20 @@ intel_vgpu_create_workload(struct intel_ 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);