Pull in updated UAPI and use kernel API version to enable softpin.
Since MSM_SUBMIT_BO_DUMP flag was added at same time, use that to
signal to kernel that cmdstream buffers are useful to dump for
debugging/cmdstream-traces.
Signed-off-by: Rob Clark <robdclark@gmail.com>
FD_VERSION_FENCE_FD = 2, /* submit command supports in/out fences */
FD_VERSION_SUBMIT_QUEUES = 3, /* submit queues and multiple priority levels */
FD_VERSION_BO_IOVA = 3, /* supports fd_bo_get/put_iova() */
+ FD_VERSION_SOFTPIN = 4, /* adds softpin, bo name, and dump flag */
};
enum fd_version fd_device_version(struct fd_device *dev);
struct fd_bo *bo;
#define FD_RELOC_READ 0x0001
#define FD_RELOC_WRITE 0x0002
+#define FD_RELOC_DUMP 0x0004
uint32_t flags;
uint32_t offset;
uint32_t or;
if (!msm_bo->offset) {
struct drm_msm_gem_info req = {
.handle = bo->handle,
+ .info = MSM_INFO_GET_OFFSET,
};
int ret;
return ret;
}
- msm_bo->offset = req.offset;
+ msm_bo->offset = req.value;
}
return 0;
{
struct drm_msm_gem_info req = {
.handle = bo->handle,
- .flags = MSM_INFO_IOVA,
+ .info = MSM_INFO_GET_IOVA,
};
int ret;
ret = drmCommandWriteRead(bo->dev->fd, DRM_MSM_GEM_INFO, &req, sizeof(req));
debug_assert(ret == 0);
- return req.offset;
+ return req.value;
}
static void msm_bo_destroy(struct fd_bo *bo)
__u32 handle; /* out */
};
-#define MSM_INFO_IOVA 0x01
-
-#define MSM_INFO_FLAGS (MSM_INFO_IOVA)
+/* Get or set GEM buffer info. The requested value can be passed
+ * directly in 'value', or for data larger than 64b 'value' is a
+ * pointer to userspace buffer, with 'len' specifying the number of
+ * bytes copied into that buffer. For info returned by pointer,
+ * calling the GEM_INFO ioctl with null 'value' will return the
+ * required buffer size in 'len'
+ */
+#define MSM_INFO_GET_OFFSET 0x00 /* get mmap() offset, returned by value */
+#define MSM_INFO_GET_IOVA 0x01 /* get iova, returned by value */
+#define MSM_INFO_SET_NAME 0x02 /* set the debug name (by pointer) */
+#define MSM_INFO_GET_NAME 0x03 /* get debug name, returned by pointer */
struct drm_msm_gem_info {
__u32 handle; /* in */
- __u32 flags; /* in - combination of MSM_INFO_* flags */
- __u64 offset; /* out, mmap() offset or iova */
+ __u32 info; /* in - one of MSM_INFO_* */
+ __u64 value; /* in or out */
+ __u32 len; /* in or out */
};
#define MSM_PREP_READ 0x01
*/
#define MSM_SUBMIT_BO_READ 0x0001
#define MSM_SUBMIT_BO_WRITE 0x0002
+#define MSM_SUBMIT_BO_DUMP 0x0004
-#define MSM_SUBMIT_BO_FLAGS (MSM_SUBMIT_BO_READ | MSM_SUBMIT_BO_WRITE)
+#define MSM_SUBMIT_BO_FLAGS (MSM_SUBMIT_BO_READ | \
+ MSM_SUBMIT_BO_WRITE | \
+ MSM_SUBMIT_BO_DUMP)
struct drm_msm_gem_submit_bo {
__u32 flags; /* in, mask of MSM_SUBMIT_BO_x */
return value;
}
-static bool use_softpin(void)
-{
- static int sp = -1;
- if (sp < 0) {
- const char *str = getenv("FD_MESA_DEBUG");
- sp = str && strstr(str, "softpin");
- }
- return sp;
-}
-
struct fd_pipe * msm_pipe_new(struct fd_device *dev,
enum fd_pipe_id id, uint32_t prio)
{
pipe = &msm_pipe->base;
- // TODO once kernel changes are in place, this switch will be
- // based on kernel version:
- if (use_softpin()) {
+ if (fd_device_version(dev) >= FD_VERSION_SOFTPIN) {
pipe->funcs = &sp_funcs;
} else {
pipe->funcs = &legacy_funcs;
submit->submit_bos[idx].flags |= MSM_SUBMIT_BO_READ;
if (flags & FD_RELOC_WRITE)
submit->submit_bos[idx].flags |= MSM_SUBMIT_BO_WRITE;
+ if (flags & FD_RELOC_DUMP)
+ submit->submit_bos[idx].flags |= MSM_SUBMIT_BO_DUMP;
return idx;
}
for (unsigned i = 0; i < primary->u.nr_cmds; i++) {
cmds[i].type = MSM_SUBMIT_CMD_BUF;
- cmds[i].submit_idx =
- append_bo(msm_submit, primary->u.cmds[i].ring_bo, FD_RELOC_READ);
+ cmds[i].submit_idx = append_bo(msm_submit,
+ primary->u.cmds[i].ring_bo, FD_RELOC_READ | FD_RELOC_DUMP);
cmds[i].submit_offset = primary->offset;
cmds[i].size = primary->u.cmds[i].size;
cmds[i].pad = 0;
msm_ringbuffer_sp_emit_reloc(ring, &(struct fd_reloc){
.bo = bo,
- .flags = FD_RELOC_READ,
+ .flags = FD_RELOC_READ | FD_RELOC_DUMP,
.offset = msm_target->offset,
});