netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v2 0/3] Fix kernel test robot issue and type error in min_t
@ 2025-04-16 12:45 Justin Lai
  2025-04-16 12:45 ` [PATCH net v2 1/3] rtase: Fix the compile error reported by the kernel test robot Justin Lai
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Justin Lai @ 2025-04-16 12:45 UTC (permalink / raw)
  To: kuba
  Cc: davem, edumazet, pabeni, andrew+netdev, linux-kernel, netdev,
	horms, pkshih, larry.chiu, Justin Lai

This patch set mainly involves fixing the kernel test robot issue and
the type error in min_t.
Details are as follows:
1. Fix the compile error reported by the kernel test robot
2. Fix the compile warning reported by the kernel test robot
3. Fix a type error in min_t

v1 -> v2:
Nothing has changed, and it is simply being posted again because the
initial version was posted incompletely.

Justin Lai (3):
  rtase: Fix the compile error reported by the kernel test robot
  rtase: Fix the compile warning reported by the kernel test robot
  rtase: Fix a type error in min_t

 drivers/net/ethernet/realtek/rtase/rtase.h      | 2 +-
 drivers/net/ethernet/realtek/rtase/rtase_main.c | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

-- 
2.34.1


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

* [PATCH net v2 1/3] rtase: Fix the compile error reported by the kernel test robot
  2025-04-16 12:45 [PATCH net v2 0/3] Fix kernel test robot issue and type error in min_t Justin Lai
@ 2025-04-16 12:45 ` Justin Lai
  2025-04-16 14:16   ` Andrew Lunn
  2025-04-16 12:45 ` [PATCH net v2 2/3] rtase: Fix the compile warning " Justin Lai
  2025-04-16 12:45 ` [PATCH net v2 3/3] rtase: Fix a type error in min_t Justin Lai
  2 siblings, 1 reply; 9+ messages in thread
From: Justin Lai @ 2025-04-16 12:45 UTC (permalink / raw)
  To: kuba
  Cc: davem, edumazet, pabeni, andrew+netdev, linux-kernel, netdev,
	horms, pkshih, larry.chiu, Justin Lai, kernel test robot

Fix the following compile error reported by the kernel test
robot by modifying the condition used to detect overflow in
rtase_calc_time_mitigation.

In file included from include/linux/mdio.h:10:0,
                  from drivers/net/ethernet/realtek/rtase/rtase_main.c:58:
 In function 'u16_encode_bits',
     inlined from 'rtase_calc_time_mitigation.constprop' at drivers/net/
     ethernet/realtek/rtase/rtase_main.c:1915:13,
     inlined from 'rtase_init_software_variable.isra.41' at drivers/net/
     ethernet/realtek/rtase/rtase_main.c:1961:13,
     inlined from 'rtase_init_one' at drivers/net/ethernet/realtek/
     rtase/rtase_main.c:2111:2:
>> include/linux/bitfield.h:178:3: error: call to '__field_overflow'
      declared with attribute error: value doesn't fit into mask
    __field_overflow();     \
    ^~~~~~~~~~~~~~~~~~
 include/linux/bitfield.h:198:2: note: in expansion of macro
 '____MAKE_OP'
   ____MAKE_OP(u##size,u##size,,)
   ^~~~~~~~~~~
 include/linux/bitfield.h:200:1: note: in expansion of macro
 '__MAKE_OP'
  __MAKE_OP(16)
  ^~~~~~~~~

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202503182158.nkAlbJWX-lkp@intel.com/
Fixes: a36e9f5cfe9e ("rtase: Add support for a pci table in this module")
Signed-off-by: Justin Lai <justinlai0215@realtek.com>
---
 drivers/net/ethernet/realtek/rtase/rtase_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/realtek/rtase/rtase_main.c b/drivers/net/ethernet/realtek/rtase/rtase_main.c
index 2aacc1996796..55b8d3666153 100644
--- a/drivers/net/ethernet/realtek/rtase/rtase_main.c
+++ b/drivers/net/ethernet/realtek/rtase/rtase_main.c
@@ -1925,8 +1925,8 @@ static u16 rtase_calc_time_mitigation(u32 time_us)
 
 	time_us = min_t(int, time_us, RTASE_MITI_MAX_TIME);
 
-	msb = fls(time_us);
-	if (msb >= RTASE_MITI_COUNT_BIT_NUM) {
+	if (time_us > RTASE_MITI_TIME_COUNT_MASK) {
+		msb = fls(time_us);
 		time_unit = msb - RTASE_MITI_COUNT_BIT_NUM;
 		time_count = time_us >> (msb - RTASE_MITI_COUNT_BIT_NUM);
 	} else {
-- 
2.34.1


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

* [PATCH net v2 2/3] rtase: Fix the compile warning reported by the kernel test robot
  2025-04-16 12:45 [PATCH net v2 0/3] Fix kernel test robot issue and type error in min_t Justin Lai
  2025-04-16 12:45 ` [PATCH net v2 1/3] rtase: Fix the compile error reported by the kernel test robot Justin Lai
@ 2025-04-16 12:45 ` Justin Lai
  2025-04-16 12:45 ` [PATCH net v2 3/3] rtase: Fix a type error in min_t Justin Lai
  2 siblings, 0 replies; 9+ messages in thread
From: Justin Lai @ 2025-04-16 12:45 UTC (permalink / raw)
  To: kuba
  Cc: davem, edumazet, pabeni, andrew+netdev, linux-kernel, netdev,
	horms, pkshih, larry.chiu, Justin Lai, kernel test robot

Fix the following compile warning reported by the kernel test robot by
increasing the size of ivec->name.

drivers/net/ethernet/realtek/rtase/rtase_main.c: In function 'rtase_open':
>> drivers/net/ethernet/realtek/rtase/rtase_main.c:1117:52: warning:
'%i' directive output may be truncated writing between 1 and 10 bytes
into a region of size between 7 and 22 [-Wformat-truncation=]
     snprintf(ivec->name, sizeof(ivec->name), "%s_int%i",
                                                     ^~
 drivers/net/ethernet/realtek/rtase/rtase_main.c:1117:45: note:
 directive argument in the range [0, 2147483647]
     snprintf(ivec->name, sizeof(ivec->name), "%s_int%i",
                                              ^~~~~~~~~~
 drivers/net/ethernet/realtek/rtase/rtase_main.c:1117:4: note:
 'snprintf' output between 6 and 30 bytes into a destination of
 size 26
     snprintf(ivec->name, sizeof(ivec->name), "%s_int%i",
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       tp->dev->name, i);
       ~~~~~~~~~~~~~~~~~

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202503182158.nkAlbJWX-lkp@intel.com/
Fixes: a36e9f5cfe9e ("rtase: Add support for a pci table in this module")
Signed-off-by: Justin Lai <justinlai0215@realtek.com>
---
 drivers/net/ethernet/realtek/rtase/rtase.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/realtek/rtase/rtase.h b/drivers/net/ethernet/realtek/rtase/rtase.h
index 2bbfcad613ab..1e63b5826da1 100644
--- a/drivers/net/ethernet/realtek/rtase/rtase.h
+++ b/drivers/net/ethernet/realtek/rtase/rtase.h
@@ -259,7 +259,7 @@ union rtase_rx_desc {
 #define RTASE_VLAN_TAG_MASK     GENMASK(15, 0)
 #define RTASE_RX_PKT_SIZE_MASK  GENMASK(13, 0)
 
-#define RTASE_IVEC_NAME_SIZE (IFNAMSIZ + 10)
+#define RTASE_IVEC_NAME_SIZE (IFNAMSIZ + 14)
 
 struct rtase_int_vector {
 	struct rtase_private *tp;
-- 
2.34.1


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

* [PATCH net v2 3/3] rtase: Fix a type error in min_t
  2025-04-16 12:45 [PATCH net v2 0/3] Fix kernel test robot issue and type error in min_t Justin Lai
  2025-04-16 12:45 ` [PATCH net v2 1/3] rtase: Fix the compile error reported by the kernel test robot Justin Lai
  2025-04-16 12:45 ` [PATCH net v2 2/3] rtase: Fix the compile warning " Justin Lai
@ 2025-04-16 12:45 ` Justin Lai
  2025-04-16 14:17   ` Andrew Lunn
  2025-04-27 10:46   ` David Laight
  2 siblings, 2 replies; 9+ messages in thread
From: Justin Lai @ 2025-04-16 12:45 UTC (permalink / raw)
  To: kuba
  Cc: davem, edumazet, pabeni, andrew+netdev, linux-kernel, netdev,
	horms, pkshih, larry.chiu, Justin Lai

Fix a type error in min_t.

Fixes: a36e9f5cfe9e ("rtase: Add support for a pci table in this module")
Signed-off-by: Justin Lai <justinlai0215@realtek.com>
---
 drivers/net/ethernet/realtek/rtase/rtase_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/realtek/rtase/rtase_main.c b/drivers/net/ethernet/realtek/rtase/rtase_main.c
index 55b8d3666153..bc856fb3d6f3 100644
--- a/drivers/net/ethernet/realtek/rtase/rtase_main.c
+++ b/drivers/net/ethernet/realtek/rtase/rtase_main.c
@@ -1923,7 +1923,7 @@ static u16 rtase_calc_time_mitigation(u32 time_us)
 	u8 msb, time_count, time_unit;
 	u16 int_miti;
 
-	time_us = min_t(int, time_us, RTASE_MITI_MAX_TIME);
+	time_us = min_t(u32, time_us, RTASE_MITI_MAX_TIME);
 
 	if (time_us > RTASE_MITI_TIME_COUNT_MASK) {
 		msb = fls(time_us);
@@ -1945,7 +1945,7 @@ static u16 rtase_calc_packet_num_mitigation(u16 pkt_num)
 	u8 msb, pkt_num_count, pkt_num_unit;
 	u16 int_miti;
 
-	pkt_num = min_t(int, pkt_num, RTASE_MITI_MAX_PKT_NUM);
+	pkt_num = min_t(u16, pkt_num, RTASE_MITI_MAX_PKT_NUM);
 
 	if (pkt_num > 60) {
 		pkt_num_unit = RTASE_MITI_MAX_PKT_NUM_IDX;
-- 
2.34.1


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

* Re: [PATCH net v2 1/3] rtase: Fix the compile error reported by the kernel test robot
  2025-04-16 12:45 ` [PATCH net v2 1/3] rtase: Fix the compile error reported by the kernel test robot Justin Lai
@ 2025-04-16 14:16   ` Andrew Lunn
  2025-04-17  5:46     ` Justin Lai
  0 siblings, 1 reply; 9+ messages in thread
From: Andrew Lunn @ 2025-04-16 14:16 UTC (permalink / raw)
  To: Justin Lai
  Cc: kuba, davem, edumazet, pabeni, andrew+netdev, linux-kernel,
	netdev, horms, pkshih, larry.chiu, kernel test robot

On Wed, Apr 16, 2025 at 08:45:32PM +0800, Justin Lai wrote:
> Fix the following compile error reported by the kernel test
> robot by modifying the condition used to detect overflow in
> rtase_calc_time_mitigation.

The Subject: line is not very useful. It is better to talk about what
you are fixing, not that a robot reported an issue.

    Andrew

---
pw-bot: cr

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

* Re: [PATCH net v2 3/3] rtase: Fix a type error in min_t
  2025-04-16 12:45 ` [PATCH net v2 3/3] rtase: Fix a type error in min_t Justin Lai
@ 2025-04-16 14:17   ` Andrew Lunn
  2025-04-27 10:46   ` David Laight
  1 sibling, 0 replies; 9+ messages in thread
From: Andrew Lunn @ 2025-04-16 14:17 UTC (permalink / raw)
  To: Justin Lai
  Cc: kuba, davem, edumazet, pabeni, andrew+netdev, linux-kernel,
	netdev, horms, pkshih, larry.chiu

On Wed, Apr 16, 2025 at 08:45:34PM +0800, Justin Lai wrote:
> Fix a type error in min_t.
> 
> Fixes: a36e9f5cfe9e ("rtase: Add support for a pci table in this module")
> Signed-off-by: Justin Lai <justinlai0215@realtek.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* RE: [PATCH net v2 1/3] rtase: Fix the compile error reported by the kernel test robot
  2025-04-16 14:16   ` Andrew Lunn
@ 2025-04-17  5:46     ` Justin Lai
  0 siblings, 0 replies; 9+ messages in thread
From: Justin Lai @ 2025-04-17  5:46 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: kuba@kernel.org, davem@davemloft.net, edumazet@google.com,
	pabeni@redhat.com, andrew+netdev@lunn.ch,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	horms@kernel.org, Ping-Ke Shih, Larry Chiu, kernel test robot

> 
> On Wed, Apr 16, 2025 at 08:45:32PM +0800, Justin Lai wrote:
> > Fix the following compile error reported by the kernel test robot by
> > modifying the condition used to detect overflow in
> > rtase_calc_time_mitigation.
> 
> The Subject: line is not very useful. It is better to talk about what you are fixing,
> not that a robot reported an issue.
> 
>     Andrew
> 
> ---
> pw-bot: cr

Hi Andrew,

Thank you for your response. I will modify the subject and post a new
version.

Thanks,
Justin

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

* Re: [PATCH net v2 3/3] rtase: Fix a type error in min_t
  2025-04-16 12:45 ` [PATCH net v2 3/3] rtase: Fix a type error in min_t Justin Lai
  2025-04-16 14:17   ` Andrew Lunn
@ 2025-04-27 10:46   ` David Laight
  2025-04-29  8:39     ` Justin Lai
  1 sibling, 1 reply; 9+ messages in thread
From: David Laight @ 2025-04-27 10:46 UTC (permalink / raw)
  To: Justin Lai
  Cc: kuba, davem, edumazet, pabeni, andrew+netdev, linux-kernel,
	netdev, horms, pkshih, larry.chiu

On Wed, 16 Apr 2025 20:45:34 +0800
Justin Lai <justinlai0215@realtek.com> wrote:

> Fix a type error in min_t.

NAK, in particular u16 is likely to be buggy
Consider what would happen if RTBASE_MITI_MAX_PKT_NUM was 65536.
(Yes, I know that isn't the intent of the code...)

As pointed out earlier using min() shouldn't generate a compile warning
and won't mask off significant bits.

Also I think it isn't a bug in any sense because the two functions
have a single caller that passes a constant.

	David


> 
> Fixes: a36e9f5cfe9e ("rtase: Add support for a pci table in this module")
> Signed-off-by: Justin Lai <justinlai0215@realtek.com>
> ---
>  drivers/net/ethernet/realtek/rtase/rtase_main.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/realtek/rtase/rtase_main.c b/drivers/net/ethernet/realtek/rtase/rtase_main.c
> index 55b8d3666153..bc856fb3d6f3 100644
> --- a/drivers/net/ethernet/realtek/rtase/rtase_main.c
> +++ b/drivers/net/ethernet/realtek/rtase/rtase_main.c
> @@ -1923,7 +1923,7 @@ static u16 rtase_calc_time_mitigation(u32 time_us)
>  	u8 msb, time_count, time_unit;
>  	u16 int_miti;
>  
> -	time_us = min_t(int, time_us, RTASE_MITI_MAX_TIME);
> +	time_us = min_t(u32, time_us, RTASE_MITI_MAX_TIME);
>  
>  	if (time_us > RTASE_MITI_TIME_COUNT_MASK) {
>  		msb = fls(time_us);
> @@ -1945,7 +1945,7 @@ static u16 rtase_calc_packet_num_mitigation(u16 pkt_num)
>  	u8 msb, pkt_num_count, pkt_num_unit;
>  	u16 int_miti;
>  
> -	pkt_num = min_t(int, pkt_num, RTASE_MITI_MAX_PKT_NUM);
> +	pkt_num = min_t(u16, pkt_num, RTASE_MITI_MAX_PKT_NUM);
>  
>  	if (pkt_num > 60) {
>  		pkt_num_unit = RTASE_MITI_MAX_PKT_NUM_IDX;


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

* RE: [PATCH net v2 3/3] rtase: Fix a type error in min_t
  2025-04-27 10:46   ` David Laight
@ 2025-04-29  8:39     ` Justin Lai
  0 siblings, 0 replies; 9+ messages in thread
From: Justin Lai @ 2025-04-29  8:39 UTC (permalink / raw)
  To: David Laight
  Cc: kuba@kernel.org, davem@davemloft.net, edumazet@google.com,
	pabeni@redhat.com, andrew+netdev@lunn.ch,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	horms@kernel.org, Ping-Ke Shih, Larry Chiu

> On Wed, 16 Apr 2025 20:45:34 +0800
> Justin Lai <justinlai0215@realtek.com> wrote:
> 
> > Fix a type error in min_t.
> 
> NAK, in particular u16 is likely to be buggy Consider what would happen if
> RTBASE_MITI_MAX_PKT_NUM was 65536.
> (Yes, I know that isn't the intent of the code...)
> 
> As pointed out earlier using min() shouldn't generate a compile warning and
> won't mask off significant bits.
> 
> Also I think it isn't a bug in any sense because the two functions have a single
> caller that passes a constant.
> 
>         David

Hi David,

This is indeed not a bug fix, and I have modified it to use min instead
of min_t, and posted it to net-next.

Thanks,
Justin

> 
> 
> >
> > Fixes: a36e9f5cfe9e ("rtase: Add support for a pci table in this
> > module")
> > Signed-off-by: Justin Lai <justinlai0215@realtek.com>
> > ---
> >  drivers/net/ethernet/realtek/rtase/rtase_main.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/realtek/rtase/rtase_main.c
> > b/drivers/net/ethernet/realtek/rtase/rtase_main.c
> > index 55b8d3666153..bc856fb3d6f3 100644
> > --- a/drivers/net/ethernet/realtek/rtase/rtase_main.c
> > +++ b/drivers/net/ethernet/realtek/rtase/rtase_main.c
> > @@ -1923,7 +1923,7 @@ static u16 rtase_calc_time_mitigation(u32
> time_us)
> >       u8 msb, time_count, time_unit;
> >       u16 int_miti;
> >
> > -     time_us = min_t(int, time_us, RTASE_MITI_MAX_TIME);
> > +     time_us = min_t(u32, time_us, RTASE_MITI_MAX_TIME);
> >
> >       if (time_us > RTASE_MITI_TIME_COUNT_MASK) {
> >               msb = fls(time_us);
> > @@ -1945,7 +1945,7 @@ static u16 rtase_calc_packet_num_mitigation(u16
> pkt_num)
> >       u8 msb, pkt_num_count, pkt_num_unit;
> >       u16 int_miti;
> >
> > -     pkt_num = min_t(int, pkt_num, RTASE_MITI_MAX_PKT_NUM);
> > +     pkt_num = min_t(u16, pkt_num, RTASE_MITI_MAX_PKT_NUM);
> >
> >       if (pkt_num > 60) {
> >               pkt_num_unit = RTASE_MITI_MAX_PKT_NUM_IDX;


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

end of thread, other threads:[~2025-04-29  8:40 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-16 12:45 [PATCH net v2 0/3] Fix kernel test robot issue and type error in min_t Justin Lai
2025-04-16 12:45 ` [PATCH net v2 1/3] rtase: Fix the compile error reported by the kernel test robot Justin Lai
2025-04-16 14:16   ` Andrew Lunn
2025-04-17  5:46     ` Justin Lai
2025-04-16 12:45 ` [PATCH net v2 2/3] rtase: Fix the compile warning " Justin Lai
2025-04-16 12:45 ` [PATCH net v2 3/3] rtase: Fix a type error in min_t Justin Lai
2025-04-16 14:17   ` Andrew Lunn
2025-04-27 10:46   ` David Laight
2025-04-29  8:39     ` Justin Lai

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).