Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright © 2016 Intel Corporation
0003  *
0004  * Permission is hereby granted, free of charge, to any person obtaining a
0005  * copy of this software and associated documentation files (the "Software"),
0006  * to deal in the Software without restriction, including without limitation
0007  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0008  * and/or sell copies of the Software, and to permit persons to whom the
0009  * Software is furnished to do so, subject to the following conditions:
0010  *
0011  * The above copyright notice and this permission notice (including the next
0012  * paragraph) shall be included in all copies or substantial portions of the
0013  * Software.
0014  *
0015  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0016  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0017  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0018  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
0019  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
0020  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
0021  * IN THE SOFTWARE.
0022  *
0023  */
0024 
0025 #ifndef __I915_GEM_H__
0026 #define __I915_GEM_H__
0027 
0028 #include <linux/bug.h>
0029 
0030 #include <drm/drm_drv.h>
0031 
0032 #include "i915_utils.h"
0033 
0034 struct drm_i915_private;
0035 
0036 #ifdef CONFIG_DRM_I915_DEBUG_GEM
0037 
0038 #define GEM_SHOW_DEBUG() drm_debug_enabled(DRM_UT_DRIVER)
0039 
0040 #ifdef CONFIG_DRM_I915_DEBUG_GEM_ONCE
0041 #define __GEM_BUG(cond) BUG()
0042 #else
0043 #define __GEM_BUG(cond) \
0044     WARN(1, "%s:%d GEM_BUG_ON(%s)\n", __func__, __LINE__, __stringify(cond))
0045 #endif
0046 
0047 #define GEM_BUG_ON(condition) do { if (unlikely((condition))) { \
0048         GEM_TRACE_ERR("%s:%d GEM_BUG_ON(%s)\n", \
0049                   __func__, __LINE__, __stringify(condition)); \
0050         GEM_TRACE_DUMP(); \
0051         __GEM_BUG(condition); \
0052         } \
0053     } while(0)
0054 #define GEM_WARN_ON(expr) WARN_ON(expr)
0055 
0056 #define GEM_DEBUG_WARN_ON(expr) GEM_WARN_ON(expr)
0057 
0058 #else
0059 
0060 #define GEM_SHOW_DEBUG() (0)
0061 
0062 #define GEM_BUG_ON(expr) BUILD_BUG_ON_INVALID(expr)
0063 #define GEM_WARN_ON(expr) ({ unlikely(!!(expr)); })
0064 
0065 #define GEM_DEBUG_WARN_ON(expr) ({ BUILD_BUG_ON_INVALID(expr); 0; })
0066 #endif
0067 
0068 #if IS_ENABLED(CONFIG_DRM_I915_TRACE_GEM)
0069 #define GEM_TRACE(...) trace_printk(__VA_ARGS__)
0070 #define GEM_TRACE_ERR(...) do {                     \
0071     pr_err(__VA_ARGS__);                        \
0072     trace_printk(__VA_ARGS__);                  \
0073 } while (0)
0074 #define GEM_TRACE_DUMP() \
0075     do { ftrace_dump(DUMP_ALL); __add_taint_for_CI(TAINT_WARN); } while (0)
0076 #define GEM_TRACE_DUMP_ON(expr) \
0077     do { if (expr) GEM_TRACE_DUMP(); } while (0)
0078 #else
0079 #define GEM_TRACE(...) do { } while (0)
0080 #define GEM_TRACE_ERR(...) do { } while (0)
0081 #define GEM_TRACE_DUMP() do { } while (0)
0082 #define GEM_TRACE_DUMP_ON(expr) BUILD_BUG_ON_INVALID(expr)
0083 #endif
0084 
0085 #define I915_GEM_IDLE_TIMEOUT (HZ / 5)
0086 
0087 #endif /* __I915_GEM_H__ */