lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240822-net-dsa-microchip-regmap-locking-v1-1-d557073b883c@kernel.org>
Date: Thu, 22 Aug 2024 20:53:04 +0100
From: Mark Brown <broonie@...nel.org>
To: Woojung Huh <woojung.huh@...rochip.com>, UNGLinuxDriver@...rochip.com, 
 Andrew Lunn <andrew@...n.ch>, Florian Fainelli <f.fainelli@...il.com>, 
 Vladimir Oltean <olteanv@...il.com>, 
 "David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>, 
 Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>
Cc: netdev@...r.kernel.org, linux-kernel@...r.kernel.org, 
 Mark Brown <broonie@...nel.org>
Subject: [PATCH] net: dsa: microchip: Use standard regmap locking

For unclear reasons the ksz drivers use custom regmap locking which is
simply a wrapper around a standard mutex. This mutex is not used outside
of the regmap operations so the result is simply to replicate the standard
mutex based locking provided by the regmap core. Remove the redundant code
and rely on the regmap core instead.

Signed-off-by: Mark Brown <broonie@...nel.org>
---
 drivers/net/dsa/microchip/ksz8863_smi.c |  7 -------
 drivers/net/dsa/microchip/ksz9477_i2c.c |  1 -
 drivers/net/dsa/microchip/ksz_common.c  |  1 -
 drivers/net/dsa/microchip/ksz_common.h  | 15 ---------------
 drivers/net/dsa/microchip/ksz_spi.c     |  1 -
 5 files changed, 25 deletions(-)

diff --git a/drivers/net/dsa/microchip/ksz8863_smi.c b/drivers/net/dsa/microchip/ksz8863_smi.c
index 5711a59e2ac9..582e744f7b68 100644
--- a/drivers/net/dsa/microchip/ksz8863_smi.c
+++ b/drivers/net/dsa/microchip/ksz8863_smi.c
@@ -105,8 +105,6 @@ static const struct regmap_config ksz8863_regmap_config[] = {
 		.pad_bits = 24,
 		.val_bits = 8,
 		.cache_type = REGCACHE_NONE,
-		.lock = ksz_regmap_lock,
-		.unlock = ksz_regmap_unlock,
 		.max_register = U8_MAX,
 	},
 	{
@@ -115,8 +113,6 @@ static const struct regmap_config ksz8863_regmap_config[] = {
 		.pad_bits = 24,
 		.val_bits = 16,
 		.cache_type = REGCACHE_NONE,
-		.lock = ksz_regmap_lock,
-		.unlock = ksz_regmap_unlock,
 		.max_register = U8_MAX,
 	},
 	{
@@ -125,8 +121,6 @@ static const struct regmap_config ksz8863_regmap_config[] = {
 		.pad_bits = 24,
 		.val_bits = 32,
 		.cache_type = REGCACHE_NONE,
-		.lock = ksz_regmap_lock,
-		.unlock = ksz_regmap_unlock,
 		.max_register = U8_MAX,
 	}
 };
@@ -150,7 +144,6 @@ static int ksz8863_smi_probe(struct mdio_device *mdiodev)
 
 	for (i = 0; i < __KSZ_NUM_REGMAPS; i++) {
 		rc = ksz8863_regmap_config[i];
-		rc.lock_arg = &dev->regmap_mutex;
 		rc.wr_table = chip->wr_table;
 		rc.rd_table = chip->rd_table;
 		dev->regmap[i] = devm_regmap_init(&mdiodev->dev,
diff --git a/drivers/net/dsa/microchip/ksz9477_i2c.c b/drivers/net/dsa/microchip/ksz9477_i2c.c
index 7d7560f23a73..59deb390e605 100644
--- a/drivers/net/dsa/microchip/ksz9477_i2c.c
+++ b/drivers/net/dsa/microchip/ksz9477_i2c.c
@@ -26,7 +26,6 @@ static int ksz9477_i2c_probe(struct i2c_client *i2c)
 
 	for (i = 0; i < __KSZ_NUM_REGMAPS; i++) {
 		rc = ksz9477_regmap_config[i];
-		rc.lock_arg = &dev->regmap_mutex;
 		dev->regmap[i] = devm_regmap_init_i2c(i2c, &rc);
 		if (IS_ERR(dev->regmap[i])) {
 			return dev_err_probe(&i2c->dev, PTR_ERR(dev->regmap[i]),
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index 1491099528be..4a383c87acf8 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -4381,7 +4381,6 @@ int ksz_switch_register(struct ksz_device *dev)
 	}
 
 	mutex_init(&dev->dev_mutex);
-	mutex_init(&dev->regmap_mutex);
 	mutex_init(&dev->alu_mutex);
 	mutex_init(&dev->vlan_mutex);
 
diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
index 5f0a628b9849..b9d4e0e9460d 100644
--- a/drivers/net/dsa/microchip/ksz_common.h
+++ b/drivers/net/dsa/microchip/ksz_common.h
@@ -152,7 +152,6 @@ struct ksz_device {
 	const struct ksz_chip_data *info;
 
 	struct mutex dev_mutex;		/* device access */
-	struct mutex regmap_mutex;	/* regmap access */
 	struct mutex alu_mutex;		/* ALU access */
 	struct mutex vlan_mutex;	/* vlan access */
 	const struct ksz_dev_ops *dev_ops;
@@ -600,18 +599,6 @@ static inline int ksz_prmw32(struct ksz_device *dev, int port, int offset,
 			 mask, val);
 }
 
-static inline void ksz_regmap_lock(void *__mtx)
-{
-	struct mutex *mtx = __mtx;
-	mutex_lock(mtx);
-}
-
-static inline void ksz_regmap_unlock(void *__mtx)
-{
-	struct mutex *mtx = __mtx;
-	mutex_unlock(mtx);
-}
-
 static inline bool ksz_is_ksz87xx(struct ksz_device *dev)
 {
 	return dev->chip_id == KSZ8795_CHIP_ID ||
@@ -781,8 +768,6 @@ static inline bool is_lan937x_tx_phy(struct ksz_device *dev, int port)
 		.write_flag_mask =					\
 			KSZ_SPI_OP_FLAG_MASK(KSZ_SPI_OP_WR, swp,	\
 					     regbits, regpad),		\
-		.lock = ksz_regmap_lock,				\
-		.unlock = ksz_regmap_unlock,				\
 		.reg_format_endian = REGMAP_ENDIAN_BIG,			\
 		.val_format_endian = REGMAP_ENDIAN_BIG			\
 	}
diff --git a/drivers/net/dsa/microchip/ksz_spi.c b/drivers/net/dsa/microchip/ksz_spi.c
index 8e8d83213b04..06a9e648df0c 100644
--- a/drivers/net/dsa/microchip/ksz_spi.c
+++ b/drivers/net/dsa/microchip/ksz_spi.c
@@ -65,7 +65,6 @@ static int ksz_spi_probe(struct spi_device *spi)
 
 	for (i = 0; i < __KSZ_NUM_REGMAPS; i++) {
 		rc = regmap_config[i];
-		rc.lock_arg = &dev->regmap_mutex;
 		rc.wr_table = chip->wr_table;
 		rc.rd_table = chip->rd_table;
 		dev->regmap[i] = devm_regmap_init_spi(spi, &rc);

---
base-commit: 7c626ce4bae1ac14f60076d00eafe71af30450ba
change-id: 20240822-net-dsa-microchip-regmap-locking-9e79d9314e1f

Best regards,
-- 
Mark Brown <broonie@...nel.org>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ