Re: [RESEND PATCHv2 0/3] usb: dwc2/s3c-hsotg: Move the s3c-hsotg driver into dwc2
On Tuesday, March 04, 2014 12:06 PM, Dinh Nguyen wrote: From: Dinh Nguyen dingu...@altera.com Hi, Apologies for sending the wrong 1st patch of this series. --- This is a shortened version of the v1 patch to combine the dwc2/s3c-hsotg into a single dual-role driver. The series will only move the s3c-hsotg driver into the dwc2 folder, use the defines in the dwc2 hw.h, and removes the s3c-hsotg.h defines. This will make the dual-role combining work a bit easier to review in the future. For now, the dwc2 and s3c-hsotg will be separate drivers. Thanks, Dinh Nguyen (3): usb: dwc2: Add defines to support the s3c-hsotg driver usb: s3c-hsotg: Move s3c-hsotg into dwc2 folder usb: s3c-hsotg: Move s3c-hsotg data structures drivers/usb/dwc2/Kconfig | 15 + drivers/usb/dwc2/Makefile| 15 +- drivers/usb/dwc2/core.h | 182 + drivers/usb/dwc2/hw.h| 11 +- drivers/usb/{gadget = dwc2}/s3c-hsotg.c | 593 +++--- drivers/usb/gadget/Kconfig |7 - drivers/usb/gadget/Makefile |1 - drivers/usb/gadget/s3c-hsotg.h | 378 --- 8 files changed, 420 insertions(+), 782 deletions(-) rename drivers/usb/{gadget = dwc2}/s3c-hsotg.c (85%) delete mode 100644 drivers/usb/gadget/s3c-hsotg.h --- Cc: Greg Kroah-Hartman gre...@linuxfoundation.org Cc: Paul Zimmerman pa...@synopsys.com Cc: Felipe Balbi ba...@ti.com Cc: Ben Dooks ben-li...@fluff.org Cc: Matt Porter mpor...@linaro.org Cc: Kukjin Kim kgene@samsung.com Cc: Stephen Warren swar...@wwwdotorg.org Cc: Matthijs Kooijman matth...@stdin.nl Cc: Jingoo Han jg1@samsung.com Tested-by: Jingoo Han jg1@samsung.com I tested these patches on Exynos4210 platform. 's3c-hsotg.c' works properly. Thank you. Best regards, Jingoo Han Cc: Sachin Kamat sachin.ka...@linaro.org Cc: Robert Baldyga r.bald...@samsung.com -- 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 02/12] phy: omap-control: Update DT binding information
Hi Tony, On 03/03/2014 09:02 PM, Tony Lindgren wrote: * Roger Quadros rog...@ti.com [140303 07:10]: Move omap-control binding information to the right location. Signed-off-by: Roger Quadros rog...@ti.com --- Documentation/devicetree/bindings/phy/ti-phy.txt | 25 ++ Documentation/devicetree/bindings/usb/omap-usb.txt | 24 - 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/Documentation/devicetree/bindings/phy/ti-phy.txt b/Documentation/devicetree/bindings/phy/ti-phy.txt index 207e14c..41dc132 100644 --- a/Documentation/devicetree/bindings/phy/ti-phy.txt +++ b/Documentation/devicetree/bindings/phy/ti-phy.txt @@ -1,5 +1,30 @@ TI PHY: DT DOCUMENTATION FOR PHYs in TI PLATFORMs +OMAP CONTROL PHY + +Required properties: + - compatible: Should be one of + ti,control-phy-otghs - if it has otghs_control mailbox register as on OMAP4. + ti,control-phy-usb2 - if it has Power down bit in control_dev_conf register +e.g. USB2_PHY on OMAP5. + ti,control-phy-pipe3 - if it has DPLL and individual Rx Tx power control +e.g. USB3 PHY and SATA PHY on OMAP5. + ti,control-phy-dra7usb2 - if it has power down register like USB2 PHY on +DRA7 platform. + ti,control-phy-am437usb2 - if it has power down register like USB2 PHY on +AM437 platform. To me it seems that you can leave out all the above. You can set these falgs flags directly in the driver based on the compatible flag. Then just initialize the .data in the driver based on the compatible flag. I'm not sure if I got you. A single platform can have different type of phys. e.g. OMAP5 has both usb2 and pipe3 PHYs, DRA7 has both pipe3 and usb2 PHYs, but this usb2 PHY is not compatible with OMAP5 one so we need a new compatible id for that. To add to the woes, the designers were creative enough to make another mutation to the USB2 PHY for AM437x, :( What do you suggest the compatible ids should look like for these 5 types of PHY control? OTGHS (OMAP4 5) USB2(OMAP5) PIPE3 (OMAP5 DRA7) USB2x (DRA7) USB2y (AM437) cheers, -roger + - reg : Address and length of the register set for the device. It contains + the address of otghs_control for control-phy-otghs or power register + for other types. + - reg-names: should be otghs_control control-phy-otghs and power for + other types. + +omap_control_usb: omap-control-usb@4a002300 { +compatible = ti,control-phy-otghs; +reg = 0x4a00233c 0x4; +reg-names = otghs_control; +}; Then you would instead have something like this: compatible = ti,am347-control-phy-otghs; That way you can initialize things without a need for custom bindings. Regards, Tony -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 06/12] phy: omap: Select OMAP_OCP2SCP bus driver
On 03/03/2014 08:52 PM, Tony Lindgren wrote: * Roger Quadros rog...@ti.com [140303 07:11]: The OMAP_USB2 and OMAP_PIP3 phy devices will not be detected if the OMAP_OCP2SCP driver is not present. So select it. Selecting drivers like this will easily lead into missing dependencies. Especially it's bad for tristate driver options that people may want to have as loadable modules. How about instead depends on OMAP_OCP2SCP? OK, 'depends' seems fine. cheers, -roger Signed-off-by: Roger Quadros rog...@ti.com --- drivers/phy/Kconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 2f02ec8..afdab3e 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -44,6 +44,7 @@ config OMAP_USB2 depends on USB_PHY select GENERIC_PHY select OMAP_CONTROL_PHY +select OMAP_OCP2SCP help Enable this to support the transceiver that is part of SOC. This driver takes care of all the PHY functionality apart from comparator. @@ -55,6 +56,7 @@ config TI_PIPE3 depends on ARCH_OMAP2PLUS || COMPILE_TEST select GENERIC_PHY select OMAP_CONTROL_PHY +select OMAP_OCP2SCP help Enable this to support the PIPE3 PHY that is part of TI SOCs. This driver takes care of all the PHY functionality apart from comparator. -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 01/12] phy: rename struct omap_control_usb to struct omap_control_phy
Roger, On Monday 03 March 2014 08:37 PM, Roger Quadros wrote: From: Kishon Vijay Abraham I kis...@ti.com Rename struct omap_control_usb to struct omap_control_phy since it can be used to control PHY of USB, SATA and PCIE. Also move the driver and include files under *phy* and made the corresponding changes in the users of phy-omap-control. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Signed-off-by: Roger Quadros rog...@ti.com --- drivers/phy/Kconfig | 14 +- drivers/phy/Makefile | 1 + drivers/phy/phy-omap-control.c | 320 +++ drivers/phy/phy-omap-usb2.c | 8 +- drivers/phy/phy-ti-pipe3.c | 8 +- drivers/usb/musb/omap2430.c | 2 +- drivers/usb/phy/Kconfig | 10 -- drivers/usb/phy/Makefile | 1 - drivers/usb/phy/phy-omap-control.c | 319 -- include/linux/phy/omap_control_phy.h | 89 ++ include/linux/usb/omap_control_usb.h | 89 -- 11 files changed, 431 insertions(+), 430 deletions(-) create mode 100644 drivers/phy/phy-omap-control.c delete mode 100644 drivers/usb/phy/phy-omap-control.c create mode 100644 include/linux/phy/omap_control_phy.h delete mode 100644 include/linux/usb/omap_control_usb.h you can use git format-patch -M if a file is moved from one place to another. The diff count will be less in that case and reviewing will be easier ;-) Cheers Kishon -- To unsubscribe from this list: send the line unsubscribe 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 03/12] phy: ti-pipe3: cleanup clock handling
Hi, On Monday 03 March 2014 08:37 PM, Roger Quadros wrote: As this driver is no longer USB specific, use generic clock names. - Fix PLL_SD_SHIFT from 9 to 10 - As optclk and wkupclk may not be always required, don't bail out if they aren't available. I think here too we face the same problem as for PHY. What if a particular platform needs a clock but is not available. I don't want this to be blocking though. Thanks Kishon -- To unsubscribe from this list: send the line unsubscribe 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 03/12] phy: ti-pipe3: cleanup clock handling
On 03/04/2014 11:29 AM, Kishon Vijay Abraham I wrote: Hi, On Monday 03 March 2014 08:37 PM, Roger Quadros wrote: As this driver is no longer USB specific, use generic clock names. - Fix PLL_SD_SHIFT from 9 to 10 - As optclk and wkupclk may not be always required, don't bail out if they aren't available. I think here too we face the same problem as for PHY. What if a particular platform needs a clock but is not available. I don't want this to be blocking though. Since we know for sure what clocks the different TI PHYs need, we could do the checks based on compatible id and always fail on clock error. cheers, -roger -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: 3.13-rc1 regression: Scatter-gather list issues at SuperSpeed only
From: Sarah Sharp Greg, Dave, Freddy, question about cross-subsystem reverts below: On Fri, Feb 28, 2014 at 04:15:12PM -0500, Alan Stern wrote: On Fri, 28 Feb 2014, Sarah Sharp wrote: When testing 3.14-rc1 with a USB 3.0 Lexar flash drive, the drive fails to be mounted. I added a bit of debugging to the USB core: That revealed the SCSI request fails because the USB core is rejecting a scatter-gather list with an entry that isn't aligned to the max packet size: Feb 28 09:45:30 xanatos kernel: [ 376.449316] usb 2-2: URB sg entry 0 of 17, size 1536 not a multiple of ep1in max packet 1024 Notice the request length: 1536. That's three 512-byte sectors. A little unusual, since most I/O is done in units of pages, which are 4096 bytes. ... Some of this behavior is to be expected. 1536 isn't a multiple of 1024 (the maxpacket size when running at SuperSpeed), but it _is_ a multiple of 512 (the maxpacket size when running at high speed). Therefore the failure won't occur when the drive is attached to an EHCI controller or is behind a USB-2 hub. ... If we can't figure out how to get max-packet sized scatter-gather list entries from the mass storage driver, Mathias is going to need to: The SG entries don't come from usb-storage; they come from the block layer. As far as I know, there is no way to tell the block layer that each element in an SG list (except the last) must be a multiple of some specific size. revert commit 3804fad45411 USBNET: ax88179_178a: enable tso if usb host supports sg dma revert commit 247bf557273d xhci 1.0: Limit arbitrarily-aligned scatter gather. And we'll need to focus on getting the TD fragments supported in 3.16. So far we've gotten away with this at high speed or below, because no USB mass-storage devices have a block size smaller than 512 (at least, none that I've ever heard of). But when the maxpacket size is 1024, a request for an odd number of blocks can cause trouble. Ok, we can't have SuperSpeed mass storage devices broken, so it looks like we'll have to revert the last patch to add scatter-gather to the ASIX driver to avoid that breakage. That means Mathias is going to need to revert those two commits then, since he's taking over pushing xHCI driver bug fixes this kernel. Greg, Dave, Freddy, how do you want to handle reverting commit 3804fad45411? Should that come through Dave's networking tree or Greg's USB tree? I'm not sure what those two commits have to do with this problem. In order to support a request with a non-terminal buffer that isn't a multiple of 1k you need something to stop a LINK TRB being in the middle of the transfer. Otherwise the 1536 byte transfer (expected as a 1k block followed by 512byte one) can probably get sent as a 512byte block (terminating the bulk data request) followed by a spurious 1k block. These should generate horrid errors from the target disk. The only code I've seen anyone suggest that will correctly send these requests starts from the patches I've sent. I suspect you need to apply ALL of the patches I've sent, and then fixup the remaining problems. David -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Bug ID: 71261 modprobe xhci-hcd driver modules failed
Hi , When we try to modprode Xhci-hcd Driver with dmesg -n 6 command in background , xhci driver loading failed.But if we give dmesg -n 7/5 or any thing its work. When Extended Capability register is being read its given zero insted of 544 value . Here is the Step to reproduce: #dd if=/dev/mtd4 of=/dev/null bs=1M count=64 #dmesg -n 6 #modprobe xhci-hcd [ 201.479243] xhci xhci.0: WARN: no supported page size [ 201.501273] xhci xhci.0: No Extended Capability registers, unable to set up roothub. [ 201.510278] xhci xhci.0: Couldn't initialize memory 7+0 records in 7+0 records out 7340032 bytes (7.0MB) copied, 6.254078 seconds, 1.1MB/s [ 207.996342] xhci xhci.0: Host not halted after 16000 microseconds. [ 208.004166] xhci xhci.0: Host controller not halted, aborting reset. [ 208.011761] Unable to handle kernel NULL pointer dereference at virtual address [ 208.019847] pgd = 830ec000 [ 208.022547] [] *pgd=030d2831, *pte=, *ppte= [ 208.028825] Internal error: Oops: 17 [#1] PREEMPT SMP ARM [ 208.034216] Modules linked in: xhci_hcd(+) [ 208.038317] CPU: 2Not tainted (3.4.14 #14) [ 208.042868] PC is at xhci_mem_cleanup+0x390/0x530 [xhci_hcd] [ 208.048530] LR is at xhci_mem_cleanup+0x384/0x530 [xhci_hcd] [ 208.054185] pc : [7f0091dc]lr : [7f0091d0]psr: a093 [ 208.054189] sp : 83001d30 ip : 836452b0 fp : 002f [ 208.065662] r10: 8a7e102c r9 : 8364bbc8 r8 : [ 208.070881] r7 : 8364df60 r6 : 8a7e1084 r5 : 800186b0 r4 : 8a7e1000 [ 208.077403] r3 : r2 : r1 : r0 : 2013 [ 208.083927] Flags: NzCv IRQs off FIQs on Mode SVC_32 ISA ARM Segment user [ 208.091144] Control: 18c53c7d Table: 030ec04a DAC: 0015 [ 208.096885] Process modprobe (pid: 179, stack limit = 0x830002f0) [ 208.102973] Stack: (0x83001d30 to 0x83002000) [ 208.107327] 1d20: 7f012160 8a7e1000 8364dfc0 [ 208.115502] 1d40: 0001 0001 8364bbc8 7f00a16c 8000e418 [ 208.123678] 1d60: 8a7e1000 0008 0060 8d89a000 00d0 0e405000 0e403000 [ 208.131853] 1d80: 8a74c200 8a7e1000 90a0 8364dfc0 0080 0001 83665ed0 [ 208.140028] 1da0: 002f 7f006308 7f006368 8a74c200 8a74c2a0 0038 80348bec [ 208.148203] 1dc0: 13e5 8364eb98 8d89a000 8364dfb8 8a74c200 0038 8364dfc0 [ 208.156378] 1de0: 13e5 8364eb98 7f0115dc 8364dfc0 8364dfc8 8364dfc0 [ 208.164552] 1e00: 836a7f98 836a7fa0 8365f4a8 7f014300 001c 802c9bd8 802c9bc0 802c8804 [ 208.172727] 1e20: 8338 8364dfc0 7f014300 8364dff4 7f017000 001c 802c8a0c [ 208.180901] 1e40: 7f014300 802c8980 802c6fe4 8d82a360 8d8b9538 7f014300 8365f4a8 [ 208.189076] 1e60: 8a7ea900 802c8028 7f012aa0 7f014300 8d82eb40 7f014300 7f014404 8300 [ 208.197251] 1e80: 7f017000 13e5 001c 002f 802c8f44 [ 208.205425] 1ea0: 7f014404 8300 7f017000 001c 7f017044 83674c80 80008674 [ 208.213599] 1ec0: 8a7b4f40 0001 80065b28 13e5 0001 0001 7f014404 [ 208.221774] 1ee0: 7f01444c 830b1c80 0001 001c 002f 800645bc 7f014410 7fff [ 208.229949] 1f00: 0010c608 0010c5a8 7f014540 8300 0010c5c8 908d612c [ 208.238124] 1f20: 908d71ac 0010c5c8 908c2000 0001c81c 908d6aa4 908d68bb 908d8ecc 00014558 [ 208.246298] 1f40: 00014df8 002d 002e 0024 0019 [ 208.254472] 1f60: 7f0118ac 0001 7f0118b4 0001 800c0620 [ 208.262646] 1f80: 0003 0001c81c 0080 8000ea28 8300 [ 208.270822] 1fa0: 0010c5a8 8000e880 0001c81c 76cf 0001c81c 0010c5c8 0010c608 [ 208.278996] 1fc0: 0001c81c 0080 0010c718 0010c608 0010c608 0010c5a8 [ 208.287171] 1fe0: 7ef2aa88 7ef2aa78 00023abc 76de1020 6010 76cf [ 208.295366] [7f0091dc] (xhci_mem_cleanup+0x390/0x530 [xhci_hcd]) from [7f00a16c] (xhci_mem_init+0xdf0/0x1e20 [xhci_hcd]) [ 208.306597] [7f00a16c] (xhci_mem_init+0xdf0/0x1e20 [xhci_hcd]) from [7f006308] (xhci_gen_setup+0x1ec/0x24c [xhci_hcd]) [ 208.317654] [7f006308] (xhci_gen_setup+0x1ec/0x24c [xhci_hcd]) from [80348bec] (usb_add_hcd+0x188/0x664) [ 208.327494] [80348bec] (usb_add_hcd+0x188/0x664) from [7f0115dc] ( xhci_plat_probe+0x19c/0x264 [xhci_hcd]) [ 208.338027] [7f0115dc] ( xhci_plat_probe+0x19c/0x264 [xhci_hcd]) from [802c9bd8] (platform_drv_probe+0x18/0x1c) [ 208.348993] [802c9bd8] (platform_drv_probe+0x18/0x1c) from [802c8804] (driver_probe_device+0x88/0x204) [ 208.358649] [802c8804] (driver_probe_device+0x88/0x204) from [802c8a0c] (__driver_attach+0x8c/0x90) [ 208.368044] [802c8a0c] (__driver_attach+0x8c/0x90) from [802c6fe4] (bus_for_each_dev+0x50/0x7c) [ 208.377091] [802c6fe4] (bus_for_each_dev+0x50/0x7c) from [802c8028]
RE: some question about xhci TRB_INTR_TARGET
From: vichy hi all: from xhci spec, Interrupter Target is the value between 0 and MaxIntrs-1. But why the parameter pass to TRB_INTR_TARGTRB_INTR_TARGET is always 0. Does that mean so far xhci host didn't support multi-interrupt as MSI-X suggested? AFAIK The Linux USB stack doesn't support the locking required for fine-grained interrupts. So only a single interrupt can be supported. David -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 1/1] xhci: Prevent runtime pm from autosuspending during initialization
On 03/03/2014 08:37 PM, Greg KH wrote: On Mon, Mar 03, 2014 at 07:30:17PM +0200, Mathias Nyman wrote: xHCI driver has its own pci probe function that will call usb_hcd_pci_probe to register its usb-2 bus, and then continue to manually register the usb-3 bus. usb_hcd_pci_probe does a pm_runtime_put_noidle at the end and might thus trigger a runtime suspend before the usb-3 bus is ready. What is the result if that happens? Crashes. Null pointer dereference in xhci_suspend() when touching xhci-shared_hcd before it's initialized. More info here: http://marc.info/?l=linux-usbm=138914518219334w=2 Is this a regression from 3.13? Or something new for 3.14? According to reporter its been around since 3.7 commit 596d789a211d134dc5f94d1e5957248c204ef850 USB: set hub's default autosuspend delay as 0 But nobody else than the reporter is able to trigger it. What platform(s) are affected by this? David, the reporter (added to cc), mentioned This bug happened in a platform with 1 usb3 host controller + 1 usb3 OTG controller run by some Intel internal group http://marc.info/?l=linux-usbm=138915969822029w=2 David, can you elaborate on the platform? xhci-platform driver is not using usb_hcd_pci_probe to set up busses and should not need to have it's usage count increased during probe. I didn't think we had any in-kernel users of the xhci-platform driver, has that changed and I missed a new platform being added? Not that I'm aware of. I just wanted to point out that this issue is only a matter on pci enumerated xhci hosts. -Mathias -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH net-next 12/12] r8152: modify the tx timeout funcfion
Reset and reinitialize the device when the tx timeout occurs. Signed-off-by: Hayes Wang hayesw...@realtek.com --- drivers/net/usb/r8152.c | 41 +++-- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index e04fcbd..23e03a6 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -1791,16 +1791,6 @@ static void rtl_drop_queued_tx(struct r8152 *tp) } } -static void rtl8152_tx_timeout(struct net_device *netdev) -{ - struct r8152 *tp = netdev_priv(netdev); - int i; - - netif_warn(tp, tx_err, netdev, Tx timeout\n); - for (i = 0; i RTL8152_MAX_TX; i++) - usb_unlink_urb(tp-tx_info[i].urb); -} - static void rtl8152_set_rx_mode(struct net_device *netdev) { struct r8152 *tp = netdev_priv(netdev); @@ -3177,6 +3167,37 @@ out: return res; } +static void rtl8152_tx_timeout(struct net_device *netdev) +{ + struct r8152 *tp = netdev_priv(netdev); + + netif_warn(tp, tx_err, netdev, Tx timeout\n); + + if (usb_autopm_get_interface(tp-intf) 0) + return; + + netif_stop_queue(netdev); + clear_bit(WORK_ENABLE, tp-flags); + usb_kill_urb(tp-intr_urb); + cancel_delayed_work_sync(tp-schedule); + tp-rtl_ops.down(tp); + + usb_reset_device(tp-udev); + + tp-rtl_ops.init(tp); + tp-rtl_ops.up(tp); + rtl8152_set_speed(tp, AUTONEG_ENABLE, + tp-mii.supports_gmii ? SPEED_1000 : SPEED_100, + DUPLEX_FULL); + tp-speed = 0; + netif_carrier_off(netdev); + netif_start_queue(netdev); + set_bit(WORK_ENABLE, tp-flags); + usb_submit_urb(tp-intr_urb, GFP_KERNEL); + + usb_autopm_put_interface(tp-intf); +} + static const struct net_device_ops rtl8152_netdev_ops = { .ndo_open = rtl8152_open, .ndo_stop = rtl8152_close, -- 1.8.4.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 net-next 10/12] r8152: reduce the numbers of the bulks
Reduce the numbers of tx and rx aggregation buffers. Signed-off-by: Hayes Wang hayesw...@realtek.com --- drivers/net/usb/r8152.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index 72cbab1..b60b3bc 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -416,8 +416,8 @@ enum rtl_register_content { FULL_DUP= 0x01, }; -#define RTL8152_MAX_TX 10 -#define RTL8152_MAX_RX 10 +#define RTL8152_MAX_TX 4 +#define RTL8152_MAX_RX 4 #define INTBUFSIZE 2 #define CRC_SIZE 4 #define TX_ALIGN 4 -- 1.8.4.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 net-next 11/12] r8152: add additional parameter for non x86 platform
Add additional parameter for non x86 platform for better throughput. Signed-off-by: Hayes Wang hayesw...@realtek.com --- drivers/net/usb/r8152.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index b60b3bc..e04fcbd 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -313,7 +313,11 @@ #define PCUT_STATUS0x0001 /* USB_RX_EARLY_AGG */ -#define EARLY_AGG_SUPPER 0x0e832981 +#if defined(__i386__) || defined(__x86_64__) + #define EARLY_AGG_SUPPER0x0e832981 +#else + #define EARLY_AGG_SUPPER0x0e835000 +#endif #define EARLY_AGG_HIGH 0x0e837a12 #define EARLY_AGG_SLOW 0x0e83 -- 1.8.4.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 net-next 09/12] r8152: support IPv6
Support hw IPv6 checksum for TCP and UDP packets. Note that the hw has the limitation of the range of the transport offset. Besides, the TCP Pseudo Header of the IPv6 TSO of the hw bases on the Microsoft document which excludes the packet length. Signed-off-by: Hayes Wang hayesw...@realtek.com --- drivers/net/usb/r8152.c | 107 ++-- 1 file changed, 104 insertions(+), 3 deletions(-) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index 774a19a..72cbab1 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -21,6 +21,7 @@ #include linux/list.h #include linux/ip.h #include linux/ipv6.h +#include net/ip6_checksum.h /* Version Information */ #define DRIVER_VERSION v1.06.0 (2014/03/03) @@ -474,6 +475,7 @@ struct rx_desc { __le32 opts2; #define RD_UDP_CS (1 23) #define RD_TCP_CS (1 22) +#define RD_IPV6_CS (1 20) #define RD_IPV4_CS (1 19) __le32 opts3; @@ -491,7 +493,9 @@ struct tx_desc { #define TX_FS (1 31) /* First segment of a packet */ #define TX_LS (1 30) /* Final segment of a packet */ #define GTSENDV4 (1 28) +#define GTSENDV6 (1 27) #define GTTCPHO_SHIFT 18 +#define GTTCPHO_MAX0x7fU #define TX_LEN_MAX 0x3U __le32 opts2; @@ -502,6 +506,7 @@ struct tx_desc { #define MSS_SHIFT 17 #define MSS_MAX0x7ffU #define TCPHO_SHIFT17 +#define TCPHO_MAX 0x7ffU }; struct r8152; @@ -1321,6 +1326,65 @@ static inline __be16 get_protocol(struct sk_buff *skb) return protocol; } +/* + * r8152_csum_workaround() + * The hw limites the value the transport offset. When the offset is out of the + * range, calculate the checksum by sw. + */ +static void r8152_csum_workaround(struct r8152 *tp, struct sk_buff *skb, + struct sk_buff_head *list) +{ + if (skb_shinfo(skb)-gso_size) { + netdev_features_t features = tp-netdev-features; + struct sk_buff *segs, *nskb; + + features = ~(NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_TSO); + segs = skb_gso_segment(skb, features); + if (IS_ERR(segs) || !segs) + goto drop; + + do { + nskb = segs; + segs = segs-next; + nskb-next = NULL; + __skb_queue_head(list, nskb); + } while (segs); + + dev_kfree_skb(skb); + } else if (skb-ip_summed == CHECKSUM_PARTIAL) { + if (skb_checksum_help(skb) 0) + goto drop; + + __skb_queue_head(list, skb); + } else { + struct net_device_stats *stats; + +drop: + stats = tp-netdev-stats; + stats-tx_dropped++; + dev_kfree_skb(skb); + } +} + +/* + * msdn_giant_send_check() + * According to the document of microsoft, the TCP Pseudo Header excludes the + * packet length for IPv6 TCP large packets. + */ +static int msdn_giant_send_check(struct sk_buff *skb) +{ + const struct ipv6hdr *ipv6h; + struct tcphdr *th; + + ipv6h = ipv6_hdr(skb); + th = tcp_hdr(skb); + + th-check = 0; + th-check = ~tcp_v6_check(0, ipv6h-saddr, ipv6h-daddr, 0); + + return 0; +} + static int r8152_tx_csum(struct r8152 *tp, struct tx_desc *desc, struct sk_buff *skb, u32 len, u32 transport_offset) { @@ -1333,11 +1397,24 @@ static int r8152_tx_csum(struct r8152 *tp, struct tx_desc *desc, opts1 = len | TX_FS | TX_LS; if (mss) { + if (transport_offset GTTCPHO_MAX) { + netif_warn(tp, tx_err, tp-netdev, + Invalid transport offset 0x%x for TSO\n, + transport_offset); + ret = TX_CSUM_TSO; + goto unavailable; + } + switch (get_protocol(skb)) { case htons(ETH_P_IP): opts1 |= GTSENDV4; break; + case htons(ETH_P_IPV6): + opts1 |= GTSENDV6; + msdn_giant_send_check(skb); + break; + default: WARN_ON_ONCE(1); break; @@ -1348,6 +1425,14 @@ static int r8152_tx_csum(struct r8152 *tp, struct tx_desc *desc, } else if (skb-ip_summed == CHECKSUM_PARTIAL) { u8 ip_protocol; + if (transport_offset TCPHO_MAX) { + netif_warn(tp, tx_err, tp-netdev, + Invalid transport offset 0x%x\n, +
[PATCH net-next 06/12] r8152: up the priority of the transmission
move the tx_bottom() from delayed_work to tasklet. It makes the rx and tx balanced. If the device is in runtime suspend when getting the tx packet, wakeup the device before trasmitting. Signed-off-by: Hayes Wang hayesw...@realtek.com --- drivers/net/usb/r8152.c | 45 +++-- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index 00b3192..f1eaa18 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -447,6 +447,7 @@ enum rtl8152_flags { RTL8152_LINK_CHG, SELECTIVE_SUSPEND, PHY_RESET, + SCHEDULE_TASKLET, }; /* Define these values to match your device */ @@ -1071,7 +1072,7 @@ static void write_bulk_callback(struct urb *urb) return; if (!skb_queue_empty(tp-tx_queue)) - schedule_delayed_work(tp-schedule, 0); + tasklet_schedule(tp-tl); } static void intr_callback(struct urb *urb) @@ -1335,9 +1336,9 @@ static int r8152_tx_agg_fill(struct r8152 *tp, struct tx_agg *agg) u8 *tx_data; __skb_queue_head_init(skb_head); - spin_lock_bh(tx_queue-lock); + spin_lock(tx_queue-lock); skb_queue_splice_init(tx_queue, skb_head); - spin_unlock_bh(tx_queue-lock); + spin_unlock(tx_queue-lock); tx_data = agg-head; agg-skb_num = agg-skb_len = 0; @@ -1374,20 +1375,20 @@ static int r8152_tx_agg_fill(struct r8152 *tp, struct tx_agg *agg) } if (!skb_queue_empty(skb_head)) { - spin_lock_bh(tx_queue-lock); + spin_lock(tx_queue-lock); skb_queue_splice(skb_head, tx_queue); - spin_unlock_bh(tx_queue-lock); + spin_unlock(tx_queue-lock); } - netif_tx_lock_bh(tp-netdev); + netif_tx_lock(tp-netdev); if (netif_queue_stopped(tp-netdev) skb_queue_len(tp-tx_queue) tp-tx_qlen) netif_wake_queue(tp-netdev); - netif_tx_unlock_bh(tp-netdev); + netif_tx_unlock(tp-netdev); - ret = usb_autopm_get_interface(tp-intf); + ret = usb_autopm_get_interface_async(tp-intf); if (ret 0) goto out_tx_fill; @@ -1395,9 +1396,9 @@ static int r8152_tx_agg_fill(struct r8152 *tp, struct tx_agg *agg) agg-head, (int)(tx_data - (u8 *)agg-head), (usb_complete_t)write_bulk_callback, agg); - ret = usb_submit_urb(agg-urb, GFP_KERNEL); + ret = usb_submit_urb(agg-urb, GFP_ATOMIC); if (ret 0) - usb_autopm_put_interface(tp-intf); + usb_autopm_put_interface_async(tp-intf); out_tx_fill: return ret; @@ -1535,6 +1536,7 @@ static void bottom_half(unsigned long data) return; rx_bottom(tp); + tx_bottom(tp); } static @@ -1630,7 +1632,7 @@ static void _rtl8152_set_rx_mode(struct net_device *netdev) } static netdev_tx_t rtl8152_start_xmit(struct sk_buff *skb, - struct net_device *netdev) + struct net_device *netdev) { struct r8152 *tp = netdev_priv(netdev); @@ -1638,13 +1640,17 @@ static netdev_tx_t rtl8152_start_xmit(struct sk_buff *skb, skb_queue_tail(tp-tx_queue, skb); - if (list_empty(tp-tx_free) - skb_queue_len(tp-tx_queue) tp-tx_qlen) + if (!list_empty(tp-tx_free)) { + if (test_bit(SELECTIVE_SUSPEND, tp-flags)) { + set_bit(SCHEDULE_TASKLET, tp-flags); + schedule_delayed_work(tp-schedule, 0); + } else { + usb_mark_last_busy(tp-udev); + tasklet_schedule(tp-tl); + } + } else if (skb_queue_len(tp-tx_queue) tp-tx_qlen) netif_stop_queue(netdev); - if (!list_empty(tp-tx_free)) - schedule_delayed_work(tp-schedule, 0); - return NETDEV_TX_OK; } @@ -2523,8 +2529,11 @@ static void rtl_work_func_t(struct work_struct *work) if (test_bit(RTL8152_SET_RX_MODE, tp-flags)) _rtl8152_set_rx_mode(tp-netdev); - if (tp-speed LINK_STATUS) - tx_bottom(tp); + if (test_bit(SCHEDULE_TASKLET, tp-flags) + (tp-speed LINK_STATUS)) { + clear_bit(SCHEDULE_TASKLET, tp-flags); + tasklet_schedule(tp-tl); + } if (test_bit(PHY_RESET, tp-flags)) rtl_phy_reset(tp); -- 1.8.4.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 net-next 05/12] r8152: check tx agg list before spin lock
Check tx agg list before spin lock to avoid doing spin lock every times. Signed-off-by: Hayes Wang hayesw...@realtek.com --- drivers/net/usb/r8152.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index 8ecb41b..00b3192 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -1266,6 +1266,9 @@ static struct tx_agg *r8152_get_tx_agg(struct r8152 *tp) struct tx_agg *agg = NULL; unsigned long flags; + if (list_empty(tp-tx_free)) + return NULL; + spin_lock_irqsave(tp-tx_lock, flags); if (!list_empty(tp-tx_free)) { struct list_head *cursor; -- 1.8.4.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 net-next 07/12] r8152: support rx checksum
Support hw rx checksum for TCP and UDP packets. Signed-off-by: Hayes Wang hayesw...@realtek.com --- drivers/net/usb/r8152.c | 53 ++--- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index f1eaa18..5fdf0af 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -464,11 +464,23 @@ enum rtl8152_flags { #define REALTEK_USB_DEVICE(vend, prod) \ USB_DEVICE_INTERFACE_CLASS(vend, prod, USB_CLASS_VENDOR_SPEC) +#define RTL_CHECKSUM_FAIL -1 + struct rx_desc { __le32 opts1; +#define RD_CRC (1 15) #define RX_LEN_MASK0x7fff + __le32 opts2; +#define RD_UDP_CS (1 23) +#define RD_TCP_CS (1 22) +#define RD_IPV4_CS (1 19) + __le32 opts3; +#define IPF(1 23) /* IP checksum fail */ +#define UDPF (1 22) /* UDP checksum fail */ +#define TCPF (1 21) /* TCP checksum fail */ + __le32 opts4; __le32 opts5; __le32 opts6; @@ -1404,6 +1416,31 @@ out_tx_fill: return ret; } +static int r8152_rx_csum(struct r8152 *tp, struct rx_desc *rx_desc) +{ + int checksum = CHECKSUM_NONE; + u32 opts2, opts3; + + if (tp-version == RTL_VER_01) + goto return_result; + + opts2 = le32_to_cpu(rx_desc-opts2); + opts3 = le32_to_cpu(rx_desc-opts3); + + if (opts2 RD_IPV4_CS) { + if (opts3 IPF) + checksum = RTL_CHECKSUM_FAIL; + else if (((opts2 RD_UDP_CS) (opts3 UDPF)) || +((opts2 RD_TCP_CS) (opts3 TCPF))) + checksum = RTL_CHECKSUM_FAIL; + else + checksum = CHECKSUM_UNNECESSARY; + } + +return_result: + return checksum; +} + static void rx_bottom(struct r8152 *tp) { unsigned long flags; @@ -1441,6 +1478,7 @@ static void rx_bottom(struct r8152 *tp) struct net_device_stats *stats = netdev-stats; unsigned int pkt_len; struct sk_buff *skb; + int checksum; pkt_len = le32_to_cpu(rx_desc-opts1) RX_LEN_MASK; if (pkt_len ETH_ZLEN) @@ -1453,11 +1491,19 @@ static void rx_bottom(struct r8152 *tp) pkt_len -= CRC_SIZE; rx_data += sizeof(struct rx_desc); + checksum = r8152_rx_csum(tp, rx_desc); + if (checksum == RTL_CHECKSUM_FAIL) { + stats-rx_errors++; + goto find_next_rx; + } + skb = netdev_alloc_skb_ip_align(netdev, pkt_len); if (!skb) { stats-rx_dropped++; - break; + goto find_next_rx; } + + skb-ip_summed = checksum; memcpy(skb-data, rx_data, pkt_len); skb_put(skb, pkt_len); skb-protocol = eth_type_trans(skb, netdev); @@ -1465,6 +1511,7 @@ static void rx_bottom(struct r8152 *tp) stats-rx_packets++; stats-rx_bytes += pkt_len; +find_next_rx: rx_data = rx_agg_align(rx_data + pkt_len + CRC_SIZE); rx_desc = (struct rx_desc *)rx_data; len_used = (int)(rx_data - (u8 *)agg-head); @@ -3102,8 +3149,8 @@ static int rtl8152_probe(struct usb_interface *intf, netdev-netdev_ops = rtl8152_netdev_ops; netdev-watchdog_timeo = RTL8152_TX_TIMEOUT; - netdev-features |= NETIF_F_IP_CSUM; - netdev-hw_features = NETIF_F_IP_CSUM; + netdev-features |= NETIF_F_RXCSUM | NETIF_F_IP_CSUM; + netdev-hw_features = NETIF_F_RXCSUM | NETIF_F_IP_CSUM; SET_ETHTOOL_OPS(netdev, ops); -- 1.8.4.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 net-next 08/12] r8152: support TSO
Support scatter gather and TSO. Adjust the tx checksum function and set the max gso size to fix the size of the tx aggregation buffer. Signed-off-by: Hayes Wang hayesw...@realtek.com --- drivers/net/usb/r8152.c | 133 +--- 1 file changed, 103 insertions(+), 30 deletions(-) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index 5fdf0af..774a19a 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -23,7 +23,7 @@ #include linux/ipv6.h /* Version Information */ -#define DRIVER_VERSION v1.05.0 (2014/02/18) +#define DRIVER_VERSION v1.06.0 (2014/03/03) #define DRIVER_AUTHOR Realtek linux nic maintainers nic_s...@realtek.com #define DRIVER_DESC Realtek RTL8152/RTL8153 Based USB Ethernet Adapters #define MODULENAME r8152 @@ -490,13 +490,18 @@ struct tx_desc { __le32 opts1; #define TX_FS (1 31) /* First segment of a packet */ #define TX_LS (1 30) /* Final segment of a packet */ -#define TX_LEN_MASK0x3 +#define GTSENDV4 (1 28) +#define GTTCPHO_SHIFT 18 +#define TX_LEN_MAX 0x3U __le32 opts2; #define UDP_CS (1 31) /* Calculate UDP/IP checksum */ #define TCP_CS (1 30) /* Calculate TCP/IP checksum */ #define IPV4_CS(1 29) /* Calculate IPv4 checksum */ #define IPV6_CS(1 28) /* Calculate IPv6 checksum */ +#define MSS_SHIFT 17 +#define MSS_MAX0x7ffU +#define TCPHO_SHIFT17 }; struct r8152; @@ -563,12 +568,21 @@ enum rtl_version { RTL_VER_MAX }; +enum tx_csum_stat { + TX_CSUM_SUCCESS = 0, + TX_CSUM_TSO, + TX_CSUM_NONE +}; + /* Maximum number of multicast addresses to filter (vs. Rx-all-multicast). * The RTL chips use a 64 element hash table based on the Ethernet CRC. */ static const int multicast_filter_limit = 32; static unsigned int rx_buf_sz = 16384; +#define RTL_LIMITED_TSO_SIZE (rx_buf_sz - sizeof(struct tx_desc) - \ +VLAN_ETH_HLEN - VLAN_HLEN) + static int get_registers(struct r8152 *tp, u16 value, u16 index, u16 size, void *data) { @@ -1295,24 +1309,46 @@ static struct tx_agg *r8152_get_tx_agg(struct r8152 *tp) return agg; } -static void -r8152_tx_csum(struct r8152 *tp, struct tx_desc *desc, struct sk_buff *skb) +static inline __be16 get_protocol(struct sk_buff *skb) { - memset(desc, 0, sizeof(*desc)); + __be16 protocol; - desc-opts1 = cpu_to_le32((skb-len TX_LEN_MASK) | TX_FS | TX_LS); + if (skb-protocol == htons(ETH_P_8021Q)) + protocol = vlan_eth_hdr(skb)-h_vlan_encapsulated_proto; + else + protocol = skb-protocol; - if (skb-ip_summed == CHECKSUM_PARTIAL) { - __be16 protocol; - u8 ip_protocol; - u32 opts2 = 0; + return protocol; +} - if (skb-protocol == htons(ETH_P_8021Q)) - protocol = vlan_eth_hdr(skb)-h_vlan_encapsulated_proto; - else - protocol = skb-protocol; +static int r8152_tx_csum(struct r8152 *tp, struct tx_desc *desc, +struct sk_buff *skb, u32 len, u32 transport_offset) +{ + u32 mss = skb_shinfo(skb)-gso_size; + u32 opts1, opts2 = 0; + int ret = TX_CSUM_SUCCESS; + + WARN_ON_ONCE(len TX_LEN_MAX); + + opts1 = len | TX_FS | TX_LS; + + if (mss) { + switch (get_protocol(skb)) { + case htons(ETH_P_IP): + opts1 |= GTSENDV4; + break; - switch (protocol) { + default: + WARN_ON_ONCE(1); + break; + } + + opts1 |= transport_offset GTTCPHO_SHIFT; + opts2 |= min(mss, MSS_MAX) MSS_SHIFT; + } else if (skb-ip_summed == CHECKSUM_PARTIAL) { + u8 ip_protocol; + + switch (get_protocol(skb)) { case htons(ETH_P_IP): opts2 |= IPV4_CS; ip_protocol = ip_hdr(skb)-protocol; @@ -1328,17 +1364,44 @@ r8152_tx_csum(struct r8152 *tp, struct tx_desc *desc, struct sk_buff *skb) break; } - if (ip_protocol == IPPROTO_TCP) { + if (ip_protocol == IPPROTO_TCP) opts2 |= TCP_CS; - opts2 |= (skb_transport_offset(skb) 0x7fff) 17; - } else if (ip_protocol == IPPROTO_UDP) { + else if (ip_protocol == IPPROTO_UDP) opts2 |= UDP_CS; - } else { + else WARN_ON_ONCE(1); - } - desc-opts2 = cpu_to_le32(opts2); + opts2 |= transport_offset
[PATCH net-next 02/12] r8152: replace tp-netdev with netdev
Replace some tp-netdev with netdev. Signed-off-by: Hayes Wang hayesw...@realtek.com --- drivers/net/usb/r8152.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index c8bad62..151398b 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -1037,6 +1037,7 @@ static void read_bulk_callback(struct urb *urb) static void write_bulk_callback(struct urb *urb) { struct net_device_stats *stats; + struct net_device *netdev; unsigned long flags; struct tx_agg *agg; struct r8152 *tp; @@ -1050,10 +1051,11 @@ static void write_bulk_callback(struct urb *urb) if (!tp) return; - stats = rtl8152_get_stats(tp-netdev); + netdev = tp-netdev; + stats = rtl8152_get_stats(netdev); if (status) { if (net_ratelimit()) - netdev_warn(tp-netdev, Tx status %d\n, status); + netdev_warn(netdev, Tx status %d\n, status); stats-tx_errors += agg-skb_num; } else { stats-tx_packets += agg-skb_num; @@ -1066,7 +1068,7 @@ static void write_bulk_callback(struct urb *urb) usb_autopm_put_interface_async(tp-intf); - if (!netif_carrier_ok(tp-netdev)) + if (!netif_carrier_ok(netdev)) return; if (!test_bit(WORK_ENABLE, tp-flags)) -- 1.8.4.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 net-next 04/12] r8152: replace spin_lock_irqsave and spin_unlock_irqrestore
Use spin_lock and spin_unlock in interrupt context. The ndo_start_xmit would not be called in interrupt context, so replace the relative spin_lock_irqsave and spin_unlock_irqrestore with spin_lock_bh and spin_unlock_bh. Signed-off-by: Hayes Wang hayesw...@realtek.com --- drivers/net/usb/r8152.c | 28 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index b8eee36..8ecb41b 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -963,7 +963,6 @@ static int rtl8152_set_mac_address(struct net_device *netdev, void *p) static void read_bulk_callback(struct urb *urb) { struct net_device *netdev; - unsigned long flags; int status = urb-status; struct rx_agg *agg; struct r8152 *tp; @@ -997,9 +996,9 @@ static void read_bulk_callback(struct urb *urb) if (urb-actual_length ETH_ZLEN) break; - spin_lock_irqsave(tp-rx_lock, flags); + spin_lock(tp-rx_lock); list_add_tail(agg-list, tp-rx_done); - spin_unlock_irqrestore(tp-rx_lock, flags); + spin_unlock(tp-rx_lock); tasklet_schedule(tp-tl); return; case -ESHUTDOWN: @@ -1022,9 +1021,9 @@ static void read_bulk_callback(struct urb *urb) if (result == -ENODEV) { netif_device_detach(tp-netdev); } else if (result) { - spin_lock_irqsave(tp-rx_lock, flags); + spin_lock(tp-rx_lock); list_add_tail(agg-list, tp-rx_done); - spin_unlock_irqrestore(tp-rx_lock, flags); + spin_unlock(tp-rx_lock); tasklet_schedule(tp-tl); } } @@ -1033,7 +1032,6 @@ static void write_bulk_callback(struct urb *urb) { struct net_device_stats *stats; struct net_device *netdev; - unsigned long flags; struct tx_agg *agg; struct r8152 *tp; int status = urb-status; @@ -1057,9 +1055,9 @@ static void write_bulk_callback(struct urb *urb) stats-tx_bytes += agg-skb_len; } - spin_lock_irqsave(tp-tx_lock, flags); + spin_lock(tp-tx_lock); list_add_tail(agg-list, tp-tx_free); - spin_unlock_irqrestore(tp-tx_lock, flags); + spin_unlock(tp-tx_lock); usb_autopm_put_interface_async(tp-intf); @@ -1330,14 +1328,13 @@ r8152_tx_csum(struct r8152 *tp, struct tx_desc *desc, struct sk_buff *skb) static int r8152_tx_agg_fill(struct r8152 *tp, struct tx_agg *agg) { struct sk_buff_head skb_head, *tx_queue = tp-tx_queue; - unsigned long flags; int remain, ret; u8 *tx_data; __skb_queue_head_init(skb_head); - spin_lock_irqsave(tx_queue-lock, flags); + spin_lock_bh(tx_queue-lock); skb_queue_splice_init(tx_queue, skb_head); - spin_unlock_irqrestore(tx_queue-lock, flags); + spin_unlock_bh(tx_queue-lock); tx_data = agg-head; agg-skb_num = agg-skb_len = 0; @@ -1374,9 +1371,9 @@ static int r8152_tx_agg_fill(struct r8152 *tp, struct tx_agg *agg) } if (!skb_queue_empty(skb_head)) { - spin_lock_irqsave(tx_queue-lock, flags); + spin_lock_bh(tx_queue-lock); skb_queue_splice(skb_head, tx_queue); - spin_unlock_irqrestore(tx_queue-lock, flags); + spin_unlock_bh(tx_queue-lock); } netif_tx_lock_bh(tp-netdev); @@ -1551,16 +1548,15 @@ static void rtl_drop_queued_tx(struct r8152 *tp) { struct net_device_stats *stats = tp-netdev-stats; struct sk_buff_head skb_head, *tx_queue = tp-tx_queue; - unsigned long flags; struct sk_buff *skb; if (skb_queue_empty(tx_queue)) return; __skb_queue_head_init(skb_head); - spin_lock_irqsave(tx_queue-lock, flags); + spin_lock_bh(tx_queue-lock); skb_queue_splice_init(tx_queue, skb_head); - spin_unlock_irqrestore(tx_queue-lock, flags); + spin_unlock_bh(tx_queue-lock); while ((skb = __skb_dequeue(skb_head))) { dev_kfree_skb(skb); -- 1.8.4.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 net-next 03/12] r8152: remove rtl8152_get_stats
The rtl8152_get_stats() returns the point address of the struct net_device_stats. This could be got from struct net_device directly. Signed-off-by: Hayes Wang hayesw...@realtek.com --- drivers/net/usb/r8152.c | 21 ++--- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index 151398b..b8eee36 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -960,11 +960,6 @@ static int rtl8152_set_mac_address(struct net_device *netdev, void *p) return 0; } -static struct net_device_stats *rtl8152_get_stats(struct net_device *dev) -{ - return dev-stats; -} - static void read_bulk_callback(struct urb *urb) { struct net_device *netdev; @@ -1052,7 +1047,7 @@ static void write_bulk_callback(struct urb *urb) return; netdev = tp-netdev; - stats = rtl8152_get_stats(netdev); + stats = netdev-stats; if (status) { if (net_ratelimit()) netdev_warn(netdev, Tx status %d\n, status); @@ -1442,7 +1437,7 @@ static void rx_bottom(struct r8152 *tp) while (urb-actual_length len_used) { struct net_device *netdev = tp-netdev; - struct net_device_stats *stats; + struct net_device_stats *stats = netdev-stats; unsigned int pkt_len; struct sk_buff *skb; @@ -1454,8 +1449,6 @@ static void rx_bottom(struct r8152 *tp) if (urb-actual_length len_used) break; - stats = rtl8152_get_stats(netdev); - pkt_len -= CRC_SIZE; rx_data += sizeof(struct rx_desc); @@ -1504,16 +1497,14 @@ static void tx_bottom(struct r8152 *tp) res = r8152_tx_agg_fill(tp, agg); if (res) { - struct net_device_stats *stats; - struct net_device *netdev; - unsigned long flags; - - netdev = tp-netdev; - stats = rtl8152_get_stats(netdev); + struct net_device *netdev = tp-netdev; if (res == -ENODEV) { netif_device_detach(netdev); } else { + struct net_device_stats *stats = netdev-stats; + unsigned long flags; + netif_warn(tp, tx_err, netdev, failed tx_urb %d\n, res); stats-tx_dropped += agg-skb_num; -- 1.8.4.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 net-next 00/12] r8152: new features
Besides the adjustment of the code, support rx checksum, TCP large send, and IPv6. Hayes Wang (12): r8152: deal with the empty line and space r8152: replace tp-netdev with netdev r8152: remove rtl8152_get_stats r8152: replace spin_lock_irqsave and spin_unlock_irqrestore r8152: check tx agg list before spin lock r8152: up the priority of the transmission r8152: support rx checksum r8152: support TSO r8152: support IPv6 r8152: reduce the numbers of the bulks r8152: add additional parameter for non x86 platform r8152: modify the tx timeout funcfion drivers/net/usb/r8152.c | 436 +--- 1 file changed, 343 insertions(+), 93 deletions(-) -- 1.8.4.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 net-next 01/12] r8152: deal with the empty line and space
Add or remove some empty lines. Replace the spaces with the tabs. Signed-off-by: Hayes Wang hayesw...@realtek.com --- drivers/net/usb/r8152.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index 0654bd3..c8bad62 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -593,6 +593,7 @@ int set_registers(struct r8152 *tp, u16 value, u16 index, u16 size, void *data) value, index, tmp, size, 500); kfree(tmp); + return ret; } @@ -1514,6 +1515,7 @@ static void tx_bottom(struct r8152 *tp) netif_warn(tp, tx_err, netdev, failed tx_urb %d\n, res); stats-tx_dropped += agg-skb_num; + spin_lock_irqsave(tp-tx_lock, flags); list_add_tail(agg-list, tp-tx_free); spin_unlock_irqrestore(tp-tx_lock, flags); @@ -1833,7 +1835,6 @@ static void r8152_power_cut_en(struct r8152 *tp, bool enable) ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_PM_CTRL_STATUS); ocp_data = ~RESUME_INDICATE; ocp_write_word(tp, MCU_TYPE_USB, USB_PM_CTRL_STATUS, ocp_data); - } #define WAKE_ANY (WAKE_PHY | WAKE_MAGIC | WAKE_UCAST | WAKE_BCAST | WAKE_MCAST) @@ -2013,8 +2014,8 @@ static void r8152b_hw_phy_cfg(struct r8152 *tp) static void r8152b_exit_oob(struct r8152 *tp) { - u32 ocp_data; - int i; + u32 ocp_data; + int i; ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR); ocp_data = ~RCR_ACPT_ALL; @@ -2573,6 +2574,7 @@ static int rtl8152_open(struct net_device *netdev) netif_carrier_off(netdev); netif_start_queue(netdev); set_bit(WORK_ENABLE, tp-flags); + res = usb_submit_urb(tp-intr_urb, GFP_KERNEL); if (res) { if (res == -ENODEV) @@ -3101,6 +3103,7 @@ static int rtl8152_probe(struct usb_interface *intf, netdev-features |= NETIF_F_IP_CSUM; netdev-hw_features = NETIF_F_IP_CSUM; + SET_ETHTOOL_OPS(netdev, ops); tp-mii.dev = netdev; -- 1.8.4.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: [PATCH net-next 08/12] r8152: support TSO
From: Hayes Wang Support scatter gather and TSO. Adjust the tx checksum function and set the max gso size to fix the size of the tx aggregation buffer. There is little point supporting TSO unless the usb host controller supports arbitrary aligned scatter-gather. All you do is require that a large skb be allocated (that may well fail), and add it another data copy. The xhci controller is almost capable of arbitrary scatter-gather, but it is currently disabled because the data must be aligned at the end of the transfer ring (the hardware designers have made it almost impossible to write efficient software). Note that the various xhci controllers behave subtly differently. David -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: some question about xhci TRB_INTR_TARGET
hi David: 2014-03-04 19:40 GMT+08:00 David Laight david.lai...@aculab.com: From: vichy hi all: from xhci spec, Interrupter Target is the value between 0 and MaxIntrs-1. But why the parameter pass to TRB_INTR_TARGTRB_INTR_TARGET is always 0. Does that mean so far xhci host didn't support multi-interrupt as MSI-X suggested? AFAIK The Linux USB stack doesn't support the locking required for fine-grained interrupts. So only a single interrupt can be supported. is there any special reason we don't support fine-grained interrupts? it semes PCI has support MSI-X quite long ago. Thanks for your kind reply, -- To unsubscribe from this list: send the line unsubscribe 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] r8152: disable the ECM mode
There are known issues for switching the drivers between ECM mode and vendor mode. The interrup transfer may become abnormal. The hardware may have the opportunity to die if you change the configuration without unloading the current driver first, because all the control transfers of the current driver would fail after the command of switching the configuration. Although to use the ecm driver and vendor driver independently is fine, it may have problems to change the driver from one to the other by switching the configuration. Additionally, now the vendor mode driver is more powerful than the ECM driver. Thus, disable the ECM mode driver, and let r8152 to set the configuration to vendor mode and reset the device automatically. Signed-off-by: Hayes Wang hayesw...@realtek.com --- drivers/net/usb/Makefile| 2 +- drivers/net/usb/cdc_ether.c | 7 ++ drivers/net/usb/r8152.c | 15 +-- drivers/net/usb/r815x.c | 248 4 files changed, 17 insertions(+), 255 deletions(-) delete mode 100644 drivers/net/usb/r815x.c diff --git a/drivers/net/usb/Makefile b/drivers/net/usb/Makefile index 433f0a0..e2797f1 100644 --- a/drivers/net/usb/Makefile +++ b/drivers/net/usb/Makefile @@ -11,7 +11,7 @@ obj-$(CONFIG_USB_HSO) += hso.o obj-$(CONFIG_USB_NET_AX8817X) += asix.o asix-y := asix_devices.o asix_common.o ax88172a.o obj-$(CONFIG_USB_NET_AX88179_178A) += ax88179_178a.o -obj-$(CONFIG_USB_NET_CDCETHER) += cdc_ether.o r815x.o +obj-$(CONFIG_USB_NET_CDCETHER) += cdc_ether.o obj-$(CONFIG_USB_NET_CDC_EEM) += cdc_eem.o obj-$(CONFIG_USB_NET_DM9601) += dm9601.o obj-$(CONFIG_USB_NET_SR9700) += sr9700.o diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c index 42e1769..bd363b2 100644 --- a/drivers/net/usb/cdc_ether.c +++ b/drivers/net/usb/cdc_ether.c @@ -652,6 +652,13 @@ static const struct usb_device_id products[] = { .driver_info = 0, }, +/* Samsung USB Ethernet Adapters */ +{ + USB_DEVICE_AND_INTERFACE_INFO(SAMSUNG_VENDOR_ID, 0xa101, USB_CLASS_COMM, + USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), + .driver_info = 0, +}, + /* WHITELIST!!! * * CDC Ether uses two interfaces, not necessarily consecutive. diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index d89dbe3..adb12f3 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -449,9 +449,6 @@ enum rtl8152_flags { #define MCU_TYPE_PLA 0x0100 #define MCU_TYPE_USB 0x -#define REALTEK_USB_DEVICE(vend, prod) \ - USB_DEVICE_INTERFACE_CLASS(vend, prod, USB_CLASS_VENDOR_SPEC) - struct rx_desc { __le32 opts1; #define RX_LEN_MASK0x7fff @@ -2739,6 +2736,12 @@ static int rtl8152_probe(struct usb_interface *intf, struct net_device *netdev; int ret; + if (udev-actconfig-desc.bConfigurationValue != 1) { + usb_driver_set_configuration(udev, 1); + return -ENODEV; + } + + usb_reset_device(udev); netdev = alloc_etherdev(sizeof(struct r8152)); if (!netdev) { dev_err(intf-dev, Out of memory\n); @@ -2819,9 +2822,9 @@ static void rtl8152_disconnect(struct usb_interface *intf) /* table of devices that work with this driver */ static struct usb_device_id rtl8152_table[] = { - {REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, PRODUCT_ID_RTL8152)}, - {REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, PRODUCT_ID_RTL8153)}, - {REALTEK_USB_DEVICE(VENDOR_ID_SAMSUNG, PRODUCT_ID_SAMSUNG)}, + {USB_DEVICE(VENDOR_ID_REALTEK, PRODUCT_ID_RTL8152)}, + {USB_DEVICE(VENDOR_ID_REALTEK, PRODUCT_ID_RTL8153)}, + {USB_DEVICE(VENDOR_ID_SAMSUNG, PRODUCT_ID_SAMSUNG)}, {} }; diff --git a/drivers/net/usb/r815x.c b/drivers/net/usb/r815x.c deleted file mode 100644 index f0a8791..000 --- a/drivers/net/usb/r815x.c +++ /dev/null @@ -1,248 +0,0 @@ -#include linux/module.h -#include linux/netdevice.h -#include linux/mii.h -#include linux/usb.h -#include linux/usb/cdc.h -#include linux/usb/usbnet.h - -#define RTL815x_REQT_READ 0xc0 -#define RTL815x_REQT_WRITE 0x40 -#define RTL815x_REQ_GET_REGS 0x05 -#define RTL815x_REQ_SET_REGS 0x05 - -#define MCU_TYPE_PLA 0x0100 -#define OCP_BASE 0xe86c -#define BASE_MII 0xa400 - -#define BYTE_EN_DWORD 0xff -#define BYTE_EN_WORD 0x33 -#define BYTE_EN_BYTE 0x11 - -#define R815x_PHY_ID 32 -#define REALTEK_VENDOR_ID 0x0bda - - -static int pla_read_word(struct usb_device *udev, u16 index) -{ - int ret; - u8 shift = index 2; - __le32 *tmp; - - tmp = kmalloc(sizeof(*tmp), GFP_KERNEL); - if (!tmp) - return -ENOMEM; - - index = ~3; - - ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), - RTL815x_REQ_GET_REGS, RTL815x_REQT_READ, -
RE: [PATCH net-next 08/12] r8152: support TSO
David Laight [mailto:david.lai...@aculab.com] Sent: Tuesday, March 04, 2014 8:12 PM To: 'Hayes Wang'; net...@vger.kernel.org Cc: nic_s...@realtek.com; linux-ker...@vger.kernel.org; linux-usb@vger.kernel.org Subject: RE: [PATCH net-next 08/12] r8152: support TSO From: Hayes Wang Support scatter gather and TSO. Adjust the tx checksum function and set the max gso size to fix the size of the tx aggregation buffer. There is little point supporting TSO unless the usb host controller supports arbitrary aligned scatter-gather. All you do is require that a large skb be allocated (that may well fail), and add it another data copy. I think I have done it. For also working for EHCI usb host controller, I allocate 16 KB continuous buffer and copy the fragmented packets to it and bulk out the buffer. Best Regards, Hayes -- To unsubscribe from this list: send the line unsubscribe 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 v5 0/6] Make dwc3 use Generic PHY Framework
On Monday 03 March 2014 10:10 PM, Felipe Balbi wrote: Hi, On Mon, Mar 03, 2014 at 05:08:09PM +0530, Kishon Vijay Abraham I wrote: Added support for optional PHY in dwc3 as not all SoCs having PHYs for DWC3 should be programmed. While this can be considered as a temporary fix, a long term solution would be to add 'nop' PHY for platforms that does not have programmable PHY. Adapted DWC3 and USB3 PHY to use Generic PHY framework. Also changed the name of USB3 PHY driver to PIPE3 PHY driver since the same driver has to be used for SATA and PCIE too. Changes from v4: (sending the entire patch series again) * check the return values of phy_init and phy_power_on * print errors if power_on or power_off of PHY fails. Changes from v3: (Sent only adapt dwc3 core to use Generic PHY Framework) * avoided using quirks and rely on the return values of PHY APIs to find the presence of PHY. Changes from v2: * added a couple of fixes. One is invoking phy_resume after phy_init and the other is power off phy in error patch * used quirks to identify if a particular platform does not have PHYs * removed using separate header for pipe3 driver and also removed all referencs to SATA and PCIe in pipe3 driver since it's not yet adapted for those drivers. Changes from v1: * The logic in which the driver detects the presence of PHYs has changed. * patch ordering has changed * udelay is replaced with usleep_range * A patch to remove set_suspend callback which was deferred from Generic PHY Framework series has been included. Kishon Vijay Abraham I (6): usb: dwc3: core: support optional PHYs usb: dwc3: adapt dwc3 core to use Generic PHY Framework drivers: phy: usb3/pipe3: Adapt pipe3 driver to Generic PHY Framework usb: phy: omap-usb2: remove *set_suspend* callback from omap-usb2 phy: omap-usb2: move omap_usb.h from linux/usb/ to linux/phy/ arm/dts: added dt properties to adapt to the new phy framwork patches 1 and 2 are in my testing/next, I guess 3,4,5 and 6 have no direct dependency on those, right ? that's right. I'll take 3, 4 and 5th patch in my tree and ping Tony to take 6th patch. -Kishon -- To unsubscribe from this list: send the line unsubscribe 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 08/12] r8152: support TSO
From: hayeswang David Laight [mailto:david.lai...@aculab.com] Sent: Tuesday, March 04, 2014 8:12 PM To: 'Hayes Wang'; net...@vger.kernel.org Cc: nic_s...@realtek.com; linux-ker...@vger.kernel.org; linux-usb@vger.kernel.org Subject: RE: [PATCH net-next 08/12] r8152: support TSO From: Hayes Wang Support scatter gather and TSO. Adjust the tx checksum function and set the max gso size to fix the size of the tx aggregation buffer. There is little point supporting TSO unless the usb host controller supports arbitrary aligned scatter-gather. All you do is require that a large skb be allocated (that may well fail), and add it another data copy. I think I have done it. For also working for EHCI usb host controller, I allocate 16 KB continuous buffer and copy the fragmented packets to it and bulk out the buffer. Does that mean you are splitting the 64k 'ethernet packet' from TCP is software? I've looked at the ax88179 where the hardware can do it. Is there really a gain doing segmentation here if you have to do the extra data copy? It might be worth packing multiple short packets into a single USB bulk data packet, but that might require a CBU (crystal ball unit). I did measure a maximum transmit ethernet frame rate of (IIRC) 25 frames/sec for the ax88179 - probably limited by the USB3 frame rate. Exceeding that would probably require putting multiple tx packets into a single URB. OTOH that limit probably doesn't matter What might be more useful is to set the rx side up to receive into page-aligned 2k (or 4k) buffers and then separate out the ethernet frames into the required skb - probably as page list fragments (I'm not entirely sure how such skb can be created). I don't know what the r8152 does, but the usbnet code encourages it to allocate long skb, pass them to the usb stack to fill, and then clone them if they contain multiple frames. This isn't really good use of memory or cpu cycles. The ax88179 driver also lies badly about the skb's truesize. David -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: 3.13-rc1 regression: Scatter-gather list issues at SuperSpeed only
On Tue, 4 Mar 2014, David Laight wrote: Notice the request length: 1536. That's three 512-byte sectors. A little unusual, since most I/O is done in units of pages, which are 4096 bytes. Ok, we can't have SuperSpeed mass storage devices broken, so it looks like we'll have to revert the last patch to add scatter-gather to the ASIX driver to avoid that breakage. That means Mathias is going to need to revert those two commits then, since he's taking over pushing xHCI driver bug fixes this kernel. Greg, Dave, Freddy, how do you want to handle reverting commit 3804fad45411? Should that come through Dave's networking tree or Greg's USB tree? I'm not sure what those two commits have to do with this problem. In order to support a request with a non-terminal buffer that isn't a multiple of 1k you need something to stop a LINK TRB being in the middle of the transfer. Otherwise the 1536 byte transfer (expected as a 1k block followed by 512byte one) can probably get sent as a 512byte block (terminating the bulk data request) followed by a spurious 1k block. These should generate horrid errors from the target disk. David is right; this problem can't be fixed simply by reverting patches. The real problem is that the block layer has handed the USB stack an SG list that xhci-hcd cannot handle at all, in its current form. There are only two reasonable ways to fix this: Add appropriate TRB fragment handling into xhci-hcd, or use bounce buffers for non-aligned requests. In theory the block layer could be taught about the need for these bounce buffers, but that would be only a partial solution. It would help for mass-storage transfers, but not for networking (which doesn't use the block layer). An alternative is to work around this particular problem by identifying the code that submits the 3-sector SG element, and changing it to use an even number of sectors. But obviously that doesn't solve the underlying issue. I think in the end there is no real choice but to bite the bullet and implement the TRB fragmentation rules. 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 net-next 08/12] r8152: support TSO
On Tue, 2014-03-04 at 14:35 +, David Laight wrote: Does that mean you are splitting the 64k 'ethernet packet' from TCP is software? I've looked at the ax88179 where the hardware can do it. Is there really a gain doing segmentation here if you have to do the extra data copy? There is no 'extra' copy. There is _already_ a copy, so what's the deal of doing this copy in a SG enabled way ? -- To unsubscribe from this list: send the line unsubscribe 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: basics of runtime d3 for xhci.
On Mon, 3 Mar 2014, Pratik Prajapati wrote: Can anyone please explain me, how runtime d3 works for xhci. It works the same way for all USB host controller drivers, including xhci-hcd. I am trying to understand generic code/control flow. When usb bus is ideal, how RTD3 (runtime d3) will be triggered and which code is involved in it. Runtime PM is described in Documentation/power/runtime_pm.txt. The code you need to look through is drivers/base/power/runtime.c, drivers/pci/pci.c, drivers/pci/pci-driver.c, and drivers/usb/core/hcd-pci.c. 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 net-next 08/12] r8152: support TSO
From: Eric Dumazet On Tue, 2014-03-04 at 14:35 +, David Laight wrote: Does that mean you are splitting the 64k 'ethernet packet' from TCP is software? I've looked at the ax88179 where the hardware can do it. Is there really a gain doing segmentation here if you have to do the extra data copy? There is no 'extra' copy. There is _already_ a copy, so what's the deal of doing this copy in a SG enabled way ? Ok. But there is one more copy than for a normal ethernet chipset which can use multiple ring entries to send the MAC+IP+TCP headers from a different buffer to the TCP userdata. David N�r��yb�X��ǧv�^�){.n�+{��^n�r���z���h����G���h�(�階�ݢj���m��z�ޖ���f���h���~�m�
Re: 3.13-rc1 regression: Scatter-gather list issues at SuperSpeed only
On Tue, Mar 4, 2014 at 10:56 PM, David Laight david.lai...@aculab.com wrote: From: Bjørn Mork If xHCI won't plan to support arbitrary-length scatter-gather any more, that is fine to revert the commit forever. Otherwise, it should be better to just clear no_sg_constraint in xhcd, shouldn't it? No, that's what's currently causing bugs with the storage driver. IIUC, the bug was added by commit 10e232c597ac (USB: check sg buffer size in usb_submit_urb) which introduced an additional restriction on SG URBs not present before: + for_each_sg(urb-sg, sg, urb-num_sgs - 1, i) + if (sg-length % max) + return -EINVAL; where max is usb_endpoint_maxp(ep-desc). As has been shown by numerous bug reports lately, the storage driver will submit SG lists with 512 byte elements on superspeed endpoints with max == 1024. That has never been 'fine'. So when this SS storage device(maxp isn't 512) comes and block layer may send scatter-gather list with an non-tail entry that isn't aligned to the max packet size, looks xHCD has to enable no_sg_constraint and has to deal with it correctly, and I am wondering if there is other solutions for the case. Basically this case is very similar with current usbnet(axis 88179/ 178a). Thanks, -- Ming Lei -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb: dwc2: Add function to calculate correct FIFO sizes
On Mon, Mar 03, 2014 at 09:20:02PM -0600, Dinh Nguyen wrote: Hi Paul, On 3/3/14 9:14 PM, Paul Zimmerman wrote: From: dingu...@altera.com [mailto:dingu...@altera.com] Sent: Monday, March 03, 2014 2:20 PM From: Dinh Nguyen dingu...@altera.com The dwc2 IP on the SOCFPGA cannot use the default HW configured FIFO sizes. The total FIFO depth as read from GHWCFG3 reports 0x1f80 or 8064 32-bit words. But the GRXFSIZ, GNPTXFSIZ, and HPTXFSIZ register defaults to 0x2000 or 8192 32-bit words. So the driver cannot just use the fifo sizes as read from those registers. For platforms that face the same issue, this commits sets the RX, periodic TX, and non-periodic TX fifo size to those that are recommended v2.93a spec for the DWC2 IP. Signed-off-by: Dinh Nguyen dingu...@altera.com Cc: Paul Zimmerman pa...@synopsys.com Cc: Greg Kroah-Hartman gre...@linuxfoundation.org --- drivers/usb/dwc2/core.c | 41 + 1 file changed, 41 insertions(+) diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c index 1d12988..e8e394c 100644 --- a/drivers/usb/dwc2/core.c +++ b/drivers/usb/dwc2/core.c @@ -507,6 +507,44 @@ void dwc2_disable_host_interrupts(struct dwc2_hsotg *hsotg) writel(intmsk, hsotg-regs + GINTMSK); } +/* + * dwc2_calculate_dynamic_fifo() - Calculates the default fifo size + * For system that have a total fifo depth that is smaller than the default + * RX + TX fifo size. + * + * @hsotg: Programming view of DWC_otg controller + */ +static void dwc2_calculate_dynamic_fifo(struct dwc2_hsotg *hsotg) +{ + struct dwc2_core_params *params = hsotg-core_params; + struct dwc2_hw_params *hw = hsotg-hw_params; + u32 rxfsiz, nptxfsiz, ptxfsiz, total_fifo_size; + + total_fifo_size = hw-total_fifo_size; + rxfsiz = params-host_rx_fifo_size; + nptxfsiz = params-host_nperio_tx_fifo_size; + ptxfsiz = params-host_perio_tx_fifo_size; + + if (total_fifo_size = (rxfsiz + nptxfsiz + ptxfsiz)) + /* Params are valid, nothing to do */ + return; + else { Kernel style says both branches of the if() statement should have parentheses here. (Checkpatch doesn't warn about that, I thought it did.) No, checkpatch was clean. try with --strict -- balbi signature.asc Description: Digital signature
Re: [RESEND PATCHv2 1/3] usb: dwc2: Add defines to support the s3c-hsotg driver
On Mon, Mar 03, 2014 at 09:06:13PM -0600, dingu...@altera.com wrote: From: Dinh Nguyen dingu...@altera.com In preparation of combining the dwc2/s3c-hsotg driver in a single DRD driver, the defines in dwc2/hw.h needs to get updated so that the s3c-hsotg driver can use them. Signed-off-by: Dinh Nguyen dingu...@altera.com Cc: Greg Kroah-Hartman gre...@linuxfoundation.org Cc: Paul Zimmerman pa...@synopsys.com Cc: Felipe Balbi ba...@ti.com Cc: Ben Dooks ben-li...@fluff.org Cc: Matt Porter mpor...@linaro.org Cc: Kukjin Kim kgene@samsung.com Cc: Stephen Warren swar...@wwwdotorg.org Cc: Matthijs Kooijman matth...@stdin.nl Cc: Jingoo Han jg1@samsung.com Cc: Sachin Kamat sachin.ka...@linaro.org Cc: Robert Baldyga r.bald...@samsung.com --- v2: - No need to redo the GRXSTS_PKTSTS defines - Add a FIFOSIZE_DEPTH_GET macro --- drivers/usb/dwc2/hw.h | 11 +++ 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/usb/dwc2/hw.h b/drivers/usb/dwc2/hw.h index 9c92a3c..18e19cd 100644 --- a/drivers/usb/dwc2/hw.h +++ b/drivers/usb/dwc2/hw.h @@ -109,6 +109,7 @@ #define GUSBCFG_FSINTF (1 5) #define GUSBCFG_ULPI_UTMI_SEL(1 4) #define GUSBCFG_PHYIF16 (1 3) +#define GUSBCFG_PHYIF8 (0 3) #define GUSBCFG_TOUTCAL_MASK (0x7 0) #define GUSBCFG_TOUTCAL_SHIFT0 #define GUSBCFG_TOUTCAL_LIMIT0x7 @@ -403,6 +404,7 @@ #define FIFOSIZE_DEPTH_SHIFT 16 #define FIFOSIZE_STARTADDR_MASK (0x 0) #define FIFOSIZE_STARTADDR_SHIFT 0 +#define FIFOSIZE_DEPTH_GET(_x) (((_x) 16) 0x) /* Device mode registers */ @@ -520,10 +522,11 @@ #define DXEPCTL_SNP (1 20) #define DXEPCTL_EPTYPE_MASK (0x3 18) #define DXEPCTL_EPTYPE_SHIFT 18 you can remove this now, if there are still any uses, remove them. -- balbi signature.asc Description: Digital signature
Re: [PATCHv2] usb: dwc2: Add function to calculate correct FIFO sizes
On Mon, Mar 03, 2014 at 09:25:13PM -0600, dingu...@altera.com wrote: From: Dinh Nguyen dingu...@altera.com The dwc2 IP on the SOCFPGA cannot use the default HW configured FIFO sizes. The total FIFO depth as read from GHWCFG3 reports 0x1f80 or 8064 32-bit words. But the GRXFSIZ, GNPTXFSIZ, and HPTXFSIZ register defaults to 0x2000 or 8192 32-bit words. So the driver cannot just use the fifo sizes as read from those registers. For platforms that face the same issue, this commits sets the RX, periodic TX, and non-periodic TX fifo size to those that are recommended v2.93a spec for the DWC2 IP. Signed-off-by: Dinh Nguyen dingu...@altera.com Acked-by: Paul Zimmerman pa...@synopsys.com --- v2: Fix coding style with braces around both if() branches --- drivers/usb/dwc2/core.c | 41 + 1 file changed, 41 insertions(+) diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c index 1d12988..efa7a45 100644 --- a/drivers/usb/dwc2/core.c +++ b/drivers/usb/dwc2/core.c @@ -507,6 +507,44 @@ void dwc2_disable_host_interrupts(struct dwc2_hsotg *hsotg) writel(intmsk, hsotg-regs + GINTMSK); } +/* + * dwc2_calculate_dynamic_fifo() - Calculates the default fifo size + * For system that have a total fifo depth that is smaller than the default + * RX + TX fifo size. + * + * @hsotg: Programming view of DWC_otg controller + */ +static void dwc2_calculate_dynamic_fifo(struct dwc2_hsotg *hsotg) +{ + struct dwc2_core_params *params = hsotg-core_params; + struct dwc2_hw_params *hw = hsotg-hw_params; + u32 rxfsiz, nptxfsiz, ptxfsiz, total_fifo_size; + + total_fifo_size = hw-total_fifo_size; + rxfsiz = params-host_rx_fifo_size; + nptxfsiz = params-host_nperio_tx_fifo_size; + ptxfsiz = params-host_perio_tx_fifo_size; + + if (total_fifo_size = (rxfsiz + nptxfsiz + ptxfsiz)) { + /* Params are valid, nothing to do */ + return; + } else { + /* min rx fifo size = ((largest packet/4)*2)+2 */ + rxfsiz = (512/4) * 2 + 2; + /* min non-periodic tx fifo depth */ + nptxfsiz = 2 * (512/4); + /* min periodic tx fifo depth */ + ptxfsiz = (512 * 3)/4; + } + + if (total_fifo_size (rxfsiz + nptxfsiz + ptxfsiz)) + dev_err(hsotg-dev, invalid fifo sizes\n); my comments were silently ignored. NAK. -- balbi signature.asc Description: Digital signature
Re: randconfig build error with next-20140304, in drivers/usb/dwc3/core.c
Hi, On Tue, Mar 04, 2014 at 07:30:20AM -0700, Jim Davis wrote: Building with the attached random configuration file, warning: (USB_OTG_FSM FSL_USB2_OTG USB_MV_OTG) selects USB_OTG which has unmet direct dependencies (USB_SUPPORT USB PM_RUNTIME) warning: (USB_OTG_FSM FSL_USB2_OTG USB_MV_OTG) selects USB_OTG which has unmet direct dependencies (USB_SUPPORT USB PM_RUNTIME) LD init/built-in.o drivers/built-in.o: In function `dwc3_setup_scratch_buffers': /home/jim/linux/drivers/usb/dwc3/core.c:280: undefined reference to `dwc3_send_gadget_generic_command' /home/jim/linux/drivers/usb/dwc3/core.c:287: undefined reference to `dwc3_send_gadget_generic_command' make: *** [vmlinux] Error 1 will fix it now. Damn, I do 200 randconfigs every week and never caught that, good job ;-) -- balbi signature.asc Description: Digital signature
Re: [RESEND PATCHv2 2/3] usb: s3c-hsotg: Move s3c-hsotg into dwc2 folder
On Mon, Mar 03, 2014 at 09:06:14PM -0600, dingu...@altera.com wrote: From: Dinh Nguyen dingu...@altera.com Moves the s3c-hsotg driver into the dwc2 folder and use the dwc2 defines in hw.h. The s3c-hostg driver will now be built with a kconfig option under the dwc2 kconfig. USB_DWC2_HOST and USB_S3C_HSOTG are mutually exclusive build options. Signed-off-by: Dinh Nguyen dingu...@altera.com Cc: Greg Kroah-Hartman gre...@linuxfoundation.org Cc: Paul Zimmerman pa...@synopsys.com Cc: Felipe Balbi ba...@ti.com Cc: Ben Dooks ben-li...@fluff.org Cc: Matt Porter mpor...@linaro.org Cc: Kukjin Kim kgene@samsung.com Cc: Stephen Warren swar...@wwwdotorg.org Cc: Matthijs Kooijman matth...@stdin.nl Cc: Jingoo Han jg1@samsung.com Cc: Sachin Kamat sachin.ka...@linaro.org Cc: Robert Baldyga r.bald...@samsung.com --- v2: - Fix whitespace damage - Redo s3c_hsotg_handle_rx() to use dwc2 definitions - Use FIFOSIZE_DEPTH_GET --- drivers/usb/dwc2/Kconfig | 15 ++ drivers/usb/dwc2/Makefile| 15 +- drivers/usb/{gadget = dwc2}/s3c-hsotg.c | 415 +++--- drivers/usb/gadget/Kconfig |7 - drivers/usb/gadget/Makefile |1 - drivers/usb/gadget/s3c-hsotg.h | 378 --- 6 files changed, 231 insertions(+), 600 deletions(-) rename drivers/usb/{gadget = dwc2}/s3c-hsotg.c (91%) delete mode 100644 drivers/usb/gadget/s3c-hsotg.h diff --git a/drivers/usb/dwc2/Kconfig b/drivers/usb/dwc2/Kconfig index be947d6..ce14859 100644 --- a/drivers/usb/dwc2/Kconfig +++ b/drivers/usb/dwc2/Kconfig @@ -20,6 +20,21 @@ config USB_DWC2 if USB_DWC2 +config USB_DWC2_HOST + bool Host only mode + depends on USB=y || USB=USB_DWC2 + default y + help + Select this when you want to use DWC2 in host mode only, + thereby the gadget feature will be regressed. + +config USB_S3C_HSOTG as I mentioned before, this should be USB_DWC2_GADGET or USB_DWC2_PERIPHERAL + depends on (ARM || USB_GADGET=y) !USB_DWC2_HOST + tristate Designware/S3C HS/OtG USB Device controller + help + The Designware USB2.0 high-speed gadget controller + integrated into many SoCs. + config USB_DWC2_DEBUG bool Enable Debugging Messages help diff --git a/drivers/usb/dwc2/Makefile b/drivers/usb/dwc2/Makefile index 11529d3..2778e16 100644 --- a/drivers/usb/dwc2/Makefile +++ b/drivers/usb/dwc2/Makefile @@ -1,9 +1,15 @@ ccflags-$(CONFIG_USB_DWC2_DEBUG) += -DDEBUG ccflags-$(CONFIG_USB_DWC2_VERBOSE) += -DVERBOSE_DEBUG +ifeq ($(CONFIG_USB_DWC2_HOST),y) obj-$(CONFIG_USB_DWC2) += dwc2.o - dwc2-y += core.o core_intr.o +dwc2-y += hcd.o hcd_intr.o +dwc2-y += hcd_queue.o hcd_ddma.o +endif +obj-$(CONFIG_USB_S3C_HSOTG) += s3c_hsotg.o +s3c_hsotg-y += s3c-hsotg.o wrong. + # NOTE: This driver at present only implements the Host mode # of the controller. The existing s3c-hsotg driver supports @@ -13,13 +19,12 @@ dwc2-y+= core.o core_intr.o # that is done, Host mode will become an optional feature that # is selected with a config option. -dwc2-y += hcd.o hcd_intr.o -dwc2-y += hcd_queue.o hcd_ddma.o - ifneq ($(CONFIG_PCI),) obj-$(CONFIG_USB_DWC2) += dwc2_pci.o endif -obj-$(CONFIG_USB_DWC2) += dwc2_platform.o +ifneq ($(CONFIG_USB_DWC2_HOST),) + obj-$(CONFIG_USB_DWC2) += dwc2_platform.o +endif wrong. Anyway, I'll stop, you completely ignored all my comments from previous series. NAK -- balbi signature.asc Description: Digital signature
[PATCH v7 0/4] phy: Add new Exynos USB 2.0 PHY driver
Hi, This is the seventh version of this patchset. First and most significant change is that this patchset includes only patches touching the Generic PHY Framework. Patches to the USB controllers were stripped as they require additional work. S5PV210 support is also omitted - it requires more testing. Thank you to everyone who joined the discussion, reviewed the patched and contributed to making the code and consequently the Linux Kernel better. Best wishes, Kamil Debski -- Changes from v6: (not including the change that controller patches were removed form this patchset, also this patchset excludes S5PV210 support - it needs more testing) 1) phy: core: Add an exported of_phy_get function - No changes since v6. 2) phy: core: Add devm_of_phy_get to phy-core - No changes since v6. 3) phy: Add new Exynos USB 2.0 PHY driver - Changed the way clocks are supplied to the driver. Prior to version v7 there were reference clocks for every phy instance, now a single ref clock was introduced. - Updated documentation to match the aforementioned change. - Add offset EXYNOS_*_UPHYCLK_PHYFSEL_OFFSET to the clock register content defines. - Corrected way clock register is modified. Instead of a simple write, a proper read, modify, write sequence was introduced. - Important stability fix - added udelay after PHY reset. This fixes a bug causing instability in USB LAN adapters. Without the delay the DMA burst mode was could not be enabled. 4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - Changed handling of clocks to use a single ref clock. Changes from v5: 1) phy: core: Add an exported of_phy_get function - corrected behaviour of the modification when GENERIC_PHY is not enabled by adding a stub of the of_phy_get function 2) phy: core: Add devm_of_phy_get to phy-core - corrected behaviour of the modification when GENERIC_PHY is not enabled by adding a stub of the devm_of_phy_get function 3) dts: Add usb2phy to Exynos 4 - no change 4) dts: Add usb2phy to Exynos 5250 - in the previous version, this patch included some phy-exynos5250-usb2.c code by mistake, the code has been remove and added to the proper patch 5) phy: Add new Exynos USB PHY driver - changed strings from Exynos 4212 to Exynos 4x12, as the Exynos 4212 driver is actually a driver for the whole Exynos 4x12 family - added documentation to the Exynos USB 2.0 PHY driver adaptaion layer - corrected strings HSCI - HSIC - fixed a problem introduced by previous change - on Exynos 4x12 the HSIC did not work on its own - mode switch support was added to Exynos 4x12 (same io pins are used by host and device) - support for phy_set_bus_width introduced by Matt Porter was added 6) phy: Add support for S5PV210 to the Exynos USB PHY - setting of clk register was fixed 7) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY - supoprt was added for HSIC and device 8) usb: ehci-exynos: Change to use phy provided by the generic phy framework - DT documentation was moved from usb-ehci.txt to exynos-usb.txt Changes from v4: 1) phy: core: Add an exported of_phy_get function - the new exported function of_phy_get was changed to take the phy's name as a parameter instead of the index 2) phy: core: Add devm_of_phy_get to phy-core - fixes made in the comments to devm_of_phy_get 3) phy: Add new Exynos USB PHY driver - move the documentation from a new to an existing file - samsung-phy.txt - fix typos and uppercase hex addresses - add more explanations to Kconfig (checkpatch still complains, but I find it hard to think what else could I add) - add selects MFD_SYSCON as the driver needs it (Thank you, Tobias!) - cleanup included headers in both *.c and .h files - use BIT(x) macro instead of (1 x) - replaced HOST and DEV with PHY0 and PHY1 in phy-exynos4212-usb2.c, the registers are described as PHYx in the documentation hence the decision to leave the PHYx naming - fixed typo in exynos4210_rate_to_clk reg - *reg - change hax_mode_switch and enabled type to bool 4) usb: ehci-s5p: Change to use phy provided by the generic phy framework - Put the issue of phy-otg in order - since the new phy driver does not provide this field. With the new driver the switch between host and device is done in power_on of the respective host and device phys. 5) usb: s3c-hsotg: Use the new Exynos USB phy driver with the generic phy framework - fixed the example in the documentation 6) phy: Add support for S5PV210 to the Exynos USB PHY driver - include files cleanup - use BIT(x) macro instead of (1 x) 7) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY driver - include files cleanup - use BIT(x) macro instead of (1 x) 8) dts: Add usb2phy to Exynos 4 - no changes 9) dts: Add usb2phy to Exynos 5250 - no changes Changes from v3: - using PMU and system registers indirectly via syscon - change labelling - change Kconfig name - fixed typos/stray
[PATCH v7 1/4] phy: core: Add an exported of_phy_get function
Previously the of_phy_get function took a struct device * and was declared static. It was impossible to call it from another driver and thus it was impossible to get phy defined for a given node. The old function was renamed to _of_phy_get and was left for internal use. of_phy_get function was added and it was exported. The function enables to get a phy for a given device tree node. Signed-off-by: Kamil Debski k.deb...@samsung.com --- drivers/phy/phy-core.c | 45 - include/linux/phy/phy.h |6 ++ 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 6c73837..7c1b0e1 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -274,8 +274,8 @@ int phy_power_off(struct phy *phy) EXPORT_SYMBOL_GPL(phy_power_off); /** - * of_phy_get() - lookup and obtain a reference to a phy by phandle - * @dev: device that requests this phy + * _of_phy_get() - lookup and obtain a reference to a phy by phandle + * @np: device_node for which to get the phy * @index: the index of the phy * * Returns the phy associated with the given phandle value, @@ -284,20 +284,17 @@ EXPORT_SYMBOL_GPL(phy_power_off); * not yet loaded. This function uses of_xlate call back function provided * while registering the phy_provider to find the phy instance. */ -static struct phy *of_phy_get(struct device *dev, int index) +static struct phy *_of_phy_get(struct device_node *np, int index) { int ret; struct phy_provider *phy_provider; struct phy *phy = NULL; struct of_phandle_args args; - ret = of_parse_phandle_with_args(dev-of_node, phys, #phy-cells, + ret = of_parse_phandle_with_args(np, phys, #phy-cells, index, args); - if (ret) { - dev_dbg(dev, failed to get phy in %s node\n, - dev-of_node-full_name); + if (ret) return ERR_PTR(-ENODEV); - } mutex_lock(phy_provider_mutex); phy_provider = of_phy_provider_lookup(args.np); @@ -317,6 +314,36 @@ err0: } /** + * of_phy_get() - lookup and obtain a reference to a phy using a device_node. + * @np: device_node for which to get the phy + * @con_id: name of the phy from device's point of view + * + * Returns the phy driver, after getting a refcount to it; or + * -ENODEV if there is no such phy. The caller is responsible for + * calling phy_put() to release that count. + */ +struct phy *of_phy_get(struct device_node *np, const char *con_id) +{ + struct phy *phy = NULL; + int index = 0; + + if (con_id) + index = of_property_match_string(np, phy-names, con_id); + + phy = _of_phy_get(np, index); + if (IS_ERR(phy)) + return phy; + + if (!try_module_get(phy-ops-owner)) + return ERR_PTR(-EPROBE_DEFER); + + get_device(phy-dev); + + return phy; +} +EXPORT_SYMBOL_GPL(of_phy_get); + +/** * phy_put() - release the PHY * @phy: the phy returned by phy_get() * @@ -407,7 +434,7 @@ struct phy *phy_get(struct device *dev, const char *string) if (dev-of_node) { index = of_property_match_string(dev-of_node, phy-names, string); - phy = of_phy_get(dev, index); + phy = _of_phy_get(dev-of_node, index); } else { phy = phy_lookup(dev, string); } diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 3f83459..2fe3194 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -151,6 +151,7 @@ struct phy *devm_phy_get(struct device *dev, const char *string); struct phy *devm_phy_optional_get(struct device *dev, const char *string); void phy_put(struct phy *phy); void devm_phy_put(struct device *dev, struct phy *phy); +struct phy *of_phy_get(struct device_node *np, const char *con_id); struct phy *of_phy_simple_xlate(struct device *dev, struct of_phandle_args *args); struct phy *phy_create(struct device *dev, const struct phy_ops *ops, @@ -259,6 +260,11 @@ static inline void devm_phy_put(struct device *dev, struct phy *phy) { } +struct phy *of_phy_get(struct device_node *np, const char *con_id) +{ + return ERR_PTR(-ENOSYS); +} + static inline struct phy *of_phy_simple_xlate(struct device *dev, struct of_phandle_args *args) { -- 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 v7 2/4] phy: core: Add devm_of_phy_get to phy-core
Adding devm_of_phy_get will allow to get phys by supplying a pointer to the struct device_node instead of struct device. Signed-off-by: Kamil Debski k.deb...@samsung.com --- drivers/phy/phy-core.c | 31 +++ include/linux/phy/phy.h |8 2 files changed, 39 insertions(+) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 7c1b0e1..623b71c 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -526,6 +526,37 @@ struct phy *devm_phy_optional_get(struct device *dev, const char *string) EXPORT_SYMBOL_GPL(devm_phy_optional_get); /** + * devm_of_phy_get() - lookup and obtain a reference to a phy. + * @dev: device that requests this phy + * @np: node containing the phy + * @con_id: name of the phy from device's point of view + * + * Gets the phy using of_phy_get(), and associates a device with it using + * devres. On driver detach, release function is invoked on the devres data, + * then, devres data is freed. + */ +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id) +{ + struct phy **ptr, *phy; + + ptr = devres_alloc(devm_phy_release, sizeof(*ptr), GFP_KERNEL); + if (!ptr) + return ERR_PTR(-ENOMEM); + + phy = of_phy_get(np, con_id); + if (!IS_ERR(phy)) { + *ptr = phy; + devres_add(dev, ptr); + } else { + devres_free(ptr); + } + + return phy; +} +EXPORT_SYMBOL_GPL(devm_of_phy_get); + +/** * phy_create() - create a new phy * @dev: device that is creating the new phy * @ops: function pointers for performing phy operations diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 2fe3194..bcbf96c 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -149,6 +149,8 @@ struct phy *phy_get(struct device *dev, const char *string); struct phy *phy_optional_get(struct device *dev, const char *string); struct phy *devm_phy_get(struct device *dev, const char *string); struct phy *devm_phy_optional_get(struct device *dev, const char *string); +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id); void phy_put(struct phy *phy); void devm_phy_put(struct device *dev, struct phy *phy); struct phy *of_phy_get(struct device_node *np, const char *con_id); @@ -252,6 +254,12 @@ static inline struct phy *devm_phy_optional_get(struct device *dev, return ERR_PTR(-ENOSYS); } +struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id) +{ + return ERR_PTR(-ENOSYS); +} + static inline void phy_put(struct phy *phy) { } -- 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: ax88179_178a problems on AMD platform with ASMedia xhci controller
From: renev...@internode.on.net Not only that though, I moved to a SandyBridge platform and... The nic stops working very quickly when using an onboard Etron controller. The nic also stops working quickly when using an addon card with Renesas controller. What I found was that the nic's transmit engine gets confused if the usb bulk packets don't exactly match the packet headers. The usb part continues to accept data, but nothing gets transmitted. With a lot of debugging I realised that the ethernet transmits stopped when a LINK TRB was misaligned. I did a quick hack to pad the ring with NOPs and it all worked a lot, lot better. On my Ivy bridge (or is it sandy) system I could then reliably enable TSO and SG. David -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v7 3/4] phy: Add new Exynos USB 2.0 PHY driver
Add a new driver for the Exynos USB 2.0 PHY. The new driver uses the generic PHY framework. The driver includes support for the Exynos 4210 and 4x12 SoC families. Signed-off-by: Kamil Debski k.deb...@samsung.com --- .../devicetree/bindings/phy/samsung-phy.txt| 53 Documentation/phy/samsung-usb2.txt | 134 drivers/phy/Kconfig| 29 ++ drivers/phy/Makefile |3 + drivers/phy/phy-exynos4210-usb2.c | 262 drivers/phy/phy-exynos4x12-usb2.c | 330 drivers/phy/phy-samsung-usb2.c | 223 + drivers/phy/phy-samsung-usb2.h | 67 8 files changed, 1101 insertions(+) create mode 100644 Documentation/phy/samsung-usb2.txt create mode 100644 drivers/phy/phy-exynos4210-usb2.c create mode 100644 drivers/phy/phy-exynos4x12-usb2.c create mode 100644 drivers/phy/phy-samsung-usb2.c create mode 100644 drivers/phy/phy-samsung-usb2.h diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt index c0fccaa..bf955ab 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -20,3 +20,56 @@ 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 S5P/EXYNOS SoC series USB PHY +- + +Required properties: +- compatible : should be one of the listed compatibles: + - samsung,exynos4210-usb2-phy + - samsung,exynos4x12-usb2-phy +- reg : a list of registers used by phy driver + - first and obligatory is the location of phy modules registers +- samsung,sysreg-phandle - handle to syscon used to control the system registers +- samsung,pmureg-phandle - handle to syscon used to control PMU registers +- #phy-cells : from the generic phy bindings, must be 1; +- clocks and clock-names: + - the phy clock is required by the phy module, used as a gate + - the ref clock is used to get the rate of the clock provided to the + PHY module + +The first phandle argument in the PHY specifier identifies the PHY, its +meaning is compatible dependent. For the currently supported SoCs (Exynos 4210 +and Exynos 4212) it is as follows: + 0 - USB device (device), + 1 - USB host (host), + 2 - HSIC0 (hsic0), + 3 - HSIC1 (hsic1), + +Exynos 4210 and Exynos 4212 use mode switching and require that mode switch +register is supplied. + +Example: + +For Exynos 4412 (compatible with Exynos 4212): + +usbphy: phy@125b { + compatible = samsung,exynos4x12-usb2-phy; + reg = 0x125b 0x100; + clocks = clock 305, clock 2; + clock-names = phy, ref; + status = okay; + #phy-cells = 1; + samsung,sysreg-phandle = sys_reg; + samsung,pmureg-phandle = pmu_reg; +}; + +Then the PHY can be used in other nodes such as: + +phy-consumer@1234 { + phys = usbphy 2; + phy-names = phy; +}; + +Refer to DT bindings documentation of particular PHY consumer devices for more +information about required PHYs and the way of specification. diff --git a/Documentation/phy/samsung-usb2.txt b/Documentation/phy/samsung-usb2.txt new file mode 100644 index 000..0c8e260 --- /dev/null +++ b/Documentation/phy/samsung-usb2.txt @@ -0,0 +1,134 @@ +.--+ +| Samsung USB 2.0 PHY adaptation layer | ++-+' + +| 1. Description ++ + +The architecture of the USB 2.0 PHY module in Samsung SoCs is similar +among many SoCs. In spite of the similarities it proved difficult to +create a one driver that would fit all these PHY controllers. Often +the differences were minor and were found in particular bits of the +registers of the PHY. In some rare cases the order of register writes or +the PHY powering up process had to be altered. This adaptation layer is +a compromise between having separate drivers and having a single driver +with added support for many special cases. + +| 2. Files description ++-- + +- phy-samsung-usb2.c + This is the main file of the adaptation layer. This file contains + the probe function and provides two callbacks to the Generic PHY + Framework. This two callbacks are used to power on and power off the + phy. They carry out the common work that has to be done on all version + of the PHY module. Depending on which SoC was chosen they execute SoC + specific callbacks. The specific SoC version is selected by choosing + the appropriate compatible string. In addition, this file contains +
RE: 3.13-rc1 regression: Scatter-gather list issues at SuperSpeed only
From: Alan Stern There are only two reasonable ways to fix this: Add appropriate TRB fragment handling into xhci-hcd, or use bounce buffers for non-aligned requests. In theory the block layer could be taught about the need for these bounce buffers, but that would be only a partial solution. It would help for mass-storage transfers, but not for networking (which doesn't use the block layer). An alternative is to work around this particular problem by identifying the code that submits the 3-sector SG element, and changing it to use an even number of sectors. But obviously that doesn't solve the underlying issue. Actually most of the block layer code could be taught to split requests into multiple URBs. Or even resubmit bounced requests split in two. Although splitting requests won't help the network code. The dma setup code could allocate bounce buffers - but you really don't want to be doing that. I think in the end there is no real choice but to bite the bullet and implement the TRB fragmentation rules. Indeed :-) David -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v7 4/4] phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY driver
Add support for Exynos 5250. This driver is to replace the old USB 2.0 PHY driver. Signed-off-by: Kamil Debski k.deb...@samsung.com --- .../devicetree/bindings/phy/samsung-phy.txt|1 + drivers/phy/Kconfig| 11 + drivers/phy/Makefile |1 + drivers/phy/phy-exynos5250-usb2.c | 405 drivers/phy/phy-samsung-usb2.c |6 + drivers/phy/phy-samsung-usb2.h |1 + 6 files changed, 425 insertions(+) create mode 100644 drivers/phy/phy-exynos5250-usb2.c diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt index bf955ab..28f9edb 100644 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt @@ -28,6 +28,7 @@ Required properties: - compatible : should be one of the listed compatibles: - samsung,exynos4210-usb2-phy - samsung,exynos4x12-usb2-phy + - samsung,exynos5250-usb2-phy - reg : a list of registers used by phy driver - first and obligatory is the location of phy modules registers - samsung,sysreg-phandle - handle to syscon used to control the system registers diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 1890351..fe2663c 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -94,4 +94,15 @@ config PHY_EXYNOS4X12_USB2 Samsung USB 2.0 PHY driver is enabled and means that support for this particular SoC is compiled in the driver. In case of Exynos 4x12 four phys are available - device, host, HSIC0 and HSIC1. + +config PHY_EXYNOS5250_USB2 + bool Support for Exynos 5250 + depends on PHY_SAMSUNG_USB2 + depends on SOC_EXYNOS5250 + help + Enable USB PHY support for Exynos 5250. This option requires that + Samsung USB 2.0 PHY driver is enabled and means that support for this + particular SoC is compiled in the driver. In case of Exynos 5250 four + phys are available - device, host, HSIC0 and HSIC. + endmenu diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index 69d0b3f2..4dcd389 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -12,3 +12,4 @@ obj-$(CONFIG_TWL4030_USB) += phy-twl4030-usb.o obj-$(CONFIG_PHY_SAMSUNG_USB2) += phy-samsung-usb2.o obj-$(CONFIG_PHY_EXYNOS4210_USB2) += phy-exynos4210-usb2.o obj-$(CONFIG_PHY_EXYNOS4X12_USB2) += phy-exynos4x12-usb2.o +obj-$(CONFIG_PHY_EXYNOS5250_USB2) += phy-exynos5250-usb2.o diff --git a/drivers/phy/phy-exynos5250-usb2.c b/drivers/phy/phy-exynos5250-usb2.c new file mode 100644 index 000..1ba0bb30 --- /dev/null +++ b/drivers/phy/phy-exynos5250-usb2.c @@ -0,0 +1,405 @@ +/* + * Samsung SoC USB 1.1/2.0 PHY driver - Exynos 5250 support + * + * Copyright (C) 2013 Samsung Electronics Co., Ltd. + * Author: Kamil Debski k.deb...@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/delay.h +#include linux/io.h +#include linux/phy/phy.h +#include linux/regmap.h +#include phy-samsung-usb2.h + +/* Exynos USB PHY registers */ +#define EXYNOS_5250_REFCLKSEL_CRYSTAL 0x0 +#define EXYNOS_5250_REFCLKSEL_XO 0x1 +#define EXYNOS_5250_REFCLKSEL_CLKCORE 0x2 + +#define EXYNOS_5250_FSEL_9MHZ6 0x0 +#define EXYNOS_5250_FSEL_10MHZ 0x1 +#define EXYNOS_5250_FSEL_12MHZ 0x2 +#define EXYNOS_5250_FSEL_19MHZ20x3 +#define EXYNOS_5250_FSEL_20MHZ 0x4 +#define EXYNOS_5250_FSEL_24MHZ 0x5 +#define EXYNOS_5250_FSEL_50MHZ 0x7 + +/* Normal host */ +#define EXYNOS_5250_HOSTPHYCTRL0 0x0 + +#define EXYNOS_5250_HOSTPHYCTRL0_PHYSWRSTALL BIT(31) +#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT 19 +#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_MASK\ + (0x3 EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT) +#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT16 +#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_MASK \ + (0x7 EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT) +#define EXYNOS_5250_HOSTPHYCTRL0_TESTBURNINBIT(11) +#define EXYNOS_5250_HOSTPHYCTRL0_RETENABLE BIT(10) +#define EXYNOS_5250_HOSTPHYCTRL0_COMMON_ON_N BIT(9) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_MASK(0x3 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_DUAL(0x0 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ID0 (0x1 7) +#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ANALOGTEST (0x2 7) +#define EXYNOS_5250_HOSTPHYCTRL0_SIDDQ BIT(6) +#define EXYNOS_5250_HOSTPHYCTRL0_FORCESLEEPBIT(5) +#define EXYNOS_5250_HOSTPHYCTRL0_FORCESUSPEND BIT(4) +#define
Re: Bug ID: 71261 modprobe xhci-hcd driver modules failed
On 03/04/2014 12:21 PM, shishir tiwari wrote: Hi , When we try to modprode Xhci-hcd Driver with dmesg -n 6 command in background , xhci driver loading failed.But if we give dmesg -n 7/5 or any thing its work. When Extended Capability register is being read its given zero insted of 544 value . Here is the Step to reproduce: #dd if=/dev/mtd4 of=/dev/null bs=1M count=64 #dmesg -n 6 #modprobe xhci-hcd Is the dd command necessary to trigger this? There seems to be two issues here, Reading xhci-cap_regs-hcc_params returns 0 for you in some cases. As this is a platform driver the xhci-cap_regs is some memory resource got from the platform device. If triggering this depends on the console log level could there be some race we run into with unlucky timing? Second issue is that if we fail during xhci_init_mem() we shold only free the stuff allocated so far, and not just bluntly call xhci_mem_cleanup(). What kernel version does this happend on? -Mathias -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v6 part1 4/8] usb: assign default peer ports for root hubs
On Mon, 3 Mar 2014, Dan Williams wrote: In general I agree, and I like the compartmentalization of only needing to take the lock in hub.c. But I still think we have a hole with a scenario like the following (granted, this should never happen in current code...): CPU1CPU2 usb_remove_hcd(hcdA) ... mutex_lock(peer_lock) hdevA-maxchild = 0; mutex_unlock(peer_lock) usb_add_hcd(hcdB) ... mutex_lock(peer_lock) hdevA = hcdA-self.root_hub usb_put_dev(hdevA) // free hubA = usb_hub_to_struct_hub(hdevA) // use after free ...and if this is a hole then so is the hcdA-self.root_hub. It makes sense that when the host controller breaks the peering relationship at the root it should hold the lock and clear -shared_hcd and -primary_hcd. Yes, you jogged my thinking. In addition to this hole, there is another section of the patch I completely forgot about. The following needs to be added on to what I posted before. Alan Stern Index: usb-3.14/drivers/usb/core/hub.c === --- usb-3.14.orig/drivers/usb/core/hub.c +++ usb-3.14/drivers/usb/core/hub.c @@ -4564,6 +4564,8 @@ static void hub_port_connect_change(stru */ status = 0; + mutex_lock(usb_port_peer_mutex); + /* We mustn't add new devices if the parent hub has * been disconnected; we would race with the * recursively_mark_NOTATTACHED() routine. @@ -4574,14 +4576,17 @@ static void hub_port_connect_change(stru else hub-ports[port1 - 1]-child = udev; spin_unlock_irq(device_state_lock); + mutex_unlock(usb_port_peer_mutex); /* Run it through the hoops (find a driver, etc) */ if (!status) { status = usb_new_device(udev); if (status) { + mutex_lock(usb_port_peer_mutex); spin_lock_irq(device_state_lock); hub-ports[port1 - 1]-child = NULL; spin_unlock_irq(device_state_lock); + mutex_unlock(usb_port_peer_mutex); } } -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] usb: dwc3: fix randconfig build errors
commit 388e5c5 (usb: dwc3: remove dwc3 dependency on host AND gadget.) created the possibility for host-only and peripheral-only dwc3 builds but left a possible randconfig build error when host-only builds are selected. Cc: sta...@vger.kernel.org # v3.8+ Reported-by: Jim Davis jim.ep...@gmail.com Signed-off-by: Felipe Balbi ba...@ti.com --- drivers/usb/dwc3/core.h | 33 + drivers/usb/dwc3/gadget.h | 13 - 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 00b0578..5b92c9e 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -872,6 +872,19 @@ union dwc3_event { struct dwc3_event_gevt gevt; }; +/** + * struct dwc3_gadget_ep_cmd_params - representation of endpoint command + * parameters + * @param2: third parameter + * @param1: second parameter + * @param0: first parameter + */ +struct dwc3_gadget_ep_cmd_params { + u32 param2; + u32 param1; + u32 param0; +}; + /* * DWC3 Features to be used as Driver Data */ @@ -897,11 +910,31 @@ static inline void dwc3_host_exit(struct dwc3 *dwc) #if IS_ENABLED(CONFIG_USB_DWC3_GADGET) || IS_ENABLED(CONFIG_USB_DWC3_DUAL_ROLE) int dwc3_gadget_init(struct dwc3 *dwc); void dwc3_gadget_exit(struct dwc3 *dwc); +int dwc3_gadget_set_test_mode(struct dwc3 *dwc, int mode); +int dwc3_gadget_get_link_state(struct dwc3 *dwc); +int dwc3_gadget_set_link_state(struct dwc3 *dwc, enum dwc3_link_state state); +int dwc3_send_gadget_ep_cmd(struct dwc3 *dwc, unsigned ep, + unsigned cmd, struct dwc3_gadget_ep_cmd_params *params); +int dwc3_send_gadget_generic_command(struct dwc3 *dwc, int cmd, u32 param); #else static inline int dwc3_gadget_init(struct dwc3 *dwc) { return 0; } static inline void dwc3_gadget_exit(struct dwc3 *dwc) { } +static inline int dwc3_gadget_set_test_mode(struct dwc3 *dwc, int mode) +{ return 0; } +static inline int dwc3_gadget_get_link_state(struct dwc3 *dwc) +{ return 0; } +static inline int dwc3_gadget_set_link_state(struct dwc3 *dwc, + enum dwc3_link_state state) +{ return 0; } + +static inline int dwc3_send_gadget_ep_cmd(struct dwc3 *dwc, unsigned ep, + unsigned cmd, struct dwc3_gadget_ep_cmd_params *params) +{ return 0; } +static inline int dwc3_send_gadget_generic_command(struct dwc3 *dwc, + int cmd, u32 param) +{ return 0; } #endif /* power management interface */ diff --git a/drivers/usb/dwc3/gadget.h b/drivers/usb/dwc3/gadget.h index d101244..a0ee75b 100644 --- a/drivers/usb/dwc3/gadget.h +++ b/drivers/usb/dwc3/gadget.h @@ -56,12 +56,6 @@ struct dwc3; /* DEPXFERCFG parameter 0 */ #define DWC3_DEPXFERCFG_NUM_XFER_RES(n)((n) 0x) -struct dwc3_gadget_ep_cmd_params { - u32 param2; - u32 param1; - u32 param0; -}; - /* -- */ #define to_dwc3_request(r) (container_of(r, struct dwc3_request, request)) @@ -85,10 +79,6 @@ static inline void dwc3_gadget_move_request_queued(struct dwc3_request *req) void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req, int status); -int dwc3_gadget_set_test_mode(struct dwc3 *dwc, int mode); -int dwc3_gadget_get_link_state(struct dwc3 *dwc); -int dwc3_gadget_set_link_state(struct dwc3 *dwc, enum dwc3_link_state state); - void dwc3_ep0_interrupt(struct dwc3 *dwc, const struct dwc3_event_depevt *event); void dwc3_ep0_out_start(struct dwc3 *dwc); @@ -96,9 +86,6 @@ int dwc3_gadget_ep0_set_halt(struct usb_ep *ep, int value); int dwc3_gadget_ep0_queue(struct usb_ep *ep, struct usb_request *request, gfp_t gfp_flags); int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value); -int dwc3_send_gadget_ep_cmd(struct dwc3 *dwc, unsigned ep, - unsigned cmd, struct dwc3_gadget_ep_cmd_params *params); -int dwc3_send_gadget_generic_command(struct dwc3 *dwc, int cmd, u32 param); /** * dwc3_gadget_ep_get_transfer_index - Gets transfer index from HW -- 1.9.0 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] usb: dwc3: define more revisions
few new revisions of the core have been released, add them to our list of revisions so we can apply workarounds if necessary. Signed-off-by: Felipe Balbi ba...@ti.com --- drivers/usb/dwc3/core.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 5b92c9e..535bb6e 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -710,6 +710,9 @@ struct dwc3 { #define DWC3_REVISION_230A 0x5533230a #define DWC3_REVISION_240A 0x5533240a #define DWC3_REVISION_250A 0x5533250a +#define DWC3_REVISION_260A 0x5533260a +#define DWC3_REVISION_270A 0x5533270a +#define DWC3_REVISION_280A 0x5533280a enum dwc3_ep0_next ep0_next_event; enum dwc3_ep0_state ep0state; -- 1.9.0 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: 3.13-rc1 regression: Scatter-gather list issues at SuperSpeed only
On Tue, Mar 4, 2014 at 11:21 PM, David Laight david.lai...@aculab.com wrote: Actually most of the block layer code could be taught to split requests into multiple URBs. Or even resubmit bounced requests split in two. Although splitting requests won't help the network code. It might not help storage too since the single URB in the middle of transfer produces short packet. Thanks, -- Ming Lei -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2] usb: gadget: return the right length in ffs_epfile_io()
Hello. On 03/04/2014 10:34 AM, Chuansheng Liu wrote: When the request length is aligned to maxpacketsize, sometimes the return length ret the user space requested len. At that time, we will use min_t(size_t, ret, len) to limit the size in case of user data buffer overflow. But we need return the min_t(size_t, ret, len) to tell the user space rightly also. Acked-by: Michal Nazarewicz min...@mina86.com Reviewed-by: David Cohen david.a.co...@linux.intel.com Signed-off-by: Chuansheng Liu chuansheng@intel.com --- drivers/usb/gadget/f_fs.c | 14 -- 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c index 42f7a0e..780f877 100644 --- a/drivers/usb/gadget/f_fs.c +++ b/drivers/usb/gadget/f_fs.c @@ -845,12 +845,14 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data) * we may end up with more data then user space has * space for. */ - ret = ep-status; - if (io_data-read ret 0 - unlikely(copy_to_user(io_data-buf, data, - min_t(size_t, ret, - io_data-len - ret = -EFAULT; + ret = ep-status; Why the indentation jumped suddenly to the right? + if (io_data-read ret 0) { + ret = min_t(size_t, ret, io_data-len); + + if (unlikely(copy_to_user(io_data-buf, + data, ret))) + ret = -EFAULT; + } } kfree(data); 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: 3.13-rc1 regression: Scatter-gather list issues at SuperSpeed only
On Tue, 4 Mar 2014, David Laight wrote: An alternative is to work around this particular problem by identifying the code that submits the 3-sector SG element, and changing it to use an even number of sectors. But obviously that doesn't solve the underlying issue. Actually most of the block layer code could be taught to split requests into multiple URBs. Or even resubmit bounced requests split in two. Although splitting requests won't help the network code. It won't help the mass-storage code either. If an SG element is shorter than the maxpacket length, splitting it up isn't going to make it longer. What _would_ help would be for the block layer to split up both this element and the next one, and then allocate a maxpacket-sized bounce buffer to hold the last part of this element plus the first part of the next. But _that_ won't help the network code. 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 v6 part1 4/8] usb: assign default peer ports for root hubs
On Mon, 3 Mar 2014, Dan Williams wrote: Ok, so the root issue is that the peering code needs to see hcd-primary_hcd = NULL to know that there is no longer a peer. I update usb_remove_hcd() to clear out -shared_hcd and -primary_hcd under the peer lock before we allow the root hub to be freed. Even if there is a peer hcd, the peer's root hub may not exist. More locking is needed than you have here. I add some description of the new locking scheme to the changelog as well. 8-- Subject: usb: assign default peer ports for root hubs From: Dan Williams dan.j.willi...@intel.com Assume that the peer of a superspeed port is the port with the same id on the shared_hcd root hub. This identification scheme is required of external hubs by the USB3 spec [1]. However, for root hubs, tier mismatch may be in effect [2]. Tier mismatch can only be enumerated via platform firmware. For now, simply perform the nominal association. Once the root hub is marked as unregistered we block attempts to walk the -shared_hcd pointer to find a root-peer port. A new lock 'usb_port_peer_mutex' is introduced to synchronize port device add/remove with peer lookups. We hold the lock for the duration of registration allowing default peers (and later firmware identified peers) to be discovered. We also hold the lock whenever hub devices are validated (hdev-maxchild set to non-zero) and invalidated (hdev-maxchild set to zero). Marking a hub valid and registering its ports is a locked operation and conversely invalidating a hub and removing its ports is another locked operation. This prevents a port from associating with an invalid peer. Finally, we hold the lock when breaking the shared hcd relationship at usb_remove_hcd() time. More generally, I would say that the new mutex protects the hcd-shared_hcd, hcd-self.root_hub, and port_dev-child pointers, in addition to hdev-maxchild. [1]: usb 3.1 section 10.3.3 [2]: xhci 1.1 appendix D Cc: Alan Stern st...@rowland.harvard.edu [alan: usb_port_peer_mutex locking scheme] Signed-off-by: Dan Williams dan.j.willi...@intel.com --- drivers/usb/core/hcd.c | 21 - drivers/usb/core/hub.c | 37 ++ drivers/usb/core/hub.h |2 + drivers/usb/core/port.c | 78 --- 4 files changed, 118 insertions(+), 20 deletions(-) diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 2518c3250750..259990a982f3 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -2766,6 +2766,8 @@ EXPORT_SYMBOL_GPL(usb_add_hcd); */ void usb_remove_hcd(struct usb_hcd *hcd) { + /* only routine outside of hub.c that needs this mutex */ + extern struct mutex usb_port_peer_mutex; To be thorough, you also should hold the mutex when initially setting hcd-self.root_hub. And in usb_create_shared_hcd, when the shared_hcd pointers are initialized. Also, don't forget to clear hcd-self.root_hub (under protection of the mutex) in the failure pathway of usb_add_hcd. @@ -2829,6 +2830,24 @@ void usb_remove_hcd(struct usb_hcd *hcd) usb_put_phy(hcd-phy); hcd-phy = NULL; } + + /* + * Before we free this device, flush in-flight peering attempts + * and disable peer lookups + */ + mutex_lock(usb_port_peer_mutex); + if (hcd-shared_hcd) { + struct usb_hcd *peer_hcd = hcd-shared_hcd; + + hcd-shared_hcd = NULL; + hcd-primary_hcd = NULL; + peer_hcd-shared_hcd = NULL; + if (peer_hcd-primary_hcd == hcd) + peer_hcd-primary_hcd = NULL; + } + mutex_unlock(usb_port_peer_mutex); This belongs in hcd_release, not here, corresponding to the fact that these pointers are initialized in usb_create_shared_hcd. + + usb_put_dev(hcd-self.root_hub); Before doing this, you need to set hcd-self.root_hub to NULL, under the protection of the mutex. Unfortunately, it's not possible to move the usb_put_dev call into hcd_release -- this is because each USB device (including the root hub) holds a reference to the hcd. diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c index 531a591a7b1e..cb42352b97e6 100644 --- a/drivers/usb/core/port.c +++ b/drivers/usb/core/port.c @@ -151,9 +151,68 @@ static struct device_driver usb_port_driver = { .owner = THIS_MODULE, }; +/* + * Set the default peer port for root hubs. Assumes the primary_hcd is + * registered first I realized last night that the second sentence is wrong. We have to be able to go both ways, from the secondary hcd to the primary and vice versa. This is because userspace can unbind and rebind the hub driver to the primary root hub at any time. + */ +static struct usb_port *find_default_peer(struct usb_hub *hub, int port1) +{ + struct usb_device *hdev = hub-hdev; + struct usb_port *peer = NULL; +
Re: [PATCH v2] usb: gadget: return the right length in ffs_epfile_io()
On Tue, Mar 04, 2014 at 08:01:15PM +0300, Sergei Shtylyov wrote: Hello. On 03/04/2014 10:34 AM, Chuansheng Liu wrote: When the request length is aligned to maxpacketsize, sometimes the return length ret the user space requested len. At that time, we will use min_t(size_t, ret, len) to limit the size in case of user data buffer overflow. But we need return the min_t(size_t, ret, len) to tell the user space rightly also. Acked-by: Michal Nazarewicz min...@mina86.com Reviewed-by: David Cohen david.a.co...@linux.intel.com Signed-off-by: Chuansheng Liu chuansheng@intel.com --- drivers/usb/gadget/f_fs.c | 14 -- 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c index 42f7a0e..780f877 100644 --- a/drivers/usb/gadget/f_fs.c +++ b/drivers/usb/gadget/f_fs.c @@ -845,12 +845,14 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data) * we may end up with more data then user space has * space for. */ -ret = ep-status; -if (io_data-read ret 0 -unlikely(copy_to_user(io_data-buf, data, - min_t(size_t, ret, - io_data-len -ret = -EFAULT; +ret = ep-status; Why the indentation jumped suddenly to the right? because it was wrong before ;-) -- balbi signature.asc Description: Digital signature
Re: [PATCH net-next 08/12] r8152: support TSO
On Tue, 2014-03-04 at 20:01 +0800, Hayes Wang wrote: +static u32 r8152_xmit_frags(struct r8152 *tp, struct sk_buff *skb, u8 *data) +{ + struct skb_shared_info *info = skb_shinfo(skb); + unsigned int cur_frag; + u32 total = skb_headlen(skb); + + memcpy(data, skb-data, total); + data += total; + + for (cur_frag = 0; cur_frag info-nr_frags; cur_frag++) { + const skb_frag_t *frag = info-frags + cur_frag; + void *addr; + u32 len; + + len = skb_frag_size(frag); + addr = skb_frag_address(frag); + memcpy(data, addr, len); + data += len; + total += len; } + + return total; } I would rather use skb_copy_bits(), because it correctly handles kmap() case. (If a frag resides in high memory) -- To unsubscribe from this list: send the line unsubscribe 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 v6 part1 6/8] usb: find internal hub tier mismatch via acpi
On Mon, 3 Mar 2014, Dan Williams wrote: Subject: usb: find internal hub tier mismatch via acpi From: Dan Williams dan.j.willi...@intel.com ACPI identifies peer ports by setting their 'group_token' and 'group_position' _PLD data to the same value. If a platform has tier mismatch [1] , ACPI can override the default (USB3 defined) peer port association for internal hubs. External hubs follow the default peer association scheme. Location data is cached as an opaque cookie in usb_port_location data. Note that we only consider the group_token and group_position attributes from the _PLD data as ACPI specifies that group_token is a unique identifier. When we find port location data for a port then we assume that the firmware will also describe its peer port. This allows the implementation to only ever set the peer once. This leads to a question about what happens when a pm runtime event occurs while the peer associations are still resolving. Since we only ever set the peer information once, a USB3 port needs to be prevented from suspending while its -peer pointer is NULL (implemented in a subsequent patch). There is always the possibility that firmware mis-identifies the ports, but there is not much the kernel can do in that case. [1]: xhci 1.1 appendix D figure 131 [2]: acpi 5 section 6.1.8 [alan]: don't do default peering when acpi data present Suggested-by: Alan Stern st...@rowland.harvard.edu Signed-off-by: Dan Williams dan.j.willi...@intel.com static struct usb_port *find_default_peer(struct usb_hub *hub, int port1) { + struct usb_port *port_dev = hub-ports[port1 - 1]; struct usb_device *hdev = hub-hdev; struct usb_device *peer_hdev = NULL; struct usb_hub *peer_hub; + /* + * If location data is available then we can only peer this port + * by a location match, not the default peer (lest we create a + * situation where we need to go back and undo a default peering + * when the port is later peered by location data) + */ + if (port_dev-location) + return NULL; I think you probably also want to reject matches where port_dev-location is 0 but the peer port does have location data. @@ -222,9 +233,92 @@ static void unlink_peers(struct usb_port *left, struct usb_port *right) left-peer = NULL; } +/** + * for_each_child_port() - invoke 'fn' on all usb_port instances beneath 'hdev' + * @hdev: potential hub usb_device (validated by usb_hub_to_struct_hub) + * @level: track recursion level to stop after reaching USB spec max depth + * @p: parameter to pass to 'fn' + * @fn: routine to invoke on each port + * + * Recursively iterate all ports (depth-first) beneath 'hdev' until 'fn' + * returns a non-NULL usb_port or all ports have been visited. + */ +static struct usb_port *for_each_child_port(struct usb_device *hdev, int level, + void *p, struct usb_port * (*fn)(struct usb_port *, void *)) +{ + struct usb_hub *hub = usb_hub_to_struct_hub(hdev); + int port1; + +#define MAX_HUB_DEPTH 5 + if (!hub || level MAX_HUB_DEPTH || hub-disconnected + || hdev-state == USB_STATE_NOTATTACHED) + return NULL; + + level++; + for (port1 = 1; port1 = hdev-maxchild; port1++) { + struct usb_port *ret, *port_dev = hub-ports[port1 - 1]; + + if (!port_dev) + continue; + ret = fn(port_dev, p); + if (ret) + return ret; + ret = for_each_child_port(port_dev-child, level, p, fn); + if (ret) + return ret; + } + + return NULL; +} + +static struct usb_port *do_match_location(struct usb_port *port_dev, void *_loc) +{ + usb_port_location_t *loc = _loc; + + if (port_dev-location == *loc) + return port_dev; + return NULL; +} + +static struct usb_port *find_port_by_location(struct usb_device *hdev, + usb_port_location_t *loc) +{ + return for_each_child_port(hdev, 1, loc, do_match_location); +} + +void usb_set_hub_port_location(struct usb_device *hdev, int port1, + usb_port_location_t location) +{ + struct usb_hub *hub = usb_hub_to_struct_hub(hdev); + struct usb_hcd *hcd = bus_to_hcd(hdev-bus); + struct usb_hcd *peer_hcd = hcd-shared_hcd; + struct usb_port *peer, *port_dev; + struct usb_device *peer_hdev; + + if (!hub) + return; + + port_dev = hub-ports[port1 - 1]; + port_dev-location = location; + if (port_dev-peer) { + WARN_ON(1); + return; + } + + if (!peer_hcd || !peer_hcd-rh_registered) + return; + + peer_hdev = peer_hcd-self.root_hub; + peer = find_port_by_location(peer_hdev, port_dev-location); + if (!peer) + return; + + link_peers(port_dev, peer);
Re: [PATCH 02/12] phy: omap-control: Update DT binding information
* Roger Quadros rog...@ti.com [140304 01:17]: Hi Tony, On 03/03/2014 09:02 PM, Tony Lindgren wrote: * Roger Quadros rog...@ti.com [140303 07:10]: Move omap-control binding information to the right location. Signed-off-by: Roger Quadros rog...@ti.com --- Documentation/devicetree/bindings/phy/ti-phy.txt | 25 ++ Documentation/devicetree/bindings/usb/omap-usb.txt | 24 - 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/Documentation/devicetree/bindings/phy/ti-phy.txt b/Documentation/devicetree/bindings/phy/ti-phy.txt index 207e14c..41dc132 100644 --- a/Documentation/devicetree/bindings/phy/ti-phy.txt +++ b/Documentation/devicetree/bindings/phy/ti-phy.txt @@ -1,5 +1,30 @@ TI PHY: DT DOCUMENTATION FOR PHYs in TI PLATFORMs +OMAP CONTROL PHY + +Required properties: + - compatible: Should be one of + ti,control-phy-otghs - if it has otghs_control mailbox register as on OMAP4. + ti,control-phy-usb2 - if it has Power down bit in control_dev_conf register +e.g. USB2_PHY on OMAP5. + ti,control-phy-pipe3 - if it has DPLL and individual Rx Tx power control +e.g. USB3 PHY and SATA PHY on OMAP5. + ti,control-phy-dra7usb2 - if it has power down register like USB2 PHY on +DRA7 platform. + ti,control-phy-am437usb2 - if it has power down register like USB2 PHY on +AM437 platform. To me it seems that you can leave out all the above. You can set these falgs flags directly in the driver based on the compatible flag. Then just initialize the .data in the driver based on the compatible flag. I'm not sure if I got you. A single platform can have different type of phys. e.g. OMAP5 has both usb2 and pipe3 PHYs, DRA7 has both pipe3 and usb2 PHYs, but this usb2 PHY is not compatible with OMAP5 one so we need a new compatible id for that. To add to the woes, the designers were creative enough to make another mutation to the USB2 PHY for AM437x, :( Oh OK, in that case the compatible flag may not be enough for configuring the various instances. What do you suggest the compatible ids should look like for these 5 types of PHY control? OTGHS (OMAP4 5) USB2 (OMAP5) PIPE3 (OMAP5 DRA7) USB2x (DRA7) USB2y (AM437) I think in that case having the various instances fully configurable from device tree is OK if you prefer that. But if you wanted to use the compatible flag, then you could do something like this: ti,control-phy-omap4-otghs (assuming same on omap4 5) ti,control-phy-omap5-usb2 ti,control-phy-omap5-pipe3 (assuming same on omap5 dra7) ti,control-phy-dra7-usb2x ti,control-phy-am437-usb2y ... Regards, Tony -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH net-next 08/12] r8152: support TSO
On Tue, 2014-03-04 at 20:01 +0800, Hayes Wang wrote: Support scatter gather and TSO. - netdev-features |= NETIF_F_RXCSUM | NETIF_F_IP_CSUM; - netdev-hw_features = NETIF_F_RXCSUM | NETIF_F_IP_CSUM; + netdev-features |= NETIF_F_RXCSUM | NETIF_F_IP_CSUM | NETIF_F_SG | + NETIF_F_TSO; + netdev-hw_features = NETIF_F_RXCSUM | NETIF_F_IP_CSUM | NETIF_F_SG | + NETIF_F_TSO; Minor nit : If you use skb_copy_bits(), then you also can add NETIF_F_FRAGLIST here. -- To unsubscribe from this list: send the line unsubscribe 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 09/12] r8152: support IPv6
On Tue, 2014-03-04 at 20:01 +0800, Hayes Wang wrote: Support hw IPv6 checksum for TCP and UDP packets. +/* + * r8152_csum_workaround() + * The hw limites the value the transport offset. When the offset is out of the + * range, calculate the checksum by sw. + */ +static void r8152_csum_workaround(struct r8152 *tp, struct sk_buff *skb, + struct sk_buff_head *list) +{ + if (skb_shinfo(skb)-gso_size) { + netdev_features_t features = tp-netdev-features; + struct sk_buff *segs, *nskb; + + features = ~(NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_TSO); + segs = skb_gso_segment(skb, features); + if (IS_ERR(segs) || !segs) + goto drop; + + do { + nskb = segs; + segs = segs-next; + nskb-next = NULL; + __skb_queue_head(list, nskb); This introduces TCP reordering. You should use some kind of skb_queue_splice() -- To unsubscribe from this list: send the line unsubscribe 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: 3.13-rc1 regression: Scatter-gather list issues at SuperSpeed only
On Tue, 4 Mar 2014, Sarah Sharp wrote: Scatter-gather under xHCI seems to work fine on mass storage, but it fails with that particular ASIX device, because of how the xHCI driver sets up the buffers on the endpoint rings. We need to implement the TD fragment rules to avoid breaking this particular USB ethernet device. In the meantime, mass storage works fine with scatter-gather, so we don't want to lose hard drive performance. Otherwise, it should be better to just clear no_sg_constraint in xhcd, shouldn't it? We tried that. That's what commit 247bf557273d does. It clears no_sg_constraint for 1.0 xHCI hosts that need TD fragments (and thus would cause the ASIX chipsets to drop packets). However, we've found that commit breaks USB 3.0 mass storage devices. The block layer may submit scatter-gather lists with entries that are multiples of 512-byte blocks. That's fine for USB 2.0 devices, where the bulk endpoint max packet size is 512 bytes. But USB 3.0 devices have bulk endpoints with a 1024 byte max packet size. That means when the block layer submits a scatter-gather list with one entry that includes, say, three 512-byte blocks, this code will reject the URB if it's submitted to a USB 3.0 bulk endpoint: int usb_submit_urb(struct urb *urb, gfp_t mem_flags) { ... max = usb_endpoint_maxp(ep-desc); ... } else if (urb-num_sgs !urb-dev-bus-no_sg_constraint dev-speed != USB_SPEED_WIRELESS) { struct scatterlist *sg; int i; for_each_sg(urb-sg, sg, urb-num_sgs - 1, i) if (sg-length % max) return -EINVAL; } This results in failures with USB 3.0 drives. For me, a failure to auto-mount the device. For others, a read or write SCSI command failure. We can't introduce a regression in USB 3.0 mass storage in order to get better performance on one USB ethernet adapter. It isn't a regression. Even without this test, the transfer will fail. (Actually, depending on the details of your device, maybe it won't fail. But it _should_!) Until we get TD fragments implemented, we need to revert the commit 3804fad45411 and commit 247bf557273d. That will mean USB 3.0 mass storage works again, and (unfortunately) the ASIX driver performance won't be as good until we implement TD fragments. USB-3 mass storage won't work, even after you revert those two commits. 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: 3.13-rc1 regression: Scatter-gather list issues at SuperSpeed only
From: Sarah Sharp ... The block layer may submit scatter-gather lists with entries that are multiples of 512-byte blocks. That's fine for USB 2.0 devices, where the bulk endpoint max packet size is 512 bytes. But USB 3.0 devices have bulk endpoints with a 1024 byte max packet size. That means when the block layer submits a scatter-gather list with one entry that includes, say, three 512-byte blocks, this code will reject the URB if it's submitted to a USB 3.0 bulk endpoint: int usb_submit_urb(struct urb *urb, gfp_t mem_flags) { ... max = usb_endpoint_maxp(ep-desc); ... } else if (urb-num_sgs !urb-dev-bus-no_sg_constraint dev-speed != USB_SPEED_WIRELESS) { struct scatterlist *sg; int i; for_each_sg(urb-sg, sg, urb-num_sgs - 1, i) if (sg-length % max) return -EINVAL; } This results in failures with USB 3.0 drives. For me, a failure to auto-mount the device. For others, a read or write SCSI command failure. We can't introduce a regression in USB 3.0 mass storage in order to get better performance on one USB ethernet adapter. Until we get TD fragments implemented, we need to revert the commit 3804fad45411 and commit 247bf557273d. That will mean USB 3.0 mass storage works again, and (unfortunately) the ASIX driver performance won't be as good until we implement TD fragments. You need to find out what happens when a request that fails the above test gets split by a LINK TRB on the Intel 1.0 controller. If, for example, there is a 3 sector read transfer the target will send a 1k USB data block followed by a 512 byte one. I suspect that the xhci controller will read the first 512 bytes into the first buffer, hit the LINK TRB, and then terminate the data TRB with some kind of error. It might read the last 512 bytes into the second buffer, or might skip to the TRB list and treat the last 512 bytes as a separate bulk transfer. A similar write transfer is likely to generate two bulk transfers, the first of 512 bytes, the second of 1k. What the target makes of that is anybodies guess. Just disabling the test won't make it work. All it does it make it fail less often. David -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 1/1] xhci: Prevent runtime pm from autosuspending during initialization
On Tue, Mar 04, 2014 at 01:50:55PM +0200, Mathias Nyman wrote: On 03/03/2014 08:37 PM, Greg KH wrote: On Mon, Mar 03, 2014 at 07:30:17PM +0200, Mathias Nyman wrote: xHCI driver has its own pci probe function that will call usb_hcd_pci_probe to register its usb-2 bus, and then continue to manually register the usb-3 bus. usb_hcd_pci_probe does a pm_runtime_put_noidle at the end and might thus trigger a runtime suspend before the usb-3 bus is ready. What is the result if that happens? Crashes. Null pointer dereference in xhci_suspend() when touching xhci-shared_hcd before it's initialized. More info here: http://marc.info/?l=linux-usbm=138914518219334w=2 Is this a regression from 3.13? Or something new for 3.14? According to reporter its been around since 3.7 commit 596d789a211d134dc5f94d1e5957248c204ef850 USB: set hub's default autosuspend delay as 0 But nobody else than the reporter is able to trigger it. Then it can wait for 3.15-rc1, and then go back to the stable trees at that time, right? I'd prefer that as it's not a regression and not common. What platform(s) are affected by this? David, the reporter (added to cc), mentioned This bug happened in a platform with 1 usb3 host controller + 1 usb3 OTG controller run by some Intel internal group http://marc.info/?l=linux-usbm=138915969822029w=2 That sounds like a not shipping platform to me :) Please resend this with patches for 3.15-rc1. thanks, greg k-h -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/4] usb: chipidea: switch over to endpoint feature flags
switch over to endpoint feature flags so we can drop naming conventions. Signed-off-by: Felipe Balbi ba...@ti.com --- drivers/usb/chipidea/udc.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index 80de2f8..e80dc82 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c @@ -1576,6 +1576,13 @@ static int init_eps(struct ci_hdrc *ci) hwep-ep.name = hwep-name; hwep-ep.ops = usb_ep_ops; + + hwep-ep.has_bulk = true; + hwep-ep.has_interrupt = true; + hwep-ep.has_isochronous = true; + hwep-ep.has_dir_in = (j == TX); + hwep-ep.has_dir_out = (j == RX); + /* * for ep0: maxP defined in desc, for other * eps, maxP is set by epautoconfig() called -- 1.9.0 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/4] usb: musb: gadget: switch over to endpoint feature flags
switch over to endpoint feature flags so we can drop naming conventions. Signed-off-by: Felipe Balbi ba...@ti.com --- drivers/usb/musb/musb_gadget.c | 13 +++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index d4aa779..f121097 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -1727,14 +1727,23 @@ init_peripheral_ep(struct musb *musb, struct musb_ep *ep, u8 epnum, int is_in) ep-end_point.name = ep-name; INIT_LIST_HEAD(ep-end_point.ep_list); if (!epnum) { + ep-end_point.has_dir_in = true; + ep-end_point.has_dir_out = true; + ep-end_point.has_control = true; usb_ep_set_maxpacket_limit(ep-end_point, 64); ep-end_point.ops = musb_g_ep0_ops; musb-g.ep0 = ep-end_point; } else { - if (is_in) + if (is_in) { + ep-end_point.has_dir_in = true; usb_ep_set_maxpacket_limit(ep-end_point, hw_ep-max_packet_sz_tx); - else + } else { + ep-end_point.has_dir_out = true; usb_ep_set_maxpacket_limit(ep-end_point, hw_ep-max_packet_sz_rx); + } + ep-end_point.has_bulk = true; + ep-end_point.has_interrupt = true; + ep-end_point.has_isochronous = true; ep-end_point.ops = musb_ep_ops; list_add_tail(ep-end_point.ep_list, musb-g.ep_list); } -- 1.9.0 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/2] usb: wusbcore: fix potential double list_del on urb dequeue
This patch locks rpipe-seg_lock around the entire transfer segment cleanup loop in wa_urb_dequeue instead of just one case of the switch statement. This fixes a race between __wa_xfer_delayed_run and wa_urb_dequeue where a transfer segment in the WA_SEG_DELAYED state could be removed from the rpipe seg_list twice leading to memory corruption. It also switches the spin_lock call to use the non-irqsave version since the xfer-lock is already held and irqs already disabled. Signed-off-by: Thomas Pugliese thomas.pugli...@gmail.com --- drivers/usb/wusbcore/wa-xfer.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c index c688afa..1cd0f61 100644 --- a/drivers/usb/wusbcore/wa-xfer.c +++ b/drivers/usb/wusbcore/wa-xfer.c @@ -1974,6 +1974,11 @@ int wa_urb_dequeue(struct wahc *wa, struct urb *urb, int status) goto out_unlock;/* setup(), enqueue_b() completes */ /* Ok, the xfer is in flight already, it's been setup and submitted.*/ xfer_abort_pending = __wa_xfer_abort(xfer) = 0; + /* +* grab the rpipe-seg_lock here to prevent racing with +* __wa_xfer_delayed_run. +*/ + spin_lock(rpipe-seg_lock); for (cnt = 0; cnt xfer-segs; cnt++) { seg = xfer-seg[cnt]; pr_debug(%s: xfer id 0x%08X#%d status = %d\n, @@ -1994,10 +1999,8 @@ int wa_urb_dequeue(struct wahc *wa, struct urb *urb, int status) */ seg-status = WA_SEG_ABORTED; seg-result = -ENOENT; - spin_lock_irqsave(rpipe-seg_lock, flags2); list_del(seg-list_node); xfer-segs_done++; - spin_unlock_irqrestore(rpipe-seg_lock, flags2); break; case WA_SEG_DONE: case WA_SEG_ERROR: @@ -2026,6 +2029,7 @@ int wa_urb_dequeue(struct wahc *wa, struct urb *urb, int status) break; } } + spin_unlock(rpipe-seg_lock); xfer-result = urb-status; /* -ENOENT or -ECONNRESET */ done = __wa_xfer_is_done(xfer); spin_unlock_irqrestore(xfer-lock, flags); -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/2] usb: wusbcore: additional urb dequeue cleanups
Fix two race conditions that could cause memory corruption when unlinking WUSB urbs. Thomas Pugliese (2): usb: wusbcore: fix potential double list_del on urb dequeue usb: wusbcore: don't mark WA_SEG_DTI_PENDING segs as done in urb_dequeue drivers/usb/wusbcore/wa-xfer.c | 19 --- 1 file changed, 16 insertions(+), 3 deletions(-) -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/2] usb: wusbcore: don't mark WA_SEG_DTI_PENDING segs as done in urb_dequeue
Data for transfer segments in the WA_SEG_DTI_PENDING state is actively being read by the driver. Let the buffer read callback handle the transfer cleanup since cleaning it up in wa_urb_dequeue will cause the read callback to access invalid memory if the transfer is completed. Signed-off-by: Thomas Pugliese thomas.pugli...@gmail.com --- drivers/usb/wusbcore/wa-xfer.c | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c index 1cd0f61..12b764e 100644 --- a/drivers/usb/wusbcore/wa-xfer.c +++ b/drivers/usb/wusbcore/wa-xfer.c @@ -2007,6 +2007,16 @@ int wa_urb_dequeue(struct wahc *wa, struct urb *urb, int status) case WA_SEG_ABORTED: break; /* +* The buf_in data for a segment in the +* WA_SEG_DTI_PENDING state is actively being read. +* Let wa_buf_in_cb handle it since it will be called +* and will increment xfer-segs_done. Cleaning up +* here could cause wa_buf_in_cb to access the xfer +* after it has been completed/freed. +*/ + case WA_SEG_DTI_PENDING: + break; + /* * In the states below, the HWA device already knows * about the transfer. If an abort request was sent, * allow the HWA to process it and wait for the @@ -2015,7 +2025,6 @@ int wa_urb_dequeue(struct wahc *wa, struct urb *urb, int status) */ case WA_SEG_SUBMITTED: case WA_SEG_PENDING: - case WA_SEG_DTI_PENDING: /* * Check if the abort was successfully sent. This could * be false if the HWA has been removed but we haven't -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCHv2] usb: dwc2: Add function to calculate correct FIFO sizes
On Tue, 2014-03-04 at 09:18 -0600, Felipe Balbi wrote: On Mon, Mar 03, 2014 at 09:25:13PM -0600, dingu...@altera.com wrote: From: Dinh Nguyen dingu...@altera.com The dwc2 IP on the SOCFPGA cannot use the default HW configured FIFO sizes. The total FIFO depth as read from GHWCFG3 reports 0x1f80 or 8064 32-bit words. But the GRXFSIZ, GNPTXFSIZ, and HPTXFSIZ register defaults to 0x2000 or 8192 32-bit words. So the driver cannot just use the fifo sizes as read from those registers. For platforms that face the same issue, this commits sets the RX, periodic TX, and non-periodic TX fifo size to those that are recommended v2.93a spec for the DWC2 IP. Signed-off-by: Dinh Nguyen dingu...@altera.com Acked-by: Paul Zimmerman pa...@synopsys.com --- v2: Fix coding style with braces around both if() branches --- drivers/usb/dwc2/core.c | 41 + 1 file changed, 41 insertions(+) diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c index 1d12988..efa7a45 100644 --- a/drivers/usb/dwc2/core.c +++ b/drivers/usb/dwc2/core.c @@ -507,6 +507,44 @@ void dwc2_disable_host_interrupts(struct dwc2_hsotg *hsotg) writel(intmsk, hsotg-regs + GINTMSK); } +/* + * dwc2_calculate_dynamic_fifo() - Calculates the default fifo size + * For system that have a total fifo depth that is smaller than the default + * RX + TX fifo size. + * + * @hsotg: Programming view of DWC_otg controller + */ +static void dwc2_calculate_dynamic_fifo(struct dwc2_hsotg *hsotg) +{ + struct dwc2_core_params *params = hsotg-core_params; + struct dwc2_hw_params *hw = hsotg-hw_params; + u32 rxfsiz, nptxfsiz, ptxfsiz, total_fifo_size; + + total_fifo_size = hw-total_fifo_size; + rxfsiz = params-host_rx_fifo_size; + nptxfsiz = params-host_nperio_tx_fifo_size; + ptxfsiz = params-host_perio_tx_fifo_size; + + if (total_fifo_size = (rxfsiz + nptxfsiz + ptxfsiz)) { + /* Params are valid, nothing to do */ + return; + } else { + /* min rx fifo size = ((largest packet/4)*2)+2 */ + rxfsiz = (512/4) * 2 + 2; + /* min non-periodic tx fifo depth */ + nptxfsiz = 2 * (512/4); + /* min periodic tx fifo depth */ + ptxfsiz = (512 * 3)/4; + } + + if (total_fifo_size (rxfsiz + nptxfsiz + ptxfsiz)) + dev_err(hsotg-dev, invalid fifo sizes\n); my comments were silently ignored. NAK. I did not mean to ignore your comments, except I did not see any for this patch. http://thread.gmane.org/gmane.linux.usb.general/104157 Except for the checkpatch --strict part. Which I reran with v1 of the patch and it still was clean. Dinh -- To unsubscribe from this list: send the line unsubscribe 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/4] usb: renesas: switch over to endpoint feature flags
switch over to endpoint feature flags so we can drop naming conventions. Signed-off-by: Felipe Balbi ba...@ti.com --- drivers/usb/renesas_usbhs/mod_gadget.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c index 458f376..e798d7a 100644 --- a/drivers/usb/renesas_usbhs/mod_gadget.c +++ b/drivers/usb/renesas_usbhs/mod_gadget.c @@ -982,15 +982,26 @@ int usbhs_mod_gadget_probe(struct usbhs_priv *priv) uep-ep.name= uep-ep_name; uep-ep.ops = usbhsg_ep_ops; + INIT_LIST_HEAD(uep-ep.ep_list); /* init DCP */ if (usbhsg_is_dcp(uep)) { + uep-ep.has_dir_in = true; + uep-ep.has_dir_out = true; + uep-ep.has_control = true; + gpriv-gadget.ep0 = uep-ep; usb_ep_set_maxpacket_limit(uep-ep, 64); } /* init normal pipe */ else { + uep-ep.has_dir_in = true; + uep-ep.has_dir_out = true; + uep-ep.has_bulk= true; + uep-ep.has_interrupt = true; + uep-ep.has_isochronous = true; + usb_ep_set_maxpacket_limit(uep-ep, 512); list_add_tail(uep-ep.ep_list, gpriv-gadget.ep_list); } -- 1.9.0 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCHv2] usb: dwc2: Add function to calculate correct FIFO sizes
Hi, On Tue, Mar 04, 2014 at 11:34:26AM -0600, Dinh Nguyen wrote: On Tue, 2014-03-04 at 09:18 -0600, Felipe Balbi wrote: On Mon, Mar 03, 2014 at 09:25:13PM -0600, dingu...@altera.com wrote: From: Dinh Nguyen dingu...@altera.com The dwc2 IP on the SOCFPGA cannot use the default HW configured FIFO sizes. The total FIFO depth as read from GHWCFG3 reports 0x1f80 or 8064 32-bit words. But the GRXFSIZ, GNPTXFSIZ, and HPTXFSIZ register defaults to 0x2000 or 8192 32-bit words. So the driver cannot just use the fifo sizes as read from those registers. For platforms that face the same issue, this commits sets the RX, periodic TX, and non-periodic TX fifo size to those that are recommended v2.93a spec for the DWC2 IP. Signed-off-by: Dinh Nguyen dingu...@altera.com Acked-by: Paul Zimmerman pa...@synopsys.com --- v2: Fix coding style with braces around both if() branches --- drivers/usb/dwc2/core.c | 41 + 1 file changed, 41 insertions(+) diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c index 1d12988..efa7a45 100644 --- a/drivers/usb/dwc2/core.c +++ b/drivers/usb/dwc2/core.c @@ -507,6 +507,44 @@ void dwc2_disable_host_interrupts(struct dwc2_hsotg *hsotg) writel(intmsk, hsotg-regs + GINTMSK); } +/* + * dwc2_calculate_dynamic_fifo() - Calculates the default fifo size + * For system that have a total fifo depth that is smaller than the default + * RX + TX fifo size. + * + * @hsotg: Programming view of DWC_otg controller + */ +static void dwc2_calculate_dynamic_fifo(struct dwc2_hsotg *hsotg) +{ + struct dwc2_core_params *params = hsotg-core_params; + struct dwc2_hw_params *hw = hsotg-hw_params; + u32 rxfsiz, nptxfsiz, ptxfsiz, total_fifo_size; + + total_fifo_size = hw-total_fifo_size; + rxfsiz = params-host_rx_fifo_size; + nptxfsiz = params-host_nperio_tx_fifo_size; + ptxfsiz = params-host_perio_tx_fifo_size; + + if (total_fifo_size = (rxfsiz + nptxfsiz + ptxfsiz)) { + /* Params are valid, nothing to do */ + return; + } else { + /* min rx fifo size = ((largest packet/4)*2)+2 */ + rxfsiz = (512/4) * 2 + 2; + /* min non-periodic tx fifo depth */ + nptxfsiz = 2 * (512/4); + /* min periodic tx fifo depth */ + ptxfsiz = (512 * 3)/4; + } + + if (total_fifo_size (rxfsiz + nptxfsiz + ptxfsiz)) + dev_err(hsotg-dev, invalid fifo sizes\n); my comments were silently ignored. NAK. I did not mean to ignore your comments, except I did not see any for this patch. http://thread.gmane.org/gmane.linux.usb.general/104157 Except for the checkpatch --strict part. Which I reran with v1 of the patch and it still was clean. here: http://marc.info/?l=linux-usbm=139390107203151w=2 The difference is that you renamed the patch, but it's still the same code. -- balbi signature.asc Description: Digital signature
Re: 3.13-rc1 regression: Scatter-gather list issues at SuperSpeed only
On Tue, Mar 04, 2014 at 10:00:16AM -0500, Alan Stern wrote: On Tue, 4 Mar 2014, David Laight wrote: Notice the request length: 1536. That's three 512-byte sectors. A little unusual, since most I/O is done in units of pages, which are 4096 bytes. Ok, we can't have SuperSpeed mass storage devices broken, so it looks like we'll have to revert the last patch to add scatter-gather to the ASIX driver to avoid that breakage. That means Mathias is going to need to revert those two commits then, since he's taking over pushing xHCI driver bug fixes this kernel. Greg, Dave, Freddy, how do you want to handle reverting commit 3804fad45411? Should that come through Dave's networking tree or Greg's USB tree? I'm not sure what those two commits have to do with this problem. In order to support a request with a non-terminal buffer that isn't a multiple of 1k you need something to stop a LINK TRB being in the middle of the transfer. Otherwise the 1536 byte transfer (expected as a 1k block followed by 512byte one) can probably get sent as a 512byte block (terminating the bulk data request) followed by a spurious 1k block. These should generate horrid errors from the target disk. David is right; this problem can't be fixed simply by reverting patches. The real problem is that the block layer has handed the USB stack an SG list that xhci-hcd cannot handle at all, in its current form. We do not know if the driver not implementing TD fragment rules impacts USB storage devices. I can certainly look into that today, with the xHCI 1.0 hosts I have on hand (Ivy Bridge and Haswell-ULT). I can experiment with shorting the ring segment so that almost every SCSI transfer has a link TRB in the middle, and use a USB 3.0 analyzer to see whether there are any short packets or abnormal traffic on the bus. There are only two reasonable ways to fix this: Add appropriate TRB fragment handling into xhci-hcd, or use bounce buffers for non-aligned requests. Or disable scatter-gather for xHCI 1.0 hosts all together. Alan, what do you suggest we do for the stable kernels in the meantime before we have TD fragment rules in place? 3.12 and 3.13 already have those two patches, and I keep getting failure reports. From a user perspective, USB 3.0 mass storage devices used to work before 3.14-rc1. Theoretically, the TD fragment rules could have caused an occasional disk glitch. Now the devices *will* fail, instead of theoretically failing. From a user perspective, this looks like a regression; the USB device obviously fails on 3.14-rc1, and may sometimes silently fail on prior kernels. So what would you have me do to fix stable kernels? In theory the block layer could be taught about the need for these bounce buffers, but that would be only a partial solution. It would help for mass-storage transfers, but not for networking (which doesn't use the block layer). An alternative is to work around this particular problem by identifying the code that submits the 3-sector SG element, and changing it to use an even number of sectors. But obviously that doesn't solve the underlying issue. I think in the end there is no real choice but to bite the bullet and implement the TRB fragmentation rules. I agree we should implement TD fragment rules. It's too late in the -rc cycle to get those finished before 3.14 final. So what do we do with stable in the meantime? Sarah Sharp -- To unsubscribe from this list: send the line unsubscribe 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: 3.13-rc1 regression: Scatter-gather list issues at SuperSpeed only
On Tue, 4 Mar 2014, Sarah Sharp wrote: David is right; this problem can't be fixed simply by reverting patches. The real problem is that the block layer has handed the USB stack an SG list that xhci-hcd cannot handle at all, in its current form. We do not know if the driver not implementing TD fragment rules impacts USB storage devices. I can certainly look into that today, with the xHCI 1.0 hosts I have on hand (Ivy Bridge and Haswell-ULT). I can experiment with shorting the ring segment so that almost every SCSI transfer has a link TRB in the middle, and use a USB 3.0 analyzer to see whether there are any short packets or abnormal traffic on the bus. Okay, that's certainly worth doing. It might be even easier to use testusb with gadget zero. Tests 5 and 6 exercise bulk SG, and you can set the length parameter to 512. There are only two reasonable ways to fix this: Add appropriate TRB fragment handling into xhci-hcd, or use bounce buffers for non-aligned requests. Or disable scatter-gather for xHCI 1.0 hosts all together. That won't help. In fact, it would cause all of these questionable transfers to fail, not just those that cross a ring segment boundary. Without SG support in the HCD, the scatter-gather library routine would end up creating a single URB for 1536 bytes. For READ, it would fail with an overflow error when the device sent two 1024-byte packets. For WRITE, goodness knows what the device would do with an unexpected short packet. Alan, what do you suggest we do for the stable kernels in the meantime before we have TD fragment rules in place? 3.12 and 3.13 already have those two patches, and I keep getting failure reports. At the moment, I guess the best you can do is keep the SG support in xhci-hcd, set the no_sg_constraint flag, and live with an occasional failure when a link TRB occurs at an odd sector boundary. Also disable SG in the ax88179 network driver. In other words, revert those two commits. From a user perspective, USB 3.0 mass storage devices used to work before 3.14-rc1. Theoretically, the TD fragment rules could have caused an occasional disk glitch. Now the devices *will* fail, instead of theoretically failing. From a user perspective, this looks like a regression; the USB device obviously fails on 3.14-rc1, and may sometimes silently fail on prior kernels. So what would you have me do to fix stable kernels? Reverting them seems to be the only choice for now. 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] usb: Make DELAY_INIT quirk wait 100ms between Get Configuration requests
On Tue, Mar 04, 2014 at 10:53:06AM -0800, Julius Werner wrote: The DELAY_INIT quirk only reduces the frequency of enumeration failures with the Logitech HD Pro C920 and C930e webcams, but does not quite eliminate them. We have found that adding a delay of 100ms between the first and second Get Configuration request makes the device enumerate perfectly reliable even after several weeks of extensive testing. The reasons for that are anyone's guess, but since the DELAY_INIT quirk already delays enumeration by a whole second, wating for another 10th of that isn't really a big deal for the one other device that uses it, and it will resolve the problems with these webcams. Change-Id: Ibf738426307fe8ef362768db2decc9bc2b30a930 What am I supposed to do with this line? :) -- To unsubscribe from this list: send the line unsubscribe 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 12/12] staging: usbip: userspace: update dependencies in README
Add libudev as dependency and remove libsysfs. Signed-off-by: Valentina Manea valentina.mane...@gmail.com --- drivers/staging/usbip/userspace/README | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/usbip/userspace/README b/drivers/staging/usbip/userspace/README index 00a1658..6ead290 100644 --- a/drivers/staging/usbip/userspace/README +++ b/drivers/staging/usbip/userspace/README @@ -9,8 +9,8 @@ - USB/IP device drivers Found in the staging directory of the Linux kernel. -- sysfsutils = 2.0.0 - sysfsutils library +- libudev = 2.0 + libudev library - libwrap0-dev tcp wrapper library -- 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
[PATCH 06/12] staging: usbip: userspace: add new list API
Add a new list API from CCAN. Signed-off-by: Valentina Manea valentina.mane...@gmail.com --- drivers/staging/usbip/userspace/libsrc/Makefile.am | 3 +- .../staging/usbip/userspace/libsrc/build_assert.h | 40 ++ .../staging/usbip/userspace/libsrc/check_type.h| 64 +++ .../staging/usbip/userspace/libsrc/container_of.h | 109 drivers/staging/usbip/userspace/libsrc/list.c | 43 ++ drivers/staging/usbip/userspace/libsrc/list.h | 613 + 6 files changed, 871 insertions(+), 1 deletion(-) create mode 100644 drivers/staging/usbip/userspace/libsrc/build_assert.h create mode 100644 drivers/staging/usbip/userspace/libsrc/check_type.h create mode 100644 drivers/staging/usbip/userspace/libsrc/container_of.h create mode 100644 drivers/staging/usbip/userspace/libsrc/list.c create mode 100644 drivers/staging/usbip/userspace/libsrc/list.h diff --git a/drivers/staging/usbip/userspace/libsrc/Makefile.am b/drivers/staging/usbip/userspace/libsrc/Makefile.am index 4921189..294270b 100644 --- a/drivers/staging/usbip/userspace/libsrc/Makefile.am +++ b/drivers/staging/usbip/userspace/libsrc/Makefile.am @@ -4,4 +4,5 @@ libusbip_la_LDFLAGS = -version-info @LIBUSBIP_VERSION@ lib_LTLIBRARIES := libusbip.la libusbip_la_SOURCES := names.c names.h usbip_host_driver.c usbip_host_driver.h \ - usbip_common.c usbip_common.h vhci_driver.c vhci_driver.h + usbip_common.c usbip_common.h vhci_driver.c vhci_driver.h \ + list.c list.h build_assert.h check_type.h container_of.h diff --git a/drivers/staging/usbip/userspace/libsrc/build_assert.h b/drivers/staging/usbip/userspace/libsrc/build_assert.h new file mode 100644 index 000..b9ecd84 --- /dev/null +++ b/drivers/staging/usbip/userspace/libsrc/build_assert.h @@ -0,0 +1,40 @@ +/* CC0 (Public domain) - see LICENSE file for details */ +#ifndef CCAN_BUILD_ASSERT_H +#define CCAN_BUILD_ASSERT_H + +/** + * BUILD_ASSERT - assert a build-time dependency. + * @cond: the compile-time condition which must be true. + * + * Your compile will fail if the condition isn't true, or can't be evaluated + * by the compiler. This can only be used within a function. + * + * Example: + * #include stddef.h + * ... + * static char *foo_to_char(struct foo *foo) + * { + * // This code needs string to be at start of foo. + * BUILD_ASSERT(offsetof(struct foo, string) == 0); + * return (char *)foo; + * } + */ +#define BUILD_ASSERT(cond) \ + do { (void) sizeof(char [1 - 2*!(cond)]); } while(0) + +/** + * BUILD_ASSERT_OR_ZERO - assert a build-time dependency, as an expression. + * @cond: the compile-time condition which must be true. + * + * Your compile will fail if the condition isn't true, or can't be evaluated + * by the compiler. This can be used in an expression: its value is 0. + * + * Example: + * #define foo_to_char(foo)\ + * ((char *)(foo) \ + * + BUILD_ASSERT_OR_ZERO(offsetof(struct foo, string) == 0)) + */ +#define BUILD_ASSERT_OR_ZERO(cond) \ + (sizeof(char [1 - 2*!(cond)]) - 1) + +#endif /* CCAN_BUILD_ASSERT_H */ diff --git a/drivers/staging/usbip/userspace/libsrc/check_type.h b/drivers/staging/usbip/userspace/libsrc/check_type.h new file mode 100644 index 000..a39cc41 --- /dev/null +++ b/drivers/staging/usbip/userspace/libsrc/check_type.h @@ -0,0 +1,64 @@ +/* CC0 (Public domain) - see LICENSE file for details */ +#ifndef CCAN_CHECK_TYPE_H +#define CCAN_CHECK_TYPE_H +#include config.h + +/** + * check_type - issue a warning or build failure if type is not correct. + * @expr: the expression whose type we should check (not evaluated). + * @type: the exact type we expect the expression to be. + * + * This macro is usually used within other macros to try to ensure that a macro + * argument is of the expected type. No type promotion of the expression is + * done: an unsigned int is not the same as an int! + * + * check_type() always evaluates to 0. + * + * If your compiler does not support typeof, then the best we can do is fail + * to compile if the sizes of the types are unequal (a less complete check). + * + * Example: + * // They should always pass a 64-bit value to _set_some_value! + * #define set_some_value(expr)\ + * _set_some_value((check_type((expr), uint64_t), (expr))) + */ + +/** + * check_types_match - issue a warning or build failure if types are not same. + * @expr1: the first expression (not evaluated). + * @expr2: the second expression (not evaluated). + * + * This macro is usually used within other macros to try to ensure that + * arguments are of identical types. No type promotion of the expressions is + * done: an unsigned int is not the same as an int! + * + * check_types_match() always evaluates to 0. + * + * If your compiler does not support typeof,
[PATCH 09/12] staging: usbip: userspace: remove class device infrastructure in vhci_driver
The class device lists were used only when being initialized, being populated and being destroyed. They had no real meaning and thus the code was useless. Signed-off-by: Valentina Manea valentina.mane...@gmail.com --- .../staging/usbip/userspace/libsrc/vhci_driver.c | 178 - .../staging/usbip/userspace/libsrc/vhci_driver.h | 4 - 2 files changed, 182 deletions(-) diff --git a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c index d5839a5..73a163aa 100644 --- a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c +++ b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c @@ -28,26 +28,6 @@ imported_device_init(struct usbip_imported_device *idev, char *busid) read_usb_device(sudev, idev-udev); udev_device_unref(sudev); - /* add class devices of this imported device */ - struct usbip_class_device *cdev; - dlist_for_each_data(vhci_driver-cdev_list, cdev, - struct usbip_class_device) { - if (!strncmp(cdev-dev_path, idev-udev.path, -strlen(idev-udev.path))) { - struct usbip_class_device *new_cdev; - /* -* alloc and copy because dlist is linked -* from only one list -*/ - new_cdev = calloc(1, sizeof(*new_cdev)); - if (!new_cdev) - goto err; - - memcpy(new_cdev, cdev, sizeof(*new_cdev)); - dlist_unshift(idev-cdev_list, (void *) new_cdev); - } - } - return idev; err: @@ -103,12 +83,6 @@ static int parse_status(char *value) idev-busnum= (devid 16); idev-devnum= (devid 0x); - idev-cdev_list = dlist_new(sizeof(struct usbip_class_device)); - if (!idev-cdev_list) { - dbg(dlist_new failed); - return -1; - } - if (idev-status != VDEV_ST_NULL idev-status != VDEV_ST_NOTASSIGNED) { idev = imported_device_init(idev, lbusid); @@ -132,118 +106,6 @@ static int parse_status(char *value) return 0; } - -static int check_usbip_device(struct sysfs_class_device *cdev) -{ - /* /sys/class/video4linux/video0/device */ - char class_path[SYSFS_PATH_MAX]; - /* /sys/devices/platform/vhci_hcd/usb6/6-1:1.1 */ - char dev_path[SYSFS_PATH_MAX]; - int ret; - struct usbip_class_device *usbip_cdev; - - snprintf(class_path, sizeof(class_path), %s/device, cdev-path); - - ret = sysfs_get_link(class_path, dev_path, sizeof(dev_path)); - if (ret == 0) { - if (!strncmp(dev_path, vhci_driver-hc_device-path, -strlen(vhci_driver-hc_device-path))) { - /* found usbip device */ - usbip_cdev = calloc(1, sizeof(*usbip_cdev)); - if (!usbip_cdev) { - dbg(calloc failed); - return -1; - } - dlist_unshift(vhci_driver-cdev_list, usbip_cdev); - strncpy(usbip_cdev-class_path, class_path, - sizeof(usbip_cdev-class_path)); - strncpy(usbip_cdev-dev_path, dev_path, - sizeof(usbip_cdev-dev_path)); - dbg(found: %s %s, class_path, dev_path); - } - } - - return 0; -} - - -static int search_class_for_usbip_device(char *cname) -{ - struct sysfs_class *class; - struct dlist *cdev_list; - struct sysfs_class_device *cdev; - int ret = 0; - - class = sysfs_open_class(cname); - if (!class) { - dbg(sysfs_open_class failed); - return -1; - } - - dbg(class: %s, class-name); - - cdev_list = sysfs_get_class_devices(class); - if (!cdev_list) - /* nothing */ - goto out; - - dlist_for_each_data(cdev_list, cdev, struct sysfs_class_device) { - dbg(cdev: %s, cdev-name); - ret = check_usbip_device(cdev); - if (ret 0) - goto out; - } - -out: - sysfs_close_class(class); - - return ret; -} - - -static int refresh_class_device_list(void) -{ - int ret; - struct dlist *cname_list; - char *cname; - char sysfs_mntpath[SYSFS_PATH_MAX]; - char class_path[SYSFS_PATH_MAX]; - - ret = sysfs_get_mnt_path(sysfs_mntpath, SYSFS_PATH_MAX); - if (ret 0) { - dbg(sysfs_get_mnt_path failed); - return -1;
[PATCH 08/12] staging: usbip: userspace: migrate usbip_host_driver to libudev
This patch modifies usbip_host_driver to use libudev. Signed-off-by: Valentina Manea valentina.mane...@gmail.com --- .../staging/usbip/userspace/libsrc/usbip_common.c | 74 ++ .../staging/usbip/userspace/libsrc/usbip_common.h | 5 +- .../usbip/userspace/libsrc/usbip_host_driver.c | 282 ++--- .../usbip/userspace/libsrc/usbip_host_driver.h | 7 +- .../staging/usbip/userspace/libsrc/vhci_driver.c | 22 +- drivers/staging/usbip/userspace/src/usbipd.c | 10 +- 6 files changed, 138 insertions(+), 262 deletions(-) diff --git a/drivers/staging/usbip/userspace/libsrc/usbip_common.c b/drivers/staging/usbip/userspace/libsrc/usbip_common.c index 6620d18..8d675a9 100644 --- a/drivers/staging/usbip/userspace/libsrc/usbip_common.c +++ b/drivers/staging/usbip/userspace/libsrc/usbip_common.c @@ -2,6 +2,7 @@ * Copyright (C) 2005-2007 Takahiro Hirofuchi */ +#include libudev.h #include usbip_common.h #include names.h @@ -12,6 +13,8 @@ int usbip_use_syslog; int usbip_use_stderr; int usbip_use_debug; +extern struct udev *udev_context; + struct speed_string { int num; char *speed; @@ -111,75 +114,48 @@ void dump_usb_device(struct usbip_usb_device *udev) } -int read_attr_value(struct sysfs_device *dev, const char *name, +int read_attr_value(struct udev_device *dev, const char *name, const char *format) { - char attrpath[SYSFS_PATH_MAX]; - struct sysfs_attribute *attr; + const char *attr; int num = 0; int ret; - snprintf(attrpath, sizeof(attrpath), %s/%s, dev-path, name); - - attr = sysfs_open_attribute(attrpath); + attr = udev_device_get_sysattr_value(dev, name); if (!attr) { - dbg(sysfs_open_attribute failed: %s, attrpath); - return 0; - } - - ret = sysfs_read_attribute(attr); - if (ret 0) { - dbg(sysfs_read_attribute failed); + dbg(udev_device_get_sysattr_value failed); goto err; } - ret = sscanf(attr-value, format, num); + ret = sscanf(attr, format, num); if (ret 1) { dbg(sscanf failed); goto err; } err: - sysfs_close_attribute(attr); return num; } -int read_attr_speed(struct sysfs_device *dev) +int read_attr_speed(struct udev_device *dev) { - char attrpath[SYSFS_PATH_MAX]; - struct sysfs_attribute *attr; - char speed[100]; - int ret; + const char *speed; - snprintf(attrpath, sizeof(attrpath), %s/%s, dev-path, speed); - - attr = sysfs_open_attribute(attrpath); - if (!attr) { - dbg(sysfs_open_attribute failed: %s, attrpath); - return 0; - } - - ret = sysfs_read_attribute(attr); - if (ret 0) { - dbg(sysfs_read_attribute failed); + speed = udev_device_get_sysattr_value(dev, speed); + if (!speed) { + dbg(udev_device_get_sysattr_value failed); goto err; } - ret = sscanf(attr-value, %99s\n, speed); - if (ret 1) { - dbg(sscanf failed); - goto err; - } -err: - sysfs_close_attribute(attr); - for (int i = 0; speed_strings[i].speed != NULL; i++) { if (!strcmp(speed, speed_strings[i].speed)) return speed_strings[i].num; } +err: + return USB_SPEED_UNKNOWN; } @@ -190,9 +166,10 @@ err: } while (0) -int read_usb_device(struct sysfs_device *sdev, struct usbip_usb_device *udev) +int read_usb_device(struct udev_device *sdev, struct usbip_usb_device *udev) { uint32_t busnum, devnum; + const char *path, *name; READ_ATTR(udev, uint8_t, sdev, bDeviceClass, %02x\n); READ_ATTR(udev, uint8_t, sdev, bDeviceSubClass,%02x\n); @@ -209,10 +186,13 @@ int read_usb_device(struct sysfs_device *sdev, struct usbip_usb_device *udev) READ_ATTR(udev, uint8_t, sdev, devnum, %d\n); udev-speed = read_attr_speed(sdev); - strncpy(udev-path, sdev-path, SYSFS_PATH_MAX); - strncpy(udev-busid, sdev-name, SYSFS_BUS_ID_SIZE); + path = udev_device_get_syspath(sdev); + name = udev_device_get_sysname(sdev); - sscanf(sdev-name, %u-%u, busnum, devnum); + strncpy(udev-path, path, SYSFS_PATH_MAX); + strncpy(udev-busid, name, SYSFS_BUS_ID_SIZE); + + sscanf(name, %u-%u, busnum, devnum); udev-busnum = busnum; return 0; @@ -222,13 +202,13 @@ int read_usb_interface(struct usbip_usb_device *udev, int i, struct usbip_usb_interface *uinf) { char busid[SYSFS_BUS_ID_SIZE]; - struct sysfs_device *sif; + struct udev_device *sif; sprintf(busid, %s:%d.%d, udev-busid, udev-bConfigurationValue, i); - sif = sysfs_open_device(usb, busid); +
[PATCH 10/12] staging: usbip: userspace: migrate vhci_driver to libudev
This patch migrates vhci_driver to libudev. Signed-off-by: Valentina Manea valentina.mane...@gmail.com --- .../staging/usbip/userspace/libsrc/usbip_common.h | 1 - .../staging/usbip/userspace/libsrc/vhci_driver.c | 154 ++--- .../staging/usbip/userspace/libsrc/vhci_driver.h | 5 +- 3 files changed, 44 insertions(+), 116 deletions(-) diff --git a/drivers/staging/usbip/userspace/libsrc/usbip_common.h b/drivers/staging/usbip/userspace/libsrc/usbip_common.h index 9c11060..c4a72c3 100644 --- a/drivers/staging/usbip/userspace/libsrc/usbip_common.h +++ b/drivers/staging/usbip/userspace/libsrc/usbip_common.h @@ -5,7 +5,6 @@ #ifndef __USBIP_COMMON_H #define __USBIP_COMMON_H -#include sysfs/libsysfs.h #include libudev.h #include stdint.h diff --git a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c index 73a163aa..e7839a0 100644 --- a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c +++ b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c @@ -7,6 +7,7 @@ #include limits.h #include netdb.h #include libudev.h +#include sysfs_utils.h #undef PROGNAME #define PROGNAME libusbip @@ -36,7 +37,7 @@ err: -static int parse_status(char *value) +static int parse_status(const char *value) { int ret = 0; char *c; @@ -108,42 +109,33 @@ static int parse_status(char *value) static int refresh_imported_device_list(void) { - struct sysfs_attribute *attr_status; + const char *attr_status; - - attr_status = sysfs_get_device_attr(vhci_driver-hc_device, status); + attr_status = udev_device_get_sysattr_value(vhci_driver-hc_device, + status); if (!attr_status) { - dbg(sysfs_get_device_attr(\status\) failed: %s, - vhci_driver-hc_device-name); + dbg(udev_device_get_sysattr_value failed); return -1; } - dbg(name: %s path: %s len: %d method: %d value: %s, - attr_status-name, attr_status-path, attr_status-len, - attr_status-method, attr_status-value); - - return parse_status(attr_status-value); + return parse_status(attr_status); } static int get_nports(void) { char *c; int nports = 0; - struct sysfs_attribute *attr_status; + const char *attr_status; - attr_status = sysfs_get_device_attr(vhci_driver-hc_device, status); + attr_status = udev_device_get_sysattr_value(vhci_driver-hc_device, + status); if (!attr_status) { - dbg(sysfs_get_device_attr(\status\) failed: %s, - vhci_driver-hc_device-name); + dbg(udev_device_get_sysattr_value failed); return -1; } - dbg(name: %s path: %s len: %d method: %d value: %s, - attr_status-name, attr_status-path, attr_status-len, - attr_status-method, attr_status-value); - /* skip a header line */ - c = strchr(attr_status-value, '\n'); + c = strchr(attr_status, '\n'); if (!c) return 0; c++; @@ -160,50 +152,6 @@ static int get_nports(void) return nports; } -static int get_hc_busid(char *sysfs_mntpath, char *hc_busid) -{ - struct sysfs_driver *sdriver; - char sdriver_path[SYSFS_PATH_MAX]; - - struct sysfs_device *hc_dev; - struct dlist *hc_devs; - - int found = 0; - - snprintf(sdriver_path, SYSFS_PATH_MAX, %s/%s/%s/%s/%s, sysfs_mntpath, - SYSFS_BUS_NAME, USBIP_VHCI_BUS_TYPE, SYSFS_DRIVERS_NAME, - USBIP_VHCI_DRV_NAME); - - sdriver = sysfs_open_driver_path(sdriver_path); - if (!sdriver) { - dbg(sysfs_open_driver_path failed: %s, sdriver_path); - dbg(make sure USBIP_CORE_MOD_NAME .ko and - USBIP_VHCI_DRV_NAME .ko are loaded!); - return -1; - } - - hc_devs = sysfs_get_driver_devices(sdriver); - if (!hc_devs) { - dbg(sysfs_get_driver failed); - goto err; - } - - /* assume only one vhci_hcd */ - dlist_for_each_data(hc_devs, hc_dev, struct sysfs_device) { - strncpy(hc_busid, hc_dev-bus_id, SYSFS_BUS_ID_SIZE); - found = 1; - } - -err: - sysfs_close_driver(sdriver); - - if (found) - return 0; - - dbg(%s not found, hc_busid); - return -1; -} - /* * Read the given port's record. * @@ -215,7 +163,6 @@ err: */ static int read_record(int rhport, char *host, unsigned long host_len, char *port, unsigned long port_len, char *busid) - { int part; FILE *file; @@ -272,36 +219,21 @@ static int read_record(int rhport, char *host, unsigned long host_len, int usbip_vhci_driver_open(void) { - int ret; - char hc_busid[SYSFS_BUS_ID_SIZE]; -
[PATCH 07/12] staging: usbip: userspace: move sysfs_utils to libsrc
Since it offers a API to both usbip tools and libusbip, it is more appropriate to be place in the library. Signed-off-by: Valentina Manea valentina.mane...@gmail.com --- drivers/staging/usbip/userspace/libsrc/Makefile.am | 3 +- .../staging/usbip/userspace/libsrc/sysfs_utils.c | 36 ++ .../staging/usbip/userspace/libsrc/sysfs_utils.h | 8 + drivers/staging/usbip/userspace/src/Makefile.am| 3 +- drivers/staging/usbip/userspace/src/sysfs_utils.c | 36 -- drivers/staging/usbip/userspace/src/sysfs_utils.h | 8 - 6 files changed, 47 insertions(+), 47 deletions(-) create mode 100644 drivers/staging/usbip/userspace/libsrc/sysfs_utils.c create mode 100644 drivers/staging/usbip/userspace/libsrc/sysfs_utils.h delete mode 100644 drivers/staging/usbip/userspace/src/sysfs_utils.c delete mode 100644 drivers/staging/usbip/userspace/src/sysfs_utils.h diff --git a/drivers/staging/usbip/userspace/libsrc/Makefile.am b/drivers/staging/usbip/userspace/libsrc/Makefile.am index 294270b..b4c7631 100644 --- a/drivers/staging/usbip/userspace/libsrc/Makefile.am +++ b/drivers/staging/usbip/userspace/libsrc/Makefile.am @@ -5,4 +5,5 @@ libusbip_la_LDFLAGS = -version-info @LIBUSBIP_VERSION@ lib_LTLIBRARIES := libusbip.la libusbip_la_SOURCES := names.c names.h usbip_host_driver.c usbip_host_driver.h \ usbip_common.c usbip_common.h vhci_driver.c vhci_driver.h \ - list.c list.h build_assert.h check_type.h container_of.h + list.c list.h build_assert.h check_type.h container_of.h \ + sysfs_utils.c sysfs_utils.h diff --git a/drivers/staging/usbip/userspace/libsrc/sysfs_utils.c b/drivers/staging/usbip/userspace/libsrc/sysfs_utils.c new file mode 100644 index 000..2c362d1 --- /dev/null +++ b/drivers/staging/usbip/userspace/libsrc/sysfs_utils.c @@ -0,0 +1,36 @@ +#include sys/types.h +#include sys/stat.h +#include fcntl.h +#include errno.h + +#include sysfs_utils.h +#include usbip_common.h + +int write_sysfs_attribute(const char *attr_path, const char *new_value, + size_t len) +{ + int fd; + int length; + + if (attr_path == NULL || new_value == NULL || len == 0) { + dbg(Invalid values provided for attribute %s., attr_path); + errno = EINVAL; + return -1; + } + + if ((fd = open(attr_path, O_WRONLY)) 0) { + dbg(Error opening attribute %s., attr_path); + return -1; + } + + length = write(fd, new_value, len); + if (length 0) { + dbg(Error writing to attribute %s., attr_path); + close(fd); + return -1; + } + + close(fd); + + return 0; +} diff --git a/drivers/staging/usbip/userspace/libsrc/sysfs_utils.h b/drivers/staging/usbip/userspace/libsrc/sysfs_utils.h new file mode 100644 index 000..32ac1d1 --- /dev/null +++ b/drivers/staging/usbip/userspace/libsrc/sysfs_utils.h @@ -0,0 +1,8 @@ + +#ifndef __SYSFS_UTILS_H +#define __SYSFS_UTILS_H + +int write_sysfs_attribute(const char *attr_path, const char *new_value, + size_t len); + +#endif diff --git a/drivers/staging/usbip/userspace/src/Makefile.am b/drivers/staging/usbip/userspace/src/Makefile.am index 6c91bcb..b4f8c4b 100644 --- a/drivers/staging/usbip/userspace/src/Makefile.am +++ b/drivers/staging/usbip/userspace/src/Makefile.am @@ -6,8 +6,7 @@ sbin_PROGRAMS := usbip usbipd usbip_SOURCES := usbip.h utils.h usbip.c utils.c usbip_network.c \ usbip_attach.c usbip_detach.c usbip_list.c \ -usbip_bind.c usbip_unbind.c usbip_port.c \ -sysfs_utils.c +usbip_bind.c usbip_unbind.c usbip_port.c usbipd_SOURCES := usbip_network.h usbipd.c usbip_network.c diff --git a/drivers/staging/usbip/userspace/src/sysfs_utils.c b/drivers/staging/usbip/userspace/src/sysfs_utils.c deleted file mode 100644 index 2c362d1..000 --- a/drivers/staging/usbip/userspace/src/sysfs_utils.c +++ /dev/null @@ -1,36 +0,0 @@ -#include sys/types.h -#include sys/stat.h -#include fcntl.h -#include errno.h - -#include sysfs_utils.h -#include usbip_common.h - -int write_sysfs_attribute(const char *attr_path, const char *new_value, - size_t len) -{ - int fd; - int length; - - if (attr_path == NULL || new_value == NULL || len == 0) { - dbg(Invalid values provided for attribute %s., attr_path); - errno = EINVAL; - return -1; - } - - if ((fd = open(attr_path, O_WRONLY)) 0) { - dbg(Error opening attribute %s., attr_path); - return -1; - } - - length = write(fd, new_value, len); - if (length 0) { - dbg(Error writing to attribute %s., attr_path); - close(fd); - return -1; - } - - close(fd); - -
[PATCH 03/12] staging: usbip: userspace: migrate usbip_unbind to libudev
This patch modifies usbip_unbind to use libudev. Signed-off-by: Valentina Manea valentina.mane...@gmail.com --- drivers/staging/usbip/userspace/src/usbip_unbind.c | 92 +++--- 1 file changed, 29 insertions(+), 63 deletions(-) diff --git a/drivers/staging/usbip/userspace/src/usbip_unbind.c b/drivers/staging/usbip/userspace/src/usbip_unbind.c index cace878..4776068 100644 --- a/drivers/staging/usbip/userspace/src/usbip_unbind.c +++ b/drivers/staging/usbip/userspace/src/usbip_unbind.c @@ -16,7 +16,7 @@ * along with this program. If not, see http://www.gnu.org/licenses/. */ -#include sysfs/libsysfs.h +#include libudev.h #include errno.h #include stdio.h @@ -27,6 +27,7 @@ #include usbip_common.h #include utils.h #include usbip.h +#include sysfs_utils.h static const char usbip_unbind_usage_string[] = usbip unbind args\n @@ -41,92 +42,57 @@ void usbip_unbind_usage(void) static int unbind_device(char *busid) { char bus_type[] = usb; - struct sysfs_driver *usbip_host_drv; - struct sysfs_device *dev; - struct dlist *devlist; - int verified = 0; int rc, ret = -1; char attr_name[] = unbind; - char sysfs_mntpath[SYSFS_PATH_MAX]; char unbind_attr_path[SYSFS_PATH_MAX]; - struct sysfs_attribute *unbind_attr; - - /* verify the busid device is using usbip-host */ - usbip_host_drv = sysfs_open_driver(bus_type, USBIP_HOST_DRV_NAME); - if (!usbip_host_drv) { - err(could not open %s driver: %s, USBIP_HOST_DRV_NAME, - strerror(errno)); - return -1; - } - devlist = sysfs_get_driver_devices(usbip_host_drv); - if (!devlist) { - err(%s is not in use by any devices, USBIP_HOST_DRV_NAME); - goto err_close_usbip_host_drv; - } + struct udev *udev; + struct udev_device *dev; + const char *driver; - dlist_for_each_data(devlist, dev, struct sysfs_device) { - if (!strncmp(busid, dev-name, strlen(busid)) - !strncmp(dev-driver_name, USBIP_HOST_DRV_NAME, -strlen(USBIP_HOST_DRV_NAME))) { - verified = 1; - break; - } - } + /* Create libudev context. */ + udev = udev_new(); - if (!verified) { - err(device on busid %s is not using %s, busid, - USBIP_HOST_DRV_NAME); - goto err_close_usbip_host_drv; + /* Check whether the device with this bus ID exists. */ + dev = udev_device_new_from_subsystem_sysname(udev, usb, busid); + if (!dev) { + err(Device with the specified bus ID does not exist.); + goto err_close_udev; } - /* -* NOTE: A read and write of an attribute value of the device busid -* refers to must be done to start probing. That way a rebind of the -* default driver for the device occurs. -* -* This seems very hackish and adds a lot of pointless code. I think it -* should be done in the kernel by the driver after del_match_busid is -* finished! -*/ - - rc = sysfs_get_mnt_path(sysfs_mntpath, SYSFS_PATH_MAX); - if (rc 0) { - err(sysfs must be mounted: %s, strerror(errno)); - return -1; + /* Check whether the device is using usbip-host driver. */ + driver = udev_device_get_driver(dev); + if (!driver || strcmp(driver, usbip-host)) { + err(Device is not bound to usbip-host driver.); + goto err_close_udev; } + /* Unbind device from driver. */ snprintf(unbind_attr_path, sizeof(unbind_attr_path), %s/%s/%s/%s/%s/%s, -sysfs_mntpath, SYSFS_BUS_NAME, bus_type, SYSFS_DRIVERS_NAME, +SYSFS_MNT_PATH, SYSFS_BUS_NAME, bus_type, SYSFS_DRIVERS_NAME, USBIP_HOST_DRV_NAME, attr_name); + dbg(unbind attribute path: %s, unbind_attr_path); - /* read a device attribute */ - unbind_attr = sysfs_open_attribute(unbind_attr_path); - if (!unbind_attr) { - err(could not open %s/%s: %s, busid, attr_name, - strerror(errno)); - return -1; + rc = write_sysfs_attribute(unbind_attr_path, busid, strlen(busid)); + if (rc 0) { + dbg(Error unbinding device %s from driver., busid); + goto err_close_udev; } - /* notify driver of unbind */ + /* Notify driver of unbind. */ rc = modify_match_busid(busid, 0); if (rc 0) { err(unable to unbind device on %s, busid); + goto err_close_udev; } - rc = sysfs_write_attribute(unbind_attr, busid, - SYSFS_BUS_ID_SIZE); - if (rc 0) { - dbg(bind driver at %s failed,
[PATCH 02/12] staging: usbip: userspace: remove useless libsysfs includes
This patch removes useless libsysfs.h includes in various userspace files. Signed-off-by: Valentina Manea valentina.mane...@gmail.com --- drivers/staging/usbip/userspace/src/usbip_attach.c | 1 - drivers/staging/usbip/userspace/src/usbip_detach.c | 2 -- drivers/staging/usbip/userspace/src/usbip_network.h | 1 - 3 files changed, 4 deletions(-) diff --git a/drivers/staging/usbip/userspace/src/usbip_attach.c b/drivers/staging/usbip/userspace/src/usbip_attach.c index 0858411..716a79e 100644 --- a/drivers/staging/usbip/userspace/src/usbip_attach.c +++ b/drivers/staging/usbip/userspace/src/usbip_attach.c @@ -17,7 +17,6 @@ */ #include sys/stat.h -#include sysfs/libsysfs.h #include limits.h #include stdint.h diff --git a/drivers/staging/usbip/userspace/src/usbip_detach.c b/drivers/staging/usbip/userspace/src/usbip_detach.c index 13308df..05c6d15 100644 --- a/drivers/staging/usbip/userspace/src/usbip_detach.c +++ b/drivers/staging/usbip/userspace/src/usbip_detach.c @@ -16,8 +16,6 @@ * along with this program. If not, see http://www.gnu.org/licenses/. */ -#include sysfs/libsysfs.h - #include ctype.h #include limits.h #include stdint.h diff --git a/drivers/staging/usbip/userspace/src/usbip_network.h b/drivers/staging/usbip/userspace/src/usbip_network.h index f19ae19..c1e875c 100644 --- a/drivers/staging/usbip/userspace/src/usbip_network.h +++ b/drivers/staging/usbip/userspace/src/usbip_network.h @@ -10,7 +10,6 @@ #endif #include sys/types.h -#include sysfs/libsysfs.h #include stdint.h -- 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
[PATCH 05/12] staging: usbip: userspace: re-add interface information listing
This was deleted in the driver conversion patch. It didn't need to be deleted; showing more information is ok. Signed-off-by: Valentina Manea valentina.mane...@gmail.com --- drivers/staging/usbip/userspace/src/usbip_list.c | 20 +++- drivers/staging/usbip/userspace/src/usbipd.c | 16 +++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/drivers/staging/usbip/userspace/src/usbip_list.c b/drivers/staging/usbip/userspace/src/usbip_list.c index 2255107..7e1820a 100644 --- a/drivers/staging/usbip/userspace/src/usbip_list.c +++ b/drivers/staging/usbip/userspace/src/usbip_list.c @@ -52,8 +52,9 @@ static int get_exported_devices(char *host, int sockfd) struct op_devlist_reply reply; uint16_t code = OP_REP_DEVLIST; struct usbip_usb_device udev; + struct usbip_usb_interface uintf; unsigned int i; - int rc; + int rc, j; rc = usbip_net_send_op_common(sockfd, OP_REQ_DEVLIST, 0); if (rc 0) { @@ -103,6 +104,23 @@ static int get_exported_devices(char *host, int sockfd) printf(%11s: %s\n, , udev.path); printf(%11s: %s\n, , class_name); + for (j = 0; j udev.bNumInterfaces; j++) { + rc = usbip_net_recv(sockfd, uintf, sizeof(uintf)); + if (rc 0) { + dbg(usbip_net_recv failed: usbip_usb_intf[%d], + j); + + return -1; + } + usbip_net_pack_usb_interface(0, uintf); + + usbip_names_get_class(class_name, sizeof(class_name), + uintf.bInterfaceClass, + uintf.bInterfaceSubClass, + uintf.bInterfaceProtocol); + printf(%11s: %2d - %s\n, , j, class_name); + } + printf(\n); } diff --git a/drivers/staging/usbip/userspace/src/usbipd.c b/drivers/staging/usbip/userspace/src/usbipd.c index c2b3ced..b2230f7 100644 --- a/drivers/staging/usbip/userspace/src/usbipd.c +++ b/drivers/staging/usbip/userspace/src/usbipd.c @@ -159,8 +159,9 @@ static int send_reply_devlist(int connfd) { struct usbip_exported_device *edev; struct usbip_usb_device pdu_udev; + struct usbip_usb_interface pdu_uinf; struct op_devlist_reply reply; - int rc; + int rc, i; reply.ndev = 0; /* number of exported devices */ @@ -194,6 +195,19 @@ static int send_reply_devlist(int connfd) dbg(usbip_net_send failed: pdu_udev); return -1; } + + for (i = 0; i edev-udev.bNumInterfaces; i++) { + dump_usb_interface(edev-uinf[i]); + memcpy(pdu_uinf, edev-uinf[i], sizeof(pdu_uinf)); + usbip_net_pack_usb_interface(1, pdu_uinf); + + rc = usbip_net_send(connfd, pdu_uinf, + sizeof(pdu_uinf)); + if (rc 0) { + dbg(usbip_net_send failed: pdu_uinf); + return -1; + } + } } return 0; -- 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
[PATCH 01/12] staging: usbip: userspace: migrate usbip_bind to libudev
This patch adds autoconf check for libudev and migrates usbip_bind to the new library. libsysfs will still be used until all userspace is modified. Signed-off-by: Valentina Manea valentina.mane...@gmail.com --- drivers/staging/usbip/userspace/configure.ac | 6 + .../staging/usbip/userspace/libsrc/usbip_common.h | 9 ++ drivers/staging/usbip/userspace/src/Makefile.am| 3 +- drivers/staging/usbip/userspace/src/sysfs_utils.c | 36 + drivers/staging/usbip/userspace/src/sysfs_utils.h | 8 ++ drivers/staging/usbip/userspace/src/usbip_bind.c | 149 + drivers/staging/usbip/userspace/src/utils.c| 51 +++ 7 files changed, 136 insertions(+), 126 deletions(-) create mode 100644 drivers/staging/usbip/userspace/src/sysfs_utils.c create mode 100644 drivers/staging/usbip/userspace/src/sysfs_utils.h diff --git a/drivers/staging/usbip/userspace/configure.ac b/drivers/staging/usbip/userspace/configure.ac index 0ee5d92..a5193c6 100644 --- a/drivers/staging/usbip/userspace/configure.ac +++ b/drivers/staging/usbip/userspace/configure.ac @@ -50,6 +50,12 @@ AC_CHECK_HEADER([sysfs/libsysfs.h], [AC_MSG_ERROR([Missing sysfs2 library!])])], [AC_MSG_ERROR([Missing /usr/include/sysfs/libsysfs.h])]) +AC_CHECK_HEADER([libudev.h], + [AC_CHECK_LIB([udev], [udev_new], + [LIBS=$LIBS -ludev], + [AC_MSG_ERROR([Missing udev library!])])], + [AC_MSG_ERROR([Missing /usr/include/libudev.h])]) + # Checks for libwrap library. AC_MSG_CHECKING([whether to use the libwrap (TCP wrappers) library]) AC_ARG_WITH([tcp-wrappers], diff --git a/drivers/staging/usbip/userspace/libsrc/usbip_common.h b/drivers/staging/usbip/userspace/libsrc/usbip_common.h index 2cb81b3..565ac78 100644 --- a/drivers/staging/usbip/userspace/libsrc/usbip_common.h +++ b/drivers/staging/usbip/userspace/libsrc/usbip_common.h @@ -29,6 +29,15 @@ #define USBIP_HOST_DRV_NAMEusbip-host #define USBIP_VHCI_DRV_NAMEvhci_hcd +/* sysfs constants */ +#define SYSFS_MNT_PATH /sys +#define SYSFS_BUS_NAME bus +#define SYSFS_BUS_TYPE usb +#define SYSFS_DRIVERS_NAME drivers + +#define SYSFS_PATH_MAX 256 +#define SYSFS_BUS_ID_SIZE 32 + extern int usbip_use_syslog; extern int usbip_use_stderr; extern int usbip_use_debug ; diff --git a/drivers/staging/usbip/userspace/src/Makefile.am b/drivers/staging/usbip/userspace/src/Makefile.am index b4f8c4b..6c91bcb 100644 --- a/drivers/staging/usbip/userspace/src/Makefile.am +++ b/drivers/staging/usbip/userspace/src/Makefile.am @@ -6,7 +6,8 @@ sbin_PROGRAMS := usbip usbipd usbip_SOURCES := usbip.h utils.h usbip.c utils.c usbip_network.c \ usbip_attach.c usbip_detach.c usbip_list.c \ -usbip_bind.c usbip_unbind.c usbip_port.c +usbip_bind.c usbip_unbind.c usbip_port.c \ +sysfs_utils.c usbipd_SOURCES := usbip_network.h usbipd.c usbip_network.c diff --git a/drivers/staging/usbip/userspace/src/sysfs_utils.c b/drivers/staging/usbip/userspace/src/sysfs_utils.c new file mode 100644 index 000..2c362d1 --- /dev/null +++ b/drivers/staging/usbip/userspace/src/sysfs_utils.c @@ -0,0 +1,36 @@ +#include sys/types.h +#include sys/stat.h +#include fcntl.h +#include errno.h + +#include sysfs_utils.h +#include usbip_common.h + +int write_sysfs_attribute(const char *attr_path, const char *new_value, + size_t len) +{ + int fd; + int length; + + if (attr_path == NULL || new_value == NULL || len == 0) { + dbg(Invalid values provided for attribute %s., attr_path); + errno = EINVAL; + return -1; + } + + if ((fd = open(attr_path, O_WRONLY)) 0) { + dbg(Error opening attribute %s., attr_path); + return -1; + } + + length = write(fd, new_value, len); + if (length 0) { + dbg(Error writing to attribute %s., attr_path); + close(fd); + return -1; + } + + close(fd); + + return 0; +} diff --git a/drivers/staging/usbip/userspace/src/sysfs_utils.h b/drivers/staging/usbip/userspace/src/sysfs_utils.h new file mode 100644 index 000..32ac1d1 --- /dev/null +++ b/drivers/staging/usbip/userspace/src/sysfs_utils.h @@ -0,0 +1,8 @@ + +#ifndef __SYSFS_UTILS_H +#define __SYSFS_UTILS_H + +int write_sysfs_attribute(const char *attr_path, const char *new_value, + size_t len); + +#endif diff --git a/drivers/staging/usbip/userspace/src/usbip_bind.c b/drivers/staging/usbip/userspace/src/usbip_bind.c index 8cfd2db..d122089 100644 --- a/drivers/staging/usbip/userspace/src/usbip_bind.c +++ b/drivers/staging/usbip/userspace/src/usbip_bind.c @@ -16,7 +16,7 @@ * along with this program. If not, see http://www.gnu.org/licenses/. */ -#include sysfs/libsysfs.h
[PATCH 04/12] staging: usbip: userspace: migrate usbip_list to libudev
This patch modifies usbip_list to use libudev. Signed-off-by: Valentina Manea valentina.mane...@gmail.com --- drivers/staging/usbip/userspace/src/usbip_list.c | 137 +-- 1 file changed, 51 insertions(+), 86 deletions(-) diff --git a/drivers/staging/usbip/userspace/src/usbip_list.c b/drivers/staging/usbip/userspace/src/usbip_list.c index 8864fa2..2255107 100644 --- a/drivers/staging/usbip/userspace/src/usbip_list.c +++ b/drivers/staging/usbip/userspace/src/usbip_list.c @@ -17,7 +17,7 @@ */ #include sys/types.h -#include sysfs/libsysfs.h +#include libudev.h #include errno.h #include stdbool.h @@ -133,8 +133,8 @@ static int list_exported_devices(char *host) return 0; } -static void print_device(char *busid, char *vendor, char *product, -bool parsable) +static void print_device(const char *busid, const char *vendor, +const char *product, bool parsable) { if (parsable) printf(busid=%s#usbid=%.4s:%.4s#, busid, vendor, product); @@ -148,106 +148,71 @@ static void print_product_name(char *product_name, bool parsable) printf( %s\n, product_name); } -static void print_interface(char *busid, char *driver, bool parsable) -{ - if (parsable) - printf(%s=%s#, busid, driver); - else - printf(%9s%s - %s\n, , busid, driver); -} - -static int is_device(void *x) -{ - struct sysfs_attribute *devpath; - struct sysfs_device *dev = x; - int ret = 0; - - devpath = sysfs_get_device_attr(dev, devpath); - if (devpath *devpath-value != '0') - ret = 1; - - return ret; -} - -static int devcmp(void *a, void *b) -{ - return strcmp(a, b); -} - static int list_devices(bool parsable) { - char bus_type[] = usb; - char busid[SYSFS_BUS_ID_SIZE]; + struct udev *udev; + struct udev_enumerate *enumerate; + struct udev_list_entry *devices, *dev_list_entry; + struct udev_device *dev; + const char *path; + const char *idVendor; + const char *idProduct; + const char *bConfValue; + const char *bNumIntfs; + const char *busid; char product_name[128]; - struct sysfs_bus *ubus; - struct sysfs_device *dev; - struct sysfs_device *intf; - struct sysfs_attribute *idVendor; - struct sysfs_attribute *idProduct; - struct sysfs_attribute *bConfValue; - struct sysfs_attribute *bNumIntfs; - struct dlist *devlist; - int i; int ret = -1; - ubus = sysfs_open_bus(bus_type); - if (!ubus) { - err(could not open %s bus: %s, bus_type, strerror(errno)); - return -1; - } - - devlist = sysfs_get_bus_devices(ubus); - if (!devlist) { - err(could not get %s bus devices: %s, bus_type, - strerror(errno)); - goto err_out; - } - - /* remove interfaces and root hubs from device list */ - dlist_filter_sort(devlist, is_device, devcmp); - - if (!parsable) { - printf(Local USB devices\n); - printf(=\n); - } - dlist_for_each_data(devlist, dev, struct sysfs_device) { - idVendor = sysfs_get_device_attr(dev, idVendor); - idProduct = sysfs_get_device_attr(dev, idProduct); - bConfValue = sysfs_get_device_attr(dev, bConfigurationValue); - bNumIntfs = sysfs_get_device_attr(dev, bNumInterfaces); + /* Create libudev context. */ + udev = udev_new(); + + /* Create libudev device enumeration. */ + enumerate = udev_enumerate_new(udev); + + /* Take only USB devices that are not hubs and do not have +* the bInterfaceNumber attribute, i.e. are not interfaces. +*/ + udev_enumerate_add_match_subsystem(enumerate, usb); + udev_enumerate_add_nomatch_sysattr(enumerate, bDeviceClass, 09); + udev_enumerate_add_nomatch_sysattr(enumerate, bInterfaceNumber, NULL); + udev_enumerate_scan_devices(enumerate); + + devices = udev_enumerate_get_list_entry(enumerate); + + /* Show information about each device. */ + udev_list_entry_foreach(dev_list_entry, devices) { + path = udev_list_entry_get_name(dev_list_entry); + dev = udev_device_new_from_syspath(udev, path); + + /* Get device information. */ + idVendor = udev_device_get_sysattr_value(dev, idVendor); + idProduct = udev_device_get_sysattr_value(dev, idProduct); + bConfValue = udev_device_get_sysattr_value(dev, bConfigurationValue); + bNumIntfs = udev_device_get_sysattr_value(dev, bNumInterfaces); + busid = udev_device_get_sysname(dev); if (!idVendor || !idProduct || !bConfValue || !bNumIntfs) { - err(problem getting
[PATCH] staging: usbip: userspace: increase version to 2.0
Signed-off-by: Valentina Manea valentina.mane...@gmail.com --- drivers/staging/usbip/userspace/configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/usbip/userspace/configure.ac b/drivers/staging/usbip/userspace/configure.ac index 25bf160..607d05c 100644 --- a/drivers/staging/usbip/userspace/configure.ac +++ b/drivers/staging/usbip/userspace/configure.ac @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. AC_PREREQ(2.59) -AC_INIT([usbip-utils], [1.1.1], [linux-usb@vger.kernel.org]) +AC_INIT([usbip-utils], [2.0], [linux-usb@vger.kernel.org]) AC_DEFINE([USBIP_VERSION], [0x0111], [binary-coded decimal version number]) CURRENT=0 -- 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: [PATCH] staging: usbip: userspace: increase version to 2.0
On Tue, Mar 04, 2014 at 09:16:39PM +0200, Valentina Manea wrote: Signed-off-by: Valentina Manea valentina.mane...@gmail.com --- drivers/staging/usbip/userspace/configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/usbip/userspace/configure.ac b/drivers/staging/usbip/userspace/configure.ac index 25bf160..607d05c 100644 --- a/drivers/staging/usbip/userspace/configure.ac +++ b/drivers/staging/usbip/userspace/configure.ac @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. AC_PREREQ(2.59) -AC_INIT([usbip-utils], [1.1.1], [linux-usb@vger.kernel.org]) +AC_INIT([usbip-utils], [2.0], [linux-usb@vger.kernel.org]) Why? What does this mean? What warrents the version change? Why have a version at all? thanks, greg k-h -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] staging: usbip: let client choose device configuration
Since usbip-host is now a device driver and the client has full access to the shared device, it makes sense to let the client choose device configuration. Signed-off-by: Valentina Manea valentina.mane...@gmail.com --- drivers/staging/usbip/stub_dev.c | 10 +- drivers/staging/usbip/stub_rx.c | 26 +++--- 2 files changed, 8 insertions(+), 28 deletions(-) diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c index 60a3e3f..1bd13cf 100644 --- a/drivers/staging/usbip/stub_dev.c +++ b/drivers/staging/usbip/stub_dev.c @@ -337,7 +337,7 @@ static int stub_probe(struct usb_device *udev) { struct stub_device *sdev = NULL; const char *udev_busid = dev_name(udev-dev); - int err = 0, config; + int err = 0; struct bus_id_priv *busid_priv; dev_dbg(udev-dev, Enter\n); @@ -383,14 +383,6 @@ static int stub_probe(struct usb_device *udev) busid_priv-shutdown_busid = 0; - config = usb_choose_configuration(udev); - if (config = 0) { - err = usb_set_configuration(udev, config); - if (err err != -ENODEV) - dev_err(udev-dev, can't set config #%d, error %d\n, - config, err); - } - /* set private data to usb_device */ dev_set_drvdata(udev-dev, sdev); busid_priv-sdev = sdev; diff --git a/drivers/staging/usbip/stub_rx.c b/drivers/staging/usbip/stub_rx.c index 76e44d9..e0b6d6b 100644 --- a/drivers/staging/usbip/stub_rx.c +++ b/drivers/staging/usbip/stub_rx.c @@ -142,31 +142,19 @@ static int tweak_set_interface_cmd(struct urb *urb) static int tweak_set_configuration_cmd(struct urb *urb) { + struct stub_priv *priv = (struct stub_priv *) urb-context; + struct stub_device *sdev = priv-sdev; struct usb_ctrlrequest *req; __u16 config; + int err; req = (struct usb_ctrlrequest *) urb-setup_packet; config = le16_to_cpu(req-wValue); - /* -* I have never seen a multi-config device. Very rare. -* For most devices, this will be called to choose a default -* configuration only once in an initialization phase. -* -* set_configuration may change a device configuration and its device -* drivers will be unbound and assigned for a new device configuration. -* This means this usbip driver will be also unbound when called, then -* eventually reassigned to the device as far as driver matching -* condition is kept. -* -* Unfortunately, an existing usbip connection will be dropped -* due to this driver unbinding. So, skip here. -* A user may need to set a special configuration value before -* exporting the device. -*/ - dev_info(urb-dev-dev, usb_set_configuration %d to %s... skip!\n, -config, dev_name(urb-dev-dev)); - + err = usb_set_configuration(sdev-udev, config); + if (err err != -ENODEV) + dev_err(sdev-udev-dev, can't set config #%d, error %d\n, + config, err); return 0; } -- 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
[PATCH] staging: usbip: trigger driver probing after unbinding from usbip-host
A sysfs attribute is used to announce kernel space that a new driver probing session should be triggered for the just unbinded device. In order to have the address of struct device associated to this USB device, a new member has been added to struct bus_id_priv. Signed-off-by: Valentina Manea valentina.mane...@gmail.com --- drivers/staging/usbip/stub.h | 1 + drivers/staging/usbip/stub_dev.c | 1 + drivers/staging/usbip/stub_main.c | 39 ++ drivers/staging/usbip/userspace/src/usbip_unbind.c | 18 -- 4 files changed, 57 insertions(+), 2 deletions(-) diff --git a/drivers/staging/usbip/stub.h b/drivers/staging/usbip/stub.h index 82e539a..266e2b0 100644 --- a/drivers/staging/usbip/stub.h +++ b/drivers/staging/usbip/stub.h @@ -86,6 +86,7 @@ struct bus_id_priv { char status; int interf_count; struct stub_device *sdev; + struct usb_device *udev; char shutdown_busid; }; diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c index 1bd13cf..ee899f0 100644 --- a/drivers/staging/usbip/stub_dev.c +++ b/drivers/staging/usbip/stub_dev.c @@ -386,6 +386,7 @@ static int stub_probe(struct usb_device *udev) /* set private data to usb_device */ dev_set_drvdata(udev-dev, sdev); busid_priv-sdev = sdev; + busid_priv-udev = udev; err = stub_add_files(udev-dev); if (err) { diff --git a/drivers/staging/usbip/stub_main.c b/drivers/staging/usbip/stub_main.c index bd7b83a..9c5832a 100644 --- a/drivers/staging/usbip/stub_main.c +++ b/drivers/staging/usbip/stub_main.c @@ -19,6 +19,7 @@ #include linux/string.h #include linux/module.h +#include linux/device.h #include usbip_common.h #include stub.h @@ -187,6 +188,34 @@ static ssize_t store_match_busid(struct device_driver *dev, const char *buf, static DRIVER_ATTR(match_busid, S_IRUSR | S_IWUSR, show_match_busid, store_match_busid); +static ssize_t rebind_store(struct device_driver *dev, const char *buf, +size_t count) +{ + int ret; + int len; + struct bus_id_priv *bid; + + /* buf length should be less that BUSID_SIZE */ + len = strnlen(buf, BUSID_SIZE); + + if (!(len BUSID_SIZE)) + return -EINVAL; + + bid = get_busid_priv(buf); + if (!bid) + return -ENODEV; + + ret = device_attach(bid-udev-dev); + if (ret 0) { + dev_err(bid-udev-dev, rebind failed\n); + return ret; + } + + return count; +} + +static DRIVER_ATTR_WO(rebind); + static struct stub_priv *stub_priv_pop_from_listhead(struct list_head *listhead) { struct stub_priv *priv, *tmp; @@ -267,6 +296,13 @@ static int __init usbip_host_init(void) goto err_create_file; } + ret = driver_create_file(stub_driver.drvwrap.driver, +driver_attr_rebind); + if (ret) { + pr_err(driver_create_file failed\n); + goto err_create_file; + } + pr_info(DRIVER_DESC v USBIP_VERSION \n); return ret; @@ -282,6 +318,9 @@ static void __exit usbip_host_exit(void) driver_remove_file(stub_driver.drvwrap.driver, driver_attr_match_busid); + driver_remove_file(stub_driver.drvwrap.driver, + driver_attr_rebind); + /* * deregister() calls stub_disconnect() for all devices. Device * specific data is cleared in stub_disconnect(). diff --git a/drivers/staging/usbip/userspace/src/usbip_unbind.c b/drivers/staging/usbip/userspace/src/usbip_unbind.c index 4776068..ba0a563 100644 --- a/drivers/staging/usbip/userspace/src/usbip_unbind.c +++ b/drivers/staging/usbip/userspace/src/usbip_unbind.c @@ -44,8 +44,10 @@ static int unbind_device(char *busid) char bus_type[] = usb; int rc, ret = -1; - char attr_name[] = unbind; + char unbind_attr_name[] = unbind; char unbind_attr_path[SYSFS_PATH_MAX]; + char rebind_attr_name[] = rebind; + char rebind_attr_path[SYSFS_PATH_MAX]; struct udev *udev; struct udev_device *dev; @@ -71,7 +73,7 @@ static int unbind_device(char *busid) /* Unbind device from driver. */ snprintf(unbind_attr_path, sizeof(unbind_attr_path), %s/%s/%s/%s/%s/%s, SYSFS_MNT_PATH, SYSFS_BUS_NAME, bus_type, SYSFS_DRIVERS_NAME, -USBIP_HOST_DRV_NAME, attr_name); +USBIP_HOST_DRV_NAME, unbind_attr_name); dbg(unbind attribute path: %s, unbind_attr_path); rc = write_sysfs_attribute(unbind_attr_path, busid, strlen(busid)); @@ -87,6 +89,18 @@ static int unbind_device(char *busid) goto err_close_udev; } + /* Trigger new probing. */ + snprintf(rebind_attr_path, sizeof(unbind_attr_path),
[PATCH] staging: usbip: claim ports used by shared devices
Signed-off-by: Valentina Manea valentina.mane...@gmail.com --- drivers/staging/usbip/stub_dev.c | 22 ++ drivers/usb/core/devio.c | 17 - drivers/usb/core/hub.c | 2 ++ drivers/usb/core/usb.h | 6 +- include/linux/usb.h | 23 +++ 5 files changed, 48 insertions(+), 22 deletions(-) diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c index ee899f0..952743c 100644 --- a/drivers/staging/usbip/stub_dev.c +++ b/drivers/staging/usbip/stub_dev.c @@ -339,6 +339,7 @@ static int stub_probe(struct usb_device *udev) const char *udev_busid = dev_name(udev-dev); int err = 0; struct bus_id_priv *busid_priv; + int rc; dev_dbg(udev-dev, Enter\n); @@ -388,6 +389,18 @@ static int stub_probe(struct usb_device *udev) busid_priv-sdev = sdev; busid_priv-udev = udev; + /* +* Claim this hub port. +* It doesn't matter what value we pass as owner +* (struct dev_state) as long as it is unique. +*/ + rc = usb_hub_claim_port(udev-parent, udev-portnum, + (struct dev_state *) udev); + if (rc) { + dev_dbg(udev-dev, unable to claim port\n); + return rc; + } + err = stub_add_files(udev-dev); if (err) { dev_err(udev-dev, stub_add_files for %s\n, udev_busid); @@ -424,6 +437,7 @@ static void stub_disconnect(struct usb_device *udev) struct stub_device *sdev; const char *udev_busid = dev_name(udev-dev); struct bus_id_priv *busid_priv; + int rc; dev_dbg(udev-dev, Enter\n); @@ -448,6 +462,14 @@ static void stub_disconnect(struct usb_device *udev) */ stub_remove_files(udev-dev); + /* release port */ + rc = usb_hub_release_port(udev-parent, udev-portnum, + (struct dev_state *) udev); + if (rc) { + dev_dbg(udev-dev, unable to release port\n); + return; + } + /* If usb reset is called from event handler */ if (busid_priv-sdev-ud.eh == current) return; diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index 90e18f6..a91dc1f 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c @@ -62,23 +62,6 @@ /* Mutual exclusion for removal, open, and release */ DEFINE_MUTEX(usbfs_mutex); -struct dev_state { - struct list_head list; /* state list */ - struct usb_device *dev; - struct file *file; - spinlock_t lock;/* protects the async urb lists */ - struct list_head async_pending; - struct list_head async_completed; - wait_queue_head_t wait; /* wake up if a request completed */ - unsigned int discsignr; - struct pid *disc_pid; - const struct cred *cred; - void __user *disccontext; - unsigned long ifclaimed; - u32 secid; - u32 disabled_bulk_eps; -}; - struct async { struct list_head asynclist; struct dev_state *ps; diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 64ea219..e484933 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -1819,6 +1819,7 @@ int usb_hub_claim_port(struct usb_device *hdev, unsigned port1, *powner = owner; return rc; } +EXPORT_SYMBOL_GPL(usb_hub_claim_port); int usb_hub_release_port(struct usb_device *hdev, unsigned port1, struct dev_state *owner) @@ -1834,6 +1835,7 @@ int usb_hub_release_port(struct usb_device *hdev, unsigned port1, *powner = NULL; return rc; } +EXPORT_SYMBOL_GPL(usb_hub_release_port); void usb_hub_release_all_ports(struct usb_device *hdev, struct dev_state *owner) { diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h index 8238577..79a5e76 100644 --- a/drivers/usb/core/usb.h +++ b/drivers/usb/core/usb.h @@ -1,8 +1,8 @@ #include linux/pm.h #include linux/acpi.h +#include linux/usb.h struct usb_hub_descriptor; -struct dev_state; /* Functions local to drivers/usb/core/ */ @@ -57,10 +57,6 @@ extern int usb_match_device(struct usb_device *dev, extern void usb_forced_unbind_intf(struct usb_interface *intf); extern void usb_rebind_intf(struct usb_interface *intf); -extern int usb_hub_claim_port(struct usb_device *hdev, unsigned port, - struct dev_state *owner); -extern int usb_hub_release_port(struct usb_device *hdev, unsigned port, - struct dev_state *owner); extern void usb_hub_release_all_ports(struct usb_device *hdev, struct dev_state *owner); extern bool usb_device_is_owned(struct usb_device *udev); diff --git a/include/linux/usb.h b/include/linux/usb.h index 22de4af..e0843a4 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -366,6 +366,24 @@ struct usb_bus { #endif }; +struct dev_state { +
Re: [PATCH 2/2] usb: Make DELAY_INIT quirk wait 100ms between Get Configuration requests
What am I supposed to do with this line? :) Oh damn, sorry, forgot to take that out on the second one. We have this really annoying commit hook that adds them automatically. v2 incoming... -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 2/2] usb: Make DELAY_INIT quirk wait 100ms between Get Configuration requests
The DELAY_INIT quirk only reduces the frequency of enumeration failures with the Logitech HD Pro C920 and C930e webcams, but does not quite eliminate them. We have found that adding a delay of 100ms between the first and second Get Configuration request makes the device enumerate perfectly reliable even after several weeks of extensive testing. The reasons for that are anyone's guess, but since the DELAY_INIT quirk already delays enumeration by a whole second, wating for another 10th of that isn't really a big deal for the one other device that uses it, and it will resolve the problems with these webcams. Signed-off-by: Julius Werner jwer...@chromium.org --- drivers/usb/core/config.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c index 8d72f0c..062967c 100644 --- a/drivers/usb/core/config.c +++ b/drivers/usb/core/config.c @@ -717,6 +717,10 @@ int usb_get_configuration(struct usb_device *dev) result = -ENOMEM; goto err; } + + if (dev-quirks USB_QUIRK_DELAY_INIT) + msleep(100); + result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, bigbuffer, length); if (result 0) { -- 1.8.3.2 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] Remove fifo sizes from dwc2 usb driver from socfpga.dtsi
On 03/03/2014 08:42 PM, Felipe Balbi wrote: Hi, On Mon, Mar 03, 2014 at 05:09:27PM -0600, dingu...@altera.com wrote: From: Dinh Nguyen dingu...@altera.com Remove reading the fifo sizes from dts in platform.c Add dwc2_calculate_dynamic_fifo Conflicts: arch/arm/boot/dts/socfpga.dtsi drivers/staging/dwc2/core.c snip diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c index 6d001b5..3acb7ee 100644 --- a/drivers/usb/dwc2/core.c +++ b/drivers/usb/dwc2/core.c @@ -478,6 +478,38 @@ void dwc2_disable_host_interrupts(struct dwc2_hsotg *hsotg) writel(intmsk, hsotg-regs + GINTMSK); } +static void dwc2_calculate_dynamic_fifo(struct dwc2_hsotg *hsotg) +{ + struct dwc2_core_params *params = hsotg-core_params; + struct dwc2_hw_params *hw = hsotg-hw_params; + u32 rxfsiz, nptxfsiz, ptxfsiz, total_fifo_size; + + total_fifo_size = hw-total_fifo_size; + rxfsiz = params-host_rx_fifo_size; + nptxfsiz = params-host_nperio_tx_fifo_size; + ptxfsiz = params-host_perio_tx_fifo_size; + + if (total_fifo_size = (rxfsiz + nptxfsiz + ptxfsiz)) + /* Params are valid, nothing to do */ + return; You really don't need this branch but in any case, if one branch has curly braces, both branches should have it too. Will fix... + else { + /* min rx fifo size = ((largest packet/4)*2)+2 */ + rxfsiz = (((1024/4) + 1 + 1) * 3) + 1; + /* min non-periodic tx fifo depth */ + nptxfsiz = 3 * (1024/4); + /* min periodic tx fifo depth */ + ptxfsiz = ((1024*3)/4) * 3; + } + + if (total_fifo_size (rxfsiz + nptxfsiz + ptxfsiz)) hmm, so in the if condition above you do: if (total_fifo_size = (rxfsiz + nptxfsiz + ptxfsiz)) then you have an else branch following it and the only way for that else branch to be reached is if this other condition is true. I think this code could be rewritten as: if (total_fifo_size (rxfsiz + nptxfsiz + ptxfsiz)) { /* min rx fifo size = ((largest packet / 4) * 2) + 2 */ rxfsiz = (((1024 / 4) + 1 + 1) * 3) + 1; /* min non-periodic tx fifo depth */ nptxfsiz = 3 * (1024 / 4); /* min periodic tx fifo depth */ ptxfsiz = ((1024 * 3) / 4) * 3; } Ok.. will re-write... Also, you could be a bit more verbose on your comments above. One thing I see is that your fifo allocation, apparently, won't work for high-bandwidth ISOC endpoints. Is that correct ? Another thing is that pre-allocating FIFO sizes might not be the best choice. I mean, if you only have two bulk endpoints enabled, you would be better off allocating bigger FIFOs for those endpoints in order to allow for double- or triple-buffering as that would give SW more time to program DMA to read out the data. yes, I am just coding this to the minimum fifo settings. Let me see if the function can be smarter about the fifo allocation. Thanks, Dinh -- To unsubscribe from this list: send the line unsubscribe 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] staging: usbip: userspace: don't throw error when trying to read configuration specific attributes
When a device has just been bound to usbip-host but the client hasn't set a configuration on it, certain attributes will not exist. Don't treat this as an error. Signed-off-by: Valentina Manea valentina.mane...@gmail.com --- drivers/staging/usbip/userspace/libsrc/usbip_common.c | 17 +++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/staging/usbip/userspace/libsrc/usbip_common.c b/drivers/staging/usbip/userspace/libsrc/usbip_common.c index 8d675a9..ac32a36 100644 --- a/drivers/staging/usbip/userspace/libsrc/usbip_common.c +++ b/drivers/staging/usbip/userspace/libsrc/usbip_common.c @@ -127,10 +127,23 @@ int read_attr_value(struct udev_device *dev, const char *name, goto err; } + /* The client chooses the device configuration +* when attaching it so right after being bound +* to usbip-host on the server the device will +* have no configuration. +* Therefore, attributes such as bConfigurationValue +* and bNumInterfaces will not exist and sscanf will +* fail. Check for these cases and don't treat them +* as errors. +*/ + ret = sscanf(attr, format, num); if (ret 1) { - dbg(sscanf failed); - goto err; + if (strcmp(name, bConfigurationValue) + strcmp(name, bNumInterfaces)) { + dbg(sscanf failed); + goto err; + } } err: -- 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
[PATCH] staging: usbip: userspace: add hwdata as optional dependency in README
This is an optional dependency since USB/IP can fully work without it. However, it is needed to display device information such as vendor. Signed-off-by: Valentina Manea valentina.mane...@gmail.com --- drivers/staging/usbip/userspace/README | 4 1 file changed, 4 insertions(+) diff --git a/drivers/staging/usbip/userspace/README b/drivers/staging/usbip/userspace/README index 6ead290..f528ba4 100644 --- a/drivers/staging/usbip/userspace/README +++ b/drivers/staging/usbip/userspace/README @@ -19,6 +19,10 @@ - libtool, automake = 1.9, autoconf = 2.5.0, pkg-config +[Optional] +- hwdata +Contains USB device identification data. + [Install] 0. Generate configuration scripts. -- 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: [PATCH] staging: usbip: claim ports used by shared devices
On Tue, 4 Mar 2014, Valentina Manea wrote: diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index 90e18f6..a91dc1f 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c @@ -62,23 +62,6 @@ /* Mutual exclusion for removal, open, and release */ DEFINE_MUTEX(usbfs_mutex); -struct dev_state { - struct list_head list; /* state list */ - struct usb_device *dev; - struct file *file; - spinlock_t lock;/* protects the async urb lists */ - struct list_head async_pending; - struct list_head async_completed; - wait_queue_head_t wait; /* wake up if a request completed */ - unsigned int discsignr; - struct pid *disc_pid; - const struct cred *cred; - void __user *disccontext; - unsigned long ifclaimed; - u32 secid; - u32 disabled_bulk_eps; -}; - Don't remove this definition. diff --git a/include/linux/usb.h b/include/linux/usb.h index 22de4af..e0843a4 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -366,6 +366,24 @@ struct usb_bus { #endif }; +struct dev_state { + struct list_head list; /* state list */ + struct usb_device *dev; + struct file *file; + spinlock_t lock;/* protects the async urb lists */ + struct list_head async_pending; + struct list_head async_completed; + wait_queue_head_t wait; /* wake up if a request completed */ + unsigned int discsignr; + struct pid *disc_pid; + const struct cred *cred; + void __user *disccontext; + unsigned long ifclaimed; + u32 secid; + u32 disabled_bulk_eps; +}; And don't put this here. Instead, just put struct dev_state; 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 v2] usb: gadget: return the right length in ffs_epfile_io()
On 03/04/2014 10:34 AM, Chuansheng Liu wrote: @@ -845,12 +845,14 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data) * we may end up with more data then user space has * space for. */ - ret = ep-status; - if (io_data-read ret 0 - unlikely(copy_to_user(io_data-buf, data, - min_t(size_t, ret, - io_data-len - ret = -EFAULT; + ret = ep-status; On Tue, Mar 04 2014, Felipe Balbi wrote: Why the indentation jumped suddenly to the right? On Tue, Mar 04, 2014 at 08:01:15PM +0300, Sergei Shtylyov wrote: because it was wrong before ;-) Yep. It looks like Robert's [2e4c7553: add aio support] introduced an if-else-if-else flow but did not indent the code and I didn't caught it when reviewing that patch. -- 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 v2] usb: gadget: return the right length in ffs_epfile_io()
On Tue, Mar 04, 2014 at 08:53:40PM +0100, Michal Nazarewicz wrote: On 03/04/2014 10:34 AM, Chuansheng Liu wrote: @@ -845,12 +845,14 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data) * we may end up with more data then user space has * space for. */ - ret = ep-status; - if (io_data-read ret 0 - unlikely(copy_to_user(io_data-buf, data, - min_t(size_t, ret, - io_data-len - ret = -EFAULT; + ret = ep-status; On Tue, Mar 04 2014, Felipe Balbi wrote: Why the indentation jumped suddenly to the right? On Tue, Mar 04, 2014 at 08:01:15PM +0300, Sergei Shtylyov wrote: because it was wrong before ;-) Yep. It looks like Robert's [2e4c7553: add aio support] introduced an if-else-if-else flow but did not indent the code and I didn't caught it when reviewing that patch. it's in my testing/next now, I also fixed the comment indentation which was also wrong. -- balbi signature.asc Description: Digital signature
Re: [PATCH net-next 07/12] r8152: support rx checksum
From: Hayes Wang hayesw...@realtek.com Date: Tue, 4 Mar 2014 20:00:59 +0800 @@ -1453,11 +1491,19 @@ static void rx_bottom(struct r8152 *tp) pkt_len -= CRC_SIZE; rx_data += sizeof(struct rx_desc); + checksum = r8152_rx_csum(tp, rx_desc); + if (checksum == RTL_CHECKSUM_FAIL) { + stats-rx_errors++; + goto find_next_rx; + } + It is not for the driver to make this policy decision and drop the packet. It is not a device RX error event. In fact you do not know what corrupted the checksum, or even if the device verified it correctly. Anything is possible. You must therefore still pass the packet up into the networking stack using CHECKSUM_NONE, and let the protocols double-check the checksum(s) in software and bump the appropriate statistic counter if the checksum is really bad. This allows allows network taps to see the packet, so that the administrator can analyze the situation. -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: xhci-errors in combination with dm-crypt
Comments below. On Mon, Mar 03, 2014 at 10:55:13PM +0100, Merlin Chlosta wrote: Hello everyone, I'd like to encrypt my external HDD using dm-crypt (luks) via USB 3.0. The crypto-container creation works, but writing to it doesn't: kernel: usb 4-2: reset SuperSpeed USB device number 2 using xhci_hcd kernel: xhci_hcd :00:14.0: xHCI xhci_drop_endpoint called with disabled ep 8800c37e5c80kernel: xhci_hcd :00:14.0: xHCI xhci_drop_endpoint called with disabled ep 8800c37e5cc0kernel: usb 4-2: reset SuperSpeed USB device number 2 using xhci_hcd kernel: xhci_hcd :00:14.0: xHCI xhci_drop_endpoint called with disabled ep 8800c37e5c80kernel: xhci_hcd :00:14.0: xHCI xhci_drop_endpoint called with disabled ep 8800c37e5cc0kernel: usb 4-2: reset SuperSpeed USB device number 2 using xhci_hcd kernel: xhci_hcd :00:14.0: xHCI xhci_drop_endpoint called with disabled ep 8800c37e5c80kernel: xhci_hcd :00:14.0: xHCI xhci_drop_endpoint called with disabled ep 8800c37e5cc0kernel: usb 4-2: reset SuperSpeed USB device number 2 using xhci_hcd kernel: xhci_hcd :00:14.0: xHCI xhci_drop_endpoint called with disabled ep 8800c37e5c80kernel: xhci_hcd :00:14.0: xHCI xhci_drop_endpoint called with disabled ep 8800c37e5cc0kernel: xhci_hcd :00:14.0: Timeout while waiting for address device command kernel: xhci_hcd :00:14.0: Timeout while waiting for address device command kernel: usb 4-2: device not accepting address 2, error -62 kernel: usb 4-2: USB disconnect, device number 2 kernel: scsi 12:0:0:0: rejecting I/O to offline device kernel: scsi 12:0:0:0: [sdc] killing request kernel: scsi 12:0:0:0: [sdc] Unhandled error code kernel: scsi 12:0:0:0: [sdc] kernel: Result: hostbyte=0x01 driverbyte=0x00 kernel: scsi 12:0:0:0: [sdc] CDB: kernel: cdb[0]=0x2a: 2a 00 00 00 10 41 00 00 12 00 kernel: end_request: I/O error, dev sdc, sector 4161 kernel: quiet_error: 1601 callbacks suppressed kernel: Buffer I/O error on device dm-5, logical block 2 kernel: lost page write due to I/O error on dm-5 kernel: Buffer I/O error on device dm-5, logical block 3 kernel: lost page write due to I/O error on dm-5 kernel: Buffer I/O error on device dm-5, logical block 4 kernel: lost page write due to I/O error on dm-5 kernel: Buffer I/O error on device dm-5, logical block 5 kernel: lost page write due to I/O error on dm-5 kernel: Buffer I/O error on device dm-5, logical block 6 kernel: lost page write due to I/O error on dm-5 kernel: Buffer I/O error on device dm-5, logical block 7 kernel: lost page write due to I/O error on dm-5 kernel: Buffer I/O error on device dm-5, logical block 8 kernel: lost page write due to I/O error on dm-5 kernel: Buffer I/O error on device dm-5, logical block 9 kernel: lost page write due to I/O error on dm-5 kernel: Buffer I/O error on device dm-5, logical block 10 kernel: lost page write due to I/O error on dm-5 kernel: Buffer I/O error on device dm-5, logical block 11 kernel: lost page write due to I/O error on dm-5 kernel: scsi 12:0:0:0: rejecting I/O to offline device kernel: scsi 12:0:0:0: [sdc] killing request kernel: scsi 12:0:0:0: [sdc] Unhandled error code kernel: scsi 12:0:0:0: [sdc] kernel: Result: hostbyte=0x01 driverbyte=0x00 kernel: scsi 12:0:0:0: [sdc] CDB: kernel: cdb[0]=0x2a: 2a 00 00 00 10 53 00 00 18 00 kernel: end_request: I/O error, dev sdc, sector 4179 kernel: xhci_hcd :00:14.0: xHCI xhci_drop_endpoint called with disabled ep 8800c37e5c80 kernel: xhci_hcd :00:14.0: xHCI xhci_drop_endpoint called with disabled ep 8800c37e5cc0 USB 2.0 (ehci-pci) works fine (direct, filesystem, crypto). With USB 3.0, both direct access using 'dd' and filesystem access is possible. Only direct access to the cryptdevice fails (including 'mkfs.ext4'). If I create a filesystem on the crypto device via USB 2.0, I can access it via USB 3.0 as well. % uname -r 3.13.5-1 (also tested on 3.14rc4) In a separate mail, you said 3.10.30-1-lts also works. We do have one known regression for USB mass storage. If you compile your own kernel, please retest with 3.14-rc4 with these two commits reverted: 3804fad45411b48233b48003e33a78f290d227c8 USBNET: ax88179_178a: enable tso if usb host supports sg dma 247bf557273dd775505fb9240d2d152f4f20d304 xhci 1.0: Limit arbitrarily-aligned scatter gather. Please let me know if reverting those two commits worked. If not, we'll dig deeper into exactly why your mass storage device is failing. Sarah Sharp % lspci -nn | grep USB 00:14.0 USB controller [0c03]: Intel Corporation 7 Series/C210 Series Chipset Family USB xHCI Host Controller [8086:1e31] (rev 04) 00:1a.0 USB controller [0c03]: Intel Corporation 7 Series/C210 Series Chipset Family USB Enhanced Host Controller #2 [8086:1e2d] (rev 04) 00:1d.0 USB controller [0c03]: Intel Corporation 7 Series/C210 Series