[PATCH 3/3] dma-mapping: use phys_to_dma in dma_direct_get_required

From: Christoph Hellwig
Date: Mon Sep 10 2018 - 02:13:50 EST


We need to apply an DMA offset for the function to work as expected.

Signed-off-by: Christoph Hellwig <hch@xxxxxx>
---
drivers/base/platform.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 7812b861b6da..6feac7294f8d 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -15,7 +15,7 @@
#include <linux/of_irq.h>
#include <linux/module.h>
#include <linux/init.h>
-#include <linux/dma-mapping.h>
+#include <linux/dma-direct.h>
#include <linux/bootmem.h>
#include <linux/err.h>
#include <linux/slab.h>
@@ -1185,7 +1185,7 @@ int __init platform_bus_init(void)
*/
u64 dma_direct_get_required_mask(struct device *dev)
{
- u64 end = ((max_pfn - 1) << PAGE_SHIFT);
+ u64 end = phys_to_dma(dev, (max_pfn - 1) << PAGE_SHIFT);

return (1 << (fls64(end) - 1)) * 2 - 1;
}
--
2.18.0