diff mbox series

[v2] net: bcmgenet: Reset RBUF on first open

Message ID 20240401111002.3111783-1-maarten@rmail.be (mailing list archive)
State Accepted
Commit 0a6380cb4c6b5c1d6dad226ba3130f9090f0ccea
Delegated to: Netdev Maintainers
Headers show
Series [v2] net: bcmgenet: Reset RBUF on first open | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 943 this patch: 943
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 1 maintainers not CCed: edumazet@google.com
netdev/build_clang success Errors and warnings before: 954 this patch: 954
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 954 this patch: 954
netdev/checkpatch warning CHECK: usleep_range is preferred over udelay; see Documentation/timers/timers-howto.rst WARNING: Unknown link reference 'See:', use 'Link:' or 'Closes:' instead
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-04-01--18-00 (tests: 951)

Commit Message

Maarten April 1, 2024, 11:09 a.m. UTC
From: Phil Elwell <phil@raspberrypi.com>

If the RBUF logic is not reset when the kernel starts then there
may be some data left over from any network boot loader. If the
64-byte packet headers are enabled then this can be fatal.

Extend bcmgenet_dma_disable to do perform the reset, but not when
called from bcmgenet_resume in order to preserve a wake packet.

N.B. This different handling of resume is just based on a hunch -
why else wouldn't one reset the RBUF as well as the TBUF? If this
isn't the case then it's easy to change the patch to make the RBUF
reset unconditional.

See: https://github.com/raspberrypi/linux/issues/3850
See: https://github.com/raspberrypi/firmware/issues/1882

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
Signed-off-by: Maarten Vanraes <maarten@rmail.be>
---
V1 -> V2: fixes formatting issues + add link to firmware issue 

V1: https://lore.kernel.org/netdev/47ba4ef5a42fe7412d7e3432a0995464@rmail.be/T/

 drivers/net/ethernet/broadcom/genet/bcmgenet.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org April 3, 2024, 10:10 a.m. UTC | #1
Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:

On Mon,  1 Apr 2024 13:09:33 +0200 you wrote:
> From: Phil Elwell <phil@raspberrypi.com>
> 
> If the RBUF logic is not reset when the kernel starts then there
> may be some data left over from any network boot loader. If the
> 64-byte packet headers are enabled then this can be fatal.
> 
> Extend bcmgenet_dma_disable to do perform the reset, but not when
> called from bcmgenet_resume in order to preserve a wake packet.
> 
> [...]

Here is the summary with links:
  - [v2] net: bcmgenet: Reset RBUF on first open
    https://git.kernel.org/netdev/net/c/0a6380cb4c6b

You are awesome, thank you!
Florian Fainelli April 3, 2024, 12:58 p.m. UTC | #2
On 4/3/2024 3:10 AM, patchwork-bot+netdevbpf@kernel.org wrote:
> Hello:
> 
> This patch was applied to netdev/net.git (main)
> by David S. Miller <davem@davemloft.net>:
> 
> On Mon,  1 Apr 2024 13:09:33 +0200 you wrote:
>> From: Phil Elwell <phil@raspberrypi.com>
>>
>> If the RBUF logic is not reset when the kernel starts then there
>> may be some data left over from any network boot loader. If the
>> 64-byte packet headers are enabled then this can be fatal.
>>
>> Extend bcmgenet_dma_disable to do perform the reset, but not when
>> called from bcmgenet_resume in order to preserve a wake packet.
>>
>> [...]
> 
> Here is the summary with links:
>    - [v2] net: bcmgenet: Reset RBUF on first open
>      https://git.kernel.org/netdev/net/c/0a6380cb4c6b
> 
> You are awesome, thank you!

Good thing I had mentioned in v1 that we were busy with other things but 
that we would like to have tested that patch. I don't expect it to cause 
regressions, but I would have appreciated that there would be a mention 
or a github issue for the VPU firmware that indicated a fix was underway.
Maarten April 3, 2024, 1:27 p.m. UTC | #3
Florian Fainelli schreef op 2024-04-03 14:58:
> On 4/3/2024 3:10 AM, patchwork-bot+netdevbpf@kernel.org wrote:
>> Hello:
>> 
>> This patch was applied to netdev/net.git (main)
>> by David S. Miller <davem@davemloft.net>:
>> 
>> On Mon,  1 Apr 2024 13:09:33 +0200 you wrote:
>>> From: Phil Elwell <phil@raspberrypi.com>
>>> 
>>> If the RBUF logic is not reset when the kernel starts then there
>>> may be some data left over from any network boot loader. If the
>>> 64-byte packet headers are enabled then this can be fatal.
>>> 
>>> Extend bcmgenet_dma_disable to do perform the reset, but not when
>>> called from bcmgenet_resume in order to preserve a wake packet.
>>> 
>>> [...]
>> 
>> Here is the summary with links:
>>    - [v2] net: bcmgenet: Reset RBUF on first open
>>      https://git.kernel.org/netdev/net/c/0a6380cb4c6b
>> 
>> You are awesome, thank you!
> 
> Good thing I had mentioned in v1 that we were busy with other things
> but that we would like to have tested that patch. I don't expect it to
> cause regressions, but I would have appreciated that there would be a
> mention or a github issue for the VPU firmware that indicated a fix
> was underway.

Eh, yeah, I had already sent an email to "David S. Miller 
<davem@davemloft.net>" indicating my surprise that this was committed.

I had added in the v2 commit msg a link to the firmware issue I created 
at raspberrypi and also linked to the lore of the v1 patch.

Should I have been clearer in some way or form when I posted the v2, 
(which was to fix the minor formatting issues and also add the firmware 
issues link to it)?

Regards,

Maarten Vanraes
diff mbox series

Patch

diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index 2d7ae71287b1..855cbe349236 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -3282,7 +3282,7 @@  static void bcmgenet_get_hw_addr(struct bcmgenet_priv *priv,
 }
 
 /* Returns a reusable dma control register value */
-static u32 bcmgenet_dma_disable(struct bcmgenet_priv *priv)
+static u32 bcmgenet_dma_disable(struct bcmgenet_priv *priv, bool flush_rx)
 {
 	unsigned int i;
 	u32 reg;
@@ -3307,6 +3307,14 @@  static u32 bcmgenet_dma_disable(struct bcmgenet_priv *priv)
 	udelay(10);
 	bcmgenet_umac_writel(priv, 0, UMAC_TX_FLUSH);
 
+	if (flush_rx) {
+		reg = bcmgenet_rbuf_ctrl_get(priv);
+		bcmgenet_rbuf_ctrl_set(priv, reg | BIT(0));
+		udelay(10);
+		bcmgenet_rbuf_ctrl_set(priv, reg);
+		udelay(10);
+	}
+
 	return dma_ctrl;
 }
 
@@ -3370,8 +3378,8 @@  static int bcmgenet_open(struct net_device *dev)
 
 	bcmgenet_set_hw_addr(priv, dev->dev_addr);
 
-	/* Disable RX/TX DMA and flush TX queues */
-	dma_ctrl = bcmgenet_dma_disable(priv);
+	/* Disable RX/TX DMA and flush TX and RX queues */
+	dma_ctrl = bcmgenet_dma_disable(priv, true);
 
 	/* Reinitialize TDMA and RDMA and SW housekeeping */
 	ret = bcmgenet_init_dma(priv);
@@ -4237,7 +4245,7 @@  static int bcmgenet_resume(struct device *d)
 			bcmgenet_hfb_create_rxnfc_filter(priv, rule);
 
 	/* Disable RX/TX DMA and flush TX queues */
-	dma_ctrl = bcmgenet_dma_disable(priv);
+	dma_ctrl = bcmgenet_dma_disable(priv, false);
 
 	/* Reinitialize TDMA and RDMA and SW housekeeping */
 	ret = bcmgenet_init_dma(priv);