xref: /linux/drivers/gpu/drm/i915/display/intel_modeset_lock.h (revision c532de5a67a70f8533d495f8f2aaa9a0491c3ad0)
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2023 Intel Corporation
4  */
5 
6 #ifndef __INTEL_MODESET_LOCK_H__
7 #define __INTEL_MODESET_LOCK_H__
8 
9 #include <linux/types.h>
10 
11 struct drm_modeset_acquire_ctx;
12 struct intel_atomic_state;
13 
14 void _intel_modeset_lock_begin(struct drm_modeset_acquire_ctx *ctx,
15 			       struct intel_atomic_state *state,
16 			       unsigned int flags,
17 			       int *ret);
18 bool _intel_modeset_lock_loop(int *ret);
19 void _intel_modeset_lock_end(struct drm_modeset_acquire_ctx *ctx,
20 			     struct intel_atomic_state *state,
21 			     int *ret);
22 
23 /*
24  * Note that one must always use "continue" rather than
25  * "break" or "return" to handle errors within the
26  * intel_modeset_lock_ctx_retry() block.
27  */
28 #define intel_modeset_lock_ctx_retry(ctx, state, flags, ret) \
29 	for (_intel_modeset_lock_begin((ctx), (state), (flags), &(ret)); \
30 	     _intel_modeset_lock_loop(&(ret)); \
31 	     _intel_modeset_lock_end((ctx), (state), &(ret)))
32 
33 #endif /* __INTEL_MODESET_LOCK_H__ */
34