From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 673B8A04B0; Sun, 18 Oct 2020 09:31:19 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F0C79C9F6; Sun, 18 Oct 2020 09:31:16 +0200 (CEST) Received: from nat-hk.nvidia.com (nat-hk.nvidia.com [203.18.50.4]) by dpdk.org (Postfix) with ESMTP id BC53FC9F0; Sun, 18 Oct 2020 09:31:13 +0200 (CEST) Received: from HKMAIL104.nvidia.com (Not Verified[10.18.92.77]) by nat-hk.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Sun, 18 Oct 2020 15:31:11 +0800 Received: from HKMAIL104.nvidia.com (10.18.16.13) by HKMAIL104.nvidia.com (10.18.16.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Sun, 18 Oct 2020 07:31:08 +0000 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.43) by HKMAIL104.nvidia.com (10.18.16.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Sun, 18 Oct 2020 07:31:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Dcszj1Jpbtyl7iCM15l1vf0Y9YkKjFSsjvxn63pgQCPNolwApYFC+pyshivHdTS9AQrFws538r4BLGeVI/EUcIHJOkGOIC4rMA6+i+WJDPQcbLFpMJUP2YFU1RrUNPk470CO+/Zj/gNYwdLPQdbi2hvJBLdGkIqB0pNXdtIWparTkFcKL+J1gFG+eCXWOH+7gA4Sky0O9uV6UqGYXxHogF4lji/Rr1KKtauGug6k1082a7trfbU0r2UjmQLH/x5cmtGMpiw2DpR6b1UyhNgVHHSHkgYUwqWfr/8TjyHfQ33wZT7n9z5+x4Y5JbKl+WAUVqIso//EZZRlA8G9JCi6NQ== 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:X-MS-Exchange-SenderADCheck; bh=Xqb1l+hJ6HBJCoDcHipFDxh1mpom0KapWBRFR0RF/fc=; b=EribhsmnWNFSte1G5k1re1dKcdA+zxOZSdqmVNchnV7L81DFLYgL0lJQaIij7M1bSOC1V9JRQBYRPwWQm37Qvi8g2D/QQuWhpauL88Xfkb8qZ9WFI7BKv5oB57D/hgopPaxKusEam9GHGg7IPBruXfVivzhRmZeuG/3rb0ZsXmDjFX1uOQ/Nt86UIH/E/OZhyWWaBBTwARKFMvu0QH1vjOlv6o9cHBsPjVCAF3iVWkweYlzclxAZBzsoMIn3WSPzoOkvGsPrwDyfwv9nA6v0YciIRMvJo2ZTEryiIhIGTid+3pbMAV2wr9785ROZa3leVxfxXJnIv3HtotwKb8FYdQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none Received: from MW2PR12MB2492.namprd12.prod.outlook.com (2603:10b6:907:8::19) by MWHPR1201MB0080.namprd12.prod.outlook.com (2603:10b6:301:54::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.21; Sun, 18 Oct 2020 07:31:06 +0000 Received: from MW2PR12MB2492.namprd12.prod.outlook.com ([fe80::39f3:2b4b:6018:4b88]) by MW2PR12MB2492.namprd12.prod.outlook.com ([fe80::39f3:2b4b:6018:4b88%7]) with mapi id 15.20.3477.025; Sun, 18 Oct 2020 07:31:06 +0000 From: Matan Azrad To: Long Li , Matan Azrad CC: "dev@dpdk.org" , NBU-Contact-longli , "stable@dpdk.org" Thread-Topic: [PATCH] net/vdev_netvsc: Prevent alarm lost on failed device probe Thread-Index: AQHWoyoZruYPot+JAk2tlPdecNOsa6mc+TdA Date: Sun, 18 Oct 2020 07:31:05 +0000 Message-ID: References: <1602790385-13032-1-git-send-email-longli@linuxonhyperv.com> In-Reply-To: <1602790385-13032-1-git-send-email-longli@linuxonhyperv.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: linuxonhyperv.com; dkim=none (message not signed) header.d=none;linuxonhyperv.com; dmarc=none action=none header.from=nvidia.com; x-originating-ip: [77.124.103.215] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 5610938e-9926-4416-76c4-08d87337c65f x-ms-traffictypediagnostic: MWHPR1201MB0080: x-ld-processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr x-microsoft-antispam-prvs: x-ms-exchange-transport-forked: True x-ms-oob-tlc-oobclassifiers: OLM:248; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: H6ObPfXnA5o4Y1GdNTdmwCGpGcLtyezMuFM0XZHkd37BOQsJ88ZI0F/DcAumWGi2+y1oUT32MZhiwlFM0rQQ4g4xU5VH5S6ULqx0qUJPiPr3ZVk4O4daZelvHxfW8rJi93uVXCpXfMy1QO9ZuEOs3HHR/a1ugLAUEFFh8ON70L4YWlSKz4CDDkXdm/iAiig7+akuJ0M+AuYHBMw6N6qLqnZXIuVfsPjH7kGMhbGrm/xdRrNM09M6HX49TLsf3HsprQgmZEEfkxYk77BloP9vcEIWtX/Umhy0ErNHfrOM78vrFj9OAEpzYpl9fUSGNXtlkBy8vx8tlNueWVEqESm/lg== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MW2PR12MB2492.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(39850400004)(376002)(346002)(366004)(136003)(86362001)(52536014)(66476007)(76116006)(8936002)(33656002)(186003)(66946007)(64756008)(66556008)(26005)(55016002)(66446008)(5660300002)(6506007)(316002)(478600001)(2906002)(71200400001)(54906003)(4326008)(110136005)(8676002)(7696005)(9686003)(83380400001); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: SBx+EOZw1N6TRbeaxmZ4442mQiR0WRLw7BtHHj+i9Us8xPkmMOD7RyPbLCrRORzdCBVAtnOZQBKOOsGTMp0cYUfIKr1azQZdAGPDnpsb/TG7UrBYRCQoNkwmp6gU26uGBNBhH3UpX/PrLgFbkR4e1+VC5u6siNrjejUFL0rGUBgMf3efCGsBz/OoW2K9cFRdiTFHIfpLjHsAxgxLUz8Vre57Rc0BbLO+7I+vCc3lD/5UqT8a+E5ZhyUeyZIPOrkbvdgQD1IYXv+HPV/5ani5uLXKMfhCH6h7DNfD0b76ip7Nvos+IsP1+HMdWpJZAwiDydyRZotfhYrugtz78ZYLi2nHvLt+HMdbejx3FoGoTU/nI1JYxqOXTFMuWbdDRLR/58ji6gEiMleTSmmu8ip/8mMQus5eWwce2t+9ljdHgwfCgQ3EqLfXzx1g0sjjzaTK34zEE2Ctxzvtovbt5xYTvyMPcL3R8TBPkVPQv2YPehGm0zAnaTvaTdNpEnYIqGhd3InZwBo2bR5ZnfH3kf/oT6Y/2OriVarLMagI6j8BNKpHEWepQpO4dAGjjE8BicNkBGNk+LOJSCTsM+pv3k4YmXv5p8AgadL+iP2GafVbsjKUgxkD9Bcz1V1lTme0pFCYjngMXgiwYp4G7d8aAx7BLA== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW2PR12MB2492.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5610938e-9926-4416-76c4-08d87337c65f X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Oct 2020 07:31:06.0076 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 4cPnvwHLxsvq6+yBdcgxLOzhe/PxrKY8xAiE0Bk3DeXzpJ3/I7C8+wNm/s5486ROnrT8kY9pPCyTyUYRv4faZw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1201MB0080 X-OriginatorOrg: Nvidia.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1603006271; bh=Xqb1l+hJ6HBJCoDcHipFDxh1mpom0KapWBRFR0RF/fc=; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To: CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References: In-Reply-To:Accept-Language:Content-Language:X-MS-Has-Attach: X-MS-TNEF-Correlator:authentication-results:x-originating-ip: x-ms-publictraffictype:x-ms-office365-filtering-correlation-id: x-ms-traffictypediagnostic:x-ld-processed: x-microsoft-antispam-prvs:x-ms-exchange-transport-forked: x-ms-oob-tlc-oobclassifiers:x-ms-exchange-senderadcheck: x-microsoft-antispam:x-microsoft-antispam-message-info: x-forefront-antispam-report:x-ms-exchange-antispam-messagedata: Content-Type:Content-Transfer-Encoding:MIME-Version: X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-AuthSource: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-originalarrivaltime: X-MS-Exchange-CrossTenant-fromentityheader: X-MS-Exchange-CrossTenant-id:X-MS-Exchange-CrossTenant-mailboxtype: X-MS-Exchange-CrossTenant-userprincipalname: X-MS-Exchange-Transport-CrossTenantHeadersStamped:X-OriginatorOrg; b=HiscwdCKYXT+kKSYptQAEsRL9LkNZo2CtsLozxuj3K0JAZKgYJbjLz4q0XIMKtbff vRcJUJNUcQMC64nAJ2gYEvBXckMIbZxnymmFm+ANTpgaxGWV3bHeydNhLepalSZIEu 2I7wzN+BAFtpL/BYOrWZvbsIkZFpaTdk85rz6KoMJbkuC9rWiTxO/x4M8TlJTm+rjb jz27Y2m+VPbwrfiKUjKvHeem3xft90SuVES0q6ECVX+wsPNOlesQqDM0YgIWwbhZ1N aGEBb7OWvygewTzKuYs2cG7unypqwMvucJhGHN4oWWEBoZ7TzHo84iSaP/SzuUTQj0 +mTyIegRSY5gg== Subject: Re: [dpdk-dev] [PATCH] net/vdev_netvsc: Prevent alarm lost on failed device probe X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" From: Long Li > If a device probe fails, the alarm is canceled and will no longer work fo= r > previously probed devices. >=20 > Fix this by introducing a flag to track if alarm has been set. Because it= 's > possible that an alarm is triggered while probing is in progress that may > modify vdev_netvsc_ctx_list, introduce a lock to protect it. >=20 > Cc: stable@dpdk.org > Signed-off-by: Long Li > --- > drivers/net/vdev_netvsc/vdev_netvsc.c | 41 > +++++++++++++++++++++++++---------- > 1 file changed, 30 insertions(+), 11 deletions(-) >=20 > diff --git a/drivers/net/vdev_netvsc/vdev_netvsc.c > b/drivers/net/vdev_netvsc/vdev_netvsc.c > index be8f19c..bd7e308 100644 > --- a/drivers/net/vdev_netvsc/vdev_netvsc.c > +++ b/drivers/net/vdev_netvsc/vdev_netvsc.c > @@ -76,6 +76,11 @@ struct vdev_netvsc_ctx { > /** Context list is common to all driver instances. */ static LIST_HEAD= (, > vdev_netvsc_ctx) vdev_netvsc_ctx_list =3D > LIST_HEAD_INITIALIZER(vdev_netvsc_ctx_list); > +/* Lock to protect concurrent accesses to vdev_netvsc_ctx_list */ > +static rte_rwlock_t vdev_netvsc_ctx_list_lock; > + > +/* Flag to track if alarm has been set */ static int > +vdev_netvsc_alarm_set; >=20 > /** Number of entries in context list. */ static unsigned int > vdev_netvsc_ctx_count; @@ -454,19 +459,26 @@ static LIST_HEAD(, > vdev_netvsc_ctx) vdev_netvsc_ctx_list =3D > struct vdev_netvsc_ctx *ctx; > int ret; >=20 > + rte_rwlock_write_lock(&vdev_netvsc_ctx_list_lock); > LIST_FOREACH(ctx, &vdev_netvsc_ctx_list, entry) { > ret =3D vdev_netvsc_foreach_iface(vdev_netvsc_device_prob= e, 0, > ctx); > if (ret < 0) > break; > } > - if (!vdev_netvsc_ctx_count) > + rte_rwlock_write_unlock(&vdev_netvsc_ctx_list_lock); > + > + if (!vdev_netvsc_ctx_count) { > + vdev_netvsc_alarm_set =3D 0; > return; > + } > + > ret =3D rte_eal_alarm_set(VDEV_NETVSC_PROBE_MS * 1000, > vdev_netvsc_alarm, NULL); > if (ret < 0) { > DRV_LOG(ERR, "unable to reschedule alarm callback: %s", > rte_strerror(-ret)); > + vdev_netvsc_alarm_set =3D 0; > } > } >=20 > @@ -698,34 +710,41 @@ static LIST_HEAD(, vdev_netvsc_ctx) > vdev_netvsc_ctx_list =3D > " device."); > goto error; > } > - rte_eal_alarm_cancel(vdev_netvsc_alarm, NULL); > + > + rte_rwlock_write_lock(&vdev_netvsc_ctx_list_lock); > /* Gather interfaces. */ > ret =3D vdev_netvsc_foreach_iface(vdev_netvsc_netvsc_probe, 1, na= me, > kvargs, specified, &matched); > if (ret < 0) > - goto error; > + goto error_unlock; > if (specified && matched < specified) { > if (!force) { > DRV_LOG(ERR, "Cannot find the specified netvsc de= vice"); > - goto error; > + goto error_unlock; > } > /* Try to force probing on non-netvsc specified device. *= / > if (vdev_netvsc_foreach_iface(vdev_netvsc_netvsc_probe, 0= , name, > kvargs, specified, &matched= ) < 0) > - goto error; > + goto error_unlock; > if (matched < specified) { > DRV_LOG(ERR, "Cannot find the specified device"); > - goto error; > + goto error_unlock; > } > DRV_LOG(WARNING, "non-netvsc device was probed as netvsc"= ); > } > - ret =3D rte_eal_alarm_set(VDEV_NETVSC_PROBE_MS * 1000, > + if (!vdev_netvsc_alarm_set) { > + ret =3D rte_eal_alarm_set(VDEV_NETVSC_PROBE_MS * 1000, > vdev_netvsc_alarm, NULL); > - if (ret < 0) { > - DRV_LOG(ERR, "unable to schedule alarm callback: %s", > - rte_strerror(-ret)); > - goto error; > + if (ret < 0) > + DRV_LOG(ERR, "unable to schedule alarm callback: = %s", > + rte_strerror(-ret)); > + else > + vdev_netvsc_alarm_set =3D 1; > } > + > +error_unlock: > + rte_rwlock_write_unlock(&vdev_netvsc_ctx_list_lock); > + > error: > if (kvargs) > rte_kvargs_free(kvargs); > -- Hi Nice direction. As I understand from your patch it looks like you want to add support for t= he vdev_netvsc driver itself to be hot-plug aware - so it can be probed\rem= oved in run-time (even after EAL initialization). So I think the title and commit log should be converted to this: net/vdev_n= etvsc: support driver instance hot-plug ... More things: Look on convention of the file - blank line only after variables declaratio= ns inside the blocks. Need to adjust also vdev_netvsc_vdev_remove to the feature.=20 Matan