[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190326224959.9656-4-nicoleotsuka@gmail.com>
Date: Tue, 26 Mar 2019 15:49:57 -0700
From: Nicolin Chen <nicoleotsuka@...il.com>
To: hch@....de, robin.murphy@....com
Cc: vdumpa@...dia.com, linux@...linux.org.uk, catalin.marinas@....com,
will.deacon@....com, joro@...tes.org, m.szyprowski@...sung.com,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
iommu@...ts.linux-foundation.org, tony@...mide.com
Subject: [PATCH RFC/RFT 3/5] iommu: amd_iommu: Add fallback normal page allocations
The CMA allocation will skip allocations of single pages to save CMA
resource. This requires its callers to rebound those page allocations
from normal area. So this patch adds fallback routines.
Note: amd_iommu driver uses dma_alloc_from_contiguous() as a fallback
allocation and uses alloc_pages() as its first round allocation.
This's in reverse order than other callers. So the alloc_pages()
added by this change becomes a second fallback, though it likely
won't succeed since the alloc_pages() has failed once.
Signed-off-by: Nicolin Chen <nicoleotsuka@...il.com>
---
drivers/iommu/amd_iommu.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index 21cb088d6687..2aa4818f5249 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -2701,6 +2701,9 @@ static void *alloc_coherent(struct device *dev, size_t size,
page = dma_alloc_from_contiguous(dev, size >> PAGE_SHIFT,
get_order(size), flag & __GFP_NOWARN);
+ if (!page)
+ page = alloc_pages(flag | __GFP_NOWARN,
+ get_order(size));
if (!page)
return NULL;
}
--
2.17.1
Powered by blists - more mailing lists