All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net 0/2] mlxsw: Two small fixes
@ 2021-11-23  7:52 Ido Schimmel
  2021-11-23  7:52 ` [PATCH net 1/2] mlxsw: spectrum: Allow driver to load with old firmware versions Ido Schimmel
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ido Schimmel @ 2021-11-23  7:52 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, jiri, mlxsw, Ido Schimmel

From: Ido Schimmel <idosch@nvidia.com>

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(-)

-- 
2.31.1


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

* [PATCH net 1/2] mlxsw: spectrum: Allow driver to load with old firmware versions
  2021-11-23  7:52 [PATCH net 0/2] mlxsw: Two small fixes Ido Schimmel
@ 2021-11-23  7:52 ` Ido Schimmel
  2021-11-23  7:52 ` [PATCH net 2/2] mlxsw: spectrum: Protect driver from buggy firmware Ido Schimmel
  2021-11-23 11:50 ` [PATCH net 0/2] mlxsw: Two small fixes patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Ido Schimmel @ 2021-11-23  7:52 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, jiri, mlxsw, Danielle Ratson, Ido Schimmel

From: Danielle Ratson <danieller@nvidia.com>

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")
Signed-off-by: Danielle Ratson <danieller@nvidia.com>
Reported-by: Vadim Pasternak <vadimp@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index 4ce07f9905f6..41da3895d97f 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -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);
-- 
2.31.1


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

* [PATCH net 2/2] mlxsw: spectrum: Protect driver from buggy firmware
  2021-11-23  7:52 [PATCH net 0/2] mlxsw: Two small fixes Ido Schimmel
  2021-11-23  7:52 ` [PATCH net 1/2] mlxsw: spectrum: Allow driver to load with old firmware versions Ido Schimmel
@ 2021-11-23  7:52 ` Ido Schimmel
  2021-11-23 11:50 ` [PATCH net 0/2] mlxsw: Two small fixes patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Ido Schimmel @ 2021-11-23  7:52 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, jiri, mlxsw, Amit Cohen, Ido Schimmel

From: Amit Cohen <amcohen@nvidia.com>

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")
Signed-off-by: Amit Cohen <amcohen@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index 41da3895d97f..24157bb59881 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -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)
-- 
2.31.1


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

* Re: [PATCH net 0/2] mlxsw: Two small fixes
  2021-11-23  7:52 [PATCH net 0/2] mlxsw: Two small fixes Ido Schimmel
  2021-11-23  7:52 ` [PATCH net 1/2] mlxsw: spectrum: Allow driver to load with old firmware versions Ido Schimmel
  2021-11-23  7:52 ` [PATCH net 2/2] mlxsw: spectrum: Protect driver from buggy firmware Ido Schimmel
@ 2021-11-23 11:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-11-23 11:50 UTC (permalink / raw)
  To: Ido Schimmel; +Cc: netdev, davem, kuba, jiri, mlxsw, idosch

Hello:

This series was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:

On Tue, 23 Nov 2021 09:52:54 +0200 you wrote:
> From: Ido Schimmel <idosch@nvidia.com>
> 
> 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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2021-11-23 11:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-23  7:52 [PATCH net 0/2] mlxsw: Two small fixes Ido Schimmel
2021-11-23  7:52 ` [PATCH net 1/2] mlxsw: spectrum: Allow driver to load with old firmware versions Ido Schimmel
2021-11-23  7:52 ` [PATCH net 2/2] mlxsw: spectrum: Protect driver from buggy firmware Ido Schimmel
2021-11-23 11:50 ` [PATCH net 0/2] mlxsw: Two small fixes patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.