Skip to content

Commit e9eafcb

Browse files
sravnborgdanvet
authored andcommitted
drm: move drm_can_sleep() to drm_util.h
Move drm_can_sleep() out of drmP.h to allow users to get rid of the drmP.h include. There was no header file that was a good match for this helper function. So add this to drm_util with the relevant includes. Add include of drm_util.h to all users. v2: - Update comments to use kernel-doc style (Daniel) - Add FIXME to drm_can_sleep and add note that this function should not be used in new code (Daniel) v3: - Fix kernel-doc syntax (Daniel) - Plug drm_util.h into drm-internels.rst (Daniel) Signed-off-by: Sam Ravnborg <[email protected]> Cc: Maarten Lankhorst <[email protected]> Cc: Maxime Ripard <[email protected]> Cc: Sean Paul <[email protected]> Cc: David Airlie <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: Alex Deucher <[email protected]> Cc: "Christian König" <[email protected]> Cc: "David (ChunMing) Zhou" <[email protected]> Cc: Gerd Hoffmann <[email protected]> Cc: Rob Clark <[email protected]> Cc: Tomi Valkeinen <[email protected]> Cc: Eric Anholt <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent f5d5ef7 commit e9eafcb

File tree

14 files changed

+66
-9
lines changed

14 files changed

+66
-9
lines changed

Documentation/gpu/drm-internals.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,15 @@ Printer
233233
.. kernel-doc:: drivers/gpu/drm/drm_print.c
234234
:export:
235235

236+
Utilities
237+
---------
238+
239+
.. kernel-doc:: include/drm/drm_util.h
240+
:doc: drm utils
241+
242+
.. kernel-doc:: include/drm/drm_util.h
243+
:internal:
244+
236245

237246
Legacy Support Code
238247
===================

drivers/gpu/drm/amd/amdgpu/atom.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#include <linux/slab.h>
2828
#include <asm/unaligned.h>
2929

30+
#include <drm/drm_util.h>
31+
3032
#define ATOM_DEBUG
3133

3234
#include "atom.h"

drivers/gpu/drm/ast/ast_fb.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@
3939
#include <drm/drmP.h>
4040
#include <drm/drm_crtc.h>
4141
#include <drm/drm_fb_helper.h>
42+
#include <drm/drm_util.h>
4243
#include <drm/drm_crtc_helper.h>
44+
4345
#include "ast_drv.h"
4446

4547
static void ast_dirty_update(struct ast_fbdev *afbdev,

drivers/gpu/drm/cirrus/cirrus_fbdev.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111
#include <linux/module.h>
1212
#include <drm/drmP.h>
13+
#include <drm/drm_util.h>
1314
#include <drm/drm_fb_helper.h>
1415
#include <drm/drm_crtc_helper.h>
1516

drivers/gpu/drm/drm_flip_work.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
*/
2323

2424
#include <drm/drmP.h>
25+
#include <drm/drm_util.h>
2526
#include <drm/drm_flip_work.h>
2627

2728
/**

drivers/gpu/drm/mgag200/mgag200_fb.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*/
1313
#include <linux/module.h>
1414
#include <drm/drmP.h>
15+
#include <drm/drm_util.h>
1516
#include <drm/drm_fb_helper.h>
1617
#include <drm/drm_crtc_helper.h>
1718

drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* this program. If not, see <http://www.gnu.org/licenses/>.
1717
*/
1818

19+
#include <drm/drm_util.h>
1920

2021
#include "mdp5_kms.h"
2122
#include "mdp5_smp.h"

drivers/gpu/drm/omapdrm/omap_fbdev.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717

1818
#include <drm/drm_crtc.h>
19+
#include <drm/drm_util.h>
1920
#include <drm/drm_fb_helper.h>
2021

2122
#include "omap_drv.h"

drivers/gpu/drm/qxl/qxl_cmd.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626
/* QXL cmd/ring handling */
2727

28+
#include <drm/drm_util.h>
29+
2830
#include "qxl_drv.h"
2931
#include "qxl_object.h"
3032

drivers/gpu/drm/radeon/atom.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#include <linux/slab.h>
2828
#include <asm/unaligned.h>
2929

30+
#include <drm/drm_util.h>
31+
3032
#define ATOM_DEBUG
3133

3234
#include "atom.h"

drivers/gpu/drm/radeon/radeon_legacy_encoders.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
* Alex Deucher
2525
*/
2626
#include <drm/drmP.h>
27+
#include <drm/drm_util.h>
2728
#include <drm/drm_crtc_helper.h>
2829
#include <drm/radeon_drm.h>
2930
#include "radeon.h"

drivers/gpu/drm/vc4/vc4_drv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <linux/mm_types.h>
1010
#include <linux/reservation.h>
1111
#include <drm/drmP.h>
12+
#include <drm/drm_util.h>
1213
#include <drm/drm_encoder.h>
1314
#include <drm/drm_gem_cma_helper.h>
1415
#include <drm/drm_atomic.h>

include/drm/drmP.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,6 @@ struct dma_buf_attachment;
9494
struct pci_dev;
9595
struct pci_controller;
9696

97-
/* returns true if currently okay to sleep */
98-
static inline bool drm_can_sleep(void)
99-
{
100-
if (in_atomic() || in_dbg_master() || irqs_disabled())
101-
return false;
102-
return true;
103-
}
104-
10597
#if defined(CONFIG_DRM_DEBUG_SELFTEST_MODULE)
10698
#define EXPORT_SYMBOL_FOR_TESTS_ONLY(x) EXPORT_SYMBOL(x)
10799
#else

include/drm/drm_util.h

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,48 @@
2626
#ifndef _DRM_UTIL_H_
2727
#define _DRM_UTIL_H_
2828

29-
/* helper for handling conditionals in various for_each macros */
29+
/**
30+
* DOC: drm utils
31+
*
32+
* Macros and inline functions that does not naturally belong in other places
33+
*/
34+
35+
#include <linux/irqflags.h>
36+
#include <linux/preempt.h>
37+
#include <linux/kgdb.h>
38+
#include <linux/smp.h>
39+
40+
/**
41+
* for_each_if - helper for handling conditionals in various for_each macros
42+
* @condition: The condition to check
43+
*
44+
* Typical use::
45+
*
46+
* #define for_each_foo_bar(x, y) \'
47+
* list_for_each_entry(x, y->list, head) \'
48+
* for_each_if(x->something == SOMETHING)
49+
*
50+
* The for_each_if() macro makes the use of for_each_foo_bar() less error
51+
* prone.
52+
*/
3053
#define for_each_if(condition) if (!(condition)) {} else
3154

55+
/**
56+
* drm_can_sleep - returns true if currently okay to sleep
57+
*
58+
* This function shall not be used in new code.
59+
* The check for running in atomic context may not work - see linux/preempt.h.
60+
*
61+
* FIXME: All users of drm_can_sleep should be removed (see todo.rst)
62+
*
63+
* Returns:
64+
* True if kgdb is active or we are in an atomic context or irqs are disabled
65+
*/
66+
static inline bool drm_can_sleep(void)
67+
{
68+
if (in_atomic() || in_dbg_master() || irqs_disabled())
69+
return false;
70+
return true;
71+
}
72+
3273
#endif

0 commit comments

Comments
 (0)