[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251202230303.1017519-15-skhawaja@google.com>
Date: Tue, 2 Dec 2025 23:02:44 +0000
From: Samiullah Khawaja <skhawaja@...gle.com>
To: David Woodhouse <dwmw2@...radead.org>, Lu Baolu <baolu.lu@...ux.intel.com>,
Joerg Roedel <joro@...tes.org>, Will Deacon <will@...nel.org>,
Pasha Tatashin <pasha.tatashin@...een.com>, Jason Gunthorpe <jgg@...pe.ca>, iommu@...ts.linux.dev
Cc: Samiullah Khawaja <skhawaja@...gle.com>, Robin Murphy <robin.murphy@....com>,
Pratyush Yadav <pratyush@...nel.org>, Kevin Tian <kevin.tian@...el.com>,
Alex Williamson <alex@...zbot.org>, linux-kernel@...r.kernel.org,
Saeed Mahameed <saeedm@...dia.com>, Adithya Jayachandran <ajayachandra@...dia.com>,
Parav Pandit <parav@...dia.com>, Leon Romanovsky <leonro@...dia.com>, William Tu <witu@...dia.com>,
Vipin Sharma <vipinsh@...gle.com>, dmatlack@...gle.com, YiFei Zhu <zhuyifei@...gle.com>,
Chris Li <chrisl@...nel.org>, praan@...gle.com
Subject: [RFC PATCH v2 14/32] iommufd: Use the iommu_domain_preserve/unpreserve
APIs
Remove the stub implementation of iommufd_domain_preserve and unpreserve
APIs and use the APIs exported by the IOMMU core.
Signed-off-by: Samiullah Khawaja <skhawaja@...gle.com>
---
drivers/iommu/iommufd/iommufd_private.h | 2 --
drivers/iommu/iommufd/liveupdate.c | 19 ++++++++++++-------
2 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/drivers/iommu/iommufd/iommufd_private.h b/drivers/iommu/iommufd/iommufd_private.h
index 15afff6ba0ea..0d358e5486d0 100644
--- a/drivers/iommu/iommufd/iommufd_private.h
+++ b/drivers/iommu/iommufd/iommufd_private.h
@@ -730,8 +730,6 @@ int iommufd_hwpt_lu_set_preserved(struct iommufd_ucmd *ucmd);
int iommufd_hwpt_lu_restore(struct iommufd_ucmd *ucmd);
/* TODO */
-#define iommu_domain_restore(x) ERR_PTR(-EOPNOTSUPP)
-#define iommu_domain_preserve(x, y) (-EOPNOTSUPP)
#define iommu_domain_has_attachments(x) (false)
#else
static inline int iommufd_liveupdate_register_lufs(void)
diff --git a/drivers/iommu/iommufd/liveupdate.c b/drivers/iommu/iommufd/liveupdate.c
index 782585aff44a..5b45071d7dd2 100644
--- a/drivers/iommu/iommufd/liveupdate.c
+++ b/drivers/iommu/iommufd/liveupdate.c
@@ -59,6 +59,7 @@ static int iommufd_save_hwpts(struct iommufd_ctx *ictx,
struct iommufd_lu *iommufd_lu)
{
struct iommufd_hwpt_paging *hwpt, **hwpts = NULL;
+ struct iommu_domain_ser *domain_ser;
struct iommufd_hwpt_lu *hwpt_lu;
struct iommufd_object *obj;
unsigned int nr_hwpts = 0;
@@ -119,8 +120,11 @@ static int iommufd_save_hwpts(struct iommufd_ctx *ictx,
hwpt = hwpts[i];
hwpt_lu = &iommufd_lu->hwpts[i];
- rc = iommu_domain_preserve(hwpt->common.domain, &hwpt_lu->domain_data);
- goto out;
+ rc = iommu_domain_preserve(hwpt->common.domain, &domain_ser);
+ if (rc < 0)
+ goto out;
+
+ hwpt_lu->domain_data = __pa(domain_ser);
}
}
@@ -201,7 +205,7 @@ static void iommufd_liveupdate_unpreserve(struct liveupdate_file_op_args *args)
if (!hwpt->common.domain)
continue;
- /* TODO: WARN_ON(iommu_domain_unpreserve(hwpt->common.domain)); */
+ WARN_ON(iommu_domain_unpreserve(hwpt->common.domain));
}
xa_unlock(&ictx->objects);
@@ -276,6 +280,7 @@ int iommufd_hwpt_lu_restore(struct iommufd_ucmd *ucmd)
struct iommu_hwpt_lu_restore *cmd = ucmd->cmd;
struct iommufd_hwpt_paging *hwpt = NULL;
struct iommufd_ctx *ictx = ucmd->ictx;
+ struct iommu_domain_ser *domain_ser;
struct iommufd_hwpt_lu *hwpt_lu;
struct iommufd_lu *iommufd_lu;
struct iommu_domain *domain;
@@ -303,10 +308,10 @@ int iommufd_hwpt_lu_restore(struct iommufd_ucmd *ucmd)
if (IS_ERR(hwpt))
return PTR_ERR(hwpt);
- /* a successful iommu_domain_restore mars the point of no return */
- domain = iommu_domain_restore(hwpt_lu->domain_data);
- if (IS_ERR(domain)) {
- rc = PTR_ERR(domain);
+ domain_ser = __va(hwpt_lu->domain_data);
+ domain = domain_ser->restored_domain;
+ if (!domain) {
+ rc = -ENOENT;
goto err_destroy;
}
--
2.52.0.158.g65b55ccf14-goog
Powered by blists - more mailing lists