Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5310511ybl; Wed, 22 Jan 2020 14:29:30 -0800 (PST) X-Google-Smtp-Source: APXvYqztNIvRp07paT6C3KazETYKhumw5UFWjExkiDpG17jSOBTux/82mtKf7Lt+/JE88lVNvtUM X-Received: by 2002:a05:6830:1d91:: with SMTP id y17mr8800070oti.276.1579732169851; Wed, 22 Jan 2020 14:29:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579732169; cv=none; d=google.com; s=arc-20160816; b=C3ira/NETS8Vi+jcXtuk0DzIemCgsOxDyibfZm8strQaIcOL3O3HYXoZKJvM1UkGaC FpkjnYlghnwONsWM0AfbD5UHgseczuO/ddEZJOc+KuIIYk7Z1sUQ/SFfzUvJZgOuGOpd A7f8fPy6MUb2H79ubHO2ayGULj2BD3LCiK9270ux2XNwDlZSE4idkQiBDcR/FfKTehVA 9Ynrrxk4NiOD4c3+4WNtiCp4W3opOzdUbiyX1CpWwXi2+wPYrnyQnwLjZiRV5iL3B8Cg coGsWzwntPqMlVltUbCsBrDyKDYCFFvDnnahNfj6A3UYOTqMJ8BMT+yUNRTBXINKH/42 QZsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=JESjh6inBv92WxZqfb4czYKZ8FKdIT47e0CUpHsL9zw=; b=ARk6nrZvudavjfMPgJCg0MLb4nkDI1/iczx+M3WWWux55YS630an+npalbOet6/jP+ eT45n5ok3Wx4G+WWhbAZonPg3EsrdzSFhtYa5jyKhCm8j5oFaLdFSdDHL+25Zmi/Qbhv PtLr+LHCraiqMgJIMxIqTZmjuJYWuGmeZlIjp8BvZDk8MIxPS+dBigLSBA/kxYl7/yJ1 afw4p6YKDeWx6NlElhKMN8rTdzAtP0uGvpIvS60ELD0iX3GxhwszqNaIlUcpdsO4qfUG lMNInG8QPNHywrKII6cvaK6Lq4yr6Vz0JZYMHA0c5G4TI/dO7SRS9BGsCYHlh6J0ZIzv cRLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RsGmOvIt; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i13si68307oth.175.2020.01.22.14.29.17; Wed, 22 Jan 2020 14:29:29 -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; dkim=pass header.i=@linaro.org header.s=google header.b=RsGmOvIt; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726061AbgAVW0y (ORCPT + 99 others); Wed, 22 Jan 2020 17:26:54 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:34274 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728731AbgAVW0w (ORCPT ); Wed, 22 Jan 2020 17:26:52 -0500 Received: by mail-pg1-f196.google.com with SMTP id r11so286494pgf.1 for ; Wed, 22 Jan 2020 14:26:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JESjh6inBv92WxZqfb4czYKZ8FKdIT47e0CUpHsL9zw=; b=RsGmOvIt+Bzr6i4aIVzintUFXr+6XX+aQJNI6juKMss4wBAunzxItSZlGbXw7ha+3c V5pNjplf1oyvhJV3/UY1eBclT7Bav7RGheW0wzEZ34ThAk5YhiMCUCN0jmmS1fz8i5Rq 3WBNsJe0+drVR3Fi8glb78/uzKQBNkHkind1gitZeqjlkXBg0eabjb5ILlDjiP473ux2 LZ5J1BPDiBf1L0IJfDdw5BDmpkkp2vVEuWl426uWWk4c+8E+pLHAJj5YK1M0M+OeLBsV MxdvsQOkXmBtkojh4QldDc4RcnkQiSuotRNJcvmGpFH5ESJmrVx/O4yKvoYr4dhdqkxW 1p0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JESjh6inBv92WxZqfb4czYKZ8FKdIT47e0CUpHsL9zw=; b=F99/4MlsTkU3JNxu9txlWnRlWLu020Uun1+5iumV+tKvBlH5pkSfyO0HZkeLkLGCJc zajyk5CzPFDm/inVgsOb/VWqgfCzellawoahNQMxaQ586ak9MpHquer0KrogfxH+h2iH YuX2GSOGvSC3l6TZw8YruM6nKCHrJXmbU/KGracWp2C5y5Vn5KRv9w5/XJdXMg9b/1XU 3YZY/gecJpM1dv6LYrTyAQKkX44Np9wCjTveR5+Tg2uHZKpM05jH6S5z6CdzO8lXbqOm e2pKYYGmCpAaLD6SYYOnNWObcaUPWLpg3yNon+ULNRQl3kTK4Cvi9ceReBAVyOkeDpO2 6kEw== X-Gm-Message-State: APjAAAWa0Un63qI9umyVDMkgQ0Q1MdPqerF1A4Ojnj/dBwr56WuoNY4G KgL8OqQMxbrK2MBs459NDY3M9R2Mlxs= X-Received: by 2002:a63:111e:: with SMTP id g30mr541062pgl.251.1579732011742; Wed, 22 Jan 2020 14:26:51 -0800 (PST) Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id a28sm47793509pfh.119.2020.01.22.14.26.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2020 14:26:51 -0800 (PST) From: John Stultz To: lkml Cc: Anurag Kumar Vulisha , Felipe Balbi , Yang Fei , Thinh Nguyen , Tejas Joglekar , Andrzej Pietrasiewicz , Jack Pham , Todd Kjos , Greg KH , Linux USB List , stable , John Stultz Subject: [RFC][PATCH 1/2] usb: dwc3: gadget: Check for IOC/LST bit in both event->status and TRB->ctrl fields Date: Wed, 22 Jan 2020 22:26:44 +0000 Message-Id: <20200122222645.38805-2-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200122222645.38805-1-john.stultz@linaro.org> References: <20200122222645.38805-1-john.stultz@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Anurag Kumar Vulisha The present code in dwc3_gadget_ep_reclaim_completed_trb() will check for IOC/LST bit in the event->status and returns if IOC/LST bit is set. This logic doesn't work if multiple TRBs are queued per request and the IOC/LST bit is set on the last TRB of that request. Consider an example where a queued request has multiple queued TRBs and IOC/LST bit is set only for the last TRB. In this case, the Core generates XferComplete/XferInProgress events only for the last TRB (since IOC/LST are set only for the last TRB). As per the logic in dwc3_gadget_ep_reclaim_completed_trb() event->status is checked for IOC/LST bit and returns on the first TRB. This makes the remaining TRBs left unhandled. To aviod this, changed the code to check for IOC/LST bits in both event->status & TRB->ctrl. This patch does the same. At a practical level, this patch resolves USB transfer stalls seen with adb on dwc3 based HiKey960 after functionfs gadget added scatter-gather support around v4.20. Cc: Felipe Balbi Cc: Yang Fei Cc: Thinh Nguyen Cc: Tejas Joglekar Cc: Andrzej Pietrasiewicz Cc: Jack Pham Cc: Todd Kjos Cc: Greg KH Cc: Linux USB List Cc: stable Tested-by: Tejas Joglekar Reviewed-by: Thinh Nguyen Signed-off-by: Anurag Kumar Vulisha [jstultz: forward ported to mainline, added note to commit log] Signed-off-by: John Stultz --- drivers/usb/dwc3/gadget.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 154f3f3e8cff..1edce3bbb55c 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2420,7 +2420,12 @@ static int dwc3_gadget_ep_reclaim_completed_trb(struct dwc3_ep *dep, if (event->status & DEPEVT_STATUS_SHORT && !chain) return 1; - if (event->status & DEPEVT_STATUS_IOC) + if ((event->status & DEPEVT_STATUS_IOC) && + (trb->ctrl & DWC3_TRB_CTRL_IOC)) + return 1; + + if ((event->status & DEPEVT_STATUS_LST) && + (trb->ctrl & DWC3_TRB_CTRL_LST)) return 1; return 0; -- 2.17.1