drm: etnaviv: clean up submit_bo()
As we now store the etnaviv_vram_mapping, we no longer need to store the iova itself: we can get this directly from the mapping structure. Arrange for submit_bo() to return a pointer to etnaviv_gem_submit_bo, and directly access mapping->iova when applying relocations. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
This commit is contained in:
parent
b6325f4099
commit
8779aa8f8b
|
@ -88,6 +88,12 @@ static inline bool is_active(struct etnaviv_gem_object *etnaviv_obj)
|
|||
|
||||
#define MAX_CMDS 4
|
||||
|
||||
struct etnaviv_gem_submit_bo {
|
||||
u32 flags;
|
||||
struct etnaviv_gem_object *obj;
|
||||
struct etnaviv_vram_mapping *mapping;
|
||||
};
|
||||
|
||||
/* Created per submit-ioctl, to track bo's and cmdstream bufs, etc,
|
||||
* associated with the cmdstream submission for synchronization (and
|
||||
* make it easier to unwind when things go wrong, etc). This only
|
||||
|
@ -99,12 +105,7 @@ struct etnaviv_gem_submit {
|
|||
struct ww_acquire_ctx ticket;
|
||||
u32 fence;
|
||||
unsigned int nr_bos;
|
||||
struct {
|
||||
u32 flags;
|
||||
struct etnaviv_gem_object *obj;
|
||||
struct etnaviv_vram_mapping *mapping;
|
||||
u32 iova;
|
||||
} bos[0];
|
||||
struct etnaviv_gem_submit_bo bos[0];
|
||||
};
|
||||
|
||||
int etnaviv_gem_wait_bo(struct etnaviv_gpu *gpu, struct drm_gem_object *obj,
|
||||
|
|
|
@ -190,7 +190,6 @@ static void submit_unpin_objects(struct etnaviv_gem_submit *submit)
|
|||
if (submit->bos[i].flags & BO_PINNED)
|
||||
etnaviv_gem_mapping_unreference(submit->bos[i].mapping);
|
||||
|
||||
submit->bos[i].iova = 0;
|
||||
submit->bos[i].mapping = NULL;
|
||||
submit->bos[i].flags &= ~BO_PINNED;
|
||||
}
|
||||
|
@ -213,14 +212,13 @@ static int submit_pin_objects(struct etnaviv_gem_submit *submit)
|
|||
|
||||
submit->bos[i].flags |= BO_PINNED;
|
||||
submit->bos[i].mapping = mapping;
|
||||
submit->bos[i].iova = mapping->iova;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int submit_bo(struct etnaviv_gem_submit *submit, u32 idx,
|
||||
struct etnaviv_gem_object **obj, u32 *iova)
|
||||
struct etnaviv_gem_submit_bo **bo)
|
||||
{
|
||||
if (idx >= submit->nr_bos) {
|
||||
DRM_ERROR("invalid buffer index: %u (out of %u)\n",
|
||||
|
@ -228,10 +226,7 @@ static int submit_bo(struct etnaviv_gem_submit *submit, u32 idx,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (obj)
|
||||
*obj = submit->bos[idx].obj;
|
||||
if (iova)
|
||||
*iova = submit->bos[idx].iova;
|
||||
*bo = &submit->bos[idx];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -247,8 +242,8 @@ static int submit_reloc(struct etnaviv_gem_submit *submit, void *stream,
|
|||
|
||||
for (i = 0; i < nr_relocs; i++) {
|
||||
const struct drm_etnaviv_gem_submit_reloc *r = relocs + i;
|
||||
struct etnaviv_gem_object *bobj;
|
||||
u32 iova, off;
|
||||
struct etnaviv_gem_submit_bo *bo;
|
||||
u32 off;
|
||||
|
||||
if (unlikely(r->flags)) {
|
||||
DRM_ERROR("invalid reloc flags\n");
|
||||
|
@ -270,17 +265,16 @@ static int submit_reloc(struct etnaviv_gem_submit *submit, void *stream,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = submit_bo(submit, r->reloc_idx, &bobj, &iova);
|
||||
ret = submit_bo(submit, r->reloc_idx, &bo);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (r->reloc_offset >=
|
||||
bobj->base.size - sizeof(*ptr)) {
|
||||
if (r->reloc_offset >= bo->obj->base.size - sizeof(*ptr)) {
|
||||
DRM_ERROR("relocation %u outside object", i);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ptr[off] = iova + r->reloc_offset;
|
||||
ptr[off] = bo->mapping->iova + r->reloc_offset;
|
||||
|
||||
last_offset = off;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue