From patchwork Tue Aug 5 10:47:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 34916 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f72.google.com (mail-pa0-f72.google.com [209.85.220.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1202F20523 for ; Tue, 5 Aug 2014 10:49:32 +0000 (UTC) Received: by mail-pa0-f72.google.com with SMTP id eu11sf5064529pac.3 for ; Tue, 05 Aug 2014 03:49:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list:content-type :content-transfer-encoding; bh=+FRdxOFG8sbY2sZ5wzYtetHio9Vu5GDI2DMsGsKR9aE=; b=Ab6K+4xuIdV12LcetvbEZbrCuyfiGgMj8DpiGdRiAgf4Jjn8YgArz+xj9K37yGSM8+ Fs4WdERVXHazd1qHoehB4MBF7d94Dhl28fqyFhS5/TYMTXfS6+6jrD36CsRIzyWibltu 88YGHJY6plfPY7ORR97+HFFeeWdOR9beFm4kCg7Aw30bxI/uFgZzXylgMLJ6AheEkYam 5OTwjMTdMnxDwrdeP8jtQQosbjqDC/p21qWcAu6WXNfntPUq721ZW1ci4XNL0r/kQJdK iLsBYB1yIocsgPu8XnFU2rj9SB/RKtzKelHiskwLT0Ir3KNHz8MV7fT2bZ9D8zSWvpp1 jjrw== X-Gm-Message-State: ALoCoQloUXQyBTGzhxRmuo0s2IX50K3Xe6juf6zilxSHgI054Eh6Fq8v0PXW8HrOtHjO+57YRmo3 X-Received: by 10.66.141.48 with SMTP id rl16mr1486447pab.1.1407235771371; Tue, 05 Aug 2014 03:49:31 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.25.144 with SMTP id 16ls220181qgt.45.gmail; Tue, 05 Aug 2014 03:49:31 -0700 (PDT) X-Received: by 10.221.68.66 with SMTP id xx2mr2341326vcb.1.1407235771202; Tue, 05 Aug 2014 03:49:31 -0700 (PDT) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id ti11si785377vdb.10.2014.08.05.03.49.31 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 05 Aug 2014 03:49:31 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.180 as permitted sender) client-ip=209.85.220.180; Received: by mail-vc0-f180.google.com with SMTP id ij19so1095096vcb.39 for ; Tue, 05 Aug 2014 03:49:31 -0700 (PDT) X-Received: by 10.221.47.9 with SMTP id uq9mr1018093vcb.48.1407235771122; Tue, 05 Aug 2014 03:49:31 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp374569vcb; Tue, 5 Aug 2014 03:49:30 -0700 (PDT) X-Received: by 10.140.98.195 with SMTP id o61mr3926213qge.41.1407235770607; Tue, 05 Aug 2014 03:49:30 -0700 (PDT) Received: from ip-10-141-164-156.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id t5si2119159qap.132.2014.08.05.03.49.30 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 05 Aug 2014 03:49:30 -0700 (PDT) Received-SPF: none (google.com: linaro-mm-sig-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-141-164-156.ec2.internal) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XEcJ7-0005Ix-IX; Tue, 05 Aug 2014 10:49:29 +0000 Received: from mailout4.w1.samsung.com ([210.118.77.14]) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XEcIb-0005Ed-Hy for linaro-mm-sig@lists.linaro.org; Tue, 05 Aug 2014 10:48:57 +0000 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N9T00BFOY19V200@mailout4.w1.samsung.com> for linaro-mm-sig@lists.linaro.org; Tue, 05 Aug 2014 11:48:46 +0100 (BST) X-AuditID: cbfec7f4-b7f156d0000063c7-b2-53e0b697f7a0 Received: from eusync3.samsung.com ( [203.254.199.213]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 9F.0C.25543.796B0E35; Tue, 05 Aug 2014 11:48:55 +0100 (BST) Received: from amdc1339.digital.local ([106.116.147.30]) by eusync3.samsung.com (Oracle Communications Messaging Server 7u4-23.01 (7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0N9T0057MY17SE80@eusync3.samsung.com>; Tue, 05 Aug 2014 11:48:55 +0100 (BST) From: Marek Szyprowski To: iommu@lists.linux-foundation.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Date: Tue, 05 Aug 2014 12:47:36 +0200 Message-id: <1407235677-26324-9-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.2 In-reply-to: <1407235677-26324-1-git-send-email-m.szyprowski@samsung.com> References: <1407235677-26324-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOLMWRmVeSWpSXmKPExsVy+t/xq7rTtz0INnixy9zi76Rj7BbNi9ez WUy6P4HFYsF+a4vO2RvYLXoXXGWzONv0ht2ic+ISdosvVx4yWWx6fI3V4vKuOWwWM87vY7JY e+Quu8Wp65/ZLP71HmS0OHP6EqvF/z072C0Ov2lntTjycDe7xapdfxgtbv/mcxD1eHJwHpPH 71+TGD12zrrL7jG7Yyarx6ZVnWwe++euYffYvKTe4/a/x8wek28sZ/S4cqKJ1aO3+R2bx5ar 7SwefVtWMXp83iQXwBfFZZOSmpNZllqkb5fAldG4XKhgsmBFz+4LbA2MZ/i6GDk5JARMJO6t XcACYYtJXLi3nq2LkYtDSGApo8SU6/OYIJw+JolzDQtZQarYBAwlut52gVWJCPQySvQ3/QCr YhZYxyqxv/c62CxhgWSJiWd3s4PYLAKqEncWPWACsXkFPCRebTjPDLFPTuL/yxVgcU4BT4nD Nw+AbRACqvm5YQ37BEbeBYwMqxhFU0uTC4qT0nMN9YoTc4tL89L1kvNzNzFCIufLDsbFx6wO MQpwMCrx8BqcvhssxJpYVlyZe4hRgoNZSYRXYs2DYCHelMTKqtSi/Pii0pzU4kOMTBycUg2M +uqvTNunTrh0wlzv6U0n2/vMM3inJR5S9yt+wZxmycxp6p6xK/OA3EPxZ0y3Tc9U/b9Y4Pb/ bsW3dqXbHs0SV1fPvyYxo37m2W3/dG4sfZ7IPnsKq3jLHvl11SHOr9mizW4w9W6wWZN+a+Kx C6zNSp3p7KeVH9pfO/clZPpP+T1uuyv8CpInKrEUZyQaajEXFScCAJzxRH16AgAA Cc: Rob Herring , Thierry Reding , Shaik Ameer Basha , Arnd Bergmann , Inki Dae , Greg Kroah-Hartman , Joerg Roedel , "Rafael J. Wysocki" , Tomasz Figa , linaro-mm-sig@lists.linaro.org, Kyungmin Park , Kukjin Kim , Laurent Pinchart , Sylwester Nawrocki , Olof Johansson , Cho KyongHo Subject: [Linaro-mm-sig] [PATCH 08/29] ARM: dma-mapping: add helpers for managing default per-device dma mappings X-BeenThere: linaro-mm-sig@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: linaro-mm-sig-bounces@lists.linaro.org Sender: linaro-mm-sig-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: m.szyprowski@samsung.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.180 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 This patch adds 2 helpers: arm_iommu_create_default_mapping and arm_iommu_release_default_mapping for managing default iommu-based dma-mapping address space, created for exlusive use only by the given device. Those helpers are convenient for setting up iommu-based dma-mapping for most typical devices in the system. Signed-off-by: Marek Szyprowski --- arch/arm/include/asm/dma-iommu.h | 5 +++++ arch/arm/mm/dma-mapping.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/arch/arm/include/asm/dma-iommu.h b/arch/arm/include/asm/dma-iommu.h index 8e3fcb9..ae3dac0 100644 --- a/arch/arm/include/asm/dma-iommu.h +++ b/arch/arm/include/asm/dma-iommu.h @@ -33,5 +33,10 @@ int arm_iommu_attach_device(struct device *dev, struct dma_iommu_mapping *mapping); void arm_iommu_detach_device(struct device *dev); +int arm_iommu_create_default_mapping(struct device *dev, dma_addr_t base, + size_t size); + +void arm_iommu_release_default_mapping(struct device *dev); + #endif /* __KERNEL__ */ #endif diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 8161102..233a8cf 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -2106,4 +2106,35 @@ void arm_iommu_detach_device(struct device *dev) } EXPORT_SYMBOL_GPL(arm_iommu_detach_device); +int arm_iommu_create_default_mapping(struct device *dev, dma_addr_t base, + size_t size) +{ + struct dma_iommu_mapping *mapping; + int ret; + + mapping = arm_iommu_create_mapping(dev->bus, base, size); + if (IS_ERR(mapping)) + return PTR_ERR(mapping); + + ret = arm_iommu_attach_device(dev, mapping); + if (ret) { + arm_iommu_release_mapping(mapping); + return ret; + } + + return 0; +} +EXPORT_SYMBOL_GPL(arm_iommu_create_default_mapping); + +void arm_iommu_release_default_mapping(struct device *dev) +{ + struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(dev); + if (!mapping) + return; + + arm_iommu_detach_device(dev); + arm_iommu_release_mapping(mapping); +} +EXPORT_SYMBOL_GPL(arm_iommu_release_default_mapping); + #endif