1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2019 Intel Corporation
4  */
5 
6 #ifndef __INTEL_BREADCRUMBS__
7 #define __INTEL_BREADCRUMBS__
8 
9 #include <linux/atomic.h>
10 #include <linux/irq_work.h>
11 
12 #include "intel_engine_types.h"
13 
14 struct drm_printer;
15 struct i915_request;
16 struct intel_breadcrumbs;
17 
18 struct intel_breadcrumbs *
19 intel_breadcrumbs_create(struct intel_engine_cs *irq_engine);
20 void intel_breadcrumbs_free(struct intel_breadcrumbs *b);
21 
22 void intel_breadcrumbs_reset(struct intel_breadcrumbs *b);
23 void __intel_breadcrumbs_park(struct intel_breadcrumbs *b);
24 
25 static inline void intel_breadcrumbs_unpark(struct intel_breadcrumbs *b)
26 {
27 	atomic_inc(&b->active);
28 }
29 
30 static inline void intel_breadcrumbs_park(struct intel_breadcrumbs *b)
31 {
32 	if (atomic_dec_and_test(&b->active))
33 		__intel_breadcrumbs_park(b);
34 }
35 
36 static inline void
37 intel_engine_signal_breadcrumbs(struct intel_engine_cs *engine)
38 {
39 	irq_work_queue(&engine->breadcrumbs->irq_work);
40 }
41 
42 void intel_engine_print_breadcrumbs(struct intel_engine_cs *engine,
43 				    struct drm_printer *p);
44 
45 bool i915_request_enable_breadcrumb(struct i915_request *request);
46 void i915_request_cancel_breadcrumb(struct i915_request *request);
47 
48 void intel_context_remove_breadcrumbs(struct intel_context *ce,
49 				      struct intel_breadcrumbs *b);
50 
51 #endif /* __INTEL_BREADCRUMBS__ */
52