drm/nouveau/bo: add helper functions for handling pinned+mapped buffers
This is a common, awkward sequence. Let's wrap it up! Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
This commit is contained in:
parent
27cda22332
commit
561464ea54
|
@ -105,4 +105,32 @@ nvbo_kmap_obj_iovirtual(struct nouveau_bo *nvbo)
|
||||||
return ioptr;
|
return ioptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
nouveau_bo_unmap_unpin_unref(struct nouveau_bo **pnvbo)
|
||||||
|
{
|
||||||
|
if (*pnvbo) {
|
||||||
|
nouveau_bo_unmap(*pnvbo);
|
||||||
|
nouveau_bo_unpin(*pnvbo);
|
||||||
|
nouveau_bo_ref(NULL, pnvbo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
nouveau_bo_new_pin_map(struct nouveau_cli *cli, u64 size, int align, u32 flags,
|
||||||
|
struct nouveau_bo **pnvbo)
|
||||||
|
{
|
||||||
|
int ret = nouveau_bo_new(cli, size, align, flags,
|
||||||
|
0, 0, NULL, NULL, pnvbo);
|
||||||
|
if (ret == 0) {
|
||||||
|
ret = nouveau_bo_pin(*pnvbo, flags, true);
|
||||||
|
if (ret == 0) {
|
||||||
|
ret = nouveau_bo_map(*pnvbo);
|
||||||
|
if (ret == 0)
|
||||||
|
return ret;
|
||||||
|
nouveau_bo_unpin(*pnvbo);
|
||||||
|
}
|
||||||
|
nouveau_bo_ref(NULL, pnvbo);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue