diff options
author | Changbin Du <changbin.du@intel.com> | 2017-05-04 06:36:54 -0400 |
---|---|---|
committer | Zhenyu Wang <zhenyuw@linux.intel.com> | 2017-06-08 01:59:14 -0400 |
commit | 5d0f5de16ef3d127469aa09dcdf07bec5174937f (patch) | |
tree | cec02cf59baf5281b009af5e78bd827552dec430 | |
parent | ffc197763e636b928963c5dd9a3eaea8146345e3 (diff) |
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: Changbin Du <changbin.du@intel.com>
Reviewed-by: Zhi Wang <zhi.a.wang@intel.com>
Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
-rw-r--r-- | drivers/gpu/drm/i915/gvt/execlist.c | 56 |
1 files changed, 23 insertions, 33 deletions
diff --git a/drivers/gpu/drm/i915/gvt/execlist.c b/drivers/gpu/drm/i915/gvt/execlist.c index dca989eb2d42..8bba38fa19b8 100644 --- a/drivers/gpu/drm/i915/gvt/execlist.c +++ b/drivers/gpu/drm/i915/gvt/execlist.c | |||
@@ -708,53 +708,43 @@ static int submit_context(struct intel_vgpu *vgpu, int ring_id, | |||
708 | int intel_vgpu_submit_execlist(struct intel_vgpu *vgpu, int ring_id) | 708 | int intel_vgpu_submit_execlist(struct intel_vgpu *vgpu, int ring_id) |
709 | { | 709 | { |
710 | struct intel_vgpu_execlist *execlist = &vgpu->execlist[ring_id]; | 710 | struct intel_vgpu_execlist *execlist = &vgpu->execlist[ring_id]; |
711 | struct execlist_ctx_descriptor_format *desc[2], valid_desc[2]; | 711 | struct execlist_ctx_descriptor_format desc[2]; |
712 | unsigned long valid_desc_bitmap = 0; | 712 | int i, ret; |
713 | bool emulate_schedule_in = true; | ||
714 | int ret; | ||
715 | int i; | ||
716 | 713 | ||
717 | memset(valid_desc, 0, sizeof(valid_desc)); | 714 | desc[0] = *get_desc_from_elsp_dwords(&execlist->elsp_dwords, 1); |
715 | desc[1] = *get_desc_from_elsp_dwords(&execlist->elsp_dwords, 0); | ||
718 | 716 | ||
719 | desc[0] = get_desc_from_elsp_dwords(&execlist->elsp_dwords, 1); | 717 | if (!desc[0].valid) { |
720 | desc[1] = get_desc_from_elsp_dwords(&execlist->elsp_dwords, 0); | 718 | gvt_vgpu_err("invalid elsp submission, desc0 is invalid\n"); |
719 | goto inv_desc; | ||
720 | } | ||
721 | 721 | ||
722 | for (i = 0; i < 2; i++) { | 722 | for (i = 0; i < ARRAY_SIZE(desc); i++) { |
723 | if (!desc[i]->valid) | 723 | if (!desc[i].valid) |
724 | continue; | 724 | continue; |
725 | 725 | if (!desc[i].privilege_access) { | |
726 | if (!desc[i]->privilege_access) { | ||
727 | gvt_vgpu_err("unexpected GGTT elsp submission\n"); | 726 | gvt_vgpu_err("unexpected GGTT elsp submission\n"); |
728 | return -EINVAL; | 727 | goto inv_desc; |
729 | } | 728 | } |
730 | |||
731 | /* TODO: add another guest context checks here. */ | ||
732 | set_bit(i, &valid_desc_bitmap); | ||
733 | valid_desc[i] = *desc[i]; | ||
734 | } | ||
735 | |||
736 | if (!valid_desc_bitmap) { | ||
737 | gvt_vgpu_err("no valid desc in a elsp submission\n"); | ||
738 | return -EINVAL; | ||
739 | } | ||
740 | |||
741 | if (!test_bit(0, (void *)&valid_desc_bitmap) && | ||
742 | test_bit(1, (void *)&valid_desc_bitmap)) { | ||
743 | gvt_vgpu_err("weird elsp submission, desc 0 is not valid\n"); | ||
744 | return -EINVAL; | ||
745 | } | 729 | } |
746 | 730 | ||
747 | /* submit workload */ | 731 | /* submit workload */ |
748 | for_each_set_bit(i, (void *)&valid_desc_bitmap, 2) { | 732 | for (i = 0; i < ARRAY_SIZE(desc); i++) { |
749 | ret = submit_context(vgpu, ring_id, &valid_desc[i], | 733 | if (!desc[i].valid) |
750 | emulate_schedule_in); | 734 | continue; |
735 | ret = submit_context(vgpu, ring_id, &desc[i], i == 0); | ||
751 | if (ret) { | 736 | if (ret) { |
752 | gvt_vgpu_err("fail to schedule workload\n"); | 737 | gvt_vgpu_err("failed to submit desc %d\n", i); |
753 | return ret; | 738 | return ret; |
754 | } | 739 | } |
755 | emulate_schedule_in = false; | ||
756 | } | 740 | } |
741 | |||
757 | return 0; | 742 | return 0; |
743 | |||
744 | inv_desc: | ||
745 | gvt_vgpu_err("descriptors content: desc0 %08x %08x desc1 %08x %08x\n", | ||
746 | desc[0].udw, desc[0].ldw, desc[1].udw, desc[1].ldw); | ||
747 | return -EINVAL; | ||
758 | } | 748 | } |
759 | 749 | ||
760 | static void init_vgpu_execlist(struct intel_vgpu *vgpu, int ring_id) | 750 | static void init_vgpu_execlist(struct intel_vgpu *vgpu, int ring_id) |