diff mbox series

[v1,02/11] drm: drop uapi dependency from drm_print.h

Message ID 20190718161507.2047-3-sam@ravnborg.org (mailing list archive)
State New, archived
Headers show
Series drm: header maintenance | expand

Commit Message

Sam Ravnborg July 18, 2019, 4:14 p.m. UTC
drm_print.h used DRM_NAME - thus adding a dependency from
include/drm/drm_print.h => uapi/drm/drm.h

Hardcode the name "drm" to break this dependency.
The idea is that there shall be a minimal dependency
between include/drm/* and uapi/*

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Suggested-by: Daniel Vetter <daniel@ffwll.ch>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
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: Rob Clark <robdclark@gmail.com>
Cc: Sean Paul <seanpaul@chromium.org>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Daniel Vetter <daniel@ffwll.ch>
---
 include/drm/drm_print.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Chris Wilson July 18, 2019, 4:46 p.m. UTC | #1
Quoting Sam Ravnborg (2019-07-18 17:14:58)
> drm_print.h used DRM_NAME - thus adding a dependency from
> include/drm/drm_print.h => uapi/drm/drm.h
> 
> Hardcode the name "drm" to break this dependency.
> The idea is that there shall be a minimal dependency
> between include/drm/* and uapi/*
> 
> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> Suggested-by: Daniel Vetter <daniel@ffwll.ch>
> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> 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: Rob Clark <robdclark@gmail.com>
> Cc: Sean Paul <seanpaul@chromium.org>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> ---
>  include/drm/drm_print.h | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h
> index a5d6f2f3e430..760d1bd0eaf1 100644
> --- a/include/drm/drm_print.h
> +++ b/include/drm/drm_print.h
> @@ -32,8 +32,6 @@
>  #include <linux/device.h>
>  #include <linux/debugfs.h>
>  
> -#include <drm/drm.h>
> -
>  /**
>   * DOC: print
>   *
> @@ -287,7 +285,7 @@ void drm_err(const char *format, ...);
>  /* Macros to make printk easier */
>  
>  #define _DRM_PRINTK(once, level, fmt, ...)                             \
> -       printk##once(KERN_##level "[" DRM_NAME "] " fmt, ##__VA_ARGS__)
> +       printk##once(KERN_##level "[drm] " fmt, ##__VA_ARGS__)

I guess I'm th only one who

#undef DRM_NAME
#define DRM_NAME i915

just so that I didn't have inane logs?

One might suggest that instead of hardcoding it, follow the pr_fmt()
pattern and only add "[drm]" for the drm core.

Even then it so useless (which drm driver is this message for???) that I
want to remove them all :(
-Chris
Sean Paul July 18, 2019, 5:40 p.m. UTC | #2
On Thu, Jul 18, 2019 at 06:14:58PM +0200, Sam Ravnborg wrote:
> drm_print.h used DRM_NAME - thus adding a dependency from
> include/drm/drm_print.h => uapi/drm/drm.h
> 
> Hardcode the name "drm" to break this dependency.
> The idea is that there shall be a minimal dependency
> between include/drm/* and uapi/*

You might also want to clean up the other uses of DRM_NAME in armada and i915
while you're at it. The easiest way to satisfy Chris' usecase and remove the
dependency would be to add #define DRM_PRINT_NAME "drm" in drm_print.h and use
that.

Sean

> 
> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> Suggested-by: Daniel Vetter <daniel@ffwll.ch>
> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> 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: Rob Clark <robdclark@gmail.com>
> Cc: Sean Paul <seanpaul@chromium.org>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> ---
>  include/drm/drm_print.h | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h
> index a5d6f2f3e430..760d1bd0eaf1 100644
> --- a/include/drm/drm_print.h
> +++ b/include/drm/drm_print.h
> @@ -32,8 +32,6 @@
>  #include <linux/device.h>
>  #include <linux/debugfs.h>
>  
> -#include <drm/drm.h>
> -
>  /**
>   * DOC: print
>   *
> @@ -287,7 +285,7 @@ void drm_err(const char *format, ...);
>  /* Macros to make printk easier */
>  
>  #define _DRM_PRINTK(once, level, fmt, ...)				\
> -	printk##once(KERN_##level "[" DRM_NAME "] " fmt, ##__VA_ARGS__)
> +	printk##once(KERN_##level "[drm] " fmt, ##__VA_ARGS__)
>  
>  #define DRM_INFO(fmt, ...)						\
>  	_DRM_PRINTK(, INFO, fmt, ##__VA_ARGS__)
> -- 
> 2.20.1
>
Christian König July 19, 2019, 6:54 a.m. UTC | #3
Am 18.07.19 um 18:46 schrieb Chris Wilson:
> Quoting Sam Ravnborg (2019-07-18 17:14:58)
>> drm_print.h used DRM_NAME - thus adding a dependency from
>> include/drm/drm_print.h => uapi/drm/drm.h
>>
>> Hardcode the name "drm" to break this dependency.
>> The idea is that there shall be a minimal dependency
>> between include/drm/* and uapi/*
>>
>> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
>> Suggested-by: Daniel Vetter <daniel@ffwll.ch>
>> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
>> 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: Rob Clark <robdclark@gmail.com>
>> Cc: Sean Paul <seanpaul@chromium.org>
>> Cc: Chris Wilson <chris@chris-wilson.co.uk>
>> Cc: Daniel Vetter <daniel@ffwll.ch>
>> ---
>>   include/drm/drm_print.h | 4 +---
>>   1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h
>> index a5d6f2f3e430..760d1bd0eaf1 100644
>> --- a/include/drm/drm_print.h
>> +++ b/include/drm/drm_print.h
>> @@ -32,8 +32,6 @@
>>   #include <linux/device.h>
>>   #include <linux/debugfs.h>
>>   
>> -#include <drm/drm.h>
>> -
>>   /**
>>    * DOC: print
>>    *
>> @@ -287,7 +285,7 @@ void drm_err(const char *format, ...);
>>   /* Macros to make printk easier */
>>   
>>   #define _DRM_PRINTK(once, level, fmt, ...)                             \
>> -       printk##once(KERN_##level "[" DRM_NAME "] " fmt, ##__VA_ARGS__)
>> +       printk##once(KERN_##level "[drm] " fmt, ##__VA_ARGS__)
> I guess I'm th only one who
>
> #undef DRM_NAME
> #define DRM_NAME i915
>
> just so that I didn't have inane logs?
>
> One might suggest that instead of hardcoding it, follow the pr_fmt()
> pattern and only add "[drm]" for the drm core.
>
> Even then it so useless (which drm driver is this message for???) that I
> want to remove them all :(

Yeah, agree. I mean it is nice if the core drm functions use a prefix 
for debug output.

But I actually don't see the point for individual drivers.

Christian.

> -Chris
Jani Nikula July 29, 2019, 12:45 p.m. UTC | #4
On Fri, 19 Jul 2019, "Koenig, Christian" <Christian.Koenig@amd.com> wrote:
> Am 18.07.19 um 18:46 schrieb Chris Wilson:
>> Quoting Sam Ravnborg (2019-07-18 17:14:58)
>>> drm_print.h used DRM_NAME - thus adding a dependency from
>>> include/drm/drm_print.h => uapi/drm/drm.h
>>>
>>> Hardcode the name "drm" to break this dependency.
>>> The idea is that there shall be a minimal dependency
>>> between include/drm/* and uapi/*
>>>
>>> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
>>> Suggested-by: Daniel Vetter <daniel@ffwll.ch>
>>> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
>>> 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: Rob Clark <robdclark@gmail.com>
>>> Cc: Sean Paul <seanpaul@chromium.org>
>>> Cc: Chris Wilson <chris@chris-wilson.co.uk>
>>> Cc: Daniel Vetter <daniel@ffwll.ch>
>>> ---
>>>   include/drm/drm_print.h | 4 +---
>>>   1 file changed, 1 insertion(+), 3 deletions(-)
>>>
>>> diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h
>>> index a5d6f2f3e430..760d1bd0eaf1 100644
>>> --- a/include/drm/drm_print.h
>>> +++ b/include/drm/drm_print.h
>>> @@ -32,8 +32,6 @@
>>>   #include <linux/device.h>
>>>   #include <linux/debugfs.h>
>>>   
>>> -#include <drm/drm.h>
>>> -
>>>   /**
>>>    * DOC: print
>>>    *
>>> @@ -287,7 +285,7 @@ void drm_err(const char *format, ...);
>>>   /* Macros to make printk easier */
>>>   
>>>   #define _DRM_PRINTK(once, level, fmt, ...)                             \
>>> -       printk##once(KERN_##level "[" DRM_NAME "] " fmt, ##__VA_ARGS__)
>>> +       printk##once(KERN_##level "[drm] " fmt, ##__VA_ARGS__)
>> I guess I'm th only one who
>>
>> #undef DRM_NAME
>> #define DRM_NAME i915
>>
>> just so that I didn't have inane logs?
>>
>> One might suggest that instead of hardcoding it, follow the pr_fmt()
>> pattern and only add "[drm]" for the drm core.
>>
>> Even then it so useless (which drm driver is this message for???) that I
>> want to remove them all :(
>
> Yeah, agree. I mean it is nice if the core drm functions use a prefix 
> for debug output.
>
> But I actually don't see the point for individual drivers.

We should all migrate to the versions with device...

BR,
Jani.


>
> Christian.
>
>> -Chris
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sam Ravnborg July 29, 2019, 2:35 p.m. UTC | #5
> >>
> >> Even then it so useless (which drm driver is this message for???) that I
> >> want to remove them all :(
> >
> > Yeah, agree. I mean it is nice if the core drm functions use a prefix 
> > for debug output.
> >
> > But I actually don't see the point for individual drivers.
> 
> We should all migrate to the versions with device...

Just to do an xkdc.com/927 I have considered:

drm_err(const struct drm_device *drm, ...)
drm_info(const struct drm_device *drm, ...)

drm_kms_err(const struct drm_device *drm, ...)
drm_kms_info(const struct drm_device *drm, ...))

And so on for vbl, primse. lease, state etc.

Then we could fish out relevant info from the drm device and present
this nicely.

For the cases where no drm_device is available the fallback is:
drm_dev_err(const struct drm_device *drm, ...)
drm_dev_info(const struct drm_device *drm, ...))

We could modify the existing UPPERCASE macros to be placeholders for
the more reader friendly lower cases variants and base it all on the
established infrastructure.

But this is just idle thinking, as only a serious patch would stir the
relevant discussions.

For now this is far from the top of my TODO list.


	Sam
Christian König July 29, 2019, 3:28 p.m. UTC | #6
Am 29.07.19 um 16:35 schrieb Sam Ravnborg:
>>>> Even then it so useless (which drm driver is this message for???) that I
>>>> want to remove them all :(
>>> Yeah, agree. I mean it is nice if the core drm functions use a prefix
>>> for debug output.
>>>
>>> But I actually don't see the point for individual drivers.
>> We should all migrate to the versions with device...
> Just to do an xkdc.com/927 I have considered:
>
> drm_err(const struct drm_device *drm, ...)
> drm_info(const struct drm_device *drm, ...)
>
> drm_kms_err(const struct drm_device *drm, ...)
> drm_kms_info(const struct drm_device *drm, ...))

Why not get completely rid of those and just use dev_err, dev_warn, 
pr_err, pr_warn etc?

I mean is it useful to have this extra printing subsystem in DRM while 
the standard Linux one actually does a better job?

Christian.

>
> And so on for vbl, primse. lease, state etc.
>
> Then we could fish out relevant info from the drm device and present
> this nicely.
>
> For the cases where no drm_device is available the fallback is:
> drm_dev_err(const struct drm_device *drm, ...)
> drm_dev_info(const struct drm_device *drm, ...))
>
> We could modify the existing UPPERCASE macros to be placeholders for
> the more reader friendly lower cases variants and base it all on the
> established infrastructure.
>
> But this is just idle thinking, as only a serious patch would stir the
> relevant discussions.
>
> For now this is far from the top of my TODO list.
>
>
> 	Sam
Sam Ravnborg July 29, 2019, 5:50 p.m. UTC | #7
Hi Christian.

On Mon, Jul 29, 2019 at 03:28:15PM +0000, Koenig, Christian wrote:
> Am 29.07.19 um 16:35 schrieb Sam Ravnborg:
> >>>> Even then it so useless (which drm driver is this message for???) that I
> >>>> want to remove them all :(
> >>> Yeah, agree. I mean it is nice if the core drm functions use a prefix
> >>> for debug output.
> >>>
> >>> But I actually don't see the point for individual drivers.
> >> We should all migrate to the versions with device...
> > Just to do an xkdc.com/927 I have considered:
> >
> > drm_err(const struct drm_device *drm, ...)
> > drm_info(const struct drm_device *drm, ...)
> >
> > drm_kms_err(const struct drm_device *drm, ...)
> > drm_kms_info(const struct drm_device *drm, ...))
> 
> Why not get completely rid of those and just use dev_err, dev_warn, 
> pr_err, pr_warn etc?
> 
> I mean is it useful to have this extra printing subsystem in DRM while 
> the standard Linux one actually does a better job?
The added functionality of drm_xxx_err would be to keep the current
drm.debug=0x1f filtering on the command-line.
I do not think we can do this with the standard logging.

And then we can prefix every logging with driver name and device name.

The idea is to make a thin layer on top of the existing pr_xxx() functions.
So not a full subsystem, only a wrapper on top of what we already have.

Anyway, idle talk only. We need patches and sample output if we should
discuss more.

	Sam
Jani Nikula Aug. 2, 2019, 1:48 p.m. UTC | #8
On Mon, 29 Jul 2019, Sam Ravnborg <sam@ravnborg.org> wrote:
> Hi Christian.
>
> On Mon, Jul 29, 2019 at 03:28:15PM +0000, Koenig, Christian wrote:
>> Am 29.07.19 um 16:35 schrieb Sam Ravnborg:
>> >>>> Even then it so useless (which drm driver is this message for???) that I
>> >>>> want to remove them all :(
>> >>> Yeah, agree. I mean it is nice if the core drm functions use a prefix
>> >>> for debug output.
>> >>>
>> >>> But I actually don't see the point for individual drivers.
>> >> We should all migrate to the versions with device...
>> > Just to do an xkdc.com/927 I have considered:
>> >
>> > drm_err(const struct drm_device *drm, ...)
>> > drm_info(const struct drm_device *drm, ...)
>> >
>> > drm_kms_err(const struct drm_device *drm, ...)
>> > drm_kms_info(const struct drm_device *drm, ...))
>> 
>> Why not get completely rid of those and just use dev_err, dev_warn, 
>> pr_err, pr_warn etc?
>> 
>> I mean is it useful to have this extra printing subsystem in DRM while 
>> the standard Linux one actually does a better job?
> The added functionality of drm_xxx_err would be to keep the current
> drm.debug=0x1f filtering on the command-line.
> I do not think we can do this with the standard logging.

Correct. I'd love the benefits of dynamic debug, but there's no support
for the kind of message categories that we do with drm.debug.

I've contemplated switching i915 over to using the variants where you
pass the device, but I really really don't like the idea of:

- 	DRM_DEBUG_KMS("hello\n");
+ 	DRM_DEV_DEBUG_KMS(i915->drm.dev, "hello\n");

Where i915 is our private wrapper for drm_device. I think it's just too
much ugly uppercase boilerplate, and a large portion of the debugs would
have to span at least an extra line after that.

I'd also very much prefer passing just struct *drm_device instead of
struct *device. In that, I think the needs of the few have prevailed
over the needs of the many. I'd definitely prefer drm_err(const struct
drm_device *drm, ...) and friends over the current ones.

Frankly, I've actually ended up thinking about adding our own, short
i915 wrappers for our needs. :(

BR,
Jani.


>
> And then we can prefix every logging with driver name and device name.
>
> The idea is to make a thin layer on top of the existing pr_xxx() functions.
> So not a full subsystem, only a wrapper on top of what we already have.
>
> Anyway, idle talk only. We need patches and sample output if we should
> discuss more.
>
> 	Sam
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Sam Ravnborg Aug. 2, 2019, 3:28 p.m. UTC | #9
Hi Jani.

> >> I mean is it useful to have this extra printing subsystem in DRM while 
> >> the standard Linux one actually does a better job?
> > The added functionality of drm_xxx_err would be to keep the current
> > drm.debug=0x1f filtering on the command-line.
> > I do not think we can do this with the standard logging.
> 
> Correct. I'd love the benefits of dynamic debug, but there's no support
> for the kind of message categories that we do with drm.debug.
> 
> I've contemplated switching i915 over to using the variants where you
> pass the device, but I really really don't like the idea of:
> 
> - 	DRM_DEBUG_KMS("hello\n");
> + 	DRM_DEV_DEBUG_KMS(i915->drm.dev, "hello\n");
> 
> Where i915 is our private wrapper for drm_device. I think it's just too
> much ugly uppercase boilerplate, and a large portion of the debugs would
> have to span at least an extra line after that.
> 
> I'd also very much prefer passing just struct *drm_device instead of
> struct *device. In that, I think the needs of the few have prevailed
> over the needs of the many. I'd definitely prefer drm_err(const struct
> drm_device *drm, ...) and friends over the current ones.

This is from my notes:

"
drm_err(const struct drm_device *drm, ...)
drm_info(const struct drm_device *drm, ...)

drm_kms_err(const struct drm_device *drm, ...)
drm_kms_info(const struct drm_device *drm, ...))

etc.

Then we could fish out relevant info from the drm device and present
this nicely.

For the cases where no drm_device is available the fallback is:
drm_dev_err(const struct drm_device *drm, ...)
drm_dev_info(const struct drm_device *drm, ...))

We could modify the existing UPPERCASE macros to be placeholders for
the more reader friendly lower cases variants.
"

So we seems to be aligned here.
In other words - if you throw time after this then try to add
the new logging variants to drm_print.h for the benefit of all.
The we can maybe later do some mass conversion if we want to get rid
of some of the older logging systems.

I have not yet found time/energy to throw after this myself.

	Sam
diff mbox series

Patch

diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h
index a5d6f2f3e430..760d1bd0eaf1 100644
--- a/include/drm/drm_print.h
+++ b/include/drm/drm_print.h
@@ -32,8 +32,6 @@ 
 #include <linux/device.h>
 #include <linux/debugfs.h>
 
-#include <drm/drm.h>
-
 /**
  * DOC: print
  *
@@ -287,7 +285,7 @@  void drm_err(const char *format, ...);
 /* Macros to make printk easier */
 
 #define _DRM_PRINTK(once, level, fmt, ...)				\
-	printk##once(KERN_##level "[" DRM_NAME "] " fmt, ##__VA_ARGS__)
+	printk##once(KERN_##level "[drm] " fmt, ##__VA_ARGS__)
 
 #define DRM_INFO(fmt, ...)						\
 	_DRM_PRINTK(, INFO, fmt, ##__VA_ARGS__)