Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3660708pxb; Mon, 24 Jan 2022 14:43:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJxDxsYzg0Efd1G21rv72cT3UALSNv8aBPu71qJB4TFNXtqwgnVxmx81X8pufhrs7bGUGQ4Z X-Received: by 2002:a17:902:d2cb:b0:14b:6611:4c6b with SMTP id n11-20020a170902d2cb00b0014b66114c6bmr2983643plc.7.1643064187621; Mon, 24 Jan 2022 14:43:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643064187; cv=none; d=google.com; s=arc-20160816; b=wGEz8J4fD29zJm1FoIFpPJYT6nCNMbcYM4CKq12iPeqNCRDrhN0wSAbdjPhOL28ORl Qu3Cuv7EMXcZyOeZHlR21cS0qQAkUf9T+sXFcIU+qRqTUXpbfDBR5xxPxaMKowyrRIhk WHxvZfd3lcwAyWq8bgg+mb+UcLS0fheB9S7at2VCwXgU3X2drdqD8Ru3E29ELk+CH9Ic 1c4rmzuj8t2W62Z8l7+BIl6j40sNGR/IWpRTmUOusbbNvnvK4WnL36TWUM+50qTWS2l3 Joqbd4SKSBz/EfIRmAoHH6SRJmmVbqYVjddZJMhZMoTeWjKijJvoAn7/YCND1+GLdcTC 8RnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=390gSdq0cyPh+ata8dPE6H4Lcf9azr2Z77PzLrrFVWY=; b=KXld9qPyXhO7Ojh/0qaSLO8eqgbAbgBozCCAYOl8BYUHr3sGU8X5RMw3hi6ZMlQWPr 6wmkSYljXeBcLvzN4t4NIuyvCgoI3suiD8RMWm0M/7NzMI/33pPGKDpsZepiLKER2dHU igZr+FgQgUdpUUU7f5DM5Uy7C6XKFBK0FCcxSIb3Fl32y5brgy2QLqF73W+p+BcsGI96 W+CPkK3byg1M/F/14WUzoNUOBvdz0xuQUs9jfhNANF1qjAfoOXnQCG8UqujNoYxqChFo 39oyU8BV5GbS5ED00PJffgiJ3Kdq0Njs7ZbP8s8MFE5WO4n1elHwfXtOHDq6TbjFaeQm uDfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ql+Go9qq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ml7si530350pjb.127.2022.01.24.14.42.56; Mon, 24 Jan 2022 14:43:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ql+Go9qq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1836902AbiAXWlQ (ORCPT + 99 others); Mon, 24 Jan 2022 17:41:16 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:59902 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1457543AbiAXVlt (ORCPT ); Mon, 24 Jan 2022 16:41:49 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 135F761521; Mon, 24 Jan 2022 21:41:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28FE8C340E4; Mon, 24 Jan 2022 21:41:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643060508; bh=DKaIZ44jXhAHBBxgsqnKrT5Vc0etjfMDYpjpcuu0RIM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ql+Go9qqWBq3vYFCFyXv76g828PV4MfEnkDRF/d40rXvgyEQk+YLUw773IL3PtaxP wTS1jTmQp24Zg3QsNln2zjyVk2imGvkzgGq/30w4p0ltFDe3LtBh7FUbV2Ui+EH5+O WAdL/JD852UzPybkVxomo62TZG+n+AG7rjPOxHtE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Robert Hancock , "David S. Miller" Subject: [PATCH 5.16 0970/1039] net: axienet: add missing memory barriers Date: Mon, 24 Jan 2022 19:45:59 +0100 Message-Id: <20220124184157.899224815@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Robert Hancock commit 95978df6fa328df619c15312e65ece469c2be2d2 upstream. This driver was missing some required memory barriers: Use dma_rmb to ensure we see all updates to the descriptor after we see that an entry has been completed. Use wmb and rmb to avoid stale descriptor status between the TX path and TX complete IRQ path. Fixes: 8a3b7a252dca9 ("drivers/net/ethernet/xilinx: added Xilinx AXI Ethernet driver") Signed-off-by: Robert Hancock Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c @@ -632,6 +632,8 @@ static int axienet_free_tx_chain(struct if (nr_bds == -1 && !(status & XAXIDMA_BD_STS_COMPLETE_MASK)) break; + /* Ensure we see complete descriptor update */ + dma_rmb(); phys = desc_get_phys_addr(lp, cur_p); dma_unmap_single(ndev->dev.parent, phys, (cur_p->cntrl & XAXIDMA_BD_CTRL_LENGTH_MASK), @@ -645,8 +647,10 @@ static int axienet_free_tx_chain(struct cur_p->app1 = 0; cur_p->app2 = 0; cur_p->app4 = 0; - cur_p->status = 0; cur_p->skb = NULL; + /* ensure our transmit path and device don't prematurely see status cleared */ + wmb(); + cur_p->status = 0; if (sizep) *sizep += status & XAXIDMA_BD_STS_ACTUAL_LEN_MASK; @@ -704,6 +708,9 @@ static inline int axienet_check_tx_bd_sp int num_frag) { struct axidma_bd *cur_p; + + /* Ensure we see all descriptor updates from device or TX IRQ path */ + rmb(); cur_p = &lp->tx_bd_v[(lp->tx_bd_tail + num_frag) % lp->tx_bd_num]; if (cur_p->status & XAXIDMA_BD_STS_ALL_MASK) return NETDEV_TX_BUSY; @@ -843,6 +850,8 @@ static void axienet_recv(struct net_devi tail_p = lp->rx_bd_p + sizeof(*lp->rx_bd_v) * lp->rx_bd_ci; + /* Ensure we see complete descriptor update */ + dma_rmb(); phys = desc_get_phys_addr(lp, cur_p); dma_unmap_single(ndev->dev.parent, phys, lp->max_frm_size, DMA_FROM_DEVICE);