Re: [PATCH] usb: gadget: nokia: Add mass storage driver to g_nokia

2015-05-28 Thread Pali Rohár
On Thursday 28 May 2015 18:34:31 Felipe Balbi wrote:
 On Thu, May 28, 2015 at 04:59:18PM +0200, Pali Rohár wrote:
  On Thursday 28 May 2015 16:51:07 Krzysztof Opasiak wrote:
   On 05/28/2015 04:31 PM, Pali Rohár wrote:
   On Thursday 28 May 2015 16:27:44 Krzysztof Opasiak wrote:
   On 05/28/2015 09:47 AM, Pali Rohár wrote:
   On Saturday 31 January 2015 10:53:30 Pali Rohár wrote:
   This patch adds removable mass storage support to g_nokia
   gadget (for N900). It means that at runtime block device can
   be exported or unexported. So it does not export anything by
   default and thus allows to use MyDocs partition as before...
   
   Signed-off-by: Pali Rohár pali.ro...@gmail.com
   ---
   
 drivers/usb/gadget/legacy/Kconfig |1 +
 drivers/usb/gadget/legacy/nokia.c |  102
 - 2 files changed, 102
 insertions(+), 1 deletion(-)
   
   diff --git a/drivers/usb/gadget/legacy/Kconfig
   b/drivers/usb/gadget/legacy/Kconfig index fd48ef3..36f6ba4
   100644
   --- a/drivers/usb/gadget/legacy/Kconfig
   +++ b/drivers/usb/gadget/legacy/Kconfig
   @@ -345,6 +345,7 @@ config USB_G_NOKIA
   
 select USB_F_OBEX
 select USB_F_PHONET
 select USB_F_ECM
   
   + select USB_F_MASS_STORAGE
   
 help
 
   The Nokia composite gadget provides support for acm,
   obex and phonet in only one composite gadget driver.
   
   diff --git a/drivers/usb/gadget/legacy/nokia.c
   b/drivers/usb/gadget/legacy/nokia.c index 9b8fd70..a09bb50
   100644
   --- a/drivers/usb/gadget/legacy/nokia.c
   +++ b/drivers/usb/gadget/legacy/nokia.c
   @@ -24,6 +24,7 @@
   
 #include u_phonet.h
 #include u_ecm.h
 #include gadget_chips.h
   
   +#include f_mass_storage.h
   
 /* Defines */
   
   @@ -34,6 +35,29 @@ USB_GADGET_COMPOSITE_OPTIONS();
   
 USB_ETHERNET_MODULE_PARAMETERS();
   
   +static struct fsg_module_parameters fsg_mod_data = {
   + .stall = 0,
   + .luns = 2,
   + .removable_count = 2,
   + .removable = { 1, 1, },
   +};
   +
   +FSG_MODULE_PARAMETERS(/* no prefix */, fsg_mod_data);
   +
   +#ifdef CONFIG_USB_GADGET_DEBUG_FILES
   +
   +static unsigned int fsg_num_buffers =
   CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS; +
   +#else
   +
   +/*
   + * Number of buffers we will use.
   + * 2 is usually enough for good buffering pipeline
   + */
   +#define
   fsg_num_buffers   CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS +
   +#endif /* CONFIG_USB_DEBUG */
   +
   
 #define NOKIA_VENDOR_ID 0x0421  /* Nokia */
 #define NOKIA_PRODUCT_ID0x01c8  /* Nokia Gadget */
   
   @@ -94,6 +118,8 @@ static struct usb_function *f_obex1_cfg2;
   
 static struct usb_function *f_obex2_cfg2;
 static struct usb_function *f_phonet_cfg1;
 static struct usb_function *f_phonet_cfg2;
   
   +static struct usb_function *f_msg_cfg1;
   +static struct usb_function *f_msg_cfg2;
   
 static struct usb_configuration nokia_config_500ma_driver =
 {
   
   @@ -117,6 +143,7 @@ static struct usb_function_instance
   *fi_ecm;
   
 static struct usb_function_instance *fi_obex1;
 static struct usb_function_instance *fi_obex2;
 static struct usb_function_instance *fi_phonet;
   
   +static struct usb_function_instance *fi_msg;
   
 static int __init nokia_bind_config(struct
 usb_configuration *c) {
   
   @@ -125,6 +152,8 @@ static int __init
   nokia_bind_config(struct usb_configuration *c)
   
 struct usb_function *f_obex1 = NULL;
 struct usb_function *f_ecm;
 struct usb_function *f_obex2 = NULL;
   
   + struct usb_function *f_msg;
   + struct fsg_opts *fsg_opts;
   
 int status = 0;
 int obex1_stat = -1;
 int obex2_stat = -1;
   
   @@ -160,6 +189,12 @@ static int __init
   nokia_bind_config(struct usb_configuration *c)
   
 goto err_get_ecm;
 
 }
   
   + f_msg = usb_get_function(fi_msg);
   + if (IS_ERR(f_msg)) {
   + status = PTR_ERR(f_msg);
   + goto err_get_msg;
   + }
   +
   
 if (!IS_ERR_OR_NULL(f_phonet)) {
 
 phonet_stat = usb_add_function(c, f_phonet);
 if (phonet_stat)
   
   @@ -187,21 +222,36 @@ static int __init
   nokia_bind_config(struct usb_configuration *c)
   
 pr_debug(could not bind ecm config %d\n, status);
 goto err_ecm;
 
 }
   
   +
   + fsg_opts = fsg_opts_from_func_inst(fi_msg);
   +
   + status = fsg_common_run_thread(fsg_opts-common);
   + if (status)
   + goto err_msg;
   +
   + status = usb_add_function(c, f_msg);
   + if (status)
   + goto err_msg;
   +
   
 if (c == nokia_config_500ma_driver) {
 
 f_acm_cfg1 = f_acm;
 f_ecm_cfg1 = f_ecm;
 f_phonet_cfg1 = f_phonet;
 f_obex1_cfg1 = 

Re: USB Host Controller no PCD interrupt and CCS and CSC update on the device disconnect

2015-05-28 Thread Alan Stern
On Thu, 28 May 2015, Rong Wang wrote:

 Thanks for this Device side information. But there's one thing I'm
 still not quite sure
 What's the behavior of the USB device when the VBUS is always present
 while the D+/D- differential signal amplitude exceeds the
 disconnection threshold (525 mV)?

I don't think devices monitor the differential signal amplitude.  That 
is, they don't care if it goes above the disconnection threshold; they 
only care if it is  0 or  0.

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: Disk access keeps causing serial/USB failures?

2015-05-28 Thread Alan Stern
On Thu, 28 May 2015, Marc MERLIN wrote:

 On Tue, May 19, 2015 at 10:56:39AM -0700, Marc MERLIN wrote:
  On Tue, May 19, 2015 at 01:21:30PM -0400, Alan Stern wrote:
   This strongly suggests that the problem lies in the hubs (or in one of 
   them).  Something caused a hub to disconnect, and when that happened 
   all of the serial ports downstream from that hub went along for the 
   ride.
  
  Hi Alan, thanks for your answer.
  
  So, when my serial ports go bad, I detect it on a high level, and one of
  my 4 port serial USB hub was connected into a powered USB hub where I
  can toggle ports on and off.
  In that case, the port got cycled, causing a full reset and things to
  start working again.
  
  But, you made me realize that my 4 and 8 port USB serial hubs are USB
  hubs themselves with 4 or 8 FTDI converts in them.
  So, I plugged the 4 port one directly into the PC (the other one was
  already directly connected too), and added external power to it just in
  case.
  
  We'll see if that helps.
  
 Well, looks like you were right, thank you for helping out.
 
  However, I have many many logs that show that my problems are happening
  during periods of high disk activity, mostly at night when I'm running
  rsync backups, so it still looks like there is a link between the 2.
 
 That was still true though, and I'm not sure how disk access was
 affecting USB reliability, but it was. 

Maybe it caused a change in the available power level.

 Either way, plugging the serial converter hub directly into the PC
 helped for sure.
 
 Thanks again,

You're welcome.

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: ehci_bus_suspend system halt

2015-05-28 Thread Alan Stern
On Thu, 28 May 2015, Michael Trimarchi wrote:

 Hi Alan
 
 we are working on a samsung exysnos5430 device and we have some problem
 during suspend. The only way to solve it seems this patch.
 We don't really know what could be the problem. Do you have any suggestion
 to debug it?
 
 diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
 index c254076..6b01784 100644
 --- a/drivers/usb/host/ehci-hub.c
 +++ b/drivers/usb/host/ehci-hub.c
 @@ -289,14 +289,6 @@ static int ehci_bus_suspend (struct usb_hcd *hcd)
  
   if (t1 != t2) {
   /*
 +  * When suspend bit for PORT 1 is set,
 +  * system halts when spin_unlock_irq()
 +  * called--- why
 +  */

You didn't say what your problem was, but I guess your system halts.
Are you certain the halt occurs when spin_unlock_irq() is called?  Did 
you put printk statements before and after that statement?  Maybe the 
halt actually occurs later.

I have no idea why suspending port 1 should cause the system to halt.  
Does the same problem occur with runtime PM?

Alan Stern

 + if (port == 0  (t1  0x01)) {
 + t2 = ~PORT_SUSPEND;
 + }
 + /*
* On some controllers, Wake-On-Disconnect will
* generate false wakeup signals until the bus
* switches over to full-speed idle.  For their

--
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 v1] usb: dwc2: gadget: fix a memory use-after-free bug

2015-05-28 Thread Yunzhi Li
When s3c_hsotg_handle_unaligned_buf_complete() hs_req-req.buf
already destroyed, in s3c_hsotg_unmap_dma(), it touches
hs_req-req.dma again, so s3c_hsotg_unmap_dma() should be called
before s3c_hsotg_handle_unaligned_buf_complete(). Otherwise, it
will cause a bad_page BUG, when allocate this memory page next
time.

This bug led to the following crash:

BUG: Bad page state in process swapper/0  pfn:2bdbc
[   26.820440] page:eed76780 count:0 mapcount:0 mapping:  (null) index:0x0
[   26.854710] page flags: 0x200(arch_1)
[   26.885836] page dumped because: PAGE_FLAGS_CHECK_AT_PREP flag set
[   26.919179] bad because of flags:
[   26.948917] page flags: 0x200(arch_1)
[   26.979100] Modules linked in:
[   27.008401] CPU: 0 PID: 0 Comm: swapper/0 Tainted: G W3.14.0 #17
[   27.041816] [c010e1f8] (unwind_backtrace) from [c010a704] 
(show_stack+0x20/0x24)
[   27.076108] [c010a704] (show_stack) from [c087eea8] 
(dump_stack+0x70/0x8c)
[   27.110246] [c087eea8] (dump_stack) from [c01ce0b8] (bad_page+0xfc/0x12c)
[   27.143958] [c01ce0b8] (bad_page) from [c01ce65c] 
(get_page_from_freelist+0x3e4/0x50c)
[   27.179298] [c01ce65c] (get_page_from_freelist) from [c01ce9a0] 
(__alloc_pages_nodemask)
[   27.216296] [c01ce9a0] (__alloc_pages_nodemask) from [c01cf00c] 
(__get_free_pages+0x20/)
[   27.252326] [c01cf00c] (__get_free_pages) from [c01e5bec] 
(kmalloc_order_trace+0x34/0xa)
[   27.288295] [c01e5bec] (kmalloc_order_trace) from [c0203304] 
(__kmalloc+0x40/0x1ac)
[   27.323751] [c0203304] (__kmalloc) from [c052abc0] 
(s3c_hsotg_ep_queue.isra.12+0x7c/0x1)
[   27.359937] [c052abc0] (s3c_hsotg_ep_queue.isra.12) from [c052af88] 
(s3c_hsotg_ep_queue)
[   27.397478] [c052af88] (s3c_hsotg_ep_queue_lock) from [c0554110] 
(rx_submit+0xfc/0x164)
[   27.433619] [c0554110] (rx_submit) from [c05546e8] 
(rx_complete+0x22c/0x230)
[   27.468872] [c05546e8] (rx_complete) from [c052b528] 
(s3c_hsotg_complete_request+0xfc/0)
[   27.506240] [c052b528] (s3c_hsotg_complete_request) from [c052bba0] 
(s3c_hsotg_handle_o)
[   27.545401] [c052bba0] (s3c_hsotg_handle_outdone) from [c052be70] 
(s3c_hsotg_epint+0x2c)
[   27.583689] [c052be70] (s3c_hsotg_epint) from [c052c750] 
(s3c_hsotg_irq+0x1dc/0x4ac)
[   27.621041] [c052c750] (s3c_hsotg_irq) from [c01682e0] 
(handle_irq_event_percpu+0x70/0x)
[   27.659066] [c01682e0] (handle_irq_event_percpu) from [c01684ec] 
(handle_irq_event+0x4c)
[   27.697322] [c01684ec] (handle_irq_event) from [c016bae0] 
(handle_fasteoi_irq+0xc8/0x11)
[   27.735451] [c016bae0] (handle_fasteoi_irq) from [c0167b8c] 
(generic_handle_irq+0x30/0x)
[   27.773918] [c0167b8c] (generic_handle_irq) from [c0167ca4] 
(__handle_domain_irq+0x84/0)
[   27.812018] [c0167ca4] (__handle_domain_irq) from [c01003b0] 
(gic_handle_irq+0x48/0x6c)
[   27.849695] [c01003b0] (gic_handle_irq) from [c010b340] 
(__irq_svc+0x40/0x50)
[   27.886907] Exception stack(0xc0d01ee0 to 0xc0d01f28)

Signed-off-by: Yunzhi Li l...@rock-chips.com

---

 drivers/usb/dwc2/gadget.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 6a30887..8070602 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -1389,14 +1389,14 @@ static void s3c_hsotg_complete_request(struct 
dwc2_hsotg *hsotg,
if (hs_req-req.status == -EINPROGRESS)
hs_req-req.status = result;
 
+   if (using_dma(hsotg))
+   s3c_hsotg_unmap_dma(hsotg, hs_ep, hs_req);
+
s3c_hsotg_handle_unaligned_buf_complete(hsotg, hs_ep, hs_req);
 
hs_ep-req = NULL;
list_del_init(hs_req-queue);
 
-   if (using_dma(hsotg))
-   s3c_hsotg_unmap_dma(hsotg, hs_ep, hs_req);
-
/*
 * call the complete request with the locks off, just in case the
 * request tries to queue more work for this endpoint.
-- 
2.0.0


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


Re: [PATCH 8/9] bus: brcmstb_gisb: Honor the big-endian and native-endian DT properties

2015-05-28 Thread Florian Fainelli
Le 11/25/14 16:49, Kevin Cernekee a écrit :
 On chips strapped for BE, we'll need to use ioread32be/iowrite32be instead of
 ioread32/iowrite32.
 
 Signed-off-by: Kevin Cernekee cerne...@gmail.com

Applied to soc/next, thanks!
-- 
Florian
--
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] drivers:usb:fsl: Fix compilation error for fsl ehci drv

2015-05-28 Thread Ramneek Mehresh
Fix compilation error in fsl ehci drv because ehci_reset()
and ehci_adjust_port_wakeup_flags() were not exported, and
are used when PM is enabled

Signed-off-by: Ramneek Mehresh ramneek.mehr...@freescale.com
---
 drivers/usb/host/ehci-hcd.c | 3 ++-
 drivers/usb/host/ehci-hub.c | 3 ++-
 drivers/usb/host/ehci.h | 3 +++
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 9dd161c..c63d82c 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -239,7 +239,7 @@ static void tdi_reset (struct ehci_hcd *ehci)
  * Reset a non-running (STS_HALT == 1) controller.
  * Must be called with interrupts enabled and the lock not held.
  */
-static int ehci_reset (struct ehci_hcd *ehci)
+int ehci_reset(struct ehci_hcd *ehci)
 {
int retval;
u32 command = ehci_readl(ehci, ehci-regs-command);
@@ -275,6 +275,7 @@ static int ehci_reset (struct ehci_hcd *ehci)
ehci-resuming_ports = 0;
return retval;
 }
+EXPORT_SYMBOL_GPL(ehci_reset);
 
 /*
  * Idle the controller (turn off the schedules).
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index 6920844..22abb68 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -155,7 +155,7 @@ static int ehci_port_change(struct ehci_hcd *ehci)
return 0;
 }
 
-static void ehci_adjust_port_wakeup_flags(struct ehci_hcd *ehci,
+void ehci_adjust_port_wakeup_flags(struct ehci_hcd *ehci,
bool suspending, bool do_wakeup)
 {
int port;
@@ -220,6 +220,7 @@ static void ehci_adjust_port_wakeup_flags(struct ehci_hcd 
*ehci,
 
spin_unlock_irq(ehci-lock);
 }
+EXPORT_SYMBOL_GPL(ehci_adjust_port_wakeup_flags);
 
 static int ehci_bus_suspend (struct usb_hcd *hcd)
 {
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index 52ef084..f700157 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -868,10 +868,13 @@ extern void   ehci_init_driver(struct hc_driver *drv,
 extern int ehci_setup(struct usb_hcd *hcd);
 extern int ehci_handshake(struct ehci_hcd *ehci, void __iomem *ptr,
u32 mask, u32 done, int usec);
+extern int ehci_reset(struct ehci_hcd *ehci);
 
 #ifdef CONFIG_PM
 extern int ehci_suspend(struct usb_hcd *hcd, bool do_wakeup);
 extern int ehci_resume(struct usb_hcd *hcd, bool force_reset);
+extern voidehci_adjust_port_wakeup_flags(struct ehci_hcd *ehci,
+   bool suspending, bool do_wakeup);
 #endif /* CONFIG_PM */
 
 extern int ehci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
-- 
1.8.3.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 v1] usb: dwc2: gadget: fix a memory use-after-free bug

2015-05-28 Thread Kaukab, Yousaf
 -Original Message-
 From: Yunzhi Li [mailto:l...@rock-chips.com]
 Sent: Friday, May 29, 2015 1:22 PM
 To: johny...@synopsys.com
 Cc: he...@sntech.de; c...@rock-chips.com; h...@rock-chips.com; yk@rock-
 chips.com; gaura...@google.com; albe...@google.com; w...@rock-chips.com;
 jwer...@chromium.org; jeffy.c...@rock-chips.com; Herrero, Gregory;
 Kaukab, Yousaf; huang...@rock-chips.com; rockchip-disc...@chromium.org;
 Yunzhi Li; Greg Kroah-Hartman; linux-usb@vger.kernel.org; linux-
 ker...@vger.kernel.org
 Subject: [PATCH v1] usb: dwc2: gadget: fix a memory use-after-free bug
 
 When s3c_hsotg_handle_unaligned_buf_complete() hs_req-req.buf already
 destroyed, in s3c_hsotg_unmap_dma(), it touches hs_req-req.dma again, so
 s3c_hsotg_unmap_dma() should be called before
 s3c_hsotg_handle_unaligned_buf_complete(). Otherwise, it will cause a
 bad_page BUG, when allocate this memory page next time.
 
 This bug led to the following crash:
 
 BUG: Bad page state in process swapper/0  pfn:2bdbc
 [   26.820440] page:eed76780 count:0 mapcount:0 mapping:  (null) index:0x0
 [   26.854710] page flags: 0x200(arch_1)
 [   26.885836] page dumped because: PAGE_FLAGS_CHECK_AT_PREP flag set
 [   26.919179] bad because of flags:
 [   26.948917] page flags: 0x200(arch_1)
 [   26.979100] Modules linked in:
 [   27.008401] CPU: 0 PID: 0 Comm: swapper/0 Tainted: G W3.14.0 #17
 [   27.041816] [c010e1f8] (unwind_backtrace) from [c010a704]
 (show_stack+0x20/0x24)
 [   27.076108] [c010a704] (show_stack) from [c087eea8]
 (dump_stack+0x70/0x8c)
 [   27.110246] [c087eea8] (dump_stack) from [c01ce0b8]
 (bad_page+0xfc/0x12c)
 [   27.143958] [c01ce0b8] (bad_page) from [c01ce65c]
 (get_page_from_freelist+0x3e4/0x50c)
 [   27.179298] [c01ce65c] (get_page_from_freelist) from [c01ce9a0]
 (__alloc_pages_nodemask)
 [   27.216296] [c01ce9a0] (__alloc_pages_nodemask) from [c01cf00c]
 (__get_free_pages+0x20/)
 [   27.252326] [c01cf00c] (__get_free_pages) from [c01e5bec]
 (kmalloc_order_trace+0x34/0xa)
 [   27.288295] [c01e5bec] (kmalloc_order_trace) from [c0203304]
 (__kmalloc+0x40/0x1ac)
 [   27.323751] [c0203304] (__kmalloc) from [c052abc0]
 (s3c_hsotg_ep_queue.isra.12+0x7c/0x1)
 [   27.359937] [c052abc0] (s3c_hsotg_ep_queue.isra.12) from [c052af88]
 (s3c_hsotg_ep_queue)
 [   27.397478] [c052af88] (s3c_hsotg_ep_queue_lock) from [c0554110]
 (rx_submit+0xfc/0x164)
 [   27.433619] [c0554110] (rx_submit) from [c05546e8]
 (rx_complete+0x22c/0x230)
 [   27.468872] [c05546e8] (rx_complete) from [c052b528]
 (s3c_hsotg_complete_request+0xfc/0)
 [   27.506240] [c052b528] (s3c_hsotg_complete_request) from [c052bba0]
 (s3c_hsotg_handle_o)
 [   27.545401] [c052bba0] (s3c_hsotg_handle_outdone) from [c052be70]
 (s3c_hsotg_epint+0x2c)
 [   27.583689] [c052be70] (s3c_hsotg_epint) from [c052c750]
 (s3c_hsotg_irq+0x1dc/0x4ac)
 [   27.621041] [c052c750] (s3c_hsotg_irq) from [c01682e0]
 (handle_irq_event_percpu+0x70/0x)
 [   27.659066] [c01682e0] (handle_irq_event_percpu) from [c01684ec]
 (handle_irq_event+0x4c)
 [   27.697322] [c01684ec] (handle_irq_event) from [c016bae0]
 (handle_fasteoi_irq+0xc8/0x11)
 [   27.735451] [c016bae0] (handle_fasteoi_irq) from [c0167b8c]
 (generic_handle_irq+0x30/0x)
 [   27.773918] [c0167b8c] (generic_handle_irq) from [c0167ca4]
 (__handle_domain_irq+0x84/0)
 [   27.812018] [c0167ca4] (__handle_domain_irq) from [c01003b0]
 (gic_handle_irq+0x48/0x6c)
 [   27.849695] [c01003b0] (gic_handle_irq) from [c010b340]
 (__irq_svc+0x40/0x50)
 [   27.886907] Exception stack(0xc0d01ee0 to 0xc0d01f28)
 
 Signed-off-by: Yunzhi Li l...@rock-chips.com
 
 ---
 
  drivers/usb/dwc2/gadget.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
 
 diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index
 6a30887..8070602 100644
 --- a/drivers/usb/dwc2/gadget.c
 +++ b/drivers/usb/dwc2/gadget.c
 @@ -1389,14 +1389,14 @@ static void s3c_hsotg_complete_request(struct
 dwc2_hsotg *hsotg,
   if (hs_req-req.status == -EINPROGRESS)
   hs_req-req.status = result;
 
 + if (using_dma(hsotg))
 + s3c_hsotg_unmap_dma(hsotg, hs_ep, hs_req);
 +
   s3c_hsotg_handle_unaligned_buf_complete(hsotg, hs_ep,
 hs_req);
 
   hs_ep-req = NULL;
   list_del_init(hs_req-queue);
 
 - if (using_dma(hsotg))
 - s3c_hsotg_unmap_dma(hsotg, hs_ep, hs_req);
 -
   /*
* call the complete request with the locks off, just in case the
* request tries to queue more work for this endpoint.

Looks good.

Reviewed-by: Mian Yousaf Kaukab yousaf.kau...@intel.com

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


[PATCH v4 08/11] usbip: letting connection establishment replaceable

2015-05-28 Thread Nobuo Iwata
To introduce some application protocols like WebSocket, this patch 
allows to substitute connection establishment and termination. In 
combination with previous patch, both connection and transmission can 
be replaced.

usbip_connection_operations_t includes open and close operation. Open 
method returns usbip_sock_t which includes send, receive and close 
method. Then, transmission methods are replaced at the same time. 

Succeeding WebSocket patch uses this feature.

Signed-off-by: Nobuo Iwata nobuo.iw...@fujixerox.co.jp
---
 tools/usb/usbip/libsrc/usbip_common.c  | 10 ++
 tools/usb/usbip/libsrc/usbip_common.h  | 11 +++
 tools/usb/usbip/src/usbip.c|  1 +
 tools/usb/usbip/src/usbip_attach.c |  6 +++---
 tools/usb/usbip/src/usbip_connect.c|  6 +++---
 tools/usb/usbip/src/usbip_disconnect.c |  6 +++---
 tools/usb/usbip/src/usbip_list.c   |  6 +++---
 tools/usb/usbip/src/usbip_network.c|  9 +++--
 tools/usb/usbip/src/usbip_network.h|  3 +--
 9 files changed, 42 insertions(+), 16 deletions(-)

diff --git a/tools/usb/usbip/libsrc/usbip_common.c 
b/tools/usb/usbip/libsrc/usbip_common.c
index dc0712c..54efa10 100644
--- a/tools/usb/usbip/libsrc/usbip_common.c
+++ b/tools/usb/usbip/libsrc/usbip_common.c
@@ -297,3 +297,13 @@ void usbip_sock_init(usbip_sock_t *sock, int fd, void *arg,
sock-shutdown = shutdown;
 }
 
+usbip_connection_operations_t usbip_conn_ops = {NULL, NULL};
+
+void usbip_conn_init(
+   usbip_sock_t *(*open)(char *host, char *port),
+   void (*close)(usbip_sock_t *sock))
+{
+   usbip_conn_ops.open = open;
+   usbip_conn_ops.close = close;
+}
+
diff --git a/tools/usb/usbip/libsrc/usbip_common.h 
b/tools/usb/usbip/libsrc/usbip_common.h
index 0dcbd99..07c411f 100644
--- a/tools/usb/usbip/libsrc/usbip_common.h
+++ b/tools/usb/usbip/libsrc/usbip_common.h
@@ -148,4 +148,15 @@ void usbip_sock_init(usbip_sock_t *sock, int fd, void *arg,
ssize_t (*recv)(void *arg, void *buf, size_t len, int wait_all),
void (*shutdown)(void *arg));
 
+typedef struct usbip_connection_operations {
+   usbip_sock_t *(*open)(char *host, char *port);
+   void (*close)(usbip_sock_t *sock);
+} usbip_connection_operations_t;
+
+extern usbip_connection_operations_t usbip_conn_ops;
+
+void usbip_conn_init(
+   usbip_sock_t *(*open)(char *host, char *port),
+   void (*close)(usbip_sock_t *sock));
+
 #endif /* __USBIP_COMMON_H */
diff --git a/tools/usb/usbip/src/usbip.c b/tools/usb/usbip/src/usbip.c
index 9d1468f..505e384 100644
--- a/tools/usb/usbip/src/usbip.c
+++ b/tools/usb/usbip/src/usbip.c
@@ -202,6 +202,7 @@ int main(int argc, char *argv[])
argc -= optind;
argv += optind;
optind = 0;
+   usbip_net_tcp_conn_init();
rc = run_command(cmds[i], argc, argv);
goto out;
}
diff --git a/tools/usb/usbip/src/usbip_attach.c 
b/tools/usb/usbip/src/usbip_attach.c
index ae0ca6e..c67e3d2 100644
--- a/tools/usb/usbip/src/usbip_attach.c
+++ b/tools/usb/usbip/src/usbip_attach.c
@@ -135,7 +135,7 @@ static int attach_device(char *host, char *busid)
int rc;
int rhport;
 
-   sock = usbip_net_tcp_connect(host, usbip_port_string);
+   sock = usbip_conn_ops.open(host, usbip_port_string);
if (!sock) {
err(tcp connect);
goto err_out;
@@ -164,13 +164,13 @@ static int attach_device(char *host, char *busid)
usbip_ux_join(ux);
}
usbip_ux_cleanup(ux);
-   usbip_net_tcp_close(sock);
+   usbip_conn_ops.close(sock);
 
return 0;
 err_cleanup_ux:
usbip_ux_cleanup(ux);
 err_close_conn:
-   usbip_net_tcp_close(sock);
+   usbip_conn_ops.close(sock);
 err_out:
return -1;
 }
diff --git a/tools/usb/usbip/src/usbip_connect.c 
b/tools/usb/usbip/src/usbip_connect.c
index 5f9505c..8dabd0b 100644
--- a/tools/usb/usbip/src/usbip_connect.c
+++ b/tools/usb/usbip/src/usbip_connect.c
@@ -150,7 +150,7 @@ static int connect_device(char *host, char *busid)
goto err_out;
}
 
-   sock = usbip_net_tcp_connect(host, usbip_port_string);
+   sock = usbip_conn_ops.open(host, usbip_port_string);
if (!sock) {
err(tcp connect);
goto err_unbind_device;
@@ -174,13 +174,13 @@ static int connect_device(char *host, char *busid)
usbip_unbind_device(busid);
}
usbip_ux_cleanup(ux);
-   usbip_net_tcp_close(sock);
+   usbip_conn_ops.close(sock);
 
return 0;
 err_cleanup_ux:
usbip_ux_cleanup(ux);
 err_close_conn:
-   usbip_net_tcp_close(sock);
+   usbip_conn_ops.close(sock);
 err_unbind_device:
usbip_unbind_device(busid);
 err_out:
diff --git a/tools/usb/usbip/src/usbip_disconnect.c 

[PATCH v4 07/11] usbip: letting send and receive replaceable

2015-05-28 Thread Nobuo Iwata
This patch allows to substitute send, receive and shutdown routines for 
both a) request/response PDUs among utilities and b) user space URBs 
transmission.

usbip_sock_t is introduced instead of sockfd. it includes function 
pointers of send/receive/shutdown routines, an argument for the 
routines, and a sockfd. The argument is needed for the routines. The 
sockfd is needed to bind connection to USB device.

Succeeding SSL and WebSocket patch use this feature.

Signed-off-by: Nobuo Iwata nobuo.iw...@fujixerox.co.jp
---
 tools/usb/usbip/libsrc/usbip_common.c  | 14 ++
 tools/usb/usbip/libsrc/usbip_common.h  | 14 ++
 tools/usb/usbip/libsrc/usbip_ux.c  | 24 +++---
 tools/usb/usbip/libsrc/usbip_ux.h  |  4 +-
 tools/usb/usbip/src/usbip_attach.c | 30 ++--
 tools/usb/usbip/src/usbip_connect.c| 30 ++--
 tools/usb/usbip/src/usbip_disconnect.c | 26 +-
 tools/usb/usbip/src/usbip_list.c   | 26 +-
 tools/usb/usbip/src/usbip_network.c| 66 ++
 tools/usb/usbip/src/usbip_network.h| 11 +++--
 tools/usb/usbip/src/usbipd.c   |  8 ++--
 tools/usb/usbip/src/usbipd_app.c   | 36 +++---
 tools/usb/usbip/src/usbipd_dev.c   | 40 
 13 files changed, 199 insertions(+), 130 deletions(-)

diff --git a/tools/usb/usbip/libsrc/usbip_common.c 
b/tools/usb/usbip/libsrc/usbip_common.c
index ac73710..dc0712c 100644
--- a/tools/usb/usbip/libsrc/usbip_common.c
+++ b/tools/usb/usbip/libsrc/usbip_common.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2005-2007 Takahiro Hirofuchi
+ * Copyright (C) 2015 Nobuo Iwata
  */
 
 #include libudev.h
@@ -283,3 +284,16 @@ void usbip_names_get_class(char *buff, size_t size, 
uint8_t class,
 
snprintf(buff, size, %s / %s / %s (%02x/%02x/%02x), c, s, p, class, 
subclass, protocol);
 }
+
+void usbip_sock_init(usbip_sock_t *sock, int fd, void *arg,
+   ssize_t (*send)(void *arg, void *buf, size_t len),
+   ssize_t (*recv)(void *arg, void *buf, size_t len, int wait_all),
+   void (*shutdown)(void *arg))
+{
+   sock-fd = fd;
+   sock-arg = arg;
+   sock-send = send;
+   sock-recv = recv;
+   sock-shutdown = shutdown;
+}
+
diff --git a/tools/usb/usbip/libsrc/usbip_common.h 
b/tools/usb/usbip/libsrc/usbip_common.h
index 15fe792..0dcbd99 100644
--- a/tools/usb/usbip/libsrc/usbip_common.h
+++ b/tools/usb/usbip/libsrc/usbip_common.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2005-2007 Takahiro Hirofuchi
+ * Copyright (C) 2015 Nobuo Iwata
  */
 
 #ifndef __USBIP_COMMON_H
@@ -134,4 +135,17 @@ void usbip_names_get_product(char *buff, size_t size, 
uint16_t vendor,
 void usbip_names_get_class(char *buff, size_t size, uint8_t class,
   uint8_t subclass, uint8_t protocol);
 
+typedef struct usbip_sock {
+   int fd;
+   void *arg;
+   ssize_t (*send)(void *arg, void *buf, size_t len);
+   ssize_t (*recv)(void *arg, void *buf, size_t len, int wait_all);
+   void (*shutdown)(void *arg);
+} usbip_sock_t;
+
+void usbip_sock_init(usbip_sock_t *sock, int fd, void *arg,
+   ssize_t (*send)(void *arg, void *buf, size_t len),
+   ssize_t (*recv)(void *arg, void *buf, size_t len, int wait_all),
+   void (*shutdown)(void *arg));
+
 #endif /* __USBIP_COMMON_H */
diff --git a/tools/usb/usbip/libsrc/usbip_ux.c 
b/tools/usb/usbip/libsrc/usbip_ux.c
index 3ac45a72..aa3d863 100644
--- a/tools/usb/usbip/libsrc/usbip_ux.c
+++ b/tools/usb/usbip/libsrc/usbip_ux.c
@@ -57,7 +57,11 @@ static void *usbip_ux_rx(void *arg)
char buf[BLEN];
 
while(good) {
-   received = recv(ux-sockfd, buf, BLEN, 0);
+   if (ux-sock-recv) {
+   received = ux-sock-recv(ux-sock-arg, buf, BLEN, 0);
+   } else {
+   received = recv(ux-sock-fd, buf, BLEN, 0);
+   }
if (received == 0) {
dbg(connection closed on sock:%p, ux-kaddr.sock);
break;
@@ -101,7 +105,11 @@ static void *usbip_ux_tx(void *arg)
break;
}
dump_buff(buf, reads, ux sending);
-   sent = send(ux-sockfd, buf, reads, 0);
+   if (ux-sock-send) {
+   sent = ux-sock-send(ux-sock-arg, buf, reads);
+   } else {
+   sent = send(ux-sock-fd, buf, reads, 0);
+   }
if (sent  0) {
dbg(connection closed on sock:%p, ux-kaddr.sock);
break;
@@ -112,7 +120,11 @@ static void *usbip_ux_tx(void *arg)
}
}
dbg(end of ux-tx for sock:%p, ux-kaddr.sock);
-   shutdown(ux-sockfd, SHUT_RDWR);
+   if (ux-sock-shutdown) {
+   ux-sock-shutdown(ux-sock-arg);
+   } else {
+   shutdown(ux-sock-fd, SHUT_RDWR);
+   }
return 0;
 }
 
@@ -120,7 +132,7 @@ static void *usbip_ux_tx(void *arg)
 

[PATCH v4 06/11] usbip: readme about user space URBs transmission

2015-05-28 Thread Nobuo Iwata
Addition to README regarding user space URBs transmission.

Signed-off-by: Nobuo Iwata nobuo.iw...@fujixerox.co.jp
---
 tools/usb/usbip/README | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/tools/usb/usbip/README b/tools/usb/usbip/README
index 74f4afb..6b61da5 100644
--- a/tools/usb/usbip/README
+++ b/tools/usb/usbip/README
@@ -98,6 +98,28 @@ Application-side: a machine runs an application software 
uses remote USB device.
- Unbind usbip-host.ko from the device.
 
 
+[Userspace Transmission]
+
+In usage shown above, once USB devices are imported or exported, USP/IP 
drivers send and receive URBs in kernel space. The usbip_ux.ko kernel module 
alternates the route to user space by forwarding USBs through USB/IP utilities 
(ie. usbip, usbipd, usbipa). When userspace transmission enabled, usbip attach 
and connect will continue executing until usbip detach or disconnect is exeuted.
+
+app:# insmod usbip-core.ko
+app:# insmod usbip-ux.ko
+app:# insmod vhci-hcd.ko
+
+app:# usbipa -D
+
+dev:# insmod usbip-core.ko
+dev:# insmod usbip-ux.ko
+dev:# insmod usbip-host.ko
+
+dev:# usbip connect --remote host --busid busid
+   - Continue running.
+   - Until disconnect command is executed in other terminal window.
+
+dev:# usbip disconnect --remote host --busid busid
+   - Stops transission, quits connect command and disconnect device.
+
+
 [Example]
 ---
DEVICE SIDE
-- 
2.1.0

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


Re: USB: OOPS 4.1.0-rc5-next-20150527 on boot usb-stick-plugged

2015-05-28 Thread Chris Ruehl

On Thu, May 28, 2015 at 11:15:47AM +0800, Chris Ruehl wrote:

Hi,

this is an other OOPS happen when the memory stick is plugged while boot
its hits a problem in the usb_hub_wq.

If you need more details please let me know.


[6.258589] Unhandled fault: external abort on non-linefetch (0x008) at
0xf4424184


looks similar some USB block clock which should be enabled at this time,
wasn't.



Balbi! Thanks.

I check the definitions, you are so right.

ci_hdrc_imx_probe take care to enable the IMX27_CLK_USB_IPG_GATE
and
usb_phy_gen_create_phy enable the main_clk (IMX27_CLK_USB_AHB_GATE)

My dts file set the wrong IMX27_CLK_USB_IPG_GATE.

and it's working.

ulpiphy0: usbphy@0x10024170 {
   compatible = usb-nop-xceiv;
   reg = 0x10024170 0x4;
   clocks = clks IMX27_CLK_USB_AHB_GATE;
   clock-names = main_clk;
   status = disabled;
};


Reboot w/ and w/o memory stick works works.
detection of partions ok..

FIXED.



--
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 9/9] usb: chipidea: update ci_otg_is_fsm_mode conditions

2015-05-28 Thread Peter Chen
On Thu, May 28, 2015 at 11:33:14AM +0800, Li Jun wrote:
 On Thu, May 28, 2015 at 09:37:47AM +0800, Peter Chen wrote:
  On Wed, May 27, 2015 at 07:50:09PM +0800, Li Jun wrote:
   After introduce usb otg properties, update ci_otg_is_fsm_mode conditions 
   to be
   depending on both usb hardware properties and usb driver config, also 
   resolve
   a compile issue after this API change in debug.c.
   
   Signed-off-by: Li Jun jun...@freescale.com
   ---
drivers/usb/chipidea/ci.h| 4 ++--
drivers/usb/chipidea/debug.c | 1 +
2 files changed, 3 insertions(+), 2 deletions(-)
   
   diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
   index 6d6200e..b2d39b3 100644
   --- a/drivers/usb/chipidea/ci.h
   +++ b/drivers/usb/chipidea/ci.h
   @@ -406,8 +406,8 @@ static inline u32 hw_test_and_write(struct ci_hdrc 
   *ci, enum ci_hw_regs reg,
static inline bool ci_otg_is_fsm_mode(struct ci_hdrc *ci)
{
#ifdef CONFIG_USB_OTG_FSM
   - return ci-is_otg  ci-roles[CI_ROLE_HOST] 
   - ci-roles[CI_ROLE_GADGET];
   + return ci-is_otg  (ci-platdata-srp_support ||
   + ci-platdata-hnp_support || ci-platdata-adp_support);
  
  The condition of (ci-roles[CI_ROLE_HOST]  ci-roles[CI_ROLE_GADGET])
  is still in case the user does not define host or device function for
  chipidea.
 ci-roles[] depends on (dr_mode == USB_DR_MODE_OTG) actually,
 ci-platdata-xx_support will not be set if dr_mode != USB_DR_MODE_OTG,
 then the condition is enough?

No, dr_mode is decided by dts, ci-roles[] is decided by dr_mode
and kernel configuration together. We only works at OTG mode when both
host and device are enabled.

 
 Besides, how about using ci-gadget.is_otg to instead of
  your three conditions according to your 8th patch change?
 I also had thought of it, but seems it looks not reasonable to let core
 depending on gadget's config, right?

Ok, then keep your way.

 
 Li Jun
  
  
#else
 return false;
#endif
   diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c
   index dfb05ed..d95f842 100644
   --- a/drivers/usb/chipidea/debug.c
   +++ b/drivers/usb/chipidea/debug.c
   @@ -10,6 +10,7 @@
#include linux/usb/phy.h
#include linux/usb/otg.h
#include linux/usb/otg-fsm.h
   +#include linux/usb/chipidea.h

#include ci.h
#include udc.h
   -- 
   1.9.1
   
  
  -- 
  
  Best Regards,
  Peter Chen

-- 

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


Re: [PATCH] usb: ulpi: don't register drivers if bus doesn't exist

2015-05-28 Thread Sudip Mukherjee
On Thu, May 28, 2015 at 12:54:59AM -0500, Felipe Balbi wrote:
 On Thu, May 28, 2015 at 11:09:38AM +0530, Sudip Mukherjee wrote:
  On Wed, May 27, 2015 at 08:21:16AM -0700, Greg KH wrote:
   On Wed, May 27, 2015 at 11:16:34AM -0400, Alan Stern wrote:
On Wed, 27 May 2015, Heikki Krogerus wrote:
   
   Maybe we need to test for this in the driver core, not allowing drivers
   for busses that are not registered, that might solve the main problem
   here.  I'll try to look at it tonight.
  may i suggest something like this ?
  buildtest with allmodconfig and allyesconfig on x86_64.
  built and booted on x86.
  
  
  diff --git a/drivers/base/bus.c b/drivers/base/bus.c
  index 5005924..95cefa0 100644
  --- a/drivers/base/bus.c
  +++ b/drivers/base/bus.c
  @@ -943,6 +943,7 @@ int bus_register(struct bus_type *bus)
  if (retval)
  goto bus_groups_fail;
   
  +   bus-registered = true;
 
 once set, it's never cleared.
It should be cleared when we go for bus_unregister.
 
  pr_debug(bus: '%s': registered\n, bus-name);
  return 0;
   
  diff --git a/drivers/base/driver.c b/drivers/base/driver.c
  index 4eabfe2..1acae5b 100644
  --- a/drivers/base/driver.c
  +++ b/drivers/base/driver.c
  @@ -150,6 +150,11 @@ int driver_register(struct device_driver *drv)
  int ret;
  struct device_driver *other;
   
  +   if (!drv-bus-registered) {
  +   pr_err(Driver %s registration failed. bus not yet 
  registered\n,
  +  drv-name);
  +   return -ENODEV;
  +   }
  BUG_ON(!drv-bus-p);
   
  if ((drv-bus-probe  drv-probe) ||
  diff --git a/include/linux/device.h b/include/linux/device.h
  index 00ac57c..8fe4745 100644
  --- a/include/linux/device.h
  +++ b/include/linux/device.h
  @@ -126,6 +126,7 @@ struct bus_type {
  const struct dev_pm_ops *pm;
   
  const struct iommu_ops *iommu_ops;
  +   bool registered;/* DON'T TOUCH THIS */
 
 I would rather use an atomic_t
ok.
This was just an idea, if Greg and you all are okay with it then I
can submit a formal patch.
BTW, the original comment that I thought was:
/* don't use else Greg will scold */

regards
sudip
 
 -- 
 balbi


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


Re: [PATCH] usb: gadget: nokia: Add mass storage driver to g_nokia

2015-05-28 Thread Pali Rohár
On Saturday 31 January 2015 10:53:30 Pali Rohár wrote:
 This patch adds removable mass storage support to g_nokia gadget (for N900).
 It means that at runtime block device can be exported or unexported.
 So it does not export anything by default and thus allows to use MyDocs
 partition as before...
 
 Signed-off-by: Pali Rohár pali.ro...@gmail.com
 ---
  drivers/usb/gadget/legacy/Kconfig |1 +
  drivers/usb/gadget/legacy/nokia.c |  102 
 -
  2 files changed, 102 insertions(+), 1 deletion(-)
 
 diff --git a/drivers/usb/gadget/legacy/Kconfig 
 b/drivers/usb/gadget/legacy/Kconfig
 index fd48ef3..36f6ba4 100644
 --- a/drivers/usb/gadget/legacy/Kconfig
 +++ b/drivers/usb/gadget/legacy/Kconfig
 @@ -345,6 +345,7 @@ config USB_G_NOKIA
   select USB_F_OBEX
   select USB_F_PHONET
   select USB_F_ECM
 + select USB_F_MASS_STORAGE
   help
 The Nokia composite gadget provides support for acm, obex
 and phonet in only one composite gadget driver.
 diff --git a/drivers/usb/gadget/legacy/nokia.c 
 b/drivers/usb/gadget/legacy/nokia.c
 index 9b8fd70..a09bb50 100644
 --- a/drivers/usb/gadget/legacy/nokia.c
 +++ b/drivers/usb/gadget/legacy/nokia.c
 @@ -24,6 +24,7 @@
  #include u_phonet.h
  #include u_ecm.h
  #include gadget_chips.h
 +#include f_mass_storage.h
  
  /* Defines */
  
 @@ -34,6 +35,29 @@ USB_GADGET_COMPOSITE_OPTIONS();
  
  USB_ETHERNET_MODULE_PARAMETERS();
  
 +static struct fsg_module_parameters fsg_mod_data = {
 + .stall = 0,
 + .luns = 2,
 + .removable_count = 2,
 + .removable = { 1, 1, },
 +};
 +
 +FSG_MODULE_PARAMETERS(/* no prefix */, fsg_mod_data);
 +
 +#ifdef CONFIG_USB_GADGET_DEBUG_FILES
 +
 +static unsigned int fsg_num_buffers = CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS;
 +
 +#else
 +
 +/*
 + * Number of buffers we will use.
 + * 2 is usually enough for good buffering pipeline
 + */
 +#define fsg_num_buffers  CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS
 +
 +#endif /* CONFIG_USB_DEBUG */
 +
  #define NOKIA_VENDOR_ID  0x0421  /* Nokia */
  #define NOKIA_PRODUCT_ID 0x01c8  /* Nokia Gadget */
  
 @@ -94,6 +118,8 @@ static struct usb_function *f_obex1_cfg2;
  static struct usb_function *f_obex2_cfg2;
  static struct usb_function *f_phonet_cfg1;
  static struct usb_function *f_phonet_cfg2;
 +static struct usb_function *f_msg_cfg1;
 +static struct usb_function *f_msg_cfg2;
  
  
  static struct usb_configuration nokia_config_500ma_driver = {
 @@ -117,6 +143,7 @@ static struct usb_function_instance *fi_ecm;
  static struct usb_function_instance *fi_obex1;
  static struct usb_function_instance *fi_obex2;
  static struct usb_function_instance *fi_phonet;
 +static struct usb_function_instance *fi_msg;
  
  static int __init nokia_bind_config(struct usb_configuration *c)
  {
 @@ -125,6 +152,8 @@ static int __init nokia_bind_config(struct 
 usb_configuration *c)
   struct usb_function *f_obex1 = NULL;
   struct usb_function *f_ecm;
   struct usb_function *f_obex2 = NULL;
 + struct usb_function *f_msg;
 + struct fsg_opts *fsg_opts;
   int status = 0;
   int obex1_stat = -1;
   int obex2_stat = -1;
 @@ -160,6 +189,12 @@ static int __init nokia_bind_config(struct 
 usb_configuration *c)
   goto err_get_ecm;
   }
  
 + f_msg = usb_get_function(fi_msg);
 + if (IS_ERR(f_msg)) {
 + status = PTR_ERR(f_msg);
 + goto err_get_msg;
 + }
 +
   if (!IS_ERR_OR_NULL(f_phonet)) {
   phonet_stat = usb_add_function(c, f_phonet);
   if (phonet_stat)
 @@ -187,21 +222,36 @@ static int __init nokia_bind_config(struct 
 usb_configuration *c)
   pr_debug(could not bind ecm config %d\n, status);
   goto err_ecm;
   }
 +
 + fsg_opts = fsg_opts_from_func_inst(fi_msg);
 +
 + status = fsg_common_run_thread(fsg_opts-common);
 + if (status)
 + goto err_msg;
 +
 + status = usb_add_function(c, f_msg);
 + if (status)
 + goto err_msg;
 +
   if (c == nokia_config_500ma_driver) {
   f_acm_cfg1 = f_acm;
   f_ecm_cfg1 = f_ecm;
   f_phonet_cfg1 = f_phonet;
   f_obex1_cfg1 = f_obex1;
   f_obex2_cfg1 = f_obex2;
 + f_msg_cfg1 = f_msg;
   } else {
   f_acm_cfg2 = f_acm;
   f_ecm_cfg2 = f_ecm;
   f_phonet_cfg2 = f_phonet;
   f_obex1_cfg2 = f_obex1;
   f_obex2_cfg2 = f_obex2;
 + f_msg_cfg2 = f_msg;
   }
  
   return status;
 +err_msg:
 + usb_remove_function(c, f_ecm);
  err_ecm:
   usb_remove_function(c, f_acm);
  err_conf:
 @@ -211,6 +261,8 @@ err_conf:
   usb_remove_function(c, f_obex1);
   if (!phonet_stat)
   usb_remove_function(c, f_phonet);
 + usb_put_function(f_msg);
 +err_get_msg:
   usb_put_function(f_ecm);
  err_get_ecm:
   usb_put_function(f_acm);
 @@ 

ehci_bus_suspend system halt

2015-05-28 Thread Michael Trimarchi
Hi Alan

we are working on a samsung exysnos5430 device and we have some problem
during suspend. The only way to solve it seems this patch.
We don't really know what could be the problem. Do you have any suggestion
to debug it?

diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index c254076..6b01784 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -289,14 +289,6 @@ static int ehci_bus_suspend (struct usb_hcd *hcd)
 
if (t1 != t2) {
/*
+* When suspend bit for PORT 1 is set,
+* system halts when spin_unlock_irq()
+* called--- why
+*/
+   if (port == 0  (t1  0x01)) {
+   t2 = ~PORT_SUSPEND;
+   }
+   /*
 * On some controllers, Wake-On-Disconnect will
 * generate false wakeup signals until the bus
 * switches over to full-speed idle.  For their
--
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: OOPS 4.1.0-rc5-next-20150527 after lsusb -v

2015-05-28 Thread Chris Ruehl



On Thursday, May 28, 2015 01:51 PM, Felipe Balbi wrote:

On Thu, May 28, 2015 at 11:10:47AM +0800, Chris Ruehl wrote:

Hi,

I'm port from 3.17 to 4.1-rc5 with imx27, Chipidea and ISP1504
When I plug a memory stick to the usb-port it do not detect so I used a
lsusb -v call with triggers the oops.
I also see usb-workqueue oops when the stick is plugged in on boot time, I will
report this in an other message.


[5.145712] ci_hdrc ci_hdrc.0: no of_node; not parsing pinctrl DT
[5.152175] ci_hdrc ci_hdrc.0: ChipIdea HDRC found, revision: 10, lpm: 0;
cap: f4424100 op: f4424140
[5.201695] ULPI Viewport 0xf4424170
[5.205425] ULPI transceiver vendor/product ID 0x04cc/0x1504
[5.211194] Found NXP ISP1504 ULPI transceiver.
[5.215831] ULPI integrity check: passed.
[5.219980] ci_hdrc ci_hdrc.0: It is OTG capable controller
[5.225715] ci_hdrc ci_hdrc.0: EHCI Host Controller
[5.230824] ci_hdrc ci_hdrc.0: new USB bus registered, assigned bus number 1
[5.247177] ci_hdrc ci_hdrc.0: USB 2.0 started, EHCI 1.00
[5.253421] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[5.260384] usb usb1: New USB device strings: Mfr=3, Product=2, 
SerialNumber=1
[5.267748] usb usb1: Product: EHCI Host Controller
[5.272756] usb usb1: Manufacturer: Linux 4.1.0-rc5-next-20150527-dirty 
ehci_hcd
[5.280280] usb usb1: SerialNumber: ci_hdrc.0
[5.286528] usb usb1: no of_node; not parsing pinctrl DT
[5.293375] hub 1-0:1.0: no of_node; not parsing pinctrl DT
[5.299273] hub 1-0:1.0: USB hub found
[5.303821] hub 1-0:1.0: 1 port detected



[ 2336.662597] Unhandled fault: external abort on non-linefetch (0x008) at
0xf4424148


probably died at a register access, can you verify ? Most likely some
necessary clock was disabled.



FIXED by set the correct clock in the dts file, for the main_clk enabled in 
phy-generic.c


Balbi, thanks for your help
:-)

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


Re: [PATCH] usb: gadget: atmel: fix build warning

2015-05-28 Thread Nicolas Ferre
Le 26/05/2015 22:38, Felipe Balbi a écrit :
 This patch fixes the following build warning:
 
 drivers/usb/gadget/udc/atmel_usba_udc.c:707:2: warning: format ‘%x’
 expects argument of type ‘unsigned int’, but argument 4 has type
 ‘dma_addr_t’ [-Wformat=]
 
 Signed-off-by: Felipe Balbi ba...@ti.com

Acked-by: Nicolas Ferre nicolas.fe...@atmel.com
Thanks Felipe!

Bye,

 ---
  drivers/usb/gadget/udc/atmel_usba_udc.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
 b/drivers/usb/gadget/udc/atmel_usba_udc.c
 index 4c01953a0869..5437346908e7 100644
 --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
 +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
 @@ -704,8 +704,8 @@ static int queue_dma(struct usba_udc *udc, struct usba_ep 
 *ep,
   unsigned long flags;
   int ret;
  
 - DBG(DBG_DMA, %s: req l/%u d/%08x %c%c%c\n,
 - ep-ep.name, req-req.length, req-req.dma,
 + DBG(DBG_DMA, %s: req l/%u d/%pad %c%c%c\n,
 + ep-ep.name, req-req.length, req-req.dma,
   req-req.zero ? 'Z' : 'z',
   req-req.short_not_ok ? 'S' : 's',
   req-req.no_interrupt ? 'I' : 'i');
 


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


Re: [PATCH] usb: ulpi: don't register drivers if bus doesn't exist

2015-05-28 Thread Sudip Mukherjee
On Thu, May 28, 2015 at 12:12:56PM +0530, Sudip Mukherjee wrote:
 On Thu, May 28, 2015 at 12:54:59AM -0500, Felipe Balbi wrote:
  On Thu, May 28, 2015 at 11:09:38AM +0530, Sudip Mukherjee wrote:
   On Wed, May 27, 2015 at 08:21:16AM -0700, Greg KH wrote:
On Wed, May 27, 2015 at 11:16:34AM -0400, Alan Stern wrote:
 On Wed, 27 May 2015, Heikki Krogerus wrote:

Maybe we need to test for this in the driver core, not allowing drivers
for busses that are not registered, that might solve the main problem
here.  I'll try to look at it tonight.
   may i suggest something like this ?
   buildtest with allmodconfig and allyesconfig on x86_64.
   built and booted on x86.
   
   
   diff --git a/drivers/base/bus.c b/drivers/base/bus.c
   index 5005924..95cefa0 100644
   --- a/drivers/base/bus.c
   +++ b/drivers/base/bus.c
   @@ -943,6 +943,7 @@ int bus_register(struct bus_type *bus)
 if (retval)
 goto bus_groups_fail;

   + bus-registered = true;
  
  once set, it's never cleared.
 It should be cleared when we go for bus_unregister.
apart from bus_register we need the check in some other places also.
like bus_create_file().

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


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

2015-05-28 Thread Oliver Neukum
On Thu, 2015-05-28 at 14:56 +0900, Nobuo Iwata wrote:
 Dear all,
 
 This series of patches introduces WebSocket to USB/IP. 

Hi,

how do you avoid deadlocking under memory pressure?
It seems to me that under these semantics you can no
longer guarantee GFP_NOIO if usb-storage or UAS are used,
because you have no control over memory allocations user
space makes.

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: USB: OOPS 4.1.0-rc5-next-20150527 on boot usb-stick-plugged

2015-05-28 Thread Chris Ruehl

On Thu, May 28, 2015 at 11:15:47AM +0800, Chris Ruehl wrote:

Hi,

this is an other OOPS happen when the memory stick is plugged while boot
its hits a problem in the usb_hub_wq.

If you need more details please let me know.


[6.258589] Unhandled fault: external abort on non-linefetch (0x008) at
0xf4424184


looks similar some USB block clock which should be enabled at this time,
wasn't.



Thanks for the hint, I will dig into this direction.

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


[PATCH v4 10/11] usbip: added const qualifier to arguments of some functions

2015-05-28 Thread Nobuo Iwata
This patch adds 'const' qualifier to 'char*' arguments of library 
interfaces to make acceptable std::string.c_str(). Essentially, these 
qualifiers are better to be used even if not to use C++. Although, I 
just added to functions related to previous patch.

Also, it changes C++ reserved words (ie. new and class) in list.h.

Signed-off-by: Nobuo Iwata nobuo.iw...@fujixerox.co.jp
---
 tools/usb/usbip/libsrc/list.h  | 24 --
 tools/usb/usbip/libsrc/usbip_common.c  | 16 +++
 tools/usb/usbip/libsrc/usbip_common.h  |  6 +++---
 tools/usb/usbip/libsrc/usbip_host_driver.c | 10 +
 tools/usb/usbip/libsrc/usbip_host_driver.h |  2 +-
 tools/usb/usbip/libsrc/vhci_driver.c   | 11 ++
 tools/usb/usbip/libsrc/vhci_driver.h   |  6 --
 tools/usb/usbip/src/usbip.h| 16 ---
 tools/usb/usbip/src/usbip_attach.c |  4 ++--
 tools/usb/usbip/src/usbip_bind.c   |  6 +++---
 tools/usb/usbip/src/usbip_connect.c|  4 ++--
 tools/usb/usbip/src/usbip_detach.c |  2 +-
 tools/usb/usbip/src/usbip_disconnect.c |  5 +++--
 tools/usb/usbip/src/usbip_list.c   |  7 +++
 tools/usb/usbip/src/usbip_netconn.c|  2 +-
 tools/usb/usbip/src/usbip_network.c| 12 +++
 tools/usb/usbip/src/usbip_unbind.c |  2 +-
 tools/usb/usbip/src/usbipd.c   |  4 ++--
 tools/usb/usbip/src/usbipd.h   |  2 +-
 tools/usb/usbip/src/usbipd_app.c   |  9 
 tools/usb/usbip/src/usbipd_dev.c   |  2 +-
 tools/usb/usbip/src/utils.c|  2 +-
 tools/usb/usbip/src/utils.h|  2 +-
 23 files changed, 86 insertions(+), 70 deletions(-)

diff --git a/tools/usb/usbip/libsrc/list.h b/tools/usb/usbip/libsrc/list.h
index 5eaaa78..b46a98f 100644
--- a/tools/usb/usbip/libsrc/list.h
+++ b/tools/usb/usbip/libsrc/list.h
@@ -36,14 +36,14 @@ static inline void INIT_LIST_HEAD(struct list_head *list)
  * This is only for internal list manipulation where we know
  * the prev/next entries already!
  */
-static inline void __list_add(struct list_head *new,
+static inline void __list_add(struct list_head *neo,
  struct list_head *prev,
  struct list_head *next)
 {
-   next-prev = new;
-   new-next = next;
-   new-prev = prev;
-   prev-next = new;
+   next-prev = neo;
+   neo-next = next;
+   neo-prev = prev;
+   prev-next = neo;
 }
 
 /**
@@ -54,9 +54,9 @@ static inline void __list_add(struct list_head *new,
  * Insert a new entry after the specified head.
  * This is good for implementing stacks.
  */
-static inline void list_add(struct list_head *new, struct list_head *head)
+static inline void list_add(struct list_head *neo, struct list_head *head)
 {
-   __list_add(new, head, head-next);
+   __list_add(neo, head, head-next);
 }
 
 /*
@@ -73,8 +73,8 @@ static inline void __list_del(struct list_head * prev, struct 
list_head * next)
 }
 
 #define POISON_POINTER_DELTA 0
-#define LIST_POISON1  ((void *) 0x00100100 + POISON_POINTER_DELTA)
-#define LIST_POISON2  ((void *) 0x00200200 + POISON_POINTER_DELTA)
+#define LIST_POISON1  ((char *) 0x00100100 + POISON_POINTER_DELTA)
+#define LIST_POISON2  ((char *) 0x00200200 + POISON_POINTER_DELTA)
 
 /**
  * list_del - deletes entry from list.
@@ -90,8 +90,8 @@ static inline void __list_del_entry(struct list_head *entry)
 static inline void list_del(struct list_head *entry)
 {
__list_del(entry-prev, entry-next);
-   entry-next = LIST_POISON1;
-   entry-prev = LIST_POISON2;
+   entry-next = (struct list_head *)LIST_POISON1;
+   entry-prev = (struct list_head *)LIST_POISON2;
 }
 
 /**
@@ -120,7 +120,9 @@ static inline void list_del(struct list_head *entry)
for (pos = (head)-next, n = pos-next; pos != (head); \
pos = n, n = pos-next)
 
+#ifndef offsetof
 #define offsetof(TYPE, MEMBER) ((size_t) ((TYPE *)0)-MEMBER)
+#endif
 
 /**
  * container_of - cast a member of a structure out to the containing structure
diff --git a/tools/usb/usbip/libsrc/usbip_common.c 
b/tools/usb/usbip/libsrc/usbip_common.c
index 54efa10..bf577b7 100644
--- a/tools/usb/usbip/libsrc/usbip_common.c
+++ b/tools/usb/usbip/libsrc/usbip_common.c
@@ -260,29 +260,29 @@ void usbip_names_get_product(char *buff, size_t size, 
uint16_t vendor,
snprintf(buff, size, %s : %s (%04x:%04x), vend, prod, vendor, 
product);
 }
 
-void usbip_names_get_class(char *buff, size_t size, uint8_t class,
+void usbip_names_get_class(char *buff, size_t size, uint8_t clazz,
   uint8_t subclass, uint8_t protocol)
 {
const char *c, *s, *p;
 
-   if (class == 0  subclass == 0  protocol == 0) {
-   snprintf(buff, size, (Defined at Interface level) 
(%02x/%02x/%02x), class, subclass, protocol);
+   if (clazz == 0  subclass == 0  protocol == 0) {
+   snprintf(buff, 

[PATCH v4 09/11] usbip: deriving functions as libraries

2015-05-28 Thread Nobuo Iwata
To utilize core parts of USB/IP to application protocol 
implementations, this patch derives libraries by exposing some 
functions of utilities and removing some unnecessary portions.

Following functions are exposed.
For command:
- usbip_attach_device()
- usbip_detach_port()
- usbip_bind_device()
- usbip_unbind_device()
- usbip_list_imported_devices() : port command
- usbip_list_importable_devices() : list --remote
- usbip_list_devices() : list --local
- usbip_connect_device()
- usbip_disconnect_device()
For daemon:
- usbip_recv_pdu() - processes accepted a connection
- usbip_break_connections() - breaks send/receive threads
- usbip_driver_open() - open host or vhci driver
- usbip_driver_close() - close host or vhci driver

main() and option processing are removed. AS_LIBRARY macro is used to 
remove option processing.

Following libraries are generated.
- libusbip.la : for commnad
- libusbipa.la : for application-side daemon
- libusbipd.la : for device-side daemon

Succeeding WebSocket patch uses these libraries.

Signed-off-by: Nobuo Iwata nobuo.iw...@fujixerox.co.jp
---
 tools/usb/usbip/libsrc/Makefile.am |  10 +-
 tools/usb/usbip/src/Makefile.am|  22 +++-
 tools/usb/usbip/src/usbip.h|   7 ++
 tools/usb/usbip/src/usbip_attach.c |  14 ++-
 tools/usb/usbip/src/usbip_bind.c   |   6 ++
 tools/usb/usbip/src/usbip_connect.c|  12 ++-
 tools/usb/usbip/src/usbip_detach.c |  13 ++-
 tools/usb/usbip/src/usbip_disconnect.c |  12 ++-
 tools/usb/usbip/src/usbip_list.c   |  70 -
 tools/usb/usbip/src/usbip_netconn.c| 133 +
 tools/usb/usbip/src/usbip_network.c|  67 -
 tools/usb/usbip/src/usbip_port.c   |  12 ++-
 tools/usb/usbip/src/usbip_unbind.c |   6 ++
 tools/usb/usbip/src/usbipd.c   |  13 +--
 tools/usb/usbip/src/usbipd.h   |  38 +++
 tools/usb/usbip/src/usbipd_app.c   |   1 +
 tools/usb/usbip/src/usbipd_dev.c   |   1 +
 17 files changed, 311 insertions(+), 126 deletions(-)

diff --git a/tools/usb/usbip/libsrc/Makefile.am 
b/tools/usb/usbip/libsrc/Makefile.am
index 5754425..356a6c0 100644
--- a/tools/usb/usbip/libsrc/Makefile.am
+++ b/tools/usb/usbip/libsrc/Makefile.am
@@ -1,9 +1,9 @@
-libusbip_la_CPPFLAGS = -DUSBIDS_FILE='@USBIDS_DIR@/usb.ids'
-libusbip_la_CFLAGS   = @EXTRA_CFLAGS@
-libusbip_la_LDFLAGS  = -version-info @LIBUSBIP_VERSION@
+libusbiplib_la_CPPFLAGS = -DUSBIDS_FILE='@USBIDS_DIR@/usb.ids'
+libusbiplib_la_CFLAGS   = @EXTRA_CFLAGS@
+libusbiplib_la_LDFLAGS  = -version-info @LIBUSBIP_VERSION@
 
-lib_LTLIBRARIES := libusbip.la
-libusbip_la_SOURCES := names.c names.h usbip_host_driver.c usbip_host_driver.h 
\
+lib_LTLIBRARIES := libusbiplib.la
+libusbiplib_la_SOURCES := names.c names.h usbip_host_driver.c 
usbip_host_driver.h \
   usbip_common.c usbip_common.h vhci_driver.c 
vhci_driver.h \
   usbip_ux.c usbip_ux.h \
   sysfs_utils.c sysfs_utils.h
diff --git a/tools/usb/usbip/src/Makefile.am b/tools/usb/usbip/src/Makefile.am
index f5697c2..780bdb3 100644
--- a/tools/usb/usbip/src/Makefile.am
+++ b/tools/usb/usbip/src/Makefile.am
@@ -1,14 +1,32 @@
 AM_CPPFLAGS = -I$(top_srcdir)/libsrc -DUSBIDS_FILE='@USBIDS_DIR@/usb.ids'
 AM_CFLAGS   = @EXTRA_CFLAGS@
-LDADD   = $(top_builddir)/libsrc/libusbip.la
+LDADD   = $(top_builddir)/libsrc/libusbiplib.la
 
 sbin_PROGRAMS := usbip usbipd usbipa
+lib_LTLIBRARIES := libusbip.la libusbipd.la libusbipa.la
 
-usbip_SOURCES := usbip.h utils.h usbip.c utils.c usbip_network.c \
+usbip_SOURCES := usbip.h utils.h usbip.c utils.c \
+usbip_network.c usbip_netconn.c\
 usbip_attach.c usbip_detach.c usbip_list.c \
 usbip_bind.c usbip_unbind.c usbip_port.c \
 usbip_connect.c usbip_disconnect.c
+usbip_CFLAGS := $(AM_CFLAGS)
 
 usbipd_SOURCES := usbip_network.h usbipd.c usbipd_dev.c usbip_network.c
+usbipd_CFLAGS := $(AM_CFLAGS)
 
 usbipa_SOURCES := usbip_network.h usbipd.c usbipd_app.c usbip_network.c
+usbipa_CFLAGS := $(AM_CFLAGS)
+
+libusbip_la_SOURCES := utils.h utils.c usbip_network.c \
+usbip_attach.c usbip_detach.c usbip_list.c \
+usbip_bind.c usbip_unbind.c usbip_port.c \
+usbip_connect.c usbip_disconnect.c
+libusbip_la_CFLAGS := $(AM_CFLAGS) -DAS_LIBRARY
+libusbip_la_LDFLAGS := -version-info @LIBUSBIP_VERSION@
+
+libusbipd_la_SOURCES := usbipd_dev.c usbip_network.c
+libusbipd_la_LDFLAGS := -version-info @LIBUSBIP_VERSION@
+
+libusbipa_la_SOURCES := usbipd_app.c usbip_network.c
+libusbipa_la_LDFLAGS := -version-info @LIBUSBIP_VERSION@
diff --git a/tools/usb/usbip/src/usbip.h b/tools/usb/usbip/src/usbip.h
index 0875d15..1d642cc 100644
--- a/tools/usb/usbip/src/usbip.h
+++ b/tools/usb/usbip/src/usbip.h
@@ -34,8 +34,15 @@ int usbip_port_show(int argc, char *argv[]);
 int usbip_connect(int argc, char *argv[]);
 int usbip_disconnect(int argc, char *argv[]);
 
+int 

[PATCH v4 11/11] usbip: USB over WebSocket

2015-05-28 Thread Nobuo Iwata
This patch adds utilities transmit packets via WebSocket protocol.
WebSocket version of utilities as following.
  usbws : command
  usbwsa : application-side daemon
  usbwsd : device-side daemon

The command supports all sub-command (ie. list, connect, disconnect, 
port, bind, unbind, attach and detach). It uses --url option to specify 
remote address and port number. 

Implementation of this patch depends on Poco C++ 
(http://pocoproject.org/).

The tree is shown below.
  tools
+--usb
 +--usbip
  +--src : command, daemons and their core libraries 
  +--libsrc : common library for command and daemon
  +--websocket : new! WebSocket implementations
   +--poco : new! implementation with Poco C++

Signed-off-by: Nobuo Iwata nobuo.iw...@fujixerox.co.jp
---
 tools/usb/usbip/websocket/INSTALL | 237 ++
 tools/usb/usbip/websocket/Makefile.am |   3 +
 tools/usb/usbip/websocket/README  | 184 
 tools/usb/usbip/websocket/autogen.sh  |   9 +
 tools/usb/usbip/websocket/cleanup.sh  |  12 +
 tools/usb/usbip/websocket/configure.ac|  55 +++
 tools/usb/usbip/websocket/doc/usbws.8 | 192 
 tools/usb/usbip/websocket/doc/usbwsa.8| 101 +
 tools/usb/usbip/websocket/doc/usbwsd.8| 109 +
 tools/usb/usbip/websocket/poco/Makefile.am|  18 +
 .../usb/usbip/websocket/poco/USBWSCommand.cpp | 410 ++
 tools/usb/usbip/websocket/poco/USBWSCommand.h |  99 +
 .../usb/usbip/websocket/poco/USBWSDaemon.cpp  | 228 ++
 tools/usb/usbip/websocket/poco/USBWSDaemon.h  |  80 
 .../websocket/poco/USBWSRequestHandler.cpp|  90 
 .../websocket/poco/USBWSRequestHandler.h  |  49 +++
 .../poco/USBWSRequestHandlerFactory.cpp   |  47 ++
 .../poco/USBWSRequestHandlerFactory.h |  48 ++
 tools/usb/usbip/websocket/poco/USBWSUtil.h|  52 +++
 .../usbip/websocket/poco/USBWSWebSocket.cpp   | 201 +
 .../usb/usbip/websocket/poco/USBWSWebSocket.h |  69 +++
 21 files changed, 2293 insertions(+)

diff --git a/tools/usb/usbip/websocket/INSTALL 
b/tools/usb/usbip/websocket/INSTALL
new file mode 100644
index 000..d3c5b40
--- /dev/null
+++ b/tools/usb/usbip/websocket/INSTALL
@@ -0,0 +1,237 @@
+Installation Instructions
+*
+
+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
+2006, 2007 Free Software Foundation, Inc.
+
+This file is free documentation; the Free Software Foundation gives
+unlimited permission to copy, distribute and modify it.
+
+Basic Installation
+==
+
+Briefly, the shell commands `./configure; make; make install' should
+configure, build, and install this package.  The following
+more-detailed instructions are generic; see the `README' file for
+instructions specific to this package.
+
+   The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation.  It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions.  Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, and a
+file `config.log' containing compiler output (useful mainly for
+debugging `configure').
+
+   It can also use an optional file (typically called `config.cache'
+and enabled with `--cache-file=config.cache' or simply `-C') that saves
+the results of its tests to speed up reconfiguring.  Caching is
+disabled by default to prevent problems with accidental use of stale
+cache files.
+
+   If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release.  If you are using the cache, and at
+some point `config.cache' contains results you don't want to keep, you
+may remove or edit it.
+
+   The file `configure.ac' (or `configure.in') is used to create
+`configure' by a program called `autoconf'.  You need `configure.ac' if
+you want to change it or regenerate `configure' using a newer version
+of `autoconf'.
+
+The simplest way to compile this package is:
+
+  1. `cd' to the directory containing the package's source code and type
+ `./configure' to configure the package for your system.
+
+ Running `configure' might take a while.  While running, it prints
+ some messages telling which features it is checking for.
+
+  2. Type `make' to compile the package.
+
+  3. Optionally, type `make check' to run any self-tests that come with
+ the package.
+
+  4. Type `make install' to install the programs and any data files and
+ documentation.
+
+  5. You can remove the program binaries and object files from the
+ source code directory by typing `make clean'.  To also 

Re: USB Host Controller no PCD interrupt and CCS and CSC update on the device disconnect

2015-05-28 Thread Rong Wang
Hi Alan,

On Tue, May 26, 2015 at 11:32 PM, Alan Stern st...@rowland.harvard.edu wrote:
 On Tue, 26 May 2015, Rong Wang wrote:

  It seems that your customer wants to change the hardware, not the
  software.

 Yes. We plan to do a hardware modification. But we want to make as little
 change as possible. So we plan to make the internal signal HostDisconnect
 , which is sent from PHY to indicate a disconnection event, configurable
 by software.
 We'll mask this signal at first, once the software determines that there's a
 disconnection event, we unmask this signal to notify the USB controller.
 The advantage of this implementation is that the disconnection indication
 signal will not go to USB controller directlly, thus no internal clean up 
 work
 will be done, which will make software recovery possible.
 The disadvantage is that since there's no disconnection indication signal,
 there's no PCD interrupt and no CCS and CSC update avalable. It's totally
 determined by software.
 We don't konw whether this implementation can handle all the corner cases.

 Clearly it can't.  For example, an unplug would not generate a wakeup
 event.  But maybe you can make it work well enough for your needs.

We actually will disable the autosuspend for all USB device classes.
We don't enable system sleep either.


 BTW, how's the USB Device Controller (HS/FS) detetct the disconnection?
 Does it detect the disconnection by a SE0 line status or by VBUS status?

 SE0 line status indicates reset, not disconnect.  USB devices detect
 disconnection by monitoring VBus.

Thanks for this Device side information. But there's one thing I'm
still not quite sure
What's the behavior of the USB device when the VBUS is always present
while the D+/D- differential signal amplitude exceeds the
disconnection threshold (525 mV)?


 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 v2] usb: gadget: dbgp: Supply config descriptor and accept set config command.

2015-05-28 Thread Vladimir 'φ-coder/phcoder' Serbinenko
commit 6d1e47017e322b09ee3c0d42e7c05babfc2a4cc7
Author: Vladimir Serbinenko phco...@gmail.com
Date:   Tue May 26 21:35:06 2015 +0200

dbgp: Supply config descriptor and accept set config command.

This descriptor and commands are part of core USB specification and every
USB device should have one.

When g_dbgp is used in early printk or in coreboot through EHCI debug those
descriptors are never read and hence this doesn't create a problem. However 
for
coreboot payloads with full USB stack or Linux once booted those descriptors
are essential, so without them both GRUB-as-payload and Linux refuse to
recognize it.

Tested and works as expected in coreboot, GRUB and early_printk=dbgp.
Booted Linux recognizes and it works the same way as Net20DC if I change 
USBID.

Signed-off-by: Vladimir Serbinenko phco...@gmail.com

diff --git a/drivers/usb/gadget/legacy/dbgp.c b/drivers/usb/gadget/legacy/dbgp.c
index 204b10b..256876ddd 100644
--- a/drivers/usb/gadget/legacy/dbgp.c
+++ b/drivers/usb/gadget/legacy/dbgp.c
@@ -18,7 +18,7 @@
 #define DRIVER_VENDOR_ID   0x0525 /* NetChip */
 #define DRIVER_PRODUCT_ID  0xc0de /* undefined */
 
-#define USB_DEBUG_MAX_PACKET_SIZE 8
+#define USB_DEBUG_MAX_PACKET_SIZE 512
 #define DBGP_REQ_EP0_LEN  128
 #define DBGP_REQ_LEN  512
 
@@ -61,6 +61,35 @@ static struct usb_endpoint_descriptor o_desc = {
.bEndpointAddress = USB_DIR_OUT,
 };
 
+struct full_config_desc {
+   struct usb_config_descriptor config_desc;
+   struct usb_interface_descriptor iface_desc;
+   u8 ep[2 * USB_DT_ENDPOINT_SIZE];
+};
+
+static struct usb_config_descriptor config_desc = {
+   .bLength = sizeof (struct usb_config_descriptor),
+   .bDescriptorType = USB_DT_CONFIG,
+   .wTotalLength = __constant_cpu_to_le16(sizeof (struct 
full_config_desc)),
+   .bNumInterfaces = 1,
+   .bConfigurationValue = 1,
+   .iConfiguration = 0,
+   .bmAttributes = 0xc0,
+   .bMaxPower = 0,
+};
+
+static struct usb_interface_descriptor iface_desc = {
+   .bLength = sizeof (struct usb_interface_descriptor),
+   .bDescriptorType = USB_DT_INTERFACE,
+   .bInterfaceNumber = 0,
+   .bAlternateSetting = 0,
+   .bNumEndpoints = 2,
+   .bInterfaceClass = 0xff,
+   .bInterfaceSubClass = 0,
+   .bInterfaceProtocol = 0,
+   .iInterface = 0,
+};
+
 #ifdef CONFIG_USB_G_DBGP_PRINTK
 static int dbgp_consume(char *buf, unsigned len)
 {
@@ -355,6 +384,7 @@ static int dbgp_setup(struct usb_gadget *gadget,
int err = -EOPNOTSUPP;
void *data = NULL;
u16 len = 0;
+   struct full_config_desc full_cfg_desc;
 
gadget-ep0-driver_data = gadget;
 
@@ -371,13 +401,26 @@ static int dbgp_setup(struct usb_gadget *gadget,
len = sizeof dbg_desc;
data = dbg_desc;
break;
+   case USB_DT_CONFIG:
+   dev_dbg(dbgp.gadget-dev, setup: desc config\n);
+   full_cfg_desc.config_desc = config_desc;
+   full_cfg_desc.iface_desc = iface_desc;
+   memcpy(full_cfg_desc.ep, i_desc, USB_DT_ENDPOINT_SIZE);
+   memcpy(full_cfg_desc.ep + USB_DT_ENDPOINT_SIZE, 
o_desc, USB_DT_ENDPOINT_SIZE);
+   data = full_cfg_desc;
+   len = sizeof full_cfg_desc;
+   break;
default:
goto fail;
}
err = 0;
-   } else if (request == USB_REQ_SET_FEATURE 
-  value == USB_DEVICE_DEBUG_MODE) {
-   dev_dbg(dbgp.gadget-dev, setup: feat debug\n);
+   } else if ((request == USB_REQ_SET_FEATURE 
+   value == USB_DEVICE_DEBUG_MODE)
+  || (request == USB_REQ_SET_CONFIGURATION  value == 1)) {
+   if (request == USB_REQ_SET_FEATURE)
+   dev_dbg(dbgp.gadget-dev, setup: feat debug\n);
+   else
+   dev_dbg(dbgp.gadget-dev, setup: config 1\n);
 #ifdef CONFIG_USB_G_DBGP_PRINTK
err = dbgp_enable_ep();
 #else
commit 6d1e47017e322b09ee3c0d42e7c05babfc2a4cc7
Author: Vladimir Serbinenko phcoder@gmail.com
Date:   Tue May 26 21:35:06 2015 +0200

dbgp: Supply config descriptor and accept set config command.

This descriptor and commands are part of core USB specification and every
USB device should have one.

When g_dbgp is used in early printk or in coreboot through EHCI debug those
descriptors are never read and hence this doesn't create a problem. However for
coreboot payloads with full USB stack or Linux once booted those descriptors
are essential, so without them both GRUB-as-payload and Linux refuse to
recognize it.

Tested and works as expected in coreboot, GRUB and early_printk=dbgp.
Booted 

RE: [PATCH v4 00/11] usbip: features to USB over WebSocket

2015-05-28 Thread fx IWATA NOBUO
Hi,

 how do you avoid deadlocking under memory pressure?
 It seems to me that under these semantics you can no
 longer guarantee GFP_NOIO if usb-storage or UAS are used,
 because you have no control over memory allocations user
 space makes.

Sorry, I haven't cared the case.
I found GFP_NOIO allocation in usbip_common.c:usbip_recv().
It is used for kernel mode transfer in existing code before this series.
It is not used when switched to userspace transfer introduced by this 
series.

Outside this series, I will study the reason why GFP_NOIO is used.

Thank you,

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

DWC3 linux driver query

2015-05-28 Thread sundeep subbaraya
Hi Felipe and Paul,

I am seeing an issue while testing iperf for USB ethernet gadget with
dwc3 controller in 2.0 mode. After debugging I figured out that:

1. Network gadget queues say 3 requests. (for IN endpoint)
2. It turns out with req.no_interrupt flag,
DWC3 driver issues START_TRANSFER with req0:IOC, req1, req2:LST
3. As per driver state machine, we get XFERNOTREADY then prepare these
TRBs and issue start transfer. Make Endpoint state as Busy.
4. Endpoint state is set to free in XFERINPROGRESS or XFERCOMPLETE event.
5. The issue I see here is there are NAKs going to host (seen in
analyzer) in between req0 and req2 hence XFERNOTREADY(Transfer Active)
events in between XFERINPROGRESS and  XFERCOMPLETE  events.
6. As a result, EP is set as free in XFERINPROGRESS, since EP is free
start transfer command is issued in XFERNOTREADY handler.The command
fails since controller did not release the xfer resource yet.

I feel controller behaviour is fine since it sends NAK and writes that
event. Driver may have to be modified to make EP as free only in
XFERCOMPLETE event handler (ofcourse not for Isoc).
Note I am testing on a platform which is very slow (the interface
between DDR and core runs at 4Mhz).
Where as on Zynq (DWC3 in PL), a faster system compared to above one I
do not see any NAKs in between Start transfer command and XFERCOMPLETE
event.

What do you guys say? Do you agree linux driver has to be modified or
Core should never issue NAKs in between Start transfer and
XFERCOMPLETE?

A patch correcting DEPCMD status macros has been applied. Thank you
Felipe for trace points in driver otherwise it would have taken very
long time to figure out the root cause :) .
Below is the trace log:(enabled only for IN bulk endpoint)

 irq/97-dwc3-1308  [001] d...   553.713513: dwc3_msg: ep1in-bulk
XFERNOTREADY.Transfer Not Active
 irq/97-dwc3-1308  [001] d...   553.713768: dwc3_msg: ep1in-bulk:
req ffc039a68580 dma 011c60a2 length 1558 IOC

 irq/97-dwc3-1308  [001] d...   553.714266: dwc3_msg: ep1in-bulk:
req ffc039a687c0 dma 011c10a2 length 1558

 irq/97-dwc3-1308  [001] d...   553.714753: dwc3_msg: ep1in-bulk:
req ffc039a68700 dma 011c18a2 length 1558 last IOC

 irq/97-dwc3-1308  [001] d...   553.717768: dwc3_msg: ep1in-bulk
XFERNOTREADY.Transfer Active
 irq/97-dwc3-1308  [001] d...   553.718203: dwc3_msg: ep1in-bulk EP BUSY
 irq/97-dwc3-1308  [001] d...   553.718412: dwc3_msg: ep1in-bulk
XFERNOTREADY.Transfer Active
 irq/97-dwc3-1308  [001] d...   553.718638: dwc3_msg: ep1in-bulk EP BUSY
 irq/97-dwc3-1308  [001] d...   553.718837: dwc3_msg: ep1in-bulk
XFERNOTREADY.Transfer Active
 irq/97-dwc3-1308  [001] d...   553.719049: dwc3_msg: ep1in-bulk EP BUSY
 irq/97-dwc3-1308  [001] d...   553.719248: dwc3_msg: ep1in-bulk
XFERINPROGRESS
 irq/97-dwc3-1308  [001] d...   553.719520: dwc3_msg: request
ffc039a68580 from ep1in-bulk completed 1558/1558 === 0

 irq/97-dwc3-1308  [001] d...   553.720225: dwc3_msg: ep1in-bulk
XFERNOTREADY.Transfer Active
 irq/97-dwc3-1308  [001] d...   553.720612: dwc3_msg: ep1in-bulk
XFERNOTREADY.Transfer Active
 irq/97-dwc3-1308  [001] d...   553.720826: dwc3_msg: ep1in-bulk EP BUSY
 irq/97-dwc3-1308  [001] d...   553.721026: dwc3_msg: ep1in-bulk
XFERNOTREADY.Transfer Active
 irq/97-dwc3-1308  [001] d...   553.721243: dwc3_msg: ep1in-bulk EP BUSY
 irq/97-dwc3-1308  [001] d...   553.721446: dwc3_msg: ep1in-bulk
XFERCOMPLETE
 irq/97-dwc3-1308  [001] d...   553.721711: dwc3_msg: request
ffc039a687c0 from ep1in-bulk completed 1558/1558 === 0

 irq/97-dwc3-1308  [001] d...   553.722411: dwc3_msg: request
ffc039a68700 from ep1in-bulk completed 1558/1558 === 0

 irq/97-dwc3-1308  [001] d...   553.722910: dwc3_msg: ep1in-bulk
XFERNOTREADY.Transfer Not Active
 irq/97-dwc3-1308  [001] d...   553.723159: dwc3_msg: ep1in-bulk:
req ffc039a68ac0 dma 398b18a2 length 1558

 irq/97-dwc3-1308  [001] d...   553.723649: dwc3_msg: ep1in-bulk:
req ffc039a68c40 dma 3a1ce8a2 length 1558

 irq/97-dwc3-1308  [001] d...   553.724136: dwc3_msg: ep1in-bulk:
req ffc039a68580 dma 3cc258a2 length 1558 last

 irq/97-dwc3-1308  [001] d...   553.724722: dwc3_msg: CMD Error:1 for ep 3
 irq/97-dwc3-1308  [001] d...   553.727245: dwc3_msg: ep1in-bulk
XFERNOTREADY.Transfer Active
 irq/97-dwc3-1308  [001] d...   553.727767: dwc3_msg: CMD Error:1 for ep 3
 irq/97-dwc3-1308  [001] d...   553.728049: dwc3_msg: ep1in-bulk
XFERNOTREADY.Transfer Active
 irq/97-dwc3-1308  [001] d...   553.728394: dwc3_msg: CMD Error:1 for ep 3
 irq/97-dwc3-1308  [001] d...   553.731226: dwc3_msg: ep1in-bulk
XFERNOTREADY.Transfer Active
 irq/97-dwc3-1308  [001] d...   553.731658: dwc3_msg: CMD Error:1 for ep 3



Thanks,
Sundeep
--
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: ulpi: don't register drivers if bus doesn't exist

2015-05-28 Thread Sasha Levin
On 05/28/2015 01:39 AM, Sudip Mukherjee wrote:
 diff --git a/drivers/base/driver.c b/drivers/base/driver.c
 index 4eabfe2..1acae5b 100644
 --- a/drivers/base/driver.c
 +++ b/drivers/base/driver.c
 @@ -150,6 +150,11 @@ int driver_register(struct device_driver *drv)
   int ret;
   struct device_driver *other;
  
 + if (!drv-bus-registered) {
 + pr_err(Driver %s registration failed. bus not yet 
 registered\n,
 +drv-name);
 + return -ENODEV;
 + }
   BUG_ON(!drv-bus-p);

This is a design issue with the code in the layer above, there's no reason
driver_register() should be called with a bus that wasn't registered to
begin with.

This is why there's a BUG_ON there to catch these issues - it's a bug, not
a desired behaviour.


Thanks,
Sasha
--
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: ulpi: don't register drivers if bus doesn't exist

2015-05-28 Thread Heikki Krogerus
On Thu, May 28, 2015 at 08:36:46AM -0400, Sasha Levin wrote:
 On 05/28/2015 01:39 AM, Sudip Mukherjee wrote:
  diff --git a/drivers/base/driver.c b/drivers/base/driver.c
  index 4eabfe2..1acae5b 100644
  --- a/drivers/base/driver.c
  +++ b/drivers/base/driver.c
  @@ -150,6 +150,11 @@ int driver_register(struct device_driver *drv)
  int ret;
  struct device_driver *other;
   
  +   if (!drv-bus-registered) {
  +   pr_err(Driver %s registration failed. bus not yet 
  registered\n,
  +  drv-name);
  +   return -ENODEV;
  +   }
  BUG_ON(!drv-bus-p);
 
 This is a design issue with the code in the layer above, there's no reason
 driver_register() should be called with a bus that wasn't registered to
 begin with.
 
 This is why there's a BUG_ON there to catch these issues - it's a bug, not
 a desired behaviour.

Unfortunately problems with the design are not the only cases why we
could end up here before the bus has been registered. If the bus has
failed to register, we definitely should not trigger a BUG here. The
bus management driver has in that case already made the decision to
not BUG. Or if the user is allowed to disable a bus somehow, for
example with something like nousb parameter, but we still manage do
get here, we should again not trigger BUG().

I don't think BUG_ON here is ever the correct thing to do. This
function can see that the bus doesn't exist or possibly that something
has gone wrong by checking the p, but it does not know any details,
nor should it. This function should trigger a warning in those cases
and return failure, and not make any extra decisions.


Thanks,

-- 
heikki
--
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: OOPS 4.1.0-rc5-next-20150527 on boot usb-stick-plugged

2015-05-28 Thread Felipe Balbi
On Thu, May 28, 2015 at 03:43:23PM +0800, Chris Ruehl wrote:
 On Thu, May 28, 2015 at 11:15:47AM +0800, Chris Ruehl wrote:
 Hi,
 
 this is an other OOPS happen when the memory stick is plugged while boot
 its hits a problem in the usb_hub_wq.
 
 If you need more details please let me know.
 
 
 [6.258589] Unhandled fault: external abort on non-linefetch (0x008) at
 0xf4424184
 
 looks similar some USB block clock which should be enabled at this time,
 wasn't.
 
 
 Balbi! Thanks.
 
 I check the definitions, you are so right.
 
 ci_hdrc_imx_probe take care to enable the IMX27_CLK_USB_IPG_GATE
 and
 usb_phy_gen_create_phy enable the main_clk (IMX27_CLK_USB_AHB_GATE)
 
 My dts file set the wrong IMX27_CLK_USB_IPG_GATE.
 
 and it's working.
 
 ulpiphy0: usbphy@0x10024170 {
compatible = usb-nop-xceiv;
reg = 0x10024170 0x4;
clocks = clks IMX27_CLK_USB_AHB_GATE;
clock-names = main_clk;
status = disabled;
 };
 
 
 Reboot w/ and w/o memory stick works works.
 detection of partions ok..
 
 FIXED.

cool :-)

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] usb: gadget: nokia: Add mass storage driver to g_nokia

2015-05-28 Thread Krzysztof Opasiak



On 05/28/2015 09:47 AM, Pali Rohár wrote:

On Saturday 31 January 2015 10:53:30 Pali Rohár wrote:

This patch adds removable mass storage support to g_nokia gadget (for N900).
It means that at runtime block device can be exported or unexported.
So it does not export anything by default and thus allows to use MyDocs
partition as before...

Signed-off-by: Pali Rohár pali.ro...@gmail.com
---
  drivers/usb/gadget/legacy/Kconfig |1 +
  drivers/usb/gadget/legacy/nokia.c |  102 -
  2 files changed, 102 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/legacy/Kconfig 
b/drivers/usb/gadget/legacy/Kconfig
index fd48ef3..36f6ba4 100644
--- a/drivers/usb/gadget/legacy/Kconfig
+++ b/drivers/usb/gadget/legacy/Kconfig
@@ -345,6 +345,7 @@ config USB_G_NOKIA
select USB_F_OBEX
select USB_F_PHONET
select USB_F_ECM
+   select USB_F_MASS_STORAGE
help
  The Nokia composite gadget provides support for acm, obex
  and phonet in only one composite gadget driver.
diff --git a/drivers/usb/gadget/legacy/nokia.c 
b/drivers/usb/gadget/legacy/nokia.c
index 9b8fd70..a09bb50 100644
--- a/drivers/usb/gadget/legacy/nokia.c
+++ b/drivers/usb/gadget/legacy/nokia.c
@@ -24,6 +24,7 @@
  #include u_phonet.h
  #include u_ecm.h
  #include gadget_chips.h
+#include f_mass_storage.h

  /* Defines */

@@ -34,6 +35,29 @@ USB_GADGET_COMPOSITE_OPTIONS();

  USB_ETHERNET_MODULE_PARAMETERS();

+static struct fsg_module_parameters fsg_mod_data = {
+   .stall = 0,
+   .luns = 2,
+   .removable_count = 2,
+   .removable = { 1, 1, },
+};
+
+FSG_MODULE_PARAMETERS(/* no prefix */, fsg_mod_data);
+
+#ifdef CONFIG_USB_GADGET_DEBUG_FILES
+
+static unsigned int fsg_num_buffers = CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS;
+
+#else
+
+/*
+ * Number of buffers we will use.
+ * 2 is usually enough for good buffering pipeline
+ */
+#define fsg_num_buffersCONFIG_USB_GADGET_STORAGE_NUM_BUFFERS
+
+#endif /* CONFIG_USB_DEBUG */
+
  #define NOKIA_VENDOR_ID   0x0421  /* Nokia */
  #define NOKIA_PRODUCT_ID  0x01c8  /* Nokia Gadget */

@@ -94,6 +118,8 @@ static struct usb_function *f_obex1_cfg2;
  static struct usb_function *f_obex2_cfg2;
  static struct usb_function *f_phonet_cfg1;
  static struct usb_function *f_phonet_cfg2;
+static struct usb_function *f_msg_cfg1;
+static struct usb_function *f_msg_cfg2;


  static struct usb_configuration nokia_config_500ma_driver = {
@@ -117,6 +143,7 @@ static struct usb_function_instance *fi_ecm;
  static struct usb_function_instance *fi_obex1;
  static struct usb_function_instance *fi_obex2;
  static struct usb_function_instance *fi_phonet;
+static struct usb_function_instance *fi_msg;

  static int __init nokia_bind_config(struct usb_configuration *c)
  {
@@ -125,6 +152,8 @@ static int __init nokia_bind_config(struct 
usb_configuration *c)
struct usb_function *f_obex1 = NULL;
struct usb_function *f_ecm;
struct usb_function *f_obex2 = NULL;
+   struct usb_function *f_msg;
+   struct fsg_opts *fsg_opts;
int status = 0;
int obex1_stat = -1;
int obex2_stat = -1;
@@ -160,6 +189,12 @@ static int __init nokia_bind_config(struct 
usb_configuration *c)
goto err_get_ecm;
}

+   f_msg = usb_get_function(fi_msg);
+   if (IS_ERR(f_msg)) {
+   status = PTR_ERR(f_msg);
+   goto err_get_msg;
+   }
+
if (!IS_ERR_OR_NULL(f_phonet)) {
phonet_stat = usb_add_function(c, f_phonet);
if (phonet_stat)
@@ -187,21 +222,36 @@ static int __init nokia_bind_config(struct 
usb_configuration *c)
pr_debug(could not bind ecm config %d\n, status);
goto err_ecm;
}
+
+   fsg_opts = fsg_opts_from_func_inst(fi_msg);
+
+   status = fsg_common_run_thread(fsg_opts-common);
+   if (status)
+   goto err_msg;
+
+   status = usb_add_function(c, f_msg);
+   if (status)
+   goto err_msg;
+
if (c == nokia_config_500ma_driver) {
f_acm_cfg1 = f_acm;
f_ecm_cfg1 = f_ecm;
f_phonet_cfg1 = f_phonet;
f_obex1_cfg1 = f_obex1;
f_obex2_cfg1 = f_obex2;
+   f_msg_cfg1 = f_msg;
} else {
f_acm_cfg2 = f_acm;
f_ecm_cfg2 = f_ecm;
f_phonet_cfg2 = f_phonet;
f_obex1_cfg2 = f_obex1;
f_obex2_cfg2 = f_obex2;
+   f_msg_cfg2 = f_msg;
}

return status;
+err_msg:
+   usb_remove_function(c, f_ecm);
  err_ecm:
usb_remove_function(c, f_acm);
  err_conf:
@@ -211,6 +261,8 @@ err_conf:
usb_remove_function(c, f_obex1);
if (!phonet_stat)
usb_remove_function(c, f_phonet);
+   usb_put_function(f_msg);
+err_get_msg:
usb_put_function(f_ecm);
  err_get_ecm:
 

Re: Disk access keeps causing serial/USB failures?

2015-05-28 Thread Marc MERLIN
On Tue, May 19, 2015 at 10:56:39AM -0700, Marc MERLIN wrote:
 On Tue, May 19, 2015 at 01:21:30PM -0400, Alan Stern wrote:
  This strongly suggests that the problem lies in the hubs (or in one of 
  them).  Something caused a hub to disconnect, and when that happened 
  all of the serial ports downstream from that hub went along for the 
  ride.
 
 Hi Alan, thanks for your answer.
 
 So, when my serial ports go bad, I detect it on a high level, and one of
 my 4 port serial USB hub was connected into a powered USB hub where I
 can toggle ports on and off.
 In that case, the port got cycled, causing a full reset and things to
 start working again.
 
 But, you made me realize that my 4 and 8 port USB serial hubs are USB
 hubs themselves with 4 or 8 FTDI converts in them.
 So, I plugged the 4 port one directly into the PC (the other one was
 already directly connected too), and added external power to it just in
 case.
 
 We'll see if that helps.
 
Well, looks like you were right, thank you for helping out.

 However, I have many many logs that show that my problems are happening
 during periods of high disk activity, mostly at night when I'm running
 rsync backups, so it still looks like there is a link between the 2.

That was still true though, and I'm not sure how disk access was
affecting USB reliability, but it was. 
Either way, plugging the serial converter hub directly into the PC
helped for sure.

Thanks again,
Marc
-- 
A mouse is a device used to point at the xterm you want to type in - A.S.R.
Microsoft is to operating systems 
   what McDonalds is to gourmet cooking
Home page: http://marc.merlins.org/ | PGP 1024R/763BE901
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: phy: add static inline wrapper for devm_usb_get_phy_by_node

2015-05-28 Thread Arnd Bergmann
The newly introduced devm_usb_get_phy_by_node function only has
an extern declaration, but no alternative for the case that
CONFIG_USB_PHY is disabled, which leads to a build error when
it is used anyway:

drivers/power/twl4030_charger.c: In function 'twl4030_bci_probe':
drivers/power/twl4030_charger.c:648:23: error: implicit declaration of function 
'devm_usb_get_phy_by_node' [-Werror=implicit-function-declaration]
bci-transceiver = devm_usb_get_phy_by_node(

This adds the wrapper in the same way that we have one for
all other usb-phy API functions.

Signed-off-by: Arnd Bergmann a...@arndb.de
Fixes: e842b84c8e7 (usb: phy: Add interface to get phy give of device_node.)

diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h
index 8ed1e29ef329..e39f251cf861 100644
--- a/include/linux/usb/phy.h
+++ b/include/linux/usb/phy.h
@@ -240,6 +240,12 @@ static inline struct usb_phy 
*devm_usb_get_phy_by_phandle(struct device *dev,
return ERR_PTR(-ENXIO);
 }
 
+static inline struct usb_phy *devm_usb_get_phy_by_node(struct device *dev,
+   struct device_node *node, struct notifier_block *nb)
+{
+   return ERR_PTR(-ENXIO);
+}
+
 static inline void usb_put_phy(struct usb_phy *x)
 {
 }

--
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: DWC3 linux driver query

2015-05-28 Thread Felipe Balbi
Hi,

On Thu, May 28, 2015 at 04:53:09PM +0530, sundeep subbaraya wrote:
 Hi Felipe and Paul,

btw, Paul has left Synopys :-)

 I am seeing an issue while testing iperf for USB ethernet gadget with
 dwc3 controller in 2.0 mode. After debugging I figured out that:
 
 1. Network gadget queues say 3 requests. (for IN endpoint)
 2. It turns out with req.no_interrupt flag,
 DWC3 driver issues START_TRANSFER with req0:IOC, req1, req2:LST
 3. As per driver state machine, we get XFERNOTREADY then prepare these
 TRBs and issue start transfer. Make Endpoint state as Busy.
 4. Endpoint state is set to free in XFERINPROGRESS or XFERCOMPLETE event.
 5. The issue I see here is there are NAKs going to host (seen in
 analyzer) in between req0 and req2 hence XFERNOTREADY(Transfer Active)
 events in between XFERINPROGRESS and  XFERCOMPLETE  events.
 6. As a result, EP is set as free in XFERINPROGRESS, since EP is free
 start transfer command is issued in XFERNOTREADY handler.The command
 fails since controller did not release the xfer resource yet.
 
 I feel controller behaviour is fine since it sends NAK and writes that
 event. Driver may have to be modified to make EP as free only in
 XFERCOMPLETE event handler (ofcourse not for Isoc).

this sounds like the correct solution.

 Note I am testing on a platform which is very slow (the interface
 between DDR and core runs at 4Mhz).

sweet :-)

 Where as on Zynq (DWC3 in PL), a faster system compared to above one I

hey, when will we see a glue layer for Zynq ? :-)

 do not see any NAKs in between Start transfer command and XFERCOMPLETE
 event.
 
 What do you guys say? Do you agree linux driver has to be modified or
 Core should never issue NAKs in between Start transfer and
 XFERCOMPLETE?

well, if we queued enough transfers, it shouldn't NAK. OTOH, we
shouldn't allow for a new StartTransfer command until all pending
requests have been transferred.

 A patch correcting DEPCMD status macros has been applied. Thank you
 Felipe for trace points in driver otherwise it would have taken very
 long time to figure out the root cause :) .

yeah, those are really helpful :-)

 Below is the trace log:(enabled only for IN bulk endpoint)
 
  irq/97-dwc3-1308  [001] d...   553.713513: dwc3_msg: ep1in-bulk
 XFERNOTREADY.Transfer Not Active
  irq/97-dwc3-1308  [001] d...   553.713768: dwc3_msg: ep1in-bulk:
 req ffc039a68580 dma 011c60a2 length 1558 IOC
 
  irq/97-dwc3-1308  [001] d...   553.714266: dwc3_msg: ep1in-bulk:
 req ffc039a687c0 dma 011c10a2 length 1558
 
  irq/97-dwc3-1308  [001] d...   553.714753: dwc3_msg: ep1in-bulk:
 req ffc039a68700 dma 011c18a2 length 1558 last IOC
 
  irq/97-dwc3-1308  [001] d...   553.717768: dwc3_msg: ep1in-bulk
 XFERNOTREADY.Transfer Active
  irq/97-dwc3-1308  [001] d...   553.718203: dwc3_msg: ep1in-bulk EP BUSY
  irq/97-dwc3-1308  [001] d...   553.718412: dwc3_msg: ep1in-bulk
 XFERNOTREADY.Transfer Active
  irq/97-dwc3-1308  [001] d...   553.718638: dwc3_msg: ep1in-bulk EP BUSY
  irq/97-dwc3-1308  [001] d...   553.718837: dwc3_msg: ep1in-bulk
 XFERNOTREADY.Transfer Active
  irq/97-dwc3-1308  [001] d...   553.719049: dwc3_msg: ep1in-bulk EP BUSY
  irq/97-dwc3-1308  [001] d...   553.719248: dwc3_msg: ep1in-bulk
 XFERINPROGRESS
  irq/97-dwc3-1308  [001] d...   553.719520: dwc3_msg: request
 ffc039a68580 from ep1in-bulk completed 1558/1558 === 0
 
  irq/97-dwc3-1308  [001] d...   553.720225: dwc3_msg: ep1in-bulk
 XFERNOTREADY.Transfer Active
  irq/97-dwc3-1308  [001] d...   553.720612: dwc3_msg: ep1in-bulk
 XFERNOTREADY.Transfer Active
  irq/97-dwc3-1308  [001] d...   553.720826: dwc3_msg: ep1in-bulk EP BUSY
  irq/97-dwc3-1308  [001] d...   553.721026: dwc3_msg: ep1in-bulk
 XFERNOTREADY.Transfer Active
  irq/97-dwc3-1308  [001] d...   553.721243: dwc3_msg: ep1in-bulk EP BUSY
  irq/97-dwc3-1308  [001] d...   553.721446: dwc3_msg: ep1in-bulk
 XFERCOMPLETE
  irq/97-dwc3-1308  [001] d...   553.721711: dwc3_msg: request
 ffc039a687c0 from ep1in-bulk completed 1558/1558 === 0
 
  irq/97-dwc3-1308  [001] d...   553.722411: dwc3_msg: request
 ffc039a68700 from ep1in-bulk completed 1558/1558 === 0
 
  irq/97-dwc3-1308  [001] d...   553.722910: dwc3_msg: ep1in-bulk
 XFERNOTREADY.Transfer Not Active
  irq/97-dwc3-1308  [001] d...   553.723159: dwc3_msg: ep1in-bulk:
 req ffc039a68ac0 dma 398b18a2 length 1558
 
  irq/97-dwc3-1308  [001] d...   553.723649: dwc3_msg: ep1in-bulk:
 req ffc039a68c40 dma 3a1ce8a2 length 1558
 
  irq/97-dwc3-1308  [001] d...   553.724136: dwc3_msg: ep1in-bulk:
 req ffc039a68580 dma 3cc258a2 length 1558 last
 
  irq/97-dwc3-1308  [001] d...   553.724722: dwc3_msg: CMD Error:1 for ep 3
  irq/97-dwc3-1308  [001] d...   553.727245: dwc3_msg: ep1in-bulk
 XFERNOTREADY.Transfer Active
  irq/97-dwc3-1308  [001] d...   553.727767: dwc3_msg: CMD Error:1 for ep 3
  irq/97-dwc3-1308  [001] d...   

Re: [PATCH] usb: gadget: nokia: Add mass storage driver to g_nokia

2015-05-28 Thread Pali Rohár
On Thursday 28 May 2015 16:27:44 Krzysztof Opasiak wrote:
 
 
 On 05/28/2015 09:47 AM, Pali Rohár wrote:
 On Saturday 31 January 2015 10:53:30 Pali Rohár wrote:
 This patch adds removable mass storage support to g_nokia gadget (for N900).
 It means that at runtime block device can be exported or unexported.
 So it does not export anything by default and thus allows to use MyDocs
 partition as before...
 
 Signed-off-by: Pali Rohár pali.ro...@gmail.com
 ---
   drivers/usb/gadget/legacy/Kconfig |1 +
   drivers/usb/gadget/legacy/nokia.c |  102 
  -
   2 files changed, 102 insertions(+), 1 deletion(-)
 
 diff --git a/drivers/usb/gadget/legacy/Kconfig 
 b/drivers/usb/gadget/legacy/Kconfig
 index fd48ef3..36f6ba4 100644
 --- a/drivers/usb/gadget/legacy/Kconfig
 +++ b/drivers/usb/gadget/legacy/Kconfig
 @@ -345,6 +345,7 @@ config USB_G_NOKIA
 select USB_F_OBEX
 select USB_F_PHONET
 select USB_F_ECM
 +   select USB_F_MASS_STORAGE
 help
   The Nokia composite gadget provides support for acm, obex
   and phonet in only one composite gadget driver.
 diff --git a/drivers/usb/gadget/legacy/nokia.c 
 b/drivers/usb/gadget/legacy/nokia.c
 index 9b8fd70..a09bb50 100644
 --- a/drivers/usb/gadget/legacy/nokia.c
 +++ b/drivers/usb/gadget/legacy/nokia.c
 @@ -24,6 +24,7 @@
   #include u_phonet.h
   #include u_ecm.h
   #include gadget_chips.h
 +#include f_mass_storage.h
 
   /* Defines */
 
 @@ -34,6 +35,29 @@ USB_GADGET_COMPOSITE_OPTIONS();
 
   USB_ETHERNET_MODULE_PARAMETERS();
 
 +static struct fsg_module_parameters fsg_mod_data = {
 +   .stall = 0,
 +   .luns = 2,
 +   .removable_count = 2,
 +   .removable = { 1, 1, },
 +};
 +
 +FSG_MODULE_PARAMETERS(/* no prefix */, fsg_mod_data);
 +
 +#ifdef CONFIG_USB_GADGET_DEBUG_FILES
 +
 +static unsigned int fsg_num_buffers = 
 CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS;
 +
 +#else
 +
 +/*
 + * Number of buffers we will use.
 + * 2 is usually enough for good buffering pipeline
 + */
 +#define fsg_num_buffersCONFIG_USB_GADGET_STORAGE_NUM_BUFFERS
 +
 +#endif /* CONFIG_USB_DEBUG */
 +
   #define NOKIA_VENDOR_ID   0x0421  /* Nokia */
   #define NOKIA_PRODUCT_ID  0x01c8  /* Nokia Gadget */
 
 @@ -94,6 +118,8 @@ static struct usb_function *f_obex1_cfg2;
   static struct usb_function *f_obex2_cfg2;
   static struct usb_function *f_phonet_cfg1;
   static struct usb_function *f_phonet_cfg2;
 +static struct usb_function *f_msg_cfg1;
 +static struct usb_function *f_msg_cfg2;
 
 
   static struct usb_configuration nokia_config_500ma_driver = {
 @@ -117,6 +143,7 @@ static struct usb_function_instance *fi_ecm;
   static struct usb_function_instance *fi_obex1;
   static struct usb_function_instance *fi_obex2;
   static struct usb_function_instance *fi_phonet;
 +static struct usb_function_instance *fi_msg;
 
   static int __init nokia_bind_config(struct usb_configuration *c)
   {
 @@ -125,6 +152,8 @@ static int __init nokia_bind_config(struct 
 usb_configuration *c)
 struct usb_function *f_obex1 = NULL;
 struct usb_function *f_ecm;
 struct usb_function *f_obex2 = NULL;
 +   struct usb_function *f_msg;
 +   struct fsg_opts *fsg_opts;
 int status = 0;
 int obex1_stat = -1;
 int obex2_stat = -1;
 @@ -160,6 +189,12 @@ static int __init nokia_bind_config(struct 
 usb_configuration *c)
 goto err_get_ecm;
 }
 
 +   f_msg = usb_get_function(fi_msg);
 +   if (IS_ERR(f_msg)) {
 +   status = PTR_ERR(f_msg);
 +   goto err_get_msg;
 +   }
 +
 if (!IS_ERR_OR_NULL(f_phonet)) {
 phonet_stat = usb_add_function(c, f_phonet);
 if (phonet_stat)
 @@ -187,21 +222,36 @@ static int __init nokia_bind_config(struct 
 usb_configuration *c)
 pr_debug(could not bind ecm config %d\n, status);
 goto err_ecm;
 }
 +
 +   fsg_opts = fsg_opts_from_func_inst(fi_msg);
 +
 +   status = fsg_common_run_thread(fsg_opts-common);
 +   if (status)
 +   goto err_msg;
 +
 +   status = usb_add_function(c, f_msg);
 +   if (status)
 +   goto err_msg;
 +
 if (c == nokia_config_500ma_driver) {
 f_acm_cfg1 = f_acm;
 f_ecm_cfg1 = f_ecm;
 f_phonet_cfg1 = f_phonet;
 f_obex1_cfg1 = f_obex1;
 f_obex2_cfg1 = f_obex2;
 +   f_msg_cfg1 = f_msg;
 } else {
 f_acm_cfg2 = f_acm;
 f_ecm_cfg2 = f_ecm;
 f_phonet_cfg2 = f_phonet;
 f_obex1_cfg2 = f_obex1;
 f_obex2_cfg2 = f_obex2;
 +   f_msg_cfg2 = f_msg;
 }
 
 return status;
 +err_msg:
 +   usb_remove_function(c, f_ecm);
   err_ecm:
 usb_remove_function(c, f_acm);
   err_conf:
 @@ -211,6 +261,8 @@ err_conf:
 usb_remove_function(c, f_obex1);
 if (!phonet_stat)
 usb_remove_function(c, f_phonet);
 +   usb_put_function(f_msg);
 +err_get_msg:
 usb_put_function(f_ecm);
   err_get_ecm:
 usb_put_function(f_acm);
 @@ -227,6 

Re: [PATCH] usb: gadget: nokia: Add mass storage driver to g_nokia

2015-05-28 Thread Krzysztof Opasiak



On 05/28/2015 04:31 PM, Pali Rohár wrote:

On Thursday 28 May 2015 16:27:44 Krzysztof Opasiak wrote:



On 05/28/2015 09:47 AM, Pali Rohár wrote:

On Saturday 31 January 2015 10:53:30 Pali Rohár wrote:

This patch adds removable mass storage support to g_nokia gadget (for N900).
It means that at runtime block device can be exported or unexported.
So it does not export anything by default and thus allows to use MyDocs
partition as before...

Signed-off-by: Pali Rohár pali.ro...@gmail.com
---
  drivers/usb/gadget/legacy/Kconfig |1 +
  drivers/usb/gadget/legacy/nokia.c |  102 -
  2 files changed, 102 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/legacy/Kconfig 
b/drivers/usb/gadget/legacy/Kconfig
index fd48ef3..36f6ba4 100644
--- a/drivers/usb/gadget/legacy/Kconfig
+++ b/drivers/usb/gadget/legacy/Kconfig
@@ -345,6 +345,7 @@ config USB_G_NOKIA
select USB_F_OBEX
select USB_F_PHONET
select USB_F_ECM
+   select USB_F_MASS_STORAGE
help
  The Nokia composite gadget provides support for acm, obex
  and phonet in only one composite gadget driver.
diff --git a/drivers/usb/gadget/legacy/nokia.c 
b/drivers/usb/gadget/legacy/nokia.c
index 9b8fd70..a09bb50 100644
--- a/drivers/usb/gadget/legacy/nokia.c
+++ b/drivers/usb/gadget/legacy/nokia.c
@@ -24,6 +24,7 @@
  #include u_phonet.h
  #include u_ecm.h
  #include gadget_chips.h
+#include f_mass_storage.h

  /* Defines */

@@ -34,6 +35,29 @@ USB_GADGET_COMPOSITE_OPTIONS();

  USB_ETHERNET_MODULE_PARAMETERS();

+static struct fsg_module_parameters fsg_mod_data = {
+   .stall = 0,
+   .luns = 2,
+   .removable_count = 2,
+   .removable = { 1, 1, },
+};
+
+FSG_MODULE_PARAMETERS(/* no prefix */, fsg_mod_data);
+
+#ifdef CONFIG_USB_GADGET_DEBUG_FILES
+
+static unsigned int fsg_num_buffers = CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS;
+
+#else
+
+/*
+ * Number of buffers we will use.
+ * 2 is usually enough for good buffering pipeline
+ */
+#define fsg_num_buffersCONFIG_USB_GADGET_STORAGE_NUM_BUFFERS
+
+#endif /* CONFIG_USB_DEBUG */
+
  #define NOKIA_VENDOR_ID   0x0421  /* Nokia */
  #define NOKIA_PRODUCT_ID  0x01c8  /* Nokia Gadget */

@@ -94,6 +118,8 @@ static struct usb_function *f_obex1_cfg2;
  static struct usb_function *f_obex2_cfg2;
  static struct usb_function *f_phonet_cfg1;
  static struct usb_function *f_phonet_cfg2;
+static struct usb_function *f_msg_cfg1;
+static struct usb_function *f_msg_cfg2;


  static struct usb_configuration nokia_config_500ma_driver = {
@@ -117,6 +143,7 @@ static struct usb_function_instance *fi_ecm;
  static struct usb_function_instance *fi_obex1;
  static struct usb_function_instance *fi_obex2;
  static struct usb_function_instance *fi_phonet;
+static struct usb_function_instance *fi_msg;

  static int __init nokia_bind_config(struct usb_configuration *c)
  {
@@ -125,6 +152,8 @@ static int __init nokia_bind_config(struct 
usb_configuration *c)
struct usb_function *f_obex1 = NULL;
struct usb_function *f_ecm;
struct usb_function *f_obex2 = NULL;
+   struct usb_function *f_msg;
+   struct fsg_opts *fsg_opts;
int status = 0;
int obex1_stat = -1;
int obex2_stat = -1;
@@ -160,6 +189,12 @@ static int __init nokia_bind_config(struct 
usb_configuration *c)
goto err_get_ecm;
}

+   f_msg = usb_get_function(fi_msg);
+   if (IS_ERR(f_msg)) {
+   status = PTR_ERR(f_msg);
+   goto err_get_msg;
+   }
+
if (!IS_ERR_OR_NULL(f_phonet)) {
phonet_stat = usb_add_function(c, f_phonet);
if (phonet_stat)
@@ -187,21 +222,36 @@ static int __init nokia_bind_config(struct 
usb_configuration *c)
pr_debug(could not bind ecm config %d\n, status);
goto err_ecm;
}
+
+   fsg_opts = fsg_opts_from_func_inst(fi_msg);
+
+   status = fsg_common_run_thread(fsg_opts-common);
+   if (status)
+   goto err_msg;
+
+   status = usb_add_function(c, f_msg);
+   if (status)
+   goto err_msg;
+
if (c == nokia_config_500ma_driver) {
f_acm_cfg1 = f_acm;
f_ecm_cfg1 = f_ecm;
f_phonet_cfg1 = f_phonet;
f_obex1_cfg1 = f_obex1;
f_obex2_cfg1 = f_obex2;
+   f_msg_cfg1 = f_msg;
} else {
f_acm_cfg2 = f_acm;
f_ecm_cfg2 = f_ecm;
f_phonet_cfg2 = f_phonet;
f_obex1_cfg2 = f_obex1;
f_obex2_cfg2 = f_obex2;
+   f_msg_cfg2 = f_msg;
}

return status;
+err_msg:
+   usb_remove_function(c, f_ecm);
  err_ecm:
usb_remove_function(c, f_acm);
  err_conf:
@@ -211,6 +261,8 @@ err_conf:
usb_remove_function(c, f_obex1);
if (!phonet_stat)
usb_remove_function(c, 

Re: [PATCH 1/1] usb: Remove Vernier devices from lsusb and hid_ignore_list

2015-05-28 Thread Jiri Kosina
On Thu, 21 May 2015, Dennis O'Brien wrote:

 From: Dennis O'Brien dennis.obr...@eqware.net
 
 Removes Vernier Software  Technology devices from the ldusb
 driver and the hid_ignore_list table of the usbhid driver in the
 Linux tree.  These devices will now be supported via the hidraw
 driver.
 
 A user space driver for these devices will be found in the
 Go! Software Development Kit from Vernier at
 http://www.vernier.com/downloads/software-development-kits/go-sdk/.
 These devices are also be supported by the LabQuest2 standalone
 interface shown at http://www.vernier.com/products/interfaces/labq2/
 and the LoggerPro for Linux software shown at
 http://www.vernier.com/downloads/logger-pro-linux/.

Given that the only thing this patch is in principle doing is dropping 
device support from ldusb driver, I am not applying it before getting Ack 
from Greg (or even seeing Greg merging it himself through his tree).

Greg ... ?

Thanks,

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


Re: [PATCH] usb: gadget: nokia: Add mass storage driver to g_nokia

2015-05-28 Thread Pali Rohár
On Thursday 28 May 2015 16:51:07 Krzysztof Opasiak wrote:
 
 
 On 05/28/2015 04:31 PM, Pali Rohár wrote:
 On Thursday 28 May 2015 16:27:44 Krzysztof Opasiak wrote:
 
 
 On 05/28/2015 09:47 AM, Pali Rohár wrote:
 On Saturday 31 January 2015 10:53:30 Pali Rohár wrote:
 This patch adds removable mass storage support to g_nokia gadget (for 
 N900).
 It means that at runtime block device can be exported or unexported.
 So it does not export anything by default and thus allows to use MyDocs
 partition as before...
 
 Signed-off-by: Pali Rohár pali.ro...@gmail.com
 ---
   drivers/usb/gadget/legacy/Kconfig |1 +
   drivers/usb/gadget/legacy/nokia.c |  102 
  -
   2 files changed, 102 insertions(+), 1 deletion(-)
 
 diff --git a/drivers/usb/gadget/legacy/Kconfig 
 b/drivers/usb/gadget/legacy/Kconfig
 index fd48ef3..36f6ba4 100644
 --- a/drivers/usb/gadget/legacy/Kconfig
 +++ b/drivers/usb/gadget/legacy/Kconfig
 @@ -345,6 +345,7 @@ config USB_G_NOKIA
   select USB_F_OBEX
   select USB_F_PHONET
   select USB_F_ECM
 + select USB_F_MASS_STORAGE
   help
 The Nokia composite gadget provides support for acm, obex
 and phonet in only one composite gadget driver.
 diff --git a/drivers/usb/gadget/legacy/nokia.c 
 b/drivers/usb/gadget/legacy/nokia.c
 index 9b8fd70..a09bb50 100644
 --- a/drivers/usb/gadget/legacy/nokia.c
 +++ b/drivers/usb/gadget/legacy/nokia.c
 @@ -24,6 +24,7 @@
   #include u_phonet.h
   #include u_ecm.h
   #include gadget_chips.h
 +#include f_mass_storage.h
 
   /* Defines */
 
 @@ -34,6 +35,29 @@ USB_GADGET_COMPOSITE_OPTIONS();
 
   USB_ETHERNET_MODULE_PARAMETERS();
 
 +static struct fsg_module_parameters fsg_mod_data = {
 + .stall = 0,
 + .luns = 2,
 + .removable_count = 2,
 + .removable = { 1, 1, },
 +};
 +
 +FSG_MODULE_PARAMETERS(/* no prefix */, fsg_mod_data);
 +
 +#ifdef CONFIG_USB_GADGET_DEBUG_FILES
 +
 +static unsigned int fsg_num_buffers = 
 CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS;
 +
 +#else
 +
 +/*
 + * Number of buffers we will use.
 + * 2 is usually enough for good buffering pipeline
 + */
 +#define fsg_num_buffers  CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS
 +
 +#endif /* CONFIG_USB_DEBUG */
 +
   #define NOKIA_VENDOR_ID 0x0421  /* Nokia */
   #define NOKIA_PRODUCT_ID0x01c8  /* Nokia Gadget */
 
 @@ -94,6 +118,8 @@ static struct usb_function *f_obex1_cfg2;
   static struct usb_function *f_obex2_cfg2;
   static struct usb_function *f_phonet_cfg1;
   static struct usb_function *f_phonet_cfg2;
 +static struct usb_function *f_msg_cfg1;
 +static struct usb_function *f_msg_cfg2;
 
 
   static struct usb_configuration nokia_config_500ma_driver = {
 @@ -117,6 +143,7 @@ static struct usb_function_instance *fi_ecm;
   static struct usb_function_instance *fi_obex1;
   static struct usb_function_instance *fi_obex2;
   static struct usb_function_instance *fi_phonet;
 +static struct usb_function_instance *fi_msg;
 
   static int __init nokia_bind_config(struct usb_configuration *c)
   {
 @@ -125,6 +152,8 @@ static int __init nokia_bind_config(struct 
 usb_configuration *c)
   struct usb_function *f_obex1 = NULL;
   struct usb_function *f_ecm;
   struct usb_function *f_obex2 = NULL;
 + struct usb_function *f_msg;
 + struct fsg_opts *fsg_opts;
   int status = 0;
   int obex1_stat = -1;
   int obex2_stat = -1;
 @@ -160,6 +189,12 @@ static int __init nokia_bind_config(struct 
 usb_configuration *c)
   goto err_get_ecm;
   }
 
 + f_msg = usb_get_function(fi_msg);
 + if (IS_ERR(f_msg)) {
 + status = PTR_ERR(f_msg);
 + goto err_get_msg;
 + }
 +
   if (!IS_ERR_OR_NULL(f_phonet)) {
   phonet_stat = usb_add_function(c, f_phonet);
   if (phonet_stat)
 @@ -187,21 +222,36 @@ static int __init nokia_bind_config(struct 
 usb_configuration *c)
   pr_debug(could not bind ecm config %d\n, status);
   goto err_ecm;
   }
 +
 + fsg_opts = fsg_opts_from_func_inst(fi_msg);
 +
 + status = fsg_common_run_thread(fsg_opts-common);
 + if (status)
 + goto err_msg;
 +
 + status = usb_add_function(c, f_msg);
 + if (status)
 + goto err_msg;
 +
   if (c == nokia_config_500ma_driver) {
   f_acm_cfg1 = f_acm;
   f_ecm_cfg1 = f_ecm;
   f_phonet_cfg1 = f_phonet;
   f_obex1_cfg1 = f_obex1;
   f_obex2_cfg1 = f_obex2;
 + f_msg_cfg1 = f_msg;
   } else {
   f_acm_cfg2 = f_acm;
   f_ecm_cfg2 = f_ecm;
   f_phonet_cfg2 = f_phonet;
   f_obex1_cfg2 = f_obex1;
   f_obex2_cfg2 = f_obex2;
 + f_msg_cfg2 = f_msg;
   }
 
   return status;
 +err_msg:
 + usb_remove_function(c, f_ecm);
   err_ecm:
   usb_remove_function(c, f_acm);
   err_conf:
 @@ 

Re: [PATCH] usb: ulpi: don't register drivers if bus doesn't exist

2015-05-28 Thread Greg KH
On Thu, May 28, 2015 at 11:09:38AM +0530, Sudip Mukherjee wrote:
 On Wed, May 27, 2015 at 08:21:16AM -0700, Greg KH wrote:
  On Wed, May 27, 2015 at 11:16:34AM -0400, Alan Stern wrote:
   On Wed, 27 May 2015, Heikki Krogerus wrote:
  
  Maybe we need to test for this in the driver core, not allowing drivers
  for busses that are not registered, that might solve the main problem
  here.  I'll try to look at it tonight.
 may i suggest something like this ?
 buildtest with allmodconfig and allyesconfig on x86_64.
 built and booted on x86.
 
 
 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
 index 5005924..95cefa0 100644
 --- a/drivers/base/bus.c
 +++ b/drivers/base/bus.c
 @@ -943,6 +943,7 @@ int bus_register(struct bus_type *bus)
   if (retval)
   goto bus_groups_fail;
  
 + bus-registered = true;
   pr_debug(bus: '%s': registered\n, bus-name);
   return 0;
  
 diff --git a/drivers/base/driver.c b/drivers/base/driver.c
 index 4eabfe2..1acae5b 100644
 --- a/drivers/base/driver.c
 +++ b/drivers/base/driver.c
 @@ -150,6 +150,11 @@ int driver_register(struct device_driver *drv)
   int ret;
   struct device_driver *other;
  
 + if (!drv-bus-registered) {
 + pr_err(Driver %s registration failed. bus not yet 
 registered\n,
 +drv-name);
 + return -ENODEV;
 + }
   BUG_ON(!drv-bus-p);
  
   if ((drv-bus-probe  drv-probe) ||
 diff --git a/include/linux/device.h b/include/linux/device.h
 index 00ac57c..8fe4745 100644
 --- a/include/linux/device.h
 +++ b/include/linux/device.h
 @@ -126,6 +126,7 @@ struct bus_type {
   const struct dev_pm_ops *pm;
  
   const struct iommu_ops *iommu_ops;
 + bool registered;/* DON'T TOUCH THIS */

As if anyone ever looks at comments and follows them :)

Anyway, let me look at this some more, I think this needs to go into the
individual buses, not the driver core.  There's a lot more to initialize
than just the driver core for most busses, they should be the ones to
allow a driver to be registered or not, not the driver core, which
shouldn't care.

I have some time on Saturday (very long plane ride), where I'll take a
look at this.

thanks,

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


Re: [PATCH 1/1] usb: Remove Vernier devices from lsusb and hid_ignore_list

2015-05-28 Thread Greg KH
On Thu, May 28, 2015 at 04:58:54PM +0200, Jiri Kosina wrote:
 On Thu, 21 May 2015, Dennis O'Brien wrote:
 
  From: Dennis O'Brien dennis.obr...@eqware.net
  
  Removes Vernier Software  Technology devices from the ldusb
  driver and the hid_ignore_list table of the usbhid driver in the
  Linux tree.  These devices will now be supported via the hidraw
  driver.
  
  A user space driver for these devices will be found in the
  Go! Software Development Kit from Vernier at
  http://www.vernier.com/downloads/software-development-kits/go-sdk/.
  These devices are also be supported by the LabQuest2 standalone
  interface shown at http://www.vernier.com/products/interfaces/labq2/
  and the LoggerPro for Linux software shown at
  http://www.vernier.com/downloads/logger-pro-linux/.
 
 Given that the only thing this patch is in principle doing is dropping 
 device support from ldusb driver, I am not applying it before getting Ack 
 from Greg (or even seeing Greg merging it himself through his tree).
 
 Greg ... ?

No objection from me:

Acked-by: Greg Kroah-Hartman gre...@linuxfoundation.org

But if you want me to take it in my tree, I can do that too, just
provide an ack and I will do so.

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: gadget: nokia: Add mass storage driver to g_nokia

2015-05-28 Thread Felipe Balbi
On Thu, May 28, 2015 at 04:59:18PM +0200, Pali Rohár wrote:
 On Thursday 28 May 2015 16:51:07 Krzysztof Opasiak wrote:
  
  
  On 05/28/2015 04:31 PM, Pali Rohár wrote:
  On Thursday 28 May 2015 16:27:44 Krzysztof Opasiak wrote:
  
  
  On 05/28/2015 09:47 AM, Pali Rohár wrote:
  On Saturday 31 January 2015 10:53:30 Pali Rohár wrote:
  This patch adds removable mass storage support to g_nokia gadget (for 
  N900).
  It means that at runtime block device can be exported or unexported.
  So it does not export anything by default and thus allows to use MyDocs
  partition as before...
  
  Signed-off-by: Pali Rohár pali.ro...@gmail.com
  ---
drivers/usb/gadget/legacy/Kconfig |1 +
drivers/usb/gadget/legacy/nokia.c |  102 
   -
2 files changed, 102 insertions(+), 1 deletion(-)
  
  diff --git a/drivers/usb/gadget/legacy/Kconfig 
  b/drivers/usb/gadget/legacy/Kconfig
  index fd48ef3..36f6ba4 100644
  --- a/drivers/usb/gadget/legacy/Kconfig
  +++ b/drivers/usb/gadget/legacy/Kconfig
  @@ -345,6 +345,7 @@ config USB_G_NOKIA
  select USB_F_OBEX
  select USB_F_PHONET
  select USB_F_ECM
  +   select USB_F_MASS_STORAGE
  help
The Nokia composite gadget provides support for acm, obex
and phonet in only one composite gadget driver.
  diff --git a/drivers/usb/gadget/legacy/nokia.c 
  b/drivers/usb/gadget/legacy/nokia.c
  index 9b8fd70..a09bb50 100644
  --- a/drivers/usb/gadget/legacy/nokia.c
  +++ b/drivers/usb/gadget/legacy/nokia.c
  @@ -24,6 +24,7 @@
#include u_phonet.h
#include u_ecm.h
#include gadget_chips.h
  +#include f_mass_storage.h
  
/* Defines */
  
  @@ -34,6 +35,29 @@ USB_GADGET_COMPOSITE_OPTIONS();
  
USB_ETHERNET_MODULE_PARAMETERS();
  
  +static struct fsg_module_parameters fsg_mod_data = {
  +   .stall = 0,
  +   .luns = 2,
  +   .removable_count = 2,
  +   .removable = { 1, 1, },
  +};
  +
  +FSG_MODULE_PARAMETERS(/* no prefix */, fsg_mod_data);
  +
  +#ifdef CONFIG_USB_GADGET_DEBUG_FILES
  +
  +static unsigned int fsg_num_buffers = 
  CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS;
  +
  +#else
  +
  +/*
  + * Number of buffers we will use.
  + * 2 is usually enough for good buffering pipeline
  + */
  +#define fsg_num_buffersCONFIG_USB_GADGET_STORAGE_NUM_BUFFERS
  +
  +#endif /* CONFIG_USB_DEBUG */
  +
#define NOKIA_VENDOR_ID   0x0421  /* Nokia */
#define NOKIA_PRODUCT_ID  0x01c8  /* Nokia Gadget */
  
  @@ -94,6 +118,8 @@ static struct usb_function *f_obex1_cfg2;
static struct usb_function *f_obex2_cfg2;
static struct usb_function *f_phonet_cfg1;
static struct usb_function *f_phonet_cfg2;
  +static struct usb_function *f_msg_cfg1;
  +static struct usb_function *f_msg_cfg2;
  
  
static struct usb_configuration nokia_config_500ma_driver = {
  @@ -117,6 +143,7 @@ static struct usb_function_instance *fi_ecm;
static struct usb_function_instance *fi_obex1;
static struct usb_function_instance *fi_obex2;
static struct usb_function_instance *fi_phonet;
  +static struct usb_function_instance *fi_msg;
  
static int __init nokia_bind_config(struct usb_configuration *c)
{
  @@ -125,6 +152,8 @@ static int __init nokia_bind_config(struct 
  usb_configuration *c)
  struct usb_function *f_obex1 = NULL;
  struct usb_function *f_ecm;
  struct usb_function *f_obex2 = NULL;
  +   struct usb_function *f_msg;
  +   struct fsg_opts *fsg_opts;
  int status = 0;
  int obex1_stat = -1;
  int obex2_stat = -1;
  @@ -160,6 +189,12 @@ static int __init nokia_bind_config(struct 
  usb_configuration *c)
  goto err_get_ecm;
  }
  
  +   f_msg = usb_get_function(fi_msg);
  +   if (IS_ERR(f_msg)) {
  +   status = PTR_ERR(f_msg);
  +   goto err_get_msg;
  +   }
  +
  if (!IS_ERR_OR_NULL(f_phonet)) {
  phonet_stat = usb_add_function(c, f_phonet);
  if (phonet_stat)
  @@ -187,21 +222,36 @@ static int __init nokia_bind_config(struct 
  usb_configuration *c)
  pr_debug(could not bind ecm config %d\n, status);
  goto err_ecm;
  }
  +
  +   fsg_opts = fsg_opts_from_func_inst(fi_msg);
  +
  +   status = fsg_common_run_thread(fsg_opts-common);
  +   if (status)
  +   goto err_msg;
  +
  +   status = usb_add_function(c, f_msg);
  +   if (status)
  +   goto err_msg;
  +
  if (c == nokia_config_500ma_driver) {
  f_acm_cfg1 = f_acm;
  f_ecm_cfg1 = f_ecm;
  f_phonet_cfg1 = f_phonet;
  f_obex1_cfg1 = f_obex1;
  f_obex2_cfg1 = f_obex2;
  +   f_msg_cfg1 = f_msg;
  } else {
  f_acm_cfg2 = f_acm;
  f_ecm_cfg2 = f_ecm;
  f_phonet_cfg2 = f_phonet;
  

Re: [PATCH] usb: ulpi: don't register drivers if bus doesn't exist

2015-05-28 Thread Alan Stern
On Thu, 28 May 2015, Felipe Balbi wrote:

 On Thu, May 28, 2015 at 11:09:38AM +0530, Sudip Mukherjee wrote:
  On Wed, May 27, 2015 at 08:21:16AM -0700, Greg KH wrote:
   On Wed, May 27, 2015 at 11:16:34AM -0400, Alan Stern wrote:
On Wed, 27 May 2015, Heikki Krogerus wrote:
   
   Maybe we need to test for this in the driver core, not allowing drivers
   for busses that are not registered, that might solve the main problem
   here.  I'll try to look at it tonight.
  may i suggest something like this ?
  buildtest with allmodconfig and allyesconfig on x86_64.
  built and booted on x86.
  
  
  diff --git a/drivers/base/bus.c b/drivers/base/bus.c
  index 5005924..95cefa0 100644
  --- a/drivers/base/bus.c
  +++ b/drivers/base/bus.c
  @@ -943,6 +943,7 @@ int bus_register(struct bus_type *bus)
  if (retval)
  goto bus_groups_fail;
   
  +   bus-registered = true;
 
 once set, it's never cleared.

It's worse than that...

  pr_debug(bus: '%s': registered\n, bus-name);
  return 0;
   
  diff --git a/drivers/base/driver.c b/drivers/base/driver.c
  index 4eabfe2..1acae5b 100644
  --- a/drivers/base/driver.c
  +++ b/drivers/base/driver.c
  @@ -150,6 +150,11 @@ int driver_register(struct device_driver *drv)
  int ret;
  struct device_driver *other;
   
  +   if (!drv-bus-registered) {
  +   pr_err(Driver %s registration failed. bus not yet 
  registered\n,
  +  drv-name);
  +   return -ENODEV;
  +   }
  BUG_ON(!drv-bus-p);
   
  if ((drv-bus-probe  drv-probe) ||
  diff --git a/include/linux/device.h b/include/linux/device.h
  index 00ac57c..8fe4745 100644
  --- a/include/linux/device.h
  +++ b/include/linux/device.h
  @@ -126,6 +126,7 @@ struct bus_type {
  const struct dev_pm_ops *pm;
   
  const struct iommu_ops *iommu_ops;
  +   bool registered;/* DON'T TOUCH THIS */
 
 I would rather use an atomic_t

What reason is there to use an atomic_t?  The value is never going to 
be changed by two threads at the same time.

More importantly, clearing the flag races with checking it.  If 
somebody tries to register a driver at the same time as the bus is 
unregistered, the result is undefined.

Of course, the same problem exists when a device is added to a bus at 
the same time as the bus is unregistered.

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