From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o7A9D-003AB5-JA for linux-um@lists.infradead.org; Fri, 01 Jul 2022 06:29:02 +0000 Received: by mail-ed1-f72.google.com with SMTP id n8-20020a05640205c800b00434fb0c150cso1068157edx.19 for ; Thu, 30 Jun 2022 23:28:54 -0700 (PDT) Date: Fri, 1 Jul 2022 02:28:46 -0400 From: "Michael S. Tsirkin" Subject: Re: [PATCH v11 02/40] virtio: struct virtio_config_ops add callbacks for queue_reset Message-ID: <20220701022728-mutt-send-email-mst@kernel.org> References: <20220629065656.54420-1-xuanzhuo@linux.alibaba.com> <20220629065656.54420-3-xuanzhuo@linux.alibaba.com> MIME-Version: 1.0 In-Reply-To: <20220629065656.54420-3-xuanzhuo@linux.alibaba.com> Content-Disposition: inline List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-um" Errors-To: linux-um-bounces+geert=linux-m68k.org@lists.infradead.org To: Xuan Zhuo Cc: virtualization@lists.linux-foundation.org, Richard Weinberger , Anton Ivanov , Johannes Berg , Jason Wang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Hans de Goede , Mark Gross , Vadim Pasternak , Bjorn Andersson , Mathieu Poirier , Cornelia Huck , Halil Pasic , Eric Farman , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Vincent Whitchurch , linux-um@lists.infradead.org, netdev@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, bpf@vger.kernel.org, kangjie.xu@linux.alibaba.com On Wed, Jun 29, 2022 at 02:56:18PM +0800, Xuan Zhuo wrote: > reset can be divided into the following four steps (example): > 1. transport: notify the device to reset the queue > 2. vring: recycle the buffer submitted > 3. vring: reset/resize the vring (may re-alloc) > 4. transport: mmap vring to device, and enable the queue > > In order to support queue reset, add two callbacks(reset_vq, > enable_reset_vq) in struct virtio_config_ops to implement steps 1 and 4. > > Signed-off-by: Xuan Zhuo > --- > include/linux/virtio_config.h | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h > index b47c2e7ed0ee..ded51b0d4823 100644 > --- a/include/linux/virtio_config.h > +++ b/include/linux/virtio_config.h > @@ -78,6 +78,16 @@ struct virtio_shm_region { > * @set_vq_affinity: set the affinity for a virtqueue (optional). > * @get_vq_affinity: get the affinity for a virtqueue (optional). > * @get_shm_region: get a shared memory region based on the index. > + * @reset_vq: reset a queue individually (optional). > + * vq: the virtqueue > + * Returns 0 on success or error status > + * reset_vq will guarantee that the callbacks are disabled and synchronized. > + * Except for the callback, the caller should guarantee that the vring is > + * not accessed by any functions of virtqueue. > + * @enable_reset_vq: enable a reset queue > + * vq: the virtqueue > + * Returns 0 on success or error status > + * If reset_vq is set, then enable_reset_vq must also be set. > */ > typedef void vq_callback_t(struct virtqueue *); > struct virtio_config_ops { > @@ -104,6 +114,8 @@ struct virtio_config_ops { > int index); > bool (*get_shm_region)(struct virtio_device *vdev, > struct virtio_shm_region *region, u8 id); > + int (*reset_vq)(struct virtqueue *vq); > + int (*enable_reset_vq)(struct virtqueue *vq); > }; The names need some tweaking. I came up with int (*disable_vq_and_reset)(struct virtqueue *vq); int (*enable_vq_after_reset)(struct virtqueue *vq); > /* If driver didn't advertise the feature, it will never appear. */ > -- > 2.31.0 _______________________________________________ linux-um mailing list linux-um@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-um