Commit 06bd82d5 authored by Jean-Claude BAU's avatar Jean-Claude BAU Committed by Adam Wujek

Soft PLL returns unlock state sometime

This was due to the introduction of system timers in the main loop of
the switch. In minirpc the pool() system call exited sometime when the
timer fired. Some other problems have been found during the debugging
process. Some of them have been already adressed :
- In minirpc, loop on pool() system call if the call is interrupted.
- Wrong check in function wrs_locking_poll(). Was working by chance.
- L12_state_machine() was calling to many often the state handle. It was
increasing the number of hardware calls for nothing.

TODO: The returned values for the function wrs_locking_poll(), halexp_lock_cmd(), and hal_port_check_lock() should be reviewed to be more consistent.
parent ce55ff3d
......@@ -130,14 +130,17 @@ int minipc_call(struct minipc_ch *ch, int millisec_timeout,
pfd.fd = ch->fd;
pfd.events = POLLIN | POLLHUP;
pfd.revents = 0;
pollnr = poll(&pfd, 1, millisec_timeout);
if (pollnr < 0) {
/* errno already set */
return -1;
}
if (pollnr == 0) {
errno = ETIMEDOUT;
return -1;
while ( 1 ) {
if ( (pollnr = poll(&pfd, 1, millisec_timeout)) > 0 )
break;
if (pollnr < 0 && errno!=EINTR) {
/* errno already set */
return -1;
}
if (pollnr == 0) {
errno = ETIMEDOUT;
return -1;
}
}
if (shm) {
......
......@@ -55,7 +55,7 @@ static l1e_state_machine_t le1_state_actions[] ={
*/
int l1e_run_state_machine(struct pp_instance *ppi) {
L1SyncBasicPortDS_t * basicDS=L1E_DSPOR_BS(ppi);
static Boolean execute_state_machine=TRUE;
Enumeration8 nextState=basicDS->next_state;
Boolean newState=nextState!=basicDS->L1SyncState;
int delay;
......@@ -77,6 +77,12 @@ int l1e_run_state_machine(struct pp_instance *ppi) {
int timeout_tx_sync = (4 << (basicDS->logL1SyncInterval + 8)) * basicDS->L1SyncReceiptTimeout;
__pp_timeout_set(ppi, L1E_TIMEOUT_RX_SYNC, timeout_tx_sync);
basicDS->L1SyncLinkAlive = FALSE;
execute_state_machine=TRUE;
}
/* Check L1SYNC transmission Time-out */
if ( pp_timeout(ppi, L1E_TIMEOUT_TX_SYNC) ) {
execute_state_machine=TRUE;
}
/*
......@@ -85,8 +91,20 @@ int l1e_run_state_machine(struct pp_instance *ppi) {
if ( newState ) {
basicDS->L1SyncState=nextState;
pp_diag(ppi, ext, 2, "L1SYNC state: Enter %s\n", l1e_state_name[nextState]);
execute_state_machine=TRUE;
}
delay=(*le1_state_actions[basicDS->L1SyncState].action) (ppi,newState);
if ( execute_state_machine ) {
/* The state machine is executed only when really needed because
* fsm can call this function too often.
*/
delay=(*le1_state_actions[basicDS->L1SyncState].action) (ppi,newState);
} else
delay=pp_next_delay_2(ppi,L1E_TIMEOUT_TX_SYNC, L1E_TIMEOUT_RX_SYNC); /* Return the shorter timeout */
/* If return delay is 0, it means that the state machine should be executed at last call */
execute_state_machine= (delay==0);
if ( basicDS->L1SyncState != basicDS->next_state )
pp_diag(ppi, ext, 2, "L1SYNC state: Exit %s\n", l1e_state_name[basicDS->L1SyncState]);
return delay;
......
......@@ -161,8 +161,12 @@ int wrs_locking_poll(struct pp_instance *ppi, int grandmaster)
ret = minipc_call(hal_ch, DEFAULT_TO, &__rpcdef_lock_cmd,
&rval, ppi->iface_name, HEXP_LOCK_CMD_CHECK, 0);
if (ret != HEXP_LOCK_STATUS_LOCKED) {
pp_diag(ppi, time, 2, "PLL is not ready\n");
if ( ret<0 ) {
pp_diag(ppi, time, 2, "PLL is not ready: minirpc communication error %s\n",strerror(errno));
return WRH_SPLL_ERROR; /* FIXME should be WRH_SPLL_NOT_READY */
}
if (rval != HEXP_LOCK_STATUS_LOCKED) {
pp_diag(ppi, time, 2, "PLL not locked(%d)\n",rval);
return WRH_SPLL_ERROR; /* FIXME should be WRH_SPLL_NOT_READY */
}
pp_diag(ppi, time, 2, "PLL is locked\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment