diff mbox series

[v5,3/5] opp: Add dev_pm_opp_find_level_floor()

Message ID 1694066433-8677-4-git-send-email-quic_krichai@quicinc.com
State Accepted
Commit a0242c81bb759ef03184be8eddcc7d5bdf36cc16
Headers show
Series PCI: qcom: Add support for OPP | expand

Commit Message

Krishna chaitanya chundru Sept. 7, 2023, 6 a.m. UTC
During initialization of some drivers, need to vote for max level.

Adding dev_pm_opp_find_level_floor() for searching a lesser match or
operating on OPP in the order of decreasing level.

Signed-off-by: Krishna chaitanya chundru <quic_krichai@quicinc.com>
---
 drivers/opp/core.c     | 25 +++++++++++++++++++++++++
 include/linux/pm_opp.h |  9 +++++++++
 2 files changed, 34 insertions(+)

Comments

Viresh Kumar Sept. 27, 2023, 7:14 a.m. UTC | #1
On 07-09-23, 11:30, Krishna chaitanya chundru wrote:

$Subject should have OPP instead of opp. Past history of framework can be seen
for this.

> During initialization of some drivers, need to vote for max level.
> 
> Adding dev_pm_opp_find_level_floor() for searching a lesser match or
> operating on OPP in the order of decreasing level.
> 
> Signed-off-by: Krishna chaitanya chundru <quic_krichai@quicinc.com>
> ---
>  drivers/opp/core.c     | 25 +++++++++++++++++++++++++
>  include/linux/pm_opp.h |  9 +++++++++
>  2 files changed, 34 insertions(+)
> 
> diff --git a/drivers/opp/core.c b/drivers/opp/core.c
> index 919cc53..6d4d226 100644
> --- a/drivers/opp/core.c
> +++ b/drivers/opp/core.c
> @@ -814,6 +814,31 @@ struct dev_pm_opp *dev_pm_opp_find_level_ceil(struct device *dev,
>  EXPORT_SYMBOL_GPL(dev_pm_opp_find_level_ceil);
>  
>  /**
> + * dev_pm_opp_find_level_floor() - Search for a rounded floor freq

freq ?

> + * @dev:	device for which we do this operation
> + * @level:	Start level
> + *
> + * Search for the matching floor *available* OPP from a starting level
> + * for a device.
> + *
> + * Return: matching *opp and refreshes *level accordingly, else returns
> + * ERR_PTR in case of error and should be handled using IS_ERR. Error return
> + * values can be:
> + * EINVAL:	for bad pointer
> + * ERANGE:	no match found for search
> + * ENODEV:	if device not found in list of registered devices
> + *
> + * The callers are required to call dev_pm_opp_put() for the returned OPP after
> + * use.
> + */
> +struct dev_pm_opp *dev_pm_opp_find_level_floor(struct device *dev,
> +					       unsigned long *level)
> +{
> +	return _find_key_floor(dev, level, 0, true, _read_level, NULL);
> +}
> +EXPORT_SYMBOL_GPL(dev_pm_opp_find_level_floor);
> +
> +/**
>   * dev_pm_opp_find_bw_ceil() - Search for a rounded ceil bandwidth
>   * @dev:	device for which we do this operation
>   * @bw:	start bandwidth
> diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h
> index 91f87d7..baea92f 100644
> --- a/include/linux/pm_opp.h
> +++ b/include/linux/pm_opp.h
> @@ -144,6 +144,9 @@ struct dev_pm_opp *dev_pm_opp_find_level_exact(struct device *dev,
>  struct dev_pm_opp *dev_pm_opp_find_level_ceil(struct device *dev,
>  					      unsigned int *level);
>  
> +struct dev_pm_opp *dev_pm_opp_find_level_floor(struct device *dev,
> +					       unsigned long *level);
> +
>  struct dev_pm_opp *dev_pm_opp_find_bw_ceil(struct device *dev,
>  					   unsigned int *bw, int index);
>  
> @@ -314,6 +317,12 @@ static inline struct dev_pm_opp *dev_pm_opp_find_bw_ceil(struct device *dev,
>  	return ERR_PTR(-EOPNOTSUPP);
>  }
>  
> +static inline struct dev_pm_opp *dev_pm_opp_find_level_floor(struct device *dev,

Why add between two bw related functions ?

> +							     unsigned long *level)
> +{
> +	return ERR_PTR(-EOPNOTSUPP);
> +}
> +
>  static inline struct dev_pm_opp *dev_pm_opp_find_bw_floor(struct device *dev,
>  					unsigned int *bw, int index)
>  {

Fixed all this and applied. Thanks.
Krishna chaitanya chundru Sept. 28, 2023, 3:35 a.m. UTC | #2
On 9/27/2023 12:44 PM, Viresh Kumar wrote:
> On 07-09-23, 11:30, Krishna chaitanya chundru wrote:
>
> $Subject should have OPP instead of opp. Past history of framework can be seen
> for this.
>
>> During initialization of some drivers, need to vote for max level.
>>
>> Adding dev_pm_opp_find_level_floor() for searching a lesser match or
>> operating on OPP in the order of decreasing level.
>>
>> Signed-off-by: Krishna chaitanya chundru <quic_krichai@quicinc.com>
>> ---
>>   drivers/opp/core.c     | 25 +++++++++++++++++++++++++
>>   include/linux/pm_opp.h |  9 +++++++++
>>   2 files changed, 34 insertions(+)
>>
>> diff --git a/drivers/opp/core.c b/drivers/opp/core.c
>> index 919cc53..6d4d226 100644
>> --- a/drivers/opp/core.c
>> +++ b/drivers/opp/core.c
>> @@ -814,6 +814,31 @@ struct dev_pm_opp *dev_pm_opp_find_level_ceil(struct device *dev,
>>   EXPORT_SYMBOL_GPL(dev_pm_opp_find_level_ceil);
>>   
>>   /**
>> + * dev_pm_opp_find_level_floor() - Search for a rounded floor freq
> freq ?
>
>> + * @dev:	device for which we do this operation
>> + * @level:	Start level
>> + *
>> + * Search for the matching floor *available* OPP from a starting level
>> + * for a device.
>> + *
>> + * Return: matching *opp and refreshes *level accordingly, else returns
>> + * ERR_PTR in case of error and should be handled using IS_ERR. Error return
>> + * values can be:
>> + * EINVAL:	for bad pointer
>> + * ERANGE:	no match found for search
>> + * ENODEV:	if device not found in list of registered devices
>> + *
>> + * The callers are required to call dev_pm_opp_put() for the returned OPP after
>> + * use.
>> + */
>> +struct dev_pm_opp *dev_pm_opp_find_level_floor(struct device *dev,
>> +					       unsigned long *level)
>> +{
>> +	return _find_key_floor(dev, level, 0, true, _read_level, NULL);
>> +}
>> +EXPORT_SYMBOL_GPL(dev_pm_opp_find_level_floor);
>> +
>> +/**
>>    * dev_pm_opp_find_bw_ceil() - Search for a rounded ceil bandwidth
>>    * @dev:	device for which we do this operation
>>    * @bw:	start bandwidth
>> diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h
>> index 91f87d7..baea92f 100644
>> --- a/include/linux/pm_opp.h
>> +++ b/include/linux/pm_opp.h
>> @@ -144,6 +144,9 @@ struct dev_pm_opp *dev_pm_opp_find_level_exact(struct device *dev,
>>   struct dev_pm_opp *dev_pm_opp_find_level_ceil(struct device *dev,
>>   					      unsigned int *level);
>>   
>> +struct dev_pm_opp *dev_pm_opp_find_level_floor(struct device *dev,
>> +					       unsigned long *level);
>> +
>>   struct dev_pm_opp *dev_pm_opp_find_bw_ceil(struct device *dev,
>>   					   unsigned int *bw, int index);
>>   
>> @@ -314,6 +317,12 @@ static inline struct dev_pm_opp *dev_pm_opp_find_bw_ceil(struct device *dev,
>>   	return ERR_PTR(-EOPNOTSUPP);
>>   }
>>   
>> +static inline struct dev_pm_opp *dev_pm_opp_find_level_floor(struct device *dev,
> Why add between two bw related functions ?
>
>> +							     unsigned long *level)
>> +{
>> +	return ERR_PTR(-EOPNOTSUPP);
>> +}
>> +
>>   static inline struct dev_pm_opp *dev_pm_opp_find_bw_floor(struct device *dev,
>>   					unsigned int *bw, int index)
>>   {
> Fixed all this and applied. Thanks.
>
I didn't notice this before, thanks for fixing and applying .

- KC
diff mbox series

Patch

diff --git a/drivers/opp/core.c b/drivers/opp/core.c
index 919cc53..6d4d226 100644
--- a/drivers/opp/core.c
+++ b/drivers/opp/core.c
@@ -814,6 +814,31 @@  struct dev_pm_opp *dev_pm_opp_find_level_ceil(struct device *dev,
 EXPORT_SYMBOL_GPL(dev_pm_opp_find_level_ceil);
 
 /**
+ * dev_pm_opp_find_level_floor() - Search for a rounded floor freq
+ * @dev:	device for which we do this operation
+ * @level:	Start level
+ *
+ * Search for the matching floor *available* OPP from a starting level
+ * for a device.
+ *
+ * Return: matching *opp and refreshes *level accordingly, else returns
+ * ERR_PTR in case of error and should be handled using IS_ERR. Error return
+ * values can be:
+ * EINVAL:	for bad pointer
+ * ERANGE:	no match found for search
+ * ENODEV:	if device not found in list of registered devices
+ *
+ * The callers are required to call dev_pm_opp_put() for the returned OPP after
+ * use.
+ */
+struct dev_pm_opp *dev_pm_opp_find_level_floor(struct device *dev,
+					       unsigned long *level)
+{
+	return _find_key_floor(dev, level, 0, true, _read_level, NULL);
+}
+EXPORT_SYMBOL_GPL(dev_pm_opp_find_level_floor);
+
+/**
  * dev_pm_opp_find_bw_ceil() - Search for a rounded ceil bandwidth
  * @dev:	device for which we do this operation
  * @bw:	start bandwidth
diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h
index 91f87d7..baea92f 100644
--- a/include/linux/pm_opp.h
+++ b/include/linux/pm_opp.h
@@ -144,6 +144,9 @@  struct dev_pm_opp *dev_pm_opp_find_level_exact(struct device *dev,
 struct dev_pm_opp *dev_pm_opp_find_level_ceil(struct device *dev,
 					      unsigned int *level);
 
+struct dev_pm_opp *dev_pm_opp_find_level_floor(struct device *dev,
+					       unsigned long *level);
+
 struct dev_pm_opp *dev_pm_opp_find_bw_ceil(struct device *dev,
 					   unsigned int *bw, int index);
 
@@ -314,6 +317,12 @@  static inline struct dev_pm_opp *dev_pm_opp_find_bw_ceil(struct device *dev,
 	return ERR_PTR(-EOPNOTSUPP);
 }
 
+static inline struct dev_pm_opp *dev_pm_opp_find_level_floor(struct device *dev,
+							     unsigned long *level)
+{
+	return ERR_PTR(-EOPNOTSUPP);
+}
+
 static inline struct dev_pm_opp *dev_pm_opp_find_bw_floor(struct device *dev,
 					unsigned int *bw, int index)
 {