From patchwork Thu Mar 29 07:19:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hiroshi Doyu X-Patchwork-Id: 7518 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 BF9C223DE1 for ; Thu, 29 Mar 2012 07:19:52 +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 565A3A18578 for ; Thu, 29 Mar 2012 07:19:52 +0000 (UTC) Received: by iage36 with SMTP id e36so3573911iag.11 for ; Thu, 29 Mar 2012 00:19:51 -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:date:from:to:message-id:in-reply-to:references :x-mailer:x-nvconfidentiality: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=+wGFSwDohKF20v/aA+UYGqL/1ejOi29RxrfIID6MduA=; b=Fz7OKQuMCtiD9mGrb/jCkA0BSzwOUz8EO6HmM/U82AoEgWj7EyFXbcFPl96Yd0cNvY awrCnpAyJctt4o4LQSC73Yl0j9RzocXNHXGMUmNhKw/rm/L9LOo/krzyNaqu+H2zblO/ QuNap0nPCYPpkTA0o+oox1dAcvkxGO+T8PbffnAcNAF8pNuYCMoFThZhsf6DUq9mXp8n TlNp6f1mZ4kXmVQ385pko5QMzRAYQCImKIdcbss3OatI4IlmLDGocSpewYpwNmDdd1xh 9j1ZFF+Xvhymjyh9QRlgBPaoTElz7DehmnxP4OPIa3ycjSK+/M6jFC6Ml/BOfwpXPq80 MPtw== Received: by 10.50.46.195 with SMTP id x3mr679198igm.54.1333005591688; Thu, 29 Mar 2012 00:19:51 -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.231.5.205 with SMTP id 13csp23126ibw; Thu, 29 Mar 2012 00:19:50 -0700 (PDT) Received: by 10.180.82.132 with SMTP id i4mr2810930wiy.12.1333005584891; Thu, 29 Mar 2012 00:19:44 -0700 (PDT) Received: from mombin.canonical.com (mombin.canonical.com. [91.189.95.16]) by mx.google.com with ESMTP id u4si25780908wid.6.2012.03.29.00.19.37; Thu, 29 Mar 2012 00:19:44 -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 1SD9dv-0007w5-3g; Thu, 29 Mar 2012 07:19:35 +0000 Received: from hqemgate04.nvidia.com ([216.228.121.35]) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1SD9ds-0007uY-IY for linaro-mm-sig@lists.linaro.org; Thu, 29 Mar 2012 07:19:33 +0000 Received: from hqnvupgp06.nvidia.com (Not Verified[216.228.121.13]) by hqemgate04.nvidia.com id ; Thu, 29 Mar 2012 00:18:32 -0700 Received: from hqemhub01.nvidia.com ([172.17.108.22]) by hqnvupgp06.nvidia.com (PGP Universal service); Thu, 29 Mar 2012 00:19:30 -0700 X-PGP-Universal: processed; by hqnvupgp06.nvidia.com on Thu, 29 Mar 2012 00:19:30 -0700 Received: from deemhub01.nvidia.com (10.21.69.137) by hqemhub01.nvidia.com (172.20.150.30) with Microsoft SMTP Server (TLS) id 8.3.245.1; Thu, 29 Mar 2012 00:19:30 -0700 Received: from oreo (10.21.65.27) by deemhub01.nvidia.com (10.21.69.137) with Microsoft SMTP Server (TLS) id 8.3.245.1; Thu, 29 Mar 2012 09:19:28 +0200 Received: from oreo ([::1]) by oreo with smtp (Exim 4.76) (envelope-from ) id 1SD9dn-0007Wd-Iw; Thu, 29 Mar 2012 10:19:27 +0300 Date: Thu, 29 Mar 2012 10:19:27 +0300 From: Hiroshi Doyu To: Marek Szyprowski Message-ID: <20120329101927.8ab6b1993475b7e16ae2258f@nvidia.com> In-Reply-To: <1330527862-16234-10-git-send-email-m.szyprowski@samsung.com> References: <1330527862-16234-1-git-send-email-m.szyprowski@samsung.com> <1330527862-16234-10-git-send-email-m.szyprowski@samsung.com> X-Mailer: Sylpheed 3.2.0beta3 (GTK+ 2.24.6; x86_64-pc-linux-gnu) X-NVConfidentiality: public MIME-Version: 1.0 Cc: "linux-arch@vger.kernel.org" , "linux-samsung-soc@vger.kernel.org" , Shariq Hasnain , Arnd Bergmann , Benjamin Herrenschmidt , Russell King - ARM Linux , "linaro-mm-sig@lists.linaro.org" , "linux-mm@kvack.org" , "iommu@lists.linux-foundation.org" , Andrzej Pietrasiewicz , Kyungmin Park , KyongHo Cho , "linux-arm-kernel@lists.infradead.org" Subject: Re: [Linaro-mm-sig] [PATCHv7 9/9] ARM: dma-mapping: add support for IOMMU mapper 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: ALoCoQnWC0foR9gp4a/tKIfgJjFw1JTjWlPPvJPk5g8nHMeofVowWwLaA2DTwHXsTBv6khQ0w+Rb Hi Marek, On Wed, 29 Feb 2012 16:04:22 +0100 Marek Szyprowski wrote: > This patch add a complete implementation of DMA-mapping API for > devices that have IOMMU support. All DMA-mapping calls are supported. > > This patch contains some of the code kindly provided by Krishna Reddy > and Andrzej Pietrasiewicz > > Signed-off-by: Marek Szyprowski > Signed-off-by: Kyungmin Park > Reviewed-by: Konrad Rzeszutek Wilk > --- > arch/arm/Kconfig | 8 + > arch/arm/include/asm/device.h | 3 + > arch/arm/include/asm/dma-iommu.h | 34 ++ > arch/arm/mm/dma-mapping.c | 726 +++++++++++++++++++++++++++++++++++++- > arch/arm/mm/vmregion.h | 2 +- > 5 files changed, 758 insertions(+), 15 deletions(-) > create mode 100644 arch/arm/include/asm/dma-iommu.h > > +/* > + * Map a part of the scatter-gather list into contiguous io address space > + */ > +static int __map_sg_chunk(struct device *dev, struct scatterlist *sg, > + size_t size, dma_addr_t *handle, > + enum dma_data_direction dir) > +{ > + struct dma_iommu_mapping *mapping = dev->archdata.mapping; > + dma_addr_t iova, iova_base; > + int ret = 0; > + unsigned int count; > + struct scatterlist *s; > + > + size = PAGE_ALIGN(size); > + *handle = ARM_DMA_ERROR; > + > + iova_base = iova = __alloc_iova(mapping, size); > + if (iova == ARM_DMA_ERROR) > + return -ENOMEM; > + > + for (count = 0, s = sg; count < (size >> PAGE_SHIFT); s = sg_next(s)) > + { > + phys_addr_t phys = page_to_phys(sg_page(s)); > + unsigned int len = PAGE_ALIGN(s->offset + s->length); > + > + if (!arch_is_coherent()) > + __dma_page_cpu_to_dev(sg_page(s), s->offset, s->length, dir); > + > + ret = iommu_map(mapping->domain, iova, phys, len, 0); > + if (ret < 0) > + goto fail; > + count += len >> PAGE_SHIFT; > + iova += len; > + } > + *handle = iova_base; > + > + return 0; > +fail: > + iommu_unmap(mapping->domain, iova_base, count * PAGE_SIZE); > + __free_iova(mapping, iova_base, size); > + return ret; > +} Do we need to set dma_address as below? >From e8bcc3cdac5375b5d7f5ac5b3f716a11c1008f38 Mon Sep 17 00:00:00 2001 From: Hiroshi DOYU Date: Thu, 29 Mar 2012 09:59:04 +0300 Subject: [PATCH 1/1] ARM: dma-mapping: Fix dma_address in sglist s->dma_address wasn't set at mapping. Signed-off-by: Hiroshi DOYU --- arch/arm/mm/dma-mapping.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 3347c37..11a9d65 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -1111,6 +1111,8 @@ static int __map_sg_chunk(struct device *dev, struct scatterlist *sg, ret = iommu_map(mapping->domain, iova, phys, len, 0); if (ret < 0) goto fail; + s->dma_address = iova; + count += len >> PAGE_SHIFT; iova += len; }