Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp280493rwb; Thu, 12 Jan 2023 19:58:09 -0800 (PST) X-Google-Smtp-Source: AMrXdXtwcl1Ez1H7nn06ESr4uUvemzOKvGPTembQxS0qZ0Colwrhmjtd+F+vBPx3QeEmKiJMSHIE X-Received: by 2002:a17:907:c307:b0:7e2:c573:d2e9 with SMTP id tl7-20020a170907c30700b007e2c573d2e9mr1978804ejc.48.1673582289012; Thu, 12 Jan 2023 19:58:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673582288; cv=none; d=google.com; s=arc-20160816; b=QaXATRajOP1RgSbnwQCYlIGDtNJq29cFmJLK9++SZvfgfT5TiVHYy7Ufl/QGk+ue7e oGhwdIMmpUf1+4podTto2x2jRJQhxFw00qzwExYL5CVfg/i+hdeCbrlFaxCb83fLaPkt AXD+2UPu7h182urTG09W3mjMM51Uly3ja7u3rorJcfyEbB1RMSIdLWweXCxoaewapEZe 1w9Vr26lheUWYdNGUawx9csf6M881YrTgwnnyNnke6AEsczLs0q4Jntcb07XWFHPhexc P5nRF65AwwiSrkt3g03jDD3WU+wPP0sYS13NEtk+su6hLFiX4tZPtPQpmGfCMecPRie9 jrVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=iQ8wi4Br7uO3KhWWeSVPWRGqxXRNQdNc7vx+DzPAcvk=; b=i7mDg+2FO24iOkxQUUXB5HoTBCf98u4OTCELwsN+Q9C8wggLMvw4WlXjTY6KdqBsS9 Nd5dlxlcp7tWrZ4FPA6BpgVmrakYx9a2KwhynUbbtQa6zRa+dZv3479L/9qdTjH0Wcgs ge+dzjopDZ2dzd2BiP2vJpodtWLMvA6qw8bbHbAKcxjC587RMyPZ2Kj4FbiIP2XhlOf3 dUsLYWBN5jOP3ABcUYnY9Qtseo8fXJrJfmG+QHOlnzUzLi5mQ4CY+0pja0cR3DiW3u0y 6fkMRe4FsEB0NXOSx4uk5z1M9DDtSJXdZGlVmYLA0tJ1yC54F1ZwROgvXjjNYmSkC/II OkHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cLsloOEd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hp18-20020a1709073e1200b0084cf763ac0esi20814864ejc.158.2023.01.12.19.57.55; Thu, 12 Jan 2023 19:58:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cLsloOEd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232594AbjAMDmA (ORCPT + 52 others); Thu, 12 Jan 2023 22:42:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230172AbjAMDl5 (ORCPT ); Thu, 12 Jan 2023 22:41:57 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F36157926 for ; Thu, 12 Jan 2023 19:41:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673581267; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=iQ8wi4Br7uO3KhWWeSVPWRGqxXRNQdNc7vx+DzPAcvk=; b=cLsloOEdpLHULXtk/dBWM9SktYBhgByrxa/0/bNXSNbQJb3yIMgv9uBXAU5qCIB13B7jEf LG4mAAA30ERVqAIFlXvrmq/Q5LX4UNOd2Cu850BVM5xSfegrmZNDIkvRetC1MxXAxpbXlX GvVv2kr25o9o0NXmRvUD+QNvWv+/VUI= Received: from mail-ot1-f69.google.com (mail-ot1-f69.google.com [209.85.210.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-93-DaX944MFOMGbNOujqZE3BQ-1; Thu, 12 Jan 2023 22:41:06 -0500 X-MC-Unique: DaX944MFOMGbNOujqZE3BQ-1 Received: by mail-ot1-f69.google.com with SMTP id e15-20020a0568301e4f00b006783b3a27c3so9942006otj.0 for ; Thu, 12 Jan 2023 19:41:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=iQ8wi4Br7uO3KhWWeSVPWRGqxXRNQdNc7vx+DzPAcvk=; b=Qd6W7cGfrEF6Qux86x5Z9W2N8SvuSnO02IEmrMzjTGtYRtyzZ7a1sgh0Pglz3RwNwt vyj1xSs2R69+pqLrAPru8HK352xerObF5WI/TqDdnsH1gZseLstvqEifbRzMYoYzSpi8 boh6asjp2987hYTvgZTZoiiaE5E2YEcGiA/lUZ9XHm0dWslsizwuS6LxOi4eLsdXoODK XUiuQJEphkwn+Al3iGeJQi9GJpIe5QPx/2DSI23i8iy1aiTlgcR8HbJGzCBherfE2+j2 BedYVO6iOxJaV4+ieq94pCFHN2wU8ito3Z1unJEBbj9VGHf0Se1TW6QSW10Ut+/1Mvfw AcYQ== X-Gm-Message-State: AFqh2kqOTZroFHejuH3OUbor+4r1w0qklX/1sIZgFDF97GeQX+RE5IDw 7KC3eVI5Zyhpc5I0YDtyYhZynef8LM5SUOFOTB/SA53MGtv6nmj27TJGVVmQEPtwdnvYUqVlMNa 37ASinw24tfBlhI6eeUgkEzi2G53elQf6j4kWkBYc X-Received: by 2002:a05:6870:4413:b0:144:a97b:1ae2 with SMTP id u19-20020a056870441300b00144a97b1ae2mr4410757oah.35.1673581265454; Thu, 12 Jan 2023 19:41:05 -0800 (PST) X-Received: by 2002:a05:6870:4413:b0:144:a97b:1ae2 with SMTP id u19-20020a056870441300b00144a97b1ae2mr4410753oah.35.1673581265229; Thu, 12 Jan 2023 19:41:05 -0800 (PST) MIME-Version: 1.0 References: <15a4566826033c5dd9a2167e5cfb0ef4d90cea49.1672742878.git.sebastien.boeuf@intel.com> In-Reply-To: <15a4566826033c5dd9a2167e5cfb0ef4d90cea49.1672742878.git.sebastien.boeuf@intel.com> From: Jason Wang Date: Fri, 13 Jan 2023 11:40:54 +0800 Message-ID: Subject: Re: [PATCH v6 4/4] vdpa_sim: Implement resume vdpa op To: sebastien.boeuf@intel.com Cc: linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, mst@redhat.com, eperezma@redhat.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,LOTS_OF_MONEY, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 3, 2023 at 6:51 PM wrote: > > From: Sebastien Boeuf > > Implement resume operation for vdpa_sim devices, so vhost-vdpa will > offer that backend feature and userspace can effectively resume the > device. > > Signed-off-by: Sebastien Boeuf Acked-by: Jason Wang Thanks > --- > drivers/vdpa/vdpa_sim/vdpa_sim.c | 29 +++++++++++++++++++++++++++++ > drivers/vdpa/vdpa_sim/vdpa_sim.h | 1 + > 2 files changed, 30 insertions(+) > > diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c > index b071f0d842fb..756a5db0109c 100644 > --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c > +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c > @@ -357,6 +357,12 @@ static void vdpasim_kick_vq(struct vdpa_device *vdpa, u16 idx) > struct vdpasim *vdpasim = vdpa_to_sim(vdpa); > struct vdpasim_virtqueue *vq = &vdpasim->vqs[idx]; > > + if (!vdpasim->running && > + (vdpasim->status & VIRTIO_CONFIG_S_DRIVER_OK)) { > + vdpasim->pending_kick = true; > + return; > + } > + > if (vq->ready) > schedule_work(&vdpasim->work); > } > @@ -527,6 +533,27 @@ static int vdpasim_suspend(struct vdpa_device *vdpa) > return 0; > } > > +static int vdpasim_resume(struct vdpa_device *vdpa) > +{ > + struct vdpasim *vdpasim = vdpa_to_sim(vdpa); > + int i; > + > + spin_lock(&vdpasim->lock); > + vdpasim->running = true; > + > + if (vdpasim->pending_kick) { > + /* Process pending descriptors */ > + for (i = 0; i < vdpasim->dev_attr.nvqs; ++i) > + vdpasim_kick_vq(vdpa, i); > + > + vdpasim->pending_kick = false; > + } > + > + spin_unlock(&vdpasim->lock); > + > + return 0; > +} > + > static size_t vdpasim_get_config_size(struct vdpa_device *vdpa) > { > struct vdpasim *vdpasim = vdpa_to_sim(vdpa); > @@ -717,6 +744,7 @@ static const struct vdpa_config_ops vdpasim_config_ops = { > .set_status = vdpasim_set_status, > .reset = vdpasim_reset, > .suspend = vdpasim_suspend, > + .resume = vdpasim_resume, > .get_config_size = vdpasim_get_config_size, > .get_config = vdpasim_get_config, > .set_config = vdpasim_set_config, > @@ -750,6 +778,7 @@ static const struct vdpa_config_ops vdpasim_batch_config_ops = { > .set_status = vdpasim_set_status, > .reset = vdpasim_reset, > .suspend = vdpasim_suspend, > + .resume = vdpasim_resume, > .get_config_size = vdpasim_get_config_size, > .get_config = vdpasim_get_config, > .set_config = vdpasim_set_config, > diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.h b/drivers/vdpa/vdpa_sim/vdpa_sim.h > index 0e78737dcc16..a745605589e2 100644 > --- a/drivers/vdpa/vdpa_sim/vdpa_sim.h > +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.h > @@ -67,6 +67,7 @@ struct vdpasim { > u64 features; > u32 groups; > bool running; > + bool pending_kick; > /* spinlock to synchronize iommu table */ > spinlock_t iommu_lock; > }; > -- > 2.37.2 > > --------------------------------------------------------------------- > Intel Corporation SAS (French simplified joint stock company) > Registered headquarters: "Les Montalets"- 2, rue de Paris, > 92196 Meudon Cedex, France > Registration Number: 302 456 199 R.C.S. NANTERRE > Capital: 5 208 026.16 Euros > > This e-mail and any attachments may contain confidential material for > the sole use of the intended recipient(s). Any review or distribution > by others is strictly prohibited. If you are not the intended > recipient, please contact the sender and delete all copies. >