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 BF03743C60 for ; Thu, 7 Mar 2024 02:33:01 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A1EEE42DFA; Thu, 7 Mar 2024 02:33:01 +0100 (CET) Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) by mails.dpdk.org (Postfix) with ESMTP id 4FE7540E5A for ; Thu, 7 Mar 2024 02:33:00 +0100 (CET) Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-33d90dfe73cso242677f8f.0 for ; Wed, 06 Mar 2024 17:33:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709775180; x=1710379980; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2/Gtn2X1dvVazygRLYsOAaZx5fxxdrB/33NplHVJW3c=; b=KQsstYraoyHa/u0Kqmr9ZKovCEfJV/zDd7uFe6PDoy9AJhPuPVGqiKRigAEvaEbyZU zEki/j2jZ6cZqZiazOfc0weIALs9vgCAm79F586271+SaLGtc4Vfp5kcMk36ITLVp8SY pEh5tx5/hyUJnb2+TnLzTTvHHu8HljTOHmqLSlVUZG471Xy9IM6KxCCd007SOnTjiZxJ CbxSdu8ILIHh1W+g3YtobqhJHBoo8z6gfxRUf2omQeRI5Z9HM3Lb4eLMelcfNfv9iCKU nQxkHTDFRKz1Ocj9uH3MgAPkE2sQDN5eMCFsGzMPGViGLcRVRFisHo+56fx+IUBfM0sx 8riQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709775180; x=1710379980; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2/Gtn2X1dvVazygRLYsOAaZx5fxxdrB/33NplHVJW3c=; b=E5uDt5zMqNB1fjZbDVy48CxU7Ll0g2ZCLT6oONrLNGjstRUpDowQyXSlj7A9q2sG6y 4z7SsJpUnif17y1STR+rPK8yB6e/272jewg1xgsUlK9dkU9/b1vfqVSgU+hIBzhFkBYR PnH2fSBjTOqckWOejF7qkVz1l6hCWaJNqo7Reul4rpZBFSByScZqOjZcpUf/rB5uwQ/J 6uR6Ns0OBnOXi87QN+YxQfz6oM7AfGVjJcBrjnSDhkoty/Moz+3shF46i5MCwL6fQv6F uD0pcqm0IoPFw249oJnuK4HJh+wfeV6AKtHfs86AjJ08hIWjwnKnDRd6nftpFmmchy7f 8iQA== X-Forwarded-Encrypted: i=1; AJvYcCWbWPToitmjrojmVSQpf79LAePDw4T2aXC9WzD7BUZ66/WQR9vitC/OlB3ukvbCeu0YcC8ejSI6bSWoMf+X9XU= X-Gm-Message-State: AOJu0Yzf9UfO0WKAD8Xqu8aCV53HZpadBlj0bMYEbvFjt00h5c7MgfNW XuM1UpOjVI20rpK6P+4p4vtNnBWRYVlmqyZRjrqyw4G6wREvy+zhT0r+qcj9 X-Google-Smtp-Source: AGHT+IFDsccRjHRXO2ohR4W569O2kc9vdLGnTQuOMS7we/7uK1/B2O+YPC6WLDIT0VxFvYEdrvp7mg== X-Received: by 2002:adf:a49a:0:b0:33d:c45:15ec with SMTP id g26-20020adfa49a000000b0033d0c4515ecmr30270wrb.32.1709775179979; Wed, 06 Mar 2024 17:32:59 -0800 (PST) Received: from localhost ([137.220.120.171]) by smtp.gmail.com with ESMTPSA id n3-20020a5d4203000000b0033e12a67fb3sm18190669wrq.50.2024.03.06.17.32.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 17:32:59 -0800 (PST) From: luca.boccassi@gmail.com To: Qi Zhang Cc: Qiming Yang , dpdk stable Subject: patch 'net/ice: fix link update' has been queued to stable release 22.11.5 Date: Thu, 7 Mar 2024 01:30:28 +0000 Message-Id: <20240307013159.1735343-11-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240307013159.1735343-1-luca.boccassi@gmail.com> References: <20240307013159.1735343-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 22.11.5 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 03/09/24. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/51cb79315c3f4d9f8282b566663794b591323a34 Thanks. Luca Boccassi --- >From 51cb79315c3f4d9f8282b566663794b591323a34 Mon Sep 17 00:00:00 2001 From: Qi Zhang Date: Thu, 14 Dec 2023 03:40:54 -0500 Subject: [PATCH] net/ice: fix link update [ upstream commit 4e5dc111464e83e9a55fa466d8f682f0027b721e ] The ice_aq_get_link_info function is not thread-safe. However, it is possible 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 utilizes a spinlock. Fixes: cf911d90e366 ("net/ice: support link update") Signed-off-by: Qi Zhang Acked-by: Qiming Yang --- drivers/net/ice/ice_ethdev.c | 26 ++++++++++++++++++++------ drivers/net/ice/ice_ethdev.h | 4 ++++ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index 8ce7d0ebaa..994eeaa83b 100644 --- a/drivers/net/ice/ice_ethdev.c +++ b/drivers/net/ice/ice_ethdev.c @@ -1773,6 +1773,7 @@ ice_pf_setup(struct ice_pf *pf) } pf->main_vsi = vsi; + rte_spinlock_init(&pf->link_lock); return 0; } @@ -3589,17 +3590,31 @@ ice_rxq_intr_setup(struct rte_eth_dev *dev) return 0; } +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 = ICE_PF_TO_HW(pf); + int ret; + + rte_spinlock_lock(&pf->link_lock); + + ret = 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 = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private); struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private); bool enable_lse = dev->data->dev_conf.intr_conf.lsc ? true : false; struct ice_link_status link_status; int ret; - ret = ice_aq_get_link_info(hw->port_info, enable_lse, - &link_status, NULL); + ret = ice_get_link_info_safe(pf, enable_lse, &link_status); if (ret != ICE_SUCCESS) { PMD_DRV_LOG(ERR, "Failed to get link info"); pf->init_link_up = false; @@ -3960,7 +3975,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 = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private); struct ice_link_status link_status; struct rte_eth_link link, old; int status; @@ -3974,8 +3989,7 @@ ice_link_update(struct rte_eth_dev *dev, int wait_to_complete) do { /* Get link status information from hardware */ - status = ice_aq_get_link_info(hw->port_info, enable_lse, - &link_status, NULL); + status = ice_get_link_info_safe(pf, enable_lse, &link_status); if (status != ICE_SUCCESS) { link.link_speed = RTE_ETH_SPEED_NUM_100M; link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX; diff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h index c8311be179..bfc9140dba 100644 --- a/drivers/net/ice/ice_ethdev.h +++ b/drivers/net/ice/ice_ethdev.h @@ -550,6 +550,10 @@ struct ice_pf { uint64_t supported_rxdid; /* bitmap for supported RXDID */ uint64_t rss_hf; struct ice_tm_conf tm_conf; + /* lock prevent race condition between lsc interrupt handler + * and link status update during dev_start. + */ + rte_spinlock_t link_lock; }; #define ICE_MAX_QUEUE_NUM 2048 -- 2.39.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-03-07 01:05:36.044255764 +0000 +++ 0011-net-ice-fix-link-update.patch 2024-03-07 01:05:34.666937215 +0000 @@ -1 +1 @@ -From 4e5dc111464e83e9a55fa466d8f682f0027b721e Mon Sep 17 00:00:00 2001 +From 51cb79315c3f4d9f8282b566663794b591323a34 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 4e5dc111464e83e9a55fa466d8f682f0027b721e ] + @@ -13 +14,0 @@ -Cc: stable@dpdk.org @@ -23 +24 @@ -index 3ccba4db80..1f8ab5158a 100644 +index 8ce7d0ebaa..994eeaa83b 100644 @@ -26 +27 @@ -@@ -1804,6 +1804,7 @@ ice_pf_setup(struct ice_pf *pf) +@@ -1773,6 +1773,7 @@ ice_pf_setup(struct ice_pf *pf) @@ -34 +35 @@ -@@ -3621,17 +3622,31 @@ ice_rxq_intr_setup(struct rte_eth_dev *dev) +@@ -3589,17 +3590,31 @@ ice_rxq_intr_setup(struct rte_eth_dev *dev) @@ -69 +70 @@ -@@ -3996,7 +4011,7 @@ ice_link_update(struct rte_eth_dev *dev, int wait_to_complete) +@@ -3960,7 +3975,7 @@ ice_link_update(struct rte_eth_dev *dev, int wait_to_complete) @@ -78 +79 @@ -@@ -4010,8 +4025,7 @@ ice_link_update(struct rte_eth_dev *dev, int wait_to_complete) +@@ -3974,8 +3989,7 @@ ice_link_update(struct rte_eth_dev *dev, int wait_to_complete) @@ -89 +90 @@ -index abe6dcdc23..d607f028e0 100644 +index c8311be179..bfc9140dba 100644 @@ -92 +93,2 @@ -@@ -548,6 +548,10 @@ struct ice_pf { +@@ -550,6 +550,10 @@ struct ice_pf { + uint64_t supported_rxdid; /* bitmap for supported RXDID */ @@ -95 +96,0 @@ - uint16_t outer_ethertype;