Received: by 10.223.164.202 with SMTP id h10csp885214wrb; Tue, 7 Nov 2017 16:53:41 -0800 (PST) X-Google-Smtp-Source: ABhQp+QKewaNs8/7co6BR0SFDXP6oH+OmKEw5KGr6VCTbn0dhGQmAtF81UIFeMg4dbFbm1z80+mS X-Received: by 10.84.192.131 with SMTP id c3mr491430pld.435.1510102421230; Tue, 07 Nov 2017 16:53:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510102421; cv=none; d=google.com; s=arc-20160816; b=C/JxvX4Vw6X146SmCjSvpzlQyVC9wnq02IvU7aLXpn+1py13z10li/MIPgbgB/dnDv UX3dBrHy0KdcoITfeJx+WGepaveCS8uSwOAj18cxSsXkJf+QD2iw64WU85gvS+kihlXR 42gIvhWmcADZIvJ2xxWc0vJk7EIVhqnX4gizi41rrFNmfFI1qXwmZCwTIaufBCg3BIFd OdiuOjqjeSs2TsApTHP40qHs4q6s69mT8iwv/MXomNxjx5B8e/WPjqCegRtIG2mIC7R1 ly/q1G6OteRG1/ojHDrtuoDQXM2s1Lhf8FPSJ1p8ml2rwUVLV0BSv5ox6atXy8/RdN2G ZB9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to :subject:cc:to:from:date:arc-authentication-results; bh=Xf4loulEtvBzLIEBtWxk67l1kDeLJ1vMumg4fxzL95I=; b=Ui6I7c6dLQJjDlaQU84H/ggGPJhFyUdQSajUn/NSSgfcUsomKOWy1j4vuUVtZtIK5e YVMVP1u5ug2hXVaiYwI3hJk4F1P8zZJXLXmmTqORoUp4PCRrbWAN0nQ9bjEBTAUppjGi XLIAfhO7zNrkS5iv5RUhmpHQnFXX6mp+Wg9wjWeHhPwpU5d0yfCV82RJQmuSP9jKxpZL h5g9JFTLGf/uqzqBghcd8S1VGRzPihkTFQ5TUkQJeMO2JI0q33iaN+sAwGDB6h4JyJf6 GmvwlVP4AGilW2m8rnL0LD8h1IxBKMcN0f7lagKCrj9YwMdM3w/22UV+dd3pldoX6qBQ B8hQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b6si2200592plx.289.2017.11.07.16.53.28; Tue, 07 Nov 2017 16:53:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965287AbdKGPSo (ORCPT + 92 others); Tue, 7 Nov 2017 10:18:44 -0500 Received: from iolanthe.rowland.org ([192.131.102.54]:60756 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S965264AbdKGPSn (ORCPT ); Tue, 7 Nov 2017 10:18:43 -0500 Received: (qmail 2701 invoked by uid 2102); 7 Nov 2017 10:18:41 -0500 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 7 Nov 2017 10:18:41 -0500 Date: Tue, 7 Nov 2017 10:18:41 -0500 (EST) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: wlf cc: Minas Harutyunyan , William Wu , "John.Youn@synopsys.com" , "balbi@kernel.org" , "gregkh@linuxfoundation.org" , "heiko@sntech.de" , "linux-kernel@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-rockchip@lists.infradead.org" , "frank.wang@rock-chips.com" , "huangtao@rock-chips.com" , "dianders@google.com" , "daniel.meng@rock-chips.com" , "fml@rock-chips.com" Subject: Re: [PATCH] usb: dwc2: host: fix isoc urb actual length In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 7 Nov 2017, wlf wrote: > > That sounds like a good idea. Minas, does the following patch fix your > > problem? > > > > In theory we could do this calculation for every isochronous URB, not > > just those coming from usbfs. But I don't think there's any point, > > since the USB class drivers don't use it. > > > > Alan Stern > > > > > > > > Index: usb-4.x/drivers/usb/core/devio.c > > =================================================================== > > --- usb-4.x.orig/drivers/usb/core/devio.c > > +++ usb-4.x/drivers/usb/core/devio.c > > @@ -1828,6 +1828,18 @@ static int proc_unlinkurb(struct usb_dev > > return 0; > > } > > > > +static void compute_isochronous_actual_length(struct urb *urb) > > +{ > > + unsigned i; > > + > > + if (urb->number_of_packets > 0) { > > + urb->actual_length = 0; > > + for (i = 0; i < urb->number_of_packets; i++) > > + urb->actual_length += > > + urb->iso_frame_desc[i].actual_length; > > + } > > +} > > + > > static int processcompl(struct async *as, void __user * __user *arg) > > { > > struct urb *urb = as->urb; > > @@ -1835,6 +1847,8 @@ static int processcompl(struct async *as > > void __user *addr = as->userurb; > > unsigned int i; > > > > + compute_isochronous_actual_length(urb); > > + > > if (as->userbuffer && urb->actual_length) { > > if (copy_urb_data_to_user(as->userbuffer, urb)) > > goto err_out; > > @@ -2003,6 +2017,8 @@ static int processcompl_compat(struct as > > void __user *addr = as->userurb; > > unsigned int i; > > > > + compute_isochronous_actual_length(urb); > > + > > if (as->userbuffer && urb->actual_length) { > > if (copy_urb_data_to_user(as->userbuffer, urb)) > > return -EFAULT; > > > > > Yeah, it's a good idea to calculate the urb actual length in the devio > driver. > Your patch seems good, and I think we can do a small optimization base > your patch, > like the following patch: > > diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c > index bd94192..a2e7b97 100644 > --- a/drivers/usb/core/devio.c > +++ b/drivers/usb/core/devio.c > @@ -1664,6 +1664,9 @@ static int processcompl(struct async *as, void > __user * __user *arg) > void __user *addr = as->userurb; > unsigned int i; > > + if (usb_endpoint_xfer_isoc(&urb->ep->desc)) > + compute_isochronous_actual_length(urb); > + > if (as->userbuffer && urb->actual_length) { > if (copy_urb_data_to_user(as->userbuffer, urb)) > goto err_out; > @@ -1833,6 +1836,9 @@ static int processcompl_compat(struct async *as, > void __user * __user *arg) > void __user *addr = as->userurb; > unsigned int i; > > + if (usb_endpoint_xfer_isoc(&urb->ep->desc)) > + compute_isochronous_actual_length(urb); > + Well, this depends on whether you want to optimize for space or for speed. I've been going for space. And since usbfs is inherently rather slow, I don't think this will make any significant speed difference. So I don't think adding the extra tests is worthwhile. (Besides, if you really wanted to do it this way, you should have moved the test for "urb->number_of_packets > 0" into the callers instead of adding an additional test of the endpoint type.) However, nobody has answered my original question: Does the patch actually fix the problem? Alan Stern From 1583408774339744876@xxx Tue Nov 07 12:04:40 +0000 2017 X-GM-THRID: 1583305738476220776 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread