Commit b96b3c8d authored by Maciej Lipinski's avatar Maciej Lipinski Committed by Jean-Claude BAU

[HAL] fix bug when writing tx_calibration file.

The writing must be done by the first LPDC-supporting port after all
the LPDC-supporting ports have been calibrated. Thus, this must be
done in the new state HAL_PORT_TX_SETUP_STATE_WAIT_OTHER_PORTS and
only the first port. Otherwise, we have problem when looping through
all the supporting ports. In particular, the writing must be done for
all LPDC-supporting ports, if we start looping on port N (by ++pointer),
then we will not cover all ports, unless we loop up (++) and (--)
down.
parent f67edd7c
......@@ -250,7 +250,7 @@ static int _hal_port_tx_setup_state_measure_phase(void *vpfg, int eventMsk, int
pr_info("TX Calibration: upd wri%d phase %d after %d "
"attempts target %d tollerance %d\n",
ps->hw_index+1, txSetup->measured_phase, txSetup->measured_phase,
ps->hw_index+1, txSetup->measured_phase,
txSetup->attempts, txSetup->expected_phase, txSetup->tollerance);
if(_within_range(phase, phase_min, phase_max, 16000)) {
......@@ -298,9 +298,6 @@ static int _hal_port_tx_setup_state_validate(void *vpfg, int eventMsk, int isNew
_fireState(vpfg,HAL_PORT_TX_SETUP_STATE_WAIT_OTHER_PORTS);
txSetupDone(ps);
if(txSetupDoneOnAllPorts(ps))
_write_tx_calibration_file(ps);
return 0;
}
/*
......@@ -310,8 +307,10 @@ static int _hal_port_tx_setup_state_validate(void *vpfg, int eventMsk, int isNew
static int _hal_port_tx_setup_state_wait_other_ports(void *vpfg, int eventMsk, int isNewState) {
struct hal_port_state * ps = ((halPortFsmGen_t *) vpfg)->ps;
if (txSetupDoneOnAllPorts(ps) )
if (txSetupDoneOnAllPorts(ps) ) {
_write_tx_calibration_file(ps);
_fireState(vpfg,HAL_PORT_TX_SETUP_STATE_DONE);
}
}
......@@ -470,6 +469,12 @@ static void _write_tx_calibration_file(struct hal_port_state * _ps)
struct hal_port_state * ps=_ps;
struct halGlobalLPDC * gl = ps->lpdc.globalLpdc;
/* Only the first LPDC-supporting port writes the file. Otherwise,
there is problem with pointers when looping through port structures
to write data for all ports, see the "for" below. */
if(gl->firstLpdcPort != ps->hw_index)
return;
if(gl->calFileSynced)
return;
......@@ -483,7 +488,7 @@ static void _write_tx_calibration_file(struct hal_port_state * _ps)
struct config_file *cfg = cfg_load(_calibrationFileName, 1);
ps=_ps;
for (i = 0; i < HAL_MAX_PORTS; i++) {
for (i = gl->firstLpdcPort; i <= gl->lastLpdcPort; i++) {
if (ps->in_use && ps->lpdc.isSupported)
{
char key_name[80];
......
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