From patchwork Tue Feb 7 15:17:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 123287 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 323A141C30; Tue, 7 Feb 2023 16:19:55 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B0CB942DAD; Tue, 7 Feb 2023 16:18:53 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 5DCCC42D79 for ; Tue, 7 Feb 2023 16:18:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675783126; 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=Kzn4RP6ejs9IaKYofIOBj5wLRdjAXvd5m3ypYnE8DaE=; b=FQc9Fji+tRa2yUdITLQR6CfAGsLcUvPvnp7H/MUDw1W+F0QGv3gZ9+OSCmCbigSzlIo5Qf le+UOX9ly+/seapoOLi0N1TT/hFc9/3ai/0cPvi0fmrJ3x1F8rSbFh+3abZzC2DEyw2y1y 5JPGvVM2wxl6VrW/9X7DYaHlov45cTw= 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-349-8CpMBhjKPxqKZQLEvhe8vw-1; Tue, 07 Feb 2023 10:18:44 -0500 X-MC-Unique: 8CpMBhjKPxqKZQLEvhe8vw-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 C5D1B823D62; Tue, 7 Feb 2023 15:18:13 +0000 (UTC) Received: from max-t490s.redhat.com (unknown [10.39.208.26]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4F60F140EBF4; Tue, 7 Feb 2023 15:18:12 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, chenbo.xia@intel.com, david.marchand@redhat.com, eperezma@redhat.com, stephen@networkplumber.org Cc: Maxime Coquelin , stable@dpdk.org Subject: [PATCH v2 12/21] net/virtio-user: fix device starting failure handling Date: Tue, 7 Feb 2023 16:17:38 +0100 Message-Id: <20230207151747.245808-13-maxime.coquelin@redhat.com> In-Reply-To: <20230207151747.245808-1-maxime.coquelin@redhat.com> References: <20230207151747.245808-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org If the device fails to start, read the status from the device and return early. Fixes: 57912824615f ("net/virtio-user: support vhost status setting") Cc: stable@dpdk.org Signed-off-by: Maxime Coquelin Reviewed-by: Chenbo Xia --- drivers/net/virtio/virtio_user_ethdev.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c index d32abec327..78b1ed9ace 100644 --- a/drivers/net/virtio/virtio_user_ethdev.c +++ b/drivers/net/virtio/virtio_user_ethdev.c @@ -90,10 +90,15 @@ virtio_user_set_status(struct virtio_hw *hw, uint8_t status) if (status & VIRTIO_CONFIG_STATUS_FEATURES_OK && ~old_status & VIRTIO_CONFIG_STATUS_FEATURES_OK) virtio_user_dev_set_features(dev); - if (status & VIRTIO_CONFIG_STATUS_DRIVER_OK) - virtio_user_start_device(dev); - else if (status == VIRTIO_CONFIG_STATUS_RESET) + + if (status & VIRTIO_CONFIG_STATUS_DRIVER_OK) { + if (virtio_user_start_device(dev)) { + virtio_user_dev_update_status(dev); + return; + } + } else if (status == VIRTIO_CONFIG_STATUS_RESET) { virtio_user_reset(hw); + } virtio_user_dev_set_status(dev, status); }