From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AEC03C433FE for ; Fri, 27 May 2022 07:34:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347545AbiE0HeL (ORCPT ); Fri, 27 May 2022 03:34:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347412AbiE0HeB (ORCPT ); Fri, 27 May 2022 03:34:01 -0400 Received: from out199-4.us.a.mail.aliyun.com (out199-4.us.a.mail.aliyun.com [47.90.199.4]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33975F7481; Fri, 27 May 2022 00:33:59 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R121e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=alimailimapcm10staff010182156082;MF=xuanzhuo@linux.alibaba.com;NM=1;PH=DS;RN=16;SR=0;TI=SMTPD_---0VEW7k5j_1653636835; Received: from localhost(mailfrom:xuanzhuo@linux.alibaba.com fp:SMTPD_---0VEW7k5j_1653636835) by smtp.aliyun-inc.com(127.0.0.1); Fri, 27 May 2022 15:33:55 +0800 Message-ID: <1653636827.6549792-6-xuanzhuo@linux.alibaba.com> Subject: Re: [PATCH V6 7/9] virtio: allow to unbreak virtqueue Date: Fri, 27 May 2022 15:33:47 +0800 From: Xuan Zhuo To: Jason Wang Cc: tglx@linutronix.de, peterz@infradead.org, paulmck@kernel.org, maz@kernel.org, pasic@linux.ibm.com, cohuck@redhat.com, eperezma@redhat.com, lulu@redhat.com, sgarzare@redhat.com, Vineeth Vijayan , Peter Oberparleiter , linux-s390@vger.kernel.org, mst@redhat.com, jasowang@redhat.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org References: <20220527060120.20964-1-jasowang@redhat.com> <20220527060120.20964-8-jasowang@redhat.com> In-Reply-To: <20220527060120.20964-8-jasowang@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 27 May 2022 14:01:18 +0800, Jason Wang wrote: > This patch allows the new introduced __virtio_break_device() to > unbreak the virtqueue. > > Cc: Thomas Gleixner > Cc: Peter Zijlstra > Cc: "Paul E. McKenney" > Cc: Marc Zyngier > Cc: Halil Pasic > Cc: Cornelia Huck > Cc: Vineeth Vijayan > Cc: Peter Oberparleiter > Cc: linux-s390@vger.kernel.org > Signed-off-by: Jason Wang Reviewed-by: Xuan Zhuo > --- > drivers/virtio/virtio_ring.c | 22 ++++++++++++++++++++++ > include/linux/virtio.h | 1 + > 2 files changed, 23 insertions(+) > > diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c > index 9d0bae4293be..9c231e1fded7 100644 > --- a/drivers/virtio/virtio_ring.c > +++ b/drivers/virtio/virtio_ring.c > @@ -2395,6 +2395,28 @@ void virtio_break_device(struct virtio_device *dev) > } > EXPORT_SYMBOL_GPL(virtio_break_device); > > +/* > + * This should allow the device to be used by the driver. You may > + * need to grab appropriate locks to flush the write to > + * vq->broken. This should only be used in some specific case e.g > + * (probing and restoring). This function should only be called by the > + * core, not directly by the driver. > + */ > +void __virtio_unbreak_device(struct virtio_device *dev) > +{ > + struct virtqueue *_vq; > + > + spin_lock(&dev->vqs_list_lock); > + list_for_each_entry(_vq, &dev->vqs, list) { > + struct vring_virtqueue *vq = to_vvq(_vq); > + > + /* Pairs with READ_ONCE() in virtqueue_is_broken(). */ > + WRITE_ONCE(vq->broken, false); > + } > + spin_unlock(&dev->vqs_list_lock); > +} > +EXPORT_SYMBOL_GPL(__virtio_unbreak_device); > + > dma_addr_t virtqueue_get_desc_addr(struct virtqueue *_vq) > { > struct vring_virtqueue *vq = to_vvq(_vq); > diff --git a/include/linux/virtio.h b/include/linux/virtio.h > index 5464f398912a..d8fdf170637c 100644 > --- a/include/linux/virtio.h > +++ b/include/linux/virtio.h > @@ -131,6 +131,7 @@ void unregister_virtio_device(struct virtio_device *dev); > bool is_virtio_device(struct device *dev); > > void virtio_break_device(struct virtio_device *dev); > +void __virtio_unbreak_device(struct virtio_device *dev); > > void virtio_config_changed(struct virtio_device *dev); > #ifdef CONFIG_PM_SLEEP > -- > 2.25.1 >