Received: by 10.223.164.202 with SMTP id h10csp1037033wrb; Tue, 7 Nov 2017 20:21:43 -0800 (PST) X-Google-Smtp-Source: ABhQp+SYQMjGkXjjDpFZZzgVjoYYzsPGehSZ/rm3l7ArUaGVjyLbtynlUCYrJSwiwJTkRIdRtqcH X-Received: by 10.101.73.136 with SMTP id r8mr990790pgs.411.1510114903177; Tue, 07 Nov 2017 20:21:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510114903; cv=none; d=google.com; s=arc-20160816; b=XN8isYzJC4l57q9+JedWAK5dzk+Dn/ZIIKPAu40qVJ2C6cOUwyIM2iTqSTvvR0y5Ip U39C4MdiBFzNTMhVJChXOn9pLm3+QjaWY+3JUSOV9MgRt6t8DUvsRQBeQqXsmZNE3Yv2 udTPBdUzpj9KEMO/q6ByK99UVtM7MTEmBzD746M3FATOAskL7DWcrJrMwFzQWy2x6F0o PR6bbByzLyTPM3oViB2T9xs+ZN3W7BoPDUJx/krsixpwwu/iapjFSObu5R1w70D+cDCu VWJmIgFw3A9AJ0B0/5qPDoTdyROBeWTUoHmhuaBIjZt9Ye484Y1ftuZzeW17OltPYhrO QbBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=Wx5ktdOcev/r9H6+fxehXf1j5OpIKO6THBIFDJxeHGY=; b=nVSoBJNSP6q++YaCkZxtmdXEnOqGaPJfa/qDgdssADY0PSRMxnX3owPF6V38dAlKy1 KSA/euU0qqc2felw179FJWlMkd2jm68y/XGlHNX7erBKamX03Oo8UoanUhH+QjVQyqQq LkFKML2kiJoKHCGlpve4kxIMD4Fpm4kChEV10uAntLbpdaDL0aExqQ6Vomm6TGBcb8CN iaypDS5G+P2mrQDoQiUnEaED0PS6aRhQFUolrshbQAcMp/28l5W7y2gQKzoD5vJFrfo9 0DPc09B/iNTkbaY+53rxRouKgscUzttOHgJ19YKFfMrIWIdmVcEI5u5GZ+FEkXqsiEbG vd7g== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e9si2667247pga.447.2017.11.07.20.21.30; Tue, 07 Nov 2017 20:21:43 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753064AbdKHC6b (ORCPT + 90 others); Tue, 7 Nov 2017 21:58:31 -0500 Received: from regular1.263xmail.com ([211.150.99.133]:58685 "EHLO regular1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752375AbdKHC63 (ORCPT ); Tue, 7 Nov 2017 21:58:29 -0500 Received: from wulf?rock-chips.com (unknown [192.168.167.174]) by regular1.263xmail.com (Postfix) with ESMTP id 199B19099; Wed, 8 Nov 2017 10:58:13 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from [172.16.12.36] (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id F29FE3A7; Wed, 8 Nov 2017 10:58:08 +0800 (CST) X-RL-SENDER: wulf@rock-chips.com X-FST-TO: fml@rock-chips.com X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: wulf@rock-chips.com X-UNIQUE-TAG: X-ATTACHMENT-NUM: 0 X-SENDER: wulf@rock-chips.com X-DNS-TYPE: 0 Received: from [172.16.12.36] (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 5877680RHK; Wed, 08 Nov 2017 10:58:11 +0800 (CST) Subject: Re: [PATCH] usb: dwc2: host: fix isoc urb actual length To: Alan Stern 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" References: From: wlf Message-ID: <8eeae89c-70a2-3c64-66dc-4053f2012e1a@rock-chips.com> Date: Wed, 8 Nov 2017 10:58:08 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Alan, 在 2017年11月07日 23:18, Alan Stern 写道: > 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.) Yes, agree with you. > > However, nobody has answered my original question: Does the patch > actually fix the problem? I test your patch on Rockchip RK3188 platform, use UsbWebCamera APP by Serenegiant (libusb + devio) with usb camera, it work well. > > Alan Stern > > > > -- 吴良峰 William.Wu 福建省福州市铜盘路软件大道89号软件园A区21号楼 No.21 Building, A District, No.89,software Boulevard Fuzhou,Fujian, PRC 手机: 13685012275 座机: 0591-83991906-8520 邮件:wulf@rock-chips.com From 1583457156293057138@xxx Wed Nov 08 00:53:41 +0000 2017 X-GM-THRID: 1583305738476220776 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread