Re: [PATCH v3 00/11] usbip: features to USB over WebSocket

2015-04-28 Thread Krzysztof Opasiak

Hello,

On 04/27/2015 03:07 AM, Nobuo Iwata wrote:
(...snip...)


2) User space transmission

USB/IP transfer URBs in kernel space. It's better for performance but
difficult to introduce application protocols.

Like fuse for file systems, it allows to transfer URBs in user space.

When usbip_ux.ko is loaded, it replaces kernel_sendmsg() and
kernel_recvmsg() with user spcace interface. When USB/IP utilities find
usbip_ux.ko, they start threads to read/write PDUs from/to usbip_ux.ko
and send/recv them.




Please correct me if I misunderstood something but aren't you rewriting 
most of the functionality which is available through the /dev/bus/usb 
nodes? Those nodes are used by libusb to communicate with the device so 
you can submit transfers etc. straight from userspace using generic raw 
usb driver.


As far as I understand your design you have kernel stub driver which is 
sending and receiving data via socket fd received from userspace. Now 
after this series you are exporting all messages  to userspace where 
daemon is sending them using web sockets. Am I right?


I don't see what are the benefits of such kernel driver?
Couldn't you just simply use libusb in your daemon and do everything 
from userspace? Such solution could be beneficial for older kernel 
because you don't need to backport your patches but simply use your 
daemon which will be compatible with most kernel versions as libusb is 
working with them.


--
Krzysztof Opasiak
Samsung R&D Institute Poland
Samsung Electronics
--
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 v2] Revert "usb: host: ehci-msm: Use devm_ioremap_resource instead of devm_ioremap"

2015-04-28 Thread Vivek Gautam

Hi,

--
From: "Alan Stern" 
Sent: Monday, April 27, 2015 8:14 PM
To: "Ivan T. Ivanov" 
Cc: "Greg Kroah-Hartman" ; 
; ; 
; "Vivek Gautam" 
Subject: Re: [PATCH v2] Revert "usb: host: ehci-msm: Use 
devm_ioremap_resource instead of devm_ioremap"



On Mon, 27 Apr 2015, Ivan T. Ivanov wrote:


This reverts commit 70843f623b58 ("usb: host: ehci-msm: Use
devm_ioremap_resource instead of devm_ioremap") and commit
e507bf577e5a ("host: ehci-msm: remove duplicate check on resource"),
because msm_otg and this driver are using same address space to
access AHB mode and USB command registers.

Cc: Vivek Gautam 
Signed-off-by: Ivan T. Ivanov 
---

Changes since v0:

* Add note to patch description that also commit e507bf577e5a is 
reverted.


Ok,

Acked-by: Vivek Gautam 



 drivers/usb/host/ehci-msm.c | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c
index 9db74ca..275c92e 100644
--- a/drivers/usb/host/ehci-msm.c
+++ b/drivers/usb/host/ehci-msm.c
@@ -88,13 +88,20 @@ static int ehci_msm_probe(struct platform_device 
*pdev)

 }

 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- hcd->regs = devm_ioremap_resource(&pdev->dev, res);
- if (IS_ERR(hcd->regs)) {
- ret = PTR_ERR(hcd->regs);
+ if (!res) {
+ dev_err(&pdev->dev, "Unable to get memory resource\n");
+ ret = -ENODEV;
 goto put_hcd;
 }
+
 hcd->rsrc_start = res->start;
 hcd->rsrc_len = resource_size(res);
+ hcd->regs = devm_ioremap(&pdev->dev, hcd->rsrc_start, hcd->rsrc_len);
+ if (!hcd->regs) {
+ dev_err(&pdev->dev, "ioremap failed\n");
+ ret = -ENOMEM;
+ goto put_hcd;
+ }

 /*
 * OTG driver takes care of PHY initialization, clock management,
--
1.9.1


Acked-by: 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] usb: gadget: composite: enable BESL support

2015-04-28 Thread Du, Changbin
>From a6615937bcd9234e6d6bb817c3701fce44d0a84d Mon Sep 17 00:00:00 2001
From: Felipe Balbi 
Date: Tue, 30 Sep 2014 16:08:03 -0500
Subject: [PATCH] usb: gadget: composite: enable BESL support

According to USB 2.0 ECN Errata for Link Power
Management (USB2-LPM-Errata-final.pdf), BESL
must be enabled if LPM is enabled.

This helps with USB30CV TD 9.21 LPM L1
Suspend Resume Test.

Cc:  # 3.14
Signed-off-by: Felipe Balbi 
Signed-off-by: Du, Changbin 
---
Hi,

This patch was introduced on v3.18. However the issue fixed already existed on
v3.14 and v3.14 is a long term support version.

So propose to backport it over there as well.

Du, Changbin
---
 drivers/usb/gadget/composite.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index a8c18df..f6a51fd 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -560,7 +560,7 @@ static int bos_desc(struct usb_composite_dev *cdev)
usb_ext->bLength = USB_DT_USB_EXT_CAP_SIZE;
usb_ext->bDescriptorType = USB_DT_DEVICE_CAPABILITY;
usb_ext->bDevCapabilityType = USB_CAP_TYPE_EXT;
-   usb_ext->bmAttributes = cpu_to_le32(USB_LPM_SUPPORT);
+   usb_ext->bmAttributes = cpu_to_le32(USB_LPM_SUPPORT | USB_BESL_SUPPORT);
 
/*
 * The Superspeed USB Capability descriptor shall be implemented by all
-- 
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 1/1] drivers/usb/chipidea/debuc.c: avoid out of bound read

2015-04-28 Thread Peter Chen
On Mon, Apr 27, 2015 at 08:25:12PM +0200, Heinrich Schuchardt wrote:
> On 22.04.2015 03:26, Peter Chen wrote:
> > On Tue, Apr 21, 2015 at 09:25:41PM +0200, Heinrich Schuchardt wrote:
> >> Hello Peter,
> >>
> >> thanks for reviewing.
> >>
> >> On 21.04.2015 03:32, Peter Chen wrote:
> >>> On Fri, Apr 17, 2015 at 08:04:13AM +0200, Heinrich Schuchardt wrote:
>  A string written by the user may not be zero terminated.
> 
>  sscanf may read memory beyond the buffer if no zero byte
>  is found.
> 
>  Signed-off-by: Heinrich Schuchardt 
>  ---
>   drivers/usb/chipidea/debug.c | 6 +-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
>  diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c
>  index dfb05ed..ef08af3 100644
>  --- a/drivers/usb/chipidea/debug.c
>  +++ b/drivers/usb/chipidea/debug.c
>  @@ -88,9 +88,13 @@ static ssize_t ci_port_test_write(struct file *file, 
>  const char __user *ubuf,
>   char buf[32];
>   int ret;
>   
>  -if (copy_from_user(buf, ubuf, min_t(size_t, sizeof(buf) - 1, 
>  count)))
>  +count = min_t(size_t, sizeof(buf) - 1, count);
>  +if (copy_from_user(buf, ubuf, count))
>   return -EFAULT;
> >>>
> >>> Any reasons to change above?
> >>
> >> Otherwise we would have two lines with the term
> >> min_t(size_t, sizeof(buf) - 1, count).
> > 
> > Sorry, two lines of min_t(..)? Why I can't find it?
> 
> Hello Peter,
> 
> in my patch I write:
> 
> count = min_t(size_t, sizeof(buf) - 1, count);
> if (copy_from_user(buf, ubuf, count))
>   return -EFAULT;
> 
> /* sscanf requires a zero terminated string */
> buf[count] = 0;
> 
> Without the first part of the change I would have had to write:
> 
> if (copy_from_user(buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
>   return -EFAULT;
> 
> /* sscanf requires a zero terminated string */
> buf[min_t(size_t, sizeof(buf) - 1, count)] = 0;
> 
> We should do the same calculation
> "min_t(size_t, sizeof(buf) - 1, count)"
> only once in the coding.

Oh, yeah. 
Send your v2 with '\0' change, thanks.

Peter

> 
> Best regards
> 
> Heinrich
> 
> 
> > 
> > 
> >>
> >> This would make the code harder to read.
> >>
>   
>  +/* sscanf requires a zero terminated string */
>  +buf[count] = 0;
>  +
> >>>
> >>> I prefer using '\0'
> >>
> >> If you confirm the rest of the patch is ok, I will send an updated patch.
> >>
> >> Best regards
> >>
> >> Heinrich
> >>
> >>>
>   if (sscanf(buf, "%u", &mode) != 1)
>   return -EINVAL;
>   
> >>
> > 
> 

-- 

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] usb: gadget: ether: Fix MAC address parsing

2015-04-28 Thread Stefan Agner
Hi Krzysztof,

On 2015-04-27 11:42, Krzysztof Opasiak wrote:
> MAC address is often written without leading zeros.
> 
> Example:
> 00:14:3d:0f:ff:fe can be written as 0:14:3d:f:ff:fe
> 
> Convention of skipping leading zeros is used in libc.
> enther_ntoa_r() generates MAC address without leading
> zeros.
> 
> Fix get_ether_addr() to correctly parse MAC address
> with and without leading zeros.

Thought about creating such a patch too, thanks for looking into it.

> 
> Signed-off-by: Krzysztof Opasiak 
> ---
>  drivers/usb/gadget/function/u_ether.c |8 +---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/gadget/function/u_ether.c
> b/drivers/usb/gadget/function/u_ether.c
> index f1fd777..1e3ee2a 100644
> --- a/drivers/usb/gadget/function/u_ether.c
> +++ b/drivers/usb/gadget/function/u_ether.c
> @@ -713,9 +713,11 @@ static int get_ether_addr(const char *str, u8 *dev_addr)
>  
>   if ((*str == '.') || (*str == ':'))
>   str++;
> - num = hex_to_bin(*str++) << 4;
> - num |= hex_to_bin(*str++);
> - dev_addr [i] = num;
> +
> + num = hex_to_bin(*str++);
> + if ((*str != '.') && (*str != ':'))
> + num = num << 4 | hex_to_bin(*str++);
> + dev_addr[i] = num;

This should definitely work, but seems a bit complex to solve the
problem.

When looking a bit close, this function seems to parse beyond the input
strings end, which clearly is not a nice thing or even a security issue.
Will try to improve it.

--
Stefan

>   }
>   if (is_valid_ether_addr(dev_addr))
>   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 v3 00/11] usbip: features to USB over WebSocket

2015-04-28 Thread fx IWATA NOBUO
Hello,

> As far as I understand your design you have kernel stub driver which 
> is sending and receiving data via socket fd received from userspace.
> Now after this series you are exporting all messages  to userspace
> where daemon is sending them using web sockets. Am I right?

Yes.

> I don't see what are the benefits of such kernel driver?
> Couldn't you just simply use libusb in your daemon and do everything
> from userspace? Such solution could be beneficial for older kernel
> because you don't need to backport your patches but simply use your
> daemon which will be compatible with most kernel versions as libusb is
> working with them.

Sorry repeating comment in V1 thread.
I had to write this to change log.

There are 2 reasons.

1) Application(vhci_hcd) side is also needed

In my understanding, usbfs provides functions to control USB devices. 
So device(usbip_host) side can be done by usbfs but 
application(vhci_hcd) side cannot. My patch covers both 
device(usbip_host) and application(vhci_hcd) side. 
And it is quite the same in both side and works symmetrically.

2) Maintainability

Usbfs provides similar interfaces which USB core provides to USB host 
drives. To use the interfaces in user space, implementation which are 
included in some portions of usbip_host.ko and usbip_core should be 
copied to userspace. At the same time, utilities must be modified 
because interfaces used between the utilities and the kernel modules 
(sysfs) will be changed to function calls in userspace.

For example, I'd like to break down usbip_host.ko as below.
(a) submits and cancels URBs to USB core
(b) core part: receives and handle URBs, manage submitted URBs, etc.
(c) provides functions to utilities via sysfs
(d) calls usbip_common's functions
(e) calls kernel functions

To move it to user space,
(a) replace with usbfs calls
(b) copy the core part
(c) modify to interface inside userspace or use usbfs directly
(d) port some portion of usbip_core
(e) replace with systemcalls and libraries.

Then, to use usbfs (a), another usbip_host like program which has same 
for (b) and different in (c), (d) and (e). By (c), utilities should be 
changed unless sysfs emulation is not provided.

I think it's better to use the kernel modules as-is. Strictly, it's 
almost as-is because I put a small code to make replaceable 
kernel_sendmsg() and kernel_recvmsg().

As a reference, I stored my prototype including userspace usbip_host 
with libusb(not sysfs but a portable wrapper of sysfs) in staging/usbip 
of linux 3.14.2. It still needs refactoring.
https://drive.google.com/drive/folders/0BxnuWBW_tB9NflFDY1hlcVBRNEd4ZzB2
VFJ3OTI0REFGelNBV2xXTHRNc0lReGJlaTRGdDQ/0BxnuWBW_tB9NfjhabzVMSnZ6VGxrTXB
wNEE1dFJYdENvaC1IMUg1ZG1kTU9iOUN1OEpGUlU

In the prototype, libsrc/stub_main.c, stub_dev.c, stub_rx.c and 
stub_tx.c are portings of usbip_host. stub_common.c and stub_event.c is 
usbip_core. Macro USE_LIBUSB in utilities denotes portions to be 
modified in utilities.

My patch works in both host and vhci side using existing kernel modules.

Thank you for your comment,

n.iwata
//
N�r��yb�X��ǧv�^�)޺{.n�+{��^n�r���z���h�&���G���h�(�階�ݢj"���m��z�ޖ���f���h���~�m�

Re: [PATCH] usb: phy: rcar-gen2-usb: Fix USBHS_UGSTS_LOCK value

2015-04-28 Thread Geert Uytterhoeven
Hi Shimoda-san,

On Tue, Apr 28, 2015 at 3:36 AM, Yoshihiro Shimoda
 wrote:
>> Sent: Tuesday, April 28, 2015 4:45 AM
>> On Thu, Apr 02, 2015 at 08:22:34PM +0900, Yoshihiro Shimoda wrote:
>> > According to the technical update (No. TN-RCS-B011A/E), the UGSTS LOCK
>> > bit location is bit 8, not bits 9 and 8. So, this patch fixes the
>> > USBHS_UGSTS_LOCK value.
>> >
>> > Signed-off-by: Yoshihiro Shimoda 
>>
>> this doesn't apply to v4.1-rc1, if it's still needed, please rebase.
>
> Thank you for the notice. I found that this patch has been already merged in 
> v4.1-rc1 by Greg.

drivers/usb/phy/phy-rcar-gen2-usb.c (which supports legacy platform data only)
is unused since commit a483dcbfa21f919c ("ARM: shmobile: lager: Remove
legacy board support").

It's my understanding this driver has been replaced by a new driver, which
supports DT only (drivers/phy/phy-rcar-gen2.c).
That driver still has the wrong value:
#define USBHS_UGSTS_LOCK0x0300 /* The manuals have 0x3 */

So:
  1) Shouldn't drivers/phy/phy-rcar-gen2.c be fixed?
  2) Shouldn't drivers/usb/phy/phy-rcar-gen2-usb.c et al be removed?

Thanks!

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH] usb: phy: rcar-gen2-usb: Fix USBHS_UGSTS_LOCK value

2015-04-28 Thread Yoshihiro Shimoda
Hi Geert-san,

Thank you for your comment!

> Sent: Tuesday, April 28, 2015 6:55 PM
> 
> Hi Shimoda-san,
> 
> On Tue, Apr 28, 2015 at 3:36 AM, Yoshihiro Shimoda
>  wrote:
> >> Sent: Tuesday, April 28, 2015 4:45 AM
> >> On Thu, Apr 02, 2015 at 08:22:34PM +0900, Yoshihiro Shimoda wrote:
> >> > According to the technical update (No. TN-RCS-B011A/E), the UGSTS LOCK
> >> > bit location is bit 8, not bits 9 and 8. So, this patch fixes the
> >> > USBHS_UGSTS_LOCK value.
> >> >
> >> > Signed-off-by: Yoshihiro Shimoda 
> >>
> >> this doesn't apply to v4.1-rc1, if it's still needed, please rebase.
> >
> > Thank you for the notice. I found that this patch has been already merged 
> > in v4.1-rc1 by Greg.
> 
> drivers/usb/phy/phy-rcar-gen2-usb.c (which supports legacy platform data only)
> is unused since commit a483dcbfa21f919c ("ARM: shmobile: lager: Remove
> legacy board support").
> 
> It's my understanding this driver has been replaced by a new driver, which
> supports DT only (drivers/phy/phy-rcar-gen2.c).

Yes. You are correct.

> That driver still has the wrong value:
> #define USBHS_UGSTS_LOCK0x0300 /* The manuals have 0x3 */
> 
> So:
>   1) Shouldn't drivers/phy/phy-rcar-gen2.c be fixed?

I already submitted such a patch. However, the patch is not merged yet.
(I should have sent a ping or something about this patch.)
http://thread.gmane.org/gmane.linux.ports.sh.devel/45089

>   2) Shouldn't drivers/usb/phy/phy-rcar-gen2-usb.c et al be removed?

We should remove this code because legacy board codes were already removed.
(In other words, nobody uses this code now.)

Best regards,
Yoshihiro Shimoda

> Thanks!
> 
> Gr{oetje,eeting}s,
> 
> Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- 
> ge...@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like 
> that.
> -- Linus Torvalds


Re: [PATCH] usb: image: mdc800: fixed various style issues

2015-04-28 Thread Greg KH
On Thu, Apr 23, 2015 at 05:59:01PM -0600, Jason Eastman wrote:
> Fixed several style issues with: comments, function perenthesis,
> indentation, and conditional braces
> 
> Signed-off-by: Jason Eastman 
> ---
>  drivers/usb/image/mdc800.c |  769 
> +++-
>  1 file changed, 336 insertions(+), 433 deletions(-)

That's a lot to fix all at "once", please break this up in to different
patches, each one only doing one thing at a time.

thanks,

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


Re: [PATCH] usb: core: add usb3 lpm sysfs

2015-04-28 Thread Greg KH
On Sun, Apr 19, 2015 at 11:46:12AM +0800, Zhuang Jin Can wrote:
> Some usb3 devices may not support usb3 lpm well.
> The patch adds a sysfs to enable/disable u1 or u2 of the port.The
> settings apply to both before and after device enumeration.
> Supported values are "0" - u1 and u2 are disabled, "u1" - only u1 is
> enabled, "u2" - only u2 is enabled, "u1_u2" - u1 and u2 are enabled.
> 
> The interface is useful for testing some USB3 devices during
> development, and provides a way to disable usb3 lpm if the issues can
> not be fixed in final products.

How is a user supposed to "know" to make this setting for a device?  Why
can't the kernel automatically set this value properly?  Why does it
need to be a kernel issue at all?

And when you are doing development of broken devices, the kernel doesn't
have to support you, you can run with debugging patches of your own
until you fix your firmware :)

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] drivers/usb/core: devio.c: Removed various errors and warnings generated by checkpatch.pl

2015-04-28 Thread Greg KH
On Sat, Apr 11, 2015 at 10:20:38AM -0700, Joe Perches wrote:
> On Sat, 2015-04-11 at 00:53 -0700, Chase Metzger wrote:
> > Fixed several errors and warnings.
> []
> > Lines 1040 and 1591: changed dev_printk(KERN_DEBUG, ...) to dev_dbg(...).
> 
> These changes hav the possibly undesired effect of
> removing these messages completely when DEBUG is not
> #defined or when CONFIG_DYNAMIC_DEBUG is not enabled
> and these messages are not specifically enabled.

That's ok, we can live with that :)

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] drivers/usb/core: hcd.c: Removed BitTime space warnings

2015-04-28 Thread Greg KH
On Sat, Apr 11, 2015 at 05:51:21PM -0700, Chase Metzger wrote:
> Removed BitTime macro space warnings generated by checkpatch.pl.
> 
> Signed-off-by: Chase Metzger 
> ---
>  drivers/usb/core/hcd.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)

You sent a bunch of patches, yet didn't tell me what order to apply them
in :(

Can you redo these as a patch series, properly numbered, so that I have
a clue as to what order they should go in?

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 3/3] Usb: core: buffer: fixed the checkpatch warning

2015-04-28 Thread Greg KH
On Sat, Apr 18, 2015 at 08:22:36PM +0530, Nizam Haider wrote:
> Fixed two warnings sizeof name and clank line after declaration

"clank"?

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


Re: [PATCH] usb: phy: rcar-gen2-usb: Fix USBHS_UGSTS_LOCK value

2015-04-28 Thread Geert Uytterhoeven
Hi Shimoda-san,

On Tue, Apr 28, 2015 at 12:25 PM, Yoshihiro Shimoda
 wrote:
>> Sent: Tuesday, April 28, 2015 6:55 PM
>> On Tue, Apr 28, 2015 at 3:36 AM, Yoshihiro Shimoda
>>  wrote:
>> >> Sent: Tuesday, April 28, 2015 4:45 AM
>> >> On Thu, Apr 02, 2015 at 08:22:34PM +0900, Yoshihiro Shimoda wrote:
>> >> > According to the technical update (No. TN-RCS-B011A/E), the UGSTS LOCK
>> >> > bit location is bit 8, not bits 9 and 8. So, this patch fixes the
>> >> > USBHS_UGSTS_LOCK value.
>> >> >
>> >> > Signed-off-by: Yoshihiro Shimoda 
>> >>
>> >> this doesn't apply to v4.1-rc1, if it's still needed, please rebase.
>> >
>> > Thank you for the notice. I found that this patch has been already merged 
>> > in v4.1-rc1 by Greg.
>>
>> drivers/usb/phy/phy-rcar-gen2-usb.c (which supports legacy platform data 
>> only)
>> is unused since commit a483dcbfa21f919c ("ARM: shmobile: lager: Remove
>> legacy board support").
>>
>> It's my understanding this driver has been replaced by a new driver, which
>> supports DT only (drivers/phy/phy-rcar-gen2.c).
>
> Yes. You are correct.
>
>> That driver still has the wrong value:
>> #define USBHS_UGSTS_LOCK0x0300 /* The manuals have 0x3 */
>>
>> So:
>>   1) Shouldn't drivers/phy/phy-rcar-gen2.c be fixed?
>
> I already submitted such a patch. However, the patch is not merged yet.
> (I should have sent a ping or something about this patch.)
> http://thread.gmane.org/gmane.linux.ports.sh.devel/45089

Right. Sorry, I forgot about that patch.

>>   2) Shouldn't drivers/usb/phy/phy-rcar-gen2-usb.c et al be removed?
>
> We should remove this code because legacy board codes were already removed.
> (In other words, nobody uses this code now.)

I'll remove it, while you can enjoy Golden Week...

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: gadget: ether: Fix MAC address parsing

2015-04-28 Thread Stefan Agner
MAC addresses can be written without leading zeros. A popular
example is libc's ether_ntoa_r function which creates such
MAC addresses.

Example:
00:14:3d:0f:ff:fe can be written as 0:14:3d:f:ff:fe

Additionally, get_ether_addr potentially parsed past the end
of the user provided string. Use the opportunity and fix the
function to never parse beyond the end of the string while
allowing MAC addresses with and without leading zeros.

Signed-off-by: Stefan Agner 
---
 drivers/usb/gadget/function/u_ether.c | 41 +--
 1 file changed, 25 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/gadget/function/u_ether.c 
b/drivers/usb/gadget/function/u_ether.c
index f1fd777..9994645 100644
--- a/drivers/usb/gadget/function/u_ether.c
+++ b/drivers/usb/gadget/function/u_ether.c
@@ -705,23 +705,27 @@ static int eth_stop(struct net_device *net)
 
 static int get_ether_addr(const char *str, u8 *dev_addr)
 {
-   if (str) {
-   unsignedi;
+   int num, i = 0;
+   char c = *str;
 
-   for (i = 0; i < 6; i++) {
-   unsigned char num;
-
-   if ((*str == '.') || (*str == ':'))
-   str++;
-   num = hex_to_bin(*str++) << 4;
-   num |= hex_to_bin(*str++);
-   dev_addr [i] = num;
+   dev_addr[i] = 0;
+   while (c && i < ETH_ALEN) {
+   if (c == '.' || c == ':') {
+   dev_addr[++i] = 0;
+   } else {
+   num = hex_to_bin(c);
+   if (num < 0)
+   break;
+   dev_addr[i] <<= 4;
+   dev_addr[i] |= num;
}
-   if (is_valid_ether_addr(dev_addr))
-   return 0;
+   c = *++str;
}
-   eth_random_addr(dev_addr);
-   return 1;
+
+   if ((i + 1) != ETH_ALEN || !is_valid_ether_addr(dev_addr))
+   return -EINVAL;
+
+   return 0;
 }
 
 static int get_ether_addr_str(u8 dev_addr[ETH_ALEN], char *str, int len)
@@ -786,12 +790,17 @@ struct eth_dev *gether_setup_name(struct usb_gadget *g,
dev->qmult = qmult;
snprintf(net->name, sizeof(net->name), "%s%%d", netname);
 
-   if (get_ether_addr(dev_addr, net->dev_addr))
+   if (get_ether_addr(dev_addr, net->dev_addr)) {
+   eth_random_addr(net->dev_addr);
dev_warn(&g->dev,
"using random %s ethernet address\n", "self");
-   if (get_ether_addr(host_addr, dev->host_mac))
+   }
+
+   if (get_ether_addr(host_addr, dev->host_mac)) {
+   eth_random_addr(dev->host_mac);
dev_warn(&g->dev,
"using random %s ethernet address\n", "host");
+   }
 
if (ethaddr)
memcpy(ethaddr, dev->host_mac, ETH_ALEN);
-- 
2.3.6

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


[PATCH] usb: phy: Remove the phy-rcar-gen2-usb driver

2015-04-28 Thread Geert Uytterhoeven
The phy-rcar-gen2-usb driver, which supports legacy platform data only,
is no longer used since commit a483dcbfa21f919c ("ARM: shmobile: lager:
Remove legacy board support").

This driver was superseded by the DT-only phy-rcar-gen2 driver, which
was introduced in commit 1233f59f745b237d ("phy: Renesas R-Car Gen2 PHY
driver").

Signed-off-by: Geert Uytterhoeven 
---
 drivers/usb/phy/Kconfig |  13 --
 drivers/usb/phy/Makefile|   1 -
 drivers/usb/phy/phy-rcar-gen2-usb.c | 246 
 include/linux/platform_data/usb-rcar-gen2-phy.h |  22 ---
 4 files changed, 282 deletions(-)
 delete mode 100644 drivers/usb/phy/phy-rcar-gen2-usb.c
 delete mode 100644 include/linux/platform_data/usb-rcar-gen2-phy.h

diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 2175678e674ebf44..3cd3bee54ca6f9b3 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -186,19 +186,6 @@ config USB_RCAR_PHY
  To compile this driver as a module, choose M here: the
  module will be called phy-rcar-usb.
 
-config USB_RCAR_GEN2_PHY
-   tristate "Renesas R-Car Gen2 USB PHY support"
-   depends on ARCH_R8A7790 || ARCH_R8A7791 || COMPILE_TEST
-   select USB_PHY
-   help
- Say Y here to add support for the Renesas R-Car Gen2 USB PHY driver.
- It is typically used to control internal USB PHY for USBHS,
- and to configure shared USB channels 0 and 2.
- This driver supports R8A7790 and R8A7791.
-
- To compile this driver as a module, choose M here: the
- module will be called phy-rcar-gen2-usb.
-
 config USB_ULPI
bool "Generic ULPI Transceiver Driver"
depends on ARM || ARM64
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index 75f2bba58c84c9d4..e36ab1d46d8b4fed 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -23,7 +23,6 @@ obj-$(CONFIG_USB_MSM_OTG) += phy-msm-usb.o
 obj-$(CONFIG_USB_MV_OTG)   += phy-mv-usb.o
 obj-$(CONFIG_USB_MXS_PHY)  += phy-mxs-usb.o
 obj-$(CONFIG_USB_RCAR_PHY) += phy-rcar-usb.o
-obj-$(CONFIG_USB_RCAR_GEN2_PHY)+= phy-rcar-gen2-usb.o
 obj-$(CONFIG_USB_ULPI) += phy-ulpi.o
 obj-$(CONFIG_USB_ULPI_VIEWPORT)+= phy-ulpi-viewport.o
 obj-$(CONFIG_KEYSTONE_USB_PHY) += phy-keystone.o
diff --git a/drivers/usb/phy/phy-rcar-gen2-usb.c 
b/drivers/usb/phy/phy-rcar-gen2-usb.c
deleted file mode 100644
index f81800b6562a46a8..
--- a/drivers/usb/phy/phy-rcar-gen2-usb.c
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Renesas R-Car Gen2 USB phy driver
- *
- * Copyright (C) 2013 Renesas Solutions Corp.
- * Copyright (C) 2013 Cogent Embedded, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-struct rcar_gen2_usb_phy_priv {
-   struct usb_phy phy;
-   void __iomem *base;
-   struct clk *clk;
-   spinlock_t lock;
-   int usecount;
-   u32 ugctrl2;
-};
-
-#define usb_phy_to_priv(p) container_of(p, struct rcar_gen2_usb_phy_priv, phy)
-
-/* Low Power Status register */
-#define USBHS_LPSTS_REG0x02
-#define USBHS_LPSTS_SUSPM  (1 << 14)
-
-/* USB General control register */
-#define USBHS_UGCTRL_REG   0x80
-#define USBHS_UGCTRL_CONNECT   (1 << 2)
-#define USBHS_UGCTRL_PLLRESET  (1 << 0)
-
-/* USB General control register 2 */
-#define USBHS_UGCTRL2_REG  0x84
-#define USBHS_UGCTRL2_USB0_PCI (1 << 4)
-#define USBHS_UGCTRL2_USB0_HS  (3 << 4)
-#define USBHS_UGCTRL2_USB2_PCI (0 << 31)
-#define USBHS_UGCTRL2_USB2_SS  (1 << 31)
-
-/* USB General status register */
-#define USBHS_UGSTS_REG0x88
-#define USBHS_UGSTS_LOCK   (1 << 8)
-
-/* Enable USBHS internal phy */
-static int __rcar_gen2_usbhs_phy_enable(void __iomem *base)
-{
-   u32 val;
-   int i;
-
-   /* USBHS PHY power on */
-   val = ioread32(base + USBHS_UGCTRL_REG);
-   val &= ~USBHS_UGCTRL_PLLRESET;
-   iowrite32(val, base + USBHS_UGCTRL_REG);
-
-   val = ioread16(base + USBHS_LPSTS_REG);
-   val |= USBHS_LPSTS_SUSPM;
-   iowrite16(val, base + USBHS_LPSTS_REG);
-
-   for (i = 0; i < 20; i++) {
-   val = ioread32(base + USBHS_UGSTS_REG);
-   if ((val & USBHS_UGSTS_LOCK) == USBHS_UGSTS_LOCK) {
-   val = ioread32(base + USBHS_UGCTRL_REG);
-   val |= USBHS_UGCTRL_CONNECT;
-   iowrite32(val, base + USBHS_UGCTRL_REG);
-   return 0;
-   }
-   udelay(1);
-   }
-
-   /* Timed out waiting f

[PATCHv3 02/11] usb: dwc3: USB2 PHY register access bits

2015-04-28 Thread Heikki Krogerus
Definitions for Global USB2 PHY Vendor Control Register
bits. We will need them to access ULPI PHY registers later.

Signed-off-by: Heikki Krogerus 
Acked-by: David Cohen 
---
 drivers/usb/dwc3/core.h | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index fdab715..747805d 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -174,6 +174,14 @@
 #define DWC3_GUSB2PHYCFG_PHYSOFTRST(1 << 31)
 #define DWC3_GUSB2PHYCFG_SUSPHY(1 << 6)
 
+/* Global USB2 PHY Vendor Control Register */
+#define DWC3_GUSB2PHYACC_NEWREGREQ (1 << 25)
+#define DWC3_GUSB2PHYACC_BUSY  (1 << 23)
+#define DWC3_GUSB2PHYACC_WRITE (1 << 22)
+#define DWC3_GUSB2PHYACC_ADDR(n)   (n << 16)
+#define DWC3_GUSB2PHYACC_EXTEND_ADDR(n)(n << 8)
+#define DWC3_GUSB2PHYACC_DATA(n)   (n & 0xff)
+
 /* Global USB3 PIPE Control Register */
 #define DWC3_GUSB3PIPECTL_PHYSOFTRST   (1 << 31)
 #define DWC3_GUSB3PIPECTL_U2SSINP3OK   (1 << 29)
-- 
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


[PATCHv3 10/11] phy: helpers for USB ULPI PHY registering

2015-04-28 Thread Heikki Krogerus
ULPI PHYs need to be bound to their controllers with a
lookup. This adds helpers that the ULPI drivers can use to
do both, the registration of the PHY and the lookup, at the
same time.

Signed-off-by: Heikki Krogerus 
Acked-by: David Cohen 
Cc: Kishon Vijay Abraham I 
---
 drivers/phy/ulpi_phy.h | 31 +++
 1 file changed, 31 insertions(+)
 create mode 100644 drivers/phy/ulpi_phy.h

diff --git a/drivers/phy/ulpi_phy.h b/drivers/phy/ulpi_phy.h
new file mode 100644
index 000..ac49fb6
--- /dev/null
+++ b/drivers/phy/ulpi_phy.h
@@ -0,0 +1,31 @@
+#include 
+
+/**
+ * Helper that registers PHY for a ULPI device and adds a lookup for binding it
+ * and it's controller, which is always the parent.
+ */
+static inline struct phy
+*ulpi_phy_create(struct ulpi *ulpi, struct phy_ops *ops)
+{
+   struct phy *phy;
+   int ret;
+
+   phy = phy_create(&ulpi->dev, NULL, ops);
+   if (IS_ERR(phy))
+   return phy;
+
+   ret = phy_create_lookup(phy, "usb2-phy", dev_name(ulpi->dev.parent));
+   if (ret) {
+   phy_destroy(phy);
+   return ERR_PTR(ret);
+   }
+
+   return phy;
+}
+
+/* Remove a PHY that was created with ulpi_phy_create() and it's lookup. */
+static inline void ulpi_phy_destroy(struct ulpi *ulpi, struct phy *phy)
+{
+   phy_remove_lookup(phy, "usb2-phy", dev_name(ulpi->dev.parent));
+   phy_destroy(phy);
+}
-- 
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


[PATCHv3 07/11] usb: dwc3: setup phys earlier

2015-04-28 Thread Heikki Krogerus
This allows dwc3_phy_setup() to be more useful later. There
is nothing preventing the PHY configuration registers from
being programmed early. They do not loose their context in
soft reset.

There are however other PHY related operations that should
be executed before the driver request handles to the PHYs,
such as registering DWC3's ULPI interface, which can now be
done in dwc3_phy_setup().

Also, if there ever was need for the two 100ms delays in
dwc3_phy_setup() there isn't anymore. The PHYs are now reset
after the PHY interfaces are setup.

Signed-off-by: Heikki Krogerus 
Acked-by: David Cohen 
---
 drivers/usb/dwc3/core.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 921f181..6b02e12 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -436,8 +436,6 @@ static void dwc3_phy_setup(struct dwc3 *dwc)
 
dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
 
-   mdelay(100);
-
reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
 
/*
@@ -453,8 +451,6 @@ static void dwc3_phy_setup(struct dwc3 *dwc)
reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;
 
dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
-
-   mdelay(100);
 }
 
 /**
@@ -569,8 +565,6 @@ static int dwc3_core_init(struct dwc3 *dwc)
 
dwc3_writel(dwc->regs, DWC3_GCTL, reg);
 
-   dwc3_phy_setup(dwc);
-
ret = dwc3_alloc_scratch_buffers(dwc);
if (ret)
goto err1;
@@ -892,6 +886,8 @@ static int dwc3_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, dwc);
dwc3_cache_hwparams(dwc);
 
+   dwc3_phy_setup(dwc);
+
ret = dwc3_core_get_phy(dwc);
if (ret)
goto err0;
-- 
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


[PATCHv3 11/11] phy: add driver for TI TUSB1210 ULPI PHY

2015-04-28 Thread Heikki Krogerus
TUSB1210 ULPI PHY has vendor specific register for eye
diagram tuning. On some platforms the system firmware has
set optimized value to it. In order to not loose the
optimized value, the driver stores it during probe and
restores it every time the PHY is powered back on.

Signed-off-by: Heikki Krogerus 
Acked-by: David Cohen 
Cc: Kishon Vijay Abraham I 
---
 drivers/phy/Kconfig|   7 +++
 drivers/phy/Makefile   |   1 +
 drivers/phy/phy-tusb1210.c | 153 +
 3 files changed, 161 insertions(+)
 create mode 100644 drivers/phy/phy-tusb1210.c

diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index a53bd5b..fceac96 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -309,4 +309,11 @@ config PHY_QCOM_UFS
help
  Support for UFS PHY on QCOM chipsets.
 
+config PHY_TUSB1210
+   tristate "TI TUSB1210 ULPI PHY module"
+   depends on USB_ULPI_BUS
+   select GENERIC_PHY
+   help
+ Support for TI TUSB1210 USB ULPI PHY.
+
 endmenu
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index f126251..0a20418 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -40,3 +40,4 @@ obj-$(CONFIG_PHY_STIH41X_USB) += phy-stih41x-usb.o
 obj-$(CONFIG_PHY_QCOM_UFS) += phy-qcom-ufs.o
 obj-$(CONFIG_PHY_QCOM_UFS) += phy-qcom-ufs-qmp-20nm.o
 obj-$(CONFIG_PHY_QCOM_UFS) += phy-qcom-ufs-qmp-14nm.o
+obj-$(CONFIG_PHY_TUSB1210) += phy-tusb1210.o
diff --git a/drivers/phy/phy-tusb1210.c b/drivers/phy/phy-tusb1210.c
new file mode 100644
index 000..07efdd3
--- /dev/null
+++ b/drivers/phy/phy-tusb1210.c
@@ -0,0 +1,153 @@
+/**
+ * tusb1210.c - TUSB1210 USB ULPI PHY driver
+ *
+ * Copyright (C) 2015 Intel Corporation
+ *
+ * Author: Heikki Krogerus 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include 
+#include 
+#include 
+
+#include "ulpi_phy.h"
+
+#define TUSB1210_VENDOR_SPECIFIC2  0x80
+#define TUSB1210_VENDOR_SPECIFIC2_IHSTX_SHIFT  0
+#define TUSB1210_VENDOR_SPECIFIC2_ZHSDRV_SHIFT 4
+#define TUSB1210_VENDOR_SPECIFIC2_DP_SHIFT 6
+
+struct tusb1210 {
+   struct ulpi *ulpi;
+   struct phy *phy;
+   struct gpio_desc *gpio_reset;
+   struct gpio_desc *gpio_cs;
+   u8 vendor_specific2;
+};
+
+static int tusb1210_power_on(struct phy *phy)
+{
+   struct tusb1210 *tusb = phy_get_drvdata(phy);
+
+   gpiod_set_value_cansleep(tusb->gpio_reset, 1);
+   gpiod_set_value_cansleep(tusb->gpio_cs, 1);
+
+   /* Restore the optional eye diagram optimization value */
+   if (tusb->vendor_specific2)
+   ulpi_write(tusb->ulpi, TUSB1210_VENDOR_SPECIFIC2,
+  tusb->vendor_specific2);
+
+   return 0;
+}
+
+static int tusb1210_power_off(struct phy *phy)
+{
+   struct tusb1210 *tusb = phy_get_drvdata(phy);
+
+   gpiod_set_value_cansleep(tusb->gpio_reset, 0);
+   gpiod_set_value_cansleep(tusb->gpio_cs, 0);
+
+   return 0;
+}
+
+static struct phy_ops phy_ops = {
+   .power_on = tusb1210_power_on,
+   .power_off = tusb1210_power_off,
+   .owner = THIS_MODULE,
+};
+
+static int tusb1210_probe(struct ulpi *ulpi)
+{
+   struct gpio_desc *gpio;
+   struct tusb1210 *tusb;
+   u8 val, reg;
+   int ret;
+
+   tusb = devm_kzalloc(&ulpi->dev, sizeof(*tusb), GFP_KERNEL);
+   if (!tusb)
+   return -ENOMEM;
+
+   gpio = devm_gpiod_get(&ulpi->dev, "reset");
+   if (!IS_ERR(gpio)) {
+   ret = gpiod_direction_output(gpio, 0);
+   if (ret)
+   return ret;
+   gpiod_set_value_cansleep(gpio, 1);
+   tusb->gpio_reset = gpio;
+   }
+
+   gpio = devm_gpiod_get(&ulpi->dev, "cs");
+   if (!IS_ERR(gpio)) {
+   ret = gpiod_direction_output(gpio, 0);
+   if (ret)
+   return ret;
+   gpiod_set_value_cansleep(gpio, 1);
+   tusb->gpio_cs = gpio;
+   }
+
+   /*
+* VENDOR_SPECIFIC2 register in TUSB1210 can be used for configuring eye
+* diagram optimization and DP/DM swap.
+*/
+
+   /* High speed output drive strength configuration */
+   device_property_read_u8(&ulpi->dev, "ihstx", &val);
+   reg = val << TUSB1210_VENDOR_SPECIFIC2_IHSTX_SHIFT;
+
+   /* High speed output impedance configuration */
+   device_property_read_u8(&ulpi->dev, "zhsdrv", &val);
+   reg |= val << TUSB1210_VENDOR_SPECIFIC2_ZHSDRV_SHIFT;
+
+   /* DP/DM swap control */
+   device_property_read_u8(&ulpi->dev, "datapolarity", &val);
+   reg |= val << TUSB1210_VENDOR_SPECIFIC2_DP_SHIFT;
+
+   if (reg) {
+   ulpi_write(ulpi, TUSB1210_VENDOR_SPECIFIC2, reg);
+   tusb->vendor_specific2 = reg;
+   }
+
+   tusb->phy = ulpi_ph

[PATCHv3 09/11] usb: dwc3: pci: add quirk for Baytrails

2015-04-28 Thread Heikki Krogerus
On some BYT platforms the USB2 PHY needs to be put into
operational mode by the controller driver with GPIOs
controlling the PHYs reset and cs signals.

Signed-off-by: Heikki Krogerus 
---
 drivers/usb/dwc3/dwc3-pci.c | 36 
 1 file changed, 36 insertions(+)

diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
index b773fb5..0235f46 100644
--- a/drivers/usb/dwc3/dwc3-pci.c
+++ b/drivers/usb/dwc3/dwc3-pci.c
@@ -21,6 +21,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include "platform_data.h"
 
@@ -31,6 +33,15 @@
 #define PCI_DEVICE_ID_INTEL_SPTLP  0x9d30
 #define PCI_DEVICE_ID_INTEL_SPTH   0xa130
 
+static const struct acpi_gpio_params reset_gpios = { 0, 0, false };
+static const struct acpi_gpio_params cs_gpios = { 1, 0, false };
+
+static const struct acpi_gpio_mapping acpi_dwc3_byt_gpios[] = {
+   { "reset-gpios", &reset_gpios, 1 },
+   { "cs-gpios", &cs_gpios, 1 },
+   { },
+};
+
 static int dwc3_pci_quirks(struct pci_dev *pdev)
 {
if (pdev->vendor == PCI_VENDOR_ID_AMD &&
@@ -65,6 +76,30 @@ static int dwc3_pci_quirks(struct pci_dev *pdev)
sizeof(pdata));
}
 
+   if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
+   pdev->device == PCI_DEVICE_ID_INTEL_BYT) {
+   struct gpio_desc *gpio;
+
+   acpi_dev_add_driver_gpios(ACPI_COMPANION(&pdev->dev),
+ acpi_dwc3_byt_gpios);
+
+   /* These GPIOs will turn on the USB2 PHY */
+   gpio = gpiod_get(&pdev->dev, "cs");
+   if (!IS_ERR(gpio)) {
+   gpiod_direction_output(gpio, 0);
+   gpiod_set_value_cansleep(gpio, 1);
+   gpiod_put(gpio);
+   }
+
+   gpio = gpiod_get(&pdev->dev, "reset");
+   if (!IS_ERR(gpio)) {
+   gpiod_direction_output(gpio, 0);
+   gpiod_set_value_cansleep(gpio, 1);
+   gpiod_put(gpio);
+   msleep(10);
+   }
+   }
+
return 0;
 }
 
@@ -128,6 +163,7 @@ err:
 
 static void dwc3_pci_remove(struct pci_dev *pci)
 {
+   acpi_dev_remove_driver_gpios(ACPI_COMPANION(&pci->dev));
platform_device_unregister(pci_get_drvdata(pci));
 }
 
-- 
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


[PATCHv3 06/11] usb: dwc3: soft reset to it's own function

2015-04-28 Thread Heikki Krogerus
So it can be called from other places later.

Signed-off-by: Heikki Krogerus 
Acked-by: David Cohen 
---
 drivers/usb/dwc3/core.c | 46 ++
 1 file changed, 30 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 104b236..921f181 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -117,6 +117,33 @@ static int dwc3_core_soft_reset(struct dwc3 *dwc)
 }
 
 /**
+ * dwc3_soft_reset - Issue soft reset
+ * @dwc: Pointer to our controller context structure
+ */
+static int dwc3_soft_reset(struct dwc3 *dwc)
+{
+   unsigned long timeout;
+   u32 reg;
+
+   timeout = jiffies + msecs_to_jiffies(500);
+   dwc3_writel(dwc->regs, DWC3_DCTL, DWC3_DCTL_CSFTRST);
+   do {
+   reg = dwc3_readl(dwc->regs, DWC3_DCTL);
+   if (!(reg & DWC3_DCTL_CSFTRST))
+   break;
+
+   if (time_after(jiffies, timeout)) {
+   dev_err(dwc->dev, "Reset Timed Out\n");
+   return -ETIMEDOUT;
+   }
+
+   cpu_relax();
+   } while (true);
+
+   return 0;
+}
+
+/**
  * dwc3_free_one_event_buffer - Frees one event buffer
  * @dwc: Pointer to our controller context structure
  * @evt: Pointer to event buffer to be freed
@@ -438,7 +465,6 @@ static void dwc3_phy_setup(struct dwc3 *dwc)
  */
 static int dwc3_core_init(struct dwc3 *dwc)
 {
-   unsigned long   timeout;
u32 hwparams4 = dwc->hwparams.hwparams4;
u32 reg;
int ret;
@@ -466,21 +492,9 @@ static int dwc3_core_init(struct dwc3 *dwc)
}
 
/* issue device SoftReset too */
-   timeout = jiffies + msecs_to_jiffies(500);
-   dwc3_writel(dwc->regs, DWC3_DCTL, DWC3_DCTL_CSFTRST);
-   do {
-   reg = dwc3_readl(dwc->regs, DWC3_DCTL);
-   if (!(reg & DWC3_DCTL_CSFTRST))
-   break;
-
-   if (time_after(jiffies, timeout)) {
-   dev_err(dwc->dev, "Reset Timed Out\n");
-   ret = -ETIMEDOUT;
-   goto err0;
-   }
-
-   cpu_relax();
-   } while (true);
+   ret = dwc3_soft_reset(dwc);
+   if (ret)
+   goto err0;
 
ret = dwc3_core_soft_reset(dwc);
if (ret)
-- 
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


[PATCHv3 08/11] usb: dwc3: add hsphy_interface property

2015-04-28 Thread Heikki Krogerus
Platforms that have configured DWC_USB3_HSPHY_INTERFACE with
value 3, i.e. UTMI+ and ULPI, need to inform the driver of
the actual HSPHY interface type with the property. "utmi" if
the interface is UTMI+ or "ulpi" if the interface is ULPI.

Signed-off-by: Heikki Krogerus 
Acked-by: David Cohen 
---
 Documentation/devicetree/bindings/usb/dwc3.txt |  2 ++
 drivers/usb/dwc3/core.c| 29 --
 drivers/usb/dwc3/core.h|  3 +++
 drivers/usb/dwc3/platform_data.h   |  2 ++
 4 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt 
b/Documentation/devicetree/bindings/usb/dwc3.txt
index 5cc3643..0815eac 100644
--- a/Documentation/devicetree/bindings/usb/dwc3.txt
+++ b/Documentation/devicetree/bindings/usb/dwc3.txt
@@ -38,6 +38,8 @@ Optional properties:
  - snps,is-utmi-l1-suspend: true when DWC3 asserts output signal
utmi_l1_suspend_n, false when asserts utmi_sleep_n
  - snps,hird-threshold: HIRD threshold
+ - snps,hsphy_interface: High-Speed PHY interface selection between "utmi" for
+   UTMI+ and "ulpi" for ULPI when the DWC_USB3_HSPHY_INTERFACE has value 3.
 
 This is usually a subnode to DWC3 glue to which it is connected.
 
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 6b02e12..b229ba1 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -395,9 +395,10 @@ static void dwc3_cache_hwparams(struct dwc3 *dwc)
  * dwc3_phy_setup - Configure USB PHY Interface of DWC3 Core
  * @dwc: Pointer to our controller context structure
  */
-static void dwc3_phy_setup(struct dwc3 *dwc)
+static int dwc3_phy_setup(struct dwc3 *dwc)
 {
u32 reg;
+   int ret;
 
reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
 
@@ -438,6 +439,22 @@ static void dwc3_phy_setup(struct dwc3 *dwc)
 
reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
 
+   /* Select the HS PHY interface */
+   switch (DWC3_GHWPARAMS3_HSPHY_IFC(dwc->hwparams.hwparams3)) {
+   case DWC3_GHWPARAMS3_HSPHY_IFC_UTMI_ULPI:
+   if (!strncmp(dwc->hsphy_interface, "utmi", 4)) {
+   reg &= ~DWC3_GUSB2PHYCFG_ULPI_UTMI;
+   } else if (!strncmp(dwc->hsphy_interface, "ulpi", 4)) {
+   reg |= DWC3_GUSB2PHYCFG_ULPI_UTMI;
+   } else {
+   dev_err(dwc->dev, "HSPHY Interface not defined\n");
+   return -EINVAL;
+   }
+   /* FALLTHROUGH */
+   default:
+   break;
+   }
+
/*
 * Above 1.94a, it is recommended to set DWC3_GUSB2PHYCFG_SUSPHY to
 * '0' during coreConsultant configuration. So default value will
@@ -451,6 +468,8 @@ static void dwc3_phy_setup(struct dwc3 *dwc)
reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;
 
dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
+
+   return 0;
 }
 
 /**
@@ -844,6 +863,8 @@ static int dwc3_probe(struct platform_device *pdev)
"snps,tx_de_emphasis_quirk");
of_property_read_u8(node, "snps,tx_de_emphasis",
&tx_de_emphasis);
+   of_property_read_string(node, "snps,hsphy_interface",
+   &dwc->hsphy_interface);
} else if (pdata) {
dwc->maximum_speed = pdata->maximum_speed;
dwc->has_lpm_erratum = pdata->has_lpm_erratum;
@@ -871,6 +892,8 @@ static int dwc3_probe(struct platform_device *pdev)
dwc->tx_de_emphasis_quirk = pdata->tx_de_emphasis_quirk;
if (pdata->tx_de_emphasis)
tx_de_emphasis = pdata->tx_de_emphasis;
+
+   dwc->hsphy_interface = pdata->hsphy_interface;
}
 
/* default to superspeed if no maximum_speed passed */
@@ -886,7 +909,9 @@ static int dwc3_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, dwc);
dwc3_cache_hwparams(dwc);
 
-   dwc3_phy_setup(dwc);
+   ret = dwc3_phy_setup(dwc);
+   if (ret)
+   goto err0;
 
ret = dwc3_core_get_phy(dwc);
if (ret)
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index c6eafaa..7b3ab64 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -682,6 +682,7 @@ struct dwc3_scratchpad_array {
  * @test_mode_nr: test feature selector
  * @lpm_nyet_threshold: LPM NYET response threshold
  * @hird_threshold: HIRD threshold
+ * @hsphy_interface: "utmi" or "ulpi"
  * @delayed_status: true when gadget driver asks for delayed status
  * @ep0_bounced: true when we used bounce buffer
  * @ep0_expect_in: true when we expect a DATA IN transfer
@@ -809,6 +810,8 @@ struct dwc3 {
u8  lpm_nyet_threshold;
u8  hird_threshold;
 
+   const char  *hsphy_interface;
+
unsigneddel

[PATCHv3 05/11] usb: dwc3: cache hwparams earlier

2015-04-28 Thread Heikki Krogerus
So they are available when ULPI interface support is added.

Signed-off-by: Heikki Krogerus 
Acked-by: David Cohen 
---
 drivers/usb/dwc3/core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index c7734ed..104b236 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -876,6 +876,7 @@ static int dwc3_probe(struct platform_device *pdev)
| (dwc->is_utmi_l1_suspend << 4);
 
platform_set_drvdata(pdev, dwc);
+   dwc3_cache_hwparams(dwc);
 
ret = dwc3_core_get_phy(dwc);
if (ret)
@@ -893,8 +894,6 @@ static int dwc3_probe(struct platform_device *pdev)
pm_runtime_get_sync(dev);
pm_runtime_forbid(dev);
 
-   dwc3_cache_hwparams(dwc);
-
ret = dwc3_alloc_event_buffers(dwc, DWC3_EVENT_BUFFERS_SIZE);
if (ret) {
dev_err(dwc->dev, "failed to allocate event buffers\n");
-- 
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


[PATCHv3 00/12] usb: ulpi bus

2015-04-28 Thread Heikki Krogerus
Hi,

I took the liberty of adding David's ACK to everything except 9/12, including to
the 1/12 (removing the module handling has no functional affect).

Changes since v2:
- remove module handling from the bus driver as suggested by Paul Bolle.
- reordered the gpio requests in BYT quirk as suggested by David Cohen.

Major changes since v1:
- calling dwc3_phy_setup earlier and registering the ULPI interface there.
- new property to dwc3 for selecting the interface in case of UTMI+ and ULPI as
  suggested by Felipe
- dwc3 soft reset before registration of the ULPI interface to sync the clocks
  as suggested by David
- Including support for the BYT boards that have the GPIOs controlling the reset
  and cs signals.

Heikki Krogerus (12):
  usb: add bus type for USB ULPI
  usb: dwc3: USB2 PHY register access bits
  usb: dwc3: ULPI or UTMI+ select
  usb: dwc3: store driver data earlier
  usb: dwc3: cache hwparams earlier
  usb: dwc3: soft reset to it's own function
  usb: dwc3: setup phys earlier
  usb: dwc3: add hsphy_interface property
  usb: dwc3: pci: add quirk for Baytrails
  usb: dwc3: add ULPI interface support
  phy: helpers for USB ULPI PHY registering
  phy: add driver for TI TUSB1210 ULPI PHY

 Documentation/devicetree/bindings/usb/dwc3.txt |   2 +
 MAINTAINERS|   7 +
 drivers/phy/Kconfig|   7 +
 drivers/phy/Makefile   |   1 +
 drivers/phy/phy-tusb1210.c | 153 +++
 drivers/phy/ulpi_phy.h |  31 
 drivers/usb/common/Makefile|   1 +
 drivers/usb/common/ulpi.c  | 246 +
 drivers/usb/core/Kconfig   |   8 +
 drivers/usb/dwc3/Kconfig   |   7 +
 drivers/usb/dwc3/Makefile  |   4 +
 drivers/usb/dwc3/core.c|  99 +++---
 drivers/usb/dwc3/core.h|  26 +++
 drivers/usb/dwc3/dwc3-pci.c|  36 
 drivers/usb/dwc3/platform_data.h   |   2 +
 drivers/usb/dwc3/ulpi.c|  91 +
 include/linux/mod_devicetable.h|   6 +
 include/linux/ulpi/driver.h|  62 +++
 include/linux/ulpi/interface.h |  23 +++
 include/linux/ulpi/regs.h  | 130 +
 include/linux/usb/ulpi.h   | 134 +-
 scripts/mod/devicetable-offsets.c  |   4 +
 scripts/mod/file2alias.c   |  13 ++
 23 files changed, 936 insertions(+), 157 deletions(-)
 create mode 100644 drivers/phy/phy-tusb1210.c
 create mode 100644 drivers/phy/ulpi_phy.h
 create mode 100644 drivers/usb/common/ulpi.c
 create mode 100644 drivers/usb/dwc3/ulpi.c
 create mode 100644 include/linux/ulpi/driver.h
 create mode 100644 include/linux/ulpi/interface.h
 create mode 100644 include/linux/ulpi/regs.h

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


[PATCHv3 03/11] usb: dwc3: ULPI or UTMI+ select

2015-04-28 Thread Heikki Krogerus
Make selection between ULPI and UTMI+ interfaces possible by
providing definition for the bit in Global USB2 PHY
Configuration Register that controls it.

Signed-off-by: Heikki Krogerus 
Acked-by: David Cohen 
---
 drivers/usb/dwc3/core.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 747805d..c6eafaa 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -173,6 +173,7 @@
 /* Global USB2 PHY Configuration Register */
 #define DWC3_GUSB2PHYCFG_PHYSOFTRST(1 << 31)
 #define DWC3_GUSB2PHYCFG_SUSPHY(1 << 6)
+#define DWC3_GUSB2PHYCFG_ULPI_UTMI (1 << 4)
 
 /* Global USB2 PHY Vendor Control Register */
 #define DWC3_GUSB2PHYACC_NEWREGREQ (1 << 25)
-- 
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


[PATCHv3 01/11] usb: add bus type for USB ULPI

2015-04-28 Thread Heikki Krogerus
UTMI+ Low Pin Interface (ULPI) is a commonly used PHY
interface for USB 2.0. The ULPI specification describes a
standard set of registers which the vendors can extend for
their specific needs. ULPI PHYs provide often functions
such as charger detection and ADP sensing and probing.

There are two major issues that the bus type is meant to
tackle:

Firstly, ULPI registers are accessed from the controller.
The bus provides convenient method for the controller
drivers to share that access with the actual PHY drivers.

Secondly, there are already platforms that assume ULPI PHYs
are runtime detected, such as many Intel Baytrail based
platforms. They do not provide any kind of hardware
description for the ULPI PHYs like separate ACPI device
object that could be used to enumerate a device from.

Signed-off-by: Heikki Krogerus 
Acked-by: David Cohen 
---
 MAINTAINERS   |   7 ++
 drivers/usb/common/Makefile   |   1 +
 drivers/usb/common/ulpi.c | 246 ++
 drivers/usb/core/Kconfig  |   7 ++
 include/linux/mod_devicetable.h   |   6 +
 include/linux/ulpi/driver.h   |  62 ++
 include/linux/ulpi/interface.h|  23 
 include/linux/ulpi/regs.h | 130 
 include/linux/usb/ulpi.h  | 134 +
 scripts/mod/devicetable-offsets.c |   4 +
 scripts/mod/file2alias.c  |  13 ++
 11 files changed, 501 insertions(+), 132 deletions(-)
 create mode 100644 drivers/usb/common/ulpi.c
 create mode 100644 include/linux/ulpi/driver.h
 create mode 100644 include/linux/ulpi/interface.h
 create mode 100644 include/linux/ulpi/regs.h

diff --git a/MAINTAINERS b/MAINTAINERS
index be26fc5..cfbdb8c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -10470,6 +10470,13 @@ S: Maintained
 F: Documentation/video4linux/zr364xx.txt
 F: drivers/media/usb/zr364xx/
 
+ULPI BUS
+M: Heikki Krogerus 
+L: linux-usb@vger.kernel.org
+S: Maintained
+F: drivers/usb/common/ulpi.c
+F: include/linux/ulpi/
+
 USER-MODE LINUX (UML)
 M: Jeff Dike 
 M: Richard Weinberger 
diff --git a/drivers/usb/common/Makefile b/drivers/usb/common/Makefile
index ca2f8bd..6bbb3ec 100644
--- a/drivers/usb/common/Makefile
+++ b/drivers/usb/common/Makefile
@@ -7,3 +7,4 @@ usb-common-y  += common.o
 usb-common-$(CONFIG_USB_LED_TRIG) += led.o
 
 obj-$(CONFIG_USB_OTG_FSM) += usb-otg-fsm.o
+obj-$(CONFIG_USB_ULPI_BUS) += ulpi.o
diff --git a/drivers/usb/common/ulpi.c b/drivers/usb/common/ulpi.c
new file mode 100644
index 000..84dcd2e
--- /dev/null
+++ b/drivers/usb/common/ulpi.c
@@ -0,0 +1,246 @@
+/**
+ * ulpi.c - USB ULPI PHY bus
+ *
+ * Copyright (C) 2015 Intel Corporation
+ *
+ * Author: Heikki Krogerus 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* -- 
*/
+
+int ulpi_read(struct ulpi *ulpi, u8 addr)
+{
+   return ulpi->ops->read(ulpi->ops, addr);
+}
+EXPORT_SYMBOL_GPL(ulpi_read);
+
+int ulpi_write(struct ulpi *ulpi, u8 addr, u8 val)
+{
+   return ulpi->ops->write(ulpi->ops, addr, val);
+}
+EXPORT_SYMBOL_GPL(ulpi_write);
+
+/* -- 
*/
+
+static int ulpi_match(struct device *dev, struct device_driver *driver)
+{
+   struct ulpi_driver *drv = to_ulpi_driver(driver);
+   struct ulpi *ulpi = to_ulpi_dev(dev);
+   const struct ulpi_device_id *id;
+
+   for (id = drv->id_table; id->vendor; id++)
+   if (id->vendor == ulpi->id.vendor &&
+   id->product == ulpi->id.product)
+   return 1;
+
+   return 0;
+}
+
+static int ulpi_uevent(struct device *dev, struct kobj_uevent_env *env)
+{
+   struct ulpi *ulpi = to_ulpi_dev(dev);
+
+   if (add_uevent_var(env, "MODALIAS=ulpi:v%04xp%04x",
+  ulpi->id.vendor, ulpi->id.product))
+   return -ENOMEM;
+   return 0;
+}
+
+static int ulpi_probe(struct device *dev)
+{
+   struct ulpi_driver *drv = to_ulpi_driver(dev->driver);
+
+   return drv->probe(to_ulpi_dev(dev));
+}
+
+static int ulpi_remove(struct device *dev)
+{
+   struct ulpi_driver *drv = to_ulpi_driver(dev->driver);
+
+   if (drv->remove)
+   drv->remove(to_ulpi_dev(dev));
+
+   return 0;
+}
+
+struct bus_type ulpi_bus = {
+   .name = "ulpi",
+   .match = ulpi_match,
+   .uevent = ulpi_uevent,
+   .probe = ulpi_probe,
+   .remove = ulpi_remove,
+};
+EXPORT_SYMBOL_GPL(ulpi_bus);
+
+/* -- 
*/
+
+static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
+ 

[PATCHv3 04/11] usb: dwc3: store driver data earlier

2015-04-28 Thread Heikki Krogerus
We need to store it before phys are handled, so we can later
use it in ULPI interface support code.

Signed-off-by: Heikki Krogerus 
Acked-by: David Cohen 
---
 drivers/usb/dwc3/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 2bbab3d..c7734ed 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -875,12 +875,13 @@ static int dwc3_probe(struct platform_device *pdev)
dwc->hird_threshold = hird_threshold
| (dwc->is_utmi_l1_suspend << 4);
 
+   platform_set_drvdata(pdev, dwc);
+
ret = dwc3_core_get_phy(dwc);
if (ret)
goto err0;
 
spin_lock_init(&dwc->lock);
-   platform_set_drvdata(pdev, dwc);
 
if (!dev->dma_mask) {
dev->dma_mask = dev->parent->dma_mask;
-- 
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] usb: gadget: ether: Fix MAC address parsing

2015-04-28 Thread Krzysztof Opasiak

Hi Stefan,

On 04/28/2015 01:51 PM, Stefan Agner wrote:

MAC addresses can be written without leading zeros. A popular
example is libc's ether_ntoa_r function which creates such
MAC addresses.

Example:
00:14:3d:0f:ff:fe can be written as 0:14:3d:f:ff:fe

Additionally, get_ether_addr potentially parsed past the end
of the user provided string. Use the opportunity and fix the
function to never parse beyond the end of the string while
allowing MAC addresses with and without leading zeros.

Signed-off-by: Stefan Agner 
---
  drivers/usb/gadget/function/u_ether.c | 41 +--
  1 file changed, 25 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/gadget/function/u_ether.c 
b/drivers/usb/gadget/function/u_ether.c
index f1fd777..9994645 100644
--- a/drivers/usb/gadget/function/u_ether.c
+++ b/drivers/usb/gadget/function/u_ether.c
@@ -705,23 +705,27 @@ static int eth_stop(struct net_device *net)

  static int get_ether_addr(const char *str, u8 *dev_addr)
  {
-   if (str) {
-   unsignedi;
+   int num, i = 0;
+   char c = *str;

-   for (i = 0; i < 6; i++) {
-   unsigned char num;
-
-   if ((*str == '.') || (*str == ':'))
-   str++;
-   num = hex_to_bin(*str++) << 4;
-   num |= hex_to_bin(*str++);
-   dev_addr [i] = num;
+   dev_addr[i] = 0;
+   while (c && i < ETH_ALEN) {
+   if (c == '.' || c == ':') {
+   dev_addr[++i] = 0;
+   } else {
+   num = hex_to_bin(c);
+   if (num < 0)
+   break;
+   dev_addr[i] <<= 4;
+   dev_addr[i] |= num;
}
-   if (is_valid_ether_addr(dev_addr))
-   return 0;
+   c = *++str;
}
-   eth_random_addr(dev_addr);
-   return 1;
+
+   if ((i + 1) != ETH_ALEN || !is_valid_ether_addr(dev_addr))
+   return -EINVAL;
+
+   return 0;
  }



First of all thank you for your remark about reading past the buffer in 
my version of this patch. I tried to make my change as little as 
possible and didn't catch that this function is broken from beginning.


This one is definitely better in this case but I'm afraid that it won't 
be able to correctly interpret MAC address written without separators 
while original version works fine for it.


I'm also not sure if it is a good idea to remove random address 
generation from this function. Please see my remark below.



  static int get_ether_addr_str(u8 dev_addr[ETH_ALEN], char *str, int len)
@@ -786,12 +790,17 @@ struct eth_dev *gether_setup_name(struct usb_gadget *g,
dev->qmult = qmult;
snprintf(net->name, sizeof(net->name), "%s%%d", netname);

-   if (get_ether_addr(dev_addr, net->dev_addr))
+   if (get_ether_addr(dev_addr, net->dev_addr)) {
+   eth_random_addr(net->dev_addr);
dev_warn(&g->dev,
"using random %s ethernet address\n", "self");
-   if (get_ether_addr(host_addr, dev->host_mac))
+   }
+
+   if (get_ether_addr(host_addr, dev->host_mac)) {
+   eth_random_addr(dev->host_mac);
dev_warn(&g->dev,
"using random %s ethernet address\n", "host");
+   }

if (ethaddr)
memcpy(ethaddr, dev->host_mac, ETH_ALEN);



This function is also called in a few other places. Is there some reason 
why you didn't change it? For example in gether_set_dev_addr() which is 
used in many gadget modules.


Best regards,

--
Krzysztof Opasiak
Samsung R&D Institute Poland
Samsung Electronics
--
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 00/11] usbip: features to USB over WebSocket

2015-04-28 Thread Krzysztof Opasiak


Hi,

On 04/28/2015 11:35 AM, fx IWATA NOBUO wrote:

Hello,


As far as I understand your design you have kernel stub driver which
is sending and receiving data via socket fd received from userspace.
Now after this series you are exporting all messages  to userspace
where daemon is sending them using web sockets. Am I right?


Yes.


I don't see what are the benefits of such kernel driver?
Couldn't you just simply use libusb in your daemon and do everything
from userspace? Such solution could be beneficial for older kernel
because you don't need to backport your patches but simply use your
daemon which will be compatible with most kernel versions as libusb is
working with them.


Sorry repeating comment in V1 thread.
I had to write this to change log.

There are 2 reasons.

1) Application(vhci_hcd) side is also needed

In my understanding, usbfs provides functions to control USB devices.
So device(usbip_host) side can be done by usbfs but
application(vhci_hcd) side cannot. My patch covers both
device(usbip_host) and application(vhci_hcd) side.
And it is quite the same in both side and works symmetrically.

2) Maintainability

Usbfs provides similar interfaces which USB core provides to USB host
drives. To use the interfaces in user space, implementation which are
included in some portions of usbip_host.ko and usbip_core should be
copied to userspace. At the same time, utilities must be modified
because interfaces used between the utilities and the kernel modules
(sysfs) will be changed to function calls in userspace.

For example, I'd like to break down usbip_host.ko as below.
(a) submits and cancels URBs to USB core
(b) core part: receives and handle URBs, manage submitted URBs, etc.
(c) provides functions to utilities via sysfs
(d) calls usbip_common's functions
(e) calls kernel functions

To move it to user space,
(a) replace with usbfs calls
(b) copy the core part
(c) modify to interface inside userspace or use usbfs directly
(d) port some portion of usbip_core
(e) replace with systemcalls and libraries.

Then, to use usbfs (a), another usbip_host like program which has same
for (b) and different in (c), (d) and (e). By (c), utilities should be
changed unless sysfs emulation is not provided.

I think it's better to use the kernel modules as-is. Strictly, it's
almost as-is because I put a small code to make replaceable
kernel_sendmsg() and kernel_recvmsg().

As a reference, I stored my prototype including userspace usbip_host
with libusb(not sysfs but a portable wrapper of sysfs) in staging/usbip
of linux 3.14.2. It still needs refactoring.
https://drive.google.com/drive/folders/0BxnuWBW_tB9NflFDY1hlcVBRNEd4ZzB2
VFJ3OTI0REFGelNBV2xXTHRNc0lReGJlaTRGdDQ/0BxnuWBW_tB9NfjhabzVMSnZ6VGxrTXB
wNEE1dFJYdENvaC1IMUg1ZG1kTU9iOUN1OEpGUlU

In the prototype, libsrc/stub_main.c, stub_dev.c, stub_rx.c and
stub_tx.c are portings of usbip_host. stub_common.c and stub_event.c is
usbip_core. Macro USE_LIBUSB in utilities denotes portions to be
modified in utilities.

My patch works in both host and vhci side using existing kernel modules.



First of all please excuse me that I didn't check list archive for this 
question. Really sorry that you had to write it once again.


I see your arguments why not libusb but why couldn't you do this in 
userspace by using simple tcp over http or ssh or anything what would 
you like to use? It would work out of box without any changes in kernel.



--
Krzysztof Opasiak
Samsung R&D Institute Poland
Samsung Electronics
--
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 5/6] usb: gadget: atmel_usba: use atmel_io.h to provide on-chip IO

2015-04-28 Thread Ben Dooks
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256


>>> 
>>> /* Register access macros */ -#ifdef CONFIG_AVR32 -#define
>>> usba_io_readl   __raw_readl -#define usba_io_writel __raw_writel 
>>> -#define usba_io_writew __raw_writew -#else -#define
>>> usba_io_readl   readl_relaxed -#define usba_io_writel
>>> writel_relaxed -#define usba_io_writew  writew_relaxed -#endif 
>>> +#define usba_io_readl  atmel_oc_readl +#define usba_io_writel
>>> atmel_oc_writel +#define usba_io_writew atmel_oc_writew
>> 
>> Same comment as earlier patch, it would be nice to remove the
>> define usba_io_{read,write}{l,w} defines in a follow-up patch.
> 
> I'm fine with this too. Is this targetted at v4.2 ?

Yes, although we may move it to the soc specific include directories
to avoid adding more to linux/

I will be sorting this out next week.

- -- 
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
-BEGIN PGP SIGNATURE-
Version: GnuPG v2

iQEcBAEBCAAGBQJVP6neAAoJEMuhVOkVU3uz6tQH/jmZ0MszsoDjiKWdTnG+etoy
WUhAEdnmaqPEfJSaBy2OPCcmj9T1O07wg1L/2rHQHBrVuR9bW0gWY/TyJQahnn3A
YG81fgfIvOTAwmxIkaF10mG1/haG1LgPQ4P6j7AaKz09Zowath0rsga17AhYuUyh
bps4Go7yHF/OpjuwB9VxSttMAbVAIHqXbuc5kufN89JAxDT6x5tV/BrqkqEoHpSV
kW7VvGb/V4Aeax1h9klfdUEBlL2czkVuYYtTnicc9lFN3T9+6XJ+SNwKLtSklEr3
SLM78DoIQQoKYWCf8vsg0FR0E9LeR1ytgZXPfOpdAoId+iZt39tBk9bMi/XOiBo=
=ceej
-END PGP SIGNATURE-
--
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: gadget: composite: enable BESL support

2015-04-28 Thread Felipe Balbi
On Tue, Apr 28, 2015 at 07:56:13AM +, Du, Changbin wrote:
> From a6615937bcd9234e6d6bb817c3701fce44d0a84d Mon Sep 17 00:00:00 2001
> From: Felipe Balbi 
> Date: Tue, 30 Sep 2014 16:08:03 -0500
> Subject: [PATCH] usb: gadget: composite: enable BESL support

missing upstream commit.

> According to USB 2.0 ECN Errata for Link Power
> Management (USB2-LPM-Errata-final.pdf), BESL
> must be enabled if LPM is enabled.
> 
> This helps with USB30CV TD 9.21 LPM L1
> Suspend Resume Test.
> 
> Cc:  # 3.14

this should be backported all the way back to 3.1. The commit which this
patch is fixing, was applied on v3.1, so we're probably going to
backport to 3.10 and 3.14. When asking for backports, don't consider
only your project, think about the kernel/stable releases as a whole.

BTW, that should be v3.1+, the + tells the Stable team that from v3.1
forward, all kernels need the backport.

> Signed-off-by: Felipe Balbi 
> Signed-off-by: Du, Changbin 
> ---
> Hi,
> 
> This patch was introduced on v3.18. However the issue fixed already existed on
> v3.14 and v3.14 is a long term support version.

the issue already existed on v3.1, why did you decide to backport only
to v3.14 ?

> So propose to backport it over there as well.
> 
> Du, Changbin
> ---
>  drivers/usb/gadget/composite.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
> index a8c18df..f6a51fd 100644
> --- a/drivers/usb/gadget/composite.c
> +++ b/drivers/usb/gadget/composite.c
> @@ -560,7 +560,7 @@ static int bos_desc(struct usb_composite_dev *cdev)
>   usb_ext->bLength = USB_DT_USB_EXT_CAP_SIZE;
>   usb_ext->bDescriptorType = USB_DT_DEVICE_CAPABILITY;
>   usb_ext->bDevCapabilityType = USB_CAP_TYPE_EXT;
> - usb_ext->bmAttributes = cpu_to_le32(USB_LPM_SUPPORT);
> + usb_ext->bmAttributes = cpu_to_le32(USB_LPM_SUPPORT | USB_BESL_SUPPORT);
>  
>   /*
>* The Superspeed USB Capability descriptor shall be implemented by all

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] usb: gadget: ether: Fix MAC address parsing

2015-04-28 Thread Stefan Agner
On 2015-04-28 17:00, Krzysztof Opasiak wrote:
> Hi Stefan,
> 
> On 04/28/2015 01:51 PM, Stefan Agner wrote:
>> MAC addresses can be written without leading zeros. A popular
>> example is libc's ether_ntoa_r function which creates such
>> MAC addresses.
>>
>> Example:
>> 00:14:3d:0f:ff:fe can be written as 0:14:3d:f:ff:fe
>>
>> Additionally, get_ether_addr potentially parsed past the end
>> of the user provided string. Use the opportunity and fix the
>> function to never parse beyond the end of the string while
>> allowing MAC addresses with and without leading zeros.
>>
>> Signed-off-by: Stefan Agner 
>> ---
>>   drivers/usb/gadget/function/u_ether.c | 41 
>> +--
>>   1 file changed, 25 insertions(+), 16 deletions(-)
>>
>> diff --git a/drivers/usb/gadget/function/u_ether.c 
>> b/drivers/usb/gadget/function/u_ether.c
>> index f1fd777..9994645 100644
>> --- a/drivers/usb/gadget/function/u_ether.c
>> +++ b/drivers/usb/gadget/function/u_ether.c
>> @@ -705,23 +705,27 @@ static int eth_stop(struct net_device *net)
>>
>>   static int get_ether_addr(const char *str, u8 *dev_addr)
>>   {
>> -if (str) {
>> -unsignedi;
>> +int num, i = 0;
>> +char c = *str;
>>
>> -for (i = 0; i < 6; i++) {
>> -unsigned char num;
>> -
>> -if ((*str == '.') || (*str == ':'))
>> -str++;
>> -num = hex_to_bin(*str++) << 4;
>> -num |= hex_to_bin(*str++);
>> -dev_addr [i] = num;
>> +dev_addr[i] = 0;
>> +while (c && i < ETH_ALEN) {
>> +if (c == '.' || c == ':') {
>> +dev_addr[++i] = 0;
>> +} else {
>> +num = hex_to_bin(c);
>> +if (num < 0)
>> +break;
>> +dev_addr[i] <<= 4;
>> +dev_addr[i] |= num;
>>  }
>> -if (is_valid_ether_addr(dev_addr))
>> -return 0;
>> +c = *++str;
>>  }
>> -eth_random_addr(dev_addr);
>> -return 1;
>> +
>> +if ((i + 1) != ETH_ALEN || !is_valid_ether_addr(dev_addr))
>> +return -EINVAL;
>> +
>> +return 0;
>>   }
>>
> 
> First of all thank you for your remark about reading past the buffer
> in my version of this patch. I tried to make my change as little as
> possible and didn't catch that this function is broken from beginning.
> 
> This one is definitely better in this case but I'm afraid that it
> won't be able to correctly interpret MAC address written without
> separators while original version works fine for it.

That is true, we need separators to be able to parse the address now. Do
we need to support the format without separators? The sysfs
documentation is not very clear about the supported format (e.g.
Documentation/ABI/testing/configfs-usb-gadget-ecm).

Having variable length of the individual bytes and no separators for the
individual bytes somehow contradicts. We can of course just assume that
we have 2 characters when using no separators, its just somewhat
irregular...

> I'm also not sure if it is a good idea to remove random address
> generation from this function. Please see my remark below.

Yes I'm aware of that.

> 
>>   static int get_ether_addr_str(u8 dev_addr[ETH_ALEN], char *str, int len)
>> @@ -786,12 +790,17 @@ struct eth_dev *gether_setup_name(struct usb_gadget *g,
>>  dev->qmult = qmult;
>>  snprintf(net->name, sizeof(net->name), "%s%%d", netname);
>>
>> -if (get_ether_addr(dev_addr, net->dev_addr))
>> +if (get_ether_addr(dev_addr, net->dev_addr)) {
>> +eth_random_addr(net->dev_addr);
>>  dev_warn(&g->dev,
>>  "using random %s ethernet address\n", "self");
>> -if (get_ether_addr(host_addr, dev->host_mac))
>> +}
>> +
>> +if (get_ether_addr(host_addr, dev->host_mac)) {
>> +eth_random_addr(dev->host_mac);
>>  dev_warn(&g->dev,
>>  "using random %s ethernet address\n", "host");
>> +}
>>
>>  if (ethaddr)
>>  memcpy(ethaddr, dev->host_mac, ETH_ALEN);
>>
> 
> This function is also called in a few other places. Is there some
> reason why you didn't change it? For example in gether_set_dev_addr()
> which is used in many gadget modules.

The other functions made no use of the random address, hence I moved
that function call from the common function get_ether_addr to the
callers. For instance gether_set_dev_addr, if 1 has been returned by
get_ether_addr, the result had been ignored anyway. 

So this is an additional optimization, which avoids generating random
addresses when not used anyway.

--
Stefan
--
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] phy: fix Kconfig dependencies

2015-04-28 Thread Felipe Balbi
DM816x PHY uses usb_phy_* methods and because
of that, it must select USB_PHY, however, because
the drivers in question (DM816x and OMAP_USB2) sit
outside of drivers/usb/ directory, they can compile
even if USB_SUPPORT=n.

This patches fixes the dependencies by adding
USB_SUPPORT as a dependency and make both drivers
select USB_PHY (which cannot be selected through
menuconfig).

Note that this fixes some linking breakages when
building with randconfig.

Cc: Tony Lindgren 
Cc: Kishon Vijay Abraham I 
Signed-off-by: Felipe Balbi 
---
 drivers/phy/Kconfig | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index a53bd5b52df9..e68ec6a6094c 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -38,7 +38,9 @@ config ARMADA375_USBCLUSTER_PHY
 config PHY_DM816X_USB
tristate "TI dm816x USB PHY driver"
depends on ARCH_OMAP2PLUS
+   depends on USB_SUPPORT
select GENERIC_PHY
+   select USB_PHY
help
  Enable this for dm816x USB to work.
 
@@ -97,8 +99,9 @@ config OMAP_CONTROL_PHY
 config OMAP_USB2
tristate "OMAP USB2 PHY Driver"
depends on ARCH_OMAP2PLUS
-   depends on USB_PHY
+   depends on USB_SUPPORT
select GENERIC_PHY
+   select USB_PHY
select OMAP_CONTROL_PHY
depends on OMAP_OCP2SCP
help
-- 
2.4.0.rc3

--
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: [BUG] xhci_hcd: intermittent bug with VL812 hub: Bad Slot ID 2 Could not allocate xHCI USB device data structures

2015-04-28 Thread Johan Hovold
On Mon, Apr 27, 2015 at 02:17:45PM +0300, Mathias Nyman wrote:
> On 27.04.2015 12:30, Johan Hovold wrote:
> > On Sat, Apr 25, 2015 at 10:39:23PM +0100, Chris Bainbridge wrote:
> >> Kernel: v4.0-10710-g27cf3a1
> >>
> >> Hardware:
> >>
> >> IvyBridge Macbook (Panther Point PCH), 2 external USB3 ports
> >> AmazonBasics 10 Port USB 3.0 Hub (3x VIA VL812 hub controllers)
> >>
> >> Bug:
> >>
> >> In ~7%-10% of boots there is an error:
> >>
> >> [0.604801] xhci_hcd :00:14.0: Bad Slot ID 2
> >> [0.604802] xhci_hcd :00:14.0: Could not allocate xHCI USB
> >> device data structures
> >> [0.604805] usb usb1-port3: couldn't allocate usb_device
> >>
> >> When this happens, no USB2 devices will be detected on the hub - the
> >> three USB2 hub controllers (2109:2812) from the hub are not detected.
> >>
> >> This problem does not seem to occur in OS X: on 60 boots the USB2
> >> devices appeared every time.
> > 
> 
> Does reverting
> commit 6fecd4f2a58c60028b1a75deefcf111516d3f836
>   USB: separate usb_address0 mutexes for each bus
> Help?
>  
> The "Bad Slot ID 2" followed by "Could not allocate xHCI USB device
> data structures" is shown if we try to allocate device data structure
> for an already existing device. 
> 
> We rely on a couple xhci wide variables during device enabling,
> xhci->addr_dev and xhci->slot_id, and also rely on them being
> protected by the usb_address0 mutex.  As xhci handles both a USB-2 and
> USB-3 bus and the mutex was changed to be per bus it's possible that
> xhci->addr_dev and xhci_>slot_id race. 

That sounds like it could be related, although I've only seen this with
3.19 (fist and only boot) and that change went into 3.16.

Chris, could you try reverting it as you seem to have a setup more
suitable for testing this?

Thanks,
Johan
--
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: fix Kconfig dependencies

2015-04-28 Thread Felipe Balbi
On Tue, Apr 28, 2015 at 11:09:30AM -0500, Felipe Balbi wrote:
> DM816x PHY uses usb_phy_* methods and because
> of that, it must select USB_PHY, however, because
> the drivers in question (DM816x and OMAP_USB2) sit
> outside of drivers/usb/ directory, they can compile
> even if USB_SUPPORT=n.
> 
> This patches fixes the dependencies by adding
> USB_SUPPORT as a dependency and make both drivers
> select USB_PHY (which cannot be selected through
> menuconfig).
> 
> Note that this fixes some linking breakages when
> building with randconfig.
> 
> Cc: Tony Lindgren 
> Cc: Kishon Vijay Abraham I 
> Signed-off-by: Felipe Balbi 
> ---
>  drivers/phy/Kconfig | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
> index a53bd5b52df9..e68ec6a6094c 100644
> --- a/drivers/phy/Kconfig
> +++ b/drivers/phy/Kconfig
> @@ -38,7 +38,9 @@ config ARMADA375_USBCLUSTER_PHY
>  config PHY_DM816X_USB
>   tristate "TI dm816x USB PHY driver"
>   depends on ARCH_OMAP2PLUS
> + depends on USB_SUPPORT
>   select GENERIC_PHY
> + select USB_PHY
>   help
> Enable this for dm816x USB to work.

oops, there's twl4030 too. I'll send another version

-- 
balbi


signature.asc
Description: Digital signature


[PATCH v2] phy: fix Kconfig dependencies

2015-04-28 Thread Felipe Balbi
DM816x PHY uses usb_phy_* methods and because
of that, it must select USB_PHY, however, because
the drivers in question (DM816x, TWL4030 and
OMAP_USB2) sit outside of drivers/usb/ directory,
meaning they can be built even if USB_SUPPORT=n.

This patches fixes the dependencies by adding
USB_SUPPORT as a dependency and make both drivers
select USB_PHY (which cannot be selected through
menuconfig).

Note that this fixes some linking breakages when
building with randconfig.

Cc: Tony Lindgren 
Cc: Kishon Vijay Abraham I 
Signed-off-by: Felipe Balbi 
---
 drivers/phy/Kconfig | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index a53bd5b52df9..2f9ea1e63ccc 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -38,7 +38,9 @@ config ARMADA375_USBCLUSTER_PHY
 config PHY_DM816X_USB
tristate "TI dm816x USB PHY driver"
depends on ARCH_OMAP2PLUS
+   depends on USB_SUPPORT
select GENERIC_PHY
+   select USB_PHY
help
  Enable this for dm816x USB to work.
 
@@ -97,8 +99,9 @@ config OMAP_CONTROL_PHY
 config OMAP_USB2
tristate "OMAP USB2 PHY Driver"
depends on ARCH_OMAP2PLUS
-   depends on USB_PHY
+   depends on USB_SUPPORT
select GENERIC_PHY
+   select USB_PHY
select OMAP_CONTROL_PHY
depends on OMAP_OCP2SCP
help
@@ -122,8 +125,9 @@ config TI_PIPE3
 config TWL4030_USB
tristate "TWL4030 USB Transceiver Driver"
depends on TWL4030_CORE && REGULATOR_TWL4030 && USB_MUSB_OMAP2PLUS
-   depends on USB_PHY
+   depends on USB_SUPPORT
select GENERIC_PHY
+   select USB_PHY
help
  Enable this to support the USB OTG transceiver on TWL4030
  family chips (including the TWL5030 and TPS659x0 devices).
-- 
2.4.0.rc3

--
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: gadget: ether: Fix MAC address parsing

2015-04-28 Thread Krzysztof Opasiak



On 04/28/2015 05:59 PM, Stefan Agner wrote:

On 2015-04-28 17:00, Krzysztof Opasiak wrote:

Hi Stefan,

On 04/28/2015 01:51 PM, Stefan Agner wrote:

MAC addresses can be written without leading zeros. A popular
example is libc's ether_ntoa_r function which creates such
MAC addresses.

Example:
00:14:3d:0f:ff:fe can be written as 0:14:3d:f:ff:fe

Additionally, get_ether_addr potentially parsed past the end
of the user provided string. Use the opportunity and fix the
function to never parse beyond the end of the string while
allowing MAC addresses with and without leading zeros.

Signed-off-by: Stefan Agner 


(...)



First of all thank you for your remark about reading past the buffer
in my version of this patch. I tried to make my change as little as
possible and didn't catch that this function is broken from beginning.

This one is definitely better in this case but I'm afraid that it
won't be able to correctly interpret MAC address written without
separators while original version works fine for it.


That is true, we need separators to be able to parse the address now. Do
we need to support the format without separators? The sysfs
documentation is not very clear about the supported format (e.g.
Documentation/ABI/testing/configfs-usb-gadget-ecm).

Having variable length of the individual bytes and no separators for the
individual bytes somehow contradicts. We can of course just assume that
we have 2 characters when using no separators, its just somewhat
irregular...


Let's check what is currently supported:

1) 00:14:3d:0f:ff:fe (no skipped 0, semicolons)
2) 00.14.3d.0f.ff.fe (no skipped 0, dots)
3) 00143d0e (no skipped 0, no separator)

What we are actually trying to do is adding a new format:

4) 0:14:3d:f:ff:fe (skipped leading 0, semicolons)
5) 0.14.3d.f.ff.fe (skipped leading 0, dots)

In my humble opinion adding a new format in this case is a very good 
idea but it should not affect any other format that is currently 
supported by this function





I'm also not sure if it is a good idea to remove random address
generation from this function. Please see my remark below.


Yes I'm aware of that.



All clear here for me, thanks.

--
Krzysztof Opasiak
Samsung R&D Institute Poland
Samsung Electronics
--
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 v2] phy: fix Kconfig dependencies

2015-04-28 Thread Tony Lindgren
* Felipe Balbi  [150428 09:16]:
> DM816x PHY uses usb_phy_* methods and because
> of that, it must select USB_PHY, however, because
> the drivers in question (DM816x, TWL4030 and
> OMAP_USB2) sit outside of drivers/usb/ directory,
> meaning they can be built even if USB_SUPPORT=n.
> 
> This patches fixes the dependencies by adding
> USB_SUPPORT as a dependency and make both drivers
> select USB_PHY (which cannot be selected through
> menuconfig).
> 
> Note that this fixes some linking breakages when
> building with randconfig.
> 
> Cc: Tony Lindgren 

Makes sense to me:

Acked-by: Tony Lindgren 

> Cc: Kishon Vijay Abraham I 
> Signed-off-by: Felipe Balbi 
> ---
>  drivers/phy/Kconfig | 8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
> index a53bd5b52df9..2f9ea1e63ccc 100644
> --- a/drivers/phy/Kconfig
> +++ b/drivers/phy/Kconfig
> @@ -38,7 +38,9 @@ config ARMADA375_USBCLUSTER_PHY
>  config PHY_DM816X_USB
>   tristate "TI dm816x USB PHY driver"
>   depends on ARCH_OMAP2PLUS
> + depends on USB_SUPPORT
>   select GENERIC_PHY
> + select USB_PHY
>   help
> Enable this for dm816x USB to work.
>  
> @@ -97,8 +99,9 @@ config OMAP_CONTROL_PHY
>  config OMAP_USB2
>   tristate "OMAP USB2 PHY Driver"
>   depends on ARCH_OMAP2PLUS
> - depends on USB_PHY
> + depends on USB_SUPPORT
>   select GENERIC_PHY
> + select USB_PHY
>   select OMAP_CONTROL_PHY
>   depends on OMAP_OCP2SCP
>   help
> @@ -122,8 +125,9 @@ config TI_PIPE3
>  config TWL4030_USB
>   tristate "TWL4030 USB Transceiver Driver"
>   depends on TWL4030_CORE && REGULATOR_TWL4030 && USB_MUSB_OMAP2PLUS
> - depends on USB_PHY
> + depends on USB_SUPPORT
>   select GENERIC_PHY
> + select USB_PHY
>   help
> Enable this to support the USB OTG transceiver on TWL4030
> family chips (including the TWL5030 and TPS659x0 devices).
> -- 
> 2.4.0.rc3
> 
--
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 5/6] usb: gadget: atmel_usba: use atmel_io.h to provide on-chip IO

2015-04-28 Thread Nicolas Ferre
Le 28/04/2015 17:40, Ben Dooks a écrit :
> 

 /* Register access macros */ -#ifdef CONFIG_AVR32 -#define
 usba_io_readl  __raw_readl -#define usba_io_writel __raw_writel 
 -#define usba_io_writew__raw_writew -#else -#define
 usba_io_readl  readl_relaxed -#define usba_io_writel
 writel_relaxed -#define usba_io_writew writew_relaxed -#endif 
 +#define usba_io_readl atmel_oc_readl +#define usba_io_writel
 atmel_oc_writel +#define usba_io_writewatmel_oc_writew
>>>
>>> Same comment as earlier patch, it would be nice to remove the
>>> define usba_io_{read,write}{l,w} defines in a follow-up patch.
> 
>> I'm fine with this too. Is this targetted at v4.2 ?
> 
> Yes, although we may move it to the soc specific include directories
> to avoid adding more to linux/

BTW, Ben, what _oc_ stands for in the new macro name?

Bye,
-- 
Nicolas Ferre
--
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 v2] phy: fix Kconfig dependencies

2015-04-28 Thread Felipe Balbi
On Tue, Apr 28, 2015 at 09:20:22AM -0700, Tony Lindgren wrote:
> * Felipe Balbi  [150428 09:16]:
> > DM816x PHY uses usb_phy_* methods and because
> > of that, it must select USB_PHY, however, because
> > the drivers in question (DM816x, TWL4030 and
> > OMAP_USB2) sit outside of drivers/usb/ directory,
> > meaning they can be built even if USB_SUPPORT=n.
> > 
> > This patches fixes the dependencies by adding
> > USB_SUPPORT as a dependency and make both drivers

s/make both/making all/

Kishon, can you fix that when applying or want me to send v3 with Tony's
ack ?

> > select USB_PHY (which cannot be selected through
> > menuconfig).
> > 
> > Note that this fixes some linking breakages when
> > building with randconfig.
> > 
> > Cc: Tony Lindgren 
> 
> Makes sense to me:
> 
> Acked-by: Tony Lindgren 

tks

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] usb: gadget: ether: Fix MAC address parsing

2015-04-28 Thread Felipe Balbi
On Tue, Apr 28, 2015 at 06:15:51PM +0200, Krzysztof Opasiak wrote:
> 
> 
> On 04/28/2015 05:59 PM, Stefan Agner wrote:
> >On 2015-04-28 17:00, Krzysztof Opasiak wrote:
> >>Hi Stefan,
> >>
> >>On 04/28/2015 01:51 PM, Stefan Agner wrote:
> >>>MAC addresses can be written without leading zeros. A popular
> >>>example is libc's ether_ntoa_r function which creates such
> >>>MAC addresses.
> >>>
> >>>Example:
> >>>00:14:3d:0f:ff:fe can be written as 0:14:3d:f:ff:fe
> >>>
> >>>Additionally, get_ether_addr potentially parsed past the end
> >>>of the user provided string. Use the opportunity and fix the
> >>>function to never parse beyond the end of the string while
> >>>allowing MAC addresses with and without leading zeros.
> >>>
> >>>Signed-off-by: Stefan Agner 
> 
> (...)
> 
> >>
> >>First of all thank you for your remark about reading past the buffer
> >>in my version of this patch. I tried to make my change as little as
> >>possible and didn't catch that this function is broken from beginning.
> >>
> >>This one is definitely better in this case but I'm afraid that it
> >>won't be able to correctly interpret MAC address written without
> >>separators while original version works fine for it.
> >
> >That is true, we need separators to be able to parse the address now. Do
> >we need to support the format without separators? The sysfs
> >documentation is not very clear about the supported format (e.g.
> >Documentation/ABI/testing/configfs-usb-gadget-ecm).
> >
> >Having variable length of the individual bytes and no separators for the
> >individual bytes somehow contradicts. We can of course just assume that
> >we have 2 characters when using no separators, its just somewhat
> >irregular...
> 
> Let's check what is currently supported:
> 
> 1) 00:14:3d:0f:ff:fe (no skipped 0, semicolons)
> 2) 00.14.3d.0f.ff.fe (no skipped 0, dots)
> 3) 00143d0e (no skipped 0, no separator)
> 
> What we are actually trying to do is adding a new format:
> 
> 4) 0:14:3d:f:ff:fe (skipped leading 0, semicolons)
> 5) 0.14.3d.f.ff.fe (skipped leading 0, dots)
> 
> In my humble opinion adding a new format in this case is a very good idea
> but it should not affect any other format that is currently supported by
> this function

agreed :-)

-- 
balbi


signature.asc
Description: Digital signature


Re: [RFC 5/6] usb: gadget: atmel_usba: use atmel_io.h to provide on-chip IO

2015-04-28 Thread Felipe Balbi
Hi,

On Tue, Apr 28, 2015 at 04:40:14PM +0100, Ben Dooks wrote:
> >>> /* Register access macros */ -#ifdef CONFIG_AVR32 -#define
> >>> usba_io_readl __raw_readl -#define usba_io_writel __raw_writel 
> >>> -#define usba_io_writew   __raw_writew -#else -#define
> >>> usba_io_readl readl_relaxed -#define usba_io_writel
> >>> writel_relaxed -#define usba_io_writewwritew_relaxed -#endif 
> >>> +#define usba_io_readlatmel_oc_readl +#define usba_io_writel
> >>> atmel_oc_writel +#define usba_io_writew   atmel_oc_writew
> >> 
> >> Same comment as earlier patch, it would be nice to remove the
> >> define usba_io_{read,write}{l,w} defines in a follow-up patch.
> > 
> > I'm fine with this too. Is this targetted at v4.2 ?
> 
> Yes, although we may move it to the soc specific include directories
> to avoid adding more to linux/
> 
> I will be sorting this out next week.

I would rather not see drivers including anything from asm or mach-*
(unless strictly necessary), otherwise it's a pain to build-test
anything

cheers

-- 
balbi


signature.asc
Description: Digital signature


Re: [RFC 5/6] usb: gadget: atmel_usba: use atmel_io.h to provide on-chip IO

2015-04-28 Thread Ben Dooks
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

On 28/04/15 17:30, Felipe Balbi wrote:
> Hi,
> 
> On Tue, Apr 28, 2015 at 04:40:14PM +0100, Ben Dooks wrote:
> /* Register access macros */ -#ifdef CONFIG_AVR32 -#define 
> usba_io_readl __raw_readl -#define usba_io_writel
> __raw_writel -#define usba_io_writew  __raw_writew -#else
> -#define usba_io_readlreadl_relaxed -#define
> usba_io_writel writel_relaxed -#define usba_io_writew
> writew_relaxed -#endif +#define usba_io_readl
> atmel_oc_readl +#define usba_io_writel atmel_oc_writel
> +#define usba_io_writew   atmel_oc_writew
 
 Same comment as earlier patch, it would be nice to remove
 the define usba_io_{read,write}{l,w} defines in a follow-up
 patch.
>>> 
>>> I'm fine with this too. Is this targetted at v4.2 ?
>> 
>> Yes, although we may move it to the soc specific include
>> directories to avoid adding more to linux/
>> 
>> I will be sorting this out next week.
> 
> I would rather not see drivers including anything from asm or
> mach-* (unless strictly necessary), otherwise it's a pain to
> build-test anything


Thanks. I think the soc/ include is available for all. I will check this
tomorrow.


- -- 
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
-BEGIN PGP SIGNATURE-
Version: GnuPG v2

iQEcBAEBCAAGBQJVP7aBAAoJEMuhVOkVU3uzId4H/3ZsZ4Vogng63I04OpLtt5Qs
VopvttCvaLczye/wOWQKptXJuKIBmrs66BcV4ZsVi1SZjfbju9X1blzc0+6fxU9X
xE2rw3kDPZmtKm6v1GCRrE/uzhKeKgAnfp7Yf7pkdn98Lx2D9gy/s7GRN6Bkql28
pz/QIqr/H6Hp2frbubakKx/F7SFV88ZUNZXLkw8+vkn7gKGRX7ODcPFldjbjooIa
zyDdrZWiqhTHdWzQ813vNgKJfP1GiYNZuht+EhAh0ngLy0YnqnSXF0eZiOy/uF0Z
cCMlXZo1Q/2LkqVKEgywJDxGhCruT3RpPDWLk6eA9trlHF62j3WSn65nDxKtBwA=
=cqtq
-END PGP SIGNATURE-
--
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 5/6] usb: gadget: atmel_usba: use atmel_io.h to provide on-chip IO

2015-04-28 Thread Felipe Balbi
On Tue, Apr 28, 2015 at 05:34:09PM +0100, Ben Dooks wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA256
> 
> On 28/04/15 17:30, Felipe Balbi wrote:
> > Hi,
> > 
> > On Tue, Apr 28, 2015 at 04:40:14PM +0100, Ben Dooks wrote:
> > /* Register access macros */ -#ifdef CONFIG_AVR32 -#define 
> > usba_io_readl   __raw_readl -#define usba_io_writel
> > __raw_writel -#define usba_io_writew__raw_writew -#else
> > -#define usba_io_readl  readl_relaxed -#define
> > usba_io_writel writel_relaxed -#define usba_io_writew
> > writew_relaxed -#endif +#define usba_io_readl
> > atmel_oc_readl +#define usba_io_writel atmel_oc_writel
> > +#define usba_io_writew atmel_oc_writew
>  
>  Same comment as earlier patch, it would be nice to remove
>  the define usba_io_{read,write}{l,w} defines in a follow-up
>  patch.
> >>> 
> >>> I'm fine with this too. Is this targetted at v4.2 ?
> >> 
> >> Yes, although we may move it to the soc specific include
> >> directories to avoid adding more to linux/
> >> 
> >> I will be sorting this out next week.
> > 
> > I would rather not see drivers including anything from asm or
> > mach-* (unless strictly necessary), otherwise it's a pain to
> > build-test anything
> 
> 
> Thanks. I think the soc/ include is available for all. I will check this
> tomorrow.

if that's the case, no issues from my side :-)

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 1/2] usb: gadget: add usb_gadget_activate/deactivate functions

2015-04-28 Thread Felipe Balbi
On Tue, Apr 07, 2015 at 10:31:52AM +0200, Robert Baldyga wrote:
> These functions allows to deactivate gadget to make it not visible to
> host and make it active again when gadget driver is finally ready.
> 
> They are needed to fix usb_function_activate() and usb_function_deactivate()
> functions which currently are not working as usb_gadget_connect() is
> called immediately after function bind regardless to previous calls of
> usb_gadget_disconnect() function.

and that's what needs to be fixed, a long time ago I wrote the patch
below which I never got to finishing:

commit a23800e2463ae1f4eafa7c0a15bb44afee75994f
Author: Felipe Balbi 
Date:   Thu Jul 26 14:23:44 2012 +0300

usb: gadget: let gadgets control pullup on their own

This is useful on gadgets that depend on userland
daemons to function properly. We can delay connection
to the host until userland is ready.

Signed-off-by: Felipe Balbi 

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 7c821de8ce3d..790ccf29f2ee 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -1784,8 +1784,9 @@ int usb_composite_probe(struct usb_composite_driver 
*driver)
driver->name = "composite";
 
driver->gadget_driver = composite_driver_template;
-   gadget_driver = &driver->gadget_driver;
 
+   gadget_driver = &driver->gadget_driver;
+   gadget_driver->controls_pullups = driver->controls_pullups;
gadget_driver->function =  (char *) driver->name;
gadget_driver->driver.name = driver->name;
gadget_driver->max_speed = driver->max_speed;
diff --git a/drivers/usb/gadget/udc-core.c b/drivers/usb/gadget/udc-core.c
index 8a1eeb24ae6a..c0f4fca9384b 100644
--- a/drivers/usb/gadget/udc-core.c
+++ b/drivers/usb/gadget/udc-core.c
@@ -235,7 +235,18 @@ static void usb_gadget_remove_driver(struct usb_udc *udc)
 
kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE);
 
-   usb_gadget_disconnect(udc->gadget);
+   /*
+* NOTICE: if gadget driver wants to control
+* pullup, it needs to make sure that when
+* user tries to rmmod the gadget driver, it
+* will disconnect the pullups before returning
+* from its ->unbind() method.
+*
+* We are truly trusting the gadget driver here.
+*/
+   if (!udc->driver->controls_pullups)
+   usb_gadget_disconnect(udc->gadget);
+
udc->driver->disconnect(udc->gadget);
udc->driver->unbind(udc->gadget);
usb_gadget_udc_stop(udc->gadget, udc->driver);
@@ -300,7 +311,18 @@ static int udc_bind_to_driver(struct usb_udc *udc, struct 
usb_gadget_driver *dri
driver->unbind(udc->gadget);
goto err1;
}
-   usb_gadget_connect(udc->gadget);
+
+   /*
+* NOTICE: if gadget driver wants to control
+* pullups, it needs to make sure its calls
+* to usb_function_activate() and
+* usb_function_deactivate() are balanced,
+* otherwise gadget_driver will never enumerate.
+*
+* We are truly trusting the gadget driver here.
+*/
+   if (!driver->controls_pullups)
+   usb_gadget_connect(udc->gadget);
 
kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE);
return 0;
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
index 3c671c1b37f6..7ae797c85cb9 100644
--- a/include/linux/usb/composite.h
+++ b/include/linux/usb/composite.h
@@ -157,6 +157,7 @@ struct usb_function {
int (*get_status)(struct usb_function *);
int (*func_suspend)(struct usb_function *,
u8 suspend_opt);
+
/* private: */
/* internals */
struct list_headlist;
@@ -279,6 +280,8 @@ enum {
  * @max_speed: Highest speed the driver supports.
  * @needs_serial: set to 1 if the gadget needs userspace to provide
  * a serial number.  If one is not provided, warning will be printed.
+ * @controls_pullups: this driver will control pullup and udc-core shouldn't
+ * enable it by default
  * @bind: (REQUIRED) Used to allocate resources that are shared across the
  * whole device, such as string IDs, and add its configurations using
  * @usb_add_config(). This may fail by returning a negative errno
@@ -308,6 +311,7 @@ struct usb_composite_driver {
struct usb_gadget_strings   **strings;
enum usb_device_speed   max_speed;
unsignedneeds_serial:1;
+   unsignedcontrols_pullups:1;
 
int (*bind)(struct usb_composite_dev *cdev);
int (*unbind)(struct usb_composite_dev *);
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index 32b734d88d6b..87971fa38f08 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gad

Re: [PATCH V7 3/9] mailbox: Fix up error handling in mbox_request_channel()

2015-04-28 Thread Suman Anna
On 04/27/2015 05:37 PM, Andrew Bresticker wrote:
> From: Benson Leung 
> 
> mbox_request_channel() currently returns EBUSY in the event the controller
> is not present or if of_xlate() fails, but in neither case is EBUSY really
> appropriate.  Return EPROBE_DEFER if the controller is not yet present
> and change of_xlate() to return an ERR_PTR instead of NULL so that the
> error can be propagated back to the caller of mbox_request_channel().
> 
> Signed-off-by: Benson Leung 
> Signed-off-by: Andrew Bresticker 
> Cc: Jassi Brar 
> Cc: Suman Anna 
> ---
> Changes from v6:
>  - Update omap-mailbox's xlate() to return error codes.
> No changes from v5.
> New for v5.
> ---
>  drivers/mailbox/mailbox.c  | 11 ---
>  drivers/mailbox/omap-mailbox.c |  6 +++---

For the OMAP mailbox portion,
Acked-by: Suman Anna 

>  2 files changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
> index 19b491d..c3c42d4 100644
> --- a/drivers/mailbox/mailbox.c
> +++ b/drivers/mailbox/mailbox.c
> @@ -318,7 +318,7 @@ struct mbox_chan *mbox_request_channel(struct mbox_client 
> *cl, int index)
>   return ERR_PTR(-ENODEV);
>   }
>  
> - chan = NULL;
> + chan = ERR_PTR(-EPROBE_DEFER);
>   list_for_each_entry(mbox, &mbox_cons, node)
>   if (mbox->dev->of_node == spec.np) {
>   chan = mbox->of_xlate(mbox, &spec);
> @@ -327,7 +327,12 @@ struct mbox_chan *mbox_request_channel(struct 
> mbox_client *cl, int index)
>  
>   of_node_put(spec.np);
>  
> - if (!chan || chan->cl || !try_module_get(mbox->dev->driver->owner)) {
> + if (IS_ERR(chan)) {
> + mutex_unlock(&con_mutex);
> + return chan;
> + }
> +
> + if (chan->cl || !try_module_get(mbox->dev->driver->owner)) {
>   dev_dbg(dev, "%s: mailbox not free\n", __func__);
>   mutex_unlock(&con_mutex);
>   return ERR_PTR(-EBUSY);
> @@ -390,7 +395,7 @@ of_mbox_index_xlate(struct mbox_controller *mbox,
>   int ind = sp->args[0];
>  
>   if (ind >= mbox->num_chans)
> - return NULL;
> + return ERR_PTR(-EINVAL);
>  
>   return &mbox->chans[ind];
>  }
> diff --git a/drivers/mailbox/omap-mailbox.c b/drivers/mailbox/omap-mailbox.c
> index 0f332c1..e0df27b 100644
> --- a/drivers/mailbox/omap-mailbox.c
> +++ b/drivers/mailbox/omap-mailbox.c
> @@ -639,18 +639,18 @@ static struct mbox_chan *omap_mbox_of_xlate(struct 
> mbox_controller *controller,
>  
>   mdev = container_of(controller, struct omap_mbox_device, controller);
>   if (WARN_ON(!mdev))
> - return NULL;
> + return ERR_PTR(-EINVAL);
>  
>   node = of_find_node_by_phandle(phandle);
>   if (!node) {
>   pr_err("%s: could not find node phandle 0x%x\n",
>  __func__, phandle);
> - return NULL;
> + return ERR_PTR(-ENODEV);
>   }
>  
>   mbox = omap_mbox_device_find(mdev, node->name);
>   of_node_put(node);
> - return mbox ? mbox->chan : NULL;
> + return mbox ? mbox->chan : ERR_PTR(-ENOENT);
>  }
>  
>  static int omap_mbox_probe(struct platform_device *pdev)
> 

--
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 V7 2/9] mailbox: Make struct mbox_controller's ops field const

2015-04-28 Thread Suman Anna
Hi Andrew,

On 04/27/2015 05:37 PM, Andrew Bresticker wrote:
> The mailbox controller's channel ops ought to be read-only.

We ought to change this on all the existing controllers as well.

regards
Suman

> 
> Signed-off-by: Andrew Bresticker 
> Cc: Jassi Brar 
> ---
> No changes from v5/v6.
> New for v5.
> ---
>  include/linux/mailbox_controller.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/mailbox_controller.h 
> b/include/linux/mailbox_controller.h
> index d4cf96f..68c4245 100644
> --- a/include/linux/mailbox_controller.h
> +++ b/include/linux/mailbox_controller.h
> @@ -72,7 +72,7 @@ struct mbox_chan_ops {
>   */
>  struct mbox_controller {
>   struct device *dev;
> - struct mbox_chan_ops *ops;
> + const struct mbox_chan_ops *ops;
>   struct mbox_chan *chans;
>   int num_chans;
>   bool txdone_irq;
> 

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


Re: [PATCH] usb: phy: Remove the phy-rcar-gen2-usb driver

2015-04-28 Thread Felipe Balbi
On Tue, Apr 28, 2015 at 02:04:07PM +0200, Geert Uytterhoeven wrote:
> The phy-rcar-gen2-usb driver, which supports legacy platform data only,
> is no longer used since commit a483dcbfa21f919c ("ARM: shmobile: lager:
> Remove legacy board support").
> 
> This driver was superseded by the DT-only phy-rcar-gen2 driver, which
> was introduced in commit 1233f59f745b237d ("phy: Renesas R-Car Gen2 PHY
> driver").
> 
> Signed-off-by: Geert Uytterhoeven 
> ---
>  drivers/usb/phy/Kconfig |  13 --
>  drivers/usb/phy/Makefile|   1 -
>  drivers/usb/phy/phy-rcar-gen2-usb.c | 246 
> 
>  include/linux/platform_data/usb-rcar-gen2-phy.h |  22 ---
>  4 files changed, 282 deletions(-)
>  delete mode 100644 drivers/usb/phy/phy-rcar-gen2-usb.c
>  delete mode 100644 include/linux/platform_data/usb-rcar-gen2-phy.h
> 
> diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
> index 2175678e674ebf44..3cd3bee54ca6f9b3 100644
> --- a/drivers/usb/phy/Kconfig
> +++ b/drivers/usb/phy/Kconfig
> @@ -186,19 +186,6 @@ config USB_RCAR_PHY
> To compile this driver as a module, choose M here: the
> module will be called phy-rcar-usb.
>  
> -config USB_RCAR_GEN2_PHY

$ git grep -e USB_RCAR_GEN2_PHY
arch/arm/configs/multi_v7_defconfig:448:CONFIG_USB_RCAR_GEN2_PHY=m
arch/arm/configs/shmobile_defconfig:163:CONFIG_USB_RCAR_GEN2_PHY=y

Are you sending patches to fix both defconfigs ?

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] usb: core: add usb3 lpm sysfs

2015-04-28 Thread Zhuang Jin Can
Hi Greg KH,

On Tue, Apr 28, 2015 at 12:42:24PM +0200, Greg KH wrote:
> On Sun, Apr 19, 2015 at 11:46:12AM +0800, Zhuang Jin Can wrote:
> > Some usb3 devices may not support usb3 lpm well.
> > The patch adds a sysfs to enable/disable u1 or u2 of the port.The
> > settings apply to both before and after device enumeration.
> > Supported values are "0" - u1 and u2 are disabled, "u1" - only u1 is
> > enabled, "u2" - only u2 is enabled, "u1_u2" - u1 and u2 are enabled.
> > 
> > The interface is useful for testing some USB3 devices during
> > development, and provides a way to disable usb3 lpm if the issues can
> > not be fixed in final products.
> 
> How is a user supposed to "know" to make this setting for a device?  Why
> can't the kernel automatically set this value properly?  Why does it
> need to be a kernel issue at all?
> 
By default kernel enables u1 u2 of all USB3 devices. This interface
provides the user to change this policy. User may set the policy
according to PID/VID of uevent or according to the platform information
known by userspace.

It's not a kernel issue, as u1 u2 is mandatory by USB3 compliance. But
for some internal hardwired USB3 connection, e.g. SSIC, passing USB3
compliance is not mandatory. So the interface provides a way for vendor
to ship with u1 or u2 broken products. Of course, this is not encouraged :).

> And when you are doing development of broken devices, the kernel doesn't
> have to support you, you can run with debugging patches of your own
> until you fix your firmware :)
> 
Understood. But I think other vendor or developer may face the same
issue in final product shipment or during development. Moreover, the
interface provide the flexibility for developer to separately
disable/enable u1 or u2, e.g. If they're debugging an u2 issue, they
can disable u1 to simplify the situtation.

Thanks
Jincan
--
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 1/4] fs: configfs: Add unlocked version of configfs_depend_item()

2015-04-28 Thread Felipe Balbi
Hi,

On Thu, Apr 09, 2015 at 06:18:07PM +0200, Krzysztof Opasiak wrote:
> Sometimes it might be desirable to prohibit removing a directory
> in configfs. One example is USB gadget (mass_storage function):
> when gadget is already bound, if lun directory is removed,
> the gadget must be thrown away, too. A better solution would be
> to fail with e.g. -EBUSY.
> 
> Currently configfs has configfs_depend/undepend_item() methods
> but they cannot be used in configfs callbacks. This commit
> adds unlocked version of this methods which can be used
> only in configfs callbacks.
> 
> Signed-off-by: Krzysztof Opasiak 

Joel, any comments to this patch ?

> ---
>  fs/configfs/dir.c|   29 +
>  include/linux/configfs.h |9 +
>  2 files changed, 38 insertions(+)
> 
> diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
> index cf0db00..7875a5e 100644
> --- a/fs/configfs/dir.c
> +++ b/fs/configfs/dir.c
> @@ -1152,6 +1152,35 @@ void configfs_undepend_item(struct configfs_subsystem 
> *subsys,
>  }
>  EXPORT_SYMBOL(configfs_undepend_item);
>  
> +int configfs_depend_item_unlocked(struct config_item *target)
> +{
> + struct configfs_dirent *sd;
> + int ret = -ENOENT;
> +
> + spin_lock(&configfs_dirent_lock);
> + BUG_ON(!target->ci_dentry);
> +
> + sd = target->ci_dentry->d_fsdata;
> + if ((sd->s_type & CONFIGFS_DIR) &&
> + ((sd->s_type & CONFIGFS_USET_DROPPING) ||
> +  (sd->s_type & CONFIGFS_USET_CREATING)))
> + goto out_unlock_dirent_lock;
> +
> + sd->s_dependent_count += 1;
> + ret = 0;
> +
> +out_unlock_dirent_lock:
> + spin_unlock(&configfs_dirent_lock);
> + return ret;
> +}
> +EXPORT_SYMBOL(configfs_depend_item_unlocked);
> +
> +void configfs_undepend_item_unlocked(struct config_item *target)
> +{
> + configfs_undepend_item(NULL, target);
> +}
> +EXPORT_SYMBOL(configfs_undepend_item_unlocked);
> +
>  static int configfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t 
> mode)
>  {
>   int ret = 0;
> diff --git a/include/linux/configfs.h b/include/linux/configfs.h
> index 34025df..e9dbf01 100644
> --- a/include/linux/configfs.h
> +++ b/include/linux/configfs.h
> @@ -257,4 +257,13 @@ void configfs_unregister_subsystem(struct 
> configfs_subsystem *subsys);
>  int configfs_depend_item(struct configfs_subsystem *subsys, struct 
> config_item *target);
>  void configfs_undepend_item(struct configfs_subsystem *subsys, struct 
> config_item *target);
>  
> +/*
> + * These functions can sleep and can alloc with GFP_KERNEL
> + * NOTE: These should be called only underneath configfs callbacks.
> + * WARNING: These cannot be called on newly created item
> + *(in make_group()/make_item callback)
> + */
> +int configfs_depend_item_unlocked(struct config_item *target);
> +void configfs_undepend_item_unlocked(struct config_item *target);
> +
>  #endif /* _CONFIGFS_H_ */
> -- 
> 1.7.9.5
> 

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] usb: phy: Remove the phy-rcar-gen2-usb driver

2015-04-28 Thread Geert Uytterhoeven
Hi Felipe,

On Tue, Apr 28, 2015 at 6:50 PM, Felipe Balbi  wrote:
> On Tue, Apr 28, 2015 at 02:04:07PM +0200, Geert Uytterhoeven wrote:
>> The phy-rcar-gen2-usb driver, which supports legacy platform data only,
>> is no longer used since commit a483dcbfa21f919c ("ARM: shmobile: lager:
>> Remove legacy board support").
>>
>> This driver was superseded by the DT-only phy-rcar-gen2 driver, which
>> was introduced in commit 1233f59f745b237d ("phy: Renesas R-Car Gen2 PHY
>> driver").
>>
>> Signed-off-by: Geert Uytterhoeven 
>> ---
>>  drivers/usb/phy/Kconfig |  13 --
>>  drivers/usb/phy/Makefile|   1 -
>>  drivers/usb/phy/phy-rcar-gen2-usb.c | 246 
>> 
>>  include/linux/platform_data/usb-rcar-gen2-phy.h |  22 ---
>>  4 files changed, 282 deletions(-)
>>  delete mode 100644 drivers/usb/phy/phy-rcar-gen2-usb.c
>>  delete mode 100644 include/linux/platform_data/usb-rcar-gen2-phy.h
>>
>> diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
>> index 2175678e674ebf44..3cd3bee54ca6f9b3 100644
>> --- a/drivers/usb/phy/Kconfig
>> +++ b/drivers/usb/phy/Kconfig
>> @@ -186,19 +186,6 @@ config USB_RCAR_PHY
>> To compile this driver as a module, choose M here: the
>> module will be called phy-rcar-usb.
>>
>> -config USB_RCAR_GEN2_PHY
>
> $ git grep -e USB_RCAR_GEN2_PHY
> arch/arm/configs/multi_v7_defconfig:448:CONFIG_USB_RCAR_GEN2_PHY=m
> arch/arm/configs/shmobile_defconfig:163:CONFIG_USB_RCAR_GEN2_PHY=y
>
> Are you sending patches to fix both defconfigs ?

http://www.spinics.net/lists/arm-kernel/msg414542.html
http://www.spinics.net/lists/arm-kernel/msg414543.html

The driver doesn't work anyway in these (DT-only) configs, as it supports
platform data only.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
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 8/8] Documentation: usb: chipidea: Update test procedure for HNP polling

2015-04-28 Thread Felipe Balbi
On Thu, Mar 19, 2015 at 11:11:25AM +0800, Li Jun wrote:
> From: Li Jun 
> 
> Update HNP test procedure as HNP polling is supported.
> 
> Signed-off-by: Li Jun 
> ---
>  Documentation/usb/chipidea.txt |   11 ++-
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/Documentation/usb/chipidea.txt b/Documentation/usb/chipidea.txt
> index 3f848c1..ff965b2 100644
> --- a/Documentation/usb/chipidea.txt
> +++ b/Documentation/usb/chipidea.txt
> @@ -26,16 +26,17 @@ cat /sys/kernel/debug/ci_hdrc.0/registers
> On B-device:
> echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req
>  
> -   if HNP polling is not supported, also need:
> -   On A-device:
> -   echo 0 > /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_req
> -
> B-device should take host role and enumrate A-device.
>  
>  4) A-device switch back to host.
> -   On B-device:
> +   on B-device:
> echo 0 > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req
>  
> +   or, by introducing HNP polling, B-Host can know when A-peripheral wish to 
> be
> +   host role, so this role switch also can be trigged in A-peripheral side by
> +   answering the polling from B-Host, this can be done on A-device:
> +   echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_req

why is this still chipidea specific ? Why isn't this part on udc-core so
that all OTG UDCs can support this too ?

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] usb: phy: Remove the phy-rcar-gen2-usb driver

2015-04-28 Thread Felipe Balbi
On Tue, Apr 28, 2015 at 06:55:37PM +0200, Geert Uytterhoeven wrote:
> Hi Felipe,
> 
> On Tue, Apr 28, 2015 at 6:50 PM, Felipe Balbi  wrote:
> > On Tue, Apr 28, 2015 at 02:04:07PM +0200, Geert Uytterhoeven wrote:
> >> The phy-rcar-gen2-usb driver, which supports legacy platform data only,
> >> is no longer used since commit a483dcbfa21f919c ("ARM: shmobile: lager:
> >> Remove legacy board support").
> >>
> >> This driver was superseded by the DT-only phy-rcar-gen2 driver, which
> >> was introduced in commit 1233f59f745b237d ("phy: Renesas R-Car Gen2 PHY
> >> driver").
> >>
> >> Signed-off-by: Geert Uytterhoeven 
> >> ---
> >>  drivers/usb/phy/Kconfig |  13 --
> >>  drivers/usb/phy/Makefile|   1 -
> >>  drivers/usb/phy/phy-rcar-gen2-usb.c | 246 
> >> 
> >>  include/linux/platform_data/usb-rcar-gen2-phy.h |  22 ---
> >>  4 files changed, 282 deletions(-)
> >>  delete mode 100644 drivers/usb/phy/phy-rcar-gen2-usb.c
> >>  delete mode 100644 include/linux/platform_data/usb-rcar-gen2-phy.h
> >>
> >> diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
> >> index 2175678e674ebf44..3cd3bee54ca6f9b3 100644
> >> --- a/drivers/usb/phy/Kconfig
> >> +++ b/drivers/usb/phy/Kconfig
> >> @@ -186,19 +186,6 @@ config USB_RCAR_PHY
> >> To compile this driver as a module, choose M here: the
> >> module will be called phy-rcar-usb.
> >>
> >> -config USB_RCAR_GEN2_PHY
> >
> > $ git grep -e USB_RCAR_GEN2_PHY
> > arch/arm/configs/multi_v7_defconfig:448:CONFIG_USB_RCAR_GEN2_PHY=m
> > arch/arm/configs/shmobile_defconfig:163:CONFIG_USB_RCAR_GEN2_PHY=y
> >
> > Are you sending patches to fix both defconfigs ?
> 
> http://www.spinics.net/lists/arm-kernel/msg414542.html
> http://www.spinics.net/lists/arm-kernel/msg414543.html
> 
> The driver doesn't work anyway in these (DT-only) configs, as it supports
> platform data only.

thanks, this patch is now in my testing/next.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCHv3 08/11] usb: dwc3: add hsphy_interface property

2015-04-28 Thread Felipe Balbi
On Tue, Apr 28, 2015 at 04:24:43PM +0300, Heikki Krogerus wrote:
> Platforms that have configured DWC_USB3_HSPHY_INTERFACE with
> value 3, i.e. UTMI+ and ULPI, need to inform the driver of
> the actual HSPHY interface type with the property. "utmi" if
> the interface is UTMI+ or "ulpi" if the interface is ULPI.
> 
> Signed-off-by: Heikki Krogerus 
> Acked-by: David Cohen 
> ---
>  Documentation/devicetree/bindings/usb/dwc3.txt |  2 ++
>  drivers/usb/dwc3/core.c| 29 
> --
>  drivers/usb/dwc3/core.h|  3 +++
>  drivers/usb/dwc3/platform_data.h   |  2 ++
>  4 files changed, 34 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt 
> b/Documentation/devicetree/bindings/usb/dwc3.txt
> index 5cc3643..0815eac 100644
> --- a/Documentation/devicetree/bindings/usb/dwc3.txt
> +++ b/Documentation/devicetree/bindings/usb/dwc3.txt
> @@ -38,6 +38,8 @@ Optional properties:
>   - snps,is-utmi-l1-suspend: true when DWC3 asserts output signal
>   utmi_l1_suspend_n, false when asserts utmi_sleep_n
>   - snps,hird-threshold: HIRD threshold
> + - snps,hsphy_interface: High-Speed PHY interface selection between "utmi" 
> for
> +   UTMI+ and "ulpi" for ULPI when the DWC_USB3_HSPHY_INTERFACE has value 3.
>  
>  This is usually a subnode to DWC3 glue to which it is connected.
>  
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index 6b02e12..b229ba1 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -395,9 +395,10 @@ static void dwc3_cache_hwparams(struct dwc3 *dwc)
>   * dwc3_phy_setup - Configure USB PHY Interface of DWC3 Core
>   * @dwc: Pointer to our controller context structure
>   */
> -static void dwc3_phy_setup(struct dwc3 *dwc)
> +static int dwc3_phy_setup(struct dwc3 *dwc)
>  {
>   u32 reg;
> + int ret;
>  
>   reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
>  
> @@ -438,6 +439,22 @@ static void dwc3_phy_setup(struct dwc3 *dwc)
>  
>   reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
>  
> + /* Select the HS PHY interface */
> + switch (DWC3_GHWPARAMS3_HSPHY_IFC(dwc->hwparams.hwparams3)) {
> + case DWC3_GHWPARAMS3_HSPHY_IFC_UTMI_ULPI:
> + if (!strncmp(dwc->hsphy_interface, "utmi", 4)) {
> + reg &= ~DWC3_GUSB2PHYCFG_ULPI_UTMI;
> + } else if (!strncmp(dwc->hsphy_interface, "ulpi", 4)) {
> + reg |= DWC3_GUSB2PHYCFG_ULPI_UTMI;
> + } else {
> + dev_err(dwc->dev, "HSPHY Interface not defined\n");
> + return -EINVAL;

instead of erroring out, just leave default value and convert this to a
dev_warn() or something similar. That way, older DTS will continue to
work.

-- 
balbi


signature.asc
Description: Digital signature


[PATCH 3/3] Usb: core: buffer: fixed the checkpatch warning

2015-04-28 Thread Nizam Haider
Fixed two warnings sizeof name and Blank line after declaration

Signed-off-by: Nizam Haider 
---
 drivers/usb/core/buffer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c
index 684ef70..04125b6 100644
--- a/drivers/usb/core/buffer.c
+++ b/drivers/usb/core/buffer.c
@@ -62,7 +62,7 @@ int hcd_buffer_create(struct usb_hcd *hcd)
size = pool_max[i];
if (!size)
continue;
-   snprintf(name, sizeof name, "buffer-%d", size);
+   snprintf(name, sizeof(name), "buffer-%d", size);
hcd->pool[i] = dma_pool_create(name, hcd->self.controller,
size, size, 0);
if (!hcd->pool[i]) {
@@ -87,6 +87,7 @@ void hcd_buffer_destroy(struct usb_hcd *hcd)
 
for (i = 0; i < HCD_BUFFER_POOLS; i++) {
struct dma_pool *pool = hcd->pool[i];
+
if (pool) {
dma_pool_destroy(pool);
hcd->pool[i] = NULL;
-- 
1.8.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: [PATCHv3 00/12] usb: ulpi bus

2015-04-28 Thread Felipe Balbi
Hi,

On Tue, Apr 28, 2015 at 04:24:35PM +0300, Heikki Krogerus wrote:
> Hi,
> 
> I took the liberty of adding David's ACK to everything except 9/12, including 
> to
> the 1/12 (removing the module handling has no functional affect).
> 
> Changes since v2:
> - remove module handling from the bus driver as suggested by Paul Bolle.
> - reordered the gpio requests in BYT quirk as suggested by David Cohen.
> 
> Major changes since v1:
> - calling dwc3_phy_setup earlier and registering the ULPI interface there.
> - new property to dwc3 for selecting the interface in case of UTMI+ and ULPI 
> as
>   suggested by Felipe
> - dwc3 soft reset before registration of the ULPI interface to sync the clocks
>   as suggested by David
> - Including support for the BYT boards that have the GPIOs controlling the 
> reset
>   and cs signals.
> 
> Heikki Krogerus (12):
>   usb: add bus type for USB ULPI
>   usb: dwc3: USB2 PHY register access bits
>   usb: dwc3: ULPI or UTMI+ select
>   usb: dwc3: store driver data earlier
>   usb: dwc3: cache hwparams earlier
>   usb: dwc3: soft reset to it's own function
>   usb: dwc3: setup phys earlier

up to patch 7/12, I've applied to my testing/next. I'll wait for a
revised 8/12 before applying the rest.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCHv3 06/11] usb: dwc3: soft reset to it's own function

2015-04-28 Thread Felipe Balbi
On Tue, Apr 28, 2015 at 04:24:41PM +0300, Heikki Krogerus wrote:
> So it can be called from other places later.
> 
> Signed-off-by: Heikki Krogerus 
> Acked-by: David Cohen 
> ---
>  drivers/usb/dwc3/core.c | 46 ++
>  1 file changed, 30 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index 104b236..921f181 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -117,6 +117,33 @@ static int dwc3_core_soft_reset(struct dwc3 *dwc)
>  }
>  
>  /**
> + * dwc3_soft_reset - Issue soft reset
> + * @dwc: Pointer to our controller context structure
> + */
> +static int dwc3_soft_reset(struct dwc3 *dwc)

I don't see this being called anywhere else in your series and I would
really like to know when we would need to reset the core again ?

I don't oppose to having this split to own function because I rather
like how it looks, but I don't want to reset the IP needlessly either.

cheers

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] usb: gadget: ether: Fix MAC address parsing

2015-04-28 Thread Stefan Agner
On 2015-04-28 18:31, Felipe Balbi wrote:
> On Tue, Apr 28, 2015 at 06:15:51PM +0200, Krzysztof Opasiak wrote:
>> On 04/28/2015 05:59 PM, Stefan Agner wrote:
>> >On 2015-04-28 17:00, Krzysztof Opasiak wrote:
>> >>Hi Stefan,
>> >>
>> >>On 04/28/2015 01:51 PM, Stefan Agner wrote:
>> >>>MAC addresses can be written without leading zeros. A popular
>> >>>example is libc's ether_ntoa_r function which creates such
>> >>>MAC addresses.
>> >>>
>> >>>Example:
>> >>>00:14:3d:0f:ff:fe can be written as 0:14:3d:f:ff:fe
>> >>>
>> >>>Additionally, get_ether_addr potentially parsed past the end
>> >>>of the user provided string. Use the opportunity and fix the
>> >>>function to never parse beyond the end of the string while
>> >>>allowing MAC addresses with and without leading zeros.
>> >>>
>> >>>Signed-off-by: Stefan Agner 
>>
>> (...)
>>
>> >>
>> >>First of all thank you for your remark about reading past the buffer
>> >>in my version of this patch. I tried to make my change as little as
>> >>possible and didn't catch that this function is broken from beginning.
>> >>
>> >>This one is definitely better in this case but I'm afraid that it
>> >>won't be able to correctly interpret MAC address written without
>> >>separators while original version works fine for it.
>> >
>> >That is true, we need separators to be able to parse the address now. Do
>> >we need to support the format without separators? The sysfs
>> >documentation is not very clear about the supported format (e.g.
>> >Documentation/ABI/testing/configfs-usb-gadget-ecm).
>> >
>> >Having variable length of the individual bytes and no separators for the
>> >individual bytes somehow contradicts. We can of course just assume that
>> >we have 2 characters when using no separators, its just somewhat
>> >irregular...
>>
>> Let's check what is currently supported:
>>
>> 1) 00:14:3d:0f:ff:fe (no skipped 0, semicolons)
>> 2) 00.14.3d.0f.ff.fe (no skipped 0, dots)
>> 3) 00143d0e (no skipped 0, no separator)
>>
>> What we are actually trying to do is adding a new format:
>>
>> 4) 0:14:3d:f:ff:fe (skipped leading 0, semicolons)
>> 5) 0.14.3d.f.ff.fe (skipped leading 0, dots)
>>
>> In my humble opinion adding a new format in this case is a very good idea
>> but it should not affect any other format that is currently supported by
>> this function
> 
> agreed :-)

I would have traded the simpler and more robust code with format 3 :-)

However, when preserving format 3, my parsing approach is probably not
suited, since it requires the separator to increment the destination
arrays index. I will see what I can do.

Btw, one other odd format which is used by module parameters is coma
separated bytes with hexadecimal indicators:
0x00,0x04,0x9f,0x01,0x30,0xe0

Which allows to use the module_param_array. But probably definitely out
of scope here.

--
Stefan
--
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/1 v2] drivers/usb/chipidea/debuc.c: avoid out of bound read

2015-04-28 Thread Heinrich Schuchardt
A string written by the user may not be zero terminated.

sscanf may read memory beyond the buffer if no zero byte
is found.

For testing build with CONFIG_USB_CHIPIDEA=y, CONFIG_USB_CHIPIDEA_DEBUG=y.

Version 2:
  Use '\0' for char constant.

Signed-off-by: Heinrich Schuchardt 
---
 drivers/usb/chipidea/debug.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c
index dfb05ed..ef08af3 100644
--- a/drivers/usb/chipidea/debug.c
+++ b/drivers/usb/chipidea/debug.c
@@ -88,9 +88,13 @@ static ssize_t ci_port_test_write(struct file *file, const 
char __user *ubuf,
char buf[32];
int ret;
 
-   if (copy_from_user(buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
+   count = min_t(size_t, sizeof(buf) - 1, count);
+   if (copy_from_user(buf, ubuf, count))
return -EFAULT;
 
+   /* sscanf requires a zero terminated string */
+   buf[count] = '\0';
+
if (sscanf(buf, "%u", &mode) != 1)
return -EINVAL;
 
-- 
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] usb: gadget: ether: Fix MAC address parsing

2015-04-28 Thread Felipe Balbi
On Tue, Apr 28, 2015 at 07:28:21PM +0200, Stefan Agner wrote:
> On 2015-04-28 18:31, Felipe Balbi wrote:
> > On Tue, Apr 28, 2015 at 06:15:51PM +0200, Krzysztof Opasiak wrote:
> >> On 04/28/2015 05:59 PM, Stefan Agner wrote:
> >> >On 2015-04-28 17:00, Krzysztof Opasiak wrote:
> >> >>Hi Stefan,
> >> >>
> >> >>On 04/28/2015 01:51 PM, Stefan Agner wrote:
> >> >>>MAC addresses can be written without leading zeros. A popular
> >> >>>example is libc's ether_ntoa_r function which creates such
> >> >>>MAC addresses.
> >> >>>
> >> >>>Example:
> >> >>>00:14:3d:0f:ff:fe can be written as 0:14:3d:f:ff:fe
> >> >>>
> >> >>>Additionally, get_ether_addr potentially parsed past the end
> >> >>>of the user provided string. Use the opportunity and fix the
> >> >>>function to never parse beyond the end of the string while
> >> >>>allowing MAC addresses with and without leading zeros.
> >> >>>
> >> >>>Signed-off-by: Stefan Agner 
> >>
> >> (...)
> >>
> >> >>
> >> >>First of all thank you for your remark about reading past the buffer
> >> >>in my version of this patch. I tried to make my change as little as
> >> >>possible and didn't catch that this function is broken from beginning.
> >> >>
> >> >>This one is definitely better in this case but I'm afraid that it
> >> >>won't be able to correctly interpret MAC address written without
> >> >>separators while original version works fine for it.
> >> >
> >> >That is true, we need separators to be able to parse the address now. Do
> >> >we need to support the format without separators? The sysfs
> >> >documentation is not very clear about the supported format (e.g.
> >> >Documentation/ABI/testing/configfs-usb-gadget-ecm).
> >> >
> >> >Having variable length of the individual bytes and no separators for the
> >> >individual bytes somehow contradicts. We can of course just assume that
> >> >we have 2 characters when using no separators, its just somewhat
> >> >irregular...
> >>
> >> Let's check what is currently supported:
> >>
> >> 1) 00:14:3d:0f:ff:fe (no skipped 0, semicolons)
> >> 2) 00.14.3d.0f.ff.fe (no skipped 0, dots)
> >> 3) 00143d0e (no skipped 0, no separator)
> >>
> >> What we are actually trying to do is adding a new format:
> >>
> >> 4) 0:14:3d:f:ff:fe (skipped leading 0, semicolons)
> >> 5) 0.14.3d.f.ff.fe (skipped leading 0, dots)
> >>
> >> In my humble opinion adding a new format in this case is a very good idea
> >> but it should not affect any other format that is currently supported by
> >> this function
> > 
> > agreed :-)
> 
> I would have traded the simpler and more robust code with format 3 :-)
> 
> However, when preserving format 3, my parsing approach is probably not
> suited, since it requires the separator to increment the destination
> arrays index. I will see what I can do.
> 
> Btw, one other odd format which is used by module parameters is coma
> separated bytes with hexadecimal indicators:
> 0x00,0x04,0x9f,0x01,0x30,0xe0
> 
> Which allows to use the module_param_array. But probably definitely out
> of scope here.

yeah, that's probably never gonna be used though as we can't add
per-instance module parameters.

-- 
balbi


signature.asc
Description: Digital signature


[PATCH v2] usb: gadget: ether: Fix MAC address parsing

2015-04-28 Thread Stefan Agner
MAC addresses can be written without leading zeros. A popular
example is libc's ether_ntoa_r function which creates such
MAC addresses.

Example:
00:14:3d:0f:ff:fe can be written as 0:14:3d:f:ff:fe

The function get_ether_addr potentially also parsed past the
end of the user provided string. Use the opportunity and fix
the function to never parse beyond the end of the string while
allowing MAC addresses with and without leading zeros. Also
corner cases such as 00:14:3d:0f:ff:0 + new-line character
are parsed correctly.

Signed-off-by: Stefan Agner 
---
 drivers/usb/gadget/function/u_ether.c | 65 +++
 1 file changed, 51 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/gadget/function/u_ether.c 
b/drivers/usb/gadget/function/u_ether.c
index f1fd777..287a7dc 100644
--- a/drivers/usb/gadget/function/u_ether.c
+++ b/drivers/usb/gadget/function/u_ether.c
@@ -703,25 +703,57 @@ static int eth_stop(struct net_device *net)
 
 /*-*/
 
+/**
+ * get_ether_addr - parse ethernet address from string
+ * @str: string to parse
+ * @ethaddr: a buffer in which the parsed ethernet address will be
+ *  written
+ *
+ * Several common formats are supported:
+ * 1) 00:14:3d:0f:ff:fe (no skipped 0, semicolons)
+ * 2) 00.14.3d.0f.ff.fe (no skipped 0, dots)
+ * 3) 00143d0e (no skipped 0, no separator)
+ * 4) 0:14:3d:f:ff:fe (skipped leading 0, semicolons)
+ * 5) 0.14.3d.f.ff.fe (skipped leading 0, dots)
+ *
+ * The function will not cross the end of the provided string even
+ * when the string has the wrong format.
+ *
+ * Returns 0 on success, or -EINVAL on error
+ */
 static int get_ether_addr(const char *str, u8 *dev_addr)
 {
-   if (str) {
-   unsignedi;
+   int num, i;
 
-   for (i = 0; i < 6; i++) {
-   unsigned char num;
+   for (i = 0; i < ETH_ALEN; i++) {
+   int j = 0;
 
-   if ((*str == '.') || (*str == ':'))
+   dev_addr[i] = 0;
+   while (*str) {
+   char c = *str;
+
+   if (c == '.' || c == ':') {
str++;
-   num = hex_to_bin(*str++) << 4;
-   num |= hex_to_bin(*str++);
-   dev_addr [i] = num;
+   break;
+   }
+
+   if (j >= 2)
+   break;
+
+   num = hex_to_bin(c);
+   if (!(num < 0)) {
+   dev_addr[i] <<= 4;
+   dev_addr[i] |= num;
+   }
+   j++;
+   str++;
}
-   if (is_valid_ether_addr(dev_addr))
-   return 0;
}
-   eth_random_addr(dev_addr);
-   return 1;
+
+   if (!is_valid_ether_addr(dev_addr))
+   return -EINVAL;
+
+   return 0;
 }
 
 static int get_ether_addr_str(u8 dev_addr[ETH_ALEN], char *str, int len)
@@ -786,12 +818,17 @@ struct eth_dev *gether_setup_name(struct usb_gadget *g,
dev->qmult = qmult;
snprintf(net->name, sizeof(net->name), "%s%%d", netname);
 
-   if (get_ether_addr(dev_addr, net->dev_addr))
+   if (get_ether_addr(dev_addr, net->dev_addr)) {
+   eth_random_addr(net->dev_addr);
dev_warn(&g->dev,
"using random %s ethernet address\n", "self");
-   if (get_ether_addr(host_addr, dev->host_mac))
+   }
+
+   if (get_ether_addr(host_addr, dev->host_mac)) {
+   eth_random_addr(dev->host_mac);
dev_warn(&g->dev,
"using random %s ethernet address\n", "host");
+   }
 
if (ethaddr)
memcpy(ethaddr, dev->host_mac, ETH_ALEN);
-- 
2.3.6

--
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/3] Usb: core: buffer: fixed the checkpatch warning

2015-04-28 Thread Greg KH
On Tue, Apr 28, 2015 at 05:17:11PM +0530, Nizam Haider wrote:
> Fixed two warnings sizeof name and Blank line after declaration
> 
> Signed-off-by: Nizam Haider 
> ---
>  drivers/usb/core/buffer.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Where are patches 1/3 and 2/3?

Please resend them all properly.

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


Computer Reboots Instead of Shutting Down

2015-04-28 Thread Brian Monroe
I filed a bug with kernel.org:
https://bugzilla.kernel.org/show_bug.cgi?id=97391 and Greg
Kroah-Hartman requested that I email this list to advise you of the
issue as well.

There's also a bug that's been filed with Fedora
https://bugzilla.redhat.com/show_bug.cgi?id=1168557 for this issue,
and there's the lspci info from different machines listed there.

The computer will reboot instead of shutting down. We found a work
around when you disable xHCI (and consequently USB3) support in the
BIOS and the bug goes away. This has been present in Version 3.17 and
later in the kernel changes for Fedora 21.
--
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 14/22] usb: dwc2: host: register handle to the phy

2015-04-28 Thread Kaukab, Yousaf
> -Original Message-
> From: Felipe Balbi [mailto:ba...@ti.com]
> Sent: Monday, April 27, 2015 10:43 PM
> To: Kaukab, Yousaf
> Cc: linux-usb@vger.kernel.org; ba...@ti.com; john.y...@synopsys.com;
> Herrero, Gregory; r.bald...@samsung.com;
> dingu...@opensource.altera.com; zhangfei@linaro.org;
> jwer...@chromium.org; sergei.shtyl...@cogentembedded.com
> Subject: Re: [PATCH v4 14/22] usb: dwc2: host: register handle to the phy
> 
> On Tue, Mar 24, 2015 at 10:01:02AM +0100, Mian Yousaf Kaukab wrote:
> > If phy driver is present register hcd handle to it.
> >
> > Signed-off-by: Mian Yousaf Kaukab 
> > ---
> >  drivers/usb/dwc2/hcd.c | 6 ++
> >  1 file changed, 6 insertions(+)
> >
> > diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index
> > 1cca5e0..919658e 100644
> > --- a/drivers/usb/dwc2/hcd.c
> > +++ b/drivers/usb/dwc2/hcd.c
> > @@ -2913,6 +2913,9 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int
> irq)
> > /* Don't support SG list at this point */
> > hcd->self.sg_tablesize = 0;
> >
> > +   if (!IS_ERR_OR_NULL(hsotg->uphy))
> 
> when is uphy NULL ? Aparently, only platform.c sets it to NULL in case of 
> error,
> I'd say we should just make NULL a valid PHY pointer, then we can remove a
> bunch of these checks scattered around.

Here we can't as we want to dereference uphy.
However, I like the idea and I guess it entails a separate patch to fix where 
possible?

> 
> --
> balbi

BR,
Yousaf
--
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 14/22] usb: dwc2: host: register handle to the phy

2015-04-28 Thread Felipe Balbi
On Tue, Apr 28, 2015 at 08:47:08PM +, Kaukab, Yousaf wrote:
> > -Original Message-
> > From: Felipe Balbi [mailto:ba...@ti.com]
> > Sent: Monday, April 27, 2015 10:43 PM
> > To: Kaukab, Yousaf
> > Cc: linux-usb@vger.kernel.org; ba...@ti.com; john.y...@synopsys.com;
> > Herrero, Gregory; r.bald...@samsung.com;
> > dingu...@opensource.altera.com; zhangfei@linaro.org;
> > jwer...@chromium.org; sergei.shtyl...@cogentembedded.com
> > Subject: Re: [PATCH v4 14/22] usb: dwc2: host: register handle to the phy
> > 
> > On Tue, Mar 24, 2015 at 10:01:02AM +0100, Mian Yousaf Kaukab wrote:
> > > If phy driver is present register hcd handle to it.
> > >
> > > Signed-off-by: Mian Yousaf Kaukab 
> > > ---
> > >  drivers/usb/dwc2/hcd.c | 6 ++
> > >  1 file changed, 6 insertions(+)
> > >
> > > diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index
> > > 1cca5e0..919658e 100644
> > > --- a/drivers/usb/dwc2/hcd.c
> > > +++ b/drivers/usb/dwc2/hcd.c
> > > @@ -2913,6 +2913,9 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int
> > irq)
> > >   /* Don't support SG list at this point */
> > >   hcd->self.sg_tablesize = 0;
> > >
> > > + if (!IS_ERR_OR_NULL(hsotg->uphy))
> > 
> > when is uphy NULL ? Aparently, only platform.c sets it to NULL in case of 
> > error,
> > I'd say we should just make NULL a valid PHY pointer, then we can remove a
> > bunch of these checks scattered around.
> 
> Here we can't as we want to dereference uphy.
> However, I like the idea and I guess it entails a separate patch to
> fix where possible?

yeah, I'll handle that, unless you want to. It should be pretty simple.

-- 
balbi


signature.asc
Description: Digital signature


RE: [PATCH v4 14/22] usb: dwc2: host: register handle to the phy

2015-04-28 Thread Kaukab, Yousaf
> -Original Message-
> From: Felipe Balbi [mailto:ba...@ti.com]
> Sent: Tuesday, April 28, 2015 10:49 PM
> To: Kaukab, Yousaf
> Cc: ba...@ti.com; linux-usb@vger.kernel.org; john.y...@synopsys.com;
> Herrero, Gregory; r.bald...@samsung.com;
> dingu...@opensource.altera.com; zhangfei@linaro.org;
> jwer...@chromium.org; sergei.shtyl...@cogentembedded.com
> Subject: Re: [PATCH v4 14/22] usb: dwc2: host: register handle to the phy
> 
> On Tue, Apr 28, 2015 at 08:47:08PM +, Kaukab, Yousaf wrote:
> > > -Original Message-
> > > From: Felipe Balbi [mailto:ba...@ti.com]
> > > Sent: Monday, April 27, 2015 10:43 PM
> > > To: Kaukab, Yousaf
> > > Cc: linux-usb@vger.kernel.org; ba...@ti.com; john.y...@synopsys.com;
> > > Herrero, Gregory; r.bald...@samsung.com;
> > > dingu...@opensource.altera.com; zhangfei@linaro.org;
> > > jwer...@chromium.org; sergei.shtyl...@cogentembedded.com
> > > Subject: Re: [PATCH v4 14/22] usb: dwc2: host: register handle to
> > > the phy
> > >
> > > On Tue, Mar 24, 2015 at 10:01:02AM +0100, Mian Yousaf Kaukab wrote:
> > > > If phy driver is present register hcd handle to it.
> > > >
> > > > Signed-off-by: Mian Yousaf Kaukab 
> > > > ---
> > > >  drivers/usb/dwc2/hcd.c | 6 ++
> > > >  1 file changed, 6 insertions(+)
> > > >
> > > > diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index
> > > > 1cca5e0..919658e 100644
> > > > --- a/drivers/usb/dwc2/hcd.c
> > > > +++ b/drivers/usb/dwc2/hcd.c
> > > > @@ -2913,6 +2913,9 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg,
> > > > int
> > > irq)
> > > > /* Don't support SG list at this point */
> > > > hcd->self.sg_tablesize = 0;
> > > >
> > > > +   if (!IS_ERR_OR_NULL(hsotg->uphy))
> > >
> > > when is uphy NULL ? Aparently, only platform.c sets it to NULL in
> > > case of error, I'd say we should just make NULL a valid PHY pointer,
> > > then we can remove a bunch of these checks scattered around.
> >
> > Here we can't as we want to dereference uphy.
> > However, I like the idea and I guess it entails a separate patch to
> > fix where possible?
> 
> yeah, I'll handle that, unless you want to. It should be pretty simple.

I can do it if it can wait.

> 
> --
> balbi

BR,
Yousaf
--
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: core: add usb3 lpm sysfs

2015-04-28 Thread Greg KH
On Wed, Apr 29, 2015 at 12:51:27AM +0800, Zhuang Jin Can wrote:
> Hi Greg KH,
> 
> On Tue, Apr 28, 2015 at 12:42:24PM +0200, Greg KH wrote:
> > On Sun, Apr 19, 2015 at 11:46:12AM +0800, Zhuang Jin Can wrote:
> > > Some usb3 devices may not support usb3 lpm well.
> > > The patch adds a sysfs to enable/disable u1 or u2 of the port.The
> > > settings apply to both before and after device enumeration.
> > > Supported values are "0" - u1 and u2 are disabled, "u1" - only u1 is
> > > enabled, "u2" - only u2 is enabled, "u1_u2" - u1 and u2 are enabled.
> > > 
> > > The interface is useful for testing some USB3 devices during
> > > development, and provides a way to disable usb3 lpm if the issues can
> > > not be fixed in final products.
> > 
> > How is a user supposed to "know" to make this setting for a device?  Why
> > can't the kernel automatically set this value properly?  Why does it
> > need to be a kernel issue at all?
> > 
> By default kernel enables u1 u2 of all USB3 devices. This interface
> provides the user to change this policy. User may set the policy
> according to PID/VID of uevent or according to the platform information
> known by userspace.

And why would they ever want to do that?

> It's not a kernel issue, as u1 u2 is mandatory by USB3 compliance. But
> for some internal hardwired USB3 connection, e.g. SSIC, passing USB3
> compliance is not mandatory. So the interface provides a way for vendor
> to ship with u1 or u2 broken products. Of course, this is not encouraged :).

If the state is broken for those devices, we can't require the user to
fix it for us, the kernel should do it automatically.

> > And when you are doing development of broken devices, the kernel doesn't
> > have to support you, you can run with debugging patches of your own
> > until you fix your firmware :)
> > 
> Understood. But I think other vendor or developer may face the same
> issue in final product shipment or during development. Moreover, the
> interface provide the flexibility for developer to separately
> disable/enable u1 or u2, e.g. If they're debugging an u2 issue, they
> can disable u1 to simplify the situtation.

For debugging only, perhaps, but for a "normal" user, please let's
handle this automatically and don't create a switch that never gets used
by anyone or anything.

thanks,

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


Re: [PATCH] usb: dwc2: gadget: cleanup useless code

2015-04-28 Thread John Youn
On 4/26/2015 12:36 AM, Yunzhi Li wrote:
> dwc2 gadget driver s3c_hsotg_of_probe() run twice in
> dwc2_gadget_init() and the first one is useless, so remove it.
> 
> Signed-off-by: Yunzhi Li 
> ---
>  drivers/usb/dwc2/gadget.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
> index 6a30887..2ae74f2 100644
> --- a/drivers/usb/dwc2/gadget.c
> +++ b/drivers/usb/dwc2/gadget.c
> @@ -3851,8 +3851,6 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
>   /* Set default UTMI width */
>   hsotg->phyif = GUSBCFG_PHYIF16;
>  
> - s3c_hsotg_of_probe(hsotg);
> -
>   /* Initialize to legacy fifo configuration values */
>   hsotg->g_rx_fifo_sz = 2048;
>   hsotg->g_np_g_tx_fifo_sz = 1024;
> 


Acked-by: John Youn 

--
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: dwc2: gadget: cleanup useless code

2015-04-28 Thread John Youn
On 4/28/2015 3:50 PM, John Youn wrote:
> On 4/26/2015 12:36 AM, Yunzhi Li wrote:
>> dwc2 gadget driver s3c_hsotg_of_probe() run twice in
>> dwc2_gadget_init() and the first one is useless, so remove it.
>>
>> Signed-off-by: Yunzhi Li 
>> ---
>>  drivers/usb/dwc2/gadget.c | 2 --
>>  1 file changed, 2 deletions(-)
>>
>> diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
>> index 6a30887..2ae74f2 100644
>> --- a/drivers/usb/dwc2/gadget.c
>> +++ b/drivers/usb/dwc2/gadget.c
>> @@ -3851,8 +3851,6 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
>>  /* Set default UTMI width */
>>  hsotg->phyif = GUSBCFG_PHYIF16;
>>  
>> -s3c_hsotg_of_probe(hsotg);
>> -
>>  /* Initialize to legacy fifo configuration values */
>>  hsotg->g_rx_fifo_sz = 2048;
>>  hsotg->g_np_g_tx_fifo_sz = 1024;
>>
> 
> 
> Acked-by: John Youn 
> 

Added Felipe.

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] usb: gadget: xilinx: fix devm_ioremap_resource() check

2015-04-28 Thread Vladimir Zapolskiy
On 30.03.2015 05:38, Sören Brinkmann wrote:
> On Sun, 2015-03-29 at 05:43AM +0300, Vladimir Zapolskiy wrote:
>> devm_ioremap_resource() returns IOMEM_ERR_PTR() and it never
>> returns NULL, fix the check to prevent access to invalid
>> virtual address.
>>
>> Signed-off-by: Vladimir Zapolskiy 
> Reviewed-by: Sören Brinkmann 
> 

Ping.

--
With best wishes,
Vladimir
--
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 14/22] usb: dwc2: host: register handle to the phy

2015-04-28 Thread Felipe Balbi
Hi,

On Tue, Apr 28, 2015 at 09:09:40PM +, Kaukab, Yousaf wrote:
> > -Original Message-
> > From: Felipe Balbi [mailto:ba...@ti.com]
> > Sent: Tuesday, April 28, 2015 10:49 PM
> > To: Kaukab, Yousaf
> > Cc: ba...@ti.com; linux-usb@vger.kernel.org; john.y...@synopsys.com;
> > Herrero, Gregory; r.bald...@samsung.com;
> > dingu...@opensource.altera.com; zhangfei@linaro.org;
> > jwer...@chromium.org; sergei.shtyl...@cogentembedded.com
> > Subject: Re: [PATCH v4 14/22] usb: dwc2: host: register handle to the phy
> > 
> > On Tue, Apr 28, 2015 at 08:47:08PM +, Kaukab, Yousaf wrote:
> > > > -Original Message-
> > > > From: Felipe Balbi [mailto:ba...@ti.com]
> > > > Sent: Monday, April 27, 2015 10:43 PM
> > > > To: Kaukab, Yousaf
> > > > Cc: linux-usb@vger.kernel.org; ba...@ti.com; john.y...@synopsys.com;
> > > > Herrero, Gregory; r.bald...@samsung.com;
> > > > dingu...@opensource.altera.com; zhangfei@linaro.org;
> > > > jwer...@chromium.org; sergei.shtyl...@cogentembedded.com
> > > > Subject: Re: [PATCH v4 14/22] usb: dwc2: host: register handle to
> > > > the phy
> > > >
> > > > On Tue, Mar 24, 2015 at 10:01:02AM +0100, Mian Yousaf Kaukab wrote:
> > > > > If phy driver is present register hcd handle to it.
> > > > >
> > > > > Signed-off-by: Mian Yousaf Kaukab 
> > > > > ---
> > > > >  drivers/usb/dwc2/hcd.c | 6 ++
> > > > >  1 file changed, 6 insertions(+)
> > > > >
> > > > > diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index
> > > > > 1cca5e0..919658e 100644
> > > > > --- a/drivers/usb/dwc2/hcd.c
> > > > > +++ b/drivers/usb/dwc2/hcd.c
> > > > > @@ -2913,6 +2913,9 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg,
> > > > > int
> > > > irq)
> > > > >   /* Don't support SG list at this point */
> > > > >   hcd->self.sg_tablesize = 0;
> > > > >
> > > > > + if (!IS_ERR_OR_NULL(hsotg->uphy))
> > > >
> > > > when is uphy NULL ? Aparently, only platform.c sets it to NULL in
> > > > case of error, I'd say we should just make NULL a valid PHY pointer,
> > > > then we can remove a bunch of these checks scattered around.
> > >
> > > Here we can't as we want to dereference uphy.
> > > However, I like the idea and I guess it entails a separate patch to
> > > fix where possible?
> > 
> > yeah, I'll handle that, unless you want to. It should be pretty simple.
> 
> I can do it if it can wait.

oh, no rush. But I'd like to get it in time for v4.2 :-) I can
definitely wait a couple weeks.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] usb: gadget: xilinx: fix devm_ioremap_resource() check

2015-04-28 Thread Felipe Balbi
On Wed, Apr 29, 2015 at 02:59:14AM +0300, Vladimir Zapolskiy wrote:
> On 30.03.2015 05:38, Sören Brinkmann wrote:
> > On Sun, 2015-03-29 at 05:43AM +0300, Vladimir Zapolskiy wrote:
> >> devm_ioremap_resource() returns IOMEM_ERR_PTR() and it never
> >> returns NULL, fix the check to prevent access to invalid
> >> virtual address.
> >>
> >> Signed-off-by: Vladimir Zapolskiy 
> > Reviewed-by: Sören Brinkmann 
> > 
> 
> Ping.

see my testing/fixes.

-- 
balbi


signature.asc
Description: Digital signature


RE: [PATCH] usb: gadget: composite: enable BESL support

2015-04-28 Thread Du, Changbin
> > From: Felipe Balbi 
> > Date: Tue, 30 Sep 2014 16:08:03 -0500
> > Subject: [PATCH] usb: gadget: composite: enable BESL support
> 
> missing upstream commit.
> 
> > According to USB 2.0 ECN Errata for Link Power Management
> > (USB2-LPM-Errata-final.pdf), BESL must be enabled if LPM is enabled.
> >
> > This helps with USB30CV TD 9.21 LPM L1 Suspend Resume Test.
> >
> > Cc:  # 3.14
> 
> this should be backported all the way back to 3.1. The commit which this
> patch is fixing, was applied on v3.1, so we're probably going to backport to
> 3.10 and 3.14. When asking for backports, don't consider only your project,
> think about the kernel/stable releases as a whole.
> 
> BTW, that should be v3.1+, the + tells the Stable team that from v3.1 forward,
> all kernels need the backport.
> 
> > Signed-off-by: Felipe Balbi 
> > Signed-off-by: Du, Changbin 
> > ---
> > Hi,
> >
> > This patch was introduced on v3.18. However the issue fixed already
> > existed on
> > v3.14 and v3.14 is a long term support version.
> 
> the issue already existed on v3.1, why did you decide to backport only to
> v3.14 ?
> 
> > So propose to backport it over there as well.
> >
> --
> balbi

Thanks for pointing it out, Balbi. Sorry for not considering the whole trees. 
This
is my first time to send backport request and now know how do it well. I will
resend request with field updated.

Du, Changbin
Regards
--
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: gadget: composite: enable BESL support

2015-04-28 Thread Du, Changbin
>From a6615937bcd9234e6d6bb817c3701fce44d0a84d Mon Sep 17 00:00:00 2001
From: Felipe Balbi 
Date: Tue, 30 Sep 2014 16:08:03 -0500
Subject: [PATCH] usb: gadget: composite: enable BESL support

According to USB 2.0 ECN Errata for Link Power
Management (USB2-LPM-Errata-final.pdf), BESL
must be enabled if LPM is enabled.

This helps with USB30CV TD 9.21 LPM L1
Suspend Resume Test.

Cc:  # 3.1+: a661593: usb: enable BESL support
Signed-off-by: Felipe Balbi 
Signed-off-by: Du, Changbin 
---
Hi,

This patch was introduced on v3.18. However the issue fixed already existed on
v3.1. Thank Balbi for pointing it out.

So propose to backport it over all 3.1+ stable trees as well.

Du, Changbin
---
 drivers/usb/gadget/composite.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index a8c18df..f6a51fd 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -560,7 +560,7 @@ static int bos_desc(struct usb_composite_dev *cdev)
usb_ext->bLength = USB_DT_USB_EXT_CAP_SIZE;
usb_ext->bDescriptorType = USB_DT_DEVICE_CAPABILITY;
usb_ext->bDevCapabilityType = USB_CAP_TYPE_EXT;
-   usb_ext->bmAttributes = cpu_to_le32(USB_LPM_SUPPORT);
+   usb_ext->bmAttributes = cpu_to_le32(USB_LPM_SUPPORT | USB_BESL_SUPPORT);
 
/*
 * The Superspeed USB Capability descriptor shall be implemented by all
-- 
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 v2] usb: gadget: composite: enable BESL support

2015-04-28 Thread Felipe Balbi
Hi,

On Wed, Apr 29, 2015 at 03:40:28AM +, Du, Changbin wrote:
> From a6615937bcd9234e6d6bb817c3701fce44d0a84d Mon Sep 17 00:00:00 2001
> From: Felipe Balbi 
> Date: Tue, 30 Sep 2014 16:08:03 -0500
> Subject: [PATCH] usb: gadget: composite: enable BESL support
> 
> According to USB 2.0 ECN Errata for Link Power
> Management (USB2-LPM-Errata-final.pdf), BESL
> must be enabled if LPM is enabled.
> 
> This helps with USB30CV TD 9.21 LPM L1
> Suspend Resume Test.
> 
> Cc:  # 3.1+: a661593: usb: enable BESL support
> Signed-off-by: Felipe Balbi 
> Signed-off-by: Du, Changbin 

this is still not how you send a patch for stable, please have a look at
commits on the stable tree and mimic the format.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] usb: gadget: composite: enable BESL support

2015-04-28 Thread Felipe Balbi
On Wed, Apr 29, 2015 at 03:04:51AM +, Du, Changbin wrote:
> > > From: Felipe Balbi 
> > > Date: Tue, 30 Sep 2014 16:08:03 -0500
> > > Subject: [PATCH] usb: gadget: composite: enable BESL support
> > 
> > missing upstream commit.
> > 
> > > According to USB 2.0 ECN Errata for Link Power Management
> > > (USB2-LPM-Errata-final.pdf), BESL must be enabled if LPM is enabled.
> > >
> > > This helps with USB30CV TD 9.21 LPM L1 Suspend Resume Test.
> > >
> > > Cc:  # 3.14
> > 
> > this should be backported all the way back to 3.1. The commit which this
> > patch is fixing, was applied on v3.1, so we're probably going to backport to
> > 3.10 and 3.14. When asking for backports, don't consider only your project,
> > think about the kernel/stable releases as a whole.
> > 
> > BTW, that should be v3.1+, the + tells the Stable team that from v3.1 
> > forward,
> > all kernels need the backport.
> > 
> > > Signed-off-by: Felipe Balbi 
> > > Signed-off-by: Du, Changbin 
> > > ---
> > > Hi,
> > >
> > > This patch was introduced on v3.18. However the issue fixed already
> > > existed on
> > > v3.14 and v3.14 is a long term support version.
> > 
> > the issue already existed on v3.1, why did you decide to backport only to
> > v3.14 ?
> > 
> > > So propose to backport it over there as well.
> > >
> > --
> > balbi
> 
> Thanks for pointing it out, Balbi. Sorry for not considering the whole
> trees. This is my first time to send backport request and now know how
> do it well. I will resend request with field updated.

ok, things which usually help are:

'git log -SLPM -- drivers/usb/gadget/composite.c'
this will help you find commits which have the string LPM in
their body and touch drivers/usb/gadget/composite.c

'git describe'
this will tell you when a commit was merged. Keep in mind that a
commit reaches a maintainer tree before Linus tags something, so
if git describe says: v3.0-rc3-212-gfoobar, that means commit
reaches mainline during v3.1 merge window.

Documentation/stable_kernel_rules.txt
This tells what a stable patch should look like

'git remote add stable \
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git \
&& git fetch stable && git log stable/linux-3.14.y'

This would help you see actual commits in a stable tree so you
can mimic the format.

cheers

-- 
balbi


signature.asc
Description: Digital signature