From: Jason Wang <jasowang@redhat.com> To: Eli Cohen <elic@nvidia.com>, mst@redhat.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1] vdp/mlx5: Fix setting the correct dma_device Date: Mon, 7 Jun 2021 10:11:25 +0800 [thread overview] Message-ID: <fa91edcc-2c99-311d-3501-8643e37c83de@redhat.com> (raw) In-Reply-To: <20210606053150.170489-1-elic@nvidia.com> 在 2021/6/6 下午1:31, Eli Cohen 写道: > Before SF support was introduced, the DMA device was equal to > mdev->device which was in essence equal to pdev->dev. > > With SF introduction this is no longer true. It has already been > handled for vhost_vdpa since the reference to the dma device can from > within mlx5_vdpa. With virtio_vdpa this broke. To fix this we set the > real dma device when initializing the device. > > In addition, for the sake of consistency, previous references in the > code to the dma device are changed to vdev->dma_dev. > > Fixes: d13a15d544ce5 ("vdpa/mlx5: Use the correct dma device when registering memory") > Signed-off-by: Eli Cohen <elic@nvidia.com> Acked-by: Jason Wang <jasowang@redhat.com> > --- > v0 --> v1: > Change blamed commit and modify references to the dma device > > drivers/vdpa/mlx5/core/mr.c | 9 ++------- > drivers/vdpa/mlx5/net/mlx5_vnet.c | 2 +- > 2 files changed, 3 insertions(+), 8 deletions(-) > > diff --git a/drivers/vdpa/mlx5/core/mr.c b/drivers/vdpa/mlx5/core/mr.c > index f0b89b62de36..dcee6039e966 100644 > --- a/drivers/vdpa/mlx5/core/mr.c > +++ b/drivers/vdpa/mlx5/core/mr.c > @@ -219,11 +219,6 @@ static void destroy_indirect_key(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_m > mlx5_vdpa_destroy_mkey(mvdev, &mkey->mkey); > } > > -static struct device *get_dma_device(struct mlx5_vdpa_dev *mvdev) > -{ > - return &mvdev->mdev->pdev->dev; > -} > - > static int map_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mr *mr, > struct vhost_iotlb *iotlb) > { > @@ -239,7 +234,7 @@ static int map_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mr > u64 pa; > u64 paend; > struct scatterlist *sg; > - struct device *dma = get_dma_device(mvdev); > + struct device *dma = mvdev->vdev.dma_dev; > > for (map = vhost_iotlb_itree_first(iotlb, mr->start, mr->end - 1); > map; map = vhost_iotlb_itree_next(map, start, mr->end - 1)) { > @@ -298,7 +293,7 @@ static int map_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mr > > static void unmap_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mr *mr) > { > - struct device *dma = get_dma_device(mvdev); > + struct device *dma = mvdev->vdev.dma_dev; > > destroy_direct_mr(mvdev, mr); > dma_unmap_sg_attrs(dma, mr->sg_head.sgl, mr->nsg, DMA_BIDIRECTIONAL, 0); > diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c > index 7e0d1b8ae3d3..a5163d8a4828 100644 > --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c > +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c > @@ -2046,7 +2046,7 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name) > if (err) > goto err_mtu; > > - mvdev->vdev.dma_dev = mdev->device; > + mvdev->vdev.dma_dev = &mdev->pdev->dev; > err = mlx5_vdpa_alloc_resources(&ndev->mvdev); > if (err) > goto err_mtu;
WARNING: multiple messages have this Message-ID (diff)
From: Jason Wang <jasowang@redhat.com> To: Eli Cohen <elic@nvidia.com>, mst@redhat.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1] vdp/mlx5: Fix setting the correct dma_device Date: Mon, 7 Jun 2021 10:11:25 +0800 [thread overview] Message-ID: <fa91edcc-2c99-311d-3501-8643e37c83de@redhat.com> (raw) In-Reply-To: <20210606053150.170489-1-elic@nvidia.com> 在 2021/6/6 下午1:31, Eli Cohen 写道: > Before SF support was introduced, the DMA device was equal to > mdev->device which was in essence equal to pdev->dev. > > With SF introduction this is no longer true. It has already been > handled for vhost_vdpa since the reference to the dma device can from > within mlx5_vdpa. With virtio_vdpa this broke. To fix this we set the > real dma device when initializing the device. > > In addition, for the sake of consistency, previous references in the > code to the dma device are changed to vdev->dma_dev. > > Fixes: d13a15d544ce5 ("vdpa/mlx5: Use the correct dma device when registering memory") > Signed-off-by: Eli Cohen <elic@nvidia.com> Acked-by: Jason Wang <jasowang@redhat.com> > --- > v0 --> v1: > Change blamed commit and modify references to the dma device > > drivers/vdpa/mlx5/core/mr.c | 9 ++------- > drivers/vdpa/mlx5/net/mlx5_vnet.c | 2 +- > 2 files changed, 3 insertions(+), 8 deletions(-) > > diff --git a/drivers/vdpa/mlx5/core/mr.c b/drivers/vdpa/mlx5/core/mr.c > index f0b89b62de36..dcee6039e966 100644 > --- a/drivers/vdpa/mlx5/core/mr.c > +++ b/drivers/vdpa/mlx5/core/mr.c > @@ -219,11 +219,6 @@ static void destroy_indirect_key(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_m > mlx5_vdpa_destroy_mkey(mvdev, &mkey->mkey); > } > > -static struct device *get_dma_device(struct mlx5_vdpa_dev *mvdev) > -{ > - return &mvdev->mdev->pdev->dev; > -} > - > static int map_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mr *mr, > struct vhost_iotlb *iotlb) > { > @@ -239,7 +234,7 @@ static int map_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mr > u64 pa; > u64 paend; > struct scatterlist *sg; > - struct device *dma = get_dma_device(mvdev); > + struct device *dma = mvdev->vdev.dma_dev; > > for (map = vhost_iotlb_itree_first(iotlb, mr->start, mr->end - 1); > map; map = vhost_iotlb_itree_next(map, start, mr->end - 1)) { > @@ -298,7 +293,7 @@ static int map_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mr > > static void unmap_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mr *mr) > { > - struct device *dma = get_dma_device(mvdev); > + struct device *dma = mvdev->vdev.dma_dev; > > destroy_direct_mr(mvdev, mr); > dma_unmap_sg_attrs(dma, mr->sg_head.sgl, mr->nsg, DMA_BIDIRECTIONAL, 0); > diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c > index 7e0d1b8ae3d3..a5163d8a4828 100644 > --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c > +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c > @@ -2046,7 +2046,7 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name) > if (err) > goto err_mtu; > > - mvdev->vdev.dma_dev = mdev->device; > + mvdev->vdev.dma_dev = &mdev->pdev->dev; > err = mlx5_vdpa_alloc_resources(&ndev->mvdev); > if (err) > goto err_mtu; _______________________________________________ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
next prev parent reply other threads:[~2021-06-07 2:11 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-06-06 5:31 [PATCH v1] vdp/mlx5: Fix setting the correct dma_device Eli Cohen 2021-06-07 2:11 ` Jason Wang [this message] 2021-06-07 2:11 ` Jason Wang
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=fa91edcc-2c99-311d-3501-8643e37c83de@redhat.com \ --to=jasowang@redhat.com \ --cc=elic@nvidia.com \ --cc=linux-kernel@vger.kernel.org \ --cc=mst@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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.