Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp130718pxk; Tue, 15 Sep 2020 23:25:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjbkCOnfydkCmHLQI0w5onyKbMWpt/FXxOyDV/s3iq5B7DVJSb6MwwoVUFTcFJCutXP0Z0 X-Received: by 2002:a17:906:1185:: with SMTP id n5mr23968415eja.495.1600237534650; Tue, 15 Sep 2020 23:25:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600237534; cv=none; d=google.com; s=arc-20160816; b=C3wePCeDCuOWL0PJlt2kPTMOhCpL68oVMEsbjPGoDlBZ+gJTEa1qjgorIWMO3/tjT2 NNn2sMvKmAo6gVGwig+lpZEIMlX5mt1tlDkezwz83x4r5PmaImIBhANa9x6myD3qsjXc WO7ZrQeqtQkK/zRiUtc2WYTerXRZpXQV8VsLrrhnMuep/d7GaH827hXIPFg8bnBZMNOx 108hQ3Ho47pwdjybkON1bgp5pUJY9MP3eeJcJV+5ljawGjvwzvI+wnzYaaSTZRu795/0 FXl3HeuP4PhNIG++Dy2WqAmnVbMPArwHrOa9nXkH9bqWEHPf/nXdMCAGBqdPYPTczyd2 4z7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BxxgQYY1DeDYvu2hSRXigNNS2r5IsjvTJ3A6Bx2A/Zo=; b=JuVCvUAmSfkLe7WQpIPI5NTKwmv+w9PaYv3L9B7GRHi+v7PbWz1vMIdhnGFRDUeFzU Lg8jQe553YaYmjurOyCyPkEvWUCfUS7aaU516m3JSchjz5ZEAlOOKyymnAXsmwoUO9F9 i6Ljw5Rg5udGfiRWuG57dqLPEWoLYhCCitenZgFjpFOeDQ53ty4srFumy9W2pSjLwOYU b1aY7+EsUjvCaPgooPVAuqB90paSEAFpYgO+fckDVnZRokS1PjNq5w3kvPLxpTk/rKWs ZC/45CMhEwhOJTRGM15qt0wszKKb2FaBKagzC47xVwZYgTQx/Qxig69tfYvcPiX5956D tOYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=b6RjMPuX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h19si11025112ejl.253.2020.09.15.23.25.12; Tue, 15 Sep 2020 23:25:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=b6RjMPuX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726401AbgIPGXz (ORCPT + 99 others); Wed, 16 Sep 2020 02:23:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726193AbgIPGXw (ORCPT ); Wed, 16 Sep 2020 02:23:52 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D1FFC06174A; Tue, 15 Sep 2020 23:23:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=BxxgQYY1DeDYvu2hSRXigNNS2r5IsjvTJ3A6Bx2A/Zo=; b=b6RjMPuXBPV1L2xq/9cSN/gZIL pDJ+Ogdkdog3WRMBnL/liSbsVIm+1nFp14fjm5I64vhHz9+kGkq0qLF52sisZUBwipshSOdD0191S VDdtGyd17p1iEYZLfSzwwXKxUhaHHAG+JvnN90NH93XE9E1hMEzKe71YVfkU0Dgg62wMVl8xjEoCf 5+m431sx66nExg52nA9tSj2LwJS3c1e1Xw0Q+eWPX44rHDpNRvMcn6HNNZ0sDFWW7GknRQkxrzcVY Z2Jlrh0MAymYlnYS9SkQSDh9shV3+9w6+Qb0BsQMvh0xi5T5YgBzH+zZViLK00ocpbknb5tvsu620 cDacfLGA==; Received: from 089144214092.atnat0023.highway.a1.net ([89.144.214.92] helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIQr2-0007LO-Jc; Wed, 16 Sep 2020 06:23:44 +0000 From: Christoph Hellwig To: iommu@lists.linux-foundation.org, Russell King , Santosh Shilimkar , Greg Kroah-Hartman Cc: Jim Quinlan , Nathan Chancellor , Florian Fainelli , Robin Murphy , Rob Herring , Frank Rowand , Ohad Ben-Cohen , Bjorn Andersson , linux-remoteproc@vger.kernel.org, linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-sh@vger.kernel.org, linux-pci@vger.kernel.org, linux-acpi@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 3/6] ARM/dma-mapping: move various helpers from dma-mapping.h to dma-direct.h Date: Wed, 16 Sep 2020 08:14:56 +0200 Message-Id: <20200916061500.1970090-4-hch@lst.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200916061500.1970090-1-hch@lst.de> References: <20200916061500.1970090-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move the helpers to translate to and from direct mapping DMA addresses to dma-direct.h. This not only is the most logical place, but the new placement also avoids dependency loops with pending commits. Signed-off-by: Christoph Hellwig Reviewed-by: Robin Murphy --- arch/arm/common/dmabounce.c | 2 +- arch/arm/include/asm/dma-direct.h | 50 ++++++++++++++++++++++++++++++ arch/arm/include/asm/dma-mapping.h | 50 ------------------------------ 3 files changed, 51 insertions(+), 51 deletions(-) diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c index f4b719bde76367..d3e00ea9208834 100644 --- a/arch/arm/common/dmabounce.c +++ b/arch/arm/common/dmabounce.c @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/arm/include/asm/dma-direct.h b/arch/arm/include/asm/dma-direct.h index bca0de56753439..fbcf4367b5cb1a 100644 --- a/arch/arm/include/asm/dma-direct.h +++ b/arch/arm/include/asm/dma-direct.h @@ -2,6 +2,56 @@ #ifndef ASM_ARM_DMA_DIRECT_H #define ASM_ARM_DMA_DIRECT_H 1 +#include + +/* + * dma_to_pfn/pfn_to_dma/virt_to_dma are architecture private + * functions used internally by the DMA-mapping API to provide DMA + * addresses. They must not be used by drivers. + */ +#ifndef __arch_pfn_to_dma +static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn) +{ + if (dev) + pfn -= dev->dma_pfn_offset; + return (dma_addr_t)__pfn_to_bus(pfn); +} + +static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr) +{ + unsigned long pfn = __bus_to_pfn(addr); + + if (dev) + pfn += dev->dma_pfn_offset; + + return pfn; +} + +static inline dma_addr_t virt_to_dma(struct device *dev, void *addr) +{ + if (dev) + return pfn_to_dma(dev, virt_to_pfn(addr)); + + return (dma_addr_t)__virt_to_bus((unsigned long)(addr)); +} + +#else +static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn) +{ + return __arch_pfn_to_dma(dev, pfn); +} + +static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr) +{ + return __arch_dma_to_pfn(dev, addr); +} + +static inline dma_addr_t virt_to_dma(struct device *dev, void *addr) +{ + return __arch_virt_to_dma(dev, addr); +} +#endif + static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr) { unsigned int offset = paddr & ~PAGE_MASK; diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h index cf2535fb8891f5..0a1a536368c3a4 100644 --- a/arch/arm/include/asm/dma-mapping.h +++ b/arch/arm/include/asm/dma-mapping.h @@ -8,8 +8,6 @@ #include #include -#include - #include #include @@ -23,54 +21,6 @@ static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus) return NULL; } -/* - * dma_to_pfn/pfn_to_dma/virt_to_dma are architecture private - * functions used internally by the DMA-mapping API to provide DMA - * addresses. They must not be used by drivers. - */ -#ifndef __arch_pfn_to_dma -static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn) -{ - if (dev) - pfn -= dev->dma_pfn_offset; - return (dma_addr_t)__pfn_to_bus(pfn); -} - -static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr) -{ - unsigned long pfn = __bus_to_pfn(addr); - - if (dev) - pfn += dev->dma_pfn_offset; - - return pfn; -} - -static inline dma_addr_t virt_to_dma(struct device *dev, void *addr) -{ - if (dev) - return pfn_to_dma(dev, virt_to_pfn(addr)); - - return (dma_addr_t)__virt_to_bus((unsigned long)(addr)); -} - -#else -static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn) -{ - return __arch_pfn_to_dma(dev, pfn); -} - -static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr) -{ - return __arch_dma_to_pfn(dev, addr); -} - -static inline dma_addr_t virt_to_dma(struct device *dev, void *addr) -{ - return __arch_virt_to_dma(dev, addr); -} -#endif - /** * arm_dma_alloc - allocate consistent memory for DMA * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices -- 2.28.0