[PATCH v3 04/12] drm: move drm_can_sleep() to drm_util.h
Daniel Vetter
daniel at ffwll.ch
Wed Jan 9 21:20:09 UTC 2019
On Tue, Jan 08, 2019 at 08:29:31PM +0100, Sam Ravnborg wrote:
> 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.
>
> Update comments to use kernel-doc style.
> Add FIXME to drm_can_sleep and add note
> that this function should not be used in new code
>
> Add include of drm_util.h to all users.
>
> Signed-off-by: Sam Ravnborg <sam at ravnborg.org>
> Cc: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
> Cc: Maxime Ripard <maxime.ripard at bootlin.com>
> Cc: Sean Paul <sean at poorly.run>
> Cc: David Airlie <airlied at linux.ie>
> Cc: Daniel Vetter <daniel at ffwll.ch>
> Cc: Alex Deucher <alexander.deucher at amd.com>
> Cc: "Christian König" <christian.koenig at amd.com>
> Cc: "David (ChunMing) Zhou" <David1.Zhou at amd.com>
> Cc: Gerd Hoffmann <kraxel at redhat.com>
> Cc: Rob Clark <robdclark at gmail.com>
> Cc: Tomi Valkeinen <tomi.valkeinen at ti.com>
> Cc: Eric Anholt <eric at anholt.net>
> ---
> drivers/gpu/drm/amd/amdgpu/atom.c | 2 ++
> drivers/gpu/drm/ast/ast_fb.c | 2 ++
> drivers/gpu/drm/cirrus/cirrus_fbdev.c | 1 +
> drivers/gpu/drm/drm_flip_work.c | 1 +
> drivers/gpu/drm/mgag200/mgag200_fb.c | 1 +
> drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c | 1 +
> drivers/gpu/drm/omapdrm/omap_fbdev.c | 1 +
> drivers/gpu/drm/qxl/qxl_cmd.c | 2 ++
> drivers/gpu/drm/radeon/atom.c | 2 ++
> drivers/gpu/drm/radeon/radeon_legacy_encoders.c | 1 +
> drivers/gpu/drm/vc4/vc4_drv.h | 1 +
> include/drm/drmP.h | 8 -----
> include/drm/drm_util.h | 42 ++++++++++++++++++++++++-
> 13 files changed, 56 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/atom.c b/drivers/gpu/drm/amd/amdgpu/atom.c
> index e9934de1b9cf..dd30f4e61a8c 100644
> --- a/drivers/gpu/drm/amd/amdgpu/atom.c
> +++ b/drivers/gpu/drm/amd/amdgpu/atom.c
> @@ -27,6 +27,8 @@
> #include <linux/slab.h>
> #include <asm/unaligned.h>
>
> +#include <drm/drm_util.h>
> +
> #define ATOM_DEBUG
>
> #include "atom.h"
> diff --git a/drivers/gpu/drm/ast/ast_fb.c b/drivers/gpu/drm/ast/ast_fb.c
> index a80bca1a857f..eb66bf7d3e63 100644
> --- a/drivers/gpu/drm/ast/ast_fb.c
> +++ b/drivers/gpu/drm/ast/ast_fb.c
> @@ -39,7 +39,9 @@
> #include <drm/drmP.h>
> #include <drm/drm_crtc.h>
> #include <drm/drm_fb_helper.h>
> +#include <drm/drm_util.h>
> #include <drm/drm_crtc_helper.h>
> +
> #include "ast_drv.h"
>
> static void ast_dirty_update(struct ast_fbdev *afbdev,
> diff --git a/drivers/gpu/drm/cirrus/cirrus_fbdev.c b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
> index 4dd499c7d1ba..79fea1b8bc14 100644
> --- a/drivers/gpu/drm/cirrus/cirrus_fbdev.c
> +++ b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
> @@ -10,6 +10,7 @@
> */
> #include <linux/module.h>
> #include <drm/drmP.h>
> +#include <drm/drm_util.h>
> #include <drm/drm_fb_helper.h>
> #include <drm/drm_crtc_helper.h>
>
> diff --git a/drivers/gpu/drm/drm_flip_work.c b/drivers/gpu/drm/drm_flip_work.c
> index 12dea16f22a8..3da3bf5af405 100644
> --- a/drivers/gpu/drm/drm_flip_work.c
> +++ b/drivers/gpu/drm/drm_flip_work.c
> @@ -22,6 +22,7 @@
> */
>
> #include <drm/drmP.h>
> +#include <drm/drm_util.h>
> #include <drm/drm_flip_work.h>
>
> /**
> diff --git a/drivers/gpu/drm/mgag200/mgag200_fb.c b/drivers/gpu/drm/mgag200/mgag200_fb.c
> index 30726c9fe28c..6893934b26c0 100644
> --- a/drivers/gpu/drm/mgag200/mgag200_fb.c
> +++ b/drivers/gpu/drm/mgag200/mgag200_fb.c
> @@ -12,6 +12,7 @@
> */
> #include <linux/module.h>
> #include <drm/drmP.h>
> +#include <drm/drm_util.h>
> #include <drm/drm_fb_helper.h>
> #include <drm/drm_crtc_helper.h>
>
> diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c b/drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c
> index 96c2b828dba4..fa2d1d8995ee 100644
> --- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c
> +++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c
> @@ -16,6 +16,7 @@
> * this program. If not, see <http://www.gnu.org/licenses/>.
> */
>
> +#include <drm/drm_util.h>
>
> #include "mdp5_kms.h"
> #include "mdp5_smp.h"
> diff --git a/drivers/gpu/drm/omapdrm/omap_fbdev.c b/drivers/gpu/drm/omapdrm/omap_fbdev.c
> index aee99194499f..851c59f07eb1 100644
> --- a/drivers/gpu/drm/omapdrm/omap_fbdev.c
> +++ b/drivers/gpu/drm/omapdrm/omap_fbdev.c
> @@ -16,6 +16,7 @@
> */
>
> #include <drm/drm_crtc.h>
> +#include <drm/drm_util.h>
> #include <drm/drm_fb_helper.h>
>
> #include "omap_drv.h"
> diff --git a/drivers/gpu/drm/qxl/qxl_cmd.c b/drivers/gpu/drm/qxl/qxl_cmd.c
> index dffc5093ff16..2e100f644236 100644
> --- a/drivers/gpu/drm/qxl/qxl_cmd.c
> +++ b/drivers/gpu/drm/qxl/qxl_cmd.c
> @@ -25,6 +25,8 @@
>
> /* QXL cmd/ring handling */
>
> +#include <drm/drm_util.h>
> +
> #include "qxl_drv.h"
> #include "qxl_object.h"
>
> diff --git a/drivers/gpu/drm/radeon/atom.c b/drivers/gpu/drm/radeon/atom.c
> index e55cbeee7a53..ac98ad561870 100644
> --- a/drivers/gpu/drm/radeon/atom.c
> +++ b/drivers/gpu/drm/radeon/atom.c
> @@ -27,6 +27,8 @@
> #include <linux/slab.h>
> #include <asm/unaligned.h>
>
> +#include <drm/drm_util.h>
> +
> #define ATOM_DEBUG
>
> #include "atom.h"
> diff --git a/drivers/gpu/drm/radeon/radeon_legacy_encoders.c b/drivers/gpu/drm/radeon/radeon_legacy_encoders.c
> index 222a1fa41d7c..7e3257e8fd56 100644
> --- a/drivers/gpu/drm/radeon/radeon_legacy_encoders.c
> +++ b/drivers/gpu/drm/radeon/radeon_legacy_encoders.c
> @@ -24,6 +24,7 @@
> * Alex Deucher
> */
> #include <drm/drmP.h>
> +#include <drm/drm_util.h>
> #include <drm/drm_crtc_helper.h>
> #include <drm/radeon_drm.h>
> #include "radeon.h"
> diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h
> index c24b078f0593..2c635f001c71 100644
> --- a/drivers/gpu/drm/vc4/vc4_drv.h
> +++ b/drivers/gpu/drm/vc4/vc4_drv.h
> @@ -9,6 +9,7 @@
> #include <linux/mm_types.h>
> #include <linux/reservation.h>
> #include <drm/drmP.h>
> +#include <drm/drm_util.h>
> #include <drm/drm_encoder.h>
> #include <drm/drm_gem_cma_helper.h>
> #include <drm/drm_atomic.h>
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index 9e47c8dc6b87..bc4cb3732407 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -94,14 +94,6 @@ struct dma_buf_attachment;
> struct pci_dev;
> struct pci_controller;
>
> -/* returns true if currently okay to sleep */
> -static inline bool drm_can_sleep(void)
> -{
> - if (in_atomic() || in_dbg_master() || irqs_disabled())
> - return false;
> - return true;
> -}
> -
> #if defined(CONFIG_DRM_DEBUG_SELFTEST_MODULE)
> #define EXPORT_SYMBOL_FOR_TESTS_ONLY(x) EXPORT_SYMBOL(x)
> #else
> diff --git a/include/drm/drm_util.h b/include/drm/drm_util.h
> index 88abdca89baa..8fda5777471c 100644
> --- a/include/drm/drm_util.h
> +++ b/include/drm/drm_util.h
> @@ -26,7 +26,47 @@
> #ifndef _DRM_UTIL_H_
> #define _DRM_UTIL_H_
>
> -/* helper for handling conditionals in various for_each macros */
> +/**
> + * DOC: drm utils
> + *
> + * Macros and inline functions that does not naturally belong in other places
> + */
The nice new docs here aren't included anywhere. We already have a "Misc
Utilities" in drm-internals.rst, including this there under a "Utilities"
subheading makes sense I think - yes I know, not the most creative name :-)
> +
> +#include <linux/irqflags.h>
> +#include <linux/preempt.h>
> +#include <linux/kgdb.h>
> +#include <linux/smp.h>
> +
> +/**
> + * for_each_if - helper for handling conditionals in various for_each macros
> + * @condition The condition to check
> + *
> + * Typical use:
> + * #define for_each_foo_bar(x, y) \
> + * list_for_each_entry(x, y->list, head) \
> + * for_each_if(x->something == SOMETHING)
I think the formatting of this in the html output will look off:
Double-colon plus indenting should fix that.
Merged the first 3 patches of this series thus far.
Thanks, Daniel
> + *
> + * The for_each_if() macro makes the use of for_each_foo_bar() less error
> + * prone.
> + */
> #define for_each_if(condition) if (!(condition)) {} else
>
> +/**
> + * drm_can_sleep - returns true if currently okay to sleep
> + *
> + * This function shall not be used in new code.
> + * The check for running in atomic context may not work - see linux/preempt.h.
> + *
> + * FIXME: All users of drm_can_sleep should be removed (see todo.rst)
> + *
> + * Returns:
> + * True if kgdb is active or we are in an atomic context or irqs are disabled
> + */
> +static inline bool drm_can_sleep(void)
> +{
> + if (in_atomic() || in_dbg_master() || irqs_disabled())
> + return false;
> + return true;
> +}
> +
> #endif
> --
> 2.12.0
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
More information about the dri-devel
mailing list