Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1898104pxk; Tue, 1 Sep 2020 10:17:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIPtCrJmG10plK8HGqww3+laaIx4rpt/gi3FvU1Hi6/4seGPZQKhAXw/OZ9Lv0q0RGP6fy X-Received: by 2002:a17:906:594c:: with SMTP id g12mr2583799ejr.347.1598980674698; Tue, 01 Sep 2020 10:17:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598980674; cv=none; d=google.com; s=arc-20160816; b=C+7KAtk9HDqxdNR+sKp0Ne0+yl0WI9LUPxJnmq8nvFIGpwyFEGwf4NzLc0HYGEaabi PWfgExoRNvPONnlAgwYk8J9iG2WY3zbvvVrfhb0GCUzl7C9BDhEpwyWD1QCTbgaHSchm GJA49DghfS4bAFAvw48zZM2qAPublWyzj45uJnCeyK3p/FzUALZaKWHVvHmxu3LA+0CB snH+jlRr5ULlTWsrpi4Xk4MZMplMTy2CylPTpw8qUeIdyVgPcqJCjGaJTKKcPEYuCBIb YEDTbQQzJAL8PoyXuAsLIRXH+KftdaATVFKrmd7Up78QKUk+1wfePPwtfyReWJo5gerc morg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=KiVf+oDbpJSVubQkmYQx5mjrpQvRzF9v3SkEokhiMig=; b=cmgEhlY0NkWESYsYkgvc4jrS/a7JmDqfWNARpp1CCk5AUiPfQ32DAmk86ac+twMy+r GcbwOXm0XmC81ne5geAXCs+108cIrhOOFTYh8Ca3OirhJthyclrWpqCsyw5b6+4qdhOH kJxUlRDK/MuaQYyXkVpsWw3c2xkx5zRq1qQ9HH435x8e8kHGf2OQ7So+RIcVijaU1krs 0d0JJpcGOBm5AIZWsp2ktUeCRzNUEOgsx7TkMYOsWFKRvdv1kwmqoDnCRGe/4/lSYmTq iJOh+PL4j4NZpKH90+Zv2XzA1v5eB82mKt6FZrC9lPXyOz4sPmEsCKDKsiaxsxMOKOAf P5DQ== 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 v5si918148edr.49.2020.09.01.10.17.30; Tue, 01 Sep 2020 10:17:54 -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 S1732569AbgIARQi (ORCPT + 99 others); Tue, 1 Sep 2020 13:16:38 -0400 Received: from verein.lst.de ([213.95.11.211]:54502 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727784AbgIARQg (ORCPT ); Tue, 1 Sep 2020 13:16:36 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 48CDB68B05; Tue, 1 Sep 2020 19:16:27 +0200 (CEST) Date: Tue, 1 Sep 2020 19:16:27 +0200 From: Christoph Hellwig To: Thomas Bogendoerfer Cc: Christoph Hellwig , alsa-devel@alsa-project.org, linux-ia64@vger.kernel.org, linux-doc@vger.kernel.org, nouveau@lists.freedesktop.org, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, "James E.J. Bottomley" , linux-mm@kvack.org, Marek Szyprowski , linux-samsung-soc@vger.kernel.org, Joonyoung Shim , linux-scsi@vger.kernel.org, Kyungmin Park , Ben Skeggs , Matt Porter , linux-media@vger.kernel.org, Tom Lendacky , Pawel Osciak , Mauro Carvalho Chehab , linux-arm-kernel@lists.infradead.org, linux-parisc@vger.kernel.org, netdev@vger.kernel.org, Seung-Woo Kim , linux-mips@vger.kernel.org, iommu@lists.linux-foundation.org Subject: Re: [PATCH 22/28] sgiseeq: convert from dma_cache_sync to dma_sync_single_for_device Message-ID: <20200901171627.GA8255@lst.de> References: <20200819065555.1802761-1-hch@lst.de> <20200819065555.1802761-23-hch@lst.de> <20200901152209.GA14288@alpha.franken.de> <20200901171241.GA20685@alpha.franken.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200901171241.GA20685@alpha.franken.de> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 01, 2020 at 07:12:41PM +0200, Thomas Bogendoerfer wrote: > On Tue, Sep 01, 2020 at 05:22:09PM +0200, Thomas Bogendoerfer wrote: > > On Wed, Aug 19, 2020 at 08:55:49AM +0200, Christoph Hellwig wrote: > > > Use the proper modern API to transfer cache ownership for incoherent DMA. > > > > > > Signed-off-by: Christoph Hellwig > > > --- > > > drivers/net/ethernet/seeq/sgiseeq.c | 12 ++++++++---- > > > 1 file changed, 8 insertions(+), 4 deletions(-) > > > > > > diff --git a/drivers/net/ethernet/seeq/sgiseeq.c b/drivers/net/ethernet/seeq/sgiseeq.c > > > index 39599bbb5d45b6..f91dae16d69a19 100644 > > > --- a/drivers/net/ethernet/seeq/sgiseeq.c > > > +++ b/drivers/net/ethernet/seeq/sgiseeq.c > > > @@ -112,14 +112,18 @@ struct sgiseeq_private { > > > > > > static inline void dma_sync_desc_cpu(struct net_device *dev, void *addr) > > > { > > > - dma_cache_sync(dev->dev.parent, addr, sizeof(struct sgiseeq_rx_desc), > > > - DMA_FROM_DEVICE); > > > + struct sgiseeq_private *sp = netdev_priv(dev); > > > + > > > + dma_sync_single_for_cpu(dev->dev.parent, VIRT_TO_DMA(sp, addr), > > > + sizeof(struct sgiseeq_rx_desc), DMA_BIDIRECTIONAL); > > > } > > > > > > static inline void dma_sync_desc_dev(struct net_device *dev, void *addr) > > > { > > > - dma_cache_sync(dev->dev.parent, addr, sizeof(struct sgiseeq_rx_desc), > > > - DMA_TO_DEVICE); > > > + struct sgiseeq_private *sp = netdev_priv(dev); > > > + > > > + dma_sync_single_for_device(dev->dev.parent, VIRT_TO_DMA(sp, addr), > > > + sizeof(struct sgiseeq_rx_desc), DMA_BIDIRECTIONAL); > > > } > > > > this breaks ethernet on IP22 completely, but I haven't figured out why, yet. > > the problem is that dma_sync_single_for_cpu() doesn't flush anything > for IP22, because it only flushes for CPUs which do speculation. So > either MIPS arch_sync_dma_for_cpu() should always flush or sgiseeq > needs to use a different sync funktion, when it wants to re-read descriptors > from memory. Well, if IP22 doesn't speculate (which I'm pretty sure is the case), dma_sync_single_for_cpu should indeeed be a no-op. But then there also shouldn't be anything in the cache, as the previous dma_sync_single_for_device should have invalidated it. So it seems like we are missing one (or more) ownership transfers to the device. I'll try to look at the the ownership management in a little more detail tomorrow.