--- a/master/cdev.c Mon Nov 30 12:26:56 2009 +0100
+++ b/master/cdev.c Tue Dec 01 14:24:57 2009 +0100
@@ -808,12 +808,12 @@
if (master->debug_level)
EC_DBG("Schedule SDO upload request for slave %u\n",request.slave->ring_position);
// schedule request.
- list_add_tail(&request.list, &master->slave_sdo_requests);
+ list_add_tail(&request.list, &request.slave->slave_sdo_requests);
up(&master->master_sem);
// wait for processing through FSM
- if (wait_event_interruptible(master->sdo_queue,
+ if (wait_event_interruptible(request.slave->sdo_queue,
request.req.state != EC_INT_REQUEST_QUEUED)) {
// interrupted by signal
down(&master->master_sem);
@@ -828,7 +828,7 @@
}
// wait until master FSM has finished processing
- wait_event(master->sdo_queue, request.req.state != EC_INT_REQUEST_BUSY);
+ wait_event(request.slave->sdo_queue, request.req.state != EC_INT_REQUEST_BUSY);
if (master->debug_level)
EC_DBG("Scheduled SDO upload request for slave %u done\n",request.slave->ring_position);
@@ -914,12 +914,12 @@
if (master->debug_level)
EC_DBG("Schedule SDO download request for slave %u\n",request.slave->ring_position);
// schedule request.
- list_add_tail(&request.list, &master->slave_sdo_requests);
+ list_add_tail(&request.list, &request.slave->slave_sdo_requests);
up(&master->master_sem);
// wait for processing through FSM
- if (wait_event_interruptible(master->sdo_queue,
+ if (wait_event_interruptible(request.slave->sdo_queue,
request.req.state != EC_INT_REQUEST_QUEUED)) {
// interrupted by signal
down(&master->master_sem);
@@ -934,7 +934,7 @@
}
// wait until master FSM has finished processing
- wait_event(master->sdo_queue, request.req.state != EC_INT_REQUEST_BUSY);
+ wait_event(request.slave->sdo_queue, request.req.state != EC_INT_REQUEST_BUSY);
if (master->debug_level)
EC_DBG("Scheduled SDO download request for slave %u done\n",request.slave->ring_position);
--- a/master/fsm_master.c Mon Nov 30 12:26:56 2009 +0100
+++ b/master/fsm_master.c Tue Dec 01 14:24:57 2009 +0100
@@ -1017,14 +1017,14 @@
EC_DBG("Failed to process internal SDO request for slave %u.\n",
fsm->slave->ring_position);
request->state = EC_INT_REQUEST_FAILURE;
- wake_up(&master->sdo_queue);
+ wake_up(&fsm->slave->sdo_queue);
ec_fsm_master_restart(fsm);
return;
}
// SDO request finished
request->state = EC_INT_REQUEST_SUCCESS;
- wake_up(&master->sdo_queue);
+ wake_up(&fsm->slave->sdo_queue);
if (master->debug_level)
EC_DBG("Finished internal SDO request for slave %u.\n",
--- a/master/fsm_slave.c Mon Nov 30 12:26:56 2009 +0100
+++ b/master/fsm_slave.c Tue Dec 01 14:24:57 2009 +0100
@@ -115,9 +115,7 @@
ec_master_sdo_request_t *request, *next;
// search the first matching external request to be processed
- list_for_each_entry_safe(request, next, &master->slave_sdo_requests, list) {
- if (request->slave != slave)
- continue;
+ list_for_each_entry_safe(request, next, &slave->slave_sdo_requests, list) {
list_del_init(&request->list); // dequeue
request->req.state = EC_INT_REQUEST_BUSY;
@@ -125,7 +123,7 @@
EC_ERR("Discarding SDO request, slave %u is in INIT.\n",
slave->ring_position);
request->req.state = EC_INT_REQUEST_FAILURE;
- wake_up(&master->sdo_queue);
+ wake_up(&slave->sdo_queue);
continue;
}
@@ -165,7 +163,7 @@
EC_DBG("Failed to process SDO request for slave %u.\n",
fsm->slave->ring_position);
request->state = EC_INT_REQUEST_FAILURE;
- wake_up(&master->sdo_queue);
+ wake_up(&slave->sdo_queue);
fsm->sdo_request = NULL;
fsm->state = ec_fsm_slave_state_idle;
return;
@@ -173,7 +171,7 @@
// SDO request finished
request->state = EC_INT_REQUEST_SUCCESS;
- wake_up(&master->sdo_queue);
+ wake_up(&slave->sdo_queue);
if (master->debug_level)
EC_DBG("Finished SDO request for slave %u.\n",
--- a/master/master.c Mon Nov 30 12:26:56 2009 +0100
+++ b/master/master.c Tue Dec 01 14:24:57 2009 +0100
@@ -184,9 +184,6 @@
INIT_LIST_HEAD(&master->sii_requests);
init_waitqueue_head(&master->sii_queue);
- INIT_LIST_HEAD(&master->slave_sdo_requests);
- init_waitqueue_head(&master->sdo_queue);
-
INIT_LIST_HEAD(&master->reg_requests);
init_waitqueue_head(&master->reg_queue);
@@ -405,21 +402,6 @@
wake_up(&master->reg_queue);
}
- // SDO requests
- while (1) {
- ec_master_sdo_request_t *request;
- if (list_empty(&master->slave_sdo_requests))
- break;
- // get first request
- request = list_entry(master->slave_sdo_requests.next,
- ec_master_sdo_request_t, list);
- list_del_init(&request->list); // dequeue
- EC_INFO("Discarding SDO request, slave %u does not exist anymore.\n",
- request->slave->ring_position);
- request->req.state = EC_INT_REQUEST_FAILURE;
- wake_up(&master->sdo_queue);
- }
-
// FoE requests
while (1) {
ec_master_foe_request_t *request;
@@ -438,6 +420,20 @@
for (slave = master->slaves;
slave < master->slaves + master->slave_count;
slave++) {
+ // SDO requests
+ while (1) {
+ ec_master_sdo_request_t *request;
+ if (list_empty(&slave->slave_sdo_requests))
+ break;
+ // get first request
+ request = list_entry(slave->slave_sdo_requests.next,
+ ec_master_sdo_request_t, list);
+ list_del_init(&request->list); // dequeue
+ EC_INFO("Discarding SDO request, slave %u does not exist anymore.\n",
+ request->slave->ring_position);
+ request->req.state = EC_INT_REQUEST_FAILURE;
+ wake_up(&slave->sdo_queue);
+ }
ec_slave_clear(slave);
}
@@ -770,6 +766,8 @@
#endif
datagram->jiffies_sent = jiffies;
+ master->fsm.idle = 0;
+
down(&master->io_sem);
list_add_tail(&datagram->queue, &master->sdo_datagram_queue);
up(&master->io_sem);
--- a/master/master.h Mon Nov 30 12:26:56 2009 +0100
+++ b/master/master.h Tue Dec 01 14:24:57 2009 +0100
@@ -185,10 +185,6 @@
wait_queue_head_t sii_queue; /**< Wait queue for SII
write requests from user space. */
- struct list_head slave_sdo_requests; /**< SDO access requests. */
- wait_queue_head_t sdo_queue; /**< Wait queue for SDO access requests
- from user space. */
-
struct list_head reg_requests; /**< Register requests. */
wait_queue_head_t reg_queue; /**< Wait queue for register requests. */
--- a/master/slave.c Mon Nov 30 12:26:56 2009 +0100
+++ b/master/slave.c Tue Dec 01 14:24:57 2009 +0100
@@ -149,6 +149,9 @@
slave->sdo_dictionary_fetched = 0;
slave->jiffies_preop = 0;
+ INIT_LIST_HEAD(&slave->slave_sdo_requests);
+ init_waitqueue_head(&slave->sdo_queue);
+
// init state machine datagram
ec_datagram_init(&slave->fsm_datagram);
snprintf(slave->fsm_datagram.name, EC_DATAGRAM_NAME_SIZE, "slave%u-fsm",slave->ring_position);
--- a/master/slave.h Mon Nov 30 12:26:56 2009 +0100
+++ b/master/slave.h Tue Dec 01 14:24:57 2009 +0100
@@ -159,6 +159,9 @@
uint8_t sdo_dictionary_fetched; /**< Dictionary has been fetched. */
unsigned long jiffies_preop; /**< Time, the slave went to PREOP. */
+ struct list_head slave_sdo_requests; /**< SDO access requests. */
+ wait_queue_head_t sdo_queue; /**< Wait queue for SDO access requests
+ from user space. */
ec_fsm_slave_t fsm; /**< Slave state machine. */
ec_datagram_t fsm_datagram; /**< Datagram used for state machines. */
};