Commit 4570dbb8 authored by Rob Clark's avatar Rob Clark
Browse files

drm/msm: rd dumping prep for sparse mappings



Similar to the previous commit, add support for dumping partial
mappings.

Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
Signed-off-by: default avatarRob Clark <robin.clark@oss.qualcomm.com>
Tested-by: default avatarAntonino Maniscalco <antomani103@gmail.com>
Reviewed-by: default avatarAntonino Maniscalco <antomani103@gmail.com>
Patchwork: https://patchwork.freedesktop.org/patch/661514/
parent 757cff73
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -403,14 +403,4 @@ static inline void msm_gem_submit_put(struct msm_gem_submit *submit)

void msm_submit_retire(struct msm_gem_submit *submit);

/* helper to determine of a buffer in submit should be dumped, used for both
 * devcoredump and debugfs cmdstream dumping:
 */
static inline bool
should_dump(struct msm_gem_submit *submit, int idx)
{
	extern bool rd_full;
	return rd_full || (submit->bos[idx].flags & MSM_SUBMIT_BO_DUMP);
}

#endif /* __MSM_GEM_H__ */
+17 −21
Original line number Diff line number Diff line
@@ -308,21 +308,11 @@ void msm_rd_debugfs_cleanup(struct msm_drm_private *priv)
	priv->hangrd = NULL;
}

static void snapshot_buf(struct msm_rd_state *rd,
		struct msm_gem_submit *submit, int idx,
		uint64_t iova, uint32_t size, bool full)
static void snapshot_buf(struct msm_rd_state *rd, struct drm_gem_object *obj,
			 uint64_t iova, bool full, size_t offset, size_t size)
{
	struct drm_gem_object *obj = submit->bos[idx].obj;
	unsigned offset = 0;
	const char *buf;

	if (iova) {
		offset = iova - submit->bos[idx].iova;
	} else {
		iova = submit->bos[idx].iova;
		size = obj->size;
	}

	/*
	 * Always write the GPUADDR header so can get a complete list of all the
	 * buffers in the cmd
@@ -333,10 +323,6 @@ static void snapshot_buf(struct msm_rd_state *rd,
	if (!full)
		return;

	/* But only dump the contents of buffers marked READ */
	if (!(submit->bos[idx].flags & MSM_SUBMIT_BO_READ))
		return;

	buf = msm_gem_get_vaddr_active(obj);
	if (IS_ERR(buf))
		return;
@@ -352,6 +338,7 @@ static void snapshot_buf(struct msm_rd_state *rd,
void msm_rd_dump_submit(struct msm_rd_state *rd, struct msm_gem_submit *submit,
		const char *fmt, ...)
{
	extern bool rd_full;
	struct task_struct *task;
	char msg[256];
	int i, n;
@@ -385,16 +372,25 @@ void msm_rd_dump_submit(struct msm_rd_state *rd, struct msm_gem_submit *submit,

	rd_write_section(rd, RD_CMD, msg, ALIGN(n, 4));

	for (i = 0; i < submit->nr_bos; i++)
		snapshot_buf(rd, submit, i, 0, 0, should_dump(submit, i));
	for (i = 0; i < submit->nr_bos; i++) {
		struct drm_gem_object *obj = submit->bos[i].obj;
		bool dump = rd_full || (submit->bos[i].flags & MSM_SUBMIT_BO_DUMP);

		snapshot_buf(rd, obj, submit->bos[i].iova, dump, 0, obj->size);
	}

	for (i = 0; i < submit->nr_cmds; i++) {
		uint32_t szd  = submit->cmd[i].size; /* in dwords */
		int idx = submit->cmd[i].idx;
		bool dump = rd_full || (submit->bos[idx].flags & MSM_SUBMIT_BO_DUMP);

		/* snapshot cmdstream bo's (if we haven't already): */
		if (!should_dump(submit, i)) {
			snapshot_buf(rd, submit, submit->cmd[i].idx,
					submit->cmd[i].iova, szd * 4, true);
		if (!dump) {
			struct drm_gem_object *obj = submit->bos[idx].obj;
			size_t offset = submit->cmd[i].iova - submit->bos[idx].iova;

			snapshot_buf(rd, obj, submit->cmd[i].iova, true,
				     offset, szd * 4);
		}
	}