linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>, Cornelia Huck <cohuck@redhat.com>
Cc: linux-kernel@vger.kernel.org,
	virtualization@lists.linux-foundation.org, sgarzare@redhat.com,
	eperezma@redhat.com, lulu@redhat.com, tglx@linutronix.de,
	peterz@infradead.org, paulmck@kernel.org, maz@kernel.org,
	pasic@linux.ibm.com
Subject: Re: [PATCH V3 7/9] virtio: allow to unbreak virtqueue
Date: Tue, 26 Apr 2022 11:45:15 +0800	[thread overview]
Message-ID: <560bcbe5-f0db-ed61-8ec0-043031145fe4@redhat.com> (raw)
In-Reply-To: <20220425100349-mutt-send-email-mst@kernel.org>


在 2022/4/25 22:04, Michael S. Tsirkin 写道:
> On Mon, Apr 25, 2022 at 02:44:06PM +0200, Cornelia Huck wrote:
>> On Mon, Apr 25 2022, Jason Wang <jasowang@redhat.com> wrote:
>>
>>> This patch allows the virtio_break_device() to accept a boolean value
>>> then we can unbreak the virtqueue.
>>>
>>> Signed-off-by: Jason Wang <jasowang@redhat.com>
>>> ---
>>>   drivers/char/virtio_console.c              | 2 +-
>>>   drivers/crypto/virtio/virtio_crypto_core.c | 2 +-
>>>   drivers/s390/virtio/virtio_ccw.c           | 4 ++--
>>>   drivers/virtio/virtio_pci_common.c         | 2 +-
>>>   drivers/virtio/virtio_ring.c               | 4 ++--
>>>   include/linux/virtio.h                     | 2 +-
>>>   6 files changed, 8 insertions(+), 8 deletions(-)
>>>
>>> diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
>>> index e3c430539a17..afede977f7b3 100644
>>> --- a/drivers/char/virtio_console.c
>>> +++ b/drivers/char/virtio_console.c
>>> @@ -1958,7 +1958,7 @@ static void virtcons_remove(struct virtio_device *vdev)
>>>   	spin_unlock_irq(&pdrvdata_lock);
>>>   
>>>   	/* Device is going away, exit any polling for buffers */
>>> -	virtio_break_device(vdev);
>>> +	virtio_break_device(vdev, true);
>>>   	if (use_multiport(portdev))
>>>   		flush_work(&portdev->control_work);
>>>   	else
>>> diff --git a/drivers/crypto/virtio/virtio_crypto_core.c b/drivers/crypto/virtio/virtio_crypto_core.c
>>> index c6f482db0bc0..fd17f3f2e958 100644
>>> --- a/drivers/crypto/virtio/virtio_crypto_core.c
>>> +++ b/drivers/crypto/virtio/virtio_crypto_core.c
>>> @@ -215,7 +215,7 @@ static int virtcrypto_update_status(struct virtio_crypto *vcrypto)
>>>   		dev_warn(&vcrypto->vdev->dev,
>>>   				"Unknown status bits: 0x%x\n", status);
>>>   
>>> -		virtio_break_device(vcrypto->vdev);
>>> +		virtio_break_device(vcrypto->vdev, true);
>>>   		return -EPERM;
>>>   	}
>>>   
>>> diff --git a/drivers/s390/virtio/virtio_ccw.c b/drivers/s390/virtio/virtio_ccw.c
>>> index c19f07a82d62..9a963f5af5b5 100644
>>> --- a/drivers/s390/virtio/virtio_ccw.c
>>> +++ b/drivers/s390/virtio/virtio_ccw.c
>>> @@ -1211,7 +1211,7 @@ static void virtio_ccw_remove(struct ccw_device *cdev)
>>>   
>>>   	if (vcdev && cdev->online) {
>>>   		if (vcdev->device_lost)
>>> -			virtio_break_device(&vcdev->vdev);
>>> +			virtio_break_device(&vcdev->vdev, true);
>>>   		unregister_virtio_device(&vcdev->vdev);
>>>   		spin_lock_irqsave(get_ccwdev_lock(cdev), flags);
>>>   		dev_set_drvdata(&cdev->dev, NULL);
>>> @@ -1228,7 +1228,7 @@ static int virtio_ccw_offline(struct ccw_device *cdev)
>>>   	if (!vcdev)
>>>   		return 0;
>>>   	if (vcdev->device_lost)
>>> -		virtio_break_device(&vcdev->vdev);
>>> +		virtio_break_device(&vcdev->vdev, true);
>>>   	unregister_virtio_device(&vcdev->vdev);
>>>   	spin_lock_irqsave(get_ccwdev_lock(cdev), flags);
>>>   	dev_set_drvdata(&cdev->dev, NULL);
>>> diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c
>>> index d724f676608b..39a711ddff30 100644
>>> --- a/drivers/virtio/virtio_pci_common.c
>>> +++ b/drivers/virtio/virtio_pci_common.c
>>> @@ -583,7 +583,7 @@ static void virtio_pci_remove(struct pci_dev *pci_dev)
>>>   	 * layers can abort any ongoing operation.
>>>   	 */
>>>   	if (!pci_device_is_present(pci_dev))
>>> -		virtio_break_device(&vp_dev->vdev);
>>> +		virtio_break_device(&vp_dev->vdev, true);
>>>   
>>>   	pci_disable_sriov(pci_dev);
>>>   
>>> diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
>>> index cfb028ca238e..6da13495a70c 100644
>>> --- a/drivers/virtio/virtio_ring.c
>>> +++ b/drivers/virtio/virtio_ring.c
>>> @@ -2382,7 +2382,7 @@ EXPORT_SYMBOL_GPL(virtqueue_is_broken);
>>>    * This should prevent the device from being used, allowing drivers to
>>>    * recover.  You may need to grab appropriate locks to flush.
>>>    */
>>> -void virtio_break_device(struct virtio_device *dev)
>>> +void virtio_break_device(struct virtio_device *dev, bool broken)
>> I think we need to be careful to say when it is safe to unset 'broken'.
>>
>> The current callers set all queues to broken in case of surprise removal
>> (ccw, pci), removal (console), or the device behaving badly
>> (crypto). There's also code setting individual queues to broken. We do
>> not want to undo any of these, unless the device has gone through a
>> reset in the meanwhile. Maybe add:
>>
>> "It is only safe to call this function to *remove* the broken flag for a
>> device that is (re)transitioning to becoming usable; calling it that way
>> during normal usage may have unpredictable consequences."
>>
>> (Not sure how to word this; especially if we consider future usage of
>> queue reset.)
>
> Right. I would prefer __virtio_unbreak_device or something similar


Ok, so I think then we don't want it to be exported.


> with a bit comment explaining it's only safe to call during probe.


Will do.

Thanks


>


  reply	other threads:[~2022-04-26  3:45 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-25  2:44 [PATCH V3 0/9] rework on the IRQ hardening of virtio Jason Wang
2022-04-25  2:44 ` [PATCH V3 1/9] virtio: use virtio_device_ready() in virtio_device_restore() Jason Wang
2022-04-28  9:07   ` Cornelia Huck
2022-04-25  2:44 ` [PATCH V3 2/9] virtio: use virtio_reset_device() when possible Jason Wang
2022-04-28  9:07   ` Cornelia Huck
2022-04-25  2:44 ` [PATCH V3 3/9] virtio: introduce config op to synchronize vring callbacks Jason Wang
2022-04-28  9:13   ` Cornelia Huck
2022-04-29  2:08     ` Jason Wang
2022-04-29  7:25       ` Cornelia Huck
2022-05-05  8:15         ` Jason Wang
2022-04-25  2:44 ` [PATCH V3 4/9] virtio-pci: implement synchronize_cbs() Jason Wang
2022-04-25  2:44 ` [PATCH V3 5/9] virtio-mmio: " Jason Wang
2022-04-25  2:44 ` [PATCH V3 6/9] virtio-ccw: " Jason Wang
2022-04-25  8:08   ` Michael S. Tsirkin
2022-04-25  8:54     ` Cornelia Huck
2022-04-25 13:59       ` Michael S. Tsirkin
2022-04-26  2:29         ` Halil Pasic
2022-04-26  3:35           ` Michael S. Tsirkin
2022-04-26  3:38             ` Michael S. Tsirkin
2022-04-26  3:42               ` Jason Wang
2022-04-26  3:53                 ` Michael S. Tsirkin
2022-04-26  3:55                   ` Michael S. Tsirkin
2022-04-26  4:07                     ` Jason Wang
2022-04-26  6:30                       ` Michael S. Tsirkin
2022-04-27  3:53                         ` Jason Wang
2022-04-27  6:28                           ` Michael S. Tsirkin
2022-04-27  6:30                           ` Michael S. Tsirkin
2022-04-27  7:57                             ` Jason Wang
2022-04-27 15:15                               ` Michael S. Tsirkin
2022-04-26 15:47                     ` Cornelia Huck
2022-04-26 16:43                       ` Michael S. Tsirkin
2022-04-27  9:27                         ` Cornelia Huck
2022-04-28  2:43                           ` Halil Pasic
2022-04-28  3:04                             ` Jason Wang
2022-04-28  5:24                               ` Michael S. Tsirkin
2022-04-28  5:51                                 ` Jason Wang
2022-04-28  5:55                                   ` Michael S. Tsirkin
2022-04-28  6:02                                     ` Jason Wang
2022-04-28  6:17                                       ` Michael S. Tsirkin
2022-04-28  7:42                                       ` Cornelia Huck
2022-04-29  2:02                                         ` Jason Wang
2022-04-28  4:12                             ` Michael S. Tsirkin
2022-04-26  2:50       ` Halil Pasic
2022-04-26  3:46         ` Jason Wang
     [not found]   ` <20220426053856.3325-1-hdanton@sina.com>
2022-04-26  5:59     ` Jason Wang
2022-04-25  2:44 ` [PATCH V3 7/9] virtio: allow to unbreak virtqueue Jason Wang
2022-04-25 12:44   ` Cornelia Huck
2022-04-25 14:04     ` Michael S. Tsirkin
2022-04-26  3:45       ` Jason Wang [this message]
2022-04-25  2:44 ` [PATCH V3 8/9] virtio: harden vring IRQ Jason Wang
2022-04-25  2:44 ` [PATCH V3 9/9] virtio: use WARN_ON() to warning illegal status value Jason Wang
2022-04-25  2:49 ` [PATCH V3 0/9] rework on the IRQ hardening of virtio 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=560bcbe5-f0db-ed61-8ec0-043031145fe4@redhat.com \
    --to=jasowang@redhat.com \
    --cc=cohuck@redhat.com \
    --cc=eperezma@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lulu@redhat.com \
    --cc=maz@kernel.org \
    --cc=mst@redhat.com \
    --cc=pasic@linux.ibm.com \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=sgarzare@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=virtualization@lists.linux-foundation.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 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).