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_breadcrumbs_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 kref *kref); 21 22 void intel_breadcrumbs_reset(struct intel_breadcrumbs *b); 23 void __intel_breadcrumbs_park(struct intel_breadcrumbs *b); 24 intel_breadcrumbs_unpark(struct intel_breadcrumbs * b)25static inline void intel_breadcrumbs_unpark(struct intel_breadcrumbs *b) 26 { 27 atomic_inc(&b->active); 28 } 29 intel_breadcrumbs_park(struct intel_breadcrumbs * b)30static 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 intel_engine_signal_breadcrumbs(struct intel_engine_cs * engine)37intel_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 static inline struct intel_breadcrumbs * intel_breadcrumbs_get(struct intel_breadcrumbs * b)52intel_breadcrumbs_get(struct intel_breadcrumbs *b) 53 { 54 kref_get(&b->ref); 55 return b; 56 } 57 intel_breadcrumbs_put(struct intel_breadcrumbs * b)58static inline void intel_breadcrumbs_put(struct intel_breadcrumbs *b) 59 { 60 kref_put(&b->ref, intel_breadcrumbs_free); 61 } 62 63 #endif /* __INTEL_BREADCRUMBS__ */ 64