Re: [PATCH] Revert "xhci: Limit USB2 port wake support for AMD Promontory hosts"

2017-09-15 Thread Kai-Heng Feng
On Mon, Aug 28, 2017 at 9:56 PM, Kai-Heng Feng
 wrote:
> On Mon, Aug 28, 2017 at 6:14 PM, Mathias Nyman
>  wrote:
>> On 28.08.2017 12:29, Greg KH wrote:
>>
>> Adding more people who were involved in the original patch.
>>
>> Users are now seeing the unresponsive USB2 ports with Promontory hosts.
>> Is there any update on a better way to solve the original issue.
>>
>> To me a "dead" USB2 port seems like a much worse issue for a user
>> than a BIOS disabled port waking up on plug/unplug (wake on
>> connect/disconnect),
>> so I'm myself in favor of doing this revert.
>
> At least I can't find "Disable USB2" on my ASUS PRIME B350M-A, so the
> new behavior is quite surprising.
>
>>
>> But there was a strong push from Promontory developers to get the original
>> fix in,
>> and I would like to get some comment from them before I do anything about
>> it.
>
> You looped them to the mail thread which I reported the regression two
> weeks ago, and there is no response since then...

Still no response from AMD and ASMedia guys.

I don't like to use out-of-tree patches for myself, but probably it's
the only way here?

>
>>
>> Thanks
>> -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] usb: dwc3: Fix the USB 3.0 hub detection bug after warm boot

2017-09-15 Thread gustavo panizzo

Hello

On Fri, Sep 15, 2017 at 09:01:13AM +, gustavo panizzo wrote:

Hello

On Thu, Sep 07, 2017 at 01:51:31PM +0300, Felipe Balbi wrote:


Hi,

gustavo panizzo  writes:

---
drivers/usb/dwc3/core.c | 33 +
1 file changed, 33 insertions(+)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 326b302fc440..f92dfe213d89 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1259,6 +1259,38 @@ static int dwc3_probe(struct platform_device
*pdev)
  return ret;
}

+static void dwc3_shutdown(struct platform_device *pdev)
+{
+   struct dwc3 *dwc = platform_get_drvdata(pdev);
+   struct resource *res = platform_get_resource(pdev,
IORESOURCE_MEM, 0);
+
+   pm_runtime_get_sync(>dev);
+   /*
+* restore res->start back to its original value so that, in case
the
+* probe is deferred, we don't end up getting error in request
the
+* memory region the next time probe is called.
+*/
+   res->start -= DWC3_GLOBALS_REGS_START;
+
+   dwc3_debugfs_exit(dwc);
+   dwc3_core_exit_mode(dwc);
+   dwc3_event_buffers_cleanup(dwc);



What about dwc3_event_buffers_cleanup? should I remove it from
dwc3_shutdown()?
It is already in dwc3_core_exit()


I think so. We should avoid duplicate code.


+   dwc3_free_event_buffers(dwc);
+
+   usb_phy_set_suspend(dwc->usb2_phy, 1);
+   usb_phy_set_suspend(dwc->usb3_phy, 1);
+
+   phy_power_off(dwc->usb2_generic_phy);
+   phy_power_off(dwc->usb3_generic_phy);



We've done these in dwc3_core_exit().


This is the patch after testing on a Odroid XU4, on top of linux-next
964bcc1b4f57028d56dace7d9bc5924f2eb43f36 which translates to 
4.13.0-rc1-next-20170717+
I tested this patch for a week without problems with heavy USB and NIC usage.
Please consider merging it


Author: Brian Kim 
Date:   Wed Jul 12 11:26:55 2017 +0800

  usb: dwc3: Fix the USB 3.0 hub detection bug after warm boot
  The dwc3 could not release resources when the module is built-in
  because this module does not have shutdown method. This causes the USB
  3.0 hub is not able to detect after warm boot.
  Original patch by Brian Kim, updated and submitted upstream by gustavo
  panizzo.
  Also see https://bugs.debian.org/843448
  Signed-off-by: Brian Kim 
  Signed-off-by: gustavo panizzo 

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 326b302fc440..09de37d47ee7 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1259,6 +1259,32 @@ static int dwc3_probe(struct platform_device *pdev)
return ret;
}

+static void dwc3_shutdown(struct platform_device *pdev)
+{
+   struct dwc3 *dwc = platform_get_drvdata(pdev);
+   struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+
+   pm_runtime_get_sync(>dev);
+   /*
+* restore res->start back to its original value so that, in case the
+* probe is deferred, we don't end up getting error in request the
+* memory region the next time probe is called.
+*/
+   res->start -= DWC3_GLOBALS_REGS_START;
+
+   dwc3_debugfs_exit(dwc);
+   dwc3_core_exit_mode(dwc);
+   dwc3_event_buffers_cleanup(dwc);
+   dwc3_free_event_buffers(dwc);
+
+   dwc3_core_exit(dwc);
+   dwc3_ulpi_exit(dwc);
+
+   pm_runtime_put_sync(>dev);
+   pm_runtime_allow(>dev);
+   pm_runtime_disable(>dev);
+}
+
static int dwc3_remove(struct platform_device *pdev)
{
struct dwc3 *dwc = platform_get_drvdata(pdev);
@@ -1488,6 +1514,7 @@ MODULE_DEVICE_TABLE(acpi, dwc3_acpi_match);
static struct platform_driver dwc3_driver = {
   .probe  = dwc3_probe,
   .remove = dwc3_remove,
+   .shutdown   = dwc3_shutdown,
   .driver = {
   .name   = "dwc3",
   .of_match_table = of_match_ptr(of_dwc3_match),

Patch applies cleanly on top of c6be5a0e3cebc145127d46a58350e05d2bcf6323 from 
linux-next
Can you _please_ merge it?


why are you upset? You didn't do the changes I requested until now. It's


I'm not upset


too late for v4.14 merge window and you didn't even send this as a
proper patch. I also have no evidence that you've been testing mainline
kernel, the commits you pointed me to are against a v4.9 vendor kernel.


the commit i sent was tested, and is still running, on top linux-next
964bcc1b4f57028d56dace7d9bc5924f2eb43f36, which gives an uname -r
4.13.0-rc1-next-20170717+




Test this against a vanilla tree (v4.13 was tagged days ago) and give me
logs showing the problem without your commit.


the patch does not work on top of 4.13.0 :(

could you draft a patch i can test?

thanks



dmesg on top of 4.13.0

[0.00] Booting Linux on physical CPU 0x100
[0.00] random: get_random_bytes called from start_kernel+0x44/0x460 
with crng_init=0
[0.00] Linux 

Re: [PATCH 5/5] usb: usb251xb: Add copyrights

2017-09-15 Thread Serge Semin
On Fri, Sep 15, 2017 at 04:53:13PM -0700, Greg KH  
wrote:
> On Sat, Sep 16, 2017 at 02:45:17AM +0300, Serge Semin wrote:
> > On Fri, Sep 15, 2017 at 04:40:28PM -0700, Greg KH 
> >  wrote:
> > > On Sat, Sep 16, 2017 at 02:31:13AM +0300, Serge Semin wrote:
> > > > Signed-off-by: Serge Semin 
> > > > ---
> > > >  drivers/usb/misc/usb251xb.c | 1 +
> > > >  1 file changed, 1 insertions(+), 0 deletion(-)
> > > 
> > > I can't take patches without any changelog text, sorry.
> > > 
> > 
> > I'll merge it into the previous patch then. There is nothing to 
> > changeloging here. 
> > 
> > > > 
> > > > diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c
> > > > index 1d47acd09..43afa04ad 100644
> > > > --- a/drivers/usb/misc/usb251xb.c
> > > > +++ b/drivers/usb/misc/usb251xb.c
> > > > @@ -3,6 +3,7 @@
> > > >   * Configuration via SMBus.
> > > >   *
> > > >   * Copyright (c) 2017 SKIDATA AG
> > > > + * Copyright (c) 2017 T-platforms
> > > 
> > > I don't see the connection between a random company, and a random
> > > gmail.com email address.  Please explain :)
> > 
> > Why do you see gmail.com only? I cc-ed this patchset to my work email:
> > sergey.se...@t-platforms.ru
> > Do I really need to send it from my work e-mail? I have met such rule 
> > before.
> 
> The authorship of these patches are coming from a gmail.com address, how
> do I know what that relates to some random email you cc: on the patch :)
> 
> thanks,
> 
> greg k-h

Does it really matter? I could create any domain and add some random company
as copyright. How would you know the copyrighted company is real then? The
only way would be just google it. That's it. But still the site can be faked
if it is really necessary.
I thought these things are a matter of trust. I submitted a patchset from my
personal e-mail, but created it while working for the company. It's highly
possible, that my personal email is going to be mine for much longer time, then
I'll be working in the company. In this case, the better way to declare it as
primary email, instead of the company one, so to have a longer support. Isn't 
it?
Why would I need to fake a copyrighted company anyway?

-Sergey

--
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] usb: usb251xb: Add USB2517/i hub support

2017-09-15 Thread Serge Semin
On Fri, Sep 15, 2017 at 04:45:14PM -0700, Greg KH  
wrote:
> On Sat, Sep 16, 2017 at 02:31:09AM +0300, Serge Semin wrote:
> > USB2517i hubs are very like USB251xb devices series. They have almost
> > the same configuration registers space except number of ports, led
> > configurations and lack of battery settings. All these peculiarities
> > are reflected in this patch.
> 
> Please add one type of feature at a time per patch.  That makes it
> easier to review and ensure you got it right.
> 
> thanks,
> 
> greg k-h

Ok. The patch isn't that big though.

Regards,
-Sergey

--
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 5/5] usb: usb251xb: Add copyrights

2017-09-15 Thread Greg KH
On Sat, Sep 16, 2017 at 02:45:17AM +0300, Serge Semin wrote:
> On Fri, Sep 15, 2017 at 04:40:28PM -0700, Greg KH 
>  wrote:
> > On Sat, Sep 16, 2017 at 02:31:13AM +0300, Serge Semin wrote:
> > > Signed-off-by: Serge Semin 
> > > ---
> > >  drivers/usb/misc/usb251xb.c | 1 +
> > >  1 file changed, 1 insertions(+), 0 deletion(-)
> > 
> > I can't take patches without any changelog text, sorry.
> > 
> 
> I'll merge it into the previous patch then. There is nothing to changeloging 
> here. 
> 
> > > 
> > > diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c
> > > index 1d47acd09..43afa04ad 100644
> > > --- a/drivers/usb/misc/usb251xb.c
> > > +++ b/drivers/usb/misc/usb251xb.c
> > > @@ -3,6 +3,7 @@
> > >   * Configuration via SMBus.
> > >   *
> > >   * Copyright (c) 2017 SKIDATA AG
> > > + * Copyright (c) 2017 T-platforms
> > 
> > I don't see the connection between a random company, and a random
> > gmail.com email address.  Please explain :)
> 
> Why do you see gmail.com only? I cc-ed this patchset to my work email:
> sergey.se...@t-platforms.ru
> Do I really need to send it from my work e-mail? I have met such rule before.

The authorship of these patches are coming from a gmail.com address, how
do I know what that relates to some random email you cc: on the patch :)

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 5/5] usb: usb251xb: Add copyrights

2017-09-15 Thread Serge Semin
On Fri, Sep 15, 2017 at 04:40:28PM -0700, Greg KH  
wrote:
> On Sat, Sep 16, 2017 at 02:31:13AM +0300, Serge Semin wrote:
> > Signed-off-by: Serge Semin 
> > ---
> >  drivers/usb/misc/usb251xb.c | 1 +
> >  1 file changed, 1 insertions(+), 0 deletion(-)
> 
> I can't take patches without any changelog text, sorry.
> 

I'll merge it into the previous patch then. There is nothing to changeloging 
here. 

> > 
> > diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c
> > index 1d47acd09..43afa04ad 100644
> > --- a/drivers/usb/misc/usb251xb.c
> > +++ b/drivers/usb/misc/usb251xb.c
> > @@ -3,6 +3,7 @@
> >   * Configuration via SMBus.
> >   *
> >   * Copyright (c) 2017 SKIDATA AG
> > + * Copyright (c) 2017 T-platforms
> 
> I don't see the connection between a random company, and a random
> gmail.com email address.  Please explain :)

Why do you see gmail.com only? I cc-ed this patchset to my work email:
sergey.se...@t-platforms.ru
Do I really need to send it from my work e-mail? I have met such rule before.

> 
> 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/5] usb: usb251xb: Add USB2517/i hub support

2017-09-15 Thread Greg KH
On Sat, Sep 16, 2017 at 02:31:09AM +0300, Serge Semin wrote:
> USB2517i hubs are very like USB251xb devices series. They have almost
> the same configuration registers space except number of ports, led
> configurations and lack of battery settings. All these peculiarities
> are reflected in this patch.

Please add one type of feature at a time per patch.  That makes it
easier to review and ensure you got it right.

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 5/5] usb: usb251xb: Add copyrights

2017-09-15 Thread Greg KH
On Fri, Sep 15, 2017 at 04:40:28PM -0700, Greg KH wrote:
> On Sat, Sep 16, 2017 at 02:31:13AM +0300, Serge Semin wrote:
> > Signed-off-by: Serge Semin 
> > ---
> >  drivers/usb/misc/usb251xb.c | 1 +
> >  1 file changed, 1 insertions(+), 0 deletion(-)
> 
> I can't take patches without any changelog text, sorry.
> 
> > 
> > diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c
> > index 1d47acd09..43afa04ad 100644
> > --- a/drivers/usb/misc/usb251xb.c
> > +++ b/drivers/usb/misc/usb251xb.c
> > @@ -3,6 +3,7 @@
> >   * Configuration via SMBus.
> >   *
> >   * Copyright (c) 2017 SKIDATA AG
> > + * Copyright (c) 2017 T-platforms
> 
> I don't see the connection between a random company, and a random
> gmail.com email address.  Please explain :)

Also, based on the changes in this series, I fail to see how you could
even claim copyright on the entire file.  Please explain that as well
when you resend this patch.

Note, I'm not a lawyer, and this isn't legal advice, please contact your
company's lawyers, they know this type of thing, and now the normal
rules for claiming copyright of a whole file.  They also know that
copyright notices in files don't mean anything, but lawyers love to
cargo-cult things more than any other profession :)

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 5/5] usb: usb251xb: Add copyrights

2017-09-15 Thread Greg KH
On Sat, Sep 16, 2017 at 02:31:13AM +0300, Serge Semin wrote:
> Signed-off-by: Serge Semin 
> ---
>  drivers/usb/misc/usb251xb.c | 1 +
>  1 file changed, 1 insertions(+), 0 deletion(-)

I can't take patches without any changelog text, sorry.

> 
> diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c
> index 1d47acd09..43afa04ad 100644
> --- a/drivers/usb/misc/usb251xb.c
> +++ b/drivers/usb/misc/usb251xb.c
> @@ -3,6 +3,7 @@
>   * Configuration via SMBus.
>   *
>   * Copyright (c) 2017 SKIDATA AG
> + * Copyright (c) 2017 T-platforms

I don't see the connection between a random company, and a random
gmail.com email address.  Please explain :)

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


[PATCH 0/5] usb: usb251xb: Add USB2517i hub support and fix some bugs

2017-09-15 Thread Serge Semin
Primarily it was intended to just add USB2517 hub support to the driver.
But after tests a bug and inconistency were discovered. So it was decided
to perform following changes:

Changelog v1:
- Add USB2517/i hub specifics support to the driver
- Fix property_u32 NULL-pointer dereference
- Add new {bus,self}-max-{power,curret} dts properties
- Replace legacy GPIO API usage with descriptor-based one

Serge Semin (5):
  usb: usb251xb: Add USB2517/i hub support
  usb: usb251xb: Fix property_u32 NULL pointer dereference
  usb: usb251xb: Add max power/current dts nodes
  usb: usb251xb: Use GPIO descriptor consumer interface
  usb: usb251xb: Add copyrights

 Documentation/devicetree/bindings/usb/usb251xb.txt |  12 +-
 drivers/usb/misc/usb251xb.c| 154 +++--
 2 files changed, 123 insertions(+), 43 deletions(-)

-- 
2.12.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/5] usb: usb251xb: Add USB2517/i hub support

2017-09-15 Thread Serge Semin
USB2517i hubs are very like USB251xb devices series. They have almost
the same configuration registers space except number of ports, led
configurations and lack of battery settings. All these peculiarities
are reflected in this patch.

Signed-off-by: Serge Semin 
---
 Documentation/devicetree/bindings/usb/usb251xb.txt |  4 +-
 drivers/usb/misc/usb251xb.c| 84 +++---
 2 files changed, 78 insertions(+), 10 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/usb251xb.txt 
b/Documentation/devicetree/bindings/usb/usb251xb.txt
index 3957d4eda..3d84626d3 100644
--- a/Documentation/devicetree/bindings/usb/usb251xb.txt
+++ b/Documentation/devicetree/bindings/usb/usb251xb.txt
@@ -6,7 +6,8 @@ Hi-Speed Controller.
 Required properties :
  - compatible : Should be "microchip,usb251xb" or one of the specific types:
"microchip,usb2512b", "microchip,usb2512bi", "microchip,usb2513b",
-   "microchip,usb2513bi", "microchip,usb2514b", "microchip,usb2514bi"
+   "microchip,usb2513bi", "microchip,usb2514b", "microchip,usb2514bi",
+   "microchip,usb2517", "microchip,usb2517i"
  - reset-gpios : Should specify the gpio for hub reset
  - reg : I2C address on the selected bus (default is <0x2C>)
 
@@ -36,6 +37,7 @@ Optional properties :
an invalid value is given, the default is used instead.
  - compound-device : indicate the hub is part of a compound device
  - port-mapping-mode : enable port mapping mode
+ - speed-led-mode : led speed indiation mode selection (usb2517 only)
  - string-support : enable string descriptor support (required for 
manufacturer,
product and serial string configuration)
  - non-removable-ports : Should specify the ports which have a non-removable
diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c
index 91f66d68b..2ef22758c 100644
--- a/drivers/usb/misc/usb251xb.c
+++ b/drivers/usb/misc/usb251xb.c
@@ -38,6 +38,7 @@
 #define USB251XB_DEF_PRODUCT_ID_12 0x2512 /* USB2512B/12Bi */
 #define USB251XB_DEF_PRODUCT_ID_13 0x2513 /* USB2513B/13Bi */
 #define USB251XB_DEF_PRODUCT_ID_14 0x2514 /* USB2514B/14Bi */
+#define USB251XB_DEF_PRODUCT_ID_17 0x2517 /* USB2517i */
 
 #define USB251XB_ADDR_DEVICE_ID_LSB0x04
 #define USB251XB_ADDR_DEVICE_ID_MSB0x05
@@ -48,7 +49,7 @@
 #define USB251XB_ADDR_CONFIG_DATA_20x07
 #define USB251XB_DEF_CONFIG_DATA_2 0x20
 #define USB251XB_ADDR_CONFIG_DATA_30x08
-#define USB251XB_DEF_CONFIG_DATA_3 0x02
+#define USB251XB_DEF_CONFIG_DATA_3 0x00
 
 #define USB251XB_ADDR_NON_REMOVABLE_DEVICES0x09
 #define USB251XB_DEF_NON_REMOVABLE_DEVICES 0x00
@@ -82,7 +83,7 @@
 
 #define USB251XB_ADDR_PRODUCT_STRING_LEN   0x14
 #define USB251XB_ADDR_PRODUCT_STRING   0x54
-#define USB251XB_DEF_PRODUCT_STRING"USB251xB/xBi"
+#define USB251XB_DEF_PRODUCT_STRING"USB251xB/xBi/7i"
 
 #define USB251XB_ADDR_SERIAL_STRING_LEN0x15
 #define USB251XB_ADDR_SERIAL_STRING0x92
@@ -93,8 +94,10 @@
 
 #define USB251XB_ADDR_BOOST_UP 0xF6
 #define USB251XB_DEF_BOOST_UP  0x00
-#define USB251XB_ADDR_BOOST_X  0xF8
-#define USB251XB_DEF_BOOST_X   0x00
+#define USB251XB_ADDR_BOOST_57 0xF8
+#define USB251XB_DEF_BOOST_57  0x00
+#define USB251XB_ADDR_BOOST_14 0xF8
+#define USB251XB_DEF_BOOST_14  0x00
 
 #define USB251XB_ADDR_PORT_SWAP0xFA
 #define USB251XB_DEF_PORT_SWAP 0x00
@@ -102,7 +105,11 @@
 #define USB251XB_ADDR_PORT_MAP_12  0xFB
 #define USB251XB_DEF_PORT_MAP_12   0x00
 #define USB251XB_ADDR_PORT_MAP_34  0xFC
-#define USB251XB_DEF_PORT_MAP_34   0x00 /* USB2513B/i & USB2514B/i only */
+#define USB251XB_DEF_PORT_MAP_34   0x00 /* USB251{3B/i,4B/i,7/i} only */
+#define USB251XB_ADDR_PORT_MAP_56  0xFD
+#define USB251XB_DEF_PORT_MAP_56   0x00 /* USB2517/i only */
+#define USB251XB_ADDR_PORT_MAP_7   0xFE
+#define USB251XB_DEF_PORT_MAP_70x00 /* USB2517/i only */
 
 #define USB251XB_ADDR_STATUS_COMMAND   0xFF
 #define USB251XB_STATUS_COMMAND_SMBUS_DOWN 0x04
@@ -144,48 +151,88 @@ struct usb251xb {
char serial[USB251XB_STRING_BUFSIZE];
u8  bat_charge_en;
u8  boost_up;
-   u8  boost_x;
+   u8  boost_57;
+   u8  boost_14;
u8  port_swap;
u8  port_map12;
u8  port_map34;
+   u8  port_map56;
+   u8  port_map7;
u8  status;
 };
 
 struct usb251xb_data {
u16 product_id;
+   u8 port_cnt;
+   bool led_support;
+   bool bat_support;
char product_str[USB251XB_STRING_BUFSIZE / 2]; /* ASCII string */
 };
 
 static const struct usb251xb_data usb2512b_data = {
.product_id = 0x2512,
+   .port_cnt = 2,
+   .led_support = false,
+   .bat_support = true,
.product_str = "USB2512B",
 };
 
 static const struct usb251xb_data usb2512bi_data = {
.product_id = 0x2512,
+   .port_cnt = 2,
+   .led_support = false,
+ 

[PATCH 4/5] usb: usb251xb: Use GPIO descriptor consumer interface

2017-09-15 Thread Serge Semin
The driver used to be developed with legacy GPIO API support. It's
better to use descriptor-based interface for several reasons. First
of all the legacy API doesn't support the ACTIVE_LOW/HIGH flag of dts
nodes, which is essential since different hardware may have different
GPIOs connectivity including the logical value inversion. Secondly,
by requesting the reset GPIO descriptor the driver prevent the other
applications from changing its value. And last but not least the
legacy GPIO interface should be avoided in the new code due to it
obsolescence.

Signed-off-by: Serge Semin 
---
 Documentation/devicetree/bindings/usb/usb251xb.txt |  2 +-
 drivers/usb/misc/usb251xb.c| 33 +-
 2 files changed, 14 insertions(+), 21 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/usb251xb.txt 
b/Documentation/devicetree/bindings/usb/usb251xb.txt
index dd59a32e7..7c981d556 100644
--- a/Documentation/devicetree/bindings/usb/usb251xb.txt
+++ b/Documentation/devicetree/bindings/usb/usb251xb.txt
@@ -8,10 +8,10 @@ Required properties :
"microchip,usb2512b", "microchip,usb2512bi", "microchip,usb2513b",
"microchip,usb2513bi", "microchip,usb2514b", "microchip,usb2514bi",
"microchip,usb2517", "microchip,usb2517i"
- - reset-gpios : Should specify the gpio for hub reset
  - reg : I2C address on the selected bus (default is <0x2C>)
 
 Optional properties :
+ - reset-gpios : Should specify the gpio for hub reset
  - skip-config : Skip Hub configuration, but only send the USB-Attach command
  - vendor-id : Set USB Vendor ID of the hub (16 bit, default is 0x0424)
  - product-id : Set USB Product ID of the hub (16 bit, default depends on type)
diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c
index d6a0ff4ec..1d47acd09 100644
--- a/drivers/usb/misc/usb251xb.c
+++ b/drivers/usb/misc/usb251xb.c
@@ -20,12 +20,11 @@
  */
 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 
 /* Internal Register Set Addresses & Default Values acc. to DS1692C */
@@ -127,7 +126,7 @@ struct usb251xb {
struct device *dev;
struct i2c_client *i2c;
u8 skip_config;
-   int gpio_reset;
+   struct gpio_desc *gpio_reset;
u16 vendor_id;
u16 product_id;
u16 device_id;
@@ -235,13 +234,13 @@ static const struct usb251xb_data usb2517i_data = {
 
 static void usb251xb_reset(struct usb251xb *hub, int state)
 {
-   if (!gpio_is_valid(hub->gpio_reset))
+   if (!hub->gpio_reset)
return;
 
-   gpio_set_value_cansleep(hub->gpio_reset, state);
+   gpiod_set_value_cansleep(hub->gpio_reset, state);
 
/* wait for hub recovery/stabilization */
-   if (state)
+   if (!state)
usleep_range(500, 750); /* >=500us at power on */
else
usleep_range(1, 10);/* >=1us at power down */
@@ -260,7 +259,7 @@ static int usb251xb_connect(struct usb251xb *hub)
i2c_wb[0] = 0x01;
i2c_wb[1] = USB251XB_STATUS_COMMAND_ATTACH;
 
-   usb251xb_reset(hub, 1);
+   usb251xb_reset(hub, 0);
 
err = i2c_smbus_write_i2c_block_data(hub->i2c,
USB251XB_ADDR_STATUS_COMMAND, 2, i2c_wb);
@@ -310,7 +309,7 @@ static int usb251xb_connect(struct usb251xb *hub)
i2c_wb[USB251XB_ADDR_PORT_MAP_7]= hub->port_map7;
i2c_wb[USB251XB_ADDR_STATUS_COMMAND] = USB251XB_STATUS_COMMAND_ATTACH;
 
-   usb251xb_reset(hub, 1);
+   usb251xb_reset(hub, 0);
 
/* write registers */
for (i = 0; i < (USB251XB_I2C_REG_SZ / USB251XB_I2C_WRITE_SZ); i++) {
@@ -363,19 +362,13 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
else
hub->skip_config = 0;
 
-   hub->gpio_reset = of_get_named_gpio(np, "reset-gpios", 0);
-   if (hub->gpio_reset == -EPROBE_DEFER)
+   hub->gpio_reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
+   if (PTR_ERR(hub->gpio_reset) == -EPROBE_DEFER) {
return -EPROBE_DEFER;
-   if (gpio_is_valid(hub->gpio_reset)) {
-   err = devm_gpio_request_one(dev, hub->gpio_reset,
-   GPIOF_OUT_INIT_LOW,
-   "usb251xb reset");
-   if (err) {
-   dev_err(dev,
-   "unable to request GPIO %d as reset pin (%d)\n",
-   hub->gpio_reset, err);
-   return err;
-   }
+   } else if (IS_ERR(hub->gpio_reset)) {
+   err = PTR_ERR(hub->gpio_reset);
+   dev_err(dev, "unable to request GPIO reset pin (%d)\n", err);
+   return err;
}
 
if (of_property_read_u16_array(np, "vendor-id", >vendor_id, 1))
-- 
2.12.0

--
To unsubscribe from this list: send the 

[PATCH 5/5] usb: usb251xb: Add copyrights

2017-09-15 Thread Serge Semin
Signed-off-by: Serge Semin 
---
 drivers/usb/misc/usb251xb.c | 1 +
 1 file changed, 1 insertions(+), 0 deletion(-)

diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c
index 1d47acd09..43afa04ad 100644
--- a/drivers/usb/misc/usb251xb.c
+++ b/drivers/usb/misc/usb251xb.c
@@ -3,6 +3,7 @@
  * Configuration via SMBus.
  *
  * Copyright (c) 2017 SKIDATA AG
+ * Copyright (c) 2017 T-platforms
  *
  * This work is based on the USB3503 driver by Dongjin Kim and
  * a not-accepted patch by Fabien Lahoudere, see:
-- 
2.12.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/5] usb: usb251xb: Fix property_u32 NULL pointer dereference

2017-09-15 Thread Serge Semin
The methods like of_property_read_u32 utilizing the specified
pointer permit only the pointer to a preallocated u32 storage as the
third argument. As a result the driver crashes on NULL pointer
dereference in case if "oc-delay-us" or "power-on-time-ms" declared
in dts file.

Signed-off-by: Serge Semin 
---
 drivers/usb/misc/usb251xb.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c
index 2ef22758c..8101c6212 100644
--- a/drivers/usb/misc/usb251xb.c
+++ b/drivers/usb/misc/usb251xb.c
@@ -348,7 +348,7 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
struct device *dev = hub->dev;
struct device_node *np = dev->of_node;
int len, err, i;
-   u32 *property_u32 = NULL;
+   u32 property_u32 = 0;
const u32 *cproperty_u32;
const char *cproperty_char;
char str[USB251XB_STRING_BUFSIZE / 2];
@@ -425,16 +425,16 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
if (of_get_property(np, "dynamic-power-switching", NULL))
hub->conf_data2 |= BIT(7);
 
-   if (!of_property_read_u32(np, "oc-delay-us", property_u32)) {
-   if (*property_u32 == 100) {
+   if (!of_property_read_u32(np, "oc-delay-us", _u32)) {
+   if (property_u32 == 100) {
/* 100 us*/
hub->conf_data2 &= ~BIT(5);
hub->conf_data2 &= ~BIT(4);
-   } else if (*property_u32 == 4000) {
+   } else if (property_u32 == 4000) {
/* 4 ms */
hub->conf_data2 &= ~BIT(5);
hub->conf_data2 |= BIT(4);
-   } else if (*property_u32 == 16000) {
+   } else if (property_u32 == 16000) {
/* 16 ms */
hub->conf_data2 |= BIT(5);
hub->conf_data2 |= BIT(4);
@@ -494,8 +494,8 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
}
 
hub->power_on_time = USB251XB_DEF_POWER_ON_TIME;
-   if (!of_property_read_u32(np, "power-on-time-ms", property_u32))
-   hub->power_on_time = min_t(u8, *property_u32 / 2, 255);
+   if (!of_property_read_u32(np, "power-on-time-ms", _u32))
+   hub->power_on_time = min_t(u8, property_u32 / 2, 255);
 
if (of_property_read_u16_array(np, "language-id", >lang_id, 1))
hub->lang_id = USB251XB_DEF_LANGUAGE_ID;
-- 
2.12.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 3/5] usb: usb251xb: Add max power/current dts nodes

2017-09-15 Thread Serge Semin
This parameters may be varied in accordance with hardware specifics.
So lets add the corresponding settings to the usb251x driver dts
specification.

Signed-off-by: Serge Semin 
---
 Documentation/devicetree/bindings/usb/usb251xb.txt |  6 ++
 drivers/usb/misc/usb251xb.c| 20 
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/usb251xb.txt 
b/Documentation/devicetree/bindings/usb/usb251xb.txt
index 3d84626d3..dd59a32e7 100644
--- a/Documentation/devicetree/bindings/usb/usb251xb.txt
+++ b/Documentation/devicetree/bindings/usb/usb251xb.txt
@@ -44,6 +44,12 @@ Optional properties :
device connected.
  - sp-disabled-ports : Specifies the ports which will be self-power disabled
  - bp-disabled-ports : Specifies the ports which will be bus-power disabled
+ - sp-max-{power,current} : Indicates the power/current consumed by hub from
+   an upstream port (VBUS) when operation as a self-powered hub. The value
+   is given in mA in a 0 - 100 range (default is 1mA).
+ - bp-max-{power,current} : Indicates the power/current consumed by hub from
+   an upstream port (VBUS) when operation as a bus-powered hub. The value
+   is given in mA in a 0 - 510 range (default is 100mA).
  - power-on-time-ms : Specifies the time it takes from the time the host
initiates the power-on sequence to a port until the port has adequate
power. The value is given in ms in a 0 - 510 range (default is 100ms).
diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c
index 8101c6212..d6a0ff4ec 100644
--- a/drivers/usb/misc/usb251xb.c
+++ b/drivers/usb/misc/usb251xb.c
@@ -493,6 +493,22 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
}
}
 
+   hub->max_power_sp = USB251XB_DEF_MAX_POWER_SELF;
+   if (!of_property_read_u32(np, "sp-max-power", _u32))
+   hub->max_power_sp = min_t(u8, property_u32 / 2, 50);
+
+   hub->max_power_bp = USB251XB_DEF_MAX_POWER_BUS;
+   if (!of_property_read_u32(np, "bp-max-power", _u32))
+   hub->max_power_bp = min_t(u8, property_u32 / 2, 255);
+
+   hub->max_current_sp = USB251XB_DEF_MAX_CURRENT_SELF;
+   if (!of_property_read_u32(np, "sp-max-current", _u32))
+   hub->max_current_sp = min_t(u8, property_u32 / 2, 50);
+
+   hub->max_current_bp = USB251XB_DEF_MAX_CURRENT_BUS;
+   if (!of_property_read_u32(np, "bp-max-current", _u32))
+   hub->max_current_bp = min_t(u8, property_u32 / 2, 255);
+
hub->power_on_time = USB251XB_DEF_POWER_ON_TIME;
if (!of_property_read_u32(np, "power-on-time-ms", _u32))
hub->power_on_time = min_t(u8, property_u32 / 2, 255);
@@ -532,10 +548,6 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
/* The following parameters are currently not exposed to devicetree, but
 * may be as soon as needed.
 */
-   hub->max_power_sp = USB251XB_DEF_MAX_POWER_SELF;
-   hub->max_power_bp = USB251XB_DEF_MAX_POWER_BUS;
-   hub->max_current_sp = USB251XB_DEF_MAX_CURRENT_SELF;
-   hub->max_current_bp = USB251XB_DEF_MAX_CURRENT_BUS;
hub->bat_charge_en = USB251XB_DEF_BATTERY_CHARGING_ENABLE;
hub->boost_up = USB251XB_DEF_BOOST_UP;
hub->boost_57 = USB251XB_DEF_BOOST_57;
-- 
2.12.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/gadget: stalls in dummy_timer

2017-09-15 Thread Alan Stern
On Thu, 14 Sep 2017, Andrey Konovalov wrote:

> On Thu, Sep 14, 2017 at 7:49 PM, Alan Stern  wrote:
> > On Thu, 14 Sep 2017, Andrey Konovalov wrote:
> >
> >> Looked at this a little more.
> >>
> >> dummy_timer() stucks in an infinite loop. It calls
> >> usb_hcd_giveback_urb(), which in turn calls usbtouch_irq(), which
> >> calls usb_submit_urb(), which calls dummy_urb_enqueue() and puts urb
> >> back into dummy urb queue. dummy_timer() then does goto restart, finds
> >> the urb and calls usb_hcd_giveback_urb() again. And this process goes
> >> on again and again. It seems that something should either process the
> >> urb and set urb->status or it should just expire.
> >
> > There is some throttling code, but it applies only to bulk transfers.
> > Probably because the bandwidth limits for other types are slightly
> > different.  However, I don't think we need to worry about this level of
> > detail, since the driver makes a number of other approximations anyway.
> >
> > Try the patch below; it should fix the problem.
> 
> Hi Alan,
> 
> Just tried your patch, my reproducer still hangs the kernel until all
> memory is exhausted.
> 
> Thanks!

Hmmm.  Your reproducer doesn't run on my system.  The mmap system call
fails, perhaps because this laptop has a 32-bit kernel.  So I can't
tell what's going on.

Can you collect a usbmon trace that shows what happens while the 
reproducer runs?  If it turns out to be extremely large, just post an 
initial portion of it.

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: xhci_hcd HC died; cleaning up with TUSB7340 and µPD720201

2017-09-15 Thread Chris Welch
> -Original Message-
> From: Roger Quadros [mailto:rog...@ti.com]
> Sent: Thursday, September 14, 2017 10:14 AM
> To: Chris Welch ; linux-usb@vger.kernel.org
> Subject: Re: xhci_hcd HC died; cleaning up with TUSB7340 and µPD720201
> 
> 
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-
> tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
> 
> On 14/09/17 16:53, Chris Welch wrote:
> >> -Original Message-
> >> From: Roger Quadros [mailto:rog...@ti.com]
> >> Sent: Thursday, September 14, 2017 6:38 AM
> >> To: Chris Welch ;
> >> linux-usb@vger.kernel.org
> >> Subject: Re: xhci_hcd HC died; cleaning up with TUSB7340 and
> >> µPD720201
> >>
> >> Chris,
> >>
> >>
> >> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-
> >> tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
> >>
> >> On 13/09/17 17:26, Chris Welch wrote:
> >>> We are developing a product based on the TI AM5728 EVM.  The product
> >> utilizes a TUSB7340 PCIe USB host for additional ports.  The TUSB7340
> >> is detected and setup properly and works OK with low data rate devices.
> >> However, hot plugging a Realtek USB network adapter and doing
> >> Ethernet transfer bandwidth testing using iperf3 causes the TUSB7340
> >> host to be  locked out.  The TUSB7340 host appears to no longer
> >> communicate and the logging indicates xhci_hcd :01:00.0: HC died;
> >> cleaning up.  Same issue occurs with another USB Ethernet adapter I tried
> (Asus).
> >>>
> >>> We looked at using another host and found a mini PCIe card that
> >>> utilizes the
> >> µPD720201 and can be directly installed on the TI AM5728 EVM.  The
> >> card is detected properly and we reran the transfer test.  The
> >> uPD720201 gets locks out with the same problem.
> >>>
> >>> The AM5728 testing was performed using the TI SD card stock
> >>> am57xx-evm-
> >> linux-04.00.00.04.img, kernel am57xx-evm 4.9.28-geed43d1050, and it
> >> reports that it is using the TI AM572x EVM Rev A3 device tree.
> >>>
> >>> It shows the following logging when it fails (this is with the TI
> >>> EVM and
> >> uPD720201).
> >>>
> >>> [  630.400899] xhci_hcd :01:00.0: xHCI host not responding to
> >>> stop
> >> endpoint command.
> >>> [  630.408769] xhci_hcd :01:00.0: Assuming host is dying, halting 
> >>> host.
> >>> [  630.420849] r8152 2-4:1.0 enp1s0u4: Tx status -108 [  630.425667]
> >>> r8152 2-4:1.0 enp1s0u4: Tx status -108 [  630.430483] r8152 2-4:1.0
> >>> enp1s0u4: Tx status -108 [  630.435297] r8152 2-4:1.0 enp1s0u4: Tx
> >>> status -108 [  630.440122] xhci_hcd :01:00.0: HC died; cleaning
> >>> up [  630.453961] usb 2-4: USB disconnect, device number 2
> >>>
> >>> The problem appears to be a general driver issue given we get the
> >>> same
> >> problem with both the  TUSB7340 and the µPD720201.
> >>
> >> Can you try to reproduce the issue with the Realtek USB network
> >> adapter on the Native USB host port of AM5727 EVM. That happens to
> >> use xhci_hcd driver as well.
> >> This will help us know if the issue is with the pcie based USB
> >> controllers or elsewhere.
> >>
> >> Also do you have another make of USB network adapter to try on?
> >>
> >
> > The issue appears to be with the PCie based USB host controllers.  I have no
> failures using the native USB ports or ports with subtended USB hubs.  We use
> TUSB8041s on the product as well to expand the native ports.
> >
> > I have also replicated the problem using an Asus Ethernet USB adapter.
> 
> How about trying the PCIe USB cards on a Linux PC?
> This would identify if PCIe bus on AM5727 EVM is the culprit or not.

I got a hold of the TI EVM for the TUSB7340 and setup a test using Ubuntu 
16.04.03, 4.10.0-28-generic.  There were no problems with the data testing.  I 
pushed it even harder than AM5728 testing and the host remained up.

So it is looking like it is an issue with the AM5728 PCI/PCIe.  I'll take the 
problem back to TI.

Roger, I'll contact you directly.  Thanks for your help!

> 
> >
> >>>
> >>> I've tried the 4.4.49, 4.12.3 and 4.13.1 kernels and they also fail.
> >>>
> >>> I tried the TI E2E support community and they were unable to provide
> >>> any
> >> solutions.
> >>>
> >>> Here is a sample session with the TUSB7340:
> >>>
> >>> root@arm:~# !iperf3
> >>> iperf3 -c 10.14.21.95 -t 6000
> >>> Connecting to host 10.14.21.95, port 5201 [ 4] local 10.14.21.89
> >>> port
> >>> 60978 connected to 10.14.21.95 port 5201 [ ID] Interval Transfer
> >>> Bandwidth Retr Cwnd [ 4] 0.00-1.00 sec 14.2 MBytes 119 Mbits/sec 1
> >>> 1.41 KBytes [ 4] 1.00-2.00 sec 0.00 Bytes 0.00 bits/sec 0 1.41
> >>> KBytes [ 4] 2.00-3.00 sec 0.00 Bytes 0.00 bits/sec 0 1.41 KBytes [
> >>> 4]
> >>> 3.00-4.00 sec 0.00 Bytes 0.00 bits/sec 0 1.41 KBytes [ 4] 4.00-5.00
> >>> sec 0.00 Bytes 0.00 bits/sec 0 1.41 KBytes [ 4] 5.00-6.00 sec 0.00
> >>> Bytes 0.00 bits/sec 0 1.41 KBytes [ 4] 6.00-7.00 sec 0.00 Bytes 0.00
> >>> 

[PATCH 0/2] max3421: add devicetree support

2017-09-15 Thread Jules Maselbas
Hi,

This patchset adds devicetree support to the max3421 driver.
Thoses modification are based on a previous (unapplied) patch
series by Alexander Amelkin [1].

Since I am not a kernel expert I would a like to have your feedbacks on:
1. Under which condition pdata must be freed (in max3421_probe) ?
2. If it neccessary to free platform_data in max3421_remove function ?

Thank you,

[1]: [https://lkml.org/lkml/2017/5/26/285]

---

Jules Maselbas (2):
  usb: max3421: Add devicetree support
  dt-bindings: max3421: Add bindings documentation

 .../devicetree/bindings/usb/maxim,max3421.txt  | 24 ++
 drivers/usb/host/max3421-hcd.c | 87 +-
 2 files changed, 110 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/usb/maxim,max3421.txt

-- 
2.14.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/2] dt-bindings: max3421: Add bindings documentation

2017-09-15 Thread Jules Maselbas
Adds bindings documentation for the max3421 driver.

Signed-off-by: Jules Maselbas 
---
 .../devicetree/bindings/usb/maxim,max3421.txt  | 24 ++
 1 file changed, 24 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/maxim,max3421.txt

diff --git a/Documentation/devicetree/bindings/usb/maxim,max3421.txt 
b/Documentation/devicetree/bindings/usb/maxim,max3421.txt
new file mode 100644
index ..7536c3ab3e5a
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/maxim,max3421.txt
@@ -0,0 +1,24 @@
+Maxim Integrated SPI-based USB 2.0 host controller MAX3421E
+
+Required properties:
+ - compatible: "maxim,max3421"
+ - spi-max-frequency: maximum frequency for this device must not exceed 26 MHz.
+ - reg: chip select number to which this device is connected.
+ - maxim,vbus-en-pin: 
+   GPOUTx is the number (1-8) of the GPOUT pin of MAX3421E to drive Vbus.
+   ACTIVE_LEVEL is 0 or 1.
+ - interrupt-parent: the phandle of the associated interrupt controller.
+ - interrupts: the interuption line description for the interrupt controller.
+   The driver configures MAX3421E for active low level triggered interrupts,
+   configure your interrupt line accordingly.
+
+Example:
+
+   usb@0 {
+   compatible = "maxim,max3421";
+   reg = <0>;
+   maxim,vbus-en-pin = <3 1>;
+   spi-max-frequency = <2600>;
+   interrupt-parent = <>;
+   interrupts = <42>;
+   };
-- 
2.14.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/2] usb: max3421: Add devicetree support

2017-09-15 Thread Jules Maselbas
Adds support for devicetree to the max3421 driver.

Signed-off-by: Jules Maselbas 
---
 drivers/usb/host/max3421-hcd.c | 87 +-
 1 file changed, 86 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/max3421-hcd.c b/drivers/usb/host/max3421-hcd.c
index 0ece9a9341e5..928a5aabee02 100644
--- a/drivers/usb/host/max3421-hcd.c
+++ b/drivers/usb/host/max3421-hcd.c
@@ -60,6 +60,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -85,6 +86,8 @@
  USB_PORT_STAT_C_OVERCURRENT | \
  USB_PORT_STAT_C_RESET) << 16)
 
+#define MAX3421_GPOUT_COUNT8
+
 enum max3421_rh_state {
MAX3421_RH_RESET,
MAX3421_RH_SUSPENDED,
@@ -1672,7 +1675,7 @@ max3421_gpout_set_value(struct usb_hcd *hcd, u8 
pin_number, u8 value)
u8 mask, idx;
 
--pin_number;
-   if (pin_number > 7)
+   if (pin_number >= MAX3421_GPOUT_COUNT)
return;
 
mask = 1u << (pin_number % 4);
@@ -1699,6 +1702,10 @@ max3421_hub_control(struct usb_hcd *hcd, u16 type_req, 
u16 value, u16 index,
spin_lock_irqsave(_hcd->lock, flags);
 
pdata = spi->dev.platform_data;
+   if (!pdata) {
+   dev_err(>dev, "Device platform data is missing\n");
+   return -EFAULT;
+   }
 
switch (type_req) {
case ClearHubFeature:
@@ -1831,11 +1838,35 @@ static const struct hc_driver max3421_hcd_desc = {
.bus_resume =   max3421_bus_resume,
 };
 
+static int
+max3421_of_vbus_en_pin(struct device *dev, struct max3421_hcd_platform_data 
*pdata)
+{
+   int retval;
+   uint32_t value[2];
+
+   if (!pdata)
+   return -EINVAL;
+
+   retval = of_property_read_u32_array(dev->of_node, "maxim,vbus-en-pin", 
value, 2);
+   if (retval) {
+   dev_err(dev, "device tree node property 'maxim,vbus-en-pin' is 
missing\n");
+   return retval;
+   }
+   dev_info(dev, "property 'maxim,vbus-en-pin' value is <%d %d>\n", 
value[0], value[1]);
+
+   pdata->vbus_gpout = value[0];
+   pdata->vbus_active_level = value[1];
+
+   return 0;
+}
+
 static int
 max3421_probe(struct spi_device *spi)
 {
+   struct device *dev = >dev;
struct max3421_hcd *max3421_hcd;
struct usb_hcd *hcd = NULL;
+   struct max3421_hcd_platform_data *pdata = NULL;
int retval = -ENOMEM;
 
if (spi_setup(spi) < 0) {
@@ -1843,6 +1874,42 @@ max3421_probe(struct spi_device *spi)
return -EFAULT;
}
 
+   if (!spi->irq) {
+   dev_err(dev, "Failed to get SPI IRQ");
+   return -EFAULT;
+   }
+
+   if (IS_ENABLED(CONFIG_OF) && dev->of_node) {
+   pdata = devm_kzalloc(>dev, sizeof(*pdata), GFP_KERNEL);
+   if (!pdata) {
+   dev_err(>dev, "failed to allocate memory for 
private data\n");
+   retval = -ENOMEM;
+   goto error;
+   }
+   retval = max3421_of_vbus_en_pin(dev, pdata);
+   if (retval)
+   goto error;
+
+   spi->dev.platform_data = pdata;
+   }
+
+   pdata = spi->dev.platform_data;
+   if (!pdata) {
+   dev_err(>dev, "driver configuration data is not 
provided\n");
+   retval = -EFAULT;
+   goto error;
+   }
+   if (pdata->vbus_active_level > 1) {
+   dev_err(>dev, "vbus active level value %d is out of range 
(0/1)\n", pdata->vbus_active_level);
+   retval = -EINVAL;
+   goto error;
+   }
+   if (pdata->vbus_gpout < 1 || pdata->vbus_gpout > MAX3421_GPOUT_COUNT) {
+   dev_err(>dev, "vbus gpout value %d is out of range 
(1..8)\n", pdata->vbus_gpout);
+   retval = -EINVAL;
+   goto error;
+   }
+
hcd = usb_create_hcd(_hcd_desc, >dev,
 dev_name(>dev));
if (!hcd) {
@@ -1885,6 +1952,11 @@ max3421_probe(struct spi_device *spi)
return 0;
 
 error:
+   if (IS_ENABLED(CONFIG_OF) && dev->of_node && pdata) {
+   devm_kfree(>dev, pdata);
+   spi->dev.platform_data = NULL;
+   }
+
if (hcd) {
kfree(max3421_hcd->tx);
kfree(max3421_hcd->rx);
@@ -1923,17 +1995,30 @@ max3421_remove(struct spi_device *spi)
 
spin_unlock_irqrestore(_hcd->lock, flags);
 
+   if (IS_ENABLED(CONFIG_OF) && spi->dev.platform_data) {
+   dev_dbg(>dev, "Freeing platform data structure\n");
+   devm_kfree(>dev, spi->dev.platform_data);
+   spi->dev.platform_data = NULL;
+   }
+
free_irq(spi->irq, hcd);
 
usb_put_hcd(hcd);
return 0;
 }
 
+static const struct of_device_id max3421_of_match_table[] = {
+   { .compatible = "maxim,max3421", },
+   {},
+};

Re: Interfacing a camera to UVC

2017-09-15 Thread Rail Shafigulin
Thanks for answers, everyone! I think I got what I needed.


-- 
Rail Shafigulin
Software Engineer
Esencia Technologies

-- 




*ESENCIA TECHNOLOGIES, INC.*3945 Freedom Circle, Suite #360,
Santa Clara CA 95054


Phone: +1 408 736 8284 Fax: +1 408 519 3475 
http://www.esenciatech.com | http://www.lnttechservices.com


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

2017-09-15 Thread Alan Stern
On Fri, 15 Sep 2017, Bruce Korb wrote:

> (Alan -- sorry for duplicate reply. iPad seems to really like HTML, so
> it bounced.)
> 
> On Thu, Sep 14, 2017 at 5:30 PM, Alan Stern  wrote:
> > On Thu, 14 Sep 2017, Bruce Korb wrote:
> > The number of tagged commits has nothing to do with it.  Bisection
> > involves testing _all_ the commits.  (But not one at a time,
> > obviously!)
> 
> I do understand binary searches ("bisection" commit searches).
> The full search range would be v4.1 through v4.5.
> The tags are just convenient markers for commits, after all.
> I would guess you'd search on the tag points before
> searching between individual commits between tags.

You can if you want to, but git bisect ignores tags.  It will divide up
the entire set of commits from the start point to the end point into
roughly equal halves at each step.

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: USB mouse

2017-09-15 Thread Bruce Korb
(Alan -- sorry for duplicate reply. iPad seems to really like HTML, so
it bounced.)

On Thu, Sep 14, 2017 at 5:30 PM, Alan Stern  wrote:
> On Thu, 14 Sep 2017, Bruce Korb wrote:
> The number of tagged commits has nothing to do with it.  Bisection
> involves testing _all_ the commits.  (But not one at a time,
> obviously!)

I do understand binary searches ("bisection" commit searches).
The full search range would be v4.1 through v4.5.
The tags are just convenient markers for commits, after all.
I would guess you'd search on the tag points before
searching between individual commits between tags.

>> 2016-10-02 16:24:33 -0700  (tag: v4.8)  << LIKELY FAILS
>
> Didn't you say earlier that 4.4.85 definitely fails?  So there's no
> need to worry about 4.8.

Oops. Yep. 4.4.85 became 4.8 while I was perusing the tags. :)
Obviously, the failure occurs before tag v4.5 and likely before v4.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 v2 2/9] clk: at91: pmc: Save SCSR during suspend

2017-09-15 Thread Romain Izard
The contents of the System Clock Status Register (SCSR) needs to be
restored into the System Clock Enable Register (SCER).

As the bootloader will restore some clocks by itself, the issue can be
missed as only the USB controller, the LCD controller, the Image Sensor
controller and the programmable clocks will be impacted.

Fix the obvious typo in the suspend/resume code, as the IMR register
does not need to be saved twice.

Signed-off-by: Romain Izard 
Acked-by: Nicolas Ferre 
---
 drivers/clk/at91/pmc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c
index 5c2b26de303e..07dc2861ad3f 100644
--- a/drivers/clk/at91/pmc.c
+++ b/drivers/clk/at91/pmc.c
@@ -86,7 +86,7 @@ static int pmc_suspend(void)
 {
int i;
 
-   regmap_read(pmcreg, AT91_PMC_IMR, _cache.scsr);
+   regmap_read(pmcreg, AT91_PMC_SCSR, _cache.scsr);
regmap_read(pmcreg, AT91_PMC_PCSR, _cache.pcsr0);
regmap_read(pmcreg, AT91_CKGR_UCKR, _cache.uckr);
regmap_read(pmcreg, AT91_CKGR_MOR, _cache.mor);
@@ -129,7 +129,7 @@ static void pmc_resume(void)
if (pmc_cache.pllar != tmp)
pr_warn("PLLAR was not configured properly by the firmware\n");
 
-   regmap_write(pmcreg, AT91_PMC_IMR, pmc_cache.scsr);
+   regmap_write(pmcreg, AT91_PMC_SCER, pmc_cache.scsr);
regmap_write(pmcreg, AT91_PMC_PCER, pmc_cache.pcsr0);
regmap_write(pmcreg, AT91_CKGR_UCKR, pmc_cache.uckr);
regmap_write(pmcreg, AT91_CKGR_MOR, pmc_cache.mor);
-- 
2.11.0

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


[PATCH v2 1/9] clk: at91: pmc: Wait for clocks when resuming

2017-09-15 Thread Romain Izard
Wait for the syncronization of all clocks when resuming, not only the
UPLL clock. Do not use regmap_read_poll_timeout, as it will call BUG()
when interrupts are masked, which is the case in here.

Signed-off-by: Romain Izard 
---
 drivers/clk/at91/pmc.c | 24 
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c
index 775af473fe11..5c2b26de303e 100644
--- a/drivers/clk/at91/pmc.c
+++ b/drivers/clk/at91/pmc.c
@@ -107,10 +107,20 @@ static int pmc_suspend(void)
return 0;
 }
 
+static bool pmc_ready(unsigned int mask)
+{
+   unsigned int status;
+
+   regmap_read(pmcreg, AT91_PMC_SR, );
+
+   return ((status & mask) == mask) ? 1 : 0;
+}
+
 static void pmc_resume(void)
 {
-   int i, ret = 0;
+   int i;
u32 tmp;
+   u32 mask = AT91_PMC_MCKRDY | AT91_PMC_LOCKA;
 
regmap_read(pmcreg, AT91_PMC_MCKR, );
if (pmc_cache.mckr != tmp)
@@ -134,13 +144,11 @@ static void pmc_resume(void)
 AT91_PMC_PCR_CMD);
}
 
-   if (pmc_cache.uckr & AT91_PMC_UPLLEN) {
-   ret = regmap_read_poll_timeout(pmcreg, AT91_PMC_SR, tmp,
-  !(tmp & AT91_PMC_LOCKU),
-  10, 5000);
-   if (ret)
-   pr_crit("USB PLL didn't lock when resuming\n");
-   }
+   if (pmc_cache.uckr & AT91_PMC_UPLLEN)
+   mask |= AT91_PMC_LOCKU;
+
+   while (!pmc_ready(mask))
+   cpu_relax();
 }
 
 static struct syscore_ops pmc_syscore_ops = {
-- 
2.11.0

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


[PATCH v2 5/9] mtd: nand: atmel: Report PMECC failures as errors

2017-09-15 Thread Romain Izard
It is not normal for the PMECC to fail when trying to fix ECC errors.
Report these cases as errors.

Signed-off-by: Romain Izard 
---
 drivers/mtd/nand/atmel/pmecc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/atmel/pmecc.c b/drivers/mtd/nand/atmel/pmecc.c
index 8d1208f38025..2a23f1ff945f 100644
--- a/drivers/mtd/nand/atmel/pmecc.c
+++ b/drivers/mtd/nand/atmel/pmecc.c
@@ -687,6 +687,8 @@ static int atmel_pmecc_err_location(struct atmel_pmecc_user 
*user)
 * Number of roots does not match the degree of smu
 * unable to correct error.
 */
+   dev_err(pmecc->dev,
+   "PMECC: Impossible to calculate error location.\n");
return -EBADMSG;
 }
 
@@ -729,7 +731,7 @@ int atmel_pmecc_correct_sector(struct atmel_pmecc_user 
*user, int sector,
ptr = ecc + byte - sectorsize;
area = "ECC";
} else {
-   dev_dbg(pmecc->dev,
+   dev_err(pmecc->dev,
"Invalid errpos value (%d, max is %d)\n",
errpos, (sectorsize + eccbytes) * 8);
return -EINVAL;
-- 
2.11.0

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


[PATCH v2 4/9] mtd: nand: atmel: Avoid ECC errors when leaving backup mode

2017-09-15 Thread Romain Izard
During backup mode, the contents of all registers will be cleared as the
SoC will be completely powered down. For a product that boots on NAND
Flash memory, the bootloader will obviously use the related controller
to read the Flash and correct any detected error in the memory, before
handling back control to the kernel's resuming entry point.

In normal devices, it is up to the driver's suspend/resume code to
restore the registers in a valid state. But the PMECC is not a regular
device in the driver model when used with the legacy device tree binding
for the Atmel NAND controller, and suspend/resume code is not called.

As in my case the bootloader leaves the PMECC controller in a programmed
state, and the controller is only reset at boot or after a NAND access,
the first NAND Flash access with the Atmel controller will report
uncorrectable ECC errors.

To avoid this, systematically reset the PMECC controller before using
it.

Signed-off-by: Romain Izard 
---
 drivers/mtd/nand/atmel/pmecc.c | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/nand/atmel/pmecc.c b/drivers/mtd/nand/atmel/pmecc.c
index 8c210a5776bc..8d1208f38025 100644
--- a/drivers/mtd/nand/atmel/pmecc.c
+++ b/drivers/mtd/nand/atmel/pmecc.c
@@ -777,6 +777,9 @@ int atmel_pmecc_enable(struct atmel_pmecc_user *user, int 
op)
 
mutex_lock(>pmecc->lock);
 
+   writel(PMECC_CTRL_RST, pmecc->regs.base + ATMEL_PMECC_CTRL);
+   writel(PMECC_CTRL_DISABLE, pmecc->regs.base + ATMEL_PMECC_CTRL);
+
cfg = user->cache.cfg;
if (op == NAND_ECC_WRITE)
cfg |= PMECC_CFG_WRITE_OP;
@@ -797,10 +800,6 @@ EXPORT_SYMBOL_GPL(atmel_pmecc_enable);
 
 void atmel_pmecc_disable(struct atmel_pmecc_user *user)
 {
-   struct atmel_pmecc *pmecc = user->pmecc;
-
-   writel(PMECC_CTRL_RST, pmecc->regs.base + ATMEL_PMECC_CTRL);
-   writel(PMECC_CTRL_DISABLE, pmecc->regs.base + ATMEL_PMECC_CTRL);
mutex_unlock(>pmecc->lock);
 }
 EXPORT_SYMBOL_GPL(atmel_pmecc_disable);
@@ -856,10 +855,6 @@ static struct atmel_pmecc *atmel_pmecc_create(struct 
platform_device *pdev,
/* Disable all interrupts before registering the PMECC handler. */
writel(0x, pmecc->regs.base + ATMEL_PMECC_IDR);
 
-   /* Reset the ECC engine */
-   writel(PMECC_CTRL_RST, pmecc->regs.base + ATMEL_PMECC_CTRL);
-   writel(PMECC_CTRL_DISABLE, pmecc->regs.base + ATMEL_PMECC_CTRL);
-
return pmecc;
 }
 
-- 
2.11.0

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


[PATCH v2 6/9] ehci-atmel: Power down during suspend is normal

2017-09-15 Thread Romain Izard
When an Atmel SoC is suspended with the backup mode, the USB bus will be
powered down. As this is expected, do not return an error to the driver
core when ehci_resume detects it.

Signed-off-by: Romain Izard 
---
 drivers/usb/host/ehci-atmel.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c
index 7440722bfbf0..2a8b9bdc0e57 100644
--- a/drivers/usb/host/ehci-atmel.c
+++ b/drivers/usb/host/ehci-atmel.c
@@ -205,7 +205,8 @@ static int __maybe_unused ehci_atmel_drv_resume(struct 
device *dev)
struct atmel_ehci_priv *atmel_ehci = hcd_to_atmel_ehci_priv(hcd);
 
atmel_start_clock(atmel_ehci);
-   return ehci_resume(hcd, false);
+   ehci_resume(hcd, false);
+   return 0;
 }
 
 #ifdef CONFIG_OF
-- 
2.11.0

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


[PATCH v2 3/9] clk: at91: pmc: Support backup for programmable clocks

2017-09-15 Thread Romain Izard
From: Romain Izard 

When an AT91 programmable clock is declared in the device tree, register
it into the Power Management Controller driver. On entering suspend mode,
the driver saves and restores the Programmable Clock registers to support
the backup mode for these clocks.

Signed-off-by: Romain Izard 
---
Changes in v2:
* register PCKs on clock startup

 drivers/clk/at91/clk-programmable.c |  2 ++
 drivers/clk/at91/pmc.c  | 27 +++
 drivers/clk/at91/pmc.h  |  2 ++
 3 files changed, 31 insertions(+)

diff --git a/drivers/clk/at91/clk-programmable.c 
b/drivers/clk/at91/clk-programmable.c
index 85a449cf61e3..0e6aab1252fc 100644
--- a/drivers/clk/at91/clk-programmable.c
+++ b/drivers/clk/at91/clk-programmable.c
@@ -204,6 +204,8 @@ at91_clk_register_programmable(struct regmap *regmap,
if (ret) {
kfree(prog);
hw = ERR_PTR(ret);
+   } else {
+   pmc_register_pck(id);
}
 
return hw;
diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c
index 07dc2861ad3f..3910b7537152 100644
--- a/drivers/clk/at91/pmc.c
+++ b/drivers/clk/at91/pmc.c
@@ -22,6 +22,7 @@
 #include "pmc.h"
 
 #define PMC_MAX_IDS 128
+#define PMC_MAX_PCKS 8
 
 int of_at91_get_clk_range(struct device_node *np, const char *propname,
  struct clk_range *range)
@@ -50,6 +51,7 @@ EXPORT_SYMBOL_GPL(of_at91_get_clk_range);
 static struct regmap *pmcreg;
 
 static u8 registered_ids[PMC_MAX_IDS];
+static u8 registered_pcks[PMC_MAX_PCKS];
 
 static struct
 {
@@ -66,8 +68,10 @@ static struct
u32 pcr[PMC_MAX_IDS];
u32 audio_pll0;
u32 audio_pll1;
+   u32 pckr[PMC_MAX_PCKS];
 } pmc_cache;
 
+/* Clock ID 0 is invalid */
 void pmc_register_id(u8 id)
 {
int i;
@@ -82,6 +86,21 @@ void pmc_register_id(u8 id)
}
 }
 
+/* Programmable Clock 0 is valid */
+void pmc_register_pck(u8 pck)
+{
+   int i;
+
+   for (i = 0; i < PMC_MAX_PCKS; i++) {
+   if (registered_pcks[i] == 0) {
+   registered_pcks[i] = pck + 1;
+   break;
+   }
+   if (registered_pcks[i] == (pck + 1))
+   break;
+   }
+}
+
 static int pmc_suspend(void)
 {
int i;
@@ -103,6 +122,10 @@ static int pmc_suspend(void)
regmap_read(pmcreg, AT91_PMC_PCR,
_cache.pcr[registered_ids[i]]);
}
+   for (i = 0; registered_pcks[i]; i++) {
+   u8 num = registered_pcks[i] - 1;
+   regmap_read(pmcreg, AT91_PMC_PCKR(num), _cache.pckr[num]);
+   }
 
return 0;
 }
@@ -143,6 +166,10 @@ static void pmc_resume(void)
 pmc_cache.pcr[registered_ids[i]] |
 AT91_PMC_PCR_CMD);
}
+   for (i = 0; registered_pcks[i]; i++) {
+   u8 num = registered_pcks[i] - 1;
+   regmap_write(pmcreg, AT91_PMC_PCKR(num), pmc_cache.pckr[num]);
+   }
 
if (pmc_cache.uckr & AT91_PMC_UPLLEN)
mask |= AT91_PMC_LOCKU;
diff --git a/drivers/clk/at91/pmc.h b/drivers/clk/at91/pmc.h
index 858e8ef7e8db..d22b1fa9ecdc 100644
--- a/drivers/clk/at91/pmc.h
+++ b/drivers/clk/at91/pmc.h
@@ -31,8 +31,10 @@ int of_at91_get_clk_range(struct device_node *np, const char 
*propname,
 
 #ifdef CONFIG_PM
 void pmc_register_id(u8 id);
+void pmc_register_pck(u8 pck);
 #else
 static inline void pmc_register_id(u8 id) {}
+static inline void pmc_register_pck(u8 pck) {}
 #endif
 
 #endif /* __PMC_H_ */
-- 
2.11.0

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


[PATCH v2 8/9] atmel_flexcom: Support backup mode

2017-09-15 Thread Romain Izard
The controller used by a flexcom module is configured at boot, and left
alone after this. As the configuration will be lost after backup mode,
restore the state of the flexcom driver on resume.

Signed-off-by: Romain Izard 
---
 drivers/mfd/atmel-flexcom.c | 65 ++---
 1 file changed, 50 insertions(+), 15 deletions(-)

diff --git a/drivers/mfd/atmel-flexcom.c b/drivers/mfd/atmel-flexcom.c
index 064bde9cff5a..ef1235c4a179 100644
--- a/drivers/mfd/atmel-flexcom.c
+++ b/drivers/mfd/atmel-flexcom.c
@@ -39,34 +39,44 @@
 #define FLEX_MR_OPMODE(opmode) (((opmode) << FLEX_MR_OPMODE_OFFSET) &  \
 FLEX_MR_OPMODE_MASK)
 
+struct atmel_flexcom {
+   void __iomem *base;
+   u32 opmode;
+   struct clk *clk;
+};
 
 static int atmel_flexcom_probe(struct platform_device *pdev)
 {
struct device_node *np = pdev->dev.of_node;
-   struct clk *clk;
struct resource *res;
-   void __iomem *base;
-   u32 opmode;
+   struct atmel_flexcom *afc;
int err;
+   u32 val;
+
+   afc = devm_kzalloc(>dev, sizeof(*afc), GFP_KERNEL);
+   if (!afc)
+   return -ENOMEM;
 
-   err = of_property_read_u32(np, "atmel,flexcom-mode", );
+   platform_set_drvdata(pdev, afc);
+
+   err = of_property_read_u32(np, "atmel,flexcom-mode", >opmode);
if (err)
return err;
 
-   if (opmode < ATMEL_FLEXCOM_MODE_USART ||
-   opmode > ATMEL_FLEXCOM_MODE_TWI)
+   if (afc->opmode < ATMEL_FLEXCOM_MODE_USART ||
+   afc->opmode > ATMEL_FLEXCOM_MODE_TWI)
return -EINVAL;
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   base = devm_ioremap_resource(>dev, res);
-   if (IS_ERR(base))
-   return PTR_ERR(base);
+   afc->base = devm_ioremap_resource(>dev, res);
+   if (IS_ERR(afc->base))
+   return PTR_ERR(afc->base);
 
-   clk = devm_clk_get(>dev, NULL);
-   if (IS_ERR(clk))
-   return PTR_ERR(clk);
+   afc->clk = devm_clk_get(>dev, NULL);
+   if (IS_ERR(afc->clk))
+   return PTR_ERR(afc->clk);
 
-   err = clk_prepare_enable(clk);
+   err = clk_prepare_enable(afc->clk);
if (err)
return err;
 
@@ -76,9 +86,10 @@ static int atmel_flexcom_probe(struct platform_device *pdev)
 * inaccessible and are read as zero. Also the external I/O lines of the
 * Flexcom are muxed to reach the selected device.
 */
-   writel(FLEX_MR_OPMODE(opmode), base + FLEX_MR);
+   val = FLEX_MR_OPMODE(afc->opmode);
+   writel(val, afc->base + FLEX_MR);
 
-   clk_disable_unprepare(clk);
+   clk_disable_unprepare(afc->clk);
 
return devm_of_platform_populate(>dev);
 }
@@ -89,10 +100,34 @@ static const struct of_device_id atmel_flexcom_of_match[] 
= {
 };
 MODULE_DEVICE_TABLE(of, atmel_flexcom_of_match);
 
+#ifdef CONFIG_PM_SLEEP
+static int atmel_flexcom_resume(struct device *dev)
+{
+   struct atmel_flexcom *afc = dev_get_drvdata(dev);
+   int err;
+   u32 val;
+
+   err = clk_prepare_enable(afc->clk);
+   if (err)
+   return err;
+
+   val = FLEX_MR_OPMODE(afc->opmode),
+   writel(val, afc->base + FLEX_MR);
+
+   clk_disable_unprepare(afc->clk);
+
+   return 0;
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(atmel_flexcom_pm_ops, NULL,
+atmel_flexcom_resume);
+
 static struct platform_driver atmel_flexcom_driver = {
.probe  = atmel_flexcom_probe,
.driver = {
.name   = "atmel_flexcom",
+   .pm = _flexcom_pm_ops,
.of_match_table = atmel_flexcom_of_match,
},
 };
-- 
2.11.0

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


[PATCH v2 7/9] pwm: atmel-tcb: Support backup mode

2017-09-15 Thread Romain Izard
Save and restore registers for the PWM on suspend and resume, which
makes hibernation and backup modes possible.

Signed-off-by: Romain Izard 
---
 drivers/pwm/pwm-atmel-tcb.c | 63 +++--
 1 file changed, 61 insertions(+), 2 deletions(-)

diff --git a/drivers/pwm/pwm-atmel-tcb.c b/drivers/pwm/pwm-atmel-tcb.c
index 75db585a2a94..acd3ce8ecf3f 100644
--- a/drivers/pwm/pwm-atmel-tcb.c
+++ b/drivers/pwm/pwm-atmel-tcb.c
@@ -37,11 +37,20 @@ struct atmel_tcb_pwm_device {
unsigned period;/* PWM period expressed in clk cycles */
 };
 
+struct atmel_tcb_channel {
+   u32 enabled;
+   u32 cmr;
+   u32 ra;
+   u32 rb;
+   u32 rc;
+};
+
 struct atmel_tcb_pwm_chip {
struct pwm_chip chip;
spinlock_t lock;
struct atmel_tc *tc;
struct atmel_tcb_pwm_device *pwms[NPWM];
+   struct atmel_tcb_channel bkup[NPWM / 2];
 };
 
 static inline struct atmel_tcb_pwm_chip *to_tcb_chip(struct pwm_chip *chip)
@@ -175,12 +184,15 @@ static void atmel_tcb_pwm_disable(struct pwm_chip *chip, 
struct pwm_device *pwm)
 * Use software trigger to apply the new setting.
 * If both PWM devices in this group are disabled we stop the clock.
 */
-   if (!(cmr & (ATMEL_TC_ACPC | ATMEL_TC_BCPC)))
+   if (!(cmr & (ATMEL_TC_ACPC | ATMEL_TC_BCPC))) {
__raw_writel(ATMEL_TC_SWTRG | ATMEL_TC_CLKDIS,
 regs + ATMEL_TC_REG(group, CCR));
-   else
+   tcbpwmc->bkup[group].enabled = 1;
+   } else {
__raw_writel(ATMEL_TC_SWTRG, regs +
 ATMEL_TC_REG(group, CCR));
+   tcbpwmc->bkup[group].enabled = 0;
+   }
 
spin_unlock(>lock);
 }
@@ -263,6 +275,7 @@ static int atmel_tcb_pwm_enable(struct pwm_chip *chip, 
struct pwm_device *pwm)
/* Use software trigger to apply the new setting */
__raw_writel(ATMEL_TC_CLKEN | ATMEL_TC_SWTRG,
 regs + ATMEL_TC_REG(group, CCR));
+   tcbpwmc->bkup[group].enabled = 1;
spin_unlock(>lock);
return 0;
 }
@@ -445,10 +458,56 @@ static const struct of_device_id atmel_tcb_pwm_dt_ids[] = 
{
 };
 MODULE_DEVICE_TABLE(of, atmel_tcb_pwm_dt_ids);
 
+#ifdef CONFIG_PM_SLEEP
+static int atmel_tcb_pwm_suspend(struct device *dev)
+{
+   struct platform_device *pdev = to_platform_device(dev);
+   struct atmel_tcb_pwm_chip *tcbpwm = platform_get_drvdata(pdev);
+   void __iomem *base = tcbpwm->tc->regs;
+   int i;
+
+   for (i = 0; i < (NPWM / 2); i++) {
+   struct atmel_tcb_channel *chan = >bkup[i];
+
+   chan->cmr = readl(base + ATMEL_TC_REG(i, CMR));
+   chan->ra = readl(base + ATMEL_TC_REG(i, RA));
+   chan->rb = readl(base + ATMEL_TC_REG(i, RB));
+   chan->rc = readl(base + ATMEL_TC_REG(i, RC));
+   }
+   return 0;
+}
+
+static int atmel_tcb_pwm_resume(struct device *dev)
+{
+   struct platform_device *pdev = to_platform_device(dev);
+   struct atmel_tcb_pwm_chip *tcbpwm = platform_get_drvdata(pdev);
+   void __iomem *base = tcbpwm->tc->regs;
+   int i;
+
+   for (i = 0; i < (NPWM / 2); i++) {
+   struct atmel_tcb_channel *chan = >bkup[i];
+
+   writel(chan->cmr, base + ATMEL_TC_REG(i, CMR));
+   writel(chan->ra, base + ATMEL_TC_REG(i, RA));
+   writel(chan->rb, base + ATMEL_TC_REG(i, RB));
+   writel(chan->rc, base + ATMEL_TC_REG(i, RC));
+   if (chan->enabled) {
+   writel(ATMEL_TC_CLKEN | ATMEL_TC_SWTRG,
+   base + ATMEL_TC_REG(i, CCR));
+   }
+   }
+   return 0;
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(atmel_tcb_pwm_pm_ops, atmel_tcb_pwm_suspend,
+atmel_tcb_pwm_resume);
+
 static struct platform_driver atmel_tcb_pwm_driver = {
.driver = {
.name = "atmel-tcb-pwm",
.of_match_table = atmel_tcb_pwm_dt_ids,
+   .pm = _tcb_pwm_pm_ops,
},
.probe = atmel_tcb_pwm_probe,
.remove = atmel_tcb_pwm_remove,
-- 
2.11.0

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


[PATCH v2 9/9] tty/serial: atmel: Prevent a warning on suspend

2017-09-15 Thread Romain Izard
The atmel serial port driver reported the following warning on suspend:
atmel_usart f802.serial: ttyS1: Unable to drain transmitter

As the ATMEL_US_TXEMPTY status bit in ATMEL_US_CSR is always cleared
when the transmitter is disabled, we need to know the transmitter's
state to return the real fifo state. And as ATMEL_US_CR is write-only,
it is necessary to save the state of the transmitter in a local
variable, and update the variable when TXEN and TXDIS is written in
ATMEL_US_CR.

After those changes, atmel_tx_empty can return "empty" on suspend, the
warning in uart_suspend_port disappears, and suspending is 20ms shorter
for each enabled Atmel serial port.

Signed-off-by: Romain Izard 
---
 drivers/tty/serial/atmel_serial.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/drivers/tty/serial/atmel_serial.c 
b/drivers/tty/serial/atmel_serial.c
index 7551cab438ff..783af6648be0 100644
--- a/drivers/tty/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
@@ -171,6 +171,7 @@ struct atmel_uart_port {
boolhas_hw_timer;
struct timer_list   uart_timer;
 
+   booltx_stopped;
boolsuspended;
unsigned intpending;
unsigned intpending_status;
@@ -380,6 +381,10 @@ static int atmel_config_rs485(struct uart_port *port,
  */
 static u_int atmel_tx_empty(struct uart_port *port)
 {
+   struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
+
+   if (atmel_port->tx_stopped)
+   return TIOCSER_TEMT;
return (atmel_uart_readl(port, ATMEL_US_CSR) & ATMEL_US_TXEMPTY) ?
TIOCSER_TEMT :
0;
@@ -485,6 +490,7 @@ static void atmel_stop_tx(struct uart_port *port)
 * is fully transmitted.
 */
atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXDIS);
+   atmel_port->tx_stopped = true;
 
/* Disable interrupts */
atmel_uart_writel(port, ATMEL_US_IDR, atmel_port->tx_done_mask);
@@ -492,6 +498,7 @@ static void atmel_stop_tx(struct uart_port *port)
if ((port->rs485.flags & SER_RS485_ENABLED) &&
!(port->rs485.flags & SER_RS485_RX_DURING_TX))
atmel_start_rx(port);
+
 }
 
 /*
@@ -521,6 +528,7 @@ static void atmel_start_tx(struct uart_port *port)
 
/* re-enable the transmitter */
atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN);
+   atmel_port->tx_stopped = false;
 }
 
 /*
@@ -1866,6 +1874,7 @@ static int atmel_startup(struct uart_port *port)
atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX);
/* enable xmit & rcvr */
atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN);
+   atmel_port->tx_stopped = false;
 
setup_timer(_port->uart_timer,
atmel_uart_timer_callback,
@@ -2122,6 +2131,7 @@ static void atmel_set_termios(struct uart_port *port, 
struct ktermios *termios,
 
/* disable receiver and transmitter */
atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXDIS | ATMEL_US_RXDIS);
+   atmel_port->tx_stopped = true;
 
/* mode */
if (port->rs485.flags & SER_RS485_ENABLED) {
@@ -2207,6 +2217,7 @@ static void atmel_set_termios(struct uart_port *port, 
struct ktermios *termios,
atmel_uart_writel(port, ATMEL_US_BRGR, quot);
atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX);
atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN);
+   atmel_port->tx_stopped = false;
 
/* restore interrupts */
atmel_uart_writel(port, ATMEL_US_IER, imr);
@@ -2450,6 +2461,7 @@ static void atmel_console_write(struct console *co, const 
char *s, u_int count)
 
/* Make sure that tx path is actually able to send characters */
atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN);
+   atmel_port->tx_stopped = false;
 
uart_console_write(port, s, count, atmel_console_putchar);
 
@@ -2511,6 +2523,7 @@ static int __init atmel_console_setup(struct console *co, 
char *options)
 {
int ret;
struct uart_port *port = _ports[co->index].uart;
+   struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
int baud = 115200;
int bits = 8;
int parity = 'n';
@@ -2528,6 +2541,7 @@ static int __init atmel_console_setup(struct console *co, 
char *options)
atmel_uart_writel(port, ATMEL_US_IDR, -1);
atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX);
atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN);
+   atmel_port->tx_stopped = false;
 
if (options)
uart_parse_options(options, , , , );
-- 
2.11.0

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


[PATCH v2 0/9] Various patches for SAMA5D2 backup mode

2017-09-15 Thread Romain Izard
While the core of the backup mode for SAMA5D2 has been integrated in
v4.13, it is far from complete. Individual controllers in the chip have
drivers that do not support the reset of the registers during suspend,
and they need to be adapted to handle it.

The first patch uses the clock wakeup code from the prototype backup
mode instead of the version integrated in the mainline, as the mainline
version is not stable. During a test loop with two-second backup
suspend, the mainline version will hang in less than one day, whereas
the prototype version has been running the same test for more than a
week without hanging.

Changes in v2:
* drop the IIO patch duplicating existing code
* determine the number of programmable clocks to save dynamically
* declare a required local variable in the tty/serial patch

Romain Izard (9):
  clk: at91: pmc: Wait for clocks when resuming
  clk: at91: pmc: Save SCSR during suspend
  clk: at91: pmc: Support backup for programmable clocks
  mtd: nand: atmel: Avoid ECC errors when leaving backup mode
  mtd: nand: atmel: Report PMECC failures as errors
  ehci-atmel: Power down during suspend is normal
  pwm: atmel-tcb: Support backup mode
  atmel_flexcom: Support backup mode
  tty/serial: atmel: Prevent a warning on suspend

 drivers/clk/at91/clk-programmable.c |  2 ++
 drivers/clk/at91/pmc.c  | 55 +--
 drivers/clk/at91/pmc.h  |  2 ++
 drivers/mfd/atmel-flexcom.c | 65 -
 drivers/mtd/nand/atmel/pmecc.c  | 15 -
 drivers/pwm/pwm-atmel-tcb.c | 63 +--
 drivers/tty/serial/atmel_serial.c   | 14 
 drivers/usb/host/ehci-atmel.c   |  3 +-
 8 files changed, 182 insertions(+), 37 deletions(-)

-- 
2.11.0

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


incomplete MJPG frames through dwc2 USB host

2017-09-15 Thread Andrea Di Chiara

Hi,
I'm using a RK3288 rockchip board whit kernel rockchip-linux release-4.4.
It has two USB host and one of them has a DW controller. If I connect a
UVC camera on it, I get into an incomplete MJPG frame error when enable
stream with a image format greater or equal than 1920x1080. There isn't
any related error on dmseg log, even if I enable CONFIG_USB_DWC2_DEBUG.
So I can check that issue only processing MJPG data or showing that frame.

I'm certain it isn't a camera problem cause if I connect it to the other
ECHI controller USB port it work properly. I thought it was an bandwidth
issue cause if I reduce image format the problem disappear. Could it be
so? If not, what could it be the problem?

This is rk3288.dtsi usb hosts config

   usb_host0_ehci: usb@ff50 {
   compatible = "generic-ehci";
   reg = <0xff50 0x100>;
   interrupts = ;
   clocks = < HCLK_USBHOST0>;
   clock-names = "usbhost";
   phys = <>;
   phy-names = "usb";
   status = "disabled";
   };

   usb_host1: usb@ff54 {
   compatible = "rockchip,rk3288-usb", "rockchip,rk3066-usb",
   "snps,dwc2";
   reg = <0xff54 0x4>;
   interrupts = ;
   clocks = < HCLK_USBHOST1>;
   clock-names = "otg";
   dr_mode = "host";
   phys = <>;
   phy-names = "usb2-phy";
   status = "disabled";
   };

thank you for the attention,
best regards
Andrea



Software Department
softw...@teseo.com

-
TESEO spavia Agnelli, 49  63900 FERMO (FM) ITALY
Tel. +39 0734 628818   --Fax. +39 0734 628816

Disclaimer: This electronic mail transmission may contain legally privileged 
and/or confidential information. Do not read this if you are not the person(s) 
named. Any use, distribution, copying or disclosure by any other person is 
strictly prohibited. If you receive this transmission by mistake destroy the 
original transmission and its attachments without reading or saving in any 
manner.
--
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: Fix the USB 3.0 hub detection bug after warm boot

2017-09-15 Thread gustavo panizzo

Hello

On Thu, Sep 07, 2017 at 01:51:31PM +0300, Felipe Balbi wrote:


Hi,

gustavo panizzo  writes:

---
drivers/usb/dwc3/core.c | 33 +
1 file changed, 33 insertions(+)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 326b302fc440..f92dfe213d89 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1259,6 +1259,38 @@ static int dwc3_probe(struct platform_device
*pdev)
   return ret;
}

+static void dwc3_shutdown(struct platform_device *pdev)
+{
+   struct dwc3 *dwc = platform_get_drvdata(pdev);
+   struct resource *res = platform_get_resource(pdev,
IORESOURCE_MEM, 0);
+
+   pm_runtime_get_sync(>dev);
+   /*
+* restore res->start back to its original value so that, in case
the
+* probe is deferred, we don't end up getting error in request
the
+* memory region the next time probe is called.
+*/
+   res->start -= DWC3_GLOBALS_REGS_START;
+
+   dwc3_debugfs_exit(dwc);
+   dwc3_core_exit_mode(dwc);
+   dwc3_event_buffers_cleanup(dwc);



What about dwc3_event_buffers_cleanup? should I remove it from
dwc3_shutdown()?
It is already in dwc3_core_exit()


I think so. We should avoid duplicate code.


+   dwc3_free_event_buffers(dwc);
+
+   usb_phy_set_suspend(dwc->usb2_phy, 1);
+   usb_phy_set_suspend(dwc->usb3_phy, 1);
+
+   phy_power_off(dwc->usb2_generic_phy);
+   phy_power_off(dwc->usb3_generic_phy);



We've done these in dwc3_core_exit().


This is the patch after testing on a Odroid XU4, on top of linux-next
964bcc1b4f57028d56dace7d9bc5924f2eb43f36 which translates to 
4.13.0-rc1-next-20170717+
I tested this patch for a week without problems with heavy USB and NIC usage.
Please consider merging it


Author: Brian Kim 
Date:   Wed Jul 12 11:26:55 2017 +0800

   usb: dwc3: Fix the USB 3.0 hub detection bug after warm boot
   The dwc3 could not release resources when the module is built-in
   because this module does not have shutdown method. This causes the USB
   3.0 hub is not able to detect after warm boot.
   Original patch by Brian Kim, updated and submitted upstream by gustavo
   panizzo.
   Also see https://bugs.debian.org/843448
   Signed-off-by: Brian Kim 
   Signed-off-by: gustavo panizzo 

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 326b302fc440..09de37d47ee7 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1259,6 +1259,32 @@ static int dwc3_probe(struct platform_device *pdev)
return ret;
}

+static void dwc3_shutdown(struct platform_device *pdev)
+{
+   struct dwc3 *dwc = platform_get_drvdata(pdev);
+   struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+
+   pm_runtime_get_sync(>dev);
+   /*
+* restore res->start back to its original value so that, in case the
+* probe is deferred, we don't end up getting error in request the
+* memory region the next time probe is called.
+*/
+   res->start -= DWC3_GLOBALS_REGS_START;
+
+   dwc3_debugfs_exit(dwc);
+   dwc3_core_exit_mode(dwc);
+   dwc3_event_buffers_cleanup(dwc);
+   dwc3_free_event_buffers(dwc);
+
+   dwc3_core_exit(dwc);
+   dwc3_ulpi_exit(dwc);
+
+   pm_runtime_put_sync(>dev);
+   pm_runtime_allow(>dev);
+   pm_runtime_disable(>dev);
+}
+
static int dwc3_remove(struct platform_device *pdev)
{
struct dwc3 *dwc = platform_get_drvdata(pdev);
@@ -1488,6 +1514,7 @@ MODULE_DEVICE_TABLE(acpi, dwc3_acpi_match);
static struct platform_driver dwc3_driver = {
.probe  = dwc3_probe,
.remove = dwc3_remove,
+   .shutdown   = dwc3_shutdown,
.driver = {
.name   = "dwc3",
.of_match_table = of_match_ptr(of_dwc3_match),

Patch applies cleanly on top of c6be5a0e3cebc145127d46a58350e05d2bcf6323 from 
linux-next
Can you _please_ merge it?


why are you upset? You didn't do the changes I requested until now. It's


I'm not upset


too late for v4.14 merge window and you didn't even send this as a
proper patch. I also have no evidence that you've been testing mainline
kernel, the commits you pointed me to are against a v4.9 vendor kernel.


the commit i sent was tested, and is still running, on top linux-next
964bcc1b4f57028d56dace7d9bc5924f2eb43f36, which gives an uname -r
4.13.0-rc1-next-20170717+




Test this against a vanilla tree (v4.13 was tagged days ago) and give me
logs showing the problem without your commit.


dmesg on top of 4.13.0

[0.00] Booting Linux on physical CPU 0x100
[0.00] random: get_random_bytes called from start_kernel+0x44/0x460 
with crng_init=0
[0.00] Linux version 4.13.0 (root@odroid) (gcc version 6.3.0 20170516 
(Debian 6.3.0-18)) #4 SMP Thu Sep 14 21:26:18 UTC 2017
[0.00] CPU: ARMv7 Processor