Received: by 10.223.164.202 with SMTP id h10csp42949wrb; Mon, 6 Nov 2017 02:10:38 -0800 (PST) X-Google-Smtp-Source: ABhQp+TKxxzP5Kl7gxh+0js38T1UoievwYYcfuzFgyIvRmgDNqAv9MVp40tuCMJC0Ab0vE7yUh1g X-Received: by 10.98.72.18 with SMTP id v18mr15991489pfa.232.1509963038138; Mon, 06 Nov 2017 02:10:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1509963038; cv=none; d=google.com; s=arc-20160816; b=EoCtLoghTivjh0Qdnv1LdhIvlbdQebtNWO6WJQ5dV5yGBap/khdCOFIbY/ZePcFiLg rooHePFOT4+h8qTbn+CjOwTn0LkML3bEUSHCrdv5z7yvZBY42jSv4bsnD1Gi/qbo65NP 1AF6s0dVaktjIMfQRdJL83/yPJWqf8kP/2A88kIYBBlexUIQ8aUUIIOpvtuy6ka8q22a F5eMbDz0YHRVTcralyFUetOkzVKVR5IakoD8oWJl3fghHJnl2nTJt2m88qARRjNTuYP4 sou1P1d3kmbdO2FIWs+wl15BddDoGSeqXrDc5iHyIoV/V1aFmDudVcEEEPmDnBHlDciy RCTg== 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=pypx4X5i6eSz7PSyvBFsBr3X3Oy5C1YU9imdinBe8/E=; b=AtQqkhkHFQ/B8elNFDWBTPkHjeEL5dqY/mYomoJyRXIz4Twvd8qyduaADBme/73mUP GwIYvgfO0tLTxt7YWPrdzmRNeSugJn+5pA0I0vsdlOIaZ7QuJE4NBdJvIWJMxUPu0X+W o8ndKKpXqEHgE/Y3AqVB7WFnwdHtvkv1iFfG9m35Z/rVBrL6Q7ikhzW9noxxvbeU3rFy 2e+WhJW1vK08dkcQRoVtpZ0YIealbDJrEl+E8NuEJZHJU+BrdB71rrf4mLo/srPo5JcZ ym3/a/CWX7HSvuQ532e+bPd21cAJQF/fICwDkHX5Qr4H5mBG0hUHjGAQ0bB3xN9cA+75 v/CQ== 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 r2si10246659plj.70.2017.11.06.02.10.24; Mon, 06 Nov 2017 02:10:38 -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 S1753185AbdKFKIm (ORCPT + 99 others); Mon, 6 Nov 2017 05:08:42 -0500 Received: from regular1.263xmail.com ([211.150.99.138]:33530 "EHLO regular1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752005AbdKFKIj (ORCPT ); Mon, 6 Nov 2017 05:08:39 -0500 Received: from wulf?rock-chips.com (unknown [192.168.165.103]) by regular1.263xmail.com (Postfix) with ESMTP id 9DA97795A; Mon, 6 Nov 2017 18:08:28 +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 [192.168.60.27] (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id 4F53C41F; Mon, 6 Nov 2017 18:08:25 +0800 (CST) X-RL-SENDER: wulf@rock-chips.com X-FST-TO: fml@rock-chips.com X-SENDER-IP: 103.29.142.67 X-LOGIN-NAME: wulf@rock-chips.com X-UNIQUE-TAG: <06105b4a54ecf46ed86a967c80432b4e> X-ATTACHMENT-NUM: 0 X-SENDER: wulf@rock-chips.com X-DNS-TYPE: 0 Received: from [192.168.60.27] (unknown [103.29.142.67]) by smtp.263.net (Postfix) whith ESMTP id 12538TZVATV; Mon, 06 Nov 2017 18:08:28 +0800 (CST) Subject: Re: [PATCH] usb: dwc2: host: fix isoc urb actual length To: Minas Harutyunyan , William Wu , "John.Youn@synopsys.com" , "balbi@kernel.org" , "gregkh@linuxfoundation.org" Cc: "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: <1509957939-31786-1-git-send-email-william.wu@rock-chips.com> <410670D7E743164D87FA6160E7907A560113A39F61@am04wembxa.internal.synopsys.com> From: wlf Message-ID: <392af079-7805-a22e-d332-cd7615adf6ba@rock-chips.com> Date: Mon, 6 Nov 2017 18:08:05 +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: <410670D7E743164D87FA6160E7907A560113A39F61@am04wembxa.internal.synopsys.com> 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 Minas, 在 2017年11月06日 17:28, Minas Harutyunyan 写道: > Hi, > > On 11/6/2017 12:46 PM, William Wu wrote: >> The actual_length in dwc2_hcd_urb structure is used >> to indicate the total data length transferred so far, >> but in dwc2_update_isoc_urb_state(), it just updates >> the actual_length of isoc frame, and don't update the >> urb actual_length at the same time, this will cause >> device drivers working error which depend on the urb >> actual_length. >> >> we can easily find this issue if use an USB camera, >> the userspace use libusb to get USB data from kernel >> via devio driver.In usb devio driver, processcompl() >> function will process urb complete and copy data to >> userspace depending on urb actual_length. >> >> Let's update the urb actual_length if the isoc frame >> is valid. >> >> Signed-off-by: William Wu >> --- >> drivers/usb/dwc2/hcd_intr.c | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/drivers/usb/dwc2/hcd_intr.c b/drivers/usb/dwc2/hcd_intr.c >> index 28a8210..01b1e13 100644 >> --- a/drivers/usb/dwc2/hcd_intr.c >> +++ b/drivers/usb/dwc2/hcd_intr.c >> @@ -580,6 +580,7 @@ static enum dwc2_halt_status dwc2_update_isoc_urb_state( >> frame_desc->status = 0; >> frame_desc->actual_length = dwc2_get_actual_xfer_length(hsotg, >> chan, chnum, qtd, halt_status, NULL); >> + urb->actual_length += frame_desc->actual_length; >> break; >> case DWC2_HC_XFER_FRAME_OVERRUN: >> urb->error_count++; >> @@ -599,6 +600,7 @@ static enum dwc2_halt_status dwc2_update_isoc_urb_state( >> frame_desc->status = -EPROTO; >> frame_desc->actual_length = dwc2_get_actual_xfer_length(hsotg, >> chan, chnum, qtd, halt_status, NULL); >> + urb->actual_length += frame_desc->actual_length; >> >> /* Skip whole frame */ >> if (chan->qh->do_split && >> > According urb description in usb.h urb->actual_length used for non-iso > transfers: > > "@actual_length: This is read in non-iso completion functions, and ... > > * ISO transfer status is reported in the status and actual_length fields > * of the iso_frame_desc array, ...." Yes, urb->actual_length is used for non-iso transfers. And for ISO transfer, the most usb class drivers can only use iso frame status and actual_length to handle usb data, like: kernel v4.4 drivers/media/usb/uvc/uvc_video.c But the usb devio driver really need the urb actual_length in the processcompl() if handle ISO transfer, just as I mentioned in the commit message. And I also found the same issue on raspberrypi board: https://github.com/raspberrypi/linux/issues/903 So do you think we need to fix the usb devio driver, rather than fix dwc2? I think maybe we can use urb actual length for ISO transfer, it seems that don't cause any side-effect. > > Thanks, > Minas > > > > > > -- 吴良峰 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 1583308607750655945@xxx Mon Nov 06 09:32:34 +0000 2017 X-GM-THRID: 1583305738476220776 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread