All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
	Virtio-Dev <virtio-dev@lists.oasis-open.org>
Subject: Re: [virtio-dev] queue_enable vs QueueReady
Date: Fri, 29 May 2020 10:57:03 +0800	[thread overview]
Message-ID: <95d6aa67-9a6e-e264-38b2-392dfffda8ef@redhat.com> (raw)
In-Reply-To: <20200528140040.GD158218@stefanha-x1.localdomain>


On 2020/5/28 下午10:00, Stefan Hajnoczi wrote:
> On Thu, May 28, 2020 at 09:06:36PM +0800, Jason Wang wrote:
>> Hi:
>>
>> I found ambiguity in the virtio specification:
>>
>> In PCI part, it describes the queue_enable as:
>>
>> The driver uses this to selectively prevent the device from executing
>> requests from this virtqueue. 1 - enabled; 0 - disabled.
>>
>> In MMIO part, it describes the QueueReady as:
>>
>> Writing one (0x1) to this register notifies the device that it can execute
>> requests from this virtual queue. Reading from this register returns the
>> last value written to it. Both read and write accesses apply to the queue
>> selected by writing to QueueSel.
>>
>> If I understand this correctly, they have the same meaning, but the driver
>> requirements section looks conflict:
>>
>> PCI said: The driver MUST NOT write a 0 to queue_enable.
>>
>> MMIO said:
>>
>> To stop using the queue the driver MUST write zero (0x0) to this QueueReady
>> and MUST read the value back to ensure synchronization.
>>
>> So we can't disable a queue via queue_enable but QueueReady. Any reason for
>> such inconsistency?
> I think MMIO is the outlier here. The device emulation code in QEMU
> doesn't deal with queue shutdown. That only happens during device reset,
> so it's like that a if the guest disables a virtio-mmio queue then
> something undefined will happen on the QEMU side.


Qemu's MMIO only implement the fucntion of value write and read. Its PCI 
implementation is also buggy which assumes the value is one.


>   For example, writing
> used elements back to the virtqueue after it has been disabled.


Ok, but kernel virtio-mmio driver did the following in vm_del_vq():

     /* Select and deactivate the queue */
     writel(index, vm_dev->base + VIRTIO_MMIO_QUEUE_SEL);
     if (vm_dev->version == 1) {
         writel(0, vm_dev->base + VIRTIO_MMIO_QUEUE_PFN);
     } else {
         writel(0, vm_dev->base + VIRTIO_MMIO_QUEUE_READY);
         WARN_ON(readl(vm_dev->base + VIRTIO_MMIO_QUEUE_READY));
     }

Which tries to align with the spec ...


>
> If the VIRTIO spec really intends to support virtqueue shutdown then the
> semantics need to be spelled out clearly: what happens to in-flight
> requests? How do devices behave that rely on multiple virtqueues during
> normal operation (e.g. virtio-vsock where you can't really have rx-only
> or tx-only)?


If we plan to do this, we need do something similar to status. That 
means driver must wait for a read of queue_enable to return 0.

For in-flight request we can do the same thing as device reset but just 
for a virtqueue probably.

Thanks


>
> Stefan


---------------------------------------------------------------------
To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org


  reply	other threads:[~2020-05-29  2:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-28 13:06 [virtio-dev] queue_enable vs QueueReady Jason Wang
2020-05-28 14:00 ` Stefan Hajnoczi
2020-05-29  2:57   ` Jason Wang [this message]
2020-06-01  6:01 ` [virtio-dev] " Michael S. Tsirkin
2020-06-02  2:57   ` Jason Wang
2020-06-02  4:20     ` Michael S. Tsirkin
2020-06-02  6:46       ` 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=95d6aa67-9a6e-e264-38b2-392dfffda8ef@redhat.com \
    --to=jasowang@redhat.com \
    --cc=mst@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=virtio-dev@lists.oasis-open.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: link
Be 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.