Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4253247pxu; Tue, 20 Oct 2020 12:00:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGq8FpDn+Q6A3mDyzZtvv+4pRX4e6AyYXcTHsvR/jqtZVJoUiGhG8uUH6fHgLLSZUp7SOa X-Received: by 2002:aa7:da05:: with SMTP id r5mr4280607eds.184.1603220427168; Tue, 20 Oct 2020 12:00:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603220427; cv=none; d=google.com; s=arc-20160816; b=YNZtuLpY7yb8XIak335wSWAFd4FMRi2kzD1RtFKK7EnTEqkbEKaZ8HdEf7hfxwvPFl fVfVGdZ165sk0nYKM6Vt6w+KS1NVqfKuWSVTPfN6/FFY+nPVUNv78gfIiQCgATH2p14c HuHBE/RUuID3EqB027RVoqv/wDPInkYkrWjc4cSNfswTq0fr6Pc1mIU5sfIITFhUqTBz AeGkNz2R6jZXVqeB1w53oYk+NoqkjiekcT0pkLdP5LndNGbRECuUcxB/5olNDiX/tqgk lbDWKgHmNR6UoqCk/4LzuVYvIeuO8ZoRTZuSsODFTgWNFBb5GEXvs0wAQvuErMwmZ5l0 BKbQ== 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:message-id:subject:cc:to:from:date :dkim-signature; bh=T75cTW2oc/7SePvJqbKx4keUlhRmeiPU5UqTdsFOOI4=; b=ysn7/ojJXoJbUoufMEQPXioImXvlsR/beACesHp5mg3T4+81DeyfFOjvHx58shL6BO Fw114BJ76/vDdCzx0xRnVMtEEh3uhnmT28NQgiRzBZmBHgpt27VNazWR8qFatgTr/EDW tOogjiIHJGUlXvVBis/InK3g7Q9nACN8OIHRTYogEaSICmPcU0SS9lHLXywbT1Ofc9xy xJqpholMqWwXXs29Tk5iB3uHMbBxZCSJzA945szzMsKU4fwnsnfRQM9MmSEiGvvcmSzq aA/pcAfXyNiBKmEilDBo9Kq5jDx8WNzDIA8k+b2Cg7n/Szw9fSblw3s2CkIxqtf5MZ91 d2tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hhwqmsA1; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q25si1783783edw.184.2020.10.20.12.00.04; Tue, 20 Oct 2020 12:00:27 -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; dkim=pass header.i=@kernel.org header.s=default header.b=hhwqmsA1; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390932AbgJTC50 (ORCPT + 99 others); Mon, 19 Oct 2020 22:57:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:50830 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729181AbgJTC50 (ORCPT ); Mon, 19 Oct 2020 22:57:26 -0400 Received: from kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com (unknown [163.114.132.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 208DF222E9; Tue, 20 Oct 2020 02:57:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603162645; bh=qwSN9blogEZVLec+dCJS+sFeJavpar63X669kQYp8rY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=hhwqmsA1cgEsFROQBL4byLwoaqAmG2QBWW0ddmocqhrtuk7Rr8x6JMM9GM4fq1HPa uzuzs1UkoYq/1DXJb5TuShJqcK5svitoMD+7JZ//UQfv2N59j4olJJIN6NdaZ7Sg2V UoBNpABhyynRdhwZqKJIsWIgo6z7AhEo6VDDiYpA= Date: Mon, 19 Oct 2020 19:57:23 -0700 From: Jakub Kicinski To: Benjamin Herrenschmidt Cc: Joel Stanley , Dylan Hung , "David S . Miller" , netdev@vger.kernel.org, Linux Kernel Mailing List , Po-Yu Chuang , linux-aspeed , OpenBMC Maillist , BMC-SW , Arnd Bergmann , linux-arch@vger.kernel.org Subject: Re: [PATCH] net: ftgmac100: Fix missing TX-poll issue Message-ID: <20201019195723.41a5591f@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> In-Reply-To: <1a02e57b6b7d425a19dc59f84091c38ca4edcf47.camel@kernel.crashing.org> References: <20201019073908.32262-1-dylan_hung@aspeedtech.com> <20201019120040.3152ea0b@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> <1a02e57b6b7d425a19dc59f84091c38ca4edcf47.camel@kernel.crashing.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 20 Oct 2020 10:23:41 +1100 Benjamin Herrenschmidt wrote: > 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. I see, but in general this sort of a problem should be resolved by adding an appropriate memory barrier. And in fact such barrier should (these days) be implied by a writel (I'm not 100% clear on why this driver uses iowrite, and if it matters). > 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). Argh.