[PATCH] b: re-queue tx dma request on herror

2016-11-15 Thread Max Uvarov
Some times dma transfer to usb endpoint fails:

[ 78.378283] musb-hdrc musb-hdrc.1.auto: Start TX10 dma
[ 78.410763] musb-hdrc musb-hdrc.1.auto: OUT/TX10 end, csr 3400, dma
[ 78.410896] musb-hdrc musb-hdrc.1.auto: complete dc01eb00 
usb_api_blocking_completion+0x0/0x24 [usbcore] (0), dev4 ep1out, 10/10
[ 78.411181] musb-hdrc musb-hdrc.1.auto: qh dc01ed00 periodic slot 10
[ 78.411205] musb-hdrc musb-hdrc.1.auto: qh dc01ed00 urb dc01eb00 dev4 
ep1out-intr, hw_ep 10, dd624d00/10
[ 78.411223] musb-hdrc musb-hdrc.1.auto: --> hw10 urb dc01eb00 spd2 dev4 ep1out 
h_addr83 h_port02 bytes 10
[ 78.411244] musb-hdrc musb-hdrc.1.auto: check whether there's still time for 
periodic Tx
[ 78.411256] musb-hdrc musb-hdrc.1.auto: Start TX10 dma
[ 78.443762] musb-hdrc musb-hdrc.1.auto: OUT/TX10 end, csr 3500, dma

success transmition:

[ 78.443889] musb-hdrc musb-hdrc.1.auto: complete dc01eb00 
usb_api_blocking_completion+0x0/0x24 [usbcore] (0), dev4 ep1out, 10/10
[ 78.444170] musb-hdrc musb-hdrc.1.auto: qh dc01ed00 periodic slot 10
[ 78.444195] musb-hdrc musb-hdrc.1.auto: qh dc01ed00 urb dc01eb00 dev4 
ep1out-intr, hw_ep 10, dd624d00/10
[ 78.444213] musb-hdrc musb-hdrc.1.auto: --> hw10 urb dc01eb00 spd2 dev4 ep1out 
h_addr83 h_port02 bytes 10
[ 78.444232] musb-hdrc musb-hdrc.1.auto: check whether there's still time for 
periodic Tx
[ 78.444245] musb-hdrc musb-hdrc.1.auto: Start TX10 dma
[ 78.540761] musb-hdrc musb-hdrc.1.auto: OUT/TX10 end, csr 3504, dma

failed transmission:

[ 78.540780] musb-hdrc musb-hdrc.1.auto: TX 3strikes on ep=10 set ETIMEDOUT
[ 78.540897] musb-hdrc musb-hdrc.1.auto: complete dc01eb00 
usb_api_blocking_completion+0x0/0x24 [usbcore] (-110), dev4 ep1out, 10/10
[ 78.540945] musb-hdrc musb-hdrc.1.auto: extra TX10 ready, csr 2500
[ 78.540989] usb 2-1.1.2: urb wait ok but retval -110

Use to reproduce is writes to /dev/hidraw0 device which end up with early
unexpected timeout and -110 errno set.

Code sets timeout to 5 seconds
vfs_write()->hidraw_write()->hidraw_send_report()->usbhid_output_report()
   ret = usb_interrupt_msg(dev, usbhid->urbout->pipe,
   buf, count, _length,
   USB_CTRL_SET_TIMEOUT);
where is set to 5 second:

when it wents to usb_start_wait_urb() where waits for completition:
   retval = usb_submit_urb(urb, GFP_NOIO);

   expire = timeout ? msecs_to_jiffies(timeout) : MAX_SCHEDULE_TIMEOUT;
   if (!wait_for_completion_timeout(, expire)) {

So user space application expects that write will be done in 5 seconds or
error will happen. But musb driver exists this logic on first dma error
without trying to retransmit current urb. This patch adds current request
to the end of list, destroys current dma transfer and renew transmission.
In that case this urb transmitted in next cycle and not failing with error
before timeout.

Signed-off-by: Max Uvarov 
---
 drivers/usb/musb/musb_host.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 53bc4ce..e44ae95 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -1293,11 +1293,11 @@ void musb_host_tx(struct musb *musb, u8 epnum)
status = -EPIPE;
 
} else if (tx_csr & MUSB_TXCSR_H_ERROR) {
-   /* (NON-ISO) dma was disabled, fifo flushed */
musb_dbg(musb, "TX 3strikes on ep=%d", epnum);
-
-   status = -ETIMEDOUT;
-
+   if (dma)
+   musb_bulk_nak_timeout(musb, hw_ep, 0);
+   else
+   status = -ETIMEDOUT;
} else if (tx_csr & MUSB_TXCSR_H_NAKTIMEOUT) {
if (USB_ENDPOINT_XFER_BULK == qh->type && qh->mux == 1
&& !list_is_singular(>out_bulk)) {
-- 
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: [PATCH v4 4/4] ARM: dts: da850: Add the usb otg device nodeg

2016-11-15 Thread Sekhar Nori
On Wednesday 16 November 2016 02:49 AM, Bin Liu wrote:
> On Tue, Nov 15, 2016 at 04:16:02PM +0530, Sekhar Nori wrote:
>> On Thursday 03 November 2016 09:29 PM, Alexandre Bailon wrote:
>>> This adds the device tree node for the usb otg
>>> controller present in the da850 family of SoC's.
>>> This also enables the otg usb controller for the lcdk board.
>>>
>>> Signed-off-by: Alexandre Bailon 
>>> ---
>>>  arch/arm/boot/dts/da850-lcdk.dts |  8 
>>>  arch/arm/boot/dts/da850.dtsi | 15 +++
>>>  2 files changed, 23 insertions(+)
>>>
>>> diff --git a/arch/arm/boot/dts/da850-lcdk.dts 
>>> b/arch/arm/boot/dts/da850-lcdk.dts
>>> index 7b8ab21..9f5040c 100644
>>> --- a/arch/arm/boot/dts/da850-lcdk.dts
>>> +++ b/arch/arm/boot/dts/da850-lcdk.dts
>>> @@ -158,6 +158,14 @@
>>> rx-num-evt = <32>;
>>>  };
>>>  
>>> +_phy {
>>> +   status = "okay";
>>> +   };
>>
>> As mentioned by David already, this node needs to be removed. Please
>> rebase this on top of latest linux-davinci/master when ready for merging
>> (driver changes accepted).
> 
> Dropped this patch due to this comment.

Bin, Please do not apply dts or arch/arm/mach-davinci patches. I have a
bunch queued through my tree and more in pipeline and it will cause
unnecessary merge conflicts in linux-next or at Linus.

For future, I have asked Alexandre to send driver and dts patches as
separate series so there is no confusion on who should apply.

Thanks,
Sekhar
--
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] dma: cpp41: Fix handling of error path

2016-11-15 Thread Sekhar Nori
On Wednesday 16 November 2016 02:28 AM, Tony Lindgren wrote:
> * Sekhar Nori  [161115 00:35]:
>> If pm_runtime_get_sync() fails due to callback error, then
>> rpm_callback() sets dev.power.runtime_error to an error value which gets
>> cleared by an explicit call to pm_runtime_set_suspended().
>>
>> This will tell the framework that the status of device is suspended.
>> Else, the failure will be sticky and on subsequent attempts,
>> rpm_resume() will keep returning early instead of trying to resume the
>> device again.
>>
>> This is as far as I can gather from code. So, I believe the recovery
>> path should be:
>>
>>  if (error < 0) {
>>  pm_runtime_set_suspended(cdd->ddev.dev);
>>  pm_runtime_put_noidle(cdd->ddev.dev);
>>
>>  ...
> 
> Well we should test this :)

Yes, right! Was this patch created to fix an error in practice or just
based on code review?

> BTW, what other users of cppi41 do we have in addition to musb? I think
> davinci is or will be using it too?

The list Bin provided seems accurate.

Thanks,
Sekhar
--
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 v4 2/6] usb: chipidea: use bus->sysdev for DMA configuration

2016-11-15 Thread Sriram Dash
From: Arnd Bergmann 

Set the dma for chipidea from sysdev. This is inherited from its
parent node. Also, do not set dma mask for child as it is not required
now.

Signed-off-by: Arnd Bergmann 
Signed-off-by: Sriram Dash 
Acked-by: Peter Chen 
---
Changes in v4:
  - No update

Changes in v3:
  - No update

Changes in v2:
  - integrate chipidea driver changes together.

 drivers/usb/chipidea/core.c |  3 ---
 drivers/usb/chipidea/host.c |  3 ++-
 drivers/usb/chipidea/udc.c  | 10 ++
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 69426e6..8917a03 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -833,9 +833,6 @@ struct platform_device *ci_hdrc_add_device(struct device 
*dev,
}
 
pdev->dev.parent = dev;
-   pdev->dev.dma_mask = dev->dma_mask;
-   pdev->dev.dma_parms = dev->dma_parms;
-   dma_set_coherent_mask(>dev, dev->coherent_dma_mask);
 
ret = platform_device_add_resources(pdev, res, nres);
if (ret)
diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index 111b0e0b..3218b49 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -116,7 +116,8 @@ static int host_start(struct ci_hdrc *ci)
if (usb_disabled())
return -ENODEV;
 
-   hcd = usb_create_hcd(_ehci_hc_driver, ci->dev, dev_name(ci->dev));
+   hcd = __usb_create_hcd(_ehci_hc_driver, ci->dev->parent,
+  ci->dev, dev_name(ci->dev), NULL);
if (!hcd)
return -ENOMEM;
 
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 661f43f..bc55922 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -423,7 +423,8 @@ static int _hardware_enqueue(struct ci_hw_ep *hwep, struct 
ci_hw_req *hwreq)
 
hwreq->req.status = -EALREADY;
 
-   ret = usb_gadget_map_request(>gadget, >req, hwep->dir);
+   ret = usb_gadget_map_request_by_dev(ci->dev->parent,
+   >req, hwep->dir);
if (ret)
return ret;
 
@@ -603,7 +604,8 @@ static int _hardware_dequeue(struct ci_hw_ep *hwep, struct 
ci_hw_req *hwreq)
list_del_init(>td);
}
 
-   usb_gadget_unmap_request(>ci->gadget, >req, hwep->dir);
+   usb_gadget_unmap_request_by_dev(hwep->ci->dev->parent,
+   >req, hwep->dir);
 
hwreq->req.actual += actual;
 
@@ -1904,13 +1906,13 @@ static int udc_start(struct ci_hdrc *ci)
INIT_LIST_HEAD(>gadget.ep_list);
 
/* alloc resources */
-   ci->qh_pool = dma_pool_create("ci_hw_qh", dev,
+   ci->qh_pool = dma_pool_create("ci_hw_qh", dev->parent,
   sizeof(struct ci_hw_qh),
   64, CI_HDRC_PAGE_SIZE);
if (ci->qh_pool == NULL)
return -ENOMEM;
 
-   ci->td_pool = dma_pool_create("ci_hw_td", dev,
+   ci->td_pool = dma_pool_create("ci_hw_td", dev->parent,
   sizeof(struct ci_hw_td),
   64, CI_HDRC_PAGE_SIZE);
if (ci->td_pool == NULL) {
-- 
2.1.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


[PATCH v4 4/6] usb: xhci: use bus->sysdev for DMA configuration

2016-11-15 Thread Sriram Dash
From: Arnd Bergmann 

For xhci-hcd platform device, all the DMA parameters are not
configured properly, notably dma ops for dwc3 devices. So, set
the dma for xhci from sysdev. sysdev is pointing to device that
is known to the system firmware or hardware.

Signed-off-by: Arnd Bergmann 
Signed-off-by: Sriram Dash 
Tested-by: Baolin Wang 
---
Changes in v4:
  - No update

Changes in v3:
  - No update

Changes in v2:
  - Separate out xhci driver changes apart

 drivers/usb/host/xhci-mem.c  | 12 ++--
 drivers/usb/host/xhci-plat.c | 33 ++---
 drivers/usb/host/xhci.c  | 15 +++
 3 files changed, 43 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 6afe323..79608df 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -586,7 +586,7 @@ static void xhci_free_stream_ctx(struct xhci_hcd *xhci,
unsigned int num_stream_ctxs,
struct xhci_stream_ctx *stream_ctx, dma_addr_t dma)
 {
-   struct device *dev = xhci_to_hcd(xhci)->self.controller;
+   struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
size_t size = sizeof(struct xhci_stream_ctx) * num_stream_ctxs;
 
if (size > MEDIUM_STREAM_ARRAY_SIZE)
@@ -614,7 +614,7 @@ static struct xhci_stream_ctx *xhci_alloc_stream_ctx(struct 
xhci_hcd *xhci,
unsigned int num_stream_ctxs, dma_addr_t *dma,
gfp_t mem_flags)
 {
-   struct device *dev = xhci_to_hcd(xhci)->self.controller;
+   struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
size_t size = sizeof(struct xhci_stream_ctx) * num_stream_ctxs;
 
if (size > MEDIUM_STREAM_ARRAY_SIZE)
@@ -1644,7 +1644,7 @@ void xhci_slot_copy(struct xhci_hcd *xhci,
 static int scratchpad_alloc(struct xhci_hcd *xhci, gfp_t flags)
 {
int i;
-   struct device *dev = xhci_to_hcd(xhci)->self.controller;
+   struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
int num_sp = HCS_MAX_SCRATCHPAD(xhci->hcs_params2);
 
xhci_dbg_trace(xhci, trace_xhci_dbg_init,
@@ -1716,7 +1716,7 @@ static void scratchpad_free(struct xhci_hcd *xhci)
 {
int num_sp;
int i;
-   struct device *dev = xhci_to_hcd(xhci)->self.controller;
+   struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
 
if (!xhci->scratchpad)
return;
@@ -1792,7 +1792,7 @@ void xhci_free_command(struct xhci_hcd *xhci,
 
 void xhci_mem_cleanup(struct xhci_hcd *xhci)
 {
-   struct device   *dev = xhci_to_hcd(xhci)->self.controller;
+   struct device   *dev = xhci_to_hcd(xhci)->self.sysdev;
int size;
int i, j, num_ports;
 
@@ -2334,7 +2334,7 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, 
gfp_t flags)
 int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
 {
dma_addr_t  dma;
-   struct device   *dev = xhci_to_hcd(xhci)->self.controller;
+   struct device   *dev = xhci_to_hcd(xhci)->self.sysdev;
unsigned intval, val2;
u64 val_64;
struct xhci_segment *seg;
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index ed56bf9..beb95c8 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -139,6 +140,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
 {
const struct of_device_id *match;
const struct hc_driver  *driver;
+   struct device   *sysdev;
struct xhci_hcd *xhci;
struct resource *res;
struct usb_hcd  *hcd;
@@ -155,22 +157,39 @@ static int xhci_plat_probe(struct platform_device *pdev)
if (irq < 0)
return -ENODEV;
 
+   /*
+* sysdev must point to a device that is known to the system firmware
+* or PCI hardware. We handle these three cases here:
+* 1. xhci_plat comes from firmware
+* 2. xhci_plat is child of a device from firmware (dwc3-plat)
+* 3. xhci_plat is grandchild of a pci device (dwc3-pci)
+*/
+   sysdev = >dev;
+   if (sysdev->parent && !sysdev->of_node && sysdev->parent->of_node)
+   sysdev = sysdev->parent;
+#ifdef CONFIG_PCI
+   else if (sysdev->parent && sysdev->parent->parent &&
+sysdev->parent->parent->bus == _bus_type)
+   sysdev = sysdev->parent->parent;
+#endif
+
/* Try to set 64-bit DMA first */
-   if (WARN_ON(!pdev->dev.dma_mask))
+   if (WARN_ON(!sysdev->dma_mask))
/* Platform did not initialize dma_mask */
-   ret = dma_coerce_mask_and_coherent(>dev,
+   ret = dma_coerce_mask_and_coherent(sysdev,
   DMA_BIT_MASK(64));
else
-   

[PATCH v4 3/6] usb: ehci: fsl: use bus->sysdev for DMA configuration

2016-11-15 Thread Sriram Dash
From: Arnd Bergmann 

For the dual role ehci fsl driver, sysdev will handle the dma
config.

Signed-off-by: Arnd Bergmann 
Signed-off-by: Sriram Dash 
---
Changes in v4:
  - No update
Changes in v3:
  - fix compile errors
Changes in v2:
  - fix compile warnings


 drivers/usb/host/ehci-fsl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index 9f5ffb6..4d4ab42 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -96,8 +96,8 @@ static int fsl_ehci_drv_probe(struct platform_device *pdev)
}
irq = res->start;
 
-   hcd = usb_create_hcd(_ehci_hc_driver, >dev,
-   dev_name(>dev));
+   hcd = __usb_create_hcd(_ehci_hc_driver, pdev->dev.parent,
+  >dev, dev_name(>dev), NULL);
if (!hcd) {
retval = -ENOMEM;
goto err1;
-- 
2.1.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: [GIT PULL] USB fixes for v4.9-rc4

2016-11-15 Thread Peter Chen
On Tue, Nov 15, 2016 at 10:54:09PM -0500, David Miller wrote:
> From: Peter Chen 
> Date: Wed, 16 Nov 2016 11:41:15 +0800
> 
> > I just notice that you submitted the "usb: gadget: u_ether: remove
> > interrupt throttling", and cc stable tree too, but we can't get
> > the agreement that it is suitable for all USB controllers, and David
> > added this comment later that the networking stack has no hard
> > requirement (eg, half of second) [1] which is not the same at your
> > commit log.
> 
> It does fix a bug in at least one of the drivers, so it is definitely
> a step forward.

But it let other drivers lost throttling interrupt features for USB Ethernet
gadget, it can supply option for user if throttling interrupt is
supported or not.

-- 

Best Regards,
Peter Chen
--
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 v4 5/6] usb: dwc3: use bus->sysdev for DMA configuration

2016-11-15 Thread Sriram Dash
From: Arnd Bergmann 

The dma ops for dwc3 devices are not set properly. So, use a
physical device sysdev, which will be inherited from parent,
to set the hardware / firmware parameters like dma.

Signed-off-by: Arnd Bergmann 
Signed-off-by: Sriram Dash 
Signed-off-by: Felipe Balbi 
Tested-by: Baolin Wang 
---
Changes in v4:
  - removed the ifdefs for pci
  - made the sysdev as a device property
  - phy create lookup take up the correct device.

Changes in v3:
  - No update

Changes in v2:
  - integrate dwc3 driver changes together

 drivers/usb/dwc3/core.c | 27 ++-
 drivers/usb/dwc3/core.h |  3 +++
 drivers/usb/dwc3/dwc3-pci.c | 11 +++
 drivers/usb/dwc3/ep0.c  |  8 
 drivers/usb/dwc3/gadget.c   | 37 +++--
 drivers/usb/dwc3/host.c | 16 ++--
 6 files changed, 57 insertions(+), 45 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index fea4469..cf37d3e 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -229,7 +229,7 @@ static void dwc3_frame_length_adjustment(struct dwc3 *dwc)
 static void dwc3_free_one_event_buffer(struct dwc3 *dwc,
struct dwc3_event_buffer *evt)
 {
-   dma_free_coherent(dwc->dev, evt->length, evt->buf, evt->dma);
+   dma_free_coherent(dwc->sysdev, evt->length, evt->buf, evt->dma);
 }
 
 /**
@@ -251,7 +251,7 @@ static struct dwc3_event_buffer 
*dwc3_alloc_one_event_buffer(struct dwc3 *dwc,
 
evt->dwc= dwc;
evt->length = length;
-   evt->buf= dma_alloc_coherent(dwc->dev, length,
+   evt->buf= dma_alloc_coherent(dwc->sysdev, length,
>dma, GFP_KERNEL);
if (!evt->buf)
return ERR_PTR(-ENOMEM);
@@ -370,11 +370,11 @@ static int dwc3_setup_scratch_buffers(struct dwc3 *dwc)
if (!WARN_ON(dwc->scratchbuf))
return 0;
 
-   scratch_addr = dma_map_single(dwc->dev, dwc->scratchbuf,
+   scratch_addr = dma_map_single(dwc->sysdev, dwc->scratchbuf,
dwc->nr_scratch * DWC3_SCRATCHBUF_SIZE,
DMA_BIDIRECTIONAL);
-   if (dma_mapping_error(dwc->dev, scratch_addr)) {
-   dev_err(dwc->dev, "failed to map scratch buffer\n");
+   if (dma_mapping_error(dwc->sysdev, scratch_addr)) {
+   dev_err(dwc->sysdev, "failed to map scratch buffer\n");
ret = -EFAULT;
goto err0;
}
@@ -398,7 +398,7 @@ static int dwc3_setup_scratch_buffers(struct dwc3 *dwc)
return 0;
 
 err1:
-   dma_unmap_single(dwc->dev, dwc->scratch_addr, dwc->nr_scratch *
+   dma_unmap_single(dwc->sysdev, dwc->scratch_addr, dwc->nr_scratch *
DWC3_SCRATCHBUF_SIZE, DMA_BIDIRECTIONAL);
 
 err0:
@@ -417,7 +417,7 @@ static void dwc3_free_scratch_buffers(struct dwc3 *dwc)
if (!WARN_ON(dwc->scratchbuf))
return;
 
-   dma_unmap_single(dwc->dev, dwc->scratch_addr, dwc->nr_scratch *
+   dma_unmap_single(dwc->sysdev, dwc->scratch_addr, dwc->nr_scratch *
DWC3_SCRATCHBUF_SIZE, DMA_BIDIRECTIONAL);
kfree(dwc->scratchbuf);
 }
@@ -986,6 +986,13 @@ static int dwc3_probe(struct platform_device *pdev)
dwc->dr_mode = usb_get_dr_mode(dev);
dwc->hsphy_mode = of_usb_get_phy_mode(dev->of_node);
 
+   dwc->sysdev_is_parent = device_property_read_bool(dev,
+   "linux,sysdev_is_parent");
+   if (dwc->sysdev_is_parent)
+   dwc->sysdev = dwc->dev->parent;
+   else
+   dwc->sysdev = dwc->dev;
+
dwc->has_lpm_erratum = device_property_read_bool(dev,
"snps,has-lpm-erratum");
device_property_read_u8(dev, "snps,lpm-nyet-threshold",
@@ -1050,12 +1057,6 @@ static int dwc3_probe(struct platform_device *pdev)
 
spin_lock_init(>lock);
 
-   if (!dev->dma_mask) {
-   dev->dma_mask = dev->parent->dma_mask;
-   dev->dma_parms = dev->parent->dma_parms;
-   dma_set_coherent_mask(dev, dev->parent->coherent_dma_mask);
-   }
-
pm_runtime_set_active(dev);
pm_runtime_use_autosuspend(dev);
pm_runtime_set_autosuspend_delay(dev, DWC3_DEFAULT_AUTOSUSPEND_DELAY);
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 6b60e42..6999e28 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -798,6 +798,7 @@ struct dwc3_scratchpad_array {
  * @ep0_bounced: true when we used bounce buffer
  * @ep0_expect_in: true when we expect a DATA IN transfer
  * @has_hibernation: true when dwc3 was configured with Hibernation
+ * @sysdev_is_parent: true when dwc3 device has a parent driver
  * @has_lpm_erratum: true when core was configured with LPM Erratum. Note that
  * there's 

[PATCH v4 6/6] usb: dwc3: Do not set dma coherent mask

2016-11-15 Thread Sriram Dash
From: Arnd Bergmann 

The dma mask is correctly set up by the DT probe function, no
need to override it any more.

Signed-off-by: Arnd Bergmann 
Signed-off-by: Sriram Dash 
---
Changes in v4:
  - No update

Changes in v3:
  - No update

Changes in v2:
  - club the cleanup for dma coherent mask for device

 drivers/usb/dwc3/dwc3-exynos.c | 10 --
 drivers/usb/dwc3/dwc3-st.c |  1 -
 2 files changed, 11 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c
index 2f1fb7e..e27899b 100644
--- a/drivers/usb/dwc3/dwc3-exynos.c
+++ b/drivers/usb/dwc3/dwc3-exynos.c
@@ -20,7 +20,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -117,15 +116,6 @@ static int dwc3_exynos_probe(struct platform_device *pdev)
if (!exynos)
return -ENOMEM;
 
-   /*
-* Right now device-tree probed devices don't get dma_mask set.
-* Since shared usb code relies on it, set it here for now.
-* Once we move to full device tree support this will vanish off.
-*/
-   ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(32));
-   if (ret)
-   return ret;
-
platform_set_drvdata(pdev, exynos);
 
exynos->dev = dev;
diff --git a/drivers/usb/dwc3/dwc3-st.c b/drivers/usb/dwc3/dwc3-st.c
index aaaf256..dfbf464 100644
--- a/drivers/usb/dwc3/dwc3-st.c
+++ b/drivers/usb/dwc3/dwc3-st.c
@@ -219,7 +219,6 @@ static int st_dwc3_probe(struct platform_device *pdev)
if (IS_ERR(regmap))
return PTR_ERR(regmap);
 
-   dma_set_coherent_mask(dev, dev->coherent_dma_mask);
dwc3_data->dev = dev;
dwc3_data->regmap = regmap;
 
-- 
2.1.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


[PATCH v4 0/6] inherit dma configuration from parent dev

2016-11-15 Thread Sriram Dash
For xhci-hcd platform device, all the DMA parameters are not
configured properly, notably dma ops for dwc3 devices.

The idea here is that you pass in the parent of_node along
with the child device pointer, so it would behave exactly
like the parent already does. The difference is that it also
handles all the other attributes besides the mask.

Arnd Bergmann (6):
  usb: separate out sysdev pointer from usb_bus
  usb: chipidea: use bus->sysdev for DMA configuration
  usb: ehci: fsl: use bus->sysdev for DMA configuration
  usb: xhci: use bus->sysdev for DMA configuration
  usb: dwc3: use bus->sysdev for DMA configuration
  usb: dwc3: Do not set dma coherent mask

 drivers/usb/chipidea/core.c|  3 ---
 drivers/usb/chipidea/host.c|  3 ++-
 drivers/usb/chipidea/udc.c | 10 +
 drivers/usb/core/buffer.c  | 12 +--
 drivers/usb/core/hcd.c | 48 +-
 drivers/usb/core/usb.c | 18 
 drivers/usb/dwc3/core.c| 27 
 drivers/usb/dwc3/core.h|  3 +++
 drivers/usb/dwc3/dwc3-exynos.c | 10 -
 drivers/usb/dwc3/dwc3-pci.c| 11 ++
 drivers/usb/dwc3/dwc3-st.c |  1 -
 drivers/usb/dwc3/ep0.c |  8 +++
 drivers/usb/dwc3/gadget.c  | 37 
 drivers/usb/dwc3/host.c| 16 ++
 drivers/usb/host/ehci-fsl.c|  4 ++--
 drivers/usb/host/xhci-mem.c| 12 +--
 drivers/usb/host/xhci-plat.c   | 33 +++--
 drivers/usb/host/xhci.c| 15 +
 include/linux/usb.h|  1 +
 include/linux/usb/hcd.h|  3 +++
 20 files changed, 158 insertions(+), 117 deletions(-)

-- 
2.1.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


[PATCH v4 1/6] usb: separate out sysdev pointer from usb_bus

2016-11-15 Thread Sriram Dash
From: Arnd Bergmann 

For xhci-hcd platform device, all the DMA parameters are not
configured properly, notably dma ops for dwc3 devices.

The idea here is that you pass in the parent of_node along with
the child device pointer, so it would behave exactly like the
parent already does. The difference is that it also handles all
the other attributes besides the mask.

sysdev will represent the physical device, as seen from firmware
or bus.Splitting the usb_bus->controller field into the
Linux-internal device (used for the sysfs hierarchy, for printks
and for power management) and a new pointer (used for DMA,
DT enumeration and phy lookup) probably covers all that we really
need.

Signed-off-by: Arnd Bergmann 
Signed-off-by: Sriram Dash 
Tested-by: Baolin Wang 
Cc: Felipe Balbi 
Cc: Grygorii Strashko 
Cc: Sinjan Kumar 
Cc: David Fisher 
Cc: Catalin Marinas 
Cc: "Thang Q. Nguyen" 
Cc: Yoshihiro Shimoda 
Cc: Stephen Boyd 
Cc: Bjorn Andersson 
Cc: Ming Lei 
Cc: Jon Masters 
Cc: Dann Frazier 
Cc: Peter Chen 
Cc: Leo Li 
---
Changes in v4:
  - No update

Changes in v3: 
  - usb is_device_dma_capable instead of directly accessing 
dma props. 
 
Changes in v2: 
  - Split the patch wrt driver


 drivers/usb/core/buffer.c | 12 ++--
 drivers/usb/core/hcd.c| 48 ---
 drivers/usb/core/usb.c| 18 +-
 include/linux/usb.h   |  1 +
 include/linux/usb/hcd.h   |  3 +++
 5 files changed, 48 insertions(+), 34 deletions(-)

diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c
index 98e39f9..a6cd44a 100644
--- a/drivers/usb/core/buffer.c
+++ b/drivers/usb/core/buffer.c
@@ -63,7 +63,7 @@ int hcd_buffer_create(struct usb_hcd *hcd)
int i, size;
 
if (!IS_ENABLED(CONFIG_HAS_DMA) ||
-   (!hcd->self.controller->dma_mask &&
+   (!is_device_dma_capable(hcd->self.sysdev) &&
 !(hcd->driver->flags & HCD_LOCAL_MEM)))
return 0;
 
@@ -72,7 +72,7 @@ int hcd_buffer_create(struct usb_hcd *hcd)
if (!size)
continue;
snprintf(name, sizeof(name), "buffer-%d", size);
-   hcd->pool[i] = dma_pool_create(name, hcd->self.controller,
+   hcd->pool[i] = dma_pool_create(name, hcd->self.sysdev,
size, size, 0);
if (!hcd->pool[i]) {
hcd_buffer_destroy(hcd);
@@ -127,7 +127,7 @@ void *hcd_buffer_alloc(
 
/* some USB hosts just use PIO */
if (!IS_ENABLED(CONFIG_HAS_DMA) ||
-   (!bus->controller->dma_mask &&
+   (!is_device_dma_capable(bus->sysdev) &&
 !(hcd->driver->flags & HCD_LOCAL_MEM))) {
*dma = ~(dma_addr_t) 0;
return kmalloc(size, mem_flags);
@@ -137,7 +137,7 @@ void *hcd_buffer_alloc(
if (size <= pool_max[i])
return dma_pool_alloc(hcd->pool[i], mem_flags, dma);
}
-   return dma_alloc_coherent(hcd->self.controller, size, dma, mem_flags);
+   return dma_alloc_coherent(hcd->self.sysdev, size, dma, mem_flags);
 }
 
 void hcd_buffer_free(
@@ -154,7 +154,7 @@ void hcd_buffer_free(
return;
 
if (!IS_ENABLED(CONFIG_HAS_DMA) ||
-   (!bus->controller->dma_mask &&
+   (!is_device_dma_capable(bus->sysdev) &&
 !(hcd->driver->flags & HCD_LOCAL_MEM))) {
kfree(addr);
return;
@@ -166,5 +166,5 @@ void hcd_buffer_free(
return;
}
}
-   dma_free_coherent(hcd->self.controller, size, addr, dma);
+   dma_free_coherent(hcd->self.sysdev, size, addr, dma);
 }
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 479e223..f8feb08 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1073,6 +1073,7 @@ static void usb_deregister_bus (struct usb_bus *bus)
 static int register_root_hub(struct usb_hcd *hcd)
 {
struct device *parent_dev = hcd->self.controller;
+   struct device *sysdev = hcd->self.sysdev;
struct usb_device *usb_dev = hcd->self.root_hub;
const int devnum = 1;
int retval;
@@ -1119,7 +1120,7 @@ static int register_root_hub(struct usb_hcd *hcd)
/* Did the HC die before the root hub was registered? */
if (HCD_DEAD(hcd))
usb_hc_died (hcd);  /* This time clean up */
-   usb_dev->dev.of_node = parent_dev->of_node;
+   usb_dev->dev.of_node = 

[PATCH 3/3] xhci: Remove busy loop from xhci_abort_cmd_ring()

2016-11-15 Thread OGAWA Hirofumi
Now, xhci_abort_cmd_ring() is sleepable. So no reason to use busy loop
anymore.

- Convert udelay(1000) => msleep(1).
- Add xhci_handshake_sleep(), and use it.

As related change, current xhci_handshake() is strange behavior,
E.g. xhci_handshake(ptr, mask, done, 1) does

result = readl(ptr);
/* check result */
udelay(1);  <= meaningless delay
return -ETIMEDOUT;

Instead of above, this changes to do

result = readl(ptr);
/* check result */
udelay(1);
result = readl(ptr);
/* check result */
return -ETIMEDOUT;

Signed-off-by: OGAWA Hirofumi 
---

 drivers/usb/host/xhci-ring.c |   10 
 drivers/usb/host/xhci.c  |   52 +-
 drivers/usb/host/xhci.h  |1 
 3 files changed, 48 insertions(+), 15 deletions(-)

diff -puN drivers/usb/host/xhci-ring.c~xhci-fix-abort-race3 
drivers/usb/host/xhci-ring.c
--- xhci/drivers/usb/host/xhci-ring.c~xhci-fix-abort-race3  2016-11-16 
13:36:08.787328641 +0900
+++ xhci-hirofumi/drivers/usb/host/xhci-ring.c  2016-11-16 13:36:08.789328640 
+0900
@@ -359,15 +359,15 @@ static int xhci_abort_cmd_ring(struct xh
 * seconds), then it should assume that the there are
 * larger problems with the xHC and assert HCRST.
 */
-   ret = xhci_handshake(>op_regs->cmd_ring,
-   CMD_RING_RUNNING, 0, 5 * 1000 * 1000);
+   ret = xhci_handshake_sleep(>op_regs->cmd_ring,
+  CMD_RING_RUNNING, 0, 5 * 1000 * 1000);
if (ret < 0) {
/* we are about to kill xhci, give it one more chance */
xhci_write_64(xhci, temp_64 | CMD_RING_ABORT,
  >op_regs->cmd_ring);
-   udelay(1000);
-   ret = xhci_handshake(>op_regs->cmd_ring,
-CMD_RING_RUNNING, 0, 3 * 1000 * 1000);
+   msleep(1);
+   ret = xhci_handshake_sleep(>op_regs->cmd_ring,
+   CMD_RING_RUNNING, 0, 3 * 1000 * 1000);
if (ret < 0) {
xhci_err(xhci, "Stopped the command ring failed, "
 "maybe the host is dead\n");
diff -puN drivers/usb/host/xhci.c~xhci-fix-abort-race3 drivers/usb/host/xhci.c
--- xhci/drivers/usb/host/xhci.c~xhci-fix-abort-race3   2016-11-16 
13:36:08.787328641 +0900
+++ xhci-hirofumi/drivers/usb/host/xhci.c   2016-11-16 13:36:08.790328639 
+0900
@@ -61,21 +61,53 @@ MODULE_PARM_DESC(quirks, "Bit flags for
  * handshake done).  There are two failure modes:  "usec" have passed (major
  * hardware flakeout), or the register reads as all-ones (hardware removed).
  */
+static int __xhci_handshake(void __iomem *ptr, u32 mask, u32 done)
+{
+   u32 result;
+
+   result = readl(ptr);
+   if (result == ~(u32)0)  /* card removed */
+   return -ENODEV;
+   result &= mask;
+   if (result == done)
+   return 0;
+   return 1;
+}
+
 int xhci_handshake(void __iomem *ptr, u32 mask, u32 done, int usec)
 {
-   u32 result;
+   int ret;
 
-   do {
-   result = readl(ptr);
-   if (result == ~(u32)0)  /* card removed */
-   return -ENODEV;
-   result &= mask;
-   if (result == done)
-   return 0;
+   while (1) {
+   ret = __xhci_handshake(ptr, mask, done);
+   if (ret <= 0)
+   goto out;
+   if (usec <= 0)
+   break;
udelay(1);
usec--;
-   } while (usec > 0);
-   return -ETIMEDOUT;
+   }
+   ret = -ETIMEDOUT;
+out:
+   return ret;
+}
+
+int xhci_handshake_sleep(void __iomem *ptr, u32 mask, u32 done, int usec)
+{
+   unsigned long timeout = jiffies + usecs_to_jiffies(usec);
+   int ret;
+
+   while (1) {
+   ret = __xhci_handshake(ptr, mask, done);
+   if (ret <= 0)
+   goto out;
+   if (time_after(jiffies, timeout))
+   break;
+   usleep_range(1, 10);
+   }
+   ret = -ETIMEDOUT;
+out:
+   return ret;
 }
 
 /*
diff -puN drivers/usb/host/xhci.h~xhci-fix-abort-race3 drivers/usb/host/xhci.h
--- xhci/drivers/usb/host/xhci.h~xhci-fix-abort-race3   2016-11-16 
13:36:08.788328640 +0900
+++ xhci-hirofumi/drivers/usb/host/xhci.h   2016-11-16 13:36:08.790328639 
+0900
@@ -1844,6 +1844,7 @@ void xhci_free_command(struct xhci_hcd *
 /* xHCI host controller glue */
 typedef void (*xhci_get_quirks_t)(struct device *, struct xhci_hcd *);
 int xhci_handshake(void __iomem *ptr, u32 mask, u32 done, int usec);
+int xhci_handshake_sleep(void __iomem *ptr, u32 mask, u32 done, int usec);
 void xhci_quiesce(struct xhci_hcd *xhci);
 int xhci_halt(struct xhci_hcd *xhci);
 int xhci_reset(struct xhci_hcd *xhci);
_

-- 

[PATCH 2/3] xhci: Fix race related to abort operation

2016-11-15 Thread OGAWA Hirofumi
Current abort operation has race.

xhci_handle_command_timeout()
  xhci_abort_cmd_ring()
xhci_write_64(CMD_RING_ABORT)
xhci_handshake(5s)
  do {
check CMD_RING_RUNNING
udelay(1)
   ...
   COMP_CMD_ABORT event
   COMP_CMD_STOP event
   xhci_handle_stopped_cmd_ring()
 restart cmd_ring
 CMD_RING_RUNNING become 1 again
  } while ()
  return -ETIMEDOUT
xhci_write_64(CMD_RING_ABORT)
/* can abort random command */

To do abort operation correctly, we have to wait both of COMP_CMD_STOP
event and negation of CMD_RING_RUNNING.

But like above, while timeout handler is waiting negation of
CMD_RING_RUNNING, event handler can restart cmd_ring. So timeout
handler never be notice negation of CMD_RING_RUNNING, and retry of
CMD_RING_ABORT can abort random command (BTW, I guess retry of
CMD_RING_ABORT was workaround of this race).

To fix this race, this moves xhci_handle_stopped_cmd_ring() to
xhci_abort_cmd_ring().  And timeout handler waits COMP_CMD_STOP event.

At this point, timeout handler is owner of cmd_ring, and safely
restart cmd_ring by using xhci_handle_stopped_cmd_ring().

[FWIW, as bonus, this way would be easily extend to add CMD_RING_PAUSE
operation]

Signed-off-by: OGAWA Hirofumi 
---

 drivers/usb/host/xhci-mem.c  |1 
 drivers/usb/host/xhci-ring.c |  163 ++
 drivers/usb/host/xhci.h  |1 
 3 files changed, 88 insertions(+), 77 deletions(-)

diff -puN drivers/usb/host/xhci-mem.c~xhci-fix-abort-race2 
drivers/usb/host/xhci-mem.c
--- xhci/drivers/usb/host/xhci-mem.c~xhci-fix-abort-race2   2016-11-16 
13:36:07.219329211 +0900
+++ xhci-hirofumi/drivers/usb/host/xhci-mem.c   2016-11-16 13:36:07.221329211 
+0900
@@ -2344,6 +2344,7 @@ int xhci_mem_init(struct xhci_hcd *xhci,
 
/* init command timeout work */
INIT_DELAYED_WORK(>cmd_timer, xhci_handle_command_timeout);
+   init_completion(>stop_completion);
 
page_size = readl(>op_regs->page_size);
xhci_dbg_trace(xhci, trace_xhci_dbg_init,
diff -puN drivers/usb/host/xhci-ring.c~xhci-fix-abort-race2 
drivers/usb/host/xhci-ring.c
--- xhci/drivers/usb/host/xhci-ring.c~xhci-fix-abort-race2  2016-11-16 
13:36:07.219329211 +0900
+++ xhci-hirofumi/drivers/usb/host/xhci-ring.c  2016-11-16 13:36:07.221329211 
+0900
@@ -284,6 +284,61 @@ static bool xhci_mod_cmd_timer(struct xh
return mod_delayed_work(system_wq, >cmd_timer, delay);
 }
 
+static struct xhci_command *xhci_next_queued_cmd(struct xhci_hcd *xhci)
+{
+   if (list_empty(>cmd_list))
+   return NULL;
+   return list_first_entry(>cmd_list, struct xhci_command, cmd_list);
+}
+
+/*
+ * Turn all commands on command ring with status set to "aborted" to no-op 
trbs.
+ * If there are other commands waiting then restart the ring and kick the 
timer.
+ * This must be called with command ring stopped and xhci->lock held.
+ */
+static void xhci_handle_stopped_cmd_ring(struct xhci_hcd *xhci,
+struct xhci_command *cur_cmd)
+{
+   struct xhci_command *i_cmd;
+   u32 cycle_state;
+
+   /* Turn all aborted commands in list to no-ops, then restart */
+   list_for_each_entry(i_cmd, >cmd_list, cmd_list) {
+
+   if (i_cmd->status != COMP_CMD_ABORT)
+   continue;
+
+   i_cmd->status = COMP_CMD_STOP;
+
+   xhci_dbg(xhci, "Turn aborted command %p to no-op\n",
+i_cmd->command_trb);
+   /* get cycle state from the original cmd trb */
+   cycle_state = le32_to_cpu(
+   i_cmd->command_trb->generic.field[3]) & TRB_CYCLE;
+   /* modify the command trb to no-op command */
+   i_cmd->command_trb->generic.field[0] = 0;
+   i_cmd->command_trb->generic.field[1] = 0;
+   i_cmd->command_trb->generic.field[2] = 0;
+   i_cmd->command_trb->generic.field[3] = cpu_to_le32(
+   TRB_TYPE(TRB_CMD_NOOP) | cycle_state);
+
+   /*
+* caller waiting for completion is called when command
+*  completion event is received for these no-op commands
+*/
+   }
+
+   xhci->cmd_ring_state = CMD_RING_STATE_RUNNING;
+
+   /* ring command ring doorbell to restart the command ring */
+   if ((xhci->cmd_ring->dequeue != xhci->cmd_ring->enqueue) &&
+   !(xhci->xhc_state & XHCI_STATE_DYING)) {
+   xhci->current_cmd = cur_cmd;
+   xhci_mod_cmd_timer(xhci, XHCI_CMD_DEFAULT_TIMEOUT);
+   xhci_ring_cmd_db(xhci);
+   }
+}
+
 static 

[PATCH 1/3] xhci: Use delayed_work instead of timer for command timeout

2016-11-15 Thread OGAWA Hirofumi
This is preparation to fix abort operation race (See "xhci: Fix race
related to abort operation"). To make timeout sleepable, use
delayed_work instead of timer.

Signed-off-by: OGAWA Hirofumi 
---

 drivers/usb/host/xhci-mem.c  |7 +++
 drivers/usb/host/xhci-ring.c |   24 +++-
 drivers/usb/host/xhci.h  |4 ++--
 3 files changed, 20 insertions(+), 15 deletions(-)

diff -puN drivers/usb/host/xhci-mem.c~xhci-fix-abort-race1 
drivers/usb/host/xhci-mem.c
--- xhci/drivers/usb/host/xhci-mem.c~xhci-fix-abort-race1   2016-11-16 
13:36:04.132330334 +0900
+++ xhci-hirofumi/drivers/usb/host/xhci-mem.c   2016-11-16 13:36:04.135330333 
+0900
@@ -1795,7 +1795,7 @@ void xhci_mem_cleanup(struct xhci_hcd *x
int size;
int i, j, num_ports;
 
-   del_timer_sync(>cmd_timer);
+   cancel_delayed_work_sync(>cmd_timer);
 
/* Free the Event Ring Segment Table and the actual Event Ring */
size = sizeof(struct xhci_erst_entry)*(xhci->erst.num_entries);
@@ -2342,9 +2342,8 @@ int xhci_mem_init(struct xhci_hcd *xhci,
 
INIT_LIST_HEAD(>cmd_list);
 
-   /* init command timeout timer */
-   setup_timer(>cmd_timer, xhci_handle_command_timeout,
-   (unsigned long)xhci);
+   /* init command timeout work */
+   INIT_DELAYED_WORK(>cmd_timer, xhci_handle_command_timeout);
 
page_size = readl(>op_regs->page_size);
xhci_dbg_trace(xhci, trace_xhci_dbg_init,
diff -puN drivers/usb/host/xhci-ring.c~xhci-fix-abort-race1 
drivers/usb/host/xhci-ring.c
--- xhci/drivers/usb/host/xhci-ring.c~xhci-fix-abort-race1  2016-11-16 
13:36:04.10334 +0900
+++ xhci-hirofumi/drivers/usb/host/xhci-ring.c  2016-11-16 13:36:04.135330333 
+0900
@@ -279,6 +279,11 @@ void xhci_ring_cmd_db(struct xhci_hcd *x
readl(>dba->doorbell[0]);
 }
 
+static bool xhci_mod_cmd_timer(struct xhci_hcd *xhci, unsigned long delay)
+{
+   return mod_delayed_work(system_wq, >cmd_timer, delay);
+}
+
 static int xhci_abort_cmd_ring(struct xhci_hcd *xhci)
 {
u64 temp_64;
@@ -295,7 +300,7 @@ static int xhci_abort_cmd_ring(struct xh
 * but the completion event in never sent. Use the cmd timeout timer to
 * handle those cases. Use twice the time to cover the bit polling retry
 */
-   mod_timer(>cmd_timer, jiffies + (2 * XHCI_CMD_DEFAULT_TIMEOUT));
+   xhci_mod_cmd_timer(xhci, 2 * XHCI_CMD_DEFAULT_TIMEOUT);
xhci_write_64(xhci, temp_64 | CMD_RING_ABORT,
>op_regs->cmd_ring);
 
@@ -320,7 +325,7 @@ static int xhci_abort_cmd_ring(struct xh
 
xhci_err(xhci, "Stopped the command ring failed, "
"maybe the host is dead\n");
-   del_timer(>cmd_timer);
+   cancel_delayed_work(>cmd_timer);
xhci->xhc_state |= XHCI_STATE_DYING;
xhci_halt(xhci);
return -ESHUTDOWN;
@@ -1251,21 +1256,22 @@ static void xhci_handle_stopped_cmd_ring
if ((xhci->cmd_ring->dequeue != xhci->cmd_ring->enqueue) &&
!(xhci->xhc_state & XHCI_STATE_DYING)) {
xhci->current_cmd = cur_cmd;
-   mod_timer(>cmd_timer, jiffies + XHCI_CMD_DEFAULT_TIMEOUT);
+   xhci_mod_cmd_timer(xhci, XHCI_CMD_DEFAULT_TIMEOUT);
xhci_ring_cmd_db(xhci);
}
return;
 }
 
 
-void xhci_handle_command_timeout(unsigned long data)
+void xhci_handle_command_timeout(struct work_struct *work)
 {
struct xhci_hcd *xhci;
int ret;
unsigned long flags;
u64 hw_ring_state;
bool second_timeout = false;
-   xhci = (struct xhci_hcd *) data;
+
+   xhci = container_of(to_delayed_work(work), struct xhci_hcd, cmd_timer);
 
/* mark this command to be cancelled */
spin_lock_irqsave(>lock, flags);
@@ -1333,7 +1339,7 @@ static void handle_cmd_completion(struct
 
cmd = list_entry(xhci->cmd_list.next, struct xhci_command, cmd_list);
 
-   del_timer(>cmd_timer);
+   cancel_delayed_work(>cmd_timer);
 
trace_xhci_cmd_completion(cmd_trb, (struct xhci_generic_trb *) event);
 
@@ -1421,7 +1427,7 @@ static void handle_cmd_completion(struct
if (cmd->cmd_list.next != >cmd_list) {
xhci->current_cmd = list_entry(cmd->cmd_list.next,
   struct xhci_command, cmd_list);
-   mod_timer(>cmd_timer, jiffies + XHCI_CMD_DEFAULT_TIMEOUT);
+   xhci_mod_cmd_timer(xhci, XHCI_CMD_DEFAULT_TIMEOUT);
}
 
 event_handled:
@@ -3790,9 +3796,9 @@ static int queue_command(struct xhci_hcd
 
/* if there are no other commands queued we start the timeout timer */
if (xhci->cmd_list.next == >cmd_list &&
-   !timer_pending(>cmd_timer)) {
+   !delayed_work_pending(>cmd_timer)) {
xhci->current_cmd = cmd;
-   mod_timer(>cmd_timer, jiffies + 

Re: [GIT PULL] USB fixes for v4.9-rc4

2016-11-15 Thread David Miller
From: Peter Chen 
Date: Wed, 16 Nov 2016 11:41:15 +0800

> I just notice that you submitted the "usb: gadget: u_ether: remove
> interrupt throttling", and cc stable tree too, but we can't get
> the agreement that it is suitable for all USB controllers, and David
> added this comment later that the networking stack has no hard
> requirement (eg, half of second) [1] which is not the same at your
> commit log.

It does fix a bug in at least one of the drivers, so it is definitely
a step forward.
--
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: [GIT PULL] USB fixes for v4.9-rc4

2016-11-15 Thread Peter Chen
On Tue, Nov 01, 2016 at 04:31:07PM +0200, Felipe Balbi wrote:
> 
> Hi Greg,
> 
> Here's another set of fixes for current -rc cycle. Let me know if you
> want anything to be changed.
> 
> cheers
> 
> The following changes since commit a909d3e636995ba7c349e2ca5dbb528154d4ac30:
> 
>   Linux 4.9-rc3 (2016-10-29 13:52:02 -0700)
> 
> are available in the git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git 
> tags/fixes-for-v4.9-rc4
> 
> for you to fetch changes up to fd9afd3cbe404998d732be6cc798f749597c5114:
> 
>   usb: gadget: u_ether: remove interrupt throttling (2016-11-01 15:48:25 
> +0200)
> 
> 
> usb: fixes for v4.9-rc4
> 
> Three more fixes for current -rc cycle. One
> randbuild fix on dwc3-st which was lacking
> , removal of IRQ
> throttling for networking gadgets and a fix for
> dwc3's error handling on failed initialization.
> 
> 
> Felipe Balbi (2):
>   usb: dwc3: st: add missing  include
>   usb: gadget: u_ether: remove interrupt throttling
> 
> Vivek Gautam (1):
>   usb: dwc3: Fix error handling for core init
> 
>  drivers/usb/dwc3/core.c   | 5 ++---
>  drivers/usb/dwc3/dwc3-st.c| 1 +
>  drivers/usb/gadget/function/u_ether.c | 8 
>  3 files changed, 3 insertions(+), 11 deletions(-)
> 

Hi Felipe,

I just notice that you submitted the "usb: gadget: u_ether: remove
interrupt throttling", and cc stable tree too, but we can't get
the agreement that it is suitable for all USB controllers, and David
added this comment later that the networking stack has no hard
requirement (eg, half of second) [1] which is not the same at your
commit log.

We have this tx interrupt throttling feature from this driver has been
written (at year 2008), and millions of shipped devices have this
feature. Even you think this feature really has problem, you may add
this to -next tree first, and test one or two revisions, this feature
itself is not a bug in all, just some controllers may can't use it.

[1] https://www.spinics.net/lists/linux-usb/msg148762.html

-- 

Best Regards,
Peter Chen
--
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] add DWR-158 in usb option

2016-11-15 Thread Lars Melin

On 2016-11-16 03:20, Giuseppe Lippolis wrote:

Signed-off-by: Giuseppe Lippolis 
---
Adding support for 3G modem DWR-158 from Dlink (I found it embedded in the
DWR-512).
---

--- drivers/usb/serial/option.c.orig2016-11-15 21:05:16.987504020 +0100
+++ drivers/usb/serial/option.c 2016-11-15 21:08:27.722378924 +0100
@@ -306,6 +306,9 @@ static void option_instat_callback(struc
 #define DLINK_PRODUCT_DWM_652_U5   0xce16
 #define DLINK_PRODUCT_DWM_652_U5A  0xce1e

+#define DLINK_ATL_VENDOR_ID0x2001
+#define DLINK_PRODUCT_DWM_158  0x7d04
+
 #define QISDA_VENDOR_ID0x1da5
 #define QISDA_PRODUCT_H21_4512 0x4512
 #define QISDA_PRODUCT_H21_4523 0x4523
@@ -1812,6 +1815,7 @@ static const struct usb_device_id option
{ USB_DEVICE(DLINK_VENDOR_ID, DLINK_PRODUCT_DWM_652) },
{ USB_DEVICE(ALINK_VENDOR_ID, DLINK_PRODUCT_DWM_652_U5) }, /* Yes,
ALINK_VENDOR_ID */
{ USB_DEVICE(ALINK_VENDOR_ID, DLINK_PRODUCT_DWM_652_U5A) },
+   { USB_DEVICE(DLINK_ATL_VENDOR_ID, DLINK_PRODUCT_DWM_158) },
{ USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4512) },
{ USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4523) },
{ USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H20_4515) },

--

NAK.
The verbose lsusb display which you pasted in your first mail shows
interface #0 and #1 to be used as netdev with cdc_ether as driver.
You must blacklist them in the option driver which otherwise will
claim them.


rgds
/Lars


--
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: core: Disable USB2.0 phy suspend when dwc3 acts as host role

2016-11-15 Thread Baolin Wang
Hi,

On 15 November 2016 at 18:49, Felipe Balbi  wrote:
>
> Hi,
>
> Baolin Wang  writes:
>> When dwc3 controller acts as host role with attaching slow speed device
>> (like mouse or keypad). Then if we plugged out the slow speed device,
>> it will timeout to run the deconfiguration endpoint command to drop the
>> endpoint's resources. Some xHCI command timeout log as below when
>> disconnecting one slow device:
>>
>> [   99.807739] c0 xhci-hcd.0.auto: Port Status Change Event for port 1
>> [   99.814699] c0 xhci-hcd.0.auto: resume root hub
>> [   99.819992] c0 xhci-hcd.0.auto: handle_port_status: starting port
>>  polling.
>> [   99.827808] c0 xhci-hcd.0.auto: get port status, actual port 0 status
>>  = 0x202a0
>> [   99.835903] c0 xhci-hcd.0.auto: Get port status returned 0x10100
>> [   99.850052] c0 xhci-hcd.0.auto: clear port connect change, actual
>>  port 0 status  = 0x2a0
>> [   99.859313] c0 xhci-hcd.0.auto: Cancel URB ffc01ed6cd00, dev 1,
>>  ep 0x81, starting at offset 0xc406d210
>> [   99.869645] c0 xhci-hcd.0.auto: // Ding dong!
>> [   99.874776] c0 xhci-hcd.0.auto: Stopped on Transfer TRB
>> [   99.880713] c0 xhci-hcd.0.auto: Removing canceled TD starting at
>>  0xc406d210 (dma).
>> [   99.889012] c0 xhci-hcd.0.auto: Finding endpoint context
>> [   99.895069] c0 xhci-hcd.0.auto: Cycle state = 0x1
>> [   99.900519] c0 xhci-hcd.0.auto: New dequeue segment =
>>  ffc1112f0880 (virtual)
>> [   99.908655] c0 xhci-hcd.0.auto: New dequeue pointer = 0xc406d220 (DMA)
>> [   99.915927] c0 xhci-hcd.0.auto: Set TR Deq Ptr cmd, new deq seg =
>>  ffc1112f0880 (0xc406d000 dma),
>>  new deq ptr = ff8002175220
>>  (0xc406d220 dma), new cycle = 1
>> [   99.931242] c0 xhci-hcd.0.auto: // Ding dong!
>> [   99.936360] c0 xhci-hcd.0.auto: Successful Set TR Deq Ptr cmd,
>>  deq = @c406d220
>> [   99.944458] c0 xhci-hcd.0.auto: xhci_hub_status_data: stopping port
>>  polling.
>> [  100.047619] c0 xhci-hcd.0.auto: xhci_drop_endpoint called for udev
>>  ffc01ae08800
>> [  100.057002] c0 xhci-hcd.0.auto: drop ep 0x81, slot id 1, new drop
>>  flags = 0x8, new add flags = 0x0
>> [  100.067878] c0 xhci-hcd.0.auto: xhci_check_bandwidth called for udev
>>  ffc01ae08800
>> [  100.076868] c0 xhci-hcd.0.auto: New Input Control Context:
>>
>> ..
>>
>> [  100.427252] c0 xhci-hcd.0.auto: // Ding dong!
>> [  105.430728] c0 xhci-hcd.0.auto: Command timeout
>> [  105.436029] c0 xhci-hcd.0.auto: Abort command ring
>> [  113.558223] c0 xhci-hcd.0.auto: Command completion event does not match
>>  command
>> [  113.569778] c0 xhci-hcd.0.auto: Timeout while waiting for configure
>>  endpoint command
>>
>> The reason is it will suspend USB phy to disable phy clock when
>> disconnecting the slow USB decice, that will hang on the xHCI commands
>> executing which depends on the phy clock.
>>
>> Thus we should disable USB2.0 phy suspend feature when dwc3 acts as host
>> role.
>>
>> Signed-off-by: Baolin Wang 
>> ---
>>  drivers/usb/dwc3/core.c |   14 ++
>>  1 file changed, 14 insertions(+)
>>
>> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
>> index 9a4a5e4..0b646cf 100644
>> --- a/drivers/usb/dwc3/core.c
>> +++ b/drivers/usb/dwc3/core.c
>> @@ -565,6 +565,20 @@ static int dwc3_phy_setup(struct dwc3 *dwc)
>>   if (dwc->revision > DWC3_REVISION_194A)
>>   reg |= DWC3_GUSB2PHYCFG_SUSPHY;
>>
>> + /*
>> +  * When dwc3 controller acts as host role with attaching one slow speed
>> +  * device (like mouse or keypad). Then if we plugged out the slow speed
>> +  * device, it will timeout to run the deconfiguration endpoint command.
>> +  * The reason is it will suspend USB phy to disable phy clock when
>> +  * disconnecting slow speed decice, which will affect the xHCI commands
>> +  * executing.
>> +  *
>> +  * Thus we should disable USB 2.0 phy suspend feature when dwc3 acts as
>> +  * host role.
>> +  */
>> + if (dwc->dr_mode == USB_DR_MODE_HOST || dwc->dr_mode == 
>> USB_DR_MODE_OTG)
>> + reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;
>
> which version of the core you're using? Recent version (since 1.94A,

My version is 2.80a.

> IIRC) can manage core suspend automatically. Also, this patch of yours
> will cause a power consumption regression.

Yes, it can manage core suspend automatically, that is the problem.
When plugging out one mouse or keypad device, the phy 

Re: add usb option device

2016-11-15 Thread Lars Melin

On 2016-11-16 02:13, Giuseppe Lippolis wrote:

Dear all,
I'm porting the Dlink DWR-512 device to LEDE (embedded linux).
This device embed a 3G modem connected through the usb bus .
The modem work properly with the option kernel module.

I added these line in the

#define DLINK_PRODUCT_DWM_652  0x3e04
#define DLINK_PRODUCT_DWM_652_U5  0xce16
#define DLINK_PRODUCT_DWM_652_U5A   0xce1e

+   #define DLINK_ATL_VENDOR_ID 0x2001
+   #define DLINK_PRODUCT_DWM_158  0x7d04

#define QISDA_VENDOR_ID 0x1da5
#define QISDA_PRODUCT_H21_4512  0x4512

[...]

{ USB_DEVICE(ALINK_VENDOR_ID, DLINK_PRODUCT_DWM_652_U5) }, /* Yes,
ALINK_VENDOR_ID */
{ USB_DEVICE(ALINK_VENDOR_ID, DLINK_PRODUCT_DWM_652_U5A) },
+ { USB_DEVICE(DLINK_ATL_VENDOR_ID, DLINK_PRODUCT_DWM_158) },
{ USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4512) },
{ USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4523) },



You have invented what looks to me as a bogus name for VID 0x2001 in
order to get it alphabetically sorted among other D-Link devices with a 
different VID.

There is already a section where the 0x2001 devices resides and that is
the right place to add this device.

Alphabetical sorting is worthless and so is the #defines for vid's and 
pid's. No one should ever search in the option driver by device name, 
but should instead do it by vid and pid directly without going via 
wrong/fake/invented defines. The whole driver is a big mess..



/Lars





--
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


Logs flooded with cdc_ether warnings

2016-11-15 Thread Josiah Schwab
Hello,

I recently observed that when my ThinkPad X1 Carbon (Gen 4) is plugged
into my Lenovo OneLink+ dock my logs are filled with lines of the form

Nov 15 18:12:28 monolith kernel: cdc_ether 2-4.1.3:2.0 eth0: kevent 11 may have 
been dropped
Nov 15 18:12:28 monolith kernel: cdc_ether 2-4.1.3:2.0 eth0: kevent 11 may have 
been dropped
Nov 15 18:12:28 monolith kernel: cdc_ether 2-4.1.3:2.0 eth0: kevent 11 may have 
been dropped
Nov 15 18:12:28 monolith kernel: cdc_ether 2-4.1.3:2.0 eth0: kevent 11 may have 
been dropped
Nov 15 18:12:28 monolith kernel: cdc_ether 2-4.1.3:2.0 eth0: kevent 11 may have 
been dropped
Nov 15 18:12:28 monolith kernel: cdc_ether 2-4.1.3:2.0 eth0: kevent 11 may have 
been dropped
Nov 15 18:12:28 monolith kernel: cdc_ether 2-4.1.3:2.0 eth0: kevent 11 may have 
been dropped
Nov 15 18:12:28 monolith kernel: cdc_ether 2-4.1.3:2.0 eth0: kevent 11 may have 
been dropped
Nov 15 18:12:28 monolith kernel: cdc_ether 2-4.1.3:2.0 eth0: kevent 11 may have 
been dropped
Nov 15 18:12:28 monolith kernel: cdc_ether 2-4.1.3:2.0 eth0: kevent 11 may have 
been dropped
Nov 15 18:12:33 monolith kernel: net_ratelimit: 69 callbacks suppressed


Here is information about my system:

$ uname -a
Linux monolith 4.8.7-1-ARCH #1 SMP PREEMPT Thu Nov 10 17:22:48 CET 2016 x86_64 
GNU/Linux

$ lsusb
Bus 002 Device 005: ID 17ef:3054 Lenovo
Bus 002 Device 004: ID 0451:8140 Texas Instruments, Inc. TUSB8041 4-Port Hub
Bus 002 Device 003: ID 17ef:1019 Lenovo
Bus 002 Device 002: ID 17ef:1018 Lenovo
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 009: ID 138a:0090 Validity Sensors, Inc.
Bus 001 Device 006: ID 13d3:5248 IMC Networks
Bus 001 Device 004: ID 8087:0a2b Intel Corp.
Bus 001 Device 012: ID 18d1:4ee1 Google Inc. Nexus Device (MTP)
Bus 001 Device 011: ID 046d:c317 Logitech, Inc. Wave Corded Keyboard
Bus 001 Device 007: ID 05e3:0608 Genesys Logic, Inc. Hub
Bus 001 Device 010: ID 17ef:3055 Lenovo
Bus 001 Device 008: ID 0451:8142 Texas Instruments, Inc. TUSB8041 4-Port Hub
Bus 001 Device 005: ID 17ef:1019 Lenovo
Bus 001 Device 003: ID 17ef:1018 Lenovo
Bus 001 Device 002: ID 046d:c52b Logitech, Inc. Unifying Receiver
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub


$ lshw
(trimmed for space)

*-usb:1
 description: Communication device
 product: OneLink+ Giga
 vendor: Lenovo
 physical id: 3
 bus info: usb@2:4.1.3
 version: 30.01
 serial: 8E00
 capabilities: usb-3.00 ethernet
 configuration: driver=cdc_ether maxpower=256mA speed=5000Mbit/s


This issue has previously been described in bug reports filed by others
with several different hardware configurations.

  https://bugzilla.kernel.org/show_bug.cgi?id=185641
  https://bugzilla.redhat.com/show_bug.cgi?id=1383810

In the bug report on kernel.org, Greg Kroah-Hartman instructs the
submitter to email this list.

However, I searched the list archives for "cdc_ether" and found no
indication that the submitter had done so, hence this message.
Searching in the kernel 4.9.x commits I did not find something that
would indicate this has already been addressed.


Josiah
--
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: PROBLEM: Oops when deactivating gadget serial driver

2016-11-15 Thread Peter Chen
On Wed, Nov 16, 2016 at 12:15:34AM +0100, Felix Hädicke wrote:
> Hello,
> 
> In 4.8.6 and 4.9-rc5, the gadget serial driver crashes during
> deinitialisation when compiled with CONFIG_U_SERIAL_CONSOLE.
> 
> Steps to reproduce:
> modprobe g-serial
> rmmod g-serial
> 
> The problem also occurs when using configfs, when the UDC is unbound.
> 
> I does not make a difference if I use my PLX3380 (driver net2280) as
> UDC, or dummy-hcd.
> 

I have tried v4.9-rc3 at nxp imx platform, and do not reproduce it,
no matter connect line or not.

root@imx6qdlsolo:~# modprobe g_serial
[   80.394264] g_serial gadget: Gadget Serial v2.4
[   80.398844] g_serial gadget: g_serial ready
root@imx6qdlsolo:~# 
root@imx6qdlsolo:~# 
root@imx6qdlsolo:~# [   90.685049] g_serial gadget: high-speed config #2: CDC 
ACM config

root@imx6qdlsolo:~# modprobe -r g_serial
root@imx6qdlsolo:~# 
root@imx6qdlsolo:~# 
root@imx6qdlsolo:~# modprobe g_serial
[   98.787081] g_serial gadget: Gadget Serial v2.4
[   98.791679] g_serial gadget: g_serial ready
root@imx6qdlsolo:~# [   99.238035] g_serial gadget: high-speed config #2: CDC 
ACM config

root@imx6qdlsolo:~# 
root@imx6qdlsolo:~# modprobe -r g_serial
root@imx6qdlsolo:~# 
root@imx6qdlsolo:~# modprobe g_serial
[  106.474225] g_serial gadget: Gadget Serial v2.4
[  106.478804] g_serial gadget: g_serial ready
root@imx6qdlsolo:~# modprobe -r g_serial
root@imx6qdlsolo:~# modprobe g_serial
[  109.219829] g_serial gadget: Gadget Serial v2.4
[  109.224476] g_serial gadget: g_serial ready
root@imx6qdlsolo:~# [  112.667040] g_serial gadget: high-speed config #2: CDC 
ACM config

root@imx6qdlsolo:~# 
root@imx6qdlsolo:~# cat /proc/version 
Linux version 4.9.0-rc3-00079-g4b75f1d (b29397@b29397-desktop) (gcc version 
5.3.0 (GCC) ) #1210 SMP Tue Nov 15 13:45:54 CST 2016
root@imx6qdlsolo:~# modprobe -r g_serial
root@imx6qdlsolo:~# modprobe g_serial
[  519.882929] g_serial gadget: Gadget Serial v2.4
[  519.887653] g_serial gadget: g_serial ready
root@imx6qdlsolo:~# [  520.355520] g_serial gadget: high-speed config #2: CDC 
ACM config
> 
> excerpt from dmesg output (complete output see below):
> 
> [   75.705246] BUG: unable to handle kernel
> [   75.751165] NULL pointer dereference
> [   75.791826]  at 0018
> [   75.814807] IP: [] kthread_stop+0x16/0x110
> [   75.882611] PGD 0
> 
> [   75.922339] Oops: 0002 [#1] SMP
> [   75.959880] Modules linked in: cdc_acm usb_f_acm u_serial g_serial(-)
> libcomposite configfs dummy_hcd bnep nls_ascii nls_cp437 vfat fat
> intel_rapl x86_pkg_temp_thermal coretemp kvm_intel kvm irqbypass
> crct10dif_pclmul crc32_pclmul ghash_clmulni_intel aesni_intel aes_x86_64
> lrw gf128mul glue_helper ablk_helper cryptd uvcvideo videobuf2_vmalloc
> videobuf2_memops videobuf2_v4l2 videobuf2_core videodev xpad ff_memless
> media joydev snd_hda_codec_hdmi snd_usb_audio snd_usbmidi_lib
> snd_hda_codec_realtek btusb btrtl efi_pstore btbcm snd_hda_codec_generic
> btintel bluetooth serio_raw rfkill crc16 efivars snd_hda_intel sg
> snd_hda_codec snd_hda_core snd_hwdep snd_seq_midi snd_seq_midi_event
> snd_pcm_oss snd_rawmidi snd_mixer_oss udc_core snd_pcm snd_seq
> snd_seq_device lpc_ich snd_timer mfd_core snd soundcore battery
> [   76.816163]  nuvoton_cir rc_core mei_me mei evdev intel_smartconnect
> shpchp ie31200_edac tpm_tis tpm_tis_core tpm edac_core parport_pc ppdev
> lp parport efivarfs autofs4 btrfs xor raid6_pq hid_logitech_hidpp
> hid_logitech_dj hid_generic usbhid hid uas usb_storage sr_mod cdrom
> sd_mod nouveau ahci libahci i915 crc32c_intel libata ttm i2c_algo_bit
> ehci_pci xhci_pci psmouse xhci_hcd drm_kms_helper ehci_hcd scsi_mod
> r8169 mii usbcore drm nvme nvme_core fjes button [last unloaded: net2280]
> [   77.316999] CPU: 2 PID: 853 Comm: rmmod Not tainted 4.9.0-rc5 #3
> [   77.388856] Hardware name: To Be Filled By O.E.M. To Be Filled By
> O.E.M./Z77 Extreme3, BIOS P1.50 07/11/2013
> [   77.506474] task: 880419f6a100 task.stack: c90002e8c000
> [   77.577292] RIP: 0010:[]  []
> kthread_stop+0x16/0x110
> [   77.674214] RSP: 0018:c90002e8fdb0  EFLAGS: 00010286
> [   77.737754] RAX: 0001 RBX:  RCX:
> 
> [   77.823133] RDX: 0001 RSI: 0246 RDI:
> 
> [   77.908513] RBP: c90002e8fdc8 R08:  R09:
> 0001
> [   77.993892] R10: 019d R11: 001f R12:
> 
> [   78.079271] R13: 88041b8d8400 R14: 0001 R15:
> 55fd59f5a1e0
> [   78.164649] FS:  7f82500be700() GS:88042f28()
> knlGS:
> [   78.261467] CS:  0010 DS:  ES:  CR0: 80050033
> [   78.330206] CR2: 0018 CR3: 00041bee2000 CR4:
> 001406e0
> [   78.415586] Stack:
> [   78.439609]   c0b8e720 88041b8d8400
> c90002e8fdf0
> [   78.528522]  c0b8bb52 88041a106300 0001
> 880419fc2ea8
> [   78.617436]  c90002e8fe08 

[PATCH 3/4] usb: dwc2: Use the ahb_burst param

2016-11-15 Thread John Youn
Use the new ahb_burst (instead of ahbcfg) to program the GAHBCFG.HBSTLEN
in both host and gadget mode.

Signed-off-by: John Youn 
---
 drivers/usb/dwc2/gadget.c |  2 +-
 drivers/usb/dwc2/hcd.c|  8 +++-
 drivers/usb/dwc2/params.c | 10 --
 3 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index ad0cd0e..da11292 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3231,7 +3231,7 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg 
*hsotg,
 
if (using_dma(hsotg)) {
dwc2_writel(GAHBCFG_GLBL_INTR_EN | GAHBCFG_DMA_EN |
-   (GAHBCFG_HBSTLEN_INCR4 << GAHBCFG_HBSTLEN_SHIFT),
+   (hsotg->params.ahb_burst << GAHBCFG_HBSTLEN_SHIFT),
hsotg->regs + GAHBCFG);
 
/* Set DDMA mode support in the core if needed */
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index fb7f8e9..7f57d5d 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -273,11 +273,9 @@ static int dwc2_gahbcfg_init(struct dwc2_hsotg *hsotg)
 
case GHWCFG2_INT_DMA_ARCH:
dev_dbg(hsotg->dev, "Internal DMA Mode\n");
-   if (hsotg->params.ahbcfg != -1) {
-   ahbcfg &= GAHBCFG_CTRL_MASK;
-   ahbcfg |= hsotg->params.ahbcfg &
- ~GAHBCFG_CTRL_MASK;
-   }
+   ahbcfg &= ~GAHBCFG_HBSTLEN_MASK;
+   ahbcfg |= (hsotg->params.ahb_burst <<
+  GAHBCFG_HBSTLEN_SHIFT);
break;
 
case GHWCFG2_SLAVE_ONLY_ARCH:
diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c
index 20f2697..5de54bc 100644
--- a/drivers/usb/dwc2/params.c
+++ b/drivers/usb/dwc2/params.c
@@ -981,15 +981,6 @@ static void dwc2_set_param_reload_ctl(struct dwc2_hsotg 
*hsotg, int val)
hsotg->params.reload_ctl = val;
 }
 
-static void dwc2_set_param_ahbcfg(struct dwc2_hsotg *hsotg, int val)
-{
-   if (val != -1)
-   hsotg->params.ahbcfg = val;
-   else
-   hsotg->params.ahbcfg = GAHBCFG_HBSTLEN_INCR4 <<
-   GAHBCFG_HBSTLEN_SHIFT;
-}
-
 static void dwc2_set_param_otg_ver(struct dwc2_hsotg *hsotg, int val)
 {
if (DWC2_OUT_OF_BOUNDS(val, 0, 1)) {
@@ -1219,7 +1210,6 @@ static void dwc2_set_parameters(struct dwc2_hsotg *hsotg,
dwc2_set_param_en_multiple_tx_fifo(hsotg,
params->en_multiple_tx_fifo);
dwc2_set_param_reload_ctl(hsotg, params->reload_ctl);
-   dwc2_set_param_ahbcfg(hsotg, params->ahbcfg);
dwc2_set_param_otg_ver(hsotg, params->otg_ver);
dwc2_set_param_uframe_sched(hsotg, params->uframe_sched);
dwc2_set_param_external_id_pin_ctl(hsotg, params->external_id_pin_ctl);
-- 
2.10.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


[PATCH 4/4] usb: dwc2: pci: Add AHB burst property for HAPS

2016-11-15 Thread John Youn
Set the AHB burst to INCR for HAPS.

Signed-off-by: John Youn 
---
 drivers/usb/dwc2/pci.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/dwc2/pci.c b/drivers/usb/dwc2/pci.c
index a23329e..146b7ce 100644
--- a/drivers/usb/dwc2/pci.c
+++ b/drivers/usb/dwc2/pci.c
@@ -67,6 +67,7 @@ static int dwc2_pci_quirks(struct pci_dev *pdev, struct 
platform_device *dwc2)
if (pdev->vendor == PCI_VENDOR_ID_SYNOPSYS &&
pdev->device == PCI_PRODUCT_ID_HAPS_HSOTG) {
struct property_entry properties[] = {
+   PROPERTY_ENTRY_STRING("snps,ahb-burst", "INCR"),
{ },
};
 
-- 
2.10.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


[PATCH 2/4] usb: dwc2: Add binding for AHB burst

2016-11-15 Thread John Youn
Add the "snps,ahb-burst" binding and read it in.

This property controls which burst type to perform on the AHB bus as a
master in internal DMA mode. This overrides the legacy param value,
which we need to keep around for now since several platforms use it.

Some platforms may see better or worse performance based on this
value. The HAPS platform is one example where all INCRx have worse
performance than INCR.

Other platforms (such as the Canyonlands board) report that the default
value causes system hangs.

Signed-off-by: John Youn 
Cc: Christian Lamparter 
---
 Documentation/devicetree/bindings/usb/dwc2.txt |  2 +
 drivers/usb/dwc2/core.h|  9 +
 drivers/usb/dwc2/params.c  | 56 ++
 3 files changed, 67 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/dwc2.txt 
b/Documentation/devicetree/bindings/usb/dwc2.txt
index 6c7c2bce..9e7b4b4 100644
--- a/Documentation/devicetree/bindings/usb/dwc2.txt
+++ b/Documentation/devicetree/bindings/usb/dwc2.txt
@@ -26,6 +26,8 @@ Optional properties:
 Refer to phy/phy-bindings.txt for generic phy consumer properties
 - dr_mode: shall be one of "host", "peripheral" and "otg"
   Refer to usb/generic.txt
+- snps,ahb-burst: specifies the ahb burst length. Valid arguments are:
+  "SINGLE", "INCR", "INCR4", "INCR8", "INCR16". Defaults to "INCR4".
 - g-rx-fifo-size: size of rx fifo size in gadget mode.
 - g-np-tx-fifo-size: size of non-periodic tx fifo size in gadget mode.
 - g-tx-fifo-size: size of periodic tx fifo per endpoint (except ep0) in gadget 
mode.
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 9548d3e..75c238c 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -430,6 +430,12 @@ enum dwc2_ep0_state {
  * needed.
  * 0 - No (default)
  * 1 - Yes
+ * @ahb_burst:  Specifies the AHB burst.
+ *   0 - Single
+ *   1 - INCR
+ *   3 - INCR4 (default)
+ *   5 - INCR8
+ *   7 - INCR16
  * @g_dma:  Enables gadget dma usage (default: autodetect).
  * @g_dma_desc: Enables gadget descriptor DMA (default: autodetect).
  * @g_rx_fifo_size:The periodic rx fifo size for the device, in
@@ -507,6 +513,9 @@ struct dwc2_core_params {
 * properties and cannot be set directly in this structure.
 */
 
+   /* Global parameters */
+   u8 ahb_burst;
+
/* Host parameters */
bool host_dma;
 
diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c
index 96387de..20f2697 100644
--- a/drivers/usb/dwc2/params.c
+++ b/drivers/usb/dwc2/params.c
@@ -1091,6 +1091,60 @@ static void dwc2_set_param_tx_fifo_sizes(struct 
dwc2_hsotg *hsotg)
}
 }
 
+static const char *const ahb_bursts[] = {
+   [GAHBCFG_HBSTLEN_SINGLE]= "SINGLE",
+   [GAHBCFG_HBSTLEN_INCR]  = "INCR",
+   [GAHBCFG_HBSTLEN_INCR4] = "INCR4",
+   [GAHBCFG_HBSTLEN_INCR8] = "INCR8",
+   [GAHBCFG_HBSTLEN_INCR16]= "INCR16",
+};
+
+static int dwc2_get_property_ahb_burst(struct dwc2_hsotg *hsotg)
+{
+   const char *str = NULL;
+   int burst;
+   int ret;
+
+   ret = device_property_read_string(hsotg->dev,
+ "snps,ahb-burst", );
+   if (ret < 0)
+   return ret;
+
+   burst = match_string(ahb_bursts,
+ARRAY_SIZE(ahb_bursts), str);
+   if (burst < 0) {
+   dev_err(hsotg->dev,
+   "Invalid parameter '%s' for ahb-burst\n", str);
+   }
+
+   return burst;
+}
+
+static void dwc2_set_ahb_burst(struct dwc2_hsotg *hsotg)
+{
+   struct dwc2_core_params *p = >params;
+   int burst;
+   int ret;
+
+   /* Default burst value */
+   burst = GAHBCFG_HBSTLEN_INCR4;
+
+   /* Get the legacy param value, if set. */
+   if (p->ahbcfg != -1) {
+   burst = (p->ahbcfg & GAHBCFG_HBSTLEN_MASK) >>
+   GAHBCFG_HBSTLEN_SHIFT;
+   }
+
+   /* Override it from devicetree, if set. */
+   ret = dwc2_get_property_ahb_burst(hsotg);
+   if (ret >= 0)
+   burst = ret;
+
+   /* Set the parameter */
+   p->ahb_burst = (u8)burst;
+   dev_dbg(hsotg->dev, "Setting ahb-burst to %d\n", burst);
+}
+
 static void dwc2_set_gadget_dma(struct dwc2_hsotg *hsotg)
 {
struct dwc2_hw_params *hw = >hw_params;
@@ -1171,6 +1225,8 @@ static void dwc2_set_parameters(struct dwc2_hsotg *hsotg,
dwc2_set_param_external_id_pin_ctl(hsotg, params->external_id_pin_ctl);
dwc2_set_param_hibernation(hsotg, params->hibernation);
 
+   dwc2_set_ahb_burst(hsotg);
+
/*
 * Set devicetree-only parameters. These parameters do not
 * take any values from 

[PATCH 0/4] usb: dwc2: Add AHB burst configuration

2016-11-15 Thread John Youn
This series adds a binding for AHB burst, reads it in, and configures
the controller for the specified burst type.

Tested on HAPS platform with DWC_hsotg IP version 3.30a.


John Youn (4):
  usb: dwc2: Fix AHB burst type for bcm2835
  usb: dwc2: Add binding for AHB burst
  usb: dwc2: Use the ahb_burst param
  usb: dwc2: pci: Add AHB burst property for HAPS

 Documentation/devicetree/bindings/usb/dwc2.txt |  2 +
 drivers/usb/dwc2/core.h|  9 
 drivers/usb/dwc2/gadget.c  |  2 +-
 drivers/usb/dwc2/hcd.c |  8 ++-
 drivers/usb/dwc2/params.c  | 68 +-
 drivers/usb/dwc2/pci.c |  1 +
 6 files changed, 73 insertions(+), 17 deletions(-)

-- 
2.10.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


[PATCH 1/4] usb: dwc2: Fix AHB burst type for bcm2835

2016-11-15 Thread John Youn
The ahbcfg param for bcm2835 is specifying a HBSTLEN of 0x8 (0x10 >> 1)
which is not a valid value for that field. Remove the param and default
to using INCR4.

Cc: Stefan Wahren 
Signed-off-by: John Youn 
---
 drivers/usb/dwc2/params.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c
index a786256..96387de 100644
--- a/drivers/usb/dwc2/params.c
+++ b/drivers/usb/dwc2/params.c
@@ -93,7 +93,7 @@ static const struct dwc2_core_params params_bcm2835 = {
.host_ls_low_power_phy_clk  = 0,/* 48 MHz */
.ts_dline   = 0,
.reload_ctl = 0,
-   .ahbcfg = 0x10,
+   .ahbcfg = -1,
.uframe_sched   = 0,
.external_id_pin_ctl= -1,
.hibernation= -1,
-- 
2.10.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: [PATHCv10 1/2] usb: USB Type-C connector class

2016-11-15 Thread Badhri Jagan Sridharan
Hi,

At present I am using the uevent in the userspace to infer
the Presence of a port on the remote end through the
appearance of usbc*-partner.

Userspace uses this info to decide on when to show a USB
notification on the screen and what should be the options
provided in the dialog.

I was assuming that this is not something that would be dropped.

Coding using events was relatively easier to program from userspace ..

Is it possible to use POLL for identifying the appearance of port partner ?
I did not notice sysfs_notify call in typec_connect/typec_disconnect.

It would also be nice to have uevent notifications when the contents
of current_data_role or current_power_role changes.

Is that too costly to have ?

Thanks,
Badhri.


On Tue, Nov 15, 2016 at 1:25 AM, Guenter Roeck  wrote:
> On 11/14/2016 11:07 PM, Greg KH wrote:
>>
>> On Mon, Nov 14, 2016 at 12:46:50PM -0800, Guenter Roeck wrote:
>>>
>>> On Mon, Nov 14, 2016 at 02:32:35PM +0200, Heikki Krogerus wrote:

 Hi Greg,

 On Mon, Nov 14, 2016 at 10:51:48AM +0100, Greg KH wrote:
>
> On Mon, Sep 19, 2016 at 02:16:56PM +0300, Heikki Krogerus wrote:
>>
>> The purpose of USB Type-C connector class is to provide
>> unified interface for the user space to get the status and
>> basic information about USB Type-C connectors on a system,
>> control over data role swapping, and when the port supports
>> USB Power Delivery, also control over power role swapping
>> and Alternate Modes.
>>
>> Reviewed-by: Guenter Roeck 
>> Tested-by: Guenter Roeck 
>> Signed-off-by: Heikki Krogerus 
>> ---
>>  Documentation/ABI/testing/sysfs-class-typec |  218 ++
>>  Documentation/usb/typec.txt |  103 +++
>>  MAINTAINERS |9 +
>>  drivers/usb/Kconfig |2 +
>>  drivers/usb/Makefile|2 +
>>  drivers/usb/typec/Kconfig   |7 +
>>  drivers/usb/typec/Makefile  |1 +
>>  drivers/usb/typec/typec.c   | 1075
>> +++
>>  include/linux/usb/typec.h   |  252 +++
>>  9 files changed, 1669 insertions(+)
>>  create mode 100644 Documentation/ABI/testing/sysfs-class-typec
>>  create mode 100644 Documentation/usb/typec.txt
>>  create mode 100644 drivers/usb/typec/Kconfig
>>  create mode 100644 drivers/usb/typec/Makefile
>>  create mode 100644 drivers/usb/typec/typec.c
>>  create mode 100644 include/linux/usb/typec.h
>
>
>>> [ ... ]
>>>
>> +
>> +int typec_connect(struct typec_port *port, struct typec_connection
>> *con)
>> +{
>> +   int ret;
>> +
>> +   if (!con->partner && !con->cable)
>> +   return -EINVAL;
>> +
>> +   port->connected = 1;
>> +   port->data_role = con->data_role;
>> +   port->pwr_role = con->pwr_role;
>> +   port->vconn_role = con->vconn_role;
>> +   port->pwr_opmode = con->pwr_opmode;
>> +
>> +   kobject_uevent(>dev.kobj, KOBJ_CHANGE);
>
>
> This worries me.  Who is listening for it?  What will you do with it?
> Shouldn't you just poll on an attribute file instead?


 Oliver! Did you need this or can we remove it?

 I remember I removed the "connected" attribute because you did not see
 any use for it at one point. I don't remember the reason exactly why?

>>>
>>> The Android team tells me that they are currently using the udev events
>>> to track port role changes, and to detect presence of port partner.
>>>
>>> Also, there are plans to track changes on usbc*cable to differentiate
>>> between cable attach vs. device being attached on the remote end.
>>>
>>> What is the problem with using kobject_uevent() and thus presumably
>>> udev events ?
>>
>>
>> It's not a "normal" thing to do and is pretty "heavy" to do.  What does
>> userspace do with that change event?  Does it read specific attributes?
>> What causes the event to happen in the kernel, is it really just a
>> change in the specific object, or do new ones get added/removed?
>>
>> In short, document the heck out of this please so people know how to use
>> it, and what is happening when the event happens.
>>
>
> Badhri,
>
> can you clarify which events you are using in detail, and what for ?
>
> Thanks,
> Guenter
>
--
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 1/2] drivers: usb: phy: Add qoriq usb 3.0 phy driver support

2016-11-15 Thread Rob Herring
On Mon, Nov 14, 2016 at 10:56:54AM +0530, Sriram Dash wrote:
> Adds qoriq usb 3.0 phy driver support for LS1043A platform.
> Describes the qoriq usb 2.0 phy driver binding, currently used
> for LS1043A platform.
> 
> Signed-off-by: Sriram Dash 
> ---
>  .../devicetree/bindings/phy/phy-qoriq-usb3.txt |  36 
>  drivers/phy/Kconfig|   8 +
>  drivers/phy/Makefile   |   1 +
>  drivers/phy/phy-qoriq-usb3.c   | 202 
> +
>  4 files changed, 247 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/phy/phy-qoriq-usb3.txt
>  create mode 100644 drivers/phy/phy-qoriq-usb3.c
> 
> diff --git a/Documentation/devicetree/bindings/phy/phy-qoriq-usb3.txt 
> b/Documentation/devicetree/bindings/phy/phy-qoriq-usb3.txt
> new file mode 100644
> index 000..d934c80
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/phy/phy-qoriq-usb3.txt
> @@ -0,0 +1,36 @@
> +Driver for Freescale USB 3.0 PHY
> +
> +Required properties:
> +
> +- compatible :   fsl,qoriq-usb3-phy
> +- reg :  register mappings for Parameter Configuration Register
> + and Phy base offset.
> +- reg-names :"param_ctrl" and "phy_base"
> +- phy_type : For multi port host USB controllers, should be one of
> + "ulpi", or "serial". For dual role USB controllers,
> + should be one of "ulpi", "utmi", "utmi_wide", or "serial".

Do any of these really apply to a USB3 PHY?

Rob

> +
> +Example:
> + usbphy0: usb3-phy@084F {

usb-phy@...

> +compatible = "fsl,qoriq-usb3-phy";
> +reg = <0x0 0x01570070 0x0 0xC>, <0x0 0x084F 0x0 
> 0x5000>;
> +reg-names = "param_ctrl", "phy_base";
> +#phy-cells = <0>;
> +phy_type = "utmi";
> +};
> +
> +usbphy1: usb3-phy@0850 {
> +compatible = "fsl,qoriq-usb3-phy";
> +reg = <0x0 0x0157007C 0x0 0xC>, <0x0 0x0850 0x0 
> 0x5000>;
> +reg-names = "param_ctrl", "phy_base";
> +#phy-cells = <0>;
> +phy_type = "utmi";
> +};
> +
> +usbphy2: usb3-phy@0851 {
> +compatible = "fsl,qoriq-usb3-phy";
> +reg = <0x0 0x01570088 0x0 0xC>, <0x0 0x0851 0x0 
> 0x5000>;
> +reg-names = "param_ctrl", "phy_base";
> +#phy-cells = <0>;
> +phy_type = "utmi";
> +};
--
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


PROBLEM: Oops when deactivating gadget serial driver

2016-11-15 Thread Felix Hädicke
Hello,

In 4.8.6 and 4.9-rc5, the gadget serial driver crashes during
deinitialisation when compiled with CONFIG_U_SERIAL_CONSOLE.

Steps to reproduce:
modprobe g-serial
rmmod g-serial

The problem also occurs when using configfs, when the UDC is unbound.

I does not make a difference if I use my PLX3380 (driver net2280) as
UDC, or dummy-hcd.


excerpt from dmesg output (complete output see below):

[   75.705246] BUG: unable to handle kernel
[   75.751165] NULL pointer dereference
[   75.791826]  at 0018
[   75.814807] IP: [] kthread_stop+0x16/0x110
[   75.882611] PGD 0

[   75.922339] Oops: 0002 [#1] SMP
[   75.959880] Modules linked in: cdc_acm usb_f_acm u_serial g_serial(-)
libcomposite configfs dummy_hcd bnep nls_ascii nls_cp437 vfat fat
intel_rapl x86_pkg_temp_thermal coretemp kvm_intel kvm irqbypass
crct10dif_pclmul crc32_pclmul ghash_clmulni_intel aesni_intel aes_x86_64
lrw gf128mul glue_helper ablk_helper cryptd uvcvideo videobuf2_vmalloc
videobuf2_memops videobuf2_v4l2 videobuf2_core videodev xpad ff_memless
media joydev snd_hda_codec_hdmi snd_usb_audio snd_usbmidi_lib
snd_hda_codec_realtek btusb btrtl efi_pstore btbcm snd_hda_codec_generic
btintel bluetooth serio_raw rfkill crc16 efivars snd_hda_intel sg
snd_hda_codec snd_hda_core snd_hwdep snd_seq_midi snd_seq_midi_event
snd_pcm_oss snd_rawmidi snd_mixer_oss udc_core snd_pcm snd_seq
snd_seq_device lpc_ich snd_timer mfd_core snd soundcore battery
[   76.816163]  nuvoton_cir rc_core mei_me mei evdev intel_smartconnect
shpchp ie31200_edac tpm_tis tpm_tis_core tpm edac_core parport_pc ppdev
lp parport efivarfs autofs4 btrfs xor raid6_pq hid_logitech_hidpp
hid_logitech_dj hid_generic usbhid hid uas usb_storage sr_mod cdrom
sd_mod nouveau ahci libahci i915 crc32c_intel libata ttm i2c_algo_bit
ehci_pci xhci_pci psmouse xhci_hcd drm_kms_helper ehci_hcd scsi_mod
r8169 mii usbcore drm nvme nvme_core fjes button [last unloaded: net2280]
[   77.316999] CPU: 2 PID: 853 Comm: rmmod Not tainted 4.9.0-rc5 #3
[   77.388856] Hardware name: To Be Filled By O.E.M. To Be Filled By
O.E.M./Z77 Extreme3, BIOS P1.50 07/11/2013
[   77.506474] task: 880419f6a100 task.stack: c90002e8c000
[   77.577292] RIP: 0010:[]  []
kthread_stop+0x16/0x110
[   77.674214] RSP: 0018:c90002e8fdb0  EFLAGS: 00010286
[   77.737754] RAX: 0001 RBX:  RCX:

[   77.823133] RDX: 0001 RSI: 0246 RDI:

[   77.908513] RBP: c90002e8fdc8 R08:  R09:
0001
[   77.993892] R10: 019d R11: 001f R12:

[   78.079271] R13: 88041b8d8400 R14: 0001 R15:
55fd59f5a1e0
[   78.164649] FS:  7f82500be700() GS:88042f28()
knlGS:
[   78.261467] CS:  0010 DS:  ES:  CR0: 80050033
[   78.330206] CR2: 0018 CR3: 00041bee2000 CR4:
001406e0
[   78.415586] Stack:
[   78.439609]   c0b8e720 88041b8d8400
c90002e8fdf0
[   78.528522]  c0b8bb52 88041a106300 0001
880419fc2ea8
[   78.617436]  c90002e8fe08 c0aed749 c0aef600
c90002e8fe20
[   78.706350] Call Trace:
[   78.735579]  [] gserial_free_line+0x72/0xb0 [u_serial]
[   78.815758]  [] acm_free_instance+0x19/0x30 [usb_f_acm]
[   78.896978]  [] usb_put_function_instance+0x20/0x30
[libcomposite]
[   78.989634]  [] gs_unbind+0x3b/0x70 [g_serial]
[   79.061493]  [] __composite_unbind+0x61/0xb0
[libcomposite]
[   79.146872]  [] composite_unbind+0x13/0x20
[libcomposite]
[   79.230172]  [] usb_gadget_remove_driver+0x3d/0x90
[udc_core]
[   79.317632]  []
usb_gadget_unregister_driver+0x6e/0xc0 [udc_core]
[   79.409248]  [] usb_composite_unregister+0x12/0x20
[libcomposite]
[   79.500866]  [] cleanup+0x10/0xda8 [g_serial]
[   79.571685]  [] SyS_delete_module+0x192/0x270
[   79.642508]  [] ? exit_to_usermode_loop+0x90/0xb0
[   79.717486]  [] entry_SYSCALL_64_fastpath+0x1e/0xad
[   79.794543] Code: 89 c6 e8 6e ff ff ff 48 89 df e8 06 bd fd ff 5b 5d
c3 0f 1f 00 0f 1f 44 00 00 55 48 89 e5 41 55 41 54 49 89 fc 53 0f 1f 44
00 00  41 ff 44 24 18 4c 89 e7 e8 bc f1 ff ff 48 85 c0 48 89 c3 74
[   80.027071] RIP  [] kthread_stop+0x16/0x110
[   80.095915]  RSP 
[   80.137617] CR2: 0018
[   80.177270] ---[ end trace 5b3336a407e1698c ]---


(gdb) list *(gserial_free_line+0x72)
0x1b52 is in gserial_free_line (drivers/usb/gadget/function/u_serial.c:187).
182  *
183  * Free the buffer and all associated memory.
184  */
185 static void gs_buf_free(struct gs_buf *gb)
186 {
187 kfree(gb->buf_buf);
188 gb->buf_buf = NULL;
189 }
190
191 /*


Complete dmesg output:

[0.00] Linux version 4.9.0-rc5 (root@han) (gcc version 5.3.1
20160413 (Ubuntu 5.3.1-14ubuntu2) ) #3 SMP Tue Nov 15 22:38:23 UTC 2016
[0.00] Command line: BOOT_IMAGE=/boot/vmlinuz-4.9.0-rc5

[PATCH v3] usb: dwc2: add amcc,dwc-otg support

2016-11-15 Thread John Youn
From: Christian Lamparter 

This patch adds support for the "amcc,usb-otg" device
which is found in the PowerPC Canyonlands' dts.

The device definition was added by:

commit c89b3458d8cc ("powerpc/44x: Add USB DWC DTS entry to Canyonlands
board")

but without any driver support as the dwc2 driver wasn't available at
that time.

Note: The system can't use the generic "snps,dwc2" compatible
because of the special ahbcfg configuration. The default
GAHBCFG_HBSTLEN_INCR4 of snps,dwc2 can cause a system hang
when the USB and SATA is used concurrently.

Signed-off-by: Christian Lamparter 
Signed-off-by: John Youn 
---

Sorry, the previous one broke compilation. This fixes it.

Regards,
John

v3 [johnyoun]:
* Fixed compilation issue

v2 [johnyoun]:
* Removed params struct
* Minor commit message formatting

 Documentation/devicetree/bindings/usb/dwc2.txt | 1 +
 drivers/usb/dwc2/params.c  | 1 +
 2 files changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/dwc2.txt 
b/Documentation/devicetree/bindings/usb/dwc2.txt
index ad8f7ff..6c7c2bce 100644
--- a/Documentation/devicetree/bindings/usb/dwc2.txt
+++ b/Documentation/devicetree/bindings/usb/dwc2.txt
@@ -12,6 +12,7 @@ Required properties:
   - "lantiq,xrx200-usb": The DWC2 USB controller instance in Lantiq XRX 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;
   - snps,dwc2: A generic DWC2 USB controller with default parameters.
 - reg : Should contain 1 register range (address and length)
 - interrupts : Should contain 1 interrupt
diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c
index 513556a..a786256 100644
--- a/drivers/usb/dwc2/params.c
+++ b/drivers/usb/dwc2/params.c
@@ -239,6 +239,7 @@ const struct of_device_id dwc2_of_match_table[] = {
{ .compatible = "samsung,s3c6400-hsotg", .data = NULL},
{ .compatible = "amlogic,meson8b-usb", .data = _amlogic },
{ .compatible = "amlogic,meson-gxbb-usb", .data = _amlogic },
+   { .compatible = "amcc,dwc-otg", .data = NULL },
{},
 };
 MODULE_DEVICE_TABLE(of, dwc2_of_match_table);
-- 
2.10.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: [PATCH 6/6] phy: twl4030-usb: Fix for musb session bit based PM

2016-11-15 Thread Bin Liu
On Tue, Nov 15, 2016 at 01:37:55PM -0800, Tony Lindgren wrote:
> Now with musb driver implementing generic session bit based
> PM, we need to have the USB PHYs behaving in a sane way for
> platforms implementing PM.
> 
> Currently twl4030-usb enables PM in twl4030_phy_power_on()
> and then disables it in twl4030_phy_power_off(). This will
> block PM runtime for the SoC when no cable is connected.
> 
> Fix the issue by moving PM runtime autosuspend call to
> happen where it gets called in twl4030_phy_power_on().
> 
> Note that this patch should not be backported to anything
> before commit 467d5c980709 ("usb: musb: Implement session bit
> based runtime PM for musb-core") as before that all the
> glue layers implemented their own PM.
> 
> Fixes: 467d5c980709 ("usb: musb: Implement session bit based
> runtime PM for musb-core")
> Tested-by: Ladislav Michl 
> Tested-by: Laurent Pinchart 
> Signed-off-by: Tony Lindgren 

I would need Kishon's Acked-by, or he picks it to his tree.

Thanks,
-Bin.

> ---
>  drivers/phy/phy-twl4030-usb.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c
> --- a/drivers/phy/phy-twl4030-usb.c
> +++ b/drivers/phy/phy-twl4030-usb.c
> @@ -459,8 +459,6 @@ static int twl4030_phy_power_off(struct phy *phy)
>   struct twl4030_usb *twl = phy_get_drvdata(phy);
>  
>   dev_dbg(twl->dev, "%s\n", __func__);
> - pm_runtime_mark_last_busy(twl->dev);
> - pm_runtime_put_autosuspend(twl->dev);
>  
>   return 0;
>  }
> @@ -472,6 +470,8 @@ static int twl4030_phy_power_on(struct phy *phy)
>   dev_dbg(twl->dev, "%s\n", __func__);
>   pm_runtime_get_sync(twl->dev);
>   schedule_delayed_work(>id_workaround_work, HZ);
> + pm_runtime_mark_last_busy(twl->dev);
> + pm_runtime_put_autosuspend(twl->dev);
>  
>   return 0;
>  }
> -- 
> 2.10.2
--
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


[RFC][PATCH 1/3] usb: dwc2: Force port resume on switching to device mode

2016-11-15 Thread John Stultz
From: Chen Yu 

We've seen failures when switching between host and gadget mode,
which was diagnosed as being caused due to the bus being
auto-suspended when we switched.

So this patch forces a port resume when switching to device
mode if the bus is suspended.

Cc: Wei Xu 
Cc: Guodong Xu 
Cc: Amit Pundir 
Cc: Rob Herring 
Cc: John Youn 
Cc: Douglas Anderson 
Cc: Chen Yu 
Cc: Felipe Balbi 
Cc: Greg Kroah-Hartman 
Cc: linux-usb@vger.kernel.org
Signed-off-by: Chen Yu 
Signed-off-by: John Stultz 
---
 drivers/usb/dwc2/hcd.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index df5a065..b374e60 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -54,6 +54,9 @@
 #include "core.h"
 #include "hcd.h"
 
+
+static void dwc2_port_resume(struct dwc2_hsotg *hsotg);
+
 /*
  * =
  *  Host Core Layer Functions
@@ -3204,6 +3207,11 @@ static void dwc2_conn_id_status_change(struct 
work_struct *work)
if (gotgctl & GOTGCTL_CONID_B) {
/* Wait for switch to device mode */
dev_dbg(hsotg->dev, "connId B\n");
+   if (hsotg->bus_suspended) {
+   dev_info(hsotg->dev,
+   "Do port resume before switching to device 
mode\n");
+   dwc2_port_resume(hsotg);
+   }
while (!dwc2_is_device_mode(hsotg)) {
dev_info(hsotg->dev,
 "Waiting for Peripheral Mode, Mode=%s\n",
-- 
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


[RFC][PATCH 2/3] usb: dwc2: Avoid suspending if we're in gadget mode

2016-11-15 Thread John Stultz
I've found when booting HiKey with the usb gadget cable attached
if I then try to connect via adb, I get an infinite spew of:

dwc2 f72c.usb: dwc2_hsotg_ep_sethalt(ep ffc0790ecb18 ep1out, 0)
dwc2 f72c.usb: dwc2_hsotg_ep_sethalt(ep ffc0790eca18 ep1in, 0)

It seems that the usb autosuspend is suspending the bus shortly
after bootup when the gadget cable is attached. So when adbd
then tries to use the device, it doesn't work and it then tries
to restart it over and over via the ep_sethalt calls (via
FUNCTIONFS_CLEAR_HALT ioctl).

Chen Yu suggested this patch to avoid suspending if we're
in device mode, and it avoids the problem.

This doesn't remove the need for the previous patch, to resume
the port when we switch to gadget mode from host mode. But it
does seem to resolve the issue.

Cc: Wei Xu 
Cc: Guodong Xu 
Cc: Amit Pundir 
Cc: Rob Herring 
Cc: John Youn 
Cc: Douglas Anderson 
Cc: Chen Yu 
Cc: Felipe Balbi 
Cc: Greg Kroah-Hartman 
Cc: linux-usb@vger.kernel.org
Suggested-by: Chen Yu 
Signed-off-by: John Stultz 
---
 drivers/usb/dwc2/hcd.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index b374e60..8c980fd 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -4373,6 +4373,9 @@ static int _dwc2_hcd_suspend(struct usb_hcd *hcd)
if (!HCD_HW_ACCESSIBLE(hcd))
goto unlock;
 
+   if (hsotg->op_state == OTG_STATE_B_PERIPHERAL)
+   goto unlock;
+
if (!hsotg->core_params->hibernation)
goto skip_power_saving;
 
-- 
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: [RFC][PATCH 0/3] DWC2 fixes and hacks to make things work on HiKey

2016-11-15 Thread John Stultz
On Tue, Nov 15, 2016 at 1:47 PM, John Stultz  wrote:
> I suspect that some of these issues may be due to the phy driver
> on hikey being somewhat minimal:
> https://git.linaro.org/people/john.stultz/android-dev.git/plain/drivers/phy/phy-hi6220-usb.c?h=dev/hikey-mainline-WIP

Whoops. Sorry, that link should have been the upstream version, not
the modified one:
https://git.linaro.org/people/john.stultz/android-dev.git/plain/drivers/phy/phy-hi6220-usb.c?id=a25f0944ba9b1d8a6813fd6f1a86f1bd59ac25a6


thanks
-john
--
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


[RFC][PATCH 3/3] usb: dwc2: Make sure we disconnect the gadget state

2016-11-15 Thread John Stultz
I had seen some odd behavior with HiKey's usb-gadget interface
that I finally seemed to have chased down. Basically every other
time I pluged in the OTG port, the gadget interface would
properly initialize. The other times, I'd get a big WARN_ON
in dwc2_hsotg_init_fifo() about the fifo_map not being clear.

Ends up if we don't disconnect the gadget state, the fifo-map
doesn't get cleared properly, which causes WARN_ON messages and
also results in the device not properly being setup as a gadget
every other time the OTG port is connected.

So this patch adds a call to dwc2_hsotg_disconnect() in the
reset path so the state is properly cleared.

With it, the gadget interface initializes properly on every
plug in.

Cc: Wei Xu 
Cc: Guodong Xu 
Cc: Amit Pundir 
Cc: Rob Herring 
Cc: John Youn 
Cc: Douglas Anderson 
Cc: Chen Yu 
Cc: Felipe Balbi 
Cc: Greg Kroah-Hartman 
Cc: linux-usb@vger.kernel.org
Signed-off-by: John Stultz 
---
 drivers/usb/dwc2/hcd.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 8c980fd..d2557b7 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -3228,6 +3228,7 @@ static void dwc2_conn_id_status_change(struct work_struct 
*work)
dwc2_core_init(hsotg, false);
dwc2_enable_global_interrupts(hsotg);
spin_lock_irqsave(>lock, flags);
+   dwc2_hsotg_disconnect(hsotg);
dwc2_hsotg_core_init_disconnected(hsotg, false);
spin_unlock_irqrestore(>lock, flags);
dwc2_hsotg_core_connect(hsotg);
-- 
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


[RFC][PATCH 0/3] DWC2 fixes and hacks to make things work on HiKey

2016-11-15 Thread John Stultz
Hey folks,
  I wanted to send out these patches again for comment.
These three patches are basically required to get otg/gadget
mode working reliably on HiKey.

I admit they do feel a bit hackish, but without them we run
into a number of problems related to autosuspend and incorrect
connection state handling.

So I wanted to resend these for feedback and guidance.

I suspect that some of these issues may be due to the phy driver
on hikey being somewhat minimal:
https://git.linaro.org/people/john.stultz/android-dev.git/plain/drivers/phy/phy-hi6220-usb.c?h=dev/hikey-mainline-WIP

So I've tried to hacked together extconn support into the phy
driver, and I'm getting phy notifications, but I've not yet
sorted out how to get the phy->gadget signaling to work
properly (or if my appraoch is even correct).

See: 
https://git.linaro.org/people/john.stultz/android-dev.git/commit/?h=dev/hikey-mainline-WIP=c608f263240f7c54dbf5439f2210cba1ab8e0136

I've had a difficult time trying to understand how the
usb contoller driver, phy driver and extcon shoudl properly
fit together, and I'm not sure what would be a good reference
driver to follow.

So suggestions or pointers here would be greatly appreciated.

Cc: Wei Xu 
Cc: Guodong Xu 
Cc: Amit Pundir 
Cc: Rob Herring 
Cc: John Youn 
Cc: Douglas Anderson 
Cc: Chen Yu 
Cc: Felipe Balbi 
Cc: Greg Kroah-Hartman 
Cc: linux-usb@vger.kernel.org

Chen Yu (1):
  usb: dwc2: Force port resume on switching to device mode

John Stultz (2):
  usb: dwc2: Avoid suspending if we're in gadget mode
  usb: dwc2: Make sure we disconnect the gadget state

 drivers/usb/dwc2/hcd.c | 12 
 1 file changed, 12 insertions(+)

-- 
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 4/6] usb: musb: Add missing pm_runtime_disable and drop 2430 PM timeout

2016-11-15 Thread Tony Lindgren
We are missing pm_runtime_disable() in 2430 glue layer. Further,
we only need to enable PM runtime and disable it on exit. With
musb_core.c doing PM, the glue layer as a parent will always be
active when musb_core.c is active.

This fixes host enumeration issues with some devices as reported
by Ladislav Michl .

And holding an RPM reference while deregistering the child would
lead to a crash in omap2430_runtime_suspend() which dereferences
the now freed child's driver data on put as pointed out by
Johan Hovold :

Unable to handle kernel paging request at virtual address 6b6b6f17
...
[] (omap2430_runtime_suspend) from []
 (pm_generic_runtime_suspend+0x3c/0x48)
[] (pm_generic_runtime_suspend) from []
 (_od_runtime_suspend+0x1c/0x30)
[] (_od_runtime_suspend) from [] (__rpm_callback+0x3c/0x70)
[] (__rpm_callback) from [] (rpm_callback+0x30/0x90)
[] (rpm_callback) from [] (rpm_suspend+0x118/0x6b4)
[] (rpm_suspend) from [] (rpm_idle+0x104/0x440)
[] (rpm_idle) from [] (__pm_runtime_idle+0x7c/0xb0)
[] (__pm_runtime_idle) from [] (omap2430_remove+0x38/0x58)
[] (omap2430_remove) from [] (platform_drv_remove+0x34/0x4c)

Note that if changes are needed to the autosuspend timeout, it should
be done in musb_core.c.

Reported-by: Ladislav Michl 
Fixes: 87326e858448 ("usb: musb: Remove extra PM runtime calls from
2430 glue layer")
Tested-by: Ladislav Michl 
Reviewed-by: Johan Hovold 
Tested-by: Laurent Pinchart 
Signed-off-by: Tony Lindgren 
---
 drivers/usb/musb/omap2430.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -513,17 +513,18 @@ static int omap2430_probe(struct platform_device *pdev)
}
 
pm_runtime_enable(glue->dev);
-   pm_runtime_use_autosuspend(glue->dev);
-   pm_runtime_set_autosuspend_delay(glue->dev, 100);
 
ret = platform_device_add(musb);
if (ret) {
dev_err(>dev, "failed to register musb device\n");
-   goto err2;
+   goto err3;
}
 
return 0;
 
+err3:
+   pm_runtime_disable(glue->dev);
+
 err2:
platform_device_put(musb);
 
@@ -535,10 +536,7 @@ static int omap2430_remove(struct platform_device *pdev)
 {
struct omap2430_glue *glue = platform_get_drvdata(pdev);
 
-   pm_runtime_get_sync(glue->dev);
platform_device_unregister(glue->musb);
-   pm_runtime_put_sync(glue->dev);
-   pm_runtime_dont_use_autosuspend(glue->dev);
pm_runtime_disable(glue->dev);
 
return 0;
-- 
2.10.2
--
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 6/6] phy: twl4030-usb: Fix for musb session bit based PM

2016-11-15 Thread Tony Lindgren
Now with musb driver implementing generic session bit based
PM, we need to have the USB PHYs behaving in a sane way for
platforms implementing PM.

Currently twl4030-usb enables PM in twl4030_phy_power_on()
and then disables it in twl4030_phy_power_off(). This will
block PM runtime for the SoC when no cable is connected.

Fix the issue by moving PM runtime autosuspend call to
happen where it gets called in twl4030_phy_power_on().

Note that this patch should not be backported to anything
before commit 467d5c980709 ("usb: musb: Implement session bit
based runtime PM for musb-core") as before that all the
glue layers implemented their own PM.

Fixes: 467d5c980709 ("usb: musb: Implement session bit based
runtime PM for musb-core")
Tested-by: Ladislav Michl 
Tested-by: Laurent Pinchart 
Signed-off-by: Tony Lindgren 
---
 drivers/phy/phy-twl4030-usb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c
--- a/drivers/phy/phy-twl4030-usb.c
+++ b/drivers/phy/phy-twl4030-usb.c
@@ -459,8 +459,6 @@ static int twl4030_phy_power_off(struct phy *phy)
struct twl4030_usb *twl = phy_get_drvdata(phy);
 
dev_dbg(twl->dev, "%s\n", __func__);
-   pm_runtime_mark_last_busy(twl->dev);
-   pm_runtime_put_autosuspend(twl->dev);
 
return 0;
 }
@@ -472,6 +470,8 @@ static int twl4030_phy_power_on(struct phy *phy)
dev_dbg(twl->dev, "%s\n", __func__);
pm_runtime_get_sync(twl->dev);
schedule_delayed_work(>id_workaround_work, HZ);
+   pm_runtime_mark_last_busy(twl->dev);
+   pm_runtime_put_autosuspend(twl->dev);
 
return 0;
 }
-- 
2.10.2
--
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 5/6] usb: musb: Drop pointless PM runtime code for dsps glue

2016-11-15 Thread Tony Lindgren
This already gets done automatically by PM runtime and we have
a separate autosuspend timeout in musb_core.c.

Reviewed-by: Johan Hovold 
Tested-by: Laurent Pinchart 
Signed-off-by: Tony Lindgren 
---
 drivers/usb/musb/musb_dsps.c | 22 ++
 1 file changed, 2 insertions(+), 20 deletions(-)

diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -783,28 +783,13 @@ static int dsps_probe(struct platform_device *pdev)
 
platform_set_drvdata(pdev, glue);
pm_runtime_enable(>dev);
-   pm_runtime_use_autosuspend(>dev);
-   pm_runtime_set_autosuspend_delay(>dev, 200);
-
-   ret = pm_runtime_get_sync(>dev);
-   if (ret < 0) {
-   dev_err(>dev, "pm_runtime_get_sync FAILED");
-   goto err2;
-   }
-
ret = dsps_create_musb_pdev(glue, pdev);
if (ret)
-   goto err3;
-
-   pm_runtime_mark_last_busy(>dev);
-   pm_runtime_put_autosuspend(>dev);
+   goto err;
 
return 0;
 
-err3:
-   pm_runtime_put_sync(>dev);
-err2:
-   pm_runtime_dont_use_autosuspend(>dev);
+err:
pm_runtime_disable(>dev);
return ret;
 }
@@ -815,9 +800,6 @@ static int dsps_remove(struct platform_device *pdev)
 
platform_device_unregister(glue->musb);
 
-   /* disable usbss clocks */
-   pm_runtime_dont_use_autosuspend(>dev);
-   pm_runtime_put_sync(>dev);
pm_runtime_disable(>dev);
 
return 0;
-- 
2.10.2
--
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


[PATCHv3 0/6] musb fixes for v4.9-rc cycle

2016-11-15 Thread Tony Lindgren
Hi all,

Here's v3 of musb fixes for issues that I've been able to track down.
The PM changes merged for v4.9 popped up various issues reported by
people that I had not seen earlier with my tests.

As many people depend on this driver, I'd like to have these merged
for v4.9-rc cycle.

Regards,

Tony


Changes since v2:

- Collect acks, update patch descriptions and remove one comment
  line based on comments from Johan Hovold 

Changes since v1:

- Numerous changes to patch 2/4 for the sleeping function fix
  based on comments from Johan

  - Two new patches to fix issues with devices not always
enumerating by removing pointless PM runtime code

Tony Lindgren (6):
  usb: musb: Fix broken use of static variable for multiple instances
  usb: musb: Fix sleeping function called from invalid context for hdrc
glue
  usb: musb: Fix PM for hub disconnect
  usb: musb: Add missing pm_runtime_disable and drop 2430 PM timeout
  usb: musb: Drop pointless PM runtime code for dsps glue
  phy: twl4030-usb: Fix for musb session bit based PM

 drivers/phy/phy-twl4030-usb.c  |   4 +-
 drivers/usb/musb/musb_core.c   | 147 -
 drivers/usb/musb/musb_core.h   |  13 +++-
 drivers/usb/musb/musb_dsps.c   |  58 
 drivers/usb/musb/musb_gadget.c |  39 +--
 drivers/usb/musb/omap2430.c|  10 ++-
 drivers/usb/musb/tusb6010.c|   6 +-
 7 files changed, 209 insertions(+), 68 deletions(-)

-- 
2.10.2
--
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/6] usb: musb: Fix sleeping function called from invalid context for hdrc glue

2016-11-15 Thread Tony Lindgren
Commit 65b3f50ed6fa ("usb: musb: Add PM runtime support for MUSB DSPS
glue layer") wrongly added a call for pm_runtime_get_sync to otg_timer
that runs in softirq context. That causes a "BUG: sleeping function called
from invalid context" every time when polling the cable status:

[] (__might_sleep) from [] (__pm_runtime_resume+0x9c/0xa0)
[] (__pm_runtime_resume) from [] (otg_timer+0x3c/0x254)
[] (otg_timer) from [] (call_timer_fn+0xfc/0x41c)
[] (call_timer_fn) from [] (expire_timers+0x120/0x210)
[] (expire_timers) from [] (run_timer_softirq+0xa4/0xdc)
[] (run_timer_softirq) from [] (__do_softirq+0x12c/0x594)

I did not notice that as I did not have CONFIG_DEBUG_ATOMIC_SLEEP enabled.
And looks like also musb_gadget_queue() suffers from the same problem.

Let's fix the issue by using a list of delayed work then call it on
resume. Note that we want to do this only when musb core and it's
parent devices are awake, and we need to make sure the DSPS glue
timer is stopped as noted by Johan Hovold .
Note that we already are re-enabling the timer with mod_timer() in
dsps_musb_enable().

Later on we may be able to remove other delayed work in the musb driver
and just do it from pending_resume_work. But this should be done only
for delayed work that does not have other timing requirements beyond
just being run on resume.

Fixes: 65b3f50ed6fa ("usb: musb: Add PM runtime support for MUSB DSPS
glue layer")
Reported-by: Johan Hovold 
Reviewed-by: Johan Hovold 
Tested-by: Laurent Pinchart 
Signed-off-by: Tony Lindgren 
---
 drivers/usb/musb/musb_core.c   | 109 +++--
 drivers/usb/musb/musb_core.h   |   7 +++
 drivers/usb/musb/musb_dsps.c   |  36 ++
 drivers/usb/musb/musb_gadget.c |  33 +++--
 4 files changed, 167 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1969,6 +1969,7 @@ static struct musb *allocate_instance(struct device *dev,
INIT_LIST_HEAD(>control);
INIT_LIST_HEAD(>in_bulk);
INIT_LIST_HEAD(>out_bulk);
+   INIT_LIST_HEAD(>pending_list);
 
musb->vbuserr_retry = VBUSERR_RETRY_COUNT;
musb->a_wait_bcon = OTG_TIME_A_WAIT_BCON;
@@ -2018,6 +2019,84 @@ static void musb_free(struct musb *musb)
musb_host_free(musb);
 }
 
+struct musb_pending_work {
+   int (*callback)(struct musb *musb, void *data);
+   void *data;
+   struct list_head node;
+};
+
+/*
+ * Called from musb_runtime_resume(), musb_resume(), and
+ * musb_queue_resume_work(). Callers must take musb->lock.
+ */
+static int musb_run_resume_work(struct musb *musb)
+{
+   struct musb_pending_work *w, *_w;
+   unsigned long flags;
+   int error = 0;
+
+   spin_lock_irqsave(>list_lock, flags);
+   list_for_each_entry_safe(w, _w, >pending_list, node) {
+   if (w->callback) {
+   error = w->callback(musb, w->data);
+   if (error < 0) {
+   dev_err(musb->controller,
+   "resume callback %p failed: %i\n",
+   w->callback, error);
+   }
+   }
+   list_del(>node);
+   devm_kfree(musb->controller, w);
+   }
+   spin_unlock_irqrestore(>list_lock, flags);
+
+   return error;
+}
+
+/*
+ * Called to run work if device is active or else queue the work to happen
+ * on resume. Caller must take musb->lock and must hold an RPM reference.
+ *
+ * Note that we cowardly refuse queuing work after musb PM runtime
+ * resume is done calling musb_run_resume_work() and return -EINPROGRESS
+ * instead.
+ */
+int musb_queue_resume_work(struct musb *musb,
+  int (*callback)(struct musb *musb, void *data),
+  void *data)
+{
+   struct musb_pending_work *w;
+   unsigned long flags;
+   int error;
+
+   if (WARN_ON(!callback))
+   return -EINVAL;
+
+   if (pm_runtime_active(musb->controller))
+   return callback(musb, data);
+
+   w = devm_kzalloc(musb->controller, sizeof(*w), GFP_ATOMIC);
+   if (!w)
+   return -ENOMEM;
+
+   w->callback = callback;
+   w->data = data;
+   spin_lock_irqsave(>list_lock, flags);
+   if (musb->is_runtime_suspended) {
+   list_add_tail(>node, >pending_list);
+   error = 0;
+   } else {
+   dev_err(musb->controller, "could not add resume work %p\n",
+   callback);
+   devm_kfree(musb->controller, w);
+   error = -EINPROGRESS;
+   }
+   spin_unlock_irqrestore(>list_lock, flags);
+
+   return error;
+}
+EXPORT_SYMBOL_GPL(musb_queue_resume_work);
+
 static void 

[PATCH 3/6] usb: musb: Fix PM for hub disconnect

2016-11-15 Thread Tony Lindgren
With a USB hub disconnected, devctl can be 0x19 for about a second
on am335x and will stay forever on at least omap3. And we get no
further interrupts when devctl session bit clears. This keeps
PM runtime active.

Let's fix the issue by polling devctl until the session bit clears
or times out. We can do this by making musb->irq_work into
delayed_work.

And with the polling implemented, we can now also have the quirk
for invalid VBUS it to avoid disconnecting too early while VBUS
is ramping up.

Fixes: 467d5c980709 ("usb: musb: Implement session bit based runtime
PM for musb-core")
Fixes: 65b3f50ed6fa ("usb: musb: Add PM runtime support for MUSB DSPS
Tested-by: Ladislav Michl 
Tested-by: Laurent Pinchart 
Signed-off-by: Tony Lindgren 
---
 drivers/usb/musb/musb_core.c   | 29 +++--
 drivers/usb/musb/musb_core.h   |  4 ++--
 drivers/usb/musb/musb_gadget.c |  6 +++---
 drivers/usb/musb/tusb6010.c|  6 +++---
 4 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -986,7 +986,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 
int_usb,
}
 #endif
 
-   schedule_work(>irq_work);
+   schedule_delayed_work(>irq_work, 0);
 
return handled;
 }
@@ -1855,14 +1855,23 @@ static void musb_pm_runtime_check_session(struct musb 
*musb)
MUSB_DEVCTL_HR;
switch (devctl & ~s) {
case MUSB_QUIRK_B_INVALID_VBUS_91:
-   if (!musb->session && !musb->quirk_invalid_vbus) {
-   musb->quirk_invalid_vbus = true;
+   if (musb->quirk_retries--) {
musb_dbg(musb,
-"First invalid vbus, assume no session");
+"Poll devctl on invalid vbus, assume no 
session");
+   schedule_delayed_work(>irq_work,
+ msecs_to_jiffies(1000));
+
return;
}
-   break;
case MUSB_QUIRK_A_DISCONNECT_19:
+   if (musb->quirk_retries--) {
+   musb_dbg(musb,
+"Poll devctl on possible host mode 
disconnect");
+   schedule_delayed_work(>irq_work,
+ msecs_to_jiffies(1000));
+
+   return;
+   }
if (!musb->session)
break;
musb_dbg(musb, "Allow PM on possible host mode disconnect");
@@ -1886,9 +1895,9 @@ static void musb_pm_runtime_check_session(struct musb 
*musb)
if (error < 0)
dev_err(musb->controller, "Could not enable: %i\n",
error);
+   musb->quirk_retries = 3;
} else {
musb_dbg(musb, "Allow PM with no session: %02x", devctl);
-   musb->quirk_invalid_vbus = false;
pm_runtime_mark_last_busy(musb->controller);
pm_runtime_put_autosuspend(musb->controller);
}
@@ -1899,7 +1908,7 @@ static void musb_pm_runtime_check_session(struct musb 
*musb)
 /* Only used to provide driver mode change events */
 static void musb_irq_work(struct work_struct *data)
 {
-   struct musb *musb = container_of(data, struct musb, irq_work);
+   struct musb *musb = container_of(data, struct musb, irq_work.work);
 
musb_pm_runtime_check_session(musb);
 
@@ -2288,7 +2297,7 @@ musb_init_controller(struct device *dev, int nIrq, void 
__iomem *ctrl)
musb_generic_disable(musb);
 
/* Init IRQ workqueue before request_irq */
-   INIT_WORK(>irq_work, musb_irq_work);
+   INIT_DELAYED_WORK(>irq_work, musb_irq_work);
INIT_DELAYED_WORK(>deassert_reset_work, musb_deassert_reset);
INIT_DELAYED_WORK(>finish_resume_work, musb_host_finish_resume);
 
@@ -2385,7 +2394,7 @@ musb_init_controller(struct device *dev, int nIrq, void 
__iomem *ctrl)
musb_host_cleanup(musb);
 
 fail3:
-   cancel_work_sync(>irq_work);
+   cancel_delayed_work_sync(>irq_work);
cancel_delayed_work_sync(>finish_resume_work);
cancel_delayed_work_sync(>deassert_reset_work);
if (musb->dma_controller)
@@ -2452,7 +2461,7 @@ static int musb_remove(struct platform_device *pdev)
 */
musb_exit_debugfs(musb);
 
-   cancel_work_sync(>irq_work);
+   cancel_delayed_work_sync(>irq_work);
cancel_delayed_work_sync(>finish_resume_work);
cancel_delayed_work_sync(>deassert_reset_work);
pm_runtime_get_sync(musb->controller);
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -310,7 +310,7 @@ struct musb {
   

[PATCH 1/6] usb: musb: Fix broken use of static variable for multiple instances

2016-11-15 Thread Tony Lindgren
We can't use static variable first for checking when musb is
initialized when we have multiple musb instances like on am335x.

Tested-by: Ladislav Michl 
Reviewed-by: Johan Hovold 
Tested-by: Laurent Pinchart 
Signed-off-by: Tony Lindgren 
---
 drivers/usb/musb/musb_core.c | 9 +
 drivers/usb/musb/musb_core.h | 2 ++
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -2291,6 +2291,7 @@ musb_init_controller(struct device *dev, int nIrq, void 
__iomem *ctrl)
if (status)
goto fail5;
 
+   musb->is_initialized = 1;
pm_runtime_mark_last_busy(musb->controller);
pm_runtime_put_autosuspend(musb->controller);
 
@@ -2629,7 +2630,6 @@ static int musb_runtime_suspend(struct device *dev)
 static int musb_runtime_resume(struct device *dev)
 {
struct musb *musb = dev_to_musb(dev);
-   static int  first = 1;
 
/*
 * When pm_runtime_get_sync called for the first time in driver
@@ -2640,9 +2640,10 @@ static int musb_runtime_resume(struct device *dev)
 * Also context restore without save does not make
 * any sense
 */
-   if (!first)
-   musb_restore_context(musb);
-   first = 0;
+   if (!musb->is_initialized)
+   return 0;
+
+   musb_restore_context(musb);
 
if (musb->need_finish_resume) {
musb->need_finish_resume = 0;
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -385,6 +385,8 @@ struct musb {
int a_wait_bcon;/* VBUS timeout in msecs */
unsigned long   idle_timeout;   /* Next timeout in jiffies */
 
+   unsignedis_initialized:1;
+
/* active means connected and not suspended */
unsignedis_active:1;
 
-- 
2.10.2
--
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] dma: cpp41: Fix handling of error path

2016-11-15 Thread Bin Liu
On Tue, Nov 15, 2016 at 12:58:17PM -0800, Tony Lindgren wrote:
> * Sekhar Nori  [161115 00:35]:
> > On Saturday 12 November 2016 12:58 AM, Tony Lindgren wrote:
> > > If we return early on pm_runtime_get() error, we need to also call
> > > pm_runtime_put_noidle() as pointed out in a musb related thread
> > > by Johan Hovold . This is to keep the PM runtime
> > > use counts happy.
> > > 
> > > Fixes: fdea2d09b997 ("dmaengine: cppi41: Add basic PM runtime support")
> > > Cc: Johan Hovold 
> > > Signed-off-by: Tony Lindgren 
> > > ---
> > >  drivers/dma/cppi41.c | 11 +--
> > >  1 file changed, 9 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c
> > > --- a/drivers/dma/cppi41.c
> > > +++ b/drivers/dma/cppi41.c
> > > @@ -366,8 +366,11 @@ static int cppi41_dma_alloc_chan_resources(struct 
> > > dma_chan *chan)
> > >   int error;
> > >  
> > >   error = pm_runtime_get_sync(cdd->ddev.dev);
> > > - if (error < 0)
> > > + if (error < 0) {
> > > + pm_runtime_put_noidle(cdd->ddev.dev);
> > > +
> > 
> > If pm_runtime_get_sync() fails due to callback error, then
> > rpm_callback() sets dev.power.runtime_error to an error value which gets
> > cleared by an explicit call to pm_runtime_set_suspended().
> > 
> > This will tell the framework that the status of device is suspended.
> > Else, the failure will be sticky and on subsequent attempts,
> > rpm_resume() will keep returning early instead of trying to resume the
> > device again.
> > 
> > This is as far as I can gather from code. So, I believe the recovery
> > path should be:
> > 
> > if (error < 0) {
> > pm_runtime_set_suspended(cdd->ddev.dev);
> > pm_runtime_put_noidle(cdd->ddev.dev);
> > 
> > ...
> 
> Well we should test this :)
> 
> BTW, what other users of cppi41 do we have in addition to musb? I think
> davinci is or will be using it too?

AFAIK, musb on am335x, da8xx, am35x uses cppi41. davinci musb uses cppi,
not cppi41.

Regards,
-Bin.
--
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 v4 4/4] ARM: dts: da850: Add the usb otg device nodeg

2016-11-15 Thread Bin Liu
On Tue, Nov 15, 2016 at 04:16:02PM +0530, Sekhar Nori wrote:
> On Thursday 03 November 2016 09:29 PM, Alexandre Bailon wrote:
> > This adds the device tree node for the usb otg
> > controller present in the da850 family of SoC's.
> > This also enables the otg usb controller for the lcdk board.
> > 
> > Signed-off-by: Alexandre Bailon 
> > ---
> >  arch/arm/boot/dts/da850-lcdk.dts |  8 
> >  arch/arm/boot/dts/da850.dtsi | 15 +++
> >  2 files changed, 23 insertions(+)
> > 
> > diff --git a/arch/arm/boot/dts/da850-lcdk.dts 
> > b/arch/arm/boot/dts/da850-lcdk.dts
> > index 7b8ab21..9f5040c 100644
> > --- a/arch/arm/boot/dts/da850-lcdk.dts
> > +++ b/arch/arm/boot/dts/da850-lcdk.dts
> > @@ -158,6 +158,14 @@
> > rx-num-evt = <32>;
> >  };
> >  
> > +_phy {
> > +   status = "okay";
> > +   };
> 
> As mentioned by David already, this node needs to be removed. Please
> rebase this on top of latest linux-davinci/master when ready for merging
> (driver changes accepted).

Dropped this patch due to this comment.

Regards,
-Bin.

> 
> > +
> > + {
> > +   status = "okay";
> > +};
> > +
> >   {
> > pinctrl-names = "default";
> > pinctrl-0 = <_pins>;
> > diff --git a/arch/arm/boot/dts/da850.dtsi b/arch/arm/boot/dts/da850.dtsi
> > index f79e1b9..322a31a 100644
> > --- a/arch/arm/boot/dts/da850.dtsi
> > +++ b/arch/arm/boot/dts/da850.dtsi
> > @@ -372,6 +372,21 @@
> > >;
> > status = "disabled";
> > };
> > +   usb_phy: usb-phy {
> > +   compatible = "ti,da830-usb-phy";
> > +   #phy-cells = <1>;
> > +   status = "disabled";
> > +   };
> > +   usb0: usb@20 {
> > +   compatible = "ti,da830-musb";
> > +   reg = <0x20 0x1>;
> > +   interrupts = <58>;
> > +   interrupt-names = "mc";
> > +   dr_mode = "otg";
> > +   phys = <_phy 0>;
> > +   phy-names = "usb-phy";
> > +   status = "disabled";
> > +   };
> 
> Can you separate out the soc specific changes from board changes? Please
> place the usb0 node above the mdio node. I am trying to get to a rough
> ordering based on reg property.
> 
> Thanks,
> Sekhar
> 
--
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: musb: remove obsolete resume-signalling comments

2016-11-15 Thread Bin Liu
On Fri, Nov 04, 2016 at 03:20:04PM +0100, Johan Hovold wrote:
> Remove comments about resume signalling being stopped from
> GetPortStatus, something which is no longer the case.
> 
> Fixes: 8ed1fb790ea2 ("usb: musb: finish suspend/reset work...")
> Signed-off-by: Johan Hovold 

Applied. Thanks.
-Bin.

> ---
>  drivers/usb/musb/musb_core.c| 5 +
>  drivers/usb/musb/musb_virthub.c | 1 -
>  2 files changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
> index 27dadc0d9114..bd58397e7c11 100644
> --- a/drivers/usb/musb/musb_core.c
> +++ b/drivers/usb/musb/musb_core.c
> @@ -569,10 +569,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 
> int_usb,
>   if (devctl & MUSB_DEVCTL_HM) {
>   switch (musb->xceiv->otg->state) {
>   case OTG_STATE_A_SUSPEND:
> - /* remote wakeup?  later, GetPortStatus
> -  * will stop RESUME signaling
> -  */
> -
> + /* remote wakeup? */
>   musb->port1_status |=
>   (USB_PORT_STAT_C_SUSPEND << 16)
>   | MUSB_PORT_STAT_RESUME;
> diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c
> index 61b5f1c3c5bc..0b4595439d51 100644
> --- a/drivers/usb/musb/musb_virthub.c
> +++ b/drivers/usb/musb/musb_virthub.c
> @@ -132,7 +132,6 @@ void musb_port_suspend(struct musb *musb, bool do_suspend)
>  
>   musb_dbg(musb, "Root port resuming, power %02x", power);
>  
> - /* later, GetPortStatus will stop RESUME signaling */
>   musb->port1_status |= MUSB_PORT_STAT_RESUME;
>   schedule_delayed_work(>finish_resume_work,
> msecs_to_jiffies(USB_RESUME_TIMEOUT));
> -- 
> 2.7.3
> 
--
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 v3 2/3] musb: sunxi: Remove custom babble handling

2016-11-15 Thread Bin Liu
On Fri, Sep 23, 2016 at 04:40:57PM +0300, Hans de Goede wrote:
> The musb core already handles babble interrupts, so the sunxi glue
> having its own custom handling is redundant.
> 
> Signed-off-by: Hans de Goede 

Applied. Thanks.
-Bin.

> ---
> Changes in v2:
> -This is a new patch in v2 of this patch series
> Changes in v3:
> -Improve commit msg
> ---
>  drivers/usb/musb/sunxi.c | 10 --
>  1 file changed, 10 deletions(-)
> 
> diff --git a/drivers/usb/musb/sunxi.c b/drivers/usb/musb/sunxi.c
> index 1408245..82eba92 100644
> --- a/drivers/usb/musb/sunxi.c
> +++ b/drivers/usb/musb/sunxi.c
> @@ -186,16 +186,6 @@ static irqreturn_t sunxi_musb_interrupt(int irq, void 
> *__hci)
>   if (musb->int_usb)
>   writeb(musb->int_usb, musb->mregs + SUNXI_MUSB_INTRUSB);
>  
> - /*
> -  * sunxi musb often signals babble on low / full speed device
> -  * disconnect, without ever raising MUSB_INTR_DISCONNECT, since
> -  * normally babble never happens treat it as disconnect.
> -  */
> - if ((musb->int_usb & MUSB_INTR_BABBLE) && is_host_active(musb)) {
> - musb->int_usb &= ~MUSB_INTR_BABBLE;
> - musb->int_usb |= MUSB_INTR_DISCONNECT;
> - }
> -
>   if ((musb->int_usb & MUSB_INTR_RESET) && !is_host_active(musb)) {
>   /* ep0 FADDR must be 0 when (re)entering peripheral mode */
>   musb_ep_select(musb->mregs, 0);
> -- 
> 2.9.3
> 
--
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: musb: omap2430: use dev_err

2016-11-15 Thread Bin Liu
On Wed, Nov 09, 2016 at 10:48:25AM -0700, Tony Lindgren wrote:
> * Ladislav Michl  [161109 07:09]:
> > Replace pr_err with dev_err to print also device name.
> > 
> > Signed-off-by: Ladislav Michl 
> 
> Acked-by: Tony Lindgren 

Applied. Thanks.
-Bin.

> 
> > ---
> >  drivers/usb/musb/omap2430.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
> > index cc12254..451b372 100644
> > --- a/drivers/usb/musb/omap2430.c
> > +++ b/drivers/usb/musb/omap2430.c
> > @@ -277,12 +277,12 @@ static int omap2430_musb_init(struct musb *musb)
> > if (status == -ENXIO)
> > return status;
> >  
> > -   pr_err("HS USB OTG: no transceiver configured\n");
> > +   dev_err(dev, "HS USB OTG: no transceiver configured\n");
> > return -EPROBE_DEFER;
> > }
> >  
> > if (IS_ERR(musb->phy)) {
> > -   pr_err("HS USB OTG: no PHY configured\n");
> > +   dev_err(dev, "HS USB OTG: no PHY configured\n");
> > return PTR_ERR(musb->phy);
> > }
> > musb->isr = omap2430_musb_interrupt;
> > @@ -301,7 +301,7 @@ static int omap2430_musb_init(struct musb *musb)
> >  
> > musb_writel(musb->mregs, OTG_INTERFSEL, l);
> >  
> > -   pr_debug("HS USB OTG: revision 0x%x, sysconfig 0x%02x, "
> > +   dev_dbg(dev, "HS USB OTG: revision 0x%x, sysconfig 0x%02x, "
> > "sysstatus 0x%x, intrfsel 0x%x, simenable  0x%x\n",
> > musb_readl(musb->mregs, OTG_REVISION),
> > musb_readl(musb->mregs, OTG_SYSCONFIG),
> > -- 
> > 2.1.4
> > 
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> > the body of a message to majord...@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
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: musb: omap2430: make complain on -EPROBE_DEFER dev_dbg

2016-11-15 Thread Bin Liu
On Wed, Nov 09, 2016 at 10:48:48AM -0700, Tony Lindgren wrote:
> * Ladislav Michl  [161109 07:11]:
> > There is no point having this complaint to be dev_err as it is just adding
> > noise to bootlog.
> 
> Acked-by: Tony Lindgren 

Applied. Thanks.
-Bin.

> 
> > Signed-off-by: Ladislav Michl 
> > ---
> >  drivers/usb/musb/omap2430.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
> > index 451b372..7c9aa5e 100644
> > --- a/drivers/usb/musb/omap2430.c
> > +++ b/drivers/usb/musb/omap2430.c
> > @@ -277,7 +277,7 @@ static int omap2430_musb_init(struct musb *musb)
> > if (status == -ENXIO)
> > return status;
> >  
> > -   dev_err(dev, "HS USB OTG: no transceiver configured\n");
> > +   dev_dbg(dev, "HS USB OTG: no transceiver configured\n");
> > return -EPROBE_DEFER;
> > }
> >  
> > -- 
> > 2.1.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 v4 0/4] Add DT support for DA8xx

2016-11-15 Thread Bin Liu
On Thu, Nov 03, 2016 at 04:59:08PM +0100, Alexandre Bailon wrote:
> Changes in v2:
> * Remove unrelated changes in patch 3
> * Rename the device node in patch 4
> 
> Changes in v3:
> * Fix few mistakes in DT binding sample
> * Only build the device table if DT is enabled
> 
> Change in v4:
> * Fix a nit
> 
> Alexandre Bailon (1):
>   ARM: dts: da850: Add the usb otg device node
> 
> Petr Kulhavy (3):
>   dt/bindings: Add binding for the DA8xx MUSB driver
>   usb: musb: core: added helper function for parsing DT
>   usb: musb: da8xx: Add DT support for the DA8xx driver

Applied. Thanks.
-Bin.

> 
>  .../devicetree/bindings/usb/da8xx-usb.txt  | 43 
>  arch/arm/boot/dts/da850-lcdk.dts   |  8 
>  arch/arm/boot/dts/da850.dtsi   | 15 +++
>  drivers/usb/musb/da8xx.c   | 46 
> ++
>  drivers/usb/musb/musb_core.c   | 19 +
>  drivers/usb/musb/musb_core.h   |  6 +++
>  6 files changed, 137 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/usb/da8xx-usb.txt
> 
> -- 
> 2.7.3
> 
--
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: musb: don't complain on -EPROBE_DEFER when initializing controller

2016-11-15 Thread Bin Liu
On Wed, Nov 09, 2016 at 10:48:10AM -0700, Tony Lindgren wrote:
> * Ladislav Michl  [161109 07:08]:
> > Don't complain on -EPROBE_DEFER when initializing controller,
> > the driver probe will be retried later.
> > 
> > Signed-off-by: Ladislav Michl 
> 
> Acked-by: Tony Lindgren 

Applied. Thanks.
-Bin.

> 
> > ---
> >  drivers/usb/musb/musb_core.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
> > index 27dadc0..77fd97b 100644
> > --- a/drivers/usb/musb/musb_core.c
> > +++ b/drivers/usb/musb/musb_core.c
> > @@ -2329,8 +2329,9 @@ musb_init_controller(struct device *dev, int nIrq, 
> > void __iomem *ctrl)
> > musb_platform_exit(musb);
> >  
> >  fail1:
> > -   dev_err(musb->controller,
> > -   "musb_init_controller failed with status %d\n", status);
> > +   if (status != -EPROBE_DEFER)
> > +   dev_err(musb->controller,
> > +   "%s failed with status %d\n", __func__, status);
> >  
> > musb_free(musb);
> >  
> > -- 
> > 2.1.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] dma: cpp41: Fix handling of error path

2016-11-15 Thread Tony Lindgren
* Sekhar Nori  [161115 00:35]:
> On Saturday 12 November 2016 12:58 AM, Tony Lindgren wrote:
> > If we return early on pm_runtime_get() error, we need to also call
> > pm_runtime_put_noidle() as pointed out in a musb related thread
> > by Johan Hovold . This is to keep the PM runtime
> > use counts happy.
> > 
> > Fixes: fdea2d09b997 ("dmaengine: cppi41: Add basic PM runtime support")
> > Cc: Johan Hovold 
> > Signed-off-by: Tony Lindgren 
> > ---
> >  drivers/dma/cppi41.c | 11 +--
> >  1 file changed, 9 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c
> > --- a/drivers/dma/cppi41.c
> > +++ b/drivers/dma/cppi41.c
> > @@ -366,8 +366,11 @@ static int cppi41_dma_alloc_chan_resources(struct 
> > dma_chan *chan)
> > int error;
> >  
> > error = pm_runtime_get_sync(cdd->ddev.dev);
> > -   if (error < 0)
> > +   if (error < 0) {
> > +   pm_runtime_put_noidle(cdd->ddev.dev);
> > +
> 
> If pm_runtime_get_sync() fails due to callback error, then
> rpm_callback() sets dev.power.runtime_error to an error value which gets
> cleared by an explicit call to pm_runtime_set_suspended().
> 
> This will tell the framework that the status of device is suspended.
> Else, the failure will be sticky and on subsequent attempts,
> rpm_resume() will keep returning early instead of trying to resume the
> device again.
> 
> This is as far as I can gather from code. So, I believe the recovery
> path should be:
> 
>   if (error < 0) {
>   pm_runtime_set_suspended(cdd->ddev.dev);
>   pm_runtime_put_noidle(cdd->ddev.dev);
> 
>   ...

Well we should test this :)

BTW, what other users of cppi41 do we have in addition to musb? I think
davinci is or will be using it too?

Regards,

Tony
--
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


AW: add usb option device

2016-11-15 Thread Giuseppe Lippolis
> Your email client ate the tabs and spit out spaces and line-wrapped the
> patch, making it impossible to apply.
> 
> Also, you need to make it against the latest kernel tree, 4.4 is really
old.
> 
> And finally, there is no good subject: line, or description of the patch,
or a
> signed-off-by: line, all of which are described in the document I pointed
you
> at.
> 
> Please fix this up and resend.

I add now a new post making a patch on the linux 4.8.8 :

[PATCH] add DWR-158 in usb option
http://marc.info/?l=linux-usb=147924122203290=2

I hope now is better.

Bye.


--
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


[RFC PATCH] xhci: Fix memory use after free in xhci_free_virt_device

2016-11-15 Thread Guenter Roeck
The following use-after-free reports were seen on resume with a specific
USB hub.

BUG: KASAN: use-after-free in xhci_free_virt_device+0x8c/0x21c
at addr ffc0cc1a2eb0
BUG: KASAN: use-after-free in xhci_update_tt_active_eps+0x9c/0xdc
at addr ffc0cc1a2eb0

Relevant traceback for the first case is:

xhci_free_virt_device+0x8c/0x21c
xhci_mem_cleanup+0x294/0x81c
xhci_resume+0x410/0x618
xhci_plat_resume+0x54/0x74
platform_pm_resume+0x74/0x84

which points to the following code in xhci_free_virt_device().

if (dev->tt_info)
old_active_eps = dev->tt_info->active_eps;

Problem with this code is that xhci_mem_cleanup() cleans up devices
starting with slot 1, and dev->tt_info for a device with higher slot
number can point back to the tt_info associated with device 1.
In lsusb, this looks as follows.

/:  Bus 05.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 480M
|__ Port 1: Dev 4, If 0, Class=Hub, Driver=hub/4p, 480M
|__ Port 3: Dev 7, If 0, Class=Vendor Specific Class, Driver=, 12M

When the higher-numbered device is cleared, it tries to access the already
released tt_info from slot 1 to get the value of old_active_eps.

The problem is not seen with all USB hubs since not all USB hubs require
the cleanup handling in xhci_resume().

Signed-off-by: Guenter Roeck 
---
Marked as RFC because I don't really like this fix at all and would prefer
a different solution.

It might be possible, for example, to change the code in xhci_mem_cleanup()
from
for (i = 1; i < MAX_HC_SLOTS; ++i)
xhci_free_virt_device(xhci, i);
to
for (i = MAX_HC_SLOTS - 1; i >= 1; i--)
xhci_free_virt_device(xhci, i);
if it is guaranteed that tt_info never points to a device with higher slot
number.

 drivers/usb/host/xhci-mem.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 6afe32381209..97a61c57a2ed 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -873,8 +873,14 @@ static void xhci_free_tt_info(struct xhci_hcd *xhci,
list_for_each_entry_safe(tt_info, next, tt_list_head, tt_list) {
/* Multi-TT hubs will have more than one entry */
if (tt_info->slot_id == slot_id) {
+   int i;
+
slot_found = true;
list_del(_info->tt_list);
+   for (i = 0; i < MAX_HC_SLOTS; i++)
+   if (xhci->devs[i] &&
+   xhci->devs[i]->tt_info == tt_info)
+   xhci->devs[i]->tt_info = NULL;
kfree(tt_info);
} else if (slot_found) {
break;
-- 
2.5.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


[PATCH] add DWR-158 in usb option

2016-11-15 Thread Giuseppe Lippolis
Signed-off-by: Giuseppe Lippolis 
---
Adding support for 3G modem DWR-158 from Dlink (I found it embedded in the
DWR-512).
---

--- drivers/usb/serial/option.c.orig2016-11-15 21:05:16.987504020 +0100
+++ drivers/usb/serial/option.c 2016-11-15 21:08:27.722378924 +0100
@@ -306,6 +306,9 @@ static void option_instat_callback(struc
 #define DLINK_PRODUCT_DWM_652_U5   0xce16
 #define DLINK_PRODUCT_DWM_652_U5A  0xce1e
 
+#define DLINK_ATL_VENDOR_ID0x2001
+#define DLINK_PRODUCT_DWM_158  0x7d04
+
 #define QISDA_VENDOR_ID0x1da5
 #define QISDA_PRODUCT_H21_4512 0x4512
 #define QISDA_PRODUCT_H21_4523 0x4523
@@ -1812,6 +1815,7 @@ static const struct usb_device_id option
{ USB_DEVICE(DLINK_VENDOR_ID, DLINK_PRODUCT_DWM_652) },
{ USB_DEVICE(ALINK_VENDOR_ID, DLINK_PRODUCT_DWM_652_U5) }, /* Yes,
ALINK_VENDOR_ID */
{ USB_DEVICE(ALINK_VENDOR_ID, DLINK_PRODUCT_DWM_652_U5A) },
+   { USB_DEVICE(DLINK_ATL_VENDOR_ID, DLINK_PRODUCT_DWM_158) },
{ USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4512) },
{ USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4523) },
{ USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H20_4515) },

--
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 v2] usb: dwc2: add amcc,dwc-otg support

2016-11-15 Thread John Youn
From: Christian Lamparter 

This patch adds support for the "amcc,usb-otg" device
which is found in the PowerPC Canyonlands' dts.

The device definition was added by:

commit c89b3458d8cc ("powerpc/44x: Add USB DWC DTS entry to Canyonlands
board")

but without any driver support as the dwc2 driver wasn't available at
that time.

Note: The system can't use the generic "snps,dwc2" compatible
because of the special ahbcfg configuration. The default
GAHBCFG_HBSTLEN_INCR4 of snps,dwc2 can cause a system hang
when the USB and SATA is used concurrently.

Signed-off-by: Christian Lamparter 
Signed-off-by: John Youn 
---

v2 [johnyoun]:
* Removed params struct
* Minor commit message formatting

 Documentation/devicetree/bindings/usb/dwc2.txt | 1 +
 drivers/usb/dwc2/params.c  | 1 +
 2 files changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/dwc2.txt 
b/Documentation/devicetree/bindings/usb/dwc2.txt
index ad8f7ff..6c7c2bce 100644
--- a/Documentation/devicetree/bindings/usb/dwc2.txt
+++ b/Documentation/devicetree/bindings/usb/dwc2.txt
@@ -12,6 +12,7 @@ Required properties:
   - "lantiq,xrx200-usb": The DWC2 USB controller instance in Lantiq XRX 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;
   - snps,dwc2: A generic DWC2 USB controller with default parameters.
 - reg : Should contain 1 register range (address and length)
 - interrupts : Should contain 1 interrupt
diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c
index 513556a..7991c21 100644
--- a/drivers/usb/dwc2/params.c
+++ b/drivers/usb/dwc2/params.c
@@ -239,6 +239,7 @@ const struct of_device_id dwc2_of_match_table[] = {
{ .compatible = "samsung,s3c6400-hsotg", .data = NULL},
{ .compatible = "amlogic,meson8b-usb", .data = _amlogic },
{ .compatible = "amlogic,meson-gxbb-usb", .data = _amlogic },
+   { .compatible = "amcc,dwc-otg", .data = _amcc_dwc_otg },
{},
 };
 MODULE_DEVICE_TABLE(of, dwc2_of_match_table);
-- 
2.10.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 stops working if a malfunctioning USB device is connected

2016-11-15 Thread Alan Stern
On Tue, 15 Nov 2016, Greg KH wrote:

> On Wed, Nov 16, 2016 at 12:12:53AM +0530, PrasannaKumar Muralidharan wrote:
> > >> scripts/kconfig/conf  --silentoldconfig Kconfig
> > >>   CHK include/config/kernel.release
> > >> Cannot use CONFIG_CC_STACKPROTECTOR_STRONG: -fstack-protector-strong
> > >> not supported by compiler
> > >> make: *** [prepare-compiler-check] Error 1
> > >> make: *** Waiting for unfinished jobs
> > >
> > > So turn off CONFIG_CC_STACKPROTECTOR_STRONG or upgrade your C compiler.
> > 
> > I turned off CONFIG_CC_STACKPROTECTOR_STRONG and got the following error
> > ***
> >   HOSTCC  scripts/basic/fixdep
> >   HOSTCC  scripts/basic/bin2c
> >   HOSTCC  arch/x86/tools/relocs_32.o
> >   HOSTCC  arch/x86/tools/relocs_64.o
> >   HOSTCC  arch/x86/tools/relocs_common.o
> >   HOSTLD  arch/x86/tools/relocs
> >   CHK include/config/kernel.release
> >   CHK include/generated/uapi/linux/version.h
> >   CHK include/generated/utsrelease.h
> >   CC  arch/x86/purgatory/purgatory.o
> >   AS  arch/x86/purgatory/stack.o
> >   AS  arch/x86/purgatory/setup-x86_64.o
> >   CC  arch/x86/purgatory/sha256.o
> >   AS  arch/x86/purgatory/entry64.o
> >   CC  arch/x86/purgatory/string.o
> >   LD  arch/x86/purgatory/purgatory.ro
> >   BIN2C   arch/x86/purgatory/kexec-purgatory.c
> >   CHK include/generated/timeconst.h
> >   CC  kernel/bounds.s
> > kernel/bounds.c:1:0: error: code model kernel does not support PIC mode
> >  /*
> > 
> > make[1]: *** [kernel/bounds.s] Error 1
> > make: *** [prepare0] Error 2
> > ***
> > 
> > Using gcc 6.2 to compile kernel. gcc works with
> > -fstack-protector-strong for a simple test c code. I doubt compiler is
> > the problem. Should I make some change to make kernel compile with gcc
> > 6.2? Thank you for your quick response.
> 
> This is Ubuntu, right?  Build a 64bit kernel and you should be fine,
> right now Canonical is shipping a version of gcc that doesn't want to
> build the kernel.  There's a patch floating around, go bug the Canonical
> developers to get it upstream please...
> 
> If not, I don't know, sorry.

Alternatively, you can try running a 4.8.7 or 4.8.8 kernel, if
Canonical supplies them.  They contain the patches that fix the bugs in
rtsx_usb.

Alan Stern

--
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: add usb option device

2016-11-15 Thread 'Greg KH'
On Tue, Nov 15, 2016 at 08:46:31PM +0100, Giuseppe Lippolis wrote:
> Here it is:
> 
> --- a/linux-4.4.23/drivers/usb/serial/option.c2016-09-30
> 10:20:43.0 +0200
> +++ b/linux-4.4.30/drivers/usb/serial/option.c   2016-11-14
> 21:01:15.738450136 +0100
> @@ -306,6 +306,9 @@ static void option_instat_callback(struc
>  #define DLINK_PRODUCT_DWM_652_U5   0xce16
>  #define DLINK_PRODUCT_DWM_652_U5A  0xce1e
> 
> +#define DLINK_ATL_VENDOR_ID0x2001
> +#define DLINK_PRODUCT_DWM_158  0x7d04
> +

Your email client ate the tabs and spit out spaces and line-wrapped the
patch, making it impossible to apply.

Also, you need to make it against the latest kernel tree, 4.4 is really
old.

And finally, there is no good subject: line, or description of the
patch, or a signed-off-by: line, all of which are described in the
document I pointed you at.

Please fix this up and resend.

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


AW: add usb option device

2016-11-15 Thread Giuseppe Lippolis
Here it is:

--- a/linux-4.4.23/drivers/usb/serial/option.c2016-09-30
10:20:43.0 +0200
+++ b/linux-4.4.30/drivers/usb/serial/option.c   2016-11-14
21:01:15.738450136 +0100
@@ -306,6 +306,9 @@ static void option_instat_callback(struc
 #define DLINK_PRODUCT_DWM_652_U5   0xce16
 #define DLINK_PRODUCT_DWM_652_U5A  0xce1e

+#define DLINK_ATL_VENDOR_ID0x2001
+#define DLINK_PRODUCT_DWM_158  0x7d04
+
 #define QISDA_VENDOR_ID0x1da5
 #define QISDA_PRODUCT_H21_4512 0x4512
 #define QISDA_PRODUCT_H21_4523 0x4523
@@ -1812,6 +1815,8 @@ static const struct usb_device_id option
{ USB_DEVICE(DLINK_VENDOR_ID, DLINK_PRODUCT_DWM_652) },
{ USB_DEVICE(ALINK_VENDOR_ID, DLINK_PRODUCT_DWM_652_U5) }, /* Yes,
ALINK_VENDOR_ID */
{ USB_DEVICE(ALINK_VENDOR_ID, DLINK_PRODUCT_DWM_652_U5A) },
+   { USB_DEVICE(DLINK_ATL_VENDOR_ID, DLINK_PRODUCT_DWM_158) },
+
{ USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4512) },
{ USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4523) },
{ USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H20_4515) },


bye

> -Ursprüngliche Nachricht-
> Von: Greg KH [mailto:gre...@linuxfoundation.org]
> Gesendet: Dienstag, 15. November 2016 20:19
> An: Giuseppe Lippolis 
> Cc: linux-usb@vger.kernel.org
> Betreff: Re: add usb option device
> 
> On Tue, Nov 15, 2016 at 08:13:56PM +0100, Giuseppe Lippolis wrote:
> > Dear all,
> > I'm porting the Dlink DWR-512 device to LEDE (embedded linux).
> > This device embed a 3G modem connected through the usb bus .
> > The modem work properly with the option kernel module.
> >
> > I added these line in the
> >
> > #define DLINK_PRODUCT_DWM_652  0x3e04
> > #define DLINK_PRODUCT_DWM_652_U5  0xce16
> > #define DLINK_PRODUCT_DWM_652_U5A   0xce1e
> >
> > +   #define DLINK_ATL_VENDOR_ID 0x2001
> > +   #define DLINK_PRODUCT_DWM_158  0x7d04
> >
> > #define QISDA_VENDOR_ID 0x1da5
> > #define QISDA_PRODUCT_H21_4512  0x4512
> >
> > [...]
> >
> > { USB_DEVICE(ALINK_VENDOR_ID, DLINK_PRODUCT_DWM_652_U5) },
> /*
> > Yes, ALINK_VENDOR_ID */
> > { USB_DEVICE(ALINK_VENDOR_ID, DLINK_PRODUCT_DWM_652_U5A)
> },
> > + { USB_DEVICE(DLINK_ATL_VENDOR_ID, DLINK_PRODUCT_DWM_158)
> },
> > { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4512) },
> > { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4523) },
> 
> Great, can you provide a patch for this in a format that we can apply it
in?
> The file, Documentation/SubmittingPatches will show you what you need to
> do.  If you have any questions after reading that, please let us know.
> 
> 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 0/3] usb: dwc2: params revert and rework

2016-11-15 Thread John Youn
On 11/15/2016 3:33 AM, Felipe Balbi wrote:
> 
> Hi,
> 
> John Youn  writes:
>> Hi Felipe,
>>
>> This reverts and fixes a few commits that are queued on your
>> testing/next, removing the previously added DT bindings, and the code
>> that reads them in.
>>
>> The feedback was that IP validation is not reason enough to add these.
>> So we'll leave them out for now.
> 
> these are still in testing/next, so I can actually still drop
> them. I'm applying only patch 3/3, please make sure it all looks good on
> testing/next.
> 

Ok thanks. There were merge issues when I did that locally so I
figured I'd give you the reverts.

Checked and looks good.

Regards,
John
--
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 v4 2/3] usb: dwc3: Implement interrupt moderation

2016-11-15 Thread John Youn
On 11/15/2016 3:16 AM, Felipe Balbi wrote:
> 
> Hi,
> 
> John Youn  writes:
>> Implement interrupt moderation which allows the interrupt rate to be
>> throttled. To enable this feature the dwc->imod_interval must be set to
>> 1 or greater. This value specifies the minimum inter-interrupt interval,
>> in 250 ns increments. A value of 0 disables interrupt moderation.
>>
>> This applies for DWC_usb3 version 3.00a and higher and for DWC_usb31
>> version 1.20a and higher.
>>
>> Signed-off-by: John Youn 
>> ---
>>  drivers/usb/dwc3/core.c   | 16 
>>  drivers/usb/dwc3/core.h   | 15 +++
>>  drivers/usb/dwc3/gadget.c | 16 
>>  3 files changed, 47 insertions(+)
>>
>> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
>> index 87d0cfb..889dbab 100644
>> --- a/drivers/usb/dwc3/core.c
>> +++ b/drivers/usb/dwc3/core.c
>> @@ -982,12 +982,28 @@ static void dwc3_get_properties(struct dwc3 *dwc)
>>  dwc->hird_threshold = hird_threshold
>>  | (dwc->is_utmi_l1_suspend << 4);
>>  
>> +dwc->imod_interval = 0;
>> +}
>> +
>> +/* check whether the core supports IMOD */
>> +bool dwc3_has_imod(struct dwc3 *dwc)
>> +{
>> +return ((dwc3_is_usb3(dwc) &&
>> + dwc->revision >= DWC3_REVISION_300A) ||
>> +(dwc3_is_usb31(dwc) &&
>> + dwc->revision >= DWC3_USB31_REVISION_120A));
>>  }
>>  
>>  static void dwc3_check_params(struct dwc3 *dwc)
>>  {
>>  struct device *dev = dwc->dev;
>>  
>> +/* Check for proper value of imod_interval */
>> +if (dwc->imod_interval && !dwc3_has_imod(dwc)) {
>> +dev_warn(dwc->dev, "Interrupt moderation not supported\n");
>> +dwc->imod_interval = 0;
>> +}
>> +
>>  /* Check the maximum_speed parameter */
>>  switch (dwc->maximum_speed) {
>>  case USB_SPEED_LOW:
>> diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
>> index bf63756..ef81fa5 100644
>> --- a/drivers/usb/dwc3/core.h
>> +++ b/drivers/usb/dwc3/core.h
>> @@ -67,6 +67,7 @@
>>  #define DWC3_DEVICE_EVENT_OVERFLOW  11
>>  
>>  #define DWC3_GEVNTCOUNT_MASK0xfffc
>> +#define DWC3_GEVNTCOUNT_EHB (1 << 31)
>>  #define DWC3_GSNPSID_MASK   0x
>>  #define DWC3_GSNPSREV_MASK  0x
>>  
>> @@ -149,6 +150,8 @@
>>  #define DWC3_DEPCMDPAR0 0x08
>>  #define DWC3_DEPCMD 0x0c
>>  
>> +#define DWC3_DEV_IMOD(n)(0xca00 + (n * 0x4))
>> +
>>  /* OTG Registers */
>>  #define DWC3_OCFG   0xcc00
>>  #define DWC3_OCTL   0xcc04
>> @@ -465,6 +468,11 @@
>>  #define DWC3_DEPCMD_TYPE_BULK   2
>>  #define DWC3_DEPCMD_TYPE_INTR   3
>>  
>> +#define DWC3_DEV_IMOD_COUNT_SHIFT   16
>> +#define DWC3_DEV_IMOD_COUNT_MASK(0x << 16)
>> +#define DWC3_DEV_IMOD_INTERVAL_SHIFT0
>> +#define DWC3_DEV_IMOD_INTERVAL_MASK (0x << 0)
>> +
>>  /* Structures */
>>  
>>  struct dwc3_trb;
>> @@ -846,6 +854,8 @@ struct dwc3_scratchpad_array {
>>   *  1   - -3.5dB de-emphasis
>>   *  2   - No de-emphasis
>>   *  3   - Reserved
>> + * @imod_interval: set the interrupt moderation interval in 250ns
>> + * increments or 0 to disable.
>>   */
>>  struct dwc3 {
>>  struct usb_ctrlrequest  *ctrl_req;
>> @@ -933,6 +943,7 @@ struct dwc3 {
>>   */
>>  #define DWC3_REVISION_IS_DWC31  0x8000
>>  #define DWC3_USB31_REVISION_110A(0x3131302a | DWC3_REVISION_IS_DWC31)
>> +#define DWC3_USB31_REVISION_120A(0x3132302a | DWC3_REVISION_IS_DWC31)
>>  
>>  enum dwc3_ep0_next  ep0_next_event;
>>  enum dwc3_ep0_state ep0state;
>> @@ -991,6 +1002,8 @@ struct dwc3 {
>>  
>>  unsignedtx_de_emphasis_quirk:1;
>>  unsignedtx_de_emphasis:2;
>> +
>> +u16 imod_interval;
>>  };
>>  
>>  /* 
>> -- */
>> @@ -1162,6 +1175,8 @@ static inline bool dwc3_is_usb31(struct dwc3 *dwc)
>>  return !!(dwc->revision & DWC3_REVISION_IS_DWC31);
>>  }
>>  
>> +bool dwc3_has_imod(struct dwc3 *dwc);
>> +
>>  #if IS_ENABLED(CONFIG_USB_DWC3_HOST) || 
>> IS_ENABLED(CONFIG_USB_DWC3_DUAL_ROLE)
>>  int dwc3_host_init(struct dwc3 *dwc);
>>  void dwc3_host_exit(struct dwc3 *dwc);
>> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
>> index baa2c64..0973167 100644
>> --- a/drivers/usb/dwc3/gadget.c
>> +++ b/drivers/usb/dwc3/gadget.c
>> @@ -1685,6 +1685,17 @@ static int __dwc3_gadget_start(struct dwc3 *dwc)
>>  int ret = 0;
>>  u32 reg;
>>  
>> +/*
>> + * Use IMOD if enabled via dwc->imod_interval. Otherwise, if
>> + * the core supports IMOD, disable it.
>> + */
>> +if (dwc->imod_interval) {
>> +dwc3_writel(dwc->regs, DWC3_DEV_IMOD(0), dwc->imod_interval);
>> +dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), DWC3_GEVNTCOUNT_EHB);
> 
> is 

Re: add usb option device

2016-11-15 Thread Greg KH
On Tue, Nov 15, 2016 at 08:13:56PM +0100, Giuseppe Lippolis wrote:
> Dear all,
> I'm porting the Dlink DWR-512 device to LEDE (embedded linux).
> This device embed a 3G modem connected through the usb bus .
> The modem work properly with the option kernel module.
> 
> I added these line in the 
> 
>   #define DLINK_PRODUCT_DWM_652  0x3e04
>   #define DLINK_PRODUCT_DWM_652_U5  0xce16
>   #define DLINK_PRODUCT_DWM_652_U5A   0xce1e
> 
> + #define DLINK_ATL_VENDOR_ID 0x2001
> + #define DLINK_PRODUCT_DWM_158  0x7d04
> 
>   #define QISDA_VENDOR_ID 0x1da5
>   #define QISDA_PRODUCT_H21_4512  0x4512
> 
> [...]
> 
> { USB_DEVICE(ALINK_VENDOR_ID, DLINK_PRODUCT_DWM_652_U5) }, /* Yes,
> ALINK_VENDOR_ID */
> { USB_DEVICE(ALINK_VENDOR_ID, DLINK_PRODUCT_DWM_652_U5A) },
> + { USB_DEVICE(DLINK_ATL_VENDOR_ID, DLINK_PRODUCT_DWM_158) },
> { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4512) },
> { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4523) },

Great, can you provide a patch for this in a format that we can apply it
in?  The file, Documentation/SubmittingPatches will show you what you
need to do.  If you have any questions after reading that, please let us
know.

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 1/2] usb: dwc2: add amcc,dwc-otg support

2016-11-15 Thread John Youn
On 11/14/2016 3:00 PM, John Youn wrote:
> On 11/11/2016 3:12 PM, Christian Lamparter wrote:
>> On Friday, November 11, 2016 2:20:42 PM CET John Youn wrote:
>>> On 11/11/2016 2:05 PM, Christian Lamparter wrote:
 On Friday, November 11, 2016 1:22:16 PM CET John Youn wrote:
> On 11/11/2016 12:59 PM, Christian Lamparter wrote:
>> This patch adds support for the "amcc,usb-otg" device
>> which is found in the PowerPC Canyonlands' dts.
>>
>> The device definition was added by:
>> commit c89b3458d8cc ("powerpc/44x: Add USB DWC DTS entry to Canyonlands 
>> board")'
>> but without any driver support as the dwc2 driver wasn't
>> available at that time.
>>
>> Note: The system can't use the generic "snps,dwc2" compatible
>> because of the special ahbcfg configuration. The default
>> GAHBCFG_HBSTLEN_INCR4 of snps,dwc2 can cause a system hang
>> when the USB and SATA is used concurrently.
>
> I don't want to add any more of these param structures to the driver
> unless really necessary. We're trying to remove usage of them in favor
> of using auto-detected defaults and device properties to override
> them.
 Ok, thanks. I think that would work. I've attached an updated patch.
 Can it be applied/queued now? Or do you want me to resent it later?

> The AHB Burst is actually one of the ones we were going to do next
> because our platform also doesn't work well with INCR4. In fact I'm
> thinking of making the default INCR.
 Is that actually possible to change the default still? This would
 require to re-evaluate all existing archs/platforms that use 
 "snps,dwc2" for INCR16 compatibility. 
>>>
>>> INCR, not INCR16, but you're right, so we may not change it even
>>> though though INCR is usually the right choice over INCR4.
>> What about making a device-tree property?
> 
> Yes, that's what I meant. I'll send a change for this shortly.
> 
>>
>> Recommended properties:
>>  - g-ahb-bursts : specifies the ahb bursts length, should be one of
>>"single", "INCRx", "INCR4", "INCR8", or "INCR16". If not specified
>>the safer but inefficient "INCR4" is used. The optimal setting is
>>"INCRx".
>>
>> Would this work? If so, I can make a patch over the weekend.
>>> Anyways, with the binding, can't you just set the compatible string to
>>> snps,dwc2?
>>
>> Ah, let me explain. I had a discussion with Mark Rutland and Rob Herring
>> a while back about device-tree bindings.
>>
>> They made it very clear to me, that they don't want any generic "catch all
>> compatible" strings:
>>
>> "Bindings should be for hardware (either specific device models, or for
>> classes), and not for Linux drivers. The latter is subject to arbitrary
>> changes while the former is not, as old hardware continues to exist and
>> does not change while drivers get completely reworked." [0]
>>
>> Furthermore, this is an existing binding in kernel's canyonlands.dts [1]
>> and this binding can't be easily changed. Rob Herring explained this in
>> the context of the "basic-mmio-gpio" patch [2] when I was editing the dts
>> to make them work with the changes I made:
>>
>> "You can't remove the old drivers as they are needed to work with 
>> old dtbs, so there is no gain.
>>
>> You would need to match on existing compatibles such as
>> moxa,moxart-gpio and provide a match data struct that has all the info
>> you are adding here (e.g. data register offset). Then additionally you
>> could add "basic-mmio-gpio" (I would drop "basic" part) and the
>> additional data associated with it. But it has to be new properties,
>> not changing properties. Changing the reg values doesn't work."
>>
>> So, for this to work with the existing canyonlands.dts, I need to have
>> the "amcc,dwc-otg" compatible string.
> 
> Ok, if that's the case. But still a bit confused as to what driver was
> working with it before since the binding was not defined for dwc2.
> 
>>
>> Of course, it would be great to hear from Rob Herring and/or Mark Rutland
>> about this case.
>>
>> Regards,
>> Christian
>>
>> [0] 
>> [1] 
>> 
>> [2] 
>>
>>  

 From what I can tell based would be:
 bcm11351, bcm21664, bcm23550, exynos3250, stm32f429, rk3xxx,
 stratix10, meson-gxbb, rt3050 and some Altera FPGAs.

> If that's all you need then a devicetree binding should be enough
> right?
 Yes. The device is working fine so far.

 Regards,
 Christian

 ---
 From 70dd4be016b89655a56bc8260f04683b50f07644 Mon Sep 17 00:00:00 2001
 From: Christian Lamparter 
 Date: Sun, 6 Nov 2016 00:39:24 +0100
 Subject: [PATCH] usb: dwc2: add amcc,dwc-otg support

 This patch adds support for the "amcc,usb-otg" device
 which is found in the PowerPC 

add usb option device

2016-11-15 Thread Giuseppe Lippolis
Dear all,
I'm porting the Dlink DWR-512 device to LEDE (embedded linux).
This device embed a 3G modem connected through the usb bus .
The modem work properly with the option kernel module.

I added these line in the 

#define DLINK_PRODUCT_DWM_652  0x3e04
#define DLINK_PRODUCT_DWM_652_U5  0xce16
#define DLINK_PRODUCT_DWM_652_U5A   0xce1e

+   #define DLINK_ATL_VENDOR_ID 0x2001
+   #define DLINK_PRODUCT_DWM_158  0x7d04

#define QISDA_VENDOR_ID 0x1da5
#define QISDA_PRODUCT_H21_4512  0x4512

[...]

{ USB_DEVICE(ALINK_VENDOR_ID, DLINK_PRODUCT_DWM_652_U5) }, /* Yes,
ALINK_VENDOR_ID */
{ USB_DEVICE(ALINK_VENDOR_ID, DLINK_PRODUCT_DWM_652_U5A) },
+ { USB_DEVICE(DLINK_ATL_VENDOR_ID, DLINK_PRODUCT_DWM_158) },
{ USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4512) },
{ USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4523) },

And at the end the system work as expected:

[   11.659320] usbcore: registered new interface driver usbserial
[   11.671412] usbcore: registered new interface driver usbserial_generic
[   11.684835] usbserial: USB Serial support registered for generic
[   11.739752] xt_time: kernel timezone is -
[   11.865508] PPP generic driver version 2.4.2
[   11.880069] NET: Registered protocol family 24
[   11.919594] usbcore: registered new interface driver option
[   11.931155] usbserial: USB Serial support registered for GSM modem
(1-port)
[   11.945724] option 1-1:1.0: no of_node; not parsing pinctrl DT
[   11.946566] option 1-1:1.0: GSM modem (1-port) converter detected
[   11.959201] option1 ttyUSB0: no of_node; not parsing pinctrl DT
[   11.959661] option 1-1:1.1: no of_node; not parsing pinctrl DT
[   11.960472] option 1-1:1.1: GSM modem (1-port) converter detected
[   11.973103] option1 ttyUSB1: no of_node; not parsing pinctrl DT
[   11.973542] option 1-1:1.2: no of_node; not parsing pinctrl DT
[   11.974347] option 1-1:1.2: GSM modem (1-port) converter detected
[   11.986980] option1 ttyUSB2: no of_node; not parsing pinctrl DT
[   11.987462] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB2
[   12.001470] option 1-1:1.3: no of_node; not parsing pinctrl DT
[   12.002354] option 1-1:1.3: GSM modem (1-port) converter detected
[   12.015005] option1 ttyUSB3: no of_node; not parsing pinctrl DT
[   12.015479] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB3
[   12.029487] option 1-1:1.4: no of_node; not parsing pinctrl DT
[   12.030327] option 1-1:1.4: GSM modem (1-port) converter detected
[   12.042978] option1 ttyUSB4: no of_node; not parsing pinctrl DT
[   12.043463] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB4
[   12.057468] option 1-1:1.5: no of_node; not parsing pinctrl DT
[   12.058395] option 1-1:1.5: GSM modem (1-port) converter detected
[   12.070971] option1 ttyUSB5: no of_node; not parsing pinctrl DT
[   12.071482] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB5
[   12.085484] option 1-1:1.6: no of_node; not parsing pinctrl DT


Here the relevant lsusb info:

Bus 001 Device 002: ID 2001:7d04 D-Link Corp. 
Device Descriptor:
  bLength18
  bDescriptorType 1
  bcdUSB   2.00
  bDeviceClass2 Communications
  bDeviceSubClass 0 
  bDeviceProtocol 0 
  bMaxPacketSize064
  idVendor   0x2001 D-Link Corp.
  idProduct  0x7d04 
  bcdDevice3.00
  iManufacturer  10 D-Link,Inc  
  iProduct   11 D-Link DWM-158
  iSerial 0 
  bNumConfigurations  1
  Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength  229
bNumInterfaces  7
bConfigurationValue 1
iConfiguration  0 
bmAttributes 0xa0
  (Bus Powered)
  Remote Wakeup
MaxPower  500mA
Interface Association:
  bLength 8
  bDescriptorType11
  bFirstInterface 0
  bInterfaceCount 2
  bFunctionClass  2 Communications
  bFunctionSubClass   6 Ethernet Networking
  bFunctionProtocol   0 
  iFunction   2 COM(comm_if)
Interface Descriptor:
  bLength 9
  bDescriptorType 4
  bInterfaceNumber0
  bAlternateSetting   0
  bNumEndpoints   1
  bInterfaceClass 2 Communications
  bInterfaceSubClass  6 Ethernet Networking
  bInterfaceProtocol  0 
  iInterface  2 COM(comm_if)
  CDC Header:
bcdCDC   1.10
  CDC Union:
bMasterInterface0
bSlaveInterface 1 
  CDC Ethernet:
iMacAddress  1 0200FFAA
bmEthernetStatistics0x7f18
wMaxSegmentSize  

Re: USB stops working if a malfunctioning USB device is connected

2016-11-15 Thread Greg KH
On Wed, Nov 16, 2016 at 12:12:53AM +0530, PrasannaKumar Muralidharan wrote:
> >> scripts/kconfig/conf  --silentoldconfig Kconfig
> >>   CHK include/config/kernel.release
> >> Cannot use CONFIG_CC_STACKPROTECTOR_STRONG: -fstack-protector-strong
> >> not supported by compiler
> >> make: *** [prepare-compiler-check] Error 1
> >> make: *** Waiting for unfinished jobs
> >
> > So turn off CONFIG_CC_STACKPROTECTOR_STRONG or upgrade your C compiler.
> 
> I turned off CONFIG_CC_STACKPROTECTOR_STRONG and got the following error
> ***
>   HOSTCC  scripts/basic/fixdep
>   HOSTCC  scripts/basic/bin2c
>   HOSTCC  arch/x86/tools/relocs_32.o
>   HOSTCC  arch/x86/tools/relocs_64.o
>   HOSTCC  arch/x86/tools/relocs_common.o
>   HOSTLD  arch/x86/tools/relocs
>   CHK include/config/kernel.release
>   CHK include/generated/uapi/linux/version.h
>   CHK include/generated/utsrelease.h
>   CC  arch/x86/purgatory/purgatory.o
>   AS  arch/x86/purgatory/stack.o
>   AS  arch/x86/purgatory/setup-x86_64.o
>   CC  arch/x86/purgatory/sha256.o
>   AS  arch/x86/purgatory/entry64.o
>   CC  arch/x86/purgatory/string.o
>   LD  arch/x86/purgatory/purgatory.ro
>   BIN2C   arch/x86/purgatory/kexec-purgatory.c
>   CHK include/generated/timeconst.h
>   CC  kernel/bounds.s
> kernel/bounds.c:1:0: error: code model kernel does not support PIC mode
>  /*
> 
> make[1]: *** [kernel/bounds.s] Error 1
> make: *** [prepare0] Error 2
> ***
> 
> Using gcc 6.2 to compile kernel. gcc works with
> -fstack-protector-strong for a simple test c code. I doubt compiler is
> the problem. Should I make some change to make kernel compile with gcc
> 6.2? Thank you for your quick response.

This is Ubuntu, right?  Build a 64bit kernel and you should be fine,
right now Canonical is shipping a version of gcc that doesn't want to
build the kernel.  There's a patch floating around, go bug the Canonical
developers to get it upstream please...

If not, I don't know, sorry.

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: Issue with Telit LE922 and cdc_mbim

2016-11-15 Thread Bjørn Mork
Daniele Palmas  writes:

> The problem is in cdc_ncm, function cdc_ncm_bind_common, line
>
> usleep_range(1, 2);
>
> It seems that LE922 needs an higher timeout; changing the line to
>
> usleep_range(7, 8);
>
> makes the modem to work fine.

Extremely interesting!  As you probably noticed, that delay was recently
added as a workaround for the same problem on Sierra Wireless EM7455
modems.  I believe these are based on the Qualcomm MDM9230.  Which
chipset is the LE922 based on?  Is it also one of the newer Qualcom
chips?


> I will submit a patch for this.

Thanks. It would also be great if you could trigger some investigation
into the actual firmware issue.  It looks like the firmware returns
control to the driver before it's actually ready at this point of
initialisation.




Bjørn
--
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 stops working if a malfunctioning USB device is connected

2016-11-15 Thread PrasannaKumar Muralidharan
>> scripts/kconfig/conf  --silentoldconfig Kconfig
>>   CHK include/config/kernel.release
>> Cannot use CONFIG_CC_STACKPROTECTOR_STRONG: -fstack-protector-strong
>> not supported by compiler
>> make: *** [prepare-compiler-check] Error 1
>> make: *** Waiting for unfinished jobs
>
> So turn off CONFIG_CC_STACKPROTECTOR_STRONG or upgrade your C compiler.

I turned off CONFIG_CC_STACKPROTECTOR_STRONG and got the following error
***
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/basic/bin2c
  HOSTCC  arch/x86/tools/relocs_32.o
  HOSTCC  arch/x86/tools/relocs_64.o
  HOSTCC  arch/x86/tools/relocs_common.o
  HOSTLD  arch/x86/tools/relocs
  CHK include/config/kernel.release
  CHK include/generated/uapi/linux/version.h
  CHK include/generated/utsrelease.h
  CC  arch/x86/purgatory/purgatory.o
  AS  arch/x86/purgatory/stack.o
  AS  arch/x86/purgatory/setup-x86_64.o
  CC  arch/x86/purgatory/sha256.o
  AS  arch/x86/purgatory/entry64.o
  CC  arch/x86/purgatory/string.o
  LD  arch/x86/purgatory/purgatory.ro
  BIN2C   arch/x86/purgatory/kexec-purgatory.c
  CHK include/generated/timeconst.h
  CC  kernel/bounds.s
kernel/bounds.c:1:0: error: code model kernel does not support PIC mode
 /*

make[1]: *** [kernel/bounds.s] Error 1
make: *** [prepare0] Error 2
***

Using gcc 6.2 to compile kernel. gcc works with
-fstack-protector-strong for a simple test c code. I doubt compiler is
the problem. Should I make some change to make kernel compile with gcc
6.2? Thank you for your quick response.

Thanks,
PrasannaKumar
--
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 15/15] net: usb: lan78xx: Utilize phy_ethtool_nway_reset

2016-11-15 Thread Woojung.Huh
> Signed-off-by: Florian Fainelli 
> ---
>  drivers/net/usb/lan78xx.c | 7 +--
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
> index bcd9010c1f27..cf2857fa938f 100644
> --- a/drivers/net/usb/lan78xx.c
> +++ b/drivers/net/usb/lan78xx.c
> @@ -1447,11 +1447,6 @@ static u32 lan78xx_get_link(struct net_device *net)
>   return net->phydev->link;
>  }
> 
> -static int lan78xx_nway_reset(struct net_device *net)
> -{
> - return phy_start_aneg(net->phydev);
> -}
> -
>  static void lan78xx_get_drvinfo(struct net_device *net,
>   struct ethtool_drvinfo *info)
>  {
> @@ -1655,7 +1650,7 @@ static int lan78xx_set_pause(struct net_device
> *net,
> 
>  static const struct ethtool_ops lan78xx_ethtool_ops = {
>   .get_link   = lan78xx_get_link,
> - .nway_reset = lan78xx_nway_reset,
> + .nway_reset = phy_ethtool_nway_reset,
>   .get_drvinfo= lan78xx_get_drvinfo,
>   .get_msglevel   = lan78xx_get_msglevel,
>   .set_msglevel   = lan78xx_set_msglevel,
> --
> 2.9.3
Acked-by: Woojung Huh 
--
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 14/15] net: usb: ax88172x: Utilize phy_ethtool_nway_reset

2016-11-15 Thread Florian Fainelli
Signed-off-by: Florian Fainelli 
---
 drivers/net/usb/ax88172a.c | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/net/usb/ax88172a.c b/drivers/net/usb/ax88172a.c
index 49a3bc107d05..6308386b09df 100644
--- a/drivers/net/usb/ax88172a.c
+++ b/drivers/net/usb/ax88172a.c
@@ -149,14 +149,6 @@ static const struct net_device_ops ax88172a_netdev_ops = {
.ndo_set_rx_mode= asix_set_multicast,
 };
 
-static int ax88172a_nway_reset(struct net_device *net)
-{
-   if (!net->phydev)
-   return -ENODEV;
-
-   return phy_start_aneg(net->phydev);
-}
-
 static const struct ethtool_ops ax88172a_ethtool_ops = {
.get_drvinfo= asix_get_drvinfo,
.get_link   = usbnet_get_link,
@@ -167,7 +159,7 @@ static const struct ethtool_ops ax88172a_ethtool_ops = {
.get_eeprom_len = asix_get_eeprom_len,
.get_eeprom = asix_get_eeprom,
.set_eeprom = asix_set_eeprom,
-   .nway_reset = ax88172a_nway_reset,
+   .nway_reset = phy_ethtool_nway_reset,
.get_link_ksettings = phy_ethtool_get_link_ksettings,
.set_link_ksettings = phy_ethtool_set_link_ksettings,
 };
-- 
2.9.3

--
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 15/15] net: usb: lan78xx: Utilize phy_ethtool_nway_reset

2016-11-15 Thread Florian Fainelli
Signed-off-by: Florian Fainelli 
---
 drivers/net/usb/lan78xx.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index bcd9010c1f27..cf2857fa938f 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -1447,11 +1447,6 @@ static u32 lan78xx_get_link(struct net_device *net)
return net->phydev->link;
 }
 
-static int lan78xx_nway_reset(struct net_device *net)
-{
-   return phy_start_aneg(net->phydev);
-}
-
 static void lan78xx_get_drvinfo(struct net_device *net,
struct ethtool_drvinfo *info)
 {
@@ -1655,7 +1650,7 @@ static int lan78xx_set_pause(struct net_device *net,
 
 static const struct ethtool_ops lan78xx_ethtool_ops = {
.get_link   = lan78xx_get_link,
-   .nway_reset = lan78xx_nway_reset,
+   .nway_reset = phy_ethtool_nway_reset,
.get_drvinfo= lan78xx_get_drvinfo,
.get_msglevel   = lan78xx_get_msglevel,
.set_msglevel   = lan78xx_set_msglevel,
-- 
2.9.3

--
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 stops working if a malfunctioning USB device is connected

2016-11-15 Thread Alan Stern
On Tue, 15 Nov 2016, PrasannaKumar Muralidharan wrote:

> I am getting the following error when I compile 4.9-rc5:
> ***
> scripts/kconfig/conf  --silentoldconfig Kconfig
>   CHK include/config/kernel.release
> Cannot use CONFIG_CC_STACKPROTECTOR_STRONG: -fstack-protector-strong
> not supported by compiler
> make: *** [prepare-compiler-check] Error 1
> make: *** Waiting for unfinished jobs

So turn off CONFIG_CC_STACKPROTECTOR_STRONG or upgrade your C compiler.

Alan Stern

--
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 v6 1/2] usb: musb: da8xx: Call earlier clk_prepare_enable()

2016-11-15 Thread Alexandre Bailon
The first attempt to read a register may fail because the clock may not
be enabled, and then the probe of musb driver will fail.
Call clk_prepare_enable() before the first register read.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/da8xx.c | 17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index 2440f88..4fc226c 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -366,6 +366,12 @@ static int da8xx_musb_init(struct musb *musb)
 
musb->mregs += DA8XX_MENTOR_CORE_OFFSET;
 
+   ret = clk_prepare_enable(glue->clk);
+   if (ret) {
+   dev_err(glue->dev, "failed to enable clock\n");
+   return ret;
+   }
+
/* Returns zero if e.g. not clocked */
rev = musb_readl(reg_base, DA8XX_USB_REVISION_REG);
if (!rev)
@@ -377,12 +383,6 @@ static int da8xx_musb_init(struct musb *musb)
goto fail;
}
 
-   ret = clk_prepare_enable(glue->clk);
-   if (ret) {
-   dev_err(glue->dev, "failed to enable clock\n");
-   goto fail;
-   }
-
setup_timer(_workaround, otg_timer, (unsigned long)musb);
 
/* Reset the controller */
@@ -392,7 +392,7 @@ static int da8xx_musb_init(struct musb *musb)
ret = phy_init(glue->phy);
if (ret) {
dev_err(glue->dev, "Failed to init phy.\n");
-   goto err_phy_init;
+   goto fail;
}
 
ret = phy_power_on(glue->phy);
@@ -412,9 +412,8 @@ static int da8xx_musb_init(struct musb *musb)
 
 err_phy_power_on:
phy_exit(glue->phy);
-err_phy_init:
-   clk_disable_unprepare(glue->clk);
 fail:
+   clk_disable_unprepare(glue->clk);
return ret;
 }
 
-- 
2.7.3

--
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 v6 2/2] usb: musb: da8xx: Set phy in OTG mode by default

2016-11-15 Thread Alexandre Bailon
The DA8xx OTG PHY has some issues when it is forced in host or
peripheral mode. Actually, most of the time, OTG is the best mode
because host or peripheral mode are only required for hardware that
miss some circuitry.
Init the PHY mode OTG mode by default.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/da8xx.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index 4fc226c..e0dbe14 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -340,6 +340,13 @@ static int da8xx_musb_set_mode(struct musb *musb, u8 
musb_mode)
struct da8xx_glue *glue = dev_get_drvdata(musb->controller->parent);
enum phy_mode phy_mode;
 
+   /*
+* The PHY has some issues when it is forced in device or host mode.
+* Unless the user request another mode, configure the PHY in OTG mode.
+*/
+   if (!musb->is_initialized)
+   return phy_set_mode(glue->phy, PHY_MODE_USB_OTG);
+
switch (musb_mode) {
case MUSB_HOST: /* Force VBUS valid, ID = 0 */
phy_mode = PHY_MODE_USB_HOST;
-- 
2.7.3

--
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 v6 0/2] usb: musb: da8xx: Fix few issues

2016-11-15 Thread Alexandre Bailon
This series require the following patch to build:
[PATCH 1/6] usb: musb: Fix broken use of static variable for multiple instances

Currently, the USB OTG of the da8xx doesn't work.
This series intend to fix them.

Change in v2:
* Fix the error path da8xx_musb_init()

Changes in v3:
* Remove the host workaround that was not working on every platform
* Add a property to the devicetree node of phy to force the phy in a specific
  mode (host or device).
* Only use dr_mode to configure the controller mode and let the phy in OTG mode.
  The main goal of this change is to prevent the phy to be set in host or
  device mode because these modes have some issues.

Changes in v4:
* Enable VBUS sense and session end comparator during probe of phy.
* Add a quirk flag to skip the phy set mode made during the init of musb.
  In that way, we can still can configure the phy mode by using mode file in
  sysfs and configure the controller mode by using dr_mode or platform_data.
* Init the phy in otg mode in da8xx glue driver.

Changes in v5:
* Add the init argument to musb_platform_set_mode() and set_mode() callback.
* Remove the quirk
* Configure the DA8xx phy in OTG mode if da8xx_musb_set_mode() is called from
  init.

Changes in v6:
* Remove the patch that was adding a new parametter to musb_platform_set_mode().
  Instead, use the variable is_initialized.
* The patch fixing the phy has been merged to phy-next, so I removed it from
  this series.

Alexandre Bailon (2):
  usb: musb: da8xx: Call earlier clk_prepare_enable()
  usb: musb: da8xx: Set phy in OTG mode by default

 drivers/usb/musb/da8xx.c | 24 +++-
 1 file changed, 15 insertions(+), 9 deletions(-)

-- 
2.7.3

--
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 stops working if a malfunctioning USB device is connected

2016-11-15 Thread Alan Stern
On Tue, 15 Nov 2016, PrasannaKumar Muralidharan wrote:

> Hi,
> 
> My android device does not work sometime when I connect it to my
> computer. It works sometime, it does not work sometime. If the device
> fails to respond to USB requests then any other USB device that I
> connect is not detected.
> 
> dmesg snippet when I connect the malfunctioning USB device:
> 
> [19850.041339] perf: interrupt took too long (5112 > 4980), lowering
> kernel.perf_event_max_sample_rate to 39000
> [36269.864918] usb 1-4: reset high-speed USB device number 2 using xhci_hcd
> [36275.241134] usb 1-4: device descriptor read/64, error -110
> [36290.858096] usb 1-4: device descriptor read/64, error -110
> [36291.086110] usb 1-4: reset high-speed USB device number 2 using xhci_hcd
> [36296.490381] usb 1-4: device descriptor read/64, error -110
> [36312.107320] usb 1-4: device descriptor read/64, error -110
> [36312.335345] usb 1-4: reset high-speed USB device number 2 using xhci_hcd
> [36317.515675] xhci_hcd :00:14.0: Timeout while waiting for setup
> device command
> [36322.891955] xhci_hcd :00:14.0: Timeout while waiting for setup
> device command
> [36323.099938] usb 1-4: device not accepting address 2, error -62
> [36323.219932] usb 1-4: reset high-speed USB device number 2 using xhci_hcd
> [36328.375162] usb 1-4: device descriptor read/8, error -110
> [36333.751509] usb 1-4: device descriptor read/8, error -110
> [36333.856628] usb 1-4: USB disconnect, device number 2
> [36494.422106] INFO: task rtsx_usb_ms_1:1033 blocked for more than 120 
> seconds.
> [36494.422110]   Not tainted 4.8.0-27-generic #29-Ubuntu
> [36494.422111] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs"
> disables this message.
> [36494.422113] rtsx_usb_ms_1   D a05d10ba3d18 0  1033  2 
> 0x
> [36494.422116]  a05d10ba3d18 00ffa05b12674c00 a05d15340e40
> a05d10f1aac0
> [36494.422119]  a05d10ba3d00 a05d10ba4000 9b8e7710
> a05d10ba3da0
> [36494.422121]   0258 a05d10ba3d30
> 9b29a855
> [36494.422123] Call Trace:
> [36494.422128]  [] schedule+0x35/0x80
> [36494.422131]  [] usb_kill_urb+0x98/0xd0
> [36494.422134]  [] ? wake_atomic_t_function+0x60/0x60
> [36494.422136]  [] usb_start_wait_urb+0xe5/0x170
> [36494.422138]  [] usb_bulk_msg+0xbd/0x160
> [36494.422143]  [] rtsx_usb_send_cmd+0x63/0x90 [rtsx_usb]
> [36494.422145]  [] rtsx_usb_read_register+0x6c/0xc0 
> [rtsx_usb]
> [36494.422147]  []
> rtsx_usb_detect_ms_card+0x74/0x100 [rtsx_usb_ms]
> [36494.422149]  [] ?
> rtsx_usb_ms_set_param+0x780/0x780 [rtsx_usb_ms]

There's a known bug in the rtsx_usb drivers in the 4.8 kernel.  Try
running a 4.9-rc kernel and see if it helps.

Alan Stern

> [36494.422151]  [] kthread+0xd8/0xf0
> [36494.422153]  [] ret_from_fork+0x1f/0x40
> [36494.422155]  [] ? kthread_create_on_node+0x1e0/0x1e0
> 
> 
> Would be glad to provide any more info if required.
> 
> Thanks,
> PrasannaKumar

--
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] dwc3: make PM functions as __maybe_unused

2016-11-15 Thread Arnd Bergmann
A change to the suspend/resume handling in dwc3-pci introduced a
harmless warning:

drivers/usb/dwc3/dwc3-pci.c:169:12: error: ‘dwc3_pci_dsm’ defined but not used 
[-Werror=unused-function]

Replacing the #ifdef around the PM functions with __maybe_unused
annotations is the easiest way to make sure this doesn't happen
again. A similar problem happened two months earlier and we
ended up updating the #ifdef, but as it has come back now,
I'd suggest going back to my earlier approach.

Fixes: 9cecca75b5a0 ("usb: dwc3: pci: call _DSM for suspend/resume")
Link: https://patchwork.kernel.org/patch/9318887/
Signed-off-by: Arnd Bergmann 
---
 drivers/usb/dwc3/dwc3-pci.c | 12 
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
index 8c39ec6522fd..771b620b4878 100644
--- a/drivers/usb/dwc3/dwc3-pci.c
+++ b/drivers/usb/dwc3/dwc3-pci.c
@@ -293,8 +293,7 @@ static const struct pci_device_id dwc3_pci_id_table[] = {
 };
 MODULE_DEVICE_TABLE(pci, dwc3_pci_id_table);
 
-#ifdef CONFIG_PM
-static int dwc3_pci_runtime_suspend(struct device *dev)
+static int __maybe_unused dwc3_pci_runtime_suspend(struct device *dev)
 {
struct dwc3_pci *dwc = dev_get_drvdata(dev);
 
@@ -304,7 +303,7 @@ static int dwc3_pci_runtime_suspend(struct device *dev)
return -EBUSY;
 }
 
-static int dwc3_pci_runtime_resume(struct device *dev)
+static int __maybe_unused dwc3_pci_runtime_resume(struct device *dev)
 {
struct dwc3_pci *dwc = dev_get_drvdata(dev);
struct platform_device  *dwc3 = dwc->dwc3;
@@ -316,23 +315,20 @@ static int dwc3_pci_runtime_resume(struct device *dev)
 
return pm_runtime_get(>dev);
 }
-#endif /* CONFIG_PM */
 
-#ifdef CONFIG_PM_SLEEP
-static int dwc3_pci_suspend(struct device *dev)
+static int __maybe_unused dwc3_pci_suspend(struct device *dev)
 {
struct dwc3_pci *dwc = dev_get_drvdata(dev);
 
return dwc3_pci_dsm(dwc, PCI_INTEL_BXT_STATE_D3);
 }
 
-static int dwc3_pci_resume(struct device *dev)
+static int __maybe_unused dwc3_pci_resume(struct device *dev)
 {
struct dwc3_pci *dwc = dev_get_drvdata(dev);
 
return dwc3_pci_dsm(dwc, PCI_INTEL_BXT_STATE_D0);
 }
-#endif /* CONFIG_PM_SLEEP */
 
 static struct dev_pm_ops dwc3_pci_dev_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(dwc3_pci_suspend, dwc3_pci_resume)
-- 
2.9.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: [PATCH] phy: twl4030-usb: make driver DT only

2016-11-15 Thread Tony Lindgren
* Nicolae Rosia  [161115 05:26]:
> Hi,
> 
> On Tue, Nov 15, 2016 at 3:20 PM, Kishon Vijay Abraham I  wrote:
> > Are you sure about this? I still see a bunch of board files in mach-omap2 
> > using
> > twl4030.
> >
> > Thanks
> > Kishon
> 
> You are right, on v4.9 it is still used in arch/arm/mach-omap2/twl-common.c.
> I forgot to mention that I'm targeting v4.10 with this. On Tony's
> for-next [0], there are no users:
> git grep twl4030_usb_data
> drivers/phy/phy-twl4030-usb.c:  struct twl4030_usb_data *pdata =
> dev_get_platdata(>dev);
> drivers/usb/phy/phy-twl6030-usb.c:  struct twl4030_usb_data *pdata
> = dev_get_platdata(dev);
> include/linux/i2c/twl.h:struct twl4030_usb_data {
> include/linux/i2c/twl.h:struct twl4030_usb_data *usb;

Yeah might be worht waiting on the omap3 specific driver changes until
v4.11 merge window unless the changes are blocking twl core clean up work.

Regards,

Tony

> [0] 
> https://git.kernel.org/cgit/linux/kernel/git/tmlind/linux-omap.git/log/?h=for-next
--
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


USB stops working if a malfunctioning USB device is connected

2016-11-15 Thread PrasannaKumar Muralidharan
Hi,

My android device does not work sometime when I connect it to my
computer. It works sometime, it does not work sometime. If the device
fails to respond to USB requests then any other USB device that I
connect is not detected.

dmesg snippet when I connect the malfunctioning USB device:

[19850.041339] perf: interrupt took too long (5112 > 4980), lowering
kernel.perf_event_max_sample_rate to 39000
[36269.864918] usb 1-4: reset high-speed USB device number 2 using xhci_hcd
[36275.241134] usb 1-4: device descriptor read/64, error -110
[36290.858096] usb 1-4: device descriptor read/64, error -110
[36291.086110] usb 1-4: reset high-speed USB device number 2 using xhci_hcd
[36296.490381] usb 1-4: device descriptor read/64, error -110
[36312.107320] usb 1-4: device descriptor read/64, error -110
[36312.335345] usb 1-4: reset high-speed USB device number 2 using xhci_hcd
[36317.515675] xhci_hcd :00:14.0: Timeout while waiting for setup
device command
[36322.891955] xhci_hcd :00:14.0: Timeout while waiting for setup
device command
[36323.099938] usb 1-4: device not accepting address 2, error -62
[36323.219932] usb 1-4: reset high-speed USB device number 2 using xhci_hcd
[36328.375162] usb 1-4: device descriptor read/8, error -110
[36333.751509] usb 1-4: device descriptor read/8, error -110
[36333.856628] usb 1-4: USB disconnect, device number 2
[36494.422106] INFO: task rtsx_usb_ms_1:1033 blocked for more than 120 seconds.
[36494.422110]   Not tainted 4.8.0-27-generic #29-Ubuntu
[36494.422111] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs"
disables this message.
[36494.422113] rtsx_usb_ms_1   D a05d10ba3d18 0  1033  2 0x
[36494.422116]  a05d10ba3d18 00ffa05b12674c00 a05d15340e40
a05d10f1aac0
[36494.422119]  a05d10ba3d00 a05d10ba4000 9b8e7710
a05d10ba3da0
[36494.422121]   0258 a05d10ba3d30
9b29a855
[36494.422123] Call Trace:
[36494.422128]  [] schedule+0x35/0x80
[36494.422131]  [] usb_kill_urb+0x98/0xd0
[36494.422134]  [] ? wake_atomic_t_function+0x60/0x60
[36494.422136]  [] usb_start_wait_urb+0xe5/0x170
[36494.422138]  [] usb_bulk_msg+0xbd/0x160
[36494.422143]  [] rtsx_usb_send_cmd+0x63/0x90 [rtsx_usb]
[36494.422145]  [] rtsx_usb_read_register+0x6c/0xc0 [rtsx_usb]
[36494.422147]  []
rtsx_usb_detect_ms_card+0x74/0x100 [rtsx_usb_ms]
[36494.422149]  [] ?
rtsx_usb_ms_set_param+0x780/0x780 [rtsx_usb_ms]
[36494.422151]  [] kthread+0xd8/0xf0
[36494.422153]  [] ret_from_fork+0x1f/0x40
[36494.422155]  [] ? kthread_create_on_node+0x1e0/0x1e0


Would be glad to provide any more info if required.

Thanks,
PrasannaKumar
--
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: Issue with Telit LE922 and cdc_mbim

2016-11-15 Thread Daniele Palmas
Hi,

2016-11-14 14:51 GMT+01:00 Daniele Palmas :
> Hi,
>
> I'm struggling with Telit LE922 modem that presents an MBIM device.
> The modem works fine in Windows, while in Linux (tested with 4.9 rc1)
> data connection is not functional: using ifconfig I can see
>
> wwp0s20u8i2 Link encap:Ethernet  HWaddr e6:c0:3b:97:80:de
>   inet addr:176.246.94.9  Bcast:176.246.94.11  Mask:255.255.255.252
>   UP BROADCAST RUNNING NOARP MULTICAST  MTU:1500  Metric:1
>   RX packets:0 errors:0 dropped:0 overruns:0 frame:0
>   TX packets:1 errors:15 dropped:0 overruns:0 carrier:0
>   collisions:0 txqueuelen:1000
>   RX bytes:0 (0.0 B)  TX bytes:40 (40.0 B)
>
> so the issue seems to be in tx.
>
> I'm using an USB hw sniffer for trying to understand the problem; this
> is an example of a NCM packet with Windows 10 driver:
>
> 4E 43 4D 48 0C 00 0B 02 48 00 38 00 45 00 00 28
> 78 E8 40 00 80 06 63 68 05 5C 7A E5 D8 3A C6 03
> E9 08 01 BB FB 36 F0 EA C6 8C D8 CB 50 10 80 00
> 9B 16 00 00 00 00 00 00 49 50 53 00 10 00 00 00
> 0C 00 28 00 00 00 00 00
>
> 16 bit NTB, with NDP at the end. So I enabled CDC_NCM_FLAG_NDP_TO_END,
> but still the device is not properly working.
>
> This is the first properly transmitted acked packet in Linux:
>
> 4E 43 4D 48 0C 00 00 00 80 00 34 00 46 C0 00 28
> 00 00 40 00 01 02 F4 F9 B0 F6 5E 09 E0 00 00 16
> 94 04 00 00 22 00 F9 02 00 00 00 01 04 00 00 00
> E0 00 00 FB 49 50 53 00 10 00 00 00 0C 00 28 00
> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>
> that looks like quite similar than the Windows one (besides the final 
> padding).
>
> Then all the following out packets are nacked, e.g:
>
> 4E 43 4D 48 0C 00 01 00 D8 00 8C 00 45 00 00 3E
> 05 71 40 00 40 11 0C E8 B0 F6 5E 09 0A 85 0E D2
> B3 30 00 35 00 2A D3 57 58 6A 01 00 00 01 00 00
> 00 00 00 00 05 64 61 69 73 79 06 75 62 75 6E 74
> 75 03 63 6F 6D 00 00 01 00 01 00 00 45 00 00 3E
> 2A EC 40 00 40 11 91 8A B0 F6 5E 09 0A 84 64 B5
> B3 30 00 35 00 2A 7D 75 58 6A 01 00 00 01 00 00
> 00 00 00 00 05 64 61 69 73 79 06 75 62 75 6E 74
> 75 03 63 6F 6D 00 00 01 00 01 00 00 49 50 53 00
> 14 00 00 00 0C 00 3E 00 4C 00 3E 00 00 00 00 00
> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> 00 00 00 00 00 00 00 00
>
> Those packets look good to me: the main difference with Windows is the
> presence of more than one datagram, but, as far as I understand, this
> should not be a problem since the modem reports:
>
> dwNtbInMaxSize=16384 dwNtbOutMaxSize=16384 wNdpOutPayloadRemainder=0
> wNdpOutDivisor=4 wNdpOutAlignment=4 wNtbOutMaxDatagrams=16 flags=0x20
>
> while in Windows it seems that always only one datagram is sent.
>
> My thought is that the problem is in the modem firmware: in some way,
> the first acked packet is breaking things inside the modem that is not
> able to receive packets anymore, but maybe there is some other
> problems in the tx packets created by the driver and I'm not able to
> catch it.
>

I was wrong, the problem is not with the first packet.

The problem is in cdc_ncm, function cdc_ncm_bind_common, line

usleep_range(1, 2);

It seems that LE922 needs an higher timeout; changing the line to

usleep_range(7, 8);

makes the modem to work fine.

I will submit a patch for this.

Regards,
Daniele

> Does someone have an hint about this?
>
> Is there a way to configure the cdc_mbim driver in order to have
> exactly the same packet format sent in Windows?
>
> USB traces taken with TotalPhase Datacenter are available at
>
> https://drive.google.com/open?id=0B1kPnH2g8ISIZWJiV05qeWN5dVE
>
> Thanks,
> Daniele
--
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 v5] phy: rcar-gen3-usb2: add sysfs for usb role swap

2016-11-15 Thread Kishon Vijay Abraham I


On Wednesday 09 November 2016 08:00 AM, Yoshihiro Shimoda wrote:
> This patch adds sysfs "role" for usb role swap. This parameter can be
> read and write. If you use this file as the following, you can swap
> the usb role.
> 
> For example:
>  1) Connect a usb cable using 2 Salvator-x boards
>  2) On A-Device (ID pin is low), you input the following command:
># echo peripheral > /sys/devices/platform/soc/ee080200.usb-phy/role
>  3) On B-Device (ID pin is high), you input the following command:
># echo host > /sys/devices/platform/soc/ee080200.usb-phy/role
> 
> Then, the A-device acts as a peripheral and the B-device acts as a host.
> Please note that A-Device must input the following command if you
> want the board to act as a host again. (even if you disconnect the usb
> cable, since id state may be the same, the A-Device keeps to act as
> peripheral.)
>  # echo host > /sys/devices/platform/soc/ee080200.usb-phy/role
> 
> Signed-off-by: Yoshihiro Shimoda 
> Reviewed-by: Peter Chen 

merged to phy -next.

Thanks
Kishon
> ---
>  This patch is based on the latest linux-phy.git / next branch.
>  (commit id = 7809cd2ce6abd4f431e4b14e6b1276a7cc842ac4)
> 
>  Since this patch is related to usb, I added email addresses of Greg, Felipe,
>  Peter and USB ML as CC. (This patch doesn't use USB OTG FSM though.)
> 
>  Changes from v4:
>   - Use if-else about the is_b_device check in role_store().
>   - Add "Reviewed-by: Peter Chen "
> 
>  Changes from v3:
>   - Clean up redundant conditions in role_store().
> 
>  Changes from v2:
>   - Modify the sysfs file name to "role", and the argument is "host" or
> "peripheral". Peter suggested this. Thank you!
> 
>  Changes from v1:
>   - rebase the latest next branch.
> 
>  .../ABI/testing/sysfs-platform-phy-rcar-gen3-usb2  |  15 +++
>  drivers/phy/phy-rcar-gen3-usb2.c   | 118 
> -
>  2 files changed, 132 insertions(+), 1 deletion(-)
>  create mode 100644 
> Documentation/ABI/testing/sysfs-platform-phy-rcar-gen3-usb2
> 
> diff --git a/Documentation/ABI/testing/sysfs-platform-phy-rcar-gen3-usb2 
> b/Documentation/ABI/testing/sysfs-platform-phy-rcar-gen3-usb2
> new file mode 100644
> index 000..6212697
> --- /dev/null
> +++ b/Documentation/ABI/testing/sysfs-platform-phy-rcar-gen3-usb2
> @@ -0,0 +1,15 @@
> +What:/sys/devices/platform//role
> +Date:October 2016
> +KernelVersion:   4.10
> +Contact: Yoshihiro Shimoda 
> +Description:
> + This file can be read and write.
> + The file can show/change the phy mode for role swap of usb.
> +
> + Write the following strings to change the mode:
> +  "host" - switching mode from peripheral to host.
> +  "peripheral" - switching mode from host to peripheral.
> +
> + Read the file, then it shows the following strings:
> +  "host" - The mode is host now.
> +  "peripheral" - The mode is peripheral now.
> diff --git a/drivers/phy/phy-rcar-gen3-usb2.c 
> b/drivers/phy/phy-rcar-gen3-usb2.c
> index 3d97ead..c63da1b 100644
> --- a/drivers/phy/phy-rcar-gen3-usb2.c
> +++ b/drivers/phy/phy-rcar-gen3-usb2.c
> @@ -70,6 +70,7 @@
>  #define USB2_LINECTRL1_DP_RPDBIT(18)
>  #define USB2_LINECTRL1_DMRPD_EN  BIT(17)
>  #define USB2_LINECTRL1_DM_RPDBIT(16)
> +#define USB2_LINECTRL1_OPMODE_NODRV  BIT(6)
>  
>  /* ADPCTRL */
>  #define USB2_ADPCTRL_OTGSESSVLD  BIT(20)
> @@ -161,6 +162,43 @@ static void rcar_gen3_init_for_peri(struct 
> rcar_gen3_chan *ch)
>   schedule_work(>work);
>  }
>  
> +static void rcar_gen3_init_for_b_host(struct rcar_gen3_chan *ch)
> +{
> + void __iomem *usb2_base = ch->base;
> + u32 val;
> +
> + val = readl(usb2_base + USB2_LINECTRL1);
> + writel(val | USB2_LINECTRL1_OPMODE_NODRV, usb2_base + USB2_LINECTRL1);
> +
> + rcar_gen3_set_linectrl(ch, 1, 1);
> + rcar_gen3_set_host_mode(ch, 1);
> + rcar_gen3_enable_vbus_ctrl(ch, 0);
> +
> + val = readl(usb2_base + USB2_LINECTRL1);
> + writel(val & ~USB2_LINECTRL1_OPMODE_NODRV, usb2_base + USB2_LINECTRL1);
> +}
> +
> +static void rcar_gen3_init_for_a_peri(struct rcar_gen3_chan *ch)
> +{
> + rcar_gen3_set_linectrl(ch, 0, 1);
> + rcar_gen3_set_host_mode(ch, 0);
> + rcar_gen3_enable_vbus_ctrl(ch, 1);
> +}
> +
> +static void rcar_gen3_init_from_a_peri_to_a_host(struct rcar_gen3_chan *ch)
> +{
> + void __iomem *usb2_base = ch->base;
> + u32 val;
> +
> + val = readl(usb2_base + USB2_OBINTEN);
> + writel(val & ~USB2_OBINT_BITS, usb2_base + USB2_OBINTEN);
> +
> + rcar_gen3_enable_vbus_ctrl(ch, 0);
> + rcar_gen3_init_for_host(ch);
> +
> + writel(val | USB2_OBINT_BITS, usb2_base + USB2_OBINTEN);
> +}
> +
>  static bool rcar_gen3_check_id(struct rcar_gen3_chan *ch)
>  {
>   return 

Re: crash by cdc_acm driver in kernels 4.8-rc1/5

2016-11-15 Thread Wim Osterholt
On Tue, Nov 15, 2016 at 12:26:00PM +0100, poma wrote:
> > In the process of searching, many options may have changed. The crash/OOPS
> > has now mitigated into just a WARNING with a call trace.
> > (Or it could be a totally different bug?)
> > 
> > Tests on other machines with (slightly) different configs all seem to
> > confirm that the problems are gone when CONFIG_SMP is set.
> > 
> 
> Try retest with mainline 4.9-rc5,
> CONFIG_SMP was not crucial[1].

I did also test 4.9-rc5 and it behaves like all the rest (since 4.8).
My problem is gone when CONFIG_SMP is set.

That doesn't mean that there are no extra bugs here, dependant on the
presence or absence of other options.

> [1] https://www.spinics.net/lists/linux-usb/msg148852.html

I experience a sliding scale.
With debug it crashes immediately. It may crash later on (even at shutdown
time). It's not even an oops but a warning. In the end it happens to just
work.


Regards, Wim.

--
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] phy: twl4030-usb: make driver DT only

2016-11-15 Thread Nicolae Rosia
Hi,

On Tue, Nov 15, 2016 at 3:20 PM, Kishon Vijay Abraham I  wrote:
> Are you sure about this? I still see a bunch of board files in mach-omap2 
> using
> twl4030.
>
> Thanks
> Kishon

You are right, on v4.9 it is still used in arch/arm/mach-omap2/twl-common.c.
I forgot to mention that I'm targeting v4.10 with this. On Tony's
for-next [0], there are no users:
git grep twl4030_usb_data
drivers/phy/phy-twl4030-usb.c:  struct twl4030_usb_data *pdata =
dev_get_platdata(>dev);
drivers/usb/phy/phy-twl6030-usb.c:  struct twl4030_usb_data *pdata
= dev_get_platdata(dev);
include/linux/i2c/twl.h:struct twl4030_usb_data {
include/linux/i2c/twl.h:struct twl4030_usb_data *usb;

Thanks,
Nicolae

[0] 
https://git.kernel.org/cgit/linux/kernel/git/tmlind/linux-omap.git/log/?h=for-next
--
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] phy: twl4030-usb: make driver DT only

2016-11-15 Thread Kishon Vijay Abraham I
Hi,

On Saturday 12 November 2016 04:09 PM, Nicolae Rosia wrote:
> All users are DT-only and it makes no sense to keep
> unused code

Are you sure about this? I still see a bunch of board files in mach-omap2 using
twl4030.

Thanks
Kishon
> 
> Signed-off-by: Nicolae Rosia 
> ---
>  drivers/phy/Kconfig   |  1 +
>  drivers/phy/phy-twl4030-usb.c | 22 +++---
>  2 files changed, 8 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
> index fe00f91..265391e 100644
> --- a/drivers/phy/Kconfig
> +++ b/drivers/phy/Kconfig
> @@ -196,6 +196,7 @@ config TWL4030_USB
>   depends on TWL4030_CORE && REGULATOR_TWL4030 && USB_MUSB_OMAP2PLUS
>   depends on USB_SUPPORT
>   depends on USB_GADGET || !USB_GADGET # if USB_GADGET=m, this can't 'y'
> + depends on OF
>   select GENERIC_PHY
>   select USB_PHY
>   help
> diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c
> index 87e6334..a5e4927 100644
> --- a/drivers/phy/phy-twl4030-usb.c
> +++ b/drivers/phy/phy-twl4030-usb.c
> @@ -656,7 +656,6 @@ static const struct dev_pm_ops twl4030_usb_pm_ops = {
>  
>  static int twl4030_usb_probe(struct platform_device *pdev)
>  {
> - struct twl4030_usb_data *pdata = dev_get_platdata(>dev);
>   struct twl4030_usb  *twl;
>   struct phy  *phy;
>   int status, err;
> @@ -664,19 +663,17 @@ static int twl4030_usb_probe(struct platform_device 
> *pdev)
>   struct device_node  *np = pdev->dev.of_node;
>   struct phy_provider *phy_provider;
>  
> + if (!np) {
> + dev_err(>dev, "no DT info\n");
> + return -EINVAL;
> + }
> +
>   twl = devm_kzalloc(>dev, sizeof(*twl), GFP_KERNEL);
>   if (!twl)
>   return -ENOMEM;
>  
> - if (np)
> - of_property_read_u32(np, "usb_mode",
> - (enum twl4030_usb_mode *)>usb_mode);
> - else if (pdata) {
> - twl->usb_mode = pdata->usb_mode;
> - } else {
> - dev_err(>dev, "twl4030 initialized without pdata\n");
> - return -EINVAL;
> - }
> + of_property_read_u32(np, "usb_mode",
> + (enum twl4030_usb_mode *)>usb_mode);
>  
>   otg = devm_kzalloc(>dev, sizeof(*otg), GFP_KERNEL);
>   if (!otg)
> @@ -750,11 +747,6 @@ static int twl4030_usb_probe(struct platform_device 
> *pdev)
>   return status;
>   }
>  
> - if (pdata)
> - err = phy_create_lookup(phy, "usb", "musb-hdrc.0");
> - if (err)
> - return err;
> -
>   pm_runtime_mark_last_busy(>dev);
>   pm_runtime_put_autosuspend(twl->dev);
>  
> 
--
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 v5 2/4] phy: da8xx-usb: Configure CFGCHIP2 to support OTG workaround

2016-11-15 Thread Kishon Vijay Abraham I


On Monday 07 November 2016 06:35 PM, Alexandre Bailon wrote:
> If we configure the da8xx OTG phy in OTG mode, neither device or host
> mode will work. That is because the PHY is not able to detect and notify
> the driver that value of ID pin changed.
> To work despite this hardware limitation, the da8xx glue implement a
> workaround.
> But to work, the workaround require the VBUS sense and the session end
> comparator to enabled.
> Enable them if the phy is configured in OTG mode.
> 
> Signed-off-by: Alexandre Bailon 

merged this to phy -next.

Thanks
Kishon
> ---
>  drivers/phy/phy-da8xx-usb.c | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/phy/phy-da8xx-usb.c b/drivers/phy/phy-da8xx-usb.c
> index 32ae78c..089c13b 100644
> --- a/drivers/phy/phy-da8xx-usb.c
> +++ b/drivers/phy/phy-da8xx-usb.c
> @@ -23,6 +23,8 @@
>  #include 
>  #include 
>  
> +#define PHY_INIT_BITS(CFGCHIP2_SESENDEN | CFGCHIP2_VBDTCTEN)
> +
>  struct da8xx_usb_phy {
>   struct phy_provider *phy_provider;
>   struct phy  *usb11_phy;
> @@ -207,6 +209,9 @@ static int da8xx_usb_phy_probe(struct platform_device 
> *pdev)
>   dev_warn(dev, "Failed to create usb20 phy lookup\n");
>   }
>  
> + regmap_write_bits(d_phy->regmap, CFGCHIP(2),
> +   PHY_INIT_BITS, PHY_INIT_BITS);
> +
>   return 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: [PATCH 3/4] usb: dwc3: gadget: use evt->cache for processing events

2016-11-15 Thread Janusz Dziedzic
On 15 November 2016 at 12:23, Felipe Balbi  wrote:
> From: John Youn 
>
> Let's start copying events from evt->buf to
> evt->cache and use evt->cache for processing events.
>
> A follow-up patch will be added to clear events in
> the top-half handler in order to bring IRQ line low
> as soon as possible.
>
> Signed-off-by: John Youn 
> Signed-off-by: Felipe Balbi 
> ---
>  drivers/usb/dwc3/gadget.c | 9 -
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index 304653fd9223..0481cb7d7142 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -2821,7 +2821,7 @@ static irqreturn_t dwc3_process_event_buf(struct 
> dwc3_event_buffer *evt)
> while (left > 0) {
> union dwc3_event event;
>
> -   event.raw = *(u32 *) (evt->buf + evt->lpos);
> +   event.raw = *(u32 *) (evt->cache + evt->lpos);
>
> dwc3_process_event_entry(dwc, );
>
> @@ -2869,6 +2869,7 @@ static irqreturn_t dwc3_thread_interrupt(int irq, void 
> *_evt)
>  static irqreturn_t dwc3_check_event_buf(struct dwc3_event_buffer *evt)
>  {
> struct dwc3 *dwc = evt->dwc;
> +   u32 amount;
> u32 count;
> u32 reg;
>
> @@ -2892,6 +2893,12 @@ static irqreturn_t dwc3_check_event_buf(struct 
> dwc3_event_buffer *evt)
> reg |= DWC3_GEVNTSIZ_INTMASK;
> dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(0), reg);
>
> +   amount = min(count, evt->length - evt->lpos);
> +   memcpy(evt->cache + evt->lpos, evt->buf + evt->lpos, amount);
> +
Why not just:
memcpy(evt->cache, evt->buf + evt->lpos, count)
And always handle evt->cache[0 ... count] in thread_interrupt.

> +   if (amount < count)
> +   memcpy(evt->cache, evt->buf, count - amount);
> +
> return IRQ_WAKE_THREAD;
>  }
>
> --
> 2.10.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
--
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 1/5] cdc-acm: reindent log messages

2016-11-15 Thread Oliver Neukum
On Tue, 2016-11-15 at 12:26 +0100, Ladislav Michl wrote:
> On Tue, Nov 15, 2016 at 11:07:27AM +0100, Greg KH wrote:
> > On Wed, Nov 09, 2016 at 12:53:25PM +0100, Ladislav Michl wrote:
> > > Signed-off-by: Ladislav Michl 
> > > ---
> > >  drivers/usb/class/cdc-acm.c | 35 +--
> > >  1 file changed, 17 insertions(+), 18 deletions(-)
> > 
> > I can't take patches without any changelog text :(
> 
> I'm sorry about that, thought subject is enough in this case.
> 
> > And please cc: Oliver and me if you want us to notice the patches,
> > otherwise they can easily get lost in the noise...
> 
> Will resend. Before that, do you or Oliver have any more
> objec^H^H^H^H^Hsuggestions to this patch serie?

No, go ahead, it looks fine.

Regards
Oliver


--
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: host: xhci: Remove unused 'addr_64' variable in xhci_hcd structure

2016-11-15 Thread Mathias Nyman

On 15.11.2016 10:34, Baolin Wang wrote:

Since the 'addr_64' variable as legacy is unused now, then remove it from
xhci_hcd structure.

Signed-off-by: Baolin Wang 
---



Thanks, I'll add it to the queue
-Mathias  


--
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 0/3] usb: dwc2: params revert and rework

2016-11-15 Thread Felipe Balbi

Hi,

John Youn  writes:
> Hi Felipe,
>
> This reverts and fixes a few commits that are queued on your
> testing/next, removing the previously added DT bindings, and the code
> that reads them in.
>
> The feedback was that IP validation is not reason enough to add these.
> So we'll leave them out for now.

these are still in testing/next, so I can actually still drop
them. I'm applying only patch 3/3, please make sure it all looks good on
testing/next.

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH 1/5] cdc-acm: reindent log messages

2016-11-15 Thread Ladislav Michl
On Tue, Nov 15, 2016 at 11:07:27AM +0100, Greg KH wrote:
> On Wed, Nov 09, 2016 at 12:53:25PM +0100, Ladislav Michl wrote:
> > Signed-off-by: Ladislav Michl 
> > ---
> >  drivers/usb/class/cdc-acm.c | 35 +--
> >  1 file changed, 17 insertions(+), 18 deletions(-)
> 
> I can't take patches without any changelog text :(

I'm sorry about that, thought subject is enough in this case.

> And please cc: Oliver and me if you want us to notice the patches,
> otherwise they can easily get lost in the noise...

Will resend. Before that, do you or Oliver have any more
objec^H^H^H^H^Hsuggestions to this patch serie?

Thank you,
ladis
--
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: crash by cdc_acm driver in kernels 4.8-rc1/5

2016-11-15 Thread poma
On 15.11.2016 01:16, Wim Osterholt wrote:
> On Tue, Oct 18, 2016 at 02:18:43PM +0200, Oliver Neukum wrote:
> 
>> It definitely does not crash and is probed and your .config is not
>> extremely unusual.
> 
> Hmmm.
> 
>> ... Something odd is going on.
> 
> Whell, yes.
> The only thing that appears you'll have to do is unset 'CONFIG_SMP'.
> 
> My machines didn't have the luxury of multicore processors (until recently),
> so there never has been any reason to deliberately switch these options on!
> 
> In the process of searching, many options may have changed. The crash/OOPS
> has now mitigated into just a WARNING with a call trace.
> (Or it could be a totally different bug?)
> After the call trace the device is working normally and a shutdown
> completes to the end now.
> That is with the config given here:
> http://webserver.djo.tudelft.nl/.config-4.9-rc4.OK (CONFIG_SMP=y)
> http://webserver.djo.tudelft.nl/WARNING-4.9-rc4(call trace for C_S unset)
> 
> Tests on other machines with (slightly) different configs all seem to
> confirm that the problems are gone when CONFIG_SMP is set.
> 
> Regards, Wim.
> 
> 

Try retest with mainline 4.9-rc5,
CONFIG_SMP was not crucial[1].

$ grep CONFIG_SMP /boot/config-4.9.0-0.rc5.git0.1.fc26.x86_64*
/boot/config-4.9.0-0.rc5.git0.1.fc26.x86_64:CONFIG_SMP=y
/boot/config-4.9.0-0.rc5.git0.1.fc26.x86_64+debug:CONFIG_SMP=y

[1] https://www.spinics.net/lists/linux-usb/msg148852.html


--
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/4] usb: dwc3: gadget: use evt->cache for processing events

2016-11-15 Thread Felipe Balbi
From: John Youn 

Let's start copying events from evt->buf to
evt->cache and use evt->cache for processing events.

A follow-up patch will be added to clear events in
the top-half handler in order to bring IRQ line low
as soon as possible.

Signed-off-by: John Youn 
Signed-off-by: Felipe Balbi 
---
 drivers/usb/dwc3/gadget.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 304653fd9223..0481cb7d7142 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -2821,7 +2821,7 @@ static irqreturn_t dwc3_process_event_buf(struct 
dwc3_event_buffer *evt)
while (left > 0) {
union dwc3_event event;
 
-   event.raw = *(u32 *) (evt->buf + evt->lpos);
+   event.raw = *(u32 *) (evt->cache + evt->lpos);
 
dwc3_process_event_entry(dwc, );
 
@@ -2869,6 +2869,7 @@ static irqreturn_t dwc3_thread_interrupt(int irq, void 
*_evt)
 static irqreturn_t dwc3_check_event_buf(struct dwc3_event_buffer *evt)
 {
struct dwc3 *dwc = evt->dwc;
+   u32 amount;
u32 count;
u32 reg;
 
@@ -2892,6 +2893,12 @@ static irqreturn_t dwc3_check_event_buf(struct 
dwc3_event_buffer *evt)
reg |= DWC3_GEVNTSIZ_INTMASK;
dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(0), reg);
 
+   amount = min(count, evt->length - evt->lpos);
+   memcpy(evt->cache + evt->lpos, evt->buf + evt->lpos, amount);
+
+   if (amount < count)
+   memcpy(evt->cache, evt->buf, count - amount);
+
return IRQ_WAKE_THREAD;
 }
 
-- 
2.10.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/4] usb: dwc3: core: add a event buffer cache

2016-11-15 Thread Felipe Balbi
From: John Youn 

This extra buffer will be used so we can copy
triggered events from our event buffer to this cache
and process all of them later in bottom half
handler.

We need this in order to implement a workaround for
a known erratum in recent DWC3 release.

Signed-off-by: John Youn 
Signed-off-by: Felipe Balbi 
---
 drivers/usb/dwc3/core.c | 4 
 drivers/usb/dwc3/core.h | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index d024d47c86d1..87d0cfb7b29e 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -224,6 +224,10 @@ static struct dwc3_event_buffer 
*dwc3_alloc_one_event_buffer(struct dwc3 *dwc,
 
evt->dwc= dwc;
evt->length = length;
+   evt->cache  = devm_kzalloc(dwc->dev, length, GFP_KERNEL);
+   if (!evt->cache)
+   return ERR_PTR(-ENOMEM);
+
evt->buf= dma_alloc_coherent(dwc->dev, length,
>dma, GFP_KERNEL);
if (!evt->buf)
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 354de247356a..bf63756bc176 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -472,6 +472,7 @@ struct dwc3_trb;
 /**
  * struct dwc3_event_buffer - Software event buffer representation
  * @buf: _THE_ buffer
+ * @cache: The buffer cache used in the threaded interrupt
  * @length: size of this buffer
  * @lpos: event offset
  * @count: cache of last read event count register
@@ -481,6 +482,7 @@ struct dwc3_trb;
  */
 struct dwc3_event_buffer {
void*buf;
+   void*cache;
unsignedlength;
unsigned intlpos;
unsigned intcount;
-- 
2.10.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 4/4] usb: dwc3: gadget: clear events in top-half handler

2016-11-15 Thread Felipe Balbi
From: John Youn 

Now that all the infrastructure is in place, we can
clear events in the top-half handler in order to
bring IRQ line low ASAP.

This is also a necessary step in order to implement
workaround for known erratum in follow-up patches.

Signed-off-by: John Youn 
Signed-off-by: Felipe Balbi 
---
 drivers/usb/dwc3/gadget.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 0481cb7d7142..3d5ba4106979 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -2836,8 +2836,6 @@ static irqreturn_t dwc3_process_event_buf(struct 
dwc3_event_buffer *evt)
 */
evt->lpos = (evt->lpos + 4) % evt->length;
left -= 4;
-
-   dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 4);
}
 
evt->count = 0;
@@ -2899,6 +2897,8 @@ static irqreturn_t dwc3_check_event_buf(struct 
dwc3_event_buffer *evt)
if (amount < count)
memcpy(evt->cache, evt->buf, count - amount);
 
+   dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), count);
+
return IRQ_WAKE_THREAD;
 }
 
-- 
2.10.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/4] usb: dwc3: gadget: use evt->length as we should

2016-11-15 Thread Felipe Balbi
Instead of always accessing the macro directly,
let's rely on evt->length which is the actual length
of current event buffer. While unlikely, we could
change event buffer's size at any time.

Signed-off-by: Felipe Balbi 
---
 drivers/usb/dwc3/gadget.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 230ffa395dc3..304653fd9223 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -2834,7 +2834,7 @@ static irqreturn_t dwc3_process_event_buf(struct 
dwc3_event_buffer *evt)
 * boundary so I worry about that once we try to handle
 * that.
 */
-   evt->lpos = (evt->lpos + 4) % DWC3_EVENT_BUFFERS_SIZE;
+   evt->lpos = (evt->lpos + 4) % evt->length;
left -= 4;
 
dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 4);
-- 
2.10.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: cdc_acm: debug - BUG - Oops

2016-11-15 Thread poma
On 08.11.2016 10:43, poma wrote:
> 
> Helloo!
> 
> Via Master Chef's debug kernel, the device ist kaputt.
> Can you explain why this is happening specifically with the kernel's debug 
> facility.
> 
> $ uname -r
> 4.9.0-0.rc4.git0.1.fc26.x86_64
> 
> $ file /dev/ttyACM0
> /dev/ttyACM0: character special (166/0)
> 
> $ dmesg -t | grep acm
> cdc_acm 2-3:1.0: ttyACM0: USB ACM device
> usbcore: registered new interface driver cdc_acm
> cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
> 
> 
> 
> $ uname -r
> 4.9.0-0.rc4.git0.1.fc26.x86_64+debug
> 
> $ file /dev/ttyACM0
> /dev/ttyACM0: cannot open `/dev/ttyACM0' (No such file or directory)
> 
> $ dmesg -t
> ...
> BUG: unable to handle kernel NULL pointer dereference at 0249
> IP: [] acm_probe+0x4e1/0x11a0 [cdc_acm]
> PGD 0 
> 
> Oops:  [#1] SMP
> Modules linked in: ... cdc_acm(+) ...
> CPU: 2 PID: 374 Comm: systemd-udevd Not tainted 
> 4.9.0-0.rc4.git0.1.fc26.x86_64+debug #1
> ...
> task: 9ae607c6 task.stack: b93740cdc000
> RIP: 0010:[]  [] acm_probe+0x4e1/0x11a0 
> [cdc_acm]
> RSP: 0018:b93740cdf9c0  EFLAGS: 00010202
> RAX: 0246 RBX: 9ae607732800 RCX: 
> RDX: 0040 RSI: 9ae607c60960 RDI: b93740cdf968
> RBP: b93740cdfae8 R08:  R09: 
> R10:  R11:  R12: 9ae607732800
> R13: 9ae607737000 R14:  R15: 9ae6067fb000
> FS:  7f6daa69c8c0() GS:9ae60f80() knlGS:
> CS:  0010 DS:  ES:  CR0: 80050033
> CR2: 0249 CR3: c7eeb000 CR4: 06e0
> ...
> Call Trace:
>  [] ? sched_clock_cpu+0x90/0xc0
>  [] ? mutex_unlock+0xe/0x10
>  [] ? trace_hardirqs_on_caller+0xf5/0x1b0
>  [] ? trace_hardirqs_on+0xd/0x10
>  [] ? __mutex_unlock_slowpath+0xfa/0x1c0
>  [] usb_probe_interface+0x15f/0x2d0
>  [] driver_probe_device+0x223/0x430
>  [] __driver_attach+0xe3/0xf0
>  [] ? driver_probe_device+0x430/0x430
>  [] bus_for_each_dev+0x73/0xc0
>  [] driver_attach+0x1e/0x20
>  [] bus_add_driver+0x173/0x270
>  [] driver_register+0x60/0xe0
>  [] usb_register_driver+0xaa/0x160
>  [] ? 0xc0462000
>  [] acm_init+0xc2/0x1000 [cdc_acm]
>  [] do_one_initcall+0x50/0x180
>  [] ? rcu_read_lock_sched_held+0x45/0x80
>  [] ? kmem_cache_alloc_trace+0x277/0x2d0
>  [] ? do_init_module+0x27/0x1f1
>  [] do_init_module+0x5f/0x1f1
>  [] load_module+0x2401/0x2b40
>  [] ? __symbol_put+0x70/0x70
>  [] ? sched_clock_cpu+0x90/0xc0
>  [] SYSC_init_module+0x19b/0x1c0
>  [] SyS_init_module+0xe/0x10
>  [] do_syscall_64+0x6c/0x1f0
>  [] entry_SYSCALL64_slow_path+0x25/0x25
> Code: 10 41 89 8f ec 0b 00 00 8d 04 80 c1 e0 02 41 89 87 e0 0b 00 00 48 8b 85 
> 48 ff ff ff 49 89 07 48 8b 85 70 ff ff ff 48 85 c0 74 0b <0f> b6 40 03 41 89 
> 87 f4 0b 00 00 f6 85 50 ff ff ff 04 74 08 41 
> RIP  [] acm_probe+0x4e1/0x11a0 [cdc_acm]
>  RSP 
> CR2: 0249
> ---[ end trace 526abbefa545cbb3 ]---
> 
> 
> 
> $ diff -u /boot/config-4.9.0-0.rc4.git0.1.fc26.x86_64 
> /boot/config-4.9.0-0.rc4.git0.1.fc26.x86_64+debug
> ...
> -# Linux/x86_64 4.9.0-0.rc4.git0.1.fc26.x86_64 Kernel Configuration
> +# Linux/x86_64 4.9.0-0.rc4.git0.1.fc26.x86_64+debug Kernel Configuration
> ...
> -# CONFIG_DEBUG_BLK_CGROUP is not set
> +CONFIG_DEBUG_BLK_CGROUP=y
> ...
> +CONFIG_PERF_USE_VMALLOC=y
> ...
> -# CONFIG_DEBUG_PERF_USE_VMALLOC is not set
> +CONFIG_DEBUG_PERF_USE_VMALLOC=y
> ...
> -# CONFIG_MODULE_FORCE_UNLOAD is not set
> +CONFIG_MODULE_FORCE_UNLOAD=y
> ...
> -CONFIG_INLINE_SPIN_UNLOCK_IRQ=y
> -CONFIG_INLINE_READ_UNLOCK=y
> -CONFIG_INLINE_READ_UNLOCK_IRQ=y
> -CONFIG_INLINE_WRITE_UNLOCK=y
> -CONFIG_INLINE_WRITE_UNLOCK_IRQ=y
> +CONFIG_UNINLINE_SPIN_UNLOCK=y
> -CONFIG_MUTEX_SPIN_ON_OWNER=y
> ...
> +CONFIG_PREEMPT_COUNT=y
> ...
> -# CONFIG_X86_BOOTPARAM_MEMORY_CORRUPTION_CHECK is not set
> +CONFIG_X86_BOOTPARAM_MEMORY_CORRUPTION_CHECK=y
> ...
> -# CONFIG_ACPI_DEBUG is not set
> +CONFIG_ACPI_DEBUG=y
> ...
> -# CONFIG_CAN_DEBUG_DEVICES is not set
> +CONFIG_CAN_DEBUG_DEVICES=y
> ...
> -# CONFIG_MAC80211_MESSAGE_TRACING is not set
> +CONFIG_MAC80211_MESSAGE_TRACING=y
> ...
> -# CONFIG_CEPH_LIB_PRETTYDEBUG is not set
> +CONFIG_CEPH_LIB_PRETTYDEBUG=y
> ...
> -# CONFIG_DRBD_FAULT_INJECTION is not set
> +CONFIG_DRBD_FAULT_INJECTION=y
> ...
> -# CONFIG_ATH_DEBUG is not set
> +CONFIG_ATH_DEBUG=y
> +# CONFIG_ATH_TRACEPOINTS is not set
> ...
> -# CONFIG_CARL9170_DEBUGFS is not set
> +CONFIG_CARL9170_DEBUGFS=y
> ...
> -# CONFIG_IWLWIFI_DEVICE_TRACING is not set
> +CONFIG_IWLWIFI_DEVICE_TRACING=y
> ...
> -# CONFIG_RTLWIFI_DEBUG is not set
> +CONFIG_RTLWIFI_DEBUG=y
> ...
> -# CONFIG_SPI_DEBUG is not set
> +CONFIG_SPI_DEBUG=y
> ...
> -# CONFIG_EDAC_DEBUG is not set
> +CONFIG_EDAC_DEBUG=y
> ...
> -# CONFIG_DMADEVICES_DEBUG is not set
> +CONFIG_DMADEVICES_DEBUG=y
> +# CONFIG_DMADEVICES_VDEBUG is not set
> ...
> -# 

Re: [PATCH v4 2/3] usb: dwc3: Implement interrupt moderation

2016-11-15 Thread Felipe Balbi

Hi,

John Youn  writes:
> Implement interrupt moderation which allows the interrupt rate to be
> throttled. To enable this feature the dwc->imod_interval must be set to
> 1 or greater. This value specifies the minimum inter-interrupt interval,
> in 250 ns increments. A value of 0 disables interrupt moderation.
>
> This applies for DWC_usb3 version 3.00a and higher and for DWC_usb31
> version 1.20a and higher.
>
> Signed-off-by: John Youn 
> ---
>  drivers/usb/dwc3/core.c   | 16 
>  drivers/usb/dwc3/core.h   | 15 +++
>  drivers/usb/dwc3/gadget.c | 16 
>  3 files changed, 47 insertions(+)
>
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index 87d0cfb..889dbab 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -982,12 +982,28 @@ static void dwc3_get_properties(struct dwc3 *dwc)
>   dwc->hird_threshold = hird_threshold
>   | (dwc->is_utmi_l1_suspend << 4);
>  
> + dwc->imod_interval = 0;
> +}
> +
> +/* check whether the core supports IMOD */
> +bool dwc3_has_imod(struct dwc3 *dwc)
> +{
> + return ((dwc3_is_usb3(dwc) &&
> +  dwc->revision >= DWC3_REVISION_300A) ||
> + (dwc3_is_usb31(dwc) &&
> +  dwc->revision >= DWC3_USB31_REVISION_120A));
>  }
>  
>  static void dwc3_check_params(struct dwc3 *dwc)
>  {
>   struct device *dev = dwc->dev;
>  
> + /* Check for proper value of imod_interval */
> + if (dwc->imod_interval && !dwc3_has_imod(dwc)) {
> + dev_warn(dwc->dev, "Interrupt moderation not supported\n");
> + dwc->imod_interval = 0;
> + }
> +
>   /* Check the maximum_speed parameter */
>   switch (dwc->maximum_speed) {
>   case USB_SPEED_LOW:
> diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
> index bf63756..ef81fa5 100644
> --- a/drivers/usb/dwc3/core.h
> +++ b/drivers/usb/dwc3/core.h
> @@ -67,6 +67,7 @@
>  #define DWC3_DEVICE_EVENT_OVERFLOW   11
>  
>  #define DWC3_GEVNTCOUNT_MASK 0xfffc
> +#define DWC3_GEVNTCOUNT_EHB  (1 << 31)
>  #define DWC3_GSNPSID_MASK0x
>  #define DWC3_GSNPSREV_MASK   0x
>  
> @@ -149,6 +150,8 @@
>  #define DWC3_DEPCMDPAR0  0x08
>  #define DWC3_DEPCMD  0x0c
>  
> +#define DWC3_DEV_IMOD(n) (0xca00 + (n * 0x4))
> +
>  /* OTG Registers */
>  #define DWC3_OCFG0xcc00
>  #define DWC3_OCTL0xcc04
> @@ -465,6 +468,11 @@
>  #define DWC3_DEPCMD_TYPE_BULK2
>  #define DWC3_DEPCMD_TYPE_INTR3
>  
> +#define DWC3_DEV_IMOD_COUNT_SHIFT16
> +#define DWC3_DEV_IMOD_COUNT_MASK (0x << 16)
> +#define DWC3_DEV_IMOD_INTERVAL_SHIFT 0
> +#define DWC3_DEV_IMOD_INTERVAL_MASK  (0x << 0)
> +
>  /* Structures */
>  
>  struct dwc3_trb;
> @@ -846,6 +854,8 @@ struct dwc3_scratchpad_array {
>   *   1   - -3.5dB de-emphasis
>   *   2   - No de-emphasis
>   *   3   - Reserved
> + * @imod_interval: set the interrupt moderation interval in 250ns
> + * increments or 0 to disable.
>   */
>  struct dwc3 {
>   struct usb_ctrlrequest  *ctrl_req;
> @@ -933,6 +943,7 @@ struct dwc3 {
>   */
>  #define DWC3_REVISION_IS_DWC31   0x8000
>  #define DWC3_USB31_REVISION_110A (0x3131302a | DWC3_REVISION_IS_DWC31)
> +#define DWC3_USB31_REVISION_120A (0x3132302a | DWC3_REVISION_IS_DWC31)
>  
>   enum dwc3_ep0_next  ep0_next_event;
>   enum dwc3_ep0_state ep0state;
> @@ -991,6 +1002,8 @@ struct dwc3 {
>  
>   unsignedtx_de_emphasis_quirk:1;
>   unsignedtx_de_emphasis:2;
> +
> + u16 imod_interval;
>  };
>  
>  /* 
> -- */
> @@ -1162,6 +1175,8 @@ static inline bool dwc3_is_usb31(struct dwc3 *dwc)
>   return !!(dwc->revision & DWC3_REVISION_IS_DWC31);
>  }
>  
> +bool dwc3_has_imod(struct dwc3 *dwc);
> +
>  #if IS_ENABLED(CONFIG_USB_DWC3_HOST) || IS_ENABLED(CONFIG_USB_DWC3_DUAL_ROLE)
>  int dwc3_host_init(struct dwc3 *dwc);
>  void dwc3_host_exit(struct dwc3 *dwc);
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index baa2c64..0973167 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -1685,6 +1685,17 @@ static int __dwc3_gadget_start(struct dwc3 *dwc)
>   int ret = 0;
>   u32 reg;
>  
> + /*
> +  * Use IMOD if enabled via dwc->imod_interval. Otherwise, if
> +  * the core supports IMOD, disable it.
> +  */
> + if (dwc->imod_interval) {
> + dwc3_writel(dwc->regs, DWC3_DEV_IMOD(0), dwc->imod_interval);
> + dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), DWC3_GEVNTCOUNT_EHB);

is this safe? You're doing this after request_threaded_irq(). Sure, IRQs
are still masked, but couldn't clear events that would get fired as soon
as we 

Re: crash by cdc_acm driver in kernels 4.8-rc1/5

2016-11-15 Thread Oliver Neukum
On Tue, 2016-11-15 at 01:16 +0100, Wim Osterholt wrote:

Hi,

> Whell, yes.
> The only thing that appears you'll have to do is unset 'CONFIG_SMP'.

OK. I haven't tested that, nor would I ever considered it.
 
> My machines didn't have the luxury of multicore processors (until recently),
> so there never has been any reason to deliberately switch these options on!
> 
> In the process of searching, many options may have changed. The crash/OOPS
> has now mitigated into just a WARNING with a call trace.
> (Or it could be a totally different bug?)
> After the call trace the device is working normally and a shutdown
> completes to the end now.
> That is with the config given here:
> http://webserver.djo.tudelft.nl/.config-4.9-rc4.OK (CONFIG_SMP=y)
> http://webserver.djo.tudelft.nl/WARNING-4.9-rc4(call trace for C_S unset)
> 
> Tests on other machines with (slightly) different configs all seem to
> confirm that the problems are gone when CONFIG_SMP is set.

OK, something extremely strange is going on. And I think it is time to get
the big hammer out. I made an extremely stupid debugging patch. Could
you test with it?

Regards
Oliver

From d9c67172611257c262a19e9d3d4d9e6b9a69e88c Mon Sep 17 00:00:00 2001
From: Oliver Neukum 
Date: Tue, 8 Nov 2016 16:12:11 +0100
Subject: [PATCH] acm: insane debugging

extremnely stupid debugging patch

Signed-off-by: Oliver Neukum 
---
 drivers/usb/class/cdc-acm.c | 49 +++--
 1 file changed, 43 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 0f3f62e..a460e46 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1329,68 +1329,103 @@ made_compressed_probe:
 	if (acm == NULL)
 		goto alloc_fail;
 
+printk(KERN_ERR"Check point  1\n");
 	minor = acm_alloc_minor(acm);
 	if (minor < 0)
 		goto alloc_fail1;
-
+printk(KERN_ERR"Check point  2\n");
 	ctrlsize = usb_endpoint_maxp(epctrl);
+printk(KERN_ERR"Check point  3\n");
 	readsize = usb_endpoint_maxp(epread) *
 (quirks == SINGLE_RX_URB ? 1 : 2);
+printk(KERN_ERR"Check point  4\n");
 	acm->combined_interfaces = combined_interfaces;
+printk(KERN_ERR"Check point  5\n");
 	acm->writesize = usb_endpoint_maxp(epwrite) * 20;
+printk(KERN_ERR"Check point  6\n");
 	acm->control = control_interface;
+printk(KERN_ERR"Check point  7\n");
 	acm->data = data_interface;
+printk(KERN_ERR"Check point  8\n");
 	acm->minor = minor;
+printk(KERN_ERR"Check point  9\n");
 	acm->dev = usb_dev;
+printk(KERN_ERR"Check point  10\n");
 	if (h.usb_cdc_acm_descriptor)
 		acm->ctrl_caps = h.usb_cdc_acm_descriptor->bmCapabilities;
+printk(KERN_ERR"Check point  11\n");
 	if (quirks & NO_CAP_LINE)
 		acm->ctrl_caps &= ~USB_CDC_CAP_LINE;
+printk(KERN_ERR"Check point  12\n");
 	acm->ctrlsize = ctrlsize;
+printk(KERN_ERR"Check point  13\n");
 	acm->readsize = readsize;
+printk(KERN_ERR"Check point  14\n");
 	acm->rx_buflimit = num_rx_buf;
+printk(KERN_ERR"Check point  15\n");
 	INIT_WORK(>work, acm_softint);
+printk(KERN_ERR"Check point  16\n");
 	init_waitqueue_head(>wioctl);
+printk(KERN_ERR"Check point  17\n");
 	spin_lock_init(>write_lock);
+printk(KERN_ERR"Check point  18\n");
 	spin_lock_init(>read_lock);
+printk(KERN_ERR"Check point  19\n");
 	mutex_init(>mutex);
+printk(KERN_ERR"Check point  20\n");
 	acm->is_int_ep = usb_endpoint_xfer_int(epread);
+printk(KERN_ERR"Check point  21\n");
 	if (acm->is_int_ep)
 		acm->bInterval = epread->bInterval;
+printk(KERN_ERR"Check point  22\n");
 	tty_port_init(>port);
+printk(KERN_ERR"Check point  23\n");
 	acm->port.ops = _port_ops;
+printk(KERN_ERR"Check point  24\n");
 	init_usb_anchor(>delayed);
+printk(KERN_ERR"Check point  25\n");
 	acm->quirks = quirks;
+printk(KERN_ERR"Check point  26\n");
 
 	buf = usb_alloc_coherent(usb_dev, ctrlsize, GFP_KERNEL, >ctrl_dma);
 	if (!buf)
 		goto alloc_fail2;
 	acm->ctrl_buffer = buf;
+printk(KERN_ERR"Check point  27\n");
 
 	if (acm_write_buffers_alloc(acm) < 0)
 		goto alloc_fail4;
+printk(KERN_ERR"Check point  28\n");
 
 	acm->ctrlurb = usb_alloc_urb(0, GFP_KERNEL);
 	if (!acm->ctrlurb)
 		goto alloc_fail5;
+printk(KERN_ERR"Check point  29\n");
 
 	for (i = 0; i < num_rx_buf; i++) {
 		struct acm_rb *rb = &(acm->read_buffers[i]);
 		struct urb *urb;
+printk(KERN_ERR"Check point  30, buffer %d\n", i);
 
 		rb->base = usb_alloc_coherent(acm->dev, readsize, GFP_KERNEL,
 >dma);
 		if (!rb->base)
 			goto alloc_fail6;
+printk(KERN_ERR"Check point  31, buffer %d\n", i);
 		rb->index = i;
+printk(KERN_ERR"Check point  32, buffer %d\n", i);
 		rb->instance = acm;
+printk(KERN_ERR"Check point  33, buffer %d\n", i);
 
 		urb = usb_alloc_urb(0, GFP_KERNEL);
 		if (!urb)
 			goto alloc_fail6;
+printk(KERN_ERR"Check point  34, buffer %d\n", i);
 
 		urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
+printk(KERN_ERR"Check point  35, buffer %d\n", i);
 		urb->transfer_dma = rb->dma;

Re: [PATCH] usb: dwc3: core: Disable USB2.0 phy suspend when dwc3 acts as host role

2016-11-15 Thread Felipe Balbi

Hi,

Baolin Wang  writes:
> When dwc3 controller acts as host role with attaching slow speed device
> (like mouse or keypad). Then if we plugged out the slow speed device,
> it will timeout to run the deconfiguration endpoint command to drop the
> endpoint's resources. Some xHCI command timeout log as below when
> disconnecting one slow device:
>
> [   99.807739] c0 xhci-hcd.0.auto: Port Status Change Event for port 1
> [   99.814699] c0 xhci-hcd.0.auto: resume root hub
> [   99.819992] c0 xhci-hcd.0.auto: handle_port_status: starting port
>  polling.
> [   99.827808] c0 xhci-hcd.0.auto: get port status, actual port 0 status
>  = 0x202a0
> [   99.835903] c0 xhci-hcd.0.auto: Get port status returned 0x10100
> [   99.850052] c0 xhci-hcd.0.auto: clear port connect change, actual
>  port 0 status  = 0x2a0
> [   99.859313] c0 xhci-hcd.0.auto: Cancel URB ffc01ed6cd00, dev 1,
>  ep 0x81, starting at offset 0xc406d210
> [   99.869645] c0 xhci-hcd.0.auto: // Ding dong!
> [   99.874776] c0 xhci-hcd.0.auto: Stopped on Transfer TRB
> [   99.880713] c0 xhci-hcd.0.auto: Removing canceled TD starting at
>  0xc406d210 (dma).
> [   99.889012] c0 xhci-hcd.0.auto: Finding endpoint context
> [   99.895069] c0 xhci-hcd.0.auto: Cycle state = 0x1
> [   99.900519] c0 xhci-hcd.0.auto: New dequeue segment =
>  ffc1112f0880 (virtual)
> [   99.908655] c0 xhci-hcd.0.auto: New dequeue pointer = 0xc406d220 (DMA)
> [   99.915927] c0 xhci-hcd.0.auto: Set TR Deq Ptr cmd, new deq seg =
>  ffc1112f0880 (0xc406d000 dma),
>  new deq ptr = ff8002175220
>  (0xc406d220 dma), new cycle = 1
> [   99.931242] c0 xhci-hcd.0.auto: // Ding dong!
> [   99.936360] c0 xhci-hcd.0.auto: Successful Set TR Deq Ptr cmd,
>  deq = @c406d220
> [   99.944458] c0 xhci-hcd.0.auto: xhci_hub_status_data: stopping port
>  polling.
> [  100.047619] c0 xhci-hcd.0.auto: xhci_drop_endpoint called for udev
>  ffc01ae08800
> [  100.057002] c0 xhci-hcd.0.auto: drop ep 0x81, slot id 1, new drop
>  flags = 0x8, new add flags = 0x0
> [  100.067878] c0 xhci-hcd.0.auto: xhci_check_bandwidth called for udev
>  ffc01ae08800
> [  100.076868] c0 xhci-hcd.0.auto: New Input Control Context:
>
> ..
>
> [  100.427252] c0 xhci-hcd.0.auto: // Ding dong!
> [  105.430728] c0 xhci-hcd.0.auto: Command timeout
> [  105.436029] c0 xhci-hcd.0.auto: Abort command ring
> [  113.558223] c0 xhci-hcd.0.auto: Command completion event does not match
>  command
> [  113.569778] c0 xhci-hcd.0.auto: Timeout while waiting for configure
>  endpoint command
>
> The reason is it will suspend USB phy to disable phy clock when
> disconnecting the slow USB decice, that will hang on the xHCI commands
> executing which depends on the phy clock.
>
> Thus we should disable USB2.0 phy suspend feature when dwc3 acts as host
> role.
>
> Signed-off-by: Baolin Wang 
> ---
>  drivers/usb/dwc3/core.c |   14 ++
>  1 file changed, 14 insertions(+)
>
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index 9a4a5e4..0b646cf 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -565,6 +565,20 @@ static int dwc3_phy_setup(struct dwc3 *dwc)
>   if (dwc->revision > DWC3_REVISION_194A)
>   reg |= DWC3_GUSB2PHYCFG_SUSPHY;
>  
> + /*
> +  * When dwc3 controller acts as host role with attaching one slow speed
> +  * device (like mouse or keypad). Then if we plugged out the slow speed
> +  * device, it will timeout to run the deconfiguration endpoint command.
> +  * The reason is it will suspend USB phy to disable phy clock when
> +  * disconnecting slow speed decice, which will affect the xHCI commands
> +  * executing.
> +  *
> +  * Thus we should disable USB 2.0 phy suspend feature when dwc3 acts as
> +  * host role.
> +  */
> + if (dwc->dr_mode == USB_DR_MODE_HOST || dwc->dr_mode == USB_DR_MODE_OTG)
> + reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;

which version of the core you're using? Recent version (since 1.94A,
IIRC) can manage core suspend automatically. Also, this patch of yours
will cause a power consumption regression.

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH v4 4/4] ARM: dts: da850: Add the usb otg device node

2016-11-15 Thread Sekhar Nori
On Thursday 03 November 2016 09:29 PM, Alexandre Bailon wrote:
> This adds the device tree node for the usb otg
> controller present in the da850 family of SoC's.
> This also enables the otg usb controller for the lcdk board.
> 
> Signed-off-by: Alexandre Bailon 
> ---
>  arch/arm/boot/dts/da850-lcdk.dts |  8 
>  arch/arm/boot/dts/da850.dtsi | 15 +++
>  2 files changed, 23 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/da850-lcdk.dts 
> b/arch/arm/boot/dts/da850-lcdk.dts
> index 7b8ab21..9f5040c 100644
> --- a/arch/arm/boot/dts/da850-lcdk.dts
> +++ b/arch/arm/boot/dts/da850-lcdk.dts
> @@ -158,6 +158,14 @@
>   rx-num-evt = <32>;
>  };
>  
> +_phy {
> + status = "okay";
> + };

As mentioned by David already, this node needs to be removed. Please
rebase this on top of latest linux-davinci/master when ready for merging
(driver changes accepted).

> +
> + {
> + status = "okay";
> +};
> +
>   {
>   pinctrl-names = "default";
>   pinctrl-0 = <_pins>;
> diff --git a/arch/arm/boot/dts/da850.dtsi b/arch/arm/boot/dts/da850.dtsi
> index f79e1b9..322a31a 100644
> --- a/arch/arm/boot/dts/da850.dtsi
> +++ b/arch/arm/boot/dts/da850.dtsi
> @@ -372,6 +372,21 @@
>   >;
>   status = "disabled";
>   };
> + usb_phy: usb-phy {
> + compatible = "ti,da830-usb-phy";
> + #phy-cells = <1>;
> + status = "disabled";
> + };
> + usb0: usb@20 {
> + compatible = "ti,da830-musb";
> + reg = <0x20 0x1>;
> + interrupts = <58>;
> + interrupt-names = "mc";
> + dr_mode = "otg";
> + phys = <_phy 0>;
> + phy-names = "usb-phy";
> + status = "disabled";
> + };

Can you separate out the soc specific changes from board changes? Please
place the usb0 node above the mdio node. I am trying to get to a rough
ordering based on reg property.

Thanks,
Sekhar

--
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 v3 1/1] usb: chipidea: move the lock initialization to core file

2016-11-15 Thread Peter Chen
This can fix below dump when the lock is accessed at host
mode due to it is not initialized.

[   46.119638] INFO: trying to register non-static key.
[   46.124643] the code is fine but needs lockdep annotation.
[   46.130144] turning off the locking correctness validator.
[   46.135659] CPU: 0 PID: 690 Comm: cat Not tainted 4.9.0-rc3-00079-g4b75f1d 
#1210
[   46.143075] Hardware name: Freescale i.MX6 SoloX (Device Tree)
[   46.148923] Backtrace:
[   46.151448] [] (dump_backtrace) from [] 
(show_stack+0x18/0x1c)
[   46.159038]  r7:edf52000
[   46.161412]  r6:6193
[   46.163967]  r5:
[   46.165035]  r4:c0e25c2c

[   46.169109] [] (show_stack) from [] 
(dump_stack+0xb4/0xe8)
[   46.176362] [] (dump_stack) from [] 
(register_lock_class+0x4fc/0x56c)
[   46.184554]  r10:c0e25d24
[   46.187014]  r9:edf53e70
[   46.189569]  r8:c1642444
[   46.190637]  r7:ee9da024
[   46.193191]  r6:
[   46.194258]  r5:
[   46.196812]  r4:
[   46.199185]  r3:0001

[   46.203259] [] (register_lock_class) from [] 
(__lock_acquire+0x80/0x10f0)
[   46.211797]  r10:c0e25d24
[   46.214257]  r9:edf53e70
[   46.216813]  r8:ee9da024
[   46.217880]  r7:c1642444
[   46.220435]  r6:edcd1800
[   46.221502]  r5:6193
[   46.224057]  r4:

[   46.227953] [] (__lock_acquire) from [] 
(lock_acquire+0x74/0x94)
[   46.235710]  r10:0001
[   46.238169]  r9:edf53e70
[   46.240723]  r8:edf53f80
[   46.241790]  r7:0001
[   46.244344]  r6:0001
[   46.245412]  r5:6193
[   46.247966]  r4:

[   46.251866] [] (lock_acquire) from [] 
(_raw_spin_lock_irqsave+0x40/0x54)
[   46.260319]  r7:ee1c6a00
[   46.262691]  r6:c062a570
[   46.265247]  r5:2113
[   46.266314]  r4:ee9da014

[   46.270393] [] (_raw_spin_lock_irqsave) from [] 
(ci_port_test_show+0x2c/0x70)
[   46.279280]  r6:eebd2000
[   46.281652]  r5:ee9da010
[   46.284207]  r4:ee9da014

[   46.286810] [] (ci_port_test_show) from [] 
(seq_read+0x1ac/0x4f8)
[   46.294655]  r9:edf53e70
[   46.297028]  r8:edf53f80
[   46.299583]  r7:ee1c6a00
[   46.300650]  r6:0001
[   46.303205]  r5:
[   46.304273]  r4:eebd2000
[   46.306850] [] (seq_read) from [] 
(full_proxy_read+0x54/0x6c)
[   46.314348]  r10:
[   46.316808]  r9:c0a6ad30
[   46.319363]  r8:edf53f80
[   46.320430]  r7:0002
[   46.322986]  r6:b6de3000
[   46.324053]  r5:ee1c6a00
[   46.326607]  r4:c0248b58

[   46.330505] [] (full_proxy_read) from [] 
(__vfs_read+0x34/0x118)
[   46.338262]  r9:edf52000
[   46.340635]  r8:c0107fc4
[   46.343190]  r7:0002
[   46.344257]  r6:edf53f80
[   46.346812]  r5:c039e810
[   46.347879]  r4:ee1c6a00
[   46.350447] [] (__vfs_read) from [] (vfs_read+0x8c/0x11c)
[   46.357597]  r9:edf52000
[   46.359969]  r8:c0107fc4
[   46.362524]  r7:edf53f80
[   46.363592]  r6:b6de3000
[   46.366147]  r5:ee1c6a00
[   46.367214]  r4:0002
[   46.369782] [] (vfs_read) from [] (SyS_read+0x4c/0xa8)
[   46.376672]  r8:c0107fc4
[   46.379045]  r7:0002
[   46.381600]  r6:b6de3000
[   46.382667]  r5:ee1c6a00
[   46.385222]  r4:ee1c6a00

[   46.387817] [] (SyS_read) from [] 
(ret_fast_syscall+0x0/0x1c)
[   46.395314]  r7:0003
[   46.397687]  r6:b6de3000
[   46.400243]  r5:0002
[   46.401310]  r4:0002

Cc: 
Fixes: 26c696c678c4 ("USB: Chipidea: rename struct
ci13xxx variables from udc to ci")
Signed-off-by: Peter Chen 
---
Changes for v3:
- Delete the wrong kernel version for stable tree, and using real "Fixes"
  instead.

Changes for v2:
- Clean up dump message by using dmesg output instead of console output.

 drivers/usb/chipidea/core.c | 1 +
 drivers/usb/chipidea/udc.c  | 2 --
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index a7d2c68..c5e7f3d 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -873,6 +873,7 @@ static int ci_hdrc_probe(struct platform_device *pdev)
if (!ci)
return -ENOMEM;
 
+   spin_lock_init(>lock);
ci->dev = dev;
ci->platdata = dev_get_platdata(dev);
ci->imx28_write_fix = !!(ci->platdata->flags &
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 1e0ffad..e7bd064 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1886,8 +1886,6 @@ static int udc_start(struct ci_hdrc *ci)
struct usb_otg_caps *otg_caps = >platdata->ci_otg_caps;
int retval = 0;
 
-   spin_lock_init(>lock);
-
ci->gadget.ops  = _gadget_ops;
ci->gadget.speed= USB_SPEED_UNKNOWN;
ci->gadget.max_speed= USB_SPEED_HIGH;
-- 
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


  1   2   >