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 2E1FEC43219 for ; Wed, 9 Mar 2022 09:25:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232026AbiCIJ0n (ORCPT ); Wed, 9 Mar 2022 04:26:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230377AbiCIJ0n (ORCPT ); Wed, 9 Mar 2022 04:26:43 -0500 Received: from out30-56.freemail.mail.aliyun.com (out30-56.freemail.mail.aliyun.com [115.124.30.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEA0D158798; Wed, 9 Mar 2022 01:25:43 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R281e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04423;MF=xuanzhuo@linux.alibaba.com;NM=1;PH=DS;RN=33;SR=0;TI=SMTPD_---0V6j9G9H_1646817937; Received: from localhost(mailfrom:xuanzhuo@linux.alibaba.com fp:SMTPD_---0V6j9G9H_1646817937) by smtp.aliyun-inc.com(127.0.0.1); Wed, 09 Mar 2022 17:25:38 +0800 Message-ID: <1646817926.9029093-7-xuanzhuo@linux.alibaba.com> Subject: Re: [PATCH v7 13/26] virtio: queue_reset: struct virtio_config_ops add callbacks for queue_reset Date: Wed, 9 Mar 2022 17:25:26 +0800 From: Xuan Zhuo To: Jason Wang Cc: Jeff Dike , Richard Weinberger , Anton Ivanov , "Michael S. Tsirkin" , "David S. Miller" , Jakub Kicinski , Hans de Goede , Mark Gross , Vadim Pasternak , Bjorn Andersson , Mathieu Poirier , Cornelia Huck , Halil Pasic , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Alexander Gordeev , Sven Schnelle , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Johannes Berg , Vincent Whitchurch , linux-um@lists.infradead.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, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org References: <20220308123518.33800-1-xuanzhuo@linux.alibaba.com> <20220308123518.33800-14-xuanzhuo@linux.alibaba.com> In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Wed, 9 Mar 2022 16:47:11 +0800, Jason Wang wrote: > > =E5=9C=A8 2022/3/8 =E4=B8=8B=E5=8D=888:35, Xuan Zhuo =E5=86=99=E9=81=93: > > Performing reset on a queue is divided into four steps: > > > > 1. reset_vq() - notify the device to reset the qu= eue > > 2. virtqueue_detach_unused_buf() - recycle the buffer submitted > > 3. virtqueue_reset_vring() - reset the vring (may re-alloc) > > 4. enable_reset_vq() - mmap vring to device, and enable = the queue > > > > So add two callbacks reset_vq, enable_reset_vq to struct > > virtio_config_ops. > > > > Signed-off-by: Xuan Zhuo > > --- > > include/linux/virtio_config.h | 11 +++++++++++ > > 1 file changed, 11 insertions(+) > > > > diff --git a/include/linux/virtio_config.h b/include/linux/virtio_confi= g.h > > index 4d107ad31149..d51906b1389f 100644 > > --- a/include/linux/virtio_config.h > > +++ b/include/linux/virtio_config.h > > @@ -74,6 +74,15 @@ 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 > > + * Caller should guarantee that the vring is not accessed by any funct= ions > > + * of virtqueue. > > > We probably need to be more accurate here: > > 1) reset_vq will guarantee that the callbacks are disabled or synchronized > 2) except for the callback, the caller should guarantee ... OK. Thanks. > > Thanks > > > > + * @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 { > > @@ -100,6 +109,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); > > }; > > > > /* If driver didn't advertise the feature, it will never appear. */ >