From: Arnd Bergmann <arnd@arndb.de>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-doc@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Joerg Roedel <joro@8bytes.org>,
Randy Dunlap <rdunlap@infradead.org>,
Liviu Dudau <Liviu.Dudau@arm.com>,
linux-kernel@vger.kernel.org,
James Bottomley <jbottomley@parallels.com>,
linux-pci@vger.kernel.org, David Woodhouse <dwmw2@infradead.org>
Subject: Re: [PATCH v2 1/5] DMA-API: Clarify physical/bus address distinction
Date: Wed, 07 May 2014 09:37:04 +0200 [thread overview]
Message-ID: <4295045.447pOn727x@wuerfel> (raw)
In-Reply-To: <20140506224819.17968.2922.stgit@bhelgaas-glaptop.roam.corp.google.com>
On Tuesday 06 May 2014 16:48:19 Bjorn Helgaas wrote:
> The DMA-API documentation sometimes refers to "physical addresses" when it
> really means "bus addresses." Sometimes these are identical, but they may
> be different if the bridge leading to the bus performs address translation.
> Update the documentation to use "bus address" when appropriate.
>
> Also, consistently capitalize "DMA", use parens with function names, use
> dev_printk() in examples, and reword a few sections for clarity.
>
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Looks great!
Acked-by: Arnd Bergmann <arnd@arndb.de>
Just some minor comments that you may include if you like (my Ack
holds if you don't as well).
> @@ -30,16 +28,16 @@ hardware exists.
>
> Note that the DMA API works with any bus independent of the underlying
> microprocessor architecture. You should use the DMA API rather than
> -the bus specific DMA API (e.g. pci_dma_*).
> +the bus-specific DMA API (e.g. pci_dma_*).
It might make sense to change the example to dma_map_* rather than pci_dma_*,
which is rarely used these days. I think there was at one point a move
to replace remove the include/asm-generic/pci-dma-compat.h APIs.
> First of all, you should make sure
>
> #include <linux/dma-mapping.h>
>
> -is in your driver. This file will obtain for you the definition of the
> -dma_addr_t (which can hold any valid DMA address for the platform)
> -type which should be used everywhere you hold a DMA (bus) address
> -returned from the DMA mapping functions.
> +is in your driver, which provides the definition of dma_addr_t. This type
> +can hold any valid DMA or bus address for the platform and should be used
> +everywhere you hold a DMA address returned from the DMA mapping functions
> +or a bus address read from a device register such as a PCI BAR.
The PCI BAR example is misleading I think: While the raw value of the
BAR would be a dma_addr_t that can be used for pci-pci DMA, we normally
only deal with translated BARs from pci_resource_*, which would be
a resource_size_t in the same space as phys_addr_t, which has the
PCI mem_offset added in.
> + * A dma_addr_t can hold any valid DMA or bus address for the platform.
> + * It can be given to a device to use as a DMA source or target, or it may
> + * appear on the bus when a CPU performs programmed I/O. A CPU cannot
> + * reference a dma_addr_t directly because there may be translation between
> + * its physical address space and the bus address space.
On a similar note, I think the part 'or it may appear on the bus when a CPU
performs programmed I/O' is somewhat misleading: While true in theory, we
would never use a dma_addr_t to store an address to be used for PIO, because
the CPU needs to use either the phys_addr_t value associated with the physical
MMIO address or the __iomem pointer for the virtually mapped address.
Arnd
next prev parent reply other threads:[~2014-05-07 7:37 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-06 22:48 [PATCH v2 0/5] Clean up DMA API & IOMMU dma_addr_t usage Bjorn Helgaas
2014-05-06 22:48 ` [PATCH v2 1/5] DMA-API: Clarify physical/bus address distinction Bjorn Helgaas
2014-05-07 7:37 ` Arnd Bergmann [this message]
2014-05-07 18:43 ` Bjorn Helgaas
2014-05-08 9:24 ` Greg Kroah-Hartman
2014-05-06 22:48 ` [PATCH v2 2/5] DMA-API: Change dma_declare_coherent_memory() CPU address to phys_addr_t Bjorn Helgaas
2014-05-07 7:38 ` Arnd Bergmann
2014-05-06 22:48 ` [PATCH v2 3/5] sh/PCI: Pass GAPSPCI_DMA_BASE CPU address to dma_declare_coherent_memory() Bjorn Helgaas
2014-05-07 7:55 ` Arnd Bergmann
2014-05-07 8:15 ` Arnd Bergmann
2014-05-07 23:18 ` Bjorn Helgaas
2014-05-08 11:36 ` Arnd Bergmann
2014-05-06 22:48 ` [PATCH v2 4/5] iommu: Use dma_addr_t for IOVA arguments Bjorn Helgaas
2014-05-07 7:58 ` Arnd Bergmann
2014-05-08 0:18 ` Bjorn Helgaas
2014-05-08 10:44 ` Arnd Bergmann
2014-05-08 20:30 ` Bjorn Helgaas
2014-05-09 9:58 ` David Woodhouse
2014-05-09 15:32 ` Bjorn Helgaas
2014-05-09 19:52 ` Arnd Bergmann
2014-05-09 20:19 ` Bjorn Helgaas
2014-05-09 20:25 ` James Bottomley
2014-05-06 22:48 ` [PATCH v2 5/5] iommu/exynos: Remove unnecessary "&" from function pointers Bjorn Helgaas
2014-05-07 7:59 ` Arnd Bergmann
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=4295045.447pOn727x@wuerfel \
--to=arnd@arndb.de \
--cc=Liviu.Dudau@arm.com \
--cc=bhelgaas@google.com \
--cc=dwmw2@infradead.org \
--cc=gregkh@linuxfoundation.org \
--cc=jbottomley@parallels.com \
--cc=joro@8bytes.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=rdunlap@infradead.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