Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6936345rwr; Wed, 10 May 2023 01:13:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7m/SOMouVQzlyCi7RnS0BvSc4L8uRCuaiLaekduD6KsZF0FZ7Pa534pU4QlVmdk0wrKllL X-Received: by 2002:a05:6a00:17a7:b0:645:454c:286d with SMTP id s39-20020a056a0017a700b00645454c286dmr15266049pfg.3.1683706380157; Wed, 10 May 2023 01:13:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683706380; cv=none; d=google.com; s=arc-20160816; b=dPeaqv0xvQODt/2ohw1/SWJdk9ZapDJ7IM5jxHRWYM/+7zmG0FWXaLPXL1v2vggulT p1IB+U2UDuW23ZvkgSQTk6G6QGeSJpFVEQNZF3sWcsGuFfF0SNkfERlRD+xUgDXs39C3 hXxjGX12pcJBv3QR+9u6AuRBXA64rNflh6dAclTSDXoiRPpVzmULkSEdg+/1/wYGLPXw UwsIBy1Hd7fQF9lnETM43SFKxhIJMKTliNYN19HqEICzYsmrby2ieg8zuwPIp7btfswM BZ3UYkqBd7UfDCEVidsg1cWckaNT+WDjcTJp7LVmlsFF/SHKlm1aDUF/wNoDERglfCfi I+5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JNSiRPQRfxVwIyMLEWxPKZ1ja5t0tK62g2sAq6cgBYY=; b=pqWAIYzcd2ZMvdwtSFmD9ofuie1yYWVfZctHQ/11Y7XYmdJSdp73c8xMWvMRCR58w9 oTKrs7yZBGuvBkYMH5rrB9mLomMajiO/KrxfLWG+mn0Z+cZHjVxe0AtgitIPbi/3d2h7 b3YWOyw0QhjbeyFvvb0vcWabMYuroWwfELrCVk2XgG5YMRrroyiZnZ3P9mLVeib1KjqC v8qWkwBgrnu8hSicAu63QoVcPG4UdDSNR/FTtNBO0gS7RJ5nAGnFYwuJMGSTc/vnAAxh jIRmrwZ7lYD6Fbu4DdzMJYGiVawKbEDCjbdyTMCZhN5oW+CEyaQV3tQEHdEN8EaCR6Go N+gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=hdL8I5FM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x12-20020aa79a4c000000b0063d5cfd0867si4378932pfj.351.2023.05.10.01.12.47; Wed, 10 May 2023 01:13:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=hdL8I5FM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236418AbjEJHx0 (ORCPT + 99 others); Wed, 10 May 2023 03:53:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235912AbjEJHxY (ORCPT ); Wed, 10 May 2023 03:53:24 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 894EACD; Wed, 10 May 2023 00:53:23 -0700 (PDT) Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34A7ZmVI008368; Wed, 10 May 2023 07:53:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=JNSiRPQRfxVwIyMLEWxPKZ1ja5t0tK62g2sAq6cgBYY=; b=hdL8I5FMp22+QzuZpThVbOhM+fXlEgqjzY9b4k3swldwV/I/cnmyBeBXPuggD39jbuU2 XgP6RZqfJDxOaJL3+uDprcfX0/MJLV2JR1CL5z4UtzPNplTN54NTzffXnZpnF1oqDB5A mEJvqOplQsLWGep+JgT7U2lfRboW8vLK/F7+jm9WIJcAepOGBmMQP9ddsvjKXzYtlxQV zlelfOgF6uiiO9fT4iYgjm8l+aAmoImOxoUdtZFh3bDZWP4vcV6jinbIKoEUNd5bJx6E FkqLN6ykTW8Tyhk8Ai4V9bxMR6AA3JvEkUyHec9Y3up0nDdJwQjvCt0tdgmX5rThdrgu 6A== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3qg5mpr67c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 May 2023 07:53:14 +0000 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 34A7rDHb031859 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 May 2023 07:53:13 GMT Received: from hu-kriskura-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.986.42; Wed, 10 May 2023 00:53:10 -0700 From: Krishna Kurapati To: Thinh Nguyen , Greg Kroah-Hartman , Alan Stern , "Jiantao Zhang" , Badhri Jagan Sridharan CC: , , , , , Krishna Kurapati Subject: [PATCH v3 1/2] usb: dwc3: gadget: Bail out in pullup if soft reset timeout happens Date: Wed, 10 May 2023 13:22:51 +0530 Message-ID: <20230510075252.31023-2-quic_kriskura@quicinc.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230510075252.31023-1-quic_kriskura@quicinc.com> References: <20230510075252.31023-1-quic_kriskura@quicinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) 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: Z7tJNKZattktY4HXrHgLFgf8QtxmQEIP X-Proofpoint-GUID: Z7tJNKZattktY4HXrHgLFgf8QtxmQEIP X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-10_04,2023-05-05_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 priorityscore=1501 phishscore=0 mlxlogscore=999 clxscore=1015 suspectscore=0 malwarescore=0 mlxscore=0 adultscore=0 lowpriorityscore=0 impostorscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2305100061 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the core soft reset timeout happens, avoid setting up event buffers and starting gadget as the writes to these registers may not reflect when in reset and setting the run stop bit can lead the controller to access wrong event buffer address resulting in a crash. Signed-off-by: Krishna Kurapati Acked-by: Thinh Nguyen --- changes in v3: Rebase on top of usb-next drivers/usb/dwc3/gadget.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index c0ca4d12f95d..9ab5161881bd 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2746,13 +2746,16 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on) * device-initiated disconnect requires a core soft reset * (DCTL.CSftRst) before enabling the run/stop bit. */ - dwc3_core_soft_reset(dwc); + ret = dwc3_core_soft_reset(dwc); + if (ret) + goto done; dwc3_event_buffers_setup(dwc); __dwc3_gadget_start(dwc); ret = dwc3_gadget_run_stop(dwc, true); } +done: pm_runtime_put(dwc->dev); return ret; -- 2.40.0