From: Si-Wei Liu <si-wei.liu@oracle.com>
To: jasowang@redhat.com, mst@redhat.com, eperezma@redhat.com,
sgarzare@redhat.com, dtatulea@nvidia.com
Cc: virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org
Subject: [PATCH v4 2/7] vhost-vdpa: reset vendor specific mapping to initial state in .release
Date: Sat, 21 Oct 2023 02:25:14 -0700 [thread overview]
Message-ID: <1697880319-4937-3-git-send-email-si-wei.liu@oracle.com> (raw)
In-Reply-To: <1697880319-4937-1-git-send-email-si-wei.liu@oracle.com>
Devices with on-chip IOMMU or vendor specific IOTLB implementation may
need to restore iotlb mapping to the initial or default state using the
.reset_map op, as it's desirable for some parent devices to not work
with DMA ops and maintain a simple IOMMU model with .reset_map. In
particular, device reset should not cause mapping to go away on such
IOTLB model, so persistent mapping is implied across reset. Before the
userspace process using vhost-vdpa is gone, give it a chance to reset
iotlb back to the initial state in vhost_vdpa_cleanup().
Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com>
Acked-by: Eugenio Pérez <eperezma@redhat.com>
---
drivers/vhost/vdpa.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
index 851535f57b95..c6bfe9bdde42 100644
--- a/drivers/vhost/vdpa.c
+++ b/drivers/vhost/vdpa.c
@@ -131,6 +131,15 @@ static struct vhost_vdpa_as *vhost_vdpa_find_alloc_as(struct vhost_vdpa *v,
return vhost_vdpa_alloc_as(v, asid);
}
+static void vhost_vdpa_reset_map(struct vhost_vdpa *v, u32 asid)
+{
+ struct vdpa_device *vdpa = v->vdpa;
+ const struct vdpa_config_ops *ops = vdpa->config;
+
+ if (ops->reset_map)
+ ops->reset_map(vdpa, asid);
+}
+
static int vhost_vdpa_remove_as(struct vhost_vdpa *v, u32 asid)
{
struct vhost_vdpa_as *as = asid_to_as(v, asid);
@@ -140,6 +149,14 @@ static int vhost_vdpa_remove_as(struct vhost_vdpa *v, u32 asid)
hlist_del(&as->hash_link);
vhost_vdpa_iotlb_unmap(v, &as->iotlb, 0ULL, 0ULL - 1, asid);
+ /*
+ * Devices with vendor specific IOMMU may need to restore
+ * iotlb to the initial or default state, which cannot be
+ * cleaned up in the all range unmap call above. Give them
+ * a chance to clean up or reset the map to the desired
+ * state.
+ */
+ vhost_vdpa_reset_map(v, asid);
kfree(as);
return 0;
--
2.39.3
next prev parent reply other threads:[~2023-10-21 9:28 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-21 9:25 [PATCH v4 0/7] vdpa: decouple reset of iotlb mapping from device reset Si-Wei Liu
2023-10-21 9:25 ` [PATCH v4 1/7] vdpa: introduce .reset_map operation callback Si-Wei Liu
2023-10-21 9:25 ` Si-Wei Liu [this message]
2023-10-21 9:25 ` [PATCH v4 3/7] vhost-vdpa: introduce IOTLB_PERSIST backend feature bit Si-Wei Liu
2023-10-21 9:25 ` [PATCH v4 4/7] vdpa: introduce .compat_reset operation callback Si-Wei Liu
2023-10-21 9:25 ` [PATCH v4 5/7] vhost-vdpa: clean iotlb map during reset for older userspace Si-Wei Liu
2023-10-24 5:45 ` Jason Wang
2023-10-24 16:21 ` Si-Wei Liu
2023-10-24 16:25 ` Si-Wei Liu
2023-10-25 1:15 ` Jason Wang
2023-10-21 9:25 ` [PATCH v4 6/7] vdpa/mlx5: implement .reset_map driver op Si-Wei Liu
2023-10-21 9:25 ` [PATCH v4 7/7] vdpa_sim: implement .reset_map support Si-Wei Liu
2023-10-23 3:51 ` [PATCH v4 0/7] vdpa: decouple reset of iotlb mapping from device reset Jason Wang
2023-10-23 22:00 ` Si-Wei Liu
2023-10-24 6:51 ` Lei Yang
2023-10-24 17:27 ` Si-Wei Liu
2023-10-25 9:41 ` Lei Yang
2023-10-25 23:31 ` Si-Wei Liu
2023-10-26 6:16 ` Lei Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1697880319-4937-3-git-send-email-si-wei.liu@oracle.com \
--to=si-wei.liu@oracle.com \
--cc=dtatulea@nvidia.com \
--cc=eperezma@redhat.com \
--cc=jasowang@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=sgarzare@redhat.com \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox