From patchwork Wed Aug 29 06:55:34 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hiroshi Doyu X-Patchwork-Id: 11012 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id C1AA823F25 for ; Wed, 29 Aug 2012 06:57:02 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 03413A18664 for ; Wed, 29 Aug 2012 06:56:30 +0000 (UTC) Received: by mail-iy0-f180.google.com with SMTP id j25so459132iaf.11 for ; Tue, 28 Aug 2012 23:57:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :x-pgp-universal:from:to:date:message-id:x-mailer:in-reply-to :references:mime-version:cc:subject:x-beenthere:x-mailman-version :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:content-type:content-transfer-encoding :sender:errors-to:x-gm-message-state; bh=IGRh2oz/pizz7EMUk0l59x8pRW3J9dxGc63FhGwbC/U=; b=lYWxqNWKuCYXWN55cYA4DMbKn1r8SVA8qvXnr5YaPw9BizPsFC8iB5KltHxT58pMZ4 AKvjKUQeHq3gNUsBbOiDEoDKmLI5tf+XBgH6JQO5cmSWA7+HnM0rqmmgw1ns7hQ8vSlt Ti2obj9PO4QMxOI19uibcXhADvGtSsOtQTxu1Ss+t3FSph95UcWGYdZnrhEQBK4Kdr5j y3VpgBEmNc15l5I1NamypR7spZB+ft1mJF76fsAWAKvosjb8Mxbijj7NgfnyJJJ7q57U pB9sOSvjXZiMyh5acIvAyD7tx3tju2S/HQn2oR/NaugOUnv79iH4fIy9uG7uy+PMBUSZ LQEQ== Received: by 10.50.237.41 with SMTP id uz9mr545199igc.43.1346223422225; Tue, 28 Aug 2012 23:57:02 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp68358igc; Tue, 28 Aug 2012 23:57:01 -0700 (PDT) Received: by 10.180.87.34 with SMTP id u2mr26317061wiz.3.1346223420725; Tue, 28 Aug 2012 23:57:00 -0700 (PDT) Received: from mombin.canonical.com (mombin.canonical.com. [91.189.95.16]) by mx.google.com with ESMTP id gq10si11794208wib.3.2012.08.28.23.56.59; Tue, 28 Aug 2012 23:57:00 -0700 (PDT) Received-SPF: neutral (google.com: 91.189.95.16 is neither permitted nor denied by best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org) client-ip=91.189.95.16; Authentication-Results: mx.google.com; spf=neutral (google.com: 91.189.95.16 is neither permitted nor denied by best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org) smtp.mail=linaro-mm-sig-bounces@lists.linaro.org Received: from localhost ([127.0.0.1] helo=mombin.canonical.com) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1T6cCv-0008KM-M4; Wed, 29 Aug 2012 06:56:57 +0000 Received: from hqemgate03.nvidia.com ([216.228.121.140]) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1T6cCu-0008K1-CJ for linaro-mm-sig@lists.linaro.org; Wed, 29 Aug 2012 06:56:56 +0000 Received: from hqnvupgp05.nvidia.com (Not Verified[216.228.121.13]) by hqemgate03.nvidia.com id ; Tue, 28 Aug 2012 23:57:33 -0700 Received: from hqemhub02.nvidia.com ([172.17.108.22]) by hqnvupgp05.nvidia.com (PGP Universal service); Tue, 28 Aug 2012 23:56:09 -0700 X-PGP-Universal: processed; by hqnvupgp05.nvidia.com on Tue, 28 Aug 2012 23:56:09 -0700 Received: from hqnvemgw01.nvidia.com (172.20.150.20) by hqemhub02.nvidia.com (172.20.150.31) with Microsoft SMTP Server id 8.3.264.0; Tue, 28 Aug 2012 23:56:12 -0700 Received: from daphne.nvidia.com (Not Verified[172.16.212.96]) by hqnvemgw01.nvidia.com with MailMarshal (v6,7,2,8378) id ; Tue, 28 Aug 2012 23:56:12 -0700 Received: from oreo.Nvidia.com (dhcp-10-21-25-186.nvidia.com [10.21.25.186]) by daphne.nvidia.com (8.13.8+Sun/8.8.8) with ESMTP id q7T6tkpn016768; Tue, 28 Aug 2012 23:56:08 -0700 (PDT) From: Hiroshi Doyu To: Date: Wed, 29 Aug 2012 09:55:34 +0300 Message-ID: <1346223335-31455-5-git-send-email-hdoyu@nvidia.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1346223335-31455-1-git-send-email-hdoyu@nvidia.com> References: <1346223335-31455-1-git-send-email-hdoyu@nvidia.com> MIME-Version: 1.0 Cc: linux@arm.linux.org.uk, arnd@arndb.de, minchan@kernel.org, konrad.wilk@oracle.com, linux-kernel@vger.kernel.org, linaro-mm-sig@lists.linaro.org, linux-mm@kvack.org, iommu@lists.linux-foundation.org, linux-tegra@vger.kernel.org, kyungmin.park@samsung.com, pullip.cho@samsung.com, linux-arm-kernel@lists.infradead.org Subject: [Linaro-mm-sig] [RFC 4/5] ARM: dma-mapping: New dma_map_ops->map_page*_at* function X-BeenThere: linaro-mm-sig@lists.linaro.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Unified memory management interest group." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linaro-mm-sig-bounces@lists.linaro.org Errors-To: linaro-mm-sig-bounces@lists.linaro.org X-Gm-Message-State: ALoCoQn5/H/CqDfoe3eE9E1k8CkRsu+dzJ21nUrxcKA9v7Z+gnSL9T+rVDNXMc+QKYm2dFSP6Muq Signed-off-by: Hiroshi Doyu --- arch/arm/mm/dma-mapping.c | 18 ++++++++++++++++++ include/asm-generic/dma-mapping-common.h | 19 +++++++++++++++++++ include/linux/dma-mapping.h | 7 +++++++ 3 files changed, 44 insertions(+), 0 deletions(-) diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 8ca2d1a..242289f 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -1715,6 +1715,23 @@ static dma_addr_t arm_iommu_map_page(struct device *dev, struct page *page, return arm_coherent_iommu_map_page(dev, page, offset, size, dir, attrs); } +static dma_addr_t arm_iommu_map_page_at(struct device *dev, struct page *page, + dma_addr_t dma_addr, unsigned long offset, size_t size, + enum dma_data_direction dir, struct dma_attrs *attrs) +{ + struct dma_iommu_mapping *mapping = dev->archdata.mapping; + int ret, len = PAGE_ALIGN(size + offset); + + if (!dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs)) + __dma_page_cpu_to_dev(page, offset, size, dir); + + ret = iommu_map(mapping->domain, dma_addr, page_to_phys(page), len, 0); + if (ret < 0) + return DMA_ERROR_CODE; + + return dma_addr + offset; +} + /** * arm_coherent_iommu_unmap_page * @dev: valid struct device pointer @@ -1813,6 +1830,7 @@ struct dma_map_ops iommu_ops = { .get_sgtable = arm_iommu_get_sgtable, .map_page = arm_iommu_map_page, + .map_page_at = arm_iommu_map_page_at, .unmap_page = arm_iommu_unmap_page, .sync_single_for_cpu = arm_iommu_sync_single_for_cpu, .sync_single_for_device = arm_iommu_sync_single_for_device, diff --git a/include/asm-generic/dma-mapping-common.h b/include/asm-generic/dma-mapping-common.h index de8bf89..eada2d8 100644 --- a/include/asm-generic/dma-mapping-common.h +++ b/include/asm-generic/dma-mapping-common.h @@ -26,6 +26,23 @@ static inline dma_addr_t dma_map_single_attrs(struct device *dev, void *ptr, return addr; } +static inline dma_addr_t dma_map_single_at_attrs(struct device *dev, void *ptr, + dma_addr_t handle, + size_t size, + enum dma_data_direction dir, + struct dma_attrs *attrs) +{ + struct dma_map_ops *ops = get_dma_ops(dev); + dma_addr_t addr; + + kmemcheck_mark_initialized(ptr, size); + BUG_ON(!valid_dma_direction(dir)); + addr = ops->map_page_at(dev, virt_to_page(ptr), handle, + (unsigned long)ptr & ~PAGE_MASK, size, + dir, attrs); + return addr; +} + static inline void dma_unmap_single_attrs(struct device *dev, dma_addr_t addr, size_t size, enum dma_data_direction dir, @@ -172,6 +189,8 @@ dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, } #define dma_map_single(d, a, s, r) dma_map_single_attrs(d, a, s, r, NULL) +#define dma_map_single_at(d, a, h, s, r) \ + dma_map_single_at_attrs(d, a, h, s, r, NULL) #define dma_unmap_single(d, a, s, r) dma_unmap_single_attrs(d, a, s, r, NULL) #define dma_map_sg(d, s, n, r) dma_map_sg_attrs(d, s, n, r, NULL) #define dma_unmap_sg(d, s, n, r) dma_unmap_sg_attrs(d, s, n, r, NULL) diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index 4cf4427..218bee3 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -25,6 +25,13 @@ struct dma_map_ops { unsigned long offset, size_t size, enum dma_data_direction dir, struct dma_attrs *attrs); + + dma_addr_t (*map_page_at)(struct device *dev, struct page *page, + dma_addr_t dma_handle, + unsigned long offset, size_t size, + enum dma_data_direction dir, + struct dma_attrs *attrs); + void (*unmap_page)(struct device *dev, dma_addr_t dma_handle, size_t size, enum dma_data_direction dir, struct dma_attrs *attrs);