[PATCH v2 1/5] net: marvell: prestera: fix driver reload
From: Elad Nachman
Date: Wed Mar 20 2024 - 13:21:07 EST
From: Elad Nachman <enachman@xxxxxxxxxxx>
Driver rmmod after insmod would fail because API call to reset the switch
HW and restart the firmware CPU code loading procedure was missing in
driver removal code handler.
Firmware reset and reload is needed as the firmware termination will make
the firmware loader change its state machine to the firmware loading state,
and thus will be able to load new firmware, which is done at the beginning
of the probing of the prestera_pci module.
Without this reset, the firmware loader will stay in the wrong state,
causing the next firmware loading phase in the probe to fail.
Fix by adding API call to reset the switch HW and restart the firmware CPU
firmware code loading when handling the driver removal procedure.
Reported-by: Köry Maincent <kory.maincent@xxxxxxxxxxx>
Closes: https://lore.kernel.org/netdev/20240208101005.29e8c7f3@kmaincent-XPS-13-7390/T/
Fixes: 501ef3066c89 ("net: marvell: prestera: Add driver for Prestera family ASIC devices")
Tested-by: Kory Maincent <kory.maincent@xxxxxxxxxxx>
Signed-off-by: Elad Nachman <enachman@xxxxxxxxxxx>
---
drivers/net/ethernet/marvell/prestera/prestera_hw.c | 8 ++++++++
drivers/net/ethernet/marvell/prestera/prestera_hw.h | 1 +
drivers/net/ethernet/marvell/prestera/prestera_main.c | 3 ++-
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/marvell/prestera/prestera_hw.c b/drivers/net/ethernet/marvell/prestera/prestera_hw.c
index fc6f7d2746e8..08de8b498e0a 100644
--- a/drivers/net/ethernet/marvell/prestera/prestera_hw.c
+++ b/drivers/net/ethernet/marvell/prestera/prestera_hw.c
@@ -21,6 +21,7 @@
enum prestera_cmd_type_t {
PRESTERA_CMD_TYPE_SWITCH_INIT = 0x1,
PRESTERA_CMD_TYPE_SWITCH_ATTR_SET = 0x2,
+ PRESTERA_CMD_TYPE_SWITCH_RESET = 0x4,
PRESTERA_CMD_TYPE_PORT_ATTR_SET = 0x100,
PRESTERA_CMD_TYPE_PORT_ATTR_GET = 0x101,
@@ -1087,6 +1088,13 @@ void prestera_hw_switch_fini(struct prestera_switch *sw)
WARN_ON(!list_empty(&sw->event_handlers));
}
+int prestera_hw_switch_reset(struct prestera_switch *sw)
+{
+ struct prestera_msg_common_req req;
+
+ return prestera_cmd(sw, PRESTERA_CMD_TYPE_SWITCH_RESET, &req.cmd, sizeof(req));
+}
+
int prestera_hw_switch_ageing_set(struct prestera_switch *sw, u32 ageing_ms)
{
struct prestera_msg_switch_attr_req req = {
diff --git a/drivers/net/ethernet/marvell/prestera/prestera_hw.h b/drivers/net/ethernet/marvell/prestera/prestera_hw.h
index 0a929279e1ce..86217bea2ca0 100644
--- a/drivers/net/ethernet/marvell/prestera/prestera_hw.h
+++ b/drivers/net/ethernet/marvell/prestera/prestera_hw.h
@@ -150,6 +150,7 @@ struct prestera_neigh_info;
/* Switch API */
int prestera_hw_switch_init(struct prestera_switch *sw);
+int prestera_hw_switch_reset(struct prestera_switch *sw);
void prestera_hw_switch_fini(struct prestera_switch *sw);
int prestera_hw_switch_ageing_set(struct prestera_switch *sw, u32 ageing_ms);
int prestera_hw_switch_mac_set(struct prestera_switch *sw, const char *mac);
diff --git a/drivers/net/ethernet/marvell/prestera/prestera_main.c b/drivers/net/ethernet/marvell/prestera/prestera_main.c
index 4fb886c57cd7..bcaa8ea27b49 100644
--- a/drivers/net/ethernet/marvell/prestera/prestera_main.c
+++ b/drivers/net/ethernet/marvell/prestera/prestera_main.c
@@ -1444,7 +1444,7 @@ static int prestera_switch_init(struct prestera_switch *sw)
err_router_init:
prestera_netdev_event_handler_unregister(sw);
prestera_hw_switch_fini(sw);
-
+ prestera_hw_switch_reset(sw);
return err;
}
@@ -1463,6 +1463,7 @@ static void prestera_switch_fini(struct prestera_switch *sw)
prestera_router_fini(sw);
prestera_netdev_event_handler_unregister(sw);
prestera_hw_switch_fini(sw);
+ prestera_hw_switch_reset(sw);
of_node_put(sw->np);
}
--
2.25.1