linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] firmware: ti_sci: Parse all resource ranges even if some is not available
@ 2019-06-04 10:28 Peter Ujfalusi
  2019-06-04 18:45 ` Peter Ujfalusi
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Ujfalusi @ 2019-06-04 10:28 UTC (permalink / raw)
  To: nm, t-kristo, ssantosh; +Cc: lokeshvutla, linux-arm-kernel

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);
-			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


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] firmware: ti_sci: Parse all resource ranges even if some is not available
  2019-06-04 10:28 [PATCH v2] firmware: ti_sci: Parse all resource ranges even if some is not available Peter Ujfalusi
@ 2019-06-04 18:45 ` Peter Ujfalusi
  2019-06-06  5:14   ` Lokesh Vutla
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Ujfalusi @ 2019-06-04 18:45 UTC (permalink / raw)
  To: nm, t-kristo, ssantosh; +Cc: lokeshvutla, linux-arm-kernel



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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] firmware: ti_sci: Parse all resource ranges even if some is not available
  2019-06-04 18:45 ` Peter Ujfalusi
@ 2019-06-06  5:14   ` Lokesh Vutla
  0 siblings, 0 replies; 3+ messages in thread
From: Lokesh Vutla @ 2019-06-06  5:14 UTC (permalink / raw)
  To: Peter Ujfalusi, nm, t-kristo, ssantosh; +Cc: linux-arm-kernel



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
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-06-06  5:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-04 10:28 [PATCH v2] firmware: ti_sci: Parse all resource ranges even if some is not available Peter Ujfalusi
2019-06-04 18:45 ` Peter Ujfalusi
2019-06-06  5:14   ` Lokesh Vutla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).