mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v4] drm/xe: Fix build error for XE_IOCTL_DBG macro
@ 2024-11-02  2:22 Gyeyoung Baek
  2024-11-04 18:04 ` Lucas De Marchi
  0 siblings, 1 reply; 4+ messages in thread
From: Gyeyoung Baek @ 2024-11-02  2:22 UTC (permalink / raw)
  To: Lucas De Marchi, Thomas Hellström, Rodrigo Vivi,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter
  Cc: Gyeyoung Baek, intel-xe, dri-devel, linux-kernel

if CONFIG_DRM_USE_DYNAMIC_DEBUG is set,
'drm_dbg' function is replaced with '__dynamic_func_call_cls',
which is replaced with a do while statement.
so in the previous code, there are the following build errors.

include/linux/dynamic_debug.h:221:58: error: expected expression before ‘do’
  221 | #define __dynamic_func_call_cls(id, cls, fmt, func, ...) do {   \
      |                                                          ^~
include/linux/dynamic_debug.h:248:9: note: in expansion of macro ‘__dynamic_func_call_cls’
  248 |         __dynamic_func_call_cls(__UNIQUE_ID(ddebug), cls, fmt, func, ##__VA_ARGS__)
      |         ^~~~~~~~~~~~~~~~~~~~~~~
include/drm/drm_print.h:425:9: note: in expansion of macro ‘_dynamic_func_call_cls’
  425 |         _dynamic_func_call_cls(cat, fmt, __drm_dev_dbg,         \
      |         ^~~~~~~~~~~~~~~~~~~~~~
include/drm/drm_print.h:504:9: note: in expansion of macro ‘drm_dev_dbg’
  504 |         drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_DRIVER, fmt, ##__VA_ARGS__)
      |         ^~~~~~~~~~~
include/drm/drm_print.h:522:33: note: in expansion of macro ‘drm_dbg_driver’
  522 | #define drm_dbg(drm, fmt, ...)  drm_dbg_driver(drm, fmt, ##__VA_ARGS__)
      |                                 ^~~~~~~~~~~~~~
drivers/gpu/drm/xe/xe_macros.h:14:21: note: in expansion of macro ‘drm_dbg’
   14 |         ((cond) && (drm_dbg(&(xe)->drm, \
      |                     ^~~~~~~
drivers/gpu/drm/xe/xe_bo.c:2029:13: note: in expansion of macro ‘XE_IOCTL_DBG’
 2029 |         if (XE_IOCTL_DBG(xe, !gem_obj))

the problem is that,
XE_IOCTL_DBG uses this function for conditional expr.

so I fix the expr to be compatible with the do while statement,
by referring to "https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html".

v2: I modified this to print when only cond is true.
v3: Modify to evaluate cond only once.
v4: There was a mistake in v3, send this again.

Signed-off-by: Gyeyoung Baek <gye976@gmail.com>
---
 drivers/gpu/drm/xe/xe_macros.h | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_macros.h b/drivers/gpu/drm/xe/xe_macros.h
index daf56c846d03..51ac8faa8975 100644
--- a/drivers/gpu/drm/xe/xe_macros.h
+++ b/drivers/gpu/drm/xe/xe_macros.h
@@ -10,9 +10,13 @@
 
 #define XE_WARN_ON WARN_ON
 
-#define XE_IOCTL_DBG(xe, cond) \
-	((cond) && (drm_dbg(&(xe)->drm, \
-			    "Ioctl argument check failed at %s:%d: %s", \
-			    __FILE__, __LINE__, #cond), 1))
+#define XE_IOCTL_DBG(xe, cond) ({					\
+	int cond__ = !!(cond);						\
+	if (cond__)                                           		\
+		drm_dbg(&(xe)->drm,                                    	\
+			"Ioctl argument check failed at %s:%d: %s",	\
+			__FILE__, __LINE__, #cond);                    	\
+	cond__;                                                        	\
+})
 
 #endif
-- 
2.34.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v4] drm/xe: Fix build error for XE_IOCTL_DBG macro
  2024-11-02  2:22 [PATCH v4] drm/xe: Fix build error for XE_IOCTL_DBG macro Gyeyoung Baek
@ 2024-11-04 18:04 ` Lucas De Marchi
  2024-11-05  7:28   ` Lucas De Marchi
  0 siblings, 1 reply; 4+ messages in thread
From: Lucas De Marchi @ 2024-11-04 18:04 UTC (permalink / raw)
  To: Gyeyoung Baek
  Cc: Thomas Hellström, Rodrigo Vivi, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	intel-xe, dri-devel, linux-kernel

On Sat, Nov 02, 2024 at 11:22:03AM +0900, Gyeyoung Baek wrote:
>if CONFIG_DRM_USE_DYNAMIC_DEBUG is set,
>'drm_dbg' function is replaced with '__dynamic_func_call_cls',
>which is replaced with a do while statement.
>so in the previous code, there are the following build errors.
>
>include/linux/dynamic_debug.h:221:58: error: expected expression before ‘do’
>  221 | #define __dynamic_func_call_cls(id, cls, fmt, func, ...) do {   \
>      |                                                          ^~
>include/linux/dynamic_debug.h:248:9: note: in expansion of macro ‘__dynamic_func_call_cls’
>  248 |         __dynamic_func_call_cls(__UNIQUE_ID(ddebug), cls, fmt, func, ##__VA_ARGS__)
>      |         ^~~~~~~~~~~~~~~~~~~~~~~
>include/drm/drm_print.h:425:9: note: in expansion of macro ‘_dynamic_func_call_cls’
>  425 |         _dynamic_func_call_cls(cat, fmt, __drm_dev_dbg,         \
>      |         ^~~~~~~~~~~~~~~~~~~~~~
>include/drm/drm_print.h:504:9: note: in expansion of macro ‘drm_dev_dbg’
>  504 |         drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_DRIVER, fmt, ##__VA_ARGS__)
>      |         ^~~~~~~~~~~
>include/drm/drm_print.h:522:33: note: in expansion of macro ‘drm_dbg_driver’
>  522 | #define drm_dbg(drm, fmt, ...)  drm_dbg_driver(drm, fmt, ##__VA_ARGS__)
>      |                                 ^~~~~~~~~~~~~~
>drivers/gpu/drm/xe/xe_macros.h:14:21: note: in expansion of macro ‘drm_dbg’
>   14 |         ((cond) && (drm_dbg(&(xe)->drm, \
>      |                     ^~~~~~~
>drivers/gpu/drm/xe/xe_bo.c:2029:13: note: in expansion of macro ‘XE_IOCTL_DBG’
> 2029 |         if (XE_IOCTL_DBG(xe, !gem_obj))
>
>the problem is that,
>XE_IOCTL_DBG uses this function for conditional expr.
>
>so I fix the expr to be compatible with the do while statement,
>by referring to "https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html".
>
>v2: I modified this to print when only cond is true.
>v3: Modify to evaluate cond only once.
>v4: There was a mistake in v3, send this again.
>
>Signed-off-by: Gyeyoung Baek <gye976@gmail.com>


Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>

I will apply this to drm-xe-next once we have CI back.

thanks
Lucas De Marchi

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v4] drm/xe: Fix build error for XE_IOCTL_DBG macro
  2024-11-04 18:04 ` Lucas De Marchi
@ 2024-11-05  7:28   ` Lucas De Marchi
  2024-11-05 10:21     ` gyeyoung
  0 siblings, 1 reply; 4+ messages in thread
From: Lucas De Marchi @ 2024-11-05  7:28 UTC (permalink / raw)
  To: Gyeyoung Baek
  Cc: Thomas Hellström, Rodrigo Vivi, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	intel-xe, dri-devel, linux-kernel

On Mon, Nov 04, 2024 at 12:04:30PM -0600, Lucas De Marchi wrote:
>On Sat, Nov 02, 2024 at 11:22:03AM +0900, Gyeyoung Baek wrote:
>>if CONFIG_DRM_USE_DYNAMIC_DEBUG is set,
>>'drm_dbg' function is replaced with '__dynamic_func_call_cls',
>>which is replaced with a do while statement.
>>so in the previous code, there are the following build errors.
>>
>>include/linux/dynamic_debug.h:221:58: error: expected expression before ‘do’
>> 221 | #define __dynamic_func_call_cls(id, cls, fmt, func, ...) do {   \
>>     |                                                          ^~
>>include/linux/dynamic_debug.h:248:9: note: in expansion of macro ‘__dynamic_func_call_cls’
>> 248 |         __dynamic_func_call_cls(__UNIQUE_ID(ddebug), cls, fmt, func, ##__VA_ARGS__)
>>     |         ^~~~~~~~~~~~~~~~~~~~~~~
>>include/drm/drm_print.h:425:9: note: in expansion of macro ‘_dynamic_func_call_cls’
>> 425 |         _dynamic_func_call_cls(cat, fmt, __drm_dev_dbg,         \
>>     |         ^~~~~~~~~~~~~~~~~~~~~~
>>include/drm/drm_print.h:504:9: note: in expansion of macro ‘drm_dev_dbg’
>> 504 |         drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_DRIVER, fmt, ##__VA_ARGS__)
>>     |         ^~~~~~~~~~~
>>include/drm/drm_print.h:522:33: note: in expansion of macro ‘drm_dbg_driver’
>> 522 | #define drm_dbg(drm, fmt, ...)  drm_dbg_driver(drm, fmt, ##__VA_ARGS__)
>>     |                                 ^~~~~~~~~~~~~~
>>drivers/gpu/drm/xe/xe_macros.h:14:21: note: in expansion of macro ‘drm_dbg’
>>  14 |         ((cond) && (drm_dbg(&(xe)->drm, \
>>     |                     ^~~~~~~
>>drivers/gpu/drm/xe/xe_bo.c:2029:13: note: in expansion of macro ‘XE_IOCTL_DBG’
>>2029 |         if (XE_IOCTL_DBG(xe, !gem_obj))
>>
>>the problem is that,
>>XE_IOCTL_DBG uses this function for conditional expr.
>>
>>so I fix the expr to be compatible with the do while statement,
>>by referring to "https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html".
>>
>>v2: I modified this to print when only cond is true.
>>v3: Modify to evaluate cond only once.
>>v4: There was a mistake in v3, send this again.
>>
>>Signed-off-by: Gyeyoung Baek <gye976@gmail.com>
>
>
>Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
>
>I will apply this to drm-xe-next once we have CI back.

there were some checkpatch issues about mixing tabs and spaces. Next
time please double check the checkpatch output. I also reworded the
commit message a little bit to follow an imperative mood as outlined at
https://www.kernel.org/doc/html/v4.10/process/submitting-patches.html#describe-your-changes

Applied to drm-xe-next. Thanks.

Lucas De Marchi

>
>thanks
>Lucas De Marchi

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v4] drm/xe: Fix build error for XE_IOCTL_DBG macro
  2024-11-05  7:28   ` Lucas De Marchi
@ 2024-11-05 10:21     ` gyeyoung
  0 siblings, 0 replies; 4+ messages in thread
From: gyeyoung @ 2024-11-05 10:21 UTC (permalink / raw)
  To: Lucas De Marchi
  Cc: Thomas Hellström, Rodrigo Vivi, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	intel-xe, dri-devel, linux-kernel

> there were some checkpatch issues about mixing tabs and spaces. Next
> time please double check the checkpatch output. I also reworded the
> commit message a little bit to follow an imperative mood as outlined at
> https://www.kernel.org/doc/html/v4.10/process/submitting-patches.html#describe-your-changes

I'm sorry for not being more careful, I'll use a script next time
instead of doing it manually.

Thanks,
Gyeyoung Baek

>
> Applied to drm-xe-next. Thanks.
>
> Lucas De Marchi
>
> >
> >thanks
> >Lucas De Marchi

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-11-05 10:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-02  2:22 [PATCH v4] drm/xe: Fix build error for XE_IOCTL_DBG macro Gyeyoung Baek
2024-11-04 18:04 ` Lucas De Marchi
2024-11-05  7:28   ` Lucas De Marchi
2024-11-05 10:21     ` gyeyoung

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®