Re: Errata for Freescale root-hub TT?
On Mon, 29 Jun 2015, Peter Chen wrote: Hi Alan, I am not sure if you have noticed the patch[1], it is the solution for this issue, in the RTL, the default reserved time for one packet is 1023 bytes for siTD, so after 4 * 64 packets has transfered, the reserved time is not enough for 1023 bytes packet. This issue should exist at all ARC/Chipidea cores. [1] http://www.spinics.net/lists/linux-usb/msg126278.html No, I did not notice it. Thank you for pointing it out. It's kind of surprising that this bug has existed for so long and nobody realized until recently. 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: 64 byte EP0 OUT data transfer issue on Chipidea highspeed dual role controller
On Mon, 29 Jun 2015, Peter Chen wrote: Just like Steve pointed, it should be a ZLT problem, do you have below patch in your tree, and the host may not send zlt, but you may queue an zero-length request, the f_hid does not set req-zero flag either. commit 953c66469735aed8d2ada639a72b150f01dae605 Author: Abbas Raza abbas_r...@mentor.com Date: Thu Jul 17 19:34:31 2014 +0800 usb: chipidea: udc: Disable auto ZLP generation on ep0 If it still has problem, send me apps if possible (with needed kernel patches). Note that a UDC should _never_ queue an extra zero-length packet for an OUT transfer, no matter how req-zero is set. In other words, req-zero is supposed to affect only IN transfers. Alan Stern -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH][RFC] usbhid: enable autosuspend for internal devices
On Mon, 2015-06-29 at 13:16 +0200, Jiri Kosina wrote: On Mon, 29 Jun 2015, Oliver Neukum wrote: Last time we were testing this, autosuspend for USB HID devices was quite a disaster. Do you have any idea whether udev developers tested the autosuspend on by default for USB HID devices on reasonable set of devices? The culrpits that I remember from top of my head (it's been long time ago): - the LEDs for suspended device go off. This is very confusing at least on keyboards, and brings really bad user experience That is a bug. hidinput_count_leds() is supposed to prevent that. This is a HW property and nothing kernel can do about. I am not saying it doesn't bring the LEDs up to a proper state again once auto-resumed. But I hate the LEDs going off a few seconds after I stop typing (i.e. once the keyboard gets auto-suspended). That is the point. Unless you give the option to override, they shouldn't autosuspend. 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
USB disks not recognized during boot
[ Please keep me in CC as I'm not subscribed ] Hello, I'm the happy owner of a Intel NUC D54250WYKH (updated it to latest Intel firmware) which has an XHCI host controller. It's connected over USB 3 to a JBOD-configured disk enclosure (ICYBOX IB-RD3640SU3E2) which uses a JMicron USB to ATA bridge. I have attached the output of lspci -v, lsusb -v, lshw to describe the hardware in more details. When I boot the computer, the disk enclosure is not detected/recognized (even though it's correctly powered up). I have to power cycle the disk enclosure while the NUC is running so that it gets properly detected (see dmesg-powercycle). The kernel messages do not show any obvious error during boot (see attached file dmesg-boot) I have this problem with the stock 4.1 kernel as well as all Debian kernels (3.16.x in Jessie, 4.0.x in Stretch). While googling for possible solutions to force a new detection of the hardware, I found the explanation of how to unbind/rebind the xhci_hcd module: echo -n :00:14.0 /sys/bus/pci/drivers/xhci_hcd/unbind echo -n :00:14.0 /sys/bus/pci/drivers/xhci_hcd/bind (with :00:14.0 the PCI identifier of the xHCI root hub) This does not work for me. The undetected disk enclosure stays unnoticed... only the hardware power cycle works. I also tried to tweak the usbcore options (disabling autosuspend, old_scheme_first=Y, increasing initial_descriptor_timeout to 15000) but none of this did help. Do you have any suggestion of what could be wrong in my setup ? I'm happy to try patches and/or do further tests. Cheers, -- Raphaël Hertzog ◈ Debian Developer Support Debian LTS: http://www.freexian.com/services/debian-lts.html Learn to master Debian: http://debian-handbook.info/get/ 00:00.0 Host bridge: Intel Corporation Haswell-ULT DRAM Controller (rev 09) Subsystem: Intel Corporation Device 2054 Flags: bus master, fast devsel, latency 0 Capabilities: [e0] Vendor Specific Information: Len=0c ? 00:02.0 VGA compatible controller: Intel Corporation Haswell-ULT Integrated Graphics Controller (rev 09) (prog-if 00 [VGA controller]) Subsystem: Intel Corporation Device 2054 Flags: bus master, fast devsel, latency 0, IRQ 45 Memory at f780 (64-bit, non-prefetchable) [size=4M] Memory at e000 (64-bit, prefetchable) [size=256M] I/O ports at f000 [size=64] Expansion ROM at unassigned [disabled] Capabilities: [90] MSI: Enable+ Count=1/1 Maskable- 64bit- Capabilities: [d0] Power Management version 2 Capabilities: [a4] PCI Advanced Features Kernel driver in use: i915 00:03.0 Audio device: Intel Corporation Haswell-ULT HD Audio Controller (rev 09) Subsystem: Intel Corporation Device 2054 Flags: bus master, fast devsel, latency 0, IRQ 48 Memory at f7c34000 (64-bit, non-prefetchable) [size=16K] Capabilities: [50] Power Management version 2 Capabilities: [60] MSI: Enable+ Count=1/1 Maskable- 64bit- Capabilities: [70] Express Root Complex Integrated Endpoint, MSI 00 Kernel driver in use: snd_hda_intel 00:14.0 USB controller: Intel Corporation 8 Series USB xHCI HC (rev 04) (prog-if 30 [XHCI]) Subsystem: Intel Corporation Device 2054 Flags: bus master, medium devsel, latency 0, IRQ 42 Memory at f7c2 (64-bit, non-prefetchable) [size=64K] Capabilities: [70] Power Management version 2 Capabilities: [80] MSI: Enable+ Count=1/8 Maskable- 64bit+ Kernel driver in use: xhci_hcd 00:16.0 Communication controller: Intel Corporation 8 Series HECI #0 (rev 04) Subsystem: Intel Corporation Device 2054 Flags: bus master, fast devsel, latency 0, IRQ 47 Memory at f7c3d000 (64-bit, non-prefetchable) [size=32] Capabilities: [50] Power Management version 3 Capabilities: [8c] MSI: Enable+ Count=1/1 Maskable- 64bit+ Kernel driver in use: mei_me 00:19.0 Ethernet controller: Intel Corporation Ethernet Connection I218-V (rev 04) Subsystem: Intel Corporation Device 2054 Flags: bus master, fast devsel, latency 0, IRQ 43 Memory at f7c0 (32-bit, non-prefetchable) [size=128K] Memory at f7c3b000 (32-bit, non-prefetchable) [size=4K] I/O ports at f080 [size=32] Capabilities: [c8] Power Management version 2 Capabilities: [d0] MSI: Enable+ Count=1/1 Maskable- 64bit+ Capabilities: [e0] PCI Advanced Features Kernel driver in use: e1000e 00:1b.0 Audio device: Intel Corporation 8 Series HD Audio Controller (rev 04) Subsystem: Intel Corporation Device 2054 Flags: bus master, fast devsel, latency 0, IRQ 46 Memory at f7c3 (64-bit, non-prefetchable) [size=16K] Capabilities: [50] Power Management version 3 Capabilities: [60] MSI: Enable+ Count=1/1 Maskable- 64bit+ Capabilities: [70] Express Root Complex Integrated Endpoint, MSI 00
Re: [PATCH][RFC] usbhid: enable autosuspend for internal devices
On Mon, 29 Jun 2015, Oliver Neukum wrote: Last time we were testing this, autosuspend for USB HID devices was quite a disaster. Do you have any idea whether udev developers tested the autosuspend on by default for USB HID devices on reasonable set of devices? The culrpits that I remember from top of my head (it's been long time ago): - the LEDs for suspended device go off. This is very confusing at least on keyboards, and brings really bad user experience That is a bug. hidinput_count_leds() is supposed to prevent that. This is a HW property and nothing kernel can do about. I am not saying it doesn't bring the LEDs up to a proper state again once auto-resumed. But I hate the LEDs going off a few seconds after I stop typing (i.e. once the keyboard gets auto-suspended). -- 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][RFC] usbhid: enable autosuspend for internal devices
On Mon, 29 Jun 2015, Oliver Neukum wrote: This is a HW property and nothing kernel can do about. I am not saying it doesn't bring the LEDs up to a proper state again once auto-resumed. But I hate the LEDs going off a few seconds after I stop typing (i.e. once the keyboard gets auto-suspended). That is the point. Unless you give the option to override, they shouldn't autosuspend. Ah, you're right, I completely forgot about the logic we've put into hidinput_count_leds() quite some time ago. Sorry for the noise, -- 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][RFC] usbhid: enable autosuspend for internal devices
On Sat, 2015-06-27 at 08:29 +0200, Jiri Kosina wrote: On Fri, 26 Jun 2015, Greg Kroah-Hartman wrote: Last time we were testing this, autosuspend for USB HID devices was quite a disaster. Do you have any idea whether udev developers tested the autosuspend on by default for USB HID devices on reasonable set of devices? The culrpits that I remember from top of my head (it's been long time ago): - the LEDs for suspended device go off. This is very confusing at least on keyboards, and brings really bad user experience That is a bug. hidinput_count_leds() is supposed to prevent that. What did you test? - many keyboards were losing first keystroke when waking up from suspend. We've been debugging this with Alan, and never root-caused it to a problem in our code, it seems to be the property of the HW - mice don't wake up from movement alone. And again I would state that we don't get enough information from user space. Hardware seems to be designed for sleeping while a screen saver is on. In kernel space we just get a binary input desired or not desired from open/close. That is insufficient. Regards Oliver -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2] usb: xhci: Add support for URB_ZERO_PACKET to bulk/sg transfers
Hi On 29.06.2015 03:53, Reyad Attiyat wrote: This commmit checks for the URB_ZERO_PACKET flag and creates an extra zero-length td if the urb transfer length is a multiple of the endpoint's max packet length. Signed-off-by: Reyad Attiyat reyad.atti...@gmail.com --- Thanks for the patch. Generic idea and implementation looks good, there are some opens though See comments and questions inline. drivers/usb/host/xhci-ring.c | 43 +-- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 7d34cbf..3d57a7a 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -3040,7 +3040,9 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, int num_sgs; int trb_buff_len, this_sg_len, running_total; unsigned int total_packet_count; + bool zero_length_needed; bool first_trb; + int last_trb; last_trb isn't a really a good name as it might be confused with td-last_trb. It's used for different purposes here. u64 addr; bool more_trbs_coming; @@ -3056,6 +3058,14 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, total_packet_count = DIV_ROUND_UP(urb-transfer_buffer_length, usb_endpoint_maxp(urb-ep-desc)); + /* Deal with URB_ZERO_PACKET - need one more td/trb */ + zero_length_needed = (urb-transfer_flags URB_ZERO_PACKET) + !(urb-transfer_buffer_length % usb_endpoint_maxp(urb-ep-desc)); Please move the to end of previous line. (minor thing but helps readability) Checkpatch also complains about missing whitespaces in the if () statements. + if(zero_length_needed){ + num_trbs++; + xhci_dbg(xhci, Creating zero length td.\n); + } + trb_buff_len = prepare_transfer(xhci, xhci-devs[slot_id], ep_index, urb-stream_id, num_trbs, urb, 0, mem_flags); @@ -3092,6 +3102,7 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, trb_buff_len = urb-transfer_buffer_length; first_trb = true; + last_trb = zero_length_needed ? 2 : 1; /* Queue the first TRB, even if it's zero-length */ do { u32 field = 0; @@ -3109,12 +3120,13 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, /* Chain all the TRBs together; clear the chain bit in the last * TRB to indicate it's the last TRB in the chain. */ - if (num_trbs 1) { + if (num_trbs last_trb) { field |= TRB_CHAIN; - } else { - /* FIXME - add check for ZERO_PACKET flag before this */ + } else if (num_trbs == last_trb) { td-last_trb = ep_ring-enqueue; field |= TRB_IOC; + } else if (zero_length_needed num_trbs == 1) { + trb_buff_len = 0; } Normally chain bits are set for all TRBs except the last TRB, and the IOC (interrupt on completion) is usually set for only the last TRB. In case last_trb == 2, the chain bit is now not set between the TRB containing the last data and the actual last zero TRB, which is the last TRB in the TD. It now also sets the interrupt on completion (IOC) for the TRB with the last data, but not for the final last, zero lengt TRB in the TD. Is this intentional and how we want zero packet bulk transfers to behave? -Mathias -- 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: 64 byte EP0 OUT data transfer issue on Chipidea highspeed dual role controller
On Tue, Jun 30, 2015 at 12:33 AM, Steve Calfee stevecal...@gmail.com wrote: On Mon, Jun 29, 2015 at 7:16 AM, Alan Stern st...@rowland.harvard.edu wrote: On Mon, 29 Jun 2015, Peter Chen wrote: Just like Steve pointed, it should be a ZLT problem, do you have below patch in your tree, and the host may not send zlt, but you may queue an zero-length request, the f_hid does not set req-zero flag either. commit 953c66469735aed8d2ada639a72b150f01dae605 Author: Abbas Raza abbas_r...@mentor.com Date: Thu Jul 17 19:34:31 2014 +0800 usb: chipidea: udc: Disable auto ZLP generation on ep0 If it still has problem, send me apps if possible (with needed kernel patches). Note that a UDC should _never_ queue an extra zero-length packet for an OUT transfer, no matter how req-zero is set. In other words, req-zero is supposed to affect only IN transfers. Yes UDC gadgets receive packets sent by the host on OUT transfers. If ZLT transfers are needed for the protocol, a short transfer is needed to end an OUT sequence and it must be sent by the sender, in this case the host. The UDC should detect receiving a zero length EP0 OUT and that signals the end of the 64 byte transfer from host to gadget. Regards, Steve Thanks Alan, Peter and Steve for your help and quick response. In fact, today I tested with a similar patch i.e. have QH_IOS and QH_ZLT set for control endpoint in udc.c. The 64 byte transfer appears to work fine. I am not sure whether this is the ideal solution, Testing some more to ensure that there are no regressions. I will send out an update in about a day. The most probably is the QH_ZLT bit, your tree may not the patch I mentioned above. The QH_IOS only affects a setup being received. Peter
Re: 64 byte EP0 OUT data transfer issue on Chipidea highspeed dual role controller
On Mon, Jun 29, 2015 at 7:16 AM, Alan Stern st...@rowland.harvard.edu wrote: On Mon, 29 Jun 2015, Peter Chen wrote: Just like Steve pointed, it should be a ZLT problem, do you have below patch in your tree, and the host may not send zlt, but you may queue an zero-length request, the f_hid does not set req-zero flag either. commit 953c66469735aed8d2ada639a72b150f01dae605 Author: Abbas Raza abbas_r...@mentor.com Date: Thu Jul 17 19:34:31 2014 +0800 usb: chipidea: udc: Disable auto ZLP generation on ep0 If it still has problem, send me apps if possible (with needed kernel patches). Note that a UDC should _never_ queue an extra zero-length packet for an OUT transfer, no matter how req-zero is set. In other words, req-zero is supposed to affect only IN transfers. Yes UDC gadgets receive packets sent by the host on OUT transfers. If ZLT transfers are needed for the protocol, a short transfer is needed to end an OUT sequence and it must be sent by the sender, in this case the host. The UDC should detect receiving a zero length EP0 OUT and that signals the end of the 64 byte transfer from host to gadget. Regards, Steve -- 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: 64 byte EP0 OUT data transfer issue on Chipidea highspeed dual role controller
On Sun, Jun 28, 2015 at 12:41 AM, Jayan John jayanjoh...@gmail.com wrote: If this is a bug in the chipidea UDC driver or hardware, how can I address this i.e. register an errata? I am hoping this is something Peter might be able to help with. What is the kernel version you are using? Could you test it with kernel 4.1? -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH RESEND v2 0/3] usb: dwc2: fix sleep while atomic bugs
Am Montag, 29. Juni 2015, 11:05:27 schrieb Mian Yousaf Kaukab: This series fixes 3 sources of sleep while atomic bugs. Including the one reported by Heiko Stuebner here: http://www.spinics.net/lists/linux-usb/msg125186.html Please review. the current state of mainline during the merge window emits the sleep while atomic warnings. This series fixes it [and usb of course still works :-) ], so it would probably be nice getting this into rc1 or so. Heiko Thank you, Best regards, Yousaf History: v2: - Fixed John's comment v1: - Added John's Acked-by Mian Yousaf Kaukab (3): usb: dwc2: host: allocate qh before atomic enqueue usb: dwc2: host: allocate qtd before atomic enqueue usb: dwc2: embed storage for reg backup in struct dwc2_hsotg drivers/usb/dwc2/core.c | 55 drivers/usb/dwc2/core.h | 9 +--- drivers/usb/dwc2/hcd.c | 55 +--- drivers/usb/dwc2/hcd.h | 5 +++- drivers/usb/dwc2/hcd_queue.c | 49 ++- 5 files changed, 79 insertions(+), 94 deletions(-) -- 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 v5 0/6] usb: interface authorization
Am Donnerstag, den 18.06.2015, 13:30 -0400 schrieb Alan Stern: On Thu, 18 Jun 2015, Stefan Koch wrote: This patch introduces an interface authorization for USB devices. The kernel supports a device authorization because of wireless USB. But the new interface authorization allows to authorize or deauthorize individual interfaces instead authorization or deauthorize a whole device. Therefore the authorized attribute is introduced for each interface. Each patch depends on all patches with a lesser number. Stefan Koch (6): usb: interface authorization: Declare authorized attribute usb: interface authorization: Introduces the default interface authorization usb: interface authorization: Control interface probing and claiming usb: interface authorization: Introduces the USB interface authorization. usb: interface authorization: SysFS part of USB interface authorization. usb: interface authorization: Documentation part Documentation/ABI/testing/sysfs-bus-usb | 22 ++ Documentation/usb/authorization.txt | 34 + drivers/usb/core/driver.c | 11 +++ drivers/usb/core/hcd.c | 52 + drivers/usb/core/message.c | 48 ++ drivers/usb/core/sysfs.c| 41 ++ drivers/usb/core/usb.h | 2 ++ include/linux/usb.h | 1 + include/linux/usb/hcd.h | 3 ++ 9 files changed, 214 insertions(+) Acked-by: Alan Stern st...@rowland.harvard.edu Other people may still have some comments. Alan Stern Hi is there any current merging state? In what git tree the patch will submitted at the first step? Best regards Stefan Koch -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 3/3] usb: dwc3: gadget: return error if command sent to DEPCMD register fails
Hi again, On Mon, Jun 29, 2015 at 04:47:01PM -0500, Felipe Balbi wrote: On Thu, May 21, 2015 at 03:46:48PM +0530, Subbaraya Sundeep Bhatta wrote: We need to return error to caller if command is not sent to controller succesfully. Signed-off-by: Subbaraya Sundeep Bhatta sbha...@xilinx.com Fixes: 72246da40f37 (usb: Introduce DesignWare USB3 DRD Driver) Cc: sta...@vger.kernel.org --- v2 changes: Added Fixes and Cc in commit message. I noticed that this breaks at least my AM437x silicon with DWC3 2.40a when used with g_zero and testusb. As of now, it could be that silicon is mis-behaving because I got a Transfer Complete before the failing Set Endpoint Transfer Resource command. In any case, can you run on your setup with g_zero and test.sh/testusb [1]/[2] just to verify that it really works for you ? Meanwhile, I'll continue testing on my end. cheers [1] https://gitorious.org/usb/usb-tools/source/47ef073d9b6c0eae816204c81374aafb795c6e40:testusb.c [2] https://gitorious.org/usb/usb-tools/source/47ef073d9b6c0eae816204c81374aafb795c6e40:test.sh Adding John here. John, any chance you could fire up dwc3 on HAPS and see wether it works or fails for you ? cheers -- balbi signature.asc Description: Digital signature
Re: [PATCH v2 3/3] usb: dwc3: gadget: return error if command sent to DEPCMD register fails
Hi, On Thu, May 21, 2015 at 03:46:48PM +0530, Subbaraya Sundeep Bhatta wrote: We need to return error to caller if command is not sent to controller succesfully. Signed-off-by: Subbaraya Sundeep Bhatta sbha...@xilinx.com Fixes: 72246da40f37 (usb: Introduce DesignWare USB3 DRD Driver) Cc: sta...@vger.kernel.org --- v2 changes: Added Fixes and Cc in commit message. I noticed that this breaks at least my AM437x silicon with DWC3 2.40a when used with g_zero and testusb. As of now, it could be that silicon is mis-behaving because I got a Transfer Complete before the failing Set Endpoint Transfer Resource command. In any case, can you run on your setup with g_zero and test.sh/testusb [1]/[2] just to verify that it really works for you ? Meanwhile, I'll continue testing on my end. cheers [1] https://gitorious.org/usb/usb-tools/source/47ef073d9b6c0eae816204c81374aafb795c6e40:testusb.c [2] https://gitorious.org/usb/usb-tools/source/47ef073d9b6c0eae816204c81374aafb795c6e40:test.sh -- balbi signature.asc Description: Digital signature
Re: [PATCH v5 0/6] usb: interface authorization
On Mon, Jun 29, 2015 at 11:23:47PM +0200, Stefan Koch wrote: Am Donnerstag, den 18.06.2015, 13:30 -0400 schrieb Alan Stern: On Thu, 18 Jun 2015, Stefan Koch wrote: This patch introduces an interface authorization for USB devices. The kernel supports a device authorization because of wireless USB. But the new interface authorization allows to authorize or deauthorize individual interfaces instead authorization or deauthorize a whole device. Therefore the authorized attribute is introduced for each interface. Each patch depends on all patches with a lesser number. Stefan Koch (6): usb: interface authorization: Declare authorized attribute usb: interface authorization: Introduces the default interface authorization usb: interface authorization: Control interface probing and claiming usb: interface authorization: Introduces the USB interface authorization. usb: interface authorization: SysFS part of USB interface authorization. usb: interface authorization: Documentation part Documentation/ABI/testing/sysfs-bus-usb | 22 ++ Documentation/usb/authorization.txt | 34 + drivers/usb/core/driver.c | 11 +++ drivers/usb/core/hcd.c | 52 + drivers/usb/core/message.c | 48 ++ drivers/usb/core/sysfs.c| 41 ++ drivers/usb/core/usb.h | 2 ++ include/linux/usb.h | 1 + include/linux/usb/hcd.h | 3 ++ 9 files changed, 214 insertions(+) Acked-by: Alan Stern st...@rowland.harvard.edu Other people may still have some comments. Alan Stern Hi is there any current merging state? In what git tree the patch will submitted at the first step? I can't do anything at the moment due to the merge window. I'll review it after 4.2-rc1 is out (usually a week or so afterward, as my queue is quite large). Don't worry, it's not lost. greg k-h -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v6 16/23] usb: gadget: g_ffs: allocate and init otg descriptor by otg capabilities
Allocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations. If otg capability is not defined, keep its original otg descriptor unchanged. Signed-off-by: Li Jun jun...@freescale.com --- drivers/usb/gadget/legacy/g_ffs.c | 32 +--- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/drivers/usb/gadget/legacy/g_ffs.c b/drivers/usb/gadget/legacy/g_ffs.c index 7b9ef7e..ddb853d 100644 --- a/drivers/usb/gadget/legacy/g_ffs.c +++ b/drivers/usb/gadget/legacy/g_ffs.c @@ -88,21 +88,7 @@ MODULE_PARM_DESC(bDeviceProtocol, USB Device protocol); module_param_array_named(functions, func_names, charp, func_num, 0); MODULE_PARM_DESC(functions, USB Functions list); -static const struct usb_descriptor_header *gfs_otg_desc[] = { - (const struct usb_descriptor_header *) - (const struct usb_otg_descriptor) { - .bLength= sizeof(struct usb_otg_descriptor), - .bDescriptorType= USB_DT_OTG, - - /* -* REVISIT SRP-only hardware is possible, although -* it would not be called OTG ... -*/ - .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, - }, - - NULL -}; +static const struct usb_descriptor_header *gfs_otg_desc[2]; /* String IDs are assigned dynamically */ static struct usb_string gfs_strings[] = { @@ -410,6 +396,17 @@ static int gfs_bind(struct usb_composite_dev *cdev) goto error_rndis; gfs_dev_desc.iProduct = gfs_strings[USB_GADGET_PRODUCT_IDX].id; + if (gadget_is_otg(cdev-gadget) !gfs_otg_desc[0]) { + struct usb_descriptor_header *usb_desc; + + usb_desc = usb_otg_descriptor_alloc(cdev-gadget); + if (!usb_desc) + goto error_rndis; + usb_otg_descriptor_init(cdev-gadget, usb_desc); + gfs_otg_desc[0] = usb_desc; + gfs_otg_desc[1] = NULL; + } + for (i = 0; i ARRAY_SIZE(gfs_configurations); ++i) { struct gfs_configuration *c = gfs_configurations + i; int sid = USB_GADGET_FIRST_AVAIL_IDX + i; @@ -430,6 +427,8 @@ static int gfs_bind(struct usb_composite_dev *cdev) /* TODO */ error_unbind: + kfree(gfs_otg_desc[0]); + gfs_otg_desc[0] = NULL; error_rndis: #ifdef CONFIG_USB_FUNCTIONFS_RNDIS usb_put_function_instance(fi_rndis); @@ -471,6 +470,9 @@ static int gfs_unbind(struct usb_composite_dev *cdev) for (i = 0; i N_CONF * func_num; ++i) usb_put_function(*(f_ffs[0] + i)); + kfree(gfs_otg_desc[0]); + gfs_otg_desc[0] = NULL; + return 0; } -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v6 08/23] usb: chipidea: set usb otg capabilities
Init and update otg capabilities by DT, set gadget's otg capabilities accordingly. Signed-off-by: Li Jun jun...@freescale.com --- drivers/usb/chipidea/core.c | 10 ++ drivers/usb/chipidea/udc.c | 7 ++- include/linux/usb/chipidea.h | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index 74fea4f..248f571 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -588,6 +588,16 @@ static int ci_get_platdata(struct device *dev, of_usb_host_tpl_support(dev-of_node); } + if (platdata-dr_mode == USB_DR_MODE_OTG) { + /* We can support HNP and SRP of OTG 2.0 */ + platdata-ci_otg_caps.otg_rev = 0x0200; + platdata-ci_otg_caps.hnp_support = true; + platdata-ci_otg_caps.srp_support = true; + + /* Update otg capabilities by DT properties */ + of_usb_update_otg_caps(dev-of_node, platdata-ci_otg_caps); + } + if (of_usb_get_maximum_speed(dev-of_node) == USB_SPEED_FULL) platdata-flags |= CI_HDRC_FORCE_FULLSPEED; diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index 764f668..b7cca3e 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c @@ -1827,6 +1827,7 @@ static irqreturn_t udc_irq(struct ci_hdrc *ci) static int udc_start(struct ci_hdrc *ci) { struct device *dev = ci-dev; + struct usb_otg_caps *otg_caps = ci-platdata-ci_otg_caps; int retval = 0; spin_lock_init(ci-lock); @@ -1834,8 +1835,12 @@ static int udc_start(struct ci_hdrc *ci) ci-gadget.ops = usb_gadget_ops; ci-gadget.speed= USB_SPEED_UNKNOWN; ci-gadget.max_speed= USB_SPEED_HIGH; - ci-gadget.is_otg = ci-is_otg ? 1 : 0; ci-gadget.name = ci-platdata-name; + ci-gadget.otg_caps = otg_caps; + + if (otg_caps-hnp_support || otg_caps-srp_support || + otg_caps-adp_support) + ci-gadget.is_otg = 1; INIT_LIST_HEAD(ci-gadget.ep_list); diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h index ab94f78..e10cefc 100644 --- a/include/linux/usb/chipidea.h +++ b/include/linux/usb/chipidea.h @@ -34,6 +34,7 @@ struct ci_hdrc_platform_data { #define CI_HDRC_CONTROLLER_STOPPED_EVENT 1 void(*notify_event) (struct ci_hdrc *ci, unsigned event); struct regulator*reg_vbus; + struct usb_otg_caps ci_otg_caps; booltpl_support; }; -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v6 09/23] usb: chipidea: update ci_otg_is_fsm_mode conditions
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 in debug.c after the API change. Signed-off-by: Li Jun jun...@freescale.com --- drivers/usb/chipidea/ci.h| 5 - drivers/usb/chipidea/debug.c | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h index 6d6200e..f243f0b 100644 --- a/drivers/usb/chipidea/ci.h +++ b/drivers/usb/chipidea/ci.h @@ -406,8 +406,11 @@ 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 + struct usb_otg_caps *otg_caps = ci-platdata-ci_otg_caps; + return ci-is_otg ci-roles[CI_ROLE_HOST] - ci-roles[CI_ROLE_GADGET]; + ci-roles[CI_ROLE_GADGET] (otg_caps-srp_support || + otg_caps-hnp_support || otg_caps-adp_support); #else return false; #endif diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c index 5b7061a..3869c6d 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 -- 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 v6 22/23] usb: gadget: serial: allocate and init otg descriptor by otg capabilities
Allocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations. If otg capability is not defined, keep its original otg descriptor unchanged. Signed-off-by: Li Jun jun...@freescale.com --- drivers/usb/gadget/legacy/serial.c | 29 +++-- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/drivers/usb/gadget/legacy/serial.c b/drivers/usb/gadget/legacy/serial.c index 8b7528f..d1cd025 100644 --- a/drivers/usb/gadget/legacy/serial.c +++ b/drivers/usb/gadget/legacy/serial.c @@ -79,20 +79,7 @@ static struct usb_device_descriptor device_desc = { .bNumConfigurations = 1, }; -static struct usb_otg_descriptor otg_descriptor = { - .bLength = sizeof otg_descriptor, - .bDescriptorType = USB_DT_OTG, - - /* REVISIT SRP-only hardware is possible, although -* it would not be called OTG ... -*/ - .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, -}; - -static const struct usb_descriptor_header *otg_desc[] = { - (struct usb_descriptor_header *) otg_descriptor, - NULL, -}; +static const struct usb_descriptor_header *otg_desc[2]; /*-*/ @@ -191,6 +178,16 @@ static int gs_bind(struct usb_composite_dev *cdev) serial_config_driver.iConfiguration = status; if (gadget_is_otg(cdev-gadget)) { + if (!otg_desc[0]) { + struct usb_descriptor_header *usb_desc; + + usb_desc = usb_otg_descriptor_alloc(cdev-gadget); + if (!usb_desc) + return -ENOMEM; + usb_otg_descriptor_init(cdev-gadget, usb_desc); + otg_desc[0] = usb_desc; + otg_desc[1] = NULL; + } serial_config_driver.descriptors = otg_desc; serial_config_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP; } @@ -227,6 +224,10 @@ static int gs_unbind(struct usb_composite_dev *cdev) usb_put_function(f_serial[i]); usb_put_function_instance(fi_serial[i]); } + + kfree(otg_desc[0]); + otg_desc[0] = NULL; + return 0; } -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v6 18/23] usb: gadget: mass_storage: allocate and init otg descriptor by otg capabilities
Allocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations. If otg capability is not defined, keep its original otg descriptor unchanged. Signed-off-by: Li Jun jun...@freescale.com --- drivers/usb/gadget/legacy/mass_storage.c | 35 +--- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/drivers/usb/gadget/legacy/mass_storage.c b/drivers/usb/gadget/legacy/mass_storage.c index e7bfb08..ab1a42c 100644 --- a/drivers/usb/gadget/legacy/mass_storage.c +++ b/drivers/usb/gadget/legacy/mass_storage.c @@ -64,21 +64,7 @@ static struct usb_device_descriptor msg_device_desc = { .bNumConfigurations = 1, }; -static struct usb_otg_descriptor otg_descriptor = { - .bLength = sizeof otg_descriptor, - .bDescriptorType = USB_DT_OTG, - - /* -* REVISIT SRP-only hardware is possible, although -* it would not be called OTG ... -*/ - .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, -}; - -static const struct usb_descriptor_header *otg_desc[] = { - (struct usb_descriptor_header *) otg_descriptor, - NULL, -}; +static const struct usb_descriptor_header *otg_desc[2]; static struct usb_string strings_dev[] = { [USB_GADGET_MANUFACTURER_IDX].s = , @@ -214,9 +200,20 @@ static int msg_bind(struct usb_composite_dev *cdev) goto fail_string_ids; msg_device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; + if (gadget_is_otg(cdev-gadget) !otg_desc[0]) { + struct usb_descriptor_header *usb_desc; + + usb_desc = usb_otg_descriptor_alloc(cdev-gadget); + if (!usb_desc) + goto fail_string_ids; + usb_otg_descriptor_init(cdev-gadget, usb_desc); + otg_desc[0] = usb_desc; + otg_desc[1] = NULL; + } + status = usb_add_config(cdev, msg_config_driver, msg_do_config); if (status 0) - goto fail_string_ids; + goto fail_otg_desc; usb_composite_overwrite_options(cdev, coverwrite); dev_info(cdev-gadget-dev, @@ -224,6 +221,9 @@ static int msg_bind(struct usb_composite_dev *cdev) set_bit(0, msg_registered); return 0; +fail_otg_desc: + kfree(otg_desc[0]); + otg_desc[0] = NULL; fail_string_ids: fsg_common_remove_luns(opts-common); fail_set_cdev: @@ -243,6 +243,9 @@ static int msg_unbind(struct usb_composite_dev *cdev) if (!IS_ERR(fi_msg)) usb_put_function_instance(fi_msg); + kfree(otg_desc[0]); + otg_desc[0] = NULL; + return 0; } -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v6 02/23] usb: add USB_OTG_ADP definition
From: Macpaul Lin macp...@gmail.com Add USB_OTG_ADP definition for usb_otg_descriptor.bmAttributes. Signed-off-by: Macpaul Lin macp...@gmail.com Signed-off-by: Li Jun jun...@freescale.com Acked-by: Peter Chen peter.c...@freescale.com --- include/uapi/linux/usb/ch9.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/uapi/linux/usb/ch9.h b/include/uapi/linux/usb/ch9.h index aec6899..f7adc6e 100644 --- a/include/uapi/linux/usb/ch9.h +++ b/include/uapi/linux/usb/ch9.h @@ -688,6 +688,7 @@ struct usb_otg20_descriptor { /* from usb_otg_descriptor.bmAttributes */ #define USB_OTG_SRP(1 0) #define USB_OTG_HNP(1 1)/* swap host/device roles */ +#define USB_OTG_ADP(1 2)/* support ADP */ /*-*/ -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v6 14/23] usb: gadget: audio: allocate and init otg descriptor by otg capabilities
Allocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations. If otg capability is not defined, keep its original otg descriptor unchanged. Signed-off-by: Li Jun jun...@freescale.com --- drivers/usb/gadget/legacy/audio.c | 34 +++--- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/drivers/usb/gadget/legacy/audio.c b/drivers/usb/gadget/legacy/audio.c index f289caf..51a2380 100644 --- a/drivers/usb/gadget/legacy/audio.c +++ b/drivers/usb/gadget/legacy/audio.c @@ -150,20 +150,7 @@ static struct usb_device_descriptor device_desc = { .bNumConfigurations = 1, }; -static struct usb_otg_descriptor otg_descriptor = { - .bLength = sizeof otg_descriptor, - .bDescriptorType = USB_DT_OTG, - - /* REVISIT SRP-only hardware is possible, although -* it would not be called OTG ... -*/ - .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, -}; - -static const struct usb_descriptor_header *otg_desc[] = { - (struct usb_descriptor_header *) otg_descriptor, - NULL, -}; +static const struct usb_descriptor_header *otg_desc[2]; /*-*/ @@ -259,14 +246,28 @@ static int audio_bind(struct usb_composite_dev *cdev) device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; + if (gadget_is_otg(cdev-gadget) !otg_desc[0]) { + struct usb_descriptor_header *usb_desc; + + usb_desc = usb_otg_descriptor_alloc(cdev-gadget); + if (!usb_desc) + goto fail; + usb_otg_descriptor_init(cdev-gadget, usb_desc); + otg_desc[0] = usb_desc; + otg_desc[1] = NULL; + } + status = usb_add_config(cdev, audio_config_driver, audio_do_config); if (status 0) - goto fail; + goto fail_otg_desc; usb_composite_overwrite_options(cdev, coverwrite); INFO(cdev, %s, version: %s\n, DRIVER_DESC, DRIVER_VERSION); return 0; +fail_otg_desc: + kfree(otg_desc[0]); + otg_desc[0] = NULL; fail: #ifndef CONFIG_GADGET_UAC1 usb_put_function_instance(fi_uac2); @@ -289,6 +290,9 @@ static int audio_unbind(struct usb_composite_dev *cdev) if (!IS_ERR_OR_NULL(fi_uac2)) usb_put_function_instance(fi_uac2); #endif + kfree(otg_desc[0]); + otg_desc[0] = NULL; + return 0; } -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v6 23/23] usb: gadget: zero: allocate and init otg descriptor by otg capabilities
Allocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations. If otg capability is not defined, keep its original otg descriptor unchanged. Signed-off-by: Li Jun jun...@freescale.com --- drivers/usb/gadget/legacy/zero.c | 32 ++-- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/drivers/usb/gadget/legacy/zero.c b/drivers/usb/gadget/legacy/zero.c index c986e8a..695c2cb 100644 --- a/drivers/usb/gadget/legacy/zero.c +++ b/drivers/usb/gadget/legacy/zero.c @@ -121,24 +121,7 @@ static struct usb_device_descriptor device_desc = { .bNumConfigurations = 2, }; -#ifdef CONFIG_USB_OTG -static struct usb_otg_descriptor otg_descriptor = { - .bLength = sizeof otg_descriptor, - .bDescriptorType = USB_DT_OTG, - - /* REVISIT SRP-only hardware is possible, although -* it would not be called OTG ... -*/ - .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, -}; - -static const struct usb_descriptor_header *otg_desc[] = { - (struct usb_descriptor_header *) otg_descriptor, - NULL, -}; -#else -#define otg_desc NULL -#endif +static const struct usb_descriptor_header *otg_desc[2]; /* string IDs are assigned dynamically */ /* default serial number takes at least two packets */ @@ -341,6 +324,16 @@ static int zero_bind(struct usb_composite_dev *cdev) /* support OTG systems */ if (gadget_is_otg(cdev-gadget)) { + if (!otg_desc[0]) { + struct usb_descriptor_header *usb_desc; + + usb_desc = usb_otg_descriptor_alloc(cdev-gadget); + if (!usb_desc) + return -ENOMEM; + usb_otg_descriptor_init(cdev-gadget, usb_desc); + otg_desc[0] = usb_desc; + otg_desc[1] = NULL; + } sourcesink_driver.descriptors = otg_desc; sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP; loopback_driver.descriptors = otg_desc; @@ -397,6 +390,9 @@ static int zero_unbind(struct usb_composite_dev *cdev) if (!IS_ERR_OR_NULL(func_lb)) usb_put_function(func_lb); usb_put_function_instance(func_inst_lb); + kfree(otg_desc[0]); + otg_desc[0] = NULL; + return 0; } -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v6 21/23] usb: gadget: printer: allocate and init otg descriptor by otg capabilities
Allocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations. If otg capability is not defined, keep its original otg descriptor unchanged. Signed-off-by: Li Jun jun...@freescale.com --- drivers/usb/gadget/legacy/printer.c | 26 +++--- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/usb/gadget/legacy/printer.c b/drivers/usb/gadget/legacy/printer.c index 1ce7df1..2ad1124 100644 --- a/drivers/usb/gadget/legacy/printer.c +++ b/drivers/usb/gadget/legacy/printer.c @@ -82,16 +82,7 @@ static struct usb_device_descriptor device_desc = { .bNumConfigurations = 1 }; -static struct usb_otg_descriptor otg_descriptor = { - .bLength = sizeof otg_descriptor, - .bDescriptorType = USB_DT_OTG, - .bmAttributes = USB_OTG_SRP, -}; - -static const struct usb_descriptor_header *otg_desc[] = { - (struct usb_descriptor_header *) otg_descriptor, - NULL, -}; +static const struct usb_descriptor_header *otg_desc[2]; /*-*/ @@ -136,7 +127,6 @@ static int printer_do_config(struct usb_configuration *c) usb_gadget_set_selfpowered(gadget); if (gadget_is_otg(gadget)) { - otg_descriptor.bmAttributes |= USB_OTG_HNP; printer_cfg_driver.descriptors = otg_desc; printer_cfg_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP; } @@ -182,6 +172,17 @@ static int printer_bind(struct usb_composite_dev *cdev) device_desc.iProduct = strings[USB_GADGET_PRODUCT_IDX].id; device_desc.iSerialNumber = strings[USB_GADGET_SERIAL_IDX].id; + if (gadget_is_otg(cdev-gadget) !otg_desc[0]) { + struct usb_descriptor_header *usb_desc; + + usb_desc = usb_otg_descriptor_alloc(cdev-gadget); + if (!usb_desc) + return -ENOMEM; + usb_otg_descriptor_init(cdev-gadget, usb_desc); + otg_desc[0] = usb_desc; + otg_desc[1] = NULL; + } + ret = usb_add_config(cdev, printer_cfg_driver, printer_do_config); if (ret) { usb_put_function_instance(fi_printer); @@ -196,6 +197,9 @@ static int printer_unbind(struct usb_composite_dev *cdev) usb_put_function(f_printer); usb_put_function_instance(fi_printer); + kfree(otg_desc[0]); + otg_desc[0] = NULL; + return 0; } -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v6 07/23] usb: common: add API to update usb otg capabilities by device tree
Check property of usb hardware to update otg version and disable SRP, HNP and ADP if its disable flag is present. Signed-off-by: Li Jun jun...@freescale.com --- drivers/usb/common/common.c | 47 + include/linux/usb/of.h | 7 +++ 2 files changed, 54 insertions(+) diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c index b530fd4..10c986b 100644 --- a/drivers/usb/common/common.c +++ b/drivers/usb/common/common.c @@ -154,6 +154,53 @@ bool of_usb_host_tpl_support(struct device_node *np) return false; } EXPORT_SYMBOL_GPL(of_usb_host_tpl_support); + +/** + * of_usb_update_otg_caps - to update usb otg capabilities according to + * the passed properties in DT. + * @np: Pointer to the given device_node + * @otg_caps: Pointer to the target usb_otg_caps to be set + * + * The function updates the otg capabilities + */ +int of_usb_update_otg_caps(struct device_node *np, + struct usb_otg_caps *otg_caps) +{ + u32 otg_rev; + + if (!otg_caps) + return -EINVAL; + + if (!of_property_read_u32(np, otg-rev, otg_rev)) { + switch (otg_rev) { + case 0x0100: + case 0x0120: + case 0x0130: + case 0x0200: + case 0x0300: + otg_caps-otg_rev = otg_rev; + break; + default: + pr_err(%s: unsupported otg-rev: 0x%x\n, + np-full_name, otg_rev); + return -EINVAL; + } + } else { + otg_caps-otg_rev = 0; + } + + if (of_find_property(np, hnp-disable, NULL)) + otg_caps-hnp_support = false; + if (of_find_property(np, srp-disable, NULL)) + otg_caps-srp_support = false; + if (of_find_property(np, adp-disable, NULL) || + (otg_caps-otg_rev 0x0200)) + otg_caps-adp_support = false; + + return 0; +} +EXPORT_SYMBOL_GPL(of_usb_update_otg_caps); + #endif MODULE_LICENSE(GPL); diff --git a/include/linux/usb/of.h b/include/linux/usb/of.h index cfe0528..8c5a818 100644 --- a/include/linux/usb/of.h +++ b/include/linux/usb/of.h @@ -15,6 +15,8 @@ enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np); enum usb_device_speed of_usb_get_maximum_speed(struct device_node *np); bool of_usb_host_tpl_support(struct device_node *np); +int of_usb_update_otg_caps(struct device_node *np, + struct usb_otg_caps *otg_caps); #else static inline enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np) { @@ -30,6 +32,11 @@ static inline bool of_usb_host_tpl_support(struct device_node *np) { return false; } +static inline int of_usb_update_otg_caps(struct device_node *np, + struct usb_otg_caps *otg_caps) +{ + return 0; +} #endif #if IS_ENABLED(CONFIG_OF) IS_ENABLED(CONFIG_USB_SUPPORT) -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v6 12/23] usb: gadget: ether: allocate and init otg descriptor by otg capabilities
Allocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations, free it while ether unbind. If otg capability is not defined, keep its otg descriptor unchanged. Signed-off-by: Li Jun jun...@freescale.com --- drivers/usb/gadget/legacy/ether.c | 36 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/drivers/usb/gadget/legacy/ether.c b/drivers/usb/gadget/legacy/ether.c index a3323dc..31e9160 100644 --- a/drivers/usb/gadget/legacy/ether.c +++ b/drivers/usb/gadget/legacy/ether.c @@ -171,20 +171,7 @@ static struct usb_device_descriptor device_desc = { .bNumConfigurations = 1, }; -static struct usb_otg_descriptor otg_descriptor = { - .bLength = sizeof otg_descriptor, - .bDescriptorType = USB_DT_OTG, - - /* REVISIT SRP-only hardware is possible, although -* it would not be called OTG ... -*/ - .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, -}; - -static const struct usb_descriptor_header *otg_desc[] = { - (struct usb_descriptor_header *) otg_descriptor, - NULL, -}; +static const struct usb_descriptor_header *otg_desc[2]; static struct usb_string strings_dev[] = { [USB_GADGET_MANUFACTURER_IDX].s = , @@ -416,17 +403,28 @@ static int eth_bind(struct usb_composite_dev *cdev) device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; + if (gadget_is_otg(gadget) !otg_desc[0]) { + struct usb_descriptor_header *usb_desc; + + usb_desc = usb_otg_descriptor_alloc(gadget); + if (!usb_desc) + goto fail1; + usb_otg_descriptor_init(gadget, usb_desc); + otg_desc[0] = usb_desc; + otg_desc[1] = NULL; + } + /* register our configuration(s); RNDIS first, if it's used */ if (has_rndis()) { status = usb_add_config(cdev, rndis_config_driver, rndis_do_config); if (status 0) - goto fail1; + goto fail2; } status = usb_add_config(cdev, eth_config_driver, eth_do_config); if (status 0) - goto fail1; + goto fail2; usb_composite_overwrite_options(cdev, coverwrite); dev_info(gadget-dev, %s, version: DRIVER_VERSION \n, @@ -434,6 +432,9 @@ static int eth_bind(struct usb_composite_dev *cdev) return 0; +fail2: + kfree(otg_desc[0]); + otg_desc[0] = NULL; fail1: if (has_rndis()) usb_put_function_instance(fi_rndis); @@ -463,6 +464,9 @@ static int eth_unbind(struct usb_composite_dev *cdev) usb_put_function(f_geth); usb_put_function_instance(fi_geth); } + kfree(otg_desc[0]); + otg_desc[0] = NULL; + return 0; } -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v6 04/23] usb: add usb_otg_caps to usb_gadget structure.
From: Macpaul Lin macp...@gmail.com Add usb_otg_caps pointer to usb_gadget structure to indicate its otg capabilities. Signed-off-by: Macpaul Lin macp...@gmail.com Signed-off-by: Li Jun jun...@freescale.com Reviewed-by: Roger Quadros rog...@ti.com --- include/linux/usb/gadget.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index 4f3dfb7..6b39087 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -511,6 +511,7 @@ struct usb_gadget_ops { * @dev: Driver model state for this abstract device. * @out_epnum: last used out ep number * @in_epnum: last used in ep number + * @otg_caps: OTG capabilities of this gadget. * @sg_supported: true if we can handle scatter-gather * @is_otg: True if the USB device port uses a Mini-AB jack, so that the * gadget driver must provide a USB OTG descriptor. @@ -559,6 +560,7 @@ struct usb_gadget { struct device dev; unsignedout_epnum; unsignedin_epnum; + struct usb_otg_caps *otg_caps; unsignedsg_supported:1; unsignedis_otg:1; -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v6 20/23] usb: gadget: ncm: allocate and init otg descriptor by otg capabilities
Allocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations. If otg capability is not defined, keep its original otg descriptor unchanged. Signed-off-by: Li Jun jun...@freescale.com --- drivers/usb/gadget/legacy/ncm.c | 34 +++--- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/drivers/usb/gadget/legacy/ncm.c b/drivers/usb/gadget/legacy/ncm.c index 6ce7421..2bae438 100644 --- a/drivers/usb/gadget/legacy/ncm.c +++ b/drivers/usb/gadget/legacy/ncm.c @@ -69,20 +69,7 @@ static struct usb_device_descriptor device_desc = { .bNumConfigurations = 1, }; -static struct usb_otg_descriptor otg_descriptor = { - .bLength = sizeof otg_descriptor, - .bDescriptorType = USB_DT_OTG, - - /* REVISIT SRP-only hardware is possible, although -* it would not be called OTG ... -*/ - .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, -}; - -static const struct usb_descriptor_header *otg_desc[] = { - (struct usb_descriptor_header *) otg_descriptor, - NULL, -}; +static const struct usb_descriptor_header *otg_desc[2]; /* string IDs are assigned dynamically */ static struct usb_string strings_dev[] = { @@ -171,16 +158,30 @@ static int gncm_bind(struct usb_composite_dev *cdev) device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; + if (gadget_is_otg(gadget) !otg_desc[0]) { + struct usb_descriptor_header *usb_desc; + + usb_desc = usb_otg_descriptor_alloc(gadget); + if (!usb_desc) + goto fail; + usb_otg_descriptor_init(gadget, usb_desc); + otg_desc[0] = usb_desc; + otg_desc[1] = NULL; + } + status = usb_add_config(cdev, ncm_config_driver, ncm_do_config); if (status 0) - goto fail; + goto fail1; usb_composite_overwrite_options(cdev, coverwrite); dev_info(gadget-dev, %s\n, DRIVER_DESC); return 0; +fail1: + kfree(otg_desc[0]); + otg_desc[0] = NULL; fail: usb_put_function_instance(f_ncm_inst); return status; @@ -192,6 +193,9 @@ static int gncm_unbind(struct usb_composite_dev *cdev) usb_put_function(f_ncm); if (!IS_ERR_OR_NULL(f_ncm_inst)) usb_put_function_instance(f_ncm_inst); + kfree(otg_desc[0]); + otg_desc[0] = NULL; + return 0; } -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v6 15/23] usb: gadget: cdc2: allocate and init otg descriptor by otg capabilities
Allocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations. If otg capability is not defined, keep its original otg descriptor unchanged. Signed-off-by: Li Jun jun...@freescale.com --- drivers/usb/gadget/legacy/cdc2.c | 35 +++ 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/drivers/usb/gadget/legacy/cdc2.c b/drivers/usb/gadget/legacy/cdc2.c index afd3e37..ecd8c8d 100644 --- a/drivers/usb/gadget/legacy/cdc2.c +++ b/drivers/usb/gadget/legacy/cdc2.c @@ -60,21 +60,7 @@ static struct usb_device_descriptor device_desc = { .bNumConfigurations = 1, }; -static struct usb_otg_descriptor otg_descriptor = { - .bLength = sizeof otg_descriptor, - .bDescriptorType = USB_DT_OTG, - - /* REVISIT SRP-only hardware is possible, although -* it would not be called OTG ... -*/ - .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, -}; - -static const struct usb_descriptor_header *otg_desc[] = { - (struct usb_descriptor_header *) otg_descriptor, - NULL, -}; - +static const struct usb_descriptor_header *otg_desc[2]; /* string IDs are assigned dynamically */ static struct usb_string strings_dev[] = { @@ -193,10 +179,21 @@ static int cdc_bind(struct usb_composite_dev *cdev) device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; + if (gadget_is_otg(gadget) !otg_desc[0]) { + struct usb_descriptor_header *usb_desc; + + usb_desc = usb_otg_descriptor_alloc(gadget); + if (!usb_desc) + goto fail1; + usb_otg_descriptor_init(gadget, usb_desc); + otg_desc[0] = usb_desc; + otg_desc[1] = NULL; + } + /* register our configuration */ status = usb_add_config(cdev, cdc_config_driver, cdc_do_config); if (status 0) - goto fail1; + goto fail2; usb_composite_overwrite_options(cdev, coverwrite); dev_info(gadget-dev, %s, version: DRIVER_VERSION \n, @@ -204,6 +201,9 @@ static int cdc_bind(struct usb_composite_dev *cdev) return 0; +fail2: + kfree(otg_desc[0]); + otg_desc[0] = NULL; fail1: usb_put_function_instance(fi_serial); fail: @@ -219,6 +219,9 @@ static int cdc_unbind(struct usb_composite_dev *cdev) usb_put_function(f_ecm); if (!IS_ERR_OR_NULL(fi_ecm)) usb_put_function_instance(fi_ecm); + kfree(otg_desc[0]); + otg_desc[0] = NULL; + return 0; } -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v6 13/23] usb: gadget: acm_ms: allocate and init otg descriptor by otg capabilities
Allocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations. If otg capability is not defined, keep its original otg descriptor unchanged. Signed-off-by: Li Jun jun...@freescale.com --- drivers/usb/gadget/legacy/acm_ms.c | 35 +++ 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/drivers/usb/gadget/legacy/acm_ms.c b/drivers/usb/gadget/legacy/acm_ms.c index 1194b09..4d8adb4 100644 --- a/drivers/usb/gadget/legacy/acm_ms.c +++ b/drivers/usb/gadget/legacy/acm_ms.c @@ -58,21 +58,7 @@ static struct usb_device_descriptor device_desc = { /*.bNumConfigurations = DYNAMIC*/ }; -static struct usb_otg_descriptor otg_descriptor = { - .bLength = sizeof otg_descriptor, - .bDescriptorType = USB_DT_OTG, - - /* -* REVISIT SRP-only hardware is possible, although -* it would not be called OTG ... -*/ - .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, -}; - -static const struct usb_descriptor_header *otg_desc[] = { - (struct usb_descriptor_header *) otg_descriptor, - NULL, -}; +static const struct usb_descriptor_header *otg_desc[2]; /* string IDs are assigned dynamically */ static struct usb_string strings_dev[] = { @@ -225,10 +211,21 @@ static int acm_ms_bind(struct usb_composite_dev *cdev) device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; + if (gadget_is_otg(gadget) !otg_desc[0]) { + struct usb_descriptor_header *usb_desc; + + usb_desc = usb_otg_descriptor_alloc(gadget); + if (!usb_desc) + goto fail_string_ids; + usb_otg_descriptor_init(gadget, usb_desc); + otg_desc[0] = usb_desc; + otg_desc[1] = NULL; + } + /* register our configuration */ status = usb_add_config(cdev, acm_ms_config_driver, acm_ms_do_config); if (status 0) - goto fail_string_ids; + goto fail_otg_desc; usb_composite_overwrite_options(cdev, coverwrite); dev_info(gadget-dev, %s, version: DRIVER_VERSION \n, @@ -236,6 +233,9 @@ static int acm_ms_bind(struct usb_composite_dev *cdev) return 0; /* error recovery */ +fail_otg_desc: + kfree(otg_desc[0]); + otg_desc[0] = NULL; fail_string_ids: fsg_common_remove_luns(opts-common); fail_set_cdev: @@ -255,6 +255,9 @@ static int acm_ms_unbind(struct usb_composite_dev *cdev) usb_put_function_instance(fi_msg); usb_put_function(f_acm); usb_put_function_instance(f_acm_inst); + kfree(otg_desc[0]); + otg_desc[0] = NULL; + return 0; } -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v6 19/23] usb: gadget: multi: allocate and init otg descriptor by otg capabilities
Allocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations. If otg capability is not defined, keep its original otg descriptor unchanged. Signed-off-by: Li Jun jun...@freescale.com --- drivers/usb/gadget/legacy/multi.c | 37 - 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/drivers/usb/gadget/legacy/multi.c b/drivers/usb/gadget/legacy/multi.c index b21b51f..c38ead1 100644 --- a/drivers/usb/gadget/legacy/multi.c +++ b/drivers/usb/gadget/legacy/multi.c @@ -78,21 +78,7 @@ static struct usb_device_descriptor device_desc = { .idProduct =cpu_to_le16(MULTI_PRODUCT_NUM), }; - -static const struct usb_descriptor_header *otg_desc[] = { - (struct usb_descriptor_header *) (struct usb_otg_descriptor){ - .bLength = sizeof(struct usb_otg_descriptor), - .bDescriptorType = USB_DT_OTG, - - /* -* REVISIT SRP-only hardware is possible, although -* it would not be called OTG ... -*/ - .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, - }, - NULL, -}; - +static const struct usb_descriptor_header *otg_desc[2]; enum { MULTI_STRING_RNDIS_CONFIG_IDX = USB_GADGET_FIRST_AVAIL_IDX, @@ -429,14 +415,25 @@ static int __ref multi_bind(struct usb_composite_dev *cdev) goto fail_string_ids; device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; + if (gadget_is_otg(gadget) !otg_desc[0]) { + struct usb_descriptor_header *usb_desc; + + usb_desc = usb_otg_descriptor_alloc(gadget); + if (!usb_desc) + goto fail_string_ids; + usb_otg_descriptor_init(gadget, usb_desc); + otg_desc[0] = usb_desc; + otg_desc[1] = NULL; + } + /* register configurations */ status = rndis_config_register(cdev); if (unlikely(status 0)) - goto fail_string_ids; + goto fail_otg_desc; status = cdc_config_register(cdev); if (unlikely(status 0)) - goto fail_string_ids; + goto fail_otg_desc; usb_composite_overwrite_options(cdev, coverwrite); /* we're done */ @@ -445,6 +442,9 @@ static int __ref multi_bind(struct usb_composite_dev *cdev) /* error recovery */ +fail_otg_desc: + kfree(otg_desc[0]); + otg_desc[0] = NULL; fail_string_ids: fsg_common_remove_luns(fsg_opts-common); fail_set_cdev: @@ -490,6 +490,9 @@ static int multi_unbind(struct usb_composite_dev *cdev) usb_put_function(f_ecm); usb_put_function_instance(fi_ecm); #endif + kfree(otg_desc[0]); + otg_desc[0] = NULL; + return 0; } -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v6 03/23] usb: otg: add usb_otg_caps structure for otg capabilities
This patch adds a structure usb_otg_caps to cover all otg related capabilities of the device, including otg revision, and if hnp/srp/adp is supported. Signed-off-by: Li Jun jun...@freescale.com Reviewed-by: Roger Quadros rog...@ti.com --- include/linux/usb/otg.h | 15 +++ 1 file changed, 15 insertions(+) diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h index 52661c5..bd1dcf8 100644 --- a/include/linux/usb/otg.h +++ b/include/linux/usb/otg.h @@ -41,6 +41,21 @@ struct usb_otg { }; +/** + * struct usb_otg_caps - describes the otg capabilities of the device + * @otg_rev: The OTG revision number the device is compliant with, it's + * in binary-coded decimal (i.e. 2.0 is 0200H). + * @hnp_support: Indicates if the device supports HNP. + * @srp_support: Indicates if the device supports SRP. + * @adp_support: Indicates if the device supports ADP. + */ +struct usb_otg_caps { + u16 otg_rev; + bool hnp_support; + bool srp_support; + bool adp_support; +}; + extern const char *usb_otg_state_string(enum usb_otg_state state); /* Context: can sleep */ -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v6 06/23] doc: dt-binding: usb: add otg related properties
Add otg version, srp, hnp and adp support for usb OTG port, then those OTG features don't have to be decided by usb gadget drivers. Signed-off-by: Li Jun jun...@freescale.com Reviewed-by: Roger Quadros rog...@ti.com --- Documentation/devicetree/bindings/usb/generic.txt | 15 +++ 1 file changed, 15 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/generic.txt b/Documentation/devicetree/bindings/usb/generic.txt index 477d5bb..bba8257 100644 --- a/Documentation/devicetree/bindings/usb/generic.txt +++ b/Documentation/devicetree/bindings/usb/generic.txt @@ -11,6 +11,19 @@ Optional properties: peripheral and otg. In case this attribute isn't passed via DT, USB DRD controllers should default to OTG. + - otg-rev: tells usb driver the release number of the OTG and EH supplement + with which the device and its descriptors are compliant, + in binary-coded decimal (i.e. 2.0 is 0200H). This + property is used if any real OTG features(HNP/SRP/ADP) + is enabled, if ADP is required, otg-rev should be + 0x0200 or above. + - hnp-disable: tells OTG controllers we want to disable OTG HNP, normally HNP + is the basic function of real OTG except you want it + to be a srp-capable only B device. + - srp-disable: tells OTG controllers we want to disable OTG SRP, SRP is + optional for OTG device. + - adp-disable: tells OTG controllers we want to disable OTG ADP, ADP is + optional for OTG device. This is an attribute to a USB controller such as: @@ -21,4 +34,6 @@ dwc3@4a03 { usb-phy = usb2_phy, usb3,phy; maximum-speed = super-speed; dr_mode = otg; + otg-rev = 0x0200; + adp-disable; }; -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v6 10/23] usb: gadget: add usb otg descriptor allocate and init interface
Allocate usb otg descriptor and initialize it according to gadget's otg capabilities, if usb_otg_caps is not set, keep settings as current gadget drivers. With this 2 new interfaces, gadget can use usb_otg_descriptor for OTG 1.x, and usb_otg20_descriptor for OTG 2.0 or above, and otg features can be decided by the combination of usb hardware property and driver config. Signed-off-by: Li Jun jun...@freescale.com Reviewed-by: Roger Quadros rog...@ti.com --- drivers/usb/gadget/config.c | 56 + include/linux/usb/gadget.h | 4 2 files changed, 60 insertions(+) diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c index 34e12fc..0fafa7a 100644 --- a/drivers/usb/gadget/config.c +++ b/drivers/usb/gadget/config.c @@ -20,6 +20,7 @@ #include linux/usb/ch9.h #include linux/usb/gadget.h #include linux/usb/composite.h +#include linux/usb/otg.h /** * usb_descriptor_fillbuf - fill buffer with descriptors @@ -195,3 +196,58 @@ void usb_free_all_descriptors(struct usb_function *f) usb_free_descriptors(f-ss_descriptors); } EXPORT_SYMBOL_GPL(usb_free_all_descriptors); + +struct usb_descriptor_header *usb_otg_descriptor_alloc( + struct usb_gadget *gadget) +{ + struct usb_descriptor_header *otg_desc; + unsigned length = 0; + + if (gadget-otg_caps (gadget-otg_caps-otg_rev = 0x0200)) + length = sizeof(struct usb_otg20_descriptor); + else + length = sizeof(struct usb_otg_descriptor); + + otg_desc = kzalloc(length, GFP_KERNEL); + return otg_desc; +} +EXPORT_SYMBOL_GPL(usb_otg_descriptor_alloc); + +int usb_otg_descriptor_init(struct usb_gadget *gadget, + struct usb_descriptor_header *otg_desc) +{ + struct usb_otg_descriptor *otg1x_desc; + struct usb_otg20_descriptor *otg20_desc; + struct usb_otg_caps *otg_caps = gadget-otg_caps; + u8 otg_attributes = 0; + + if (!otg_desc) + return -EINVAL; + + if (otg_caps otg_caps-otg_rev) { + if (otg_caps-hnp_support) + otg_attributes |= USB_OTG_HNP; + if (otg_caps-srp_support) + otg_attributes |= USB_OTG_SRP; + if (otg_caps-adp_support (otg_caps-otg_rev = 0x0200)) + otg_attributes |= USB_OTG_ADP; + } else { + otg_attributes = USB_OTG_SRP | USB_OTG_HNP; + } + + if (otg_caps (otg_caps-otg_rev = 0x0200)) { + otg20_desc = (struct usb_otg20_descriptor *)otg_desc; + otg20_desc-bLength = sizeof(struct usb_otg20_descriptor); + otg20_desc-bDescriptorType = USB_DT_OTG; + otg20_desc-bmAttributes = otg_attributes; + otg20_desc-bcdOTG = cpu_to_le16(otg_caps-otg_rev); + } else { + otg1x_desc = (struct usb_otg_descriptor *)otg_desc; + otg1x_desc-bLength = sizeof(struct usb_otg_descriptor); + otg1x_desc-bDescriptorType = USB_DT_OTG; + otg1x_desc-bmAttributes = otg_attributes; + } + + return 0; +} +EXPORT_SYMBOL_GPL(usb_otg_descriptor_init); diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index 6b39087..5f65bd2 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -1004,6 +1004,10 @@ int usb_assign_descriptors(struct usb_function *f, struct usb_descriptor_header **ss); void usb_free_all_descriptors(struct usb_function *f); +struct usb_descriptor_header *usb_otg_descriptor_alloc( + struct usb_gadget *gadget); +int usb_otg_descriptor_init(struct usb_gadget *gadget, + struct usb_descriptor_header *otg_desc); /*-*/ /* utility to simplify map/unmap of usb_requests to/from DMA */ -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v6 11/23] usb: gadget: configfs: allocate and init otg descriptor by otg capabilities
Allocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations, free it while composite unbind. If otg capability is not defined, keep its otg descriptor unchanged. Signed-off-by: Li Jun jun...@freescale.com Reviewed-by: Roger Quadros rog...@ti.com --- drivers/usb/gadget/configfs.c | 29 - 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c index 0495c94..c7b62ef 100644 --- a/drivers/usb/gadget/configfs.c +++ b/drivers/usb/gadget/configfs.c @@ -41,6 +41,8 @@ int check_user_usb_string(const char *name, #define MAX_NAME_LEN 40 #define MAX_USB_STRING_LANGS 2 +static const struct usb_descriptor_header *otg_desc[2]; + struct gadget_info { struct config_group group; struct config_group functions_group; @@ -55,9 +57,6 @@ struct gadget_info { struct list_head available_func; const char *udc_name; -#ifdef CONFIG_USB_OTG - struct usb_otg_descriptor otg; -#endif struct usb_composite_driver composite; struct usb_composite_dev cdev; bool use_os_desc; @@ -1376,6 +1375,19 @@ static int configfs_composite_bind(struct usb_gadget *gadget, memcpy(cdev-qw_sign, gi-qw_sign, OS_STRING_QW_SIGN_LEN); } + if (gadget_is_otg(gadget) !otg_desc[0]) { + struct usb_descriptor_header *usb_desc; + + usb_desc = usb_otg_descriptor_alloc(gadget); + if (!usb_desc) { + ret = -ENOMEM; + goto err_comp_cleanup; + } + usb_otg_descriptor_init(gadget, usb_desc); + otg_desc[0] = usb_desc; + otg_desc[1] = NULL; + } + /* Go through all configs, attach all functions */ list_for_each_entry(c, gi-cdev.configs, list) { struct config_usb_cfg *cfg; @@ -1383,6 +1395,9 @@ static int configfs_composite_bind(struct usb_gadget *gadget, struct usb_function *tmp; struct gadget_config_name *cn; + if (gadget_is_otg(gadget)) + c-descriptors = otg_desc; + cfg = container_of(c, struct config_usb_cfg, c); if (!list_empty(cfg-string_list)) { i = 0; @@ -1437,6 +1452,8 @@ static void configfs_composite_unbind(struct usb_gadget *gadget) cdev = get_gadget_data(gadget); gi = container_of(cdev, struct gadget_info, cdev); + kfree(otg_desc[0]); + otg_desc[0] = NULL; purge_configs_funcs(gi); composite_dev_cleanup(cdev); usb_ep_autoconfig_reset(cdev-gadget); @@ -1510,12 +1527,6 @@ static struct config_group *gadgets_make( if (!gi-composite.gadget_driver.function) goto err; -#ifdef CONFIG_USB_OTG - gi-otg.bLength = sizeof(struct usb_otg_descriptor); - gi-otg.bDescriptorType = USB_DT_OTG; - gi-otg.bmAttributes = USB_OTG_SRP | USB_OTG_HNP; -#endif - config_group_init_type_name(gi-group, name, gadget_root_type); return gi-group; -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v6 17/23] usb: gadget: hid: allocate and init otg descriptor by otg capabilities
Allocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations. If otg capability is not defined, keep its original otg descriptor unchanged. Signed-off-by: Li Jun jun...@freescale.com --- drivers/usb/gadget/legacy/hid.c | 36 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/drivers/usb/gadget/legacy/hid.c b/drivers/usb/gadget/legacy/hid.c index 2baa572..e4874d3 100644 --- a/drivers/usb/gadget/legacy/hid.c +++ b/drivers/usb/gadget/legacy/hid.c @@ -68,21 +68,7 @@ static struct usb_device_descriptor device_desc = { .bNumConfigurations = 1, }; -static struct usb_otg_descriptor otg_descriptor = { - .bLength = sizeof otg_descriptor, - .bDescriptorType = USB_DT_OTG, - - /* REVISIT SRP-only hardware is possible, although -* it would not be called OTG ... -*/ - .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, -}; - -static const struct usb_descriptor_header *otg_desc[] = { - (struct usb_descriptor_header *) otg_descriptor, - NULL, -}; - +static const struct usb_descriptor_header *otg_desc[2]; /* string IDs are assigned dynamically */ static struct usb_string strings_dev[] = { @@ -186,16 +172,30 @@ static int hid_bind(struct usb_composite_dev *cdev) device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; + if (gadget_is_otg(gadget) !otg_desc[0]) { + struct usb_descriptor_header *usb_desc; + + usb_desc = usb_otg_descriptor_alloc(gadget); + if (!usb_desc) + goto put; + usb_otg_descriptor_init(gadget, usb_desc); + otg_desc[0] = usb_desc; + otg_desc[1] = NULL; + } + /* register our configuration */ status = usb_add_config(cdev, config_driver, do_config); if (status 0) - goto put; + goto free_otg_desc; usb_composite_overwrite_options(cdev, coverwrite); dev_info(gadget-dev, DRIVER_DESC , version: DRIVER_VERSION \n); return 0; +free_otg_desc: + kfree(otg_desc[0]); + otg_desc[0] = NULL; put: list_for_each_entry(m, hidg_func_list, node) { if (m == n) @@ -213,6 +213,10 @@ static int hid_unbind(struct usb_composite_dev *cdev) usb_put_function(n-f); usb_put_function_instance(n-fi); } + + kfree(otg_desc[0]); + otg_desc[0] = NULL; + return 0; } -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v6 05/23] usb: gadget: composite: add USB_DT_OTG request handling
From: Macpaul Lin macp...@gmail.com Copy usb_otg_descriptor from config's descriptor if host requests USB_DT_OTG. Signed-off-by: Macpaul Lin macp...@gmail.com Signed-off-by: Li Jun jun...@freescale.com Reviewed-by: Roger Quadros rog...@ti.com --- drivers/usb/gadget/composite.c | 27 +++ 1 file changed, 27 insertions(+) diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 4e3447b..2c1c6eb 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -19,6 +19,7 @@ #include linux/utsname.h #include linux/usb/composite.h +#include linux/usb/otg.h #include asm/unaligned.h #include u_os_desc.h @@ -1534,6 +1535,32 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) value = min(w_length, (u16) value); } break; + case USB_DT_OTG: + if (gadget_is_otg(gadget)) { + struct usb_configuration *config; + int otg_desc_len = 0; + + if (cdev-config) + config = cdev-config; + else + config = list_first_entry( + cdev-configs, + struct usb_configuration, list); + if (!config) + goto done; + + if (gadget-otg_caps + (gadget-otg_caps-otg_rev = 0x0200)) + otg_desc_len += sizeof( + struct usb_otg20_descriptor); + else + otg_desc_len += sizeof( + struct usb_otg_descriptor); + + value = min_t(int, w_length, otg_desc_len); + memcpy(req-buf, config-descriptors[0], value); + } + break; } break; -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] usbhid: no flushing if device is already polled
From: Oliver Neukum oneu...@suse.de During open() it is unnecessary to wait for the device to flush stale inputs if the device is polled while closed due to a quirk or opening fails. Signed-off-by: Oliver Neukum oneu...@suse.com --- drivers/hid/usbhid/hid-core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index 63d1f0f..54dec35 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c @@ -710,7 +710,8 @@ int usbhid_open(struct hid_device *hid) * Wait 50 msec for the queue to empty before allowing events * to go through hid. */ - msleep(50); + if (res == 0 !(hid-quirks HID_QUIRK_ALWAYS_POLL)) + msleep(50); clear_bit(HID_RESUME_RUNNING, usbhid-iofl); } done: -- 2.1.4 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v6 01/23] usb: add usb_otg20_descriptor for OTG 2.0 and above
From: Macpaul Lin macp...@gmail.com OTG 2.0 introduces bcdOTG in otg descriptor to identify the OTG and EH supplement release number with which the OTG device is compliant, this patch adds structure usb_otg20_descriptor for OTG 2.0 and above. Signed-off-by: Macpaul Lin macp...@gmail.com Signed-off-by: Li Jun jun...@freescale.com Reviewed-by: Roger Quadros rog...@ti.com --- include/uapi/linux/usb/ch9.h | 11 +++ 1 file changed, 11 insertions(+) diff --git a/include/uapi/linux/usb/ch9.h b/include/uapi/linux/usb/ch9.h index aa33fd1..aec6899 100644 --- a/include/uapi/linux/usb/ch9.h +++ b/include/uapi/linux/usb/ch9.h @@ -674,6 +674,17 @@ struct usb_otg_descriptor { __u8 bmAttributes; /* support for HNP, SRP, etc */ } __attribute__ ((packed)); +/* USB_DT_OTG (from OTG 2.0 supplement) */ +struct usb_otg20_descriptor { + __u8 bLength; + __u8 bDescriptorType; + + __u8 bmAttributes; /* support for HNP, SRP and ADP, etc */ + __le16 bcdOTG; /* OTG and EH supplement release number +* in binary-coded decimal(i.e. 2.0 is 0200H) +*/ +} __attribute__ ((packed)); + /* from usb_otg_descriptor.bmAttributes */ #define USB_OTG_SRP(1 0) #define USB_OTG_HNP(1 1)/* swap host/device roles */ -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v6 00/23] usb gadget update for OTG 2.0
Change for v6: - Change of_usb_set_otg_caps to be of_usb_update_otg_caps, and add sanity check of otg-rev. - Add chipidea otg-rev ability to be 0x0200, which will be updated in DT, if not passed, will be reset to be 0. - Remove unnecessary change: move config's descriptor and bmAttributes init from xxxi_config() to xxx_bind() in leagcy gadget drivers. Changes for v5: - By default otg feature are enabled if usb controller can support it. use of_usb_set_otg_caps to set otg_rev and disable features by DT. - Update legacy drivers, allocate and init otg descriptor in bind function, free it in unbind, to make alloation and free are symmetric. - Add Roger's reviewed-by. This is a follow-up of Macpaul Lin's previous patchset to resolve usb gadget driver working with OTG 2.0, and set otg features by not only usb driver config but also usb hardware property in DT, main changes: 1. Add usb_otg20_descriptor definition for OTG 2.0 which introduces bcdOTG field for otg revision, bcdOTG can be passed via device tree. 2. OTG features(SRP/HNP/ADP) can be decided by combination of usb HW properties and usb driver config. 3. Change the chipidea usb driver to use the updated mechanism. 4. Remove static usb otg descriptor definition, but allocate and init it according to otg capabilities in each gadget driver, if otg capabilities is not defined for legacy platforms, the usb otg descriptor content is kept the same as current static definition. Li Jun (19): usb: otg: add usb_otg_caps structure for otg capabilities doc: dt-binding: usb: add otg related properties usb: common: add API to update usb otg capabilities by device tree usb: chipidea: set usb otg capabilities usb: chipidea: update ci_otg_is_fsm_mode conditions usb: gadget: add usb otg descriptor allocate and init interface usb: gadget: configfs: allocate and init otg descriptor by otg capabilities usb: gadget: ether: allocate and init otg descriptor by otg capabilities usb: gadget: acm_ms: allocate and init otg descriptor by otg capabilities usb: gadget: audio: allocate and init otg descriptor by otg capabilities usb: gadget: cdc2: allocate and init otg descriptor by otg capabilities usb: gadget: g_ffs: allocate and init otg descriptor by otg capabilities usb: gadget: hid: allocate and init otg descriptor by otg capabilities usb: gadget: mass_storage: allocate and init otg descriptor by otg capabilities usb: gadget: multi: allocate and init otg descriptor by otg capabilities usb: gadget: ncm: allocate and init otg descriptor by otg capabilities usb: gadget: printer: allocate and init otg descriptor by otg capabilities usb: gadget: serial: allocate and init otg descriptor by otg capabilities usb: gadget: zero: allocate and init otg descriptor by otg capabilities Macpaul Lin (4): usb: add usb_otg20_descriptor for OTG 2.0 and above usb: add USB_OTG_ADP definition usb: add usb_otg_caps to usb_gadget structure. usb: gadget: composite: add USB_DT_OTG request handling Documentation/devicetree/bindings/usb/generic.txt | 15 ++ drivers/usb/chipidea/ci.h | 5 +- drivers/usb/chipidea/core.c | 10 drivers/usb/chipidea/debug.c | 1 + drivers/usb/chipidea/udc.c| 7 ++- drivers/usb/common/common.c | 47 +++ drivers/usb/gadget/composite.c| 27 +++ drivers/usb/gadget/config.c | 56 +++ drivers/usb/gadget/configfs.c | 29 drivers/usb/gadget/legacy/acm_ms.c| 35 +++--- drivers/usb/gadget/legacy/audio.c | 34 -- drivers/usb/gadget/legacy/cdc2.c | 35 +++--- drivers/usb/gadget/legacy/ether.c | 36 --- drivers/usb/gadget/legacy/g_ffs.c | 32 +++-- drivers/usb/gadget/legacy/hid.c | 36 --- drivers/usb/gadget/legacy/mass_storage.c | 35 +++--- drivers/usb/gadget/legacy/multi.c | 37 --- drivers/usb/gadget/legacy/ncm.c | 34 -- drivers/usb/gadget/legacy/printer.c | 26 ++- drivers/usb/gadget/legacy/serial.c| 29 ++-- drivers/usb/gadget/legacy/zero.c | 32 ++--- include/linux/usb/chipidea.h | 1 + include/linux/usb/gadget.h| 6 +++ include/linux/usb/of.h| 7 +++ include/linux/usb/otg.h | 15 ++ include/uapi/linux/usb/ch9.h | 12 + 26 files changed, 443 insertions(+), 196 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to
Re: 64 byte EP0 OUT data transfer issue on Chipidea highspeed dual role controller
On Sun, Jun 28, 2015 at 09:11:30AM +0530, Jayan John wrote: On Sun, Jun 28, 2015 at 5:34 AM, Alan Stern st...@rowland.harvard.edu wrote: On Sat, 27 Jun 2015, Jayan John wrote: Thanks. Yes, the wLength value in the Setup packet is equal to 64. Aligned was the wrong term, multiple of 64 would be more appropriate :). The hid gadget driver queues a request for the transfer. Please see below logs.. ... HID: drivers/usb/gadget/f_hid_meu.c:366 - hidg_setup() HID: hid_setup crtl_request : bRequestType:0x21 bRequest:0x9 Value:0x200 What driver is this? I don't see drivers/usb/gadget/f_hid_meu.c in 4.1. I do see drivers/usb/gadget/function/f_hid.c, but in that driver the hidg_setup() routine does this: case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE) 8 | HID_REQ_SET_REPORT): VDBG(cdev, set_report | wLength=%d\n, ctrl-wLength); goto stall; break; Thus, it doesn't handle Set Report at all. This is a modified f_hid.c i.e. uses a single Interrupt IN endpoint and control ep0 for in and out transfers. The source is the same as f_hid.c before the integration of the Interrupt OUT patch usb: gadget: hidg: register OUT INT endpoint for SET_REPORT. See https://github.com/torvalds/linux/commit/99c515005857ff7d6cd5c2ba272ccab5dc0ea648 HID: drivers/usb/chipidea/udc.c:1337 - ep_queue() HID: drivers/usb/chipidea/udc.c:794 - _ep_queue() HID: drivers/usb/chipidea/udc.c:467 - _hardware_enqueue() HID: drivers/usb/chipidea/udc.c:395 - add_td_to_list() HID: drivers/usb/chipidea/udc.c:61 - hw_ep_bit() HID: drivers/usb/chipidea/udc.c:209 - hw_ep_prime() .. In the 64 bytes case, the following logs are missing (indicating transfer complete interrupt): ... HID: drivers/usb/chipidea/core.c:368 - ci_irq() HID: drivers/usb/chipidea/udc.c:1786 - udc_irq() HID: drivers/usb/chipidea/udc.c:282 - hw_read_intr_status() HID: drivers/usb/chipidea/udc.c:271 - hw_read_intr_enable() HID: drivers/usb/chipidea/udc.c:309 - hw_test_and_clear_intr_active() HID: drivers/usb/chipidea/udc.c:992 - isr_tr_complete_handler() HID: drivers/usb/chipidea/udc.c:295 - hw_test_and_clear_complete() HID: drivers/usb/chipidea/udc.c:68 - ep_to_bit() HID: drivers/usb/chipidea/udc.c:957 - isr_tr_complete_low() HID: drivers/usb/chipidea/udc.c:583 - _hardware_dequeue() HID: drivers/usb/gadget/f_hid_meu.c:322 - hidg_set_report_complete() ... Assuming the ep_queue() was for a 64-byte transfer, this indicates there is a bug in the chipidea UDC driver or hardware. Alan Stern If this is a bug in the chipidea UDC driver or hardware, how can I address this i.e. register an errata? I am hoping this is something Peter might be able to help with. Just like Steve pointed, it should be a ZLT problem, do you have below patch in your tree, and the host may not send zlt, but you may queue an zero-length request, the f_hid does not set req-zero flag either. commit 953c66469735aed8d2ada639a72b150f01dae605 Author: Abbas Raza abbas_r...@mentor.com Date: Thu Jul 17 19:34:31 2014 +0800 usb: chipidea: udc: Disable auto ZLP generation on ep0 If it still has problem, send me apps if possible (with needed kernel patches). -- 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
[PATCH RESEND v2 1/3] usb: dwc2: host: allocate qh before atomic enqueue
To avoid sleep while atomic bugs, allocate qh before calling dwc2_hcd_urb_enqueue. qh pointer can be used directly now instead of passing ep-hcpriv as double pointer. Acked-by: John Youn johny...@synopsys.com Tested-by: Heiko Stuebner he...@sntech.de Tested-by: Doug Anderson diand...@chromium.org Signed-off-by: Mian Yousaf Kaukab yousaf.kau...@intel.com --- drivers/usb/dwc2/hcd.c | 31 drivers/usb/dwc2/hcd.h | 5 - drivers/usb/dwc2/hcd_queue.c | 49 +++- 3 files changed, 43 insertions(+), 42 deletions(-) diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index b10377c..80bce71 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -359,7 +359,7 @@ void dwc2_hcd_stop(struct dwc2_hsotg *hsotg) /* Caller must hold driver lock */ static int dwc2_hcd_urb_enqueue(struct dwc2_hsotg *hsotg, - struct dwc2_hcd_urb *urb, void **ep_handle, + struct dwc2_hcd_urb *urb, struct dwc2_qh *qh, gfp_t mem_flags) { struct dwc2_qtd *qtd; @@ -391,8 +391,7 @@ static int dwc2_hcd_urb_enqueue(struct dwc2_hsotg *hsotg, return -ENOMEM; dwc2_hcd_qtd_init(qtd, urb); - retval = dwc2_hcd_qtd_add(hsotg, qtd, (struct dwc2_qh **)ep_handle, - mem_flags); + retval = dwc2_hcd_qtd_add(hsotg, qtd, qh); if (retval) { dev_err(hsotg-dev, DWC OTG HCD URB Enqueue failed adding QTD. Error status %d\n, @@ -2445,6 +2444,8 @@ static int _dwc2_hcd_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, u32 tflags = 0; void *buf; unsigned long flags; + struct dwc2_qh *qh; + bool qh_allocated = false; if (dbg_urb(urb)) { dev_vdbg(hsotg-dev, DWC OTG HCD URB Enqueue\n); @@ -2523,13 +2524,24 @@ static int _dwc2_hcd_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, urb-iso_frame_desc[i].length); urb-hcpriv = dwc2_urb; + qh = (struct dwc2_qh *) ep-hcpriv; + /* Create QH for the endpoint if it doesn't exist */ + if (!qh) { + qh = dwc2_hcd_qh_create(hsotg, dwc2_urb, mem_flags); + if (!qh) { + retval = -ENOMEM; + goto fail0; + } + ep-hcpriv = qh; + qh_allocated = true; + } spin_lock_irqsave(hsotg-lock, flags); retval = usb_hcd_link_urb_to_ep(hcd, urb); if (retval) goto fail1; - retval = dwc2_hcd_urb_enqueue(hsotg, dwc2_urb, ep-hcpriv, mem_flags); + retval = dwc2_hcd_urb_enqueue(hsotg, dwc2_urb, qh, mem_flags); if (retval) goto fail2; @@ -2549,6 +2561,17 @@ fail2: fail1: spin_unlock_irqrestore(hsotg-lock, flags); urb-hcpriv = NULL; + if (qh_allocated) { + struct dwc2_qtd *qtd2, *qtd2_tmp; + + ep-hcpriv = NULL; + dwc2_hcd_qh_unlink(hsotg, qh); + /* Free each QTD in the QH's QTD list */ + list_for_each_entry_safe(qtd2, qtd2_tmp, qh-qtd_list, +qtd_list_entry) + dwc2_hcd_qtd_unlink_and_free(hsotg, qtd2, qh); + dwc2_hcd_qh_free(hsotg, qh); + } fail0: kfree(dwc2_urb); diff --git a/drivers/usb/dwc2/hcd.h b/drivers/usb/dwc2/hcd.h index 7b5841c..fc10549 100644 --- a/drivers/usb/dwc2/hcd.h +++ b/drivers/usb/dwc2/hcd.h @@ -463,6 +463,9 @@ extern void dwc2_hcd_queue_transactions(struct dwc2_hsotg *hsotg, /* Schedule Queue Functions */ /* Implemented in hcd_queue.c */ extern void dwc2_hcd_init_usecs(struct dwc2_hsotg *hsotg); +extern struct dwc2_qh *dwc2_hcd_qh_create(struct dwc2_hsotg *hsotg, + struct dwc2_hcd_urb *urb, + gfp_t mem_flags); extern void dwc2_hcd_qh_free(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh); extern int dwc2_hcd_qh_add(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh); extern void dwc2_hcd_qh_unlink(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh); @@ -471,7 +474,7 @@ extern void dwc2_hcd_qh_deactivate(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh, extern void dwc2_hcd_qtd_init(struct dwc2_qtd *qtd, struct dwc2_hcd_urb *urb); extern int dwc2_hcd_qtd_add(struct dwc2_hsotg *hsotg, struct dwc2_qtd *qtd, - struct dwc2_qh **qh, gfp_t mem_flags); + struct dwc2_qh *qh); /* Unlinks and frees a QTD */ static inline void dwc2_hcd_qtd_unlink_and_free(struct dwc2_hsotg *hsotg, diff --git a/drivers/usb/dwc2/hcd_queue.c b/drivers/usb/dwc2/hcd_queue.c index 9b5c362..3ad63d3 100644 --- a/drivers/usb/dwc2/hcd_queue.c +++ b/drivers/usb/dwc2/hcd_queue.c @@ -191,7 +191,7 @@ static
[PATCH RESEND v2 0/3] usb: dwc2: fix sleep while atomic bugs
This series fixes 3 sources of sleep while atomic bugs. Including the one reported by Heiko Stuebner here: http://www.spinics.net/lists/linux-usb/msg125186.html Please review. Thank you, Best regards, Yousaf History: v2: - Fixed John's comment v1: - Added John's Acked-by Mian Yousaf Kaukab (3): usb: dwc2: host: allocate qh before atomic enqueue usb: dwc2: host: allocate qtd before atomic enqueue usb: dwc2: embed storage for reg backup in struct dwc2_hsotg drivers/usb/dwc2/core.c | 55 drivers/usb/dwc2/core.h | 9 +--- drivers/usb/dwc2/hcd.c | 55 +--- drivers/usb/dwc2/hcd.h | 5 +++- drivers/usb/dwc2/hcd_queue.c | 49 ++- 5 files changed, 79 insertions(+), 94 deletions(-) -- 2.3.3 -- 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: Errata for Freescale root-hub TT?
On Tue, Mar 31, 2015 at 10:02:52AM -0400, Alan Stern wrote: On Tue, 31 Mar 2015, Peter Chen wrote: I reproduced this issue, I can't see the fifth endpoints during the SoFs although the time to SoF boundary is about 800us, see attached. - At transaction 3749, the third UAC2 gadget is ready to send/receive data. - At next SoF periods, the first and the second devices send/receive data. - At transaction 3754, the third device's OUT is on the bus, but the address 11's OUT is disappeared. I reported this problem to IC team, but they are on new SoC validation periods, they said they will simulate it after new project has finished. That's great! I'm happy that you were able to duplicate the problem. Please let me know what the IC team has to say when they look at it. Do you know whether Freescale's root-hub TT implementation was done in-house? Or was it based on the old ARC/TDI IP? It's possible that a lot of different kinds of host controllers suffer from this problem. Alan Stern Hi Alan, I am not sure if you have noticed the patch[1], it is the solution for this issue, in the RTL, the default reserved time for one packet is 1023 bytes for siTD, so after 4 * 64 packets has transfered, the reserved time is not enough for 1023 bytes packet. This issue should exist at all ARC/Chipidea cores. [1] http://www.spinics.net/lists/linux-usb/msg126278.html -- 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
[PATCH RESEND v2 2/3] usb: dwc2: host: allocate qtd before atomic enqueue
To avoid sleep while atomic bugs, allocate qtd before calling dwc2_hcd_urb_enqueue. No need to pass mem_flags to dwc2_hcd_urb_enqueue any more as no memory allocations are done in it. Acked-by: John Youn johny...@synopsys.com Tested-by: Heiko Stuebner he...@sntech.de Tested-by: Doug Anderson diand...@chromium.org Signed-off-by: Mian Yousaf Kaukab yousaf.kau...@intel.com --- drivers/usb/dwc2/hcd.c | 26 -- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 80bce71..f845c41 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -360,9 +360,8 @@ void dwc2_hcd_stop(struct dwc2_hsotg *hsotg) /* Caller must hold driver lock */ static int dwc2_hcd_urb_enqueue(struct dwc2_hsotg *hsotg, struct dwc2_hcd_urb *urb, struct dwc2_qh *qh, - gfp_t mem_flags) + struct dwc2_qtd *qtd) { - struct dwc2_qtd *qtd; u32 intr_mask; int retval; int dev_speed; @@ -386,9 +385,8 @@ static int dwc2_hcd_urb_enqueue(struct dwc2_hsotg *hsotg, return -ENODEV; } - qtd = kzalloc(sizeof(*qtd), mem_flags); if (!qtd) - return -ENOMEM; + return -EINVAL; dwc2_hcd_qtd_init(qtd, urb); retval = dwc2_hcd_qtd_add(hsotg, qtd, qh); @@ -396,7 +394,6 @@ static int dwc2_hcd_urb_enqueue(struct dwc2_hsotg *hsotg, dev_err(hsotg-dev, DWC OTG HCD URB Enqueue failed adding QTD. Error status %d\n, retval); - kfree(qtd); return retval; } @@ -2446,6 +2443,7 @@ static int _dwc2_hcd_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, unsigned long flags; struct dwc2_qh *qh; bool qh_allocated = false; + struct dwc2_qtd *qtd; if (dbg_urb(urb)) { dev_vdbg(hsotg-dev, DWC OTG HCD URB Enqueue\n); @@ -2536,14 +2534,20 @@ static int _dwc2_hcd_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, qh_allocated = true; } + qtd = kzalloc(sizeof(*qtd), mem_flags); + if (!qtd) { + retval = -ENOMEM; + goto fail1; + } + spin_lock_irqsave(hsotg-lock, flags); retval = usb_hcd_link_urb_to_ep(hcd, urb); if (retval) - goto fail1; + goto fail2; - retval = dwc2_hcd_urb_enqueue(hsotg, dwc2_urb, qh, mem_flags); + retval = dwc2_hcd_urb_enqueue(hsotg, dwc2_urb, qh, qtd); if (retval) - goto fail2; + goto fail3; if (alloc_bandwidth) { dwc2_allocate_bus_bandwidth(hcd, @@ -2555,12 +2559,14 @@ static int _dwc2_hcd_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, return 0; -fail2: +fail3: dwc2_urb-priv = NULL; usb_hcd_unlink_urb_from_ep(hcd, urb); -fail1: +fail2: spin_unlock_irqrestore(hsotg-lock, flags); urb-hcpriv = NULL; + kfree(qtd); +fail1: if (qh_allocated) { struct dwc2_qtd *qtd2, *qtd2_tmp; -- 2.3.3 -- 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 RESEND v2 3/3] usb: dwc2: embed storage for reg backup in struct dwc2_hsotg
Register backup function can be called from atomic context. Instead of using atomic memory pool, embed backup storage space in struct dwc2_hsotg. Also add a valid flag in each struct as NULL pointer can't be used as the content validity check any more. Acked-by: John Youn johny...@synopsys.com Tested-by: Heiko Stuebner he...@sntech.de Tested-by: Doug Anderson diand...@chromium.org Signed-off-by: Mian Yousaf Kaukab yousaf.kau...@intel.com --- drivers/usb/dwc2/core.c | 55 ++--- drivers/usb/dwc2/core.h | 9 +--- 2 files changed, 21 insertions(+), 43 deletions(-) diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c index e5b546f..c3cc1a7 100644 --- a/drivers/usb/dwc2/core.c +++ b/drivers/usb/dwc2/core.c @@ -72,17 +72,7 @@ static int dwc2_backup_host_registers(struct dwc2_hsotg *hsotg) dev_dbg(hsotg-dev, %s\n, __func__); /* Backup Host regs */ - hr = hsotg-hr_backup; - if (!hr) { - hr = devm_kzalloc(hsotg-dev, sizeof(*hr), GFP_KERNEL); - if (!hr) { - dev_err(hsotg-dev, %s: can't allocate host regs\n, - __func__); - return -ENOMEM; - } - - hsotg-hr_backup = hr; - } + hr = hsotg-hr_backup; hr-hcfg = readl(hsotg-regs + HCFG); hr-haintmsk = readl(hsotg-regs + HAINTMSK); for (i = 0; i hsotg-core_params-host_channels; ++i) @@ -90,6 +80,7 @@ static int dwc2_backup_host_registers(struct dwc2_hsotg *hsotg) hr-hprt0 = readl(hsotg-regs + HPRT0); hr-hfir = readl(hsotg-regs + HFIR); + hr-valid = true; return 0; } @@ -109,12 +100,13 @@ static int dwc2_restore_host_registers(struct dwc2_hsotg *hsotg) dev_dbg(hsotg-dev, %s\n, __func__); /* Restore host regs */ - hr = hsotg-hr_backup; - if (!hr) { + hr = hsotg-hr_backup; + if (!hr-valid) { dev_err(hsotg-dev, %s: no host registers to restore\n, __func__); return -EINVAL; } + hr-valid = false; writel(hr-hcfg, hsotg-regs + HCFG); writel(hr-haintmsk, hsotg-regs + HAINTMSK); @@ -152,17 +144,7 @@ static int dwc2_backup_device_registers(struct dwc2_hsotg *hsotg) dev_dbg(hsotg-dev, %s\n, __func__); /* Backup dev regs */ - dr = hsotg-dr_backup; - if (!dr) { - dr = devm_kzalloc(hsotg-dev, sizeof(*dr), GFP_KERNEL); - if (!dr) { - dev_err(hsotg-dev, %s: can't allocate device regs\n, - __func__); - return -ENOMEM; - } - - hsotg-dr_backup = dr; - } + dr = hsotg-dr_backup; dr-dcfg = readl(hsotg-regs + DCFG); dr-dctl = readl(hsotg-regs + DCTL); @@ -195,7 +177,7 @@ static int dwc2_backup_device_registers(struct dwc2_hsotg *hsotg) dr-doeptsiz[i] = readl(hsotg-regs + DOEPTSIZ(i)); dr-doepdma[i] = readl(hsotg-regs + DOEPDMA(i)); } - + dr-valid = true; return 0; } @@ -215,12 +197,13 @@ static int dwc2_restore_device_registers(struct dwc2_hsotg *hsotg) dev_dbg(hsotg-dev, %s\n, __func__); /* Restore dev regs */ - dr = hsotg-dr_backup; - if (!dr) { + dr = hsotg-dr_backup; + if (!dr-valid) { dev_err(hsotg-dev, %s: no device registers to restore\n, __func__); return -EINVAL; } + dr-valid = false; writel(dr-dcfg, hsotg-regs + DCFG); writel(dr-dctl, hsotg-regs + DCTL); @@ -268,17 +251,7 @@ static int dwc2_backup_global_registers(struct dwc2_hsotg *hsotg) int i; /* Backup global regs */ - gr = hsotg-gr_backup; - if (!gr) { - gr = devm_kzalloc(hsotg-dev, sizeof(*gr), GFP_KERNEL); - if (!gr) { - dev_err(hsotg-dev, %s: can't allocate global regs\n, - __func__); - return -ENOMEM; - } - - hsotg-gr_backup = gr; - } + gr = hsotg-gr_backup; gr-gotgctl = readl(hsotg-regs + GOTGCTL); gr-gintmsk = readl(hsotg-regs + GINTMSK); @@ -291,6 +264,7 @@ static int dwc2_backup_global_registers(struct dwc2_hsotg *hsotg) for (i = 0; i MAX_EPS_CHANNELS; i++) gr-dtxfsiz[i] = readl(hsotg-regs + DPTXFSIZN(i)); + gr-valid = true; return 0; } @@ -309,12 +283,13 @@ static int dwc2_restore_global_registers(struct dwc2_hsotg *hsotg) dev_dbg(hsotg-dev, %s\n, __func__); /* Restore global regs */ - gr = hsotg-gr_backup; - if (!gr) { + gr = hsotg-gr_backup; + if (!gr-valid) { dev_err(hsotg-dev, %s: no global registers
Re: 64 byte EP0 OUT data transfer issue on Chipidea highspeed dual role controller
On Tue, Jun 30, 2015 at 6:50 AM, Peter Chen peter.c...@freescale.com wrote: On Tue, Jun 30, 2015 at 12:33 AM, Steve Calfee stevecal...@gmail.com wrote: On Mon, Jun 29, 2015 at 7:16 AM, Alan Stern st...@rowland.harvard.edu wrote: On Mon, 29 Jun 2015, Peter Chen wrote: Just like Steve pointed, it should be a ZLT problem, do you have below patch in your tree, and the host may not send zlt, but you may queue an zero-length request, the f_hid does not set req-zero flag either. commit 953c66469735aed8d2ada639a72b150f01dae605 Author: Abbas Raza abbas_r...@mentor.com Date: Thu Jul 17 19:34:31 2014 +0800 usb: chipidea: udc: Disable auto ZLP generation on ep0 If it still has problem, send me apps if possible (with needed kernel patches). Note that a UDC should _never_ queue an extra zero-length packet for an OUT transfer, no matter how req-zero is set. In other words, req-zero is supposed to affect only IN transfers. Yes UDC gadgets receive packets sent by the host on OUT transfers. If ZLT transfers are needed for the protocol, a short transfer is needed to end an OUT sequence and it must be sent by the sender, in this case the host. The UDC should detect receiving a zero length EP0 OUT and that signals the end of the 64 byte transfer from host to gadget. Regards, Steve Thanks Alan, Peter and Steve for your help and quick response. In fact, today I tested with a similar patch i.e. have QH_IOS and QH_ZLT set for control endpoint in udc.c. The 64 byte transfer appears to work fine. I am not sure whether this is the ideal solution, Testing some more to ensure that there are no regressions. I will send out an update in about a day. The most probably is the QH_ZLT bit, your tree may not the patch I mentioned above. The QH_IOS only affects a setup being received. Peter Sure, I will test this and update closure on this issue. Cheers, Jayan -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb: dwc2: gadget: use | instead of + for bitmasks
Hi, On Mon, Jun 29, 2015 at 08:18:48PM -0500, Felipe Balbi wrote: It's just a lot clearer to use | operator instead of + operator. Caught by coccicheck: drivers/usb/dwc2/gadget.c:2883:26-27: WARNING: sum of probable bitmasks, consider | Cc: John Youn john.y...@synopsys.com Signed-off-by: Felipe Balbi ba...@ti.com I have added this to my testing/next since it's not a bug fix. There's still plenty of time to remove this patch if people disagree. -- balbi signature.asc Description: Digital signature
[PATCH] usb: dwc2: gadget: use | instead of + for bitmasks
It's just a lot clearer to use | operator instead of + operator. Caught by coccicheck: drivers/usb/dwc2/gadget.c:2883:26-27: WARNING: sum of probable bitmasks, consider | Cc: John Youn john.y...@synopsys.com Signed-off-by: Felipe Balbi ba...@ti.com --- drivers/usb/dwc2/gadget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 4d47b7c09238..731b13dfc512 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -2880,7 +2880,7 @@ static int s3c_hsotg_ep_sethalt(struct usb_ep *ep, int value) epctl = readl(hs-regs + epreg); if (value) { - epctl |= DXEPCTL_STALL + DXEPCTL_SNAK; + epctl |= DXEPCTL_STALL | DXEPCTL_SNAK; if (epctl DXEPCTL_EPENA) epctl |= DXEPCTL_EPDIS; } else { -- 2.4.4 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: 64 byte EP0 OUT data transfer issue on Chipidea highspeed dual role controller
On Mon, Jun 29, 2015 at 7:16 AM, Alan Stern st...@rowland.harvard.edu wrote: On Mon, 29 Jun 2015, Peter Chen wrote: Just like Steve pointed, it should be a ZLT problem, do you have below patch in your tree, and the host may not send zlt, but you may queue an zero-length request, the f_hid does not set req-zero flag either. commit 953c66469735aed8d2ada639a72b150f01dae605 Author: Abbas Raza abbas_r...@mentor.com Date: Thu Jul 17 19:34:31 2014 +0800 usb: chipidea: udc: Disable auto ZLP generation on ep0 If it still has problem, send me apps if possible (with needed kernel patches). Note that a UDC should _never_ queue an extra zero-length packet for an OUT transfer, no matter how req-zero is set. In other words, req-zero is supposed to affect only IN transfers. Yes UDC gadgets receive packets sent by the host on OUT transfers. If ZLT transfers are needed for the protocol, a short transfer is needed to end an OUT sequence and it must be sent by the sender, in this case the host. The UDC should detect receiving a zero length EP0 OUT and that signals the end of the 64 byte transfer from host to gadget. Thanks, Alan Steve, I will have a patch to fix this in chipidea udc driver. Peter
Re: [PATCH 1/2] usb: chipidea: Reduce ULPI PHY reset pulse to datasheet spec of 1us
On Fri, Jun 26, 2015 at 03:47:03PM +0200, Mike Looijmans wrote: The datasheet for the 334x PHY mentions that a reset can be performed: ... by bringing the pin low for a minimum of 1 microsecond and then high. A delay of 5ms to implement that seems overly long, so reduce it to just 1us. As for the delay after reset, the datasheet only mentioned that the chip will assert the DIR output. 1ms seems like a safe time to wait for that to happen, so no change there. Signed-off-by: Mike Looijmans mike.looijm...@topic.nl --- drivers/usb/chipidea/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index e970863..c865abe 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -664,7 +664,7 @@ static int ci_hdrc_create_ulpi_phy(struct device *dev, struct ci_hdrc *ci) dev_err(dev, Failed to request ULPI reset gpio: %d\n, ret); return ret; } - msleep(5); + udelay(1); gpio_set_value_cansleep(reset_gpio, 1); msleep(1); } -- 1.9.1 We have no such function at mainline code. -- 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 v2] usb: xhci: Add support for URB_ZERO_PACKET to bulk/sg transfers
Hey Mathias, The intention is to send an extra endpoint packet of length zero as my wireless card needs this to function properly. I have skimmed through the xhci spec and assumed that each td would generate a packet. That is why I do not chain the last trb or add a interrupt flag, since I don't want to call the urb completion function called twice or called with the incorrect td or length. I have since tried a patch that just chains the trbs together, with the zero-length trb, and this still creates a zero-length packet. I was thinking I could remove the use of the last_trb variable I was using and simply chain all the trbs together and place the interupt flag on the zero-length trb if it exsits. Also I noticed that the other host controller drivers (ehci and ohci) check to ensure that the endpoint is sending data out and that the urb length is greater than zero. I will add these checks as well to keep in line with the their implementation. Do you think this is the best method for creating a zero-length packet, will every trb convert into at least one endpoint packet? Thank you, Reyad Attiyat On Mon, Jun 29, 2015 at 10:48 AM, Mathias Nyman mathias.ny...@intel.com wrote: Hi On 29.06.2015 03:53, Reyad Attiyat wrote: This commmit checks for the URB_ZERO_PACKET flag and creates an extra zero-length td if the urb transfer length is a multiple of the endpoint's max packet length. Signed-off-by: Reyad Attiyat reyad.atti...@gmail.com --- Thanks for the patch. Generic idea and implementation looks good, there are some opens though See comments and questions inline. drivers/usb/host/xhci-ring.c | 43 +-- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 7d34cbf..3d57a7a 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -3040,7 +3040,9 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, int num_sgs; int trb_buff_len, this_sg_len, running_total; unsigned int total_packet_count; + bool zero_length_needed; bool first_trb; + int last_trb; last_trb isn't a really a good name as it might be confused with td-last_trb. It's used for different purposes here. u64 addr; bool more_trbs_coming; @@ -3056,6 +3058,14 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, total_packet_count = DIV_ROUND_UP(urb-transfer_buffer_length, usb_endpoint_maxp(urb-ep-desc)); + /* Deal with URB_ZERO_PACKET - need one more td/trb */ + zero_length_needed = (urb-transfer_flags URB_ZERO_PACKET) + !(urb-transfer_buffer_length % usb_endpoint_maxp(urb-ep-desc)); Please move the to end of previous line. (minor thing but helps readability) Checkpatch also complains about missing whitespaces in the if () statements. + if(zero_length_needed){ + num_trbs++; + xhci_dbg(xhci, Creating zero length td.\n); + } + trb_buff_len = prepare_transfer(xhci, xhci-devs[slot_id], ep_index, urb-stream_id, num_trbs, urb, 0, mem_flags); @@ -3092,6 +3102,7 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, trb_buff_len = urb-transfer_buffer_length; first_trb = true; + last_trb = zero_length_needed ? 2 : 1; /* Queue the first TRB, even if it's zero-length */ do { u32 field = 0; @@ -3109,12 +3120,13 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, /* Chain all the TRBs together; clear the chain bit in the last * TRB to indicate it's the last TRB in the chain. */ - if (num_trbs 1) { + if (num_trbs last_trb) { field |= TRB_CHAIN; - } else { - /* FIXME - add check for ZERO_PACKET flag before this */ + } else if (num_trbs == last_trb) { td-last_trb = ep_ring-enqueue; field |= TRB_IOC; + } else if (zero_length_needed num_trbs == 1) { + trb_buff_len = 0; } Normally chain bits are set for all TRBs except the last TRB, and the IOC (interrupt on completion) is usually set for only the last TRB. In case last_trb == 2, the chain bit is now not set between the TRB containing the last data and the actual last zero TRB, which is the last TRB in the TD. It now also sets the interrupt on completion (IOC) for the TRB with the last data, but not for the final last, zero lengt TRB in the TD. Is this intentional and how we want zero packet bulk transfers to behave? -Mathias -- 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
Re: [PATCH RESEND v2 0/3] usb: dwc2: fix sleep while atomic bugs
On 6/29/2015 2:04 AM, Mian Yousaf Kaukab wrote: This series fixes 3 sources of sleep while atomic bugs. Including the one reported by Heiko Stuebner here: http://www.spinics.net/lists/linux-usb/msg125186.html Please review. Thank you, Best regards, Yousaf History: v2: - Fixed John's comment v1: - Added John's Acked-by Mian Yousaf Kaukab (3): usb: dwc2: host: allocate qh before atomic enqueue usb: dwc2: host: allocate qtd before atomic enqueue usb: dwc2: embed storage for reg backup in struct dwc2_hsotg drivers/usb/dwc2/core.c | 55 drivers/usb/dwc2/core.h | 9 +--- drivers/usb/dwc2/hcd.c | 55 +--- drivers/usb/dwc2/hcd.h | 5 +++- drivers/usb/dwc2/hcd_queue.c | 49 ++- 5 files changed, 79 insertions(+), 94 deletions(-) Hi Felipe, Could you queue this series for rc? Thanks, John -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH RESEND v2 0/3] usb: dwc2: fix sleep while atomic bugs
Hi, On Mon, Jun 29, 2015 at 11:56:10PM +, John Youn wrote: On 6/29/2015 2:04 AM, Mian Yousaf Kaukab wrote: This series fixes 3 sources of sleep while atomic bugs. Including the one reported by Heiko Stuebner here: http://www.spinics.net/lists/linux-usb/msg125186.html Please review. Thank you, Best regards, Yousaf History: v2: - Fixed John's comment v1: - Added John's Acked-by Mian Yousaf Kaukab (3): usb: dwc2: host: allocate qh before atomic enqueue usb: dwc2: host: allocate qtd before atomic enqueue usb: dwc2: embed storage for reg backup in struct dwc2_hsotg drivers/usb/dwc2/core.c | 55 drivers/usb/dwc2/core.h | 9 +--- drivers/usb/dwc2/hcd.c | 55 +--- drivers/usb/dwc2/hcd.h | 5 +++- drivers/usb/dwc2/hcd_queue.c | 49 ++- 5 files changed, 79 insertions(+), 94 deletions(-) Hi Felipe, Could you queue this series for rc? it's now in my testing/fixes. Once -rc1 is tagged I'll rebase, retest and send pull request. Thanks -- balbi signature.asc Description: Digital signature
Re: [PATCH 2/2] usb: chipidea: Wait 50 ms before reading ID bit
On Fri, Jun 26, 2015 at 03:47:04PM +0200, Mike Looijmans wrote: The datasheet for the USB343x PHY mentions a 50ms wait time before reading back the ID bit after enabling the internal pull-up or a reset: To monitor the status of the ID pin, the Link activates the IdPullup bit in the OTG Control register, waits 50mS and then reads the status of the IdGnd bit in the USB Interrupt Status register. Implement this by adding a 50ms sleep at the only point in the code where the ID status is being read without IRQ trigger. This 50mS delay is dedicated for this PHY, you may add it at the PHY driver. When starting the board with a USB cable connected to a PC, the system would activate host mode, then in ~20ms get an ID IRQ and attempt to switch to gadget mode. This then failed because the VBUS will not drop to zero (because the host is supplying it). After this patch, the system starts up correctly and selects gadget mode immediately, and the USB link works. It also fixes the issue that the VBUS supply was being activated while already being supplied from the host PC. Signed-off-by: Mike Looijmans mike.looijm...@topic.nl --- drivers/usb/chipidea/core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index c865abe..4c6cf48 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -801,6 +801,7 @@ static int ci_hdrc_probe(struct platform_device *pdev) if (ci-roles[CI_ROLE_HOST] ci-roles[CI_ROLE_GADGET]) { if (ci-is_otg) { + msleep(50); /* Datasheet: Wait 50ms to read ID */ ci-role = ci_otg_role(ci); /* Enable ID change irq */ hw_write_otgsc(ci, OTGSC_IDIE, OTGSC_IDIE); -- 1.9.1 -- 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 v2 3/3] usb: dwc3: gadget: return error if command sent to DEPCMD register fails
On 6/29/2015 2:48 PM, Felipe Balbi wrote: Hi again, On Mon, Jun 29, 2015 at 04:47:01PM -0500, Felipe Balbi wrote: On Thu, May 21, 2015 at 03:46:48PM +0530, Subbaraya Sundeep Bhatta wrote: We need to return error to caller if command is not sent to controller succesfully. Signed-off-by: Subbaraya Sundeep Bhatta sbha...@xilinx.com Fixes: 72246da40f37 (usb: Introduce DesignWare USB3 DRD Driver) Cc: sta...@vger.kernel.org --- v2 changes: Added Fixes and Cc in commit message. I noticed that this breaks at least my AM437x silicon with DWC3 2.40a when used with g_zero and testusb. As of now, it could be that silicon is mis-behaving because I got a Transfer Complete before the failing Set Endpoint Transfer Resource command. In any case, can you run on your setup with g_zero and test.sh/testusb [1]/[2] just to verify that it really works for you ? Meanwhile, I'll continue testing on my end. cheers [1] https://gitorious.org/usb/usb-tools/source/47ef073d9b6c0eae816204c81374aafb795c6e40:testusb.c [2] https://gitorious.org/usb/usb-tools/source/47ef073d9b6c0eae816204c81374aafb795c6e40:test.sh Adding John here. John, any chance you could fire up dwc3 on HAPS and see wether it works or fails for you ? Sure. I'll try to get to it tomorrow. John -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Official bugreport 4.1 kernel (audio gadget and ChipIdea)
On Fri, Jun 26, 2015 at 07:15:18PM +0200, Sébastien Pruvost wrote: Hello, I'm sending this mail to report a bug concerning the latest kernel 4.1. Here is the problem (and the test I've done): I have firstly used the 3.10.53 kernel for my two sabrelites in order to use the audio gadget driver with the Dual Role ChipIdea Controller (in order to switch roles between my two IMX6 sabreLite). After loading g_audio in my two sabreLite and plugging the cable (microA – microB), there is an error “ci_hdrc.0 request length too big for isochronous snd_uac2.0 1116 Error”. And even after running aplay command, I still got this error and there is no sound getting out of the jack port. I've switched roles between the two boards by following this: https:// www.kernel.org/doc/Documentation/usb/chipidea.txt. This works fine with the serial driver, I can see a new serial interface (host side) and after switching role a new serial interfaces at device side. Same thing for ethernet gadget: this works fine too. But not with the audio gadget. In fact, there is a new audio interface at host side but I can not interact with it (even alsamixer doesn’t see any controls on this new sound card). I’ve tested that audio gadget works fine if I don’t use ChipIdea HighSpeed Dual Role Controller. Secondly I have tested this audio gadget with the latest Kernel 4.1 for my two IMX6 sabrelites (imx_v6_v7_defconfig). Now these previous errors are gone but there are still no sound getting out of the jack port (even if there are a new sound card in host side) It is may not a role switch problem, please check if the g_audio can work well with an ubuntu PC (make sure your codec works well). I think this needs a patch to fix that. Best regards Sébastien Pruvost. -- 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] phy: phy-mxs-usb: suspend to RAM causes NULL pointer dereference
Am 15.06.2015 um 06:37 schrieb Stefan Wahren: Triggering suspend to RAM via sysfs on a i.MX28 causes a NULL pointer dereference. This patch avoids the oops in mxs_phy_get_vbus_status() by aborting since there is no syscon available. Signed-off-by: Stefan Wahren stefan.wah...@i2se.com Fixes: efdbd3a5d6e (usb: phy: mxs: do not set PWD.RXPWD1PT1 for low speed connection) CC: sta...@vger.kernel.org # 4.0 Acked-by: Peter Chen peter.c...@freescale.com Just a gentle ping -- 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: 64 byte EP0 OUT data transfer issue on Chipidea highspeed dual role controller
On Tue, Jun 30, 2015 at 12:33 AM, Steve Calfee stevecal...@gmail.com wrote: On Mon, Jun 29, 2015 at 7:16 AM, Alan Stern st...@rowland.harvard.edu wrote: On Mon, 29 Jun 2015, Peter Chen wrote: Just like Steve pointed, it should be a ZLT problem, do you have below patch in your tree, and the host may not send zlt, but you may queue an zero-length request, the f_hid does not set req-zero flag either. commit 953c66469735aed8d2ada639a72b150f01dae605 Author: Abbas Raza abbas_r...@mentor.com Date: Thu Jul 17 19:34:31 2014 +0800 usb: chipidea: udc: Disable auto ZLP generation on ep0 If it still has problem, send me apps if possible (with needed kernel patches). Note that a UDC should _never_ queue an extra zero-length packet for an OUT transfer, no matter how req-zero is set. In other words, req-zero is supposed to affect only IN transfers. Yes UDC gadgets receive packets sent by the host on OUT transfers. If ZLT transfers are needed for the protocol, a short transfer is needed to end an OUT sequence and it must be sent by the sender, in this case the host. The UDC should detect receiving a zero length EP0 OUT and that signals the end of the 64 byte transfer from host to gadget. Regards, Steve Thanks Alan, Peter and Steve for your help and quick response. In fact, today I tested with a similar patch i.e. have QH_IOS and QH_ZLT set for control endpoint in udc.c. The 64 byte transfer appears to work fine. I am not sure whether this is the ideal solution, Testing some more to ensure that there are no regressions. I will send out an update in about a day. Regards, Jayan -- 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