]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
greybus: timesync: Enforce TimeSync locks as subordinate to Interface locks
authorBryan O'Donoghue <bryan.odonoghue@linaro.org>
Thu, 23 Jun 2016 15:26:00 +0000 (16:26 +0100)
committerGreg Kroah-Hartman <gregkh@google.com>
Thu, 23 Jun 2016 21:15:21 +0000 (14:15 -0700)
gb_timesync_svc_teardown() is called from gb_timesync_svc_del() and issues a
command to a remote Interface to switch off its timers. The lock ordering
is TimeSync => Interface in this case. However gb_module_del() takes an
Interface lock then calls gb_interface_del() => gb_timesync_svc_del() in
this case the lock ordering is Interface => TimeSync.

This patch fixes by removing the taking of the Interface mutex in
gb_interface_timesync_do_something(). If an Interface is present in the
TimeSync linked-list - it is by definition intf->enabled.

Reported-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/interface.c

index 9b90209e8fe0007f17530c7f10564a65dbb7f865..05d0020d3a8d4c76c09e3cef2467689faa0ab651 100644 (file)
@@ -872,59 +872,27 @@ void gb_interface_disable(struct gb_interface *intf)
        intf->enabled = false;
 }
 
-/*
- * Enable TimeSync on an Interface control connection.
- *
- * Locking: Takes and releases the interface mutex.
- */
+/* Enable TimeSync on an Interface control connection. */
 int gb_interface_timesync_enable(struct gb_interface *intf, u8 count,
                                 u64 frame_time, u32 strobe_delay, u32 refclk)
 {
-       int ret = -ENODEV;
-
-       mutex_lock(&intf->mutex);
-       if (intf->enabled) {
-               ret = gb_control_timesync_enable(intf->control, count,
-                                                frame_time, strobe_delay,
-                                                refclk);
-       }
-       mutex_unlock(&intf->mutex);
-       return ret;
+       return gb_control_timesync_enable(intf->control, count,
+                                         frame_time, strobe_delay,
+                                         refclk);
 }
 
-/*
- * Disable TimeSync on an Interface control connection.
- *
- * Locking: Takes and releases the interface mutex.
- */
+/* Disable TimeSync on an Interface control connection. */
 int gb_interface_timesync_disable(struct gb_interface *intf)
 {
-       int ret = -ENODEV;
-
-       mutex_lock(&intf->mutex);
-       if (intf->enabled)
-               ret = gb_control_timesync_disable(intf->control);
-       mutex_unlock(&intf->mutex);
-       return ret;
+       return gb_control_timesync_disable(intf->control);
 }
 
-/*
- * Transmit the Authoritative FrameTime via an Interface control connection.
- *
- * Locking: Takes and releases the interface mutex.
- */
+/* Transmit the Authoritative FrameTime via an Interface control connection. */
 int gb_interface_timesync_authoritative(struct gb_interface *intf,
                                        u64 *frame_time)
 {
-       int ret = -ENODEV;
-
-       mutex_lock(&intf->mutex);
-       if (intf->enabled) {
-               ret = gb_control_timesync_authoritative(intf->control,
-                                                       frame_time);
-       }
-       mutex_unlock(&intf->mutex);
-       return ret;
+       return gb_control_timesync_authoritative(intf->control,
+                                               frame_time);
 }
 
 /* Register an interface. */