diff mbox series

[v2] firmware: ti_sci: Parse all resource ranges even if some is not available

Message ID 20190604102823.10166-1-peter.ujfalusi@ti.com (mailing list archive)
State New, archived
Headers show
Series [v2] firmware: ti_sci: Parse all resource ranges even if some is not available | expand

Commit Message

Peter Ujfalusi June 4, 2019, 10:28 a.m. UTC
Do not fail if any of the requested subtypes are not availabe, but set the
number of resources to 0 and continue parsing the resource ranges.

Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
Hi,

Changes since v1:
- moved the 'bool valid_set = false;' to avoid 'reverse Christmas tree'
- Added Reviewed-by from Lokesh

Regards,
Peter

 drivers/firmware/ti_sci.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Comments

Peter Ujfalusi June 4, 2019, 6:45 p.m. UTC | #1
On 6/4/19 1:28 PM, Peter Ujfalusi wrote:
> Do not fail if any of the requested subtypes are not availabe, but set the
> number of resources to 0 and continue parsing the resource ranges.
> 
> Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>
> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
> ---
> Hi,
> 
> Changes since v1:
> - moved the 'bool valid_set = false;' to avoid 'reverse Christmas tree'
> - Added Reviewed-by from Lokesh
> 
> Regards,
> Peter
> 
>  drivers/firmware/ti_sci.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
> index ef93406ace1b..191939476d64 100644
> --- a/drivers/firmware/ti_sci.c
> +++ b/drivers/firmware/ti_sci.c
> @@ -2342,6 +2342,7 @@ devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle,
>  			    struct device *dev, u32 dev_id, char *of_prop)
>  {
>  	struct ti_sci_resource *res;
> +	bool valid_set = false;
>  	u32 resource_subtype;
>  	int i, ret;
>  
> @@ -2374,13 +2375,16 @@ devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle,
>  		if (ret) {
>  			dev_err(dev, "dev = %d subtype %d not allocated for this host\n",
>  				dev_id, resource_subtype);

Should we change dev_err() to dev_dbg() as this is no longer a failure?

> -			return ERR_PTR(ret);
> +			res->desc[i].start = 0;
> +			res->desc[i].num = 0;
> +			continue;
>  		}
>  
>  		dev_dbg(dev, "dev = %d, subtype = %d, start = %d, num = %d\n",
>  			dev_id, resource_subtype, res->desc[i].start,
>  			res->desc[i].num);
>  
> +		valid_set = true;
>  		res->desc[i].res_map =
>  			devm_kzalloc(dev, BITS_TO_LONGS(res->desc[i].num) *
>  				     sizeof(*res->desc[i].res_map), GFP_KERNEL);
> @@ -2389,7 +2393,10 @@ devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle,
>  	}
>  	raw_spin_lock_init(&res->lock);
>  
> -	return res;
> +	if (valid_set)
> +		return res;
> +
> +	return ERR_PTR(-EINVAL);
>  }
>  
>  static int tisci_reboot_handler(struct notifier_block *nb, unsigned long mode,
> 

- Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
Lokesh Vutla June 6, 2019, 5:14 a.m. UTC | #2
On 05/06/19 12:15 AM, Peter Ujfalusi wrote:
> 
> 
> On 6/4/19 1:28 PM, Peter Ujfalusi wrote:
>> Do not fail if any of the requested subtypes are not availabe, but set the
>> number of resources to 0 and continue parsing the resource ranges.
>>
>> Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>
>> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
>> ---
>> Hi,
>>
>> Changes since v1:
>> - moved the 'bool valid_set = false;' to avoid 'reverse Christmas tree'
>> - Added Reviewed-by from Lokesh
>>
>> Regards,
>> Peter
>>
>>  drivers/firmware/ti_sci.c | 11 +++++++++--
>>  1 file changed, 9 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
>> index ef93406ace1b..191939476d64 100644
>> --- a/drivers/firmware/ti_sci.c
>> +++ b/drivers/firmware/ti_sci.c
>> @@ -2342,6 +2342,7 @@ devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle,
>>  			    struct device *dev, u32 dev_id, char *of_prop)
>>  {
>>  	struct ti_sci_resource *res;
>> +	bool valid_set = false;
>>  	u32 resource_subtype;
>>  	int i, ret;
>>  
>> @@ -2374,13 +2375,16 @@ devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle,
>>  		if (ret) {
>>  			dev_err(dev, "dev = %d subtype %d not allocated for this host\n",
>>  				dev_id, resource_subtype);
> 
> Should we change dev_err() to dev_dbg() as this is no longer a failure?

Valid point. Please make it dev_dbg.


Thanks and regards,
Lokesh

> 
>> -			return ERR_PTR(ret);
>> +			res->desc[i].start = 0;
>> +			res->desc[i].num = 0;
>> +			continue;
>>  		}
>>  
>>  		dev_dbg(dev, "dev = %d, subtype = %d, start = %d, num = %d\n",
>>  			dev_id, resource_subtype, res->desc[i].start,
>>  			res->desc[i].num);
>>  
>> +		valid_set = true;
>>  		res->desc[i].res_map =
>>  			devm_kzalloc(dev, BITS_TO_LONGS(res->desc[i].num) *
>>  				     sizeof(*res->desc[i].res_map), GFP_KERNEL);
>> @@ -2389,7 +2393,10 @@ devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle,
>>  	}
>>  	raw_spin_lock_init(&res->lock);
>>  
>> -	return res;
>> +	if (valid_set)
>> +		return res;
>> +
>> +	return ERR_PTR(-EINVAL);
>>  }
>>  
>>  static int tisci_reboot_handler(struct notifier_block *nb, unsigned long mode,
>>
> 
> - Peter
> 
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
>
diff mbox series

Patch

diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
index ef93406ace1b..191939476d64 100644
--- a/drivers/firmware/ti_sci.c
+++ b/drivers/firmware/ti_sci.c
@@ -2342,6 +2342,7 @@  devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle,
 			    struct device *dev, u32 dev_id, char *of_prop)
 {
 	struct ti_sci_resource *res;
+	bool valid_set = false;
 	u32 resource_subtype;
 	int i, ret;
 
@@ -2374,13 +2375,16 @@  devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle,
 		if (ret) {
 			dev_err(dev, "dev = %d subtype %d not allocated for this host\n",
 				dev_id, resource_subtype);
-			return ERR_PTR(ret);
+			res->desc[i].start = 0;
+			res->desc[i].num = 0;
+			continue;
 		}
 
 		dev_dbg(dev, "dev = %d, subtype = %d, start = %d, num = %d\n",
 			dev_id, resource_subtype, res->desc[i].start,
 			res->desc[i].num);
 
+		valid_set = true;
 		res->desc[i].res_map =
 			devm_kzalloc(dev, BITS_TO_LONGS(res->desc[i].num) *
 				     sizeof(*res->desc[i].res_map), GFP_KERNEL);
@@ -2389,7 +2393,10 @@  devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle,
 	}
 	raw_spin_lock_init(&res->lock);
 
-	return res;
+	if (valid_set)
+		return res;
+
+	return ERR_PTR(-EINVAL);
 }
 
 static int tisci_reboot_handler(struct notifier_block *nb, unsigned long mode,