Re: [PATCH v4 1/8] drm: move drm_can_sleep() to drm_util.h

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Sam,

Thank you for the patch.

On Sat, Jan 12, 2019 at 08:32:44PM +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.
> 
> 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@xxxxxxxxxxxx>
> Cc: Maarten Lankhorst <maarten.lankhorst@xxxxxxxxxxxxxxx>
> Cc: Maxime Ripard <maxime.ripard@xxxxxxxxxxx>
> Cc: Sean Paul <sean@xxxxxxxxxx>
> Cc: David Airlie <airlied@xxxxxxxx>
> Cc: Daniel Vetter <daniel@xxxxxxxx>
> Cc: Alex Deucher <alexander.deucher@xxxxxxx>
> Cc: "Christian König" <christian.koenig@xxxxxxx>
> Cc: "David (ChunMing) Zhou" <David1.Zhou@xxxxxxx>
> Cc: Gerd Hoffmann <kraxel@xxxxxxxxxx>
> Cc: Rob Clark <robdclark@xxxxxxxxx>
> Cc: Tomi Valkeinen <tomi.valkeinen@xxxxxx>
> Cc: Eric Anholt <eric@xxxxxxxxxx>
> ---
>  Documentation/gpu/drm-internals.rst             |  9 ++++++
>  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                          | 43 ++++++++++++++++++++++++-
>  14 files changed, 66 insertions(+), 9 deletions(-)
> 
> diff --git a/Documentation/gpu/drm-internals.rst b/Documentation/gpu/drm-internals.rst
> index 9090fabf3f7a..2caf21effd28 100644
> --- a/Documentation/gpu/drm-internals.rst
> +++ b/Documentation/gpu/drm-internals.rst
> @@ -233,6 +233,15 @@ Printer
>  .. kernel-doc:: drivers/gpu/drm/drm_print.c
>     :export:
>  
> +Utilities
> +---------
> +
> +.. kernel-doc:: include/drm/drm_util.h
> +   :doc: drm utils
> +
> +.. kernel-doc:: include/drm/drm_util.h
> +   :internal:

Why do we need it twice ?

> +
>  
>  Legacy Support Code
>  ===================

[snip]

> 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>

Please keep headers alphabetically sorted, here and everywhere else in
this patch. This helps locating and avoiding duplicated headers.

>  #include "omap_drv.h"

[snip]

> diff --git a/include/drm/drm_util.h b/include/drm/drm_util.h
> index 88abdca89baa..f776a55e5508 100644
> --- a/include/drm/drm_util.h
> +++ b/include/drm/drm_util.h
> @@ -26,7 +26,48 @@
>  #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

s/does/do/

> + */
> +
> +#include <linux/irqflags.h>
> +#include <linux/preempt.h>
> +#include <linux/kgdb.h>
> +#include <linux/smp.h>

Four headers needed to use three functions, impressive :-)

Alphabetical sorted here too please (and actually everywhere in this
patch series :-)).

> +/**
> + * 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)
> + *
> + * 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

Did you mean False ?

With these fixed,

Reviewed-by: Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx>

> + */
> +static inline bool drm_can_sleep(void)
> +{
> +	if (in_atomic() || in_dbg_master() || irqs_disabled())
> +		return false;
> +	return true;
> +}
> +
>  #endif

-- 
Regards,

Laurent Pinchart
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux