Skip to content

Commit 2dd0d98

Browse files
committed
Merge tag 'usb-6.4-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB / Thunderbolt fixes from Greg KH: "Here are some USB fixes for 6.4-rc3, as well as a driver core fix that resolves a memory leak that shows up in USB devices easier than other subsystems. Included in here are: - driver core memory leak as reported and tested by syzbot and developers - dwc3 driver fixes for reported problems - xhci driver fixes for reported problems - USB gadget driver reverts to resolve regressions - usbtmc driver fix for syzbot reported problem - thunderbolt driver fixes for reported issues - other small USB fixes All of these, except for the driver core fix, have been in linux-next with no reported problems. The driver core fix was tested and verified to solve the issue by syzbot and the original reporter" * tag 'usb-6.4-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: driver core: class: properly reference count class_dev_iter() xhci: Fix incorrect tracking of free space on transfer rings xhci-pci: Only run d3cold avoidance quirk for s2idle usb-storage: fix deadlock when a scsi command timeouts more than once usb: dwc3: fix a test for error in dwc3_core_init() usb: typec: tps6598x: Fix fault at module removal usb: gadget: u_ether: Fix host MAC address case usb: typec: altmodes/displayport: fix pin_assignment_show Revert "usb: gadget: udc: core: Invoke usb_gadget_connect only when started" Revert "usb: gadget: udc: core: Prevent redundant calls to pullup" usb: gadget: drop superfluous ':' in doc string usb: dwc3: debugfs: Resume dwc3 before accessing registers USB: UHCI: adjust zhaoxin UHCI controllers OverCurrent bit value usb: dwc3: fix gadget mode suspend interrupt handler issue usb: dwc3: gadget: Improve dwc3_gadget_suspend() and dwc3_gadget_resume() USB: usbtmc: Fix direction for 0-length ioctl control messages thunderbolt: Clear registers properly when auto clear isn't in use
2 parents 98be58a + ddaf098 commit 2dd0d98

File tree

19 files changed

+309
-163
lines changed

19 files changed

+309
-163
lines changed

drivers/base/class.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ void class_dev_iter_init(struct class_dev_iter *iter, const struct class *class,
320320
start_knode = &start->p->knode_class;
321321
klist_iter_init_node(&sp->klist_devices, &iter->ki, start_knode);
322322
iter->type = type;
323+
iter->sp = sp;
323324
}
324325
EXPORT_SYMBOL_GPL(class_dev_iter_init);
325326

@@ -361,6 +362,7 @@ EXPORT_SYMBOL_GPL(class_dev_iter_next);
361362
void class_dev_iter_exit(struct class_dev_iter *iter)
362363
{
363364
klist_iter_exit(&iter->ki);
365+
subsys_put(iter->sp);
364366
}
365367
EXPORT_SYMBOL_GPL(class_dev_iter_exit);
366368

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 */

drivers/usb/class/usbtmc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,6 +1928,8 @@ static int usbtmc_ioctl_request(struct usbtmc_device_data *data,
19281928

19291929
if (request.req.wLength > USBTMC_BUFSIZE)
19301930
return -EMSGSIZE;
1931+
if (request.req.wLength == 0) /* Length-0 requests are never IN */
1932+
request.req.bRequestType &= ~USB_DIR_IN;
19311933

19321934
is_in = request.req.bRequestType & USB_DIR_IN;
19331935

drivers/usb/dwc3/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1137,7 +1137,7 @@ static int dwc3_core_init(struct dwc3 *dwc)
11371137

11381138
dwc3_set_incr_burst_type(dwc);
11391139

1140-
dwc3_phy_power_on(dwc);
1140+
ret = dwc3_phy_power_on(dwc);
11411141
if (ret)
11421142
goto err_exit_phy;
11431143

drivers/usb/dwc3/core.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,6 +1116,7 @@ struct dwc3_scratchpad_array {
11161116
* @dis_metastability_quirk: set to disable metastability quirk.
11171117
* @dis_split_quirk: set to disable split boundary.
11181118
* @wakeup_configured: set if the device is configured for remote wakeup.
1119+
* @suspended: set to track suspend event due to U3/L2.
11191120
* @imod_interval: set the interrupt moderation interval in 250ns
11201121
* increments or 0 to disable.
11211122
* @max_cfg_eps: current max number of IN eps used across all USB configs.
@@ -1332,6 +1333,7 @@ struct dwc3 {
13321333
unsigned dis_split_quirk:1;
13331334
unsigned async_callbacks:1;
13341335
unsigned wakeup_configured:1;
1336+
unsigned suspended:1;
13351337

13361338
u16 imod_interval;
13371339

0 commit comments

Comments
 (0)