On Sat, 24 May 2014, Pratyush Anand wrote: > OTG3 and EH Compliance Plan 1.0 talks about Super Speed OTG Verification > system (SS-OVS) which consists of an excersizer and analyzer. > > USB Compliance Suite from Lecroy or Ellisys can act as such SS-OVS for > Link Layer Validation (LVS). > > Some modifications are needed for an embedded Linux USB host to pass all > these tests. Most of these tests require just Link to be in U0. They do > not work with default Linux USB stack since, default stack does port > reset and then starts sending setup packet, which is not expected by > Link Layer Validation (LVS) device of Lecroy Compliance Suit. Then, > There are many Link Layer Tests which need host to generate specific > traffic. > > This patch supports specific traffic generation cases. As of now all the > host Lecroy Link Layer-USBIF tests (except TD7.26) passes > with this patch for single run using Lecroy USB Compliance Suite > Version 1.98 Build 239 and Lecroy USB Protocol Analyzer version 4.80 > Build 1603. Therefore patch seems to be a good candidate for inclusion. > Further modification can be done on top of it. Acked-by: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> There are a couple of things you should be aware of... > +static void lvs_rh_work(struct work_struct *work) > +{ > + struct lvs_rh *lvs = container_of(work, struct lvs_rh, rh_work); > + struct usb_interface *intf = lvs->intf; > + struct usb_device *hdev = interface_to_usbdev(intf); > + struct usb_hcd *hcd = bus_to_hcd(hdev->bus); > + struct usb_hub_descriptor *descriptor = &lvs->descriptor; > + struct usb_port_status *port_status; > + int i, ret = 0; > + > + port_status = kmalloc(sizeof(*port_status), GFP_KERNEL); > + if (!port_status) { > + dev_err(&intf->dev, "failed to allocate port_status memory\n"); > + return; > + } If you allocated the port_status buffer just once and stored a pointer to it in the lvs_rh structure then you wouldn't need to allocate a buffer each time this routine runs. > + /* Examine each root port */ > + for (i = 1; i <= descriptor->bNbrPorts; i++) { > + ret = usb_control_msg(hdev, usb_rcvctrlpipe(hdev, 0), > + USB_REQ_GET_STATUS, USB_DIR_IN | USB_RT_PORT, 0, i, > + port_status, sizeof(*port_status), 1000); > + if (ret < 4) > + continue; > + /* handle only connection change notification */ > + if (!(port_status->wPortChange & USB_PORT_STAT_C_CONNECTION)) > + continue; There will be other bits set in the wPortChange word from time to time, such as USB_PORT_STAT_C_RESET and maybe USB_PORT_STAT_C_ENABLE. By not ever clearing them, you will cause this routine to be polled 4 times per second instead of only when there's a connect change. This isn't terribly important but you should realize what you are doing. Alan Stern -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html