/* * container_of_user: Extract the superclass from a pointer to a member. * * Exactly like container_of() with the exception that it plays nicely * with sparse for __user @ptr.
*/ #define container_of_user(ptr, type, member) ({ \ void __user *__mptr = (void __user *)(ptr); \
BUILD_BUG_ON_MSG(!__same_type(*(ptr), typeof_member(type, member)) && \
!__same_type(*(ptr), void), \ "pointer type mismatch in container_of()"); \
((type __user *)(__mptr - offsetof(type, member))); })
/* * check_user_mbz: Check that a user value exists and is zero * * Frequently in our uABI we reserve space for future extensions, and * two ensure that userspace is prepared we enforce that space must * be zero. (Then any future extension can safely assume a default value * of 0.) * * check_user_mbz() combines checking that the user pointer is accessible * and that the contained value is zero. * * Returns: -EFAULT if not accessible, -EINVAL if !zero, or 0 on success.
*/ #define check_user_mbz(U) ({ \
typeof(*(U)) mbz__; \
get_user(mbz__, (U)) ? -EFAULT : mbz__ ? -EINVAL : 0; \
})
/* * If you need to wait X milliseconds between events A and B, but event B * doesn't happen exactly after event A, you record the timestamp (jiffies) of * when event A happened, then just before event B you call this function and * pass the timestamp as the first argument, and X as the second argument.
*/ staticinlinevoid
wait_remaining_ms_from_jiffies(unsignedlong timestamp_jiffies, int to_wait_ms)
{ unsignedlong target_jiffies, tmp_jiffies, remaining_jiffies;
/* * Don't re-read the value of "jiffies" every time since it may change * behind our back and break the math.
*/
tmp_jiffies = jiffies;
target_jiffies = timestamp_jiffies +
msecs_to_jiffies_timeout(to_wait_ms);
if (time_after(target_jiffies, tmp_jiffies)) {
remaining_jiffies = target_jiffies - tmp_jiffies; while (remaining_jiffies)
remaining_jiffies =
schedule_timeout_uninterruptible(remaining_jiffies);
}
}
/* * __wait_for - magic wait macro * * Macro to help avoid open coding check/wait/timeout patterns. Note that it's * important that we check the condition again after having timed out, since the * timeout could be due to preemption or similar and we've never had a chance to * check the condition before the timeout.
*/ #define __wait_for(OP, COND, US, Wmin, Wmax) ({ \ const ktime_t end__ = ktime_add_ns(ktime_get_raw(), 1000ll * (US)); \ long wait__ = (Wmin); /* recommended min for usleep is 10 us */ \ int ret__; \
might_sleep(); \ for (;;) { \ constbool expired__ = ktime_after(ktime_get_raw(), end__); \
OP; \ /* Guarantee COND check prior to timeout */ \
barrier(); \ if (COND) { \
ret__ = 0; \ break; \
} \ if (expired__) { \
ret__ = -ETIMEDOUT; \ break; \
} \
usleep_range(wait__, wait__ * 2); \ if (wait__ < (Wmax)) \
wait__ <<= 1; \
} \
ret__; \
})
void add_taint_for_CI(struct drm_i915_private *i915, unsignedint taint); staticinlinevoid __add_taint_for_CI(unsignedint taint)
{ /* * The system is "ok", just about surviving for the user, but * CI results are now unreliable as the HW is very suspect. * CI checks the taint state after every test and will reboot * the machine if the kernel is tainted.
*/
add_taint(taint, LOCKDEP_STILL_OK);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.