Re: [PATCH] Regression fix revert: "Bluetooth: Add missing reset_resume dev_pm_ops"
Hi, On 10/03/2013 05:39 AM, Marcel Holtmann wrote: Hi Gustavo, Many btusb devices have 2 modes, a hid mode and a bluetooth hci mode. These devices default to hid mode for BIOS use. This means that after having been reset they will revert to HID mode, and are no longer usable as a HCI. Therefor it is a very bad idea to just blindly make reset_resume point to the regular resume handler. Note that the btusb driver has no clue how to switch these devices from hid to hci mode, this is done in userspace through udev rules, so the proper way to deal with this is to not have a reset-resume handler and instead let the usb-system re-enumerate the device, and re-run the udev rules. I must also note, that the commit message for the commit causing this problem has a very weak motivation for the change: "Add missing reset_resume dev_pm_ops. Missing reset_resume results in the following message after power management device test. This change sets reset_resume to btusb_resume(). [ 2506.936134] btusb 1-1.5:1.0: no reset_resume for driver btusb? [ 2506.936137] btusb 1-1.5:1.1: no reset_resume for driver btusb?" Making a change solely to silence a warning while also changing important behavior (normal resume handling versus re-enumeration) requires a commit message with a proper explanation why it is safe to do so, which clearly lacks here, and unsurprisingly it turns out to not be safe to make this change. Reverting the commit in question fixes bt no longer working on my Dell E6430 after a suspend/resume, and I believe it likely also fixes the following bugs: https://bugzilla.redhat.com/show_bug.cgi?id=988481 https://bugzilla.redhat.com/show_bug.cgi?id=1010649 https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1213239 This reverts commit 502f769662978a2fe99d0caed5e53e3006107381. Cc: Shuah Khan Cc: Gustavo Padovan Cc: sta...@vger.kernel.org Signed-off-by: Hans de Goede --- drivers/bluetooth/btusb.c | 1 - 1 file changed, 1 deletion(-) Patch has been applied to bluetooth.git. Thanks. why? Because we have one broken Dell Bluetooth dongle. Well for one, because we have a no regressions policy. For another because the original patch does not actually fix anything (according to the original commit message), it just silences a warning (with a way too big hammer). Do we actually know how this affects other chips. In the mean time I have confirmation that the reset_resume patch also breaks intel hci's (embedded in their wlan cards, 8087:07da) after suspend/resume, and that reverting it also fixes this. To be precise I've confirmation that downgrading to 3.10 which lacks this patch fixes the intel hci issues, see: https://bugzilla.redhat.com/show_bug.cgi?id=988481 The dell HID Proxy thing has always been special case and that is Dell's fault. And the Logitech HID proxy, and various devices with broadcom chips ... Look at the extra code that we have in hid2hci tool and its udev rules for Dell hardware. Is anybody actually willing to investigate this one properly. If people really want a reset_resume handler, then a lot more works need to be done then just making reset_resume point to the current resume handler. reset_resume gets called when on resume the usb subsys sees that the device has lost power, iow the device has had a hard reset, and all device state is gone. The current btusb resume handler was never written with the assumption that all device state is gone. All it does is resubmit a bunch of urbs, it does not restore any device state, therefor it is unsuitable as a reset_resume handler. Regards, Hans -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
usbserial_generic does not recognize Inovia SEW858 (or TE W120) 3G modem
Hello world! Greg Kroah-Hartman asked me to post this to linux-usb mailing list. Inovia SEW858 (or TE W120) 3G modem is a device with three virtual serial ports, it has VID=0x20a6 and PID=0x1105. To make use of this modem one have to issue $ sudo modprobe -v usbserial vendor=0x20a6 product=0x1105 It is inconvenient to issue such a command or write udev rule for it. It would be better for kernel USB driver to recognize this modem. I've also filed this bug at https://bugzilla.kernel.org/show_bug.cgi?id=62411 Following is the output of `uname` and `lsusb` [pavel@desktop5072 ~]$ uname -a Linux desktop5072 3.11.1-1-ARCH #1 SMP PREEMPT Sat Sep 14 19:30:21 CEST 2013 x86_64 GNU/Linux [pavel@desktop5072 ~]$ lsusb -v Bus 007 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Couldn't open device, some information will be missing Device Descriptor: bLength18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass9 Hub bDeviceSubClass 0 Unused bDeviceProtocol 0 Full speed (or root) hub bMaxPacketSize064 idVendor 0x1d6b Linux Foundation idProduct 0x0002 2.0 root hub bcdDevice3.11 iManufacturer 3 iProduct2 iSerial 1 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 25 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xe0 Self Powered Remote Wakeup MaxPower0mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber0 bAlternateSetting 0 bNumEndpoints 1 bInterfaceClass 9 Hub bInterfaceSubClass 0 Unused bInterfaceProtocol 0 Full speed (or root) hub iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes3 Transfer TypeInterrupt Synch Type None Usage Type Data wMaxPacketSize 0x0004 1x 4 bytes bInterval 12 Bus 005 Device 002: ID 046d:c040 Logitech, Inc. Corded Tilt-Wheel Mouse Couldn't open device, some information will be missing Device Descriptor: bLength18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass0 (Defined at Interface level) bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 8 idVendor 0x046d Logitech, Inc. idProduct 0xc040 Corded Tilt-Wheel Mouse bcdDevice 24.20 iManufacturer 1 iProduct2 iSerial 0 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 34 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xa0 (Bus Powered) Remote Wakeup MaxPower 98mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber0 bAlternateSetting 0 bNumEndpoints 1 bInterfaceClass 3 Human Interface Device bInterfaceSubClass 1 Boot Interface Subclass bInterfaceProtocol 2 Mouse iInterface 0 HID Device Descriptor: bLength 9 bDescriptorType33 bcdHID 1.10 bCountryCode0 Not supported bNumDescriptors 1 bDescriptorType34 Report wDescriptorLength 59 Report Descriptors: ** UNAVAILABLE ** Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes3 Transfer TypeInterrupt Synch Type None Usage Type Data wMaxPacketSize 0x0005 1x 5 bytes bInterval 10 Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Couldn't open device, some information will be missing Device Descriptor: bLength18 bDescriptorType 1 bcdUSB 1.10 bDeviceClass9 Hub bDeviceSubClass 0 Unused bDeviceProtocol 0 Full speed (or root) hub bMaxPacketSize064 idVendor 0x1d6b Linux Foundation idProduct 0x0001 1.1 root hub bcdDevice3.11 iManufacturer 3 iProduct2 iSerial 1 bNumConfigurations 1 Configuration Descript
Re: [PATCH] staging: dwc2: Make dwc2_hw_params.host_channels large enough
Hi Paul, > By the way, it looks like 'num_dev_ep' would have the same problem, I don't think so, since the hardware doesn't do the off-by-one trick there (presumably because having 0 endpoints make sense, but 0 host channels doesn't): hw->num_dev_ep = (hwcfg2 & GHWCFG2_NUM_DEV_EP_MASK) >> GHWCFG2_NUM_DEV_EP_SHIFT; > except it is not used because we don't support device mode yet. > That one and also 'num_dev_perio_in_ep' and 'dev_token_q_depth' should > be removed, I think. Doesn't hurt to keep them around, I think? When device mode is implemented, I guess this code will need to present exactly like it is now (unlike other device mode code, which likely needs to be adapted to whatever s3-hsotg is doing now)? Gr. Matthijs signature.asc Description: Digital signature
[PATCH] staging: dwc2: Make dwc2_hw_params.host_channels large enough
The hardware offers a 4-bit register containing the number of host channels. However, the values of these register mean 1-16 host channels, not 0-15. Since the dwc2_hw_params struct stores the actual number of host channels supported instead of the raw register value, it should be 5 bits wide instead of 4. Before this commit, hardware with 16 host channels would overflow the field, making it appear as 0 channels. This bug was introduced in commit 9badec2 (staging: dwc2: interpret all hwcfg and related register at init time). Reported-by: Dinh Nguyen Signed-off-by: Matthijs Kooijman Acked-by: Paul Zimmerman --- This is exactly the same patch as before, but with updated tags in the commit message. drivers/staging/dwc2/core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/dwc2/core.h b/drivers/staging/dwc2/core.h index f7ba34b..fab718d 100644 --- a/drivers/staging/dwc2/core.h +++ b/drivers/staging/dwc2/core.h @@ -294,7 +294,7 @@ struct dwc2_hw_params { unsigned dev_token_q_depth:5; unsigned max_transfer_size:26; unsigned max_packet_count:11; - unsigned host_channels:4; + unsigned host_channels:5; unsigned hs_phy_type:2; unsigned fs_phy_type:2; unsigned i2c_enable:1; -- 1.8.4.rc1 -- 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 v8 5/8] usb: musb: omap2430: Don't use omap_get_control_dev()
omap_get_control_dev() is being deprecated as it doesn't support multiple instances. As control device is present only from OMAP4 onwards which supports DT only, we use phandles to get the reference to the control device. Also get rid of "ti,has-mailbox" property as it is redundant and we can determine that from whether "ctrl-module" property is present or not. Get rid of has_mailbox from musb_hdrc_platform_data as well. Signed-off-by: Roger Quadros --- Documentation/devicetree/bindings/usb/omap-usb.txt |4 --- drivers/usb/musb/omap2430.c| 25 +++ include/linux/usb/musb.h |2 - 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/omap-usb.txt b/Documentation/devicetree/bindings/usb/omap-usb.txt index 9add35c..090e5e2 100644 --- a/Documentation/devicetree/bindings/usb/omap-usb.txt +++ b/Documentation/devicetree/bindings/usb/omap-usb.txt @@ -3,9 +3,6 @@ OMAP GLUE AND OTHER OMAP SPECIFIC COMPONENTS OMAP MUSB GLUE - compatible : Should be "ti,omap4-musb" or "ti,omap3-musb" - ti,hwmods : must be "usb_otg_hs" - - ti,has-mailbox : to specify that omap uses an external mailbox - (in control module) to communicate with the musb core during device connect - and disconnect. - multipoint : Should be "1" indicating the musb controller supports multipoint. This is a MUSB configuration-specific setting. - num-eps : Specifies the number of endpoints. This is also a @@ -31,7 +28,6 @@ SOC specific device node entry usb_otg_hs: usb_otg_hs@4a0ab000 { compatible = "ti,omap4-musb"; ti,hwmods = "usb_otg_hs"; - ti,has-mailbox; multipoint = <1>; num-eps = <16>; ram-bits = <12>; diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index d0fc4d9..9eab645 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c @@ -38,6 +38,7 @@ #include #include #include +#include #include "musb_core.h" #include "omap2430.h" @@ -524,8 +525,12 @@ static int omap2430_probe(struct platform_device *pdev) glue->dev = &pdev->dev; glue->musb = musb; glue->status= OMAP_MUSB_UNKNOWN; + glue->control_otghs = ERR_PTR(-ENODEV); if (np) { + struct device_node *control_node; + struct platform_device *control_pdev; + pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) { dev_err(&pdev->dev, @@ -554,22 +559,20 @@ static int omap2430_probe(struct platform_device *pdev) of_property_read_u32(np, "ram-bits", (u32 *)&config->ram_bits); of_property_read_u32(np, "power", (u32 *)&pdata->power); config->multipoint = of_property_read_bool(np, "multipoint"); - pdata->has_mailbox = of_property_read_bool(np, - "ti,has-mailbox"); pdata->board_data = data; pdata->config = config; - } - if (pdata->has_mailbox) { - glue->control_otghs = omap_get_control_dev(); - if (IS_ERR(glue->control_otghs)) { - dev_vdbg(&pdev->dev, "Failed to get control device\n"); - ret = PTR_ERR(glue->control_otghs); - goto err2; + control_node = of_parse_phandle(np, "ctrl-module", 0); + if (control_node) { + control_pdev = of_find_device_by_node(control_node); + if (!control_pdev) { + dev_err(&pdev->dev, "Failed to get control device\n"); + ret = -EINVAL; + goto err2; + } + glue->control_otghs = &control_pdev->dev; } - } else { - glue->control_otghs = ERR_PTR(-ENODEV); } pdata->platform_ops = &omap2430_ops; diff --git a/include/linux/usb/musb.h b/include/linux/usb/musb.h index 053c268..eb50525 100644 --- a/include/linux/usb/musb.h +++ b/include/linux/usb/musb.h @@ -99,8 +99,6 @@ struct musb_hdrc_platform_data { /* MUSB_HOST, MUSB_PERIPHERAL, or MUSB_OTG */ u8 mode; - u8 has_mailbox:1; - /* for clk_get() */ const char *clock; -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v8 7/8] usb: phy: omap: get rid of omap_get_control_dev()
This function was preventing us from supporting multiple instances. Get rid of it. Since we support DT boots only, users can get the control device phandle from the DT node. Signed-off-by: Roger Quadros --- drivers/usb/phy/phy-omap-control.c | 31 ++- include/linux/usb/omap_control_usb.h |5 - 2 files changed, 10 insertions(+), 26 deletions(-) diff --git a/drivers/usb/phy/phy-omap-control.c b/drivers/usb/phy/phy-omap-control.c index 1c8a7c5..09c5ace 100644 --- a/drivers/usb/phy/phy-omap-control.c +++ b/drivers/usb/phy/phy-omap-control.c @@ -26,26 +26,6 @@ #include #include -static struct omap_control_usb *control_usb; - -/** - * omap_get_control_dev - returns the device pointer for this control device - * - * This API should be called to get the device pointer for this control - * module device. This device pointer should be used for called other - * exported API's in this driver. - * - * To be used by PHY driver and glue driver. - */ -struct device *omap_get_control_dev(void) -{ - if (!control_usb) - return ERR_PTR(-ENODEV); - - return control_usb->dev; -} -EXPORT_SYMBOL_GPL(omap_get_control_dev); - /** * omap_control_usb_phy_power - power on/off the phy using control module reg * @dev: the control module device @@ -182,11 +162,19 @@ void omap_control_usb_set_mode(struct device *dev, { struct omap_control_usb *ctrl_usb; - if (IS_ERR(dev) || control_usb->type != OMAP_CTRL_TYPE_OTGHS) + if (IS_ERR(dev) || !dev) return; ctrl_usb = dev_get_drvdata(dev); + if (!ctrl_usb) { + dev_err(dev, "Invalid control usb device\n"); + return; + } + + if (ctrl_usb->type != OMAP_CTRL_TYPE_OTGHS) + return; + switch (mode) { case USB_MODE_HOST: omap_control_usb_host_mode(ctrl_usb); @@ -237,6 +225,7 @@ static int omap_control_usb_probe(struct platform_device *pdev) { struct resource *res; const struct of_device_id *of_id; + struct omap_control_usb *control_usb; of_id = of_match_device(of_match_ptr(omap_control_usb_id_table), &pdev->dev); diff --git a/include/linux/usb/omap_control_usb.h b/include/linux/usb/omap_control_usb.h index 61b889a..596b019 100644 --- a/include/linux/usb/omap_control_usb.h +++ b/include/linux/usb/omap_control_usb.h @@ -65,15 +65,10 @@ enum omap_control_usb_mode { #define OMAP_CTRL_USB2_PHY_PD BIT(28) #if IS_ENABLED(CONFIG_OMAP_CONTROL_USB) -extern struct device *omap_get_control_dev(void); extern void omap_control_usb_phy_power(struct device *dev, int on); extern void omap_control_usb_set_mode(struct device *dev, enum omap_control_usb_mode mode); #else -static inline struct device *omap_get_control_dev(void) -{ - return ERR_PTR(-ENODEV); -} static inline void omap_control_usb_phy_power(struct device *dev, int on) { -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v8 8/8] ARM: dts: omap5: update omap-control-usb node
Split USB2 PHY and USB3 PHY into separate omap-control-usb nodes. Get rid of "ti,type" property. CC: Benoit Cousson Signed-off-by: Roger Quadros --- arch/arm/boot/dts/omap5.dtsi | 20 1 files changed, 12 insertions(+), 8 deletions(-) diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi index 7cdea1b..c0ec6dc 100644 --- a/arch/arm/boot/dts/omap5.dtsi +++ b/arch/arm/boot/dts/omap5.dtsi @@ -626,12 +626,16 @@ hw-caps-temp-alert; }; - omap_control_usb: omap-control-usb@4a002300 { - compatible = "ti,omap-control-usb"; - reg = <0x4a002300 0x4>, - <0x4a002370 0x4>; - reg-names = "control_dev_conf", "phy_power_usb"; - ti,type = <2>; + omap_control_usb2phy: control-phy@4a002300 { + compatible = "ti,control-phy-usb2"; + reg = <0x4a002300 0x4>; + reg-names = "power"; + }; + + omap_control_usb3phy: control-phy@4a002370 { + compatible = "ti,control-phy-pipe3"; + reg = <0x4a002370 0x4>; + reg-names = "power"; }; omap_dwc3@4a02 { @@ -662,7 +666,7 @@ usb2_phy: usb2phy@4a084000 { compatible = "ti,omap-usb2"; reg = <0x4a084000 0x7c>; - ctrl-module = <&omap_control_usb>; + ctrl-module = <&omap_control_usb2phy>; }; usb3_phy: usb3phy@4a084400 { @@ -671,7 +675,7 @@ <0x4a084800 0x64>, <0x4a084c00 0x40>; reg-names = "phy_rx", "phy_tx", "pll_ctrl"; - ctrl-module = <&omap_control_usb>; + ctrl-module = <&omap_control_usb3phy>; }; }; -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v8 4/8] usb: phy: omap-usb3: Don't use omap_get_control_dev()
omap_get_control_dev() is being deprecated as it doesn't support multiple instances. As control device is present only from OMAP4 onwards which supports DT only, we use phandles to get the reference to the control device. As we don't support non-DT boot, we just bail out on probe if device node is not present. Signed-off-by: Roger Quadros --- drivers/usb/phy/phy-omap-usb3.c | 26 -- 1 files changed, 20 insertions(+), 6 deletions(-) diff --git a/drivers/usb/phy/phy-omap-usb3.c b/drivers/usb/phy/phy-omap-usb3.c index 0824be4..0c6ba29 100644 --- a/drivers/usb/phy/phy-omap-usb3.c +++ b/drivers/usb/phy/phy-omap-usb3.c @@ -26,6 +26,7 @@ #include #include #include +#include #definePLL_STATUS 0x0004 #definePLL_GO 0x0008 @@ -196,8 +197,14 @@ static int omap_usb3_init(struct usb_phy *x) static int omap_usb3_probe(struct platform_device *pdev) { - struct omap_usb *phy; - struct resource *res; + struct omap_usb *phy; + struct resource *res; + struct device_node *node = pdev->dev.of_node; + struct device_node *control_node; + struct platform_device *control_pdev; + + if (!node) + return -EINVAL; phy = devm_kzalloc(&pdev->dev, sizeof(*phy), GFP_KERNEL); if (!phy) { @@ -239,11 +246,18 @@ static int omap_usb3_probe(struct platform_device *pdev) return -EINVAL; } - phy->control_dev = omap_get_control_dev(); - if (IS_ERR(phy->control_dev)) { - dev_dbg(&pdev->dev, "Failed to get control device\n"); - return -ENODEV; + control_node = of_parse_phandle(node, "ctrl-module", 0); + if (!control_node) { + dev_err(&pdev->dev, "Failed to get control device phandle\n"); + return -EINVAL; } + control_pdev = of_find_device_by_node(control_node); + if (!control_pdev) { + dev_err(&pdev->dev, "Failed to get control device\n"); + return -EINVAL; + } + + phy->control_dev = &control_pdev->dev; omap_control_usb_phy_power(phy->control_dev, 0); usb_add_phy_dev(&phy->phy); -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v8 2/8] usb: phy: omap: Add new device types and remove omap_control_usb3_phy_power()
Add support for new device types and in the process rid of "ti,type" device tree property. The correct type of device will be determined from the compatible string instead. Introduce a compatible string for each device type. At the moment we support 4 types OTGHS, USB2, PIPE3 (e.g. USB3) and DRA7USB2. Update DT binding information to reflect these changes. Also get rid of omap_control_usb3_phy_power(). Just one function i.e. omap_control_usb_phy_power() will now take care of all PHY types. Signed-off-by: Roger Quadros --- Documentation/devicetree/bindings/usb/omap-usb.txt | 30 ++-- drivers/usb/phy/phy-omap-control.c | 173 +++ drivers/usb/phy/phy-omap-usb3.c|6 +- include/linux/usb/omap_control_usb.h | 24 ++-- 4 files changed, 130 insertions(+), 103 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/omap-usb.txt b/Documentation/devicetree/bindings/usb/omap-usb.txt index 661cb06..9add35c 100644 --- a/Documentation/devicetree/bindings/usb/omap-usb.txt +++ b/Documentation/devicetree/bindings/usb/omap-usb.txt @@ -83,22 +83,22 @@ omap_dwc3 { OMAP CONTROL USB Required properties: - - compatible: Should be "ti,omap-control-usb" + - compatible: Should be one of + "ti,control-phy-otghs" - if it has otghs_control mailbox register as on OMAP4. + "ti,control-phy-usb2" - if it has Power down bit in control_dev_conf register + e.g. USB2_PHY on OMAP5. + "ti,control-phy-pipe3" - if it has DPLL and individual Rx & Tx power control + e.g. USB3 PHY and SATA PHY on OMAP5. + "ti,control-phy-dra7usb2" - if it has power down register like USB2 PHY on + DRA7 platform. - reg : Address and length of the register set for the device. It contains - the address of "control_dev_conf" and "otghs_control" or "phy_power_usb" - depending upon omap4 or omap5. - - reg-names: The names of the register addresses corresponding to the registers - filled in "reg". - - ti,type: This is used to differentiate whether the control module has - usb mailbox or usb3 phy power. omap4 has usb mailbox in control module to - notify events to the musb core and omap5 has usb3 phy power register to - power on usb3 phy. Should be "1" if it has mailbox and "2" if it has usb3 - phy power. + the address of "otghs_control" for control-phy-otghs or "power" register + for other types. + - reg-names: should be "otghs_control" control-phy-otghs and "power" for + other types. omap_control_usb: omap-control-usb@4a002300 { - compatible = "ti,omap-control-usb"; - reg = <0x4a002300 0x4>, - <0x4a00233c 0x4>; - reg-names = "control_dev_conf", "otghs_control"; - ti,type = <1>; + compatible = "ti,control-phy-otghs"; + reg = <0x4a00233c 0x4>; + reg-names = "otghs_control"; }; diff --git a/drivers/usb/phy/phy-omap-control.c b/drivers/usb/phy/phy-omap-control.c index 9772592..1c8a7c5 100644 --- a/drivers/usb/phy/phy-omap-control.c +++ b/drivers/usb/phy/phy-omap-control.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -46,61 +47,70 @@ struct device *omap_get_control_dev(void) EXPORT_SYMBOL_GPL(omap_get_control_dev); /** - * omap_control_usb3_phy_power - power on/off the serializer using control - * module + * omap_control_usb_phy_power - power on/off the phy using control module reg * @dev: the control module device - * @on: 0 to off and 1 to on based on powering on or off the PHY - * - * usb3 PHY driver should call this API to power on or off the PHY. + * @on: 0 or 1, based on powering on or off the PHY */ -void omap_control_usb3_phy_power(struct device *dev, bool on) +void omap_control_usb_phy_power(struct device *dev, int on) { u32 val; unsigned long rate; - struct omap_control_usb *control_usb = dev_get_drvdata(dev); + struct omap_control_usb *control_usb; - if (control_usb->type != OMAP_CTRL_DEV_TYPE2) + if (IS_ERR(dev) || !dev) { + pr_err("%s: invalid device\n", __func__); return; + } - rate = clk_get_rate(control_usb->sys_clk); - rate = rate/100; - - val = readl(control_usb->phy_power); - - if (on) { - val &= ~(OMAP_CTRL_USB_PWRCTL_CLK_CMD_MASK | - OMAP_CTRL_USB_PWRCTL_CLK_FREQ_MASK); - val |= OMAP_CTRL_USB3_PHY_TX_RX_POWERON << - OMAP_CTRL_USB_PWRCTL_CLK_CMD_SHIFT; - val |= rate << OMAP_CTRL_USB_PWRCTL_CLK_FREQ_SHIFT; - } else { - val &= ~OMAP_CTRL_USB_PWRCTL_CLK_CMD_MASK; - val |= OMAP_CTRL_USB3_PHY_TX_RX_POWEROFF << - OMAP_CTRL_USB_PWRCTL_CLK_CMD_SHIFT; + control_usb = dev_get_drvdata(dev); + if (!control_usb) { + dev_err(dev, "%s: invalid control usb device\n", __func__); + return
[PATCH v8 1/8] usb: phy: omap-control: Get rid of platform data
omap-control device is present from OMAP4 onwards which support device tree boots only. So get rid of platform data. Signed-off-by: Roger Quadros --- drivers/usb/phy/phy-omap-control.c | 12 +++- include/linux/usb/omap_control_usb.h |4 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/drivers/usb/phy/phy-omap-control.c b/drivers/usb/phy/phy-omap-control.c index a4dda8e..9772592 100644 --- a/drivers/usb/phy/phy-omap-control.c +++ b/drivers/usb/phy/phy-omap-control.c @@ -197,8 +197,6 @@ static int omap_control_usb_probe(struct platform_device *pdev) { struct resource *res; struct device_node *np = pdev->dev.of_node; - struct omap_control_usb_platform_data *pdata = - dev_get_platdata(&pdev->dev); control_usb = devm_kzalloc(&pdev->dev, sizeof(*control_usb), GFP_KERNEL); @@ -207,14 +205,10 @@ static int omap_control_usb_probe(struct platform_device *pdev) return -ENOMEM; } - if (np) { + if (np) of_property_read_u32(np, "ti,type", &control_usb->type); - } else if (pdata) { - control_usb->type = pdata->type; - } else { - dev_err(&pdev->dev, "no pdata present\n"); - return -EINVAL; - } + else + return -EINVAL; /* We only support DT boot */ control_usb->dev= &pdev->dev; diff --git a/include/linux/usb/omap_control_usb.h b/include/linux/usb/omap_control_usb.h index 27b5b8c..e2416b4 100644 --- a/include/linux/usb/omap_control_usb.h +++ b/include/linux/usb/omap_control_usb.h @@ -31,10 +31,6 @@ struct omap_control_usb { u32 type; }; -struct omap_control_usb_platform_data { - u8 type; -}; - enum omap_control_usb_mode { USB_MODE_UNDEFINED = 0, USB_MODE_HOST, -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v8 3/8] usb: phy: omap-usb2: Don't use omap_get_control_dev()
omap_get_control_dev() is being deprecated as it doesn't support multiple instances. As control device is present only from OMAP4 onwards which supports DT only, we use phandles to get the reference to the control device. As we don't support non-DT boot, we just bail out on probe if device node is not present. Signed-off-by: Roger Quadros --- drivers/phy/phy-omap-usb2.c | 31 +++ 1 files changed, 23 insertions(+), 8 deletions(-) diff --git a/drivers/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c index 4d7b4e5..bfc5c33 100644 --- a/drivers/phy/phy-omap-usb2.c +++ b/drivers/phy/phy-omap-usb2.c @@ -29,6 +29,7 @@ #include #include #include +#include /** * omap_usb2_set_comparator - links the comparator present in the sytem with @@ -145,10 +146,16 @@ static struct phy_ops ops = { static int omap_usb2_probe(struct platform_device *pdev) { - struct omap_usb *phy; - struct phy *generic_phy; - struct usb_otg *otg; - struct phy_provider *phy_provider; + struct omap_usb *phy; + struct phy *generic_phy; + struct phy_provider *phy_provider; + struct usb_otg *otg; + struct device_node *node = pdev->dev.of_node; + struct device_node *control_node; + struct platform_device *control_pdev; + + if (!node) + return -EINVAL; phy = devm_kzalloc(&pdev->dev, sizeof(*phy), GFP_KERNEL); if (!phy) { @@ -175,12 +182,20 @@ static int omap_usb2_probe(struct platform_device *pdev) if (IS_ERR(phy_provider)) return PTR_ERR(phy_provider); - phy->control_dev = omap_get_control_dev(); - if (IS_ERR(phy->control_dev)) { - dev_dbg(&pdev->dev, "Failed to get control device\n"); - return -ENODEV; + control_node = of_parse_phandle(node, "ctrl-module", 0); + if (!control_node) { + dev_err(&pdev->dev, "Failed to get control device phandle\n"); + return -EINVAL; } + control_pdev = of_find_device_by_node(control_node); + if (!control_pdev) { + dev_err(&pdev->dev, "Failed to get control device\n"); + return -EINVAL; + } + + phy->control_dev = &control_pdev->dev; + phy->is_suspended = 1; omap_control_usb_phy_power(phy->control_dev, 0); -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v8 0/8] phy: omap-usb: Support multiple instances and new types
Hi, This patchset does the following: * Get rid of omap_control_usb platform data as we support DT only. * Restructure and add support for new PHY types. We now support the following four types TYPE_OTGHS - if it has otghs_control mailbox register (e.g. on OMAP4) TYPE_USB2 - if it has Power down bit in control_dev_conf register. e.g. USB2 PHY TYPE_PIPE3 - if it has DPLL and individual Rx & Tx power control. e.g. USB3 PHY or SATA PHY TYPE_DRA7USB2 - if it has both power down and power aux registers. e.g. USB2 PHY on DRA7 * Get rid of "ti,type" DT property and introduce compatible strings for each type. * Have only one power control API "omap_control_usb_phy_power()" instead of a different one for each PHY type. * Get rid of omap_get_control_dev() so that we can support multiple instances of the control device. We take advantage of the fact that omap control USB device is only present on OMAP4 onwards and hence only supports DT boot. The users of control USB device can get a reference to it from the device node's phandle. Patches are based on greg/usb-next. Smoke tested on OMAP4 panda with MUSB in gadget mode (g_zero). You can find the patches in branch usb-control-module in git tree git://github.com/rogerq/linux.git v8: - Rebased on top of greg/usb-next to avoid conflicts - Removed patches 9 and 10 as they are not applicable v7: - Rebased on v3.12-rc1 - Updated DT compatibility ID for better readability - Renamed TYPE_OMAP4 to TYPE_OTGHS, TYPE_USB3 to TYPE_PIPE3 and TYPE_DRA7 to TYPE_DRA7USB2 v6: - addressed review comment about usage of control_usb before allocation. v5: - fixed whitespace alignment issues. v4: - removed "ti,has-mailbox" from omap-usb binding document example. v3: - return -EINVAL instead of -ENODEV on probe failure. - pass device type data through of_device_id table. - get rid of "ti,mailbox" property and "has_mailbox" from musb platform data. v2: - get rid of "ti,type" property and introduce compatible strings for each device type. cheers, -roger Roger Quadros (8): usb: phy: omap-control: Get rid of platform data usb: phy: omap: Add new device types and remove omap_control_usb3_phy_power() usb: phy: omap-usb2: Don't use omap_get_control_dev() usb: phy: omap-usb3: Don't use omap_get_control_dev() usb: musb: omap2430: Don't use omap_get_control_dev() ARM: dts: omap4: update omap-control-usb nodes usb: phy: omap: get rid of omap_get_control_dev() ARM: dts: omap5: update omap-control-usb node Documentation/devicetree/bindings/usb/omap-usb.txt | 34 ++-- arch/arm/boot/dts/omap4.dtsi | 20 ++- arch/arm/boot/dts/omap5.dtsi | 20 ++- drivers/phy/phy-omap-usb2.c| 31 +++- drivers/usb/musb/omap2430.c| 25 ++- drivers/usb/phy/phy-omap-control.c | 208 ++- drivers/usb/phy/phy-omap-usb3.c| 32 +++- include/linux/usb/musb.h |2 - include/linux/usb/omap_control_usb.h | 33 ++-- 9 files changed, 220 insertions(+), 185 deletions(-) -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v8 6/8] ARM: dts: omap4: update omap-control-usb nodes
Split otghs_ctrl and USB2 PHY power-down into separate omap-control-usb nodes. Get rid of "ti,type" property. Also get rid of "ti,has-mailbox" property from usb_otg_hs node and provide the ctrl-module phandle. CC: Benoit Cousson Signed-off-by: Roger Quadros --- arch/arm/boot/dts/omap4.dtsi | 20 1 files changed, 12 insertions(+), 8 deletions(-) diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi index 1e8e2fe..ea4054b 100644 --- a/arch/arm/boot/dts/omap4.dtsi +++ b/arch/arm/boot/dts/omap4.dtsi @@ -519,7 +519,7 @@ usb2_phy: usb2phy@4a0ad080 { compatible = "ti,omap-usb2"; reg = <0x4a0ad080 0x58>; - ctrl-module = <&omap_control_usb>; + ctrl-module = <&omap_control_usb2phy>; #phy-cells = <0>; }; }; @@ -644,12 +644,16 @@ }; }; - omap_control_usb: omap-control-usb@4a002300 { - compatible = "ti,omap-control-usb"; - reg = <0x4a002300 0x4>, - <0x4a00233c 0x4>; - reg-names = "control_dev_conf", "otghs_control"; - ti,type = <1>; + omap_control_usb2phy: control-phy@4a002300 { + compatible = "ti,control-phy-usb2"; + reg = <0x4a002300 0x4>; + reg-names = "power"; + }; + + omap_control_usbotg: control-phy@4a00233c { + compatible = "ti,control-phy-otghs"; + reg = <0x4a00233c 0x4>; + reg-names = "otghs_control"; }; usb_otg_hs: usb_otg_hs@4a0ab000 { @@ -664,7 +668,7 @@ multipoint = <1>; num-eps = <16>; ram-bits = <12>; - ti,has-mailbox; + ctrl-module = <&omap_control_usbotg>; }; }; }; -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 00/10] USB: phy: phy-nop: Manage RESET GPIO in the driver
Hi, On 09/24/2013 11:53 AM, Roger Quadros wrote: > Hi, > > Modelling the RESET line as a regulator supply wasn't a good idea > as it abuses the regulator framework and makes adaptation > code/data more complex. > > Instead, manage the RESET gpio line directly in the driver. > > This also makes us easy to migrate to a dedicated GPIO RESET controller > whenever it becomes available. > > Apart from RESET line changes this series also adds USB host support > fro beagle-xm and fixes USB OTG port on beagle. > > The full series is avilable at > git://github.com/rogerq/linux.git > in branch > phy-reset The branch is now updated based on v3.12-rc3. cheers, -roger > > *NOTE:* As there are changes to platform data, Patch 1 needs to be shared > between the arm-soc tree and usb tree. > > Patch 1 is available at repo > git://github.com/rogerq/linux.git > in branch > phy-reset-common > > Patch 2 contains the phy-nop driver changes > Patches 3 and 4 adapt legacy boot code to the phy-nop driver changes. > Patches 5, 6 and 7 adapt DT data to the binding changes. > Patch 8 is cleanup of omap3-beagle DT. > Patch 9 adds USB host support to omap3-beagle-xm using the new binding. > Patch 10 fixes USB OTG port on beagle. > > Patches are based on v3.12-rc1 > > Tested leacy boot on omap3-beagle and omap3-beagle-xm > Tested DT boot on omap3-beagle, omap3-beagle-xm and omap4-panda-es > > v3: > - Fix the Initial state of RESET line at probe time. > - Update hsusb3_reset line on omap5-uevm as well. > - Add patch 10 that fixes USB OTG port on beagle. > > v2: > - Added RESET GPIO polarity feature > - Changed to gpio_set_value_cansleep() > > cheers, > -roger > > Roger Quadros (10): > usb: phy: generic: Add gpio_reset to platform data > usb: phy: generic: Don't use regulator framework for RESET line > ARM: OMAP2+: omap-usb-host: Get rid of platform_data from struct > usbhs_phy_data > ARM: OMAP2+: usb-host: Adapt to USB phy-nop RESET line changes > ARM: dts: omap3-beagle: Use reset-gpios for hsusb2_reset > ARM: dts: omap4-panda: Use reset-gpios for hsusb1_reset > ARM: dts: omap5-uevm: Use reset-gpios for hsusb2/3_reset > ARM: dts: omap3-beagle: Make USB host pin naming consistent > ARM: dts: omap3-beagle-xm: Add USB Host support > ARM: dts: omap3-beagle: Add USB OTG PHY details > > .../devicetree/bindings/usb/usb-nop-xceiv.txt |7 +- > arch/arm/boot/dts/omap3-beagle-xm.dts | 65 +-- > arch/arm/boot/dts/omap3-beagle.dts | 44 +-- > arch/arm/boot/dts/omap4-panda-common.dtsi | 18 + > arch/arm/boot/dts/omap5-uevm.dts | 26 +-- > arch/arm/mach-omap2/board-omap3beagle.c|6 -- > arch/arm/mach-omap2/usb-host.c | 18 ++-- > arch/arm/mach-omap2/usb.h |1 - > drivers/usb/phy/phy-am335x.c |2 +- > drivers/usb/phy/phy-generic.c | 84 > +--- > drivers/usb/phy/phy-generic.h |6 +- > include/linux/usb/usb_phy_gen_xceiv.h |3 +- > 12 files changed, 153 insertions(+), 127 deletions(-) > -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 05/10] ARM: dts: omap3-beagle: Use reset-gpios for hsusb2_reset
Hi Benoit, Could you please take the device tree related patches [5 to 10] in this series? Thanks. cheers, -roger On 09/24/2013 11:53 AM, Roger Quadros wrote: > We no longer need to model the RESET line as a regulator since > the USB phy-nop driver accepts "reset-gpios" property. > > Signed-off-by: Roger Quadros > --- > arch/arm/boot/dts/omap3-beagle.dts | 13 + > 1 files changed, 1 insertions(+), 12 deletions(-) > > diff --git a/arch/arm/boot/dts/omap3-beagle.dts > b/arch/arm/boot/dts/omap3-beagle.dts > index dfd8310..71bde47 100644 > --- a/arch/arm/boot/dts/omap3-beagle.dts > +++ b/arch/arm/boot/dts/omap3-beagle.dts > @@ -44,17 +44,6 @@ > }; > }; > > - /* HS USB Port 2 RESET */ > - hsusb2_reset: hsusb2_reset_reg { > - compatible = "regulator-fixed"; > - regulator-name = "hsusb2_reset"; > - regulator-min-microvolt = <330>; > - regulator-max-microvolt = <330>; > - gpio = <&gpio5 19 0>; /* gpio_147 */ > - startup-delay-us = <7>; > - enable-active-high; > - }; > - > /* HS USB Port 2 Power */ > hsusb2_power: hsusb2_power_reg { > compatible = "regulator-fixed"; > @@ -68,7 +57,7 @@ > /* HS USB Host PHY on PORT 2 */ > hsusb2_phy: hsusb2_phy { > compatible = "usb-nop-xceiv"; > - reset-supply = <&hsusb2_reset>; > + reset-gpios = <&gpio5 19 GPIO_ACTIVE_LOW>; /* gpio_147 */ > vcc-supply = <&hsusb2_power>; > }; > > -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4] USB: gadget: epautoconf: fix ep maxpacket check
Hello, On 10/02/2013 05:48 PM, Alan Stern wrote: On Wed, 2 Oct 2013, Robert Baldyga wrote: This patch fix validation of maxpacket value given in endpoint descriptor. Add check of maxpacket for bulk endpoints. If maxpacket is not set in descriptor, it's set to maximum value for given type on endpoint in used speed. Correct maxpacket value is: FULL-SPEEDHIGH-SPEED SUPER-SPEED BULK 8, 16, 32, 64 512 1024 INTERRUPT1..64 1..1024 1..1024 ISOCHRONOUS 1..1023 1..1024 1..1024 Signed-off-by: Robert Baldyga --- Hello, This is fourth version of my patch. From last version I have removed code reporting full speed bulk maxpacket because it's not needed since maxpacket check for all speeds is performed before. It seems that this patch does a lot of things wrong. Comments below. @@ -124,37 +124,90 @@ ep_matches ( } + max = 0x7ff & usb_endpoint_maxp(desc); + /* -* If the protocol driver hasn't yet decided on wMaxPacketSize -* and wants to know the maximum possible, provide the info. +* Test if maxpacket given in descriptor isn't greater than maximum +* packet size for this endpoint */ - if (desc->wMaxPacketSize == 0) - desc->wMaxPacketSize = cpu_to_le16(ep->maxpacket); + if (ep->maxpacket < max) + return 0; - /* endpoint maxpacket size is an input parameter, except for bulk -* where it's an output parameter representing the full speed limit. -* the usb spec fixes high speed bulk maxpacket at 512 bytes. + /* +* Test if ep supports maxpacket size set in descriptor. +* If the protocol driver hasn't yet decided on wMaxPacketSize +* (when wMaxPacketSize == 0) and wants to know the maximum possible, +* provide the info. This disagrees with the kerneldoc for usb_ep_autoconfig(). For bulk endpoints, wMaxPacket is always supposed to be set to the full-speed value, regardless of what the protocol driver specifies. Hmm, it looks like all gadgets calls usb_ep_autoconfig() for full speed descriptors and after it they uses usb_assign_descriptors() function to set descriptors proper for device speed. And it works until gadget sets full speed descriptors. But what if gadget supports only high speed and don't want to set full speed descriptors? If it will use usb_ep_autoconfig() function for high speed descriptor, value of wMaxPacketSize field will change to 64. Is there any good solution for this problem or all gadgets have to support full speed? */ - max = 0x7ff & usb_endpoint_maxp(desc); switch (type) { + case USB_ENDPOINT_XFER_BULK: + /* +* LIMITS: +* full speed:64 bytes +* high speed: 512 bytes +* super speed: 1024 bytes +*/ + if (max == 0) { + if (gadget_is_superspeed(gadget)) + desc->wMaxPacketSize = cpu_to_le16(1024); + else if (gadget_is_dualspeed(gadget)) + desc->wMaxPacketSize = cpu_to_le16(512); + else + desc->wMaxPacketSize = cpu_to_le16(64); So these lines are wrong. Also, how do you know that 64 is correct for full speed? The hardware might only support 32. + } else { + if (max > 1024) + return 0; + if (!gadget_is_superspeed(gadget) && max > 512) + return 0; + if (!gadget_is_dualspeed(gadget) && max > 64) + return 0; + } For bulk endpoints, you should ignore the original value in the descriptor. All that matters is ep->maxpacket; it will override the value in the descriptor. + break; + case USB_ENDPOINT_XFER_INT: - /* INT: limit 64 bytes full speed, 1024 high/super speed */ - if (!gadget_is_dualspeed(gadget) && max > 64) - return 0; - /* FALLTHROUGH */ + /* +* LIMITS: +* full speed: 64 bytes +* high/super speed: 1024 bytes +* multiple transactions per microframe only for super speed The last comment is wrong. High speed also allows multiple interrupt transactions in a microframe. Also, why bother to spell out the limits in the comment? You're not going to use those values; you're going to use the limit in ep->maxpacket. +*/ + if (max == 0) { + if (gadget_is_dualspeed(gadget)) + desc->wMaxPacketSize = cpu_to_le16(1024); + else + desc->wMaxPacketSize = cpu_to_l
[PATCH v5 07/15] usb/gadget: f_mass_storage: create fsg_common_set_cdev for use in fsg_common_init
fsg_common_init is a lengthy function. Factor a portion of it out. Signed-off-by: Andrzej Pietrasiewicz Signed-off-by: Kyungmin Park --- drivers/usb/gadget/f_mass_storage.c | 52 +-- drivers/usb/gadget/f_mass_storage.h |3 ++ 2 files changed, 34 insertions(+), 21 deletions(-) diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 39f7f1f..61952b6 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -2800,6 +2800,35 @@ void fsg_common_set_private_data(struct fsg_common *common, void *priv) common->private_data = priv; } +int fsg_common_set_cdev(struct fsg_common *common, +struct usb_composite_dev *cdev, bool can_stall) +{ + struct usb_string *us; + int rc; + + common->gadget = cdev->gadget; + common->ep0 = cdev->gadget->ep0; + common->ep0req = cdev->req; + common->cdev = cdev; + + us = usb_gstrings_attach(cdev, fsg_strings_array, +ARRAY_SIZE(fsg_strings)); + if (IS_ERR(us)) { + rc = PTR_ERR(us); + return rc; + } + fsg_intf_desc.iInterface = us[FSG_STRING_INTERFACE].id; + + /* +* Some peripheral controllers are known not to be able to +* halt bulk endpoints correctly. If one of them is present, +* disable stalls. +*/ + common->can_stall = can_stall && !(gadget_is_at91(common->gadget)); + + return 0; +} + #define MAX_LUN_NAME_LEN 80 struct fsg_common *fsg_common_init(struct fsg_common *common, @@ -2809,7 +2838,6 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, struct usb_gadget *gadget = cdev->gadget; struct fsg_lun **curlun_it; struct fsg_lun_config *lcfg; - struct usb_string *us; int nluns, i, rc; char *pathbuf; @@ -2830,19 +2858,9 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, fsg_common_set_ops(common, cfg->ops); fsg_common_set_private_data(common, cfg->private_data); - common->gadget = gadget; - common->ep0 = gadget->ep0; - common->ep0req = cdev->req; - common->cdev = cdev; - - us = usb_gstrings_attach(cdev, fsg_strings_array, -ARRAY_SIZE(fsg_strings)); - if (IS_ERR(us)) { - rc = PTR_ERR(us); + rc = fsg_common_set_cdev(common, cdev, cfg->can_stall); + if (rc) goto error_release; - } - fsg_intf_desc.iInterface = us[FSG_STRING_INTERFACE].id; - rc = fsg_common_set_nluns(common, cfg->nluns); if (rc) @@ -2924,14 +2942,6 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, : "File-Stor Gadget"), i); - /* -* Some peripheral controllers are known not to be able to -* halt bulk endpoints correctly. If one of them is present, -* disable stalls. -*/ - common->can_stall = cfg->can_stall && - !(gadget_is_at91(common->gadget)); - /* Tell the thread to start working */ common->thread_task = diff --git a/drivers/usb/gadget/f_mass_storage.h b/drivers/usb/gadget/f_mass_storage.h index 3be09a1..547a5c6 100644 --- a/drivers/usb/gadget/f_mass_storage.h +++ b/drivers/usb/gadget/f_mass_storage.h @@ -111,6 +111,9 @@ void fsg_common_set_ops(struct fsg_common *common, void fsg_common_set_private_data(struct fsg_common *common, void *priv); +int fsg_common_set_cdev(struct fsg_common *common, + struct usb_composite_dev *cdev, bool can_stall); + void fsg_common_remove_lun(struct fsg_lun *lun, bool sysfs); void fsg_common_remove_luns(struct fsg_common *common); -- 1.7.0.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 v5 15/15] usb/gadget: f_mass_storage: add configfs support
>From this commit on f_mass_storage is available through configfs. Signed-off-by: Andrzej Pietrasiewicz Signed-off-by: Kyungmin Park --- .../ABI/testing/configfs-usb-gadget-mass-storage | 31 ++ drivers/usb/gadget/Kconfig | 11 + drivers/usb/gadget/f_mass_storage.c| 368 drivers/usb/gadget/f_mass_storage.h| 17 + 4 files changed, 427 insertions(+), 0 deletions(-) create mode 100644 Documentation/ABI/testing/configfs-usb-gadget-mass-storage diff --git a/Documentation/ABI/testing/configfs-usb-gadget-mass-storage b/Documentation/ABI/testing/configfs-usb-gadget-mass-storage new file mode 100644 index 000..e1e918e --- /dev/null +++ b/Documentation/ABI/testing/configfs-usb-gadget-mass-storage @@ -0,0 +1,31 @@ +What: /config/usb-gadget/gadget/functions/mass_storage.name +Date: Jul 2013 +KenelVersion: 3.12 +Description: + The attributes: + + stall - Set to permit function to halt bulk endpoints. + Disabled on some USB devices known not to work + correctly. You should set it to true. + num_buffers - Number of pipeline buffers. Valid numbers + are 2..4. Available only if + CONFIG_USB_GADGET_DEBUG_FILES is set. + +What: /config/usb-gadget/gadget/functions/mass_storage.name/lun.name +Date: Jul 2013 +KenelVersion: 3.12 +Description: + The attributes: + + file- The path to the backing file for the LUN. + Required if LUN is not marked as removable. + ro - Flag specifying access to the LUN shall be + read-only. This is implied if CD-ROM emulation + is enabled as well as when it was impossible + to open "filename" in R/W mode. + removable - Flag specifying that LUN shall be indicated as + being removable. + cdrom - Flag specifying that LUN shall be reported as + being a CD-ROM. + nofua - Flag specifying that FUA flag + in SCSI WRITE(10,12) diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 7d64e47..bc5dea2 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -668,6 +668,17 @@ config USB_CONFIGFS_PHONET help The Phonet protocol implementation for USB device. +config USB_CONFIGFS_MASS_STORAGE + boolean "Mass storage" + depends on USB_CONFIGFS + select USB_U_MS + select USB_F_MASS_STORAGE + help + The Mass Storage Gadget acts as a USB Mass Storage disk drive. + As its storage repository it can use a regular file or a block + device (in much the same way as the "loop" device driver), + specified as a module parameter or sysfs option. + config USB_ZERO tristate "Gadget Zero (DEVELOPMENT)" select USB_LIBCOMPOSITE diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 7dc0adf..4320eae 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -220,6 +220,7 @@ #include #include "gadget_chips.h" +#include "configfs.h" /**/ @@ -3326,6 +3327,350 @@ static int fsg_bind_config(struct usb_composite_dev *cdev, #else +static inline struct fsg_lun_opts *to_fsg_lun_opts(struct config_item *item) +{ + return container_of(to_config_group(item), struct fsg_lun_opts, group); +} + +static inline struct fsg_opts *to_fsg_opts(struct config_item *item) +{ + return container_of(to_config_group(item), struct fsg_opts, + func_inst.group); +} + +CONFIGFS_ATTR_STRUCT(fsg_lun_opts); +CONFIGFS_ATTR_OPS(fsg_lun_opts); + +static void fsg_lun_attr_release(struct config_item *item) +{ + struct fsg_lun_opts *lun_opts; + + lun_opts = to_fsg_lun_opts(item); + kfree(lun_opts); +} + +static struct configfs_item_operations fsg_lun_item_ops = { + .release= fsg_lun_attr_release, + .show_attribute = fsg_lun_opts_attr_show, + .store_attribute = fsg_lun_opts_attr_store, +}; + +static ssize_t fsg_lun_opts_file_show(struct fsg_lun_opts *opts, char *page) +{ + struct fsg_opts *fsg_opts; + + fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent); + + return fsg_show_file(opts->lun, &fsg_opts->common->filesem, page); +} + +static ssize_t fsg_lun_opts_file_store(struct fsg_lun_opts *opts, + const char *page, size_t len) +{ + struct fsg_opts *fsg_opts; + + fsg_opts = to_fsg_opts(opts->g
[PATCH v5 11/15] usb/gadget: f_mass_storage: convert to new function interface with backward compatibility
Converting mass storage to the new function interface requires converting the USB mass storage's function code and its users. This patch converts the f_mass_storage.c to the new function interface. The file is now compiled into a separate usb_f_mass_storage.ko module. The old function interface is provided by means of a preprocessor conditional directives. After all users are converted, the old interface can be removed. Signed-off-by: Andrzej Pietrasiewicz Signed-off-by: Kyungmin Park --- drivers/usb/gadget/Kconfig |3 + drivers/usb/gadget/Makefile |2 + drivers/usb/gadget/acm_ms.c |1 + drivers/usb/gadget/f_mass_storage.c | 223 +++--- drivers/usb/gadget/f_mass_storage.h |9 ++ drivers/usb/gadget/mass_storage.c |1 + drivers/usb/gadget/multi.c |1 + 7 files changed, 220 insertions(+), 20 deletions(-) diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 98220dc..40adaf0 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -528,6 +528,9 @@ config USB_F_RNDIS config USB_U_MS tristate +config USB_F_MASS_STORAGE + tristate + choice tristate "USB Gadget Drivers" default USB_ETH diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile index d90a0b0..4a86b0c 100644 --- a/drivers/usb/gadget/Makefile +++ b/drivers/usb/gadget/Makefile @@ -62,6 +62,8 @@ usb_f_rndis-y := f_rndis.o obj-$(CONFIG_USB_F_RNDIS) += usb_f_rndis.o u_ms-y := storage_common.o obj-$(CONFIG_USB_U_MS) += u_ms.o +usb_f_mass_storage-y := f_mass_storage.o +obj-$(CONFIG_USB_F_MASS_STORAGE)+= usb_f_mass_storage.o # # USB gadget drivers diff --git a/drivers/usb/gadget/acm_ms.c b/drivers/usb/gadget/acm_ms.c index 992ffb0..31aae8f 100644 --- a/drivers/usb/gadget/acm_ms.c +++ b/drivers/usb/gadget/acm_ms.c @@ -40,6 +40,7 @@ * the runtime footprint, and giving us at least some parts of what * a "gcc --combine ... part1.c part2.c part3.c ... " build would. */ +#define USB_FMS_INCLUDED #include "f_mass_storage.c" /*-*/ diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 3b2fef8..185ff66 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -213,6 +213,7 @@ #include #include #include +#include #include #include @@ -2627,11 +2628,17 @@ void fsg_common_get(struct fsg_common *common) { kref_get(&common->ref); } +#ifndef USB_FMS_INCLUDED +EXPORT_SYMBOL(fsg_common_get); +#endif void fsg_common_put(struct fsg_common *common) { kref_put(&common->ref, fsg_common_release); } +#ifndef USB_FMS_INCLUDED +EXPORT_SYMBOL(fsg_common_put); +#endif /* check if fsg_num_buffers is within a valid range */ static inline int fsg_num_buffers_validate(unsigned int fsg_num_buffers) @@ -2669,6 +2676,9 @@ void fsg_common_set_sysfs(struct fsg_common *common, bool sysfs) { common->sysfs = sysfs; } +#ifndef USB_FMS_INCLUDED +EXPORT_SYMBOL(fsg_common_set_sysfs); +#endif static void _fsg_common_free_buffers(struct fsg_buffhd *buffhds, unsigned n) { @@ -2720,6 +2730,9 @@ error_release: return -ENOMEM; } +#ifndef USB_FMS_INCLUDED +EXPORT_SYMBOL(fsg_common_set_num_buffers); +#endif static inline void fsg_common_remove_sysfs(struct fsg_lun *lun) { @@ -2740,6 +2753,9 @@ void fsg_common_remove_lun(struct fsg_lun *lun, bool sysfs) kfree(lun->name); kfree(lun); } +#ifndef USB_FMS_INCLUDED +EXPORT_SYMBOL(fsg_common_remove_lun); +#endif void _fsg_common_remove_luns(struct fsg_common *common, int n) { @@ -2751,6 +2767,9 @@ void _fsg_common_remove_luns(struct fsg_common *common, int n) common->luns[i] = NULL; } } +#ifndef USB_FMS_INCLUDED +EXPORT_SYMBOL(fsg_common_remove_luns); +#endif void fsg_common_remove_luns(struct fsg_common *common) { @@ -2763,6 +2782,9 @@ void fsg_common_free_luns(struct fsg_common *common) kfree(common->luns); common->luns = NULL; } +#ifndef USB_FMS_INCLUDED +EXPORT_SYMBOL(fsg_common_free_luns); +#endif int fsg_common_set_nluns(struct fsg_common *common, int nluns) { @@ -2788,17 +2810,35 @@ int fsg_common_set_nluns(struct fsg_common *common, int nluns) return 0; } +#ifndef USB_FMS_INCLUDED +EXPORT_SYMBOL(fsg_common_set_nluns); +#endif + +void fsg_common_free_buffers(struct fsg_common *common) +{ + _fsg_common_free_buffers(common->buffhds, common->fsg_num_buffers); + common->buffhds = NULL; +} +#ifndef USB_FMS_INCLUDED +EXPORT_SYMBOL(fsg_common_free_buffers); +#endif void fsg_common_set_ops(struct fsg_common *common, const struct fsg_operations *ops) { common->ops = ops; } +#ifndef USB_FMS_INCLUDED +EXPORT_SYMBOL(fsg_common_set_ops); +#endif void fs
[PATCH v5 05/15] usb/gadget: f_mass_storage: create lun handling helpers for use in fsg_common_init
fsg_common_init is a lengthy function. Factor portions of it out. Signed-off-by: Andrzej Pietrasiewicz Signed-off-by: Kyungmin Park --- drivers/usb/gadget/f_mass_storage.c | 81 +++--- drivers/usb/gadget/f_mass_storage.h |8 +++ 2 files changed, 72 insertions(+), 17 deletions(-) diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 4833710..16a44e1 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -2730,6 +2730,65 @@ static inline void fsg_common_remove_sysfs(struct fsg_lun *lun) ? &dev_attr_file : &dev_attr_file_nonremovable); } +void fsg_common_remove_lun(struct fsg_lun *lun, bool sysfs) +{ + if (sysfs) { + fsg_common_remove_sysfs(lun); + device_unregister(&lun->dev); + } + fsg_lun_close(lun); + kfree(lun->name); + kfree(lun); +} + +void _fsg_common_remove_luns(struct fsg_common *common, int n) +{ + int i; + + for (i = 0; i < n; ++i) + if (common->luns[i]) { + fsg_common_remove_lun(common->luns[i], common->sysfs); + common->luns[i] = NULL; + } +} + +void fsg_common_remove_luns(struct fsg_common *common) +{ + _fsg_common_remove_luns(common, common->nluns); +} + +void fsg_common_free_luns(struct fsg_common *common) +{ + fsg_common_remove_luns(common); + kfree(common->luns); + common->luns = NULL; +} + +int fsg_common_set_nluns(struct fsg_common *common, int nluns) +{ + struct fsg_lun **curlun; + + /* Find out how many LUNs there should be */ + if (nluns < 1 || nluns > FSG_MAX_LUNS) { + pr_err("invalid number of LUNs: %u\n", nluns); + return -EINVAL; + } + + curlun = kcalloc(nluns, sizeof(*curlun), GFP_KERNEL); + if (unlikely(!curlun)) + return -ENOMEM; + + if (common->luns) + fsg_common_free_luns(common); + + common->luns = curlun; + common->nluns = nluns; + + pr_info("Number of LUNs=%d\n", common->nluns); + + return 0; +} + #define MAX_LUN_NAME_LEN 80 struct fsg_common *fsg_common_init(struct fsg_common *common, @@ -2743,12 +2802,6 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, int nluns, i, rc; char *pathbuf; - /* Find out how many LUNs there should be */ - nluns = cfg->nluns; - if (nluns < 1 || nluns > FSG_MAX_LUNS) { - dev_err(&gadget->dev, "invalid number of LUNs: %u\n", nluns); - return ERR_PTR(-EINVAL); - } common = fsg_common_setup(common, !!common); if (IS_ERR(common)) @@ -2778,17 +2831,12 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, } fsg_intf_desc.iInterface = us[FSG_STRING_INTERFACE].id; - /* -* Create the LUNs, open their backing files, and register the -* LUN devices in sysfs. -*/ - curlun_it = kcalloc(nluns, sizeof(*curlun_it), GFP_KERNEL); - if (unlikely(!curlun_it)) { - rc = -ENOMEM; - goto error_release; - } - common->luns = curlun_it; + rc = fsg_common_set_nluns(common, cfg->nluns); + if (rc) + goto error_release; + curlun_it = common->luns; + nluns = cfg->nluns; for (i = 0, lcfg = cfg->luns; i < nluns; ++i, ++curlun_it, ++lcfg) { struct fsg_lun *curlun; @@ -2852,7 +2900,6 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, goto error_luns; } } - common->nluns = nluns; /* Prepare inquiryString */ diff --git a/drivers/usb/gadget/f_mass_storage.h b/drivers/usb/gadget/f_mass_storage.h index a00f51a..f98c792 100644 --- a/drivers/usb/gadget/f_mass_storage.h +++ b/drivers/usb/gadget/f_mass_storage.h @@ -106,6 +106,14 @@ void fsg_common_set_sysfs(struct fsg_common *common, bool sysfs); int fsg_common_set_num_buffers(struct fsg_common *common, unsigned int n); +void fsg_common_remove_lun(struct fsg_lun *lun, bool sysfs); + +void fsg_common_remove_luns(struct fsg_common *common); + +void fsg_common_free_luns(struct fsg_common *common); + +int fsg_common_set_nluns(struct fsg_common *common, int nluns); + void fsg_config_from_params(struct fsg_config *cfg, const struct fsg_module_parameters *params, unsigned int fsg_num_buffers); -- 1.7.0.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 v5 01/15] usb/gadget: f_mass_storage: create _fsg_common_free_buffers
When configfs is in place, gadgets will have to be able to free fsg buffers. Add a helper function. Signed-off-by: Andrzej Pietrasiewicz Signed-off-by: Kyungmin Park --- drivers/usb/gadget/f_mass_storage.c | 24 +++- 1 files changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 32e5ab7..7d57542 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -2642,6 +2642,18 @@ static inline int fsg_num_buffers_validate(unsigned int fsg_num_buffers) return -EINVAL; } +static void _fsg_common_free_buffers(struct fsg_buffhd *buffhds, unsigned n) +{ + if (buffhds) { + struct fsg_buffhd *bh = buffhds; + while (n--) { + kfree(bh->buf); + ++bh; + } + kfree(buffhds); + } +} + struct fsg_common *fsg_common_init(struct fsg_common *common, struct usb_composite_dev *cdev, struct fsg_config *cfg) @@ -2897,15 +2909,9 @@ static void fsg_common_release(struct kref *ref) kfree(common->luns); } - { - struct fsg_buffhd *bh = common->buffhds; - unsigned i = common->fsg_num_buffers; - do { - kfree(bh->buf); - } while (++bh, --i); - } - - kfree(common->buffhds); + if (likely(common->buffhds)) + _fsg_common_free_buffers(common->buffhds, +common->fsg_num_buffers); if (common->free_storage_on_release) kfree(common); } -- 1.7.0.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 v5 03/15] usb/gadget: f_mass_storage: create fsg_common_setup for use in fsg_common_init
fsg_common_init is a lengthy function. Factor a portion of it out. Signed-off-by: Andrzej Pietrasiewicz Signed-off-by: Kyungmin Park --- drivers/usb/gadget/f_mass_storage.c | 41 +- 1 files changed, 25 insertions(+), 16 deletions(-) diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 14c9e5b..b7ed792 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -2643,6 +2643,28 @@ static inline int fsg_num_buffers_validate(unsigned int fsg_num_buffers) return -EINVAL; } +static struct fsg_common *fsg_common_setup(struct fsg_common *common, bool zero) +{ + if (!common) { + common = kzalloc(sizeof(*common), GFP_KERNEL); + if (!common) + return ERR_PTR(-ENOMEM); + common->free_storage_on_release = 1; + } else { + if (zero) + memset(common, 0, sizeof(*common)); + common->free_storage_on_release = 0; + } + init_rwsem(&common->filesem); + spin_lock_init(&common->lock); + kref_init(&common->ref); + init_completion(&common->thread_notifier); + init_waitqueue_head(&common->fsg_wait); + common->state = FSG_STATE_TERMINATED; + + return common; +} + void fsg_common_set_sysfs(struct fsg_common *common, bool sysfs) { common->sysfs = sysfs; @@ -2694,16 +2716,9 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, return ERR_PTR(-EINVAL); } - /* Allocate? */ - if (!common) { - common = kzalloc(sizeof *common, GFP_KERNEL); - if (!common) - return ERR_PTR(-ENOMEM); - common->free_storage_on_release = 1; - } else { - memset(common, 0, sizeof *common); - common->free_storage_on_release = 0; - } + common = fsg_common_setup(common, !!common); + if (IS_ERR(common)) + return common; fsg_common_set_sysfs(common, true); common->state = FSG_STATE_IDLE; @@ -2743,8 +2758,6 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, } common->luns = curlun_it; - init_rwsem(&common->filesem); - for (i = 0, lcfg = cfg->luns; i < nluns; ++i, ++curlun_it, ++lcfg) { struct fsg_lun *curlun; @@ -2844,8 +2857,6 @@ buffhds_first_it: common->can_stall = cfg->can_stall && !(gadget_is_at91(common->gadget)); - spin_lock_init(&common->lock); - kref_init(&common->ref); /* Tell the thread to start working */ common->thread_task = @@ -2854,8 +2865,6 @@ buffhds_first_it: rc = PTR_ERR(common->thread_task); goto error_release; } - init_completion(&common->thread_notifier); - init_waitqueue_head(&common->fsg_wait); /* Information */ INFO(common, FSG_DRIVER_DESC ", version: " FSG_DRIVER_VERSION "\n"); -- 1.7.0.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 v5 13/15] usb/gadget: storage_common: make attribute operations more generic
Show/store methods for sysfs attributes contain code which can be used also by configfs. Make them abstract the source the lun and rw_semaphore are taken from. Signed-off-by: Andrzej Pietrasiewicz Signed-off-by: Kyungmin Park --- drivers/usb/gadget/f_mass_storage.c | 27 +-- drivers/usb/gadget/storage_common.c | 31 ++- drivers/usb/gadget/storage_common.h | 21 +++-- 3 files changed, 38 insertions(+), 41 deletions(-) diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 185ff66..7dc0adf 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -2574,37 +2574,52 @@ static int fsg_main_thread(void *common_) static ssize_t ro_show(struct device *dev, struct device_attribute *attr, char *buf) { - return fsg_show_ro(dev, attr, buf); + struct fsg_lun *curlun = fsg_lun_from_dev(dev); + + return fsg_show_ro(curlun, buf); } static ssize_t nofua_show(struct device *dev, struct device_attribute *attr, char *buf) { - return fsg_show_nofua(dev, attr, buf); + struct fsg_lun *curlun = fsg_lun_from_dev(dev); + + return fsg_show_nofua(curlun, buf); } static ssize_t file_show(struct device *dev, struct device_attribute *attr, char *buf) { - return fsg_show_file(dev, attr, buf); + struct fsg_lun *curlun = fsg_lun_from_dev(dev); + struct rw_semaphore *filesem = dev_get_drvdata(dev); + + return fsg_show_file(curlun, filesem, buf); } static ssize_t ro_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - return fsg_store_ro(dev, attr, buf, count); + struct fsg_lun *curlun = fsg_lun_from_dev(dev); + struct rw_semaphore *filesem = dev_get_drvdata(dev); + + return fsg_store_ro(curlun, filesem, buf, count); } static ssize_t nofua_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - return fsg_store_nofua(dev, attr, buf, count); + struct fsg_lun *curlun = fsg_lun_from_dev(dev); + + return fsg_store_nofua(curlun, buf, count); } static ssize_t file_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - return fsg_store_file(dev, attr, buf, count); + struct fsg_lun *curlun = fsg_lun_from_dev(dev); + struct rw_semaphore *filesem = dev_get_drvdata(dev); + + return fsg_store_file(curlun, filesem, buf, count); } static DEVICE_ATTR_RW(ro); diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c index 3e2500f..969948d 100644 --- a/drivers/usb/gadget/storage_common.c +++ b/drivers/usb/gadget/storage_common.c @@ -31,11 +31,6 @@ #include "storage_common.h" -static inline struct fsg_lun *fsg_lun_from_dev(struct device *dev) -{ - return container_of(dev, struct fsg_lun, dev); -} - /* There is only one interface. */ struct usb_interface_descriptor fsg_intf_desc = { @@ -324,31 +319,23 @@ EXPORT_SYMBOL(store_cdrom_address); /*-*/ -ssize_t fsg_show_ro(struct device *dev, struct device_attribute *attr, - char *buf) +ssize_t fsg_show_ro(struct fsg_lun *curlun, char *buf) { - struct fsg_lun *curlun = fsg_lun_from_dev(dev); - return sprintf(buf, "%d\n", fsg_lun_is_open(curlun) ? curlun->ro : curlun->initially_ro); } EXPORT_SYMBOL(fsg_show_ro); -ssize_t fsg_show_nofua(struct device *dev, struct device_attribute *attr, - char *buf) +ssize_t fsg_show_nofua(struct fsg_lun *curlun, char *buf) { - struct fsg_lun *curlun = fsg_lun_from_dev(dev); - return sprintf(buf, "%u\n", curlun->nofua); } EXPORT_SYMBOL(fsg_show_nofua); -ssize_t fsg_show_file(struct device *dev, struct device_attribute *attr, +ssize_t fsg_show_file(struct fsg_lun *curlun, struct rw_semaphore *filesem, char *buf) { - struct fsg_lun *curlun = fsg_lun_from_dev(dev); - struct rw_semaphore *filesem = dev_get_drvdata(dev); char*p; ssize_t rc; @@ -373,12 +360,10 @@ ssize_t fsg_show_file(struct device *dev, struct device_attribute *attr, EXPORT_SYMBOL(fsg_show_file); -ssize_t fsg_store_ro(struct device *dev, struct device_attribute *attr, +ssize_t fsg_store_ro(struct fsg_lun *curlun, struct rw_semaphore *filesem, const char *buf, size_t count) { ssize_t rc; - struct fsg_lun *curlun = fsg_lun_from_dev(dev); - struct rw_semaphore *filesem = dev_get_drvdata(dev); unsignedro
[PATCH v5 08/15] usb/gadget: f_mass_storage: create lun creation helpers for use in fsg_common_init
fsg_common_init is a lengthy function. Factor portions of it out. Signed-off-by: Andrzej Pietrasiewicz Signed-off-by: Kyungmin Park --- drivers/usb/gadget/f_mass_storage.c | 260 ++- drivers/usb/gadget/f_mass_storage.h |6 + 2 files changed, 169 insertions(+), 97 deletions(-) diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 61952b6..441bde5 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -2829,18 +2829,172 @@ int fsg_common_set_cdev(struct fsg_common *common, return 0; } +static inline int fsg_common_add_sysfs(struct fsg_common *common, + struct fsg_lun *lun) +{ + int rc; + + rc = device_register(&lun->dev); + if (rc) { + put_device(&lun->dev); + return rc; + } + + rc = device_create_file(&lun->dev, + lun->cdrom + ? &dev_attr_ro_cdrom + : &dev_attr_ro); + if (rc) + goto error_cdrom; + rc = device_create_file(&lun->dev, + lun->removable + ? &dev_attr_file + : &dev_attr_file_nonremovable); + if (rc) + goto error_removable; + rc = device_create_file(&lun->dev, &dev_attr_nofua); + if (rc) + goto error_nofua; + + return 0; + +error_nofua: + device_remove_file(&lun->dev, + lun->removable +? &dev_attr_file +: &dev_attr_file_nonremovable); +error_removable: + device_remove_file(&lun->dev, + lun->cdrom +? &dev_attr_ro_cdrom +: &dev_attr_ro); +error_cdrom: + device_unregister(&lun->dev); + return rc; +} + #define MAX_LUN_NAME_LEN 80 +int fsg_common_create_lun(struct fsg_common *common, struct fsg_lun_config *cfg, + unsigned int id, const char *name, + const char **name_pfx) +{ + struct fsg_lun *lun; + char *pathbuf; + int rc = -ENOMEM; + int name_len; + + if (!common->nluns || !common->luns) + return -ENODEV; + + if (common->luns[id]) + return -EBUSY; + + name_len = strlen(name) + 1; + if (name_len > MAX_LUN_NAME_LEN) + return -ENAMETOOLONG; + + lun = kzalloc(sizeof(*lun), GFP_KERNEL); + if (!lun) + return -ENOMEM; + + lun->name = kstrndup(name, name_len, GFP_KERNEL); + if (!lun->name) + goto error_name; + lun->name_pfx = name_pfx; + + lun->cdrom = !!cfg->cdrom; + lun->ro = cfg->cdrom || cfg->ro; + lun->initially_ro = lun->ro; + lun->removable = !!cfg->removable; + + common->luns[id] = lun; + + if (common->sysfs) { + lun->dev.release = fsg_lun_release; + lun->dev.parent = &common->gadget->dev; + dev_set_drvdata(&lun->dev, &common->filesem); + dev_set_name(&lun->dev, name); + + rc = fsg_common_add_sysfs(common, lun); + if (rc) { + pr_info("failed to register LUN%d: %d\n", id, rc); + goto error_sysfs; + } + } + + if (cfg->filename) { + rc = fsg_lun_open(lun, cfg->filename); + if (rc) + goto error_lun; + } else if (!lun->removable) { + pr_err("no file given for LUN%d\n", id); + rc = -EINVAL; + goto error_lun; + } + + pathbuf = kmalloc(PATH_MAX, GFP_KERNEL); + { + char *p = "(no medium)"; + if (fsg_lun_is_open(lun)) { + p = "(error)"; + if (pathbuf) { + p = d_path(&lun->filp->f_path, + pathbuf, PATH_MAX); + if (IS_ERR(p)) + p = "(error)"; + } + } + pr_info("LUN: %s%s%sfile: %s\n", + lun->removable ? "removable " : "", + lun->ro ? "read only " : "", + lun->cdrom ? "CD-ROM " : "", + p); + } + kfree(pathbuf); + + return 0; + +error_lun: + if (common->sysfs) { + fsg_common_remove_sysfs(lun); + device_unregister(&lun->dev); + } + fsg_lun_close(lun); +error_sysfs: + common->luns[id] = NULL; + kfree(lun->name); +error_name: + kfree(lun); + return rc; +} + +int fsg_common_create_luns(struct fsg_common *common, struct fsg_config *cfg) +{ + char buf[40]; /* eno
[PATCH v5 02/15] usb/gadget: f_mass_storage: make sysfs interface optional
When configfs is in place, the luns will not be represented in sysfs, so there will be no struct device associated with a lun. In order to maintain compatibility and allow configfs adoption sysfs is made optional in this patch. As a consequence some debug macros need to be adjusted. Two new fields are added to struct fsg_lun: name and name_pfx. The "name" is for storing a string which is presented to the user instead of the dev_name. The "name_pfx", if non-NULL, is prepended to the "name" at printing time. The name_pfx is for a future lun.0, which will be a default group in mass_storage.. By design at USB function configfs group's creation time its name is not known (but instead set a bit later in drivers/usb/gadget/configfs.c:function_make) and it is this name that serves the purpose of the said name prefix. So instead of copying a yet-unknown string a pointer to it is stored in struct fsg_lun. Signed-off-by: Andrzej Pietrasiewicz Signed-off-by: Kyungmin Park --- drivers/usb/gadget/f_mass_storage.c | 41 ++ drivers/usb/gadget/f_mass_storage.h |2 + drivers/usb/gadget/storage_common.h | 20 +--- 3 files changed, 49 insertions(+), 14 deletions(-) diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 7d57542..14c9e5b 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -299,6 +299,7 @@ struct fsg_common { unsigned intshort_packet_received:1; unsigned intbad_lun_okay:1; unsigned intrunning:1; + unsigned intsysfs:1; int thread_wakeup_needed; struct completion thread_notifier; @@ -2642,6 +2643,11 @@ static inline int fsg_num_buffers_validate(unsigned int fsg_num_buffers) return -EINVAL; } +void fsg_common_set_sysfs(struct fsg_common *common, bool sysfs) +{ + common->sysfs = sysfs; +} + static void _fsg_common_free_buffers(struct fsg_buffhd *buffhds, unsigned n) { if (buffhds) { @@ -2654,6 +2660,17 @@ static void _fsg_common_free_buffers(struct fsg_buffhd *buffhds, unsigned n) } } +static inline void fsg_common_remove_sysfs(struct fsg_lun *lun) +{ + device_remove_file(&lun->dev, &dev_attr_nofua); + device_remove_file(&lun->dev, lun->cdrom + ? &dev_attr_ro_cdrom : &dev_attr_ro); + device_remove_file(&lun->dev, lun->removable + ? &dev_attr_file : &dev_attr_file_nonremovable); +} + +#define MAX_LUN_NAME_LEN 80 + struct fsg_common *fsg_common_init(struct fsg_common *common, struct usb_composite_dev *cdev, struct fsg_config *cfg) @@ -2687,6 +2704,8 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, memset(common, 0, sizeof *common); common->free_storage_on_release = 0; } + fsg_common_set_sysfs(common, true); + common->state = FSG_STATE_IDLE; common->fsg_num_buffers = cfg->fsg_num_buffers; common->buffhds = kcalloc(common->fsg_num_buffers, @@ -2737,6 +2756,12 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, } *curlun_it = curlun; + curlun->name = kzalloc(MAX_LUN_NAME_LEN, GFP_KERNEL); + if (!curlun->name) { + rc = -ENOMEM; + common->nluns = i; + goto error_release; + } curlun->cdrom = !!lcfg->cdrom; curlun->ro = lcfg->cdrom || lcfg->ro; curlun->initially_ro = curlun->ro; @@ -2746,6 +2771,7 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, /* curlun->dev.driver = &fsg_driver.driver; XXX */ dev_set_drvdata(&curlun->dev, &common->filesem); dev_set_name(&curlun->dev, "lun%d", i); + strlcpy(curlun->name, dev_name(&curlun->dev), MAX_LUN_NAME_LEN); rc = device_register(&curlun->dev); if (rc) { @@ -2892,17 +2918,12 @@ static void fsg_common_release(struct kref *ref) struct fsg_lun *lun = *lun_it; if (!lun) continue; - device_remove_file(&lun->dev, &dev_attr_nofua); - device_remove_file(&lun->dev, - lun->cdrom -? &dev_attr_ro_cdrom -: &dev_attr_ro); - device_remove_file(&lun->dev, - lun->removable -? &dev_attr_file -: &dev_attr_file_nonremovable); + if (common->sysfs) +
[PATCH v5 04/15] usb/gadget: f_mass_storage: create fsg_common_set_num_buffers for use in fsg_common_init
fsg_common_init is a lengthy function. Factor a portion of it out. Signed-off-by: Andrzej Pietrasiewicz Signed-off-by: Kyungmin Park --- drivers/usb/gadget/f_mass_storage.c | 68 +- drivers/usb/gadget/f_mass_storage.h |2 + 2 files changed, 44 insertions(+), 26 deletions(-) diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index b7ed792..4833710 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -2682,6 +2682,45 @@ static void _fsg_common_free_buffers(struct fsg_buffhd *buffhds, unsigned n) } } +int fsg_common_set_num_buffers(struct fsg_common *common, unsigned int n) +{ + struct fsg_buffhd *bh, *new_buffhds; + int i, rc; + + rc = fsg_num_buffers_validate(n); + if (rc != 0) + return rc; + + new_buffhds = kcalloc(n, sizeof *(new_buffhds), GFP_KERNEL); + if (!new_buffhds) + return -ENOMEM; + + /* Data buffers cyclic list */ + bh = new_buffhds; + i = n; + goto buffhds_first_it; + do { + bh->next = bh + 1; + ++bh; +buffhds_first_it: + bh->buf = kmalloc(FSG_BUFLEN, GFP_KERNEL); + if (unlikely(!bh->buf)) + goto error_release; + } while (--i); + bh->next = new_buffhds; + + _fsg_common_free_buffers(common->buffhds, common->fsg_num_buffers); + common->fsg_num_buffers = n; + common->buffhds = new_buffhds; + + return 0; + +error_release: + _fsg_common_free_buffers(new_buffhds, n - i); + + return -ENOMEM; +} + static inline void fsg_common_remove_sysfs(struct fsg_lun *lun) { device_remove_file(&lun->dev, &dev_attr_nofua); @@ -2698,17 +2737,12 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, struct fsg_config *cfg) { struct usb_gadget *gadget = cdev->gadget; - struct fsg_buffhd *bh; struct fsg_lun **curlun_it; struct fsg_lun_config *lcfg; struct usb_string *us; int nluns, i, rc; char *pathbuf; - rc = fsg_num_buffers_validate(cfg->fsg_num_buffers); - if (rc != 0) - return ERR_PTR(rc); - /* Find out how many LUNs there should be */ nluns = cfg->nluns; if (nluns < 1 || nluns > FSG_MAX_LUNS) { @@ -2722,15 +2756,12 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, fsg_common_set_sysfs(common, true); common->state = FSG_STATE_IDLE; - common->fsg_num_buffers = cfg->fsg_num_buffers; - common->buffhds = kcalloc(common->fsg_num_buffers, - sizeof *(common->buffhds), GFP_KERNEL); - if (!common->buffhds) { + rc = fsg_common_set_num_buffers(common, cfg->fsg_num_buffers); + if (rc) { if (common->free_storage_on_release) kfree(common); - return ERR_PTR(-ENOMEM); + return ERR_PTR(rc); } - common->ops = cfg->ops; common->private_data = cfg->private_data; @@ -2823,21 +2854,6 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, } common->nluns = nluns; - /* Data buffers cyclic list */ - bh = common->buffhds; - i = common->fsg_num_buffers; - goto buffhds_first_it; - do { - bh->next = bh + 1; - ++bh; -buffhds_first_it: - bh->buf = kmalloc(FSG_BUFLEN, GFP_KERNEL); - if (unlikely(!bh->buf)) { - rc = -ENOMEM; - goto error_release; - } - } while (--i); - bh->next = common->buffhds; /* Prepare inquiryString */ i = get_default_bcdDevice(); diff --git a/drivers/usb/gadget/f_mass_storage.h b/drivers/usb/gadget/f_mass_storage.h index 1b88eae..a00f51a 100644 --- a/drivers/usb/gadget/f_mass_storage.h +++ b/drivers/usb/gadget/f_mass_storage.h @@ -104,6 +104,8 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, void fsg_common_set_sysfs(struct fsg_common *common, bool sysfs); +int fsg_common_set_num_buffers(struct fsg_common *common, unsigned int n); + void fsg_config_from_params(struct fsg_config *cfg, const struct fsg_module_parameters *params, unsigned int fsg_num_buffers); -- 1.7.0.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 v5 06/15] usb/gadget: f_mass_storage: create fsg_common_set_ops/_private_data for use in fsg_common_init
fsg_common_init is a lengthy function. Factor portions of it out. Signed-off-by: Andrzej Pietrasiewicz Signed-off-by: Kyungmin Park --- drivers/usb/gadget/f_mass_storage.c | 16 ++-- drivers/usb/gadget/f_mass_storage.h |5 + 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 16a44e1..39f7f1f 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -2789,6 +2789,17 @@ int fsg_common_set_nluns(struct fsg_common *common, int nluns) return 0; } +void fsg_common_set_ops(struct fsg_common *common, + const struct fsg_operations *ops) +{ + common->ops = ops; +} + +void fsg_common_set_private_data(struct fsg_common *common, void *priv) +{ + common->private_data = priv; +} + #define MAX_LUN_NAME_LEN 80 struct fsg_common *fsg_common_init(struct fsg_common *common, @@ -2815,8 +2826,9 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, kfree(common); return ERR_PTR(rc); } - common->ops = cfg->ops; - common->private_data = cfg->private_data; + + fsg_common_set_ops(common, cfg->ops); + fsg_common_set_private_data(common, cfg->private_data); common->gadget = gadget; common->ep0 = gadget->ep0; diff --git a/drivers/usb/gadget/f_mass_storage.h b/drivers/usb/gadget/f_mass_storage.h index f98c792..3be09a1 100644 --- a/drivers/usb/gadget/f_mass_storage.h +++ b/drivers/usb/gadget/f_mass_storage.h @@ -106,6 +106,11 @@ void fsg_common_set_sysfs(struct fsg_common *common, bool sysfs); int fsg_common_set_num_buffers(struct fsg_common *common, unsigned int n); +void fsg_common_set_ops(struct fsg_common *common, + const struct fsg_operations *ops); + +void fsg_common_set_private_data(struct fsg_common *common, void *priv); + void fsg_common_remove_lun(struct fsg_lun *lun, bool sysfs); void fsg_common_remove_luns(struct fsg_common *common); -- 1.7.0.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 v5 09/15] usb/gadget: f_mass_storage: create fsg_common_set_inquiry_string for use in fsg_common_init
fsg_common_init is a lengthy function. Factor a portion of it out. Signed-off-by: Andrzej Pietrasiewicz Signed-off-by: Kyungmin Park --- drivers/usb/gadget/f_mass_storage.c | 29 +++-- drivers/usb/gadget/f_mass_storage.h |3 +++ 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 441bde5..1cac208 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -2990,11 +2990,27 @@ fail: return rc; } +void fsg_common_set_inquiry_string(struct fsg_common *common, const char *vn, + const char *pn) +{ + int i; + + /* Prepare inquiryString */ + i = get_default_bcdDevice(); + snprintf(common->inquiry_string, sizeof(common->inquiry_string), +"%-8s%-16s%04x", vn ?: "Linux", +/* Assume product name dependent on the first LUN */ +pn ?: ((*common->luns)->cdrom +? "File-CD Gadget" +: "File-Stor Gadget"), +i); +} + struct fsg_common *fsg_common_init(struct fsg_common *common, struct usb_composite_dev *cdev, struct fsg_config *cfg) { - int i, rc; + int rc; common = fsg_common_setup(common, !!common); if (IS_ERR(common)) @@ -3024,16 +3040,9 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, if (rc) goto error_release; - /* Prepare inquiryString */ - i = get_default_bcdDevice(); - snprintf(common->inquiry_string, sizeof common->inquiry_string, -"%-8s%-16s%04x", cfg->vendor_name ?: "Linux", -/* Assume product name dependent on the first LUN */ -cfg->product_name ?: ((*common->luns)->cdrom -? "File-CD Gadget" -: "File-Stor Gadget"), -i); + fsg_common_set_inquiry_string(common, cfg->vendor_name, + cfg->product_name); /* Tell the thread to start working */ common->thread_task = kthread_create(fsg_main_thread, common, "file-storage"); diff --git a/drivers/usb/gadget/f_mass_storage.h b/drivers/usb/gadget/f_mass_storage.h index 08243c3..343a8a4 100644 --- a/drivers/usb/gadget/f_mass_storage.h +++ b/drivers/usb/gadget/f_mass_storage.h @@ -128,6 +128,9 @@ int fsg_common_create_lun(struct fsg_common *common, struct fsg_lun_config *cfg, int fsg_common_create_luns(struct fsg_common *common, struct fsg_config *cfg); +void fsg_common_set_inquiry_string(struct fsg_common *common, const char *vn, + const char *pn); + void fsg_config_from_params(struct fsg_config *cfg, const struct fsg_module_parameters *params, unsigned int fsg_num_buffers); -- 1.7.0.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 v5 00/15] Equivalent of g_mass_storage with configfs
This series aims at integrating configfs into mass storage, the way it has been done for acm, ncm, ecm, eem, ecm subset, rndis, obex and phonet. It contains everything that is required to provide the equivalent of g_mass_storage.ko with configfs. Mass storage itself is quite large, so the resulting patch series is a bit lengthy. However, it is supposed to be done in steps like this: 1) preliminary work, e.g. factoring out a header file, creating a utility u_ms.ko module, use usb_gstrings_attach 2) prepare for initializing the fsg_common structure in smaller steps instead of in one big step 3) usual stuff, similar to functions previously converted to configfs v1..v2: - simplified adding a level of indirection for fsg_lun storing - reworked lun debugging macros in order not to use struct device [both after discussion with Alan, thanks] v2..v3: - implemented changes resulting from Michal's comments [thanks, Michal] - used static inline fsg_common_remove_sysfs wherever possible - some small bugfixes v3..v4: -rebased onto 3.12-rc1 v4..v5: - rebased onto Felipe's "testing" (3.12-rc3) - the same code as in v4, just distributed over patches in such a way that there are no compiler warnings A branch 'usb-gadget-configfs-3.12' is available at: git://git.linaro.org/people/mszyprowski/linux-srpol.git BACKWARD COMPATIBILITY == Please note that the old g_mass_storage.ko is still available and works. USING THE NEW "GADGET" == Please refer to this post: http://www.spinics.net/lists/linux-usb/msg76388.html for general information from Sebastian on how to use configfs-based gadgets (*). With configfs the procedure is as follows, compared to the information mentioned above (*): instead of mkdir functions/acm.ttyS1 do mkdir functions/. e.g. mkdir functions/mass_storage.0 In functions/. there will be the following attribute files: stall - Set to permit function to halt bulk endpoints. Disabled on some USB devices known not to work correctly. You should set it to true. num_buffers - Number of pipeline buffers. Valid numbers are 2..4. Available only if CONFIG_USB_GADGET_DEBUG_FILES is set. and a default lun.0 directory corresponding to SCSI LUN #0. A new lun can be added with mkdir: $ mkdir functions/mass_storage.0/partition.5 Lun numbering does not have to be continuous, except for lun #0 which is created by default. A maximum of 8 luns can be specified and they all must be named following the . scheme. The numbers can be 0..8. Probably a good convention is to name the luns "lun.", although it is not mandatory. In each lun directory there are the following attribute files: file- The path to the backing file for the LUN. Required if LUN is not marked as removable. ro - Flag specifying access to the LUN shall be read-only. This is implied if CD-ROM emulation is enabled as well as when it was impossible to open "filename" in R/W mode. removable - Flag specifying that LUN shall be indicated as being removable. cdrom - Flag specifying that LUN shall be reported as being a CD-ROM. nofua - Flag specifying that FUA flag in SCSI WRITE(10,12) The rest of the procedure (*) remains the same. An example gadget with two luns: $ modprobe libcomposite $ mount none cfg -t configfs $ mkdir cfg/usb_gadget/g1 $ cd cfg/usb_gadget/g1 $ mkdir configs/c.1 $ mkdir functions/mass_storage.0 $ echo /root/lun0.img > functions/mass_storage.0/lun.0/file $ mkdir functions/mass_storage.0/lun.1 $ echo /root/lun1.img > functions/mass_storage.0/lun.1/file $ mkdir strings/0x409 $ mkdir configs/c.1/strings/0x409 $ echo 0xa4a2 > idProduct $ echo 0x0525 > idVendor $ echo my-serial-num > strings/0x409/serialnumber $ echo my-manufacturer > strings/0x409/manufacturer $ echo "Mass Storage Gadget" > strings/0x409/product $ echo "Conf 1" > configs/c.1/strings/0x409/configuration $ echo 120 > configs/c.1/MaxPower $ ln -s functions/mass_storage.0 configs/c.1 $ echo s3c-hsotg > UDC After unbinding the gadget with echo "" > UDC the symbolic links in the configuration directory can be removed, the strings/* subdirectories in the configuration directory can be removed, the strings/* subdirectories at the gadget level can be removed and the configs/* subdirectories can be removed. The functions/* subdirectories can be removed. After that the gadget directory can be removed. After that the respective modules can be unloaded. TESTING THE FUNCTIONS (actually there is only one) = mass_storage) device: connect the gadget, enable it host: dmesg, see the USB drives appear (if system configured to auto
[PATCH v4 2/5] usb/gadget: multi: convert to new interface of f_rndis
Convert the legacy multi gadget to the new interface of f_rndis, so that later the compatibility layer in f_rndis can be removed. Signed-off-by: Andrzej Pietrasiewicz Signed-off-by: Kyungmin Park --- drivers/usb/gadget/Kconfig |3 +- drivers/usb/gadget/multi.c | 73 ++-- 2 files changed, 52 insertions(+), 24 deletions(-) diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 92a8966..bbcc313 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -1036,7 +1036,6 @@ config USB_G_MULTI select USB_LIBCOMPOSITE select USB_U_SERIAL select USB_U_ETHER - select USB_U_RNDIS select USB_F_ACM select USB_U_MS help @@ -1057,6 +1056,8 @@ config USB_G_MULTI config USB_G_MULTI_RNDIS bool "RNDIS + CDC Serial + Storage configuration" depends on USB_G_MULTI + select USB_U_RNDIS + select USB_F_RNDIS default y help This option enables a configuration with RNDIS, CDC Serial and diff --git a/drivers/usb/gadget/multi.c b/drivers/usb/gadget/multi.c index 7dd5544..fceef0f 100644 --- a/drivers/usb/gadget/multi.c +++ b/drivers/usb/gadget/multi.c @@ -47,8 +47,7 @@ MODULE_LICENSE("GPL"); #include "u_ecm.h" #ifdef USB_ETH_RNDIS -# define USB_FRNDIS_INCLUDED -# include "f_rndis.c" +# include "u_rndis.h" # include "rndis.h" #endif #include "u_ether.h" @@ -152,14 +151,13 @@ FSG_MODULE_PARAMETERS(/* no prefix */, fsg_mod_data); static struct fsg_common fsg_common; static struct usb_function_instance *fi_acm; -static struct eth_dev *the_dev; /** RNDIS **/ #ifdef USB_ETH_RNDIS -static u8 host_mac[ETH_ALEN]; - +static struct usb_function_instance *fi_rndis; static struct usb_function *f_acm_rndis; +static struct usb_function *f_rndis; static __init int rndis_do_config(struct usb_configuration *c) { @@ -170,13 +168,19 @@ static __init int rndis_do_config(struct usb_configuration *c) c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; } - ret = rndis_bind_config(c, host_mac, the_dev); + f_rndis = usb_get_function(fi_rndis); + if (IS_ERR(f_rndis)) + return PTR_ERR(f_rndis); + + ret = usb_add_function(c, f_rndis); if (ret < 0) - return ret; + goto err_func_rndis; f_acm_rndis = usb_get_function(fi_acm); - if (IS_ERR(f_acm_rndis)) - return PTR_ERR(f_acm_rndis); + if (IS_ERR(f_acm_rndis)) { + ret = PTR_ERR(f_acm_rndis); + goto err_func_acm; + } ret = usb_add_function(c, f_acm_rndis); if (ret) @@ -191,6 +195,10 @@ err_fsg: usb_remove_function(c, f_acm_rndis); err_conf: usb_put_function(f_acm_rndis); +err_func_acm: + usb_remove_function(c, f_rndis); +err_func_rndis: + usb_put_function(f_rndis); return ret; } @@ -300,11 +308,14 @@ static int __ref multi_bind(struct usb_composite_dev *cdev) #ifdef CONFIG_USB_G_MULTI_CDC struct f_ecm_opts *ecm_opts; #endif +#ifdef USB_ETH_RNDIS + struct f_rndis_opts *rndis_opts; +#endif int status; if (!can_support_ecm(cdev->gadget)) { dev_err(&gadget->dev, "controller '%s' not usable\n", - gadget->name); + gadget->name); return -EINVAL; } @@ -320,26 +331,38 @@ static int __ref multi_bind(struct usb_composite_dev *cdev) pr_info("using host ethernet address: %s", host_addr); if (!gether_set_dev_addr(ecm_opts->net, dev_addr)) pr_info("using self ethernet address: %s", dev_addr); +#endif - the_dev = netdev_priv(ecm_opts->net); +#ifdef USB_ETH_RNDIS + fi_rndis = usb_get_function_instance("rndis"); + if (IS_ERR(fi_rndis)) { + status = PTR_ERR(fi_rndis); + goto fail; + } -#elif defined USB_ETH_RNDIS + rndis_opts = container_of(fi_rndis, struct f_rndis_opts, func_inst); - /* set up network link layer */ - the_dev = gether_setup(cdev->gadget, dev_addr, host_addr, host_mac, - qmult); - if (IS_ERR(the_dev)) - return PTR_ERR(the_dev); + gether_set_qmult(rndis_opts->net, qmult); + if (!gether_set_host_addr(rndis_opts->net, host_addr)) + pr_info("using host ethernet address: %s", host_addr); + if (!gether_set_dev_addr(rndis_opts->net, dev_addr)) + pr_info("using self ethernet address: %s", dev_addr); #endif #if (defined CONFIG_USB_G_MULTI_CDC && defined USB_ETH_RNDIS) + /* +* If both ecm and rndis are selected then: +* 1) rndis borrows the net interface from ecm +* 2) since the interface is shared it must not be bound +* twice - in ecm's _and_ rndis' binds, so do it here. +*/ gether_
[PATCH v4 3/5] usb/gadget: multi: convert to new interface of f_mass_storage
Convert the legacy multi gadget to the new interface of f_mass_storage, so that later the compatibility layer in f_mass_storage can be removed. Signed-off-by: Andrzej Pietrasiewicz Signed-off-by: Kyungmin Park --- drivers/usb/gadget/Kconfig |1 + drivers/usb/gadget/multi.c | 112 2 files changed, 83 insertions(+), 30 deletions(-) diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index bbcc313..4b0c456 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -1038,6 +1038,7 @@ config USB_G_MULTI select USB_U_ETHER select USB_F_ACM select USB_U_MS + select USB_F_MASS_STORAGE help The Multifunction Composite Gadget provides Ethernet (RNDIS and/or CDC Ethernet), mass storage and ACM serial link diff --git a/drivers/usb/gadget/multi.c b/drivers/usb/gadget/multi.c index fceef0f..9d98825 100644 --- a/drivers/usb/gadget/multi.c +++ b/drivers/usb/gadget/multi.c @@ -33,17 +33,7 @@ MODULE_AUTHOR("Michal Nazarewicz"); MODULE_LICENSE("GPL"); -/* All the files... */ - -/* - * kbuild is not very cooperative with respect to linking separately - * compiled library objects into one module. So for now we won't use - * separate compilation ... ensuring init/exit sections work to shrink - * the runtime footprint, and giving us at least some parts of what - * a "gcc --combine ... part1.c part2.c part3.c ... " build would. - */ -#define USB_FMS_INCLUDED -#include "f_mass_storage.c" +#include "f_mass_storage.h" #include "u_ecm.h" #ifdef USB_ETH_RNDIS @@ -148,9 +138,8 @@ static unsigned int fsg_num_buffers = CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS; FSG_MODULE_PARAMETERS(/* no prefix */, fsg_mod_data); -static struct fsg_common fsg_common; - static struct usb_function_instance *fi_acm; +static struct usb_function_instance *fi_msg; /** RNDIS **/ @@ -158,9 +147,11 @@ static struct usb_function_instance *fi_acm; static struct usb_function_instance *fi_rndis; static struct usb_function *f_acm_rndis; static struct usb_function *f_rndis; +static struct usb_function *f_msg_rndis; static __init int rndis_do_config(struct usb_configuration *c) { + struct fsg_opts *fsg_opts; int ret; if (gadget_is_otg(c->cdev->gadget)) { @@ -186,11 +177,24 @@ static __init int rndis_do_config(struct usb_configuration *c) if (ret) goto err_conf; - ret = fsg_bind_config(c->cdev, c, &fsg_common); - if (ret < 0) + f_msg_rndis = usb_get_function(fi_msg); + if (IS_ERR(f_msg_rndis)) { + ret = PTR_ERR(f_msg_rndis); goto err_fsg; + } + + fsg_opts = container_of(fi_msg, struct fsg_opts, func_inst); + ret = fsg_common_run_thread(fsg_opts->common); + if (ret) + goto err_run; + + ret = usb_add_function(c, f_msg_rndis); + if (ret) + goto err_run; return 0; +err_run: + usb_put_function(f_msg_rndis); err_fsg: usb_remove_function(c, f_acm_rndis); err_conf: @@ -231,9 +235,11 @@ static __ref int rndis_config_register(struct usb_composite_dev *cdev) static struct usb_function_instance *fi_ecm; static struct usb_function *f_acm_multi; static struct usb_function *f_ecm; +static struct usb_function *f_msg_multi; static __init int cdc_do_config(struct usb_configuration *c) { + struct fsg_opts *fsg_opts; int ret; if (gadget_is_otg(c->cdev->gadget)) { @@ -260,11 +266,24 @@ static __init int cdc_do_config(struct usb_configuration *c) if (ret) goto err_conf; - ret = fsg_bind_config(c->cdev, c, &fsg_common); - if (ret < 0) + f_msg_multi = usb_get_function(fi_msg); + if (IS_ERR(f_msg_multi)) { + ret = PTR_ERR(f_msg_multi); goto err_fsg; + } + + fsg_opts = container_of(fi_msg, struct fsg_opts, func_inst); + ret = fsg_common_run_thread(fsg_opts->common); + if (ret) + goto err_run; + + ret = usb_add_function(c, f_msg_multi); + if (ret) + goto err_run; return 0; +err_run: + usb_put_function(f_msg_multi); err_fsg: usb_remove_function(c, f_acm_multi); err_conf: @@ -311,6 +330,8 @@ static int __ref multi_bind(struct usb_composite_dev *cdev) #ifdef USB_ETH_RNDIS struct f_rndis_opts *rndis_opts; #endif + struct fsg_opts *fsg_opts; + struct fsg_config config; int status; if (!can_support_ecm(cdev->gadget)) { @@ -373,41 +394,65 @@ static int __ref multi_bind(struct usb_composite_dev *cdev) } /* set up mass storage function */ - { - void *retp; - retp = fsg_common_from_params(&fsg_common, cdev, &fsg_mod_data, - fsg_num_buffers);
[PATCH v4 4/5] usb/gadget: f_mass_storage: remove compatibility layer
There are no more old interface users left. Remove it. Signed-off-by: Andrzej Pietrasiewicz Signed-off-by: Kyungmin Park --- drivers/usb/gadget/f_mass_storage.c | 154 +-- drivers/usb/gadget/f_mass_storage.h | 21 - 2 files changed, 1 insertions(+), 174 deletions(-) diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 4320eae..837a443 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -2644,17 +2644,13 @@ void fsg_common_get(struct fsg_common *common) { kref_get(&common->ref); } -#ifndef USB_FMS_INCLUDED EXPORT_SYMBOL(fsg_common_get); -#endif void fsg_common_put(struct fsg_common *common) { kref_put(&common->ref, fsg_common_release); } -#ifndef USB_FMS_INCLUDED EXPORT_SYMBOL(fsg_common_put); -#endif /* check if fsg_num_buffers is within a valid range */ static inline int fsg_num_buffers_validate(unsigned int fsg_num_buffers) @@ -2692,9 +2688,7 @@ void fsg_common_set_sysfs(struct fsg_common *common, bool sysfs) { common->sysfs = sysfs; } -#ifndef USB_FMS_INCLUDED EXPORT_SYMBOL(fsg_common_set_sysfs); -#endif static void _fsg_common_free_buffers(struct fsg_buffhd *buffhds, unsigned n) { @@ -2746,9 +2740,7 @@ error_release: return -ENOMEM; } -#ifndef USB_FMS_INCLUDED EXPORT_SYMBOL(fsg_common_set_num_buffers); -#endif static inline void fsg_common_remove_sysfs(struct fsg_lun *lun) { @@ -2769,9 +2761,7 @@ void fsg_common_remove_lun(struct fsg_lun *lun, bool sysfs) kfree(lun->name); kfree(lun); } -#ifndef USB_FMS_INCLUDED EXPORT_SYMBOL(fsg_common_remove_lun); -#endif void _fsg_common_remove_luns(struct fsg_common *common, int n) { @@ -2783,9 +2773,7 @@ void _fsg_common_remove_luns(struct fsg_common *common, int n) common->luns[i] = NULL; } } -#ifndef USB_FMS_INCLUDED EXPORT_SYMBOL(fsg_common_remove_luns); -#endif void fsg_common_remove_luns(struct fsg_common *common) { @@ -2798,9 +2786,7 @@ void fsg_common_free_luns(struct fsg_common *common) kfree(common->luns); common->luns = NULL; } -#ifndef USB_FMS_INCLUDED EXPORT_SYMBOL(fsg_common_free_luns); -#endif int fsg_common_set_nluns(struct fsg_common *common, int nluns) { @@ -2826,35 +2812,27 @@ int fsg_common_set_nluns(struct fsg_common *common, int nluns) return 0; } -#ifndef USB_FMS_INCLUDED EXPORT_SYMBOL(fsg_common_set_nluns); -#endif void fsg_common_free_buffers(struct fsg_common *common) { _fsg_common_free_buffers(common->buffhds, common->fsg_num_buffers); common->buffhds = NULL; } -#ifndef USB_FMS_INCLUDED EXPORT_SYMBOL(fsg_common_free_buffers); -#endif void fsg_common_set_ops(struct fsg_common *common, const struct fsg_operations *ops) { common->ops = ops; } -#ifndef USB_FMS_INCLUDED EXPORT_SYMBOL(fsg_common_set_ops); -#endif void fsg_common_set_private_data(struct fsg_common *common, void *priv) { common->private_data = priv; } -#ifndef USB_FMS_INCLUDED EXPORT_SYMBOL(fsg_common_set_private_data); -#endif int fsg_common_set_cdev(struct fsg_common *common, struct usb_composite_dev *cdev, bool can_stall) @@ -2884,9 +2862,7 @@ int fsg_common_set_cdev(struct fsg_common *common, return 0; } -#ifndef USB_FMS_INCLUDED EXPORT_SYMBOL(fsg_common_set_cdev); -#endif static inline int fsg_common_add_sysfs(struct fsg_common *common, struct fsg_lun *lun) @@ -3027,9 +3003,7 @@ error_name: kfree(lun); return rc; } -#ifndef USB_FMS_INCLUDED EXPORT_SYMBOL(fsg_common_create_lun); -#endif int fsg_common_create_luns(struct fsg_common *common, struct fsg_config *cfg) { @@ -3051,9 +3025,7 @@ fail: _fsg_common_remove_luns(common, i); return rc; } -#ifndef USB_FMS_INCLUDED EXPORT_SYMBOL(fsg_common_create_luns); -#endif void fsg_common_set_inquiry_string(struct fsg_common *common, const char *vn, const char *pn) @@ -3070,9 +3042,7 @@ void fsg_common_set_inquiry_string(struct fsg_common *common, const char *vn, : "File-Stor Gadget"), i); } -#ifndef USB_FMS_INCLUDED EXPORT_SYMBOL(fsg_common_set_inquiry_string); -#endif int fsg_common_run_thread(struct fsg_common *common) { @@ -3091,66 +3061,7 @@ int fsg_common_run_thread(struct fsg_common *common) return 0; } -#ifndef USB_FMS_INCLUDED EXPORT_SYMBOL(fsg_common_run_thread); -#endif - -struct fsg_common *fsg_common_init(struct fsg_common *common, - struct usb_composite_dev *cdev, - struct fsg_config *cfg) -{ - int rc; - - common = fsg_common_setup(common, !!common); - if (IS_ERR(common)) - return common; - fsg_common_set_sysfs(common, true); - common->state
[PATCH v4 0/1] Equivalent of g_acm_ms.ko with configfs
Here I present the conversion of everything that is required to provide the equivalent of g_acm_ms.ko with configfs. In fact this series consists of just one patch; everything required to provide the equivalent of g_acm_ms.ko with configfs has been done in the series related to the g_mass_storage.ko. The current series just moves the g_acm_ms to the new function interface of f_mass_storage. v1..v2: - removed the cause of Felipe returning -ENOLOG - moved fsg_common_set_sysfs invocation after the lun number is set, so that the latter operation does not try freeing nonexistent sysfs entries v2..v3: - rebased onto 3.12-rc1 v3..v4: - rebased onto Felipe's "testing" (3.12-rc3) A branch 'usb-gadget-configfs-3.12' is available at: git://git.linaro.org/people/mszyprowski/linux-srpol.git This series depends on the [PATCH v4 ] Equivalent of g_mass_storage with configfs which has just been sent. BACKWARD COMPATIBILITY == Please note that the old g_acm_ms.ko is still available and works. USING THE NEW "GADGET" == Please refer to this post: http://www.spinics.net/lists/linux-usb/msg76388.html for general information from Sebastian on how to use configfs-based gadgets (*). The g_acm_ms.ko provides 2 functions: - acm (described in (*)) - mass storage (described in a series preceding the current one, I will reply to this post to send a link when spinics or gmane has indexed the series in question) The procedure of setting up such a gadget with configfs is given below with an example: $ modprobe libcomposite $ mount none cfg -t configfs $ mkdir cfg/usb_gadget/g1 $ cd cfg/usb_gadget/g1 $ echo 0x0106 > idProduct $ echo 0x04e8 > idVendor $ mkdir strings/0x409 $ echo my-serial-number > strings/0x409/serialnumber $ echo my-manufacturer > strings/0x409/manufacturer $ echo "ACM/MS Gadget" > strings/0x409/product $ mkdir configs/c.1 $ echo 120 > configs/c.1/MaxPower $ mkdir configs/c.1/strings/0x409 $ echo "Conf 1" > configs/c.1/strings/0x409/configuration $ mkdir functions/mass_storage.0 $ echo /root/lun0.img > functions/mass_storage.0/lun.0/file $ mkdir functions/mass_storage.0/lun.1 $ echo /root/lun1.img > functions/mass_storage.0/lun.1/file $ mkdir functions/acm.usb0 $ ln -s functions/mass_storage.0 configs/c.1 $ ln -s functions/acm.usb0 configs/c.1 $ echo s3c-hsotg > UDC After unbinding the gadget with echo "" > UDC the symbolic links in the configuration directory can be removed, the strings/* subdirectories in the configuration directory can be removed, the strings/* subdirectories at the gadget level can be removed and the configs/* subdirectories can be removed. The functions/* subdirectories can be removed. After that the gadget directory can be removed. After that the respective modules can be unloaded. TESTING THE FUNCTIONS acm) On the host: cat > /dev/ttyACM0 On the device: cat /dev/ttyGS0 and then the other way round: cat > /dev/ttyGS0 cat /dev/ttyACM0 mass storage) device: connect the gadget, enable it host: dmesg, see the USB drives appear (if system configured to automatically mount) Andrzej Pietrasiewicz (1): usb/gadget: acm_ms: convert to new interface of f_mass_storage drivers/usb/gadget/Kconfig |1 + drivers/usb/gadget/acm_ms.c | 113 --- 2 files changed, 75 insertions(+), 39 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
[PATCH v5 14/15] usb/gadget: storage_common: add methods to show/store 'cdrom' and 'removable'
This will be required by configfs integration. Signed-off-by: Andrzej Pietrasiewicz Signed-off-by: Kyungin Park --- drivers/usb/gadget/storage_common.c | 42 +++ drivers/usb/gadget/storage_common.h |5 2 files changed, 47 insertions(+), 0 deletions(-) diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c index 969948d..c7b78a1 100644 --- a/drivers/usb/gadget/storage_common.c +++ b/drivers/usb/gadget/storage_common.c @@ -359,6 +359,17 @@ ssize_t fsg_show_file(struct fsg_lun *curlun, struct rw_semaphore *filesem, } EXPORT_SYMBOL(fsg_show_file); +ssize_t fsg_show_cdrom(struct fsg_lun *curlun, char *buf) +{ + return sprintf(buf, "%u\n", curlun->cdrom); +} +EXPORT_SYMBOL(fsg_show_cdrom); + +ssize_t fsg_show_removable(struct fsg_lun *curlun, char *buf) +{ + return sprintf(buf, "%u\n", curlun->removable); +} +EXPORT_SYMBOL(fsg_show_removable); ssize_t fsg_store_ro(struct fsg_lun *curlun, struct rw_semaphore *filesem, const char *buf, size_t count) @@ -439,4 +450,35 @@ ssize_t fsg_store_file(struct fsg_lun *curlun, struct rw_semaphore *filesem, } EXPORT_SYMBOL(fsg_store_file); +ssize_t fsg_store_cdrom(struct fsg_lun *curlun, const char *buf, size_t count) +{ + unsignedcdrom; + int ret; + + ret = kstrtouint(buf, 2, &cdrom); + if (ret) + return ret; + + curlun->cdrom = cdrom; + + return count; +} +EXPORT_SYMBOL(fsg_store_cdrom); + +ssize_t fsg_store_removable(struct fsg_lun *curlun, const char *buf, + size_t count) +{ + unsignedremovable; + int ret; + + ret = kstrtouint(buf, 2, &removable); + if (ret) + return ret; + + curlun->removable = removable; + + return count; +} +EXPORT_SYMBOL(fsg_store_removable); + MODULE_LICENSE("GPL"); diff --git a/drivers/usb/gadget/storage_common.h b/drivers/usb/gadget/storage_common.h index aa8bf94..ca7b479 100644 --- a/drivers/usb/gadget/storage_common.h +++ b/drivers/usb/gadget/storage_common.h @@ -214,10 +214,15 @@ ssize_t fsg_show_ro(struct fsg_lun *curlun, char *buf); ssize_t fsg_show_nofua(struct fsg_lun *curlun, char *buf); ssize_t fsg_show_file(struct fsg_lun *curlun, struct rw_semaphore *filesem, char *buf); +ssize_t fsg_show_cdrom(struct fsg_lun *curlun, char *buf); +ssize_t fsg_show_removable(struct fsg_lun *curlun, char *buf); ssize_t fsg_store_ro(struct fsg_lun *curlun, struct rw_semaphore *filesem, const char *buf, size_t count); ssize_t fsg_store_nofua(struct fsg_lun *curlun, const char *buf, size_t count); ssize_t fsg_store_file(struct fsg_lun *curlun, struct rw_semaphore *filesem, const char *buf, size_t count); +ssize_t fsg_store_cdrom(struct fsg_lun *curlun, const char *buf, size_t count); +ssize_t fsg_store_removable(struct fsg_lun *curlun, const char *buf, + size_t count); #endif /* USB_STORAGE_COMMON_H */ -- 1.7.0.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 v5 10/15] usb/gadget: f_mass_storage: create fsg_common_run_thread for use in fsg_common_init
fsg_common_init is a lengthy function. Factor a portion of it out. Signed-off-by: Andrzej Pietrasiewicz Signed-off-by: Kyungmin Park --- drivers/usb/gadget/f_mass_storage.c | 32 +--- drivers/usb/gadget/f_mass_storage.h |2 ++ 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 1cac208..3b2fef8 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -3006,6 +3006,24 @@ void fsg_common_set_inquiry_string(struct fsg_common *common, const char *vn, i); } +int fsg_common_run_thread(struct fsg_common *common) +{ + common->state = FSG_STATE_IDLE; + /* Tell the thread to start working */ + common->thread_task = + kthread_create(fsg_main_thread, common, "file-storage"); + if (IS_ERR(common->thread_task)) { + common->state = FSG_STATE_TERMINATED; + return PTR_ERR(common->thread_task); + } + + DBG(common, "I/O thread pid: %d\n", task_pid_nr(common->thread_task)); + + wake_up_process(common->thread_task); + + return 0; +} + struct fsg_common *fsg_common_init(struct fsg_common *common, struct usb_composite_dev *cdev, struct fsg_config *cfg) @@ -3043,21 +3061,13 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, fsg_common_set_inquiry_string(common, cfg->vendor_name, cfg->product_name); - /* Tell the thread to start working */ - common->thread_task = - kthread_create(fsg_main_thread, common, "file-storage"); - if (IS_ERR(common->thread_task)) { - rc = PTR_ERR(common->thread_task); - goto error_release; - } /* Information */ INFO(common, FSG_DRIVER_DESC ", version: " FSG_DRIVER_VERSION "\n"); - INFO(common, "Number of LUNs=%d\n", common->nluns); - - DBG(common, "I/O thread pid: %d\n", task_pid_nr(common->thread_task)); - wake_up_process(common->thread_task); + rc = fsg_common_run_thread(common); + if (rc) + goto error_release; return common; diff --git a/drivers/usb/gadget/f_mass_storage.h b/drivers/usb/gadget/f_mass_storage.h index 343a8a4..1ae8d20 100644 --- a/drivers/usb/gadget/f_mass_storage.h +++ b/drivers/usb/gadget/f_mass_storage.h @@ -131,6 +131,8 @@ int fsg_common_create_luns(struct fsg_common *common, struct fsg_config *cfg); void fsg_common_set_inquiry_string(struct fsg_common *common, const char *vn, const char *pn); +int fsg_common_run_thread(struct fsg_common *common); + void fsg_config_from_params(struct fsg_config *cfg, const struct fsg_module_parameters *params, unsigned int fsg_num_buffers); -- 1.7.0.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 v4 1/1] usb/gadget: acm_ms: convert to new interface of f_mass_storage
Convert the legacy acm_ms gadget to use the new function interface of f_mass_storage, so that later the compatibility layer in f_mass_storage can be removed. Signed-off-by: Andrzej Pietrasiewicz Signed-off-by: Kyungmin Park --- drivers/usb/gadget/Kconfig |1 + drivers/usb/gadget/acm_ms.c | 113 --- 2 files changed, 75 insertions(+), 39 deletions(-) diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index bc5dea2..886db6a 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -1021,6 +1021,7 @@ config USB_G_ACM_MS select USB_U_SERIAL select USB_F_ACM select USB_U_MS + select USB_F_MASS_STORAGE help This driver provides two functions in one configuration: a mass storage, and a CDC ACM (serial port) link. diff --git a/drivers/usb/gadget/acm_ms.c b/drivers/usb/gadget/acm_ms.c index 31aae8f..b405bc4 100644 --- a/drivers/usb/gadget/acm_ms.c +++ b/drivers/usb/gadget/acm_ms.c @@ -31,17 +31,7 @@ #define ACM_MS_VENDOR_NUM 0x1d6b /* Linux Foundation */ #define ACM_MS_PRODUCT_NUM 0x0106 /* Composite Gadget: ACM + MS*/ -/*-*/ - -/* - * Kbuild is not very cooperative with respect to linking separately - * compiled library objects into one module. So for now we won't use - * separate compilation ... ensuring init/exit sections work to shrink - * the runtime footprint, and giving us at least some parts of what - * a "gcc --combine ... part1.c part2.c part3.c ... " build would. - */ -#define USB_FMS_INCLUDED -#include "f_mass_storage.c" +#include "f_mass_storage.h" /*-*/ USB_GADGET_COMPOSITE_OPTIONS(); @@ -121,16 +111,19 @@ static unsigned int fsg_num_buffers = CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS; FSG_MODULE_PARAMETERS(/* no prefix */, fsg_mod_data); -static struct fsg_common fsg_common; - /*-*/ static struct usb_function *f_acm; static struct usb_function_instance *f_acm_inst; + +static struct usb_function_instance *fi_msg; +static struct usb_function *f_msg; + /* * We _always_ have both ACM and mass storage functions. */ static int __init acm_ms_do_config(struct usb_configuration *c) { + struct fsg_opts *opts; int status; if (gadget_is_otg(c->cdev->gadget)) { @@ -138,31 +131,37 @@ static int __init acm_ms_do_config(struct usb_configuration *c) c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; } - f_acm_inst = usb_get_function_instance("acm"); - if (IS_ERR(f_acm_inst)) - return PTR_ERR(f_acm_inst); + opts = container_of(fi_msg, struct fsg_opts, func_inst); f_acm = usb_get_function(f_acm_inst); - if (IS_ERR(f_acm)) { - status = PTR_ERR(f_acm); - goto err_func; + if (IS_ERR(f_acm)) + return PTR_ERR(f_acm); + + f_msg = usb_get_function(fi_msg); + if (IS_ERR(f_msg)) { + status = PTR_ERR(f_msg); + goto put_acm; } status = usb_add_function(c, f_acm); if (status < 0) - goto err_conf; + goto put_msg; - status = fsg_bind_config(c->cdev, c, &fsg_common); - if (status < 0) - goto err_fsg; + status = fsg_common_run_thread(opts->common); + if (status) + goto remove_acm; + + status = usb_add_function(c, f_msg); + if (status) + goto remove_acm; return 0; -err_fsg: +remove_acm: usb_remove_function(c, f_acm); -err_conf: +put_msg: + usb_put_function(f_msg); +put_acm: usb_put_function(f_acm); -err_func: - usb_put_function_instance(f_acm_inst); return status; } @@ -178,46 +177,82 @@ static struct usb_configuration acm_ms_config_driver = { static int __init acm_ms_bind(struct usb_composite_dev *cdev) { struct usb_gadget *gadget = cdev->gadget; + struct fsg_opts *opts; + struct fsg_config config; int status; - void*retp; - /* set up mass storage function */ - retp = fsg_common_from_params(&fsg_common, cdev, &fsg_mod_data, - fsg_num_buffers); - if (IS_ERR(retp)) { - status = PTR_ERR(retp); - return PTR_ERR(retp); + f_acm_inst = usb_get_function_instance("acm"); + if (IS_ERR(f_acm_inst)) + return PTR_ERR(f_acm_inst); + + fi_msg = usb_get_function_instance("mass_storage"); + if (IS_ERR(fi_msg)) { + status = PTR_ERR(fi_msg); + goto fail_get_msg; } + /* set up mass storage function */ + fsg_config_from_params(&config, &fsg_mod_data,
[PATCH v5 12/15] usb/gadget: mass_storage: convert to new interface of f_mass_storage
Convert old mass_storage gadget to use the new interface of f_mass_storage so that later the compatibility layer in f_mass_storage can be removed. Signed-off-by: Andrzej Pietrasiewicz Signed-off-by: Kyungmin Park --- drivers/usb/gadget/Kconfig|1 + drivers/usb/gadget/mass_storage.c | 107 +++- 2 files changed, 81 insertions(+), 27 deletions(-) diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 40adaf0..7d64e47 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -885,6 +885,7 @@ config USB_MASS_STORAGE depends on BLOCK select USB_LIBCOMPOSITE select USB_U_MS + select USB_F_MASS_STORAGE help The Mass Storage Gadget acts as a USB Mass Storage disk drive. As its storage repository it can use a regular file or a block diff --git a/drivers/usb/gadget/mass_storage.c b/drivers/usb/gadget/mass_storage.c index f670251..580f23e 100644 --- a/drivers/usb/gadget/mass_storage.c +++ b/drivers/usb/gadget/mass_storage.c @@ -46,17 +46,7 @@ #define FSG_VENDOR_ID 0x0525 /* NetChip */ #define FSG_PRODUCT_ID 0xa4a5 /* Linux-USB File-backed Storage Gadget */ -/*-*/ - -/* - * kbuild is not very cooperative with respect to linking separately - * compiled library objects into one module. So for now we won't use - * separate compilation ... ensuring init/exit sections work to shrink - * the runtime footprint, and giving us at least some parts of what - * a "gcc --combine ... part1.c part2.c part3.c ... " build would. - */ -#define USB_FMS_INCLUDED -#include "f_mass_storage.c" +#include "f_mass_storage.h" /*-*/ USB_GADGET_COMPOSITE_OPTIONS(); @@ -107,6 +97,9 @@ static struct usb_gadget_strings *dev_strings[] = { NULL, }; +static struct usb_function_instance *fi_msg; +static struct usb_function *f_msg; + /** Configurations **/ static struct fsg_module_parameters mod_data = { @@ -139,13 +132,7 @@ static int msg_thread_exits(struct fsg_common *common) static int __init msg_do_config(struct usb_configuration *c) { - static const struct fsg_operations ops = { - .thread_exits = msg_thread_exits, - }; - static struct fsg_common common; - - struct fsg_common *retp; - struct fsg_config config; + struct fsg_opts *opts; int ret; if (gadget_is_otg(c->cdev->gadget)) { @@ -153,15 +140,24 @@ static int __init msg_do_config(struct usb_configuration *c) c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; } - fsg_config_from_params(&config, &mod_data, fsg_num_buffers); - config.ops = &ops; + opts = container_of(fi_msg, struct fsg_opts, func_inst); + + f_msg = usb_get_function(fi_msg); + if (IS_ERR(f_msg)) + return PTR_ERR(f_msg); - retp = fsg_common_init(&common, c->cdev, &config); - if (IS_ERR(retp)) - return PTR_ERR(retp); + ret = fsg_common_run_thread(opts->common); + if (ret) + goto put_func; - ret = fsg_bind_config(c->cdev, c, &common); - fsg_common_put(&common); + ret = usb_add_function(c, f_msg); + if (ret) + goto put_func; + + return 0; + +put_func: + usb_put_function(f_msg); return ret; } @@ -176,23 +172,79 @@ static struct usb_configuration msg_config_driver = { static int __init msg_bind(struct usb_composite_dev *cdev) { + static const struct fsg_operations ops = { + .thread_exits = msg_thread_exits, + }; + struct fsg_opts *opts; + struct fsg_config config; int status; + fi_msg = usb_get_function_instance("mass_storage"); + if (IS_ERR(fi_msg)) + return PTR_ERR(fi_msg); + + fsg_config_from_params(&config, &mod_data, fsg_num_buffers); + opts = container_of(fi_msg, struct fsg_opts, func_inst); + + opts->no_configfs = true; + status = fsg_common_set_num_buffers(opts->common, fsg_num_buffers); + if (status) + goto fail; + + status = fsg_common_set_nluns(opts->common, config.nluns); + if (status) + goto fail_set_nluns; + + fsg_common_set_ops(opts->common, &ops); + + status = fsg_common_set_cdev(opts->common, cdev, config.can_stall); + if (status) + goto fail_set_cdev; + + fsg_common_set_sysfs(opts->common, true); + status = fsg_common_create_luns(opts->common, &config); + if (status) + goto fail_set_cdev; + + fsg_common_set_inquiry_string(opts->common, config.vendor_name, + config.product_name); + status = usb_string_ids_tab(cdev, strings_dev); if (status < 0)
[PATCH v4 5/5] usb/gadget: mass_storage: merge usb_f_mass_storage module with u_ms module
u_ms.ko is needed only together with usb_f_mass_storage.ko. Merge them. Signed-off-by: Andrzej Pietrasiewicz Signed-off-by: Kyungmin Park --- drivers/usb/gadget/Kconfig |7 --- drivers/usb/gadget/Makefile |4 +--- 2 files changed, 1 insertions(+), 10 deletions(-) diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 4b0c456..604f885 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -525,9 +525,6 @@ config USB_F_SUBSET config USB_F_RNDIS tristate -config USB_U_MS - tristate - config USB_F_MASS_STORAGE tristate @@ -671,7 +668,6 @@ config USB_CONFIGFS_PHONET config USB_CONFIGFS_MASS_STORAGE boolean "Mass storage" depends on USB_CONFIGFS - select USB_U_MS select USB_F_MASS_STORAGE help The Mass Storage Gadget acts as a USB Mass Storage disk drive. @@ -895,7 +891,6 @@ config USB_MASS_STORAGE tristate "Mass Storage Gadget" depends on BLOCK select USB_LIBCOMPOSITE - select USB_U_MS select USB_F_MASS_STORAGE help The Mass Storage Gadget acts as a USB Mass Storage disk drive. @@ -1020,7 +1015,6 @@ config USB_G_ACM_MS select USB_LIBCOMPOSITE select USB_U_SERIAL select USB_F_ACM - select USB_U_MS select USB_F_MASS_STORAGE help This driver provides two functions in one configuration: @@ -1037,7 +1031,6 @@ config USB_G_MULTI select USB_U_SERIAL select USB_U_ETHER select USB_F_ACM - select USB_U_MS select USB_F_MASS_STORAGE help The Multifunction Composite Gadget provides Ethernet (RNDIS diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile index 4a86b0c..f1bd42a 100644 --- a/drivers/usb/gadget/Makefile +++ b/drivers/usb/gadget/Makefile @@ -60,9 +60,7 @@ usb_f_ecm_subset-y:= f_subset.o obj-$(CONFIG_USB_F_SUBSET) += usb_f_ecm_subset.o usb_f_rndis-y := f_rndis.o obj-$(CONFIG_USB_F_RNDIS) += usb_f_rndis.o -u_ms-y := storage_common.o -obj-$(CONFIG_USB_U_MS) += u_ms.o -usb_f_mass_storage-y := f_mass_storage.o +usb_f_mass_storage-y := f_mass_storage.o storage_common.o obj-$(CONFIG_USB_F_MASS_STORAGE)+= usb_f_mass_storage.o # -- 1.7.0.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 v4 1/5] usb/gadget: multi: convert to new interface of f_ecm
Convert the legacy multi gadget to the new interface of f_ecm, so that later the compatibility layer in f_ecm can be removed. Signed-off-by: Andrzej Pietrasiewicz Signed-off-by: Kyungmin Park --- drivers/usb/gadget/Kconfig |1 + drivers/usb/gadget/multi.c | 68 ++- 2 files changed, 61 insertions(+), 8 deletions(-) diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 886db6a..92a8966 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -1070,6 +1070,7 @@ config USB_G_MULTI_CDC bool "CDC Ethernet + CDC Serial + Storage configuration" depends on USB_G_MULTI default n + select USB_F_ECM help This option enables a configuration with CDC Ethernet (ECM), CDC Serial and Mass Storage functions available in the Multifunction diff --git a/drivers/usb/gadget/multi.c b/drivers/usb/gadget/multi.c index 42a5bed..7dd5544 100644 --- a/drivers/usb/gadget/multi.c +++ b/drivers/usb/gadget/multi.c @@ -15,6 +15,7 @@ #include #include +#include #include "u_serial.h" #if defined USB_ETH_RNDIS @@ -44,8 +45,7 @@ MODULE_LICENSE("GPL"); #define USB_FMS_INCLUDED #include "f_mass_storage.c" -#define USBF_ECM_INCLUDED -#include "f_ecm.c" +#include "u_ecm.h" #ifdef USB_ETH_RNDIS # define USB_FRNDIS_INCLUDED # include "f_rndis.c" @@ -151,14 +151,14 @@ FSG_MODULE_PARAMETERS(/* no prefix */, fsg_mod_data); static struct fsg_common fsg_common; -static u8 host_mac[ETH_ALEN]; - static struct usb_function_instance *fi_acm; static struct eth_dev *the_dev; /** RNDIS **/ #ifdef USB_ETH_RNDIS +static u8 host_mac[ETH_ALEN]; + static struct usb_function *f_acm_rndis; static __init int rndis_do_config(struct usb_configuration *c) @@ -220,7 +220,9 @@ static __ref int rndis_config_register(struct usb_composite_dev *cdev) /** CDC ECM **/ #ifdef CONFIG_USB_G_MULTI_CDC +static struct usb_function_instance *fi_ecm; static struct usb_function *f_acm_multi; +static struct usb_function *f_ecm; static __init int cdc_do_config(struct usb_configuration *c) { @@ -231,14 +233,20 @@ static __init int cdc_do_config(struct usb_configuration *c) c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; } - ret = ecm_bind_config(c, host_mac, the_dev); + f_ecm = usb_get_function(fi_ecm); + if (IS_ERR(f_ecm)) + return PTR_ERR(f_ecm); + + ret = usb_add_function(c, f_ecm); if (ret < 0) - return ret; + goto err_func_ecm; /* implicit port_num is zero */ f_acm_multi = usb_get_function(fi_acm); - if (IS_ERR(f_acm_multi)) - return PTR_ERR(f_acm_multi); + if (IS_ERR(f_acm_multi)) { + ret = PTR_ERR(f_acm_multi); + goto err_func_acm; + } ret = usb_add_function(c, f_acm_multi); if (ret) @@ -253,6 +261,10 @@ err_fsg: usb_remove_function(c, f_acm_multi); err_conf: usb_put_function(f_acm_multi); +err_func_acm: + usb_remove_function(c, f_ecm); +err_func_ecm: + usb_put_function(f_ecm); return ret; } @@ -285,6 +297,9 @@ static __ref int cdc_config_register(struct usb_composite_dev *cdev) static int __ref multi_bind(struct usb_composite_dev *cdev) { struct usb_gadget *gadget = cdev->gadget; +#ifdef CONFIG_USB_G_MULTI_CDC + struct f_ecm_opts *ecm_opts; +#endif int status; if (!can_support_ecm(cdev->gadget)) { @@ -293,11 +308,39 @@ static int __ref multi_bind(struct usb_composite_dev *cdev) return -EINVAL; } +#ifdef CONFIG_USB_G_MULTI_CDC + fi_ecm = usb_get_function_instance("ecm"); + if (IS_ERR(fi_ecm)) + return PTR_ERR(fi_ecm); + + ecm_opts = container_of(fi_ecm, struct f_ecm_opts, func_inst); + + gether_set_qmult(ecm_opts->net, qmult); + if (!gether_set_host_addr(ecm_opts->net, host_addr)) + pr_info("using host ethernet address: %s", host_addr); + if (!gether_set_dev_addr(ecm_opts->net, dev_addr)) + pr_info("using self ethernet address: %s", dev_addr); + + the_dev = netdev_priv(ecm_opts->net); + +#elif defined USB_ETH_RNDIS + /* set up network link layer */ the_dev = gether_setup(cdev->gadget, dev_addr, host_addr, host_mac, qmult); if (IS_ERR(the_dev)) return PTR_ERR(the_dev); +#endif + +#if (defined CONFIG_USB_G_MULTI_CDC && defined USB_ETH_RNDIS) + gether_set_gadget(ecm_opts->net, cdev->gadget); + status = gether_register_netdev(ecm_opts->net); + if (status) + goto fail0; + ecm_opts->bound = true; + + gether_get_host_addr_u8(ecm_opts->net, host_mac); +#endif /* set up serial link layer */ fi_acm = usb_get_function_instance("acm"); @@ -345,7 +388,11 @@ fail2: fail1:
[PATCH v4 0/5] Equivalent of g_multi.ko with configfs
Here I present the conversion of everything that is required to provide the equivalent of g_multi.ko with configfs. v1..v2: - removed the cause of Felipe returning -ENOLOG - moved fsg_common_set_sysfs invocation after the lun number is set, so that the latter operation does not try freeing nonexistent sysfs entries - adapted to earlier changes in multi.c (*_do_config) v2..v3: - rebased onto 3.12-rc1 v3..v4: - rebased onto Felipe's "testing" (3.12-rc3) A branch 'usb-gadget-configfs-3.12' is available at: git://git.linaro.org/people/mszyprowski/linux-srpol.git This series depends on a [PATCH v3] Equivalent of g_acm_ms with configfs, which has just been sent. BACKWARD COMPATIBILITY == Please note that the old g_multi.ko is still available and works. USING THE NEW "GADGET" == Please refer to this post: http://www.spinics.net/lists/linux-usb/msg76388.html for general information from Sebastian on how to use configfs-based gadgets (*). The g_multi.ko provides 4 functions: - acm (described in (*)) - ecm (http://www.spinics.net/lists/linux-usb/msg86561.html) - rndis (http://www.spinics.net/lists/linux-usb/msg86561.html) - mass storage (described in a series preceding the current one, I will reply to this post to send a link when spinics or gmane has indexed the series in question) and using all of them with configfs has already been described. The procedure of setting up a new "multi" gadget with configfs is given below with an example: $ modprobe libcomposite $ mount none cfg -t configfs $ mkdir cfg/usb_gadget/g1 $ cd cfg/usb_gadget/g1 $ echo 0x0106 > idProduct $ echo 0x04e8 > idVendor $ mkdir strings/0x409 $ echo my-serial-num > strings/0x409/serialnumber $ echo my-manufacturer > strings/0x409/manufacturer $ echo "Multi Gadget" > strings/0x409/product $ mkdir configs/c.1 $ echo 120 > configs/c.1/MaxPower $ mkdir configs/c.1/strings/0x409 $ echo "Conf 1" > configs/c.1/strings/0x409/configuration $ mkdir configs/c.2 $ echo 120 > configs/c.2/MaxPower $ mkdir configs/c.2/strings/0x409 $ echo "Conf 2" > configs/c.2/strings/0x409/configuration $ mkdir functions/mass_storage.0 $ echo /root/lun0.img > functions/mass_storage.0/lun.0/file $ mkdir functions/mass_storage.0/lun.1 $ echo /root/lun1.img > functions/mass_storage.0/lun.1/file $ mkdir functions/acm.0 $ mkdir functions/ecm.0 $ mkdir functions/rndis.0 $ ln -s functions/rndis.0 configs/c.1 $ ln -s functions/acm.0 configs/c.1 $ ln -s functions/mass_storage.0 configs/c.1 $ ln -s functions/ecm.0 configs/c.2 $ ln -s functions/acm.0 configs/c.2 $ ln -s functions/mass_storage.0 configs/c.2 After unbinding the gadget with echo "" > UDC the symbolic links in the configuration directory can be removed, the strings/* subdirectories in the configuration directory can be removed, the strings/* subdirectories at the gadget level can be removed and the configs/* subdirectories can be removed. The functions/* subdirectories can be removed. After that the gadget directory can be removed. After that the respective modules can be unloaded. TESTING THE FUNCTIONS acm) On the host: cat > /dev/ttyACM0 On the device: cat /dev/ttyGS0 and then the other way round: cat > /dev/ttyGS0 cat /dev/ttyACM0 mass storage) device: connect the gadget, enable it host: dmesg, see the USB drives appear (if system configured to automatically mount) ecm, rndis) On the device: ping On the host: ping Andrzej Pietrasiewicz (5): usb/gadget: multi: convert to new interface of f_ecm usb/gadget: multi: convert to new interface of f_rndis usb/gadget: multi: convert to new interface of f_mass_storage usb/gadget: f_mass_storage: remove compatibility layer usb/gadget: mass_storage: merge usb_f_mass_storage module with u_ms module drivers/usb/gadget/Kconfig | 12 +-- drivers/usb/gadget/Makefile |4 +- drivers/usb/gadget/f_mass_storage.c | 154 +-- drivers/usb/gadget/f_mass_storage.h | 21 --- drivers/usb/gadget/multi.c | 237 +++ 5 files changed, 190 insertions(+), 238 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 05/10] ARM: dts: omap3-beagle: Use reset-gpios for hsusb2_reset
Hi Roger, Yes, I will. I've been waiting for these ones for so long :-) Thanks, Benoit On 03/10/2013 12:34, Roger Quadros wrote: Hi Benoit, Could you please take the device tree related patches [5 to 10] in this series? Thanks. cheers, -roger On 09/24/2013 11:53 AM, Roger Quadros wrote: We no longer need to model the RESET line as a regulator since the USB phy-nop driver accepts "reset-gpios" property. Signed-off-by: Roger Quadros --- arch/arm/boot/dts/omap3-beagle.dts | 13 + 1 files changed, 1 insertions(+), 12 deletions(-) diff --git a/arch/arm/boot/dts/omap3-beagle.dts b/arch/arm/boot/dts/omap3-beagle.dts index dfd8310..71bde47 100644 --- a/arch/arm/boot/dts/omap3-beagle.dts +++ b/arch/arm/boot/dts/omap3-beagle.dts @@ -44,17 +44,6 @@ }; }; - /* HS USB Port 2 RESET */ - hsusb2_reset: hsusb2_reset_reg { - compatible = "regulator-fixed"; - regulator-name = "hsusb2_reset"; - regulator-min-microvolt = <330>; - regulator-max-microvolt = <330>; - gpio = <&gpio5 19 0>; /* gpio_147 */ - startup-delay-us = <7>; - enable-active-high; - }; - /* HS USB Port 2 Power */ hsusb2_power: hsusb2_power_reg { compatible = "regulator-fixed"; @@ -68,7 +57,7 @@ /* HS USB Host PHY on PORT 2 */ hsusb2_phy: hsusb2_phy { compatible = "usb-nop-xceiv"; - reset-supply = <&hsusb2_reset>; + reset-gpios = <&gpio5 19 GPIO_ACTIVE_LOW>;/* gpio_147 */ vcc-supply = <&hsusb2_power>; }; -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v7 09/10] usb: dwc3: omap: manage "usb_otg_ss_refclk960m" clock
Hi, On Wed, Oct 02, 2013 at 04:41:53PM +0300, Roger Quadros wrote: > On 10/02/2013 04:11 PM, Felipe Balbi wrote: > > On Mon, Sep 23, 2013 at 04:11:30PM +0300, Roger Quadros wrote: > >> Hi Felipe, > >> > >> On 09/18/2013 03:49 PM, Roger Quadros wrote: > >>> "usb_otg_ss_refclk960m" is an optional functional clock to the > >>> UBS_OTG_SS module. So manage it in the driver. > >>> > >> > >> Just realized that "usb_otg_ss_refclk960m" is in fact functional clock to > >> the > >> PHY and not USB_OTG_SS module. The name is misleading. > >> > >> So please ignore patch 9 and 10. > > > > ignored. All others are fine, right ? > > > Yes. But I might have to rebase this on top of Phy framework stuff. alright, Greg already took the PHY framework, so maybe we need to just give him my Acked-by and he takes the patches directly as I don't have PYH framework. -- balbi signature.asc Description: Digital signature
[PATCH V2 01/11] USB: OHCI: Properly handle OHCI controller suspend
From: Manjunath Goudar Suspend scenario in case of OHCI was not properly handled in ochi_suspend()routine. Alan Stern suggested, properly handle OHCI suspend scenario. This does generic proper handling of suspend scenario to all OHCI SOC. Signed-off-by: Manjunath Goudar Signed-off-by: Manjunath Goudar Cc: Alan Stern Cc: Arnd Bergmann Cc: Greg KH Cc: linux-usb@vger.kernel.org --- drivers/usb/host/ohci-hcd.c | 11 +-- drivers/usb/host/ohci.h |2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 8ada13f..46087a1 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -1032,10 +1032,11 @@ EXPORT_SYMBOL_GPL(ohci_restart); #ifdef CONFIG_PM -int ohci_suspend(struct usb_hcd *hcd, bool do_wakeup) +int ohci_suspend(struct usb_hcd *hcd) { struct ohci_hcd *ohci = hcd_to_ohci (hcd); unsigned long flags; + int rc = 0; /* Disable irq emission and mark HW unaccessible. Use * the spinlock to properly synchronize with possible pending @@ -1048,7 +1049,13 @@ int ohci_suspend(struct usb_hcd *hcd, bool do_wakeup) clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); spin_unlock_irqrestore (&ohci->lock, flags); - return 0; + synchronize_irq(hcd->irq); + + if (HCD_WAKEUP_PENDING(hcd)) { + ohci_resume(hcd, false); + rc = -EBUSY; + } + return rc; } EXPORT_SYMBOL_GPL(ohci_suspend); diff --git a/drivers/usb/host/ohci.h b/drivers/usb/host/ohci.h index e2e5faa..f2ebd423 100644 --- a/drivers/usb/host/ohci.h +++ b/drivers/usb/host/ohci.h @@ -735,6 +735,6 @@ extern void ohci_init_driver(struct hc_driver *drv, extern int ohci_restart(struct ohci_hcd *ohci); extern int ohci_setup(struct usb_hcd *hcd); #ifdef CONFIG_PM -extern int ohci_suspend(struct usb_hcd *hcd, bool do_wakeup); +extern int ohci_suspend(struct usb_hcd *hcd); extern int ohci_resume(struct usb_hcd *hcd, bool hibernated); #endif -- 1.7.9.5 -- 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 02/11] USB: OHCI: Properly handle ohci-at91 suspend
From: Manjunath Goudar Suspend scenario in case of ohci-at91 glue was not properly handled as it was not suspending generic part of ohci controller. Alan Stern suggested, properly handle ohci-at91 suspend scenario. Calling explicitly the ohci_suspend() routine in ohci_hcd_at91_drv_suspend() will ensure proper handling of suspend scenario. Signed-off-by: Manjunath Goudar Signed-off-by: Manjunath Goudar Cc: Alan Stern Cc: Arnd Bergmann Cc: Greg KH Cc: linux-usb@vger.kernel.org --- drivers/usb/host/ohci-at91.c |8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c index 476b5a5..13449cc 100644 --- a/drivers/usb/host/ohci-at91.c +++ b/drivers/usb/host/ohci-at91.c @@ -636,9 +636,11 @@ ohci_hcd_at91_drv_suspend(struct platform_device *pdev, pm_message_t mesg) { struct usb_hcd *hcd = platform_get_drvdata(pdev); struct ohci_hcd *ohci = hcd_to_ohci(hcd); + int ret; - if (device_may_wakeup(&pdev->dev)) - enable_irq_wake(hcd->irq); + ret = ohci_suspend(hcd); + if (ret) + return ret; /* * The integrated transceivers seem unable to notice disconnect, @@ -658,7 +660,7 @@ ohci_hcd_at91_drv_suspend(struct platform_device *pdev, pm_message_t mesg) at91_stop_clock(); } - return 0; + return ret; } static int ohci_hcd_at91_drv_resume(struct platform_device *pdev) -- 1.7.9.5 -- 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 03/11] USB: OHCI: Properly handle ohci-s3c2410 suspend
From: Manjunath Goudar Suspend scenario in case of ohci-s3c2410 glue was not properly handled as it was not suspending generic part of ohci controller. Alan Stern suggested, properly handle ohci-s3c2410 suspend scenario. Calling explicitly the ohci_suspend() routine in ohci_hcd_s3c2410_drv_suspend() will ensure proper handling of suspend scenario. Signed-off-by: Manjunath Goudar Signed-off-by: Manjunath Goudar Cc: Alan Stern Cc: Arnd Bergmann Cc: Greg KH Cc: linux-usb@vger.kernel.org --- drivers/usb/host/ohci-s3c2410.c | 20 +++- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c index be3429e..0d2a98d 100644 --- a/drivers/usb/host/ohci-s3c2410.c +++ b/drivers/usb/host/ohci-s3c2410.c @@ -426,28 +426,14 @@ static int ohci_hcd_s3c2410_drv_remove(struct platform_device *pdev) static int ohci_hcd_s3c2410_drv_suspend(struct device *dev) { struct usb_hcd *hcd = dev_get_drvdata(dev); - struct ohci_hcd *ohci = hcd_to_ohci(hcd); struct platform_device *pdev = to_platform_device(dev); - unsigned long flags; int rc = 0; - /* -* Root hub was already suspended. Disable irq emission and -* mark HW unaccessible, bail out if RH has been resumed. Use -* the spinlock to properly synchronize with possible pending -* RH suspend or resume activity. -*/ - spin_lock_irqsave(&ohci->lock, flags); - if (ohci->rh_state != OHCI_RH_SUSPENDED) { - rc = -EINVAL; - goto bail; - } - - clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); + rc = ohci_suspend(hcd); + if (rc) + return rc; s3c2410_stop_hc(pdev); -bail: - spin_unlock_irqrestore(&ohci->lock, flags); return rc; } -- 1.7.9.5 -- 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 05/11] USB: OHCI: Properly handle ohci-ep93xx suspend
From: Manjunath Goudar Suspend scenario in case of ohci-ep93xx glue was not properly handled as it was not suspending generic part of ohci controller. Alan Stern suggested, properly handle ohci-ep93xx suspend scenario. Calling explicitly the ohci_suspend() routine in ohci_hcd_ep93xx_drv_suspend() will ensure proper handling of suspend scenario. Signed-off-by: Manjunath Goudar Signed-off-by: Manjunath Goudar Cc: Alan Stern Cc: Arnd Bergmann Cc: Greg KH Cc: linux-usb@vger.kernel.org --- drivers/usb/host/ohci-ep93xx.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/ohci-ep93xx.c b/drivers/usb/host/ohci-ep93xx.c index 492f681..fe60e72 100644 --- a/drivers/usb/host/ohci-ep93xx.c +++ b/drivers/usb/host/ohci-ep93xx.c @@ -112,13 +112,19 @@ static int ohci_hcd_ep93xx_drv_suspend(struct platform_device *pdev, pm_message_ { struct usb_hcd *hcd = platform_get_drvdata(pdev); struct ohci_hcd *ohci = hcd_to_ohci(hcd); + int ret; if (time_before(jiffies, ohci->next_statechange)) msleep(5); ohci->next_statechange = jiffies; - clk_disable(usb_host_clock); - return 0; + ret = ohci_suspend(hcd); + if (ret) + return ret; + + ep93xx_stop_hc(&pdev->dev); + + return ret; } static int ohci_hcd_ep93xx_drv_resume(struct platform_device *pdev) -- 1.7.9.5 -- 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 04/11] USB: OHCI: Properly handle ohci-da8xx suspend
From: Manjunath Goudar Suspend scenario in case of ohci-da8xx glue was not properly handled as it was not suspending generic part of ohci controller. Alan Stern suggested, properly handle ohci-da8xx suspend scenario. Calling explicitly the ohci_suspend() routine in ohci_da8xx_suspend() will ensure proper handling of suspend scenario. Signed-off-by: Manjunath Goudar Signed-off-by: Manjunath Goudar Cc: Alan Stern Cc: Arnd Bergmann Cc: Greg KH Cc: linux-usb@vger.kernel.org --- drivers/usb/host/ohci-da8xx.c | 14 ++ 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c index 9be59f1..4b9a7a3 100644 --- a/drivers/usb/host/ohci-da8xx.c +++ b/drivers/usb/host/ohci-da8xx.c @@ -406,19 +406,25 @@ static int ohci_hcd_da8xx_drv_remove(struct platform_device *dev) } #ifdef CONFIG_PM -static int ohci_da8xx_suspend(struct platform_device *dev, pm_message_t message) +static int ohci_da8xx_suspend(struct platform_device *pdev, + pm_message_t message) { - struct usb_hcd *hcd= platform_get_drvdata(dev); + struct usb_hcd *hcd= platform_get_drvdata(pdev); struct ohci_hcd *ohci = hcd_to_ohci(hcd); + int ret; if (time_before(jiffies, ohci->next_statechange)) msleep(5); ohci->next_statechange = jiffies; + ret = ohci_suspend(hcd); + if (ret) + return ret; + ohci_da8xx_clock(0); hcd->state = HC_STATE_SUSPENDED; - dev->dev.power.power_state = PMSG_SUSPEND; - return 0; + + return ret; } static int ohci_da8xx_resume(struct platform_device *dev) -- 1.7.9.5 -- 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 07/11] USB: OHCI: Properly handle ohci-omap suspend
From: Manjunath Goudar Suspend scenario in case of ohci-omap glue was not properly handled as it was not suspending generic part of ohci controller. Alan Stern suggested, properly handle ohci-omap suspend scenario. Calling explicitly the ohci_suspend() routine in ohci_omap_suspend() will ensure proper handling of suspend scenario. Signed-off-by: Manjunath Goudar Signed-off-by: Manjunath Goudar Cc: Alan Stern Cc: Arnd Bergmann Cc: Greg KH Cc: linux-usb@vger.kernel.org --- drivers/usb/host/ohci-omap.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c index 18b27a2..ec2d04c 100644 --- a/drivers/usb/host/ohci-omap.c +++ b/drivers/usb/host/ohci-omap.c @@ -431,16 +431,22 @@ static int ohci_hcd_omap_drv_remove(struct platform_device *dev) #ifdef CONFIG_PM -static int ohci_omap_suspend(struct platform_device *dev, pm_message_t message) +static int ohci_omap_suspend(struct platform_device *pdev, pm_message_t message) { - struct ohci_hcd *ohci = hcd_to_ohci(platform_get_drvdata(dev)); + struct usb_hcd *hcd = platform_get_drvdata(pdev); + struct ohci_hcd *ohci = hcd_to_ohci(hcd); + int ret; if (time_before(jiffies, ohci->next_statechange)) msleep(5); ohci->next_statechange = jiffies; + ret = ohci_suspend(hcd); + if (ret) + return ret; + omap_ohci_clock_power(0); - return 0; + return ret; } static int ohci_omap_resume(struct platform_device *dev) -- 1.7.9.5 -- 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 06/11] USB: OHCI: Properly handle ohci-exynos suspend
From: Manjunath Goudar Suspend scenario in case of ohci-exynos glue was not properly handled as it was not suspending generic part of ohci controller. Alan Stern suggested, properly handle ohci-exynos suspend scenario. Calling explicitly the ohci_suspend() routine in exynos_ohci_suspend() will ensure proper handling of suspend scenario. Signed-off-by: Manjunath Goudar Signed-off-by: Manjunath Goudar Cc: Alan Stern Cc: Bartlomiej Zolnierkiewicz Cc: Arnd Bergmann Cc: Greg KH Cc: linux-usb@vger.kernel.org --- drivers/usb/host/ohci-exynos.c | 19 --- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c index 3e4bc74..47e9c38 100644 --- a/drivers/usb/host/ohci-exynos.c +++ b/drivers/usb/host/ohci-exynos.c @@ -206,21 +206,11 @@ static int exynos_ohci_suspend(struct device *dev) unsigned long flags; int rc = 0; - /* -* Root hub was already suspended. Disable irq emission and -* mark HW unaccessible, bail out if RH has been resumed. Use -* the spinlock to properly synchronize with possible pending -* RH suspend or resume activity. -*/ - spin_lock_irqsave(&ohci->lock, flags); - if (ohci->rh_state != OHCI_RH_SUSPENDED && - ohci->rh_state != OHCI_RH_HALTED) { - rc = -EINVAL; - goto fail; - } - - clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); + rc = ohci_suspend(hcd); + if (rc) + return rc; + spin_lock_irqsave(&ohci->lock, flags); if (exynos_ohci->otg) exynos_ohci->otg->set_host(exynos_ohci->otg, &hcd->self); @@ -228,7 +218,6 @@ static int exynos_ohci_suspend(struct device *dev) clk_disable_unprepare(exynos_ohci->clk); -fail: spin_unlock_irqrestore(&ohci->lock, flags); return rc; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH V2 10/11] USB: OHCI: Properly handle ohci-sm501 suspend
From: Manjunath Goudar Suspend scenario in case of ohci-sm501 glue was not properly handled as it was not suspending generic part of ohci controller. Alan Stern suggested, properly handle ohci-sm501 suspend scenario. Calling explicitly the ohci_suspend() routine in ohci_sm501_suspend() will ensure proper handling of suspend scenario. Signed-off-by: Manjunath Goudar Signed-off-by: Manjunath Goudar Cc: Alan Stern Cc: Arnd Bergmann Cc: Greg KH Cc: linux-usb@vger.kernel.org --- drivers/usb/host/ohci-sm501.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/ohci-sm501.c b/drivers/usb/host/ohci-sm501.c index d479d5d..cdf25ef 100644 --- a/drivers/usb/host/ohci-sm501.c +++ b/drivers/usb/host/ohci-sm501.c @@ -216,14 +216,20 @@ static int ohci_hcd_sm501_drv_remove(struct platform_device *pdev) static int ohci_sm501_suspend(struct platform_device *pdev, pm_message_t msg) { struct device *dev = &pdev->dev; - struct ohci_hcd *ohci = hcd_to_ohci(platform_get_drvdata(pdev)); + struct usb_hcd *hcd = platform_get_drvdata(pdev); + struct ohci_hcd *ohci = hcd_to_ohci(hcd); + int ret; if (time_before(jiffies, ohci->next_statechange)) msleep(5); ohci->next_statechange = jiffies; + ret = ohci_suspend(hcd); + if (ret) + return ret; + sm501_unit_power(dev->parent, SM501_GATE_USB_HOST, 0); - return 0; + return ret; } static int ohci_sm501_resume(struct platform_device *pdev) -- 1.7.9.5 -- 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 09/11] USB: OHCI: Properly handle ohci-pxa27x suspend
From: Manjunath Goudar Suspend scenario in case of ohci-pxa27x glue was not properly handled as it was not suspending generic part of ohci controller. Alan Stern suggested, properly handle ohci-pxa27x suspend scenario. Calling explicitly the ohci_suspend() routine in ohci_hcd_pxa27x_drv_suspend() will ensure proper handling of suspend scenario. Signed-off-by: Manjunath Goudar Signed-off-by: Manjunath Goudar Cc: Alan Stern Cc: Arnd Bergmann Cc: Greg KH Cc: linux-usb@vger.kernel.org --- drivers/usb/host/ohci-pxa27x.c |8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c index c1b1fa3..3b77109 100644 --- a/drivers/usb/host/ohci-pxa27x.c +++ b/drivers/usb/host/ohci-pxa27x.c @@ -509,13 +509,19 @@ static int ohci_hcd_pxa27x_drv_suspend(struct device *dev) struct usb_hcd *hcd = dev_get_drvdata(dev); struct pxa27x_ohci *pxa_ohci = to_pxa27x_ohci(hcd); struct ohci_hcd *ohci = hcd_to_ohci(hcd); + int ret; + if (time_before(jiffies, ohci->next_statechange)) msleep(5); ohci->next_statechange = jiffies; + ret = ohci_suspend(hcd); + if (ret) + return ret; + pxa27x_stop_hc(pxa_ohci, dev); - return 0; + return ret; } static int ohci_hcd_pxa27x_drv_resume(struct device *dev) -- 1.7.9.5 -- 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 08/11] USB: OHCI: Properly handle ohci-platform suspend
From: Manjunath Goudar Suspend scenario in case of ohci-platform glue was not properly handled as it was not suspending generic part of ohci controller.Alan Stern suggested, properly handle ohci-platform suspend scenario. Calling explicitly the ohci_suspend() routine in ohci_platform_suspend() will ensure proper handling of suspend scenario. Signed-off-by: Manjunath Goudar Signed-off-by: Manjunath Goudar Cc: Alan Stern Cc: Arnd Bergmann Cc: Greg KH Cc: linux-usb@vger.kernel.org --- drivers/usb/host/ohci-platform.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c index a4c6410..d67f841 100644 --- a/drivers/usb/host/ohci-platform.c +++ b/drivers/usb/host/ohci-platform.c @@ -139,14 +139,20 @@ static int ohci_platform_remove(struct platform_device *dev) static int ohci_platform_suspend(struct device *dev) { - struct usb_ohci_pdata *pdata = dev_get_platdata(dev); + struct usb_hcd *hcd = dev_get_drvdata(dev); + struct usb_ohci_pdata *pdata = dev->platform_data; struct platform_device *pdev = container_of(dev, struct platform_device, dev); + int ret; + + ret = ohci_suspend(hcd); + if (ret) + return ret; if (pdata->power_suspend) pdata->power_suspend(pdev); - return 0; + return ret; } static int ohci_platform_resume(struct device *dev) -- 1.7.9.5 -- 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 11/11] USB: OHCI: Properly handle ohci-spear suspend
From: Manjunath Goudar Suspend scenario in case of ohci-spear glue was not properly handled as it was not suspending generic part of ohci controller. Alan Stern suggested, properly handle ohci-spear suspend scenario. Calling explicitly the ohci_suspend() routine in spear_ohci_hcd_drv_suspend() will ensure proper handling of suspend scenario. Signed-off-by: Manjunath Goudar Signed-off-by: Manjunath Goudar Cc: Alan Stern Cc: Arnd Bergmann Cc: Greg KH Cc: linux-usb@vger.kernel.org --- drivers/usb/host/ohci-spear.c | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/usb/host/ohci-spear.c b/drivers/usb/host/ohci-spear.c index 31ff3fc..d6787a8 100644 --- a/drivers/usb/host/ohci-spear.c +++ b/drivers/usb/host/ohci-spear.c @@ -130,20 +130,25 @@ static int spear_ohci_hcd_drv_remove(struct platform_device *pdev) } #if defined(CONFIG_PM) -static int spear_ohci_hcd_drv_suspend(struct platform_device *dev, +static int spear_ohci_hcd_drv_suspend(struct platform_device *pdev, pm_message_t message) { - struct usb_hcd *hcd = platform_get_drvdata(dev); + struct usb_hcd *hcd = platform_get_drvdata(pdev); struct ohci_hcd *ohci = hcd_to_ohci(hcd); struct spear_ohci *sohci_p = to_spear_ohci(hcd); + int ret; if (time_before(jiffies, ohci->next_statechange)) msleep(5); ohci->next_statechange = jiffies; + ret = ohci_suspend(hcd); + if (ret) + return ret; + clk_disable_unprepare(sohci_p->clk); - return 0; + return ret; } static int spear_ohci_hcd_drv_resume(struct platform_device *dev) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 05/10] ARM: dts: omap3-beagle: Use reset-gpios for hsusb2_reset
On 03/10/2013 14:05, Benoit Cousson wrote: Hi Roger, Yes, I will. I've been waiting for these ones for so long :-) In fact it does not apply correctly on my for_3.13/dts branch :-( error: arch/arm/boot/dts/omap3-beagle.dts: patch does not apply Patch failed at 0004 ARM: dts: omap3-beagle: Make USB host pin naming consistent Could you rebase it? Thanks, Benoit Thanks, Benoit On 03/10/2013 12:34, Roger Quadros wrote: Hi Benoit, Could you please take the device tree related patches [5 to 10] in this series? Thanks. cheers, -roger On 09/24/2013 11:53 AM, Roger Quadros wrote: We no longer need to model the RESET line as a regulator since the USB phy-nop driver accepts "reset-gpios" property. Signed-off-by: Roger Quadros --- arch/arm/boot/dts/omap3-beagle.dts | 13 + 1 files changed, 1 insertions(+), 12 deletions(-) diff --git a/arch/arm/boot/dts/omap3-beagle.dts b/arch/arm/boot/dts/omap3-beagle.dts index dfd8310..71bde47 100644 --- a/arch/arm/boot/dts/omap3-beagle.dts +++ b/arch/arm/boot/dts/omap3-beagle.dts @@ -44,17 +44,6 @@ }; }; -/* HS USB Port 2 RESET */ -hsusb2_reset: hsusb2_reset_reg { -compatible = "regulator-fixed"; -regulator-name = "hsusb2_reset"; -regulator-min-microvolt = <330>; -regulator-max-microvolt = <330>; -gpio = <&gpio5 19 0>;/* gpio_147 */ -startup-delay-us = <7>; -enable-active-high; -}; - /* HS USB Port 2 Power */ hsusb2_power: hsusb2_power_reg { compatible = "regulator-fixed"; @@ -68,7 +57,7 @@ /* HS USB Host PHY on PORT 2 */ hsusb2_phy: hsusb2_phy { compatible = "usb-nop-xceiv"; -reset-supply = <&hsusb2_reset>; +reset-gpios = <&gpio5 19 GPIO_ACTIVE_LOW>;/* gpio_147 */ vcc-supply = <&hsusb2_power>; }; -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 05/10] ARM: dts: omap3-beagle: Use reset-gpios for hsusb2_reset
Hi Benoit, On 10/03/2013 04:44 PM, Benoit Cousson wrote: > On 03/10/2013 14:05, Benoit Cousson wrote: >> Hi Roger, >> >> Yes, I will. I've been waiting for these ones for so long :-) > > In fact it does not apply correctly on my for_3.13/dts branch :-( > > error: arch/arm/boot/dts/omap3-beagle.dts: patch does not apply > Patch failed at 0004 ARM: dts: omap3-beagle: Make USB host pin naming > consistent > > Could you rebase it? Looks like it was already applied before. Could you please skip that and use the rest? I've checked that the remaining patches apply fine on top of your for_3.13/dts branch. cheers, -roger >> >> On 03/10/2013 12:34, Roger Quadros wrote: >>> Hi Benoit, >>> >>> Could you please take the device tree related patches [5 to 10] in >>> this series? >>> Thanks. >>> >>> cheers, >>> -roger >>> >>> On 09/24/2013 11:53 AM, Roger Quadros wrote: We no longer need to model the RESET line as a regulator since the USB phy-nop driver accepts "reset-gpios" property. Signed-off-by: Roger Quadros --- arch/arm/boot/dts/omap3-beagle.dts | 13 + 1 files changed, 1 insertions(+), 12 deletions(-) diff --git a/arch/arm/boot/dts/omap3-beagle.dts b/arch/arm/boot/dts/omap3-beagle.dts index dfd8310..71bde47 100644 --- a/arch/arm/boot/dts/omap3-beagle.dts +++ b/arch/arm/boot/dts/omap3-beagle.dts @@ -44,17 +44,6 @@ }; }; -/* HS USB Port 2 RESET */ -hsusb2_reset: hsusb2_reset_reg { -compatible = "regulator-fixed"; -regulator-name = "hsusb2_reset"; -regulator-min-microvolt = <330>; -regulator-max-microvolt = <330>; -gpio = <&gpio5 19 0>;/* gpio_147 */ -startup-delay-us = <7>; -enable-active-high; -}; - /* HS USB Port 2 Power */ hsusb2_power: hsusb2_power_reg { compatible = "regulator-fixed"; @@ -68,7 +57,7 @@ /* HS USB Host PHY on PORT 2 */ hsusb2_phy: hsusb2_phy { compatible = "usb-nop-xceiv"; -reset-supply = <&hsusb2_reset>; +reset-gpios = <&gpio5 19 GPIO_ACTIVE_LOW>;/* gpio_147 */ vcc-supply = <&hsusb2_power>; }; >>> >> > -- 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/2] usb: ehci: use amd_chipset_type to filter for usb subsystem hang bug
On Thu, 3 Oct 2013, Huang Rui wrote: > Commit "usb: pci-quirks: refactor AMD quirk to abstract AMD chipset types" > introduced a new AMD chipset type to filter AMD platforms with different > chipsets. > > According to a recent thread [1], this patch updates USB subsystem hang > symptom quirk which is observed on AMD all SB600 and SB700 revision > 0x3a/0x3b. And make it use the new chipset type to represent. > > [1] http://marc.info/?l=linux-usb&m=138012321616452&w=2 > > Signed-off-by: Huang Rui > +int usb_amd_hang_symptom_quirk(void) > +{ > + u8 rev; > + > + usb_amd_find_chipset_info(); > + rev = amd_chipset.sb_type.rev; > + /* SB600 and old version of SB700 have hang symptom bug */ > + return (amd_chipset.sb_type.gen == AMD_CHIPSET_SB600 || > + (amd_chipset.sb_type.gen == AMD_CHIPSET_SB700 && > + rev >= 0x3a && rev <= 0x3b)) ? 1 : 0; You don't need the "? 1 : 0" part. When you remove it, change the function's return type to bool. The same comment applies to the other patch in this series. For both patches, when you make this change you can add: Acked-by: 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 v4] USB: gadget: epautoconf: fix ep maxpacket check
On Thu, 3 Oct 2013, Robert Baldyga wrote: > > This disagrees with the kerneldoc for usb_ep_autoconfig(). For bulk > > endpoints, wMaxPacket is always supposed to be set to the full-speed > > value, regardless of what the protocol driver specifies. > > Hmm, it looks like all gadgets calls usb_ep_autoconfig() for full speed > descriptors and after it they uses usb_assign_descriptors() function to > set descriptors proper for device speed. Also, the gadgets have the wMaxPacketSize value hard-coded for the HS and SS descriptors. > And it works until gadget sets > full speed descriptors. But what if gadget supports only high speed and > don't want to set full speed descriptors? If it will use > usb_ep_autoconfig() function for high speed descriptor, value of > wMaxPacketSize field will change to 64. Is there any good solution for > this problem or all gadgets have to support full speed? The gadget driver can change wMaxPacketSize back to the correct value after calling usb_ep_autoconfig(). Or you can change the definition of usb_ep_autoconfig(), and have the driver pass the speed value as an additional argument. 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 1/2] usb: ehci: use amd_chipset_type to filter for usb subsystem hang bug
On Thu, Oct 03, 2013 at 10:11:36AM -0400, Alan Stern wrote: > On Thu, 3 Oct 2013, Huang Rui wrote: > > > +int usb_amd_hang_symptom_quirk(void) > > +{ > > + u8 rev; > > + > > + usb_amd_find_chipset_info(); > > + rev = amd_chipset.sb_type.rev; > > + /* SB600 and old version of SB700 have hang symptom bug */ > > + return (amd_chipset.sb_type.gen == AMD_CHIPSET_SB600 || > > + (amd_chipset.sb_type.gen == AMD_CHIPSET_SB700 && > > +rev >= 0x3a && rev <= 0x3b)) ? 1 : 0; > > You don't need the "? 1 : 0" part. When you remove it, change the > function's return type to bool. The same comment applies to the other > patch in this series. > Thank you, will update. Thanks, Rui -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 05/10] ARM: dts: omap3-beagle: Use reset-gpios for hsusb2_reset
On 03/10/2013 15:58, Roger Quadros wrote: Hi Benoit, On 10/03/2013 04:44 PM, Benoit Cousson wrote: On 03/10/2013 14:05, Benoit Cousson wrote: Hi Roger, Yes, I will. I've been waiting for these ones for so long :-) In fact it does not apply correctly on my for_3.13/dts branch :-( error: arch/arm/boot/dts/omap3-beagle.dts: patch does not apply Patch failed at 0004 ARM: dts: omap3-beagle: Make USB host pin naming consistent Could you rebase it? Looks like it was already applied before. Could you please skip that and use the rest? I've checked that the remaining patches apply fine on top of your for_3.13/dts branch. Indeed, it was already there :-) Sorry for the noise. Benoit cheers, -roger On 03/10/2013 12:34, Roger Quadros wrote: Hi Benoit, Could you please take the device tree related patches [5 to 10] in this series? Thanks. cheers, -roger On 09/24/2013 11:53 AM, Roger Quadros wrote: We no longer need to model the RESET line as a regulator since the USB phy-nop driver accepts "reset-gpios" property. Signed-off-by: Roger Quadros --- arch/arm/boot/dts/omap3-beagle.dts | 13 + 1 files changed, 1 insertions(+), 12 deletions(-) diff --git a/arch/arm/boot/dts/omap3-beagle.dts b/arch/arm/boot/dts/omap3-beagle.dts index dfd8310..71bde47 100644 --- a/arch/arm/boot/dts/omap3-beagle.dts +++ b/arch/arm/boot/dts/omap3-beagle.dts @@ -44,17 +44,6 @@ }; }; -/* HS USB Port 2 RESET */ -hsusb2_reset: hsusb2_reset_reg { -compatible = "regulator-fixed"; -regulator-name = "hsusb2_reset"; -regulator-min-microvolt = <330>; -regulator-max-microvolt = <330>; -gpio = <&gpio5 19 0>;/* gpio_147 */ -startup-delay-us = <7>; -enable-active-high; -}; - /* HS USB Port 2 Power */ hsusb2_power: hsusb2_power_reg { compatible = "regulator-fixed"; @@ -68,7 +57,7 @@ /* HS USB Host PHY on PORT 2 */ hsusb2_phy: hsusb2_phy { compatible = "usb-nop-xceiv"; -reset-supply = <&hsusb2_reset>; +reset-gpios = <&gpio5 19 GPIO_ACTIVE_LOW>;/* gpio_147 */ vcc-supply = <&hsusb2_power>; }; -- 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 06/11] USB: OHCI: Properly handle ohci-exynos suspend
On Thu, 3 Oct 2013, manju goudar wrote: > On Wed, Oct 2, 2013 at 9:22 PM, Alan Stern wrote: > > > On Wed, 2 Oct 2013, Bartlomiej Zolnierkiewicz wrote: > > > > > > > > Hi, > > > > > > On Wednesday, October 02, 2013 10:38:58 AM Alan Stern wrote: > > > > On Wed, 2 Oct 2013, Bartlomiej Zolnierkiewicz wrote: > > > > > > > > > Maybe it would make sense to cleanup ohci_suspend() first (before > > adding > > > > > new ohci_suspend() users) and remove unused do_wakeup parameter? > > > > > > > > Not possible. The do_wakeup parameter is part of a function prototype > > > > shared by other callback routines (such as ehci_suspend()) that _do_ > > > > use the parameter. > > > > > > If you mean ohci-pci.c usage (which is currently the only usage of > > > ohci_suspend() looking at the latest -next kernel) than it is enough > > > to add a simple wrapper for it in ohci-pci.c: > > > > > > ... > > > static int ohci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup) > > > { > > > ohci_suspend(hcd); > > > } > > > ... > > > ohci_pci_hc_driver.pci_suspend = ohci_pci_suspend; > > > ... > > > > Ah, now I see your point. Yes, it's true; that parameter could be > > eliminated. > > > > Manjunath, would you like to update your patch series to get rid of the > > do_wakeup argument to ohci_suspend()? > > > > Yes I will do. I think we can also rid of ehci_suspend() do_wakeup > argument. Arrgh! Manjunath, I was wrong. I'm sorry to make you do all this extra work -- your original patch series was correct. Bartlomiej, we both failed to notice that the 1/11 patch in the original series adds a usage of do_wakeup. Therefore that argument cannot be removed. Greg, please ignore Manjunath's V2 series (sent today) and merge the original 11-patch series posted on October 2. 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 06/11] USB: OHCI: Properly handle ohci-exynos suspend
On Thursday, October 03, 2013 10:31:53 AM Alan Stern wrote: > On Thu, 3 Oct 2013, manju goudar wrote: > > > On Wed, Oct 2, 2013 at 9:22 PM, Alan Stern wrote: > > > > > On Wed, 2 Oct 2013, Bartlomiej Zolnierkiewicz wrote: > > > > > > > > > > > Hi, > > > > > > > > On Wednesday, October 02, 2013 10:38:58 AM Alan Stern wrote: > > > > > On Wed, 2 Oct 2013, Bartlomiej Zolnierkiewicz wrote: > > > > > > > > > > > Maybe it would make sense to cleanup ohci_suspend() first (before > > > adding > > > > > > new ohci_suspend() users) and remove unused do_wakeup parameter? > > > > > > > > > > Not possible. The do_wakeup parameter is part of a function prototype > > > > > shared by other callback routines (such as ehci_suspend()) that _do_ > > > > > use the parameter. > > > > > > > > If you mean ohci-pci.c usage (which is currently the only usage of > > > > ohci_suspend() looking at the latest -next kernel) than it is enough > > > > to add a simple wrapper for it in ohci-pci.c: > > > > > > > > ... > > > > static int ohci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup) > > > > { > > > > ohci_suspend(hcd); > > > > } > > > > ... > > > > ohci_pci_hc_driver.pci_suspend = ohci_pci_suspend; > > > > ... > > > > > > Ah, now I see your point. Yes, it's true; that parameter could be > > > eliminated. > > > > > > Manjunath, would you like to update your patch series to get rid of the > > > do_wakeup argument to ohci_suspend()? > > > > > > Yes I will do. I think we can also rid of ehci_suspend() do_wakeup > > argument. > > Arrgh! Manjunath, I was wrong. I'm sorry to make you do all this > extra work -- your original patch series was correct. > > Bartlomiej, we both failed to notice that the 1/11 patch in the > original series adds a usage of do_wakeup. Therefore that argument > cannot be removed. Uhh, indeed. Sorry about that. > Greg, please ignore Manjunath's V2 series (sent today) and merge the > original 11-patch series posted on October 2. Yep. Best regards, -- Bartlomiej Zolnierkiewicz Samsung R&D Institute Poland Samsung Electronics -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v7 09/10] usb: dwc3: omap: manage "usb_otg_ss_refclk960m" clock
On 10/03/2013 03:29 PM, Felipe Balbi wrote: > Hi, > > On Wed, Oct 02, 2013 at 04:41:53PM +0300, Roger Quadros wrote: >> On 10/02/2013 04:11 PM, Felipe Balbi wrote: >>> On Mon, Sep 23, 2013 at 04:11:30PM +0300, Roger Quadros wrote: Hi Felipe, On 09/18/2013 03:49 PM, Roger Quadros wrote: > "usb_otg_ss_refclk960m" is an optional functional clock to the > UBS_OTG_SS module. So manage it in the driver. > Just realized that "usb_otg_ss_refclk960m" is in fact functional clock to the PHY and not USB_OTG_SS module. The name is misleading. So please ignore patch 9 and 10. >>> >>> ignored. All others are fine, right ? >>> >> Yes. But I might have to rebase this on top of Phy framework stuff. > > alright, Greg already took the PHY framework, so maybe we need to just > give him my Acked-by and he takes the patches directly as I don't have > PYH framework. > OK. I'll resend this series to Greg in a while. cheers, -roger -- 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] Regression fix revert: "Bluetooth: Add missing reset_resume dev_pm_ops"
On 10/02/2013 09:39 PM, Marcel Holtmann wrote: Hi Gustavo, Many btusb devices have 2 modes, a hid mode and a bluetooth hci mode. These devices default to hid mode for BIOS use. This means that after having been reset they will revert to HID mode, and are no longer usable as a HCI. Therefor it is a very bad idea to just blindly make reset_resume point to the regular resume handler. Note that the btusb driver has no clue how to switch these devices from hid to hci mode, this is done in userspace through udev rules, so the proper way to deal with this is to not have a reset-resume handler and instead let the usb-system re-enumerate the device, and re-run the udev rules. I must also note, that the commit message for the commit causing this problem has a very weak motivation for the change: "Add missing reset_resume dev_pm_ops. Missing reset_resume results in the following message after power management device test. This change sets reset_resume to btusb_resume(). [ 2506.936134] btusb 1-1.5:1.0: no reset_resume for driver btusb? [ 2506.936137] btusb 1-1.5:1.1: no reset_resume for driver btusb?" Making a change solely to silence a warning while also changing important behavior (normal resume handling versus re-enumeration) requires a commit message with a proper explanation why it is safe to do so, which clearly lacks here, and unsurprisingly it turns out to not be safe to make this change. Reverting the commit in question fixes bt no longer working on my Dell E6430 after a suspend/resume, and I believe it likely also fixes the following bugs: https://bugzilla.redhat.com/show_bug.cgi?id=988481 https://bugzilla.redhat.com/show_bug.cgi?id=1010649 https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1213239 This reverts commit 502f769662978a2fe99d0caed5e53e3006107381. Cc: Shuah Khan Cc: Gustavo Padovan Cc: sta...@vger.kernel.org Signed-off-by: Hans de Goede --- drivers/bluetooth/btusb.c | 1 - 1 file changed, 1 deletion(-) Patch has been applied to bluetooth.git. Thanks. why? Because we have one broken Dell Bluetooth dongle. Do we actually know how this affects other chips. The dell HID Proxy thing has always been special case and that is Dell's fault. Look at the extra code that we have in hid2hci tool and its udev rules for Dell hardware. Is anybody actually willing to investigate this one properly. Regards Marcel Sorry for the late reply on this. Sorry for the regression on Dell. I didn't see any problems when I tested it on the bluetooth mouse I have. However, I understand what Hans is saying. My change did cause a regression. I will investigate this further. The warning message itself is very misleading in the sense that it gives the impression that the resume routine that should have been installed is missing. Which is what caused me to fix things in the first place. thanks, -- Shuah -- Shuah Khan Senior Linux Kernel Developer - Open Source Group Samsung Research America(Silicon Valley) shuah...@samsung.com | (970) 672-0658 -- 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 v8 2/8] usb: phy: omap: Add new device types and remove omap_control_usb3_phy_power()
Add support for new device types and in the process rid of "ti,type" device tree property. The correct type of device will be determined from the compatible string instead. Introduce a compatible string for each device type. At the moment we support 4 types OTGHS, USB2, PIPE3 (e.g. USB3) and DRA7USB2. Update DT binding information to reflect these changes. Also get rid of omap_control_usb3_phy_power(). Just one function i.e. omap_control_usb_phy_power() will now take care of all PHY types. Signed-off-by: Roger Quadros --- Documentation/devicetree/bindings/usb/omap-usb.txt | 30 ++-- drivers/usb/phy/phy-omap-control.c | 173 +++ drivers/usb/phy/phy-omap-usb3.c|6 +- include/linux/usb/omap_control_usb.h | 24 ++-- 4 files changed, 130 insertions(+), 103 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/omap-usb.txt b/Documentation/devicetree/bindings/usb/omap-usb.txt index 661cb06..9add35c 100644 --- a/Documentation/devicetree/bindings/usb/omap-usb.txt +++ b/Documentation/devicetree/bindings/usb/omap-usb.txt @@ -83,22 +83,22 @@ omap_dwc3 { OMAP CONTROL USB Required properties: - - compatible: Should be "ti,omap-control-usb" + - compatible: Should be one of + "ti,control-phy-otghs" - if it has otghs_control mailbox register as on OMAP4. + "ti,control-phy-usb2" - if it has Power down bit in control_dev_conf register + e.g. USB2_PHY on OMAP5. + "ti,control-phy-pipe3" - if it has DPLL and individual Rx & Tx power control + e.g. USB3 PHY and SATA PHY on OMAP5. + "ti,control-phy-dra7usb2" - if it has power down register like USB2 PHY on + DRA7 platform. - reg : Address and length of the register set for the device. It contains - the address of "control_dev_conf" and "otghs_control" or "phy_power_usb" - depending upon omap4 or omap5. - - reg-names: The names of the register addresses corresponding to the registers - filled in "reg". - - ti,type: This is used to differentiate whether the control module has - usb mailbox or usb3 phy power. omap4 has usb mailbox in control module to - notify events to the musb core and omap5 has usb3 phy power register to - power on usb3 phy. Should be "1" if it has mailbox and "2" if it has usb3 - phy power. + the address of "otghs_control" for control-phy-otghs or "power" register + for other types. + - reg-names: should be "otghs_control" control-phy-otghs and "power" for + other types. omap_control_usb: omap-control-usb@4a002300 { - compatible = "ti,omap-control-usb"; - reg = <0x4a002300 0x4>, - <0x4a00233c 0x4>; - reg-names = "control_dev_conf", "otghs_control"; - ti,type = <1>; + compatible = "ti,control-phy-otghs"; + reg = <0x4a00233c 0x4>; + reg-names = "otghs_control"; }; diff --git a/drivers/usb/phy/phy-omap-control.c b/drivers/usb/phy/phy-omap-control.c index 9772592..1c8a7c5 100644 --- a/drivers/usb/phy/phy-omap-control.c +++ b/drivers/usb/phy/phy-omap-control.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -46,61 +47,70 @@ struct device *omap_get_control_dev(void) EXPORT_SYMBOL_GPL(omap_get_control_dev); /** - * omap_control_usb3_phy_power - power on/off the serializer using control - * module + * omap_control_usb_phy_power - power on/off the phy using control module reg * @dev: the control module device - * @on: 0 to off and 1 to on based on powering on or off the PHY - * - * usb3 PHY driver should call this API to power on or off the PHY. + * @on: 0 or 1, based on powering on or off the PHY */ -void omap_control_usb3_phy_power(struct device *dev, bool on) +void omap_control_usb_phy_power(struct device *dev, int on) { u32 val; unsigned long rate; - struct omap_control_usb *control_usb = dev_get_drvdata(dev); + struct omap_control_usb *control_usb; - if (control_usb->type != OMAP_CTRL_DEV_TYPE2) + if (IS_ERR(dev) || !dev) { + pr_err("%s: invalid device\n", __func__); return; + } - rate = clk_get_rate(control_usb->sys_clk); - rate = rate/100; - - val = readl(control_usb->phy_power); - - if (on) { - val &= ~(OMAP_CTRL_USB_PWRCTL_CLK_CMD_MASK | - OMAP_CTRL_USB_PWRCTL_CLK_FREQ_MASK); - val |= OMAP_CTRL_USB3_PHY_TX_RX_POWERON << - OMAP_CTRL_USB_PWRCTL_CLK_CMD_SHIFT; - val |= rate << OMAP_CTRL_USB_PWRCTL_CLK_FREQ_SHIFT; - } else { - val &= ~OMAP_CTRL_USB_PWRCTL_CLK_CMD_MASK; - val |= OMAP_CTRL_USB3_PHY_TX_RX_POWEROFF << - OMAP_CTRL_USB_PWRCTL_CLK_CMD_SHIFT; + control_usb = dev_get_drvdata(dev); + if (!control_usb) { + dev_err(dev, "%s: invalid control usb device\n", __func__); + return
[PATCH v8 6/8] usb: phy: omap: get rid of omap_get_control_dev()
This function was preventing us from supporting multiple instances. Get rid of it. Since we support DT boots only, users can get the control device phandle from the DT node. Signed-off-by: Roger Quadros --- drivers/usb/phy/phy-omap-control.c | 31 ++- include/linux/usb/omap_control_usb.h |5 - 2 files changed, 10 insertions(+), 26 deletions(-) diff --git a/drivers/usb/phy/phy-omap-control.c b/drivers/usb/phy/phy-omap-control.c index 1c8a7c5..09c5ace 100644 --- a/drivers/usb/phy/phy-omap-control.c +++ b/drivers/usb/phy/phy-omap-control.c @@ -26,26 +26,6 @@ #include #include -static struct omap_control_usb *control_usb; - -/** - * omap_get_control_dev - returns the device pointer for this control device - * - * This API should be called to get the device pointer for this control - * module device. This device pointer should be used for called other - * exported API's in this driver. - * - * To be used by PHY driver and glue driver. - */ -struct device *omap_get_control_dev(void) -{ - if (!control_usb) - return ERR_PTR(-ENODEV); - - return control_usb->dev; -} -EXPORT_SYMBOL_GPL(omap_get_control_dev); - /** * omap_control_usb_phy_power - power on/off the phy using control module reg * @dev: the control module device @@ -182,11 +162,19 @@ void omap_control_usb_set_mode(struct device *dev, { struct omap_control_usb *ctrl_usb; - if (IS_ERR(dev) || control_usb->type != OMAP_CTRL_TYPE_OTGHS) + if (IS_ERR(dev) || !dev) return; ctrl_usb = dev_get_drvdata(dev); + if (!ctrl_usb) { + dev_err(dev, "Invalid control usb device\n"); + return; + } + + if (ctrl_usb->type != OMAP_CTRL_TYPE_OTGHS) + return; + switch (mode) { case USB_MODE_HOST: omap_control_usb_host_mode(ctrl_usb); @@ -237,6 +225,7 @@ static int omap_control_usb_probe(struct platform_device *pdev) { struct resource *res; const struct of_device_id *of_id; + struct omap_control_usb *control_usb; of_id = of_match_device(of_match_ptr(omap_control_usb_id_table), &pdev->dev); diff --git a/include/linux/usb/omap_control_usb.h b/include/linux/usb/omap_control_usb.h index 61b889a..596b019 100644 --- a/include/linux/usb/omap_control_usb.h +++ b/include/linux/usb/omap_control_usb.h @@ -65,15 +65,10 @@ enum omap_control_usb_mode { #define OMAP_CTRL_USB2_PHY_PD BIT(28) #if IS_ENABLED(CONFIG_OMAP_CONTROL_USB) -extern struct device *omap_get_control_dev(void); extern void omap_control_usb_phy_power(struct device *dev, int on); extern void omap_control_usb_set_mode(struct device *dev, enum omap_control_usb_mode mode); #else -static inline struct device *omap_get_control_dev(void) -{ - return ERR_PTR(-ENODEV); -} static inline void omap_control_usb_phy_power(struct device *dev, int on) { -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v8 5/8] usb: musb: omap2430: Don't use omap_get_control_dev()
omap_get_control_dev() is being deprecated as it doesn't support multiple instances. As control device is present only from OMAP4 onwards which supports DT only, we use phandles to get the reference to the control device. Also get rid of "ti,has-mailbox" property as it is redundant and we can determine that from whether "ctrl-module" property is present or not. Get rid of has_mailbox from musb_hdrc_platform_data as well. Signed-off-by: Roger Quadros --- Documentation/devicetree/bindings/usb/omap-usb.txt |4 --- drivers/usb/musb/omap2430.c| 25 +++ include/linux/usb/musb.h |2 - 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/omap-usb.txt b/Documentation/devicetree/bindings/usb/omap-usb.txt index 9add35c..090e5e2 100644 --- a/Documentation/devicetree/bindings/usb/omap-usb.txt +++ b/Documentation/devicetree/bindings/usb/omap-usb.txt @@ -3,9 +3,6 @@ OMAP GLUE AND OTHER OMAP SPECIFIC COMPONENTS OMAP MUSB GLUE - compatible : Should be "ti,omap4-musb" or "ti,omap3-musb" - ti,hwmods : must be "usb_otg_hs" - - ti,has-mailbox : to specify that omap uses an external mailbox - (in control module) to communicate with the musb core during device connect - and disconnect. - multipoint : Should be "1" indicating the musb controller supports multipoint. This is a MUSB configuration-specific setting. - num-eps : Specifies the number of endpoints. This is also a @@ -31,7 +28,6 @@ SOC specific device node entry usb_otg_hs: usb_otg_hs@4a0ab000 { compatible = "ti,omap4-musb"; ti,hwmods = "usb_otg_hs"; - ti,has-mailbox; multipoint = <1>; num-eps = <16>; ram-bits = <12>; diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index d0fc4d9..9eab645 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c @@ -38,6 +38,7 @@ #include #include #include +#include #include "musb_core.h" #include "omap2430.h" @@ -524,8 +525,12 @@ static int omap2430_probe(struct platform_device *pdev) glue->dev = &pdev->dev; glue->musb = musb; glue->status= OMAP_MUSB_UNKNOWN; + glue->control_otghs = ERR_PTR(-ENODEV); if (np) { + struct device_node *control_node; + struct platform_device *control_pdev; + pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) { dev_err(&pdev->dev, @@ -554,22 +559,20 @@ static int omap2430_probe(struct platform_device *pdev) of_property_read_u32(np, "ram-bits", (u32 *)&config->ram_bits); of_property_read_u32(np, "power", (u32 *)&pdata->power); config->multipoint = of_property_read_bool(np, "multipoint"); - pdata->has_mailbox = of_property_read_bool(np, - "ti,has-mailbox"); pdata->board_data = data; pdata->config = config; - } - if (pdata->has_mailbox) { - glue->control_otghs = omap_get_control_dev(); - if (IS_ERR(glue->control_otghs)) { - dev_vdbg(&pdev->dev, "Failed to get control device\n"); - ret = PTR_ERR(glue->control_otghs); - goto err2; + control_node = of_parse_phandle(np, "ctrl-module", 0); + if (control_node) { + control_pdev = of_find_device_by_node(control_node); + if (!control_pdev) { + dev_err(&pdev->dev, "Failed to get control device\n"); + ret = -EINVAL; + goto err2; + } + glue->control_otghs = &control_pdev->dev; } - } else { - glue->control_otghs = ERR_PTR(-ENODEV); } pdata->platform_ops = &omap2430_ops; diff --git a/include/linux/usb/musb.h b/include/linux/usb/musb.h index 053c268..eb50525 100644 --- a/include/linux/usb/musb.h +++ b/include/linux/usb/musb.h @@ -99,8 +99,6 @@ struct musb_hdrc_platform_data { /* MUSB_HOST, MUSB_PERIPHERAL, or MUSB_OTG */ u8 mode; - u8 has_mailbox:1; - /* for clk_get() */ const char *clock; -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v8 7/8] ARM: dts: omap4: update omap-control-usb nodes
Split otghs_ctrl and USB2 PHY power-down into separate omap-control-usb nodes. Get rid of "ti,type" property. Also get rid of "ti,has-mailbox" property from usb_otg_hs node and provide the ctrl-module phandle. CC: Benoit Cousson Signed-off-by: Roger Quadros --- arch/arm/boot/dts/omap4.dtsi | 20 1 files changed, 12 insertions(+), 8 deletions(-) diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi index 1e8e2fe..ea4054b 100644 --- a/arch/arm/boot/dts/omap4.dtsi +++ b/arch/arm/boot/dts/omap4.dtsi @@ -519,7 +519,7 @@ usb2_phy: usb2phy@4a0ad080 { compatible = "ti,omap-usb2"; reg = <0x4a0ad080 0x58>; - ctrl-module = <&omap_control_usb>; + ctrl-module = <&omap_control_usb2phy>; #phy-cells = <0>; }; }; @@ -644,12 +644,16 @@ }; }; - omap_control_usb: omap-control-usb@4a002300 { - compatible = "ti,omap-control-usb"; - reg = <0x4a002300 0x4>, - <0x4a00233c 0x4>; - reg-names = "control_dev_conf", "otghs_control"; - ti,type = <1>; + omap_control_usb2phy: control-phy@4a002300 { + compatible = "ti,control-phy-usb2"; + reg = <0x4a002300 0x4>; + reg-names = "power"; + }; + + omap_control_usbotg: control-phy@4a00233c { + compatible = "ti,control-phy-otghs"; + reg = <0x4a00233c 0x4>; + reg-names = "otghs_control"; }; usb_otg_hs: usb_otg_hs@4a0ab000 { @@ -664,7 +668,7 @@ multipoint = <1>; num-eps = <16>; ram-bits = <12>; - ti,has-mailbox; + ctrl-module = <&omap_control_usbotg>; }; }; }; -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v8 8/8] ARM: dts: omap5: update omap-control-usb node
Split USB2 PHY and USB3 PHY into separate omap-control-usb nodes. Get rid of "ti,type" property. CC: Benoit Cousson Signed-off-by: Roger Quadros --- arch/arm/boot/dts/omap5.dtsi | 20 1 files changed, 12 insertions(+), 8 deletions(-) diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi index 7cdea1b..c0ec6dc 100644 --- a/arch/arm/boot/dts/omap5.dtsi +++ b/arch/arm/boot/dts/omap5.dtsi @@ -626,12 +626,16 @@ hw-caps-temp-alert; }; - omap_control_usb: omap-control-usb@4a002300 { - compatible = "ti,omap-control-usb"; - reg = <0x4a002300 0x4>, - <0x4a002370 0x4>; - reg-names = "control_dev_conf", "phy_power_usb"; - ti,type = <2>; + omap_control_usb2phy: control-phy@4a002300 { + compatible = "ti,control-phy-usb2"; + reg = <0x4a002300 0x4>; + reg-names = "power"; + }; + + omap_control_usb3phy: control-phy@4a002370 { + compatible = "ti,control-phy-pipe3"; + reg = <0x4a002370 0x4>; + reg-names = "power"; }; omap_dwc3@4a02 { @@ -662,7 +666,7 @@ usb2_phy: usb2phy@4a084000 { compatible = "ti,omap-usb2"; reg = <0x4a084000 0x7c>; - ctrl-module = <&omap_control_usb>; + ctrl-module = <&omap_control_usb2phy>; }; usb3_phy: usb3phy@4a084400 { @@ -671,7 +675,7 @@ <0x4a084800 0x64>, <0x4a084c00 0x40>; reg-names = "phy_rx", "phy_tx", "pll_ctrl"; - ctrl-module = <&omap_control_usb>; + ctrl-module = <&omap_control_usb3phy>; }; }; -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v8 0/8][RESEND] phy: omap-usb: Support multiple instances and new types
Hi Greg, I was initially pushing this series through Felipe, but now that PHY framework is in your usb-next tree, Felipe has asked me to send it to you. We need this for 3.13. There are more patches related to USB support for TI's DRA7 SoC and SATA support for OMAP5 that depend on this series. This patchset does the following: * Get rid of omap_control_usb platform data as we support DT only. * Restructure and add support for new PHY types. We now support the following four types TYPE_OTGHS - if it has otghs_control mailbox register (e.g. on OMAP4) TYPE_USB2 - if it has Power down bit in control_dev_conf register. e.g. USB2 PHY TYPE_PIPE3 - if it has DPLL and individual Rx & Tx power control. e.g. USB3 PHY or SATA PHY TYPE_DRA7USB2 - if it has both power down and power aux registers. e.g. USB2 PHY on DRA7 * Get rid of "ti,type" DT property and introduce compatible strings for each type. * Have only one power control API "omap_control_usb_phy_power()" instead of a different one for each PHY type. * Get rid of omap_get_control_dev() so that we can support multiple instances of the control device. We take advantage of the fact that omap control USB device is only present on OMAP4 onwards and hence only supports DT boot. The users of control USB device can get a reference to it from the device node's phandle. Patches are based on greg/usb-next. *NOTE: Patches 7 and 8 need to go through Benoit Cousson's OMAP DTS tree. You can also find the patches in branch usb-control-module in git tree git://github.com/rogerq/linux.git v8: - Rebased on top of greg/usb-next to avoid conflicts - Removed patches 9 and 10 as they are not applicable v7: - Rebased on v3.12-rc1 - Updated DT compatibility ID for better readability - Renamed TYPE_OMAP4 to TYPE_OTGHS, TYPE_USB3 to TYPE_PIPE3 and TYPE_DRA7 to TYPE_DRA7USB2 v6: - addressed review comment about usage of control_usb before allocation. v5: - fixed whitespace alignment issues. v4: - removed "ti,has-mailbox" from omap-usb binding document example. v3: - return -EINVAL instead of -ENODEV on probe failure. - pass device type data through of_device_id table. - get rid of "ti,mailbox" property and "has_mailbox" from musb platform data. v2: - get rid of "ti,type" property and introduce compatible strings for each device type. cheers, -roger Roger Quadros (8): usb: phy: omap-control: Get rid of platform data usb: phy: omap: Add new device types and remove omap_control_usb3_phy_power() usb: phy: omap-usb2: Don't use omap_get_control_dev() usb: phy: omap-usb3: Don't use omap_get_control_dev() usb: musb: omap2430: Don't use omap_get_control_dev() ARM: dts: omap4: update omap-control-usb nodes usb: phy: omap: get rid of omap_get_control_dev() ARM: dts: omap5: update omap-control-usb node Documentation/devicetree/bindings/usb/omap-usb.txt | 34 ++-- arch/arm/boot/dts/omap4.dtsi | 20 ++- arch/arm/boot/dts/omap5.dtsi | 20 ++- drivers/phy/phy-omap-usb2.c| 31 +++- drivers/usb/musb/omap2430.c| 25 ++- drivers/usb/phy/phy-omap-control.c | 208 ++- drivers/usb/phy/phy-omap-usb3.c| 32 +++- include/linux/usb/musb.h |2 - include/linux/usb/omap_control_usb.h | 33 ++-- 9 files changed, 220 insertions(+), 185 deletions(-) -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v8 3/8] usb: phy: omap-usb2: Don't use omap_get_control_dev()
omap_get_control_dev() is being deprecated as it doesn't support multiple instances. As control device is present only from OMAP4 onwards which supports DT only, we use phandles to get the reference to the control device. As we don't support non-DT boot, we just bail out on probe if device node is not present. Signed-off-by: Roger Quadros --- drivers/phy/phy-omap-usb2.c | 31 +++ 1 files changed, 23 insertions(+), 8 deletions(-) diff --git a/drivers/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c index 4d7b4e5..bfc5c33 100644 --- a/drivers/phy/phy-omap-usb2.c +++ b/drivers/phy/phy-omap-usb2.c @@ -29,6 +29,7 @@ #include #include #include +#include /** * omap_usb2_set_comparator - links the comparator present in the sytem with @@ -145,10 +146,16 @@ static struct phy_ops ops = { static int omap_usb2_probe(struct platform_device *pdev) { - struct omap_usb *phy; - struct phy *generic_phy; - struct usb_otg *otg; - struct phy_provider *phy_provider; + struct omap_usb *phy; + struct phy *generic_phy; + struct phy_provider *phy_provider; + struct usb_otg *otg; + struct device_node *node = pdev->dev.of_node; + struct device_node *control_node; + struct platform_device *control_pdev; + + if (!node) + return -EINVAL; phy = devm_kzalloc(&pdev->dev, sizeof(*phy), GFP_KERNEL); if (!phy) { @@ -175,12 +182,20 @@ static int omap_usb2_probe(struct platform_device *pdev) if (IS_ERR(phy_provider)) return PTR_ERR(phy_provider); - phy->control_dev = omap_get_control_dev(); - if (IS_ERR(phy->control_dev)) { - dev_dbg(&pdev->dev, "Failed to get control device\n"); - return -ENODEV; + control_node = of_parse_phandle(node, "ctrl-module", 0); + if (!control_node) { + dev_err(&pdev->dev, "Failed to get control device phandle\n"); + return -EINVAL; } + control_pdev = of_find_device_by_node(control_node); + if (!control_pdev) { + dev_err(&pdev->dev, "Failed to get control device\n"); + return -EINVAL; + } + + phy->control_dev = &control_pdev->dev; + phy->is_suspended = 1; omap_control_usb_phy_power(phy->control_dev, 0); -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v8 1/8] usb: phy: omap-control: Get rid of platform data
omap-control device is present from OMAP4 onwards which support device tree boots only. So get rid of platform data. Signed-off-by: Roger Quadros --- drivers/usb/phy/phy-omap-control.c | 12 +++- include/linux/usb/omap_control_usb.h |4 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/drivers/usb/phy/phy-omap-control.c b/drivers/usb/phy/phy-omap-control.c index a4dda8e..9772592 100644 --- a/drivers/usb/phy/phy-omap-control.c +++ b/drivers/usb/phy/phy-omap-control.c @@ -197,8 +197,6 @@ static int omap_control_usb_probe(struct platform_device *pdev) { struct resource *res; struct device_node *np = pdev->dev.of_node; - struct omap_control_usb_platform_data *pdata = - dev_get_platdata(&pdev->dev); control_usb = devm_kzalloc(&pdev->dev, sizeof(*control_usb), GFP_KERNEL); @@ -207,14 +205,10 @@ static int omap_control_usb_probe(struct platform_device *pdev) return -ENOMEM; } - if (np) { + if (np) of_property_read_u32(np, "ti,type", &control_usb->type); - } else if (pdata) { - control_usb->type = pdata->type; - } else { - dev_err(&pdev->dev, "no pdata present\n"); - return -EINVAL; - } + else + return -EINVAL; /* We only support DT boot */ control_usb->dev= &pdev->dev; diff --git a/include/linux/usb/omap_control_usb.h b/include/linux/usb/omap_control_usb.h index 27b5b8c..e2416b4 100644 --- a/include/linux/usb/omap_control_usb.h +++ b/include/linux/usb/omap_control_usb.h @@ -31,10 +31,6 @@ struct omap_control_usb { u32 type; }; -struct omap_control_usb_platform_data { - u8 type; -}; - enum omap_control_usb_mode { USB_MODE_UNDEFINED = 0, USB_MODE_HOST, -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v8 4/8] usb: phy: omap-usb3: Don't use omap_get_control_dev()
omap_get_control_dev() is being deprecated as it doesn't support multiple instances. As control device is present only from OMAP4 onwards which supports DT only, we use phandles to get the reference to the control device. As we don't support non-DT boot, we just bail out on probe if device node is not present. Signed-off-by: Roger Quadros --- drivers/usb/phy/phy-omap-usb3.c | 26 -- 1 files changed, 20 insertions(+), 6 deletions(-) diff --git a/drivers/usb/phy/phy-omap-usb3.c b/drivers/usb/phy/phy-omap-usb3.c index 0824be4..0c6ba29 100644 --- a/drivers/usb/phy/phy-omap-usb3.c +++ b/drivers/usb/phy/phy-omap-usb3.c @@ -26,6 +26,7 @@ #include #include #include +#include #definePLL_STATUS 0x0004 #definePLL_GO 0x0008 @@ -196,8 +197,14 @@ static int omap_usb3_init(struct usb_phy *x) static int omap_usb3_probe(struct platform_device *pdev) { - struct omap_usb *phy; - struct resource *res; + struct omap_usb *phy; + struct resource *res; + struct device_node *node = pdev->dev.of_node; + struct device_node *control_node; + struct platform_device *control_pdev; + + if (!node) + return -EINVAL; phy = devm_kzalloc(&pdev->dev, sizeof(*phy), GFP_KERNEL); if (!phy) { @@ -239,11 +246,18 @@ static int omap_usb3_probe(struct platform_device *pdev) return -EINVAL; } - phy->control_dev = omap_get_control_dev(); - if (IS_ERR(phy->control_dev)) { - dev_dbg(&pdev->dev, "Failed to get control device\n"); - return -ENODEV; + control_node = of_parse_phandle(node, "ctrl-module", 0); + if (!control_node) { + dev_err(&pdev->dev, "Failed to get control device phandle\n"); + return -EINVAL; } + control_pdev = of_find_device_by_node(control_node); + if (!control_pdev) { + dev_err(&pdev->dev, "Failed to get control device\n"); + return -EINVAL; + } + + phy->control_dev = &control_pdev->dev; omap_control_usb_phy_power(phy->control_dev, 0); usb_add_phy_dev(&phy->phy); -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 06/11] USB: OHCI: Properly handle ohci-exynos suspend
On Thu, Oct 03, 2013 at 10:31:53AM -0400, Alan Stern wrote: > On Thu, 3 Oct 2013, manju goudar wrote: > > > On Wed, Oct 2, 2013 at 9:22 PM, Alan Stern wrote: > > > > > On Wed, 2 Oct 2013, Bartlomiej Zolnierkiewicz wrote: > > > > > > > > > > > Hi, > > > > > > > > On Wednesday, October 02, 2013 10:38:58 AM Alan Stern wrote: > > > > > On Wed, 2 Oct 2013, Bartlomiej Zolnierkiewicz wrote: > > > > > > > > > > > Maybe it would make sense to cleanup ohci_suspend() first (before > > > adding > > > > > > new ohci_suspend() users) and remove unused do_wakeup parameter? > > > > > > > > > > Not possible. The do_wakeup parameter is part of a function prototype > > > > > shared by other callback routines (such as ehci_suspend()) that _do_ > > > > > use the parameter. > > > > > > > > If you mean ohci-pci.c usage (which is currently the only usage of > > > > ohci_suspend() looking at the latest -next kernel) than it is enough > > > > to add a simple wrapper for it in ohci-pci.c: > > > > > > > > ... > > > > static int ohci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup) > > > > { > > > > ohci_suspend(hcd); > > > > } > > > > ... > > > > ohci_pci_hc_driver.pci_suspend = ohci_pci_suspend; > > > > ... > > > > > > Ah, now I see your point. Yes, it's true; that parameter could be > > > eliminated. > > > > > > Manjunath, would you like to update your patch series to get rid of the > > > do_wakeup argument to ohci_suspend()? > > > > > > Yes I will do. I think we can also rid of ehci_suspend() do_wakeup > > argument. > > Arrgh! Manjunath, I was wrong. I'm sorry to make you do all this > extra work -- your original patch series was correct. > > Bartlomiej, we both failed to notice that the 1/11 patch in the > original series adds a usage of do_wakeup. Therefore that argument > cannot be removed. > > Greg, please ignore Manjunath's V2 series (sent today) and merge the > original 11-patch series posted on October 2. I no longer have these. Manjunath, can you please resend the "correct" series that I should apply so that it is obvious which is your latest version? 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 v2 2/2] usb: ohci: use amd_chipset_type to filter for SB800 prefetch
Commit "usb: pci-quirks: refactor AMD quirk to abstract AMD chipset types" introduced a new AMD chipset type to filter AMD platforms with different chipsets. According to a recent thread [1], this patch updates SB800 prefetch routine in AMD PLL quirk. And make it use the new chipset type to represent SB800 generation. [1] http://marc.info/?l=linux-usb&m=138012321616452&w=2 Signed-off-by: Huang Rui Acked-by: Alan Stern --- Changes from v1 -> v2: - Remove "? 1 : 0" part and change usb_amd_prefetch_quirk return type to bool. This patch is generated on gregkh/usb usb-next. drivers/usb/host/ohci-pci.c | 14 +- drivers/usb/host/pci-quirks.c | 8 drivers/usb/host/pci-quirks.h | 1 + 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c index eedf97c..90879e9 100644 --- a/drivers/usb/host/ohci-pci.c +++ b/drivers/usb/host/ohci-pci.c @@ -150,28 +150,16 @@ static int ohci_quirk_nec(struct usb_hcd *hcd) static int ohci_quirk_amd700(struct usb_hcd *hcd) { struct ohci_hcd *ohci = hcd_to_ohci(hcd); - struct pci_dev *amd_smbus_dev; - u8 rev; if (usb_amd_find_chipset_info()) ohci->flags |= OHCI_QUIRK_AMD_PLL; - amd_smbus_dev = pci_get_device(PCI_VENDOR_ID_ATI, - PCI_DEVICE_ID_ATI_SBX00_SMBUS, NULL); - if (!amd_smbus_dev) - return 0; - - rev = amd_smbus_dev->revision; - /* SB800 needs pre-fetch fix */ - if ((rev >= 0x40) && (rev <= 0x4f)) { + if (usb_amd_prefetch_quirk()) { ohci->flags |= OHCI_QUIRK_AMD_PREFETCH; ohci_dbg(ohci, "enabled AMD prefetch quirk\n"); } - pci_dev_put(amd_smbus_dev); - amd_smbus_dev = NULL; - return 0; } diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c index 138a555..8c6c6d9 100644 --- a/drivers/usb/host/pci-quirks.c +++ b/drivers/usb/host/pci-quirks.c @@ -275,6 +275,14 @@ bool usb_amd_hang_symptom_quirk(void) } EXPORT_SYMBOL_GPL(usb_amd_hang_symptom_quirk); +bool usb_amd_prefetch_quirk(void) +{ + usb_amd_find_chipset_info(); + /* SB800 needs pre-fetch fix */ + return amd_chipset.sb_type.gen == AMD_CHIPSET_SB800; +} +EXPORT_SYMBOL_GPL(usb_amd_prefetch_quirk); + /* * The hardware normally enables the A-link power management feature, which * lets the system lower the power consumption in idle states. diff --git a/drivers/usb/host/pci-quirks.h b/drivers/usb/host/pci-quirks.h index 820f532..638e88f 100644 --- a/drivers/usb/host/pci-quirks.h +++ b/drivers/usb/host/pci-quirks.h @@ -6,6 +6,7 @@ void uhci_reset_hc(struct pci_dev *pdev, unsigned long base); int uhci_check_and_reset_hc(struct pci_dev *pdev, unsigned long base); int usb_amd_find_chipset_info(void); bool usb_amd_hang_symptom_quirk(void); +bool usb_amd_prefetch_quirk(void); void usb_amd_dev_put(void); void usb_amd_quirk_pll_disable(void); void usb_amd_quirk_pll_enable(void); -- 1.7.11.7 -- 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: ehci: use amd_chipset_type to filter for usb subsystem hang bug
Commit "usb: pci-quirks: refactor AMD quirk to abstract AMD chipset types" introduced a new AMD chipset type to filter AMD platforms with different chipsets. According to a recent thread [1], this patch updates USB subsystem hang symptom quirk which is observed on AMD all SB600 and SB700 revision 0x3a/0x3b. And make it use the new chipset type to represent. [1] http://marc.info/?l=linux-usb&m=138012321616452&w=2 Signed-off-by: Huang Rui Acked-by: Alan Stern --- Changes from v1 -> v2: - Remove "? 1 : 0" part and change usb_amd_hang_symptom_quirk return type to bool. This patch is generated on gregkh/usb usb-next. drivers/usb/host/ehci-pci.c | 24 ++-- drivers/usb/host/pci-quirks.c | 13 + drivers/usb/host/pci-quirks.h | 1 + 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c index 854c2ec..3e86bf4 100644 --- a/drivers/usb/host/ehci-pci.c +++ b/drivers/usb/host/ehci-pci.c @@ -58,8 +58,6 @@ static int ehci_pci_setup(struct usb_hcd *hcd) { struct ehci_hcd *ehci = hcd_to_ehci(hcd); struct pci_dev *pdev = to_pci_dev(hcd->self.controller); - struct pci_dev *p_smbus; - u8 rev; u32 temp; int retval; @@ -175,22 +173,12 @@ static int ehci_pci_setup(struct usb_hcd *hcd) /* SB600 and old version of SB700 have a bug in EHCI controller, * which causes usb devices lose response in some cases. */ - if ((pdev->device == 0x4386) || (pdev->device == 0x4396)) { - p_smbus = pci_get_device(PCI_VENDOR_ID_ATI, -PCI_DEVICE_ID_ATI_SBX00_SMBUS, -NULL); - if (!p_smbus) - break; - rev = p_smbus->revision; - if ((pdev->device == 0x4386) || (rev == 0x3a) - || (rev == 0x3b)) { - u8 tmp; - ehci_info(ehci, "applying AMD SB600/SB700 USB " - "freeze workaround\n"); - pci_read_config_byte(pdev, 0x53, &tmp); - pci_write_config_byte(pdev, 0x53, tmp | (1<<3)); - } - pci_dev_put(p_smbus); + if ((pdev->device == 0x4386 || pdev->device == 0x4396) && + usb_amd_hang_symptom_quirk()) { + u8 tmp; + ehci_info(ehci, "applying AMD SB600/SB700 USB freeze workaround\n"); + pci_read_config_byte(pdev, 0x53, &tmp); + pci_write_config_byte(pdev, 0x53, tmp | (1<<3)); } break; case PCI_VENDOR_ID_NETMOS: diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c index 9eec463..138a555 100644 --- a/drivers/usb/host/pci-quirks.c +++ b/drivers/usb/host/pci-quirks.c @@ -262,6 +262,19 @@ int usb_hcd_amd_remote_wakeup_quirk(struct pci_dev *pdev) } EXPORT_SYMBOL_GPL(usb_hcd_amd_remote_wakeup_quirk); +bool usb_amd_hang_symptom_quirk(void) +{ + u8 rev; + + usb_amd_find_chipset_info(); + rev = amd_chipset.sb_type.rev; + /* SB600 and old version of SB700 have hang symptom bug */ + return amd_chipset.sb_type.gen == AMD_CHIPSET_SB600 || + (amd_chipset.sb_type.gen == AMD_CHIPSET_SB700 && +rev >= 0x3a && rev <= 0x3b); +} +EXPORT_SYMBOL_GPL(usb_amd_hang_symptom_quirk); + /* * The hardware normally enables the A-link power management feature, which * lets the system lower the power consumption in idle states. diff --git a/drivers/usb/host/pci-quirks.h b/drivers/usb/host/pci-quirks.h index ed6700d..820f532 100644 --- a/drivers/usb/host/pci-quirks.h +++ b/drivers/usb/host/pci-quirks.h @@ -5,6 +5,7 @@ void uhci_reset_hc(struct pci_dev *pdev, unsigned long base); int uhci_check_and_reset_hc(struct pci_dev *pdev, unsigned long base); int usb_amd_find_chipset_info(void); +bool usb_amd_hang_symptom_quirk(void); void usb_amd_dev_put(void); void usb_amd_quirk_pll_disable(void); void usb_amd_quirk_pll_enable(void); -- 1.7.11.7 -- 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] xhci: quirk for extra long delay for S4[V2]
Hi Oliver, This patch looks fine, aside from the introduction of trailing whitespace on the blank line change, which I've fixed. I'll queue it to Greg shortly. Thanks, Sarah Sharp On Mon, Sep 30, 2013 at 03:50:54PM +0200, oli...@neukum.org wrote: > From: Oliver Neukum > > It has been reported that this chipset really cannot > sleep without this extraordinary delay. > > Signed-off-by: Oliver Neukum > --- > drivers/usb/host/xhci-pci.c | 8 > drivers/usb/host/xhci.c | 9 +++-- > drivers/usb/host/xhci.h | 1 + > 3 files changed, 16 insertions(+), 2 deletions(-) > > diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c > index 236c3aa..5444ecd 100644 > --- a/drivers/usb/host/xhci-pci.c > +++ b/drivers/usb/host/xhci-pci.c > @@ -69,6 +69,14 @@ static void xhci_pci_quirks(struct device *dev, struct > xhci_hcd *xhci) > "QUIRK: Fresco Logic xHC needs configure" > " endpoint cmd after reset endpoint"); > } > + if (pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_PDK && > + pdev->revision == 0x4) { > + xhci->quirks |= XHCI_SLOW_SUSPEND; > + xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, > + "QUIRK: Fresco Logic xHC revision %u" > + "must be suspended extra slowly", > + pdev->revision); > + } > /* Fresco Logic confirms: all revisions of this chip do not >* support MSI, even though some of them claim to in their PCI >* capabilities. > diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c > index 1e36dbb..e9825b9 100644 > --- a/drivers/usb/host/xhci.c > +++ b/drivers/usb/host/xhci.c > @@ -839,6 +839,7 @@ static void xhci_clear_command_ring(struct xhci_hcd *xhci) > int xhci_suspend(struct xhci_hcd *xhci) > { > int rc = 0; > + unsigned intdelay = XHCI_MAX_HALT_USEC; > struct usb_hcd *hcd = xhci_to_hcd(xhci); > u32 command; > > @@ -850,7 +851,7 @@ int xhci_suspend(struct xhci_hcd *xhci) > xhci_dbg(xhci, "%s: stopping port polling.\n", __func__); > clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); > del_timer_sync(&hcd->rh_timer); > - > + > spin_lock_irq(&xhci->lock); > clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); > clear_bit(HCD_FLAG_HW_ACCESSIBLE, &xhci->shared_hcd->flags); > @@ -861,8 +862,12 @@ int xhci_suspend(struct xhci_hcd *xhci) > command = xhci_readl(xhci, &xhci->op_regs->command); > command &= ~CMD_RUN; > xhci_writel(xhci, command, &xhci->op_regs->command); > + > + /* Some chips from Fresco Logic need an extraordinary delay */ > + delay *= (xhci->quirks & XHCI_SLOW_SUSPEND) ? 10 : 1; > + > if (xhci_handshake(xhci, &xhci->op_regs->status, > - STS_HALT, STS_HALT, XHCI_MAX_HALT_USEC)) { > + STS_HALT, STS_HALT, delay)) { > xhci_warn(xhci, "WARN: xHC CMD_RUN timeout\n"); > spin_unlock_irq(&xhci->lock); > return -ETIMEDOUT; > diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h > index 289fbfb..4f82d21 100644 > --- a/drivers/usb/host/xhci.h > +++ b/drivers/usb/host/xhci.h > @@ -1548,6 +1548,7 @@ struct xhci_hcd { > #define XHCI_COMP_MODE_QUIRK (1 << 14) > #define XHCI_AVOID_BEI (1 << 15) > #define XHCI_PLAT(1 << 16) > +#define XHCI_SLOW_SUSPEND(1 << 17) > unsigned intnum_active_eps; > unsigned intlimit_active_eps; > /* There are two roothubs to keep track of bus suspend info for */ > -- > 1.8.3.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 v7 09/10] usb: dwc3: omap: manage "usb_otg_ss_refclk960m" clock
On Thu, Oct 03, 2013 at 05:54:14PM +0300, Roger Quadros wrote: > On 10/03/2013 03:29 PM, Felipe Balbi wrote: > > Hi, > > > > On Wed, Oct 02, 2013 at 04:41:53PM +0300, Roger Quadros wrote: > >> On 10/02/2013 04:11 PM, Felipe Balbi wrote: > >>> On Mon, Sep 23, 2013 at 04:11:30PM +0300, Roger Quadros wrote: > Hi Felipe, > > On 09/18/2013 03:49 PM, Roger Quadros wrote: > > "usb_otg_ss_refclk960m" is an optional functional clock to the > > UBS_OTG_SS module. So manage it in the driver. > > > > Just realized that "usb_otg_ss_refclk960m" is in fact functional clock > to the > PHY and not USB_OTG_SS module. The name is misleading. > > So please ignore patch 9 and 10. > >>> > >>> ignored. All others are fine, right ? > >>> > >> Yes. But I might have to rebase this on top of Phy framework stuff. > > > > alright, Greg already took the PHY framework, so maybe we need to just > > give him my Acked-by and he takes the patches directly as I don't have > > PYH framework. > > > OK. I'll resend this series to Greg in a while. It looks like you did, but forgot Felipe's ack :( -- 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/1] usb: xhci: Staticize xhci_del_comp_mod_timer
This patch looks good. I've applied it and will send it to Greg shortly. Sarah Sharp On Mon, Sep 16, 2013 at 12:01:34PM +0530, Sachin Kamat wrote: > 'xhci_del_comp_mod_timer' is local to this file. > > Signed-off-by: Sachin Kamat > --- > drivers/usb/host/xhci-hub.c |3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c > index fae697e..2b61700 100644 > --- a/drivers/usb/host/xhci-hub.c > +++ b/drivers/usb/host/xhci-hub.c > @@ -524,7 +524,8 @@ static void xhci_hub_report_usb3_link_state(u32 *status, > u32 status_reg) > * the compliance mode timer is deleted. A port won't enter > * compliance mode if it has previously entered U0. > */ > -void xhci_del_comp_mod_timer(struct xhci_hcd *xhci, u32 status, u16 wIndex) > +static void xhci_del_comp_mod_timer(struct xhci_hcd *xhci, u32 status, > + u16 wIndex) > { > u32 all_ports_seen_u0 = ((1 << xhci->num_usb3_ports)-1); > bool port_in_u0 = ((status & PORT_PLS_MASK) == XDEV_U0); > -- > 1.7.9.5 > -- 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 2/2] usb: chipidea: add Intel Clovertrail pci id
Hi Greg, On 10/02/2013 10:21 PM, Greg KH wrote: On Tue, Oct 01, 2013 at 02:32:58PM -0700, David Cohen wrote: Signed-off-by: David Cohen --- drivers/usb/chipidea/ci_hdrc_pci.c | 5 + 1 file changed, 5 insertions(+) diff --git a/drivers/usb/chipidea/ci_hdrc_pci.c b/drivers/usb/chipidea/ci_hdrc_pci.c index 08a724b..d514332 100644 --- a/drivers/usb/chipidea/ci_hdrc_pci.c +++ b/drivers/usb/chipidea/ci_hdrc_pci.c @@ -129,6 +129,11 @@ static DEFINE_PCI_DEVICE_TABLE(ci_hdrc_pci_id_table) = { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0829), .driver_data = (kernel_ulong_t)&penwell_pci_platdata, }, + { + /* Intel Clovertrail */ + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xe006), + .driver_data = (kernel_ulong_t)&penwell_pci_platdata, + }, Can this go into 3.12-final, and any other stable kernel releases as well? Or does this platform also need other fixes that aren't in 3.10 and 3.11? This was tested on 3.10+ It might work on 3.4 but it's not validated. I can test it if we care about chipidea on 3.4. Br, David 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: Usb 3.0 external dd offlined, not ready after error recovery
On Wed, 2 Oct 2013, [ISO-8859-1] Jorge Mu�oz Camadro wrote: > Usbmon shows this when plugin the usb external drive: It's all normal up to here... > 880213239a80 1383565784 S Ci:1:006:0 s a1 fe 0001 1 < > 880213239a80 1383566386 C Ci:1:006:0 0 1 = 01 > 880213239a80 1383566512 S Bo:1:006:2 -115 31 = 55534243 0100 > 2400 8612 0024 00 > 880213239a80 1383566536 C Bo:1:006:2 0 31 > > 880202ba1780 1383566549 S Bi:1:006:1 -115 36 < This shows the drive telling the computer that it has two logical units. Then the computer sends its first command to the drive, but the drive doesn't send any data back. > I never used usbmon before, so i follow the instructions from > https://www.kernel.org/doc/Documentation/usb/usbmon.txt > Hope this is useful. You did it right. However, the trace doesn't show _why_ the drive failed to respond. One thing I just noticed in your earlier message: > >> [ 1405.646775] usb 1-2: new high-speed USB device number 5 using xhci_hcd Although the drive is USB-3 and is capable of communicating at SuperSpeed (5 Gb/s), it is running at only high speed (480 Mb/s). This suggests there may be something wrong with the cable. Are you using a high-quality USB-3 cable? It's possible that this is a link power management problem. There have been reports of similar problems in that area, and a patch was posted here: http://marc.info/?l=linux-usb&m=138005811528076&w=2 Does the drive work with that patch installed? 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
XHCI: Handling of Zero length packet in data stage
We have devices which require to send zero length packet in data stage to host in certain cases. We were not seeing any issue when we were using ehci based controller. When we switched to XHCI here is what we are observing:- For IN DATA dir control xfer XHCI sets ISP so xhci updates actual_length for short packet in data stage using event->transfer_len. But for data packets not short xhci directly uses urb->transfer_buffer_length as actual_length.This is done assuming data stage will never have zero length (short packet) data packet. Once Device sends zero length packet in data stage ISP triggers and actual_length is updated with value 0. Then later in status stage (since urb->actual_length is zero) driver incorrectly sets actual_length with urb->transfer_buffer_length. I would like to get insight from linux-usb grp to fix this issue. Thanks, Hemant -- 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: XHCI: Handling of Zero length packet in data stage
On Thu, Oct 03, 2013 at 06:00:50PM -, hema...@codeaurora.org wrote: > We have devices which require to send zero length packet in data stage to > host in certain cases. We were not seeing any issue when we were using > ehci based controller. When we switched to XHCI here is what we are > observing:- > > For IN DATA dir control xfer XHCI sets ISP so xhci updates actual_length > for short packet in data stage using event->transfer_len. > > But for data packets not short xhci directly uses > urb->transfer_buffer_length as actual_length.This is done assuming data > stage will never have zero length (short packet) data packet. Once Device > sends zero length packet in data stage > ISP triggers and actual_length is updated with value 0. Then later in > status stage (since urb->actual_length is zero) driver incorrectly sets > actual_length with urb->transfer_buffer_length. > > > I would like to get insight from linux-usb grp to fix this issue. What kernel version are you seeing these problems? 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] staging: dwc2: Make dwc2_hw_params.host_channels large enough
> From: Matthijs Kooijman [mailto:matth...@stdin.nl] > Sent: Thursday, October 03, 2013 12:35 AM > > > By the way, it looks like 'num_dev_ep' would have the same problem, > > I don't think so, since the hardware doesn't do the off-by-one trick > there (presumably because having 0 endpoints make sense, but 0 host > channels doesn't): > > hw->num_dev_ep = (hwcfg2 & GHWCFG2_NUM_DEV_EP_MASK) >> > GHWCFG2_NUM_DEV_EP_SHIFT; Yep, you're right, I got it confused with GHWCFG4_NUM_IN_EPS, which we don't use. > > That one and also 'num_dev_perio_in_ep' and 'dev_token_q_depth' should > > be removed, I think. > > Doesn't hurt to keep them around, I think? When device mode is > implemented, I guess this code will need to present exactly like it is > now (unlike other device mode code, which likely needs to be adapted to > whatever s3-hsotg is doing now)? When we go to move the driver out of staging, I'm pretty sure these do-nothing parameters will have to be removed. -- Paul -- 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: XHCI: Handling of Zero length packet in data stage
> On Thu, Oct 03, 2013 at 06:00:50PM -, hema...@codeaurora.org wrote: >> We have devices which require to send zero length packet in data stage >> to >> host in certain cases. We were not seeing any issue when we were using >> ehci based controller. When we switched to XHCI here is what we are >> observing:- >> >> For IN DATA dir control xfer XHCI sets ISP so xhci updates actual_length >> for short packet in data stage using event->transfer_len. >> >> But for data packets not short xhci directly uses >> urb->transfer_buffer_length as actual_length.This is done assuming data >> stage will never have zero length (short packet) data packet. Once >> Device >> sends zero length packet in data stage >> ISP triggers and actual_length is updated with value 0. Then later in >> status stage (since urb->actual_length is zero) driver incorrectly sets >> actual_length with urb->transfer_buffer_length. >> >> >> I would like to get insight from linux-usb grp to fix this issue. > > What kernel version are you seeing these problems? > > thanks, > > greg k-h > i am using 3.10 kernel. Also i looked at tip i see same implementation for process_ctrl_td() https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/host/xhci-ring.c Thanks, Hemant -- 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/1] hso: fix problem with wrong status code sent by OPTION GTM601 during RING indication
From: "Dr. H. Nikolaus Schaller" Date: Wed, 2 Oct 2013 09:00:18 +0200 > From f5c7e15b61f2ce4fe3105ff914f6bfaf5d74af0d Mon Sep 17 00:00:00 2001 > From: "H. Nikolaus Schaller" > Date: Thu, 15 Nov 2012 14:40:57 +0100 > Subject: [PATCH 1/1] hso: fix problem with wrong status code sent by OPTION > GTM601 during RING indication > > It has been observed that the GTM601 with 1.7 firmware sometimes sends a > value > wIndex that has bit 0x04 set instead of being reset as the code expects. So > we > mask it for the error check. > > See > http://lists.goldelico.com/pipermail/gta04-owner/2012-February/001643.html > > Signed-off-by: NeilBrown > Signed-off-by: H. Nikolaus Schaller I think we should look more deeply into what this bit might mean and why the firmware might be setting it before we even consider applying a patch like this one. -- 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/1] hso: fix problem with wrong status code sent by OPTION GTM601 during RING indication
Hi, Am 03.10.2013 um 21:29 schrieb David Miller: > From: "Dr. H. Nikolaus Schaller" > Date: Wed, 2 Oct 2013 09:00:18 +0200 > >> From f5c7e15b61f2ce4fe3105ff914f6bfaf5d74af0d Mon Sep 17 00:00:00 2001 >> From: "H. Nikolaus Schaller" >> Date: Thu, 15 Nov 2012 14:40:57 +0100 >> Subject: [PATCH 1/1] hso: fix problem with wrong status code sent by OPTION >> GTM601 during RING indication >> >> It has been observed that the GTM601 with 1.7 firmware sometimes sends a >> value >> wIndex that has bit 0x04 set instead of being reset as the code expects. So >> we >> mask it for the error check. >> >> See >> http://lists.goldelico.com/pipermail/gta04-owner/2012-February/001643.html >> >> Signed-off-by: NeilBrown >> Signed-off-by: H. Nikolaus Schaller > > I think we should look more deeply into what this bit might mean > and why the firmware might be setting it before we even consider > applying a patch like this one. Yes, that would be the right way. The problem is that the firmware is a black box and the packet format has no (public) documentation (unless someone inside OPTION has access to it). I have made the bug observation from debug log that this bit is set in a response each time the modem has a RING message. It might be specific to this modem and firmware version, i.e. a firmware bug. But we have no means to verify or even change it in the firmware. I.e. the driver must handle it in a better way. Because the notification is rejected by the driver, the driver will hang up and the whole modem connection breaks down. With this patch, the problem was never observed again in ~2 years. I'd hope the maintainer of this driver can shed some light on it. BR, Nikolaus Schaller -- 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/1] hso: fix problem with wrong status code sent by OPTION GTM601 during RING indication
From: "Dr. H. Nikolaus Schaller" Date: Thu, 3 Oct 2013 21:40:34 +0200 > I have made the bug observation from debug log that this bit is set in a > response > each time the modem has a RING message. It might be specific to this modem > and firmware version, i.e. a firmware bug. But we have no means to verify or > even > change it in the firmware. > > I.e. the driver must handle it in a better way. > > Because the notification is rejected by the driver, the driver will hang up > and the > whole modem connection breaks down. > > With this patch, the problem was never observed again in ~2 years. > > I'd hope the maintainer of this driver can shed some light on it. I think if you suspect the bit is set in response to RING messages then you should define a macro so that the number is not just magic, and put a descriptrive comment above the macro definition for that bit. -- 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
looking for loan
Do you have a firm or company that need loan to start up a business or need,personal loan, Debt consolidation? For more information,Contact us now for a guarantee loan with low interest rate. We will provide you with loan to meet your needs. For more information contact us with the following information's. Full name: country: Address: Phone Number: Amount needed: Duration of loan: sg.loan...@outlook.com Kind regards -- 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 3.0 external dd offlined, not ready after error recovery
> Although the drive is USB-3 and is capable of communicating at > SuperSpeed (5 Gb/s), it is running at only high speed (480 Mb/s). > This suggests there may be something wrong with the cable. Are you > using a high-quality USB-3 cable? > I'm using the one who comes with the drive, i've never changed it, and doesn't show any sign of been broken or something like that. It seems like a propietary model. > It's possible that this is a link power management problem. There have > been reports of similar problems in that area, and a patch was posted > here: > > http://marc.info/?l=linux-usb&m=138005811528076&w=2 > > Does the drive work with that patch installed? > Guess not, i'm using exactly the same kernel provided by my distro, no changes. > 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
[PATCH 3/6] xhci: Check size rather then number of streams when allocating stream ctxs
Before this a device needing ie 32 stream ctxs would end up with an entry from the small_streams_pool which has 256 bytes entries, where as 32 stream ctxs need 512 bytes. Things actually keep running for a surprisingly long time before crashing because of this. Signed-off-by: Hans de Goede --- drivers/usb/host/xhci-mem.c | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 2a63489f..623f7b6 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -441,12 +441,12 @@ static void xhci_free_stream_ctx(struct xhci_hcd *xhci, struct xhci_stream_ctx *stream_ctx, dma_addr_t dma) { struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); + size_t size = sizeof(struct xhci_stream_ctx) * num_stream_ctxs; - if (num_stream_ctxs > MEDIUM_STREAM_ARRAY_SIZE) - dma_free_coherent(&pdev->dev, - sizeof(struct xhci_stream_ctx)*num_stream_ctxs, + if (size > MEDIUM_STREAM_ARRAY_SIZE) + dma_free_coherent(&pdev->dev, size, stream_ctx, dma); - else if (num_stream_ctxs <= SMALL_STREAM_ARRAY_SIZE) + else if (size <= SMALL_STREAM_ARRAY_SIZE) return dma_pool_free(xhci->small_streams_pool, stream_ctx, dma); else @@ -469,12 +469,12 @@ static struct xhci_stream_ctx *xhci_alloc_stream_ctx(struct xhci_hcd *xhci, gfp_t mem_flags) { struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); + size_t size = sizeof(struct xhci_stream_ctx) * num_stream_ctxs; - if (num_stream_ctxs > MEDIUM_STREAM_ARRAY_SIZE) - return dma_alloc_coherent(&pdev->dev, - sizeof(struct xhci_stream_ctx)*num_stream_ctxs, + if (size > MEDIUM_STREAM_ARRAY_SIZE) + return dma_alloc_coherent(&pdev->dev, size, dma, mem_flags); - else if (num_stream_ctxs <= SMALL_STREAM_ARRAY_SIZE) + else if (size <= SMALL_STREAM_ARRAY_SIZE) return dma_pool_alloc(xhci->small_streams_pool, mem_flags, dma); else -- 1.8.3.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 1/6] xhci: fix usb3 streams
From: Gerd Hoffmann xhci maintains a radix tree for each stream endpoint because it must be able to map a trb address to the stream ring. Each ring segment must be added to the ring for this to work. Currently xhci sticks only the first segment of each stream ring into the radix tree. Result is that things work initially, but as soon as the first segment is full xhci can't map the trb address from the completion event to the stream ring any more -> BOOM. You'll find this message in the logs: ERROR Transfer event for disabled endpoint or incorrect stream ring This patch adds a helper function to update the radix tree. It can both insert and remove ring segments. It loops over the segment list and handles all segments instead of just the first. It is called whenever an update is needed: When allocating a ring, when expanding a ring and when releasing a ring. Signed-off-by: Gerd Hoffmann Signed-off-by: Hans de Goede --- drivers/usb/host/xhci-mem.c | 53 ++--- drivers/usb/host/xhci.h | 2 ++ 2 files changed, 42 insertions(+), 13 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 53b972c..2a63489f 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -155,8 +155,11 @@ void xhci_ring_free(struct xhci_hcd *xhci, struct xhci_ring *ring) if (!ring) return; - if (ring->first_seg) + if (ring->first_seg) { + if (ring->type == TYPE_STREAM) + xhci_update_stream_ring(ring, false); xhci_free_segments_for_ring(xhci, ring->first_seg); + } kfree(ring); } @@ -353,6 +356,11 @@ int xhci_ring_expansion(struct xhci_hcd *xhci, struct xhci_ring *ring, "ring expansion succeed, now has %d segments", ring->num_segs); + if (ring->type == TYPE_STREAM) { + ret = xhci_update_stream_ring(ring, true); + WARN_ON(ret); /* FIXME */ + } + return 0; } @@ -540,6 +548,35 @@ struct xhci_ring *xhci_stream_id_to_ring( * extended systems (where the DMA address can be bigger than 32-bits), * if we allow the PCI dma mask to be bigger than 32-bits. So don't do that. */ + +int xhci_update_stream_ring(struct xhci_ring *ring, bool insert) +{ + struct xhci_segment *seg; + unsigned long key; + bool present; + int ret; + + if (WARN_ON_ONCE(ring->trb_address_map == NULL)) + return 0; + + seg = ring->first_seg; + do { + key = (unsigned long)(seg->dma >> TRB_SEGMENT_SHIFT); + present = radix_tree_lookup(ring->trb_address_map, key) != NULL; + if (!present && insert) { + ret = radix_tree_insert(ring->trb_address_map, + key, ring); + if (ret) + return ret; + } + if (present && !insert) + radix_tree_delete(ring->trb_address_map, key); + seg = seg->next; + } while (seg != ring->first_seg); + + return 0; +} + struct xhci_stream_info *xhci_alloc_stream_info(struct xhci_hcd *xhci, unsigned int num_stream_ctxs, unsigned int num_streams, gfp_t mem_flags) @@ -547,7 +584,6 @@ struct xhci_stream_info *xhci_alloc_stream_info(struct xhci_hcd *xhci, struct xhci_stream_info *stream_info; u32 cur_stream; struct xhci_ring *cur_ring; - unsigned long key; u64 addr; int ret; @@ -602,6 +638,7 @@ struct xhci_stream_info *xhci_alloc_stream_info(struct xhci_hcd *xhci, if (!cur_ring) goto cleanup_rings; cur_ring->stream_id = cur_stream; + cur_ring->trb_address_map = &stream_info->trb_address_map; /* Set deq ptr, cycle bit, and stream context type */ addr = cur_ring->first_seg->dma | SCT_FOR_CTX(SCT_PRI_TR) | @@ -611,10 +648,7 @@ struct xhci_stream_info *xhci_alloc_stream_info(struct xhci_hcd *xhci, xhci_dbg(xhci, "Setting stream %d ring ptr to 0x%08llx\n", cur_stream, (unsigned long long) addr); - key = (unsigned long) - (cur_ring->first_seg->dma >> TRB_SEGMENT_SHIFT); - ret = radix_tree_insert(&stream_info->trb_address_map, - key, cur_ring); + ret = xhci_update_stream_ring(cur_ring, true); if (ret) { xhci_ring_free(xhci, cur_ring); stream_info->stream_rings[cur_stream] = NULL; @@ -634,9 +668,6 @@ cleanup_rings: for (cur_stream = 1; cur_stream < num_streams; cur_stream++) { cur_ring = stream_info->stream_rings[cur_stream];
[PATCH 2/6] xhci: Free streams when they are still allocated on a set_interface call
And warn about this, as that would be a driver bug. Like wise drivers should ensure that streams are properly free-ed before a device is reset. So lets warn about that too. This already causes warnings in the form of: [ 96.982398] xhci_hcd :01:00.0: WARN Can't disable streams for endpoint 0x81 , streams are already disabled! [ 96.982400] xhci_hcd :01:00.0: WARN xhci_free_streams() called with non-streams endpoint But it is better to also warn about the actual cause of this later warnings. Signed-off-by: Hans de Goede --- drivers/usb/host/xhci.c | 23 ++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 49b6edb..e06ee5d 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -2670,6 +2670,21 @@ static int xhci_configure_endpoint(struct xhci_hcd *xhci, return ret; } +static void xhci_check_bw_drop_ep_streams(struct xhci_hcd *xhci, + struct xhci_virt_device *vdev, int i) +{ + struct xhci_virt_ep *ep = &vdev->eps[i]; + + if (ep->ep_state & EP_HAS_STREAMS) { + xhci_warn(xhci, "WARN: endpoint 0x%02x has streams" + "on set_interface, freeing streams.\n", + xhci_get_endpoint_address(i)); + xhci_free_stream_info(xhci, ep->stream_info); + ep->stream_info = NULL; + ep->ep_state &= ~EP_HAS_STREAMS; + } +} + /* Called after one or more calls to xhci_add_endpoint() or * xhci_drop_endpoint(). If this call fails, the USB core is expected * to call xhci_reset_bandwidth(). @@ -2734,8 +2749,10 @@ int xhci_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev) /* Free any rings that were dropped, but not changed. */ for (i = 1; i < 31; ++i) { if ((le32_to_cpu(ctrl_ctx->drop_flags) & (1 << (i + 1))) && - !(le32_to_cpu(ctrl_ctx->add_flags) & (1 << (i + 1 + !(le32_to_cpu(ctrl_ctx->add_flags) & (1 << (i + 1 { xhci_free_or_cache_endpoint_ring(xhci, virt_dev, i); + xhci_check_bw_drop_ep_streams(xhci, virt_dev, i); + } } xhci_zero_in_ctx(xhci, virt_dev); /* @@ -2751,6 +2768,7 @@ int xhci_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev) if (virt_dev->eps[i].ring) { xhci_free_or_cache_endpoint_ring(xhci, virt_dev, i); } + xhci_check_bw_drop_ep_streams(xhci, virt_dev, i); virt_dev->eps[i].ring = virt_dev->eps[i].new_ring; virt_dev->eps[i].new_ring = NULL; } @@ -3518,6 +3536,9 @@ int xhci_discover_or_reset_device(struct usb_hcd *hcd, struct usb_device *udev) struct xhci_virt_ep *ep = &virt_dev->eps[i]; if (ep->ep_state & EP_HAS_STREAMS) { + xhci_warn(xhci, "WARN: endpoint 0x%02x has streams" + "on device reset, freeing streams.\n", + xhci_get_endpoint_address(i)); xhci_free_stream_info(xhci, ep->stream_info); ep->stream_info = NULL; ep->ep_state &= ~EP_HAS_STREAMS; -- 1.8.3.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 0/6] xhci: Multiple fixes for usb bulk streams
Hi All, After spending 1.5 weeks debugging issues with xhci streams which would hard-freeze my machine every 5 minutes, I'm very happy to present this patch set, with which usb 3 streams are fully stable for me, including using them from userspace through qemu usb redirection (I'll post kernel patches for that tomorrow). This was tested with an uas device using Gerd Hoffmann's uas fixes / patches. To be sure that Gerd's important xhci stream fix patch does not get forgotten (if not already merged) I've added it as the first patch of this set. Regards, Hans -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 5/6] xhci: Set SCT field for Set TR dequeue on streams
Nec XHCI controllers don't seem to care, but without this Intel XHCI controllers reject Set TR dequeue commands with a COMP_TRB_ERR, leading to the following warning: WARN Set TR Deq Ptr cmd invalid because of stream ID configuration And very shortly after this the system completely freezes. Signed-off-by: Hans de Goede --- drivers/usb/host/xhci-ring.c | 5 - drivers/usb/host/xhci.h | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 1ad397f..bed4cfa 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -4007,6 +4007,7 @@ static int queue_set_tr_deq(struct xhci_hcd *xhci, int slot_id, u32 trb_slot_id = SLOT_ID_FOR_TRB(slot_id); u32 trb_ep_index = EP_ID_FOR_TRB(ep_index); u32 trb_stream_id = STREAM_ID_FOR_TRB(stream_id); + u32 trb_sct = 0; u32 type = TRB_TYPE(TRB_SET_DEQ); struct xhci_virt_ep *ep; @@ -4025,7 +4026,9 @@ static int queue_set_tr_deq(struct xhci_hcd *xhci, int slot_id, } ep->queued_deq_seg = deq_seg; ep->queued_deq_ptr = deq_ptr; - return queue_command(xhci, lower_32_bits(addr) | cycle_state, + if (stream_id) + trb_sct = SCT_FOR_TRB(SCT_PRI_TR); + return queue_command(xhci, lower_32_bits(addr) | trb_sct | cycle_state, upper_32_bits(addr), trb_stream_id, trb_slot_id | trb_ep_index | type, false); } diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 56bed15..a135f76 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -,9 +,10 @@ struct xhci_event_cmd { #define TRB_TO_SUSPEND_PORT(p) (((p) & (1 << 23)) >> 23) #define LAST_EP_INDEX 30 -/* Set TR Dequeue Pointer command TRB fields */ +/* Set TR Dequeue Pointer command TRB fields, 6.4.3.9 */ #define TRB_TO_STREAM_ID(p)p) & (0x << 16)) >> 16)) #define STREAM_ID_FOR_TRB(p) p)) & 0x) << 16) +#define SCT_FOR_TRB(p) (((p) << 1) & 0x7) /* Port Status Change Event TRB fields */ -- 1.8.3.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/6] xhci: For streams the css flag most be read from the stream-ctx on ep stop
Signed-off-by: Hans de Goede --- drivers/usb/host/xhci-ring.c | 14 +++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 411da1f..1ad397f 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -542,9 +542,9 @@ void xhci_find_new_dequeue_state(struct xhci_hcd *xhci, struct xhci_dequeue_state *state) { struct xhci_virt_device *dev = xhci->devs[slot_id]; + struct xhci_virt_ep *ep = &dev->eps[ep_index]; struct xhci_ring *ep_ring; struct xhci_generic_trb *trb; - struct xhci_ep_ctx *ep_ctx; dma_addr_t addr; ep_ring = xhci_triad_to_transfer_ring(xhci, slot_id, @@ -569,8 +569,16 @@ void xhci_find_new_dequeue_state(struct xhci_hcd *xhci, /* Dig out the cycle state saved by the xHC during the stop ep cmd */ xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, "Finding endpoint context"); - ep_ctx = xhci_get_ep_ctx(xhci, dev->out_ctx, ep_index); - state->new_cycle_state = 0x1 & le64_to_cpu(ep_ctx->deq); + /* 4.6.9 the css flag is written to the stream context for streams */ + if (ep->ep_state & EP_HAS_STREAMS) { + struct xhci_stream_ctx *ctx = + &ep->stream_info->stream_ctx_array[stream_id]; + state->new_cycle_state = 0x1 & le64_to_cpu(ctx->stream_ring); + } else { + struct xhci_ep_ctx *ep_ctx + = xhci_get_ep_ctx(xhci, dev->out_ctx, ep_index); + state->new_cycle_state = 0x1 & le64_to_cpu(ep_ctx->deq); + } state->new_deq_ptr = cur_td->last_trb; xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, -- 1.8.3.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 6/6] xhci: For streams the dequeue ptr must be read from the stream ctx
This fixes TR dequeue validation failing on Intel XHCI controllers with the following warning: Mismatch between completed Set TR Deq Ptr command & xHCI internal state. Interestingly enough reading the deq ptr from the ep ctx after a TR Deq Ptr command does work on a Nec XHCI controller, it seems the Nec writes the ptr to both the ep and stream contexts when streams are used. Signed-off-by: Hans de Goede --- drivers/usb/host/xhci-ring.c | 22 +++--- drivers/usb/host/xhci.h | 1 + 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index bed4cfa..1ca1732 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -1080,6 +1080,7 @@ static void handle_set_deq_completion(struct xhci_hcd *xhci, unsigned int stream_id; struct xhci_ring *ep_ring; struct xhci_virt_device *dev; + struct xhci_virt_ep *ep; struct xhci_ep_ctx *ep_ctx; struct xhci_slot_ctx *slot_ctx; @@ -1087,6 +1088,7 @@ static void handle_set_deq_completion(struct xhci_hcd *xhci, ep_index = TRB_TO_EP_INDEX(le32_to_cpu(trb->generic.field[3])); stream_id = TRB_TO_STREAM_ID(le32_to_cpu(trb->generic.field[2])); dev = xhci->devs[slot_id]; + ep = &dev->eps[ep_index]; ep_ring = xhci_stream_id_to_ring(dev, ep_index, stream_id); if (!ep_ring) { @@ -1138,12 +1140,19 @@ static void handle_set_deq_completion(struct xhci_hcd *xhci, * cancelling URBs, which might not be an error... */ } else { + __le64 deq; + /* 4.6.10 deq ptr is written to the stream ctx for streams */ + if (ep->ep_state & EP_HAS_STREAMS) { + struct xhci_stream_ctx *ctx = + &ep->stream_info->stream_ctx_array[stream_id]; + deq = le64_to_cpu(ctx->stream_ring) & SCTX_DEQ_MASK; + } else { + deq = le64_to_cpu(ep_ctx->deq) & ~EP_CTX_CYCLE_MASK; + } xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, - "Successful Set TR Deq Ptr cmd, deq = @%08llx", -le64_to_cpu(ep_ctx->deq)); - if (xhci_trb_virt_to_dma(dev->eps[ep_index].queued_deq_seg, -dev->eps[ep_index].queued_deq_ptr) == - (le64_to_cpu(ep_ctx->deq) & ~(EP_CTX_CYCLE_MASK))) { + "Successful Set TR Deq Ptr cmd, deq = @%08llx", deq); + if (xhci_trb_virt_to_dma(ep->queued_deq_seg, +ep->queued_deq_ptr) == deq) { /* Update the ring's dequeue segment and dequeue pointer * to reflect the new position. */ @@ -1153,8 +1162,7 @@ static void handle_set_deq_completion(struct xhci_hcd *xhci, xhci_warn(xhci, "Mismatch between completed Set TR Deq " "Ptr command & xHCI internal state.\n"); xhci_warn(xhci, "ep deq seg = %p, deq ptr = %p\n", - dev->eps[ep_index].queued_deq_seg, - dev->eps[ep_index].queued_deq_ptr); + ep->queued_deq_seg, ep->queued_deq_ptr); } } diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index a135f76..108e349 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -702,6 +702,7 @@ struct xhci_ep_ctx { /* deq bitmasks */ #define EP_CTX_CYCLE_MASK (1 << 0) +#define SCTX_DEQ_MASK (~0xfL) /** -- 1.8.3.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
RFC: leave bulk stream endpoints disabled until streams are allocated
Hi All, As a result of all my streams work, I've started to wonder if it would not be better to leave bulk endpoints with streams disabled until streams are allocated. It seems to me that allowing to submit non stream bulk transfers on stream eps is not useful, and could even be harmful if it causes the hardware to act up. I've also come up with a plan for implementing this, but before spending time on this, I would like to get some feedback on it. The plan is: 1) Alloc / free streams is part of setting up an interface, normally a driver would only call set_interface for this, but with streams a second call is necessary to let the hcd know how much streams the driver plans to use. Only one set_interface can run at a time due to the hcd->bandwidth_mutex lock, the xhci driver uses this to protect dev->in_ctx. Make usb_alloc_streams and usb_free_streams also take hcd->bandwidth_mutex, so that they cannot run at the same time as a set_interface and use dev->in_ctx 2) Change xhci_endpoint_init to take a streams argument. If this is non 0, no regular ring will be allocated, instead xhci_alloc_streaminfo will be called. 3.1) modify xhci_add_endpoint to be a nop for eps with streams, thus leaving them disabled 3.2) Make xhci_alloc_streams use dev->in_ctx, call xhci_endpoint_init for the eps on which streams are to be enabled, then do a xhci_configure_endpoint 3.3) Make xhci_free_streams use dev->in_ctx, make it drop all endpoints rather then reconfigure them, thus moving the endpoints to disabled. 4) Drop the no longer needed free_streams_command from stream_info So good idea or bad idea ? Regards, Hans -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] sound: usb: add support for wireless USB devices
On Tue, Oct 01, 2013 at 02:32:15PM -0500, Thomas Pugliese wrote: > This patch updates snd_usb_audio_create also support devices whose > speed == USB_SPEED_WIRELESS. > > Signed-off-by: Thomas Pugliese Acked-by: Greg Kroah-Hartman -- 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] sound: usb: support wireless devices in snd_usb_parse_datainterval
On Tue, Oct 01, 2013 at 02:32:57PM -0500, Thomas Pugliese wrote: > Hi, > This patch adds support for dev speed USB_SPEED_WIRELESS in > snd_usb_parse_datainterval which allows the usb sound core to create > ISO urbs with the correct number and size of buffers. > > Signed-off-by: Thomas Pugliese Acked-by: Greg Kroah-Hartman -- 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 2/2] usb: chipidea: add Intel Clovertrail pci id
On Thu, Oct 03, 2013 at 09:04:04AM -0700, David Cohen wrote: > Hi Greg, > > On 10/02/2013 10:21 PM, Greg KH wrote: > >On Tue, Oct 01, 2013 at 02:32:58PM -0700, David Cohen wrote: > >>Signed-off-by: David Cohen > >>--- > >> drivers/usb/chipidea/ci_hdrc_pci.c | 5 + > >> 1 file changed, 5 insertions(+) > >> > >>diff --git a/drivers/usb/chipidea/ci_hdrc_pci.c > >>b/drivers/usb/chipidea/ci_hdrc_pci.c > >>index 08a724b..d514332 100644 > >>--- a/drivers/usb/chipidea/ci_hdrc_pci.c > >>+++ b/drivers/usb/chipidea/ci_hdrc_pci.c > >>@@ -129,6 +129,11 @@ static DEFINE_PCI_DEVICE_TABLE(ci_hdrc_pci_id_table) = > >>{ > >>PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0829), > >>.driver_data = (kernel_ulong_t)&penwell_pci_platdata, > >>}, > >>+ { > >>+ /* Intel Clovertrail */ > >>+ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xe006), > >>+ .driver_data = (kernel_ulong_t)&penwell_pci_platdata, > >>+ }, > > > >Can this go into 3.12-final, and any other stable kernel releases as > >well? Or does this platform also need other fixes that aren't in 3.10 > >and 3.11? > > This was tested on 3.10+ > It might work on 3.4 but it's not validated. I can test it if we > care about chipidea on 3.4. I doubt anyone cares about chipidea on 3.4, 3.10 is good enough. I've mushed these patches together into one to make it easier to backport and apply to Linus's tree for 3.12-final. 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