Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp842301ybg; Wed, 3 Jun 2020 15:25:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+gl/1BofKMoo7jiSC4yk7JIgZZrHUsnzNwBZSKW719MH0wZsDWU7hlLZOZOjKQzUnxG2z X-Received: by 2002:a17:906:f06:: with SMTP id z6mr1315325eji.105.1591223123509; Wed, 03 Jun 2020 15:25:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591223123; cv=none; d=google.com; s=arc-20160816; b=eg5iSkl/xGxPOIVwLAM4P/0mCECi31Xt09qmRigQBT1Xn7n7n35eLJc79JJM1V6FD6 RWI2HumrRfQNoEhDWRIH9M3/O+Z/CRAPtRticBFlGhKfPzezxaVg4GceOo30Kv3xKpRA gCMZKNXLnF9DD3Rc5UOg+ToKHJHSJ6alTs4+36lKcCmX6x6in68tYibXUZEXBXXPf9UF v8tE/fHvaIEpCu4r1UjQ0Wcdoeb2ddegquH0OtsPStrLuEpFc+uKow/w4ErS5pP2n7RY c/tad3D3RKFRU37D26KA3qctcBkOH/aQ1hVysEWwfQMzlYQ+poJXu0viEh+C5oxUepBf oPVw== 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=SITRDy+NiuUviu4hxpgf+Nh3feuYclWN42EbJnNzswQ=; b=RWZnraIO0NO5BJoHPjT+zllx/Ki0etqG0EzCz3RtcDZge54LSMlFfH3ugtaKdz/t4O vzkIExNLxhp7Ol6/zn1Mq2Y7vFFJoCffWd3n2+8gZZWAVtduaKQJs82NizIBmbTJhpv2 BcRiTKqPWCYMFSOpnnK9Bu/tRZomItAdih6VAIsxAc96mGksavKBU9M1F5S6FVwpZ4ZX cPLwmH44uNEP1/goM0CQ/m/3F2Nmq3afj1ORYXjC90g9XlQwSAwN1A7qgU2hBLXJwpPb CgYYECasRgvbYT/a9euI8f2Gf4M5XgdEbCaXMfnGSSZZLqFSo50sfCV1uqJDzwweuOmx xxKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HU0yb8Se; 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 z5si517187ejf.264.2020.06.03.15.25.00; Wed, 03 Jun 2020 15:25:23 -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=HU0yb8Se; 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 S1726955AbgFCWXF (ORCPT + 99 others); Wed, 3 Jun 2020 18:23:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:56584 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726911AbgFCWWy (ORCPT ); Wed, 3 Jun 2020 18:22:54 -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 E899D20897; Wed, 3 Jun 2020 22:22:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591222974; bh=lK4AfabqfBMg+UgGk9XZHrVioJuYeQJmxxbhRHjLG1Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HU0yb8Se8hTNLEEvdnECpahuasRiicyLghp6oTLQ6baEadzpC09vZdyPb/DNQntF5 2cm5wkWTrm3qbvlueLnW1tYtdJd8pLuLNtcbZd/mDyiu2uPR+ZrQ7jvTXiQetm74Ec xqJAsL1OE7ZMCQrK2T3CUYQVNY6ZfhynSrMCDYa8= 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, tamas@tklengyel.com, roman@zededa.com, Stefano Stabellini Subject: [PATCH v2 11/11] xen/arm: call dma_to_phys on the dma_addr_t parameter of dma_cache_maint Date: Wed, 3 Jun 2020 15:22:47 -0700 Message-Id: <20200603222247.11681-11-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 dma_cache_maint is getting called passing a dma address which could be different from a physical address. 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 Tested-by: Corey Minyard Tested-by: Roman Shaposhnik --- Changes in v2: - improve commit message --- 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 bbad712a890d..1dc20f4bdc33 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