[PATCH 30/40] sandbox: iommu: remove lmb allocation in the driver

Sughosh Ganu sughosh.ganu at linaro.org
Wed Jul 24 08:02:14 CEST 2024


The sandbox iommu driver uses the LMB module to allocate a particular
range of memory for the device virtual address(DVA). This used to work
earlier since the LMB memory map was caller specific and not
global. But with the change to make the LMB allocations global and
persistent, adding this memory range has other side effects. On the
other hand, the sandbox iommu test expects to see this particular
value of the DVA. Use the DVA address directly, instead of mapping it
in the LMB memory map, and then have it allocated.

Signed-off-by: Sughosh Ganu <sughosh.ganu at linaro.org>
---
Changes since rfc: None

 drivers/iommu/sandbox_iommu.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/iommu/sandbox_iommu.c b/drivers/iommu/sandbox_iommu.c
index 505f2c3250..15ecaacbb3 100644
--- a/drivers/iommu/sandbox_iommu.c
+++ b/drivers/iommu/sandbox_iommu.c
@@ -5,10 +5,10 @@
 
 #include <dm.h>
 #include <iommu.h>
-#include <lmb.h>
 #include <asm/io.h>
 #include <linux/sizes.h>
 
+#define DVA_ADDR		0x89abc000
 #define IOMMU_PAGE_SIZE		SZ_4K
 
 static dma_addr_t sandbox_iommu_map(struct udevice *dev, void *addr,
@@ -20,8 +20,7 @@ static dma_addr_t sandbox_iommu_map(struct udevice *dev, void *addr,
 	paddr = ALIGN_DOWN(virt_to_phys(addr), IOMMU_PAGE_SIZE);
 	off = virt_to_phys(addr) - paddr;
 	psize = ALIGN(size + off, IOMMU_PAGE_SIZE);
-
-	dva = lmb_alloc(psize, IOMMU_PAGE_SIZE, LMB_NONE);
+	dva = (phys_addr_t)DVA_ADDR;
 
 	return dva + off;
 }
@@ -35,8 +34,6 @@ static void sandbox_iommu_unmap(struct udevice *dev, dma_addr_t addr,
 	dva = ALIGN_DOWN(addr, IOMMU_PAGE_SIZE);
 	psize = size + (addr - dva);
 	psize = ALIGN(psize, IOMMU_PAGE_SIZE);
-
-	lmb_free(dva, psize, LMB_NONE);
 }
 
 static struct iommu_ops sandbox_iommu_ops = {
@@ -46,8 +43,6 @@ static struct iommu_ops sandbox_iommu_ops = {
 
 static int sandbox_iommu_probe(struct udevice *dev)
 {
-	lmb_add(0x89abc000, SZ_16K, LMB_NONE);
-
 	return 0;
 }
 
-- 
2.34.1



More information about the U-Boot mailing list