Received: by 10.223.164.202 with SMTP id h10csp160328wrb; Mon, 6 Nov 2017 04:31:27 -0800 (PST) X-Google-Smtp-Source: ABhQp+SlWCk8ex0N/NJceFneYNT4fUGmC+NxcDTABQuhWW5bCayoQGwquPZ+NZo6d0D6rzcVp4eA X-Received: by 10.84.209.164 with SMTP id y33mr14598196plh.439.1509971487703; Mon, 06 Nov 2017 04:31:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1509971487; cv=none; d=google.com; s=arc-20160816; b=Bu4h5x19EcwBDSupmR/Icgsaet660jsacdvgq6EHRREEutFIkqCcWr0QWMuD4crN76 0Xtq1+debbqcpp3BbKn3135jijp6JgiC83seQrOtpHc6GAOO/jr3hrgYIJ9tU3o1Z1E1 wHJmIz6VpIGRTaUa9wlKjRJAbPwtt//AViKn/sBNwU0yk294jcGmlDkeLRrdJ7vx+M5a jWT5RKAw/aqm9uzd0D8jdgFBsNiS5BMSa0cxBWqCSHwxDPwEp5z6xdcSd7aEftxh9vwf PqUPwVqd76qK4ByQojRcEZ6eeWRQhDgevFSdLd6pJ5AOkMUIT6qICxtH3+MREBk/wZGe RoFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:references:message-id:date :thread-index:thread-topic:subject:cc:to:from :arc-authentication-results; bh=FVCjPBUCx3tG21uB2Dkhvyu3dhZB366G2ZwzOUjWC1U=; b=vkYK4tPHLHyIY2I9wCTfFxzqwK2jgvU3qiQ+riDSpt4gnL8bmzbdUewIuB2VJLRcrv ULh3MjXSRWDtvOf29InrdFfv2h2VFFM/COWQxIilp8gbucsZxdf4gAMOnoemL/ArQzaB 2dtit/ja9RpEP20V/4mE4I1dUIg7uZ9RP99T4gkKfFCvbuG4JYGFo2eUPofmHU2QMkw3 lUPfuI+il4qC77G6OunwGzWvZc1GjxP/52owqIxb+R4aFG+lgACj/+Vrl/HoJAUlqTPI LwFUuCeAwUODQ2MB6kcuWvhdm8dO4J8RHFVBWeHAFZIUP/J5FNpdKmc+ZhmRzwc0nyvQ LBog== 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=synopsys.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 97si10201444plc.372.2017.11.06.04.31.13; Mon, 06 Nov 2017 04:31:27 -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=synopsys.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752709AbdKFMac convert rfc822-to-8bit (ORCPT + 99 others); Mon, 6 Nov 2017 07:30:32 -0500 Received: from us01smtprelay-2.synopsys.com ([198.182.60.111]:47074 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751717AbdKFMaa (ORCPT ); Mon, 6 Nov 2017 07:30:30 -0500 Received: from mailhost.synopsys.com (mailhost3.synopsys.com [10.12.238.238]) by smtprelay.synopsys.com (Postfix) with ESMTP id A427310C1405; Mon, 6 Nov 2017 04:30:29 -0800 (PST) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id 79CC85A3; Mon, 6 Nov 2017 04:30:29 -0800 (PST) Received: from US01WXQAHTC1.internal.synopsys.com (us01wxqahtc1.internal.synopsys.com [10.12.238.230]) by mailhost.synopsys.com (Postfix) with ESMTP id 8DE07594; Mon, 6 Nov 2017 04:30:28 -0800 (PST) Received: from AM04WEHTCA.internal.synopsys.com (10.116.16.190) by US01WXQAHTC1.internal.synopsys.com (10.12.238.230) with Microsoft SMTP Server (TLS) id 14.3.266.1; Mon, 6 Nov 2017 04:30:28 -0800 Received: from AM04WEMBXA.internal.synopsys.com ([fe80::79c3:55f2:1f20:5bf4]) by am04wehtca.internal.synopsys.com ([::1]) with mapi id 14.03.0266.001; Mon, 6 Nov 2017 16:30:25 +0400 From: Minas Harutyunyan To: wlf , 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" Subject: Re: [PATCH] usb: dwc2: host: fix isoc urb actual length Thread-Topic: [PATCH] usb: dwc2: host: fix isoc urb actual length Thread-Index: AQHTVtu+Eo3Q7iuGGUWWpNtXqQP+xQ== Date: Mon, 6 Nov 2017 12:30:24 +0000 Message-ID: <410670D7E743164D87FA6160E7907A560113A3A07F@am04wembxa.internal.synopsys.com> References: <1509957939-31786-1-git-send-email-william.wu@rock-chips.com> <410670D7E743164D87FA6160E7907A560113A39F61@am04wembxa.internal.synopsys.com> <392af079-7805-a22e-d332-cd7615adf6ba@rock-chips.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.116.70.92] Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi William, On 11/6/2017 2:08 PM, wlf wrote: > 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://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_raspberrypi_linux_issues_903&d=DwIDaQ&c=DPL6_X_6JkXFx7AXWqB0tg&r=6z9Al9FrHR_ZqbbtSAsD16pvOL2S3XHxQnSzq8kusyI&m=v5ECJPMqgVerj8G74QqsTJ7jt-qDVbCVIq8jq_t245s&s=ArX8DL6fZL4p3dsOY5AstGDRguIB_c1GDuuhf49-ev8&e= > > 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. Agree, should be no any side-effect. > >> >> Thanks, >> Minas >> >> >> >> >> >> > From 1583311002216741401@xxx Mon Nov 06 10:10:37 +0000 2017 X-GM-THRID: 1583305738476220776 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread