Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp3297369lfo; Mon, 23 May 2022 01:01:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJysUl+FlHUCg9guvlhVoTNcYMTkAnQsJkO/Zi1lo6fIElraY7u7HykBTYuaImIlIojAQcOD X-Received: by 2002:a05:6a00:851:b0:518:50a9:32f5 with SMTP id q17-20020a056a00085100b0051850a932f5mr17466290pfk.47.1653292886306; Mon, 23 May 2022 01:01:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653292886; cv=none; d=google.com; s=arc-20160816; b=j2cU3iz1GCR9f8fwDLc8+UId3/EBA1nborLkBoRw3OBO99fKfTjZslEEw1GV/cvWB1 E/3ArzT7p7rkWB6byKlc8ZYxeLehfS0PhfkWHQWwKebQvRSjuluUfbL8OYWU1GQeo2Fg kaShCGZeSgWa2r5DqOOIycA9CDaOldRkWLMOx4cxmbwSnUgoJ2AYVW/84+JAYd5c+w0G pbvj8WX8/T80cn8akkui6/Kbr95HvTjZnXwsr3RkSl/00+/0e4AH4QK/W/w5Z9yDLYDw l2HHSlyPgJiAkMvlhqwH3qzT8ngtrYCVuaEEZOU6wWpf8mhtGQpqTrdSBDagDgfQr2t1 gmjQ== 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=kov56r1jsuiTzaYs0eaT4ViAnRJYvmg/k+QVFy5P/+0=; b=fKaThI2Uc/eS2TGyNdWsMVNbGYXGZjQ5rKBJFkB0LhY2YJg17RQNc324T4yo4SwT3i Np0O91XiihpiR6IDVGPCAbclnp/lNuKL8NpRN4ce/J+xVCP1RTgZnc+ZrqIFxfe/FYMh MxIkDMAkiAZiW4cuFoLuaa2U8HkwOHykq4iBJ3tPJbvOokz2SLM74Niu/N+dskODzaj1 uOTU2ap7+QiUYiSTExq9vYO8+WYyg9hs+PqeUhVwhIqi2JcD+shkcmRwtfdjeBvjesmP dDCh8OmTXMTQ4tNcViOKo2t7fRjAA58vTwj6ryfb3WH4ubPQ4GhKCVNUrAwuxp8noEp4 RnMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Uow3c0Oj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id m2-20020a170902768200b0015d281d00a5si9033066pll.599.2022.05.23.01.01.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 01:01:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Uow3c0Oj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1CDB92550B7; Mon, 23 May 2022 00:01:20 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352227AbiETRYg (ORCPT + 99 others); Fri, 20 May 2022 13:24:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352251AbiETRYI (ORCPT ); Fri, 20 May 2022 13:24:08 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 77E7E18AA95 for ; Fri, 20 May 2022 10:23:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653067435; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kov56r1jsuiTzaYs0eaT4ViAnRJYvmg/k+QVFy5P/+0=; b=Uow3c0OjELahIknlNkrHROQ7l5cxdLy7UlMbc02O0bKZUB891UYuIaWNQjwcxRBe3O+zzF cXlupxuqlhyn0UrHhP19hDHm4EKwt0D6fPbgOnyKl9YK8kq5eep3LFs172aiHXoWrozZ7u gBd3u/obebCq/3wjhkGbXeZiNuaaY58= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-673-nwlB4FZBM6KK2GEL8ZhIIQ-1; Fri, 20 May 2022 13:23:49 -0400 X-MC-Unique: nwlB4FZBM6KK2GEL8ZhIIQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8842285A5AA; Fri, 20 May 2022 17:23:47 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.124]) by smtp.corp.redhat.com (Postfix) with ESMTP id C8458492C14; Fri, 20 May 2022 17:23:42 +0000 (UTC) From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: virtualization@lists.linux-foundation.org, Jason Wang , kvm@vger.kernel.org, "Michael S. Tsirkin" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Stefano Garzarella , Longpeng , Zhu Lingshan , martinh@xilinx.com, hanand@xilinx.com, Si-Wei Liu , dinang@xilinx.com, Eli Cohen , lvivier@redhat.com, pabloc@xilinx.com, gautam.dawar@amd.com, Xie Yongji , habetsm.xilinx@gmail.com, Christophe JAILLET , tanuj.kamde@amd.com, eperezma@redhat.com, Wu Zongyong , martinpo@xilinx.com, lulu@redhat.com, ecree.xilinx@gmail.com, Parav Pandit , Dan Carpenter , Zhang Min Subject: [PATCH 3/4] vhost-vdpa: uAPI to stop the device Date: Fri, 20 May 2022 19:23:24 +0200 Message-Id: <20220520172325.980884-4-eperezma@redhat.com> In-Reply-To: <20220520172325.980884-1-eperezma@redhat.com> References: <20220520172325.980884-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 The ioctl adds support for stop the device from userspace. Signed-off-by: Eugenio PĂ©rez --- drivers/vhost/vdpa.c | 18 ++++++++++++++++++ include/uapi/linux/vhost.h | 3 +++ 2 files changed, 21 insertions(+) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index a325bc259afb..da4a8c709bc1 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -478,6 +478,21 @@ static long vhost_vdpa_get_vqs_count(struct vhost_vdpa *v, u32 __user *argp) return 0; } +static long vhost_vdpa_stop(struct vhost_vdpa *v, u32 __user *argp) +{ + struct vdpa_device *vdpa = v->vdpa; + const struct vdpa_config_ops *ops = vdpa->config; + int stop; + + if (!ops->stop) + return -EOPNOTSUPP; + + if (copy_to_user(argp, &stop, sizeof(stop))) + return -EFAULT; + + return ops->stop(vdpa, stop); +} + static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd, void __user *argp) { @@ -649,6 +664,9 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep, case VHOST_VDPA_GET_VQS_COUNT: r = vhost_vdpa_get_vqs_count(v, argp); break; + case VHOST_STOP: + r = vhost_vdpa_stop(v, argp); + 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 cab645d4a645..e7526968ab0c 100644 --- a/include/uapi/linux/vhost.h +++ b/include/uapi/linux/vhost.h @@ -171,4 +171,7 @@ #define VHOST_VDPA_SET_GROUP_ASID _IOW(VHOST_VIRTIO, 0x7C, \ struct vhost_vring_state) +/* Stop or resume a device so it does not process virtqueue requests anymore */ +#define VHOST_STOP _IOW(VHOST_VIRTIO, 0x7D, int) + #endif -- 2.27.0