From patchwork Tue Oct 18 08:37:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Boeuf, Sebastien" X-Patchwork-Id: 4026 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1849221wrs; Tue, 18 Oct 2022 02:02:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM56TWQTg0WQtrxWxWJ70IDXRG8GmsXhmKuv++f5pBZ1QUm3ONijWgEqgVJc9LLq6RC+uhEt X-Received: by 2002:a17:907:a47:b0:780:6883:2a37 with SMTP id be7-20020a1709070a4700b0078068832a37mr1521962ejc.219.1666083778999; Tue, 18 Oct 2022 02:02:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666083778; cv=none; d=google.com; s=arc-20160816; b=hVbWKyFeOF/qd25NMhtnHu8zmJyAByiBiXJ/AONw056xfhlq8kOATHHt/9XLN71wKF r/UoU5sH1KsHt1UdexFF1PoDXO/4AFjMY+1nTpciXnWfINH8pqs8iyQuWvazCvw2AmIK 15hnAn2567HK7OORIRB11zvwip7yjwmox1rZMgvf92Gl9jVZkq8wypgSAZUJMvZlL9pp ZMng6lUkOgSPZYW6maugF8aEbVE4zP0z8+vj7od/ed2OD9MxgX0I3D2UHF53I1b2qEBe iVS4ZKJdo9fJo0gf10lgs8OUkqYKD4r3BiemMjgx+EUEDwhoorlmiddbIxxpYaCvIHmw pKDw== 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=CmutJhSnCo7GzUEgjGUiWPoZ4PIgkK24LIqJ3waWfKs=; b=r4yTIrAUbk3TrESfYFDHQCskI3l0fGdGWv7TTEw96DvEyKnpbO5OrtnOuZFf6yyFwN gHVip/7kjHI3ZHEpKDC5UUucKoX5TBu8LoWmEr1Bs7xAKkYzgBev9x9I5FDMKm86n9Va xekTOYFkl2+084SgKtc5Pf9YkjwxvbLU1McDCv/0zHlDEC3pisdTSWgyfJF8TqxwiCSX y9NrpTlvWZPq+WhbN69GVMC0GVlaKuQoUTKhQS0cBeoR+weBGSmGAtlqDCTqHpbUhgBA Do2Ctc5HUXQm9EHl6baFnpPGBtzp4I3BRsEa7cxMSz0Dx4nODauZM8clgrFaN5RJgfP2 iofA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=l96uS4Em; 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 r14-20020a056402018e00b0045c7c7b95easi10031257edv.73.2022.10.18.02.02.34; Tue, 18 Oct 2022 02:02:58 -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=l96uS4Em; 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 S230073AbiJRIiY (ORCPT + 99 others); Tue, 18 Oct 2022 04:38:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229874AbiJRIiQ (ORCPT ); Tue, 18 Oct 2022 04:38:16 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C25C19F740 for ; Tue, 18 Oct 2022 01:38:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666082294; x=1697618294; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=w/VJ/zZxV+j4zvTylkKvQJvW+/QH7d4xZGt7+Trkcoo=; b=l96uS4EmYUO3BLTGwChexAWk0zVXAtKM5sy2kKK3J1ondbDbPmPqQmB5 I6PqKoafoNslnU+PjJzpJnrsLr4ZGVz1J6i6KlpcotYH+AczQlgYlPhTp aOoKVBw+fOC98r/CbXZS/RSOhrBHgG0Lp0RjHIiBDiwEgXhQXm/kE0vph vGDH0B1juUIRBYG9EkUctUxBrtcSPhZXdcb1mzpoxmkAEgPFPS6AZIEPd /ePZo56ybq4+cDNwFtlPLsh1cccf/VcOf2q+VkrcHqF20NLkOb3gFa+1Q qcwpm3OnU2vQ+Mek0PLfBifh7lyFYO3DigCgrm0kedOURf+Tl7fGDSsc9 w==; X-IronPort-AV: E=McAfee;i="6500,9779,10503"; a="307125502" X-IronPort-AV: E=Sophos;i="5.95,193,1661842800"; d="scan'208";a="307125502" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2022 01:37:56 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10503"; a="753951033" X-IronPort-AV: E=Sophos;i="5.95,193,1661842800"; d="scan'208";a="753951033" Received: from aboyhan-mobl1.ger.corp.intel.com (HELO sboeuf-mobl.home) ([10.252.26.192]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2022 01:37:55 -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 v4 1/4] vdpa: Add resume operation Date: Tue, 18 Oct 2022 10:37:24 +0200 Message-Id: <17c8f9fba6c8533cce013f7613247a527d4eed42.1666082013.git.sebastien.boeuf@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-4.7 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,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747015440924137052?= X-GMAIL-MSGID: =?utf-8?q?1747015464671830550?= From: Sebastien Boeuf Add a new operation to allow a vDPA device to be resumed after it has been suspended. Trying to resume a device that wasn't suspended will result in a no-op. This operation is optional. If it's not implemented, the associated backend feature bit will not be exposed. And if the feature bit is not exposed, invoking this operation will return an error. Acked-by: Jason Wang Signed-off-by: Sebastien Boeuf --- include/linux/vdpa.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h index 6d0f5e4e82c2..96d308cbf97b 100644 --- a/include/linux/vdpa.h +++ b/include/linux/vdpa.h @@ -219,7 +219,10 @@ struct vdpa_map_file { * @reset: Reset device * @vdev: vdpa device * Returns integer: success (0) or error (< 0) - * @suspend: Suspend or resume the device (optional) + * @suspend: Suspend the device (optional) + * @vdev: vdpa device + * Returns integer: success (0) or error (< 0) + * @resume: Resume the device (optional) * @vdev: vdpa device * Returns integer: success (0) or error (< 0) * @get_config_size: Get the size of the configuration space includes @@ -324,6 +327,7 @@ struct vdpa_config_ops { void (*set_status)(struct vdpa_device *vdev, u8 status); int (*reset)(struct vdpa_device *vdev); int (*suspend)(struct vdpa_device *vdev); + int (*resume)(struct vdpa_device *vdev); size_t (*get_config_size)(struct vdpa_device *vdev); void (*get_config)(struct vdpa_device *vdev, unsigned int offset, void *buf, unsigned int len); From patchwork Tue Oct 18 08:37:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Boeuf, Sebastien" X-Patchwork-Id: 4021 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1845304wrs; Tue, 18 Oct 2022 01:48:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7TDrdm61Pav4VXc369JaH/Q6c5HpatL4eaj8T4QR6dUGhSgZPIOwJr+LF4R85FO2dq/hvN X-Received: by 2002:a17:906:d54d:b0:78e:2fbf:ca2a with SMTP id cr13-20020a170906d54d00b0078e2fbfca2amr1550629ejc.488.1666082937840; Tue, 18 Oct 2022 01:48:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666082937; cv=none; d=google.com; s=arc-20160816; b=OH0ywvMSF4gMbk4o3z7RXiSLlM/Eruz/usim+2vSVaKKOiMcYo2h+qOXktcD0U6hwl iD+Gb4VssxlzLYjXD1v9Ep6AbKsM2umJyG8FXTFhkJJj6PCQ22s5xz3RYQde95PF4zIk UfJU27Y0n+uB4KleePO1llPb99o+8JTXm5ppX92rw8k7eyzuPiKTBA0ME4URICllQdT1 N1XTMTnS9MtYjIqarIyLf/AT/roUbrp3V5N47HHiaxfy/ox40dSHNfr0chhRVDY9fdoL c7ZpEWo1twEyCX+nqth22nu8mG8E2xhKG2yCmDDRsS1NcGVLGFhG4cUwqvVSccYFs1sV oBHw== 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=QXcMFmQdkvGWNbSfz2wW92RpTmPjr1ay3/gajuLNKiM=; b=LWooyO5NxqnWH+eesuRWR1lDKead6OKD7jJK6FJiWeeio5193WJ47ANWEFnzFWt5Bt zwP70uIGBvqXIEcAGcluB6U/cCIeLr0az+Mjvg+eTiAj5gmXs5QjMAVemHAQqQglhmdq 4E1igvwznFlLnLp5Q36xQgspofZZWMf4k0xqGhbR5H9jdZ36VYW3bi0GHdgJu5Vt0ZKN JC0wfySCNTvLhpSRrsm3YCffi2T1qEshpQkcaBfRUZtKZp9EW+HKvIbWy/XXTvqJ7RXZ zZ7b7CyPT16aDsGe9Y+lmuk96xiMpu7kMpBcppqX1msfnnL46rBQ9+EsdpXumYMaAbSl SgYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=NqK807Jl; 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 nb17-20020a1709071c9100b0077979f8d3dbsi11226776ejc.838.2022.10.18.01.48.32; Tue, 18 Oct 2022 01:48:57 -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=NqK807Jl; 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 S230175AbiJRIi1 (ORCPT + 99 others); Tue, 18 Oct 2022 04:38:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230137AbiJRIiS (ORCPT ); Tue, 18 Oct 2022 04:38:18 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 059A69F758 for ; Tue, 18 Oct 2022 01:38:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666082296; x=1697618296; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3EV55upffRiHWnrQrH8wPJ3mud3btZU1zYuiKkySMH4=; b=NqK807Jl1koTGxZZ6e1xouzcUHtBoAq0IRB3USz2a8t7oP8sBOrXc0tx Xw1QrNpUXHJZIVM+xSD0BOJhwWcOUQYprRZh7+3kSBrp9vUUDHAbkQwuy CkNT0KyQO/73P9x14rf2tvpNL/4fWZmwQqf9RJD1T93/sPQX7mvmxne2d VmjSBfTEt+a6Zeg6GtT29v9tWQFBuwz6XUFyfD/xXO1i4VzNpDMORL5v9 rOYsd3nJzX3UQV+dKGGdzzB3wtX5RSSf3gR77zxJhuNgQR7t/Y9WYBdl4 DsCFmEoAe39gUODgzUnuql8uM0XbT/KgYsJuh8ylWeWtOXOH0RIMaQVeb w==; X-IronPort-AV: E=McAfee;i="6500,9779,10503"; a="307125543" X-IronPort-AV: E=Sophos;i="5.95,193,1661842800"; d="scan'208";a="307125543" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2022 01:38:04 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10503"; a="753951077" X-IronPort-AV: E=Sophos;i="5.95,193,1661842800"; d="scan'208";a="753951077" Received: from aboyhan-mobl1.ger.corp.intel.com (HELO sboeuf-mobl.home) ([10.252.26.192]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2022 01:38:02 -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 v4 2/4] vhost-vdpa: Introduce RESUME backend feature bit Date: Tue, 18 Oct 2022 10:37:25 +0200 Message-Id: <2b70c4e3c811d0f769399b0bdc0dae52853ac8c4.1666082013.git.sebastien.boeuf@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-4.7 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,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747014582332982878?= X-GMAIL-MSGID: =?utf-8?q?1747014582332982878?= From: Sebastien Boeuf Userspace knows if the device can be resumed or not by checking this feature bit. It's only exposed if the vdpa driver backend implements the resume() operation callback. Userspace trying to negotiate this feature when it hasn't been exposed will result in an error. Acked-by: Jason Wang Signed-off-by: Sebastien Boeuf --- drivers/vhost/vdpa.c | 16 +++++++++++++++- include/uapi/linux/vhost_types.h | 2 ++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index 166044642fd5..833617d00ef6 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -355,6 +355,14 @@ static bool vhost_vdpa_can_suspend(const struct vhost_vdpa *v) return ops->suspend; } +static bool vhost_vdpa_can_resume(const struct vhost_vdpa *v) +{ + struct vdpa_device *vdpa = v->vdpa; + const struct vdpa_config_ops *ops = vdpa->config; + + return ops->resume; +} + static long vhost_vdpa_get_features(struct vhost_vdpa *v, u64 __user *featurep) { struct vdpa_device *vdpa = v->vdpa; @@ -602,11 +610,15 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep, if (copy_from_user(&features, featurep, sizeof(features))) return -EFAULT; if (features & ~(VHOST_VDPA_BACKEND_FEATURES | - BIT_ULL(VHOST_BACKEND_F_SUSPEND))) + BIT_ULL(VHOST_BACKEND_F_SUSPEND) | + BIT_ULL(VHOST_BACKEND_F_RESUME))) return -EOPNOTSUPP; if ((features & BIT_ULL(VHOST_BACKEND_F_SUSPEND)) && !vhost_vdpa_can_suspend(v)) return -EOPNOTSUPP; + if ((features & BIT_ULL(VHOST_BACKEND_F_RESUME)) && + !vhost_vdpa_can_resume(v)) + return -EOPNOTSUPP; vhost_set_backend_features(&v->vdev, features); return 0; } @@ -658,6 +670,8 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep, features = VHOST_VDPA_BACKEND_FEATURES; if (vhost_vdpa_can_suspend(v)) features |= BIT_ULL(VHOST_BACKEND_F_SUSPEND); + if (vhost_vdpa_can_resume(v)) + features |= BIT_ULL(VHOST_BACKEND_F_RESUME); if (copy_to_user(featurep, &features, sizeof(features))) r = -EFAULT; break; diff --git a/include/uapi/linux/vhost_types.h b/include/uapi/linux/vhost_types.h index 53601ce2c20a..c5690a8992d8 100644 --- a/include/uapi/linux/vhost_types.h +++ b/include/uapi/linux/vhost_types.h @@ -163,5 +163,7 @@ struct vhost_vdpa_iova_range { #define VHOST_BACKEND_F_IOTLB_ASID 0x3 /* Device can be suspended */ #define VHOST_BACKEND_F_SUSPEND 0x4 +/* Device can be resumed */ +#define VHOST_BACKEND_F_RESUME 0x5 #endif From patchwork Tue Oct 18 08:37:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Boeuf, Sebastien" X-Patchwork-Id: 4024 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1849016wrs; Tue, 18 Oct 2022 02:02:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Jh1iAJ8gcieMJE7PnvxbpbbwjexJySHH2rTdkPqYcovy4L4UX0nvjCWVOO5KsT5FM+mwD X-Received: by 2002:aa7:c58a:0:b0:459:1511:6cff with SMTP id g10-20020aa7c58a000000b0045915116cffmr1688543edq.27.1666083752952; Tue, 18 Oct 2022 02:02:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666083752; cv=none; d=google.com; s=arc-20160816; b=fF+BOIZxYA2Irig9RnWH7WxOomdgIPi5YfUauPal3iZeyDXPSl0TMDCAKbCgGhVsRP 8/LefGUXiUPnldC0sZhflrPwGOICyWf16dmOd07KhfqF7iiuZZ3iFOYP9T780iBfRYVr kU9qYBIZ0E+DtCgsaZKlgyJAQsdtnLLIA33uVvylOxTV5kCMceL30no/B9zRBRPbd9+4 rip6L3B7OYRAlCWlhAhB6nrzENWrdn41l7I0tJr+3YSqnwypYWWwhxRmp8Ska3pBvwpn UnQWYwNE6prsh7o+uUNrnFl+NQbw/aWXfjJuFpSkItZMymrQ20VesGCvNaPyWIKdzaTA vnPg== 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=1InPzRD+gAzrYUOfP2l2RJaVXLWLM+f9BHUts4Ginfc=; b=AUVP2+SgMoX6uSMIW8WCe0Ab6DkC+OJVRJ/BD9SWdCjqmhWrpApXd69swB74J9eYnh aOXpWmU0zLdzw3/i+IVvw57HGR8PvsaQtyVn2MO9Wn9C6GtPAPHjqAjDgjC5yaN4Hcn2 m9dVgswWCfR7QJkGuJv34+/i6GlRsm/wJ7oUNkTsl0qEb2rj4v+cwz+ORR5CIhoE4Fl2 oJCkAQdsHLhBKkfBi+mru0rekLhrmJ/YcJAetEvHzZslvj3yOSB0gX2om6G5Sg8lV2x3 n5Lev4TSSMTpAHUy4klhCY7Hx9IDkyfEeqzk3+VSfzQakW/cPP0ldGJTeyEZgl9LN3P1 6+Gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=byZvNa7K; 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 e27-20020a50d4db000000b004594ac619b4si9867518edj.245.2022.10.18.02.02.07; Tue, 18 Oct 2022 02:02:32 -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=byZvNa7K; 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 S229978AbiJRIiN (ORCPT + 99 others); Tue, 18 Oct 2022 04:38:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229874AbiJRIiL (ORCPT ); Tue, 18 Oct 2022 04:38:11 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE4C19C7DF for ; Tue, 18 Oct 2022 01:38:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666082290; x=1697618290; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=d4xVHWCp3WQNIGyJXoYLjNrxvXCMfEsO8t0kmydFxrI=; b=byZvNa7KdJhllvF8/L55vnOYBX6/4JsCqAkxnvMqApbMYNEhPM2u9wMX lktM6JtuT0eRl1nfH7vxElgtxAuGl8DUAFHgcaeephq55k8IUk+l2InMA sFW89bsXUaUzd+7ZcV3Z9Z1sHjSPCZwf+Y3sFFmX4/8m9/+56mZjK394w xOCXRYargdS3Hdw0gS1y9w+RG7HyRJRPArMWfDrbuZZSBK3tzN4W+vddE D0LLJ7rOoUCNx9aZ9qdASCHvIsDewKyUjInzu+se5XFYbrbzoy8U9xnOh Z3bUj2ApzQydpbpKoWdDFzEIe7421LMWwwAGfWAMgUqIAfmne0FAmQ9ak g==; X-IronPort-AV: E=McAfee;i="6500,9779,10503"; a="332580434" X-IronPort-AV: E=Sophos;i="5.95,193,1661842800"; d="scan'208";a="332580434" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2022 01:38:10 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10503"; a="753951118" X-IronPort-AV: E=Sophos;i="5.95,193,1661842800"; d="scan'208";a="753951118" Received: from aboyhan-mobl1.ger.corp.intel.com (HELO sboeuf-mobl.home) ([10.252.26.192]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2022 01:38:08 -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 v4 3/4] vhost-vdpa: uAPI to resume the device Date: Tue, 18 Oct 2022 10:37:26 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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_HI,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747015437119671517?= X-GMAIL-MSGID: =?utf-8?q?1747015437119671517?= From: Sebastien Boeuf This new ioctl adds support for resuming the device from userspace. This is required when trying to restore the device in a functioning state after it's been suspended. It is already possible to reset a suspended device, but that means the device must be reconfigured and all the IOMMU/IOTLB mappings must be recreated. This new operation allows the device to be resumed without going through a full reset. This is particularly useful when trying to perform offline migration of a virtual machine (also known as snapshot/restore) as it allows the VMM to resume the virtual machine back to a running state after the snapshot is performed. Acked-by: Jason Wang Signed-off-by: Sebastien Boeuf --- drivers/vhost/vdpa.c | 18 ++++++++++++++++++ include/uapi/linux/vhost.h | 8 ++++++++ 2 files changed, 26 insertions(+) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index 833617d00ef6..1db7bd39fb63 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -502,6 +502,21 @@ static long vhost_vdpa_suspend(struct vhost_vdpa *v) return ops->suspend(vdpa); } +/* After a successful return of this ioctl the device resumes processing + * virtqueue descriptors. The device becomes fully operational the same way it + * was before it was suspended. + */ +static long vhost_vdpa_resume(struct vhost_vdpa *v) +{ + struct vdpa_device *vdpa = v->vdpa; + const struct vdpa_config_ops *ops = vdpa->config; + + if (!ops->resume) + return -EOPNOTSUPP; + + return ops->resume(vdpa); +} + static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd, void __user *argp) { @@ -687,6 +702,9 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep, case VHOST_VDPA_SUSPEND: r = vhost_vdpa_suspend(v); break; + case VHOST_VDPA_RESUME: + r = vhost_vdpa_resume(v); + break; default: r = vhost_dev_ioctl(&v->vdev, cmd, argp); if (r == -ENOIOCTLCMD) diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h index f9f115a7c75b..92e1b700b51c 100644 --- a/include/uapi/linux/vhost.h +++ b/include/uapi/linux/vhost.h @@ -180,4 +180,12 @@ */ #define VHOST_VDPA_SUSPEND _IO(VHOST_VIRTIO, 0x7D) +/* Resume a device so it can resume processing virtqueue requests + * + * After the return of this ioctl the device will have restored all the + * necessary states and it is fully operational to continue processing the + * virtqueue descriptors. + */ +#define VHOST_VDPA_RESUME _IO(VHOST_VIRTIO, 0x7E) + #endif From patchwork Tue Oct 18 08:37:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Boeuf, Sebastien" X-Patchwork-Id: 4027 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1849684wrs; Tue, 18 Oct 2022 02:04:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6WuujMUsSG3m6+jDBbUiT8LgyJWuW8Dx+5HxBFqyy2Y6P0RxPhYgz7Cs0WwJYEC/EPKqSL X-Received: by 2002:a17:907:7f05:b0:78d:e869:f2fe with SMTP id qf5-20020a1709077f0500b0078de869f2femr1477765ejc.684.1666083851207; Tue, 18 Oct 2022 02:04:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666083851; cv=none; d=google.com; s=arc-20160816; b=ayM6sPRdKLjmIabkxuZME3EWkwm8qoGdoZQ8UUmzHqiovuyCyHTjn2vkIutCOQSHn2 cWoyelSVoZY4vQFew1UZTxbogO4OpyJ2bwjGXYoR+Fnnz01h5dHoK60+r6UsrKHACr9v HAyG4nzlOYf7Uui3bQnUHHqNHWuS1B3QMiwze3IybxW2YX17K/3DOJIzCLYgVtQDJ0Ym YL+laXEsUdO+CsJC3rI3G2/ICVlmRrExw2ryNWVWmspj2/Xgjd+A8SbeIDmtvBLsS9xt mPDs2NWoNJqSMsYQbmhqle/pIt0S5ce+IzP8gHSkNVy2C13UyfUiON3p7AyFmgUFn8h4 DlTw== 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=FyhY/8syAmv1FOjt3RsBJ+gOvlbuX8cadnh6tpus/2I=; b=GcwMrxP0T0hrgnhLl9qJOMzYLtQbkbdaROv8SBOxY3HZ8VOsiJX8wwN2/tYIO9CMdx m/sxAEbXXm2ThRwqdd/aXVK49CLmZcpY1JQREPaipnyYlucDT/IigP56e0y1qi6hj8Zy u2RqwApbRYGNLR8DihQUkum09Lr/g5sDGuR7Jp6B1q1ARNO3aspJ8iaJXkRtCA3kELXs BwNuOYmuaQg2yRiFz+6G4FKU3DFFYQt2KvmoUE3xpjcIY6DGy1Bw6HvSu2bCsr1GhFz9 9EQ+RuzlTY/jkU3FmIEKEBc8ydwSEvLX1nHhccCrhWElvUi+og6+dmhgAGklRJOlkoJ5 9MoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=G2co5r0G; 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 v18-20020aa7dbd2000000b00447d6f244c6si9796555edt.248.2022.10.18.02.03.46; Tue, 18 Oct 2022 02:04:11 -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=G2co5r0G; 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 S230185AbiJRIic (ORCPT + 99 others); Tue, 18 Oct 2022 04:38:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230163AbiJRIiV (ORCPT ); Tue, 18 Oct 2022 04:38:21 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C91769F773 for ; Tue, 18 Oct 2022 01:38:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666082296; x=1697618296; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PL0A8+uYcphH0sIJRwXwGnLqTPe3EEcbUoVnkmTTq0Q=; b=G2co5r0GCuLEe7+tygjD5t455Tjk+9n4WGRgvg0HGN3s6R7eXNB6Ic8f LE5Keykfo8lHhuuwi49RMlKzgrYavRuIB2LX3XFNsAJQjK4hPza9sCAGZ 398qzHQ2nCb+PoKt2o6T1nywo6ndDScV9xdO+rxmzIUlJ379Sgct5G09X Fz22WBnQAYxs9dDaSOxeJ9712flzGnKdSMXoqOB6dpTd803hY4oWVT04G pYnfD4fdxeNNY48HOALmbLFKm4Att1mzcia0VOMeta5sxrupWE4W3RZjc XRYVpDOP2YgbhL9/xBDEPoq6rFHZgmHpmD1jL7WtLp8sM1pHf8Ye0ZelU A==; X-IronPort-AV: E=McAfee;i="6500,9779,10503"; a="368069143" X-IronPort-AV: E=Sophos;i="5.95,193,1661842800"; d="scan'208";a="368069143" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2022 01:38:15 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10503"; a="753951155" X-IronPort-AV: E=Sophos;i="5.95,193,1661842800"; d="scan'208";a="753951155" Received: from aboyhan-mobl1.ger.corp.intel.com (HELO sboeuf-mobl.home) ([10.252.26.192]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2022 01:38:13 -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 v4 4/4] vdpa_sim: Implement resume vdpa op Date: Tue, 18 Oct 2022 10:37:27 +0200 Message-Id: <56c045ac70e44e7d80f3f9e901deae3d7485b2a1.1666082013.git.sebastien.boeuf@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-4.7 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747015540163004197?= X-GMAIL-MSGID: =?utf-8?q?1747015540163004197?= 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 --- drivers/vdpa/vdpa_sim/vdpa_sim.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c index b071f0d842fb..05e3802fb746 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c @@ -527,6 +527,18 @@ 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; + 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 +729,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 +763,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,