2022-03-09 20:25:32

by Alex Elder

[permalink] [raw]
Subject: [PATCH net-next v2 0/7] net: ipa: use bulk interconnect interfaces

The IPA code currently enables and disables interconnects by setting
the bandwidth of each to a non-zero value, or to zero. The
interconnect API now supports enable/disable functions, so we can
use those instead. In addition, the interconnect API provides bulk
interfaces that allow all interconnects to be operated on at once.

This series converts the IPA driver to use the bulk enable and
disable interfaces. In the process it uses some existing data
structures rather than defining new ones.

Version 2 contains the same code as version 1; it's just rebased.
Now that commit 1dba41c9d2e2d ("net: ipa: add an interconnect
dependency") is in net-next/master the COMPILE_TEST build error
reported for the original version should be gone.
https://lore.kernel.org/all/20220204202336.67c95e15@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com/

-Alex

Alex Elder (7):
net: ipa: kill struct ipa_interconnect
net: ipa: use icc_enable() and icc_disable()
net: ipa: use interconnect bulk enable/disable operations
net: ipa: use bulk operations to set up interconnects
net: ipa: use bulk interconnect initialization
net: ipa: embed interconnect array in the power structure
net: ipa: use IPA power device pointer

drivers/net/ipa/ipa_power.c | 178 +++++++++---------------------------
1 file changed, 42 insertions(+), 136 deletions(-)

--
2.32.0


2022-03-09 23:54:48

by Alex Elder

[permalink] [raw]
Subject: [PATCH net-next v2 4/7] net: ipa: use bulk operations to set up interconnects

Use of_icc_bulk_get() and icc_bulk_put(), icc_bulk_set_bw(), and
icc_bulk_enable() and icc_bulk_disable() to initialize individual
IPA interconnects. Those functions already log messages in the
event of error so we don't need to.

Signed-off-by: Alex Elder <[email protected]>
---
drivers/net/ipa/ipa_power.c | 40 ++++++++++++++-----------------------
1 file changed, 15 insertions(+), 25 deletions(-)

diff --git a/drivers/net/ipa/ipa_power.c b/drivers/net/ipa/ipa_power.c
index 67f76e6a6ae59..c0da1274f5d67 100644
--- a/drivers/net/ipa/ipa_power.c
+++ b/drivers/net/ipa/ipa_power.c
@@ -74,41 +74,31 @@ static int ipa_interconnect_init_one(struct device *dev,
struct icc_bulk_data *interconnect,
const struct ipa_interconnect_data *data)
{
- struct icc_path *path;
int ret;

- path = of_icc_get(dev, data->name);
- if (IS_ERR(path)) {
- ret = PTR_ERR(path);
- dev_err_probe(dev, ret, "error getting %s interconnect\n",
- data->name);
-
- return ret;
- }
-
- /* All interconnects are initially disabled */
- (void)icc_disable(path);
-
- /* Set the bandwidth values to be used when enabled */
- ret = icc_set_bw(path, data->average_bandwidth, data->peak_bandwidth);
- if (ret) {
- dev_err(dev, "error %d setting %s interconnect bandwidths\n",
- ret, data->name);
-
- return ret;
- }
-
- interconnect->path = path;
+ /* interconnect->path is filled in by of_icc_bulk_get() */
interconnect->name = data->name;
interconnect->avg_bw = data->average_bandwidth;
interconnect->peak_bw = data->peak_bandwidth;

- return 0;
+ ret = of_icc_bulk_get(dev, 1, interconnect);
+ if (ret)
+ return ret;
+
+ /* All interconnects are initially disabled */
+ icc_bulk_disable(1, interconnect);
+
+ /* Set the bandwidth values to be used when enabled */
+ ret = icc_bulk_set_bw(1, interconnect);
+ if (ret)
+ icc_bulk_put(1, interconnect);
+
+ return ret;
}

static void ipa_interconnect_exit_one(struct icc_bulk_data *interconnect)
{
- icc_put(interconnect->path);
+ icc_bulk_put(1, interconnect);
memset(interconnect, 0, sizeof(*interconnect));
}

--
2.32.0

2022-03-10 00:00:01

by Alex Elder

[permalink] [raw]
Subject: [PATCH net-next v2 5/7] net: ipa: use bulk interconnect initialization

The previous patch used bulk interconnect operations to initialize
IPA interconnects one at a time. This rearranges things to use the
bulk interfaces as intended--on all interconnects together. As a
result ipa_interconnect_init_one() and ipa_interconnect_exit_one()
are no longer needed.

Signed-off-by: Alex Elder <[email protected]>
---
drivers/net/ipa/ipa_power.c | 66 +++++++++++++------------------------
1 file changed, 23 insertions(+), 43 deletions(-)

diff --git a/drivers/net/ipa/ipa_power.c b/drivers/net/ipa/ipa_power.c
index c0da1274f5d67..b1f6978dddadb 100644
--- a/drivers/net/ipa/ipa_power.c
+++ b/drivers/net/ipa/ipa_power.c
@@ -70,38 +70,6 @@ struct ipa_power {
struct icc_bulk_data *interconnect;
};

-static int ipa_interconnect_init_one(struct device *dev,
- struct icc_bulk_data *interconnect,
- const struct ipa_interconnect_data *data)
-{
- int ret;
-
- /* interconnect->path is filled in by of_icc_bulk_get() */
- interconnect->name = data->name;
- interconnect->avg_bw = data->average_bandwidth;
- interconnect->peak_bw = data->peak_bandwidth;
-
- ret = of_icc_bulk_get(dev, 1, interconnect);
- if (ret)
- return ret;
-
- /* All interconnects are initially disabled */
- icc_bulk_disable(1, interconnect);
-
- /* Set the bandwidth values to be used when enabled */
- ret = icc_bulk_set_bw(1, interconnect);
- if (ret)
- icc_bulk_put(1, interconnect);
-
- return ret;
-}
-
-static void ipa_interconnect_exit_one(struct icc_bulk_data *interconnect)
-{
- icc_bulk_put(1, interconnect);
- memset(interconnect, 0, sizeof(*interconnect));
-}
-
/* Initialize interconnects required for IPA operation */
static int ipa_interconnect_init(struct ipa_power *power, struct device *dev,
const struct ipa_interconnect_data *data)
@@ -116,18 +84,34 @@ static int ipa_interconnect_init(struct ipa_power *power, struct device *dev,
return -ENOMEM;
power->interconnect = interconnect;

+ /* Initialize our interconnect data array for bulk operations */
while (count--) {
- ret = ipa_interconnect_init_one(dev, interconnect, data++);
- if (ret)
- goto out_unwind;
+ /* interconnect->path is filled in by of_icc_bulk_get() */
+ interconnect->name = data->name;
+ interconnect->avg_bw = data->average_bandwidth;
+ interconnect->peak_bw = data->peak_bandwidth;
+ data++;
interconnect++;
}

+ ret = of_icc_bulk_get(dev, power->interconnect_count,
+ power->interconnect);
+ if (ret)
+ goto err_free;
+
+ /* All interconnects are initially disabled */
+ icc_bulk_disable(power->interconnect_count, power->interconnect);
+
+ /* Set the bandwidth values to be used when enabled */
+ ret = icc_bulk_set_bw(power->interconnect_count, power->interconnect);
+ if (ret)
+ goto err_bulk_put;
+
return 0;

-out_unwind:
- while (interconnect-- > power->interconnect)
- ipa_interconnect_exit_one(interconnect);
+err_bulk_put:
+ icc_bulk_put(power->interconnect_count, power->interconnect);
+err_free:
kfree(power->interconnect);
power->interconnect = NULL;

@@ -137,11 +121,7 @@ static int ipa_interconnect_init(struct ipa_power *power, struct device *dev,
/* Inverse of ipa_interconnect_init() */
static void ipa_interconnect_exit(struct ipa_power *power)
{
- struct icc_bulk_data *interconnect;
-
- interconnect = power->interconnect + power->interconnect_count;
- while (interconnect-- > power->interconnect)
- ipa_interconnect_exit_one(interconnect);
+ icc_bulk_put(power->interconnect_count, power->interconnect);
kfree(power->interconnect);
power->interconnect = NULL;
}
--
2.32.0

2022-03-10 03:17:58

by Alex Elder

[permalink] [raw]
Subject: [PATCH net-next v2 1/7] net: ipa: kill struct ipa_interconnect

The ipa_interconnect structure contains an icc_path pointer, plus an
average and peak bandwidth value. Other than the interconnect name,
this matches the icc_bulk_data structure exactly.

Use the icc_bulk_data structure in place of the ipa_interconnect
structure, and add an initialization of its name field. Then get
rid of the now unnecessary ipa_interconnect structure definition.

Signed-off-by: Alex Elder <[email protected]>
---
drivers/net/ipa/ipa_power.c | 39 +++++++++++++------------------------
1 file changed, 14 insertions(+), 25 deletions(-)

diff --git a/drivers/net/ipa/ipa_power.c b/drivers/net/ipa/ipa_power.c
index f2989aac47a62..28be0e45cccfd 100644
--- a/drivers/net/ipa/ipa_power.c
+++ b/drivers/net/ipa/ipa_power.c
@@ -34,18 +34,6 @@

#define IPA_AUTOSUSPEND_DELAY 500 /* milliseconds */

-/**
- * struct ipa_interconnect - IPA interconnect information
- * @path: Interconnect path
- * @average_bandwidth: Average interconnect bandwidth (KB/second)
- * @peak_bandwidth: Peak interconnect bandwidth (KB/second)
- */
-struct ipa_interconnect {
- struct icc_path *path;
- u32 average_bandwidth;
- u32 peak_bandwidth;
-};
-
/**
* enum ipa_power_flag - IPA power flags
* @IPA_POWER_FLAG_RESUMED: Whether resume from suspend has been signaled
@@ -79,11 +67,11 @@ struct ipa_power {
spinlock_t spinlock; /* used with STOPPED/STARTED power flags */
DECLARE_BITMAP(flags, IPA_POWER_FLAG_COUNT);
u32 interconnect_count;
- struct ipa_interconnect *interconnect;
+ struct icc_bulk_data *interconnect;
};

static int ipa_interconnect_init_one(struct device *dev,
- struct ipa_interconnect *interconnect,
+ struct icc_bulk_data *interconnect,
const struct ipa_interconnect_data *data)
{
struct icc_path *path;
@@ -99,13 +87,14 @@ static int ipa_interconnect_init_one(struct device *dev,
}

interconnect->path = path;
- interconnect->average_bandwidth = data->average_bandwidth;
- interconnect->peak_bandwidth = data->peak_bandwidth;
+ interconnect->name = data->name;
+ interconnect->avg_bw = data->average_bandwidth;
+ interconnect->peak_bw = data->peak_bandwidth;

return 0;
}

-static void ipa_interconnect_exit_one(struct ipa_interconnect *interconnect)
+static void ipa_interconnect_exit_one(struct icc_bulk_data *interconnect)
{
icc_put(interconnect->path);
memset(interconnect, 0, sizeof(*interconnect));
@@ -115,7 +104,7 @@ static void ipa_interconnect_exit_one(struct ipa_interconnect *interconnect)
static int ipa_interconnect_init(struct ipa_power *power, struct device *dev,
const struct ipa_interconnect_data *data)
{
- struct ipa_interconnect *interconnect;
+ struct icc_bulk_data *interconnect;
u32 count;
int ret;

@@ -146,7 +135,7 @@ static int ipa_interconnect_init(struct ipa_power *power, struct device *dev,
/* Inverse of ipa_interconnect_init() */
static void ipa_interconnect_exit(struct ipa_power *power)
{
- struct ipa_interconnect *interconnect;
+ struct icc_bulk_data *interconnect;

interconnect = power->interconnect + power->interconnect_count;
while (interconnect-- > power->interconnect)
@@ -158,7 +147,7 @@ static void ipa_interconnect_exit(struct ipa_power *power)
/* Currently we only use one bandwidth level, so just "enable" interconnects */
static int ipa_interconnect_enable(struct ipa *ipa)
{
- struct ipa_interconnect *interconnect;
+ struct icc_bulk_data *interconnect;
struct ipa_power *power = ipa->power;
int ret;
u32 i;
@@ -166,12 +155,12 @@ static int ipa_interconnect_enable(struct ipa *ipa)
interconnect = power->interconnect;
for (i = 0; i < power->interconnect_count; i++) {
ret = icc_set_bw(interconnect->path,
- interconnect->average_bandwidth,
- interconnect->peak_bandwidth);
+ interconnect->avg_bw,
+ interconnect->peak_bw);
if (ret) {
dev_err(&ipa->pdev->dev,
"error %d enabling %s interconnect\n",
- ret, icc_get_name(interconnect->path));
+ ret, interconnect->name);
goto out_unwind;
}
interconnect++;
@@ -189,9 +178,9 @@ static int ipa_interconnect_enable(struct ipa *ipa)
/* To disable an interconnect, we just its bandwidth to 0 */
static int ipa_interconnect_disable(struct ipa *ipa)
{
- struct ipa_interconnect *interconnect;
struct ipa_power *power = ipa->power;
struct device *dev = &ipa->pdev->dev;
+ struct icc_bulk_data *interconnect;
int result = 0;
u32 count;
int ret;
@@ -203,7 +192,7 @@ static int ipa_interconnect_disable(struct ipa *ipa)
ret = icc_set_bw(interconnect->path, 0, 0);
if (ret) {
dev_err(dev, "error %d disabling %s interconnect\n",
- ret, icc_get_name(interconnect->path));
+ ret, interconnect->name);
/* Try to disable all; record only the first error */
if (!result)
result = ret;
--
2.32.0

2022-03-10 08:48:43

by Alex Elder

[permalink] [raw]
Subject: [PATCH net-next v2 6/7] net: ipa: embed interconnect array in the power structure

Rather than allocating the interconnect array dynamically, represent
the interconnects with a variable-length array at the end of the
ipa_power structure.

Signed-off-by: Alex Elder <[email protected]>
---
drivers/net/ipa/ipa_power.c | 31 +++++++++----------------------
1 file changed, 9 insertions(+), 22 deletions(-)

diff --git a/drivers/net/ipa/ipa_power.c b/drivers/net/ipa/ipa_power.c
index b1f6978dddadb..8a564d72799da 100644
--- a/drivers/net/ipa/ipa_power.c
+++ b/drivers/net/ipa/ipa_power.c
@@ -67,7 +67,7 @@ struct ipa_power {
spinlock_t spinlock; /* used with STOPPED/STARTED power flags */
DECLARE_BITMAP(flags, IPA_POWER_FLAG_COUNT);
u32 interconnect_count;
- struct icc_bulk_data *interconnect;
+ struct icc_bulk_data interconnect[];
};

/* Initialize interconnects required for IPA operation */
@@ -75,17 +75,12 @@ static int ipa_interconnect_init(struct ipa_power *power, struct device *dev,
const struct ipa_interconnect_data *data)
{
struct icc_bulk_data *interconnect;
- u32 count;
int ret;
-
- count = power->interconnect_count;
- interconnect = kcalloc(count, sizeof(*interconnect), GFP_KERNEL);
- if (!interconnect)
- return -ENOMEM;
- power->interconnect = interconnect;
+ u32 i;

/* Initialize our interconnect data array for bulk operations */
- while (count--) {
+ interconnect = &power->interconnect[0];
+ for (i = 0; i < power->interconnect_count; i++) {
/* interconnect->path is filled in by of_icc_bulk_get() */
interconnect->name = data->name;
interconnect->avg_bw = data->average_bandwidth;
@@ -97,7 +92,7 @@ static int ipa_interconnect_init(struct ipa_power *power, struct device *dev,
ret = of_icc_bulk_get(dev, power->interconnect_count,
power->interconnect);
if (ret)
- goto err_free;
+ return ret;

/* All interconnects are initially disabled */
icc_bulk_disable(power->interconnect_count, power->interconnect);
@@ -105,15 +100,7 @@ static int ipa_interconnect_init(struct ipa_power *power, struct device *dev,
/* Set the bandwidth values to be used when enabled */
ret = icc_bulk_set_bw(power->interconnect_count, power->interconnect);
if (ret)
- goto err_bulk_put;
-
- return 0;
-
-err_bulk_put:
- icc_bulk_put(power->interconnect_count, power->interconnect);
-err_free:
- kfree(power->interconnect);
- power->interconnect = NULL;
+ icc_bulk_put(power->interconnect_count, power->interconnect);

return ret;
}
@@ -122,8 +109,6 @@ static int ipa_interconnect_init(struct ipa_power *power, struct device *dev,
static void ipa_interconnect_exit(struct ipa_power *power)
{
icc_bulk_put(power->interconnect_count, power->interconnect);
- kfree(power->interconnect);
- power->interconnect = NULL;
}

/* Enable IPA power, enabling interconnects and the core clock */
@@ -372,6 +357,7 @@ ipa_power_init(struct device *dev, const struct ipa_power_data *data)
{
struct ipa_power *power;
struct clk *clk;
+ size_t size;
int ret;

clk = clk_get(dev, "core");
@@ -388,7 +374,8 @@ ipa_power_init(struct device *dev, const struct ipa_power_data *data)
goto err_clk_put;
}

- power = kzalloc(sizeof(*power), GFP_KERNEL);
+ size = data->interconnect_count * sizeof(power->interconnect[0]);
+ power = kzalloc(sizeof(*power) + size, GFP_KERNEL);
if (!power) {
ret = -ENOMEM;
goto err_clk_put;
--
2.32.0

2022-03-10 09:19:22

by Alex Elder

[permalink] [raw]
Subject: [PATCH net-next v2 7/7] net: ipa: use IPA power device pointer

The ipa_power structure contains a copy of the IPA device pointer,
so there's no need to pass it to ipa_interconnect_init(). We can
also use that pointer for an error message in ipa_power_enable().

Signed-off-by: Alex Elder <[email protected]>
---
drivers/net/ipa/ipa_power.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ipa/ipa_power.c b/drivers/net/ipa/ipa_power.c
index 8a564d72799da..16ece27d14d7e 100644
--- a/drivers/net/ipa/ipa_power.c
+++ b/drivers/net/ipa/ipa_power.c
@@ -71,7 +71,7 @@ struct ipa_power {
};

/* Initialize interconnects required for IPA operation */
-static int ipa_interconnect_init(struct ipa_power *power, struct device *dev,
+static int ipa_interconnect_init(struct ipa_power *power,
const struct ipa_interconnect_data *data)
{
struct icc_bulk_data *interconnect;
@@ -89,7 +89,7 @@ static int ipa_interconnect_init(struct ipa_power *power, struct device *dev,
interconnect++;
}

- ret = of_icc_bulk_get(dev, power->interconnect_count,
+ ret = of_icc_bulk_get(power->dev, power->interconnect_count,
power->interconnect);
if (ret)
return ret;
@@ -123,7 +123,7 @@ static int ipa_power_enable(struct ipa *ipa)

ret = clk_prepare_enable(power->core);
if (ret) {
- dev_err(&ipa->pdev->dev, "error %d enabling core clock\n", ret);
+ dev_err(power->dev, "error %d enabling core clock\n", ret);
icc_bulk_disable(power->interconnect_count,
power->interconnect);
}
@@ -385,7 +385,7 @@ ipa_power_init(struct device *dev, const struct ipa_power_data *data)
spin_lock_init(&power->spinlock);
power->interconnect_count = data->interconnect_count;

- ret = ipa_interconnect_init(power, dev, data->interconnect_data);
+ ret = ipa_interconnect_init(power, data->interconnect_data);
if (ret)
goto err_kfree;

--
2.32.0

2022-03-10 13:37:30

by Alex Elder

[permalink] [raw]
Subject: [PATCH net-next v2 3/7] net: ipa: use interconnect bulk enable/disable operations

The power interconnect array is now an array of icc_bulk_data
structures, which is what the interconnect bulk enable and disable
functions require.

Get rid of ipa_interconnect_enable() and ipa_interconnect_disable(),
and just call icc_bulk_enable() and icc_bulk_disable() instead.

Signed-off-by: Alex Elder <[email protected]>
---
drivers/net/ipa/ipa_power.c | 76 +++++++------------------------------
1 file changed, 13 insertions(+), 63 deletions(-)

diff --git a/drivers/net/ipa/ipa_power.c b/drivers/net/ipa/ipa_power.c
index ec2ebc74edb8b..67f76e6a6ae59 100644
--- a/drivers/net/ipa/ipa_power.c
+++ b/drivers/net/ipa/ipa_power.c
@@ -156,86 +156,34 @@ static void ipa_interconnect_exit(struct ipa_power *power)
power->interconnect = NULL;
}

-/* Currently we only use one bandwidth level, so just "enable" interconnects */
-static int ipa_interconnect_enable(struct ipa *ipa)
-{
- struct icc_bulk_data *interconnect;
- struct ipa_power *power = ipa->power;
- int ret;
- u32 i;
-
- interconnect = power->interconnect;
- for (i = 0; i < power->interconnect_count; i++) {
- ret = icc_enable(interconnect->path);
- if (ret) {
- dev_err(&ipa->pdev->dev,
- "error %d enabling %s interconnect\n",
- ret, interconnect->name);
- goto out_unwind;
- }
- interconnect++;
- }
-
- return 0;
-
-out_unwind:
- while (interconnect-- > power->interconnect)
- (void)icc_disable(interconnect->path);
-
- return ret;
-}
-
-/* To disable an interconnect, we just its bandwidth to 0 */
-static int ipa_interconnect_disable(struct ipa *ipa)
-{
- struct ipa_power *power = ipa->power;
- struct device *dev = &ipa->pdev->dev;
- struct icc_bulk_data *interconnect;
- int result = 0;
- u32 count;
- int ret;
-
- count = power->interconnect_count;
- interconnect = power->interconnect + count;
- while (count--) {
- interconnect--;
- ret = icc_disable(interconnect->path);
- if (ret) {
- dev_err(dev, "error %d disabling %s interconnect\n",
- ret, interconnect->name);
- /* Try to disable all; record only the first error */
- if (!result)
- result = ret;
- }
- }
-
- return result;
-}
-
/* Enable IPA power, enabling interconnects and the core clock */
static int ipa_power_enable(struct ipa *ipa)
{
+ struct ipa_power *power = ipa->power;
int ret;

- ret = ipa_interconnect_enable(ipa);
+ ret = icc_bulk_enable(power->interconnect_count, power->interconnect);
if (ret)
return ret;

- ret = clk_prepare_enable(ipa->power->core);
+ ret = clk_prepare_enable(power->core);
if (ret) {
dev_err(&ipa->pdev->dev, "error %d enabling core clock\n", ret);
- (void)ipa_interconnect_disable(ipa);
+ icc_bulk_disable(power->interconnect_count,
+ power->interconnect);
}

return ret;
}

/* Inverse of ipa_power_enable() */
-static int ipa_power_disable(struct ipa *ipa)
+static void ipa_power_disable(struct ipa *ipa)
{
- clk_disable_unprepare(ipa->power->core);
+ struct ipa_power *power = ipa->power;

- return ipa_interconnect_disable(ipa);
+ clk_disable_unprepare(power->core);
+
+ icc_bulk_disable(power->interconnect_count, power->interconnect);
}

static int ipa_runtime_suspend(struct device *dev)
@@ -249,7 +197,9 @@ static int ipa_runtime_suspend(struct device *dev)
gsi_suspend(&ipa->gsi);
}

- return ipa_power_disable(ipa);
+ ipa_power_disable(ipa);
+
+ return 0;
}

static int ipa_runtime_resume(struct device *dev)
--
2.32.0

2022-03-10 13:43:51

by Alex Elder

[permalink] [raw]
Subject: [PATCH net-next v2 2/7] net: ipa: use icc_enable() and icc_disable()

The interconnect framework now provides the ability to enable and
disable interconnects without having to change their recorded
"enabled" bandwidth value. Use this mechanism, rather than setting
the bandwidth values to zero and non-zero respectively to disable
and enable the IPA interconnects.

Disable each interconnect before setting its "enabled" average and
peak bandwidth values. Thereafter, enable and disable interconnects
when required rather than setting their bandwidths.

Signed-off-by: Alex Elder <[email protected]>
---
drivers/net/ipa/ipa_power.c | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ipa/ipa_power.c b/drivers/net/ipa/ipa_power.c
index 28be0e45cccfd..ec2ebc74edb8b 100644
--- a/drivers/net/ipa/ipa_power.c
+++ b/drivers/net/ipa/ipa_power.c
@@ -75,17 +75,29 @@ static int ipa_interconnect_init_one(struct device *dev,
const struct ipa_interconnect_data *data)
{
struct icc_path *path;
+ int ret;

path = of_icc_get(dev, data->name);
if (IS_ERR(path)) {
- int ret = PTR_ERR(path);
-
+ ret = PTR_ERR(path);
dev_err_probe(dev, ret, "error getting %s interconnect\n",
data->name);

return ret;
}

+ /* All interconnects are initially disabled */
+ (void)icc_disable(path);
+
+ /* Set the bandwidth values to be used when enabled */
+ ret = icc_set_bw(path, data->average_bandwidth, data->peak_bandwidth);
+ if (ret) {
+ dev_err(dev, "error %d setting %s interconnect bandwidths\n",
+ ret, data->name);
+
+ return ret;
+ }
+
interconnect->path = path;
interconnect->name = data->name;
interconnect->avg_bw = data->average_bandwidth;
@@ -154,9 +166,7 @@ static int ipa_interconnect_enable(struct ipa *ipa)

interconnect = power->interconnect;
for (i = 0; i < power->interconnect_count; i++) {
- ret = icc_set_bw(interconnect->path,
- interconnect->avg_bw,
- interconnect->peak_bw);
+ ret = icc_enable(interconnect->path);
if (ret) {
dev_err(&ipa->pdev->dev,
"error %d enabling %s interconnect\n",
@@ -170,7 +180,7 @@ static int ipa_interconnect_enable(struct ipa *ipa)

out_unwind:
while (interconnect-- > power->interconnect)
- (void)icc_set_bw(interconnect->path, 0, 0);
+ (void)icc_disable(interconnect->path);

return ret;
}
@@ -189,7 +199,7 @@ static int ipa_interconnect_disable(struct ipa *ipa)
interconnect = power->interconnect + count;
while (count--) {
interconnect--;
- ret = icc_set_bw(interconnect->path, 0, 0);
+ ret = icc_disable(interconnect->path);
if (ret) {
dev_err(dev, "error %d disabling %s interconnect\n",
ret, interconnect->name);
--
2.32.0

2022-03-11 05:59:46

by patchwork-bot+netdevbpf

[permalink] [raw]
Subject: Re: [PATCH net-next v2 0/7] net: ipa: use bulk interconnect interfaces

Hello:

This series was applied to netdev/net-next.git (master)
by Jakub Kicinski <[email protected]>:

On Wed, 9 Mar 2022 13:20:30 -0600 you wrote:
> The IPA code currently enables and disables interconnects by setting
> the bandwidth of each to a non-zero value, or to zero. The
> interconnect API now supports enable/disable functions, so we can
> use those instead. In addition, the interconnect API provides bulk
> interfaces that allow all interconnects to be operated on at once.
>
> This series converts the IPA driver to use the bulk enable and
> disable interfaces. In the process it uses some existing data
> structures rather than defining new ones.
>
> [...]

Here is the summary with links:
- [net-next,v2,1/7] net: ipa: kill struct ipa_interconnect
https://git.kernel.org/netdev/net-next/c/c7be12fa2fcc
- [net-next,v2,2/7] net: ipa: use icc_enable() and icc_disable()
https://git.kernel.org/netdev/net-next/c/9dd50068916c
- [net-next,v2,3/7] net: ipa: use interconnect bulk enable/disable operations
(no matching commit)
- [net-next,v2,4/7] net: ipa: use bulk operations to set up interconnects
(no matching commit)
- [net-next,v2,5/7] net: ipa: use bulk interconnect initialization
https://git.kernel.org/netdev/net-next/c/63ac8cce5063
- [net-next,v2,6/7] net: ipa: embed interconnect array in the power structure
https://git.kernel.org/netdev/net-next/c/8ee7ec4890e2
- [net-next,v2,7/7] net: ipa: use IPA power device pointer
https://git.kernel.org/netdev/net-next/c/37e0cf33f8a1

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html


2022-03-11 11:31:34

by Jakub Kicinski

[permalink] [raw]
Subject: Re: [PATCH net-next v2 6/7] net: ipa: embed interconnect array in the power structure

On Wed, 9 Mar 2022 13:20:36 -0600 Alex Elder wrote:
> - power = kzalloc(sizeof(*power), GFP_KERNEL);
> + size = data->interconnect_count * sizeof(power->interconnect[0]);
> + power = kzalloc(sizeof(*power) + size, GFP_KERNEL);

struct_size(), can be a follow up

2022-03-11 21:02:03

by Alex Elder

[permalink] [raw]
Subject: Re: [PATCH net-next v2 6/7] net: ipa: embed interconnect array in the power structure

On 3/10/22 11:25 PM, Jakub Kicinski wrote:
> On Wed, 9 Mar 2022 13:20:36 -0600 Alex Elder wrote:
>> - power = kzalloc(sizeof(*power), GFP_KERNEL);
>> + size = data->interconnect_count * sizeof(power->interconnect[0]);
>> + power = kzalloc(sizeof(*power) + size, GFP_KERNEL);
>
> struct_size(), can be a follow up

I can do that today; I'll look for other instances in the
driver where this could be done as well. Thanks.

-Alex