From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796386384; b=4F4asfxR5onJCZDxuYe5vKF5JeaJ3kcm30p7HRF62neRhV7hayprKb8B3B1U1PbY3kF+ ZP9z2Z+sMMV5SoN7zixyE75ZUI9z+DAuMcTmXH7AZ5PZfJwceEI0qC3BX1ETje42jdZYy hSovafTpSOiW7ZrBg4g7dGXCfOIzF1jQk3ezBYe5HmwlIM/ACInABJ8VPd0mLaiqHpkDA M0iqRxE9Ag0DuZct2Mc/jNpgXDmmOHWa5XTI03aBRFR29FbvSszeTPbdY/WEKyxqkB0ww qR5GQkbSUGGoj7iUNboOueaBbPRrF4qvs4foA1ljLZY5c53nnQHY9C00rqY1V9Q2n5Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796386384; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=4Ljw73fdTuAsqlBwZX56QzgJ56ZHT5gjhNiJnNDhv+w=; b=x51/YrS1fnqg1btMO99sf6Uf3/Pz3UhD3y1lsm7RIN9R0I0mYcQjyf4kGxJKaMiu4emu 0wRIaB5w8q/5qP+mvp4zKQkcIz50tRLVJddJpNyYU3EQr6Jb7SS8wsjuKuQtyjKyyMasY 5jSQ4s1e2XdzUkh5aVDU48M2o2ZMwwrgcOmVk5pMylpljmIFFeXlqfNagwOwNJcDseoJi iCnHXfy0H3N1ifKd34JvmxPOCivtJPytPzR/keyq9uZZ9ZLFwxvDTCVf5q+tHREWpTICD uY5MfjyocZSfzpF6/MrtHXJztdFX8znNm7NOhemqQ6WbpsLo61Yy++zfAf4v3ceenNg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=oYMdSbLp; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D1185606A322; Fri, 4 Dec 2026 12:13:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=oYMdSbLp Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3AADD1F00897; Fri, 4 Dec 2026 12:13:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796386384; bh=4Ljw73fdTuAsqlBwZX56QzgJ56ZHT5gjhNiJnNDhv+w=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=oYMdSbLp7QrbR3OgxAU2o5wBRDah0GsftLBg2IX8uqH+WnXbuh0XLk4c+SC8qFvk9 liNOxs3ABx2gDyKr5skJvNRDcWnLSNrGbN0B0X1LLtZaZzd7wwdF6rZcfI43vUD43Z 40K9fwC4jKgF+bifvV4iBaDTvutauwOko3SXBgKs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Florian Fainelli , Kordian Chmielewski , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.6 0899/1167] net: bcm4908_enet: publish the buffer address before OWN Date: Fri, 4 Dec 2026 19:05:26 +0900 Message-ID: <20261204100725.622348649@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kordian Chmielewski [ Upstream commit 4d47e6c2f3ceb638d4ea5c21e304b20f526255bd ] bcm4908_enet_dma_alloc_rx_buf() hands a descriptor to the DMA by writing its control word, with DMA_CTL_STATUS_OWN, first and the new buffer address second. If the DMA read the descriptor between the two stores, it would write the next frame into the old buffer, which poll_rx() is turning into an skb. start_xmit() writes the address first, but nothing orders the two stores, and the descriptors live in coherent memory, where arm64 may make them visible in either order. Write the address first on both paths and order it before the control word with dma_wmb(). In poll_rx(), read what the DMA wrote only after seeing OWN clear (dma_rmb()), as Documentation/memory-barriers.txt describes for descriptors shared with a device. Found by reading the code; I have no test that shows the DMA reading a descriptor while it is being refilled. Fixes: 4feffeadbcb2 ("net: broadcom: bcm4908enet: add BCM4908 controller driver") Reviewed-by: Florian Fainelli Signed-off-by: Kordian Chmielewski Link: https://patch.msgid.link/20261113235847.517308-7-kudzo51@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/ethernet/broadcom/bcm4908_enet.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bcm4908_enet.c b/drivers/net/ethernet/broadcom/bcm4908_enet.c index 9dc944f6d69d1..e419de9e1b958 100644 --- a/drivers/net/ethernet/broadcom/bcm4908_enet.c +++ b/drivers/net/ethernet/broadcom/bcm4908_enet.c @@ -291,8 +291,10 @@ static int bcm4908_enet_dma_alloc_rx_buf(struct bcm4908_enet *enet, unsigned int tmp |= DMA_CTL_STATUS_OWN; if (idx == enet->rx_ring.length - 1) tmp |= DMA_CTL_STATUS_WRAP; - buf_desc->ctl = cpu_to_le32(tmp); buf_desc->addr = cpu_to_le32(slot->dma_addr); + /* Hand the descriptor to the DMA only once it holds the new buffer */ + dma_wmb(); + buf_desc->ctl = cpu_to_le32(tmp); return 0; } @@ -613,6 +615,8 @@ static netdev_tx_t bcm4908_enet_start_xmit(struct sk_buff *skb, struct net_devic netdev_sent_queue(enet->netdev, skb->len); buf_desc->addr = cpu_to_le32((uint32_t)slot->dma_addr); + /* The DMA must not see OWN before the buffer address */ + dma_wmb(); buf_desc->ctl = cpu_to_le32(tmp); bcm4908_enet_dma_tx_ring_enable(enet, &enet->tx_ring); @@ -647,6 +651,8 @@ static int bcm4908_enet_poll_rx(struct napi_struct *napi, int weight) ctl = le32_to_cpu(buf_desc->ctl); if (ctl & DMA_CTL_STATUS_OWN) break; + /* Read the rest only after the DMA gave the descriptor back */ + dma_rmb(); slot = enet->rx_ring.slots[enet->rx_ring.read_idx]; -- 2.53.0