blob: fe6d514a0833e1d2fe4fe4a62911ccc96423e3e6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
/* SPDX-License-Identifier: GPL-2.0 or MIT */
/*
* Copyright (c) 2024 Intel
* Copyright (c) 2024 Red Hat
*/
#ifndef __DRM_PANIC_INTERNAL_H__
#define __DRM_PANIC_INTERNAL_H__
#include <linux/spinlock.h>
struct drm_device;
#ifdef CONFIG_DRM_PANIC
/**
* drm_panic_lock - protect panic printing relevant state
* @dev: struct drm_device
* @flags: unsigned long irq flags you need to pass to the unlock() counterpart
*
* This function must be called to protect software and hardware state that the
* panic printing code must be able to rely on. The protected sections must be
* as small as possible. It uses the irqsave/irqrestore variant, and can be
* called from irq handler. Examples include:
*
* - Access to peek/poke or other similar registers, if that is the way the
* driver prints the pixels into the scanout buffer at panic time.
*
* - Updates to pointers like &drm_plane.state, allowing the panic handler to
* safely deference these. This is done in drm_atomic_helper_swap_state().
*
* - An state that isn't invariant and that the driver must be able to access
* during panic printing.
*/
#define drm_panic_lock(dev, flags) \
raw_spin_lock_irqsave(&(dev)->mode_config.panic_lock, flags)
/**
* drm_panic_unlock - end of the panic printing critical section
* @dev: struct drm_device
* @flags: irq flags that were returned when acquiring the lock
*
* Unlocks the raw spinlock acquired by either drm_panic_lock() or
* drm_panic_trylock().
*/
#define drm_panic_unlock(dev, flags) \
raw_spin_unlock_irqrestore(&(dev)->mode_config.panic_lock, flags)
#else
static inline void drm_panic_lock(struct drm_device *dev, unsigned long flags) {}
static inline void drm_panic_unlock(struct drm_device *dev, unsigned long flags) {}
#endif
#if IS_ENABLED(CONFIG_DRM_PANIC_HELPER)
/* drm_panic_helper.c */
int __init drm_panic_helper_init(void);
void __exit drm_panic_helper_exit(void);
#else
static inline int __init drm_panic_helper_init(void)
{
return 0;
}
static inline void __exit drm_panic_helper_exit(void)
{ }
#endif
#endif /* __DRM_PANIC_INTERNAL_H__ */
|