Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp801399ybe; Thu, 5 Sep 2019 06:14:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqwJrsvhlBQLubO2lG80qtIpr+P5RNKkupC/W5/Ym1sE5F857iVRmX+TNyux/d0FZ+v9sOJc X-Received: by 2002:a62:82cb:: with SMTP id w194mr3564436pfd.181.1567689243074; Thu, 05 Sep 2019 06:14:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567689243; cv=none; d=google.com; s=arc-20160816; b=eHe0VlgPBA8ebNvPLERv0FxdzJIvNokonf5McsIiaFPmW8mn0/cVZ3Fm2GE1CvWTV+ Bpa9ZRZEAw+ZYseFAEIveoDJqcEqHsc6fvIB+0RBjSxOVY0DuS9TdoIMGA5UqNs1T6fL /DFofMH5vtS2IsuQ5mJgue/yGBA/9QfP1KkedX6EFDRugVfkVwdd2qdpF3u3RG4AQg91 tUklwhgj3/YsgIg+gbs2/0RmC71VRl5oEUTH4bYgv0HmJBRIPkm8UVAJIX98dIYMQggA xvWIbTWtjAAIIYa0yyNTRyQ/05saBZjVQNoynkC3fnmEgYYK7Lk1c6GhE4/leuwfTB1V Mo9Q== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=EWNScfWDMyrvxl4YkL1REfmmjq71emAlpbDmA+Ece6c=; b=IT6b7+6KIyrQ3h39Gh+ZTy/cnkpJtwo6FDWA+XfbbGi7Yi2Z5zzF4P4qa9uLASrDzH JnnbugMTYjRuNzxzjhgsjgy3G8rlOwiNdqI6sKt77JKEpepwwV87fXprJUGkfIL6Mjxd sQpn5gvE5dUAne4TLRWgpZGHclEo8/Vup62mZPmzpnrE/AhL/BaD3ENLDimlCT/Qwuxr aeCd5FDrRhp5v1Ql3lDqLfqhbgzNsOyQSzBC3B2EwOUISeei1fi4PCy/+BuSWf8G+g1j vl2EhI8CtxBjJzBTl5U4TfTAiwcCtru7qF7NcJgneedEU7neFvi6QYV7HJqCvl33bxZ7 eaFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=YAz6TZlY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o19si1676544pgv.497.2019.09.05.06.13.47; Thu, 05 Sep 2019 06:14:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=YAz6TZlY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388665AbfIELky (ORCPT + 99 others); Thu, 5 Sep 2019 07:40:54 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:50664 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733010AbfIELkv (ORCPT ); Thu, 5 Sep 2019 07:40:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type: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=EWNScfWDMyrvxl4YkL1REfmmjq71emAlpbDmA+Ece6c=; b=YAz6TZlYaFH5Yk7mw92FLMNIfT h3wo5Y5MVVeIdU/4jJtQ8nPvW/Qgbe0iSreVyQ2tweXEWN70cegq4neGZHLR9ntvmNH8T8nBQrcXG ngdapn6wkQfjTbEm+0rts5ZSTdDRsamSS5disgDUBY5gEYl5kUvaSpYKMC8KaxmoxU7s3qTSsfzDp fVvYmWUyvLlRzPx+0QUWiG4S2TwsTqFicO3toar4abGbKAyXlLSzN9H5YO2xnTqZ8Hd2lpL61mOG5 uizMAGRTGQ9hA9Vzvh4oa20Pdx6hEzMW80Dsg7bJnkPIWiLrM7Ox6W+Y7RAS7BagJyMTfklMy8zk0 ShFeYJeA==; Received: from 213-225-38-191.nat.highway.a1.net ([213.225.38.191] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1i5q87-0004qN-0k; Thu, 05 Sep 2019 11:40:47 +0000 From: Christoph Hellwig To: Stefano Stabellini , Konrad Rzeszutek Wilk , gross@suse.com, boris.ostrovsky@oracle.com Cc: x86@kernel.org, linux-arm-kernel@lists.infradead.org, xen-devel@lists.xenproject.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH 02/11] xen/arm: consolidate page-coherent.h Date: Thu, 5 Sep 2019 13:33:59 +0200 Message-Id: <20190905113408.3104-3-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190905113408.3104-1-hch@lst.de> References: <20190905113408.3104-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Shared the duplicate arm/arm64 code in include/xen/arm/page-coherent.h. Signed-off-by: Christoph Hellwig --- arch/arm/include/asm/xen/page-coherent.h | 75 -------------------- arch/arm64/include/asm/xen/page-coherent.h | 75 -------------------- include/xen/arm/page-coherent.h | 80 ++++++++++++++++++++++ 3 files changed, 80 insertions(+), 150 deletions(-) diff --git a/arch/arm/include/asm/xen/page-coherent.h b/arch/arm/include/asm/xen/page-coherent.h index 602ac02f154c..27e984977402 100644 --- a/arch/arm/include/asm/xen/page-coherent.h +++ b/arch/arm/include/asm/xen/page-coherent.h @@ -1,77 +1,2 @@ /* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _ASM_ARM_XEN_PAGE_COHERENT_H -#define _ASM_ARM_XEN_PAGE_COHERENT_H - -#include -#include #include - -static inline void *xen_alloc_coherent_pages(struct device *hwdev, size_t size, - dma_addr_t *dma_handle, gfp_t flags, unsigned long attrs) -{ - return dma_direct_alloc(hwdev, size, dma_handle, flags, attrs); -} - -static inline void xen_free_coherent_pages(struct device *hwdev, size_t size, - void *cpu_addr, dma_addr_t dma_handle, unsigned long attrs) -{ - dma_direct_free(hwdev, size, cpu_addr, dma_handle, attrs); -} - -static inline void xen_dma_sync_single_for_cpu(struct device *hwdev, - dma_addr_t handle, size_t size, enum dma_data_direction dir) -{ - unsigned long pfn = PFN_DOWN(handle); - - if (pfn_valid(pfn)) - dma_direct_sync_single_for_cpu(hwdev, handle, size, dir); - else - __xen_dma_sync_single_for_cpu(hwdev, handle, size, dir); -} - -static inline void xen_dma_sync_single_for_device(struct device *hwdev, - dma_addr_t handle, size_t size, enum dma_data_direction dir) -{ - unsigned long pfn = PFN_DOWN(handle); - if (pfn_valid(pfn)) - dma_direct_sync_single_for_device(hwdev, handle, size, dir); - else - __xen_dma_sync_single_for_device(hwdev, handle, size, dir); -} - -static inline void xen_dma_map_page(struct device *hwdev, struct page *page, - dma_addr_t dev_addr, unsigned long offset, size_t size, - enum dma_data_direction dir, unsigned long attrs) -{ - unsigned long page_pfn = page_to_xen_pfn(page); - unsigned long dev_pfn = XEN_PFN_DOWN(dev_addr); - unsigned long compound_pages = - (1< -#include #include - -static inline void *xen_alloc_coherent_pages(struct device *hwdev, size_t size, - dma_addr_t *dma_handle, gfp_t flags, unsigned long attrs) -{ - return dma_direct_alloc(hwdev, size, dma_handle, flags, attrs); -} - -static inline void xen_free_coherent_pages(struct device *hwdev, size_t size, - void *cpu_addr, dma_addr_t dma_handle, unsigned long attrs) -{ - dma_direct_free(hwdev, size, cpu_addr, dma_handle, attrs); -} - -static inline void xen_dma_sync_single_for_cpu(struct device *hwdev, - dma_addr_t handle, size_t size, enum dma_data_direction dir) -{ - unsigned long pfn = PFN_DOWN(handle); - - if (pfn_valid(pfn)) - dma_direct_sync_single_for_cpu(hwdev, handle, size, dir); - else - __xen_dma_sync_single_for_cpu(hwdev, handle, size, dir); -} - -static inline void xen_dma_sync_single_for_device(struct device *hwdev, - dma_addr_t handle, size_t size, enum dma_data_direction dir) -{ - unsigned long pfn = PFN_DOWN(handle); - if (pfn_valid(pfn)) - dma_direct_sync_single_for_device(hwdev, handle, size, dir); - else - __xen_dma_sync_single_for_device(hwdev, handle, size, dir); -} - -static inline void xen_dma_map_page(struct device *hwdev, struct page *page, - dma_addr_t dev_addr, unsigned long offset, size_t size, - enum dma_data_direction dir, unsigned long attrs) -{ - unsigned long page_pfn = page_to_xen_pfn(page); - unsigned long dev_pfn = XEN_PFN_DOWN(dev_addr); - unsigned long compound_pages = - (1< +#include + void __xen_dma_map_page(struct device *hwdev, struct page *page, dma_addr_t dev_addr, unsigned long offset, size_t size, enum dma_data_direction dir, unsigned long attrs); @@ -13,4 +16,81 @@ void __xen_dma_sync_single_for_cpu(struct device *hwdev, void __xen_dma_sync_single_for_device(struct device *hwdev, dma_addr_t handle, size_t size, enum dma_data_direction dir); +static inline void *xen_alloc_coherent_pages(struct device *hwdev, size_t size, + dma_addr_t *dma_handle, gfp_t flags, unsigned long attrs) +{ + return dma_direct_alloc(hwdev, size, dma_handle, flags, attrs); +} + +static inline void xen_free_coherent_pages(struct device *hwdev, size_t size, + void *cpu_addr, dma_addr_t dma_handle, unsigned long attrs) +{ + dma_direct_free(hwdev, size, cpu_addr, dma_handle, attrs); +} + +static inline void xen_dma_sync_single_for_cpu(struct device *hwdev, + dma_addr_t handle, size_t size, enum dma_data_direction dir) +{ + unsigned long pfn = PFN_DOWN(handle); + + if (pfn_valid(pfn)) + dma_direct_sync_single_for_cpu(hwdev, handle, size, dir); + else + __xen_dma_sync_single_for_cpu(hwdev, handle, size, dir); +} + +static inline void xen_dma_sync_single_for_device(struct device *hwdev, + dma_addr_t handle, size_t size, enum dma_data_direction dir) +{ + unsigned long pfn = PFN_DOWN(handle); + if (pfn_valid(pfn)) + dma_direct_sync_single_for_device(hwdev, handle, size, dir); + else + __xen_dma_sync_single_for_device(hwdev, handle, size, dir); +} + +static inline void xen_dma_map_page(struct device *hwdev, struct page *page, + dma_addr_t dev_addr, unsigned long offset, size_t size, + enum dma_data_direction dir, unsigned long attrs) +{ + unsigned long page_pfn = page_to_xen_pfn(page); + unsigned long dev_pfn = XEN_PFN_DOWN(dev_addr); + unsigned long compound_pages = + (1<