Skip to content

Commit e900f2c

Browse files
committed
Merge tag 'usb-4.1-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB and PHY driver fixes from Greg KH: "Here are some USB and PHY driver fixes that resolve some reported regressions. Also in here are some new device ids. All of the details are in the shortlog and these patches have been in linux-next with no problems" * tag 'usb-4.1-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (22 commits) USB: cp210x: add ID for HubZ dual ZigBee and Z-Wave dongle usb: renesas_usbhs: Don't disable the pipe if Control write status stage usb: renesas_usbhs: Fix fifo unclear in usbhsf_prepare_pop usb: gadget: f_fs: fix check in read operation usb: musb: fix order of conditions for assigning end point operations usb: gadget: f_uac1: check return code from config_ep_by_speed usb: gadget: ffs: fix: Always call ffs_closed() in ffs_data_clear() usb: gadget: g_ffs: Fix counting of missing_functions usb: s3c2410_udc: correct reversed pullup logic usb: dwc3: gadget: Fix incorrect DEPCMD and DGCMD status macros usb: phy: tahvo: Pass the IRQF_ONESHOT flag usb: phy: ab8500-usb: Pass the IRQF_ONESHOT flag usb: renesas_usbhs: Revise the binding document about the dma-names usb: host: xhci: add mutex for non-thread-safe data usb: make module xhci_hcd removable USB: serial: ftdi_sio: Add support for a Motion Tracker Development Board usb: gadget: f_midi: fix segfault when reading empty id phy: phy-rcar-gen2: Fix USBHS_UGSTS_LOCK value phy: omap-usb2: invoke pm_runtime_disable on error path phy: fix Kconfig dependencies ...
2 parents be19c4a + 9d08203 commit e900f2c

File tree

20 files changed

+123
-63
lines changed

20 files changed

+123
-63
lines changed

Documentation/devicetree/bindings/usb/renesas_usbhs.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@ Optional properties:
1515
- phys: phandle + phy specifier pair
1616
- phy-names: must be "usb"
1717
- dmas: Must contain a list of references to DMA specifiers.
18-
- dma-names : Must contain a list of DMA names:
19-
- tx0 ... tx<n>
20-
- rx0 ... rx<n>
21-
- This <n> means DnFIFO in USBHS module.
18+
- dma-names : named "ch%d", where %d is the channel number ranging from zero
19+
to the number of channels (DnFIFOs) minus one.
2220

2321
Example:
2422
usbhs: usb@e6590000 {

drivers/phy/Kconfig

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ config ARMADA375_USBCLUSTER_PHY
3838
config PHY_DM816X_USB
3939
tristate "TI dm816x USB PHY driver"
4040
depends on ARCH_OMAP2PLUS
41+
depends on USB_SUPPORT
4142
select GENERIC_PHY
43+
select USB_PHY
4244
help
4345
Enable this for dm816x USB to work.
4446

@@ -97,8 +99,9 @@ config OMAP_CONTROL_PHY
9799
config OMAP_USB2
98100
tristate "OMAP USB2 PHY Driver"
99101
depends on ARCH_OMAP2PLUS
100-
depends on USB_PHY
102+
depends on USB_SUPPORT
101103
select GENERIC_PHY
104+
select USB_PHY
102105
select OMAP_CONTROL_PHY
103106
depends on OMAP_OCP2SCP
104107
help
@@ -122,8 +125,9 @@ config TI_PIPE3
122125
config TWL4030_USB
123126
tristate "TWL4030 USB Transceiver Driver"
124127
depends on TWL4030_CORE && REGULATOR_TWL4030 && USB_MUSB_OMAP2PLUS
125-
depends on USB_PHY
128+
depends on USB_SUPPORT
126129
select GENERIC_PHY
130+
select USB_PHY
127131
help
128132
Enable this to support the USB OTG transceiver on TWL4030
129133
family chips (including the TWL5030 and TPS659x0 devices).
@@ -304,7 +308,7 @@ config PHY_STIH41X_USB
304308

305309
config PHY_QCOM_UFS
306310
tristate "Qualcomm UFS PHY driver"
307-
depends on OF && ARCH_MSM
311+
depends on OF && ARCH_QCOM
308312
select GENERIC_PHY
309313
help
310314
Support for UFS PHY on QCOM chipsets.

drivers/phy/phy-core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ struct phy *phy_optional_get(struct device *dev, const char *string)
530530
{
531531
struct phy *phy = phy_get(dev, string);
532532

533-
if (PTR_ERR(phy) == -ENODEV)
533+
if (IS_ERR(phy) && (PTR_ERR(phy) == -ENODEV))
534534
phy = NULL;
535535

536536
return phy;
@@ -584,7 +584,7 @@ struct phy *devm_phy_optional_get(struct device *dev, const char *string)
584584
{
585585
struct phy *phy = devm_phy_get(dev, string);
586586

587-
if (PTR_ERR(phy) == -ENODEV)
587+
if (IS_ERR(phy) && (PTR_ERR(phy) == -ENODEV))
588588
phy = NULL;
589589

590590
return phy;

drivers/phy/phy-omap-usb2.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ static int omap_usb2_probe(struct platform_device *pdev)
275275
phy->wkupclk = devm_clk_get(phy->dev, "usb_phy_cm_clk32k");
276276
if (IS_ERR(phy->wkupclk)) {
277277
dev_err(&pdev->dev, "unable to get usb_phy_cm_clk32k\n");
278+
pm_runtime_disable(phy->dev);
278279
return PTR_ERR(phy->wkupclk);
279280
} else {
280281
dev_warn(&pdev->dev,

drivers/phy/phy-rcar-gen2.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#define USBHS_LPSTS 0x02
2424
#define USBHS_UGCTRL 0x80
2525
#define USBHS_UGCTRL2 0x84
26-
#define USBHS_UGSTS 0x88 /* The manuals have 0x90 */
26+
#define USBHS_UGSTS 0x88 /* From technical update */
2727

2828
/* Low Power Status register (LPSTS) */
2929
#define USBHS_LPSTS_SUSPM 0x4000
@@ -41,7 +41,7 @@
4141
#define USBHS_UGCTRL2_USB0SEL_HS_USB 0x00000030
4242

4343
/* USB General status register (UGSTS) */
44-
#define USBHS_UGSTS_LOCK 0x00000300 /* The manuals have 0x3 */
44+
#define USBHS_UGSTS_LOCK 0x00000100 /* From technical update */
4545

4646
#define PHYS_PER_CHANNEL 2
4747

drivers/usb/dwc3/core.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@
339339
#define DWC3_DGCMD_SET_ENDPOINT_NRDY 0x0c
340340
#define DWC3_DGCMD_RUN_SOC_BUS_LOOPBACK 0x10
341341

342-
#define DWC3_DGCMD_STATUS(n) (((n) >> 15) & 1)
342+
#define DWC3_DGCMD_STATUS(n) (((n) >> 12) & 0x0F)
343343
#define DWC3_DGCMD_CMDACT (1 << 10)
344344
#define DWC3_DGCMD_CMDIOC (1 << 8)
345345

@@ -355,7 +355,7 @@
355355
#define DWC3_DEPCMD_PARAM_SHIFT 16
356356
#define DWC3_DEPCMD_PARAM(x) ((x) << DWC3_DEPCMD_PARAM_SHIFT)
357357
#define DWC3_DEPCMD_GET_RSC_IDX(x) (((x) >> DWC3_DEPCMD_PARAM_SHIFT) & 0x7f)
358-
#define DWC3_DEPCMD_STATUS(x) (((x) >> 15) & 1)
358+
#define DWC3_DEPCMD_STATUS(x) (((x) >> 12) & 0x0F)
359359
#define DWC3_DEPCMD_HIPRI_FORCERM (1 << 11)
360360
#define DWC3_DEPCMD_CMDACT (1 << 10)
361361
#define DWC3_DEPCMD_CMDIOC (1 << 8)

drivers/usb/gadget/function/f_fs.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,6 @@ static ssize_t ffs_ep0_write(struct file *file, const char __user *buf,
315315
return ret;
316316
}
317317

318-
set_bit(FFS_FL_CALL_CLOSED_CALLBACK, &ffs->flags);
319318
return len;
320319
}
321320
break;
@@ -847,7 +846,7 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data)
847846
ret = ep->status;
848847
if (io_data->read && ret > 0) {
849848
ret = copy_to_iter(data, ret, &io_data->data);
850-
if (unlikely(iov_iter_count(&io_data->data)))
849+
if (!ret)
851850
ret = -EFAULT;
852851
}
853852
}
@@ -1463,8 +1462,7 @@ static void ffs_data_clear(struct ffs_data *ffs)
14631462
{
14641463
ENTER();
14651464

1466-
if (test_and_clear_bit(FFS_FL_CALL_CLOSED_CALLBACK, &ffs->flags))
1467-
ffs_closed(ffs);
1465+
ffs_closed(ffs);
14681466

14691467
BUG_ON(ffs->gadget);
14701468

@@ -3422,9 +3420,13 @@ static int ffs_ready(struct ffs_data *ffs)
34223420
ffs_obj->desc_ready = true;
34233421
ffs_obj->ffs_data = ffs;
34243422

3425-
if (ffs_obj->ffs_ready_callback)
3423+
if (ffs_obj->ffs_ready_callback) {
34263424
ret = ffs_obj->ffs_ready_callback(ffs);
3425+
if (ret)
3426+
goto done;
3427+
}
34273428

3429+
set_bit(FFS_FL_CALL_CLOSED_CALLBACK, &ffs->flags);
34283430
done:
34293431
ffs_dev_unlock();
34303432
return ret;
@@ -3443,7 +3445,8 @@ static void ffs_closed(struct ffs_data *ffs)
34433445

34443446
ffs_obj->desc_ready = false;
34453447

3446-
if (ffs_obj->ffs_closed_callback)
3448+
if (test_and_clear_bit(FFS_FL_CALL_CLOSED_CALLBACK, &ffs->flags) &&
3449+
ffs_obj->ffs_closed_callback)
34473450
ffs_obj->ffs_closed_callback(ffs);
34483451

34493452
if (!ffs_obj->opts || ffs_obj->opts->no_configfs

drivers/usb/gadget/function/f_midi.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,13 @@ static ssize_t f_midi_opts_id_show(struct f_midi_opts *opts, char *page)
973973
int result;
974974

975975
mutex_lock(&opts->lock);
976-
result = strlcpy(page, opts->id, PAGE_SIZE);
976+
if (opts->id) {
977+
result = strlcpy(page, opts->id, PAGE_SIZE);
978+
} else {
979+
page[0] = 0;
980+
result = 0;
981+
}
982+
977983
mutex_unlock(&opts->lock);
978984

979985
return result;

drivers/usb/gadget/function/f_uac1.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,10 @@ static int f_audio_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
588588

589589
if (intf == 1) {
590590
if (alt == 1) {
591-
config_ep_by_speed(cdev->gadget, f, out_ep);
591+
err = config_ep_by_speed(cdev->gadget, f, out_ep);
592+
if (err)
593+
return err;
594+
592595
usb_ep_enable(out_ep);
593596
out_ep->driver_data = audio;
594597
audio->copy_buf = f_audio_buffer_alloc(audio_buf_size);

drivers/usb/gadget/legacy/g_ffs.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,10 @@ static int functionfs_ready_callback(struct ffs_data *ffs)
304304
gfs_registered = true;
305305

306306
ret = usb_composite_probe(&gfs_driver);
307-
if (unlikely(ret < 0))
307+
if (unlikely(ret < 0)) {
308+
++missing_funcs;
308309
gfs_registered = false;
310+
}
309311

310312
return ret;
311313
}

drivers/usb/gadget/udc/s3c2410_udc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1487,7 +1487,7 @@ static int s3c2410_udc_pullup(struct usb_gadget *gadget, int is_on)
14871487

14881488
dprintk(DEBUG_NORMAL, "%s()\n", __func__);
14891489

1490-
s3c2410_udc_set_pullup(udc, is_on ? 0 : 1);
1490+
s3c2410_udc_set_pullup(udc, is_on);
14911491
return 0;
14921492
}
14931493

drivers/usb/host/xhci.c

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3682,18 +3682,21 @@ int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev)
36823682
{
36833683
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
36843684
unsigned long flags;
3685-
int ret;
3685+
int ret, slot_id;
36863686
struct xhci_command *command;
36873687

36883688
command = xhci_alloc_command(xhci, false, false, GFP_KERNEL);
36893689
if (!command)
36903690
return 0;
36913691

3692+
/* xhci->slot_id and xhci->addr_dev are not thread-safe */
3693+
mutex_lock(&xhci->mutex);
36923694
spin_lock_irqsave(&xhci->lock, flags);
36933695
command->completion = &xhci->addr_dev;
36943696
ret = xhci_queue_slot_control(xhci, command, TRB_ENABLE_SLOT, 0);
36953697
if (ret) {
36963698
spin_unlock_irqrestore(&xhci->lock, flags);
3699+
mutex_unlock(&xhci->mutex);
36973700
xhci_dbg(xhci, "FIXME: allocate a command ring segment\n");
36983701
kfree(command);
36993702
return 0;
@@ -3702,8 +3705,10 @@ int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev)
37023705
spin_unlock_irqrestore(&xhci->lock, flags);
37033706

37043707
wait_for_completion(command->completion);
3708+
slot_id = xhci->slot_id;
3709+
mutex_unlock(&xhci->mutex);
37053710

3706-
if (!xhci->slot_id || command->status != COMP_SUCCESS) {
3711+
if (!slot_id || command->status != COMP_SUCCESS) {
37073712
xhci_err(xhci, "Error while assigning device slot ID\n");
37083713
xhci_err(xhci, "Max number of devices this xHCI host supports is %u.\n",
37093714
HCS_MAX_SLOTS(
@@ -3728,11 +3733,11 @@ int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev)
37283733
* xhci_discover_or_reset_device(), which may be called as part of
37293734
* mass storage driver error handling.
37303735
*/
3731-
if (!xhci_alloc_virt_device(xhci, xhci->slot_id, udev, GFP_NOIO)) {
3736+
if (!xhci_alloc_virt_device(xhci, slot_id, udev, GFP_NOIO)) {
37323737
xhci_warn(xhci, "Could not allocate xHCI USB device data structures\n");
37333738
goto disable_slot;
37343739
}
3735-
udev->slot_id = xhci->slot_id;
3740+
udev->slot_id = slot_id;
37363741

37373742
#ifndef CONFIG_USB_DEFAULT_PERSIST
37383743
/*
@@ -3778,12 +3783,15 @@ static int xhci_setup_device(struct usb_hcd *hcd, struct usb_device *udev,
37783783
struct xhci_slot_ctx *slot_ctx;
37793784
struct xhci_input_control_ctx *ctrl_ctx;
37803785
u64 temp_64;
3781-
struct xhci_command *command;
3786+
struct xhci_command *command = NULL;
3787+
3788+
mutex_lock(&xhci->mutex);
37823789

37833790
if (!udev->slot_id) {
37843791
xhci_dbg_trace(xhci, trace_xhci_dbg_address,
37853792
"Bad Slot ID %d", udev->slot_id);
3786-
return -EINVAL;
3793+
ret = -EINVAL;
3794+
goto out;
37873795
}
37883796

37893797
virt_dev = xhci->devs[udev->slot_id];
@@ -3796,21 +3804,24 @@ static int xhci_setup_device(struct usb_hcd *hcd, struct usb_device *udev,
37963804
*/
37973805
xhci_warn(xhci, "Virt dev invalid for slot_id 0x%x!\n",
37983806
udev->slot_id);
3799-
return -EINVAL;
3807+
ret = -EINVAL;
3808+
goto out;
38003809
}
38013810

38023811
if (setup == SETUP_CONTEXT_ONLY) {
38033812
slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->out_ctx);
38043813
if (GET_SLOT_STATE(le32_to_cpu(slot_ctx->dev_state)) ==
38053814
SLOT_STATE_DEFAULT) {
38063815
xhci_dbg(xhci, "Slot already in default state\n");
3807-
return 0;
3816+
goto out;
38083817
}
38093818
}
38103819

38113820
command = xhci_alloc_command(xhci, false, false, GFP_KERNEL);
3812-
if (!command)
3813-
return -ENOMEM;
3821+
if (!command) {
3822+
ret = -ENOMEM;
3823+
goto out;
3824+
}
38143825

38153826
command->in_ctx = virt_dev->in_ctx;
38163827
command->completion = &xhci->addr_dev;
@@ -3820,8 +3831,8 @@ static int xhci_setup_device(struct usb_hcd *hcd, struct usb_device *udev,
38203831
if (!ctrl_ctx) {
38213832
xhci_warn(xhci, "%s: Could not get input context, bad type.\n",
38223833
__func__);
3823-
kfree(command);
3824-
return -EINVAL;
3834+
ret = -EINVAL;
3835+
goto out;
38253836
}
38263837
/*
38273838
* If this is the first Set Address since device plug-in or
@@ -3848,8 +3859,7 @@ static int xhci_setup_device(struct usb_hcd *hcd, struct usb_device *udev,
38483859
spin_unlock_irqrestore(&xhci->lock, flags);
38493860
xhci_dbg_trace(xhci, trace_xhci_dbg_address,
38503861
"FIXME: allocate a command ring segment");
3851-
kfree(command);
3852-
return ret;
3862+
goto out;
38533863
}
38543864
xhci_ring_cmd_db(xhci);
38553865
spin_unlock_irqrestore(&xhci->lock, flags);
@@ -3896,10 +3906,8 @@ static int xhci_setup_device(struct usb_hcd *hcd, struct usb_device *udev,
38963906
ret = -EINVAL;
38973907
break;
38983908
}
3899-
if (ret) {
3900-
kfree(command);
3901-
return ret;
3902-
}
3909+
if (ret)
3910+
goto out;
39033911
temp_64 = xhci_read_64(xhci, &xhci->op_regs->dcbaa_ptr);
39043912
xhci_dbg_trace(xhci, trace_xhci_dbg_address,
39053913
"Op regs DCBAA ptr = %#016llx", temp_64);
@@ -3932,8 +3940,10 @@ static int xhci_setup_device(struct usb_hcd *hcd, struct usb_device *udev,
39323940
xhci_dbg_trace(xhci, trace_xhci_dbg_address,
39333941
"Internal device address = %d",
39343942
le32_to_cpu(slot_ctx->dev_state) & DEV_ADDR_MASK);
3943+
out:
3944+
mutex_unlock(&xhci->mutex);
39353945
kfree(command);
3936-
return 0;
3946+
return ret;
39373947
}
39383948

39393949
int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev)
@@ -4855,6 +4865,7 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
48554865
return 0;
48564866
}
48574867

4868+
mutex_init(&xhci->mutex);
48584869
xhci->cap_regs = hcd->regs;
48594870
xhci->op_regs = hcd->regs +
48604871
HC_LENGTH(readl(&xhci->cap_regs->hc_capbase));
@@ -5011,4 +5022,12 @@ static int __init xhci_hcd_init(void)
50115022
BUILD_BUG_ON(sizeof(struct xhci_run_regs) != (8+8*128)*32/8);
50125023
return 0;
50135024
}
5025+
5026+
/*
5027+
* If an init function is provided, an exit function must also be provided
5028+
* to allow module unload.
5029+
*/
5030+
static void __exit xhci_hcd_fini(void) { }
5031+
50145032
module_init(xhci_hcd_init);
5033+
module_exit(xhci_hcd_fini);

drivers/usb/host/xhci.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,6 +1497,8 @@ struct xhci_hcd {
14971497
struct list_head lpm_failed_devs;
14981498

14991499
/* slot enabling and address device helpers */
1500+
/* these are not thread safe so use mutex */
1501+
struct mutex mutex;
15001502
struct completion addr_dev;
15011503
int slot_id;
15021504
/* For USB 3.0 LPM enable/disable. */

0 commit comments

Comments
 (0)