Skip to content

Commit 9dda3f0

Browse files
jgunthorpejoergroedel
authored andcommitted
iommu/riscv: Update to use iommu_alloc_pages_node_lg2()
One part of RISCV already has a computed size, however the queue allocation must be aligned to 4k. The other objects are 4k by spec. Reviewed-by: Tomasz Jeznach <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 5faa04c commit 9dda3f0

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

drivers/iommu/riscv/iommu.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,14 @@ static int riscv_iommu_devres_pages_match(struct device *dev, void *res, void *p
6565
return devres->addr == target->addr;
6666
}
6767

68-
static void *riscv_iommu_get_pages(struct riscv_iommu_device *iommu, int order)
68+
static void *riscv_iommu_get_pages(struct riscv_iommu_device *iommu,
69+
unsigned int size)
6970
{
7071
struct riscv_iommu_devres *devres;
7172
void *addr;
7273

73-
addr = iommu_alloc_pages_node(dev_to_node(iommu->dev),
74-
GFP_KERNEL_ACCOUNT, order);
74+
addr = iommu_alloc_pages_node_sz(dev_to_node(iommu->dev),
75+
GFP_KERNEL_ACCOUNT, size);
7576
if (unlikely(!addr))
7677
return NULL;
7778

@@ -161,9 +162,9 @@ static int riscv_iommu_queue_alloc(struct riscv_iommu_device *iommu,
161162
} else {
162163
do {
163164
const size_t queue_size = entry_size << (logsz + 1);
164-
const int order = get_order(queue_size);
165165

166-
queue->base = riscv_iommu_get_pages(iommu, order);
166+
queue->base = riscv_iommu_get_pages(
167+
iommu, max(queue_size, SZ_4K));
167168
queue->phys = __pa(queue->base);
168169
} while (!queue->base && logsz-- > 0);
169170
}
@@ -618,7 +619,7 @@ static struct riscv_iommu_dc *riscv_iommu_get_dc(struct riscv_iommu_device *iomm
618619
break;
619620
}
620621

621-
ptr = riscv_iommu_get_pages(iommu, 0);
622+
ptr = riscv_iommu_get_pages(iommu, SZ_4K);
622623
if (!ptr)
623624
return NULL;
624625

@@ -698,7 +699,7 @@ static int riscv_iommu_iodir_alloc(struct riscv_iommu_device *iommu)
698699
}
699700

700701
if (!iommu->ddt_root) {
701-
iommu->ddt_root = riscv_iommu_get_pages(iommu, 0);
702+
iommu->ddt_root = riscv_iommu_get_pages(iommu, SZ_4K);
702703
iommu->ddt_phys = __pa(iommu->ddt_root);
703704
}
704705

0 commit comments

Comments
 (0)