linux/drivers/gpu/drm/i915/i915_utils.h

/*
 * 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/list.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;
struct timer_list;

#define FDO_BUG_URL

#define MISSING_CASE(x)

#if IS_ENABLED(CONFIG_DRM_I915_DEBUG)

int __i915_inject_probe_error(struct drm_i915_private *i915, int err,
			      const char *func, int line);
#define i915_inject_probe_error
bool i915_error_injected(void);

#else

#define i915_inject_probe_error(i915, e)
#define i915_error_injected()

#endif

#define i915_inject_probe_failure(i915)

#define i915_probe_error(i915, fmt, ...)

#define range_overflows(start, size, max)

#define range_overflows_t(type, start, size, max)

#define range_overflows_end(start, size, max)

#define range_overflows_end_t(type, start, size, max)

#define ptr_mask_bits(ptr, n)

#define ptr_unmask_bits(ptr, n)

#define ptr_unpack_bits(ptr, bits, n)

#define ptr_pack_bits(ptr, bits, n)

#define ptr_dec(ptr)

#define ptr_inc(ptr)

#define page_mask_bits(ptr)
#define page_unmask_bits(ptr)
#define page_pack_bits(ptr, bits)
#define page_unpack_bits(ptr, bits)

#define fetch_and_zero(ptr)

static __always_inline ptrdiff_t ptrdiff(const void *a, const void *b)
{}

/*
 * 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)

/*
 * 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)

#define u64_to_ptr(T, x)

#define __mask_next_bit(mask)

static inline bool is_power_of_2_u64(u64 n)
{}

static inline void __list_del_many(struct list_head *head,
				   struct list_head *first)
{}

static inline int list_is_last_rcu(const struct list_head *list,
				   const struct list_head *head)
{}

static inline unsigned long msecs_to_jiffies_timeout(const unsigned int m)
{}

/*
 * 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.
 */
static inline void
wait_remaining_ms_from_jiffies(unsigned long timestamp_jiffies, int to_wait_ms)
{}

/*
 * __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)

#define _wait_for(COND, US, Wmin, Wmax)
#define wait_for(COND, MS)

/* If CONFIG_PREEMPT_COUNT is disabled, in_atomic() always reports false. */
#if defined(CONFIG_DRM_I915_DEBUG) && defined(CONFIG_PREEMPT_COUNT)
#define _WAIT_FOR_ATOMIC_CHECK
#else
#define _WAIT_FOR_ATOMIC_CHECK(ATOMIC)
#endif

#define _wait_for_atomic(COND, US, ATOMIC)

#define wait_for_us(COND, US)

#define wait_for_atomic_us(COND, US)

#define wait_for_atomic(COND, MS)

#define KHz(x)
#define MHz(x)

void add_taint_for_CI(struct drm_i915_private *i915, unsigned int taint);
static inline void __add_taint_for_CI(unsigned int taint)
{}

void cancel_timer(struct timer_list *t);
void set_timer_ms(struct timer_list *t, unsigned long timeout);

static inline bool timer_active(const struct timer_list *t)
{}

static inline bool timer_expired(const struct timer_list *t)
{}

static inline bool i915_run_as_guest(void)
{}

bool i915_vtd_active(struct drm_i915_private *i915);

bool i915_direct_stolen_access(struct drm_i915_private *i915);

#endif /* !__I915_UTILS_H */