[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230411024109-mutt-send-email-mst@kernel.org>
Date: Tue, 11 Apr 2023 02:41:40 -0400
From: "Michael S. Tsirkin" <mst@...hat.com>
To: Angus Chen <angus.chen@...uarmicro.com>
Cc: "jasowang@...hat.com" <jasowang@...hat.com>,
"virtualization@...ts.linux-foundation.org"
<virtualization@...ts.linux-foundation.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] virtio_pci: Wait for legacy device to be reset
On Tue, Apr 11, 2023 at 06:39:16AM +0000, Angus Chen wrote:
> Hi mst.
>
> > -----Original Message-----
> > From: Michael S. Tsirkin <mst@...hat.com>
> > Sent: Tuesday, April 11, 2023 2:30 PM
> > To: Angus Chen <angus.chen@...uarmicro.com>
> > Cc: jasowang@...hat.com; virtualization@...ts.linux-foundation.org;
> > linux-kernel@...r.kernel.org
> > Subject: Re: [PATCH] virtio_pci: Wait for legacy device to be reset
> >
> > On Tue, Apr 11, 2023 at 09:38:32AM +0800, Angus Chen wrote:
> > > We read the status of device after reset,
> > > It is not guaranteed that the device be reseted successfully.
> >
> > Sorry not guaranteed by what? I am guessing you have a legacy device
> > that does not reset fully on write, and you need to wait?
> When the card not finished reset, the read only return the middle state of card.
> >
> > > We can use a while loop to make sure that,like the modern device did.
> > > The spec is not request it ,but it work.
> > >
> > > Signed-off-by: Angus Chen <angus.chen@...uarmicro.com>
> >
> > Generally I don't much like touching legacy, no telling what
> > that will do. Case in point, is your device a pure
> > legacy device or a transitional device?
> Yes.,we have a real card which is use vitio spec.
So is it a transitional device?
> Thank you.
> >
> > > ---
> > > drivers/virtio/virtio_pci_legacy.c | 4 +++-
> > > 1 file changed, 3 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/virtio/virtio_pci_legacy.c b/drivers/virtio/virtio_pci_legacy.c
> > > index 2257f1b3d8ae..f2d241563e4f 100644
> > > --- a/drivers/virtio/virtio_pci_legacy.c
> > > +++ b/drivers/virtio/virtio_pci_legacy.c
> > > @@ -14,6 +14,7 @@
> > > * Michael S. Tsirkin <mst@...hat.com>
> > > */
> > >
> > > +#include <linux/delay.h>
> > > #include "linux/virtio_pci_legacy.h"
> > > #include "virtio_pci_common.h"
> > >
> > > @@ -97,7 +98,8 @@ static void vp_reset(struct virtio_device *vdev)
> > > vp_legacy_set_status(&vp_dev->ldev, 0);
> > > /* Flush out the status write, and flush in device writes,
> > > * including MSi-X interrupts, if any. */
> > > - vp_legacy_get_status(&vp_dev->ldev);
> > > + while (vp_legacy_get_status(&vp_dev->ldev))
> > > + msleep(1);
> >
> > The problem with this is that it will break surprise
> > removal even worse than it's already broken.
> >
> >
> > > /* Flush pending VQ/configuration callbacks. */
> > > vp_synchronize_vectors(vdev);
> > > }
> > > --
> > > 2.25.1
>
Powered by blists - more mailing lists