Re: [PATCH 1/3] usb: misc: generic_onboard_hub: add generic onboard USB HUB driver
Am Mittwoch, den 09.12.2015, 16:50 +0800 schrieb Peter Chen: > On Tue, Dec 08, 2015 at 08:36:00AM -0700, Mathieu Poirier wrote: > > On 7 December 2015 at 18:37, Peter Chenwrote: > > > + > > > + if (dev->of_node) { > > > + struct device_node *node = dev->of_node; > > > + > > > + hub_data->clk = devm_clk_get(dev, "external_clk"); > > > + if (IS_ERR(hub_data->clk)) { > > > + dev_dbg(dev, "Can't get external clock: %ld\n", > > > + PTR_ERR(hub_data->clk)); > > > + } > > > > Is the intended behaviour to keep going here event when there is an > > error? Can the "hub_data" really work without a clock? > > Yes, some HUB may work with fixed 24M OSC at the board, but they need to > reset through external IO, so the clock is not need at this case, but > reset pin is mandatory. > If the hub always requires a clock it must not be optional. If you have a fixed 24MHz clock on board add this to the DT as a fixed-clock and use it as an input to the hub. > > > + } > > > + > > > + if (gpiod_reset) { > > > + /* Sanity check */ > > > + if (duration_us > 100) > > > + duration_us = 50; > > > + usleep_range(duration_us, duration_us + 100); > > > + gpiod_set_value(gpiod_reset, reset_pol ? 0 : 1); > > > > What are these hard-coded values? Shouldn't this be taken from the > > DT? If not then some comments explaining the values would be > > appreciated. > > Yes, I did it wrongly, thanks. > > > > diff --git a/include/linux/usb/generic_onboard_hub.h > > > b/include/linux/usb/generic_onboard_hub.h > > > new file mode 100644 > > > index 000..1b70ccc > > > --- /dev/null > > > +++ b/include/linux/usb/generic_onboard_hub.h > > > @@ -0,0 +1,11 @@ > > > +#ifndef __LINUX_USB_GENERIC_HUB_H > > > +#define __LINUX_USB_GENERIC_HUB_H > > > + > > > +struct usb_hub_generic_platform_data { > > > + int gpio_reset; > > > + int gpio_reset_polarity; > > > + int gpio_reset_duration_us; > > > + struct clk *ext_clk; > > > +}; > > > > Please document this structure in accordance with kernel documentation > > standards. > > > > Thanks, it should be. > -- Pengutronix e.K. | Lucas Stach | Industrial Linux Solutions | http://www.pengutronix.de/ | -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/3] usb: misc: generic_onboard_hub: add generic onboard USB HUB driver
On Wed, Dec 09, 2015 at 09:57:40AM +0100, Lucas Stach wrote: > Am Mittwoch, den 09.12.2015, 16:50 +0800 schrieb Peter Chen: > > On Tue, Dec 08, 2015 at 08:36:00AM -0700, Mathieu Poirier wrote: > > > On 7 December 2015 at 18:37, Peter Chenwrote: > > > > + > > > > + if (dev->of_node) { > > > > + struct device_node *node = dev->of_node; > > > > + > > > > + hub_data->clk = devm_clk_get(dev, "external_clk"); > > > > + if (IS_ERR(hub_data->clk)) { > > > > + dev_dbg(dev, "Can't get external clock: %ld\n", > > > > + PTR_ERR(hub_data->clk)); > > > > + } > > > > > > Is the intended behaviour to keep going here event when there is an > > > error? Can the "hub_data" really work without a clock? > > > > Yes, some HUB may work with fixed 24M OSC at the board, but they need to > > reset through external IO, so the clock is not need at this case, but > > reset pin is mandatory. > > > If the hub always requires a clock it must not be optional. If you have > a fixed 24MHz clock on board add this to the DT as a fixed-clock and use > it as an input to the hub. > This fixed 24MHz clock may from a fixed crystal on board, it is always on, no software need to control it, imx51-bbg board is an example. -- Best Regards, Peter Chen -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/3] usb: misc: generic_onboard_hub: add generic onboard USB HUB driver
On Wednesday 09 December 2015 09:57:40 Lucas Stach wrote: > Am Mittwoch, den 09.12.2015, 16:50 +0800 schrieb Peter Chen: > > On Tue, Dec 08, 2015 at 08:36:00AM -0700, Mathieu Poirier wrote: > > > On 7 December 2015 at 18:37, Peter Chenwrote: > > > > + > > > > + if (dev->of_node) { > > > > + struct device_node *node = dev->of_node; > > > > + > > > > + hub_data->clk = devm_clk_get(dev, "external_clk"); > > > > + if (IS_ERR(hub_data->clk)) { > > > > + dev_dbg(dev, "Can't get external clock: %ld\n", > > > > + PTR_ERR(hub_data->clk)); > > > > + } > > > > > > Is the intended behaviour to keep going here event when there is an > > > error? Can the "hub_data" really work without a clock? > > > > Yes, some HUB may work with fixed 24M OSC at the board, but they need to > > reset through external IO, so the clock is not need at this case, but > > reset pin is mandatory. > > > If the hub always requires a clock it must not be optional. If you have > a fixed 24MHz clock on board add this to the DT as a fixed-clock and use > it as an input to the hub. I think it's fine to make the clock optional in the sense that you only need to list non-fixed clocks that have to be enabled and or controlled. Which reminds me, should the driver call clk_set_rate()? It currently doesn't, but other machines might need that. Arnd -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/3] usb: misc: generic_onboard_hub: add generic onboard USB HUB driver
Am Mittwoch, den 09.12.2015, 17:00 +0800 schrieb Peter Chen: > On Wed, Dec 09, 2015 at 09:57:40AM +0100, Lucas Stach wrote: > > Am Mittwoch, den 09.12.2015, 16:50 +0800 schrieb Peter Chen: > > > On Tue, Dec 08, 2015 at 08:36:00AM -0700, Mathieu Poirier wrote: > > > > On 7 December 2015 at 18:37, Peter Chen> > > > wrote: > > > > > + > > > > > + if (dev->of_node) { > > > > > + struct device_node *node = dev->of_node; > > > > > + > > > > > + hub_data->clk = devm_clk_get(dev, "external_clk"); > > > > > + if (IS_ERR(hub_data->clk)) { > > > > > + dev_dbg(dev, "Can't get external clock: > > > > > %ld\n", > > > > > + PTR_ERR(hub_data->clk)); > > > > > + } > > > > > > > > Is the intended behaviour to keep going here event when there is an > > > > error? Can the "hub_data" really work without a clock? > > > > > > Yes, some HUB may work with fixed 24M OSC at the board, but they need to > > > reset through external IO, so the clock is not need at this case, but > > > reset pin is mandatory. > > > > > If the hub always requires a clock it must not be optional. If you have > > a fixed 24MHz clock on board add this to the DT as a fixed-clock and use > > it as an input to the hub. > > > > This fixed 24MHz clock may from a fixed crystal on board, it is always > on, no software need to control it, imx51-bbg board is an example. > And that's wh it is a fixed-clock. Please look it up in the DT binding documentation. -- Pengutronix e.K. | Lucas Stach | Industrial Linux Solutions | http://www.pengutronix.de/ | -- 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: f_tcm: memory leak on error in tcm_alloc_inst()
We need to kfree(opts) on error. Also it's nicer to allocate opts before taking the lock. Signed-off-by: Dan Carpenterdiff --git a/drivers/usb/gadget/function/f_tcm.c b/drivers/usb/gadget/function/f_tcm.c index ed47e40..0a26a2e 100644 --- a/drivers/usb/gadget/function/f_tcm.c +++ b/drivers/usb/gadget/function/f_tcm.c @@ -2300,20 +2300,19 @@ static struct usb_function_instance *tcm_alloc_inst(void) struct f_tcm_opts *opts; int i; - mutex_lock(_instances_lock); - opts = kzalloc(sizeof(*opts), GFP_KERNEL); - if (!opts) { - mutex_unlock(_instances_lock); + opts = kzalloc(sizeof(*opts), GFP_KERNEL); + if (!opts) return ERR_PTR(-ENOMEM); - } + + mutex_lock(_instances_lock); for (i = 0; i < TPG_INSTANCES; ++i) if (!tpg_instances[i].func_inst) break; if (i == TPG_INSTANCES) { mutex_unlock(_instances_lock); - + kfree(opts); return ERR_PTR(-EBUSY); } tpg_instances[i].func_inst = >func_inst; -- 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: Use memdup_user to reuse the code
Hello Alan, Should I resend this patch version with the tear line correction? Regards Rahul Pathak From: Alan SternSent: Tuesday, December 8, 2015 8:53 PM To: Pathak, Rahul (R.) Cc: gre...@linuxfoundation.org; kbo...@gmail.com; dan.carpen...@oracle.com; chasemetzge...@gmail.com; linux-usb@vger.kernel.org; linux-ker...@vger.kernel.org Subject: Re: [PATCH v2] usb: Use memdup_user to reuse the code On Tue, 8 Dec 2015, Pathak, Rahul (R.) wrote: > From: Rahul Pathak > > Fixing coccicheck warning which recommends to use memdup_user instead > to reimplement its code, using memdup_user simplifies the code > > ./drivers/usb/core/devio.c:1398:11-18: WARNING opportunity for memdup_user > > Changes after v1: setting isopkt=NULL for proper kfree() call This line belongs below the "---" tear line, so that it doesn't show up in the final commit changelog. People reading the final commit won't care about earlier versions of the patch. > Signed-off-by: Rahul Pathak > --- > drivers/usb/core/devio.c | 9 - > 1 file changed, 4 insertions(+), 5 deletions(-) > > diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c > index 38ae877c..844407c 100644 > --- a/drivers/usb/core/devio.c > +++ b/drivers/usb/core/devio.c > @@ -1395,11 +1395,10 @@ static int proc_do_submiturb(struct usb_dev_state > *ps, struct usbdevfs_urb *uurb > number_of_packets = uurb->number_of_packets; > isofrmlen = sizeof(struct usbdevfs_iso_packet_desc) * > number_of_packets; > - isopkt = kmalloc(isofrmlen, GFP_KERNEL); > - if (!isopkt) > - return -ENOMEM; > - if (copy_from_user(isopkt, iso_frame_desc, isofrmlen)) { > - ret = -EFAULT; > + isopkt = memdup_user(iso_frame_desc, isofrmlen); > + if (IS_ERR(isopkt)) { > + ret = PTR_ERR(isopkt); > + isopkt = NULL; > goto error; > } > for (totlen = u = 0; u < number_of_packets; u++) { Aside from that, Acked-by: Alan Stern 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 2/3] doc: dt-binding: generic onboard USB HUB
On Tue, Dec 08, 2015 at 10:50:49AM +0100, Philipp Zabel wrote: > Hi Peter, > > Am Dienstag, den 08.12.2015, 09:37 +0800 schrieb Peter Chen: > > Add dt-binding documentation for generic onboard USB HUB. > > > > Signed-off-by: Peter Chen> > --- > > .../bindings/usb/generic-onboard-hub.txt | 28 > > ++ > > 1 file changed, 28 insertions(+) > > create mode 100644 > > Documentation/devicetree/bindings/usb/generic-onboard-hub.txt > > > > diff --git a/Documentation/devicetree/bindings/usb/generic-onboard-hub.txt > > b/Documentation/devicetree/bindings/usb/generic-onboard-hub.txt > > new file mode 100644 > > index 000..ea92205 > > --- /dev/null > > +++ b/Documentation/devicetree/bindings/usb/generic-onboard-hub.txt > > @@ -0,0 +1,28 @@ > > +Generic Onboard USB HUB > >+ > > +Required properties: > > +- compatible: should be "generic-onboard-hub" > > This something we don't have to define ad-hoc. The hub hangs off an USB > controller, right? The "Open Firmware recommended practice: USB" > document already describes how to represent USB devices in a generic > manner: > http://www.firmware.org/1275/bindings/usb/usb-1_0.ps > > Is there a reason not to reuse this? > > The usb hub node would be a child of the usb controller node, and it > could use > compatible = "usb,class9"; /* bDeviceClass 9 (Hub) */ > Before writing this driver, I did consider how to let the USB core handle device tree, but without good solution. The controller (platform) driver should not handle specific USB device described at device tree, since we want this handling to be generic. And the USB device may not be recognized by controller without handling its properties, like clock, reset pins. With your suggestion, the dts likes below usbh1: usb@02184000 { compatible = "fsl,imx6q-usb", "fsl,imx27-usb"; reg = <0x02184000 0x200>; interrupts = <0 43 IRQ_TYPE_LEVEL_HIGH>; clocks = < IMX6QDL_CLK_USBOH3>; usb_hub@1 { compatible = "usb,class9" clocks = < USB_HUB_CLK>; }; }; I don't know how to handle above at USB bus, if you have any suggestions, give me some tips please. > > > +Optional properties: > > +- clocks: the input clock for HUB. > > + > > +- clock-names: Should be "external_clk" > > Is clock-names necessary for a single clock? > > > +- hub-reset-gpios: Should specify the GPIO for reset. > > I'd prefer that to be just "reset-gpios", it is the only reset property > in the hub node after all. And use the GPIO_ACTIVE_HIGH/LOW flags to > indicate polarity. I will change to "clk" and "reset-gpios". > > > +- hub-reset-active-high: the active reset signal is high, if this property > > is > > + not set, the active reset signal is low. > > Then this could be dropped. > > > +- hub-reset-duration-us: the duration for assert reset signal, the time > > unit > > + is microsecond. > > And consequently, this could just be called "reset-duration-us". > It might make sense to define the same for other reset GPIOs, too. > The Freescale FEC, for example, has "phy-reset-duration" (in ms) > already. > Agree. By the way: Felipe suggest using generic reset gpio driver to handle above, I find you have written similar things before [1], why it can't be accepted? [1]http://comments.gmane.org/gmane.linux.ports.arm.kernel/255129 -- Best Regards, Peter Chen -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/3] usb: misc: generic_onboard_hub: add generic onboard USB HUB driver
On Tue, Dec 08, 2015 at 08:36:00AM -0700, Mathieu Poirier wrote: > On 7 December 2015 at 18:37, Peter Chenwrote: > > + > > + if (dev->of_node) { > > + struct device_node *node = dev->of_node; > > + > > + hub_data->clk = devm_clk_get(dev, "external_clk"); > > + if (IS_ERR(hub_data->clk)) { > > + dev_dbg(dev, "Can't get external clock: %ld\n", > > + PTR_ERR(hub_data->clk)); > > + } > > Is the intended behaviour to keep going here event when there is an > error? Can the "hub_data" really work without a clock? Yes, some HUB may work with fixed 24M OSC at the board, but they need to reset through external IO, so the clock is not need at this case, but reset pin is mandatory. > > + } > > + > > + if (gpiod_reset) { > > + /* Sanity check */ > > + if (duration_us > 100) > > + duration_us = 50; > > + usleep_range(duration_us, duration_us + 100); > > + gpiod_set_value(gpiod_reset, reset_pol ? 0 : 1); > > What are these hard-coded values? Shouldn't this be taken from the > DT? If not then some comments explaining the values would be > appreciated. Yes, I did it wrongly, thanks. > > diff --git a/include/linux/usb/generic_onboard_hub.h > > b/include/linux/usb/generic_onboard_hub.h > > new file mode 100644 > > index 000..1b70ccc > > --- /dev/null > > +++ b/include/linux/usb/generic_onboard_hub.h > > @@ -0,0 +1,11 @@ > > +#ifndef __LINUX_USB_GENERIC_HUB_H > > +#define __LINUX_USB_GENERIC_HUB_H > > + > > +struct usb_hub_generic_platform_data { > > + int gpio_reset; > > + int gpio_reset_polarity; > > + int gpio_reset_duration_us; > > + struct clk *ext_clk; > > +}; > > Please document this structure in accordance with kernel documentation > standards. > Thanks, it should be. -- Best Regards, Peter Chen -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/3] usb: misc: generic_onboard_hub: add generic onboard USB HUB driver
On Tue, Dec 08, 2015 at 10:48:28AM +0100, Arnd Bergmann wrote: > On Tuesday 08 December 2015 09:37:48 Peter Chen wrote: > > > +struct usb_hub_generic_data { > > + struct clk *clk; > > +}; > > + > > +static int usb_hub_generic_probe(struct platform_device *pdev) > > +{ > > + struct device *dev = >dev; > > + struct usb_hub_generic_platform_data *pdata = dev->platform_data; > > + struct usb_hub_generic_data *hub_data; > > + int reset_pol = 0, duration_us = 50, ret = 0; > > + struct gpio_desc *gpiod_reset = NULL; > > + > > + hub_data = devm_kzalloc(dev, sizeof(*hub_data), GFP_KERNEL); > > + if (!hub_data) > > + return -ENOMEM; > > + > > + if (dev->of_node) { > > Let's not worry about the !DT case until someone adds a board file > that needs it. Just remove the if() here along and the whole else > block. > > > +#ifdef CONFIG_OF > > +static const struct of_device_id usb_hub_generic_dt_ids[] = { > > + {.compatible = "generic-onboard-hub"}, > > + { }, > > +}; > > +MODULE_DEVICE_TABLE(of, usb_hub_generic_dt_ids); > > +#endif > > + > > +static struct platform_driver usb_hub_generic_driver = { > > + .probe = usb_hub_generic_probe, > > + .remove = usb_hub_generic_remove, > > + .driver = { > > + .name = "usb_hub_generic_onboard", > > + .of_match_table = usb_hub_generic_dt_ids, > > +}, > > +}; > > Build error when CONFIG_OF is disabled: Please remove the #ifdef around the > device > table. > > > diff --git a/include/linux/usb/generic_onboard_hub.h > > b/include/linux/usb/generic_onboard_hub.h > > new file mode 100644 > > index 000..1b70ccc > > --- /dev/null > > +++ b/include/linux/usb/generic_onboard_hub.h > > @@ -0,0 +1,11 @@ > > +#ifndef __LINUX_USB_GENERIC_HUB_H > > +#define __LINUX_USB_GENERIC_HUB_H > > + > > +struct usb_hub_generic_platform_data { > > + int gpio_reset; > > + int gpio_reset_polarity; > > + int gpio_reset_duration_us; > > + struct clk *ext_clk; > > +}; > > Merge this structure into struct usb_hub_generic_data and remove the header. > > ARnd Agree. -- Best Regards, Peter Chen -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/3] usb: misc: generic_onboard_hub: add generic onboard USB HUB driver
On Tue, Dec 08, 2015 at 10:44:02AM +0100, Sascha Hauer wrote: > On Tue, Dec 08, 2015 at 05:26:56PM +0800, Peter Chen wrote: > > On Tue, Dec 08, 2015 at 07:19:05AM +0100, Sascha Hauer wrote: > > > > + hub_data = devm_kzalloc(dev, sizeof(*hub_data), GFP_KERNEL); > > > > + if (!hub_data) > > > > + return -ENOMEM; > > > > + > > > > + if (dev->of_node) { > > > > + struct device_node *node = dev->of_node; > > > > + > > > > + hub_data->clk = devm_clk_get(dev, "external_clk"); > > > > > > Please drop such _clk suffixes. The context already makes it clear that > > > it's a clock. > > > > > > > Will change. > > > > > > + if (IS_ERR(hub_data->clk)) { > > > > + dev_dbg(dev, "Can't get external clock: %ld\n", > > > > + PTR_ERR(hub_data->clk)); > > > > + } > > > > + > > > > + /* > > > > +* Try to get the information for HUB reset, the > > > > +* default setting like below: > > > > +* > > > > +* - Reset state is low > > > > +* - The duration is 50us > > > > +*/ > > > > + if (of_find_property(node, "hub-reset-active-high", > > > > NULL)) > > > > + reset_pol = 1; > > > > + > > > > + of_property_read_u32(node, "hub-reset-duration-us", > > > > + _us); > > > > + > > > > + gpiod_reset = devm_gpiod_get_optional(dev, "hub-reset", > > > > + reset_pol ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW); > > > > + ret = PTR_ERR_OR_ZERO(gpiod_reset); > > > > + if (ret) { > > > > + dev_err(dev, "Failed to get reset gpio, err = > > > > %d\n", > > > > + ret); > > > > + return ret; > > > > + } > > > > + } else if (pdata) { > > > > + hub_data->clk = pdata->ext_clk; > > > > > > Passing clocks in platform_data is a no go. clocks must always be > > > retrieved with clk_get. > > > > Yes, you are right. > > > > > > > > > + duration_us = pdata->gpio_reset_duration_us; > > > > + reset_pol = pdata->gpio_reset_polarity; > > > > + > > > > + if (gpio_is_valid(pdata->gpio_reset)) { > > > > + ret = devm_gpio_request_one( > > > > + dev, pdata->gpio_reset, reset_pol > > > > + ? GPIOF_OUT_INIT_HIGH : > > > > GPIOF_OUT_INIT_LOW, > > > > + dev_name(dev)); > > > > + if (!ret) > > > > + gpiod_reset = > > > > gpio_to_desc(pdata->gpio_reset); > > > > > > If the gpio is valid then being unable to get it is an error. > > > > I can't catch you, if the gpio is invalid, its descriptor will be NULL, > > then, the code will not do any gpio operation. > > When the platform_data provides a gpio (gpio_is_valid() is true) then > you must use the gpio. If then devm_gpio_request_one() fails you must > bail out. I see. > > > > > > > > > Do you need this platform_data stuff at all? > > > > > > > If not, how can I cover the platform which does not use dts, but still > > uses these kinds of HUBs? > > You can't, but are there any non device tree platforms which want to use > this driver? > I thought there are i386 embedded devices, it may use the HUB, like this driver tries to handle. I agree that we only handle dt in this driver first until the non-dt user appears. -- Best Regards, Peter Chen -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/3] usb: misc: generic_onboard_hub: add generic onboard USB HUB driver
On Tue, Dec 08, 2015 at 07:55:05AM -0600, Felipe Balbi wrote: > > Hi, > > Peter Chenwrites: > >> seriously ? Is this really all ? What about that reset line below ? > > > > The clock is PHY input clock on the HUB, this clock may from SoC's > > PLL. > > oh, you might have misunderstood my comment. I'm saying that there is > more than one thing you could cache in your private structure. That's > all. > How? I need to handle clock at both ->probe and ->remove. > >> > +static int usb_hub_generic_probe(struct platform_device *pdev) > >> > +{ > >> > +struct device *dev = >dev; > >> > +struct usb_hub_generic_platform_data *pdata = > >> > dev->platform_data; > >> > +struct usb_hub_generic_data *hub_data; > >> > +int reset_pol = 0, duration_us = 50, ret = 0; > >> > +struct gpio_desc *gpiod_reset = NULL; > >> > + > >> > +hub_data = devm_kzalloc(dev, sizeof(*hub_data), GFP_KERNEL); > >> > +if (!hub_data) > >> > +return -ENOMEM; > >> > + > >> > +if (dev->of_node) { > >> > +struct device_node *node = dev->of_node; > >> > + > >> > +hub_data->clk = devm_clk_get(dev, "external_clk"); > >> > +if (IS_ERR(hub_data->clk)) { > >> > +dev_dbg(dev, "Can't get external clock: %ld\n", > >> > +PTR_ERR(hub_data->clk)); > >> > >> how about setting clock to NULL to here ? then you don't need IS_ERR() > >> checks anywhere else. > >> > >> > +} > >> > >> braces shouldn't be used here, if you add NULL trick above, > >> however... then you can keep them. > >> > > > > Braces aren't needed, it may not too much useful to using NULL > > as a indicator for error pointer. > > heh, it's not about using it as an error pointer. I'm merely trying to > make clk optional. NULL is a valid clk, meaning you won't get NULL > pointer dereferences when passing it along clk_*() calls (if you find > any, it's likely a bug in CCF), so NULL can be used to cope with > optional clocks: > > clk = clk_get(dev, "foo"); > if (IS_ERR(clk)) { > if (PTR_ERR(clk) == -EPROBE_DEFER) > return -EPROBE_DEFER; > else > clk = NULL; > } > Get your point, so at coming code, we don't need to add condition to enable optional clock. > >> > +/* > >> > + * Try to get the information for HUB reset, the > >> > + * default setting like below: > >> > + * > >> > + * - Reset state is low > >> > + * - The duration is 50us > >> > + */ > >> > +if (of_find_property(node, "hub-reset-active-high", > >> > NULL)) > >> > +reset_pol = 1; > >> > >> you see, this is definitely *not* generic. You should write a generic > >> reset-gpio.c reset controller and describe the polarity on the gpio > >> binding. This driver *always* uses reset_assert(); reset_deassert(); and > >> reset-gpio implements though by gpiod_set_value() correctly. > >> > >> Polarity _must_ be described elsewhere in DT. > >> > >> > +of_property_read_u32(node, "hub-reset-duration-us", > >> > +_us); > >> > >> likewise, this should be described as a debounce time for the GPIO. > >> > > > > Yes, if we are a reset gpio driver. > > even if you use a raw GPIO, polarity and duration must come through DT. > > >> > +usleep_range(duration_us, duration_us + 100); > >> > +gpiod_set_value(gpiod_reset, reset_pol ? 0 : 1); > >> > >> wrong. You should _not_ have polarity checks here. You should have > >> already initialized the gpio as ACTIVE_HIGH or ACTIVE_LOW and gpiolib > >> will handle the polarity for you. > > > > Yes, you are right. I did not understand ACTIVE_LOW for gpio flag > > before. > > with open source code, that's a rather poor excuse, Peter. I will pay attention to it, thanks. At my dts example, it is like below, I just treat it at raw gpio handling. usb_hub1 { compatible = "generic-onboard-hub"; clocks = < IMX6QDL_CLK_CKO>; clock-names = "external_clk"; hub-reset-active-high; hub-reset-gpios = < 12 0>; hub-reset-duration-us = <2>; }; I will change it like below: usb_hub1 { compatible = "generic-onboard-hub"; clocks = < IMX6QDL_CLK_CKO>; clock-names = "clk"; reset-gpios = < 12 GPIO_ACTIVE_HIGH>; reset-duration-us = <2>; }; > > >> > +static int __init usb_hub_generic_init(void) > >> > +{ > >> > +return platform_driver_register(_hub_generic_driver); > >> > +} > >> > +subsys_initcall(usb_hub_generic_init); > >> > + > >> > +static void __exit
Re: [PATCH 1/3] usb: misc: generic_onboard_hub: add generic onboard USB HUB driver
On Wed, Dec 09, 2015 at 10:10:51AM +0100, Arnd Bergmann wrote: > On Wednesday 09 December 2015 09:57:40 Lucas Stach wrote: > > Am Mittwoch, den 09.12.2015, 16:50 +0800 schrieb Peter Chen: > > > On Tue, Dec 08, 2015 at 08:36:00AM -0700, Mathieu Poirier wrote: > > > > On 7 December 2015 at 18:37, Peter Chen> > > > wrote: > > > > > + > > > > > + if (dev->of_node) { > > > > > + struct device_node *node = dev->of_node; > > > > > + > > > > > + hub_data->clk = devm_clk_get(dev, "external_clk"); > > > > > + if (IS_ERR(hub_data->clk)) { > > > > > + dev_dbg(dev, "Can't get external clock: > > > > > %ld\n", > > > > > + PTR_ERR(hub_data->clk)); > > > > > + } > > > > > > > > Is the intended behaviour to keep going here event when there is an > > > > error? Can the "hub_data" really work without a clock? > > > > > > Yes, some HUB may work with fixed 24M OSC at the board, but they need to > > > reset through external IO, so the clock is not need at this case, but > > > reset pin is mandatory. > > > > > If the hub always requires a clock it must not be optional. If you have > > a fixed 24MHz clock on board add this to the DT as a fixed-clock and use > > it as an input to the hub. > > I think it's fine to make the clock optional in the sense that you only > need to list non-fixed clocks that have to be enabled and or controlled. > > Which reminds me, should the driver call clk_set_rate()? It currently > doesn't, but other machines might need that. > Yes, you are right, I will add it at v2. -- Best Regards, Peter Chen -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/3] doc: dt-binding: generic onboard USB HUB
On Wednesday 09 December 2015 16:12:24 Peter Chen wrote: > On Tue, Dec 08, 2015 at 09:24:03PM -0600, Rob Herring wrote: > > On Tue, Dec 08, 2015 at 10:58:48AM +0100, Arnd Bergmann wrote: > > > On Tuesday 08 December 2015 10:50:49 Philipp Zabel wrote: > > > > This something we don't have to define ad-hoc. The hub hangs off an USB > > > > controller, right? The "Open Firmware recommended practice: USB" > > > > document already describes how to represent USB devices in a generic > > > > manner: > > > > http://www.firmware.org/1275/bindings/usb/usb-1_0.ps > > > > > > > > Is there a reason not to reuse this? > > > > > > > > The usb hub node would be a child of the usb controller node, and it > > > > could use > > > > compatible = "usb,class9"; /* bDeviceClass 9 (Hub) */ > > > > > > Good point, I had not thought of that when I looked at the patches. > > > > > > Yes, let's do this way. I don't know if we ever implemented the simple > > > patch to associate a USB device with a device_node, but if not, then > > > let's do it now for this driver. A lot of people have asked for it in > > > the past. > > > > Agreed. Also, some hubs have I2C buses as well, but I still think under > > the USB bus is the right place. > > > > However, one complication here is often (probably this case) these > > addtional signals need to be controlled before the device enumerates. > > > > Yes, I did not find a way to let the USB bus code handle it, so I had to > write a platform driver to do it Looping in Ulf, he solved the same problem for SDIO devices recently, and probably remembers the details best. Arnd -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH 1/3] usb: misc: generic_onboard_hub: add generic onboard USB HUB driver
Best regards, Peter Chen > -Original Message- > From: Lucas Stach [mailto:l.st...@pengutronix.de] > Sent: Wednesday, December 09, 2015 5:13 PM > To: Chen Peter-B29397> Cc: Mathieu Poirier ; Mark Rutland > ; devicet...@vger.kernel.org; feste...@gmail.com; > Philipp Zabel ; Paweł Moll ; > Greg KH ; linux-usb@vger.kernel.org; > pat...@kowalczyk.ws; Rob Herring ; > st...@rowland.harvard.edu; ker...@pengutronix.de; Shawn Guo > ; linux-arm-ker...@lists.infradead.org > Subject: Re: [PATCH 1/3] usb: misc: generic_onboard_hub: add generic > onboard USB HUB driver > > Am Mittwoch, den 09.12.2015, 17:00 +0800 schrieb Peter Chen: > > On Wed, Dec 09, 2015 at 09:57:40AM +0100, Lucas Stach wrote: > > > Am Mittwoch, den 09.12.2015, 16:50 +0800 schrieb Peter Chen: > > > > On Tue, Dec 08, 2015 at 08:36:00AM -0700, Mathieu Poirier wrote: > > > > > On 7 December 2015 at 18:37, Peter Chen > wrote: > > > > > > + > > > > > > + if (dev->of_node) { > > > > > > + struct device_node *node = dev->of_node; > > > > > > + > > > > > > + hub_data->clk = devm_clk_get(dev, "external_clk"); > > > > > > + if (IS_ERR(hub_data->clk)) { > > > > > > + dev_dbg(dev, "Can't get external clock: > > > > > > %ld\n", > > > > > > + PTR_ERR(hub_data->clk)); > > > > > > + } > > > > > > > > > > Is the intended behaviour to keep going here event when there is > > > > > an error? Can the "hub_data" really work without a clock? > > > > > > > > Yes, some HUB may work with fixed 24M OSC at the board, but they > > > > need to reset through external IO, so the clock is not need at > > > > this case, but reset pin is mandatory. > > > > > > > If the hub always requires a clock it must not be optional. If you > > > have a fixed 24MHz clock on board add this to the DT as a > > > fixed-clock and use it as an input to the hub. > > > > > > > This fixed 24MHz clock may from a fixed crystal on board, it is always > > on, no software need to control it, imx51-bbg board is an example. > > > And that's wh it is a fixed-clock. Please look it up in the DT binding > documentation. Yes, I see similar things are described at [1], but why we need this additional entry at dts for this case, it is always on, no software is needed. [1] Documentation/devicetree/bindings/clock/clock-bindings.txt Peter
Re: [PATCH 2/3] doc: dt-binding: generic onboard USB HUB
On Tue, Dec 08, 2015 at 09:24:03PM -0600, Rob Herring wrote: > On Tue, Dec 08, 2015 at 10:58:48AM +0100, Arnd Bergmann wrote: > > On Tuesday 08 December 2015 10:50:49 Philipp Zabel wrote: > > > Am Dienstag, den 08.12.2015, 09:37 +0800 schrieb Peter Chen: > > > > Add dt-binding documentation for generic onboard USB HUB. > > > > > > > > Signed-off-by: Peter Chen> > > > --- > > > > .../bindings/usb/generic-onboard-hub.txt | 28 > > > > ++ > > > > 1 file changed, 28 insertions(+) > > > > create mode 100644 > > > > Documentation/devicetree/bindings/usb/generic-onboard-hub.txt > > > > > > > > diff --git > > > > a/Documentation/devicetree/bindings/usb/generic-onboard-hub.txt > > > > b/Documentation/devicetree/bindings/usb/generic-onboard-hub.txt > > > > new file mode 100644 > > > > index 000..ea92205 > > > > --- /dev/null > > > > +++ b/Documentation/devicetree/bindings/usb/generic-onboard-hub.txt > > > > @@ -0,0 +1,28 @@ > > > > +Generic Onboard USB HUB > > > >+ > > > > +Required properties: > > > > +- compatible: should be "generic-onboard-hub" > > > > > > This something we don't have to define ad-hoc. The hub hangs off an USB > > > controller, right? The "Open Firmware recommended practice: USB" > > > document already describes how to represent USB devices in a generic > > > manner: > > > http://www.firmware.org/1275/bindings/usb/usb-1_0.ps > > > > > > Is there a reason not to reuse this? > > > > > > The usb hub node would be a child of the usb controller node, and it > > > could use > > > compatible = "usb,class9"; /* bDeviceClass 9 (Hub) */ > > > > Good point, I had not thought of that when I looked at the patches. > > > > Yes, let's do this way. I don't know if we ever implemented the simple > > patch to associate a USB device with a device_node, but if not, then > > let's do it now for this driver. A lot of people have asked for it in > > the past. > > Agreed. Also, some hubs have I2C buses as well, but I still think under > the USB bus is the right place. > > However, one complication here is often (probably this case) these > addtional signals need to be controlled before the device enumerates. > Yes, I did not find a way to let the USB bus code handle it, so I had to write a platform driver to do it -- Best Regards, Peter Chen -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] Add support for usbfs zerocopy.
Add a new interface for userspace to preallocate memory that can be used with usbfs. This gives two primary benefits: - Zerocopy; data no longer needs to be copied between the userspace and the kernel, but can instead be read directly by the driver from userspace's buffers. This works for all kinds of transfers (even if nonsensical for control and interrupt transfers); isochronous also no longer need to memset() the buffer to zero to avoid leaking kernel data. - Once the buffers are allocated, USB transfers can no longer fail due to memory fragmentation; previously, long-running programs could run into problems finding a large enough contiguous memory chunk, especially on embedded systems or at high rates. Memory is allocated by using mmap() against the usbfs file descriptor, and similarly deallocated by munmap(). Once memory has been allocated, using it as pointers to a bulk or isochronous operation means you will automatically get zerocopy behavior. Note that this also means you cannot modify outgoing data until the transfer is complete. The same holds for data on the same cache lines as incoming data; DMA modifying them at the same time could lead to your changes being overwritten. There's a new capability USBDEVFS_CAP_MMAP that userspace can query to see if the running kernel supports this functionality, if just trying mmap() is not acceptable. Largely based on a patch by Markus Rechberger with some updates. The original patch can be found at: http://sundtek.de/support/devio_mmap_v0.4.diff Signed-off-by: Steinar H. GundersonSigned-off-by: Markus Rechberger Acked-by: Alan Stern --- drivers/usb/core/devio.c | 230 +- include/uapi/linux/usbdevice_fs.h | 1 + 2 files changed, 206 insertions(+), 25 deletions(-) diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index 38ae877c..3349222 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c @@ -50,6 +50,7 @@ #include #include #include +#include #include #include @@ -69,6 +70,7 @@ struct usb_dev_state { spinlock_t lock;/* protects the async urb lists */ struct list_head async_pending; struct list_head async_completed; + struct list_head memory_list; wait_queue_head_t wait; /* wake up if a request completed */ unsigned int discsignr; struct pid *disc_pid; @@ -79,6 +81,17 @@ struct usb_dev_state { u32 disabled_bulk_eps; }; +struct usb_memory { + struct list_head memlist; + int vma_use_count; + int urb_use_count; + u32 size; + void *mem; + dma_addr_t dma_handle; + unsigned long vm_start; + struct usb_dev_state *ps; +}; + struct async { struct list_head asynclist; struct usb_dev_state *ps; @@ -89,6 +102,7 @@ struct async { void __user *userbuffer; void __user *userurb; struct urb *urb; + struct usb_memory *usbm; unsigned int mem_usage; int status; u32 secid; @@ -157,6 +171,108 @@ static int connected(struct usb_dev_state *ps) ps->dev->state != USB_STATE_NOTATTACHED); } +static void dec_usb_memory_use_count(struct usb_memory *usbm, int *count) +{ + struct usb_dev_state *ps = usbm->ps; + unsigned long flags; + + spin_lock_irqsave(>lock, flags); + --*count; + if (usbm->urb_use_count == 0 && usbm->vma_use_count == 0) { + list_del(>memlist); + spin_unlock_irqrestore(>lock, flags); + + usb_free_coherent(ps->dev, usbm->size, usbm->mem, + usbm->dma_handle); + usbfs_decrease_memory_usage( + usbm->size + sizeof(struct usb_memory)); + kfree(usbm); + } else { + spin_unlock_irqrestore(>lock, flags); + } +} + +static void usbdev_vm_open(struct vm_area_struct *vma) +{ + struct usb_memory *usbm = vma->vm_private_data; + unsigned long flags; + + spin_lock_irqsave(>ps->lock, flags); + ++usbm->vma_use_count; + spin_unlock_irqrestore(>ps->lock, flags); +} + +static void usbdev_vm_close(struct vm_area_struct *vma) +{ + struct usb_memory *usbm = vma->vm_private_data; + + dec_usb_memory_use_count(usbm, >vma_use_count); +} + +struct vm_operations_struct usbdev_vm_ops = { + .open = usbdev_vm_open, + .close = usbdev_vm_close +}; + +static int usbdev_mmap(struct file *file, struct vm_area_struct *vma) +{ + struct usb_memory *usbm = NULL; + struct usb_dev_state *ps = file->private_data; + size_t size = vma->vm_end - vma->vm_start; + void *mem; + unsigned long flags; + dma_addr_t dma_handle; + int ret; + + ret = usbfs_increase_memory_usage(size + sizeof(struct usb_memory)); + if (ret) { +
Re: [PATCH v2] usb: Use memdup_user to reuse the code
On Wed, Dec 09, 2015 at 08:02:53AM +, Pathak, Rahul (R.) wrote: > Hello Alan, > > Should I resend this patch version with the tear line correction? Why wouldn't you? -- 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] Add support for usbfs zerocopy.
On Thu, Nov 26, 2015 at 01:19:13AM +0100, Steinar H. Gunderson wrote: > Add a new interface for userspace to preallocate memory that can be > used with usbfs. This gives two primary benefits: > > - Zerocopy; data no longer needs to be copied between the userspace >and the kernel, but can instead be read directly by the driver from >userspace's buffers. This works for all kinds of transfers (even if >nonsensical for control and interrupt transfers); isochronous also >no longer need to memset() the buffer to zero to avoid leaking kernel data. > > - Once the buffers are allocated, USB transfers can no longer fail due to >memory fragmentation; previously, long-running programs could run into >problems finding a large enough contiguous memory chunk, especially on >embedded systems or at high rates. > > Memory is allocated by using mmap() against the usbfs file descriptor, > and similarly deallocated by munmap(). Once memory has been allocated, > using it as pointers to a bulk or isochronous operation means you will > automatically get zerocopy behavior. Note that this also means you cannot > modify outgoing data until the transfer is complete. The same holds for > data on the same cache lines as incoming data; DMA modifying them at the > same time could lead to your changes being overwritten. > > There's a new capability USBDEVFS_CAP_MMAP that userspace can query to see > if the running kernel supports this functionality, if just trying mmap() is > not acceptable. Shouldn't there also be some sort of documentation update with this patch as well, so that people know of the new functionality we are adding? 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] Add support for usbfs zerocopy.
On Wed, Dec 09, 2015 at 09:29:20AM -0500, Greg Kroah-Hartman wrote: > Shouldn't there also be some sort of documentation update with this > patch as well, so that people know of the new functionality we are > adding? I can write documentation if you can point me to a reasonable place. /* Steinar */ -- Software Engineer, Google Switzerland -- 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: f_tcm: ignore return value of queue_work
queue_work() has never returned anything less than zero. Reported-by: Dan CarpenterSigned-off-by: Andrzej Pietrasiewicz --- This patch depends on the series adding configfs support to tcm usb gadget: http://www.spinics.net/lists/target-devel/msg11215.html drivers/usb/gadget/function/f_tcm.c | 8 ++-- 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/usb/gadget/function/f_tcm.c b/drivers/usb/gadget/function/f_tcm.c index 9cb4a6b..508f271 100644 --- a/drivers/usb/gadget/function/f_tcm.c +++ b/drivers/usb/gadget/function/f_tcm.c @@ -1156,9 +1156,7 @@ static int usbg_submit_command(struct f_uas *fu, cmd->unpacked_lun = scsilun_to_int(_iu->lun); INIT_WORK(>work, usbg_cmd_work); - ret = queue_work(tpg->workqueue, >work); - if (ret < 0) - goto err; + queue_work(tpg->workqueue, >work); return 0; err: @@ -1253,9 +1251,7 @@ static int bot_submit_command(struct f_uas *fu, cmd->se_cmd.tag = le32_to_cpu(cmd->bot_tag); INIT_WORK(>work, bot_cmd_work); - ret = queue_work(tpg->workqueue, >work); - if (ret < 0) - goto err; + queue_work(tpg->workqueue, >work); return 0; err: -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] Add support for usbfs zerocopy.
On Wed, 9 Dec 2015, Steinar H. Gunderson wrote: > On Wed, Dec 09, 2015 at 09:29:20AM -0500, Greg Kroah-Hartman wrote: > > Shouldn't there also be some sort of documentation update with this > > patch as well, so that people know of the new functionality we are > > adding? > > I can write documentation if you can point me to a reasonable place. The only documentation I know of for usbfs is a dreadfully out-of-date section in Documentation/DocBook/usb.tmpl. 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
[GIT PULL] USB fixes for v4.4-rc5
Hi Greg, Here's what I hope to be the last set of fixes for current -rc. Let me know if you want anything to be changed. cheers The following changes since commit f74875dc36135ebae82a8e005f4b7f52289d2c40: usb: dwc2: fix kernel oops during driver probe (2015-11-20 09:29:47 -0600) are available in the git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git tags/fixes-for-v4.4-rc5 for you to fetch changes up to 7d32cdef535622c0aea39807989f62cdddea207e: usb: musb: fail with error when no DMA controller set (2015-12-09 09:36:03 -0600) usb: fixes for-v4.4-rc5 Hopefully final set of fixes for v4.4 release cycle. There's a fix for a regression on dwc3 caused by recent changes to how transfers are started. We're not pre-starting interrupt endpoints anymore. A NULL pointer dereference fix for the MSM phy driver. The UVC gadget got a minor fix for permissions to its configfs attributes and, finally, two fixes for MUSB. A fix for PM runtime when MUSB returns EPROBE_DEFER and a fix to actually return an error in case we can't initialize a DMA engine. Signed-off-by: Felipe BalbiAaro Koskinen (1): usb: musb: fail with error when no DMA controller set Felipe Balbi (1): usb: dwc3: gadget: don't prestart interrupt endpoints LABBE Corentin (1): usb: phy: msm: fix a possible NULL dereference Mian Yousaf Kaukab (1): usb: gadget: uvc: fix permissions of configfs attributes Tony Lindgren (1): usb: musb: core: Fix pm runtime for deferred probe drivers/usb/dwc3/gadget.c | 1 + drivers/usb/gadget/function/uvc_configfs.c | 2 +- drivers/usb/musb/musb_core.c | 8 +++- drivers/usb/phy/phy-msm-usb.c | 6 +++--- 4 files changed, 12 insertions(+), 5 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: USB TrackPoint mouse non-functional with dock; works if direct
On Tue, 8 Dec 2015, Josh Triplett wrote: > On Tue, Dec 08, 2015 at 11:04:00AM -0500, Alan Stern wrote: > > On Mon, 7 Dec 2015, Josh Triplett wrote: > > > > > > You're looking at the wrong files. The files to monitor are the ones > > > > in /sys/devices/pci:00/:00:14.0/usb2/2-3/2-3.1/2-3.1.2/power > > > > (assuming that this device really is the mouse and not something else). > > > > > > > > Handy shortcut link: /sys/bus/usb/devices/2-3.1.2/power. > > > > > > Based on the idVendor and idProduct in that directory, that device is > > > the keyboard/mouse combo device, yes. > > > > > > That power directory has many more files, but nothing obvious: > > ... > > > ==> > > > /sys/devices/pci:00/:00:14.0/usb2/2-3/2-3.1/2-3.1.2/power/control > > > <== > > > on > > > > That's the important one. It means the mouse isn't going to be > > autosuspended. > > So it doesn't matter that the other sysfs directory (the one listed by > dmesg for the mouse input device, containing the :1.1) showed up with > autosuspend enabled and the device suspending after a moment, roughly > matching the "works for a second and then stops" behavior? That seems > entirely too coincidental. You had a couple of other sysfs directories. Along with /sys/.../2-3.1.2:1.1/power there was also /sys/.../2-2:1.1/0003:17EF:6009.002D/power. The first corresponds to the USB interface (bound to the usbhid driver in this case). The autosuspend values in that directory are nearly meaningless; even when it says the interface is in runtime suspend, it need not actually be. I don't know what the second refers to. Some other device entirely? In any case, what actually matters is what the hardware sees, not what the drivers do, and we know what messages were sent to/from the mouse hardware. The usbmon output shows all of them. And in particular we can rule out suspend as the cause of the problem. _Nothing_ got suspended during the time interval in question (it would have shown up in the usbmon trace). > What do that other sysfs directory's properties mean, if not the actual > suspend state of the device? Basically, they indicate what the PM core thinks is going on. But the PM core doesn't understand the internal workings of every bus subsystem and every driver. For example, in the case of USB consider the difference between your 2-3.1.2 and 2-3.1.2:1.1 "devices". I put the word in quotes because only the first refers to a physical device (the mouse); the other refers to one of the logical interfaces within that device. Suspending a USB device requires that all its interfaces be in their logical suspend state, but suspending an interface while the device remains powered does nothing at all. Neither the hardware nor the driver is aware of the interface's state; the interface driver's runtime PM callbacks are invoked when the device (not the interface!) goes into or out of runtime suspend. > > > > For more information on what's happening, try collecting a usbmon trace > > > > for bus 2 (see Documentation/usb/usbmon.txt). > > > > > > Done. I started a trace, plugged in the device, moved the mouse a > > > little (which moved the pointer for a moment and then stopped > > > producing any result), typed a couple of keys (which did work), moved > > > the mouse a bit more (which didn't), and unplugged the device. > > > > > > Trace attached. > > > > Well, the trace shows the mouse being plugged in and enumerated. Then > > it shows the pointer being moved for about half a second, and a couple > > of keys typed. 2.7 seconds later, it shows the device died and the > > port was disconnected -- I assume that's when you unplugged the mouse. > > > > During that 2.7-second interval, the usbmon trace shows nothing at all. > > No activity from the mouse (although it appears to have been > > communicating okay because the computer polled it at 8-ms intervals and > > didn't get any errors). And in particular, no suspends. > > I moved the mouse again during that interval, but the cursor did not > respond. Of course not, since the computer did not receive any messages from the mouse. The usbmon trace shows that no messages were sent at all. > > It looks like there's something funny going on between the dock and the > > mouse. For instance, maybe the dock doesn't provide quite enough > > power. > > This is just a keyboard/mouse; it doesn't draw significant power from > the port, and doesn't require a powered port. > > > Or maybe the dock's internal hub doesn't work quite right. > > > It's also possible that something strange happened in the xHCI host > > controller, but that seems less likely. You could test it by > > removing the dock and then connecting the mouse to the computer by way > > of a USB-2.0 hub. > > If it makes any difference, the dock has both USB 2 and USB 3 ports; I > observe the same behavior in both. Yes, but do you observe the same behavior if you use a USB-2 hub made by a
Re: Infrastructure for zerocopy I/O
On Tue, 8 Dec 2015, Steinar H. Gunderson wrote: > Do you know what the status is for the LPM blacklisting patch we discussed > earlier? Last I heard, Baolu Lu was working on a more general solution. In its absence, maybe I should go ahead and submit the patch. 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] usb: gadget: f_tcm: ignore return value of queue_work
Hi Andrzej, [auto build test WARNING on next-20151209] [cannot apply to balbi-usb/next usb/usb-testing v4.4-rc4 v4.4-rc3 v4.4-rc2 v4.4-rc4] url: https://github.com/0day-ci/linux/commits/Andrzej-Pietrasiewicz/usb-gadget-f_tcm-ignore-return-value-of-queue_work/20151209-225509 config: i386-allmodconfig (attached as .config) reproduce: # save the attached .config to linux build tree make ARCH=i386 All warnings (new ones prefixed by >>): drivers/usb/gadget/function/f_tcm.c: In function 'usbg_submit_command': >> drivers/usb/gadget/function/f_tcm.c:1084:6: warning: unused variable 'ret' >> [-Wunused-variable] int ret; ^ drivers/usb/gadget/function/f_tcm.c: In function 'bot_submit_command': drivers/usb/gadget/function/f_tcm.c:1197:6: warning: unused variable 'ret' [-Wunused-variable] int ret; ^ vim +/ret +1084 drivers/usb/gadget/function/f_tcm.c b4b91143 Andrzej Pietrasiewicz 2015-10-27 1068 return; b4b91143 Andrzej Pietrasiewicz 2015-10-27 1069 b4b91143 Andrzej Pietrasiewicz 2015-10-27 1070 out: b4b91143 Andrzej Pietrasiewicz 2015-10-27 1071 transport_send_check_condition_and_sense(se_cmd, b4b91143 Andrzej Pietrasiewicz 2015-10-27 1072 TCM_UNSUPPORTED_SCSI_OPCODE, 1); b4b91143 Andrzej Pietrasiewicz 2015-10-27 1073 usbg_cleanup_cmd(cmd); b4b91143 Andrzej Pietrasiewicz 2015-10-27 1074 } b4b91143 Andrzej Pietrasiewicz 2015-10-27 1075 b4b91143 Andrzej Pietrasiewicz 2015-10-27 1076 static int usbg_submit_command(struct f_uas *fu, b4b91143 Andrzej Pietrasiewicz 2015-10-27 1077 void *cmdbuf, unsigned int len) b4b91143 Andrzej Pietrasiewicz 2015-10-27 1078 { b4b91143 Andrzej Pietrasiewicz 2015-10-27 1079 struct command_iu *cmd_iu = cmdbuf; b4b91143 Andrzej Pietrasiewicz 2015-10-27 1080 struct usbg_cmd *cmd; b4b91143 Andrzej Pietrasiewicz 2015-10-27 1081 struct usbg_tpg *tpg; b4b91143 Andrzej Pietrasiewicz 2015-10-27 1082 struct tcm_usbg_nexus *tv_nexus; b4b91143 Andrzej Pietrasiewicz 2015-10-27 1083 u32 cmd_len; b4b91143 Andrzej Pietrasiewicz 2015-10-27 @1084 int ret; b4b91143 Andrzej Pietrasiewicz 2015-10-27 1085 b4b91143 Andrzej Pietrasiewicz 2015-10-27 1086 if (cmd_iu->iu_id != IU_ID_COMMAND) { b4b91143 Andrzej Pietrasiewicz 2015-10-27 1087 pr_err("Unsupported type %d\n", cmd_iu->iu_id); b4b91143 Andrzej Pietrasiewicz 2015-10-27 1088 return -EINVAL; b4b91143 Andrzej Pietrasiewicz 2015-10-27 1089 } b4b91143 Andrzej Pietrasiewicz 2015-10-27 1090 b4b91143 Andrzej Pietrasiewicz 2015-10-27 1091 cmd = kzalloc(sizeof(*cmd), GFP_ATOMIC); b4b91143 Andrzej Pietrasiewicz 2015-10-27 1092 if (!cmd) :: The code at line 1084 was first introduced by commit :: b4b91143ec451471ab9bbb9966afc82ce92f65e8 usb: gadget: tcm: factor out f_tcm :: TO: Andrzej Pietrasiewicz <andrze...@samsung.com> :: CC: Nicholas Bellinger <n...@linux-iscsi.org> --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: Binary data
[PATCH 1/9] usb: define USB_SPEED_SUPER_PLUS speed for SuperSpeedPlus USB3.1 devices
Add a new USB_SPEED_SUPER_PLUS device speed, and make sure usb core can handle the new speed. In most cases the behaviour is the same as with USB_SPEED_SUPER SuperSpeed devices. In a few places we add a "Plus" string to inform the user of the new speed. Signed-off-by: Mathias Nyman--- drivers/usb/common/common.c | 1 + drivers/usb/core/config.c| 3 ++- drivers/usb/core/devices.c | 10 ++ drivers/usb/core/hcd-pci.c | 2 +- drivers/usb/core/hcd.c | 6 +++--- drivers/usb/core/hub.c | 26 +++--- drivers/usb/core/urb.c | 3 ++- drivers/usb/core/usb.h | 2 +- include/uapi/linux/usb/ch9.h | 1 + 9 files changed, 32 insertions(+), 22 deletions(-) diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c index 673d530..a00bfb9 100644 --- a/drivers/usb/common/common.c +++ b/drivers/usb/common/common.c @@ -50,6 +50,7 @@ static const char *const speed_names[] = { [USB_SPEED_HIGH] = "high-speed", [USB_SPEED_WIRELESS] = "wireless", [USB_SPEED_SUPER] = "super-speed", + [USB_SPEED_SUPER_PLUS] = "super-speed-plus", }; const char *usb_speed_string(enum usb_device_speed speed) diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c index 7caff02..8aca169 100644 --- a/drivers/usb/core/config.c +++ b/drivers/usb/core/config.c @@ -190,6 +190,7 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum, if (usb_endpoint_xfer_int(d)) { i = 1; switch (to_usb_device(ddev)->speed) { + case USB_SPEED_SUPER_PLUS: case USB_SPEED_SUPER: case USB_SPEED_HIGH: /* Many device manufacturers are using full-speed @@ -273,7 +274,7 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum, } /* Parse a possible SuperSpeed endpoint companion descriptor */ - if (to_usb_device(ddev)->speed == USB_SPEED_SUPER) + if (to_usb_device(ddev)->speed >= USB_SPEED_SUPER) usb_parse_ss_endpoint_companion(ddev, cfgno, inum, asnum, endpoint, buffer, size); diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c index 2a3bbdf..332ed27 100644 --- a/drivers/usb/core/devices.c +++ b/drivers/usb/core/devices.c @@ -221,7 +221,7 @@ static char *usb_dump_endpoint_descriptor(int speed, char *start, char *end, break; case USB_ENDPOINT_XFER_INT: type = "Int."; - if (speed == USB_SPEED_HIGH || speed == USB_SPEED_SUPER) + if (speed == USB_SPEED_HIGH || speed >= USB_SPEED_SUPER) interval = 1 << (desc->bInterval - 1); else interval = desc->bInterval; @@ -230,7 +230,7 @@ static char *usb_dump_endpoint_descriptor(int speed, char *start, char *end, return start; } interval *= (speed == USB_SPEED_HIGH || -speed == USB_SPEED_SUPER) ? 125 : 1000; +speed >= USB_SPEED_SUPER) ? 125 : 1000; if (interval % 1000) unit = 'u'; else { @@ -322,7 +322,7 @@ static char *usb_dump_config_descriptor(char *start, char *end, if (start > end) return start; - if (speed == USB_SPEED_SUPER) + if (speed >= USB_SPEED_SUPER) mul = 8; else mul = 2; @@ -534,6 +534,8 @@ static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes, speed = "480"; break; case USB_SPEED_SUPER: speed = "5000"; break; + case USB_SPEED_SUPER_PLUS: + speed = "1"; break; default: speed = "??"; } @@ -553,7 +555,7 @@ static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes, /* super/high speed reserves 80%, full/low reserves 90% */ if (usbdev->speed == USB_SPEED_HIGH || - usbdev->speed == USB_SPEED_SUPER) + usbdev->speed >= USB_SPEED_SUPER) max = 800; else max = FRAME_TIME_MAX_USECS_ALLOC; diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c index 9eb1cff..22a9ac2 100644 --- a/drivers/usb/core/hcd-pci.c +++ b/drivers/usb/core/hcd-pci.c @@ -197,7 +197,7 @@ int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) * The xHCI driver has its own irq management * make sure irq setup is not touched for xhci in generic hcd code */ - if ((driver->flags & HCD_MASK) != HCD_USB3) { + if ((driver->flags & HCD_MASK) < HCD_USB3) { if (!dev->irq) { dev_err(>dev, "Found HC with no IRQ. Check BIOS/PCI %s setup!\n", diff --git a/drivers/usb/core/hcd.c
[PATCH 6/9] xhci: Make sure xhci handles USB_SPEED_SUPER_PLUS devices.
In most cases the devices with the speed set to USB_SPEED_SUPER_PLUS are handled like regular SuperSpeed devices. Signed-off-by: Mathias Nyman--- drivers/usb/host/xhci-mem.c | 11 --- drivers/usb/host/xhci-ring.c | 3 ++- drivers/usb/host/xhci.c | 7 +-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 5cd080e..1c37988 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -1070,7 +1070,7 @@ static u32 xhci_find_real_port_number(struct xhci_hcd *xhci, struct usb_device *top_dev; struct usb_hcd *hcd; - if (udev->speed == USB_SPEED_SUPER) + if (udev->speed >= USB_SPEED_SUPER) hcd = xhci->shared_hcd; else hcd = xhci->main_hcd; @@ -1105,6 +1105,7 @@ int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *ud /* 3) Only the control endpoint is valid - one endpoint context */ slot_ctx->dev_info |= cpu_to_le32(LAST_CTX(1) | udev->route); switch (udev->speed) { + case USB_SPEED_SUPER_PLUS: case USB_SPEED_SUPER: slot_ctx->dev_info |= cpu_to_le32(SLOT_SPEED_SS); max_packets = MAX_PACKET(512); @@ -1292,6 +1293,7 @@ static unsigned int xhci_get_endpoint_interval(struct usb_device *udev, } /* Fall through - SS and HS isoc/int have same decoding */ + case USB_SPEED_SUPER_PLUS: case USB_SPEED_SUPER: if (usb_endpoint_xfer_int(>desc) || usb_endpoint_xfer_isoc(>desc)) { @@ -1332,7 +1334,7 @@ static unsigned int xhci_get_endpoint_interval(struct usb_device *udev, static u32 xhci_get_endpoint_mult(struct usb_device *udev, struct usb_host_endpoint *ep) { - if (udev->speed != USB_SPEED_SUPER || + if (udev->speed < USB_SPEED_SUPER || !usb_endpoint_xfer_isoc(>desc)) return 0; return ep->ss_ep_comp.bmAttributes; @@ -1382,9 +1384,11 @@ static u32 xhci_get_max_esit_payload(struct usb_device *udev, usb_endpoint_xfer_bulk(>desc)) return 0; - if (udev->speed == USB_SPEED_SUPER) + if (udev->speed >= USB_SPEED_SUPER) + /* MATTU, requires attention in the SSP case */ return le16_to_cpu(ep->ss_ep_comp.wBytesPerInterval); + max_packet = GET_MAX_PACKET(usb_endpoint_maxp(>desc)); max_burst = (usb_endpoint_maxp(>desc) & 0x1800) >> 11; /* A 0 in max burst means 1 transfer per ESIT */ @@ -1453,6 +1457,7 @@ int xhci_endpoint_init(struct xhci_hcd *xhci, max_packet = GET_MAX_PACKET(usb_endpoint_maxp(>desc)); max_burst = 0; switch (udev->speed) { + case USB_SPEED_SUPER_PLUS: case USB_SPEED_SUPER: /* dig out max burst from ep companion desc */ max_burst = ep->ss_ep_comp.bMaxBurst; diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 8fab758..c156fdd 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -3572,7 +3572,7 @@ static unsigned int xhci_get_burst_count(struct xhci_hcd *xhci, { unsigned int max_burst; - if (xhci->hci_version < 0x100 || udev->speed != USB_SPEED_SUPER) + if (xhci->hci_version < 0x100 || udev->speed < USB_SPEED_SUPER) return 0; max_burst = urb->ep->ss_ep_comp.bMaxBurst; @@ -3598,6 +3598,7 @@ static unsigned int xhci_get_last_burst_packet_count(struct xhci_hcd *xhci, return 0; switch (udev->speed) { + case USB_SPEED_SUPER_PLUS: case USB_SPEED_SUPER: /* bMaxBurst is zero based: 0 means 1 packet per burst */ max_burst = urb->ep->ss_ep_comp.bMaxBurst; diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 643d312..dd87be2 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -2084,6 +2084,7 @@ static unsigned int xhci_get_block_size(struct usb_device *udev) case USB_SPEED_HIGH: return HS_BLOCK; case USB_SPEED_SUPER: + case USB_SPEED_SUPER_PLUS: return SS_BLOCK; case USB_SPEED_UNKNOWN: case USB_SPEED_WIRELESS: @@ -2209,7 +2210,7 @@ static int xhci_check_bw_table(struct xhci_hcd *xhci, unsigned int packets_remaining = 0; unsigned int i; - if (virt_dev->udev->speed == USB_SPEED_SUPER) + if (virt_dev->udev->speed >= USB_SPEED_SUPER) return xhci_check_ss_bw(xhci, virt_dev); if (virt_dev->udev->speed == USB_SPEED_HIGH) { @@ -2410,7 +2411,7 @@ void xhci_drop_ep_from_interval_table(struct xhci_hcd *xhci, if (xhci_is_async_ep(ep_bw->type)) return; - if (udev->speed == USB_SPEED_SUPER) { + if (udev->speed >= USB_SPEED_SUPER) {
[PATCH 7/9] xhci: set roothub speed to USB_SPEED_SUPER_PLUS for USB3.1 capable controllers
Signed-off-by: Mathias Nyman--- drivers/usb/host/xhci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index dd87be2..1044241 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -4890,6 +4890,7 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) if (xhci->sbrn == 0x31) { xhci_info(xhci, "Host supports USB 3.1 Enhanced SuperSpeed\n"); hcd->speed = HCD_USB31; + hcd->self.root_hub->speed = USB_SPEED_SUPER_PLUS; } /* xHCI private pointer was set in xhci_pci_probe for the second * registered roothub. -- 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 9/9] xhci: set slot context speed field to SuperSpeedPlus for USB 3.1 SSP devices
The speed field of the input slot context should represent the speed the device is working at. Signed-off-by: Mathias Nyman--- drivers/usb/host/xhci-mem.c | 3 +++ drivers/usb/host/xhci.h | 1 + 2 files changed, 4 insertions(+) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 1c37988..5cdb25a 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -1106,6 +1106,9 @@ int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *ud slot_ctx->dev_info |= cpu_to_le32(LAST_CTX(1) | udev->route); switch (udev->speed) { case USB_SPEED_SUPER_PLUS: + slot_ctx->dev_info |= cpu_to_le32(SLOT_SPEED_SSP); + max_packets = MAX_PACKET(512); + break; case USB_SPEED_SUPER: slot_ctx->dev_info |= cpu_to_le32(SLOT_SPEED_SS); max_packets = MAX_PACKET(512); diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 9be7348..9f28bea 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -343,6 +343,7 @@ struct xhci_op_regs { #defineSLOT_SPEED_LS (XDEV_LS << 10) #defineSLOT_SPEED_HS (XDEV_HS << 10) #defineSLOT_SPEED_SS (XDEV_SS << 10) +#defineSLOT_SPEED_SSP (XDEV_SSP << 10) /* Port Indicator Control */ #define PORT_LED_OFF (0 << 14) #define PORT_LED_AMBER (1 << 14) -- 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 3/9] usb: show speed "10000" in sysfs for USB 3.1 SuperSpeedPlus devices
The same way as SuperSpeed devices show "5000" as device speed we wan't to show "1" as the default speed for SuperSpeedPlus devices in sysfs. Signed-off-by: Mathias Nyman--- drivers/usb/core/sysfs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c index 65b6e6b..f195320 100644 --- a/drivers/usb/core/sysfs.c +++ b/drivers/usb/core/sysfs.c @@ -141,6 +141,9 @@ static ssize_t speed_show(struct device *dev, struct device_attribute *attr, case USB_SPEED_SUPER: speed = "5000"; break; + case USB_SPEED_SUPER_PLUS: + speed = "1"; + break; default: speed = "unknown"; } -- 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 8/9] xhci: USB 3.1 add default Speed Attributes to SuperSpeedPlus device capability
If a xhci controller does not provide a protocol speed ID (PSI) table, a default one should be used instead. Add the default values to the SuperSpeedPlus device capability. Overwrite the default ones if a PSI table exists. See xHCI 1.1 sectio 7.2.2.1.1 for more info Signed-off-by: Mathias Nyman--- drivers/usb/host/xhci-hub.c | 27 ++- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index 0863d8a..2c26ab50 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c @@ -50,14 +50,18 @@ static u8 usb_bos_descriptor [] = { 0x00, /* bU1DevExitLat, set later. */ 0x00, 0x00, /* __le16 bU2DevExitLat, set later. */ /* Second device capability, SuperSpeedPlus */ - 0x0c, /* bLength 12, will be adjusted later */ + 0x1c, /* bLength 28, will be adjusted later */ USB_DT_DEVICE_CAPABILITY, /* Device Capability */ USB_SSP_CAP_TYPE, /* bDevCapabilityType SUPERSPEED_PLUS */ 0x00, /* bReserved 0 */ - 0x00, 0x00, 0x00, 0x00, /* bmAttributes, get from xhci psic */ - 0x00, 0x00, /* wFunctionalitySupport */ + 0x23, 0x00, 0x00, 0x00, /* bmAttributes, SSAC=3 SSIC=1 */ + 0x01, 0x00, /* wFunctionalitySupport */ 0x00, 0x00, /* wReserved 0 */ - /* Sublink Speed Attributes are added in xhci_create_usb3_bos_desc() */ + /* Default Sublink Speed Attributes, overwrite if custom PSI exists */ + 0x34, 0x00, 0x05, 0x00, /* 5Gbps, symmetric, rx, ID = 4 */ + 0xb4, 0x00, 0x05, 0x00, /* 5Gbps, symmetric, tx, ID = 4 */ + 0x35, 0x40, 0x0a, 0x00, /* 10Gbps, SSP, symmetric, rx, ID = 5 */ + 0xb5, 0x40, 0x0a, 0x00, /* 10Gbps, SSP, symmetric, tx, ID = 5 */ }; static int xhci_create_usb3_bos_desc(struct xhci_hcd *xhci, char *buf, @@ -72,10 +76,14 @@ static int xhci_create_usb3_bos_desc(struct xhci_hcd *xhci, char *buf, ssp_cap_size = sizeof(usb_bos_descriptor) - desc_size; /* does xhci support USB 3.1 Enhanced SuperSpeed */ - if (xhci->usb3_rhub.min_rev >= 0x01 && xhci->usb3_rhub.psi_uid_count) { - /* two SSA entries for each unique PSI ID, one RX and one TX */ - ssa_count = xhci->usb3_rhub.psi_uid_count * 2; - ssa_size = ssa_count * sizeof(u32); + if (xhci->usb3_rhub.min_rev >= 0x01) { + /* does xhci provide a PSI table for SSA speed attributes? */ + if (xhci->usb3_rhub.psi_count) { + /* two SSA entries for each unique PSI ID, RX and TX */ + ssa_count = xhci->usb3_rhub.psi_uid_count * 2; + ssa_size = ssa_count * sizeof(u32); + ssp_cap_size -= 16; /* skip copying the default SSA */ + } desc_size += ssp_cap_size; usb3_1 = true; } @@ -102,7 +110,8 @@ static int xhci_create_usb3_bos_desc(struct xhci_hcd *xhci, char *buf, put_unaligned_le16(HCS_U2_LATENCY(temp), [13]); } - if (usb3_1) { + /* If PSI table exists, add the custom speed attributes from it */ + if (usb3_1 && xhci->usb3_rhub.psi_count) { u32 ssp_cap_base, bm_attrib, psi; int offset; -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [GIT PULL] USB fixes for v4.4-rc5
On Wed, Dec 09, 2015 at 09:58:41AM -0600, Felipe Balbi wrote: > Hi Greg, > > Here's what I hope to be the last set of fixes for current -rc. Let me > know if you want anything to be changed. > > cheers > > The following changes since commit f74875dc36135ebae82a8e005f4b7f52289d2c40: > > usb: dwc2: fix kernel oops during driver probe (2015-11-20 09:29:47 -0600) > > are available in the git repository at: > > git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git > tags/fixes-for-v4.4-rc5 Pulled and pushed out, 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
USB to serial(ttyUSB) port crash in debian. task khubd:369 blocked for more than 120 seconds
We are using sierra modem for 4G LTE networks. we used to communicate with modem using AT commands via ttyUSB ports. Recently we observed a crash in usb driver interface when we try to post some AT commands. After the crash the kernel seems to be hanged. We were not able to execute any commands or open a new tty terminal. Even reboot command was not working fine. The system went to completely unusable/unstable state. It recovered only after hard reboot. Nov 30 18:59:01 ATCMD = [AT+CMEE=2] Nov 30 18:59:02 [AT_TRX]Garbage cleared Nov 30 18:59:02 [AT_TRX]Data from Stream --> [OK] Nov 30 18:59:02 [AT_TRX]Poll Ended Nov 30 18:59:02 [AT_TRX]Result :[-1] Nov 30 18:59:02 [AT_TRX]Garbage cleared Nov 30 18:59:02 kernel: [19926.147811] usb 2-1.3: USB disconnect, device number 126 Nov 30 18:59:02 kernel: [19926.147985] sierra ttyUSB0: Sierra USB modem converter now disconnected from ttyUSB0 Nov 30 18:59:02 kernel: [19926.148002] sierra 2-1.3:1.0: device disconnected Nov 30 18:59:02 kernel: [19926.148127] sierra ttyUSB1: Sierra USB modem converter now disconnected from ttyUSB1 Nov 30 18:59:02 kernel: [19926.148138] sierra 2-1.3:1.1: device disconnected Nov 30 18:59:02 kernel: [19926.150070] sierra ttyUSB2: sierra_submit_rx_urbs: submit urb failed: -19 Nov 30 18:59:02 kernel: [19926.152626] sierra ttyUSB2: sierra_submit_rx_urbs: submit urb failed: -19 Nov 30 18:59:02 kernel: [19926.155136] sierra ttyUSB2: sierra_submit_rx_urbs: submit urb failed: -19 Nov 30 18:59:02 kernel: [19926.157589] sierra ttyUSB2: sierra_submit_rx_urbs: submit urb failed: -19 Nov 30 18:59:02 kernel: [19926.15] sierra ttyUSB2: sierra_submit_rx_urbs: submit urb failed: -19 Nov 30 18:59:02 kernel: [19926.162438] sierra ttyUSB2: sierra_submit_rx_urbs: submit urb failed: -19 Nov 30 18:59:02 kernel: [19926.164870] sierra ttyUSB2: sierra_submit_rx_urbs: submit urb failed: -19 Nov 30 19:01:12 kernel: [20056.174514] INFO: task khubd:369 blocked for more than 120 seconds. Nov 30 19:01:12 kernel: [20056.176931] Tainted: G O 3.12.0.custom-1.3 #2 Nov 30 19:01:12 kernel: [20056.179297] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. Nov 30 19:01:12 kernel: [20056.181648] khubd D 880409a3f3c8 0 369 2 0x Nov 30 19:01:12 kernel: [20056.181653] 880409a3f0c0 0046 88040b573780 Nov 30 19:01:12 kernel: [20056.181655] 880032f1ffd8 880032f1ffd8 880032f1ffd8 880409a3f0c0 Nov 30 19:01:12 kernel: [20056.181657] 8000 88035aafc9e8 88035aafc9ec 880409a3f0c0 Nov 30 19:01:12 kernel: [20056.181660] Call Trace: Nov 30 19:01:12 kernel: [20056.181667] [] ? schedule_preempt_disabled+0x9/0x10 Nov 30 19:01:12 kernel: [20056.181670] [] ? __mutex_lock_slowpath+0x141/0x1c0 Nov 30 19:01:12 kernel: [20056.181673] [] ? mutex_lock+0x16/0x30 Nov 30 19:01:12 kernel: [20056.181685] [] ? usb_serial_disconnect+0x2e/0x120 [usbserial] Nov 30 19:01:12 kernel: [20056.181699] [] ? usb_unbind_interface+0x6a/0x1c0 [usbcore] Nov 30 19:01:12 kernel: [20056.181705] [] ? __device_release_driver+0x79/0xf0 Nov 30 19:01:12 kernel: [20056.181707] [] ? bus_get_device_klist+0x10/0x10 Nov 30 19:01:12 kernel: [20056.181709] [] ? device_release_driver+0x25/0x40 Nov 30 19:01:12 kernel: [20056.181712] [] ? bus_remove_device+0xf2/0x140 Nov 30 19:01:12 kernel: [20056.181714] [] ? device_del+0x115/0x1a0 Nov 30 19:01:12 kernel: [20056.181722] [] ? usb_disable_device+0x94/0x1d0 [usbcore] Nov 30 19:01:12 kernel: [20056.181728] [] ? usb_disconnect+0x8e/0x190 [usbcore] Nov 30 19:01:12 kernel: [20056.181734] [] ? hub_thread+0x422/0x1380 [usbcore] Nov 30 19:01:12 kernel: [20056.181738] [] ? __schedule+0x2de/0x770 Nov 30 19:01:12 kernel: [20056.181740] [] ? finish_wait+0x90/0x90 Nov 30 19:01:12 kernel: [20056.181747] [] ? hub_port_debounce+0xe0/0xe0 [usbcore] Nov 30 19:01:12 kernel: [20056.181750] [] ? kthread+0xb3/0xc0 Nov 30 19:01:12 kernel: [20056.181753] [] ? hrtimer_get_remaining+0x20/0x50 Nov 30 19:01:12 kernel: [20056.181756] [] ? kthread_create_on_node+0x110/0x110 Nov 30 19:01:12 kernel: [20056.181758] [] ? ret_from_fork+0x7c/0xb0 Nov 30 19:01:12 kernel: [20056.181761] [] ? kthread_create_on_node+0x110/0x110 Regards, Saravanan N -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/9] usb core and xhci USB 3.1 features for usb-next
Hi Greg This patchseries continues on the USB 3.1 support. It adds a new USB_SUPER_SPEED_PLUS speed, adds and takes into use a new extended get_port_status hub request introduced in USB 3.1. The most visible change to users is the speed "1" shown by lsusb -t, and the occasional "SuperSpeedPlus" string visible when a new USB 3.1 SSP device is detected. Mathias Nyman (9): usb: define USB_SPEED_SUPER_PLUS speed for SuperSpeedPlus USB3.1 devices usb: set USB 3.1 roothub device speed to USB_SPEED_SUPER_PLUS usb: show speed "1" in sysfs for USB 3.1 SuperSpeedPlus devices usb: add device descriptor for usb 3.1 root hub usb: Support USB 3.1 extended port status request xhci: Make sure xhci handles USB_SPEED_SUPER_PLUS devices. xhci: set roothub speed to USB_SPEED_SUPER_PLUS for USB3.1 capable controllers xhci: USB 3.1 add default Speed Attributes to SuperSpeedPlus device capability xhci: set slot context speed field to SuperSpeedPlus for USB 3.1 SSP devices drivers/usb/common/common.c | 1 + drivers/usb/core/config.c | 3 +- drivers/usb/core/devices.c| 10 +++-- drivers/usb/core/hcd-pci.c| 2 +- drivers/usb/core/hcd.c| 41 +++--- drivers/usb/core/hub.c| 96 ++- drivers/usb/core/hub.h| 7 drivers/usb/core/sysfs.c | 3 ++ drivers/usb/core/urb.c| 3 +- drivers/usb/core/usb.h| 2 +- drivers/usb/host/xhci-hub.c | 27 drivers/usb/host/xhci-mem.c | 14 +-- drivers/usb/host/xhci-ring.c | 3 +- drivers/usb/host/xhci.c | 8 +++- drivers/usb/host/xhci.h | 1 + include/uapi/linux/usb/ch11.h | 21 ++ include/uapi/linux/usb/ch9.h | 1 + 17 files changed, 195 insertions(+), 48 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 4/9] usb: add device descriptor for usb 3.1 root hub
Signed-off-by: Mathias Nyman--- drivers/usb/core/hcd.c | 23 +++ 1 file changed, 23 insertions(+) diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index ff3073d..fb0a9c2 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -128,6 +128,27 @@ static inline int is_root_hub(struct usb_device *udev) #define KERNEL_REL bin2bcd(((LINUX_VERSION_CODE >> 16) & 0x0ff)) #define KERNEL_VER bin2bcd(((LINUX_VERSION_CODE >> 8) & 0x0ff)) +/* usb 3.1 root hub device descriptor */ +static const u8 usb31_rh_dev_descriptor[18] = { + 0x12, /* __u8 bLength; */ + 0x01, /* __u8 bDescriptorType; Device */ + 0x10, 0x03, /* __le16 bcdUSB; v3.1 */ + + 0x09, /* __u8 bDeviceClass; HUB_CLASSCODE */ + 0x00, /* __u8 bDeviceSubClass; */ + 0x03, /* __u8 bDeviceProtocol; USB 3 hub */ + 0x09, /* __u8 bMaxPacketSize0; 2^9 = 512 Bytes */ + + 0x6b, 0x1d, /* __le16 idVendor; Linux Foundation 0x1d6b */ + 0x03, 0x00, /* __le16 idProduct; device 0x0003 */ + KERNEL_VER, KERNEL_REL, /* __le16 bcdDevice */ + + 0x03, /* __u8 iManufacturer; */ + 0x02, /* __u8 iProduct; */ + 0x01, /* __u8 iSerialNumber; */ + 0x01/* __u8 bNumConfigurations; */ +}; + /* usb 3.0 root hub device descriptor */ static const u8 usb3_rh_dev_descriptor[18] = { 0x12, /* __u8 bLength; */ @@ -557,6 +578,8 @@ static int rh_call_control (struct usb_hcd *hcd, struct urb *urb) case USB_DT_DEVICE << 8: switch (hcd->speed) { case HCD_USB31: + bufp = usb31_rh_dev_descriptor; + break; case HCD_USB3: bufp = usb3_rh_dev_descriptor; break; -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/9] usb: set USB 3.1 roothub device speed to USB_SPEED_SUPER_PLUS
A hcd roothub that supports HCD_USB31 is running at SuperSpeedPlus speed Signed-off-by: Mathias Nyman--- drivers/usb/core/hcd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 0e38ce6..ff3073d 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -2778,9 +2778,11 @@ int usb_add_hcd(struct usb_hcd *hcd, rhdev->speed = USB_SPEED_WIRELESS; break; case HCD_USB3: - case HCD_USB31: rhdev->speed = USB_SPEED_SUPER; break; + case HCD_USB31: + rhdev->speed = USB_SPEED_SUPER_PLUS; + break; default: retval = -EINVAL; goto err_set_rh_speed; -- 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 5/9] usb: Support USB 3.1 extended port status request
usb 3.1 extend the hub get-port-status request by adding different request types. the new request types return 4 additional bytes called extended port status, these bytes are returned after the regular portstatus and portchange values. The extended port status contains a speed ID for the currently used sublink speed. A table of supported Speed IDs with details about the link is provided by the hub in the device descriptor BOS SuperSpeedPlus device capability Sublink Speed Attributes. Support this new request. Ask for the extended port status after port reset if hub supports USB 3.1. If link is running at SuperSpeedPlus set the device speed to USB_SPEED_SUPER_PLUS Signed-off-by: Mathias Nyman--- drivers/usb/core/hcd.c| 8 - drivers/usb/core/hub.c| 70 +-- drivers/usb/core/hub.h| 7 + include/uapi/linux/usb/ch11.h | 21 + 4 files changed, 96 insertions(+), 10 deletions(-) diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index fb0a9c2..436dea1 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -668,9 +668,15 @@ nongeneric: /* non-generic request */ switch (typeReq) { case GetHubStatus: - case GetPortStatus: len = 4; break; + case GetPortStatus: + if (wValue == HUB_PORT_STATUS) + len = 4; + else + /* other port status types return 8 bytes */ + len = 8; + break; case GetHubDescriptor: len = sizeof (struct usb_hub_descriptor); break; diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 79c08a3..e3423f1 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -533,29 +533,34 @@ static int get_hub_status(struct usb_device *hdev, /* * USB 2.0 spec Section 11.24.2.7 + * USB 3.1 takes into use the wValue and wLength fields, spec Section 10.16.2.6 */ static int get_port_status(struct usb_device *hdev, int port1, - struct usb_port_status *data) + void *data, u16 value, u16 length) { int i, status = -ETIMEDOUT; for (i = 0; i < USB_STS_RETRIES && (status == -ETIMEDOUT || status == -EPIPE); i++) { status = usb_control_msg(hdev, usb_rcvctrlpipe(hdev, 0), - USB_REQ_GET_STATUS, USB_DIR_IN | USB_RT_PORT, 0, port1, - data, sizeof(*data), USB_STS_TIMEOUT); + USB_REQ_GET_STATUS, USB_DIR_IN | USB_RT_PORT, value, + port1, data, length, USB_STS_TIMEOUT); } return status; } -static int hub_port_status(struct usb_hub *hub, int port1, - u16 *status, u16 *change) +static int hub_ext_port_status(struct usb_hub *hub, int port1, int type, + u16 *status, u16 *change, u32 *ext_status) { int ret; + int len = 4; + + if (type != HUB_PORT_STATUS) + len = 8; mutex_lock(>status_mutex); - ret = get_port_status(hub->hdev, port1, >status->port); - if (ret < 4) { + ret = get_port_status(hub->hdev, port1, >status->port, type, len); + if (ret < len) { if (ret != -ENODEV) dev_err(hub->intfdev, "%s failed (err = %d)\n", __func__, ret); @@ -564,13 +569,22 @@ static int hub_port_status(struct usb_hub *hub, int port1, } else { *status = le16_to_cpu(hub->status->port.wPortStatus); *change = le16_to_cpu(hub->status->port.wPortChange); - + if (type != HUB_PORT_STATUS && ext_status) + *ext_status = le32_to_cpu( + hub->status->port.dwExtPortStatus); ret = 0; } mutex_unlock(>status_mutex); return ret; } +static int hub_port_status(struct usb_hub *hub, int port1, + u16 *status, u16 *change) +{ + return hub_ext_port_status(hub, port1, HUB_PORT_STATUS, + status, change, NULL); +} + static void kick_hub_wq(struct usb_hub *hub) { struct usb_interface *intf; @@ -2592,6 +2606,32 @@ out_authorized: return result; } +/* + * Return 1 if port speed is SuperSpeedPlus, 0 otherwise + * check it from the link protocol field of the current speed ID attribute. + * current speed ID is got from ext port status request. Sublink speed attribute + * table is returned with the hub BOS SSP device capability descriptor + */ +static int port_speed_is_ssp(struct usb_device *hdev, int speed_id) +{ + int ssa_count; + u32 ss_attr; + int i; +
Re: [PATCH 4/9] usb: add device descriptor for usb 3.1 root hub
Hello. On 12/09/2015 09:22 PM, Mathias Nyman wrote: Signed-off-by: Mathias Nyman--- drivers/usb/core/hcd.c | 23 +++ 1 file changed, 23 insertions(+) diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index ff3073d..fb0a9c2 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -128,6 +128,27 @@ static inline int is_root_hub(struct usb_device *udev) #define KERNEL_RELbin2bcd(((LINUX_VERSION_CODE >> 16) & 0x0ff)) #define KERNEL_VERbin2bcd(((LINUX_VERSION_CODE >> 8) & 0x0ff)) +/* usb 3.1 root hub device descriptor */ +static const u8 usb31_rh_dev_descriptor[18] = { + 0x12, /* __u8 bLength; */ + 0x01, /* __u8 bDescriptorType; Device */ Please use USB_DT_DEVICE here as is now done in all the other such places in this file. [...] 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: [PATCH 3/4] usb: host: ehci.h: remove duplicated return
On 12/09/2015 11:15 PM, Geyslan G. Bem wrote: This patch removes the return of the default switch case, since 'ehci_port_speed()' already has the same default return. Signed-off-by: Geyslan G. Bem--- drivers/usb/host/ehci.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index 0daed80..49b91b6 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -664,8 +664,8 @@ ehci_port_speed(struct ehci_hcd *ehci, unsigned int portsc) case 1: return USB_PORT_STAT_LOW_SPEED; case 2: + /* fall through to default function return */ We just don't need the above *case*. default: - return USB_PORT_STAT_HIGH_SPEED; And n ow we don't need *dafault* too. Case 1 only? If not low_speed, high_speed. So, I'll change it to a simple if branch. There's *case* 0 yet. } } return USB_PORT_STAT_HIGH_SPEED; 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: [PATCH 3/4] usb: host: ehci.h: remove duplicated return
Hi Geyslan, [auto build test ERROR on usb/usb-testing] [also build test ERROR on v4.4-rc4 next-20151209] url: https://github.com/0day-ci/linux/commits/Geyslan-G-Bem/usb-host-ehci-h-cleanup-header-file/20151210-040115 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing config: x86_64-randconfig-s0-12100345 (attached as .config) reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All errors (new ones prefixed by >>): In file included from drivers/usb/chipidea/host.c:29:0: drivers/usb/chipidea/../host/ehci.h: In function 'ehci_port_speed': >> drivers/usb/chipidea/../host/ehci.h:668:3: error: label at end of compound >> statement default: ^ vim +668 drivers/usb/chipidea/../host/ehci.h ^1da177e Linus Torvalds 2005-04-16 662 case 0: ^1da177e Linus Torvalds 2005-04-16 663 return 0; ^1da177e Linus Torvalds 2005-04-16 664 case 1: 288ead45 Alan Stern 2010-03-04 665 return USB_PORT_STAT_LOW_SPEED; ^1da177e Linus Torvalds 2005-04-16 666 case 2: 50691528 Geyslan G. Bem 2015-12-09 667 /* fall through to default function return */ ^1da177e Linus Torvalds 2005-04-16 @668 default: ^1da177e Linus Torvalds 2005-04-16 669 } ^1da177e Linus Torvalds 2005-04-16 670 } 288ead45 Alan Stern 2010-03-04 671 return USB_PORT_STAT_HIGH_SPEED; :: The code at line 668 was first introduced by commit :: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2 :: TO: Linus Torvalds <torva...@ppc970.osdl.org> :: CC: Linus Torvalds <torva...@ppc970.osdl.org> --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: Binary data
[PATCH 9/9] usb: host: ehci.h: move constant to right
This patch moves the constant 0x3ff to right and put spaces in the right shift. Caught by coccinelle: scripts/coccinelle/misc/compare_const_fl.cocci Signed-off-by: Geyslan G. Bem--- drivers/usb/host/ehci.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index 81e609a..de94555 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -555,7 +555,7 @@ struct ehci_sitd { __hc32 hw_results; /* EHCI table 3-11 */ #defineSITD_IOC(1 << 31) /* interrupt on completion */ #defineSITD_PAGE (1 << 30) /* buffer 0/1 */ -#defineSITD_LENGTH(x) (0x3ff & ((x)>>16)) +#defineSITD_LENGTH(x) (((x) >> 16) & 0x3ff) #defineSITD_STS_ACTIVE (1 << 7)/* HC may execute this */ #defineSITD_STS_ERR(1 << 6)/* error from TT */ #defineSITD_STS_DBE(1 << 5)/* data buffer error (in HC) */ -- 2.6.3 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 8/9] usb: host: ehci.h: move pointer operator to name side
The pointer operator must be sticked to name. Caught by cppcheck: ERROR: "foo * bar" should be "foo *bar" Signed-off-by: Geyslan G. Bem--- drivers/usb/host/ehci.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index 15de5bf..81e609a 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -732,7 +732,7 @@ ehci_port_speed(struct ehci_hcd *ehci, unsigned int portsc) #endif static inline unsigned int ehci_readl(const struct ehci_hcd *ehci, - __u32 __iomem * regs) + __u32 __iomem *regs) { #ifdef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO return ehci_big_endian_mmio(ehci) ? -- 2.6.3 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 7/9] usb: host: ehci.h: remove macros trailing semicolon
Removes trailing semicolon from macros. Caught by cppcheck: "WARNING: macros should not use a trailing semicolon" Signed-off-by: Geyslan G. Bem--- drivers/usb/host/ehci.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index ea56147..15de5bf 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -635,10 +635,10 @@ struct ehci_tt { /* Prepare the PORTSC wakeup flags during controller suspend/resume */ #define ehci_prepare_ports_for_controller_suspend(ehci, do_wakeup) \ - ehci_adjust_port_wakeup_flags(ehci, true, do_wakeup); + ehci_adjust_port_wakeup_flags(ehci, true, do_wakeup) #define ehci_prepare_ports_for_controller_resume(ehci) \ - ehci_adjust_port_wakeup_flags(ehci, false, false); + ehci_adjust_port_wakeup_flags(ehci, false, false) /*-*/ -- 2.6.3 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 4/9] usb: host: ehci.h: fix single statement macros
Don't use the 'do {} while (0)' wrapper in a single statement macro. Caught by cppcheck: "WARNING: Single statement macros should not use a do {} while (0) loop" Signed-off-by: Geyslan G. Bem--- drivers/usb/host/ehci.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index cfeebd8..945000a 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -244,9 +244,9 @@ struct ehci_hcd { /* one per controller */ /* irq statistics */ #ifdef EHCI_STATS struct ehci_stats stats; -# define COUNT(x) do { (x)++; } while (0) +# define COUNT(x) ((x)++) #else -# define COUNT(x) do {} while (0) +# define COUNT(x) ((void) 0) #endif /* debug files */ -- 2.6.3 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/4] usb: host: ehci.h: cleanup header file
On Wed, Dec 09, 2015 at 04:57:30PM -0300, Geyslan G. Bem wrote: > This patch silences > - A coccinelle warning 'scripts/coccinelle/misc/compare_const_fl.cocci' > - All the errors and many warnings shown by checkpatch "all" is a lot. Please break down each type of change to a separate patch. Then do a patch with the coccinelle warning fixes as well. That will make these patches a lot smaller and easier to review. 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 3/4] usb: host: ehci.h: remove duplicated return
2015-12-09 17:10 GMT-03:00 Sergei Shtylyov: > Hello. > > On 12/09/2015 10:57 PM, Geyslan G. Bem wrote: > >> This patch removes the return of the default switch case, since >> 'ehci_port_speed()' already has the same default return. >> >> Signed-off-by: Geyslan G. Bem >> --- >> drivers/usb/host/ehci.h | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h >> index 0daed80..49b91b6 100644 >> --- a/drivers/usb/host/ehci.h >> +++ b/drivers/usb/host/ehci.h >> @@ -664,8 +664,8 @@ ehci_port_speed(struct ehci_hcd *ehci, unsigned int >> portsc) >> case 1: >> return USB_PORT_STAT_LOW_SPEED; >> case 2: >> + /* fall through to default function return */ > > >We just don't need the above *case*. > >> default: >> - return USB_PORT_STAT_HIGH_SPEED; > > >And n ow we don't need *dafault* too. Case 1 only? If not low_speed, high_speed. So, I'll change it to a simple if branch. > >> } >> } >> return USB_PORT_STAT_HIGH_SPEED; > > > MBR, Sergei > -- Regards, Geyslan G. Bem hackingbits.com -- 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 3/4] usb: host: ehci.h: remove duplicated return
Hi Geyslan, [auto build test ERROR on usb/usb-testing] [also build test ERROR on v4.4-rc4 next-20151209] url: https://github.com/0day-ci/linux/commits/Geyslan-G-Bem/usb-host-ehci-h-cleanup-header-file/20151210-040115 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing config: x86_64-randconfig-s3-12100340 (attached as .config) reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All errors (new ones prefixed by >>): In file included from drivers/usb/host/ehci-hcd.c:109:0: drivers/usb/host/ehci.h: In function 'ehci_port_speed': >> drivers/usb/host/ehci.h:668:3: error: label at end of compound statement default: ^ vim +668 drivers/usb/host/ehci.h ^1da177e Linus Torvalds 2005-04-16 662 case 0: ^1da177e Linus Torvalds 2005-04-16 663 return 0; ^1da177e Linus Torvalds 2005-04-16 664 case 1: 288ead45 Alan Stern 2010-03-04 665 return USB_PORT_STAT_LOW_SPEED; ^1da177e Linus Torvalds 2005-04-16 666 case 2: 50691528 Geyslan G. Bem 2015-12-09 667 /* fall through to default function return */ ^1da177e Linus Torvalds 2005-04-16 @668 default: ^1da177e Linus Torvalds 2005-04-16 669 } ^1da177e Linus Torvalds 2005-04-16 670 } 288ead45 Alan Stern 2010-03-04 671 return USB_PORT_STAT_HIGH_SPEED; :: The code at line 668 was first introduced by commit :: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2 :: TO: Linus Torvalds <torva...@ppc970.osdl.org> :: CC: Linus Torvalds <torva...@ppc970.osdl.org> --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: Binary data
Re: [PATCH] Add support for usbfs zerocopy.
On Wed, Dec 09, 2015 at 10:39:35AM -0500, Alan Stern wrote: >> I can write documentation if you can point me to a reasonable place. > The only documentation I know of for usbfs is a dreadfully out-of-date > section in Documentation/DocBook/usb.tmpl. I don't volunteer to get your documentation in shape there. :-) I would guess most usbfs users go through libusb. I have a patch against libusb that I'll send after the kernel patch is merged (it's hard to argue for inclusion of something that is not in mainline), and it includes documentation for the newly added functions, including zerocopy caveats. /* Steinar */ -- Software Engineer, Google Switzerland -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 6/9] usb: host: ehci.h: use space after comma
Put space after comma. This patch also changes QH_NEXT macro for better reading. Caught by cppcheck: "ERROR: space required after that ','" Signed-off-by: Geyslan G. Bem--- drivers/usb/host/ehci.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index 7b2b213..ea56147 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -334,7 +334,7 @@ struct ehci_qtd { /*-*/ /* type tag from {qh,itd,sitd,fstn}->hw_next */ -#define Q_NEXT_TYPE(ehci,dma) ((dma) & cpu_to_hc32(ehci, 3 << 1)) +#define Q_NEXT_TYPE(ehci, dma) ((dma) & cpu_to_hc32(ehci, 3 << 1)) /* * Now the following defines are not converted using the @@ -350,7 +350,8 @@ struct ehci_qtd { #define Q_TYPE_FSTN(3 << 1) /* next async queue entry, or pointer to interrupt/periodic QH */ -#define QH_NEXT(ehci,dma) (cpu_to_hc32(ehci, (((u32)dma)&~0x01f)|Q_TYPE_QH)) +#define QH_NEXT(ehci, dma) \ + (cpu_to_hc32(ehci, (((u32) dma) & ~0x01f) | Q_TYPE_QH)) /* for periodic/async schedules and qtd lists, mark end of list */ #define EHCI_LIST_END(ehci)cpu_to_hc32(ehci, 1) /* "null pointer" to hw */ -- 2.6.3 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/4] usb: host: ehci.h: cleanup header file
2015-12-09 17:09 GMT-03:00 Greg Kroah-Hartman: > On Wed, Dec 09, 2015 at 04:57:30PM -0300, Geyslan G. Bem wrote: >> This patch silences >> - A coccinelle warning 'scripts/coccinelle/misc/compare_const_fl.cocci' >> - All the errors and many warnings shown by checkpatch > > "all" is a lot. Please break down each type of change to a separate > patch. Then do a patch with the coccinelle warning fixes as well. > That will make these patches a lot smaller and easier to review. Ok. Doing. > > thanks, > > greg k-h -- Regards, Geyslan G. Bem hackingbits.com -- 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 3/4] usb: host: ehci.h: remove duplicated return
2015-12-09 18:24 GMT-03:00 kbuild test robot <l...@intel.com>: > Hi Geyslan, > > [auto build test ERROR on usb/usb-testing] > [also build test ERROR on v4.4-rc4 next-20151209] > > url: > https://github.com/0day-ci/linux/commits/Geyslan-G-Bem/usb-host-ehci-h-cleanup-header-file/20151210-040115 > base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git > usb-testing > config: x86_64-randconfig-s0-12100345 (attached as .config) > reproduce: > # save the attached .config to linux build tree > make ARCH=x86_64 > > All errors (new ones prefixed by >>): > >In file included from drivers/usb/chipidea/host.c:29:0: >drivers/usb/chipidea/../host/ehci.h: In function 'ehci_port_speed': >>> drivers/usb/chipidea/../host/ehci.h:668:3: error: label at end of compound >>> statement > default: Missed the break. Coul be removed too. > ^ > > vim +668 drivers/usb/chipidea/../host/ehci.h > > ^1da177e Linus Torvalds 2005-04-16 662 case 0: > ^1da177e Linus Torvalds 2005-04-16 663 return 0; > ^1da177e Linus Torvalds 2005-04-16 664 case 1: > 288ead45 Alan Stern 2010-03-04 665 return > USB_PORT_STAT_LOW_SPEED; > ^1da177e Linus Torvalds 2005-04-16 666 case 2: > 50691528 Geyslan G. Bem 2015-12-09 667 /* fall through to > default function return */ > ^1da177e Linus Torvalds 2005-04-16 @668 default: > ^1da177e Linus Torvalds 2005-04-16 669 } > ^1da177e Linus Torvalds 2005-04-16 670 } > 288ead45 Alan Stern 2010-03-04 671 return > USB_PORT_STAT_HIGH_SPEED; > > :: The code at line 668 was first introduced by commit > :: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2 > > :: TO: Linus Torvalds <torva...@ppc970.osdl.org> > :: CC: Linus Torvalds <torva...@ppc970.osdl.org> > > --- > 0-DAY kernel test infrastructureOpen Source Technology Center > https://lists.01.org/pipermail/kbuild-all Intel Corporation > No, please leave it as-is, it helps to understand what is going on here > easier. Ok. Let it go. :) > thanks, > greg k-h -- Regards, Geyslan G. Bem hackingbits.com -- 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 3/9] usb: host: ehci.h: remove space before open square bracket
Get rid of space before open square bracket. Caught by cppcheck: "ERROR: space prohibited before open square bracket '['" Signed-off-by: Geyslan G. Bem--- drivers/usb/host/ehci.h | 20 ++-- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index 46982df..cfeebd8 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -185,7 +185,7 @@ struct ehci_hcd { /* one per controller */ struct ehci_sitd*last_sitd_to_free; /* per root hub port */ - unsigned long reset_done [EHCI_MAX_ROOT_PORTS]; + unsigned long reset_done[EHCI_MAX_ROOT_PORTS]; /* bit vectors (one bit per port) */ unsigned long bus_suspended; /* which ports were @@ -316,8 +316,8 @@ struct ehci_qtd { #define HALT_BIT(ehci) cpu_to_hc32(ehci, QTD_STS_HALT) #define STATUS_BIT(ehci) cpu_to_hc32(ehci, QTD_STS_STS) - __hc32 hw_buf [5];/* see EHCI 3.5.4 */ - __hc32 hw_buf_hi [5];/* Appendix B */ + __hc32 hw_buf[5];/* see EHCI 3.5.4 */ + __hc32 hw_buf_hi[5];/* Appendix B */ /* the rest is HCD-private */ dma_addr_t qtd_dma;/* qtd address */ @@ -405,8 +405,8 @@ struct ehci_qh_hw { __hc32 hw_qtd_next; __hc32 hw_alt_next; __hc32 hw_token; - __hc32 hw_buf [5]; - __hc32 hw_buf_hi [5]; + __hc32 hw_buf[5]; + __hc32 hw_buf_hi[5]; } __attribute__ ((aligned(32))); struct ehci_qh { @@ -510,7 +510,7 @@ struct ehci_iso_stream { struct ehci_itd { /* first part defined by EHCI spec */ __hc32 hw_next; /* see EHCI 3.3.1 */ - __hc32 hw_transaction [8]; /* see EHCI 3.3.2 */ + __hc32 hw_transaction[8]; /* see EHCI 3.3.2 */ #define EHCI_ISOC_ACTIVE(1<<31)/* activate transfer this slot */ #define EHCI_ISOC_BUF_ERR (1<<30)/* Data buffer error */ #define EHCI_ISOC_BABBLE(1<<29)/* babble detected */ @@ -520,8 +520,8 @@ struct ehci_itd { #define ITD_ACTIVE(ehci) cpu_to_hc32(ehci, EHCI_ISOC_ACTIVE) - __hc32 hw_bufp [7];/* see EHCI 3.3.3 */ - __hc32 hw_bufp_hi [7]; /* Appendix B */ + __hc32 hw_bufp[7]; /* see EHCI 3.3.3 */ + __hc32 hw_bufp_hi[7]; /* Appendix B */ /* the rest is HCD-private */ dma_addr_t itd_dma;/* for this itd */ @@ -565,9 +565,9 @@ struct ehci_sitd { #define SITD_ACTIVE(ehci) cpu_to_hc32(ehci, SITD_STS_ACTIVE) - __hc32 hw_buf [2]; /* EHCI table 3-12 */ + __hc32 hw_buf[2]; /* EHCI table 3-12 */ __hc32 hw_backpointer; /* EHCI table 3-13 */ - __hc32 hw_buf_hi [2]; /* Appendix B */ + __hc32 hw_buf_hi[2]; /* Appendix B */ /* the rest is HCD-private */ dma_addr_t sitd_dma; -- 2.6.3 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/9] usb: host: ehci.h: remove space before function open parenthesis
Get rid of space between function name and open parenthesis. Caught by cppcheck: "WARNING: space prohibited between function name and open parenthesis '('" Signed-off-by: Geyslan G. Bem--- drivers/usb/host/ehci.h | 22 +++--- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index 6a36ef4..46982df 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -268,13 +268,13 @@ struct ehci_hcd { /* one per controller */ }; /* convert between an HCD pointer and the corresponding EHCI_HCD */ -static inline struct ehci_hcd *hcd_to_ehci (struct usb_hcd *hcd) +static inline struct ehci_hcd *hcd_to_ehci(struct usb_hcd *hcd) { return (struct ehci_hcd *) (hcd->hcd_priv); } -static inline struct usb_hcd *ehci_to_hcd (struct ehci_hcd *ehci) +static inline struct usb_hcd *ehci_to_hcd(struct ehci_hcd *ehci) { - return container_of ((void *) ehci, struct usb_hcd, hcd_priv); + return container_of((void *) ehci, struct usb_hcd, hcd_priv); } /*-*/ @@ -327,9 +327,9 @@ struct ehci_qtd { } __attribute__ ((aligned (32))); /* mask NakCnt+T in qh->hw_alt_next */ -#define QTD_MASK(ehci) cpu_to_hc32 (ehci, ~0x1f) +#define QTD_MASK(ehci) cpu_to_hc32(ehci, ~0x1f) -#define IS_SHORT_READ(token) (QTD_LENGTH (token) != 0 && QTD_PID (token) == 1) +#define IS_SHORT_READ(token) (QTD_LENGTH(token) != 0 && QTD_PID(token) == 1) /*-*/ @@ -806,7 +806,7 @@ static inline void set_ohci_hcfs(struct ehci_hcd *ehci, int operational) #define ehci_big_endian_desc(e)((e)->big_endian_desc) /* cpu to ehci */ -static inline __hc32 cpu_to_hc32 (const struct ehci_hcd *ehci, const u32 x) +static inline __hc32 cpu_to_hc32(const struct ehci_hcd *ehci, const u32 x) { return ehci_big_endian_desc(ehci) ? (__force __hc32)cpu_to_be32(x) @@ -814,14 +814,14 @@ static inline __hc32 cpu_to_hc32 (const struct ehci_hcd *ehci, const u32 x) } /* ehci to cpu */ -static inline u32 hc32_to_cpu (const struct ehci_hcd *ehci, const __hc32 x) +static inline u32 hc32_to_cpu(const struct ehci_hcd *ehci, const __hc32 x) { return ehci_big_endian_desc(ehci) ? be32_to_cpu((__force __be32)x) : le32_to_cpu((__force __le32)x); } -static inline u32 hc32_to_cpup (const struct ehci_hcd *ehci, const __hc32 *x) +static inline u32 hc32_to_cpup(const struct ehci_hcd *ehci, const __hc32 *x) { return ehci_big_endian_desc(ehci) ? be32_to_cpup((__force __be32 *)x) @@ -831,18 +831,18 @@ static inline u32 hc32_to_cpup (const struct ehci_hcd *ehci, const __hc32 *x) #else /* cpu to ehci */ -static inline __hc32 cpu_to_hc32 (const struct ehci_hcd *ehci, const u32 x) +static inline __hc32 cpu_to_hc32(const struct ehci_hcd *ehci, const u32 x) { return cpu_to_le32(x); } /* ehci to cpu */ -static inline u32 hc32_to_cpu (const struct ehci_hcd *ehci, const __hc32 x) +static inline u32 hc32_to_cpu(const struct ehci_hcd *ehci, const __hc32 x) { return le32_to_cpu(x); } -static inline u32 hc32_to_cpup (const struct ehci_hcd *ehci, const __hc32 *x) +static inline u32 hc32_to_cpup(const struct ehci_hcd *ehci, const __hc32 *x) { return le32_to_cpup(x); } -- 2.6.3 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 5/9] usb: host: ehci.h: remove direct use of __attribute__ keyword
Prefer to use __aligned(size) macro instead of __attribute__((aligned(size))). Caught by cppcheck: "WARNING" Signed-off-by: Geyslan G. Bem--- drivers/usb/host/ehci.h | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index 945000a..7b2b213 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -324,7 +324,7 @@ struct ehci_qtd { struct list_headqtd_list; /* sw qtd list */ struct urb *urb; /* qtd's urb */ size_t length; /* length of buffer */ -} __attribute__ ((aligned (32))); +} __aligned(32); /* mask NakCnt+T in qh->hw_alt_next */ #define QTD_MASK(ehci) cpu_to_hc32(ehci, ~0x1f) @@ -407,7 +407,7 @@ struct ehci_qh_hw { __hc32 hw_token; __hc32 hw_buf[5]; __hc32 hw_buf_hi[5]; -} __attribute__ ((aligned(32))); +} __aligned(32); struct ehci_qh { struct ehci_qh_hw *hw;/* Must come first */ @@ -535,7 +535,7 @@ struct ehci_itd { unsignedframe; /* where scheduled */ unsignedpg; unsignedindex[8]; /* in urb->iso_frame_desc */ -} __attribute__ ((aligned (32))); +} __aligned(32); /*-*/ @@ -578,7 +578,7 @@ struct ehci_sitd { struct list_headsitd_list; /* list of stream's sitds */ unsignedframe; unsignedindex; -} __attribute__ ((aligned (32))); +} __aligned(32); /*-*/ @@ -598,7 +598,7 @@ struct ehci_fstn { /* the rest is HCD-private */ dma_addr_t fstn_dma; union ehci_shadow fstn_next; /* ptr to periodic q entry */ -} __attribute__ ((aligned (32))); +} __aligned(32); /*-*/ -- 2.6.3 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/9] usb: host: ehci.h: remove space before comma
Get rid of spaces before comma. Caught by cppcheck: "ERROR: space prohibited before that ','" Signed-off-by: Geyslan G. Bem--- drivers/usb/host/ehci.h | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index ec61aed..6a36ef4 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -852,13 +852,13 @@ static inline u32 hc32_to_cpup (const struct ehci_hcd *ehci, const __hc32 *x) /*-*/ #define ehci_dbg(ehci, fmt, args...) \ - dev_dbg(ehci_to_hcd(ehci)->self.controller , fmt , ## args) + dev_dbg(ehci_to_hcd(ehci)->self.controller, fmt, ## args) #define ehci_err(ehci, fmt, args...) \ - dev_err(ehci_to_hcd(ehci)->self.controller , fmt , ## args) + dev_err(ehci_to_hcd(ehci)->self.controller, fmt, ## args) #define ehci_info(ehci, fmt, args...) \ - dev_info(ehci_to_hcd(ehci)->self.controller , fmt , ## args) + dev_info(ehci_to_hcd(ehci)->self.controller, fmt, ## args) #define ehci_warn(ehci, fmt, args...) \ - dev_warn(ehci_to_hcd(ehci)->self.controller , fmt , ## args) + dev_warn(ehci_to_hcd(ehci)->self.controller, fmt, ## args) #ifndef CONFIG_DYNAMIC_DEBUG -- 2.6.3 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/4] usb: host: ehci.h: remove duplicated return
Hello. On 12/09/2015 10:57 PM, Geyslan G. Bem wrote: This patch removes the return of the default switch case, since 'ehci_port_speed()' already has the same default return. Signed-off-by: Geyslan G. Bem--- drivers/usb/host/ehci.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index 0daed80..49b91b6 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -664,8 +664,8 @@ ehci_port_speed(struct ehci_hcd *ehci, unsigned int portsc) case 1: return USB_PORT_STAT_LOW_SPEED; case 2: + /* fall through to default function return */ We just don't need the above *case*. default: - return USB_PORT_STAT_HIGH_SPEED; And n ow we don't need *dafault* too. } } return USB_PORT_STAT_HIGH_SPEED; 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: [PATCH 2/4] usb: host: ehci.h: cleanup header file
Hello. On 12/09/2015 10:57 PM, Geyslan G. Bem wrote: This patch does align function/macro definitions. Signed-off-by: Geyslan G. BemUSB code just uses different alignment style (2 tabs) than the other kernel parts (like networking). 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: USB to serial(ttyUSB) port crash in debian. task khubd:369 blocked for more than 120 seconds
Our device went for reset. So it starts loading and unloading the serial USB port. Here the serious concern is kernel lock. Once it happens the system is unusable and hard reboot is the only way of recovering it. Kernel version is 3.12.0 Regards, Saravanan N On Wed, Dec 9, 2015 at 2:21 PM, Greg KHwrote: > On Wed, Dec 09, 2015 at 12:36:12PM -0600, SaRaVanAn wrote: >> We are using sierra modem for 4G LTE networks. we used to communicate >> with modem using AT commands via ttyUSB ports. >> Recently we observed a crash in usb driver interface when we try to >> post some AT commands. After the crash the kernel seems to be hanged. >> We were not able to execute any commands or open a new tty terminal. >> Even reboot command was not working fine. >> The system went to completely unusable/unstable state. It recovered >> only after hard reboot. >> >> >> >> Nov 30 18:59:01 ATCMD = [AT+CMEE=2] >> Nov 30 18:59:02 [AT_TRX]Garbage cleared >> Nov 30 18:59:02 [AT_TRX]Data from Stream --> [OK] >> Nov 30 18:59:02 [AT_TRX]Poll Ended >> Nov 30 18:59:02 [AT_TRX]Result :[-1] >> >> Nov 30 18:59:02 [AT_TRX]Garbage cleared >> Nov 30 18:59:02 kernel: [19926.147811] usb 2-1.3: USB disconnect, >> device number 126 > > Your device disconnected itself from the system for some reason, you > might want to look into why that happens, could be an electrical issue. > >> Nov 30 18:59:02 kernel: [19926.147985] sierra ttyUSB0: Sierra USB >> modem converter now disconnected from ttyUSB0 >> Nov 30 18:59:02 kernel: [19926.148002] sierra 2-1.3:1.0: device disconnected >> Nov 30 18:59:02 kernel: [19926.148127] sierra ttyUSB1: Sierra USB >> modem converter now disconnected from ttyUSB1 >> Nov 30 18:59:02 kernel: [19926.148138] sierra 2-1.3:1.1: device disconnected >> Nov 30 18:59:02 kernel: [19926.150070] sierra ttyUSB2: >> sierra_submit_rx_urbs: submit urb failed: -19 >> Nov 30 18:59:02 kernel: [19926.152626] sierra ttyUSB2: >> sierra_submit_rx_urbs: submit urb failed: -19 >> Nov 30 18:59:02 kernel: [19926.155136] sierra ttyUSB2: >> sierra_submit_rx_urbs: submit urb failed: -19 >> Nov 30 18:59:02 kernel: [19926.157589] sierra ttyUSB2: >> sierra_submit_rx_urbs: submit urb failed: -19 >> Nov 30 18:59:02 kernel: [19926.15] sierra ttyUSB2: >> sierra_submit_rx_urbs: submit urb failed: -19 >> Nov 30 18:59:02 kernel: [19926.162438] sierra ttyUSB2: >> sierra_submit_rx_urbs: submit urb failed: -19 >> Nov 30 18:59:02 kernel: [19926.164870] sierra ttyUSB2: >> sierra_submit_rx_urbs: submit urb failed: -19 >> Nov 30 19:01:12 kernel: [20056.174514] INFO: task khubd:369 blocked >> for more than 120 seconds. > > Not good, what kernel version is this? > > thanks, > > greg k-h -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 5/9v2] usb: host: ehci.h: remove direct use of __attribute__ keyword
Prefer to use __aligned(size) macro instead of __attribute__((aligned(size))). Caught by checkpatch: "WARNING" Signed-off-by: Geyslan G. Bem--- drivers/usb/host/ehci.h | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index 945000a..7b2b213 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -324,7 +324,7 @@ struct ehci_qtd { struct list_headqtd_list; /* sw qtd list */ struct urb *urb; /* qtd's urb */ size_t length; /* length of buffer */ -} __attribute__ ((aligned (32))); +} __aligned(32); /* mask NakCnt+T in qh->hw_alt_next */ #define QTD_MASK(ehci) cpu_to_hc32(ehci, ~0x1f) @@ -407,7 +407,7 @@ struct ehci_qh_hw { __hc32 hw_token; __hc32 hw_buf[5]; __hc32 hw_buf_hi[5]; -} __attribute__ ((aligned(32))); +} __aligned(32); struct ehci_qh { struct ehci_qh_hw *hw;/* Must come first */ @@ -535,7 +535,7 @@ struct ehci_itd { unsignedframe; /* where scheduled */ unsignedpg; unsignedindex[8]; /* in urb->iso_frame_desc */ -} __attribute__ ((aligned (32))); +} __aligned(32); /*-*/ @@ -578,7 +578,7 @@ struct ehci_sitd { struct list_headsitd_list; /* list of stream's sitds */ unsignedframe; unsignedindex; -} __attribute__ ((aligned (32))); +} __aligned(32); /*-*/ @@ -598,7 +598,7 @@ struct ehci_fstn { /* the rest is HCD-private */ dma_addr_t fstn_dma; union ehci_shadow fstn_next; /* ptr to periodic q entry */ -} __attribute__ ((aligned (32))); +} __aligned(32); /*-*/ -- 2.6.3 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/9v2] usb: host: ehci.h: remove space before comma
Get rid of spaces before comma. Caught by checkpatch: "ERROR: space prohibited before that ','" Signed-off-by: Geyslan G. Bem--- drivers/usb/host/ehci.h | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index ec61aed..6a36ef4 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -852,13 +852,13 @@ static inline u32 hc32_to_cpup (const struct ehci_hcd *ehci, const __hc32 *x) /*-*/ #define ehci_dbg(ehci, fmt, args...) \ - dev_dbg(ehci_to_hcd(ehci)->self.controller , fmt , ## args) + dev_dbg(ehci_to_hcd(ehci)->self.controller, fmt, ## args) #define ehci_err(ehci, fmt, args...) \ - dev_err(ehci_to_hcd(ehci)->self.controller , fmt , ## args) + dev_err(ehci_to_hcd(ehci)->self.controller, fmt, ## args) #define ehci_info(ehci, fmt, args...) \ - dev_info(ehci_to_hcd(ehci)->self.controller , fmt , ## args) + dev_info(ehci_to_hcd(ehci)->self.controller, fmt, ## args) #define ehci_warn(ehci, fmt, args...) \ - dev_warn(ehci_to_hcd(ehci)->self.controller , fmt , ## args) + dev_warn(ehci_to_hcd(ehci)->self.controller, fmt, ## args) #ifndef CONFIG_DYNAMIC_DEBUG -- 2.6.3 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 4/9v2] usb: host: ehci.h: fix single statement macros
Don't use the 'do {} while (0)' wrapper in a single statement macro. Caught by checkpatch: "WARNING: Single statement macros should not use a do {} while (0) loop" Signed-off-by: Geyslan G. Bem--- drivers/usb/host/ehci.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index cfeebd8..945000a 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -244,9 +244,9 @@ struct ehci_hcd { /* one per controller */ /* irq statistics */ #ifdef EHCI_STATS struct ehci_stats stats; -# define COUNT(x) do { (x)++; } while (0) +# define COUNT(x) ((x)++) #else -# define COUNT(x) do {} while (0) +# define COUNT(x) ((void) 0) #endif /* debug files */ -- 2.6.3 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: USB to serial(ttyUSB) port crash in debian. task khubd:369 blocked for more than 120 seconds
On Wed, Dec 09, 2015 at 12:36:12PM -0600, SaRaVanAn wrote: > We are using sierra modem for 4G LTE networks. we used to communicate > with modem using AT commands via ttyUSB ports. > Recently we observed a crash in usb driver interface when we try to > post some AT commands. After the crash the kernel seems to be hanged. > We were not able to execute any commands or open a new tty terminal. > Even reboot command was not working fine. > The system went to completely unusable/unstable state. It recovered > only after hard reboot. > > > > Nov 30 18:59:01 ATCMD = [AT+CMEE=2] > Nov 30 18:59:02 [AT_TRX]Garbage cleared > Nov 30 18:59:02 [AT_TRX]Data from Stream --> [OK] > Nov 30 18:59:02 [AT_TRX]Poll Ended > Nov 30 18:59:02 [AT_TRX]Result :[-1] > > Nov 30 18:59:02 [AT_TRX]Garbage cleared > Nov 30 18:59:02 kernel: [19926.147811] usb 2-1.3: USB disconnect, > device number 126 Your device disconnected itself from the system for some reason, you might want to look into why that happens, could be an electrical issue. > Nov 30 18:59:02 kernel: [19926.147985] sierra ttyUSB0: Sierra USB > modem converter now disconnected from ttyUSB0 > Nov 30 18:59:02 kernel: [19926.148002] sierra 2-1.3:1.0: device disconnected > Nov 30 18:59:02 kernel: [19926.148127] sierra ttyUSB1: Sierra USB > modem converter now disconnected from ttyUSB1 > Nov 30 18:59:02 kernel: [19926.148138] sierra 2-1.3:1.1: device disconnected > Nov 30 18:59:02 kernel: [19926.150070] sierra ttyUSB2: > sierra_submit_rx_urbs: submit urb failed: -19 > Nov 30 18:59:02 kernel: [19926.152626] sierra ttyUSB2: > sierra_submit_rx_urbs: submit urb failed: -19 > Nov 30 18:59:02 kernel: [19926.155136] sierra ttyUSB2: > sierra_submit_rx_urbs: submit urb failed: -19 > Nov 30 18:59:02 kernel: [19926.157589] sierra ttyUSB2: > sierra_submit_rx_urbs: submit urb failed: -19 > Nov 30 18:59:02 kernel: [19926.15] sierra ttyUSB2: > sierra_submit_rx_urbs: submit urb failed: -19 > Nov 30 18:59:02 kernel: [19926.162438] sierra ttyUSB2: > sierra_submit_rx_urbs: submit urb failed: -19 > Nov 30 18:59:02 kernel: [19926.164870] sierra ttyUSB2: > sierra_submit_rx_urbs: submit urb failed: -19 > Nov 30 19:01:12 kernel: [20056.174514] INFO: task khubd:369 blocked > for more than 120 seconds. Not good, what kernel version is this? thanks, greg k-h -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/9v2] usb: host: ehci.h: remove space before open square bracket
Get rid of space before open square bracket. Caught by checkpatch: "ERROR: space prohibited before open square bracket '['" Signed-off-by: Geyslan G. Bem--- drivers/usb/host/ehci.h | 20 ++-- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index 46982df..cfeebd8 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -185,7 +185,7 @@ struct ehci_hcd { /* one per controller */ struct ehci_sitd*last_sitd_to_free; /* per root hub port */ - unsigned long reset_done [EHCI_MAX_ROOT_PORTS]; + unsigned long reset_done[EHCI_MAX_ROOT_PORTS]; /* bit vectors (one bit per port) */ unsigned long bus_suspended; /* which ports were @@ -316,8 +316,8 @@ struct ehci_qtd { #define HALT_BIT(ehci) cpu_to_hc32(ehci, QTD_STS_HALT) #define STATUS_BIT(ehci) cpu_to_hc32(ehci, QTD_STS_STS) - __hc32 hw_buf [5];/* see EHCI 3.5.4 */ - __hc32 hw_buf_hi [5];/* Appendix B */ + __hc32 hw_buf[5];/* see EHCI 3.5.4 */ + __hc32 hw_buf_hi[5];/* Appendix B */ /* the rest is HCD-private */ dma_addr_t qtd_dma;/* qtd address */ @@ -405,8 +405,8 @@ struct ehci_qh_hw { __hc32 hw_qtd_next; __hc32 hw_alt_next; __hc32 hw_token; - __hc32 hw_buf [5]; - __hc32 hw_buf_hi [5]; + __hc32 hw_buf[5]; + __hc32 hw_buf_hi[5]; } __attribute__ ((aligned(32))); struct ehci_qh { @@ -510,7 +510,7 @@ struct ehci_iso_stream { struct ehci_itd { /* first part defined by EHCI spec */ __hc32 hw_next; /* see EHCI 3.3.1 */ - __hc32 hw_transaction [8]; /* see EHCI 3.3.2 */ + __hc32 hw_transaction[8]; /* see EHCI 3.3.2 */ #define EHCI_ISOC_ACTIVE(1<<31)/* activate transfer this slot */ #define EHCI_ISOC_BUF_ERR (1<<30)/* Data buffer error */ #define EHCI_ISOC_BABBLE(1<<29)/* babble detected */ @@ -520,8 +520,8 @@ struct ehci_itd { #define ITD_ACTIVE(ehci) cpu_to_hc32(ehci, EHCI_ISOC_ACTIVE) - __hc32 hw_bufp [7];/* see EHCI 3.3.3 */ - __hc32 hw_bufp_hi [7]; /* Appendix B */ + __hc32 hw_bufp[7]; /* see EHCI 3.3.3 */ + __hc32 hw_bufp_hi[7]; /* Appendix B */ /* the rest is HCD-private */ dma_addr_t itd_dma;/* for this itd */ @@ -565,9 +565,9 @@ struct ehci_sitd { #define SITD_ACTIVE(ehci) cpu_to_hc32(ehci, SITD_STS_ACTIVE) - __hc32 hw_buf [2]; /* EHCI table 3-12 */ + __hc32 hw_buf[2]; /* EHCI table 3-12 */ __hc32 hw_backpointer; /* EHCI table 3-13 */ - __hc32 hw_buf_hi [2]; /* Appendix B */ + __hc32 hw_buf_hi[2]; /* Appendix B */ /* the rest is HCD-private */ dma_addr_t sitd_dma; -- 2.6.3 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/9v2] usb: host: ehci.h: remove space before function open parenthesis
Get rid of space between function name and open parenthesis. Caught by checkpatch: "WARNING: space prohibited between function name and open parenthesis '('" Signed-off-by: Geyslan G. Bem--- drivers/usb/host/ehci.h | 22 +++--- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index 6a36ef4..46982df 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -268,13 +268,13 @@ struct ehci_hcd { /* one per controller */ }; /* convert between an HCD pointer and the corresponding EHCI_HCD */ -static inline struct ehci_hcd *hcd_to_ehci (struct usb_hcd *hcd) +static inline struct ehci_hcd *hcd_to_ehci(struct usb_hcd *hcd) { return (struct ehci_hcd *) (hcd->hcd_priv); } -static inline struct usb_hcd *ehci_to_hcd (struct ehci_hcd *ehci) +static inline struct usb_hcd *ehci_to_hcd(struct ehci_hcd *ehci) { - return container_of ((void *) ehci, struct usb_hcd, hcd_priv); + return container_of((void *) ehci, struct usb_hcd, hcd_priv); } /*-*/ @@ -327,9 +327,9 @@ struct ehci_qtd { } __attribute__ ((aligned (32))); /* mask NakCnt+T in qh->hw_alt_next */ -#define QTD_MASK(ehci) cpu_to_hc32 (ehci, ~0x1f) +#define QTD_MASK(ehci) cpu_to_hc32(ehci, ~0x1f) -#define IS_SHORT_READ(token) (QTD_LENGTH (token) != 0 && QTD_PID (token) == 1) +#define IS_SHORT_READ(token) (QTD_LENGTH(token) != 0 && QTD_PID(token) == 1) /*-*/ @@ -806,7 +806,7 @@ static inline void set_ohci_hcfs(struct ehci_hcd *ehci, int operational) #define ehci_big_endian_desc(e)((e)->big_endian_desc) /* cpu to ehci */ -static inline __hc32 cpu_to_hc32 (const struct ehci_hcd *ehci, const u32 x) +static inline __hc32 cpu_to_hc32(const struct ehci_hcd *ehci, const u32 x) { return ehci_big_endian_desc(ehci) ? (__force __hc32)cpu_to_be32(x) @@ -814,14 +814,14 @@ static inline __hc32 cpu_to_hc32 (const struct ehci_hcd *ehci, const u32 x) } /* ehci to cpu */ -static inline u32 hc32_to_cpu (const struct ehci_hcd *ehci, const __hc32 x) +static inline u32 hc32_to_cpu(const struct ehci_hcd *ehci, const __hc32 x) { return ehci_big_endian_desc(ehci) ? be32_to_cpu((__force __be32)x) : le32_to_cpu((__force __le32)x); } -static inline u32 hc32_to_cpup (const struct ehci_hcd *ehci, const __hc32 *x) +static inline u32 hc32_to_cpup(const struct ehci_hcd *ehci, const __hc32 *x) { return ehci_big_endian_desc(ehci) ? be32_to_cpup((__force __be32 *)x) @@ -831,18 +831,18 @@ static inline u32 hc32_to_cpup (const struct ehci_hcd *ehci, const __hc32 *x) #else /* cpu to ehci */ -static inline __hc32 cpu_to_hc32 (const struct ehci_hcd *ehci, const u32 x) +static inline __hc32 cpu_to_hc32(const struct ehci_hcd *ehci, const u32 x) { return cpu_to_le32(x); } /* ehci to cpu */ -static inline u32 hc32_to_cpu (const struct ehci_hcd *ehci, const __hc32 x) +static inline u32 hc32_to_cpu(const struct ehci_hcd *ehci, const __hc32 x) { return le32_to_cpu(x); } -static inline u32 hc32_to_cpup (const struct ehci_hcd *ehci, const __hc32 *x) +static inline u32 hc32_to_cpup(const struct ehci_hcd *ehci, const __hc32 *x) { return le32_to_cpup(x); } -- 2.6.3 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/4] usb: host: ehci.h: cleanup header file
2015-12-09 17:11 GMT-03:00 Sergei Shtylyov: > Hello. > > On 12/09/2015 10:57 PM, Geyslan G. Bem wrote: > >> This patch does align function/macro definitions. >> >> Signed-off-by: Geyslan G. Bem > > > USB code just uses different alignment style (2 tabs) than the other > kernel parts (like networking). I see. Please, ignore it. New code has to have 2 tabs too? > > MBR, Sergei > -- Regards, Geyslan G. Bem hackingbits.com -- 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 8/9v2] usb: host: ehci.h: move pointer operator to name side
The pointer operator must be sticked to name. Caught by checkpatch: ERROR: "foo * bar" should be "foo *bar" Signed-off-by: Geyslan G. Bem--- drivers/usb/host/ehci.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index 15de5bf..81e609a 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -732,7 +732,7 @@ ehci_port_speed(struct ehci_hcd *ehci, unsigned int portsc) #endif static inline unsigned int ehci_readl(const struct ehci_hcd *ehci, - __u32 __iomem * regs) + __u32 __iomem *regs) { #ifdef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO return ehci_big_endian_mmio(ehci) ? -- 2.6.3 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 7/9v2] usb: host: ehci.h: remove macros trailing semicolon
Removes trailing semicolon from macros. Caught by checkpatch: "WARNING: macros should not use a trailing semicolon" Signed-off-by: Geyslan G. Bem--- drivers/usb/host/ehci.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index ea56147..15de5bf 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -635,10 +635,10 @@ struct ehci_tt { /* Prepare the PORTSC wakeup flags during controller suspend/resume */ #define ehci_prepare_ports_for_controller_suspend(ehci, do_wakeup) \ - ehci_adjust_port_wakeup_flags(ehci, true, do_wakeup); + ehci_adjust_port_wakeup_flags(ehci, true, do_wakeup) #define ehci_prepare_ports_for_controller_resume(ehci) \ - ehci_adjust_port_wakeup_flags(ehci, false, false); + ehci_adjust_port_wakeup_flags(ehci, false, false) /*-*/ -- 2.6.3 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 6/9v2] usb: host: ehci.h: use space after comma
Put space after comma. This patch also changes QH_NEXT macro for better reading. Caught by checkpatch: "ERROR: space required after that ','" Signed-off-by: Geyslan G. Bem--- drivers/usb/host/ehci.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index 7b2b213..ea56147 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -334,7 +334,7 @@ struct ehci_qtd { /*-*/ /* type tag from {qh,itd,sitd,fstn}->hw_next */ -#define Q_NEXT_TYPE(ehci,dma) ((dma) & cpu_to_hc32(ehci, 3 << 1)) +#define Q_NEXT_TYPE(ehci, dma) ((dma) & cpu_to_hc32(ehci, 3 << 1)) /* * Now the following defines are not converted using the @@ -350,7 +350,8 @@ struct ehci_qtd { #define Q_TYPE_FSTN(3 << 1) /* next async queue entry, or pointer to interrupt/periodic QH */ -#define QH_NEXT(ehci,dma) (cpu_to_hc32(ehci, (((u32)dma)&~0x01f)|Q_TYPE_QH)) +#define QH_NEXT(ehci, dma) \ + (cpu_to_hc32(ehci, (((u32) dma) & ~0x01f) | Q_TYPE_QH)) /* for periodic/async schedules and qtd lists, mark end of list */ #define EHCI_LIST_END(ehci)cpu_to_hc32(ehci, 1) /* "null pointer" to hw */ -- 2.6.3 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 1/1] Add a usbredir kernel module to remotely connect USB devices over IP.
I've parked some working code, and I wanted to leave a pointer to it to end this thread. That is, the sense was that usbredir was not appropriate for the linux kernel, because Intel was working on a driver implementing the Media Agnostic USB standard, and having a proliferation of drivers didn't make sense. Stephanie and Sean of Intel tell me that they continue to progress on the ma-usb driver, so that all seems reasonable to me. However, due to time and customer pressure, I made the usbredir kernel module, and a set of associated utilities, work reasonably well for a small set of use cases. I've submitted that as an out of tree module build to the spice-devel mailing list. [1] It works reasonably well, and may benefit someone else that cannot wait for ma-usb. I felt it would be a courtesy to end this thread with this pointer; forgive me if it's unwanted noise. Cheers, Jeremy [1] http://lists.freedesktop.org/archives/spice-devel/2015-December/024779.html -- 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 13/18] usb: dwc2: Move reset into dwc2_get_hwparams()
John, On Wed, Dec 2, 2015 at 11:14 AM, John Younwrote: > The reset is required to get reset values of the hardware parameters but > the force mode is not. Move the base reset into dwc2_get_hwparams() and > do the reset and force mode afterwards. > > Signed-off-by: John Youn > --- > drivers/usb/dwc2/core.c | 5 + > drivers/usb/dwc2/platform.c | 8 ++-- > 2 files changed, 7 insertions(+), 6 deletions(-) > > diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c > index 382f563..7090050 100644 > --- a/drivers/usb/dwc2/core.c > +++ b/drivers/usb/dwc2/core.c > @@ -3116,6 +3116,7 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg) > u32 hwcfg1, hwcfg2, hwcfg3, hwcfg4; > u32 hptxfsiz, grxfsiz, gnptxfsiz; > u32 gusbcfg = 0; > + int retval; > > /* > * Attempt to ensure this device is really a DWC_otg Controller. nit: technically the comment from commit aa63719d0b31 ("usb: dwc2: Improve handling of host and device hwparams") adding that this function now does a reset should have been added in this patch. > @@ -3135,6 +3136,10 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg) > hw->snpsid >> 12 & 0xf, hw->snpsid >> 8 & 0xf, > hw->snpsid >> 4 & 0xf, hw->snpsid & 0xf, hw->snpsid); > > + retval = dwc2_core_reset(hsotg); > + if (retval) > + return retval; > + > hwcfg1 = dwc2_readl(hsotg->regs + GHWCFG1); > hwcfg2 = dwc2_readl(hsotg->regs + GHWCFG2); > hwcfg3 = dwc2_readl(hsotg->regs + GHWCFG3); > diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c > index f18d50f..12826a1 100644 > --- a/drivers/usb/dwc2/platform.c > +++ b/drivers/usb/dwc2/platform.c > @@ -510,12 +510,6 @@ static int dwc2_driver_probe(struct platform_device *dev) > if (retval) > return retval; > > - /* > -* Reset before dwc2_get_hwparams() then it could get power-on real > -* reset value form registers. > -*/ > - dwc2_core_reset_and_force_mode(hsotg); > - > /* Detect config values from hardware */ > retval = dwc2_get_hwparams(hsotg); > if (retval) > @@ -524,6 +518,8 @@ static int dwc2_driver_probe(struct platform_device *dev) > /* Validate parameter values */ > dwc2_set_parameters(hsotg, params); > > + dwc2_core_reset_and_force_mode(hsotg); > + Isn't this introducing a 2nd reset that's not necessary? You already know that dwc2_get_hwparams() did a reset and now you're doing a 2nd reset. Maybe I'm misunderstanding... -Doug -- 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 00/18] usb: dwc2: Reduce probe delays
John, On Wed, Dec 2, 2015 at 11:11 AM, John Younwrote: > This series includes patches that were submitted earlier by Douglas > Anderson and Yunzhi Li to reduce delays during probe and get the > correct reset values of the hardware configuration registers. These > are patches 1-6 in this series. > > I have additionally added patches to clean up the code around that > area, and have further reduced the delays by: > > - Taking into account the correct dr_mode > - Skipping force mode when not needed > - Removing unnecessary force mode from the gadget side > - Reduce the force mode delay from 150 ms to 25 ms > > Tested on: > - Synopsys HAPS, IP v3.20 > - Altera SOCFPGA, IP v2.93 > > Appreciate testing on other platforms. > > Regards, > John > > Douglas Anderson (4): > usb: dwc2: Restore GUSBCFG in dwc2_get_hwparams() > usb: dwc2: Avoid double-reset at boot time > usb: dwc2: Speed dwc2_get_hwparams() on some host-only ports > usb: dwc2: Avoid more calls to dwc2_core_reset() > > John Youn (12): > usb: dwc2: Reorder AHBIDLE and CSFTRST in dwc2_core_reset() > usb: dwc2: Rename dwc2_core_reset() > usb: dwc2: Add dwc2_core_reset() > usb: dwc2: Add functions to check the HW OTG config > usb: dwc2: Fix dr_mode validation > usb: dwc2: Move mode querying functions into core.h > usb: dwc2: Move reset into dwc2_get_hwparams() > usb: dwc2: Add functions to set and clear force mode > usb: dwc2: Improve handling of host and device hwparams > usb: dwc2: gadget: Use the common dwc2_core_reset() > usb: dwc2: gadget: Remove force device mode > usb: dwc2: Reduce delay when forcing mode in reset > > Yunzhi Li (2): > usb: dwc2: reset dwc2 core before dwc2_get_hwparams() > usb: dwc2: reduce dwc2 driver probe time > > drivers/usb/dwc2/core.c | 301 > ++-- > drivers/usb/dwc2/core.h | 30 - > drivers/usb/dwc2/gadget.c | 68 +- > drivers/usb/dwc2/hcd.c | 6 +- > drivers/usb/dwc2/hcd.h | 12 -- > drivers/usb/dwc2/platform.c | 81 ++-- > 6 files changed, 340 insertions(+), 158 deletions(-) I confirmed that the first 6 patches match the last ones I posted. As you found, there was a trivial merge conflict with "usb: dwc2: reset dwc2 core before dwc2_get_hwparams()" and you resolved it in the same way that I resolved it locally. I'm not sure tags like Tested-by or Reviewed-by make sense for patches that I authored and/or have Signed-off-by, but just noting that I'm OK with them as you've reposted (thanks!) I picked all the other patches locally to my 3.14 too and am testing. So far so good. I've got a farm of 5 devices doing reboot tests overnight. On each bootup it will confirm that a USB based Ethernet adapter on one of the two ports is at least sane enough to get SSH connections and that the device never crashes. I'll send review feedback and tested-by for each patch (other than the gadget ones, which I applied mostly to avoid merge conflicts) tomorrow morning on the conclusion of the boot test. -Doug -- 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: remove redundant conditions
This patch removes redundant conditions. - (!A || (A && B)) is the same as (!A || B). - (length && length > 5) can be reduced to a single evaluation. Caught by: cppcheck Signed-off-by: Geyslan G. Bem--- drivers/usb/gadget/udc/s3c-hsudc.c | 2 +- drivers/usb/host/fhci-sched.c | 2 +- drivers/usb/musb/musb_gadget.c | 5 ++--- drivers/usb/serial/io_edgeport.c | 35 ++- drivers/usb/serial/mos7840.c | 2 +- 5 files changed, 19 insertions(+), 27 deletions(-) diff --git a/drivers/usb/gadget/udc/s3c-hsudc.c b/drivers/usb/gadget/udc/s3c-hsudc.c index e9def42..82a9e2a 100644 --- a/drivers/usb/gadget/udc/s3c-hsudc.c +++ b/drivers/usb/gadget/udc/s3c-hsudc.c @@ -569,7 +569,7 @@ static int s3c_hsudc_handle_reqfeat(struct s3c_hsudc *hsudc, hsep = >ep[ep_num]; switch (le16_to_cpu(ctrl->wValue)) { case USB_ENDPOINT_HALT: - if (set || (!set && !hsep->wedge)) + if (set || !hsep->wedge) s3c_hsudc_set_halt(>ep, set); return 0; } diff --git a/drivers/usb/host/fhci-sched.c b/drivers/usb/host/fhci-sched.c index 95ca598..23ecac5 100644 --- a/drivers/usb/host/fhci-sched.c +++ b/drivers/usb/host/fhci-sched.c @@ -288,7 +288,7 @@ static int scan_ed_list(struct fhci_usb *usb, list_for_each_entry(ed, list, node) { td = ed->td_head; - if (!td || (td && td->status == USB_TD_INPROGRESS)) + if (!td || (td->status == USB_TD_INPROGRESS)) continue; if (ed->state != FHCI_ED_OPER) { diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index 67ad630..87bd578 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -353,9 +353,8 @@ static void txstate(struct musb *musb, struct musb_request *req) * 1 >0 Yes(FS bulk) */ if (!musb_ep->hb_mult || - (musb_ep->hb_mult && -can_bulk_split(musb, - musb_ep->type))) + can_bulk_split(musb, + musb_ep->type)) csr |= MUSB_TXCSR_AUTOSET; } csr &= ~MUSB_TXCSR_P_UNDERRUN; diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index c086697..f49327d 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c @@ -1046,9 +1046,8 @@ static void edge_close(struct usb_serial_port *port) edge_port->closePending = true; - if ((!edge_serial->is_epic) || - ((edge_serial->is_epic) && -(edge_serial->epic_descriptor.Supports.IOSPChase))) { + if (!edge_serial->is_epic || + edge_serial->epic_descriptor.Supports.IOSPChase) { /* flush and chase */ edge_port->chaseResponsePending = true; @@ -1061,9 +1060,8 @@ static void edge_close(struct usb_serial_port *port) edge_port->chaseResponsePending = false; } - if ((!edge_serial->is_epic) || - ((edge_serial->is_epic) && -(edge_serial->epic_descriptor.Supports.IOSPClose))) { + if (!edge_serial->is_epic || + edge_serial->epic_descriptor.Supports.IOSPClose) { /* close the port */ dev_dbg(>dev, "%s - Sending IOSP_CMD_CLOSE_PORT\n", __func__); send_iosp_ext_cmd(edge_port, IOSP_CMD_CLOSE_PORT, 0); @@ -1612,9 +1610,8 @@ static void edge_break(struct tty_struct *tty, int break_state) struct edgeport_serial *edge_serial = usb_get_serial_data(port->serial); int status; - if ((!edge_serial->is_epic) || - ((edge_serial->is_epic) && -(edge_serial->epic_descriptor.Supports.IOSPChase))) { + if (!edge_serial->is_epic || + edge_serial->epic_descriptor.Supports.IOSPChase) { /* flush and chase */ edge_port->chaseResponsePending = true; @@ -1628,9 +1625,8 @@ static void edge_break(struct tty_struct *tty, int break_state) } } - if ((!edge_serial->is_epic) || - ((edge_serial->is_epic) && -(edge_serial->epic_descriptor.Supports.IOSPSetClrBreak))) { + if (!edge_serial->is_epic || + edge_serial->epic_descriptor.Supports.IOSPSetClrBreak) { if (break_state == -1) { dev_dbg(>dev, "%s - Sending IOSP_CMD_SET_BREAK\n", __func__); status =
[PATCH 3/5] usb: ehci-msm: Add support for ACPI probing
From: Jack PhamAllow the EHCI MSM driver to probe against an ACPI enumerated device with ID QCOM8040. Signed-off-by: Jack Pham Signed-off-by: Timur Tabi --- drivers/usb/host/ehci-msm.c | 8 1 file changed, 8 insertions(+) diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c index 0a86b8e..fc666ef 100644 --- a/drivers/usb/host/ehci-msm.c +++ b/drivers/usb/host/ehci-msm.c @@ -33,6 +33,7 @@ #include #include #include +#include #include "ehci.h" @@ -202,6 +203,12 @@ static const struct dev_pm_ops ehci_msm_dev_pm_ops = { .resume = ehci_msm_pm_resume, }; +static const struct acpi_device_id msm_ehci_acpi_ids[] = { + { "QCOM8040", 0 }, + { } +}; +MODULE_DEVICE_TABLE(acpi, msm_ehci_acpi_ids); + static const struct of_device_id msm_ehci_dt_match[] = { { .compatible = "qcom,ehci-host", }, {} @@ -215,6 +222,7 @@ static struct platform_driver ehci_msm_driver = { .name = "msm_hsusb_host", .pm = _msm_dev_pm_ops, .of_match_table = msm_ehci_dt_match, + .acpi_match_table = ACPI_PTR(msm_ehci_acpi_ids), }, }; -- Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project. -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 5/5] usb: ehci-msm: Register usb shutdown function
From: Azriel SamsonRegistering usb_hcd_platform_shutdown to be called during shutdown. This is a generic function that performs the generic host stack's shutdown. It ensures that USB operations do not continue while kexec boots a new kernel. Signed-off-by: Azriel Samson Signed-off-by: Timur Tabi --- drivers/usb/host/ehci-msm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c index b8c0df0..cde3d18 100644 --- a/drivers/usb/host/ehci-msm.c +++ b/drivers/usb/host/ehci-msm.c @@ -220,6 +220,7 @@ MODULE_DEVICE_TABLE(of, msm_ehci_dt_match); static struct platform_driver ehci_msm_driver = { .probe = ehci_msm_probe, .remove = ehci_msm_remove, + .shutdown = usb_hcd_platform_shutdown, .driver = { .name = "msm_hsusb_host", .pm = _msm_dev_pm_ops, -- Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project. -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/5] usb: ehci-msm: Remove dependency on OTG PHY
From: Jack PhamCurrently the EHCI MSM driver has a hard dependency to be created by an OTG layer, namely the phy-msm-usb driver. In some cases or board configurations we want to allow the EHCI host to be instantiated without OTG capability. Instead, relax the dependency on having an OTG PHY being present and call usb_add_hcd() directly. Signed-off-by: Jack Pham Signed-off-by: Timur Tabi --- drivers/usb/host/ehci-msm.c | 53 ++--- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c index d3ed6c9..0a86b8e 100644 --- a/drivers/usb/host/ehci-msm.c +++ b/drivers/usb/host/ehci-msm.c @@ -106,9 +106,9 @@ static int ehci_msm_probe(struct platform_device *pdev) } /* -* OTG driver takes care of PHY initialization, clock management, -* powering up VBUS, mapping of registers address space and power -* management. +* If there is an OTG driver, let it take care of PHY initialization, +* clock management, powering up VBUS, mapping of registers address +* space and power management. */ if (pdev->dev.of_node) phy = devm_usb_get_phy_by_phandle(>dev, "usb-phy", 0); @@ -116,27 +116,35 @@ static int ehci_msm_probe(struct platform_device *pdev) phy = devm_usb_get_phy(>dev, USB_PHY_TYPE_USB2); if (IS_ERR(phy)) { - dev_err(>dev, "unable to find transceiver\n"); - ret = -EPROBE_DEFER; - goto put_hcd; - } - - ret = otg_set_host(phy->otg, >self); - if (ret < 0) { - dev_err(>dev, "unable to register with transceiver\n"); - goto put_hcd; + if (PTR_ERR(phy) == -EPROBE_DEFER) { + dev_err(>dev, "unable to find transceiver\n"); + ret = -EPROBE_DEFER; + goto put_hcd; + } + phy = NULL; } hcd->usb_phy = phy; device_init_wakeup(>dev, 1); - /* -* OTG device parent of HCD takes care of putting -* hardware into low power mode. -*/ - pm_runtime_no_callbacks(>dev); - pm_runtime_enable(>dev); - /* FIXME: need to call usb_add_hcd() here? */ + if (phy && phy->otg) { + /* +* MSM OTG driver takes care of adding the HCD and +* placing hardware into low power mode via runtime PM. +*/ + ret = otg_set_host(phy->otg, >self); + if (ret < 0) { + dev_err(>dev, "unable to register with transceiver\n"); + goto put_hcd; + } + + pm_runtime_no_callbacks(>dev); + pm_runtime_enable(>dev); + } else { + ret = usb_add_hcd(hcd, hcd->irq, IRQF_SHARED); + if (ret) + goto put_hcd; + } return 0; @@ -154,9 +162,10 @@ static int ehci_msm_remove(struct platform_device *pdev) pm_runtime_disable(>dev); pm_runtime_set_suspended(>dev); - otg_set_host(hcd->usb_phy->otg, NULL); - - /* FIXME: need to call usb_remove_hcd() here? */ + if (hcd->usb_phy && hcd->usb_phy->otg) + otg_set_host(hcd->usb_phy->otg, NULL); + else + usb_remove_hcd(hcd); usb_put_hcd(hcd); -- Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project. -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/5] usb: ehci-msm: Allow LS devices to work
From: Jack PhamDisable the silicon quirk which is normally enabled for HSIC host mode. This would otherwise prevent low speed devices from enumerating properly. Signed-off-by: Jack Pham Signed-off-by: Timur Tabi --- drivers/usb/host/ehci-msm.c | 2 ++ include/linux/usb/msm_hsusb_hw.h | 1 + 2 files changed, 3 insertions(+) diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c index c4f84c8..d3ed6c9 100644 --- a/drivers/usb/host/ehci-msm.c +++ b/drivers/usb/host/ehci-msm.c @@ -61,6 +61,8 @@ static int ehci_msm_reset(struct usb_hcd *hcd) writel(0, USB_AHBMODE); /* Disable streaming mode and select host mode */ writel(0x13, USB_USBMODE); + /* Disable ULPI_TX_PKT_EN_CLR_FIX which is valid only for HSIC */ + writel(readl(USB_GENCONFIG_2) & ~ULPI_TX_PKT_EN_CLR_FIX, USB_GENCONFIG_2); return 0; } diff --git a/include/linux/usb/msm_hsusb_hw.h b/include/linux/usb/msm_hsusb_hw.h index e159b39..974c379 100644 --- a/include/linux/usb/msm_hsusb_hw.h +++ b/include/linux/usb/msm_hsusb_hw.h @@ -22,6 +22,7 @@ #define USB_AHBBURST (MSM_USB_BASE + 0x0090) #define USB_AHBMODE (MSM_USB_BASE + 0x0098) #define USB_GENCONFIG_2 (MSM_USB_BASE + 0x00a0) +#define ULPI_TX_PKT_EN_CLR_FIX BIT(19) #define USB_CAPLENGTH(MSM_USB_BASE + 0x0100) /* 8 bit */ -- Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project. -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 4/5] usb: ehci-msm: Fix register initialization
From: Jack PhamThe default value for the 'transceiver select' field of the PORTSC register may not always be correct. Previously the phy-msm-usb driver would do this for us, but since ehci-msm can now be instantiated standalone without any PHY driver, the register needs to be explicitly initialized to ULPI mode to properly communicate with the PHY. This is not readily apparent, as firmware or bootloader code also happen to pre-initialize this for us. However, it can manifest when performing a driver unbind/rebind as follows: cd /sys/bus/platform/drivers/msm_hsusb_host echo QCOM8040:00 > unbind echo QCOM8040:00 > bind The EHCI core executes a controller reset as part of this, and as a result the register in question would revert to its default state and must be re-initialized properly. Furthermore this may be useful in the future when adding PM suspend/resume support. Also, update to use the correct value of AHBMODE to allow data transfers to be posted AHB transactions. This aligns with the value used in the downstream MSM kernel. Signed-off-by: Jack Pham Signed-off-by: Timur Tabi --- drivers/usb/host/ehci-msm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c index fc666ef..b8c0df0 100644 --- a/drivers/usb/host/ehci-msm.c +++ b/drivers/usb/host/ehci-msm.c @@ -56,10 +56,12 @@ static int ehci_msm_reset(struct usb_hcd *hcd) if (retval) return retval; + /* select ULPI phy and clear other status/control bits in PORTSC */ + writel(PORTSC_PTS_ULPI, USB_PORTSC); /* bursts of unspecified length. */ writel(0, USB_AHBBURST); /* Use the AHB transactor */ - writel(0, USB_AHBMODE); + writel(0x8, USB_AHBMODE); /* Disable streaming mode and select host mode */ writel(0x13, USB_USBMODE); /* Disable ULPI_TX_PKT_EN_CLR_FIX which is valid only for HSIC */ -- Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project. -- 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 4/5] usb: ehci-msm: Fix register initialization
Hi Timur, Thanks for sending these patches upstream on my behalf. On Wed, Dec 09, 2015 at 05:41:07PM -0600, Timur Tabi wrote: > Also, update to use the correct value of AHBMODE to allow > data transfers to be posted AHB transactions. This aligns > with the value used in the downstream MSM kernel. > /* Use the AHB transactor */ > - writel(0, USB_AHBMODE); > + writel(0x8, USB_AHBMODE); Andy already sent a patch for just this register change. http://marc.info/?l=linux-usb=144678991912202=2 I see it's already been queued on Greg's usb-next. I think it would be good to rebase. Jack -- 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 4/5] usb: ehci-msm: Fix register initialization
Jack Pham wrote: Andy already sent a patch for just this register change. http://marc.info/?l=linux-usb=144678991912202=2 I see it's already been queued on Greg's usb-next. I think it would be good to rebase. Ok, I will do that in my next patch version. -- Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation. -- 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: [PATCHv3] Input: xpad - Fix double URB submission races
Hi Laura, On Mon, Nov 16, 2015 at 02:47:13PM -0800, Laura Abbott wrote: > +static int __xpad_submit_urb(struct usb_xpad *xpad, > + unsigned char odata[XPAD_PKT_LEN], int transfer_length, > + int type, bool safe_submit) > +{ > + int ret; > + > + if (safe_submit || xpad->submit_state == OUT_IRQ_AVAILABLE) { > + memcpy(xpad->odata, odata, transfer_length); > + xpad->irq_out->transfer_buffer_length = transfer_length; > + ret = usb_submit_urb(xpad->irq_out, GFP_ATOMIC); > + xpad->submit_state = OUT_IRQ_QUEUE_EMPTY; > + xpad->out_submitter = type; > + } else { > + /* > + * The goal here is to prevent starvation of any other type. > + * If this type matches what is being submitted and there is > + * another type in the queue, don't ovewrite it > + */ > + if (xpad->submit_state != OUT_IRQ_QUEUE_EMPTY && > + xpad->out_submitter == type && > + xpad->queue_submitter != type) { > + ret = -EBUSY; > + goto out; No, we do not want to return "busy" here. We should save the most up-to-date request of given type and re-submit it when URB is no longer busy. I CCed you on another patch addressing the same issue, please take a look when you have a chance. Thanks. -- Dmitry -- 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 13/18] usb: dwc2: Move reset into dwc2_get_hwparams()
On 12/9/2015 4:46 PM, Doug Anderson wrote: > John, > > On Wed, Dec 2, 2015 at 11:14 AM, John Younwrote: >> The reset is required to get reset values of the hardware parameters but >> the force mode is not. Move the base reset into dwc2_get_hwparams() and >> do the reset and force mode afterwards. >> >> Signed-off-by: John Youn >> --- >> drivers/usb/dwc2/core.c | 5 + >> drivers/usb/dwc2/platform.c | 8 ++-- >> 2 files changed, 7 insertions(+), 6 deletions(-) >> >> diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c >> index 382f563..7090050 100644 >> --- a/drivers/usb/dwc2/core.c >> +++ b/drivers/usb/dwc2/core.c >> @@ -3116,6 +3116,7 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg) >> u32 hwcfg1, hwcfg2, hwcfg3, hwcfg4; >> u32 hptxfsiz, grxfsiz, gnptxfsiz; >> u32 gusbcfg = 0; >> + int retval; >> >> /* >> * Attempt to ensure this device is really a DWC_otg Controller. > > nit: technically the comment from commit aa63719d0b31 ("usb: dwc2: > Improve handling of host and device hwparams") adding that this > function now does a reset should have been added in this patch. Ahh thanks. I'll fix it if I have to respin this series. > > >> @@ -3135,6 +3136,10 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg) >> hw->snpsid >> 12 & 0xf, hw->snpsid >> 8 & 0xf, >> hw->snpsid >> 4 & 0xf, hw->snpsid & 0xf, hw->snpsid); >> >> + retval = dwc2_core_reset(hsotg); >> + if (retval) >> + return retval; >> + >> hwcfg1 = dwc2_readl(hsotg->regs + GHWCFG1); >> hwcfg2 = dwc2_readl(hsotg->regs + GHWCFG2); >> hwcfg3 = dwc2_readl(hsotg->regs + GHWCFG3); >> diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c >> index f18d50f..12826a1 100644 >> --- a/drivers/usb/dwc2/platform.c >> +++ b/drivers/usb/dwc2/platform.c >> @@ -510,12 +510,6 @@ static int dwc2_driver_probe(struct platform_device >> *dev) >> if (retval) >> return retval; >> >> - /* >> -* Reset before dwc2_get_hwparams() then it could get power-on real >> -* reset value form registers. >> -*/ >> - dwc2_core_reset_and_force_mode(hsotg); >> - >> /* Detect config values from hardware */ >> retval = dwc2_get_hwparams(hsotg); >> if (retval) >> @@ -524,6 +518,8 @@ static int dwc2_driver_probe(struct platform_device *dev) >> /* Validate parameter values */ >> dwc2_set_parameters(hsotg, params); >> >> + dwc2_core_reset_and_force_mode(hsotg); >> + > > Isn't this introducing a 2nd reset that's not necessary? You already > know that dwc2_get_hwparams() did a reset and now you're doing a 2nd > reset. Maybe I'm misunderstanding... I wanted to preserve setting force mode just before calling the gadget/hcd init. Only a plain (fast) reset is required to read the HW params. But it is redundant. I can split out the force mode to avoid the extra reset. I'll send an add-on patch to this series that does that. 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 15/18] usb: dwc2: Improve handling of host and device hwparams
John, On Wed, Dec 2, 2015 at 11:15 AM, John Younwrote: > This commit adds separate functions for getting the host and device > specific hardware params. These functions check whether the parameters > need to be read at all, depending on dr_mode, and they force the mode > only if necessary. This saves some delays during probe. > > Signed-off-by: John Youn > --- > drivers/usb/dwc2/core.c | 93 > + > drivers/usb/dwc2/core.h | 1 + > 2 files changed, 71 insertions(+), 23 deletions(-) > > diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c > index caaff42..91d63a8 100644 > --- a/drivers/usb/dwc2/core.c > +++ b/drivers/usb/dwc2/core.c > @@ -3159,17 +3159,76 @@ static void dwc2_clear_force_mode(struct dwc2_hsotg > *hsotg) > usleep_range(25000, 5); > } > > +/* > + * Gets host hardware parameters. Forces host mode if not currently in > + * host mode. Should be called immediately after a core soft reset in > + * order to get the reset values. > + */ > +static void dwc2_get_host_hwparams(struct dwc2_hsotg *hsotg) > +{ > + struct dwc2_hw_params *hw = >hw_params; > + u32 gnptxfsiz; > + u32 hptxfsiz; > + bool forced; > + > + if (hsotg->dr_mode == USB_DR_MODE_PERIPHERAL) > + return; > + > + forced = dwc2_force_host_if_needed(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); > + > + hw->host_nperio_tx_fifo_size = (gnptxfsiz & FIFOSIZE_DEPTH_MASK) >> > + FIFOSIZE_DEPTH_SHIFT; > + hw->host_perio_tx_fifo_size = (hptxfsiz & FIFOSIZE_DEPTH_MASK) >> > + FIFOSIZE_DEPTH_SHIFT; > +} > + > +/* > + * Gets device hardware parameters. Forces device mode if not > + * currently in device mode. Should be called immediately after a core > + * soft reset in order to get the reset values. > + */ > +static void dwc2_get_dev_hwparams(struct dwc2_hsotg *hsotg) > +{ > + struct dwc2_hw_params *hw = >hw_params; > + bool forced; > + u32 gnptxfsiz; > + > + if (hsotg->dr_mode == USB_DR_MODE_HOST) > + return; > + > + forced = dwc2_force_device_if_needed(hsotg); Interesting. You're getting a new parameter that's never been needed in the code before and (as far as I can tell) isn't used anywhere in your series. I presume this is in prep for a future patch that uses this? At the moment you're burning a decent delay to read this unused parameter (potentially up to 100ms), so hopefully there's a good use for it eventually... > + > + gnptxfsiz = dwc2_readl(hsotg->regs + GNPTXFSIZ); > + dev_dbg(hsotg->dev, "gnptxfsiz=%08x\n", gnptxfsiz); > + > + if (forced) > + dwc2_clear_force_mode(hsotg); > + > + hw->dev_nperio_tx_fifo_size = (gnptxfsiz & FIFOSIZE_DEPTH_MASK) >> > + FIFOSIZE_DEPTH_SHIFT; > +} > + > /** > * During device initialization, read various hardware configuration > * registers and interpret the contents. > + * > + * This should be called during driver probe. It will perform a core > + * soft reset in order to get the reset values of the parameters. > */ > int dwc2_get_hwparams(struct dwc2_hsotg *hsotg) > { > struct dwc2_hw_params *hw = >hw_params; > unsigned width; > u32 hwcfg1, hwcfg2, hwcfg3, hwcfg4; > - u32 hptxfsiz, grxfsiz, gnptxfsiz; > - u32 gusbcfg = 0; > + u32 grxfsiz; > int retval; > > /* > @@ -3206,23 +3265,6 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg) > dev_dbg(hsotg->dev, "hwcfg4=%08x\n", hwcfg4); > dev_dbg(hsotg->dev, "grxfsiz=%08x\n", grxfsiz); > > - /* Force host mode to get HPTXFSIZ / GNPTXFSIZ exact power on value */ > - if (hsotg->dr_mode != USB_DR_MODE_HOST) { > - gusbcfg = dwc2_readl(hsotg->regs + GUSBCFG); > - dwc2_writel(gusbcfg | GUSBCFG_FORCEHOSTMODE, > - hsotg->regs + GUSBCFG); > - usleep_range(25000, 5); > - } > - > - 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 (hsotg->dr_mode != USB_DR_MODE_HOST) { > - dwc2_writel(gusbcfg, hsotg->regs + GUSBCFG); > - usleep_range(25000, 5); > - } > - optional nit: To make the function change less, it seems like dwc2_get_host_hwparams() and dwc2_get_dev_hwparams() could be here instead of below. Then your forcing of modes /
[PATCH v2 0/2] usb: renesas_usbhs: More compat strings
Hi, this short series adds generic, and soc-specific r8a7792 and r8a7793 compat strings to the Renesas USBHS driver. The intention is to provide a complete set of compat strings for known R-Car SoCs. Changes since v1: * Add R-Car Gen2 and Gen3 fallback compatibility strings rather than a single compatibility string for all of R-Car. *** BLURB HERE *** Simon Horman (2): usb: renesas_usbhs: add fallback compatibility strings usb: renesas_usbhs: add device tree support for r8a779[23] .../devicetree/bindings/usb/renesas_usbhs.txt| 20 +++- drivers/usb/renesas_usbhs/common.c | 9 + 2 files changed, 24 insertions(+), 5 deletions(-) -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 2/2] usb: renesas_usbhs: add device tree support for r8a779[23]
Simply document new compatibility string. As a previous patch adds a generic R-Car Gen2 compatibility string there appears to be no need for a driver updates. Signed-off-by: Simon HormanAcked-by: Rob Herring --- Documentation/devicetree/bindings/usb/renesas_usbhs.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/renesas_usbhs.txt b/Documentation/devicetree/bindings/usb/renesas_usbhs.txt index b959059826cd..efb3199a2a80 100644 --- a/Documentation/devicetree/bindings/usb/renesas_usbhs.txt +++ b/Documentation/devicetree/bindings/usb/renesas_usbhs.txt @@ -5,6 +5,8 @@ Required properties: - "renesas,usbhs-r8a7790" for r8a7790 (R-Car H2) compatible device - "renesas,usbhs-r8a7791" for r8a7791 (R-Car M2-W) compatible device + - "renesas,usbhs-r8a7792" for r8a7792 (R-Car V2H) compatible device + - "renesas,usbhs-r8a7793" for r8a7793 (R-Car M2-N) compatible device - "renesas,usbhs-r8a7794" for r8a7794 (R-Car E2) compatible device - "renesas,usbhs-r8a7795" for r8a7795 (R-Car H3) compatible device - "renesas,rcar-gen2-usbhs" for R-Car Gen2 compatibile device -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 1/2] usb: renesas_usbhs: add fallback compatibility strings
Add fallback compatibility strings for R-Car Gen2 and Gen3. This is in keeping with the fallback scheme being adopted wherever appropriate for drivers for Renesas SoCs. Also add SoC names. Signed-off-by: Simon Horman--- v2 * Add R-Car Gen2 and Gen3 fallback compatibility strings rather than a single compatibility string for all of R-Car. --- .../devicetree/bindings/usb/renesas_usbhs.txt | 18 +- drivers/usb/renesas_usbhs/common.c | 9 + 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/renesas_usbhs.txt b/Documentation/devicetree/bindings/usb/renesas_usbhs.txt index 7d48f63db44e..b959059826cd 100644 --- a/Documentation/devicetree/bindings/usb/renesas_usbhs.txt +++ b/Documentation/devicetree/bindings/usb/renesas_usbhs.txt @@ -2,10 +2,18 @@ Renesas Electronics USBHS driver Required properties: - compatible: Must contain one of the following: - - "renesas,usbhs-r8a7790" - - "renesas,usbhs-r8a7791" - - "renesas,usbhs-r8a7794" - - "renesas,usbhs-r8a7795" + + - "renesas,usbhs-r8a7790" for r8a7790 (R-Car H2) compatible device + - "renesas,usbhs-r8a7791" for r8a7791 (R-Car M2-W) compatible device + - "renesas,usbhs-r8a7794" for r8a7794 (R-Car E2) compatible device + - "renesas,usbhs-r8a7795" for r8a7795 (R-Car H3) compatible device + - "renesas,rcar-gen2-usbhs" for R-Car Gen2 compatibile device + - "renesas,rcar-gen3-usbhs" for R-Car Gen3 compatibile device + + When compatible with the generic version, nodes must list the + SoC-specific version corresponding to the platform first followed + by the generic version. + - reg: Base address and length of the register for the USBHS - interrupts: Interrupt specifier for the USBHS - clocks: A list of phandle + clock specifier pairs @@ -22,7 +30,7 @@ Optional properties: Example: usbhs: usb@e659 { - compatible = "renesas,usbhs-r8a7790"; + compatible = "renesas,usbhs-r8a7790", "renesas,rcar-usbhs"; reg = <0 0xe659 0 0x100>; interrupts = <0 107 IRQ_TYPE_LEVEL_HIGH>; clocks = <_clks R8A7790_CLK_HSUSB>; diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c index d82fa36c3465..db9a17bd8997 100644 --- a/drivers/usb/renesas_usbhs/common.c +++ b/drivers/usb/renesas_usbhs/common.c @@ -481,6 +481,15 @@ static const struct of_device_id usbhs_of_match[] = { .compatible = "renesas,usbhs-r8a7795", .data = (void *)USBHS_TYPE_RCAR_GEN2, }, + { + .compatible = "renesas,rcar-gen2-usbhs", + .data = (void *)USBHS_TYPE_RCAR_GEN2, + }, + { + /* Gen3 is compatible with Gen2 */ + .compatible = "renesas,rcar-gen3-usbhs", + .data = (void *)USBHS_TYPE_RCAR_GEN2, + }, { }, }; MODULE_DEVICE_TABLE(of, usbhs_of_match); -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 12/18] usb: dwc2: Move mode querying functions into core.h
John, On Wed, Dec 2, 2015 at 11:14 AM, John Younwrote: > These functions should go in core.h where they can be called from core, > device, or host. > > Signed-off-by: John Youn > --- > drivers/usb/dwc2/core.h | 12 > drivers/usb/dwc2/hcd.h | 12 > 2 files changed, 12 insertions(+), 12 deletions(-) Yup. Fine, fine. Works across many reboots on a farm of rk3288-based devices on a 3.14 kernel. Reviewed-by: Douglas Anderson Tested-by: Douglas Anderson -- 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 18/18] usb: dwc2: Reduce delay when forcing mode in reset
John, On Wed, Dec 2, 2015 at 11:15 AM, John Younwrote: > The delay for force mode is only 25ms according to the databook. > > 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 91d63a8..a6fddbf 100644 > --- a/drivers/usb/dwc2/core.c > +++ b/drivers/usb/dwc2/core.c > @@ -552,7 +552,7 @@ int dwc2_core_reset_and_force_mode(struct dwc2_hsotg > *hsotg) > * NOTE: This long sleep is _very_ important, otherwise the core will > * not stay in host mode after a connector ID change! > */ > - usleep_range(15, 16); > + usleep_range(25000, 5); This seems to work for me. At least I've done reboots and not noticed any problems. :-P Personally I'd suggest tightening the range to something like (25000, 3) or even replacing with "msleep(25)". From past experience I've found that usleep_range() nearly always picks the largest value you gave it. That's supposed to be for power savings for things you do all the time. For a rare thing like a reset it's just a waste of time. In any case, up to you. What yo have is certainly better than what was there. This is tested on some rk3288-based devices with a 3.14 kernel. Reviewed-by: Douglas Anderson Tested-by: Douglas Anderson -- 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 09/18] usb: dwc2: Add dwc2_core_reset()
John, On Wed, Dec 2, 2015 at 11:13 AM, John Younwrote: > dwc2_core_reset() was previously renamed to > dwc2_core_reset_and_force_mode(). Now add back dwc2_core_reset() which > performs only a basic core reset without forcing the mode. > > Signed-off-by: John Youn > --- > drivers/usb/dwc2/core.c | 22 ++ > drivers/usb/dwc2/core.h | 1 + > 2 files changed, 19 insertions(+), 4 deletions(-) > > diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c > index 24f9e80..b7a733a 100644 > --- a/drivers/usb/dwc2/core.c > +++ b/drivers/usb/dwc2/core.c > @@ -478,14 +478,12 @@ static void dwc2_init_fs_ls_pclk_sel(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. > + * Performs a base controller soft reset. Wouldn't the "be careful" message still be relevant? Presumably this makes the mode no longer match what may be stored in hsotg->dr_mode, so it probably wouldn't hurt to at least mention dwc2_core_reset_and_force_mode() in the comment? > */ > -int dwc2_core_reset_and_force_mode(struct dwc2_hsotg *hsotg) > +int dwc2_core_reset(struct dwc2_hsotg *hsotg) > { > u32 greset; > int count = 0; > - u32 gusbcfg; > > dev_vdbg(hsotg->dev, "%s()\n", __func__); > > @@ -517,6 +515,22 @@ int dwc2_core_reset_and_force_mode(struct dwc2_hsotg > *hsotg) > } > } while (!(greset & GRSTCTL_AHBIDLE)); > > + return 0; > +} > + > +/* > + * Do core a soft reset of the core. Be careful with this because it > + * resets all the internal state machines of the core. Nothing differentiates this comment from dwc2_core_reset() other than the warning message, and that warning message seems like it also belongs on the other one. Maybe at least a comment like "This will apply mode forces as per the stored hsotg->dr_mode" > + */ > +int dwc2_core_reset_and_force_mode(struct dwc2_hsotg *hsotg) > +{ > + int retval; > + u32 gusbcfg; > + > + retval = dwc2_core_reset(hsotg); > + if (retval) > + return retval; > + > if (hsotg->dr_mode == USB_DR_MODE_HOST) { > gusbcfg = dwc2_readl(hsotg->regs + GUSBCFG); > gusbcfg &= ~GUSBCFG_FORCEDEVMODE; > diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h > index 0b4c036..53c992a 100644 > --- a/drivers/usb/dwc2/core.h > +++ b/drivers/usb/dwc2/core.h > @@ -889,6 +889,7 @@ enum dwc2_halt_status { > * The following functions support initialization of the core driver > component > * and the DWC_otg controller > */ > +extern int dwc2_core_reset(struct dwc2_hsotg *hsotg); > extern int dwc2_core_reset_and_force_mode(struct dwc2_hsotg *hsotg); > extern void dwc2_core_host_init(struct dwc2_hsotg *hsotg); > extern int dwc2_enter_hibernation(struct dwc2_hsotg *hsotg); Other than function commenting, this seems sane. Works across many reboots on a farm of rk3288-based devices on a 3.14 kernel. Reviewed-by: Douglas Anderson Tested-by: Douglas Anderson -- 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 08/18] usb: dwc2: Rename dwc2_core_reset()
John, On Wed, Dec 2, 2015 at 11:13 AM, John Younwrote: > Renamed dwc2_core_reset() to dwc2_core_reset_and_force_mode(). This > describes what it is doing more accurately. This is in preparation of > introducing a plain dwc2_core_reset() function that only performs the > reset and doesn't force the mode. > > Signed-off-by: John Youn > --- > drivers/usb/dwc2/core.c | 8 > drivers/usb/dwc2/core.h | 2 +- > drivers/usb/dwc2/platform.c | 2 +- > 3 files changed, 6 insertions(+), 6 deletions(-) Agree that this does a rename and said rename seems sane to me. Works across many reboots on a farm of rk3288-based devices on a 3.14 kernel. Reviewed-by: Douglas Anderson Tested-by: Douglas Anderson -- 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 10/18] usb: dwc2: Add functions to check the HW OTG config
John, On Wed, Dec 2, 2015 at 11:13 AM, John Younwrote: > Added functions to query the GHWCFG2.OTG_MODE. This tells us whether the > controller hardware is configured for OTG, device-only, or host-only. > > Signed-off-by: John Youn > --- > drivers/usb/dwc2/core.c | 37 + > drivers/usb/dwc2/core.h | 13 + > 2 files changed, 50 insertions(+) On a backport to 3.14 on rk3288, confirmed that one port is properly identified as host only and the other as OTG. Specifically: dwc2_hw_is_device() = false on both ports dwc2_hw_is_host() = true on host only port, false on otg port dwc2_hw_is_otg() = true on otg port (didn't test on host only port, but by code inspection should be right). These functions also look sane according to the databook, so feel free to add: Tested-by: Douglas Anderson Reviewed-by: Douglas Anderson -- 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 07/18] usb: dwc2: Reorder AHBIDLE and CSFTRST in dwc2_core_reset()
John, On Wed, Dec 2, 2015 at 11:13 AM, John Younwrote: > According to the databook, the core soft reset should be done before > checking for AHBIDLE. The gadget version of core reset had it correct > but the hcd version did not. This fixes the hcd version. > > Signed-off-by: John Youn > --- > drivers/usb/dwc2/core.c | 17 + > 1 file changed, 9 insertions(+), 8 deletions(-) Seems fine to me and works across many reboots on a farm of rk3288-based devices on a 3.14 kernel. Doesn't fix any problems that I've seen, though. Reviewed-by: Douglas Anderson Tested-by: Douglas Anderson -- 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 14/18] usb: dwc2: Add functions to set and clear force mode
John, On Wed, Dec 2, 2015 at 11:14 AM, John Younwrote: > Added functions to set force mode for host and device. These functions > will check the current mode and only force if needed. > > Signed-off-by: John Youn > --- > drivers/usb/dwc2/core.c | 54 > + > 1 file changed, 54 insertions(+) > > diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c > index 7090050..caaff42 100644 > --- a/drivers/usb/dwc2/core.c > +++ b/drivers/usb/dwc2/core.c > @@ -3105,6 +3105,60 @@ void dwc2_set_parameters(struct dwc2_hsotg *hsotg, > dwc2_set_param_hibernation(hsotg, params->hibernation); > } > > +/* > + * Force host mode if not in host mode. Returns true if the mode was > + * forced. > + */ > +static bool dwc2_force_host_if_needed(struct dwc2_hsotg *hsotg) > +{ > + u32 gusbcfg; > + > + if (dwc2_is_host_mode(hsotg)) > + return false; > + > + gusbcfg = dwc2_readl(hsotg->regs + GUSBCFG); > + gusbcfg &= ~GUSBCFG_FORCEDEVMODE; > + gusbcfg |= GUSBCFG_FORCEHOSTMODE; > + dwc2_writel(gusbcfg, hsotg->regs + GUSBCFG); > + usleep_range(25000, 5); > + > + return true; > +} > + > +/* > + * Force device mode if not in device mode. Returns true if the mode > + * was forced. > + */ > +static bool dwc2_force_device_if_needed(struct dwc2_hsotg *hsotg) > +{ > + u32 gusbcfg; > + > + if (dwc2_is_device_mode(hsotg)) > + return false; > + > + gusbcfg = dwc2_readl(hsotg->regs + GUSBCFG); > + gusbcfg &= ~GUSBCFG_FORCEHOSTMODE; > + gusbcfg |= GUSBCFG_FORCEDEVMODE; > + dwc2_writel(gusbcfg, hsotg->regs + GUSBCFG); > + usleep_range(25000, 5); > + > + return true; > +} > + > +/* > + * Clears the force mode bits. > + */ > +static void dwc2_clear_force_mode(struct dwc2_hsotg *hsotg) > +{ > + u32 gusbcfg; > + > + gusbcfg = dwc2_readl(hsotg->regs + GUSBCFG); > + gusbcfg &= ~GUSBCFG_FORCEHOSTMODE; > + gusbcfg &= ~GUSBCFG_FORCEDEVMODE; > + dwc2_writel(gusbcfg, hsotg->regs + GUSBCFG); > + usleep_range(25000, 5); > +} > + Other than same comments as "usb: dwc2: Reduce delay when forcing mode in reset" (decrease range to 25000, 3 or use msleep), this looks good to me. Optionally I'd think it might be worth it to add: WARN_ON(hsotg->dr_mode == USB_DR_MODE_HOST) ...in dwc2_force_device_if_needed() and in dwc2_clear_force_mode() ...and WARN_ON(hsotg->dr_mode == USB_DR_MODE_PERIPHERAL) ...in dwc2_force_host_if_needed() and in dwc2_clear_force_mode() AKA: make it clear that the caller was expected to check these things. This is tested on some rk3288-based devices with a 3.14 kernel. Reviewed-by: Douglas Anderson Tested-by: Douglas Anderson -Doug -- 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 8/9] xhci: USB 3.1 add default Speed Attributes to SuperSpeedPlus device capability
If a xhci controller does not provide a protocol speed ID (PSI) table, a default one should be used instead. Add the default values to the SuperSpeedPlus device capability. Overwrite the default ones if a PSI table exists. See xHCI 1.1 sectio 7.2.2.1.1 for more info Signed-off-by: Mathias Nyman--- drivers/usb/host/xhci-hub.c | 27 ++- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index 0863d8a..2c26ab50 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c @@ -50,14 +50,18 @@ static u8 usb_bos_descriptor [] = { 0x00, /* bU1DevExitLat, set later. */ 0x00, 0x00, /* __le16 bU2DevExitLat, set later. */ /* Second device capability, SuperSpeedPlus */ - 0x0c, /* bLength 12, will be adjusted later */ + 0x1c, /* bLength 28, will be adjusted later */ USB_DT_DEVICE_CAPABILITY, /* Device Capability */ USB_SSP_CAP_TYPE, /* bDevCapabilityType SUPERSPEED_PLUS */ 0x00, /* bReserved 0 */ - 0x00, 0x00, 0x00, 0x00, /* bmAttributes, get from xhci psic */ - 0x00, 0x00, /* wFunctionalitySupport */ + 0x23, 0x00, 0x00, 0x00, /* bmAttributes, SSAC=3 SSIC=1 */ + 0x01, 0x00, /* wFunctionalitySupport */ 0x00, 0x00, /* wReserved 0 */ - /* Sublink Speed Attributes are added in xhci_create_usb3_bos_desc() */ + /* Default Sublink Speed Attributes, overwrite if custom PSI exists */ + 0x34, 0x00, 0x05, 0x00, /* 5Gbps, symmetric, rx, ID = 4 */ + 0xb4, 0x00, 0x05, 0x00, /* 5Gbps, symmetric, tx, ID = 4 */ + 0x35, 0x40, 0x0a, 0x00, /* 10Gbps, SSP, symmetric, rx, ID = 5 */ + 0xb5, 0x40, 0x0a, 0x00, /* 10Gbps, SSP, symmetric, tx, ID = 5 */ }; static int xhci_create_usb3_bos_desc(struct xhci_hcd *xhci, char *buf, @@ -72,10 +76,14 @@ static int xhci_create_usb3_bos_desc(struct xhci_hcd *xhci, char *buf, ssp_cap_size = sizeof(usb_bos_descriptor) - desc_size; /* does xhci support USB 3.1 Enhanced SuperSpeed */ - if (xhci->usb3_rhub.min_rev >= 0x01 && xhci->usb3_rhub.psi_uid_count) { - /* two SSA entries for each unique PSI ID, one RX and one TX */ - ssa_count = xhci->usb3_rhub.psi_uid_count * 2; - ssa_size = ssa_count * sizeof(u32); + if (xhci->usb3_rhub.min_rev >= 0x01) { + /* does xhci provide a PSI table for SSA speed attributes? */ + if (xhci->usb3_rhub.psi_count) { + /* two SSA entries for each unique PSI ID, RX and TX */ + ssa_count = xhci->usb3_rhub.psi_uid_count * 2; + ssa_size = ssa_count * sizeof(u32); + ssp_cap_size -= 16; /* skip copying the default SSA */ + } desc_size += ssp_cap_size; usb3_1 = true; } @@ -102,7 +110,8 @@ static int xhci_create_usb3_bos_desc(struct xhci_hcd *xhci, char *buf, put_unaligned_le16(HCS_U2_LATENCY(temp), [13]); } - if (usb3_1) { + /* If PSI table exists, add the custom speed attributes from it */ + if (usb3_1 && xhci->usb3_rhub.psi_count) { u32 ssp_cap_base, bm_attrib, psi; int offset; -- 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 5/9] usb: Support USB 3.1 extended port status request
usb 3.1 extend the hub get-port-status request by adding different request types. the new request types return 4 additional bytes called extended port status, these bytes are returned after the regular portstatus and portchange values. The extended port status contains a speed ID for the currently used sublink speed. A table of supported Speed IDs with details about the link is provided by the hub in the device descriptor BOS SuperSpeedPlus device capability Sublink Speed Attributes. Support this new request. Ask for the extended port status after port reset if hub supports USB 3.1. If link is running at SuperSpeedPlus set the device speed to USB_SPEED_SUPER_PLUS Signed-off-by: Mathias Nyman--- drivers/usb/core/hcd.c| 8 - drivers/usb/core/hub.c| 70 +-- drivers/usb/core/hub.h| 7 + include/uapi/linux/usb/ch11.h | 21 + 4 files changed, 96 insertions(+), 10 deletions(-) diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index bca13a0..9af9506 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -668,9 +668,15 @@ nongeneric: /* non-generic request */ switch (typeReq) { case GetHubStatus: - case GetPortStatus: len = 4; break; + case GetPortStatus: + if (wValue == HUB_PORT_STATUS) + len = 4; + else + /* other port status types return 8 bytes */ + len = 8; + break; case GetHubDescriptor: len = sizeof (struct usb_hub_descriptor); break; diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 79c08a3..e3423f1 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -533,29 +533,34 @@ static int get_hub_status(struct usb_device *hdev, /* * USB 2.0 spec Section 11.24.2.7 + * USB 3.1 takes into use the wValue and wLength fields, spec Section 10.16.2.6 */ static int get_port_status(struct usb_device *hdev, int port1, - struct usb_port_status *data) + void *data, u16 value, u16 length) { int i, status = -ETIMEDOUT; for (i = 0; i < USB_STS_RETRIES && (status == -ETIMEDOUT || status == -EPIPE); i++) { status = usb_control_msg(hdev, usb_rcvctrlpipe(hdev, 0), - USB_REQ_GET_STATUS, USB_DIR_IN | USB_RT_PORT, 0, port1, - data, sizeof(*data), USB_STS_TIMEOUT); + USB_REQ_GET_STATUS, USB_DIR_IN | USB_RT_PORT, value, + port1, data, length, USB_STS_TIMEOUT); } return status; } -static int hub_port_status(struct usb_hub *hub, int port1, - u16 *status, u16 *change) +static int hub_ext_port_status(struct usb_hub *hub, int port1, int type, + u16 *status, u16 *change, u32 *ext_status) { int ret; + int len = 4; + + if (type != HUB_PORT_STATUS) + len = 8; mutex_lock(>status_mutex); - ret = get_port_status(hub->hdev, port1, >status->port); - if (ret < 4) { + ret = get_port_status(hub->hdev, port1, >status->port, type, len); + if (ret < len) { if (ret != -ENODEV) dev_err(hub->intfdev, "%s failed (err = %d)\n", __func__, ret); @@ -564,13 +569,22 @@ static int hub_port_status(struct usb_hub *hub, int port1, } else { *status = le16_to_cpu(hub->status->port.wPortStatus); *change = le16_to_cpu(hub->status->port.wPortChange); - + if (type != HUB_PORT_STATUS && ext_status) + *ext_status = le32_to_cpu( + hub->status->port.dwExtPortStatus); ret = 0; } mutex_unlock(>status_mutex); return ret; } +static int hub_port_status(struct usb_hub *hub, int port1, + u16 *status, u16 *change) +{ + return hub_ext_port_status(hub, port1, HUB_PORT_STATUS, + status, change, NULL); +} + static void kick_hub_wq(struct usb_hub *hub) { struct usb_interface *intf; @@ -2592,6 +2606,32 @@ out_authorized: return result; } +/* + * Return 1 if port speed is SuperSpeedPlus, 0 otherwise + * check it from the link protocol field of the current speed ID attribute. + * current speed ID is got from ext port status request. Sublink speed attribute + * table is returned with the hub BOS SSP device capability descriptor + */ +static int port_speed_is_ssp(struct usb_device *hdev, int speed_id) +{ + int ssa_count; + u32 ss_attr; + int i; +
[PATCH v2 9/9] xhci: set slot context speed field to SuperSpeedPlus for USB 3.1 SSP devices
The speed field of the input slot context should represent the speed the device is working at. Signed-off-by: Mathias Nyman--- drivers/usb/host/xhci-mem.c | 3 +++ drivers/usb/host/xhci.h | 1 + 2 files changed, 4 insertions(+) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 1c37988..5cdb25a 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -1106,6 +1106,9 @@ int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *ud slot_ctx->dev_info |= cpu_to_le32(LAST_CTX(1) | udev->route); switch (udev->speed) { case USB_SPEED_SUPER_PLUS: + slot_ctx->dev_info |= cpu_to_le32(SLOT_SPEED_SSP); + max_packets = MAX_PACKET(512); + break; case USB_SPEED_SUPER: slot_ctx->dev_info |= cpu_to_le32(SLOT_SPEED_SS); max_packets = MAX_PACKET(512); diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 9be7348..9f28bea 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -343,6 +343,7 @@ struct xhci_op_regs { #defineSLOT_SPEED_LS (XDEV_LS << 10) #defineSLOT_SPEED_HS (XDEV_HS << 10) #defineSLOT_SPEED_SS (XDEV_SS << 10) +#defineSLOT_SPEED_SSP (XDEV_SSP << 10) /* Port Indicator Control */ #define PORT_LED_OFF (0 << 14) #define PORT_LED_AMBER (1 << 14) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 1/2] usb: renesas_usbhs: add fallback compatibility strings
Hi Simon Thank you for your patch > Add fallback compatibility strings for R-Car Gen2 and Gen3. > This is in keeping with the fallback scheme being adopted wherever > appropriate for drivers for Renesas SoCs. > > Also add SoC names. > > Signed-off-by: Simon Horman> --- (snip) > Required properties: >- compatible: Must contain one of the following: > - - "renesas,usbhs-r8a7790" > - - "renesas,usbhs-r8a7791" > - - "renesas,usbhs-r8a7794" > - - "renesas,usbhs-r8a7795" > + > + - "renesas,usbhs-r8a7790" for r8a7790 (R-Car H2) compatible device > + - "renesas,usbhs-r8a7791" for r8a7791 (R-Car M2-W) compatible device > + - "renesas,usbhs-r8a7794" for r8a7794 (R-Car E2) compatible device > + - "renesas,usbhs-r8a7795" for r8a7795 (R-Car H3) compatible device > + - "renesas,rcar-gen2-usbhs" for R-Car Gen2 compatibile device > + - "renesas,rcar-gen3-usbhs" for R-Car Gen3 compatibile device > + > + When compatible with the generic version, nodes must list the > + SoC-specific version corresponding to the platform first followed > + by the generic version. I think these can be separated ? 1. document update for "renesas,usbhs-r8a77xx" 2. add new "rcar-genX" (this patch) > Example: > usbhs: usb@e659 { > - compatible = "renesas,usbhs-r8a7790"; > + compatible = "renesas,usbhs-r8a7790", "renesas,rcar-usbhs"; I think you want - compatible = "renesas,usbhs-r8a7790", "renesas,rcar-usbhs"; + compatible = "renesas,usbhs-r8a7790", "renesas,rcar-gen2-usbhs"; -- 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 4/9] usb: add device descriptor for usb 3.1 root hub
On 09.12.2015 20:35, Sergei Shtylyov wrote: Hello. On 12/09/2015 09:22 PM, Mathias Nyman wrote: Signed-off-by: Mathias Nyman--- drivers/usb/core/hcd.c | 23 +++ 1 file changed, 23 insertions(+) diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index ff3073d..fb0a9c2 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -128,6 +128,27 @@ static inline int is_root_hub(struct usb_device *udev) #define KERNEL_RELbin2bcd(((LINUX_VERSION_CODE >> 16) & 0x0ff)) #define KERNEL_VERbin2bcd(((LINUX_VERSION_CODE >> 8) & 0x0ff)) +/* usb 3.1 root hub device descriptor */ +static const u8 usb31_rh_dev_descriptor[18] = { +0x12, /* __u8 bLength; */ +0x01, /* __u8 bDescriptorType; Device */ Please use USB_DT_DEVICE here as is now done in all the other such places in this file. [...] MBR, Sergei Sure, will resend -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
[PATCH v2 7/9] xhci: set roothub speed to USB_SPEED_SUPER_PLUS for USB3.1 capable controllers
Signed-off-by: Mathias Nyman--- drivers/usb/host/xhci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index dd87be2..1044241 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -4890,6 +4890,7 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) if (xhci->sbrn == 0x31) { xhci_info(xhci, "Host supports USB 3.1 Enhanced SuperSpeed\n"); hcd->speed = HCD_USB31; + hcd->self.root_hub->speed = USB_SPEED_SUPER_PLUS; } /* xHCI private pointer was set in xhci_pci_probe for the second * registered roothub. -- 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 1/9] usb: define USB_SPEED_SUPER_PLUS speed for SuperSpeedPlus USB3.1 devices
Add a new USB_SPEED_SUPER_PLUS device speed, and make sure usb core can handle the new speed. In most cases the behaviour is the same as with USB_SPEED_SUPER SuperSpeed devices. In a few places we add a "Plus" string to inform the user of the new speed. Signed-off-by: Mathias Nyman--- drivers/usb/common/common.c | 1 + drivers/usb/core/config.c| 3 ++- drivers/usb/core/devices.c | 10 ++ drivers/usb/core/hcd-pci.c | 2 +- drivers/usb/core/hcd.c | 6 +++--- drivers/usb/core/hub.c | 26 +++--- drivers/usb/core/urb.c | 3 ++- drivers/usb/core/usb.h | 2 +- include/uapi/linux/usb/ch9.h | 1 + 9 files changed, 32 insertions(+), 22 deletions(-) diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c index 673d530..a00bfb9 100644 --- a/drivers/usb/common/common.c +++ b/drivers/usb/common/common.c @@ -50,6 +50,7 @@ static const char *const speed_names[] = { [USB_SPEED_HIGH] = "high-speed", [USB_SPEED_WIRELESS] = "wireless", [USB_SPEED_SUPER] = "super-speed", + [USB_SPEED_SUPER_PLUS] = "super-speed-plus", }; const char *usb_speed_string(enum usb_device_speed speed) diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c index 7caff02..8aca169 100644 --- a/drivers/usb/core/config.c +++ b/drivers/usb/core/config.c @@ -190,6 +190,7 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum, if (usb_endpoint_xfer_int(d)) { i = 1; switch (to_usb_device(ddev)->speed) { + case USB_SPEED_SUPER_PLUS: case USB_SPEED_SUPER: case USB_SPEED_HIGH: /* Many device manufacturers are using full-speed @@ -273,7 +274,7 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum, } /* Parse a possible SuperSpeed endpoint companion descriptor */ - if (to_usb_device(ddev)->speed == USB_SPEED_SUPER) + if (to_usb_device(ddev)->speed >= USB_SPEED_SUPER) usb_parse_ss_endpoint_companion(ddev, cfgno, inum, asnum, endpoint, buffer, size); diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c index 2a3bbdf..332ed27 100644 --- a/drivers/usb/core/devices.c +++ b/drivers/usb/core/devices.c @@ -221,7 +221,7 @@ static char *usb_dump_endpoint_descriptor(int speed, char *start, char *end, break; case USB_ENDPOINT_XFER_INT: type = "Int."; - if (speed == USB_SPEED_HIGH || speed == USB_SPEED_SUPER) + if (speed == USB_SPEED_HIGH || speed >= USB_SPEED_SUPER) interval = 1 << (desc->bInterval - 1); else interval = desc->bInterval; @@ -230,7 +230,7 @@ static char *usb_dump_endpoint_descriptor(int speed, char *start, char *end, return start; } interval *= (speed == USB_SPEED_HIGH || -speed == USB_SPEED_SUPER) ? 125 : 1000; +speed >= USB_SPEED_SUPER) ? 125 : 1000; if (interval % 1000) unit = 'u'; else { @@ -322,7 +322,7 @@ static char *usb_dump_config_descriptor(char *start, char *end, if (start > end) return start; - if (speed == USB_SPEED_SUPER) + if (speed >= USB_SPEED_SUPER) mul = 8; else mul = 2; @@ -534,6 +534,8 @@ static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes, speed = "480"; break; case USB_SPEED_SUPER: speed = "5000"; break; + case USB_SPEED_SUPER_PLUS: + speed = "1"; break; default: speed = "??"; } @@ -553,7 +555,7 @@ static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes, /* super/high speed reserves 80%, full/low reserves 90% */ if (usbdev->speed == USB_SPEED_HIGH || - usbdev->speed == USB_SPEED_SUPER) + usbdev->speed >= USB_SPEED_SUPER) max = 800; else max = FRAME_TIME_MAX_USECS_ALLOC; diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c index 9eb1cff..22a9ac2 100644 --- a/drivers/usb/core/hcd-pci.c +++ b/drivers/usb/core/hcd-pci.c @@ -197,7 +197,7 @@ int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) * The xHCI driver has its own irq management * make sure irq setup is not touched for xhci in generic hcd code */ - if ((driver->flags & HCD_MASK) != HCD_USB3) { + if ((driver->flags & HCD_MASK) < HCD_USB3) { if (!dev->irq) { dev_err(>dev, "Found HC with no IRQ. Check BIOS/PCI %s setup!\n", diff --git a/drivers/usb/core/hcd.c
[PATCH v2 3/9] usb: show speed "10000" in sysfs for USB 3.1 SuperSpeedPlus devices
The same way as SuperSpeed devices show "5000" as device speed we wan't to show "1" as the default speed for SuperSpeedPlus devices in sysfs. Signed-off-by: Mathias Nyman--- drivers/usb/core/sysfs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c index 65b6e6b..f195320 100644 --- a/drivers/usb/core/sysfs.c +++ b/drivers/usb/core/sysfs.c @@ -141,6 +141,9 @@ static ssize_t speed_show(struct device *dev, struct device_attribute *attr, case USB_SPEED_SUPER: speed = "5000"; break; + case USB_SPEED_SUPER_PLUS: + speed = "1"; + break; default: speed = "unknown"; } -- 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