From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 75ABBA0C41; Wed, 15 Sep 2021 11:21:53 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5DF194003F; Wed, 15 Sep 2021 11:21:53 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2089.outbound.protection.outlook.com [40.107.236.89]) by mails.dpdk.org (Postfix) with ESMTP id EA9474003C for ; Wed, 15 Sep 2021 11:21:51 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oKJXNQ/wGrrPqHSJmn5aMycmDkPXqa1Iu/0i61Kfk0h/4/Fq+PwhpSxoXkXcsvVO8C27dgqZIIk7+sEL55pj5mODJhIN3RKvYxhEclttVO3PrB3ZkEK7rzMz5GeQfpn4jKvkU6pUO1shf7lQ7kSDNWpQYHMUAvcVb7zseCRmHlN/7KXUaF6KAQzCg2i7WRIRbXkuMVb40vXr/1C9ad4J5BFONX/DMxiPQW9KNsA8pI0HyJ3UEfGvo9ypdGWACtajmR3xBK1aMVFmBLm/9pd52LCEvziLicvlWf3Ko64HBPcjrgPQrWitd5HWulmLU4nWyObFAkk9M4cxABYkXVFoHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=VMnWLgrCQFPSNHjVLB46Q+lKm+O0dP+xlhG+Hq4Ozwk=; b=WuYHC8IkUK9b014dwth01ZjE6hCoTiMLNfrNC2NvWJWcOPD4GDvf4f6aaY9qa0pO7t/AJPgaUzVTS5cuIX5oSGIbRlpYd4MOSP021d+/03Mi+9+aQJhSklo/JyCFcyhMeF/fqF4Y9BhKPFE0cG0N4ognpX2b56Zp3ySVDotwiwLOIC3xMzzGvWP5i4Otef2tubG9NSozHSot/jNqfNprB/Pplg0HPs7DQ/Iq0XVFjWHBLnFdXShYjRepvLQJacXN5eSxmwcXifgLuX2r89Wo+Q2BZsDHm5HkypDF9ZnT7kaw4R4oZvHjLsLuxLFmDO5ZZXItnaeGJ/almhqXyejNEQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.36) smtp.rcpttodomain=oktetlabs.ru smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VMnWLgrCQFPSNHjVLB46Q+lKm+O0dP+xlhG+Hq4Ozwk=; b=pRmLGp2MvRRAzUSpNR2Hyk/j2gS1INfoVLoJpCSCBcx3Dx/RZ03ApDqlhq1tDkFLoo1fZDbiJhz1VQiGVlKqHG5CvyT6pPBA0DlGsYXHK183y4Xp5NURai4W0Hl9pxJLNGsGq5SFDZsuTcOe7jG5D975ycKS2a3sD9I7R0aHRC9kC4EfDJ/5gTbdVKWFCj+VGXDuqZP8d2W3UOdHA1C5iuOUgmeWinlybutMWNfwLgpSLLSeyrGVV4oDEQOQ/1Cg937jOwRaLpHjYBztWTucmnvf1qhngzb2h7dkGKPqVc56Ah6HO/lPFaJXTQdHgLdHzjZfdK7AF7gqJp4a6DF77g== Received: from MWHPR15CA0033.namprd15.prod.outlook.com (2603:10b6:300:ad::19) by MWHPR1201MB0096.namprd12.prod.outlook.com (2603:10b6:301:55::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Wed, 15 Sep 2021 09:21:50 +0000 Received: from CO1NAM11FT011.eop-nam11.prod.protection.outlook.com (2603:10b6:300:ad:cafe::4b) by MWHPR15CA0033.outlook.office365.com (2603:10b6:300:ad::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Wed, 15 Sep 2021 09:21:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.36) smtp.mailfrom=nvidia.com; oktetlabs.ru; dkim=none (message not signed) header.d=none;oktetlabs.ru; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.36 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.36; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.36) by CO1NAM11FT011.mail.protection.outlook.com (10.13.175.186) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4523.14 via Frontend Transport; Wed, 15 Sep 2021 09:21:49 +0000 Received: from DRHQMAIL107.nvidia.com (10.27.9.16) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 15 Sep 2021 09:21:48 +0000 Received: from nvidia.com (172.20.187.5) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 15 Sep 2021 09:21:46 +0000 From: Xueming Li To: CC: , Andrew Rybchenko , Maxime Coquelin , Chenbo Xia Date: Wed, 15 Sep 2021 17:21:13 +0800 Message-ID: <20210915092113.79205-1-xuemingl@nvidia.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210823063906.1382544-1-xuemingl@nvidia.com> References: <20210823063906.1382544-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To DRHQMAIL107.nvidia.com (10.27.9.16) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 440e271c-6add-40f8-8dd3-08d9782a3f1a X-MS-TrafficTypeDiagnostic: MWHPR1201MB0096: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RLhEVPKu5mVO8BZ/1TAUGDpzSxQwvNr4Bozg00b83a1rOWlUPyv/1cTq67IFfRmW5mQTA81bKuPFVSbbGhVtPuPDvxV0yPbMb6Xm58V9HyZrLHYbITBNjsN8uYRtD//rLsab2mnzW4+k/YZKEcKwjIkQGOG1BQKhiPlVFUdKPs6Wh4jfulDQAIHe4/lmKCnazF/GDnxGEjzJhX0boCJN1SfjUrMH/9PZwjdJ5csDPlZrM9DyZwypSpUYRzZquT+CvA56PBoje8qP6SrWIcMI4WQRLQbKi18NdoYgI73ZgtFyC6dHbDkcO8zqsc1SqaR/beszaf1H30z9SMHd/Xr34SKHiv9+UYfL5UOyonZCZR9bPlEghOvyLOwHahzOV9Zxrm4ISWhMZhU3smN6lxYbi69fLr/tMDeDBqgvHjl+l/Tjzqjd6StWd6HNqlrr4ixB0A/wX8N+sR+6inwqqLkyfeCA/dRQB2bn5GbHHzL2IFfyPbiraCYgPCU0hEIaTwlK1r4kuMF2RQ8hwnrZ/C0p9q0m/8N6fjGmJOCT6SPXCwcnM/cEy9Dm2hNlJ0iyJ5ZAPqKTr4sV5hVr6z1izgPTKL4JgVZatVP0IXeNPywSJS1T2xpVbd2YT4Qfqo1WAr6ZYGrsBjBHCRycr+n9K7FMj2UYRTCyl0W3Ss5n5vS2yihVExYbNKoeOrl/KXJyKdb6dCINZ9/C8d7N6VdTKz9klQ== X-Forefront-Antispam-Report: CIP:216.228.112.36; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid05.nvidia.com; CAT:NONE; SFS:(4636009)(46966006)(36840700001)(86362001)(6286002)(7696005)(1076003)(186003)(82310400003)(16526019)(6916009)(2906002)(26005)(54906003)(55016002)(508600001)(6666004)(336012)(2616005)(47076005)(83380400001)(36906005)(426003)(316002)(4326008)(36756003)(36860700001)(7636003)(70206006)(5660300002)(356005)(70586007)(8936002)(8676002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2021 09:21:49.1280 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 440e271c-6add-40f8-8dd3-08d9782a3f1a X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.36]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT011.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1201MB0096 Subject: [dpdk-dev] [PATCH v1] net/virtio: wait device ready during reset 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 Sender: "dev" According to virtio spec, the device MUST reset when 0 is written to device_status, and present 0 in device_status once reset is done. This patch waits status value to be 0 during reset operation, if timeout in 3 seconds, log and continue. Signed-off-by: Xueming Li Cc: Andrew Rybchenko --- drivers/net/virtio/virtio.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/net/virtio/virtio.c b/drivers/net/virtio/virtio.c index 7e1e77797f..f865b27b65 100644 --- a/drivers/net/virtio/virtio.c +++ b/drivers/net/virtio/virtio.c @@ -3,7 +3,10 @@ * Copyright(c) 2020 Red Hat, Inc. */ +#include + #include "virtio.h" +#include "virtio_logs.h" uint64_t virtio_negotiate_features(struct virtio_hw *hw, uint64_t host_features) @@ -38,9 +41,17 @@ virtio_write_dev_config(struct virtio_hw *hw, size_t offset, void virtio_reset(struct virtio_hw *hw) { + uint32_t retry = 0; + VIRTIO_OPS(hw)->set_status(hw, VIRTIO_CONFIG_STATUS_RESET); - /* flush status write */ - VIRTIO_OPS(hw)->get_status(hw); + /* Flush status write and wait device ready max 3 seconds. */ + while (VIRTIO_OPS(hw)->get_status(hw) != VIRTIO_CONFIG_STATUS_RESET) { + if (retry++ > 3000) { + PMD_INIT_LOG(WARNING, "device reset timeout"); + break; + } + usleep(1000L); + } } void -- 2.33.0