u-boot/drivers/iommu/sandbox_iommu.c
Sughosh Ganu 727c4348d3 sandbox: iommu: remove lmb allocation in the driver
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@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2024-09-03 14:08:50 -06:00

52 lines
1.2 KiB
C

// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (C) 2021 Mark Kettenis <kettenis@openbsd.org>
*/
#include <dm.h>
#include <iommu.h>
#include <asm/io.h>
#include <asm/test.h>
#include <linux/sizes.h>
static dma_addr_t sandbox_iommu_map(struct udevice *dev, void *addr,
size_t size)
{
phys_addr_t paddr, dva;
phys_size_t psize, off;
paddr = ALIGN_DOWN(virt_to_phys(addr), SANDBOX_IOMMU_PAGE_SIZE);
off = virt_to_phys(addr) - paddr;
psize = ALIGN(size + off, SANDBOX_IOMMU_PAGE_SIZE);
dva = (phys_addr_t)SANDBOX_IOMMU_DVA_ADDR;
return dva + off;
}
static void sandbox_iommu_unmap(struct udevice *dev, dma_addr_t addr,
size_t size)
{
phys_addr_t dva;
phys_size_t psize;
dva = ALIGN_DOWN(addr, SANDBOX_IOMMU_PAGE_SIZE);
psize = size + (addr - dva);
psize = ALIGN(psize, SANDBOX_IOMMU_PAGE_SIZE);
}
static struct iommu_ops sandbox_iommu_ops = {
.map = sandbox_iommu_map,
.unmap = sandbox_iommu_unmap,
};
static const struct udevice_id sandbox_iommu_ids[] = {
{ .compatible = "sandbox,iommu" },
{ /* sentinel */ }
};
U_BOOT_DRIVER(sandbox_iommu) = {
.name = "sandbox_iommu",
.id = UCLASS_IOMMU,
.of_match = sandbox_iommu_ids,
.ops = &sandbox_iommu_ops,
};