* [PATCH net v2 0/2] can: mcp251xfd: bound RX offload batches during long IRQs
@ 2026-09-29 15:35 Chris Strong via B4 Relay
2026-09-29 15:35 ` [PATCH net v2 1/2] can: rx-offload: add IRQ queue flush predicate Chris Strong via B4 Relay
2026-09-29 15:35 ` [PATCH net v2 2/2] can: mcp251xfd: flush RX offload queue during long IRQs Chris Strong via B4 Relay
0 siblings, 2 replies; 3+ messages in thread
From: Chris Strong via B4 Relay @ 2026-09-29 15:35 UTC (permalink / raw)
To: Marc Kleine-Budde, Vincent Mailhol, Manivannan Sadhasivam, Thomas Kopp
Cc: linux-can, linux-kernel, Chris Strong
Hi all,
Under sustained receive traffic, the MCP251XFD threaded interrupt handler
can remain active indefinitely, leaving received SKBs in the IRQ-local
RX-offload queue while NAPI remains unscheduled.
Add an RX-offload helper for identifying a full IRQ-local batch, then use
it in MCP251XFD to publish batches while the handler continues draining
the controller.
An equivalent backport was tested on a Qualcomm QRB5165
(msm-qrb5165-4.19 vendor tree, with mcp251xfd and rx-offload backported
from v5.15+) driving an MCP251863 over GENI SPI at 125 kbit/s. The system
remained operational overnight under 100% CAN bus load while receiving
more than 51 million frames.
This mainline version passes checkpatch and an x86_64 build with
MCP251XFD enabled. I do not have a setup that can run mainline with an
MCP251863, so it is build-tested only; a hardware test would be welcome.
Signed-off-by: Chris Strong <chris.strong@flocksafety.com>
---
Changes in v2:
- Split the RX-offload helper into a separate patch.
- Shorten the patch descriptions and use imperative mood.
- Keep the code unchanged from v1.
Link to v1: https://lore.kernel.org/r/20260922-upstream-can-rx-offload-batching-v1-1-099e7ca12c91@flocksafety.com
---
Chris Strong (2):
can: rx-offload: add IRQ queue flush predicate
can: mcp251xfd: flush RX offload queue during long IRQs
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c | 14 +++++++++++++-
include/linux/can/rx-offload.h | 7 +++++++
2 files changed, 20 insertions(+), 1 deletion(-)
---
base-commit: 54518e0e827f4ca9229ae657022c60bf60f5c1bf
change-id: 20260921-upstream-can-rx-offload-batching-6c8faed6c156
Best regards,
--
Chris Strong <chris.strong@flocksafety.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH net v2 1/2] can: rx-offload: add IRQ queue flush predicate
2026-09-29 15:35 [PATCH net v2 0/2] can: mcp251xfd: bound RX offload batches during long IRQs Chris Strong via B4 Relay
@ 2026-09-29 15:35 ` Chris Strong via B4 Relay
2026-09-29 15:35 ` [PATCH net v2 2/2] can: mcp251xfd: flush RX offload queue during long IRQs Chris Strong via B4 Relay
1 sibling, 0 replies; 3+ messages in thread
From: Chris Strong via B4 Relay @ 2026-09-29 15:35 UTC (permalink / raw)
To: Marc Kleine-Budde, Vincent Mailhol, Manivannan Sadhasivam, Thomas Kopp
Cc: linux-can, linux-kernel, Chris Strong
From: Chris Strong <chris.strong@flocksafety.com>
Drivers that queue received SKBs from a threaded interrupt may need to
publish a partial batch before the handler returns. The existing overflow
check covers only the NAPI-visible queue after the IRQ-local queue has
been spliced, so it cannot guide that decision.
Add can_rx_offload_irq_queue_needs_flush() to report when the IRQ-local
queue reaches the NAPI poll weight. Keep the query separate from the
flush operation so callers can finish processing related interrupt
sources before publishing the batch.
Assisted-by: LLM
Signed-off-by: Chris Strong <chris.strong@flocksafety.com>
---
include/linux/can/rx-offload.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/include/linux/can/rx-offload.h b/include/linux/can/rx-offload.h
index d29bb4521947..f9b9474f7190 100644
--- a/include/linux/can/rx-offload.h
+++ b/include/linux/can/rx-offload.h
@@ -62,4 +62,11 @@ static inline void can_rx_offload_disable(struct can_rx_offload *offload)
napi_disable(&offload->napi);
}
+static inline bool
+can_rx_offload_irq_queue_needs_flush(const struct can_rx_offload *offload)
+{
+ /* skb_irq_queue is owned by the interrupt context queuing the SKBs. */
+ return skb_queue_len(&offload->skb_irq_queue) >= offload->napi.weight;
+}
+
#endif /* !_CAN_RX_OFFLOAD_H */
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH net v2 2/2] can: mcp251xfd: flush RX offload queue during long IRQs
2026-09-29 15:35 [PATCH net v2 0/2] can: mcp251xfd: bound RX offload batches during long IRQs Chris Strong via B4 Relay
2026-09-29 15:35 ` [PATCH net v2 1/2] can: rx-offload: add IRQ queue flush predicate Chris Strong via B4 Relay
@ 2026-09-29 15:35 ` Chris Strong via B4 Relay
1 sibling, 0 replies; 3+ messages in thread
From: Chris Strong via B4 Relay @ 2026-09-29 15:35 UTC (permalink / raw)
To: Marc Kleine-Budde, Vincent Mailhol, Manivannan Sadhasivam, Thomas Kopp
Cc: linux-can, linux-kernel, Chris Strong
From: Chris Strong <chris.strong@flocksafety.com>
Under sustained receive traffic, the threaded interrupt handler can
continue draining the controller indefinitely. Received SKBs remain in
skb_irq_queue until the handler returns, but the overflow checks inspect
the NAPI-visible skb_queue instead. The IRQ-local queue can therefore
grow without bound while NAPI remains unscheduled, potentially
exhausting memory.
Stop the dedicated RX loop when the IRQ-local queue reaches the NAPI
weight so TEF and other pending interrupts are processed before
publishing the batch. Publish further batches from the main interrupt
loop while the controller remains busy. This bounds IRQ-local
accumulation and keeps RX and TEF timestamps from each controller-status
pass in the same sort window.
Fixes: c757096ea103 ("can: rx-offload: add skb queue for use during ISR")
Assisted-by: LLM
Signed-off-by: Chris Strong <chris.strong@flocksafety.com>
---
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
index f441f2265299..d8078895b6d4 100644
--- a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
+++ b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
@@ -1498,8 +1498,14 @@ static irqreturn_t mcp251xfd_irq(int irq, void *dev_id)
/* We don't know which RX-FIFO is pending, but only
* handle the 1st RX-FIFO. Leave loop here if we have
* more than 1 RX-FIFO to avoid starvation.
+ *
+ * Once the IRQ queue reaches the NAPI weight, process
+ * TEF and other pending interrupts before publishing
+ * the batch, keeping RX and TEF timestamps in the same
+ * sort window.
*/
- } while (priv->rx_ring_num == 1);
+ } while (priv->rx_ring_num == 1 &&
+ !can_rx_offload_irq_queue_needs_flush(&priv->offload));
do {
u32 intf_pending, intf_pending_clearable;
@@ -1615,6 +1621,12 @@ static irqreturn_t mcp251xfd_irq(int irq, void *dev_id)
}
}
+ /* Keep each splice into the offload queue near one NAPI poll
+ * budget when a busy controller keeps this handler running.
+ */
+ if (can_rx_offload_irq_queue_needs_flush(&priv->offload))
+ can_rx_offload_threaded_irq_finish(&priv->offload);
+
handled = IRQ_HANDLED;
} while (1);
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-29 15:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-29 15:35 [PATCH net v2 0/2] can: mcp251xfd: bound RX offload batches during long IRQs Chris Strong via B4 Relay
2026-09-29 15:35 ` [PATCH net v2 1/2] can: rx-offload: add IRQ queue flush predicate Chris Strong via B4 Relay
2026-09-29 15:35 ` [PATCH net v2 2/2] can: mcp251xfd: flush RX offload queue during long IRQs Chris Strong via B4 Relay
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®