[PATCH 09/19] iommu/riscv: Convert to use struct iommu_pages_list
Tomasz Jeznach
tjeznach at rivosinc.com
Wed Feb 5 21:53:02 PST 2025
On Tue, Feb 04, 2025 at 02:34:50PM -0400, Jason Gunthorpe wrote:
> Change the internal freelist to use struct iommu_pages_list.
>
> riscv uses this page list to free page table levels that are replaced
> with leaf ptes.
>
> Signed-off-by: Jason Gunthorpe <jgg at nvidia.com>
> ---
> drivers/iommu/riscv/iommu.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/iommu/riscv/iommu.c b/drivers/iommu/riscv/iommu.c
> index 6e7df7273426da..549bd8d0615d75 100644
> --- a/drivers/iommu/riscv/iommu.c
> +++ b/drivers/iommu/riscv/iommu.c
> @@ -1085,7 +1085,8 @@ static void riscv_iommu_iotlb_sync(struct iommu_domain *iommu_domain,
> #define _io_pte_entry(pn, prot) ((_PAGE_PFN_MASK & ((pn) << _PAGE_PFN_SHIFT)) | (prot))
>
> static void riscv_iommu_pte_free(struct riscv_iommu_domain *domain,
> - unsigned long pte, struct list_head *freelist)
> + unsigned long pte,
> + struct iommu_pages_list *freelist)
> {
> unsigned long *ptr;
> int i;
> @@ -1103,7 +1104,7 @@ static void riscv_iommu_pte_free(struct riscv_iommu_domain *domain,
> }
>
> if (freelist)
> - list_add_tail(&virt_to_page(ptr)->lru, freelist);
> + iommu_pages_list_add(freelist, ptr);
> else
> iommu_free_page(ptr);
> }
> @@ -1192,7 +1193,7 @@ static int riscv_iommu_map_pages(struct iommu_domain *iommu_domain,
> unsigned long *ptr;
> unsigned long pte, old, pte_prot;
> int rc = 0;
> - LIST_HEAD(freelist);
> + struct iommu_pages_list freelist = IOMMU_PAGES_LIST_INIT(freelist);
>
> if (!(prot & IOMMU_WRITE))
> pte_prot = _PAGE_BASE | _PAGE_READ;
> @@ -1223,7 +1224,7 @@ static int riscv_iommu_map_pages(struct iommu_domain *iommu_domain,
>
> *mapped = size;
>
> - if (!list_empty(&freelist)) {
> + if (!iommu_pages_list_empty(&freelist)) {
> /*
> * In 1.0 spec version, the smallest scope we can use to
> * invalidate all levels of page table (i.e. leaf and non-leaf)
> --
> 2.43.0
>
Reviewed-by: Tomasz Jeznach <tjeznach at rivosinc.com>
Thanks,
- Tomasz
More information about the linux-arm-kernel
mailing list