Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 40f7fc96 authored by Ajay Singh Parmar's avatar Ajay Singh Parmar
Browse files

drm/msm/dp: fix aux transaction dump and log formatting



Fix the AUX transaction and link logging with proper formatting.
Provide AUX related debug data like Native or I2C type,
read or write, message address, length and data when dynamic
debugging is enabled for AUX module.

CRs-Fixed: 2293020
Change-Id: I65271d458ceb84b683c131f412cb960f256ba6e9
Signed-off-by: default avatarAjay Singh Parmar <aparmar@codeaurora.org>
parent 924079dc
Loading
Loading
Loading
Loading
+17 −11
Original line number Diff line number Diff line
@@ -58,20 +58,26 @@ struct dp_aux_private {
static void dp_aux_hex_dump(struct drm_dp_aux *drm_aux,
		struct drm_dp_aux_msg *msg)
{
	DEFINE_DYNAMIC_DEBUG_METADATA(ddm, "dp aux tracker");

	if (unlikely(ddm.flags & _DPRINTK_FLAGS_PRINT)) {
		u8 buf[SZ_64];
	char prefix[64];
	int i, linelen, remaining = msg->size;
	const int rowsize = 16;
	u8 linebuf[64];
	struct dp_aux_private *aux = container_of(drm_aux,
		struct dp_aux_private, drm_aux);

		snprintf(buf, SZ_64, "[drm-dp] %5s %5s %5xh(%2zu): ",
			aux->native ? "NATIVE" : "I2C",
			aux->read ? "READ" : "WRITE",
	snprintf(prefix, sizeof(prefix), "%s %s %4xh(%2zu): ",
		aux->native ? "NAT" : "I2C",
		aux->read ? "RD" : "WR",
		msg->address, msg->size);

		print_hex_dump(KERN_DEBUG, buf, DUMP_PREFIX_NONE,
			8, 1, msg->buffer, msg->size, false);
	for (i = 0; i < msg->size; i += rowsize) {
		linelen = min(remaining, rowsize);
		remaining -= rowsize;

		hex_dump_to_buffer(msg->buffer + i, linelen, rowsize, 1,
			linebuf, sizeof(linebuf), false);

		pr_debug("%s%s\n", prefix, linebuf);
	}
}
#else
+17 −7
Original line number Diff line number Diff line
@@ -161,8 +161,6 @@ static ssize_t dp_debug_write_edid(struct file *file,
	edid = debug->edid;
bail:
	kfree(buf);

	if (!debug->dp_debug.sim_mode)
	debug->panel->set_edid(debug->panel, edid);

	return rc;
@@ -178,7 +176,8 @@ static ssize_t dp_debug_write_dpcd(struct file *file,
	size_t size = 0, dpcd_buf_index = 0;
	ssize_t rc = count;
	char offset_ch[5];
	u32 offset;
	u32 offset, data_len;
	const u32 dp_receiver_cap_size = 16;

	if (!debug)
		return -ENODEV;
@@ -188,6 +187,9 @@ static ssize_t dp_debug_write_dpcd(struct file *file,

	size = min_t(size_t, count, SZ_2K);

	if (size <= char_to_nib)
		goto bail;

	buf = kzalloc(size, GFP_KERNEL);
	if (ZERO_OR_NULL_PTR(buf)) {
		rc = -ENOMEM;
@@ -217,6 +219,7 @@ static ssize_t dp_debug_write_dpcd(struct file *file,
	size -= 4;

	dpcd_size = size / char_to_nib;
	data_len = dpcd_size;
	buf_t = buf + 4;

	dpcd_buf_index = offset;
@@ -242,10 +245,15 @@ static ssize_t dp_debug_write_dpcd(struct file *file,
	dpcd = debug->dpcd;
bail:
	kfree(buf);
	if (debug->dp_debug.sim_mode)
		debug->aux->dpcd_updated(debug->aux);
	else

	/*
	 * Reset panel's dpcd in case of any failure. Also, set the
	 * panel's dpcd only if a full dpcd is provided with offset as 0.
	 */
	if (!dpcd || (!offset && (data_len == dp_receiver_cap_size)))
		debug->panel->set_dpcd(debug->panel, dpcd);
	else
		debug->aux->dpcd_updated(debug->aux);

	return rc;
}
@@ -1393,11 +1401,13 @@ static ssize_t dp_debug_write_sim(struct file *file,
		debug->aux->set_sim_mode(debug->aux, false, NULL, NULL);
		debug->dp_debug.sim_mode = false;

		debug->panel->set_edid(debug->panel, 0);
		if (debug->edid) {
			devm_kfree(debug->dev, debug->edid);
			debug->edid = NULL;
		}

		debug->panel->set_dpcd(debug->panel, 0);
		if (debug->dpcd) {
			devm_kfree(debug->dev, debug->dpcd);
			debug->dpcd = NULL;
+0 −4
Original line number Diff line number Diff line
@@ -478,10 +478,6 @@ static void dp_hdcp2p2_send_msg_work(struct kthread_work *work)
		goto exit;
	}

	print_hex_dump(KERN_DEBUG, ": ",
		DUMP_PREFIX_NONE, 16, 1, ctrl->response.data,
		ctrl->response.length, false);

	mutex_lock(&ctrl->msg_lock);

	rc = dp_hdcp2p2_aux_write_message(ctrl, ctrl->response.data,
+34 −28
Original line number Diff line number Diff line
@@ -788,12 +788,8 @@ static int dp_link_parse_request(struct dp_link_private *link)

	data = bp;

	pr_debug("device service irq vector = 0x%x\n", data);

	if (!(data & DP_AUTOMATED_TEST_REQUEST)) {
		pr_debug("no test requested\n");
	if (!(data & DP_AUTOMATED_TEST_REQUEST))
		return 0;
	}

	/**
	 * Read the link request byte (Byte 0x218) to determine what type
@@ -814,7 +810,6 @@ static int dp_link_parse_request(struct dp_link_private *link)
		goto end;
	}

	pr_debug("%s (0x%x) requested\n", dp_link_get_test_name(data), data);
	link->request.test_requested = data;

	if (link->request.test_requested == DP_TEST_LINK_PHY_TEST_PATTERN) {
@@ -1286,8 +1281,6 @@ static int dp_link_process_request(struct dp_link *dp_link)

	link = container_of(dp_link, struct dp_link_private, dp_link);

	pr_debug("start\n");

	dp_link_reset_data(link);

	dp_link_parse_sink_status_field(link);
@@ -1333,9 +1326,18 @@ static int dp_link_process_request(struct dp_link *dp_link)
		goto exit;
	}

	pr_debug("done\n");
exit:
	pr_debug("no test requested\n");
	return ret;
exit:
	/*
	 * log this as it can be a use initiated action to run a DP CTS
	 * test or in normal cases, sink has encountered a problem and
	 * and want source to redo some part of initialization which can
	 * be helpful in debugging.
	 */
	pr_info("test requested: %s\n",
		dp_link_get_test_name(dp_link->sink_request));
	return 0;
}

static int dp_link_get_colorimetry_config(struct dp_link *dp_link)
@@ -1376,6 +1378,7 @@ static int dp_link_adjust_levels(struct dp_link *dp_link, u8 *link_status)
	int max = 0;
	u8 data;
	struct dp_link_private *link;
	u8 buf[8] = {0}, offset = 0;

	if (!dp_link) {
		pr_err("invalid input\n");
@@ -1387,49 +1390,52 @@ static int dp_link_adjust_levels(struct dp_link *dp_link, u8 *link_status)
	/* use the max level across lanes */
	for (i = 0; i < dp_link->link_params.lane_count; i++) {
		data = drm_dp_get_adjust_request_voltage(link_status, i);
		pr_debug("lane=%d req_voltage_swing=%d\n", i, data);
		data >>= DP_TRAIN_VOLTAGE_SWING_SHIFT;

		offset = i * 2;
		if (offset < sizeof(buf))
			buf[offset] = data;

		if (max < data)
			max = data;
	}

	dp_link->phy_params.v_level = max >> DP_TRAIN_VOLTAGE_SWING_SHIFT;
	dp_link->phy_params.v_level = max;

	/* use the max level across lanes */
	max = 0;
	for (i = 0; i < dp_link->link_params.lane_count; i++) {
		data = drm_dp_get_adjust_request_pre_emphasis(link_status, i);
		pr_debug("lane=%d req_pre_emphasis=%d\n", i, data);
		data >>= DP_TRAIN_PRE_EMPHASIS_SHIFT;

		offset = (i * 2) + 1;
		if (offset < sizeof(buf))
			buf[offset] = data;

		if (max < data)
			max = data;
	}

	dp_link->phy_params.p_level = max >> DP_TRAIN_PRE_EMPHASIS_SHIFT;
	dp_link->phy_params.p_level = max;

	print_hex_dump(KERN_DEBUG, "[drm-dp] Req (VxPx): ",
		DUMP_PREFIX_NONE, 8, 2, buf, sizeof(buf), false);

	/**
	 * Adjust the voltage swing and pre-emphasis level combination to within
	 * the allowable range.
	 */
	if (dp_link->phy_params.v_level > DP_LINK_VOLTAGE_MAX) {
		pr_debug("Requested vSwingLevel=%d, change to %d\n",
			dp_link->phy_params.v_level, DP_LINK_VOLTAGE_MAX);
	if (dp_link->phy_params.v_level > DP_LINK_VOLTAGE_MAX)
		dp_link->phy_params.v_level = DP_LINK_VOLTAGE_MAX;
	}

	if (dp_link->phy_params.p_level > DP_LINK_PRE_EMPHASIS_MAX) {
		pr_debug("Requested preEmphasisLevel=%d, change to %d\n",
			dp_link->phy_params.p_level, DP_LINK_PRE_EMPHASIS_MAX);
	if (dp_link->phy_params.p_level > DP_LINK_PRE_EMPHASIS_MAX)
		dp_link->phy_params.p_level = DP_LINK_PRE_EMPHASIS_MAX;
	}

	if ((dp_link->phy_params.p_level > DP_LINK_PRE_EMPHASIS_LEVEL_1)
		&& (dp_link->phy_params.v_level == DP_LINK_VOLTAGE_LEVEL_2)) {
		pr_debug("Requested preEmphasisLevel=%d, change to %d\n",
			dp_link->phy_params.p_level,
			DP_LINK_PRE_EMPHASIS_LEVEL_1);
		&& (dp_link->phy_params.v_level == DP_LINK_VOLTAGE_LEVEL_2))
		dp_link->phy_params.p_level = DP_LINK_PRE_EMPHASIS_LEVEL_1;
	}

	pr_debug("adjusted: v_level=%d, p_level=%d\n",
	pr_debug("Set (VxPx): %x%x\n",
		dp_link->phy_params.v_level, dp_link->phy_params.p_level);

	return 0;
+4 −0
Original line number Diff line number Diff line
@@ -101,6 +101,10 @@ static inline char *dp_link_get_test_name(u32 test_requested)
		return DP_LINK_ENUM_STR(DP_TEST_LINK_PHY_TEST_PATTERN);
	case DP_TEST_LINK_AUDIO_PATTERN:
		return DP_LINK_ENUM_STR(DP_TEST_LINK_AUDIO_PATTERN);
	case DS_PORT_STATUS_CHANGED:
		return DP_LINK_ENUM_STR(DS_PORT_STATUS_CHANGED);
	case DP_LINK_STATUS_UPDATED:
		return DP_LINK_ENUM_STR(DP_LINK_STATUS_UPDATED);
	default:
		return "unknown";
	}
Loading