From patchwork Thu Apr 24 15:30:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Santosh Shilimkar X-Patchwork-Id: 28984 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f70.google.com (mail-yh0-f70.google.com [209.85.213.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5541D2036A for ; Thu, 24 Apr 2014 15:33:10 +0000 (UTC) Received: by mail-yh0-f70.google.com with SMTP id 29sf10343442yhl.9 for ; Thu, 24 Apr 2014 08:33:10 -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:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=fGs1CnTWuBhyaboDNun01RwmyVSRASnmDJbIyi0tAIg=; b=LVUaIPINcxUPldcGBhRVA/GcoCD46YIGqLFVUSzWvlqn7Hk7Vz6xaLPj98mmpk0SzT wwFyWGgTGMA6XL2gngjOQ7S0UyG45bsZugC2chmwLim5ypG8alyMcgxvV6qcktfYkSFq 4cjxaI2VYUyMQpa5R6cn0cEm2Sz9iyf2uhtTmK5sqSK1bJChoXim35XykZKUqV9/hzfW t4JKSZ+cXhxuszTPJfOVvhkE978CoeS8Vclt6KeZJv8OY8kW60wTMiAVRDjaFdW7oyR2 YkPepv7MN/n/agYc6jg50wb8spqG49QVaTfzIYABrJSUE2TB3Mq4CLa8UtBoQVht0Xy9 iDZg== X-Gm-Message-State: ALoCoQlzzBEkoVDZZ9VcrjQcWjHA4b2eBsz9/N9AM6vnEthnk6z9gm8gsjoXtHNTB0ramZa+34Gt X-Received: by 10.236.127.35 with SMTP id c23mr148768yhi.51.1398353590088; Thu, 24 Apr 2014 08:33:10 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.29.130 with SMTP id b2ls814594qgb.99.gmail; Thu, 24 Apr 2014 08:33:09 -0700 (PDT) X-Received: by 10.58.38.166 with SMTP id h6mr1686668vek.22.1398353589830; Thu, 24 Apr 2014 08:33:09 -0700 (PDT) Received: from mail-ve0-f175.google.com (mail-ve0-f175.google.com [209.85.128.175]) by mx.google.com with ESMTPS id sw4si1009558vdc.12.2014.04.24.08.33.09 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 24 Apr 2014 08:33:09 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.128.175; Received: by mail-ve0-f175.google.com with SMTP id oz11so3115256veb.20 for ; Thu, 24 Apr 2014 08:33:09 -0700 (PDT) X-Received: by 10.220.146.13 with SMTP id f13mr110977vcv.57.1398353589749; Thu, 24 Apr 2014 08:33:09 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp25483vcb; Thu, 24 Apr 2014 08:33:09 -0700 (PDT) X-Received: by 10.68.215.68 with SMTP id og4mr4338114pbc.112.1398353588809; Thu, 24 Apr 2014 08:33:08 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id iw3si2918280pac.96.2014.04.24.08.33.06; Thu, 24 Apr 2014 08:33:06 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758243AbaDXPc6 (ORCPT + 27 others); Thu, 24 Apr 2014 11:32:58 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:45674 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932074AbaDXPbn (ORCPT ); Thu, 24 Apr 2014 11:31:43 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id s3OFV23r004172; Thu, 24 Apr 2014 10:31:02 -0500 Received: from DLEE70.ent.ti.com (dlemailx.itg.ti.com [157.170.170.113]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s3OFV2Or012788; Thu, 24 Apr 2014 10:31:02 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.174.1; Thu, 24 Apr 2014 10:31:02 -0500 Received: from ula0393909.am.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id s3OFU9MB019851; Thu, 24 Apr 2014 10:31:01 -0500 From: Santosh Shilimkar To: CC: , , Grygorii Strashko , Greg Kroah-Hartman , Russell King , Arnd Bergmann , Olof Johansson , Grant Likely , Rob Herring , Catalin Marinas , Linus Walleij , Santosh Shilimkar Subject: [PATCH v3 5/7] ARM: dma: Use dma_pfn_offset for dma address translation Date: Thu, 24 Apr 2014 11:30:05 -0400 Message-ID: <1398353407-2345-6-git-send-email-santosh.shilimkar@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1398353407-2345-1-git-send-email-santosh.shilimkar@ti.com> References: <1398353407-2345-1-git-send-email-santosh.shilimkar@ti.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: santosh.shilimkar@ti.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) 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 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Grygorii Strashko In most of cases DMA addresses can be performed using offset value of Bus address space relatively to physical address space as following: PFN->DMA: __pfn_to_phys(pfn + [-]dma_pfn_offset) DMA->PFN: __phys_to_pfn(dma_addr) + [-]dma_pfn_offset Cc: Greg Kroah-Hartman Cc: Russell King Cc: Arnd Bergmann Cc: Olof Johansson Cc: Grant Likely Cc: Rob Herring Cc: Catalin Marinas Cc: Linus Walleij Signed-off-by: Grygorii Strashko Signed-off-by: Santosh Shilimkar Reviewed-by: Rob Herring --- arch/arm/include/asm/dma-mapping.h | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h index e701a4d..424fda9 100644 --- a/arch/arm/include/asm/dma-mapping.h +++ b/arch/arm/include/asm/dma-mapping.h @@ -58,22 +58,35 @@ static inline int dma_set_mask(struct device *dev, u64 mask) #ifndef __arch_pfn_to_dma static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn) { - return (dma_addr_t)__pfn_to_bus(pfn); + if (!dev) + return (dma_addr_t)__pfn_to_bus(pfn); + else + return (dma_addr_t)__pfn_to_bus(pfn - dev->dma_pfn_offset); } static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr) { - return __bus_to_pfn(addr); + if (!dev) + return __bus_to_pfn(addr); + else + return __bus_to_pfn(addr) + dev->dma_pfn_offset; } static inline void *dma_to_virt(struct device *dev, dma_addr_t addr) { - return (void *)__bus_to_virt((unsigned long)addr); + if (!dev) + return (void *)__bus_to_virt((unsigned long)addr); + else + return (void *)__bus_to_virt(__pfn_to_bus(dma_to_pfn(dev, addr))); } static inline dma_addr_t virt_to_dma(struct device *dev, void *addr) { - return (dma_addr_t)__virt_to_bus((unsigned long)(addr)); + if (!dev) + return (dma_addr_t)__virt_to_bus((unsigned long)(addr)); + else + return pfn_to_dma(dev, + __bus_to_pfn(__virt_to_bus((unsigned long)(addr)))); } #else