Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <sam@ravnborg.org>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <maxime.ripard@bootlin.com>
Cc: Sean Paul <sean@poorly.run>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: "Christian König" <christian.koenig@amd.com>
Cc: "David (ChunMing) Zhou" <David1.Zhou@amd.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Rob Clark <robdclark@gmail.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Eric Anholt <eric@anholt.net>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20190112193251.20450-2-sam@ravnborg.org

authored by

Sam Ravnborg and committed by
Daniel Vetter
e9eafcb5 f5d5ef72

+66 -9
+9
Documentation/gpu/drm-internals.rst
··· 233 233 .. kernel-doc:: drivers/gpu/drm/drm_print.c 234 234 :export: 235 235 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 + 236 245 237 246 Legacy Support Code 238 247 ===================
+2
drivers/gpu/drm/amd/amdgpu/atom.c
··· 27 27 #include <linux/slab.h> 28 28 #include <asm/unaligned.h> 29 29 30 + #include <drm/drm_util.h> 31 + 30 32 #define ATOM_DEBUG 31 33 32 34 #include "atom.h"
+2
drivers/gpu/drm/ast/ast_fb.c
··· 39 39 #include <drm/drmP.h> 40 40 #include <drm/drm_crtc.h> 41 41 #include <drm/drm_fb_helper.h> 42 + #include <drm/drm_util.h> 42 43 #include <drm/drm_crtc_helper.h> 44 + 43 45 #include "ast_drv.h" 44 46 45 47 static void ast_dirty_update(struct ast_fbdev *afbdev,
+1
drivers/gpu/drm/cirrus/cirrus_fbdev.c
··· 10 10 */ 11 11 #include <linux/module.h> 12 12 #include <drm/drmP.h> 13 + #include <drm/drm_util.h> 13 14 #include <drm/drm_fb_helper.h> 14 15 #include <drm/drm_crtc_helper.h> 15 16
+1
drivers/gpu/drm/drm_flip_work.c
··· 22 22 */ 23 23 24 24 #include <drm/drmP.h> 25 + #include <drm/drm_util.h> 25 26 #include <drm/drm_flip_work.h> 26 27 27 28 /**
+1
drivers/gpu/drm/mgag200/mgag200_fb.c
··· 12 12 */ 13 13 #include <linux/module.h> 14 14 #include <drm/drmP.h> 15 + #include <drm/drm_util.h> 15 16 #include <drm/drm_fb_helper.h> 16 17 #include <drm/drm_crtc_helper.h> 17 18
+1
drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c
··· 16 16 * this program. If not, see <http://www.gnu.org/licenses/>. 17 17 */ 18 18 19 + #include <drm/drm_util.h> 19 20 20 21 #include "mdp5_kms.h" 21 22 #include "mdp5_smp.h"
+1
drivers/gpu/drm/omapdrm/omap_fbdev.c
··· 16 16 */ 17 17 18 18 #include <drm/drm_crtc.h> 19 + #include <drm/drm_util.h> 19 20 #include <drm/drm_fb_helper.h> 20 21 21 22 #include "omap_drv.h"
+2
drivers/gpu/drm/qxl/qxl_cmd.c
··· 25 25 26 26 /* QXL cmd/ring handling */ 27 27 28 + #include <drm/drm_util.h> 29 + 28 30 #include "qxl_drv.h" 29 31 #include "qxl_object.h" 30 32
+2
drivers/gpu/drm/radeon/atom.c
··· 27 27 #include <linux/slab.h> 28 28 #include <asm/unaligned.h> 29 29 30 + #include <drm/drm_util.h> 31 + 30 32 #define ATOM_DEBUG 31 33 32 34 #include "atom.h"
+1
drivers/gpu/drm/radeon/radeon_legacy_encoders.c
··· 24 24 * Alex Deucher 25 25 */ 26 26 #include <drm/drmP.h> 27 + #include <drm/drm_util.h> 27 28 #include <drm/drm_crtc_helper.h> 28 29 #include <drm/radeon_drm.h> 29 30 #include "radeon.h"
+1
drivers/gpu/drm/vc4/vc4_drv.h
··· 9 9 #include <linux/mm_types.h> 10 10 #include <linux/reservation.h> 11 11 #include <drm/drmP.h> 12 + #include <drm/drm_util.h> 12 13 #include <drm/drm_encoder.h> 13 14 #include <drm/drm_gem_cma_helper.h> 14 15 #include <drm/drm_atomic.h>
-8
include/drm/drmP.h
··· 94 94 struct pci_dev; 95 95 struct pci_controller; 96 96 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 - 105 97 #if defined(CONFIG_DRM_DEBUG_SELFTEST_MODULE) 106 98 #define EXPORT_SYMBOL_FOR_TESTS_ONLY(x) EXPORT_SYMBOL(x) 107 99 #else
+42 -1
include/drm/drm_util.h
··· 26 26 #ifndef _DRM_UTIL_H_ 27 27 #define _DRM_UTIL_H_ 28 28 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 + */ 30 53 #define for_each_if(condition) if (!(condition)) {} else 54 + 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 + } 31 72 32 73 #endif