Message ID | d8c405c150c6eb25acab58718c38e0ef4c3c0293.1666796792.git.sebastien.boeuf@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp329103wru; Wed, 26 Oct 2022 08:19:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Y+sWGD0u0veRMCrm/T1ZbQv3533EeS6YbPKh5U63SHMuWGTgYb3wCISK49IA+2sxKco6I X-Received: by 2002:a17:907:78a:b0:78d:9ac7:b697 with SMTP id xd10-20020a170907078a00b0078d9ac7b697mr37618105ejb.457.1666797580857; Wed, 26 Oct 2022 08:19:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666797580; cv=none; d=google.com; s=arc-20160816; b=epCSa3qs3umrwgTg6u8SXCnunTf56E9QCRrG09L0kcQotou70siylqWVXnfw7+U0aN /DTk0ncdsbkXpjeu7OUEt7dDFZLQ5HVmbKUpKnl3quueBCmPNfN6o3ogM5cNj24CpYlW 37Ficc/3th7Ixtlrsq/dCmgffAnluUY2Dl45bW5tO+P/ESGW9pjzkCoe/bJsD2T07l+Y qCbHpVJmrOSjsUVXrYp0WrOG9c7dWQ8OAT8hNwYqJCIqcyJ6eM+5bN53r3EaYFEu9SIw AyeznW/tE27313KJ1nd2WJCCIH0T+ixEmM3yC3f7b4XlHygMHhzy03K2d30RrJrpJnk9 NBdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=DRAyu2nedGUpRmjgEhLho0Isyrm6euj16kwLoUe3GIE=; b=sybnlr2EQwnbkom6BbrnKo8sMaXvvF/EMjq90VImc8ctXNryqOxhYjGc9EIn6RvJBy 5rQ1KoPtxoWYpI0s4vUPJL0f/QeZiuzdkFmM4Wrr2caS4DmUDjN71cGD//D3b/y2iTFF LDW1PcMRGjOulLrEzHlWd3SRWTrDWHHY2jWolGGfv5RVa1dQMwUCqDeiZ146CDaRwMvW XWtb3szxJwo/B0I2l6yjJJReqAeXxnSpA/gEeORM+T/vP/MukhVaXysp2J3D4W6MiaPt xQ21OAyQ4K81CFo0zdowmG+qF7s71huIaY11IteA8ITNAO2mOQH1jvA2/mQirBjBMCj6 0pjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QmeLlV4M; 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=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e17-20020a056402191100b0046159da6233si7660129edz.145.2022.10.26.08.19.16; Wed, 26 Oct 2022 08:19:40 -0700 (PDT) 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=@intel.com header.s=Intel header.b=QmeLlV4M; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233689AbiJZPJr (ORCPT <rfc822;pwkd43@gmail.com> + 99 others); Wed, 26 Oct 2022 11:09:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234484AbiJZPJ1 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 26 Oct 2022 11:09:27 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F6B2200 for <linux-kernel@vger.kernel.org>; Wed, 26 Oct 2022 08:09:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666796964; x=1698332964; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xRbBHi5E+N2qU/Z+c5NfZHEpwCKk1QOB5B18pjThjKE=; b=QmeLlV4MhkNOzGy6Uj26VA187RwSJHPE0qEAZHjWlwpkDFgeFTph0DCJ JV9YB6QEyKzLdNY814xoavjc4li/j+TlnhuVk5WJboG46PmU64dpWCXHo c9g8SHKrUCIUiCza6ueBpraA9KqNjcpOhRY0idhtjNCZTu4CAQXPKyLqX zbS52c9EaOGojFW5u8uvpkkd9HxLBM/kOsfjaFOW0L6EeHsuL7ri6D7uo 6A200kvsSIGkSvivYsraqEA5NkJx9UmHwljxVD2RNyvrWxd5GNpbj+DWE YSQcXqwrsayMLVSiKRnwDgnjH29bRLJOt6RinO9Zga+ouBlXQPkT7d4Ql g==; X-IronPort-AV: E=McAfee;i="6500,9779,10512"; a="372178709" X-IronPort-AV: E=Sophos;i="5.95,215,1661842800"; d="scan'208";a="372178709" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2022 08:09:03 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10512"; a="961252466" X-IronPort-AV: E=Sophos;i="5.95,215,1661842800"; d="scan'208";a="961252466" Received: from briansim-mobl.ger.corp.intel.com (HELO sboeuf-mobl.home) ([10.252.29.107]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2022 08:09:01 -0700 From: sebastien.boeuf@intel.com To: linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org Cc: mst@redhat.com, jasowang@redhat.com, eperezma@redhat.com, sebastien.boeuf@intel.com Subject: [PATCH v5 4/4] vdpa_sim: Implement resume vdpa op Date: Wed, 26 Oct 2022 17:08:38 +0200 Message-Id: <d8c405c150c6eb25acab58718c38e0ef4c3c0293.1666796792.git.sebastien.boeuf@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <cover.1666796792.git.sebastien.boeuf@intel.com> References: <cover.1666796792.git.sebastien.boeuf@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.9 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_MED,SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747763940098527682?= X-GMAIL-MSGID: =?utf-8?q?1747763940098527682?= |
Series |
vdpa: Add resume operation
|
|
Commit Message
Boeuf, Sebastien
Oct. 26, 2022, 3:08 p.m. UTC
From: Sebastien Boeuf <sebastien.boeuf@intel.com> 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 <sebastien.boeuf@intel.com> --- drivers/vdpa/vdpa_sim/vdpa_sim.c | 28 ++++++++++++++++++++++++++++ drivers/vdpa/vdpa_sim/vdpa_sim.h | 1 + 2 files changed, 29 insertions(+)
Comments
On Wed, Oct 26, 2022 at 11:09 PM <sebastien.boeuf@intel.com> wrote: > > From: Sebastien Boeuf <sebastien.boeuf@intel.com> > > 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 <sebastien.boeuf@intel.com> > --- > drivers/vdpa/vdpa_sim/vdpa_sim.c | 28 ++++++++++++++++++++++++++++ > drivers/vdpa/vdpa_sim/vdpa_sim.h | 1 + > 2 files changed, 29 insertions(+) > > diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c > index b071f0d842fb..84fee8bb2929 100644 > --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c > +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c > @@ -357,6 +357,11 @@ 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->pending_kick = true; > + return; I think we may hit here when the driver kicks vq before DRIVER_OK. Do we need to check device status in this case and resume? Thanks > + } > + > if (vq->ready) > schedule_work(&vdpasim->work); > } > @@ -527,6 +532,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 +743,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 +777,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.34.1 > > --------------------------------------------------------------------- > 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. >
On Mon, Nov 07, 2022 at 03:43:54PM +0800, Jason Wang wrote: > On Wed, Oct 26, 2022 at 11:09 PM <sebastien.boeuf@intel.com> wrote: > > > > From: Sebastien Boeuf <sebastien.boeuf@intel.com> > > > > 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 <sebastien.boeuf@intel.com> > > --- > > drivers/vdpa/vdpa_sim/vdpa_sim.c | 28 ++++++++++++++++++++++++++++ > > drivers/vdpa/vdpa_sim/vdpa_sim.h | 1 + > > 2 files changed, 29 insertions(+) > > > > diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c > > index b071f0d842fb..84fee8bb2929 100644 > > --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c > > +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c > > @@ -357,6 +357,11 @@ 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->pending_kick = true; > > + return; > > I think we may hit here when the driver kicks vq before DRIVER_OK. Do > we need to check device status in this case and resume? > > Thanks Sebastien did you forget to reply here? > > + } > > + > > if (vq->ready) > > schedule_work(&vdpasim->work); > > } > > @@ -527,6 +532,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 +743,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 +777,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.34.1 > > > > --------------------------------------------------------------------- > > 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. > >
On Mon, 2022-12-19 at 01:23 -0500, Michael S. Tsirkin wrote: > On Mon, Nov 07, 2022 at 03:43:54PM +0800, Jason Wang wrote: > > On Wed, Oct 26, 2022 at 11:09 PM <sebastien.boeuf@intel.com> wrote: > > > > > > From: Sebastien Boeuf <sebastien.boeuf@intel.com> > > > > > > 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 <sebastien.boeuf@intel.com> > > > --- > > > drivers/vdpa/vdpa_sim/vdpa_sim.c | 28 > > > ++++++++++++++++++++++++++++ > > > drivers/vdpa/vdpa_sim/vdpa_sim.h | 1 + > > > 2 files changed, 29 insertions(+) > > > > > > diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c > > > b/drivers/vdpa/vdpa_sim/vdpa_sim.c > > > index b071f0d842fb..84fee8bb2929 100644 > > > --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c > > > +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c > > > @@ -357,6 +357,11 @@ 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->pending_kick = true; > > > + return; > > > > I think we may hit here when the driver kicks vq before DRIVER_OK. > > Do > > we need to check device status in this case and resume? > > > > Thanks > > Sebastien did you forget to reply here? Ah yes sorry I got carried away with other things and forgot about this. And then I was on vacation. I'll look at it this week. Thanks, Sebastien > > > > + } > > > + > > > if (vq->ready) > > > schedule_work(&vdpasim->work); > > > } > > > @@ -527,6 +532,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 +743,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 +777,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.34.1 > > > > > > ----------------------------------------------------------------- > > > ---- > > > 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. > > > > --------------------------------------------------------------------- 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.
On Tue, Jan 3, 2023 at 12:52 AM Boeuf, Sebastien <sebastien.boeuf@intel.com> wrote: > > Hi Jason, > > Are you suggesting we do something like the following: > > if ((!vdpasim->running) && (vdpasim->status == DRIVER_OK)) { > vdpasim->pending_kick = true; > return; > } > > ? Yes. Thanks > > Thanks, > Sebastien > ________________________________ > From: Jason Wang <jasowang@redhat.com> > Sent: Monday, November 7, 2022 8:43 AM > To: Boeuf, Sebastien <sebastien.boeuf@intel.com> > Cc: linux-kernel@vger.kernel.org <linux-kernel@vger.kernel.org>; virtualization@lists.linux-foundation.org <virtualization@lists.linux-foundation.org>; mst@redhat.com <mst@redhat.com>; eperezma@redhat.com <eperezma@redhat.com> > Subject: Re: [PATCH v5 4/4] vdpa_sim: Implement resume vdpa op > > On Wed, Oct 26, 2022 at 11:09 PM <sebastien.boeuf@intel.com> wrote: > > > > From: Sebastien Boeuf <sebastien.boeuf@intel.com> > > > > 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 <sebastien.boeuf@intel.com> > > --- > > drivers/vdpa/vdpa_sim/vdpa_sim.c | 28 ++++++++++++++++++++++++++++ > > drivers/vdpa/vdpa_sim/vdpa_sim.h | 1 + > > 2 files changed, 29 insertions(+) > > > > diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c > > index b071f0d842fb..84fee8bb2929 100644 > > --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c > > +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c > > @@ -357,6 +357,11 @@ 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->pending_kick = true; > > + return; > > I think we may hit here when the driver kicks vq before DRIVER_OK. Do > we need to check device status in this case and resume? > > Thanks > > > + } > > + > > if (vq->ready) > > schedule_work(&vdpasim->work); > > } > > @@ -527,6 +532,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 +743,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 +777,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.34.1 > > > > --------------------------------------------------------------------- > > 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. > > > > --------------------------------------------------------------------- > 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.
diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c index b071f0d842fb..84fee8bb2929 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c @@ -357,6 +357,11 @@ 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->pending_kick = true; + return; + } + if (vq->ready) schedule_work(&vdpasim->work); } @@ -527,6 +532,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 +743,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 +777,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; };