Skip to content

Commit 5fa0ab4

Browse files
committed
Merge tag 'usb-6.9-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB / Thunderbolt driver fixes from Greg KH: "Here are some small USB and Thunderbolt driver fixes for 6.9-rc5. Included in here are: - MAINTAINER file update for invalid email address - usb-serial device id updates - typec driver fixes - thunderbolt / usb4 driver fixes - usb core shutdown fixes - cdc-wdm driver revert for reported problem in -rc1 - usb gadget driver fixes - xhci driver fixes All of these have been in linux-next for a while with no reported problems" * tag 'usb-6.9-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (25 commits) USB: serial: option: add Telit FN920C04 rmnet compositions usb: dwc3: ep0: Don't reset resource alloc flag Revert "usb: cdc-wdm: close race between read and workqueue" USB: serial: option: add Rolling RW101-GL and RW135-GL support USB: serial: option: add Lonsung U8300/U9300 product USB: serial: option: add support for Fibocom FM650/FG650 USB: serial: option: support Quectel EM060K sub-models USB: serial: option: add Fibocom FM135-GL variants usb: misc: onboard_usb_hub: Disable the USB hub clock on failure thunderbolt: Avoid notify PM core about runtime PM resume thunderbolt: Fix wake configurations after device unplug usb: dwc2: host: Fix dereference issue in DDMA completion flow. usb: typec: mux: it5205: Fix ChipID value typo MAINTAINERS: Drop Li Yang as their email address stopped working usb: gadget: fsl: Initialize udc before using it usb: Disable USB3 LPM at shutdown usb: gadget: f_ncm: Fix UAF ncm object at re-bind after usb ep transport error usb: typec: tcpm: Correct the PDO counting in pd_set usb: gadget: functionfs: Wait for fences before enqueueing DMABUF usb: gadget: functionfs: Fix inverted DMA fence direction ...
2 parents 3b68086 + 7a9a304 commit 5fa0ab4

File tree

19 files changed

+147
-64
lines changed

19 files changed

+147
-64
lines changed

MAINTAINERS

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8746,10 +8746,9 @@ S: Orphan
87468746
F: drivers/usb/gadget/udc/fsl*
87478747

87488748
FREESCALE USB PHY DRIVER
8749-
M: Ran Wang <ran.wang_1@nxp.com>
87508749
L: linux-usb@vger.kernel.org
87518750
L: linuxppc-dev@lists.ozlabs.org
8752-
S: Maintained
8751+
S: Orphan
87538752
F: drivers/usb/phy/phy-fsl-usb*
87548753

87558754
FREEVXFS FILESYSTEM

drivers/thunderbolt/switch.c

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3180,22 +3180,29 @@ void tb_switch_unconfigure_link(struct tb_switch *sw)
31803180
{
31813181
struct tb_port *up, *down;
31823182

3183-
if (sw->is_unplugged)
3184-
return;
31853183
if (!tb_route(sw) || tb_switch_is_icm(sw))
31863184
return;
31873185

3186+
/*
3187+
* Unconfigure downstream port so that wake-on-connect can be
3188+
* configured after router unplug. No need to unconfigure upstream port
3189+
* since its router is unplugged.
3190+
*/
31883191
up = tb_upstream_port(sw);
3189-
if (tb_switch_is_usb4(up->sw))
3190-
usb4_port_unconfigure(up);
3191-
else
3192-
tb_lc_unconfigure_port(up);
3193-
31943192
down = up->remote;
31953193
if (tb_switch_is_usb4(down->sw))
31963194
usb4_port_unconfigure(down);
31973195
else
31983196
tb_lc_unconfigure_port(down);
3197+
3198+
if (sw->is_unplugged)
3199+
return;
3200+
3201+
up = tb_upstream_port(sw);
3202+
if (tb_switch_is_usb4(up->sw))
3203+
usb4_port_unconfigure(up);
3204+
else
3205+
tb_lc_unconfigure_port(up);
31993206
}
32003207

32013208
static void tb_switch_credits_init(struct tb_switch *sw)
@@ -3441,7 +3448,26 @@ static int tb_switch_set_wake(struct tb_switch *sw, unsigned int flags)
34413448
return tb_lc_set_wake(sw, flags);
34423449
}
34433450

3444-
int tb_switch_resume(struct tb_switch *sw)
3451+
static void tb_switch_check_wakes(struct tb_switch *sw)
3452+
{
3453+
if (device_may_wakeup(&sw->dev)) {
3454+
if (tb_switch_is_usb4(sw))
3455+
usb4_switch_check_wakes(sw);
3456+
}
3457+
}
3458+
3459+
/**
3460+
* tb_switch_resume() - Resume a switch after sleep
3461+
* @sw: Switch to resume
3462+
* @runtime: Is this resume from runtime suspend or system sleep
3463+
*
3464+
* Resumes and re-enumerates router (and all its children), if still plugged
3465+
* after suspend. Don't enumerate device router whose UID was changed during
3466+
* suspend. If this is resume from system sleep, notifies PM core about the
3467+
* wakes occurred during suspend. Disables all wakes, except USB4 wake of
3468+
* upstream port for USB4 routers that shall be always enabled.
3469+
*/
3470+
int tb_switch_resume(struct tb_switch *sw, bool runtime)
34453471
{
34463472
struct tb_port *port;
34473473
int err;
@@ -3490,6 +3516,9 @@ int tb_switch_resume(struct tb_switch *sw)
34903516
if (err)
34913517
return err;
34923518

3519+
if (!runtime)
3520+
tb_switch_check_wakes(sw);
3521+
34933522
/* Disable wakes */
34943523
tb_switch_set_wake(sw, 0);
34953524

@@ -3519,7 +3548,8 @@ int tb_switch_resume(struct tb_switch *sw)
35193548
*/
35203549
if (tb_port_unlock(port))
35213550
tb_port_warn(port, "failed to unlock port\n");
3522-
if (port->remote && tb_switch_resume(port->remote->sw)) {
3551+
if (port->remote &&
3552+
tb_switch_resume(port->remote->sw, runtime)) {
35233553
tb_port_warn(port,
35243554
"lost during suspend, disconnecting\n");
35253555
tb_sw_set_unplugged(port->remote->sw);

drivers/thunderbolt/tb.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,6 +1801,12 @@ static struct tb_port *tb_find_dp_out(struct tb *tb, struct tb_port *in)
18011801
continue;
18021802
}
18031803

1804+
/* Needs to be on different routers */
1805+
if (in->sw == port->sw) {
1806+
tb_port_dbg(port, "skipping DP OUT on same router\n");
1807+
continue;
1808+
}
1809+
18041810
tb_port_dbg(port, "DP OUT available\n");
18051811

18061812
/*
@@ -2936,7 +2942,7 @@ static int tb_resume_noirq(struct tb *tb)
29362942
if (!tb_switch_is_usb4(tb->root_switch))
29372943
tb_switch_reset(tb->root_switch);
29382944

2939-
tb_switch_resume(tb->root_switch);
2945+
tb_switch_resume(tb->root_switch, false);
29402946
tb_free_invalid_tunnels(tb);
29412947
tb_free_unplugged_children(tb->root_switch);
29422948
tb_restore_children(tb->root_switch);
@@ -3062,7 +3068,7 @@ static int tb_runtime_resume(struct tb *tb)
30623068
struct tb_tunnel *tunnel, *n;
30633069

30643070
mutex_lock(&tb->lock);
3065-
tb_switch_resume(tb->root_switch);
3071+
tb_switch_resume(tb->root_switch, true);
30663072
tb_free_invalid_tunnels(tb);
30673073
tb_restore_children(tb->root_switch);
30683074
list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list)

drivers/thunderbolt/tb.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ int tb_switch_configuration_valid(struct tb_switch *sw);
827827
int tb_switch_add(struct tb_switch *sw);
828828
void tb_switch_remove(struct tb_switch *sw);
829829
void tb_switch_suspend(struct tb_switch *sw, bool runtime);
830-
int tb_switch_resume(struct tb_switch *sw);
830+
int tb_switch_resume(struct tb_switch *sw, bool runtime);
831831
int tb_switch_reset(struct tb_switch *sw);
832832
int tb_switch_wait_for_bit(struct tb_switch *sw, u32 offset, u32 bit,
833833
u32 value, int timeout_msec);
@@ -1288,6 +1288,7 @@ static inline bool tb_switch_is_usb4(const struct tb_switch *sw)
12881288
return usb4_switch_version(sw) > 0;
12891289
}
12901290

1291+
void usb4_switch_check_wakes(struct tb_switch *sw);
12911292
int usb4_switch_setup(struct tb_switch *sw);
12921293
int usb4_switch_configuration_valid(struct tb_switch *sw);
12931294
int usb4_switch_read_uid(struct tb_switch *sw, u64 *uid);

drivers/thunderbolt/usb4.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,17 +155,20 @@ static inline int usb4_switch_op_data(struct tb_switch *sw, u16 opcode,
155155
tx_dwords, rx_data, rx_dwords);
156156
}
157157

158-
static void usb4_switch_check_wakes(struct tb_switch *sw)
158+
/**
159+
* usb4_switch_check_wakes() - Check for wakes and notify PM core about them
160+
* @sw: Router whose wakes to check
161+
*
162+
* Checks wakes occurred during suspend and notify the PM core about them.
163+
*/
164+
void usb4_switch_check_wakes(struct tb_switch *sw)
159165
{
160166
bool wakeup_usb4 = false;
161167
struct usb4_port *usb4;
162168
struct tb_port *port;
163169
bool wakeup = false;
164170
u32 val;
165171

166-
if (!device_may_wakeup(&sw->dev))
167-
return;
168-
169172
if (tb_route(sw)) {
170173
if (tb_sw_read(sw, &val, TB_CFG_SWITCH, ROUTER_CS_6, 1))
171174
return;
@@ -244,8 +247,6 @@ int usb4_switch_setup(struct tb_switch *sw)
244247
u32 val = 0;
245248
int ret;
246249

247-
usb4_switch_check_wakes(sw);
248-
249250
if (!tb_route(sw))
250251
return 0;
251252

drivers/usb/class/cdc-wdm.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,6 @@ static ssize_t wdm_write
485485
static int service_outstanding_interrupt(struct wdm_device *desc)
486486
{
487487
int rv = 0;
488-
int used;
489488

490489
/* submit read urb only if the device is waiting for it */
491490
if (!desc->resp_count || !--desc->resp_count)
@@ -500,10 +499,7 @@ static int service_outstanding_interrupt(struct wdm_device *desc)
500499
goto out;
501500
}
502501

503-
used = test_and_set_bit(WDM_RESPONDING, &desc->flags);
504-
if (used)
505-
goto out;
506-
502+
set_bit(WDM_RESPONDING, &desc->flags);
507503
spin_unlock_irq(&desc->iuspin);
508504
rv = usb_submit_urb(desc->response, GFP_KERNEL);
509505
spin_lock_irq(&desc->iuspin);

drivers/usb/core/port.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,10 @@ static void usb_port_shutdown(struct device *dev)
449449
{
450450
struct usb_port *port_dev = to_usb_port(dev);
451451

452-
if (port_dev->child)
452+
if (port_dev->child) {
453453
usb_disable_usb2_hardware_lpm(port_dev->child);
454+
usb_unlocked_disable_lpm(port_dev->child);
455+
}
454456
}
455457

456458
static const struct dev_pm_ops usb_port_pm_ops = {

drivers/usb/dwc2/hcd_ddma.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,13 +867,15 @@ static int dwc2_cmpl_host_isoc_dma_desc(struct dwc2_hsotg *hsotg,
867867
struct dwc2_dma_desc *dma_desc;
868868
struct dwc2_hcd_iso_packet_desc *frame_desc;
869869
u16 frame_desc_idx;
870-
struct urb *usb_urb = qtd->urb->priv;
870+
struct urb *usb_urb;
871871
u16 remain = 0;
872872
int rc = 0;
873873

874874
if (!qtd->urb)
875875
return -EINVAL;
876876

877+
usb_urb = qtd->urb->priv;
878+
877879
dma_sync_single_for_cpu(hsotg->dev, qh->desc_list_dma + (idx *
878880
sizeof(struct dwc2_dma_desc)),
879881
sizeof(struct dwc2_dma_desc),

drivers/usb/dwc3/ep0.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ void dwc3_ep0_stall_and_restart(struct dwc3 *dwc)
226226

227227
/* reinitialize physical ep1 */
228228
dep = dwc->eps[1];
229-
dep->flags = DWC3_EP_ENABLED;
229+
dep->flags &= DWC3_EP_RESOURCE_ALLOCATED;
230+
dep->flags |= DWC3_EP_ENABLED;
230231

231232
/* stall is always issued on EP0 */
232233
dep = dwc->eps[0];

drivers/usb/gadget/function/f_fs.c

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646

4747
#define FUNCTIONFS_MAGIC 0xa647361 /* Chosen by a honest dice roll ;) */
4848

49+
#define DMABUF_ENQUEUE_TIMEOUT_MS 5000
50+
4951
MODULE_IMPORT_NS(DMA_BUF);
5052

5153
/* Reference counter handling */
@@ -1578,10 +1580,13 @@ static int ffs_dmabuf_transfer(struct file *file,
15781580
struct ffs_dmabuf_priv *priv;
15791581
struct ffs_dma_fence *fence;
15801582
struct usb_request *usb_req;
1583+
enum dma_resv_usage resv_dir;
15811584
struct dma_buf *dmabuf;
1585+
unsigned long timeout;
15821586
struct ffs_ep *ep;
15831587
bool cookie;
15841588
u32 seqno;
1589+
long retl;
15851590
int ret;
15861591

15871592
if (req->flags & ~USB_FFS_DMABUF_TRANSFER_MASK)
@@ -1615,17 +1620,14 @@ static int ffs_dmabuf_transfer(struct file *file,
16151620
goto err_attachment_put;
16161621

16171622
/* Make sure we don't have writers */
1618-
if (!dma_resv_test_signaled(dmabuf->resv, DMA_RESV_USAGE_WRITE)) {
1619-
pr_vdebug("FFS WRITE fence is not signaled\n");
1620-
ret = -EBUSY;
1621-
goto err_resv_unlock;
1622-
}
1623-
1624-
/* If we're writing to the DMABUF, make sure we don't have readers */
1625-
if (epfile->in &&
1626-
!dma_resv_test_signaled(dmabuf->resv, DMA_RESV_USAGE_READ)) {
1627-
pr_vdebug("FFS READ fence is not signaled\n");
1628-
ret = -EBUSY;
1623+
timeout = nonblock ? 0 : msecs_to_jiffies(DMABUF_ENQUEUE_TIMEOUT_MS);
1624+
retl = dma_resv_wait_timeout(dmabuf->resv,
1625+
dma_resv_usage_rw(epfile->in),
1626+
true, timeout);
1627+
if (retl == 0)
1628+
retl = -EBUSY;
1629+
if (retl < 0) {
1630+
ret = (int)retl;
16291631
goto err_resv_unlock;
16301632
}
16311633

@@ -1665,8 +1667,9 @@ static int ffs_dmabuf_transfer(struct file *file,
16651667
dma_fence_init(&fence->base, &ffs_dmabuf_fence_ops,
16661668
&priv->lock, priv->context, seqno);
16671669

1668-
dma_resv_add_fence(dmabuf->resv, &fence->base,
1669-
dma_resv_usage_rw(epfile->in));
1670+
resv_dir = epfile->in ? DMA_RESV_USAGE_WRITE : DMA_RESV_USAGE_READ;
1671+
1672+
dma_resv_add_fence(dmabuf->resv, &fence->base, resv_dir);
16701673
dma_resv_unlock(dmabuf->resv);
16711674

16721675
/* Now that the dma_fence is in place, queue the transfer. */

0 commit comments

Comments
 (0)