Skip to content

Commit 447e238

Browse files
committed
Merge tag 'usb-5.14' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB fixes from Greg KH: "Here are a few tiny USB fixes for reported issues with some USB drivers. These fixes include: - gadget driver fixes for regressions - tcpm driver fix - dwc3 driver fixes - xhci renesas firmware loading fix, again. - usb serial option driver device id addition - usb serial ch341 revert for regression All all of these have been in linux-next with no reported problems" * tag 'usb-5.14' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: usb: gadget: u_audio: fix race condition on endpoint stop usb: gadget: f_uac2: fixup feedback endpoint stop usb: typec: tcpm: Raise vdm_sm_running flag only when VDM SM is running usb: renesas-xhci: Prefer firmware loading on unknown ROM state usb: dwc3: gadget: Stop EP0 transfers during pullup disable usb: dwc3: gadget: Fix dwc3_calc_trbs_left() Revert "USB: serial: ch341: fix character loss at high transfer rates" USB: serial: option: add new VID/PID to support Fibocom FG150
2 parents 9f73eac + 068fdad commit 447e238

File tree

6 files changed

+89
-76
lines changed

6 files changed

+89
-76
lines changed

drivers/usb/dwc3/gadget.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -940,19 +940,19 @@ static struct dwc3_trb *dwc3_ep_prev_trb(struct dwc3_ep *dep, u8 index)
940940

941941
static u32 dwc3_calc_trbs_left(struct dwc3_ep *dep)
942942
{
943-
struct dwc3_trb *tmp;
944943
u8 trbs_left;
945944

946945
/*
947-
* If enqueue & dequeue are equal than it is either full or empty.
948-
*
949-
* One way to know for sure is if the TRB right before us has HWO bit
950-
* set or not. If it has, then we're definitely full and can't fit any
951-
* more transfers in our ring.
946+
* If the enqueue & dequeue are equal then the TRB ring is either full
947+
* or empty. It's considered full when there are DWC3_TRB_NUM-1 of TRBs
948+
* pending to be processed by the driver.
952949
*/
953950
if (dep->trb_enqueue == dep->trb_dequeue) {
954-
tmp = dwc3_ep_prev_trb(dep, dep->trb_enqueue);
955-
if (tmp->ctrl & DWC3_TRB_CTRL_HWO)
951+
/*
952+
* If there is any request remained in the started_list at
953+
* this point, that means there is no TRB available.
954+
*/
955+
if (!list_empty(&dep->started_list))
956956
return 0;
957957

958958
return DWC3_TRB_NUM - 1;
@@ -2243,10 +2243,8 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on)
22432243

22442244
ret = wait_for_completion_timeout(&dwc->ep0_in_setup,
22452245
msecs_to_jiffies(DWC3_PULL_UP_TIMEOUT));
2246-
if (ret == 0) {
2247-
dev_err(dwc->dev, "timed out waiting for SETUP phase\n");
2248-
return -ETIMEDOUT;
2249-
}
2246+
if (ret == 0)
2247+
dev_warn(dwc->dev, "timed out waiting for SETUP phase\n");
22502248
}
22512249

22522250
/*
@@ -2458,6 +2456,7 @@ static int __dwc3_gadget_start(struct dwc3 *dwc)
24582456
/* begin to receive SETUP packets */
24592457
dwc->ep0state = EP0_SETUP_PHASE;
24602458
dwc->link_state = DWC3_LINK_STATE_SS_DIS;
2459+
dwc->delayed_status = false;
24612460
dwc3_ep0_out_start(dwc);
24622461

24632462
dwc3_gadget_enable_irq(dwc);

drivers/usb/gadget/function/u_audio.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,13 @@ static void u_audio_iso_fback_complete(struct usb_ep *ep,
230230
int status = req->status;
231231

232232
/* i/f shutting down */
233-
if (!prm->fb_ep_enabled || req->status == -ESHUTDOWN)
233+
if (!prm->fb_ep_enabled) {
234+
kfree(req->buf);
235+
usb_ep_free_request(ep, req);
236+
return;
237+
}
238+
239+
if (req->status == -ESHUTDOWN)
234240
return;
235241

236242
/*
@@ -388,8 +394,6 @@ static inline void free_ep(struct uac_rtd_params *prm, struct usb_ep *ep)
388394
if (!prm->ep_enabled)
389395
return;
390396

391-
prm->ep_enabled = false;
392-
393397
audio_dev = uac->audio_dev;
394398
params = &audio_dev->params;
395399

@@ -407,6 +411,8 @@ static inline void free_ep(struct uac_rtd_params *prm, struct usb_ep *ep)
407411
}
408412
}
409413

414+
prm->ep_enabled = false;
415+
410416
if (usb_ep_disable(ep))
411417
dev_err(uac->card->dev, "%s:%d Error!\n", __func__, __LINE__);
412418
}
@@ -418,15 +424,16 @@ static inline void free_ep_fback(struct uac_rtd_params *prm, struct usb_ep *ep)
418424
if (!prm->fb_ep_enabled)
419425
return;
420426

421-
prm->fb_ep_enabled = false;
422-
423427
if (prm->req_fback) {
424-
usb_ep_dequeue(ep, prm->req_fback);
425-
kfree(prm->req_fback->buf);
426-
usb_ep_free_request(ep, prm->req_fback);
428+
if (usb_ep_dequeue(ep, prm->req_fback)) {
429+
kfree(prm->req_fback->buf);
430+
usb_ep_free_request(ep, prm->req_fback);
431+
}
427432
prm->req_fback = NULL;
428433
}
429434

435+
prm->fb_ep_enabled = false;
436+
430437
if (usb_ep_disable(ep))
431438
dev_err(uac->card->dev, "%s:%d Error!\n", __func__, __LINE__);
432439
}

drivers/usb/host/xhci-pci-renesas.c

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ static int renesas_check_rom_state(struct pci_dev *pdev)
207207
return 0;
208208

209209
case RENESAS_ROM_STATUS_NO_RESULT: /* No result yet */
210-
return 0;
210+
dev_dbg(&pdev->dev, "Unknown ROM status ...\n");
211+
return -ENOENT;
211212

212213
case RENESAS_ROM_STATUS_ERROR: /* Error State */
213214
default: /* All other states are marked as "Reserved states" */
@@ -224,14 +225,6 @@ static int renesas_fw_check_running(struct pci_dev *pdev)
224225
u8 fw_state;
225226
int err;
226227

227-
/* Check if device has ROM and loaded, if so skip everything */
228-
err = renesas_check_rom(pdev);
229-
if (err) { /* we have rom */
230-
err = renesas_check_rom_state(pdev);
231-
if (!err)
232-
return err;
233-
}
234-
235228
/*
236229
* Test if the device is actually needing the firmware. As most
237230
* BIOSes will initialize the device for us. If the device is
@@ -591,21 +584,39 @@ int renesas_xhci_check_request_fw(struct pci_dev *pdev,
591584
(struct xhci_driver_data *)id->driver_data;
592585
const char *fw_name = driver_data->firmware;
593586
const struct firmware *fw;
587+
bool has_rom;
594588
int err;
595589

590+
/* Check if device has ROM and loaded, if so skip everything */
591+
has_rom = renesas_check_rom(pdev);
592+
if (has_rom) {
593+
err = renesas_check_rom_state(pdev);
594+
if (!err)
595+
return 0;
596+
else if (err != -ENOENT)
597+
has_rom = false;
598+
}
599+
596600
err = renesas_fw_check_running(pdev);
597601
/* Continue ahead, if the firmware is already running. */
598602
if (err == 0)
599603
return 0;
600604

605+
/* no firmware interface available */
601606
if (err != 1)
602-
return err;
607+
return has_rom ? 0 : err;
603608

604609
pci_dev_get(pdev);
605-
err = request_firmware(&fw, fw_name, &pdev->dev);
610+
err = firmware_request_nowarn(&fw, fw_name, &pdev->dev);
606611
pci_dev_put(pdev);
607612
if (err) {
608-
dev_err(&pdev->dev, "request_firmware failed: %d\n", err);
613+
if (has_rom) {
614+
dev_info(&pdev->dev, "failed to load firmware %s, fallback to ROM\n",
615+
fw_name);
616+
return 0;
617+
}
618+
dev_err(&pdev->dev, "failed to load firmware %s: %d\n",
619+
fw_name, err);
609620
return err;
610621
}
611622

drivers/usb/serial/ch341.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,6 @@ static struct usb_serial_driver ch341_device = {
851851
.owner = THIS_MODULE,
852852
.name = "ch341-uart",
853853
},
854-
.bulk_in_size = 512,
855854
.id_table = id_table,
856855
.num_ports = 1,
857856
.open = ch341_open,

drivers/usb/serial/option.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2074,6 +2074,8 @@ static const struct usb_device_id option_ids[] = {
20742074
.driver_info = RSVD(4) | RSVD(5) },
20752075
{ USB_DEVICE_INTERFACE_CLASS(0x2cb7, 0x0105, 0xff), /* Fibocom NL678 series */
20762076
.driver_info = RSVD(6) },
2077+
{ USB_DEVICE_AND_INTERFACE_INFO(0x2cb7, 0x010b, 0xff, 0xff, 0x30) }, /* Fibocom FG150 Diag */
2078+
{ USB_DEVICE_AND_INTERFACE_INFO(0x2cb7, 0x010b, 0xff, 0, 0) }, /* Fibocom FG150 AT */
20772079
{ USB_DEVICE_INTERFACE_CLASS(0x2cb7, 0x01a0, 0xff) }, /* Fibocom NL668-AM/NL652-EU (laptop MBIM) */
20782080
{ USB_DEVICE_INTERFACE_CLASS(0x2df3, 0x9d03, 0xff) }, /* LongSung M5710 */
20792081
{ USB_DEVICE_INTERFACE_CLASS(0x305a, 0x1404, 0xff) }, /* GosunCn GM500 RNDIS */

0 commit comments

Comments
 (0)