Home | History | Annotate | Line # | Download | only in gt
      1 /*	$NetBSD: intel_reset_types.h,v 1.4 2021/12/19 11:49:11 riastradh Exp $	*/
      2 
      3 /* SPDX-License-Identifier: MIT */
      4 /*
      5  * Copyright  2019 Intel Corporation
      6  */
      7 
      8 #ifndef __INTEL_RESET_TYPES_H_
      9 #define __INTEL_RESET_TYPES_H_
     10 
     11 #include <linux/mutex.h>
     12 #include <linux/wait.h>
     13 #include <linux/srcu.h>
     14 #include <drm/drm_wait_netbsd.h> /* XXX */
     15 
     16 struct intel_reset {
     17 	/**
     18 	 * flags: Control various stages of the GPU reset
     19 	 *
     20 	 * #I915_RESET_BACKOFF - When we start a global reset, we need to
     21 	 * serialise with any other users attempting to do the same, and
     22 	 * any global resources that may be clobber by the reset (such as
     23 	 * FENCE registers).
     24 	 *
     25 	 * #I915_RESET_ENGINE[num_engines] - Since the driver doesn't need to
     26 	 * acquire the struct_mutex to reset an engine, we need an explicit
     27 	 * flag to prevent two concurrent reset attempts in the same engine.
     28 	 * As the number of engines continues to grow, allocate the flags from
     29 	 * the most significant bits.
     30 	 *
     31 	 * #I915_WEDGED - If reset fails and we can no longer use the GPU,
     32 	 * we set the #I915_WEDGED bit. Prior to command submission, e.g.
     33 	 * i915_request_alloc(), this bit is checked and the sequence
     34 	 * aborted (with -EIO reported to userspace) if set.
     35 	 *
     36 	 * #I915_WEDGED_ON_INIT - If we fail to initialize the GPU we can no
     37 	 * longer use the GPU - similar to #I915_WEDGED bit. The difference in
     38 	 * in the way we're handling "forced" unwedged (e.g. through debugfs),
     39 	 * which is not allowed in case we failed to initialize.
     40 	 */
     41 	unsigned long flags;
     42 #define I915_RESET_BACKOFF	0
     43 #define I915_RESET_MODESET	1
     44 #define I915_RESET_ENGINE	2
     45 #define I915_WEDGED_ON_INIT	(BITS_PER_LONG - 2)
     46 #define I915_WEDGED		(BITS_PER_LONG - 1)
     47 
     48 	struct mutex mutex; /* serialises wedging/unwedging */
     49 
     50 	/**
     51 	 * Waitqueue to signal when the reset has completed. Used by clients
     52 	 * that wait for dev_priv->mm.wedged to settle.
     53 	 */
     54 	spinlock_t lock;
     55 	drm_waitqueue_t queue;
     56 
     57 	struct srcu_struct backoff_srcu;
     58 };
     59 
     60 #endif /* _INTEL_RESET_TYPES_H_ */
     61