Skip to content

Commit

Permalink
net: ipa: only enable the SUSPEND IPA interrupt when needed
Browse files Browse the repository at this point in the history
Only enable the SUSPEND IPA interrupt type when at least one
endpoint has that interrupt enabled.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
  • Loading branch information
Alex Elder authored and Paolo Abeni committed Apr 23, 2024
1 parent 2eca734 commit 6f37002
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
8 changes: 8 additions & 0 deletions drivers/net/ipa/ipa_interrupt.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ static void ipa_interrupt_suspend_control(struct ipa_interrupt *interrupt,
u32 mask = BIT(endpoint_id % 32);
u32 unit = endpoint_id / 32;
const struct reg *reg;
unsigned long weight;
u32 offset;
u32 val;

Expand All @@ -205,6 +206,10 @@ static void ipa_interrupt_suspend_control(struct ipa_interrupt *interrupt,
if (ipa->version == IPA_VERSION_3_0)
return;

weight = bitmap_weight(interrupt->suspend_enabled, ipa->endpoint_count);
if (weight == 1 && !enable)
ipa_interrupt_disable(ipa, IPA_IRQ_TX_SUSPEND);

reg = ipa_reg(ipa, IRQ_SUSPEND_EN);
offset = reg_n_offset(reg, unit);
val = ioread32(ipa->reg_virt + offset);
Expand All @@ -216,6 +221,9 @@ static void ipa_interrupt_suspend_control(struct ipa_interrupt *interrupt,
__change_bit(endpoint_id, interrupt->suspend_enabled);

iowrite32(val, ipa->reg_virt + offset);

if (!weight && enable)
ipa_interrupt_enable(ipa, IPA_IRQ_TX_SUSPEND);
}

/* Enable TX_SUSPEND for an endpoint */
Expand Down
11 changes: 1 addition & 10 deletions drivers/net/ipa/ipa_power.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,21 +234,12 @@ void ipa_power_retention(struct ipa *ipa, bool enable)

int ipa_power_setup(struct ipa *ipa)
{
int ret;

ipa_interrupt_enable(ipa, IPA_IRQ_TX_SUSPEND);

ret = device_init_wakeup(ipa->dev, true);
if (ret)
ipa_interrupt_disable(ipa, IPA_IRQ_TX_SUSPEND);

return ret;
return device_init_wakeup(ipa->dev, true);
}

void ipa_power_teardown(struct ipa *ipa)
{
(void)device_init_wakeup(ipa->dev, false);
ipa_interrupt_disable(ipa, IPA_IRQ_TX_SUSPEND);
}

/* Initialize IPA power management */
Expand Down

0 comments on commit 6f37002

Please sign in to comment.