[RESEND PATCH] USB: gadget: udc: atmel: fix possible oops when unloading module
From: Songjun Wu songjun...@atmel.com When unloading the module 'g_hid.ko', the urb request will be dequeued and the completion routine will be excuted. If there is no urb packet, the urb request will not be added to the endpoint queue and the completion routine pointer in urb request is NULL. Accessing to this NULL function pointer will cause the Oops issue reported below. Add the code to check if the urb request is in the endpoint queue or not. If the urb request is not in the endpoint queue, a negative error code will be returned. Here is the Oops log: Unable to handle kernel NULL pointer dereference at virtual address pgd = dedf [] *pgd=3ede5831, *pte=, *ppte= Internal error: Oops: 8007 [#1] ARM Modules linked in: g_hid(-) usb_f_hid libcomposite CPU: 0 PID: 923 Comm: rmmod Not tainted 3.18.0+ #2 Hardware name: Atmel SAMA5 (Device Tree) task: df6b1100 ti: dedf6000 task.ti: dedf6000 PC is at 0x0 LR is at usb_gadget_giveback_request+0xc/0x10 pc : []lr : [c02ace88]psr: 6093 sp : dedf7eb0 ip : df572634 fp : r10: r9 : df52e210 r8 : 6013 r7 : df6a9858 r6 : df52e210 r5 : df6a9858 r4 : df572600 r3 : r2 : ff98 r1 : df572600 r0 : df6a9868 Flags: nZCv IRQs off FIQs on Mode SVC_32 ISA ARM Segment user Control: 10c53c7d Table: 3edf0059 DAC: 0015 Process rmmod (pid: 923, stack limit = 0xdedf6230) Stack: (0xdedf7eb0 to 0xdedf8000) 7ea0: c02adbbc df572580 deced608 7ec0: df572600 df6a9868 df572634 c02aed3c df577c00 c01b8608 df6be27c 7ee0: 00200200 00100100 bf0162f4 c000e544 dedf6000 bf010c00 7f00: bf0162cc bf00159c df572980 df52e218 0001 df5729b8 bf0031d0 [..] [c02ace88] (usb_gadget_giveback_request) from [c02adbbc] (request_complete+0x64/0x88) [c02adbbc] (request_complete) from [c02aed3c] (usba_ep_dequeue+0x70/0x128) [c02aed3c] (usba_ep_dequeue) from [bf010c00] (hidg_unbind+0x50/0x7c [usb_f_hid]) [bf010c00] (hidg_unbind [usb_f_hid]) from [bf00159c] (remove_config.isra.6+0x98/0x9c [libcomposite]) [bf00159c] (remove_config.isra.6 [libcomposite]) from [bf0031d0] (__composite_unbind+0x34/0x98 [libcomposite]) [bf0031d0] (__composite_unbind [libcomposite]) from [c02acee0] (usb_gadget_remove_driver+0x50/0x78) [c02acee0] (usb_gadget_remove_driver) from [c02ad570] (usb_gadget_unregister_driver+0x64/0x94) [c02ad570] (usb_gadget_unregister_driver) from [bf0160c0] (hidg_cleanup+0x10/0x34 [g_hid]) [bf0160c0] (hidg_cleanup [g_hid]) from [c0056748] (SyS_delete_module+0x118/0x19c) [c0056748] (SyS_delete_module) from [c000e3c0] (ret_fast_syscall+0x0/0x30) Code: bad PC value Signed-off-by: Songjun Wu songjun...@atmel.com [nicolas.fe...@atmel.com: reworked the commit message] Signed-off-by: Nicolas Ferre nicolas.fe...@atmel.com Fixes: 914a3f3b3754 (USB: add atmel_usba_udc driver) Cc: sta...@vger.kernel.org # 2.6.x-ish --- Felipe, I tried to collect all the information needed. Please tell me if it's what you expect from us. Songjun, I took a summary of your previous emails + the Oops log without breaking lines. The Fixes tag goes into the last part of the email. Thanks a lot for your fix. Bye, drivers/usb/gadget/udc/atmel_usba_udc.c | 12 +++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c index ce882371786b..48629cc3d6f8 100644 --- a/drivers/usb/gadget/udc/atmel_usba_udc.c +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c @@ -828,7 +828,7 @@ static int usba_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req) { struct usba_ep *ep = to_usba_ep(_ep); struct usba_udc *udc = ep-udc; - struct usba_request *req = to_usba_req(_req); + struct usba_request *req; unsigned long flags; u32 status; @@ -837,6 +837,16 @@ static int usba_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req) spin_lock_irqsave(udc-lock, flags); + list_for_each_entry(req, ep-queue, queue) { + if (req-req == _req) + break; + } + + if (req-req != _req) { + spin_unlock_irqrestore(udc-lock, flags); + return -EINVAL; + } + if (req-using_dma) { /* * If this request is currently being transferred, -- 2.1.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 0/1] xhci fix for 3.19-rc
Hi Greg Only one patch to solve the retry issue with reading device descriptors. Hopefully fixes Linus needing to re-plug his usb keyboard to make it work. Same fix solves some extra device resets done at resume. -Mathias Mathias Nyman (1): xhci: Check if slot is already in default state before moving it there drivers/usb/host/xhci.c | 9 + 1 file changed, 9 insertions(+) -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/1] xhci: Check if slot is already in default state before moving it there
Solves xhci error cases with debug messages: xhci_hcd :00:14.0: Setup ERROR: setup context command for slot 1. usb 1-6: hub failed to enable device, error -22 xhci will give a context state error if we try to set a slot in default state to the same default state with a special address device command. Turns out this happends in several cases: - retry reading the device rescriptor in hub_port_init() - usb_reset_device() is called for a slot in default state - in resume path, usb_port_resume() calls hub_port_init() The default state is usually reached from most states with a reset device command without any context state errors, but using the address device command with BSA bit set (block set address) only works from the enabled state and will otherwise cause context error. solve this by checking if we are already in the default state before issuing a address device BSA=1 command. Fixes: 48fc7dbd52c0 (usb: xhci: change enumeration scheme to 'new scheme') Cc: sta...@vger.kernel.org # v3.14+ Signed-off-by: Mathias Nyman mathias.ny...@linux.intel.com --- drivers/usb/host/xhci.c | 9 + 1 file changed, 9 insertions(+) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 01fcbb5..c50d8d2 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -3803,6 +3803,15 @@ static int xhci_setup_device(struct usb_hcd *hcd, struct usb_device *udev, return -EINVAL; } + if (setup == SETUP_CONTEXT_ONLY) { + slot_ctx = xhci_get_slot_ctx(xhci, virt_dev-out_ctx); + if (GET_SLOT_STATE(le32_to_cpu(slot_ctx-dev_state)) == + SLOT_STATE_DEFAULT) { + xhci_dbg(xhci, Slot already in default state\n); + return 0; + } + } + command = xhci_alloc_command(xhci, false, false, GFP_KERNEL); if (!command) return -ENOMEM; -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH V2] xhci: clean up work to remove unused parameters for functions in xhci-mem.c
Some parameters are not used by functions in xhci-mem.c, just remove it. Changes compared to v1: - Rebase to the latest usb-next branch Signed-off-by: Lin Wang lin.x.w...@intel.com --- drivers/usb/host/xhci-dbg.c |2 +- drivers/usb/host/xhci-mem.c | 21 + drivers/usb/host/xhci-ring.c |6 +++--- drivers/usb/host/xhci.c | 34 +- drivers/usb/host/xhci.h |7 +++ 5 files changed, 33 insertions(+), 37 deletions(-) diff --git a/drivers/usb/host/xhci-dbg.c b/drivers/usb/host/xhci-dbg.c index bb89175..745717e 100644 --- a/drivers/usb/host/xhci-dbg.c +++ b/drivers/usb/host/xhci-dbg.c @@ -552,7 +552,7 @@ void xhci_dbg_ctx(struct xhci_hcd *xhci, if (ctx-type == XHCI_CTX_TYPE_INPUT) { struct xhci_input_control_ctx *ctrl_ctx = - xhci_get_input_control_ctx(xhci, ctx); + xhci_get_input_control_ctx(ctx); if (!ctrl_ctx) { xhci_warn(xhci, Could not get input context, bad type.\n); return; diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 5cb3d7a..2e6eaf4 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -535,7 +535,7 @@ static void xhci_free_container_ctx(struct xhci_hcd *xhci, kfree(ctx); } -struct xhci_input_control_ctx *xhci_get_input_control_ctx(struct xhci_hcd *xhci, +struct xhci_input_control_ctx *xhci_get_input_control_ctx( struct xhci_container_ctx *ctx) { if (ctx-type != XHCI_CTX_TYPE_INPUT) @@ -784,8 +784,7 @@ void xhci_setup_streams_ep_input_ctx(struct xhci_hcd *xhci, * Reinstalls the normal endpoint ring (at its previous dequeue mark, * not at the beginning of the ring). */ -void xhci_setup_no_streams_ep_input_ctx(struct xhci_hcd *xhci, - struct xhci_ep_ctx *ep_ctx, +void xhci_setup_no_streams_ep_input_ctx(struct xhci_ep_ctx *ep_ctx, struct xhci_virt_ep *ep) { dma_addr_t addr; @@ -1342,8 +1341,7 @@ static u32 xhci_get_endpoint_mult(struct usb_device *udev, return ep-ss_ep_comp.bmAttributes; } -static u32 xhci_get_endpoint_type(struct usb_device *udev, - struct usb_host_endpoint *ep) +static u32 xhci_get_endpoint_type(struct usb_host_endpoint *ep) { int in; u32 type; @@ -1376,8 +1374,7 @@ static u32 xhci_get_endpoint_type(struct usb_device *udev, * Basically, this is the maxpacket size, multiplied by the burst size * and mult size. */ -static u32 xhci_get_max_esit_payload(struct xhci_hcd *xhci, - struct usb_device *udev, +static u32 xhci_get_max_esit_payload(struct usb_device *udev, struct usb_host_endpoint *ep) { int max_burst; @@ -1418,7 +1415,7 @@ int xhci_endpoint_init(struct xhci_hcd *xhci, ep_index = xhci_get_endpoint_index(ep-desc); ep_ctx = xhci_get_ep_ctx(xhci, virt_dev-in_ctx, ep_index); - endpoint_type = xhci_get_endpoint_type(udev, ep); + endpoint_type = xhci_get_endpoint_type(ep); if (!endpoint_type) return -EINVAL; ep_ctx-ep_info2 = cpu_to_le32(endpoint_type); @@ -1484,7 +1481,7 @@ int xhci_endpoint_init(struct xhci_hcd *xhci, } ep_ctx-ep_info2 |= cpu_to_le32(MAX_PACKET(max_packet) | MAX_BURST(max_burst)); - max_esit_payload = xhci_get_max_esit_payload(xhci, udev, ep); + max_esit_payload = xhci_get_max_esit_payload(udev, ep); ep_ctx-tx_info = cpu_to_le32(MAX_ESIT_PAYLOAD_FOR_EP(max_esit_payload)); /* @@ -1773,7 +1770,7 @@ struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci, return command; } -void xhci_urb_free_priv(struct xhci_hcd *xhci, struct urb_priv *urb_priv) +void xhci_urb_free_priv(struct urb_priv *urb_priv) { if (urb_priv) { kfree(urb_priv-td[0]); @@ -1926,7 +1923,7 @@ static int xhci_test_trb_in_td(struct xhci_hcd *xhci, } /* TRB math checks for xhci_trb_in_td(), using the command and event rings. */ -static int xhci_check_trb_in_td_math(struct xhci_hcd *xhci, gfp_t mem_flags) +static int xhci_check_trb_in_td_math(struct xhci_hcd *xhci) { struct { dma_addr_t input_dma; @@ -2452,7 +2449,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) flags); if (!xhci-event_ring) goto fail; - if (xhci_check_trb_in_td_math(xhci, flags) 0) + if (xhci_check_trb_in_td_math(xhci) 0) goto fail; xhci-erst.entries = dma_alloc_coherent(dev, diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index e692e76..5e1090a 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -609,7 +609,7 @@ static void xhci_giveback_urb_in_irq(struct xhci_hcd *xhci,
RE: [PATCH v2 00/30] usb: updates for dwc2 gadget driver
-Original Message- From: Dinh Nguyen [mailto:dingu...@opensource.altera.com] Sent: Thursday, January 8, 2015 5:34 PM To: Kaukab, Yousaf; 'Paul Zimmerman'; 'linux-usb@vger.kernel.org'; 'ba...@ti.com' Cc: Herrero, Gregory; 'sergei.shtyl...@cogentembedded.com'; 'r.bald...@samsung.com' Subject: Re: [PATCH v2 00/30] usb: updates for dwc2 gadget driver Hi Yousaf, On 01/08/2015 08:27 AM, Kaukab, Yousaf wrote: Hi, -Original Message- From: Kaukab, Yousaf Sent: Wednesday, January 7, 2015 7:55 PM To: Dinh Nguyen; Paul Zimmerman; linux-usb@vger.kernel.org; ba...@ti.com Cc: Herrero, Gregory; sergei.shtyl...@cogentembedded.com; r.bald...@samsung.com Subject: RE: [PATCH v2 00/30] usb: updates for dwc2 gadget driver Hi Dinh, -Original Message- From: Dinh Nguyen [mailto:dingu...@opensource.altera.com] Sent: Wednesday, January 7, 2015 5:26 PM To: Kaukab, Yousaf; Paul Zimmerman; linux-usb@vger.kernel.org; ba...@ti.com Cc: Herrero, Gregory; sergei.shtyl...@cogentembedded.com; r.bald...@samsung.com Subject: Re: [PATCH v2 00/30] usb: updates for dwc2 gadget driver Hi Yousaf, I've also attached a text file of the log. root@socfpga_cyclone5:~# insmod g_mass_storage.ko file=/dev/mmcblk0p1 [ 144.084933] Number of LUNs=8 [ 144.087817] Mass Storage Function, version: 2009/09/11 [ 144.092936] LUN: removable file: (no medium) [ 144.097228] Number of LUNs=1 [ 144.100217] LUN: file: /dev/mmcblk0p1 [ 144.103867] Number of LUNs=1 [ 144.106941] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11 [ 144.113874] g_mass_storage gadget: userspace failed to provide iSerialNumber [ 144.120922] g_mass_storage gadget: g_mass_storage ready [ 144.129387] dwc2 ffb4.usb: bound driver g_mass_storage root@socfpga_cyclone5:~# root@socfpga_cyclone5:~# [ 144.353610] dwc2 ffb4.usb: new device is high-speed [ 144.527612] dwc2 ffb4.usb: new device is high-speed [ 149.595802] [ cut here ] [ 149.600420] WARNING: CPU: 0 PID: 0 at drivers/usb/dwc2/gadget.c:1352 s3c_hsotg_rx_data+0xcc/0x144() [ 149.609423] Modules linked in: g_mass_storage usb_f_mass_storage libcomposite [ 149.616582] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 3.19.0-rc1-00090-g4864f14 #14 [ 149.624202] Hardware name: Altera SOCFPGA [ 149.628222] [c00165e4] (unwind_backtrace) from [c00124f0] (show_stack+0x20/0x24) [ 149.635941] [c00124f0] (show_stack) from [c04c7374] (dump_stack+0x7c/0x98) [ 149.643147] [c04c7374] (dump_stack) from [c0023ec4] (warn_slowpath_common+0x88/0xc4) [ 149.651208] [c0023ec4] (warn_slowpath_common) from [c0023f2c] (warn_slowpath_null+0x2c/0x34) [ 149.659961] [c0023f2c] (warn_slowpath_null) from [c034ccc4] (s3c_hsotg_rx_data+0xcc/0x144) [ 149.668542] [c034ccc4] (s3c_hsotg_rx_data) from [c034f884] (s3c_hsotg_irq+0x3e0/0x708) [ 149.676777] [c034f884] (s3c_hsotg_irq) from [c0060d30] (handle_irq_event_percpu+0x68/0x204) [ 149.685442] [c0060d30] (handle_irq_event_percpu) from [c0060f20] (handle_irq_event+0x54/0x74) [ 149.694280] [c0060f20] (handle_irq_event) from [c0063e2c] (handle_fasteoi_irq+0xb8/0x190) [ 149.702771] [c0063e2c] (handle_fasteoi_irq) from [c0060548] (generic_handle_irq+0x30/0x40) [ 149.711348] [c0060548] (generic_handle_irq) from [c0060694] (__handle_domain_irq+0x64/0xc4) [ 149.720012] [c0060694] (__handle_domain_irq) from [c00086bc] (gic_handle_irq+0x30/0x6c) [ 149.728333] [c00086bc] (gic_handle_irq) from [c00130c0] (__irq_svc+0x40/0x54) [ 149.735781] Exception stack(0xc06fbf38 to 0xc06fbf80) [ 149.740811] bf20: [ 149.748953] bf40: c06fbf90 c001f600 c0702c60 c0733560 c0702498 c04cf08c c0732d73 413fc090 [ 149.757096] bf60: c0733560 c06fbf8c c06fbf90 c06fbf80 c000f934 c000f938 6013 [ 149.765243] [c00130c0] (__irq_svc) from [c000f938] (arch_cpu_idle+0x40/0x4c) [ 149.772616] [c000f938] (arch_cpu_idle) from [c0057670] (cpu_startup_entry+0x144/0x22c) [ 149.780857] [c0057670] (cpu_startup_entry) from [c04c2bc4] (rest_init+0x70/0x88) [ 149.788581] [c04c2bc4] (rest_init) from [c069bc60] (start_kernel+0x310/0x368) [ 149.796030] ---[ end trace 05bdb288fcc8864d ]--- [ 155.793924] random: nonblocking pool is initialized I don't see any debug messages. Did you enable CONFIG_USB_DWC2_DEBUG? If so, then perhaps you need to set the log level in your console (/proc/sys/kernel/printk)? What about Values of following registers GSNPSID, GHWCFG1-GHWCFG4? Is it possible for you to print them as well? Without the debug log it's difficult to conclude why you are seeing this behavior. One probable reason could be that your revision of the dwc2 core does not generate GRXSTS_PKTSTS_OUTDONE on setup packets. Rev 3.0a generates both GRXSTS_PKTSTS_OUTDONE and GRXSTS_PKTSTS_SETUPDONE on setup packets.
Re: USB HID Gadget Support for Intel Edison
W dniu 08.01.2015 o 18:09, Felipe Balbi pisze: Hi, On Thu, Jan 08, 2015 at 09:05:24AM -0800, Chris McClimans wrote: I'm trying to get the g_hid module working with the Intel Edison. I tried just compiling intel's patch(1) to 3.10.17 with CONFIG_USB_GADGETFS=m CONFIG_USB_G_HID=m but I get an error trying to load the module: modprobe: ERROR: could not insert 'g_hid': No such device According to https://www.kernel.org/doc/Documentation/usb/gadget_hid.txt: In the very same file there is an example platform driver; well, at least the most important hid-specific parts of it. You must add the usual module boilerplate code and in module's init do platform_device_register(), while in module's exit do platform_device_unregister(). You might also want to have a look at a configfs-composed gadget, where the hid function does not require creating nor registering any platform devices; the report descriptors are passed through a configfs attribute (file). For more information you can have a look here: http://www.spinics.net/lists/linux-usb/msg116980.html and here: http://www.spinics.net/lists/linux-usb/msg118705.html AP -- 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 03/30] usb: dwc2: gadget: don't process XferCompl on setup packet
Hi, -Original Message- From: Sergei Shtylyov [mailto:sergei.shtyl...@cogentembedded.com] Sent: Friday, January 2, 2015 6:09 PM To: Kaukab, Yousaf; linux-usb@vger.kernel.org; ba...@ti.com Cc: Herrero, Gregory; pa...@synopsys.com; r.bald...@samsung.com Subject: Re: [PATCH v2 03/30] usb: dwc2: gadget: don't process XferCompl on setup packet Hello. On 1/2/2015 5:42 PM, Mian Yousaf Kaukab wrote: Only process DOEPINT.XferCompl on data packet as DOEPINTn.SetUp can occur with or without DOEPINT.XferCompl. When DOEPINT.SetUp occurs with DOEPINT.XferCompl, only DOEPINT.SetUp needs to be handled. Moreover, ignore DOEPINT.XferCompl when it occurs with DOEPINT.StupPktRcvd as driver needs to wait for DOEPINT.SetUp to continue. Signed-off-by: Mian Yousaf Kaukab yousaf.kau...@intel.com --- drivers/usb/dwc2/gadget.c | 4 drivers/usb/dwc2/hw.h | 1 + 2 files changed, 5 insertions(+) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 843f3ee..e190d68 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -1810,6 +1810,10 @@ static void s3c_hsotg_epint(struct dwc2_hsotg *hsotg, unsigned int idx, dev_dbg(hsotg-dev, %s: ep%d(%s) DxEPINT=0x%08x\n, __func__, idx, dir_in ? in : out, ints); + /* Don't process XferCompl interrupt if it is a setup packet */ + if (ints DXEPINT_SETUP || ints DXEPINT_SETUP_RCVD) if (ints (DXEPINT_SETUP | DXEPINT_SETUP_RCVD)) Sure. In a rare case, DXEPINT_SETUP_RCVD was also set for a non-control endpoint. So I will modify the check to following: if (idx == 0 (ints (DXEPINT_SETUP | DXEPINT_SETUP_RCVD))) [...] WBR, Sergei BR, Yousaf -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Fwd: USB HID Gadget support for dwc3 on platform/intel-mid
Hi Chris On 2015-01-08 at 17:38:07 +0100, Chris McClimans ch...@hippiehacker.org wrote: I found your email in the commits for gadget_hid.txt and thought one of you might might be able to point me in the right direction. I'm trying to get the g_hid module working with the Intel Edison. Please don't send such e-mails to people in private, this is considered quite rude by some. Rather send the e-mail to the respective mailing list (linux-usb@vger.kernel.org in your case). That way the person considering herself proficient on the subject can answer. Additionally the possible solution for the problem will be archived in the mailin list's archive, such that other people having the same problem in the future might get their answer directly from there. As for myself, I only did some minor edits to the documentation file and haven't worked with g_hid in a while. I tried just compiling intel's patch(1) to 3.10.17 with CONFIG_USB_GADGETFS=m CONFIG_USB_G_HID=m but I get an error trying to load the module: modprobe: ERROR: could not insert 'g_hid': No such device According to https://www.kernel.org/doc/Documentation/usb/gadget_hid.txt: g_hid is a platform driver, so to use it you need to add struct platform_device(s) to your platform code defining the HID function descriptors you want to use It's not clear to me what part of the platform code I should be adding, but I assume it's something under: https://github.com/instantinfrastructure/linux-yocto-3.10/tree/edison/arch/x86/platform/intel-mid The documentation file already contains the respective code. Did you try adding that to the appropriate place for your platform? You might want to ask on a list specifc to the platform for where that would be. -- 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: Another Seagate USB 3 device that needs uas blacklisting - 0bc2:2321
On Wed, Dec 31, 2014 at 09:10:32PM +, Thomas Eriksson wrote: Sorry, was a bit hasty there. Should have tested properly. The US_FL_NO_ATA_1X flag does not fix this problem, but the US_FL_IGNORE_UAS flag does. The patch should be *** unusual_uas.h.orig2014-12-18 19:20:12.0 -0800 --- unusual_uas.h 2014-12-31 12:55:56.0 -0800 *** *** 47,52 --- 47,59 USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_NO_ATA_1X), + /* Reported by: Thomas Eriksson lte...@gmail.com */ + UNUSUAL_DEV(0x0bc2, 0x2321, 0x, 0x, + Seagate, + Expansion, + USB_SC_DEVICE, USB_PR_DEVICE, NULL, + US_FL_IGNORE_UAS), + /* https://bbs.archlinux.org/viewtopic.php?id=183190 */ UNUSUAL_DEV(0x0bc2, 0x3312, 0x, 0x, Seagate, Can you fix this up and resend it in a format I can apply it? Please read Documentation/SubmittingPatches for all of the details. thanks, greg k-h -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: storage: Revise/fix quirk for 04E6:000F SCM USB-SCSI converter
On Fri, Dec 05, 2014 at 02:48:19PM +, Mark Knibbs wrote: I recently posted a patch (storage: Add quirk for another SCM-based USB-SCSI converter) to add a quirk for the converter with ID 04E6:000F, which is listed along with 04E6:000B in the Windows INF file for the Startech ICUSBSCSI2 as eUSB SCSI Adapter (Bus Powered). The already-present quirk for 04E6:000B has USB_SC_SCSI/USB_PR_BULK, not USB_SC_DEVICE/USB_PR_DEVICE. Change the 04E6:000F quirk to match that. Signed-off-by: Mark Knibbs ma...@clara.co.uk --- While I don't have one to check, later SCM converters probably use vendor-specific class and protocol, thus specifying USB_SC_SCSI/USB_PR_BULK is necessary. Some speculation as to the reason for the difference... I'm not sure whether the change was for all later products, or is related to the later products being bus-powered. Windows 98 was the current mainstream OS when the eUSCSI converter was first introduced. That OS didn't ship with a USB mass storage driver, thus in order to use the converter the SCM driver had to be installed. Later Windows 2000 was released, which included a USB mass storage driver. If the user were to connect the converter before installing the SCM driver, Windows would install its default mass storage driver which only works with the SCSI device at ID 0. Perhaps SCM changed to a vendor-specific class/ protocol to prevent the Windows generic driver binding to it, and reduce driver-related technical support issues? Patch is based on 3.18-rc7. diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index 11c7a96..bfc4a6a 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h @@ -507,7 +507,7 @@ UNUSUAL_DEV( 0x04e6, 0x000c, 0x0100, 0x0100, UNUSUAL_DEV( 0x04e6, 0x000f, 0x, 0x, SCM Microsystems, eUSB SCSI Adapter (Bus Powered), - USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_euscsi_init, + USB_SC_SCSI, USB_PR_BULK, usb_stor_euscsi_init, US_FL_SCM_MULT_TARG ), The whitespace here is all messed up (all spaces), and prevents this patch from being applied :( Can you please fix that up and resend? thanks, greg k-h -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 1/1] usb: chipidea: host: add .bus_suspend quirk
On Fri, 9 Jan 2015, Peter Chen wrote: For chipidea, its resume sequence is not-EHCI compatible, see below description for FPR at portsc. So in order to send SoF in time for remote wakeup sequence(within 3ms), the RUN/STOP bit must be set before the resume signal is ended, but the usb resume code may run after resume signal is ended, so we had to set it at suspend path. Force Port Resume - RW. Default = 0b. 1= Resume detected/driven on port. 0=No resume (K-state) detected/driven on port. Host mode: Software sets this bit to one to drive resume signaling. The Controller sets this bit to '1' if a J-to-K transition is detected while the port is in the Suspend state. When this bit transitions to a '1' because a J-to-K transition is detected, the Port Change Detect bit in the USBSTS register is also set to '1'. This bit will automatically change to '0' after the resume sequence is complete. This behavior is different from EHCI where the controller driver is required to set this bit to a '0' after the resume duration is timed in the driver. Note that when the controller owns the port, the resume sequence follows the defined sequence documented in the USB Specification Revision 2.0. The resume signaling (Full-speed 'K') is driven on the port as long as this bit remains a '1'. This bit will remain a '1' until the port has switched to idle. Writing a '0' has no affect because the port controller will time the resume operation, clear the bit and the port control state switches to HS or FS idle. This field is '0' if Port Power(PP) is '0' in host mode. This bit is not-EHCI compatible. Signed-off-by: Peter Chen peter.c...@freescale.com Acked-by: Alan Stern st...@rowland.harvard.edu -- 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-storage/SCSI: blacklist FUA on JMicron 152d:2566 USB-SATA controller
On Mon, Dec 29, 2014 at 06:02:45PM +0200, Dmitry Nezhevenko wrote: It looks like FUA support is broken on JMicron 152d:2566 bridge: [223159.885704] sd 7:0:0:0: [sdc] Write Protect is off [223159.885706] sd 7:0:0:0: [sdc] Mode Sense: 47 00 10 08 [223159.885942] sd 7:0:0:0: [sdc] Write cache: enabled, read cache: enabled, supports DPO and FUA [223283.691677] sd 7:0:0:0: [sdc] [223283.691680] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE [223283.691681] sd 7:0:0:0: [sdc] [223283.691682] Sense Key : Illegal Request [current] [223283.691684] sd 7:0:0:0: [sdc] [223283.691685] Add. Sense: Invalid field in cdb [223283.691686] sd 7:0:0:0: [sdc] CDB: [223283.691687] Write(10): 2a 08 15 d0 83 0d 00 00 01 00 [223283.691690] blk_update_request: critical target error, dev sdc, sector 2927892584 This patch adds blacklist flag so that sd will not use FUA --- drivers/usb/storage/unusual_devs.h | 7 +++ 1 file changed, 7 insertions(+) No signed-off-by line, so I can't take this :( Please resend with the proper information. thanks, greg k-h -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 00/20] Add UDC support to the isp1760 driver
Hi, On Tue, Dec 30, 2014 at 01:49:28PM +0200, Laurent Pinchart wrote: Hello, This patch set adds UDC support to the isp1760 driver, to be used with the ISP1761 dual-role USB controller. The first 17 patches rework the isp1760 driver to prepare it for UDC support. In particular they removes the direct HCD dependencies from the glue code (01/20 to 04/20), creates core initialization code shared by the HCD and UDC (15/20) and move common initialization code to the core (16/20 to 17/20). Patch 18/20 adds UDC support, and patches 19/20 and 20/20 move the driver to drivers/usb/isp1760/ and make HCD support optional. The ISP1761 has three USB ports, with port 1 configurable in host or peripheral mode with OTG support, and ports 2 and 3 supporting host mode only. OTG support is not implemented yet, port 1 can thus be configured in host or peripheral mode only. The UDC driver has been successfully tested with the g_zero and g_mass_storage gadgets. Global changes compared to v2: - Rebase on top of Felipe's testing/next branch - Drop patches that have been merged already - Add patch 19/20 and 20/20 Global changes compared to v1: - Replace GPIO request move by patch 01/22 - Split PORT1 configuration to separate patch - Drop the shutdown implementation patch - Add patches 02/22, 04/22, 05/22, 13/22, 14/22 See individual patches for patch-specific changes. with this set I started getting: In file included from drivers/usb/isp1760/isp1760-core.h:22:0, from drivers/usb/isp1760/isp1760-core.c:24: drivers/usb/isp1760/isp1760-udc.h:65:5: warning: CONFIG_USB_ISP1761_UDC is not defined [-Wundef] drivers/usb/isp1760/isp1760-udc.h:90:5: warning: CONFIG_USB_ISP1761_UDC is not defined [-Wundef] I have now dropped this series from my testing/next -- balbi signature.asc Description: Digital signature
Re: [PATCH v3 00/20] Add UDC support to the isp1760 driver
Hi, On Fri, Jan 09, 2015 at 11:30:31AM -0600, Felipe Balbi wrote: This patch set adds UDC support to the isp1760 driver, to be used with the ISP1761 dual-role USB controller. The first 17 patches rework the isp1760 driver to prepare it for UDC support. In particular they removes the direct HCD dependencies from the glue code (01/20 to 04/20), creates core initialization code shared by the HCD and UDC (15/20) and move common initialization code to the core (16/20 to 17/20). Patch 18/20 adds UDC support, and patches 19/20 and 20/20 move the driver to drivers/usb/isp1760/ and make HCD support optional. The ISP1761 has three USB ports, with port 1 configurable in host or peripheral mode with OTG support, and ports 2 and 3 supporting host mode only. OTG support is not implemented yet, port 1 can thus be configured in host or peripheral mode only. The UDC driver has been successfully tested with the g_zero and g_mass_storage gadgets. Global changes compared to v2: - Rebase on top of Felipe's testing/next branch - Drop patches that have been merged already - Add patch 19/20 and 20/20 Global changes compared to v1: - Replace GPIO request move by patch 01/22 - Split PORT1 configuration to separate patch - Drop the shutdown implementation patch - Add patches 02/22, 04/22, 05/22, 13/22, 14/22 See individual patches for patch-specific changes. with this set I started getting: In file included from drivers/usb/isp1760/isp1760-core.h:22:0, from drivers/usb/isp1760/isp1760-core.c:24: drivers/usb/isp1760/isp1760-udc.h:65:5: warning: CONFIG_USB_ISP1761_UDC is not defined [-Wundef] drivers/usb/isp1760/isp1760-udc.h:90:5: warning: CONFIG_USB_ISP1761_UDC is not defined [-Wundef] I have now dropped this series from my testing/next btw, I've dropped the entire series, even the ones which were applied before. Please rebase and make sure each patch builds fine without warnings or build errors. -- balbi signature.asc Description: Digital signature
RE: [PATCH v3 00/30] usb: updates for dwc2 gadget driver
CCing more of the Samsung folks and linux-kernel. Robert, Marek, can you test this series on your platform, please? If I don't hear from you soon, I'll just ack it and we can deal with any breakage later. -- Paul From: Mian Yousaf Kaukab [mailto:yousaf.kau...@intel.com] Sent: Friday, January 09, 2015 4:39 AM Hi, This patchset consists of various bug fixes and feature enhancements for the dwc2 gadget driver. All the patches are verified on dwc2 v3.0a with dedicated fifos. Main focus of testing was with dma enabled. Although basic testing without dma was also done. It is based on testing/next branch in Felipe's git and Tested-by: Dinh Nguyen dingu...@opensource.altera.com Thank you, Best regards, Yousaf History: v3: - Fixed comment from Sergei Shtylyov - Updated usb: dwc2: gadget: don't process XferCompl on setup packet to apply the check on endpoint 0 only. - Fixed regression in usb: dwc2: gadget: manage ep0 state in software for dwc2 ip v2.93a, found by Dinh Nguyen. v2: - Rebased to Felipe's testing/next with https://lkml.org/lkml/2014/12/16/135 applied on top. - Fixed comments from Robert Baldyga - Some cosmetic changes - Replaced usb: dwc2: gadget: process setup packet on transfer complete with usb: dwc2: gadget: don't process XferCompl on setup packet - Updated usb: dwc2: gadget: provide gadget handle to the phy so that otg_set_peripheral is called in both udc_start and udc_stop. v1: - Addressed comments from Sergei Shtylyov Gregory Herrero (13): usb: dwc2: gadget: register gadget handle to the phy usb: dwc2: gadget: write correct value in ahbcfg register usb: dwc2: gadget: don't erase gahbcfg register when enabling dma usb: dwc2: gadget: add device tree property to enable dma Documentation: dt-bindings: add dt binding info for dwc2 g-use-dma usb: dwc2: gadget: configure fifos from device tree Documentation: dt-bindings: add dt binding info for dwc2 fifo resizing usb: dwc2: gadget: don't block after fifo flush timeout usb: dwc2: gadget: add vbus_session support usb: dwc2: gadget: reset fifo_map when initializing fifos usb: dwc2: gadget: fix pullup handling usb: dwc2: gadget: add vbus_draw support usb: dwc2: gadget: force gadget initialization in dev mode Mian Yousaf Kaukab (17): usb: dwc2: gadget: mask fifo empty irq with dma usb: dwc2: gadget: don't process XferCompl on setup packet usb: dwc2: gadget: don't embed ep0 buffers usb: dwc2: gadget: fix error path in dwc2_gadget_init usb: dwc2: gadget: add bi-directional endpoint support usb: dwc2: gadget: check interrupts for all endpoints usb: dwc2: gadget: remove unused members from hsotg_req usb: dwc2: gadget: fix debug loop limits usb: dwc2: gadget: consider all tx fifos usb: dwc2: gadget: kill requests after disabling ep usb: dwc2: gadget: manage ep0 state in software usb: dwc2: gadget: fix zero length packet transfers usb: dwc2: gadget: dont warn if endpoint is not enabled usb: dwc2: gadget: rename sent_zlp to send_zlp usb: dwc2: gadget: pick smallest acceptable fifo usb: dwc2: gadget: fix fifo allocation leak usb: dwc2: gadget: report disconnection after reset Documentation/devicetree/bindings/usb/dwc2.txt | 4 + drivers/usb/dwc2/core.h| 46 +- drivers/usb/dwc2/gadget.c | 792 - drivers/usb/dwc2/hw.h | 1 + 4 files changed, 556 insertions(+), 287 deletions(-) -- 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
Re: [PATCH 2/2 resend v2] USB: host: Introduce flag to enable use of 64-bit dma_mask for ehci-platform
On Tue, Jan 06, 2015 at 01:50:15PM +0100, Andreas Herrmann wrote: ehci-octeon driver used a 64-bit dma_mask. With removal of ehci-octeon and usage of ehci-platform ehci dma_mask is now limited to 32 bits (coerced in ehci_platform_probe). Provide a flag in ehci platform data to allow use of 64 bits for dma_mask. Cc: David Daney david.da...@cavium.com Cc: Alex Smith alex.sm...@imgtec.com Signed-off-by: Andreas Herrmann andreas.herrm...@caviumnetworks.com Tested-by: Aaro Koskinen aaro.koski...@iki.fi Acked-by: Alan Stern st...@rowland.harvard.edu --- arch/mips/cavium-octeon/octeon-platform.c |4 +--- drivers/usb/host/ehci-platform.c |3 ++- include/linux/usb/ehci_pdriver.h |1 + 3 files changed, 4 insertions(+), 4 deletions(-) This no longer applies to my usb-testing branch, can you refresh it and resend? thanks, greg k-h -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] usb/kaweth: use GFP_ATOMIC under spin_lock in usb_start_wait_urb()
Commit e4c7f259c5be (USB: kaweth.c: use GFP_ATOMIC under spin_lock) makes sure that kaweth_internal_control_msg() allocates memory with GFP_ATOMIC, but kaweth_internal_control_msg() also calls usb_start_wait_urb() that still allocates memory with GFP_NOIO. The patch fixes usb_start_wait_urb() as well. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov khoroshi...@ispras.ru --- drivers/net/usb/kaweth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c index dcb6d33141e0..1e9cdca37014 100644 --- a/drivers/net/usb/kaweth.c +++ b/drivers/net/usb/kaweth.c @@ -1276,7 +1276,7 @@ static int usb_start_wait_urb(struct urb *urb, int timeout, int* actual_length) awd.done = 0; urb-context = awd; -status = usb_submit_urb(urb, GFP_NOIO); +status = usb_submit_urb(urb, GFP_ATOMIC); if (status) { // something went wrong usb_free_urb(urb); -- 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
Re: Difference between run time and normal suspend
On Fri, 2015-01-09 at 13:32 +0800, Peter Chen wrote: Two reasons together cause this problem - Special mouse which will disconnect (pulldown dm) if there is no host IN token within limited time (60s has observed at one microsoft mouse) - The rootfs has not opened mouse, it causes the host does not send IN token to mouse, if rootfs has opened mouse (eg, some gnome application or using 'evtest' to open mouse ), it will send IN token every 8ms. This bug in some devices is known. There is a quirk flag for it. HID_QUIRK_ALWAYS_POLL should be set for those devices. Do all devices of those vendors show the problem? 2. For USB keyboard issue usbhid-ledcount has some problems, need to set ignoreled=1 to let auto-suspend work Do the LEDs go out when they shouldn't? 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: Difference between run time and normal suspend
On Fri, 2015-01-09 at 13:32 +0800, Peter Chen wrote: Two reasons together cause this problem - Special mouse which will disconnect (pulldown dm) if there is no host IN token within limited time (60s has observed at one microsoft mouse) - The rootfs has not opened mouse, it causes the host does not send IN token to mouse, if rootfs has opened mouse (eg, some gnome application or using 'evtest' to open mouse ), it will send IN token every 8ms. This bug in some devices is known. There is a quirk flag for it. HID_QUIRK_ALWAYS_POLL should be set for those devices. Do all devices of those vendors show the problem? All Microsoft mouse I meet have this problem. 2. For USB keyboard issue usbhid-ledcount has some problems, need to set ignoreled=1 to let auto-suspend work Do the LEDs go out when they shouldn't? What's your mean? Peter N�r��yb�X��ǧv�^�){.n�+{��^n�r���z���h����G���h�(�階�ݢj���m��z�ޖ���f���h���~�m�
[PATCH 0/6] xhci features for usb-next
Hi Greg These xhci patches for usb-next are all minor cleanups, debug fixes etc. -Mathias Julia Lawall (2): xhci: Use setup_timer xhci-mem: Use setup_timer Lin Wang (3): xhci: Clean up work to xhci_add_endpoint(). xhci: remove unused parameter 'xhci' in function xhci_handshake(). xhci: clean up work to remove unused parameters for functions in xhci-mem.c Mathias Nyman (1): xhci: Add completion code to the debug ouput of unhandled transfer events drivers/usb/host/xhci-dbg.c | 2 +- drivers/usb/host/xhci-mem.c | 31 +--- drivers/usb/host/xhci-ring.c | 12 drivers/usb/host/xhci.c | 68 drivers/usb/host/xhci.h | 10 +++ 5 files changed, 55 insertions(+), 68 deletions(-) -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/6] xhci: remove unused parameter 'xhci' in function xhci_handshake().
From: Lin Wang lin.x.w...@intel.com Parameter 'xhci' is no longer be used in function xhci_handshake(), just remove it. Signed-off-by: Lin Wang lin.x.w...@intel.com Signed-off-by: Mathias Nyman mathias.ny...@linux.intel.com --- drivers/usb/host/xhci-ring.c | 2 +- drivers/usb/host/xhci.c | 19 +-- drivers/usb/host/xhci.h | 3 +-- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index e692e76..c84a959 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -299,7 +299,7 @@ static int xhci_abort_cmd_ring(struct xhci_hcd *xhci) * seconds), then it should assume that the there are * larger problems with the xHC and assert HCRST. */ - ret = xhci_handshake(xhci, xhci-op_regs-cmd_ring, + ret = xhci_handshake(xhci-op_regs-cmd_ring, CMD_RING_RUNNING, 0, 5 * 1000 * 1000); if (ret 0) { xhci_err(xhci, Stopped the command ring failed, diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 93200db..5ec74e2 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -60,8 +60,7 @@ MODULE_PARM_DESC(quirks, Bit flags for quirks to be enabled as default); * handshake done). There are two failure modes: usec have passed (major * hardware flakeout), or the register reads as all-ones (hardware removed). */ -int xhci_handshake(struct xhci_hcd *xhci, void __iomem *ptr, - u32 mask, u32 done, int usec) +int xhci_handshake(void __iomem *ptr, u32 mask, u32 done, int usec) { u32 result; @@ -111,7 +110,7 @@ int xhci_halt(struct xhci_hcd *xhci) xhci_dbg_trace(xhci, trace_xhci_dbg_init, // Halt the HC); xhci_quiesce(xhci); - ret = xhci_handshake(xhci, xhci-op_regs-status, + ret = xhci_handshake(xhci-op_regs-status, STS_HALT, STS_HALT, XHCI_MAX_HALT_USEC); if (!ret) { xhci-xhc_state |= XHCI_STATE_HALTED; @@ -140,7 +139,7 @@ static int xhci_start(struct xhci_hcd *xhci) * Wait for the HCHalted Status bit to be 0 to indicate the host is * running. */ - ret = xhci_handshake(xhci, xhci-op_regs-status, + ret = xhci_handshake(xhci-op_regs-status, STS_HALT, 0, XHCI_MAX_HALT_USEC); if (ret == -ETIMEDOUT) xhci_err(xhci, Host took too long to start, @@ -175,7 +174,7 @@ int xhci_reset(struct xhci_hcd *xhci) command |= CMD_RESET; writel(command, xhci-op_regs-command); - ret = xhci_handshake(xhci, xhci-op_regs-command, + ret = xhci_handshake(xhci-op_regs-command, CMD_RESET, 0, 10 * 1000 * 1000); if (ret) return ret; @@ -186,7 +185,7 @@ int xhci_reset(struct xhci_hcd *xhci) * xHCI cannot write to any doorbells or operational registers other * than status until the Controller Not Ready flag is cleared. */ - ret = xhci_handshake(xhci, xhci-op_regs-status, + ret = xhci_handshake(xhci-op_regs-status, STS_CNR, 0, 10 * 1000 * 1000); for (i = 0; i 2; ++i) { @@ -929,7 +928,7 @@ int xhci_suspend(struct xhci_hcd *xhci, bool do_wakeup) /* Some chips from Fresco Logic need an extraordinary delay */ delay *= (xhci-quirks XHCI_SLOW_SUSPEND) ? 10 : 1; - if (xhci_handshake(xhci, xhci-op_regs-status, + if (xhci_handshake(xhci-op_regs-status, STS_HALT, STS_HALT, delay)) { xhci_warn(xhci, WARN: xHC CMD_RUN timeout\n); spin_unlock_irq(xhci-lock); @@ -944,7 +943,7 @@ int xhci_suspend(struct xhci_hcd *xhci, bool do_wakeup) command = readl(xhci-op_regs-command); command |= CMD_CSS; writel(command, xhci-op_regs-command); - if (xhci_handshake(xhci, xhci-op_regs-status, + if (xhci_handshake(xhci-op_regs-status, STS_SAVE, 0, 10 * 1000)) { xhci_warn(xhci, WARN: xHC save state timeout\n); spin_unlock_irq(xhci-lock); @@ -1011,7 +1010,7 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated) command = readl(xhci-op_regs-command); command |= CMD_CRS; writel(command, xhci-op_regs-command); - if (xhci_handshake(xhci, xhci-op_regs-status, + if (xhci_handshake(xhci-op_regs-status, STS_RESTORE, 0, 10 * 1000)) { xhci_warn(xhci, WARN: xHC restore state timeout\n); spin_unlock_irq(xhci-lock); @@ -1082,7 +1081,7 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated) command = readl(xhci-op_regs-command); command |= CMD_RUN; writel(command, xhci-op_regs-command); - xhci_handshake(xhci, xhci-op_regs-status, STS_HALT, +
[PATCH 3/6] xhci: Use setup_timer
From: Julia Lawall julia.law...@lip6.fr Convert a call to init_timer and accompanying intializations of the timer's data and function fields to a call to setup_timer. A simplified version of the semantic match that fixes this problem is as follows: (http://coccinelle.lip6.fr/) // smpl @@ expression t,f,d; @@ -init_timer(t); +setup_timer(t,f,d); -t.data = d; -t.function = f; // /smpl Signed-off-by: Julia Lawall julia.law...@lip6.fr Signed-off-by: Mathias Nyman mathias.ny...@linux.intel.com --- drivers/usb/host/xhci.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 5ec74e2..1e3f39c 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -472,10 +472,8 @@ static void compliance_mode_recovery(unsigned long arg) static void compliance_mode_recovery_timer_init(struct xhci_hcd *xhci) { xhci-port_status_u0 = 0; - init_timer(xhci-comp_mode_recovery_timer); - - xhci-comp_mode_recovery_timer.data = (unsigned long) xhci; - xhci-comp_mode_recovery_timer.function = compliance_mode_recovery; + setup_timer(xhci-comp_mode_recovery_timer, + compliance_mode_recovery, (unsigned long)xhci); xhci-comp_mode_recovery_timer.expires = jiffies + msecs_to_jiffies(COMP_MODE_RCVRY_MSECS); -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 4/6] xhci-mem: Use setup_timer
From: Julia Lawall julia.law...@lip6.fr Convert a call to init_timer and accompanying intializations of the timer's data and function fields to a call to setup_timer. A simplified version of the semantic match that fixes this problem is as follows: (http://coccinelle.lip6.fr/) // smpl @@ expression t,f,d; @@ -init_timer(t); +setup_timer(t,f,d); -t.data = d; -t.function = f; // /smpl Signed-off-by: Julia Lawall julia.law...@lip6.fr Signed-off-by: Mathias Nyman mathias.ny...@linux.intel.com --- drivers/usb/host/xhci-mem.c | 10 -- 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 5cb3d7a..e72265c 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -833,9 +833,8 @@ void xhci_free_stream_info(struct xhci_hcd *xhci, static void xhci_init_endpoint_timer(struct xhci_hcd *xhci, struct xhci_virt_ep *ep) { - init_timer(ep-stop_cmd_timer); - ep-stop_cmd_timer.data = (unsigned long) ep; - ep-stop_cmd_timer.function = xhci_stop_endpoint_command_watchdog; + setup_timer(ep-stop_cmd_timer, xhci_stop_endpoint_command_watchdog, + (unsigned long)ep); ep-xhci = xhci; } @@ -2509,9 +2508,8 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) xhci_print_ir_set(xhci, 0); /* init command timeout timer */ - init_timer(xhci-cmd_timer); - xhci-cmd_timer.data = (unsigned long) xhci; - xhci-cmd_timer.function = xhci_handle_command_timeout; + setup_timer(xhci-cmd_timer, xhci_handle_command_timeout, + (unsigned long)xhci); /* * XXX: Might need to set the Interrupter Moderation Register to -- 1.8.3.2 -- 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 6/6] xhci: Add completion code to the debug ouput of unhandled transfer events
Helps debugging to know the unhandled event type. Also make the debug message grepable Signed-off-by: Mathias Nyman mathias.ny...@linux.intel.com --- drivers/usb/host/xhci-ring.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 067f18a..88da8d6 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -2354,8 +2354,8 @@ static int handle_tx_event(struct xhci_hcd *xhci, status = 0; break; } - xhci_warn(xhci, ERROR Unknown event condition, HC probably - busted\n); + xhci_warn(xhci, ERROR Unknown event condition %u, HC probably busted\n, + trb_comp_code); goto cleanup; } -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 5/6] xhci: clean up work to remove unused parameters for functions in xhci-mem.c
From: Lin Wang lin.x.w...@intel.com Some parameters are not used by functions in xhci-mem.c, just remove it. Changes compared to v1: - Rebase to the latest usb-next branch Signed-off-by: Lin Wang lin.x.w...@intel.com Signed-off-by: Mathias Nyman mathias.ny...@linux.intel.com --- drivers/usb/host/xhci-dbg.c | 2 +- drivers/usb/host/xhci-mem.c | 21 + drivers/usb/host/xhci-ring.c | 6 +++--- drivers/usb/host/xhci.c | 34 +- drivers/usb/host/xhci.h | 7 +++ 5 files changed, 33 insertions(+), 37 deletions(-) diff --git a/drivers/usb/host/xhci-dbg.c b/drivers/usb/host/xhci-dbg.c index bb89175..745717e 100644 --- a/drivers/usb/host/xhci-dbg.c +++ b/drivers/usb/host/xhci-dbg.c @@ -552,7 +552,7 @@ void xhci_dbg_ctx(struct xhci_hcd *xhci, if (ctx-type == XHCI_CTX_TYPE_INPUT) { struct xhci_input_control_ctx *ctrl_ctx = - xhci_get_input_control_ctx(xhci, ctx); + xhci_get_input_control_ctx(ctx); if (!ctrl_ctx) { xhci_warn(xhci, Could not get input context, bad type.\n); return; diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index e72265c..f833640 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -535,7 +535,7 @@ static void xhci_free_container_ctx(struct xhci_hcd *xhci, kfree(ctx); } -struct xhci_input_control_ctx *xhci_get_input_control_ctx(struct xhci_hcd *xhci, +struct xhci_input_control_ctx *xhci_get_input_control_ctx( struct xhci_container_ctx *ctx) { if (ctx-type != XHCI_CTX_TYPE_INPUT) @@ -784,8 +784,7 @@ void xhci_setup_streams_ep_input_ctx(struct xhci_hcd *xhci, * Reinstalls the normal endpoint ring (at its previous dequeue mark, * not at the beginning of the ring). */ -void xhci_setup_no_streams_ep_input_ctx(struct xhci_hcd *xhci, - struct xhci_ep_ctx *ep_ctx, +void xhci_setup_no_streams_ep_input_ctx(struct xhci_ep_ctx *ep_ctx, struct xhci_virt_ep *ep) { dma_addr_t addr; @@ -1341,8 +1340,7 @@ static u32 xhci_get_endpoint_mult(struct usb_device *udev, return ep-ss_ep_comp.bmAttributes; } -static u32 xhci_get_endpoint_type(struct usb_device *udev, - struct usb_host_endpoint *ep) +static u32 xhci_get_endpoint_type(struct usb_host_endpoint *ep) { int in; u32 type; @@ -1375,8 +1373,7 @@ static u32 xhci_get_endpoint_type(struct usb_device *udev, * Basically, this is the maxpacket size, multiplied by the burst size * and mult size. */ -static u32 xhci_get_max_esit_payload(struct xhci_hcd *xhci, - struct usb_device *udev, +static u32 xhci_get_max_esit_payload(struct usb_device *udev, struct usb_host_endpoint *ep) { int max_burst; @@ -1417,7 +1414,7 @@ int xhci_endpoint_init(struct xhci_hcd *xhci, ep_index = xhci_get_endpoint_index(ep-desc); ep_ctx = xhci_get_ep_ctx(xhci, virt_dev-in_ctx, ep_index); - endpoint_type = xhci_get_endpoint_type(udev, ep); + endpoint_type = xhci_get_endpoint_type(ep); if (!endpoint_type) return -EINVAL; ep_ctx-ep_info2 = cpu_to_le32(endpoint_type); @@ -1483,7 +1480,7 @@ int xhci_endpoint_init(struct xhci_hcd *xhci, } ep_ctx-ep_info2 |= cpu_to_le32(MAX_PACKET(max_packet) | MAX_BURST(max_burst)); - max_esit_payload = xhci_get_max_esit_payload(xhci, udev, ep); + max_esit_payload = xhci_get_max_esit_payload(udev, ep); ep_ctx-tx_info = cpu_to_le32(MAX_ESIT_PAYLOAD_FOR_EP(max_esit_payload)); /* @@ -1772,7 +1769,7 @@ struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci, return command; } -void xhci_urb_free_priv(struct xhci_hcd *xhci, struct urb_priv *urb_priv) +void xhci_urb_free_priv(struct urb_priv *urb_priv) { if (urb_priv) { kfree(urb_priv-td[0]); @@ -1925,7 +1922,7 @@ static int xhci_test_trb_in_td(struct xhci_hcd *xhci, } /* TRB math checks for xhci_trb_in_td(), using the command and event rings. */ -static int xhci_check_trb_in_td_math(struct xhci_hcd *xhci, gfp_t mem_flags) +static int xhci_check_trb_in_td_math(struct xhci_hcd *xhci) { struct { dma_addr_t input_dma; @@ -2451,7 +2448,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) flags); if (!xhci-event_ring) goto fail; - if (xhci_check_trb_in_td_math(xhci, flags) 0) + if (xhci_check_trb_in_td_math(xhci) 0) goto fail; xhci-erst.entries = dma_alloc_coherent(dev, diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index c84a959..067f18a 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -609,7
[PATCH 1/6] xhci: Clean up work to xhci_add_endpoint().
From: Lin Wang lin.x.w...@intel.com This patch removes unused variable out_ctx and avoid multiple calls to function xhci_get_endpoint_flag(). Signed-off-by: Lin Wang lin.x.w...@intel.com Signed-off-by: Mathias Nyman mathias.ny...@linux.intel.com --- drivers/usb/host/xhci.c | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 01fcbb5..93200db 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -1714,7 +1714,7 @@ int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev, struct usb_host_endpoint *ep) { struct xhci_hcd *xhci; - struct xhci_container_ctx *in_ctx, *out_ctx; + struct xhci_container_ctx *in_ctx; unsigned int ep_index; struct xhci_input_control_ctx *ctrl_ctx; u32 added_ctxs; @@ -1745,7 +1745,6 @@ int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev, virt_dev = xhci-devs[udev-slot_id]; in_ctx = virt_dev-in_ctx; - out_ctx = virt_dev-out_ctx; ctrl_ctx = xhci_get_input_control_ctx(xhci, in_ctx); if (!ctrl_ctx) { xhci_warn(xhci, %s: Could not get input context, bad type.\n, @@ -1758,8 +1757,7 @@ int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev, * to add it again without dropping it, reject the addition. */ if (virt_dev-eps[ep_index].ring - !(le32_to_cpu(ctrl_ctx-drop_flags) - xhci_get_endpoint_flag(ep-desc))) { + !(le32_to_cpu(ctrl_ctx-drop_flags) added_ctxs)) { xhci_warn(xhci, Trying to add endpoint 0x%x without dropping it.\n, (unsigned int) ep-desc.bEndpointAddress); @@ -1769,8 +1767,7 @@ int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev, /* If the HCD has already noted the endpoint is enabled, * ignore this request. */ - if (le32_to_cpu(ctrl_ctx-add_flags) - xhci_get_endpoint_flag(ep-desc)) { + if (le32_to_cpu(ctrl_ctx-add_flags) added_ctxs) { xhci_warn(xhci, xHCI %s called with enabled ep %p\n, __func__, ep); return 0; -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
re: USB gadget: video class function driver
Hello Laurent Pinchart, The patch cdda479f15cd: USB gadget: video class function driver from May 2, 2010, leads to the following static checker warning: drivers/usb/gadget/function/f_uvc.c:223 uvc_function_ep0_complete() error: overflow detected. memcpy() 'uvc_event-data.data' is 60 bytes. user controlled range = '0-64' drivers/usb/gadget/function/f_uvc.c 210 static void 211 uvc_function_ep0_complete(struct usb_ep *ep, struct usb_request *req) 212 { 213 struct uvc_device *uvc = req-context; 214 struct v4l2_event v4l2_event; 215 struct uvc_event *uvc_event = (void *)v4l2_event.u.data; 216 217 if (uvc-event_setup_out) { 218 uvc-event_setup_out = 0; 219 220 memset(v4l2_event, 0, sizeof(v4l2_event)); 221 v4l2_event.type = UVC_EVENT_DATA; 222 uvc_event-data.length = req-actual; 223 memcpy(uvc_event-data.data, req-buf, req-actual); It doesn't know the real limit of req-actual, but it's saying that there is a untrusted source which can pick a value between 0-64. 224 v4l2_event_queue(uvc-vdev, v4l2_event); 225 } 226 } The untrusted source is in dummy_queue(). drivers/usb/gadget/udc/dummy_hcd.c 648 /* implement an emulated single-request FIFO */ 649 if (ep-desc (ep-desc-bEndpointAddress USB_DIR_IN) 650 list_empty(dum-fifo_req.queue) 651 list_empty(ep-queue) 652 _req-length = FIFO_SIZE) { ^^ _req-length is untrusted for some reason. This caps it at 0-64. 653 req = dum-fifo_req; 654 req-req = *_req; 655 req-req.buf = dum-fifo_buf; 656 memcpy(dum-fifo_buf, _req-buf, _req-length); 657 req-req.context = dum; 658 req-req.complete = fifo_complete; 659 660 list_add_tail(req-queue, ep-queue); 661 spin_unlock(dum-lock); 662 _req-actual = _req-length; ^^^ Assigned to _req-actual. 663 _req-status = 0; 664 usb_gadget_giveback_request(_ep, _req); ^^ And down this call tree. 665 spin_lock(dum-lock); There is another similar issue: drivers/usb/gadget/function/f_uac1.c:367 f_audio_complete() error: overflow detected. memcpy() 'data' is 4 bytes. user controlled range = '0-64' TODO-List: USB: gadget: potential overflow in uvc_function_ep0_complete(). regards, dan carpenter -- 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 v3 14/30] usb: dwc2: gadget: remove unused members from hsotg_req
These members are only occupying space. Signed-off-by: Mian Yousaf Kaukab yousaf.kau...@intel.com --- drivers/usb/dwc2/core.h | 4 1 file changed, 4 deletions(-) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index df6a64f..db5348c 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -158,14 +158,10 @@ struct s3c_hsotg_ep { * struct s3c_hsotg_req - data transfer request * @req: The USB gadget request * @queue: The list of requests for the endpoint this is queued for. - * @in_progress: Has already had size/packets written to core - * @mapped: DMA buffer for this request has been mapped via dma_map_single(). */ struct s3c_hsotg_req { struct usb_request req; struct list_headqueue; - unsigned char in_progress; - unsigned char mapped; }; #if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE) -- 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 v3 20/30] usb: dwc2: gadget: dont warn if endpoint is not enabled
The warning is probably good but it has false positives in both dma and non-dma cases. So its not very helpful in either. Signed-off-by: Mian Yousaf Kaukab yousaf.kau...@intel.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 992a2eb..6d76e28 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -678,7 +678,7 @@ static void s3c_hsotg_start_req(struct dwc2_hsotg *hsotg, /* check ep is enabled */ if (!(readl(hsotg-regs + epctrl_reg) DXEPCTL_EPENA)) - dev_warn(hsotg-dev, + dev_dbg(hsotg-dev, ep%d: failed to become enabled (DXEPCTL=0x%08x)?\n, index, readl(hsotg-regs + epctrl_reg)); -- 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 v3 17/30] usb: dwc2: gadget: kill requests after disabling ep
kill_all_requests() can flush the fifo. Call it after disabling the endpoint. Signed-off-by: Mian Yousaf Kaukab yousaf.kau...@intel.com --- drivers/usb/dwc2/gadget.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index cd8880d..3dda17e 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -2605,8 +2605,6 @@ static int s3c_hsotg_ep_disable(struct usb_ep *ep) epctrl_reg = dir_in ? DIEPCTL(index) : DOEPCTL(index); spin_lock_irqsave(hsotg-lock, flags); - /* terminate all requests with shutdown */ - kill_all_requests(hsotg, hs_ep, -ESHUTDOWN); hsotg-fifo_map = ~(1hs_ep-fifo_index); hs_ep-fifo_index = 0; @@ -2623,6 +2621,9 @@ static int s3c_hsotg_ep_disable(struct usb_ep *ep) /* disable endpoint interrupts */ s3c_hsotg_ctrl_epint(hsotg, hs_ep-index, hs_ep-dir_in, 0); + /* terminate all requests with shutdown */ + kill_all_requests(hsotg, hs_ep, -ESHUTDOWN); + spin_unlock_irqrestore(hsotg-lock, flags); 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 v3 18/30] usb: dwc2: gadget: manage ep0 state in software
Manage ep0 state in software to add handling of status OUT stage. Just toggling hsotg-setup in s3c_hsotg_handle_outdone leaves it in wrong state in 2-stage control transfers. Moreover, ensure that for setup-packet s3c_hsotg_handle_outdone is called either from SetupDone or OutDone but not both. Dwc2 ip v3.00a generates both SetupDone and OutDone on setup packets. Signed-off-by: Mian Yousaf Kaukab yousaf.kau...@intel.com --- drivers/usb/dwc2/core.h | 13 +++- drivers/usb/dwc2/gadget.c | 156 +++--- 2 files changed, 89 insertions(+), 80 deletions(-) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index db5348c..e963aef 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -196,6 +196,15 @@ enum dwc2_lx_state { #define DWC2_G_P_LEGACY_TX_FIFO_SIZE {256, 256, 256, 256, 768, 768, 768, \ 768, 0, 0, 0, 0, 0, 0, 0} +/* Gadget ep0 states */ +enum dwc2_ep0_state { + DWC2_EP0_SETUP, + DWC2_EP0_DATA_IN, + DWC2_EP0_DATA_OUT, + DWC2_EP0_STATUS_IN, + DWC2_EP0_STATUS_OUT, +}; + /** * struct dwc2_core_params - Parameters for configuring the core * @@ -563,7 +572,7 @@ struct dwc2_hw_params { * @ep0_buff: Buffer for EP0 reply data, if needed. * @ctrl_buff: Buffer for EP0 control requests. * @ctrl_req: Request for EP0 control packets. - * @setup: NAK management for EP0 SETUP + * @ep0_state: EP0 control transfers state * @last_rst: Time of last reset * @eps:The endpoints being supplied to the gadget framework * @g_using_dma: Indicate if dma usage is enabled @@ -696,11 +705,11 @@ struct dwc2_hsotg { struct usb_request *ctrl_req; void *ep0_buff; void *ctrl_buff; + enum dwc2_ep0_state ep0_state; struct usb_gadget gadget; unsigned int enabled:1; unsigned int connected:1; - unsigned int setup:1; unsigned long last_rst; struct s3c_hsotg_ep *eps_in[MAX_EPS_CHANNELS]; struct s3c_hsotg_ep *eps_out[MAX_EPS_CHANNELS]; diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 3dda17e..c3977a8 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -638,15 +638,12 @@ static void s3c_hsotg_start_req(struct dwc2_hsotg *hsotg, ctrl |= DXEPCTL_EPENA; /* ensure ep enabled */ ctrl |= DXEPCTL_USBACTEP; - dev_dbg(hsotg-dev, setup req:%d\n, hsotg-setup); + dev_dbg(hsotg-dev, ep0 state:%d\n, hsotg-ep0_state); /* For Setup request do not clear NAK */ - if (hsotg-setup index == 0) - hsotg-setup = 0; - else + if (!(index == 0 hsotg-ep0_state == DWC2_EP0_SETUP)) ctrl |= DXEPCTL_CNAK; /* clear NAK set by core */ - dev_dbg(hsotg-dev, %s: DxEPCTL=0x%08x\n, __func__, ctrl); writel(ctrl, hsotg-regs + epctrl_reg); @@ -865,8 +862,6 @@ static int s3c_hsotg_send_reply(struct dwc2_hsotg *hsotg, if (length) memcpy(req-buf, buff, length); - else - ep-sent_zlp = 1; ret = s3c_hsotg_ep_queue(ep-ep, req, GFP_ATOMIC); if (ret) { @@ -1080,26 +1075,20 @@ static void s3c_hsotg_process_control(struct dwc2_hsotg *hsotg, int ret = 0; u32 dcfg; - ep0-sent_zlp = 0; - dev_dbg(hsotg-dev, ctrl Req=%02x, Type=%02x, V=%04x, L=%04x\n, ctrl-bRequest, ctrl-bRequestType, ctrl-wValue, ctrl-wLength); - /* -* record the direction of the request, for later use when enquing -* packets onto EP0. -*/ - - ep0-dir_in = (ctrl-bRequestType USB_DIR_IN) ? 1 : 0; - dev_dbg(hsotg-dev, ctrl: dir_in=%d\n, ep0-dir_in); - - /* -* if we've no data with this request, then the last part of the -* transaction is going to implicitly be IN. -*/ - if (ctrl-wLength == 0) + if (ctrl-wLength == 0) { + ep0-dir_in = 1; + hsotg-ep0_state = DWC2_EP0_STATUS_IN; + } else if (ctrl-bRequestType USB_DIR_IN) { ep0-dir_in = 1; + hsotg-ep0_state = DWC2_EP0_DATA_IN; + } else { + ep0-dir_in = 0; + hsotg-ep0_state = DWC2_EP0_DATA_OUT; + } if ((ctrl-bRequestType USB_TYPE_MASK) == USB_TYPE_STANDARD) { switch (ctrl-bRequest) { @@ -1198,6 +1187,8 @@ static void s3c_hsotg_enqueue_setup(struct dwc2_hsotg *hsotg) } hsotg-eps_out[0]-dir_in = 0; + hsotg-eps_out[0]-sent_zlp = 0; + hsotg-ep0_state = DWC2_EP0_SETUP; ret = s3c_hsotg_ep_queue(hsotg-eps_out[0]-ep, req, GFP_ATOMIC); if (ret 0) { @@ -1209,6 +1200,27 @@ static void s3c_hsotg_enqueue_setup(struct dwc2_hsotg *hsotg) } } +static void s3c_hsotg_program_zlp(struct dwc2_hsotg *hsotg, +
[PATCH v3 24/30] usb: dwc2: gadget: pick smallest acceptable fifo
Current algorithm picks the first fifo which is equal to or greater than the required size. This can result in bigger fifos assigned to endpoints with smaller maxps. Change the algorithm to pick the smallest fifo which is greater than or equal to the required size. Moreover, only use signed variables when required. Signed-off-by: Mian Yousaf Kaukab yousaf.kau...@intel.com --- drivers/usb/dwc2/gadget.c | 25 +++-- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 5fdc3f5..54e6d15 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -2439,12 +2439,12 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep, struct s3c_hsotg_ep *hs_ep = our_ep(ep); struct dwc2_hsotg *hsotg = hs_ep-parent; unsigned long flags; - int index = hs_ep-index; + unsigned int index = hs_ep-index; u32 epctrl_reg; u32 epctrl; u32 mps; - int dir_in; - int i, val, size; + unsigned int dir_in; + unsigned int i, val, size; int ret = 0; dev_dbg(hsotg-dev, @@ -2533,6 +2533,8 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep, * a unique tx-fifo even if it is non-periodic. */ if (dir_in hsotg-dedicated_fifos) { + u32 fifo_index = 0; + u32 fifo_size = UINT_MAX; size = hs_ep-ep.maxpacket*hs_ep-mc; for (i = 1; i hsotg-num_of_eps; ++i) { if (hsotg-fifo_map (1i)) @@ -2541,19 +2543,22 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep, val = (val FIFOSIZE_DEPTH_SHIFT)*4; if (val size) continue; - hsotg-fifo_map |= 1i; - - epctrl |= DXEPCTL_TXFNUM(i); - hs_ep-fifo_index = i; - hs_ep-fifo_size = val; - break; + /* Search for smallest acceptable fifo */ + if (val fifo_size) { + fifo_size = val; + fifo_index = i; + } } - if (i == hsotg-num_of_eps) { + if (!fifo_index) { dev_err(hsotg-dev, %s: No suitable fifo found\n, __func__); ret = -ENOMEM; goto error; } + hsotg-fifo_map |= 1 fifo_index; + epctrl |= DXEPCTL_TXFNUM(fifo_index); + hs_ep-fifo_index = fifo_index; + hs_ep-fifo_size = fifo_size; } /* for non control endpoints, set PID to D0 */ -- 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 v3 16/30] usb: dwc2: gadget: consider all tx fifos
When matching tx fifo to endpoint, consider all fifos instead of hard limiting to 8 Moreover, print error in case no fifo could be found. Signed-off-by: Mian Yousaf Kaukab yousaf.kau...@intel.com --- drivers/usb/dwc2/gadget.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 7dfda95..cd8880d 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -2540,7 +2540,7 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep, */ if (dir_in hsotg-dedicated_fifos) { size = hs_ep-ep.maxpacket*hs_ep-mc; - for (i = 1; i = 8; ++i) { + for (i = 1; i hsotg-num_of_eps; ++i) { if (hsotg-fifo_map (1i)) continue; val = readl(hsotg-regs + DPTXFSIZN(i)); @@ -2554,7 +2554,9 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep, hs_ep-fifo_size = val; break; } - if (i == 8) { + if (i == hsotg-num_of_eps) { + dev_err(hsotg-dev, + %s: No suitable fifo found\n, __func__); ret = -ENOMEM; goto error; } -- 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 v3 30/30] usb: dwc2: gadget: report disconnection after reset
If usb bus is reset without a physical disconnection, all endpoints will remain open. Call s3c_hsotg_disconnect() from reset handler to report a disconnect to gadget framework. hsotg-connected is checked in s3c_hsotg_disconnect() before processing disconnect. In some cases, USBRst is seen before EnumDone and after it as well. So move setting of hsotg-connected to set-address to avoid reporting extra disconnection in this case. Signed-off-by: Mian Yousaf Kaukab yousaf.kau...@intel.com --- drivers/usb/dwc2/gadget.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index df9080d..882a1a8 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -1103,6 +1103,7 @@ static void s3c_hsotg_process_control(struct dwc2_hsotg *hsotg, if ((ctrl-bRequestType USB_TYPE_MASK) == USB_TYPE_STANDARD) { switch (ctrl-bRequest) { case USB_REQ_SET_ADDRESS: + hsotg-connected = 1; dcfg = readl(hsotg-regs + DCFG); dcfg = ~DCFG_DEVADDR_MASK; dcfg |= (le16_to_cpu(ctrl-wValue) @@ -2305,7 +2306,6 @@ irq_retry: writel(GINTSTS_ENUMDONE, hsotg-regs + GINTSTS); s3c_hsotg_irq_enumdone(hsotg); - hsotg-connected = 1; } if (gintsts (GINTSTS_OEPINT | GINTSTS_IEPINT)) { @@ -2343,6 +2343,9 @@ irq_retry: writel(GINTSTS_USBRST, hsotg-regs + GINTSTS); + /* Report disconnection if it is not already done. */ + s3c_hsotg_disconnect(hsotg); + if (usb_status GOTGCTL_BSESVLD) { if (time_after(jiffies, hsotg-last_rst + msecs_to_jiffies(200))) { -- 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 v3 19/30] usb: dwc2: gadget: fix zero length packet transfers
According to programming guide, zero length packet should be programmed on its own and should not be counted in DIEPTSIZ.PktCnt with other packets. For ep0, this is the zlp for DATA IN stage (if required) and not for the STATUS stage. Signed-off-by: Gregory Herrero gregory.herr...@intel.com Signed-off-by: Mian Yousaf Kaukab yousaf.kau...@intel.com --- drivers/usb/dwc2/gadget.c | 51 --- 1 file changed, 22 insertions(+), 29 deletions(-) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index c3977a8..992a2eb 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -598,14 +598,15 @@ static void s3c_hsotg_start_req(struct dwc2_hsotg *hsotg, else epsize = 0; - if (index != 0 ureq-zero) { - /* -* test for the packets being exactly right for the -* transfer -*/ - - if (length == (packets * hs_ep-ep.maxpacket)) - packets++; + /* +* zero length packet should be programmed on its own and should not +* be counted in DIEPTSIZ.PktCnt with other packets. +*/ + if (dir_in ureq-zero !continuing) { + /* Test if zlp is actually required. */ + if ((ureq-length = hs_ep-ep.maxpacket) + !(ureq-length % hs_ep-ep.maxpacket)) + hs_ep-sent_zlp = 1; } epsize |= DXEPTSIZ_PKTCNT(packets); @@ -857,7 +858,11 @@ static int s3c_hsotg_send_reply(struct dwc2_hsotg *hsotg, req-buf = hsotg-ep0_buff; req-length = length; - req-zero = 1; /* always do zero-length final transfer */ + /* +* zero flag is for sending zlp in DATA IN stage. It has no impact on +* STATUS stage. +*/ + req-zero = 0; req-complete = s3c_hsotg_complete_oursetup; if (length) @@ -1744,32 +1749,20 @@ static void s3c_hsotg_complete_in(struct dwc2_hsotg *hsotg, dev_dbg(hsotg-dev, req-length:%d req-actual:%d req-zero:%d\n, hs_req-req.length, hs_req-req.actual, hs_req-req.zero); - /* -* Check if dealing with Maximum Packet Size(MPS) IN transfer at EP0 -* When sent data is a multiple MPS size (e.g. 64B ,128B ,192B -* ,256B ... ), after last MPS sized packet send IN ZLP packet to -* inform the host that no more data is available. -* The state of req.zero member is checked to be sure that the value to -* send is smaller than wValue expected from host. -* Check req.length to NOT send another ZLP when the current one is -* under completion (the one for which this completion has been called). -*/ - if (hs_req-req.length hs_ep-index == 0 hs_req-req.zero - hs_req-req.length == hs_req-req.actual - !(hs_req-req.length % hs_ep-ep.maxpacket)) { - - dev_dbg(hsotg-dev, ep0 zlp IN packet sent\n); - s3c_hsotg_program_zlp(hsotg, hs_ep); - - return; - } - if (!size_left hs_req-req.actual hs_req-req.length) { dev_dbg(hsotg-dev, %s trying more for req...\n, __func__); s3c_hsotg_start_req(hsotg, hs_ep, hs_req, true); return; } + /* Zlp for all endpoints, for ep0 only in DATA IN stage */ + if (hs_ep-sent_zlp) { + s3c_hsotg_program_zlp(hsotg, hs_ep); + hs_ep-sent_zlp = 0; + /* transfer will be completed on next complete interrupt */ + return; + } + if (hs_ep-index == 0 hsotg-ep0_state == DWC2_EP0_DATA_IN) { /* Move to STATUS OUT */ s3c_hsotg_ep0_zlp(hsotg, false); -- 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 v3 25/30] usb: dwc2: gadget: fix fifo allocation leak
When selecting different alt setting, s3c_hsotg_ep_enable can be called with fifo already allocated. Allocate fifo again only if required and after deallocating the previous fifo. Signed-off-by: Mian Yousaf Kaukab yousaf.kau...@intel.com --- drivers/usb/dwc2/gadget.c | 13 - 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 54e6d15..de5da92 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -2528,11 +2528,22 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep, break; } + /* If fifo is already allocated for this ep */ + if (hs_ep-fifo_index) { + size = hs_ep-ep.maxpacket * hs_ep-mc; + /* If bigger fifo is required deallocate current one */ + if (size hs_ep-fifo_size) { + hsotg-fifo_map = ~(1 hs_ep-fifo_index); + hs_ep-fifo_index = 0; + hs_ep-fifo_size = 0; + } + } + /* * if the hardware has dedicated fifos, we must give each IN EP * a unique tx-fifo even if it is non-periodic. */ - if (dir_in hsotg-dedicated_fifos) { + if (dir_in hsotg-dedicated_fifos !hs_ep-fifo_index) { u32 fifo_index = 0; u32 fifo_size = UINT_MAX; size = hs_ep-ep.maxpacket*hs_ep-mc; -- 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 v3 21/30] usb: dwc2: gadget: don't block after fifo flush timeout
From: Gregory Herrero gregory.herr...@intel.com Can't stay in the loop forever. Break it after timeout. Signed-off-by: Gregory Herrero gregory.herr...@intel.com --- drivers/usb/dwc2/gadget.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 6d76e28..e3bb525 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -230,6 +230,7 @@ static void s3c_hsotg_init_fifo(struct dwc2_hsotg *hsotg) dev_err(hsotg-dev, %s: timeout flushing fifos (GRSTCTL=%08x)\n, __func__, val); + break; } udelay(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 v3 22/30] usb: dwc2: gadget: add vbus_session support
From: Gregory Herrero gregory.herr...@intel.com Enable phy driver to report vbus session. This allows us to remove D+ pullup when vbus is not present. Signed-off-by: Gregory Herrero gregory.herr...@intel.com Signed-off-by: Mian Yousaf Kaukab yousaf.kau...@intel.com --- drivers/usb/dwc2/gadget.c | 24 1 file changed, 24 insertions(+) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index e3bb525..65ec0f2 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -3009,11 +3009,35 @@ static int s3c_hsotg_pullup(struct usb_gadget *gadget, int is_on) return 0; } +static int s3c_hsotg_vbus_session(struct usb_gadget *gadget, int is_active) +{ + struct dwc2_hsotg *hsotg = to_hsotg(gadget); + unsigned long flags; + + dev_dbg(hsotg-dev, %s: is_active: %d\n, __func__, is_active); + spin_lock_irqsave(hsotg-lock, flags); + + if (is_active) { + /* Kill any ep0 requests as controller will be reinitialized */ + kill_all_requests(hsotg, hsotg-eps_out[0], -ECONNRESET); + s3c_hsotg_core_init_disconnected(hsotg); + if (hsotg-enabled) + s3c_hsotg_core_connect(hsotg); + } else { + s3c_hsotg_core_disconnect(hsotg); + s3c_hsotg_disconnect(hsotg); + } + + spin_unlock_irqrestore(hsotg-lock, flags); + return 0; +} + static const struct usb_gadget_ops s3c_hsotg_gadget_ops = { .get_frame = s3c_hsotg_gadget_getframe, .udc_start = s3c_hsotg_udc_start, .udc_stop = s3c_hsotg_udc_stop, .pullup = s3c_hsotg_pullup, + .vbus_session = s3c_hsotg_vbus_session, }; /** -- 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 v3 12/30] usb: dwc2: gadget: configure fifos from device tree
From: Gregory Herrero gregory.herr...@intel.com As fifo size can vary between SOCs, add possibility to configure them from device tree. Fifo sizes used by the legacy driver will be used If they are not provided by the device tree. Signed-off-by: Gregory Herrero gregory.herr...@intel.com Signed-off-by: Mian Yousaf Kaukab yousaf.kau...@intel.com Reviewed-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/dwc2/core.h | 13 +++ drivers/usb/dwc2/gadget.c | 88 --- 2 files changed, 73 insertions(+), 28 deletions(-) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index 7a0309d..df6a64f 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -193,6 +193,13 @@ enum dwc2_lx_state { DWC2_L3,/* Off state */ }; +/* + * Gadget periodic tx fifo sizes as used by legacy driver + * EP0 is not included + */ +#define DWC2_G_P_LEGACY_TX_FIFO_SIZE {256, 256, 256, 256, 768, 768, 768, \ + 768, 0, 0, 0, 0, 0, 0, 0} + /** * struct dwc2_core_params - Parameters for configuring the core * @@ -564,6 +571,9 @@ struct dwc2_hw_params { * @last_rst: Time of last reset * @eps:The endpoints being supplied to the gadget framework * @g_using_dma: Indicate if dma usage is enabled + * @g_rx_fifo_sz: Contains rx fifo size value + * @g_np_g_tx_fifo_sz: Contains Non-Periodic tx fifo size value + * @g_tx_fifo_sz: Contains tx fifo size value per endpoints */ struct dwc2_hsotg { struct device *dev; @@ -699,6 +709,9 @@ struct dwc2_hsotg { struct s3c_hsotg_ep *eps_in[MAX_EPS_CHANNELS]; struct s3c_hsotg_ep *eps_out[MAX_EPS_CHANNELS]; u32 g_using_dma; + u32 g_rx_fifo_sz; + u32 g_np_g_tx_fifo_sz; + u32 g_tx_fifo_sz[MAX_EPS_CHANNELS]; #endif /* CONFIG_USB_DWC2_PERIPHERAL || CONFIG_USB_DWC2_DUAL_ROLE */ }; diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index b7879fd..c43ce7e 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -174,15 +174,14 @@ static void s3c_hsotg_init_fifo(struct dwc2_hsotg *hsotg) { unsigned int ep; unsigned int addr; - unsigned int size; int timeout; u32 val; - /* set FIFO sizes to 2048/1024 */ - - writel(2048, hsotg-regs + GRXFSIZ); - writel((2048 FIFOSIZE_STARTADDR_SHIFT) | - (1024 FIFOSIZE_DEPTH_SHIFT), hsotg-regs + GNPTXFSIZ); + /* set RX/NPTX FIFO sizes */ + writel(hsotg-g_rx_fifo_sz, hsotg-regs + GRXFSIZ); + writel((hsotg-g_rx_fifo_sz FIFOSIZE_STARTADDR_SHIFT) | + (hsotg-g_np_g_tx_fifo_sz FIFOSIZE_DEPTH_SHIFT), + hsotg-regs + GNPTXFSIZ); /* * arange all the rest of the TX FIFOs, as some versions of this @@ -192,35 +191,21 @@ static void s3c_hsotg_init_fifo(struct dwc2_hsotg *hsotg) */ /* start at the end of the GNPTXFSIZ, rounded up */ - addr = 2048 + 1024; + addr = hsotg-g_rx_fifo_sz + hsotg-g_np_g_tx_fifo_sz; /* -* Because we have not enough memory to have each TX FIFO of size at -* least 3072 bytes (the maximum single packet size), we create four -* FIFOs of lenght 1024, and four of length 3072 bytes, and assing +* Configure fifos sizes from provided configuration and assign * them to endpoints dynamically according to maxpacket size value of * given endpoint. */ - - /* 256*4=1024 bytes FIFO length */ - size = 256; - for (ep = 1; ep = 4; ep++) { - val = addr; - val |= size FIFOSIZE_DEPTH_SHIFT; - WARN_ONCE(addr + size hsotg-fifo_mem, - insufficient fifo memory); - addr += size; - - writel(val, hsotg-regs + DPTXFSIZN(ep)); - } - /* 768*4=3072 bytes FIFO length */ - size = 768; - for (ep = 5; ep = 8; ep++) { + for (ep = 1; ep MAX_EPS_CHANNELS; ep++) { + if (!hsotg-g_tx_fifo_sz[ep]) + continue; val = addr; - val |= size FIFOSIZE_DEPTH_SHIFT; - WARN_ONCE(addr + size hsotg-fifo_mem, + val |= hsotg-g_tx_fifo_sz[ep] FIFOSIZE_DEPTH_SHIFT; + WARN_ONCE(addr + hsotg-g_tx_fifo_sz[ep] hsotg-fifo_mem, insufficient fifo memory); - addr += size; + addr += hsotg-g_tx_fifo_sz[ep]; writel(val, hsotg-regs + DPTXFSIZN(ep)); } @@ -3495,9 +3480,42 @@ static void s3c_hsotg_delete_debug(struct dwc2_hsotg *hsotg) static void s3c_hsotg_of_probe(struct dwc2_hsotg *hsotg) { struct device_node *np = hsotg-dev-of_node; + u32 len = 0; + u32 i = 0; /* Enable dma if requested in device tree */ hsotg-g_using_dma = of_property_read_bool(np,
[PATCH v3 26/30] usb: dwc2: gadget: reset fifo_map when initializing fifos
From: Gregory Herrero gregory.herr...@intel.com After all endpoints are disabled, fifo_map should have reached 0. Its a bug if if didn't, so warn about it and reset it to 0 so that driver can continue using all the fifos. Signed-off-by: Gregory Herrero gregory.herr...@intel.com Signed-off-by: Mian Yousaf Kaukab yousaf.kau...@intel.com --- drivers/usb/dwc2/gadget.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index de5da92..a1fd86f 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -177,6 +177,10 @@ static void s3c_hsotg_init_fifo(struct dwc2_hsotg *hsotg) int timeout; u32 val; + /* Reset fifo map if not correctly cleared during previous session */ + WARN_ON(hsotg-fifo_map); + hsotg-fifo_map = 0; + /* set RX/NPTX FIFO sizes */ writel(hsotg-g_rx_fifo_sz, hsotg-regs + GRXFSIZ); writel((hsotg-g_rx_fifo_sz FIFOSIZE_STARTADDR_SHIFT) | -- 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 v3 11/30] usb: dwc2: gadget: check interrupts for all endpoints
Current code does not check endpoint 15 interrupt. Use number of endpoint configured in hardware instead of the hardcoded value. Signed-off-by: Mian Yousaf Kaukab yousaf.kau...@intel.com --- drivers/usb/dwc2/gadget.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 530c246..b7879fd 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -2337,12 +2337,14 @@ irq_retry: dev_dbg(hsotg-dev, %s: daint=%08x\n, __func__, daint); - for (ep = 0; ep 15 daint_out; ep++, daint_out = 1) { + for (ep = 0; ep hsotg-num_of_eps daint_out; + ep++, daint_out = 1) { if (daint_out 1) s3c_hsotg_epint(hsotg, ep, 0); } - for (ep = 0; ep 15 daint_in; ep++, daint_in = 1) { + for (ep = 0; ep hsotg-num_of_eps daint_in; + ep++, daint_in = 1) { if (daint_in 1) s3c_hsotg_epint(hsotg, ep, 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 v3 13/30] Documentation: dt-bindings: add dt binding info for dwc2 fifo resizing
From: Gregory Herrero gregory.herr...@intel.com Signed-off-by: Gregory Herrero gregory.herr...@intel.com --- Documentation/devicetree/bindings/usb/dwc2.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/dwc2.txt b/Documentation/devicetree/bindings/usb/dwc2.txt index a7a9cb6..fd132cb 100644 --- a/Documentation/devicetree/bindings/usb/dwc2.txt +++ b/Documentation/devicetree/bindings/usb/dwc2.txt @@ -21,6 +21,9 @@ Refer to phy/phy-bindings.txt for generic phy consumer properties - dr_mode: shall be one of host, peripheral and otg Refer to usb/generic.txt - g-use-dma: enable dma usage in gadget driver. +- g-rx-fifo-size: size of rx fifo size in gadget mode. +- g-np-tx-fifo-size: size of non-periodic tx fifo size in gadget mode. +- g-tx-fifo-size: size of periodic tx fifo per endpoint (except ep0) in gadget mode. Example: -- 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 v3 15/30] usb: dwc2: gadget: fix debug loop limits
15 check doesn't show debug information for endpoint 15. It is possible to have less than 15 endpoints so use limit provided by hardware configuration. Signed-off-by: Mian Yousaf Kaukab yousaf.kau...@intel.com --- drivers/usb/dwc2/gadget.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index c43ce7e..7dfda95 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -3156,14 +3156,14 @@ static void s3c_hsotg_dump(struct dwc2_hsotg *hsotg) /* show periodic fifo settings */ - for (idx = 1; idx = 15; idx++) { + for (idx = 1; idx hsotg-num_of_eps; idx++) { val = readl(regs + DPTXFSIZN(idx)); dev_info(dev, DPTx[%d] FSize=%d, StAddr=0x%08x\n, idx, val FIFOSIZE_DEPTH_SHIFT, val FIFOSIZE_STARTADDR_MASK); } - for (idx = 0; idx 15; idx++) { + for (idx = 0; idx hsotg-num_of_eps; idx++) { dev_info(dev, ep%d-in: EPCTL=0x%08x, SIZ=0x%08x, DMA=0x%08x\n, idx, readl(regs + DIEPCTL(idx)), @@ -3221,7 +3221,7 @@ static int state_show(struct seq_file *seq, void *v) seq_puts(seq, \nEndpoint status:\n); - for (idx = 0; idx 15; idx++) { + for (idx = 0; idx hsotg-num_of_eps; idx++) { u32 in, out; in = readl(regs + DIEPCTL(idx)); @@ -3280,7 +3280,7 @@ static int fifo_show(struct seq_file *seq, void *v) seq_puts(seq, \nPeriodic TXFIFOs:\n); - for (idx = 1; idx = 15; idx++) { + for (idx = 1; idx hsotg-num_of_eps; idx++) { val = readl(regs + DPTXFSIZN(idx)); seq_printf(seq, \tDPTXFIFO%2d: Size %d, Start 0x%08x\n, idx, -- 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 v3 23/30] usb: dwc2: gadget: rename sent_zlp to send_zlp
This flag is set before sending the zlp. So use present tense instead of the past tense. Signed-off-by: Mian Yousaf Kaukab yousaf.kau...@intel.com --- drivers/usb/dwc2/core.h | 4 ++-- drivers/usb/dwc2/gadget.c | 8 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index e963aef..f09b3de 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -108,7 +108,7 @@ struct s3c_hsotg_req; * @halted: Set if the endpoint has been halted. * @periodic: Set if this is a periodic ep, such as Interrupt * @isochronous: Set if this is a isochronous ep - * @sent_zlp: Set if we've sent a zero-length packet. + * @send_zlp: Set if we need to send a zero-length packet. * @total_data: The total number of data bytes done. * @fifo_size: The size of the FIFO (for periodic IN endpoints) * @fifo_load: The amount of data loaded into the FIFO (periodic IN) @@ -149,7 +149,7 @@ struct s3c_hsotg_ep { unsigned inthalted:1; unsigned intperiodic:1; unsigned intisochronous:1; - unsigned intsent_zlp:1; + unsigned intsend_zlp:1; charname[10]; }; diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 65ec0f2..5fdc3f5 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -607,7 +607,7 @@ static void s3c_hsotg_start_req(struct dwc2_hsotg *hsotg, /* Test if zlp is actually required. */ if ((ureq-length = hs_ep-ep.maxpacket) !(ureq-length % hs_ep-ep.maxpacket)) - hs_ep-sent_zlp = 1; + hs_ep-send_zlp = 1; } epsize |= DXEPTSIZ_PKTCNT(packets); @@ -1193,7 +1193,7 @@ static void s3c_hsotg_enqueue_setup(struct dwc2_hsotg *hsotg) } hsotg-eps_out[0]-dir_in = 0; - hsotg-eps_out[0]-sent_zlp = 0; + hsotg-eps_out[0]-send_zlp = 0; hsotg-ep0_state = DWC2_EP0_SETUP; ret = s3c_hsotg_ep_queue(hsotg-eps_out[0]-ep, req, GFP_ATOMIC); @@ -1757,9 +1757,9 @@ static void s3c_hsotg_complete_in(struct dwc2_hsotg *hsotg, } /* Zlp for all endpoints, for ep0 only in DATA IN stage */ - if (hs_ep-sent_zlp) { + if (hs_ep-send_zlp) { s3c_hsotg_program_zlp(hsotg, hs_ep); - hs_ep-sent_zlp = 0; + hs_ep-send_zlp = 0; /* transfer will be completed on next complete interrupt */ return; } -- 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 v3 27/30] usb: dwc2: gadget: fix pullup handling
From: Gregory Herrero gregory.herr...@intel.com Gadget must be informed about disconnection when pullup is removed. Signed-off-by: Gregory Herrero gregory.herr...@intel.com --- drivers/usb/dwc2/gadget.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index a1fd86f..2719d48 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -3018,6 +3018,7 @@ static int s3c_hsotg_pullup(struct usb_gadget *gadget, int is_on) s3c_hsotg_core_connect(hsotg); } else { s3c_hsotg_core_disconnect(hsotg); + s3c_hsotg_disconnect(hsotg); hsotg-enabled = 0; clk_disable(hsotg-clk); } -- 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 v3 28/30] usb: dwc2: gadget: add vbus_draw support
From: Gregory Herrero gregory.herr...@intel.com This callback informs the driver about the total amount of current it is allowed to draw. Share this information with the phy so that current limits can be set for charging for example. Signed-off-by: Gregory Herrero gregory.herr...@intel.com --- drivers/usb/dwc2/gadget.c | 17 + 1 file changed, 17 insertions(+) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 2719d48..f477709 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -3053,12 +3053,29 @@ static int s3c_hsotg_vbus_session(struct usb_gadget *gadget, int is_active) return 0; } +/** + * s3c_hsotg_vbus_draw - report bMaxPower field + * @gadget: The usb gadget state + * @mA: Amount of current + * + * Report how much power the device may consume to the phy. + */ +static int s3c_hsotg_vbus_draw(struct usb_gadget *gadget, unsigned mA) +{ + struct dwc2_hsotg *hsotg = to_hsotg(gadget); + + if (IS_ERR_OR_NULL(hsotg-uphy)) + return -ENOTSUPP; + return usb_phy_set_power(hsotg-uphy, mA); +} + static const struct usb_gadget_ops s3c_hsotg_gadget_ops = { .get_frame = s3c_hsotg_gadget_getframe, .udc_start = s3c_hsotg_udc_start, .udc_stop = s3c_hsotg_udc_stop, .pullup = s3c_hsotg_pullup, .vbus_session = s3c_hsotg_vbus_session, + .vbus_draw = s3c_hsotg_vbus_draw, }; /** -- 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 v3 29/30] usb: dwc2: gadget: force gadget initialization in dev mode
From: Gregory Herrero gregory.herr...@intel.com When booting with id pin grounded, dwc2 default to host mode. Thus, force device mode prior initializing gadget part. Else fifo init will fail since fifo values are not correct in host mode. Signed-off-by: Gregory Herrero gregory.herr...@intel.com --- drivers/usb/dwc2/gadget.c | 16 1 file changed, 16 insertions(+) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index f477709..df9080d 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -3675,6 +3675,19 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq) /* usb phy enable */ s3c_hsotg_phy_enable(hsotg); + /* +* Force Device mode before initialization. +* This allows correctly configuring fifo for device mode. +*/ + __bic32(hsotg-regs + GUSBCFG, GUSBCFG_FORCEHOSTMODE); + __orr32(hsotg-regs + GUSBCFG, GUSBCFG_FORCEDEVMODE); + + /* +* According to Synopsys databook, this sleep is needed for the force +* device mode to take effect. +*/ + msleep(25); + s3c_hsotg_corereset(hsotg); ret = s3c_hsotg_hw_cfg(hsotg); if (ret) { @@ -3684,6 +3697,9 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq) s3c_hsotg_init(hsotg); + /* Switch back to default configuration */ + __bic32(hsotg-regs + GUSBCFG, GUSBCFG_FORCEDEVMODE); + hsotg-ctrl_buff = devm_kzalloc(hsotg-dev, DWC2_CTRL_BUFF_SIZE, GFP_KERNEL); if (!hsotg-ctrl_buff) { -- 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 v3 07/30] usb: dwc2: gadget: don't erase gahbcfg register when enabling dma
From: Gregory Herrero gregory.herr...@intel.com Do a read-modify-write instead of only setting DMAEn bit. Signed-off-by: Gregory Herrero gregory.herr...@intel.com --- drivers/usb/dwc2/gadget.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index b69b8fa8..b98622f 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -2827,8 +2827,8 @@ static void s3c_hsotg_init(struct dwc2_hsotg *hsotg) writel(GUSBCFG_PHYIF16 | GUSBCFG_TOUTCAL(7) | (0x5 10), hsotg-regs + GUSBCFG); - writel(using_dma(hsotg) ? GAHBCFG_DMA_EN : 0x0, - hsotg-regs + GAHBCFG); + if (using_dma(hsotg)) + __orr32(hsotg-regs + GAHBCFG, GAHBCFG_DMA_EN); } /** -- 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 v3 09/30] Documentation: dt-bindings: add dt binding info for dwc2 g-use-dma
From: Gregory Herrero gregory.herr...@intel.com Indicate if gadget driver must use dma for usb transfers. Signed-off-by: Gregory Herrero gregory.herr...@intel.com --- Documentation/devicetree/bindings/usb/dwc2.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/usb/dwc2.txt b/Documentation/devicetree/bindings/usb/dwc2.txt index 482f815..a7a9cb6 100644 --- a/Documentation/devicetree/bindings/usb/dwc2.txt +++ b/Documentation/devicetree/bindings/usb/dwc2.txt @@ -20,6 +20,7 @@ Optional properties: Refer to phy/phy-bindings.txt for generic phy consumer properties - dr_mode: shall be one of host, peripheral and otg Refer to usb/generic.txt +- g-use-dma: enable dma usage in gadget driver. Example: -- 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 v3 00/30] usb: updates for dwc2 gadget driver
Hi, This patchset consists of various bug fixes and feature enhancements for the dwc2 gadget driver. All the patches are verified on dwc2 v3.0a with dedicated fifos. Main focus of testing was with dma enabled. Although basic testing without dma was also done. It is based on testing/next branch in Felipe's git and Tested-by: Dinh Nguyen dingu...@opensource.altera.com Thank you, Best regards, Yousaf History: v3: - Fixed comment from Sergei Shtylyov - Updated usb: dwc2: gadget: don't process XferCompl on setup packet to apply the check on endpoint 0 only. - Fixed regression in usb: dwc2: gadget: manage ep0 state in software for dwc2 ip v2.93a, found by Dinh Nguyen. v2: - Rebased to Felipe's testing/next with https://lkml.org/lkml/2014/12/16/135 applied on top. - Fixed comments from Robert Baldyga - Some cosmetic changes - Replaced usb: dwc2: gadget: process setup packet on transfer complete with usb: dwc2: gadget: don't process XferCompl on setup packet - Updated usb: dwc2: gadget: provide gadget handle to the phy so that otg_set_peripheral is called in both udc_start and udc_stop. v1: - Addressed comments from Sergei Shtylyov Gregory Herrero (13): usb: dwc2: gadget: register gadget handle to the phy usb: dwc2: gadget: write correct value in ahbcfg register usb: dwc2: gadget: don't erase gahbcfg register when enabling dma usb: dwc2: gadget: add device tree property to enable dma Documentation: dt-bindings: add dt binding info for dwc2 g-use-dma usb: dwc2: gadget: configure fifos from device tree Documentation: dt-bindings: add dt binding info for dwc2 fifo resizing usb: dwc2: gadget: don't block after fifo flush timeout usb: dwc2: gadget: add vbus_session support usb: dwc2: gadget: reset fifo_map when initializing fifos usb: dwc2: gadget: fix pullup handling usb: dwc2: gadget: add vbus_draw support usb: dwc2: gadget: force gadget initialization in dev mode Mian Yousaf Kaukab (17): usb: dwc2: gadget: mask fifo empty irq with dma usb: dwc2: gadget: don't process XferCompl on setup packet usb: dwc2: gadget: don't embed ep0 buffers usb: dwc2: gadget: fix error path in dwc2_gadget_init usb: dwc2: gadget: add bi-directional endpoint support usb: dwc2: gadget: check interrupts for all endpoints usb: dwc2: gadget: remove unused members from hsotg_req usb: dwc2: gadget: fix debug loop limits usb: dwc2: gadget: consider all tx fifos usb: dwc2: gadget: kill requests after disabling ep usb: dwc2: gadget: manage ep0 state in software usb: dwc2: gadget: fix zero length packet transfers usb: dwc2: gadget: dont warn if endpoint is not enabled usb: dwc2: gadget: rename sent_zlp to send_zlp usb: dwc2: gadget: pick smallest acceptable fifo usb: dwc2: gadget: fix fifo allocation leak usb: dwc2: gadget: report disconnection after reset Documentation/devicetree/bindings/usb/dwc2.txt | 4 + drivers/usb/dwc2/core.h| 46 +- drivers/usb/dwc2/gadget.c | 792 - drivers/usb/dwc2/hw.h | 1 + 4 files changed, 556 insertions(+), 287 deletions(-) -- 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 v3 04/30] usb: dwc2: gadget: don't embed ep0 buffers
When using DMA, data of the previous setup packet can be read back from cache because ep0 and ctrl buffers are embedded in struct s3c_hsotg. Allocate buffers instead of embedding them. Signed-off-by: Mian Yousaf Kaukab yousaf.kau...@intel.com Reviewed-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/dwc2/core.h | 7 +-- drivers/usb/dwc2/gadget.c | 16 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index 0d2ee29..7db83d0 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -434,6 +434,9 @@ struct dwc2_hw_params { u32 snpsid; }; +/* Size of control and EP0 buffers */ +#define DWC2_CTRL_BUFF_SIZE 8 + /** * struct dwc2_hsotg - Holds the state of the driver, including the non-periodic * and periodic schedules @@ -684,8 +687,8 @@ struct dwc2_hsotg { struct usb_request *ep0_reply; struct usb_request *ctrl_req; - u8 ep0_buff[8]; - u8 ctrl_buff[8]; + void *ep0_buff; + void *ctrl_buff; struct usb_gadget gadget; unsigned int enabled:1; diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 45afbf8..35d346f 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -3486,6 +3486,22 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq) s3c_hsotg_hw_cfg(hsotg); s3c_hsotg_init(hsotg); + hsotg-ctrl_buff = devm_kzalloc(hsotg-dev, + DWC2_CTRL_BUFF_SIZE, GFP_KERNEL); + if (!hsotg-ctrl_buff) { + dev_err(dev, failed to allocate ctrl request buff\n); + ret = -ENOMEM; + goto err_supplies; + } + + hsotg-ep0_buff = devm_kzalloc(hsotg-dev, + DWC2_CTRL_BUFF_SIZE, GFP_KERNEL); + if (!hsotg-ep0_buff) { + dev_err(dev, failed to allocate ctrl reply buff\n); + ret = -ENOMEM; + goto err_supplies; + } + ret = devm_request_irq(hsotg-dev, irq, s3c_hsotg_irq, IRQF_SHARED, dev_name(hsotg-dev), hsotg); if (ret 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 v3 01/30] usb: dwc2: gadget: register gadget handle to the phy
From: Gregory Herrero gregory.herr...@intel.com Bind peripheral controller to the phy on udc_start. Unbind on udc_stop. Signed-off-by: Gregory Herrero gregory.herr...@intel.com Signed-off-by: Mian Yousaf Kaukab yousaf.kau...@intel.com --- drivers/usb/dwc2/gadget.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 1a8e0a6..b5332f0 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -2878,6 +2878,8 @@ static int s3c_hsotg_udc_start(struct usb_gadget *gadget, } s3c_hsotg_phy_enable(hsotg); + if (!IS_ERR_OR_NULL(hsotg-uphy)) + otg_set_peripheral(hsotg-uphy-otg, hsotg-gadget); spin_lock_irqsave(hsotg-lock, flags); s3c_hsotg_init(hsotg); @@ -2927,6 +2929,8 @@ static int s3c_hsotg_udc_stop(struct usb_gadget *gadget) spin_unlock_irqrestore(hsotg-lock, flags); + if (!IS_ERR_OR_NULL(hsotg-uphy)) + otg_set_peripheral(hsotg-uphy-otg, NULL); s3c_hsotg_phy_disable(hsotg); regulator_bulk_disable(ARRAY_SIZE(hsotg-supplies), hsotg-supplies); -- 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 v3 03/30] usb: dwc2: gadget: don't process XferCompl on setup packet
Only process DOEPINT.XferCompl on data packet as DOEPINTn.SetUp can occur with or without DOEPINT.XferCompl. When DOEPINT.SetUp occurs with DOEPINT.XferCompl, only DOEPINT.SetUp needs to be handled. Moreover, ignore DOEPINT.XferCompl when it occurs with DOEPINT.StupPktRcvd as driver needs to wait for DOEPINT.SetUp to continue. Signed-off-by: Mian Yousaf Kaukab yousaf.kau...@intel.com --- drivers/usb/dwc2/gadget.c | 4 drivers/usb/dwc2/hw.h | 1 + 2 files changed, 5 insertions(+) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 843f3ee..45afbf8 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -1810,6 +1810,10 @@ static void s3c_hsotg_epint(struct dwc2_hsotg *hsotg, unsigned int idx, dev_dbg(hsotg-dev, %s: ep%d(%s) DxEPINT=0x%08x\n, __func__, idx, dir_in ? in : out, ints); + /* Don't process XferCompl interrupt if it is a setup packet */ + if (idx == 0 (ints (DXEPINT_SETUP | DXEPINT_SETUP_RCVD))) + ints = ~DXEPINT_XFERCOMPL; + if (ints DXEPINT_XFERCOMPL) { if (hs_ep-isochronous hs_ep-interval == 1) { if (ctrl DXEPCTL_EOFRNUM) diff --git a/drivers/usb/dwc2/hw.h b/drivers/usb/dwc2/hw.h index 51248b9..d018ebe 100644 --- a/drivers/usb/dwc2/hw.h +++ b/drivers/usb/dwc2/hw.h @@ -541,6 +541,7 @@ #define DIEPINT(_a)HSOTG_REG(0x908 + ((_a) * 0x20)) #define DOEPINT(_a)HSOTG_REG(0xB08 + ((_a) * 0x20)) +#define DXEPINT_SETUP_RCVD (1 15) #define DXEPINT_INEPNAKEFF (1 6) #define DXEPINT_BACK2BACKSETUP (1 6) #define DXEPINT_INTKNEPMIS (1 5) -- 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 v3 02/30] usb: dwc2: gadget: mask fifo empty irq with dma
When using DMA, keep fifo empty interrupt disabled. Otherwise core is flooded by interrupts. Signed-off-by: Gregory Herrero gregory.herr...@intel.com Signed-off-by: Mian Yousaf Kaukab yousaf.kau...@intel.com --- drivers/usb/dwc2/gadget.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index b5332f0..843f3ee 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -2170,8 +2170,8 @@ void s3c_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg) * interrupts. */ - writel(((hsotg-dedicated_fifos) ? DIEPMSK_TXFIFOEMPTY | - DIEPMSK_INTKNTXFEMPMSK : 0) | + writel(((hsotg-dedicated_fifos !using_dma(hsotg)) ? + DIEPMSK_TXFIFOEMPTY | DIEPMSK_INTKNTXFEMPMSK : 0) | DIEPMSK_EPDISBLDMSK | DIEPMSK_XFERCOMPLMSK | DIEPMSK_TIMEOUTMSK | DIEPMSK_AHBERRMSK | DIEPMSK_INTKNEPMISMSK, -- 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 v3 05/30] usb: dwc2: gadget: fix error path in dwc2_gadget_init
In the error path, s3c_hsotg_phy_disable should be called after a call to s3c_hsotg_phy_enable is made. Signed-off-by: Mian Yousaf Kaukab yousaf.kau...@intel.com --- drivers/usb/dwc2/gadget.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 35d346f..a4d2c26 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -3476,7 +3476,7 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq) if (ret) { dev_err(dev, failed to enable supplies: %d\n, ret); - goto err_supplies; + goto err_clk; } /* usb phy enable */ @@ -3510,7 +3510,7 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq) regulator_bulk_disable(ARRAY_SIZE(hsotg-supplies), hsotg-supplies); dev_err(dev, cannot claim IRQ for gadget\n); - goto err_clk; + goto err_supplies; } /* hsotg-num_of_eps holds number of EPs other than ep0 */ -- 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 v3 06/30] usb: dwc2: gadget: write correct value in ahbcfg register
From: Gregory Herrero gregory.herr...@intel.com HBstLen is GAHBCFG[4:1]. Use GAHBCFG_HBSTLEN_SHIFT to write burst- length at correct position. Signed-off-by: Gregory Herrero gregory.herr...@intel.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 a4d2c26..b69b8fa8 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -2160,7 +2160,7 @@ void s3c_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg) if (using_dma(hsotg)) writel(GAHBCFG_GLBL_INTR_EN | GAHBCFG_DMA_EN | - GAHBCFG_HBSTLEN_INCR4, + (GAHBCFG_HBSTLEN_INCR4 GAHBCFG_HBSTLEN_SHIFT), hsotg-regs + GAHBCFG); else writel(((hsotg-dedicated_fifos) ? (GAHBCFG_NP_TXF_EMP_LVL | -- 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 v3 08/30] usb: dwc2: gadget: add device tree property to enable dma
From: Gregory Herrero gregory.herr...@intel.com * Add an of specific function to parse device node properties. * Enable dma usage only if device tree property 'g_use_dma' is present. Signed-off-by: Gregory Herrero gregory.herr...@intel.com --- drivers/usb/dwc2/core.h | 2 ++ drivers/usb/dwc2/gadget.c | 18 -- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index 7db83d0..376a008 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -563,6 +563,7 @@ struct dwc2_hw_params { * @setup: NAK management for EP0 SETUP * @last_rst: Time of last reset * @eps:The endpoints being supplied to the gadget framework + * @g_using_dma: Indicate if dma usage is enabled */ struct dwc2_hsotg { struct device *dev; @@ -696,6 +697,7 @@ struct dwc2_hsotg { unsigned int setup:1; unsigned long last_rst; struct s3c_hsotg_ep *eps; + u32 g_using_dma; #endif /* CONFIG_USB_DWC2_PERIPHERAL || CONFIG_USB_DWC2_DUAL_ROLE */ }; diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index b98622f..c24cb3b 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -85,11 +85,11 @@ static void s3c_hsotg_dump(struct dwc2_hsotg *hsotg); * a core reset. This means we either need to fix the gadgets to take * account of DMA alignment, or add bounce buffers (yuerk). * - * Until this issue is sorted out, we always return 'false'. + * g_using_dma is set depending on dts flag. */ static inline bool using_dma(struct dwc2_hsotg *hsotg) { - return false; /* support is not complete */ + return hsotg-g_using_dma; } /** @@ -3402,6 +3402,18 @@ static void s3c_hsotg_delete_debug(struct dwc2_hsotg *hsotg) debugfs_remove(hsotg-debug_root); } +#ifdef CONFIG_OF +static void s3c_hsotg_of_probe(struct dwc2_hsotg *hsotg) +{ + struct device_node *np = hsotg-dev-of_node; + + /* Enable dma if requested in device tree */ + hsotg-g_using_dma = of_property_read_bool(np, g-use-dma); +} +#else +static inline void s3c_hsotg_of_probe(struct dwc2_hsotg *hsotg) { } +#endif + /** * dwc2_gadget_init - init function for gadget * @dwc2: The data structure for the DWC2 driver. @@ -3419,6 +3431,8 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq) /* Set default UTMI width */ hsotg-phyif = GUSBCFG_PHYIF16; + s3c_hsotg_of_probe(hsotg); + /* * If platform probe couldn't find a generic PHY or an old style * USB PHY, fall back to pdata -- 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 v3 10/30] usb: dwc2: gadget: add bi-directional endpoint support
GHWCFG1 provides hardware configuration of each endpoint. Use it to configure the endpoints instead of assuming all even endpoint are OUT and all odd endpoints are IN. Signed-off-by: Mian Yousaf Kaukab yousaf.kau...@intel.com --- drivers/usb/dwc2/core.h | 3 +- drivers/usb/dwc2/gadget.c | 326 +- 2 files changed, 210 insertions(+), 119 deletions(-) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index 376a008..7a0309d 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -696,7 +696,8 @@ struct dwc2_hsotg { unsigned int connected:1; unsigned int setup:1; unsigned long last_rst; - struct s3c_hsotg_ep *eps; + struct s3c_hsotg_ep *eps_in[MAX_EPS_CHANNELS]; + struct s3c_hsotg_ep *eps_out[MAX_EPS_CHANNELS]; u32 g_using_dma; #endif /* CONFIG_USB_DWC2_PERIPHERAL || CONFIG_USB_DWC2_DUAL_ROLE */ }; diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index c24cb3b..530c246 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -65,6 +65,15 @@ static inline void __bic32(void __iomem *ptr, u32 val) writel(readl(ptr) ~val, ptr); } +static inline struct s3c_hsotg_ep *index_to_ep(struct dwc2_hsotg *hsotg, + u32 ep_index, u32 dir_in) +{ + if (dir_in) + return hsotg-eps_in[ep_index]; + else + return hsotg-eps_out[ep_index]; +} + /* forward declaration of functions */ static void s3c_hsotg_dump(struct dwc2_hsotg *hsotg); @@ -819,7 +828,7 @@ static void s3c_hsotg_complete_oursetup(struct usb_ep *ep, static struct s3c_hsotg_ep *ep_from_windex(struct dwc2_hsotg *hsotg, u32 windex) { - struct s3c_hsotg_ep *ep = hsotg-eps[windex 0x7F]; + struct s3c_hsotg_ep *ep; int dir = (windex USB_DIR_IN) ? 1 : 0; int idx = windex 0x7F; @@ -829,6 +838,8 @@ static struct s3c_hsotg_ep *ep_from_windex(struct dwc2_hsotg *hsotg, if (idx hsotg-num_of_eps) return NULL; + ep = index_to_ep(hsotg, idx, dir); + if (idx ep-dir_in != dir) return NULL; @@ -889,7 +900,7 @@ static int s3c_hsotg_send_reply(struct dwc2_hsotg *hsotg, static int s3c_hsotg_process_req_status(struct dwc2_hsotg *hsotg, struct usb_ctrlrequest *ctrl) { - struct s3c_hsotg_ep *ep0 = hsotg-eps[0]; + struct s3c_hsotg_ep *ep0 = hsotg-eps_out[0]; struct s3c_hsotg_ep *ep; __le16 reply; int ret; @@ -960,7 +971,7 @@ static struct s3c_hsotg_req *get_ep_head(struct s3c_hsotg_ep *hs_ep) static int s3c_hsotg_process_req_feature(struct dwc2_hsotg *hsotg, struct usb_ctrlrequest *ctrl) { - struct s3c_hsotg_ep *ep0 = hsotg-eps[0]; + struct s3c_hsotg_ep *ep0 = hsotg-eps_out[0]; struct s3c_hsotg_req *hs_req; bool restart; bool set = (ctrl-bRequest == USB_REQ_SET_FEATURE); @@ -1040,7 +1051,7 @@ static void s3c_hsotg_enqueue_setup(struct dwc2_hsotg *hsotg); */ static void s3c_hsotg_stall_ep0(struct dwc2_hsotg *hsotg) { - struct s3c_hsotg_ep *ep0 = hsotg-eps[0]; + struct s3c_hsotg_ep *ep0 = hsotg-eps_out[0]; u32 reg; u32 ctrl; @@ -1080,7 +1091,7 @@ static void s3c_hsotg_stall_ep0(struct dwc2_hsotg *hsotg) static void s3c_hsotg_process_control(struct dwc2_hsotg *hsotg, struct usb_ctrlrequest *ctrl) { - struct s3c_hsotg_ep *ep0 = hsotg-eps[0]; + struct s3c_hsotg_ep *ep0 = hsotg-eps_out[0]; int ret = 0; u32 dcfg; @@ -1201,9 +1212,9 @@ static void s3c_hsotg_enqueue_setup(struct dwc2_hsotg *hsotg) return; } - hsotg-eps[0].dir_in = 0; + hsotg-eps_out[0]-dir_in = 0; - ret = s3c_hsotg_ep_queue(hsotg-eps[0].ep, req, GFP_ATOMIC); + ret = s3c_hsotg_ep_queue(hsotg-eps_out[0]-ep, req, GFP_ATOMIC); if (ret 0) { dev_err(hsotg-dev, %s: failed queue (%d)\n, __func__, ret); /* @@ -1293,7 +1304,7 @@ static void s3c_hsotg_complete_request(struct dwc2_hsotg *hsotg, */ static void s3c_hsotg_rx_data(struct dwc2_hsotg *hsotg, int ep_idx, int size) { - struct s3c_hsotg_ep *hs_ep = hsotg-eps[ep_idx]; + struct s3c_hsotg_ep *hs_ep = hsotg-eps_out[ep_idx]; struct s3c_hsotg_req *hs_req = hs_ep-req; void __iomem *fifo = hsotg-regs + EPFIFO(ep_idx); int to_read; @@ -1367,13 +1378,14 @@ static void s3c_hsotg_send_zlp(struct dwc2_hsotg *hsotg, } if (req-req.length == 0) { - hsotg-eps[0].sent_zlp = 1; + hsotg-eps_out[0]-sent_zlp = 1; s3c_hsotg_enqueue_setup(hsotg); return; } - hsotg-eps[0].dir_in = 1; - hsotg-eps[0].sent_zlp = 1; + /*
[PATCH resend 1/2] xhci: Print hcc params, version and quirks on init
To help debugging xhci problems. Signed-off-by: Hans de Goede hdego...@redhat.com --- drivers/usb/host/xhci.c | 4 drivers/usb/host/xhci.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 01fcbb5..bb3e328 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -4901,6 +4901,10 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) if (retval) goto error; xhci_dbg(xhci, Called HCD init\n); + + xhci_info(xhci, hcc params 0x%08x hci version 0x%x quirks 0x%08x\n, + xhci-hcc_params, xhci-hci_version, xhci-quirks); + return 0; error: kfree(xhci); diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index cc7c5bb..89a0793 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1605,6 +1605,8 @@ static inline struct usb_hcd *xhci_to_hcd(struct xhci_hcd *xhci) dev_warn(xhci_to_hcd(xhci)-self.controller , fmt , ## args) #define xhci_warn_ratelimited(xhci, fmt, args...) \ dev_warn_ratelimited(xhci_to_hcd(xhci)-self.controller , fmt , ## args) +#define xhci_info(xhci, fmt, args...) \ + dev_info(xhci_to_hcd(xhci)-self.controller , fmt , ## args) /* * Registers should always be accessed with double word or quad word accesses. -- 2.1.0 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH resend 2/2] xhci: Silence xHCI xhci_drop_endpoint called with disabled ep ... messages
When re-applying the configuration after a successful usb device reset, xhci_discover_or_reset_device has already dropped the endpoints, and free-ed the rings. The endpoints already being dropped is expected, and should not lead to warnings. Use the fact that the rings are also free-ed in this scenario to detect this, and suppress the xHCI xhci_drop_endpoint called with disabled ep ... message in this case. Signed-off-by: Hans de Goede hdego...@redhat.com -- Changes in v2: Move the ring check to only guard the xhci_warn, so as to avoid side-effects in case we have a scenario where the rings are free-ed, but the endpoint is not yet dropped. --- drivers/usb/host/xhci.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index bb3e328..305aacf 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -1676,8 +1676,10 @@ int xhci_drop_endpoint(struct usb_hcd *hcd, struct usb_device *udev, cpu_to_le32(EP_STATE_DISABLED)) || le32_to_cpu(ctrl_ctx-drop_flags) xhci_get_endpoint_flag(ep-desc)) { - xhci_warn(xhci, xHCI %s called with disabled ep %p\n, - __func__, ep); + /* Do not warn when called after a usb_device_reset */ + if (xhci-devs[udev-slot_id]-eps[ep_index].ring != NULL) + xhci_warn(xhci, xHCI %s called with disabled ep %p\n, + __func__, ep); return 0; } -- 2.1.0 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH resend 0/2] xhci: Logging improvements
Hi Mathias, These 2 patches which have been sitting in my personal tree for a while now seem to have fallen through the cracks, hence this resend. If you're simply just not interested in them let me know and I'll drop them. Regards, Hans -- 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