* [PATCH] mips: consolidate coherent and non-coherent dma_alloc code
@ 2017-06-16 7:12 Christoph Hellwig
2017-08-29 12:54 ` Ralf Baechle
0 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2017-06-16 7:12 UTC (permalink / raw)
To: ralf, linux-mips
Besides eliminating lots of duplication this also allows allocations with
the DMA_ATTR_NON_CONSISTENT to use the CMA allocator.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
Note: compile tested only.
arch/mips/mm/dma-default.c | 42 +++---------------------------------------
1 file changed, 3 insertions(+), 39 deletions(-)
diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c
index fe8df14b6169..9e0faaf9f96f 100644
--- a/arch/mips/mm/dma-default.c
+++ b/arch/mips/mm/dma-default.c
@@ -114,23 +114,6 @@ static gfp_t massage_gfp_flags(const struct device *dev, gfp_t gfp)
return gfp | dma_flag;
}
-static void *mips_dma_alloc_noncoherent(struct device *dev, size_t size,
- dma_addr_t * dma_handle, gfp_t gfp)
-{
- void *ret;
-
- gfp = massage_gfp_flags(dev, gfp);
-
- ret = (void *) __get_free_pages(gfp, get_order(size));
-
- if (ret != NULL) {
- memset(ret, 0, size);
- *dma_handle = plat_map_dma_mem(dev, ret, size);
- }
-
- return ret;
-}
-
static void *mips_dma_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *dma_handle, gfp_t gfp, unsigned long attrs)
{
@@ -138,13 +121,6 @@ static void *mips_dma_alloc_coherent(struct device *dev, size_t size,
struct page *page = NULL;
unsigned int count = PAGE_ALIGN(size) >> PAGE_SHIFT;
- /*
- * XXX: seems like the coherent and non-coherent implementations could
- * be consolidated.
- */
- if (attrs & DMA_ATTR_NON_CONSISTENT)
- return mips_dma_alloc_noncoherent(dev, size, dma_handle, gfp);
-
gfp = massage_gfp_flags(dev, gfp);
if (IS_ENABLED(CONFIG_DMA_CMA) && gfpflags_allow_blocking(gfp))
@@ -159,7 +135,8 @@ static void *mips_dma_alloc_coherent(struct device *dev, size_t size,
ret = page_address(page);
memset(ret, 0, size);
*dma_handle = plat_map_dma_mem(dev, ret, size);
- if (!plat_device_is_coherent(dev)) {
+ if (!(attrs & DMA_ATTR_NON_CONSISTENT) &&
+ !plat_device_is_coherent(dev)) {
dma_cache_wback_inv((unsigned long) ret, size);
ret = UNCAC_ADDR(ret);
}
@@ -167,14 +144,6 @@ static void *mips_dma_alloc_coherent(struct device *dev, size_t size,
return ret;
}
-
-static void mips_dma_free_noncoherent(struct device *dev, size_t size,
- void *vaddr, dma_addr_t dma_handle)
-{
- plat_unmap_dma_mem(dev, dma_handle, size, DMA_BIDIRECTIONAL);
- free_pages((unsigned long) vaddr, get_order(size));
-}
-
static void mips_dma_free_coherent(struct device *dev, size_t size, void *vaddr,
dma_addr_t dma_handle, unsigned long attrs)
{
@@ -182,14 +151,9 @@ static void mips_dma_free_coherent(struct device *dev, size_t size, void *vaddr,
unsigned int count = PAGE_ALIGN(size) >> PAGE_SHIFT;
struct page *page = NULL;
- if (attrs & DMA_ATTR_NON_CONSISTENT) {
- mips_dma_free_noncoherent(dev, size, vaddr, dma_handle);
- return;
- }
-
plat_unmap_dma_mem(dev, dma_handle, size, DMA_BIDIRECTIONAL);
- if (!plat_device_is_coherent(dev))
+ if (!(attrs & DMA_ATTR_NON_CONSISTENT) && !plat_device_is_coherent(dev))
addr = CAC_ADDR(addr);
page = virt_to_page((void *) addr);
--
2.11.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] mips: consolidate coherent and non-coherent dma_alloc code
2017-06-16 7:12 [PATCH] mips: consolidate coherent and non-coherent dma_alloc code Christoph Hellwig
@ 2017-08-29 12:54 ` Ralf Baechle
2017-08-29 12:59 ` Christoph Hellwig
0 siblings, 1 reply; 5+ messages in thread
From: Ralf Baechle @ 2017-08-29 12:54 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: linux-mips
On Fri, Jun 16, 2017 at 09:12:29AM +0200, Christoph Hellwig wrote:
> Besides eliminating lots of duplication this also allows allocations with
> the DMA_ATTR_NON_CONSISTENT to use the CMA allocator.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Ralf Baechle <ralf@linux-mips.org>
> Note: compile tested only.
Your change essentially reverts a change from Oct 2007 so it should work.
Ralf
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mips: consolidate coherent and non-coherent dma_alloc code
2017-08-29 12:54 ` Ralf Baechle
@ 2017-08-29 12:59 ` Christoph Hellwig
2017-08-29 13:18 ` Ralf Baechle
0 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2017-08-29 12:59 UTC (permalink / raw)
To: Ralf Baechle; +Cc: Christoph Hellwig, linux-mips
On Tue, Aug 29, 2017 at 02:54:55PM +0200, Ralf Baechle wrote:
> On Fri, Jun 16, 2017 at 09:12:29AM +0200, Christoph Hellwig wrote:
>
> > Besides eliminating lots of duplication this also allows allocations with
> > the DMA_ATTR_NON_CONSISTENT to use the CMA allocator.
> >
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
>
> Acked-by: Ralf Baechle <ralf@linux-mips.org>
I don't have anything that depends on it - do you just want to pick
it up in the mips tree?
> > Note: compile tested only.
>
> Your change essentially reverts a change from Oct 2007 so it should work.
Which commit is that? I can't find anything that looks related in the
Oct 2017 commits.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mips: consolidate coherent and non-coherent dma_alloc code
2017-08-29 12:59 ` Christoph Hellwig
@ 2017-08-29 13:18 ` Ralf Baechle
2017-08-29 13:20 ` Christoph Hellwig
0 siblings, 1 reply; 5+ messages in thread
From: Ralf Baechle @ 2017-08-29 13:18 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: linux-mips
On Tue, Aug 29, 2017 at 02:59:28PM +0200, Christoph Hellwig wrote:
> On Tue, Aug 29, 2017 at 02:54:55PM +0200, Ralf Baechle wrote:
> > On Fri, Jun 16, 2017 at 09:12:29AM +0200, Christoph Hellwig wrote:
> >
> > > Besides eliminating lots of duplication this also allows allocations with
> > > the DMA_ATTR_NON_CONSISTENT to use the CMA allocator.
> > >
> > > Signed-off-by: Christoph Hellwig <hch@lst.de>
> >
> > Acked-by: Ralf Baechle <ralf@linux-mips.org>
>
> I don't have anything that depends on it - do you just want to pick
> it up in the mips tree?
Sure, done.
> > > Note: compile tested only.
> >
> > Your change essentially reverts a change from Oct 2007 so it should work.
>
> Which commit is that? I can't find anything that looks related in the
> Oct 2017 commits.
Well, it predates the git history so it indeed is hard to find:
https://git.linux-mips.org/cgit/ralf/linux.git/commit/?id=7ca16d269a1a4b96d98968b48f137977bcab1522
Ralf
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mips: consolidate coherent and non-coherent dma_alloc code
2017-08-29 13:18 ` Ralf Baechle
@ 2017-08-29 13:20 ` Christoph Hellwig
0 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2017-08-29 13:20 UTC (permalink / raw)
To: Ralf Baechle; +Cc: Christoph Hellwig, linux-mips
On Tue, Aug 29, 2017 at 03:18:33PM +0200, Ralf Baechle wrote:
> > > Your change essentially reverts a change from Oct 2007 so it should work.
> >
> > Which commit is that? I can't find anything that looks related in the
> > Oct 2017 commits.
>
> Well, it predates the git history so it indeed is hard to find:
>
> https://git.linux-mips.org/cgit/ralf/linux.git/commit/?id=7ca16d269a1a4b96d98968b48f137977bcab1522
That looks like a different commit from a different series than the
one you replied to. But I'll happily take the ACK for that one :)
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-08-29 13:21 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-16 7:12 [PATCH] mips: consolidate coherent and non-coherent dma_alloc code Christoph Hellwig
2017-08-29 12:54 ` Ralf Baechle
2017-08-29 12:59 ` Christoph Hellwig
2017-08-29 13:18 ` Ralf Baechle
2017-08-29 13:20 ` Christoph Hellwig
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.