* [PATCH] wifi: iwlwifi: pcie: ensure RX_QUEUE_CB_SIZE fits bitfield for gcc-8|9
@ 2025-06-12 13:07 Anders Roxell
2025-06-12 13:17 ` Dan Carpenter
2025-06-12 15:21 ` Johannes Berg
0 siblings, 2 replies; 7+ messages in thread
From: Anders Roxell @ 2025-06-12 13:07 UTC (permalink / raw)
To: miriam.rachel.korenblit
Cc: dan.carpenter, arnd, linux-wireless, linux-kernel, Anders Roxell,
Linux Kernel Functional Testing
GCC-8 and GCC-9 emits a hard error when the value passed to
`u32_encode_bits()`. These versions somehow think that
RX_QUEUE_CB_SIZE(iwl_trans_get_num_rbds(trans)) is an out of bounds
constant. Open code this calculation using FIELD_PREP() to avoid this
compile error.
error: call to '__field_overflow' declared with attribute error: value
doesn't fit into mask
Fixes: b8eee90f0ba5 ("wifi: iwlwifi: cfg: unify num_rbds config")
Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>
Closes: https://lore.kernel.org/all/CA+G9fYssasMnOE36xLH5m7ky4fKxbzN7kX5mEE7icnuu+0hGuQ@mail.gmail.com/
Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
---
drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info.c b/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info.c
index cb36baac14da..1854d071aff2 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info.c
@@ -204,9 +204,10 @@ int iwl_pcie_ctxt_info_init(struct iwl_trans *trans,
WARN_ON(RX_QUEUE_CB_SIZE(iwl_trans_get_num_rbds(trans)) > 12);
control_flags = IWL_CTXT_INFO_TFD_FORMAT_LONG;
- control_flags |=
- u32_encode_bits(RX_QUEUE_CB_SIZE(iwl_trans_get_num_rbds(trans)),
- IWL_CTXT_INFO_RB_CB_SIZE);
+ /* This should just be u32_encode_bits() but gcc-8 and gcc-9 fail to build */
+ control_flags |= FIELD_PREP(IWL_CTXT_INFO_RB_CB_SIZE,
+ RX_QUEUE_CB_SIZE(iwl_trans_get_num_rbds(trans)) &
+ FIELD_MAX(IWL_CTXT_INFO_RB_CB_SIZE));
control_flags |= u32_encode_bits(rb_size, IWL_CTXT_INFO_RB_SIZE);
ctxt_info->control.control_flags = cpu_to_le32(control_flags);
--
2.47.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] wifi: iwlwifi: pcie: ensure RX_QUEUE_CB_SIZE fits bitfield for gcc-8|9
2025-06-12 13:07 [PATCH] wifi: iwlwifi: pcie: ensure RX_QUEUE_CB_SIZE fits bitfield for gcc-8|9 Anders Roxell
@ 2025-06-12 13:17 ` Dan Carpenter
2025-06-12 15:21 ` Johannes Berg
1 sibling, 0 replies; 7+ messages in thread
From: Dan Carpenter @ 2025-06-12 13:17 UTC (permalink / raw)
To: Anders Roxell
Cc: miriam.rachel.korenblit, arnd, linux-wireless, linux-kernel,
Linux Kernel Functional Testing
On Thu, Jun 12, 2025 at 03:07:19PM +0200, Anders Roxell wrote:
> GCC-8 and GCC-9 emits a hard error when the value passed to
> `u32_encode_bits()`. These versions somehow think that
> RX_QUEUE_CB_SIZE(iwl_trans_get_num_rbds(trans)) is an out of bounds
> constant. Open code this calculation using FIELD_PREP() to avoid this
> compile error.
>
> error: call to '__field_overflow' declared with attribute error: value
> doesn't fit into mask
>
> Fixes: b8eee90f0ba5 ("wifi: iwlwifi: cfg: unify num_rbds config")
> Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>
> Closes: https://lore.kernel.org/all/CA+G9fYssasMnOE36xLH5m7ky4fKxbzN7kX5mEE7icnuu+0hGuQ@mail.gmail.com/
> Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
regards,
dan carpenter
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] wifi: iwlwifi: pcie: ensure RX_QUEUE_CB_SIZE fits bitfield for gcc-8|9
2025-06-12 13:07 [PATCH] wifi: iwlwifi: pcie: ensure RX_QUEUE_CB_SIZE fits bitfield for gcc-8|9 Anders Roxell
2025-06-12 13:17 ` Dan Carpenter
@ 2025-06-12 15:21 ` Johannes Berg
2025-06-12 19:33 ` Anders Roxell
1 sibling, 1 reply; 7+ messages in thread
From: Johannes Berg @ 2025-06-12 15:21 UTC (permalink / raw)
To: Anders Roxell, miriam.rachel.korenblit
Cc: dan.carpenter, arnd, linux-wireless, linux-kernel,
Linux Kernel Functional Testing
>
> diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info.c b/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info.c
> index cb36baac14da..1854d071aff2 100644
> --- a/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info.c
> +++ b/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info.c
> @@ -204,9 +204,10 @@ int iwl_pcie_ctxt_info_init(struct iwl_trans *trans,
>
> WARN_ON(RX_QUEUE_CB_SIZE(iwl_trans_get_num_rbds(trans)) > 12);
> control_flags = IWL_CTXT_INFO_TFD_FORMAT_LONG;
> - control_flags |=
> - u32_encode_bits(RX_QUEUE_CB_SIZE(iwl_trans_get_num_rbds(trans)),
> - IWL_CTXT_INFO_RB_CB_SIZE);
> + /* This should just be u32_encode_bits() but gcc-8 and gcc-9 fail to build */
> + control_flags |= FIELD_PREP(IWL_CTXT_INFO_RB_CB_SIZE,
> + RX_QUEUE_CB_SIZE(iwl_trans_get_num_rbds(trans)) &
> + FIELD_MAX(IWL_CTXT_INFO_RB_CB_SIZE));
>
The coding style is really confusing now though - what are arguments to
the macro and all that.
johannes
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] wifi: iwlwifi: pcie: ensure RX_QUEUE_CB_SIZE fits bitfield for gcc-8|9
2025-06-12 15:21 ` Johannes Berg
@ 2025-06-12 19:33 ` Anders Roxell
2025-06-12 19:46 ` Johannes Berg
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Anders Roxell @ 2025-06-12 19:33 UTC (permalink / raw)
To: Johannes Berg
Cc: miriam.rachel.korenblit, dan.carpenter, arnd, linux-wireless,
linux-kernel, Linux Kernel Functional Testing
On 2025-06-12 17:21, Johannes Berg wrote:
> >
> > diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info.c b/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info.c
> > index cb36baac14da..1854d071aff2 100644
> > --- a/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info.c
> > +++ b/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info.c
> > @@ -204,9 +204,10 @@ int iwl_pcie_ctxt_info_init(struct iwl_trans *trans,
> >
> > WARN_ON(RX_QUEUE_CB_SIZE(iwl_trans_get_num_rbds(trans)) > 12);
> > control_flags = IWL_CTXT_INFO_TFD_FORMAT_LONG;
> > - control_flags |=
> > - u32_encode_bits(RX_QUEUE_CB_SIZE(iwl_trans_get_num_rbds(trans)),
> > - IWL_CTXT_INFO_RB_CB_SIZE);
> > + /* This should just be u32_encode_bits() but gcc-8 and gcc-9 fail to build */
> > + control_flags |= FIELD_PREP(IWL_CTXT_INFO_RB_CB_SIZE,
> > + RX_QUEUE_CB_SIZE(iwl_trans_get_num_rbds(trans)) &
> > + FIELD_MAX(IWL_CTXT_INFO_RB_CB_SIZE));
> >
>
> The coding style is really confusing now though - what are arguments to
> the macro and all that.
Would it help if I indent like this?
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info.c b/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info.c
index cb36baac14da..5bb81ed7db79 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info.c
@@ -204,9 +204,10 @@ int iwl_pcie_ctxt_info_init(struct iwl_trans *trans,
WARN_ON(RX_QUEUE_CB_SIZE(iwl_trans_get_num_rbds(trans)) > 12);
control_flags = IWL_CTXT_INFO_TFD_FORMAT_LONG;
- control_flags |=
- u32_encode_bits(RX_QUEUE_CB_SIZE(iwl_trans_get_num_rbds(trans)),
- IWL_CTXT_INFO_RB_CB_SIZE);
+ /* This should just be u32_encode_bits() but gcc-8 and gcc-9 fail to build */
+ control_flags |= FIELD_PREP(IWL_CTXT_INFO_RB_CB_SIZE,
+ RX_QUEUE_CB_SIZE(iwl_trans_get_num_rbds(trans)) &
+ FIELD_MAX(IWL_CTXT_INFO_RB_CB_SIZE));
control_flags |= u32_encode_bits(rb_size, IWL_CTXT_INFO_RB_SIZE);
ctxt_info->control.control_flags = cpu_to_le32(control_flags);
Cheers,
Anders
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] wifi: iwlwifi: pcie: ensure RX_QUEUE_CB_SIZE fits bitfield for gcc-8|9
2025-06-12 19:33 ` Anders Roxell
@ 2025-06-12 19:46 ` Johannes Berg
2025-06-12 19:48 ` Arnd Bergmann
2025-06-14 8:21 ` David Laight
2 siblings, 0 replies; 7+ messages in thread
From: Johannes Berg @ 2025-06-12 19:46 UTC (permalink / raw)
To: Anders Roxell
Cc: miriam.rachel.korenblit, dan.carpenter, arnd, linux-wireless,
linux-kernel, Linux Kernel Functional Testing
>
> Would it help if I indent like this?
Yeah, maybe? I actually misread it and thought the & went outside
FIELD_PREP() ...
> diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info.c b/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info.c
> index cb36baac14da..5bb81ed7db79 100644
> --- a/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info.c
> +++ b/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info.c
> @@ -204,9 +204,10 @@ int iwl_pcie_ctxt_info_init(struct iwl_trans *trans,
>
> WARN_ON(RX_QUEUE_CB_SIZE(iwl_trans_get_num_rbds(trans)) > 12);
> control_flags = IWL_CTXT_INFO_TFD_FORMAT_LONG;
> - control_flags |=
> - u32_encode_bits(RX_QUEUE_CB_SIZE(iwl_trans_get_num_rbds(trans)),
> - IWL_CTXT_INFO_RB_CB_SIZE);
> + /* This should just be u32_encode_bits() but gcc-8 and gcc-9 fail to build */
> + control_flags |= FIELD_PREP(IWL_CTXT_INFO_RB_CB_SIZE,
> + RX_QUEUE_CB_SIZE(iwl_trans_get_num_rbds(trans)) &
> + FIELD_MAX(IWL_CTXT_INFO_RB_CB_SIZE));
Also now that I think more about it, this really just adds the part with
the masking ("& FIELD_MAX()"), is it even necessary to use FIELD_PREP()
rather than u32_encode_bits()?
johannes
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] wifi: iwlwifi: pcie: ensure RX_QUEUE_CB_SIZE fits bitfield for gcc-8|9
2025-06-12 19:33 ` Anders Roxell
2025-06-12 19:46 ` Johannes Berg
@ 2025-06-12 19:48 ` Arnd Bergmann
2025-06-14 8:21 ` David Laight
2 siblings, 0 replies; 7+ messages in thread
From: Arnd Bergmann @ 2025-06-12 19:48 UTC (permalink / raw)
To: Anders Roxell, Johannes Berg
Cc: Miri Korenblit, Dan Carpenter, linux-wireless, linux-kernel,
Linaro Kernel Functional Testing
On Thu, Jun 12, 2025, at 21:33, Anders Roxell wrote:
> On 2025-06-12 17:21, Johannes Berg wrote:
>
> Would it help if I indent like this?
>
> + /* This should just be u32_encode_bits() but gcc-8 and gcc-9 fail to build */
> + control_flags |= FIELD_PREP(IWL_CTXT_INFO_RB_CB_SIZE,
> + RX_QUEUE_CB_SIZE(iwl_trans_get_num_rbds(trans)) &
> + FIELD_MAX(IWL_CTXT_INFO_RB_CB_SIZE));
> control_flags |= u32_encode_bits(rb_size, IWL_CTXT_INFO_RB_SIZE);
I still find it odd to mix FIELD_PREP() and u32_encode_bits() here,
as they do the same thing.
Arnd
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] wifi: iwlwifi: pcie: ensure RX_QUEUE_CB_SIZE fits bitfield for gcc-8|9
2025-06-12 19:33 ` Anders Roxell
2025-06-12 19:46 ` Johannes Berg
2025-06-12 19:48 ` Arnd Bergmann
@ 2025-06-14 8:21 ` David Laight
2 siblings, 0 replies; 7+ messages in thread
From: David Laight @ 2025-06-14 8:21 UTC (permalink / raw)
To: Anders Roxell
Cc: Johannes Berg, miriam.rachel.korenblit, dan.carpenter, arnd,
linux-wireless, linux-kernel, Linux Kernel Functional Testing
On Thu, 12 Jun 2025 21:33:44 +0200
Anders Roxell <anders.roxell@linaro.org> wrote:
> On 2025-06-12 17:21, Johannes Berg wrote:
> > >
> > > diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info.c b/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info.c
> > > index cb36baac14da..1854d071aff2 100644
> > > --- a/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info.c
> > > +++ b/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info.c
> > > @@ -204,9 +204,10 @@ int iwl_pcie_ctxt_info_init(struct iwl_trans *trans,
> > >
> > > WARN_ON(RX_QUEUE_CB_SIZE(iwl_trans_get_num_rbds(trans)) > 12);
> > > control_flags = IWL_CTXT_INFO_TFD_FORMAT_LONG;
> > > - control_flags |=
> > > - u32_encode_bits(RX_QUEUE_CB_SIZE(iwl_trans_get_num_rbds(trans)),
> > > - IWL_CTXT_INFO_RB_CB_SIZE);
> > > + /* This should just be u32_encode_bits() but gcc-8 and gcc-9 fail to build */
> > > + control_flags |= FIELD_PREP(IWL_CTXT_INFO_RB_CB_SIZE,
> > > + RX_QUEUE_CB_SIZE(iwl_trans_get_num_rbds(trans)) &
> > > + FIELD_MAX(IWL_CTXT_INFO_RB_CB_SIZE));
> > >
> >
> > The coding style is really confusing now though - what are arguments to
> > the macro and all that.
>
> Would it help if I indent like this?
>
> diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info.c b/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info.c
> index cb36baac14da..5bb81ed7db79 100644
> --- a/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info.c
> +++ b/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info.c
> @@ -204,9 +204,10 @@ int iwl_pcie_ctxt_info_init(struct iwl_trans *trans,
>
> WARN_ON(RX_QUEUE_CB_SIZE(iwl_trans_get_num_rbds(trans)) > 12);
> control_flags = IWL_CTXT_INFO_TFD_FORMAT_LONG;
> - control_flags |=
> - u32_encode_bits(RX_QUEUE_CB_SIZE(iwl_trans_get_num_rbds(trans)),
> - IWL_CTXT_INFO_RB_CB_SIZE);
> + /* This should just be u32_encode_bits() but gcc-8 and gcc-9 fail to build */
> + control_flags |= FIELD_PREP(IWL_CTXT_INFO_RB_CB_SIZE,
> + RX_QUEUE_CB_SIZE(iwl_trans_get_num_rbds(trans)) &
> + FIELD_MAX(IWL_CTXT_INFO_RB_CB_SIZE));
I would always indent the 'continued' part of an arithmetic expression.
Otherwise it looks (in this case) like another argument to FIELD_PREP().
(Not helped by the coding style requiring the '&' on the end of the line
rather than the start of the continuation line.)
David
> control_flags |= u32_encode_bits(rb_size, IWL_CTXT_INFO_RB_SIZE);
> ctxt_info->control.control_flags = cpu_to_le32(control_flags);
>
>
> Cheers,
> Anders
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-06-14 8:21 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-12 13:07 [PATCH] wifi: iwlwifi: pcie: ensure RX_QUEUE_CB_SIZE fits bitfield for gcc-8|9 Anders Roxell
2025-06-12 13:17 ` Dan Carpenter
2025-06-12 15:21 ` Johannes Berg
2025-06-12 19:33 ` Anders Roxell
2025-06-12 19:46 ` Johannes Berg
2025-06-12 19:48 ` Arnd Bergmann
2025-06-14 8:21 ` David Laight
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).