Re: [PATCH] USB: Add quirk for WORLDE easykey.25 MIDI keyboard
On Tue, Jan 24, 2017 at 8:32 AM, Oliver Neukum wrote: > Am Montag, den 23.01.2017, 19:36 +0100 schrieb Lukáš Lalinský: >> I have uploaded both captures here - >> https://gist.github.com/lalinsky/83148a827d5cd43e79e377d8e1b5ed0d > > Indeed it is does not set a configuration. Either the capture > is incomplete or device and host violate the standard. A device > may be left unconfigured. Is this may or may not? I'm not familiar with USB, so I assumed if there is only one configuration and there is always one active, it does not need to be set explicitly because the correct one is already active. > We need to read the descriptors even if we > see only one configuration to get the power budgeting right. Aren't those in the CONFIGURATION descriptors? Reading the STRING descriptor is probably only useful if you need to print the configuration details somewhere. > Does the device work without any .ini file? Yes. It's a standard MIDI device, no configuration is required. Lukas -- 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: Add quirk for WORLDE easykey.25 MIDI keyboard
Am Montag, den 23.01.2017, 19:36 +0100 schrieb Lukáš Lalinský: > On Sat, Jan 21, 2017 at 10:08 AM, Greg Kroah-Hartman > wrote: > > > > Always use scripts/get_maintainer.pl to determine who to send > > patches > > to, and what mailing list. You forgot linux-usb@vger, which I've > > now > > added... > > I'm sorry about that. I actually did use scripts/get_maintainer.pl, > but it only returned your email address and I added linux-kernel@vger > myself. I guess I ran it with wrong options. > > > > > That's odd, how does other operating systems handle this device? > > I'm not sure how realistic this test is, but I ran a Wireshark > capture > from Windows 8.1 VM and it seems that for this particular device, > Windows doesn't try to set the current configuration (since there is > only one) and it does not even attempt to get the configuration > string > descriptor. I'm not sure if Windows does this in general, but it > seems > to work around the problem for this device by not caring about the > configuration string descriptor in the first place. > > I have uploaded both captures here - > https://gist.github.com/lalinsky/83148a827d5cd43e79e377d8e1b5ed0d Indeed it is does not set a configuration. Either the capture is incomplete or device and host violate the standard. A device may be left unconfigured. We need to read the descriptors even if we see only one configuration to get the power budgeting right. Does the device work without any .ini file? Regards Oliver -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 02/24] Revert "usb: dwc2: Read in the AHB burst property"
Hi John, [auto build test ERROR on balbi-usb/next] [also build test ERROR on next-20170123] [cannot apply to v4.10-rc5] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/John-Youn/usb-dwc2-Rework-params-FIFO-and-other-changes/20170124-072407 base: https://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git next config: x86_64-randconfig-s5-01241246 (attached as .config) compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 Note: the linux-review/John-Youn/usb-dwc2-Rework-params-FIFO-and-other-changes/20170124-072407 HEAD 3ef187d597d009e39cc77484b95a2c935096eba5 builds fine. It only hurts bisectibility. All errors (new ones prefixed by >>): drivers/usb/dwc2/gadget.c: In function 'dwc2_hsotg_core_init_disconnected': >> drivers/usb/dwc2/gadget.c:3237:22: error: 'struct dwc2_core_params' has no >> member named 'ahb_burst' (hsotg->params.ahb_burst << GAHBCFG_HBSTLEN_SHIFT), ^ vim +3237 drivers/usb/dwc2/gadget.c 1ee6903b drivers/usb/dwc2/gadget.c Gregory Herrero 2015-09-29 3231 intmsk |= GINTSTS_CONIDSTSCHNG; 1ee6903b drivers/usb/dwc2/gadget.c Gregory Herrero 2015-09-29 3232 1ee6903b drivers/usb/dwc2/gadget.c Gregory Herrero 2015-09-29 3233 dwc2_writel(intmsk, hsotg->regs + GINTMSK); 308d734e drivers/usb/gadget/s3c-hsotg.c Lukasz Majewski 2012-05-04 3234 a5c18f11 drivers/usb/dwc2/gadget.c Vahram Aharonyan 2016-11-14 3235 if (using_dma(hsotg)) { 95c8bc36 drivers/usb/dwc2/gadget.c Antti Seppälä2015-08-20 3236 dwc2_writel(GAHBCFG_GLBL_INTR_EN | GAHBCFG_DMA_EN | 70033c5e drivers/usb/dwc2/gadget.c John Youn2016-11-17 @3237 (hsotg->params.ahb_burst << GAHBCFG_HBSTLEN_SHIFT), 94cb8fd6 drivers/usb/gadget/s3c-hsotg.c Lukasz Majewski 2012-05-04 3238 hsotg->regs + GAHBCFG); a5c18f11 drivers/usb/dwc2/gadget.c Vahram Aharonyan 2016-11-14 3239 a5c18f11 drivers/usb/dwc2/gadget.c Vahram Aharonyan 2016-11-14 3240 /* Set DDMA mode support in the core if needed */ :: The code at line 3237 was first introduced by commit :: 70033c5ec15b5b634927b6ffe8bcc9bf5029ab4c usb: dwc2: Use the ahb_burst param :: TO: John Youn :: CC: Felipe Balbi --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: application/gzip
Re: [PATCH v3 02/24] Revert "usb: dwc2: Read in the AHB burst property"
Hi John, [auto build test ERROR on balbi-usb/next] [also build test ERROR on next-20170123] [cannot apply to v4.10-rc5] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/John-Youn/usb-dwc2-Rework-params-FIFO-and-other-changes/20170124-072407 base: https://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git next config: x86_64-randconfig-u0-01241252 (attached as .config) compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 Note: the linux-review/John-Youn/usb-dwc2-Rework-params-FIFO-and-other-changes/20170124-072407 HEAD 3ef187d597d009e39cc77484b95a2c935096eba5 builds fine. It only hurts bisectibility. All errors (new ones prefixed by >>): drivers/usb/dwc2/hcd.c: In function 'dwc2_gahbcfg_init': >> drivers/usb/dwc2/hcd.c:277:27: error: 'struct dwc2_core_params' has no >> member named 'ahb_burst' ahbcfg |= (hsotg->params.ahb_burst << ^ vim +277 drivers/usb/dwc2/hcd.c b02038fa John Youn 2016-02-23 271 dev_err(hsotg->dev, "External DMA Mode not supported\n"); b02038fa John Youn 2016-02-23 272 return -EINVAL; b02038fa John Youn 2016-02-23 273 b02038fa John Youn 2016-02-23 274 case GHWCFG2_INT_DMA_ARCH: b02038fa John Youn 2016-02-23 275 dev_dbg(hsotg->dev, "Internal DMA Mode\n"); 70033c5e John Youn 2016-11-17 276 ahbcfg &= ~GAHBCFG_HBSTLEN_MASK; 70033c5e John Youn 2016-11-17 @277 ahbcfg |= (hsotg->params.ahb_burst << 70033c5e John Youn 2016-11-17 278 GAHBCFG_HBSTLEN_SHIFT); b02038fa John Youn 2016-02-23 279 break; b02038fa John Youn 2016-02-23 280 :: The code at line 277 was first introduced by commit :: 70033c5ec15b5b634927b6ffe8bcc9bf5029ab4c usb: dwc2: Use the ahb_burst param :: TO: John Youn :: CC: Felipe Balbi --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: application/gzip
Re: [PATCH v6 1/4] usb: dbc: early driver for xhci debug capability
Hi Ingo, On 01/22/2017 05:31 PM, Ingo Molnar wrote: > * Lu Baolu wrote: > >> xHCI debug capability (DbC) is an optional but standalone >> functionality provided by an xHCI host controller. Software >> learns this capability by walking through the extended >> capability list of the host. xHCI specification describes >> DbC in section 7.6. >> >> This patch introduces the code to probe and initialize the >> debug capability hardware during early boot. With hardware >> initialized, the debug target (system on which this code is >> running) will present a debug device through the debug port >> (normally the first USB3 port). The debug device is fully >> compliant with the USB framework and provides the equivalent >> of a very high performance (USB3) full-duplex serial link >> between the debug host and target. The DbC functionality is >> independent of xHCI host. There isn't any precondition from >> xHCI host side for DbC to work. > s/xHCI host/the xHCI host > >> This patch also includes bulk out and bulk in interfaces. >> These interfaces could be used to implement early printk >> bootconsole or hook to various system debuggers. > s/out/output > s/in/input > >> +config EARLY_PRINTK_USB_XDBC >> +bool "Early printk via xHCI debug port" > s/xHCI/the xHCI > > I remarked on this in my first review as well - mind checking the whole > series for > uses of 'xHCI'? > >> +depends on EARLY_PRINTK && PCI >> +select EARLY_PRINTK_USB >> +---help--- >> + Write kernel log output directly into the xHCI debug port. >> + >> + This is useful for kernel debugging when your machine crashes very >> + early before the console code is initialized. For normal operation >> + it is not recommended because it looks ugly and doesn't cooperate >> + with klogd/syslogd or the X server. You should normally N here, >> + unless you want to debug such a crash. >> + >> config X86_PTDUMP_CORE >> def_bool n >> >> diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig >> index fbe493d..9313fff 100644 >> --- a/drivers/usb/Kconfig >> +++ b/drivers/usb/Kconfig >> @@ -19,6 +19,9 @@ config USB_EHCI_BIG_ENDIAN_MMIO >> config USB_EHCI_BIG_ENDIAN_DESC >> bool >> >> +config USB_EARLY_PRINTK >> +bool >> + >> menuconfig USB_SUPPORT >> bool "USB support" >> depends on HAS_IOMEM >> diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile >> index 7791af6..53d1356 100644 >> --- a/drivers/usb/Makefile >> +++ b/drivers/usb/Makefile >> @@ -49,7 +49,7 @@ obj-$(CONFIG_USB_MICROTEK) += image/ >> obj-$(CONFIG_USB_SERIAL)+= serial/ >> >> obj-$(CONFIG_USB) += misc/ >> -obj-$(CONFIG_EARLY_PRINTK_DBGP) += early/ >> +obj-$(CONFIG_EARLY_PRINTK_USB) += early/ >> >> obj-$(CONFIG_USB_ATM) += atm/ >> obj-$(CONFIG_USB_SPEEDTOUCH)+= atm/ >> diff --git a/drivers/usb/early/Makefile b/drivers/usb/early/Makefile >> index 24bbe51..fcde228 100644 >> --- a/drivers/usb/early/Makefile >> +++ b/drivers/usb/early/Makefile >> @@ -3,3 +3,4 @@ >> # >> >> obj-$(CONFIG_EARLY_PRINTK_DBGP) += ehci-dbgp.o >> +obj-$(CONFIG_EARLY_PRINTK_USB_XDBC) += xhci-dbc.o >> diff --git a/drivers/usb/early/xhci-dbc.c b/drivers/usb/early/xhci-dbc.c >> new file mode 100644 >> index 000..72480c4 >> --- /dev/null >> +++ b/drivers/usb/early/xhci-dbc.c >> @@ -0,0 +1,1027 @@ >> +/** >> + * xhci-dbc.c - xHCI debug capability early driver >> + * >> + * Copyright (C) 2016 Intel Corporation >> + * >> + * Author: Lu Baolu >> + * >> + * This program is free software; you can redistribute it and/or modify >> + * it under the terms of the GNU General Public License version 2 as >> + * published by the Free Software Foundation. >> + */ >> + >> +#define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__ >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +#include "../host/xhci.h" >> +#include "xhci-dbc.h" >> + >> +static struct xdbc_state xdbc; >> +static int early_console_keep; >> + >> +#ifdef XDBC_TRACE >> +#define xdbc_trace trace_printk >> +#else >> +static inline void xdbc_trace(const char *fmt, ...) { } >> +#endif /* XDBC_TRACE */ >> + >> +static int xdbc_bulk_transfer(void *data, int size, bool read); >> + >> +static void __iomem * __init xdbc_map_pci_mmio(u32 bus, u32 dev, u32 func) >> +{ >> +u32 val, sz; >> +u64 val64, sz64, mask64; >> +u8 byte; >> +void __iomem *base; >> + >> +val = read_pci_config(bus, dev, func, PCI_BASE_ADDRESS_0); >> +write_pci_config(bus, dev, func, PCI_BASE_ADDRESS_0, ~0); >> +sz = read_pci_config(bus, dev, func, PCI_BASE_ADDRESS_0); >> +write_pci_config(bus, dev, func, PCI_BASE_ADDRESS_0, val); >> +if (val == 0x || sz == 0x) { >> +pr_notice("invalid mmio bar\n"); >> +return NULL; >> +} >> + >> +val64 = val & PCI_BASE_ADDRESS_MEM_MASK; >> +
Re: [PATCH v5 1/4] usb: dbc: early driver for xhci debug capability
Hi Ingo, On 01/22/2017 05:04 PM, Ingo Molnar wrote: > * Lu Baolu wrote: > +static void xdbc_runtime_delay(unsigned long count) +{ + udelay(count); +} +static void (*xdbc_delay)(unsigned long) = xdbc_early_delay; >>> Is this udelay() complication really necessary? udelay() should work fine >>> even in >>> early code. It might not be precisely calibrated, but should be good enough. >> I tried udelay() in the early code. It's not precise enough for the >> hardware handshaking. > Possibly because on x86 early udelay() did not work at all - i.e. there's no > delay > whatsoever. Yes. > > Could you try it on top of this commit in tip:timers/core: > > 4c45c5167c95 x86/timer: Make delay() work during early bootup > > ? I tried tip:timers/core. It's not precise enough for my context either. __const_udelay(). 157 inline void __const_udelay(unsigned long xloops) 158 { 159 unsigned long lpj = this_cpu_read(cpu_info.loops_per_jiffy) ? : loops_per_jiffy; 160 int d0; 161 162 xloops *= 4; 163 asm("mull %%edx" 164 :"=d" (xloops), "=&a" (d0) 165 :"1" (xloops), "0" (lpj * (HZ / 4))); 166 167 __delay(++xloops); 168 } In my early code, loops_per_jiffy is not initialized yet. Hence "lpj" for the asm line is 4096 (default value). The cpu_info.loops_per_jiffy actually reads 8832000 after initialization. They are about 2000 times different. I did a hacky test in kernel to check the difference between these two different "lpj" values. (The hacky patch is attached.) Below is the output for 100ms delay. [2.494751] udelay_test uninitialized >start [2.494820] udelay_test uninitialized >end [2.494828] udelay_test initialized >start [2.595234] udelay_test initialized >end For 100ms delay, udelay() with uninitialized loops_per_jiffy only gives a delay of only 69us. Best regards, Lu Baolu diff --git a/arch/x86/lib/delay.c b/arch/x86/lib/delay.c index a8e91ae..ffc2874 100644 --- a/arch/x86/lib/delay.c +++ b/arch/x86/lib/delay.c @@ -168,6 +168,36 @@ inline void __const_udelay(unsigned long xloops) } EXPORT_SYMBOL(__const_udelay); +void udelay_uninitialized(unsigned long xloops) +{ + unsigned long lpj = (1<<12); + int d0; + + xloops *= 0x10c7ul; + xloops *= 4; + asm("mull %%edx" + :"=d" (xloops), "=&a" (d0) + :"1" (xloops), "0" (lpj * (HZ / 4))); + + delay_loop(++xloops); +} +EXPORT_SYMBOL(udelay_uninitialized); + +void udelay_initialized(unsigned long xloops) +{ + unsigned long lpj = this_cpu_read(cpu_info.loops_per_jiffy); + int d0; + + xloops *= 0x10c7ul; + xloops *= 4; + asm("mull %%edx" + :"=d" (xloops), "=&a" (d0) + :"1" (xloops), "0" (lpj * (HZ / 4))); + + delay_loop(++xloops); +} +EXPORT_SYMBOL(udelay_initialized); + void __udelay(unsigned long usecs) { __const_udelay(usecs * 0x10c7); /* 2**32 / 100 (rounded up) */ diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index 954abfd..b6a7437 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -302,6 +302,21 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) /* USB-2 and USB-3 roothubs initialized, allow runtime pm suspend */ pm_runtime_put_noidle(&dev->dev); + do { + int count = 1000; + + pr_notice("udelay_test uninitialized >start\n"); + while (count-- > 0) + udelay_uninitialized(100); + pr_notice("udelay_test uninitialized >end\n"); + + count = 1000; + pr_notice("udelay_test initialized >start\n"); + while (count-- > 0) + udelay_initialized(100); + pr_notice("udelay_test initialized >end\n"); + } while (0); + return 0; put_usb3_hcd: diff --git a/include/asm-generic/delay.h b/include/asm-generic/delay.h index 0f79054..200ab55 100644 --- a/include/asm-generic/delay.h +++ b/include/asm-generic/delay.h @@ -9,6 +9,8 @@ extern void __udelay(unsigned long usecs); extern void __ndelay(unsigned long nsecs); extern void __const_udelay(unsigned long xloops); extern void __delay(unsigned long loops); +extern void udelay_uninitialized(unsigned long xloops); +extern void udelay_initialized(unsigned long xloops); /* * The weird n/2 thing suppresses a "comparison is always false due to
[PATCH v2] usb: gadget: f_hid: fix: Move IN request allocation to set_alt()
Since commit: ba1582f22231 ("usb: gadget: f_hid: use alloc_ep_req()") we cannot allocate any requests in bind() as we check if we should align request buffer based on endpoint descriptor which is assigned in set_alt(). Allocating request in bind() function causes a NULL pointer dereference. This commit moves allocation of IN request from bind() to set_alt() to prevent this issue. Fixes: ba1582f22231 ("usb: gadget: f_hid: use alloc_ep_req()") Cc: sta...@vger.kernel.org Tested-by: David Lechner Signed-off-by: Krzysztof Opasiak --- Changes since v1: - rebased on top of testing/next --- drivers/usb/gadget/function/f_hid.c | 89 - 1 file changed, 67 insertions(+), 22 deletions(-) diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c index b62e69d..89b48bc 100644 --- a/drivers/usb/gadget/function/f_hid.c +++ b/drivers/usb/gadget/function/f_hid.c @@ -338,6 +338,7 @@ static ssize_t f_hidg_write(struct file *file, const char __user *buffer, size_t count, loff_t *offp) { struct f_hidg *hidg = file->private_data; + struct usb_request *req; unsigned long flags; ssize_t status = -ENOMEM; @@ -347,7 +348,7 @@ static ssize_t f_hidg_write(struct file *file, const char __user *buffer, spin_lock_irqsave(&hidg->write_spinlock, flags); #define WRITE_COND (!hidg->write_pending) - +try_again: /* write queue */ while (!WRITE_COND) { spin_unlock_irqrestore(&hidg->write_spinlock, flags); @@ -362,6 +363,7 @@ static ssize_t f_hidg_write(struct file *file, const char __user *buffer, } hidg->write_pending = 1; + req = hidg->req; count = min_t(unsigned, count, hidg->report_length); spin_unlock_irqrestore(&hidg->write_spinlock, flags); @@ -374,24 +376,38 @@ static ssize_t f_hidg_write(struct file *file, const char __user *buffer, goto release_write_pending; } - hidg->req->status = 0; - hidg->req->zero = 0; - hidg->req->length = count; - hidg->req->complete = f_hidg_req_complete; - hidg->req->context = hidg; + spin_lock_irqsave(&hidg->write_spinlock, flags); + + /* we our function has been disabled by host */ + if (!hidg->req) { + free_ep_req(hidg->in_ep, hidg->req); + /* +* TODO +* Should we fail with error here? +*/ + goto try_again; + } + + req->status = 0; + req->zero = 0; + req->length = count; + req->complete = f_hidg_req_complete; + req->context = hidg; status = usb_ep_queue(hidg->in_ep, hidg->req, GFP_ATOMIC); if (status < 0) { ERROR(hidg->func.config->cdev, "usb_ep_queue error on int endpoint %zd\n", status); - goto release_write_pending; + goto release_write_pending_unlocked; } else { status = count; } + spin_unlock_irqrestore(&hidg->write_spinlock, flags); return status; release_write_pending: spin_lock_irqsave(&hidg->write_spinlock, flags); +release_write_pending_unlocked: hidg->write_pending = 0; spin_unlock_irqrestore(&hidg->write_spinlock, flags); @@ -595,12 +611,23 @@ static void hidg_disable(struct usb_function *f) kfree(list); } spin_unlock_irqrestore(&hidg->read_spinlock, flags); + + spin_lock_irqsave(&hidg->write_spinlock, flags); + if (!hidg->write_pending) { + free_ep_req(hidg->in_ep, hidg->req); + hidg->write_pending = 1; + } + + hidg->req = NULL; + spin_unlock_irqrestore(&hidg->write_spinlock, flags); } static int hidg_set_alt(struct usb_function *f, unsigned intf, unsigned alt) { struct usb_composite_dev*cdev = f->config->cdev; struct f_hidg *hidg = func_to_hidg(f); + struct usb_request *req_in = NULL; + unsigned long flags; int i, status = 0; VDBG(cdev, "hidg_set_alt intf:%d alt:%d\n", intf, alt); @@ -621,6 +648,12 @@ static int hidg_set_alt(struct usb_function *f, unsigned intf, unsigned alt) goto fail; } hidg->in_ep->driver_data = hidg; + + req_in = hidg_alloc_ep_req(hidg->in_ep, hidg->report_length); + if (!req_in) { + status = -ENOMEM; + goto disable_ep_in; + } } @@ -632,12 +665,12 @@ static int hidg_set_alt(struct usb_function *f, unsigned intf, unsigned alt) hidg->out_ep); if (status) { ERROR(cdev, "config_ep_by_speed FAILED!\n"); -
Re: functionfs on dwc3, xhci host: endpoint cannot be used in both directions ?
Hello, On Tue, Jan 24, 2017 at 12:20 AM, Felipe Balbi wrote: > Seems like HW engineer wanted these last few endpoints to *not* support > full USB3 packets. They are probably supposed to be used for Isochronous > and/or Interrupts endpoints. At some point we need to support this as > well. During initialization we should read FIFO size configuration and > extract wMaxPacketSize for $endpoint from the HW. If my understanding of your register explanation is correct, the >9 IN endpoints could still work as bulk in LS/FS speeds (I don't have the board at hand to try right now). If this is correct, won't your patch (in your testing/next branch) make these endpoints unusable for bulk use even in LS/FS ? A bit more generally, I have the feeling (from reading epautoconf.c and f_fs.c) that the endpoint dispatching (and hence, endpoint capabilities) lacks the notion of speed (SS has it, kind of, via the companion descriptor argument in epautoconf.c). I noticed something a few weeks back which may come from this lack: when I tried only populating the HS descriptors, the host xHCI would complain about non-standard endpoint size (64B instead of HS-required 512B). In my understanding, this is because f_fs.c allocates endpoints using the first populated descriptor set (in LS/FS, then HS, then SS order), and epautoconf.c overwriting the buffer size to 64 on non-SS bulk descriptors. I think extending such API is over my head still. Do you have ideas on this ? FWIW, the Intel Edison (the board I'm using as device) is not USB 3 capable despite dwc3 usage. If my undrstanding is correct, it is because it lacks the USB 3 companion phy, and of course does not expose the corresponding tracks on the expansion connector (would it be possible to host the companion outside the edison module ? I have no idea how it is supposed to interract with the dwc3 and USB 2 phy). Regards, -- Vincent Pelletier -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4 6/6] usb: musb: dsps: Manage CPPI 4.1 DMA interrupt in DSPS
+cc linux-usb list On Mon, Jan 23, 2017 at 05:48:08PM +0100, Alexandre Bailon wrote: > Despite the CPPI 4.1 is a generic DMA, it is tied to USB. > On the DSPS, CPPI 4.1 interrupt's registers are in USBSS (the MUSB glue). > Currently, to enable / disable and clear interrupts, the CPPI 4.1 driver > maps and accesses to USBSS's register, which making CPPI 4.1 driver not > really generic. > Move the interrupt management to DSPS driver. > > Signed-off-by: Alexandre Bailon It seems this patch set is almost ready to go. If Vinod would ACK on this patch, I'd like to pick it into my tree, since the rest of the set is for musb. Regards, -Bin. -- 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 24/24] usb: dwc2: gadget: Add checking for g-tx-fifo-size parameter
From: Sevak Arakelyan Add dwc2_check_param_tx_fifo_sizes function which validates the members of g_tx_fifo_size array and sets to average or default values if it is needed. Cc: Stefan Wahren Signed-off-by: Sevak Arakelyan Signed-off-by: John Youn --- drivers/usb/dwc2/params.c | 35 +++ 1 file changed, 35 insertions(+) diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c index 016fff0cb887..2990c347289f 100644 --- a/drivers/usb/dwc2/params.c +++ b/drivers/usb/dwc2/params.c @@ -427,6 +427,40 @@ static void dwc2_check_param_phy_utmi_width(struct dwc2_hsotg *hsotg) dwc2_set_param_phy_utmi_width(hsotg); } +static void dwc2_check_param_tx_fifo_sizes(struct dwc2_hsotg *hsotg) +{ + int fifo_count; + int fifo; + int min; + u32 total = 0; + u32 dptxfszn; + + fifo_count = dwc2_hsotg_tx_fifo_count(hsotg); + min = hsotg->hw_params.en_multiple_tx_fifo ? 16 : 4; + + for (fifo = 1; fifo <= fifo_count; fifo++) + total += hsotg->params.g_tx_fifo_size[fifo]; + + if (total > dwc2_hsotg_tx_fifo_total_depth(hsotg) || !total) { + dev_warn(hsotg->dev, "%s: Invalid parameter g-tx-fifo-size, setting to default average\n", +__func__); + dwc2_set_param_tx_fifo_sizes(hsotg); + } + + for (fifo = 1; fifo <= fifo_count; fifo++) { + dptxfszn = (dwc2_readl(hsotg->regs + DPTXFSIZN(fifo)) & + FIFOSIZE_DEPTH_MASK) >> FIFOSIZE_DEPTH_SHIFT; + + if (hsotg->params.g_tx_fifo_size[fifo] < min || + hsotg->params.g_tx_fifo_size[fifo] > dptxfszn) { + dev_warn(hsotg->dev, "%s: Invalid parameter g_tx_fifo_size[%d]=%d\n", +__func__, fifo, +hsotg->params.g_tx_fifo_size[fifo]); + hsotg->params.g_tx_fifo_size[fifo] = dptxfszn; + } + } +} + #define CHECK_RANGE(_param, _min, _max, _def) do { \ if ((hsotg->params._param) < (_min) || \ (hsotg->params._param) > (_max)) { \ @@ -496,6 +530,7 @@ static void dwc2_check_params(struct dwc2_hsotg *hsotg) CHECK_RANGE(g_np_tx_fifo_size, 16, hw->dev_nperio_tx_fifo_size, hw->dev_nperio_tx_fifo_size); + dwc2_check_param_tx_fifo_sizes(hsotg); } } -- 2.11.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 v3 22/24] usb: dwc2: host: Correct snpsid checking for GDFIFOCFG
From: Sevak Arakelyan GDFIFOCFG is available from IP version 2.91a. Fix the code to reflect this. Signed-off-by: Sevak Arakelyan Signed-off-by: John Youn --- drivers/usb/dwc2/core.h | 1 + drivers/usb/dwc2/hcd.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index a473853ca39c..5370e6429f28 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -940,6 +940,7 @@ struct dwc2_hsotg { /* DWC OTG HW Release versions */ #define DWC2_CORE_REV_2_71a0x4f54271a #define DWC2_CORE_REV_2_90a0x4f54290a +#define DWC2_CORE_REV_2_91a0x4f54291a #define DWC2_CORE_REV_2_92a0x4f54292a #define DWC2_CORE_REV_2_94a0x4f54294a #define DWC2_CORE_REV_3_00a0x4f54300a diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 751f0ddd741b..a2d4997d822c 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -494,8 +494,9 @@ static void dwc2_config_fifos(struct dwc2_hsotg *hsotg) dwc2_readl(hsotg->regs + HPTXFSIZ)); if (hsotg->params.en_multiple_tx_fifo && - hsotg->hw_params.snpsid <= DWC2_CORE_REV_2_94a) { + hsotg->hw_params.snpsid >= DWC2_CORE_REV_2_91a) { /* +* This feature was implemented in 2.91a version * Global DFIFOCFG calculation for Host mode - * include RxFIFO, NPTXFIFO and HPTXFIFO */ -- 2.11.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 v3 23/24] usb: dwc2: gadget: Set TX FIFO depths to calculated defaults
From: Sevak Arakelyan Remove legacy DWC2_G_P_LEGACY_TX_FIFO_SIZE array for TX FIFOs. Update dwc2_set_param_tx_fifo_sizes function to calculate and assign default average FIFO depth to each member of g_tx_fifo_size array. Total FIFO size, EP Info block's size, FIFO operation mode and device operation mode are taken into consideration during the calculation. Cc: Stefan Wahren Signed-off-by: Sevak Arakelyan Signed-off-by: John Youn --- drivers/usb/dwc2/core.h | 16 drivers/usb/dwc2/gadget.c | 93 +++ drivers/usb/dwc2/params.c | 12 -- 3 files changed, 110 insertions(+), 11 deletions(-) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index 5370e6429f28..f10eca91d2be 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -274,13 +274,6 @@ 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} - /* Gadget ep0 states */ enum dwc2_ep0_state { DWC2_EP0_SETUP, @@ -1180,6 +1173,9 @@ int dwc2_hsotg_set_test_mode(struct dwc2_hsotg *hsotg, int testmode); #define dwc2_is_device_connected(hsotg) (hsotg->connected) int dwc2_backup_device_registers(struct dwc2_hsotg *hsotg); int dwc2_restore_device_registers(struct dwc2_hsotg *hsotg); +int dwc2_hsotg_tx_fifo_count(struct dwc2_hsotg *hsotg); +int dwc2_hsotg_tx_fifo_total_depth(struct dwc2_hsotg *hsotg); +int dwc2_hsotg_tx_fifo_average_depth(struct dwc2_hsotg *hsotg); #else static inline int dwc2_hsotg_remove(struct dwc2_hsotg *dwc2) { return 0; } @@ -1201,6 +1197,12 @@ static inline int dwc2_backup_device_registers(struct dwc2_hsotg *hsotg) { return 0; } static inline int dwc2_restore_device_registers(struct dwc2_hsotg *hsotg) { return 0; } +static inline int dwc2_hsotg_tx_fifo_count(struct dwc2_hsotg *hsotg) +{ return 0; } +static inline int dwc2_hsotg_tx_fifo_total_depth(struct dwc2_hsotg *hsotg) +{ return 0; } +static inline int dwc2_hsotg_tx_fifo_average_depth(struct dwc2_hsotg *hsotg) +{ return 0; } #endif #if IS_ENABLED(CONFIG_USB_DWC2_HOST) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 30ff51eab35c..eb579b6f68f0 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -191,6 +191,99 @@ static void dwc2_hsotg_ctrl_epint(struct dwc2_hsotg *hsotg, local_irq_restore(flags); } +/** + * dwc2_hsotg_tx_fifo_count - return count of TX FIFOs in device mode + */ +int dwc2_hsotg_tx_fifo_count(struct dwc2_hsotg *hsotg) +{ + if (hsotg->hw_params.en_multiple_tx_fifo) + /* In dedicated FIFO mode we need count of IN EPs */ + return (dwc2_readl(hsotg->regs + GHWCFG4) & + GHWCFG4_NUM_IN_EPS_MASK) >> GHWCFG4_NUM_IN_EPS_SHIFT; + else + /* In shared FIFO mode we need count of Periodic IN EPs */ + return hsotg->hw_params.num_dev_perio_in_ep; +} + +/** + * dwc2_hsotg_ep_info_size - return Endpoint Info Control block size in DWORDs + */ +static int dwc2_hsotg_ep_info_size(struct dwc2_hsotg *hsotg) +{ + int val = 0; + int i; + u32 ep_dirs; + + /* +* Don't need additional space for ep info control registers in +* slave mode. +*/ + if (!using_dma(hsotg)) { + dev_dbg(hsotg->dev, "Buffer DMA ep info size 0\n"); + return 0; + } + + /* +* Buffer DMA mode - 1 location per endpoit +* Descriptor DMA mode - 4 locations per endpoint +*/ + ep_dirs = hsotg->hw_params.dev_ep_dirs; + + for (i = 0; i <= hsotg->hw_params.num_dev_ep; i++) { + val += ep_dirs & 3 ? 1 : 2; + ep_dirs >>= 2; + } + + if (using_desc_dma(hsotg)) + val = val * 4; + + return val; +} + +/** + * dwc2_hsotg_tx_fifo_total_depth - return total FIFO depth available for + * device mode TX FIFOs + */ +int dwc2_hsotg_tx_fifo_total_depth(struct dwc2_hsotg *hsotg) +{ + int ep_info_size; + int addr; + int tx_addr_max; + u32 np_tx_fifo_size; + + np_tx_fifo_size = min_t(u32, hsotg->hw_params.dev_nperio_tx_fifo_size, + hsotg->params.g_np_tx_fifo_size); + + /* Get Endpoint Info Control block size in DWORDs. */ + ep_info_size = dwc2_hsotg_ep_info_size(hsotg); + tx_addr_max = hsotg->hw_params.total_fifo_size - ep_info_size; + + addr = hsotg->params.g_rx_fifo_size + np_tx_fifo_size; + if (tx_addr_max <= addr) + return 0; + + return tx_addr_max - addr; +} + +/** + * dwc2_hsotg_tx_fifo_average_depth - returns average depth of device mode + * TX FIFOs + */ +int dwc2_hsotg_tx_fifo_average_depth(struct dwc2_hsotg *hsotg
[PATCH v3 21/24] usb: dwc2: host: use msleep() for long delay
From: Nicholas Mc Guire ulseep_range() uses hrtimers and provides no advantage over msleep() for larger delays. Fix up the 100ms delays here passing the adjusted "min" value to msleep(). This helps reduce the load on the hrtimer subsystem. Link: http://lkml.org/lkml/2017/1/11/377 Fixes: commit 2938fc63e0c2 ("usb: dwc2: Properly account for the force mode delays") Signed-off-by: Nicholas Mc Guire Signed-off-by: John Youn --- drivers/usb/dwc2/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c index 7195366e26bf..1b6612c2cdda 100644 --- a/drivers/usb/dwc2/core.c +++ b/drivers/usb/dwc2/core.c @@ -455,7 +455,7 @@ void dwc2_clear_force_mode(struct dwc2_hsotg *hsotg) dwc2_writel(gusbcfg, hsotg->regs + GUSBCFG); if (dwc2_iddig_filter_enabled(hsotg)) - usleep_range(10, 11); + msleep(100); } /* -- 2.11.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 v3 19/24] usb: dwc2: Force port resume on switching to device mode
From: Chen Yu We've seen failures when switching between host and gadget mode, which was diagnosed as being caused due to the bus being auto-suspended when we switched. So this patch forces a port resume when switching to device mode if the bus is suspended. Cc: Wei Xu Cc: Guodong Xu Cc: Amit Pundir Cc: Rob Herring Cc: John Youn Cc: Douglas Anderson Cc: Chen Yu Cc: Vardan Mikayelyan Cc: Kishon Vijay Abraham I Cc: Felipe Balbi Cc: Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org Signed-off-by: Chen Yu Signed-off-by: John Stultz Signed-off-by: John Youn --- drivers/usb/dwc2/hcd.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index e0d152f2c81b..1f670c3429a6 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -54,6 +54,8 @@ #include "core.h" #include "hcd.h" +static void dwc2_port_resume(struct dwc2_hsotg *hsotg); + /* * = * Host Core Layer Functions @@ -3231,6 +3233,11 @@ static void dwc2_conn_id_status_change(struct work_struct *work) if (gotgctl & GOTGCTL_CONID_B) { /* Wait for switch to device mode */ dev_dbg(hsotg->dev, "connId B\n"); + if (hsotg->bus_suspended) { + dev_info(hsotg->dev, +"Do port resume before switching to device mode\n"); + dwc2_port_resume(hsotg); + } while (!dwc2_is_device_mode(hsotg)) { dev_info(hsotg->dev, "Waiting for Peripheral Mode, Mode=%s\n", -- 2.11.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 v3 20/24] usb: dwc2: Add a quirk to allow speed negotiation for Hisilicon Hi6220
From: Chen Yu The Hi6220's usb controller is limited in that it does not support "Split Transactions", so it does not support communicating with low-speed and full-speed devices behind a high-speed hub. Thus it requires a quirk so that we can manually drop the usb speed when low/full-speed are attached, and bump back to high speed when they are removed. Cc: Wei Xu Cc: Guodong Xu Cc: Amit Pundir Cc: Rob Herring Cc: John Youn Cc: Douglas Anderson Cc: Chen Yu Cc: Vardan Mikayelyan Cc: Kishon Vijay Abraham I Cc: Felipe Balbi Cc: Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org Signed-off-by: Chen Yu [jstultz: Reworked to simplify the patch, and made commit log to be more specific about the issue] Signed-off-by: John Stultz Signed-off-by: John Youn --- drivers/usb/dwc2/core.h | 7 ++ drivers/usb/dwc2/hcd.c| 60 +++ drivers/usb/dwc2/params.c | 1 + 3 files changed, 68 insertions(+) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index b07bf7be2034..a473853ca39c 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -444,6 +444,11 @@ enum dwc2_ep0_state { * in DWORDS with possible values from from * 16-32768 (default: 256, 256, 256, 256, 768, * 768, 768, 768, 0, 0, 0, 0, 0, 0, 0). + * @change_speed_quirk: Change speed configuration to DWC2_SPEED_PARAM_FULL + * while full&low speed device connect. And change speed + * back to DWC2_SPEED_PARAM_HIGH while device is gone. + * 0 - No (default) + * 1 - Yes * * The following parameters may be specified when starting the module. These * parameters define how the DWC_otg controller should be configured. A @@ -501,6 +506,8 @@ struct dwc2_core_params { u32 g_rx_fifo_size; u32 g_np_tx_fifo_size; u32 g_tx_fifo_size[MAX_EPS_CHANNELS]; + + bool change_speed_quirk; }; /** diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 1f670c3429a6..751f0ddd741b 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -4868,6 +4868,61 @@ static void _dwc2_hcd_clear_tt_buffer_complete(struct usb_hcd *hcd, spin_unlock_irqrestore(&hsotg->lock, flags); } +/* + * HPRT0_SPD_HIGH_SPEED: high speed + * HPRT0_SPD_FULL_SPEED: full speed + */ +static void dwc2_change_bus_speed(struct usb_hcd *hcd, int speed) +{ + struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); + + if (hsotg->params.speed == speed) + return; + + hsotg->params.speed = speed; + queue_work(hsotg->wq_otg, &hsotg->wf_otg); +} + +static void dwc2_free_dev(struct usb_hcd *hcd, struct usb_device *udev) +{ + struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); + + if (!hsotg->params.change_speed_quirk) + return; + + /* +* On removal, set speed to default high-speed. +*/ + if (udev->parent && udev->parent->speed > USB_SPEED_UNKNOWN && + udev->parent->speed < USB_SPEED_HIGH) { + dev_info(hsotg->dev, "Set speed to default high-speed\n"); + dwc2_change_bus_speed(hcd, HPRT0_SPD_HIGH_SPEED); + } +} + +static int dwc2_reset_device(struct usb_hcd *hcd, struct usb_device *udev) +{ + struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); + + if (!hsotg->params.change_speed_quirk) + return 0; + + if (udev->speed == USB_SPEED_HIGH) { + dev_info(hsotg->dev, "Set speed to high-speed\n"); + dwc2_change_bus_speed(hcd, HPRT0_SPD_HIGH_SPEED); + } else if ((udev->speed == USB_SPEED_FULL || + udev->speed == USB_SPEED_LOW)) { + /* +* Change speed setting to full-speed if there's +* a full-speed or low-speed device plugged in. +*/ + dev_info(hsotg->dev, "Set speed to full-speed\n"); + dwc2_change_bus_speed(hcd, HPRT0_SPD_FULL_SPEED); + } + + return 0; +} + static struct hc_driver dwc2_hc_driver = { .description = "dwc2_hsotg", .product_desc = "DWC OTG Controller", @@ -5023,6 +5078,11 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq) dev_warn(hsotg->dev, "can't set coherent DMA mask\n"); } + if (hsotg->params.change_speed_quirk) { + dwc2_hc_driver.free_dev = dwc2_free_dev; + dwc2_hc_driver.reset_device = dwc2_reset_device; + } + hcd = usb_create_hcd(&dwc2_hc_driver, hsotg->dev, dev_name(hsotg->dev)); if (!hcd) goto error1; diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c index 620b02723f0d..8e5039e2d3fc 100644 --- a/drivers/usb/dwc2/params.c +++ b/drivers/usb/dwc2/params.c @@ -68,6 +68,7 @@ static void dwc2_set_his_params(struct dwc2_hsotg *hsotg) p->ahbcfg = GAHBC
[PATCH v3 18/24] usb: dwc2: Workaround case where GOTGCTL state is wrong
From: John Stultz When removing a USB-A to USB-otg adapter cable, we get a change status irq, and then in dwc2_conn_id_status_change, we erroniously see the GOTGCTL_CONID_B flag set. This causes us to get stuck in the "while (!dwc2_is_device_mode(hsotg))" loop, spitting out "Waiting for Peripheral Mode, Mode=Host" warnings until it fails out many seconds later. This patch works around the issue by re-reading the GOTGCTL state to check if the GOTGCTL_CONID_B is still set and if not restarting the change status logic. I suspect this isn't the best solution, but it seems to work well for me. Feedback would be greatly appreciated! Cc: Wei Xu Cc: Guodong Xu Cc: Amit Pundir Cc: Rob Herring Cc: John Youn Cc: Douglas Anderson Cc: Chen Yu Cc: Vardan Mikayelyan Cc: Kishon Vijay Abraham I Cc: Felipe Balbi Cc: Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org Reviewed-by: Vardan Mikayelyan Signed-off-by: John Stultz Signed-off-by: John Youn --- drivers/usb/dwc2/hcd.c | 9 + 1 file changed, 9 insertions(+) diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 8b688b041696..e0d152f2c81b 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -3237,6 +3237,14 @@ static void dwc2_conn_id_status_change(struct work_struct *work) dwc2_is_host_mode(hsotg) ? "Host" : "Peripheral"); msleep(20); + /* +* Sometimes the initial GOTGCTRL read is wrong, so +* check it again and jump to host mode if that was +* the case. +*/ + gotgctl = dwc2_readl(hsotg->regs + GOTGCTL); + if (!(gotgctl & GOTGCTL_CONID_B)) + goto host; if (++count > 250) break; } @@ -3251,6 +3259,7 @@ static void dwc2_conn_id_status_change(struct work_struct *work) spin_unlock_irqrestore(&hsotg->lock, flags); dwc2_hsotg_core_connect(hsotg); } else { +host: /* A-Device connector (Host Mode) */ dev_dbg(hsotg->dev, "connId A\n"); while (!dwc2_is_host_mode(hsotg)) { -- 2.11.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 v3 17/24] usb: dwc2: Avoid sleeping while holding hsotg->lock
From: John Stultz Basically when plugging in various cables in different orders, I'm occasionally seeing the following BUG splat: [ 86.215403] BUG: scheduling while atomic: kworker/u16:2/53/0x0002 [ 86.219164] usb 1-1: USB disconnect, device number 9 [ 86.226845] Preemption disabled at:[ 86.230218] [] dwc2_conn_id_status_change+0x120/0x250 [ 86.236894] CPU: 0 PID: 53 Comm: kworker/u16:2 Tainted: GW 4.9.0-rc8-00051-gd5a7979-dirty #1702 [ 86.246836] Hardware name: HiKey Development Board (DT) [ 86.252100] Workqueue: dwc2 dwc2_conn_id_status_change [ 86.257279] Call trace: [ 86.259771] [] dump_backtrace+0x0/0x1a0 [ 86.265210] [] show_stack+0x14/0x20 [ 86.270308] [] dump_stack+0x90/0xb0 [ 86.275401] [] __schedule_bug+0x6c/0xb8 [ 86.280841] [] __schedule+0x4f8/0x5b0 [ 86.286099] [] schedule+0x38/0xa0 [ 86.291017] [] schedule_hrtimeout_range_clock+0x8c/0xf0 [ 86.297846] [] schedule_hrtimeout_range+0x10/0x18 [ 86.304150] [] usleep_range+0x50/0x58 [ 86.309418] [] dwc2_wait_for_mode.isra.4+0x54/0xd0 [ 86.315815] [] dwc2_core_reset+0xe0/0x168 [ 86.321431] [] dwc2_hsotg_core_init_disconnected+0x2c/0x310 [ 86.328602] [] dwc2_conn_id_status_change+0x130/0x250 [ 86.335254] [] process_one_work+0x118/0x370 [ 86.341035] [] worker_thread+0x48/0x498 [ 86.346473] [] kthread+0xd0/0xe8 [ 86.351299] [] ret_from_fork+0x10/0x50 This seems to be caused by the dwc2_wait_for_mode() calling usleep_range() while the hstog->lock spinlock is held, since we take that before calling dwc2_hsotg_core_init_disconnected(). This patch avoids the issue by adding an extra argument to dwc2_core_reset(), as suggested by John Youn, which allows us to skip the waiting, which should be unnecessary when calling from dwc2_hsotg_core_init_disconnected(). Cc: Wei Xu Cc: Guodong Xu Cc: Amit Pundir Cc: Rob Herring Cc: John Youn Cc: Douglas Anderson Cc: Chen Yu Cc: Vardan Mikayelyan Cc: Kishon Vijay Abraham I Cc: Felipe Balbi Cc: Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org Signed-off-by: John Stultz Signed-off-by: John Youn --- drivers/usb/dwc2/core.c | 6 +++--- drivers/usb/dwc2/core.h | 2 +- drivers/usb/dwc2/gadget.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c index c987547a1e7b..7195366e26bf 100644 --- a/drivers/usb/dwc2/core.c +++ b/drivers/usb/dwc2/core.c @@ -313,7 +313,7 @@ static bool dwc2_iddig_filter_enabled(struct dwc2_hsotg *hsotg) * Do core a soft reset of the core. Be careful with this because it * resets all the internal state machines of the core. */ -int dwc2_core_reset(struct dwc2_hsotg *hsotg) +int dwc2_core_reset(struct dwc2_hsotg *hsotg, bool skip_wait) { u32 greset; int count = 0; @@ -369,7 +369,7 @@ int dwc2_core_reset(struct dwc2_hsotg *hsotg) } } while (!(greset & GRSTCTL_AHBIDLE)); - if (wait_for_host_mode) + if (wait_for_host_mode && !skip_wait) dwc2_wait_for_mode(hsotg, true); return 0; @@ -500,7 +500,7 @@ int dwc2_core_reset_and_force_dr_mode(struct dwc2_hsotg *hsotg) { int retval; - retval = dwc2_core_reset(hsotg); + retval = dwc2_core_reset(hsotg, false); if (retval) return retval; diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index 2bd3ea624cfc..b07bf7be2034 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -1088,7 +1088,7 @@ static inline bool dwc2_is_hs_iot(struct dwc2_hsotg *hsotg) * The following functions support initialization of the core driver component * and the DWC_otg controller */ -int dwc2_core_reset(struct dwc2_hsotg *hsotg); +int dwc2_core_reset(struct dwc2_hsotg *hsotg, bool skip_wait); int dwc2_core_reset_and_force_dr_mode(struct dwc2_hsotg *hsotg); int dwc2_enter_hibernation(struct dwc2_hsotg *hsotg); int dwc2_exit_hibernation(struct dwc2_hsotg *hsotg, bool restore); diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 1a1355429c1a..30ff51eab35c 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -3164,7 +3164,7 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg, kill_all_requests(hsotg, hsotg->eps_out[0], -ECONNRESET); if (!is_usb_reset) - if (dwc2_core_reset(hsotg)) + if (dwc2_core_reset(hsotg, true)) return; /* -- 2.11.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 v3 12/24] usb: dwc2: Fix usage of bool params
Check these parameters only for true or false. There is no need to check for greater or less than 0. Signed-off-by: John Youn --- drivers/usb/dwc2/core.c | 4 +- drivers/usb/dwc2/core.h | 5 -- drivers/usb/dwc2/core_intr.c | 2 +- drivers/usb/dwc2/gadget.c| 2 +- drivers/usb/dwc2/hcd.c | 113 +-- drivers/usb/dwc2/hcd_ddma.c | 4 +- drivers/usb/dwc2/hcd_intr.c | 45 + drivers/usb/dwc2/hcd_queue.c | 14 +++--- drivers/usb/dwc2/params.c| 4 +- 9 files changed, 93 insertions(+), 100 deletions(-) diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c index 0d322b7d4b28..c987547a1e7b 100644 --- a/drivers/usb/dwc2/core.c +++ b/drivers/usb/dwc2/core.c @@ -541,7 +541,7 @@ void dwc2_dump_host_registers(struct dwc2_hsotg *hsotg) addr = hsotg->regs + HAINTMSK; dev_dbg(hsotg->dev, "HAINTMSK@0x%08lX : 0x%08X\n", (unsigned long)addr, dwc2_readl(addr)); - if (hsotg->params.dma_desc_enable > 0) { + if (hsotg->params.dma_desc_enable) { addr = hsotg->regs + HFLBADDR; dev_dbg(hsotg->dev, "HFLBADDR @0x%08lX : 0x%08X\n", (unsigned long)addr, dwc2_readl(addr)); @@ -571,7 +571,7 @@ void dwc2_dump_host_registers(struct dwc2_hsotg *hsotg) addr = hsotg->regs + HCDMA(i); dev_dbg(hsotg->dev, "HCDMA @0x%08lX : 0x%08X\n", (unsigned long)addr, dwc2_readl(addr)); - if (hsotg->params.dma_desc_enable > 0) { + if (hsotg->params.dma_desc_enable) { addr = hsotg->regs + HCDMAB(i); dev_dbg(hsotg->dev, "HCDMAB @0x%08lX : 0x%08X\n", (unsigned long)addr, dwc2_readl(addr)); diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index 011e88017ce8..2bd3ea624cfc 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -470,9 +470,6 @@ struct dwc2_core_params { u8 phy_utmi_width; bool phy_ulpi_ddr; bool phy_ulpi_ext_vbus; -#define DWC2_PHY_ULPI_INTERNAL_VBUS0 -#define DWC2_PHY_ULPI_EXTERNAL_VBUS1 - bool enable_dynamic_fifo; bool en_multiple_tx_fifo; bool i2c_enable; @@ -492,8 +489,6 @@ struct dwc2_core_params { bool dma_desc_fs_enable; bool host_support_fs_ls_low_power; bool host_ls_low_power_phy_clk; -#define DWC2_HOST_LS_LOW_POWER_PHY_CLK_PARAM_48MHZ 0 -#define DWC2_HOST_LS_LOW_POWER_PHY_CLK_PARAM_6MHZ 1 u8 host_channels; u16 host_rx_fifo_size; diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c index 2f161bcf5f83..b8bcb007c92a 100644 --- a/drivers/usb/dwc2/core_intr.c +++ b/drivers/usb/dwc2/core_intr.c @@ -160,7 +160,7 @@ static void dwc2_handle_otg_intr(struct dwc2_hsotg *hsotg) gotgctl = dwc2_readl(hsotg->regs + GOTGCTL); if (gotgctl & GOTGCTL_SESREQSCS) { if (hsotg->params.phy_type == DWC2_PHY_TYPE_PARAM_FS && - hsotg->params.i2c_enable > 0) { + hsotg->params.i2c_enable) { hsotg->srp_success = 1; } else { /* Clear Session Request */ diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 4e15ff2f59db..1a1355429c1a 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -3227,7 +3227,7 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg, if (!using_desc_dma(hsotg)) intmsk |= GINTSTS_INCOMPL_SOIN | GINTSTS_INCOMPL_SOOUT; - if (hsotg->params.external_id_pin_ctl <= 0) + if (!hsotg->params.external_id_pin_ctl) intmsk |= GINTSTS_CONIDSTSCHNG; dwc2_writel(intmsk, hsotg->regs + GINTMSK); diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index c08c07a46bc6..8b688b041696 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -79,9 +79,9 @@ static void dwc2_enable_common_interrupts(struct dwc2_hsotg *hsotg) /* Enable the interrupts in the GINTMSK */ intmsk = GINTSTS_MODEMIS | GINTSTS_OTGINT; - if (hsotg->params.host_dma <= 0) + if (!hsotg->params.host_dma) intmsk |= GINTSTS_RXFLVL; - if (hsotg->params.external_id_pin_ctl <= 0) + if (!hsotg->params.external_id_pin_ctl) intmsk |= GINTSTS_CONIDSTSCHNG; intmsk |= GINTSTS_WKUPINT | GINTSTS_USBSUSP | @@ -100,7 +100,7 @@ static void dwc2_init_fs_ls_pclk_sel(struct dwc2_hsotg *hsotg) if ((hsotg->hw_params.hs_phy_type == GHWCFG2_HS_PHY_TYPE_ULPI && hsotg->hw_params.fs_phy_type == GHWCFG2_FS_PHY_TYPE_DEDICATED && -hsotg->params.ulpi_fs_ls > 0) || +hsotg->params.ulpi_fs_ls) || hsotg->params.phy_type == DWC2_PHY_TYPE_PARAM
[PATCH v3 16/24] usb: dwc2: Show dr_mode via debugfs
Show the value of dr_mode via a debufs file. Signed-off-by: John Youn --- drivers/usb/dwc2/debugfs.c | 29 + 1 file changed, 29 insertions(+) diff --git a/drivers/usb/dwc2/debugfs.c b/drivers/usb/dwc2/debugfs.c index 57747b0df595..794b959a7c8c 100644 --- a/drivers/usb/dwc2/debugfs.c +++ b/drivers/usb/dwc2/debugfs.c @@ -839,6 +839,29 @@ static const struct file_operations hw_params_fops = { .release= single_release, }; +static int dr_mode_show(struct seq_file *seq, void *v) +{ + struct dwc2_hsotg *hsotg = seq->private; + const char *dr_mode = ""; + + device_property_read_string(hsotg->dev, "dr_mode", &dr_mode); + seq_printf(seq, "%s\n", dr_mode); + return 0; +} + +static int dr_mode_open(struct inode *inode, struct file *file) +{ + return single_open(file, dr_mode_show, inode->i_private); +} + +static const struct file_operations dr_mode_fops = { + .owner = THIS_MODULE, + .open = dr_mode_open, + .read = seq_read, + .llseek = seq_lseek, + .release= single_release, +}; + int dwc2_debugfs_init(struct dwc2_hsotg *hsotg) { int ret; @@ -863,6 +886,12 @@ int dwc2_debugfs_init(struct dwc2_hsotg *hsotg) dev_err(hsotg->dev, "%s: failed to create hw_params\n", __func__); + file = debugfs_create_file("dr_mode", 0444, + hsotg->debug_root, + hsotg, &dr_mode_fops); + if (IS_ERR(file)) + dev_err(hsotg->dev, "%s: failed to create dr_mode\n", __func__); + /* Add gadget debugfs nodes */ dwc2_hsotg_create_debug(hsotg); -- 2.11.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 v3 15/24] usb: dwc2: Remove debug prints in params.c
Remove debugging prints to show params. Signed-off-by: John Youn --- drivers/usb/dwc2/params.c | 56 --- 1 file changed, 56 deletions(-) diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c index 0e7f0f92c18f..620b02723f0d 100644 --- a/drivers/usb/dwc2/params.c +++ b/drivers/usb/dwc2/params.c @@ -513,8 +513,6 @@ static void dwc2_get_host_hwparams(struct dwc2_hsotg *hsotg) gnptxfsiz = dwc2_readl(hsotg->regs + GNPTXFSIZ); hptxfsiz = dwc2_readl(hsotg->regs + HPTXFSIZ); - dev_dbg(hsotg->dev, "gnptxfsiz=%08x\n", gnptxfsiz); - dev_dbg(hsotg->dev, "hptxfsiz=%08x\n", hptxfsiz); if (forced) dwc2_clear_force_mode(hsotg); @@ -542,7 +540,6 @@ static void dwc2_get_dev_hwparams(struct dwc2_hsotg *hsotg) forced = dwc2_force_mode_if_needed(hsotg, false); gnptxfsiz = dwc2_readl(hsotg->regs + GNPTXFSIZ); - dev_dbg(hsotg->dev, "gnptxfsiz=%08x\n", gnptxfsiz); if (forced) dwc2_clear_force_mode(hsotg); @@ -588,12 +585,6 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg) hwcfg4 = dwc2_readl(hsotg->regs + GHWCFG4); grxfsiz = dwc2_readl(hsotg->regs + GRXFSIZ); - dev_dbg(hsotg->dev, "hwcfg1=%08x\n", hwcfg1); - dev_dbg(hsotg->dev, "hwcfg2=%08x\n", hwcfg2); - dev_dbg(hsotg->dev, "hwcfg3=%08x\n", hwcfg3); - dev_dbg(hsotg->dev, "hwcfg4=%08x\n", hwcfg4); - dev_dbg(hsotg->dev, "grxfsiz=%08x\n", grxfsiz); - /* * Host specific hardware parameters. Reading these parameters * requires the controller to be in host mode. The mode will @@ -653,53 +644,6 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg) hw->rx_fifo_size = (grxfsiz & GRXFSIZ_DEPTH_MASK) >> GRXFSIZ_DEPTH_SHIFT; - dev_dbg(hsotg->dev, "Detected values from hardware:\n"); - dev_dbg(hsotg->dev, " op_mode=%d\n", - hw->op_mode); - dev_dbg(hsotg->dev, " arch=%d\n", - hw->arch); - dev_dbg(hsotg->dev, " dma_desc_enable=%d\n", - hw->dma_desc_enable); - dev_dbg(hsotg->dev, " power_optimized=%d\n", - hw->power_optimized); - dev_dbg(hsotg->dev, " i2c_enable=%d\n", - hw->i2c_enable); - dev_dbg(hsotg->dev, " hs_phy_type=%d\n", - hw->hs_phy_type); - dev_dbg(hsotg->dev, " fs_phy_type=%d\n", - hw->fs_phy_type); - dev_dbg(hsotg->dev, " utmi_phy_data_width=%d\n", - hw->utmi_phy_data_width); - dev_dbg(hsotg->dev, " num_dev_ep=%d\n", - hw->num_dev_ep); - dev_dbg(hsotg->dev, " num_dev_perio_in_ep=%d\n", - hw->num_dev_perio_in_ep); - dev_dbg(hsotg->dev, " host_channels=%d\n", - hw->host_channels); - dev_dbg(hsotg->dev, " max_transfer_size=%d\n", - hw->max_transfer_size); - dev_dbg(hsotg->dev, " max_packet_count=%d\n", - hw->max_packet_count); - dev_dbg(hsotg->dev, " nperio_tx_q_depth=0x%0x\n", - hw->nperio_tx_q_depth); - dev_dbg(hsotg->dev, " host_perio_tx_q_depth=0x%0x\n", - hw->host_perio_tx_q_depth); - dev_dbg(hsotg->dev, " dev_token_q_depth=0x%0x\n", - hw->dev_token_q_depth); - dev_dbg(hsotg->dev, " enable_dynamic_fifo=%d\n", - hw->enable_dynamic_fifo); - dev_dbg(hsotg->dev, " en_multiple_tx_fifo=%d\n", - hw->en_multiple_tx_fifo); - dev_dbg(hsotg->dev, " total_fifo_size=%d\n", - hw->total_fifo_size); - dev_dbg(hsotg->dev, " rx_fifo_size=%d\n", - hw->rx_fifo_size); - dev_dbg(hsotg->dev, " host_nperio_tx_fifo_size=%d\n", - hw->host_nperio_tx_fifo_size); - dev_dbg(hsotg->dev, " host_perio_tx_fifo_size=%d\n", - hw->host_perio_tx_fifo_size); - dev_dbg(hsotg->dev, "\n"); - return 0; } -- 2.11.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 v3 14/24] usb: dwc2: Add debugfs file to show params
Show the core params and hardware params. Signed-off-by: John Youn --- drivers/usb/dwc2/debugfs.c | 127 + 1 file changed, 127 insertions(+) diff --git a/drivers/usb/dwc2/debugfs.c b/drivers/usb/dwc2/debugfs.c index cad621f02972..57747b0df595 100644 --- a/drivers/usb/dwc2/debugfs.c +++ b/drivers/usb/dwc2/debugfs.c @@ -725,6 +725,120 @@ static const struct debugfs_reg32 dwc2_regs[] = { dump_register(HCDMAB(15)), }; +#define print_param(_seq, _ptr, _param) \ +seq_printf((_seq), "%-30s: %d\n", #_param, (_ptr)->_param) + +#define print_param_hex(_seq, _ptr, _param) \ +seq_printf((_seq), "%-30s: 0x%x\n", #_param, (_ptr)->_param) + +static int params_show(struct seq_file *seq, void *v) +{ + struct dwc2_hsotg *hsotg = seq->private; + struct dwc2_core_params *p = &hsotg->params; + int i; + + print_param(seq, p, otg_cap); + print_param(seq, p, dma_desc_enable); + print_param(seq, p, dma_desc_fs_enable); + print_param(seq, p, speed); + print_param(seq, p, enable_dynamic_fifo); + print_param(seq, p, en_multiple_tx_fifo); + print_param(seq, p, host_rx_fifo_size); + print_param(seq, p, host_nperio_tx_fifo_size); + print_param(seq, p, host_perio_tx_fifo_size); + print_param(seq, p, max_transfer_size); + print_param(seq, p, max_packet_count); + print_param(seq, p, host_channels); + print_param(seq, p, phy_type); + print_param(seq, p, phy_utmi_width); + print_param(seq, p, phy_ulpi_ddr); + print_param(seq, p, phy_ulpi_ext_vbus); + print_param(seq, p, i2c_enable); + print_param(seq, p, ulpi_fs_ls); + print_param(seq, p, host_support_fs_ls_low_power); + print_param(seq, p, host_ls_low_power_phy_clk); + print_param(seq, p, ts_dline); + print_param(seq, p, reload_ctl); + print_param_hex(seq, p, ahbcfg); + print_param(seq, p, uframe_sched); + print_param(seq, p, external_id_pin_ctl); + print_param(seq, p, hibernation); + print_param(seq, p, host_dma); + print_param(seq, p, g_dma); + print_param(seq, p, g_dma_desc); + print_param(seq, p, g_rx_fifo_size); + print_param(seq, p, g_np_tx_fifo_size); + + for (i = 0; i < MAX_EPS_CHANNELS; i++) { + char str[32]; + + snprintf(str, 32, "g_tx_fifo_size[%d]", i); + seq_printf(seq, "%-30s: %d\n", str, p->g_tx_fifo_size[i]); + } + + return 0; +} + +static int params_open(struct inode *inode, struct file *file) +{ + return single_open(file, params_show, inode->i_private); +} + +static const struct file_operations params_fops = { + .owner = THIS_MODULE, + .open = params_open, + .read = seq_read, + .llseek = seq_lseek, + .release= single_release, +}; + +static int hw_params_show(struct seq_file *seq, void *v) +{ + struct dwc2_hsotg *hsotg = seq->private; + struct dwc2_hw_params *hw = &hsotg->hw_params; + + print_param(seq, hw, op_mode); + print_param(seq, hw, arch); + print_param(seq, hw, dma_desc_enable); + print_param(seq, hw, enable_dynamic_fifo); + print_param(seq, hw, en_multiple_tx_fifo); + print_param(seq, hw, rx_fifo_size); + print_param(seq, hw, host_nperio_tx_fifo_size); + print_param(seq, hw, dev_nperio_tx_fifo_size); + print_param(seq, hw, host_perio_tx_fifo_size); + print_param(seq, hw, nperio_tx_q_depth); + print_param(seq, hw, host_perio_tx_q_depth); + print_param(seq, hw, dev_token_q_depth); + print_param(seq, hw, max_transfer_size); + print_param(seq, hw, max_packet_count); + print_param(seq, hw, host_channels); + print_param(seq, hw, hs_phy_type); + print_param(seq, hw, fs_phy_type); + print_param(seq, hw, i2c_enable); + print_param(seq, hw, num_dev_ep); + print_param(seq, hw, num_dev_perio_in_ep); + print_param(seq, hw, total_fifo_size); + print_param(seq, hw, power_optimized); + print_param(seq, hw, utmi_phy_data_width); + print_param_hex(seq, hw, snpsid); + print_param_hex(seq, hw, dev_ep_dirs); + + return 0; +} + +static int hw_params_open(struct inode *inode, struct file *file) +{ + return single_open(file, hw_params_show, inode->i_private); +} + +static const struct file_operations hw_params_fops = { + .owner = THIS_MODULE, + .open = hw_params_open, + .read = seq_read, + .llseek = seq_lseek, + .release= single_release, +}; + int dwc2_debugfs_init(struct dwc2_hsotg *hsotg) { int ret; @@ -736,6 +850,19 @@ int dwc2_debugfs_init(struct dwc2_hsotg *hsotg) goto err0; } + file = debugfs_create_file("params", 0444, + hsotg->debug_root, +
[PATCH v3 13/24] usb: dwc2: Remove unnecessary parameters
Further reduce the set of parameters set by platforms. Many of them are unnecessary as they should be reported by hardware. They should only need to be overridden if there is a problem. Signed-off-by: John Youn --- drivers/usb/dwc2/params.c | 11 --- 1 file changed, 11 deletions(-) diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c index b872f6128cc2..0e7f0f92c18f 100644 --- a/drivers/usb/dwc2/params.c +++ b/drivers/usb/dwc2/params.c @@ -42,19 +42,9 @@ static void dwc2_set_bcm_params(struct dwc2_hsotg *hsotg) { struct dwc2_core_params *p = &hsotg->params; - p->otg_cap = DWC2_CAP_PARAM_HNP_SRP_CAPABLE; - p->speed = DWC2_SPEED_PARAM_HIGH; p->host_rx_fifo_size = 774; - p->host_nperio_tx_fifo_size = 256; - p->host_perio_tx_fifo_size = 512; p->max_transfer_size = 65535; p->max_packet_count = 511; - p->host_channels = 8; - p->phy_type = 1; - p->phy_utmi_width = 8; - p->i2c_enable = false; - p->host_ls_low_power_phy_clk = false; - p->reload_ctl = false; p->ahbcfg = 0x10; p->uframe_sched = false; } @@ -74,7 +64,6 @@ static void dwc2_set_his_params(struct dwc2_hsotg *hsotg) p->phy_type = DWC2_PHY_TYPE_PARAM_UTMI; p->phy_utmi_width = 8; p->i2c_enable = false; - p->host_ls_low_power_phy_clk = false; p->reload_ctl = false; p->ahbcfg = GAHBCFG_HBSTLEN_INCR16 << GAHBCFG_HBSTLEN_SHIFT; -- 2.11.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 v3 11/24] usb: dwc2: Remove platform static params
Remove the platform-specific static param structs and set only those params that are necessary for each platform. Signed-off-by: John Youn --- drivers/usb/dwc2/params.c | 262 +++--- 1 file changed, 108 insertions(+), 154 deletions(-) diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c index 6ea9d2dafd74..949d988f13cc 100644 --- a/drivers/usb/dwc2/params.c +++ b/drivers/usb/dwc2/params.c @@ -38,166 +38,111 @@ #include "core.h" -static const struct dwc2_core_params params_hi6220 = { - .otg_cap= 2,/* No HNP/SRP capable */ - .dma_desc_enable= 0, - .dma_desc_fs_enable = 0, - .speed = 0,/* High Speed */ - .enable_dynamic_fifo= 1, - .en_multiple_tx_fifo= 1, - .host_rx_fifo_size = 512, - .host_nperio_tx_fifo_size = 512, - .host_perio_tx_fifo_size= 512, - .max_transfer_size = 65535, - .max_packet_count = 511, - .host_channels = 16, - .phy_type = 1,/* UTMI */ - .phy_utmi_width = 8, - .phy_ulpi_ddr = 0,/* Single */ - .phy_ulpi_ext_vbus = 0, - .i2c_enable = 0, - .ulpi_fs_ls = 0, - .host_support_fs_ls_low_power = 0, - .host_ls_low_power_phy_clk = 0,/* 48 MHz */ - .ts_dline = 0, - .reload_ctl = 0, - .ahbcfg = GAHBCFG_HBSTLEN_INCR16 << - GAHBCFG_HBSTLEN_SHIFT, - .uframe_sched = 0, - .external_id_pin_ctl= -1, - .hibernation= -1, -}; +static void dwc2_set_bcm_params(struct dwc2_hsotg *hsotg) +{ + struct dwc2_core_params *p = &hsotg->params; -static const struct dwc2_core_params params_bcm2835 = { - .otg_cap= 0,/* HNP/SRP capable */ - .dma_desc_enable= 0, - .dma_desc_fs_enable = 0, - .speed = 0,/* High Speed */ - .enable_dynamic_fifo= 1, - .en_multiple_tx_fifo= 1, - .host_rx_fifo_size = 774, /* 774 DWORDs */ - .host_nperio_tx_fifo_size = 256, /* 256 DWORDs */ - .host_perio_tx_fifo_size= 512, /* 512 DWORDs */ - .max_transfer_size = 65535, - .max_packet_count = 511, - .host_channels = 8, - .phy_type = 1,/* UTMI */ - .phy_utmi_width = 8,/* 8 bits */ - .phy_ulpi_ddr = 0,/* Single */ - .phy_ulpi_ext_vbus = 0, - .i2c_enable = 0, - .ulpi_fs_ls = 0, - .host_support_fs_ls_low_power = 0, - .host_ls_low_power_phy_clk = 0,/* 48 MHz */ - .ts_dline = 0, - .reload_ctl = 0, - .ahbcfg = 0x10, - .uframe_sched = 0, - .external_id_pin_ctl= -1, - .hibernation= -1, -}; + p->otg_cap = DWC2_CAP_PARAM_HNP_SRP_CAPABLE; + p->speed = DWC2_SPEED_PARAM_HIGH; + p->host_rx_fifo_size = 774; + p->host_nperio_tx_fifo_size = 256; + p->host_perio_tx_fifo_size = 512; + p->max_transfer_size = 65535; + p->max_packet_count = 511; + p->host_channels = 8; + p->phy_type = 1; + p->phy_utmi_width = 8; + p->i2c_enable = false; + p->host_ls_low_power_phy_clk = 0; + p->reload_ctl = false; + p->ahbcfg = 0x10; + p->uframe_sched = false; +} -static const struct dwc2_core_params params_rk3066 = { - .otg_cap= 2,/* non-HNP/non-SRP */ - .dma_desc_enable= 0, - .dma_desc_fs_enable = 0, - .speed = -1, - .enable_dynamic_fifo= 1, - .en_multiple_tx_fifo= -1, - .host_rx_fifo_size = 525, /* 525 DWORDs */ - .host_nperio_tx_fifo_size = 128, /* 128 DWORDs */ - .host_perio_tx_fifo_size= 256, /* 256 DWORDs */ - .max_transfer_size = -1, - .max_packet_count = -1, - .host_channels = -1, - .phy_type = -1, - .phy_utmi_width = -1, - .phy_ulpi_ddr = -1, - .phy_ulpi_ext_vbus = -1, - .i2c_enable = -1, - .ulpi_fs_ls = -1, - .host_support_fs_ls_low_power = -1,
[PATCH v3 09/24] usb: dwc2: Rearrange param structure members
Group the members by global, host, and gadget params. Formatting and organizational change only. Signed-off-by: John Youn --- drivers/usb/dwc2/core.h | 51 ++--- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index c6f62648ad97..011e88017ce8 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -457,53 +457,48 @@ struct dwc2_core_params { #define DWC2_CAP_PARAM_SRP_ONLY_CAPABLE1 #define DWC2_CAP_PARAM_NO_HNP_SRP_CAPABLE 2 - bool dma_desc_enable; - bool dma_desc_fs_enable; - u8 speed; -#define DWC2_SPEED_PARAM_HIGH 0 -#define DWC2_SPEED_PARAM_FULL 1 -#define DWC2_SPEED_PARAM_LOW 2 - - bool enable_dynamic_fifo; - bool en_multiple_tx_fifo; - u16 host_rx_fifo_size; - u16 host_nperio_tx_fifo_size; - u16 host_perio_tx_fifo_size; - u32 max_transfer_size; - u16 max_packet_count; - u8 host_channels; u8 phy_type; #define DWC2_PHY_TYPE_PARAM_FS 0 #define DWC2_PHY_TYPE_PARAM_UTMI 1 #define DWC2_PHY_TYPE_PARAM_ULPI 2 + u8 speed; +#define DWC2_SPEED_PARAM_HIGH 0 +#define DWC2_SPEED_PARAM_FULL 1 +#define DWC2_SPEED_PARAM_LOW 2 + u8 phy_utmi_width; bool phy_ulpi_ddr; bool phy_ulpi_ext_vbus; -#define DWC2_PHY_ULPI_INTERNAL_VBUS0 -#define DWC2_PHY_ULPI_EXTERNAL_VBUS1 +#define DWC2_PHY_ULPI_INTERNAL_VBUS0 +#define DWC2_PHY_ULPI_EXTERNAL_VBUS1 + bool enable_dynamic_fifo; + bool en_multiple_tx_fifo; bool i2c_enable; bool ulpi_fs_ls; - bool host_support_fs_ls_low_power; - bool host_ls_low_power_phy_clk; -#define DWC2_HOST_LS_LOW_POWER_PHY_CLK_PARAM_48MHZ 0 -#define DWC2_HOST_LS_LOW_POWER_PHY_CLK_PARAM_6MHZ 1 - bool ts_dline; bool reload_ctl; - u32 ahbcfg; bool uframe_sched; bool external_id_pin_ctl; bool hibernation; - - /* -* The following parameters are *only* set via device -* properties and cannot be set directly in this structure. -*/ + u16 max_packet_count; + u32 max_transfer_size; + u32 ahbcfg; /* Host parameters */ bool host_dma; + bool dma_desc_enable; + bool dma_desc_fs_enable; + bool host_support_fs_ls_low_power; + bool host_ls_low_power_phy_clk; +#define DWC2_HOST_LS_LOW_POWER_PHY_CLK_PARAM_48MHZ 0 +#define DWC2_HOST_LS_LOW_POWER_PHY_CLK_PARAM_6MHZ 1 + + u8 host_channels; + u16 host_rx_fifo_size; + u16 host_nperio_tx_fifo_size; + u16 host_perio_tx_fifo_size; /* Gadget parameters */ bool g_dma; -- 2.11.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 v3 10/24] usb: dwc2: Check core parameters
Check that core parameters have valid values and adjust them if they aren't. Signed-off-by: John Youn --- drivers/usb/dwc2/params.c | 185 ++ 1 file changed, 185 insertions(+) diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c index 4416eae09647..6ea9d2dafd74 100644 --- a/drivers/usb/dwc2/params.c +++ b/drivers/usb/dwc2/params.c @@ -377,6 +377,189 @@ static void dwc2_get_device_properties(struct dwc2_hsotg *hsotg) } } +static void dwc2_check_param_otg_cap(struct dwc2_hsotg *hsotg) +{ + int valid = 1; + + switch (hsotg->params.otg_cap) { + case DWC2_CAP_PARAM_HNP_SRP_CAPABLE: + if (hsotg->hw_params.op_mode != GHWCFG2_OP_MODE_HNP_SRP_CAPABLE) + valid = 0; + break; + case DWC2_CAP_PARAM_SRP_ONLY_CAPABLE: + switch (hsotg->hw_params.op_mode) { + case GHWCFG2_OP_MODE_HNP_SRP_CAPABLE: + case GHWCFG2_OP_MODE_SRP_ONLY_CAPABLE: + case GHWCFG2_OP_MODE_SRP_CAPABLE_DEVICE: + case GHWCFG2_OP_MODE_SRP_CAPABLE_HOST: + break; + default: + valid = 0; + break; + } + break; + case DWC2_CAP_PARAM_NO_HNP_SRP_CAPABLE: + /* always valid */ + break; + default: + valid = 0; + break; + } + + if (!valid) + dwc2_set_param_otg_cap(hsotg); +} + +static void dwc2_check_param_phy_type(struct dwc2_hsotg *hsotg) +{ + int valid = 0; + u32 hs_phy_type; + u32 fs_phy_type; + + hs_phy_type = hsotg->hw_params.hs_phy_type; + fs_phy_type = hsotg->hw_params.fs_phy_type; + + switch (hsotg->params.phy_type) { + case DWC2_PHY_TYPE_PARAM_FS: + if (fs_phy_type == GHWCFG2_FS_PHY_TYPE_DEDICATED) + valid = 1; + break; + case DWC2_PHY_TYPE_PARAM_UTMI: + if ((hs_phy_type == GHWCFG2_HS_PHY_TYPE_UTMI) || + (hs_phy_type == GHWCFG2_HS_PHY_TYPE_UTMI_ULPI)) + valid = 1; + break; + case DWC2_PHY_TYPE_PARAM_ULPI: + if ((hs_phy_type == GHWCFG2_HS_PHY_TYPE_UTMI) || + (hs_phy_type == GHWCFG2_HS_PHY_TYPE_UTMI_ULPI)) + valid = 1; + break; + default: + break; + } + + if (!valid) + dwc2_set_param_phy_type(hsotg); +} + +static void dwc2_check_param_speed(struct dwc2_hsotg *hsotg) +{ + int valid = 1; + int phy_type = hsotg->params.phy_type; + int speed = hsotg->params.speed; + + switch (speed) { + case DWC2_SPEED_PARAM_HIGH: + if ((hsotg->params.speed == DWC2_SPEED_PARAM_HIGH) && + (phy_type == DWC2_PHY_TYPE_PARAM_FS)) + valid = 0; + break; + case DWC2_SPEED_PARAM_FULL: + case DWC2_SPEED_PARAM_LOW: + break; + default: + valid = 0; + break; + } + + if (!valid) + dwc2_set_param_speed(hsotg); +} + +static void dwc2_check_param_phy_utmi_width(struct dwc2_hsotg *hsotg) +{ + int valid = 0; + int param = hsotg->params.phy_utmi_width; + int width = hsotg->hw_params.utmi_phy_data_width; + + switch (width) { + case GHWCFG4_UTMI_PHY_DATA_WIDTH_8: + valid = (param == 8); + break; + case GHWCFG4_UTMI_PHY_DATA_WIDTH_16: + valid = (param == 16); + break; + case GHWCFG4_UTMI_PHY_DATA_WIDTH_8_OR_16: + valid = (param == 8 || param == 16); + break; + } + + if (!valid) + dwc2_set_param_phy_utmi_width(hsotg); +} + +#define CHECK_RANGE(_param, _min, _max, _def) do { \ + if ((hsotg->params._param) < (_min) || \ + (hsotg->params._param) > (_max)) { \ + dev_warn(hsotg->dev, "%s: Invalid parameter %s=%d\n", \ +__func__, #_param, hsotg->params._param); \ + hsotg->params._param = (_def); \ + } \ + } while (0) + +#define CHECK_BOOL(_param, _check) do { \ + if (hsotg->params._param && !(_check)) {\ + dev_warn(hsotg->dev, "%s: Invalid parameter %s=%d\n", \ +__func__, #_param, hsotg->params._param); \ + hsotg->params._param = false; \ + } \ + } while (0) + +static void dwc2_check_params(struct dwc2_hso
[PATCH v3 07/24] usb: dwc2: Get device properties
After setting the default core parameter values, read in the device properties and modify core parameter values if needed. Signed-off-by: John Youn --- drivers/usb/dwc2/params.c | 35 +++ 1 file changed, 35 insertions(+) diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c index 6729f14d25de..4416eae09647 100644 --- a/drivers/usb/dwc2/params.c +++ b/drivers/usb/dwc2/params.c @@ -343,6 +343,40 @@ static void dwc2_set_default_params(struct dwc2_hsotg *hsotg) } } +/** + * dwc2_get_device_properties() - Read in device properties. + * + * Read in the device properties and adjust core parameters if needed. + */ +static void dwc2_get_device_properties(struct dwc2_hsotg *hsotg) +{ + struct dwc2_core_params *p = &hsotg->params; + int num; + + if ((hsotg->dr_mode == USB_DR_MODE_PERIPHERAL) || + (hsotg->dr_mode == USB_DR_MODE_OTG)) { + device_property_read_u32(hsotg->dev, "g-rx-fifo-size", +&p->g_rx_fifo_size); + + device_property_read_u32(hsotg->dev, "g-np-tx-fifo-size", +&p->g_np_tx_fifo_size); + + num = device_property_read_u32_array(hsotg->dev, +"g-tx-fifo-size", +NULL, 0); + + if (num > 0) { + num = min(num, 15); + memset(p->g_tx_fifo_size, 0, + sizeof(p->g_tx_fifo_size)); + device_property_read_u32_array(hsotg->dev, + "g-tx-fifo-size", + &p->g_tx_fifo_size[1], + num); + } + } +} + /* * Gets host hardware parameters. Forces host mode if not currently in * host mode. Should be called immediately after a core soft reset in @@ -555,6 +589,7 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg) int dwc2_init_params(struct dwc2_hsotg *hsotg) { dwc2_set_default_params(hsotg); + dwc2_get_device_properties(hsotg); return 0; } -- 2.11.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 v3 08/24] usb: dwc2: Update parameter types
Update the param types to appropriately sized ints and bools. Signed-off-by: John Youn --- drivers/usb/dwc2/core.h | 52 - 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index 7256b9f7097a..c6f62648ad97 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -452,50 +452,50 @@ enum dwc2_ep0_state { * default described above. */ struct dwc2_core_params { - int otg_cap; + u8 otg_cap; #define DWC2_CAP_PARAM_HNP_SRP_CAPABLE 0 #define DWC2_CAP_PARAM_SRP_ONLY_CAPABLE1 #define DWC2_CAP_PARAM_NO_HNP_SRP_CAPABLE 2 - int dma_desc_enable; - int dma_desc_fs_enable; - int speed; + bool dma_desc_enable; + bool dma_desc_fs_enable; + u8 speed; #define DWC2_SPEED_PARAM_HIGH 0 #define DWC2_SPEED_PARAM_FULL 1 #define DWC2_SPEED_PARAM_LOW 2 - int enable_dynamic_fifo; - int en_multiple_tx_fifo; - int host_rx_fifo_size; - int host_nperio_tx_fifo_size; - int host_perio_tx_fifo_size; - int max_transfer_size; - int max_packet_count; - int host_channels; - int phy_type; + bool enable_dynamic_fifo; + bool en_multiple_tx_fifo; + u16 host_rx_fifo_size; + u16 host_nperio_tx_fifo_size; + u16 host_perio_tx_fifo_size; + u32 max_transfer_size; + u16 max_packet_count; + u8 host_channels; + u8 phy_type; #define DWC2_PHY_TYPE_PARAM_FS 0 #define DWC2_PHY_TYPE_PARAM_UTMI 1 #define DWC2_PHY_TYPE_PARAM_ULPI 2 - int phy_utmi_width; - int phy_ulpi_ddr; - int phy_ulpi_ext_vbus; + u8 phy_utmi_width; + bool phy_ulpi_ddr; + bool phy_ulpi_ext_vbus; #define DWC2_PHY_ULPI_INTERNAL_VBUS0 #define DWC2_PHY_ULPI_EXTERNAL_VBUS1 - int i2c_enable; - int ulpi_fs_ls; - int host_support_fs_ls_low_power; - int host_ls_low_power_phy_clk; + bool i2c_enable; + bool ulpi_fs_ls; + bool host_support_fs_ls_low_power; + bool host_ls_low_power_phy_clk; #define DWC2_HOST_LS_LOW_POWER_PHY_CLK_PARAM_48MHZ 0 #define DWC2_HOST_LS_LOW_POWER_PHY_CLK_PARAM_6MHZ 1 - int ts_dline; - int reload_ctl; - int ahbcfg; - int uframe_sched; - int external_id_pin_ctl; - int hibernation; + bool ts_dline; + bool reload_ctl; + u32 ahbcfg; + bool uframe_sched; + bool external_id_pin_ctl; + bool hibernation; /* * The following parameters are *only* set via device -- 2.11.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 v3 06/24] usb: dwc2: Set core parameters to default values
Initialize the core parameters to their default, auto-detected values. Remove all the previous dwc2_set_param* methods. Most of what this code is doing is handling defaults for "not set" values and other trivial checks. The checking can be simplified and will be done in a later commit. This allows us to change only those parameters that won't work with default settings. It also allows us to use non-int parameters. Signed-off-by: John Youn --- drivers/usb/dwc2/core.h | 4 - drivers/usb/dwc2/params.c | 990 -- 2 files changed, 75 insertions(+), 919 deletions(-) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index 73514f263e40..7256b9f7097a 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -452,10 +452,6 @@ enum dwc2_ep0_state { * default described above. */ struct dwc2_core_params { - /* -* Don't add any non-int members here, this will break -* dwc2_set_all_params! -*/ int otg_cap; #define DWC2_CAP_PARAM_HNP_SRP_CAPABLE 0 #define DWC2_CAP_PARAM_SRP_ONLY_CAPABLE1 diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c index 074f4061206a..6729f14d25de 100644 --- a/drivers/usb/dwc2/params.c +++ b/drivers/usb/dwc2/params.c @@ -187,42 +187,6 @@ static const struct dwc2_core_params params_amlogic = { .hibernation= -1, }; -static const struct dwc2_core_params params_default = { - .otg_cap= -1, - - /* -* Disable descriptor dma mode by default as the HW can support -* it, but does not support it for SPLIT transactions. -* Disable it for FS devices as well. -*/ - .dma_desc_enable= 0, - .dma_desc_fs_enable = 0, - - .speed = -1, - .enable_dynamic_fifo= -1, - .en_multiple_tx_fifo= -1, - .host_rx_fifo_size = -1, - .host_nperio_tx_fifo_size = -1, - .host_perio_tx_fifo_size= -1, - .max_transfer_size = -1, - .max_packet_count = -1, - .host_channels = -1, - .phy_type = -1, - .phy_utmi_width = -1, - .phy_ulpi_ddr = -1, - .phy_ulpi_ext_vbus = -1, - .i2c_enable = -1, - .ulpi_fs_ls = -1, - .host_support_fs_ls_low_power = -1, - .host_ls_low_power_phy_clk = -1, - .ts_dline = -1, - .reload_ctl = -1, - .ahbcfg = -1, - .uframe_sched = -1, - .external_id_pin_ctl= -1, - .hibernation= -1, -}; - const struct of_device_id dwc2_of_match_table[] = { { .compatible = "brcm,bcm2835-usb", .data = ¶ms_bcm2835 }, { .compatible = "hisilicon,hi6220-usb", .data = ¶ms_hi6220 }, @@ -238,913 +202,131 @@ const struct of_device_id dwc2_of_match_table[] = { }; MODULE_DEVICE_TABLE(of, dwc2_of_match_table); -static void dwc2_get_device_property(struct dwc2_hsotg *hsotg, -char *property, u8 size, u64 *value) +static void dwc2_set_param_otg_cap(struct dwc2_hsotg *hsotg) { - u32 val32; + u8 val; - switch (size) { - case 0: - *value = device_property_read_bool(hsotg->dev, property); + switch (hsotg->hw_params.op_mode) { + case GHWCFG2_OP_MODE_HNP_SRP_CAPABLE: + val = DWC2_CAP_PARAM_HNP_SRP_CAPABLE; break; - case 1: - case 2: - case 4: - if (device_property_read_u32(hsotg->dev, property, &val32)) - return; - - *value = val32; - break; - case 8: - if (device_property_read_u64(hsotg->dev, property, value)) - return; - + case GHWCFG2_OP_MODE_SRP_ONLY_CAPABLE: + case GHWCFG2_OP_MODE_SRP_CAPABLE_DEVICE: + case GHWCFG2_OP_MODE_SRP_CAPABLE_HOST: + val = DWC2_CAP_PARAM_SRP_ONLY_CAPABLE; break; default: - /* -* The size is checked by the only function that calls -* this so this should never happen. -*/ - WARN_ON(1); - return; - } -} - -static void dwc2_set_core_param(void *param, u8 size, u64 value) -{ - switch (size) { - case 0: - *((bool *)param) = !!value; - break; - case 1: - *((u8 *)param) = (u8)value; - break; - case 2: - *((u16 *)param) = (u16)value; - break; - case 4: - *((u32 *)param) = (u32)value; - break; - case 8: -
[PATCH v3 04/24] Revert "usb: dwc2: pci: Add AHB burst property for HAPS"
This reverts commit e0beae49474c ("usb: dwc2: pci: Add AHB burst property for HAPS"). This commit was inadvertently applied. Signed-off-by: John Youn --- drivers/usb/dwc2/pci.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/usb/dwc2/pci.c b/drivers/usb/dwc2/pci.c index f8bffda92495..fdeb8c7bf30a 100644 --- a/drivers/usb/dwc2/pci.c +++ b/drivers/usb/dwc2/pci.c @@ -67,7 +67,6 @@ static int dwc2_pci_quirks(struct pci_dev *pdev, struct platform_device *dwc2) if (pdev->vendor == PCI_VENDOR_ID_SYNOPSYS && pdev->device == PCI_PRODUCT_ID_HAPS_HSOTG) { struct property_entry properties[] = { - PROPERTY_ENTRY_STRING("snps,ahb-burst", "INCR"), { }, }; -- 2.11.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 v3 05/24] usb: dwc2: Remove unused otg_ver parameter
The otg_ver parameter only controls the SRP pulsing method and defaults to the 1.3 behavior. It is unused and can be removed. Signed-off-by: John Youn --- drivers/usb/dwc2/core.c | 5 - drivers/usb/dwc2/core.h | 9 - drivers/usb/dwc2/hcd.c| 3 --- drivers/usb/dwc2/params.c | 23 --- 4 files changed, 40 deletions(-) diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c index 0446f3d6d54a..0d322b7d4b28 100644 --- a/drivers/usb/dwc2/core.c +++ b/drivers/usb/dwc2/core.c @@ -751,11 +751,6 @@ bool dwc2_force_mode_if_needed(struct dwc2_hsotg *hsotg, bool host) return dwc2_force_mode(hsotg, host); } -u16 dwc2_get_otg_version(struct dwc2_hsotg *hsotg) -{ - return hsotg->params.otg_ver == 1 ? 0x0200 : 0x0103; -} - bool dwc2_is_controller_alive(struct dwc2_hsotg *hsotg) { if (dwc2_readl(hsotg->regs + GSNPSID) == 0x) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index 2fdd74d502c0..73514f263e40 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -298,9 +298,6 @@ enum dwc2_ep0_state { * 1 - SRP Only capable * 2 - No HNP/SRP capable (always available) * Defaults to best available option (0, 1, then 2) - * @otg_ver:OTG version supported - * 0 - 1.3 (default) - * 1 - 2.0 * @host_dma: Specifies whether to use slave or DMA mode for accessing * the data FIFOs. The driver will automatically detect the * value for this parameter if none is specified. @@ -464,7 +461,6 @@ struct dwc2_core_params { #define DWC2_CAP_PARAM_SRP_ONLY_CAPABLE1 #define DWC2_CAP_PARAM_NO_HNP_SRP_CAPABLE 2 - int otg_ver; int dma_desc_enable; int dma_desc_fs_enable; int speed; @@ -1175,11 +1171,6 @@ void dwc2_dump_dev_registers(struct dwc2_hsotg *hsotg); void dwc2_dump_host_registers(struct dwc2_hsotg *hsotg); void dwc2_dump_global_registers(struct dwc2_hsotg *hsotg); -/* - * Return OTG version - either 1.3 or 2.0 - */ -u16 dwc2_get_otg_version(struct dwc2_hsotg *hsotg); - /* Gadget defines */ #if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || \ IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE) diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 2c90b0867ee1..c08c07a46bc6 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -2260,10 +2260,7 @@ static int dwc2_core_init(struct dwc2_hsotg *hsotg, bool initial_setup) /* Program the GOTGCTL register */ otgctl = dwc2_readl(hsotg->regs + GOTGCTL); otgctl &= ~GOTGCTL_OTGVER; - if (hsotg->params.otg_ver > 0) - otgctl |= GOTGCTL_OTGVER; dwc2_writel(otgctl, hsotg->regs + GOTGCTL); - dev_dbg(hsotg->dev, "OTG VER PARAM: %d\n", hsotg->params.otg_ver); /* Clear the SRP success bit for FS-I2c */ hsotg->srp_success = 0; diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c index bcd1e19b4076..074f4061206a 100644 --- a/drivers/usb/dwc2/params.c +++ b/drivers/usb/dwc2/params.c @@ -40,7 +40,6 @@ static const struct dwc2_core_params params_hi6220 = { .otg_cap= 2,/* No HNP/SRP capable */ - .otg_ver= 0,/* 1.3 */ .dma_desc_enable= 0, .dma_desc_fs_enable = 0, .speed = 0,/* High Speed */ @@ -71,7 +70,6 @@ static const struct dwc2_core_params params_hi6220 = { static const struct dwc2_core_params params_bcm2835 = { .otg_cap= 0,/* HNP/SRP capable */ - .otg_ver= 0,/* 1.3 */ .dma_desc_enable= 0, .dma_desc_fs_enable = 0, .speed = 0,/* High Speed */ @@ -101,7 +99,6 @@ static const struct dwc2_core_params params_bcm2835 = { static const struct dwc2_core_params params_rk3066 = { .otg_cap= 2,/* non-HNP/non-SRP */ - .otg_ver= -1, .dma_desc_enable= 0, .dma_desc_fs_enable = 0, .speed = -1, @@ -132,7 +129,6 @@ static const struct dwc2_core_params params_rk3066 = { static const struct dwc2_core_params params_ltq = { .otg_cap= 2,/* non-HNP/non-SRP */ - .otg_ver= -1, .dma_desc_enable= -1, .dma_desc_fs_enable = -1, .speed = -1, @@ -163,7 +159,6 @@ static const struct dwc2_core_params params_ltq = { static const struct dwc2_core_params params_amlogic = { .otg_cap= DWC2_CAP_PARAM_NO_HNP_SRP_CAPABLE, - .otg_ver= -1,
[PATCH v3 03/24] Revert "usb: dwc2: Use the ahb_burst param"
This reverts commit 70033c5ec15b ("usb: dwc2: Use the ahb_burst param"). This commit was inadvertently applied. Signed-off-by: John Youn --- drivers/usb/dwc2/gadget.c | 2 +- drivers/usb/dwc2/hcd.c| 8 +--- drivers/usb/dwc2/params.c | 10 ++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index c7e1ab84a9bc..4e15ff2f59db 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -3234,7 +3234,7 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg, if (using_dma(hsotg)) { dwc2_writel(GAHBCFG_GLBL_INTR_EN | GAHBCFG_DMA_EN | - (hsotg->params.ahb_burst << GAHBCFG_HBSTLEN_SHIFT), + (GAHBCFG_HBSTLEN_INCR4 << GAHBCFG_HBSTLEN_SHIFT), hsotg->regs + GAHBCFG); /* Set DDMA mode support in the core if needed */ diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 2173f979705a..2c90b0867ee1 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -273,9 +273,11 @@ static int dwc2_gahbcfg_init(struct dwc2_hsotg *hsotg) case GHWCFG2_INT_DMA_ARCH: dev_dbg(hsotg->dev, "Internal DMA Mode\n"); - ahbcfg &= ~GAHBCFG_HBSTLEN_MASK; - ahbcfg |= (hsotg->params.ahb_burst << - GAHBCFG_HBSTLEN_SHIFT); + if (hsotg->params.ahbcfg != -1) { + ahbcfg &= GAHBCFG_CTRL_MASK; + ahbcfg |= hsotg->params.ahbcfg & + ~GAHBCFG_CTRL_MASK; + } break; case GHWCFG2_SLAVE_ONLY_ARCH: diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c index aba8ee83..bcd1e19b4076 100644 --- a/drivers/usb/dwc2/params.c +++ b/drivers/usb/dwc2/params.c @@ -969,6 +969,15 @@ static void dwc2_set_param_reload_ctl(struct dwc2_hsotg *hsotg, int val) hsotg->params.reload_ctl = val; } +static void dwc2_set_param_ahbcfg(struct dwc2_hsotg *hsotg, int val) +{ + if (val != -1) + hsotg->params.ahbcfg = val; + else + hsotg->params.ahbcfg = GAHBCFG_HBSTLEN_INCR4 << + GAHBCFG_HBSTLEN_SHIFT; +} + static void dwc2_set_param_otg_ver(struct dwc2_hsotg *hsotg, int val) { if (DWC2_OUT_OF_BOUNDS(val, 0, 1)) { @@ -1144,6 +1153,7 @@ static void dwc2_set_parameters(struct dwc2_hsotg *hsotg, dwc2_set_param_en_multiple_tx_fifo(hsotg, params->en_multiple_tx_fifo); dwc2_set_param_reload_ctl(hsotg, params->reload_ctl); + dwc2_set_param_ahbcfg(hsotg, params->ahbcfg); dwc2_set_param_otg_ver(hsotg, params->otg_ver); dwc2_set_param_uframe_sched(hsotg, params->uframe_sched); dwc2_set_param_external_id_pin_ctl(hsotg, params->external_id_pin_ctl); -- 2.11.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 v3 00/24] usb: dwc2: Rework params, FIFO, and other changes
Hi Felipe, This is a consolidation, rebase, and resend of several dwc2 patch series that were submitted to this list in the past month or so. See v2 [1] of this series for a summary. This latest revision is rebased to apply cleanly to your latest testing/next. This series also rebases the FIFO series from Sevak [2]. So there's no need to pick that up separately. The first 4 patches revert commits that were mistakenly added to your next branch. Regards, John [1] https://www.spinics.net/lists/linux-usb/msg152258.html [2] https://www.spinics.net/lists/linux-usb/msg152322.html Chen Yu (2): usb: dwc2: Force port resume on switching to device mode usb: dwc2: Add a quirk to allow speed negotiation for Hisilicon Hi6220 John Stultz (2): usb: dwc2: Avoid sleeping while holding hsotg->lock usb: dwc2: Workaround case where GOTGCTL state is wrong John Youn (16): Revert "Documentation: devictree: dwc2: Add AHB burst binding" Revert "usb: dwc2: Read in the AHB burst property" Revert "usb: dwc2: Use the ahb_burst param" Revert "usb: dwc2: pci: Add AHB burst property for HAPS" usb: dwc2: Remove unused otg_ver parameter usb: dwc2: Set core parameters to default values usb: dwc2: Get device properties usb: dwc2: Update parameter types usb: dwc2: Rearrange param structure members usb: dwc2: Check core parameters usb: dwc2: Remove platform static params usb: dwc2: Fix usage of bool params usb: dwc2: Remove unnecessary parameters usb: dwc2: Add debugfs file to show params usb: dwc2: Remove debug prints in params.c usb: dwc2: Show dr_mode via debugfs Nicholas Mc Guire (1): usb: dwc2: host: use msleep() for long delay Sevak Arakelyan (3): usb: dwc2: host: Correct snpsid checking for GDFIFOCFG usb: dwc2: gadget: Set TX FIFO depths to calculated defaults usb: dwc2: gadget: Add checking for g-tx-fifo-size parameter Documentation/devicetree/bindings/usb/dwc2.txt |2 - drivers/usb/dwc2/core.c| 17 +- drivers/usb/dwc2/core.h| 118 +- drivers/usb/dwc2/core_intr.c |2 +- drivers/usb/dwc2/debugfs.c | 156 +++ drivers/usb/dwc2/gadget.c | 99 +- drivers/usb/dwc2/hcd.c | 203 +++- drivers/usb/dwc2/hcd_ddma.c|4 +- drivers/usb/dwc2/hcd_intr.c| 45 +- drivers/usb/dwc2/hcd_queue.c | 14 +- drivers/usb/dwc2/params.c | 1511 ++-- drivers/usb/dwc2/pci.c |1 - 12 files changed, 845 insertions(+), 1327 deletions(-) -- 2.11.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 v3 02/24] Revert "usb: dwc2: Read in the AHB burst property"
This reverts commit 605f91f9f5a6 ("usb: dwc2: Read in the AHB burst property"). This commit was inadvertently applied. Signed-off-by: John Youn --- drivers/usb/dwc2/core.h | 9 --- drivers/usb/dwc2/params.c | 69 --- 2 files changed, 78 deletions(-) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index 570a8004998c..2fdd74d502c0 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -433,12 +433,6 @@ enum dwc2_ep0_state { * needed. * 0 - No (default) * 1 - Yes - * @ahb_burst: Specifies the AHB burst. - * 0 - Single - * 1 - INCR - * 3 - INCR4 (default) - * 5 - INCR8 - * 7 - INCR16 * @g_dma: Enables gadget dma usage (default: autodetect). * @g_dma_desc: Enables gadget descriptor DMA (default: autodetect). * @g_rx_fifo_size:The periodic rx fifo size for the device, in @@ -516,9 +510,6 @@ struct dwc2_core_params { * properties and cannot be set directly in this structure. */ - /* Global parameters */ - u8 ahb_burst; - /* Host parameters */ bool host_dma; diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c index 014e269f2d64..aba8ee83 100644 --- a/drivers/usb/dwc2/params.c +++ b/drivers/usb/dwc2/params.c @@ -93,13 +93,6 @@ static const struct dwc2_core_params params_bcm2835 = { .host_ls_low_power_phy_clk = 0,/* 48 MHz */ .ts_dline = 0, .reload_ctl = 0, - - /* -* Although this value would normally be invalid, for BCM2835, -* the GAHBCFG.HBSTLEN field has a different meaning from that -* defined by Synopsys. See the BCM2835 databook section 15.2 -* for details. -*/ .ahbcfg = 0x10, .uframe_sched = 0, .external_id_pin_ctl= -1, @@ -1077,66 +1070,6 @@ static void dwc2_set_param_tx_fifo_sizes(struct dwc2_hsotg *hsotg) } } -static const char *const ahb_bursts[] = { - [GAHBCFG_HBSTLEN_SINGLE]= "SINGLE", - [GAHBCFG_HBSTLEN_INCR] = "INCR", - [GAHBCFG_HBSTLEN_INCR4] = "INCR4", - [GAHBCFG_HBSTLEN_INCR8] = "INCR8", - [GAHBCFG_HBSTLEN_INCR16]= "INCR16", -}; - -static int dwc2_get_property_ahb_burst(struct dwc2_hsotg *hsotg) -{ - struct device_node *node = hsotg->dev->of_node; - const char *str = NULL; - int burst; - int ret; - - ret = device_property_read_string(hsotg->dev, - "snps,ahb-burst", &str); - if (ret < 0) { - return ret; - } else if (of_device_is_compatible(node, "brcm,bcm2835-usb")) { - dev_warn(hsotg->dev, -"snps,ahb-burst is not supported on this platform"); - return -EINVAL; - } - - burst = match_string(ahb_bursts, -ARRAY_SIZE(ahb_bursts), str); - if (burst < 0) { - dev_err(hsotg->dev, - "Invalid parameter '%s' for ahb-burst\n", str); - } - - return burst; -} - -static void dwc2_set_ahb_burst(struct dwc2_hsotg *hsotg) -{ - struct dwc2_core_params *p = &hsotg->params; - int burst; - int ret; - - /* Default burst value */ - burst = GAHBCFG_HBSTLEN_INCR4; - - /* Get the legacy param value, if set. */ - if (p->ahbcfg != -1) { - burst = (p->ahbcfg & GAHBCFG_HBSTLEN_MASK) >> - GAHBCFG_HBSTLEN_SHIFT; - } - - /* Override it from devicetree, if set. */ - ret = dwc2_get_property_ahb_burst(hsotg); - if (ret >= 0) - burst = ret; - - /* Set the parameter */ - p->ahb_burst = (u8)burst; - dev_dbg(hsotg->dev, "Setting ahb-burst to %d\n", burst); -} - static void dwc2_set_gadget_dma(struct dwc2_hsotg *hsotg) { struct dwc2_hw_params *hw = &hsotg->hw_params; @@ -1216,8 +1149,6 @@ static void dwc2_set_parameters(struct dwc2_hsotg *hsotg, dwc2_set_param_external_id_pin_ctl(hsotg, params->external_id_pin_ctl); dwc2_set_param_hibernation(hsotg, params->hibernation); - dwc2_set_ahb_burst(hsotg); - /* * Set devicetree-only parameters. These parameters do not * take any values from @params. -- 2.11.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 v3 01/24] Revert "Documentation: devictree: dwc2: Add AHB burst binding"
This reverts commit d067dad79548 ("Documentation: devictree: dwc2: Add AHB burst binding"). This commit was inadvertently applied. Signed-off-by: John Youn --- Documentation/devicetree/bindings/usb/dwc2.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/dwc2.txt b/Documentation/devicetree/bindings/usb/dwc2.txt index 9e7b4b4a37ae..6c7c2bce6d0c 100644 --- a/Documentation/devicetree/bindings/usb/dwc2.txt +++ b/Documentation/devicetree/bindings/usb/dwc2.txt @@ -26,8 +26,6 @@ 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 -- snps,ahb-burst: specifies the ahb burst length. Valid arguments are: - "SINGLE", "INCR", "INCR4", "INCR8", "INCR16". Defaults to "INCR4". - 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. -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: v4.9 to v4.10 regression: oops when USB cable is plugged in.
* Pavel Machek [170123 14:26]: > [25392.239837] Unhandled fault: external abort on non-linefetch (0x1028) at > 0xfa0ab060 > [25392.239868] pgd = c0004000 > [25392.239898] [fa0ab060] *pgd=48011452(bad) > [25392.239929] Internal error: : 1028 [#1] ARM > [25392.239929] Modules linked in: > [25392.239959] CPU: 0 PID: 24322 Comm: kworker/0:1 Not tainted > 4.10.0-rc5-142127-g41f2839-dirty #222 > [25392.239990] Hardware name: Nokia RX-51 board > [25392.240020] Workqueue: events musb_irq_work > [25392.240051] task: cd44d5c0 task.stack: cd308000 > [25392.240051] PC is at musb_default_readb+0x0/0xc > [25392.240081] LR is at musb_irq_work+0x1c/0x1b0 OK I'm pretty sure the patch I posted few days ago fixes this. Can you please test patch "[PATCH] usb: musb: Fix external abort on non-linefetch for musb_irq_work()"? I was able to hit that only once so far, do you hit it every time with your built-in g_ether .config? Regards, Tony -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2] usb: dwc3: handle DWC_USB3_NUM == DWC_USB3_NUM_IN_EPS
On 1/23/2017 2:10 PM, Alan Stern wrote: > On Mon, 23 Jan 2017, John Youn wrote: > >> On 1/22/2017 5:29 PM, Bryan O'Donoghue wrote: >>> - DWC_USB3_NUM indicates the number of Device mode single directional >>> endpoints, including OUT and IN endpoint 0. >>> >>> - DWC_USB3_NUM_IN_EPS indicates the maximum number of Device mode IN >>> endpoints active at any time, including control endpoint 0. >>> >>> It's possible to configure RTL such that DWC_USB3_NUM_EPS is equal to >>> DWC_USB3_NUM_IN_EPS. >>> >>> dwc3-core calculates the number of OUT endpoints as DWC_USB3_NUM minus >>> DWC_USB3_NUM_IN_EPS. If RTL has been configured with DWC_USB3_NUM_IN_EPS >>> equal to DWC_USB3_NUM then dwc3-core will calculate the number of OUT >>> endpoints as zero. >>> >>> For example a from dwc3_core_num_eps() shows: >>> [1.565000] /usb0@f01d: found 8 IN and 0 OUT endpoints >>> >>> This patch works around this case by detecting when DWC_USB3_NUM_EPS is >>> equal to DWC3_USB3_NUM_IN_EPS and over-rides the calculation of the number >> >> What if NUM_IN_EPS=7 and NUM_EPS=8? You will still have a problem. >> >> It's possible to fix this for the general case rather than for this >> specific case. > > What is the reason for computing NUM_OUT_EPS in the first place? > Isn't it true that any endpoint can be used as an OUT endpoint? > > So the real restrictions on a configuration are: > > number of IN endpoints <= NUM_IN_EPS, and > > number of IN endpoints + number of OUT endpoints <= NUM_EPS, > > where ep0 must be counted twice, as both an IN and an OUT endpoint. > The value of NUM_OUT_EPS isn't used and shouldn't matter. > Yes that's correct. The general fix should take all that into account so that any combination of NUM_EPS and NUM_IN_EPS will work fine. However it must also account for FPGA configs where each HW endpoint has a fixed number/direction, which the current code is compatible with. John -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
v4.9 to v4.10 regression: oops when USB cable is plugged in.
Hi! v4.9 was ok (this is annoying enought that I'd notice). v4.10-rc5 is not. (And yes, I probably [0.00] Booting Linux on physical CPU 0x0 [0.00] Linux version 4.10.0-rc5-142127-g41f2839-dirty (pavel@amd) (gcc version 4.7.2 (GCC) ) #222 Mon Jan 23 15:13:11 CET 2017 [0.00] CPU: ARMv7 Processor [411fc083] revision 3 (ARMv7), cr=10c5387d [0.00] CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache [0.00] OF: fdt:Machine model: Nokia N900 [0.00] cma: Reserved 16 MiB at 0x8e80 [0.00] Memory policy: Data cache writeback [0.00] On node 0 totalpages: 65280 [0.00] free_area_init_node: node 0, pgdat c0b4b848, node_mem_map cfcf1000 [0.00] Normal zone: 512 pages used for memmap [0.00] Normal zone: 0 pages reserved [0.00] Normal zone: 65280 pages, LIFO batch:15 [0.00] CPU: All CPU(s) started in SVC mode. [0.00] OMAP3430/3530 ES3.1 (l2cache iva sgx neon isp) [0.00] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768 [0.00] pcpu-alloc: [0] 0 [0.00] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 64768 [0.00] Kernel command line: root=/dev/mmcblk0p1 rootwait no-omap-wd no-ext-wd [0.00] PID hash table entries: 1024 (order: 0, 4096 bytes) [0.00] Dentry cache hash table entries: 32768 (order: 5, 131072 bytes) [0.00] Inode-cache hash table entries: 16384 (order: 4, 65536 bytes) [0.00] Memory: 231196K/261120K available (6144K kernel code, 305K rwdata, 2048K rodata, 1024K init, 313K bss, 13540K reserved, 16384K cma-reserved, 0K highmem) [0.00] Virtual kernel memory layout: [0.00] vector : 0x - 0x1000 ( 4 kB) [0.00] fixmap : 0xffc0 - 0xfff0 (3072 kB) [0.00] vmalloc : 0xd080 - 0xff80 ( 752 MB) [0.00] lowmem : 0xc000 - 0xd000 ( 256 MB) [0.00] pkmap : 0xbfe0 - 0xc000 ( 2 MB) [0.00] modules : 0xbf00 - 0xbfe0 ( 14 MB) [0.00] .text : 0xc0008000 - 0xc070 (7136 kB) [0.00] .init : 0xc0a0 - 0xc0b0 (1024 kB) [0.00] .data : 0xc0b0 - 0xc0b4c480 ( 306 kB) [0.00].bss : 0xc0b4e000 - 0xc0b9c5f4 ( 314 kB) [0.00] NR_IRQS:16 nr_irqs:16 16 [0.00] IRQ: Found an INTC at 0xfa20 (revision 4.0) with 96 interrupts [0.00] Clocking rate (Crystal/Core/MPU): 19.2/332/500 MHz [0.00] OMAP clockevent source: timer1 at 32768 Hz [0.00] clocksource: 32k_counter: mask: 0x max_cycles: 0x, max_idle_ns: 58327039986419 ns [0.00] sched_clock: 32 bits at 32kHz, resolution 30517ns, wraps every 6553584741ns [0.30] OMAP clocksource: 32k_counter at 32768 Hz [0.000885] Console: colour dummy device 80x30 [0.001708] console [tty0] enabled [0.001770] Calibrating delay loop... 496.43 BogoMIPS (lpj=2482176) [0.047760] pid_max: default: 32768 minimum: 301 [0.047943] Security Framework initialized [0.048065] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes) [0.048126] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes) [0.049377] CPU: Testing write buffer coherency: ok [0.050384] Setting up static identity map for 0x8010 - 0x80100070 [0.054046] devtmpfs: initialized [0.092803] VFP support v0.3: implementor 41 architecture 3 part 30 variant c rev 1 [0.093353] clocksource: jiffies: mask: 0x max_cycles: 0x, max_idle_ns: 1911260446275 ns [0.094879] pinctrl core: initialized pinctrl subsystem [0.096954] NET: Registered protocol family 16 [0.101165] DMA: preallocated 256 KiB pool for atomic coherent allocations [0.128479] omap_hwmod: mcbsp2_sidetone using broken dt data from mcbsp [0.129394] omap_hwmod: mcbsp3_sidetone using broken dt data from mcbsp [0.175903] cpuidle: using governor menu [0.176574] Reprogramming SDRC clock to 33200 Hz [0.182952] gpio gpiochip0: (gpio): added GPIO chardev (254:0) [0.183471] gpiochip_setup_dev: registered GPIOs 0 to 31 on device: gpiochip0 (gpio) [0.186126] OMAP GPIO hardware version 2.5 [0.187164] gpio gpiochip1: (gpio): added GPIO chardev (254:1) [0.187927] gpiochip_setup_dev: registered GPIOs 32 to 63 on device: gpiochip1 (gpio) [0.191314] gpio gpiochip2: (gpio): added GPIO chardev (254:2) [0.191925] gpiochip_setup_dev: registered GPIOs 64 to 95 on device: gpiochip2 (gpio) [0.195404] gpio gpiochip3: (gpio): added GPIO chardev (254:3) [0.195922] gpiochip_setup_dev: registered GPIOs 96 to 127 on device: gpiochip3 (gpio) [0.199218] gpio gpiochip4: (gpio): added GPIO chardev (254:4) [0.199737] gpiochip_setup_dev: registered GPIOs 128 to 159 on device: gpiochip4 (gpio) [0.203033] gpio gpiochip5: (gpio): added GPIO chardev (254:5) [
Claims Requirements
The British National Lottery P O Box 1010 3b Olympic Way, Sefton Business Park, Aintree, Liverpool , L30 1RD (Customer Services) Ref: UK/9420X2/68 Batch: 074/05/ZY369 Ticket number:56475600545 188 Lucky Numbers: 05,06,17,20,28,42(Bonus33) WINNING NOTIFICATION: We wish to congratulate and inform you on the selection of cash prize 1,000,000.00 (British Pounds) held on the 20th January 2017 in London Uk.The selection process was carried out through random selection in Our computerized email selection system (ess) from a database of over 250,000 email addresses drawn from which you were selected. And Your e-mail address attached to ticket number: 56475600545 188 with Serial number 5368/02 drew the lucky numbers: 05, 06, 17, 20, 28, 42 (Bonus 33) ,which subsequently won you the lottery in the 1st category i.e match 5 plus bonus. You have therefore been approved to claim a total sum of 1 Million Pounds,(One Million Pounds) in cash credited to fileKTU/ 9023118308/03. This is from a total cash prize of ?1,000,000 Million Pounds,shared amongst the (4)lucky winners in this category i.e Match 6 plus bonus. For due processing of your winning claim,please contact the FIDUCIARY AGENT Information Officer Mr. Francisco pedro who has been assigned to assist you. You are to contact him with the following details for the release of your winnings. Agent Name: Mr. Francisco pedro Tel:+447024077948 Email: mr.franciscopedro...@yahoo.com Contact him, please provide him with the following Requirements below: Claims Requirements: 1.Name in full-- 2.Address--- 3.Nationality--- 4.Age--- 5.Occupation 6.Sex -- 7.Phone/Fax- 8.Present Country--- If you do not contact your claims agent within 5 working days of this Notification, your winnings would be revoked. Winners are advised to keep their winning details/information from the public to avoid Fraudulent claim (IMPORTANT) pending the prize claim by Winner. *Winner under the age of 18 are automatically disqualified. *Staff of the British Lottery are not to partake in this Lottery. Accept my hearty congratulations once again! Regards Mrs. Stella Ellis (Group Coordinator Note that you are not to reply to this E-mail,please contact your claims officer directly to start the processing of your claims application form. -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2] usb: dwc3: handle DWC_USB3_NUM == DWC_USB3_NUM_IN_EPS
On Mon, 23 Jan 2017, John Youn wrote: > On 1/22/2017 5:29 PM, Bryan O'Donoghue wrote: > > - DWC_USB3_NUM indicates the number of Device mode single directional > > endpoints, including OUT and IN endpoint 0. > > > > - DWC_USB3_NUM_IN_EPS indicates the maximum number of Device mode IN > > endpoints active at any time, including control endpoint 0. > > > > It's possible to configure RTL such that DWC_USB3_NUM_EPS is equal to > > DWC_USB3_NUM_IN_EPS. > > > > dwc3-core calculates the number of OUT endpoints as DWC_USB3_NUM minus > > DWC_USB3_NUM_IN_EPS. If RTL has been configured with DWC_USB3_NUM_IN_EPS > > equal to DWC_USB3_NUM then dwc3-core will calculate the number of OUT > > endpoints as zero. > > > > For example a from dwc3_core_num_eps() shows: > > [1.565000] /usb0@f01d: found 8 IN and 0 OUT endpoints > > > > This patch works around this case by detecting when DWC_USB3_NUM_EPS is > > equal to DWC3_USB3_NUM_IN_EPS and over-rides the calculation of the number > > What if NUM_IN_EPS=7 and NUM_EPS=8? You will still have a problem. > > It's possible to fix this for the general case rather than for this > specific case. What is the reason for computing NUM_OUT_EPS in the first place? Isn't it true that any endpoint can be used as an OUT endpoint? So the real restrictions on a configuration are: number of IN endpoints <= NUM_IN_EPS, and number of IN endpoints + number of OUT endpoints <= NUM_EPS, where ep0 must be counted twice, as both an IN and an OUT endpoint. The value of NUM_OUT_EPS isn't used and shouldn't matter. Alan Stern -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 3/3] usb: musb: dsps: Manage CPPI 4.1 DMA interrupt in dsps
On Mon, Jan 23, 2017 at 09:44:42AM -0800, Kevin Hilman wrote: > Bin Liu writes: > > > On Thu, Jan 19, 2017 at 11:06:59AM +0100, Alexandre Bailon wrote: > >> Despite the CPPI 4.1 is a generic DMA, it is tied to USB. > >> On the dsps, CPPI 4.1 interrupt's registers are in USBSS (the MUSB glue). > >> Currently, to enable / disable and clear interrupts, the CPPI 4.1 driver > >> maps and accesses to USBSS's register, which making CPPI 4.1 driver not > >> really generic. > >> Move the interrupt management to dsps driver. > >> > >> Signed-off-by: Alexandre Bailon > >> --- > >> drivers/dma/cppi41.c | 28 > >> drivers/usb/musb/musb_dsps.c | 77 > >> ++-- > >> 2 files changed, 82 insertions(+), 23 deletions(-) > > > > This patch touches both dma and musb modules, I know it makes review > > easier, but how we get it merged? One maintainer ACK it and the other > > pick it up? Sorry for the dumb question, I am new as a maintainer... > > For patches where the change needs to go together, then one maintainer > can ack, and the other can merge. Alternately, if the patch can be done Ok, this is what I thought :) > in a way that the parts can go independently, that is sometimes > cleaner. I don't know this code well enough to know which is which. In this case it is better to keep all together, since it moves code from one place to another. I think it makes sense it goes to my tree, since the reset patches are for musb. Regards, -Bin. -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2] usb: dwc3: handle DWC_USB3_NUM == DWC_USB3_NUM_IN_EPS
On 1/22/2017 5:29 PM, Bryan O'Donoghue wrote: > - DWC_USB3_NUM indicates the number of Device mode single directional > endpoints, including OUT and IN endpoint 0. > > - DWC_USB3_NUM_IN_EPS indicates the maximum number of Device mode IN > endpoints active at any time, including control endpoint 0. > > It's possible to configure RTL such that DWC_USB3_NUM_EPS is equal to > DWC_USB3_NUM_IN_EPS. > > dwc3-core calculates the number of OUT endpoints as DWC_USB3_NUM minus > DWC_USB3_NUM_IN_EPS. If RTL has been configured with DWC_USB3_NUM_IN_EPS > equal to DWC_USB3_NUM then dwc3-core will calculate the number of OUT > endpoints as zero. > > For example a from dwc3_core_num_eps() shows: > [1.565000] /usb0@f01d: found 8 IN and 0 OUT endpoints > > This patch works around this case by detecting when DWC_USB3_NUM_EPS is > equal to DWC3_USB3_NUM_IN_EPS and over-rides the calculation of the number What if NUM_IN_EPS=7 and NUM_EPS=8? You will still have a problem. It's possible to fix this for the general case rather than for this specific case. Regards, John -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4 0/6] usb: musb: cppi41: Add a way to manage DMA irq
On Mon, Jan 23, 2017 at 05:48:02PM +0100, Alexandre Bailon wrote: > This series was "dmaengine: cppi41: Make the driver more generic". > I have tried to separate as munch I could CPPI 4.1 MUSB driver changes. > > Currently, the DMA interrupt is managed by the CPPI 4.1 driver. > The issue here is the CPPI 4.1 driver must access to MUSB glue registers > to manage its interrupt. > In order to move the interrupts management from CPPI 4.1 driver to MUSB > (and then make it more generic), update the MUSB CPPI 4.1 driver with > changes that will help to manage DMA interrupt from MUSB driver. > > Changes in v4: > - Remove musb pointer from struct cppi, cppi41_dma_controller and > tusb_omap_dma. > > Changes in v3: > - Move a patch from another series to this one to avoid build error report > from kbuild test robot > - Instead of adding and exporting function, add one callback and a pointer > to musb in struct dma_controller > - Surround the DMA function introduced in musb_dsps with #ifdef / #endif. > > Changes in v2: > - Fix some typo in commit messages > - Add more explanation about some changes made by patch 2 in commit message > > Alexandre Bailon (6): > usb: musb: dma: Add a DMA completion platform callback > usb: musb: cppi41: Detect aborted transfers in cppi41_dma_callback() > usb: musb: cppi_dma: Clean up cppi structure > usb: musb: cppi_dma: Clean up cppi41_dma_controller structure > usb: musb: cppi_dma: Clean up tusb_omap_dma structure > usb: musb: dsps: Manage CPPI 4.1 DMA interrupt in DSPS > > drivers/dma/cppi41.c | 28 -- > drivers/usb/musb/cppi_dma.c | 26 ++--- > drivers/usb/musb/cppi_dma.h | 1 - > drivers/usb/musb/musb_cppi41.c | 48 +--- > drivers/usb/musb/musb_dma.h | 5 +++ > drivers/usb/musb/musb_dsps.c | 81 > +++- > drivers/usb/musb/tusb6010_omap.c | 7 ++-- > 7 files changed, 134 insertions(+), 62 deletions(-) > Please keep linux-usb list cc'd. Regards, -Bin. -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2] usb: dwc3: handle DWC_USB3_NUM == DWC_USB3_NUM_IN_EPS
On 1/23/2017 5:34 AM, Bryan O'Donoghue wrote: > On 23/01/17 12:08, Felipe Balbi wrote: >> >> Hi, >> >> Bryan O'Donoghue writes: >>> - DWC_USB3_NUM indicates the number of Device mode single directional >>> endpoints, including OUT and IN endpoint 0. >>> >>> - DWC_USB3_NUM_IN_EPS indicates the maximum number of Device mode IN >>> endpoints active at any time, including control endpoint 0. >>> >>> It's possible to configure RTL such that DWC_USB3_NUM_EPS is equal to >>> DWC_USB3_NUM_IN_EPS. >>> >>> dwc3-core calculates the number of OUT endpoints as DWC_USB3_NUM minus >>> DWC_USB3_NUM_IN_EPS. If RTL has been configured with DWC_USB3_NUM_IN_EPS >>> equal to DWC_USB3_NUM then dwc3-core will calculate the number of OUT >>> endpoints as zero. >>> >>> For example a from dwc3_core_num_eps() shows: >>> [1.565000] /usb0@f01d: found 8 IN and 0 OUT endpoints >>> >>> This patch works around this case by detecting when DWC_USB3_NUM_EPS is >>> equal to DWC3_USB3_NUM_IN_EPS and over-rides the calculation of the number >>> of OUT and IN endpoints to make dwc->num_in_eps equal to half >>> DWC_USB3_NUM_EPS. >>> >>> If DWC_USB3_NUM_EPS is equal to DWC3_USB3_NUM_IN_EPS and the endpoint count >>> is an odd number then dwc->num_out_eps will be assigned the extra endpoint. >> >> sorry, now that I spent some more time with this. Isn't something like >> below solving all problems? >> >> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c >> index 369bab16a824..68c9c84b7216 100644 >> --- a/drivers/usb/dwc3/core.c >> +++ b/drivers/usb/dwc3/core.c >> @@ -397,8 +397,7 @@ static void dwc3_core_num_eps(struct dwc3 *dwc) >> { >> struct dwc3_hwparams*parms = &dwc->hwparams; >> >> -dwc->num_in_eps = DWC3_NUM_IN_EPS(parms); >> -dwc->num_out_eps = DWC3_NUM_EPS(parms) - dwc->num_in_eps; >> +dwc->num_eps = DWC3_NUM_EPS(parms); >> } >> >> static void dwc3_cache_hwparams(struct dwc3 *dwc) >> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c >> index 0a664d8eba3f..8c187df0aa42 100644 >> --- a/drivers/usb/dwc3/gadget.c >> +++ b/drivers/usb/dwc3/gadget.c >> @@ -2001,23 +2002,7 @@ static int dwc3_gadget_init_hw_endpoints(struct dwc3 >> *dwc, >> >> static int dwc3_gadget_init_endpoints(struct dwc3 *dwc) >> { >> -int ret; >> - >> -INIT_LIST_HEAD(&dwc->gadget.ep_list); >> - >> -ret = dwc3_gadget_init_hw_endpoints(dwc, dwc->num_out_eps, 0); >> -if (ret < 0) { >> -dev_err(dwc->dev, "failed to initialize OUT endpoints\n"); >> -return ret; >> -} >> - >> -ret = dwc3_gadget_init_hw_endpoints(dwc, dwc->num_in_eps, 1); >> -if (ret < 0) { >> -dev_err(dwc->dev, "failed to initialize IN endpoints\n"); >> -return ret; >> -} >> - >> -return 0; >> +return dwc3_gadget_init_hw_endpoints(dwc, dwc->num_eps); > > Well I hadn't considered that level of change myself but, it should work. > It should work for ASICS. But it won't work for our FPGA platform. It needs to work the existing, more limited, way. You can check this with the GHWPARAMS6.EN_FPGA. John -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH V2 1/2] dt-bindings: leds: document new led-triggers property
On 01/23/2017 05:45 PM, Rob Herring wrote: > On Fri, Jan 20, 2017 at 11:35:20PM +0100, Jacek Anaszewski wrote: >> Hi Rafał, >> >> On 01/20/2017 10:56 PM, Rafał Miłecki wrote: >>> From: Rafał Miłecki >>> >>> Some LEDs can be related to particular devices described in DT. This >>> property allows specifying such relations. E.g. USB LED should usually >>> be used to indicate some USB port(s) state. >>> >>> Signed-off-by: Rafał Miłecki >>> --- >>> V2: Replace "usb-ports" with "led-triggers" property which is more generic >>> and >>> allows specifying other devices as well. >>> >>> When bindings patch is related to some followup implementation, they >>> usually go >>> through the same tree. >>> >>> Greg: this patch is based on top of e64b8cc72bf9 ("DT: leds: Improve >>> examples by >>> adding some context") from kernel/git/j.anaszewski/linux-leds.git . Is >>> there any >>> way to solve this dependency issue? Or should this patch wait until 3.11 is >>> released? >>> --- >>> Documentation/devicetree/bindings/leds/common.txt | 16 >>> 1 file changed, 16 insertions(+) >>> >>> diff --git a/Documentation/devicetree/bindings/leds/common.txt >>> b/Documentation/devicetree/bindings/leds/common.txt >>> index 24b656014089..17632a041196 100644 >>> --- a/Documentation/devicetree/bindings/leds/common.txt >>> +++ b/Documentation/devicetree/bindings/leds/common.txt >>> @@ -49,6 +49,17 @@ Optional properties for child nodes: >>> - panic-indicator : This property specifies that the LED should be used, >>> if at all possible, as a panic indicator. >>> >>> +- led-triggers : List of devices that should trigger this LED activity. >>> Some >>> +LEDs can be related to a specific device and should somehow >>> +indicate its state. E.g. USB 2.0 LED may react to device(s) in >>> +a USB 2.0 port(s). Another common example is switch or router >>> +with multiple Ethernet ports each of them having its own LED >>> +assigned (assuminled-trigger-usbportg they are not hardwired). >>> +In such cases this property should contain phandle(s) of >>> +related device(s). In many cases LED can be related to more >>> +than one device (e.g. one USB LED vs. multiple USB ports) so a >>> +list of entries can be specified. >>> + >> >> This implies that it is possible to define multiple triggers for >> a LED class device but it is not supported by LED Trigger core. > > Not really relevant for designing (and future proofing) a binding. But relevant for LED Trigger ABI, which would have to be changed to support the semantics in this form. I think that changing the property name to linux,trigger-sources would make its purpose more clear. Note that we have to also associate somehow this property with the triggers that will make use of the information it provides. I can imagine also other compound triggers that could benefit on it. What follows, the trigger sources would trigger LED activity only if the LED class device was assigned appropriate trigger. We need to define somewhere which triggers support this property. Trigger specific bindings? >> There is linux,default-trigger property which allows to define one >> trigger that will be initially assigned. >> >> I am aware that this is renamed usb-ports property from v1, >> that attempts to address Rob's comment, but we can't do that this way. >> Maybe usb-ports property could be documented in led-trigger-usbport's >> specific bindings and a reference to it could be added next to the >> related entry on the list of the available LED triggers (which is >> actually missing) in Documentation/devicetree/bindings/leds/common.txt. > > I'm not going to accept something specific to USB. So the choice is make > the existing property work for USB or design something more flexible and > generic. -- Best regards, Jacek Anaszewski -- 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 v7 3/5] phy: Add set_vbus callback
Quoting Kishon Vijay Abraham I (2017-01-22 00:46:21) > Hi, > > On Saturday 21 January 2017 12:20 AM, Stephen Boyd wrote: > > Some USB PHYs need to be told about vbus changing state > > explicitly. For example the qcom USB HS PHY needs to toggle a bit > > when vbus goes from low to high (VBUSVLDEXT) to cause the > > "session valid" signal to toggle. This signal will pull up D+ > > when the phy starts running. If the vbus signal isn't routed to > > the PHY this "session valid" signal won't ever toggle, so we have > > to toggle it explicitly. This callback is used to do that. > > > > Cc: Peter Chen > > Signed-off-by: Stephen Boyd > > --- > > > > New patch > > > > drivers/phy/phy-core.c | 15 +++ > > include/linux/phy/phy.h | 10 ++ > > 2 files changed, 25 insertions(+) > > > > diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c > > index a268f4d6f3e9..8b1a6bfa5133 100644 > > --- a/drivers/phy/phy-core.c > > +++ b/drivers/phy/phy-core.c > > @@ -357,6 +357,21 @@ int phy_set_mode(struct phy *phy, enum phy_mode mode) > > } > > EXPORT_SYMBOL_GPL(phy_set_mode); > > > > +int phy_set_vbus(struct phy *phy, int on) > > +{ > > + int ret; > > + > > + if (!phy || !phy->ops->set_vbus) > > + return 0; > > + > > + mutex_lock(&phy->mutex); > > + ret = phy->ops->set_vbus(phy, on); > > + mutex_unlock(&phy->mutex); > > + > > + return ret; > > +} > > +EXPORT_SYMBOL_GPL(phy_set_vbus); > > + > > int phy_reset(struct phy *phy) > > { > > int ret; > > diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h > > index 78bb0d7f6b11..4d1ebde7fb14 100644 > > --- a/include/linux/phy/phy.h > > +++ b/include/linux/phy/phy.h > > @@ -36,6 +36,7 @@ enum phy_mode { > > * @power_on: powering on the phy > > * @power_off: powering off the phy > > * @set_mode: set the mode of the phy > > + * @set_vbus: enable/disable vbus in the phy (USB) > > * @reset: resetting the phy > > * @owner: the module owner containing the ops > > */ > > @@ -45,6 +46,7 @@ struct phy_ops { > > int (*power_on)(struct phy *phy); > > int (*power_off)(struct phy *phy); > > int (*set_mode)(struct phy *phy, enum phy_mode mode); > > + int (*set_vbus)(struct phy *phy, int on); > > please avoid adding usb specific ops in generic phy ops. > Is there any alternative? Something has to happen here. The only other thing I can think of is putting back the vbus extcon in the phy driver so it can be notified when vbus is present or not. I can rely on phy_set_mode() being called so that we don't need to figure out if we're in host mode or not like was being done before. -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb: dwc2: fix "iomem 0x00000000" message by setting iomem parameters in usb_hcd
On 1/23/2017 3:50 AM, Felipe Balbi wrote: > > Hi, > > John Youn writes: >> @@ -1229,7 +1229,8 @@ static inline void dwc2_hcd_connect(struct >> dwc2_hsotg *hsotg) {} >> static inline void dwc2_hcd_disconnect(struct dwc2_hsotg *hsotg, bool >> force) {} >> static inline void dwc2_hcd_start(struct dwc2_hsotg *hsotg) {} >> static inline void dwc2_hcd_remove(struct dwc2_hsotg *hsotg) {} >> -static inline int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq) >> +static inline int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq, >> +struct resource *res) >> { return 0; } >> static inline int dwc2_backup_host_registers(struct dwc2_hsotg *hsotg) >> { return 0; } >> diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c >> index 911c3b36..2cfbd10e 100644 >> --- a/drivers/usb/dwc2/hcd.c >> +++ b/drivers/usb/dwc2/hcd.c >> @@ -4964,7 +4964,7 @@ static void dwc2_hcd_release(struct dwc2_hsotg >> *hsotg) >> * USB bus with the core and calls the hc_driver->start() function. It >> returns >> * a negative error on failure. >> */ >> -int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq) >> +int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq, struct resource >> *res) >> { >> struct usb_hcd *hcd; >> struct dwc2_host_chan *channel; >> @@ -5021,6 +5021,9 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int >> irq) >> >> hcd->has_tt = 1; >> >> +hcd->rsrc_start = res->start; >> +hcd->rsrc_len = resource_size(res); >> + >> ((struct wrapper_priv_data *) &hcd->hcd_priv)->hsotg = hsotg; >> hsotg->priv = hcd; >> >> diff --git a/drivers/usb/dwc2/hcd.h b/drivers/usb/dwc2/hcd.h >> index 1ed5fa2b..2305b5fb 100644 >> --- a/drivers/usb/dwc2/hcd.h >> +++ b/drivers/usb/dwc2/hcd.h >> @@ -521,7 +521,8 @@ static inline u8 dwc2_hcd_is_pipe_out(struct >> dwc2_hcd_pipe_info *pipe) >> return !dwc2_hcd_is_pipe_in(pipe); >> } >> >> -extern int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq); >> +extern int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq, >> + struct resource *res); >> extern void dwc2_hcd_remove(struct dwc2_hsotg *hsotg); >> >> /* Transaction Execution Functions */ >> diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c >> index 4fc8c603..5ddc8860 100644 >> --- a/drivers/usb/dwc2/platform.c >> +++ b/drivers/usb/dwc2/platform.c >> @@ -445,7 +445,7 @@ static int dwc2_driver_probe(struct platform_device >> *dev) >> } >> >> if (hsotg->dr_mode != USB_DR_MODE_PERIPHERAL) { >> -retval = dwc2_hcd_init(hsotg, hsotg->irq); >> +retval = dwc2_hcd_init(hsotg, hsotg->irq, res); > > This is a good idea, but there's more work that can come out of this, if > you're interested: > > i) devm_ioremap_resource() could be called by the generic layer > ii) devm_request_irq() could be move to the generic layer > iii) dwc2_hcd_init() could also be called generically as long as dr_mode > is set properly. > iv) dwc2_debugfs_init() could be called generically as well > > IOW, dwc2_driver_probe() could be as minimal as: > > static int dwc2_driver_probe(struct platform_device *dev) > { > struct dwc2_hsotg *hsotg; > struct resource *res; > int retval; > > hsotg = devm_kzalloc(&dev->dev, sizeof(*hsotg), GFP_KERNEL); > if (!hsotg) > return -ENOMEM; > > hsotg->dev = &dev->dev; > > if (!dev->dev.dma_mask) > dev->dev.dma_mask = &dev->dev.coherent_dma_mask; > > retval = dma_set_coherent_mask(&dev->dev, DMA_BIT_MASK(32)); > if (retval) > return retval; > > hsotg->res = platform_get_resource(dev, IORESOURCE_MEM, 0); > hsotg->irq = platform_get_irq(dev, 0); > > retval = dwc2_get_dr_mode(hsotg); > if (retval) > return retval; > > retval = dwc2_get_hwparams(hsotg); > if (retval) > return retval; > > platform_set_drvdata(dev, hsotg); > > retval = dwc2_core_init(hsotg); > if (retval) > return retval; > > return 0; > } > > dwc2_core_init() needs to implemented, of course, but it could hide all > details about what to do with IRQs and resources and what not. Assuming > you can properly initialize clocks, it could even handle clocks > generically for you. > I see what you mean. I'm just a little confused about the term "generic" here: For me something generic has more than one user. Here we seem to speak just about factoring out some code from the probe function, or? >>
Re: [PATCH v2 10/28] usb: dwc2: Remove unused otg_ver parameter
On 1/23/2017 3:41 AM, Felipe Balbi wrote: > John Youn writes: > >> The otg_ver parameter only controls the SRP pulsing method and defaults >> to the 1.3 behavior. It is unused and can be removed. >> >> Signed-off-by: John Youn > > this patch fails to apply: > > checking file drivers/usb/dwc2/core.c > checking file drivers/usb/dwc2/core.h > Hunk #2 succeeded at 467 (offset 6 lines). > Hunk #3 succeeded at 1180 (offset 9 lines). > checking file drivers/usb/dwc2/hcd.c > Hunk #1 succeeded at 2258 (offset -2 lines). > checking file drivers/usb/dwc2/params.c > Hunk #3 succeeded at 106 (offset 7 lines). > Hunk #4 succeeded at 136 (offset 7 lines). > Hunk #5 succeeded at 166 (offset 7 lines). > Hunk #6 succeeded at 196 (offset 7 lines). > Hunk #7 succeeded at 970 with fuzz 1 (offset -2 lines). > Hunk #8 FAILED at 1132. > 1 out of 8 hunks FAILED > > please rebase on testing/next > Sure, I'll do that. But as I mentioned before, you have commits that made it to your next that need to be removed. I'll send revert commits for those. Thanks, John -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] USB: Add quirk for WORLDE easykey.25 MIDI keyboard
On Sat, Jan 21, 2017 at 10:08 AM, Greg Kroah-Hartman wrote: > Always use scripts/get_maintainer.pl to determine who to send patches > to, and what mailing list. You forgot linux-usb@vger, which I've now > added... I'm sorry about that. I actually did use scripts/get_maintainer.pl, but it only returned your email address and I added linux-kernel@vger myself. I guess I ran it with wrong options. > That's odd, how does other operating systems handle this device? I'm not sure how realistic this test is, but I ran a Wireshark capture from Windows 8.1 VM and it seems that for this particular device, Windows doesn't try to set the current configuration (since there is only one) and it does not even attempt to get the configuration string descriptor. I'm not sure if Windows does this in general, but it seems to work around the problem for this device by not caring about the configuration string descriptor in the first place. I have uploaded both captures here - https://gist.github.com/lalinsky/83148a827d5cd43e79e377d8e1b5ed0d Lukas -- 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 3/3] usb: musb: dsps: Manage CPPI 4.1 DMA interrupt in dsps
Bin Liu writes: > On Thu, Jan 19, 2017 at 11:06:59AM +0100, Alexandre Bailon wrote: >> Despite the CPPI 4.1 is a generic DMA, it is tied to USB. >> On the dsps, CPPI 4.1 interrupt's registers are in USBSS (the MUSB glue). >> Currently, to enable / disable and clear interrupts, the CPPI 4.1 driver >> maps and accesses to USBSS's register, which making CPPI 4.1 driver not >> really generic. >> Move the interrupt management to dsps driver. >> >> Signed-off-by: Alexandre Bailon >> --- >> drivers/dma/cppi41.c | 28 >> drivers/usb/musb/musb_dsps.c | 77 >> ++-- >> 2 files changed, 82 insertions(+), 23 deletions(-) > > This patch touches both dma and musb modules, I know it makes review > easier, but how we get it merged? One maintainer ACK it and the other > pick it up? Sorry for the dumb question, I am new as a maintainer... For patches where the change needs to go together, then one maintainer can ack, and the other can merge. Alternately, if the patch can be done in a way that the parts can go independently, that is sometimes cleaner. I don't know this code well enough to know which is which. Kevin -- 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: Kernel panic (NULL pointer dereference) when using fsl_udc2_core on i.MX31 PDK
Hi On 23 January 2017 at 12:51, Felipe Balbi wrote: > > Hi, > > Magnus Lilja writes: >> Hi >> >> I tried the fsl_udc_core gadget driver on the i.MX31 PDK board and got a >> kernel panic (NULL pointer dereference) when connecting the USB cable. I >> had the g_serial module loaded as well. >> >> The NULL pointer panic comes from gadget/udc/core.c >> usb_gadget_giveback_request() which calls req->complete() and in some >> cases req->complete is NULL. >> >> Commit 304f7e5e1d08 ("usb: gadget: Refactor request completion") changed >> fsl_udc2_core.c (and several other files) and in fsl_udc2_core.c a check >> that req->complete is non-NULL was removed: >> >> --- a/drivers/usb/gadget/udc/fsl_udc_core.c >> +++ b/drivers/usb/gadget/udc/fsl_udc_core.c >> @@ -197,10 +197,8 @@ __acquires(ep->udc->lock) >> ep->stopped = 1; >> >> spin_unlock(&ep->udc->lock); >> - /* complete() is from gadget layer, >> -* eg fsg->bulk_in_complete() */ >> - if (req->req.complete) >> - req->req.complete(&ep->ep, &req->req); >> + >> + usb_gadget_giveback_request(&ep->ep, &req->req); >> >> spin_lock(&ep->udc->lock); >> ep->stopped = stopped; >> >> If I re-introduce the check (either in fsl_udc_core.c or core.c) at >> least USB gadget operation using g_serial seems to work just fine. >> >> I don't know the logic in detail to understand whether this is a proper >> fix or if there is some other more problem with the fls_udc_core driver. >> Does anyone have input in this matter? >> >> I can produce a proper patch that fixes this problem by re-introducing >> the check (in either fsl_udc_core.c or core.c) if that is a proper >> solution and I can also assist in testing other fixes to the problem. > > ->complete() is supposed to be mandatory. Which gadget do you have that > ->doesn't set ->complete() to a valid function pointer? I'm modprobing g_serial so the following modules are loaded (using my patch): ~ # lsmod usb_f_acm u_serial g_serial libcomposite configfs fsl_usb2_udc Regards, Magnus -- 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: gadget: udc: constify usb_ep_ops structures
Declare usb_ep_ops structures as const as they are only stored in the ops field of an usb_ep structure. This field is of type const, so usb_ep_ops structures having this property can be made const too. Done using Coccinelle( A smaller version of the script) @r disable optional_qualifier@ identifier i; position p; @@ static struct usb_ep_ops i@p={...}; @ok@ identifier r.i; position p; struct mv_ep a; struct mv_u3d_ep b; struct omap_ep c; @@ ( a.ep.ops=&i@p; | b.ep.ops=&i@p; | c.ep.ops=&i@p; ) @bad@ position p!={r.p,ok.p}; identifier r.i; @@ i@p @depends on !bad disable optional_qualifier@ identifier r.i; @@ +const struct usb_ep_ops i; File size details before and after applying the patch. First line of every .o file shows the file size before patching and second line shows the file size after patching. text data bss dec hex filename 7782 384 881741fee usb/gadget/udc/fotg210-udc.o 7878 296 881821ff6 usb/gadget/udc/fotg210-udc.o 17866 992 40 1889849d2 usb/gadget/udc/fsl_udc_core.o 17954 896 40 1889049ca usb/gadget/udc/fsl_udc_core.o 9646 288 8994226d6 usb/gadget/udc/fusb300_udc.o 9742 192 8994226d6 usb/gadget/udc/fusb300_udc.o 12752 416 8 131763378 drivers/usb/gadget/udc/goku_udc.o 12832 328 8 131683370 drivers/usb/gadget/udc/goku_udc.o 165411696 8 182454745 drivers/usb/gadget/udc/gr_udc.o 166371600 8 182454745 drivers/usb/gadget/udc/gr_udc.o 15798 288 16 161023ee6 drivers/usb/gadget/udc/m66592-udc.o 15894 192 16 161023ee6 drivers/usb/gadget/udc/m66592-udc.o 177513808 16 215755447 usb/gadget/udc/mv_u3d_core.o 178393712 16 21567543f usb/gadget/udc/mv_u3d_core.o 173481112 24 184844834 usb/gadget/udc/mv_udc_core.o 174361016 24 18476482c usb/gadget/udc/mv_udc_core.o 259902620 13 286236fcf drivers/usb/gadget/udc/net2272.o 260862524 13 286236fcf drivers/usb/gadget/udc/net2272.o 184097312 8 257296481 drivers/usb/gadget/udc/pxa27x_udc.o 185057208 8 257216479 drivers/usb/gadget/udc/pxa27x_udc.o 18644 288 16 189484a04 usb/gadget/udc/r8a66597-udc.o 18740 192 16 189484a04 usb/gadget/udc/r8a66597-udc.o Files: drivers/usb/gadget/udc/{s3c-hsudc.o/omap_udc.o/fsl_qe_udc.o} did not complie. Signed-off-by: Bhumika Goyal --- drivers/usb/gadget/udc/fotg210-udc.c | 2 +- drivers/usb/gadget/udc/fsl_qe_udc.c | 2 +- drivers/usb/gadget/udc/fsl_udc_core.c | 2 +- drivers/usb/gadget/udc/fusb300_udc.c | 2 +- drivers/usb/gadget/udc/goku_udc.c | 2 +- drivers/usb/gadget/udc/gr_udc.c | 2 +- drivers/usb/gadget/udc/m66592-udc.c | 2 +- drivers/usb/gadget/udc/mv_u3d_core.c | 2 +- drivers/usb/gadget/udc/mv_udc_core.c | 2 +- drivers/usb/gadget/udc/net2272.c | 4 ++-- drivers/usb/gadget/udc/omap_udc.c | 2 +- drivers/usb/gadget/udc/pxa27x_udc.c | 2 +- drivers/usb/gadget/udc/r8a66597-udc.c | 2 +- drivers/usb/gadget/udc/s3c-hsudc.c| 2 +- 14 files changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/usb/gadget/udc/fotg210-udc.c b/drivers/usb/gadget/udc/fotg210-udc.c index 6ba122c..966637d 100644 --- a/drivers/usb/gadget/udc/fotg210-udc.c +++ b/drivers/usb/gadget/udc/fotg210-udc.c @@ -527,7 +527,7 @@ static void fotg210_ep_fifo_flush(struct usb_ep *_ep) { } -static struct usb_ep_ops fotg210_ep_ops = { +static const struct usb_ep_ops fotg210_ep_ops = { .enable = fotg210_ep_enable, .disable= fotg210_ep_disable, diff --git a/drivers/usb/gadget/udc/fsl_qe_udc.c b/drivers/usb/gadget/udc/fsl_qe_udc.c index 4fff51b..303328ce 100644 --- a/drivers/usb/gadget/udc/fsl_qe_udc.c +++ b/drivers/usb/gadget/udc/fsl_qe_udc.c @@ -1847,7 +1847,7 @@ static int qe_ep_set_halt(struct usb_ep *_ep, int value) return status; } -static struct usb_ep_ops qe_ep_ops = { +static const struct usb_ep_ops qe_ep_ops = { .enable = qe_ep_enable, .disable = qe_ep_disable, diff --git a/drivers/usb/gadget/udc/fsl_udc_core.c b/drivers/usb/gadget/udc/fsl_udc_core.c index 71094e4..f518727 100644 --- a/drivers/usb/gadget/udc/fsl_udc_core.c +++ b/drivers/usb/gadget/udc/fsl_udc_core.c @@ -1118,7 +1118,7 @@ static void fsl_ep_fifo_flush(struct usb_ep *_ep) } while (fsl_readl(&dr_regs->endptstatus) & bits); } -static struct usb_ep_ops fsl_ep_ops = { +static const struct usb_ep_ops fsl_ep_ops = { .enable = fsl_ep_enable, .disable = fsl_ep_disable, diff --git a/drivers/usb/gadget/udc/fusb300_udc.c b/drivers/usb/gadget/udc/fusb300_udc.c index 42ff308..e0c1b00 100644 --- a/drivers/usb/gadget/udc/fusb300_udc.c +++ b/drivers/usb/gadget/udc/fusb300_udc.c @@ -518,7 +518,7 @@ static void fusb300_fifo_flush(struct usb_ep *_ep)
Re: [PATCH V2 1/2] dt-bindings: leds: document new led-triggers property
On Fri, Jan 20, 2017 at 11:35:20PM +0100, Jacek Anaszewski wrote: > Hi Rafał, > > On 01/20/2017 10:56 PM, Rafał Miłecki wrote: > > From: Rafał Miłecki > > > > Some LEDs can be related to particular devices described in DT. This > > property allows specifying such relations. E.g. USB LED should usually > > be used to indicate some USB port(s) state. > > > > Signed-off-by: Rafał Miłecki > > --- > > V2: Replace "usb-ports" with "led-triggers" property which is more generic > > and > > allows specifying other devices as well. > > > > When bindings patch is related to some followup implementation, they > > usually go > > through the same tree. > > > > Greg: this patch is based on top of e64b8cc72bf9 ("DT: leds: Improve > > examples by > > adding some context") from kernel/git/j.anaszewski/linux-leds.git . Is > > there any > > way to solve this dependency issue? Or should this patch wait until 3.11 is > > released? > > --- > > Documentation/devicetree/bindings/leds/common.txt | 16 > > 1 file changed, 16 insertions(+) > > > > diff --git a/Documentation/devicetree/bindings/leds/common.txt > > b/Documentation/devicetree/bindings/leds/common.txt > > index 24b656014089..17632a041196 100644 > > --- a/Documentation/devicetree/bindings/leds/common.txt > > +++ b/Documentation/devicetree/bindings/leds/common.txt > > @@ -49,6 +49,17 @@ Optional properties for child nodes: > > - panic-indicator : This property specifies that the LED should be used, > > if at all possible, as a panic indicator. > > > > +- led-triggers : List of devices that should trigger this LED activity. > > Some > > +LEDs can be related to a specific device and should somehow > > +indicate its state. E.g. USB 2.0 LED may react to device(s) in > > +a USB 2.0 port(s). Another common example is switch or router > > +with multiple Ethernet ports each of them having its own LED > > +assigned (assuminled-trigger-usbportg they are not hardwired). > > +In such cases this property should contain phandle(s) of > > +related device(s). In many cases LED can be related to more > > +than one device (e.g. one USB LED vs. multiple USB ports) so a > > +list of entries can be specified. > > + > > This implies that it is possible to define multiple triggers for > a LED class device but it is not supported by LED Trigger core. Not really relevant for designing (and future proofing) a binding. > There is linux,default-trigger property which allows to define one > trigger that will be initially assigned. > > I am aware that this is renamed usb-ports property from v1, > that attempts to address Rob's comment, but we can't do that this way. > Maybe usb-ports property could be documented in led-trigger-usbport's > specific bindings and a reference to it could be added next to the > related entry on the list of the available LED triggers (which is > actually missing) in Documentation/devicetree/bindings/leds/common.txt. I'm not going to accept something specific to USB. So the choice is make the existing property work for USB or design something more flexible and generic. Rob -- 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 26/37] xhci: use the trb_to_noop() helper for command trbs
From: Mathias Nyman > Sent: 20 January 2017 14:47 > Remove duplicate code by using trb_to_noop() when > handling Aborted commads ^n ... > xhci_dbg(xhci, "Turn aborted command %p to no-op\n", >i_cmd->command_trb); > - /* get cycle state from the original cmd trb */ > - cycle_state = le32_to_cpu( > - i_cmd->command_trb->generic.field[3]) & TRB_CYCLE; > - /* modify the command trb to no-op command */ > - i_cmd->command_trb->generic.field[0] = 0; > - i_cmd->command_trb->generic.field[1] = 0; > - i_cmd->command_trb->generic.field[2] = 0; > - i_cmd->command_trb->generic.field[3] = cpu_to_le32( > - TRB_TYPE(TRB_CMD_NOOP) | cycle_state); > + > + trb_to_noop(i_cmd->command_trb, TRB_CMD_NOOP); I was thinking you could move the trace inside trb_to_noop() by adding a parameter "aborted command". David -- 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: dwc3: gadget: read IN ep FIFO size from HW
Instead of assuming all IN endpoints support 1024 bytes, let's read the actual value from HW and pass that to gadget API. Signed-off-by: Felipe Balbi --- drivers/usb/dwc3/gadget.c | 43 +++ 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 0a664d8eba3f..c55940f9e9da 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1963,14 +1963,49 @@ static int dwc3_gadget_init_hw_endpoints(struct dwc3 *dwc, if (epnum == 0 || epnum == 1) { usb_ep_set_maxpacket_limit(&dep->endpoint, 512); + dep->endpoint.caps.type_control = true; dep->endpoint.maxburst = 1; dep->endpoint.ops = &dwc3_gadget_ep0_ops; if (!epnum) dwc->gadget.ep0 = &dep->endpoint; + } else if (direction) { + int mdwidth; + int size; + int num; + + mdwidth = DWC3_MDWIDTH(dwc->hwparams.hwparams0); + /* MDWIDTH is represented in bits, we need it in bytes */ + mdwidth /= 8; + + size = dwc3_readl(dwc->regs, DWC3_GTXFIFOSIZ(i)); + size = DWC3_GTXFIFOSIZ_TXFDEF(size); + + /* FIFO Depth is in MDWDITH bytes. Multiply */ + size *= mdwidth; + + /* Every packet has MDWIDTH bytes of overhead */ + size -= mdwidth; + num = size / 1024; + if (num == 0) + num = 1; + + size -= mdwidth * num; + size /= num; + + usb_ep_set_maxpacket_limit(&dep->endpoint, size); + + dep->endpoint.caps.type_iso = true; + dep->endpoint.caps.type_int = true; + + if (size == 1024) + dep->endpoint.caps.type_bulk = true; } else { int ret; usb_ep_set_maxpacket_limit(&dep->endpoint, 1024); + dep->endpoint.caps.type_iso = true; + dep->endpoint.caps.type_bulk = true; + dep->endpoint.caps.type_int = true; dep->endpoint.max_streams = 15; dep->endpoint.ops = &dwc3_gadget_ep_ops; list_add_tail(&dep->endpoint.ep_list, @@ -1981,14 +2016,6 @@ static int dwc3_gadget_init_hw_endpoints(struct dwc3 *dwc, return ret; } - if (epnum == 0 || epnum == 1) { - dep->endpoint.caps.type_control = true; - } else { - dep->endpoint.caps.type_iso = true; - dep->endpoint.caps.type_bulk = true; - dep->endpoint.caps.type_int = true; - } - dep->endpoint.caps.dir_in = !!direction; dep->endpoint.caps.dir_out = !direction; -- 2.11.0.295.gd7dffce1ce -- 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: dwc3: add quirk to handle DWC_USB3_NUM == DWC_USB3_NUM_IN_EPS
On 23/01/17 15:38, Rob Herring wrote: >> - tx-fifo-resize: determines if the FIFO *has* to be >> reallocated. >> + - snps,num_in_eps_quirk: when set core will over-ride the num_in_eps value. >> + - snps,num_in_eps_override: the value that will be used for num_in_eps when >> +num_in_eps_quirk is true > > Why do you need 2 properties? Presence of the prop eanbles the override > and the value of the prop provides the value. We don't, sorry Rob I didn't CC you on the follow up patch, we've decided to do everything in-code minus any DT bindings. --- bod -- 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 36/37] xhci: simplify how we store TDs in urb private data
From: David Laight > Sent: 23 January 2017 11:58 > From: Mathias Nyman > > Sent: 20 January 2017 14:47 > > > Instead of storing a zero length array of td pointers, and then > > allocate memory both for the td pointer array and the td's, just > > use a zero length array of actual td's in urb private data. > > This reminds me of an old patch that got reverted because things > broke because the lifetimes/accesses of the data wasn't the obvious one. Mathias checked (off list) and the handling of stalled endpoints has apparently changed - which is what caused the problem with the old patch. David -- 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: dwc3: add quirk to handle DWC_USB3_NUM == DWC_USB3_NUM_IN_EPS
On Thu, Jan 19, 2017 at 07:58:02PM +, Bryan O'Donoghue wrote: > - DWC_USB3_NUM indicates the number of Device mode single directional > endpoints, including OUT and IN endpoint 0. > > - DWC_USB3_NUM_IN_EPS indicates the maximum number of Device mode IN > endpoints active at any time, including control endpoint 0. > > It's possible to configure RTL such that DWC_USB3_NUM_EPS is equal to > DWC_USB3_NUM_IN_EPS. > > dwc3-core calculates the number of OUT endpoints as DWC_USB3_NUM minus > DWC_USB3_NUM_IN_EPS. If RTL has been configured with DWC_USB3_NUM_IN_EPS > equal to DWC_USB3_NUM then dwc3-core will calculate the number of OUT > endpoints as zero. > > For example a from dwc3_core_num_eps() shows: > [1.565000] /usb0@f01d: found 8 IN and 0 OUT endpoints > > This patch fixes this case by adding a snps,num_in_eps quirk and an > over-ride value for DWC_USB3_NUM_IN_EPS snps,num_in_eps_override. When the > quirk is declared then snps,num_in_eps_override will be used instead of > DWC_USB3_NUM_IN_EPS as the value of the number active IN endpoints. > > The minimum value specified for DWC_USB3_NUM_IN_EPS in the Designware > data-book is two, if snps,num_in_eps_quirk is declared but > snps,num_in_eps_override is omitted, then the minimum value will be used as > the default. > > Signed-off-by: Bryan O'Donoghue > --- > Documentation/devicetree/bindings/usb/dwc3.txt | 3 +++ > drivers/usb/dwc3/core.c| 11 +++ > drivers/usb/dwc3/core.h| 6 ++ > 3 files changed, 20 insertions(+) > > diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt > b/Documentation/devicetree/bindings/usb/dwc3.txt > index e3e6983..bb383bf 100644 > --- a/Documentation/devicetree/bindings/usb/dwc3.txt > +++ b/Documentation/devicetree/bindings/usb/dwc3.txt > @@ -55,6 +55,9 @@ Optional properties: > fladj_30mhz_sdbnd signal is invalid or incorrect. > > - tx-fifo-resize: determines if the FIFO *has* to be > reallocated. > + - snps,num_in_eps_quirk: when set core will over-ride the num_in_eps value. > + - snps,num_in_eps_override: the value that will be used for num_in_eps when > + num_in_eps_quirk is true Why do you need 2 properties? Presence of the prop eanbles the override and the value of the prop provides the value. Use '-' rather than '_'. > > This is usually a subnode to DWC3 glue to which it is connected. > -- 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: functionfs on dwc3, xhci host: endpoint cannot be used in both directions ?
Vincent Pelletier writes: > On Mon, 23 Jan 2017 16:30:57 +0200, Felipe Balbi > wrote: >> well, the IN limit can be lower than what HW reports depending on how >> your TX FIFO space is setup. > > And while I am in regdump, in case it would help (especially all the > GTXFIFOSIZ entries and GDBGFIFOSPACE ?) while lowering the number of > mail round-trips... thanks GHWPARAMS0 = 0x2020400a from this we get MDWIDTH = 64 / 8 = 8 GHWPARAMS7 = 0x038807e6 GTXFIFOSIZ(0) = 0x0042 fifo_size = 0x42 * MDWIDTH - 8 - 8 = 512 *(8 and 8 are overheads, more below) GTXFIFOSIZ(1) = 0x00420184 fifo_size = (0x184 * MDWIDTH) - 8 - 8 - 8 - 8 = 3072 GTXFIFOSIZ(2) = 0x01c60184 fifo_size = 3072 GTXFIFOSIZ(3) = 0x034a0184 fifo_size = 3072 GTXFIFOSIZ(4) = 0x04ce0082 fifo_size = (0x82 * MDWIDTH) - 8 - 8 = 1024 GTXFIFOSIZ(5) = 0x05500082 fifo_size = 1024 GTXFIFOSIZ(6) = 0x05d20082 fifo_size = 1024 GTXFIFOSIZ(7) = 0x06540082 fifo_size = 1024 GTXFIFOSIZ(8) = 0x06d60022 fifo_size = 1024 GTXFIFOSIZ(9) = 0x06f80022 fifo_size = (0x22 * MDIWDTH) - 8 - 8 = 256 GTXFIFOSIZ(10) = 0x071a0022 fifo_size = 256 GTXFIFOSIZ(11) = 0x073c0022 fifo_size = 256 GTXFIFOSIZ(12) = 0x075e0022 fifo_size = 256 GTXFIFOSIZ(13) = 0x07800022 fifo_size = 256 GTXFIFOSIZ(14) = 0x07a20022 fifo_size = 256 GTXFIFOSIZ(15) = 0x07c40022 fifo_size = 256 Seems like HW engineer wanted these last few endpoints to *not* support full USB3 packets. They are probably supposed to be used for Isochronous and/or Interrupts endpoints. At some point we need to support this as well. During initialization we should read FIFO size configuration and extract wMaxPacketSize for $endpoint from the HW. * the overheads are a bit funny. IIRC (I have to confirm), you have MDWIDTH overhead for every single endpoint. Plus MDWIDTH overhead for each full packet endpoint can support. So an endpoint with 3072 byte FIFO supports 3 full 1024 byte packets. So it has MDWIDTH * 3 + MDWIDTH overhead. -- balbi signature.asc Description: PGP signature
Re: functionfs on dwc3, xhci host: endpoint cannot be used in both directions ?
On Mon, 23 Jan 2017 16:30:57 +0200, Felipe Balbi wrote: > well, the IN limit can be lower than what HW reports depending on how > your TX FIFO space is setup. And while I am in regdump, in case it would help (especially all the GTXFIFOSIZ entries and GDBGFIFOSPACE ?) while lowering the number of mail round-trips... # grep -v '0x$' regdump GSBUSCFG0 = 0x0006 GSBUSCFG1 = 0x0f00 GTXTHRCFG = 0x230a GRXTHRCFG = 0x0280 GCTL = 0x45802002 GSTS = 0x3e80 GSNPSID = 0x5533250a GUID = 0x00040a00 GUCTL = 0x0200ce00 GHWPARAMS0 = 0x2020400a GHWPARAMS1 = 0x0260c93b GHWPARAMS2 = 0x008086a0 GHWPARAMS3 = 0x10420089 GHWPARAMS4 = 0x47a22004 GHWPARAMS5 = 0x04202088 GHWPARAMS6 = 0x0c00ac20 GHWPARAMS7 = 0x038807e6 GDBGFIFOSPACE = 0x00b3 GDBGLTSSM = 0x01090658 GUSB2PHYCFG(0) = 0xa650 GUSB2PHYACC(0) = 0x01030015 GUSB3PIPECTL(0) = 0x02020002 GTXFIFOSIZ(0) = 0x0042 GTXFIFOSIZ(1) = 0x00420184 GTXFIFOSIZ(2) = 0x01c60184 GTXFIFOSIZ(3) = 0x034a0184 GTXFIFOSIZ(4) = 0x04ce0082 GTXFIFOSIZ(5) = 0x05500082 GTXFIFOSIZ(6) = 0x05d20082 GTXFIFOSIZ(7) = 0x06540082 GTXFIFOSIZ(8) = 0x06d60022 GTXFIFOSIZ(9) = 0x06f80022 GTXFIFOSIZ(10) = 0x071a0022 GTXFIFOSIZ(11) = 0x073c0022 GTXFIFOSIZ(12) = 0x075e0022 GTXFIFOSIZ(13) = 0x07800022 GTXFIFOSIZ(14) = 0x07a20022 GTXFIFOSIZ(15) = 0x07c40022 GRXFIFOSIZ(0) = 0x0385 GRXFIFOSIZ(1) = 0x0385 GRXFIFOSIZ(2) = 0x0385 GEVNTADRLO(0) = 0x34ede000 GEVNTSIZ(0) = 0x1000 GHWPARAMS8 = 0x0c00 DCFG = 0x004e0994 DCTL = 0x8cf00a00 DEVTEN = 0x1217 DSTS = 0x000315c8 DALEPENA = 0x DEPCMDPAR1(0) = 0x34ec1000 DEPCMD(0) = 0x0006 DEPCMDPAR1(1) = 0x34ec1000 DEPCMD(1) = 0x00010006 DEPCMD(2) = 0x00020007 DEPCMD(3) = 0x00030007 DEPCMD(4) = 0x00040007 DEPCMD(5) = 0x00050007 DEPCMD(6) = 0x00060007 DEPCMD(7) = 0x00070007 DEPCMD(8) = 0x00080007 DEPCMD(9) = 0x00090007 DEPCMD(10) = 0x000a0007 DEPCMD(11) = 0x000b0007 DEPCMD(12) = 0x000c0007 DEPCMD(13) = 0x000d0007 DEPCMD(14) = 0x000e0007 DEPCMD(15) = 0x000f0007 DEPCMD(16) = 0x0017 DEPCMD(17) = 0x00110007 DEPCMD(18) = 0x00120007 DEPCMD(19) = 0x00130007 DEPCMD(20) = 0x00140007 DEPCMD(21) = 0x00150007 DEPCMD(22) = 0x00160007 DEPCMD(23) = 0x00170007 DEPCMD(24) = 0x00180007 DEPCMD(25) = 0x00190007 DEPCMD(26) = 0x001a0007 DEPCMD(27) = 0x001b0007 DEPCMD(28) = 0x001c0007 DEPCMD(29) = 0x001d0007 DEPCMD(30) = 0x001e0007 DEPCMD(31) = 0x001f0007 OCTL = 0x0040 OEVT = 0x8002 OSTS = 0x201f This is with the 30-endpoints function enabled and idling. Regards, -- Vincent Pelletier pgpwwD_oSMBpT.pgp Description: Signature digitale OpenPGP
[PATCH linux-next v2 0/1] usb: gadget: udc: atmel: Update endpoint allocation scheme
From: Cristian Birsan Hi, This patch updates the usb endpoint allocation scheme for atmel usba driver to make sure all endpoints are allocated in order. This requirement comes from the datasheet of the controller. The allocation scheme is decided by fifo_mode parameter. For fifo_mode = 0 the driver tries to autoconfigure the endpoints fifo size. All other modes contain fixed configurations optimized for different purposes. The idea is somehow similar with the approach used on musb driver. Please let me know if you have any comments or suggestions. Changes since v1: - Minor reworks based on received fedback Kind regards, Cristian Cristian Birsan (1): usb: gadget: udc: atmel: Update endpoint allocation scheme drivers/usb/gadget/udc/Kconfig | 14 ++ drivers/usb/gadget/udc/atmel_usba_udc.c | 236 +++- drivers/usb/gadget/udc/atmel_usba_udc.h | 10 +- 3 files changed, 227 insertions(+), 33 deletions(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCHv15 2/3] usb: USB Type-C connector class
Hi, Heikki Krogerus writes: > +static void typec_report_identity(struct device *dev) > +{ > + sysfs_notify(&dev->kobj, "identity", "id_header"); > + sysfs_notify(&dev->kobj, "identity", "cert_stat"); > + sysfs_notify(&dev->kobj, "identity", "product"); if you sysfs_notify() all three everytime this might cause issues for userspace pollers. What will happen is that you're gonna change e.g. id_header and threads polling id_header, cert_stat and product will be notified of what's supposed to be new data. Maybe this should know what it's notifying and only notify what actually changed. Seems like just passing one extra char * argument is enough: static void typec_report_identity(struct device *dev, const char *prop) { sysfs_notify(&dev->kobj, "identity", prop); } > +static ssize_t power_role_show(struct device *dev, > +struct device_attribute *attr, char *buf) > +{ > + struct typec_port *port = to_typec_port(dev); > + > + if (port->cap->type == TYPEC_PORT_DRP) > + return sprintf(buf, "%s\n", port->pwr_role == TYPEC_SOURCE ? > +"[source] sink" : "source [sink]"); > + > + return sprintf(buf, "[%s]\n", typec_roles[port->pwr_role]); > +} > +static DEVICE_ATTR_RW(power_role); > + > +static const char * const typec_pwr_opmodes[] = { > + [TYPEC_PWR_MODE_USB]= "default", > + [TYPEC_PWR_MODE_1_5A] = "1.5A", > + [TYPEC_PWR_MODE_3_0A] = "3.0A", > + [TYPEC_PWR_MODE_PD] = "usb_power_delivery", do you need this to have underscores? How about "USB Power Delivery", instead? Userland could use the string untreated as part of GUI. > +static ssize_t vconn_source_store(struct device *dev, > + struct device_attribute *attr, > + const char *buf, size_t size) > +{ > + struct typec_port *port = to_typec_port(dev); > + enum typec_role role; > + int ret; > + > + if (!port->cap->pd_revision) { > + dev_dbg(dev, "VCONN swap depends on USB Power Delivery\n"); > + return -EOPNOTSUPP; > + } > + > + if (!port->cap->vconn_set) { > + dev_dbg(dev, "VCONN swapping not supported\n"); > + return -EOPNOTSUPP; > + } > + > + if (sysfs_streq(buf, "1")) > + role = TYPEC_SOURCE; > + else if (sysfs_streq(buf, "0")) > + role = TYPEC_SINK; > + else > + return -EINVAL; seems to me this could be stringified (both store and show) to "source" and "sink". > + > + ret = port->cap->vconn_set(port->cap, role); > + if (ret) > + return ret; > + > + return size; > +} > + > +static ssize_t vconn_source_show(struct device *dev, > + struct device_attribute *attr, char *buf) > +{ > + struct typec_port *port = to_typec_port(dev); > + > + return sprintf(buf, "%d\n", port->vconn_role == TYPEC_SOURCE ? 1 : 0); > +} > +static DEVICE_ATTR_RW(vconn_source); > + > +static ssize_t supported_accessory_modes_show(struct device *dev, > + struct device_attribute *attr, > + char *buf) > +{ > + struct typec_port *port = to_typec_port(dev); > + ssize_t ret = 0; > + int i; > + > + if (!port->cap->accessory) > + return 0; > + > + for (i = 0; port->cap->accessory[i]; i++) > + ret += sprintf(buf + ret, "%s ", > +typec_accessory_modes[port->cap->accessory[i]]); possible buffer overflow here? -- balbi signature.asc Description: PGP signature
Re: functionfs on dwc3, xhci host: endpoint cannot be used in both directions ?
Hi, Vincent Pelletier writes: > On Mon, 23 Jan 2017 16:30:57 +0200, Felipe Balbi > wrote: >> hmmm, what does the following show? >> >> # mkdir -p /d >> # mount -t debugfs none /d >> # grep HWPARAMS3 /d/*dwc3*/regdump > > # grep HWPARAMS3 /sys/kernel/debug/*dwc3*/regdump > GHWPARAMS3 = 0x10420089 odd, this board was configured with support for all 32 endpoints. You should not be running out of FIFO space and you can have all 16 IN endpoints enabled at the same time. This all shouldn't matter for you. Unless total TX FIFO size isn't large enough for all 16 endpoints, which I kinda doubt. -- balbi signature.asc Description: PGP signature
Re: [PATCH v5] USB: Add uPD78F0730 USB to Serial Adaptor Driver
On Sun, Jan 22, 2017 at 12:32:16AM +0300, Maksim Salau wrote: > The adaptor can be found on development boards for 78k, RL78 and V850 > microcontrollers produced by Renesas Electronics Corporation. > > This is not a full-featured USB to serial converter, however it allows > basic communication and simple control which is enough for programming of > on-board flash and debugging through a debug monitor. > > uPD78F0730 is a USB-enabled microcontroller with USB-to-UART conversion > implemented in firmware. > > This chip is also present in some debugging adaptors which use it for > USB-to-SPI conversion as well. The present driver doesn't cover SPI, > only USB-to-UART conversion is supported. > > Signed-off-by: Maksim Salau > --- > Changes in v5: > Fixed a typo in assignment of opcode of the SET_DTR_RTS request > > Changes in v4: > Addressed comments from Johan You made some further changes than what I suggested but forgot to document those. Often better to explicitly list the changes made rather than refer to review comments this way. This already looks really good; just a few minor things noted below. > drivers/usb/serial/Kconfig | 9 + > drivers/usb/serial/Makefile | 1 + > drivers/usb/serial/upd78f0730.c | 458 > > 3 files changed, 468 insertions(+) > create mode 100644 drivers/usb/serial/upd78f0730.c > +static int upd78f0730_send_ctl(struct usb_serial_port *port, > + void *data, int size) > +{ > + struct device *dev = &port->dev; > + struct usb_device *usbdev = port->serial->dev; > + void *buf; > + int res; > + > + if (!size || !data) > + return -EINVAL; > + > + buf = kmemdup(data, size, GFP_KERNEL); > + if (!buf) > + return -ENOMEM; > + > + res = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x00, > + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, > + 0x, 0x, buf, size, USB_CTRL_SET_TIMEOUT); > + > + kfree(buf); > + > + if (res < 0) > + return res; > + > + if (res != size) { > + dev_err(dev, "%s - send failed: opcode=%02x, size=%d, res=%d\n", > + __func__, *(u8 *)data, size, res); You still want an error message in case res < 0 (as in v3), but you can return that errno instead of -EIO then. You can drop the __func__ prefixes you added to error messages in v5 throughout, better to spell out what went wrong (e.g. "failed to send control request %02x: %d\n", *(u8 *)data, res). > + /* The maximum expected length of a transfer is 6 bytes */ > + return -EIO; > + } > + > + return 0; > +} > + > +static int upd78f0730_attach(struct usb_serial *serial) > +{ > + const char num_ports = serial->num_ports; > + > + if (serial->num_bulk_in < num_ports || > + serial->num_bulk_out < num_ports) { > + dev_err(&serial->interface->dev, "%s - missing endpoints\n", > + __func__); > + return -ENODEV; > + } > + > + return 0; > +} This is new in v5, and should have been mentioned in the changelog above. Note that this is not strictly necessary, though. Some drivers dereferenced pointers without the appropriate sanity checks, but this driver and the generic callbacks it uses, does not suffer from such problems. I suggest you just drop this check (i.e. the attach callback). > +static int upd78f0730_tiocmget(struct tty_struct *tty) > +{ > + struct device *dev = tty->dev; > + struct upd78f0730_port_private *private; > + struct usb_serial_port *port = tty->driver_data; > + int signals; > + int res; > + > + private = usb_get_serial_port_data(port); > + > + mutex_lock(&private->lock); > + signals = private->line_signals; > + mutex_unlock(&private->lock); > + > + res = ((signals & UPD78F0730_DTR) ? TIOCM_DTR : 0) | > + ((signals & UPD78F0730_RTS) ? TIOCM_RTS : 0); > + > + dev_dbg(dev, "%s - res = %x\n", __func__, res); Note that __func__ is fine for concise debug messages like this one (that users generally won't see). But please drop it from all ERR and WARN messages. > + > + return res; > +} Thanks, Johan -- 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 linux-next v2 1/1] usb: gadget: udc: atmel: Update endpoint allocation scheme
From: Cristian Birsan Update atmel udc driver with a new enpoint allocation scheme. The data sheet requires that all endpoints are allocated in order. Signed-off-by: Cristian Birsan --- drivers/usb/gadget/udc/Kconfig | 14 ++ drivers/usb/gadget/udc/atmel_usba_udc.c | 236 +++- drivers/usb/gadget/udc/atmel_usba_udc.h | 10 +- 3 files changed, 227 insertions(+), 33 deletions(-) diff --git a/drivers/usb/gadget/udc/Kconfig b/drivers/usb/gadget/udc/Kconfig index 658b8da..4b69f28 100644 --- a/drivers/usb/gadget/udc/Kconfig +++ b/drivers/usb/gadget/udc/Kconfig @@ -60,6 +60,20 @@ config USB_ATMEL_USBA USBA is the integrated high-speed USB Device controller on the AT32AP700x, some AT91SAM9 and AT91CAP9 processors from Atmel. + The fifo_mode parameter is used to select endpoint allocation mode. + fifo_mode = 0 is used to let the driver autoconfigure the endpoints. + In this case 2 banks are allocated for isochronous endpoints and + only one bank is allocated for the rest of the endpoints. + + fifo_mode = 1 is a generic maximum fifo size (1024 bytes) configuration + allowing the usage of ep1 - ep6 + + fifo_mode = 2 is a generic performance maximum fifo size (1024 bytes) + configuration allowing the usage of ep1 - ep3 + + fifo_mode = 3 is a balanced performance configuration allowing the + the usage of ep1 - ep8 + config USB_BCM63XX_UDC tristate "Broadcom BCM63xx Peripheral Controller" depends on BCM63XX diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c index 12c7687..11bbce2 100644 --- a/drivers/usb/gadget/udc/atmel_usba_udc.c +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -318,6 +319,91 @@ static inline void usba_cleanup_debugfs(struct usba_udc *udc) } #endif +static ushort fifo_mode; + +/* "modprobe ... fifo_mode=1" etc */ +module_param(fifo_mode, ushort, 0x0); +MODULE_PARM_DESC(fifo_mode, "Endpoint configuration mode"); + +/* mode 0 - uses autoconfig */ + +/* mode 1 - fits in 8KB, generic max fifo configuration */ +static struct usba_fifo_cfg mode_1_cfg[] = { +{ .hw_ep_num = 0, .fifo_size = 64, .nr_banks = 1, }, +{ .hw_ep_num = 1, .fifo_size = 1024, .nr_banks = 2, }, +{ .hw_ep_num = 2, .fifo_size = 1024, .nr_banks = 1, }, +{ .hw_ep_num = 3, .fifo_size = 1024, .nr_banks = 1, }, +{ .hw_ep_num = 4, .fifo_size = 1024, .nr_banks = 1, }, +{ .hw_ep_num = 5, .fifo_size = 1024, .nr_banks = 1, }, +{ .hw_ep_num = 6, .fifo_size = 1024, .nr_banks = 1, }, +}; + +/* mode 2 - fits in 8KB, performance max fifo configuration */ +static struct usba_fifo_cfg mode_2_cfg[] = { +{ .hw_ep_num = 0, .fifo_size = 64, .nr_banks = 1, }, +{ .hw_ep_num = 1, .fifo_size = 1024, .nr_banks = 3, }, +{ .hw_ep_num = 2, .fifo_size = 1024, .nr_banks = 2, }, +{ .hw_ep_num = 3, .fifo_size = 1024, .nr_banks = 2, }, +}; + +/* mode 3 - fits in 8KB, mixed fifo configuration */ +static struct usba_fifo_cfg mode_3_cfg[] = { +{ .hw_ep_num = 0, .fifo_size = 64, .nr_banks = 1, }, +{ .hw_ep_num = 1, .fifo_size = 1024, .nr_banks = 2, }, +{ .hw_ep_num = 2, .fifo_size = 512,.nr_banks = 2, }, +{ .hw_ep_num = 3, .fifo_size = 512,.nr_banks = 2, }, +{ .hw_ep_num = 4, .fifo_size = 512,.nr_banks = 2, }, +{ .hw_ep_num = 5, .fifo_size = 512,.nr_banks = 2, }, +{ .hw_ep_num = 6, .fifo_size = 512,.nr_banks = 2, }, +}; + +/* mode 4 - fits in 8KB, custom fifo configuration */ +static struct usba_fifo_cfg mode_4_cfg[] = { +{ .hw_ep_num = 0, .fifo_size = 64, .nr_banks = 1, }, +{ .hw_ep_num = 1, .fifo_size = 512,.nr_banks = 2, }, +{ .hw_ep_num = 2, .fifo_size = 512,.nr_banks = 2, }, +{ .hw_ep_num = 3, .fifo_size = 8, .nr_banks = 2, }, +{ .hw_ep_num = 4, .fifo_size = 512,.nr_banks = 2, }, +{ .hw_ep_num = 5, .fifo_size = 512,.nr_banks = 2, }, +{ .hw_ep_num = 6, .fifo_size = 16, .nr_banks = 2, }, +{ .hw_ep_num = 7, .fifo_size = 8, .nr_banks = 2, }, +{ .hw_ep_num = 8, .fifo_size = 8, .nr_banks = 2, }, +}; +/* Add additional configurations here */ + +int usba_config_fifo_table(struct usba_udc *udc) +{ + int n; + + switch (fifo_mode) { + default: + fifo_mode = 0; + case 0: + udc->fifo_cfg = NULL; + n = 0; + break; + case 1: + udc->fifo_cfg = mode_1_cfg; + n = ARRAY_SIZE(mode_1_cfg); + break; + case 2: + udc->fifo_cfg = mode_2_cfg; + n = ARRAY_SIZE(mode_2_cfg); + break; + case 3: + udc->fifo_cfg = mode_3_cfg; + n = ARRAY_SIZE(mode_3_cfg); + break; + case 4: + udc->fifo_cfg = mode_4_cfg; + n = ARRAY_SIZE(mode_4_cfg); + break; +
usb: gadget: f_fs: Accept up to 30 endpoints.
It is allowed by the USB specification to enabled same-address, opposite- direction endpoints simultaneously, which means 30 non-zero endpoints are allowed. So double eps_addrmap length to 30. The original code only accepted 14 descriptors out of a likely intended 15 (as there are 15 endpoint addresses, ignoring direction), because the first eps_addrmap entry is unused (it is a placeholder for endpoint zero). So increase eps_addrmap length by one to 31. Signed-off-by: Vincent Pelletier --- drivers/usb/gadget/function/f_fs.c | 2 +- drivers/usb/gadget/function/u_fs.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index 5c91a6f4613b..c4364c87 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -2101,7 +2101,7 @@ static int __ffs_data_do_entity(enum ffs_entity_type type, case FFS_ENDPOINT: d = (void *)desc; helper->eps_count++; - if (helper->eps_count >= 15) + if (helper->eps_count >= FFS_MAX_EPS_COUNT) return -EINVAL; /* Check if descriptors for any speed were already parsed */ if (!helper->ffs->eps_count && !helper->ffs->interfaces_count) diff --git a/drivers/usb/gadget/function/u_fs.h b/drivers/usb/gadget/function/u_fs.h index 60139854e0b1..4b6969451cdc 100644 --- a/drivers/usb/gadget/function/u_fs.h +++ b/drivers/usb/gadget/function/u_fs.h @@ -247,7 +247,8 @@ struct ffs_data { unsigneduser_flags; - u8 eps_addrmap[15]; +#define FFS_MAX_EPS_COUNT 31 + u8 eps_addrmap[FFS_MAX_EPS_COUNT]; unsigned short strings_count; unsigned short interfaces_count; -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: functionfs on dwc3, xhci host: endpoint cannot be used in both directions ?
Changes since try 1: - impove commit message a bit - #declare array size to avoid duplication -- 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: functionfs on dwc3, xhci host: endpoint cannot be used in both directions ?
On Mon, 23 Jan 2017 16:30:57 +0200, Felipe Balbi wrote: > hmmm, what does the following show? > > # mkdir -p /d > # mount -t debugfs none /d > # grep HWPARAMS3 /d/*dwc3*/regdump # grep HWPARAMS3 /sys/kernel/debug/*dwc3*/regdump GHWPARAMS3 = 0x10420089 Regards, -- Vincent Pelletier pgp9ZJv9GNzfE.pgp Description: Signature digitale OpenPGP
Re: [PATCH 36/37] xhci: simplify how we store TDs in urb private data
On 23.01.2017 14:15, Mathias Nyman wrote: On 23.01.2017 13:57, David Laight wrote: From: Mathias Nyman Sent: 20 January 2017 14:47 Instead of storing a zero length array of td pointers, and then allocate memory both for the td pointer array and the td's, just use a zero length array of actual td's in urb private data. This reminds me of an old patch that got reverted because things broke because the lifetimes/accesses of the data wasn't the obvious one. Can you recall more details about that case? I'd hate to revert this later. Thanks for the (off list) info. You submitted a similar patch in 2013, but it caused a regression and was not applied: https://www.spinics.net/lists/linux-usb/msg99748.html Reason it regressed back then was because we handled stalled endpoints a bit differently. We saved a pointer to the current TD of a stalled endpoint, then gave back the URB, and freed urb_priv, but _not_ the TD that urb_priv->td[x] pointed to. This TD was later used in the endpoint reset callback to figure out where we should set the dequeue pointer of that ring. Handling stalled endpoints has changed since then. We don't store the TD pointer in STALL cases, and we free the urb_priv completely when giving back the URB see: commit 8e71a322fdb127814bcba423a512914ca5bc6cf5 USB: xhci: Reset a halted endpoint immediately when we encounter a stall. So now it should work -Mathias -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: functionfs on dwc3, xhci host: endpoint cannot be used in both directions ?
Hi, Vincent Pelletier writes: > On Mon, 23 Jan 2017 14:00:40 +0200, Felipe Balbi > wrote: >> it could be that we're ran out of IN endpoints. There's a maximum number >> to how many IN endpoints we can have enabled at one time and, currently, >> dwc3 is not enforcing that in any way (I'll get that sorted out for >> v4.12, v4.11 is already too late) > > 8OUT failing also caught my eye, which is the only OUT endpoint > failing. And it happens when ep_addr & 0x7 == 0. Could something > (hardware ?) be confused and handle this as a kind of EP0 ? hmmm, what does the following show? # mkdir -p /d # mount -t debugfs none /d # grep HWPARAMS3 /d/*dwc3*/regdump > Then, there would be 3 patterns to my uneducated eye: > - 15IN and several downward would fail because of the dwc3 active IN > endpoint limit you mention > - 8IN and 8OUT would fail for some aliasing-with-EP0 reason > - 1IN and 9IN may fail for a related reason (depending on where the IN > endpoint limit exactly stands - 8 or 9 I guess - and whether EP0 > counts towards the limit) well, the IN limit can be lower than what HW reports depending on how your TX FIFO space is setup. > BTW, I also checked what my protocol analyser says in this 30-endpoints > version, but the result is quite boring: > - all (failing) IN endpoints NAK > - the one failing OUT endpoint NAKs the first attempt, then follows the > PING protocol (MAK'ing all PINGs until the 0.2s timeout I set in the > host test app). > Addresses are properly transmitted (ie, it's not on bus level that EP8 > would get aliased). I still could not find the time to rebuild my > machine's kernel on your xhci-cleanup branch, so I'm still on 4.8.11 > from a bit outdated Debian sid package). > > I also noticed your commit about dwc3 having problems when clearing > halt of an already non-halted endpoint (and reciprocally), and I do > clear halts in the device test program. I tried commenting that out in > my program and merging your testing/next branch in my working copy, > without any improvement. thorough testing, thanks :-) -- balbi signature.asc Description: PGP signature
Re: [PATCH v3 2/3] dmaengine: cppi41: Add support of DA8xx to CPPI 4.1
On 01/19/2017 07:15 PM, Sergei Shtylyov wrote: > On 01/19/2017 02:13 PM, Alexandre Bailon wrote: > > > The DA8xx has a CPPI 4.1 DMA controller. > > This is add the glue layer required to make it work on DA8xx. > > > > Signed-off-by: Alexandre Bailon > > --- > > drivers/dma/Kconfig | 6 +++--- > > drivers/dma/cppi41.c | 24 > > 2 files changed, 27 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig > > index 0d6a96e..03ae2a1 100644 > > --- a/drivers/dma/Kconfig > > +++ b/drivers/dma/Kconfig > > @@ -514,12 +514,12 @@ config TIMB_DMA > >Enable support for the Timberdale FPGA DMA engine. > > > > config TI_CPPI41 > > -tristate "AM33xx CPPI41 DMA support" > > -depends on ARCH_OMAP > > +tristate "CPPI41 DMA support" > >Grr... CPPI 4.1, please. > > > +depends on (ARCH_OMAP || ARCH_DAVINCI_DA8XX) > > select DMA_ENGINE > > help > >The Communications Port Programming Interface (CPPI) 4.1 DMA > > engine > > - is currently used by the USB driver on AM335x platforms. > > + is currently used by the USB driver on AM335x and DA8xx platforms. > > > > config TI_DMA_CROSSBAR > > bool > > diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c > > index 9767b97..f6f2d84 100644 > > --- a/drivers/dma/cppi41.c > > +++ b/drivers/dma/cppi41.c > [...] > > @@ -951,8 +965,18 @@ static const struct cppi_glue_infos > > am335x_usb_infos = { > > .qmgr_num_pend = 5, > > }; > > > > +static const struct cppi_glue_infos da8xx_usb_infos = { > > +.isr = cppi41_irq, > >Isn't the ISR the same for all glues now? True. I should remove isr callback. > > [...] > > MBR, Sergei > -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC] usb: gadget: uvc: webcam gadget USB PID is using value from a different gadget
Hi, Greg KH writes: >> >> fine by me. Just lsusb will look funky ;-) >> > >> > Heh, true, but I thought lsusb would use a string if the device provided >> > it. Haven't looked at that portion of the code in a very long time... >> > >> >> My lsusb shows separate strings (using usbutils from slackware64-current): >> >> Bus 004 Device 003: ID 1d6b:0102 Linux Foundation EEM Gadget >> ... >> idVendor 0x1d6b Linux Foundation >> idProduct 0x0102 EEM Gadget >> bcdDevice4.07 >> iManufacturer 1 Linux Foundation >> iProduct2 Webcam gadget >> ... > > Ah, I guess it doesn't, but who knows how old that version of usbutils > is, considering the last release I did was well over a year ago. I > should do a new one one of these days... > > Anyway, I'd like to not assign a product id to a chunk of code that is > going to be eventually deleted. Felipe, what's the plan for the > "legacy" gadget code. Is it ever going away? Well, I wasn't really planning on deleting them just stopped accepting any new one. I wanted to avoid angry mobs complaining about not having a g_mass_storage.ko anymore. Personally, I don't feel strongly about the legacy gadget drivers. They're not really needed anymore as everything they do can be done with configfs already. Perhaps we could schedule their removal for v5.0? -- balbi signature.asc Description: PGP signature
Re: functionfs on dwc3, xhci host: endpoint cannot be used in both directions ?
Hello, On Mon, 23 Jan 2017 14:00:40 +0200, Felipe Balbi wrote: > it could be that we're ran out of IN endpoints. There's a maximum number > to how many IN endpoints we can have enabled at one time and, currently, > dwc3 is not enforcing that in any way (I'll get that sorted out for > v4.12, v4.11 is already too late) 8OUT failing also caught my eye, which is the only OUT endpoint failing. And it happens when ep_addr & 0x7 == 0. Could something (hardware ?) be confused and handle this as a kind of EP0 ? Then, there would be 3 patterns to my uneducated eye: - 15IN and several downward would fail because of the dwc3 active IN endpoint limit you mention - 8IN and 8OUT would fail for some aliasing-with-EP0 reason - 1IN and 9IN may fail for a related reason (depending on where the IN endpoint limit exactly stands - 8 or 9 I guess - and whether EP0 counts towards the limit) BTW, I also checked what my protocol analyser says in this 30-endpoints version, but the result is quite boring: - all (failing) IN endpoints NAK - the one failing OUT endpoint NAKs the first attempt, then follows the PING protocol (MAK'ing all PINGs until the 0.2s timeout I set in the host test app). Addresses are properly transmitted (ie, it's not on bus level that EP8 would get aliased). I still could not find the time to rebuild my machine's kernel on your xhci-cleanup branch, so I'm still on 4.8.11 from a bit outdated Debian sid package). I also noticed your commit about dwc3 having problems when clearing halt of an already non-halted endpoint (and reciprocally), and I do clear halts in the device test program. I tried commenting that out in my program and merging your testing/next branch in my working copy, without any improvement. Regards, -- Vincent Pelletier pgpvG5cslVx5L.pgp Description: Signature digitale OpenPGP
Re: [PATCHv15 3/3] usb: typec: add driver for Intel Whiskey Cove PMIC USB Type-C PHY
Hi, Heikki Krogerus writes: > +static int wcove_typec_probe(struct platform_device *pdev) > +{ [snip] > + wcove->cap.prefer_role = TYPEC_NO_PREFERRED_ROLE; we have a slight problem here that affects users of this particular driver. Well, more specifically, it affects Intel Joule. Because of the way ASL was written and the way Intel's DRD mux works, we don't have a state which means "don't route USB signals to either Host or Peripheral". Because of that, when we plug the type-c cable either XHCI or dwc3 will have noise coming into the IP. If default mode ends up being peripheral we have two possible problems here: i) device-to-device cable assembly this won't be a big problem because we will just negotiate who's Sink and who's Source then change mux on one side. ii) lack of disconnect IRQ on dwc3 Because of how ASL was written, when we unplug the cable, mux's VBUS_VALID bit won't be cleared which means dwc3 won't generate disconnect interrupt. This means that upon cable reconnect (!!) we will run ->disconnect() callback. The result is that dwc3 will never runtime suspend. If default mode ends up being host we're possibly going to end up with a host-to-host cable assembly. Now this can cause 2 issues: i) port config error host-to-host is not a supported cable assembly. While we see errors on dmesg, eventually type-c negotiation will happen and nothing will actually break. ii) DbC can start on the other end of the cable Now this was really surprising to me. When testing this on Intel Joule and plugging Intel Joule straight to my PC's roothub port, I noticed Joule ended up being host and my Desktop () became a peripheral enumerated by Joule. I can only assume this is DbC somehow being started. The only way to have Joule become a peripheral is to connect it through an external hub to my PC. Odd, ain't it? I'm not sure how to solve this problem apart from modifying BIOS :-( Any ideas? -- balbi signature.asc Description: PGP signature
Re: [RFC] usb: gadget: uvc: webcam gadget USB PID is using value from a different gadget
On Mon, Jan 23, 2017 at 12:47:31PM +0100, Petr Cvek wrote: > Dne 23.1.2017 v 12:32 Greg KH napsal(a): > I know it is only a cosmetic change on a legacy driver, but I assume > it would be better to have some default value for configfs API than to > borrow a PID from a whole different gadget. > >>> > >>> For class devices, they really don't need a new id, we should just use > >>> only one of them as it doesn't matter :) > >> > > So using 0106 "Composite gadget: ACM + Mass Storage" or 0104 > "Multifunction Composite Gadget" should be fine? (my actual setup is > not multifunction though). > > I'm actually trying to catch bug, when using configfs access webcam > does not work or kernel oopses (and webcam does not work) :-D. The product id should never be an issue for a bug, if so, then something a lot worse is going on. > >> fine by me. Just lsusb will look funky ;-) > > > > Heh, true, but I thought lsusb would use a string if the device provided > > it. Haven't looked at that portion of the code in a very long time... > > > > My lsusb shows separate strings (using usbutils from slackware64-current): > > Bus 004 Device 003: ID 1d6b:0102 Linux Foundation EEM Gadget > ... > idVendor 0x1d6b Linux Foundation > idProduct 0x0102 EEM Gadget > bcdDevice4.07 > iManufacturer 1 Linux Foundation > iProduct2 Webcam gadget > ... Ah, I guess it doesn't, but who knows how old that version of usbutils is, considering the last release I did was well over a year ago. I should do a new one one of these days... Anyway, I'd like to not assign a product id to a chunk of code that is going to be eventually deleted. Felipe, what's the plan for the "legacy" gadget code. Is it ever going away? 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] HID: get rid of HID_QUIRK_NO_INIT_REPORTS
On Thu, 5 Jan 2017, Benjamin Tissoires wrote: > I don't know what to do about hiddev too. I don't know if we have actual > users besides some debugging tools. And hidraw is much better than > hiddev, so ideally, I'd like to remove it some way. First, I'd love to get rid of HID_QUIRK_NO_INIT_REPORTS; I am whole-heartedly convinced that initializing reports was a big mistake to start with, but changing history is hard :) Regarding hiddev -- there actually are 'legitimate' non-debug users; for example NUT (UPS management software) has been using it last time I looked. I am pretty sure there are more. So we'd rather be careful not to break hiddev by default. I'll think about your RFC a little bit more. Thanks, -- Jiri Kosina SUSE Labs -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RESEND PATCH 6/6] dt-bindings: phy-mt65xx-usb: add support for mt2712 platform
On Sat, Jan 21, 2017 at 8:50 PM, Chunfeng Yun wrote: > On Sat, 2017-01-21 at 14:08 -0600, Rob Herring wrote: >> On Wed, Jan 18, 2017 at 02:00:14PM +0800, Chunfeng Yun wrote: >> > add a new compatible string for "mt2712", and a new reference clock >> > for SuperSpeed analog phy; >> > >> > Signed-off-by: Chunfeng Yun >> > --- >> > .../devicetree/bindings/phy/phy-mt65xx-usb.txt | 81 >> > +--- >> > 1 file changed, 70 insertions(+), 11 deletions(-) [...] >> > @@ -31,21 +37,27 @@ Example: >> > u3phy: usb-phy@1129 { >> > compatible = "mediatek,mt8173-u3phy"; >> > reg = <0 0x1129 0 0x800>; >> > - clocks = <&apmixedsys CLK_APMIXED_REF2USB_TX>; >> > - clock-names = "u3phya_ref"; >> > + clocks = <&apmixedsys CLK_APMIXED_REF2USB_TX>, <&clk26m>; >> > + clock-names = "u2ref_clk", "u3ref_clk"; >> > #address-cells = <2>; >> > #size-cells = <2>; >> > ranges; >> > status = "okay"; >> > >> > - phy_port0: port@11290800 { >> > - reg = <0 0x11290800 0 0x800>; >> > + u2port0: port@11290800 { >> >> port is for OF graph. This should be usb-phy@... instead. > Is there any problems if u2port0's name@addr is the same as its parent's > (u3phy)? as following: > u3phy: usb-phy@1129 { > compatible = ...; > // no reg property > clocks = ...; > u2port0: usb-phy@1129 { > reg = ...; > } No problem, that is fine. Rob -- 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 6/6] dt-bindings: mt8173-mtu3: add reference clock
On Sat, Jan 21, 2017 at 7:49 PM, Chunfeng Yun wrote: > Hi, > > On Sat, 2017-01-21 at 14:11 -0600, Rob Herring wrote: >> On Wed, Jan 18, 2017 at 02:08:27PM +0800, Chunfeng Yun wrote: >> > add a reference clock for compatibility >> >> Why? This block suddenly has 2 clocks instead of 1? > In fact, there is a reference clock which comes from 26M oscillator > directly. I ignore it because it is a fixed-clock in DTS, and always > turned on for mt8173. But later, I find that I made a mistake before > when I bring up it on a new platform whose reference clock comes from > PLL, and need control it. So here add it, no matter it is a fixed-clock > or not. Add this explanation to the changelog. Rob -- 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 1/3] usb: musb: dma: Add a DMA completion platform callback
On 01/20/2017 09:00 PM, Bin Liu wrote: > On Thu, Jan 19, 2017 at 11:06:57AM +0100, Alexandre Bailon wrote: >> Currently, the CPPI 4.1 driver is not completely generic and >> only work on dsps. This is because of IRQ management. >> Add a callback to dma_controller that could be invoked on DMA completion >> to acknodlege the IRQ. >> >> Signed-off-by: Alexandre Bailon >> --- >> drivers/usb/musb/musb_cppi41.c | 7 +-- >> drivers/usb/musb/musb_dma.h| 4 >> 2 files changed, 9 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c >> index 1636385..f7d3d27 100644 >> --- a/drivers/usb/musb/musb_cppi41.c >> +++ b/drivers/usb/musb/musb_cppi41.c >> @@ -217,6 +217,10 @@ static void cppi41_dma_callback(void *private_data) >> int is_hs = 0; >> bool empty; >> >> +controller = cppi41_channel->controller; >> +if (controller->controller.dma_callback) >> +controller->controller.dma_callback(&controller->controller); >> + >> spin_lock_irqsave(&musb->lock, flags); >> >> dmaengine_tx_status(cppi41_channel->dc, cppi41_channel->cookie, >> @@ -249,8 +253,6 @@ static void cppi41_dma_callback(void *private_data) >> * We spin on HS (no longer than than 25us and setup a timer on >> * FS to check for the bit and complete the transfer. >> */ >> -controller = cppi41_channel->controller; >> - >> if (is_host_active(musb)) { >> if (musb->port1_status & USB_PORT_STAT_HIGH_SPEED) >> is_hs = 1; >> @@ -695,6 +697,7 @@ cppi41_dma_controller_create(struct musb *musb, void >> __iomem *base) >> controller->controller.channel_program = cppi41_dma_channel_program; >> controller->controller.channel_abort = cppi41_dma_channel_abort; >> controller->controller.is_compatible = cppi41_is_compatible; >> +controller->controller.musb = musb; >> >> ret = cppi41_dma_controller_start(controller); >> if (ret) >> diff --git a/drivers/usb/musb/musb_dma.h b/drivers/usb/musb/musb_dma.h >> index 46357e1..8bea0cd 100644 >> --- a/drivers/usb/musb/musb_dma.h >> +++ b/drivers/usb/musb/musb_dma.h >> @@ -181,10 +181,13 @@ dma_channel_status(struct dma_channel *c) >> * @channel_release: call this to release a DMA channel >> * @channel_abort: call this to abort a pending DMA transaction, >> * returning it to FREE (but allocated) state >> + * @platform_dma_callback: invoked on DMA completion, useful to run platform >> + * code such IRQ acknowledgment. >> * >> * Controllers manage dma channels. >> */ >> struct dma_controller { >> +struct musb *musb; > > Since musb is added here, can we clean up the corresponding one in > struct cppi41_dma_controller and struct cppi? Yes, and also for the one in tusb_omap_dma. > > Regards, > -Bin. > Regards, Alexandre -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2] usb: dwc3: handle DWC_USB3_NUM == DWC_USB3_NUM_IN_EPS
On 23/01/17 12:08, Felipe Balbi wrote: > > Hi, > > Bryan O'Donoghue writes: >> - DWC_USB3_NUM indicates the number of Device mode single directional >> endpoints, including OUT and IN endpoint 0. >> >> - DWC_USB3_NUM_IN_EPS indicates the maximum number of Device mode IN >> endpoints active at any time, including control endpoint 0. >> >> It's possible to configure RTL such that DWC_USB3_NUM_EPS is equal to >> DWC_USB3_NUM_IN_EPS. >> >> dwc3-core calculates the number of OUT endpoints as DWC_USB3_NUM minus >> DWC_USB3_NUM_IN_EPS. If RTL has been configured with DWC_USB3_NUM_IN_EPS >> equal to DWC_USB3_NUM then dwc3-core will calculate the number of OUT >> endpoints as zero. >> >> For example a from dwc3_core_num_eps() shows: >> [1.565000] /usb0@f01d: found 8 IN and 0 OUT endpoints >> >> This patch works around this case by detecting when DWC_USB3_NUM_EPS is >> equal to DWC3_USB3_NUM_IN_EPS and over-rides the calculation of the number >> of OUT and IN endpoints to make dwc->num_in_eps equal to half >> DWC_USB3_NUM_EPS. >> >> If DWC_USB3_NUM_EPS is equal to DWC3_USB3_NUM_IN_EPS and the endpoint count >> is an odd number then dwc->num_out_eps will be assigned the extra endpoint. > > sorry, now that I spent some more time with this. Isn't something like > below solving all problems? > > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c > index 369bab16a824..68c9c84b7216 100644 > --- a/drivers/usb/dwc3/core.c > +++ b/drivers/usb/dwc3/core.c > @@ -397,8 +397,7 @@ static void dwc3_core_num_eps(struct dwc3 *dwc) > { > struct dwc3_hwparams*parms = &dwc->hwparams; > > - dwc->num_in_eps = DWC3_NUM_IN_EPS(parms); > - dwc->num_out_eps = DWC3_NUM_EPS(parms) - dwc->num_in_eps; > + dwc->num_eps = DWC3_NUM_EPS(parms); > } > > static void dwc3_cache_hwparams(struct dwc3 *dwc) > diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c > index 0a664d8eba3f..8c187df0aa42 100644 > --- a/drivers/usb/dwc3/gadget.c > +++ b/drivers/usb/dwc3/gadget.c > @@ -2001,23 +2002,7 @@ static int dwc3_gadget_init_hw_endpoints(struct dwc3 > *dwc, > > static int dwc3_gadget_init_endpoints(struct dwc3 *dwc) > { > - int ret; > - > - INIT_LIST_HEAD(&dwc->gadget.ep_list); > - > - ret = dwc3_gadget_init_hw_endpoints(dwc, dwc->num_out_eps, 0); > - if (ret < 0) { > - dev_err(dwc->dev, "failed to initialize OUT endpoints\n"); > - return ret; > - } > - > - ret = dwc3_gadget_init_hw_endpoints(dwc, dwc->num_in_eps, 1); > - if (ret < 0) { > - dev_err(dwc->dev, "failed to initialize IN endpoints\n"); > - return ret; > - } > - > - return 0; > + return dwc3_gadget_init_hw_endpoints(dwc, dwc->num_eps); Well I hadn't considered that level of change myself but, it should work. > > static void dwc3_gadget_free_endpoints(struct dwc3 *dwc) > > (clearly this won't compile... It's just to illustrate) > > The HW actually already tells us total number of endpoints and according > to John, they can all behave in either direction. Can you test it out > and finish it up as a proper patch? Sure no problem. > > I'll make sure to fix up the "maximum number of IN endpoints enabled at > one time" for v4.12. > > thanks > -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC v2 1/5] UDC: Split the driver into amd (pci) and Synopsys core driver
Hi Florian, On Fri, Jan 20, 2017 at 12:58 AM, Florian Fainelli wrote: > On 01/19/2017 02:44 AM, Raviteja Garimella wrote: >> Hi, >> >> On Thu, Jan 19, 2017 at 12:15 AM, Florian Fainelli >> wrote: >>> On 01/17/2017 12:05 AM, Raviteja Garimella wrote: This patch splits the amd5536udc driver into two -- one that does pci device registration and the other file that does the rest of the driver tasks like the gadget/ep ops etc for Synopsys UDC. This way of splitting helps in exporting core driver symbols which can be used by any other platform/pci driver that is written for the same Synopsys USB device controller. The current patch also includes a change in the Kconfig and Makefile. A new config option USB_SNP_CORE will be selected automatically when any one of the platform or pci driver for the same UDC is selected. Signed-off-by: Raviteja Garimella >>> >>> Although the changes you have done make sense and it is most certainly a >>> good idea to split udc core from bus specific glue logic, it is really >>> hard to review the changes per-se because of the file rename, could that >>> happen at a later time? >> >> If you start looking at this specific patch from the header file >> (amd5536udc.h), >> the additions in there comprise of: >> - 9 function declarations >> - some module parameter variable declarations that's moved out from the older >> common file amd5536udc.c >> - 2 #includes that are needed by all files. > > Well, I don't really question the changes themselves, rather how this is > presented as a patch series to reviewers. > > What I would do, to help introduce both the rename, and the splitting of > core vs. bus-glue specific changes is: > > - have an initial patch which extracts the core functionality of the > driver and the PCI bus glue logic into adm5536udc_pci.c and left > adm5536udc.c intact (that would be a small delta to review) > > - have a second patch that performs the file rename from adm5536udc.c > into snps_udc_core.c and updates adm5536udc_pci.c eventually as a result > of that, then again, a reviewer can ignore the rename part (don't format > to generate your patches with git format-patch -M in that case) and just > focus on the conversion part for adm5536udc_pci.c > Just waited for any more comments coming in. I will submit the next version as PATCH like the way you suggested. >> >> So, basically what's done for this split is that: >> 1. the static keyword is removed from those 9 functions in the new file >> snps_udc_core.c and are exported. >> 2. The module parameters declarations (since they are used in both core >> and pci file) are moved to the header file now. > > These should really be part of the commit messages for each commit doing > the changes, this is meant to help a reviewer understand what you are > doing, and to some degree, will help him/her make an educated decision > as to what part of the code the focus should be put on. > Will do. Thanks, Ravi > Thanks > -- > Florian -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH 32/37] usb: host: xhci: remove newline from tracer
From: Mathias Nyman > Sent: 20 January 2017 14:47 > From: Felipe Balbi > > If we add that newline, the output will like like the following: > > kworker/2:1-42[002] 169.811435: xhci_address_ctx: > ctx_64=0, ctx_type=2, ctx_dma=@153fbd000, ctx_va=@880153fbd000 > > We would rather have that in a single line. ... > diff --git a/drivers/usb/host/xhci-trace.h b/drivers/usb/host/xhci-trace.h > index 4bad0d6..08bed2f 100644 > --- a/drivers/usb/host/xhci-trace.h > +++ b/drivers/usb/host/xhci-trace.h > @@ -103,7 +103,7 @@ > ((HCC_64BYTE_CONTEXT(xhci->hcc_params) + 1) * 32) * > ((ctx->type == XHCI_CTX_TYPE_INPUT) + ep_num + 1)); > ), > - TP_printk("\nctx_64=%d, ctx_type=%u, ctx_dma=@%llx, ctx_va=@%p", > + TP_printk("ctx_64=%d, ctx_type=%u, ctx_dma=@%llx, ctx_va=@%p", > __entry->ctx_64, __entry->ctx_type, > (unsigned long long) __entry->ctx_dma, __entry->ctx_va I suspect the '\n' needs to go at the end of the previous trace? Attempts to generate single lines from multiple printk() calls are doomed to give unreadable output. As are attempts to generate readable multi-line output. (Ever had multiple cpus splat stack traces at the same time??) David -- 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 32/37] usb: host: xhci: remove newline from tracer
Hi, David Laight writes: > From: Mathias Nyman >> Sent: 20 January 2017 14:47 >> From: Felipe Balbi >> >> If we add that newline, the output will like like the following: >> >> kworker/2:1-42[002] 169.811435: xhci_address_ctx: >> ctx_64=0, ctx_type=2, ctx_dma=@153fbd000, ctx_va=@880153fbd000 >> >> We would rather have that in a single line. > ... >> diff --git a/drivers/usb/host/xhci-trace.h b/drivers/usb/host/xhci-trace.h >> index 4bad0d6..08bed2f 100644 >> --- a/drivers/usb/host/xhci-trace.h >> +++ b/drivers/usb/host/xhci-trace.h >> @@ -103,7 +103,7 @@ >> ((HCC_64BYTE_CONTEXT(xhci->hcc_params) + 1) * 32) * >> ((ctx->type == XHCI_CTX_TYPE_INPUT) + ep_num + 1)); >> ), >> -TP_printk("\nctx_64=%d, ctx_type=%u, ctx_dma=@%llx, ctx_va=@%p", >> +TP_printk("ctx_64=%d, ctx_type=%u, ctx_dma=@%llx, ctx_va=@%p", >> __entry->ctx_64, __entry->ctx_type, >> (unsigned long long) __entry->ctx_dma, __entry->ctx_va > > I suspect the '\n' needs to go at the end of the previous trace? > Attempts to generate single lines from multiple printk() calls > are doomed to give unreadable output. > > As are attempts to generate readable multi-line output. > (Ever had multiple cpus splat stack traces at the same time??) TP_printk() adds \n to the end of every single tracepoint. Tracepoints shouldn't have \n ever ;-) -- balbi signature.asc Description: PGP signature
[PATCH v2 34/37] xhci: rename size variable to num_tds
No functinal changes. num_tds describes the number of transfer descriptor better than "size" Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci.c | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 4968e9a..40b1486 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -1337,7 +1337,7 @@ int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags) int ret = 0; unsigned int slot_id, ep_index; struct urb_priv *urb_priv; - int size, i; + int num_tds, i; if (!urb || xhci_check_args(hcd, urb->dev, urb->ep, true, true, __func__) <= 0) @@ -1354,32 +1354,32 @@ int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags) } if (usb_endpoint_xfer_isoc(&urb->ep->desc)) - size = urb->number_of_packets; + num_tds = urb->number_of_packets; else if (usb_endpoint_is_bulk_out(&urb->ep->desc) && urb->transfer_buffer_length > 0 && urb->transfer_flags & URB_ZERO_PACKET && !(urb->transfer_buffer_length % usb_endpoint_maxp(&urb->ep->desc))) - size = 2; + num_tds = 2; else - size = 1; + num_tds = 1; urb_priv = kzalloc(sizeof(struct urb_priv) + - size * sizeof(struct xhci_td *), mem_flags); + num_tds * sizeof(struct xhci_td *), mem_flags); if (!urb_priv) return -ENOMEM; - buffer = kzalloc(size * sizeof(struct xhci_td), mem_flags); + buffer = kzalloc(num_tds * sizeof(struct xhci_td), mem_flags); if (!buffer) { kfree(urb_priv); return -ENOMEM; } - for (i = 0; i < size; i++) { + for (i = 0; i < num_tds; i++) { urb_priv->td[i] = buffer; buffer++; } - urb_priv->length = size; + urb_priv->length = num_tds; urb_priv->td_cnt = 0; urb->hcpriv = urb_priv; -- 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 v2 27/37] usb: host: xhci: convert to list_for_each_entry_safe()
From: Felipe Balbi instead of using while(!list_empty()) followed by list_first_entry(), we can actually use list_for_each_entry_safe(). Signed-off-by: Felipe Balbi Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 92715b9..059825b 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -808,11 +808,11 @@ static void xhci_handle_cmd_stop_ep(struct xhci_hcd *xhci, int slot_id, static void xhci_kill_ring_urbs(struct xhci_hcd *xhci, struct xhci_ring *ring) { struct xhci_td *cur_td; + struct xhci_td *tmp; - while (!list_empty(&ring->td_list)) { - cur_td = list_first_entry(&ring->td_list, - struct xhci_td, td_list); + list_for_each_entry_safe(cur_td, tmp, &ring->td_list, td_list) { list_del_init(&cur_td->td_list); + if (!list_empty(&cur_td->cancelled_td_list)) list_del_init(&cur_td->cancelled_td_list); @@ -828,6 +828,7 @@ static void xhci_kill_endpoint_urbs(struct xhci_hcd *xhci, int slot_id, int ep_index) { struct xhci_td *cur_td; + struct xhci_td *tmp; struct xhci_virt_ep *ep; struct xhci_ring *ring; @@ -853,12 +854,12 @@ static void xhci_kill_endpoint_urbs(struct xhci_hcd *xhci, slot_id, ep_index); xhci_kill_ring_urbs(xhci, ring); } - while (!list_empty(&ep->cancelled_td_list)) { - cur_td = list_first_entry(&ep->cancelled_td_list, - struct xhci_td, cancelled_td_list); - list_del_init(&cur_td->cancelled_td_list); + list_for_each_entry_safe(cur_td, tmp, &ep->cancelled_td_list, + cancelled_td_list) { + list_del_init(&cur_td->cancelled_td_list); inc_td_cnt(cur_td->urb); + if (last_td_in_urb(cur_td)) xhci_giveback_urb_in_irq(xhci, cur_td, -ESHUTDOWN); } -- 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 v2 31/37] usb: host: xhci: convert several if() to a single switch statement
From: Felipe Balbi when getting endpoint type, a switch statement looks better than a series of if () branches. There are no functional changes with this patch, cleanup only. Signed-off-by: Felipe Balbi Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-mem.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 0640e762..0019094 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -1414,14 +1414,16 @@ static u32 xhci_get_endpoint_type(struct usb_host_endpoint *ep) in = usb_endpoint_dir_in(&ep->desc); - if (usb_endpoint_xfer_control(&ep->desc)) + switch (usb_endpoint_type(&ep->desc)) { + case USB_ENDPOINT_XFER_CONTROL: return CTRL_EP; - if (usb_endpoint_xfer_bulk(&ep->desc)) + case USB_ENDPOINT_XFER_BULK: return in ? BULK_IN_EP : BULK_OUT_EP; - if (usb_endpoint_xfer_isoc(&ep->desc)) + case USB_ENDPOINT_XFER_ISOC: return in ? ISOC_IN_EP : ISOC_OUT_EP; - if (usb_endpoint_xfer_int(&ep->desc)) + case USB_ENDPOINT_XFER_INT: return in ? INT_IN_EP : INT_OUT_EP; + } 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 v2 35/37] xhci: Rename variables related to transfer descritpors
urb_priv structure has a count on how many TDs the URB contains, and how many of those TD's we have handled. rename: length -> num_tds td_cnt -> num_tds_done No functional changes Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 10 +- drivers/usb/host/xhci.c | 14 +++--- drivers/usb/host/xhci.h | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index e0a49cb..7a70406 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -119,14 +119,14 @@ static bool last_td_in_urb(struct xhci_td *td) { struct urb_priv *urb_priv = td->urb->hcpriv; - return urb_priv->td_cnt == urb_priv->length; + return urb_priv->num_tds_done == urb_priv->num_tds; } static void inc_td_cnt(struct urb *urb) { struct urb_priv *urb_priv = urb->hcpriv; - urb_priv->td_cnt++; + urb_priv->num_tds_done++; } static void trb_to_noop(union xhci_trb *trb, u32 noop_type) @@ -2055,7 +2055,7 @@ static int process_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td, ep_ring = xhci_dma_to_transfer_ring(ep, le64_to_cpu(event->buffer)); trb_comp_code = GET_COMP_CODE(le32_to_cpu(event->transfer_len)); urb_priv = td->urb->hcpriv; - idx = urb_priv->td_cnt; + idx = urb_priv->num_tds_done; frame = &td->urb->iso_frame_desc[idx]; requested = frame->length; remaining = EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)); @@ -2134,7 +2134,7 @@ static int skip_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td, ep_ring = xhci_dma_to_transfer_ring(ep, le64_to_cpu(event->buffer)); urb_priv = td->urb->hcpriv; - idx = urb_priv->td_cnt; + idx = urb_priv->num_tds_done; frame = &td->urb->iso_frame_desc[idx]; /* The transfer is partly done. */ @@ -3131,7 +3131,7 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, urb_priv = urb->hcpriv; /* Deal with URB_ZERO_PACKET - need one more td/trb */ - if (urb->transfer_flags & URB_ZERO_PACKET && urb_priv->length > 1) + if (urb->transfer_flags & URB_ZERO_PACKET && urb_priv->num_tds > 1) need_zero_pkt = true; td = urb_priv->td[0]; diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 40b1486..bee6272 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -1379,8 +1379,8 @@ int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags) buffer++; } - urb_priv->length = num_tds; - urb_priv->td_cnt = 0; + urb_priv->num_tds = num_tds; + urb_priv->num_tds_done = 0; urb->hcpriv = urb_priv; trace_xhci_urb_enqueue(urb); @@ -1523,8 +1523,8 @@ int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, "HW died, freeing TD."); urb_priv = urb->hcpriv; - for (i = urb_priv->td_cnt; -i < urb_priv->length && xhci->devs[urb->dev->slot_id]; + for (i = urb_priv->num_tds_done; +i < urb_priv->num_tds && xhci->devs[urb->dev->slot_id]; i++) { td = urb_priv->td[i]; if (!list_empty(&td->td_list)) @@ -1549,8 +1549,8 @@ int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) } urb_priv = urb->hcpriv; - i = urb_priv->td_cnt; - if (i < urb_priv->length) + i = urb_priv->num_tds_done; + if (i < urb_priv->num_tds) xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, "Cancel URB %p, dev %s, ep 0x%x, " "starting at offset 0x%llx", @@ -1560,7 +1560,7 @@ int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) urb_priv->td[i]->start_seg, urb_priv->td[i]->first_trb)); - for (; i < urb_priv->length; i++) { + for (; i < urb_priv->num_tds; i++) { td = urb_priv->td[i]; list_add_tail(&td->cancelled_td_list, &ep->cancelled_td_list); } diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 9193a42..dab2719 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1608,8 +1608,8 @@ struct xhci_scratchpad { }; struct urb_priv { - int length; - int td_cnt; + int num_tds; + int num_tds_done; struct xhci_td *td[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 v2 36/37] xhci: simplify how we store TDs in urb private data
Instead of storing a zero length array of td pointers, and then allocate memory both for the td pointer array and the td's, just use a zero length array of actual td's in urb private data. old: struct urb_priv { struct xhci_td *td[0] } new: struct urb_priv { struct xhci_td td[0] } Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-mem.c | 5 + drivers/usb/host/xhci-ring.c | 20 ++-- drivers/usb/host/xhci.c | 24 ++-- drivers/usb/host/xhci.h | 2 +- 4 files changed, 18 insertions(+), 33 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index e452492..ba1853f4 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -1817,10 +1817,7 @@ struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci, void xhci_urb_free_priv(struct urb_priv *urb_priv) { - if (urb_priv) { - kfree(urb_priv->td[0]); - kfree(urb_priv); - } + kfree(urb_priv); } void xhci_free_command(struct xhci_hcd *xhci, diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 7a70406..d9936c7 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -2838,7 +2838,7 @@ static int prepare_transfer(struct xhci_hcd *xhci, return ret; urb_priv = urb->hcpriv; - td = urb_priv->td[td_index]; + td = &urb_priv->td[td_index]; INIT_LIST_HEAD(&td->td_list); INIT_LIST_HEAD(&td->cancelled_td_list); @@ -3134,7 +3134,7 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, if (urb->transfer_flags & URB_ZERO_PACKET && urb_priv->num_tds > 1) need_zero_pkt = true; - td = urb_priv->td[0]; + td = &urb_priv->td[0]; /* * Don't give the first TRB to the hardware (by toggling the cycle bit) @@ -3227,7 +3227,7 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, ret = prepare_transfer(xhci, xhci->devs[slot_id], ep_index, urb->stream_id, 1, urb, 1, mem_flags); - urb_priv->td[1]->last_trb = ring->enqueue; + urb_priv->td[1].last_trb = ring->enqueue; field = TRB_TYPE(TRB_NORMAL) | ring->cycle_state | TRB_IOC; queue_trb(xhci, ring, 0, 0, 0, TRB_INTR_TARGET(0), field); } @@ -3279,7 +3279,7 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, return ret; urb_priv = urb->hcpriv; - td = urb_priv->td[0]; + td = &urb_priv->td[0]; /* * Don't give the first TRB to the hardware (by toggling the cycle bit) @@ -3567,7 +3567,7 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags, return ret; goto cleanup; } - td = urb_priv->td[i]; + td = &urb_priv->td[i]; /* use SIA as default, if frame id is used overwrite it */ sia_frame_id = TRB_SIA; @@ -3674,20 +3674,20 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags, /* Clean up a partially enqueued isoc transfer. */ for (i--; i >= 0; i--) - list_del_init(&urb_priv->td[i]->td_list); + list_del_init(&urb_priv->td[i].td_list); /* Use the first TD as a temporary variable to turn the TDs we've queued * into No-ops with a software-owned cycle bit. That way the hardware * won't accidentally start executing bogus TDs when we partially * overwrite them. td->first_trb and td->start_seg are already set. */ - urb_priv->td[0]->last_trb = ep_ring->enqueue; + urb_priv->td[0].last_trb = ep_ring->enqueue; /* Every TRB except the first & last will have its cycle bit flipped. */ - td_to_noop(xhci, ep_ring, urb_priv->td[0], true); + td_to_noop(xhci, ep_ring, &urb_priv->td[0], true); /* Reset the ring enqueue back to the first TRB and its cycle bit. */ - ep_ring->enqueue = urb_priv->td[0]->first_trb; - ep_ring->enq_seg = urb_priv->td[0]->start_seg; + ep_ring->enqueue = urb_priv->td[0].first_trb; + ep_ring->enq_seg = urb_priv->td[0].start_seg; ep_ring->cycle_state = start_cycle; ep_ring->num_trbs_free = ep_ring->num_trbs_free_temp; usb_hcd_unlink_urb_from_ep(bus_to_hcd(urb->dev->bus), urb); diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index bee6272..dde5c2d 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -1332,12 +1332,11 @@ static int xhci_check_maxpacket(struct xhci_hcd *xhci, unsigned int slot_id, int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags) { struct xhci_hcd *xhci = hcd_to_xhci(hcd); - struct xhci_td *buffer; unsigned long fl
[PATCH v2 22/37] usb: host: xhci: remove bogus __releases()/__acquires() annotation
From: Felipe Balbi handle_tx_event() is not releasing xhci->lock nor reacquiring it, remove the bogus annotation. Signed-off-by: Felipe Balbi Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 31518dd..9084afb 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -2223,8 +2223,6 @@ static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_td *td, */ static int handle_tx_event(struct xhci_hcd *xhci, struct xhci_transfer_event *event) - __releases(&xhci->lock) - __acquires(&xhci->lock) { struct xhci_virt_device *xdev; struct xhci_virt_ep *ep; -- 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 v2 33/37] usb: host: xhci: add xhci_virt_device tracer
From: Felipe Balbi Let's start tracing at least part of an xhci_virt_device lifetime. We might want to extend this tracepoint class later, but for now it already exposes quite a bit of valuable information. Signed-off-by: Felipe Balbi Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-hub.c | 2 ++ drivers/usb/host/xhci-mem.c | 7 ++ drivers/usb/host/xhci-trace.h | 57 +++ drivers/usb/host/xhci.c | 1 + 4 files changed, 67 insertions(+) diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index 50d086b..3bddeaa 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c @@ -389,6 +389,8 @@ static int xhci_stop_device(struct xhci_hcd *xhci, int slot_id, int suspend) if (!virt_dev) return -ENODEV; + trace_xhci_stop_device(virt_dev); + cmd = xhci_alloc_command(xhci, false, true, GFP_NOIO); if (!cmd) { xhci_dbg(xhci, "Couldn't allocate command structure.\n"); diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 0019094..e452492 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -936,6 +936,9 @@ void xhci_free_virt_device(struct xhci_hcd *xhci, int slot_id) return; dev = xhci->devs[slot_id]; + + trace_xhci_free_virt_device(dev); + xhci->dcbaa->dev_context_ptrs[slot_id] = 0; if (!dev) return; @@ -1075,6 +1078,8 @@ int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id, &xhci->dcbaa->dev_context_ptrs[slot_id], le64_to_cpu(xhci->dcbaa->dev_context_ptrs[slot_id])); + trace_xhci_alloc_virt_device(dev); + return 1; fail: xhci_free_virt_device(xhci, slot_id); @@ -1249,6 +1254,8 @@ int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *ud ep0_ctx->deq = cpu_to_le64(dev->eps[0].ring->first_seg->dma | dev->eps[0].ring->cycle_state); + trace_xhci_setup_addressable_virt_device(dev); + /* Steps 7 and 8 were done in xhci_alloc_virt_device() */ return 0; diff --git a/drivers/usb/host/xhci-trace.h b/drivers/usb/host/xhci-trace.h index 08bed2f..1ac2cdf 100644 --- a/drivers/usb/host/xhci-trace.h +++ b/drivers/usb/host/xhci-trace.h @@ -158,6 +158,63 @@ TP_ARGS(ring, trb) ); +DECLARE_EVENT_CLASS(xhci_log_virt_dev, + TP_PROTO(struct xhci_virt_device *vdev), + TP_ARGS(vdev), + TP_STRUCT__entry( + __field(void *, vdev) + __field(unsigned long long, out_ctx) + __field(unsigned long long, in_ctx) + __field(int, devnum) + __field(int, state) + __field(int, speed) + __field(u8, portnum) + __field(u8, level) + __field(int, slot_id) + ), + TP_fast_assign( + __entry->vdev = vdev; + __entry->in_ctx = (unsigned long long) vdev->in_ctx->dma; + __entry->out_ctx = (unsigned long long) vdev->out_ctx->dma; + __entry->devnum = vdev->udev->devnum; + __entry->state = vdev->udev->state; + __entry->speed = vdev->udev->speed; + __entry->portnum = vdev->udev->portnum; + __entry->level = vdev->udev->level; + __entry->slot_id = vdev->udev->slot_id; + ), + TP_printk("vdev %p ctx %llx | %llx num %d state %d speed %d port %d level %d slot %d", + __entry->vdev, __entry->in_ctx, __entry->out_ctx, + __entry->devnum, __entry->state, __entry->speed, + __entry->portnum, __entry->level, __entry->slot_id + ) +); + +DEFINE_EVENT(xhci_log_virt_dev, xhci_alloc_virt_device, + TP_PROTO(struct xhci_virt_device *vdev), + TP_ARGS(vdev) +); + +DEFINE_EVENT(xhci_log_virt_dev, xhci_free_virt_device, + TP_PROTO(struct xhci_virt_device *vdev), + TP_ARGS(vdev) +); + +DEFINE_EVENT(xhci_log_virt_dev, xhci_setup_device, + TP_PROTO(struct xhci_virt_device *vdev), + TP_ARGS(vdev) +); + +DEFINE_EVENT(xhci_log_virt_dev, xhci_setup_addressable_virt_device, + TP_PROTO(struct xhci_virt_device *vdev), + TP_ARGS(vdev) +); + +DEFINE_EVENT(xhci_log_virt_dev, xhci_stop_device, + TP_PROTO(struct xhci_virt_device *vdev), + TP_ARGS(vdev) +); + DECLARE_EVENT_CLASS(xhci_log_urb, TP_PROTO(struct urb *urb), TP_ARGS(urb), diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 958c92b..4968e9a 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -3848,6 +3848,7 @@ static int xhci_setup_device(struct usb_hcd *hcd, struct usb_device *udev, le32_to_cpu(slot_ctx->dev_info) >> 27); spin_lock_irqsave(&xhci->lock, flags); + trace_xhci_setup_device(virt_dev); ret = xhci
[PATCH v2 32/37] usb: host: xhci: remove newline from tracer
From: Felipe Balbi If we add that newline, the output will look like the following: kworker/2:1-42[002] 169.811435: xhci_address_ctx: ctx_64=0, ctx_type=2, ctx_dma=@153fbd000, ctx_va=@880153fbd000 We would rather have that in a single line. Signed-off-by: Felipe Balbi Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-trace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci-trace.h b/drivers/usb/host/xhci-trace.h index 4bad0d6..08bed2f 100644 --- a/drivers/usb/host/xhci-trace.h +++ b/drivers/usb/host/xhci-trace.h @@ -103,7 +103,7 @@ ((HCC_64BYTE_CONTEXT(xhci->hcc_params) + 1) * 32) * ((ctx->type == XHCI_CTX_TYPE_INPUT) + ep_num + 1)); ), - TP_printk("\nctx_64=%d, ctx_type=%u, ctx_dma=@%llx, ctx_va=@%p", + TP_printk("ctx_64=%d, ctx_type=%u, ctx_dma=@%llx, ctx_va=@%p", __entry->ctx_64, __entry->ctx_type, (unsigned long long) __entry->ctx_dma, __entry->ctx_va ) -- 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 v2 29/37] usb: host: xhci: make a generic TRB tracer
From: Felipe Balbi instead of having a tracer that can only trace command completions, let's promote this tracer so it can trace and decode any TRB. With that, it will be easier to extrapolate the lifetime of any TRB which might help debugging certain issues. Signed-off-by: Felipe Balbi Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 14 +- drivers/usb/host/xhci-trace.h | 55 --- drivers/usb/host/xhci.h | 329 ++ 3 files changed, 375 insertions(+), 23 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 059825b..4316273 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -1319,6 +1319,9 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, cmd_dma = le64_to_cpu(event->cmd_trb); cmd_trb = xhci->cmd_ring->dequeue; + + trace_xhci_handle_command(xhci->cmd_ring, &cmd_trb->generic); + cmd_dequeue_dma = xhci_trb_virt_to_dma(xhci->cmd_ring->deq_seg, cmd_trb); /* @@ -1335,8 +1338,6 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, cancel_delayed_work(&xhci->cmd_timer); - trace_xhci_cmd_completion(cmd_trb, (struct xhci_generic_trb *) event); - cmd_comp_code = GET_COMP_CODE(le32_to_cpu(event->status)); /* If CMD ring stopped we own the trbs between enqueue and dequeue */ @@ -2479,6 +2480,10 @@ static int handle_tx_event(struct xhci_hcd *xhci, ep_trb = &ep_seg->trbs[(ep_trb_dma - ep_seg->dma) / sizeof(*ep_trb)]; + + trace_xhci_handle_transfer(ep_ring, + (struct xhci_generic_trb *) ep_trb); + /* * No-op TRB should not trigger interrupts. * If ep_trb is a no-op TRB, it means the @@ -2545,6 +2550,8 @@ static int xhci_handle_event(struct xhci_hcd *xhci) xhci->event_ring->cycle_state) return 0; + trace_xhci_handle_event(xhci->event_ring, &event->generic); + /* * Barrier between reading the TRB_CYCLE (valid) flag above and any * speculative reads of the event's flags/data below. @@ -2714,6 +2721,9 @@ static void queue_trb(struct xhci_hcd *xhci, struct xhci_ring *ring, trb->field[1] = cpu_to_le32(field2); trb->field[2] = cpu_to_le32(field3); trb->field[3] = cpu_to_le32(field4); + + trace_xhci_queue_trb(ring, trb); + inc_enq(xhci, ring, more_trbs_coming); } diff --git a/drivers/usb/host/xhci-trace.h b/drivers/usb/host/xhci-trace.h index 59c0565..d01524b 100644 --- a/drivers/usb/host/xhci-trace.h +++ b/drivers/usb/host/xhci-trace.h @@ -115,34 +115,47 @@ TP_ARGS(xhci, ctx, ep_num) ); -DECLARE_EVENT_CLASS(xhci_log_event, - TP_PROTO(void *trb_va, struct xhci_generic_trb *ev), - TP_ARGS(trb_va, ev), +DECLARE_EVENT_CLASS(xhci_log_trb, + TP_PROTO(struct xhci_ring *ring, struct xhci_generic_trb *trb), + TP_ARGS(ring, trb), TP_STRUCT__entry( - __field(void *, va) - __field(u64, dma) - __field(u32, status) - __field(u32, flags) - __dynamic_array(u8, trb, sizeof(struct xhci_generic_trb)) + __field(u32, type) + __field(u32, field0) + __field(u32, field1) + __field(u32, field2) + __field(u32, field3) ), TP_fast_assign( - __entry->va = trb_va; - __entry->dma = ((u64)le32_to_cpu(ev->field[1])) << 32 | - le32_to_cpu(ev->field[0]); - __entry->status = le32_to_cpu(ev->field[2]); - __entry->flags = le32_to_cpu(ev->field[3]); - memcpy(__get_dynamic_array(trb), trb_va, - sizeof(struct xhci_generic_trb)); + __entry->type = ring->type; + __entry->field0 = le32_to_cpu(trb->field[0]); + __entry->field1 = le32_to_cpu(trb->field[1]); + __entry->field2 = le32_to_cpu(trb->field[2]); + __entry->field3 = le32_to_cpu(trb->field[3]); ), - TP_printk("\ntrb_dma=@%llx, trb_va=@%p, status=%08x, flags=%08x", - (unsigned long long) __entry->dma, __entry->va, - __entry->status, __entry->flags + TP_printk("%s: %s", xhci_ring_type_string(__entry->type), + xhci_decode_trb(__entry->field0, __entry->field1, + __entry->field2, __entry->field3) ) ); -DEFINE_EVENT(xhci_log_event, xhci_cmd_completion, - TP_PROTO(void *trb_va, struct xhci_generic_trb *ev), - TP_ARGS(trb_va, ev) +DEFINE_EVENT(xhci_log_trb, xhci_handle_event, + TP_PROTO(struct xhci_ring *ring, struct xhci_generic_trb *trb), + TP_ARGS(ring, trb) +);
[PATCH v2 19/37] usb: host: xhci: use slightly better list helpers
From: Felipe Balbi Replace list_entry() with list_first_entry() and list_for_each() with list_for_each_entry(). This makes the code slightly more readable. Signed-off-by: Felipe Balbi Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 19 ++- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index efc4657..4e7a6c2 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -689,7 +689,6 @@ static void xhci_handle_cmd_stop_ep(struct xhci_hcd *xhci, int slot_id, unsigned int ep_index; struct xhci_ring *ep_ring; struct xhci_virt_ep *ep; - struct list_head *entry; struct xhci_td *cur_td = NULL; struct xhci_td *last_unlinked_td; @@ -706,6 +705,8 @@ static void xhci_handle_cmd_stop_ep(struct xhci_hcd *xhci, int slot_id, memset(&deq_state, 0, sizeof(deq_state)); ep_index = TRB_TO_EP_INDEX(le32_to_cpu(trb->generic.field[3])); ep = &xhci->devs[slot_id]->eps[ep_index]; + last_unlinked_td = list_last_entry(&ep->cancelled_td_list, + struct xhci_td, cancelled_td_list); if (list_empty(&ep->cancelled_td_list)) { xhci_stop_watchdog_timer_in_irq(xhci, ep); @@ -719,8 +720,7 @@ static void xhci_handle_cmd_stop_ep(struct xhci_hcd *xhci, int slot_id, * it. We're also in the event handler, so we can't get re-interrupted * if another Stop Endpoint command completes */ - list_for_each(entry, &ep->cancelled_td_list) { - cur_td = list_entry(entry, struct xhci_td, cancelled_td_list); + list_for_each_entry(cur_td, &ep->cancelled_td_list, cancelled_td_list) { xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, "Removing canceled TD starting at 0x%llx (dma).", (unsigned long long)xhci_trb_virt_to_dma( @@ -762,7 +762,7 @@ static void xhci_handle_cmd_stop_ep(struct xhci_hcd *xhci, int slot_id, */ list_del_init(&cur_td->td_list); } - last_unlinked_td = cur_td; + xhci_stop_watchdog_timer_in_irq(xhci, ep); /* If necessary, queue a Set Transfer Ring Dequeue Pointer command */ @@ -784,7 +784,7 @@ static void xhci_handle_cmd_stop_ep(struct xhci_hcd *xhci, int slot_id, * So stop when we've completed the URB for the last TD we unlinked. */ do { - cur_td = list_entry(ep->cancelled_td_list.next, + cur_td = list_first_entry(&ep->cancelled_td_list, struct xhci_td, cancelled_td_list); list_del_init(&cur_td->cancelled_td_list); @@ -1335,7 +1335,7 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, return; } - cmd = list_entry(xhci->cmd_list.next, struct xhci_command, cmd_list); + cmd = list_first_entry(&xhci->cmd_list, struct xhci_command, cmd_list); cancel_delayed_work(&xhci->cmd_timer); @@ -1426,8 +1426,8 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, /* restart timer if this wasn't the last command */ if (!list_is_singular(&xhci->cmd_list)) { - xhci->current_cmd = list_entry(cmd->cmd_list.next, - struct xhci_command, cmd_list); + xhci->current_cmd = list_first_entry(&cmd->cmd_list, + struct xhci_command, cmd_list); xhci_mod_cmd_timer(xhci, XHCI_CMD_DEFAULT_TIMEOUT); } else if (xhci->current_cmd == cmd) { xhci->current_cmd = NULL; @@ -2421,7 +2421,8 @@ static int handle_tx_event(struct xhci_hcd *xhci, goto cleanup; } - td = list_entry(ep_ring->td_list.next, struct xhci_td, td_list); + td = list_first_entry(&ep_ring->td_list, struct xhci_td, + td_list); if (ep->skip) td_num--; -- 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 v2 26/37] xhci: use the trb_to_noop() helper for command trbs
Remove duplicate code by using trb_to_noop() when handling Aborted commads Based on earlier code by Felipe Balbi Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 12 ++-- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index bd00ada..92715b9 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -314,7 +314,6 @@ static void xhci_handle_stopped_cmd_ring(struct xhci_hcd *xhci, struct xhci_command *cur_cmd) { struct xhci_command *i_cmd; - u32 cycle_state; /* Turn all aborted commands in list to no-ops, then restart */ list_for_each_entry(i_cmd, &xhci->cmd_list, cmd_list) { @@ -326,15 +325,8 @@ static void xhci_handle_stopped_cmd_ring(struct xhci_hcd *xhci, xhci_dbg(xhci, "Turn aborted command %p to no-op\n", i_cmd->command_trb); - /* get cycle state from the original cmd trb */ - cycle_state = le32_to_cpu( - i_cmd->command_trb->generic.field[3]) & TRB_CYCLE; - /* modify the command trb to no-op command */ - i_cmd->command_trb->generic.field[0] = 0; - i_cmd->command_trb->generic.field[1] = 0; - i_cmd->command_trb->generic.field[2] = 0; - i_cmd->command_trb->generic.field[3] = cpu_to_le32( - TRB_TYPE(TRB_CMD_NOOP) | cycle_state); + + trb_to_noop(i_cmd->command_trb, TRB_CMD_NOOP); /* * caller waiting for completion is called when command -- 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 v2 21/37] usb: host: xhci: introduce xhci_td_cleanup()
From: Felipe Balbi By extracting xhci_td_cleanup() from finish_td(), code before clearer and easier to follow. There are no functional changes with this patch. It's merely a cleanup. Signed-off-by: Felipe Balbi Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 92 1 file changed, 50 insertions(+), 42 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 627518d..31518dd 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -1822,6 +1822,55 @@ int xhci_is_vendor_info_code(struct xhci_hcd *xhci, unsigned int trb_comp_code) return 0; } +static int xhci_td_cleanup(struct xhci_hcd *xhci, struct xhci_td *td, + struct xhci_ring *ep_ring, int *status) +{ + struct urb_priv *urb_priv; + struct urb *urb = NULL; + + /* Clean up the endpoint's TD list */ + urb = td->urb; + urb_priv = urb->hcpriv; + + /* if a bounce buffer was used to align this td then unmap it */ + if (td->bounce_seg) + xhci_unmap_td_bounce_buffer(xhci, ep_ring, td); + + /* Do one last check of the actual transfer length. +* If the host controller said we transferred more data than the buffer +* length, urb->actual_length will be a very big number (since it's +* unsigned). Play it safe and say we didn't transfer anything. +*/ + if (urb->actual_length > urb->transfer_buffer_length) { + xhci_warn(xhci, "URB req %u and actual %u transfer length mismatch\n", + urb->transfer_buffer_length, urb->actual_length); + urb->actual_length = 0; + *status = 0; + } + list_del_init(&td->td_list); + /* Was this TD slated to be cancelled but completed anyway? */ + if (!list_empty(&td->cancelled_td_list)) + list_del_init(&td->cancelled_td_list); + + inc_td_cnt(urb); + /* Giveback the urb when all the tds are completed */ + if (last_td_in_urb(td)) { + if ((urb->actual_length != urb->transfer_buffer_length && +(urb->transfer_flags & URB_SHORT_NOT_OK)) || + (*status != 0 && !usb_endpoint_xfer_isoc(&urb->ep->desc))) + xhci_dbg(xhci, "Giveback URB %p, len = %d, expected = %d, status = %d\n", +urb, urb->actual_length, +urb->transfer_buffer_length, *status); + + /* set isoc urb status to 0 just as EHCI, UHCI, and OHCI */ + if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) + *status = 0; + xhci_giveback_urb_in_irq(xhci, td, *status); + } + + return 0; +} + static int finish_td(struct xhci_hcd *xhci, struct xhci_td *td, union xhci_trb *ep_trb, struct xhci_transfer_event *event, struct xhci_virt_ep *ep, int *status, bool skip) @@ -1829,8 +1878,6 @@ static int finish_td(struct xhci_hcd *xhci, struct xhci_td *td, struct xhci_virt_device *xdev; struct xhci_ep_ctx *ep_ctx; struct xhci_ring *ep_ring; - struct urb_priv *urb_priv; - struct urb *urb = NULL; unsigned int slot_id; u32 trb_comp_code; int ep_index; @@ -1873,46 +1920,7 @@ static int finish_td(struct xhci_hcd *xhci, struct xhci_td *td, } td_cleanup: - /* Clean up the endpoint's TD list */ - urb = td->urb; - urb_priv = urb->hcpriv; - - /* if a bounce buffer was used to align this td then unmap it */ - if (td->bounce_seg) - xhci_unmap_td_bounce_buffer(xhci, ep_ring, td); - - /* Do one last check of the actual transfer length. -* If the host controller said we transferred more data than the buffer -* length, urb->actual_length will be a very big number (since it's -* unsigned). Play it safe and say we didn't transfer anything. -*/ - if (urb->actual_length > urb->transfer_buffer_length) { - xhci_warn(xhci, "URB req %u and actual %u transfer length mismatch\n", - urb->transfer_buffer_length, urb->actual_length); - urb->actual_length = 0; - *status = 0; - } - list_del_init(&td->td_list); - /* Was this TD slated to be cancelled but completed anyway? */ - if (!list_empty(&td->cancelled_td_list)) - list_del_init(&td->cancelled_td_list); - - inc_td_cnt(urb); - /* Giveback the urb when all the tds are completed */ - if (last_td_in_urb(td)) { - if ((urb->actual_length != urb->transfer_buffer_length && -(urb->transfer_flags & URB_SHORT_NOT_OK)) || - (*status != 0 && !usb_endpoint_xfer_isoc(&urb->ep->desc))) - xhci_dbg(xhci, "Giveback URB %p, len = %d, expected = %d, status = %d\n", -
RE: [PATCH 36/37] xhci: simplify how we store TDs in urb private data
From: Mathias Nyman > Sent: 20 January 2017 14:47 > Instead of storing a zero length array of td pointers, and then > allocate memory both for the td pointer array and the td's, just > use a zero length array of actual td's in urb private data. This reminds me of an old patch that got reverted because things broke because the lifetimes/accesses of the data wasn't the obvious one. That might have been a different structure. FWIW it is a shame that things like USB3 ethernet can't transmit and receive without all these intermediate and dynamically allocated structures. David -- 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 24/37] usb: host: xhci: unconditionally call xhci_unmap_td_bounce_buffer()
From: Felipe Balbi xhci_unmap_td_bounce_buffer() already checks for a valid td->bounce_seg and bails out early if that's invalid. There's no need to check for this twice. Signed-off-by: Felipe Balbi Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 0de9966..8b78eee 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -793,8 +793,7 @@ static void xhci_handle_cmd_stop_ep(struct xhci_hcd *xhci, int slot_id, * just overwrite it (because the URB has been unlinked). */ ep_ring = xhci_urb_to_transfer_ring(xhci, cur_td->urb); - if (ep_ring && cur_td->bounce_seg) - xhci_unmap_td_bounce_buffer(xhci, ep_ring, cur_td); + xhci_unmap_td_bounce_buffer(xhci, ep_ring, cur_td); inc_td_cnt(cur_td->urb); if (last_td_in_urb(cur_td)) xhci_giveback_urb_in_irq(xhci, cur_td, 0); @@ -820,8 +819,7 @@ static void xhci_kill_ring_urbs(struct xhci_hcd *xhci, struct xhci_ring *ring) if (!list_empty(&cur_td->cancelled_td_list)) list_del_init(&cur_td->cancelled_td_list); - if (cur_td->bounce_seg) - xhci_unmap_td_bounce_buffer(xhci, ring, cur_td); + xhci_unmap_td_bounce_buffer(xhci, ring, cur_td); inc_td_cnt(cur_td->urb); if (last_td_in_urb(cur_td)) @@ -1833,8 +1831,7 @@ static int xhci_td_cleanup(struct xhci_hcd *xhci, struct xhci_td *td, urb_priv = urb->hcpriv; /* if a bounce buffer was used to align this td then unmap it */ - if (td->bounce_seg) - xhci_unmap_td_bounce_buffer(xhci, ep_ring, td); + xhci_unmap_td_bounce_buffer(xhci, ep_ring, td); /* Do one last check of the actual transfer length. * If the host controller said we transferred more data than the buffer -- 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 v2 20/37] usb: host: xhci: reorder variable definitions
From: Felipe Balbi no functional changes. Simple cleanup to make sure variables are ordered in a 'reverse christmas tree' fashion. While at that, also remove an obsolete comment which doesn't apply anymore. Signed-off-by: Felipe Balbi Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 12 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 4e7a6c2..627518d 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -1822,22 +1822,18 @@ int xhci_is_vendor_info_code(struct xhci_hcd *xhci, unsigned int trb_comp_code) return 0; } -/* - * Finish the td processing, remove the td from td list; - * Return 1 if the urb can be given back. - */ static int finish_td(struct xhci_hcd *xhci, struct xhci_td *td, union xhci_trb *ep_trb, struct xhci_transfer_event *event, struct xhci_virt_ep *ep, int *status, bool skip) { struct xhci_virt_device *xdev; - struct xhci_ring *ep_ring; - unsigned int slot_id; - int ep_index; - struct urb *urb = NULL; struct xhci_ep_ctx *ep_ctx; + struct xhci_ring *ep_ring; struct urb_priv *urb_priv; + struct urb *urb = NULL; + unsigned int slot_id; u32 trb_comp_code; + int ep_index; slot_id = TRB_TO_SLOT_ID(le32_to_cpu(event->flags)); xdev = xhci->devs[slot_id]; -- 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 v2 28/37] usb: host: xhci: combine event TRB completion debugging messages
From: Felipe Balbi If we just provide a helper to convert completion code to string, we can combine all debugging messages into a single print. [keep the old debug messages, for warn and grep -Mathias] Signed-off-by: Felipe Balbi Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci.h | 80 + 1 file changed, 80 insertions(+) diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index aa63e38..ebdd920 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1097,6 +1097,86 @@ struct xhci_transfer_event { #define COMP_SECONDARY_BANDWIDTH_ERROR 35 #define COMP_SPLIT_TRANSACTION_ERROR 36 +static inline const char *xhci_trb_comp_code_string(u8 status) +{ + switch (status) { + case COMP_INVALID: + return "Invalid"; + case COMP_SUCCESS: + return "Success"; + case COMP_DATA_BUFFER_ERROR: + return "Data Buffer Error"; + case COMP_BABBLE_DETECTED_ERROR: + return "Babble Detected"; + case COMP_USB_TRANSACTION_ERROR: + return "USB Transaction Error"; + case COMP_TRB_ERROR: + return "TRB Error"; + case COMP_STALL_ERROR: + return "Stall Error"; + case COMP_RESOURCE_ERROR: + return "Resource Error"; + case COMP_BANDWIDTH_ERROR: + return "Bandwidth Error"; + case COMP_NO_SLOTS_AVAILABLE_ERROR: + return "No Slots Available Error"; + case COMP_INVALID_STREAM_TYPE_ERROR: + return "Invalid Stream Type Error"; + case COMP_SLOT_NOT_ENABLED_ERROR: + return "Slot Not Enabled Error"; + case COMP_ENDPOINT_NOT_ENABLED_ERROR: + return "Endpoint Not Enabled Error"; + case COMP_SHORT_PACKET: + return "Short Packet"; + case COMP_RING_UNDERRUN: + return "Ring Underrun"; + case COMP_RING_OVERRUN: + return "Ring Overrun"; + case COMP_VF_EVENT_RING_FULL_ERROR: + return "VF Event Ring Full Error"; + case COMP_PARAMETER_ERROR: + return "Parameter Error"; + case COMP_BANDWIDTH_OVERRUN_ERROR: + return "Bandwidth Overrun Error"; + case COMP_CONTEXT_STATE_ERROR: + return "Context State Error"; + case COMP_NO_PING_RESPONSE_ERROR: + return "No Ping Response Error"; + case COMP_EVENT_RING_FULL_ERROR: + return "Event Ring Full Error"; + case COMP_INCOMPATIBLE_DEVICE_ERROR: + return "Incompatible Device Error"; + case COMP_MISSED_SERVICE_ERROR: + return "Missed Service Error"; + case COMP_COMMAND_RING_STOPPED: + return "Command Ring Stopped"; + case COMP_COMMAND_ABORTED: + return "Command Aborted"; + case COMP_STOPPED: + return "Stopped"; + case COMP_STOPPED_LENGTH_INVALID: + return "Stopped - Length Invalid"; + case COMP_STOPPED_SHORT_PACKET: + return "Stopped - Short Packet"; + case COMP_MAX_EXIT_LATENCY_TOO_LARGE_ERROR: + return "Max Exit Latency Too Large Error"; + case COMP_ISOCH_BUFFER_OVERRUN: + return "Isoch Buffer Overrun"; + case COMP_EVENT_LOST_ERROR: + return "Event Lost Error"; + case COMP_UNDEFINED_ERROR: + return "Undefined Error"; + case COMP_INVALID_STREAM_ID_ERROR: + return "Invalid Stream ID Error"; + case COMP_SECONDARY_BANDWIDTH_ERROR: + return "Secondary Bandwidth Error"; + case COMP_SPLIT_TRANSACTION_ERROR: + return "Split Transaction Error"; + default: + return "Unknown!!"; + } +} + struct xhci_link_trb { /* 64-bit segment pointer*/ __le64 segment_ptr; -- 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 v2 23/37] usb: host: xhci: check for a valid ring when unmapping bounce buffer
From: Felipe Balbi This way we can remove checks for valid ring from call sites of xhci_unmap_td_bounce_buffer() Signed-off-by: Felipe Balbi Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 9084afb..0de9966 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -655,7 +655,7 @@ static void xhci_unmap_td_bounce_buffer(struct xhci_hcd *xhci, struct xhci_segment *seg = td->bounce_seg; struct urb *urb = td->urb; - if (!seg || !urb) + if (!ring || !seg || !urb) return; if (usb_urb_dir_out(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
[PATCH v2 10/37] usb: xhci: remove unnecessary assignment
From: Lu Baolu Drop an unnecessary assignment in prepare_transfer(). Signed-off-by: Lu Baolu Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index bcc0894..61b5fea 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -2844,8 +2844,6 @@ static int prepare_transfer(struct xhci_hcd *xhci, td->start_seg = ep_ring->enq_seg; td->first_trb = ep_ring->enqueue; - urb_priv->td[td_index] = td; - 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