brintos

brintos / linux-shallow public Read only

0
0
Text · 1.0 KiB · 86f0fe3 Raw
42 lines · c
1/* SPDX-License-Identifier: MIT */2/*3 * Copyright © 2020 Intel Corporation4 */5#ifndef __I915_GEM_WW_H__6#define __I915_GEM_WW_H__7 8#include <drm/drm_drv.h>9 10struct i915_gem_ww_ctx {11	struct ww_acquire_ctx ctx;12	struct list_head obj_list;13	struct drm_i915_gem_object *contended;14	bool intr;15};16 17void i915_gem_ww_ctx_init(struct i915_gem_ww_ctx *ctx, bool intr);18void i915_gem_ww_ctx_fini(struct i915_gem_ww_ctx *ctx);19int __must_check i915_gem_ww_ctx_backoff(struct i915_gem_ww_ctx *ctx);20void i915_gem_ww_unlock_single(struct drm_i915_gem_object *obj);21 22/* Internal function used by the inlines! Don't use. */23static inline int __i915_gem_ww_fini(struct i915_gem_ww_ctx *ww, int err)24{25	if (err == -EDEADLK) {26		err = i915_gem_ww_ctx_backoff(ww);27		if (!err)28			err = -EDEADLK;29	}30 31	if (err != -EDEADLK)32		i915_gem_ww_ctx_fini(ww);33 34	return err;35}36 37#define for_i915_gem_ww(_ww, _err, _intr)			  \38	for (i915_gem_ww_ctx_init(_ww, _intr), (_err) = -EDEADLK; \39	     (_err) == -EDEADLK;				  \40	     (_err) = __i915_gem_ww_fini(_ww, _err))41#endif42