Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp11462ybg; Tue, 9 Jun 2020 14:53:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHWPwBluxpfayLcgjsVfKVOxGrm3C05n2Y6zm6WDuczpaq1VLnYXCmX2lcSgrQHyJZDQza X-Received: by 2002:a17:906:4e57:: with SMTP id g23mr409461ejw.522.1591739617127; Tue, 09 Jun 2020 14:53:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591739617; cv=none; d=google.com; s=arc-20160816; b=Mdy2TJiGt+LMNOthEOKzfxt/MD8ny5pFSYV+iaH/7D4Oqq4wzwpIH6pgRZ9+DfJe6+ gPj4di93pNaGTkXFGOSDarevyYJuIRdbpW3F1F2NCxoktUHpfKoBpP8uaV8jgbDrV5dG v59gkL2gOb/d5+9teCfiVU4n+1bB/bhgp2FTOaZO2gE2RdEabe5J8y40L1/VPmi/fnMb Ywqyj90desiX88szzbVxC1vVN/EUfyZSJJZ2IBwhB8R9KxSR9yWYE6ekZnTrWVdJ261g +ZYxJjJflz0Vp1GPIgb0+JfvIz6PVM6nmsryeww8VI3JWEQnrt/Ot8BfOqXOOoYb0BrG gWXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=XOJDPTZNo4UWvC/ixPjikPp9SVfII85IP5/ux2P1Sw4=; b=0qrybBD9KmGWQj0FAjZmGTbe+AY/zmsGGzey5gm+0W+b0CKItELMEvMBxl5lDDn/+p bp3+XxMspbHom4gGorb34R5H3Yp7aCuxCcOU4q308THsF61UZrHJUkUX5kq90agc3ycD AneINPWdr1DB7YDM0Q/A4RvZKa9v/1xmsxctXD+r0eSBAD6Q1C7/tpJ454EXFnTqs+g/ wqKYQ3zI6/1TkzBYlGLpiI3bncMzLqjHa9TTdvZVp1/PklUzz/rprm2N0y+LWjFTfNfh g1QYuDfIWr4NihLIlQ6ZPCU/Nhz9LVqNdvFz+joIXhH96iK18ggUHjm5qOAxKTjj50YK +AOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FYWiwtT8; 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 d18si11681479edz.309.2020.06.09.14.53.14; Tue, 09 Jun 2020 14:53:37 -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=FYWiwtT8; 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 S1728242AbgFIVu6 (ORCPT + 99 others); Tue, 9 Jun 2020 17:50:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:53658 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726992AbgFIVu4 (ORCPT ); Tue, 9 Jun 2020 17:50:56 -0400 Received: from localhost (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (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 CA7DA206D5; Tue, 9 Jun 2020 21:50:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591739456; bh=XTv0AfIhSGBAVmR///EPvXgZuQrSzUx+9M9fNndpuWk=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=FYWiwtT8vtIEdZWsACy6EuABQDJ0EERJh8aI4qNJOssQy+ay6qAz2Fpj54hAfTRYk Pqi/iPfoRC8DmBrdNc7Q9R2XGnptCIOoQyHTgvCUxRcDfsz2ZOHMHOmtRMmZehUJLU tRk1KzKwczMBaTpRMv5gKpCGKc9zkgacd3vmwPxo= Date: Tue, 9 Jun 2020 14:50:55 -0700 (PDT) From: Stefano Stabellini X-X-Sender: sstabellini@sstabellini-ThinkPad-T480s To: Christoph Hellwig cc: Stefano Stabellini , 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_* In-Reply-To: <20200609053949.GA26473@infradead.org> Message-ID: References: <20200603222247.11681-10-sstabellini@kernel.org> <20200608071221.GF15742@infradead.org> <20200609053802.GB3015@infradead.org> <20200609053949.GA26473@infradead.org> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 8 Jun 2020, Christoph Hellwig wrote: > 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. I can do that.