Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp3083791pxu; Mon, 19 Oct 2020 03:36:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxc3jxInaTgAhK50Gm+xxibcltlKdBEaoBiqU6ZFfWxoIfeqrWrNmp50l/vIPyYI8IA/qD2 X-Received: by 2002:a50:8e5a:: with SMTP id 26mr17852971edx.161.1603103782864; Mon, 19 Oct 2020 03:36:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603103782; cv=none; d=google.com; s=arc-20160816; b=esesRcpf2FbYDI6CTCiyNjFmeCr7vQ5xmaZ4zgwqjb+w8fLLOg4PcAdfyuhR3+e/J2 zHyqdXDL+B1vXMYSlPYtIwWyT0tHggI55JMB9yzFBq5TcvkPAY27GusREggfzA8uRhAp vZ1d/gGlyxVNFm2V9ielVBoPdy3WEt/qjvBGACurACn1cFNB2+8U2KNn433Z3XUAOKEv c6mun3zxbMjvV/x9PTKYqDj4lspdUQa0/fstyu+NwB3JOZHdme7xdracJcQOzcqekUrK Z8ycxN2UuHwK8sB0Oy1Ovre0vN0zJzGcQ7F1No5QVsdrW0jbKKPZtvRWQWyYuOxpEYPQ HkCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=VKjowH02GQwzKsit2YlV/7K1l9HmQx+TiV/GrvmyYro=; b=vaRfD7OZKt30JbWbJg8LMdnMIoorrpGcX4gHtPjSgEIcXOm4l5Drb12DVcSSiJTI12 kNHlvLS1W96i8Hkls2HpVudPlq23Wc0ZHh8Sr33gHnIrldBJbSkVL783pYKmvg+L1oPp XrKWlAa4DQqOK4eS7ZNzUoeoiCcLewd8ULNY4HzQqH6fBkoz7Z/GJxy7YE0OIjfWk6hq q70gkOjEpsJ37CsgQh1hl1u/JAxbZlYBY8Gc4N9tAIT9dDXqaWpIhjVXQDjDatCv/jd4 tKauZhZ+oTJLYis0pJPqTFYEPP5FzdmglIbeA1cPJiJyHsTi6Xme62ULAZwY2uvJT/1I l/Nw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r7si7271266edy.440.2020.10.19.03.36.00; Mon, 19 Oct 2020 03:36:22 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729765AbgJSI5f (ORCPT + 99 others); Mon, 19 Oct 2020 04:57:35 -0400 Received: from twspam01.aspeedtech.com ([211.20.114.71]:65313 "EHLO twspam01.aspeedtech.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729415AbgJSI5f (ORCPT ); Mon, 19 Oct 2020 04:57:35 -0400 Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 09J8so81046772; Mon, 19 Oct 2020 16:54:50 +0800 (GMT-8) (envelope-from dylan_hung@aspeedtech.com) Received: from localhost.localdomain (192.168.10.9) by TWMBX02.aspeed.com (192.168.0.24) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 19 Oct 2020 16:57:27 +0800 From: Dylan Hung To: , , , , , , CC: , Joel Stanley Subject: [PATCH 1/4] ftgmac100: Fix race issue on TX descriptor[0] Date: Mon, 19 Oct 2020 16:57:14 +0800 Message-ID: <20201019085717.32413-2-dylan_hung@aspeedtech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201019085717.32413-1-dylan_hung@aspeedtech.com> References: <20201019085717.32413-1-dylan_hung@aspeedtech.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [192.168.10.9] X-ClientProxiedBy: TWMBX02.aspeed.com (192.168.0.24) To TWMBX02.aspeed.com (192.168.0.24) X-DNSRBL: X-MAIL: twspam01.aspeedtech.com 09J8so81046772 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org These rules must be followed when accessing the TX descriptor: 1. A TX descriptor is "cleanable" only when its value is non-zero and the owner bit is set to "software" 2. A TX descriptor is "writable" only when its value is zero regardless the edotr mask. Fixes: 52c0cae87465 ("ftgmac100: Remove tx descriptor accessors") Signed-off-by: Dylan Hung Signed-off-by: Joel Stanley --- drivers/net/ethernet/faraday/ftgmac100.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c index 00024dd41147..7cacbe4aecb7 100644 --- a/drivers/net/ethernet/faraday/ftgmac100.c +++ b/drivers/net/ethernet/faraday/ftgmac100.c @@ -647,6 +647,9 @@ static bool ftgmac100_tx_complete_packet(struct ftgmac100 *priv) if (ctl_stat & FTGMAC100_TXDES0_TXDMA_OWN) return false; + if ((ctl_stat & ~(priv->txdes0_edotr_mask)) == 0) + return false; + skb = priv->tx_skbs[pointer]; netdev->stats.tx_packets++; netdev->stats.tx_bytes += skb->len; @@ -756,6 +759,9 @@ static netdev_tx_t ftgmac100_hard_start_xmit(struct sk_buff *skb, pointer = priv->tx_pointer; txdes = first = &priv->txdes[pointer]; + if (le32_to_cpu(txdes->txdes0) & ~priv->txdes0_edotr_mask) + goto drop; + /* Setup it up with the packet head. Don't write the head to the * ring just yet */ @@ -787,6 +793,10 @@ static netdev_tx_t ftgmac100_hard_start_xmit(struct sk_buff *skb, /* Setup descriptor */ priv->tx_skbs[pointer] = skb; txdes = &priv->txdes[pointer]; + + if (le32_to_cpu(txdes->txdes0) & ~priv->txdes0_edotr_mask) + goto dma_err; + ctl_stat = ftgmac100_base_tx_ctlstat(priv, pointer); ctl_stat |= FTGMAC100_TXDES0_TXDMA_OWN; ctl_stat |= FTGMAC100_TXDES0_TXBUF_SIZE(len); -- 2.17.1