From: Dragos Tatulea <dtatulea@nvidia.com>
To: "si-wei.liu@oracle.com" <si-wei.liu@oracle.com>,
"jasowang@redhat.com" <jasowang@redhat.com>
Cc: "virtualization@lists.linux-foundation.org"
<virtualization@lists.linux-foundation.org>,
"mst@redhat.com" <mst@redhat.com>, Gal Pressman <gal@nvidia.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"eperezma@redhat.com" <eperezma@redhat.com>,
"xuanzhuo@linux.alibaba.com" <xuanzhuo@linux.alibaba.com>
Subject: Re: [PATCH RFC 2/4] vdpa/mlx5: implement .reset_map driver op
Date: Tue, 15 Aug 2023 08:26:17 +0000 [thread overview]
Message-ID: <ec351090ef971976f5149ca1a32563b1fb1bb857.camel@nvidia.com> (raw)
In-Reply-To: <1692063807-5018-3-git-send-email-si-wei.liu@oracle.com>
On Mon, 2023-08-14 at 18:43 -0700, Si-Wei Liu wrote:
> This patch is based on top of the "vdpa/mlx5: Fixes
> for ASID handling" series [1].
>
> [1] vdpa/mlx5: Fixes for ASID handling
> https://lore.kernel.org/virtualization/20230802171231.11001-1-dtatulea@nvidia.com/
>
> Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com>
> ---
> drivers/vdpa/mlx5/core/mlx5_vdpa.h | 1 +
> drivers/vdpa/mlx5/core/mr.c | 72 +++++++++++++++++++++----------------
> -
> drivers/vdpa/mlx5/net/mlx5_vnet.c | 18 +++++++---
> 3 files changed, 54 insertions(+), 37 deletions(-)
>
> diff --git a/drivers/vdpa/mlx5/core/mlx5_vdpa.h
> b/drivers/vdpa/mlx5/core/mlx5_vdpa.h
> index b53420e..5c9a25a 100644
> --- a/drivers/vdpa/mlx5/core/mlx5_vdpa.h
> +++ b/drivers/vdpa/mlx5/core/mlx5_vdpa.h
> @@ -123,6 +123,7 @@ int mlx5_vdpa_create_mr(struct mlx5_vdpa_dev *mvdev,
> struct vhost_iotlb *iotlb,
> unsigned int asid);
> void mlx5_vdpa_destroy_mr(struct mlx5_vdpa_dev *mvdev);
> void mlx5_vdpa_destroy_mr_asid(struct mlx5_vdpa_dev *mvdev, unsigned int
> asid);
> +int mlx5_vdpa_reset_mr(struct mlx5_vdpa_dev *mvdev, unsigned int asid);
>
> #define mlx5_vdpa_warn(__dev, format,
> ...) \
> dev_warn((__dev)->mdev->device, "%s:%d:(pid %d) warning: " format,
> __func__, __LINE__, \
> diff --git a/drivers/vdpa/mlx5/core/mr.c b/drivers/vdpa/mlx5/core/mr.c
> index 5a1971fc..c8d64fc 100644
> --- a/drivers/vdpa/mlx5/core/mr.c
> +++ b/drivers/vdpa/mlx5/core/mr.c
> @@ -489,21 +489,15 @@ static void destroy_user_mr(struct mlx5_vdpa_dev *mvdev,
> struct mlx5_vdpa_mr *mr
> }
> }
>
> -static void _mlx5_vdpa_destroy_cvq_mr(struct mlx5_vdpa_dev *mvdev, unsigned
> int asid)
> +static void _mlx5_vdpa_destroy_cvq_mr(struct mlx5_vdpa_dev *mvdev)
> {
> - if (mvdev->group2asid[MLX5_VDPA_CVQ_GROUP] != asid)
> - return;
> -
> prune_iotlb(mvdev);
> }
>
> -static void _mlx5_vdpa_destroy_dvq_mr(struct mlx5_vdpa_dev *mvdev, unsigned
> int asid)
> +static void _mlx5_vdpa_destroy_dvq_mr(struct mlx5_vdpa_dev *mvdev)
> {
> struct mlx5_vdpa_mr *mr = &mvdev->mr;
>
> - if (mvdev->group2asid[MLX5_VDPA_DATAVQ_GROUP] != asid)
> - return;
> -
> if (!mr->initialized)
> return;
>
> @@ -521,8 +515,10 @@ void mlx5_vdpa_destroy_mr_asid(struct mlx5_vdpa_dev
> *mvdev, unsigned int asid)
>
> mutex_lock(&mr->mkey_mtx);
>
> - _mlx5_vdpa_destroy_dvq_mr(mvdev, asid);
> - _mlx5_vdpa_destroy_cvq_mr(mvdev, asid);
> + if (mvdev->group2asid[MLX5_VDPA_DATAVQ_GROUP] == asid)
> + _mlx5_vdpa_destroy_dvq_mr(mvdev);
> + if (mvdev->group2asid[MLX5_VDPA_CVQ_GROUP] == asid)
> + _mlx5_vdpa_destroy_cvq_mr(mvdev);
>
> mutex_unlock(&mr->mkey_mtx);
> }
> @@ -534,25 +530,17 @@ void mlx5_vdpa_destroy_mr(struct mlx5_vdpa_dev *mvdev)
> }
>
> static int _mlx5_vdpa_create_cvq_mr(struct mlx5_vdpa_dev *mvdev,
> - struct vhost_iotlb *iotlb,
> - unsigned int asid)
> + struct vhost_iotlb *iotlb)
> {
> - if (mvdev->group2asid[MLX5_VDPA_CVQ_GROUP] != asid)
> - return 0;
> -
> return dup_iotlb(mvdev, iotlb);
> }
>
> static int _mlx5_vdpa_create_dvq_mr(struct mlx5_vdpa_dev *mvdev,
> - struct vhost_iotlb *iotlb,
> - unsigned int asid)
> + struct vhost_iotlb *iotlb)
> {
> struct mlx5_vdpa_mr *mr = &mvdev->mr;
> int err;
>
> - if (mvdev->group2asid[MLX5_VDPA_DATAVQ_GROUP] != asid)
> - return 0;
> -
> if (mr->initialized)
> return 0;
>
> @@ -574,20 +562,18 @@ static int _mlx5_vdpa_create_mr(struct mlx5_vdpa_dev
> *mvdev,
> {
> int err;
>
> - err = _mlx5_vdpa_create_dvq_mr(mvdev, iotlb, asid);
> - if (err)
> - return err;
> -
> - err = _mlx5_vdpa_create_cvq_mr(mvdev, iotlb, asid);
> - if (err)
> - goto out_err;
> + if (mvdev->group2asid[MLX5_VDPA_DATAVQ_GROUP] == asid) {
> + err = _mlx5_vdpa_create_dvq_mr(mvdev, iotlb, asid);
> + if (err)
> + return err;
> + }
> + if (mvdev->group2asid[MLX5_VDPA_CVQ_GROUP] == asid) {
> + err = _mlx5_vdpa_create_cvq_mr(mvdev, iotlb);
> + if (err)
> + return err;
I think you still need the goto here, when CVQ and DVQ fall in same asid and
there's a CVQ mr creation error, you are left stuck with the DVQ mr.
> + }
>
> return 0;
> -
> -out_err:
> - _mlx5_vdpa_destroy_dvq_mr(mvdev, asid);
> -
> - return err;
> }
>
> int mlx5_vdpa_create_mr(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb
> *iotlb,
> @@ -601,6 +587,28 @@ int mlx5_vdpa_create_mr(struct mlx5_vdpa_dev *mvdev,
> struct vhost_iotlb *iotlb,
> return err;
> }
>
> +int mlx5_vdpa_reset_mr(struct mlx5_vdpa_dev *mvdev, unsigned int asid)
> +{
> + struct mlx5_vdpa_mr *mr = &mvdev->mr;
> + int err = 0;
> +
> + if (asid != 0)
> + return 0;
> +
> + mutex_lock(&mr->mkey_mtx);
> + if (!mr->user_mr)
> + goto out;
> + _mlx5_vdpa_destroy_dvq_mr(mvdev);
> + if (MLX5_CAP_GEN(mvdev->mdev, umem_uid_0)) {
> + err = _mlx5_vdpa_create_dvq_mr(mvdev, NULL, 0);
> + if (err)
> + mlx5_vdpa_warn(mvdev, "create DMA MR failed\n");
> + }
> +out:
> + mutex_unlock(&mr->mkey_mtx);
> + return err;
> +}
> +
> int mlx5_vdpa_handle_set_map(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb
> *iotlb,
> bool *change_map, unsigned int asid)
> {
> diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c
> b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> index 61c10ba..399a690 100644
> --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
> +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> @@ -2816,7 +2816,6 @@ static int mlx5_vdpa_reset(struct vdpa_device *vdev)
> unregister_link_notifier(ndev);
> teardown_driver(ndev);
> clear_vqs_ready(ndev);
> - mlx5_vdpa_destroy_mr(&ndev->mvdev);
> ndev->mvdev.status = 0;
> ndev->mvdev.suspended = false;
> ndev->cur_num_vqs = 0;
> @@ -2827,10 +2826,6 @@ static int mlx5_vdpa_reset(struct vdpa_device *vdev)
> init_group_to_asid_map(mvdev);
> ++mvdev->generation;
>
> - if (MLX5_CAP_GEN(mvdev->mdev, umem_uid_0)) {
> - if (mlx5_vdpa_create_mr(mvdev, NULL, 0))
> - mlx5_vdpa_warn(mvdev, "create MR failed\n");
> - }
> up_write(&ndev->reslock);
>
> return 0;
> @@ -2895,6 +2890,18 @@ static int mlx5_vdpa_set_map(struct vdpa_device *vdev,
> unsigned int asid,
> return err;
> }
>
> +static int mlx5_vdpa_reset_map(struct vdpa_device *vdev, unsigned int asid)
> +{
> + struct mlx5_vdpa_dev *mvdev = to_mvdev(vdev);
> + struct mlx5_vdpa_net *ndev = to_mlx5_vdpa_ndev(mvdev);
> + int err;
> +
> + down_write(&ndev->reslock);
> + err = mlx5_vdpa_reset_mr(mvdev, asid);
> + up_write(&ndev->reslock);
> + return err;
> +}
> +
> static struct device *mlx5_get_vq_dma_dev(struct vdpa_device *vdev, u16 idx)
> {
> struct mlx5_vdpa_dev *mvdev = to_mvdev(vdev);
> @@ -3154,6 +3161,7 @@ static int mlx5_set_group_asid(struct vdpa_device *vdev,
> u32 group,
> .set_config = mlx5_vdpa_set_config,
> .get_generation = mlx5_vdpa_get_generation,
> .set_map = mlx5_vdpa_set_map,
> + .reset_map = mlx5_vdpa_reset_map,
> .set_group_asid = mlx5_set_group_asid,
> .get_vq_dma_dev = mlx5_get_vq_dma_dev,
> .free = mlx5_vdpa_free,
next prev parent reply other threads:[~2023-08-15 8:27 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-02 17:12 [PATCH 0/2] vdpa/mlx5: Fixes for ASID handling Dragos Tatulea
2023-08-02 17:12 ` [PATCH 1/2] vdpa/mlx5: Fix mr->initialized semantics Dragos Tatulea
2023-08-03 8:03 ` Jason Wang
2023-08-03 11:40 ` Dragos Tatulea
2023-08-08 2:57 ` Jason Wang
2023-08-08 7:24 ` Dragos Tatulea
2023-08-09 1:42 ` Jason Wang
2023-08-14 14:15 ` Dragos Tatulea
2023-08-15 1:28 ` Jason Wang
2023-08-03 17:57 ` Si-Wei Liu
2023-08-08 3:00 ` Jason Wang
2023-08-08 22:58 ` Si-Wei Liu
2023-08-09 6:52 ` Jason Wang
2023-08-10 0:40 ` Si-Wei Liu
2023-08-10 3:10 ` Jason Wang
2023-08-10 22:20 ` Si-Wei Liu
2023-08-14 2:59 ` Jason Wang
2023-08-15 1:43 ` [PATCH RFC 0/4] vdpa: decouple reset of iotlb mapping from device reset Si-Wei Liu
2023-08-15 1:43 ` [PATCH RFC 1/4] vdpa: introduce .reset_map operation callback Si-Wei Liu
2023-08-15 2:21 ` Jason Wang
2023-08-15 19:49 ` Si-Wei Liu
2023-08-16 1:55 ` Jason Wang
2023-08-17 0:05 ` Si-Wei Liu
2023-08-17 15:28 ` Eugenio Perez Martin
2023-08-21 22:31 ` Si-Wei Liu
2023-08-15 1:43 ` [PATCH RFC 2/4] vdpa/mlx5: implement .reset_map driver op Si-Wei Liu
2023-08-15 8:26 ` Dragos Tatulea [this message]
2023-08-15 23:11 ` Si-Wei Liu
2023-08-15 1:43 ` [PATCH RFC 3/4] vhost-vdpa: should restore 1:1 dma mapping before detaching driver Si-Wei Liu
2023-08-15 2:32 ` Jason Wang
2023-08-15 23:09 ` Si-Wei Liu
2023-08-15 1:43 ` [PATCH RFC 4/4] vhost-vdpa: introduce IOTLB_PERSIST backend feature bit Si-Wei Liu
2023-08-15 2:25 ` Jason Wang
2023-08-15 22:30 ` Si-Wei Liu
2023-08-16 1:48 ` Jason Wang
2023-08-16 23:43 ` Si-Wei Liu
2023-08-22 8:54 ` Jason Wang
2023-08-28 23:46 ` Si-Wei Liu
2023-08-02 17:12 ` [PATCH 2/2] vdpa/mlx5: Delete control vq iotlb in destroy_mr only when necessary Dragos Tatulea
2023-08-10 8:54 ` [PATCH 0/2] vdpa/mlx5: Fixes for ASID handling Michael S. Tsirkin
2023-08-10 8:59 ` Jason Wang
2023-08-10 9:04 ` Dragos Tatulea
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=ec351090ef971976f5149ca1a32563b1fb1bb857.camel@nvidia.com \
--to=dtatulea@nvidia.com \
--cc=eperezma@redhat.com \
--cc=gal@nvidia.com \
--cc=jasowang@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=si-wei.liu@oracle.com \
--cc=virtualization@lists.linux-foundation.org \
--cc=xuanzhuo@linux.alibaba.com \
/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
all inboxes | Powered by JetHome®