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 566A7A04B5 for ; Tue, 3 Dec 2019 19:28:38 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 490EF235; Tue, 3 Dec 2019 19:28:38 +0100 (CET) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by dpdk.org (Postfix) with ESMTP id 4843E1BF8D for ; Tue, 3 Dec 2019 19:28:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575397715; 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=0mnIedeI0P3olu6b/mcjW4SXTII/hcAj7Q54aKmxOpQ=; b=SQyeiQA7VgZpccmflDpv+y3xSkgfHekVRGSpKnp4DG9WVlbVbOJ/daSVHE1/ix1BdusPbt NDL9+Uq+8u/V8QVqks6L5QGGHtxeRNyozhw6pv1aBuTYqidX6S13Os8z2O5QkQfUU3XZhg 48W2Or4apJnrzJMZ6+BRzpUsXyOTAt4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-153-sIYf0jCLOnmEx9rlsbqzAg-1; Tue, 03 Dec 2019 13:28:34 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 82F78107ACC7; Tue, 3 Dec 2019 18:28:33 +0000 (UTC) Received: from rh.redhat.com (ovpn-117-10.ams2.redhat.com [10.36.117.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9B28F5C240; Tue, 3 Dec 2019 18:28:32 +0000 (UTC) From: Kevin Traynor To: Pavel Belous Cc: Igor Russkikh , dpdk stable Date: Tue, 3 Dec 2019 18:26:42 +0000 Message-Id: <20191203182714.17297-33-ktraynor@redhat.com> In-Reply-To: <20191203182714.17297-1-ktraynor@redhat.com> References: <20191203182714.17297-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: sIYf0jCLOnmEx9rlsbqzAg-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Subject: [dpdk-stable] patch 'net/atlantic: add FW mailbox guard mutex' has been queued to LTS release 18.11.6 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 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 Sender: "stable" Hi, FYI, your patch has been queued to LTS release 18.11.6 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 12/10/19. 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 rebasi= ng (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/kevintraynor/dpdk-stable-queue This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable-queue/commit/b3f030c219d633fcdc= 73824a8958e3ab1b2e8a95 Thanks. Kevin. --- >From b3f030c219d633fcdc73824a8958e3ab1b2e8a95 Mon Sep 17 00:00:00 2001 From: Pavel Belous Date: Fri, 20 Sep 2019 16:22:07 +0000 Subject: [PATCH] net/atlantic: add FW mailbox guard mutex [ upstream commit e9924638f5c967e119983f871959bc632d37d83d ] Driver uses the Firmware mailbox to read statistics and configure some features. This patch introduces a mutex to provide consistent access to the FW mailbox to prevent potential data corruption. Fixes: 86d36773bd42 ("net/atlantic: implement firmware operations") Signed-off-by: Pavel Belous Signed-off-by: Igor Russkikh --- drivers/net/atlantic/atl_ethdev.c | 4 + drivers/net/atlantic/atl_types.h | 3 + .../net/atlantic/hw_atl/hw_atl_utils_fw2x.c | 73 ++++++++++++++----- 3 files changed, 61 insertions(+), 19 deletions(-) diff --git a/drivers/net/atlantic/atl_ethdev.c b/drivers/net/atlantic/atl_e= thdev.c index 623c7166e..761347fb5 100644 --- a/drivers/net/atlantic/atl_ethdev.c +++ b/drivers/net/atlantic/atl_ethdev.c @@ -360,4 +360,6 @@ eth_atl_dev_init(struct rte_eth_dev *eth_dev) =09hw->aq_nic_cfg =3D &adapter->hw_cfg; =20 +=09pthread_mutex_init(&hw->mbox_mutex, NULL); + =09/* disable interrupt */ =09atl_disable_intr(hw); @@ -423,4 +425,6 @@ eth_atl_dev_uninit(struct rte_eth_dev *eth_dev) =09eth_dev->data->mac_addrs =3D NULL; =20 +=09pthread_mutex_destroy(&hw->mbox_mutex); + =09return 0; } diff --git a/drivers/net/atlantic/atl_types.h b/drivers/net/atlantic/atl_ty= pes.h index c53d58969..1a7965c2f 100644 --- a/drivers/net/atlantic/atl_types.h +++ b/drivers/net/atlantic/atl_types.h @@ -11,4 +11,5 @@ #include #include +#include =20 typedef uint8_t=09=09u8; @@ -104,4 +105,6 @@ struct aq_hw_s { =09u32 rpc_tid; =09struct hw_aq_atl_utils_fw_rpc rpc; + +=09pthread_mutex_t mbox_mutex; }; =20 diff --git a/drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c b/drivers/net/= atlantic/hw_atl/hw_atl_utils_fw2x.c index 11f14d1a2..a6c686833 100644 --- a/drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c +++ b/drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c @@ -7,4 +7,5 @@ =20 #include +#include #include "../atl_hw_regs.h" =20 @@ -214,4 +215,6 @@ int aq_fw2x_get_mac_permanent(struct aq_hw_s *self, u8 = *mac) =09u32 efuse_addr =3D aq_hw_read_reg(self, HW_ATL_FW2X_MPI_EFUSE_ADDR); =20 +=09pthread_mutex_lock(&self->mbox_mutex); + =09if (efuse_addr !=3D 0) { =09=09err =3D hw_atl_utils_fw_downld_dwords(self, @@ -220,5 +223,5 @@ int aq_fw2x_get_mac_permanent(struct aq_hw_s *self, u8 = *mac) =09=09=09=09=09=09 ARRAY_SIZE(mac_addr)); =09=09if (err) -=09=09=09return err; +=09=09=09goto exit; =09=09mac_addr[0] =3D rte_constant_bswap32(mac_addr[0]); =09=09mac_addr[1] =3D rte_constant_bswap32(mac_addr[1]); @@ -249,4 +252,8 @@ int aq_fw2x_get_mac_permanent(struct aq_hw_s *self, u8 = *mac) =09=09mac[0] =3D (u8)(0xFFU & h); =09} + +exit: +=09pthread_mutex_unlock(&self->mbox_mutex); + =09return err; } @@ -258,4 +265,7 @@ static int aq_fw2x_update_stats(struct aq_hw_s *self) =09u32 orig_stats_val =3D mpi_opts & BIT(CAPS_HI_STATISTICS); =20 + +=09pthread_mutex_lock(&self->mbox_mutex); + =09/* Toggle statistics bit for FW to update */ =09mpi_opts =3D mpi_opts ^ BIT(CAPS_HI_STATISTICS); @@ -268,7 +278,13 @@ static int aq_fw2x_update_stats(struct aq_hw_s *self) =09=09 1U, 10000U); =09if (err) -=09=09return err; +=09=09goto exit; + +=09err =3D hw_atl_utils_update_stats(self); + +exit: +=09pthread_mutex_unlock(&self->mbox_mutex); + +=09return err; =20 -=09return hw_atl_utils_update_stats(self); } =20 @@ -280,4 +296,6 @@ static int aq_fw2x_get_temp(struct aq_hw_s *self, int *= temp) =09u32 temp_res; =20 +=09pthread_mutex_lock(&self->mbox_mutex); + =09/* Toggle statistics bit for FW to 0x36C.18 (CAPS_HI_TEMPERATURE) */ =09mpi_opts =3D mpi_opts ^ BIT(CAPS_HI_TEMPERATURE); @@ -295,4 +313,7 @@ static int aq_fw2x_get_temp(struct aq_hw_s *self, int *= temp) =09=09=09=09sizeof(temp_res) / sizeof(u32)); =20 + +=09pthread_mutex_unlock(&self->mbox_mutex); + =09if (err) =09=09return err; @@ -512,4 +533,6 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, int= dev_addr, =09=09return -EOPNOTSUPP; =20 +=09pthread_mutex_lock(&self->mbox_mutex); + =09request.msg_id =3D 0; =09request.device_id =3D dev_addr; @@ -523,5 +546,5 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, int= dev_addr, =20 =09if (err < 0) -=09=09return err; +=09=09goto exit; =20 =09/* Toggle 0x368.CAPS_LO_SMBUS_READ bit */ @@ -538,5 +561,5 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, int= dev_addr, =20 =09if (err < 0) -=09=09return err; +=09=09goto exit; =20 =09err =3D hw_atl_utils_fw_downld_dwords(self, self->rpc_addr + sizeof(u32= ), @@ -545,8 +568,10 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, in= t dev_addr, =20 =09if (err < 0) -=09=09return err; +=09=09goto exit; =20 -=09if (result) -=09=09return -EIO; +=09if (result) { +=09=09err =3D -EIO; +=09=09goto exit; +=09} =20 =09if (num_dwords) { @@ -557,5 +582,5 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, int= dev_addr, =20 =09=09if (err < 0) -=09=09=09return err; +=09=09=09goto exit; =09} =20 @@ -570,5 +595,5 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, int= dev_addr, =20 =09=09if (err < 0) -=09=09=09return err; +=09=09=09goto exit; =20 =09=09rte_memcpy((u8 *)data + len - bytes_remains, @@ -576,5 +601,8 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, int= dev_addr, =09} =20 -=09return 0; +exit: +=09pthread_mutex_unlock(&self->mbox_mutex); + +=09return err; } =20 @@ -595,4 +623,6 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, int= dev_addr, =09request.length =3D len; =20 +=09pthread_mutex_lock(&self->mbox_mutex); + =09/* Write SMBUS request to cfg memory */ =09err =3D hw_atl_utils_fw_upload_dwords(self, self->rpc_addr, @@ -601,5 +631,5 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, int= dev_addr, =20 =09if (err < 0) -=09=09return err; +=09=09goto exit; =20 =09/* Write SMBUS data to cfg memory */ @@ -614,5 +644,5 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, int= dev_addr, =20 =09=09if (err < 0) -=09=09=09return err; +=09=09=09goto exit; =09} =20 @@ -630,5 +660,5 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, int= dev_addr, =20 =09=09if (err < 0) -=09=09=09return err; +=09=09=09goto exit; =09} =20 @@ -645,5 +675,5 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, int= dev_addr, =20 =09if (err < 0) -=09=09return err; +=09=09goto exit; =20 =09/* Read status of write operation */ @@ -653,10 +683,15 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, i= nt dev_addr, =20 =09if (err < 0) -=09=09return err; +=09=09goto exit; =20 -=09if (result) -=09=09return -EIO; +=09if (result) { +=09=09err =3D -EIO; +=09=09goto exit; +=09} =20 -=09return 0; +exit: +=09pthread_mutex_unlock(&self->mbox_mutex); + +=09return err; } =20 --=20 2.21.0 --- Diff of the applied patch vs upstream commit (please double-check if non-= empty: --- --- -=092019-12-03 17:29:53.733776541 +0000 +++ 0033-net-atlantic-add-FW-mailbox-guard-mutex.patch=092019-12-03 17:29:5= 1.757749807 +0000 @@ -1 +1 @@ -From e9924638f5c967e119983f871959bc632d37d83d Mon Sep 17 00:00:00 2001 +From b3f030c219d633fcdc73824a8958e3ab1b2e8a95 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit e9924638f5c967e119983f871959bc632d37d83d ] + @@ -12 +13,0 @@ -Cc: stable@dpdk.org @@ -19,2 +20,2 @@ - .../net/atlantic/hw_atl/hw_atl_utils_fw2x.c | 82 ++++++++++++++----- - 3 files changed, 68 insertions(+), 21 deletions(-) + .../net/atlantic/hw_atl/hw_atl_utils_fw2x.c | 73 ++++++++++++++----- + 3 files changed, 61 insertions(+), 19 deletions(-) @@ -23 +24 @@ -index d5c2ec594..b2b3bd36c 100644 +index 623c7166e..761347fb5 100644 @@ -26 +27 @@ -@@ -408,4 +408,6 @@ eth_atl_dev_init(struct rte_eth_dev *eth_dev) +@@ -360,4 +360,6 @@ eth_atl_dev_init(struct rte_eth_dev *eth_dev) @@ -33 +34 @@ -@@ -472,4 +474,6 @@ eth_atl_dev_uninit(struct rte_eth_dev *eth_dev) +@@ -423,4 +425,6 @@ eth_atl_dev_uninit(struct rte_eth_dev *eth_dev) @@ -41 +42 @@ -index 19aaf3767..c200a1fad 100644 +index c53d58969..1a7965c2f 100644 @@ -50 +51 @@ -@@ -138,4 +139,6 @@ struct aq_hw_s { +@@ -104,4 +105,6 @@ struct aq_hw_s { @@ -58 +59 @@ -index 70d6e14bb..55dc728d3 100644 +index 11f14d1a2..a6c686833 100644 @@ -67 +68 @@ -@@ -218,4 +219,6 @@ int aq_fw2x_get_mac_permanent(struct aq_hw_s *self, u8= *mac) +@@ -214,4 +215,6 @@ int aq_fw2x_get_mac_permanent(struct aq_hw_s *self, u8= *mac) @@ -74 +75 @@ -@@ -224,5 +227,5 @@ int aq_fw2x_get_mac_permanent(struct aq_hw_s *self, u8= *mac) +@@ -220,5 +223,5 @@ int aq_fw2x_get_mac_permanent(struct aq_hw_s *self, u8= *mac) @@ -81 +82 @@ -@@ -253,4 +256,8 @@ int aq_fw2x_get_mac_permanent(struct aq_hw_s *self, u8= *mac) +@@ -249,4 +252,8 @@ int aq_fw2x_get_mac_permanent(struct aq_hw_s *self, u8= *mac) @@ -90 +91 @@ -@@ -262,4 +269,7 @@ static int aq_fw2x_update_stats(struct aq_hw_s *self) +@@ -258,4 +265,7 @@ static int aq_fw2x_update_stats(struct aq_hw_s *self) @@ -98 +99 @@ -@@ -272,7 +282,13 @@ static int aq_fw2x_update_stats(struct aq_hw_s *self) +@@ -268,7 +278,13 @@ static int aq_fw2x_update_stats(struct aq_hw_s *self) @@ -114 +115 @@ -@@ -284,4 +300,6 @@ static int aq_fw2x_get_temp(struct aq_hw_s *self, int = *temp) +@@ -280,4 +296,6 @@ static int aq_fw2x_get_temp(struct aq_hw_s *self, int = *temp) @@ -121 +122 @@ -@@ -299,4 +317,7 @@ static int aq_fw2x_get_temp(struct aq_hw_s *self, int = *temp) +@@ -295,4 +313,7 @@ static int aq_fw2x_get_temp(struct aq_hw_s *self, int = *temp) @@ -129 +130 @@ -@@ -516,4 +537,6 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, in= t dev_addr, +@@ -512,4 +533,6 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, in= t dev_addr, @@ -136 +137 @@ -@@ -527,5 +550,5 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, in= t dev_addr, +@@ -523,5 +546,5 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, in= t dev_addr, @@ -143 +144 @@ -@@ -542,5 +565,5 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, in= t dev_addr, +@@ -538,5 +561,5 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, in= t dev_addr, @@ -150 +151 @@ -@@ -549,8 +572,10 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, i= nt dev_addr, +@@ -545,8 +568,10 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, i= nt dev_addr, @@ -164 +165 @@ -@@ -561,5 +586,5 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, in= t dev_addr, +@@ -557,5 +582,5 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, in= t dev_addr, @@ -171 +172 @@ -@@ -574,5 +599,5 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, in= t dev_addr, +@@ -570,5 +595,5 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, in= t dev_addr, @@ -178 +179 @@ -@@ -580,5 +605,8 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, in= t dev_addr, +@@ -576,5 +601,8 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, in= t dev_addr, @@ -188 +189 @@ -@@ -599,4 +627,6 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, in= t dev_addr, +@@ -595,4 +623,6 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, in= t dev_addr, @@ -195 +196 @@ -@@ -605,5 +635,5 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, in= t dev_addr, +@@ -601,5 +631,5 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, in= t dev_addr, @@ -202 +203 @@ -@@ -618,5 +648,5 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, in= t dev_addr, +@@ -614,5 +644,5 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, in= t dev_addr, @@ -209 +210 @@ -@@ -634,5 +664,5 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, in= t dev_addr, +@@ -630,5 +660,5 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, in= t dev_addr, @@ -216 +217 @@ -@@ -649,5 +679,5 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, in= t dev_addr, +@@ -645,5 +675,5 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, in= t dev_addr, @@ -223 +224 @@ -@@ -657,10 +687,15 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, = int dev_addr, +@@ -653,10 +683,15 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, = int dev_addr, @@ -243,29 +243,0 @@ -@@ -678,4 +713,6 @@ static int aq_fw2x_send_macsec_request(struct aq_hw_s = *self, - =09=09return -EOPNOTSUPP; -=20 -+=09pthread_mutex_lock(&self->mbox_mutex); -+ - =09/* Write macsec request to cfg memory */ - =09err =3D hw_atl_utils_fw_upload_dwords(self, self->rpc_addr, -@@ -684,5 +721,5 @@ static int aq_fw2x_send_macsec_request(struct aq_hw_s = *self, -=20 - =09if (err < 0) --=09=09return err; -+=09=09goto exit; -=20 - =09/* Toggle 0x368.CAPS_LO_MACSEC bit */ -@@ -698,5 +735,5 @@ static int aq_fw2x_send_macsec_request(struct aq_hw_s = *self, -=20 - =09if (err < 0) --=09=09return err; -+=09=09goto exit; -=20 - =09/* Read status of write operation */ -@@ -705,4 +742,7 @@ static int aq_fw2x_send_macsec_request(struct aq_hw_s = *self, - =09=09RTE_ALIGN(sizeof(*response) / sizeof(u32), sizeof(u32))); -=20 -+exit: -+=09pthread_mutex_unlock(&self->mbox_mutex); -+ - =09return err; - }