Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp898845ybt; Fri, 10 Jul 2020 15:35:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHqlSeyG9wR7M7uk98nuJ1duq63cmAvKEEmG2oMc/KNPH38sXG2MOiojvoBOdzT3ORyAAN X-Received: by 2002:a05:6402:134e:: with SMTP id y14mr80358670edw.4.1594420541198; Fri, 10 Jul 2020 15:35:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594420541; cv=none; d=google.com; s=arc-20160816; b=F+n8ON69LRJEQwABovOho+yBxFPndkzTbwjhQCy84dsxKQ98nf8ngrS8yNvL1jD6w6 t+Cw4UTGThug5LJ8LP6OQWRmztVPrrLXdhtFptiUkB7zhuHHjzJrZtCrJsxu5UE5Tx7T Uo7f6IkXYS6+1VG3FhHyVttz84ilaL8U66+HB+x6e5nyftNpAulgI28EtJpyAoSCK3ww p6z7YyuPYyZ6wmlzi7gSjJfGa6xRb1hyVl3olqDLdNioGZIX7bmQST+TPP69BTdk9l17 tDXzMRzN1o7cF8ZDI/sNkcfo1o25dKYO7ORHkord6HzfYTKwIEma1AGRQX7ZUs5TztXj ewWQ== 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=otX10QeuyuQfo38SItHDi82VSL0/UgLiHWfFSpTeXXY=; b=qys6Zv19SGgXrjN6wa4X6pmCHViEu2M69OvMTeoIotm/3Kjg68dw3srN4Xy8WJWNUl 4nGdQEnOYrQAeIwC4jnJC4drStYPOZhIGNYS3PV0efAUJyjO9bCIPyHsjC591ZEonSQf Qb4YRF4yyijyeAejAtpTb34Hvo53BRfoPoYzoWiKb8nSQwG+E+3cKOa+Pp2pZ0CjzipN HIddetI9YtG6LAStgzt+h63d6mbMX/EpUCFvIVCOqKGtqho3hamJPkqATtIbfji5k1Ky Ry/Vu79+Ebt3c9BPqCTeOsENWcW+ipbzFCpHoGx/wGIASi+DIg2+8NY1pxdPRUMsdFct uIeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FMZ1pvxB; 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 l16si4274123edw.377.2020.07.10.15.35.18; Fri, 10 Jul 2020 15:35:41 -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=FMZ1pvxB; 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 S1726907AbgGJWeq (ORCPT + 99 others); Fri, 10 Jul 2020 18:34:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:45984 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726801AbgGJWee (ORCPT ); Fri, 10 Jul 2020 18:34:34 -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 1306420842; Fri, 10 Jul 2020 22:34:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594420474; bh=cbWejgBryP3wyPjTJqgvL1vW18Wt3qtjvaAEe9kL0pA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FMZ1pvxBAj/UqOMhOUE4LnQZIiFubMpVx7zHItoWPFKhBrWbTBYPVAdTBFCy2+0G1 9WCbwxcHHxgEqTzBBWG2k82KXIWM2L+Q1svJMEePdQc1BWjdG3rg+K0IjMVi9IuZ5m Fahls4gJEmbcd12Pe6pig9hLI9mD2vlA5ttxzRQQ= 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, hch@infradead.org, Stefano Stabellini Subject: [PATCH v3 11/11] xen/arm: call dma_to_phys on the dma_addr_t parameter of dma_cache_maint Date: Fri, 10 Jul 2020 15:34:27 -0700 Message-Id: <20200710223427.6897-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 Reviewed-by: Boris Ostrovsky 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 a8251a70f442..396797ffe2b1 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); } @@ -76,16 +79,16 @@ void xen_dma_sync_for_cpu(struct device *dev, dma_addr_t handle, size_t size, enum dma_data_direction dir) { 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, size_t size, enum dma_data_direction dir) { 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