Skip to content

Commit

Permalink
hdata: Check the Host I2C devices array version
Browse files Browse the repository at this point in the history
Currently this is not populated on FSP machines which causes some
obnoxious errors to appear in the boot log. We also only want to
parse version 1 of this structure since future versions will completely
change the array item format.

Cc: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
[stewart@linux.vnet.ibm.com: return -1 on error rather than 1]
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
  • Loading branch information
oohal authored and stewartsmith committed May 26, 2017
1 parent 3bb3f13 commit 41dc3eb
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions hdata/i2c.c
Expand Up @@ -149,14 +149,21 @@ static bool is_zeros(const void *p, size_t size)
return true;
}

struct host_i2c_hdr {
const struct HDIF_array_hdr hdr;
__be32 version;
};

int parse_i2c_devs(const struct HDIF_common_hdr *hdr, int idata_index,
struct dt_node *xscom)
{
struct dt_node *i2cm, *bus, *node;
const struct hdat_i2c_type *type;
const struct i2c_dev *dev;
const char *label, *name, *compat;
const struct host_i2c_hdr *ahdr;
uint32_t i2c_addr;
uint32_t version;
uint32_t size;
int i, count;

Expand All @@ -166,6 +173,32 @@ int parse_i2c_devs(const struct HDIF_common_hdr *hdr, int idata_index,
*/
assert(proc_gen == proc_gen_p9);

/*
* Emit an error if we get a newer version. This is an interim measure
* until the new version format is finalised.
*/
ahdr = HDIF_get_idata(hdr, idata_index, &size);
if (!ahdr || !size)
return -1;

/*
* Some hostboots don't correctly fill the version field. On these
* the offset from the start of the header to the start of the array
* is 16 bytes.
*/
if (be32_to_cpu(ahdr->hdr.offset) == 16) {
version = 1;
prerror("I2C: HDAT device array has no version! Assuming v1\n");
} else {
version = be32_to_cpu(hdr->version);
}

if (version != 1) {
prerror("I2C: HDAT version %d not supported! THIS IS A BUG\n",
version);
return -1;
}

count = HDIF_get_iarray_size(hdr, idata_index);
for (i = 0; i < count; i++) {
dev = HDIF_get_iarray_item(hdr, idata_index, i, &size);
Expand Down

0 comments on commit 41dc3eb

Please sign in to comment.