Skip to content

Commit 1e94be7

Browse files
committed
Merge tag 'thunderbolt-for-v6.4-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt into usb-linus
Mika writes: thunderbolt: Fix for v6.4-rc3 This includes a single fix that fixes an error when resuming from hibernation if the driver is built into the kernel. This has been in linux-next with no reported issues. * tag 'thunderbolt-for-v6.4-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt: thunderbolt: Clear registers properly when auto clear isn't in use
2 parents fe82f16 + c4af8e3 commit 1e94be7

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

drivers/thunderbolt/nhi.c

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,30 @@ static int ring_interrupt_index(const struct tb_ring *ring)
5454
return bit;
5555
}
5656

57+
static void nhi_mask_interrupt(struct tb_nhi *nhi, int mask, int ring)
58+
{
59+
if (nhi->quirks & QUIRK_AUTO_CLEAR_INT)
60+
return;
61+
iowrite32(mask, nhi->iobase + REG_RING_INTERRUPT_MASK_CLEAR_BASE + ring);
62+
}
63+
64+
static void nhi_clear_interrupt(struct tb_nhi *nhi, int ring)
65+
{
66+
if (nhi->quirks & QUIRK_AUTO_CLEAR_INT)
67+
ioread32(nhi->iobase + REG_RING_NOTIFY_BASE + ring);
68+
else
69+
iowrite32(~0, nhi->iobase + REG_RING_INT_CLEAR + ring);
70+
}
71+
5772
/*
5873
* ring_interrupt_active() - activate/deactivate interrupts for a single ring
5974
*
6075
* ring->nhi->lock must be held.
6176
*/
6277
static void ring_interrupt_active(struct tb_ring *ring, bool active)
6378
{
64-
int reg = REG_RING_INTERRUPT_BASE +
65-
ring_interrupt_index(ring) / 32 * 4;
79+
int index = ring_interrupt_index(ring) / 32 * 4;
80+
int reg = REG_RING_INTERRUPT_BASE + index;
6681
int interrupt_bit = ring_interrupt_index(ring) & 31;
6782
int mask = 1 << interrupt_bit;
6883
u32 old, new;
@@ -123,7 +138,11 @@ static void ring_interrupt_active(struct tb_ring *ring, bool active)
123138
"interrupt for %s %d is already %s\n",
124139
RING_TYPE(ring), ring->hop,
125140
active ? "enabled" : "disabled");
126-
iowrite32(new, ring->nhi->iobase + reg);
141+
142+
if (active)
143+
iowrite32(new, ring->nhi->iobase + reg);
144+
else
145+
nhi_mask_interrupt(ring->nhi, mask, index);
127146
}
128147

129148
/*
@@ -136,11 +155,11 @@ static void nhi_disable_interrupts(struct tb_nhi *nhi)
136155
int i = 0;
137156
/* disable interrupts */
138157
for (i = 0; i < RING_INTERRUPT_REG_COUNT(nhi); i++)
139-
iowrite32(0, nhi->iobase + REG_RING_INTERRUPT_BASE + 4 * i);
158+
nhi_mask_interrupt(nhi, ~0, 4 * i);
140159

141160
/* clear interrupt status bits */
142161
for (i = 0; i < RING_NOTIFY_REG_COUNT(nhi); i++)
143-
ioread32(nhi->iobase + REG_RING_NOTIFY_BASE + 4 * i);
162+
nhi_clear_interrupt(nhi, 4 * i);
144163
}
145164

146165
/* ring helper methods */

drivers/thunderbolt/nhi_regs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ struct ring_desc {
9393
#define REG_RING_INTERRUPT_BASE 0x38200
9494
#define RING_INTERRUPT_REG_COUNT(nhi) ((31 + 2 * nhi->hop_count) / 32)
9595

96+
#define REG_RING_INTERRUPT_MASK_CLEAR_BASE 0x38208
97+
9698
#define REG_INT_THROTTLING_RATE 0x38c00
9799

98100
/* Interrupt Vector Allocation */

0 commit comments

Comments
 (0)