[PATCH v1 2/5] iommufd: Iterate the cache invalidation array in the core
Tian, Kevin
kevin.tian at intel.com
Thu Jul 2 23:21:41 PDT 2026
> From: Nicolin Chen <nicolinc at nvidia.com>
> Sent: Tuesday, June 30, 2026 5:16 AM
>
> @@ -535,8 +535,15 @@ int iommufd_hwpt_invalidate(struct
> iommufd_ucmd *ucmd)
> rc = -EOPNOTSUPP;
> goto out_put_pt;
> }
> - rc = hwpt->domain->ops->cache_invalidate_user(hwpt-
> >domain,
> - &data_array);
> + do {
> + rc = hwpt->domain->ops->cache_invalidate_user(
> + hwpt->domain, &data_array);
> +
> + done_num += data_array.entry_num;
> + data_array.uptr +=
> + data_array.entry_num * cmd->entry_len;
> + data_array.entry_num = cmd->entry_num -
> done_num;
> + } while (!rc && done_num != cmd->entry_num);
> } else if (pt_obj->type == IOMMUFD_OBJ_VIOMMU) {
> struct iommufd_viommu *viommu =
> container_of(pt_obj, struct iommufd_viommu, obj);
> @@ -545,14 +552,19 @@ int iommufd_hwpt_invalidate(struct
> iommufd_ucmd *ucmd)
> rc = -EOPNOTSUPP;
> goto out_put_pt;
> }
> - rc = viommu->ops->cache_invalidate(viommu, &data_array);
> + do {
> + rc = viommu->ops->cache_invalidate(viommu,
> &data_array);
> +
> + done_num += data_array.entry_num;
> + data_array.uptr +=
> + data_array.entry_num * cmd->entry_len;
> + data_array.entry_num = cmd->entry_num -
> done_num;
> + } while (!rc && done_num != cmd->entry_num);
> } else {
> rc = -EINVAL;
> goto out_put_pt;
> }
>
the two loops above can be consolidated into one after the ops is
selected.
Reviewed-by: Kevin Tian <kevin.tian at intel.com>
More information about the linux-arm-kernel
mailing list