public inbox for virtio-comment@lists.linux.dev
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: "Zhu Lingshan" <lingshan.zhu@amd.com>,
	"Parav Pandit" <parav@nvidia.com>,
	"cohuck@redhat.com" <cohuck@redhat.com>,
	"virtio-comment@lists.linux.dev" <virtio-comment@lists.linux.dev>,
	"Eugenio Pérez" <eperezma@redhat.com>,
	"David Stevens" <stevensd@chromium.org>
Subject: Re: [PATCH V7 v7] virtio: introduce SUSPEND bit in device status
Date: Sun, 29 Sep 2024 13:55:03 -0400	[thread overview]
Message-ID: <20240929135241-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <CACGkMEtYJOVHMtsqcW2OXSvArcUxHJXMCz3h5KRwaTGe5OzngA@mail.gmail.com>

On Fri, Sep 27, 2024 at 12:08:54PM +0800, Jason Wang wrote:
> On Wed, Sep 25, 2024 at 7:17 PM Michael S. Tsirkin <mst@redhat.com> wrote:
> >
> > On Wed, Sep 25, 2024 at 11:47:49AM +0800, Jason Wang wrote:
> > > On Wed, Sep 25, 2024 at 7:05 AM Michael S. Tsirkin <mst@redhat.com> wrote:
> > > >
> > > > On Tue, Sep 24, 2024 at 03:35:57PM +0800, Jason Wang wrote:
> > > > > >
> > > > > > > And I still don't see why
> > > > > > > introducing a single new bit in the status brings any new troubles
> > > > > > > compared with the existing reset and other state transitions.
> > > > > >
> > > > > > reset is not a state.
> > > > >
> > > > > Well, I'm not sure I get this. Each value read from status should
> > > > > represent a device state.
> > > >
> > > > What makes you say so?
> > > > status represents driver state, not device state.
> > > > In fact, driver writes there and does not double check with the
> > > > sole exception of reset.
> > >
> > >
> > > For example, spec said
> > >
> > > """
> > >
> > > 2.1 Device Status Field
> >
> > yes, this is confusingly written
> 
> Anything makes you think it is confusing?


It says Device Status but most of it reflects the driver probe progress.
Compare to pci RO status and RW control.

> >
> > > During device initialization by a driver, the driver follows the
> > > sequence of steps specified in 3.1.
> > >
> > > The device status field provides a simple low-level indication of the
> > > completed steps of this sequence.
> >
> > And note the sequence is driver sequence.
> 
> Right but it means the driver needs to know the status of the device
> in order to proceed.

again this is not device status at all.



> >
> > > It’s most useful to imagine it
> > > hooked up to traffic lights on the console indicating the status of
> > > each device. The following bits are defined (listed below in the order
> > > in which they would be typically set):
> > >
> > > """
> >
> >
> >
> >
> > > Driver knows its own state, so there's no need for the driver to read
> > > it from the device.
> >
> > That is why it never reads status.
> 
> Well, looking at the current Linux drivers there're plenty (in virtio
> core, there could be other in the transport)
> 
> drivers/virtio/virtio.c:        return sysfs_emit(buf, "0x%08x\n",
> dev->config->get_status(dev));
> drivers/virtio/virtio.c:        dev->config->set_status(dev,
> dev->config->get_status(dev) | status);
> drivers/virtio/virtio.c:        status = dev->config->get_status(dev);
> drivers/virtio/virtio.c:        if (!(dev->config->get_status(dev) &
> VIRTIO_CONFIG_S_DRIVER_OK))
> drivers/virtio/virtio.c:        WARN_ON_ONCE(dev->config->get_status(dev));
> drivers/virtio/virtio.c:        dev->failed =
> dev->config->get_status(dev) & VIRTIO_CONFIG_S_FAILED;
> drivers/virtio/virtio.c:        if (!(dev->config->get_status(dev) &
> VIRTIO_CONFIG_S_DRIVER_OK))

It's done like this for robustness and simplicity.
But we could easily cache it in the driver on write.


> >
> >
> > > >
> > > > > And 0 is a valid status which means device
> > > > > is resetted:
> > > > >
> > > > > """
> > > > > The driver SHOULD consider a driver-initiated reset complete when it
> > > > > reads device status as 0.
> > > > > """
> > > >
> > > > It means all registers have their reset values,
> > >
> > > This is exactly the device status? Drivers need to know that there's a
> > > device state that is safe to start to program.
> >
> > yes but otherwise, all registers respond normally
> > device is assumed to be fully operational, and
> > it is assumed that no time at all is needed to
> > get from that to DRIVER.
> >
> >
> > > > but it is
> > > > not a special state in that device behaves normally in this
> > > > state, it does not need to be handles in any special way.
> > > >
> > > > Contrast with suspend where device does not respond and
> > > > must be first resumed.
> > >
> > > I think not. Driver can choose to reset the device when the device is suspended.
> > >
> > > Thanks
> >
> > Yes, reset should take device out of suspend.
> 
> Thanks
> 
> >
> > > >
> > >
> > >
> > > >
> > > > --
> > > > MST
> > > >
> >


  reply	other threads:[~2024-09-29 17:55 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-01 11:35 [PATCH V7 v7] virtio: introduce SUSPEND bit in device status Zhu Lingshan
2024-08-13  4:42 ` Parav Pandit
2024-08-13  5:44   ` Zhu Lingshan
2024-08-13  5:50     ` Parav Pandit
2024-08-13  6:14       ` Zhu Lingshan
2024-08-13  6:55         ` Parav Pandit
2024-08-15  8:23           ` Zhu Lingshan
2024-08-15  9:34             ` Parav Pandit
2024-08-30  2:31               ` Zhu Lingshan
2024-08-30  3:02                 ` Parav Pandit
2024-09-03  9:05                   ` Zhu Lingshan
2024-09-03  9:45                     ` Michael S. Tsirkin
2024-09-03 10:09                       ` Parav Pandit
2024-09-03 10:35                         ` Michael S. Tsirkin
2024-09-03 10:37                           ` Michael S. Tsirkin
2024-09-04  3:07                             ` Jason Wang
2024-09-04  4:02                               ` Michael S. Tsirkin
2024-09-04  6:31                                 ` Jason Wang
2024-09-04  6:38                                   ` Zhu Lingshan
2024-09-04  6:46                                     ` Parav Pandit
2024-09-05  7:14                                       ` Zhu Lingshan
2024-09-05  7:16                                         ` Parav Pandit
2024-09-05  7:29                                           ` Zhu Lingshan
2024-09-05  7:35                                             ` Parav Pandit
2024-09-05  8:30                                               ` Zhu Lingshan
2024-09-05  8:41                                                 ` David Stevens
2024-09-06  1:53                                                   ` Parav Pandit
2024-09-05  7:17                                         ` Michael S. Tsirkin
2024-09-05  7:31                                           ` Zhu Lingshan
2024-09-05  7:34                                             ` Parav Pandit
2024-09-05  6:51                                     ` Michael S. Tsirkin
2024-09-05  7:12                                       ` Zhu Lingshan
2024-09-05  8:12                                         ` Michael S. Tsirkin
2024-09-05  9:09                                           ` Zhu Lingshan
2024-09-06  1:54                                             ` Parav Pandit
2024-09-05 23:51                                           ` Jason Wang
2024-09-11  3:52                                             ` Zhu Lingshan
2024-09-11 10:20                                             ` Michael S. Tsirkin
2024-09-12  2:05                                               ` Jason Wang
2024-09-12  5:44                                                 ` Michael S. Tsirkin
2024-09-24  7:35                                                   ` Jason Wang
2024-09-24 23:05                                                     ` Michael S. Tsirkin
2024-09-25  3:47                                                       ` Jason Wang
2024-09-25 11:17                                                         ` Michael S. Tsirkin
2024-09-27  4:08                                                           ` Jason Wang
2024-09-29 17:55                                                             ` Michael S. Tsirkin [this message]
2024-10-17  6:56                                                               ` Jason Wang
2024-09-03 10:28                     ` Parav Pandit
2024-09-05  7:20                       ` Zhu Lingshan
2024-08-15 10:45             ` Michael S. Tsirkin
2024-08-30  2:32               ` Zhu Lingshan
2024-08-15 10:52           ` Michael S. Tsirkin
2024-08-15 10:59             ` Parav Pandit
2024-08-15 15:07               ` Michael S. Tsirkin
2024-08-17  5:19                 ` Parav Pandit
2024-08-30  2:37                 ` Zhu Lingshan
2024-08-30  3:10                   ` Parav Pandit
2024-09-03  8:51                     ` Zhu Lingshan
2024-09-03  8:55                       ` Parav Pandit
2024-09-03  9:36                       ` Michael S. Tsirkin
2024-09-05  7:27                         ` Zhu Lingshan
2024-09-24 23:07                           ` Michael S. Tsirkin
2024-08-13  7:51   ` Michael S. Tsirkin
2024-08-13  7:58     ` Parav Pandit
2024-08-13  8:03       ` Michael S. Tsirkin
2024-08-13  8:01 ` Michael S. Tsirkin
2024-08-15  9:12   ` Zhu Lingshan
2024-08-15 10:50     ` Michael S. Tsirkin
2024-08-30  2:20       ` Zhu Lingshan

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=20240929135241-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=cohuck@redhat.com \
    --cc=eperezma@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=lingshan.zhu@amd.com \
    --cc=parav@nvidia.com \
    --cc=stevensd@chromium.org \
    --cc=virtio-comment@lists.linux.dev \
    /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