Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp245852ybg; Mon, 8 Jun 2020 22:40:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypSaaF1a5B++rLVGUoFZZx95Q/8WsojKxq7w1BpZv1ZnWXH+EOzK6HhoOckdo4If+3eZ0T X-Received: by 2002:a17:906:4c81:: with SMTP id q1mr6140074eju.273.1591681225581; Mon, 08 Jun 2020 22:40:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591681225; cv=none; d=google.com; s=arc-20160816; b=t4SGjFvkcOKVyG1j+3fFobpMqL7Mhp3x3FE13flkuXmzWpODhWQGRJGn1Jc7u9hOtf JuuZTh8qAPKwlV3tqgFFL63GiFF0GNRz1iOymDZFxS9aax5vOv22gF3r1T6LQwZywZBx cmp1elJbw3T0X2gkBEGt+ymL5SFp+AK7/sZc/VEUIxsFbeOoVsiKk6Jr5lx3w3PTzNAe vzwhgEJXp9k8txo9r1Gkcrmo4YrZxP0+N5D0TXFk+g1OuijYUb488gahtw3dQ3O4lMdt Jc43+XhsYA/FPrItwLWdHEl5t9Eh5C3r+/8hxlxEiyJrO/XSSJTK4iKU1FW1s94hbphm TtKA== 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=TaoLQA/iHofCA82dwdTGmf/d+d6nTw1lk728rMya7LM=; b=FjCx7mJF3sBu1Nde9TkXIpKwpKPDIr/Gnx20FU6N1vnJR9DVRNbFUvy3gld7KONyhg 9JIVCFMsM3TW5MYD0iLolaNBOAti6ODoYp2fXIhWYJEgzxpEocA/I8RPkTHukWRQRoua 9eMaGYfv4RV7Z0X3EXY5YS1cr5b4+aQ2+Ttv9uzjFjwuJ8I9C2XLcQbP+UNzwBPlUYGF f2SeolIg0mlFsCXMwFkntrfqaSzKKO8z1aBWrMQXNSvKGBQjv1nLuOpRKqKjtlK9Z9zL oq2WtjyQaFXMpHPXcWX603EZN0SnMNLtJpihr5Ua4ZqksynkILPNvEfiyWY0fcwUgMnr 3s4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=TMxv+Qz+; 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 e1si10156281edn.68.2020.06.08.22.40.01; Mon, 08 Jun 2020 22:40:25 -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=TMxv+Qz+; 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 S1727055AbgFIFiG (ORCPT + 99 others); Tue, 9 Jun 2020 01:38:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726917AbgFIFiG (ORCPT ); Tue, 9 Jun 2020 01:38:06 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EF1DC03E969 for ; Mon, 8 Jun 2020 22:38:06 -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=TaoLQA/iHofCA82dwdTGmf/d+d6nTw1lk728rMya7LM=; b=TMxv+Qz+Z2VzON5gsdIxcbjqf1 NzglBzFgoUfCgS+BonQq8w8owGelI6UxV7CQd8KKHRH2vrqB4gWNC4xAnUQMZ6Xk0emCuqFDDUZN8 43aesbmuvY5m8XGuGM7eCOdKinI4Oauwq/iRDNua4u1OHm6ytKPBm9xgFYjRKwtgsn52ZTiS4Urt6 qao/+nZoFeC5nk3/TMSQtxcz+4ABzV7wGbpujPWX0CdLINwfPpL3cI7Hjy0butd/0qS2vw4jIWxOq ZQwRIK6GUfhXpHZJOa3gGG/KKm0myQsIimI9mC9XHlENO5KP2QnP88nACyy5We+sRVVCRp9UFJ/zw QWANqufQ==; Received: from hch by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jiWxW-0006qv-Bf; Tue, 09 Jun 2020 05:38:02 +0000 Date: Mon, 8 Jun 2020 22:38:02 -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: <20200609053802.GB3015@infradead.org> References: <20200603222247.11681-10-sstabellini@kernel.org> <20200608071221.GF15742@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 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.