Received: by 2002:a17:90a:bc8d:0:0:0:0 with SMTP id x13csp1166011pjr; Thu, 21 May 2020 01:30:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzDvWN7JxPwBcisfBUMw5zl0y4EHkVReFnep5uovOa3BvmY9m6plVVCDQ6c6jqsizi1g+W X-Received: by 2002:a17:907:4096:: with SMTP id nm6mr2383042ejb.30.1590049814554; Thu, 21 May 2020 01:30:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590049814; cv=none; d=google.com; s=arc-20160816; b=xiF+Dnem4LL4bV5kTtsI1pNtuKxxoJqvoFJlgBf4n6tbbvcl0My5Ez8x4cFOPv+tqg BSlcTuZrxk6sQvUXbLOHysn7ZrlUfqdU2a6T49F0xlK04rq8lHdXjEv03O+YZJiaO3g0 QtVwUnRTF+eShk3Yrfgn2aGhsUYNwXGQ7rovcZ3Mx7PTsLwXAHudcIAbnVeLBXrGUPkC iATGzu29CSznfdAyrEsWFw2jRmm95IPP2/THXFDGBcG2lW036Pn+I2zKU/Hul0lTKZHW UxhHPS0X0ICsf6OAa/uMtMISn0YlKK/7dcvEqIgfazEkB/ZwTY4BEepl+GMgIMYpL7a0 AqPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=hXHVUCa/FWiIinv37wJMJKlq+4q06rxlpbzT5I9rDrE=; b=TizWmZ4amBUIxessPHoh+RXl+sajUbaD+eUoxl9HeaKzuPI8FnEr9OJ36x/VL0nW9p FheVt13ZFMZ8Y81yPx3HInnzGKqLGXnaTl/QaDcM9/yKiErWO9cGvBvNJkM85ae72ck5 zY/aaJ7At47GxzREf3BrQyAWHj0/NnRiv8jDERm0REXLb1njBXOrqC1U/47EqTrK7sJA 554+nLjhINaROOZ8MMmyAA2UlfVxZtlLmUH06Jv55kqRelixza+y7xoMp/oCU1n25dcQ C3MzY3khPhtNQ7uzJqrX/PXv6KNnzwQRhoMiY4tTgn6tHCHdQkwMN2fgDdolytZlUn91 063Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@xen.org header.s=20200302mail header.b=dgiAhbOi; 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 cy7si2475377edb.484.2020.05.21.01.29.51; Thu, 21 May 2020 01:30:14 -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=@xen.org header.s=20200302mail header.b=dgiAhbOi; 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 S1728596AbgEUI0B (ORCPT + 99 others); Thu, 21 May 2020 04:26:01 -0400 Received: from mail.xenproject.org ([104.130.215.37]:53968 "EHLO mail.xenproject.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728481AbgEUI0B (ORCPT ); Thu, 21 May 2020 04:26:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=hXHVUCa/FWiIinv37wJMJKlq+4q06rxlpbzT5I9rDrE=; b=dgiAhbOin/mrdQK1tmYjd7ud82 lc7lhmM+8uyQKk7hTF/rU7sIE1Xhhve5VCs8P2pGzLw9ZorI1DRN8EFZGtxH/8jbwk5j43SfvZeh7 bSGiG1z6ZsxO3vHAhqC0tkGl5CHnhfA94ecvzTrAjWTliiIhdjonP+Rl4AyCDxER7Bvo=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jbgWd-0004iC-Jl; Thu, 21 May 2020 08:25:59 +0000 Received: from 54-240-197-225.amazon.com ([54.240.197.225] helo=a483e7b01a66.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1jbgWd-0007d5-Bc; Thu, 21 May 2020 08:25:59 +0000 Subject: Re: [PATCH 10/10] xen/arm: call dma_to_phys on the dma_addr_t parameter of dma_cache_maint To: Stefano Stabellini , jgross@suse.com, boris.ostrovsky@oracle.com, konrad.wilk@oracle.com Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, Stefano Stabellini References: <20200520234520.22563-10-sstabellini@kernel.org> From: Julien Grall Message-ID: Date: Thu, 21 May 2020 09:25:57 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200520234520.22563-10-sstabellini@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 21/05/2020 00:45, Stefano Stabellini wrote: > From: Stefano Stabellini > > Add a struct device* parameter to dma_cache_maint. > > Translate the dma_addr_t parameter of dma_cache_maint by calling > dma_to_phys. Do it for the first page and all the following pages, in > case of multipage handling. The term 'page' is confusing here. Are we referring to Xen page or Linux page? Also, same as patch #8 and #9 regarding the commit message. > > Signed-off-by: Stefano Stabellini > --- > arch/arm/xen/mm.c | 15 +++++++++------ > 1 file changed, 9 insertions(+), 6 deletions(-) > > diff --git a/arch/arm/xen/mm.c b/arch/arm/xen/mm.c > index 7639251bcc79..6ddf3b3c1ab5 100644 > --- a/arch/arm/xen/mm.c > +++ b/arch/arm/xen/mm.c > @@ -43,15 +43,18 @@ unsigned long xen_get_swiotlb_free_pages(unsigned int order) > static bool hypercall_cflush = false; > > /* buffers in highmem or foreign pages cannot cross page boundaries */ > -static void dma_cache_maint(dma_addr_t handle, size_t size, u32 op) > +static void dma_cache_maint(struct device *dev, dma_addr_t handle, > + size_t size, u32 op) > { > struct gnttab_cache_flush cflush; > > - cflush.a.dev_bus_addr = handle & XEN_PAGE_MASK; > cflush.offset = xen_offset_in_page(handle); > cflush.op = op; > + handle &= XEN_PAGE_MASK; > > do { > + cflush.a.dev_bus_addr = dma_to_phys(dev, handle); > + > if (size + cflush.offset > XEN_PAGE_SIZE) > cflush.length = XEN_PAGE_SIZE - cflush.offset; > else > @@ -60,7 +63,7 @@ static void dma_cache_maint(dma_addr_t handle, size_t size, u32 op) > HYPERVISOR_grant_table_op(GNTTABOP_cache_flush, &cflush, 1); > > cflush.offset = 0; > - cflush.a.dev_bus_addr += cflush.length; > + handle += cflush.length; > size -= cflush.length; > } while (size); > } > @@ -79,7 +82,7 @@ void xen_dma_sync_for_cpu(struct device *dev, dma_addr_t handle, > if (pfn_valid(PFN_DOWN(dma_to_phys(dev, handle)))) > arch_sync_dma_for_cpu(paddr, size, dir); > else if (dir != DMA_TO_DEVICE) > - dma_cache_maint(handle, size, GNTTAB_CACHE_INVAL); > + dma_cache_maint(dev, handle, size, GNTTAB_CACHE_INVAL); > } > > void xen_dma_sync_for_device(struct device *dev, dma_addr_t handle, > @@ -89,9 +92,9 @@ void xen_dma_sync_for_device(struct device *dev, dma_addr_t handle, > if (pfn_valid(PFN_DOWN(dma_to_phys(dev, handle)))) > arch_sync_dma_for_device(paddr, size, dir); > else if (dir == DMA_FROM_DEVICE) > - dma_cache_maint(handle, size, GNTTAB_CACHE_INVAL); > + dma_cache_maint(dev, handle, size, GNTTAB_CACHE_INVAL); > else > - dma_cache_maint(handle, size, GNTTAB_CACHE_CLEAN); > + dma_cache_maint(dev, handle, size, GNTTAB_CACHE_CLEAN); > } > > bool xen_arch_need_swiotlb(struct device *dev, > Cheers, -- Julien Grall