Fixed race: Stop EoE processing when entering or leaving operation mode.
authorFlorian Pose <fp@igh-essen.com>
Tue, 09 Jan 2007 12:56:03 +0000
changeset 518 b6a1426ba724
parent 517 b6ebde3d006d
child 519 54787e1b57d4
Fixed race: Stop EoE processing when entering or leaving operation mode.
master/master.c
--- a/master/master.c	Mon Jan 08 15:15:17 2007 +0000
+++ b/master/master.c	Tue Jan 09 12:56:03 2007 +0000
@@ -393,6 +393,9 @@
     ec_slave_t *slave;
     ec_datagram_t *datagram = &master->fsm.datagram;
 
+    ec_master_eoe_stop(master); // stop EoE timer
+    master->eoe_checked = 0; // prevent from starting again by FSM
+
     master->mode = EC_MASTER_MODE_OPERATION;
     while (!cancel_delayed_work(&master->idle_work)) {
         flush_workqueue(master->workqueue);
@@ -429,6 +432,8 @@
         }
     }
 
+    master->eoe_checked = 1; // allow starting EoE again
+
     return 0;
 
  out_idle:
@@ -449,6 +454,9 @@
     ec_fsm_t *fsm = &master->fsm;
     ec_datagram_t *datagram = &master->fsm.datagram;
 
+    ec_master_eoe_stop(master); // stop EoE timer
+    master->eoe_checked = 0; // prevent from starting again by FSM
+
     // wait for FSM datagram
     if (datagram->state == EC_DATAGRAM_SENT) {
         // active waiting
@@ -486,6 +494,8 @@
     master->release_cb = ec_master_release_cb;
     master->cb_data = master;
 
+    master->eoe_checked = 0; // allow EoE again
+
     master->mode = EC_MASTER_MODE_IDLE;
     queue_delayed_work(master->workqueue, &master->idle_work, 1);
 }
@@ -766,6 +776,8 @@
     ec_master_t *master = (ec_master_t *) data;
     cycles_t cycles_start, cycles_end;
 
+    if (master->mode != EC_MASTER_MODE_IDLE) return;
+    
     cycles_start = get_cycles();
 
     // receive
@@ -1037,14 +1049,6 @@
 
     master->eoe_checked = 1;
 
-    // if the locking callbacks are not set in operation mode,
-    // the EoE timer my not be started.
-    if (master->mode == EC_MASTER_MODE_OPERATION
-        && (!master->request_cb || !master->release_cb)) {
-        EC_INFO("No EoE processing because of missing locking callbacks.\n");
-        return;
-    }
-
     // decouple all EoE handlers
     list_for_each_entry(eoe, &master->eoe_handlers, list)
         eoe->slave = NULL;