net: marvell: prestera: add delayed wq and flush wq on deinit
authorYevhen Orlov <yevhen.orlov@plvision.eu>
Sat, 1 Oct 2022 09:34:12 +0000 (12:34 +0300)
committerJakub Kicinski <kuba@kernel.org>
Tue, 4 Oct 2022 00:14:52 +0000 (17:14 -0700)
Flushing workqueues ensures, that no more pending works, related to just
unregistered or deinitialized notifiers. After that we can free memory.

Delayed wq will be used for neighbours in next patches.

Co-developed-by: Taras Chornyi <tchornyi@marvell.com>
Signed-off-by: Taras Chornyi <tchornyi@marvell.com>
Co-developed-by: Oleksandr Mazur <oleksandr.mazur@plvision.eu>
Signed-off-by: Oleksandr Mazur <oleksandr.mazur@plvision.eu>
Signed-off-by: Yevhen Orlov <yevhen.orlov@plvision.eu>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/marvell/prestera/prestera.h
drivers/net/ethernet/marvell/prestera/prestera_main.c
drivers/net/ethernet/marvell/prestera/prestera_router.c

index 903e2e13e687a7fa95a89cade1fd5b186cd7db91..fe0d6001a6b607a7f41c828f99642701a6a50b2a 100644 (file)
@@ -367,6 +367,8 @@ int prestera_port_cfg_mac_write(struct prestera_port *port,
 struct prestera_port *prestera_port_dev_lower_find(struct net_device *dev);
 
 void prestera_queue_work(struct work_struct *work);
+void prestera_queue_delayed_work(struct delayed_work *work, unsigned long delay);
+void prestera_queue_drain(void);
 
 int prestera_port_learning_set(struct prestera_port *port, bool learn_enable);
 int prestera_port_uc_flood_set(struct prestera_port *port, bool flood);
index 639d3e940a885acf97e9eb5c798ba1c556969edd..24f9d60247453107f79f425e1918928d27a92568 100644 (file)
@@ -36,6 +36,17 @@ void prestera_queue_work(struct work_struct *work)
        queue_work(prestera_owq, work);
 }
 
+void prestera_queue_delayed_work(struct delayed_work *work, unsigned long delay)
+{
+       queue_delayed_work(prestera_wq, work, delay);
+}
+
+void prestera_queue_drain(void)
+{
+       drain_workqueue(prestera_wq);
+       drain_workqueue(prestera_owq);
+}
+
 int prestera_port_learning_set(struct prestera_port *port, bool learn)
 {
        return prestera_hw_port_learning_set(port, learn);
index b4fd8276bbce9ccd7b4049e2187d16a2b5ad8b88..9625c58708477820b0d8c42d783d8e10161a65dc 100644 (file)
@@ -639,6 +639,7 @@ void prestera_router_fini(struct prestera_switch *sw)
        unregister_fib_notifier(&init_net, &sw->router->fib_nb);
        unregister_inetaddr_notifier(&sw->router->inetaddr_nb);
        unregister_inetaddr_validator_notifier(&sw->router->inetaddr_valid_nb);
+       prestera_queue_drain();
 
        prestera_k_arb_abort(sw);