[PATCH net-next v6 2/3] net: huawei_cdc_ncm: Introduce the huawei_cdc_ncm driver
From: Enrico Mioso mrkiko...@gmail.com This driver supports devices using the NCM protocol as an encapsulation layer for other protocols, like the E3131 Huawei 3G modem. This drivers approach was heavily inspired by the qmi_wwan/cdc_mbim approach code model. Signed-off-by: Enrico Mioso mrkiko...@gmail.com Signed-off-by: Bjørn Mork bj...@mork.no --- drivers/net/usb/Kconfig | 15 +++ drivers/net/usb/Makefile |1 + drivers/net/usb/huawei_cdc_ncm.c | 230 ++ 3 files changed, 246 insertions(+) create mode 100644 drivers/net/usb/huawei_cdc_ncm.c diff --git a/drivers/net/usb/Kconfig b/drivers/net/usb/Kconfig index 40db312..85e4a01 100644 --- a/drivers/net/usb/Kconfig +++ b/drivers/net/usb/Kconfig @@ -242,6 +242,21 @@ config USB_NET_CDC_NCM * ST-Ericsson M343 HSPA Mobile Broadband Modem (reference design) * Ericsson F5521gw Mobile Broadband Module +config USB_NET_HUAWEI_CDC_NCM + tristate Huawei NCM embedded AT channel support + depends on USB_USBNET + select USB_WDM + select USB_NET_CDC_NCM + help + This driver supports huawei-style NCM devices, that use NCM as a + transport for other protocols, usually an embedded AT channel. + Good examples are: + * Huawei E3131 + * Huawei E3251 + + To compile this driver as a module, choose M here: the module will be + called huawei_cdc_ncm.ko. + config USB_NET_CDC_MBIM tristate CDC MBIM support depends on USB_USBNET diff --git a/drivers/net/usb/Makefile b/drivers/net/usb/Makefile index 8b342cf..b17b5e8 100644 --- a/drivers/net/usb/Makefile +++ b/drivers/net/usb/Makefile @@ -32,6 +32,7 @@ obj-$(CONFIG_USB_IPHETH) += ipheth.o obj-$(CONFIG_USB_SIERRA_NET) += sierra_net.o obj-$(CONFIG_USB_NET_CX82310_ETH) += cx82310_eth.o obj-$(CONFIG_USB_NET_CDC_NCM) += cdc_ncm.o +obj-$(CONFIG_USB_NET_HUAWEI_CDC_NCM) += huawei_cdc_ncm.o obj-$(CONFIG_USB_VL600)+= lg-vl600.o obj-$(CONFIG_USB_NET_QMI_WWAN) += qmi_wwan.o obj-$(CONFIG_USB_NET_CDC_MBIM) += cdc_mbim.o diff --git a/drivers/net/usb/huawei_cdc_ncm.c b/drivers/net/usb/huawei_cdc_ncm.c new file mode 100644 index 000..312178d --- /dev/null +++ b/drivers/net/usb/huawei_cdc_ncm.c @@ -0,0 +1,230 @@ +/* huawei_cdc_ncm.c - handles Huawei devices using the CDC NCM protocol as + * transport layer. + * Copyright (C) 2013 Enrico Mioso mrkiko...@gmail.com + * + * + * ABSTRACT: + * This driver handles devices resembling the CDC NCM standard, but + * encapsulating another protocol inside it. An example are some Huawei 3G + * devices, exposing an embedded AT channel where you can set up the NCM + * connection. + * This code has been heavily inspired by the cdc_mbim.c driver, which is + * Copyright (c) 2012 Smith Micro Software, Inc. + * Copyright (c) 2012 Bjørn Mork bj...@mork.no + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + */ + +#include linux/module.h +#include linux/netdevice.h +#include linux/ethtool.h +#include linux/if_vlan.h +#include linux/ip.h +#include linux/mii.h +#include linux/usb.h +#include linux/usb/cdc.h +#include linux/usb/usbnet.h +#include linux/usb/cdc-wdm.h +#include linux/usb/cdc_ncm.h + +/* Driver data */ +struct huawei_cdc_ncm_state { + struct cdc_ncm_ctx *ctx; + atomic_t pmcount; + struct usb_driver *subdriver; + struct usb_interface *control; + struct usb_interface *data; +}; + +static int huawei_cdc_ncm_manage_power(struct usbnet *usbnet_dev, int on) +{ + struct huawei_cdc_ncm_state *drvstate = (void *)usbnet_dev-data; + int rv; + + if ((on atomic_add_return(1, drvstate-pmcount) == 1) || + (!on atomic_dec_and_test(drvstate-pmcount))) { + rv = usb_autopm_get_interface(usbnet_dev-intf); + usbnet_dev-intf-needs_remote_wakeup = on; + if (!rv) + usb_autopm_put_interface(usbnet_dev-intf); + } + return 0; +} + +static int huawei_cdc_ncm_wdm_manage_power(struct usb_interface *intf, + int status) +{ + struct usbnet *usbnet_dev = usb_get_intfdata(intf); + + /* can be called while disconnecting */ + if (!usbnet_dev) + return 0; + + return huawei_cdc_ncm_manage_power(usbnet_dev, status); +} + + +static int huawei_cdc_ncm_bind(struct usbnet *usbnet_dev, + struct usb_interface *intf) +{ + struct cdc_ncm_ctx *ctx; + struct usb_driver *subdriver = ERR_PTR(-ENODEV); + int ret = -ENODEV; + struct huawei_cdc_ncm_state *drvstate = (void *)usbnet_dev-data; + + /* altsetting should always be 1 for NCM devices - so we hard-coded +* it
[PATCH net-next v6 0/3] The huawei_cdc_ncm driver
Enrico has been kind enough to let me repost his driver with the changes requested by Oliver Neukum during the last review of this series. The changes I have made from Enricos original v5 series to this version are: v6: - fix to avoid corrupting drvstate-pmcount - fix error return value from huawei_cdc_ncm_suspend() - drop redundant testing for subdriver-suspend during resume - broke a few lines to keep within the 80 columns recommendation - rebased on top of current net-next Enrico's orginal introduction to the v5 series follows below. It explains the background much better than I can. Bjørn [quote Enrico Mioso] So this is a new, revised, edition of the huawei_cdc_ncm.c driver, which supports devices resembling the NCM standard, but using it also as a mean to encapsulate other protocols, as is the case for the Huawei E3131 and E3251 modem devices. Some precisations are needed however - and I encourage discussion on this: and that's why I'm sending this message with a broader CC. Merging those patches might change: - the way Modem Manager interacts with those devices - some regressions might be possible if there are some unknown firmware variants around (Franko?) First of all: I observed the behaviours of two devices. Huawei E3131: this device doesn't accept NDIS setup requests unless they're sent via the embedded AT channel exposed by this driver. So actually we gain funcionality in this case! The second case, is the Huawei E3251: which works with standard NCM driver, still exposing an AT embedded channel. Whith this patch set applied, you gain some funcionality, loosing the ability to catch standard NCM events for now. The device will work in both ways with no problems, but this has to be acknowledged and discussed. Might be we can develop this driver further to change this, when more devices are tested. We where thinking Huawei changed their interfaces on new devices - but probably this driver only works around a nice firmware bug present in E3131, which prevented the modem from being used in NDIS mode. I think committing this is definitely wortth-while, since it will allow for more Huawei devices to be used without serial connection. Some devices like the E3251 also, reports some status information only via the embedded AT channel, at least in my case. Note: I'm not subscribed to any list except the Modem Manager's one, so please CC me, thanks!! [/quote] Enrico Mioso (3): net: cdc_ncm: Export cdc_ncm_{tx,rx}_fixup functions for re-use net: huawei_cdc_ncm: Introduce the huawei_cdc_ncm driver net: cdc_ncm: remove non-standard NCM device IDs drivers/net/usb/Kconfig | 15 +++ drivers/net/usb/Makefile |1 + drivers/net/usb/cdc_ncm.c| 17 +-- drivers/net/usb/huawei_cdc_ncm.c | 230 ++ include/linux/usb/cdc_ncm.h |3 + 5 files changed, 253 insertions(+), 13 deletions(-) create mode 100644 drivers/net/usb/huawei_cdc_ncm.c -- 1.7.10.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 net-next v6 3/3] net: cdc_ncm: remove non-standard NCM device IDs
From: Enrico Mioso mrkiko...@gmail.com Remove device IDs of NCM-like (but not NCM-conformant) devices, that are handled by the huawwei_cdc_ncm driver now. Signed-off-by: Enrico Mioso mrkiko...@gmail.com Signed-off-by: Bjørn Mork bj...@mork.no --- drivers/net/usb/cdc_ncm.c | 11 --- 1 file changed, 11 deletions(-) diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c index 1763195..f74786a 100644 --- a/drivers/net/usb/cdc_ncm.c +++ b/drivers/net/usb/cdc_ncm.c @@ -1186,17 +1186,6 @@ static const struct usb_device_id cdc_devs[] = { .driver_info = (unsigned long)wwan_info, }, - /* Huawei NCM devices disguised as vendor specific */ - { USB_VENDOR_AND_INTERFACE_INFO(0x12d1, 0xff, 0x02, 0x16), - .driver_info = (unsigned long)wwan_info, - }, - { USB_VENDOR_AND_INTERFACE_INFO(0x12d1, 0xff, 0x02, 0x46), - .driver_info = (unsigned long)wwan_info, - }, - { USB_VENDOR_AND_INTERFACE_INFO(0x12d1, 0xff, 0x02, 0x76), - .driver_info = (unsigned long)wwan_info, - }, - /* Infineon(now Intel) HSPA Modem platform */ { USB_DEVICE_AND_INTERFACE_INFO(0x1519, 0x0443, USB_CLASS_COMM, -- 1.7.10.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 net-next v6 1/3] net: cdc_ncm: Export cdc_ncm_{tx,rx}_fixup functions for re-use
From: Enrico Mioso mrkiko...@gmail.com Some drivers implementing NCM-like protocols, may re-use those functions, as is the case in the huawei_cdc_ncm driver. Export them via EXPORT_SYMBOL_GPL, in accordance with how other functions have been exported. Signed-off-by: Enrico Mioso mrkiko...@gmail.com Signed-off-by: Bjørn Mork bj...@mork.no --- drivers/net/usb/cdc_ncm.c |6 -- include/linux/usb/cdc_ncm.h |3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c index 11c7033..1763195 100644 --- a/drivers/net/usb/cdc_ncm.c +++ b/drivers/net/usb/cdc_ncm.c @@ -830,7 +830,7 @@ static void cdc_ncm_txpath_bh(unsigned long param) } } -static struct sk_buff * +struct sk_buff * cdc_ncm_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) { struct sk_buff *skb_out; @@ -857,6 +857,7 @@ error: return NULL; } +EXPORT_SYMBOL_GPL(cdc_ncm_tx_fixup); /* verify NTB header and return offset of first NDP, or negative error */ int cdc_ncm_rx_verify_nth16(struct cdc_ncm_ctx *ctx, struct sk_buff *skb_in) @@ -943,7 +944,7 @@ error: } EXPORT_SYMBOL_GPL(cdc_ncm_rx_verify_ndp16); -static int cdc_ncm_rx_fixup(struct usbnet *dev, struct sk_buff *skb_in) +int cdc_ncm_rx_fixup(struct usbnet *dev, struct sk_buff *skb_in) { struct sk_buff *skb; struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev-data[0]; @@ -1019,6 +1020,7 @@ err_ndp: error: return 0; } +EXPORT_SYMBOL_GPL(cdc_ncm_rx_fixup); static void cdc_ncm_speed_change(struct usbnet *dev, diff --git a/include/linux/usb/cdc_ncm.h b/include/linux/usb/cdc_ncm.h index 2300f74..c3fa807 100644 --- a/include/linux/usb/cdc_ncm.h +++ b/include/linux/usb/cdc_ncm.h @@ -125,5 +125,8 @@ void cdc_ncm_unbind(struct usbnet *dev, struct usb_interface *intf); struct sk_buff *cdc_ncm_fill_tx_frame(struct usbnet *dev, struct sk_buff *skb, __le32 sign); int cdc_ncm_rx_verify_nth16(struct cdc_ncm_ctx *ctx, struct sk_buff *skb_in); int cdc_ncm_rx_verify_ndp16(struct sk_buff *skb_in, int ndpoffset); +struct sk_buff * +cdc_ncm_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags); +int cdc_ncm_rx_fixup(struct usbnet *dev, struct sk_buff *skb_in); #endif /* __LINUX_USB_CDC_NCM_H */ -- 1.7.10.4 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH net-next 17/24] net: cdc_ncm: use netif_* and dev_* instead of pr_*
Joe Perches j...@perches.com writes: You did most all the multi-line statement alignment perfectly but missed a couple. Damn! OK, that will teach me to do checkpatch --strict before submitting. Maybe in a follow-on patch. Yes, I'll fix this when I get around to the next series for this driver. Thanks. Bjørn diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c [] @@ -1031,17 +1035,13 @@ cdc_ncm_speed_change(struct usbnet *dev, * device speed. Do print it instead. */ if ((tx_speed 100) (rx_speed 100)) { -printk(KERN_INFO KBUILD_MODNAME - : %s: %u mbit/s downlink - %u mbit/s uplink\n, - dev-net-name, +netif_info(dev, link, dev-net, + %u mbit/s downlink %u mbit/s uplink\n, (unsigned int)(rx_speed / 100U), (unsigned int)(tx_speed / 100U)); } else { -printk(KERN_INFO KBUILD_MODNAME - : %s: %u kbit/s downlink - %u kbit/s uplink\n, - dev-net-name, +netif_info(dev, link, dev-net, + %u kbit/s downlink %u kbit/s uplink\n, (unsigned int)(rx_speed / 1000U), (unsigned int)(tx_speed / 1000U)); } -- To unsubscribe from this list: send the line unsubscribe 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/3] USB: phy: Add OTG FSM configuration option
This patch removes dependency on Freescale USB UTG Transceiver driver and makes OTG FSM implementation selectable. Signed-off-by: Anton Tikhomirov av.tikhomi...@samsung.com --- drivers/usb/phy/Kconfig | 10 +- drivers/usb/phy/Makefile |4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig index d5589f9..9d5eaba 100644 --- a/drivers/usb/phy/Kconfig +++ b/drivers/usb/phy/Kconfig @@ -6,6 +6,14 @@ menu USB Physical Layer drivers config USB_PHY def_bool n +config USB_OTG_FSM + bool USB 2.0 OTG FSM implementation + select USB_OTG + select USB_PHY + help + Implements OTG Final State Machine as specified in On-The-Go + and Embedded Host Supplement to the USB Revision 2.0 Specification. + # # USB Transceiver Drivers # @@ -20,7 +28,7 @@ config AB8500_USB config FSL_USB2_OTG bool Freescale USB OTG Transceiver Driver - depends on USB_EHCI_FSL USB_FSL_USB2 PM_RUNTIME + depends on USB_EHCI_FSL USB_FSL_USB2 USB_OTG_FSM PM_RUNTIME select USB_OTG select USB_PHY help diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile index 2135e85..df274a1 100644 --- a/drivers/usb/phy/Makefile +++ b/drivers/usb/phy/Makefile @@ -3,12 +3,12 @@ # obj-$(CONFIG_USB_PHY) += phy.o obj-$(CONFIG_OF) += of.o +obj-$(CONFIG_USB_OTG_FSM) += phy-fsm-usb.o # transceiver drivers, keep the list sorted obj-$(CONFIG_AB8500_USB) += phy-ab8500-usb.o -phy-fsl-usb2-objs := phy-fsl-usb.o phy-fsm-usb.o -obj-$(CONFIG_FSL_USB2_OTG) += phy-fsl-usb2.o +obj-$(CONFIG_FSL_USB2_OTG) += phy-fsl-usb.o obj-$(CONFIG_ISP1301_OMAP) += phy-isp1301-omap.o obj-$(CONFIG_MV_U3D_PHY) += phy-mv-u3d-usb.o obj-$(CONFIG_NOP_USB_XCEIV)+= phy-generic.o -- 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 1/3] USB: phy: replace spinlock with mutex in OTG FSM
OTG Final State Machine calls functions which may sleep. For example, start_gadget callback implementation can use usb_gadget_vbus_connect(), whose context: can sleep. If so, mutex should be used instead of spinlock. Signed-off-by: Anton Tikhomirov av.tikhomi...@samsung.com --- drivers/usb/phy/phy-fsl-usb.c |7 +++ drivers/usb/phy/phy-fsm-usb.c |7 +++ drivers/usb/phy/phy-fsm-usb.h |2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c index 7f3c73b..62d5af2 100644 --- a/drivers/usb/phy/phy-fsl-usb.c +++ b/drivers/usb/phy/phy-fsl-usb.c @@ -848,7 +848,7 @@ static int fsl_otg_conf(struct platform_device *pdev) pr_info(Couldn't init OTG timers\n); goto err; } - spin_lock_init(fsl_otg_tc-fsm.lock); + mutex_init(fsl_otg_tc-fsm.lock); /* Set OTG state machine operations */ fsl_otg_tc-fsm.ops = fsl_otg_ops; @@ -1017,10 +1017,9 @@ static int show_fsl_usb2_otg_state(struct device *dev, struct otg_fsm *fsm = fsl_otg_dev-fsm; char *next = buf; unsigned size = PAGE_SIZE; - unsigned long flags; int t; - spin_lock_irqsave(fsm-lock, flags); + mutex_lock(fsm-lock); /* basic driver infomation */ t = scnprintf(next, size, @@ -1088,7 +1087,7 @@ static int show_fsl_usb2_otg_state(struct device *dev, size -= t; next += t; - spin_unlock_irqrestore(fsm-lock, flags); + mutex_unlock(fsm-lock); return PAGE_SIZE - size; } diff --git a/drivers/usb/phy/phy-fsm-usb.c b/drivers/usb/phy/phy-fsm-usb.c index 329c2d2..2817b04 100644 --- a/drivers/usb/phy/phy-fsm-usb.c +++ b/drivers/usb/phy/phy-fsm-usb.c @@ -23,7 +23,7 @@ #include linux/kernel.h #include linux/types.h -#include linux/spinlock.h +#include linux/mutex.h #include linux/delay.h #include linux/usb.h #include linux/usb/gadget.h @@ -245,9 +245,8 @@ int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state) int otg_statemachine(struct otg_fsm *fsm) { enum usb_otg_state state; - unsigned long flags; - spin_lock_irqsave(fsm-lock, flags); + mutex_lock(fsm-lock); state = fsm-otg-phy-state; state_changed = 0; @@ -359,7 +358,7 @@ int otg_statemachine(struct otg_fsm *fsm) default: break; } - spin_unlock_irqrestore(fsm-lock, flags); + mutex_lock(fsm-lock); VDBG(quit statemachine, changed = %d\n, state_changed); return state_changed; diff --git a/drivers/usb/phy/phy-fsm-usb.h b/drivers/usb/phy/phy-fsm-usb.h index 7441b46..12ece58 100644 --- a/drivers/usb/phy/phy-fsm-usb.h +++ b/drivers/usb/phy/phy-fsm-usb.h @@ -110,7 +110,7 @@ struct otg_fsm { /* Current usb protocol used: 0:undefine; 1:host; 2:client */ int protocol; - spinlock_t lock; + struct mutex lock; }; struct otg_fsm_ops { -- 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 2/3] USB: phy: move OTG FSM header
Other USB drivers may want to use OTG final state machine implementation, so make this header available for them. Signed-off-by: Anton Tikhomirov av.tikhomi...@samsung.com --- drivers/usb/phy/phy-fsl-usb.h |1 - drivers/usb/phy/phy-fsm-usb.c |2 - drivers/usb/phy/phy-fsm-usb.h | 236 - include/linux/usb/otg.h |1 + include/linux/usb/otg_fsm.h | 236 + 5 files changed, 237 insertions(+), 239 deletions(-) delete mode 100644 drivers/usb/phy/phy-fsm-usb.h create mode 100644 include/linux/usb/otg_fsm.h diff --git a/drivers/usb/phy/phy-fsl-usb.h b/drivers/usb/phy/phy-fsl-usb.h index 7365170..b8589c5 100644 --- a/drivers/usb/phy/phy-fsl-usb.h +++ b/drivers/usb/phy/phy-fsl-usb.h @@ -15,7 +15,6 @@ * 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include phy-fsm-usb.h #include linux/usb/otg.h #include linux/ioctl.h diff --git a/drivers/usb/phy/phy-fsm-usb.c b/drivers/usb/phy/phy-fsm-usb.c index 2817b04..e72dbee 100644 --- a/drivers/usb/phy/phy-fsm-usb.c +++ b/drivers/usb/phy/phy-fsm-usb.c @@ -29,8 +29,6 @@ #include linux/usb/gadget.h #include linux/usb/otg.h -#include phy-fsm-usb.h - /* Change USB protocol when there is a protocol change */ static int otg_set_protocol(struct otg_fsm *fsm, int protocol) { diff --git a/drivers/usb/phy/phy-fsm-usb.h b/drivers/usb/phy/phy-fsm-usb.h deleted file mode 100644 index 12ece58..000 --- a/drivers/usb/phy/phy-fsm-usb.h +++ /dev/null @@ -1,236 +0,0 @@ -/* Copyright (C) 2007,2008 Freescale Semiconductor, Inc. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#undef VERBOSE - -#ifdef VERBOSE -#define VDBG(fmt, args...) pr_debug([%s] fmt , \ -__func__, ## args) -#else -#define VDBG(stuff...) do {} while (0) -#endif - -#ifdef VERBOSE -#define MPC_LOC printk(Current Location [%s]:[%d]\n, __FILE__, __LINE__) -#else -#define MPC_LOC do {} while (0) -#endif - -#define PROTO_UNDEF(0) -#define PROTO_HOST (1) -#define PROTO_GADGET (2) - -enum otg_fsm_timer { - /* Standard OTG timers */ - A_WAIT_VRISE, - A_WAIT_VFALL, - A_WAIT_BCON, - A_AIDL_BDIS, - B_ASE0_BRST, - A_BIDL_ADIS, - - /* Auxiliary timers */ - B_SE0_SRP, - B_SRP_FAIL, - A_WAIT_ENUM, - - NUM_OTG_FSM_TIMERS, -}; - -/* OTG state machine according to the OTG spec */ -struct otg_fsm { - /* Input */ - int id; - int adp_change; - int power_up; - int test_device; - int a_bus_drop; - int a_bus_req; - int a_srp_det; - int a_vbus_vld; - int b_conn; - int a_bus_resume; - int a_bus_suspend; - int a_conn; - int b_bus_req; - int b_se0_srp; - int b_ssend_srp; - int b_sess_vld; - /* Auxilary inputs */ - int a_sess_vld; - int b_bus_resume; - int b_bus_suspend; - - /* Output */ - int data_pulse; - int drv_vbus; - int loc_conn; - int loc_sof; - int adp_prb; - int adp_sns; - - /* Internal variables */ - int a_set_b_hnp_en; - int b_srp_done; - int b_hnp_enable; - int a_clr_err; - - /* Informative variables */ - int a_bus_drop_inf; - int a_bus_req_inf; - int a_clr_err_inf; - int b_bus_req_inf; - /* Auxilary informative variables */ - int a_suspend_req_inf; - - /* Timeout indicator for timers */ - int a_wait_vrise_tmout; - int a_wait_vfall_tmout; - int a_wait_bcon_tmout; - int a_aidl_bdis_tmout; - int b_ase0_brst_tmout; - int a_bidl_adis_tmout; - - struct otg_fsm_ops *ops; - struct usb_otg *otg; - - /* Current usb protocol used: 0:undefine; 1:host; 2:client */ - int protocol; - struct mutex lock; -}; - -struct otg_fsm_ops { - void(*chrg_vbus)(struct otg_fsm *fsm, int on); - void(*drv_vbus)(struct otg_fsm *fsm, int on); - void(*loc_conn)(struct otg_fsm *fsm, int on); - void(*loc_sof)(struct otg_fsm *fsm, int on); - void(*start_pulse)(struct otg_fsm *fsm); - void(*start_adp_prb)(struct otg_fsm *fsm); - void(*start_adp_sns)(struct otg_fsm *fsm); - void
Re: [PATCH V5 net-next 2/3] net: huawei_cdc_ncm: Introduce the huawei_cdc_ncm driver
On Fri, 2013-11-01 at 12:35 +0100, Bjørn Mork wrote: So I believe we should do the update unconditionally, and but skip usb_autopm_put_interface if the get failed. Accordingly, these functions should always return 0 (not that there is anything currently checking the return anyway). I'll prepare patches for cdc-wdm, qmi_wwan and cdc_mbim. Good plan. Regards Oliver -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] USB: pl2303: fixed handling of CS5 setting
On Sun, Nov 03, 2013 at 11:09:50PM +0100, Colin Leitner wrote: This patch fixes the CS5 setting on the PL2303 USB-to-serial devices. CS5 has a value of 0 and the CSIZE setting has been skipped altogether by the enclosing if. Tested on 3.11.6 and the scope shows the correct output after the fix has been applied. Tagged to be added to stable, because it fixes a user visible driver bug and is simple enough to backport easily. Cc: sta...@vger.kernel.org Signed-off-by: Colin Leitner colin.leit...@gmail.com Looks good now, but I'm afraid it doesn't apply to v3.12. There were some last minute reverts in v3.12 which could possibly explain that. Care to rebase against v3.12 and send a v2 (v3?)? Thanks, Johan --- drivers/usb/serial/pl2303.c | 30 ++ 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index bedf8e4..fd86357 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c @@ -522,23 +522,21 @@ static void pl2303_set_termios(struct tty_struct *tty, 0, 0, buf, 7, 100); dev_dbg(port-dev, 0xa1:0x21:0:0 %d - %7ph\n, i, buf); - if (C_CSIZE(tty)) { - switch (C_CSIZE(tty)) { - case CS5: - buf[6] = 5; - break; - case CS6: - buf[6] = 6; - break; - case CS7: - buf[6] = 7; - break; - default: - case CS8: - buf[6] = 8; - } - dev_dbg(port-dev, data bits = %d\n, buf[6]); + switch (C_CSIZE(tty)) { + case CS5: + buf[6] = 5; + break; + case CS6: + buf[6] = 6; + break; + case CS7: + buf[6] = 7; + break; + default: + case CS8: + buf[6] = 8; } + dev_dbg(port-dev, data bits = %d\n, buf[6]); /* For reference: buf[0]:buf[3] baud rate value */ pl2303_encode_baudrate(tty, port, spriv-type, buf); -- 1.7.10.4 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH RFC 1/4] phy: Add new Exynos5 USB 3.0 PHY driver
Hi Kishon, From: Kishon Vijay Abraham I [mailto:kis...@ti.com] Sent: Monday, November 04, 2013 7:55 AM Hi Vivek, On Thursday 31 October 2013 01:15 PM, Vivek Gautam wrote: Add a new driver for the USB 3.0 PHY on Exynos5 series of SoCs. The new driver uses the generic PHY framework and will interact with DWC3 controller present on Exynos5 series of SoCs. In Exynos, you have a single IP that supports both USB3 and USB2 PHY right? I think that needs to be mentioned here. As far as I know the IP is different. Do you have separate registers that should be used for initializing/powerin_on/powering_off etc.. for usb2 phy and usb3 phy? If so, then you should model this driver as a single driver that supports two PHYs similar to what Sylwester has done before? Best wishes, Kamil Cheers Kishon Signed-off-by: Vivek Gautam gautam.vi...@samsung.com --- .../devicetree/bindings/phy/samsung-phy.txt| 20 + drivers/phy/Kconfig|7 + drivers/phy/Makefile |1 + drivers/phy/phy-exynos5-usb3.c | 562 4 files changed, 590 insertions(+), 0 deletions(-) create mode 100644 drivers/phy/phy-exynos5-usb3.c diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt index c0fccaa..9b5c111 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -20,3 +20,23 @@ Required properties: - compatible : should be samsung,exynos5250-dp-video-phy; - reg : offset and length of the Display Port PHY register set; - #phy-cells : from the generic PHY bindings, must be 0; + +Samsung Exynos5 SoC seiries USB 3.0 PHY controller +-- + +Required properties: +- compatible : + should be samsung,exynos5250-usb3phy for exynos5250 SoC + should be samsung,exynos5420-usb3phy for exynos5420 SoC +- reg : Register offset and length array + - first field corresponds to USB 3.0 PHY register set; + - second field corresponds to PHY power isolation register + present in PMU; +- clocks: Clock IDs array as required by the controller +- clock-names: names of clocks correseponding to IDs in the clock property; + Required clocks: + - first clock is main PHY clock (same as USB 3.0 controller IP clock) + - second clock is reference clock (usually crystal clock) + optional clock: + - third clock is special clock used by PHY for operation +- #phy-cells : from the generic PHY bindings, must be 0; diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index a344f3d..9a100c6 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -51,4 +51,11 @@ config PHY_EXYNOS_DP_VIDEO help Support for Display Port PHY found on Samsung EXYNOS SoCs. +config PHY_EXYNOS5_USB3 + tristate Exynos5 SoC series USB 3.0 PHY driver + depends on ARCH_EXYNOS5 + select GENERIC_PHY + help + Enable USB 3.0 PHY support for Exynos 5 SoC series + endmenu diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index d0caae9..9c06a61 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -7,3 +7,4 @@ obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO) += phy-exynos-dp- video.o obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO) += phy-exynos-mipi-video.o obj-$(CONFIG_OMAP_USB2) += phy-omap-usb2.o obj-$(CONFIG_TWL4030_USB) += phy-twl4030-usb.o +obj-$(CONFIG_PHY_EXYNOS5_USB3) += phy-exynos5-usb3.o diff --git a/drivers/phy/phy-exynos5-usb3.c b/drivers/phy/phy-exynos5-usb3.c new file mode 100644 index 000..b9a2674 --- /dev/null +++ b/drivers/phy/phy-exynos5-usb3.c @@ -0,0 +1,562 @@ +/* + * Samsung EXYNOS5 SoC series USB 3.0 PHY driver + * + * Copyright (C) 2013 Samsung Electronics Co., Ltd. + * Author: Vivek Gautam gautam.vi...@samsung.com + * + * This program is free software; you can redistribute it and/or +modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include linux/clk.h +#include linux/delay.h +#include linux/io.h +#include linux/kernel.h +#include linux/module.h +#include linux/of.h +#include linux/of_address.h +#include linux/phy/phy.h +#include linux/platform_device.h +#include linux/mutex.h + +/* Exynos USB PHY registers */ +#define EXYNOS5_FSEL_9MHZ6 0x0 +#define EXYNOS5_FSEL_10MHZ 0x1 +#define EXYNOS5_FSEL_12MHZ 0x2 +#define EXYNOS5_FSEL_19MHZ20x3 +#define EXYNOS5_FSEL_20MHZ 0x4 +#define EXYNOS5_FSEL_24MHZ 0x5 +#define EXYNOS5_FSEL_50MHZ 0x7 + +/* EXYNOS5: USB 3.0 DRD PHY registers */ +#define EXYNOS5_DRD_LINKSYSTEM
[PATCH] xhci: Allocate the td array and urb_priv together.
Replace the array of pointers to transfer descriptors with the transfer descriptors themselves. This saves a kzalloc() call on every transfer and some memory indirections. The only possible downside is for isochronous tranfers with 64 td when the allocate is 8+4096 bytes (on 64bit systems) so requires an additional page. --- drivers/usb/host/xhci-mem.c | 4 +--- drivers/usb/host/xhci-ring.c | 22 ++ drivers/usb/host/xhci.c | 24 ++-- drivers/usb/host/xhci.h | 2 +- 4 files changed, 18 insertions(+), 34 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 79cdcc2..9b5d1c3 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -1675,10 +1675,8 @@ struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci, void xhci_urb_free_priv(struct xhci_hcd *xhci, struct urb_priv *urb_priv) { - if (urb_priv) { - kfree(urb_priv-td[0]); + if (urb_priv) kfree(urb_priv); - } } void xhci_free_command(struct xhci_hcd *xhci, diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index e38abc2..d3f4a9a 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -3007,7 +3007,7 @@ static int prepare_transfer(struct xhci_hcd *xhci, return ret; urb_priv = urb-hcpriv; - td = urb_priv-td[td_index]; + td = urb_priv-td[td_index]; INIT_LIST_HEAD(td-td_list); INIT_LIST_HEAD(td-cancelled_td_list); @@ -3024,8 +3024,6 @@ static int prepare_transfer(struct xhci_hcd *xhci, td-start_seg = ep_ring-enq_seg; td-first_trb = ep_ring-enqueue; - urb_priv-td[td_index] = td; - return 0; } @@ -3216,7 +3214,7 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, return trb_buff_len; urb_priv = urb-hcpriv; - td = urb_priv-td[0]; + td = urb_priv-td[0]; /* * Don't give the first TRB to the hardware (by toggling the cycle bit) @@ -3387,7 +3385,7 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, return ret; urb_priv = urb-hcpriv; - td = urb_priv-td[0]; + td = urb_priv-td[0]; /* * Don't give the first TRB to the hardware (by toggling the cycle bit) @@ -3517,7 +3515,7 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, return ret; urb_priv = urb-hcpriv; - td = urb_priv-td[0]; + td = urb_priv-td[0]; /* * Don't give the first TRB to the hardware (by toggling the cycle bit) @@ -3729,7 +3727,7 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags, goto cleanup; } - td = urb_priv-td[i]; + td = urb_priv-td[i]; for (j = 0; j trbs_per_td; j++) { u32 remainder = 0; field = 0; @@ -3829,20 +3827,20 @@ cleanup: /* Clean up a partially enqueued isoc transfer. */ for (i--; i = 0; i--) - list_del_init(urb_priv-td[i]-td_list); + list_del_init(urb_priv-td[i].td_list); /* Use the first TD as a temporary variable to turn the TDs we've queued * into No-ops with a software-owned cycle bit. That way the hardware * won't accidentally start executing bogus TDs when we partially * overwrite them. td-first_trb and td-start_seg are already set. */ - urb_priv-td[0]-last_trb = ep_ring-enqueue; + urb_priv-td[0].last_trb = ep_ring-enqueue; /* Every TRB except the first last will have its cycle bit flipped. */ - td_to_noop(xhci, ep_ring, urb_priv-td[0], true); + td_to_noop(xhci, ep_ring, urb_priv-td[0], true); /* Reset the ring enqueue back to the first TRB and its cycle bit. */ - ep_ring-enqueue = urb_priv-td[0]-first_trb; - ep_ring-enq_seg = urb_priv-td[0]-start_seg; + ep_ring-enqueue = urb_priv-td[0].first_trb; + ep_ring-enq_seg = urb_priv-td[0].start_seg; ep_ring-cycle_state = start_cycle; ep_ring-num_trbs_free = ep_ring-num_trbs_free_temp; usb_hcd_unlink_urb_from_ep(bus_to_hcd(urb-dev-bus), urb); diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 6e0d886..0969f74 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -1248,12 +1248,11 @@ static int xhci_check_maxpacket(struct xhci_hcd *xhci, unsigned int slot_id, int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags) { struct xhci_hcd *xhci = hcd_to_xhci(hcd); - struct xhci_td *buffer; unsigned long flags; int ret = 0; unsigned int slot_id, ep_index; struct urb_priv *urb_priv; - int size, i; + int size; if (!urb || xhci_check_args(hcd, urb-dev, urb-ep,
[PATCH] xhci: Use TRB_CYCLE instead of the constant 0x1
In many cases the constant 1 is used for values that eventually get written to the hardware ring. Replace all of these with the symbolic constant TRB_CYCLE. This makes it clear that the ring-cycle_state value is used when writing to the actual ring itself. Always use ^= TRB_CYCLE to invert the bit. --- drivers/usb/host/xhci-mem.c | 10 +- drivers/usb/host/xhci-ring.c | 16 drivers/usb/host/xhci.c | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 9b5d1c3..5b2d835 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -597,7 +597,7 @@ struct xhci_stream_info *xhci_alloc_stream_info(struct xhci_hcd *xhci, */ for (cur_stream = 1; cur_stream num_streams; cur_stream++) { stream_info-stream_rings[cur_stream] = - xhci_ring_alloc(xhci, 2, 1, TYPE_STREAM, mem_flags); + xhci_ring_alloc(xhci, 2, TRB_CYCLE, TYPE_STREAM, mem_flags); cur_ring = stream_info-stream_rings[cur_stream]; if (!cur_ring) goto cleanup_rings; @@ -906,7 +906,7 @@ int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id, } /* Allocate endpoint 0 ring */ - dev-eps[0].ring = xhci_ring_alloc(xhci, 2, 1, TYPE_CTRL, flags); + dev-eps[0].ring = xhci_ring_alloc(xhci, 2, TRB_CYCLE, TYPE_CTRL, flags); if (!dev-eps[0].ring) goto fail; @@ -1326,7 +1326,7 @@ int xhci_endpoint_init(struct xhci_hcd *xhci, type = usb_endpoint_type(ep-desc); /* Set up the endpoint ring */ virt_dev-eps[ep_index].new_ring = - xhci_ring_alloc(xhci, 2, 1, type, mem_flags); + xhci_ring_alloc(xhci, 2, TRB_CYCLE, type, mem_flags); if (!virt_dev-eps[ep_index].new_ring) { /* Attempt to use the ring cache */ if (virt_dev-num_rings_cached == 0) @@ -2311,7 +2311,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) goto fail; /* Set up the command ring to have one segments for now. */ - xhci-cmd_ring = xhci_ring_alloc(xhci, 1, 1, TYPE_COMMAND, flags); + xhci-cmd_ring = xhci_ring_alloc(xhci, 1, TRB_CYCLE, TYPE_COMMAND, flags); if (!xhci-cmd_ring) goto fail; xhci_dbg_trace(xhci, trace_xhci_dbg_init, @@ -2355,7 +2355,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) * the event ring segment table (ERST). Section 4.9.3. */ xhci_dbg_trace(xhci, trace_xhci_dbg_init, // Allocating event ring); - xhci-event_ring = xhci_ring_alloc(xhci, ERST_NUM_SEGS, 1, TYPE_EVENT, + xhci-event_ring = xhci_ring_alloc(xhci, ERST_NUM_SEGS, TRB_CYCLE, TYPE_EVENT, flags); if (!xhci-event_ring) goto fail; diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index d3f4a9a..408978b 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -178,7 +178,7 @@ static void inc_deq(struct xhci_hcd *xhci, struct xhci_ring *ring) if (ring-type == TYPE_EVENT last_trb_on_last_seg(xhci, ring, ring-deq_seg, ring-dequeue)) { - ring-cycle_state = (ring-cycle_state ? 0 : 1); + ring-cycle_state ^= TRB_CYCLE; } ring-deq_seg = ring-deq_seg-next; ring-dequeue = ring-deq_seg-trbs; @@ -257,7 +257,7 @@ static void inc_enq(struct xhci_hcd *xhci, struct xhci_ring *ring, /* Toggle the cycle bit after the last ring segment. */ if (last_trb_on_last_seg(xhci, ring, ring-enq_seg, next)) { - ring-cycle_state = (ring-cycle_state ? 0 : 1); + ring-cycle_state ^= TRB_CYCLE; } } ring-enq_seg = ring-enq_seg-next; @@ -475,7 +475,7 @@ static struct xhci_segment *find_trb_seg( cur_seg-trbs[TRBS_PER_SEGMENT - 1] trb) { generic_trb = cur_seg-trbs[TRBS_PER_SEGMENT - 1].generic; if (generic_trb-field[3] cpu_to_le32(LINK_TOGGLE)) - *cycle_state ^= 0x1; + *cycle_state ^= TRB_CYCLE; cur_seg = cur_seg-next; if (cur_seg == start_seg) /* Looped over the entire list. Oops! */ @@ -2967,7 +2967,7 @@ static int prepare_ring(struct xhci_hcd *xhci, struct xhci_ring *ep_ring, /* Toggle the cycle bit after the last ring segment. */ if (last_trb_on_last_seg(xhci, ring, ring-enq_seg, next)) { -
[PATCH 1/4] usb/gadget: composite: redirect setup requests
If there are setup requests not directed to an endpont or an interface, current config's setup() has been attempted so far. This patch, in case the above fails, adds code which tries the setup() of configuration's function if there is only one function in the configuration. This behavior is required to provide equivalent of gadget zero with configfs. The gadget zero has a config driver for sourcesink, but all it does is delegating the request to the function proper. So when the equivalent gadget is set up with configfs it needs to handle requests directed to config driver, but with configfs it is not possible to specify config drivers. Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- drivers/usb/gadget/composite.c | 17 - 1 files changed, 16 insertions(+), 1 deletions(-) diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index d4f0f33..287c63d 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -1451,8 +1451,23 @@ unknown: struct usb_configuration*c; c = cdev-config; - if (c c-setup) + if (!c) + goto done; + + /* try current config's setup */ + if (c-setup) { value = c-setup(c, ctrl); + goto done; + } + + /* try the only function in the current config */ + if (!c-functions || c-functions == c-functions.next + || c-functions.next != c-functions.prev) + goto done; + f = list_entry(cdev-config-functions.next, + struct usb_function, list); + if (f f-setup) + value = f-setup(f, ctrl); } goto done; -- 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 3/4] usb/gadget: f_loopback: add configfs support
Add support for using the loopback USB function in gadgets composed with configfs. Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- .../ABI/testing/configfs-usb-gadget-loopback |8 ++ drivers/usb/gadget/Kconfig | 12 ++ drivers/usb/gadget/f_loopback.c| 132 drivers/usb/gadget/g_zero.h| 12 ++ drivers/usb/gadget/zero.c |4 +- 5 files changed, 166 insertions(+), 2 deletions(-) create mode 100644 Documentation/ABI/testing/configfs-usb-gadget-loopback diff --git a/Documentation/ABI/testing/configfs-usb-gadget-loopback b/Documentation/ABI/testing/configfs-usb-gadget-loopback new file mode 100644 index 000..852b236 --- /dev/null +++ b/Documentation/ABI/testing/configfs-usb-gadget-loopback @@ -0,0 +1,8 @@ +What: /config/usb-gadget/gadget/functions/Loopback.name +Date: Nov 2013 +KenelVersion: 3.13 +Description: + The attributes: + + qlen- depth of loopback queue + bulk_buflen - buffer length diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 79617d4..dadbffb 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -700,6 +700,18 @@ config USB_CONFIGFS_F_FS implemented in kernel space (for instance Ethernet, serial or mass storage) and other are implemented in user space. +config USB_CONFIGFS_F_LB + boolean Loopback function (for testing) + depends on USB_CONFIGFS + select USB_F_SS_LB + help + It loops back a configurable number of transfers. + It also implements control requests, for chapter 9 conformance. + Make this be the first driver you try using on top of any new + USB peripheral controller driver. Then you can use host-side + test software, like the usbtest driver, to put your hardware + and its driver through a basic set of functional tests. + config USB_ZERO tristate Gadget Zero (DEVELOPMENT) select USB_LIBCOMPOSITE diff --git a/drivers/usb/gadget/f_loopback.c b/drivers/usb/gadget/f_loopback.c index b790653..c35bb40 100644 --- a/drivers/usb/gadget/f_loopback.c +++ b/drivers/usb/gadget/f_loopback.c @@ -231,6 +231,14 @@ autoconf_fail: static void lb_free_func(struct usb_function *f) { + struct f_lb_opts *opts; + + opts = container_of(f-fi, struct f_lb_opts, func_inst); + + mutex_lock(opts-lock); + opts-refcnt--; + mutex_unlock(opts-lock); + usb_free_all_descriptors(f); kfree(func_to_loop(f)); } @@ -386,6 +394,11 @@ static struct usb_function *loopback_alloc(struct usb_function_instance *fi) return ERR_PTR(-ENOMEM); lb_opts = container_of(fi, struct f_lb_opts, func_inst); + + mutex_lock(lb_opts-lock); + lb_opts-refcnt++; + mutex_unlock(lb_opts-lock); + buflen = lb_opts-bulk_buflen; qlen = lb_opts-qlen; if (!qlen) @@ -402,6 +415,118 @@ static struct usb_function *loopback_alloc(struct usb_function_instance *fi) return loop-function; } +static inline struct f_lb_opts *to_f_lb_opts(struct config_item *item) +{ + return container_of(to_config_group(item), struct f_lb_opts, + func_inst.group); +} + +CONFIGFS_ATTR_STRUCT(f_lb_opts); +CONFIGFS_ATTR_OPS(f_lb_opts); + +static void lb_attr_release(struct config_item *item) +{ + struct f_lb_opts *lb_opts = to_f_lb_opts(item); + + usb_put_function_instance(lb_opts-func_inst); +} + +static struct configfs_item_operations lb_item_ops = { + .release= lb_attr_release, + .show_attribute = f_lb_opts_attr_show, + .store_attribute= f_lb_opts_attr_store, +}; + +static ssize_t f_lb_opts_qlen_show(struct f_lb_opts *opts, char *page) +{ + int result; + + mutex_lock(opts-lock); + result = sprintf(page, %d, opts-qlen); + mutex_unlock(opts-lock); + + return result; +} + +static ssize_t f_lb_opts_qlen_store(struct f_lb_opts *opts, + const char *page, size_t len) +{ + int ret; + u32 num; + + mutex_lock(opts-lock); + if (opts-refcnt) { + ret = -EBUSY; + goto end; + } + + ret = kstrtou32(page, 0, num); + if (ret) + goto end; + + opts-qlen = num; + ret = len; +end: + mutex_unlock(opts-lock); + return ret; +} + +static struct f_lb_opts_attribute f_lb_opts_qlen = + __CONFIGFS_ATTR(qlen, S_IRUGO | S_IWUSR, + f_lb_opts_qlen_show, + f_lb_opts_qlen_store); + +static ssize_t f_lb_opts_bulk_buflen_show(struct f_lb_opts *opts, char *page) +{ + int result; + + mutex_lock(opts-lock); + result = sprintf(page,
[PATCH 2/4] usb/gadget: factor out alloc_ep_req
alloc_ep_req() is a function repeated in several modules. Make a common implementation and use it. Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- drivers/usb/gadget/Makefile |2 +- drivers/usb/gadget/f_hid.c| 18 +- drivers/usb/gadget/f_loopback.c |8 +++- drivers/usb/gadget/f_midi.c | 22 +++--- drivers/usb/gadget/f_sourcesink.c | 23 +-- drivers/usb/gadget/g_zero.h |1 - drivers/usb/gadget/u_f.c | 32 drivers/usb/gadget/u_f.h | 26 ++ 8 files changed, 83 insertions(+), 49 deletions(-) create mode 100644 drivers/usb/gadget/u_f.c create mode 100644 drivers/usb/gadget/u_f.h diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile index 6bb1155..6cccdfe 100644 --- a/drivers/usb/gadget/Makefile +++ b/drivers/usb/gadget/Makefile @@ -7,7 +7,7 @@ ccflags-$(CONFIG_USB_GADGET_VERBOSE)+= -DVERBOSE_DEBUG obj-$(CONFIG_USB_GADGET) += udc-core.o obj-$(CONFIG_USB_LIBCOMPOSITE) += libcomposite.o libcomposite-y := usbstring.o config.o epautoconf.o -libcomposite-y += composite.o functions.o configfs.o +libcomposite-y += composite.o functions.o configfs.o u_f.o obj-$(CONFIG_USB_DUMMY_HCD)+= dummy_hcd.o obj-$(CONFIG_USB_NET2272) += net2272.o obj-$(CONFIG_USB_NET2280) += net2280.o diff --git a/drivers/usb/gadget/f_hid.c b/drivers/usb/gadget/f_hid.c index 6e69a8e..a95290a 100644 --- a/drivers/usb/gadget/f_hid.c +++ b/drivers/usb/gadget/f_hid.c @@ -20,6 +20,8 @@ #include linux/sched.h #include linux/usb/g_hid.h +#include u_f.h + static int major, minors; static struct class *hidg_class; @@ -334,20 +336,10 @@ static int f_hidg_open(struct inode *inode, struct file *fd) /*-*/ /*usb_function */ -static struct usb_request *hidg_alloc_ep_req(struct usb_ep *ep, unsigned length) +static inline struct usb_request *hidg_alloc_ep_req(struct usb_ep *ep, + unsigned length) { - struct usb_request *req; - - req = usb_ep_alloc_request(ep, GFP_ATOMIC); - if (req) { - req-length = length; - req-buf = kmalloc(length, GFP_ATOMIC); - if (!req-buf) { - usb_ep_free_request(ep, req); - req = NULL; - } - } - return req; + return alloc_ep_req(ep, length, length); } static void hidg_set_report_complete(struct usb_ep *ep, struct usb_request *req) diff --git a/drivers/usb/gadget/f_loopback.c b/drivers/usb/gadget/f_loopback.c index 4a3873a..b790653 100644 --- a/drivers/usb/gadget/f_loopback.c +++ b/drivers/usb/gadget/f_loopback.c @@ -20,6 +20,7 @@ #include linux/usb/composite.h #include g_zero.h +#include u_f.h /* * LOOPBACK FUNCTION ... a testing vehicle for USB peripherals, @@ -293,6 +294,11 @@ static void disable_loopback(struct f_loopback *loop) VDBG(cdev, %s disabled\n, loop-function.name); } +static inline struct usb_request *lb_alloc_ep_req(struct usb_ep *ep, int len) +{ + return alloc_ep_req(ep, len, buflen); +} + static int enable_loopback(struct usb_composite_dev *cdev, struct f_loopback *loop) { @@ -332,7 +338,7 @@ fail0: * than 'buflen' bytes each. */ for (i = 0; i qlen result == 0; i++) { - req = alloc_ep_req(ep, 0); + req = lb_alloc_ep_req(ep, 0); if (req) { req-complete = loopback_complete; result = usb_ep_queue(ep, req, GFP_ATOMIC); diff --git a/drivers/usb/gadget/f_midi.c b/drivers/usb/gadget/f_midi.c index 263e721..36d4bb2 100644 --- a/drivers/usb/gadget/f_midi.c +++ b/drivers/usb/gadget/f_midi.c @@ -32,6 +32,8 @@ #include linux/usb/audio.h #include linux/usb/midi.h +#include u_f.h + MODULE_AUTHOR(Ben Williamson); MODULE_LICENSE(GPL v2); @@ -191,20 +193,10 @@ static struct usb_gadget_strings *midi_strings[] = { NULL, }; -static struct usb_request *alloc_ep_req(struct usb_ep *ep, unsigned length) +static inline struct usb_request *midi_alloc_ep_req(struct usb_ep *ep, + unsigned length) { - struct usb_request *req; - - req = usb_ep_alloc_request(ep, GFP_ATOMIC); - if (req) { - req-length = length; - req-buf = kmalloc(length, GFP_ATOMIC); - if (!req-buf) { - usb_ep_free_request(ep, req); - req = NULL; - } - } - return req; + return alloc_ep_req(ep, length, length); } static void free_ep_req(struct usb_ep *ep,
[PATCH 4/4] usb/gadget: f_sourcesink: add configfs support
Add support for using the sourcesink function in gadgets composed with configfs. Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- .../ABI/testing/configfs-usb-gadget-sourcesink | 12 + drivers/usb/gadget/Kconfig |7 +- drivers/usb/gadget/f_sourcesink.c | 318 drivers/usb/gadget/g_zero.h| 11 + drivers/usb/gadget/zero.c |4 +- 5 files changed, 347 insertions(+), 5 deletions(-) create mode 100644 Documentation/ABI/testing/configfs-usb-gadget-sourcesink diff --git a/Documentation/ABI/testing/configfs-usb-gadget-sourcesink b/Documentation/ABI/testing/configfs-usb-gadget-sourcesink new file mode 100644 index 000..a30f309 --- /dev/null +++ b/Documentation/ABI/testing/configfs-usb-gadget-sourcesink @@ -0,0 +1,12 @@ +What: /config/usb-gadget/gadget/functions/SourceSink.name +Date: Nov 2013 +KenelVersion: 3.13 +Description: + The attributes: + + pattern - 0 (all zeros), 1 (mod63), 2 (none) + isoc_interval - 1..16 + isoc_maxpacket - 0 - 1023 (fs), 0 - 1024 (hs/ss) + isoc_mult - 0..2 (hs/ss only) + isoc_maxburst - 0..15 (ss only) + qlen- buffer length diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index dadbffb..3cc77c9 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -700,12 +700,13 @@ config USB_CONFIGFS_F_FS implemented in kernel space (for instance Ethernet, serial or mass storage) and other are implemented in user space. -config USB_CONFIGFS_F_LB - boolean Loopback function (for testing) +config USB_CONFIGFS_F_LB_SS + boolean Loopback and sourcesink function (for testing) depends on USB_CONFIGFS select USB_F_SS_LB help - It loops back a configurable number of transfers. + Loopback function loops back a configurable number of transfers. + Sourcesink function either sinks and sources bulk data. It also implements control requests, for chapter 9 conformance. Make this be the first driver you try using on top of any new USB peripheral controller driver. Then you can use host-side diff --git a/drivers/usb/gadget/f_sourcesink.c b/drivers/usb/gadget/f_sourcesink.c index c5ad4a1..5d4251e 100644 --- a/drivers/usb/gadget/f_sourcesink.c +++ b/drivers/usb/gadget/f_sourcesink.c @@ -477,6 +477,14 @@ no_iso: static void sourcesink_free_func(struct usb_function *f) { + struct f_ss_opts *opts; + + opts = container_of(f-fi, struct f_ss_opts, func_inst); + + mutex_lock(opts-lock); + opts-refcnt--; + mutex_unlock(opts-lock); + usb_free_all_descriptors(f); kfree(func_to_ss(f)); } @@ -865,6 +873,11 @@ static struct usb_function *source_sink_alloc_func( return NULL; ss_opts = container_of(fi, struct f_ss_opts, func_inst); + + mutex_lock(ss_opts-lock); + ss_opts-refcnt++; + mutex_unlock(ss_opts-lock); + pattern = ss_opts-pattern; isoc_interval = ss_opts-isoc_interval; isoc_maxpacket = ss_opts-isoc_maxpacket; @@ -885,6 +898,303 @@ static struct usb_function *source_sink_alloc_func( return ss-function; } +static inline struct f_ss_opts *to_f_ss_opts(struct config_item *item) +{ + return container_of(to_config_group(item), struct f_ss_opts, + func_inst.group); +} + +CONFIGFS_ATTR_STRUCT(f_ss_opts); +CONFIGFS_ATTR_OPS(f_ss_opts); + +static void ss_attr_release(struct config_item *item) +{ + struct f_ss_opts *ss_opts = to_f_ss_opts(item); + + usb_put_function_instance(ss_opts-func_inst); +} + +static struct configfs_item_operations ss_item_ops = { + .release= ss_attr_release, + .show_attribute = f_ss_opts_attr_show, + .store_attribute= f_ss_opts_attr_store, +}; + +static ssize_t f_ss_opts_pattern_show(struct f_ss_opts *opts, char *page) +{ + int result; + + mutex_lock(opts-lock); + result = sprintf(page, %d, opts-pattern); + mutex_unlock(opts-lock); + + return result; +} + +static ssize_t f_ss_opts_pattern_store(struct f_ss_opts *opts, + const char *page, size_t len) +{ + int ret; + u8 num; + + mutex_lock(opts-lock); + if (opts-refcnt) { + ret = -EBUSY; + goto end; + } + + ret = kstrtou8(page, 0, num); + if (ret) + goto end; + + if (num != 0 num != 1 num != 2) { + ret = -EINVAL; + goto end; + } + + opts-pattern = num; + ret = len; +end: + mutex_unlock(opts-lock); + return ret; +} + +static struct
[PATCH 0/4] Equivalent of g_zero with configfs
This series aims at integrating configfs into gadget zero, the way it has been done for acm, ncm, ecm, eem, ecm subset, rndis, obex, phonet, mass_storage and FunctionFS. It contains everything that is required to provide the equivalent of g_zero.ko with configfs. BACKWARD COMPATIBILITY == Please note that the old g_zero.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/Loopback.0 mkdir functions/SourceSink.0 In the Loopback.0 directory there will be two attributes: qlen - depth of loopback queue bulk_buflen - buffer length In the SourceSink.0 directory there will be six attributes: pattern - 0 (all zeros), 1 (mod63), 2 (none) isoc_interval - 1..16 isoc_maxpacket - 0 - 1023 (fs), 0 - 1024 (hs/ss) isoc_mult - 0..2 (hs/ss only) isoc_maxburst - 0..15 (ss only) bulk_buflen - buffer length An example gadget with Loopback and SourceSink functions: $ modprobe libcomposite $ mount none cfg -t configfs $ mkdir cfg/usb_gadget/g1 $ cd cfg/usb_gadget/g1 $ mkdir configs/c.1 $ mkdir configs/c.2 $ mkdir functions/Loopback.0 $ mkdir functions/SourceSink.0 $ mkdir strings/0x409 $ mkdir configs/c.1/strings/0x409 $ mkdir configs/c.2/strings/0x409 $ echo 0x2d01 idProduct $ echo 0x04e8 idVendor $ echo my-serial-num strings/0x409/serialnumber $ echo my-manufacturer strings/0x409/manufacturer $ echo Test gadget strings/0x409/product $ echo Conf 1 configs/c.1/strings/0x409/configuration $ echo Conf 2 configs/c.2/strings/0x409/configuration $ echo 120 configs/c.1/MaxPower $ ln -s functions/Loopback.0 configs/c.1 $ ln -s functions/SourceSink.0 configs/c.2 $ echo s3c-hsotg cfg/usb_gadget/g1/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. Daemons need to be closed and then the respective modules can be unloaded. TESTING THE FUNCTIONS (actually there is only one) = loopback, souresink) device: run the gadget host: test-usb http://www.linux-usb.org/usbtest/testusb.c The results should be the same as with the g_zero.ko. Andrzej Pietrasiewicz (4): usb/gadget: composite: redirect setup requests usb/gadget: factor out alloc_ep_req usb/gadget: f_loopback: add configfs support usb/gadget: f_sourcesink: add configfs support .../ABI/testing/configfs-usb-gadget-loopback |8 + .../ABI/testing/configfs-usb-gadget-sourcesink | 12 + drivers/usb/gadget/Kconfig | 13 + drivers/usb/gadget/Makefile|2 +- drivers/usb/gadget/composite.c | 17 +- drivers/usb/gadget/f_hid.c | 18 +- drivers/usb/gadget/f_loopback.c| 140 - drivers/usb/gadget/f_midi.c| 22 +- drivers/usb/gadget/f_sourcesink.c | 341 ++- drivers/usb/gadget/g_zero.h| 24 ++- drivers/usb/gadget/u_f.c | 32 ++ drivers/usb/gadget/u_f.h | 26 ++ drivers/usb/gadget/zero.c |8 +- 13 files changed, 609 insertions(+), 54 deletions(-) create mode 100644 Documentation/ABI/testing/configfs-usb-gadget-loopback create mode 100644 Documentation/ABI/testing/configfs-usb-gadget-sourcesink create mode 100644 drivers/usb/gadget/u_f.c create mode 100644 drivers/usb/gadget/u_f.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
about libusbg (formerly libgadget)
Hi Matt, Thank you for the library: http://thread.gmane.org/gmane.linux.kernel/1556137 I'd like to make some comments you might want to consider. I don't like too much the idea of hardcoding the set of available functions. When new functions' conversions to use configfs are available (or completely new functions are added), you have to patch and recompile your library. Why not discover what the available functions are? Your library implicitly assumes that kernel modules' dependencies are properly calculated and modules are available for modprobe; otherwise mkdir function dir will not cause its corresponding module to load. This is a sane assumption. So modules' aliases should be available, too, and functions using the new function registration interface do follow a convention for aliases: $ cat /lib/modules/`uname -r`/modules.alias alias usbfunc:acm usb_f_acm alias usbfunc:rndis usb_f_rndis alias usbfunc:gser usb_f_serial alias usbfunc:eem usb_f_eem alias usbfunc:obex usb_f_obex alias usbfunc:phonet usb_f_phonet alias usbfunc:ecm usb_f_ecm alias usbfunc:geth usb_f_ecm_subset alias usbfunc:ncm usb_f_ncm Why not parse this file? I know that using strings (which are short, though) might not be the preferred way of identifying the functions in the program, so perhaps you could create an array of strings once and then use an index into it to tell one function from another? Alternatively, maybe you could use a configuration file which specifies the available functions? And provide a tool for creating the config file? If one of the above is in place, it is pretty straightforward to provide a method of listing the available functions, which is a nice feature for a gadget tool: $ gt --list-func acm ecm phonet obex ... In gadget_create_gadget(), gadget_create_config() and gadget_create_function() you first mkdir() and then allocate some memory. If memory is not allocated, you don't remove the directories. I guess you should. And even better, first do all other stuff that can fail, and as the last step try creating the directory; that way the filesystem operation does not need to be reverted. And for function directories there is also a side effect of loading the function's module upon directory creation, so it is better not to cause it to load if the function's creation is unsuccessful. Writing to attributes might actually fail, so whenever you call fputs()/fgets(), perhaps you should take it into account? Propagate the error further? Or not? Perhaps consider making gadget_write_string() static inline? It is called in a number of places while in fact it does nothing apart from delegating its job to gadget_write_buf(). I have mixed feelings about specialized setters in the section USB function- specific attribute configuration. Whenever new USB functions are available through configfs, the library must be patched and recompiled, which might also affect its users. Discovering what attributes are available for a given function is possible only after its directory is created. So I guess the library should provide a way of setting an attribute of any name and type (number, string) and fail if there happens to be no such attribute or the attribute type does not match. Then, the gadget tool invocation would be something on the lines of: $ gt {...} --func=ecm,qmult=1 {..} If qmult happens to be ecm's attribute and it makes sense to write 1 to it the gadget is created, otherwise an appropriate error message is returned. The gt would eventually call gadget_write_buf(path, name, qmult, 1) However, I admit there might be cases when e.g. qmult is already available as a number. Then it would be inconvenient to have to convert it first to a string, so gadget_write_int/dec/hex() could be made public. The above is just a bunch of thoughts for you to consider. If there are better ideas they are more than welcome. Thank you, AP -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Read transaction not work for EHCI host controller
Hi, greg I have used the minicom program which calls the open system call in blocking mode to access the usb device, and it seems there is no problem with it. So, the only thing I can suspect is that there is a bug in open system call implementation. Do you know which directory containing the source code about the implementation of open system call in the linux kernel tree? sincerely loki 2013/10/27 Greg KH gre...@linuxfoundation.org On Fri, Oct 25, 2013 at 08:21:58AM +, loki wrote: Hi, I used the USB-serial driver option.c to communicate with the GSM modem device through usb, the used host controller is EHCI. The problem is that nothing appear on the screen when type characters after using microcom -s 115200 /dev/ttyUSB3 command to access the ttyUSB3 device node. It sounds like microcom is not setting up the proper tty line settings for the device, as you say if you run it in blocking mode, it works properly, right? What about using the normal programs to connect to this device (i.e. network/modem manager and the like?) Don't they work properly with the hardware here? 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 RFC 1/4] phy: Add new Exynos5 USB 3.0 PHY driver
Hi Kishon, On Monday 04 of November 2013 12:24:42 Kishon Vijay Abraham I wrote: Hi Vivek, On Thursday 31 October 2013 01:15 PM, Vivek Gautam wrote: Add a new driver for the USB 3.0 PHY on Exynos5 series of SoCs. The new driver uses the generic PHY framework and will interact with DWC3 controller present on Exynos5 series of SoCs. In Exynos, you have a single IP that supports both USB3 and USB2 PHY right? I think that needs to be mentioned here. Nope. There are two separate, different IPs. Do you have separate registers that should be used for initializing/powerin_on/powering_off etc.. for usb2 phy and usb3 phy? If so, then you should model this driver as a single driver that supports two PHYs similar to what Sylwester has done before? Sylwester's MIPI PHY uses such model because it has a single register that controls both PHYs. Best regards, Tomasz -- To unsubscribe from this list: send the line unsubscribe 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: Gadget tool proposition
Hi, -Original Message- From: Felipe Balbi [mailto:ba...@ti.com] Sent: Thursday, October 31, 2013 4:23 PM To: Krzysztof Opasiak Cc: ba...@ti.com; linux-usb@vger.kernel.org; 'Matt Porter' Subject: Re: Gadget tool proposition Hi, On Thu, Oct 31, 2013 at 01:35:45PM +0100, Krzysztof Opasiak wrote: Dear List, After introduction of ConfigFS composite gadget, there appeared an gap in the user space. I mean that without this file system, creation of gadget is as simple as: $ modprobe g_gadget_module [params] But when we are trying to use ConfigFS we have to write a lot of commands. The minimal set is: $ mkdir gadget name $ mkdir configs/config name.config number $ mkdir functions/fucion type.instance name $ ln -s functions/fucion configs/configuration $ echo udc name UDC + setting vendorID, productID and others not entirely true. not at all!!! We have provided stubs for the gadget drivers which were already in tree and you can still use modprobe g_mass_storage, etc. Ok, fine, but it's done only for backward compatibility. The main method of gadget creation should be configFS. yes, this is what I said on line below For new gadgets, then sure, they need to be done via configfs. Not exactly. In my opinion we should tell all around that method 'modprobe g_mass_storage' works but is obsolete and works only due to backward compatibility. I think that not only new gadgets should be created using configFS. We should provide gadget templates for modules which are currently in mainline and encourage users to use them so they can notice that there is ConfigFS and it is good practice to use it. Great, I hope you will enjoy using the new tool when it will be ready. sure, for testing purposes it's awesome, but when building a real device, I'd expect application framework to use libgadget directly and use your tool as a reference implementation. Yes. In my opinion loading gadgets from template is so basic think that at least one format of templates should be supported by library. So I would like to implement a functions like: usbg_load_gadget_template(int fd, /*additional params*/); usbg_load_func_template(int fd, /*additional params*/); usbg_load_config_template(int fd, /*additional params*/); This let all applications which will use libusbg to use that same templates as gadget tool. -- BR's Krzysiek -- To unsubscribe from this list: send the line unsubscribe 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: Gadget tool proposition
Hi, -Original Message- From: 'Matt Porter' [mailto:matt.por...@linaro.org] Sent: Saturday, November 02, 2013 6:59 PM To: Krzysztof Opasiak Cc: ba...@ti.com; linux-usb@vger.kernel.org Subject: Re: Gadget tool proposition On Thu, Oct 31, 2013 at 01:35:45PM +0100, Krzysztof Opasiak wrote: Hi, -Original Message- From: Felipe Balbi [mailto:ba...@ti.com] Sent: Wednesday, October 30, 2013 6:33 PM To: Krzysztof Opasiak Cc: linux-usb@vger.kernel.org; Matt Porter Subject: Re: Gadget tool proposition Hi, On Wed, Oct 30, 2013 at 03:28:43PM +0100, Krzysztof Opasiak wrote: With all ConfigFS benefits, flexibility and other advantages, it's 5 or maybe 10 times more writing than in the old solution to fulfill the most common use cases. Users are lazy, they will still use the old, bad solution, unless we will develop some user-space tool for convenient gadget management. there's already libgadget [1] which Matt Porter has been working on, how about you help him out ? I'd really like to see libgadget bindings for ruby, for example. As well as some default examples for current, in-tree gadget drivers. As I wrote in previous message. I would like to use libgadget. There are some issues, but I will prepare some patches which implements the missing things, I that Matt will accept them. More over I'm not sure if there is a need to have two projects - gt and libgadget. Maybe create only one and only in distributions provide separate packages for tool and library. What do you think Matt? Yes, I'd like that. I very much want patches to support this. My intention has been to support a tool like the gt you describe below. I've got some wip changes to rename libgadget-libusbg to avoid some older libgadget projects that are not maintained but provide confusion. I also have some other apis mostly finished that I previously mentioned for removal and other support functions. Great, I'm looking forward for the upgrade. Let's plan on having gt being part of the same repo..packagers can split the library and tool out as they need. I was traveling last week and didn't get these updates cleaned up and pushed but it should happen next week for 0.0.2. What about repo which I have created at github? Maybe we can use it for both gadget tool and libusbg? The next version of this library could be introduced there? -- BR's Krzysiek -- To unsubscribe from this list: send the line unsubscribe 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: Read transaction not work for EHCI host controller
A: No. Q: Should I include quotations after my reply? http://daringfireball.net/2007/07/on_top On Mon, Nov 04, 2013 at 07:58:42PM +0800, ys6 land wrote: Hi, greg I have used the minicom program which calls the open system call in blocking mode to access the usb device, and it seems there is no problem with it. That's good to know. So, the only thing I can suspect is that there is a bug in open system call implementation. Do you know which directory containing the source code about the implementation of open system call in the linux kernel tree? I really doubt there is a problem with open(), but the code for it should be easy to look through if you are interested, it's in fs/open.c in the kernel source tree. I still think this is a line setting issue for your userspace program... good luck, 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][bugfix] usb/gadget: f_mass_storage: fix mass storage dependency
Legacy gadgets supporting mass storage (g_mass_storage, g_acm_ms, g_multi) all depend on BLOCK. Make the standalone compilation of f_mass_storage (without any legacy gadget) dependent no BLOCK, too. Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- drivers/usb/gadget/Kconfig |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 3cc77c9..597189d 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -681,6 +681,7 @@ config USB_CONFIGFS_PHONET config USB_CONFIGFS_MASS_STORAGE boolean Mass storage depends on USB_CONFIGFS + depends on BLOCK select USB_F_MASS_STORAGE help The Mass Storage Gadget acts as a USB Mass Storage disk drive. -- 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] USB: serial: option: blacklist intf1 for Huawei E173s-6
Interface 1 on this device isn't for option to bind to otherwise an oops on usb_wwan with log flooding will happen: tty_release: ttyUSB1: read/write wait queue active! And it doesn't seem to respond to QMI if it's added to qmi_wwan so don't add it there. Signed-off-by: Gustavo Zacarias gust...@zacarias.com.ar --- drivers/usb/serial/option.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index acaee06..b5d3b33 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c @@ -81,6 +81,7 @@ static void option_instat_callback(struct urb *urb); #define HUAWEI_VENDOR_ID 0x12D1 #define HUAWEI_PRODUCT_E1730x140C +#define HUAWEI_PRODUCT_E173S 0x1C07 #define HUAWEI_PRODUCT_E1750 0x1406 #define HUAWEI_PRODUCT_K4505 0x1464 #define HUAWEI_PRODUCT_K3765 0x1465 @@ -572,6 +573,8 @@ static const struct usb_device_id option_ids[] = { { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0x1c23, USB_CLASS_COMM, 0x02, 0xff) }, { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E173, 0xff, 0xff, 0xff), .driver_info = (kernel_ulong_t) net_intf1_blacklist }, + { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E173S, 0xff, 0xff, 0xff), + .driver_info = (kernel_ulong_t) net_intf1_blacklist }, { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1750, 0xff, 0xff, 0xff), .driver_info = (kernel_ulong_t) net_intf2_blacklist }, { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0x1441, USB_CLASS_COMM, 0x02, 0xff) }, -- 1.8.1.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
USB 3.0 SDR / Ettus Research B200/210
Hi guys, This is my first post to this list, so let me quickly introduce myself. I'm a software engineer for Ettus Research (National Instruments). One of our new products [1] is a USB 3.0 (using Cypress FX3) based SDR that currently ships with a libusb based open source driver integrated in our open source UHD userland driver. Our device comes with ADC/DACs that need high throughput streaming from and to the host. We're using bulk transfers to send data to a Spartan 6 FPGA in the device. As the CPU usage is quite high and the throughput using libusb is not as high as we expect we're currently looking into developing a kernel driver. Profiling showed we're spending quite some time in the kernel when using libusb. I've started grepping around the tree for an example to steal from and stumbled upon the drivers/usb/usb-skeleton.c file. Can I base a high throughput (streaming) USB 3.0 driver off of this or is this not a good starting point to look at? Are there other device drivers to look at that might give me some insight into how to deal with super speed devices using bulk transfers? If there is nothing to look at (yet) I'm happy to work on this and contribute our solution back. Cheers, Moritz [1] https://www.ettus.com/product/details/UB210-KIT -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH RFC 1/4] phy: Add new Exynos5 USB 3.0 PHY driver
On Monday 04 November 2013 05:56 PM, Tomasz Figa wrote: Hi Kishon, On Monday 04 of November 2013 12:24:42 Kishon Vijay Abraham I wrote: Hi Vivek, On Thursday 31 October 2013 01:15 PM, Vivek Gautam wrote: Add a new driver for the USB 3.0 PHY on Exynos5 series of SoCs. The new driver uses the generic PHY framework and will interact with DWC3 controller present on Exynos5 series of SoCs. In Exynos, you have a single IP that supports both USB3 and USB2 PHY right? I think that needs to be mentioned here. Nope. There are two separate, different IPs. Alright. Thanks for the clarification. Cheers Kishon Do you have separate registers that should be used for initializing/powerin_on/powering_off etc.. for usb2 phy and usb3 phy? If so, then you should model this driver as a single driver that supports two PHYs similar to what Sylwester has done before? Sylwester's MIPI PHY uses such model because it has a single register that controls both PHYs. Best regards, Tomasz -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH RFC 1/4] phy: Add new Exynos5 USB 3.0 PHY driver
Hi, On Monday 04 November 2013 03:45 PM, Kamil Debski wrote: Hi Kishon, From: Kishon Vijay Abraham I [mailto:kis...@ti.com] Sent: Monday, November 04, 2013 7:55 AM Hi Vivek, On Thursday 31 October 2013 01:15 PM, Vivek Gautam wrote: Add a new driver for the USB 3.0 PHY on Exynos5 series of SoCs. The new driver uses the generic PHY framework and will interact with DWC3 controller present on Exynos5 series of SoCs. In Exynos, you have a single IP that supports both USB3 and USB2 PHY right? I think that needs to be mentioned here. As far as I know the IP is different. Ok. Sometime back Vivek was mentioning about a single IP for both USB3 and USB2. Thought it should be this driver. Anyway thanks for the clarification. Cheers Kishon Do you have separate registers that should be used for initializing/powerin_on/powering_off etc.. for usb2 phy and usb3 phy? If so, then you should model this driver as a single driver that supports two PHYs similar to what Sylwester has done before? Best wishes, Kamil Cheers Kishon Signed-off-by: Vivek Gautam gautam.vi...@samsung.com --- .../devicetree/bindings/phy/samsung-phy.txt| 20 + drivers/phy/Kconfig|7 + drivers/phy/Makefile |1 + drivers/phy/phy-exynos5-usb3.c | 562 4 files changed, 590 insertions(+), 0 deletions(-) create mode 100644 drivers/phy/phy-exynos5-usb3.c diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt index c0fccaa..9b5c111 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -20,3 +20,23 @@ Required properties: - compatible : should be samsung,exynos5250-dp-video-phy; - reg : offset and length of the Display Port PHY register set; - #phy-cells : from the generic PHY bindings, must be 0; + +Samsung Exynos5 SoC seiries USB 3.0 PHY controller +-- + +Required properties: +- compatible : + should be samsung,exynos5250-usb3phy for exynos5250 SoC + should be samsung,exynos5420-usb3phy for exynos5420 SoC +- reg : Register offset and length array + - first field corresponds to USB 3.0 PHY register set; + - second field corresponds to PHY power isolation register + present in PMU; +- clocks: Clock IDs array as required by the controller +- clock-names: names of clocks correseponding to IDs in the clock property; + Required clocks: + - first clock is main PHY clock (same as USB 3.0 controller IP clock) + - second clock is reference clock (usually crystal clock) + optional clock: + - third clock is special clock used by PHY for operation +- #phy-cells : from the generic PHY bindings, must be 0; diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index a344f3d..9a100c6 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -51,4 +51,11 @@ config PHY_EXYNOS_DP_VIDEO help Support for Display Port PHY found on Samsung EXYNOS SoCs. +config PHY_EXYNOS5_USB3 + tristate Exynos5 SoC series USB 3.0 PHY driver + depends on ARCH_EXYNOS5 + select GENERIC_PHY + help + Enable USB 3.0 PHY support for Exynos 5 SoC series + endmenu diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index d0caae9..9c06a61 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -7,3 +7,4 @@ obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO) += phy-exynos-dp- video.o obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO) += phy-exynos-mipi-video.o obj-$(CONFIG_OMAP_USB2) += phy-omap-usb2.o obj-$(CONFIG_TWL4030_USB)+= phy-twl4030-usb.o +obj-$(CONFIG_PHY_EXYNOS5_USB3) += phy-exynos5-usb3.o diff --git a/drivers/phy/phy-exynos5-usb3.c b/drivers/phy/phy-exynos5-usb3.c new file mode 100644 index 000..b9a2674 --- /dev/null +++ b/drivers/phy/phy-exynos5-usb3.c @@ -0,0 +1,562 @@ +/* + * Samsung EXYNOS5 SoC series USB 3.0 PHY driver + * + * Copyright (C) 2013 Samsung Electronics Co., Ltd. + * Author: Vivek Gautam gautam.vi...@samsung.com + * + * This program is free software; you can redistribute it and/or +modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include linux/clk.h +#include linux/delay.h +#include linux/io.h +#include linux/kernel.h +#include linux/module.h +#include linux/of.h +#include linux/of_address.h +#include linux/phy/phy.h +#include linux/platform_device.h +#include linux/mutex.h + +/* Exynos USB PHY registers */ +#define EXYNOS5_FSEL_9MHZ6 0x0 +#define EXYNOS5_FSEL_10MHZ 0x1 +#define EXYNOS5_FSEL_12MHZ 0x2 +#define EXYNOS5_FSEL_19MHZ20x3 +#define EXYNOS5_FSEL_20MHZ 0x4 +#define EXYNOS5_FSEL_24MHZ 0x5
[PATCH] usb: usbtest: add a test case to support bos for queue control
In Test 10 of usbtest module, it queues multiple control messages and thereby tests control message queuing, protocol stalls, short reads, and fault handling. And this patch add a test case to support queue BOS control request for USB 3.0 SPEC. Signed-off-by: Huang Rui ray.hu...@amd.com --- drivers/usb/misc/usbtest.c | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index b415282..f3c3136 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c @@ -944,7 +944,7 @@ struct ctrl_ctx { int last; }; -#define NUM_SUBCASES 15 /* how many test subcases here? */ +#define NUM_SUBCASES 16 /* how many test subcases here? */ struct subcase { struct usb_ctrlrequest setup; @@ -1218,6 +1218,15 @@ test_ctrl_queue(struct usbtest_dev *dev, struct usbtest_param *param) } expected = -EREMOTEIO; break; + case 15: + req.wValue = cpu_to_le16(USB_DT_BOS 8); + if (udev-bos) + len = le16_to_cpu(udev-bos-desc-wTotalLength); + else + len = sizeof(struct usb_bos_descriptor); + if (udev-speed != USB_SPEED_SUPER) + expected = -EPIPE; + break; default: ERROR(dev, bogus number of ctrl queue testcases!\n); context.status = -EINVAL; -- 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: about libusbg (formerly libgadget)
Hi, -Original Message- From: Andrzej Pietrasiewicz [mailto:andrze...@samsung.com] Sent: Monday, November 04, 2013 12:52 PM To: matt.por...@linaro.org Cc: jeng...@inai.de; linux-usb@vger.kernel.org; Marek Szyprowski; kyungmin.p...@samsung.com; Krzysztof Opasiak Subject: about libusbg (formerly libgadget) Hi Matt, Thank you for the library: http://thread.gmane.org/gmane.linux.kernel/1556137 I'd like to make some comments you might want to consider. I don't like too much the idea of hardcoding the set of available functions. When new functions' conversions to use configfs are available (or completely new functions are added), you have to patch and recompile your library. Why not discover what the available functions are? Your library implicitly assumes that kernel modules' dependencies are properly calculated and modules are available for modprobe; otherwise mkdir function dir will not cause its corresponding module to load. This is a sane assumption. So modules' aliases should be available, too, and functions using the new function registration interface do follow a convention for aliases: $ cat /lib/modules/`uname -r`/modules.alias alias usbfunc:acm usb_f_acm alias usbfunc:rndis usb_f_rndis alias usbfunc:gser usb_f_serial alias usbfunc:eem usb_f_eem alias usbfunc:obex usb_f_obex alias usbfunc:phonet usb_f_phonet alias usbfunc:ecm usb_f_ecm alias usbfunc:geth usb_f_ecm_subset alias usbfunc:ncm usb_f_ncm Why not parse this file? I know that using strings (which are short, though) might not be the preferred way of identifying the functions in the program, so perhaps you could create an array of strings once and then use an index into it to tell one function from another? Alternatively, maybe you could use a configuration file which specifies the available functions? And provide a tool for creating the config file? If one of the above is in place, it is pretty straightforward to provide a method of listing the available functions, which is a nice feature for a gadget tool: $ gt --list-func acm ecm phonet obex ... I'm not optimistic about this idea. First of all, modules can be build-in kernel so the file modules.aliases may not contain the whole list of available functions. Secondly, the assumption about calculated modules dependencies is quite good. Providing modules and dependencies is a task of super user. Library should not contain any code related to module loading etc. Program which use this library may not have root permissions. For example root will give chmod 777 /configFS and then all users will be able to manipulate gadget's but they will be able to create only gadget's delivered by root (or other users with such permissions). It's quite good method for gadget administration. Moreover, maybe we can follow the convention of libusb? We could provide a set of dedicated functions for standard gadgets (gadget actually in mainline) and the develop library when new module appeared, but also we should provide a set of functions which will allow to create any gadgets and their parameters from user strings for example gadget_create_raw_function(my_brand_new_function); gadget_create_raw_function(FUNCTION_ENUM_ACM); In gadget_create_gadget(), gadget_create_config() and gadget_create_function() you first mkdir() and then allocate some memory. If memory is not allocated, you don't remove the directories. I guess you should. And even better, first do all other stuff that can fail, and as the last step try creating the directory; that way the filesystem operation does not need to be reverted. And for function directories there is also a side effect of loading the function's module upon directory creation, so it is better not to cause it to load if the function's creation is unsuccessful. Writing to attributes might actually fail, so whenever you call fputs()/fgets(), perhaps you should take it into account? Propagate the error further? Or not? Perhaps consider making gadget_write_string() static inline? It is called in a number of places while in fact it does nothing apart from delegating its job to gadget_write_buf(). Good points, this should be changed. I have mixed feelings about specialized setters in the section USB function- specific attribute configuration. Whenever new USB functions are available through configfs, the library must be patched and recompiled, which might also affect its users. Discovering what attributes are available for a given function is possible only after its directory is created. So I guess the library should provide a way of setting an attribute of any name and type (number, string) and fail if there happens to be no such attribute or the attribute type does not match. Then, the gadget tool invocation would be something on the lines of: $ gt {...} --func=ecm,qmult=1 {..} If qmult happens to be ecm's
Re: [PATCH] USB: ehci-atmel: add usb_clk for transition to CCF
On 18/10/2013 21:26, Boris BREZILLON : The AT91 PMC (Power Management Controller) provides a USB clock used by the different USB controllers (ehci, ohci and udc). The atmel-ehci driver must configure the usb clock rate to 48Mhz in order to get a fully functionnal USB host controller. This configuration was formely done in mach-at91/clock.c, but will be bypassed when moving to common clk framework. This patch adds support for usb clock retrieval and configuration only if CCF is enabled (CONFIG_COMMON_CLK). Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com Acked-by: Nicolas Ferre nicolas.fe...@atmel.com Greg, as this patch is already in your tree, it is only for the record. I have tested it and it works now. Thanks Boris, bye. --- drivers/usb/host/ehci-atmel.c | 16 +++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c index 3b645ff..f417526 100644 --- a/drivers/usb/host/ehci-atmel.c +++ b/drivers/usb/host/ehci-atmel.c @@ -30,13 +30,17 @@ static const char hcd_name[] = ehci-atmel; static struct hc_driver __read_mostly ehci_atmel_hc_driver; /* interface and function clocks */ -static struct clk *iclk, *fclk; +static struct clk *iclk, *fclk, *uclk; static int clocked; /*-*/ static void atmel_start_clock(void) { + if (IS_ENABLED(CONFIG_COMMON_CLK)) { + clk_set_rate(uclk, 4800); + clk_prepare_enable(uclk); + } clk_prepare_enable(iclk); clk_prepare_enable(fclk); clocked = 1; @@ -46,6 +50,8 @@ static void atmel_stop_clock(void) { clk_disable_unprepare(fclk); clk_disable_unprepare(iclk); + if (IS_ENABLED(CONFIG_COMMON_CLK)) + clk_disable_unprepare(uclk); clocked = 0; } @@ -130,6 +136,14 @@ static int ehci_atmel_drv_probe(struct platform_device *pdev) retval = -ENOENT; goto fail_request_resource; } + if (IS_ENABLED(CONFIG_COMMON_CLK)) { + uclk = devm_clk_get(pdev-dev, usb_clk); + if (IS_ERR(uclk)) { + dev_err(pdev-dev, failed to get uclk\n); + retval = PTR_ERR(uclk); + goto fail_request_resource; + } + } ehci = hcd_to_ehci(hcd); /* registers start at offset 0x0 */ -- Nicolas Ferre -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/2] added fputs() fgets() error handling
Change-Id: I787380dda981c7cee6508a4ff566d7ca9fb273cf Signed-off-by: Stanislaw Wadas s.wa...@samsung.com --- src/gadget.c | 12 +++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/gadget.c b/src/gadget.c index faed675..ff4f3d5 100644 --- a/src/gadget.c +++ b/src/gadget.c @@ -93,6 +93,11 @@ static char *gadget_read_buf(char *path, char *name, char *file, char *buf) goto out; ret = fgets(buf, MAX_LENGHT, fp); + if (ret == NULL) { + ERROR(read error); + fclose(fp); + return ret; + } fclose(fp); @@ -127,6 +132,7 @@ static void gadget_write_buf(char *path, char *name, char *file, char *buf) { char p[MAX_LENGHT]; FILE *fp; + int ret; sprintf(p, %s/%s/%s, path, name, file); @@ -136,7 +142,11 @@ static void gadget_write_buf(char *path, char *name, char *file, char *buf) return; } - fputs(buf, fp); + if (fputs(buf, fp) == EOF) { + ERROR(write error); + fclose(fp); + return; + } fclose(fp); } -- 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
libusbg clean up and error handling
In reference to the message sent by Andrzej Pietrasiewicz (about libusbg (formerly libgadget)) I would like to propose some changes to libusbg. Best Regards Stanislaw Wadas Samsung RD Institute Poland Samsung Electronics s.wa...@samsung.com -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/2] Moved mkdir functions, added MAX_LENGHT MAX_PATH_LENGHT
mkdir() function are now called after successfull function creation. Added inline to gadget_write_string(). 256 hard coded value has been replaced by two defined constants MAX_LENGHT and MAX_PATH_LENGHT Change-Id: Ifcfaf9cf95da6558c176ce3367cd553cea54e871 Signed-off-by: Stanislaw Wadas s.wa...@samsung.com --- include/gadget/gadget.h | 27 --- src/gadget.c| 84 +++ 2 files changed, 57 insertions(+), 54 deletions(-) diff --git a/include/gadget/gadget.h b/include/gadget/gadget.h index 6a32c39..80e9dd6 100644 --- a/include/gadget/gadget.h +++ b/include/gadget/gadget.h @@ -33,13 +33,16 @@ #define DEFAULT_UDCNULL #define LANG_US_ENG0x0409 +#define MAX_LENGHT 256 +#define MAX_PATH_LENGHT 256 + /** * @struct state * @brief State of the gadget devices in the system */ struct state { - char path[256]; + char path[MAX_PATH_LENGHT]; TAILQ_HEAD(ghead, gadget) gadgets; }; @@ -51,8 +54,8 @@ struct state struct gadget { char name[40]; - char path[256]; - char udc[256]; + char path[MAX_PATH_LENGHT]; + char udc[MAX_LENGHT]; int dclass; int dsubclass; int dproto; @@ -61,9 +64,9 @@ struct gadget int bcdusb; int product; int vendor; - char str_ser[256]; - char str_mnf[256]; - char str_prd[256]; + char str_ser[MAX_LENGHT]; + char str_mnf[MAX_LENGHT]; + char str_prd[MAX_LENGHT]; TAILQ_ENTRY(gadget) gnode; TAILQ_HEAD(chead, config) configs; TAILQ_HEAD(fhead, function) functions; @@ -81,10 +84,10 @@ struct config struct gadget *parent; char name[40]; - char path[256]; + char path[MAX_PATH_LENGHT]; int maxpower; int bmattrs; - char str_cfg[256]; + char str_cfg[MAX_LENGHT]; }; /** @@ -136,7 +139,7 @@ struct serial_attrs { struct net_attrs { struct ether_addr dev_addr; struct ether_addr host_addr; - char ifname[256]; + char ifname[MAX_LENGHT]; int qmult; }; @@ -145,7 +148,7 @@ struct net_attrs { * @brief Attributes for the phonet USB function */ struct phonet_attrs { - char ifname[256]; + char ifname[MAX_LENGHT]; }; /** @@ -168,7 +171,7 @@ struct function struct gadget *parent; char name[40]; - char path[256]; + char path[MAX_PATH_LENGHT]; enum function_type type; union attrs attr; @@ -187,7 +190,7 @@ struct binding struct function *target; char name[40]; - char path[256]; + char path[MAX_PATH_LENGHT]; }; /* Library init and cleanup */ diff --git a/src/gadget.c b/src/gadget.c index 83b8b62..faed675 100644 --- a/src/gadget.c +++ b/src/gadget.c @@ -82,7 +82,7 @@ static int file_select(const struct dirent *dent) static char *gadget_read_buf(char *path, char *name, char *file, char *buf) { - char p[256]; + char p[MAX_LENGHT]; FILE *fp; char *ret = NULL; @@ -92,7 +92,7 @@ static char *gadget_read_buf(char *path, char *name, char *file, char *buf) if (!fp) goto out; - ret = fgets(buf, 256, fp); + ret = fgets(buf, MAX_LENGHT, fp); fclose(fp); @@ -102,7 +102,7 @@ out: static int gadget_read_int(char *path, char *name, char *file, int base) { - char buf[256]; + char buf[MAX_LENGHT]; if (gadget_read_buf(path, name, file, buf)) return strtol(buf, NULL, base); @@ -125,7 +125,7 @@ static void gadget_read_string(char *path, char *name, char *file, char *buf) static void gadget_write_buf(char *path, char *name, char *file, char *buf) { - char p[256]; + char p[MAX_LENGHT]; FILE *fp; sprintf(p, %s/%s/%s, path, name, file); @@ -143,7 +143,7 @@ static void gadget_write_buf(char *path, char *name, char *file, char *buf) static void gadget_write_int(char *path, char *name, char *file, int value, char *str) { - char buf[256]; + char buf[MAX_LENGHT]; sprintf(buf, str, value); gadget_write_buf(path, name, file, buf); @@ -153,7 +153,7 @@ static void gadget_write_int(char *path, char *name, char *file, int value, char #define gadget_write_hex16(p, n, f, v) gadget_write_int(p, n, f, v, 0x%04x\n) #define gadget_write_hex8(p, n, f, v) gadget_write_int(p, n, f, v, 0x%02x\n) -static void gadget_write_string(char *path, char *name, char *file, char *buf) +static inline void gadget_write_string(char *path, char *name, char *file, char *buf) { gadget_write_buf(path, name, file, buf); } @@ -196,7 +196,7 @@ static int gadget_parse_functions(char *path, struct gadget *g) struct function *f; int i, n; struct dirent **dent; - char fpath[256]; + char fpath[MAX_PATH_LENGHT]; sprintf(fpath, %s/%s/functions, path, g-name); @@ -227,7 +227,7 @@
Re: [PATCH 1/2] Moved mkdir functions, added MAX_LENGHT MAX_PATH_LENGHT
W dniu 04.11.2013 14:55, Stanislaw Wadas pisze: mkdir() function are now called after successfull function creation. Added inline to gadget_write_string(). 256 hard coded value has been replaced by two defined constants MAX_LENGHT and MAX_PATH_LENGHT LENGHT - LENGTH Change-Id: Ifcfaf9cf95da6558c176ce3367cd553cea54e871 Signed-off-by: Stanislaw Wadas s.wa...@samsung.com --- include/gadget/gadget.h | 27 --- src/gadget.c| 84 +++ 2 files changed, 57 insertions(+), 54 deletions(-) diff --git a/include/gadget/gadget.h b/include/gadget/gadget.h index 6a32c39..80e9dd6 100644 --- a/include/gadget/gadget.h +++ b/include/gadget/gadget.h @@ -33,13 +33,16 @@ #define DEFAULT_UDC NULL #define LANG_US_ENG 0x0409 +#define MAX_LENGHT 256 +#define MAX_PATH_LENGHT 256 + /** * @struct state * @brief State of the gadget devices in the system */ struct state { - char path[256]; + char path[MAX_PATH_LENGHT]; TAILQ_HEAD(ghead, gadget) gadgets; }; @@ -51,8 +54,8 @@ struct state struct gadget { char name[40]; - char path[256]; - char udc[256]; + char path[MAX_PATH_LENGHT]; + char udc[MAX_LENGHT]; int dclass; int dsubclass; int dproto; @@ -61,9 +64,9 @@ struct gadget int bcdusb; int product; int vendor; - char str_ser[256]; - char str_mnf[256]; - char str_prd[256]; + char str_ser[MAX_LENGHT]; + char str_mnf[MAX_LENGHT]; + char str_prd[MAX_LENGHT]; TAILQ_ENTRY(gadget) gnode; TAILQ_HEAD(chead, config) configs; TAILQ_HEAD(fhead, function) functions; @@ -81,10 +84,10 @@ struct config struct gadget *parent; char name[40]; - char path[256]; + char path[MAX_PATH_LENGHT]; int maxpower; int bmattrs; - char str_cfg[256]; + char str_cfg[MAX_LENGHT]; }; /** @@ -136,7 +139,7 @@ struct serial_attrs { struct net_attrs { struct ether_addr dev_addr; struct ether_addr host_addr; - char ifname[256]; + char ifname[MAX_LENGHT]; int qmult; }; @@ -145,7 +148,7 @@ struct net_attrs { * @brief Attributes for the phonet USB function */ struct phonet_attrs { - char ifname[256]; + char ifname[MAX_LENGHT]; }; /** @@ -168,7 +171,7 @@ struct function struct gadget *parent; char name[40]; - char path[256]; + char path[MAX_PATH_LENGHT]; enum function_type type; union attrs attr; @@ -187,7 +190,7 @@ struct binding struct function *target; char name[40]; - char path[256]; + char path[MAX_PATH_LENGHT]; }; /* Library init and cleanup */ diff --git a/src/gadget.c b/src/gadget.c index 83b8b62..faed675 100644 --- a/src/gadget.c +++ b/src/gadget.c @@ -82,7 +82,7 @@ static int file_select(const struct dirent *dent) static char *gadget_read_buf(char *path, char *name, char *file, char *buf) { - char p[256]; + char p[MAX_LENGHT]; FILE *fp; char *ret = NULL; @@ -92,7 +92,7 @@ static char *gadget_read_buf(char *path, char *name, char *file, char *buf) if (!fp) goto out; - ret = fgets(buf, 256, fp); + ret = fgets(buf, MAX_LENGHT, fp); fclose(fp); @@ -102,7 +102,7 @@ out: static int gadget_read_int(char *path, char *name, char *file, int base) { - char buf[256]; + char buf[MAX_LENGHT]; if (gadget_read_buf(path, name, file, buf)) return strtol(buf, NULL, base); @@ -125,7 +125,7 @@ static void gadget_read_string(char *path, char *name, char *file, char *buf) static void gadget_write_buf(char *path, char *name, char *file, char *buf) { - char p[256]; + char p[MAX_LENGHT]; FILE *fp; sprintf(p, %s/%s/%s, path, name, file); @@ -143,7 +143,7 @@ static void gadget_write_buf(char *path, char *name, char *file, char *buf) static void gadget_write_int(char *path, char *name, char *file, int value, char *str) { - char buf[256]; + char buf[MAX_LENGHT]; sprintf(buf, str, value); gadget_write_buf(path, name, file, buf); @@ -153,7 +153,7 @@ static void gadget_write_int(char *path, char *name, char *file, int value, char #define gadget_write_hex16(p, n, f, v)gadget_write_int(p, n, f, v, 0x%04x\n) #define gadget_write_hex8(p, n, f, v) gadget_write_int(p, n, f, v, 0x%02x\n) -static void gadget_write_string(char *path, char *name, char *file, char *buf) +static inline void gadget_write_string(char *path, char *name, char *file, char *buf) { gadget_write_buf(path, name, file, buf); } @@ -196,7 +196,7 @@ static int gadget_parse_functions(char *path, struct gadget *g) struct function *f; int i, n; struct dirent **dent; - char fpath[256]; + char
Re: [PATCH net-next 13/13] scripts/checkpatch.pl: Add dev_kfree_skb*(NULL) check to checkpatch
On Sat, 2013-11-02 at 19:17 +0530, Govindarajulu Varadarajan wrote: Signed-off-by: Govindarajulu Varadarajan govindarajul...@gmail.com [] diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl [] @@ -3719,7 +3719,7 @@ sub process { # check for needless if (foo) fn(foo) uses if ($prevline =~ /\bif\s*\(\s*($Lval)\s*\)/) { my $expr = '\s*\(\s*' . quotemeta($1) . '\s*\)\s*;'; - if ($line =~ /\b(kfree|usb_free_urb|debugfs_remove(?:_recursive)?)$expr/) { + if ($line =~ /\b(kfree|dev_kfree_skb|dev_kfree_skb_any|dev_kfree_skb_irq|usb_free_urb|debugfs_remove(?:_recursive)?)$expr/) { WARN('NEEDLESS_IF', $1(NULL) is safe this check is probably not required\n . $hereprev); } OK, but I think this is easier to read as dev_kfree_skb(?:_skb|_any|_irq)? -- To unsubscribe from this list: send the line unsubscribe 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 SDR / Ettus Research B200/210
On Mon, Nov 4, 2013 at 2:21 PM, Greg KH gre...@linuxfoundation.org wrote: Where specifically in the kernel? Busywaiting for data transferrs to complete, or doing something else? Are you keeping the pipeline full to the device? You should be able to hit USB line speed from userspace if you just are reading/writing bulk data with enough transferrs in flight. I'll confirm this with my colleagues. Sorry I wasn't really verbose enough here. That's a good place to start, but it really depends on what type of interface you want to expose to userspace, as to what the best driver to base off of would be. I was thinking about a simple char / misc device with a read / write / ioctl or sysfs interface. The userland part would again be provided by UHD as with our ethernet devices. As you are a ADC/DAC, you probably want to tie into the comedi subsystem, so take a look at the USB drivers in the drivers/staging/comedi/ subdirectories for an example of what to use. Thanks a lot already for your quick response. I'll read up on comedi and see if it fits our use case, and hopefully come back with some code to look at ;-) Cheers, Moritz -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 1/1] usb: hcd: move controller wakeup setting initialization to individual driver
On Sun, 3 Nov 2013, Peter Chen wrote: diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c index a06d501..bf405fd 100644 --- a/drivers/usb/host/ehci-fsl.c +++ b/drivers/usb/host/ehci-fsl.c @@ -139,6 +139,7 @@ static int usb_hcd_fsl_probe(const struct hc_driver *driver, if (retval != 0) goto err4; + device_wakeup_enable(hcd-self.controller); #ifdef CONFIG_USB_OTG if (pdata-operating_mode == FSL_USB2_DR_OTG) { struct ehci_hcd *ehci = hcd_to_ehci(hcd); Here and in some other places, the patch displays a bad sense of style. The device_wakeup_enable() call belongs along with the other hcd-related statements; it has nothing to do with CONFIG_USB_OTG. Therefore you should put a blank line before the #ifdef. (You could also consider removing the blank line that precedes device_wakeup_enable().) So the basic code stype is: before comment and MACRO, there is a blank line. No, the basic coding style is: You should prefer to put blank lines between unrelated lines, not between related lines. This can be stated more precisely: If there are three lines of code, A B C, and if B is more closely related to A than to C, then they should not be written like this: A B C because then the blank line indicates that B is more closely related to C than to A, and people reading the code will be confused. But after if (), keep a blank line will let code look like clean, do you think so? That's up to you. Either way is okay with me. For pci device, do you want hcd-pci to control wakeup setting together? or let each pci(xhci/ehci/ohci/uhci-pci) driver controller it? For now, put it in hcd-pci. We can move it later if we need to. 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: kernel NULL pointer dereference at (null) - inside hub_disconnect
On Mon, 4 Nov 2013, Luke-Jr wrote: On Tuesday, October 29, 2013 2:39:14 PM Alan Stern wrote: On Mon, 28 Oct 2013, Luke-Jr wrote: https://bugzilla.kernel.org/show_bug.cgi?id=63961 Kernel version 3.10.15 [1774470.503558] hub 2-1.3:1.0: hub_port_status failed (err = -71) [1774475.483021] hub 2-1.4:1.0: config failed, can't get hub status (err -110) [1774475.483042] BUG: unable to handle kernel NULL pointer dereference at (null) [1774475.483075] IP: [a019b30e] hub_quiesce+0x4e/0xb0 [usbcore] This bug has been fixed in 3.12-rc1 by commit d0308d4b6b02 (usb: fix cleanup after failure in hub_configure()). That commit has not been applied to the -stable branches. I'm beginning to question if this is a bug at all? That's a strange thing to say. If the kernel always gets an error in the same place and under the same circumstances, doesn't that suggest very strongly there is a bug? How else would you expect a bug to show up? As of tonight, my kernel is now panicing this way 100% of the time I turn my new USB3 hub on... :/ Sounds like a bug to me. Have you tried applying the commit mentioned above? If it fixes your problem, you'll know that there really was a bug. 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 1/2](fix) Moved mkdir functions, added MAX_LENGTH MAX_PATH_LENGTH
mkdir() function are now called after successfull function creation. Added inline to gadget_write_string(). 256 hard coded value has been replaced by two defined constants MAX_LENGTH and MAX_PATH_LENGTH Change-Id: Ifcfaf9cf95da6558c176ce3367cd553cea54e871 Signed-off-by: Stanislaw Wadas s.wa...@samsung.com --- include/gadget/gadget.h | 27 --- src/gadget.c| 84 +++ 2 files changed, 57 insertions(+), 54 deletions(-) diff --git a/include/gadget/gadget.h b/include/gadget/gadget.h index 6a32c39..80e9dd6 100644 --- a/include/gadget/gadget.h +++ b/include/gadget/gadget.h @@ -33,13 +33,16 @@ #define DEFAULT_UDCNULL #define LANG_US_ENG0x0409 +#define MAX_LENGTH 256 +#define MAX_PATH_LENGTH 256 + /** * @struct state * @brief State of the gadget devices in the system */ struct state { - char path[256]; + char path[MAX_PATH_LENGTH]; TAILQ_HEAD(ghead, gadget) gadgets; }; @@ -51,8 +54,8 @@ struct state struct gadget { char name[40]; - char path[256]; - char udc[256]; + char path[MAX_PATH_LENGTH]; + char udc[MAX_LENGTH]; int dclass; int dsubclass; int dproto; @@ -61,9 +64,9 @@ struct gadget int bcdusb; int product; int vendor; - char str_ser[256]; - char str_mnf[256]; - char str_prd[256]; + char str_ser[MAX_LENGTH]; + char str_mnf[MAX_LENGTH]; + char str_prd[MAX_LENGTH]; TAILQ_ENTRY(gadget) gnode; TAILQ_HEAD(chead, config) configs; TAILQ_HEAD(fhead, function) functions; @@ -81,10 +84,10 @@ struct config struct gadget *parent; char name[40]; - char path[256]; + char path[MAX_PATH_LENGTH]; int maxpower; int bmattrs; - char str_cfg[256]; + char str_cfg[MAX_LENGTH]; }; /** @@ -136,7 +139,7 @@ struct serial_attrs { struct net_attrs { struct ether_addr dev_addr; struct ether_addr host_addr; - char ifname[256]; + char ifname[MAX_LENGTH]; int qmult; }; @@ -145,7 +148,7 @@ struct net_attrs { * @brief Attributes for the phonet USB function */ struct phonet_attrs { - char ifname[256]; + char ifname[MAX_LENGTH]; }; /** @@ -168,7 +171,7 @@ struct function struct gadget *parent; char name[40]; - char path[256]; + char path[MAX_PATH_LENGTH]; enum function_type type; union attrs attr; @@ -187,7 +190,7 @@ struct binding struct function *target; char name[40]; - char path[256]; + char path[MAX_PATH_LENGTH]; }; /* Library init and cleanup */ diff --git a/src/gadget.c b/src/gadget.c index 83b8b62..faed675 100644 --- a/src/gadget.c +++ b/src/gadget.c @@ -82,7 +82,7 @@ static int file_select(const struct dirent *dent) static char *gadget_read_buf(char *path, char *name, char *file, char *buf) { - char p[256]; + char p[MAX_LENGTH]; FILE *fp; char *ret = NULL; @@ -92,7 +92,7 @@ static char *gadget_read_buf(char *path, char *name, char *file, char *buf) if (!fp) goto out; - ret = fgets(buf, 256, fp); + ret = fgets(buf, MAX_LENGTH, fp); fclose(fp); @@ -102,7 +102,7 @@ out: static int gadget_read_int(char *path, char *name, char *file, int base) { - char buf[256]; + char buf[MAX_LENGTH]; if (gadget_read_buf(path, name, file, buf)) return strtol(buf, NULL, base); @@ -125,7 +125,7 @@ static void gadget_read_string(char *path, char *name, char *file, char *buf) static void gadget_write_buf(char *path, char *name, char *file, char *buf) { - char p[256]; + char p[MAX_LENGTH]; FILE *fp; sprintf(p, %s/%s/%s, path, name, file); @@ -143,7 +143,7 @@ static void gadget_write_buf(char *path, char *name, char *file, char *buf) static void gadget_write_int(char *path, char *name, char *file, int value, char *str) { - char buf[256]; + char buf[MAX_LENGTH]; sprintf(buf, str, value); gadget_write_buf(path, name, file, buf); @@ -153,7 +153,7 @@ static void gadget_write_int(char *path, char *name, char *file, int value, char #define gadget_write_hex16(p, n, f, v) gadget_write_int(p, n, f, v, 0x%04x\n) #define gadget_write_hex8(p, n, f, v) gadget_write_int(p, n, f, v, 0x%02x\n) -static void gadget_write_string(char *path, char *name, char *file, char *buf) +static inline void gadget_write_string(char *path, char *name, char *file, char *buf) { gadget_write_buf(path, name, file, buf); } @@ -196,7 +196,7 @@ static int gadget_parse_functions(char *path, struct gadget *g) struct function *f; int i, n; struct dirent **dent; - char fpath[256]; + char fpath[MAX_PATH_LENGTH]; sprintf(fpath, %s/%s/functions, path, g-name); @@ -227,7 +227,7 @@
[PATCH 2/2](fix) added fputs() fgets() error handling
Change-Id: I787380dda981c7cee6508a4ff566d7ca9fb273cf Signed-off-by: Stanislaw Wadas s.wa...@samsung.com --- src/gadget.c | 12 +++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/gadget.c b/src/gadget.c index faed675..ff4f3d5 100644 --- a/src/gadget.c +++ b/src/gadget.c @@ -93,6 +93,11 @@ static char *gadget_read_buf(char *path, char *name, char *file, char *buf) goto out; ret = fgets(buf, MAX_LENGTH, fp); + if (ret == NULL) { + ERROR(read error); + fclose(fp); + return ret; + } fclose(fp); @@ -127,6 +132,7 @@ static void gadget_write_buf(char *path, char *name, char *file, char *buf) { char p[MAX_LENGTH]; FILE *fp; + int ret; sprintf(p, %s/%s/%s, path, name, file); @@ -136,7 +142,11 @@ static void gadget_write_buf(char *path, char *name, char *file, char *buf) return; } - fputs(buf, fp); + if (fputs(buf, fp) == EOF) { + ERROR(write error); + fclose(fp); + return; + } fclose(fp); } -- 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 1/2] Moved mkdir functions, added MAX_LENGHT MAX_PATH_LENGHT
On 04.11.2013 15:10, Andrzej Pietrasiewicz wrote: W dniu 04.11.2013 14:55, Stanislaw Wadas pisze: mkdir() function are now called after successfull function creation. Added inline to gadget_write_string(). 256 hard coded value has been replaced by two defined constants MAX_LENGHT and MAX_PATH_LENGHT LENGHT - LENGTH sorry for the typo, corrected patches have been sent Stach Change-Id: Ifcfaf9cf95da6558c176ce3367cd553cea54e871 Signed-off-by: Stanislaw Wadas s.wa...@samsung.com --- include/gadget/gadget.h | 27 --- src/gadget.c| 84 +++ 2 files changed, 57 insertions(+), 54 deletions(-) diff --git a/include/gadget/gadget.h b/include/gadget/gadget.h index 6a32c39..80e9dd6 100644 --- a/include/gadget/gadget.h +++ b/include/gadget/gadget.h @@ -33,13 +33,16 @@ #define DEFAULT_UDCNULL #define LANG_US_ENG0x0409 +#define MAX_LENGHT 256 +#define MAX_PATH_LENGHT 256 + /** * @struct state * @brief State of the gadget devices in the system */ struct state { -char path[256]; +char path[MAX_PATH_LENGHT]; TAILQ_HEAD(ghead, gadget) gadgets; }; @@ -51,8 +54,8 @@ struct state struct gadget { char name[40]; -char path[256]; -char udc[256]; +char path[MAX_PATH_LENGHT]; +char udc[MAX_LENGHT]; int dclass; int dsubclass; int dproto; @@ -61,9 +64,9 @@ struct gadget int bcdusb; int product; int vendor; -char str_ser[256]; -char str_mnf[256]; -char str_prd[256]; +char str_ser[MAX_LENGHT]; +char str_mnf[MAX_LENGHT]; +char str_prd[MAX_LENGHT]; TAILQ_ENTRY(gadget) gnode; TAILQ_HEAD(chead, config) configs; TAILQ_HEAD(fhead, function) functions; @@ -81,10 +84,10 @@ struct config struct gadget *parent; char name[40]; -char path[256]; +char path[MAX_PATH_LENGHT]; int maxpower; int bmattrs; -char str_cfg[256]; +char str_cfg[MAX_LENGHT]; }; /** @@ -136,7 +139,7 @@ struct serial_attrs { struct net_attrs { struct ether_addr dev_addr; struct ether_addr host_addr; -char ifname[256]; +char ifname[MAX_LENGHT]; int qmult; }; @@ -145,7 +148,7 @@ struct net_attrs { * @brief Attributes for the phonet USB function */ struct phonet_attrs { -char ifname[256]; +char ifname[MAX_LENGHT]; }; /** @@ -168,7 +171,7 @@ struct function struct gadget *parent; char name[40]; -char path[256]; +char path[MAX_PATH_LENGHT]; enum function_type type; union attrs attr; @@ -187,7 +190,7 @@ struct binding struct function *target; char name[40]; -char path[256]; +char path[MAX_PATH_LENGHT]; }; /* Library init and cleanup */ diff --git a/src/gadget.c b/src/gadget.c index 83b8b62..faed675 100644 --- a/src/gadget.c +++ b/src/gadget.c @@ -82,7 +82,7 @@ static int file_select(const struct dirent *dent) static char *gadget_read_buf(char *path, char *name, char *file, char *buf) { -char p[256]; +char p[MAX_LENGHT]; FILE *fp; char *ret = NULL; @@ -92,7 +92,7 @@ static char *gadget_read_buf(char *path, char *name, char *file, char *buf) if (!fp) goto out; -ret = fgets(buf, 256, fp); +ret = fgets(buf, MAX_LENGHT, fp); fclose(fp); @@ -102,7 +102,7 @@ out: static int gadget_read_int(char *path, char *name, char *file, int base) { -char buf[256]; +char buf[MAX_LENGHT]; if (gadget_read_buf(path, name, file, buf)) return strtol(buf, NULL, base); @@ -125,7 +125,7 @@ static void gadget_read_string(char *path, char *name, char *file, char *buf) static void gadget_write_buf(char *path, char *name, char *file, char *buf) { -char p[256]; +char p[MAX_LENGHT]; FILE *fp; sprintf(p, %s/%s/%s, path, name, file); @@ -143,7 +143,7 @@ static void gadget_write_buf(char *path, char *name, char *file, char *buf) static void gadget_write_int(char *path, char *name, char *file, int value, char *str) { -char buf[256]; +char buf[MAX_LENGHT]; sprintf(buf, str, value); gadget_write_buf(path, name, file, buf); @@ -153,7 +153,7 @@ static void gadget_write_int(char *path, char *name, char *file, int value, char #define gadget_write_hex16(p, n, f, v)gadget_write_int(p, n, f, v, 0x%04x\n) #define gadget_write_hex8(p, n, f, v)gadget_write_int(p, n, f, v, 0x%02x\n) -static void gadget_write_string(char *path, char *name, char *file, char *buf) +static inline void gadget_write_string(char *path, char *name, char *file, char *buf) { gadget_write_buf(path, name, file, buf); } @@ -196,7 +196,7 @@ static int gadget_parse_functions(char *path, struct gadget *g) struct function *f; int i, n; struct dirent **dent; -char fpath[256]; +char fpath[MAX_PATH_LENGHT]; sprintf(fpath, %s/%s/functions, path, g-name); @@
Re: USB 3.0 SDR / Ettus Research B200/210
On Mon, 4 Nov 2013, Moritz Fischer wrote: Hi guys, This is my first post to this list, so let me quickly introduce myself. I'm a software engineer for Ettus Research (National Instruments). One of our new products [1] is a USB 3.0 (using Cypress FX3) based SDR that currently ships with a libusb based open source driver integrated in our open source UHD userland driver. Our device comes with ADC/DACs that need high throughput streaming from and to the host. We're using bulk transfers to send data to a Spartan 6 FPGA in the device. As the CPU usage is quite high and the throughput using libusb is not as high as we expect we're currently looking into developing a kernel driver. Profiling showed we're spending quite some time in the kernel when using libusb. A patch was proposed in the last couple of months to reduce kernel overhead for transfers using libusb: http://marc.info/?l=linux-usbm=138046339714340w=2 The patch would need to be finished and all the relevant comments addressed, and libusb might need some changes to match. Still, this seems like it would be easier than writing your own kernel driver. I've started grepping around the tree for an example to steal from and stumbled upon the drivers/usb/usb-skeleton.c file. Can I base a high throughput (streaming) USB 3.0 driver off of this or is this not a good starting point to look at? What do you think you could add to usb-skeleton that isn't already present in usbfs/libusb? They do support streaming. Are there other device drivers to look at that might give me some insight into how to deal with super speed devices using bulk transfers? If there is nothing to look at (yet) I'm happy to work on this and contribute our solution back. There are no drivers specifically meant for SuperSpeed bulk transfers, except for uas. And that is quite different from what you're talking about, because it uses multiple streams (which is not the same thing as streaming, despite the similarity in the names). 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: kernel NULL pointer dereference at (null) - inside hub_disconnect
On Monday, November 04, 2013 3:07:18 PM Alan Stern wrote: On Mon, 4 Nov 2013, Luke-Jr wrote: On Tuesday, October 29, 2013 2:39:14 PM Alan Stern wrote: On Mon, 28 Oct 2013, Luke-Jr wrote: https://bugzilla.kernel.org/show_bug.cgi?id=63961 Kernel version 3.10.15 [1774470.503558] hub 2-1.3:1.0: hub_port_status failed (err = -71) [1774475.483021] hub 2-1.4:1.0: config failed, can't get hub status (err -110) [1774475.483042] BUG: unable to handle kernel NULL pointer dereference at (null) [1774475.483075] IP: [a019b30e] hub_quiesce+0x4e/0xb0 [usbcore] This bug has been fixed in 3.12-rc1 by commit d0308d4b6b02 (usb: fix cleanup after failure in hub_configure()). That commit has not been applied to the -stable branches. I'm beginning to question if this is a bug at all? That's a strange thing to say. If the kernel always gets an error in the same place and under the same circumstances, doesn't that suggest very strongly there is a bug? How else would you expect a bug to show up? As of tonight, my kernel is now panicing this way 100% of the time I turn my new USB3 hub on... :/ Sounds like a bug to me. Have you tried applying the commit mentioned above? If it fixes your problem, you'll know that there really was a bug. Perhaps I phrased that wrong: I suspect this is a hardware issue or firmware bug, triggering bad error handling in Linux. After upgrading to 3.12, Linux indeed survives the hub being plugged in, and the hub is usable, but I still see various errors in dmesg. Luke -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] usb: xhci: Simplify the way the TRB_CYCLE bit is set on the first trb
Updating the TRB_CYCLE bit in the first trb has to be done after all the subsequent trb have been written. The code to do this was overly complicated. When initially writing the start_trb invert its TRB_CYCLE bit. In giveback_first_trb() invert the TRB_CYCLE bit again. Tested with a USB keyboard and the smsc95xx ethernet driver. Signed-off-by: David Laight david.lai...@aculab.com --- I hope this patch (and the others I've sent recently) are properly formatted. They are the first Linux patches I've written. I think this one depends on the earlier s/1/TRB_CYCLE/ change. David drivers/usb/host/xhci-ring.c | 68 +++- 1 file changed, 23 insertions(+), 45 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 408978b..d0ef8b8 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -3077,7 +3077,7 @@ static void check_trb_math(struct urb *urb, int num_trbs, int running_total) } static void giveback_first_trb(struct xhci_hcd *xhci, int slot_id, - unsigned int ep_index, unsigned int stream_id, int start_cycle, + unsigned int ep_index, unsigned int stream_id, struct xhci_generic_trb *start_trb) { /* @@ -3085,10 +3085,7 @@ static void giveback_first_trb(struct xhci_hcd *xhci, int slot_id, * isn't reordered. */ wmb(); - if (start_cycle) - start_trb-field[3] |= cpu_to_le32(start_cycle); - else - start_trb-field[3] = cpu_to_le32(~TRB_CYCLE); + start_trb-field[3] ^= cpu_to_le32(TRB_CYCLE); xhci_ring_ep_doorbell(xhci, slot_id, ep_index, stream_id); } @@ -3191,12 +3188,11 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, int num_sgs; int trb_buff_len, this_sg_len, running_total; unsigned int total_packet_count; - bool first_trb; + u32 trb_cycle_invert; u64 addr; bool more_trbs_coming; struct xhci_generic_trb *start_trb; - int start_cycle; ep_ring = xhci_urb_to_transfer_ring(xhci, urb); if (!ep_ring) @@ -3222,7 +3218,6 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, * state may change as we enqueue the other TRBs, so save it too. */ start_trb = ep_ring-enqueue-generic; - start_cycle = ep_ring-cycle_state; running_total = 0; /* @@ -3242,20 +3237,17 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, if (trb_buff_len urb-transfer_buffer_length) trb_buff_len = urb-transfer_buffer_length; - first_trb = true; + trb_cycle_invert = TRB_CYCLE; /* Queue the first TRB, even if it's zero-length */ do { u32 field = 0; u32 length_field = 0; u32 remainder = 0; + field |= ep_ring-cycle_state; /* Don't change the cycle bit of the first TRB until later */ - if (first_trb) { - first_trb = false; - if (start_cycle == 0) - field |= TRB_CYCLE; - } else - field |= ep_ring-cycle_state; + field ^= trb_cycle_invert; + trb_cycle_invert = 0; /* Chain all the TRBs together; clear the chain bit in the last * TRB to indicate it's the last TRB in the chain. @@ -3330,8 +3322,7 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, } while (running_total urb-transfer_buffer_length); check_trb_math(urb, num_trbs, running_total); - giveback_first_trb(xhci, slot_id, ep_index, urb-stream_id, - start_cycle, start_trb); + giveback_first_trb(xhci, slot_id, ep_index, urb-stream_id, start_trb); return 0; } @@ -3344,9 +3335,8 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, struct xhci_td *td; int num_trbs; struct xhci_generic_trb *start_trb; - bool first_trb; + u32 trb_cycle_invert; bool more_trbs_coming; - int start_cycle; u32 field, length_field; int running_total, trb_buff_len, ret; @@ -3393,7 +3383,6 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, * state may change as we enqueue the other TRBs, so save it too. */ start_trb = ep_ring-enqueue-generic; - start_cycle = ep_ring-cycle_state; running_total = 0; total_packet_count = DIV_ROUND_UP(urb-transfer_buffer_length, @@ -3405,20 +3394,17 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, if (trb_buff_len urb-transfer_buffer_length) trb_buff_len = urb-transfer_buffer_length; - first_trb = true; + trb_cycle_invert = TRB_CYCLE; /* Queue the first
Re: Large USB HID transfers
On Fri, Nov 1, 2013 at 5:04 PM, Alan Stern st...@rowland.harvard.edu wrote: On Fri, 1 Nov 2013, Cliff Brake wrote: On Thu, Oct 31, 2013 at 2:25 PM, Alan Stern st...@rowland.harvard.edu wrote: What host controller driver are you using? Its the USB EHCI host in the TI DM3730, so it uses the drivers/usb/host/ehci-omap.c driver. You can find out exactly what part of the kernel is responsible for interrupt delays by using the irqsoff tracer. See Documentation/trace/ftrace.txt for details about how to use it. I captured a trace here: http://bec-systems.com/usb-trace.txt Still working to decode it -- any suggestions are welcome. As far as I can tell, the big blockage occurs when the machine has to analyze an input report from which it extracts 767 fields and ends up calling hid_process_event about 2300 times. Since each call takes around 60-80 microseconds, you end up with a very large latency. Why on earth are you using such enormous HID reports? The consumer device we are interfacing with only supports HID transfers. Since we are trying to transfer large amounts of data, we need to send a lot of packets, as the average HID packet size is only ~700 bytes. Its a very slow and inefficient mechanism, but its the only way to interface with this device if the linux system is the USB host. We have the same system running on a older PXA270 version of the product (vs the current TI DM3730). It has an older OHCI 12Mbit USB host controller (vs the current TI EHCI controller). We have _not_ experienced these types of latencies with the older PXA270 product. This may be another indication the problem lies in the TI EHCI controller driver, but its odd we have not seen any issues with other peripherals. Will be digging into it more today ... Thanks, Cliff -- = http://bec-systems.com -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: kernel NULL pointer dereference at (null) - inside hub_disconnect
On Mon, 4 Nov 2013, Luke-Jr wrote: Perhaps I phrased that wrong: I suspect this is a hardware issue or firmware bug, triggering bad error handling in Linux. After upgrading to 3.12, Linux indeed survives the hub being plugged in, and the hub is usable, but I still see various errors in dmesg. What errors? Alan Stern -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/2](fix) added fputs() fgets() error handling
On Mon, Nov 04, 2013 at 04:09:39PM +0100, Stanislaw Wadas wrote: Change-Id: I787380dda981c7cee6508a4ff566d7ca9fb273cf Signed-off-by: Stanislaw Wadas s.wa...@samsung.com Need a commit log entry for this one. Can you please follow kernel conventions when posting/reposting? Submit the updated series with a version and specify what the patch is against. If we're going to review these on linux-usb, especially, it's important to separate them out. Should be [PATCH v2 2/2] libusbg: added fputs()/fgets() error handling For libusbg I'd like to see the changelog over revisions of a patch being reviewed under the --- marker line in your commit log entry. e.g. - Subject: [PATCH v2 2/2] libusbg: added fputs()/fgets() error handling This patch adds foo using the bar implementation. This is need because of baz. Signed-off-by: Stanislaw Wadas s.wa...@samsung.com --- Changes since v1: - fixed typos in MAX_LENGTH thoughout src/gadget.c | 12 +++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/gadget.c b/src/gadget.c ... -- --- src/gadget.c | 12 +++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/gadget.c b/src/gadget.c index faed675..ff4f3d5 100644 --- a/src/gadget.c +++ b/src/gadget.c @@ -93,6 +93,11 @@ static char *gadget_read_buf(char *path, char *name, char *file, char *buf) goto out; ret = fgets(buf, MAX_LENGTH, fp); + if (ret == NULL) { + ERROR(read error); + fclose(fp); + return ret; + } Kernel coding style in this project, please. Please correct the indentation throughout. I'll add a copy of this in the project to make it clear. -Matt fclose(fp); @@ -127,6 +132,7 @@ static void gadget_write_buf(char *path, char *name, char *file, char *buf) { char p[MAX_LENGTH]; FILE *fp; + int ret; sprintf(p, %s/%s/%s, path, name, file); @@ -136,7 +142,11 @@ static void gadget_write_buf(char *path, char *name, char *file, char *buf) return; } - fputs(buf, fp); + if (fputs(buf, fp) == EOF) { + ERROR(write error); + fclose(fp); + return; + } fclose(fp); } -- 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: kernel NULL pointer dereference at (null) - inside hub_disconnect
On Monday, November 04, 2013 4:22:04 PM Alan Stern wrote: On Mon, 4 Nov 2013, Luke-Jr wrote: Perhaps I phrased that wrong: I suspect this is a hardware issue or firmware bug, triggering bad error handling in Linux. After upgrading to 3.12, Linux indeed survives the hub being plugged in, and the hub is usable, but I still see various errors in dmesg. What errors? [33454.079555] usb 2-1: Parent hub missing LPM exit latency info. Power management will be impacted. [33454.080514] xhci_hcd :03:00.0: xHCI xhci_drop_endpoint called with disabled ep 88006e5cfd80 [33436.081842] hub 2-1:1.0: USB hub found [33436.082326] hub 2-1:1.0: 4 ports detected [33436.284763] hub 2-1:1.0: hub_port_status failed (err = -71) [33436.285139] xhci_hcd :03:00.0: URB transfer length is wrong, xHC issue? req. len = 4, act. len = 4294967292 [33436.285156] hub 2-1:1.0: hub_port_status failed (err = 0) [33436.285399] hub 2-1:1.0: hub_port_status failed (err = -71) [33436.285629] hub 2-1:1.0: hub_port_status failed (err = -71) -- To unsubscribe from this list: send the line unsubscribe 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: libusbg clean up and error handling
On Mon, Nov 04, 2013 at 02:55:46PM +0100, Stanislaw Wadas wrote: In reference to the message sent by Andrzej Pietrasiewicz (about libusbg (formerly libgadget)) I would like to propose some changes to libusbg. Along the lines in my other reply, it would be preferred if you could send this type of cover letter using the git send-email style --cover-letter as part 0/2 with an overview of the two part series. Thanks, Matt -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] usb: gadget: mass storage: fix return of delayed status
Mass storage gadget returns DELAYED_STATUS in stead of USB_GADGET_DELAYED_STATUS while handling bulk reset request. Since peripheral driver uses USB_GADGET_DELAYED_STATUS for delayed status handling, therefore replace DELAYED_STATUS by USB_GADGET_DELAYED_STATUS in mass storage driver. Since, DELAYED_STATUS and hence EP0_BUFSIZE will no longer be used now, so remove them. Signed-off-by: Pratyush Anand pratyush.an...@st.com Cc: Felipe Balbi ba...@ti.com Cc: Paul Zimmerman paul.zimmer...@synopsys.com Cc: Alan Stern st...@rowland.harvard.edu --- drivers/usb/gadget/f_mass_storage.c | 2 +- drivers/usb/gadget/storage_common.c | 4 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index a01d7d3..f4b1547 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -536,7 +536,7 @@ static int fsg_setup(struct usb_function *f, */ DBG(fsg, bulk reset request\n); raise_exception(fsg-common, FSG_STATE_RESET); - return DELAYED_STATUS; + return USB_GADGET_DELAYED_STATUS; case US_BULK_GET_MAX_LUN: if (ctrl-bRequestType != diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c index 08a1a32..2dada1b 100644 --- a/drivers/usb/gadget/storage_common.c +++ b/drivers/usb/gadget/storage_common.c @@ -154,10 +154,6 @@ static inline struct fsg_lun *fsg_lun_from_dev(struct device *dev) } -/* Big enough to hold our biggest descriptor */ -#define EP0_BUFSIZE256 -#define DELAYED_STATUS (EP0_BUFSIZE + 999) /* An impossibly large value */ - #ifdef CONFIG_USB_GADGET_DEBUG_FILES static unsigned int fsg_num_buffers = CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS; -- 1.8.1.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: khubd timed out on ep0in len=0/64 with 3.4 kernel
Hi I'm attaching dmesg with old_scheme_first=1 and CONFIG_USB_STORAGE_DEBUG enabled. I compiled code with old_scheme_first set to 1. I see that it doesn't do get descriptor early in the loop so it doesn't run into khubd time out. But as I mentioned earlier usb-storage runs into some sort of error and resets the device 20s later it was first initialized. Thanks for looking. [1.787606] usb-storage: *** thread sleeping. [ 22.816061] usb-storage: command_abort called [ 22.816066] usb-storage: usb_stor_stop_transport called [ 22.816068] usb-storage: -- cancelling URB [ 22.816117] usb-storage: Status code -104; transferred 0/31 [ 22.816120] usb-storage: -- transfer cancelled [ 22.816122] usb-storage: Bulk command transfer result=4 [ 22.816125] usb-storage: -- command was aborted [ 22.816129] usb-storage: usb_stor_pre_reset [ 22.928057] usb 1-3: reset high speed USB device using ehci_hcd and address 2 [ 22.928062] usb 1-3: old_scheme_first 1 USE_NEW_SCHEME 0 retry_counter 0 [ 22.949263] usb-storage: usb_stor_post_reset [ 22.949270] usb-storage: usb_reset_device returns 0 [ 22.949274] usb-storage: scsi command aborted On Sun, Nov 3, 2013 at 8:22 AM, Alan Stern st...@rowland.harvard.edu wrote: On Sat, 2 Nov 2013, Prasad Koya wrote: Hi I didn't have luck reproducing with both CONFIG_USB_DEBUG and CONFIG_USB_STORAGE_DEBUG. I could reproduce with each of them enabled separately. Am attaching the whole dmesg of both as zip files. If I should send them in different format, please let me know. I didn't see anything warnings or errors with USB_STORAGE_DEBUG enabled. The USB in question is usb 1-3 on hub 1 and bus 1. I see no errors or warnings in that 5s timeout. Am trying with both 3.4 kernel and our older 2.6.32 kernel based images on bunch of setups. It looks like you didn't use usbcore.old_scheme_first=1. Alan Stern dmesg_config_usb_storage_old_scheme_first.gz Description: GNU Zip compressed data
Re: Large USB HID transfers
On Mon, 4 Nov 2013, Cliff Brake wrote: As far as I can tell, the big blockage occurs when the machine has to analyze an input report from which it extracts 767 fields and ends up calling hid_process_event about 2300 times. Since each call takes around 60-80 microseconds, you end up with a very large latency. Why on earth are you using such enormous HID reports? The consumer device we are interfacing with only supports HID transfers. Since we are trying to transfer large amounts of data, we need to send a lot of packets, as the average HID packet size is only ~700 bytes. Its a very slow and inefficient mechanism, but its the only way to interface with this device if the linux system is the USB host. I think your real problem here is the slow and inefficient. HID packets are encoded in a way that allows great flexibility and permits a large number of values to be stored in a single packet. All of this adds a good deal of processing overhead. The HID format is not well suited for efficient transfers of lots of data. How would things differ if the USB host were something else? We have the same system running on a older PXA270 version of the product (vs the current TI DM3730). It has an older OHCI 12Mbit USB host controller (vs the current TI EHCI controller). We have _not_ experienced these types of latencies with the older PXA270 product. This may be another indication the problem lies in the TI EHCI controller driver, but its odd we have not seen any issues with other peripherals. More likely it's an indication that you aren't transferring such large amounts of data with the older host. The trace shows very clearly that the lion's share of the overhead was not in the EHCI controller driver; it was in the HID processing. Put it this way: For each packet, the EHCI controller driver required less than 0.5 ms for processing, whereas the HID layer required more than 60 ms. 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: CSW endpoint status returned STALL after BOT MSC Reset
On Sat, Nov 02, 2013 at 04:18:05AM +0800, Paul Zimmerman wrote: From: Alan Stern Sent: Friday, November 01, 2013 7:09 AM Now DELAYED_STATUS isn't used anywhere. You should add the following hunk to this patch: Index: usb-3.12/drivers/usb/gadget/storage_common.c === --- usb-3.12.orig/drivers/usb/gadget/storage_common.c +++ usb-3.12/drivers/usb/gadget/storage_common.c @@ -156,7 +156,6 @@ static inline struct fsg_lun *fsg_lun_fr /* Big enough to hold our biggest descriptor */ #define EP0_BUFSIZE256 -#define DELAYED_STATUS (EP0_BUFSIZE + 999) /* An impossibly large value */ #ifdef CONFIG_USB_GADGET_DEBUG_FILES And after that, EP0_BUFSIZE isn't used anywhere that I can see. So I think that should be: --- usb-3.12.orig/drivers/usb/gadget/storage_common.c +++ usb-3.12/drivers/usb/gadget/storage_common.c @@ -156,7 +156,3 @@ static inline struct fsg_lun *fsg_lun_fr -/* Big enough to hold our biggest descriptor */ -#define EP0_BUFSIZE 256 -#define DELAYED_STATUS (EP0_BUFSIZE + 999) /* An impossibly large value */ - Ok. I will send a patch with the above hunk. Regards Pratyush #ifdef CONFIG_USB_GADGET_DEBUG_FILES -- 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: [PATCH 2/2] added fputs() fgets() error handling
2013/11/4 Stanislaw Wadas: @@ -127,6 +132,7 @@ static void gadget_write_buf(char *path, char *name, char *file, char *buf) { char p[MAX_LENGHT]; FILE *fp; + int ret; this new variable isn't used in the hunk that follows: sprintf(p, %s/%s/%s, path, name, file); @@ -136,7 +142,11 @@ static void gadget_write_buf(char *path, char *name, char *file, char *buf) return; } - fputs(buf, fp); + if (fputs(buf, fp) == EOF) { + ERROR(write error); + fclose(fp); + return; + } fclose(fp); } -- -- Daniele Forsi -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb: musb: dsps: polling ID pin status only in otg mode
On 10/30/2013 03:38 PM, Bin Liu wrote: Only start the otg_timer in dual role mode; otherwise in peripheral mode when musb is disconnected from the host port, otg_timer starts and continuously toggles the session, which causes VBUS pulse. Hmm. Okay, so one piece of the pulsing should be gone since 24616eb (usb: musb: dsps: run the timer only on OTG systems). Now you have still the pulsing in device only mode coming from the irq routine itself. It would be nice if we could get rid of it but then probably something else fails… Acked-by: Sebastian Andrzej Siewior bige...@linutronix.de Signed-off-by: Bin Liu b-...@ti.com Sebastian -- To unsubscribe from this list: send the line unsubscribe 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: kernel NULL pointer dereference at (null) - inside hub_disconnect
On Mon, 4 Nov 2013, Luke-Jr wrote: On Monday, November 04, 2013 4:22:04 PM Alan Stern wrote: On Mon, 4 Nov 2013, Luke-Jr wrote: Perhaps I phrased that wrong: I suspect this is a hardware issue or firmware bug, triggering bad error handling in Linux. After upgrading to 3.12, Linux indeed survives the hub being plugged in, and the hub is usable, but I still see various errors in dmesg. What errors? [33454.079555] usb 2-1: Parent hub missing LPM exit latency info. Power management will be impacted. This was fixed by commit 9df89d85b407 (usbcore: set lpm_capable field for LPM capable root hubs). I don't know why that commit never got into the 3.12 kernel. Maybe the description didn't explain clearly that it fixed a bug. In any case, if you want to add that commit to your own kernel, you can find it here: https://git.kernel.org/cgit/linux/kernel/git/gregkh/usb.git/commit?id=9df89d85b407690afa46ddfbccc80bec6869971d [33454.080514] xhci_hcd :03:00.0: xHCI xhci_drop_endpoint called with disabled ep 88006e5cfd80 That's just a warning, not an error. [33436.081842] hub 2-1:1.0: USB hub found [33436.082326] hub 2-1:1.0: 4 ports detected [33436.284763] hub 2-1:1.0: hub_port_status failed (err = -71) This indicates that your hub had some sort of problem communicating with the computer. [33436.285139] xhci_hcd :03:00.0: URB transfer length is wrong, xHC issue? req. len = 4, act. len = 4294967292 That is a genuine bug. At least, the bogus value for the actual len is. The error itself probably arose because of the communication failure above. [33436.285156] hub 2-1:1.0: hub_port_status failed (err = 0) That also looks rather weird. err = 0 shouldn't indicate a failure. [33436.285399] hub 2-1:1.0: hub_port_status failed (err = -71) [33436.285629] hub 2-1:1.0: hub_port_status failed (err = -71) More communication failures. 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: khubd timed out on ep0in len=0/64 with 3.4 kernel
On Mon, 4 Nov 2013, Prasad Koya wrote: Hi I'm attaching dmesg with old_scheme_first=1 and CONFIG_USB_STORAGE_DEBUG enabled. I compiled code with old_scheme_first set to 1. I see that it doesn't do get descriptor early in the loop so it doesn't run into khubd time out. But as I mentioned earlier usb-storage runs into some sort of error and resets the device 20s later it was first initialized. Thanks for looking. [1.787606] usb-storage: *** thread sleeping. [ 22.816061] usb-storage: command_abort called I need to see the earlier part of the log -- that's when the problem occurred. By the time of the reset, it's already too late. 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: khubd timed out on ep0in len=0/64 with 3.4 kernel
On Mon, 4 Nov 2013, Alan Stern wrote: On Mon, 4 Nov 2013, Prasad Koya wrote: Hi I'm attaching dmesg with old_scheme_first=1 and CONFIG_USB_STORAGE_DEBUG enabled. I compiled code with old_scheme_first set to 1. I see that it doesn't do get descriptor early in the loop so it doesn't run into khubd time out. But as I mentioned earlier usb-storage runs into some sort of error and resets the device 20s later it was first initialized. Thanks for looking. [1.787606] usb-storage: *** thread sleeping. [ 22.816061] usb-storage: command_abort called I need to see the earlier part of the log -- that's when the problem occurred. By the time of the reset, it's already too late. Sorry -- I wrote that before noticing you had attached the entire log. The log shows that the SMART eUSB device failed to respond to the initial INQUIRY command. Face it; that device simply is buggy. If you can't replace it, you will have to live with its shortcomings. Alan Stern -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3] kconfig/symbol.c: handle choice_values that depend on 'm' symbols
* Dirk Gouders | 2013-11-01 00:39:46 [+0100]: This patch sets choice_values' visibility that depend on symbols set to 'm' to 'n' if the corresponding choice is set to 'y'. This makes them disappear from the choice list and will also cause the choice_values' value set to 'n' in sym_calc_value() and as a result they are written as not set to the resulting .config file. Reported-by: Sebastian Andrzej Siewior bige...@linutronix.de Still solves the issue for me :) Signed-off-by: Dirk Gouders d...@gouders.net Sebastian -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb: musb: dsps: polling ID pin status only in otg mode
Sebastian, On Mon, Nov 4, 2013 at 11:13 AM, Sebastian Andrzej Siewior bige...@linutronix.de wrote: On 10/30/2013 03:38 PM, Bin Liu wrote: Only start the otg_timer in dual role mode; otherwise in peripheral mode when musb is disconnected from the host port, otg_timer starts and continuously toggles the session, which causes VBUS pulse. Hmm. Okay, so one piece of the pulsing should be gone since 24616eb (usb: musb: dsps: run the timer only on OTG systems). Now you have still the pulsing in device only mode coming from the irq routine itself. It would be nice if we could get rid of it but then probably something else fails… I don't think the problem is in anywhere else other than where this patch tries to fix. The pulses only start to happen after MUSB in device mode got disconnected from host, due to otg_timer is set in dsps_interrupt() regardless the role mode is. Regards, -Bin. Acked-by: Sebastian Andrzej Siewior bige...@linutronix.de Signed-off-by: Bin Liu b-...@ti.com Sebastian -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb: musb: dsps: polling ID pin status only in otg mode
Sebastian, On Mon, Nov 4, 2013 at 11:40 AM, Bin Liu binml...@gmail.com wrote: Sebastian, On Mon, Nov 4, 2013 at 11:13 AM, Sebastian Andrzej Siewior bige...@linutronix.de wrote: On 10/30/2013 03:38 PM, Bin Liu wrote: Only start the otg_timer in dual role mode; otherwise in peripheral mode when musb is disconnected from the host port, otg_timer starts and continuously toggles the session, which causes VBUS pulse. Hmm. Okay, so one piece of the pulsing should be gone since 24616eb (usb: musb: dsps: run the timer only on OTG systems). Now you have still the pulsing in device only mode coming from the irq routine itself. It would be nice if we could get rid of it but then probably something else fails… I don't think the problem is in anywhere else other than where this patch tries to fix. The pulses only start to happen after MUSB in device mode got disconnected from host, due to otg_timer is set in dsps_interrupt() regardless the role mode is. Sorry, please ignore my message above. I misinterpreted your response. Yeah, probably not easy to get rid of starting otg_timer in dsps_interrupt(), otg mode still needs it. -Bin. Regards, -Bin. Acked-by: Sebastian Andrzej Siewior bige...@linutronix.de Signed-off-by: Bin Liu b-...@ti.com Sebastian -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb: musb: dsps: polling ID pin status only in otg mode
On 11/04/2013 06:43 PM, Bin Liu wrote: Sebastian, Hi Bin, Sorry, please ignore my message above. I misinterpreted your response. Yeah, probably not easy to get rid of starting otg_timer in dsps_interrupt(), otg mode still needs it. Yes. It may work with the try_idle() thingy that we have in various places but it probably does not cover everything. So for the time this is probably the best thing we can do. -Bin. Sebastian -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] USB: pl2303: fixed handling of CS5 setting
This patch fixes the CS5 setting on the PL2303 USB-to-serial devices. CS5 has a value of 0 and the CSIZE setting has been skipped altogether by the enclosing if. Tested on 3.11.6 and the scope shows the correct output after the fix has been applied. Tagged to be added to stable, because it fixes a user visible driver bug and is simple enough to backport easily. Cc: sta...@vger.kernel.org Signed-off-by: Colin Leitner colin.leit...@gmail.com --- drivers/usb/serial/pl2303.c | 30 ++ 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index 1e6de4c..1e3318d 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c @@ -361,23 +361,21 @@ static void pl2303_set_termios(struct tty_struct *tty, 0, 0, buf, 7, 100); dev_dbg(port-dev, 0xa1:0x21:0:0 %d - %7ph\n, i, buf); - if (C_CSIZE(tty)) { - switch (C_CSIZE(tty)) { - case CS5: - buf[6] = 5; - break; - case CS6: - buf[6] = 6; - break; - case CS7: - buf[6] = 7; - break; - default: - case CS8: - buf[6] = 8; - } - dev_dbg(port-dev, data bits = %d\n, buf[6]); + switch (C_CSIZE(tty)) { + case CS5: + buf[6] = 5; + break; + case CS6: + buf[6] = 6; + break; + case CS7: + buf[6] = 7; + break; + default: + case CS8: + buf[6] = 8; } + dev_dbg(port-dev, data bits = %d\n, buf[6]); /* For reference buf[0]:buf[3] baud rate value */ pl2303_encode_baudrate(tty, port, buf[0]); -- 1.7.10.4 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] USB: serial: option: blacklist intf1 for Huawei E173s-6
Hello. On 11/04/2013 04:01 PM, Gustavo Zacarias wrote: Interface 1 on this device isn't for option to bind to otherwise an oops on usb_wwan with log flooding will happen: tty_release: ttyUSB1: read/write wait queue active! And it doesn't seem to respond to QMI if it's added to qmi_wwan so don't add it there. Signed-off-by: Gustavo Zacarias gust...@zacarias.com.ar --- drivers/usb/serial/option.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index acaee06..b5d3b33 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c @@ -81,6 +81,7 @@ static void option_instat_callback(struct urb *urb); #define HUAWEI_VENDOR_ID 0x12D1 #define HUAWEI_PRODUCT_E173 0x140C +#define HUAWEI_PRODUCT_E173S 0x1C07 I think the #define's are sorted by number... #define HUAWEI_PRODUCT_E1750 0x1406 #define HUAWEI_PRODUCT_K4505 0x1464 #define HUAWEI_PRODUCT_K3765 0x1465 WBR, Sergei -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/2] added fputs() fgets() error handling
Hello. On 11/04/2013 04:55 PM, Stanislaw Wadas wrote: Change-Id: I787380dda981c7cee6508a4ff566d7ca9fb273cf This line shouldn't be present in the upstream patches. Signed-off-by: Stanislaw Wadas s.wa...@samsung.com --- src/gadget.c | 12 +++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/gadget.c b/src/gadget.c index faed675..ff4f3d5 100644 --- a/src/gadget.c +++ b/src/gadget.c @@ -93,6 +93,11 @@ static char *gadget_read_buf(char *path, char *name, char *file, char *buf) goto out; ret = fgets(buf, MAX_LENGHT, fp); + if (ret == NULL) { + ERROR(read error); + fclose(fp); + return ret; You should indent the code in the block (by using tab). + } fclose(fp); [...] @@ -136,7 +142,11 @@ static void gadget_write_buf(char *path, char *name, char *file, char *buf) return; } - fputs(buf, fp); + if (fputs(buf, fp) == EOF) { + ERROR(write error); + fclose(fp); + return; + } Same here. WBR, Sergei -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] USB: pl2303: fixed handling of CS5 setting
On Mon, Nov 04, 2013 at 07:40:43PM +0100, Colin Leitner wrote: This patch fixes the CS5 setting on the PL2303 USB-to-serial devices. CS5 has a value of 0 and the CSIZE setting has been skipped altogether by the enclosing if. Tested on 3.11.6 and the scope shows the correct output after the fix has been applied. Tagged to be added to stable, because it fixes a user visible driver bug and is simple enough to backport easily. Thanks! Now it applies cleanly to v3.12. Greg, can you pick this one up for v3.13-rc? The fix could be backported to all stable trees as the bug has been there since pre-git times. Cc: sta...@vger.kernel.org Signed-off-by: Colin Leitner colin.leit...@gmail.com Signed-off-by: Johan Hovold jhov...@gmail.com --- drivers/usb/serial/pl2303.c | 30 ++ 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index 1e6de4c..1e3318d 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c @@ -361,23 +361,21 @@ static void pl2303_set_termios(struct tty_struct *tty, 0, 0, buf, 7, 100); dev_dbg(port-dev, 0xa1:0x21:0:0 %d - %7ph\n, i, buf); - if (C_CSIZE(tty)) { - switch (C_CSIZE(tty)) { - case CS5: - buf[6] = 5; - break; - case CS6: - buf[6] = 6; - break; - case CS7: - buf[6] = 7; - break; - default: - case CS8: - buf[6] = 8; - } - dev_dbg(port-dev, data bits = %d\n, buf[6]); + switch (C_CSIZE(tty)) { + case CS5: + buf[6] = 5; + break; + case CS6: + buf[6] = 6; + break; + case CS7: + buf[6] = 7; + break; + default: + case CS8: + buf[6] = 8; } + dev_dbg(port-dev, data bits = %d\n, buf[6]); /* For reference buf[0]:buf[3] baud rate value */ pl2303_encode_baudrate(tty, port, buf[0]); -- 1.7.10.4 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH net-next 02/13] driver: net: remove unnecessary skb NULL check before calling dev_kfree_skb_irq
From: Govindarajulu Varadarajan govindarajul...@gmail.com Date: Sat, 2 Nov 2013 19:17:43 +0530 @@ -1030,10 +1030,8 @@ static void ni65_xmit_intr(struct net_device *dev,int csr0) } #ifdef XMT_VIA_SKB - if(p-tmd_skb[p-tmdlast]) { - dev_kfree_skb_irq(p-tmd_skb[p-tmdlast]); - p-tmd_skb[p-tmdlast] = NULL; - } + dev_kfree_skb_irq(p-tmd_skb[p-tmdlast]); + p-tmd_skb[p-tmdlast] = NULL; #endif I absolutely disagree with this kind of change. There is a non-trivial cost for NULL'ing out that array entry unconditionally. It's a dirtied cache line and this is in the fast path of TX SKB reclaim of this driver. You've made several changes of this kind. And it sort-of shows that the places that do check for NULL, are getting something in return for that test, namely avoidance of an unnecessary cpu store in the fast path of the driver. I'm throwing away this series, sorry. -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC] Revert sierra_net: keep status interrupt URB active
On Fri, 2013-11-01 at 13:53 +0100, Bjørn Mork wrote: This reverts commit 7b0c5f21f348a66de495868b8df0284e8dfd6bbf. It's not easy to create a driver for all the various firmware bugs out there. This change caused regressions for a number of devices, which started to fail link detection and therefore became completely non-functional. The exact reason is yet unknown, it looks like the affected firmwares might actually need all or some of the additional SYNC messages the patch got rid of. Reverting is not optimal, as it will re-introduce the original problem, but it is currently the only alternative known to fix this issue. Instead, how does the following patch work for you? Dan --- diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c index a79e9d3..dd59d97 100644 --- a/drivers/net/usb/sierra_net.c +++ b/drivers/net/usb/sierra_net.c @@ -163,18 +163,19 @@ struct lsi_umts { #define SIERRA_NET_LSI_UMTS_LEN(sizeof(struct lsi_umts)) #define SIERRA_NET_LSI_UMTS_STATUS_LEN \ (SIERRA_NET_LSI_UMTS_LEN - SIERRA_NET_LSI_COMMON_LEN) /* Forward definitions */ static void sierra_sync_timer(unsigned long syncdata); static int sierra_net_change_mtu(struct net_device *net, int new_mtu); +static int sierra_net_open (struct net_device *net); /* Our own net device operations structure */ static const struct net_device_ops sierra_net_device_ops = { - .ndo_open = usbnet_open, + .ndo_open = sierra_net_open, .ndo_stop = usbnet_stop, .ndo_start_xmit = usbnet_start_xmit, .ndo_tx_timeout = usbnet_tx_timeout, .ndo_change_mtu = sierra_net_change_mtu, .ndo_set_mac_address= eth_mac_addr, .ndo_validate_addr = eth_validate_addr, }; @@ -439,14 +440,15 @@ static void sierra_net_dosync(struct usbnet *dev) netdev_err(dev-net, Send SYNC failed, status %d\n, status); status = sierra_net_send_sync(dev); if (status 0) netdev_err(dev-net, Send SYNC failed, status %d\n, status); +printk(KERN_INFO %s: sent two SYNC messages\n, __func__); /* Now, start a timer and make sure we get the Restart Indication */ priv-sync_timer.function = sierra_sync_timer; priv-sync_timer.data = (unsigned long) dev; priv-sync_timer.expires = jiffies + SIERRA_NET_SYNCDELAY; add_timer(priv-sync_timer); } @@ -497,31 +499,34 @@ static void sierra_net_kevent(struct work_struct *work) netdev_err(dev-net, %s: Bad packet, received %d, expected %d\n, __func__, len, hh.hdrlen + hh.payload_len.word); kfree(buf); return; } +printk(KERN_INFO %s: received msg 0x%02x len %d\n, __func__, hh.msgid.byte, len); /* Switch on received message types */ switch (hh.msgid.byte) { case SIERRA_NET_HIP_LSI_UMTSID: dev_dbg(dev-udev-dev, LSI for ctx:%d, hh.msgspecific.byte); sierra_net_handle_lsi(dev, buf, hh); break; case SIERRA_NET_HIP_RESTART_ID: +printk(KERN_INFO %s: RESTART received code 0x%02x\n, __func__, hh.msgspecific.byte); dev_dbg(dev-udev-dev, Restart reported: %d, stopping sync timer, hh.msgspecific.byte); /* Got sync resp - stop timer clear mask */ del_timer_sync(priv-sync_timer); clear_bit(SIERRA_NET_TIMER_EXPIRY, priv-kevent_flags); break; case SIERRA_NET_HIP_HSYNC_ID: +printk(KERN_INFO %s: HSYNC received\n, __func__); dev_dbg(dev-udev-dev, SYNC received); err = sierra_net_send_sync(dev); if (err 0) netdev_err(dev-net, Send SYNC failed %d\n, err); break; case SIERRA_NET_HIP_EXTENDEDID: @@ -537,14 +542,15 @@ static void sierra_net_kevent(struct work_struct *work) break; } } kfree(buf); } /* The sync timer bit might be set */ if (test_bit(SIERRA_NET_TIMER_EXPIRY, priv-kevent_flags)) { +printk(KERN_INFO %s: re-sending SYNC\n, __func__);
Re: [PATCH v3] kconfig/symbol.c: handle choice_values that depend on 'm' symbols
Sebastian, All, On 2013-11-04 18:27 +0100, Sebastian Andrzej Siewior spake thusly: * Dirk Gouders | 2013-11-01 00:39:46 [+0100]: This patch sets choice_values' visibility that depend on symbols set to 'm' to 'n' if the corresponding choice is set to 'y'. This makes them disappear from the choice list and will also cause the choice_values' value set to 'n' in sym_calc_value() and as a result they are written as not set to the resulting .config file. Reported-by: Sebastian Andrzej Siewior bige...@linutronix.de Still solves the issue for me :) Should I consider this as: Tested-by: you ? Regards, Yann E. MORIN. -- .-..--.. | Yann E. MORIN | Real-Time Embedded | /\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `.---: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL| v conspiracy. | '--^---^--^' -- To unsubscribe from this list: send the line unsubscribe 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 net-next 0/5] cdc_mbim + qmi_wwan trivial fixes
From: Bjørn Mork bj...@mork.no Date: Fri, 1 Nov 2013 14:18:51 +0100 This series fixes three problems Oliver pointed out during the review of the new huawei_cdc_ncm driver: http://patchwork.ozlabs.org/patch/278903/ That innocent driver only used cdc_mbim as a blueprint, and all the blame should really have gone to me I do have a similar fix for the manage_power issue in the cdc-wdm USB class driver as well. It will be submitted to linux-usb as soon as Greg opens up his mailbox again :-) Looks good, applied, thanks. -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH net v2 2/3] r8152: modify the tx flow
From: hayeswang hayesw...@realtek.com Date: Thu, 31 Oct 2013 13:52:38 +0800 From: David Miller [mailto:da...@davemloft.net] Sent: Thursday, October 31, 2013 5:05 AM From: Hayes Wang hayesw...@realtek.com Date: Wed, 30 Oct 2013 15:13:39 +0800 [...] Basically, your driver will now queue up to 1,000 packets onto this tx_queue list, because that is what tx_queue_len will be for alloc_etherdev() allocated network devices. In my previous reply to you about this patch, I asked you to quantify and study the effects of using a limit of 60. I said that 60 might be too large. You've responded by removing the limit completely, which is exactly the opposite of what I've asked you to do. Why did you do this? Excuse me. My question is that the original code doesn't stop the tx queue either, so I don't understand why it is necessary for this patch. I don't say I wouldn't find the suitable value for the tx queue length. I feel I need some time to think how to find the reasonable value. And I don't hope it influences the submission of the other patches, so I remove it first. Or, may I submit the other two patches first? The more TX work you push into the workqueue handler, the longer the latency for releasing the SKB and releasing all the queues that are waiting for release of that packet. Do you know that sockets, queueing discplines, etc. all rely upon there being a timely release of SKBs once they are successfully transmitted? It must happen at the earliest moment possible that can be reasonable obtained. -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 13/16] usb/gadget: FunctionFS: convert to new function interface with backward compatibility
On Wed, Oct 23 2013, Andrzej Pietrasiewicz wrote: This is required in order to integrate configfs support. f_fs needs to be a separately compiled module and so it needs to use the new interface. Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com Acked-by: Michal Nazarewicz min...@mina86.com @@ -2216,8 +2096,70 @@ static int __ffs_func_bind_do_nums(enum ffs_entity_type type, u8 *valuep, return 0; } -static int ffs_func_bind(struct usb_configuration *c, - struct usb_function *f) +static inline void mutex_lock_if_nonnull(struct mutex *mutex) +{ + if (mutex) + mutex_lock(mutex); +} + +static inline void mutex_unlock_if_nonnull(struct mutex *mutex) +{ + if (mutex) + mutex_unlock(mutex); +} + +#ifndef USB_FFS_INCLUDED +static inline struct f_fs_opts *ffs_do_functionfs_bind(struct usb_function *f, + struct usb_configuration *c) +{ + struct ffs_function *func = ffs_func_from_usb(f); + struct f_fs_opts *ffs_opts = + container_of(f-fi, struct f_fs_opts, func_inst); + int ret; + + ENTER(); + + /* + * Legacy gadget triggers binding in functionfs_ready_callback, + * which already uses locking; taking the same lock here would + * cause a deadlock. + * + * Configfs-enabled gadgets however do need ffs_dev_lock. + */ + mutex_lock_if_nonnull(ffs_dev_lock); + if (!ffs_opts-dev-desc_ready) { + mutex_unlock_if_nonnull(ffs_dev_lock); + return ERR_PTR(-ENODEV); + } + mutex_unlock_if_nonnull(ffs_dev_lock); The *_if_nonnull functions are used only here; it almost seems like it's not worth creating them. Furthermore, the above can be easily rewritten to avoid two unlock call sites: if (ffs_dev_lock) mutex_lock(ffs_dev_lock); ret = ffs_opts-dev-desc_ready ? : - ENODEV; if (ffs_dev_lock) mutex_unlock(ffs_dev_lock); if (ret) return ERR_PTR(ret); + + func-conf = c; + func-gadget = c-cdev-gadget; + + func-ffs = ffs_opts-dev-ffs_data; + ffs_data_get(func-ffs); + + /* + * in drivers/usb/gadget/configfs.c:configfs_composite_bind() + * configurations are bound in sequence with list_for_each_entry, + * in each configuration its functions are bound in sequence + * with list_for_each_entry, so we assume no race condition + * with regard to ffs_opts-bound access + */ + if (!ffs_opts-refcnt) { + ret = functionfs_bind(func-ffs, c-cdev); + if (ret) + return ERR_PTR(ret); + } + ffs_opts-refcnt++; + func-function.strings = ffs_opts-dev-ffs_data-stringtabs; + + return ffs_opts; +} +#endif + +static int _ffs_func_bind(struct usb_configuration *c, + struct usb_function *f) { struct ffs_function *func = ffs_func_from_usb(f); struct ffs_data *ffs = func-ffs; +static struct usb_function_instance *ffs_alloc_inst(void) +{ + struct f_fs_opts *opts; + struct ffs_dev *dev; + int ret = 0; + + opts = kzalloc(sizeof(*opts), GFP_KERNEL); + if (!opts) + return ERR_PTR(-ENOMEM); + + opts-func_inst.free_func_inst = ffs_free_inst; + dev = ffs_alloc_dev(); + if (IS_ERR(dev)) { + ret = PTR_ERR(dev); + goto error; + } + opts-dev = dev; + + mutex_lock(auto_init_lock); + if (auto_init_active do_auto_init) { + kref_init(auto_init_ref); + /* + * ffs_set_acquire_dev_cb(); + * ffs_set_release_dev_cb(); + * ffs_set_ready_cb(); + * ffs_set_closed_cb(); + */ + /* fails if callbacks not set */ Not sure about purpose of the above comments. + ret = functionfs_init(NULL); + if (ret) { + mutex_unlock(auto_init_lock); + goto error; + } + do_init_kref = do_auto_init = false; Instead of doing goto, do: if (!ret) do_init_kref = do_auto_init = false; and then… + } else { + if (do_init_kref) { + kref_init(auto_init_ref); + do_init_kref = false; + } else { + kref_get(auto_init_ref); + } + } + mutex_unlock(auto_init_lock); + + return opts-func_inst; …after the if and mutex_unlock: if (!ret) return opts-func_inst; +error: + ffs_free_dev(opts-dev); + kfree(opts); + return ERR_PTR(ret); +} + +static void ffs_free(struct usb_function *f) +{ + struct ffs_function *func = ffs_func_from_usb(f); + + kfree(func); Why complicate things: kfree(ffs_func_from_usb(f)); +} + +static void
Re: [PATCH 14/16] usb/gadget: g_ffs: convert to new interface of f_fs
On Wed, Oct 23 2013, Andrzej Pietrasiewicz wrote: Prepare for configfs integration. Use the new interface so that f_fs can be made a module. Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- drivers/usb/gadget/Kconfig |1 + drivers/usb/gadget/g_ffs.c | 138 2 files changed, 89 insertions(+), 50 deletions(-) diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 851d864..2234001 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -861,6 +861,7 @@ config USB_GADGETFS config USB_FUNCTIONFS tristate Function Filesystem select USB_LIBCOMPOSITE + select USB_F_FS select USB_FUNCTIONFS_GENERIC if !(USB_FUNCTIONFS_ETH || USB_FUNCTIONFS_RNDIS) help The Function Filesystem (FunctionFS) lets one create USB diff --git a/drivers/usb/gadget/g_ffs.c b/drivers/usb/gadget/g_ffs.c index 0298018..5e7b43a 100644 --- a/drivers/usb/gadget/g_ffs.c +++ b/drivers/usb/gadget/g_ffs.c @@ -13,13 +13,7 @@ #define pr_fmt(fmt) g_ffs: fmt #include linux/module.h -/* - * 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. - */ + #if defined CONFIG_USB_FUNCTIONFS_ETH || defined CONFIG_USB_FUNCTIONFS_RNDIS #include linux/netdevice.h @@ -55,8 +49,7 @@ static struct usb_function *f_rndis; # endif #endif -#define USB_FFS_INCLUDED -#include f_fs.c +#include u_fs.h #define DRIVER_NAME g_ffs #define DRIVER_DESC USB Function Filesystem @@ -140,6 +133,7 @@ static struct usb_gadget_strings *gfs_dev_strings[] = { struct gfs_configuration { struct usb_configuration c; int (*eth)(struct usb_configuration *c); + int num; } gfs_configurations[] = { #ifdef CONFIG_USB_FUNCTIONFS_RNDIS { @@ -162,6 +156,11 @@ struct gfs_configuration { static int gfs_bind(struct usb_composite_dev *cdev); static int gfs_unbind(struct usb_composite_dev *cdev); static int gfs_do_config(struct usb_configuration *c); +static int functionfs_ready_callback(struct ffs_data *ffs); +static void functionfs_closed_callback(struct ffs_data *ffs); +static void *functionfs_acquire_dev_callback(const char *dev_name); +static void functionfs_release_dev_callback(struct ffs_data *ffs_data); + static __refdata struct usb_composite_driver gfs_driver = { .name = DRIVER_NAME, @@ -176,7 +175,22 @@ static DEFINE_MUTEX(gfs_lock); static unsigned int missing_funcs; static bool gfs_registered; static bool gfs_single_func; -static struct ffs_dev **ffs_tab; +static struct usb_function_instance **fi_ffs; +static struct usb_function **f_ffs[] = { +#ifdef CONFIG_USB_FUNCTIONFS_RNDIS + NULL, +#endif + +#ifdef CONFIG_USB_FUNCTIONFS_ETH + NULL, +#endif + +#ifdef CONFIG_USB_FUNCTIONFS_GENERIC + NULL, +#endif +}; + +#define N_CONF ARRAY_SIZE(f_ffs) static int __init gfs_init(void) { @@ -185,32 +199,53 @@ static int __init gfs_init(void) ENTER(); + ffs_set_auto_init(false); + if (func_num 2) { gfs_single_func = true; func_num = 1; } - ffs_tab = kcalloc(func_num, sizeof(ffs_tab), GFP_KERNEL); - if (!ffs_tab) - return -ENOMEM; + for (i = 0; i N_CONF; i++) { + f_ffs[i] = kcalloc(func_num, sizeof(f_ffs[i]), GFP_KERNEL); + if (!f_ffs[i]) { + ret = -ENOMEM; + goto no_func; + } + } Perhaps: f_ffs[0] = kcalloc(func_num * N_CONF, sizeof(*f_ffs), GFP_KERNEL); if (!f_ffs[0]) { ret = -ENOMEM; goto no_func; } for (i = 1; i N_CONF; ++i) f_ffs[i] = f_ffs[0] + i * func_num; + + fi_ffs = kcalloc(func_num, sizeof(fi_ffs), GFP_KERNEL); Missing dereference in sizeof: fi_ffs = kcalloc(func_num, sizeof(*fi_ffs), GFP_KERNEL); + if (!fi_ffs) { + ret = -ENOMEM; + i = N_CONF; i is already N_CONF. + goto no_func; + } for (i = 0; i func_num; i++) { - ffs_tab[i] = ffs_alloc_dev(); - if (IS_ERR(ffs_tab[i])) { - ret = PTR_ERR(ffs_tab[i]); + fi_ffs[i] = usb_get_function_instance(ffs); + if (IS_ERR(fi_ffs[i])) { + ret = PTR_ERR(fi_ffs[i]); goto no_dev; } if (!gfs_single_func) - ffs_tab[i]-name = func_names[i]; + to_f_fs_opts(fi_ffs[i])-dev-name = func_names[i]; } missing_funcs = func_num; -
Re: [PATCH 15/16] usb/gadget: FunctionFS: Remove compatibility layer
On Wed, Oct 23 2013, Andrzej Pietrasiewicz wrote: There are no old function interface users left, so the old interface can be removed. Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com Acked-by: Michal Nazarewicz min...@mina86.com --- drivers/usb/gadget/f_fs.c | 148 +--- drivers/usb/gadget/u_fs.h |2 - include/linux/usb/functionfs.h | 33 - 3 files changed, 2 insertions(+), 181 deletions(-) -- Best regards, _ _ .o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o ..o | Computer Science, Michał “mina86” Nazarewicz(o o) ooo +--m...@google.com--xmpp:min...@jabber.org--ooO--(_)--Ooo-- signature.asc Description: PGP signature
Re: [PATCH 16/16] usb/gadget: FunctionFS: add configfs support
On Wed, Oct 23 2013, Andrzej Pietrasiewicz wrote: Add support for using FunctionFS in configfs-based USB gadgets. Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com Acked-by: Michal Nazarewicz min...@mina86.com -- Best regards, _ _ .o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o ..o | Computer Science, Michał “mina86” Nazarewicz(o o) ooo +--m...@google.com--xmpp:min...@jabber.org--ooO--(_)--Ooo-- signature.asc Description: PGP signature
Re: [PATCH 2/2] added fputs() fgets() error handling
On Mon, Nov 04, 2013 at 02:55:48PM +0100, Stanislaw Wadas wrote: Change-Id: I787380dda981c7cee6508a4ff566d7ca9fb273cf Signed-off-by: Stanislaw Wadas s.wa...@samsung.com --- src/gadget.c | 12 +++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/gadget.c b/src/gadget.c index faed675..ff4f3d5 100644 --- a/src/gadget.c +++ b/src/gadget.c @@ -93,6 +93,11 @@ static char *gadget_read_buf(char *path, char *name, char *file, char *buf) goto out; ret = fgets(buf, MAX_LENGHT, fp); + if (ret == NULL) { + ERROR(read error); + fclose(fp); + return ret; + } What happened to your indentation? :( -- To unsubscribe from this list: send the line unsubscribe 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/4] usb: gadget: move bitflags to the end of usb_gadget struct
This patch moves all bitflags to the end of usb_gadget struct in order to improve readability. Signed-off-by: David Cohen david.a.co...@linux.intel.com --- include/linux/usb/gadget.h | 19 ++- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index 942ef5e053bf..23b3bfd0a842 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -485,6 +485,11 @@ struct usb_gadget_ops { * @max_speed: Maximal speed the UDC can handle. UDC must support this * and all slower speeds. * @state: the state we are now (attached, suspended, configured, etc) + * @name: Identifies the controller hardware type. Used in diagnostics + * and sometimes configuration. + * @dev: Driver model state for this abstract device. + * @out_epnum: last used out ep number + * @in_epnum: last used in ep number * @sg_supported: true if we can handle scatter-gather * @is_otg: True if the USB device port uses a Mini-AB jack, so that the * gadget driver must provide a USB OTG descriptor. @@ -497,11 +502,6 @@ struct usb_gadget_ops { * only supports HNP on a different root port. * @b_hnp_enable: OTG device feature flag, indicating that the A-Host * enabled HNP support. - * @name: Identifies the controller hardware type. Used in diagnostics - * and sometimes configuration. - * @dev: Driver model state for this abstract device. - * @out_epnum: last used out ep number - * @in_epnum: last used in ep number * * Gadgets have a mostly-portable gadget driver implementing device * functions, handling all usb configurations and interfaces. Gadget @@ -530,16 +530,17 @@ struct usb_gadget { enum usb_device_speed speed; enum usb_device_speed max_speed; enum usb_device_state state; + const char *name; + struct device dev; + unsignedout_epnum; + unsignedin_epnum; + unsignedsg_supported:1; unsignedis_otg:1; unsignedis_a_peripheral:1; unsignedb_hnp_enable:1; unsigneda_hnp_support:1; unsigneda_alt_hnp_support:1; - const char *name; - struct device dev; - unsignedout_epnum; - unsignedin_epnum; }; #define work_to_gadget(w) (container_of((w), struct usb_gadget, work)) -- 1.8.4.rc3 -- To unsubscribe from this list: send the line unsubscribe 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 2/4] usb: gadget: add quirk_ep_out_aligned_size field to struct usb_gadget
Due to USB controllers may have different restrictions, usb gadget layer needs to provide a generic way to inform gadget functions to complain with non-standard requirements. This patch adds 'quirk_ep_out_aligned_size' field to struct usb_gadget to inform when controller's epout requires buffer size to be aligned to MaxPacketSize. A helper is also provided to align buffer size when necessary. Signed-off-by: David Cohen david.a.co...@linux.intel.com --- include/linux/usb/gadget.h | 19 +++ 1 file changed, 19 insertions(+) diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index 23b3bfd0a842..260d972489bd 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -442,6 +442,22 @@ static inline void usb_ep_fifo_flush(struct usb_ep *ep) } +static inline size_t usb_ep_align_maxpacketsize(struct usb_ep *ep, size_t len) +{ + int aligned; + + if (ep-desc-bmAttributes USB_ENDPOINT_XFER_INT) + /* +* Interrupt eps don't need max packet size to be power of 2, +* so can't use cheap IS_ALIGNED() macro. +*/ + aligned = !(len % ep-desc-wMaxPacketSize); + else + aligned = IS_ALIGNED(len, ep-desc-wMaxPacketSize); + + return aligned ? len : round_up(len, (size_t)ep-desc-wMaxPacketSize); +} + /*-*/ struct usb_dcd_config_params { @@ -502,6 +518,8 @@ struct usb_gadget_ops { * only supports HNP on a different root port. * @b_hnp_enable: OTG device feature flag, indicating that the A-Host * enabled HNP support. + * @quirk_ep_out_aligned_size: epout requires buffer size to be aligned to + * MaxPacketSize. * * Gadgets have a mostly-portable gadget driver implementing device * functions, handling all usb configurations and interfaces. Gadget @@ -541,6 +559,7 @@ struct usb_gadget { unsignedb_hnp_enable:1; unsigneda_hnp_support:1; unsigneda_alt_hnp_support:1; + unsignedquirk_ep_out_aligned_size:1; }; #define work_to_gadget(w) (container_of((w), struct usb_gadget, work)) -- 1.8.4.rc3 -- To unsubscribe from this list: send the line unsubscribe 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 4/4] usb: dwc3: add quirk USB_GADGET_QUIRK_EP_OUT_ALIGNED_SIZE to gadget driver
DWC3 requires epout to have buffer size aligned to MaxPacketSize value. This patch adds necessary quirk for it. Signed-off-by: David Cohen david.a.co...@linux.intel.com --- drivers/usb/dwc3/gadget.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 5452c0fce360..b85ec110d6a0 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2600,6 +2600,12 @@ int dwc3_gadget_init(struct dwc3 *dwc) dwc-gadget.name= dwc3-gadget; /* +* Per databook, DWC3 needs buffer size to be aligned to MaxPacketSize +* on ep out. +*/ + dwc-gadget.quirk_ep_out_aligned_size = true; + + /* * REVISIT: Here we should clear all pending IRQs to be * sure we're starting from a well known location. */ -- 1.8.4.rc3 -- To unsubscribe from this list: send the line unsubscribe 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 3/4] usb: ffs: check quirk to pad epout buf size when not aligned to maxpacketsize
Check gadget.quirk_ep_out_aligned_size to decide if buffer size requires to be aligned to maxpacketsize of an out endpoint. ffs_epfile_io() needs to pad epout buffer to match above condition if quirk is found. Signed-off-by: David Cohen david.a.co...@linux.intel.com --- drivers/usb/gadget/f_fs.c | 22 ++ 1 file changed, 22 insertions(+) diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c index 75e4b7846a8d..e7c3c3119552 100644 --- a/drivers/usb/gadget/f_fs.c +++ b/drivers/usb/gadget/f_fs.c @@ -755,10 +755,13 @@ static ssize_t ffs_epfile_io(struct file *file, char __user *buf, size_t len, int read) { struct ffs_epfile *epfile = file-private_data; + struct usb_gadget *gadget = epfile-ffs-gadget; struct ffs_ep *ep; char *data = NULL; + size_t data_len = 0; ssize_t ret; int halt; + size_t orig_len = len; goto first_try; do { @@ -794,11 +797,30 @@ first_try: goto error; } + /* +* Controller requires buffer size to be aligned to +* maxpacketsize of an out endpoint. +*/ + if (gadget-quirk_ep_out_aligned_size read) { + /* +* We pass 'orig_len' to usp_ep_align_maxpacketsize() +* due to we're in a loop and 'len' may have been +* changed. +*/ + len = usb_ep_align_maxpacketsize(ep-ep, orig_len); + if (data len data_len) { + kfree(data); + data = NULL; + data_len = 0; + } + } + /* Allocate copy */ if (!halt !data) { data = kzalloc(len, GFP_KERNEL); if (unlikely(!data)) return -ENOMEM; + data_len = len; if (!read unlikely(__copy_from_user(data, buf, len))) { -- 1.8.4.rc3 -- To unsubscribe from this list: send the line unsubscribe 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 0/4] add gadget quirk to adapt f_fs for DWC3
Hi, These patches are a proposal to add gadget quirks in an immediate objective to adapt f_fs when using DWC3 controller. But the quirk solution is generic and can be used by other controllers to adapt gadget functions to their non-standard restrictions. This change is necessary to make Android's adbd service to work on Intel Merrifield with f_fs instead of out-of-tree android gadget. Changes from v3 to v4: - replace u32 quirk flags by single unsigned:1 flag for ep out aligned size quirk on usb_gadget - add static inline helper to align ep out buf size --- David Cohen (4): usb: gadget: move bitflags to the end of usb_gadget struct usb: gadget: add quirk_ep_out_aligned_size field to struct usb_gadget usb: ffs: check quirk to pad epout buf size when not aligned to maxpacketsize usb: dwc3: add quirk USB_GADGET_QUIRK_EP_OUT_ALIGNED_SIZE to gadget driver drivers/usb/dwc3/gadget.c | 6 ++ drivers/usb/gadget/f_fs.c | 22 ++ include/linux/usb/gadget.h | 38 +- 3 files changed, 57 insertions(+), 9 deletions(-) -- 1.8.4.rc3 -- To unsubscribe from this list: send the line unsubscribe 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 4/4] usb: dwc3: set gadget's quirk ep_out_align_size
DWC3 requires epout to have buffer size aligned to MaxPacketSize value. This patch sets necessary quirk for it. Signed-off-by: David Cohen david.a.co...@linux.intel.com --- Changes from v4 to v4.1: - just updated patch's subject. No actual code changed. drivers/usb/dwc3/gadget.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 5452c0fce360..b85ec110d6a0 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2600,6 +2600,12 @@ int dwc3_gadget_init(struct dwc3 *dwc) dwc-gadget.name= dwc3-gadget; /* +* Per databook, DWC3 needs buffer size to be aligned to MaxPacketSize +* on ep out. +*/ + dwc-gadget.quirk_ep_out_aligned_size = true; + + /* * REVISIT: Here we should clear all pending IRQs to be * sure we're starting from a well known location. */ -- 1.8.4.rc3 -- To unsubscribe from this list: send the line unsubscribe 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: Large USB HID transfers
On Mon, Nov 4, 2013 at 11:51 AM, Alan Stern st...@rowland.harvard.edu wrote: On Mon, 4 Nov 2013, Cliff Brake wrote: We have the same system running on a older PXA270 version of the product (vs the current TI DM3730). It has an older OHCI 12Mbit USB host controller (vs the current TI EHCI controller). We have _not_ experienced these types of latencies with the older PXA270 product. This may be another indication the problem lies in the TI EHCI controller driver, but its odd we have not seen any issues with other peripherals. More likely it's an indication that you aren't transferring such large amounts of data with the older host. The trace shows very clearly that the lion's share of the overhead was not in the EHCI controller driver; it was in the HID processing. I did comparison function traces with the PXA270 and DM3730 system, and the big difference is the older (gen1) system is only using 64 byte packets, where the newer one is using ~700 byte packets. See: http://bec-systems.com/usb-trace-gen1_filtered.txt http://bec-systems.com/usb-trace-gen2_filtered.txt I assume interrupts are disabled during both ohci_irq() and ehci_irq(). Short term we'll try to force 64-byte packets on the EHCI system. Long term it would be nice if this work did not happen in a irq handler, although this is clearly an abuse of the HID protocol. Thanks, Cliff -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 00/11] Add power management support for MXS PHY
Hi Felipe Shawn, The serial adds power management support for MXS PHY, it includes: - Add three common PHY APIs, .set_wakeup, .notify_suspend, notify_resume. - Related above API implementation at mxs phy driver - misc changes for mxs phy to support low power mode and wakeup. My github tree: https://github.com/hzpeterchen/linux-usb branch: master It is based on linux-next-1029. Changes for v3: - Using flag bit to indicate SoC features/bugs, so we can remove platform_device_id. - Remove 3 unnecessary dts/doc patches due to above change - Several comment change Changes for v2: - Add missing patches which introduce platform judgement code [1/14,2/14] - re-order the patch sequence, like doc-dts-source file, the reviewers can know the meaning of dt properties before review source - Add description of two IC problems exsiting at mxs PHY; change high speed to HS and non-high speed to FS/LS [5/14] - Change the dt property disconnect-line-without-vbus that the separator should be - not the _, meanwhile, related source code has changed. - Using one local variable to get the function return val to avoid long condition statement. [13/14] Peter Chen (11): usb: phy-mxs: Add platform judgement code usb: phy-mxs: Add auto clock and power setting usb: doc: phy-mxs: update binding for adding anatop phandle ARM: dts: imx6: add anatop phandle for usbphy usb: phy-mxs: Add anatop regmap usb: phy: add notify suspend and resume callback usb: phy-mxs: Add implementation of nofity_suspend and notify_resume usb: phy-mxs: Enable IC fixes for related SoCs usb: phy: Add set_wakeup API usb: phy-mxs: Add implementation of set_wakeup usb: phy-mxs: Add system suspend/resume API Documentation/devicetree/bindings/usb/mxs-phy.txt |2 + arch/arm/boot/dts/imx6qdl.dtsi|2 + drivers/usb/phy/phy-mxs-usb.c | 313 - include/linux/usb/phy.h | 39 +++ 4 files changed, 341 insertions(+), 15 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 v3 08/11] usb: phy-mxs: Enable IC fixes for related SoCs
Some PHY bugs are fixed by IC logic, but these bits are not enabled by default, so we enable them at driver. Signed-off-by: Peter Chen peter.c...@freescale.com --- drivers/usb/phy/phy-mxs-usb.c | 32 ++-- 1 files changed, 30 insertions(+), 2 deletions(-) diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c index c794011..b7e1744 100644 --- a/drivers/usb/phy/phy-mxs-usb.c +++ b/drivers/usb/phy/phy-mxs-usb.c @@ -31,6 +31,10 @@ #define HW_USBPHY_CTRL_SET 0x34 #define HW_USBPHY_CTRL_CLR 0x38 +#define HW_USBPHY_IP 0x90 +#define HW_USBPHY_IP_SET 0x94 +#define HW_USBPHY_IP_CLR 0x98 + #define BM_USBPHY_CTRL_SFTRST BIT(31) #define BM_USBPHY_CTRL_CLKGATE BIT(30) #define BM_USBPHY_CTRL_ENAUTOSET_USBCLKS BIT(26) @@ -60,6 +64,18 @@ */ #define MXS_PHY_SENDING_SOF_TOO_FAST BIT(2) +/* + * IC fix for MXS_PHY_ABNORAML_IN_SUSPEND, bit 17 is the effective bit + * in HW_USBPHY_IP. + */ +#define MXS_PHY_FIX_ABNORAML_IN_SUSPENDBIT(17) + +/* + * IC fix for MXS_PHY_SENDING_SOF_TOO_FAST, bit 18 is the effective bit + * in HW_USBPHY_IP. + */ +#define MXS_PHY_FIX_SENDING_SOF_TOO_FAST BIT(18) + struct mxs_phy_platform_flag { unsigned int flags; }; @@ -70,11 +86,14 @@ static const struct mxs_phy_platform_flag imx23_phy_data = { static const struct mxs_phy_platform_flag imx6q_phy_data = { .flags = MXS_PHY_SENDING_SOF_TOO_FAST | - MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS, + MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS | + MXS_PHY_FIX_ABNORAML_IN_SUSPEND, }; static const struct mxs_phy_platform_flag imx6sl_phy_data = { - .flags = MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS, + .flags = MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS | + MXS_PHY_FIX_ABNORAML_IN_SUSPEND | + MXS_PHY_FIX_SENDING_SOF_TOO_FAST, }; static const struct of_device_id mxs_phy_dt_ids[] = { @@ -118,6 +137,15 @@ static int mxs_phy_hw_init(struct mxs_phy *mxs_phy) BM_USBPHY_CTRL_ENUTMILEVEL3, base + HW_USBPHY_CTRL_SET); + /* Enable IC solution */ + if (mxs_phy-flags MXS_PHY_FIX_ABNORAML_IN_SUSPEND) + writel(MXS_PHY_FIX_ABNORAML_IN_SUSPEND, + base + HW_USBPHY_IP_SET); + + if (mxs_phy-flags MXS_PHY_FIX_SENDING_SOF_TOO_FAST) + writel(MXS_PHY_FIX_SENDING_SOF_TOO_FAST, + base + HW_USBPHY_IP_SET); + return 0; } -- 1.7.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 01/11] usb: phy-mxs: Add platform judgement code
The mxs-phy has several bugs and features at different versions, the driver code can get it through of_device_id.data. Signed-off-by: Peter Chen peter.c...@freescale.com --- drivers/usb/phy/phy-mxs-usb.c | 59 ++-- 1 files changed, 50 insertions(+), 9 deletions(-) diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c index fdd33b4..8b9d80c 100644 --- a/drivers/usb/phy/phy-mxs-usb.c +++ b/drivers/usb/phy/phy-mxs-usb.c @@ -1,5 +1,5 @@ /* - * Copyright 2012 Freescale Semiconductor, Inc. + * Copyright 2012-2013 Freescale Semiconductor, Inc. * Copyright (C) 2012 Marek Vasut ma...@denx.de * on behalf of DENX Software Engineering GmbH * @@ -20,6 +20,7 @@ #include linux/delay.h #include linux/err.h #include linux/io.h +#include linux/of_device.h #define DRIVER_NAME mxs_phy @@ -34,13 +35,55 @@ #define BM_USBPHY_CTRL_ENUTMILEVEL2BIT(14) #define BM_USBPHY_CTRL_ENHOSTDISCONDETECT BIT(1) +#define to_mxs_phy(p) container_of((p), struct mxs_phy, phy) + +/* Do disconnection between PHY and controller without vbus */ +#define MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS BIT(0) + +/* + * The PHY will be in messy if there is an wakeup after putting + * bus to suspend (set portsc.suspendM) but before setting PHY to low + * power mode (set portsc.phcd). + */ +#define MXS_PHY_ABNORAML_IN_SUSPENDBIT(1) + +/* + * The SOF sends too fast after resuming, it will cause disconnection + * between host and high speed device. + */ +#define MXS_PHY_SENDING_SOF_TOO_FAST BIT(2) + +struct mxs_phy_platform_flag { + unsigned int flags; +}; + +static const struct mxs_phy_platform_flag imx23_phy_data = { + .flags = MXS_PHY_ABNORAML_IN_SUSPEND | MXS_PHY_SENDING_SOF_TOO_FAST, +}; + +static const struct mxs_phy_platform_flag imx6q_phy_data = { + .flags = MXS_PHY_SENDING_SOF_TOO_FAST | + MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS, +}; + +static const struct mxs_phy_platform_flag imx6sl_phy_data = { + .flags = MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS, +}; + +static const struct of_device_id mxs_phy_dt_ids[] = { + { .compatible = fsl,imx6sl-usbphy, .data = imx6sl_phy_data, }, + { .compatible = fsl,imx6q-usbphy, .data = imx6q_phy_data, }, + { .compatible = fsl,imx23-usbphy, .data = imx23_phy_data, }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, mxs_phy_dt_ids); + struct mxs_phy { struct usb_phy phy; struct clk *clk; + unsigned int flags; }; -#define to_mxs_phy(p) container_of((p), struct mxs_phy, phy) - static int mxs_phy_hw_init(struct mxs_phy *mxs_phy) { int ret; @@ -131,6 +174,9 @@ static int mxs_phy_probe(struct platform_device *pdev) struct clk *clk; struct mxs_phy *mxs_phy; int ret; + const struct of_device_id *of_id = + of_match_device(mxs_phy_dt_ids, pdev-dev); + const struct mxs_phy_platform_flag *platform_flag = of_id-data; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); base = devm_ioremap_resource(pdev-dev, res); @@ -163,6 +209,7 @@ static int mxs_phy_probe(struct platform_device *pdev) ATOMIC_INIT_NOTIFIER_HEAD(mxs_phy-phy.notifier); mxs_phy-clk = clk; + mxs_phy-flags = platform_flag-flags; platform_set_drvdata(pdev, mxs_phy-phy); @@ -182,12 +229,6 @@ static int mxs_phy_remove(struct platform_device *pdev) return 0; } -static const struct of_device_id mxs_phy_dt_ids[] = { - { .compatible = fsl,imx23-usbphy, }, - { /* sentinel */ } -}; -MODULE_DEVICE_TABLE(of, mxs_phy_dt_ids); - static struct platform_driver mxs_phy_driver = { .probe = mxs_phy_probe, .remove = mxs_phy_remove, -- 1.7.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 03/11] usb: doc: phy-mxs: update binding for adding anatop phandle
Add anatop phandle which is used to access anatop registers to control PHY's power and other USB operations. Signed-off-by: Peter Chen peter.c...@freescale.com --- Documentation/devicetree/bindings/usb/mxs-phy.txt |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/mxs-phy.txt b/Documentation/devicetree/bindings/usb/mxs-phy.txt index 5835b27..e2d5211 100644 --- a/Documentation/devicetree/bindings/usb/mxs-phy.txt +++ b/Documentation/devicetree/bindings/usb/mxs-phy.txt @@ -4,10 +4,12 @@ Required properties: - compatible: Should be fsl,imx23-usbphy - reg: Should contain registers location and length - interrupts: Should contain phy interrupt +- fsl,anatop: phandle for anatop register, it is only for mx6 SoC serial Example: usbphy1: usbphy@020c9000 { compatible = fsl,imx6q-usbphy, fsl,imx23-usbphy; reg = 0x020c9000 0x1000; interrupts = 0 44 0x04; + fsl,anatop = anatop; }; -- 1.7.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 05/11] usb: phy-mxs: Add anatop regmap
It is needed by imx6 SoC serial, but not for imx23 and imx28. Signed-off-by: Peter Chen peter.c...@freescale.com --- drivers/usb/phy/phy-mxs-usb.c | 15 +++ 1 files changed, 15 insertions(+), 0 deletions(-) diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c index 472fe36..8cdfbf1 100644 --- a/drivers/usb/phy/phy-mxs-usb.c +++ b/drivers/usb/phy/phy-mxs-usb.c @@ -21,6 +21,8 @@ #include linux/err.h #include linux/io.h #include linux/of_device.h +#include linux/regmap.h +#include linux/mfd/syscon.h #define DRIVER_NAME mxs_phy @@ -87,6 +89,7 @@ struct mxs_phy { struct usb_phy phy; struct clk *clk; unsigned int flags; + struct regmap *regmap_anatop; }; static int mxs_phy_hw_init(struct mxs_phy *mxs_phy) @@ -191,6 +194,7 @@ static int mxs_phy_probe(struct platform_device *pdev) const struct of_device_id *of_id = of_match_device(mxs_phy_dt_ids, pdev-dev); const struct mxs_phy_platform_flag *platform_flag = of_id-data; + struct device_node *np = pdev-dev.of_node; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); base = devm_ioremap_resource(pdev-dev, res); @@ -210,6 +214,17 @@ static int mxs_phy_probe(struct platform_device *pdev) return -ENOMEM; } + /* Some SoCs don't have anatop registers */ + if (of_get_property(np, fsl,anatop, NULL)) { + mxs_phy-regmap_anatop = syscon_regmap_lookup_by_phandle + (np, fsl,anatop); + if (IS_ERR(mxs_phy-regmap_anatop)) { + dev_dbg(pdev-dev, + failed to find regmap for anatop\n); + return PTR_ERR(mxs_phy-regmap_anatop); + } + } + mxs_phy-phy.io_priv= base; mxs_phy-phy.dev= pdev-dev; mxs_phy-phy.label = DRIVER_NAME; -- 1.7.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 07/11] usb: phy-mxs: Add implementation of nofity_suspend and notify_resume
Implementation of notify_suspend and notify_resume will be different according to mxs_phy_platform_flag-flags. Signed-off-by: Peter Chen peter.c...@freescale.com --- drivers/usb/phy/phy-mxs-usb.c | 54 +--- 1 files changed, 50 insertions(+), 4 deletions(-) diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c index 8cdfbf1..c794011 100644 --- a/drivers/usb/phy/phy-mxs-usb.c +++ b/drivers/usb/phy/phy-mxs-usb.c @@ -161,8 +161,8 @@ static int mxs_phy_suspend(struct usb_phy *x, int suspend) static int mxs_phy_on_connect(struct usb_phy *phy, enum usb_device_speed speed) { - dev_dbg(phy-dev, %s speed device has connected\n, - (speed == USB_SPEED_HIGH) ? high : non-high); + dev_dbg(phy-dev, %s device has connected\n, + (speed == USB_SPEED_HIGH) ? HS : FS/LS); if (speed == USB_SPEED_HIGH) writel(BM_USBPHY_CTRL_ENHOSTDISCONDETECT, @@ -174,8 +174,8 @@ static int mxs_phy_on_connect(struct usb_phy *phy, static int mxs_phy_on_disconnect(struct usb_phy *phy, enum usb_device_speed speed) { - dev_dbg(phy-dev, %s speed device has disconnected\n, - (speed == USB_SPEED_HIGH) ? high : non-high); + dev_dbg(phy-dev, %s device has disconnected\n, + (speed == USB_SPEED_HIGH) ? HS : FS/LS); if (speed == USB_SPEED_HIGH) writel(BM_USBPHY_CTRL_ENHOSTDISCONDETECT, @@ -184,6 +184,48 @@ static int mxs_phy_on_disconnect(struct usb_phy *phy, return 0; } +static int mxs_phy_on_suspend(struct usb_phy *phy, + enum usb_device_speed speed) +{ + struct mxs_phy *mxs_phy = to_mxs_phy(phy); + + dev_dbg(phy-dev, %s device has suspended\n, + (speed == USB_SPEED_HIGH) ? HS : FS/LS); + + /* delay 4ms to wait bus entering idle */ + usleep_range(4000, 5000); + + if (mxs_phy-flags MXS_PHY_ABNORAML_IN_SUSPEND) { + writel_relaxed(0x, phy-io_priv + HW_USBPHY_PWD); + writel_relaxed(0, phy-io_priv + HW_USBPHY_PWD); + } + + if (speed == USB_SPEED_HIGH) + writel_relaxed(BM_USBPHY_CTRL_ENHOSTDISCONDETECT, + phy-io_priv + HW_USBPHY_CTRL_CLR); + + return 0; +} + +/* + * The resume signal must be finished here. + */ +static int mxs_phy_on_resume(struct usb_phy *phy, + enum usb_device_speed speed) +{ + dev_dbg(phy-dev, %s device has resumed\n, + (speed == USB_SPEED_HIGH) ? HS : FS/LS); + + if (speed == USB_SPEED_HIGH) { + /* Make sure the device has switched to High-Speed mode */ + udelay(500); + writel_relaxed(BM_USBPHY_CTRL_ENHOSTDISCONDETECT, + phy-io_priv + HW_USBPHY_CTRL_SET); + } + + return 0; +} + static int mxs_phy_probe(struct platform_device *pdev) { struct resource *res; @@ -239,6 +281,10 @@ static int mxs_phy_probe(struct platform_device *pdev) mxs_phy-clk = clk; mxs_phy-flags = platform_flag-flags; + if (mxs_phy-flags MXS_PHY_SENDING_SOF_TOO_FAST) { + mxs_phy-phy.notify_suspend = mxs_phy_on_suspend; + mxs_phy-phy.notify_resume = mxs_phy_on_resume; + } platform_set_drvdata(pdev, mxs_phy-phy); -- 1.7.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 10/11] usb: phy-mxs: Add implementation of set_wakeup
When we need the PHY can be waken up by external signals, we can call this API. Besides, we call mxs_phy_disconnect_line at this API to close the connection between USB PHY and controller, after that, the line state from controller is SE0. Once the PHY is out of power, without calling mxs_phy_disconnect_line, there are unknown wakeups due to dp/dm floating at device mode. Signed-off-by: Peter Chen peter.c...@freescale.com --- drivers/usb/phy/phy-mxs-usb.c | 79 + 1 files changed, 79 insertions(+), 0 deletions(-) diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c index b7e1744..ff8b98c 100644 --- a/drivers/usb/phy/phy-mxs-usb.c +++ b/drivers/usb/phy/phy-mxs-usb.c @@ -31,6 +31,9 @@ #define HW_USBPHY_CTRL_SET 0x34 #define HW_USBPHY_CTRL_CLR 0x38 +#define HW_USBPHY_DEBUG_SET0x54 +#define HW_USBPHY_DEBUG_CLR0x58 + #define HW_USBPHY_IP 0x90 #define HW_USBPHY_IP_SET 0x94 #define HW_USBPHY_IP_CLR 0x98 @@ -39,6 +42,9 @@ #define BM_USBPHY_CTRL_CLKGATE BIT(30) #define BM_USBPHY_CTRL_ENAUTOSET_USBCLKS BIT(26) #define BM_USBPHY_CTRL_ENAUTOCLR_USBCLKGATEBIT(25) +#define BM_USBPHY_CTRL_ENVBUSCHG_WKUP BIT(23) +#define BM_USBPHY_CTRL_ENIDCHG_WKUPBIT(22) +#define BM_USBPHY_CTRL_ENDPDMCHG_WKUP BIT(21) #define BM_USBPHY_CTRL_ENAUTOCLR_PHY_PWD BIT(20) #define BM_USBPHY_CTRL_ENAUTOCLR_CLKGATE BIT(19) #define BM_USBPHY_CTRL_ENAUTO_PWRON_PLLBIT(18) @@ -46,6 +52,19 @@ #define BM_USBPHY_CTRL_ENUTMILEVEL2BIT(14) #define BM_USBPHY_CTRL_ENHOSTDISCONDETECT BIT(1) +#define BM_USBPHY_DEBUG_CLKGATEBIT(30) + +/* Anatop Registers */ +#define ANADIG_USB1_VBUS_DET_STAT 0x1c0 + +#define ANADIG_USB1_LOOPBACK_SET 0x1e4 +#define ANADIG_USB1_LOOPBACK_CLR 0x1e8 + +#define BM_ANADIG_USB1_VBUS_DET_STAT_VBUS_VALIDBIT(3) + +#define BM_ANADIG_USB1_LOOPBACK_UTMI_DIG_TST1 BIT(2) +#define BM_ANADIG_USB1_LOOPBACK_TSTI_TX_EN BIT(5) + #define to_mxs_phy(p) container_of((p), struct mxs_phy, phy) /* Do disconnection between PHY and controller without vbus */ @@ -149,6 +168,48 @@ static int mxs_phy_hw_init(struct mxs_phy *mxs_phy) return 0; } +static void mxs_phy_disconnect_line(struct mxs_phy *mxs_phy, bool on) +{ + void __iomem *base = mxs_phy-phy.io_priv; + bool vbus_is_on = false; + static bool line_is_disconnected; + unsigned int vbus_value = 0; + + /* If the SoCs don't need to disconnect line without vbus, quit */ + if (!(mxs_phy-flags MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS)) + return; + + /* If the SoCs don't have anatop, quit */ + if (!mxs_phy-regmap_anatop) + return; + + regmap_read(mxs_phy-regmap_anatop, ANADIG_USB1_VBUS_DET_STAT, + vbus_value); + if (vbus_value BM_ANADIG_USB1_VBUS_DET_STAT_VBUS_VALID) + vbus_is_on = true; + + if (on !vbus_is_on) { + writel_relaxed(BM_USBPHY_DEBUG_CLKGATE, + base + HW_USBPHY_DEBUG_CLR); + regmap_write(mxs_phy-regmap_anatop, ANADIG_USB1_LOOPBACK_SET, + BM_ANADIG_USB1_LOOPBACK_UTMI_DIG_TST1 | + BM_ANADIG_USB1_LOOPBACK_TSTI_TX_EN); + /* Delay some time, and let Linestate be SE0 for controller */ + usleep_range(500, 1000); + line_is_disconnected = true; + } else if (line_is_disconnected) { + regmap_write(mxs_phy-regmap_anatop, ANADIG_USB1_LOOPBACK_CLR, + BM_ANADIG_USB1_LOOPBACK_UTMI_DIG_TST1 | + BM_ANADIG_USB1_LOOPBACK_TSTI_TX_EN); + writel_relaxed(BM_USBPHY_DEBUG_CLKGATE, + base + HW_USBPHY_DEBUG_SET); + line_is_disconnected = false; + } + + dev_dbg(mxs_phy-phy.dev, line is %s\n, line_is_disconnected + ? disconnected : connected); +} + static int mxs_phy_init(struct usb_phy *phy) { struct mxs_phy *mxs_phy = to_mxs_phy(phy); @@ -186,6 +247,23 @@ static int mxs_phy_suspend(struct usb_phy *x, int suspend) return 0; } +static int mxs_phy_set_wakeup(struct usb_phy *x, bool enabled) +{ + struct mxs_phy *mxs_phy = to_mxs_phy(x); + u32 value = BM_USBPHY_CTRL_ENVBUSCHG_WKUP | + BM_USBPHY_CTRL_ENDPDMCHG_WKUP | + BM_USBPHY_CTRL_ENIDCHG_WKUP; + if (enabled) { + mxs_phy_disconnect_line(mxs_phy, true); + writel_relaxed(value, x-io_priv + HW_USBPHY_CTRL_SET); + } else { + writel_relaxed(value, x-io_priv + HW_USBPHY_CTRL_CLR); +
[PATCH v3 04/11] ARM: dts: imx6: add anatop phandle for usbphy
Add anatop phandle for usbphy Signed-off-by: Peter Chen peter.c...@freescale.com --- arch/arm/boot/dts/imx6qdl.dtsi |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/arch/arm/boot/dts/imx6qdl.dtsi b/arch/arm/boot/dts/imx6qdl.dtsi index 226ce75..bb79678 100644 --- a/arch/arm/boot/dts/imx6qdl.dtsi +++ b/arch/arm/boot/dts/imx6qdl.dtsi @@ -559,6 +559,7 @@ reg = 0x020c9000 0x1000; interrupts = 0 44 0x04; clocks = clks 182; + fsl,anatop = anatop; }; usbphy2: usbphy@020ca000 { @@ -566,6 +567,7 @@ reg = 0x020ca000 0x1000; interrupts = 0 45 0x04; clocks = clks 183; + fsl,anatop = anatop; }; snvs@020cc000 { -- 1.7.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 11/11] usb: phy-mxs: Add system suspend/resume API
We need this to keep PHY's power on or off during the system suspend mode. If we need to enable USB wakeup, then we must keep PHY's power being on during the system suspend mode. Otherwise, we need to keep PHY's power being off to save power. Signed-off-by: Peter Chen peter.c...@freescale.com --- drivers/usb/phy/phy-mxs-usb.c | 66 +++-- 1 files changed, 63 insertions(+), 3 deletions(-) diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c index ff8b98c..4588c72 100644 --- a/drivers/usb/phy/phy-mxs-usb.c +++ b/drivers/usb/phy/phy-mxs-usb.c @@ -55,11 +55,18 @@ #define BM_USBPHY_DEBUG_CLKGATEBIT(30) /* Anatop Registers */ +#define ANADIG_ANA_MISC0 0x150 +#define ANADIG_ANA_MISC0_SET 0x154 +#define ANADIG_ANA_MISC0_CLR 0x158 + #define ANADIG_USB1_VBUS_DET_STAT 0x1c0 #define ANADIG_USB1_LOOPBACK_SET 0x1e4 #define ANADIG_USB1_LOOPBACK_CLR 0x1e8 +#define BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG BIT(12) +#define BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG_SL BIT(11) + #define BM_ANADIG_USB1_VBUS_DET_STAT_VBUS_VALIDBIT(3) #define BM_ANADIG_USB1_LOOPBACK_UTMI_DIG_TST1 BIT(2) @@ -83,6 +90,15 @@ */ #define MXS_PHY_SENDING_SOF_TOO_FAST BIT(2) +/* imx23 style PHY */ +#define MXS_PHY_IMX23 BIT(3) + +/* imx6q style PHY */ +#define MXS_PHY_IMX6Q BIT(4) + +/* imx6sl style PHY */ +#define MXS_PHY_IMX6SL BIT(5) + /* * IC fix for MXS_PHY_ABNORAML_IN_SUSPEND, bit 17 is the effective bit * in HW_USBPHY_IP. @@ -100,19 +116,23 @@ struct mxs_phy_platform_flag { }; static const struct mxs_phy_platform_flag imx23_phy_data = { - .flags = MXS_PHY_ABNORAML_IN_SUSPEND | MXS_PHY_SENDING_SOF_TOO_FAST, + .flags = MXS_PHY_ABNORAML_IN_SUSPEND | + MXS_PHY_SENDING_SOF_TOO_FAST | + MXS_PHY_IMX23, }; static const struct mxs_phy_platform_flag imx6q_phy_data = { .flags = MXS_PHY_SENDING_SOF_TOO_FAST | MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS | - MXS_PHY_FIX_ABNORAML_IN_SUSPEND, + MXS_PHY_FIX_ABNORAML_IN_SUSPEND | + MXS_PHY_IMX6Q, }; static const struct mxs_phy_platform_flag imx6sl_phy_data = { .flags = MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS | MXS_PHY_FIX_ABNORAML_IN_SUSPEND | - MXS_PHY_FIX_SENDING_SOF_TOO_FAST, + MXS_PHY_FIX_SENDING_SOF_TOO_FAST | + MXS_PHY_IMX6SL, }; static const struct of_device_id mxs_phy_dt_ids[] = { @@ -210,6 +230,22 @@ static void mxs_phy_disconnect_line(struct mxs_phy *mxs_phy, bool on) ? disconnected : connected); } +static void mxs_phy_enable_ldo_in_suspend(struct mxs_phy *mxs_phy, bool on) +{ + unsigned int reg = on ? ANADIG_ANA_MISC0_SET : ANADIG_ANA_MISC0_CLR; + + /* If the SoCs don't have anatop, quit */ + if (!mxs_phy-regmap_anatop) + return; + + if (mxs_phy-flags MXS_PHY_IMX6Q) + regmap_write(mxs_phy-regmap_anatop, reg, + BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG); + else if (mxs_phy-flags MXS_PHY_IMX6SL) + regmap_write(mxs_phy-regmap_anatop, + reg, BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG_SL); +} + static int mxs_phy_init(struct usb_phy *phy) { struct mxs_phy *mxs_phy = to_mxs_phy(phy); @@ -395,6 +431,7 @@ static int mxs_phy_probe(struct platform_device *pdev) platform_set_drvdata(pdev, mxs_phy-phy); + device_set_wakeup_capable(pdev-dev, true); ret = usb_add_phy_dev(mxs_phy-phy); if (ret) return ret; @@ -411,6 +448,28 @@ static int mxs_phy_remove(struct platform_device *pdev) return 0; } +static int mxs_phy_system_suspend(struct device *dev) +{ + struct mxs_phy *mxs_phy = dev_get_drvdata(dev); + + if (device_may_wakeup(dev)) + mxs_phy_enable_ldo_in_suspend(mxs_phy, true); + + return 0; +} + +static int mxs_phy_system_resume(struct device *dev) +{ + struct mxs_phy *mxs_phy = dev_get_drvdata(dev); + + if (device_may_wakeup(dev)) + mxs_phy_enable_ldo_in_suspend(mxs_phy, false); + + return 0; +} + +SIMPLE_DEV_PM_OPS(mxs_phy_pm, mxs_phy_system_suspend, mxs_phy_system_resume); + static struct platform_driver mxs_phy_driver = { .probe = mxs_phy_probe, .remove = mxs_phy_remove, @@ -418,6 +477,7 @@ static struct platform_driver mxs_phy_driver = { .name = DRIVER_NAME, .owner = THIS_MODULE, .of_match_table = mxs_phy_dt_ids, + .pm = mxs_phy_pm, }, }; -- 1.7.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
[PATCH v3 02/11] usb: phy-mxs: Add auto clock and power setting
With the auto setting, the PHY's clock and power can be recovered correctly from low power mode, it is ganranteed by IC logic. Signed-off-by: Peter Chen peter.c...@freescale.com --- drivers/usb/phy/phy-mxs-usb.c | 20 +--- 1 files changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c index 8b9d80c..472fe36 100644 --- a/drivers/usb/phy/phy-mxs-usb.c +++ b/drivers/usb/phy/phy-mxs-usb.c @@ -31,6 +31,11 @@ #define BM_USBPHY_CTRL_SFTRST BIT(31) #define BM_USBPHY_CTRL_CLKGATE BIT(30) +#define BM_USBPHY_CTRL_ENAUTOSET_USBCLKS BIT(26) +#define BM_USBPHY_CTRL_ENAUTOCLR_USBCLKGATEBIT(25) +#define BM_USBPHY_CTRL_ENAUTOCLR_PHY_PWD BIT(20) +#define BM_USBPHY_CTRL_ENAUTOCLR_CLKGATE BIT(19) +#define BM_USBPHY_CTRL_ENAUTO_PWRON_PLLBIT(18) #define BM_USBPHY_CTRL_ENUTMILEVEL3BIT(15) #define BM_USBPHY_CTRL_ENUTMILEVEL2BIT(14) #define BM_USBPHY_CTRL_ENHOSTDISCONDETECT BIT(1) @@ -96,9 +101,18 @@ static int mxs_phy_hw_init(struct mxs_phy *mxs_phy) /* Power up the PHY */ writel(0, base + HW_USBPHY_PWD); - /* enable FS/LS device */ - writel(BM_USBPHY_CTRL_ENUTMILEVEL2 | - BM_USBPHY_CTRL_ENUTMILEVEL3, + /* +* USB PHY Ctrl Setting +* - Auto clock/power on +* - Enable full/low speed support +*/ + writel(BM_USBPHY_CTRL_ENAUTOSET_USBCLKS | + BM_USBPHY_CTRL_ENAUTOCLR_USBCLKGATE | + BM_USBPHY_CTRL_ENAUTOCLR_PHY_PWD | + BM_USBPHY_CTRL_ENAUTOCLR_CLKGATE | + BM_USBPHY_CTRL_ENAUTO_PWRON_PLL | + BM_USBPHY_CTRL_ENUTMILEVEL2 | + BM_USBPHY_CTRL_ENUTMILEVEL3, base + HW_USBPHY_CTRL_SET); return 0; -- 1.7.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 09/11] usb: phy: Add set_wakeup API
This API is used to set wakeup enable at PHY registers, in that case, the PHY can be waken up from suspend due to external events, like vbus change, dp/dm change and id change. Signed-off-by: Peter Chen peter.c...@freescale.com --- include/linux/usb/phy.h | 16 1 files changed, 16 insertions(+), 0 deletions(-) diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h index a747960..c6ebe1d 100644 --- a/include/linux/usb/phy.h +++ b/include/linux/usb/phy.h @@ -111,6 +111,13 @@ struct usb_phy { int (*set_suspend)(struct usb_phy *x, int suspend); + /* +* Set wakeup enable for PHY, in that case, the PHY can be +* waken up from suspend status due to external events, +* like vbus change, dp/dm change and id. +*/ + int (*set_wakeup)(struct usb_phy *x, bool enabled); + /* notify phy connect status change */ int (*notify_connect)(struct usb_phy *x, enum usb_device_speed speed); @@ -270,6 +277,15 @@ usb_phy_set_suspend(struct usb_phy *x, int suspend) } static inline int +usb_phy_set_wakeup(struct usb_phy *x, bool enabled) +{ + if (x x-set_wakeup) + return x-set_wakeup(x, enabled); + else + return 0; +} + +static inline int usb_phy_notify_connect(struct usb_phy *x, enum usb_device_speed speed) { if (x x-notify_connect) -- 1.7.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 00/10] Add power management support for chipidea
Hi Greg, This serial adds power management (system runtime) for chipidea core. With this, the chipidea controller can be at low power mode when it is not in use, and the chipidea controller can be the system wakeup source. It needs to depend on my patch[1], since [1]-Add power management support for MXS PHY adds some common PHY APIs, and this serial uses it. It has been verified at Freescale i.mx6Q/DL SabreSD, i.mx28 evk platform (no runtime pm support), I will verify it at other FSL platforms during the patch review. Hi Alan, Due to chipidea core and imx concontroller needs some special operations during the standard ehci routine, I override .hub_control, .bus_suspend, and .bus_resume. There is one special thing is I use flag ehci-bus_suspended to know it was a global suspend before due to I need to notify PHY when the suspend has finished (portsc.suspendM is set) and the resume signal has finished (portsc.fpr is cleared) for high speed device, but there are two places will send suspend/resume, and I don't want to patch ehci-hub.c (if you think patch ehci-hub.c is a good way, I can do it). The related host patches: usb: chipidea: host: add quirk for ehci operation usb: chipidea: host: add ehci quirk for imx controller My github tree: https://github.com/hzpeterchen/linux-usb branch: master It is based on linux-next-1029. Changes for v3: - Using flag bit to indicate SoC features/bugs [7/10][10/10] Changes for v2: - Do not use atomic_read and atomic_set for ci-in_lpm - Do not use supports_runtime_pm as DT property due to it is not a hardware feature, instead of it, we use compatible string to enable it. Peter Chen (10): usb: chipidea: Add power management support usb: chipidea: imx: add power management support usb: chipidea: add wakeup interrupt handler usb: chipidea: usbmisc_imx: remove the controller's clock information usb: chipidea: usbmisc_imx: add set_wakup API usb: chipidea: imx: call set_wakeup when necessary usb: chipidea: imx: Enable runtime pm support for imx6q usb: chipidea: host: add quirk for ehci operation usb: chipidea: host: add ehci quirk for imx controller usb: chipidea: imx: Enable CI_HDRC_IMX_EHCI_QUIRK drivers/usb/chipidea/ci.h |3 + drivers/usb/chipidea/ci_hdrc_imx.c | 156 ++- drivers/usb/chipidea/ci_hdrc_imx.h |1 + drivers/usb/chipidea/core.c| 139 +++ drivers/usb/chipidea/host.c| 180 drivers/usb/chipidea/otg.c |5 + drivers/usb/chipidea/usbmisc_imx.c | 59 include/linux/usb/chipidea.h |2 + 8 files changed, 522 insertions(+), 23 deletions(-) [1] http://marc.info/?l=linux-usbm=138361739523355w=2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 07/10] usb: chipidea: imx: Enable runtime pm support for imx6q
Currently, only imx6q adds wakeup logic, so only enable runtime pm for imx6q. Signed-off-by: Peter Chen peter.c...@freescale.com --- drivers/usb/chipidea/ci_hdrc_imx.c | 13 - 1 files changed, 12 insertions(+), 1 deletions(-) diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c index 5fbaa73..fd26c38 100644 --- a/drivers/usb/chipidea/ci_hdrc_imx.c +++ b/drivers/usb/chipidea/ci_hdrc_imx.c @@ -23,7 +23,8 @@ #include ci.h #include ci_hdrc_imx.h -#define CI_HDRC_IMX_IMX28_WRITE_FIX BIT(0) +#define CI_HDRC_IMX_IMX28_WRITE_FIXBIT(0) +#define CI_HDRC_IMX_SUPPORT_RUNTIME_PM BIT(1) struct ci_hdrc_imx_platform_flag { unsigned int flags; @@ -36,7 +37,12 @@ static const struct ci_hdrc_imx_platform_flag imx28_usb_data = { .flags = CI_HDRC_IMX_IMX28_WRITE_FIX, }; +static const struct ci_hdrc_imx_platform_flag imx6q_usb_data = { + .flags = CI_HDRC_IMX_SUPPORT_RUNTIME_PM, +}; + static const struct of_device_id ci_hdrc_imx_dt_ids[] = { + { .compatible = fsl,imx6q-usb, .data = imx6q_usb_data}, { .compatible = fsl,imx28-usb, .data = imx28_usb_data}, { .compatible = fsl,imx27-usb, .data = imx27_usb_data}, { /* sentinel */ } @@ -147,6 +153,11 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev) if (imx_platform_flag-flags CI_HDRC_IMX_IMX28_WRITE_FIX) pdata.flags |= CI_HDRC_IMX28_WRITE_FIX; + if (imx_platform_flag-flags CI_HDRC_IMX_SUPPORT_RUNTIME_PM) + pdata.flags |= CI_HDRC_SUPPORTS_RUNTIME_PM; + data-supports_runtime_pm = true; + } + if (data-usbmisc_data) { ret = imx_usbmisc_init(data-usbmisc_data); if (ret) { -- 1.7.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 06/10] usb: chipidea: imx: call set_wakeup when necessary
- Disable wakeup after probe - Enable wakeup during the suspend - Disable wakeup after controller is active Signed-off-by: Peter Chen peter.c...@freescale.com --- drivers/usb/chipidea/ci_hdrc_imx.c | 36 1 files changed, 36 insertions(+), 0 deletions(-) diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c index 803630e..5fbaa73 100644 --- a/drivers/usb/chipidea/ci_hdrc_imx.c +++ b/drivers/usb/chipidea/ci_hdrc_imx.c @@ -176,6 +176,15 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev) } } + if (data-usbmisc_data) { + ret = imx_usbmisc_set_wakeup(data-usbmisc_data, false); + if (ret) { + dev_err(pdev-dev, usbmisc set_wakeup failed, ret=%d\n, + ret); + goto disable_device; + } + } + platform_set_drvdata(pdev, data); device_set_wakeup_capable(pdev-dev, true); @@ -213,12 +222,23 @@ static int ci_hdrc_imx_remove(struct platform_device *pdev) static int imx_controller_suspend(struct device *dev) { struct ci_hdrc_imx_data *data = dev_get_drvdata(dev); + int ret; dev_dbg(dev, at %s\n, __func__); if (data-in_lpm) return 0; + if (data-usbmisc_data) { + ret = imx_usbmisc_set_wakeup(data-usbmisc_data, true); + if (ret) { + dev_err(dev, + usbmisc set_wakeup failed, ret=%d\n, + ret); + return ret; + } + } + clk_disable_unprepare(data-clk); data-in_lpm = true; @@ -242,6 +262,22 @@ static int imx_controller_resume(struct device *dev) data-in_lpm = false; + if (data-usbmisc_data) { + ret = imx_usbmisc_set_wakeup(data-usbmisc_data, false); + if (ret) { + dev_err(dev, + usbmisc set_wakeup failed, ret=%d\n, + ret); + ret = -EINVAL; + goto clk_disable; + } + } + + return 0; + +clk_disable: + clk_disable_unprepare(data-clk); + return ret; } -- 1.7.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 02/10] usb: chipidea: imx: add power management support
Add system and runtime power management support for imx gluy layer. Signed-off-by: Peter Chen peter.c...@freescale.com --- drivers/usb/chipidea/ci_hdrc_imx.c | 94 ++- 1 files changed, 91 insertions(+), 3 deletions(-) diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c index 0bd7ce1..803630e 100644 --- a/drivers/usb/chipidea/ci_hdrc_imx.c +++ b/drivers/usb/chipidea/ci_hdrc_imx.c @@ -48,6 +48,8 @@ struct ci_hdrc_imx_data { struct platform_device *ci_pdev; struct clk *clk; struct imx_usbmisc_data *usbmisc_data; + bool supports_runtime_pm; + bool in_lpm; }; /* Common functions shared by usbmisc drivers */ @@ -176,8 +178,12 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev) platform_set_drvdata(pdev, data); - pm_runtime_no_callbacks(pdev-dev); - pm_runtime_enable(pdev-dev); + device_set_wakeup_capable(pdev-dev, true); + + if (data-supports_runtime_pm) { + pm_runtime_set_active(pdev-dev); + pm_runtime_enable(pdev-dev); + } return 0; @@ -192,13 +198,94 @@ static int ci_hdrc_imx_remove(struct platform_device *pdev) { struct ci_hdrc_imx_data *data = platform_get_drvdata(pdev); - pm_runtime_disable(pdev-dev); ci_hdrc_remove_device(data-ci_pdev); + if (data-supports_runtime_pm) { + pm_runtime_get_sync(pdev-dev); + pm_runtime_disable(pdev-dev); + pm_runtime_put_noidle(pdev-dev); + } + clk_disable_unprepare(data-clk); + + return 0; +} + +#ifdef CONFIG_PM +static int imx_controller_suspend(struct device *dev) +{ + struct ci_hdrc_imx_data *data = dev_get_drvdata(dev); + + dev_dbg(dev, at %s\n, __func__); + + if (data-in_lpm) + return 0; + clk_disable_unprepare(data-clk); + data-in_lpm = true; + return 0; } +static int imx_controller_resume(struct device *dev) +{ + struct ci_hdrc_imx_data *data = dev_get_drvdata(dev); + int ret = 0; + + dev_dbg(dev, at %s\n, __func__); + + if (!data-in_lpm) + return 0; + + ret = clk_prepare_enable(data-clk); + if (ret) + return ret; + + data-in_lpm = false; + + return ret; +} + +#ifdef CONFIG_PM_SLEEP +static int ci_hdrc_imx_suspend(struct device *dev) +{ + return imx_controller_suspend(dev); +} + +static int ci_hdrc_imx_resume(struct device *dev) +{ + struct ci_hdrc_imx_data *data = dev_get_drvdata(dev); + int ret; + + ret = imx_controller_resume(dev); + if (!ret data-supports_runtime_pm) { + pm_runtime_disable(dev); + pm_runtime_set_active(dev); + pm_runtime_enable(dev); + } + + return ret; +} +#endif /* CONFIG_PM_SLEEP */ + +#ifdef CONFIG_PM_RUNTIME +static int ci_hdrc_imx_runtime_suspend(struct device *dev) +{ + return imx_controller_suspend(dev); +} + +static int ci_hdrc_imx_runtime_resume(struct device *dev) +{ + return imx_controller_resume(dev); +} +#endif /* CONFIG_PM_RUNTIME */ + +#endif /* CONFIG_PM */ +static const struct dev_pm_ops ci_hdrc_imx_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(ci_hdrc_imx_suspend, ci_hdrc_imx_resume) + SET_RUNTIME_PM_OPS(ci_hdrc_imx_runtime_suspend, + ci_hdrc_imx_runtime_resume, NULL) +}; + static struct platform_driver ci_hdrc_imx_driver = { .probe = ci_hdrc_imx_probe, .remove = ci_hdrc_imx_remove, @@ -206,6 +293,7 @@ static struct platform_driver ci_hdrc_imx_driver = { .name = imx_usb, .owner = THIS_MODULE, .of_match_table = ci_hdrc_imx_dt_ids, + .pm = ci_hdrc_imx_pm_ops, }, }; -- 1.7.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