Rather than supplying a __weak hook which architectures which support
highmem can overide simply provide a version of swiotlb_bus_to_virt
which works with high memory. Make it conditional since it is a more
expensive variant than the non-highmem version.

Acutal function contents taken from the PowerPC swiotlb patchset by
Becky Bruce.

Signed-off-by: Ian Campbell <ian.campb...@citrix.com>
Cc: Becky Bruce <bec...@kernel.crashing.org>
Cc: Benjamin Herrenschmidt <b...@kernel.crashing.org>
Cc: Kumar Gala <ga...@kernel.crashing.org>
Cc: FUJITA Tomonori <fujita.tomon...@lab.ntt.co.jp>
Cc: Ingo Molnar <mi...@elte.hu>
Cc: Jeremy Fitzhardinge <jer...@goop.org>
Cc: linuxppc-dev@ozlabs.org
---
 lib/swiotlb.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index d37499b..d2b296a 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -130,9 +130,18 @@ static dma_addr_t swiotlb_virt_to_bus(struct device *hwdev,
        return phys_to_dma(hwdev, virt_to_phys(address));
 }
 
-void * __weak swiotlb_bus_to_virt(struct device *hwdev, dma_addr_t address)
+static void *swiotlb_bus_to_virt(struct device *hwdev, dma_addr_t address)
 {
+#ifdef CONFIG_HIGHMEM
+       unsigned long pfn = PFN_DOWN(dma_to_phys(hwdev, address));
+       void *pageaddr = page_address(pfn_to_page(pfn));
+
+       if (pageaddr != NULL)
+               return pageaddr + (address % PAGE_SIZE);
+       return NULL;
+#else
        return phys_to_virt(dma_to_phys(hwdev, address));
+#endif
 }
 
 static void swiotlb_print_info(unsigned long bytes)
-- 
1.5.6.5

_______________________________________________
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev

Reply via email to