From: Christoph Hellwig <hch@lst.de>
To: Robin Murphy <robin.murphy@arm.com>
Cc: Vignesh Raghavendra <vigneshr@ti.com>,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
Russell King - ARM Linux admin <linux@armlinux.org.uk>,
linux-kernel@vger.kernel.org,
Peter Ujfalusi <peter.ujfalusi@ti.com>,
iommu@lists.linux-foundation.org, Christoph Hellwig <hch@lst.de>,
linux-arm-kernel@lists.infradead.org,
Roger Quadros <rogerq@ti.com>
Subject: Re: [PATCH 2/2] arm: use swiotlb for bounce buffer on LPAE configs
Date: Thu, 9 Jan 2020 15:49:20 +0100 [thread overview]
Message-ID: <20200109144920.GB22907@lst.de> (raw)
In-Reply-To: <0e6decce-c54e-9791-473e-0aef05650f39@arm.com>
On Wed, Jan 08, 2020 at 03:20:07PM +0000, Robin Murphy wrote:
>> The problem - I think - is that the DMA_BIT_MASK(32) from
>> dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32)) is treated as physical
>> address along the call path so the dma_pfn_offset is applied to it and
>> the check will fail, saying that DMA_BIT_MASK(32) can not be supported.
>
> But that's the thing - in isolation, that is entirely correct. Considering
> ZONE_DMA32 for simplicity, in general the zone is expected to cover the
> physical address range 0x0000_0000 - 0xffff_ffff (because DMA offsets are
> relatively rare), and a device with a dma_pfn_offset of more than
> (0x1_0000_0000 >> PAGE_SHIFT) *cannot* support that range with any mask,
> because the DMA address itself would have to be negative.
Note that ZONE_DMA32 is irrelevant in this particular case, as we are
talking about arm32. But with ZONE_DMA instead this roughly makes sense.
> The problem is that platforms with esoteric memory maps have no right thing
> to do. If the base of RAM is at at 0x1_0000_0000 or higher, the "correct"
> ZONE_DMA32 would be empty while ZONE_NORMAL above it would not, and last
> time I looked that makes the page allocator break badly. So the standard
> bodge on such platforms is to make ZONE_DMA32 cover not the first 4GB of
> *PA space*, but the first 4GB of *RAM*, wherever that happens to be. That
> then brings different problems - now the page allocator is happy and
> successfully returns GFP_DMA32 allocations from the range 0x8_0000_0000 -
> 0x8_ffff_ffff that are utterly useless to 32-bit devices with zero
> dma_pfn_offset - see the AMD Seattle SoC for the prime example of that. If
> on the other hand all devices are guaranteed to have a dma_pfn_offset that
> puts the base of RAM at DMA address 0 then GFP_DMA32 allocations do end up
> working as expected, but now the original assumption of where ZONE_DMA32
> actually is is broken, so generic code unaware of the
> platform/architecture-specific bodge will be misled - that's the case
> you're running into.
>
> Having thought this far, if there's a non-hacky way to reach in and grab
> ZONE_DMA{32} such that dma_direct_supported() could use zone_end_pfn()
> instead of trying to assume either way, that might be the most robust
> general solution.
zone_dma_bits is our somewhat ugly way to try to poke into this
information, although the way it is done right now sucks pretty badly.
The patch I sent to Peter in December was trying to convey that
information in a way similar to what the arm32 legacy dma code does, but
it didn't work, so I'll need to find some time to sit down and figure out
why.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2020-01-09 14:49 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-09 14:20 add swiotlb support to arm32 Christoph Hellwig
2019-07-09 14:20 ` [PATCH 1/2] dma-mapping check pfn validity in dma_common_{mmap, get_sgtable} Christoph Hellwig
2019-07-09 14:20 ` [PATCH 2/2] arm: use swiotlb for bounce buffer on LPAE configs Christoph Hellwig
2019-07-24 17:23 ` Nicolas Saenz Julienne
2019-07-24 17:55 ` Christoph Hellwig
2019-12-19 13:10 ` Peter Ujfalusi via iommu
2019-12-19 15:02 ` Christoph Hellwig
2019-12-19 15:20 ` Peter Ujfalusi via iommu
2020-01-08 8:28 ` Peter Ujfalusi via iommu
2020-01-08 12:21 ` Robin Murphy
2020-01-08 14:00 ` Peter Ujfalusi via iommu
2020-01-08 15:20 ` Robin Murphy
2020-01-09 14:49 ` Christoph Hellwig [this message]
2020-01-14 10:43 ` Peter Ujfalusi via iommu
2020-01-14 16:43 ` [PoC] arm: dma-mapping: direct: Apply dma_pfn_offset only when it is valid Peter Ujfalusi via iommu
2020-01-14 18:19 ` Robin Murphy
2020-01-15 11:50 ` Peter Ujfalusi via iommu
2020-01-16 19:13 ` Robin Murphy
2020-01-27 14:00 ` Peter Ujfalusi via iommu
2020-01-30 7:53 ` Christoph Hellwig
2020-01-30 13:04 ` Peter Ujfalusi via iommu
2020-01-30 16:40 ` Christoph Hellwig
2020-01-31 13:59 ` Peter Ujfalusi via iommu
2020-01-31 14:00 ` Peter Ujfalusi via iommu
2020-01-31 14:00 ` Peter Ujfalusi via iommu
2020-02-03 17:08 ` Christoph Hellwig
2020-02-05 10:19 ` Peter Ujfalusi via iommu
2019-07-17 13:21 ` add swiotlb support to arm32 Vignesh Raghavendra via iommu
2019-07-19 12:33 ` Christoph Hellwig
2019-07-24 15:37 ` 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=20200109144920.GB22907@lst.de \
--to=hch@lst.de \
--cc=iommu@lists.linux-foundation.org \
--cc=konrad.wilk@oracle.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=peter.ujfalusi@ti.com \
--cc=robin.murphy@arm.com \
--cc=rogerq@ti.com \
--cc=vigneshr@ti.com \
/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).