From: Robin Murphy <robin.murphy@arm.com>
To: Christoph Hellwig <hch@lst.de>,
iommu@lists.linux-foundation.org,
Russell King <linux@armlinux.org.uk>,
Santosh Shilimkar <ssantosh@kernel.org>
Cc: devicetree@vger.kernel.org,
Florian Fainelli <f.fainelli@gmail.com>,
linux-sh@vger.kernel.org, linux-pci@vger.kernel.org,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-acpi@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
Jim Quinlan <james.quinlan@broadcom.com>,
Nathan Chancellor <natechancellor@gmail.com>,
Frank Rowand <frowand.list@gmail.com>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 1/3] ARM/dma-mapping: move various helpers from dma-mapping.h to dma-direct.h
Date: Thu, 10 Sep 2020 19:02:23 +0100 [thread overview]
Message-ID: <42497691-ec93-1e93-d3e5-e841eaf8247a@arm.com> (raw)
In-Reply-To: <20200910054038.324517-2-hch@lst.de>
On 2020-09-10 06:40, Christoph Hellwig wrote:
> 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.
For the straightforward move as it should be,
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
However I do wonder how much of this could be cleaned up further...
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> arch/arm/common/dmabounce.c | 2 +-
> arch/arm/include/asm/dma-direct.h | 70 ++++++++++++++++++++++++++++++
> arch/arm/include/asm/dma-mapping.h | 70 ------------------------------
> 3 files changed, 71 insertions(+), 71 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 <linux/slab.h>
> #include <linux/page-flags.h>
> #include <linux/device.h>
> -#include <linux/dma-mapping.h>
> +#include <linux/dma-direct.h>
> #include <linux/dmapool.h>
> #include <linux/list.h>
> #include <linux/scatterlist.h>
> diff --git a/arch/arm/include/asm/dma-direct.h b/arch/arm/include/asm/dma-direct.h
> index 7c3001a6a775bf..de0f4ff9279615 100644
> --- a/arch/arm/include/asm/dma-direct.h
> +++ b/arch/arm/include/asm/dma-direct.h
> @@ -2,6 +2,76 @@
> #ifndef ASM_ARM_DMA_DIRECT_H
> #define ASM_ARM_DMA_DIRECT_H 1
>
> +#include <asm/memory.h>
> +
> +#ifdef __arch_page_to_dma
> +#error Please update to __arch_pfn_to_dma
> +#endif
This must be long, long dead by now.
> +
> +/*
> + * dma_to_pfn/pfn_to_dma/dma_to_virt/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;
> +}
These are only overridden for OMAP1510, and it looks like it wouldn't
take much for the platform code or ohci-omap driver to set up a generic
DMA offset for the relevant device.
> +
> +static inline void *dma_to_virt(struct device *dev, dma_addr_t addr)
> +{
> + if (dev) {
> + unsigned long pfn = dma_to_pfn(dev, addr);
> +
> + return phys_to_virt(__pfn_to_phys(pfn));
> + }
> +
> + return (void *)__bus_to_virt((unsigned long)addr);
> +}
This appears entirely unused.
> +
> +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));
> +}
And this is only used for some debug prints in dmabounce.
Similarly the __bus_to_*()/__*_to_bus() calls themselves only appear
significant to mach-footbridge any more, and could probably also be
evolved into regular DMA offsets now that all API calls must have a
non-NULL device. I think I might come back and take a closer look at all
this at some point in future... :)
Robin.
> +
> +#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 void *dma_to_virt(struct device *dev, dma_addr_t addr)
> +{
> + return __arch_dma_to_virt(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 bdd80ddbca3451..0a1a536368c3a4 100644
> --- a/arch/arm/include/asm/dma-mapping.h
> +++ b/arch/arm/include/asm/dma-mapping.h
> @@ -8,8 +8,6 @@
> #include <linux/scatterlist.h>
> #include <linux/dma-debug.h>
>
> -#include <asm/memory.h>
> -
> #include <xen/xen.h>
> #include <asm/xen/hypervisor.h>
>
> @@ -23,74 +21,6 @@ static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
> return NULL;
> }
>
> -#ifdef __arch_page_to_dma
> -#error Please update to __arch_pfn_to_dma
> -#endif
> -
> -/*
> - * dma_to_pfn/pfn_to_dma/dma_to_virt/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 void *dma_to_virt(struct device *dev, dma_addr_t addr)
> -{
> - if (dev) {
> - unsigned long pfn = dma_to_pfn(dev, addr);
> -
> - return phys_to_virt(__pfn_to_phys(pfn));
> - }
> -
> - return (void *)__bus_to_virt((unsigned long)addr);
> -}
> -
> -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 void *dma_to_virt(struct device *dev, dma_addr_t addr)
> -{
> - return __arch_dma_to_virt(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
>
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2020-09-10 18:02 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-10 5:40 support range based offsets in dma-direct Christoph Hellwig
2020-09-10 5:40 ` [PATCH 1/3] ARM/dma-mapping: move various helpers from dma-mapping.h to dma-direct.h Christoph Hellwig
2020-09-10 18:02 ` Robin Murphy [this message]
2020-09-11 6:25 ` Christoph Hellwig
2020-09-10 5:40 ` [PATCH 2/3] ARM/keystone: move the DMA offset handling under ifdef CONFIG_ARM_LPAE Christoph Hellwig
2020-09-11 11:12 ` Robin Murphy
2020-09-11 11:15 ` Russell King - ARM Linux admin
2020-09-11 11:27 ` Robin Murphy
2020-09-11 18:00 ` santosh.shilimkar
2020-09-10 5:40 ` [PATCH 3/3] dma-mapping: introduce DMA range map, supplanting dma_pfn_offset Christoph Hellwig
2020-09-10 7:53 ` Greg KH
2020-09-10 9:13 ` Christoph Hellwig
2020-09-10 16:12 ` Greg KH
2020-09-11 16:12 ` Robin Murphy
2020-09-12 6:46 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=42497691-ec93-1e93-d3e5-e841eaf8247a@arm.com \
--to=robin.murphy@arm.com \
--cc=devicetree@vger.kernel.org \
--cc=f.fainelli@gmail.com \
--cc=frowand.list@gmail.com \
--cc=hch@lst.de \
--cc=iommu@lists.linux-foundation.org \
--cc=james.quinlan@broadcom.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=natechancellor@gmail.com \
--cc=robh+dt@kernel.org \
--cc=ssantosh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).