Commit f0a8f533 authored by Jani Nikula's avatar Jani Nikula

drm/print: add drm_debug_enabled()

Add helper to check if a drm debug category is enabled. Convert drm core
to use it. No functional changes.

v2: Move unlikely() to drm_debug_enabled() (Eric)

v3: Keep unlikely() when combined with other conditions (Eric)

Cc: Eric Engestrom <eric@engestrom.ch>
Acked-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Reviewed-by: default avatarEric Engestrom <eric@engestrom.ch>
Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191001140614.26909-1-jani.nikula@intel.com
parent 959b077f
...@@ -1406,7 +1406,7 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, ...@@ -1406,7 +1406,7 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
} else if (arg->flags & DRM_MODE_ATOMIC_NONBLOCK) { } else if (arg->flags & DRM_MODE_ATOMIC_NONBLOCK) {
ret = drm_atomic_nonblocking_commit(state); ret = drm_atomic_nonblocking_commit(state);
} else { } else {
if (unlikely(drm_debug & DRM_UT_STATE)) if (drm_debug_enabled(DRM_UT_STATE))
drm_atomic_print_state(state); drm_atomic_print_state(state);
ret = drm_atomic_commit(state); ret = drm_atomic_commit(state);
......
...@@ -1179,7 +1179,7 @@ static int drm_dp_mst_wait_tx_reply(struct drm_dp_mst_branch *mstb, ...@@ -1179,7 +1179,7 @@ static int drm_dp_mst_wait_tx_reply(struct drm_dp_mst_branch *mstb,
} }
} }
out: out:
if (unlikely(ret == -EIO && drm_debug & DRM_UT_DP)) { if (unlikely(ret == -EIO) && drm_debug_enabled(DRM_UT_DP)) {
struct drm_printer p = drm_debug_printer(DBG_PREFIX); struct drm_printer p = drm_debug_printer(DBG_PREFIX);
drm_dp_mst_dump_sideband_msg_tx(&p, txmsg); drm_dp_mst_dump_sideband_msg_tx(&p, txmsg);
...@@ -2322,7 +2322,7 @@ static int process_single_tx_qlock(struct drm_dp_mst_topology_mgr *mgr, ...@@ -2322,7 +2322,7 @@ static int process_single_tx_qlock(struct drm_dp_mst_topology_mgr *mgr,
idx += tosend + 1; idx += tosend + 1;
ret = drm_dp_send_sideband_msg(mgr, up, chunk, idx); ret = drm_dp_send_sideband_msg(mgr, up, chunk, idx);
if (unlikely(ret && drm_debug & DRM_UT_DP)) { if (unlikely(ret) && drm_debug_enabled(DRM_UT_DP)) {
struct drm_printer p = drm_debug_printer(DBG_PREFIX); struct drm_printer p = drm_debug_printer(DBG_PREFIX);
drm_printf(&p, "sideband msg failed to send\n"); drm_printf(&p, "sideband msg failed to send\n");
...@@ -2389,7 +2389,7 @@ static void drm_dp_queue_down_tx(struct drm_dp_mst_topology_mgr *mgr, ...@@ -2389,7 +2389,7 @@ static void drm_dp_queue_down_tx(struct drm_dp_mst_topology_mgr *mgr,
mutex_lock(&mgr->qlock); mutex_lock(&mgr->qlock);
list_add_tail(&txmsg->next, &mgr->tx_msg_downq); list_add_tail(&txmsg->next, &mgr->tx_msg_downq);
if (unlikely(drm_debug & DRM_UT_DP)) { if (drm_debug_enabled(DRM_UT_DP)) {
struct drm_printer p = drm_debug_printer(DBG_PREFIX); struct drm_printer p = drm_debug_printer(DBG_PREFIX);
drm_dp_mst_dump_sideband_msg_tx(&p, txmsg); drm_dp_mst_dump_sideband_msg_tx(&p, txmsg);
......
...@@ -1651,7 +1651,7 @@ static void connector_bad_edid(struct drm_connector *connector, ...@@ -1651,7 +1651,7 @@ static void connector_bad_edid(struct drm_connector *connector,
{ {
int i; int i;
if (connector->bad_edid_counter++ && !(drm_debug & DRM_UT_KMS)) if (connector->bad_edid_counter++ && !drm_debug_enabled(DRM_UT_KMS))
return; return;
dev_warn(connector->dev->dev, dev_warn(connector->dev->dev,
......
...@@ -175,7 +175,7 @@ static void *edid_load(struct drm_connector *connector, const char *name, ...@@ -175,7 +175,7 @@ static void *edid_load(struct drm_connector *connector, const char *name,
u8 *edid; u8 *edid;
int fwsize, builtin; int fwsize, builtin;
int i, valid_extensions = 0; int i, valid_extensions = 0;
bool print_bad_edid = !connector->bad_edid_counter || (drm_debug & DRM_UT_KMS); bool print_bad_edid = !connector->bad_edid_counter || drm_debug_enabled(DRM_UT_KMS);
builtin = match_string(generic_edid_name, GENERIC_EDIDS, name); builtin = match_string(generic_edid_name, GENERIC_EDIDS, name);
if (builtin >= 0) { if (builtin >= 0) {
......
...@@ -783,7 +783,7 @@ static int mipi_dbi_spi1e_transfer(struct mipi_dbi *dbi, int dc, ...@@ -783,7 +783,7 @@ static int mipi_dbi_spi1e_transfer(struct mipi_dbi *dbi, int dc,
int i, ret; int i, ret;
u8 *dst; u8 *dst;
if (drm_debug & DRM_UT_DRIVER) if (drm_debug_enabled(DRM_UT_DRIVER))
pr_debug("[drm:%s] dc=%d, max_chunk=%zu, transfers:\n", pr_debug("[drm:%s] dc=%d, max_chunk=%zu, transfers:\n",
__func__, dc, max_chunk); __func__, dc, max_chunk);
...@@ -907,7 +907,7 @@ static int mipi_dbi_spi1_transfer(struct mipi_dbi *dbi, int dc, ...@@ -907,7 +907,7 @@ static int mipi_dbi_spi1_transfer(struct mipi_dbi *dbi, int dc,
max_chunk = dbi->tx_buf9_len; max_chunk = dbi->tx_buf9_len;
dst16 = dbi->tx_buf9; dst16 = dbi->tx_buf9;
if (drm_debug & DRM_UT_DRIVER) if (drm_debug_enabled(DRM_UT_DRIVER))
pr_debug("[drm:%s] dc=%d, max_chunk=%zu, transfers:\n", pr_debug("[drm:%s] dc=%d, max_chunk=%zu, transfers:\n",
__func__, dc, max_chunk); __func__, dc, max_chunk);
......
...@@ -262,7 +262,7 @@ void drm_dev_dbg(const struct device *dev, unsigned int category, ...@@ -262,7 +262,7 @@ void drm_dev_dbg(const struct device *dev, unsigned int category,
struct va_format vaf; struct va_format vaf;
va_list args; va_list args;
if (!(drm_debug & category)) if (!drm_debug_enabled(category))
return; return;
va_start(args, format); va_start(args, format);
...@@ -285,7 +285,7 @@ void drm_dbg(unsigned int category, const char *format, ...) ...@@ -285,7 +285,7 @@ void drm_dbg(unsigned int category, const char *format, ...)
struct va_format vaf; struct va_format vaf;
va_list args; va_list args;
if (!(drm_debug & category)) if (!drm_debug_enabled(category))
return; return;
va_start(args, format); va_start(args, format);
......
...@@ -332,7 +332,7 @@ u64 drm_crtc_accurate_vblank_count(struct drm_crtc *crtc) ...@@ -332,7 +332,7 @@ u64 drm_crtc_accurate_vblank_count(struct drm_crtc *crtc)
u64 vblank; u64 vblank;
unsigned long flags; unsigned long flags;
WARN_ONCE(drm_debug & DRM_UT_VBL && !dev->driver->get_vblank_timestamp, WARN_ONCE(drm_debug_enabled(DRM_UT_VBL) && !dev->driver->get_vblank_timestamp,
"This function requires support for accurate vblank timestamps."); "This function requires support for accurate vblank timestamps.");
spin_lock_irqsave(&dev->vblank_time_lock, flags); spin_lock_irqsave(&dev->vblank_time_lock, flags);
...@@ -706,7 +706,7 @@ bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, ...@@ -706,7 +706,7 @@ bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
*/ */
*vblank_time = ktime_sub_ns(etime, delta_ns); *vblank_time = ktime_sub_ns(etime, delta_ns);
if ((drm_debug & DRM_UT_VBL) == 0) if (!drm_debug_enabled(DRM_UT_VBL))
return true; return true;
ts_etime = ktime_to_timespec64(etime); ts_etime = ktime_to_timespec64(etime);
...@@ -1352,7 +1352,7 @@ void drm_vblank_restore(struct drm_device *dev, unsigned int pipe) ...@@ -1352,7 +1352,7 @@ void drm_vblank_restore(struct drm_device *dev, unsigned int pipe)
assert_spin_locked(&dev->vblank_time_lock); assert_spin_locked(&dev->vblank_time_lock);
vblank = &dev->vblank[pipe]; vblank = &dev->vblank[pipe];
WARN_ONCE((drm_debug & DRM_UT_VBL) && !vblank->framedur_ns, WARN_ONCE(drm_debug_enabled(DRM_UT_VBL) && !vblank->framedur_ns,
"Cannot compute missed vblanks without frame duration\n"); "Cannot compute missed vblanks without frame duration\n");
framedur_ns = vblank->framedur_ns; framedur_ns = vblank->framedur_ns;
......
...@@ -293,6 +293,11 @@ static inline struct drm_printer drm_err_printer(const char *prefix) ...@@ -293,6 +293,11 @@ static inline struct drm_printer drm_err_printer(const char *prefix)
#define DRM_UT_LEASE 0x80 #define DRM_UT_LEASE 0x80
#define DRM_UT_DP 0x100 #define DRM_UT_DP 0x100
static inline bool drm_debug_enabled(unsigned int category)
{
return unlikely(drm_debug & category);
}
__printf(3, 4) __printf(3, 4)
void drm_dev_printk(const struct device *dev, const char *level, void drm_dev_printk(const struct device *dev, const char *level,
const char *format, ...); const char *format, ...);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment