Skip to contentSkip to conversation

vdpa: add VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK flag

RFC Jason Wang 3 participants 6 messages May 24, 2023 – May 26, 2023 6 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): CAJaqyWfSzqdyPHogzccuYBeThJgcx-A_AfF8tmqLgxKNVczBWA@mail.gmail.com

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): CAJaqyWd632RiE9Zhc8OLsQbnaC42VG1FW97UMDHPQRofukYPrg@mail.gmail.com

Jason Wang

author
#6 lore raw
Quoted 42 lines · Eugenio Perez Martin
Quoted 31 lines · Shannon Nelson
Quoted 23 lines · Eugenio Perez Martin
Quoted 7 lines · Michael S. Tsirkin
Quoted 5 lines · Eugenio Pérez
---
  include/uapi/linux/vhost_types.h | 2 ++
  1 file changed, 2 insertions(+)
Quoted 13 lines

include/uapi/linux/vhost_types.h struct vhost_vdpa_iova_range { · line 168

Quoted 9 lines
include/uapi/linux/vhost_types.h +1 -0
index c5690a8992d8..a1b316f49b38 100644
@@ -165,5 +165,7 @@ struct vhost_vdpa_iova_range {
  #define VHOST_BACKEND_F_SUSPEND  0x4
  /* Device can be resumed */
  #define VHOST_BACKEND_F_RESUME  0x5
+/* Device can enable virtqueues after DRIVER_OK */

A bit more detail on what does this mean?
It's normally driver that enables VQs not device itself ...

Quoted 5 lines

I agree, it is not well explained.

What about "Device supports the driver to enable virtqueues after DRIVER_OK"?

Quoted 1 line
Quoted 1 line
include/uapi/linux/vhost_types.h +1 -0
+#define VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK  0x6
Quoted 8 lines

Does this mean it is possible only after DRIVER_OK, or does it mean in addition to before DRIVER_OK? It isn't clear to me.

Maybe something like
"Device supports virtqueue enable only after DRIVER_OK" or
"Device supports virtqueue enable both before and after DRIVER_OK"

Quoted 6 lines

I agree too,

With the previous suggestion it would be:

"Device supports the driver to enable virtqueues both before and after DRIVER_OK"

Btw, I think it might be worth clarifying whether or not this is supported by the current virtio spec. Spec seems to be unclear on this:

1) The driver MUST NOT write a 0 to queue_enable.
2) if reset is support, driver can wrote 1 to re-enable a virtqueue

But it doesn't say if the driver can write 1 after DRIVER_OK without reset.

Thanks

Quoted 16 lines

Does it look better?

Thanks!

Quoted 10 lines

sln

Quoted 6 lines
Quoted 5 lines
Quoted 4 lines
include/uapi/linux/vhost_types.h +0 -1
  #endif
--

2.31.1

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

#7 lore raw
Quoted 55 lines · Jason Wang
Quoted 42 lines · Eugenio Perez Martin
Quoted 31 lines · Shannon Nelson
Quoted 23 lines · Eugenio Perez Martin
Quoted 7 lines · Michael S. Tsirkin
Quoted 5 lines · Eugenio Pérez
---
  include/uapi/linux/vhost_types.h | 2 ++
  1 file changed, 2 insertions(+)
Quoted 13 lines

include/uapi/linux/vhost_types.h struct vhost_vdpa_iova_range { · line 168

Quoted 9 lines
include/uapi/linux/vhost_types.h +1 -0
index c5690a8992d8..a1b316f49b38 100644
@@ -165,5 +165,7 @@ struct vhost_vdpa_iova_range {
  #define VHOST_BACKEND_F_SUSPEND  0x4
  /* Device can be resumed */
  #define VHOST_BACKEND_F_RESUME  0x5
+/* Device can enable virtqueues after DRIVER_OK */

A bit more detail on what does this mean?
It's normally driver that enables VQs not device itself ...

Quoted 5 lines

I agree, it is not well explained.

What about "Device supports the driver to enable virtqueues after DRIVER_OK"?

Quoted 1 line
Quoted 1 line
include/uapi/linux/vhost_types.h +1 -0
+#define VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK  0x6
Quoted 8 lines

Does this mean it is possible only after DRIVER_OK, or does it mean in addition to before DRIVER_OK? It isn't clear to me.

Maybe something like
"Device supports virtqueue enable only after DRIVER_OK" or
"Device supports virtqueue enable both before and after DRIVER_OK"

Quoted 6 lines

I agree too,

With the previous suggestion it would be:

"Device supports the driver to enable virtqueues both before and after DRIVER_OK"

Btw, I think it might be worth clarifying whether or not this is supported by the current virtio spec. Spec seems to be unclear on this:

Quoted 6 lines

1) The driver MUST NOT write a 0 to queue_enable.
2) if reset is support, driver can wrote 1 to re-enable a virtqueue

But it doesn't say if the driver can write 1 after DRIVER_OK without reset.

Thanks

I don't think it can. Do any drivers do this?

Quoted 10 lines
Quoted 10 lines

Does it look better?

Thanks!

Quoted 4 lines

sln

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 5 lines
Quoted 4 lines
Quoted 3 lines

#endif
--
2.31.1

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

author
#8 lore raw
Quoted 57 lines · Michael S. Tsirkin
Quoted 55 lines · Jason Wang
Quoted 42 lines · Eugenio Perez Martin
Quoted 31 lines · Shannon Nelson
Quoted 23 lines · Eugenio Perez Martin
Quoted 7 lines · Michael S. Tsirkin
Quoted 5 lines · Eugenio Pérez
---
  include/uapi/linux/vhost_types.h | 2 ++
  1 file changed, 2 insertions(+)
Quoted 13 lines

include/uapi/linux/vhost_types.h struct vhost_vdpa_iova_range { · line 168

Quoted 9 lines
include/uapi/linux/vhost_types.h +1 -0
index c5690a8992d8..a1b316f49b38 100644
@@ -165,5 +165,7 @@ struct vhost_vdpa_iova_range {
  #define VHOST_BACKEND_F_SUSPEND  0x4
  /* Device can be resumed */
  #define VHOST_BACKEND_F_RESUME  0x5
+/* Device can enable virtqueues after DRIVER_OK */

A bit more detail on what does this mean?
It's normally driver that enables VQs not device itself ...

Quoted 5 lines

I agree, it is not well explained.

What about "Device supports the driver to enable virtqueues after DRIVER_OK"?

Quoted 1 line
Quoted 1 line
include/uapi/linux/vhost_types.h +1 -0
+#define VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK  0x6
Quoted 8 lines

Does this mean it is possible only after DRIVER_OK, or does it mean in addition to before DRIVER_OK? It isn't clear to me.

Maybe something like
"Device supports virtqueue enable only after DRIVER_OK" or
"Device supports virtqueue enable both before and after DRIVER_OK"

Quoted 6 lines

I agree too,

With the previous suggestion it would be:

"Device supports the driver to enable virtqueues both before and after DRIVER_OK"

Btw, I think it might be worth clarifying whether or not this is supported by the current virtio spec. Spec seems to be unclear on this:

Quoted 8 lines
Quoted 6 lines

1) The driver MUST NOT write a 0 to queue_enable.
2) if reset is support, driver can wrote 1 to re-enable a virtqueue

But it doesn't say if the driver can write 1 after DRIVER_OK without reset.

Thanks

I don't think it can. Do any drivers do this?

I don't know. But the spec is unclear in this. And Qemu seems to support this which is probably a side effect since vq reset.

    case VIRTIO_PCI_COMMON_Q_ENABLE:
        if (val == 1) {
            virtio_queue_set_num(vdev, vdev->queue_sel,
                                 proxy->vqs[vdev->queue_sel].num);
            virtio_queue_set_rings(vdev, vdev->queue_sel,
                       ((uint64_t)proxy->vqs[vdev->queue_sel].desc[1]) << 32 |
                       proxy->vqs[vdev->queue_sel].desc[0],
                       ((uint64_t)proxy->vqs[vdev->queue_sel].avail[1]) << 32 |
                       proxy->vqs[vdev->queue_sel].avail[0],
                       ((uint64_t)proxy->vqs[vdev->queue_sel].used[1]) << 32 |
                       proxy->vqs[vdev->queue_sel].used[0]);
            proxy->vqs[vdev->queue_sel].enabled = 1;
            proxy->vqs[vdev->queue_sel].reset = 0;
            virtio_queue_enable(vdev, vdev->queue_sel);

We need either

1) relax the spec to allow this feature
2) or fix the qemu (not sure if it's too late to do this) and have a new feature for queue_enable after DRIVER_OK

Thanks

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines

Does it look better?

Thanks!

Quoted 4 lines

sln

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 5 lines
Quoted 4 lines
Quoted 3 lines

#endif
--
2.31.1

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

#9 lore raw
In reply to Jason Wang
Quoted 52 lines · Jason Wang
Quoted 42 lines · Eugenio Perez Martin
Quoted 31 lines · Shannon Nelson
Quoted 23 lines · Eugenio Perez Martin
Quoted 7 lines · Michael S. Tsirkin
Quoted 5 lines · Eugenio Pérez
---
  include/uapi/linux/vhost_types.h | 2 ++
  1 file changed, 2 insertions(+)
Quoted 13 lines

include/uapi/linux/vhost_types.h struct vhost_vdpa_iova_range { · line 168

Quoted 9 lines
include/uapi/linux/vhost_types.h +1 -0
index c5690a8992d8..a1b316f49b38 100644
@@ -165,5 +165,7 @@ struct vhost_vdpa_iova_range {
  #define VHOST_BACKEND_F_SUSPEND  0x4
  /* Device can be resumed */
  #define VHOST_BACKEND_F_RESUME  0x5
+/* Device can enable virtqueues after DRIVER_OK */

A bit more detail on what does this mean?
It's normally driver that enables VQs not device itself ...

Quoted 5 lines

I agree, it is not well explained.

What about "Device supports the driver to enable virtqueues after DRIVER_OK"?

Quoted 1 line
Quoted 1 line
include/uapi/linux/vhost_types.h +1 -0
+#define VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK  0x6
Quoted 8 lines

Does this mean it is possible only after DRIVER_OK, or does it mean in addition to before DRIVER_OK? It isn't clear to me.

Maybe something like
"Device supports virtqueue enable only after DRIVER_OK" or
"Device supports virtqueue enable both before and after DRIVER_OK"

Quoted 6 lines

I agree too,

With the previous suggestion it would be:

"Device supports the driver to enable virtqueues both before and after DRIVER_OK"

Quoted 9 lines

Btw, I think it might be worth clarifying whether or not this is supported by the current virtio spec. Spec seems to be unclear on this:

1) The driver MUST NOT write a 0 to queue_enable.
2) if reset is support, driver can wrote 1 to re-enable a virtqueue

But it doesn't say if the driver can write 1 after DRIVER_OK without reset.

To double check, you mean to write 1 even if the queue is live? "without reset *the virtqueue*"?

I'd add another combination that might be worth clarifying: ack VIRTIO_F_RING_RESET, write 1 to queue_enable, then write 1 to queue_reset. Set state DRIVER_OK, and then enable the queue afterwards. Is this valid?

I guess it is not, but I don't see the standard forbidding it, isn't it?

Thanks!

Quoted 20 lines

Thanks

Quoted 16 lines

Does it look better?

Thanks!

Quoted 10 lines

sln

Quoted 6 lines
Quoted 5 lines
Quoted 4 lines
include/uapi/linux/vhost_types.h +0 -1
  #endif
--

2.31.1

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

author
#10 lore raw
Quoted 58 lines · Eugenio Perez Martin
Quoted 56 lines · Jason Wang
Quoted 42 lines · Eugenio Perez Martin
Quoted 31 lines · Shannon Nelson
Quoted 23 lines · Eugenio Perez Martin
Quoted 7 lines · Michael S. Tsirkin
Quoted 5 lines · Eugenio Pérez
---
  include/uapi/linux/vhost_types.h | 2 ++
  1 file changed, 2 insertions(+)
Quoted 13 lines

include/uapi/linux/vhost_types.h struct vhost_vdpa_iova_range { · line 168

Quoted 9 lines
include/uapi/linux/vhost_types.h +1 -0
index c5690a8992d8..a1b316f49b38 100644
@@ -165,5 +165,7 @@ struct vhost_vdpa_iova_range {
  #define VHOST_BACKEND_F_SUSPEND  0x4
  /* Device can be resumed */
  #define VHOST_BACKEND_F_RESUME  0x5
+/* Device can enable virtqueues after DRIVER_OK */

A bit more detail on what does this mean?
It's normally driver that enables VQs not device itself ...

Quoted 5 lines

I agree, it is not well explained.

What about "Device supports the driver to enable virtqueues after DRIVER_OK"?

Quoted 1 line
Quoted 1 line
include/uapi/linux/vhost_types.h +1 -0
+#define VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK  0x6
Quoted 8 lines

Does this mean it is possible only after DRIVER_OK, or does it mean in addition to before DRIVER_OK? It isn't clear to me.

Maybe something like
"Device supports virtqueue enable only after DRIVER_OK" or
"Device supports virtqueue enable both before and after DRIVER_OK"

Quoted 6 lines

I agree too,

With the previous suggestion it would be:

"Device supports the driver to enable virtqueues both before and after DRIVER_OK"

Btw, I think it might be worth clarifying whether or not this is supported by the current virtio spec. Spec seems to be unclear on this:

Quoted 8 lines
Quoted 5 lines

1) The driver MUST NOT write a 0 to queue_enable.
2) if reset is support, driver can wrote 1 to re-enable a virtqueue

But it doesn't say if the driver can write 1 after DRIVER_OK without reset.

To double check, you mean to write 1 even if the queue is live? "without reset *the virtqueue*"?

No I mean something like this

1) write queue_enable to cvq
2) set DRIVER_OK
3) restore
4) write queue_enable to txq 0

Quoted 5 lines

I'd add another combination that might be worth clarifying: ack VIRTIO_F_RING_RESET, write 1 to queue_enable, then write 1 to queue_reset. Set state DRIVER_OK, and then enable the queue afterwards. Is this valid?

Spec doesn't say it can't so it's implementation specific which is probably suboptimal. But as replied in another thread this seems to be supported by Qemu.

Quoted 2 lines

I guess it is not, but I don't see the standard forbidding it, isn't it?

Yes, this needs to be fixed.

But one point here is that we should make svq work without RING_RESET (or we can say if RING_REST implies the feature you proposed here)

Thanks

Quoted 24 lines

Thanks!

Quoted 20 lines

Thanks

Quoted 16 lines

Does it look better?

Thanks!

Quoted 10 lines

sln

Quoted 6 lines
Quoted 5 lines
Quoted 4 lines
include/uapi/linux/vhost_types.h +0 -1
  #endif
--

2.31.1

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

#11 lore raw
Quoted 78 lines · Jason Wang
Quoted 58 lines · Eugenio Perez Martin
Quoted 56 lines · Jason Wang
Quoted 42 lines · Eugenio Perez Martin
Quoted 31 lines · Shannon Nelson
Quoted 23 lines · Eugenio Perez Martin
Quoted 7 lines · Michael S. Tsirkin
Quoted 5 lines · Eugenio Pérez
---
  include/uapi/linux/vhost_types.h | 2 ++
  1 file changed, 2 insertions(+)
Quoted 13 lines

include/uapi/linux/vhost_types.h struct vhost_vdpa_iova_range { · line 168

Quoted 9 lines
include/uapi/linux/vhost_types.h +1 -0
index c5690a8992d8..a1b316f49b38 100644
@@ -165,5 +165,7 @@ struct vhost_vdpa_iova_range {
  #define VHOST_BACKEND_F_SUSPEND  0x4
  /* Device can be resumed */
  #define VHOST_BACKEND_F_RESUME  0x5
+/* Device can enable virtqueues after DRIVER_OK */

A bit more detail on what does this mean?
It's normally driver that enables VQs not device itself ...

Quoted 5 lines

I agree, it is not well explained.

What about "Device supports the driver to enable virtqueues after DRIVER_OK"?

Quoted 1 line
Quoted 1 line
include/uapi/linux/vhost_types.h +1 -0
+#define VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK  0x6
Quoted 8 lines

Does this mean it is possible only after DRIVER_OK, or does it mean in addition to before DRIVER_OK? It isn't clear to me.

Maybe something like
"Device supports virtqueue enable only after DRIVER_OK" or
"Device supports virtqueue enable both before and after DRIVER_OK"

Quoted 6 lines

I agree too,

With the previous suggestion it would be:

"Device supports the driver to enable virtqueues both before and after DRIVER_OK"

Btw, I think it might be worth clarifying whether or not this is supported by the current virtio spec. Spec seems to be unclear on this:

Quoted 8 lines
Quoted 5 lines

1) The driver MUST NOT write a 0 to queue_enable.
2) if reset is support, driver can wrote 1 to re-enable a virtqueue

But it doesn't say if the driver can write 1 after DRIVER_OK without reset.

To double check, you mean to write 1 even if the queue is live? "without reset *the virtqueue*"?

No I mean something like this

1) write queue_enable to cvq
2) set DRIVER_OK
3) restore
4) write queue_enable to txq 0

Quoted 1 line
Quoted 9 lines
Quoted 4 lines

I'd add another combination that might be worth clarifying: ack VIRTIO_F_RING_RESET, write 1 to queue_enable, then write 1 to queue_reset. Set state DRIVER_OK, and then enable the queue afterwards. Is this valid?

Spec doesn't say it can't so it's implementation specific which is probably suboptimal. But as replied in another thread this seems to be supported by Qemu.

Right, as long as the queue number is valid qemu allows it at this moment.

Quoted 8 lines
Quoted 2 lines

I guess it is not, but I don't see the standard forbidding it, isn't it?

Yes, this needs to be fixed.

But one point here is that we should make svq work without RING_RESET (or we can say if RING_REST implies the feature you proposed here)

If RING_RESET implies that the driver can enable just CVQ and that it can enable data vqs after DRIVER_OK and is easy to implement for hw vendors, I think it is easier to reuse it, instead of creating a new feature bit that overlaps so much with it.

Thanks!

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]