2019-08-08 20:42:43 +07:00
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
/*
|
|
|
|
* Copyright © 2019 Intel Corporation
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <drm/drm_drv.h>
|
|
|
|
|
|
|
|
#include "i915_drv.h"
|
|
|
|
#include "i915_utils.h"
|
|
|
|
|
2020-02-12 23:04:34 +07:00
|
|
|
#define FDO_BUG_MSG "Please file a bug on drm/i915; see " FDO_BUG_URL " for details."
|
2019-08-08 20:42:43 +07:00
|
|
|
|
|
|
|
void
|
|
|
|
__i915_printk(struct drm_i915_private *dev_priv, const char *level,
|
|
|
|
const char *fmt, ...)
|
|
|
|
{
|
|
|
|
static bool shown_bug_once;
|
|
|
|
struct device *kdev = dev_priv->drm.dev;
|
|
|
|
bool is_error = level[1] <= KERN_ERR[1];
|
|
|
|
bool is_debug = level[1] == KERN_DEBUG[1];
|
|
|
|
struct va_format vaf;
|
|
|
|
va_list args;
|
|
|
|
|
2019-10-28 17:38:15 +07:00
|
|
|
if (is_debug && !drm_debug_enabled(DRM_UT_DRIVER))
|
2019-08-08 20:42:43 +07:00
|
|
|
return;
|
|
|
|
|
|
|
|
va_start(args, fmt);
|
|
|
|
|
|
|
|
vaf.fmt = fmt;
|
|
|
|
vaf.va = &args;
|
|
|
|
|
|
|
|
if (is_error)
|
|
|
|
dev_printk(level, kdev, "%pV", &vaf);
|
|
|
|
else
|
|
|
|
dev_printk(level, kdev, "[" DRM_NAME ":%ps] %pV",
|
|
|
|
__builtin_return_address(0), &vaf);
|
|
|
|
|
|
|
|
va_end(args);
|
|
|
|
|
|
|
|
if (is_error && !shown_bug_once) {
|
|
|
|
/*
|
|
|
|
* Ask the user to file a bug report for the error, except
|
|
|
|
* if they may have caused the bug by fiddling with unsafe
|
|
|
|
* module parameters.
|
|
|
|
*/
|
|
|
|
if (!test_taint(TAINT_USER))
|
|
|
|
dev_notice(kdev, "%s", FDO_BUG_MSG);
|
|
|
|
shown_bug_once = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-06 21:41:06 +07:00
|
|
|
void add_taint_for_CI(struct drm_i915_private *i915, unsigned int taint)
|
|
|
|
{
|
|
|
|
__i915_printk(i915, KERN_NOTICE, "CI tainted:%#x by %pS\n",
|
|
|
|
taint, (void *)_RET_IP_);
|
2020-07-06 21:41:07 +07:00
|
|
|
|
|
|
|
/* Failures that occur during fault injection testing are expected */
|
|
|
|
if (!i915_error_injected())
|
|
|
|
__add_taint_for_CI(taint);
|
2020-07-06 21:41:06 +07:00
|
|
|
}
|
|
|
|
|
2019-08-08 20:42:43 +07:00
|
|
|
#if IS_ENABLED(CONFIG_DRM_I915_DEBUG)
|
|
|
|
static unsigned int i915_probe_fail_count;
|
|
|
|
|
2019-10-29 17:20:35 +07:00
|
|
|
int __i915_inject_probe_error(struct drm_i915_private *i915, int err,
|
|
|
|
const char *func, int line)
|
2019-08-08 20:42:43 +07:00
|
|
|
{
|
2019-10-29 17:20:36 +07:00
|
|
|
if (i915_probe_fail_count >= i915_modparams.inject_probe_failure)
|
2019-08-08 20:42:43 +07:00
|
|
|
return 0;
|
|
|
|
|
2019-10-29 17:20:36 +07:00
|
|
|
if (++i915_probe_fail_count < i915_modparams.inject_probe_failure)
|
2019-08-08 20:42:43 +07:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
__i915_printk(i915, KERN_INFO,
|
|
|
|
"Injecting failure %d at checkpoint %u [%s:%d]\n",
|
2019-10-29 17:20:36 +07:00
|
|
|
err, i915_modparams.inject_probe_failure, func, line);
|
|
|
|
i915_modparams.inject_probe_failure = 0;
|
2019-08-08 20:42:43 +07:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool i915_error_injected(void)
|
|
|
|
{
|
2019-10-29 17:20:36 +07:00
|
|
|
return i915_probe_fail_count && !i915_modparams.inject_probe_failure;
|
2019-08-08 20:42:43 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2019-10-23 20:31:05 +07:00
|
|
|
|
|
|
|
void cancel_timer(struct timer_list *t)
|
|
|
|
{
|
|
|
|
if (!READ_ONCE(t->expires))
|
|
|
|
return;
|
|
|
|
|
|
|
|
del_timer(t);
|
|
|
|
WRITE_ONCE(t->expires, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_timer_ms(struct timer_list *t, unsigned long timeout)
|
|
|
|
{
|
|
|
|
if (!timeout) {
|
|
|
|
cancel_timer(t);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-06-04 20:59:38 +07:00
|
|
|
timeout = msecs_to_jiffies(timeout);
|
2019-10-23 20:31:05 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Paranoia to make sure the compiler computes the timeout before
|
|
|
|
* loading 'jiffies' as jiffies is volatile and may be updated in
|
|
|
|
* the background by a timer tick. All to reduce the complexity
|
|
|
|
* of the addition and reduce the risk of losing a jiffie.
|
|
|
|
*/
|
|
|
|
barrier();
|
|
|
|
|
2020-04-03 14:36:57 +07:00
|
|
|
/* Keep t->expires = 0 reserved to indicate a canceled timer. */
|
|
|
|
mod_timer(t, jiffies + timeout ?: 1);
|
2019-10-23 20:31:05 +07:00
|
|
|
}
|