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

Vasant Hegde hegdevasant at linux.vnet.ibm.com
Tue Oct 15 04:14:40 AEDT 2019


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?
May be its better to defer dt node creation until we find some sensors instead 
of freeing up at the end.

-Vasant



More information about the Skiboot mailing list