* [PATCH] drm/fourcc: fix integer type usage in uapi header
@ 2022-06-21 20:39 Carlos Llamas
2022-06-22 7:02 ` Simon Ser
0 siblings, 1 reply; 3+ messages in thread
From: Carlos Llamas @ 2022-06-21 20:39 UTC (permalink / raw)
To: amd-gfx
Cc: Masahiro Yamada, Carlos Llamas, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Daniel Vetter, Alex Deucher,
Bas Nieuwenhuizen, dri-devel, linux-kernel
Kernel uapi headers are supposed to use __[us]{8,16,32,64} types defined
by <linux/types.h> as opposed to 'uint32_t' and similar. See [1] for the
relevant discussion about this topic. In this particular case, the usage
of 'uint64_t' escaped headers_check as these macros are not being called
here. However, the following program triggers a compilation error:
#include <drm/drm_fourcc.h>
int main()
{
unsigned long x = AMD_FMT_MOD_CLEAR(RB);
return 0;
}
gcc error:
drm.c:5:27: error: ‘uint64_t’ undeclared (first use in this function)
5 | unsigned long x = AMD_FMT_MOD_CLEAR(RB);
| ^~~~~~~~~~~~~~~~~
This patch changes AMD_FMT_MOD_{SET,CLEAR} macros to use the correct
integer types, which fixes the above issue.
[1] https://lkml.org/lkml/2019/6/5/18
Fixes: 8ba16d599374 ("drm/fourcc: Add AMD DRM modifiers.")
Signed-off-by: Carlos Llamas <cmllamas@google.com>
---
include/uapi/drm/drm_fourcc.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h
index f1972154a594..0980678d502d 100644
--- a/include/uapi/drm/drm_fourcc.h
+++ b/include/uapi/drm/drm_fourcc.h
@@ -1444,11 +1444,11 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)
#define AMD_FMT_MOD_PIPE_MASK 0x7
#define AMD_FMT_MOD_SET(field, value) \
- ((uint64_t)(value) << AMD_FMT_MOD_##field##_SHIFT)
+ ((__u64)(value) << AMD_FMT_MOD_##field##_SHIFT)
#define AMD_FMT_MOD_GET(field, value) \
(((value) >> AMD_FMT_MOD_##field##_SHIFT) & AMD_FMT_MOD_##field##_MASK)
#define AMD_FMT_MOD_CLEAR(field) \
- (~((uint64_t)AMD_FMT_MOD_##field##_MASK << AMD_FMT_MOD_##field##_SHIFT))
+ (~((__u64)AMD_FMT_MOD_##field##_MASK << AMD_FMT_MOD_##field##_SHIFT))
#if defined(__cplusplus)
}
--
2.37.0.rc0.104.g0611611a94-goog
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/fourcc: fix integer type usage in uapi header
2022-06-21 20:39 [PATCH] drm/fourcc: fix integer type usage in uapi header Carlos Llamas
@ 2022-06-22 7:02 ` Simon Ser
2022-06-22 18:47 ` Alex Deucher
0 siblings, 1 reply; 3+ messages in thread
From: Simon Ser @ 2022-06-22 7:02 UTC (permalink / raw)
To: Carlos Llamas
Cc: amd-gfx, David Airlie, Masahiro Yamada, linux-kernel, dri-devel,
Thomas Zimmermann, Alex Deucher, Bas Nieuwenhuizen
On Tuesday, June 21st, 2022 at 22:39, Carlos Llamas <cmllamas@google.com> wrote:
> Kernel uapi headers are supposed to use __[us]{8,16,32,64} types defined
> by <linux/types.h> as opposed to 'uint32_t' and similar. See [1] for the
> relevant discussion about this topic. In this particular case, the usage
> of 'uint64_t' escaped headers_check as these macros are not being called
> here. However, the following program triggers a compilation error:
>
> #include <drm/drm_fourcc.h>
>
> int main()
> {
> unsigned long x = AMD_FMT_MOD_CLEAR(RB);
> return 0;
> }
>
> gcc error:
> drm.c:5:27: error: ‘uint64_t’ undeclared (first use in this function)
> 5 | unsigned long x = AMD_FMT_MOD_CLEAR(RB);
> | ^~~~~~~~~~~~~~~~~
>
> This patch changes AMD_FMT_MOD_{SET,CLEAR} macros to use the correct
> integer types, which fixes the above issue.
>
> [1] https://lkml.org/lkml/2019/6/5/18
>
> Fixes: 8ba16d599374 ("drm/fourcc: Add AMD DRM modifiers.")
> Signed-off-by: Carlos Llamas <cmllamas@google.com>
Reviewed-by: Simon Ser <contact@emersion.fr>
Cc'ing Bas as well
> ---
> include/uapi/drm/drm_fourcc.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h
> index f1972154a594..0980678d502d 100644
> --- a/include/uapi/drm/drm_fourcc.h
> +++ b/include/uapi/drm/drm_fourcc.h
> @@ -1444,11 +1444,11 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)
> #define AMD_FMT_MOD_PIPE_MASK 0x7
>
> #define AMD_FMT_MOD_SET(field, value) \
> - ((uint64_t)(value) << AMD_FMT_MOD_##field##_SHIFT)
> + ((__u64)(value) << AMD_FMT_MOD_##field##_SHIFT)
> #define AMD_FMT_MOD_GET(field, value) \
> (((value) >> AMD_FMT_MOD_##field##_SHIFT) & AMD_FMT_MOD_##field##_MASK)
> #define AMD_FMT_MOD_CLEAR(field) \
> - (~((uint64_t)AMD_FMT_MOD_##field##_MASK << AMD_FMT_MOD_##field##_SHIFT))
> + (~((__u64)AMD_FMT_MOD_##field##_MASK << AMD_FMT_MOD_##field##_SHIFT))
>
> #if defined(__cplusplus)
> }
> --
> 2.37.0.rc0.104.g0611611a94-goog
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/fourcc: fix integer type usage in uapi header
2022-06-22 7:02 ` Simon Ser
@ 2022-06-22 18:47 ` Alex Deucher
0 siblings, 0 replies; 3+ messages in thread
From: Alex Deucher @ 2022-06-22 18:47 UTC (permalink / raw)
To: Simon Ser
Cc: Carlos Llamas, David Airlie, Masahiro Yamada, LKML,
Maling list - DRI developers, amd-gfx list, Thomas Zimmermann,
Alex Deucher
Applied. Thanks!
Alex
On Wed, Jun 22, 2022 at 3:02 AM Simon Ser <contact@emersion.fr> wrote:
>
> On Tuesday, June 21st, 2022 at 22:39, Carlos Llamas <cmllamas@google.com> wrote:
>
> > Kernel uapi headers are supposed to use __[us]{8,16,32,64} types defined
> > by <linux/types.h> as opposed to 'uint32_t' and similar. See [1] for the
> > relevant discussion about this topic. In this particular case, the usage
> > of 'uint64_t' escaped headers_check as these macros are not being called
> > here. However, the following program triggers a compilation error:
> >
> > #include <drm/drm_fourcc.h>
> >
> > int main()
> > {
> > unsigned long x = AMD_FMT_MOD_CLEAR(RB);
> > return 0;
> > }
> >
> > gcc error:
> > drm.c:5:27: error: ‘uint64_t’ undeclared (first use in this function)
> > 5 | unsigned long x = AMD_FMT_MOD_CLEAR(RB);
> > | ^~~~~~~~~~~~~~~~~
> >
> > This patch changes AMD_FMT_MOD_{SET,CLEAR} macros to use the correct
> > integer types, which fixes the above issue.
> >
> > [1] https://lkml.org/lkml/2019/6/5/18
> >
> > Fixes: 8ba16d599374 ("drm/fourcc: Add AMD DRM modifiers.")
> > Signed-off-by: Carlos Llamas <cmllamas@google.com>
>
> Reviewed-by: Simon Ser <contact@emersion.fr>
>
> Cc'ing Bas as well
>
> > ---
> > include/uapi/drm/drm_fourcc.h | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h
> > index f1972154a594..0980678d502d 100644
> > --- a/include/uapi/drm/drm_fourcc.h
> > +++ b/include/uapi/drm/drm_fourcc.h
> > @@ -1444,11 +1444,11 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)
> > #define AMD_FMT_MOD_PIPE_MASK 0x7
> >
> > #define AMD_FMT_MOD_SET(field, value) \
> > - ((uint64_t)(value) << AMD_FMT_MOD_##field##_SHIFT)
> > + ((__u64)(value) << AMD_FMT_MOD_##field##_SHIFT)
> > #define AMD_FMT_MOD_GET(field, value) \
> > (((value) >> AMD_FMT_MOD_##field##_SHIFT) & AMD_FMT_MOD_##field##_MASK)
> > #define AMD_FMT_MOD_CLEAR(field) \
> > - (~((uint64_t)AMD_FMT_MOD_##field##_MASK << AMD_FMT_MOD_##field##_SHIFT))
> > + (~((__u64)AMD_FMT_MOD_##field##_MASK << AMD_FMT_MOD_##field##_SHIFT))
> >
> > #if defined(__cplusplus)
> > }
> > --
> > 2.37.0.rc0.104.g0611611a94-goog
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-06-22 18:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-21 20:39 [PATCH] drm/fourcc: fix integer type usage in uapi header Carlos Llamas
2022-06-22 7:02 ` Simon Ser
2022-06-22 18:47 ` Alex Deucher
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®