Re: use generic DMA mapping code in powerpc V4

From: Christoph Hellwig
Date: Fri Jan 18 2019 - 07:18:14 EST


On Fri, Jan 18, 2019 at 01:07:54PM +0100, Christian Zigotzky wrote:
> git clone git://git.infradead.org/users/hch/misc.git -b powerpc-dma.6 a
>
> git checkout 257002094bc5935dd63207a380d9698ab81f0775
>
>
> I get the following error message with your patch:

Hmm. Did I attached the wrong patch? Here is the one I want and just
applied to that revision:

diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
index 355d16acee6d..e46c9b64ec0d 100644
--- a/kernel/dma/direct.c
+++ b/kernel/dma/direct.c
@@ -118,8 +118,11 @@ struct page *__dma_direct_alloc_pages(struct device *dev, size_t size,
page = NULL;
}
}
- if (!page)
+ if (!page) {
page = alloc_pages_node(dev_to_node(dev), gfp, page_order);
+ if (!page)
+ pr_warn("failed to allocate memory with gfp 0x%x\n", gfp);
+ }

if (page && !dma_coherent_ok(dev, page_to_phys(page), size)) {
__free_pages(page, page_order);
@@ -139,6 +142,10 @@ struct page *__dma_direct_alloc_pages(struct device *dev, size_t size,
}
}

+ if (!page) {
+ pr_warn("failed to allocate DMA memory!\n");
+ dump_stack();
+ }
return page;
}