Linux-ARM-Kernel Archive on
 help / color / Atom feed
From: Christoph Hellwig <>
To: Robin Murphy <>
Cc: "Niklas Söderlund" <>,, "Pawel Osciak" <>,
	"Russell King" <>,,,
	"Kyungmin Park" <>,
	"Mauro Carvalho Chehab" <>,, "Christoph Hellwig" <>,,
	"Marek Szyprowski" <>
Subject: Re: [PATCH 1/3] dma-mapping: remove the default map_resource implementation
Date: Mon, 14 Jan 2019 18:08:55 +0100
Message-ID: <> (raw)
In-Reply-To: <>

On Mon, Jan 14, 2019 at 01:12:33PM +0000, Robin Murphy wrote:
> Ignoring the offset was kind of intentional there, because at the time I 
> was primarily thinking about it in terms of the Keystone 2 platform where 
> the peripherals are all in the same place (0-2GB) in both the bus and CPU 
> physical address maps, and only the view of RAM differs between the two 
> (2-4GB vs. 32-34GB). However, on something like BCM283x, the peripherals 
> region is also offset from its bus address in the CPU view, but at a 
> *different* offset relative to that of RAM.

I was more thinking of the PCIe P2P case, where we need to apply a
consistent offset to translate between the CPU and the bus view.

But this isn't really used for PCIe P2P, so I guess keeping the original
sematics might be a better idea.  That being said the videobuf code seems
to rely on these offsets, so we might be between a rock and a hard place.

> Fortunately, I'm not aware of any platform which has a DMA engine behind an 
> IOMMU (and thus *needs* to use dma_map_resource() to avoid said IOMMU 
> blocking the slave device register reads/writes) and also has any nonzero 
> offsets, and AFAIK the IOMMU-less platforms above aren't using 
> dma_map_resource() at all, so this change shouldn't actually break 
> anything, but I guess we have a bit of a problem making it truly generic 
> and robust :(

Note that we don't actually use the code in this patch for ARM/ARM64
platforms with IOMMUs, as both the ARM and the ARM64 iommu code have
their own implementations of ->map_resource that actually program
the iommu (which at least for the PCIe P2P case would be wrong).

> Is this perhaps another shove in the direction of overhauling 
> dma_pfn_offset into an arbitrary "DMA ranges" lookup table?

It is long overdue anyway.

>>   		addr = ops->map_resource(dev, phys_addr, size, dir, attrs);
> Might it be reasonable to do:
> 	if (!dma_is_direct(ops) && ops->map_resource)
> 		addr = ops->map_resource(...);
> 	else
> 		addr = dma_direct_map_resource(...);
> and avoid having to explicitly wire up the dma_direct callback elsewhere?

No, I absolutely _want_ the callback explicitly wired up.  That is the
only way to ensure we actually intentionally support it and don't just
get a default that often won't work.  Same issue for ->mmap and

linux-arm-kernel mailing list

  reply index

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <>
2019-01-11 18:17 ` fix a layering violation in videobuf2 and improve dma_map_resource Christoph Hellwig
2019-01-11 18:17   ` [PATCH 1/3] dma-mapping: remove the default map_resource implementation Christoph Hellwig
2019-01-14 13:12     ` Robin Murphy
2019-01-14 17:08       ` Christoph Hellwig [this message]
2019-01-11 18:17   ` [PATCH 2/3] dma-mapping: don't BUG when calling dma_map_resource on RAM Christoph Hellwig
2019-01-14 14:16     ` Robin Murphy
2019-01-11 18:17   ` [PATCH 3/3] videobuf2: replace a layering violation with dma_map_resource Christoph Hellwig
2019-01-11 19:54     ` Mauro Carvalho Chehab
2019-01-14 10:31       ` Christoph Hellwig
2019-01-14 11:04         ` Mauro Carvalho Chehab
2019-01-14 11:12           ` Christoph Hellwig
2019-01-14 12:42     ` Marek Szyprowski
2019-01-17 17:21       ` Christoph Hellwig
2019-01-18  9:41         ` Marek Szyprowski
2019-01-31 15:31           ` Christoph Hellwig
2019-01-14 11:43   ` fix a layering violation in videobuf2 and improve dma_map_resource Marek Szyprowski
2019-01-18 11:37 fix a layering violation in videobuf2 and improve dma_map_resource v2 Christoph Hellwig
2019-01-18 11:37 ` [PATCH 1/3] dma-mapping: remove the default map_resource implementation Christoph Hellwig

Reply instructions:

You may reply publically 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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-ARM-Kernel Archive on

Archives are clonable:
	git clone --mirror linux-arm-kernel/git/0.git
	git clone --mirror linux-arm-kernel/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-arm-kernel linux-arm-kernel/ \
	public-inbox-index linux-arm-kernel

Newsgroup available over NNTP:

AGPL code for this site: git clone public-inbox