USB_MUSB_DA8XX with g_multi.ko

2014-06-25 Thread Jon Ringle
In commit 787f5627bec80094db487bfcb401e9744f181aed
usb: musb: make davinci and da8xx glues depend on BROKEN

USB_MUSB_DA8XX was marked as BROKEN

A few months ago, we updated the linux kernel on our AM1808 SoC based
embedded board from Linux 2.6.33 to the latest long term 3.12.

I am interested in having the USB gadget support on my board, so I
removed BROKEN on USB_MUSB_DA8XX. I found that when I modprobe
g_ether, g_serial, and g_mass_storage (by themselves), they all appear
to work as expected, but if I try to use g_multi to have a composite
device supporting all three simultaneously, I run into failure during
initialization.

Here is the USB related config:
# zcat /proc/config.gz |grep "^CONFIG_USB"
CONFIG_USB_HID=y
CONFIG_USB_OHCI_LITTLE_ENDIAN=y
CONFIG_USB_SUPPORT=y
CONFIG_USB_COMMON=y
CONFIG_USB_ARCH_HAS_HCD=y
CONFIG_USB=y
CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
CONFIG_USB_DEFAULT_PERSIST=y
CONFIG_USB_OTG=y
CONFIG_USB_OHCI_HCD=y
CONFIG_USB_MUSB_HDRC=y
CONFIG_USB_MUSB_DUAL_ROLE=y
CONFIG_USB_MUSB_DA8XX=y
CONFIG_USB_STORAGE=y
CONFIG_USB_SERIAL=y
CONFIG_USB_SERIAL_CONSOLE=y
CONFIG_USB_SERIAL_GENERIC=y
CONFIG_USB_SERIAL_FTDI_SIO=y
CONFIG_USB_SERIAL_PL2303=y
CONFIG_USB_PHY=y
CONFIG_USB_ULPI=y
CONFIG_USB_GADGET=y
CONFIG_USB_GADGET_DEBUG=y
CONFIG_USB_GADGET_DEBUG_FILES=y
CONFIG_USB_GADGET_DEBUG_FS=y
CONFIG_USB_GADGET_VBUS_DRAW=2
CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS=2
CONFIG_USB_LIBCOMPOSITE=m
CONFIG_USB_F_ACM=m
CONFIG_USB_U_SERIAL=m
CONFIG_USB_U_ETHER=m
CONFIG_USB_U_RNDIS=m
CONFIG_USB_F_SERIAL=m
CONFIG_USB_F_OBEX=m
CONFIG_USB_F_ECM=m
CONFIG_USB_F_SUBSET=m
CONFIG_USB_F_RNDIS=m
CONFIG_USB_ETH=m
CONFIG_USB_ETH_RNDIS=y
CONFIG_USB_MASS_STORAGE=m
CONFIG_USB_G_SERIAL=m
CONFIG_USB_G_MULTI=m
CONFIG_USB_G_MULTI_RNDIS=y

# modprobe g_multi file=/root/backing_file
modprobe: can't load module g_multi
(kernel/drivers/usb/gadget/g_multi.ko): Unknown error 524

I added a couple of debug message to identify where I was failing in:

diff --git a/drivers/usb/gadget/f_mass_storage.c
b/drivers/usb/gadget/f_mass_storage.c
index a01d7d3..3e7a22a 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -2899,14 +2899,18 @@ static int fsg_bind(struct usb_configuration
*c, struct usb_function *f)

/* Find all the endpoints we will use */
ep = usb_ep_autoconfig(gadget, &fsg_fs_bulk_in_desc);
-   if (!ep)
+   if (!ep) {
+   ERROR(fsg, "usb_ep_autoconfig in failed\n");
goto autoconf_fail;
+   }
ep->driver_data = fsg->common;  /* claim the endpoint */
fsg->bulk_in = ep;

ep = usb_ep_autoconfig(gadget, &fsg_fs_bulk_out_desc);
-   if (!ep)
+   if (!ep) {
+   ERROR(fsg, "usb_ep_autoconfig out failed\n");
goto autoconf_fail;
+   }
ep->driver_data = fsg->common;  /* claim the endpoint */
fsg->bulk_out = ep;

@@ -2929,8 +2933,10 @@ static int fsg_bind(struct usb_configuration
*c, struct usb_function *f)

ret = usb_assign_descriptors(f, fsg_fs_function, fsg_hs_function,
fsg_ss_function);
-   if (ret)
+   if (ret) {
+   ERROR(fsg, "usb_assign_descriptors failed\n");
goto autoconf_fail;
+   }

return 0;

diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index c258a97..5172b00 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -67,7 +67,6 @@ config USB_MUSB_DAVINCI
 config USB_MUSB_DA8XX
tristate "DA8xx/OMAP-L1x"
depends on ARCH_DAVINCI_DA8XX
-   depends on BROKEN

 config USB_MUSB_TUSB6010
tristate "TUSB6010"

This is the kernel log I get from journalctl -f:

Jun 25 14:36:00 Ringle1 kernel: calling  multi_init+0x0/0xc [g_multi] @ 957
Jun 25 14:36:01 Ringle1 kernel: udc musb-hdrc.0.auto: registering UDC
driver [g_multi]
Jun 25 14:36:01 Ringle1 kernel: g_multi gadget: using random self
ethernet address
Jun 25 14:36:01 Ringle1 kernel: g_multi gadget: using random host
ethernet address
Jun 25 14:36:01 Ringle1 kernel: usb0: MAC 22:34:67:82:df:aa
Jun 25 14:36:01 Ringle1 kernel: usb0: HOST MAC 0e:a8:d1:26:29:37
Jun 25 14:36:01 Ringle1 kernel: calling  userial_init+0x0/0x180 [u_serial] @ 963
Jun 25 14:36:01 Ringle1 kernel: userial_init: registered 4 ttyGS* devices
Jun 25 14:36:01 Ringle1 kernel: initcall userial_init+0x0/0x180
[u_serial] returned 0 after 87 usecs
Jun 25 14:36:01 Ringle1 kernel: calling  acmmod_init+0x0/0xc [usb_f_acm] @ 963
Jun 25 14:36:01 Ringle1 kernel: initcall acmmod_init+0x0/0xc
[usb_f_acm] returned 0 after 10 usecs
Jun 25 14:36:01 Ringle1 kernel:  lun0: open backing file: /root/backing_file
Jun 25 14:36:01 Ringle1 kernel: g_multi gadget: Mass Storage Function,
version: 2009/09/11
Jun 25 14:36:01 Ringle1 kernel: g_multi gadget: Number of LUNs=1
Jun 25 14:36:01 Ringle1 kernel:  lun0: LUN: file: /root/backing_file
Jun 25 14:36:01 Ringle1 kernel: g_multi gadget: I/O thread pid: 969
Jun 25 14:36:01 Ringle1 kernel: g_multi gadget: 

Re: USB_MUSB_DA8XX with g_multi.ko

2014-06-25 Thread Jon Ringle
On Wed, Jun 25, 2014 at 11:52 AM, Jon Ringle  wrote:
> On Wed, Jun 25, 2014 at 11:35 AM, Andrzej Pietrasiewicz
>  wrote:
>> W dniu 25.06.2014 17:13, Jon Ringle pisze:
>>
>>> In commit 787f5627bec80094db487bfcb401e9744f181aed
>>> usb: musb: make davinci and da8xx glues depend on BROKEN
>>>
>>> USB_MUSB_DA8XX was marked as BROKEN
>>>
>>> A few months ago, we updated the linux kernel on our AM1808 SoC based
>>> embedded board from Linux 2.6.33 to the latest long term 3.12.
>>>
>>> I am interested in having the USB gadget support on my board, so I
>>> removed BROKEN on USB_MUSB_DA8XX. I found that when I modprobe
>>> g_ether, g_serial, and g_mass_storage (by themselves), they all appear
>>> to work as expected, but if I try to use g_multi to have a composite
>>> device supporting all three simultaneously, I run into failure during
>>> initialization.
>>>
>>
>> 
>>
>>
>>>
 From this I can see that it's failing on the following call in
 fsg_bind():
>>>
>>> ep = usb_ep_autoconfig(gadget, &fsg_fs_bulk_in_desc);
>>>
>>
>> Just a random guess (I don't know your hardware): how many bulk,
>> iso and interrupt endpoints does your hardware provide? Perhaps you
>> just run out of endpoints?
>
> Perhaps... From the documentation it appears that I can have 4
> simultaneous RX/TX endpoints... Is this not enough?

I now see that each function seems to require 2 endpoints, so with 4
endpoints available, I can only have two functions with this hardware.
I tested this successfully with g_adm_ms.ko having both serial and
mass storage working. The only thing I needed to do was to remove the
BROKEN dependency on USB_MUSB_DA8XX. Is there anything else I would
have to do besides just removing BROKEN to get this accepted back into
the kernel source tree?

Jon
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: USB_MUSB_DA8XX with g_multi.ko

2014-06-25 Thread Christian Riesch
Hi Jon,

On Thu, Jun 26, 2014 at 4:46 AM, Jon Ringle  wrote:
> The only thing I needed to do was to remove the
> BROKEN dependency on USB_MUSB_DA8XX. Is there anything else I would
> have to do besides just removing BROKEN to get this accepted back into
> the kernel source tree?

I tried to remove the BROKEN dependency in [1], but without success.
See Felipe's response to my patch for more info. There was also
another discussion about this, see [2].
Christian

[1] http://marc.info/?t=1394061&r=1&w=2
[2] http://marc.info/?t=13952576757&r=1&w=2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: USB_MUSB_DA8XX with g_multi.ko

2014-06-26 Thread Jon Ringle
On Thu, Jun 26, 2014 at 2:29 AM, Christian Riesch
 wrote:
> Hi Jon,
>
> On Thu, Jun 26, 2014 at 4:46 AM, Jon Ringle  wrote:
>> The only thing I needed to do was to remove the
>> BROKEN dependency on USB_MUSB_DA8XX. Is there anything else I would
>> have to do besides just removing BROKEN to get this accepted back into
>> the kernel source tree?
>
> I tried to remove the BROKEN dependency in [1], but without success.
> See Felipe's response to my patch for more info. There was also
> another discussion about this, see [2].
> Christian
>
> [1] http://marc.info/?t=1394061&r=1&w=2
> [2] http://marc.info/?t=13952576757&r=1&w=2

Thanks for the additional info.
Since my primary interest is in getting this working on the 3.12 tree,
and the drivers/phy/ source directory had not been added yet at this
point in the history, I am not motivated enough to implement Felipe's
suggestion of moving phy_on()/phy_off() to a drivers/usb/phy-da8xx.c.
If sometime down the road, we decided to move to a newer kernel
release, and the work hasn't been done yet, then I'll have a greater
motivation to implement something along those lines. For now I will
live with just removing BROKEN from our local kernel tree.

Jon
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: USB_MUSB_DA8XX with g_multi.ko

2014-06-25 Thread Bin Liu
Hi,

On Wed, Jun 25, 2014 at 10:13 AM, Jon Ringle  wrote:
> In commit 787f5627bec80094db487bfcb401e9744f181aed
> usb: musb: make davinci and da8xx glues depend on BROKEN
>
> USB_MUSB_DA8XX was marked as BROKEN
>
> A few months ago, we updated the linux kernel on our AM1808 SoC based
> embedded board from Linux 2.6.33 to the latest long term 3.12.
>
> I am interested in having the USB gadget support on my board, so I
> removed BROKEN on USB_MUSB_DA8XX. I found that when I modprobe
> g_ether, g_serial, and g_mass_storage (by themselves), they all appear
> to work as expected, but if I try to use g_multi to have a composite
> device supporting all three simultaneously, I run into failure during
> initialization.
>
> Here is the USB related config:
> # zcat /proc/config.gz |grep "^CONFIG_USB"
> CONFIG_USB_HID=y
> CONFIG_USB_OHCI_LITTLE_ENDIAN=y
> CONFIG_USB_SUPPORT=y
> CONFIG_USB_COMMON=y
> CONFIG_USB_ARCH_HAS_HCD=y
> CONFIG_USB=y
> CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
> CONFIG_USB_DEFAULT_PERSIST=y
> CONFIG_USB_OTG=y
> CONFIG_USB_OHCI_HCD=y
> CONFIG_USB_MUSB_HDRC=y
> CONFIG_USB_MUSB_DUAL_ROLE=y
> CONFIG_USB_MUSB_DA8XX=y
> CONFIG_USB_STORAGE=y
> CONFIG_USB_SERIAL=y
> CONFIG_USB_SERIAL_CONSOLE=y
> CONFIG_USB_SERIAL_GENERIC=y
> CONFIG_USB_SERIAL_FTDI_SIO=y
> CONFIG_USB_SERIAL_PL2303=y
> CONFIG_USB_PHY=y
> CONFIG_USB_ULPI=y
> CONFIG_USB_GADGET=y
> CONFIG_USB_GADGET_DEBUG=y
> CONFIG_USB_GADGET_DEBUG_FILES=y
> CONFIG_USB_GADGET_DEBUG_FS=y
> CONFIG_USB_GADGET_VBUS_DRAW=2
> CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS=2
> CONFIG_USB_LIBCOMPOSITE=m
> CONFIG_USB_F_ACM=m
> CONFIG_USB_U_SERIAL=m
> CONFIG_USB_U_ETHER=m
> CONFIG_USB_U_RNDIS=m
> CONFIG_USB_F_SERIAL=m
> CONFIG_USB_F_OBEX=m
> CONFIG_USB_F_ECM=m
> CONFIG_USB_F_SUBSET=m
> CONFIG_USB_F_RNDIS=m
> CONFIG_USB_ETH=m
> CONFIG_USB_ETH_RNDIS=y
> CONFIG_USB_MASS_STORAGE=m
> CONFIG_USB_G_SERIAL=m
> CONFIG_USB_G_MULTI=m
> CONFIG_USB_G_MULTI_RNDIS=y
>
> # modprobe g_multi file=/root/backing_file
> modprobe: can't load module g_multi
> (kernel/drivers/usb/gadget/g_multi.ko): Unknown error 524
>
> I added a couple of debug message to identify where I was failing in:
>
> diff --git a/drivers/usb/gadget/f_mass_storage.c
> b/drivers/usb/gadget/f_mass_storage.c
> index a01d7d3..3e7a22a 100644
> --- a/drivers/usb/gadget/f_mass_storage.c
> +++ b/drivers/usb/gadget/f_mass_storage.c
> @@ -2899,14 +2899,18 @@ static int fsg_bind(struct usb_configuration
> *c, struct usb_function *f)
>
> /* Find all the endpoints we will use */
> ep = usb_ep_autoconfig(gadget, &fsg_fs_bulk_in_desc);
> -   if (!ep)
> +   if (!ep) {
> +   ERROR(fsg, "usb_ep_autoconfig in failed\n");
> goto autoconf_fail;
> +   }
> ep->driver_data = fsg->common;  /* claim the endpoint */
> fsg->bulk_in = ep;
>
> ep = usb_ep_autoconfig(gadget, &fsg_fs_bulk_out_desc);
> -   if (!ep)
> +   if (!ep) {
> +   ERROR(fsg, "usb_ep_autoconfig out failed\n");
> goto autoconf_fail;
> +   }
> ep->driver_data = fsg->common;  /* claim the endpoint */
> fsg->bulk_out = ep;
>
> @@ -2929,8 +2933,10 @@ static int fsg_bind(struct usb_configuration
> *c, struct usb_function *f)
>
> ret = usb_assign_descriptors(f, fsg_fs_function, fsg_hs_function,
> fsg_ss_function);
> -   if (ret)
> +   if (ret) {
> +   ERROR(fsg, "usb_assign_descriptors failed\n");
> goto autoconf_fail;
> +   }
>
> return 0;
>
> diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
> index c258a97..5172b00 100644
> --- a/drivers/usb/musb/Kconfig
> +++ b/drivers/usb/musb/Kconfig
> @@ -67,7 +67,6 @@ config USB_MUSB_DAVINCI
>  config USB_MUSB_DA8XX
> tristate "DA8xx/OMAP-L1x"
> depends on ARCH_DAVINCI_DA8XX
> -   depends on BROKEN
>
>  config USB_MUSB_TUSB6010
> tristate "TUSB6010"
>
> This is the kernel log I get from journalctl -f:
>
> Jun 25 14:36:00 Ringle1 kernel: calling  multi_init+0x0/0xc [g_multi] @ 957
> Jun 25 14:36:01 Ringle1 kernel: udc musb-hdrc.0.auto: registering UDC
> driver [g_multi]
> Jun 25 14:36:01 Ringle1 kernel: g_multi gadget: using random self
> ethernet address
> Jun 25 14:36:01 Ringle1 kernel: g_multi gadget: using random host
> ethernet address
> Jun 25 14:36:01 Ringle1 kernel: usb0: MAC 22:34:67:82:df:aa
> Jun 25 14:36:01 Ringle1 kernel: usb0: HOST MAC 0e:a8:d1:26:29:37
> Jun 25 14:36:01 Ringle1 kernel: calling  userial_init+0x0/0x180 [u_serial] @ 
> 963
> Jun 25 14:36:01 Ringle1 kernel: userial_init: registered 4 ttyGS* devices
> Jun 25 14:36:01 Ringle1 kernel: initcall userial_init+0x0/0x180
> [u_serial] returned 0 after 87 usecs
> Jun 25 14:36:01 Ringle1 kernel: calling  acmmod_init+0x0/0xc [usb_f_acm] @ 963
> Jun 25 14:36:01 Ringle1 kernel: initcall acmmod_init+0x0/0xc
> [usb_f_acm] returned 0 after 10 usecs
> Jun 25 14:36:01 Ringle1 kernel:  lun0: open backing file: /root/backing_file
> Jun 25 14:36:01 

Re: USB_MUSB_DA8XX with g_multi.ko

2014-06-25 Thread Andrzej Pietrasiewicz

W dniu 25.06.2014 17:13, Jon Ringle pisze:

In commit 787f5627bec80094db487bfcb401e9744f181aed
usb: musb: make davinci and da8xx glues depend on BROKEN

USB_MUSB_DA8XX was marked as BROKEN

A few months ago, we updated the linux kernel on our AM1808 SoC based
embedded board from Linux 2.6.33 to the latest long term 3.12.

I am interested in having the USB gadget support on my board, so I
removed BROKEN on USB_MUSB_DA8XX. I found that when I modprobe
g_ether, g_serial, and g_mass_storage (by themselves), they all appear
to work as expected, but if I try to use g_multi to have a composite
device supporting all three simultaneously, I run into failure during
initialization.








From this I can see that it's failing on the following call in fsg_bind():

ep = usb_ep_autoconfig(gadget, &fsg_fs_bulk_in_desc);



Just a random guess (I don't know your hardware): how many bulk,
iso and interrupt endpoints does your hardware provide? Perhaps you
just run out of endpoints?

AP

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


Re: USB_MUSB_DA8XX with g_multi.ko

2014-06-25 Thread Jon Ringle
On Wed, Jun 25, 2014 at 11:35 AM, Andrzej Pietrasiewicz
 wrote:
> W dniu 25.06.2014 17:13, Jon Ringle pisze:
>
>> In commit 787f5627bec80094db487bfcb401e9744f181aed
>> usb: musb: make davinci and da8xx glues depend on BROKEN
>>
>> USB_MUSB_DA8XX was marked as BROKEN
>>
>> A few months ago, we updated the linux kernel on our AM1808 SoC based
>> embedded board from Linux 2.6.33 to the latest long term 3.12.
>>
>> I am interested in having the USB gadget support on my board, so I
>> removed BROKEN on USB_MUSB_DA8XX. I found that when I modprobe
>> g_ether, g_serial, and g_mass_storage (by themselves), they all appear
>> to work as expected, but if I try to use g_multi to have a composite
>> device supporting all three simultaneously, I run into failure during
>> initialization.
>>
>
> 
>
>
>>
>>> From this I can see that it's failing on the following call in
>>> fsg_bind():
>>
>> ep = usb_ep_autoconfig(gadget, &fsg_fs_bulk_in_desc);
>>
>
> Just a random guess (I don't know your hardware): how many bulk,
> iso and interrupt endpoints does your hardware provide? Perhaps you
> just run out of endpoints?

Perhaps... From the documentation it appears that I can have 4
simultaneous RX/TX endpoints... Is this not enough?

34.1.2 Features
The USB has the following features:
• Operating as a host, it complies with the USB 2.0 standard for
high-speed (480 Mbps), full-speed
(12 Mbps), and low-speed (1.5 Mbps) operations with a peripheral
• Operating as a peripheral, it complies with the USB 2.0 standard for
high-speed (480 Mbps) and
full-speed (12 Mbps) operation with a host.
• Supports USB extensions for Session Request (SRP) and Host
Negotiation (HNP) – OTG
• Supports 4 simultaneous RX and TX endpoints, in addition to control
endpoint, more devices can be
supported by dynamically switching endpoints states
• Each endpoint (other than endpoint 0) can support all transfer types
(control, bulk, interrupt, and
isochronous)
• Includes a 4K endpoint FIFO RAM, and supports programmable FIFO sizes
• External 5V power supply for VBUS, when operating as host, enabled
directly by the USB controller
through a dedicated signal
• Includes a DMA controller that supports 4 TX and 4 RX DMA channels
• Includes four types of Communications Port Programming Interface
(CPPI) 4.1 DMA compliant transfer
modes, Transparent, Generic RNDIS, RNDIS, and Linux CDC mode of DMA
for accelerating RNDIS
type protocols using short packet termination over USB.
• DMA supports single data transfer size up to 4Mbytes
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/