Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp808198imu; Fri, 7 Dec 2018 09:11:55 -0800 (PST) X-Google-Smtp-Source: AFSGD/UGD5j7Y+KmPG3Iw3yAZYL+scWONdmS2Ye5dBI8w5xInsQXT9vEB9oMCWTT+/yyDS3NISaE X-Received: by 2002:a63:e445:: with SMTP id i5mr2643175pgk.307.1544202715149; Fri, 07 Dec 2018 09:11:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544202715; cv=none; d=google.com; s=arc-20160816; b=mmMfV/R5U2tDqHSJEOxmRJkgwJHnenD+lAIjcNSAM15Pboo5A5G2gDiBWxJWReS1Tb GknFtdgul2h3KJFUrHrPRL0x4O/8SFsLIpxNM6JepGAsGbi1UejABPMYlo/fJABGdZjm mV/nAbNVD6j6SOHFB9FBKPxtbxvRBowCsxN27N6ukpcCQdGHLjPK7PC697UV4yJWOZRb 2NIveVSuNe3rKT3FUbLGWQz+oM6Ghkr8mz5eGMsA3sK9UG5Zg0qIjNJ4o+7CFZGqr8G2 uYriy88ufagtghRawlIQMW4OmyUZ5ci2tvwo9b+nSirmB1rXeL+LNAnaAjJDE/BAKHae 3Q4g== 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; bh=yC/kvuOd/Ub87t12678xKXpfvKgc7F3gFx9Byh0n/Gg=; b=h3KPU9EFZzxBfe8AgK0FWe82TYcPJ443IrYDQYSLJ6O+fzlHwIXdA88l1K0QzlxaLE BDSvuT9JGGipYRSTgy1nRueNXCYhhj96mF8SFwmjnezACT/nqWcu6sFpkWaLDgepdTsb /Y4aktBoIgrSHYwCFjOcP0yxPoX9KTNfnxuZ67tDguSL4a/yhjIBYgISNY0nLGfpqXQL bYaACXYe9oP5hKyTJ8bHZW0FXi4FLrNJYHEAb3fDWOur0n1PH3mRCp4GORUgb2uvKIkj HhBHCYglY+OY7gNkURSdNYjX4bUeww1VJdp1fmeC/uAWUgtmtDSKibjr+MihMZo6g+Oc vQHw== 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 v32si3426450plb.369.2018.12.07.09.11.39; Fri, 07 Dec 2018 09:11:55 -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 S1726132AbeLGRJe (ORCPT + 99 others); Fri, 7 Dec 2018 12:09:34 -0500 Received: from iolanthe.rowland.org ([192.131.102.54]:59446 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1726045AbeLGRJd (ORCPT ); Fri, 7 Dec 2018 12:09:33 -0500 Received: (qmail 2366 invoked by uid 2102); 7 Dec 2018 12:09:32 -0500 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 7 Dec 2018 12:09:32 -0500 Date: Fri, 7 Dec 2018 12:09:32 -0500 (EST) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Felipe Balbi cc: Anurag Kumar Vulisha , Greg Kroah-Hartman , Shuah Khan , Johan Hovold , Jaejoong Kim , Benjamin Herrenschmidt , Roger Quadros , Manu Gautam , "martin.petersen@oracle.com" , Bart Van Assche , Mike Christie , Matthew Wilcox , Colin Ian King , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "v.anuragkumar@gmail.com" , Thinh Nguyen , Tejas Joglekar , Ajay Yugalkishore Pandey Subject: RE: [PATCH v7 01/10] usb: gadget: udc: Add timer support for usb requests In-Reply-To: <877eglx45o.fsf@linux.intel.com> 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 Fri, 7 Dec 2018, Felipe Balbi wrote: > > hi, > > Anurag Kumar Vulisha writes: > >>Does the data book suggest a value for the timeout? > >> > > > > No, the databook doesn't mention about the timeout value > > > >>> >At this point, it seems that the generic approach will be messier than having every > >>> >controller driver implement its own fix. At least, that's how it appears to me. > > Why, if the UDC implementation will, anyway, be a timer? It's mostly a question of what happens when the timer expires. (After all, starting a timer is just as easy to do in a UDC driver as it is in the core.) When the timer expires, what can the core do? Don't say it can cancel the offending request and resubmit it. That leads to the sort of trouble we discussed earlier in this thread. In particular, we don't want the class driver's completion routine to be called when the cancel occurs. Furthermore, this leads to a race: Suppose the class driver decides to cancel the request at the same time as the core does a cancel and resubmit. Then the class driver's cancel could get lost and the request would remain on the UDC's queue. What you really want to do is issue the appropriate stop and restart commands to the hardware, while leaving the request logically active the entire time. The UDC core can't do this, but a UDC driver can. > >>(Especially if dwc3 is the only driver affected.) > > > > As discussed above, the issue may happen with other gadgets too. As I got divide opinions > > on this implementation and both the implementations looks fine to me, I am little confused > > on which should be implemented. > > > > @Felipe: Do you agree with Alan's implementation? Please let us know your suggestion > > on this. > > I still think a generic timer is a better solution since it has other uses. Putting a struct timer into struct usb_request is okay with me, but I wouldn't go any farther than that. > >>Since the purpose of the timeout is to detect a deadlock caused by a > >>hardware bug, I suggest a fixed and relatively short timeout value such > >>as one second. Cancelling and requeuing a few requests at 1-second > >>intervals shouldn't add very much overhead. > > I wouldn't call this a HW bug though. This is just how the UDC > behaves. There are N streams and host can move data in any stream at any > time. This means that host & gadget _can_ disagree on what stream to > start next. But the USB 3 spec says what should happen when the host and gadget disagree in this way, doesn't it? And it doesn't say that they should deadlock. :-) Or have I misread the spec? > One way to avoid this would be to never pre-start any streams and always > rely on XferNotReady, but that would mean greatly reduced throughput for > streams. It would be good if there was some way to actively detect the problem instead of passively waiting for a timer to expire. Alan Stern