diff mbox series

[1/2] interconnect: Add a common standard aggregate function

Message ID 20191128134839.27606-1-georgi.djakov@linaro.org (mailing list archive)
State Accepted
Commit 3172e4d276315afa82c12b14c8dd0db526c7aff1
Headers show
Series [1/2] interconnect: Add a common standard aggregate function | expand

Commit Message

Georgi Djakov Nov. 28, 2019, 1:48 p.m. UTC
Currently there is one very standard aggregation method that is used by
several drivers. Let's add this as a common function, so that drivers
could just point to it, instead of copy/pasting code.

Suggested-by: Evan Green <evgreen@chromium.org>
Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>
---
 drivers/interconnect/core.c           | 10 ++++++++++
 include/linux/interconnect-provider.h |  8 ++++++++
 2 files changed, 18 insertions(+)

Comments

Brian Masney Nov. 28, 2019, 3:15 p.m. UTC | #1
On Thu, Nov 28, 2019 at 03:48:38PM +0200, Georgi Djakov wrote:
> Currently there is one very standard aggregation method that is used by
> several drivers. Let's add this as a common function, so that drivers
> could just point to it, instead of copy/pasting code.
> 
> Suggested-by: Evan Green <evgreen@chromium.org>
> Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>

Reviewed-by: Brian Masney <masneyb@onstation.org>
Bjorn Andersson Nov. 28, 2019, 5:53 p.m. UTC | #2
On Thu 28 Nov 05:48 PST 2019, Georgi Djakov wrote:

> Currently there is one very standard aggregation method that is used by
> several drivers. Let's add this as a common function, so that drivers
> could just point to it, instead of copy/pasting code.
> 
> Suggested-by: Evan Green <evgreen@chromium.org>
> Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>

Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>

> ---
>  drivers/interconnect/core.c           | 10 ++++++++++
>  include/linux/interconnect-provider.h |  8 ++++++++
>  2 files changed, 18 insertions(+)
> 
> diff --git a/drivers/interconnect/core.c b/drivers/interconnect/core.c
> index 0e4852feb395..2633fd223875 100644
> --- a/drivers/interconnect/core.c
> +++ b/drivers/interconnect/core.c
> @@ -221,6 +221,16 @@ static int apply_constraints(struct icc_path *path)
>  	return ret;
>  }
>  
> +int icc_std_aggregate(struct icc_node *node, u32 tag, u32 avg_bw,
> +		      u32 peak_bw, u32 *agg_avg, u32 *agg_peak)
> +{
> +	*agg_avg += avg_bw;
> +	*agg_peak = max(*agg_peak, peak_bw);
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(icc_std_aggregate);
> +
>  /* of_icc_xlate_onecell() - Translate function using a single index.
>   * @spec: OF phandle args to map into an interconnect node.
>   * @data: private data (pointer to struct icc_onecell_data)
> diff --git a/include/linux/interconnect-provider.h b/include/linux/interconnect-provider.h
> index 31440c921216..0c494534b4d3 100644
> --- a/include/linux/interconnect-provider.h
> +++ b/include/linux/interconnect-provider.h
> @@ -92,6 +92,8 @@ struct icc_node {
>  
>  #if IS_ENABLED(CONFIG_INTERCONNECT)
>  
> +int icc_std_aggregate(struct icc_node *node, u32 tag, u32 avg_bw,
> +		      u32 peak_bw, u32 *agg_avg, u32 *agg_peak);
>  struct icc_node *icc_node_create(int id);
>  void icc_node_destroy(int id);
>  int icc_link_create(struct icc_node *node, const int dst_id);
> @@ -104,6 +106,12 @@ int icc_provider_del(struct icc_provider *provider);
>  
>  #else
>  
> +static inline int icc_std_aggregate(struct icc_node *node, u32 tag, u32 avg_bw,
> +				    u32 peak_bw, u32 *agg_avg, u32 *agg_peak)
> +{
> +	return -ENOTSUPP;
> +}
> +
>  static inline struct icc_node *icc_node_create(int id)
>  {
>  	return ERR_PTR(-ENOTSUPP);
Evan Green Dec. 6, 2019, 8:43 p.m. UTC | #3
On Thu, Nov 28, 2019 at 5:48 AM Georgi Djakov <georgi.djakov@linaro.org> wrote:
>
> Currently there is one very standard aggregation method that is used by
> several drivers. Let's add this as a common function, so that drivers
> could just point to it, instead of copy/pasting code.
>
> Suggested-by: Evan Green <evgreen@chromium.org>
> Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>

Reviewed-by: Evan Green <evgreen@chromium.org>
diff mbox series

Patch

diff --git a/drivers/interconnect/core.c b/drivers/interconnect/core.c
index 0e4852feb395..2633fd223875 100644
--- a/drivers/interconnect/core.c
+++ b/drivers/interconnect/core.c
@@ -221,6 +221,16 @@  static int apply_constraints(struct icc_path *path)
 	return ret;
 }
 
+int icc_std_aggregate(struct icc_node *node, u32 tag, u32 avg_bw,
+		      u32 peak_bw, u32 *agg_avg, u32 *agg_peak)
+{
+	*agg_avg += avg_bw;
+	*agg_peak = max(*agg_peak, peak_bw);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(icc_std_aggregate);
+
 /* of_icc_xlate_onecell() - Translate function using a single index.
  * @spec: OF phandle args to map into an interconnect node.
  * @data: private data (pointer to struct icc_onecell_data)
diff --git a/include/linux/interconnect-provider.h b/include/linux/interconnect-provider.h
index 31440c921216..0c494534b4d3 100644
--- a/include/linux/interconnect-provider.h
+++ b/include/linux/interconnect-provider.h
@@ -92,6 +92,8 @@  struct icc_node {
 
 #if IS_ENABLED(CONFIG_INTERCONNECT)
 
+int icc_std_aggregate(struct icc_node *node, u32 tag, u32 avg_bw,
+		      u32 peak_bw, u32 *agg_avg, u32 *agg_peak);
 struct icc_node *icc_node_create(int id);
 void icc_node_destroy(int id);
 int icc_link_create(struct icc_node *node, const int dst_id);
@@ -104,6 +106,12 @@  int icc_provider_del(struct icc_provider *provider);
 
 #else
 
+static inline int icc_std_aggregate(struct icc_node *node, u32 tag, u32 avg_bw,
+				    u32 peak_bw, u32 *agg_avg, u32 *agg_peak)
+{
+	return -ENOTSUPP;
+}
+
 static inline struct icc_node *icc_node_create(int id)
 {
 	return ERR_PTR(-ENOTSUPP);