From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C7AE9137929; Mon, 15 Apr 2024 12:51:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713185478; cv=none; b=bc2jNzeD1dABg2PSA3YUsxacjGOL+Gi5G2B+ADi2Epi+xyQ+rMi8FWmVGj9EGTk5JHu/UVBy8vYJaqkrK2z2b5gl24TSU3jKe+iRJ00AGUMUuuyxub4NOVSix2NLLP/xgw9nsrQKSl9cFV++y2gIcFIO3KtyZ1+Ifkxt2vSr6GM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713185478; c=relaxed/simple; bh=Oo0HmZn4HcaG5HvHayGYvJg3XC6Ow+32gUDsEVSw9QE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dehc2NovPgFiBuP4E6nt9fMbAHQiyp3XHHtYDka+EpVVs3CtBjtvnlYpAQy/MHD/jcs8wOKhpphCcv2gW0s3kQViUhWdiThTFE5CaenolhZIJRtZ/juzxJJ0WUO/IM3phmfh+trgtKdDpxI8OI+4/2/dBF2cMzo8hWUkL5MnG2E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=N4Oug5pS; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="N4Oug5pS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C7067C4AF09; Mon, 15 Apr 2024 12:51:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713185478; bh=Oo0HmZn4HcaG5HvHayGYvJg3XC6Ow+32gUDsEVSw9QE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N4Oug5pSAtOYW5P5kZ7l7rob+nzCEwQrMJLWOhS4Y/cgaRi95Fr/gWY624jCTs1Wc RtLHw9oK4uUO3BsLJBELVmb1sqTUHpyUlIBaHmHOUM6aYL9PRZQZFrlKtSxgFhy9d0 PMZLZuv6+2SHEQzS2iQsKJgiBsOPQVVNw8lWKTJSaJWgBta21zPxd2WqN3bCQArbMj Agz1MpPLB/1ze+Oirz+67iGzqZLq5p8cNndOgPYr7M1VAtLsEkUb0HwY36kCee/MMW FwfjTN9+Cgz2uaPnw/nLBLn02O7SC8xPbkiaulAf7I+fulh42NdCfu5t5BOmaXNZZ/ FQs85XvZeoJGg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Phil Elwell , Maarten Vanraes , "David S . Miller" , Sasha Levin , opendmb@gmail.com, florian.fainelli@broadcom.com, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 2/4] net: bcmgenet: Reset RBUF on first open Date: Mon, 15 Apr 2024 06:05:15 -0400 Message-ID: <20240415100520.3127870-2-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240415100520.3127870-1-sashal@kernel.org> References: <20240415100520.3127870-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 4.19.312 Content-Transfer-Encoding: 8bit From: Phil Elwell [ Upstream commit 0a6380cb4c6b5c1d6dad226ba3130f9090f0ccea ] 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 Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- 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 8bbc5dcf8cb43..9fded8a862d46 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c @@ -2806,7 +2806,7 @@ static void bcmgenet_set_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; @@ -2831,6 +2831,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; } @@ -2926,8 +2934,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); @@ -3682,7 +3690,7 @@ static int bcmgenet_resume(struct device *d) bcmgenet_power_up(priv, GENET_POWER_WOL_MAGIC); /* 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); -- 2.43.0