PD#SWPL-11362
Problem:
A deadlock happens when a task initiates a CMA allocation that triggers
a page migration *AND* the tasks holding the subsequent pages have to
writeback their pages using CMA allocations.
In such a situation, the task that has triggered the page migration
holds a mutex that prevents other tasks from migrating their pages using
that same CMA allocator. This leads to a deadlock.
Solution:
The CMA is incapable of honoring the NOIO flags in some scenario, thus
cannot be used for writeback. The fix allows the code that chooses which
allocator to use in the ARM platform to avoid the CMA case for that
scenario.
The ARM DMA layer checks for allow blocking flag (_GFP_BDEV) to decide
whether to go for CMA or not. That test is not sufficient to cover the
case of writeback (GFP_NOIO).
The fix consists in adding a gfp_allow_writeback helper that tests for
the __GFP_IO flag. Then, the DMA layer uses it to decide not to go for
CMA in case of writeback.
Verify:
TL1
Change-Id: I175eb94de588234d3de2dc7f65dafe980e2636af
Signed-off-by: Yue Wang <yue.wang@amlogic.com>
*handle = DMA_ERROR_CODE;
allowblock = gfpflags_allow_blocking(gfp);
cma = allowblock ? dev_get_cma_area(dev) : false;
-
+#ifdef CONFIG_AMLOGIC_CMA
+ if (!!(gfp & __GFP_BDEV))
+ cma = false;
+#endif
if (cma)
buf->allocator = &cma_allocator;
else if (nommu() || is_coherent)
* process context, not interrupt context (or so documenation
* for usb_set_interface() and usb_set_configuration() claim).
*/
+#ifdef CONFIG_AMLOGIC_CMA
+ if (xhci_endpoint_init(xhci, virt_dev, udev, ep,
+ GFP_NOIO | __GFP_BDEV) < 0) {
+#else
if (xhci_endpoint_init(xhci, virt_dev, udev, ep, GFP_NOIO) < 0) {
+#endif
dev_dbg(&udev->dev, "%s - could not initialize ep %#x\n",
__func__, ep->desc.bEndpointAddress);
return -ENOMEM;