2016-04-13 17:35:02 +01:00
|
|
|
/*
|
|
|
|
|
* 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_GEM_H__
|
|
|
|
|
#define __I915_GEM_H__
|
|
|
|
|
|
2017-05-03 10:39:21 +01:00
|
|
|
#include <linux/bug.h>
|
2022-09-05 18:00:53 +03:00
|
|
|
#include <linux/types.h>
|
2017-05-03 10:39:21 +01:00
|
|
|
|
2019-08-06 13:07:28 +03:00
|
|
|
#include <drm/drm_drv.h>
|
|
|
|
|
|
2019-11-19 10:09:13 +00:00
|
|
|
#include "i915_utils.h"
|
|
|
|
|
|
2022-09-05 18:00:53 +03:00
|
|
|
struct drm_file;
|
|
|
|
|
struct drm_i915_gem_object;
|
2018-04-06 16:51:44 +01:00
|
|
|
struct drm_i915_private;
|
2022-09-05 18:00:53 +03:00
|
|
|
struct i915_gem_ww_ctx;
|
2022-09-21 07:46:54 +10:00
|
|
|
struct i915_gtt_view;
|
2022-09-05 18:00:53 +03:00
|
|
|
struct i915_vma;
|
|
|
|
|
|
|
|
|
|
void i915_gem_init_early(struct drm_i915_private *i915);
|
|
|
|
|
void i915_gem_cleanup_early(struct drm_i915_private *i915);
|
|
|
|
|
|
|
|
|
|
void i915_gem_drain_freed_objects(struct drm_i915_private *i915);
|
|
|
|
|
void i915_gem_drain_workqueue(struct drm_i915_private *i915);
|
|
|
|
|
|
|
|
|
|
struct i915_vma * __must_check
|
|
|
|
|
i915_gem_object_ggtt_pin_ww(struct drm_i915_gem_object *obj,
|
|
|
|
|
struct i915_gem_ww_ctx *ww,
|
2022-09-21 07:46:54 +10:00
|
|
|
const struct i915_gtt_view *view,
|
2022-09-05 18:00:53 +03:00
|
|
|
u64 size, u64 alignment, u64 flags);
|
|
|
|
|
|
|
|
|
|
struct i915_vma * __must_check
|
|
|
|
|
i915_gem_object_ggtt_pin(struct drm_i915_gem_object *obj,
|
2022-09-21 07:46:54 +10:00
|
|
|
const struct i915_gtt_view *view,
|
2022-09-05 18:00:53 +03:00
|
|
|
u64 size, u64 alignment, u64 flags);
|
|
|
|
|
|
|
|
|
|
int i915_gem_object_unbind(struct drm_i915_gem_object *obj,
|
|
|
|
|
unsigned long flags);
|
|
|
|
|
#define I915_GEM_OBJECT_UNBIND_ACTIVE BIT(0)
|
|
|
|
|
#define I915_GEM_OBJECT_UNBIND_BARRIER BIT(1)
|
|
|
|
|
#define I915_GEM_OBJECT_UNBIND_TEST BIT(2)
|
|
|
|
|
#define I915_GEM_OBJECT_UNBIND_VM_TRYLOCK BIT(3)
|
|
|
|
|
#define I915_GEM_OBJECT_UNBIND_ASYNC BIT(4)
|
|
|
|
|
|
|
|
|
|
void i915_gem_runtime_suspend(struct drm_i915_private *i915);
|
|
|
|
|
|
|
|
|
|
int __must_check i915_gem_init(struct drm_i915_private *i915);
|
|
|
|
|
void i915_gem_driver_register(struct drm_i915_private *i915);
|
|
|
|
|
void i915_gem_driver_unregister(struct drm_i915_private *i915);
|
|
|
|
|
void i915_gem_driver_remove(struct drm_i915_private *i915);
|
|
|
|
|
void i915_gem_driver_release(struct drm_i915_private *i915);
|
|
|
|
|
|
|
|
|
|
int i915_gem_open(struct drm_i915_private *i915, struct drm_file *file);
|
|
|
|
|
|
|
|
|
|
/* FIXME: All of the below belong somewhere else. */
|
2018-04-06 16:51:44 +01:00
|
|
|
|
2016-04-13 17:35:02 +01:00
|
|
|
#ifdef CONFIG_DRM_I915_DEBUG_GEM
|
2018-04-26 11:32:19 +01:00
|
|
|
|
2019-10-28 12:38:15 +02:00
|
|
|
#define GEM_SHOW_DEBUG() drm_debug_enabled(DRM_UT_DRIVER)
|
2018-04-26 11:32:19 +01:00
|
|
|
|
2021-01-14 11:34:34 +00:00
|
|
|
#ifdef CONFIG_DRM_I915_DEBUG_GEM_ONCE
|
|
|
|
|
#define __GEM_BUG(cond) BUG()
|
|
|
|
|
#else
|
|
|
|
|
#define __GEM_BUG(cond) \
|
|
|
|
|
WARN(1, "%s:%d GEM_BUG_ON(%s)\n", __func__, __LINE__, __stringify(cond))
|
|
|
|
|
#endif
|
|
|
|
|
|
2017-11-16 10:39:54 +02:00
|
|
|
#define GEM_BUG_ON(condition) do { if (unlikely((condition))) { \
|
2019-10-10 08:14:26 +01:00
|
|
|
GEM_TRACE_ERR("%s:%d GEM_BUG_ON(%s)\n", \
|
|
|
|
|
__func__, __LINE__, __stringify(condition)); \
|
2019-11-19 10:09:13 +00:00
|
|
|
GEM_TRACE_DUMP(); \
|
2021-01-14 11:34:34 +00:00
|
|
|
__GEM_BUG(condition); \
|
2017-11-16 10:39:54 +02:00
|
|
|
} \
|
|
|
|
|
} while(0)
|
2016-12-13 20:32:19 +00:00
|
|
|
#define GEM_WARN_ON(expr) WARN_ON(expr)
|
2017-02-06 17:05:01 +00:00
|
|
|
|
2018-10-12 07:31:42 +01:00
|
|
|
#define GEM_DEBUG_WARN_ON(expr) GEM_WARN_ON(expr)
|
2017-02-06 17:05:01 +00:00
|
|
|
|
2016-04-13 17:35:02 +01:00
|
|
|
#else
|
2018-04-26 11:32:19 +01:00
|
|
|
|
|
|
|
|
#define GEM_SHOW_DEBUG() (0)
|
|
|
|
|
|
2016-12-02 18:47:50 +00:00
|
|
|
#define GEM_BUG_ON(expr) BUILD_BUG_ON_INVALID(expr)
|
2018-10-12 07:31:42 +01:00
|
|
|
#define GEM_WARN_ON(expr) ({ unlikely(!!(expr)); })
|
2017-02-06 17:05:01 +00:00
|
|
|
|
2018-10-12 07:31:42 +01:00
|
|
|
#define GEM_DEBUG_WARN_ON(expr) ({ BUILD_BUG_ON_INVALID(expr); 0; })
|
2016-04-13 17:35:02 +01:00
|
|
|
#endif
|
|
|
|
|
|
2017-11-09 14:30:19 +00:00
|
|
|
#if IS_ENABLED(CONFIG_DRM_I915_TRACE_GEM)
|
|
|
|
|
#define GEM_TRACE(...) trace_printk(__VA_ARGS__)
|
2019-10-10 08:14:26 +01:00
|
|
|
#define GEM_TRACE_ERR(...) do { \
|
|
|
|
|
pr_err(__VA_ARGS__); \
|
|
|
|
|
trace_printk(__VA_ARGS__); \
|
|
|
|
|
} while (0)
|
2019-11-10 18:57:54 +00:00
|
|
|
#define GEM_TRACE_DUMP() \
|
2020-07-06 16:41:06 +02:00
|
|
|
do { ftrace_dump(DUMP_ALL); __add_taint_for_CI(TAINT_WARN); } while (0)
|
2018-05-24 09:11:35 +01:00
|
|
|
#define GEM_TRACE_DUMP_ON(expr) \
|
2019-11-10 18:57:54 +00:00
|
|
|
do { if (expr) GEM_TRACE_DUMP(); } while (0)
|
2017-11-09 14:30:19 +00:00
|
|
|
#else
|
|
|
|
|
#define GEM_TRACE(...) do { } while (0)
|
2019-10-10 08:14:26 +01:00
|
|
|
#define GEM_TRACE_ERR(...) do { } while (0)
|
2018-03-09 10:11:14 +00:00
|
|
|
#define GEM_TRACE_DUMP() do { } while (0)
|
2018-05-24 09:11:35 +01:00
|
|
|
#define GEM_TRACE_DUMP_ON(expr) BUILD_BUG_ON_INVALID(expr)
|
2017-11-09 14:30:19 +00:00
|
|
|
#endif
|
|
|
|
|
|
2019-03-07 10:45:29 +00:00
|
|
|
#define I915_GEM_IDLE_TIMEOUT (HZ / 5)
|
|
|
|
|
|
2016-04-13 17:35:02 +01:00
|
|
|
#endif /* __I915_GEM_H__ */
|