From patchwork Wed Aug 29 06:55:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hiroshi Doyu X-Patchwork-Id: 11010 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 B411723F25 for ; Wed, 29 Aug 2012 06:56:33 +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 C414FA1869D for ; Wed, 29 Aug 2012 06:56:01 +0000 (UTC) Received: by mail-iy0-f180.google.com with SMTP id j25so459132iaf.11 for ; Tue, 28 Aug 2012 23:56:33 -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=UhM3cMkaWfSi/xglkhXf/6k3iXsznusuihj3aWXJ9ME=; b=TXI/BWFhqKrwCTaHI/afHSLeCXNT+GaJNP6nCu3alUysW7tbx46UAyKCxdmxkmkjpB 2NR7H6LwI3W+CFbVja+EYHq0Qie00rX3dvvNDmLKAGV2f0y3TrQ5TmlpQDUFYgm4AZXH AVodusFXLNV81Jvm2bSV9BOab62MAR+hkzmJz9KmsuTSa5RzE4isYJe4kr7AVgqLyTwy MAsHiivxwIYgB+DTClTrGkxh2jJeAcmvKKoTIfsk4LbyL7Lld1bqPyRZxpYYDs31G2Nj wUVMO4sjxcNCqVxLIxoPwfsZUKrUctz99BqduIgJZw52WeJz7GjWgoMh9hX4b+dd5vZE Hwzw== Received: by 10.50.159.196 with SMTP id xe4mr16217891igb.43.1346223392833; Tue, 28 Aug 2012 23:56:32 -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 ex8csp68332igc; Tue, 28 Aug 2012 23:56:31 -0700 (PDT) Received: by 10.180.98.138 with SMTP id ei10mr1524461wib.1.1346223391091; Tue, 28 Aug 2012 23:56:31 -0700 (PDT) Received: from mombin.canonical.com (mombin.canonical.com. [91.189.95.16]) by mx.google.com with ESMTP id fj1si11752931wib.21.2012.08.28.23.56.30; Tue, 28 Aug 2012 23:56:31 -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 1T6cCR-0008Ew-Df; Wed, 29 Aug 2012 06:56:27 +0000 Received: from hqemgate03.nvidia.com ([216.228.121.140]) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1T6cCQ-0008EZ-5I for linaro-mm-sig@lists.linaro.org; Wed, 29 Aug 2012 06:56:26 +0000 Received: from hqnvupgp06.nvidia.com (Not Verified[216.228.121.13]) by hqemgate03.nvidia.com id ; Tue, 28 Aug 2012 23:57:38 -0700 Received: from hqemhub01.nvidia.com ([172.17.108.22]) by hqnvupgp06.nvidia.com (PGP Universal service); Tue, 28 Aug 2012 23:56:17 -0700 X-PGP-Universal: processed; by hqnvupgp06.nvidia.com on Tue, 28 Aug 2012 23:56:17 -0700 Received: from hqnvemgw02.nvidia.com (172.16.227.111) by hqemhub01.nvidia.com (172.20.150.30) with Microsoft SMTP Server id 8.3.264.0; Tue, 28 Aug 2012 23:56:16 -0700 Received: from daphne.nvidia.com (Not Verified[172.16.212.96]) by hqnvemgw02.nvidia.com with MailMarshal (v6,7,2,8378) id ; Tue, 28 Aug 2012 23:56:26 -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 q7T6tkpo016768; Tue, 28 Aug 2012 23:56:12 -0700 (PDT) From: Hiroshi Doyu To: Date: Wed, 29 Aug 2012 09:55:35 +0300 Message-ID: <1346223335-31455-6-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 5/5] ARM: dma-mapping: Introduce dma_map_linear_attrs() for IOVA linear map 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: ALoCoQmIiOKly454sMa04Z64/sswAnXMybQPXhLIjQ2UUR0PGQi6HUDeq1hQRJv5Bpk2udKIvi+V Introduce a helper function, dma_map_linear(_attrs)() to create IOVA linear map, where IOVA and kernel virtual addresses are mapped at the same address linearly. This is useful to support legacy device drivers which expects no IOMMU. Signed-off-by: Hiroshi Doyu --- arch/arm/include/asm/dma-mapping.h | 13 +++++++++++++ include/asm-generic/dma-mapping-common.h | 1 + 2 files changed, 14 insertions(+), 0 deletions(-) diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h index f04a533..7a78dd4 100644 --- a/arch/arm/include/asm/dma-mapping.h +++ b/arch/arm/include/asm/dma-mapping.h @@ -212,6 +212,19 @@ static inline size_t dma_iova_get_free_max(struct device *dev) return ops->iova_get_free_max(dev); } +static inline dma_addr_t dma_map_linear_attrs(struct device *dev, void *va, + size_t size, enum dma_data_direction dir, + struct dma_attrs *attrs) +{ + dma_addr_t da; + + da = dma_iova_alloc_at(dev, (dma_addr_t)va, size); + if (da == DMA_ERROR_CODE) + return DMA_ERROR_CODE; + + return dma_map_single_at_attrs(dev, va, da, size, dir, attrs); +} + /** * arm_dma_mmap - map a coherent DMA allocation into user space * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices diff --git a/include/asm-generic/dma-mapping-common.h b/include/asm-generic/dma-mapping-common.h index eada2d8..4564bf0 100644 --- a/include/asm-generic/dma-mapping-common.h +++ b/include/asm-generic/dma-mapping-common.h @@ -191,6 +191,7 @@ 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_map_linear(d, a, s, r) dma_map_linear_attrs(d, a, 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)