forked from luck/tmp_suning_uos_patched
USB fixes for 4.12-rc5
Here are some small USB fixes for 4.12-rc5 They are for some reported issues in the chipidea and gadget drivers. Nothing major. All have been in linux-next for a while with no reported issues. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> -----BEGIN PGP SIGNATURE----- iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCWTzztQ8cZ3JlZ0Brcm9h aC5jb20ACgkQMUfUDdst+ymdXACgjqMbdAmv2tS2Ng1dRMtqsi/TXqsAn18ZBKpK jKwoGlzOCVWYfIFx5nNp =A7ix -----END PGP SIGNATURE----- Merge tag 'usb-4.12-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb Pull USB fixes from Greg KH: "Here are some small USB fixes for 4.12-rc5 They are for some reported issues in the chipidea and gadget drivers. Nothing major. All have been in linux-next for a while with no reported issues" * tag 'usb-4.12-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: usb: gadget: udc: renesas_usb3: Fix PN_INT_ENA disabling timing usb: gadget: udc: renesas_usb3: lock for PN_ registers access usb: gadget: udc: renesas_usb3: fix deadlock by spinlock usb: gadget: udc: renesas_usb3: fix pm_runtime functions calling usb: gadget: f_mass_storage: Serialize wake and sleep execution usb: dwc2: add support for the DWC2 controller on Meson8 SoCs phy: qualcomm: phy-qcom-qmp: fix application of sizeof to pointer usb: musb: dsps: keep VBUS on for host-only mode usb: chipidea: core: check before accessing ci_role in ci_role_show usb: chipidea: debug: check before accessing ci_role phy: qcom-qmp: fix return value check in qcom_qmp_phy_create() usb: chipidea: udc: fix NULL pointer dereference if udc_start failed usb: chipidea: imx: Do not access CLKONOFF on i.MX51
This commit is contained in:
commit
246baac2fd
|
@ -10,6 +10,7 @@ Required properties:
|
|||
- "rockchip,rk3288-usb", "rockchip,rk3066-usb", "snps,dwc2": for rk3288 Soc;
|
||||
- "lantiq,arx100-usb": The DWC2 USB controller instance in Lantiq ARX SoCs;
|
||||
- "lantiq,xrx200-usb": The DWC2 USB controller instance in Lantiq XRX SoCs;
|
||||
- "amlogic,meson8-usb": The DWC2 USB controller instance in Amlogic Meson8 SoCs;
|
||||
- "amlogic,meson8b-usb": The DWC2 USB controller instance in Amlogic Meson8b SoCs;
|
||||
- "amlogic,meson-gxbb-usb": The DWC2 USB controller instance in Amlogic S905 SoCs;
|
||||
- "amcc,dwc-otg": The DWC2 USB controller instance in AMCC Canyonlands 460EX SoCs;
|
||||
|
|
|
@ -844,7 +844,7 @@ static int qcom_qmp_phy_vreg_init(struct device *dev)
|
|||
int num = qmp->cfg->num_vregs;
|
||||
int i;
|
||||
|
||||
qmp->vregs = devm_kcalloc(dev, num, sizeof(qmp->vregs), GFP_KERNEL);
|
||||
qmp->vregs = devm_kcalloc(dev, num, sizeof(*qmp->vregs), GFP_KERNEL);
|
||||
if (!qmp->vregs)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@ -983,16 +983,16 @@ int qcom_qmp_phy_create(struct device *dev, struct device_node *np, int id)
|
|||
* Resources are indexed as: tx -> 0; rx -> 1; pcs -> 2.
|
||||
*/
|
||||
qphy->tx = of_iomap(np, 0);
|
||||
if (IS_ERR(qphy->tx))
|
||||
return PTR_ERR(qphy->tx);
|
||||
if (!qphy->tx)
|
||||
return -ENOMEM;
|
||||
|
||||
qphy->rx = of_iomap(np, 1);
|
||||
if (IS_ERR(qphy->rx))
|
||||
return PTR_ERR(qphy->rx);
|
||||
if (!qphy->rx)
|
||||
return -ENOMEM;
|
||||
|
||||
qphy->pcs = of_iomap(np, 2);
|
||||
if (IS_ERR(qphy->pcs))
|
||||
return PTR_ERR(qphy->pcs);
|
||||
if (!qphy->pcs)
|
||||
return -ENOMEM;
|
||||
|
||||
/*
|
||||
* Get PHY's Pipe clock, if any. USB3 and PCIe are PIPE3
|
||||
|
|
|
@ -843,7 +843,10 @@ static ssize_t ci_role_show(struct device *dev, struct device_attribute *attr,
|
|||
{
|
||||
struct ci_hdrc *ci = dev_get_drvdata(dev);
|
||||
|
||||
return sprintf(buf, "%s\n", ci_role(ci)->name);
|
||||
if (ci->role != CI_ROLE_END)
|
||||
return sprintf(buf, "%s\n", ci_role(ci)->name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t ci_role_store(struct device *dev,
|
||||
|
|
|
@ -294,7 +294,8 @@ static int ci_role_show(struct seq_file *s, void *data)
|
|||
{
|
||||
struct ci_hdrc *ci = s->private;
|
||||
|
||||
seq_printf(s, "%s\n", ci_role(ci)->name);
|
||||
if (ci->role != CI_ROLE_END)
|
||||
seq_printf(s, "%s\n", ci_role(ci)->name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1993,6 +1993,7 @@ static void udc_id_switch_for_host(struct ci_hdrc *ci)
|
|||
int ci_hdrc_gadget_init(struct ci_hdrc *ci)
|
||||
{
|
||||
struct ci_role_driver *rdrv;
|
||||
int ret;
|
||||
|
||||
if (!hw_read(ci, CAP_DCCPARAMS, DCCPARAMS_DC))
|
||||
return -ENXIO;
|
||||
|
@ -2005,7 +2006,10 @@ int ci_hdrc_gadget_init(struct ci_hdrc *ci)
|
|||
rdrv->stop = udc_id_switch_for_host;
|
||||
rdrv->irq = udc_irq;
|
||||
rdrv->name = "gadget";
|
||||
ci->roles[CI_ROLE_GADGET] = rdrv;
|
||||
|
||||
return udc_start(ci);
|
||||
ret = udc_start(ci);
|
||||
if (!ret)
|
||||
ci->roles[CI_ROLE_GADGET] = rdrv;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -108,6 +108,8 @@ struct imx_usbmisc {
|
|||
const struct usbmisc_ops *ops;
|
||||
};
|
||||
|
||||
static inline bool is_imx53_usbmisc(struct imx_usbmisc_data *data);
|
||||
|
||||
static int usbmisc_imx25_init(struct imx_usbmisc_data *data)
|
||||
{
|
||||
struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
|
||||
|
@ -242,10 +244,15 @@ static int usbmisc_imx53_init(struct imx_usbmisc_data *data)
|
|||
val = readl(reg) | MX53_USB_UHx_CTRL_WAKE_UP_EN
|
||||
| MX53_USB_UHx_CTRL_ULPI_INT_EN;
|
||||
writel(val, reg);
|
||||
/* Disable internal 60Mhz clock */
|
||||
reg = usbmisc->base + MX53_USB_CLKONOFF_CTRL_OFFSET;
|
||||
val = readl(reg) | MX53_USB_CLKONOFF_CTRL_H2_INT60CKOFF;
|
||||
writel(val, reg);
|
||||
if (is_imx53_usbmisc(data)) {
|
||||
/* Disable internal 60Mhz clock */
|
||||
reg = usbmisc->base +
|
||||
MX53_USB_CLKONOFF_CTRL_OFFSET;
|
||||
val = readl(reg) |
|
||||
MX53_USB_CLKONOFF_CTRL_H2_INT60CKOFF;
|
||||
writel(val, reg);
|
||||
}
|
||||
|
||||
}
|
||||
if (data->disable_oc) {
|
||||
reg = usbmisc->base + MX53_USB_UH2_CTRL_OFFSET;
|
||||
|
@ -267,10 +274,15 @@ static int usbmisc_imx53_init(struct imx_usbmisc_data *data)
|
|||
val = readl(reg) | MX53_USB_UHx_CTRL_WAKE_UP_EN
|
||||
| MX53_USB_UHx_CTRL_ULPI_INT_EN;
|
||||
writel(val, reg);
|
||||
/* Disable internal 60Mhz clock */
|
||||
reg = usbmisc->base + MX53_USB_CLKONOFF_CTRL_OFFSET;
|
||||
val = readl(reg) | MX53_USB_CLKONOFF_CTRL_H3_INT60CKOFF;
|
||||
writel(val, reg);
|
||||
|
||||
if (is_imx53_usbmisc(data)) {
|
||||
/* Disable internal 60Mhz clock */
|
||||
reg = usbmisc->base +
|
||||
MX53_USB_CLKONOFF_CTRL_OFFSET;
|
||||
val = readl(reg) |
|
||||
MX53_USB_CLKONOFF_CTRL_H3_INT60CKOFF;
|
||||
writel(val, reg);
|
||||
}
|
||||
}
|
||||
if (data->disable_oc) {
|
||||
reg = usbmisc->base + MX53_USB_UH3_CTRL_OFFSET;
|
||||
|
@ -456,6 +468,10 @@ static const struct usbmisc_ops imx27_usbmisc_ops = {
|
|||
.init = usbmisc_imx27_init,
|
||||
};
|
||||
|
||||
static const struct usbmisc_ops imx51_usbmisc_ops = {
|
||||
.init = usbmisc_imx53_init,
|
||||
};
|
||||
|
||||
static const struct usbmisc_ops imx53_usbmisc_ops = {
|
||||
.init = usbmisc_imx53_init,
|
||||
};
|
||||
|
@ -479,6 +495,13 @@ static const struct usbmisc_ops imx7d_usbmisc_ops = {
|
|||
.set_wakeup = usbmisc_imx7d_set_wakeup,
|
||||
};
|
||||
|
||||
static inline bool is_imx53_usbmisc(struct imx_usbmisc_data *data)
|
||||
{
|
||||
struct imx_usbmisc *usbmisc = dev_get_drvdata(data->dev);
|
||||
|
||||
return usbmisc->ops == &imx53_usbmisc_ops;
|
||||
}
|
||||
|
||||
int imx_usbmisc_init(struct imx_usbmisc_data *data)
|
||||
{
|
||||
struct imx_usbmisc *usbmisc;
|
||||
|
@ -536,7 +559,7 @@ static const struct of_device_id usbmisc_imx_dt_ids[] = {
|
|||
},
|
||||
{
|
||||
.compatible = "fsl,imx51-usbmisc",
|
||||
.data = &imx53_usbmisc_ops,
|
||||
.data = &imx51_usbmisc_ops,
|
||||
},
|
||||
{
|
||||
.compatible = "fsl,imx53-usbmisc",
|
||||
|
|
|
@ -144,6 +144,8 @@ const struct of_device_id dwc2_of_match_table[] = {
|
|||
{ .compatible = "lantiq,xrx200-usb", .data = dwc2_set_ltq_params },
|
||||
{ .compatible = "snps,dwc2" },
|
||||
{ .compatible = "samsung,s3c6400-hsotg" },
|
||||
{ .compatible = "amlogic,meson8-usb",
|
||||
.data = dwc2_set_amlogic_params },
|
||||
{ .compatible = "amlogic,meson8b-usb",
|
||||
.data = dwc2_set_amlogic_params },
|
||||
{ .compatible = "amlogic,meson-gxbb-usb",
|
||||
|
|
|
@ -396,7 +396,11 @@ static int fsg_set_halt(struct fsg_dev *fsg, struct usb_ep *ep)
|
|||
/* Caller must hold fsg->lock */
|
||||
static void wakeup_thread(struct fsg_common *common)
|
||||
{
|
||||
smp_wmb(); /* ensure the write of bh->state is complete */
|
||||
/*
|
||||
* Ensure the reading of thread_wakeup_needed
|
||||
* and the writing of bh->state are completed
|
||||
*/
|
||||
smp_mb();
|
||||
/* Tell the main thread that something has happened */
|
||||
common->thread_wakeup_needed = 1;
|
||||
if (common->thread_task)
|
||||
|
@ -627,7 +631,12 @@ static int sleep_thread(struct fsg_common *common, bool can_freeze)
|
|||
}
|
||||
__set_current_state(TASK_RUNNING);
|
||||
common->thread_wakeup_needed = 0;
|
||||
smp_rmb(); /* ensure the latest bh->state is visible */
|
||||
|
||||
/*
|
||||
* Ensure the writing of thread_wakeup_needed
|
||||
* and the reading of bh->state are completed
|
||||
*/
|
||||
smp_mb();
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
|
@ -623,7 +623,6 @@ static void renesas_usb3_stop_controller(struct renesas_usb3 *usb3)
|
|||
{
|
||||
usb3_disconnect(usb3);
|
||||
usb3_write(usb3, 0, USB3_P0_INT_ENA);
|
||||
usb3_write(usb3, 0, USB3_PN_INT_ENA);
|
||||
usb3_write(usb3, 0, USB3_USB_OTG_INT_ENA);
|
||||
usb3_write(usb3, 0, USB3_USB_INT_ENA_1);
|
||||
usb3_write(usb3, 0, USB3_USB_INT_ENA_2);
|
||||
|
@ -1475,7 +1474,13 @@ static void usb3_request_done_pipen(struct renesas_usb3 *usb3,
|
|||
struct renesas_usb3_request *usb3_req,
|
||||
int status)
|
||||
{
|
||||
usb3_pn_stop(usb3);
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&usb3->lock, flags);
|
||||
if (usb3_pn_change(usb3, usb3_ep->num))
|
||||
usb3_pn_stop(usb3);
|
||||
spin_unlock_irqrestore(&usb3->lock, flags);
|
||||
|
||||
usb3_disable_pipe_irq(usb3, usb3_ep->num);
|
||||
usb3_request_done(usb3_ep, usb3_req, status);
|
||||
|
||||
|
@ -1504,30 +1509,46 @@ static void usb3_irq_epc_pipen_bfrdy(struct renesas_usb3 *usb3, int num)
|
|||
{
|
||||
struct renesas_usb3_ep *usb3_ep = usb3_get_ep(usb3, num);
|
||||
struct renesas_usb3_request *usb3_req = usb3_get_request(usb3_ep);
|
||||
bool done = false;
|
||||
|
||||
if (!usb3_req)
|
||||
return;
|
||||
|
||||
spin_lock(&usb3->lock);
|
||||
if (usb3_pn_change(usb3, num))
|
||||
goto out;
|
||||
|
||||
if (usb3_ep->dir_in) {
|
||||
/* Do not stop the IN pipe here to detect LSTTR interrupt */
|
||||
if (!usb3_write_pipe(usb3_ep, usb3_req, USB3_PN_WRITE))
|
||||
usb3_clear_bit(usb3, PN_INT_BFRDY, USB3_PN_INT_ENA);
|
||||
} else {
|
||||
if (!usb3_read_pipe(usb3_ep, usb3_req, USB3_PN_READ))
|
||||
usb3_request_done_pipen(usb3, usb3_ep, usb3_req, 0);
|
||||
done = true;
|
||||
}
|
||||
|
||||
out:
|
||||
/* need to unlock because usb3_request_done_pipen() locks it */
|
||||
spin_unlock(&usb3->lock);
|
||||
|
||||
if (done)
|
||||
usb3_request_done_pipen(usb3, usb3_ep, usb3_req, 0);
|
||||
}
|
||||
|
||||
static void usb3_irq_epc_pipen(struct renesas_usb3 *usb3, int num)
|
||||
{
|
||||
u32 pn_int_sta;
|
||||
|
||||
if (usb3_pn_change(usb3, num) < 0)
|
||||
spin_lock(&usb3->lock);
|
||||
if (usb3_pn_change(usb3, num) < 0) {
|
||||
spin_unlock(&usb3->lock);
|
||||
return;
|
||||
}
|
||||
|
||||
pn_int_sta = usb3_read(usb3, USB3_PN_INT_STA);
|
||||
pn_int_sta &= usb3_read(usb3, USB3_PN_INT_ENA);
|
||||
usb3_write(usb3, pn_int_sta, USB3_PN_INT_STA);
|
||||
spin_unlock(&usb3->lock);
|
||||
if (pn_int_sta & PN_INT_LSTTR)
|
||||
usb3_irq_epc_pipen_lsttr(usb3, num);
|
||||
if (pn_int_sta & PN_INT_BFRDY)
|
||||
|
@ -1660,6 +1681,7 @@ static int usb3_disable_pipe_n(struct renesas_usb3_ep *usb3_ep)
|
|||
|
||||
spin_lock_irqsave(&usb3->lock, flags);
|
||||
if (!usb3_pn_change(usb3, usb3_ep->num)) {
|
||||
usb3_write(usb3, 0, USB3_PN_INT_ENA);
|
||||
usb3_write(usb3, 0, USB3_PN_RAMMAP);
|
||||
usb3_clear_bit(usb3, PN_CON_EN, USB3_PN_CON);
|
||||
}
|
||||
|
@ -1799,6 +1821,9 @@ static int renesas_usb3_start(struct usb_gadget *gadget,
|
|||
/* hook up the driver */
|
||||
usb3->driver = driver;
|
||||
|
||||
pm_runtime_enable(usb3_to_dev(usb3));
|
||||
pm_runtime_get_sync(usb3_to_dev(usb3));
|
||||
|
||||
renesas_usb3_init_controller(usb3);
|
||||
|
||||
return 0;
|
||||
|
@ -1807,14 +1832,14 @@ static int renesas_usb3_start(struct usb_gadget *gadget,
|
|||
static int renesas_usb3_stop(struct usb_gadget *gadget)
|
||||
{
|
||||
struct renesas_usb3 *usb3 = gadget_to_renesas_usb3(gadget);
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&usb3->lock, flags);
|
||||
usb3->softconnect = false;
|
||||
usb3->gadget.speed = USB_SPEED_UNKNOWN;
|
||||
usb3->driver = NULL;
|
||||
renesas_usb3_stop_controller(usb3);
|
||||
spin_unlock_irqrestore(&usb3->lock, flags);
|
||||
|
||||
pm_runtime_put(usb3_to_dev(usb3));
|
||||
pm_runtime_disable(usb3_to_dev(usb3));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1891,9 +1916,6 @@ static int renesas_usb3_remove(struct platform_device *pdev)
|
|||
|
||||
device_remove_file(&pdev->dev, &dev_attr_role);
|
||||
|
||||
pm_runtime_put(&pdev->dev);
|
||||
pm_runtime_disable(&pdev->dev);
|
||||
|
||||
usb_del_gadget_udc(&usb3->gadget);
|
||||
|
||||
__renesas_usb3_ep_free_request(usb3->ep0_req);
|
||||
|
@ -2099,9 +2121,6 @@ static int renesas_usb3_probe(struct platform_device *pdev)
|
|||
|
||||
usb3->workaround_for_vbus = priv->workaround_for_vbus;
|
||||
|
||||
pm_runtime_enable(&pdev->dev);
|
||||
pm_runtime_get_sync(&pdev->dev);
|
||||
|
||||
dev_info(&pdev->dev, "probed\n");
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -245,6 +245,11 @@ static int dsps_check_status(struct musb *musb, void *unused)
|
|||
dsps_mod_timer_optional(glue);
|
||||
break;
|
||||
case OTG_STATE_A_WAIT_BCON:
|
||||
/* keep VBUS on for host-only mode */
|
||||
if (musb->port_mode == MUSB_PORT_MODE_HOST) {
|
||||
dsps_mod_timer_optional(glue);
|
||||
break;
|
||||
}
|
||||
musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
|
||||
skip_session = 1;
|
||||
/* fall */
|
||||
|
|
Loading…
Reference in New Issue
Block a user