From patchwork Mon Apr 1 11:09:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maarten X-Patchwork-Id: 13612711 X-Patchwork-Delegate: kuba@kernel.org Received: from mail.rmail.be (mail.rmail.be [85.234.218.189]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 52F1721105 for ; Mon, 1 Apr 2024 11:10:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=85.234.218.189 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711969844; cv=none; b=kv0p61S5kjTQ0ezAicDaNB2VnpJ7HrbU0cziN9bOP5U7+8bcwm+YSu7MwCXJGHx0xePTtCA5B41Ac79bMhVur/CMMcpaK2dFPK85I/4pVJbNT1gGQOU5K9ETfZSYf2fuYMUGp4uVysc2bVYerAwdEXAuvxhVCuZ2oj0C3xTyc38= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711969844; c=relaxed/simple; bh=d0P33geLx0XFyRkKAItFJeT8MrMEhD9QHvh4CNvcFYU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=n7WDyAHzkn6B2kyLOhQ1twEMJdCojWLBD/wdpe/paLakInHWypqz3K2wMGjFjwM2i6flWFPH8uT/CDugTlSgkpkklsPTxwGUtdZaNiTI/sIzyHs6ig55rZVROYVsNEwZGSB6n6DTdhVePHg4Bv9HcXD3uBGAd7jU+ukd9CPRd3M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rmail.be; spf=pass smtp.mailfrom=rmail.be; arc=none smtp.client-ip=85.234.218.189 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rmail.be Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rmail.be Received: from localhost.rmail.be (unknown [10.238.9.208]) by mail.rmail.be (Postfix) with ESMTP id 3DC8D4FF40; Mon, 1 Apr 2024 13:10:38 +0200 (CEST) From: Maarten Vanraes To: Doug Berger , Florian Fainelli , netdev@vger.kernel.org, Phil Elwell , Broadcom internal kernel review list , Jakub Kicinski Cc: Paolo Abeni , Maarten Vanraes Subject: [PATCH v2] net: bcmgenet: Reset RBUF on first open Date: Mon, 1 Apr 2024 13:09:33 +0200 Message-ID: <20240401111002.3111783-1-maarten@rmail.be> X-Mailer: git-send-email 2.41.0 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Phil Elwell 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 Signed-off-by: Maarten Vanraes --- 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(-) 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);