* [PATCH -mm 0/2] x86: fix DMA CMA on x86
@ 2014-04-20 12:39 Akinobu Mita
[not found] ` <1397997587-11021-1-git-send-email-akinobu.mita-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Akinobu Mita @ 2014-04-20 12:39 UTC (permalink / raw)
To: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b
Cc: Andi Kleen, x86-DgEjT+Ai2ygdnm+yROfE0A, Akinobu Mita,
iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, Ingo Molnar,
H. Peter Anvin, Thomas Gleixner, David Woodhouse
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-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
Cc: Konrad Rzeszutek Wilk <konrad.wilk-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Cc: David Woodhouse <dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
Cc: Don Dutile <ddutile-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: Thomas Gleixner <tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
Cc: Ingo Molnar <mingo-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: "H. Peter Anvin" <hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>
Cc: Andi Kleen <andi-Vw/NltI1exuRpAAqCnN02g@public.gmane.org>
Cc: x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
--
1.8.3.2
^ permalink raw reply [flat|nested] 3+ messages in thread[parent not found: <1397997587-11021-1-git-send-email-akinobu.mita-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* [PATCH -mm 1/2] x86: fix dma_generic_alloc_coherent() when CONFIG_DMA_CMA is enabled [not found] ` <1397997587-11021-1-git-send-email-akinobu.mita-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 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-u79uwXL29TY76Z2rM5mHXA, akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b Cc: Andi Kleen, x86-DgEjT+Ai2ygdnm+yROfE0A, Akinobu Mita, iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, Ingo Molnar, H. Peter Anvin, Thomas Gleixner, David Woodhouse 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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Cc: Marek Szyprowski <m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> Cc: Konrad Rzeszutek Wilk <konrad.wilk-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> Cc: David Woodhouse <dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org> Cc: Don Dutile <ddutile-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> Cc: Thomas Gleixner <tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org> Cc: Ingo Molnar <mingo-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> Cc: "H. Peter Anvin" <hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org> Cc: Andi Kleen <andi-Vw/NltI1exuRpAAqCnN02g@public.gmane.org> Cc: x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.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 related [flat|nested] 3+ messages in thread
* [PATCH -mm 2/2] x86: avoid duplicated memset in dma_generic_alloc_coherent() [not found] ` <1397997587-11021-1-git-send-email-akinobu.mita-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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-u79uwXL29TY76Z2rM5mHXA, akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b Cc: Andi Kleen, x86-DgEjT+Ai2ygdnm+yROfE0A, Akinobu Mita, iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, Ingo Molnar, H. Peter Anvin, Thomas Gleixner, David Woodhouse 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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Cc: Marek Szyprowski <m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> Cc: Konrad Rzeszutek Wilk <konrad.wilk-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> Cc: David Woodhouse <dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org> Cc: Don Dutile <ddutile-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> Cc: Thomas Gleixner <tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org> Cc: Ingo Molnar <mingo-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> Cc: "H. Peter Anvin" <hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org> Cc: Andi Kleen <andi-Vw/NltI1exuRpAAqCnN02g@public.gmane.org> Cc: x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.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 related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-04-20 12:39 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
[not found] ` <1397997587-11021-1-git-send-email-akinobu.mita-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
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; as well as URLs for NNTP newsgroup(s).