Thread (14 messages) 14 messages, 5 authors, 2015-12-24

Re: [PATCH net-next V2 3/4] net/mlx5e: Add HW timestamping (TS) support

From: Saeed Mahameed <hidden>
Date: 2015-12-21 14:35:24

On Mon, Dec 21, 2015 at 11:15 AM, Richard Cochran
[off-list ref] wrote:
On Sun, Dec 20, 2015 at 11:46:30PM +0200, Saeed Mahameed wrote:
quoted
+/* Should run once every mlx5e_tstamp->overflow_period */
+static void mlx5e_timestamp_overflow(struct work_struct *work)
+{
+     struct delayed_work *dwork = to_delayed_work(work);
+     struct mlx5e_tstamp *tstamp = container_of(dwork, struct mlx5e_tstamp, overflow_work);
+     unsigned long flags;
+
+     write_lock_irqsave(&tstamp->lock, flags);
+     timecounter_read(&tstamp->clock);
+     if (tstamp->overflow_period)
+             schedule_delayed_work(&tstamp->overflow_work, tstamp->overflow_period);
You don't need this test, and the call to schedule_delayed_work can be
outside of the lock.
think of a case where:
CPU1: is just about to call
"schedule_delayed_work(&tstamp->overflow_work,
tstamp->overflow_period);"
CPU2: cancel_delayed_work

In this case cancel_dalyed_work_sync (CPU2) will wait for CPU1 to
complete but CPU1 will re-arm the work, and we will
be left with tstamp->overflow_work running forever.
quoted
+     write_unlock_irqrestore(&tstamp->lock, flags);
+}
quoted
+void mlx5e_timestamp_cleanup(struct mlx5e_priv *priv)
+{
+     struct mlx5e_tstamp *tstamp = &priv->tstamp;
+
+     if (!MLX5_CAP_GEN(priv->mdev, device_frequency_khz))
+             return;
+
+     write_lock(&tstamp->lock);
+     tstamp->overflow_period = 0; /* Signal overflow_check to stop */
+     write_unlock(&tstamp->lock);
This is unnecessary because
quoted
+
+     cancel_delayed_work_sync(&tstamp->overflow_work);
this will block until the work is cancelled.
see my previous comment it sure will block but without the protected
signal " tstamp->overflow_period = 0;"
the work can reschedule itself.
quoted
+}
Thanks,
Richard
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help