[dpdk-stable] patch 'net/atlantic: add FW mailbox guard mutex' has been queued to LTS release 18.11.6

Kevin Traynor ktraynor at redhat.com
Tue Dec 3 19:26:42 CET 2019


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 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/kevintraynor/dpdk-stable-queue

This queued commit can be viewed at:
https://github.com/kevintraynor/dpdk-stable-queue/commit/b3f030c219d633fcdc73824a8958e3ab1b2e8a95

Thanks.

Kevin.

---
>From b3f030c219d633fcdc73824a8958e3ab1b2e8a95 Mon Sep 17 00:00:00 2001
From: Pavel Belous <pavel.belous at aquantia.com>
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 <pavel.belous at aquantia.com>
Signed-off-by: Igor Russkikh <igor.russkikh at aquantia.com>
---
 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_ethdev.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)
 	hw->aq_nic_cfg = &adapter->hw_cfg;
 
+	pthread_mutex_init(&hw->mbox_mutex, NULL);
+
 	/* disable interrupt */
 	atl_disable_intr(hw);
@@ -423,4 +425,6 @@ eth_atl_dev_uninit(struct rte_eth_dev *eth_dev)
 	eth_dev->data->mac_addrs = NULL;
 
+	pthread_mutex_destroy(&hw->mbox_mutex);
+
 	return 0;
 }
diff --git a/drivers/net/atlantic/atl_types.h b/drivers/net/atlantic/atl_types.h
index c53d58969..1a7965c2f 100644
--- a/drivers/net/atlantic/atl_types.h
+++ b/drivers/net/atlantic/atl_types.h
@@ -11,4 +11,5 @@
 #include <stdbool.h>
 #include <netinet/in.h>
+#include <pthread.h>
 
 typedef uint8_t		u8;
@@ -104,4 +105,6 @@ struct aq_hw_s {
 	u32 rpc_tid;
 	struct hw_aq_atl_utils_fw_rpc rpc;
+
+	pthread_mutex_t mbox_mutex;
 };
 
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 @@
 
 #include <rte_ether.h>
+#include <pthread.h>
 #include "../atl_hw_regs.h"
 
@@ -214,4 +215,6 @@ int aq_fw2x_get_mac_permanent(struct aq_hw_s *self, u8 *mac)
 	u32 efuse_addr = aq_hw_read_reg(self, HW_ATL_FW2X_MPI_EFUSE_ADDR);
 
+	pthread_mutex_lock(&self->mbox_mutex);
+
 	if (efuse_addr != 0) {
 		err = hw_atl_utils_fw_downld_dwords(self,
@@ -220,5 +223,5 @@ int aq_fw2x_get_mac_permanent(struct aq_hw_s *self, u8 *mac)
 						    ARRAY_SIZE(mac_addr));
 		if (err)
-			return err;
+			goto exit;
 		mac_addr[0] = rte_constant_bswap32(mac_addr[0]);
 		mac_addr[1] = rte_constant_bswap32(mac_addr[1]);
@@ -249,4 +252,8 @@ int aq_fw2x_get_mac_permanent(struct aq_hw_s *self, u8 *mac)
 		mac[0] = (u8)(0xFFU & h);
 	}
+
+exit:
+	pthread_mutex_unlock(&self->mbox_mutex);
+
 	return err;
 }
@@ -258,4 +265,7 @@ static int aq_fw2x_update_stats(struct aq_hw_s *self)
 	u32 orig_stats_val = mpi_opts & BIT(CAPS_HI_STATISTICS);
 
+
+	pthread_mutex_lock(&self->mbox_mutex);
+
 	/* Toggle statistics bit for FW to update */
 	mpi_opts = mpi_opts ^ BIT(CAPS_HI_STATISTICS);
@@ -268,7 +278,13 @@ static int aq_fw2x_update_stats(struct aq_hw_s *self)
 		       1U, 10000U);
 	if (err)
-		return err;
+		goto exit;
+
+	err = hw_atl_utils_update_stats(self);
+
+exit:
+	pthread_mutex_unlock(&self->mbox_mutex);
+
+	return err;
 
-	return hw_atl_utils_update_stats(self);
 }
 
@@ -280,4 +296,6 @@ static int aq_fw2x_get_temp(struct aq_hw_s *self, int *temp)
 	u32 temp_res;
 
+	pthread_mutex_lock(&self->mbox_mutex);
+
 	/* Toggle statistics bit for FW to 0x36C.18 (CAPS_HI_TEMPERATURE) */
 	mpi_opts = mpi_opts ^ BIT(CAPS_HI_TEMPERATURE);
@@ -295,4 +313,7 @@ static int aq_fw2x_get_temp(struct aq_hw_s *self, int *temp)
 				sizeof(temp_res) / sizeof(u32));
 
+
+	pthread_mutex_unlock(&self->mbox_mutex);
+
 	if (err)
 		return err;
@@ -512,4 +533,6 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, int dev_addr,
 		return -EOPNOTSUPP;
 
+	pthread_mutex_lock(&self->mbox_mutex);
+
 	request.msg_id = 0;
 	request.device_id = dev_addr;
@@ -523,5 +546,5 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, int dev_addr,
 
 	if (err < 0)
-		return err;
+		goto exit;
 
 	/* 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,
 
 	if (err < 0)
-		return err;
+		goto exit;
 
 	err = 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, int dev_addr,
 
 	if (err < 0)
-		return err;
+		goto exit;
 
-	if (result)
-		return -EIO;
+	if (result) {
+		err = -EIO;
+		goto exit;
+	}
 
 	if (num_dwords) {
@@ -557,5 +582,5 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, int dev_addr,
 
 		if (err < 0)
-			return err;
+			goto exit;
 	}
 
@@ -570,5 +595,5 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, int dev_addr,
 
 		if (err < 0)
-			return err;
+			goto exit;
 
 		rte_memcpy((u8 *)data + len - bytes_remains,
@@ -576,5 +601,8 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, int dev_addr,
 	}
 
-	return 0;
+exit:
+	pthread_mutex_unlock(&self->mbox_mutex);
+
+	return err;
 }
 
@@ -595,4 +623,6 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, int dev_addr,
 	request.length = len;
 
+	pthread_mutex_lock(&self->mbox_mutex);
+
 	/* Write SMBUS request to cfg memory */
 	err = 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,
 
 	if (err < 0)
-		return err;
+		goto exit;
 
 	/* Write SMBUS data to cfg memory */
@@ -614,5 +644,5 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, int dev_addr,
 
 		if (err < 0)
-			return err;
+			goto exit;
 	}
 
@@ -630,5 +660,5 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, int dev_addr,
 
 		if (err < 0)
-			return err;
+			goto exit;
 	}
 
@@ -645,5 +675,5 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, int dev_addr,
 
 	if (err < 0)
-		return err;
+		goto exit;
 
 	/* Read status of write operation */
@@ -653,10 +683,15 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, int dev_addr,
 
 	if (err < 0)
-		return err;
+		goto exit;
 
-	if (result)
-		return -EIO;
+	if (result) {
+		err = -EIO;
+		goto exit;
+	}
 
-	return 0;
+exit:
+	pthread_mutex_unlock(&self->mbox_mutex);
+
+	return err;
 }
 
-- 
2.21.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2019-12-03 17:29:53.733776541 +0000
+++ 0033-net-atlantic-add-FW-mailbox-guard-mutex.patch	2019-12-03 17:29:51.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 at 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, int dev_addr,
+@@ -512,4 +533,6 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, int dev_addr,
@@ -136 +137 @@
-@@ -527,5 +550,5 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, int dev_addr,
+@@ -523,5 +546,5 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, int dev_addr,
@@ -143 +144 @@
-@@ -542,5 +565,5 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, int dev_addr,
+@@ -538,5 +561,5 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, int dev_addr,
@@ -150 +151 @@
-@@ -549,8 +572,10 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, int dev_addr,
+@@ -545,8 +568,10 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, int dev_addr,
@@ -164 +165 @@
-@@ -561,5 +586,5 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, int dev_addr,
+@@ -557,5 +582,5 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, int dev_addr,
@@ -171 +172 @@
-@@ -574,5 +599,5 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, int dev_addr,
+@@ -570,5 +595,5 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, int dev_addr,
@@ -178 +179 @@
-@@ -580,5 +605,8 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, int dev_addr,
+@@ -576,5 +601,8 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, int dev_addr,
@@ -188 +189 @@
-@@ -599,4 +627,6 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, int dev_addr,
+@@ -595,4 +623,6 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, int dev_addr,
@@ -195 +196 @@
-@@ -605,5 +635,5 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, int dev_addr,
+@@ -601,5 +631,5 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, int dev_addr,
@@ -202 +203 @@
-@@ -618,5 +648,5 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, int dev_addr,
+@@ -614,5 +644,5 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, int dev_addr,
@@ -209 +210 @@
-@@ -634,5 +664,5 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, int dev_addr,
+@@ -630,5 +660,5 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, int dev_addr,
@@ -216 +217 @@
-@@ -649,5 +679,5 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, int dev_addr,
+@@ -645,5 +675,5 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, int 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,
- 		return -EOPNOTSUPP;
- 
-+	pthread_mutex_lock(&self->mbox_mutex);
-+
- 	/* Write macsec request to cfg memory */
- 	err = 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,
- 
- 	if (err < 0)
--		return err;
-+		goto exit;
- 
- 	/* Toggle 0x368.CAPS_LO_MACSEC bit */
-@@ -698,5 +735,5 @@ static int aq_fw2x_send_macsec_request(struct aq_hw_s *self,
- 
- 	if (err < 0)
--		return err;
-+		goto exit;
- 
- 	/* Read status of write operation */
-@@ -705,4 +742,7 @@ static int aq_fw2x_send_macsec_request(struct aq_hw_s *self,
- 		RTE_ALIGN(sizeof(*response) / sizeof(u32), sizeof(u32)));
- 
-+exit:
-+	pthread_mutex_unlock(&self->mbox_mutex);
-+
- 	return err;
- }



More information about the stable mailing list