* [PATCH] media: imx-pxp: Rewrite coeff expression
@ 2024-06-28 15:11 Ricardo Ribalda
2024-07-01 9:30 ` Philipp Zabel
0 siblings, 1 reply; 3+ messages in thread
From: Ricardo Ribalda @ 2024-06-28 15:11 UTC (permalink / raw)
To: Philipp Zabel, Mauro Carvalho Chehab, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam
Cc: linux-media, imx, linux-arm-kernel, linux-kernel, Hans Verkuil,
Ricardo Ribalda
GCC5 cannot figure out that the expressions are constant, and that
triggers a build failure. Rewrite the expressions.
The following gcc5 error is workaround:
#define BM_PXP_CSC1_COEF0_YCBCR_MODE 0x80000000
^
BM_PXP_CSC1_COEF0_YCBCR_MODE |
^
#define BM_PXP_CSC1_COEF0_YCBCR_MODE 0x80000000
^
drivers/media/platform/nxp/imx-pxp.c: In function 'pxp_setup_csc':
drivers/media/platform/nxp/imx-pxp.h:582:38: error: initializer element is not constant
drivers/media/platform/nxp/imx-pxp.c:374:4: note: in expansion of macro 'BM_PXP_CSC1_COEF0_YCBCR_MODE'
drivers/media/platform/nxp/imx-pxp.h:582:38: note: (near initialization for 'csc1_coef_bt601_lim[0]')
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
While implementing media-ci, we have found this build error with gcc5.
---
drivers/media/platform/nxp/imx-pxp.h | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/media/platform/nxp/imx-pxp.h b/drivers/media/platform/nxp/imx-pxp.h
index 44f95c749d2e..ae4c6021c156 100644
--- a/drivers/media/platform/nxp/imx-pxp.h
+++ b/drivers/media/platform/nxp/imx-pxp.h
@@ -594,12 +594,17 @@
(((v) << 18) & BM_PXP_CSC1_COEF0_C0)
#define BP_PXP_CSC1_COEF0_UV_OFFSET 9
#define BM_PXP_CSC1_COEF0_UV_OFFSET 0x0003FE00
+
+/*
+ * We use v * (1 << 9) instead of v << 9, to workaround a gcc5 bug.
+ * The compiler cannot understand that the expression is constant.
+*/
#define BF_PXP_CSC1_COEF0_UV_OFFSET(v) \
- (((v) << 9) & BM_PXP_CSC1_COEF0_UV_OFFSET)
+ (((v) * (1 << 9)) & BM_PXP_CSC1_COEF0_UV_OFFSET)
#define BP_PXP_CSC1_COEF0_Y_OFFSET 0
#define BM_PXP_CSC1_COEF0_Y_OFFSET 0x000001FF
#define BF_PXP_CSC1_COEF0_Y_OFFSET(v) \
- (((v) << 0) & BM_PXP_CSC1_COEF0_Y_OFFSET)
+ ((v) & BM_PXP_CSC1_COEF0_Y_OFFSET)
#define HW_PXP_CSC1_COEF1 (0x000001b0)
---
base-commit: 6aa082910445aec6b1dc652a69c5178a555d8ca5
change-id: 20240628-gcc5-71a968c78e98
Best regards,
--
Ricardo Ribalda <ribalda@chromium.org>
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] media: imx-pxp: Rewrite coeff expression
2024-06-28 15:11 [PATCH] media: imx-pxp: Rewrite coeff expression Ricardo Ribalda
@ 2024-07-01 9:30 ` Philipp Zabel
2024-07-15 8:22 ` Ricardo Ribalda
0 siblings, 1 reply; 3+ messages in thread
From: Philipp Zabel @ 2024-07-01 9:30 UTC (permalink / raw)
To: Ricardo Ribalda, Mauro Carvalho Chehab, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam
Cc: linux-media, imx, linux-arm-kernel, linux-kernel, Hans Verkuil
On Fr, 2024-06-28 at 15:11 +0000, Ricardo Ribalda wrote:
> GCC5 cannot figure out that the expressions are constant, and that
> triggers a build failure. Rewrite the expressions.
>
> The following gcc5 error is workaround:
>
> #define BM_PXP_CSC1_COEF0_YCBCR_MODE 0x80000000
> ^
> BM_PXP_CSC1_COEF0_YCBCR_MODE |
> ^
> #define BM_PXP_CSC1_COEF0_YCBCR_MODE 0x80000000
> ^
>
> drivers/media/platform/nxp/imx-pxp.c: In function 'pxp_setup_csc':
> drivers/media/platform/nxp/imx-pxp.h:582:38: error: initializer element is not constant
> drivers/media/platform/nxp/imx-pxp.c:374:4: note: in expansion of macro 'BM_PXP_CSC1_COEF0_YCBCR_MODE'
> drivers/media/platform/nxp/imx-pxp.h:582:38: note: (near initialization for 'csc1_coef_bt601_lim[0]')
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Can you elaborate on how this is triggered?
At least I couldn't reproduce this by just copy & pasting the
csc1_coef_bt601_lim initializer and the required macros into gcc 5.4 on
godbolt.
Can this be fixed by using GENMASK / FIELD_PREP instead?
regards
Philipp
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] media: imx-pxp: Rewrite coeff expression
2024-07-01 9:30 ` Philipp Zabel
@ 2024-07-15 8:22 ` Ricardo Ribalda
0 siblings, 0 replies; 3+ messages in thread
From: Ricardo Ribalda @ 2024-07-15 8:22 UTC (permalink / raw)
To: Philipp Zabel
Cc: Mauro Carvalho Chehab, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, linux-media, imx,
linux-arm-kernel, linux-kernel, Hans Verkuil
Hi Philipp
On Mon, 1 Jul 2024 at 11:30, Philipp Zabel <p.zabel@pengutronix.de> wrote:
>
> On Fr, 2024-06-28 at 15:11 +0000, Ricardo Ribalda wrote:
> > GCC5 cannot figure out that the expressions are constant, and that
> > triggers a build failure. Rewrite the expressions.
> >
> > The following gcc5 error is workaround:
> >
> > #define BM_PXP_CSC1_COEF0_YCBCR_MODE 0x80000000
> > ^
> > BM_PXP_CSC1_COEF0_YCBCR_MODE |
> > ^
> > #define BM_PXP_CSC1_COEF0_YCBCR_MODE 0x80000000
> > ^
> >
> > drivers/media/platform/nxp/imx-pxp.c: In function 'pxp_setup_csc':
> > drivers/media/platform/nxp/imx-pxp.h:582:38: error: initializer element is not constant
> > drivers/media/platform/nxp/imx-pxp.c:374:4: note: in expansion of macro 'BM_PXP_CSC1_COEF0_YCBCR_MODE'
> > drivers/media/platform/nxp/imx-pxp.h:582:38: note: (near initialization for 'csc1_coef_bt601_lim[0]')
> > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
>
> Can you elaborate on how this is triggered?
Building the driver with
https://cdn.kernel.org/pub/tools/crosstool/files/bin/x86_64/5.5.0/
It might be easier to repro with:
ribalda@denia:~/work/linux$ podman run --pids-limit=-1 --rm -it -v
.:/workdir registry.freedesktop.org/linux-media/media-ci/build-ancient
# cd /workdir
# CROSS_COMPILE=x86_64-linux- make allyesconfig
# scripts/config -d MITIGATION_RETPOLINE
# CROSS_COMPILE=x86_64-linux- make olddefconfig
# CROSS_COMPILE=x86_64-linux- make drivers/media/platform/nxp/
>
> At least I couldn't reproduce this by just copy & pasting the
> csc1_coef_bt601_lim initializer and the required macros into gcc 5.4 on
> godbolt.
>
> Can this be fixed by using GENMASK / FIELD_PREP instead?
I was looking to make the change as simple as possible :)
>
> regards
> Philipp
--
Ricardo Ribalda
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-07-15 8:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-28 15:11 [PATCH] media: imx-pxp: Rewrite coeff expression Ricardo Ribalda
2024-07-01 9:30 ` Philipp Zabel
2024-07-15 8:22 ` Ricardo Ribalda
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).