All of lore.kernel.org
 help / color / mirror / Atom feed
* include/linux/compiler_types.h:597:38: error: call to '__compiletime_assert_437' declared with attribute error: FIELD_PREP: value too large for the field
@ 2025-12-05 10:16 kernel test robot
  2025-12-30  2:47 ` Marek Vasut
  0 siblings, 1 reply; 5+ messages in thread
From: kernel test robot @ 2025-12-05 10:16 UTC (permalink / raw)
  To: Marek Vasut; +Cc: oe-kbuild-all, linux-kernel, Tomi Valkeinen

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   2061f18ad76ecaddf8ed17df81b8611ea88dbddd
commit: 4f716a1db661cfb31502a0a6d7e62c06daf2e603 drm/rcar-du: dsi: Convert register bitfields to GENMASK() macro
date:   5 weeks ago
config: arc-randconfig-001-20251205 (https://download.01.org/0day-ci/archive/20251205/202512051834.bESvhDiG-lkp@intel.com/config)
compiler: arc-linux-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251205/202512051834.bESvhDiG-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202512051834.bESvhDiG-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from <command-line>:
   drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi.c: In function 'rcar_mipi_dsi_startup.isra.4':
>> include/linux/compiler_types.h:597:38: error: call to '__compiletime_assert_437' declared with attribute error: FIELD_PREP: value too large for the field
     _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
                                         ^
   include/linux/compiler_types.h:578:4: note: in definition of macro '__compiletime_assert'
       prefix ## suffix();    \
       ^~~~~~
   include/linux/compiler_types.h:597:2: note: in expansion of macro '_compiletime_assert'
     _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
     ^~~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
    #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                        ^~~~~~~~~~~~~~~~~~
   include/linux/bitfield.h:68:3: note: in expansion of macro 'BUILD_BUG_ON_MSG'
      BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ?  \
      ^~~~~~~~~~~~~~~~
   include/linux/bitfield.h:115:3: note: in expansion of macro '__BF_FIELD_CHECK'
      __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
      ^~~~~~~~~~~~~~~~
   drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi_regs.h:259:29: note: in expansion of macro 'FIELD_PREP'
    #define VCLKSET_DIV_V4H(n)  FIELD_PREP(VCLKSET_DIV_V4H_MASK, (n))
                                ^~~~~~~~~~
   drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi.c:660:14: note: in expansion of macro 'VCLKSET_DIV_V4H'
      vclkset |= VCLKSET_DIV_V4H(__ffs(setup_info.vclk_divider) - 1);
                 ^~~~~~~~~~~~~~~
--
   In file included from <command-line>:
   rcar_mipi_dsi.c: In function 'rcar_mipi_dsi_startup.isra.4':
>> include/linux/compiler_types.h:597:38: error: call to '__compiletime_assert_437' declared with attribute error: FIELD_PREP: value too large for the field
     _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
                                         ^
   include/linux/compiler_types.h:578:4: note: in definition of macro '__compiletime_assert'
       prefix ## suffix();    \
       ^~~~~~
   include/linux/compiler_types.h:597:2: note: in expansion of macro '_compiletime_assert'
     _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
     ^~~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
    #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                        ^~~~~~~~~~~~~~~~~~
   include/linux/bitfield.h:68:3: note: in expansion of macro 'BUILD_BUG_ON_MSG'
      BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ?  \
      ^~~~~~~~~~~~~~~~
   include/linux/bitfield.h:115:3: note: in expansion of macro '__BF_FIELD_CHECK'
      __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
      ^~~~~~~~~~~~~~~~
   rcar_mipi_dsi_regs.h:259:29: note: in expansion of macro 'FIELD_PREP'
    #define VCLKSET_DIV_V4H(n)  FIELD_PREP(VCLKSET_DIV_V4H_MASK, (n))
                                ^~~~~~~~~~
   rcar_mipi_dsi.c:660:14: note: in expansion of macro 'VCLKSET_DIV_V4H'
      vclkset |= VCLKSET_DIV_V4H(__ffs(setup_info.vclk_divider) - 1);
                 ^~~~~~~~~~~~~~~


vim +/__compiletime_assert_437 +597 include/linux/compiler_types.h

eb5c2d4b45e3d2 Will Deacon 2020-07-21  583  
eb5c2d4b45e3d2 Will Deacon 2020-07-21  584  #define _compiletime_assert(condition, msg, prefix, suffix) \
eb5c2d4b45e3d2 Will Deacon 2020-07-21  585  	__compiletime_assert(condition, msg, prefix, suffix)
eb5c2d4b45e3d2 Will Deacon 2020-07-21  586  
eb5c2d4b45e3d2 Will Deacon 2020-07-21  587  /**
eb5c2d4b45e3d2 Will Deacon 2020-07-21  588   * compiletime_assert - break build and emit msg if condition is false
eb5c2d4b45e3d2 Will Deacon 2020-07-21  589   * @condition: a compile-time constant condition to check
eb5c2d4b45e3d2 Will Deacon 2020-07-21  590   * @msg:       a message to emit if condition is false
eb5c2d4b45e3d2 Will Deacon 2020-07-21  591   *
eb5c2d4b45e3d2 Will Deacon 2020-07-21  592   * In tradition of POSIX assert, this macro will break the build if the
eb5c2d4b45e3d2 Will Deacon 2020-07-21  593   * supplied condition is *false*, emitting the supplied error message if the
eb5c2d4b45e3d2 Will Deacon 2020-07-21  594   * compiler has support to do so.
eb5c2d4b45e3d2 Will Deacon 2020-07-21  595   */
eb5c2d4b45e3d2 Will Deacon 2020-07-21  596  #define compiletime_assert(condition, msg) \
eb5c2d4b45e3d2 Will Deacon 2020-07-21 @597  	_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
eb5c2d4b45e3d2 Will Deacon 2020-07-21  598  

:::::: The code at line 597 was first introduced by commit
:::::: eb5c2d4b45e3d2d5d052ea6b8f1463976b1020d5 compiler.h: Move compiletime_assert() macros into compiler_types.h

:::::: TO: Will Deacon <will@kernel.org>
:::::: CC: Will Deacon <will@kernel.org>

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: include/linux/compiler_types.h:597:38: error: call to '__compiletime_assert_437' declared with attribute error: FIELD_PREP: value too large for the field
  2025-12-05 10:16 include/linux/compiler_types.h:597:38: error: call to '__compiletime_assert_437' declared with attribute error: FIELD_PREP: value too large for the field kernel test robot
@ 2025-12-30  2:47 ` Marek Vasut
  2025-12-30 10:30   ` Laurent Pinchart
  2025-12-30 23:02   ` David Laight
  0 siblings, 2 replies; 5+ messages in thread
From: Marek Vasut @ 2025-12-30  2:47 UTC (permalink / raw)
  To: kernel test robot, Tomi Valkeinen, Laurent Pinchart
  Cc: oe-kbuild-all, linux-kernel,
	open list:MEDIA DRIVERS FOR RENESAS - FCP

On 12/5/25 11:16 AM, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head:   2061f18ad76ecaddf8ed17df81b8611ea88dbddd
> commit: 4f716a1db661cfb31502a0a6d7e62c06daf2e603 drm/rcar-du: dsi: Convert register bitfields to GENMASK() macro
> date:   5 weeks ago
> config: arc-randconfig-001-20251205 (https://download.01.org/0day-ci/archive/20251205/202512051834.bESvhDiG-lkp@intel.com/config)
> compiler: arc-linux-gcc (GCC) 8.5.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251205/202512051834.bESvhDiG-lkp@intel.com/reproduce)
> 
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202512051834.bESvhDiG-lkp@intel.com/
> 
> All errors (new ones prefixed by >>):
> 
>     In file included from <command-line>:
>     drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi.c: In function 'rcar_mipi_dsi_startup.isra.4':
>>> include/linux/compiler_types.h:597:38: error: call to '__compiletime_assert_437' declared with attribute error: FIELD_PREP: value too large for the field

[...]

>     rcar_mipi_dsi.c:660:14: note: in expansion of macro 'VCLKSET_DIV_V4H'
>        vclkset |= VCLKSET_DIV_V4H(__ffs(setup_info.vclk_divider) - 1);
>                   ^~~~~~~~~~~~~~~
I don't think this condition can occur.

In drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi.c :
- rcar_mipi_dsi_startup() calls rcar_mipi_dsi_parameters_calc() which is 
the only site that assigns setup_info.vclk_divider this way:

  415         switch (dsi->info->model) {
  416         case RCAR_DSI_V3U:
  417         default:
  418                 setup_info->vclk_divider = 1 << 
((clk_cfg->vco_cntrl >> 4) & 0x3);
  419                 break;
  420
  421         case RCAR_DSI_V4H:
  422                 setup_info->vclk_divider = 1 << 
(((clk_cfg->vco_cntrl >> 3) & 0x7) + 1);
  423                 break;
  424         }

In case of V3U, vclk_divider is 1 << (0..3) .
In case of V4H, vclk_divider is 1 << (1..8) .

In drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi.c :
- rcar_mipi_dsi_startup() later contains the offending code:

  653         switch (dsi->info->model) {
  654         case RCAR_DSI_V3U:
  655         default:
  656                 vclkset |= 
VCLKSET_DIV_V3U(__ffs(setup_info.vclk_divider));
  657                 break;
  658
  659         case RCAR_DSI_V4H:
  660                 vclkset |= 
VCLKSET_DIV_V4H(__ffs(setup_info.vclk_divider) - 1);
  661                 break;
  662         }

This does the reverse of the code that assigned the value above, so:

In case of V3U, field value is (0..3) .
In case of V4H, field value is (0..7) .

Finally in drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi_regs.h :

256 #define VCLKSET_DIV_V3U_MASK            GENMASK_U32(5, 4)
257 #define VCLKSET_DIV_V3U(n) 
FIELD_PREP(VCLKSET_DIV_V3U_MASK, (n))
258 #define VCLKSET_DIV_V4H_MASK            GENMASK_U32(6, 4)
259 #define VCLKSET_DIV_V4H(n) 
FIELD_PREP(VCLKSET_DIV_V4H_MASK, (n))

The masks fit exactly. For V3U the mask is 2-bit, or V4H the mask is 3-bit .

...

I can however rewrite the code in this way, which should also mitigate 
this warning. Do you think this makes the code any better ?

diff --git a/drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi.c 
b/drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi.c
index 4ef2e3c129ed7..20e2a4cae5b86 100644
--- a/drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi.c
+++ b/drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi.c
@@ -84,7 +84,6 @@ struct dsi_setup_info {
  	unsigned long fout;
  	u16 m;
  	u16 n;
-	u16 vclk_divider;
  	const struct dsi_clk_config *clkset;
  };

@@ -338,7 +337,8 @@ rcar_mipi_dsi_post_init_phtw_v4h(struct 
rcar_mipi_dsi *dsi,
  static void rcar_mipi_dsi_pll_calc(struct rcar_mipi_dsi *dsi,
  				   unsigned long fin_rate,
  				   unsigned long fout_target,
-				   struct dsi_setup_info *setup_info)
+				   struct dsi_setup_info *setup_info,
+				   u16 vclk_divider)
  {
  	unsigned int best_err = -1;
  	const struct rcar_mipi_dsi_device_info *info = dsi->info;
@@ -391,6 +391,7 @@ static void rcar_mipi_dsi_parameters_calc(struct 
rcar_mipi_dsi *dsi,
  	unsigned long fin_rate;
  	unsigned int i;
  	unsigned int err;
+	u16 vclk_divider;

  	/*
  	 * Calculate Fout = dot clock * ColorDepth / (2 * Lane Count)
@@ -415,15 +416,15 @@ static void rcar_mipi_dsi_parameters_calc(struct 
rcar_mipi_dsi *dsi,
  	switch (dsi->info->model) {
  	case RCAR_DSI_V3U:
  	default:
-		setup_info->vclk_divider = 1 << ((clk_cfg->vco_cntrl >> 4) & 0x3);
+		vclk_divider = 1 << ((clk_cfg->vco_cntrl >> 4) & 0x3);
  		break;

  	case RCAR_DSI_V4H:
-		setup_info->vclk_divider = 1 << (((clk_cfg->vco_cntrl >> 3) & 0x7) + 1);
+		vclk_divider = 1 << (((clk_cfg->vco_cntrl >> 3) & 0x7) + 1);
  		break;
  	}

-	rcar_mipi_dsi_pll_calc(dsi, fin_rate, fout_target, setup_info);
+	rcar_mipi_dsi_pll_calc(dsi, fin_rate, fout_target, setup_info, 
vclk_divider);

  	/* Find hsfreqrange */
  	setup_info->hsfreq = setup_info->fout * 2;
@@ -439,7 +440,7 @@ static void rcar_mipi_dsi_parameters_calc(struct 
rcar_mipi_dsi *dsi,
  	dev_dbg(dsi->dev,
  		"Fout = %u * %lu / (%u * %u * %u) = %lu (target %lu Hz, error 
%d.%02u%%)\n",
  		setup_info->m, fin_rate, dsi->info->n_mul, setup_info->n,
-		setup_info->vclk_divider, setup_info->fout, fout_target,
+		vclk_divider, setup_info->fout, fout_target,
  		err / 100, err % 100);

  	dev_dbg(dsi->dev,
@@ -653,11 +654,11 @@ static int rcar_mipi_dsi_startup(struct 
rcar_mipi_dsi *dsi,
  	switch (dsi->info->model) {
  	case RCAR_DSI_V3U:
  	default:
-		vclkset |= VCLKSET_DIV_V3U(__ffs(setup_info.vclk_divider));
+		vclkset |= VCLKSET_DIV_V3U((clk_cfg->vco_cntrl >> 4) & 0x3);
  		break;

  	case RCAR_DSI_V4H:
-		vclkset |= VCLKSET_DIV_V4H(__ffs(setup_info.vclk_divider) - 1);
+		vclkset |= VCLKSET_DIV_V4H((clk_cfg->vco_cntrl >> 3) & 0x7);
  		break;
  	}

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

* Re: include/linux/compiler_types.h:597:38: error: call to '__compiletime_assert_437' declared with attribute error: FIELD_PREP: value too large for the field
  2025-12-30  2:47 ` Marek Vasut
@ 2025-12-30 10:30   ` Laurent Pinchart
  2025-12-31 15:05     ` Marek Vasut
  2025-12-30 23:02   ` David Laight
  1 sibling, 1 reply; 5+ messages in thread
From: Laurent Pinchart @ 2025-12-30 10:30 UTC (permalink / raw)
  To: Marek Vasut
  Cc: kernel test robot, Tomi Valkeinen, oe-kbuild-all, linux-kernel,
	open list:MEDIA DRIVERS FOR RENESAS - FCP

On Tue, Dec 30, 2025 at 03:47:17AM +0100, Marek Vasut wrote:
> On 12/5/25 11:16 AM, kernel test robot wrote:
> > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > head:   2061f18ad76ecaddf8ed17df81b8611ea88dbddd
> > commit: 4f716a1db661cfb31502a0a6d7e62c06daf2e603 drm/rcar-du: dsi: Convert register bitfields to GENMASK() macro
> > date:   5 weeks ago
> > config: arc-randconfig-001-20251205 (https://download.01.org/0day-ci/archive/20251205/202512051834.bESvhDiG-lkp@intel.com/config)
> > compiler: arc-linux-gcc (GCC) 8.5.0
> > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251205/202512051834.bESvhDiG-lkp@intel.com/reproduce)
> > 
> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <lkp@intel.com>
> > | Closes: https://lore.kernel.org/oe-kbuild-all/202512051834.bESvhDiG-lkp@intel.com/
> > 
> > All errors (new ones prefixed by >>):
> > 
> >     In file included from <command-line>:
> >     drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi.c: In function 'rcar_mipi_dsi_startup.isra.4':
> >>> include/linux/compiler_types.h:597:38: error: call to '__compiletime_assert_437' declared with attribute error: FIELD_PREP: value too large for the field
> 
> [...]
> 
> >     rcar_mipi_dsi.c:660:14: note: in expansion of macro 'VCLKSET_DIV_V4H'
> >        vclkset |= VCLKSET_DIV_V4H(__ffs(setup_info.vclk_divider) - 1);
> >                   ^~~~~~~~~~~~~~~
> I don't think this condition can occur.
> 
> In drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi.c :
> - rcar_mipi_dsi_startup() calls rcar_mipi_dsi_parameters_calc() which is 
> the only site that assigns setup_info.vclk_divider this way:
> 
>   415         switch (dsi->info->model) {
>   416         case RCAR_DSI_V3U:
>   417         default:
>   418                 setup_info->vclk_divider = 1 << ((clk_cfg->vco_cntrl >> 4) & 0x3);
>   419                 break;
>   420
>   421         case RCAR_DSI_V4H:
>   422                 setup_info->vclk_divider = 1 << (((clk_cfg->vco_cntrl >> 3) & 0x7) + 1);
>   423                 break;
>   424         }
> 
> In case of V3U, vclk_divider is 1 << (0..3) .
> In case of V4H, vclk_divider is 1 << (1..8) .
> 
> In drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi.c :
> - rcar_mipi_dsi_startup() later contains the offending code:
> 
>   653         switch (dsi->info->model) {
>   654         case RCAR_DSI_V3U:
>   655         default:
>   656                 vclkset |= VCLKSET_DIV_V3U(__ffs(setup_info.vclk_divider));
>   657                 break;
>   658
>   659         case RCAR_DSI_V4H:
>   660                 vclkset |= VCLKSET_DIV_V4H(__ffs(setup_info.vclk_divider) - 1);
>   661                 break;
>   662         }
> 
> This does the reverse of the code that assigned the value above, so:
> 
> In case of V3U, field value is (0..3) .
> In case of V4H, field value is (0..7) .
> 
> Finally in drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi_regs.h :
> 
> 256 #define VCLKSET_DIV_V3U_MASK            GENMASK_U32(5, 4)
> 257 #define VCLKSET_DIV_V3U(n) 
> FIELD_PREP(VCLKSET_DIV_V3U_MASK, (n))
> 258 #define VCLKSET_DIV_V4H_MASK            GENMASK_U32(6, 4)
> 259 #define VCLKSET_DIV_V4H(n) 
> FIELD_PREP(VCLKSET_DIV_V4H_MASK, (n))
> 
> The masks fit exactly. For V3U the mask is 2-bit, or V4H the mask is 3-bit .
> 
> ...
> 
> I can however rewrite the code in this way, which should also mitigate 
> this warning. Do you think this makes the code any better ?

The datasheet says that the VCLKSET.DIV field "should be same as the
CLOCKSET2.vco_cntrl[5:3]". The change below makes this explicit, which
may not be a bad thing, even if it duplicates the small calculation.

> diff --git a/drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi.c 
> b/drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi.c
> index 4ef2e3c129ed7..20e2a4cae5b86 100644
> --- a/drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi.c
> +++ b/drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi.c
> @@ -84,7 +84,6 @@ struct dsi_setup_info {
>   	unsigned long fout;
>   	u16 m;
>   	u16 n;
> -	u16 vclk_divider;
>   	const struct dsi_clk_config *clkset;
>   };
> 
> @@ -338,7 +337,8 @@ rcar_mipi_dsi_post_init_phtw_v4h(struct 
> rcar_mipi_dsi *dsi,
>   static void rcar_mipi_dsi_pll_calc(struct rcar_mipi_dsi *dsi,
>   				   unsigned long fin_rate,
>   				   unsigned long fout_target,
> -				   struct dsi_setup_info *setup_info)
> +				   struct dsi_setup_info *setup_info,
> +				   u16 vclk_divider)
>   {
>   	unsigned int best_err = -1;
>   	const struct rcar_mipi_dsi_device_info *info = dsi->info;
> @@ -391,6 +391,7 @@ static void rcar_mipi_dsi_parameters_calc(struct 
> rcar_mipi_dsi *dsi,
>   	unsigned long fin_rate;
>   	unsigned int i;
>   	unsigned int err;
> +	u16 vclk_divider;
> 
>   	/*
>   	 * Calculate Fout = dot clock * ColorDepth / (2 * Lane Count)
> @@ -415,15 +416,15 @@ static void rcar_mipi_dsi_parameters_calc(struct 
> rcar_mipi_dsi *dsi,
>   	switch (dsi->info->model) {
>   	case RCAR_DSI_V3U:
>   	default:
> -		setup_info->vclk_divider = 1 << ((clk_cfg->vco_cntrl >> 4) & 0x3);
> +		vclk_divider = 1 << ((clk_cfg->vco_cntrl >> 4) & 0x3);
>   		break;
> 
>   	case RCAR_DSI_V4H:
> -		setup_info->vclk_divider = 1 << (((clk_cfg->vco_cntrl >> 3) & 0x7) + 1);
> +		vclk_divider = 1 << (((clk_cfg->vco_cntrl >> 3) & 0x7) + 1);
>   		break;
>   	}
> 
> -	rcar_mipi_dsi_pll_calc(dsi, fin_rate, fout_target, setup_info);
> +	rcar_mipi_dsi_pll_calc(dsi, fin_rate, fout_target, setup_info, vclk_divider);
> 
>   	/* Find hsfreqrange */
>   	setup_info->hsfreq = setup_info->fout * 2;
> @@ -439,7 +440,7 @@ static void rcar_mipi_dsi_parameters_calc(struct rcar_mipi_dsi *dsi,
>   	dev_dbg(dsi->dev,
>   		"Fout = %u * %lu / (%u * %u * %u) = %lu (target %lu Hz, error %d.%02u%%)\n",
>   		setup_info->m, fin_rate, dsi->info->n_mul, setup_info->n,
> -		setup_info->vclk_divider, setup_info->fout, fout_target,
> +		vclk_divider, setup_info->fout, fout_target,
>   		err / 100, err % 100);
> 
>   	dev_dbg(dsi->dev,
> @@ -653,11 +654,11 @@ static int rcar_mipi_dsi_startup(struct rcar_mipi_dsi *dsi,
>   	switch (dsi->info->model) {
>   	case RCAR_DSI_V3U:
>   	default:
> -		vclkset |= VCLKSET_DIV_V3U(__ffs(setup_info.vclk_divider));
> +		vclkset |= VCLKSET_DIV_V3U((clk_cfg->vco_cntrl >> 4) & 0x3);
>   		break;
> 
>   	case RCAR_DSI_V4H:
> -		vclkset |= VCLKSET_DIV_V4H(__ffs(setup_info.vclk_divider) - 1);
> +		vclkset |= VCLKSET_DIV_V4H((clk_cfg->vco_cntrl >> 3) & 0x7);
>   		break;
>   	}

Laurent Pinchart

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

* Re: include/linux/compiler_types.h:597:38: error: call to '__compiletime_assert_437' declared with attribute error: FIELD_PREP: value too large for the field
  2025-12-30  2:47 ` Marek Vasut
  2025-12-30 10:30   ` Laurent Pinchart
@ 2025-12-30 23:02   ` David Laight
  1 sibling, 0 replies; 5+ messages in thread
From: David Laight @ 2025-12-30 23:02 UTC (permalink / raw)
  To: Marek Vasut
  Cc: kernel test robot, Tomi Valkeinen, Laurent Pinchart,
	oe-kbuild-all, linux-kernel,
	open list:MEDIA DRIVERS FOR RENESAS - FCP

On Tue, 30 Dec 2025 03:47:17 +0100
Marek Vasut <marek.vasut@mailbox.org> wrote:

> On 12/5/25 11:16 AM, kernel test robot wrote:
> > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > head:   2061f18ad76ecaddf8ed17df81b8611ea88dbddd
> > commit: 4f716a1db661cfb31502a0a6d7e62c06daf2e603 drm/rcar-du: dsi: Convert register bitfields to GENMASK() macro
> > date:   5 weeks ago
> > config: arc-randconfig-001-20251205 (https://download.01.org/0day-ci/archive/20251205/202512051834.bESvhDiG-lkp@intel.com/config)
> > compiler: arc-linux-gcc (GCC) 8.5.0
> > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251205/202512051834.bESvhDiG-lkp@intel.com/reproduce)
> > 
> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <lkp@intel.com>
> > | Closes: https://lore.kernel.org/oe-kbuild-all/202512051834.bESvhDiG-lkp@intel.com/
> > 
> > All errors (new ones prefixed by >>):
> > 
> >     In file included from <command-line>:
> >     drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi.c: In function 'rcar_mipi_dsi_startup.isra.4':  
> >>> include/linux/compiler_types.h:597:38: error: call to '__compiletime_assert_437' declared with attribute error: FIELD_PREP: value too large for the field  
> 
> [...]
> 
> >     rcar_mipi_dsi.c:660:14: note: in expansion of macro 'VCLKSET_DIV_V4H'
> >        vclkset |= VCLKSET_DIV_V4H(__ffs(setup_info.vclk_divider) - 1);
> >                   ^~~~~~~~~~~~~~~  
> I don't think this condition can occur.

The value of vclk_divider makes no difference.
The compiler has generated a code path where a constant is passed to
FIELD_PREP().

At a guess 'arc' doesn't have a definition for __ffs(x) so the compiler
builtin in used (I've forgotten its name), but that probably has looks like:
#define __ffs(x) (__builtin_ffs(x) - 1)
where (effectively):
#define __builtin_ffs(x) (!x ? 0 : 1 + count_trailing_zeros(x))
That ?: condition ends up in the code and gcc moves the FIELD_PREP()
into it (gcc likes optimising arithmetic on constants).
So you end up with FIELD_PREP(mask, -1) - and hence the error.

> 
> In drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi.c :
> - rcar_mipi_dsi_startup() calls rcar_mipi_dsi_parameters_calc() which is 
> the only site that assigns setup_info.vclk_divider this way:
> 
>   415         switch (dsi->info->model) {
>   416         case RCAR_DSI_V3U:
>   417         default:
>   418                 setup_info->vclk_divider = 1 << ((clk_cfg->vco_cntrl >> 4) & 0x3);
>   419                 break;
>   420
>   421         case RCAR_DSI_V4H:
>   422                 setup_info->vclk_divider = 1 << (((clk_cfg->vco_cntrl >> 3) & 0x7) + 1);
>   423                 break;
>   424         }
> 
> In case of V3U, vclk_divider is 1 << (0..3) .
> In case of V4H, vclk_divider is 1 << (1..8) .
> 
> In drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi.c :
> - rcar_mipi_dsi_startup() later contains the offending code:
> 
>   653         switch (dsi->info->model) {
>   654         case RCAR_DSI_V3U:
>   655         default:
>   656                 vclkset |= VCLKSET_DIV_V3U(__ffs(setup_info.vclk_divider));
>   657                 break;
>   658
>   659         case RCAR_DSI_V4H:
>   660                 vclkset |= VCLKSET_DIV_V4H(__ffs(setup_info.vclk_divider) - 1);
>   661                 break;
>   662         }
> 
> This does the reverse of the code that assigned the value above, so:
> 
> In case of V3U, field value is (0..3) .
> In case of V4H, field value is (0..7) .
> 
> Finally in drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi_regs.h :
> 
> 256 #define VCLKSET_DIV_V3U_MASK            GENMASK_U32(5, 4)
> 257 #define VCLKSET_DIV_V3U(n) FIELD_PREP(VCLKSET_DIV_V3U_MASK, (n))
> 258 #define VCLKSET_DIV_V4H_MASK            GENMASK_U32(6, 4)
> 259 #define VCLKSET_DIV_V4H(n) FIELD_PREP(VCLKSET_DIV_V4H_MASK, (n))
> 
> The masks fit exactly. For V3U the mask is 2-bit, or V4H the mask is 3-bit .

The only other use I can see is:
			fout = div64_u64(fout, setup_info->vclk_divider);

ISTM that there is an unnecessary '1 << n' and __ffs().
Perhaps you should be saving the 'bit number' not the shifted value.
The div64_u64() is then just a >> and fine on 32bit systems.

	David

> 
> ...
> 
> I can however rewrite the code in this way, which should also mitigate 
> this warning. Do you think this makes the code any better ?
> 
> diff --git a/drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi.c 
> b/drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi.c
> index 4ef2e3c129ed7..20e2a4cae5b86 100644
> --- a/drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi.c
> +++ b/drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi.c
> @@ -84,7 +84,6 @@ struct dsi_setup_info {
>   	unsigned long fout;
>   	u16 m;
>   	u16 n;
> -	u16 vclk_divider;
>   	const struct dsi_clk_config *clkset;
>   };
> 
> @@ -338,7 +337,8 @@ rcar_mipi_dsi_post_init_phtw_v4h(struct 
> rcar_mipi_dsi *dsi,
>   static void rcar_mipi_dsi_pll_calc(struct rcar_mipi_dsi *dsi,
>   				   unsigned long fin_rate,
>   				   unsigned long fout_target,
> -				   struct dsi_setup_info *setup_info)
> +				   struct dsi_setup_info *setup_info,
> +				   u16 vclk_divider)
>   {
>   	unsigned int best_err = -1;
>   	const struct rcar_mipi_dsi_device_info *info = dsi->info;
> @@ -391,6 +391,7 @@ static void rcar_mipi_dsi_parameters_calc(struct 
> rcar_mipi_dsi *dsi,
>   	unsigned long fin_rate;
>   	unsigned int i;
>   	unsigned int err;
> +	u16 vclk_divider;
> 
>   	/*
>   	 * Calculate Fout = dot clock * ColorDepth / (2 * Lane Count)
> @@ -415,15 +416,15 @@ static void rcar_mipi_dsi_parameters_calc(struct 
> rcar_mipi_dsi *dsi,
>   	switch (dsi->info->model) {
>   	case RCAR_DSI_V3U:
>   	default:
> -		setup_info->vclk_divider = 1 << ((clk_cfg->vco_cntrl >> 4) & 0x3);
> +		vclk_divider = 1 << ((clk_cfg->vco_cntrl >> 4) & 0x3);
>   		break;
> 
>   	case RCAR_DSI_V4H:
> -		setup_info->vclk_divider = 1 << (((clk_cfg->vco_cntrl >> 3) & 0x7) + 1);
> +		vclk_divider = 1 << (((clk_cfg->vco_cntrl >> 3) & 0x7) + 1);
>   		break;
>   	}
> 
> -	rcar_mipi_dsi_pll_calc(dsi, fin_rate, fout_target, setup_info);
> +	rcar_mipi_dsi_pll_calc(dsi, fin_rate, fout_target, setup_info, 
> vclk_divider);
> 
>   	/* Find hsfreqrange */
>   	setup_info->hsfreq = setup_info->fout * 2;
> @@ -439,7 +440,7 @@ static void rcar_mipi_dsi_parameters_calc(struct 
> rcar_mipi_dsi *dsi,
>   	dev_dbg(dsi->dev,
>   		"Fout = %u * %lu / (%u * %u * %u) = %lu (target %lu Hz, error 
> %d.%02u%%)\n",
>   		setup_info->m, fin_rate, dsi->info->n_mul, setup_info->n,
> -		setup_info->vclk_divider, setup_info->fout, fout_target,
> +		vclk_divider, setup_info->fout, fout_target,
>   		err / 100, err % 100);
> 
>   	dev_dbg(dsi->dev,
> @@ -653,11 +654,11 @@ static int rcar_mipi_dsi_startup(struct 
> rcar_mipi_dsi *dsi,
>   	switch (dsi->info->model) {
>   	case RCAR_DSI_V3U:
>   	default:
> -		vclkset |= VCLKSET_DIV_V3U(__ffs(setup_info.vclk_divider));
> +		vclkset |= VCLKSET_DIV_V3U((clk_cfg->vco_cntrl >> 4) & 0x3);
>   		break;
> 
>   	case RCAR_DSI_V4H:
> -		vclkset |= VCLKSET_DIV_V4H(__ffs(setup_info.vclk_divider) - 1);
> +		vclkset |= VCLKSET_DIV_V4H((clk_cfg->vco_cntrl >> 3) & 0x7);
>   		break;
>   	}
> 


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

* Re: include/linux/compiler_types.h:597:38: error: call to '__compiletime_assert_437' declared with attribute error: FIELD_PREP: value too large for the field
  2025-12-30 10:30   ` Laurent Pinchart
@ 2025-12-31 15:05     ` Marek Vasut
  0 siblings, 0 replies; 5+ messages in thread
From: Marek Vasut @ 2025-12-31 15:05 UTC (permalink / raw)
  To: Laurent Pinchart, David Laight
  Cc: kernel test robot, Tomi Valkeinen, oe-kbuild-all, linux-kernel,
	open list:MEDIA DRIVERS FOR RENESAS - FCP

On 12/30/25 11:30 AM, Laurent Pinchart wrote:
> On Tue, Dec 30, 2025 at 03:47:17AM +0100, Marek Vasut wrote:
>> On 12/5/25 11:16 AM, kernel test robot wrote:
>>> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
>>> head:   2061f18ad76ecaddf8ed17df81b8611ea88dbddd
>>> commit: 4f716a1db661cfb31502a0a6d7e62c06daf2e603 drm/rcar-du: dsi: Convert register bitfields to GENMASK() macro
>>> date:   5 weeks ago
>>> config: arc-randconfig-001-20251205 (https://download.01.org/0day-ci/archive/20251205/202512051834.bESvhDiG-lkp@intel.com/config)
>>> compiler: arc-linux-gcc (GCC) 8.5.0
>>> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251205/202512051834.bESvhDiG-lkp@intel.com/reproduce)
>>>
>>> If you fix the issue in a separate patch/commit (i.e. not just a new version of
>>> the same patch/commit), kindly add following tags
>>> | Reported-by: kernel test robot <lkp@intel.com>
>>> | Closes: https://lore.kernel.org/oe-kbuild-all/202512051834.bESvhDiG-lkp@intel.com/
>>>
>>> All errors (new ones prefixed by >>):
>>>
>>>      In file included from <command-line>:
>>>      drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi.c: In function 'rcar_mipi_dsi_startup.isra.4':
>>>>> include/linux/compiler_types.h:597:38: error: call to '__compiletime_assert_437' declared with attribute error: FIELD_PREP: value too large for the field
>>
>> [...]
>>
>>>      rcar_mipi_dsi.c:660:14: note: in expansion of macro 'VCLKSET_DIV_V4H'
>>>         vclkset |= VCLKSET_DIV_V4H(__ffs(setup_info.vclk_divider) - 1);
>>>                    ^~~~~~~~~~~~~~~
>> I don't think this condition can occur.
>>
>> In drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi.c :
>> - rcar_mipi_dsi_startup() calls rcar_mipi_dsi_parameters_calc() which is
>> the only site that assigns setup_info.vclk_divider this way:
>>
>>    415         switch (dsi->info->model) {
>>    416         case RCAR_DSI_V3U:
>>    417         default:
>>    418                 setup_info->vclk_divider = 1 << ((clk_cfg->vco_cntrl >> 4) & 0x3);
>>    419                 break;
>>    420
>>    421         case RCAR_DSI_V4H:
>>    422                 setup_info->vclk_divider = 1 << (((clk_cfg->vco_cntrl >> 3) & 0x7) + 1);
>>    423                 break;
>>    424         }
>>
>> In case of V3U, vclk_divider is 1 << (0..3) .
>> In case of V4H, vclk_divider is 1 << (1..8) .
>>
>> In drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi.c :
>> - rcar_mipi_dsi_startup() later contains the offending code:
>>
>>    653         switch (dsi->info->model) {
>>    654         case RCAR_DSI_V3U:
>>    655         default:
>>    656                 vclkset |= VCLKSET_DIV_V3U(__ffs(setup_info.vclk_divider));
>>    657                 break;
>>    658
>>    659         case RCAR_DSI_V4H:
>>    660                 vclkset |= VCLKSET_DIV_V4H(__ffs(setup_info.vclk_divider) - 1);
>>    661                 break;
>>    662         }
>>
>> This does the reverse of the code that assigned the value above, so:
>>
>> In case of V3U, field value is (0..3) .
>> In case of V4H, field value is (0..7) .
>>
>> Finally in drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi_regs.h :
>>
>> 256 #define VCLKSET_DIV_V3U_MASK            GENMASK_U32(5, 4)
>> 257 #define VCLKSET_DIV_V3U(n)
>> FIELD_PREP(VCLKSET_DIV_V3U_MASK, (n))
>> 258 #define VCLKSET_DIV_V4H_MASK            GENMASK_U32(6, 4)
>> 259 #define VCLKSET_DIV_V4H(n)
>> FIELD_PREP(VCLKSET_DIV_V4H_MASK, (n))
>>
>> The masks fit exactly. For V3U the mask is 2-bit, or V4H the mask is 3-bit .
>>
>> ...
>>
>> I can however rewrite the code in this way, which should also mitigate
>> this warning. Do you think this makes the code any better ?
> 
> The datasheet says that the VCLKSET.DIV field "should be same as the
> CLOCKSET2.vco_cntrl[5:3]". The change below makes this explicit, which
> may not be a bad thing, even if it duplicates the small calculation.
I believe the following rework should address the duplication concern too:

https://lore.kernel.org/dri-devel/20251231145712.60816-1-marek.vasut+renesas@mailbox.org/

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

end of thread, other threads:[~2025-12-31 15:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-05 10:16 include/linux/compiler_types.h:597:38: error: call to '__compiletime_assert_437' declared with attribute error: FIELD_PREP: value too large for the field kernel test robot
2025-12-30  2:47 ` Marek Vasut
2025-12-30 10:30   ` Laurent Pinchart
2025-12-31 15:05     ` Marek Vasut
2025-12-30 23:02   ` David Laight

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.