[PATCH] usb: core: add debugobjects support for urb object

2016-05-24 Thread changbin . du
From: "Du, Changbin" Add debugobject support to track the life time of struct urb. This feature help us detect violation of urb operations by generating a warning message from debugobject core. And we fix the possible issues at runtime to avoid oops if we can. I have done

[PATCH] usb: gadget: f_fs: report error if excess data received

2016-05-11 Thread changbin . du
From: "Du, Changbin" Since the buffer size for req is rounded up to maxpacketsize, then we may end up with more data then user space has space for. If it happen, we can keep the excess data for next i/o, or report an error. But we cannot silently drop data, because USB

[PATCH 2/2] Documentation: gadget_configfs: update UDC binding

2016-05-02 Thread changbin . du
From: "Du, Changbin" Add the usage of new binding mode 'any'. $ echo any > UDC Signed-off-by: Du, Changbin Signed-off-by: Du, Changbin --- Documentation/usb/gadget_configfs.txt | 6 -- 1 file changed, 4 insertions(+), 2

[PATCH 1/2] usb: configfs: allow UDC binding rule configured as binding to *any* UDC

2016-05-02 Thread changbin . du
From: "Du, Changbin" On most platforms, there is only one device controller available. In this case, we desn't care the UDC's name. So let's ignore the name by setting 'UDC' to 'any'. And also we can change UDC name at any time if it is not binded (no need set to ""

[PATCH 0/2] Add binding rule *any* support for USB Gadget Configfs

2016-05-02 Thread changbin . du
From: "Du, Changbin" When I am configuring Gadget Configfs, I need found a exactly UDC name before I can start my gadget. But, really I doesn't care about which UDC name is used, because I have only controller. "any" is a good option. Du, Changbin (2): usb: configfs:

[PATCH] usb: dwc3: usb/dwc3: fake dissconnect event when turn off pullup

2016-04-27 Thread changbin . du
From: "Du, Changbin" The dwc3 controller can't generate a disconnect event after it is stopped. Thus gadget dissconnect callback is not invoked when do soft dissconnect. Call dissconnect here to workaround this issue. Note, most time we still see disconnect be called that

[PATCH v4 0/2] Add a new debugfs entry to dump FIFO/Queue available space

2016-04-12 Thread changbin . du
From: "Du, Changbin" FIFO/Queue available space info can be used to debug dwc3 issues. First we remove unnecessary checking for debugfs api call, then add the new entry. Du, Changbin (2): usb: dwc3: make dwc3_debugfs_init return value be void usb: dwc3: add debugfs

[PATCH v4 2/2] usb: dwc3: add debugfs node to dump FIFO/Queue available space

2016-04-12 Thread changbin . du
From: "Du, Changbin" For DWC3 USB controller, the Global Debug Queue/FIFO Space Available Register(GDBGFIFOSPACE) can be used to dump FIFO/Queue available space. This can be used to check some special issues, like whether data is successfully copied from memory to fifo

[PATCH v4 1/2] usb: dwc3: make dwc3_debugfs_init return value be void

2016-04-12 Thread changbin . du
From: "Du, Changbin" Debugfs init failure is not so important. We can continue our job on this failure. Also no break need for debugfs_create_file call failure. Signed-off-by: Du, Changbin --- v4: Do not fail silently, but print error. ---

[PATCH v3] usb: dwc3: fix memory leak of dwc->regset

2016-04-12 Thread changbin . du
From: "Du, Changbin" dwc->regset is allocated on dwc3_debugfs_init, and should be released on init failure or dwc3_debugfs_exit. Btw, The line "dwc->root = NULL" is unnecessary, so remove it. Signed-off-by: Du, Changbin --- v3: remove unnecessary

[PATCH v2] usb: dwc3: fix memory leak of dwc->regset

2016-04-12 Thread changbin . du
From: "Du, Changbin" dwc->regset is allocated on dwc3_debugfs_init, and should be released on init failure or dwc3_debugfs_exit. Btw, The line "dwc->root = NULL" is unnecessary, so remove it. Signed-off-by: Du, Changbin --- v2: Title changed;

[PATCH] usb: dwc3: free dwc->regset on dwc3_debugfs_exit

2016-04-08 Thread changbin . du
From: "Du, Changbin" dwc->regset is allocated on dwc3_debugfs_init, and should be released on dwc3_debugfs_exit. Signed-off-by: Du, Changbin --- This patch is seperated from patch set: [PATCH v2 0/3] Improvement, fix and new entry for dwc3 debugfs

[PATCH v3 1/2] usb: dwc3: make dwc3_debugfs_init return value be void

2016-04-08 Thread changbin . du
From: "Du, Changbin" Debugfs init failure is not so important. We can continue our job on this failure. Also no need to check debugfs_create_file call results. Signed-off-by: Du, Changbin --- changes from v2: no changes ---

[PATCH v3 0/2] Add a new debugfs entry to dump FIFO/Queue available space

2016-04-08 Thread changbin . du
From: "Du, Changbin" FIFO/Queue available space info can be used to debug dwc3 issues. First we remove unnecessary checking for debugfs api call, then add the new entry. changes from v2: 1. Remove commit "usb: dwc3: free dwc->regset on dwc3_debugfs_exit" Du, Changbin

[PATCH v3 2/2] usb: dwc3: add debugfs node to dump FIFO/Queue available space

2016-04-08 Thread changbin . du
From: "Du, Changbin" For DWC3 USB controller, the Global Debug Queue/FIFO Space Available Register(GDBGFIFOSPACE) can be used to dump FIFO/Queue available space. This can be used to check some special issues, like whether data is successfully copied from memory to fifo

[PATCH v2 1/3] usb: dwc3: make dwc3_debugfs_init return value be void

2016-04-06 Thread changbin . du
From: "Du, Changbin" Debugfs init failure is not so important. We can continue our job on this failure. Also no need to check debugfs_create_file call results. Signed-off-by: Du, Changbin --- drivers/usb/dwc3/core.c| 10 +-

[PATCH v2 3/3] usb: dwc3: add debugfs node to dump FIFO/Queue available space

2016-04-06 Thread changbin . du
From: "Du, Changbin" For DWC3 USB controller, the Global Debug Queue/FIFO Space Available Register(GDBGFIFOSPACE) can be used to dump FIFO/Queue available space. This can be used to check some special issues, like whether data is successfully copied from memory to fifo

[PATCH v2 2/3] usb: dwc3: free dwc->regset on dwc3_debugfs_exit

2016-04-06 Thread changbin . du
From: "Du, Changbin" Signed-off-by: Du, Changbin --- drivers/usb/dwc3/debugfs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c index 071b286..2d4f397 100644 ---

[PATCH] usb: dwc3: rename __dwc3_cleanup_done_trbs to __dwc3_cleanup_one_trb

2016-03-30 Thread changbin . du
From: "Du, Changbin" Actually, the function only clean one trb. So rename the function. Signed-off-by: Du, Changbin --- drivers/usb/dwc3/gadget.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/dwc3/gadget.c

[PATCH] usb: hub: fix panic caused by NULL bos pointer during reset device

2016-03-08 Thread changbin . du
From: "Du, Changbin" This is a reworked patch based on reverted commit d8f00cd685f5 ("usb: hub: do not clear BOS field during reset device"). The privious one caused double mem-free if run to re_enumerate label. New patch title changed to distinguish from old one. And I

[PATCH] usb: f_fs: avoid race condition with ffs_epfile_io_complete

2015-12-28 Thread changbin . du
From: "Du, Changbin" ffs_epfile_io and ffs_epfile_io_complete runs in different context, but there is no synchronization between them. consider the following scenario: 1) ffs_epfile_io interrupted by sigal while wait_for_completion_interruptible 2) then ffs_epfile_io set

[PATCH v2] usb: gadget: fix double mem free for usb_request caused by wild pointers

2015-12-27 Thread changbin . du
From: "Du, Changbin" acm, ecm, hid, ncm, phonet, rndis and uvc functions all have double memory free issue. Set pointers to NULL after freed to avoid this. Here explain how it happen on acm function, others has analogical case. If acm_bind fails before allocate

[PATCH] usb: gadget: acm: set notify_req to NULL after freed to avoid double free

2015-12-25 Thread changbin . du
From: "Du, Changbin" If acm_bind fails before allocate notification and acm->notify_req is not set to NULL after freed last time, double free will happen. kernel BUG at mm/slub.c:3392! invalid opcode: [#1] PREEMPT SMP EIP is at kfree+0x172/0x180 Call Trace:

[PATCH v3] usb: gadget: forbid queuing request to a disabled ep

2015-12-17 Thread changbin . du
From: "Du, Changbin" Queue a request to disabled ep doesn't make sense, and induce caller make mistakes. Here is a example for the android mtp gadget function driver. A mem corruption can happen on below senario. 1) On disconnect, mtp driver disable its EPs, 2) During

[PATCH v4] usb: gadget: forbid queuing request to a disabled ep

2015-12-17 Thread changbin . du
From: "Du, Changbin" Queue a request to disabled ep doesn't make sense, and induce caller make mistakes. Here is a example for the android mtp gadget function driver. A mem corruption can happen on below senario. 1) On disconnect, mtp driver disable its EPs, 2) During

[PATCH v2] usb: gadget: forbid queuing request to a disabled ep

2015-12-13 Thread changbin . du
From: "Du, Changbin" Queue a request to disabled ep doesn't make sense, and induce caller make mistakes. Here is a example for the android mtp gadget function driver. A mem corruption can happen on below senario. 1) On disconnect, mtp driver disable its EPs, 2) During

[PATCH v2] usb: gadget: make usb_ep_enable return -EBUSY if ep has already enabled

2015-12-13 Thread changbin . du
From: "Du, Changbin" When usb_ep_enable on a enabled ep, the configuration of the ep probably has changed. In this scenario, the ep configuration in hw should be reprogrammed by udc driver. Hence, it is better to return an error to inform the caller. Signed-off-by: Du,

[PATCH] usb: gadget: forbid queuing request to a disabled ep

2015-12-03 Thread changbin . du
From: "Du, Changbin" Queue a request to disabled ep doesn't make sense, and induce caller make mistakes. Here is a example for the android mtp gadget function driver. A mem corruption can happen on below senario. 1) On disconnect, mtp driver disable its EPs, 2) During

[PATCH] usb: dwc2: fix transfer stop programming for out endpoint

2015-12-03 Thread changbin . du
From: "Du, Changbin" To stop an out endpoint, software should set sets the Global OUT NAK, but not the Global Non-periodic IN NAK. This driver bug leads the out-ep failed be in disabled state with below error. dwc2_hsotg_ep_stop_xfr: timeout DOEPCTL.EPDisable

[PATCH 0/2] Two fix for dwc2 gadget driver

2015-11-29 Thread changbin . du
From: "Du, Changbin" With the first patch, enable a enabled ep will return -EBUSY. The second patch forbid queuing on disabled ep to avoid panic. Du, Changbin (2): usb: dwc2: add ep enabled flag to avoid double enable/disable usb: dwc2: forbid queuing request to a

[PATCH 1/2] usb: dwc2: add ep enabled flag to avoid double enable/disable

2015-11-29 Thread changbin . du
From: "Du, Changbin" Enabling a already enabled ep is illegal, because the ep may has trbs running. Reprogram the ep may break running transfer. So udc driver must avoid this happening by return an error -EBUSY. Gadget function driver also should avoid such things, but

[PATCH 2/2] usb: dwc2: forbid queuing request to a disabled ep

2015-11-29 Thread changbin . du
From: "Du, Changbin" Queue a request to disabled ep doesn't make sense, and induce caller make mistakes. Here is a example for the android mtp gadget function driver. A mem corruption can happen on below senario. 1) On disconnect, mtp driver disable its EPs, 2) During