Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp246813ybg; Mon, 8 Jun 2020 22:42:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJys8x9hSiuNvHUjK8ivXODyylPcViBeMEjtfbs2unW55FMczg+Xs5H0u3BfUM0HXGwFdo2+ X-Received: by 2002:a05:6402:1c8b:: with SMTP id cy11mr24421647edb.122.1591681356309; Mon, 08 Jun 2020 22:42:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591681356; cv=none; d=google.com; s=arc-20160816; b=zSnWXngL0IDNPyrpXLsQevng+/TyyCSPVmgSNM48P/IUtCxiAg+fqfTXPGQxMgabsL wrr+MqoE69mtKVWkxXQiwwb5r4n5wmiDtFafSv28ryLH56ya87Nj4Q6s7q/4dwCYsdDa h9CUrc+SU/Xes2R4vp76eVTx7O72n0Ha/09DDUScEQqdSDvhE3brzvdwj/YAySyelIH6 CzWWsVSFAMRg7/uKtoZ6qEpmZXV5NI3s/rqVBbOxShwjsQHUnzLJ3Zx0foktBYbym5s8 HvT1Iq2EXAiMH7kUHTxqg+d+5n7zZqB5IVapZw7ecCJ/MPwOCHJ5U5q/BNi2EzBmwo5l 3Pyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=9d5I29beiuD8NWd2IsPtQEkt8LGPlWEkqusG+bWe9Kc=; b=IDoxTYbQ9Ebk+0cQdOxMqAr0lOOfgL3AcCW+q2AQu4wpLVD1geiVi4Mif1OKsgBG6b u0QNyBI9TusVvmnZBJJD+7FGg1h9Gzm1w1Xdl/HacZa4dRgFT3WATLcSTbi1ygwEXUi2 Mw7PsNH+U//acJardUYKUbcG9La/hcVnaYfKp+GsNfXkSAocdrGXNKiTbyd2jk5Cu2PK YypdE3JY3/DDxfkAioScLK6A0526olw4I7VYoyAYHJwMxe8QXFF0vzAZj1Ou9VAHe+yp IuorcxTETF2mIEsApNLRnOuqmsVm/+ix+1TVDu+GGnL9PEtycKBCBvPa7eSadP6J5mbX 0huA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=g1VsEAhW; 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 n12si10497084edo.509.2020.06.08.22.42.13; Mon, 08 Jun 2020 22:42:36 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=g1VsEAhW; 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 S1726967AbgFIFjz (ORCPT + 99 others); Tue, 9 Jun 2020 01:39:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725770AbgFIFjy (ORCPT ); Tue, 9 Jun 2020 01:39:54 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06906C03E969 for ; Mon, 8 Jun 2020 22:39:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=9d5I29beiuD8NWd2IsPtQEkt8LGPlWEkqusG+bWe9Kc=; b=g1VsEAhWGLq6aDTVOGdfeDkonX y1gSr98rgZ2hcxCxV2zauJeM6hdWqvsFQnaSSQijOhtGEoNVA1aa07WMA42IHEOMq/RDPmo8hSeGi pSUOrrie20eynxqznnGZXRmEu1/qMjG58X0vq16YJiVur+7QfzhxYdh5LepnWkJE+y5Q2YhkQtlnN f+kBccJFktcR9xtsq7y6zdcC/88HnUpcCFZZumhRWXz6fTNUYIiGw1gf1PjM+9l6RRrNGSXBRyODQ Sq35sayJTmQD1/WhSvbwCL5ruGavLLTd3hYDtD9ueSN+BLG5UPao6Wl5u0Sf3OSSe+KU5/xRDXFQi YiB520Nw==; Received: from hch by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jiWzF-0006xo-UR; Tue, 09 Jun 2020 05:39:49 +0000 Date: Mon, 8 Jun 2020 22:39:49 -0700 From: Christoph Hellwig To: Stefano Stabellini Cc: Christoph Hellwig , jgross@suse.com, boris.ostrovsky@oracle.com, konrad.wilk@oracle.com, xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, tamas@tklengyel.com, roman@zededa.com, Stefano Stabellini Subject: Re: [PATCH v2 10/11] xen/arm: introduce phys/dma translations in xen_dma_sync_for_* Message-ID: <20200609053949.GA26473@infradead.org> References: <20200603222247.11681-10-sstabellini@kernel.org> <20200608071221.GF15742@infradead.org> <20200609053802.GB3015@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200609053802.GB3015@infradead.org> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 08, 2020 at 10:38:02PM -0700, Christoph Hellwig wrote: > On Mon, Jun 08, 2020 at 05:38:28PM -0700, Stefano Stabellini wrote: > > Yeah, the pfn_valid check is a bit weird by definition because we are > > using it to understand whether the address belong to us or to another > > VM. To do the pfn_valid check we need to translate the dma address into > > something the CPU understands, hence, the dma_to_phys call. > > > > Why can't we use the already-provided paddr? Because paddr has been > > translated twice: > > 1) from dma to maybe-foreign phys address (could be ours, or another VM) > > 2) from maybe-foreign address to local (using our local mapping of the foreign page) > > > > In fact, it would be clearer if we had all three addresses as parameters > > of xen_dma_sync_for_cpu: the dma address, the maybe-foreign physical > > address (we tend to call it xenbus address, baddr), the local physical > > address. Something like: > > I think instead we should move the arch_sync_dma_for_{device,cpu} > calls from xen_dma_sync_for_{device,cpu} into the callers, as they > are provided by the generic dma-noncoherent.h and optimized out for > coherent architectures like x86. Then the swiotlb-xen.c code only > need to call dma_cache_maint as the interface (which would have to > grow a better name), which should then only need a single kind of > address. ... actually I'd keep the xen_dma_sync_for_{device,cpu} names for the low-level interface, just move the arch_sync_dma_for_{device,cpu} calls up.