Skip to contentSkip to conversation

net: ipa: don't overrun IPA suspend interrupt registers

PATCH Superseded Alex Elder 2 participants 3 messages Feb 18, 2024 – Feb 19, 2024

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Alex Elder

author
#0 lore raw

PATCH 1/1 net: ipa: don't overrun IPA suspend interrupt registers

In newer hardware, IPA supports more than 32 endpoints. Some registers--such as IPA interrupt registers--represent endpoints as bits in a 4-byte register, and such registers are repeated as needed to represent endpoints beyond the first 32.

In ipa_interrupt_suspend_clear_all(), we clear all pending IPA suspend interrupts by reading all status register(s) and writing corresponding registers to clear interrupt conditions.

Unfortunately the number of registers to read/write is calculated incorrectly, and as a result we access *many* more registers than intended. This bug occurs only when the IPA hardware signals a SUSPEND interrupt, which happens when a packet is received for an endpoint (or its underlying GSI channel) that is suspended. This situation is difficult to reproduce, but possible.

Fix this by correctly computing the number of interrupt registers to read and write. This is the only place in the code where registers that map endpoints or channels this way perform this calculation.

Fixes f298ba785e2d ("net: ipa: add a parameter to suspend registers")
---
 drivers/net/ipa/ipa_interrupt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ipa/ipa_interrupt.c +1 -1
index 4bc05948f772d..a78c692f2d3c5 100644
@@ -212,7 +212,7 @@ void ipa_interrupt_suspend_clear_all(struct ipa_interrupt *interrupt)
 	u32 unit_count;
 	u32 unit;
 
-	unit_count = roundup(ipa->endpoint_count, 32);
+	unit_count = DIV_ROUND_UP(ipa->endpoint_count, 32);
 	for (unit = 0; unit < unit_count; unit++) {
 		const struct reg *reg;
 		u32 val;
Signature · 1 line
2.40.1
author
#1 lore raw
Quoted 4 lines · Alex Elder

In newer hardware, IPA supports more than 32 endpoints. Some registers--such as IPA interrupt registers--represent endpoints as bits in a 4-byte register, and such registers are repeated as needed to represent endpoints beyond the first 32.

I'm sorry, this is a BUG FIX and I neglected to include "net" in the subject. Please handle this accordingly...

-Alex

Quoted 35 lines

In ipa_interrupt_suspend_clear_all(), we clear all pending IPA suspend interrupts by reading all status register(s) and writing corresponding registers to clear interrupt conditions.

Unfortunately the number of registers to read/write is calculated incorrectly, and as a result we access *many* more registers than intended. This bug occurs only when the IPA hardware signals a SUSPEND interrupt, which happens when a packet is received for an endpoint (or its underlying GSI channel) that is suspended. This situation is difficult to reproduce, but possible.

Fix this by correctly computing the number of interrupt registers to read and write. This is the only place in the code where registers that map endpoints or channels this way perform this calculation.

Fixes f298ba785e2d ("net: ipa: add a parameter to suspend registers")
---
  drivers/net/ipa/ipa_interrupt.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ipa/ipa_interrupt.c +1 -1
index 4bc05948f772d..a78c692f2d3c5 100644
@@ -212,7 +212,7 @@ void ipa_interrupt_suspend_clear_all(struct ipa_interrupt *interrupt)
  	u32 unit_count;
  	u32 unit;
 
-	unit_count = roundup(ipa->endpoint_count, 32);
+	unit_count = DIV_ROUND_UP(ipa->endpoint_count, 32);
  	for (unit = 0; unit < unit_count; unit++) {
  		const struct reg *reg;
  		u32 val;
reviewer Reviewed-by on v1 1/1
#2 lore raw
In reply to Alex Elder
Quoted 9 lines · Alex Elder

In newer hardware, IPA supports more than 32 endpoints. Some registers--such as IPA interrupt registers--represent endpoints as bits in a 4-byte register, and such registers are repeated as needed to represent endpoints beyond the first 32.

In ipa_interrupt_suspend_clear_all(), we clear all pending IPA suspend interrupts by reading all status register(s) and writing corresponding registers to clear interrupt conditions.

Quoted 6 lines

Unfortunately the number of registers to read/write is calculated incorrectly, and as a result we access *many* more registers than intended. This bug occurs only when the IPA hardware signals a SUSPEND interrupt, which happens when a packet is received for an endpoint (or its underlying GSI channel) that is suspended. This situation is difficult to reproduce, but possible.

I see what you mean about *many* more :)

Quoted 6 lines

Fix this by correctly computing the number of interrupt registers to read and write. This is the only place in the code where registers that map endpoints or channels this way perform this calculation.

Fixes f298ba785e2d ("net: ipa: add a parameter to suspend registers")

As noted by Alex elsewhere elsewhere in this thread, this is for net.