From nobody Fri Apr 26 19:35:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1590018365; cv=none; d=zohomail.com; s=zohoarc; b=OKjqYRI2q1eGaJp5iddGWoh36JrwMgB8kjpUHCjULBpg9maBNOmkBgzUgOpxuZcl8oLfqLDdYxDtRwdWsys90Vq/Bj9ya5BOPLU08ihLxXuVSVLqdVJq9reKfZjit3tb+qk61RzQW4iEIkYyW5h0k22ggHj6BO9WmrnkdfG9bFY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1590018365; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=k4Iai76517lNz0TSux7SGiVmScF9cE0bhvZMFv0ECIE=; b=N9Ti/ahQNfWXjhCf9Q87C7XZPh3ErMqEgM570NDH4JcTbl4sn6fQ/OyQYEiEeTzlcOFwngKieJQRuxRSxRM8Q3hE1d4aGXlUzLkYBOGY3uGtdiUMOBamtJaedrWY2zRf+w8+30QeceSMsDlmiZd9N58Yro0WfMBJOQAkNZ6F6iI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1590018365347570.0830741525772; Wed, 20 May 2020 16:46:05 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jbYP7-00085v-Pf; Wed, 20 May 2020 23:45:41 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jbYP6-00084m-Av for xen-devel@lists.xenproject.org; Wed, 20 May 2020 23:45:40 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id fac52810-9af3-11ea-9887-bc764e2007e4; Wed, 20 May 2020 23:45:26 +0000 (UTC) Received: from sstabellini-ThinkPad-T480s.hsd1.ca.comcast.net (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D156F208C7; Wed, 20 May 2020 23:45:25 +0000 (UTC) X-Inumbo-ID: fac52810-9af3-11ea-9887-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590018326; bh=K/T4h2BFa+NcoPT654ciuMnQsexCfqtyhB6cVtjK0L4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iO1sa0jxbGms6doP+1SAsu8gCvwCCG2FLgnZDuwrFexC103KNiw38nDll+VHU43s2 Nh2TpH2F36+9fsLjiS6cJyqFf9ZymsSVC2VoFK1SHz/99E0SURKQRXWu+SOnutOCzF s0HqcEICwCpORe7VX79MIUVoZtX9bZ86p6lqngIo= From: Stefano Stabellini To: jgross@suse.com, boris.ostrovsky@oracle.com, konrad.wilk@oracle.com Subject: [PATCH 10/10] xen/arm: call dma_to_phys on the dma_addr_t parameter of dma_cache_maint Date: Wed, 20 May 2020 16:45:20 -0700 Message-Id: <20200520234520.22563-10-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: xen-devel@lists.xenproject.org, sstabellini@kernel.org, linux-kernel@vger.kernel.org, Stefano Stabellini Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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. 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 o= rder) static bool hypercall_cflush =3D false; =20 /* 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; =20 - cflush.a.dev_bus_addr =3D handle & XEN_PAGE_MASK; cflush.offset =3D xen_offset_in_page(handle); cflush.op =3D op; + handle &=3D XEN_PAGE_MASK; =20 do { + cflush.a.dev_bus_addr =3D dma_to_phys(dev, handle); + if (size + cflush.offset > XEN_PAGE_SIZE) cflush.length =3D XEN_PAGE_SIZE - cflush.offset; else @@ -60,7 +63,7 @@ static void dma_cache_maint(dma_addr_t handle, size_t siz= e, u32 op) HYPERVISOR_grant_table_op(GNTTABOP_cache_flush, &cflush, 1); =20 cflush.offset =3D 0; - cflush.a.dev_bus_addr +=3D cflush.length; + handle +=3D cflush.length; size -=3D 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 !=3D DMA_TO_DEVICE) - dma_cache_maint(handle, size, GNTTAB_CACHE_INVAL); + dma_cache_maint(dev, handle, size, GNTTAB_CACHE_INVAL); } =20 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 =3D=3D 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); } =20 bool xen_arch_need_swiotlb(struct device *dev, --=20 2.17.1