mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-03-22 07:27:12 +08:00
The i915_utils.h and intel_display_utils.h were in some cases included from the same files, the former via i915_drv.h and the latter directly. This lead to a clash between MISSING_CASE() and fetch_and_zero() defined in both, requiring ifdefs. With the display dependency on i915_drv.h removed, we can also remove the now unnecessary ifdefs. Reviewed-by: Matt Roper <matthew.d.roper@intel.com> Link: https://patch.msgid.link/f40a1fd365cbcfb77bd76ce0041c4523699f6052.1767009044.git.jani.nikula@intel.com Signed-off-by: Jani Nikula <jani.nikula@intel.com>
110 lines
3.3 KiB
C
110 lines
3.3 KiB
C
/*
|
|
* Copyright © 2016 Intel Corporation
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
* to deal in the Software without restriction, including without limitation
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice (including the next
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
* Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
* IN THE SOFTWARE.
|
|
*
|
|
*/
|
|
|
|
#ifndef __I915_UTILS_H
|
|
#define __I915_UTILS_H
|
|
|
|
#include <linux/overflow.h>
|
|
#include <linux/sched.h>
|
|
#include <linux/string_helpers.h>
|
|
#include <linux/types.h>
|
|
#include <linux/workqueue.h>
|
|
#include <linux/sched/clock.h>
|
|
|
|
#ifdef CONFIG_X86
|
|
#include <asm/hypervisor.h>
|
|
#endif
|
|
|
|
struct drm_i915_private;
|
|
|
|
#define MISSING_CASE(x) WARN(1, "Missing case (%s == %ld)\n", \
|
|
__stringify(x), (long)(x))
|
|
|
|
#define i915_probe_error(i915, fmt, ...) ({ \
|
|
drm_err(&(i915)->drm, fmt, ##__VA_ARGS__); \
|
|
})
|
|
|
|
#define fetch_and_zero(ptr) ({ \
|
|
typeof(*ptr) __T = *(ptr); \
|
|
*(ptr) = (typeof(*ptr))0; \
|
|
__T; \
|
|
})
|
|
|
|
/*
|
|
* 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; \
|
|
})
|
|
|
|
#define __mask_next_bit(mask) ({ \
|
|
int __idx = ffs(mask) - 1; \
|
|
mask &= ~BIT(__idx); \
|
|
__idx; \
|
|
})
|
|
|
|
static inline bool is_power_of_2_u64(u64 n)
|
|
{
|
|
return (n != 0 && ((n & (n - 1)) == 0));
|
|
}
|
|
|
|
void add_taint_for_CI(struct drm_i915_private *i915, unsigned int taint);
|
|
static inline void __add_taint_for_CI(unsigned int 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);
|
|
}
|
|
|
|
static inline bool i915_run_as_guest(void)
|
|
{
|
|
#if IS_ENABLED(CONFIG_X86)
|
|
return !hypervisor_is_type(X86_HYPER_NATIVE);
|
|
#else
|
|
/* Not supported yet */
|
|
return false;
|
|
#endif
|
|
}
|
|
|
|
bool i915_vtd_active(struct drm_i915_private *i915);
|
|
|
|
bool i915_direct_stolen_access(struct drm_i915_private *i915);
|
|
|
|
#endif /* !__I915_UTILS_H */
|