Commit db6cd514 authored by Alex Elder's avatar Alex Elder Committed by Jakub Kicinski

net: ipa: store average and peak interconnect bandwidth

Add fields in the ipa_interconnect structure to hold the average and
peak bandwidth values for the interconnect.  Pass the configuring
data for interconnects to ipa_interconnect_init() so these values
can be recorded, and use them when enabling the interconnects.

There's no longer any need to keep a copy of the interconnect data
after initialization.
Signed-off-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 5b40810b
...@@ -33,9 +33,13 @@ ...@@ -33,9 +33,13 @@
/** /**
* struct ipa_interconnect - IPA interconnect information * struct ipa_interconnect - IPA interconnect information
* @path: Interconnect path * @path: Interconnect path
* @average_bandwidth: Average interconnect bandwidth (KB/second)
* @peak_bandwidth: Peak interconnect bandwidth (KB/second)
*/ */
struct ipa_interconnect { struct ipa_interconnect {
struct icc_path *path; struct icc_path *path;
u32 average_bandwidth;
u32 peak_bandwidth;
}; };
/** /**
...@@ -44,14 +48,12 @@ struct ipa_interconnect { ...@@ -44,14 +48,12 @@ struct ipa_interconnect {
* @mutex: Protects clock enable/disable * @mutex: Protects clock enable/disable
* @core: IPA core clock * @core: IPA core clock
* @interconnect: Interconnect array * @interconnect: Interconnect array
* @interconnect_data: Interconnect configuration data
*/ */
struct ipa_clock { struct ipa_clock {
refcount_t count; refcount_t count;
struct mutex mutex; /* protects clock enable/disable */ struct mutex mutex; /* protects clock enable/disable */
struct clk *core; struct clk *core;
struct ipa_interconnect *interconnect[IPA_INTERCONNECT_COUNT]; struct ipa_interconnect interconnect[IPA_INTERCONNECT_COUNT];
const struct ipa_interconnect_data *interconnect_data;
}; };
static struct icc_path * static struct icc_path *
...@@ -61,38 +63,52 @@ ipa_interconnect_init_one(struct device *dev, const char *name) ...@@ -61,38 +63,52 @@ ipa_interconnect_init_one(struct device *dev, const char *name)
path = of_icc_get(dev, name); path = of_icc_get(dev, name);
if (IS_ERR(path)) if (IS_ERR(path))
dev_err(dev, "error %ld getting %s interconnect\n", dev_err(dev, "error %d getting %s interconnect\n",
PTR_ERR(path), name); (int)PTR_ERR(path), name);
return path; return path;
} }
/* Initialize interconnects required for IPA operation */ /* Initialize interconnects required for IPA operation */
static int ipa_interconnect_init(struct ipa_clock *clock, struct device *dev) static int ipa_interconnect_init(struct ipa_clock *clock, struct device *dev,
const struct ipa_interconnect_data *data)
{ {
struct ipa_interconnect *interconnect;
struct icc_path *path; struct icc_path *path;
path = ipa_interconnect_init_one(dev, "memory"); path = ipa_interconnect_init_one(dev, "memory");
if (IS_ERR(path)) if (IS_ERR(path))
goto err_return; goto err_return;
clock->interconnect[IPA_INTERCONNECT_MEMORY]->path = path; interconnect = &clock->interconnect[IPA_INTERCONNECT_MEMORY];
interconnect->path = path;
interconnect->average_bandwidth = data->average_bandwidth;
interconnect->peak_bandwidth = data->peak_bandwidth;
data++;
path = ipa_interconnect_init_one(dev, "imem"); path = ipa_interconnect_init_one(dev, "imem");
if (IS_ERR(path)) if (IS_ERR(path))
goto err_memory_path_put; goto err_memory_path_put;
clock->interconnect[IPA_INTERCONNECT_IMEM]->path = path; interconnect = &clock->interconnect[IPA_INTERCONNECT_IMEM];
interconnect->path = path;
interconnect->average_bandwidth = data->average_bandwidth;
interconnect->peak_bandwidth = data->peak_bandwidth;
data++;
path = ipa_interconnect_init_one(dev, "config"); path = ipa_interconnect_init_one(dev, "config");
if (IS_ERR(path)) if (IS_ERR(path))
goto err_imem_path_put; goto err_imem_path_put;
clock->interconnect[IPA_INTERCONNECT_CONFIG]->path = path; interconnect = &clock->interconnect[IPA_INTERCONNECT_CONFIG];
interconnect->path = path;
interconnect->average_bandwidth = data->average_bandwidth;
interconnect->peak_bandwidth = data->peak_bandwidth;
data++;
return 0; return 0;
err_imem_path_put: err_imem_path_put:
icc_put(clock->interconnect[IPA_INTERCONNECT_IMEM]->path); icc_put(clock->interconnect[IPA_INTERCONNECT_IMEM].path);
err_memory_path_put: err_memory_path_put:
icc_put(clock->interconnect[IPA_INTERCONNECT_MEMORY]->path); icc_put(clock->interconnect[IPA_INTERCONNECT_MEMORY].path);
err_return: err_return:
return PTR_ERR(path); return PTR_ERR(path);
} }
...@@ -100,44 +116,44 @@ static int ipa_interconnect_init(struct ipa_clock *clock, struct device *dev) ...@@ -100,44 +116,44 @@ static int ipa_interconnect_init(struct ipa_clock *clock, struct device *dev)
/* Inverse of ipa_interconnect_init() */ /* Inverse of ipa_interconnect_init() */
static void ipa_interconnect_exit(struct ipa_clock *clock) static void ipa_interconnect_exit(struct ipa_clock *clock)
{ {
icc_put(clock->interconnect[IPA_INTERCONNECT_CONFIG]->path); icc_put(clock->interconnect[IPA_INTERCONNECT_CONFIG].path);
icc_put(clock->interconnect[IPA_INTERCONNECT_IMEM]->path); icc_put(clock->interconnect[IPA_INTERCONNECT_IMEM].path);
icc_put(clock->interconnect[IPA_INTERCONNECT_MEMORY]->path); icc_put(clock->interconnect[IPA_INTERCONNECT_MEMORY].path);
} }
/* Currently we only use one bandwidth level, so just "enable" interconnects */ /* Currently we only use one bandwidth level, so just "enable" interconnects */
static int ipa_interconnect_enable(struct ipa *ipa) static int ipa_interconnect_enable(struct ipa *ipa)
{ {
const struct ipa_interconnect_data *data; struct ipa_interconnect *interconnect;
struct ipa_clock *clock = ipa->clock; struct ipa_clock *clock = ipa->clock;
int ret; int ret;
data = &clock->interconnect_data[IPA_INTERCONNECT_MEMORY]; interconnect = &clock->interconnect[IPA_INTERCONNECT_MEMORY];
ret = icc_set_bw(clock->interconnect[IPA_INTERCONNECT_MEMORY]->path, ret = icc_set_bw(interconnect->path, interconnect->average_bandwidth,
data->average_bandwidth, data->peak_bandwidth); interconnect->peak_bandwidth);
if (ret) if (ret)
return ret; return ret;
data = &clock->interconnect_data[IPA_INTERCONNECT_IMEM]; interconnect = &clock->interconnect[IPA_INTERCONNECT_IMEM];
ret = icc_set_bw(clock->interconnect[IPA_INTERCONNECT_IMEM]->path, ret = icc_set_bw(interconnect->path, interconnect->average_bandwidth,
data->average_bandwidth, data->peak_bandwidth); interconnect->peak_bandwidth);
if (ret) if (ret)
goto err_memory_path_disable; goto err_memory_path_disable;
data = &clock->interconnect_data[IPA_INTERCONNECT_CONFIG]; interconnect = &clock->interconnect[IPA_INTERCONNECT_CONFIG];
ret = icc_set_bw(clock->interconnect[IPA_INTERCONNECT_CONFIG]->path, ret = icc_set_bw(interconnect->path, interconnect->average_bandwidth,
data->average_bandwidth, data->peak_bandwidth); interconnect->peak_bandwidth);
if (ret) if (ret)
goto err_imem_path_disable; goto err_imem_path_disable;
return 0; return 0;
err_imem_path_disable: err_imem_path_disable:
(void)icc_set_bw(clock->interconnect[IPA_INTERCONNECT_IMEM]->path, interconnect = &clock->interconnect[IPA_INTERCONNECT_IMEM];
0, 0); (void)icc_set_bw(interconnect->path, 0, 0);
err_memory_path_disable: err_memory_path_disable:
(void)icc_set_bw(clock->interconnect[IPA_INTERCONNECT_MEMORY]->path, interconnect = &clock->interconnect[IPA_INTERCONNECT_MEMORY];
0, 0); (void)icc_set_bw(interconnect->path, 0, 0);
return ret; return ret;
} }
...@@ -145,22 +161,23 @@ static int ipa_interconnect_enable(struct ipa *ipa) ...@@ -145,22 +161,23 @@ static int ipa_interconnect_enable(struct ipa *ipa)
/* To disable an interconnect, we just its bandwidth to 0 */ /* To disable an interconnect, we just its bandwidth to 0 */
static void ipa_interconnect_disable(struct ipa *ipa) static void ipa_interconnect_disable(struct ipa *ipa)
{ {
struct ipa_interconnect *interconnect;
struct ipa_clock *clock = ipa->clock; struct ipa_clock *clock = ipa->clock;
int result = 0; int result = 0;
int ret; int ret;
ret = icc_set_bw(clock->interconnect[IPA_INTERCONNECT_MEMORY]->path, interconnect = &clock->interconnect[IPA_INTERCONNECT_MEMORY];
0, 0); ret = icc_set_bw(interconnect->path, 0, 0);
if (ret) if (ret)
result = ret; result = ret;
ret = icc_set_bw(clock->interconnect[IPA_INTERCONNECT_IMEM]->path, interconnect = &clock->interconnect[IPA_INTERCONNECT_IMEM];
0, 0); ret = icc_set_bw(interconnect->path, 0, 0);
if (ret && !result) if (ret && !result)
result = ret; result = ret;
ret = icc_set_bw(clock->interconnect[IPA_INTERCONNECT_CONFIG]->path, interconnect = &clock->interconnect[IPA_INTERCONNECT_IMEM];
0, 0); ret = icc_set_bw(interconnect->path, 0, 0);
if (ret && !result) if (ret && !result)
result = ret; result = ret;
...@@ -286,9 +303,8 @@ ipa_clock_init(struct device *dev, const struct ipa_clock_data *data) ...@@ -286,9 +303,8 @@ ipa_clock_init(struct device *dev, const struct ipa_clock_data *data)
goto err_clk_put; goto err_clk_put;
} }
clock->core = clk; clock->core = clk;
clock->interconnect_data = data->interconnect;
ret = ipa_interconnect_init(clock, dev); ret = ipa_interconnect_init(clock, dev, data->interconnect);
if (ret) if (ret)
goto err_kfree; goto err_kfree;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment