Skip to content

Commit bec6f00

Browse files
committed
Merge tag 'usb-6.15-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB fixes from Greg KH: "Here are some small USB driver fixes for 6.15-rc6. Included in here are: - typec driver fixes - usbtmc ioctl fixes - xhci driver fixes - cdnsp driver fixes - some gadget driver fixes Nothing really major, just all little stuff that people have reported being issues. All of these have been in linux-next this week with no reported issues" * tag 'usb-6.15-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: xhci: dbc: Avoid event polling busyloop if pending rx transfers are inactive. usb: xhci: Don't trust the EP Context cycle bit when moving HW dequeue usb: usbtmc: Fix erroneous generic_read ioctl return usb: usbtmc: Fix erroneous wait_srq ioctl return usb: usbtmc: Fix erroneous get_stb ioctl error returns usb: typec: tcpm: delay SNK_TRY_WAIT_DEBOUNCE to SRC_TRYWAIT transition USB: usbtmc: use interruptible sleep in usbtmc_read usb: cdnsp: fix L1 resume issue for RTL_REVISION_NEW_LPM version usb: typec: ucsi: displayport: Fix NULL pointer access usb: typec: ucsi: displayport: Fix deadlock usb: misc: onboard_usb_dev: fix support for Cypress HX3 hubs usb: uhci-platform: Make the clock really optional usb: dwc3: gadget: Make gadget_wakeup asynchronous usb: gadget: Use get_status callback to set remote wakeup capability usb: gadget: f_ecm: Add get_status callback usb: host: tegra: Prevent host controller crash when OTG port is used usb: cdnsp: Fix issue with resuming from L1 usb: gadget: tegra-xudc: ACK ST_RC after clearing CTRL_RUN
2 parents 067dd58 + cab6393 commit bec6f00

File tree

21 files changed

+221
-95
lines changed

21 files changed

+221
-95
lines changed

drivers/usb/cdns3/cdnsp-gadget.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,26 @@ static void cdnsp_clear_port_change_bit(struct cdnsp_device *pdev,
139139
(portsc & PORT_CHANGE_BITS), port_regs);
140140
}
141141

142+
static void cdnsp_set_apb_timeout_value(struct cdnsp_device *pdev)
143+
{
144+
struct cdns *cdns = dev_get_drvdata(pdev->dev);
145+
__le32 __iomem *reg;
146+
void __iomem *base;
147+
u32 offset = 0;
148+
u32 val;
149+
150+
if (!cdns->override_apb_timeout)
151+
return;
152+
153+
base = &pdev->cap_regs->hc_capbase;
154+
offset = cdnsp_find_next_ext_cap(base, offset, D_XEC_PRE_REGS_CAP);
155+
reg = base + offset + REG_CHICKEN_BITS_3_OFFSET;
156+
157+
val = le32_to_cpu(readl(reg));
158+
val = CHICKEN_APB_TIMEOUT_SET(val, cdns->override_apb_timeout);
159+
writel(cpu_to_le32(val), reg);
160+
}
161+
142162
static void cdnsp_set_chicken_bits_2(struct cdnsp_device *pdev, u32 bit)
143163
{
144164
__le32 __iomem *reg;
@@ -1773,6 +1793,8 @@ static void cdnsp_get_rev_cap(struct cdnsp_device *pdev)
17731793
reg += cdnsp_find_next_ext_cap(reg, 0, RTL_REV_CAP);
17741794
pdev->rev_cap = reg;
17751795

1796+
pdev->rtl_revision = readl(&pdev->rev_cap->rtl_revision);
1797+
17761798
dev_info(pdev->dev, "Rev: %08x/%08x, eps: %08x, buff: %08x/%08x\n",
17771799
readl(&pdev->rev_cap->ctrl_revision),
17781800
readl(&pdev->rev_cap->rtl_revision),
@@ -1798,6 +1820,15 @@ static int cdnsp_gen_setup(struct cdnsp_device *pdev)
17981820
pdev->hci_version = HC_VERSION(pdev->hcc_params);
17991821
pdev->hcc_params = readl(&pdev->cap_regs->hcc_params);
18001822

1823+
/*
1824+
* Override the APB timeout value to give the controller more time for
1825+
* enabling UTMI clock and synchronizing APB and UTMI clock domains.
1826+
* This fix is platform specific and is required to fixes issue with
1827+
* reading incorrect value from PORTSC register after resuming
1828+
* from L1 state.
1829+
*/
1830+
cdnsp_set_apb_timeout_value(pdev);
1831+
18011832
cdnsp_get_rev_cap(pdev);
18021833

18031834
/* Make sure the Device Controller is halted. */

drivers/usb/cdns3/cdnsp-gadget.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,9 @@ struct cdnsp_rev_cap {
520520
#define REG_CHICKEN_BITS_2_OFFSET 0x48
521521
#define CHICKEN_XDMA_2_TP_CACHE_DIS BIT(28)
522522

523+
#define REG_CHICKEN_BITS_3_OFFSET 0x4C
524+
#define CHICKEN_APB_TIMEOUT_SET(p, val) (((p) & ~GENMASK(21, 0)) | (val))
525+
523526
/* XBUF Extended Capability ID. */
524527
#define XBUF_CAP_ID 0xCB
525528
#define XBUF_RX_TAG_MASK_0_OFFSET 0x1C
@@ -1357,6 +1360,7 @@ struct cdnsp_port {
13571360
* @rev_cap: Controller Capabilities Registers.
13581361
* @hcs_params1: Cached register copies of read-only HCSPARAMS1
13591362
* @hcc_params: Cached register copies of read-only HCCPARAMS1
1363+
* @rtl_revision: Cached controller rtl revision.
13601364
* @setup: Temporary buffer for setup packet.
13611365
* @ep0_preq: Internal allocated request used during enumeration.
13621366
* @ep0_stage: ep0 stage during enumeration process.
@@ -1411,6 +1415,8 @@ struct cdnsp_device {
14111415
__u32 hcs_params1;
14121416
__u32 hcs_params3;
14131417
__u32 hcc_params;
1418+
#define RTL_REVISION_NEW_LPM 0x2700
1419+
__u32 rtl_revision;
14141420
/* Lock used in interrupt thread context. */
14151421
spinlock_t lock;
14161422
struct usb_ctrlrequest setup;

drivers/usb/cdns3/cdnsp-pci.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
#define PCI_DRIVER_NAME "cdns-pci-usbssp"
2929
#define PLAT_DRIVER_NAME "cdns-usbssp"
3030

31+
#define CHICKEN_APB_TIMEOUT_VALUE 0x1C20
32+
3133
static struct pci_dev *cdnsp_get_second_fun(struct pci_dev *pdev)
3234
{
3335
/*
@@ -139,6 +141,14 @@ static int cdnsp_pci_probe(struct pci_dev *pdev,
139141
cdnsp->otg_irq = pdev->irq;
140142
}
141143

144+
/*
145+
* Cadence PCI based platform require some longer timeout for APB
146+
* to fixes domain clock synchronization issue after resuming
147+
* controller from L1 state.
148+
*/
149+
cdnsp->override_apb_timeout = CHICKEN_APB_TIMEOUT_VALUE;
150+
pci_set_drvdata(pdev, cdnsp);
151+
142152
if (pci_is_enabled(func)) {
143153
cdnsp->dev = dev;
144154
cdnsp->gadget_init = cdnsp_gadget_init;
@@ -148,8 +158,6 @@ static int cdnsp_pci_probe(struct pci_dev *pdev,
148158
goto free_cdnsp;
149159
}
150160

151-
pci_set_drvdata(pdev, cdnsp);
152-
153161
device_wakeup_enable(&pdev->dev);
154162
if (pci_dev_run_wake(pdev))
155163
pm_runtime_put_noidle(&pdev->dev);

drivers/usb/cdns3/cdnsp-ring.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,8 @@ static bool cdnsp_ring_ep_doorbell(struct cdnsp_device *pdev,
308308

309309
writel(db_value, reg_addr);
310310

311-
cdnsp_force_l0_go(pdev);
311+
if (pdev->rtl_revision < RTL_REVISION_NEW_LPM)
312+
cdnsp_force_l0_go(pdev);
312313

313314
/* Doorbell was set. */
314315
return true;

drivers/usb/cdns3/core.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ struct cdns3_platform_data {
7979
* @pdata: platform data from glue layer
8080
* @lock: spinlock structure
8181
* @xhci_plat_data: xhci private data structure pointer
82+
* @override_apb_timeout: hold value of APB timeout. For value 0 the default
83+
* value in CHICKEN_BITS_3 will be preserved.
8284
* @gadget_init: pointer to gadget initialization function
8385
*/
8486
struct cdns {
@@ -117,6 +119,7 @@ struct cdns {
117119
struct cdns3_platform_data *pdata;
118120
spinlock_t lock;
119121
struct xhci_plat_priv *xhci_plat_data;
122+
u32 override_apb_timeout;
120123

121124
int (*gadget_init)(struct cdns *cdns);
122125
};

drivers/usb/class/usbtmc.c

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ static int usbtmc_get_stb(struct usbtmc_file_data *file_data, __u8 *stb)
482482
u8 *buffer;
483483
u8 tag;
484484
int rv;
485+
long wait_rv;
485486

486487
dev_dbg(dev, "Enter ioctl_read_stb iin_ep_present: %d\n",
487488
data->iin_ep_present);
@@ -511,16 +512,17 @@ static int usbtmc_get_stb(struct usbtmc_file_data *file_data, __u8 *stb)
511512
}
512513

513514
if (data->iin_ep_present) {
514-
rv = wait_event_interruptible_timeout(
515+
wait_rv = wait_event_interruptible_timeout(
515516
data->waitq,
516517
atomic_read(&data->iin_data_valid) != 0,
517518
file_data->timeout);
518-
if (rv < 0) {
519-
dev_dbg(dev, "wait interrupted %d\n", rv);
519+
if (wait_rv < 0) {
520+
dev_dbg(dev, "wait interrupted %ld\n", wait_rv);
521+
rv = wait_rv;
520522
goto exit;
521523
}
522524

523-
if (rv == 0) {
525+
if (wait_rv == 0) {
524526
dev_dbg(dev, "wait timed out\n");
525527
rv = -ETIMEDOUT;
526528
goto exit;
@@ -539,6 +541,8 @@ static int usbtmc_get_stb(struct usbtmc_file_data *file_data, __u8 *stb)
539541

540542
dev_dbg(dev, "stb:0x%02x received %d\n", (unsigned int)*stb, rv);
541543

544+
rv = 0;
545+
542546
exit:
543547
/* bump interrupt bTag */
544548
data->iin_bTag += 1;
@@ -602,9 +606,9 @@ static int usbtmc488_ioctl_wait_srq(struct usbtmc_file_data *file_data,
602606
{
603607
struct usbtmc_device_data *data = file_data->data;
604608
struct device *dev = &data->intf->dev;
605-
int rv;
606609
u32 timeout;
607610
unsigned long expire;
611+
long wait_rv;
608612

609613
if (!data->iin_ep_present) {
610614
dev_dbg(dev, "no interrupt endpoint present\n");
@@ -618,25 +622,24 @@ static int usbtmc488_ioctl_wait_srq(struct usbtmc_file_data *file_data,
618622

619623
mutex_unlock(&data->io_mutex);
620624

621-
rv = wait_event_interruptible_timeout(
622-
data->waitq,
623-
atomic_read(&file_data->srq_asserted) != 0 ||
624-
atomic_read(&file_data->closing),
625-
expire);
625+
wait_rv = wait_event_interruptible_timeout(
626+
data->waitq,
627+
atomic_read(&file_data->srq_asserted) != 0 ||
628+
atomic_read(&file_data->closing),
629+
expire);
626630

627631
mutex_lock(&data->io_mutex);
628632

629633
/* Note! disconnect or close could be called in the meantime */
630634
if (atomic_read(&file_data->closing) || data->zombie)
631-
rv = -ENODEV;
635+
return -ENODEV;
632636

633-
if (rv < 0) {
634-
/* dev can be invalid now! */
635-
pr_debug("%s - wait interrupted %d\n", __func__, rv);
636-
return rv;
637+
if (wait_rv < 0) {
638+
dev_dbg(dev, "%s - wait interrupted %ld\n", __func__, wait_rv);
639+
return wait_rv;
637640
}
638641

639-
if (rv == 0) {
642+
if (wait_rv == 0) {
640643
dev_dbg(dev, "%s - wait timed out\n", __func__);
641644
return -ETIMEDOUT;
642645
}
@@ -830,6 +833,7 @@ static ssize_t usbtmc_generic_read(struct usbtmc_file_data *file_data,
830833
unsigned long expire;
831834
int bufcount = 1;
832835
int again = 0;
836+
long wait_rv;
833837

834838
/* mutex already locked */
835839

@@ -942,19 +946,24 @@ static ssize_t usbtmc_generic_read(struct usbtmc_file_data *file_data,
942946
if (!(flags & USBTMC_FLAG_ASYNC)) {
943947
dev_dbg(dev, "%s: before wait time %lu\n",
944948
__func__, expire);
945-
retval = wait_event_interruptible_timeout(
949+
wait_rv = wait_event_interruptible_timeout(
946950
file_data->wait_bulk_in,
947951
usbtmc_do_transfer(file_data),
948952
expire);
949953

950-
dev_dbg(dev, "%s: wait returned %d\n",
951-
__func__, retval);
954+
dev_dbg(dev, "%s: wait returned %ld\n",
955+
__func__, wait_rv);
956+
957+
if (wait_rv < 0) {
958+
retval = wait_rv;
959+
goto error;
960+
}
952961

953-
if (retval <= 0) {
954-
if (retval == 0)
955-
retval = -ETIMEDOUT;
962+
if (wait_rv == 0) {
963+
retval = -ETIMEDOUT;
956964
goto error;
957965
}
966+
958967
}
959968

960969
urb = usb_get_from_anchor(&file_data->in_anchor);
@@ -1380,7 +1389,10 @@ static ssize_t usbtmc_read(struct file *filp, char __user *buf,
13801389
if (!buffer)
13811390
return -ENOMEM;
13821391

1383-
mutex_lock(&data->io_mutex);
1392+
retval = mutex_lock_interruptible(&data->io_mutex);
1393+
if (retval < 0)
1394+
goto exit_nolock;
1395+
13841396
if (data->zombie) {
13851397
retval = -ENODEV;
13861398
goto exit;
@@ -1503,6 +1515,7 @@ static ssize_t usbtmc_read(struct file *filp, char __user *buf,
15031515

15041516
exit:
15051517
mutex_unlock(&data->io_mutex);
1518+
exit_nolock:
15061519
kfree(buffer);
15071520
return retval;
15081521
}

drivers/usb/dwc3/core.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,6 +1164,9 @@ struct dwc3_scratchpad_array {
11641164
* @gsbuscfg0_reqinfo: store GSBUSCFG0.DATRDREQINFO, DESRDREQINFO,
11651165
* DATWRREQINFO, and DESWRREQINFO value passed from
11661166
* glue driver.
1167+
* @wakeup_pending_funcs: Indicates whether any interface has requested for
1168+
* function wakeup in bitmap format where bit position
1169+
* represents interface_id.
11671170
*/
11681171
struct dwc3 {
11691172
struct work_struct drd_work;
@@ -1394,6 +1397,7 @@ struct dwc3 {
13941397
int num_ep_resized;
13951398
struct dentry *debug_root;
13961399
u32 gsbuscfg0_reqinfo;
1400+
u32 wakeup_pending_funcs;
13971401
};
13981402

13991403
#define INCRX_BURST_MODE 0

0 commit comments

Comments
 (0)