Message ID | 20230430170656.137549-2-shmuel.h@siklu.com (mailing list archive) |
---|---|
State | Deferred |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net: mvpp2: tai: add extts support | expand |
Context | Check | Description |
---|---|---|
netdev/series_format | success | Posting correctly formatted |
netdev/tree_selection | success | Guessed tree name to be net-next |
netdev/fixes_present | success | Fixes tag not required for -next series |
netdev/header_inline | success | No static functions without inline keyword in header files |
netdev/build_32bit | success | Errors and warnings before: 8 this patch: 8 |
netdev/cc_maintainers | success | CCed 8 of 8 maintainers |
netdev/build_clang | success | Errors and warnings before: 8 this patch: 8 |
netdev/verify_signedoff | success | Signed-off-by tag matches author and committer |
netdev/deprecated_api | success | None detected |
netdev/check_selftest | success | No net selftest shell script |
netdev/verify_fixes | success | Fixes tag looks correct |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 8 this patch: 8 |
netdev/checkpatch | warning | WARNING: line length of 82 exceeds 80 columns |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/source_inline | success | Was 0 now: 0 |
On Sun, 2023-04-30 at 20:06 +0300, Shmuel Hazan wrote: > In some configurations, a single TAI can be responsible for multiple > mvpp2 interfaces. However, the mvpp2 driver will call mvpp22_tai_stop > and mvpp22_tai_start per interface RX timestamp disable/enable. > > As a result, disabling timestamping for one interface would stop the > worker and corrupt the other interface's RX timestamps. > > This commit solves the issue by introducing a simpler ref count for each > TAI instance. > > Due to the ref count, we need now to lock tai->refcount_lock before > doing anything. As a result, we can't call mvpp22_tai_do_aux_work as it > will cause a deadlock. Therefore, we will just schedule the worker to > start immediately. > > Fixes: ce3497e2072e ("net: mvpp2: ptp: add support for receive timestamping") > Signed-off-by: Shmuel Hazan <shmuel.h@siklu.com> > --- > v1 -> v2: lock tai->lock before touching poll_worker_refcount. > v2 -> v3: no change > v3 -> v4: added additional lock for poll_worker_refcount due to > a possible deadlock. > --- > .../net/ethernet/marvell/mvpp2/mvpp2_tai.c | 28 +++++++++++++++++-- > 1 file changed, 25 insertions(+), 3 deletions(-) > So this patch looks fine to me. However you submitted this and the other 2 for net. The other 2 patches in this series seem to be a feature add rather than a fix. As such you may want to split up this set and submit the other two patches for net-next instead of net. Reviewed-by: Alexander Duyck <alexanderduyck@fb.com>
diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_tai.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_tai.c index 95862aff49f1..d8ce8bdae046 100644 --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_tai.c +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_tai.c @@ -32,6 +32,7 @@ * * Consequently, we support none of these. */ +#include "linux/spinlock.h" #include <linux/io.h> #include <linux/ptp_clock_kernel.h> #include <linux/slab.h> @@ -61,6 +62,8 @@ struct mvpp2_tai { u64 period; // nanosecond period in 32.32 fixed point /* This timestamp is updated every two seconds */ struct timespec64 stamp; + spinlock_t refcount_lock; /* Protects the poll_worker_refcount variable */ + u16 poll_worker_refcount; }; static void mvpp2_tai_modify(void __iomem *reg, u32 mask, u32 set) @@ -370,16 +373,34 @@ void mvpp22_tai_tstamp(struct mvpp2_tai *tai, u32 tstamp, void mvpp22_tai_start(struct mvpp2_tai *tai) { - long delay; + unsigned long flags; + + spin_lock_irqsave(&tai->refcount_lock, flags); - delay = mvpp22_tai_aux_work(&tai->caps); + tai->poll_worker_refcount++; + if (tai->poll_worker_refcount > 1) + goto out_unlock; - ptp_schedule_worker(tai->ptp_clock, delay); + ptp_schedule_worker(tai->ptp_clock, 0); + +out_unlock: + spin_unlock_irqrestore(&tai->refcount_lock, flags); } void mvpp22_tai_stop(struct mvpp2_tai *tai) { + unsigned long flags; + + spin_lock_irqsave(&tai->refcount_lock, flags); + + tai->poll_worker_refcount--; + if (tai->poll_worker_refcount) + goto unlock_out; + ptp_cancel_worker_sync(tai->ptp_clock); + +unlock_out: + spin_unlock_irqrestore(&tai->refcount_lock, flags); } static void mvpp22_tai_remove(void *priv) @@ -400,6 +421,7 @@ int mvpp22_tai_probe(struct device *dev, struct mvpp2 *priv) return -ENOMEM; spin_lock_init(&tai->lock); + spin_lock_init(&tai->refcount_lock); tai->base = priv->iface_base;
In some configurations, a single TAI can be responsible for multiple mvpp2 interfaces. However, the mvpp2 driver will call mvpp22_tai_stop and mvpp22_tai_start per interface RX timestamp disable/enable. As a result, disabling timestamping for one interface would stop the worker and corrupt the other interface's RX timestamps. This commit solves the issue by introducing a simpler ref count for each TAI instance. Due to the ref count, we need now to lock tai->refcount_lock before doing anything. As a result, we can't call mvpp22_tai_do_aux_work as it will cause a deadlock. Therefore, we will just schedule the worker to start immediately. Fixes: ce3497e2072e ("net: mvpp2: ptp: add support for receive timestamping") Signed-off-by: Shmuel Hazan <shmuel.h@siklu.com> --- v1 -> v2: lock tai->lock before touching poll_worker_refcount. v2 -> v3: no change v3 -> v4: added additional lock for poll_worker_refcount due to a possible deadlock. --- .../net/ethernet/marvell/mvpp2/mvpp2_tai.c | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-)