Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp901654lqm; Wed, 1 May 2024 21:41:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVHuJO2vSvfHkMUQd+4Qlmtv+v3WherC3jCVxoK1uhPhLMcENL5CgtuQpzJlEIbQyjJt9jkU5IIvlZgtszQlSOINJeri89fnwVwJUDO4g== X-Google-Smtp-Source: AGHT+IFDVjfohpyl+0cK1sw/tQAt2dBppVErBvTzigNO93vtCfvOQ123+kiYdAkYqG15XrAh7jky X-Received: by 2002:a17:90a:6406:b0:2b1:69c:8096 with SMTP id g6-20020a17090a640600b002b1069c8096mr915055pjj.25.1714624908029; Wed, 01 May 2024 21:41:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714624908; cv=pass; d=google.com; s=arc-20160816; b=L/VqdOODg5Z3lQxOh+U6Rjt5B/AarBhzOk1md+yQYnvdGhMdOCOphxWl7wqnevV6/c nQTyKHZs40qzPQBOo58EcCjR0OtTqF5ALJ1SsM1I9u8utYIv1IPzMM7Gn8Jj3ne/+D+G JJVtt38vB+6PZxTRGyGYMGYyTLj8nWrcbrGby9cEOvGEdEWr6gFJCKhK3w0Nth/9c1xd dmUrVnic4jPFKGM341XvbCv7V4vw73rLGhKlEnJMtQK/30sihag1wiYh5b+XEiaU5ZhW d43Qf64teld9RAjGGA6UIKrBwb4zUOshfJd3BE3WtiayKXhFjeM7ikqZra0KPmRVagfa D1lA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=5zIIYEsh/B9NGyiwPUz3ttQWfA7ru763lpbdHrXzpVQ=; fh=hpqGPsyWPpDWPluI7tldArh3YCJkWnNMH8V6gR0NNwY=; b=NplnLH/4ekWervjBEowMJFcX9Grbv1fuj74m9Gmuu1PS89WbbHn7kEXo4V+tKFyAwG n6Fe8+N7H4icCAkhQMPnlA1OcNqoqVWlIxsGJsxRwhvZtejnyH0YPfphCXEdL4AUngo1 dpEYhOw7nQ0aey7za3hUf9F53JDrfXUnlwYoeZqhFN40xfPK7UwmqhkW5t8WAT6PeF39 tXIldxM/lyqO49sdPl2sj2+PUG9CWBFM2sbLgoLLyyiiEfBWDxvK8EuWGQEMfo5Z9jsF UVkVzazeUQiU6hxvxCQKPyJWClAlAfHOmIKow0WIDXm+zIQmY2rYlVTmbBIeEtlxVsu5 tvew==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=oeIMWEPg; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-165966-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165966-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id t12-20020a17090ae50c00b002aeae8eda5csi2756776pjy.135.2024.05.01.21.41.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 21:41:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-165966-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=oeIMWEPg; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-165966-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165966-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7632B284106 for ; Thu, 2 May 2024 04:41:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 228501CD35; Thu, 2 May 2024 04:41:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="oeIMWEPg" Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B37D523A9; Thu, 2 May 2024 04:41:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714624897; cv=none; b=qV/WDbaVYpbfsdQhZHsFxsoiG/iDcAqyhs+YiCdRqG3AAAXQxxoAEB1D4G6vC8EgtimrEXafjYBpa7sAC7cAucpVCelmqGD2Pe1uB/7wh7YxUUvWZH8B0zzK+rfe+VfETWSLAGgHxXE9dLF+wcSfhPNjauyDDsCmV7yazj0xvVo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714624897; c=relaxed/simple; bh=299mMI2LUjr+nObINO/jPTh23fQK8xv06dDMPbsZubw=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=eQd2EFWpqlIAgcAqBNTxrlM+6pK5Ch3nxIZQvkyfr4+gL/9WoqKZdTFtRhSAfZG4GnuTMb3yLP+h/7PTyOQMJ5SCoRJ6YWZQ8cRIToqH/+0ZjqcGWzFWajLhTH1q1dc7GKKbJU/ixnZ1g15x9MWFACVTzUqf5hKkwqj6BMVzNdU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=oeIMWEPg; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4424MBr4013887; Thu, 2 May 2024 04:41:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding:content-type; s=qcppdkim1; bh=5zIIYEs h/B9NGyiwPUz3ttQWfA7ru763lpbdHrXzpVQ=; b=oeIMWEPgadSM+3gk4chOoyI Sk30WkFRUxHElL4lgX40lhC8DZpEB4qx3wcvt03GRX41etTIHJgnLY+0BDXoYT78 bvD4yPqGxSC/sC4qWxL8xtafwJC+w//PkE0MSBtGVbYp1wZNbpU2+O4/DVhFLOUU 3gKd7JOaWOmh+sG1r8HfO24eZVKTH0ehVNtQo2ctjXEBFqmvv5uMjTCEs+bbzZNn cqH3i1Fw7AchgYR6+r2QGMvWnyy7h09t5azl6EehyzfVXxgF3uc7CId6dvg6sQe/ TUY/X6Y9AWCyeBMEqYPV3PF4ZyODgakyET2798pD2bYckXPWG9Wj4S4NfLLeinA= = Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3xv01trah4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 02 May 2024 04:41:32 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 4424fV9Q024889 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 2 May 2024 04:41:31 GMT Received: from hu-prashk-hyd.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Wed, 1 May 2024 21:41:28 -0700 From: Prashanth K To: Thinh Nguyen , Greg Kroah-Hartman CC: Wesley Cheng , , , Prashanth K , Subject: [PATCH v3] usb: dwc3: Wait unconditionally after issuing EndXfer command Date: Thu, 2 May 2024 10:11:03 +0530 Message-ID: <20240502044103.1066350-1-quic_prashk@quicinc.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: iXvG1bllfJr-GaGeReu1yE6PRpcfmnbb X-Proofpoint-GUID: iXvG1bllfJr-GaGeReu1yE6PRpcfmnbb X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-01_16,2024-04-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 spamscore=0 lowpriorityscore=0 impostorscore=0 phishscore=0 adultscore=0 priorityscore=1501 mlxscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2405020022 Currently all controller IP/revisions except DWC3_usb3 >= 310a wait 1ms unconditionally for ENDXFER completion when IOC is not set. This is because DWC_usb3 controller revisions >= 3.10a supports GUCTL2[14: Rst_actbitlater] bit which allows polling CMDACT bit to know whether ENDXFER command is completed. Consider a case where an IN request was queued, and parallelly soft_disconnect was called (due to ffs_epfile_release). This eventually calls stop_active_transfer with IOC cleared, hence send_gadget_ep_cmd() skips waiting for CMDACT cleared during EndXfer. For DWC3 controllers with revisions >= 310a, we don't forcefully wait for 1ms either, and we proceed by unmapping the requests. If ENDXFER didn't complete by this time, it leads to SMMU faults since the controller would still be accessing those requests. Fix this by ensuring ENDXFER completion by adding 1ms delay in __dwc3_stop_active_transfer() unconditionally. Cc: Fixes: b353eb6dc285 ("usb: dwc3: gadget: Skip waiting for CMDACT cleared during endxfer") Signed-off-by: Prashanth K Acked-by: Thinh Nguyen --- Changes in v3: Fixed build errors by removing unused variable 'dwc'. Changes in v2: Changed the patch logic from CMDACT polling to 1ms mdelay. Updated subject and commit accordingly. Link to v1: https://lore.kernel.org/all/20240422090539.3986723-1-quic_prashk@quicinc.com/ drivers/usb/dwc3/gadget.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 4df2661f6675..140120953c76 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1699,7 +1699,6 @@ static int __dwc3_gadget_get_frame(struct dwc3 *dwc) */ static int __dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force, bool interrupt) { - struct dwc3 *dwc = dep->dwc; struct dwc3_gadget_ep_cmd_params params; u32 cmd; int ret; @@ -1724,8 +1723,7 @@ static int __dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force, bool int dep->resource_index = 0; if (!interrupt) { - if (!DWC3_IP_IS(DWC3) || DWC3_VER_IS_PRIOR(DWC3, 310A)) - mdelay(1); + mdelay(1); dep->flags &= ~DWC3_EP_TRANSFER_STARTED; } else if (!ret) { dep->flags |= DWC3_EP_END_TRANSFER_PENDING; -- 2.25.1