Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7038591imu; Mon, 3 Dec 2018 06:51:55 -0800 (PST) X-Google-Smtp-Source: AFSGD/VUHZBENWcnE5wW/zMDy+eGhVTz88sStMBHR3CorRpkvOLFL5FH2uqVvXChNkIMJydV46Cp X-Received: by 2002:a17:902:6b87:: with SMTP id p7-v6mr16531653plk.282.1543848715411; Mon, 03 Dec 2018 06:51:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543848715; cv=none; d=google.com; s=arc-20160816; b=diYwfeqvjk+749vjfyfuammH3Yv3abmOIZLG4bNCUw0cO2P5hSuHqttgN3GuW09eUE 2ZYc0yF9wX1gZDwOGsHE6/r6auD1A55shpb8ccrEZjpzMwbkPgokuxnz32fiqxWGq98G MkjetarApjLa6H3OF6D9TBBZ/Dr6JzZYWO7//lBa9ywtWfGZkR8Aw1UXOkH6uCW4wJIY IHYq3gnnShNVUU/R7TLItgdGHJNqofJE72tICEzGaBpR8PbWtCuYu32aq/e3GhSkOM+M QCZOuXXOJE9lRxODdcIxnHwGzRiM3byq/gfAUFgX0+VP5rCsNZmWMRk+8MblGKfXcBjI aYbg== 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=n4CxDHDGUc3ewDu+OjaWv7nySYcRB+kHQgl88gv+VK0=; b=rZ+yol87Zh1SDi18iTmt0cSmUe/2/U5Hcitq6s1g7wfucVjrWdz3JY7jFzI7RvVo92 CHWnubfTsHUemH63JwFbJXLcnNTYTllIBTxjlyhdXRiXDba2gvsZui9GNnjOdsUiNjjf gbgEGwGmayZiYUGaM51VkmwW/G5jK6dp/a1MzPW7znRUzYN2Z1qh57gMrZZkjr1Jqilt 2PdljZr1g6stzMgnWWoL+pehwLBaXhOO28Nk5uddS61/4kz7T64L1yqghg3NEbR5WtJ3 6VIGB7R26I/Ayy3c11OVSIsrGZb4QyqBxfFvGxwjNgGTjkRwiwLRtVcFK1YJG6zw3/oq 86PA== 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 i90si13971660pli.135.2018.12.03.06.51.40; Mon, 03 Dec 2018 06:51: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 S1726687AbeLCOwV (ORCPT + 99 others); Mon, 3 Dec 2018 09:52:21 -0500 Received: from netrider.rowland.org ([192.131.102.5]:36937 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1726592AbeLCOwU (ORCPT ); Mon, 3 Dec 2018 09:52:20 -0500 Received: (qmail 23547 invoked by uid 500); 3 Dec 2018 09:51:01 -0500 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 3 Dec 2018 09:51:01 -0500 Date: Mon, 3 Dec 2018 09:51:01 -0500 (EST) From: Alan Stern X-X-Sender: stern@netrider.rowland.org To: Anurag Kumar Vulisha cc: Felipe Balbi , 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: 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 Mon, 3 Dec 2018, Anurag Kumar Vulisha wrote: > >First of all, if some sort of deadlock causes a transfer to fail to > >complete, the host is expected to cancel and restart it. Not the > >gadget. > > > > Thanks for spending your time in reviewing this patch. The deadlock > is a very rare case scenario and is happening because both the gadget > controller & host controllers get out of sync and are stuck waiting for the > relevant event. For example this issue is observed in stream protocol where > the gadget controller is waiting on Host controller to issue PRIME transaction > and Host controller is waiting on gadget to issue ERDY transaction. Since > the stream protocol is gadget driven, the host may not proceed further until it > receives a valid Start Stream (ERDY) transaction from gadget. That's not entirely true. Can't the host cancel the transfer and then restart it? > Since the gadget > controller driver is aware that the controller is stuck , makes it responsible > to recover the controller from hang condition by restarting the transfer (which > triggers the controller FSM to issue ERDY to host). Isn't there a cleaner way to recover than by cancelling the request and resubmitting it? > >Second, if a request timer expires and the request is cancelled, the > >gadget driver's completion handler will be called. This is not what > >you want if the UDC core is going to resubmit the request > >automatically. > > > >Third, if a request timer expires and the timer handler calls > >usb_ep_dequeue() followed immediately by usb_ep_queue_timeout(), the > >resubmit will probably fail because the dequeue won't have completed > >yet. > > > >Fourth, the patch contains a race between the timer expiring and the > >request completing. > > Thanks for correcting, I agree with you on all the above 3 cases that the > resubmission of the request should only be done from the class driver and > the udc core should simply dequeue the request on timeout. I am not sure > why I haven't seen any issue while testing on this patch series. I will modify > the code to handle the resubmitting of requests properly. How can the gadget driver know what timeout to use? The host is allowed to be as slow as it wants; the gadget driver doesn't have any way to tell when the host wants to start the transfer. Alan Stern