freedreno: add interface to get buffer address

Needed for clover/OpenCL.  Fortunately the kernel interface is already
in place.

Include a stub _put_iova() so mesa can tell us when it no longer needs
the buffer to be pinned.  There is no kernel interface for this (yet),
but at least if we want to unpin buffers we won't need mesa changes.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
main
Rob Clark 2018-02-25 14:56:18 -05:00
parent 4f08bfe96d
commit 1384c08123
4 changed files with 27 additions and 0 deletions

View File

@ -195,6 +195,16 @@ out_unlock:
return bo; return bo;
} }
uint64_t fd_bo_get_iova(struct fd_bo *bo)
{
return bo->funcs->iova(bo);
}
void fd_bo_put_iova(struct fd_bo *bo)
{
/* currently a no-op */
}
struct fd_bo * fd_bo_ref(struct fd_bo *bo) struct fd_bo * fd_bo_ref(struct fd_bo *bo)
{ {
atomic_inc(&bo->refcnt); atomic_inc(&bo->refcnt);

View File

@ -95,6 +95,7 @@ enum fd_version {
FD_VERSION_UNLIMITED_CMDS = 1, /* submits w/ >4 cmd buffers (growable ringbuffer) */ FD_VERSION_UNLIMITED_CMDS = 1, /* submits w/ >4 cmd buffers (growable ringbuffer) */
FD_VERSION_FENCE_FD = 2, /* submit command supports in/out fences */ FD_VERSION_FENCE_FD = 2, /* submit command supports in/out fences */
FD_VERSION_SUBMIT_QUEUES = 3, /* submit queues and multiple priority levels */ FD_VERSION_SUBMIT_QUEUES = 3, /* submit queues and multiple priority levels */
FD_VERSION_BO_IOVA = 3, /* supports fd_bo_get/put_iova() */
}; };
enum fd_version fd_device_version(struct fd_device *dev); enum fd_version fd_device_version(struct fd_device *dev);
@ -123,6 +124,8 @@ struct fd_bo *fd_bo_from_handle(struct fd_device *dev,
uint32_t handle, uint32_t size); uint32_t handle, uint32_t size);
struct fd_bo * fd_bo_from_name(struct fd_device *dev, uint32_t name); struct fd_bo * fd_bo_from_name(struct fd_device *dev, uint32_t name);
struct fd_bo * fd_bo_from_dmabuf(struct fd_device *dev, int fd); struct fd_bo * fd_bo_from_dmabuf(struct fd_device *dev, int fd);
uint64_t fd_bo_get_iova(struct fd_bo *bo);
void fd_bo_put_iova(struct fd_bo *bo);
struct fd_bo * fd_bo_ref(struct fd_bo *bo); struct fd_bo * fd_bo_ref(struct fd_bo *bo);
void fd_bo_del(struct fd_bo *bo); void fd_bo_del(struct fd_bo *bo);
int fd_bo_get_name(struct fd_bo *bo, uint32_t *name); int fd_bo_get_name(struct fd_bo *bo, uint32_t *name);

View File

@ -157,6 +157,7 @@ struct fd_bo_funcs {
int (*cpu_prep)(struct fd_bo *bo, struct fd_pipe *pipe, uint32_t op); int (*cpu_prep)(struct fd_bo *bo, struct fd_pipe *pipe, uint32_t op);
void (*cpu_fini)(struct fd_bo *bo); void (*cpu_fini)(struct fd_bo *bo);
int (*madvise)(struct fd_bo *bo, int willneed); int (*madvise)(struct fd_bo *bo, int willneed);
uint64_t (*iova)(struct fd_bo *bo);
void (*destroy)(struct fd_bo *bo); void (*destroy)(struct fd_bo *bo);
}; };

View File

@ -108,6 +108,18 @@ static int msm_bo_madvise(struct fd_bo *bo, int willneed)
return req.retained; return req.retained;
} }
static uint64_t msm_bo_iova(struct fd_bo *bo)
{
struct drm_msm_gem_info req = {
.handle = bo->handle,
.flags = MSM_INFO_IOVA,
};
drmCommandWriteRead(bo->dev->fd, DRM_MSM_GEM_INFO, &req, sizeof(req));
return req.offset;
}
static void msm_bo_destroy(struct fd_bo *bo) static void msm_bo_destroy(struct fd_bo *bo)
{ {
struct msm_bo *msm_bo = to_msm_bo(bo); struct msm_bo *msm_bo = to_msm_bo(bo);
@ -120,6 +132,7 @@ static const struct fd_bo_funcs funcs = {
.cpu_prep = msm_bo_cpu_prep, .cpu_prep = msm_bo_cpu_prep,
.cpu_fini = msm_bo_cpu_fini, .cpu_fini = msm_bo_cpu_fini,
.madvise = msm_bo_madvise, .madvise = msm_bo_madvise,
.iova = msm_bo_iova,
.destroy = msm_bo_destroy, .destroy = msm_bo_destroy,
}; };