summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/i915
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2016-10-19 11:11:46 +0100
committerZhenyu Wang <zhenyuw@linux.intel.com>2016-10-20 17:31:34 +0800
commita28615041ea2d1645143b868cd5ea65e9cf28381 (patch)
treef2e8ebf87ec903b7709a9578c7628b7fae8e3688 /drivers/gpu/drm/i915
parentbcd0aeded478f1ed6dfbbeafc3e2581c4021a99c (diff)
drm/i915/gvt: Use common mapping routines for shadow_bb object
We have the ability to map an object, so use it rather than opencode it badly. Note that the object remains permanently pinned, this is poor practise. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
Diffstat (limited to 'drivers/gpu/drm/i915')
-rw-r--r--drivers/gpu/drm/i915/gvt/cmd_parser.c21
-rw-r--r--drivers/gpu/drm/i915/gvt/execlist.c2
2 files changed, 7 insertions, 16 deletions
diff --git a/drivers/gpu/drm/i915/gvt/cmd_parser.c b/drivers/gpu/drm/i915/gvt/cmd_parser.c
index 153943a9411e..ff719e77a594 100644
--- a/drivers/gpu/drm/i915/gvt/cmd_parser.c
+++ b/drivers/gpu/drm/i915/gvt/cmd_parser.c
@@ -1650,18 +1650,10 @@ static int perform_bb_shadow(struct parser_exec_state *s)
entry_obj->len = bb_size;
INIT_LIST_HEAD(&entry_obj->list);
- ret = i915_gem_object_get_pages(entry_obj->obj);
- if (ret)
+ dst = i915_gem_object_pin_map(entry_obj->obj, I915_MAP_WB);
+ if (IS_ERR(dst)) {
+ ret = PTR_ERR(dst);
goto put_obj;
-
- i915_gem_object_pin_pages(entry_obj->obj);
-
- /* get the va of the shadow batch buffer */
- dst = (void *)vmap_batch(entry_obj->obj, 0, bb_size);
- if (!dst) {
- gvt_err("failed to vmap shadow batch\n");
- ret = -ENOMEM;
- goto unpin_src;
}
ret = i915_gem_object_set_to_cpu_domain(entry_obj->obj, false);
@@ -1675,7 +1667,8 @@ static int perform_bb_shadow(struct parser_exec_state *s)
/* copy batch buffer to shadow batch buffer*/
ret = copy_gma_to_hva(s->vgpu, s->vgpu->gtt.ggtt_mm,
- gma, gma + bb_size, dst);
+ gma, gma + bb_size,
+ dst);
if (ret) {
gvt_err("fail to copy guest ring buffer\n");
goto unmap_src;
@@ -1696,9 +1689,7 @@ static int perform_bb_shadow(struct parser_exec_state *s)
return 0;
unmap_src:
- vunmap(dst);
-unpin_src:
- i915_gem_object_unpin_pages(entry_obj->obj);
+ i915_gem_object_unpin_map(entry_obj->obj);
put_obj:
i915_gem_object_put(entry_obj->obj);
free_entry:
diff --git a/drivers/gpu/drm/i915/gvt/execlist.c b/drivers/gpu/drm/i915/gvt/execlist.c
index 88430ca23504..d4bd29306d84 100644
--- a/drivers/gpu/drm/i915/gvt/execlist.c
+++ b/drivers/gpu/drm/i915/gvt/execlist.c
@@ -505,8 +505,8 @@ static void release_shadow_batch_buffer(struct intel_vgpu_workload *workload)
list_for_each_entry_safe(entry_obj, temp, &workload->shadow_bb,
list) {
+ i915_gem_object_unpin_map(entry_obj->obj);
i915_gem_object_put(entry_obj->obj);
- kvfree(entry_obj->va);
list_del(&entry_obj->list);
kfree(entry_obj);
}