Received: by 10.223.164.197 with SMTP id h5csp118926wrb; Sat, 4 Nov 2017 07:06:54 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Q8YD74YNY23cZs3jQUEh99eTxwegGjwxPIYX0OIXNf3MUyunIBVCZ0UpcHnzJioE7/XfN6 X-Received: by 10.99.105.72 with SMTP id e69mr10176139pgc.50.1509804414749; Sat, 04 Nov 2017 07:06:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509804414; cv=none; d=google.com; s=arc-20160816; b=Ii82QhCJsO+wooCwIZBZpoKjnJSiGxtpCsHCe9119EUACROx1hMO7J/itJZEBCjOL7 547MqtryiTsCGHSQX5HFGw041jC/8fiZTs71AeQTj7FiqAZCYigPz9hQo/pAF9jpZZHG UhRAt/NACkv9JS62NeaviPTVPhxHIvdSkkyUaD1EwAVd7ffXmRr1VqCfL3SPemEFjfiB e0V3VpdDVWrwk2kvCtGd990XLTSpl+l/bxocwLJDK0cDlIad2ODO1bJvYbcrcYNhkZMa 02ME/OUDmRcF7S+svhIcE1KopUg+k81x6ILon5Iv6NQpzwPR5pPbr1XC3r58WKPwp1+k hckQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=2k96IqUgrK5HF0oqqLoeMNZsnazjct8Mm5axPTlnYMk=; b=hWCdsAHle5ZODwN2Ve9DwfK86F8weP9BKMIVg3fDE2nHpwcDApxEIHjXHfyTxX8ADL jglRrq3bv/oULsCArkQ1+z1hlz0e2dTiUGDhB4w6t3VuJm3ZkG3vMLIUAObGEzX6+5s3 kDXJvjNE7YvL9hVXQIK8kQZUOTKGVghOtaoz44omMus33kpepURjSRrXA8+iz56/uHoM qTvQy73ZHlZ5BgkdlizKU2O9O59jhX3gN/FOYhVrG3pKL755S7nfBkJKdMdQ3TCAS5GM OaiC2wrrpQmvpZdbqpooCQDNgl9ZScXbIKvxzYPKjjq892p3TiOkps1ON+Ny/P6OYvb8 JsFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=XhIwJ8cx; 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 a28si9031618pfl.216.2017.11.04.07.06.29; Sat, 04 Nov 2017 07:06:54 -0700 (PDT) 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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=XhIwJ8cx; 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 S1756747AbdKDOFi (ORCPT + 93 others); Sat, 4 Nov 2017 10:05:38 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:51969 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756662AbdKDOFf (ORCPT ); Sat, 4 Nov 2017 10:05:35 -0400 Received: by mail-oi0-f65.google.com with SMTP id j126so4104606oib.8; Sat, 04 Nov 2017 07:05:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=2k96IqUgrK5HF0oqqLoeMNZsnazjct8Mm5axPTlnYMk=; b=XhIwJ8cxQXVrg3f/Tw/P9mf59NuIgwMaXcdEw729fMEYl95PjXf63KlgvXbl2DkDzE a4zxgywVKhdcNqrv+aqvLpoqjn0uLOqZzuabQo6IjHPuQbZY5Ye2LyP3cqh5V9LkDxOF FR/B9UASUro+RmEPXKsJzjAec+FiRoKzNPRXHVqD41Jyd1vlnECtKD59H2ufODsOiJ+L mcECQbL0+FacTVX81tJ0lFTnFpvP0vc/u3uemtFJc/l74J+Qa0OEU5atqxxtaa7g1b3W XpXCo8GSX7ZM4fTnp+EYY5dCRnhT0ty8Q5u5hFDce0WUMNFTWNbeMte+bxVoHGSQ0rwQ Bc0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=2k96IqUgrK5HF0oqqLoeMNZsnazjct8Mm5axPTlnYMk=; b=HBwz5Y6Mg8G9IWGq5Gx5KjgCtsZV/nKIOiRsxeJT7xZlhHLXc/vyb5ouPf9+ziTFG+ HMfA1RLr2KXQtG/TS55XtdoqjJUBPHnNy9X9mUah5M4SJBaNoXROda//YKOrHwDhHPS8 Jj0nt2XsP2EZFdUP/vjmzm/yIKWMknoeDoApZPlmSiEBsWUv9KWltEYWJVXKFRPhRhz0 RoV8R/vOvmivFuf+J7U4f25zwH2j16gwUeBr66STZdtg7Eim5m6qX4khTiaeAn82EKt6 jHFzPECmtVmr94L8bN0t/FEvJCzD1YAfL4FVFfBJym/xZNZGeKwUK32ovtTSDKYre3Oa zo+w== X-Gm-Message-State: AMCzsaW5HD3iXnky9Qi8fZFpqmEzq3m8RjBgWU9+9wEtBaWm8ehqJcAo uTS7aZLVWk6/CN/5w11AhNXYxy1VhYuLdXmLT5c= X-Received: by 10.202.192.197 with SMTP id q188mr6214041oif.295.1509804334591; Sat, 04 Nov 2017 07:05:34 -0700 (PDT) MIME-Version: 1.0 Received: by 10.157.46.130 with HTTP; Sat, 4 Nov 2017 07:05:14 -0700 (PDT) In-Reply-To: <20170427102033.5500-1-matwey@sai.msu.ru> References: <20170427102033.5500-1-matwey@sai.msu.ru> From: "Matwey V. Kornilov" Date: Sat, 4 Nov 2017 17:05:14 +0300 X-Google-Sender-Auth: oq8NNc6bKEFg_5b30PRGwIX0AWU Message-ID: Subject: Re: [PATCH] usb: musb: musb_host: Introduce postponed URB giveback To: Bin Liu , Greg KH Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, "Matwey V. Kornilov" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Bin, I've just checked that the issue is still present in 4.13.10. 2017-04-27 13:20 GMT+03:00 Matwey V. Kornilov : > This commit changes the order of actions undertaken in > musb_advance_schedule() in order to overcome issue with broken > isochronous transfer [1]. > > There is no harm to split musb_giveback into two pieces. The first > unlinks finished urb, the second givebacks it. The issue here that > givebacking may be quite time-consuming due to urb->complete() call. > As it happens in case of pwc-driven web cameras. It may take about 0.5 > ms to call __musb_giveback() that calls urb->callback() internally. > Under specific circumstances setting MUSB_RXCSR_H_REQPKT in subsequent > musb_start_urb() for the next urb will be too late to produce physical > IN packet. Since auto req is not used by this module the exchange > would be as the following: > > [ ] 7.220456 d= 0.000997 [182 + 3.667] [ 3] IN : 4.5 > [ T ] 7.220459 d= 0.000003 [182 + 7.000] [800] DATA0: [skipped] > [ ] 7.222456 d= 0.001997 [184 + 3.667] [ 3] IN : 4.5 > [ ] 7.222459 d= 0.000003 [184 + 7.000] [ 3] DATA0: 00 00 > > It is known that missed IN in isochronous mode makes some > perepherial broken. For instance, pwc-driven or uvc-driven > web cameras. > In order to workaround this issue we postpone calling > urb->callback() after setting MUSB_RXCSR_H_REQPKT for the > next urb if there is the next urb pending in queue. > > [1] https://www.spinics.net/lists/linux-usb/msg145747.html > > Fixes: f551e1352983 ("Revert "usb: musb: musb_host: Enable HCD_BH flag to handle urb return in bottom half"") > Signed-off-by: Matwey V. Kornilov > --- > drivers/usb/musb/musb_host.c | 54 +++++++++++++++++++++++++++++++++++++------- > 1 file changed, 46 insertions(+), 8 deletions(-) > > diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c > index ac3a4952abb4..b590c2555dab 100644 > --- a/drivers/usb/musb/musb_host.c > +++ b/drivers/usb/musb/musb_host.c > @@ -299,19 +299,24 @@ musb_start_urb(struct musb *musb, int is_in, struct musb_qh *qh) > } > } > > -/* Context: caller owns controller lock, IRQs are blocked */ > -static void musb_giveback(struct musb *musb, struct urb *urb, int status) > +static void __musb_giveback(struct musb *musb, struct urb *urb, int status) > __releases(musb->lock) > __acquires(musb->lock) > { > - trace_musb_urb_gb(musb, urb); > - > - usb_hcd_unlink_urb_from_ep(musb->hcd, urb); > spin_unlock(&musb->lock); > usb_hcd_giveback_urb(musb->hcd, urb, status); > spin_lock(&musb->lock); > } > > +/* Context: caller owns controller lock, IRQs are blocked */ > +static void musb_giveback(struct musb *musb, struct urb *urb, int status) > +{ > + trace_musb_urb_gb(musb, urb); > + > + usb_hcd_unlink_urb_from_ep(musb->hcd, urb); > + __musb_giveback(musb, urb, status); > +} > + > /* For bulk/interrupt endpoints only */ > static inline void musb_save_toggle(struct musb_qh *qh, int is_in, > struct urb *urb) > @@ -346,6 +351,7 @@ static void musb_advance_schedule(struct musb *musb, struct urb *urb, > struct musb_hw_ep *ep = qh->hw_ep; > int ready = qh->is_ready; > int status; > + int postponed_giveback = 0; > > status = (urb->status == -EINPROGRESS) ? 0 : urb->status; > > @@ -361,9 +367,35 @@ static void musb_advance_schedule(struct musb *musb, struct urb *urb, > break; > } > > - qh->is_ready = 0; > - musb_giveback(musb, urb, status); > - qh->is_ready = ready; > + usb_hcd_unlink_urb_from_ep(musb->hcd, urb); > + > + /* It may take about 0.5 ms to call __musb_giveback() that > + * calls urb->callback() internally. Under specific circumstances > + * setting MUSB_RXCSR_H_REQPKT in subsequent musb_start_urb() for the > + * next urb will be too late to produce physical IN packet. Since > + * auto req is not used by this module the exchange would be as the > + * following: > + * > + * [ ] 7.220456 d= 0.000997 [182 + 3.667] [ 3] IN : 4.5 > + * [ T ] 7.220459 d= 0.000003 [182 + 7.000] [800] DATA0: [skipped] > + * [ ] 7.222456 d= 0.001997 [184 + 3.667] [ 3] IN : 4.5 > + * [ ] 7.222459 d= 0.000003 [184 + 7.000] [ 3] DATA0: 00 00 > + * > + * It is known that missed IN in isochronous mode makes some > + * perepherial broken. For instance, pwc-driven or uvc-driven > + * web cameras. > + * In order to workaround this issue we postpone calling > + * urb->callback() after setting MUSB_RXCSR_H_REQPKT for the > + * next urb if there is the next urb pending in queue. > + */ > + if (is_in && qh->type == USB_ENDPOINT_XFER_ISOC > + && !list_empty(&qh->hep->urb_list)) { > + postponed_giveback = 1; > + } else { > + qh->is_ready = 0; > + __musb_giveback(musb, urb, status); > + qh->is_ready = ready; > + } > > /* reclaim resources (and bandwidth) ASAP; deschedule it, and > * invalidate qh as soon as list_empty(&hep->urb_list) > @@ -428,6 +460,12 @@ static void musb_advance_schedule(struct musb *musb, struct urb *urb, > hw_ep->epnum, is_in ? 'R' : 'T', next_urb(qh)); > musb_start_urb(musb, is_in, qh); > } > + > + if (postponed_giveback) { > + qh->is_ready = 0; > + __musb_giveback(musb, urb, status); > + qh->is_ready = ready; > + } > } > > static u16 musb_h_flush_rxfifo(struct musb_hw_ep *hw_ep, u16 csr) > -- > 2.12.0 > -- With best regards, Matwey V. Kornilov. Sternberg Astronomical Institute, Lomonosov Moscow State University, Russia 119234, Moscow, Universitetsky pr-k 13, +7 (495) 9392382 From 1584268667058033944@xxx Thu Nov 16 23:52:18 +0000 2017 X-GM-THRID: 1584263785940925114 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread