[Skiboot] [PATCH] hdata/i2c: Workaround broken i2c devices

Michael Neuling mikey at neuling.org
Wed Apr 12 17:21:25 AEST 2017


On Wed, 2017-04-12 at 17:14 +1000, Oliver O'Halloran wrote:
> Some older revisions of hostboot populate the host i2c device fields
> with all zero entires. Detect and ignore these so we don't crash on
> boot.

Can you put the backtrace here? ie:

[  151.251240444,3] DT: dt_attach_root failed, duplicate unknown at 0
[  151.251300274,3] ***********************************************
[  151.251339330,3] Unexpected exception 200 !
[  151.251363654,3] SRR0 : 0000000030090c28 SRR1 : 9000000000201000
[  151.251409207,3] HSRR0: 0000000000000010 HSRR1: 9000000000001000
[  151.251444114,3] LR   : 30034018300c5ab0 CTR  : 30034018300a343c
[  151.251478314,3] CFAR : 0000000030024804
[  151.251500346,3] CR   : 40004208  XER: 00000000
[  151.251526264,3] GPR00: 00000000300248b8 GPR16: 00000000300a41c5
[  151.251562920,3] GPR01: 0000000031cd3840 GPR17: 00000000300aaa90
[  151.251597135,3] GPR02: 00000000300d9800 GPR18: 00000000300aac92
[  151.251632007,3] GPR03: 7c7b1b784800249b GPR19: 0000000000000000
[  151.251668459,3] GPR04: 00000000300a343c GPR20: 000000003009b4eb
[  151.251701693,3] GPR05: 000000003009f670 GPR21: 000000003009b4fa
[  151.251736384,3] GPR06: 000000003009f670 GPR22: 00000000300aac9d
[  151.251772549,3] GPR07: 0000000000000034 GPR23: 0000000030305718
[  151.251807075,3] GPR08: 0000000000000000 GPR24: 000000003009b530
[  151.251841854,3] GPR09: 0000000000000000 GPR25: 00000000300a343c
[  151.251880071,3] GPR10: 0000000031cd0000 GPR26: 00000000300c5ab0
[  151.251913217,3] GPR11: 0000000000000000 GPR27: 0000000000000005
[  151.251947153,3] GPR12: 0000000080004208 GPR28: 0000000000000004
[  151.251982179,3] GPR13: 0000000031cd0000 GPR29: 00000000300a343c
[  151.252014930,3] GPR14: 0000000000000000 GPR30: 0000000000000018
[  151.252050430,3] GPR15: 00000000300c5ac8 GPR31: 0000000000000000
[  151.252083372,0] Aborting!
CPU 0034 Backtrace:
 S: 0000000031cd36a0 R: 000000003001364c   .backtrace+0x2c
 S: 0000000031cd3730 R: 0000000030018db8   ._abort+0x4c
 S: 0000000031cd37b0 R: 0000000030025c6c   .exception_entry+0x114
 S: 0000000031cd3840 R: 0000000000001f00 * +0x1f00
 S: 0000000031cd3a10 R: 0000000031cd3ab0 * 
 S: 0000000031cd3aa0 R: 00000000300248b8   .new_property+0x90
 S: 0000000031cd3b30 R: 0000000030024b50   .__dt_add_property_cells+0x30
 S: 0000000031cd3bd0 R: 000000003009abec   .parse_i2c_devs+0x350
 S: 0000000031cd3cf0 R: 0000000030093ffc   .parse_hdat+0x11e4
 S: 0000000031cd3e30 R: 00000000300144c8   .main_cpu_entry+0x138
 S: 0000000031cd3f00 R: 0000000030002648   boot_entry+0x198

> 
> Signed-off-by: Oliver O'Halloran <oohall at gmail.com>
> ---
>  hdata/i2c.c | 24 +++++++++++++++++++++++-
>  1 file changed, 23 insertions(+), 1 deletion(-)
> 
> diff --git a/hdata/i2c.c b/hdata/i2c.c
> index 127068fafdeb..17f9ff1f8edf 100644
> --- a/hdata/i2c.c
> +++ b/hdata/i2c.c
> @@ -132,6 +132,18 @@ static const char *map_label(uint32_t type)
>  	return NULL;
>  }
>  
> +static bool is_zeros(const void *p, size_t size)
> +{
> +	const char *c = p;
> +	size_t i;
> +
> +	for (i = 0; i < size; i++)
> +		if (c[i] != 0)
> +			break;

s/break/return false/

> +
> +	return i == size;

return true;

> +}
> +
>  int parse_i2c_devs(const struct HDIF_common_hdr *hdr, int idata_index,
>  	struct dt_node *xscom)
>  {
> @@ -140,6 +152,7 @@ int parse_i2c_devs(const struct HDIF_common_hdr *hdr, int
> idata_index,
>  	const struct i2c_dev *dev;
>  	const char *label, *name, *compat;
>  	uint32_t i2c_addr;
> +	uint32_t size;
>  	int i, count;
>  
>  	/*
> @@ -150,7 +163,16 @@ int parse_i2c_devs(const struct HDIF_common_hdr *hdr, int
> idata_index,
>  
>  	count = HDIF_get_iarray_size(hdr, idata_index);
>  	for (i = 0; i < count; i++) {
> -		dev = HDIF_get_iarray_item(hdr, idata_index, i, NULL);
> +		dev = HDIF_get_iarray_item(hdr, idata_index, i, &size);
> +
> +		/*
> +		 * XXX: Some broken hostboots populate i2c devs with zeros.
> +		 * Workaround them for now.
> +		 */
> +		if (is_zeros(dev, size)) {
> +			prerror("I2C: Ignoring broken i2c dev %d\n", i);
> +			continue;
> +		}
>  
>  		i2cm = get_i2cm_node(xscom, dev->i2cm_engine);
>  		bus = get_bus_node(i2cm, dev->i2cm_port,


More information about the Skiboot mailing list