Skip to content

Commit a18b219

Browse files
committed
drm/dp_helper: Add DP aux channel tracing
This is something we've needed for a very long time now, as it makes debugging issues with faulty MST hubs along with debugging issues regarding us interfacing with hubs correctly vastly easier to debug. Currently this can actually be done if you trace the i2c devices for DP using ftrace but that's significantly less useful for a couple of reasons: - Tracing the i2c devices through ftrace means all of the traces are going to contain a lot of "garbage" output that we're sending over the i2c line. Most of this garbage comes from retrying transactions, DRM's helper library adding extra transactions to work around bad hubs, etc. - Having a user set up ftrace so that they can provide debugging information is a lot more difficult then being able to say "just boot with drm.debug=0x100" - We can potentially expand upon this tracing in the future to print debugging information in regards to other DP transactions like MST sideband transactions This is inspired by a patch Rob Clark sent to do this a long time back. Neither of us could find the patch however, so we both assumed it would probably just be easier to rewrite it anyway. Cc: Rob Clark <robdclark@gmail.com> Signed-off-by: Lyude Paul <lyude@redhat.com> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: https://patchwork.freedesktop.org/patch/msgid/20180716154432.13433-1-lyude@redhat.com
1 parent 71a5cb3 commit a18b219

3 files changed

Lines changed: 41 additions & 12 deletions

File tree

‎drivers/gpu/drm/drm_dp_helper.c‎

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,20 @@ EXPORT_SYMBOL(drm_dp_bw_code_to_link_rate);
185185

186186
#define AUX_RETRY_INTERVAL 500 /* us */
187187

188+
static inline void
189+
drm_dp_dump_access(const struct drm_dp_aux *aux,
190+
u8 request, uint offset, void *buffer, int ret)
191+
{
192+
const char *arrow = request == DP_AUX_NATIVE_READ ? "->" : "<-";
193+
194+
if (ret > 0)
195+
drm_dbg(DRM_UT_DP, "%s: 0x%05x AUX %s (ret=%3d) %*ph\n",
196+
aux->name, offset, arrow, ret, min(ret, 20), buffer);
197+
else
198+
drm_dbg(DRM_UT_DP, "%s: 0x%05x AUX %s (ret=%3d)\n",
199+
aux->name, offset, arrow, ret);
200+
}
201+
188202
/**
189203
* DOC: dp helpers
190204
*
@@ -288,10 +302,14 @@ ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux, unsigned int offset,
288302
ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, DP_DPCD_REV, buffer,
289303
1);
290304
if (ret != 1)
291-
return ret;
305+
goto out;
292306

293-
return drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, offset, buffer,
294-
size);
307+
ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, offset, buffer,
308+
size);
309+
310+
out:
311+
drm_dp_dump_access(aux, DP_AUX_NATIVE_READ, offset, buffer, ret);
312+
return ret;
295313
}
296314
EXPORT_SYMBOL(drm_dp_dpcd_read);
297315

@@ -312,8 +330,12 @@ EXPORT_SYMBOL(drm_dp_dpcd_read);
312330
ssize_t drm_dp_dpcd_write(struct drm_dp_aux *aux, unsigned int offset,
313331
void *buffer, size_t size)
314332
{
315-
return drm_dp_dpcd_access(aux, DP_AUX_NATIVE_WRITE, offset, buffer,
316-
size);
333+
int ret;
334+
335+
ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_WRITE, offset, buffer,
336+
size);
337+
drm_dp_dump_access(aux, DP_AUX_NATIVE_WRITE, offset, buffer, ret);
338+
return ret;
317339
}
318340
EXPORT_SYMBOL(drm_dp_dpcd_write);
319341

‎drivers/gpu/drm/drm_drv.c‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,14 @@ MODULE_AUTHOR("Gareth Hughes, Leif Delgass, José Fonseca, Jon Smirl");
5454
MODULE_DESCRIPTION("DRM shared core routines");
5555
MODULE_LICENSE("GPL and additional rights");
5656
MODULE_PARM_DESC(debug, "Enable debug output, where each bit enables a debug category.\n"
57-
"\t\tBit 0 (0x01) will enable CORE messages (drm core code)\n"
58-
"\t\tBit 1 (0x02) will enable DRIVER messages (drm controller code)\n"
59-
"\t\tBit 2 (0x04) will enable KMS messages (modesetting code)\n"
60-
"\t\tBit 3 (0x08) will enable PRIME messages (prime code)\n"
61-
"\t\tBit 4 (0x10) will enable ATOMIC messages (atomic code)\n"
62-
"\t\tBit 5 (0x20) will enable VBL messages (vblank code)\n"
63-
"\t\tBit 7 (0x80) will enable LEASE messages (leasing code)");
57+
"\t\tBit 0 (0x01) will enable CORE messages (drm core code)\n"
58+
"\t\tBit 1 (0x02) will enable DRIVER messages (drm controller code)\n"
59+
"\t\tBit 2 (0x04) will enable KMS messages (modesetting code)\n"
60+
"\t\tBit 3 (0x08) will enable PRIME messages (prime code)\n"
61+
"\t\tBit 4 (0x10) will enable ATOMIC messages (atomic code)\n"
62+
"\t\tBit 5 (0x20) will enable VBL messages (vblank code)\n"
63+
"\t\tBit 7 (0x80) will enable LEASE messages (leasing code)\n"
64+
"\t\tBit 8 (0x100) will enable DP messages (displayport code)");
6465
module_param_named(debug, drm_debug, int, 0600);
6566

6667
static DEFINE_SPINLOCK(drm_minor_lock);

‎include/drm/drm_print.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ static inline struct drm_printer drm_debug_printer(const char *prefix)
195195
#define DRM_UT_VBL 0x20
196196
#define DRM_UT_STATE 0x40
197197
#define DRM_UT_LEASE 0x80
198+
#define DRM_UT_DP 0x100
198199

199200
__printf(3, 4)
200201
void drm_dev_printk(const struct device *dev, const char *level,
@@ -307,6 +308,11 @@ void drm_err(const char *format, ...);
307308
#define DRM_DEBUG_LEASE(fmt, ...) \
308309
drm_dbg(DRM_UT_LEASE, fmt, ##__VA_ARGS__)
309310

311+
#define DRM_DEV_DEBUG_DP(dev, fmt, ...) \
312+
drm_dev_dbg(dev, DRM_UT_DP, fmt, ## __VA_ARGS__)
313+
#define DRM_DEBUG_DP(dev, fmt, ...) \
314+
drm_dbg(DRM_UT_DP, fmt, ## __VA_ARGS__)
315+
310316
#define _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, category, fmt, ...) \
311317
({ \
312318
static DEFINE_RATELIMIT_STATE(_rs, \

0 commit comments

Comments
 (0)