From patchwork Wed Nov 16 15:05:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 13045368 Return-Path: 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 9544EC4332F for ; Wed, 16 Nov 2022 15:07:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233620AbiKPPHg (ORCPT ); Wed, 16 Nov 2022 10:07:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233818AbiKPPH3 (ORCPT ); Wed, 16 Nov 2022 10:07:29 -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 74DE82982A for ; Wed, 16 Nov 2022 07:06:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668611194; 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=0+au/UM9VIHTmPOqBDQ2vQGnj810Su87nJuzkIxq8kA=; b=HDxlgE+Q1c3t6ps+7270esQNMiPmS8OaldKlNL8s0pUTvogXfP/QH0f4QU739z5+HwpynH cCZyMFQqgTbF1QmmFJGLbixp+fgOko/HGO3mvrpjn6s6tRuOI/M5vmxO/Bu+VAzIq1ds35 Gm5Brdmo3PQPTUrVI/eliFzXp6+DjYk= 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-389-9Gm-IvmuNJy1Q4ZfMHUb3w-1; Wed, 16 Nov 2022 10:06:24 -0500 X-MC-Unique: 9Gm-IvmuNJy1Q4ZfMHUb3w-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A5827803D49; Wed, 16 Nov 2022 15:06:23 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.144]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9E5C8140EBF3; Wed, 16 Nov 2022 15:06:20 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Cornelia Huck , Gautam Dawar , Eli Cohen , Stefano Garzarella , Harpreet Singh Anand , Paolo Bonzini , Stefan Hajnoczi , Cindy Lu , Liuxiangdong , "Gonglei (Arei)" , Jason Wang , Parav Pandit , Si-Wei Liu , Zhu Lingshan , Laurent Vivier , "Michael S. Tsirkin" , kvm@vger.kernel.org Subject: [PATCH for 8.0 v7 05/10] vdpa: move SVQ vring features check to net/ Date: Wed, 16 Nov 2022 16:05:51 +0100 Message-Id: <20221116150556.1294049-6-eperezma@redhat.com> In-Reply-To: <20221116150556.1294049-1-eperezma@redhat.com> References: <20221116150556.1294049-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org The next patches will start control SVQ if possible. However, we don't know if that will be possible at qemu boot anymore. Since the moved checks will be already evaluated at net/ to know if it is ok to shadow CVQ, move them. Signed-off-by: Eugenio PĂ©rez Acked-by: Jason Wang --- hw/virtio/vhost-vdpa.c | 33 ++------------------------------- net/vhost-vdpa.c | 3 ++- 2 files changed, 4 insertions(+), 32 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 3df2775760..146f0dcb40 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -402,29 +402,9 @@ static int vhost_vdpa_get_dev_features(struct vhost_dev *dev, return ret; } -static int vhost_vdpa_init_svq(struct vhost_dev *hdev, struct vhost_vdpa *v, - Error **errp) +static void vhost_vdpa_init_svq(struct vhost_dev *hdev, struct vhost_vdpa *v) { g_autoptr(GPtrArray) shadow_vqs = NULL; - uint64_t dev_features, svq_features; - int r; - bool ok; - - if (!v->shadow_vqs_enabled) { - return 0; - } - - r = vhost_vdpa_get_dev_features(hdev, &dev_features); - if (r != 0) { - error_setg_errno(errp, -r, "Can't get vdpa device features"); - return r; - } - - svq_features = dev_features; - ok = vhost_svq_valid_features(svq_features, errp); - if (unlikely(!ok)) { - return -1; - } shadow_vqs = g_ptr_array_new_full(hdev->nvqs, vhost_svq_free); for (unsigned n = 0; n < hdev->nvqs; ++n) { @@ -436,7 +416,6 @@ static int vhost_vdpa_init_svq(struct vhost_dev *hdev, struct vhost_vdpa *v, } v->shadow_vqs = g_steal_pointer(&shadow_vqs); - return 0; } static int vhost_vdpa_init(struct vhost_dev *dev, void *opaque, Error **errp) @@ -461,11 +440,7 @@ static int vhost_vdpa_init(struct vhost_dev *dev, void *opaque, Error **errp) dev->opaque = opaque ; v->listener = vhost_vdpa_memory_listener; v->msg_type = VHOST_IOTLB_MSG_V2; - ret = vhost_vdpa_init_svq(dev, v, errp); - if (ret) { - goto err; - } - + vhost_vdpa_init_svq(dev, v); vhost_vdpa_get_iova_range(v); if (!vhost_vdpa_first_dev(dev)) { @@ -476,10 +451,6 @@ static int vhost_vdpa_init(struct vhost_dev *dev, void *opaque, Error **errp) VIRTIO_CONFIG_S_DRIVER); return 0; - -err: - ram_block_discard_disable(false); - return ret; } static void vhost_vdpa_host_notifier_uninit(struct vhost_dev *dev, diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index e98d5f5eac..dd9cea42d0 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -117,9 +117,10 @@ static bool vhost_vdpa_net_valid_svq_features(uint64_t features, Error **errp) if (invalid_dev_features) { error_setg(errp, "vdpa svq does not work with features 0x%" PRIx64, invalid_dev_features); + return false; } - return !invalid_dev_features; + return vhost_svq_valid_features(features, errp); } static int vhost_vdpa_net_check_device_id(struct vhost_net *net)