Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp953680ybk; Wed, 20 May 2020 16:47:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzH/yHBG+gnyRHcCgiQoGJF7QWJJ6W234s3xK0Aj9Eyk9KLsjbeIg7WAreoHHW1YdLN19dO X-Received: by 2002:a17:906:c108:: with SMTP id do8mr1394096ejc.134.1590018454415; Wed, 20 May 2020 16:47:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590018454; cv=none; d=google.com; s=arc-20160816; b=bucQMw4ygfC5McdZYf8l6bSF9jI1/gnL9shDzGB4zD/jnTperLhb2qc9q0KjpwDsIs MPQ6IOXQFwhiWVeUL/BrgG+3FyGX/LioN9ZMLEFpRMrPctuH+tNWEfd0Fb8TpdVgf3ZW z74nHQ9aLc4sojYrcV7zKUu+y3+A4KKu3ImDHRS5QD4HwCEh4ytp1TyJnfZnWGeeuEr9 CGFoz0o+zBF1FsHpA9dO9f2nPZupKMxRRO+XciVvhEvycVNmCisMjIw6z/MzTbFqrgYu Z+iNmqbDtcsSeJVoq9IX6Bn67g4KETpDVijvGM/V0tFjnXDek0Av0cEyMhATP/SWPbpM 8MBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=k4Iai76517lNz0TSux7SGiVmScF9cE0bhvZMFv0ECIE=; b=cnxqiPpFGCL1Hjmun1Fihi8jYLrua2OxDAVI3nWXi+9FL6OnqtcWANJca5KPqk1bK7 NlK7KQE8svTiKvZWCQym5E6+Be8V8/v6YmHblMup1qCJp9QOabhGB4Rkau0x6TC7cCi2 Wnz00AFIuv3TUH94DG7QSIj5iVDLjTpd+2/VKxXDY/dX8VrPMhGt++67RBdF64wL2lGo piXlZPYKI+FvNt62+OOm4Ql5nHjJti+/eDRsImMEqEv3uReNG4BNMsg7AyHsgenkRQf5 ZG1u21qmph89YsXi1yEhgIt057msKV/Wurpe/lOhOuYvn9PPHdVPEIx15c+gJWtBi7Zo fpqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iO1sa0jx; 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 t13si2255855edr.503.2020.05.20.16.47.12; Wed, 20 May 2020 16:47:34 -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=iO1sa0jx; 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 S1728137AbgETXpe (ORCPT + 99 others); Wed, 20 May 2020 19:45:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:36934 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727798AbgETXp0 (ORCPT ); Wed, 20 May 2020 19:45:26 -0400 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) 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 Cc: sstabellini@kernel.org, xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, Stefano Stabellini 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: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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, -- 2.17.1