提交 d2a84a76 编写于 作者: C Chris Wilson

drm/i915: Use radixtree to jump start intel_partial_pages()

We can use the radixtree index of the obj->pages to find the start
position of the desired partial range.
Signed-off-by: NChris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: NTvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20161028125858.23563-11-chris@chris-wilson.co.uk
上级 96d77634
...@@ -3584,35 +3584,47 @@ intel_partial_pages(const struct i915_ggtt_view *view, ...@@ -3584,35 +3584,47 @@ intel_partial_pages(const struct i915_ggtt_view *view,
struct drm_i915_gem_object *obj) struct drm_i915_gem_object *obj)
{ {
struct sg_table *st; struct sg_table *st;
struct scatterlist *sg; struct scatterlist *sg, *iter;
struct sg_page_iter obj_sg_iter; unsigned int count = view->params.partial.size;
unsigned int offset;
int ret = -ENOMEM; int ret = -ENOMEM;
st = kmalloc(sizeof(*st), GFP_KERNEL); st = kmalloc(sizeof(*st), GFP_KERNEL);
if (!st) if (!st)
goto err_st_alloc; goto err_st_alloc;
ret = sg_alloc_table(st, view->params.partial.size, GFP_KERNEL); ret = sg_alloc_table(st, count, GFP_KERNEL);
if (ret) if (ret)
goto err_sg_alloc; goto err_sg_alloc;
iter = i915_gem_object_get_sg(obj,
view->params.partial.offset,
&offset);
GEM_BUG_ON(!iter);
sg = st->sgl; sg = st->sgl;
st->nents = 0; st->nents = 0;
for_each_sg_page(obj->pages->sgl, &obj_sg_iter, obj->pages->nents, do {
view->params.partial.offset) unsigned int len;
{
if (st->nents >= view->params.partial.size)
break;
sg_set_page(sg, NULL, PAGE_SIZE, 0); len = min(iter->length - (offset << PAGE_SHIFT),
sg_dma_address(sg) = sg_page_iter_dma_address(&obj_sg_iter); count << PAGE_SHIFT);
sg_dma_len(sg) = PAGE_SIZE; sg_set_page(sg, NULL, len, 0);
sg_dma_address(sg) =
sg_dma_address(iter) + (offset << PAGE_SHIFT);
sg_dma_len(sg) = len;
sg = sg_next(sg);
st->nents++; st->nents++;
count -= len >> PAGE_SHIFT;
if (count == 0) {
sg_mark_end(sg);
return st;
} }
return st; sg = __sg_next(sg);
iter = __sg_next(iter);
offset = 0;
} while (1);
err_sg_alloc: err_sg_alloc:
kfree(st); kfree(st);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册