* [PATCH] wifi: iwlwifi: cfg: Limit cb_size to valid range
@ 2025-05-23 6:04 Pei Xiao
2025-05-23 7:59 ` Johannes Berg
0 siblings, 1 reply; 4+ messages in thread
From: Pei Xiao @ 2025-05-23 6:04 UTC (permalink / raw)
To: miriam.rachel.korenblit, johannes.berg, emmanuel.grumbach,
linux-wireless, linux-kernel
Cc: Pei Xiao
on arm64 defconfig build failed with gcc-8:
drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info.c:208:3:
include/linux/bitfield.h:195:3: error: call to '__field_overflow'
declared with attribute error: value doesn't fit into mask
__field_overflow(); \
^~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:215:2: note: in expansion of macro '____MAKE_OP'
____MAKE_OP(u##size,u##size,,)
^~~~~~~~~~~
include/linux/bitfield.h:218:1: note: in expansion of macro '__MAKE_OP'
__MAKE_OP(32)
Limit cb_size to valid range to fix it.
Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
---
drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 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..8437763dcf5a 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info.c
@@ -166,7 +166,7 @@ int iwl_pcie_ctxt_info_init(struct iwl_trans *trans,
struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
struct iwl_context_info *ctxt_info;
struct iwl_context_info_rbd_cfg *rx_cfg;
- u32 control_flags = 0, rb_size;
+ u32 control_flags = 0, rb_size, cb_size;
dma_addr_t phys;
int ret;
@@ -202,11 +202,14 @@ int iwl_pcie_ctxt_info_init(struct iwl_trans *trans,
rb_size = IWL_CTXT_INFO_RB_SIZE_4K;
}
- WARN_ON(RX_QUEUE_CB_SIZE(iwl_trans_get_num_rbds(trans)) > 12);
+ cb_size = RX_QUEUE_CB_SIZE(iwl_trans_get_num_rbds(trans));
+ if (unlikely(cb_size > 12)) {
+ WARN_ON(1);
+ cb_size = 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);
+ control_flags |= u32_encode_bits(cb_size, 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.25.1
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] wifi: iwlwifi: cfg: Limit cb_size to valid range
2025-05-23 6:04 [PATCH] wifi: iwlwifi: cfg: Limit cb_size to valid range Pei Xiao
@ 2025-05-23 7:59 ` Johannes Berg
2025-05-27 8:05 ` Pei Xiao
2025-05-27 8:06 ` Pei Xiao
0 siblings, 2 replies; 4+ messages in thread
From: Johannes Berg @ 2025-05-23 7:59 UTC (permalink / raw)
To: Pei Xiao, miriam.rachel.korenblit, emmanuel.grumbach,
linux-wireless, linux-kernel
On Fri, 2025-05-23 at 14:04 +0800, Pei Xiao wrote:
>
>
> - WARN_ON(RX_QUEUE_CB_SIZE(iwl_trans_get_num_rbds(trans)) > 12);
> + cb_size = RX_QUEUE_CB_SIZE(iwl_trans_get_num_rbds(trans));
> + if (unlikely(cb_size > 12)) {
> + WARN_ON(1);
>
What's wrong with "if (WARN_ON(...))"?!?
Not that I think it even really needs to be there but I guess working
around a compiler warning could be worth it.
johannes
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] wifi: iwlwifi: cfg: Limit cb_size to valid range
2025-05-23 7:59 ` Johannes Berg
@ 2025-05-27 8:05 ` Pei Xiao
2025-05-27 8:06 ` Pei Xiao
1 sibling, 0 replies; 4+ messages in thread
From: Pei Xiao @ 2025-05-27 8:05 UTC (permalink / raw)
To: Johannes Berg, miriam.rachel.korenblit, emmanuel.grumbach,
linux-wireless, linux-kernel
在 2025/5/23 15:59, Johannes Berg 写道:
> On Fri, 2025-05-23 at 14:04 +0800, Pei Xiao wrote:
>>
>> - WARN_ON(RX_QUEUE_CB_SIZE(iwl_trans_get_num_rbds(trans)) > 12);
>> + cb_size = RX_QUEUE_CB_SIZE(iwl_trans_get_num_rbds(trans));
>> + if (unlikely(cb_size > 12)) {
>> + WARN_ON(1);
>>
> What's wrong with "if (WARN_ON(...))"?!?
ok,thanks!
> Not that I think it even really needs to be there but I guess working
> around a compiler warning could be worth it.
yes!
> johannes
Pei.
Thanks !
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] wifi: iwlwifi: cfg: Limit cb_size to valid range
2025-05-23 7:59 ` Johannes Berg
2025-05-27 8:05 ` Pei Xiao
@ 2025-05-27 8:06 ` Pei Xiao
1 sibling, 0 replies; 4+ messages in thread
From: Pei Xiao @ 2025-05-27 8:06 UTC (permalink / raw)
To: Johannes Berg, miriam.rachel.korenblit, emmanuel.grumbach,
linux-wireless, linux-kernel
在 2025/5/23 15:59, Johannes Berg 写道:
> On Fri, 2025-05-23 at 14:04 +0800, Pei Xiao wrote:
>>
>> - WARN_ON(RX_QUEUE_CB_SIZE(iwl_trans_get_num_rbds(trans)) > 12);
>> + cb_size = RX_QUEUE_CB_SIZE(iwl_trans_get_num_rbds(trans));
>> + if (unlikely(cb_size > 12)) {
>> + WARN_ON(1);
>>
> What's wrong with "if (WARN_ON(...))"?!?
thanks!
V2:
https://lore.kernel.org/lkml/7b373a4426070d50b5afb3269fd116c18ce3aea8.1748332709.git.xiaopei01@kylinos.cn/
> Not that I think it even really needs to be there but I guess working
> around a compiler warning could be worth it.
>
> johannes
Pei.Thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-05-27 8:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-23 6:04 [PATCH] wifi: iwlwifi: cfg: Limit cb_size to valid range Pei Xiao
2025-05-23 7:59 ` Johannes Berg
2025-05-27 8:05 ` Pei Xiao
2025-05-27 8:06 ` Pei Xiao
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®