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 7061443719; Thu, 21 Dec 2023 02:44:12 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9529D4067E; Thu, 21 Dec 2023 02:44:11 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id 8C835402C4; Thu, 21 Dec 2023 02:44:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1703123049; x=1734659049; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=4PvAb3VwUhOX2bohofH7j5u/+L4ZJcDqpROJF4S83PQ=; b=Y1EhIf/SC2I7Cp7XPW8+lySY6IHX3DQrf+H3LKJ+d9AlAGYAle2rjWSs S/rfk+GFLDTpq07CtSalQUIvlwtKETrIyqQ2ob/uygSB/d8ZqCmprhwDY 8qsWYb+SH/oZTj866zRag1mOd52oUxNHHhnT9LLbaVwbJTOwDNms03tgM gFFFpFsX5E4qgKcofivvLd9OeAHfz82qrp4JiFU7IC7LmgagwtuNYnRWo y6ZUmLxkvoHlbx1+0cBku/n72PqPBqxFghB1K05qoYHseZcfi/n6kuvt1 XuMr/KQ2K0RMpkgQCzwne7H2kdx5yh13ckTuyU2KQyrQRryZbL+2UkeBZ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10930"; a="386328586" X-IronPort-AV: E=Sophos;i="6.04,292,1695711600"; d="scan'208";a="386328586" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Dec 2023 17:44:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,292,1695711600"; d="scan'208";a="18507929" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by fmviesa001.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 20 Dec 2023 17:44:06 -0800 Received: from fmsmsx602.amr.corp.intel.com (10.18.126.82) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 20 Dec 2023 17:44:05 -0800 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Wed, 20 Dec 2023 17:44:05 -0800 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.169) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Wed, 20 Dec 2023 17:44:05 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jFVaMI5NOuKK+eySrBb9vcsu6al5gWkFDHjhJsQ67M6ONs2UiiDYDF7qP0tNw8mPAqWkfxU+HVlCcr9WbA0BRVFiWAgBF6ai5vLwBx+O+FpJlsM+A5tPXnJl8uYbec70qPZCpS0HVx/azWaTXmMAucvT4dfpg+ElnyiiokIY4/Ih5yoZD3f72ReMqhbQ0NZVxKimeZtY6x9d4O/vuwQZgxPVEYi/28uXQfXeW8DFpM2ojNJbz+90x0Y9aEhzMYUChZ1b3eE31rsxQBq8RsFVU7+SoL0MLXVpTMtBP6xck5TrvJXhGIQ7Sbnd8xNB6FP2rc0mWoQLmIkoWI9JeVwbGA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=MRhAO/FchbAZb8aSoVs/ps/qAbkP0a+NAUcRv2vcB6U=; b=S3ZUSaLmTFpPc3vE7xKCC7GT5h+4LfvSgmID7AkjiqnKxu9o1U67fCgus2oBXZ1KK6G9fot4J5k6/dv7RLyUuMHgQQNVxtdO/oS1eGyV9QGru1VHTNRPhxsFiF6wXCm9lOMTmhZija62dJimFHCgE0twdsrsI3G/6JFL4Aab1UQOwCwnrzrKuX7uey8+V58wQzak7uLgAKnRQpsgMqHCRgfvUPMDDyrguBlP0i0r4RbUsBbc//7ir6e2LhEaOEV7faa7gkDCbMLFLC5nfAwA3UtysCjSy6iYzXA8Q4Fox5UG6yzPepRh9cQXO5qJLiLoP0sMhjoiik0iJFMQYNMz1A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from CH0PR11MB8086.namprd11.prod.outlook.com (2603:10b6:610:190::8) by CYYPR11MB8387.namprd11.prod.outlook.com (2603:10b6:930:c8::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.18; Thu, 21 Dec 2023 01:44:03 +0000 Received: from CH0PR11MB8086.namprd11.prod.outlook.com ([fe80::a021:43b2:a5c5:ed34]) by CH0PR11MB8086.namprd11.prod.outlook.com ([fe80::a021:43b2:a5c5:ed34%3]) with mapi id 15.20.7113.016; Thu, 21 Dec 2023 01:43:59 +0000 From: "Yang, Qiming" To: "Zhang, Qi Z" CC: "dev@dpdk.org" , "stable@dpdk.org" Subject: RE: [PATCH v2] net/ice: fix link update Thread-Topic: [PATCH v2] net/ice: fix link update Thread-Index: AQHaLiNaunxwYR21pky7WsKWDb7Gi7CzAemw Date: Thu, 21 Dec 2023 01:43:59 +0000 Message-ID: References: <20231214084054.2593194-1-qi.z.zhang@intel.com> In-Reply-To: <20231214084054.2593194-1-qi.z.zhang@intel.com> Accept-Language: en-US, zh-CN Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: CH0PR11MB8086:EE_|CYYPR11MB8387:EE_ x-ms-office365-filtering-correlation-id: ffd47419-11b1-41fc-630f-08dc01c64d7c x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: OcVCTRWqWSawk9kSgeMWYQCrZFq/CbExwt/jrNa08C0Dnpj7HCSmuCstzkxiKLFFk2/+inTSmIKCymSNmnHVxvynuDy8q7v5A+NKJK01c3hcqDkJNhmNrzsjTwgcO/BNOhPLglQKJa1Pz8K1nvPJuThQfJgxxCBkauRmazXDhD4rdxT5p+j/WEyN7p1rGvjyzAi0njHMD3O8ZHYPlIMjL7nGySofV6P58ca1KCsPdPRSBI+ly94iwBbvh973AYjNrXHGmQqCyOTUjhbQSkEiDsgzHwLJ1qVEzOIh+LqhWGXUVZ30GgIiQkxjDA9BUOS4tTUZtSz2Nyt+Jpi4GK8Z1P1/kcPtRn2NNPMRx7cTMjBJz1qEI+xutp1FJikJhlEVI00BYuCB46UZRR9Fp6iKmCvTwmRMBrQPwxRUkBuMMk4lM5CIqrAvpA1KvSGeiImbQafWn+26WUQjJgUc++Sex62MTIMDbenSW2zvpclw3JgPb4UhoIrAhWv3fGQqqFNPEY5ouMHKZvcfaR2BDhJS1VesvJHsZ8QzT+FlHFGH+JBKKb6sQ5+qaKme2DC453UQAoN6siaQBv6rDsbVS0FpFrCTAIZwXQtHItLXVo9sASkPIOnxcaJXUIxqNnTjotsWH+ybkw3OZOrW/Du1VjukFmxD+Vji+anuQj91rWAqpFI= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH0PR11MB8086.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(136003)(346002)(366004)(376002)(396003)(39860400002)(230922051799003)(230273577357003)(230173577357003)(1800799012)(451199024)(64100799003)(186009)(52536014)(450100002)(6862004)(8676002)(8936002)(4326008)(82960400001)(15650500001)(38100700002)(122000001)(41300700001)(86362001)(33656002)(2906002)(38070700009)(5660300002)(26005)(53546011)(71200400001)(9686003)(66446008)(55016003)(478600001)(7696005)(6506007)(66556008)(54906003)(76116006)(66476007)(83380400001)(64756008)(66946007)(316002)(6636002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?6FKvo6X16UCcfbLl07uQFLqDV7QP+hThdS7zqD0SwCWZjdkq602067FaDc5R?= =?us-ascii?Q?UMZWhEJjYwaeMbtFEPL1i1lpDeQKXhxfF5yrB1/9uHhqd7RaDXCViGes6JbO?= =?us-ascii?Q?QCvjsYIUGG953zeXqx2Tto6bklz8rVSBCQN0u+4oiclfv0uMZaqTA0CsKkix?= =?us-ascii?Q?WHAerh3FIvb1J7BBYekSdAT9k9PsWvQejaLp3CaD/vepnfPVx5vsbO9u72/R?= =?us-ascii?Q?SdEDZJLCj747fZtNK6qFS7g6hexmMENp9DGO77zb9J4HtxtPzrRGKA/BS9aB?= =?us-ascii?Q?fdUDqZxfzQovnNFjxFTH2jbQSSF8h0BDjZKwAAnbhS8mREPhD7LRCAcdiUV6?= =?us-ascii?Q?SPV5pDi33R3JSu2+V+4ldsJe1wdxdmzNK6/DDXNCrytQg1YBY0yqwCemcGDD?= =?us-ascii?Q?nYYPVPQb/RBOVVwlqOu99s4q37gJasTUa2hhvX872uWpZAmknQleMByHHsG+?= =?us-ascii?Q?gJ34eScnYOoYWKD6j4CEjtVJJQhtmH7antnOc3oynD2qDjpm5Gt9TsYbjAZr?= =?us-ascii?Q?gLpF2PrMI+r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G0MF7NSsdmUGVs?= =?us-ascii?Q?USMZ8ZihxrVE2bL0W3sIobElVU7zyODkzFtU3nahhadFdnXPAYIhG6yEnXj+?= =?us-ascii?Q?loDyH2QWYISKKXukMa2xA7Io/Kde3HOts1porw1hSXQXbazsN/mfcOsBtYRk?= =?us-ascii?Q?Kvx2NMe48QAaTDzUGwFhxDo5FVC9RfwMGqIxoviC?= 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: CH0PR11MB8086.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ffd47419-11b1-41fc-630f-08dc01c64d7c X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Dec 2023 01:43:59.4449 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 9nAmUaLfUU03qIBqDEU4wK7wIFkNlo3vgSTHItJNgZg8cMKV4upd9YLoKYYej6hax8xgddc6L9moHQ3k9sTxuA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR11MB8387 X-OriginatorOrg: intel.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 hi > -----Original Message----- > From: Zhang, Qi Z > Sent: Thursday, December 14, 2023 4:41 PM > To: Yang, Qiming > Cc: dev@dpdk.org; Zhang, Qi Z ; stable@dpdk.org > Subject: [PATCH v2] net/ice: fix link update >=20 > The ice_aq_get_link_info function is not thread-safe. However, it is poss= ible > to simultaneous invocations during both the dev_start and the LSC > interrupt handler, potentially leading to unexpected adminq errors. This > patch addresses the issue by introducing a thread-safe wrapper that utili= zes > a spinlock. >=20 > Fixes: cf911d90e366 ("net/ice: support link update") > Cc: stable@dpdk.org >=20 > Signed-off-by: Qi Zhang > --- > v2: > - fix coding style warning. >=20 > drivers/net/ice/ice_ethdev.c | 26 ++++++++++++++++++++------ > drivers/net/ice/ice_ethdev.h | 4 ++++ > 2 files changed, 24 insertions(+), 6 deletions(-) >=20 > diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c = index > 3ccba4db80..1f8ab5158a 100644 > --- a/drivers/net/ice/ice_ethdev.c > +++ b/drivers/net/ice/ice_ethdev.c > @@ -1804,6 +1804,7 @@ ice_pf_setup(struct ice_pf *pf) > } >=20 > pf->main_vsi =3D vsi; > + rte_spinlock_init(&pf->link_lock); >=20 > return 0; > } > @@ -3621,17 +3622,31 @@ ice_rxq_intr_setup(struct rte_eth_dev *dev) > return 0; > } >=20 > +static enum ice_status > +ice_get_link_info_safe(struct ice_pf *pf, bool ena_lse, > + struct ice_link_status *link) > +{ > + struct ice_hw *hw =3D ICE_PF_TO_HW(pf); > + int ret; > + > + rte_spinlock_lock(&pf->link_lock); > + > + ret =3D ice_aq_get_link_info(hw->port_info, ena_lse, link, NULL); > + > + rte_spinlock_unlock(&pf->link_lock); > + > + return ret; > +} > + > static void > ice_get_init_link_status(struct rte_eth_dev *dev) { > - struct ice_hw *hw =3D ICE_DEV_PRIVATE_TO_HW(dev->data- > >dev_private); > struct ice_pf *pf =3D ICE_DEV_PRIVATE_TO_PF(dev->data- > >dev_private); > bool enable_lse =3D dev->data->dev_conf.intr_conf.lsc ? true : false; > struct ice_link_status link_status; > int ret; >=20 > - ret =3D ice_aq_get_link_info(hw->port_info, enable_lse, > - &link_status, NULL); > + ret =3D ice_get_link_info_safe(pf, enable_lse, &link_status); > if (ret !=3D ICE_SUCCESS) { > PMD_DRV_LOG(ERR, "Failed to get link info"); > pf->init_link_up =3D false; > @@ -3996,7 +4011,7 @@ ice_link_update(struct rte_eth_dev *dev, int > wait_to_complete) { #define CHECK_INTERVAL 50 /* 50ms */ #define > MAX_REPEAT_TIME 40 /* 2s (40 * 50ms) in total */ > - struct ice_hw *hw =3D ICE_DEV_PRIVATE_TO_HW(dev->data- > >dev_private); > + struct ice_pf *pf =3D ICE_DEV_PRIVATE_TO_PF(dev->data- > >dev_private); > struct ice_link_status link_status; > struct rte_eth_link link, old; > int status; > @@ -4010,8 +4025,7 @@ ice_link_update(struct rte_eth_dev *dev, int > wait_to_complete) >=20 > do { > /* Get link status information from hardware */ > - status =3D ice_aq_get_link_info(hw->port_info, enable_lse, > - &link_status, NULL); > + status =3D ice_get_link_info_safe(pf, enable_lse, &link_status); > if (status !=3D ICE_SUCCESS) { > link.link_speed =3D RTE_ETH_SPEED_NUM_100M; > link.link_duplex =3D RTE_ETH_LINK_FULL_DUPLEX; diff - > -git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h index > abe6dcdc23..d607f028e0 100644 > --- a/drivers/net/ice/ice_ethdev.h > +++ b/drivers/net/ice/ice_ethdev.h > @@ -548,6 +548,10 @@ struct ice_pf { > uint64_t rss_hf; > struct ice_tm_conf tm_conf; > uint16_t outer_ethertype; > + /* lock prevent race condition between lsc interrupt handler > + * and link status update during dev_start. > + */ > + rte_spinlock_t link_lock; > }; >=20 > #define ICE_MAX_QUEUE_NUM 2048 > -- > 2.31.1 Acked-by: Qiming Yang