Skip to content

Commit

Permalink
net: ipa: improve IPA clock error messages
Browse files Browse the repository at this point in the history
Rearrange messages reported when errors occur in the IPA clock code,
so that the specific interconnect is identified when an error occurs
enabling or disabling it, or the core clock is indicated when an
error occurs enabling it.

Have ipa_interconnect_disable() return zero or the negative error
value returned by the first interconnect that produced an error
when disabled.  For now, the callers ignore the returned value.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Alex Elder authored and David S. Miller committed Aug 5, 2021
1 parent 10cc73c commit 8ee7c40
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions drivers/net/ipa/ipa_clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,12 @@ static int ipa_interconnect_enable(struct ipa *ipa)
ret = icc_set_bw(interconnect->path,
interconnect->average_bandwidth,
interconnect->peak_bandwidth);
if (ret)
if (ret) {
dev_err(&ipa->pdev->dev,
"error %d enabling %s interconnect\n",
ret, icc_get_name(interconnect->path));
goto out_unwind;
}
interconnect++;
}

Expand All @@ -159,10 +163,11 @@ static int ipa_interconnect_enable(struct ipa *ipa)
}

/* To disable an interconnect, we just its bandwidth to 0 */
static void ipa_interconnect_disable(struct ipa *ipa)
static int ipa_interconnect_disable(struct ipa *ipa)
{
struct ipa_interconnect *interconnect;
struct ipa_clock *clock = ipa->clock;
struct device *dev = &ipa->pdev->dev;
int result = 0;
u32 count;
int ret;
Expand All @@ -172,13 +177,16 @@ static void ipa_interconnect_disable(struct ipa *ipa)
while (count--) {
interconnect--;
ret = icc_set_bw(interconnect->path, 0, 0);
if (ret && !result)
result = ret;
if (ret) {
dev_err(dev, "error %d disabling %s interconnect\n",
ret, icc_get_name(interconnect->path));
/* Try to disable all; record only the first error */
if (!result)
result = ret;
}
}

if (result)
dev_err(&ipa->pdev->dev,
"error %d disabling IPA interconnects\n", ret);
return result;
}

/* Turn on IPA clocks, including interconnects */
Expand All @@ -191,8 +199,10 @@ static int ipa_clock_enable(struct ipa *ipa)
return ret;

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

return ret;
}
Expand All @@ -201,7 +211,7 @@ static int ipa_clock_enable(struct ipa *ipa)
static void ipa_clock_disable(struct ipa *ipa)
{
clk_disable_unprepare(ipa->clock->core);
ipa_interconnect_disable(ipa);
(void)ipa_interconnect_disable(ipa);
}

/* Get an IPA clock reference, but only if the reference count is
Expand Down Expand Up @@ -238,13 +248,8 @@ void ipa_clock_get(struct ipa *ipa)
goto out_mutex_unlock;

ret = ipa_clock_enable(ipa);
if (ret) {
dev_err(&ipa->pdev->dev, "error %d enabling IPA clock\n", ret);
goto out_mutex_unlock;
}

refcount_set(&clock->count, 1);

if (!ret)
refcount_set(&clock->count, 1);
out_mutex_unlock:
mutex_unlock(&clock->mutex);
}
Expand Down

0 comments on commit 8ee7c40

Please sign in to comment.