Skip to contentSkip to conversation

mlxsw: Two small fixes

PATCH Applied Ido Schimmel 2 participants 4 messages Nov 23, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover mlxsw: Two small fixes

From: Ido Schimmel <[email protected]>

Patch #1 fixes a recent regression that prevents the driver from loading with old firmware versions.

Patch #2 protects the driver from a NULL pointer dereference when working on top of a buggy firmware. This was never observed in an actual system, only on top of an emulator during development.

Amit Cohen (1):
mlxsw: spectrum: Protect driver from buggy firmware

Danielle Ratson (1):
mlxsw: spectrum: Allow driver to load with old firmware versions

 drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
Signature · 1 line
2.31.1
#1 lore raw

PATCH 1/2 mlxsw: spectrum: Allow driver to load with old firmware versions

From: Danielle Ratson <[email protected]>

The driver fails to load with old firmware versions that cannot report the maximum number of RIF MAC profiles [1].

Fix this by defaulting to a maximum of a single profile in such situations, as multiple profiles are not supported by old firmware versions.

[1]
mlxsw_spectrum 0000:03:00.0: cannot register bus device
mlxsw_spectrum: probe of 0000:03:00.0 failed with error -5

Fixes 1c375ffb2efab ("mlxsw: spectrum_router: Expose RIF MAC profiles to devlink resource")
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +4 -4
index 4ce07f9905f6..41da3895d97f 100644
@@ -3290,10 +3290,10 @@ mlxsw_sp_resources_rif_mac_profile_register(struct mlxsw_core *mlxsw_core)
 	u8 max_rif_mac_profiles;
 
 	if (!MLXSW_CORE_RES_VALID(mlxsw_core, MAX_RIF_MAC_PROFILES))
-		return -EIO;
-
-	max_rif_mac_profiles = MLXSW_CORE_RES_GET(mlxsw_core,
-						  MAX_RIF_MAC_PROFILES);
+		max_rif_mac_profiles = 1;
+	else
+		max_rif_mac_profiles = MLXSW_CORE_RES_GET(mlxsw_core,
+							  MAX_RIF_MAC_PROFILES);
 	devlink_resource_size_params_init(&size_params, max_rif_mac_profiles,
 					  max_rif_mac_profiles, 1,
 					  DEVLINK_RESOURCE_UNIT_ENTRY);
Signature · 1 line
2.31.1
#2 lore raw

PATCH 2/2 mlxsw: spectrum: Protect driver from buggy firmware

In reply to Ido Schimmel

From: Amit Cohen <[email protected]>

When processing port up/down events generated by the device's firmware, the driver protects itself from events reported for non-existent local ports, but not the CPU port (local port 0), which exists, but lacks a netdev.

This can result in a NULL pointer dereference when calling netif_carrier_{on,off}().

Fix this by bailing early when processing an event reported for the CPU port. Problem was only observed when running on top of a buggy emulator.

Fixes 28b1987ef506 ("mlxsw: spectrum: Register CPU port with devlink")
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +1 -1
index 41da3895d97f..24157bb59881 100644
@@ -2153,7 +2153,7 @@ static void mlxsw_sp_pude_event_func(const struct mlxsw_reg_info *reg,
 	max_ports = mlxsw_core_max_ports(mlxsw_sp->core);
 	local_port = mlxsw_reg_pude_local_port_get(pude_pl);
 
-	if (WARN_ON_ONCE(local_port >= max_ports))
+	if (WARN_ON_ONCE(!local_port || local_port >= max_ports))
 		return;
 	mlxsw_sp_port = mlxsw_sp->ports[local_port];
 	if (!mlxsw_sp_port)
Signature · 1 line
2.31.1
#3 lore raw
In reply to Ido Schimmel
This series was applied to netdev/net.git (master) by David S. Miller <[email protected]>:

Hello:

This series was applied to netdev/net.git (master) by David S. Miller <[email protected]>:

Quoted 10 lines · On Tue, 23 Nov 2021 09:52:54 +0200 you wrote:

From: Ido Schimmel <[email protected]>

Patch #1 fixes a recent regression that prevents the driver from loading with old firmware versions.

Patch #2 protects the driver from a NULL pointer dereference when working on top of a buggy firmware. This was never observed in an actual system, only on top of an emulator during development.

[...]

Here is the summary with links:
- [net,1/2] mlxsw: spectrum: Allow driver to load with old firmware versions

    https://git.kernel.org/netdev/net/c/ce4995bc6c8e
  - [net,2/2] mlxsw: spectrum: Protect driver from buggy firmware
    https://git.kernel.org/netdev/net/c/63b08b1f6834

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html