Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: MIT */
0002 /*
0003  * Copyright © 2020 Intel Corporation
0004  */
0005 #ifndef __I915_GEM_WW_H__
0006 #define __I915_GEM_WW_H__
0007 
0008 #include <drm/drm_drv.h>
0009 
0010 struct i915_gem_ww_ctx {
0011     struct ww_acquire_ctx ctx;
0012     struct list_head obj_list;
0013     struct drm_i915_gem_object *contended;
0014     bool intr;
0015 };
0016 
0017 void i915_gem_ww_ctx_init(struct i915_gem_ww_ctx *ctx, bool intr);
0018 void i915_gem_ww_ctx_fini(struct i915_gem_ww_ctx *ctx);
0019 int __must_check i915_gem_ww_ctx_backoff(struct i915_gem_ww_ctx *ctx);
0020 void i915_gem_ww_unlock_single(struct drm_i915_gem_object *obj);
0021 
0022 /* Internal function used by the inlines! Don't use. */
0023 static inline int __i915_gem_ww_fini(struct i915_gem_ww_ctx *ww, int err)
0024 {
0025     if (err == -EDEADLK) {
0026         err = i915_gem_ww_ctx_backoff(ww);
0027         if (!err)
0028             err = -EDEADLK;
0029     }
0030 
0031     if (err != -EDEADLK)
0032         i915_gem_ww_ctx_fini(ww);
0033 
0034     return err;
0035 }
0036 
0037 #define for_i915_gem_ww(_ww, _err, _intr)             \
0038     for (i915_gem_ww_ctx_init(_ww, _intr), (_err) = -EDEADLK; \
0039          (_err) == -EDEADLK;                  \
0040          (_err) = __i915_gem_ww_fini(_ww, _err))
0041 #endif