Skip to content

Commit 3dadbd2

Browse files
committed
drm/dp/mst: Provide better debugs for NAK replies
Decode the NAK reply fields to make it easier to parse the logs. v2: s/STR/DP_STR/ to avoid conflict with some header stuff (0day) Use drm_dp_mst_req_type_str() more (DK) Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20190122200301.18633-2-ville.syrjala@linux.intel.com
1 parent 45bbda1 commit 3dadbd2

File tree

2 files changed

+69
-3
lines changed

2 files changed

+69
-3
lines changed

drivers/gpu/drm/drm_dp_mst_topology.c

Lines changed: 68 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,64 @@ static bool drm_dp_validate_guid(struct drm_dp_mst_topology_mgr *mgr,
6767
static int drm_dp_mst_register_i2c_bus(struct drm_dp_aux *aux);
6868
static void drm_dp_mst_unregister_i2c_bus(struct drm_dp_aux *aux);
6969
static void drm_dp_mst_kick_tx(struct drm_dp_mst_topology_mgr *mgr);
70+
71+
#define DP_STR(x) [DP_ ## x] = #x
72+
73+
static const char *drm_dp_mst_req_type_str(u8 req_type)
74+
{
75+
static const char * const req_type_str[] = {
76+
DP_STR(GET_MSG_TRANSACTION_VERSION),
77+
DP_STR(LINK_ADDRESS),
78+
DP_STR(CONNECTION_STATUS_NOTIFY),
79+
DP_STR(ENUM_PATH_RESOURCES),
80+
DP_STR(ALLOCATE_PAYLOAD),
81+
DP_STR(QUERY_PAYLOAD),
82+
DP_STR(RESOURCE_STATUS_NOTIFY),
83+
DP_STR(CLEAR_PAYLOAD_ID_TABLE),
84+
DP_STR(REMOTE_DPCD_READ),
85+
DP_STR(REMOTE_DPCD_WRITE),
86+
DP_STR(REMOTE_I2C_READ),
87+
DP_STR(REMOTE_I2C_WRITE),
88+
DP_STR(POWER_UP_PHY),
89+
DP_STR(POWER_DOWN_PHY),
90+
DP_STR(SINK_EVENT_NOTIFY),
91+
DP_STR(QUERY_STREAM_ENC_STATUS),
92+
};
93+
94+
if (req_type >= ARRAY_SIZE(req_type_str) ||
95+
!req_type_str[req_type])
96+
return "unknown";
97+
98+
return req_type_str[req_type];
99+
}
100+
101+
#undef DP_STR
102+
#define DP_STR(x) [DP_NAK_ ## x] = #x
103+
104+
static const char *drm_dp_mst_nak_reason_str(u8 nak_reason)
105+
{
106+
static const char * const nak_reason_str[] = {
107+
DP_STR(WRITE_FAILURE),
108+
DP_STR(INVALID_READ),
109+
DP_STR(CRC_FAILURE),
110+
DP_STR(BAD_PARAM),
111+
DP_STR(DEFER),
112+
DP_STR(LINK_FAILURE),
113+
DP_STR(NO_RESOURCES),
114+
DP_STR(DPCD_FAIL),
115+
DP_STR(I2C_NAK),
116+
DP_STR(ALLOCATE_FAIL),
117+
};
118+
119+
if (nak_reason >= ARRAY_SIZE(nak_reason_str) ||
120+
!nak_reason_str[nak_reason])
121+
return "unknown";
122+
123+
return nak_reason_str[nak_reason];
124+
}
125+
126+
#undef DP_STR
127+
70128
/* sideband msg handling */
71129
static u8 drm_dp_msg_header_crc4(const uint8_t *data, size_t num_nibbles)
72130
{
@@ -594,7 +652,8 @@ static bool drm_dp_sideband_parse_reply(struct drm_dp_sideband_msg_rx *raw,
594652
case DP_POWER_UP_PHY:
595653
return drm_dp_sideband_parse_power_updown_phy_ack(raw, msg);
596654
default:
597-
DRM_ERROR("Got unknown reply 0x%02x\n", msg->req_type);
655+
DRM_ERROR("Got unknown reply 0x%02x (%s)\n", msg->req_type,
656+
drm_dp_mst_req_type_str(msg->req_type));
598657
return false;
599658
}
600659
}
@@ -661,7 +720,8 @@ static bool drm_dp_sideband_parse_req(struct drm_dp_sideband_msg_rx *raw,
661720
case DP_RESOURCE_STATUS_NOTIFY:
662721
return drm_dp_sideband_parse_resource_status_notify(raw, msg);
663722
default:
664-
DRM_ERROR("Got unknown request 0x%02x\n", msg->req_type);
723+
DRM_ERROR("Got unknown request 0x%02x (%s)\n", msg->req_type,
724+
drm_dp_mst_req_type_str(msg->req_type));
665725
return false;
666726
}
667727
}
@@ -2747,7 +2807,12 @@ static int drm_dp_mst_handle_down_rep(struct drm_dp_mst_topology_mgr *mgr)
27472807
drm_dp_sideband_parse_reply(&mgr->down_rep_recv, &txmsg->reply);
27482808

27492809
if (txmsg->reply.reply_type == DP_SIDEBAND_REPLY_NAK)
2750-
DRM_DEBUG_KMS("Got NAK reply: req 0x%02x, reason 0x%02x, nak data 0x%02x\n", txmsg->reply.req_type, txmsg->reply.u.nak.reason, txmsg->reply.u.nak.nak_data);
2810+
DRM_DEBUG_KMS("Got NAK reply: req 0x%02x (%s), reason 0x%02x (%s), nak data 0x%02x\n",
2811+
txmsg->reply.req_type,
2812+
drm_dp_mst_req_type_str(txmsg->reply.req_type),
2813+
txmsg->reply.u.nak.reason,
2814+
drm_dp_mst_nak_reason_str(txmsg->reply.u.nak.reason),
2815+
txmsg->reply.u.nak.nak_data);
27512816

27522817
memset(&mgr->down_rep_recv, 0, sizeof(struct drm_dp_sideband_msg_rx));
27532818
drm_dp_mst_topology_put_mstb(mstb);

include/drm/drm_dp_helper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,7 @@
976976
#define DP_PEER_DEVICE_DP_LEGACY_CONV 0x4
977977

978978
/* DP 1.2 MST sideband request names DP 1.2a Table 2-80 */
979+
#define DP_GET_MSG_TRANSACTION_VERSION 0x00 /* DP 1.3 */
979980
#define DP_LINK_ADDRESS 0x01
980981
#define DP_CONNECTION_STATUS_NOTIFY 0x02
981982
#define DP_ENUM_PATH_RESOURCES 0x10

0 commit comments

Comments
 (0)