layerscape: add patches-5.4
[openwrt/staging/hauke.git] / target / linux / layerscape / patches-5.4 / 701-net-0346-staging-dpaa2-ethsw-ordered-workqueue-should-be-per-.patch
1 From 6e0b1cafcfc1bf343cf4957a93850178ba9ea165 Mon Sep 17 00:00:00 2001
2 From: Ioana Ciornei <ioana.ciornei@nxp.com>
3 Date: Mon, 11 Nov 2019 18:50:58 +0200
4 Subject: [PATCH] staging: dpaa2-ethsw: ordered workqueue should be per ethsw
5
6 Create a different ordered workqueue per dpaa2-ethsw instance. Without
7 this change, we overwrite the global queue and leak memory when probing
8 multiple instances of the driver.
9
10 Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
11 Link: https://lore.kernel.org/r/1573491058-24766-5-git-send-email-ioana.ciornei@nxp.com
12 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
13 ---
14 drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 17 +++++++++--------
15 drivers/staging/fsl-dpaa2/ethsw/ethsw.h | 1 +
16 2 files changed, 10 insertions(+), 8 deletions(-)
17
18 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
19 +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
20 @@ -18,8 +18,6 @@
21
22 #include "ethsw.h"
23
24 -static struct workqueue_struct *ethsw_owq;
25 -
26 /* Minimal supported DPSW version */
27 #define DPSW_MIN_VER_MAJOR 8
28 #define DPSW_MIN_VER_MINOR 1
29 @@ -1229,8 +1227,10 @@ static int port_switchdev_event(struct n
30 unsigned long event, void *ptr)
31 {
32 struct net_device *dev = switchdev_notifier_info_to_dev(ptr);
33 + struct ethsw_port_priv *port_priv = netdev_priv(dev);
34 struct ethsw_switchdev_event_work *switchdev_work;
35 struct switchdev_notifier_fdb_info *fdb_info = ptr;
36 + struct ethsw_core *ethsw = port_priv->ethsw_data;
37
38 if (!ethsw_port_dev_check(dev))
39 return NOTIFY_DONE;
40 @@ -1266,7 +1266,7 @@ static int port_switchdev_event(struct n
41 return NOTIFY_DONE;
42 }
43
44 - queue_work(ethsw_owq, &switchdev_work->work);
45 + queue_work(ethsw->workqueue, &switchdev_work->work);
46
47 return NOTIFY_DONE;
48
49 @@ -1427,9 +1427,10 @@ static int ethsw_init(struct fsl_mc_devi
50 }
51 }
52
53 - ethsw_owq = alloc_ordered_workqueue("%s_ordered", WQ_MEM_RECLAIM,
54 - "ethsw");
55 - if (!ethsw_owq) {
56 + ethsw->workqueue = alloc_ordered_workqueue("%s_%d_ordered",
57 + WQ_MEM_RECLAIM, "ethsw",
58 + ethsw->sw_attr.id);
59 + if (!ethsw->workqueue) {
60 err = -ENOMEM;
61 goto err_close;
62 }
63 @@ -1441,7 +1442,7 @@ static int ethsw_init(struct fsl_mc_devi
64 return 0;
65
66 err_destroy_ordered_workqueue:
67 - destroy_workqueue(ethsw_owq);
68 + destroy_workqueue(ethsw->workqueue);
69
70 err_close:
71 dpsw_close(ethsw->mc_io, 0, ethsw->dpsw_handle);
72 @@ -1529,7 +1530,7 @@ static int ethsw_remove(struct fsl_mc_de
73
74 ethsw_teardown_irqs(sw_dev);
75
76 - destroy_workqueue(ethsw_owq);
77 + destroy_workqueue(ethsw->workqueue);
78
79 dpsw_disable(ethsw->mc_io, 0, ethsw->dpsw_handle);
80
81 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.h
82 +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.h
83 @@ -70,6 +70,7 @@ struct ethsw_core {
84 struct notifier_block port_nb;
85 struct notifier_block port_switchdev_nb;
86 struct notifier_block port_switchdevb_nb;
87 + struct workqueue_struct *workqueue;
88 };
89
90 #endif /* __ETHSW_H */