linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] virtio_vdpa: Support surprise removal of virtio vdpa device
       [not found] <tencent_7A45E1E967F13AE14B061269@qq.com>
@ 2022-01-11  4:37 ` Jason Wang
  2022-01-11 11:52 ` Michael S. Tsirkin
  1 sibling, 0 replies; 8+ messages in thread
From: Jason Wang @ 2022-01-11  4:37 UTC (permalink / raw)
  To: 李东升; +Cc: mst, virtualization, linux-kernel

On Tue, Jan 11, 2022 at 11:38 AM 李东升 <lidongsheng@dayudpu.com> wrote:
>
> When virtio vdpa device removed, the abnormal damage of the device cannot be
> perceived normally, which will cause problems similar to:
>
> 43bb40c5b926
>
> Hence, add the ability to abort the command on surprise removal
>
> Signed-off-by: dongsheng li <lidongsheng@dayudpu.com>

Acked-by: Jason Wang <jasowang@redhat.com>

> ---
>  drivers/virtio/virtio_vdpa.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/virtio/virtio_vdpa.c b/drivers/virtio/virtio_vdpa.c
> index 4a9ddb44b2a7..fd930409d190 100644
> --- a/drivers/virtio/virtio_vdpa.c
> +++ b/drivers/virtio/virtio_vdpa.c
> @@ -374,6 +374,7 @@ static void virtio_vdpa_remove(struct vdpa_device *vdpa)
>  {
>   struct virtio_vdpa_device *vd_dev = vdpa_get_drvdata(vdpa);
>
> + virtio_break_device(vd_dev->vdev);
>   unregister_virtio_device(&vd_dev->vdev);
>  }
>
> --
> 2.17.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] virtio_vdpa: Support surprise removal of virtio vdpa device
       [not found] <tencent_7A45E1E967F13AE14B061269@qq.com>
  2022-01-11  4:37 ` [PATCH] virtio_vdpa: Support surprise removal of virtio vdpa device Jason Wang
@ 2022-01-11 11:52 ` Michael S. Tsirkin
  2022-01-12  2:23   ` Jason Wang
  1 sibling, 1 reply; 8+ messages in thread
From: Michael S. Tsirkin @ 2022-01-11 11:52 UTC (permalink / raw)
  To: 李东升; +Cc: jasowang, virtualization, linux-kernel

On Tue, Jan 11, 2022 at 11:36:42AM +0800, 李东升 wrote:
> When virtio vdpa device removed, the abnormal damage of the device cannot be
> perceived normally, which will cause problems similar to:
> 
> 43bb40c5b926


Should include the subject of the patch too.

> Hence, add the ability to abort the command on surprise removal
> 
> Signed-off-by: dongsheng li <lidongsheng@dayudpu.com>

When removing gracefully,
I am not sure we should break device unconditionally like this
before giving drivers a chance to clean up.
Should we just do it for surprise removal?

> ---
>  drivers/virtio/virtio_vdpa.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/virtio/virtio_vdpa.c b/drivers/virtio/virtio_vdpa.c
> index 4a9ddb44b2a7..fd930409d190 100644
> --- a/drivers/virtio/virtio_vdpa.c
> +++ b/drivers/virtio/virtio_vdpa.c
> @@ -374,6 +374,7 @@ static void virtio_vdpa_remove(struct vdpa_device *vdpa)
>  {
>   struct virtio_vdpa_device *vd_dev = vdpa_get_drvdata(vdpa);
> 
> + virtio_break_device(vd_dev->vdev);
>   unregister_virtio_device(&vd_dev->vdev);
>  }
> 
> --
> 2.17.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] virtio_vdpa: Support surprise removal of virtio vdpa device
  2022-01-11 11:52 ` Michael S. Tsirkin
@ 2022-01-12  2:23   ` Jason Wang
  2022-01-12  6:30     ` Michael S. Tsirkin
  0 siblings, 1 reply; 8+ messages in thread
From: Jason Wang @ 2022-01-12  2:23 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: 李东升, virtualization, linux-kernel

On Tue, Jan 11, 2022 at 7:52 PM Michael S. Tsirkin <mst@redhat.com> wrote:
>
> On Tue, Jan 11, 2022 at 11:36:42AM +0800, 李东升 wrote:
> > When virtio vdpa device removed, the abnormal damage of the device cannot be
> > perceived normally, which will cause problems similar to:
> >
> > 43bb40c5b926
>
>
> Should include the subject of the patch too.
>
> > Hence, add the ability to abort the command on surprise removal
> >
> > Signed-off-by: dongsheng li <lidongsheng@dayudpu.com>
>
> When removing gracefully,
> I am not sure we should break device unconditionally like this
> before giving drivers a chance to clean up.
> Should we just do it for surprise removal?

That requires a new method to query whether it's a surprise removal.

Thanks

>
> > ---
> >  drivers/virtio/virtio_vdpa.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/virtio/virtio_vdpa.c b/drivers/virtio/virtio_vdpa.c
> > index 4a9ddb44b2a7..fd930409d190 100644
> > --- a/drivers/virtio/virtio_vdpa.c
> > +++ b/drivers/virtio/virtio_vdpa.c
> > @@ -374,6 +374,7 @@ static void virtio_vdpa_remove(struct vdpa_device *vdpa)
> >  {
> >   struct virtio_vdpa_device *vd_dev = vdpa_get_drvdata(vdpa);
> >
> > + virtio_break_device(vd_dev->vdev);
> >   unregister_virtio_device(&vd_dev->vdev);
> >  }
> >
> > --
> > 2.17.1
>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] virtio_vdpa: Support surprise removal of virtio vdpa device
  2022-01-12  2:23   ` Jason Wang
@ 2022-01-12  6:30     ` Michael S. Tsirkin
  2022-01-12  7:52       ` Jason Wang
       [not found]       ` <tencent_18F8A88D22E327230EF313BE@qq.com>
  0 siblings, 2 replies; 8+ messages in thread
From: Michael S. Tsirkin @ 2022-01-12  6:30 UTC (permalink / raw)
  To: Jason Wang; +Cc: 李东升, virtualization, linux-kernel

On Wed, Jan 12, 2022 at 10:23:07AM +0800, Jason Wang wrote:
> On Tue, Jan 11, 2022 at 7:52 PM Michael S. Tsirkin <mst@redhat.com> wrote:
> >
> > On Tue, Jan 11, 2022 at 11:36:42AM +0800, 李东升 wrote:
> > > When virtio vdpa device removed, the abnormal damage of the device cannot be
> > > perceived normally, which will cause problems similar to:
> > >
> > > 43bb40c5b926
> >
> >
> > Should include the subject of the patch too.
> >
> > > Hence, add the ability to abort the command on surprise removal
> > >
> > > Signed-off-by: dongsheng li <lidongsheng@dayudpu.com>
> >
> > When removing gracefully,
> > I am not sure we should break device unconditionally like this
> > before giving drivers a chance to clean up.
> > Should we just do it for surprise removal?
> 
> That requires a new method to query whether it's a surprise removal.
> 
> Thanks

We can check pci_device_is_present like virtio does.

> >
> > > ---
> > >  drivers/virtio/virtio_vdpa.c | 1 +
> > >  1 file changed, 1 insertion(+)
> > >
> > > diff --git a/drivers/virtio/virtio_vdpa.c b/drivers/virtio/virtio_vdpa.c
> > > index 4a9ddb44b2a7..fd930409d190 100644
> > > --- a/drivers/virtio/virtio_vdpa.c
> > > +++ b/drivers/virtio/virtio_vdpa.c
> > > @@ -374,6 +374,7 @@ static void virtio_vdpa_remove(struct vdpa_device *vdpa)
> > >  {
> > >   struct virtio_vdpa_device *vd_dev = vdpa_get_drvdata(vdpa);
> > >
> > > + virtio_break_device(vd_dev->vdev);
> > >   unregister_virtio_device(&vd_dev->vdev);
> > >  }
> > >
> > > --
> > > 2.17.1
> >


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] virtio_vdpa: Support surprise removal of virtio vdpa device
  2022-01-12  6:30     ` Michael S. Tsirkin
@ 2022-01-12  7:52       ` Jason Wang
  2022-01-12 14:52         ` Michael S. Tsirkin
       [not found]       ` <tencent_18F8A88D22E327230EF313BE@qq.com>
  1 sibling, 1 reply; 8+ messages in thread
From: Jason Wang @ 2022-01-12  7:52 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: 李东升, virtualization, linux-kernel

On Wed, Jan 12, 2022 at 2:30 PM Michael S. Tsirkin <mst@redhat.com> wrote:
>
> On Wed, Jan 12, 2022 at 10:23:07AM +0800, Jason Wang wrote:
> > On Tue, Jan 11, 2022 at 7:52 PM Michael S. Tsirkin <mst@redhat.com> wrote:
> > >
> > > On Tue, Jan 11, 2022 at 11:36:42AM +0800, 李东升 wrote:
> > > > When virtio vdpa device removed, the abnormal damage of the device cannot be
> > > > perceived normally, which will cause problems similar to:
> > > >
> > > > 43bb40c5b926
> > >
> > >
> > > Should include the subject of the patch too.
> > >
> > > > Hence, add the ability to abort the command on surprise removal
> > > >
> > > > Signed-off-by: dongsheng li <lidongsheng@dayudpu.com>
> > >
> > > When removing gracefully,
> > > I am not sure we should break device unconditionally like this
> > > before giving drivers a chance to clean up.
> > > Should we just do it for surprise removal?
> >
> > That requires a new method to query whether it's a surprise removal.
> >
> > Thanks
>
> We can check pci_device_is_present like virtio does.

Though the PCI device is the main user, we are vdpa transport that is
unaware of the type of its parent.

So it looks to me we need a new method and PCI parent and do call this
function when needed.

Thanks

>
> > >
> > > > ---
> > > >  drivers/virtio/virtio_vdpa.c | 1 +
> > > >  1 file changed, 1 insertion(+)
> > > >
> > > > diff --git a/drivers/virtio/virtio_vdpa.c b/drivers/virtio/virtio_vdpa.c
> > > > index 4a9ddb44b2a7..fd930409d190 100644
> > > > --- a/drivers/virtio/virtio_vdpa.c
> > > > +++ b/drivers/virtio/virtio_vdpa.c
> > > > @@ -374,6 +374,7 @@ static void virtio_vdpa_remove(struct vdpa_device *vdpa)
> > > >  {
> > > >   struct virtio_vdpa_device *vd_dev = vdpa_get_drvdata(vdpa);
> > > >
> > > > + virtio_break_device(vd_dev->vdev);
> > > >   unregister_virtio_device(&vd_dev->vdev);
> > > >  }
> > > >
> > > > --
> > > > 2.17.1
> > >
>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] virtio_vdpa: Support surprise removal of virtio vdpa device
  2022-01-12  7:52       ` Jason Wang
@ 2022-01-12 14:52         ` Michael S. Tsirkin
  0 siblings, 0 replies; 8+ messages in thread
From: Michael S. Tsirkin @ 2022-01-12 14:52 UTC (permalink / raw)
  To: Jason Wang; +Cc: 李东升, virtualization, linux-kernel

On Wed, Jan 12, 2022 at 03:52:52PM +0800, Jason Wang wrote:
> On Wed, Jan 12, 2022 at 2:30 PM Michael S. Tsirkin <mst@redhat.com> wrote:
> >
> > On Wed, Jan 12, 2022 at 10:23:07AM +0800, Jason Wang wrote:
> > > On Tue, Jan 11, 2022 at 7:52 PM Michael S. Tsirkin <mst@redhat.com> wrote:
> > > >
> > > > On Tue, Jan 11, 2022 at 11:36:42AM +0800, 李东升 wrote:
> > > > > When virtio vdpa device removed, the abnormal damage of the device cannot be
> > > > > perceived normally, which will cause problems similar to:
> > > > >
> > > > > 43bb40c5b926
> > > >
> > > >
> > > > Should include the subject of the patch too.
> > > >
> > > > > Hence, add the ability to abort the command on surprise removal
> > > > >
> > > > > Signed-off-by: dongsheng li <lidongsheng@dayudpu.com>
> > > >
> > > > When removing gracefully,
> > > > I am not sure we should break device unconditionally like this
> > > > before giving drivers a chance to clean up.
> > > > Should we just do it for surprise removal?
> > >
> > > That requires a new method to query whether it's a surprise removal.
> > >
> > > Thanks
> >
> > We can check pci_device_is_present like virtio does.
> 
> Though the PCI device is the main user, we are vdpa transport that is
> unaware of the type of its parent.
> 
> So it looks to me we need a new method and PCI parent and do call this
> function when needed.
> 
> Thanks

Sure.

> >
> > > >
> > > > > ---
> > > > >  drivers/virtio/virtio_vdpa.c | 1 +
> > > > >  1 file changed, 1 insertion(+)
> > > > >
> > > > > diff --git a/drivers/virtio/virtio_vdpa.c b/drivers/virtio/virtio_vdpa.c
> > > > > index 4a9ddb44b2a7..fd930409d190 100644
> > > > > --- a/drivers/virtio/virtio_vdpa.c
> > > > > +++ b/drivers/virtio/virtio_vdpa.c
> > > > > @@ -374,6 +374,7 @@ static void virtio_vdpa_remove(struct vdpa_device *vdpa)
> > > > >  {
> > > > >   struct virtio_vdpa_device *vd_dev = vdpa_get_drvdata(vdpa);
> > > > >
> > > > > + virtio_break_device(vd_dev->vdev);
> > > > >   unregister_virtio_device(&vd_dev->vdev);
> > > > >  }
> > > > >
> > > > > --
> > > > > 2.17.1
> > > >
> >


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] virtio_vdpa: Support surprise removal of virtio vdpa device
       [not found]       ` <tencent_18F8A88D22E327230EF313BE@qq.com>
@ 2022-01-12 15:02         ` Michael S. Tsirkin
  0 siblings, 0 replies; 8+ messages in thread
From: Michael S. Tsirkin @ 2022-01-12 15:02 UTC (permalink / raw)
  To: 李东升; +Cc: jasowang, virtualization, linux-kernel


On Wed, Jan 12, 2022 at 04:44:08PM +0800, 李东升 wrote:
> Indeed, there are hidden dangers for storage devices.
> So maybe we can break the device before virtio_net unregister_netdev and before
> virtio_blk reset
> 
> Unlike pci device, there is a manufacturer-driven existence between virtio vdpa
> and hardware devices, 
> unless the manufacturer provides a state interface, virtio vdpa and
> higher-level drivers cannot obtain the real hardware state.

I think for surprise removal you need to propagate the presence status up.
No way around that imho.

> 
> ------------------ Original ------------------
> From:  "mst"<mst@redhat.com>;
> Date:  Wed, Jan 12, 2022 02:30 PM
> To:  "jasowang"<jasowang@redhat.com>;
> Cc:  "李东升"<lidongsheng@dayudpu.com>; "virtualization"
> <virtualization@lists.linux-foundation.org>; "linux-kernel"
> <linux-kernel@vger.kernel.org>;
> Subject:  Re: [PATCH] virtio_vdpa: Support surprise removal of virtio vdpa
> device
>  
> On Wed, Jan 12, 2022 at 10:23:07AM +0800, Jason Wang wrote:
> > On Tue, Jan 11, 2022 at 7:52 PM Michael S. Tsirkin <mst@redhat.com> wrote:
> > >
> > > On Tue, Jan 11, 2022 at 11:36:42AM +0800, 李东升 wrote:
> > > > When virtio vdpa device removed, the abnormal damage of the device cannot
> be
> > > > perceived normally, which will cause problems similar to:
> > > >
> > > > 43bb40c5b926
> > >
> > >
> > > Should include the subject of the patch too.
> > >
> > > > Hence, add the ability to abort the command on surprise removal
> > > >
> > > > Signed-off-by: dongsheng li <lidongsheng@dayudpu.com>
> > >
> > > When removing gracefully,
> > > I am not sure we should break device unconditionally like this
> > > before giving drivers a chance to clean up.
> > > Should we just do it for surprise removal?
> >
> > That requires a new method to query whether it's a surprise removal.
> >
> > Thanks
> 
> We can check pci_device_is_present like virtio does.
> 
> > >
> > > > ---
> > > >  drivers/virtio/virtio_vdpa.c | 1 +
> > > >  1 file changed, 1 insertion(+)
> > > >
> > > > diff --git a/drivers/virtio/virtio_vdpa.c b/drivers/virtio/virtio_vdpa.c
> > > > index 4a9ddb44b2a7..fd930409d190 100644
> > > > --- a/drivers/virtio/virtio_vdpa.c
> > > > +++ b/drivers/virtio/virtio_vdpa.c
> > > > @@ -374,6 +374,7 @@ static void virtio_vdpa_remove(struct vdpa_device
> *vdpa)
> > > >  {
> > > >   struct virtio_vdpa_device *vd_dev = vdpa_get_drvdata(vdpa);
> > > >
> > > > + virtio_break_device(vd_dev->vdev);
> > > >   unregister_virtio_device(&vd_dev->vdev);
> > > >  }
> > > >
> > > > --
> > > > 2.17.1
> > >
> 


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] virtio_vdpa: Support surprise removal of virtio vdpa device
@ 2022-01-11  4:08 dongsheng li
  0 siblings, 0 replies; 8+ messages in thread
From: dongsheng li @ 2022-01-11  4:08 UTC (permalink / raw)
  To: mst, jasowang; +Cc: virtualization, linux-kernel, dongsheng li

When virtio vdpa device removed, the abnormal damage of the device cannot be
perceived normally, which will cause problems similar to:

Commit 43bb40c5b926 ("virtio_pci: Support surprise removal of
virtio pci device")

Hence, add the ability to abort the command on surprise removal

Signed-off-by: dongsheng li <lidongsheng@dayudpu.com>
---
 drivers/virtio/virtio_vdpa.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/virtio/virtio_vdpa.c b/drivers/virtio/virtio_vdpa.c
index 4a9ddb44b2a7..fd930409d190 100644
--- a/drivers/virtio/virtio_vdpa.c
+++ b/drivers/virtio/virtio_vdpa.c
@@ -374,6 +374,7 @@ static void virtio_vdpa_remove(struct vdpa_device *vdpa)
 {
 	struct virtio_vdpa_device *vd_dev = vdpa_get_drvdata(vdpa);
 
+	virtio_break_device(vd_dev->vdev);
 	unregister_virtio_device(&vd_dev->vdev);
 }
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-01-12 15:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <tencent_7A45E1E967F13AE14B061269@qq.com>
2022-01-11  4:37 ` [PATCH] virtio_vdpa: Support surprise removal of virtio vdpa device Jason Wang
2022-01-11 11:52 ` Michael S. Tsirkin
2022-01-12  2:23   ` Jason Wang
2022-01-12  6:30     ` Michael S. Tsirkin
2022-01-12  7:52       ` Jason Wang
2022-01-12 14:52         ` Michael S. Tsirkin
     [not found]       ` <tencent_18F8A88D22E327230EF313BE@qq.com>
2022-01-12 15:02         ` Michael S. Tsirkin
2022-01-11  4:08 dongsheng li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).