* [PATCH v2] net: ethernet: sun: Remove redundant code
@ 2022-03-04 8:36 Jiapeng Chong
2022-03-04 13:10 ` patchwork-bot+netdevbpf
2022-03-04 13:32 ` Andrew Lunn
0 siblings, 2 replies; 3+ messages in thread
From: Jiapeng Chong @ 2022-03-04 8:36 UTC (permalink / raw)
To: davem; +Cc: kuba, gustavoars, netdev, linux-kernel, Jiapeng Chong,
Abaci Robot
Since the starting value in the for loop is greater than or equal to 1,
the restriction is CAS_FLAG_REG_PLUS is in the file cassini.h is
defined as 0x1 by macro, and the for loop and if condition is not
satisfied, so the code here is redundant.
Clean up the following smatch warning:
drivers/net/ethernet/sun/cassini.c:3513 cas_start_dma() warn: we never
enter this loop.
drivers/net/ethernet/sun/cassini.c:1239 cas_init_rx_dma() warn: we never
enter this loop.
drivers/net/ethernet/sun/cassini.c:1247 cas_init_rx_dma() warn: we never
enter this loop.
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
Changes in v2:
-Expand this comment.
drivers/net/ethernet/sun/cassini.c | 16 ----------------
1 file changed, 16 deletions(-)
diff --git a/drivers/net/ethernet/sun/cassini.c b/drivers/net/ethernet/sun/cassini.c
index 947a76a788c7..153edc5eadad 100644
--- a/drivers/net/ethernet/sun/cassini.c
+++ b/drivers/net/ethernet/sun/cassini.c
@@ -1235,19 +1235,6 @@ static void cas_init_rx_dma(struct cas *cp)
*/
readl(cp->regs + REG_INTR_STATUS_ALIAS);
writel(INTR_RX_DONE | INTR_RX_BUF_UNAVAIL, cp->regs + REG_ALIAS_CLEAR);
- if (cp->cas_flags & CAS_FLAG_REG_PLUS) {
- for (i = 1; i < N_RX_COMP_RINGS; i++)
- readl(cp->regs + REG_PLUS_INTRN_STATUS_ALIAS(i));
-
- /* 2 is different from 3 and 4 */
- if (N_RX_COMP_RINGS > 1)
- writel(INTR_RX_DONE_ALT | INTR_RX_BUF_UNAVAIL_1,
- cp->regs + REG_PLUS_ALIASN_CLEAR(1));
-
- for (i = 2; i < N_RX_COMP_RINGS; i++)
- writel(INTR_RX_DONE_ALT,
- cp->regs + REG_PLUS_ALIASN_CLEAR(i));
- }
/* set up pause thresholds */
val = CAS_BASE(RX_PAUSE_THRESH_OFF,
@@ -3509,9 +3496,6 @@ static inline void cas_start_dma(struct cas *cp)
if (N_RX_DESC_RINGS > 1)
writel(RX_DESC_RINGN_SIZE(1) - 4,
cp->regs + REG_PLUS_RX_KICK1);
-
- for (i = 1; i < N_RX_COMP_RINGS; i++)
- writel(0, cp->regs + REG_PLUS_RX_COMPN_TAIL(i));
}
}
--
2.20.1.7.g153144c
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] net: ethernet: sun: Remove redundant code
2022-03-04 8:36 [PATCH v2] net: ethernet: sun: Remove redundant code Jiapeng Chong
@ 2022-03-04 13:10 ` patchwork-bot+netdevbpf
2022-03-04 13:32 ` Andrew Lunn
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-03-04 13:10 UTC (permalink / raw)
To: Jiapeng Chong; +Cc: davem, kuba, gustavoars, netdev, linux-kernel, abaci
Hello:
This patch was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:
On Fri, 4 Mar 2022 16:36:53 +0800 you wrote:
> Since the starting value in the for loop is greater than or equal to 1,
> the restriction is CAS_FLAG_REG_PLUS is in the file cassini.h is
> defined as 0x1 by macro, and the for loop and if condition is not
> satisfied, so the code here is redundant.
>
> Clean up the following smatch warning:
>
> [...]
Here is the summary with links:
- [v2] net: ethernet: sun: Remove redundant code
https://git.kernel.org/netdev/net-next/c/1039135aedfc
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] net: ethernet: sun: Remove redundant code
2022-03-04 8:36 [PATCH v2] net: ethernet: sun: Remove redundant code Jiapeng Chong
2022-03-04 13:10 ` patchwork-bot+netdevbpf
@ 2022-03-04 13:32 ` Andrew Lunn
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2022-03-04 13:32 UTC (permalink / raw)
To: Jiapeng Chong, David Miller
Cc: davem, kuba, gustavoars, netdev, linux-kernel, Abaci Robot
On Fri, Mar 04, 2022 at 04:36:53PM +0800, Jiapeng Chong wrote:
> Since the starting value in the for loop is greater than or equal to 1,
> the restriction is CAS_FLAG_REG_PLUS is in the file cassini.h is
> defined as 0x1 by macro, and the for loop and if condition is not
> satisfied, so the code here is redundant.
This still does not make much sense. Too late, David has merged it.
Taking a deeper look, we see:
https://elixir.bootlin.com/linux/v5.17-rc6/source/drivers/net/ethernet/sun/cassini.h#L2542
#define N_RX_COMP_RINGS 0x1 /* for mult. PCI interrupts */
So what the bot is reporting:
> drivers/net/ethernet/sun/cassini.c:3513 cas_start_dma() warn: we never
> enter this loop.
>
> drivers/net/ethernet/sun/cassini.c:1239 cas_init_rx_dma() warn: we never
> enter this loop.
>
> drivers/net/ethernet/sun/cassini.c:1247 cas_init_rx_dma() warn: we never
> enter this loop.
>
> - if (cp->cas_flags & CAS_FLAG_REG_PLUS) {
> - for (i = 1; i < N_RX_COMP_RINGS; i++)
> - readl(cp->regs + REG_PLUS_INTRN_STATUS_ALIAS(i));
has nothing to do with CAS_FLAG_REG_PLUS, which you say in your commit
message. It has to do with N_RX_COMP_RINGS.
So you have 'fixed' a bots warning by removing code which cannot be
used. But is this the correct fix? Or has the bot actually found a
bug? Don't you think somebody wrote this code expecting it to be used?
Or do you think people write extra code which will never be used for
fun?
Looking at the git history, this code was actually written by DaveM.
Dave, this very old code, do you still remember this hardware? Bug or
dead code?
Andrew
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-03-04 13:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-04 8:36 [PATCH v2] net: ethernet: sun: Remove redundant code Jiapeng Chong
2022-03-04 13:10 ` patchwork-bot+netdevbpf
2022-03-04 13:32 ` Andrew Lunn
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.