Skip to content

Schedule slave FSMs with config_requested/config_running in pick-up loop#156

Closed
Copilot wants to merge 1 commit intoparallel-slave-configfrom
copilot/add-pickup-loop-for-slave-fsms
Closed

Schedule slave FSMs with config_requested/config_running in pick-up loop#156
Copilot wants to merge 1 commit intoparallel-slave-configfrom
copilot/add-pickup-loop-for-slave-fsms

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 2, 2026

Without this fix, ec_fsm_master_state_wait_config spins forever because slaves flagged for parallel configuration are never scheduled — ec_fsm_slave_is_ready() only returns true for request-based operations, not for configuration flags set by ec_fsm_slave_request_config().

Change

master/master.cec_master_exec_slave_fsms() pick-up loop

  • Expand the pick-up condition to include slaves with config_requested or config_running set, alongside the existing ec_fsm_slave_is_ready() check:
if (ec_fsm_slave_is_ready(&master->fsm_slave->fsm)
        || master->fsm_slave->fsm.config_requested
        || master->fsm_slave->fsm.config_running) {

This is Step 4 of the parallel slave configuration implementation — ec_fsm_slave_exec() already handles these flags correctly; they just needed to be included in the scheduler's pick-up condition.

Original prompt

Problem

This is the final step (Step 4) of the parallel slave configuration implementation described in PARALLEL_SLAVE_CONFIG_IMPL.md.

Steps 1-3 are already complete on the parallel-slave-config branch:

However, Step 4 is missing: The slave FSM pick-up loop in ec_master_exec_slave_fsms() in master/master.c never adds slaves with config_requested or config_running flags to the execution list. This means parallel configuration will hangec_fsm_master_state_wait_config will spin forever because the slave FSMs are never scheduled.

Required Change

In master/master.c, in the ec_master_exec_slave_fsms() function, there is a pick-up loop (around line 1336-1358) that scans slaves and adds their FSMs to master->fsm_exec_list:

while (master->fsm_exec_count < EC_EXT_RING_SIZE / 2
        && count < master->slave_count) {

    if (ec_fsm_slave_is_ready(&master->fsm_slave->fsm)) {
        // ... pick up and execute ...
    }

    master->fsm_slave++;
    // ...
    count++;
}

The condition ec_fsm_slave_is_ready() only returns true when the slave FSM state is ec_fsm_slave_state_ready (set via ec_fsm_slave_set_ready()). It does not detect slaves whose config_requested or config_running flags have been set by ec_fsm_slave_request_config().

The fix: Expand the pick-up condition to also check the configuration flags:

if (ec_fsm_slave_is_ready(&master->fsm_slave->fsm)
        || master->fsm_slave->fsm.config_requested
        || master->fsm_slave->fsm.config_running) {

This ensures that when fsm_master sets config_requested=1 on slave FSMs (Step 3), those slaves will be picked up by ec_master_exec_slave_fsms(), given an external datagram, and executed in parallel.

File to modify

  • master/master.c — the slave FSM pick-up loop inside ec_master_exec_slave_fsms()

Important context

  • The ec_fsm_slave_exec() function (in master/fsm_slave.c) already handles config_requested and config_running correctly — it starts the config FSM, propagates datagrams to sub-FSMs, and clears the flags when done.
  • The existing ec_fsm_slave_is_ready() check handles normal request-based slave operations (SDO, FoE, etc.)
  • The new condition adds parallel configuration scheduling alongside the existing request scheduling.
  • No other files need modification for this step.

This pull request was created from Copilot chat.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Add slave FSM pick-up loop for parallel configuration Schedule slave FSMs with config_requested/config_running in pick-up loop Mar 2, 2026
@sittner sittner closed this Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants