mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-22 22:51:37 +00:00
IB/hfi1: Add parsing for platform configuration format version 4
Platform configuration format version 4, that didn't use the file size field, is not parsed by the host driver. Only version 5 is supported. Add logic in parsing procedure to determine what format is being used and allow to read data from version 4 files. Reviewed-by: Jan Sokolowski <jan.sokolowski@intel.com> Reviewed-by: Ira Weiny <ira.weiny@intel.com> Reviewed-by: Andrzej Kacprowski <andrzej.kacprowski@intel.com> Signed-off-by: Jakub Byczkowski <jakub.byczkowski@intel.com> Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
This commit is contained in:
parent
40837273d0
commit
9773afb97f
1 changed files with 22 additions and 2 deletions
|
@ -113,6 +113,12 @@ struct css_header {
|
||||||
#define MU_SIZE 8
|
#define MU_SIZE 8
|
||||||
#define EXPONENT_SIZE 4
|
#define EXPONENT_SIZE 4
|
||||||
|
|
||||||
|
/* size of platform configuration partition */
|
||||||
|
#define MAX_PLATFORM_CONFIG_FILE_SIZE 4096
|
||||||
|
|
||||||
|
/* size of file of plaform configuration encoded in format version 4 */
|
||||||
|
#define PLATFORM_CONFIG_FORMAT_4_FILE_SIZE 528
|
||||||
|
|
||||||
/* the file itself */
|
/* the file itself */
|
||||||
struct firmware_file {
|
struct firmware_file {
|
||||||
struct css_header css_header;
|
struct css_header css_header;
|
||||||
|
@ -1774,7 +1780,20 @@ int parse_platform_config(struct hfi1_devdata *dd)
|
||||||
|
|
||||||
/* Field is file size in DWORDs */
|
/* Field is file size in DWORDs */
|
||||||
file_length = (*ptr) * 4;
|
file_length = (*ptr) * 4;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Length can't be larger than partition size. Assume platform
|
||||||
|
* config format version 4 is being used. Interpret the file size
|
||||||
|
* field as header instead by not moving the pointer.
|
||||||
|
*/
|
||||||
|
if (file_length > MAX_PLATFORM_CONFIG_FILE_SIZE) {
|
||||||
|
dd_dev_info(dd,
|
||||||
|
"%s:File length out of bounds, using alternative format\n",
|
||||||
|
__func__);
|
||||||
|
file_length = PLATFORM_CONFIG_FORMAT_4_FILE_SIZE;
|
||||||
|
} else {
|
||||||
ptr++;
|
ptr++;
|
||||||
|
}
|
||||||
|
|
||||||
if (file_length > dd->platform_config.size) {
|
if (file_length > dd->platform_config.size) {
|
||||||
dd_dev_info(dd, "%s:File claims to be larger than read size\n",
|
dd_dev_info(dd, "%s:File claims to be larger than read size\n",
|
||||||
|
@ -1789,7 +1808,8 @@ int parse_platform_config(struct hfi1_devdata *dd)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* In both cases where we proceed, using the self-reported file length
|
* In both cases where we proceed, using the self-reported file length
|
||||||
* is the safer option
|
* is the safer option. In case of old format a predefined value is
|
||||||
|
* being used.
|
||||||
*/
|
*/
|
||||||
while (ptr < (u32 *)(dd->platform_config.data + file_length)) {
|
while (ptr < (u32 *)(dd->platform_config.data + file_length)) {
|
||||||
header1 = *ptr;
|
header1 = *ptr;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue