summaryrefslogtreecommitdiff
path: root/drivers/iommu/sandbox_iommu.c
diff options
context:
space:
mode:
authorSughosh Ganu <sughosh.ganu@linaro.org>2024-08-26 17:29:18 +0530
committerTom Rini <trini@konsulko.com>2024-09-03 14:08:50 -0600
commited17a33fed296a87219b0ff702045ce488bc3771 (patch)
treee1ac01002f7dcd0e1c1adbf5139234038ea58f8f /drivers/iommu/sandbox_iommu.c
parenta368850ae2551a4fcc5f9a2e9e8e90c056d4fe73 (diff)
lmb: make LMB memory map persistent and global
The current LMB API's for allocating and reserving memory use a per-caller based memory view. Memory allocated by a caller can then be overwritten by another caller. Make these allocations and reservations persistent using the alloced list data structure. Two alloced lists are declared -- one for the available(free) memory, and one for the used memory. Once full, the list can then be extended at runtime. [sjg: Use a stack to store pointer of lmb struct when running lmb tests] Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> Signed-off-by: Simon Glass <sjg@chromium.org> [sjg: Optimise the logic to add a region in lmb_add_region_flags()]
Diffstat (limited to 'drivers/iommu/sandbox_iommu.c')
-rw-r--r--drivers/iommu/sandbox_iommu.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/drivers/iommu/sandbox_iommu.c b/drivers/iommu/sandbox_iommu.c
index e37976f86f0..5b4a6a89824 100644
--- a/drivers/iommu/sandbox_iommu.c
+++ b/drivers/iommu/sandbox_iommu.c
@@ -11,14 +11,9 @@
#define IOMMU_PAGE_SIZE SZ_4K
-struct sandbox_iommu_priv {
- struct lmb lmb;
-};
-
static dma_addr_t sandbox_iommu_map(struct udevice *dev, void *addr,
size_t size)
{
- struct sandbox_iommu_priv *priv = dev_get_priv(dev);
phys_addr_t paddr, dva;
phys_size_t psize, off;
@@ -26,7 +21,7 @@ static dma_addr_t sandbox_iommu_map(struct udevice *dev, void *addr,
off = virt_to_phys(addr) - paddr;
psize = ALIGN(size + off, IOMMU_PAGE_SIZE);
- dva = lmb_alloc(&priv->lmb, psize, IOMMU_PAGE_SIZE);
+ dva = lmb_alloc(psize, IOMMU_PAGE_SIZE);
return dva + off;
}
@@ -34,7 +29,6 @@ static dma_addr_t sandbox_iommu_map(struct udevice *dev, void *addr,
static void sandbox_iommu_unmap(struct udevice *dev, dma_addr_t addr,
size_t size)
{
- struct sandbox_iommu_priv *priv = dev_get_priv(dev);
phys_addr_t dva;
phys_size_t psize;
@@ -42,7 +36,7 @@ static void sandbox_iommu_unmap(struct udevice *dev, dma_addr_t addr,
psize = size + (addr - dva);
psize = ALIGN(psize, IOMMU_PAGE_SIZE);
- lmb_free(&priv->lmb, dva, psize);
+ lmb_free(dva, psize);
}
static struct iommu_ops sandbox_iommu_ops = {
@@ -52,10 +46,7 @@ static struct iommu_ops sandbox_iommu_ops = {
static int sandbox_iommu_probe(struct udevice *dev)
{
- struct sandbox_iommu_priv *priv = dev_get_priv(dev);
-
- lmb_init(&priv->lmb);
- lmb_add(&priv->lmb, 0x89abc000, SZ_16K);
+ lmb_add(0x89abc000, SZ_16K);
return 0;
}
@@ -69,7 +60,6 @@ U_BOOT_DRIVER(sandbox_iommu) = {
.name = "sandbox_iommu",
.id = UCLASS_IOMMU,
.of_match = sandbox_iommu_ids,
- .priv_auto = sizeof(struct sandbox_iommu_priv),
.ops = &sandbox_iommu_ops,
.probe = sandbox_iommu_probe,
};