Skip to content

Commit

Permalink
Fix IPMI FRU Read command returning invalid data
Browse files Browse the repository at this point in the history
When trying to read the FRU contents via ipmitool, it return
different/incomplete data every time. This occurs due to a fail when
trying to take the mutex for read the memory. Increazing the timeout
value solve the problem.
  • Loading branch information
gustavosr8 committed Jul 10, 2023
1 parent 3e3783e commit 4dfcd82
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion modules/fru.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ size_t fru_read( uint8_t id, uint8_t *rx_buff, uint16_t offset, size_t len )
return 0;
}

/*
* Read runtime FRU info that is auto-generated
* when there is no valid FRU info in the EEPROM
*/
if ( fru[id].runtime ) {
for ( i = 0; i < len; i++, j++ ) {
if ( j < fru[id].fru_size ) {
Expand All @@ -234,8 +238,12 @@ size_t fru_read( uint8_t id, uint8_t *rx_buff, uint16_t offset, size_t len )
}
}
ret_val = i;

/*
* Read EEPROM FRU info
*/
} else {
ret_val = fru[id].cfg.read_f( fru[id].cfg.eeprom_id, offset, rx_buff, len, 0 );
ret_val = fru[id].cfg.read_f( fru[id].cfg.eeprom_id, offset, rx_buff, len, 10 );
}
return ret_val;
}
Expand Down Expand Up @@ -295,6 +303,17 @@ IPMI_HANDLER(ipmi_storage_read_fru_data_cmd, NETFN_STORAGE, IPMI_READ_FRU_DATA_C
offset = (req->data[2] << 8) | (req->data[1]);

count = fru_read( fru_id, &(rsp->data[len+1]), offset, count );

/*
* If count == 0, it may indicate that the fru_read function
* failed somehow.
*/

if (count == 0) {
rsp->completion_code = IPMI_CC_UNSPECIFIED_ERROR;
return ;
}

rsp->data[len++] = count;

rsp->data_len = len + count;
Expand Down

0 comments on commit 4dfcd82

Please sign in to comment.