netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 00/10] mlxsw: core_thermal: Small cleanups
@ 2024-07-30 13:58 Petr Machata
  2024-07-30 13:58 ` [PATCH net-next 01/10] mlxsw: core_thermal: Call thermal_zone_device_unregister() unconditionally Petr Machata
                   ` (11 more replies)
  0 siblings, 12 replies; 14+ messages in thread
From: Petr Machata @ 2024-07-30 13:58 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	netdev
  Cc: Vadim Pasternak, Ido Schimmel, Petr Machata, mlxsw

Ido Schimmel says:

Clean up various issues which I noticed while addressing feedback on a
different patchset.

Ido Schimmel (10):
  mlxsw: core_thermal: Call thermal_zone_device_unregister()
    unconditionally
  mlxsw: core_thermal: Remove unnecessary check
  mlxsw: core_thermal: Remove another unnecessary check
  mlxsw: core_thermal: Fold two loops into one
  mlxsw: core_thermal: Remove unused arguments
  mlxsw: core_thermal: Make mlxsw_thermal_module_{init, fini} symmetric
  mlxsw: core_thermal: Simplify rollback
  mlxsw: core_thermal: Remove unnecessary checks
  mlxsw: core_thermal: Remove unnecessary assignments
  mlxsw: core_thermal: Fix -Wformat-truncation warning

 .../ethernet/mellanox/mlxsw/core_thermal.c    | 43 ++++++-------------
 1 file changed, 12 insertions(+), 31 deletions(-)

-- 
2.45.0


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH net-next 01/10] mlxsw: core_thermal: Call thermal_zone_device_unregister() unconditionally
  2024-07-30 13:58 [PATCH net-next 00/10] mlxsw: core_thermal: Small cleanups Petr Machata
@ 2024-07-30 13:58 ` Petr Machata
  2024-07-30 13:58 ` [PATCH net-next 02/10] mlxsw: core_thermal: Remove unnecessary check Petr Machata
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Petr Machata @ 2024-07-30 13:58 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	netdev
  Cc: Vadim Pasternak, Ido Schimmel, Petr Machata, mlxsw

From: Ido Schimmel <idosch@nvidia.com>

The function returns immediately if the thermal zone pointer is NULL so
there is no need to check it before calling the function.

Remove the check.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Vadim Pasternak <vadimp@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
index d61478c0c632..0b38bab4eaa8 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
@@ -821,10 +821,7 @@ int mlxsw_thermal_init(struct mlxsw_core *core,
 err_thermal_gearboxes_init:
 	mlxsw_thermal_modules_fini(thermal, &thermal->line_cards[0]);
 err_thermal_modules_init:
-	if (thermal->tzdev) {
-		thermal_zone_device_unregister(thermal->tzdev);
-		thermal->tzdev = NULL;
-	}
+	thermal_zone_device_unregister(thermal->tzdev);
 err_thermal_zone_device_register:
 err_thermal_cooling_device_register:
 	for (i = 0; i < MLXSW_MFCR_PWMS_MAX; i++)
@@ -845,10 +842,7 @@ void mlxsw_thermal_fini(struct mlxsw_thermal *thermal)
 					     thermal);
 	mlxsw_thermal_gearboxes_fini(thermal, &thermal->line_cards[0]);
 	mlxsw_thermal_modules_fini(thermal, &thermal->line_cards[0]);
-	if (thermal->tzdev) {
-		thermal_zone_device_unregister(thermal->tzdev);
-		thermal->tzdev = NULL;
-	}
+	thermal_zone_device_unregister(thermal->tzdev);
 
 	for (i = 0; i < MLXSW_MFCR_PWMS_MAX; i++)
 		thermal_cooling_device_unregister(thermal->cdevs[i].cdev);
-- 
2.45.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH net-next 02/10] mlxsw: core_thermal: Remove unnecessary check
  2024-07-30 13:58 [PATCH net-next 00/10] mlxsw: core_thermal: Small cleanups Petr Machata
  2024-07-30 13:58 ` [PATCH net-next 01/10] mlxsw: core_thermal: Call thermal_zone_device_unregister() unconditionally Petr Machata
@ 2024-07-30 13:58 ` Petr Machata
  2024-07-30 13:58 ` [PATCH net-next 03/10] mlxsw: core_thermal: Remove another " Petr Machata
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Petr Machata @ 2024-07-30 13:58 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	netdev
  Cc: Vadim Pasternak, Ido Schimmel, Petr Machata, mlxsw

From: Ido Schimmel <idosch@nvidia.com>

mlxsw_thermal_modules_init() allocates an array of modules and then
calls mlxsw_thermal_module_init() to initialize each entry in the array.
It is therefore impossible for mlxsw_thermal_module_init() to encounter
an entry that is already initialized and has its 'parent' pointer set.

Remove the unnecessary check.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Vadim Pasternak <vadimp@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
index 0b38bab4eaa8..394e4fd633ef 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
@@ -453,9 +453,6 @@ mlxsw_thermal_module_init(struct device *dev, struct mlxsw_core *core,
 	struct mlxsw_thermal_module *module_tz;
 
 	module_tz = &area->tz_module_arr[module];
-	/* Skip if parent is already set (case of port split). */
-	if (module_tz->parent)
-		return;
 	module_tz->module = module;
 	module_tz->slot_index = area->slot_index;
 	module_tz->parent = thermal;
-- 
2.45.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH net-next 03/10] mlxsw: core_thermal: Remove another unnecessary check
  2024-07-30 13:58 [PATCH net-next 00/10] mlxsw: core_thermal: Small cleanups Petr Machata
  2024-07-30 13:58 ` [PATCH net-next 01/10] mlxsw: core_thermal: Call thermal_zone_device_unregister() unconditionally Petr Machata
  2024-07-30 13:58 ` [PATCH net-next 02/10] mlxsw: core_thermal: Remove unnecessary check Petr Machata
@ 2024-07-30 13:58 ` Petr Machata
  2024-07-30 13:58 ` [PATCH net-next 04/10] mlxsw: core_thermal: Fold two loops into one Petr Machata
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Petr Machata @ 2024-07-30 13:58 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	netdev
  Cc: Vadim Pasternak, Ido Schimmel, Petr Machata, mlxsw

From: Ido Schimmel <idosch@nvidia.com>

mlxsw_thermal_modules_init() allocates an array of modules and then
initializes each entry by calling mlxsw_thermal_module_init() which
among other things initializes the 'parent' pointer of the entry.

mlxsw_thermal_modules_init() then traverses over the array again, but
skips over entries that do not have their 'parent' pointer set which is
impossible given the above.

Therefore, remove the unnecessary check.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Vadim Pasternak <vadimp@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
index 394e4fd633ef..afd8fe85a94d 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
@@ -505,8 +505,6 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core,
 
 	for (i = 0; i < area->tz_module_num; i++) {
 		module_tz = &area->tz_module_arr[i];
-		if (!module_tz->parent)
-			continue;
 		err = mlxsw_thermal_module_tz_init(module_tz);
 		if (err)
 			goto err_thermal_module_tz_init;
-- 
2.45.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH net-next 04/10] mlxsw: core_thermal: Fold two loops into one
  2024-07-30 13:58 [PATCH net-next 00/10] mlxsw: core_thermal: Small cleanups Petr Machata
                   ` (2 preceding siblings ...)
  2024-07-30 13:58 ` [PATCH net-next 03/10] mlxsw: core_thermal: Remove another " Petr Machata
@ 2024-07-30 13:58 ` Petr Machata
  2024-07-30 13:58 ` [PATCH net-next 05/10] mlxsw: core_thermal: Remove unused arguments Petr Machata
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Petr Machata @ 2024-07-30 13:58 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	netdev
  Cc: Vadim Pasternak, Ido Schimmel, Petr Machata, mlxsw

From: Ido Schimmel <idosch@nvidia.com>

There is no need to traverse the same array twice. Do it once by folding
both loops into one.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Vadim Pasternak <vadimp@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
index afd8fe85a94d..b2a4eea859d1 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
@@ -500,10 +500,8 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core,
 	if (!area->tz_module_arr)
 		return -ENOMEM;
 
-	for (i = 0; i < area->tz_module_num; i++)
-		mlxsw_thermal_module_init(dev, core, thermal, area, i);
-
 	for (i = 0; i < area->tz_module_num; i++) {
+		mlxsw_thermal_module_init(dev, core, thermal, area, i);
 		module_tz = &area->tz_module_arr[i];
 		err = mlxsw_thermal_module_tz_init(module_tz);
 		if (err)
-- 
2.45.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH net-next 05/10] mlxsw: core_thermal: Remove unused arguments
  2024-07-30 13:58 [PATCH net-next 00/10] mlxsw: core_thermal: Small cleanups Petr Machata
                   ` (3 preceding siblings ...)
  2024-07-30 13:58 ` [PATCH net-next 04/10] mlxsw: core_thermal: Fold two loops into one Petr Machata
@ 2024-07-30 13:58 ` Petr Machata
  2024-07-30 13:58 ` [PATCH net-next 06/10] mlxsw: core_thermal: Make mlxsw_thermal_module_{init, fini} symmetric Petr Machata
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Petr Machata @ 2024-07-30 13:58 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	netdev
  Cc: Vadim Pasternak, Ido Schimmel, Petr Machata, mlxsw

From: Ido Schimmel <idosch@nvidia.com>

'dev' and 'core' arguments are not used by mlxsw_thermal_module_init().
Remove them.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Vadim Pasternak <vadimp@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
index b2a4eea859d1..95821e91da18 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
@@ -446,8 +446,7 @@ static void mlxsw_thermal_module_tz_fini(struct thermal_zone_device *tzdev)
 }
 
 static void
-mlxsw_thermal_module_init(struct device *dev, struct mlxsw_core *core,
-			  struct mlxsw_thermal *thermal,
+mlxsw_thermal_module_init(struct mlxsw_thermal *thermal,
 			  struct mlxsw_thermal_area *area, u8 module)
 {
 	struct mlxsw_thermal_module *module_tz;
@@ -501,7 +500,7 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core,
 		return -ENOMEM;
 
 	for (i = 0; i < area->tz_module_num; i++) {
-		mlxsw_thermal_module_init(dev, core, thermal, area, i);
+		mlxsw_thermal_module_init(thermal, area, i);
 		module_tz = &area->tz_module_arr[i];
 		err = mlxsw_thermal_module_tz_init(module_tz);
 		if (err)
-- 
2.45.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH net-next 06/10] mlxsw: core_thermal: Make mlxsw_thermal_module_{init, fini} symmetric
  2024-07-30 13:58 [PATCH net-next 00/10] mlxsw: core_thermal: Small cleanups Petr Machata
                   ` (4 preceding siblings ...)
  2024-07-30 13:58 ` [PATCH net-next 05/10] mlxsw: core_thermal: Remove unused arguments Petr Machata
@ 2024-07-30 13:58 ` Petr Machata
  2024-07-30 13:58 ` [PATCH net-next 07/10] mlxsw: core_thermal: Simplify rollback Petr Machata
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Petr Machata @ 2024-07-30 13:58 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	netdev
  Cc: Vadim Pasternak, Ido Schimmel, Petr Machata, mlxsw

From: Ido Schimmel <idosch@nvidia.com>

mlxsw_thermal_module_fini() de-initializes the module's thermal zone,
but mlxsw_thermal_module_init() does not initialize it. Make both
functions symmetric by moving the initialization of the module's thermal
zone to mlxsw_thermal_module_init().

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Vadim Pasternak <vadimp@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
index 95821e91da18..36b883a7ee60 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
@@ -445,7 +445,7 @@ static void mlxsw_thermal_module_tz_fini(struct thermal_zone_device *tzdev)
 	thermal_zone_device_unregister(tzdev);
 }
 
-static void
+static int
 mlxsw_thermal_module_init(struct mlxsw_thermal *thermal,
 			  struct mlxsw_thermal_area *area, u8 module)
 {
@@ -461,6 +461,8 @@ mlxsw_thermal_module_init(struct mlxsw_thermal *thermal,
 	       sizeof(thermal->trips));
 	memcpy(module_tz->cooling_states, default_cooling_states,
 	       sizeof(thermal->cooling_states));
+
+	return mlxsw_thermal_module_tz_init(module_tz);
 }
 
 static void mlxsw_thermal_module_fini(struct mlxsw_thermal_module *module_tz)
@@ -477,7 +479,6 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core,
 			   struct mlxsw_thermal *thermal,
 			   struct mlxsw_thermal_area *area)
 {
-	struct mlxsw_thermal_module *module_tz;
 	char mgpir_pl[MLXSW_REG_MGPIR_LEN];
 	int i, err;
 
@@ -500,16 +501,14 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core,
 		return -ENOMEM;
 
 	for (i = 0; i < area->tz_module_num; i++) {
-		mlxsw_thermal_module_init(thermal, area, i);
-		module_tz = &area->tz_module_arr[i];
-		err = mlxsw_thermal_module_tz_init(module_tz);
+		err = mlxsw_thermal_module_init(thermal, area, i);
 		if (err)
-			goto err_thermal_module_tz_init;
+			goto err_thermal_module_init;
 	}
 
 	return 0;
 
-err_thermal_module_tz_init:
+err_thermal_module_init:
 	for (i = area->tz_module_num - 1; i >= 0; i--)
 		mlxsw_thermal_module_fini(&area->tz_module_arr[i]);
 	kfree(area->tz_module_arr);
-- 
2.45.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH net-next 07/10] mlxsw: core_thermal: Simplify rollback
  2024-07-30 13:58 [PATCH net-next 00/10] mlxsw: core_thermal: Small cleanups Petr Machata
                   ` (5 preceding siblings ...)
  2024-07-30 13:58 ` [PATCH net-next 06/10] mlxsw: core_thermal: Make mlxsw_thermal_module_{init, fini} symmetric Petr Machata
@ 2024-07-30 13:58 ` Petr Machata
  2024-07-30 13:58 ` [PATCH net-next 08/10] mlxsw: core_thermal: Remove unnecessary checks Petr Machata
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Petr Machata @ 2024-07-30 13:58 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	netdev
  Cc: Vadim Pasternak, Ido Schimmel, Petr Machata, mlxsw

From: Ido Schimmel <idosch@nvidia.com>

During rollback, instead of calling mlxsw_thermal_module_fini() for all
the modules, only call it for modules that were successfully
initialized. This is not a bug fix since mlxsw_thermal_module_fini()
first checks that the module was initialized.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Vadim Pasternak <vadimp@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
index 36b883a7ee60..e9bf11a38ae9 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
@@ -509,7 +509,7 @@ mlxsw_thermal_modules_init(struct device *dev, struct mlxsw_core *core,
 	return 0;
 
 err_thermal_module_init:
-	for (i = area->tz_module_num - 1; i >= 0; i--)
+	for (i--; i >= 0; i--)
 		mlxsw_thermal_module_fini(&area->tz_module_arr[i]);
 	kfree(area->tz_module_arr);
 	return err;
-- 
2.45.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH net-next 08/10] mlxsw: core_thermal: Remove unnecessary checks
  2024-07-30 13:58 [PATCH net-next 00/10] mlxsw: core_thermal: Small cleanups Petr Machata
                   ` (6 preceding siblings ...)
  2024-07-30 13:58 ` [PATCH net-next 07/10] mlxsw: core_thermal: Simplify rollback Petr Machata
@ 2024-07-30 13:58 ` Petr Machata
  2024-07-30 13:58 ` [PATCH net-next 09/10] mlxsw: core_thermal: Remove unnecessary assignments Petr Machata
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Petr Machata @ 2024-07-30 13:58 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	netdev
  Cc: Vadim Pasternak, Ido Schimmel, Petr Machata, mlxsw

From: Ido Schimmel <idosch@nvidia.com>

mlxsw_thermal_module_fini() cannot be invoked with a thermal module
which is NULL or which is not associated with a thermal zone, so remove
these checks.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Vadim Pasternak <vadimp@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
index e9bf11a38ae9..cfbfabec816e 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
@@ -467,11 +467,9 @@ mlxsw_thermal_module_init(struct mlxsw_thermal *thermal,
 
 static void mlxsw_thermal_module_fini(struct mlxsw_thermal_module *module_tz)
 {
-	if (module_tz && module_tz->tzdev) {
-		mlxsw_thermal_module_tz_fini(module_tz->tzdev);
-		module_tz->tzdev = NULL;
-		module_tz->parent = NULL;
-	}
+	mlxsw_thermal_module_tz_fini(module_tz->tzdev);
+	module_tz->tzdev = NULL;
+	module_tz->parent = NULL;
 }
 
 static int
-- 
2.45.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH net-next 09/10] mlxsw: core_thermal: Remove unnecessary assignments
  2024-07-30 13:58 [PATCH net-next 00/10] mlxsw: core_thermal: Small cleanups Petr Machata
                   ` (7 preceding siblings ...)
  2024-07-30 13:58 ` [PATCH net-next 08/10] mlxsw: core_thermal: Remove unnecessary checks Petr Machata
@ 2024-07-30 13:58 ` Petr Machata
  2024-07-30 13:58 ` [PATCH net-next 10/10] mlxsw: core_thermal: Fix -Wformat-truncation warning Petr Machata
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Petr Machata @ 2024-07-30 13:58 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	netdev
  Cc: Vadim Pasternak, Ido Schimmel, Petr Machata, mlxsw

From: Ido Schimmel <idosch@nvidia.com>

Setting both pointers to NULL is unnecessary since the code never checks
whether these pointers are NULL or not. Remove the assignments.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Vadim Pasternak <vadimp@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
index cfbfabec816e..269c4986ea24 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
@@ -468,8 +468,6 @@ mlxsw_thermal_module_init(struct mlxsw_thermal *thermal,
 static void mlxsw_thermal_module_fini(struct mlxsw_thermal_module *module_tz)
 {
 	mlxsw_thermal_module_tz_fini(module_tz->tzdev);
-	module_tz->tzdev = NULL;
-	module_tz->parent = NULL;
 }
 
 static int
-- 
2.45.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH net-next 10/10] mlxsw: core_thermal: Fix -Wformat-truncation warning
  2024-07-30 13:58 [PATCH net-next 00/10] mlxsw: core_thermal: Small cleanups Petr Machata
                   ` (8 preceding siblings ...)
  2024-07-30 13:58 ` [PATCH net-next 09/10] mlxsw: core_thermal: Remove unnecessary assignments Petr Machata
@ 2024-07-30 13:58 ` Petr Machata
  2024-08-01  1:40   ` Jakub Kicinski
  2024-07-31 13:13 ` [PATCH net-next 00/10] mlxsw: core_thermal: Small cleanups Wojciech Drewek
  2024-08-01  1:40 ` patchwork-bot+netdevbpf
  11 siblings, 1 reply; 14+ messages in thread
From: Petr Machata @ 2024-07-30 13:58 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	netdev
  Cc: Vadim Pasternak, Ido Schimmel, Petr Machata, mlxsw

From: Ido Schimmel <idosch@nvidia.com>

The name of a thermal zone device cannot be longer than 19 characters
('THERMAL_NAME_LENGTH - 1'). The format string 'mlxsw-lc%d-module%d' can
exceed this limitation if the maximum number of line cards cannot be
represented using a single digit and the maximum number of transceiver
modules cannot be represented using two digits.

This is not the case with current systems nor future ones. Therefore,
increase the size of the result buffer beyond 'THERMAL_NAME_LENGTH' and
suppress the following build warning [1].

If this limitation is ever exceeded, we will know about it since the
thermal core validates the thermal device's name during registration.

[1]
drivers/net/ethernet/mellanox/mlxsw/core_thermal.c: In function ‘mlxsw_thermal_modules_init.part.0’:
drivers/net/ethernet/mellanox/mlxsw/core_thermal.c:418:70: error: ‘%d’ directive output may be truncated writing between 1 and 3 bytes into a region of size between 2 and 4 [-Werror=format-truncation=]
  418 |                 snprintf(tz_name, sizeof(tz_name), "mlxsw-lc%d-module%d",
      |                                                                      ^~
In function ‘mlxsw_thermal_module_tz_init’,
    inlined from ‘mlxsw_thermal_module_init’ at drivers/net/ethernet/mellanox/mlxsw/core_thermal.c:465:9,
    inlined from ‘mlxsw_thermal_modules_init.part.0’ at drivers/net/ethernet/mellanox/mlxsw/core_thermal.c:500:9:
drivers/net/ethernet/mellanox/mlxsw/core_thermal.c:418:52: note: directive argument in the range [1, 256]
  418 |                 snprintf(tz_name, sizeof(tz_name), "mlxsw-lc%d-module%d",
      |                                                    ^~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/mellanox/mlxsw/core_thermal.c:418:17: note: ‘snprintf’ output between 18 and 22 bytes into a destination of size 20
  418 |                 snprintf(tz_name, sizeof(tz_name), "mlxsw-lc%d-module%d",
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  419 |                          module_tz->slot_index, module_tz->module + 1);
      |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Vadim Pasternak <vadimp@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
index 269c4986ea24..303d2ce4dc1e 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
@@ -411,7 +411,7 @@ static const struct thermal_cooling_device_ops mlxsw_cooling_ops = {
 static int
 mlxsw_thermal_module_tz_init(struct mlxsw_thermal_module *module_tz)
 {
-	char tz_name[THERMAL_NAME_LENGTH];
+	char tz_name[40];
 	int err;
 
 	if (module_tz->slot_index)
-- 
2.45.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH net-next 00/10] mlxsw: core_thermal: Small cleanups
  2024-07-30 13:58 [PATCH net-next 00/10] mlxsw: core_thermal: Small cleanups Petr Machata
                   ` (9 preceding siblings ...)
  2024-07-30 13:58 ` [PATCH net-next 10/10] mlxsw: core_thermal: Fix -Wformat-truncation warning Petr Machata
@ 2024-07-31 13:13 ` Wojciech Drewek
  2024-08-01  1:40 ` patchwork-bot+netdevbpf
  11 siblings, 0 replies; 14+ messages in thread
From: Wojciech Drewek @ 2024-07-31 13:13 UTC (permalink / raw)
  To: Petr Machata, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, netdev
  Cc: Vadim Pasternak, Ido Schimmel, mlxsw



On 30.07.2024 15:58, Petr Machata wrote:
> Ido Schimmel says:
> 
> Clean up various issues which I noticed while addressing feedback on a
> different patchset.

For the whole series:
Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>

> 
> Ido Schimmel (10):
>   mlxsw: core_thermal: Call thermal_zone_device_unregister()
>     unconditionally
>   mlxsw: core_thermal: Remove unnecessary check
>   mlxsw: core_thermal: Remove another unnecessary check
>   mlxsw: core_thermal: Fold two loops into one
>   mlxsw: core_thermal: Remove unused arguments
>   mlxsw: core_thermal: Make mlxsw_thermal_module_{init, fini} symmetric
>   mlxsw: core_thermal: Simplify rollback
>   mlxsw: core_thermal: Remove unnecessary checks
>   mlxsw: core_thermal: Remove unnecessary assignments
>   mlxsw: core_thermal: Fix -Wformat-truncation warning
> 
>  .../ethernet/mellanox/mlxsw/core_thermal.c    | 43 ++++++-------------
>  1 file changed, 12 insertions(+), 31 deletions(-)
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH net-next 10/10] mlxsw: core_thermal: Fix -Wformat-truncation warning
  2024-07-30 13:58 ` [PATCH net-next 10/10] mlxsw: core_thermal: Fix -Wformat-truncation warning Petr Machata
@ 2024-08-01  1:40   ` Jakub Kicinski
  0 siblings, 0 replies; 14+ messages in thread
From: Jakub Kicinski @ 2024-08-01  1:40 UTC (permalink / raw)
  To: Petr Machata
  Cc: David S. Miller, Eric Dumazet, Paolo Abeni, netdev,
	Vadim Pasternak, Ido Schimmel, mlxsw

On Tue, 30 Jul 2024 15:58:21 +0200 Petr Machata wrote:
> From: Ido Schimmel <idosch@nvidia.com>
> 
> The name of a thermal zone device cannot be longer than 19 characters
> ('THERMAL_NAME_LENGTH - 1'). The format string 'mlxsw-lc%d-module%d' can
> exceed this limitation if the maximum number of line cards cannot be
> represented using a single digit and the maximum number of transceiver
> modules cannot be represented using two digits.

The ordering could have been better since this comes from patch 6 
in the same series :(

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH net-next 00/10] mlxsw: core_thermal: Small cleanups
  2024-07-30 13:58 [PATCH net-next 00/10] mlxsw: core_thermal: Small cleanups Petr Machata
                   ` (10 preceding siblings ...)
  2024-07-31 13:13 ` [PATCH net-next 00/10] mlxsw: core_thermal: Small cleanups Wojciech Drewek
@ 2024-08-01  1:40 ` patchwork-bot+netdevbpf
  11 siblings, 0 replies; 14+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-08-01  1:40 UTC (permalink / raw)
  To: Petr Machata; +Cc: davem, edumazet, kuba, pabeni, netdev, vadimp, idosch, mlxsw

Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 30 Jul 2024 15:58:11 +0200 you wrote:
> Ido Schimmel says:
> 
> Clean up various issues which I noticed while addressing feedback on a
> different patchset.
> 
> Ido Schimmel (10):
>   mlxsw: core_thermal: Call thermal_zone_device_unregister()
>     unconditionally
>   mlxsw: core_thermal: Remove unnecessary check
>   mlxsw: core_thermal: Remove another unnecessary check
>   mlxsw: core_thermal: Fold two loops into one
>   mlxsw: core_thermal: Remove unused arguments
>   mlxsw: core_thermal: Make mlxsw_thermal_module_{init, fini} symmetric
>   mlxsw: core_thermal: Simplify rollback
>   mlxsw: core_thermal: Remove unnecessary checks
>   mlxsw: core_thermal: Remove unnecessary assignments
>   mlxsw: core_thermal: Fix -Wformat-truncation warning
> 
> [...]

Here is the summary with links:
  - [net-next,01/10] mlxsw: core_thermal: Call thermal_zone_device_unregister() unconditionally
    https://git.kernel.org/netdev/net-next/c/a1bb54b1a066
  - [net-next,02/10] mlxsw: core_thermal: Remove unnecessary check
    https://git.kernel.org/netdev/net-next/c/4be011d76408
  - [net-next,03/10] mlxsw: core_thermal: Remove another unnecessary check
    https://git.kernel.org/netdev/net-next/c/2a1c9dcb52dd
  - [net-next,04/10] mlxsw: core_thermal: Fold two loops into one
    https://git.kernel.org/netdev/net-next/c/d81d71434036
  - [net-next,05/10] mlxsw: core_thermal: Remove unused arguments
    https://git.kernel.org/netdev/net-next/c/73c18f9998fd
  - [net-next,06/10] mlxsw: core_thermal: Make mlxsw_thermal_module_{init, fini} symmetric
    https://git.kernel.org/netdev/net-next/c/fb76ea1d4b12
  - [net-next,07/10] mlxsw: core_thermal: Simplify rollback
    https://git.kernel.org/netdev/net-next/c/e25f3040a619
  - [net-next,08/10] mlxsw: core_thermal: Remove unnecessary checks
    https://git.kernel.org/netdev/net-next/c/e7e3a450e552
  - [net-next,09/10] mlxsw: core_thermal: Remove unnecessary assignments
    https://git.kernel.org/netdev/net-next/c/ec672931d150
  - [net-next,10/10] mlxsw: core_thermal: Fix -Wformat-truncation warning
    https://git.kernel.org/netdev/net-next/c/b0d21321140c

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2024-08-01  1:40 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-30 13:58 [PATCH net-next 00/10] mlxsw: core_thermal: Small cleanups Petr Machata
2024-07-30 13:58 ` [PATCH net-next 01/10] mlxsw: core_thermal: Call thermal_zone_device_unregister() unconditionally Petr Machata
2024-07-30 13:58 ` [PATCH net-next 02/10] mlxsw: core_thermal: Remove unnecessary check Petr Machata
2024-07-30 13:58 ` [PATCH net-next 03/10] mlxsw: core_thermal: Remove another " Petr Machata
2024-07-30 13:58 ` [PATCH net-next 04/10] mlxsw: core_thermal: Fold two loops into one Petr Machata
2024-07-30 13:58 ` [PATCH net-next 05/10] mlxsw: core_thermal: Remove unused arguments Petr Machata
2024-07-30 13:58 ` [PATCH net-next 06/10] mlxsw: core_thermal: Make mlxsw_thermal_module_{init, fini} symmetric Petr Machata
2024-07-30 13:58 ` [PATCH net-next 07/10] mlxsw: core_thermal: Simplify rollback Petr Machata
2024-07-30 13:58 ` [PATCH net-next 08/10] mlxsw: core_thermal: Remove unnecessary checks Petr Machata
2024-07-30 13:58 ` [PATCH net-next 09/10] mlxsw: core_thermal: Remove unnecessary assignments Petr Machata
2024-07-30 13:58 ` [PATCH net-next 10/10] mlxsw: core_thermal: Fix -Wformat-truncation warning Petr Machata
2024-08-01  1:40   ` Jakub Kicinski
2024-07-31 13:13 ` [PATCH net-next 00/10] mlxsw: core_thermal: Small cleanups Wojciech Drewek
2024-08-01  1:40 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).