Commit 5d0f5de1 authored by Changbin Du's avatar Changbin Du Committed by Zhenyu Wang

drm/i915/gvt: refactor function intel_vgpu_submit_execlist

The function intel_vgpu_submit_execlist could be more simpler. It
actually does:
  1) validate the submission. The first context must be valid,
     and all two must be privilege_access.
  2) submit valid contexts. The first one need emulate schedule_in.

We do not need a bitmap, valid desc copy valid_desc. Local variable
emulate_schedule_in also can be optimized out.

v2: dump desc content in err msg (Zhi Wang)
Signed-off-by: default avatarChangbin Du <changbin.du@intel.com>
Reviewed-by: default avatarZhi Wang <zhi.a.wang@intel.com>
Signed-off-by: default avatarZhenyu Wang <zhenyuw@linux.intel.com>
parent ffc19776
...@@ -708,53 +708,43 @@ static int submit_context(struct intel_vgpu *vgpu, int ring_id, ...@@ -708,53 +708,43 @@ static int submit_context(struct intel_vgpu *vgpu, int ring_id,
int intel_vgpu_submit_execlist(struct intel_vgpu *vgpu, int ring_id) int intel_vgpu_submit_execlist(struct intel_vgpu *vgpu, int ring_id)
{ {
struct intel_vgpu_execlist *execlist = &vgpu->execlist[ring_id]; struct intel_vgpu_execlist *execlist = &vgpu->execlist[ring_id];
struct execlist_ctx_descriptor_format *desc[2], valid_desc[2]; struct execlist_ctx_descriptor_format desc[2];
unsigned long valid_desc_bitmap = 0; int i, ret;
bool emulate_schedule_in = true;
int ret;
int i;
memset(valid_desc, 0, sizeof(valid_desc)); desc[0] = *get_desc_from_elsp_dwords(&execlist->elsp_dwords, 1);
desc[1] = *get_desc_from_elsp_dwords(&execlist->elsp_dwords, 0);
desc[0] = get_desc_from_elsp_dwords(&execlist->elsp_dwords, 1); if (!desc[0].valid) {
desc[1] = get_desc_from_elsp_dwords(&execlist->elsp_dwords, 0); gvt_vgpu_err("invalid elsp submission, desc0 is invalid\n");
goto inv_desc;
}
for (i = 0; i < 2; i++) { for (i = 0; i < ARRAY_SIZE(desc); i++) {
if (!desc[i]->valid) if (!desc[i].valid)
continue; continue;
if (!desc[i].privilege_access) {
if (!desc[i]->privilege_access) {
gvt_vgpu_err("unexpected GGTT elsp submission\n"); gvt_vgpu_err("unexpected GGTT elsp submission\n");
return -EINVAL; goto inv_desc;
} }
/* TODO: add another guest context checks here. */
set_bit(i, &valid_desc_bitmap);
valid_desc[i] = *desc[i];
}
if (!valid_desc_bitmap) {
gvt_vgpu_err("no valid desc in a elsp submission\n");
return -EINVAL;
}
if (!test_bit(0, (void *)&valid_desc_bitmap) &&
test_bit(1, (void *)&valid_desc_bitmap)) {
gvt_vgpu_err("weird elsp submission, desc 0 is not valid\n");
return -EINVAL;
} }
/* submit workload */ /* submit workload */
for_each_set_bit(i, (void *)&valid_desc_bitmap, 2) { for (i = 0; i < ARRAY_SIZE(desc); i++) {
ret = submit_context(vgpu, ring_id, &valid_desc[i], if (!desc[i].valid)
emulate_schedule_in); continue;
ret = submit_context(vgpu, ring_id, &desc[i], i == 0);
if (ret) { if (ret) {
gvt_vgpu_err("fail to schedule workload\n"); gvt_vgpu_err("failed to submit desc %d\n", i);
return ret; return ret;
} }
emulate_schedule_in = false;
} }
return 0; return 0;
inv_desc:
gvt_vgpu_err("descriptors content: desc0 %08x %08x desc1 %08x %08x\n",
desc[0].udw, desc[0].ldw, desc[1].udw, desc[1].ldw);
return -EINVAL;
} }
static void init_vgpu_execlist(struct intel_vgpu *vgpu, int ring_id) static void init_vgpu_execlist(struct intel_vgpu *vgpu, int ring_id)
......
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