Re: [PATCH] drivers: usb: chipidea: convert to devm_ioremap_resource()

2013-04-11 Thread Alexander Shishkin
Silviu-Mihai Popescu silviupopescu1...@gmail.com writes:

 Convert  use of devm_request_and_ioremap() to the newly introduced
 devm_ioremap_resource() which provides more consistent error handling.

You mean, you've run coccinelle? Remember to mention it, then.

 devm_ioremap_resource() provides its own error messages so all explicit
 error messages can be removed from the failure code paths.

 Signed-off-by: Silviu-Mihai Popescu silviupopescu1...@gmail.com

That's cool, but your chipidea patches have to be based off of
ci-for-greg branch of the chipidea tree [1] or at least usb-next branch
of Greg's usb.git [2].

[1] git://github.com/virtuoso/linux-ci.git
[2] git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git

Regards,
--
Alex
--
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: chipidea: convert to devm_ioremap_resource()

2013-04-11 Thread Silviu Popescu
On Thu, Apr 11, 2013 at 10:12 AM, Alexander Shishkin
alexander.shish...@linux.intel.com wrote:
 That's cool, but your chipidea patches have to be based off of
 ci-for-greg branch of the chipidea tree [1] or at least usb-next branch
 of Greg's usb.git [2].

 [1] git://github.com/virtuoso/linux-ci.git
 [2] git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git

Thanks for the tip. I see that both trees use devm_ioremap_resource().
I'll remember to check them next time I have a patch.

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


Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

2013-04-11 Thread Roger Quadros
On 04/10/2013 08:39 PM, Nishanth Menon wrote:
 On 13:55-20130410, Roger Quadros wrote:
 On 04/10/2013 11:06 AM, Mike Turquette wrote:
 Quoting Nishanth Menon (2013-04-09 13:49:00)
 On 10:43-20130409, Tony Lindgren wrote:
 * Tony Lindgren t...@atomide.com [130409 09:54]:
 * Roger Quadros rog...@ti.com [130409 03:00]:
 On 04/05/2013 06:58 PM, Tony Lindgren wrote:

 Can't you just use the clock name there to get it?

 In device tree we don't pass around clock names. You can either get
 a phandle or an index to the clock.

 e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt

 Yes I understand that. But the driver/clock/omap driver can just
 remap the DT device initially so the board specific clock is
 found from the clock alias table. Basically initially a passthrough
 driver that can be enhanced to parse DT clock bindings and load
 data from /lib/firmware.

 Actually probably the driver/clock/omap can even do even less
 initially. There probably even no need to remap clocks there.

 As long as the DT clock driver understands that a board specific
 auxclk is specified in the DT it can just call clk_add_alias() so
 the driver will get the right auxclk from cclock44xx_data.c.

 Then other features can be added later on like to allocate a
 clock entirely based on the binding etc.
 I did try to have an implementation for cpufreq using clock nodes.
 unfortunately, device tree wont let me have arguments of strings :(
 So, I am unable to do clock = clk mpu_dpll;
 instead, I am forced to do clock = clk 249;


 See http://article.gmane.org/gmane.linux.ports.arm.kernel/229034


 Awesome. Thanks for pointing this out Mike.

 Now all we need to do is create a named define for each clock index in the
 header file.
 Approach #3: Thanks to Tony for collaborating on this:
 Works for cpufreq-cpu0 - additional patches:
 http://pastebin.com/GHnTRVJf, http://pastebin.com/FZS89J6L (tested on
 beagleXM)
 Work for USB - http://pastebin.com/aJpDnXci - thanks Roger for testing
 this.
 Details in the patch below (Tony, I have added you as collaborator for
 helping in getting this working-clk_add_alias was'nt needed in the
 internal patch discussion we had - I have taken a bit of freedom in
 adding your contributions to the patch below)
 
 Folks, this does seem to be the best compromise we can achieve at this
 point in time. feedback on this approach is much appreciated - if folks
 are ok, I can post this as an formal patch series.

This looks fine to me. Minor comments below.

 
 From 130a41821bf57081ca45ef654029175d173135e6 Mon Sep 17 00:00:00 2001
 From: Nishanth Menon n...@ti.com
 Date: Tue, 9 Apr 2013 19:26:40 -0500
 Subject: [RFC PATCH] clk: OMAP: introduce device tree binding to kernel clock
  data
 
 OMAP clock data is located in arch/arm/mach-omap2/cclockXYZ_data.c.
 However, this presents an obstacle for using these clock nodes in
 Device Tree definitions. There are many possible approaches to this
 problem as discussed in the following thread:
 http://marc.info/?t=13637032569r=1w=2
 Highlights of the options:
 a) device specific clk_add_alias:
   cons: driver handling required
 b) using an generic clk node and indexing to reach the clock required.
This is similar in approach taken by tegra and few other platforms.
example clock = clk 5;
cons: potential to have mismatches in indexed table and associated
dtb data. In addition, managing continued documentation in bindings
as clock indexing increases. Even though readability angle could be
improved by using preprocessing of DT using macros, indexed approach
is inherently risky from cases like the following:
clk indexes in kernel:
1 - mpu_dpll
2 - aux_clk1
3 - core_clk
DT entry for peripheral x uses clk 2, kernel updates to:
1 - mpu_dpll
2 - per_dpll
3 - aux_clk1
4 - core_clk
using the old dtb(or dts missing an update), on new kernel which has
updated indices will result in per_dpll now controlled for peripheral
X without warning or any potential error detection and warning.
 
Even though we can claim this is user error, such errors are hard to
track down and fix.
 
 An alternate approach introduced here is to introduce device tree bindings
 corresponding to the clock nodes required in DT definition for SoC which
 automatically maps back to the definitions in cclockXYZ_data.c.
 
 The driver introduced here to do this mapping will eventually be the
 place where the clock handling will migrate to. We need to consider this
 angle as well so that the solution will be an valid transition point for
 moving the clock data out of kernel image (into device tree or firmware load
 etc..).
 
 Overall strategy introduced here is simple: an clock node described in

typo: an-a

 device tree blob is used to identify the exact clock provided in the SoC
 specific data. This is then linked back using of_clk_add_provider to the
 device node to be accessible by of_clk_get.
 
 Based on discussion 

Re: [Libusbx-devel] libusbx v1.0.15-rc2 is now available for testing

2013-04-11 Thread nico

thanx!
++
nicolas
Le 10/04/13 02:44, Pete Batard a écrit :

On 2013.04.09 11:39, nico wrote:

can someone provide a MinGW 32bits built of the last working RC,

Sure. Please have a look at the -win download from:
https://sourceforge.net/projects/libusbx/files/releases/1.0.15/binaries/

The Windows binary contains the 32 and 64 bit versions of both the
static library and DLL, for MSVC and MinGW.

In related news, the MSCV DLLs now include the .pdb, as was recently
requested.

Regards,

/Pete



--
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis  visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
___
libusbx-devel mailing list
libusbx-de...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel



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


Re: [PATCH 1/2 v5] usbnet: allow status interrupt URB to always be active

2013-04-11 Thread Bjørn Mork
Oliver Neukum oli...@neukum.org writes:
 On Thursday 11 April 2013 10:31:31 Ming Lei wrote:
  
 'mem_flags' isn't needed any more since we can apply allocation
 of GFP_NOIO automatically in resume path now, and you can always
 use GFP_KERNEL safely. Considered that it is a API, please don't
 introduce it.

 The automatic system goes a long way, but there are corner cases, for example
 work queues, which still need mem_flags.


My immediate thought was that someone also might want to use this new
API from atomic context, e.g. calling it directly from an URB callback.
But that is of course not possible taking a mutex.  Could the lock
preventing interrupt_count maybe be a spinlock instead?  Or am I on the
completely wrong track here?

In any case, I don't see the point unnecessarily limiting the API by
dropping the memflags.  What possible problem would that solve?


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


Re: [PATCH 1/2 v5] usbnet: allow status interrupt URB to always be active

2013-04-11 Thread Ming Lei
On Thu, Apr 11, 2013 at 2:50 PM, Oliver Neukum oli...@neukum.org wrote:
 On Thursday 11 April 2013 10:31:31 Ming Lei wrote:

 'mem_flags' isn't needed any more since we can apply allocation
 of GFP_NOIO automatically in resume path now, and you can always
 use GFP_KERNEL safely. Considered that it is a API, please don't
 introduce it.

 The automatic system goes a long way, but there are corner cases, for example
 work queues, which still need mem_flags.

Could you explain why work queue need GFP_NOIO? and the use case for
usbnet?

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


Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

2013-04-11 Thread Grygorii Strashko

On 04/11/2013 10:48 AM, Roger Quadros wrote:

On 04/10/2013 08:39 PM, Nishanth Menon wrote:

On 13:55-20130410, Roger Quadros wrote:

On 04/10/2013 11:06 AM, Mike Turquette wrote:

Quoting Nishanth Menon (2013-04-09 13:49:00)

On 10:43-20130409, Tony Lindgren wrote:

* Tony Lindgren t...@atomide.com [130409 09:54]:

* Roger Quadros rog...@ti.com [130409 03:00]:

On 04/05/2013 06:58 PM, Tony Lindgren wrote:

Can't you just use the clock name there to get it?

In device tree we don't pass around clock names. You can either get
a phandle or an index to the clock.

e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt

Yes I understand that. But the driver/clock/omap driver can just
remap the DT device initially so the board specific clock is
found from the clock alias table. Basically initially a passthrough
driver that can be enhanced to parse DT clock bindings and load
data from /lib/firmware.

Actually probably the driver/clock/omap can even do even less
initially. There probably even no need to remap clocks there.

As long as the DT clock driver understands that a board specific
auxclk is specified in the DT it can just call clk_add_alias() so
the driver will get the right auxclk from cclock44xx_data.c.

Then other features can be added later on like to allocate a
clock entirely based on the binding etc.

I did try to have an implementation for cpufreq using clock nodes.
unfortunately, device tree wont let me have arguments of strings :(
So, I am unable to do clock = clk mpu_dpll;
instead, I am forced to do clock = clk 249;


See http://article.gmane.org/gmane.linux.ports.arm.kernel/229034


Awesome. Thanks for pointing this out Mike.

Now all we need to do is create a named define for each clock index in the
header file.

Approach #3: Thanks to Tony for collaborating on this:
Works for cpufreq-cpu0 - additional patches:
http://pastebin.com/GHnTRVJf, http://pastebin.com/FZS89J6L (tested on
beagleXM)
Work for USB - http://pastebin.com/aJpDnXci - thanks Roger for testing
this.
Details in the patch below (Tony, I have added you as collaborator for
helping in getting this working-clk_add_alias was'nt needed in the
internal patch discussion we had - I have taken a bit of freedom in
adding your contributions to the patch below)

Folks, this does seem to be the best compromise we can achieve at this
point in time. feedback on this approach is much appreciated - if folks
are ok, I can post this as an formal patch series.

This looks fine to me. Minor comments below.


I like it. No IDs and can add clocks support in DT as needed.




 From 130a41821bf57081ca45ef654029175d173135e6 Mon Sep 17 00:00:00 2001
From: Nishanth Menon n...@ti.com
Date: Tue, 9 Apr 2013 19:26:40 -0500
Subject: [RFC PATCH] clk: OMAP: introduce device tree binding to kernel clock
  data

OMAP clock data is located in arch/arm/mach-omap2/cclockXYZ_data.c.
However, this presents an obstacle for using these clock nodes in
Device Tree definitions. There are many possible approaches to this
problem as discussed in the following thread:
http://marc.info/?t=13637032569r=1w=2
Highlights of the options:
a) device specific clk_add_alias:
cons: driver handling required
b) using an generic clk node and indexing to reach the clock required.
This is similar in approach taken by tegra and few other platforms.
example clock = clk 5;
cons: potential to have mismatches in indexed table and associated
dtb data. In addition, managing continued documentation in bindings
as clock indexing increases. Even though readability angle could be
improved by using preprocessing of DT using macros, indexed approach
is inherently risky from cases like the following:
clk indexes in kernel:
1 - mpu_dpll
2 - aux_clk1
3 - core_clk
DT entry for peripheral x uses clk 2, kernel updates to:
1 - mpu_dpll
2 - per_dpll
3 - aux_clk1
4 - core_clk
using the old dtb(or dts missing an update), on new kernel which has
updated indices will result in per_dpll now controlled for peripheral
X without warning or any potential error detection and warning.

Even though we can claim this is user error, such errors are hard to
track down and fix.

An alternate approach introduced here is to introduce device tree bindings
corresponding to the clock nodes required in DT definition for SoC which
automatically maps back to the definitions in cclockXYZ_data.c.

The driver introduced here to do this mapping will eventually be the
place where the clock handling will migrate to. We need to consider this
angle as well so that the solution will be an valid transition point for
moving the clock data out of kernel image (into device tree or firmware load
etc..).

Overall strategy introduced here is simple: an clock node described in

typo: an-a


device tree blob is used to identify the exact clock provided in the SoC
specific data. This is then linked back using of_clk_add_provider to the
device node to be 

Re: Linux USB file storage gadget with new UDC

2013-04-11 Thread victor yeo
Hi,

 I use kernel 3.4.4, the code in handle_stat1_irqs() is as below. There
 is no reset or disconnect member function in struct
 usb_gadget_driver in kernel 3.4.4.

 if (stat  (1  SUSPEND_REQUEST_INTERRUPT)) {
 if (dev-driver-suspend)
 dev-driver-suspend (dev-gadget);
 if (!enable_suspend)
 stat = ~(1  SUSPEND_REQUEST_INTERRUPT);
 } else {
 if (dev-driver-resume)
 dev-driver-resume (dev-gadget);
 /* at high speed, note erratum 0133 */
 }

 Okay.  I have a hard enough time remembering how the kernel works now;
 I can't afford to remember how it worked five releases ago.  :-)

 In the 3.4 kernel, when either a reset or a disconnect occurs, the UDC
 driver should call the gadget driver's -disconnect handler.

  Another usbmon trace showing 3 SCSI_READ_10 command.
 
 This trace shows that the READ(10) commands worked correctly.  Good.
 But it also shows that the gadget did not respond correctly to the 0xA1
 command near the end.  The UDC was supposed to set the Halt feature
 for the bulk-in endpoint and send a STALL packet, but it didn't.

 In gadget driver, when do_scsi_command() receives an unknown command,
 the return value is -EINVAL.

 No, the return value is 0.  Read the last line of do_scsi_command():

 return 0;

  Will this value be returned to UDC
 driver, so that UDC driver can set the Halt feature for the bulk-in
 endpoint and send a STALL packet? For now, UDC driver does not set
 Halt when unknown SCSI command is received.

 Look at finish_reply(), near the end of the DATA_DIR_TO_HOST case:

 /*
  * For Bulk-only, mark the end of the data with a short
  * packet.  If we are allowed to stall, halt the bulk-in
  * endpoint.  (Note: This violates the Bulk-Only Transport
  * specification, which requires us to pad the data if we
  * don't halt the endpoint.  Presumably nobody will mind.)
  */
 else {
 bh-inreq-zero = 1;
 start_transfer(fsg, fsg-bulk_in, bh-inreq,
 bh-inreq_busy, bh-state);
 fsg-next_buffhd_to_fill = bh-next;
 if (mod_data.can_stall)
 rc = halt_bulk_in_endpoint(fsg);
 }

 And read the fist line in halt_bulk_in_endpoint():

 rc = fsg_set_halt(fsg, fsg-bulk_in);

 And finally, read the last line of fsg_set_halt():

 return usb_ep_set_halt(ep);

 That's when your UDC is supposed to set the Halt feature -- when its
 usb_ep_set_halt() function is called.  If the controller is busy at
 this time because the bulk-in buffer is full, and it is unable to set
 the Halt feature, then usb_ep_set_halt() should return -EAGAIN -- see
 the documentation for usb_ep_set_halt in include/linux/usb/gadget.h.

 Alan Stern


Thanks for the detailed write-up. I have checked the UDC driver
set_halt(), it is called by the gadget driver. The full ascii text of
usbmon trace for one usb session is also attached. This usbmon trace
shows a few EOVERFLOW(-75) error. I don't know why EOVERFLOW error
happened.

victor


scsi_read_10_again10.log
Description: Binary data


[PATCH 1/1] usb: gadget/uvc: Add support for Bulk endpoint to be used as Video Streaming ep

2013-04-11 Thread Bhupesh Sharma
This patch adds the support for Bulk endpoint to be used as video streaming
endpoint, on basis of a module parameter.

By default, the gadget still supports Isochronous endpoint for video streaming,
but if the module parameter 'bulk_streaming_ep' is set to 1, we can support
Bulk endpoint as well, which is useful for UDC's which don't support Isochronous
endpoints.

The important difference between the two implementations is that, alt-settings
in a video streaming interface are supported only for Isochronous endpoints as
there are different alt-settings for zero-bandwidth and full-bandwidth
use-cases, but the same is not true for Bulk endpoints, as they support only
a single alt-setting.

Signed-off-by: Bhupesh Sharma bhupesh.sha...@st.com
---
Note that to ease review and integration of this patch, I have rebased it
on Laurent's UVC gadget git tree available here (head uvc-gadget):
git://linuxtv.org/pinchartl/uvcvideo.git

This will allow the patch to be pulled into Felipe's repo in one go
after review and any subsequent rework (if required).

 drivers/usb/gadget/f_uvc.c |  321 
 drivers/usb/gadget/uvc.h   |2 +
 drivers/usb/gadget/uvc_v4l2.c  |   17 ++-
 drivers/usb/gadget/uvc_video.c |   13 ++-
 4 files changed, 286 insertions(+), 67 deletions(-)

diff --git a/drivers/usb/gadget/f_uvc.c b/drivers/usb/gadget/f_uvc.c
index 38dcedd..e5953eb 100644
--- a/drivers/usb/gadget/f_uvc.c
+++ b/drivers/usb/gadget/f_uvc.c
@@ -45,6 +45,11 @@ static unsigned int streaming_maxburst;
 module_param(streaming_maxburst, uint, S_IRUGO|S_IWUSR);
 MODULE_PARM_DESC(streaming_maxburst, 0 - 15 (ss only));
 
+static bool bulk_streaming_ep;
+module_param(bulk_streaming_ep, bool, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(bulk_streaming_ep, 0 (Use ISOC video streaming ep) / 
+   1 (Use BULK video streaming ep));
+
 /* --
  * Function descriptors
  */
@@ -135,6 +140,19 @@ static struct usb_interface_descriptor 
uvc_streaming_intf_alt0 __initdata = {
.iInterface = 0,
 };
 
+static struct usb_interface_descriptor uvc_bulk_streaming_intf_alt0
+__initdata = {
+   .bLength= USB_DT_INTERFACE_SIZE,
+   .bDescriptorType= USB_DT_INTERFACE,
+   .bInterfaceNumber   = UVC_INTF_VIDEO_STREAMING,
+   .bAlternateSetting  = 0,
+   .bNumEndpoints  = 1,
+   .bInterfaceClass= USB_CLASS_VIDEO,
+   .bInterfaceSubClass = UVC_SC_VIDEOSTREAMING,
+   .bInterfaceProtocol = 0x00,
+   .iInterface = 0,
+};
+
 static struct usb_interface_descriptor uvc_streaming_intf_alt1 __initdata = {
.bLength= USB_DT_INTERFACE_SIZE,
.bDescriptorType= USB_DT_INTERFACE,
@@ -160,6 +178,18 @@ static struct usb_endpoint_descriptor uvc_fs_streaming_ep 
__initdata = {
.bInterval  = 0,
 };
 
+static struct usb_endpoint_descriptor uvc_fs_bulk_streaming_ep __initdata = {
+   .bLength= USB_DT_ENDPOINT_SIZE,
+   .bDescriptorType= USB_DT_ENDPOINT,
+   .bEndpointAddress   = USB_DIR_IN,
+   .bmAttributes   = USB_ENDPOINT_XFER_BULK,
+   /* The wMaxPacketSize and bInterval values will be initialized from
+* module parameters.
+*/
+   .wMaxPacketSize = 0,
+   .bInterval  = 0,
+};
+
 static struct usb_endpoint_descriptor uvc_hs_streaming_ep __initdata = {
.bLength= USB_DT_ENDPOINT_SIZE,
.bDescriptorType= USB_DT_ENDPOINT,
@@ -173,6 +203,18 @@ static struct usb_endpoint_descriptor uvc_hs_streaming_ep 
__initdata = {
.bInterval  = 0,
 };
 
+static struct usb_endpoint_descriptor uvc_hs_bulk_streaming_ep __initdata = {
+   .bLength= USB_DT_ENDPOINT_SIZE,
+   .bDescriptorType= USB_DT_ENDPOINT,
+   .bEndpointAddress   = USB_DIR_IN,
+   .bmAttributes   = USB_ENDPOINT_XFER_BULK,
+   /* The wMaxPacketSize and bInterval values will be initialized from
+* module parameters.
+*/
+   .wMaxPacketSize = 0,
+   .bInterval  = 0,
+};
+
 static struct usb_endpoint_descriptor uvc_ss_streaming_ep __initdata = {
.bLength= USB_DT_ENDPOINT_SIZE,
.bDescriptorType= USB_DT_ENDPOINT,
@@ -187,6 +229,19 @@ static struct usb_endpoint_descriptor uvc_ss_streaming_ep 
__initdata = {
.bInterval  = 0,
 };
 
+static struct usb_endpoint_descriptor uvc_ss_bulk_streaming_ep __initdata = {
+   .bLength= USB_DT_ENDPOINT_SIZE,
+   .bDescriptorType= USB_DT_ENDPOINT,
+
+   .bEndpointAddress   = USB_DIR_IN,
+   .bmAttributes   = USB_ENDPOINT_XFER_BULK,
+   /* The wMaxPacketSize and bInterval values will be initialized from
+* module 

[PATCH] USB: ehci-omap: Select USB_PHY

2013-04-11 Thread Roger Quadros
Hi Greg,

The following patch gets rid of Kbuild warnings when USB_EHCI_HCD_OMAP
is enabled.

Patch is based on your usb-next branch and is needed for 3.10.

From: Roger Quadros rog...@ti.com
Date: Thu, 11 Apr 2013 12:08:19 +0300
Subject: [PATCH] USB: ehci-omap: Select USB_PHY

As we need NOP_USB_XCEIV which depends on USB_PHY
we need to select USB_PHY as well.

Gets rid of the below warnings when USB_EHCI_HCD_OMAP
is enabled.

warning: (USB_EHCI_HCD_OMAP) selects NOP_USB_XCEIV which has unmet direct 
dependencies (USB_SUPPORT  USB_PHY)
warning: (USB_EHCI_HCD_OMAP) selects NOP_USB_XCEIV which has unmet direct 
dependencies (USB_SUPPORT  USB_PHY)

Signed-off-by: Roger Quadros rog...@ti.com
---
 drivers/usb/host/Kconfig |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index c0be25c..931b437 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -150,6 +150,7 @@ config USB_EHCI_MXC
 config USB_EHCI_HCD_OMAP
tristate EHCI support for OMAP3 and later chips
depends on ARCH_OMAP
+   select USB_PHY
select NOP_USB_XCEIV
default y
---help---
-- 
1.7.4.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/2 v5] usbnet: allow status interrupt URB to always be active

2013-04-11 Thread Oliver Neukum
On Thursday 11 April 2013 16:09:16 Ming Lei wrote:
 On Thu, Apr 11, 2013 at 2:50 PM, Oliver Neukum oli...@neukum.org wrote:
  On Thursday 11 April 2013 10:31:31 Ming Lei wrote:
 
  'mem_flags' isn't needed any more since we can apply allocation
  of GFP_NOIO automatically in resume path now, and you can always
  use GFP_KERNEL safely. Considered that it is a API, please don't
  introduce it.
 
  The automatic system goes a long way, but there are corner cases, for 
  example
  work queues, which still need mem_flags.
 
 Could you explain why work queue need GFP_NOIO?

Your fix for the memory allocation depends on it happening in the same
context. If you execute code on a work queue this happens in the context
of a kernel thread.

 and the use case for
 usbnet?

Processing your response from a work queue.

Regards
Oliver

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


Re: [PATCH 1/2 v5] usbnet: allow status interrupt URB to always be active

2013-04-11 Thread Oliver Neukum
On Thursday 11 April 2013 16:37:53 Ming Lei wrote:
 On Thu, Apr 11, 2013 at 4:06 PM, Bjørn Mork bj...@mork.no wrote:
  Oliver Neukum oli...@neukum.org writes:
 
  My immediate thought was that someone also might want to use this new
  API from atomic context, e.g. calling it directly from an URB callback.
 
 I am wondering it is a valid use case, and if there is one URB submitted,
 the interrupt URB for status has been submitted already, hasn't it?

That is the point of this patch. There are multiple reasons to keep
the status urb submitted. The generic layer has to count them and
react to the count.

  But that is of course not possible taking a mutex.  Could the lock
  preventing interrupt_count maybe be a spinlock instead?  Or am I on the
  completely wrong track here?
 
 Also it is a bit odd that the 'start' API is allowed in atomic context, but
 the 'stop' API isn't allowed, and it is very easy to cause unbalanced counter.

It simply is easier to submit an URB in an atomic context than to kill it.
The code allowing doing it under a spinlock would be complex.

  In any case, I don't see the point unnecessarily limiting the API by
  dropping the memflags.  What possible problem would that solve?
 
 If you think 'start' API should be called in atomic context, the memflags

It may be called. It doesn't have to be. usbnet needs a certain amount
of genericness in the API. Passing a flag does that and is simple.

Regards
Oliver

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


Re: [PATCH 1/2 v5] usbnet: allow status interrupt URB to always be active

2013-04-11 Thread Ming Lei
On Thu, Apr 11, 2013 at 5:53 PM, Oliver Neukum oli...@neukum.org wrote:
 On Thursday 11 April 2013 16:09:16 Ming Lei wrote:

 Could you explain why work queue need GFP_NOIO?

 Your fix for the memory allocation depends on it happening in the same
 context. If you execute code on a work queue this happens in the context
 of a kernel thread.

I understand the interface might be called from workqueue, and my question
is why GFP_NOIO is needed in the work queue context. Generally speaking,
GFP_KERNEL is enough for work queue context.

As we discussed before, GFP_NOIO is required in runtime resume context
and reset context, and the two contexts have been addressed automatically.
So looks you didn't answer my question, :-)

I mean if GFP_NOIO isn't needed, we can use GFP_KERNEL directly, and
the extra parameter isn't need.

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


Re: [PATCH 1/2 v5] usbnet: allow status interrupt URB to always be active

2013-04-11 Thread Bjørn Mork
Ming Lei tom.leim...@gmail.com writes:

 On Thu, Apr 11, 2013 at 4:06 PM, Bjørn Mork bj...@mork.no wrote:
 Oliver Neukum oli...@neukum.org writes:

 My immediate thought was that someone also might want to use this new
 API from atomic context, e.g. calling it directly from an URB callback.

 I am wondering it is a valid use case, and if there is one URB submitted,
 the interrupt URB for status has been submitted already, hasn't it?

It might not be valid.

 But that is of course not possible taking a mutex.  Could the lock
 preventing interrupt_count maybe be a spinlock instead?  Or am I on the
 completely wrong track here?

 Also it is a bit odd that the 'start' API is allowed in atomic context, but
 the 'stop' API isn't allowed, and it is very easy to cause unbalanced counter.

Yes, that's a valid point.  Just a random thought popping out :)

For the record: I believe the v5 patch as posted really is fine without
any changes.

 In any case, I don't see the point unnecessarily limiting the API by
 dropping the memflags.  What possible problem would that solve?

 If you think 'start' API should be called in atomic context, the memflags
 should be always 'GFP_ATOMIC'. I let Oliver explain why GFP_NOIO
 is needed in other cases.

Again: What problem are you attempting to solve by removing the
mem_flags from the API?

I think you are turning this the wrong way around. Please explain why
there are no use cases where different flags are needed.  You seem to be
only concerned about the resume case. This API is not limited to
resuming. We pass mem_flags around all the time. It's the common thing
to do in any API where allocations may be required.


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


Re: [PATCH 1/2 v5] usbnet: allow status interrupt URB to always be active

2013-04-11 Thread Ming Lei
On Thu, Apr 11, 2013 at 6:04 PM, Bjørn Mork bj...@mork.no wrote:
 Ming Lei tom.leim...@gmail.com writes:

 Again: What problem are you attempting to solve by removing the
 mem_flags from the API?

It is not about removing anything, we are discussing one new API
(include the parameters) to be introduced.

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


Re: [PATCH 1/2 v5] usbnet: allow status interrupt URB to always be active

2013-04-11 Thread Bjørn Mork
Ming Lei tom.leim...@gmail.com writes:

 On Thu, Apr 11, 2013 at 6:04 PM, Bjørn Mork bj...@mork.no wrote:
 Ming Lei tom.leim...@gmail.com writes:

 Again: What problem are you attempting to solve by removing the
 mem_flags from the API?

 It is not about removing anything, we are discussing one new API
 (include the parameters) to be introduced.

Yes.  Sure.  And the original proposal was to add a new API with a
mem_flags parameter.  You proposed to add the same API, but without the
mem_flags parameter.  You did not explain why.  I still assumed that you
have some reason to propose it.  I assumed that reason must be some
problem which would be introduced by having the mem_flags parameter, and
which would be solved if we instead drop it.

It seems that you are either unable or unwilling to explain your
reasons, so I'll just go ahead and drop my assumptions.  You never had
any reason and there never would be any problem.

Thanks.


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


Re: [PATCH 1/2 v5] usbnet: allow status interrupt URB to always be active

2013-04-11 Thread Ming Lei
On Thu, Apr 11, 2013 at 6:26 PM, Bjørn Mork bj...@mork.no wrote:
 Ming Lei tom.leim...@gmail.com writes:

 On Thu, Apr 11, 2013 at 6:04 PM, Bjørn Mork bj...@mork.no wrote:
 Ming Lei tom.leim...@gmail.com writes:

 Again: What problem are you attempting to solve by removing the
 mem_flags from the API?

 It is not about removing anything, we are discussing one new API
 (include the parameters) to be introduced.

 Yes.  Sure.  And the original proposal was to add a new API with a
 mem_flags parameter.  You proposed to add the same API, but without the
 mem_flags parameter.  You did not explain why.  I still assumed that you
 have some reason to propose it.  I assumed that reason must be some
 problem which would be introduced by having the mem_flags parameter, and
 which would be solved if we instead drop it.

 It seems that you are either unable or unwilling to explain your
 reasons, so I'll just go ahead and drop my assumptions.  You never had
 any reason and there never would be any problem.

OK, I say it again, GFP_KERNEL is enough to cover all cases, and the
mem_flags parameter is redundant.


Thanks,
-- 
Ming Lei
--
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: ehci-omap: Select USB_PHY

2013-04-11 Thread Roger Quadros
On 04/11/2013 01:04 PM, Felipe Balbi wrote:
 Hi,
 
 On Thu, Apr 11, 2013 at 12:42:04PM +0300, Roger Quadros wrote:
 Hi Greg,

 The following patch gets rid of Kbuild warnings when USB_EHCI_HCD_OMAP
 is enabled.

 Patch is based on your usb-next branch and is needed for 3.10.

 From: Roger Quadros rog...@ti.com
 Date: Thu, 11 Apr 2013 12:08:19 +0300
 Subject: [PATCH] USB: ehci-omap: Select USB_PHY

 As we need NOP_USB_XCEIV which depends on USB_PHY
 we need to select USB_PHY as well.

 Gets rid of the below warnings when USB_EHCI_HCD_OMAP
 is enabled.

 warning: (USB_EHCI_HCD_OMAP) selects NOP_USB_XCEIV which has unmet direct 
 dependencies (USB_SUPPORT  USB_PHY)
 warning: (USB_EHCI_HCD_OMAP) selects NOP_USB_XCEIV which has unmet direct 
 dependencies (USB_SUPPORT  USB_PHY)

 Signed-off-by: Roger Quadros rog...@ti.com
 
 Ideally, however, we wouldn't select any PHY in particular as different
 boards might need a different PHY driver, even on OMAP ;-)
 
Right, but we need to select USB_PHY here as the driver uses
the USB_PHY APIs.

The NOP_USB_XCEIV selection could be done by the board config.

cheers,
-roger
--
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: ehci-omap: Select USB_PHY

2013-04-11 Thread Felipe Balbi
Hi,

On Thu, Apr 11, 2013 at 01:51:16PM +0300, Roger Quadros wrote:
 On 04/11/2013 01:04 PM, Felipe Balbi wrote:
  Hi,
  
  On Thu, Apr 11, 2013 at 12:42:04PM +0300, Roger Quadros wrote:
  Hi Greg,
 
  The following patch gets rid of Kbuild warnings when USB_EHCI_HCD_OMAP
  is enabled.
 
  Patch is based on your usb-next branch and is needed for 3.10.
 
  From: Roger Quadros rog...@ti.com
  Date: Thu, 11 Apr 2013 12:08:19 +0300
  Subject: [PATCH] USB: ehci-omap: Select USB_PHY
 
  As we need NOP_USB_XCEIV which depends on USB_PHY
  we need to select USB_PHY as well.
 
  Gets rid of the below warnings when USB_EHCI_HCD_OMAP
  is enabled.
 
  warning: (USB_EHCI_HCD_OMAP) selects NOP_USB_XCEIV which has unmet direct 
  dependencies (USB_SUPPORT  USB_PHY)
  warning: (USB_EHCI_HCD_OMAP) selects NOP_USB_XCEIV which has unmet direct 
  dependencies (USB_SUPPORT  USB_PHY)
 
  Signed-off-by: Roger Quadros rog...@ti.com
  
  Ideally, however, we wouldn't select any PHY in particular as different
  boards might need a different PHY driver, even on OMAP ;-)
  
 Right, but we need to select USB_PHY here as the driver uses
 the USB_PHY APIs.
 
 The NOP_USB_XCEIV selection could be done by the board config.

I would avoid 'select' completely and just update omap2plus_defconfig
adding those two as modules.

cheers

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 1/2 v5] usbnet: allow status interrupt URB to always be active

2013-04-11 Thread Bjørn Mork
Ming Lei tom.leim...@gmail.com writes:

 OK, I say it again, GFP_KERNEL is enough to cover all cases, and the
 mem_flags parameter is redundant.

The docs for usb_submit_urb() in drivers/usb/core/urb.c lists some
possible mem_flags use cases. Among these are (where (b) and (c) are
cases needing GFP_ATOMIC and not applicable here):

quote
 *  (3) If you use a kernel thread with a network driver you must use
 *  GFP_NOIO, unless (b) or (c) apply;
/quote

Is this example 
 a) wrong, or
 b) not applicable, or 
 c) to be excluded from the new API?


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


Re: [PATCH 1/2 v5] usbnet: allow status interrupt URB to always be active

2013-04-11 Thread Oliver Neukum
On Thursday 11 April 2013 18:03:09 Ming Lei wrote:
 On Thu, Apr 11, 2013 at 5:53 PM, Oliver Neukum oli...@neukum.org wrote:
  On Thursday 11 April 2013 16:09:16 Ming Lei wrote:
 
  Could you explain why work queue need GFP_NOIO?
 
  Your fix for the memory allocation depends on it happening in the same
  context. If you execute code on a work queue this happens in the context
  of a kernel thread.
 
 I understand the interface might be called from workqueue, and my question
 is why GFP_NOIO is needed in the work queue context. Generally speaking,
 GFP_KERNEL is enough for work queue context.
 
 As we discussed before, GFP_NOIO is required in runtime resume context
 and reset context, and the two contexts have been addressed automatically.
 So looks you didn't answer my question, :-)

Sorry, I misunderstood.

Task A  Task B  queue

queue work
request a reset

allocate memory and block
cancel the work

shit happened

Regards
Oliver


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


[PATCH] usb: ehci-s5p: skip phy setup for Exynos5440 based platforms

2013-04-11 Thread Thomas Abraham
Exynos5440 does not require any explict USB phy configuration. So skip
the USB phy configuration for Exynos5440 based platforms.

Signed-off-by: Thomas Abraham thomas...@samsung.com
---
 drivers/usb/host/ehci-s5p.c |   11 +--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/ehci-s5p.c b/drivers/usb/host/ehci-s5p.c
index 867a923..0f13ef3 100644
--- a/drivers/usb/host/ehci-s5p.c
+++ b/drivers/usb/host/ehci-s5p.c
@@ -76,7 +76,7 @@ static void s5p_ehci_phy_enable(struct s5p_ehci_hcd *s5p_ehci)
 
if (s5p_ehci-phy)
usb_phy_init(s5p_ehci-phy);
-   else if (s5p_ehci-pdata-phy_init)
+   else if (s5p_ehci-pdata  s5p_ehci-pdata-phy_init)
s5p_ehci-pdata-phy_init(pdev, USB_PHY_TYPE_HOST);
 }
 
@@ -86,7 +86,7 @@ static void s5p_ehci_phy_disable(struct s5p_ehci_hcd 
*s5p_ehci)
 
if (s5p_ehci-phy)
usb_phy_shutdown(s5p_ehci-phy);
-   else if (s5p_ehci-pdata-phy_exit)
+   else if (s5p_ehci-pdata  s5p_ehci-pdata-phy_exit)
s5p_ehci-pdata-phy_exit(pdev, USB_PHY_TYPE_HOST);
 }
 
@@ -138,6 +138,10 @@ static int s5p_ehci_probe(struct platform_device *pdev)
if (!s5p_ehci)
return -ENOMEM;
 
+   if (of_device_is_compatible(pdev-dev.of_node,
+   samsung,exynos5440-ehci))
+   goto skip_phy;
+
phy = devm_usb_get_phy(pdev-dev, USB_PHY_TYPE_USB2);
if (IS_ERR(phy)) {
/* Fallback to pdata */
@@ -152,6 +156,8 @@ static int s5p_ehci_probe(struct platform_device *pdev)
s5p_ehci-otg = phy-otg;
}
 
+skip_phy:
+
s5p_ehci-dev = pdev-dev;
 
hcd = usb_create_hcd(s5p_ehci_hc_driver, pdev-dev,
@@ -306,6 +312,7 @@ static const struct dev_pm_ops s5p_ehci_pm_ops = {
 #ifdef CONFIG_OF
 static const struct of_device_id exynos_ehci_match[] = {
{ .compatible = samsung,exynos4210-ehci },
+   { .compatible = samsung,exynos5440-ehci },
{},
 };
 MODULE_DEVICE_TABLE(of, exynos_ehci_match);
-- 
1.6.6.rc2

--
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: ohci-exynos: skip phy setup for Exynos5440 based platforms

2013-04-11 Thread Thomas Abraham
Exynos5440 does not require any explict USB phy configuration. So skip
the USB phy configuration for Exynos5440 based platforms.

Signed-off-by: Thomas Abraham thomas...@samsung.com
---
 drivers/usb/host/ohci-exynos.c |   11 +--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c
index b38fdd9..70b9517 100644
--- a/drivers/usb/host/ohci-exynos.c
+++ b/drivers/usb/host/ohci-exynos.c
@@ -35,7 +35,7 @@ static void exynos_ohci_phy_enable(struct exynos_ohci_hcd 
*exynos_ohci)
 
if (exynos_ohci-phy)
usb_phy_init(exynos_ohci-phy);
-   else if (exynos_ohci-pdata-phy_init)
+   else if (exynos_ohci-pdata  exynos_ohci-pdata-phy_init)
exynos_ohci-pdata-phy_init(pdev, USB_PHY_TYPE_HOST);
 }
 
@@ -45,7 +45,7 @@ static void exynos_ohci_phy_disable(struct exynos_ohci_hcd 
*exynos_ohci)
 
if (exynos_ohci-phy)
usb_phy_shutdown(exynos_ohci-phy);
-   else if (exynos_ohci-pdata-phy_exit)
+   else if (exynos_ohci-pdata  exynos_ohci-pdata-phy_exit)
exynos_ohci-pdata-phy_exit(pdev, USB_PHY_TYPE_HOST);
 }
 
@@ -128,6 +128,10 @@ static int exynos_ohci_probe(struct platform_device *pdev)
if (!exynos_ohci)
return -ENOMEM;
 
+   if (of_device_is_compatible(pdev-dev.of_node,
+   samsung,exynos5440-ohci))
+   goto skip_phy;
+
phy = devm_usb_get_phy(pdev-dev, USB_PHY_TYPE_USB2);
if (IS_ERR(phy)) {
/* Fallback to pdata */
@@ -142,6 +146,8 @@ static int exynos_ohci_probe(struct platform_device *pdev)
exynos_ohci-otg = phy-otg;
}
 
+skip_phy:
+
exynos_ohci-dev = pdev-dev;
 
hcd = usb_create_hcd(exynos_ohci_hc_driver, pdev-dev,
@@ -312,6 +318,7 @@ static const struct dev_pm_ops exynos_ohci_pm_ops = {
 #ifdef CONFIG_OF
 static const struct of_device_id exynos_ohci_match[] = {
{ .compatible = samsung,exynos4210-ohci },
+   { .compatible = samsung,exynos5440-ohci },
{},
 };
 MODULE_DEVICE_TABLE(of, exynos_ohci_match);
-- 
1.6.6.rc2

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


Re: [PATCH 1/2 v5] usbnet: allow status interrupt URB to always be active

2013-04-11 Thread Ming Lei
On Thu, Apr 11, 2013 at 7:08 PM, Bjørn Mork bj...@mork.no wrote:

 The docs for usb_submit_urb() in drivers/usb/core/urb.c lists some
 possible mem_flags use cases. Among these are (where (b) and (c) are
 cases needing GFP_ATOMIC and not applicable here):

 quote
  *  (3) If you use a kernel thread with a network driver you must use
  *  GFP_NOIO, unless (b) or (c) apply;
 /quote

 Is this example
  a) wrong, or
  b) not applicable, or
  c) to be excluded from the new API?

IMO, it may be a) or b), and we can find many GFP_KERNEL usage
inside usbnet(kevent(), ...).

Also (3) doesn't explain the cause. Oliver, could you give a hit?

Wrt. usbnet, except for in xmit  receive handler, the rule should be
same with other usb driver.

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


Re: [PATCH 1/2 v5] usbnet: allow status interrupt URB to always be active

2013-04-11 Thread Oliver Neukum
On Thursday 11 April 2013 19:42:53 Ming Lei wrote:
 On Thu, Apr 11, 2013 at 7:08 PM, Bjørn Mork bj...@mork.no wrote:
 
  The docs for usb_submit_urb() in drivers/usb/core/urb.c lists some
  possible mem_flags use cases. Among these are (where (b) and (c) are
  cases needing GFP_ATOMIC and not applicable here):
 
  quote
   *  (3) If you use a kernel thread with a network driver you must use
   *  GFP_NOIO, unless (b) or (c) apply;
  /quote
 
  Is this example
   a) wrong, or
   b) not applicable, or
   c) to be excluded from the new API?
 
 IMO, it may be a) or b), and we can find many GFP_KERNEL usage
 inside usbnet(kevent(), ...).

Only in the rx path.

 Also (3) doesn't explain the cause. Oliver, could you give a hit?

IIRC this was to cover networked file systems.

Regards
Oliver

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


Re: [PATCH v3 0/9] Reorganize R8A7779/Marzen USB code

2013-04-11 Thread Sergei Shtylyov

Hello.

On 11-04-2013 4:51, Simon Horman wrote:


Here's the set of 9 patches against the Simon Horman's 'renesas.git' repo,
'renesas-next-20130410' tag.  It was created to fix the shortcomings in the
R8A7779/Marzen USB platform code and R8A7779 USB common PHY driver, and so
spans both arch/arm/mach-shmobile/ and drivers/usb/ subtrees (some patches have
to touch both subtrees). The patches were conceived with the complete
bisectability goal in mind.



[1/9] ARM: shmobile: Marzen: move USB EHCI, OHCI, and PHY devices to R8A7779 
code
[2/9] ehci-platform: add pre_setup() method to platform data
[3/9] ARM: shmobile: R8A7779: setup EHCI internal buffer
[4/9] rcar-phy: remove EHCI internal buffer setup
[5/9] ARM: shmobile: R8A7779: remove USB PHY 2nd memory resource
[6/9] rcar-phy: correct base address
[7/9] rcar-phy: add platform data
[8/9] ARM: shmobile: Marzen: pass platform data to USB PHY device
[9/9] rcar-phy: handle platform data



I'm not sure thru which tree this patchset should be merged, however it 
turns
out that it's too late now to push it thru Felipe Balbi's USB tree for 3.10
(which would have been most convenient probably), and it's probably too late to
merge thru Simon's tree for 3.10 too. So it now have to be postponed to 3.11,
unfortunately...



Felipe, how would you prefer to handle this?
I'm happy for you to take it or to take it myself.



please take it yourself, just keep in mind there will be conflicts, I
will go over the patches now and give my Acked-by so you can queue them
up.



Thanks



Sergei, it looks like patches 1-7 are clear.


   #7  #9 have been refused by Felipe (hence #8 isn't good too).


Do you want me to start queueing them up.


   I was going to repost the whole series soon, adding ACK from Alan to the 
patch #2 and resolving issues with patches #7..#9. It's worth waiting for that 
to happen I think.



Or would you rather wait for the issue with patch 6 to be resolved?


   There's no special issue with patch #6 other than the PHY driver files 
being renamed in Felipe's tree -- but that concerns all patches touching 
drivers/usb/phy/rcar-phy.c (some of which precede #6).
   I don't know how the rename conflict will be handled (this is really bad 
coincidence), perhaps I still should have done this patchset against Felipe's 
'next' branch and pushed it thru his tree. If the patches will be queued for 
3.11 anyway, maybe it's worth doing that -- I'm still of the opinion that his 
tree would be the one most fitting for this patchset.


WBR, Sergei

--
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 0/9] Reorganize R8A7779/Marzen USB code

2013-04-11 Thread Felipe Balbi
Hi,

On Thu, Apr 11, 2013 at 04:02:33PM +0400, Sergei Shtylyov wrote:
 Hello.
 
 On 11-04-2013 4:51, Simon Horman wrote:
 
 Here's the set of 9 patches against the Simon Horman's 'renesas.git' 
  repo,
 'renesas-next-20130410' tag.  It was created to fix the shortcomings in 
 the
 R8A7779/Marzen USB platform code and R8A7779 USB common PHY driver, and 
 so
 spans both arch/arm/mach-shmobile/ and drivers/usb/ subtrees (some 
 patches have
 to touch both subtrees). The patches were conceived with the complete
 bisectability goal in mind.
 
 [1/9] ARM: shmobile: Marzen: move USB EHCI, OHCI, and PHY devices to 
 R8A7779 code
 [2/9] ehci-platform: add pre_setup() method to platform data
 [3/9] ARM: shmobile: R8A7779: setup EHCI internal buffer
 [4/9] rcar-phy: remove EHCI internal buffer setup
 [5/9] ARM: shmobile: R8A7779: remove USB PHY 2nd memory resource
 [6/9] rcar-phy: correct base address
 [7/9] rcar-phy: add platform data
 [8/9] ARM: shmobile: Marzen: pass platform data to USB PHY device
 [9/9] rcar-phy: handle platform data
 
 I'm not sure thru which tree this patchset should be merged, however 
  it turns
 out that it's too late now to push it thru Felipe Balbi's USB tree for 
 3.10
 (which would have been most convenient probably), and it's probably too 
 late to
 merge thru Simon's tree for 3.10 too. So it now have to be postponed to 
 3.11,
 unfortunately...
 
 Felipe, how would you prefer to handle this?
 I'm happy for you to take it or to take it myself.
 
 please take it yourself, just keep in mind there will be conflicts, I
 will go over the patches now and give my Acked-by so you can queue them
 up.
 
 Thanks
 
 Sergei, it looks like patches 1-7 are clear.
 
#7  #9 have been refused by Felipe (hence #8 isn't good too).
 
 Do you want me to start queueing them up.
 
I was going to repost the whole series soon, adding ACK from Alan
 to the patch #2 and resolving issues with patches #7..#9. It's worth
 waiting for that to happen I think.
 
 Or would you rather wait for the issue with patch 6 to be resolved?
 
There's no special issue with patch #6 other than the PHY driver
 files being renamed in Felipe's tree -- but that concerns all patches
 touching drivers/usb/phy/rcar-phy.c (some of which precede #6).
I don't know how the rename conflict will be handled (this is
 really bad coincidence), perhaps I still should have done this
 patchset against Felipe's 'next' branch and pushed it thru his tree.
 If the patches will be queued for 3.11 anyway, maybe it's worth doing
 that -- I'm still of the opinion that his tree would be the one most
 fitting for this patchset.

git can handle renames well, don't worry. Conflict will be easy to
resolve.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v3 0/9] Reorganize R8A7779/Marzen USB code

2013-04-11 Thread Sergei Shtylyov

Hello.

On 11-04-2013 16:06, Felipe Balbi wrote:


Here's the set of 9 patches against the Simon Horman's 'renesas.git' repo,
'renesas-next-20130410' tag.  It was created to fix the shortcomings in the
R8A7779/Marzen USB platform code and R8A7779 USB common PHY driver, and so
spans both arch/arm/mach-shmobile/ and drivers/usb/ subtrees (some patches have
to touch both subtrees). The patches were conceived with the complete
bisectability goal in mind.



[1/9] ARM: shmobile: Marzen: move USB EHCI, OHCI, and PHY devices to R8A7779 
code
[2/9] ehci-platform: add pre_setup() method to platform data
[3/9] ARM: shmobile: R8A7779: setup EHCI internal buffer
[4/9] rcar-phy: remove EHCI internal buffer setup
[5/9] ARM: shmobile: R8A7779: remove USB PHY 2nd memory resource
[6/9] rcar-phy: correct base address
[7/9] rcar-phy: add platform data
[8/9] ARM: shmobile: Marzen: pass platform data to USB PHY device
[9/9] rcar-phy: handle platform data



I'm not sure thru which tree this patchset should be merged, however it 
turns
out that it's too late now to push it thru Felipe Balbi's USB tree for 3.10
(which would have been most convenient probably), and it's probably too late to
merge thru Simon's tree for 3.10 too. So it now have to be postponed to 3.11,
unfortunately...



Felipe, how would you prefer to handle this?
I'm happy for you to take it or to take it myself.



please take it yourself, just keep in mind there will be conflicts, I
will go over the patches now and give my Acked-by so you can queue them
up.



Thanks



Sergei, it looks like patches 1-7 are clear.



#7  #9 have been refused by Felipe (hence #8 isn't good too).



Do you want me to start queueing them up.



I was going to repost the whole series soon, adding ACK from Alan
to the patch #2 and resolving issues with patches #7..#9. It's worth
waiting for that to happen I think.



Or would you rather wait for the issue with patch 6 to be resolved?



There's no special issue with patch #6 other than the PHY driver
files being renamed in Felipe's tree -- but that concerns all patches
touching drivers/usb/phy/rcar-phy.c (some of which precede #6).
I don't know how the rename conflict will be handled (this is
really bad coincidence), perhaps I still should have done this
patchset against Felipe's 'next' branch and pushed it thru his tree.
If the patches will be queued for 3.11 anyway, maybe it's worth doing
that -- I'm still of the opinion that his tree would be the one most
fitting for this patchset.



git can handle renames well, don't worry. Conflict will be easy to
resolve.


   I'm adding a header file to include/linux/usb/ which now should probably 
be renamed too, after the driver, to 'phy-rcar-usb.h'. I prbably should rename 
it now, in anticipation, or the one who would resolve the conflict, won't 
figure it out to do it. Or perhaps indeed patches #1..#6 can be merged now, 
and the rest postponed...


WBR, Sergei

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


[PATCH 0/9] Equivalent of g_ncm.ko with configfs

2013-04-11 Thread Andrzej Pietrasiewicz
Here I present the conversion of everthing that is required to provide
the equivalent of g_ncm.ko with configfs.

A branch will be available here (from 11th April 2013, afternoon UTC):

git://git.infradead.org/users/kmpark/linux-samsung usb-gadget-configfs

@Felipe: The branch name is now corrected and reads usb-gadget-configfs.
The old name had a typo and read usb-gadgdet-configfs. It is rebased
onto your current master, and does not contain any work-in-progress
commits added by me without proper authorship information.

The prerequisite for this series is a series which can be found here:

http://www.spinics.net/lists/linux-usb/msg83460.html

and which is already applied to Felipe's master.


BACKWARD COMPATIBILITY
==

Please note that the old g_ncm.ko is still available and works.


USING THE NEW GADGET
==

Please refer to this post:

http://www.spinics.net/lists/linux-usb/msg76388.html

for general information from Sebastian on how to use configfs-based
gadgets (*).

Here is the description specific to using g_ncm.ko equivalent.

The old g_ncm.ko offered three parameters:

qmult  - queue length multiplier for high/super -speed devices
dev_addr   - device's MAC address
host_addr  - host's MAC address

With configfs the procedure is as follows, compared to the information
mentioned above (*):

instead of mkdir functions/acm.ttyS1 do

mkdir functions/ncm.instance name

e.g. mkdir functions/ncm.usb0

In functions/ncm.instance name there will be the following attribute files:

qmult
dev_addr
host_addr
ifname

and after creating the functions/ncm.instance name they contain default
values: qmult is 5, dev_addr and host_addr are randomly selected.
Except for ifname they can be written to until the function is linked to a
configuration. The ifname is read-only and contains the name of the interface
which was assigned by the net core, e. g. usb0.

The rest of the procedure (*) remains the same.

After unbinding the gadget with echo   UDC
the symbolic links in the configuration directory can be removed,
the strings/* subdirectories in the configuration directory can
be removed, the strings/* subdirectories at the gadget level can
be removed and the configs/* subdirectories can be removed.
The functions/* subdirectories can be removed.
After that the gadget directory can be removed.
After that the respective modules can be unloaded.


TESTING THE FUNCTIONS (actually there is just one)
==

ncm)

On the device: ping host's IP
On the host: ping device's IP


Andrzej Pietrasiewicz (9):
  usb/gadget: u_ether: convert into module
  usb/gadget: rndis: convert into module
  usb/gadget: change sysfs parent device for USB Ethernet
  usb/gadget: u_ether: construct with default values and add
setters/getters
  usb/gadget: f_ncm: convert to new function interface with backward
compatibility
  usb/gadget: ncm: convert to new function interface
  usb/gadget: f_ncm: remove compatibility layer
  usb/gadget: f_ncm: use usb_gstrings_attach
  usb/gadget: f_ncm: add configfs support

 drivers/usb/gadget/Kconfig|   20 +++
 drivers/usb/gadget/Makefile   |6 +
 drivers/usb/gadget/cdc2.c |   18 ++-
 drivers/usb/gadget/configfs.c |   15 ++
 drivers/usb/gadget/configfs.h |   18 +++
 drivers/usb/gadget/ether.c|   22 +++-
 drivers/usb/gadget/f_ncm.c|  310 -
 drivers/usb/gadget/g_ffs.c|   21 +++-
 drivers/usb/gadget/multi.c|   21 +++-
 drivers/usb/gadget/ncm.c  |   70 +++---
 drivers/usb/gadget/nokia.c|   19 +++-
 drivers/usb/gadget/rndis.c|   16 ++
 drivers/usb/gadget/rndis.h|1 +
 drivers/usb/gadget/u_ether.c  |  228 +++
 drivers/usb/gadget/u_ether.h  |  115 ++-
 drivers/usb/gadget/u_ncm.h|   36 +
 16 files changed, 805 insertions(+), 131 deletions(-)
 create mode 100644 drivers/usb/gadget/configfs.h
 create mode 100644 drivers/usb/gadget/u_ncm.h

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


[PATCH 2/9] usb/gadget: rndis: convert into module

2013-04-11 Thread Andrzej Pietrasiewicz
In order to convert to configfs the usb functions need to be converted
to a new interface and compiled as modules. This patch creates an rndis
module which will be used by the new functions. After all users of
f_rndis are converted to the new interface, this module can be
merged with f_rndis module.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/usb/gadget/Kconfig  |6 ++
 drivers/usb/gadget/Makefile |2 ++
 drivers/usb/gadget/ether.c  |4 +++-
 drivers/usb/gadget/g_ffs.c  |2 +-
 drivers/usb/gadget/multi.c  |2 +-
 drivers/usb/gadget/rndis.c  |   16 
 drivers/usb/gadget/rndis.h  |1 +
 7 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 1b5b89b..84167fa 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -509,6 +509,9 @@ config USB_U_SERIAL
 config USB_U_ETHER
tristate
 
+config USB_U_RNDIS
+   tristate
+
 config USB_F_SERIAL
tristate
 
@@ -606,6 +609,7 @@ config USB_ETH
depends on NET
select USB_LIBCOMPOSITE
select USB_U_ETHER
+   select USB_U_RNDIS
select CRC32
help
  This driver implements Ethernet style communication, in one of
@@ -731,6 +735,7 @@ config USB_FUNCTIONFS_RNDIS
bool Include configuration with RNDIS (Ethernet)
depends on USB_FUNCTIONFS  NET
select USB_U_ETHER
+   select USB_U_RNDIS
help
  Include a configuration with RNDIS function (Ethernet) and the 
Filesystem.
 
@@ -878,6 +883,7 @@ config USB_G_MULTI
select USB_LIBCOMPOSITE
select USB_U_SERIAL
select USB_U_ETHER
+   select USB_U_RNDIS
select USB_F_ACM
help
  The Multifunction Composite Gadget provides Ethernet (RNDIS
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index 8ca4fc7..6882033 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -46,6 +46,8 @@ obj-$(CONFIG_USB_F_SERIAL)+= usb_f_serial.o
 usb_f_obex-y   := f_obex.o
 obj-$(CONFIG_USB_F_OBEX)   += usb_f_obex.o
 obj-$(CONFIG_USB_U_ETHER)  += u_ether.o
+u_rndis-y  := rndis.o
+obj-$(CONFIG_USB_U_RNDIS)  += u_rndis.o
 
 #
 # USB gadget drivers
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 5fd58c1..74ffc49 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -91,6 +91,8 @@ static inline bool has_rndis(void)
 #endif
 }
 
+#include linux/module.h
+
 /*-*/
 
 /*
@@ -104,7 +106,7 @@ static inline bool has_rndis(void)
 #include f_subset.c
 #ifdef USB_ETH_RNDIS
 #include f_rndis.c
-#include rndis.c
+#include rndis.h
 #endif
 #include f_eem.c
 
diff --git a/drivers/usb/gadget/g_ffs.c b/drivers/usb/gadget/g_ffs.c
index 6e9c63b..209b446 100644
--- a/drivers/usb/gadget/g_ffs.c
+++ b/drivers/usb/gadget/g_ffs.c
@@ -32,7 +32,7 @@
 #  include f_subset.c
 #  ifdef USB_ETH_RNDIS
 #include f_rndis.c
-#include rndis.c
+#include rndis.h
 #  endif
 #  include u_ether.h
 
diff --git a/drivers/usb/gadget/multi.c b/drivers/usb/gadget/multi.c
index 5d9e3ab..ca2ea3f 100644
--- a/drivers/usb/gadget/multi.c
+++ b/drivers/usb/gadget/multi.c
@@ -47,7 +47,7 @@ MODULE_LICENSE(GPL);
 #include f_subset.c
 #ifdef USB_ETH_RNDIS
 #  include f_rndis.c
-#  include rndis.c
+#  include rndis.h
 #endif
 #include u_ether.h
 
diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c
index d9297ee..1ce6bae 100644
--- a/drivers/usb/gadget/rndis.c
+++ b/drivers/usb/gadget/rndis.c
@@ -761,6 +761,7 @@ int rndis_signal_connect(int configNr)
return rndis_indicate_status_msg(configNr,
  RNDIS_STATUS_MEDIA_CONNECT);
 }
+EXPORT_SYMBOL(rndis_signal_connect);
 
 int rndis_signal_disconnect(int configNr)
 {
@@ -769,6 +770,7 @@ int rndis_signal_disconnect(int configNr)
return rndis_indicate_status_msg(configNr,
  RNDIS_STATUS_MEDIA_DISCONNECT);
 }
+EXPORT_SYMBOL(rndis_signal_disconnect);
 
 void rndis_uninit(int configNr)
 {
@@ -783,11 +785,13 @@ void rndis_uninit(int configNr)
while ((buf = rndis_get_next_response(configNr, length)))
rndis_free_response(configNr, buf);
 }
+EXPORT_SYMBOL(rndis_uninit);
 
 void rndis_set_host_mac(int configNr, const u8 *addr)
 {
rndis_per_dev_params[configNr].host_mac = addr;
 }
+EXPORT_SYMBOL(rndis_set_host_mac);
 
 /*
  * Message Parser
@@ -870,6 +874,7 @@ int rndis_msg_parser(u8 configNr, u8 *buf)
 
return -ENOTSUPP;
 }
+EXPORT_SYMBOL(rndis_msg_parser);
 
 int rndis_register(void (*resp_avail)(void *v), void *v)
 {
@@ -891,6 +896,7 @@ int rndis_register(void (*resp_avail)(void *v), void *v)
 
return -ENODEV;
 }
+EXPORT_SYMBOL(rndis_register);

[PATCH 1/9] usb/gadget: u_ether: convert into module

2013-04-11 Thread Andrzej Pietrasiewicz
u_ether.c has been #include'd by all gadgets which implement
USB Ethernet functions. In order to add configfs support,
the f_ecm.c, f_eem.c, f_ncm.c, f_subset.c, f_rndis.c need to be
converted into modules and must not be #include'd. Consequently,
the u_ether.c needs to be a module too, in a manner similar
to u_serial.c. The resulting module should not take any parameters,
so they are pushed to the current users of it, that is ether.c,
g_ffs.c, multi.c, ncm.c, nokia.c.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/usb/gadget/Kconfig   |   10 ++
 drivers/usb/gadget/Makefile  |2 ++
 drivers/usb/gadget/cdc2.c|   18 --
 drivers/usb/gadget/ether.c   |   18 --
 drivers/usb/gadget/g_ffs.c   |   19 +--
 drivers/usb/gadget/multi.c   |   19 +--
 drivers/usb/gadget/ncm.c |   18 --
 drivers/usb/gadget/nokia.c   |   19 +--
 drivers/usb/gadget/u_ether.c |   38 ++
 drivers/usb/gadget/u_ether.h |   12 
 10 files changed, 137 insertions(+), 36 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index a61d981..1b5b89b 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -506,6 +506,9 @@ config USB_F_SS_LB
 config USB_U_SERIAL
tristate
 
+config USB_U_ETHER
+   tristate
+
 config USB_F_SERIAL
tristate
 
@@ -602,6 +605,7 @@ config USB_ETH
tristate Ethernet Gadget (with CDC Ethernet support)
depends on NET
select USB_LIBCOMPOSITE
+   select USB_U_ETHER
select CRC32
help
  This driver implements Ethernet style communication, in one of
@@ -674,6 +678,7 @@ config USB_G_NCM
tristate Network Control Model (NCM) support
depends on NET
select USB_LIBCOMPOSITE
+   select USB_U_ETHER
select CRC32
help
  This driver implements USB CDC NCM subclass standard. NCM is
@@ -717,6 +722,7 @@ config USB_FUNCTIONFS
 config USB_FUNCTIONFS_ETH
bool Include configuration with CDC ECM (Ethernet)
depends on USB_FUNCTIONFS  NET
+   select USB_U_ETHER
help
  Include a configuration with CDC ECM function (Ethernet) and the
  Function Filesystem.
@@ -724,6 +730,7 @@ config USB_FUNCTIONFS_ETH
 config USB_FUNCTIONFS_RNDIS
bool Include configuration with RNDIS (Ethernet)
depends on USB_FUNCTIONFS  NET
+   select USB_U_ETHER
help
  Include a configuration with RNDIS function (Ethernet) and the 
Filesystem.
 
@@ -824,6 +831,7 @@ config USB_CDC_COMPOSITE
depends on NET
select USB_LIBCOMPOSITE
select USB_U_SERIAL
+   select USB_U_ETHER
select USB_F_ACM
help
  This driver provides two functions in one configuration:
@@ -841,6 +849,7 @@ config USB_G_NOKIA
depends on PHONET
select USB_LIBCOMPOSITE
select USB_U_SERIAL
+   select USB_U_ETHER
select USB_F_ACM
help
  The Nokia composite gadget provides support for acm, obex
@@ -868,6 +877,7 @@ config USB_G_MULTI
select USB_G_MULTI_CDC if !USB_G_MULTI_RNDIS
select USB_LIBCOMPOSITE
select USB_U_SERIAL
+   select USB_U_ETHER
select USB_F_ACM
help
  The Multifunction Composite Gadget provides Ethernet (RNDIS
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index 6afd166..8ca4fc7 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -45,6 +45,7 @@ usb_f_serial-y:= f_serial.o
 obj-$(CONFIG_USB_F_SERIAL) += usb_f_serial.o
 usb_f_obex-y   := f_obex.o
 obj-$(CONFIG_USB_F_OBEX)   += usb_f_obex.o
+obj-$(CONFIG_USB_U_ETHER)  += u_ether.o
 
 #
 # USB gadget drivers
@@ -85,3 +86,4 @@ obj-$(CONFIG_USB_G_WEBCAM)+= g_webcam.o
 obj-$(CONFIG_USB_G_NCM)+= g_ncm.o
 obj-$(CONFIG_USB_G_ACM_MS) += g_acm_ms.o
 obj-$(CONFIG_USB_GADGET_TARGET)+= tcm_usb_gadget.o
+
diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c
index c6ee6f1..8cf8c6d 100644
--- a/drivers/usb/gadget/cdc2.c
+++ b/drivers/usb/gadget/cdc2.c
@@ -35,6 +35,20 @@
 /*-*/
 USB_GADGET_COMPOSITE_OPTIONS();
 
+static unsigned qmult = QMULT_DEFAULT;
+module_param(qmult, uint, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(qmult, queue length multiplier at high/super speed);
+
+/* initial value, changed by ifconfig usb0 hw ether xx:xx:xx:xx:xx:xx */
+static char *dev_addr;
+module_param(dev_addr, charp, S_IRUGO);
+MODULE_PARM_DESC(dev_addr, Device Ethernet Address);
+
+/* this address is invisible to ifconfig */
+static char *host_addr;
+module_param(host_addr, charp, S_IRUGO);
+MODULE_PARM_DESC(host_addr, Host Ethernet Address);
+
 /*
  * 

[PATCH 4/9] usb/gadget: u_ether: construct with default values and add setters/getters

2013-04-11 Thread Andrzej Pietrasiewicz
When configfs support is added it will be possible to add an unconfigured
interface to the system. This patch adds an interface to u_ether which
makes it possible to create a struct eth_dev filled with default values,
an interface which makes it possible to fill the struct with useful values,
and an interface which makes it possible to read the values set.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/usb/gadget/u_ether.c |  173 ++
 drivers/usb/gadget/u_ether.h |  101 
 2 files changed, 274 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/gadget/u_ether.c b/drivers/usb/gadget/u_ether.c
index de9d84f..f9b17c8 100644
--- a/drivers/usb/gadget/u_ether.c
+++ b/drivers/usb/gadget/u_ether.c
@@ -719,6 +719,24 @@ static int get_ether_addr(const char *str, u8 *dev_addr)
return 1;
 }
 
+static int get_ether_addr_str(u8 dev_addr[ETH_ALEN], char *str, int len)
+{
+   char *s;
+
+   if (len  16)
+   return -EINVAL;
+
+   hex_dump_to_buffer(dev_addr, ETH_ALEN, 16, 1, str, 20, false);
+   s = str;
+   while (*s) {
+   if (*s == ' ')
+   *s = ':';
+   s++;
+   }
+
+   return strlen(str);
+}
+
 static const struct net_device_ops eth_netdev_ops = {
.ndo_open   = eth_open,
.ndo_stop   = eth_stop,
@@ -812,6 +830,161 @@ struct eth_dev *gether_setup_name(struct usb_gadget *g,
 }
 EXPORT_SYMBOL(gether_setup_name);
 
+struct net_device *gether_setup_name_default(const char *netname,
+u8 ethaddr[ETH_ALEN])
+{
+   struct net_device   *net;
+   struct eth_dev  *dev;
+   int status;
+
+   net = alloc_etherdev(sizeof(*dev));
+   if (!net)
+   return ERR_PTR(-ENOMEM);
+
+   dev = netdev_priv(net);
+   spin_lock_init(dev-lock);
+   spin_lock_init(dev-req_lock);
+   INIT_WORK(dev-work, eth_work);
+   INIT_LIST_HEAD(dev-tx_reqs);
+   INIT_LIST_HEAD(dev-rx_reqs);
+
+   skb_queue_head_init(dev-rx_frames);
+
+   /* network device setup */
+   dev-net = net;
+   dev-qmult = QMULT_DEFAULT;
+   snprintf(net-name, sizeof(net-name), %s%%d, netname);
+   dev-parent_dev = gadget_sysfs_root;
+
+   eth_random_addr(net-dev_addr);
+   dev_warn(dev-parent_dev, using random %s ethernet address\n, self);
+   eth_random_addr(dev-host_mac);
+   dev_warn(dev-parent_dev, using random %s ethernet address\n, host);
+
+   if (ethaddr)
+   memcpy(ethaddr, dev-host_mac, ETH_ALEN);
+
+   net-netdev_ops = eth_netdev_ops;
+
+   SET_ETHTOOL_OPS(net, ops);
+
+   SET_NETDEV_DEV(net, dev-parent_dev);
+   SET_NETDEV_DEVTYPE(net, gadget_type);
+
+   status = register_netdev(net);
+   if (status  0) {
+   dev_dbg(dev-parent_dev, register_netdev failed, %d\n,
+   status);
+   free_netdev(net);
+   dev = ERR_PTR(status);
+   } else {
+   INFO(dev, MAC %pM\n, net-dev_addr);
+   INFO(dev, HOST MAC %pM\n, dev-host_mac);
+
+   /* two kinds of host-initiated state changes:
+*  - iff DATA transfer is active, carrier is on
+*  - tx queueing enabled if open *and* carrier is on
+*/
+   netif_carrier_off(net);
+   }
+
+   return net;
+}
+EXPORT_SYMBOL(gether_setup_name_default);
+
+void gether_set_gadget(struct net_device *net, struct usb_gadget *g)
+{
+   struct eth_dev *dev;
+
+   dev = netdev_priv(net);
+   dev-gadget = g;
+}
+EXPORT_SYMBOL(gether_set_gadget);
+
+int gether_set_dev_addr(struct net_device *net, const char *dev_addr)
+{
+   struct eth_dev *dev;
+   struct sockaddr sa;
+   u8 ethaddr[ETH_ALEN];
+   int status;
+
+   dev = netdev_priv(net);
+
+   if (get_ether_addr(dev_addr, ethaddr))
+   dev_warn(dev-parent_dev,
+   using random %s ethernet address\n, self);
+
+   sa.sa_family = net-type;
+   memcpy(sa.sa_data, ethaddr, ETH_ALEN);
+   rtnl_lock();
+   status = dev_set_mac_address(net, sa);
+   rtnl_unlock();
+   if (status) {
+   dev_warn(dev-parent_dev,
+   cannot set self ethernet address: %d\n, status);
+   return status;
+   }
+
+   return 0;
+
+}
+EXPORT_SYMBOL(gether_set_dev_addr);
+
+int gether_get_dev_addr(struct net_device *net, char *dev_addr, int len)
+{
+   return get_ether_addr_str(net-dev_addr, dev_addr, len);
+}
+EXPORT_SYMBOL(gether_get_dev_addr);
+
+void gether_set_host_addr(struct net_device *net, const char *host_addr,
+  u8 hostaddr[ETH_ALEN])
+{
+   struct eth_dev *dev;
+
+   dev = netdev_priv(net);
+   if 

[PATCH 7/9] usb/gadget: f_ncm: remove compatibility layer

2013-04-11 Thread Andrzej Pietrasiewicz
There are no old function interface users left, so the old interface
can be removed.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/usb/gadget/f_ncm.c   |   80 --
 drivers/usb/gadget/u_ether.h |2 -
 2 files changed, 0 insertions(+), 82 deletions(-)

diff --git a/drivers/usb/gadget/f_ncm.c b/drivers/usb/gadget/f_ncm.c
index 280b18b..21ba578 100644
--- a/drivers/usb/gadget/f_ncm.c
+++ b/drivers/usb/gadget/f_ncm.c
@@ -1160,8 +1160,6 @@ static int ncm_bind(struct usb_configuration *c, struct 
usb_function *f)
struct f_ncm*ncm = func_to_ncm(f);
int status;
struct usb_ep   *ep;
-
-#ifndef USB_FNCM_INCLUDED
struct f_ncm_opts   *ncm_opts;
 
if (!can_support_ecm(cdev-gadget))
@@ -1171,7 +1169,6 @@ static int ncm_bind(struct usb_configuration *c, struct 
usb_function *f)
if (!ncm_opts-ethaddr)
return -EINVAL;
gether_set_gadget(ncm_opts-net, cdev-gadget);
-#endif
if (ncm_string_defs[0].id == 0) {
status = usb_string_ids_tab(c-cdev, ncm_string_defs);
if (status  0)
@@ -1286,80 +1283,6 @@ fail:
return status;
 }
 
-#ifdef USB_FNCM_INCLUDED
-
-static void
-ncm_old_unbind(struct usb_configuration *c, struct usb_function *f)
-{
-   struct f_ncm*ncm = func_to_ncm(f);
-
-   DBG(c-cdev, ncm unbind\n);
-
-   ncm_string_defs[0].id = 0;
-   usb_free_all_descriptors(f);
-
-   kfree(ncm-notify_req-buf);
-   usb_ep_free_request(ncm-notify, ncm-notify_req);
-
-   kfree(ncm);
-}
-
-/**
- * ncm_bind_config - add CDC Network link to a configuration
- * @c: the configuration to support the network link
- * @ethaddr: a buffer in which the ethernet address of the host side
- * side of the link was recorded
- * Context: single threaded during gadget setup
- *
- * Returns zero on success, else negative errno.
- *
- * Caller must have called @gether_setup().  Caller is also responsible
- * for calling @gether_cleanup() before module unload.
- */
-int __init ncm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
-   struct eth_dev *dev)
-{
-   struct f_ncm*ncm;
-   int status;
-
-   if (!can_support_ecm(c-cdev-gadget) || !ethaddr)
-   return -EINVAL;
-
-   /* allocate and initialize one new instance */
-   ncm = kzalloc(sizeof *ncm, GFP_KERNEL);
-   if (!ncm)
-   return -ENOMEM;
-
-   /* export host's Ethernet address in CDC format */
-   snprintf(ncm-ethaddr, sizeof ncm-ethaddr, %pm, ethaddr);
-   ncm_string_defs[STRING_MAC_IDX].s = ncm-ethaddr;
-
-   spin_lock_init(ncm-lock);
-   ncm_reset_values(ncm);
-   ncm-port.ioport = dev;
-   ncm-port.is_fixed = true;
-
-   ncm-port.func.name = cdc_network;
-   ncm-port.func.strings = ncm_strings;
-   /* descriptors are per-instance copies */
-   ncm-port.func.bind = ncm_bind;
-   ncm-port.func.unbind = ncm_old_unbind;
-   ncm-port.func.set_alt = ncm_set_alt;
-   ncm-port.func.get_alt = ncm_get_alt;
-   ncm-port.func.setup = ncm_setup;
-   ncm-port.func.disable = ncm_disable;
-
-   ncm-port.wrap = ncm_wrap_ntb;
-   ncm-port.unwrap = ncm_unwrap_ntb;
-
-   status = usb_add_function(c, ncm-port.func);
-   if (status)
-   kfree(ncm);
-   return status;
-}
-
-#else
-
 static void ncm_free_inst(struct usb_function_instance *f)
 {
struct f_ncm_opts *opts;
@@ -1446,6 +1369,3 @@ struct usb_function *ncm_alloc(struct 
usb_function_instance *fi)
 DECLARE_USB_FUNCTION_INIT(ncm, ncm_alloc_inst, ncm_alloc);
 MODULE_LICENSE(GPL);
 MODULE_AUTHOR(Yauheni Kaliuta);
-
-#endif
-
diff --git a/drivers/usb/gadget/u_ether.h b/drivers/usb/gadget/u_ether.h
index 76a0058..2c5d40b 100644
--- a/drivers/usb/gadget/u_ether.h
+++ b/drivers/usb/gadget/u_ether.h
@@ -222,8 +222,6 @@ int geth_bind_config(struct usb_configuration *c, u8 
ethaddr[ETH_ALEN],
struct eth_dev *dev);
 int ecm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
struct eth_dev *dev);
-int ncm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
-   struct eth_dev *dev);
 int eem_bind_config(struct usb_configuration *c, struct eth_dev *dev);
 
 #ifdef USB_ETH_RNDIS
-- 
1.7.0.4

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


[PATCH 8/9] usb/gadget: f_ncm: use usb_gstrings_attach

2013-04-11 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/usb/gadget/f_ncm.c |   26 ++
 1 files changed, 10 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/gadget/f_ncm.c b/drivers/usb/gadget/f_ncm.c
index 21ba578..0198f60 100644
--- a/drivers/usb/gadget/f_ncm.c
+++ b/drivers/usb/gadget/f_ncm.c
@@ -1158,6 +1158,7 @@ static int ncm_bind(struct usb_configuration *c, struct 
usb_function *f)
 {
struct usb_composite_dev *cdev = c-cdev;
struct f_ncm*ncm = func_to_ncm(f);
+   struct usb_string   *us;
int status;
struct usb_ep   *ep;
struct f_ncm_opts   *ncm_opts;
@@ -1169,20 +1170,15 @@ static int ncm_bind(struct usb_configuration *c, struct 
usb_function *f)
if (!ncm_opts-ethaddr)
return -EINVAL;
gether_set_gadget(ncm_opts-net, cdev-gadget);
-   if (ncm_string_defs[0].id == 0) {
-   status = usb_string_ids_tab(c-cdev, ncm_string_defs);
-   if (status  0)
-   return status;
-   ncm_control_intf.iInterface =
-   ncm_string_defs[STRING_CTRL_IDX].id;
-
-   status = ncm_string_defs[STRING_DATA_IDX].id;
-   ncm_data_nop_intf.iInterface = status;
-   ncm_data_intf.iInterface = status;
-
-   ecm_desc.iMACAddress = ncm_string_defs[STRING_MAC_IDX].id;
-   ncm_iad_desc.iFunction = ncm_string_defs[STRING_IAD_IDX].id;
-   }
+   us = usb_gstrings_attach(cdev, ncm_strings,
+ARRAY_SIZE(ncm_string_defs));
+   if (IS_ERR(us))
+   return PTR_ERR(us);
+   ncm_control_intf.iInterface = us[STRING_CTRL_IDX].id;
+   ncm_data_nop_intf.iInterface = us[STRING_DATA_IDX].id;
+   ncm_data_intf.iInterface = us[STRING_DATA_IDX].id;
+   ecm_desc.iMACAddress = us[STRING_MAC_IDX].id;
+   ncm_iad_desc.iFunction = us[STRING_IAD_IDX].id;
 
/* allocate instance-specific interface IDs */
status = usb_interface_id(c, f);
@@ -1321,7 +1317,6 @@ static void ncm_unbind(struct usb_configuration *c, 
struct usb_function *f)
 
DBG(c-cdev, ncm unbind\n);
 
-   ncm_string_defs[0].id = 0;
usb_free_all_descriptors(f);
 
kfree(ncm-notify_req-buf);
@@ -1350,7 +1345,6 @@ struct usb_function *ncm_alloc(struct 
usb_function_instance *fi)
ncm-port.is_fixed = true;
 
ncm-port.func.name = cdc_network;
-   ncm-port.func.strings = ncm_strings;
/* descriptors are per-instance copies */
ncm-port.func.bind = ncm_bind;
ncm-port.func.unbind = ncm_unbind;
-- 
1.7.0.4

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


[PATCH 3/9] usb/gadget: change sysfs parent device for USB Ethernet

2013-04-11 Thread Andrzej Pietrasiewicz
This adds a new sysfs root device to serve as a replacement for
devices which are available only when a gadget is being bound.

It is motivated by adding configfs support to USB Ethernet functions.
When configfs is there, we would like to be able to mkdir some function
directory, e.g.:

$ mkdir functions/ecm.usb0

and have the usb0 available in the system (albeit in an unconfigured,
or default state) at this very point, which is _way_ before the gadget
is actually bound. However, this poses a chicken and egg problem.
In order for the interface to appear in the system, it needs to be
registered with register_netdev. But in order to register it, its
parent device must be known and it becomes known only later during
gadget's bind.

This patch adds a /sys/devices/usb_gadget root device, which is registered
during module_init of libcomposite, so it is available at any time for
all libcomposite users and is used as a parent device for USB Ethernet
devices instead of the gadget-dev.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/usb/gadget/configfs.c |   15 +++
 drivers/usb/gadget/configfs.h |   18 ++
 drivers/usb/gadget/u_ether.c  |   17 +++--
 3 files changed, 44 insertions(+), 6 deletions(-)
 create mode 100644 drivers/usb/gadget/configfs.h

diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
index a34633a..9e24c0b 100644
--- a/drivers/usb/gadget/configfs.c
+++ b/drivers/usb/gadget/configfs.c
@@ -985,6 +985,9 @@ static struct configfs_subsystem gadget_subsys = {
.su_mutex = __MUTEX_INITIALIZER(gadget_subsys.su_mutex),
 };
 
+struct device *gadget_sysfs_root;
+EXPORT_SYMBOL(gadget_sysfs_root);
+
 static int __init gadget_cfs_init(void)
 {
int ret;
@@ -992,12 +995,24 @@ static int __init gadget_cfs_init(void)
config_group_init(gadget_subsys.su_group);
 
ret = configfs_register_subsystem(gadget_subsys);
+   if (ret)
+   return ret;
+
+   gadget_sysfs_root = root_device_register(
+   gadget_subsys.su_group.cg_item.ci_namebuf);
+
+   if (IS_ERR_OR_NULL(gadget_sysfs_root)) {
+   ret = PTR_ERR(gadget_sysfs_root);
+   configfs_unregister_subsystem(gadget_subsys);
+   }
+
return ret;
 }
 module_init(gadget_cfs_init);
 
 static void __exit gadget_cfs_exit(void)
 {
+   root_device_unregister(gadget_sysfs_root);
configfs_unregister_subsystem(gadget_subsys);
 }
 module_exit(gadget_cfs_exit);
diff --git a/drivers/usb/gadget/configfs.h b/drivers/usb/gadget/configfs.h
new file mode 100644
index 000..58362a6
--- /dev/null
+++ b/drivers/usb/gadget/configfs.h
@@ -0,0 +1,18 @@
+/* linux/drivers/usb/gadget/configfs.h
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * Author: Andrzej Pietrasiewicz andrze...@samsung.com
+ *
+ * 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.
+ */
+
+#ifndef USB_GADGET_CONFIGFS_H
+#define USB_GADGET_CONFIGFS_H
+
+extern struct device *gadget_sysfs_root;
+
+#endif /* USB_GADGET_CONFIGFS_H */
diff --git a/drivers/usb/gadget/u_ether.c b/drivers/usb/gadget/u_ether.c
index 5f9dacf..de9d84f 100644
--- a/drivers/usb/gadget/u_ether.c
+++ b/drivers/usb/gadget/u_ether.c
@@ -23,6 +23,7 @@
 #include linux/if_vlan.h
 
 #include u_ether.h
+#include configfs.h
 
 
 /*
@@ -56,6 +57,7 @@ struct eth_dev {
 
struct net_device   *net;
struct usb_gadget   *gadget;
+   struct device   *parent_dev;
 
spinlock_t  req_lock;   /* guard {rx,tx}_reqs */
struct list_headtx_reqs, rx_reqs;
@@ -160,8 +162,9 @@ static void eth_get_drvinfo(struct net_device *net, struct 
ethtool_drvinfo *p)
 
strlcpy(p-driver, g_ether, sizeof(p-driver));
strlcpy(p-version, UETH__VERSION, sizeof(p-version));
-   strlcpy(p-fw_version, dev-gadget-name, sizeof(p-fw_version));
-   strlcpy(p-bus_info, dev_name(dev-gadget-dev), sizeof(p-bus_info));
+   strlcpy(p-fw_version, dev_name(dev-parent_dev),
+   sizeof(p-fw_version));
+   strlcpy(p-bus_info, dev_name(dev-parent_dev), sizeof(p-bus_info));
 }
 
 /* REVISIT can also support:
@@ -768,12 +771,13 @@ struct eth_dev *gether_setup_name(struct usb_gadget *g,
dev-net = net;
dev-qmult = qmult;
snprintf(net-name, sizeof(net-name), %s%%d, netname);
+   dev-parent_dev = gadget_sysfs_root;
 
if (get_ether_addr(dev_addr, net-dev_addr))
-   dev_warn(g-dev,
+   dev_warn(dev-parent_dev,
using random %s ethernet address\n, self);
if (get_ether_addr(host_addr, dev-host_mac))
-   dev_warn(g-dev,
+   dev_warn(dev-parent_dev,

[PATCH 9/9] usb/gadget: f_ncm: add configfs support

2013-04-11 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/usb/gadget/f_ncm.c |  162 +++-
 drivers/usb/gadget/u_ncm.h |9 +++
 2 files changed, 170 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/gadget/f_ncm.c b/drivers/usb/gadget/f_ncm.c
index 0198f60..d4a6982 100644
--- a/drivers/usb/gadget/f_ncm.c
+++ b/drivers/usb/gadget/f_ncm.c
@@ -1167,9 +1167,13 @@ static int ncm_bind(struct usb_configuration *c, struct 
usb_function *f)
return -EINVAL;
 
ncm_opts = container_of(f-fi, struct f_ncm_opts, func_inst);
-   if (!ncm_opts-ethaddr)
+   mutex_lock(ncm_opts-lock);
+   if (!ncm_opts-ethaddr) {
+   mutex_unlock(ncm_opts-lock);
return -EINVAL;
+   }
gether_set_gadget(ncm_opts-net, cdev-gadget);
+   mutex_unlock(ncm_opts-lock);
us = usb_gstrings_attach(cdev, ncm_strings,
 ARRAY_SIZE(ncm_string_defs));
if (IS_ERR(us))
@@ -1279,6 +1283,151 @@ fail:
return status;
 }
 
+static inline struct f_ncm_opts *to_f_ncm_opts(struct config_item *item)
+{
+   return container_of(to_config_group(item), struct f_ncm_opts,
+   func_inst.group);
+}
+
+CONFIGFS_ATTR_STRUCT(f_ncm_opts);
+CONFIGFS_ATTR_OPS(f_ncm_opts);
+
+static void ncm_attr_release(struct config_item *item)
+{
+   struct f_ncm_opts *opts = to_f_ncm_opts(item);
+
+   usb_put_function_instance(opts-func_inst);
+}
+
+static struct configfs_item_operations ncm_item_ops = {
+   .release= ncm_attr_release,
+   .show_attribute = f_ncm_opts_attr_show,
+   .store_attribute = f_ncm_opts_attr_store,
+};
+
+static ssize_t ncm_opts_dev_addr_show(struct f_ncm_opts *opts, char *page)
+{
+   int result;
+
+   mutex_lock(opts-lock);
+   result = gether_get_dev_addr(opts-net, page, PAGE_SIZE);
+   mutex_unlock(opts-lock);
+
+   return result;
+}
+
+static ssize_t ncm_opts_dev_addr_store(struct f_ncm_opts *opts,
+   const char *page, size_t len)
+{
+   mutex_lock(opts-lock);
+   if (opts-refcnt) {
+   mutex_unlock(opts-lock);
+   return -EBUSY;
+   }
+
+   gether_set_dev_addr(opts-net, page);
+   mutex_unlock(opts-lock);
+   return len;
+}
+
+static struct f_ncm_opts_attribute f_ncm_opts_dev_addr =
+   __CONFIGFS_ATTR(dev_addr, S_IRUGO | S_IWUSR, ncm_opts_dev_addr_show,
+   ncm_opts_dev_addr_store);
+
+static ssize_t ncm_opts_host_addr_show(struct f_ncm_opts *opts, char *page)
+{
+   int result;
+
+   mutex_lock(opts-lock);
+   result = gether_get_host_addr(opts-net, page, PAGE_SIZE);
+   mutex_unlock(opts-lock);
+
+   return result;
+}
+
+static ssize_t ncm_opts_host_addr_store(struct f_ncm_opts *opts,
+   const char *page, size_t len)
+{
+   mutex_lock(opts-lock);
+   if (opts-refcnt) {
+   mutex_unlock(opts-lock);
+   return -EBUSY;
+   }
+
+   gether_set_host_addr(opts-net, page, opts-ethaddr);
+   mutex_unlock(opts-lock);
+   return len;
+}
+
+static struct f_ncm_opts_attribute f_ncm_opts_host_addr =
+   __CONFIGFS_ATTR(host_addr, S_IRUGO | S_IWUSR, ncm_opts_host_addr_show,
+   ncm_opts_host_addr_store);
+
+static ssize_t ncm_opts_qmult_show(struct f_ncm_opts *opts, char *page)
+{
+   unsigned qmult;
+
+   mutex_lock(opts-lock);
+   qmult = gether_get_qmult(opts-net);
+   mutex_unlock(opts-lock);
+   return sprintf(page, %d, qmult);
+}
+
+static ssize_t ncm_opts_qmult_store(struct f_ncm_opts *opts,
+   const char *page, size_t len)
+{
+   u8 val;
+   int ret;
+
+   mutex_lock(opts-lock);
+   if (opts-refcnt) {
+   ret = -EBUSY;
+   goto out;
+   }
+
+   ret = kstrtou8(page, 0, val);
+   if (ret)
+   goto out;
+
+   gether_set_qmult(opts-net, val);
+   ret = len;
+out:
+   mutex_unlock(opts-lock);
+   return ret;
+}
+
+static struct f_ncm_opts_attribute f_ncm_opts_qmult =
+   __CONFIGFS_ATTR(qmult, S_IRUGO | S_IWUSR, ncm_opts_qmult_show,
+   ncm_opts_qmult_store);
+
+static ssize_t ncm_opts_ifname_show(struct f_ncm_opts *opts, char *page)
+{
+   int ret;
+
+   mutex_lock(opts-lock);
+   ret = gether_get_ifname(opts-net, page, PAGE_SIZE);
+   mutex_unlock(opts-lock);
+
+   return ret;
+}
+
+static struct f_ncm_opts_attribute f_ncm_opts_ifname =
+   __CONFIGFS_ATTR_RO(ifname, ncm_opts_ifname_show);
+
+static struct configfs_attribute *ncm_attrs[] = {
+   f_ncm_opts_dev_addr.attr,
+   f_ncm_opts_host_addr.attr,
+   f_ncm_opts_qmult.attr,
+   f_ncm_opts_ifname.attr,
+   NULL,
+};
+
+static struct config_item_type ncm_func_type = {
+   .ct_item_ops= ncm_item_ops,
+   .ct_attrs   = 

[PATCH 6/9] usb/gadget: ncm: convert to new function interface

2013-04-11 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/usb/gadget/Kconfig |1 +
 drivers/usb/gadget/ncm.c   |   57 +++-
 2 files changed, 36 insertions(+), 22 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 276b1ba..1571f27 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -686,6 +686,7 @@ config USB_G_NCM
depends on NET
select USB_LIBCOMPOSITE
select USB_U_ETHER
+   select USB_F_NCM
select CRC32
help
  This driver implements USB CDC NCM subclass standard. NCM is
diff --git a/drivers/usb/gadget/ncm.c b/drivers/usb/gadget/ncm.c
index 539a06e..236bdae 100644
--- a/drivers/usb/gadget/ncm.c
+++ b/drivers/usb/gadget/ncm.c
@@ -24,23 +24,12 @@
 #include linux/usb/composite.h
 
 #include u_ether.h
+#include u_ncm.h
 
 #define DRIVER_DESCNCM Gadget
 
 /*-*/
 
-/*
- * Kbuild is not very cooperative with respect to linking separately
- * compiled library objects into one module.  So for now we won't use
- * separate compilation ... ensuring init/exit sections work to shrink
- * the runtime footprint, and giving us at least some parts of what
- * a gcc --combine ... part1.c part2.c part3.c ...  build would.
- */
-#define USB_FNCM_INCLUDED
-#include f_ncm.c
-
-/*-*/
-
 /* DO NOT REUSE THESE IDs with a protocol-incompatible driver!!  Ever!!
  * Instead:  allocate your own, using normal USB-IF procedures.
  */
@@ -125,13 +114,15 @@ static struct usb_gadget_strings *dev_strings[] = {
NULL,
 };
 
-struct eth_dev *the_dev;
-static u8 hostaddr[ETH_ALEN];
+static struct usb_function_instance *f_ncm_inst;
+static struct usb_function *f_ncm;
 
 /*-*/
 
 static int __init ncm_do_config(struct usb_configuration *c)
 {
+   int status;
+
/* FIXME alloc iConfiguration string, set it in c-strings */
 
if (gadget_is_otg(c-cdev-gadget)) {
@@ -139,7 +130,19 @@ static int __init ncm_do_config(struct usb_configuration 
*c)
c-bmAttributes |= USB_CONFIG_ATT_WAKEUP;
}
 
-   return ncm_bind_config(c, hostaddr, the_dev);
+   f_ncm = usb_get_function(f_ncm_inst);
+   if (IS_ERR(f_ncm)) {
+   status = PTR_ERR(f_ncm);
+   return status;
+   }
+
+   status = usb_add_function(c, f_ncm);
+   if (status  0) {
+   usb_put_function(f_ncm);
+   return status;
+   }
+
+   return 0;
 }
 
 static struct usb_configuration ncm_config_driver = {
@@ -155,13 +158,20 @@ static struct usb_configuration ncm_config_driver = {
 static int __init gncm_bind(struct usb_composite_dev *cdev)
 {
struct usb_gadget   *gadget = cdev-gadget;
+   struct f_ncm_opts   *ncm_opts;
int status;
 
-   /* set up network link layer */
-   the_dev = gether_setup(cdev-gadget, dev_addr, host_addr, hostaddr,
-  qmult);
-   if (IS_ERR(the_dev))
-   return PTR_ERR(the_dev);
+   f_ncm_inst = usb_get_function_instance(ncm);
+   if (IS_ERR(f_ncm_inst))
+   return PTR_ERR(f_ncm_inst);
+
+   ncm_opts = container_of(f_ncm_inst, struct f_ncm_opts, func_inst);
+   status = gether_set_dev_addr(ncm_opts-net, dev_addr);
+   if (status  0)
+   goto fail;
+
+   gether_set_host_addr(ncm_opts-net, host_addr, ncm_opts-ethaddr);
+   gether_set_qmult(ncm_opts-net, qmult);
 
/* Allocate string descriptor numbers ... note that string
 * contents can be overridden by the composite_dev glue.
@@ -184,13 +194,16 @@ static int __init gncm_bind(struct usb_composite_dev 
*cdev)
return 0;
 
 fail:
-   gether_cleanup(the_dev);
+   usb_put_function_instance(f_ncm_inst);
return status;
 }
 
 static int __exit gncm_unbind(struct usb_composite_dev *cdev)
 {
-   gether_cleanup(the_dev);
+   if (!IS_ERR_OR_NULL(f_ncm))
+   usb_put_function(f_ncm);
+   if (!IS_ERR_OR_NULL(f_ncm_inst))
+   usb_put_function_instance(f_ncm_inst);
return 0;
 }
 
-- 
1.7.0.4

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


[PATCH 5/9] usb/gadget: f_ncm: convert to new function interface with backward compatibility

2013-04-11 Thread Andrzej Pietrasiewicz
Converting ncm to the new function interface requires converting
the USB ncm's function code and its users.
This patch converts the f_ncm.c to the new function interface.
The file is now compiled into a separate usb_f_ncm.ko module.
The old function interface is provided by means of a preprocessor
conditional directives. After all users are converted, the old interface
can be removed.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/usb/gadget/Kconfig  |3 +
 drivers/usb/gadget/Makefile |2 +
 drivers/usb/gadget/f_ncm.c  |  176 ++-
 drivers/usb/gadget/ncm.c|1 +
 drivers/usb/gadget/u_ncm.h  |   27 +++
 5 files changed, 174 insertions(+), 35 deletions(-)
 create mode 100644 drivers/usb/gadget/u_ncm.h

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 84167fa..276b1ba 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -518,6 +518,9 @@ config USB_F_SERIAL
 config USB_F_OBEX
tristate
 
+config USB_F_NCM
+   tristate
+
 choice
tristate USB Gadget Drivers
default USB_ETH
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index 6882033..be12037 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -48,6 +48,8 @@ obj-$(CONFIG_USB_F_OBEX)  += usb_f_obex.o
 obj-$(CONFIG_USB_U_ETHER)  += u_ether.o
 u_rndis-y  := rndis.o
 obj-$(CONFIG_USB_U_RNDIS)  += u_rndis.o
+usb_f_ncm-y:= f_ncm.o
+obj-$(CONFIG_USB_F_NCM)+= usb_f_ncm.o
 
 #
 # USB gadget drivers
diff --git a/drivers/usb/gadget/f_ncm.c b/drivers/usb/gadget/f_ncm.c
index ee19bc8..280b18b 100644
--- a/drivers/usb/gadget/f_ncm.c
+++ b/drivers/usb/gadget/f_ncm.c
@@ -16,6 +16,7 @@
  */
 
 #include linux/kernel.h
+#include linux/module.h
 #include linux/device.h
 #include linux/etherdevice.h
 #include linux/crc32.h
@@ -23,6 +24,7 @@
 #include linux/usb/cdc.h
 
 #include u_ether.h
+#include u_ncm.h
 
 /*
  * This function is a CDC Network Control Model (CDC NCM) Ethernet link.
@@ -125,7 +127,7 @@ static struct usb_cdc_ncm_ntb_parameters ntb_parameters = {
 #define NCM_STATUS_INTERVAL_MS 32
 #define NCM_STATUS_BYTECOUNT   16  /* 8 byte header + data */
 
-static struct usb_interface_assoc_descriptor ncm_iad_desc __initdata = {
+static struct usb_interface_assoc_descriptor ncm_iad_desc = {
.bLength =  sizeof ncm_iad_desc,
.bDescriptorType =  USB_DT_INTERFACE_ASSOCIATION,
 
@@ -139,7 +141,7 @@ static struct usb_interface_assoc_descriptor ncm_iad_desc 
__initdata = {
 
 /* interface descriptor: */
 
-static struct usb_interface_descriptor ncm_control_intf __initdata = {
+static struct usb_interface_descriptor ncm_control_intf = {
.bLength =  sizeof ncm_control_intf,
.bDescriptorType =  USB_DT_INTERFACE,
 
@@ -151,7 +153,7 @@ static struct usb_interface_descriptor ncm_control_intf 
__initdata = {
/* .iInterface = DYNAMIC */
 };
 
-static struct usb_cdc_header_desc ncm_header_desc __initdata = {
+static struct usb_cdc_header_desc ncm_header_desc = {
.bLength =  sizeof ncm_header_desc,
.bDescriptorType =  USB_DT_CS_INTERFACE,
.bDescriptorSubType =   USB_CDC_HEADER_TYPE,
@@ -159,7 +161,7 @@ static struct usb_cdc_header_desc ncm_header_desc 
__initdata = {
.bcdCDC =   cpu_to_le16(0x0110),
 };
 
-static struct usb_cdc_union_desc ncm_union_desc __initdata = {
+static struct usb_cdc_union_desc ncm_union_desc = {
.bLength =  sizeof(ncm_union_desc),
.bDescriptorType =  USB_DT_CS_INTERFACE,
.bDescriptorSubType =   USB_CDC_UNION_TYPE,
@@ -167,7 +169,7 @@ static struct usb_cdc_union_desc ncm_union_desc __initdata 
= {
/* .bSlaveInterface0 =  DYNAMIC */
 };
 
-static struct usb_cdc_ether_desc ecm_desc __initdata = {
+static struct usb_cdc_ether_desc ecm_desc = {
.bLength =  sizeof ecm_desc,
.bDescriptorType =  USB_DT_CS_INTERFACE,
.bDescriptorSubType =   USB_CDC_ETHERNET_TYPE,
@@ -182,7 +184,7 @@ static struct usb_cdc_ether_desc ecm_desc __initdata = {
 
 #define NCAPS  (USB_CDC_NCM_NCAP_ETH_FILTER | USB_CDC_NCM_NCAP_CRC_MODE)
 
-static struct usb_cdc_ncm_desc ncm_desc __initdata = {
+static struct usb_cdc_ncm_desc ncm_desc = {
.bLength =  sizeof ncm_desc,
.bDescriptorType =  USB_DT_CS_INTERFACE,
.bDescriptorSubType =   USB_CDC_NCM_TYPE,
@@ -194,7 +196,7 @@ static struct usb_cdc_ncm_desc ncm_desc __initdata = {
 
 /* the default data interface has no endpoints ... */
 
-static struct usb_interface_descriptor ncm_data_nop_intf __initdata = {
+static struct usb_interface_descriptor ncm_data_nop_intf = {
.bLength =  sizeof ncm_data_nop_intf,
.bDescriptorType =  

Re: [PATCH] USB: ehci-omap: Select USB_PHY

2013-04-11 Thread Roger Quadros
On 04/11/2013 01:55 PM, Felipe Balbi wrote:
 Hi,
 
 On Thu, Apr 11, 2013 at 01:51:16PM +0300, Roger Quadros wrote:
 On 04/11/2013 01:04 PM, Felipe Balbi wrote:
 Hi,

 On Thu, Apr 11, 2013 at 12:42:04PM +0300, Roger Quadros wrote:
 Hi Greg,

 The following patch gets rid of Kbuild warnings when USB_EHCI_HCD_OMAP
 is enabled.

 Patch is based on your usb-next branch and is needed for 3.10.

 From: Roger Quadros rog...@ti.com
 Date: Thu, 11 Apr 2013 12:08:19 +0300
 Subject: [PATCH] USB: ehci-omap: Select USB_PHY

 As we need NOP_USB_XCEIV which depends on USB_PHY
 we need to select USB_PHY as well.

 Gets rid of the below warnings when USB_EHCI_HCD_OMAP
 is enabled.

 warning: (USB_EHCI_HCD_OMAP) selects NOP_USB_XCEIV which has unmet direct 
 dependencies (USB_SUPPORT  USB_PHY)
 warning: (USB_EHCI_HCD_OMAP) selects NOP_USB_XCEIV which has unmet direct 
 dependencies (USB_SUPPORT  USB_PHY)

 Signed-off-by: Roger Quadros rog...@ti.com

 Ideally, however, we wouldn't select any PHY in particular as different
 boards might need a different PHY driver, even on OMAP ;-)

 Right, but we need to select USB_PHY here as the driver uses
 the USB_PHY APIs.

 The NOP_USB_XCEIV selection could be done by the board config.
 
 I would avoid 'select' completely and just update omap2plus_defconfig
 adding those two as modules.
 

OK, makes sense. I will update the patch to remove select NOP_USB_XCEIV.

cheers,
-roger

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


Re: [PATCH 1/2 v5] usbnet: allow status interrupt URB to always be active

2013-04-11 Thread Ming Lei
On Thu, Apr 11, 2013 at 8:28 PM, Oliver Neukum oli...@neukum.org wrote:
 On Thursday 11 April 2013 20:11:13 Ming Lei wrote:
 On Thu, Apr 11, 2013 at 7:14 PM, Oliver Neukum oli...@neukum.org wrote:
 
  Sorry, I misunderstood.

 No problem, :-)

 
  Task A  Task B  
  queue
 
  queue work
  request a reset
 
   allocate memory and block
  cancel the work
 
   shit happened

 If I understand the case correctly, the above deadlock can be avoided
 by canceling rx/tx URBs at the end of pre_reset() or usbnet_disconnect(),

 No. cancel_work_sync() must wait for the work. The work will not finish.

The work will complete when memory is reclaimed, and the rx/tx path is
still working, so memory reclaim can continue and the deadlock may not
be caused, may it?


Thanks,
-- 
Ming Lei
--
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: ehci-omap: Select USB_PHY

2013-04-11 Thread Alexander Holler
Am 11.04.2013 14:42, schrieb Roger Quadros:
 On 04/11/2013 01:55 PM, Felipe Balbi wrote:

 I would avoid 'select' completely and just update omap2plus_defconfig
 adding those two as modules.

 
 OK, makes sense. I will update the patch to remove select NOP_USB_XCEIV.

Sorry, but this just will end up with many users having broken configs
because of disabled stuff they don't know why they have to enable them.
And thus with a never ending stream of questions and thus with a needed
FAQ entry.

Regards,

Alexander

--
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-serial: add support for USB Wishbone-serial adapters

2013-04-11 Thread Wesley W. Terpstra
Wishbone is an open hardware SoC bus commonly used in FPGA
designs. Bus access can be serialized using the Etherbone
protocol http://www.ohwr.org/projects/etherbone-core.

This driver is intended to be used with devices which attach
their internal Wishbone bus to a USB serial interface using
the Etherbone protocol. A userspace library is required to
speak the protocol made available by this driver as ttyUSBx.

Signed-off-by: Wesley W. Terpstra w.terps...@gsi.de
---
 drivers/usb/serial/Kconfig   |   17 ++
 drivers/usb/serial/Makefile  |1 +
 drivers/usb/serial/wishbone-serial.c |   95 ++
 3 files changed, 113 insertions(+)
 create mode 100644 drivers/usb/serial/wishbone-serial.c

diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
index 17b7f9a..504f26e 100644
--- a/drivers/usb/serial/Kconfig
+++ b/drivers/usb/serial/Kconfig
@@ -667,6 +667,23 @@ config USB_SERIAL_ZIO
  To compile this driver as a module, choose M here: the
  module will be called zio.
 
+config USB_SERIAL_WISHBONE
+   tristate USB-Wishbone adapter interface driver
+   help
+ Say Y here if you want to use a USB attached Wishbone bus.
+
+ Wishbone is an open hardware SoC bus commonly used in FPGA
+ designs. Bus access can be serialized using the Etherbone
+ protocol http://www.ohwr.org/projects/etherbone-core.
+
+ This driver is intended to be used with devices which attach
+ their internal Wishbone bus to a USB serial interface using
+ the Etherbone protocol. A userspace library is required to
+ speak the protocol made available by this driver as ttyUSBx.
+
+ To compile this driver as a module, choose M here: the
+ module will be called wishbone-serial.
+
 config USB_SERIAL_ZTE
tristate ZTE USB serial driver
help
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile
index eaf5ca1..cec63fa 100644
--- a/drivers/usb/serial/Makefile
+++ b/drivers/usb/serial/Makefile
@@ -58,6 +58,7 @@ obj-$(CONFIG_USB_SERIAL_SYMBOL)   += 
symbolserial.o
 obj-$(CONFIG_USB_SERIAL_WWAN)  += usb_wwan.o
 obj-$(CONFIG_USB_SERIAL_TI)+= ti_usb_3410_5052.o
 obj-$(CONFIG_USB_SERIAL_VISOR) += visor.o
+obj-$(CONFIG_USB_SERIAL_WISHBONE)  += wishbone-serial.o
 obj-$(CONFIG_USB_SERIAL_WHITEHEAT) += whiteheat.o
 obj-$(CONFIG_USB_SERIAL_XIRCOM)+= keyspan_pda.o
 obj-$(CONFIG_USB_SERIAL_VIVOPAY_SERIAL)+= vivopay-serial.o
diff --git a/drivers/usb/serial/wishbone-serial.c 
b/drivers/usb/serial/wishbone-serial.c
new file mode 100644
index 000..481ec66
--- /dev/null
+++ b/drivers/usb/serial/wishbone-serial.c
@@ -0,0 +1,95 @@
+/*
+ * USB Wishbone-Serial adapter driver
+ *
+ * Copyright (C) 2013 Wesley W. Terpstra w.terps...@gsi.de
+ * Copyright (C) 2013 GSI Helmholtz Centre for Heavy Ion Research GmbH
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ */
+
+#include linux/kernel.h
+#include linux/init.h
+#include linux/tty.h
+#include linux/module.h
+#include linux/usb.h
+#include linux/usb/serial.h
+#include linux/uaccess.h
+
+#define GSI_VENDOR_OPENCLOSE 0xB0
+
+static const struct usb_device_id id_table[] = {
+   { USB_DEVICE_AND_INTERFACE_INFO(0x1D50, 0x6062, 0xFF, 0xFF, 0xFF) },
+   { },
+};
+MODULE_DEVICE_TABLE(usb, id_table);
+
+/*
+ * Etherbone must be told that a new stream has begun before data arrives.
+ * This is necessary to restart the negotiation of Wishbone bus parameters.
+ * Similarly, when the stream ends, Etherbone must be told so that the cycle
+ * line can be driven low in the case that userspace failed to do so.
+ */
+static int usb_gsi_openclose(struct usb_serial_port *port, int value)
+{
+   struct usb_device *dev = port-serial-dev;
+
+   return usb_control_msg(
+   dev,
+   usb_sndctrlpipe(dev, 0), /* Send to EP0OUT */
+   GSI_VENDOR_OPENCLOSE,
+   USB_DIR_OUT|USB_TYPE_VENDOR|USB_RECIP_INTERFACE,
+   value, /* wValue = device is open(1) or closed(0) */
+   port-serial-interface-cur_altsetting-desc.bInterfaceNumber,
+   0, 0,  /* There is no data stage */
+   5000); /* Timeout till operation fails */
+}
+
+static int wishbone_serial_open(struct tty_struct *tty,
+   struct usb_serial_port *port)
+{
+   int retval;
+
+   retval = usb_gsi_openclose(port, 1);
+   if (retval) {
+   dev_err(port-serial-dev-dev,
+  Could not mark device as open (%d)\n,
+  retval);
+   return retval;
+   }
+
+   

Re: [PATCH] USB: ehci-omap: Select USB_PHY

2013-04-11 Thread Roger Quadros
On 04/11/2013 03:42 PM, Roger Quadros wrote:
 On 04/11/2013 01:55 PM, Felipe Balbi wrote:
 Hi,

 On Thu, Apr 11, 2013 at 01:51:16PM +0300, Roger Quadros wrote:
 On 04/11/2013 01:04 PM, Felipe Balbi wrote:
 Hi,

 On Thu, Apr 11, 2013 at 12:42:04PM +0300, Roger Quadros wrote:
 Hi Greg,

 The following patch gets rid of Kbuild warnings when USB_EHCI_HCD_OMAP
 is enabled.

 Patch is based on your usb-next branch and is needed for 3.10.

 From: Roger Quadros rog...@ti.com
 Date: Thu, 11 Apr 2013 12:08:19 +0300
 Subject: [PATCH] USB: ehci-omap: Select USB_PHY

 As we need NOP_USB_XCEIV which depends on USB_PHY
 we need to select USB_PHY as well.

 Gets rid of the below warnings when USB_EHCI_HCD_OMAP
 is enabled.

 warning: (USB_EHCI_HCD_OMAP) selects NOP_USB_XCEIV which has unmet direct 
 dependencies (USB_SUPPORT  USB_PHY)
 warning: (USB_EHCI_HCD_OMAP) selects NOP_USB_XCEIV which has unmet direct 
 dependencies (USB_SUPPORT  USB_PHY)

 Signed-off-by: Roger Quadros rog...@ti.com

 Ideally, however, we wouldn't select any PHY in particular as different
 boards might need a different PHY driver, even on OMAP ;-)

 Right, but we need to select USB_PHY here as the driver uses
 the USB_PHY APIs.

 The NOP_USB_XCEIV selection could be done by the board config.

 I would avoid 'select' completely and just update omap2plus_defconfig
 adding those two as modules.

 
 OK, makes sense. I will update the patch to remove select NOP_USB_XCEIV.
 

One more issue to clarify.

if USB_PHY is not enabled, then all phy_get() API's should return NULL and not
-ENXIO as it does now.

This way the drivers need not treat it as an error and all PHY ops can be NOPs.

This will make it behave like other frameworks. e.g. clk.

cheers,
-roger.


--
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: [Libusbx-devel] libusbx v1.0.15-rc2 is now available for testing

2013-04-11 Thread nico

Hi,
is there is any windows Vista32 restriction?

++
Nicolas
Le 11/04/13 09:53, nico a écrit :

thanx!
++
nicolas
Le 10/04/13 02:44, Pete Batard a écrit :

On 2013.04.09 11:39, nico wrote:

can someone provide a MinGW 32bits built of the last working RC,

Sure. Please have a look at the -win download from:
https://sourceforge.net/projects/libusbx/files/releases/1.0.15/binaries/

The Windows binary contains the 32 and 64 bit versions of both the
static library and DLL, for MSVC and MinGW.

In related news, the MSCV DLLs now include the .pdb, as was recently
requested.

Regards,

/Pete



-- 


Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for 
building

apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis  visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
___
libusbx-devel mailing list
libusbx-de...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel





--
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 09/26] goku_udc: Don't use create_proc_read_entry() [RFC]

2013-04-11 Thread David Howells
Don't use create_proc_read_entry() as that is deprecated, but rather use
proc_create_data() and seq_file instead.

Signed-off-by: David Howells dhowe...@redhat.com
cc: Felipe Balbi ba...@ti.com
cc: Greg Kroah-Hartman gre...@linuxfoundation.org
cc: linux-usb@vger.kernel.org
---

 drivers/usb/gadget/goku_udc.c |   89 ++---
 1 file changed, 39 insertions(+), 50 deletions(-)

diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c
index 85742d4..57a5470 100644
--- a/drivers/usb/gadget/goku_udc.c
+++ b/drivers/usb/gadget/goku_udc.c
@@ -35,6 +35,7 @@
 #include linux/list.h
 #include linux/interrupt.h
 #include linux/proc_fs.h
+#include linux/seq_file.h
 #include linux/device.h
 #include linux/usb/ch9.h
 #include linux/usb/gadget.h
@@ -1008,7 +1009,7 @@ static const struct usb_gadget_ops goku_ops = {
 
 /*-*/
 
-static inline char *dmastr(void)
+static inline const char *dmastr(void)
 {
if (use_dma == 0)
return (dma disabled);
@@ -1025,13 +1026,10 @@ static const char proc_node_name [] = driver/udc;
 #define FOURBITS %s%s%s%s
 #define EIGHTBITS FOURBITS FOURBITS
 
-static void
-dump_intmask(const char *label, u32 mask, char **next, unsigned *size)
+static void dump_intmask(struct seq_file *m, const char *label, u32 mask)
 {
-   int t;
-
/* int_status is the same format ... */
-   t = scnprintf(*next, *size,
+   seq_printf(m,
%s %05X = FOURBITS EIGHTBITS EIGHTBITS \n,
label, mask,
(mask  INT_PWRDETECT) ?  power : ,
@@ -1058,33 +1056,23 @@ dump_intmask(const char *label, u32 mask, char **next, 
unsigned *size)
(mask  INT_ENDPOINT0) ?  ep0 : ,
(mask  INT_USBRESET) ?  reset : ,
(mask  INT_SUSPEND) ?  suspend : );
-   *size -= t;
-   *next += t;
 }
 
 
-static int
-udc_proc_read(char *buffer, char **start, off_t off, int count,
-   int *eof, void *_dev)
+static int udc_proc_read(struct seq_file *m, void *v)
 {
-   char*buf = buffer;
-   struct goku_udc *dev = _dev;
+   struct goku_udc *dev = m-private;
struct goku_udc_regs __iomem*regs = dev-regs;
-   char*next = buf;
-   unsignedsize = count;
unsigned long   flags;
-   int i, t, is_usb_connected;
+   int i, is_usb_connected;
u32 tmp;
 
-   if (off != 0)
-   return 0;
-
local_irq_save(flags);
 
/* basic device status */
tmp = readl(regs-power_detect);
is_usb_connected = tmp  PW_DETECT;
-   t = scnprintf(next, size,
+   seq_printf(m,
%s - %s\n
%s version: %s %s\n
Gadget driver: %s\n
@@ -1096,7 +1084,7 @@ udc_proc_read(char *buffer, char **start, off_t off, int 
count,
is_usb_connected
? ((tmp  PW_PULLUP) ? full speed : powered)
: disconnected,
-   ({char *state;
+   ({const char *state;
switch(dev-ep0state){
case EP0_DISCONNECT:state = ep0_disconnect; break;
case EP0_IDLE:  state = ep0_idle; break;
@@ -1108,27 +1096,24 @@ udc_proc_read(char *buffer, char **start, off_t off, 
int count,
default:state = ep0_?; break;
} state; })
);
-   size -= t;
-   next += t;
 
-   dump_intmask(int_status, readl(regs-int_status), next, size);
-   dump_intmask(int_enable, readl(regs-int_enable), next, size);
+   dump_intmask(m, int_status, readl(regs-int_status));
+   dump_intmask(m, int_enable, readl(regs-int_enable));
 
if (!is_usb_connected || !dev-driver || (tmp  PW_PULLUP) == 0)
goto done;
 
/* registers for (active) device and ep0 */
-   t = scnprintf(next, size, \nirqs %lu\ndataset %02x 
+   if (seq_printf(m, \nirqs %lu\ndataset %02x 
single.bcs %02x.%02x state %x addr %u\n,
dev-irqs, readl(regs-DataSet),
readl(regs-EPxSingle), readl(regs-EPxBCS),
readl(regs-UsbState),
-   readl(regs-address));
-   size -= t;
-   next += t;
+   readl(regs-address))  0)
+   goto done;
 
tmp = readl(regs-dma_master);
-   t = scnprintf(next, size,
+   if (seq_printf(m,
dma %03X = EIGHTBITS %s %s\n, tmp,
(tmp  MST_EOPB_DIS) ?  eopb- : ,
(tmp  MST_EOPB_ENA) ?  eopb+ : ,
@@ -1143,9 +1128,8 @@ udc_proc_read(char *buffer, char **start, off_t off, int 
count,
 

[PATCH 10/26] fsl_udc: Don't use create_proc_read_entry() [RFC]

2013-04-11 Thread David Howells
Don't use create_proc_read_entry() as that is deprecated, but rather use
proc_create_data() and seq_file instead.

Signed-off-by: David Howells dhowe...@redhat.com
cc: Li Yang le...@freescale.com
cc: Felipe Balbi ba...@ti.com
cc: Greg Kroah-Hartman gre...@linuxfoundation.org
cc: linux-usb@vger.kernel.org
cc: linuxppc-...@lists.ozlabs.org
---

 drivers/usb/gadget/fsl_udc_core.c |  124 +
 1 file changed, 43 insertions(+), 81 deletions(-)

diff --git a/drivers/usb/gadget/fsl_udc_core.c 
b/drivers/usb/gadget/fsl_udc_core.c
index 04d5fef..ede70ff 100644
--- a/drivers/usb/gadget/fsl_udc_core.c
+++ b/drivers/usb/gadget/fsl_udc_core.c
@@ -2038,47 +2038,37 @@ static int fsl_udc_stop(struct usb_gadget *g,
 
 static const char proc_filename[] = driver/fsl_usb2_udc;
 
-static int fsl_proc_read(char *page, char **start, off_t off, int count,
-   int *eof, void *_dev)
+static int fsl_proc_read(struct seq_file *m, void *v)
 {
-   char *buf = page;
-   char *next = buf;
-   unsigned size = count;
unsigned long flags;
-   int t, i;
+   int i;
u32 tmp_reg;
struct fsl_ep *ep = NULL;
struct fsl_req *req;
 
struct fsl_udc *udc = udc_controller;
-   if (off != 0)
-   return 0;
 
spin_lock_irqsave(udc-lock, flags);
 
/* --basic driver information  */
-   t = scnprintf(next, size,
+   seq_printf(m,
DRIVER_DESC \n
%s version: %s\n
Gadget driver: %s\n\n,
driver_name, DRIVER_VERSION,
udc-driver ? udc-driver-driver.name : (none));
-   size -= t;
-   next += t;
 
/* -- DR Registers - */
tmp_reg = fsl_readl(dr_regs-usbcmd);
-   t = scnprintf(next, size,
+   seq_printf(m,
USBCMD reg:\n
SetupTW: %d\n
Run/Stop: %s\n\n,
(tmp_reg  USB_CMD_SUTW) ? 1 : 0,
(tmp_reg  USB_CMD_RUN_STOP) ? Run : Stop);
-   size -= t;
-   next += t;
 
tmp_reg = fsl_readl(dr_regs-usbsts);
-   t = scnprintf(next, size,
+   seq_printf(m,
USB Status Reg:\n
Dr Suspend: %d Reset Received: %d System Error: %s 
USB Error Interrupt: %s\n\n,
@@ -2086,11 +2076,9 @@ static int fsl_proc_read(char *page, char **start, off_t 
off, int count,
(tmp_reg  USB_STS_RESET) ? 1 : 0,
(tmp_reg  USB_STS_SYS_ERR) ? Err : Normal,
(tmp_reg  USB_STS_ERR) ? Err detected : No err);
-   size -= t;
-   next += t;
 
tmp_reg = fsl_readl(dr_regs-usbintr);
-   t = scnprintf(next, size,
+   seq_printf(m,
USB Interrupt Enable Reg:\n
Sleep Enable: %d SOF Received Enable: %d 
Reset Enable: %d\n
@@ -2104,33 +2092,25 @@ static int fsl_proc_read(char *page, char **start, 
off_t off, int count,
(tmp_reg  USB_INTR_PTC_DETECT_EN) ? 1 : 0,
(tmp_reg  USB_INTR_ERR_INT_EN) ? 1 : 0,
(tmp_reg  USB_INTR_INT_EN) ? 1 : 0);
-   size -= t;
-   next += t;
 
tmp_reg = fsl_readl(dr_regs-frindex);
-   t = scnprintf(next, size,
+   seq_printf(m,
USB Frame Index Reg: Frame Number is 0x%x\n\n,
(tmp_reg  USB_FRINDEX_MASKS));
-   size -= t;
-   next += t;
 
tmp_reg = fsl_readl(dr_regs-deviceaddr);
-   t = scnprintf(next, size,
+   seq_printf(m,
USB Device Address Reg: Device Addr is 0x%x\n\n,
(tmp_reg  USB_DEVICE_ADDRESS_MASK));
-   size -= t;
-   next += t;
 
tmp_reg = fsl_readl(dr_regs-endpointlistaddr);
-   t = scnprintf(next, size,
+   seq_printf(m,
USB Endpoint List Address Reg: 
Device Addr is 0x%x\n\n,
(tmp_reg  USB_EP_LIST_ADDRESS_MASK));
-   size -= t;
-   next += t;
 
tmp_reg = fsl_readl(dr_regs-portsc1);
-   t = scnprintf(next, size,
+   seq_printf(m,
USB Port StatusControl Reg:\n
Port Transceiver Type : %s Port Speed: %s\n
PHY Low Power Suspend: %s Port Reset: %s 
@@ -2139,7 +2119,7 @@ static int fsl_proc_read(char *page, char **start, off_t 
off, int count,
Port Enable/Disable Change: %s\n
Port Enabled/Disabled: %s 
Current Connect Status: %s\n\n, ( {
-   char *s;
+   const char *s;
switch (tmp_reg  PORTSCX_PTS_FSLS) {
case PORTSCX_PTS_UTMI:
s = UTMI; break;
@@ -2165,13 +2145,11 @@ static 

Re: [PATCH] usb-serial: add support for USB Wishbone-serial adapters

2013-04-11 Thread Greg KH
On Thu, Apr 11, 2013 at 03:08:20PM +0200, Wesley W. Terpstra wrote:
 Wishbone is an open hardware SoC bus commonly used in FPGA
 designs. Bus access can be serialized using the Etherbone
 protocol http://www.ohwr.org/projects/etherbone-core.
 
 This driver is intended to be used with devices which attach
 their internal Wishbone bus to a USB serial interface using
 the Etherbone protocol. A userspace library is required to
 speak the protocol made available by this driver as ttyUSBx.
 
 Signed-off-by: Wesley W. Terpstra w.terps...@gsi.de

This looks great, thanks.

I only have one very minor question about the code:

 +++ b/drivers/usb/serial/wishbone-serial.c
 @@ -0,0 +1,95 @@
 +/*
 + * USB Wishbone-Serial adapter driver
 + *
 + * Copyright (C) 2013 Wesley W. Terpstra w.terps...@gsi.de
 + * Copyright (C) 2013 GSI Helmholtz Centre for Heavy Ion Research GmbH
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * as published by the Free Software Foundation; either version 2
 + * of the License, or (at your option) any later version.
 + */

Do you really mean or any later version for the license of this
driver?  I ask as the kernel itself is GPLv2-only.  It's fine if you
want this to be GPLv2+, I just have to ask.

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-serial: add support for USB Wishbone-serial adapters

2013-04-11 Thread Wesley W. Terpstra
On Thu, 2013-04-11 at 06:45 -0700, Greg KH wrote:
 I only have one very minor question about the code:
 
  +++ b/drivers/usb/serial/wishbone-serial.c
  @@ -0,0 +1,95 @@
  +/*
  + * USB Wishbone-Serial adapter driver
  + *
  + * Copyright (C) 2013 Wesley W. Terpstra w.terps...@gsi.de
  + * Copyright (C) 2013 GSI Helmholtz Centre for Heavy Ion Research GmbH
  + *
  + * This program is free software; you can redistribute it and/or
  + * modify it under the terms of the GNU General Public License
  + * as published by the Free Software Foundation; either version 2
  + * of the License, or (at your option) any later version.
  + */
 
 Do you really mean or any later version for the license of this
 driver?  I ask as the kernel itself is GPLv2-only.  It's fine if you
 want this to be GPLv2+, I just have to ask.

Yes, I know the kernel is v2. Which is a shame because the FSF made the
v3 licence which some people would prefer. If in the distant future, the
kernel were to slowly be relicenced as v2+ or v3, I don't want to
contribute to the migration problem.

A question for you in turn: why were usb_serial_[de]register removed?
The new usb_serial_deregister_drivers isn't available in older kernels.
So drivers cannot support (without ifdefs) both old and new kernels


--
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: ehci-omap: Select USB_PHY

2013-04-11 Thread Felipe Balbi
Hi,

On Thu, Apr 11, 2013 at 04:18:33PM +0300, Roger Quadros wrote:
 On 04/11/2013 03:42 PM, Roger Quadros wrote:
  On 04/11/2013 01:55 PM, Felipe Balbi wrote:
  Hi,
 
  On Thu, Apr 11, 2013 at 01:51:16PM +0300, Roger Quadros wrote:
  On 04/11/2013 01:04 PM, Felipe Balbi wrote:
  Hi,
 
  On Thu, Apr 11, 2013 at 12:42:04PM +0300, Roger Quadros wrote:
  Hi Greg,
 
  The following patch gets rid of Kbuild warnings when USB_EHCI_HCD_OMAP
  is enabled.
 
  Patch is based on your usb-next branch and is needed for 3.10.
 
  From: Roger Quadros rog...@ti.com
  Date: Thu, 11 Apr 2013 12:08:19 +0300
  Subject: [PATCH] USB: ehci-omap: Select USB_PHY
 
  As we need NOP_USB_XCEIV which depends on USB_PHY
  we need to select USB_PHY as well.
 
  Gets rid of the below warnings when USB_EHCI_HCD_OMAP
  is enabled.
 
  warning: (USB_EHCI_HCD_OMAP) selects NOP_USB_XCEIV which has unmet 
  direct dependencies (USB_SUPPORT  USB_PHY)
  warning: (USB_EHCI_HCD_OMAP) selects NOP_USB_XCEIV which has unmet 
  direct dependencies (USB_SUPPORT  USB_PHY)
 
  Signed-off-by: Roger Quadros rog...@ti.com
 
  Ideally, however, we wouldn't select any PHY in particular as different
  boards might need a different PHY driver, even on OMAP ;-)
 
  Right, but we need to select USB_PHY here as the driver uses
  the USB_PHY APIs.
 
  The NOP_USB_XCEIV selection could be done by the board config.
 
  I would avoid 'select' completely and just update omap2plus_defconfig
  adding those two as modules.
 
  
  OK, makes sense. I will update the patch to remove select NOP_USB_XCEIV.
  
 
 One more issue to clarify.
 
 if USB_PHY is not enabled, then all phy_get() API's should return NULL and not
 -ENXIO as it does now.

ENXIO means No such device or address, looks alright to me ;-)

 This way the drivers need not treat it as an error and all PHY ops can
 be NOPs.

drivers will already be using if (IS_ERR()) construction, returning
-ENXIO when the API is disabled gives them an oportunity to *not*
request probe deferral since the API isn't enabled anyway.

 This will make it behave like other frameworks. e.g. clk.

if we return NULL we will need IS_ERR_OR_NULL() which will cause
problems with people who aren't careful enough.

-- 
balbi


signature.asc
Description: Digital signature


Re: Linux USB file storage gadget with new UDC

2013-04-11 Thread Alan Stern
On Thu, 11 Apr 2013, victor yeo wrote:

 Thanks for the detailed write-up. I have checked the UDC driver
 set_halt(), it is called by the gadget driver. The full ascii text of
 usbmon trace for one usb session is also attached. This usbmon trace
 shows a few EOVERFLOW(-75) error. I don't know why EOVERFLOW error
 happened.

Because your UDC driver sent a packet that was too big.  Here's the
first example from the trace:

f3a2b6c0 3633034189 S Bo:2:036:1 -115 31 = 55534243 0600  0600 
   00
f3a2b6c0 3633034326 C Bo:2:036:1 0 31 
f3a2b6c0 3633034518 S Bi:2:036:1 -115 13 
f3a2b6c0 3633040328 C Bi:2:036:1 -75 0

The first two lines show the host sending a TEST UNIT READY command.  
The third line shows the host waiting for a 13-byte CSW data packet.  
The -75 error means that the UDC sent back a data packet containing 
more than 13 bytes.

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 01/11] usbnet: introduce usbnet_link_change API

2013-04-11 Thread Ming Lei
This patch introduces the API of usbnet_link_change, so that
usbnet can handle link change centrally, which may help to
implement killing traffic URBs for saving USB bus bandwidth
and host controller power.

Signed-off-by: Ming Lei ming@canonical.com
---
 drivers/net/usb/usbnet.c   |   13 +
 include/linux/usb/usbnet.h |1 +
 2 files changed, 14 insertions(+)

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 51f3192..40e4237 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1653,6 +1653,19 @@ int usbnet_manage_power(struct usbnet *dev, int on)
 }
 EXPORT_SYMBOL(usbnet_manage_power);
 
+void usbnet_link_change(struct usbnet *dev, bool link, bool need_reset)
+{
+   /* update link after link is reseted */
+   if (link  !need_reset)
+   netif_carrier_on(dev-net);
+   else
+   netif_carrier_off(dev-net);
+
+   if (need_reset  link)
+   usbnet_defer_kevent(dev, EVENT_LINK_RESET);
+}
+EXPORT_SYMBOL(usbnet_link_change);
+
 /*-*/
 static int __usbnet_read_cmd(struct usbnet *dev, u8 cmd, u8 reqtype,
 u16 value, u16 index, void *data, u16 size)
diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
index 0e5ac93..eb021b8 100644
--- a/include/linux/usb/usbnet.h
+++ b/include/linux/usb/usbnet.h
@@ -245,5 +245,6 @@ extern void usbnet_get_drvinfo(struct net_device *, struct 
ethtool_drvinfo *);
 extern int usbnet_nway_reset(struct net_device *net);
 
 extern int usbnet_manage_power(struct usbnet *, int);
+extern void usbnet_link_change(struct usbnet *, bool, bool);
 
 #endif /* __LINUX_USB_USBNET_H */
-- 
1.7.9.5

--
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 02/11] usbnet: mcs7830: don't reset link

2013-04-11 Thread Ming Lei
The driver doesn't implement link_reset() callback, so it needn't
to send link reset event.

Signed-off-by: Ming Lei ming@canonical.com
---
 drivers/net/usb/mcs7830.c |5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/usb/mcs7830.c b/drivers/net/usb/mcs7830.c
index 3f3f566..e1c00e9 100644
--- a/drivers/net/usb/mcs7830.c
+++ b/drivers/net/usb/mcs7830.c
@@ -576,10 +576,9 @@ static void mcs7830_status(struct usbnet *dev, struct urb 
*urb)
 */
if (data-link_counter  20) {
data-link_counter = 0;
-   if (link) {
+   if (link)
netif_carrier_on(dev-net);
-   usbnet_defer_kevent(dev, EVENT_LINK_RESET);
-   } else
+   else
netif_carrier_off(dev-net);
netdev_dbg(dev-net, Link Status is: %d\n, link);
}
-- 
1.7.9.5

--
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 03/11] usbnet: mcs7830: apply usbnet_link_change

2013-04-11 Thread Ming Lei
This patch uses the introduced usbnet_link_change() to handle
link change.

Signed-off-by: Ming Lei ming@canonical.com
---
 drivers/net/usb/mcs7830.c |5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/net/usb/mcs7830.c b/drivers/net/usb/mcs7830.c
index e1c00e9..03832d3 100644
--- a/drivers/net/usb/mcs7830.c
+++ b/drivers/net/usb/mcs7830.c
@@ -576,10 +576,7 @@ static void mcs7830_status(struct usbnet *dev, struct urb 
*urb)
 */
if (data-link_counter  20) {
data-link_counter = 0;
-   if (link)
-   netif_carrier_on(dev-net);
-   else
-   netif_carrier_off(dev-net);
+   usbnet_link_change(dev, link, 0);
netdev_dbg(dev-net, Link Status is: %d\n, link);
}
} else
-- 
1.7.9.5

--
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 00/11] usbnet: usbnet: handle link change

2013-04-11 Thread Ming Lei
Hi,

This patch set introduces usbnet_link_change() API and applies
it on all usbnet drivers, then handle the link change centrally
to stop bulk transfer when link becomes off and restart bulk
transfer when link becomes on.

With the change, ~10% performance boost on bulk transfer
of another device on the same bus can be obtained when link
is off. Also, stopping bulk transfer when link becomes off
may disable asynchonous schedule of host controller, power
might be saved probabally.

 drivers/net/usb/asix_devices.c |6 +-
 drivers/net/usb/ax88179_178a.c |   12 ---
 drivers/net/usb/cdc_ether.c|5 +
 drivers/net/usb/cdc_ncm.c  |9 +++-
 drivers/net/usb/dm9601.c   |7 +--
 drivers/net/usb/mcs7830.c  |6 +-
 drivers/net/usb/sierra_net.c   |3 +--
 drivers/net/usb/usbnet.c   |   45 +++-
 include/linux/usb/usbnet.h |2 ++
 9 files changed, 58 insertions(+), 37 deletions(-)


Thanks,
--
Ming Lei


--
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 04/11] usbnet: cdc_ncm: apply usbnet_link_change

2013-04-11 Thread Ming Lei
Use the introduced usbnet_link_change to handle link change.

Signed-off-by: Ming Lei ming@canonical.com
---
 drivers/net/usb/cdc_ncm.c |9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 67012cb..43afde8 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -610,7 +610,7 @@ static int cdc_ncm_bind(struct usbnet *dev, struct 
usb_interface *intf)
 * (carrier is OFF) during attach, so the IP network stack does not
 * start IPv6 negotiation and more.
 */
-   netif_carrier_off(dev-net);
+   usbnet_link_change(dev, 0, 0);
return ret;
 }
 
@@ -1106,12 +1106,9 @@ static void cdc_ncm_status(struct usbnet *dev, struct 
urb *urb)
 %sconnected\n,
ctx-netdev-name, ctx-connected ?  : dis);
 
-   if (ctx-connected)
-   netif_carrier_on(dev-net);
-   else {
-   netif_carrier_off(dev-net);
+   usbnet_link_change(dev, ctx-connected, 0);
+   if (!ctx-connected)
ctx-tx_speed = ctx-rx_speed = 0;
-   }
break;
 
case USB_CDC_NOTIFY_SPEED_CHANGE:
-- 
1.7.9.5

--
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 05/11] usbnet: asix: apply usbnet_link_change

2013-04-11 Thread Ming Lei
Use usbnet_link_change to handle link change centrally.

Signed-off-by: Ming Lei ming@canonical.com
---
 drivers/net/usb/asix_devices.c |6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index 7097534..ad5d1e4 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -55,11 +55,7 @@ static void asix_status(struct usbnet *dev, struct urb *urb)
event = urb-transfer_buffer;
link = event-link  0x01;
if (netif_carrier_ok(dev-net) != link) {
-   if (link) {
-   netif_carrier_on(dev-net);
-   usbnet_defer_kevent (dev, EVENT_LINK_RESET );
-   } else
-   netif_carrier_off(dev-net);
+   usbnet_link_change(dev, link, 1);
netdev_dbg(dev-net, Link Status is: %d\n, link);
}
 }
-- 
1.7.9.5

--
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 06/11] usbnet: ax88179_1781: apply usbnet_link_change

2013-04-11 Thread Ming Lei
Use usbnet_link_change to handle link change centrally.

Signed-off-by: Ming Lei ming@canonical.com
---
 drivers/net/usb/ax88179_178a.c |   12 
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index 71c27d8..bd8758f 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -352,11 +352,7 @@ static void ax88179_status(struct usbnet *dev, struct urb 
*urb)
link = (((__force u32)event-intdata1)  AX_INT_PPLS_LINK)  16;
 
if (netif_carrier_ok(dev-net) != link) {
-   if (link)
-   usbnet_defer_kevent(dev, EVENT_LINK_RESET);
-   else
-   netif_carrier_off(dev-net);
-
+   usbnet_link_change(dev, link, 1);
netdev_info(dev-net, ax88179 - Link status is: %d\n, link);
}
 }
@@ -455,7 +451,7 @@ static int ax88179_resume(struct usb_interface *intf)
u16 tmp16;
u8 tmp8;
 
-   netif_carrier_off(dev-net);
+   usbnet_link_change(dev, 0, 0);
 
/* Power up ethernet PHY */
tmp16 = 0;
@@ -1068,7 +1064,7 @@ static int ax88179_bind(struct usbnet *dev, struct 
usb_interface *intf)
/* Restart autoneg */
mii_nway_restart(dev-mii);
 
-   netif_carrier_off(dev-net);
+   usbnet_link_change(dev, 0, 0);
 
return 0;
 }
@@ -1356,7 +1352,7 @@ static int ax88179_reset(struct usbnet *dev)
/* Restart autoneg */
mii_nway_restart(dev-mii);
 
-   netif_carrier_off(dev-net);
+   usbnet_link_change(dev, 0, 0);
 
return 0;
 }
-- 
1.7.9.5

--
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 07/11] usbnet: cdc-ether: apply usbnet_link_change

2013-04-11 Thread Ming Lei
Use usbnet_link_change to handle link change centrally.

Signed-off-by: Ming Lei ming@canonical.com
---
 drivers/net/usb/cdc_ether.c |5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
index 57136dc..e965806 100644
--- a/drivers/net/usb/cdc_ether.c
+++ b/drivers/net/usb/cdc_ether.c
@@ -406,10 +406,7 @@ void usbnet_cdc_status(struct usbnet *dev, struct urb *urb)
case USB_CDC_NOTIFY_NETWORK_CONNECTION:
netif_dbg(dev, timer, dev-net, CDC: carrier %s\n,
  event-wValue ? on : off);
-   if (event-wValue)
-   netif_carrier_on(dev-net);
-   else
-   netif_carrier_off(dev-net);
+   usbnet_link_change(dev, event-wValue, 0);
break;
case USB_CDC_NOTIFY_SPEED_CHANGE:   /* tx/rx rates */
netif_dbg(dev, timer, dev-net, CDC: speed change (len %d)\n,
-- 
1.7.9.5

--
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 09/11] usbnet: sierra: apply usbnet_link_change

2013-04-11 Thread Ming Lei
Use usbnet_link_change to handle link change centrally.

Signed-off-by: Ming Lei ming@canonical.com
---
 drivers/net/usb/sierra_net.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
index 79ab243..a923d61 100644
--- a/drivers/net/usb/sierra_net.c
+++ b/drivers/net/usb/sierra_net.c
@@ -413,11 +413,10 @@ static void sierra_net_handle_lsi(struct usbnet *dev, 
char *data,
if (link_up) {
sierra_net_set_ctx_index(priv, hh-msgspecific.byte);
priv-link_up = 1;
-   netif_carrier_on(dev-net);
} else {
priv-link_up = 0;
-   netif_carrier_off(dev-net);
}
+   usbnet_link_change(dev, link_up, 0);
 }
 
 static void sierra_net_dosync(struct usbnet *dev)
-- 
1.7.9.5

--
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 10/11] usbnet: apply usbnet_link_change

2013-04-11 Thread Ming Lei
Use usbnet_link_change to handle link change centrally.

Signed-off-by: Ming Lei ming@canonical.com
---
 drivers/net/usb/usbnet.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 40e4237..34e4252 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1521,7 +1521,7 @@ usbnet_probe (struct usb_interface *udev, const struct 
usb_device_id *prod)
netif_device_attach (net);
 
if (dev-driver_info-flags  FLAG_LINK_INTR)
-   netif_carrier_off(net);
+   usbnet_link_change(dev, 0, 0);
 
return 0;
 
-- 
1.7.9.5

--
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 08/11] usbnet: dm9601: apply usbnet_link_change

2013-04-11 Thread Ming Lei
Use usbnet_link_change to handle link change centrally.

Cc: Peter Korsgaard jac...@sunsite.dk
Signed-off-by: Ming Lei ming@canonical.com
---
 drivers/net/usb/dm9601.c |7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/net/usb/dm9601.c b/drivers/net/usb/dm9601.c
index 174e5ec..2dbb946 100644
--- a/drivers/net/usb/dm9601.c
+++ b/drivers/net/usb/dm9601.c
@@ -524,12 +524,7 @@ static void dm9601_status(struct usbnet *dev, struct urb 
*urb)
 
link = !!(buf[0]  0x40);
if (netif_carrier_ok(dev-net) != link) {
-   if (link) {
-   netif_carrier_on(dev-net);
-   usbnet_defer_kevent (dev, EVENT_LINK_RESET);
-   }
-   else
-   netif_carrier_off(dev-net);
+   usbnet_link_change(dev, link, 1);
netdev_dbg(dev-net, Link Status is: %d\n, link);
}
 }
-- 
1.7.9.5

--
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 11/11] usbnet: handle link change

2013-04-11 Thread Ming Lei
The link change is detected via the interrupt pipe, and bulk
pipes are responsible for transfering packets, so it is reasonable
to stop bulk transfer after link is reported as off.

Two adavantages may be obtained with stopping bulk transfer
after link becomes off:

- USB bus bandwidth is saved(USB bus is shared bus except for
USB3.0), for example, lots of 'IN' token packets and 'NYET'
handshake packets is transfered on 2.0 bus.

- probabaly power might be saved for usb host controller since
cancelling bulk transfer may disable the asynchronous schedule of
host controller.

With this patch, when link becomes off, about ~10% performance
boost can be found on bulk transfer of anther usb device which
is attached to same bus with the usbnet device, see below
test on next-20130410:

- read from usb mass storage(Sandisk Extreme USB 3.0) on pandaboard
with below command after unplugging ethernet cable:

dd if=/dev/sda iflag=direct of=/dev/null bs=1M count=500

- without the patch
1, 838860800 bytes (839 MB) copied, 36.2216 s, 23.2 MB/s
2, 838860800 bytes (839 MB) copied, 35.8368 s, 23.4 MB/s
3, 838860800 bytes (839 MB) copied, 35.823 s, 23.4 MB/s
4, 838860800 bytes (839 MB) copied, 35.937 s, 23.3 MB/s
5, 838860800 bytes (839 MB) copied, 35.7365 s, 23.5 MB/s
average: 23.6MB/s

- with the patch
1, 838860800 bytes (839 MB) copied, 32.3817 s, 25.9 MB/s
2, 838860800 bytes (839 MB) copied, 31.7389 s, 26.4 MB/s
3, 838860800 bytes (839 MB) copied, 32.438 s, 25.9 MB/s
4, 838860800 bytes (839 MB) copied, 32.5492 s, 25.8 MB/s
5, 838860800 bytes (839 MB) copied, 31.6178 s, 26.5 MB/s
average: 26.1MB/s

Signed-off-by: Ming Lei ming@canonical.com
---
 drivers/net/usb/usbnet.c   |   30 ++
 include/linux/usb/usbnet.h |1 +
 2 files changed, 31 insertions(+)

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 34e4252..1e5a9b7 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -938,6 +938,27 @@ static const struct ethtool_ops usbnet_ethtool_ops = {
 
 /*-*/
 
+static void __handle_link_change(struct usbnet *dev)
+{
+   if (!test_bit(EVENT_DEV_OPEN, dev-flags))
+   return;
+
+   if (!netif_carrier_ok(dev-net)) {
+   /* kill URBs for reading packets to save bus bandwidth */
+   unlink_urbs(dev, dev-rxq);
+
+   /*
+* tx_timeout will unlink URBs for sending packets and
+* tx queue is stopped by netcore after link becomes off
+*/
+   } else {
+   /* submitting URBs for reading packets */
+   tasklet_schedule(dev-bh);
+   }
+
+   clear_bit(EVENT_LINK_CHANGE, dev-flags);
+}
+
 /* work that cannot be done in interrupt context uses keventd.
  *
  * NOTE:  with 2.5 we could do more of this using completion callbacks,
@@ -1035,8 +1056,14 @@ skip_reset:
} else {
usb_autopm_put_interface(dev-intf);
}
+
+   /* handle link change from link resetting */
+   __handle_link_change(dev);
}
 
+   if (test_bit (EVENT_LINK_CHANGE, dev-flags))
+   __handle_link_change(dev);
+
if (dev-flags)
netdev_dbg(dev-net, kevent done, flags = 0x%lx\n, 
dev-flags);
 }
@@ -1286,6 +1313,7 @@ static void usbnet_bh (unsigned long param)
// or are we maybe short a few urbs?
} else if (netif_running (dev-net) 
   netif_device_present (dev-net) 
+  netif_carrier_ok(dev-net) 
   !timer_pending (dev-delay) 
   !test_bit (EVENT_RX_HALT, dev-flags)) {
int temp = dev-rxq.qlen;
@@ -1663,6 +1691,8 @@ void usbnet_link_change(struct usbnet *dev, bool link, 
bool need_reset)
 
if (need_reset  link)
usbnet_defer_kevent(dev, EVENT_LINK_RESET);
+   else
+   usbnet_defer_kevent(dev, EVENT_LINK_CHANGE);
 }
 EXPORT_SYMBOL(usbnet_link_change);
 
diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
index eb021b8..da46327 100644
--- a/include/linux/usb/usbnet.h
+++ b/include/linux/usb/usbnet.h
@@ -72,6 +72,7 @@ struct usbnet {
 #  define EVENT_DEVICE_REPORT_IDLE 8
 #  define EVENT_NO_RUNTIME_PM  9
 #  define EVENT_RX_KILL10
+#  define EVENT_LINK_CHANGE11
 };
 
 static inline struct usb_driver *driver_of(struct usb_interface *intf)
-- 
1.7.9.5

--
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: ehci-omap: Select USB_PHY

2013-04-11 Thread Roger Quadros
Felipe,

On 04/11/2013 04:02 PM, Alexander Holler wrote:
 Am 11.04.2013 14:42, schrieb Roger Quadros:
 On 04/11/2013 01:55 PM, Felipe Balbi wrote:
 
 I would avoid 'select' completely and just update omap2plus_defconfig
 adding those two as modules.

Setting USB_PHY as a module gives rise to these problems

arch/arm/mach-omap2/built-in.o: In function `usbhs_init_phys':
/work/linux-2.6/arch/arm/mach-omap2/usb-host.c:652: undefined reference to 
`usb_bind_phy'
arch/arm/mach-omap2/built-in.o: In function `omap_2430sdp_init':
/work/linux-2.6/arch/arm/mach-omap2/board-2430sdp.c:236: undefined reference to 
`usb_bind_phy'
arch/arm/mach-omap2/built-in.o: In function `omap3_beagle_init':
/work/linux-2.6/arch/arm/mach-omap2/board-omap3beagle.c:554: undefined 
reference to `usb_bind_phy'
arch/arm/mach-omap2/built-in.o: In function `devkit8000_init':
/work/linux-2.6/arch/arm/mach-omap2/board-devkit8000.c:596: undefined reference 
to `usb_bind_phy'
arch/arm/mach-omap2/built-in.o: In function `omap_ldp_init':
/work/linux-2.6/arch/arm/mach-omap2/board-ldp.c:379: undefined reference to 
`usb_bind_phy'

So USB_PHY shouldn't be tristate IMO or at least the platform registration stuff
as the usb_bind_phy() part is used by platform code.



 OK, makes sense. I will update the patch to remove select NOP_USB_XCEIV.
 
 Sorry, but this just will end up with many users having broken configs
 because of disabled stuff they don't know why they have to enable them.
 And thus with a never ending stream of questions and thus with a needed
 FAQ entry.
 

Alexander,

I agree with you that it can get difficult with users. But it is best for
users do not disable anything they are not familiar with.

As the USB_PHY option doesn't depend on anything, it is safe to select it
from USB_EHCI_HCD_OMAP.

However, the PHY drivers themselves must be selected from the board configs.

cheers,
-roger
--
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 11/11] usbnet: handle link change

2013-04-11 Thread Ming Lei
On Thu, Apr 11, 2013 at 10:40 PM, Ming Lei ming@canonical.com wrote:
 The link change is detected via the interrupt pipe, and bulk
 pipes are responsible for transfering packets, so it is reasonable
 to stop bulk transfer after link is reported as off.

 Two adavantages may be obtained with stopping bulk transfer
 after link becomes off:

 - USB bus bandwidth is saved(USB bus is shared bus except for
 USB3.0), for example, lots of 'IN' token packets and 'NYET'
 handshake packets is transfered on 2.0 bus.

 - probabaly power might be saved for usb host controller since
 cancelling bulk transfer may disable the asynchronous schedule of
 host controller.

 With this patch, when link becomes off, about ~10% performance
 boost can be found on bulk transfer of anther usb device which
 is attached to same bus with the usbnet device, see below
 test on next-20130410:

 - read from usb mass storage(Sandisk Extreme USB 3.0) on pandaboard
 with below command after unplugging ethernet cable:

 dd if=/dev/sda iflag=direct of=/dev/null bs=1M count=500

Sorry, the above should be:

dd if=/dev/sda iflag=direct of=/dev/null bs=1M count=800


 - without the patch
 1, 838860800 bytes (839 MB) copied, 36.2216 s, 23.2 MB/s
 2, 838860800 bytes (839 MB) copied, 35.8368 s, 23.4 MB/s
 3, 838860800 bytes (839 MB) copied, 35.823 s, 23.4 MB/s
 4, 838860800 bytes (839 MB) copied, 35.937 s, 23.3 MB/s
 5, 838860800 bytes (839 MB) copied, 35.7365 s, 23.5 MB/s
 average: 23.6MB/s

 - with the patch
 1, 838860800 bytes (839 MB) copied, 32.3817 s, 25.9 MB/s
 2, 838860800 bytes (839 MB) copied, 31.7389 s, 26.4 MB/s
 3, 838860800 bytes (839 MB) copied, 32.438 s, 25.9 MB/s
 4, 838860800 bytes (839 MB) copied, 32.5492 s, 25.8 MB/s
 5, 838860800 bytes (839 MB) copied, 31.6178 s, 26.5 MB/s
 average: 26.1MB/s

 Signed-off-by: Ming Lei ming@canonical.com
 ---
  drivers/net/usb/usbnet.c   |   30 ++
  include/linux/usb/usbnet.h |1 +
  2 files changed, 31 insertions(+)

 diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
 index 34e4252..1e5a9b7 100644
 --- a/drivers/net/usb/usbnet.c
 +++ b/drivers/net/usb/usbnet.c
 @@ -938,6 +938,27 @@ static const struct ethtool_ops usbnet_ethtool_ops = {

  /*-*/

 +static void __handle_link_change(struct usbnet *dev)
 +{
 +   if (!test_bit(EVENT_DEV_OPEN, dev-flags))
 +   return;
 +
 +   if (!netif_carrier_ok(dev-net)) {
 +   /* kill URBs for reading packets to save bus bandwidth */
 +   unlink_urbs(dev, dev-rxq);
 +
 +   /*
 +* tx_timeout will unlink URBs for sending packets and
 +* tx queue is stopped by netcore after link becomes off
 +*/
 +   } else {
 +   /* submitting URBs for reading packets */
 +   tasklet_schedule(dev-bh);
 +   }
 +
 +   clear_bit(EVENT_LINK_CHANGE, dev-flags);
 +}
 +
  /* work that cannot be done in interrupt context uses keventd.
   *
   * NOTE:  with 2.5 we could do more of this using completion callbacks,
 @@ -1035,8 +1056,14 @@ skip_reset:
 } else {
 usb_autopm_put_interface(dev-intf);
 }
 +
 +   /* handle link change from link resetting */
 +   __handle_link_change(dev);
 }

 +   if (test_bit (EVENT_LINK_CHANGE, dev-flags))
 +   __handle_link_change(dev);
 +
 if (dev-flags)
 netdev_dbg(dev-net, kevent done, flags = 0x%lx\n, 
 dev-flags);
  }
 @@ -1286,6 +1313,7 @@ static void usbnet_bh (unsigned long param)
 // or are we maybe short a few urbs?
 } else if (netif_running (dev-net) 
netif_device_present (dev-net) 
 +  netif_carrier_ok(dev-net) 
!timer_pending (dev-delay) 
!test_bit (EVENT_RX_HALT, dev-flags)) {
 int temp = dev-rxq.qlen;
 @@ -1663,6 +1691,8 @@ void usbnet_link_change(struct usbnet *dev, bool link, 
 bool need_reset)

 if (need_reset  link)
 usbnet_defer_kevent(dev, EVENT_LINK_RESET);
 +   else
 +   usbnet_defer_kevent(dev, EVENT_LINK_CHANGE);
  }
  EXPORT_SYMBOL(usbnet_link_change);

 diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
 index eb021b8..da46327 100644
 --- a/include/linux/usb/usbnet.h
 +++ b/include/linux/usb/usbnet.h
 @@ -72,6 +72,7 @@ struct usbnet {
  #  define EVENT_DEVICE_REPORT_IDLE 8
  #  define EVENT_NO_RUNTIME_PM  9
  #  define EVENT_RX_KILL10
 +#  define EVENT_LINK_CHANGE11
  };

  static inline struct usb_driver *driver_of(struct usb_interface *intf)
 --
 1.7.9.5

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

Re: [PATCH] USB: ehci-omap: Select USB_PHY

2013-04-11 Thread Roger Quadros
On 04/11/2013 05:34 PM, Felipe Balbi wrote:
 Hi,
 
 On Thu, Apr 11, 2013 at 04:18:33PM +0300, Roger Quadros wrote:
 On 04/11/2013 03:42 PM, Roger Quadros wrote:
 On 04/11/2013 01:55 PM, Felipe Balbi wrote:
 Hi,

 On Thu, Apr 11, 2013 at 01:51:16PM +0300, Roger Quadros wrote:
 On 04/11/2013 01:04 PM, Felipe Balbi wrote:
 Hi,

 On Thu, Apr 11, 2013 at 12:42:04PM +0300, Roger Quadros wrote:
 Hi Greg,

 The following patch gets rid of Kbuild warnings when USB_EHCI_HCD_OMAP
 is enabled.

 Patch is based on your usb-next branch and is needed for 3.10.

 From: Roger Quadros rog...@ti.com
 Date: Thu, 11 Apr 2013 12:08:19 +0300
 Subject: [PATCH] USB: ehci-omap: Select USB_PHY

 As we need NOP_USB_XCEIV which depends on USB_PHY
 we need to select USB_PHY as well.

 Gets rid of the below warnings when USB_EHCI_HCD_OMAP
 is enabled.

 warning: (USB_EHCI_HCD_OMAP) selects NOP_USB_XCEIV which has unmet 
 direct dependencies (USB_SUPPORT  USB_PHY)
 warning: (USB_EHCI_HCD_OMAP) selects NOP_USB_XCEIV which has unmet 
 direct dependencies (USB_SUPPORT  USB_PHY)

 Signed-off-by: Roger Quadros rog...@ti.com

 Ideally, however, we wouldn't select any PHY in particular as different
 boards might need a different PHY driver, even on OMAP ;-)

 Right, but we need to select USB_PHY here as the driver uses
 the USB_PHY APIs.

 The NOP_USB_XCEIV selection could be done by the board config.

 I would avoid 'select' completely and just update omap2plus_defconfig
 adding those two as modules.


 OK, makes sense. I will update the patch to remove select NOP_USB_XCEIV.


 One more issue to clarify.

 if USB_PHY is not enabled, then all phy_get() API's should return NULL and 
 not
 -ENXIO as it does now.
 
 ENXIO means No such device or address, looks alright to me ;-)
 
 This way the drivers need not treat it as an error and all PHY ops can
 be NOPs.
 
 drivers will already be using if (IS_ERR()) construction, returning
 -ENXIO when the API is disabled gives them an oportunity to *not*
 request probe deferral since the API isn't enabled anyway.

on second thoughts I agree with you. So the general understanding is
that USB_PHY users without USB_PHY enabled is an error case.

This means we need to allow controller drivers to select USB_PHY
and minimize this possibility.

 
 This will make it behave like other frameworks. e.g. clk.
 
 if we return NULL we will need IS_ERR_OR_NULL() which will cause
 problems with people who aren't careful enough.
 
OK.

cheers,
-roger
--
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/9] usb/gadget: change sysfs parent device for USB Ethernet

2013-04-11 Thread Alan Stern
On Thu, 11 Apr 2013, Andrzej Pietrasiewicz wrote:

 This adds a new sysfs root device to serve as a replacement for
 devices which are available only when a gadget is being bound.
 
 It is motivated by adding configfs support to USB Ethernet functions.
 When configfs is there, we would like to be able to mkdir some function
 directory, e.g.:
 
 $ mkdir functions/ecm.usb0
 
 and have the usb0 available in the system (albeit in an unconfigured,
 or default state) at this very point, which is _way_ before the gadget

What do you mean by available in the system?

 is actually bound. However, this poses a chicken and egg problem.
 In order for the interface to appear in the system, it needs to be

What interface are you talking about?  Is it a USB interface, a network
interface, a programming interface, a user interface, or some other
sort of interface?

 registered with register_netdev. But in order to register it, its
 parent device must be known and it becomes known only later during
 gadget's bind.

Why must this happen before the gadget driver is bound?  What can't it
happen after the driver is bound and before the gadget is connected to 
a host?

 This patch adds a /sys/devices/usb_gadget root device, which is registered
 during module_init of libcomposite, so it is available at any time for
 all libcomposite users and is used as a parent device for USB Ethernet
 devices instead of the gadget-dev.

I can't understand the reasoning here.  It's like saying I should be 
able to configure the network settings for my ethernet controller 
before the e100 driver is bound to it.

Are you sure this is necessary?

Alan Stern

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


Re: Linux USB file storage gadget with new UDC

2013-04-11 Thread victor yeo
Hi,

 Thanks for the detailed write-up. I have checked the UDC driver
 set_halt(), it is called by the gadget driver. The full ascii text of
 usbmon trace for one usb session is also attached. This usbmon trace
 shows a few EOVERFLOW(-75) error. I don't know why EOVERFLOW error
 happened.

 Because your UDC driver sent a packet that was too big.  Here's the
 first example from the trace:

 f3a2b6c0 3633034189 S Bo:2:036:1 -115 31 = 55534243 0600  
 0600    00
 f3a2b6c0 3633034326 C Bo:2:036:1 0 31 
 f3a2b6c0 3633034518 S Bi:2:036:1 -115 13 
 f3a2b6c0 3633040328 C Bi:2:036:1 -75 0

 The first two lines show the host sending a TEST UNIT READY command.
 The third line shows the host waiting for a 13-byte CSW data packet.
 The -75 error means that the UDC sent back a data packet containing
 more than 13 bytes.

 Alan Stern


Thanks, i do not know why UDC sent back a data packet containing more
than 13 bytes in response to TEST UNIT READY command.

Here is another usbmon trace attached in this email. There are two
issues in this usbmon trace. Firstly, the CSW that is sent back in
response to SCSI_READ_10 is wrong (wrong tag).

f2c92340 2379075608 S Bo:2:047:1 -115 31 = 55534243 1100 0010
8a28  0008  00
f2c92340 2379075737 C Bo:2:047:1 0 31 
f2c92ac0 2379075746 S Bi:2:047:1 -115 4096 
f2c92ac0 2382204478 C Bi:2:047:1 0 4096 =   
    
f2c92340 2382204489 S Bi:2:047:1 -115 13 
f2c92340 2382210596 C Bi:2:047:1 0 13 = 55534253 1000  00

Secondly, this CSW shows remote I/O error (-121).

f2c92340 2382422538 S Bo:2:047:1 -115 31 = 55534243 1200 0010
8a28  0008  00
f2c92340 2382422588 C Bo:2:047:1 0 31 
f3a2b5c0 2382422596 S Bi:2:047:1 -115 4096 
f3a2b5c0 2382448965 C Bi:2:047:1 -121 13 = 55534253 1200 0010 01
f2c92340 2382448977 S Bi:2:047:1 -115 13 

I am lost. Every time i connect Linux host to the USB gadget,
different error scenario is shown in usbmon.

victor


scsi_read_10_again11.log
Description: Binary data


Re: [PATCH] USB: ehci-omap: Select USB_PHY

2013-04-11 Thread Felipe Balbi
Hi,

On Thu, Apr 11, 2013 at 05:53:10PM +0300, Roger Quadros wrote:
  From: Roger Quadros rog...@ti.com
  Date: Thu, 11 Apr 2013 12:08:19 +0300
  Subject: [PATCH] USB: ehci-omap: Select USB_PHY
 
  As we need NOP_USB_XCEIV which depends on USB_PHY
  we need to select USB_PHY as well.
 
  Gets rid of the below warnings when USB_EHCI_HCD_OMAP
  is enabled.
 
  warning: (USB_EHCI_HCD_OMAP) selects NOP_USB_XCEIV which has unmet 
  direct dependencies (USB_SUPPORT  USB_PHY)
  warning: (USB_EHCI_HCD_OMAP) selects NOP_USB_XCEIV which has unmet 
  direct dependencies (USB_SUPPORT  USB_PHY)
 
  Signed-off-by: Roger Quadros rog...@ti.com
 
  Ideally, however, we wouldn't select any PHY in particular as different
  boards might need a different PHY driver, even on OMAP ;-)
 
  Right, but we need to select USB_PHY here as the driver uses
  the USB_PHY APIs.
 
  The NOP_USB_XCEIV selection could be done by the board config.
 
  I would avoid 'select' completely and just update omap2plus_defconfig
  adding those two as modules.
 
 
  OK, makes sense. I will update the patch to remove select NOP_USB_XCEIV.
 
 
  One more issue to clarify.
 
  if USB_PHY is not enabled, then all phy_get() API's should return NULL and 
  not
  -ENXIO as it does now.
  
  ENXIO means No such device or address, looks alright to me ;-)
  
  This way the drivers need not treat it as an error and all PHY ops can
  be NOPs.
  
  drivers will already be using if (IS_ERR()) construction, returning
  -ENXIO when the API is disabled gives them an oportunity to *not*
  request probe deferral since the API isn't enabled anyway.
 
 on second thoughts I agree with you. So the general understanding is
 that USB_PHY users without USB_PHY enabled is an error case.
 
 This means we need to allow controller drivers to select USB_PHY
 and minimize this possibility.

perhaps but OTOH careless select will also cause lots of problems.
distro-like kernels will just put all those as modules and product-like
kernels will only enable exactly what they need, so it makes no
difference if we select or not. Except that select will enable that PHY
even in e.g. beaglebone derivative which is, for now, using the same DTS
file.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] usb-serial: add support for USB Wishbone-serial adapters

2013-04-11 Thread Greg KH
On Thu, Apr 11, 2013 at 03:54:47PM +0200, Wesley W. Terpstra wrote:
 On Thu, 2013-04-11 at 06:45 -0700, Greg KH wrote:
  I only have one very minor question about the code:
  
   +++ b/drivers/usb/serial/wishbone-serial.c
   @@ -0,0 +1,95 @@
   +/*
   + * USB Wishbone-Serial adapter driver
   + *
   + * Copyright (C) 2013 Wesley W. Terpstra w.terps...@gsi.de
   + * Copyright (C) 2013 GSI Helmholtz Centre for Heavy Ion Research GmbH
   + *
   + * This program is free software; you can redistribute it and/or
   + * modify it under the terms of the GNU General Public License
   + * as published by the Free Software Foundation; either version 2
   + * of the License, or (at your option) any later version.
   + */
  
  Do you really mean or any later version for the license of this
  driver?  I ask as the kernel itself is GPLv2-only.  It's fine if you
  want this to be GPLv2+, I just have to ask.
 
 Yes, I know the kernel is v2. Which is a shame because the FSF made the
 v3 licence which some people would prefer. If in the distant future, the
 kernel were to slowly be relicenced as v2+ or v3, I don't want to
 contribute to the migration problem.

Fair enough, although this driver would probably be the least of our
worries if that were to happen :)

 A question for you in turn: why were usb_serial_[de]register removed?

Because no one uses it anymore.

 The new usb_serial_deregister_drivers isn't available in older kernels.
 So drivers cannot support (without ifdefs) both old and new kernels

We don't support drivers outside of the Linux kernel tree very well, if
at all.  If an author wants to do that, they are on their own.  Fore
more details about this, please read the
Documenation/stable_api_nonsense.txt file in the kernel source tree.

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 00/11] usbnet: usbnet: handle link change

2013-04-11 Thread Jussi Kivilinna
On 11.04.2013 17:40, Ming Lei wrote:
 Hi,
 
 This patch set introduces usbnet_link_change() API and applies
 it on all usbnet drivers, then handle the link change centrally
 to stop bulk transfer when link becomes off and restart bulk
 transfer when link becomes on.

Should 'rndis_wlan' be changed to use this too?

-Jussi

 
 With the change, ~10% performance boost on bulk transfer
 of another device on the same bus can be obtained when link
 is off. Also, stopping bulk transfer when link becomes off
 may disable asynchonous schedule of host controller, power
 might be saved probabally.
 
  drivers/net/usb/asix_devices.c |6 +-
  drivers/net/usb/ax88179_178a.c |   12 ---
  drivers/net/usb/cdc_ether.c|5 +
  drivers/net/usb/cdc_ncm.c  |9 +++-
  drivers/net/usb/dm9601.c   |7 +--
  drivers/net/usb/mcs7830.c  |6 +-
  drivers/net/usb/sierra_net.c   |3 +--
  drivers/net/usb/usbnet.c   |   45 
 +++-
  include/linux/usb/usbnet.h |2 ++
  9 files changed, 58 insertions(+), 37 deletions(-)
 
 
 Thanks,
 --
 Ming Lei
 
 
 --
 To unsubscribe from this list: send the line unsubscribe netdev in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 

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


Re: [PATCH 08/11] usbnet: dm9601: apply usbnet_link_change

2013-04-11 Thread Peter Korsgaard
 Ming == Ming Lei ming@canonical.com writes:

 Ming Use usbnet_link_change to handle link change centrally.

Acked-by: Peter Korsgaard jac...@sunsite.dk

 Ming Cc: Peter Korsgaard jac...@sunsite.dk
 Ming Signed-off-by: Ming Lei ming@canonical.com
 Ming ---
 Ming  drivers/net/usb/dm9601.c |7 +--
 Ming  1 file changed, 1 insertion(+), 6 deletions(-)

 Ming diff --git a/drivers/net/usb/dm9601.c b/drivers/net/usb/dm9601.c
 Ming index 174e5ec..2dbb946 100644
 Ming --- a/drivers/net/usb/dm9601.c
 Ming +++ b/drivers/net/usb/dm9601.c
 Ming @@ -524,12 +524,7 @@ static void dm9601_status(struct usbnet *dev, 
struct urb *urb)
 
 Ming  link = !!(buf[0]  0x40);
 Ming  if (netif_carrier_ok(dev-net) != link) {
 Ming -if (link) {
 Ming -netif_carrier_on(dev-net);
 Ming -usbnet_defer_kevent (dev, EVENT_LINK_RESET);
 Ming -}
 Ming -else
 Ming -netif_carrier_off(dev-net);
 Ming +usbnet_link_change(dev, link, 1);
 Ming  netdev_dbg(dev-net, Link Status is: %d\n, link);
 Ming  }
 Ming  }
 Ming -- 
 Ming 1.7.9.5



-- 
Bye, Peter Korsgaard
--
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 00/11] usbnet: usbnet: handle link change

2013-04-11 Thread Ming Lei
On Thu, Apr 11, 2013 at 11:18 PM, Jussi Kivilinna
jussi.kivili...@iki.fi wrote:
 On 11.04.2013 17:40, Ming Lei wrote:
 Hi,

 This patch set introduces usbnet_link_change() API and applies
 it on all usbnet drivers, then handle the link change centrally
 to stop bulk transfer when link becomes off and restart bulk
 transfer when link becomes on.

 Should 'rndis_wlan' be changed to use this too?

If link detection of 'rndis_wlan' doesn't depend on
bulk transfer, it can benefit from the change. Otherwise,
it needn't the change, but the patch won't have side-effect
on 'rndis_wlan'.


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


Re: [PATCH 1/2 v5] usbnet: allow status interrupt URB to always be active

2013-04-11 Thread Dan Williams
On Thu, 2013-04-11 at 10:31 +0800, Ming Lei wrote:
 On Thu, Apr 11, 2013 at 4:30 AM, Dan Williams d...@redhat.com wrote:
  Some drivers (sierra_net) need the status interrupt URB
  active even when the device is closed, because they receive
  custom indications from firmware.  Add functions to refcount
  the status interrupt URB submit/kill operation so that
  sub-drivers and the generic driver don't fight over whether
  the status interrupt URB is active or not.
 
  A sub-driver can call usbnet_status_start() at any time, but
  the URB is only submitted the first time the function is
  called.  Likewise, when the sub-driver is done with the URB,
  it calls usbnet_status_stop() but the URB is only killed when
  all users have stopped it.  The URB is still killed and
  re-submitted for suspend/resume, as before, with the same
  refcount it had at suspend.
 
  Signed-off-by: Dan Williams d...@redhat.com
  ---
   drivers/net/usb/usbnet.c   | 79 
  ++
   include/linux/usb/usbnet.h |  5 +++
   2 files changed, 77 insertions(+), 7 deletions(-)
 
  diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
  index 51f3192..b71ce36 100644
  --- a/drivers/net/usb/usbnet.c
  +++ b/drivers/net/usb/usbnet.c
  @@ -252,6 +252,70 @@ static int init_status (struct usbnet *dev, struct 
  usb_interface *intf)
  return 0;
   }
 
  +/* Submit the interrupt URB if not previously submitted, increasing 
  refcount */
  +int usbnet_status_start(struct usbnet *dev, gfp_t mem_flags)
 
 'mem_flags' isn't needed any more since we can apply allocation
 of GFP_NOIO automatically in resume path now, and you can always
 use GFP_KERNEL safely. Considered that it is a API, please don't
 introduce it.
 
 After removing it, you can add
 
   Acked-by: Ming Lei ming@canonical.com
 
  +{
  +   int ret = 0;
  +
  +   WARN_ON_ONCE(dev-interrupt == NULL);
  +   if (dev-interrupt) {
  +   mutex_lock(dev-interrupt_mutex);
  +
  +   if (++dev-interrupt_count == 1)
  +   ret = usb_submit_urb(dev-interrupt, mem_flags);
  +
  +   dev_dbg(dev-udev-dev, incremented interrupt URB count 
  to %d\n,
  +   dev-interrupt_count);
  +   mutex_unlock(dev-interrupt_mutex);
  +   }
  +   return ret;
  +}
  +EXPORT_SYMBOL_GPL(usbnet_status_start);
  +
  +/* For resume; submit interrupt URB if previously submitted */
  +static int __usbnet_status_start_force(struct usbnet *dev, gfp_t mem_flags)
  +{
  +   int ret = 0;
  +
  +   mutex_lock(dev-interrupt_mutex);
  +   if (dev-interrupt_count) {
  +   ret = usb_submit_urb(dev-interrupt, mem_flags);
  +   dev_dbg(dev-udev-dev,
  +   submitted interrupt URB for resume\n);
  +   }
  +   mutex_unlock(dev-interrupt_mutex);
  +   return ret;
  +}
  +
  +/* Kill the interrupt URB if all submitters want it killed */
  +void usbnet_status_stop(struct usbnet *dev)
  +{
  +   if (dev-interrupt) {
  +   mutex_lock(dev-interrupt_mutex);
  +   WARN_ON(dev-interrupt_count == 0);
  +
  +   if (dev-interrupt_count  --dev-interrupt_count == 0)
  +   usb_kill_urb(dev-interrupt);
  +
  +   dev_dbg(dev-udev-dev,
  +   decremented interrupt URB count to %d\n,
  +   dev-interrupt_count);
  +   mutex_unlock(dev-interrupt_mutex);
  +   }
  +}
  +EXPORT_SYMBOL_GPL(usbnet_status_stop);
  +
  +/* For suspend; always kill interrupt URB */
  +static void __usbnet_status_stop_force(struct usbnet *dev)
  +{
  +   if (dev-interrupt) {
  +   mutex_lock(dev-interrupt_mutex);
  +   usb_kill_urb(dev-interrupt);
  +   dev_dbg(dev-udev-dev, killed interrupt URB for 
  suspend\n);
  +   mutex_unlock(dev-interrupt_mutex);
  +   }
  +}
 
 Looks it isn't a good practice to duplicate code in above four functions, but
 it should be OK to merge first.

Oliver requested this approach.  I'd originally taken your suggestion to
merge them, but this proved somewhat more complicated and Oliver
rejected that approach.

Dan

  +
   /* Passes this packet up the stack, updating its accounting.
* Some link protocols batch packets, so their rx_fixup paths
* can return clones as well as just modify the original skb.
  @@ -725,7 +789,7 @@ int usbnet_stop (struct net_device *net)
  if (!(info-flags  FLAG_AVOID_UNLINK_URBS))
  usbnet_terminate_urbs(dev);
 
  -   usb_kill_urb(dev-interrupt);
  +   usbnet_status_stop(dev);
 
  usbnet_purge_paused_rxq(dev);
 
  @@ -787,7 +851,7 @@ int usbnet_open (struct net_device *net)
 
  /* start any status interrupt transfer */
  if (dev-interrupt) {
  -   retval = usb_submit_urb (dev-interrupt, GFP_KERNEL);
  +   retval = 

Re: [PATCH] usb-serial: add support for USB Wishbone-serial adapters

2013-04-11 Thread Wesley W. Terpstra
On Thu, 2013-04-11 at 08:15 -0700, Greg KH wrote:
 Fair enough, although this driver would probably be the least of our
 worries if that were to happen :)
Of course.

 Documenation/stable_api_nonsense.txt
Tactfully named. :)

Is there a document that describes how to track the progress a patch
makes on its way to a released kernel version? I understand that
subsystem maintainers aggregate changes which then are aggregated in
turn by Linus, but beyond that I have no understanding of the flow.

Also: Thank you very much for all your help. I've made several kernel
modules over the years, but never submitted any of them for inclusion
because I had the (it seems false) impression that the linux kernel
development process was full of angry people who would make it
unpleasant.

Glad to learn that this is just a myth!
I will probably contribute more patches in the future.


--
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: Linux USB file storage gadget with new UDC

2013-04-11 Thread Alan Stern
On Thu, 11 Apr 2013, victor yeo wrote:

 Thanks, i do not know why UDC sent back a data packet containing more
 than 13 bytes in response to TEST UNIT READY command.

Sounds like you need to debug the UDC driver.

 Here is another usbmon trace attached in this email. There are two
 issues in this usbmon trace. Firstly, the CSW that is sent back in
 response to SCSI_READ_10 is wrong (wrong tag).
 
 f2c92340 2379075608 S Bo:2:047:1 -115 31 = 55534243 1100 0010
 8a28  0008  00
 f2c92340 2379075737 C Bo:2:047:1 0 31 
 f2c92ac0 2379075746 S Bi:2:047:1 -115 4096 
 f2c92ac0 2382204478 C Bi:2:047:1 0 4096 =   
     
 f2c92340 2382204489 S Bi:2:047:1 -115 13 
 f2c92340 2382210596 C Bi:2:047:1 0 13 = 55534253 1000  00

Maybe the UDC driver doesn't update some buffer contents properly, so
the same buffer gets sent twice.

(Also, it seems odd that there was a 3-second delay in the middle of
this command.  Maybe that is related to your problem somehow.  On the
other hand, all the READ commands in the log show a similar delay, even
though they are for only 4096 bytes.)

 Secondly, this CSW shows remote I/O error (-121).
 
 f2c92340 2382422538 S Bo:2:047:1 -115 31 = 55534243 1200 0010
 8a28  0008  00
 f2c92340 2382422588 C Bo:2:047:1 0 31 
 f3a2b5c0 2382422596 S Bi:2:047:1 -115 4096 
 f3a2b5c0 2382448965 C Bi:2:047:1 -121 13 = 55534253 1200 0010 01
 f2c92340 2382448977 S Bi:2:047:1 -115 13 

In this case the 4096 data bytes weren't sent at all.  Just the 13-byte 
CSW, which isn't supposed to be sent until the command ends.

 I am lost. Every time i connect Linux host to the USB gadget,
 different error scenario is shown in usbmon.

You need to find out what is happening inside the UDC driver.  Write
out a log message every time the gadget driver submits a request for
the bulk-in endpoint, and every time a bulk-in packet is sent, and 
every time a request completes.  Print out the first eight bytes or so 
of the buffer contents, so you can see if the right data is getting 
sent back to the host, plus whatever additional information might be 
helpful.  I can't debug your driver for you.

Alan Stern

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


Re: [PATCH] usb-serial: add support for USB Wishbone-serial adapters

2013-04-11 Thread Greg KH
On Thu, Apr 11, 2013 at 05:30:52PM +0200, Wesley W. Terpstra wrote:
 Is there a document that describes how to track the progress a patch
 makes on its way to a released kernel version? I understand that
 subsystem maintainers aggregate changes which then are aggregated in
 turn by Linus, but beyond that I have no understanding of the flow.

Not really, as each maintainer has a different workflow.  For example,
my scripts will email you when the patch is applied to my trees with
some information as to what is going to happen to it, and where you can
find the patch.  Other maintainers just do a short patch applied email
response, and others (and I personally hate this), don't say anything at
all and you have to watch and see if your patch ever gets applied
anywhere.

You might want to look at Documentation/development_model/ for some
information on how the overall process works.  If you have any questions
about it after reading this, be sure to let us know.

 Also: Thank you very much for all your help. I've made several kernel
 modules over the years, but never submitted any of them for inclusion
 because I had the (it seems false) impression that the linux kernel
 development process was full of angry people who would make it
 unpleasant.
 
 Glad to learn that this is just a myth!
 I will probably contribute more patches in the future.

That's good to hear.

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


[PATCH 0/2] staging: dwc2: Interrupt-related fixes

2013-04-11 Thread Matthijs Kooijman
Hi folks,

here's two interrupt-related fixes (though the first is a bit between a
fix and a cleanup). These two are needed for the platform driver patches
I'm sending next. I have some interrupt related cleanups (no fixes)
later on.

These two patches haven't changed from when I sent them in the big
40-patch series last week.

Gr.

Matthijs

Matthijs Kooijman (2):
  staging: dwc2: don't pass IRQ_LEVEL to devm_request_irq
  staging: dwc2: register common irq handler in dwc2_core_init

 drivers/staging/dwc2/core.c | 13 -
 drivers/staging/dwc2/core.h |  2 +-
 drivers/staging/dwc2/hcd.c  | 14 +++---
 drivers/staging/dwc2/pci.c  |  7 ---
 4 files changed, 20 insertions(+), 16 deletions(-)

-- 
1.8.0

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


[PATCH 1/2] staging: dwc2: don't pass IRQ_LEVEL to devm_request_irq

2013-04-11 Thread Matthijs Kooijman
It seems this flag is intended to pass to irq_set_status_flags, not
request_irq, and is not available on all architectures. Its value
corresponds to IRQF_PROBE_SHARED, which shouldn't be needed for this
driver, so removing this flag should be safe.

Signed-off-by: Matthijs Kooijman matth...@stdin.nl
---
 drivers/staging/dwc2/pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/dwc2/pci.c b/drivers/staging/dwc2/pci.c
index 0825eef..80808d8 100644
--- a/drivers/staging/dwc2/pci.c
+++ b/drivers/staging/dwc2/pci.c
@@ -157,7 +157,7 @@ static int dwc2_driver_probe(struct pci_dev *dev,
 
dev_dbg(dev-dev, registering common handler for irq%d\n, dev-irq);
retval = devm_request_irq(dev-dev, dev-irq, dwc2_handle_common_intr,
- IRQF_SHARED | IRQ_LEVEL, dev_name(dev-dev),
+ IRQF_SHARED, dev_name(dev-dev),
  hsotg);
if (retval)
dwc2_hcd_remove(hsotg);
-- 
1.8.0

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


[PATCH 2/2] staging: dwc2: register common irq handler in dwc2_core_init

2013-04-11 Thread Matthijs Kooijman
Before, this was initialized in pci.c, after the dwc2_hcd_init was
called and the interrupts were enabled. This opened up a small time
window where common interrupts could be triggered, but there was no
handler for them, causing them to keep triggering infinitely and locking
up the machine.

On my RT3052 board this bug could be easily reproduced by hardcoding
the console log level to 8, so that a bunch of debug output from the dwc2
driver was generated inside this time window. This caused the interrupt
lockup to occur almost every time.

By requesting the irq inside dwc2_core_init and by disabling interrupts
before calling dwc2_core_init instead of after, we can be sure the
handler is registered before the interrupts are enabled, which should
close this window.

Reported-by: Stephen Warren swar...@wwwdotorg.org
Signed-off-by: Matthijs Kooijman matth...@stdin.nl
---
 drivers/staging/dwc2/core.c | 13 -
 drivers/staging/dwc2/core.h |  2 +-
 drivers/staging/dwc2/hcd.c  | 14 +++---
 drivers/staging/dwc2/pci.c  |  7 ---
 4 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/dwc2/core.c b/drivers/staging/dwc2/core.c
index 549cd3d..3177db2 100644
--- a/drivers/staging/dwc2/core.c
+++ b/drivers/staging/dwc2/core.c
@@ -365,8 +365,9 @@ static void dwc2_gusbcfg_init(struct dwc2_hsotg *hsotg)
  *
  * @hsotg:  Programming view of the DWC_otg controller
  * @select_phy: If true then also set the Phy type
+ * @irq:If = 0, the irq to register
  */
-int dwc2_core_init(struct dwc2_hsotg *hsotg, bool select_phy)
+int dwc2_core_init(struct dwc2_hsotg *hsotg, bool select_phy, int irq)
 {
u32 usbcfg, otgctl;
int retval;
@@ -430,6 +431,16 @@ int dwc2_core_init(struct dwc2_hsotg *hsotg, bool 
select_phy)
/* Clear the SRP success bit for FS-I2c */
hsotg-srp_success = 0;
 
+   if (irq = 0) {
+   dev_dbg(hsotg-dev, registering common handler for irq%d\n,
+   irq);
+   retval = devm_request_irq(hsotg-dev, irq,
+ dwc2_handle_common_intr, IRQF_SHARED,
+ dev_name(hsotg-dev), hsotg);
+   if (retval)
+   return retval;
+   }
+
/* Enable common interrupts */
dwc2_enable_common_interrupts(hsotg);
 
diff --git a/drivers/staging/dwc2/core.h b/drivers/staging/dwc2/core.h
index f8ee04b..320ed00 100644
--- a/drivers/staging/dwc2/core.h
+++ b/drivers/staging/dwc2/core.h
@@ -445,7 +445,7 @@ extern void dwc2_read_packet(struct dwc2_hsotg *hsotg, u8 
*dest, u16 bytes);
 extern void dwc2_flush_tx_fifo(struct dwc2_hsotg *hsotg, const int num);
 extern void dwc2_flush_rx_fifo(struct dwc2_hsotg *hsotg);
 
-extern int dwc2_core_init(struct dwc2_hsotg *hsotg, bool select_phy);
+extern int dwc2_core_init(struct dwc2_hsotg *hsotg, bool select_phy, int irq);
 extern void dwc2_enable_global_interrupts(struct dwc2_hsotg *hcd);
 extern void dwc2_disable_global_interrupts(struct dwc2_hsotg *hcd);
 
diff --git a/drivers/staging/dwc2/hcd.c b/drivers/staging/dwc2/hcd.c
index 1ea1222..f68d8cc 100644
--- a/drivers/staging/dwc2/hcd.c
+++ b/drivers/staging/dwc2/hcd.c
@@ -1313,7 +1313,7 @@ static void dwc2_conn_id_status_change(struct work_struct 
*work)
dev_err(hsotg-dev,
Connection id status change timed out);
hsotg-op_state = OTG_STATE_B_PERIPHERAL;
-   dwc2_core_init(hsotg, false);
+   dwc2_core_init(hsotg, false, -1);
dwc2_enable_global_interrupts(hsotg);
} else {
/* A-Device connector (Host Mode) */
@@ -1332,7 +1332,7 @@ static void dwc2_conn_id_status_change(struct work_struct 
*work)
hsotg-op_state = OTG_STATE_A_HOST;
 
/* Initialize the Core for Host mode */
-   dwc2_core_init(hsotg, false);
+   dwc2_core_init(hsotg, false, -1);
dwc2_enable_global_interrupts(hsotg);
dwc2_hcd_start(hsotg);
}
@@ -2818,17 +2818,17 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
((struct wrapper_priv_data *) hcd-hcd_priv)-hsotg = hsotg;
hsotg-priv = hcd;
 
-   /* Initialize the DWC_otg core, and select the Phy type */
-   retval = dwc2_core_init(hsotg, true);
-   if (retval)
-   goto error2;
-
/*
 * Disable the global interrupt until all the interrupt handlers are
 * installed
 */
dwc2_disable_global_interrupts(hsotg);
 
+   /* Initialize the DWC_otg core, and select the Phy type */
+   retval = dwc2_core_init(hsotg, true, irq);
+   if (retval)
+   goto error2;
+
/* Create new workqueue and init work */
hsotg-wq_otg = create_singlethread_workqueue(dwc_otg);
if (!hsotg-wq_otg) {
diff --git a/drivers/staging/dwc2/pci.c b/drivers/staging/dwc2/pci.c
index 

[PATCH 1/4] staging: dwc2: set the driver name to dwc2

2013-04-11 Thread Matthijs Kooijman
Previously, it was dwc_otg, but this does not correspond to the
directory name and might cause confusion with the old out-of-tree
dwc_otg driver of which many versions circulate.

Signed-off-by: Matthijs Kooijman matth...@stdin.nl
---
 drivers/staging/dwc2/hcd.c | 2 +-
 drivers/staging/dwc2/pci.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/dwc2/hcd.c b/drivers/staging/dwc2/hcd.c
index f68d8cc..4d5f34e 100644
--- a/drivers/staging/dwc2/hcd.c
+++ b/drivers/staging/dwc2/hcd.c
@@ -2830,7 +2830,7 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
goto error2;
 
/* Create new workqueue and init work */
-   hsotg-wq_otg = create_singlethread_workqueue(dwc_otg);
+   hsotg-wq_otg = create_singlethread_workqueue(dwc2);
if (!hsotg-wq_otg) {
dev_err(hsotg-dev, Failed to create workqueue\n);
goto error2;
diff --git a/drivers/staging/dwc2/pci.c b/drivers/staging/dwc2/pci.c
index 8d9a902..69c65eb 100644
--- a/drivers/staging/dwc2/pci.c
+++ b/drivers/staging/dwc2/pci.c
@@ -57,7 +57,7 @@
 #define PCI_VENDOR_ID_SYNOPSYS 0x16c3
 #define PCI_PRODUCT_ID_HAPS_HSOTG  0xabc0
 
-static const char dwc2_driver_name[] = dwc_otg;
+static const char dwc2_driver_name[] = dwc2;
 
 static struct dwc2_core_params dwc2_module_params = {
.otg_cap= -1,
-- 
1.8.0

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


[PATCH 0/4] staging: dwc2: Add platform driver

2013-04-11 Thread Matthijs Kooijman
Hi folks,

this is a few patches centering around the dwc2 platform driver. I've
added the devicetree boilerplate, I'll be sending over a patch for
actually using this driver on the ramips platform through the mips
people.

Gr.

Matthijs

Matthijs Kooijman (4):
  staging: dwc2: set the driver name to dwc2
  staging: dwc2: Make dwc2_set_uninitialized more specific
  staging: dwc2: add platform device bindings
  staging: dwc2: load parameters from the devicetree

 Documentation/devicetree/bindings/staging/dwc2.txt |  51 +
 drivers/staging/dwc2/Kconfig   |   6 +-
 drivers/staging/dwc2/Makefile  |   2 +
 drivers/staging/dwc2/core.h|   4 +
 drivers/staging/dwc2/hcd.c |  14 +-
 drivers/staging/dwc2/hcd.h |   1 +
 drivers/staging/dwc2/pci.c |   2 +-
 drivers/staging/dwc2/platform.c| 250 +
 8 files changed, 323 insertions(+), 7 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/staging/dwc2.txt
 create mode 100644 drivers/staging/dwc2/platform.c

-- 
1.8.0

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


[PATCH 4/4] staging: dwc2: load parameters from the devicetree

2013-04-11 Thread Matthijs Kooijman
Each of the parameters in the dwc2_core_params struct can now be changed
using devicetree parameters.

Signed-off-by: Matthijs Kooijman matth...@stdin.nl
---
 Documentation/devicetree/bindings/staging/dwc2.txt |  36 
 drivers/staging/dwc2/platform.c| 100 +
 2 files changed, 136 insertions(+)

This just adds all existing parameters to the devicetree for now. It's
not unlikely that some of these parameters gets dropped later or turn
out to be unsuitable for setting from the devicetree, but for now I've
just added them all without closely looking at each.

diff --git a/Documentation/devicetree/bindings/staging/dwc2.txt 
b/Documentation/devicetree/bindings/staging/dwc2.txt
index 3649c88..05d9c08 100644
--- a/Documentation/devicetree/bindings/staging/dwc2.txt
+++ b/Documentation/devicetree/bindings/staging/dwc2.txt
@@ -5,6 +5,39 @@ Required properties:
 - compatible : snps,dwc2
 - reg : Should contain 1 register range (address and length)
 - interrupts : Should contain 1 interrupt
+Optional properties:
+ - dma-enable
+ - otg-cap
+ - otg-ver
+ - dma-enable
+ - dma-desc-enable
+ - speed
+ - enable-dynamic-fifo
+ - en-multiple-tx-fifo
+ - host-rx-fifo-size
+ - host-nperio-tx-fifo-size
+ - host-perio-tx-fifo-size
+ - max-transfer-size
+ - max-packet-count
+ - host-channels
+ - phy-type
+ - phy-utmi-width
+ - phy-ulpi-ddr
+ - phy-ulpi-ext-vbus
+ - i2c-enable
+ - ulpi-fs-ls
+ - host-support-fs-ls-low-power
+ - host-ls-low-power-phy-clk
+ - ts-dline
+ - reload-ctl
+ - ahb-single
+
+Each of the above properties take a single cell containing an integer. See
+struct dwc2_core_params in dwc2/core.h for their meanings and possible values.
+
+If absent, these values have either a driver default or are autodetected.
+Where possible, the values set through the devicetree are checked against
+hardware limits and automatically capped or adjusted as needed.
 
 Example:
 
@@ -12,4 +45,7 @@ Example:
 compatible = ralink,rt3050-otg, snps,dwc2;
 reg = 0x101c 4;
 interrupts = 18;
+
+   # Force slave mode, even when dma is advertised to work
+   dma-enable = 0;
 };
diff --git a/drivers/staging/dwc2/platform.c b/drivers/staging/dwc2/platform.c
index e65fa0d..9e05865 100644
--- a/drivers/staging/dwc2/platform.c
+++ b/drivers/staging/dwc2/platform.c
@@ -40,6 +40,8 @@
 #include linux/device.h
 #include linux/dma-mapping.h
 #include linux/platform_device.h
+#include linux/of.h
+#include asm/byteorder.h
 
 #include core.h
 #include hcd.h
@@ -69,6 +71,101 @@ static int dwc2_driver_remove(struct platform_device *dev)
 }
 
 /**
+ * dwc2_load_property() - Load a single property from the devicetree
+ * node into the given variable.
+ *
+ * @dev: Platform device
+ * @res: The variable to put the loaded value into
+ * @name: The name of the devicetree property to load
+ */
+static void dwc2_load_property(struct platform_device *dev, int *res,
+  const char *name)
+{
+   int len;
+   const u32 *val;
+
+   val = of_get_property(dev-dev.of_node, name, len);
+   if (!val)
+   return;
+
+   if (len != sizeof(*val)) {
+   dev_warn(dev-dev,
+Invalid value in devicetree for %s property, should 
be a single integer\n,
+name);
+   return;
+   }
+
+   *res = be32_to_cpu(*val);
+
+   dev_dbg(dev-dev, Loaded %s parameter from devicetree: %d\n,
+   name, *res);
+}
+
+/**
+ * dwc2_load_properties() - Load all devicetree properties into the core
+ * params.
+ *
+ * @dev: Platform device
+ * @params: The core parameters to load the values into
+ */
+static void dwc2_load_properties(struct platform_device *dev,
+struct dwc2_core_params *params)
+{
+   dev_dbg(dev-dev, Loading parameters from devicetree node %s\n,
+   dev-dev.of_node-name);
+   dwc2_load_property(dev, params-dma_enable,
+  dma-enable);
+   dwc2_load_property(dev, params-otg_cap,
+  otg-cap);
+   dwc2_load_property(dev, params-otg_ver,
+  otg-ver);
+   dwc2_load_property(dev, params-dma_enable,
+  dma-enable);
+   dwc2_load_property(dev, params-dma_desc_enable,
+  dma-desc-enable);
+   dwc2_load_property(dev, params-speed,
+  speed);
+   dwc2_load_property(dev, params-enable_dynamic_fifo,
+  enable-dynamic-fifo);
+   dwc2_load_property(dev, params-en_multiple_tx_fifo,
+  en-multiple-tx-fifo);
+   dwc2_load_property(dev, params-host_rx_fifo_size,
+  host-rx-fifo-size);
+   dwc2_load_property(dev, params-host_nperio_tx_fifo_size,
+  host-nperio-tx-fifo-size);
+   dwc2_load_property(dev, 

[PATCH 3/4] staging: dwc2: add platform device bindings

2013-04-11 Thread Matthijs Kooijman
This adds a dwc_platform.ko module that can be loaded by using
compatible = snps,dwc2 in a device tree.

Signed-off-by: Matthijs Kooijman matth...@stdin.nl
---
 Documentation/devicetree/bindings/staging/dwc2.txt |  15 +++
 drivers/staging/dwc2/Kconfig   |   6 +-
 drivers/staging/dwc2/Makefile  |   2 +
 drivers/staging/dwc2/platform.c| 150 +
 4 files changed, 171 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/staging/dwc2.txt
 create mode 100644 drivers/staging/dwc2/platform.c

diff --git a/Documentation/devicetree/bindings/staging/dwc2.txt 
b/Documentation/devicetree/bindings/staging/dwc2.txt
new file mode 100644
index 000..3649c88
--- /dev/null
+++ b/Documentation/devicetree/bindings/staging/dwc2.txt
@@ -0,0 +1,15 @@
+Platform DesignWare HS OTG USB 2.0 controller
+-
+
+Required properties:
+- compatible : snps,dwc2
+- reg : Should contain 1 register range (address and length)
+- interrupts : Should contain 1 interrupt
+
+Example:
+
+otg@101c {
+compatible = ralink,rt3050-otg, snps,dwc2;
+reg = 0x101c 4;
+interrupts = 18;
+};
diff --git a/drivers/staging/dwc2/Kconfig b/drivers/staging/dwc2/Kconfig
index 2f75be7..f0b4739 100644
--- a/drivers/staging/dwc2/Kconfig
+++ b/drivers/staging/dwc2/Kconfig
@@ -8,9 +8,11 @@ config USB_DWC2
  USB controller based on the DesignWare HSOTG IP Core.
 
  If you choose to build this driver as dynamically linked
- modules, the core module will be called dwc2.ko, and the
+ modules, the core module will be called dwc2.ko, the
  PCI bus interface module (if you have a PCI bus system)
- will be called dwc2_pci.ko.
+ will be called dwc2_pci.ko and the platform interface module
+ (for controllers directly connected to the CPU) will be called
+ dwc2_platform.ko.
 
  NOTE: This driver at present only implements the Host mode
  of the controller. The existing s3c-hsotg driver supports
diff --git a/drivers/staging/dwc2/Makefile b/drivers/staging/dwc2/Makefile
index 6dccf46..11529d3 100644
--- a/drivers/staging/dwc2/Makefile
+++ b/drivers/staging/dwc2/Makefile
@@ -19,5 +19,7 @@ dwc2-y+= hcd_queue.o 
hcd_ddma.o
 ifneq ($(CONFIG_PCI),)
obj-$(CONFIG_USB_DWC2)  += dwc2_pci.o
 endif
+obj-$(CONFIG_USB_DWC2) += dwc2_platform.o
 
 dwc2_pci-y += pci.o
+dwc2_platform-y+= platform.o
diff --git a/drivers/staging/dwc2/platform.c b/drivers/staging/dwc2/platform.c
new file mode 100644
index 000..e65fa0d
--- /dev/null
+++ b/drivers/staging/dwc2/platform.c
@@ -0,0 +1,150 @@
+/*
+ * platform.c - DesignWare HS OTG Controller platform driver
+ *
+ * Copyright (C) 2004-2013 Synopsys, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions, and the following disclaimer,
+ *without modification.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ * 3. The names of the above-listed copyright holders may not be used
+ *to endorse or promote products derived from this software without
+ *specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License (GPL) as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS
+ * IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include linux/kernel.h
+#include linux/module.h
+#include linux/slab.h
+#include linux/device.h
+#include linux/dma-mapping.h
+#include linux/platform_device.h
+
+#include core.h
+#include hcd.h
+

[PATCH 2/4] staging: dwc2: Make dwc2_set_uninitialized more specific

2013-04-11 Thread Matthijs Kooijman
Before, it was a function that would set all members of a given struct
containing only int members to -1. Now, it is renamed to
dwc_set_all_params and it works only on the dwc2_core_params struct.
This makes sure that all of the slightly dubious casting and assumptions
happen inside the function instead of by the caller.

Signed-off-by: Matthijs Kooijman matth...@stdin.nl
---
 drivers/staging/dwc2/core.h |  4 
 drivers/staging/dwc2/hcd.c  | 12 +---
 drivers/staging/dwc2/hcd.h  |  1 +
 3 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/dwc2/core.h b/drivers/staging/dwc2/core.h
index 320ed00..fc075a7 100644
--- a/drivers/staging/dwc2/core.h
+++ b/drivers/staging/dwc2/core.h
@@ -162,6 +162,10 @@ enum dwc2_lx_state {
  * parameters define how the DWC_otg controller should be configured.
  */
 struct dwc2_core_params {
+   /*
+* Don't add any non-int members here, this will break
+* dwc2_set_all_params!
+*/
int otg_cap;
int otg_ver;
int dma_enable;
diff --git a/drivers/staging/dwc2/hcd.c b/drivers/staging/dwc2/hcd.c
index 4d5f34e..bc9c3c5 100644
--- a/drivers/staging/dwc2/hcd.c
+++ b/drivers/staging/dwc2/hcd.c
@@ -2679,8 +2679,15 @@ static void dwc2_hcd_release(struct dwc2_hsotg *hsotg)
dwc2_hcd_free(hsotg);
 }
 
-static void dwc2_set_uninitialized(int *p, int size)
+/*
+ * Sets all parameters to the given value.
+ *
+ * Assumes that the dwc2_core_params struct contains only integers.
+ */
+void dwc2_set_all_params(struct dwc2_core_params *params, int value)
 {
+   int *p = (int *)params;
+   size_t size = sizeof(*params) / sizeof(*p);
int i;
 
for (i = 0; i  size; i++)
@@ -2789,8 +2796,7 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
if (!hsotg-core_params)
goto error1;
 
-   dwc2_set_uninitialized((int *)hsotg-core_params,
-  sizeof(*hsotg-core_params) / sizeof(int));
+   dwc2_set_all_params(hsotg-core_params, -1);
 
/* Validate parameter values */
dwc2_set_parameters(hsotg, params);
diff --git a/drivers/staging/dwc2/hcd.h b/drivers/staging/dwc2/hcd.h
index b9f8780..d071f1a 100644
--- a/drivers/staging/dwc2/hcd.h
+++ b/drivers/staging/dwc2/hcd.h
@@ -452,6 +452,7 @@ extern int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
 extern void dwc2_hcd_remove(struct dwc2_hsotg *hsotg);
 extern int dwc2_set_parameters(struct dwc2_hsotg *hsotg,
   struct dwc2_core_params *params);
+extern void dwc2_set_all_params(struct dwc2_core_params *params, int value);
 
 /* Transaction Execution Functions */
 extern enum dwc2_transaction_type dwc2_hcd_select_transactions(
-- 
1.8.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: USB2.0 disk format failure in windows guest

2013-04-11 Thread Alan Stern
On Wed, 10 Apr 2013, Gonglei (Arei) wrote:

 Hi Alan,
 We pass-throughed USB 2.0 disk to guest using usb-host (qemu option: -device 
 usb-ehci,id=ehci -device usb-host,bus=ehci.0,hostbus=2,hostport=1) on KVM(on 
 linux-3.8.3 or linux-3.0.13) and qemu 1.4.0 ,

Are you sure this disk was using EHCI?  The attached log shows bulk
packet sizes that aren't multiples of 512, which isn't possible in the
middle of a high-speed transfer.

Also, the log doesn't show data for the IN transfers.  Did you remove 
it?

  it worked fine for reading and writing data, but failed when format it in a 
 windows Guest OS such as winXP,win7,win2003. We captured usb operations on 
 Dom0, found below logs:
   ...
 Feb  1 11:17:50 linux-bLKBXy kernel: [66642.325169] usb 6-1: usbdev_do_ioctl: 
 REAPURBNDELAY
 Feb  1 11:17:50 linux-bLKBXy kernel: [66642.325172] usb 6-1: usbdev_do_ioctl: 
 REAPURBNDELAY
 Feb  1 11:17:50 linux-bLKBXy kernel: [66642.325176] usb 6-1: usbdev_do_ioctl: 
 REAPURBNDELAY
 Feb  1 11:17:50 linux-bLKBXy kernel: [66642.326757] usb 6-1: urb complete
 Feb  1 11:17:50 linux-bLKBXy kernel: [66642.326761] usb 6-1: userurb 
 7fa196d04b10, ep2 bulk-out, actual_length 4096 status 0
 Feb  1 11:17:50 linux-bLKBXy kernel: [66642.326780] usb 6-1: usbdev_do_ioctl: 
 REAPURBNDELAY
 Feb  1 11:17:50 linux-bLKBXy kernel: [66642.326787] usb 6-1: usbdev_do_ioctl: 
 REAPURBNDELAY--- stuck here about one minute or 10 seconds
 Feb  1 11:18:50 linux-bLKBXy kernel: [66702.289239] usb 6-1: usbdev_do_ioctl: 
 DISCARDURB --- received a DISCARD instruction
 Feb  1 11:18:50 linux-bLKBXy kernel: [66702.289398] usb 6-1: urb complete
 Feb  1 11:18:50 linux-bLKBXy kernel: [66702.289403] usb 6-1: userurb 
 7fa196d04d00, ep2 bulk-out, actual_length 512 status -2  
 Feb  1 11:18:50 linux-bLKBXy kernel: [66702.289437] usb 6-1: usbdev_do_ioctl: 
 REAPURBNDELAY
 Feb  1 11:18:50 linux-bLKBXy kernel: [66702.289450] usb 6-1: usbdev_do_ioctl: 
 REAPURBNDELAY
 Feb  1 11:18:50 linux-bLKBXy kernel: [66702.428985] usb 6-1: usbdev_do_ioctl: 
 RESET --- received a reset instruction to retry
 
 We are wondering why the usb operation will be stuck one minute and then 
 DISCARD instruction was issued. Was DISCARD instruction triggered by a time 
 out in format software? Any ideas? Thanks.
 
 BTW, We attached usb operation logs:  windows format log (failure)  

What kernel version did you use while recording this log?

This looks like a hardware problem in the disk drive's USB interface or
in the computer's USB controller.  Either the drive stopped accepting
data or else the controller stopped sending data.  After 10 seconds (or
one minute), the command timed out and the URB was cancelled.

To find out exactly what is going wrong, you would need to use a USB 
bus analyzer to monitor the packets as they go across the USB cable.

Alan Stern

P.S.: For recording USB data transfers, it's generally better to use 
usbmon rather than usbfs_snoop.

--
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: ehci-omap: Select USB_PHY

2013-04-11 Thread Alexander Holler

Am 11.04.2013 16:44, schrieb Roger Quadros:


Sorry, but this just will end up with many users having broken configs
because of disabled stuff they don't know why they have to enable them.
And thus with a never ending stream of questions and thus with a needed
FAQ entry.



Alexander,

I agree with you that it can get difficult with users. But it is best for
users do not disable anything they are not familiar with.

As the USB_PHY option doesn't depend on anything, it is safe to select it
from USB_EHCI_HCD_OMAP.

However, the PHY drivers themselves must be selected from the board configs.


Maybe I understood something wrong, but if the OMAP USB driver requires 
CONFIG_USB_PHY (or similiar), it should be selected automatically and 
not just enabled in the board config.


I just had it to often, that I needed to search around why a driver 
doesn't work (or even compiles), just to find out that I need to enable 
some strange config option which wasn't selected automatically. 
Especially with OMAPs. ;)


And this not only occured when disabling options, it often occured by 
just updating the kernel. Suddenly some obscur option was needed too, it 
wasn't selected automatically by make oldconfig, bang. So the argument 
to not remove anything from a board config doesn't help much.


Sorry for the rant. ;)

Regards,

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


RE: [PATCH 1/2] staging: dwc2: don't pass IRQ_LEVEL to devm_request_irq

2013-04-11 Thread Paul Zimmerman
 From: Matthijs Kooijman [mailto:matth...@stdin.nl]
 Sent: Thursday, April 11, 2013 8:53 AM
 
 It seems this flag is intended to pass to irq_set_status_flags, not
 request_irq, and is not available on all architectures. Its value
 corresponds to IRQF_PROBE_SHARED, which shouldn't be needed for this
 driver, so removing this flag should be safe.
 
 Signed-off-by: Matthijs Kooijman matth...@stdin.nl

Acked-by: Paul Zimmerman pa...@synopsys.com

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


RE: [PATCH 2/2] staging: dwc2: register common irq handler in dwc2_core_init

2013-04-11 Thread Paul Zimmerman
 From: Matthijs Kooijman [mailto:matth...@stdin.nl]
 Sent: Thursday, April 11, 2013 8:53 AM
 
 Before, this was initialized in pci.c, after the dwc2_hcd_init was
 called and the interrupts were enabled. This opened up a small time
 window where common interrupts could be triggered, but there was no
 handler for them, causing them to keep triggering infinitely and locking
 up the machine.
 
 On my RT3052 board this bug could be easily reproduced by hardcoding
 the console log level to 8, so that a bunch of debug output from the dwc2
 driver was generated inside this time window. This caused the interrupt
 lockup to occur almost every time.
 
 By requesting the irq inside dwc2_core_init and by disabling interrupts
 before calling dwc2_core_init instead of after, we can be sure the
 handler is registered before the interrupts are enabled, which should
 close this window.
 
 Reported-by: Stephen Warren swar...@wwwdotorg.org
 Signed-off-by: Matthijs Kooijman matth...@stdin.nl

Acked-by: Paul Zimmerman pa...@synopsys.com

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


Re: USB storage disconnects on xHCI only with Renesas host and ASMedia enclosure

2013-04-11 Thread Alan Stern
On Tue, 9 Apr 2013, infernix wrote:

 Hi,
 
 For some time now (at least since 3.0) I have been having issues with an 
 USB3 to Sata enclosure and xHCI. The device (174c:55aa ASMedia 
 Technology Inc) works perfectly fine on USB2 ports in Linux, as well as 
 on the NEC/Renesas uPD720200(A) USB3 controller in Windows, but not so 
 on any Linux kernels that I've tried (all mainline).
 
 Today I've built 3.8.6, enabled debugging and usbmon, and I've captured 
 lspci, lsusb, dmesg and usbmon (both text and wireshark) data here: 
 http://dx.infernix.net/renesas/
 
 Device insertion happens around the 21:50:15 mark, and isn't removed 
 during the logs. Some excerpts in no specific order:
 
 Apr  9 21:50:16 believe kernel: sd 7:0:0:0: [sdc] 976773168 512-byte 
 logical blocks: (500 GB/465 GiB)
 ..
 Apr  9 21:50:16 believe kernel: xhci_hcd :07:00.0: WARN halted 
 endpoint, queueing URB anyway.

These messages appear to be bugs, either in the xHCI hardware or in the 
driver.  They appear immediately after the endpoint halt was cleared, 
so they are obviously wrong.

 ..
 Apr  9 21:50:59 believe kernel: xhci_hcd :07:00.0: Stalled endpoint
 ..
 Apr  9 21:51:30 believe udevd[23487]: timeout: killing '/sbin/blkid -o 
 udev -p /dev/sdc' [23924]
 ..
 Apr  9 21:52:52 believe kernel: usb 4-2: device not accepting address 6, 
 error -22
 ..
 Apr  9 21:52:54 believe kernel: hub 4-0:1.0: logical disconnect on port 2
 ..
 Apr  9 21:52:54 believe kernel: usb-storage: usb_stor_post_reset
 
 It constantly cycles into resets.

That appears to be the real problem.  I can't tell what's going on but 
maybe Sarah can.

Sarah, look at what the dmesg log says around timestamp 21:51:00:

Apr  9 21:51:00 believe kernel: xhci_hcd :07:00.0: Port Status Change Event 
for port 2
Apr  9 21:51:00 believe kernel: xhci_hcd :07:00.0: handle_port_status: 
starting port polling.
Apr  9 21:51:00 believe kernel: hub 4-0:1.0: state 7 ports 2 chg  evt 0004
Apr  9 21:51:00 believe kernel: xhci_hcd :07:00.0: get port status, actual 
port 1 status  = 0x202c0
Apr  9 21:51:00 believe kernel: xhci_hcd :07:00.0: Get port status returned 
0x102c0
Apr  9 21:51:00 believe kernel: xhci_hcd :07:00.0: clear port connect 
change, actual port 1 status  = 0x2c0
Apr  9 21:51:00 believe kernel: hub 4-0:1.0: warm reset port 2
Apr  9 21:51:00 believe kernel: usb-storage: usb_stor_pre_reset
Apr  9 21:51:00 believe kernel: xhci_hcd :07:00.0: xhci_hub_status_data: 
stopping port polling.
Apr  9 21:51:00 believe kernel: xhci_hcd :07:00.0: Port Status Change Event 
for port 2
Apr  9 21:51:00 believe kernel: xhci_hcd :07:00.0: handle_port_status: 
starting port polling.
Apr  9 21:51:30 believe kernel: usb-storage: command_abort called

What's up with all that?  The port polling persists for 30 seconds 
because usb-storage's pre_reset routine has to wait for the current 
command to finish, and the command doesn't finish until there's either 
an error or a timeout.  In this case the command timed out -- that's 
the reason for the 30-second delay.

But why wasn't there an immediate error?  Evidently a port-connect 
change occurred.  It should have caused the bulk-IN URB to complete 
right away with an error.  After all, how can the device respond to 
poll packets if it isn't connected?

We have seen this same problem reported before by other people.

  From time to time in previous kernels 
 I was able to mount it and copy some data, but after seconds of copying 
 data it would reset and it would lose the SCSI device. With 3.8.6 I 
 can't even do an fdisk -l /dev/sdc because it will just reset before 
 that even happens. Plug it into an USB2 port and all is well with the 
 world. Boot to Windows on USB3 and I can copy data with 100MByte/s to 
 and from it.
 
 Is this device not working properly in Linux due to lack of vendor 
 documentation for the USB3 controller, or is something else going on 
 here? Could someone please shed some light on this?

I don't know the answers, but obviously something is wrong in the 
interaction among the driver, the controller, and the device.

Alan Stern

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


Re: [PATCH] USB: ehci-omap: Select USB_PHY

2013-04-11 Thread Felipe Balbi
Hi,

On Thu, Apr 11, 2013 at 07:33:32PM +0200, Alexander Holler wrote:
 Sorry, but this just will end up with many users having broken configs
 because of disabled stuff they don't know why they have to enable them.
 And thus with a never ending stream of questions and thus with a needed
 FAQ entry.
 
 
 Alexander,
 
 I agree with you that it can get difficult with users. But it is best for
 users do not disable anything they are not familiar with.
 
 As the USB_PHY option doesn't depend on anything, it is safe to select it
 from USB_EHCI_HCD_OMAP.
 
 However, the PHY drivers themselves must be selected from the board configs.
 
 Maybe I understood something wrong, but if the OMAP USB driver
 requires CONFIG_USB_PHY (or similiar), it should be selected
 automatically and not just enabled in the board config.

and who said OMAP USB depends on CONFIG_USB_PHY ? Some platforms need to
control a PHY and some don't.

 I just had it to often, that I needed to search around why a driver
 doesn't work (or even compiles), just to find out that I need to
 enable some strange config option which wasn't selected
 automatically. Especially with OMAPs. ;)

so ? Send a patch fixing it, those are really welcome. You see, it's
very difficult to get all of this perfectly right and if people continue
to rant rather than fix, we will get nowhere.

 And this not only occured when disabling options, it often occured by
 just updating the kernel. Suddenly some obscur option was needed too,
 it wasn't selected automatically by make oldconfig, bang. So the
 argument to not remove anything from a board config doesn't help
 much.

blablabla, Kconfig changes are *always* necessary. Specially when we
need to re-design an entire API because the previous one was just a
*SINGLE* global pointer.

Go check out kernel 2.6.39 (maybe even 3.1 and 3.2) and you'll see that
we're much better off today where we can actually have multiple PHY
drivers and multiple UDC drivers enabled (either as modules or
built-in), but the fact is that changing all of this over takes time and
sometimes people make mistakes, but that's alright, since we have the
-rc series to catch those unwanted errors.

Without the help of the rest of the community, though, it'll just get
slower and slower. With the whole single zImage effort going on in the
ARM land, things have gotten much more critical WRT getting rid of
selects and turning legacy drivers into real drivers, not just a
bunch of exported functions which a single architecture uses.

Add to that all the rework going on in the Gadget Framework, PHY layer
and EHCI drivers (which now has a core re-usable library thanks to Alan
Stern) and you have a lot of work to do.

Next time you consider ranting about something, use that 'frustration'
and turn it into motivation to write patches, then we all win. Also
consider that under drivers/usb/ alone we have 270K LOCs, and that's
quite a lot of code to handle with only a few of us (Greg, Sarah, Alan,
Alex and myself) being the gateway towards mainline.

With all that comes the responsibility of revieweing drivers for
architectures we, most of the times, don't have access to with drivers
that only compile in some ceratin ways.

Cleaning all of that takes time. Look at all the effort it's taking the
Chipidea folks just to get rid of a couple copies of the chipidea
driver. It takes time, it takes sweat and we can all use some help
rather than some random rant.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 3/4] staging: dwc2: add platform device bindings

2013-04-11 Thread Felipe Balbi
On Thu, Apr 11, 2013 at 06:43:48PM +0200, Matthijs Kooijman wrote:
 This adds a dwc_platform.ko module that can be loaded by using
 compatible = snps,dwc2 in a device tree.
 
 Signed-off-by: Matthijs Kooijman matth...@stdin.nl
 ---
  Documentation/devicetree/bindings/staging/dwc2.txt |  15 +++
  drivers/staging/dwc2/Kconfig   |   6 +-
  drivers/staging/dwc2/Makefile  |   2 +
  drivers/staging/dwc2/platform.c| 150 
 +
  4 files changed, 171 insertions(+), 2 deletions(-)
  create mode 100644 Documentation/devicetree/bindings/staging/dwc2.txt
  create mode 100644 drivers/staging/dwc2/platform.c
 
 diff --git a/Documentation/devicetree/bindings/staging/dwc2.txt 
 b/Documentation/devicetree/bindings/staging/dwc2.txt
 new file mode 100644
 index 000..3649c88
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/staging/dwc2.txt
 @@ -0,0 +1,15 @@
 +Platform DesignWare HS OTG USB 2.0 controller
 +-
 +
 +Required properties:
 +- compatible : snps,dwc2

please use the company's full name - synopsys.

 +- reg : Should contain 1 register range (address and length)
 +- interrupts : Should contain 1 interrupt
 +
 +Example:
 +
 +otg@101c {

this should probably be 'usb' instead of 'otg'

 +static int dwc2_driver_remove(struct platform_device *dev)
 +{
 + struct dwc2_hsotg *hsotg = platform_get_drvdata(dev);
 +
 + dev_dbg(dev-dev, %s(%p)\n, __func__, dev);

I don't think you need this dev_dbg() line.

 +static int dwc2_driver_probe(struct platform_device *dev)
 +{
 + struct dwc2_hsotg *hsotg;
 + struct resource *res;
 + int retval;
 + int irq;
 + struct dwc2_core_params params;
 +
 + /* Default all params to autodetect */
 + dwc2_set_all_params(params, -1);
 +
 + dev_dbg(dev-dev, %s(%p)\n, __func__, dev);

neither this one.

 + hsotg = devm_kzalloc(dev-dev, sizeof(*hsotg), GFP_KERNEL);
 + if (!hsotg)
 + return -ENOMEM;
 +
 + hsotg-dev = dev-dev;
 +
 + irq = platform_get_irq(dev, 0);
 + if (irq  0) {
 + dev_err(dev-dev, missing IRQ resource\n);
 + return -EINVAL;
 + }
 +
 + res = platform_get_resource(dev, IORESOURCE_MEM, 0);
 + if (!res) {
 + dev_err(dev-dev, missing memory base resource\n);
 + return -EINVAL;
 + }
 +
 + hsotg-regs = devm_ioremap_resource(dev-dev, res);
 + if (IS_ERR(hsotg-regs))
 + return PTR_ERR(hsotg-regs);
 +
 + dev_dbg(dev-dev, mapped PA %08lx to VA %p\n,
 + (unsigned long)res-start, hsotg-regs);
 +
 + retval = dwc2_hcd_init(hsotg, irq, params);
 + if (retval)
 + return retval;
 +
 + platform_set_drvdata(dev, hsotg);
 + dev_dbg(dev-dev, hsotg=%p\n, hsotg);

or this.

 +MODULE_AUTHOR(Synopsys, Inc.);

isn't MODULE_AUTHOR(Matthijs Kooijman matth...@stdin.nl) more
appropriate ?

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 4/4] staging: dwc2: load parameters from the devicetree

2013-04-11 Thread Felipe Balbi
Hi,

On Thu, Apr 11, 2013 at 06:43:49PM +0200, Matthijs Kooijman wrote:
 diff --git a/Documentation/devicetree/bindings/staging/dwc2.txt 
 b/Documentation/devicetree/bindings/staging/dwc2.txt
 index 3649c88..05d9c08 100644
 --- a/Documentation/devicetree/bindings/staging/dwc2.txt
 +++ b/Documentation/devicetree/bindings/staging/dwc2.txt
 @@ -5,6 +5,39 @@ Required properties:
  - compatible : snps,dwc2
  - reg : Should contain 1 register range (address and length)
  - interrupts : Should contain 1 interrupt
 +Optional properties:
 + - dma-enable
 + - otg-cap
 + - otg-ver
 + - dma-enable
 + - dma-desc-enable
 + - speed
 + - enable-dynamic-fifo
 + - en-multiple-tx-fifo
 + - host-rx-fifo-size
 + - host-nperio-tx-fifo-size
 + - host-perio-tx-fifo-size
 + - max-transfer-size
 + - max-packet-count
 + - host-channels
 + - phy-type
 + - phy-utmi-width
 + - phy-ulpi-ddr
 + - phy-ulpi-ext-vbus
 + - i2c-enable
 + - ulpi-fs-ls
 + - host-support-fs-ls-low-power
 + - host-ls-low-power-phy-clk
 + - ts-dline
 + - reload-ctl
 + - ahb-single

are you 110% sure you want all of these parameters ? You will have to
support them forever once it gets accepted in mainline kernel. After DT
is accepted, it's really, really hard to change.

 @@ -12,4 +45,7 @@ Example:
  compatible = ralink,rt3050-otg, snps,dwc2;
  reg = 0x101c 4;
  interrupts = 18;
 +
 + # Force slave mode, even when dma is advertised to work
 + dma-enable = 0;

looks like a test feature.

 diff --git a/drivers/staging/dwc2/platform.c b/drivers/staging/dwc2/platform.c
 index e65fa0d..9e05865 100644
 --- a/drivers/staging/dwc2/platform.c
 +++ b/drivers/staging/dwc2/platform.c
 @@ -40,6 +40,8 @@
  #include linux/device.h
  #include linux/dma-mapping.h
  #include linux/platform_device.h
 +#include linux/of.h
 +#include asm/byteorder.h

can you use the generic header instead ?

-- 
balbi


signature.asc
Description: Digital signature


Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs

2013-04-11 Thread Mike Turquette
Quoting Nishanth Menon (2013-04-10 10:39:21)
 diff --git a/drivers/clk/omap/clk.c b/drivers/clk/omap/clk.c
 new file mode 100644
 index 000..63a4cce
 --- /dev/null
 +++ b/drivers/clk/omap/clk.c
 @@ -0,0 +1,94 @@
 +/*
 + * Texas Instruments OMAP Clock driver
 + *
 + * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
 + * Nishanth Menon
 + * Tony Lindgren t...@atomide.com
 + *
 + * 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.
 + *
 + * This program is distributed as is WITHOUT ANY WARRANTY of any
 + * kind, whether express or implied; without even the implied warranty
 + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + */
 +
 +#include linux/clkdev.h
 +#include linux/clk-private.h

Please use clk-provider.h.  Otherwise this looks like an OK transitional
solution.  Hopefully this will be replaced with a more legitimate clock
driver for 3.11.

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


RE: [PATCH 3/4] staging: dwc2: add platform device bindings

2013-04-11 Thread Paul Zimmerman
 From: Felipe Balbi [mailto:ba...@ti.com]
 Sent: Thursday, April 11, 2013 11:36 AM
 
 On Thu, Apr 11, 2013 at 06:43:48PM +0200, Matthijs Kooijman wrote:
  This adds a dwc_platform.ko module that can be loaded by using
  compatible = snps,dwc2 in a device tree.
 
  Signed-off-by: Matthijs Kooijman matth...@stdin.nl
  ---
   Documentation/devicetree/bindings/staging/dwc2.txt |  15 +++
   drivers/staging/dwc2/Kconfig   |   6 +-
   drivers/staging/dwc2/Makefile  |   2 +
   drivers/staging/dwc2/platform.c| 150 
  +
   4 files changed, 171 insertions(+), 2 deletions(-)
   create mode 100644 Documentation/devicetree/bindings/staging/dwc2.txt
   create mode 100644 drivers/staging/dwc2/platform.c
 
  diff --git a/Documentation/devicetree/bindings/staging/dwc2.txt 
  b/Documentation/devicetree/bindings/staging/dwc2.txt
  new file mode 100644
  index 000..3649c88
  --- /dev/null
  +++ b/Documentation/devicetree/bindings/staging/dwc2.txt
  @@ -0,0 +1,15 @@
  +Platform DesignWare HS OTG USB 2.0 controller
  +-
  +
  +Required properties:
  +- compatible : snps,dwc2
 
 please use the company's full name - synopsys.

Actually, if you grep the tree for 'snps' vs. 'synopsys', you will see
that 'snps' is much more common in dt bindings. So I would suggest that
this is actually more correct, and the few outliers using 'synopsys'
should be converted.

  +- reg : Should contain 1 register range (address and length)
  +- interrupts : Should contain 1 interrupt
  +
  +Example:
  +
  +otg@101c {
 
 this should probably be 'usb' instead of 'otg'
 
  +static int dwc2_driver_remove(struct platform_device *dev)
  +{
  +   struct dwc2_hsotg *hsotg = platform_get_drvdata(dev);
  +
  +   dev_dbg(dev-dev, %s(%p)\n, __func__, dev);
 
 I don't think you need this dev_dbg() line.
 
  +static int dwc2_driver_probe(struct platform_device *dev)
  +{
  +   struct dwc2_hsotg *hsotg;
  +   struct resource *res;
  +   int retval;
  +   int irq;
  +   struct dwc2_core_params params;
  +
  +   /* Default all params to autodetect */
  +   dwc2_set_all_params(params, -1);
  +
  +   dev_dbg(dev-dev, %s(%p)\n, __func__, dev);
 
 neither this one.
 
  +   hsotg = devm_kzalloc(dev-dev, sizeof(*hsotg), GFP_KERNEL);
  +   if (!hsotg)
  +   return -ENOMEM;
  +
  +   hsotg-dev = dev-dev;
  +
  +   irq = platform_get_irq(dev, 0);
  +   if (irq  0) {
  +   dev_err(dev-dev, missing IRQ resource\n);
  +   return -EINVAL;
  +   }
  +
  +   res = platform_get_resource(dev, IORESOURCE_MEM, 0);
  +   if (!res) {
  +   dev_err(dev-dev, missing memory base resource\n);
  +   return -EINVAL;
  +   }
  +
  +   hsotg-regs = devm_ioremap_resource(dev-dev, res);
  +   if (IS_ERR(hsotg-regs))
  +   return PTR_ERR(hsotg-regs);
  +
  +   dev_dbg(dev-dev, mapped PA %08lx to VA %p\n,
  +   (unsigned long)res-start, hsotg-regs);
  +
  +   retval = dwc2_hcd_init(hsotg, irq, params);
  +   if (retval)
  +   return retval;
  +
  +   platform_set_drvdata(dev, hsotg);
  +   dev_dbg(dev-dev, hsotg=%p\n, hsotg);
 
 or this.
 
  +MODULE_AUTHOR(Synopsys, Inc.);
 
 isn't MODULE_AUTHOR(Matthijs Kooijman matth...@stdin.nl) more
 appropriate ?

Yes, I agree.

-- 
Paul

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


Re: [PATCH 3/4] staging: dwc2: add platform device bindings

2013-04-11 Thread Matthijs Kooijman
Hi Felipe,

thanks for your comments.

On Thu, Apr 11, 2013 at 09:36:23PM +0300, Felipe Balbi wrote:
 On Thu, Apr 11, 2013 at 06:43:48PM +0200, Matthijs Kooijman wrote:
  This adds a dwc_platform.ko module that can be loaded by using
  compatible = snps,dwc2 in a device tree.
  
  Signed-off-by: Matthijs Kooijman matth...@stdin.nl
[]
  +Required properties:
  +- compatible : snps,dwc2
 
 please use the company's full name - synopsys.

I've done as documented:

$ cat Documentation/devicetree/bindings/vendor-prefixes.txt | grep Synopsys
snpsSynopsys, Inc.

Further grepping shows that only dwc3 uses synopsys, all others use
snps.

  +- reg : Should contain 1 register range (address and length)
  +- interrupts : Should contain 1 interrupt
  +
  +Example:
  +
  +otg@101c {
 
 this should probably be 'usb' instead of 'otg'
This is what the mips folks have in their upcoming version in the
arch/mips/ralink/dts/rt3050.dtsi file, but I'm happy to change this for
just the example.

  +static int dwc2_driver_remove(struct platform_device *dev)
  +{
  +   struct dwc2_hsotg *hsotg = platform_get_drvdata(dev);
  +
  +   dev_dbg(dev-dev, %s(%p)\n, __func__, dev);
 
 I don't think you need this dev_dbg() line.
[]
  +   dev_dbg(dev-dev, %s(%p)\n, __func__, dev);
 
 neither this one.
 
[]
  +   dev_dbg(dev-dev, hsotg=%p\n, hsotg);
 
 or this.

These are just copied from pci.c, to make these as similar as possible.
I can drop them and send a patch to drop them from pci.c as well, since
I agree they're rather pointless.

  +MODULE_AUTHOR(Synopsys, Inc.);
 
 isn't MODULE_AUTHOR(Matthijs Kooijman matth...@stdin.nl) more
 appropriate ?
It started out as a copy of pci.c, which is why I left this in. Changing
it would probably make sense now, yes.

I'll wait for Paul to have a look and then send an updated version.

Gr.

Matthijs
--
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 4/4] staging: dwc2: load parameters from the devicetree

2013-04-11 Thread Matthijs Kooijman
Hi Felipe,

On Thu, Apr 11, 2013 at 09:39:26PM +0300, Felipe Balbi wrote:
 On Thu, Apr 11, 2013 at 06:43:49PM +0200, Matthijs Kooijman wrote:
[devicetree params]
  + - ahb-single
 
 are you 110% sure you want all of these parameters ? You will have to
 support them forever once it gets accepted in mainline kernel. After DT
 is accepted, it's really, really hard to change.
I had in mind to revisit this list when the drivers leaves staging, just
like the debug prints in the code are intended to be stripped later on.
For now, I just added whatever params are available (which is what used
to be module params before).

Perhaps it is ok like this with a notice about this in the bindings
documentation?

 
  @@ -12,4 +45,7 @@ Example:
   compatible = ralink,rt3050-otg, snps,dwc2;
   reg = 0x101c 4;
   interrupts = 18;
  +
  +   # Force slave mode, even when dma is advertised to work
  +   dma-enable = 0;
 
 looks like a test feature.
Yeah, I guess it is.

 
  diff --git a/drivers/staging/dwc2/platform.c 
  b/drivers/staging/dwc2/platform.c
  index e65fa0d..9e05865 100644
  --- a/drivers/staging/dwc2/platform.c
  +++ b/drivers/staging/dwc2/platform.c
  @@ -40,6 +40,8 @@
   #include linux/device.h
   #include linux/dma-mapping.h
   #include linux/platform_device.h
  +#include linux/of.h
  +#include asm/byteorder.h
 
 can you use the generic header instead ?
Which one would that be? asm/byteorder.h seems to be used by most
drivers?

Gr.

Matthijs
--
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 4/4] staging: dwc2: load parameters from the devicetree

2013-04-11 Thread Paul Zimmerman
 From: Felipe Balbi [mailto:ba...@ti.com]
 Sent: Thursday, April 11, 2013 11:39 AM
 
 On Thu, Apr 11, 2013 at 06:43:49PM +0200, Matthijs Kooijman wrote:
  diff --git a/Documentation/devicetree/bindings/staging/dwc2.txt 
  b/Documentation/devicetree/bindings/staging/dwc2.txt
  index 3649c88..05d9c08 100644
  --- a/Documentation/devicetree/bindings/staging/dwc2.txt
  +++ b/Documentation/devicetree/bindings/staging/dwc2.txt
  @@ -5,6 +5,39 @@ Required properties:
   - compatible : snps,dwc2
   - reg : Should contain 1 register range (address and length)
   - interrupts : Should contain 1 interrupt
  +Optional properties:
  + - dma-enable
  + - otg-cap
  + - otg-ver
  + - dma-enable
  + - dma-desc-enable
  + - speed
  + - enable-dynamic-fifo
  + - en-multiple-tx-fifo
  + - host-rx-fifo-size
  + - host-nperio-tx-fifo-size
  + - host-perio-tx-fifo-size
  + - max-transfer-size
  + - max-packet-count
  + - host-channels
  + - phy-type
  + - phy-utmi-width
  + - phy-ulpi-ddr
  + - phy-ulpi-ext-vbus
  + - i2c-enable
  + - ulpi-fs-ls
  + - host-support-fs-ls-low-power
  + - nhost-ls-low-power-phy-clk
  + - ts-dline
  + - reload-ctl
  + - ahb-single
 
 are you 110% sure you want all of these parameters ? You will have to
 support them forever once it gets accepted in mainline kernel. After DT
 is accepted, it's really, really hard to change.

Sadly, a lot of these are actually required. But Matthijs, I believe
several of these (otg-cap, otg-ver, ts-dline?) are only for peripheral
mode, so they could be removed for now, and only brought back if needed
when peripheral mode is implemented. And I think a couple of others
(reload-ctl, ?) are not actually used in the driver, so they could be
removed.

And I agree with Felipe that 'speed' is only for debugging, so it
doesn't belong in dt.

-- 
Paul

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


Re: [PATCH 3/4] staging: dwc2: add platform device bindings

2013-04-11 Thread Felipe Balbi
Hi,

On Thu, Apr 11, 2013 at 09:15:28PM +0200, Matthijs Kooijman wrote:
 Hi Felipe,
 
 thanks for your comments.
 
 On Thu, Apr 11, 2013 at 09:36:23PM +0300, Felipe Balbi wrote:
  On Thu, Apr 11, 2013 at 06:43:48PM +0200, Matthijs Kooijman wrote:
   This adds a dwc_platform.ko module that can be loaded by using
   compatible = snps,dwc2 in a device tree.
   
   Signed-off-by: Matthijs Kooijman matth...@stdin.nl
 []
   +Required properties:
   +- compatible : snps,dwc2
  
  please use the company's full name - synopsys.
 
 I've done as documented:
 
 $ cat Documentation/devicetree/bindings/vendor-prefixes.txt | grep Synopsys
 snpsSynopsys, Inc.
 
 Further grepping shows that only dwc3 uses synopsys, all others use
 snps.

fair enough, in that case I'll fix dwc3 for v3.10. A bit odd not to use
the full name, though, but meh..

   +static int dwc2_driver_remove(struct platform_device *dev)
   +{
   + struct dwc2_hsotg *hsotg = platform_get_drvdata(dev);
   +
   + dev_dbg(dev-dev, %s(%p)\n, __func__, dev);
  
  I don't think you need this dev_dbg() line.
 []
   + dev_dbg(dev-dev, %s(%p)\n, __func__, dev);
  
  neither this one.
  
 []
   + dev_dbg(dev-dev, hsotg=%p\n, hsotg);
  
  or this.
 
 These are just copied from pci.c, to make these as similar as possible.
 I can drop them and send a patch to drop them from pci.c as well, since
 I agree they're rather pointless.

right, makes sense to me.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 4/4] staging: dwc2: load parameters from the devicetree

2013-04-11 Thread Marc Kleine-Budde
On 04/11/2013 06:43 PM, Matthijs Kooijman wrote:
 Each of the parameters in the dwc2_core_params struct can now be changed
 using devicetree parameters.
 
 Signed-off-by: Matthijs Kooijman matth...@stdin.nl
 ---
  Documentation/devicetree/bindings/staging/dwc2.txt |  36 
  drivers/staging/dwc2/platform.c| 100 
 +
  2 files changed, 136 insertions(+)
 
 This just adds all existing parameters to the devicetree for now. It's
 not unlikely that some of these parameters gets dropped later or turn
 out to be unsuitable for setting from the devicetree, but for now I've
 just added them all without closely looking at each.
 
 diff --git a/Documentation/devicetree/bindings/staging/dwc2.txt 
 b/Documentation/devicetree/bindings/staging/dwc2.txt
 index 3649c88..05d9c08 100644
 --- a/Documentation/devicetree/bindings/staging/dwc2.txt
 +++ b/Documentation/devicetree/bindings/staging/dwc2.txt
 @@ -5,6 +5,39 @@ Required properties:
  - compatible : snps,dwc2
  - reg : Should contain 1 register range (address and length)
  - interrupts : Should contain 1 interrupt
 +Optional properties:
 + - dma-enable
 + - otg-cap
 + - otg-ver
 + - dma-enable
 + - dma-desc-enable
 + - speed
 + - enable-dynamic-fifo
 + - en-multiple-tx-fifo
 + - host-rx-fifo-size
 + - host-nperio-tx-fifo-size
 + - host-perio-tx-fifo-size
 + - max-transfer-size
 + - max-packet-count
 + - host-channels
 + - phy-type
 + - phy-utmi-width
 + - phy-ulpi-ddr
 + - phy-ulpi-ext-vbus
 + - i2c-enable
 + - ulpi-fs-ls
 + - host-support-fs-ls-low-power
 + - host-ls-low-power-phy-clk
 + - ts-dline
 + - reload-ctl
 + - ahb-single
 +
 +Each of the above properties take a single cell containing an integer. See
 +struct dwc2_core_params in dwc2/core.h for their meanings and possible 
 values.
 +
 +If absent, these values have either a driver default or are autodetected.
 +Where possible, the values set through the devicetree are checked against
 +hardware limits and automatically capped or adjusted as needed.
  
  Example:
  
 @@ -12,4 +45,7 @@ Example:
  compatible = ralink,rt3050-otg, snps,dwc2;
  reg = 0x101c 4;
  interrupts = 18;
 +
 + # Force slave mode, even when dma is advertised to work
 + dma-enable = 0;
  };
 diff --git a/drivers/staging/dwc2/platform.c b/drivers/staging/dwc2/platform.c
 index e65fa0d..9e05865 100644
 --- a/drivers/staging/dwc2/platform.c
 +++ b/drivers/staging/dwc2/platform.c
 @@ -40,6 +40,8 @@
  #include linux/device.h
  #include linux/dma-mapping.h
  #include linux/platform_device.h
 +#include linux/of.h
 +#include asm/byteorder.h
  
  #include core.h
  #include hcd.h
 @@ -69,6 +71,101 @@ static int dwc2_driver_remove(struct platform_device *dev)
  }
  
  /**
 + * dwc2_load_property() - Load a single property from the devicetree
 + * node into the given variable.
 + *
 + * @dev: Platform device
 + * @res: The variable to put the loaded value into
 + * @name: The name of the devicetree property to load
 + */
 +static void dwc2_load_property(struct platform_device *dev, int *res,
 +const char *name)
 +{
 + int len;
 + const u32 *val;
 +
 + val = of_get_property(dev-dev.of_node, name, len);
 + if (!val)
 + return;
 +
 + if (len != sizeof(*val)) {
 + dev_warn(dev-dev,
 +  Invalid value in devicetree for %s property, should 
 be a single integer\n,
 +  name);
 + return;
 + }
 +
 + *res = be32_to_cpu(*val);

What about using of_property_read_u32() instead of open coding it here?

 +
 + dev_dbg(dev-dev, Loaded %s parameter from devicetree: %d\n,
 + name, *res);
 +}

Marc


-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


Re: [PATCH 4/4] staging: dwc2: load parameters from the devicetree

2013-04-11 Thread Felipe Balbi
On Thu, Apr 11, 2013 at 09:19:37PM +0200, Matthijs Kooijman wrote:
 Hi Felipe,
 
 On Thu, Apr 11, 2013 at 09:39:26PM +0300, Felipe Balbi wrote:
  On Thu, Apr 11, 2013 at 06:43:49PM +0200, Matthijs Kooijman wrote:
 [devicetree params]
   + - ahb-single
  
  are you 110% sure you want all of these parameters ? You will have to
  support them forever once it gets accepted in mainline kernel. After DT
  is accepted, it's really, really hard to change.
 I had in mind to revisit this list when the drivers leaves staging, just
 like the debug prints in the code are intended to be stripped later on.
 For now, I just added whatever params are available (which is what used
 to be module params before).
 
 Perhaps it is ok like this with a notice about this in the bindings
 documentation?

perhaps, since this is still in staging.

   @@ -12,4 +45,7 @@ Example:
compatible = ralink,rt3050-otg, snps,dwc2;
reg = 0x101c 4;
interrupts = 18;
   +
   + # Force slave mode, even when dma is advertised to work
   + dma-enable = 0;
  
  looks like a test feature.
 Yeah, I guess it is.
 
  
   diff --git a/drivers/staging/dwc2/platform.c 
   b/drivers/staging/dwc2/platform.c
   index e65fa0d..9e05865 100644
   --- a/drivers/staging/dwc2/platform.c
   +++ b/drivers/staging/dwc2/platform.c
   @@ -40,6 +40,8 @@
#include linux/device.h
#include linux/dma-mapping.h
#include linux/platform_device.h
   +#include linux/of.h
   +#include asm/byteorder.h
  
  can you use the generic header instead ?
 Which one would that be? asm/byteorder.h seems to be used by most
 drivers?

right, I was under the impression that linux/byteorder/generic.h
should be used instead of asm/byteorder.h which isn't provided by all
arches.

-- 
balbi


signature.asc
Description: Digital signature


  1   2   >