From: Russell King - ARM Linux <linux@arm.linux.org.uk> To: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Arnd Bergmann <arnd@arndb.de>, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [RFC] ARM DMA mapping TODO, v1 Date: Thu, 28 Apr 2011 10:37:41 +0100 [thread overview] Message-ID: <20110428093741.GV17290@n2100.arm.linux.org.uk> (raw) In-Reply-To: <1303940271.2513.187.camel@pasglop> On Thu, Apr 28, 2011 at 07:37:51AM +1000, Benjamin Herrenschmidt wrote: > On Wed, 2011-04-27 at 08:35 +0100, Russell King - ARM Linux wrote: > > On Thu, Apr 21, 2011 at 09:29:16PM +0200, Arnd Bergmann wrote: > > > 1. Fix the arm version of dma_alloc_coherent. It's in use today and > > > is broken on modern CPUs because it results in both cached and > > > uncached mappings. Rebecca suggested different approaches how to > > > get there. > > > > I also suggested various approaches and produced patches, which I'm slowly > > feeding in. However, I think whatever we do, we'll end up breaking > > something along the line - especially as various places assume that > > dma_alloc_coherent() is ultimately backed by memory with a struct page. > > Our implementation for embedded ppc has a similar problem. It currently > uses a pool of memory and does virtual mappings on it which means no > struct page easy to get to. How do you do on your side ? A fixed size > pool that you take out of the linear mapping ? Or you allocate pages in > the linear mapping and "unmap" them ? The problem I have with some > embedded ppc's is that the linear map is mapped in chunks of 256M or > so.... We don't - what I was referring to was people taking the DMA cookie and treating it as a physical address, converting it to a PFN and then doing pfn_to_page() on that. (Yes, it's been tried.) There have been some subsystems (eg ALSA) which also tried to use virt_to_page() on dma_alloc_coherent(), but I think those got fixed to use our dma_mmap_coherent() stuff when building on ARM. > > > 2. Implement dma_alloc_noncoherent on ARM. Marek pointed out > > > that this is needed, and it currently is not implemented, with > > > an outdated comment explaining why it used to not be possible > > > to do it. > > > > dma_alloc_noncoherent is an entirely pointless API afaics. > > I was about to ask what the point is ... (what is the expected > semantic ? Memory that is reachable but not necessarily cache > coherent ?) As far as I can see, dma_alloc_noncoherent() should just be a wrapper around the normal page allocation function. I don't see it ever needing to do anything special - and the advantage of just being the normal page allocation function is that its properties are well known and architecture independent. > > > 3. Convert ARM to use asm-generic/dma-mapping-common.h. We need > > > both IOMMU and direct mapped DMA on some machines. > > > > > > 4. Implement an architecture independent version of dma_map_ops > > > based on the iommu.h API. As Joerg mentioned, this has been > > > missing for some time, and it would be better to do it once > > > than for each IOMMU separately. This is probably a lot of work. > > > > dma_map_ops design is broken - we can't have the entire DMA API indirected > > through that structure. > > Why not ? That's the only way we can deal in my experience with multiple > type of different iommu's etc... at runtime in a single kernel. We used > to more/less have global function pointers in a long past but we moved > to per device ops instead to cope with multiple DMA path within a given > system and it works fine. > > > Whether you have an IOMMU or not is completely > > independent of whether you have to do DMA cache handling. Moreover, with > > dmabounce, having the DMA cache handling in place doesn't make sense. Here I've answered your question above. > Right. For now I don't have that problem on ppc as my iommu archs are > also fully coherent, so it's a bit more tricky that way but can be > handled I suppose by having the cache mgmnt be lib functions based on > flags added to the struct device. Think about stuffing all the iommu drivers with DMA cache management for ARM, and think about the maintainability for that when other folk come along and change the iommu drivers. I've no desire to keep going to fix them each time someone breaks the DMA cache management because everyone elses cache is DMA coherent. Keep that in the arch code, out of the dma_ops and it doesn't have to be thought about by each and every iommu driver. > > So you can't have a dma_map_ops for the cache handling bits, a dma_map_ops > > for IOMMU, and a dma_map_ops for the dmabounce stuff. It just doesn't > > work like that. > > Well, the dmabounce and cache handling is one implementation that's just > on/off with parameters no ?. iommu is different implementations. So the > ops should be for the iommu backends. The dmabounce & cache handling is > then done by those backends based on flags you stick in struct device > for example. You've completely missed the point.
WARNING: multiple messages have this Message-ID (diff)
From: linux@arm.linux.org.uk (Russell King - ARM Linux) To: linux-arm-kernel@lists.infradead.org Subject: [RFC] ARM DMA mapping TODO, v1 Date: Thu, 28 Apr 2011 10:37:41 +0100 [thread overview] Message-ID: <20110428093741.GV17290@n2100.arm.linux.org.uk> (raw) In-Reply-To: <1303940271.2513.187.camel@pasglop> On Thu, Apr 28, 2011 at 07:37:51AM +1000, Benjamin Herrenschmidt wrote: > On Wed, 2011-04-27 at 08:35 +0100, Russell King - ARM Linux wrote: > > On Thu, Apr 21, 2011 at 09:29:16PM +0200, Arnd Bergmann wrote: > > > 1. Fix the arm version of dma_alloc_coherent. It's in use today and > > > is broken on modern CPUs because it results in both cached and > > > uncached mappings. Rebecca suggested different approaches how to > > > get there. > > > > I also suggested various approaches and produced patches, which I'm slowly > > feeding in. However, I think whatever we do, we'll end up breaking > > something along the line - especially as various places assume that > > dma_alloc_coherent() is ultimately backed by memory with a struct page. > > Our implementation for embedded ppc has a similar problem. It currently > uses a pool of memory and does virtual mappings on it which means no > struct page easy to get to. How do you do on your side ? A fixed size > pool that you take out of the linear mapping ? Or you allocate pages in > the linear mapping and "unmap" them ? The problem I have with some > embedded ppc's is that the linear map is mapped in chunks of 256M or > so.... We don't - what I was referring to was people taking the DMA cookie and treating it as a physical address, converting it to a PFN and then doing pfn_to_page() on that. (Yes, it's been tried.) There have been some subsystems (eg ALSA) which also tried to use virt_to_page() on dma_alloc_coherent(), but I think those got fixed to use our dma_mmap_coherent() stuff when building on ARM. > > > 2. Implement dma_alloc_noncoherent on ARM. Marek pointed out > > > that this is needed, and it currently is not implemented, with > > > an outdated comment explaining why it used to not be possible > > > to do it. > > > > dma_alloc_noncoherent is an entirely pointless API afaics. > > I was about to ask what the point is ... (what is the expected > semantic ? Memory that is reachable but not necessarily cache > coherent ?) As far as I can see, dma_alloc_noncoherent() should just be a wrapper around the normal page allocation function. I don't see it ever needing to do anything special - and the advantage of just being the normal page allocation function is that its properties are well known and architecture independent. > > > 3. Convert ARM to use asm-generic/dma-mapping-common.h. We need > > > both IOMMU and direct mapped DMA on some machines. > > > > > > 4. Implement an architecture independent version of dma_map_ops > > > based on the iommu.h API. As Joerg mentioned, this has been > > > missing for some time, and it would be better to do it once > > > than for each IOMMU separately. This is probably a lot of work. > > > > dma_map_ops design is broken - we can't have the entire DMA API indirected > > through that structure. > > Why not ? That's the only way we can deal in my experience with multiple > type of different iommu's etc... at runtime in a single kernel. We used > to more/less have global function pointers in a long past but we moved > to per device ops instead to cope with multiple DMA path within a given > system and it works fine. > > > Whether you have an IOMMU or not is completely > > independent of whether you have to do DMA cache handling. Moreover, with > > dmabounce, having the DMA cache handling in place doesn't make sense. Here I've answered your question above. > Right. For now I don't have that problem on ppc as my iommu archs are > also fully coherent, so it's a bit more tricky that way but can be > handled I suppose by having the cache mgmnt be lib functions based on > flags added to the struct device. Think about stuffing all the iommu drivers with DMA cache management for ARM, and think about the maintainability for that when other folk come along and change the iommu drivers. I've no desire to keep going to fix them each time someone breaks the DMA cache management because everyone elses cache is DMA coherent. Keep that in the arch code, out of the dma_ops and it doesn't have to be thought about by each and every iommu driver. > > So you can't have a dma_map_ops for the cache handling bits, a dma_map_ops > > for IOMMU, and a dma_map_ops for the dmabounce stuff. It just doesn't > > work like that. > > Well, the dmabounce and cache handling is one implementation that's just > on/off with parameters no ?. iommu is different implementations. So the > ops should be for the iommu backends. The dmabounce & cache handling is > then done by those backends based on flags you stick in struct device > for example. You've completely missed the point.
next prev parent reply other threads:[~2011-04-28 9:37 UTC|newest] Thread overview: 196+ messages / expand[flat|nested] mbox.gz Atom feed top 2011-04-21 19:29 [RFC] ARM DMA mapping TODO, v1 Arnd Bergmann 2011-04-21 19:29 ` Arnd Bergmann 2011-04-21 20:09 ` [Linaro-mm-sig] " Jesse Barnes 2011-04-21 20:09 ` Jesse Barnes 2011-04-21 21:52 ` Zach Pfeffer 2011-04-21 21:52 ` Zach Pfeffer 2011-04-22 0:34 ` KyongHo Cho 2011-04-22 0:34 ` KyongHo Cho 2011-04-26 14:29 ` Arnd Bergmann 2011-04-26 14:29 ` Arnd Bergmann 2011-04-26 14:28 ` Arnd Bergmann 2011-04-26 14:28 ` Arnd Bergmann 2011-04-26 14:26 ` Arnd Bergmann 2011-04-26 14:26 ` Arnd Bergmann 2011-04-26 15:39 ` Jesse Barnes 2011-04-26 15:39 ` Jesse Barnes 2011-04-27 7:35 ` Russell King - ARM Linux 2011-04-27 7:35 ` Russell King - ARM Linux 2011-04-27 8:56 ` Arnd Bergmann 2011-04-27 8:56 ` Arnd Bergmann 2011-04-27 9:09 ` Russell King - ARM Linux 2011-04-27 9:09 ` Russell King - ARM Linux 2011-04-27 11:02 ` Arnd Bergmann 2011-04-27 11:02 ` Arnd Bergmann 2011-04-27 16:16 ` [Linaro-mm-sig] " Alex Deucher 2011-04-27 16:16 ` Alex Deucher 2011-04-27 17:44 ` Anca Emanuel 2011-04-27 17:44 ` Anca Emanuel 2011-04-27 20:27 ` Russell King - ARM Linux 2011-04-27 20:27 ` Russell King - ARM Linux 2011-04-27 20:16 ` Russell King - ARM Linux 2011-04-27 20:16 ` Russell King - ARM Linux 2011-04-27 20:21 ` Arnd Bergmann 2011-04-27 20:21 ` Arnd Bergmann 2011-04-27 20:26 ` Russell King - ARM Linux 2011-04-27 20:26 ` Russell King - ARM Linux 2011-04-27 20:48 ` Arnd Bergmann 2011-04-27 20:48 ` Arnd Bergmann 2011-04-27 21:41 ` Benjamin Herrenschmidt 2011-04-27 21:41 ` Benjamin Herrenschmidt 2011-04-28 9:30 ` Russell King - ARM Linux 2011-04-28 9:30 ` Russell King - ARM Linux 2011-04-28 21:07 ` Benjamin Herrenschmidt 2011-04-28 21:07 ` Benjamin Herrenschmidt 2011-04-29 11:26 ` Arnd Bergmann 2011-04-29 11:26 ` Arnd Bergmann 2011-04-29 11:47 ` Benjamin Herrenschmidt 2011-04-29 11:47 ` Benjamin Herrenschmidt 2011-04-29 11:56 ` Alan Cox 2011-04-29 11:56 ` Alan Cox 2011-04-29 22:51 ` Benjamin Herrenschmidt 2011-04-29 22:51 ` Benjamin Herrenschmidt 2011-04-29 12:06 ` [Linaro-mm-sig] " Thomas Hellstrom 2011-04-29 12:06 ` Thomas Hellstrom 2011-04-29 13:34 ` Jerome Glisse 2011-04-29 13:34 ` Jerome Glisse 2011-04-29 22:55 ` Benjamin Herrenschmidt 2011-04-29 22:55 ` Benjamin Herrenschmidt 2011-04-29 22:53 ` Benjamin Herrenschmidt 2011-04-29 22:53 ` Benjamin Herrenschmidt 2011-04-27 10:51 ` Marek Szyprowski 2011-04-27 10:51 ` Marek Szyprowski 2011-04-27 21:37 ` Benjamin Herrenschmidt 2011-04-27 21:37 ` Benjamin Herrenschmidt 2011-04-28 6:40 ` [Linaro-mm-sig] " Arnd Bergmann 2011-04-28 6:40 ` Arnd Bergmann 2011-04-28 6:46 ` FUJITA Tomonori 2011-04-28 6:46 ` FUJITA Tomonori 2011-04-28 9:37 ` Russell King - ARM Linux [this message] 2011-04-28 9:37 ` Russell King - ARM Linux 2011-04-28 10:32 ` [Linaro-mm-sig] " Marek Szyprowski 2011-04-28 10:32 ` Marek Szyprowski 2011-04-28 10:51 ` Russell King - ARM Linux 2011-04-28 10:51 ` Russell King - ARM Linux 2011-04-28 12:28 ` Arnd Bergmann 2011-04-28 12:28 ` Arnd Bergmann 2011-04-28 13:15 ` Russell King - ARM Linux 2011-04-28 13:15 ` Russell King - ARM Linux 2011-04-28 14:29 ` Arnd Bergmann 2011-04-28 14:29 ` Arnd Bergmann 2011-04-28 14:34 ` Russell King - ARM Linux 2011-04-28 14:34 ` Russell King - ARM Linux 2011-04-28 14:39 ` Arnd Bergmann 2011-04-28 14:39 ` Arnd Bergmann 2011-04-28 14:58 ` Russell King - ARM Linux 2011-04-28 14:58 ` Russell King - ARM Linux 2011-04-28 19:37 ` Jerome Glisse 2011-04-28 19:37 ` Jerome Glisse 2011-04-29 0:29 ` Benjamin Herrenschmidt 2011-04-29 0:29 ` Benjamin Herrenschmidt 2011-04-29 5:50 ` Thomas Hellstrom 2011-04-29 5:50 ` Thomas Hellstrom 2011-04-29 7:35 ` Benjamin Herrenschmidt 2011-04-29 7:35 ` Benjamin Herrenschmidt 2011-04-29 10:55 ` Thomas Hellstrom 2011-04-29 10:55 ` Thomas Hellstrom 2011-04-29 22:50 ` Benjamin Herrenschmidt 2011-04-29 22:50 ` Benjamin Herrenschmidt 2011-04-29 16:27 ` Jesse Barnes 2011-04-29 16:27 ` Jesse Barnes 2011-04-29 22:46 ` Benjamin Herrenschmidt 2011-04-29 22:46 ` Benjamin Herrenschmidt 2011-04-30 2:45 ` Jesse Barnes 2011-04-30 2:45 ` Jesse Barnes 2011-04-29 7:59 ` Russell King - ARM Linux 2011-04-29 7:59 ` Russell King - ARM Linux 2011-04-29 16:32 ` Jesse Barnes 2011-04-29 16:32 ` Jesse Barnes 2011-04-29 18:29 ` Arnd Bergmann 2011-04-29 18:29 ` Arnd Bergmann 2011-04-29 22:15 ` Russell King - ARM Linux 2011-04-29 22:15 ` Russell King - ARM Linux 2011-05-02 4:42 ` David Brown 2011-05-02 4:42 ` David Brown 2011-05-02 11:26 ` Arnd Bergmann 2011-05-02 11:26 ` Arnd Bergmann 2011-04-29 22:37 ` Benjamin Herrenschmidt 2011-04-29 22:37 ` Benjamin Herrenschmidt 2011-04-29 13:42 ` Joerg Roedel 2011-04-29 13:42 ` Joerg Roedel 2011-04-29 14:19 ` Jerome Glisse 2011-04-29 14:19 ` Jerome Glisse 2011-04-29 15:37 ` Jordan Crouse 2011-04-29 15:37 ` Jordan Crouse 2011-04-28 14:38 ` FUJITA Tomonori 2011-04-28 14:38 ` FUJITA Tomonori 2011-04-29 0:25 ` Benjamin Herrenschmidt 2011-04-29 0:25 ` Benjamin Herrenschmidt 2011-04-29 11:21 ` Arnd Bergmann 2011-04-29 11:21 ` Arnd Bergmann 2011-04-28 10:41 ` Joerg Roedel 2011-04-28 10:41 ` Joerg Roedel 2011-04-28 11:01 ` Russell King - ARM Linux 2011-04-28 11:01 ` Russell King - ARM Linux 2011-04-28 12:25 ` Joerg Roedel 2011-04-28 12:25 ` Joerg Roedel 2011-04-28 12:42 ` Russell King - ARM Linux 2011-04-28 12:42 ` Russell King - ARM Linux 2011-04-28 12:59 ` Joerg Roedel 2011-04-28 12:59 ` Joerg Roedel 2011-04-28 13:02 ` Arnd Bergmann 2011-04-28 13:02 ` Arnd Bergmann 2011-04-28 13:19 ` Russell King - ARM Linux 2011-04-28 13:19 ` Russell King - ARM Linux 2011-04-28 13:56 ` Joerg Roedel 2011-04-28 13:56 ` Joerg Roedel 2011-04-28 14:30 ` Russell King - ARM Linux 2011-04-28 14:30 ` Russell King - ARM Linux 2011-04-27 9:52 ` Catalin Marinas 2011-04-27 9:52 ` Catalin Marinas 2011-04-27 10:43 ` Arnd Bergmann 2011-04-27 10:43 ` Arnd Bergmann 2011-04-27 11:08 ` Catalin Marinas 2011-04-27 11:08 ` Catalin Marinas 2011-04-28 0:15 ` Valdis.Kletnieks 2011-04-28 0:15 ` Valdis.Kletnieks at vt.edu 2011-04-28 8:27 ` Catalin Marinas 2011-04-28 8:27 ` Catalin Marinas 2011-04-28 12:12 ` Arnd Bergmann 2011-04-28 12:12 ` Arnd Bergmann 2011-04-28 12:36 ` Russell King - ARM Linux 2011-04-28 12:36 ` Russell King - ARM Linux 2011-04-28 12:48 ` Arnd Bergmann 2011-04-28 12:48 ` Arnd Bergmann 2011-05-03 14:45 ` Dave Martin 2011-05-03 14:45 ` Dave Martin 2011-04-29 15:41 ` [Linaro-mm-sig] " Arnd Bergmann 2011-04-29 15:41 ` Arnd Bergmann 2011-04-29 16:42 ` Catalin Marinas 2011-04-29 16:42 ` Catalin Marinas 2011-05-03 15:05 ` [Linaro-mm-sig] " Laurent Pinchart 2011-05-03 15:05 ` Laurent Pinchart 2011-05-03 15:31 ` Arnd Bergmann 2011-05-03 15:31 ` Arnd Bergmann 2011-04-27 14:06 ` FUJITA Tomonori 2011-04-27 14:06 ` FUJITA Tomonori 2011-04-27 14:29 ` Catalin Marinas 2011-04-27 14:29 ` Catalin Marinas 2011-04-27 14:34 ` FUJITA Tomonori 2011-04-27 14:34 ` FUJITA Tomonori 2011-04-27 20:29 ` Russell King - ARM Linux 2011-04-27 20:29 ` Russell King - ARM Linux 2011-04-27 21:45 ` Benjamin Herrenschmidt 2011-04-27 21:45 ` Benjamin Herrenschmidt 2011-04-28 7:24 ` [Linaro-mm-sig] " KyongHo Cho 2011-04-28 7:24 ` KyongHo Cho 2011-04-28 8:31 ` Catalin Marinas 2011-04-28 8:31 ` Catalin Marinas 2011-04-27 21:31 ` Benjamin Herrenschmidt 2011-04-27 21:31 ` Benjamin Herrenschmidt 2011-04-28 9:42 ` Russell King - ARM Linux 2011-04-28 9:42 ` Russell King - ARM Linux 2011-04-28 10:27 ` Joerg Roedel 2011-04-28 10:27 ` Joerg Roedel 2011-04-28 12:15 ` Arnd Bergmann 2011-04-28 12:15 ` 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=20110428093741.GV17290@n2100.arm.linux.org.uk \ --to=linux@arm.linux.org.uk \ --cc=arnd@arndb.de \ --cc=benh@kernel.crashing.org \ --cc=linaro-mm-sig@lists.linaro.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.