[PATCH 2/2] usb: xhci: Reset halted endpoint if trb is noop

2017-09-29 Thread Lu Baolu
When a URB is cancled, xhci driver turns the untransferred trbs
into no-ops.  If an endpoint stalls on a no-op trb that belongs
to the cancelled URB, the event handler won't reset the endpoint.
Hence, it will stay halted.

Link: http://marc.info/?l=linux-usb&m=149582598330127&w=2

Signed-off-by: Lu Baolu 
---
 drivers/usb/host/xhci-ring.c | 19 ---
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index c75cfe7..b1de9f2 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -2577,15 +2577,20 @@ static int handle_tx_event(struct xhci_hcd *xhci,
(struct xhci_generic_trb *) ep_trb);
 
/*
-* No-op TRB should not trigger interrupts.
-* If ep_trb is a no-op TRB, it means the
-* corresponding TD has been cancelled. Just ignore
-* the TD.
+* No-op TRB could trigger interrupts in a case where
+* a URB was killed and a STALL_ERROR happens right
+* after the endpoint ring stopped. Reset the halted
+* endpoint. Otherwise, the endpoint remains stalled
+* indefinitely.
 */
if (trb_is_noop(ep_trb)) {
-   xhci_dbg(xhci,
-"ep_trb is a no-op TRB. Skip it for slot %u ep 
%u\n",
-slot_id, ep_index);
+   if (trb_comp_code == COMP_STALL_ERROR ||
+   xhci_requires_manual_halt_cleanup(xhci, ep_ctx,
+ trb_comp_code))
+   xhci_cleanup_halted_endpoint(xhci, slot_id,
+ep_index,
+ep_ring->stream_id,
+td, EP_HARD_RESET);
goto cleanup;
}
 
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] usb: xhci: Remove ep_trb from xhci_cleanup_halted_endpoint()

2017-09-29 Thread Lu Baolu
Function argument ep_trb for xhci_cleanup_halted_endpoint() isn't
needed anymore. Cleanup it.

Signed-off-by: Lu Baolu 
---
 drivers/usb/host/xhci-ring.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index a944365..c75cfe7 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -1823,8 +1823,7 @@ struct xhci_segment *trb_in_td(struct xhci_hcd *xhci,
 
 static void xhci_cleanup_halted_endpoint(struct xhci_hcd *xhci,
unsigned int slot_id, unsigned int ep_index,
-   unsigned int stream_id,
-   struct xhci_td *td, union xhci_trb *ep_trb,
+   unsigned int stream_id, struct xhci_td *td,
enum xhci_ep_reset_type reset_type)
 {
struct xhci_virt_ep *ep = &xhci->devs[slot_id]->eps[ep_index];
@@ -1967,8 +1966,7 @@ static int finish_td(struct xhci_hcd *xhci, struct 
xhci_td *td,
 * The class driver clears the device side halt later.
 */
xhci_cleanup_halted_endpoint(xhci, slot_id, ep_index,
-   ep_ring->stream_id, td, ep_trb,
-   EP_HARD_RESET);
+   ep_ring->stream_id, td, EP_HARD_RESET);
} else {
/* Update ring dequeue pointer */
while (ep_ring->dequeue != td->last_trb)
@@ -2330,7 +2328,7 @@ static int handle_tx_event(struct xhci_hcd *xhci,
case COMP_INVALID_STREAM_TYPE_ERROR:
case COMP_INVALID_STREAM_ID_ERROR:
xhci_cleanup_halted_endpoint(xhci, slot_id, ep_index, 0,
-NULL, NULL, EP_SOFT_RESET);
+NULL, EP_SOFT_RESET);
goto cleanup;
case COMP_RING_UNDERRUN:
case COMP_RING_OVERRUN:
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: phy: tegra: Fix phy suspend for UDC

2017-09-29 Thread Jon Hunter

On 29/09/17 15:57, Dmitry Osipenko wrote:
> On 29.09.2017 16:10, Jon Hunter wrote:
>> Adding Dmitry ...
>>
>> Felipe, Thierry, this is needed for v4.14-rc because suspend is currently
>> broken for some Tegra devices.
>>
>> Jon
>>
>> On 29/09/17 14:06, Jon Hunter wrote:
>>> Commit dfebb5f43a78 ("usb: chipidea: Add support for Tegra20/30/114/124")
>>> added UDC support for Tegra but with UDC support enabled, is was found
>>> that Tegra30, Tegra114 and Tegra124 would hang on entry to suspend.
>>>
>>> The hang occurred during the suspend of the USB PHY when the Tegra PHY
>>> driver attempted to disable the PHY clock. The problem is that before
>>> the Tegra PHY driver is suspended, the chipidea driver already disabled
>>> the PHY clock and when the Tegra PHY driver suspended, it could not read
>>> DEVLC register and caused the device to hang.
>>>
>>> The Tegra USB PHY driver is used by both the Tegra EHCI driver and now
>>> the chipidea UDC driver and so simply removing the disabling of the PHY
>>> clock from the USB PHY driver would not work for the Tegra EHCI driver.
>>> Fortunately, the status of the USB PHY clock can be read from the
>>> USB_SUSP_CTRL register and therefore, to workaround this issue, simply
>>> poll the register prior to disabling the clock in USB PHY driver to see
>>> if clock gating has already been initiated. Please note that it can take
>>> a few uS for the clock to disable and so simply reading this status
>>> register once on entry is not sufficient.
>>>
>>> Please note that no issues are seen with Tegra20 because it has a slightly
>>> different PHY to Tegra30/114/124.
>>>
>>
>> I forgot the fixes tag ...
>>
>> Fixes: dfebb5f43a78 ("usb: chipidea: Add support for Tegra20/30/114/124")
>>  
>>> Signed-off-by: Jon Hunter 
>>> ---
>>>  drivers/usb/phy/phy-tegra-usb.c | 8 
>>>  1 file changed, 8 insertions(+)
>>>
>>> diff --git a/drivers/usb/phy/phy-tegra-usb.c 
>>> b/drivers/usb/phy/phy-tegra-usb.c
>>> index 5fe4a5704bde..c8fff99bd16e 100644
>>> --- a/drivers/usb/phy/phy-tegra-usb.c
>>> +++ b/drivers/usb/phy/phy-tegra-usb.c
>>> @@ -329,6 +329,14 @@ static void utmi_phy_clk_disable(struct tegra_usb_phy 
>>> *phy)
>>> unsigned long val;
>>> void __iomem *base = phy->regs;
>>>  
>>> +   /*
>>> +* The USB driver may have already initiated the phy clock
>>> +* disable so wait to see if the clock turns off and if not
>>> +* then proceed with gating the clock.
>>> +*/
>>> +   if (utmi_wait_register(base + USB_SUSP_CTRL, USB_PHY_CLK_VALID, 0) == 0)
>>> +   return;
>>> +
>>> if (phy->is_legacy_phy) {
>>> val = readl(base + USB_SUSP_CTRL);
>>> val |= USB_SUSP_SET;
>>>
>>
> 
> Adding analogical check to clk_enable fixes "utmi_phy_clk_enable: timeout
> waiting for phy to stabilize" error message during of kernel boot-up on 
> Tegra20.
> 
> What about to incorporate it to this patch?
> 
> @@ -354,16 +354,25 @@ static void utmi_phy_clk_disable(struct tegra_usb_phy 
> *phy)
>   pr_err("%s: timeout waiting for phy to stabilize\n", __func__);
>  }
> 
>  static void utmi_phy_clk_enable(struct tegra_usb_phy *phy)
>  {
>   unsigned long val;
>   void __iomem *base = phy->regs;
> 
> + /*
> +  * The USB driver may have already initiated the phy clock
> +  * enable so wait to see if the clock turns on and if not
> +  * then proceed with ungating the clock.
> +  */
> + if (utmi_wait_register(base + USB_SUSP_CTRL, USB_PHY_CLK_VALID,
> +  USB_PHY_CLK_VALID) == 0)
> + return;
> +
>   if (phy->is_legacy_phy) {
>   val = readl(base + USB_SUSP_CTRL);
>   val |= USB_SUSP_CLR;
>   writel(val, base + USB_SUSP_CTRL);
> 
>   udelay(10);
> 
>   val = readl(base + USB_SUSP_CTRL);
> 

Yes, I see that message as well. However, looks like that has been
around for a long time (for all v4.x kernels)! I also see the following
on Tegra20-trimslice (for all v4.x kernels as well) ...

[1.852474] ulpi_phy_power_on: ulpi write failed
[1.857086] tegra-ehci c5004000.usb: Failed to power on the phy
[1.863039] tegra-ehci: probe of c5004000.usb failed with error -110

The above is not related to this issue though. Let me take a look at bit
closer at these messages.

Cheers
Jon

-- 
nvpublic
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: phy: tegra: Fix phy suspend for UDC

2017-09-29 Thread Dmitry Osipenko
On 29.09.2017 17:57, Dmitry Osipenko wrote:
> On 29.09.2017 16:10, Jon Hunter wrote:
>> Adding Dmitry ...
>>
>> Felipe, Thierry, this is needed for v4.14-rc because suspend is currently
>> broken for some Tegra devices.
>>
>> Jon
>>
>> On 29/09/17 14:06, Jon Hunter wrote:
>>> Commit dfebb5f43a78 ("usb: chipidea: Add support for Tegra20/30/114/124")
>>> added UDC support for Tegra but with UDC support enabled, is was found
>>> that Tegra30, Tegra114 and Tegra124 would hang on entry to suspend.
>>>
>>> The hang occurred during the suspend of the USB PHY when the Tegra PHY
>>> driver attempted to disable the PHY clock. The problem is that before
>>> the Tegra PHY driver is suspended, the chipidea driver already disabled
>>> the PHY clock and when the Tegra PHY driver suspended, it could not read
>>> DEVLC register and caused the device to hang.
>>>
>>> The Tegra USB PHY driver is used by both the Tegra EHCI driver and now
>>> the chipidea UDC driver and so simply removing the disabling of the PHY
>>> clock from the USB PHY driver would not work for the Tegra EHCI driver.
>>> Fortunately, the status of the USB PHY clock can be read from the
>>> USB_SUSP_CTRL register and therefore, to workaround this issue, simply
>>> poll the register prior to disabling the clock in USB PHY driver to see
>>> if clock gating has already been initiated. Please note that it can take
>>> a few uS for the clock to disable and so simply reading this status
>>> register once on entry is not sufficient.
>>>
>>> Please note that no issues are seen with Tegra20 because it has a slightly
>>> different PHY to Tegra30/114/124.
>>>
>>
>> I forgot the fixes tag ...
>>
>> Fixes: dfebb5f43a78 ("usb: chipidea: Add support for Tegra20/30/114/124")
>>  
>>> Signed-off-by: Jon Hunter 
>>> ---
>>>  drivers/usb/phy/phy-tegra-usb.c | 8 
>>>  1 file changed, 8 insertions(+)
>>>
>>> diff --git a/drivers/usb/phy/phy-tegra-usb.c 
>>> b/drivers/usb/phy/phy-tegra-usb.c
>>> index 5fe4a5704bde..c8fff99bd16e 100644
>>> --- a/drivers/usb/phy/phy-tegra-usb.c
>>> +++ b/drivers/usb/phy/phy-tegra-usb.c
>>> @@ -329,6 +329,14 @@ static void utmi_phy_clk_disable(struct tegra_usb_phy 
>>> *phy)
>>> unsigned long val;
>>> void __iomem *base = phy->regs;
>>>  
>>> +   /*
>>> +* The USB driver may have already initiated the phy clock
>>> +* disable so wait to see if the clock turns off and if not
>>> +* then proceed with gating the clock.
>>> +*/
>>> +   if (utmi_wait_register(base + USB_SUSP_CTRL, USB_PHY_CLK_VALID, 0) == 0)
>>> +   return;
>>> +
>>> if (phy->is_legacy_phy) {
>>> val = readl(base + USB_SUSP_CTRL);
>>> val |= USB_SUSP_SET;
>>>
>>
> 
> Adding analogical check to clk_enable fixes "utmi_phy_clk_enable: timeout
> waiting for phy to stabilize" error message during of kernel boot-up on 
> Tegra20.
> 

'During of UDC probe' would me more correct to say and UDC driver still working
excellent.


-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: phy: tegra: Fix phy suspend for UDC

2017-09-29 Thread Dmitry Osipenko
On 29.09.2017 16:10, Jon Hunter wrote:
> Adding Dmitry ...
> 
> Felipe, Thierry, this is needed for v4.14-rc because suspend is currently
> broken for some Tegra devices.
> 
> Jon
> 
> On 29/09/17 14:06, Jon Hunter wrote:
>> Commit dfebb5f43a78 ("usb: chipidea: Add support for Tegra20/30/114/124")
>> added UDC support for Tegra but with UDC support enabled, is was found
>> that Tegra30, Tegra114 and Tegra124 would hang on entry to suspend.
>>
>> The hang occurred during the suspend of the USB PHY when the Tegra PHY
>> driver attempted to disable the PHY clock. The problem is that before
>> the Tegra PHY driver is suspended, the chipidea driver already disabled
>> the PHY clock and when the Tegra PHY driver suspended, it could not read
>> DEVLC register and caused the device to hang.
>>
>> The Tegra USB PHY driver is used by both the Tegra EHCI driver and now
>> the chipidea UDC driver and so simply removing the disabling of the PHY
>> clock from the USB PHY driver would not work for the Tegra EHCI driver.
>> Fortunately, the status of the USB PHY clock can be read from the
>> USB_SUSP_CTRL register and therefore, to workaround this issue, simply
>> poll the register prior to disabling the clock in USB PHY driver to see
>> if clock gating has already been initiated. Please note that it can take
>> a few uS for the clock to disable and so simply reading this status
>> register once on entry is not sufficient.
>>
>> Please note that no issues are seen with Tegra20 because it has a slightly
>> different PHY to Tegra30/114/124.
>>
> 
> I forgot the fixes tag ...
> 
> Fixes: dfebb5f43a78 ("usb: chipidea: Add support for Tegra20/30/114/124")
>  
>> Signed-off-by: Jon Hunter 
>> ---
>>  drivers/usb/phy/phy-tegra-usb.c | 8 
>>  1 file changed, 8 insertions(+)
>>
>> diff --git a/drivers/usb/phy/phy-tegra-usb.c 
>> b/drivers/usb/phy/phy-tegra-usb.c
>> index 5fe4a5704bde..c8fff99bd16e 100644
>> --- a/drivers/usb/phy/phy-tegra-usb.c
>> +++ b/drivers/usb/phy/phy-tegra-usb.c
>> @@ -329,6 +329,14 @@ static void utmi_phy_clk_disable(struct tegra_usb_phy 
>> *phy)
>>  unsigned long val;
>>  void __iomem *base = phy->regs;
>>  
>> +/*
>> + * The USB driver may have already initiated the phy clock
>> + * disable so wait to see if the clock turns off and if not
>> + * then proceed with gating the clock.
>> + */
>> +if (utmi_wait_register(base + USB_SUSP_CTRL, USB_PHY_CLK_VALID, 0) == 0)
>> +return;
>> +
>>  if (phy->is_legacy_phy) {
>>  val = readl(base + USB_SUSP_CTRL);
>>  val |= USB_SUSP_SET;
>>
> 

Adding analogical check to clk_enable fixes "utmi_phy_clk_enable: timeout
waiting for phy to stabilize" error message during of kernel boot-up on Tegra20.

What about to incorporate it to this patch?

@@ -354,16 +354,25 @@ static void utmi_phy_clk_disable(struct tegra_usb_phy 
*phy)
pr_err("%s: timeout waiting for phy to stabilize\n", __func__);
 }

 static void utmi_phy_clk_enable(struct tegra_usb_phy *phy)
 {
unsigned long val;
void __iomem *base = phy->regs;

+   /*
+* The USB driver may have already initiated the phy clock
+* enable so wait to see if the clock turns on and if not
+* then proceed with ungating the clock.
+*/
+   if (utmi_wait_register(base + USB_SUSP_CTRL, USB_PHY_CLK_VALID,
+USB_PHY_CLK_VALID) == 0)
+   return;
+
if (phy->is_legacy_phy) {
val = readl(base + USB_SUSP_CTRL);
val |= USB_SUSP_CLR;
writel(val, base + USB_SUSP_CTRL);

udelay(10);

val = readl(base + USB_SUSP_CTRL);

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: usbtest: fix NULL pointer dereference

2017-09-29 Thread Alan Stern
If the usbtest driver encounters a device with an IN bulk endpoint but
no OUT bulk endpoint, it will try to dereference a NULL pointer
(out->desc.bEndpointAddress).  The problem can be solved by adding a
missing test.

Signed-off-by: Alan Stern 
Reported-by: Andrey Konovalov 
Tested-by: Andrey Konovalov 

---


[as1849]



 drivers/usb/misc/usbtest.c |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Index: usb-4.x/drivers/usb/misc/usbtest.c
===
--- usb-4.x.orig/drivers/usb/misc/usbtest.c
+++ usb-4.x/drivers/usb/misc/usbtest.c
@@ -202,12 +202,13 @@ found:
return tmp;
}
 
-   if (in) {
+   if (in)
dev->in_pipe = usb_rcvbulkpipe(udev,
in->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
+   if (out)
dev->out_pipe = usb_sndbulkpipe(udev,
out->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
-   }
+
if (iso_in) {
dev->iso_in = &iso_in->desc;
dev->in_iso_pipe = usb_rcvisocpipe(udev,

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCHv2 2/7] usb: dwc2: add support for STM32F7 USB OTG HS

2017-09-29 Thread Amelie DELAUNAY
Hi,

Gentle ping for driver review submitted on August 28th.

Thanks,
Amelie

On 08/28/2017 04:20 PM, Amelie Delaunay wrote:
> This patch adds the dwc2_set_params function for STM32F7 USB OTG HS.
> 
> Signed-off-by: Amelie Delaunay 
> ---
>   drivers/usb/dwc2/params.c | 11 +++
>   1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c
> index a3ffe97..d5b672d 100644
> --- a/drivers/usb/dwc2/params.c
> +++ b/drivers/usb/dwc2/params.c
> @@ -136,6 +136,15 @@ static void dwc2_set_stm32f4x9_fsotg_params(struct 
> dwc2_hsotg *hsotg)
>   p->activate_stm_fs_transceiver = true;
>   }
>   
> +static void dwc2_set_stm32f7_hsotg_params(struct dwc2_hsotg *hsotg)
> +{
> + struct dwc2_core_params *p = &hsotg->params;
> +
> + p->host_rx_fifo_size = 622;
> + p->host_nperio_tx_fifo_size = 128;
> + p->host_perio_tx_fifo_size = 256;
> +}
> +
>   const struct of_device_id dwc2_of_match_table[] = {
>   { .compatible = "brcm,bcm2835-usb", .data = dwc2_set_bcm_params },
>   { .compatible = "hisilicon,hi6220-usb", .data = dwc2_set_his_params  },
> @@ -154,6 +163,8 @@ const struct of_device_id dwc2_of_match_table[] = {
>   { .compatible = "st,stm32f4x9-fsotg",
> .data = dwc2_set_stm32f4x9_fsotg_params },
>   { .compatible = "st,stm32f4x9-hsotg" },
> + { .compatible = "st,stm32f7-hsotg",
> +   .data = dwc2_set_stm32f7_hsotg_params },
>   {},
>   };
>   MODULE_DEVICE_TABLE(of, dwc2_of_match_table);
> N�r��yb�X��ǧv�^�)޺{.n�+{��^n�r���z���h�&���G���h�(�階�ݢj"���m��z�ޖ���f���h���~�m�

Re: [PATCH 07/12] usb: mtu3: add support for usb3.1 IP

2017-09-29 Thread Chunfeng Yun
On Thu, 2017-09-28 at 08:17 +0800, Chunfeng Yun wrote:
> Support SuperSpeedPlus for usb3.1 device IP
> 
> Signed-off-by: Chunfeng Yun 
> ---
>  drivers/usb/mtu3/mtu3.h|1 +
>  drivers/usb/mtu3/mtu3_core.c   |   14 +++---
>  drivers/usb/mtu3/mtu3_gadget.c |3 ++-
>  drivers/usb/mtu3/mtu3_gadget_ep0.c |   16 
>  drivers/usb/mtu3/mtu3_hw_regs.h|1 +
>  5 files changed, 23 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/usb/mtu3/mtu3.h b/drivers/usb/mtu3/mtu3.h
> index b0c2b5d..d80e4e8 100644
> --- a/drivers/usb/mtu3/mtu3.h
> +++ b/drivers/usb/mtu3/mtu3.h
> @@ -94,6 +94,7 @@ enum mtu3_speed {
>   MTU3_SPEED_FULL = 1,
>   MTU3_SPEED_HIGH = 3,
>   MTU3_SPEED_SUPER = 4,
> + MTU3_SPEED_SUPER_PLUS = 5,
>  };
>  
>  /**
> diff --git a/drivers/usb/mtu3/mtu3_core.c b/drivers/usb/mtu3/mtu3_core.c
> index cd4528f..67f7a30 100644
> --- a/drivers/usb/mtu3/mtu3_core.c
> +++ b/drivers/usb/mtu3/mtu3_core.c
> @@ -237,7 +237,7 @@ void mtu3_ep_stall_set(struct mtu3_ep *mep, bool set)
>  
>  void mtu3_dev_on_off(struct mtu3 *mtu, int is_on)
>  {
> - if (mtu->is_u3_ip && (mtu->max_speed == USB_SPEED_SUPER))
> + if (mtu->is_u3_ip && mtu->max_speed >= USB_SPEED_SUPER)
>   mtu3_ss_func_set(mtu, is_on);
>   else
>   mtu3_hs_softconn_set(mtu, is_on);
> @@ -547,6 +547,9 @@ static void mtu3_set_speed(struct mtu3 *mtu)
>   mtu3_clrbits(mbase, U3D_USB3_CONFIG, USB3_EN);
>   /* HS/FS detected by HW */
>   mtu3_setbits(mbase, U3D_POWER_MANAGEMENT, HS_ENABLE);
> + } else if (mtu->max_speed == USB_SPEED_SUPER) {
> + mtu3_clrbits(mtu->ippc_base, SSUSB_U3_CTRL(0),
> +  SSUSB_U3_PORT_SSP_SPEED);
>   }
>  
>   dev_info(mtu->dev, "max_speed: %s\n",
> @@ -624,6 +627,10 @@ static irqreturn_t mtu3_link_isr(struct mtu3 *mtu)
>   udev_speed = USB_SPEED_SUPER;
>   maxpkt = 512;
>   break;
> + case MTU3_SPEED_SUPER_PLUS:
> + udev_speed = USB_SPEED_SUPER_PLUS;
> + maxpkt = 512;
> + break;
>   default:
>   udev_speed = USB_SPEED_UNKNOWN;
>   break;
> @@ -825,14 +832,15 @@ int ssusb_gadget_init(struct ssusb_mtk *ssusb)
>   case USB_SPEED_FULL:
>   case USB_SPEED_HIGH:
>   case USB_SPEED_SUPER:
> + case USB_SPEED_SUPER_PLUS:
>   break;
>   default:
>   dev_err(dev, "invalid max_speed: %s\n",
>   usb_speed_string(mtu->max_speed));
>   /* fall through */
>   case USB_SPEED_UNKNOWN:
> - /* default as SS */
> - mtu->max_speed = USB_SPEED_SUPER;
> + /* default as SSP */
> + mtu->max_speed = USB_SPEED_SUPER_PLUS;
>   break;
>   }
>  
> diff --git a/drivers/usb/mtu3/mtu3_gadget.c b/drivers/usb/mtu3/mtu3_gadget.c
> index 434fca5..b495471 100644
> --- a/drivers/usb/mtu3/mtu3_gadget.c
> +++ b/drivers/usb/mtu3/mtu3_gadget.c
> @@ -89,6 +89,7 @@ static int mtu3_ep_enable(struct mtu3_ep *mep)
>  
>   switch (mtu->g.speed) {
>   case USB_SPEED_SUPER:
> + case USB_SPEED_SUPER_PLUS:
>   if (usb_endpoint_xfer_int(desc) ||
>   usb_endpoint_xfer_isoc(desc)) {
>   interval = desc->bInterval;
> @@ -456,7 +457,7 @@ static int mtu3_gadget_wakeup(struct usb_gadget *gadget)
>   return  -EOPNOTSUPP;
>  
>   spin_lock_irqsave(&mtu->lock, flags);
> - if (mtu->g.speed == USB_SPEED_SUPER) {
> + if (mtu->g.speed >= USB_SPEED_SUPER) {
>   mtu3_setbits(mtu->mac_base, U3D_LINK_POWER_CONTROL, UX_EXIT);
>   } else {
>   mtu3_setbits(mtu->mac_base, U3D_POWER_MANAGEMENT, RESUME);
> diff --git a/drivers/usb/mtu3/mtu3_gadget_ep0.c 
> b/drivers/usb/mtu3/mtu3_gadget_ep0.c
> index 958d74d..1ca77e8 100644
> --- a/drivers/usb/mtu3/mtu3_gadget_ep0.c
> +++ b/drivers/usb/mtu3/mtu3_gadget_ep0.c
> @@ -212,8 +212,8 @@ static int ep0_set_sel(struct mtu3 *mtu, struct 
> usb_ctrlrequest *setup)
>   case USB_RECIP_DEVICE:
>   result[0] = mtu->is_self_powered << USB_DEVICE_SELF_POWERED;
>   result[0] |= mtu->may_wakeup << USB_DEVICE_REMOTE_WAKEUP;
> - /* superspeed only */
> - if (mtu->g.speed == USB_SPEED_SUPER) {
> +
> + if (mtu->g.speed >= USB_SPEED_SUPER) {
>   result[0] |= mtu->u1_enable << USB_DEV_STAT_U1_ENABLED;
>   result[0] |= mtu->u2_enable << USB_DEV_STAT_U2_ENABLED;
>   }
> @@ -329,8 +329,8 @@ static int ep0_handle_feature_dev(struct mtu3 *mtu,
>   handled = handle_test_mode(mtu, setup);
>   break;
>   case USB_DEVICE_U1_ENABLE:
> - if (mtu->g.speed != USB_SPEED_SUPER ||
> - mtu->g.state != USB_STATE_CONFIGURED)
> + if (mtu->g.speed <= USB_SPEED_SUPER ||

Re: [PATCH] extcon: Split out extcon header file for consumer and provider device

2017-09-29 Thread Sebastian Reichel
Hi,

On Fri, Sep 29, 2017 at 09:01:45AM +0900, Chanwoo Choi wrote:
> The extcon has two type of extcon devices as following.
> - 'extcon provider deivce' adds new extcon device and detect the
>state/properties of external connector. Also, it notifies the
>state/properties to the extcon consumer device.
> - 'extcon consumer device' gets the change state/properties
>from extcon provider device.
> Prior to that, include/linux/extcon.h contains all exported API for
> both provider and consumer device driver. To clarify the meaning of
> header file and to remove the wrong use-case on consumer device,
> this patch separates into extcon.h and extcon-provider.h.
> 
> [Description for include/linux/{extcon.h|extcon-provider.h}]
> - extcon.h includes the extcon API and data structure for extcon consumer
>   device driver. This header file contains the following APIs:
>   : Register/unregister the notifier to catch the change of extcon device
>   : Get the extcon device instance
>   : Get the extcon device name
>   : Get the state of each external connector
>   : Get the property value of each external connector
>   : Get the property capability of each external connector
> 
> - extcon-provider.h includes the extcon API and data structure for extcon
>   provider device driver. This header file contains the following APIs:
>   : Include 'include/linux/extcon.h'
>   : Allocate the memory for extcon device instance
>   : Register/unregister extcon device
>   : Set the state of each external connector
>   : Set the property value of each external connector
>   : Set the property capability of each external connector
> 

[...]

>  drivers/power/supply/qcom_smbb.c  |   2 +-

[...]

Acked-by: Sebastian Reichel 

-- Sebastian


signature.asc
Description: PGP signature


Re: [PATCH] usb: phy: tegra: Fix phy suspend for UDC

2017-09-29 Thread Jon Hunter
Adding Dmitry ...

Felipe, Thierry, this is needed for v4.14-rc because suspend is currently
broken for some Tegra devices.

Jon

On 29/09/17 14:06, Jon Hunter wrote:
> Commit dfebb5f43a78 ("usb: chipidea: Add support for Tegra20/30/114/124")
> added UDC support for Tegra but with UDC support enabled, is was found
> that Tegra30, Tegra114 and Tegra124 would hang on entry to suspend.
> 
> The hang occurred during the suspend of the USB PHY when the Tegra PHY
> driver attempted to disable the PHY clock. The problem is that before
> the Tegra PHY driver is suspended, the chipidea driver already disabled
> the PHY clock and when the Tegra PHY driver suspended, it could not read
> DEVLC register and caused the device to hang.
> 
> The Tegra USB PHY driver is used by both the Tegra EHCI driver and now
> the chipidea UDC driver and so simply removing the disabling of the PHY
> clock from the USB PHY driver would not work for the Tegra EHCI driver.
> Fortunately, the status of the USB PHY clock can be read from the
> USB_SUSP_CTRL register and therefore, to workaround this issue, simply
> poll the register prior to disabling the clock in USB PHY driver to see
> if clock gating has already been initiated. Please note that it can take
> a few uS for the clock to disable and so simply reading this status
> register once on entry is not sufficient.
> 
> Please note that no issues are seen with Tegra20 because it has a slightly
> different PHY to Tegra30/114/124.
>

I forgot the fixes tag ...

Fixes: dfebb5f43a78 ("usb: chipidea: Add support for Tegra20/30/114/124")
 
> Signed-off-by: Jon Hunter 
> ---
>  drivers/usb/phy/phy-tegra-usb.c | 8 
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
> index 5fe4a5704bde..c8fff99bd16e 100644
> --- a/drivers/usb/phy/phy-tegra-usb.c
> +++ b/drivers/usb/phy/phy-tegra-usb.c
> @@ -329,6 +329,14 @@ static void utmi_phy_clk_disable(struct tegra_usb_phy 
> *phy)
>   unsigned long val;
>   void __iomem *base = phy->regs;
>  
> + /*
> +  * The USB driver may have already initiated the phy clock
> +  * disable so wait to see if the clock turns off and if not
> +  * then proceed with gating the clock.
> +  */
> + if (utmi_wait_register(base + USB_SUSP_CTRL, USB_PHY_CLK_VALID, 0) == 0)
> + return;
> +
>   if (phy->is_legacy_phy) {
>   val = readl(base + USB_SUSP_CTRL);
>   val |= USB_SUSP_SET;
> 

-- 
nvpublic
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: phy: tegra: Fix phy suspend for UDC

2017-09-29 Thread Jon Hunter
Commit dfebb5f43a78 ("usb: chipidea: Add support for Tegra20/30/114/124")
added UDC support for Tegra but with UDC support enabled, is was found
that Tegra30, Tegra114 and Tegra124 would hang on entry to suspend.

The hang occurred during the suspend of the USB PHY when the Tegra PHY
driver attempted to disable the PHY clock. The problem is that before
the Tegra PHY driver is suspended, the chipidea driver already disabled
the PHY clock and when the Tegra PHY driver suspended, it could not read
DEVLC register and caused the device to hang.

The Tegra USB PHY driver is used by both the Tegra EHCI driver and now
the chipidea UDC driver and so simply removing the disabling of the PHY
clock from the USB PHY driver would not work for the Tegra EHCI driver.
Fortunately, the status of the USB PHY clock can be read from the
USB_SUSP_CTRL register and therefore, to workaround this issue, simply
poll the register prior to disabling the clock in USB PHY driver to see
if clock gating has already been initiated. Please note that it can take
a few uS for the clock to disable and so simply reading this status
register once on entry is not sufficient.

Please note that no issues are seen with Tegra20 because it has a slightly
different PHY to Tegra30/114/124.

Signed-off-by: Jon Hunter 
---
 drivers/usb/phy/phy-tegra-usb.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
index 5fe4a5704bde..c8fff99bd16e 100644
--- a/drivers/usb/phy/phy-tegra-usb.c
+++ b/drivers/usb/phy/phy-tegra-usb.c
@@ -329,6 +329,14 @@ static void utmi_phy_clk_disable(struct tegra_usb_phy *phy)
unsigned long val;
void __iomem *base = phy->regs;
 
+   /*
+* The USB driver may have already initiated the phy clock
+* disable so wait to see if the clock turns off and if not
+* then proceed with gating the clock.
+*/
+   if (utmi_wait_register(base + USB_SUSP_CTRL, USB_PHY_CLK_VALID, 0) == 0)
+   return;
+
if (phy->is_legacy_phy) {
val = readl(base + USB_SUSP_CTRL);
val |= USB_SUSP_SET;
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] usb: gadget: udc: renesas_usb3: add support for generic phy

2017-09-29 Thread Yoshihiro Shimoda
This patch adds support for generic phy as an optional. If you want
to use a generic phy (e.g. phy-rcar-gen3-usb3 driver) on this driver,
you have to do "insmod phy-rcar-gen3-usb3.ko" first for now.

Signed-off-by: Yoshihiro Shimoda 
---
 .../devicetree/bindings/usb/renesas_usb3.txt   |  4 
 drivers/usb/gadget/udc/renesas_usb3.c  | 26 --
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/renesas_usb3.txt 
b/Documentation/devicetree/bindings/usb/renesas_usb3.txt
index e280258..87a45e2 100644
--- a/Documentation/devicetree/bindings/usb/renesas_usb3.txt
+++ b/Documentation/devicetree/bindings/usb/renesas_usb3.txt
@@ -15,6 +15,10 @@ Required properties:
   - interrupts: Interrupt specifier for the USB3.0 Peripheral
   - clocks: clock phandle and specifier pair
 
+Optional properties:
+  - phys: phandle + phy specifier pair
+  - phy-names: must be "usb"
+
 Example of R-Car H3 ES1.x:
usb3_peri0: usb@ee02 {
compatible = "renesas,r8a7795-usb3-peri",
diff --git a/drivers/usb/gadget/udc/renesas_usb3.c 
b/drivers/usb/gadget/udc/renesas_usb3.c
index d55a06b..3ea4e91 100644
--- a/drivers/usb/gadget/udc/renesas_usb3.c
+++ b/drivers/usb/gadget/udc/renesas_usb3.c
@@ -1,7 +1,7 @@
 /*
  * Renesas USB3.0 Peripheral driver (USB gadget)
  *
- * Copyright (C) 2015  Renesas Electronics Corporation
+ * Copyright (C) 2015-2017  Renesas Electronics Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -334,6 +335,7 @@ struct renesas_usb3 {
struct usb_gadget_driver *driver;
struct extcon_dev *extcon;
struct work_struct extcon_work;
+   struct phy *phy;
 
struct renesas_usb3_ep *usb3_ep;
int num_usb3_eps;
@@ -2228,6 +2230,9 @@ static int renesas_usb3_start(struct usb_gadget *gadget,
/* hook up the driver */
usb3->driver = driver;
 
+   if (usb3->phy)
+   phy_init(usb3->phy);
+
pm_runtime_get_sync(usb3_to_dev(usb3));
 
renesas_usb3_init_controller(usb3);
@@ -2244,6 +2249,9 @@ static int renesas_usb3_stop(struct usb_gadget *gadget)
usb3->driver = NULL;
renesas_usb3_stop_controller(usb3);
 
+   if (usb3->phy)
+   phy_exit(usb3->phy);
+
pm_runtime_put(usb3_to_dev(usb3));
 
return 0;
@@ -2392,6 +2400,8 @@ static int renesas_usb3_remove(struct platform_device 
*pdev)
renesas_usb3_dma_free_prd(usb3, &pdev->dev);
 
__renesas_usb3_ep_free_request(usb3->ep0_req);
+   if (usb3->phy)
+   phy_put(usb3->phy);
pm_runtime_disable(usb3_to_dev(usb3));
 
return 0;
@@ -2623,11 +2633,19 @@ static int renesas_usb3_probe(struct platform_device 
*pdev)
if (ret < 0)
goto err_dev_create;
 
+   /*
+* This is an optional. So, if this driver cannot get a phy,
+* this driver will not handle a phy anymore.
+*/
+   usb3->phy = devm_phy_get(&pdev->dev, "usb");
+   if (IS_ERR(usb3->phy))
+   usb3->phy = NULL;
+
usb3->workaround_for_vbus = priv->workaround_for_vbus;
 
renesas_usb3_debugfs_init(usb3, &pdev->dev);
 
-   dev_info(&pdev->dev, "probed\n");
+   dev_info(&pdev->dev, "probed%s\n", usb3->phy ? " with phy" : "");
pm_runtime_enable(usb3_to_dev(usb3));
 
return 0;
@@ -2654,6 +2672,8 @@ static int renesas_usb3_suspend(struct device *dev)
return 0;
 
renesas_usb3_stop_controller(usb3);
+   if (usb3->phy)
+   phy_exit(usb3->phy);
pm_runtime_put(dev);
 
return 0;
@@ -2667,6 +2687,8 @@ static int renesas_usb3_resume(struct device *dev)
if (!usb3->driver)
return 0;
 
+   if (usb3->phy)
+   phy_init(usb3->phy);
pm_runtime_get_sync(dev);
renesas_usb3_init_controller(usb3);
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] usb: gadget: udc: renesas_usb3: move pm_runtime_{en,dis}able()

2017-09-29 Thread Yoshihiro Shimoda
From: Kazuya Mizuguchi 

This patch moves pm_runtime_{en,dis}able() call timing to
renesas_usb3_{probe,remove}() for supporting PM_SLEEP feature in
the future.

Signed-off-by: Kazuya Mizuguchi 
[shimoda: Revise the commit log]
Signed-off-by: Yoshihiro Shimoda 
---
 drivers/usb/gadget/udc/renesas_usb3.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/udc/renesas_usb3.c 
b/drivers/usb/gadget/udc/renesas_usb3.c
index df37c1e..7d99774 100644
--- a/drivers/usb/gadget/udc/renesas_usb3.c
+++ b/drivers/usb/gadget/udc/renesas_usb3.c
@@ -2228,7 +2228,6 @@ 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);
@@ -2246,7 +2245,6 @@ static int renesas_usb3_stop(struct usb_gadget *gadget)
renesas_usb3_stop_controller(usb3);
 
pm_runtime_put(usb3_to_dev(usb3));
-   pm_runtime_disable(usb3_to_dev(usb3));
 
return 0;
 }
@@ -2394,6 +2392,7 @@ static int renesas_usb3_remove(struct platform_device 
*pdev)
renesas_usb3_dma_free_prd(usb3, &pdev->dev);
 
__renesas_usb3_ep_free_request(usb3->ep0_req);
+   pm_runtime_disable(usb3_to_dev(usb3));
 
return 0;
 }
@@ -2629,6 +2628,7 @@ static int renesas_usb3_probe(struct platform_device 
*pdev)
renesas_usb3_debugfs_init(usb3, &pdev->dev);
 
dev_info(&pdev->dev, "probed\n");
+   pm_runtime_enable(usb3_to_dev(usb3));
 
return 0;
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/3] usb: gadget: udc: renesas_usb3: add suspend/resume and generic phy

2017-09-29 Thread Yoshihiro Shimoda
This patch set is based on the latest Felipe's usb.git / testing/next branch
(commit id = af846d7ab55c846af6d6f150e9af96295101e068)

Kazuya Mizuguchi (1):
  usb: gadget: udc: renesas_usb3: move pm_runtime_{en,dis}able()

Yoshihiro Shimoda (2):
  usb: gadget: udc: renesas_usb3: Add suspend/resume functions
  usb: gadget: udc: renesas_usb3: add support for generic phy

 .../devicetree/bindings/usb/renesas_usb3.txt   |  4 ++
 drivers/usb/gadget/udc/renesas_usb3.c  | 64 --
 2 files changed, 64 insertions(+), 4 deletions(-)

-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] usb: gadget: udc: renesas_usb3: Add suspend/resume functions

2017-09-29 Thread Yoshihiro Shimoda
This patch adds support suspend/resume functions

Signed-off-by: Kazuya Mizuguchi 
[shimoda: add the commit log]
Signed-off-by: Yoshihiro Shimoda 
---
 drivers/usb/gadget/udc/renesas_usb3.c | 34 ++
 1 file changed, 34 insertions(+)

diff --git a/drivers/usb/gadget/udc/renesas_usb3.c 
b/drivers/usb/gadget/udc/renesas_usb3.c
index 7d99774..d55a06b 100644
--- a/drivers/usb/gadget/udc/renesas_usb3.c
+++ b/drivers/usb/gadget/udc/renesas_usb3.c
@@ -2644,11 +2644,45 @@ static int renesas_usb3_probe(struct platform_device 
*pdev)
return ret;
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int renesas_usb3_suspend(struct device *dev)
+{
+   struct renesas_usb3 *usb3 = dev_get_drvdata(dev);
+
+   /* Not started */
+   if (!usb3->driver)
+   return 0;
+
+   renesas_usb3_stop_controller(usb3);
+   pm_runtime_put(dev);
+
+   return 0;
+}
+
+static int renesas_usb3_resume(struct device *dev)
+{
+   struct renesas_usb3 *usb3 = dev_get_drvdata(dev);
+
+   /* Not started */
+   if (!usb3->driver)
+   return 0;
+
+   pm_runtime_get_sync(dev);
+   renesas_usb3_init_controller(usb3);
+
+   return 0;
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(renesas_usb3_pm_ops, renesas_usb3_suspend,
+   renesas_usb3_resume);
+
 static struct platform_driver renesas_usb3_driver = {
.probe  = renesas_usb3_probe,
.remove = renesas_usb3_remove,
.driver = {
.name = (char *)udc_name,
+   .pm = &renesas_usb3_pm_ops,
.of_match_table = of_match_ptr(usb3_of_match),
},
 };
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: usb/misc/usbtest: null-ptr-deref in usbtest_probe/get_endpoints

2017-09-29 Thread Andrey Konovalov
On Thu, Sep 28, 2017 at 7:01 PM, Alan Stern  wrote:
> On Thu, 28 Sep 2017, Andrey Konovalov wrote:
>
>> Hi!
>>
>> I've got the following report while fuzzing the kernel with syzkaller.
>>
>> On commit dc972a67cc54585bd83ad811c4e9b6ab3dcd427e (4.14-rc2+).
>>
>> It seems that out pointer ends up being NULL and kernel crashes on
>> access to out->desc.bEndpointAddress.
>>
>> gadgetfs: bound to dummy_udc driver
>> usb 1-1: new full-speed USB device number 2 using dummy_hcd
>> gadgetfs: connected
>> gadgetfs: disconnected
>> gadgetfs: connected
>> usb 1-1: config 2 interface 0 altsetting 206 endpoint 0x81 has invalid
>> maxpacket 2040, setting to 64
>> usb 1-1: config 2 interface 0 altsetting 206 has an invalid endpoint
>> with address 0xFF, skipping
>> usb 1-1: config 2 interface 0 altsetting 206 endpoint 0x5 has an
>> invalid bInterval 255, changing to 4
>> usb 1-1: config 2 interface 0 has no altsetting 0
>> usb 1-1: New USB device found, idVendor=0525, idProduct=a4a0
>> usb 1-1: New USB device strings: Mfr=0, Product=185, SerialNumber=1
>> usb 1-1: Product: a
>> usb 1-1: SerialNumber: a
>> gadgetfs: configuration #2
>> kasan: CONFIG_KASAN_INLINE enabled
>> kasan: GPF could be caused by NULL-ptr deref or user memory access
>> general protection fault:  [#1] PREEMPT SMP KASAN
>> Modules linked in:
>> CPU: 1 PID: 1845 Comm: kworker/1:2 Not tainted
>> 4.14.0-rc2-42664-gaf7d1481b3cb #297
>> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
>> Workqueue: usb_hub_wq hub_event
>> task: 880064328000 task.stack: 880064398000
>> RIP: 0010:get_endpoints drivers/usb/misc/usbtest.c:208
>> RIP: 0010:usbtest_probe+0x114f/0x1ef0 drivers/usb/misc/usbtest.c:2706
>
> This looks like a simple logic error.
>
> Alan Stern

Hi Alan,

This fixes it.

Tested-by: Andrey Konovalov 

Thanks!

>
>
>
> Index: usb-4.x/drivers/usb/misc/usbtest.c
> ===
> --- usb-4.x.orig/drivers/usb/misc/usbtest.c
> +++ usb-4.x/drivers/usb/misc/usbtest.c
> @@ -202,12 +202,13 @@ found:
> return tmp;
> }
>
> -   if (in) {
> +   if (in)
> dev->in_pipe = usb_rcvbulkpipe(udev,
> in->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
> +   if (out)
> dev->out_pipe = usb_sndbulkpipe(udev,
> out->desc.bEndpointAddress & 
> USB_ENDPOINT_NUMBER_MASK);
> -   }
> +
> if (iso_in) {
> dev->iso_in = &iso_in->desc;
> dev->in_iso_pipe = usb_rcvisocpipe(udev,
>
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: usb/serial/visor: slab-out-of-bounds in palm_os_3_probe

2017-09-29 Thread Andrey Konovalov
On Fri, Sep 29, 2017 at 10:37 AM, Greg Kroah-Hartman
 wrote:
> On Thu, Sep 28, 2017 at 07:57:46PM +0200, Andrey Konovalov wrote:
>> Hi!
>>
>> I've got the following report while fuzzing the kernel with syzkaller.
>>
>> On commit dc972a67cc54585bd83ad811c4e9b6ab3dcd427e (4.14-rc2+).
>>
>> There's no check on the connection_info->num_ports value when
>> iterating over ports.
>>
>> usb 1-1: Handspring Visor / Palm OS: port 162, is for unknown use
>> usb 1-1: Handspring Visor / Palm OS: port 81, is for unknown use
>> ==
>> BUG: KASAN: slab-out-of-bounds in palm_os_3_probe+0x4e4/0x570
>> Read of size 1 at addr 8800686daa26 by task kworker/0:1/24
>>
>> CPU: 0 PID: 24 Comm: kworker/0:1 Not tainted 4.14.0-rc2-42748-gcd3da2fe6c25 
>> #324
>> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
>> Workqueue: usb_hub_wq hub_event
>> Call Trace:
>>  __dump_stack lib/dump_stack.c:16
>>  dump_stack+0x292/0x395 lib/dump_stack.c:52
>>  print_address_description+0x78/0x280 mm/kasan/report.c:252
>>  kasan_report_error mm/kasan/report.c:351
>>  kasan_report+0x23d/0x350 mm/kasan/report.c:409
>>  __asan_report_load1_noabort+0x19/0x20 mm/kasan/report.c:427
>>  palm_os_3_probe+0x4e4/0x570 drivers/usb/serial/visor.c:348
>>  visor_probe+0x11c/0x1e0 drivers/usb/serial/visor.c:463
>>  usb_serial_probe+0x540/0x4090 drivers/usb/serial/usb-serial.c:903
>>  usb_probe_interface+0x35d/0x8e0 drivers/usb/core/driver.c:361
>>  really_probe drivers/base/dd.c:413
>>  driver_probe_device+0x610/0xa00 drivers/base/dd.c:557
>>  __device_attach_driver+0x230/0x290 drivers/base/dd.c:653
>>  bus_for_each_drv+0x161/0x210 drivers/base/bus.c:463
>>  __device_attach+0x26e/0x3d0 drivers/base/dd.c:710
>>  device_initial_probe+0x1f/0x30 drivers/base/dd.c:757
>>  bus_probe_device+0x1eb/0x290 drivers/base/bus.c:523
>>  device_add+0xd0b/0x1660 drivers/base/core.c:1835
>>  usb_set_configuration+0x104e/0x1870 drivers/usb/core/message.c:1932
>>  generic_probe+0x73/0xe0 drivers/usb/core/generic.c:174
>>  usb_probe_device+0xaf/0xe0 drivers/usb/core/driver.c:266
>>  really_probe drivers/base/dd.c:413
>>  driver_probe_device+0x610/0xa00 drivers/base/dd.c:557
>>  __device_attach_driver+0x230/0x290 drivers/base/dd.c:653
>>  bus_for_each_drv+0x161/0x210 drivers/base/bus.c:463
>>  __device_attach+0x26e/0x3d0 drivers/base/dd.c:710
>>  device_initial_probe+0x1f/0x30 drivers/base/dd.c:757
>>  bus_probe_device+0x1eb/0x290 drivers/base/bus.c:523
>>  device_add+0xd0b/0x1660 drivers/base/core.c:1835
>>  usb_new_device+0x7b8/0x1020 drivers/usb/core/hub.c:2538
>>  hub_port_connect drivers/usb/core/hub.c:4984
>>  hub_port_connect_change drivers/usb/core/hub.c:5090
>>  port_event drivers/usb/core/hub.c:5196
>>  hub_event_impl+0x1971/0x3760 drivers/usb/core/hub.c:5310
>>  hub_event+0x11b/0x3f0 drivers/usb/core/hub.c:5206
>>  process_one_work+0xc7f/0x1db0 kernel/workqueue.c:2119
>>  worker_thread+0x221/0x1850 kernel/workqueue.c:2253
>>  kthread+0x3a1/0x470 kernel/kthread.c:231
>>  ret_from_fork+0x2a/0x40 arch/x86/entry/entry_64.S:431
>>
>> Allocated by task 24:
>>  save_stack_trace+0x1b/0x20 arch/x86/kernel/stacktrace.c:59
>>  save_stack+0x43/0xd0 mm/kasan/kasan.c:447
>>  set_track mm/kasan/kasan.c:459
>>  kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:551
>>  kmem_cache_alloc_trace+0x11e/0x2d0 mm/slub.c:2772
>>  kmalloc ./include/linux/slab.h:493
>>  palm_os_3_probe+0x7c/0x570 drivers/usb/serial/visor.c:325
>>  visor_probe+0x11c/0x1e0 drivers/usb/serial/visor.c:463
>>  usb_serial_probe+0x540/0x4090 drivers/usb/serial/usb-serial.c:903
>>  usb_probe_interface+0x35d/0x8e0 drivers/usb/core/driver.c:361
>>  really_probe drivers/base/dd.c:413
>>  driver_probe_device+0x610/0xa00 drivers/base/dd.c:557
>>  __device_attach_driver+0x230/0x290 drivers/base/dd.c:653
>>  bus_for_each_drv+0x161/0x210 drivers/base/bus.c:463
>>  __device_attach+0x26e/0x3d0 drivers/base/dd.c:710
>>  device_initial_probe+0x1f/0x30 drivers/base/dd.c:757
>>  bus_probe_device+0x1eb/0x290 drivers/base/bus.c:523
>>  device_add+0xd0b/0x1660 drivers/base/core.c:1835
>>  usb_set_configuration+0x104e/0x1870 drivers/usb/core/message.c:1932
>>  generic_probe+0x73/0xe0 drivers/usb/core/generic.c:174
>>  usb_probe_device+0xaf/0xe0 drivers/usb/core/driver.c:266
>>  really_probe drivers/base/dd.c:413
>>  driver_probe_device+0x610/0xa00 drivers/base/dd.c:557
>>  __device_attach_driver+0x230/0x290 drivers/base/dd.c:653
>>  bus_for_each_drv+0x161/0x210 drivers/base/bus.c:463
>>  __device_attach+0x26e/0x3d0 drivers/base/dd.c:710
>>  device_initial_probe+0x1f/0x30 drivers/base/dd.c:757
>>  bus_probe_device+0x1eb/0x290 drivers/base/bus.c:523
>>  device_add+0xd0b/0x1660 drivers/base/core.c:1835
>>  usb_new_device+0x7b8/0x1020 drivers/usb/core/hub.c:2538
>>  hub_port_connect drivers/usb/core/hub.c:4984
>>  hub_port_connect_change drivers/usb/core/hub.c:5090
>>  port_event drivers/usb/core/hub.c:5196
>>  hub_event_impl+0x1971/0x3760 drivers/usb/core/hub.c:53

[PATCH v2] xhci: Cleanup current_cmd in xhci_cleanup_command_queue()

2017-09-29 Thread Jeffy Chen
KASAN reported use-after-free bug when xhci host controller died:
[  176.952537] BUG: KASAN: use-after-free in 
xhci_handle_command_timeout+0x68/0x224
[  176.960846] Write of size 4 at addr ffc0cbb01608 by task kworker/3:3/1680
...
[  177.180644] Freed by task 0:
[  177.183882]  kasan_slab_free+0x90/0x15c
[  177.188194]  kfree+0x114/0x28c
[  177.191630]  xhci_cleanup_command_queue+0xc8/0xf8
[  177.196916]  xhci_hc_died+0x84/0x358

Problem here is that when the cmd_timer fired, it would try to access
current_cmd while the command queue is already freed by xhci_hc_died().

Cleanup current_cmd in xhci_cleanup_command_queue() to avoid that.

Fixes: d9f11ba9f107 ("xhci: Rework how we handle unresponsive or hoptlug 
removed hosts")
Signed-off-by: Jeffy Chen 
---

Changes in v2:
We cannot cancel cmd_timer in xhci_hc_died(), which would cause
might_sleep warning.

 drivers/usb/host/xhci-ring.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index a9443651ce0f..48ae15afa59e 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -1309,6 +1309,7 @@ static void xhci_complete_del_and_free_cmd(struct 
xhci_command *cmd, u32 status)
 void xhci_cleanup_command_queue(struct xhci_hcd *xhci)
 {
struct xhci_command *cur_cmd, *tmp_cmd;
+   xhci->current_cmd = NULL;
list_for_each_entry_safe(cur_cmd, tmp_cmd, &xhci->cmd_list, cmd_list)
xhci_complete_del_and_free_cmd(cur_cmd, COMP_COMMAND_ABORTED);
 }
-- 
2.11.0


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: Type-C port on the Asmedia ASM1142

2017-09-29 Thread David Laight
From: Adrian Bocaniciu
> Sent: 28 September 2017 20:25
..
> The correct names used in the new specification for the 4 speeds that can be 
> supported by a USB 3
> interface are: "Gen 1x1", "Gen 2x1", "Gen 1x2" and "Gen 2x2".

I think I'd add the speed itself as well.

David

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] xhci: Cancel cmd_timer before cleanup the command queue in xhci_hc_died()

2017-09-29 Thread Jeffy Chen
When the cmd_timer fired, it would try to access the command struct.
So cancel it before cleanup the command queue in xhci_hc_died(), to
avoid use-after-free reported by KASAN:
[  176.952537] BUG: KASAN: use-after-free in 
xhci_handle_command_timeout+0x68/0x224
[  176.960846] Write of size 4 at addr ffc0cbb01608 by task kworker/3:3/1680
...
[  177.180644] Freed by task 0:
[  177.183882]  kasan_slab_free+0x90/0x15c
[  177.188194]  kfree+0x114/0x28c
[  177.191630]  xhci_cleanup_command_queue+0xc8/0xf8
[  177.196916]  xhci_hc_died+0x84/0x358

Fixes: d9f11ba9f107 ("xhci: Rework how we handle unresponsive or hoptlug 
removed hosts")
Signed-off-by: Jeffy Chen 
---

 drivers/usb/host/xhci-ring.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index a9443651ce0f..69ac3deffb7b 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -914,6 +914,7 @@ void xhci_hc_died(struct xhci_hcd *xhci)
xhci_err(xhci, "xHCI host controller not responding, assume dead\n");
xhci->xhc_state |= XHCI_STATE_DYING;
 
+   cancel_delayed_work_sync(&xhci->cmd_timer);
xhci_cleanup_command_queue(xhci);
 
/* return any pending urbs, remove may be waiting for them */
-- 
2.11.0


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: usb/serial/visor: slab-out-of-bounds in palm_os_3_probe

2017-09-29 Thread Greg Kroah-Hartman
On Thu, Sep 28, 2017 at 07:57:46PM +0200, Andrey Konovalov wrote:
> Hi!
> 
> I've got the following report while fuzzing the kernel with syzkaller.
> 
> On commit dc972a67cc54585bd83ad811c4e9b6ab3dcd427e (4.14-rc2+).
> 
> There's no check on the connection_info->num_ports value when
> iterating over ports.
> 
> usb 1-1: Handspring Visor / Palm OS: port 162, is for unknown use
> usb 1-1: Handspring Visor / Palm OS: port 81, is for unknown use
> ==
> BUG: KASAN: slab-out-of-bounds in palm_os_3_probe+0x4e4/0x570
> Read of size 1 at addr 8800686daa26 by task kworker/0:1/24
> 
> CPU: 0 PID: 24 Comm: kworker/0:1 Not tainted 4.14.0-rc2-42748-gcd3da2fe6c25 
> #324
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
> Workqueue: usb_hub_wq hub_event
> Call Trace:
>  __dump_stack lib/dump_stack.c:16
>  dump_stack+0x292/0x395 lib/dump_stack.c:52
>  print_address_description+0x78/0x280 mm/kasan/report.c:252
>  kasan_report_error mm/kasan/report.c:351
>  kasan_report+0x23d/0x350 mm/kasan/report.c:409
>  __asan_report_load1_noabort+0x19/0x20 mm/kasan/report.c:427
>  palm_os_3_probe+0x4e4/0x570 drivers/usb/serial/visor.c:348
>  visor_probe+0x11c/0x1e0 drivers/usb/serial/visor.c:463
>  usb_serial_probe+0x540/0x4090 drivers/usb/serial/usb-serial.c:903
>  usb_probe_interface+0x35d/0x8e0 drivers/usb/core/driver.c:361
>  really_probe drivers/base/dd.c:413
>  driver_probe_device+0x610/0xa00 drivers/base/dd.c:557
>  __device_attach_driver+0x230/0x290 drivers/base/dd.c:653
>  bus_for_each_drv+0x161/0x210 drivers/base/bus.c:463
>  __device_attach+0x26e/0x3d0 drivers/base/dd.c:710
>  device_initial_probe+0x1f/0x30 drivers/base/dd.c:757
>  bus_probe_device+0x1eb/0x290 drivers/base/bus.c:523
>  device_add+0xd0b/0x1660 drivers/base/core.c:1835
>  usb_set_configuration+0x104e/0x1870 drivers/usb/core/message.c:1932
>  generic_probe+0x73/0xe0 drivers/usb/core/generic.c:174
>  usb_probe_device+0xaf/0xe0 drivers/usb/core/driver.c:266
>  really_probe drivers/base/dd.c:413
>  driver_probe_device+0x610/0xa00 drivers/base/dd.c:557
>  __device_attach_driver+0x230/0x290 drivers/base/dd.c:653
>  bus_for_each_drv+0x161/0x210 drivers/base/bus.c:463
>  __device_attach+0x26e/0x3d0 drivers/base/dd.c:710
>  device_initial_probe+0x1f/0x30 drivers/base/dd.c:757
>  bus_probe_device+0x1eb/0x290 drivers/base/bus.c:523
>  device_add+0xd0b/0x1660 drivers/base/core.c:1835
>  usb_new_device+0x7b8/0x1020 drivers/usb/core/hub.c:2538
>  hub_port_connect drivers/usb/core/hub.c:4984
>  hub_port_connect_change drivers/usb/core/hub.c:5090
>  port_event drivers/usb/core/hub.c:5196
>  hub_event_impl+0x1971/0x3760 drivers/usb/core/hub.c:5310
>  hub_event+0x11b/0x3f0 drivers/usb/core/hub.c:5206
>  process_one_work+0xc7f/0x1db0 kernel/workqueue.c:2119
>  worker_thread+0x221/0x1850 kernel/workqueue.c:2253
>  kthread+0x3a1/0x470 kernel/kthread.c:231
>  ret_from_fork+0x2a/0x40 arch/x86/entry/entry_64.S:431
> 
> Allocated by task 24:
>  save_stack_trace+0x1b/0x20 arch/x86/kernel/stacktrace.c:59
>  save_stack+0x43/0xd0 mm/kasan/kasan.c:447
>  set_track mm/kasan/kasan.c:459
>  kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:551
>  kmem_cache_alloc_trace+0x11e/0x2d0 mm/slub.c:2772
>  kmalloc ./include/linux/slab.h:493
>  palm_os_3_probe+0x7c/0x570 drivers/usb/serial/visor.c:325
>  visor_probe+0x11c/0x1e0 drivers/usb/serial/visor.c:463
>  usb_serial_probe+0x540/0x4090 drivers/usb/serial/usb-serial.c:903
>  usb_probe_interface+0x35d/0x8e0 drivers/usb/core/driver.c:361
>  really_probe drivers/base/dd.c:413
>  driver_probe_device+0x610/0xa00 drivers/base/dd.c:557
>  __device_attach_driver+0x230/0x290 drivers/base/dd.c:653
>  bus_for_each_drv+0x161/0x210 drivers/base/bus.c:463
>  __device_attach+0x26e/0x3d0 drivers/base/dd.c:710
>  device_initial_probe+0x1f/0x30 drivers/base/dd.c:757
>  bus_probe_device+0x1eb/0x290 drivers/base/bus.c:523
>  device_add+0xd0b/0x1660 drivers/base/core.c:1835
>  usb_set_configuration+0x104e/0x1870 drivers/usb/core/message.c:1932
>  generic_probe+0x73/0xe0 drivers/usb/core/generic.c:174
>  usb_probe_device+0xaf/0xe0 drivers/usb/core/driver.c:266
>  really_probe drivers/base/dd.c:413
>  driver_probe_device+0x610/0xa00 drivers/base/dd.c:557
>  __device_attach_driver+0x230/0x290 drivers/base/dd.c:653
>  bus_for_each_drv+0x161/0x210 drivers/base/bus.c:463
>  __device_attach+0x26e/0x3d0 drivers/base/dd.c:710
>  device_initial_probe+0x1f/0x30 drivers/base/dd.c:757
>  bus_probe_device+0x1eb/0x290 drivers/base/bus.c:523
>  device_add+0xd0b/0x1660 drivers/base/core.c:1835
>  usb_new_device+0x7b8/0x1020 drivers/usb/core/hub.c:2538
>  hub_port_connect drivers/usb/core/hub.c:4984
>  hub_port_connect_change drivers/usb/core/hub.c:5090
>  port_event drivers/usb/core/hub.c:5196
>  hub_event_impl+0x1971/0x3760 drivers/usb/core/hub.c:5310
>  hub_event+0x11b/0x3f0 drivers/usb/core/hub.c:5206
>  process_one_work+0xc7f/0x1db0 kernel/workqueue.c:2119
>  worker_thread+0x221/0x1850 kernel/wo

Re: [GIT PULL] USB: fixes for v4.14-rc3

2017-09-29 Thread Greg Kroah-Hartman
On Fri, Sep 29, 2017 at 10:38:18AM +0300, Felipe Balbi wrote:
> 
> Hi Greg,
> 
> Here's the second set of fixes for this -rc cycle.
> 
> Surprisingly, no fixes on dwc3, just a new device ID. I guess we can
> call dwc3 done :-p
> 
> Anyway, let me know if you want anything to be changed.

Looks good, pulled and pushed out, thanks.

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: dwc3: workaround: disable device-initiated U1/U2

2017-09-29 Thread Felipe Balbi

Hi,

Felipe Balbi  writes:
> (first things first: use get-maintainer.pl. You should have Cc:ed linux-usb)

apologies. Just now I noticed that you did Cc linux-usb.

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH] usb: dwc3: workaround: disable device-initiated U1/U2

2017-09-29 Thread Felipe Balbi

Hi,

(first things first: use get-maintainer.pl. You should have Cc:ed linux-usb)

> Issue: When the USB controller is configured as a USB device
> mode, the device initiates low power when an ACK is pending for a
> data packet (DP). When operating in SuperSpeed mode and when the
> internal condition for low power (u1/u2) is satisfied, the device
> initiates u1/u2 even though it has just received a DPH of the DP
> header (DPH). This causes the link to enter and exit low power before
> the device sends an ACK for the DP. This behavior can cause a
> transaction timeout on the host for the DP. Impact: Depending on the
> host transaction timeout value, the host may timeout on the
> transaction and the host retries the transfer. If the same issue
> happens again, this could result in the host resetting the device and
> re-enumerating.
>
> Workaround: Disable USB_DCTL (InitU1Ena, InitU2Ena) bits. As a
> result,the device does not initiate lowpower requests; however,
> it can still accept low-power requests from the host/hub and enter
> low power.

which dwc3 versions does this erratum affect? I'm not taking any
workaround that doesn't refer to a Synopsys STARS ticket, sorry.

Also, are you sure this can't be runtime detected?

> Signed-off-by: Ran Wang 
> ---
>  Documentation/devicetree/bindings/usb/dwc3.txt | 2 ++
>  drivers/usb/dwc3/core.c| 2 ++
>  drivers/usb/dwc3/core.h| 2 ++
>  drivers/usb/dwc3/ep0.c | 4 ++--
>  drivers/usb/dwc3/gadget.c  | 7 +++
>  5 files changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt 
> b/Documentation/devicetree/bindings/usb/dwc3.txt
> index 7d4f90c16cd4..9afa8e95831e 100644
> --- a/Documentation/devicetree/bindings/usb/dwc3.txt
> +++ b/Documentation/devicetree/bindings/usb/dwc3.txt
> @@ -47,6 +47,8 @@ Optional properties:
>   from P0 to P1/P2/P3 without delay.
>   - snps,dis-tx-ipgap-linecheck-quirk: when set, disable u2mac linestate check
>   during HS transmit.
> + - snps,disable_devinit_u1u2: when set, disable device-initiated U1/U2
> + LPM request in USB device mode.
>   - snps,is-utmi-l1-suspend: true when DWC3 asserts output signal
>   utmi_l1_suspend_n, false when asserts utmi_sleep_n
>   - snps,hird-threshold: HIRD threshold
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index f13096b0900e..63d599872a43 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -1143,6 +1143,8 @@ static void dwc3_get_properties(struct dwc3 *dwc)
> 
>   dwc->tx_de_emphasis_quirk = device_property_read_bool(dev,
>   "snps,tx_de_emphasis_quirk");
> + dwc->disable_devinit_u1u2_quirk = device_property_read_bool(dev,
> + "snps,disable_devinit_u1u2");
>   device_property_read_u8(dev, "snps,tx_de_emphasis",
>   &tx_de_emphasis);
>   device_property_read_string(dev, "snps,hsphy_interface",
> diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
> index 7c2f84dc218a..2be63c1a6ab6 100644
> --- a/drivers/usb/dwc3/core.h
> +++ b/drivers/usb/dwc3/core.h
> @@ -896,6 +896,7 @@ struct dwc3_scratchpad_array {
>   *   1   - -3.5dB de-emphasis
>   *   2   - No de-emphasis
>   *   3   - Reserved
> + * @disable_devinit_u1u2_quirk: disable device-initiated U1/U2 request.
>   * @imod_interval: set the interrupt moderation interval in 250ns
>   * increments or 0 to disable.
>   */
> @@ -1057,6 +1058,7 @@ struct dwc3 {
> 
>   unsignedtx_de_emphasis_quirk:1;
>   unsignedtx_de_emphasis:2;
> + unsigneddisable_devinit_u1u2_quirk:1;
> 
>   u16 imod_interval;
>  };
> diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
> index 827e376bfa97..bbbf46f031e2 100644
> --- a/drivers/usb/dwc3/ep0.c
> +++ b/drivers/usb/dwc3/ep0.c
> @@ -391,7 +391,7 @@ static int dwc3_ep0_handle_u1(struct dwc3 *dwc, enum 
> usb_device_state state,
>   return -EINVAL;
> 
>   reg = dwc3_readl(dwc->regs, DWC3_DCTL);
> - if (set)
> + if (set && !dwc->disable_devinit_u1u2_quirk)
>   reg |= DWC3_DCTL_INITU1ENA;
>   else
>   reg &= ~DWC3_DCTL_INITU1ENA;
> @@ -413,7 +413,7 @@ static int dwc3_ep0_handle_u2(struct dwc3 *dwc, enum 
> usb_device_state state,
>   return -EINVAL;
> 
>   reg = dwc3_readl(dwc->regs, DWC3_DCTL);
> - if (set)
> + if (set && !dwc->disable_devinit_u1u2_quirk)

This is likely going to block USB30CV from passing, no? Have you
verified that USB30CV Chapter9 LPM tests still pass? What about Lecroy's
Certification Suite, does that still pass?

Which dwc3 version do *you* use?

> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index f064f1549333..61141c6350

[GIT PULL] USB: fixes for v4.14-rc3

2017-09-29 Thread Felipe Balbi

Hi Greg,

Here's the second set of fixes for this -rc cycle.

Surprisingly, no fixes on dwc3, just a new device ID. I guess we can
call dwc3 done :-p

Anyway, let me know if you want anything to be changed.

cheers

The following changes since commit 8fec9355a968ad240f3a2e9ad55b823cf1cc52ff:

  USB: cdc-wdm: ignore -EPIPE from GetEncapsulatedResponse (2017-09-25 10:57:13 
+0200)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git 
tags/fixes-for-v4.14-rc3

for you to fetch changes up to c3cdce45f8d3dfa5c3467894aa89798314920328:

  usb: dwc3: of-simple: Add compatible for Spreadtrum SC9860 platform 
(2017-09-28 12:41:56 +0300)


usb: fixes for v4.14-rc3

Alan Stern fixed 3 old bugs on dummy_hcd which were reported recently.

Yoshihiro Shimoda continues his work on the renensas_usb3 driver by
fixing several bugs all over the place. The most important of which is
a fix for 2-stage control transfers, previously renesas_usb3 would,
anyway, try to move a 0-length data stage, which is wrong.

Apart from these, there are two minor bug fixes (atmel udc and ffs)
and a new device ID for dwc3-of-simple.c


Alan Stern (3):
  USB: dummy-hcd: fix connection failures (wrong speed)
  USB: dummy-hcd: fix infinite-loop resubmission bug
  USB: dummy-hcd: Fix erroneous synchronization change

Baolin Wang (1):
  usb: dwc3: of-simple: Add compatible for Spreadtrum SC9860 platform

John Keeping (1):
  usb: gadget: ffs: handle I/O completion in-order

Nicolas Ferre (1):
  usb: gadget: udc: atmel: set vbus irqflags explicitly

Yoshihiro Shimoda (5):
  usb: gadget: udc: renesas_usb3: fix for no-data control transfer
  usb: gadget: udc: renesas_usb3: fix Pn_RAMMAP.Pn_MPKT value
  usb: gadget: udc: renesas_usb3: Fix return value of usb3_write_pipe()
  usb: renesas_usbhs: fix the BCLR setting condition for non-DCP pipe
  usb: renesas_usbhs: fix usbhsf_fifo_clear() for RX direction

 drivers/usb/dwc3/dwc3-of-simple.c   |  1 +
 drivers/usb/gadget/function/f_fs.c  | 17 +++---
 drivers/usb/gadget/function/u_fs.h  |  1 +
 drivers/usb/gadget/udc/atmel_usba_udc.c |  4 ++-
 drivers/usb/gadget/udc/dummy_hcd.c  | 56 +
 drivers/usb/gadget/udc/renesas_usb3.c   | 19 ---
 drivers/usb/renesas_usbhs/fifo.c| 21 +++--
 7 files changed, 101 insertions(+), 18 deletions(-)

-- 
balbi


signature.asc
Description: PGP signature