[Skiboot] [PATCH] occ-sensor: clean dt properties if sensor is not available

Balamuruhan S bala24 at linux.ibm.com
Tue Oct 15 18:11:25 AEDT 2019


On Mon, Oct 14, 2019 at 10:44:40PM +0530, Vasant Hegde wrote:
> On 10/14/19 3:21 PM, Balamuruhan S wrote:
> > In `occ_sensor_init()` device tree node is created for sensor-goups
> > and performs `occ_sensor_sanity()` check to initialize the device
> > tree. But if there are no sensors like in Qemu, sanity check fails
> > but still device tree populates the sensor-groups node wrongly as
> > the node created is not cleaned up.
> > 
> > Signed-off-by: Balamuruhan S <bala24 at linux.ibm.com>
> > ---
> >   hw/occ-sensor.c | 9 ++++++++-
> >   1 file changed, 8 insertions(+), 1 deletion(-)
> > 
> > diff --git a/hw/occ-sensor.c b/hw/occ-sensor.c
> > index d06ca725..ec116c9a 100644
> > --- a/hw/occ-sensor.c
> > +++ b/hw/occ-sensor.c
> > @@ -491,6 +491,7 @@ bool occ_sensors_init(void)
> >   	struct dt_node *sg, *exports;
> >   	int occ_num = 0, i;
> >   	bool has_gpu = false;
> > +	bool has_sensor = false;
> > 
> >   	/* OCC inband sensors is only supported in P9 */
> >   	if (proc_gen != proc_gen_p9)
> > @@ -526,7 +527,9 @@ bool occ_sensors_init(void)
> >   		md = get_names_block(hb);
> > 
> >   		/* Sanity check of the Sensor Data Header Block */
> > -		if (!occ_sensor_sanity(hb, chip->id))
> > +		if (occ_sensor_sanity(hb, chip->id))
> > +			has_sensor = true;
> > +		else
> >   			continue;
> > 
> >   		phandles = malloc(hb->nr_sensors * sizeof(u32));
> > @@ -587,6 +590,10 @@ bool occ_sensors_init(void)
> >   		free(phandles);
> >   		free(ptype);
> >   	}
> > +	if (!has_sensor) {
> > +		/* clear the device tree property for sensors */
> > +               dt_free(sg);
> > +	}
> 
> Patch doesn't explain what is the issue? Are you hitting any issue -OR- just
> cleanup?

It doesn't create any issue, just a minor cleanup.

> May be its better to defer dt node creation until we find some sensors
> instead of freeing up at the end.

Yeah I thought about it, but currently it creates the head node `sensor-groups`,
iterate over each chip and its sensors to create child node. Finally if
no valid sensors header block detected, initially created `sensor-groups`
hangs empty. so we could not defer head dt node in this logic, please suggest
if we can handle in better way. Thanks Vasant.

> 
> -Vasant



More information about the Skiboot mailing list