Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp3834764pxu; Tue, 20 Oct 2020 01:28:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgGsPH6Y43jzcTVI4Zj0FqizwrUo6rFUX0KyXbONMFz2OkdWw1piq/I7jXE2HbaAYvPfD7 X-Received: by 2002:a50:9502:: with SMTP id u2mr1551768eda.196.1603182536793; Tue, 20 Oct 2020 01:28:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603182536; cv=none; d=google.com; s=arc-20160816; b=UZnbVAKPtLTmGdEjMVrd/bcMUW4F2iYGjgsp2zW80eUnQcHL6/Nvw5TI+sKsTDo/8u yqWv3T+5ovxJb11aN1abllLGn6YsIpWmFzgQtiphx+H7TzAH5D2lDv231Tjf0djNLNTZ esoIpFgI4koPkdFgEP9XxNAQIDY8e4ct/mPCR/U8I+SqpQGWVnBJ0GTUnBnUiCbCJmtj x3RAouh4fIx97amESG/0kjcXWBBZrz5hxCJFvppsZxh+RAVxMZDU7zQj9NCD+WjRUWup 6kJWH29zk06hotpr3qc913XXA3F5cUOpSXTwX/WZpHwPhAkR2bPWN6ko1Ovhe4iioH0V 6i4A== 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 :references:in-reply-to:date:cc:to:from:subject:message-id; bh=H3bjIWbkC131THJP6Ls18OGWgRMDnYY1MW9jBaOIfq0=; b=YwJ68ou22OuUYpJXgCLeIMGmrKNhSb8PG4QFIhH/Y4FxJ4Xbb7cGg1kE7SPuuoFNWD hZyEvo5Y8y73i7bB9jvIJkhOKIogfaFXYjppEe6XF7uvNJYlZuEUIbJsJjFY782LQw4q Asu2zx4d+reyN0cHMbWzYWCGdjiY24Ed/7UgixiIfw14NXvxI9IrcgcArZIO/oJvxvW0 LbwVDTeuz8Xz+d69bU5dDYWNQ1ae5uWwWnxh0UHPoy3D4HMf7izLT/v+YC7WXd27goL6 z1O6nQRfCV9Qy/MHBoStVrzzckMadMkfQYfMvs9ICtLzv+rEynSzMquLoLj3JE4lpj6y d12w== 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 y18si628819edw.393.2020.10.20.01.28.34; Tue, 20 Oct 2020 01:28:56 -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 S2389055AbgJSXaO (ORCPT + 99 others); Mon, 19 Oct 2020 19:30:14 -0400 Received: from kernel.crashing.org ([76.164.61.194]:42630 "EHLO kernel.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389000AbgJSXaO (ORCPT ); Mon, 19 Oct 2020 19:30:14 -0400 Received: from localhost (gate.crashing.org [63.228.1.57]) (authenticated bits=0) by kernel.crashing.org (8.14.7/8.14.7) with ESMTP id 09JNNgCF024309 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 19 Oct 2020 18:23:45 -0500 Message-ID: <1a02e57b6b7d425a19dc59f84091c38ca4edcf47.camel@kernel.crashing.org> Subject: Re: [PATCH] net: ftgmac100: Fix missing TX-poll issue From: Benjamin Herrenschmidt To: Jakub Kicinski , Joel Stanley Cc: Dylan Hung , "David S . Miller" , netdev@vger.kernel.org, Linux Kernel Mailing List , Po-Yu Chuang , linux-aspeed , OpenBMC Maillist , BMC-SW Date: Tue, 20 Oct 2020 10:23:41 +1100 In-Reply-To: <20201019120040.3152ea0b@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> References: <20201019073908.32262-1-dylan_hung@aspeedtech.com> <20201019120040.3152ea0b@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2020-10-19 at 12:00 -0700, Jakub Kicinski wrote: > On Mon, 19 Oct 2020 08:57:03 +0000 Joel Stanley wrote: > > > diff --git a/drivers/net/ethernet/faraday/ftgmac100.c > > > b/drivers/net/ethernet/faraday/ftgmac100.c > > > index 00024dd41147..9a99a87f29f3 100644 > > > --- a/drivers/net/ethernet/faraday/ftgmac100.c > > > +++ b/drivers/net/ethernet/faraday/ftgmac100.c > > > @@ -804,7 +804,8 @@ static netdev_tx_t > > > ftgmac100_hard_start_xmit(struct sk_buff *skb, > > > * before setting the OWN bit on the first descriptor. > > > */ > > > dma_wmb(); > > > - first->txdes0 = cpu_to_le32(f_ctl_stat); > > > + WRITE_ONCE(first->txdes0, cpu_to_le32(f_ctl_stat)); > > > + READ_ONCE(first->txdes0); > > > > I understand what you're trying to do here, but I'm not sure that > > this > > is the correct way to go about it. > > > > It does cause the compiler to produce a store and then a load. > > +1 @first is system memory from dma_alloc_coherent(), right? > > You shouldn't have to do this. Is coherent DMA memory broken > on your platform? I suspect the problem is that the HW (and yes this would be a HW bug) doesn't order the CPU -> memory and the CPU -> MMIO path. What I think happens is that the store to txde0 is potentially still in a buffer somewhere on its way to memory, gets bypassed by the store to MMIO, causing the MAC to try to read the descriptor, and getting the "old" data from memory. It's ... fishy, but that isn't the first time an Aspeed chip has that type of bug (there's a similar one in the USB device controler iirc). Cheers, Ben.