[PATCH v2 14/22] thunderbolt: Add ring_interrupt_mask to tb_nhi_ops
From: Sven Peter
Date: Sun Sep 06 2026 - 14:42:37 EST
Masking ring interrupts works differently on the Apple NHI as well. Add
an optional tb_nhi_ops hook for it which falls back to the standard
USB4 NHI method when it is not set.
Signed-off-by: Sven Peter <sven@xxxxxxxxxx>
Reviewed-by: Joshua Peisach <jpeisach@xxxxxxxxxx>
---
drivers/thunderbolt/nhi.c | 12 ++++++++++--
drivers/thunderbolt/nhi.h | 4 ++++
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c
index 1b1e4a12c744..4ef86e7c0285 100644
--- a/drivers/thunderbolt/nhi.c
+++ b/drivers/thunderbolt/nhi.c
@@ -427,6 +427,14 @@ static void __ring_interrupt_mask(struct tb_ring *ring, bool mask)
iowrite32(val, ring->nhi->iobase + reg);
}
+static void nhi_ring_interrupt_mask(struct tb_ring *ring, bool mask)
+{
+ if (ring->nhi->ops->ring_interrupt_mask)
+ ring->nhi->ops->ring_interrupt_mask(ring, mask);
+ else
+ __ring_interrupt_mask(ring, mask);
+}
+
/* Both @nhi->lock and @ring->lock should be held */
static void __ring_interrupt(struct tb_ring *ring)
{
@@ -434,7 +442,7 @@ static void __ring_interrupt(struct tb_ring *ring)
return;
if (ring->start_poll) {
- __ring_interrupt_mask(ring, true);
+ nhi_ring_interrupt_mask(ring, true);
ring->start_poll(ring->poll_data);
} else {
schedule_work(&ring->work);
@@ -455,7 +463,7 @@ void tb_ring_poll_complete(struct tb_ring *ring)
spin_lock_irqsave(&ring->nhi->lock, flags);
spin_lock(&ring->lock);
if (ring->start_poll)
- __ring_interrupt_mask(ring, false);
+ nhi_ring_interrupt_mask(ring, false);
spin_unlock(&ring->lock);
spin_unlock_irqrestore(&ring->nhi->lock, flags);
}
diff --git a/drivers/thunderbolt/nhi.h b/drivers/thunderbolt/nhi.h
index 3a963b0b5b46..ca3eddf862e0 100644
--- a/drivers/thunderbolt/nhi.h
+++ b/drivers/thunderbolt/nhi.h
@@ -59,6 +59,9 @@ extern const struct dev_pm_ops nhi_pm_ops;
* @ring_interrupt_active: NHI specific hook to activate/deactivate the
* interrupt of a single ring. If not set the
* standard USB4 NHI registers are used.
+ * @ring_interrupt_mask: NHI specific hook to mask/unmask the interrupt of a
+ * single ring. If not set the standard USB4 NHI
+ * registers are used.
* @is_present: Whether the device is currently present on the parent bus
* @init_interrupts: NHI specific interrupt initialization hook
* @reset_interface: Resets the host interface
@@ -77,6 +80,7 @@ struct tb_nhi_ops {
void __iomem *(*ring_desc_base)(struct tb_ring *ring);
void __iomem *(*ring_options_base)(struct tb_ring *ring);
void (*ring_interrupt_active)(struct tb_ring *ring, bool active);
+ void (*ring_interrupt_mask)(struct tb_ring *ring, bool mask);
bool (*is_present)(struct tb_nhi *nhi);
int (*init_interrupts)(struct tb_nhi *nhi);
void (*reset_interface)(struct tb_nhi *nhi);
--
2.55.0