Message ID | 20220624025621.128843-24-xuanzhuo@linux.alibaba.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show
Return-Path: <linux-remoteproc-owner@kernel.org> 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 5C3D6CCA47C for <linux-remoteproc@archiver.kernel.org>; Fri, 24 Jun 2022 02:58:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231766AbiFXC6H (ORCPT <rfc822;linux-remoteproc@archiver.kernel.org>); Thu, 23 Jun 2022 22:58:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231598AbiFXC5a (ORCPT <rfc822;linux-remoteproc@vger.kernel.org>); Thu, 23 Jun 2022 22:57:30 -0400 Received: from out30-54.freemail.mail.aliyun.com (out30-54.freemail.mail.aliyun.com [115.124.30.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FFD762C16; Thu, 23 Jun 2022 19:57:20 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046051;MF=xuanzhuo@linux.alibaba.com;NM=1;PH=DS;RN=37;SR=0;TI=SMTPD_---0VHEuW2C_1656039433; Received: from localhost(mailfrom:xuanzhuo@linux.alibaba.com fp:SMTPD_---0VHEuW2C_1656039433) by smtp.aliyun-inc.com; Fri, 24 Jun 2022 10:57:14 +0800 From: Xuan Zhuo <xuanzhuo@linux.alibaba.com> To: virtualization@lists.linux-foundation.org Cc: Richard Weinberger <richard@nod.at>, Anton Ivanov <anton.ivanov@cambridgegreys.com>, Johannes Berg <johannes@sipsolutions.net>, "Michael S. Tsirkin" <mst@redhat.com>, Jason Wang <jasowang@redhat.com>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Hans de Goede <hdegoede@redhat.com>, Mark Gross <markgross@kernel.org>, Vadim Pasternak <vadimp@nvidia.com>, Bjorn Andersson <bjorn.andersson@linaro.org>, Mathieu Poirier <mathieu.poirier@linaro.org>, Cornelia Huck <cohuck@redhat.com>, Halil Pasic <pasic@linux.ibm.com>, Eric Farman <farman@linux.ibm.com>, Heiko Carstens <hca@linux.ibm.com>, Vasily Gorbik <gor@linux.ibm.com>, Alexander Gordeev <agordeev@linux.ibm.com>, Christian Borntraeger <borntraeger@linux.ibm.com>, Sven Schnelle <svens@linux.ibm.com>, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Jesper Dangaard Brouer <hawk@kernel.org>, John Fastabend <john.fastabend@gmail.com>, Xuan Zhuo <xuanzhuo@linux.alibaba.com>, Vincent Whitchurch <vincent.whitchurch@axis.com>, 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 Subject: [PATCH v10 23/41] virtio_ring: packed: introduce virtqueue_resize_packed() Date: Fri, 24 Jun 2022 10:56:03 +0800 Message-Id: <20220624025621.128843-24-xuanzhuo@linux.alibaba.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20220624025621.128843-1-xuanzhuo@linux.alibaba.com> References: <20220624025621.128843-1-xuanzhuo@linux.alibaba.com> MIME-Version: 1.0 X-Git-Hash: fef800c86cd2 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-remoteproc.vger.kernel.org> X-Mailing-List: linux-remoteproc@vger.kernel.org |
Series |
virtio pci support VIRTIO_F_RING_RESET
|
expand
|
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 740b17550df5..d3b2139200fa 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -2016,6 +2016,35 @@ static struct virtqueue *vring_create_virtqueue_packed( return NULL; } +static int virtqueue_resize_packed(struct virtqueue *_vq, u32 num) +{ + struct vring_virtqueue_packed vring = {}; + struct vring_virtqueue *vq = to_vvq(_vq); + struct virtio_device *vdev = _vq->vdev; + int err; + + if (vring_alloc_queue_packed(&vring, vdev, num)) + goto err_ring; + + err = vring_alloc_state_extra_packed(&vring); + if (err) + goto err_state_extra; + + vring_free(&vq->vq); + + virtqueue_init(vq, vring.vring.num); + virtqueue_vring_attach_packed(vq, &vring); + virtqueue_vring_init_packed(vq); + + return 0; + +err_state_extra: + vring_free_packed(&vring, vdev); +err_ring: + virtqueue_reinit_packed(vq); + return -ENOMEM; +} + /* * Generic functions and exported symbols.
virtio ring packed supports resize. Only after the new vring is successfully allocated based on the new num, we will release the old vring. In any case, an error is returned, indicating that the vring still points to the old vring. In the case of an error, re-initialize(by virtqueue_reinit_packed()) the virtqueue to ensure that the vring can be used. Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com> --- drivers/virtio/virtio_ring.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)