* [PATCH -mm 0/2] x86: fix DMA CMA on x86
@ 2014-04-20 12:39 Akinobu Mita
2014-04-20 12:39 ` [PATCH -mm 1/2] x86: fix dma_generic_alloc_coherent() when CONFIG_DMA_CMA is enabled Akinobu Mita
2014-04-20 12:39 ` [PATCH -mm 2/2] x86: avoid duplicated memset in dma_generic_alloc_coherent() Akinobu Mita
0 siblings, 2 replies; 3+ messages in thread
From: Akinobu Mita @ 2014-04-20 12:39 UTC (permalink / raw)
To: linux-kernel, akpm
Cc: Akinobu Mita, Marek Szyprowski, Konrad Rzeszutek Wilk,
David Woodhouse, Don Dutile, Thomas Gleixner, Ingo Molnar,
H. Peter Anvin, Andi Kleen, x86, iommu
This series includes two fixes for dma_generic_alloc_coherent(), based
on top of the patchset 'enhance DMA CMA on x86' which has been added
in -mm tree.
Akinobu Mita (2):
x86: fix dma_generic_alloc_coherent() when CONFIG_DMA_CMA is enabled
x86: avoid duplicated memset in dma_generic_alloc_coherent()
arch/x86/kernel/pci-dma.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Don Dutile <ddutile@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: x86@kernel.org
Cc: iommu@lists.linux-foundation.org
--
1.8.3.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH -mm 1/2] x86: fix dma_generic_alloc_coherent() when CONFIG_DMA_CMA is enabled
2014-04-20 12:39 [PATCH -mm 0/2] x86: fix DMA CMA on x86 Akinobu Mita
@ 2014-04-20 12:39 ` Akinobu Mita
2014-04-20 12:39 ` [PATCH -mm 2/2] x86: avoid duplicated memset in dma_generic_alloc_coherent() Akinobu Mita
1 sibling, 0 replies; 3+ messages in thread
From: Akinobu Mita @ 2014-04-20 12:39 UTC (permalink / raw)
To: linux-kernel, akpm
Cc: Akinobu Mita, Marek Szyprowski, Konrad Rzeszutek Wilk,
David Woodhouse, Don Dutile, Thomas Gleixner, Ingo Molnar,
H. Peter Anvin, Andi Kleen, x86, iommu
dma_generic_alloc_coherent() firstly attempts to allocate by
dma_alloc_from_contiguous() if CONFIG_DMA_CMA is enabled. But the memory
region allocated by it may not fit within the device's DMA mask.
This change makes it fall back to usual alloc_pages_node() allocation
for such cases.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Don Dutile <ddutile@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: x86@kernel.org
Cc: iommu@lists.linux-foundation.org
---
arch/x86/kernel/pci-dma.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index a0ffe44..f15bf8d 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -100,8 +100,13 @@ void *dma_generic_alloc_coherent(struct device *dev, size_t size,
again:
page = NULL;
/* CMA can be used only in the context which permits sleeping */
- if (flag & __GFP_WAIT)
+ if (flag & __GFP_WAIT) {
page = dma_alloc_from_contiguous(dev, count, get_order(size));
+ if (page && page_to_phys(page) + size > dma_mask) {
+ dma_release_from_contiguous(dev, page, count);
+ page = NULL;
+ }
+ }
/* fallback */
if (!page)
page = alloc_pages_node(dev_to_node(dev), flag, get_order(size));
--
1.8.3.2
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH -mm 2/2] x86: avoid duplicated memset in dma_generic_alloc_coherent()
2014-04-20 12:39 [PATCH -mm 0/2] x86: fix DMA CMA on x86 Akinobu Mita
2014-04-20 12:39 ` [PATCH -mm 1/2] x86: fix dma_generic_alloc_coherent() when CONFIG_DMA_CMA is enabled Akinobu Mita
@ 2014-04-20 12:39 ` Akinobu Mita
1 sibling, 0 replies; 3+ messages in thread
From: Akinobu Mita @ 2014-04-20 12:39 UTC (permalink / raw)
To: linux-kernel, akpm
Cc: Akinobu Mita, Marek Szyprowski, Konrad Rzeszutek Wilk,
David Woodhouse, Don Dutile, Thomas Gleixner, Ingo Molnar,
H. Peter Anvin, Andi Kleen, x86, iommu
This patch fixes duplicated memset that is introduced by the patch
x86-make-dma_alloc_coherent-return-zeroed-memory-if-cma-is-enabled.patch
in -mm tree, and this change should be folded into it.
If dma_generic_alloc_coherent() is called with __GFP_ZERO, it does a
duplicated memset to the memory area allocated by alloc_pages_node()
with __GFP_ZERO. This change fixes that inefficiency by clearing
__GFP_ZERO bit in gfp flages before calling alloc_pages_node(). Note
that dma_generic_alloc_coherent() always returns zeroed memory.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Don Dutile <ddutile@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: x86@kernel.org
Cc: iommu@lists.linux-foundation.org
---
arch/x86/kernel/pci-dma.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index f15bf8d..a25e202 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -97,6 +97,7 @@ void *dma_generic_alloc_coherent(struct device *dev, size_t size,
dma_mask = dma_alloc_coherent_mask(dev, flag);
+ flag &= ~__GFP_ZERO;
again:
page = NULL;
/* CMA can be used only in the context which permits sleeping */
--
1.8.3.2
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-04-20 12:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-20 12:39 [PATCH -mm 0/2] x86: fix DMA CMA on x86 Akinobu Mita
2014-04-20 12:39 ` [PATCH -mm 1/2] x86: fix dma_generic_alloc_coherent() when CONFIG_DMA_CMA is enabled Akinobu Mita
2014-04-20 12:39 ` [PATCH -mm 2/2] x86: avoid duplicated memset in dma_generic_alloc_coherent() Akinobu Mita
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®