Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2804258rwd; Wed, 14 Jun 2023 07:33:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5pYmMLZKDkJqoT4KPhIba34nlPcOC2KYIpxCdWNgWrtLsVJAGO6J6qmSX3MXqNyUDH+hzs X-Received: by 2002:a17:906:d542:b0:973:d7cd:44ac with SMTP id cr2-20020a170906d54200b00973d7cd44acmr16192866ejc.54.1686753198531; Wed, 14 Jun 2023 07:33:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686753198; cv=none; d=google.com; s=arc-20160816; b=tS7d85ZcrHsXFhQNer/DY/EOXEWKv2TXJ2/StKSxWzwnmJ4Fz5zLp1nsquDDU1H+5/ rW3rXDAKi7/xl1C2iPTZVBLSQXOTGxaZZ8NvJlrDD+Ru4GQETW7do+uoLNJjNEs2YhbO hTgRM3eTOcjLNIls+TWhq5s049zG2f35O4gxapOrZ/4QVCC5R7A1rnYha2vipHvj5aLS ZQzAdOXBN9dZH+a5LRklQF5SYYzdowmfcZBbg9msq3fC/Ie6bhAcTzCT5LY1oiPGDj08 ejO0hnH5DGsMTpN6MXCiWE1eVU35wPljlJn2iOZPnwtYErJBYx9q6mTVEkGhhQiISUUO +6Lg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=KGFhcp6wG4mFGI3AUHmeh1MZz+Qi6kEdPGQgIQYhlxs=; b=eNyCHedEsLfFRUjPcxuT2GAWMwky71FE/jdG+i1ssARBsP4PIi8kgbWXvA3EOzTErP ny9769miLBVWKu1hxRd+IdMt04xutlNq3vlv5Wyk5dSqRFOE3RmsNMI/qv6smAvoX8Th KmtJ6d/+6LqOlDFkx8hsPDRyiuiAsXC+P6NG7J/hbDD/PnpRmq9iuSskFOPmeDkldsKq HAOyt/Uh3ClCIR/BRLdG2KXQvxUYZ7yf1i7FbW0ni5c1pCUXoOJ6De8XNSFbm5fRnLFL cuY8qmmE85KNXVyFtOUdWCi1nm8ptyNwQK2cVL0PqWDcgAtosus60cyWf7c+6NkL8qx4 NOfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=eGPTyCST; 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 ha13-20020a170906a88d00b009745124453csi7837478ejb.815.2023.06.14.07.32.51; Wed, 14 Jun 2023 07:33:18 -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=eGPTyCST; 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 S245186AbjFNNuD (ORCPT + 99 others); Wed, 14 Jun 2023 09:50:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245172AbjFNNti (ORCPT ); Wed, 14 Jun 2023 09:49:38 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DA90ED; Wed, 14 Jun 2023 06:49:37 -0700 (PDT) Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35EDOIDW030344; Wed, 14 Jun 2023 13:49:35 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=KGFhcp6wG4mFGI3AUHmeh1MZz+Qi6kEdPGQgIQYhlxs=; b=eGPTyCSTlyzGFjdDnS/wYbBvGAmFtd3C1kbqj8MIyobhjZNHUI6bfkXv2PY8b7b9yAem DyzN/qRYZeD8E6eUgptuZVTsuDHet0fJ5VFhdJ8T9SjUlsiYyxCadZXZKmB6+V3om5rU CCIV7jwz19SdNBHdNey/YhBKoQJzM+sx15Y5V9T8C6+QZGBsdNa8RQGwAFAl+O84KSDp D0H6b5WnKLepJJLdKxJACPn9aE1zCQIjAQXkQyShPRZ3v855T1UeUQTuIet+6+/xlyGS tPRaja3I2v9ifl1gy4Of+i915X1P/AbEYqNnB8WSScCgT6T0afcnjNro8gS3+wvXEk2G Qw== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3r7eceg1ju-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 14 Jun 2023 13:49:35 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 35EDnYVJ014953 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 14 Jun 2023 13:49:34 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, 14 Jun 2023 06:49:31 -0700 From: Krishna Kurapati To: Thinh Nguyen , Greg Kroah-Hartman CC: , , , , , , Krishna Kurapati Subject: [PATCH] usb: dwc3: gadget: Propagate core init errors to UDC during pullup Date: Wed, 14 Jun 2023 19:19:22 +0530 Message-ID: <20230614134922.23516-1-quic_kriskura@quicinc.com> X-Mailer: git-send-email 2.40.0 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-GUID: xBZvHOp9U7IIdNspoBrFJzRga9y1SgvU X-Proofpoint-ORIG-GUID: xBZvHOp9U7IIdNspoBrFJzRga9y1SgvU X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-14_10,2023-06-14_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 clxscore=1015 impostorscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 lowpriorityscore=0 phishscore=0 priorityscore=1501 bulkscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306140120 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 In scenarios where pullup relies on resume (get sync) to initialize the controller and set the run stop bit, then core_init is followed by gadget_resume which will eventually set run stop bit. But in cases where the core_init fails, the return value is not sent back to udc appropriately. So according to UDC the controller has started but in reality we never set the run stop bit. On systems like Android, there are uevents sent to HAL depending on whether the configfs_bind / configfs_disconnect were invoked. In the above mentioned scnenario, if the core init fails, the run stop won't be set and the cable plug-out won't result in generation of any disconnect event and userspace would never get any uevent regarding cable plug out and we never call pullup(0) again. Furthermore none of the next Plug-In/Plug-Out's would be known to configfs. Return back the appropriate result to UDC to let the userspace/ configfs know that the pullup failed so they can take appropriate action. Signed-off-by: Krishna Kurapati --- drivers/usb/dwc3/gadget.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 578804dc29ca..27cb671e18e3 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2747,7 +2747,9 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on) ret = pm_runtime_get_sync(dwc->dev); if (!ret || ret < 0) { pm_runtime_put(dwc->dev); - return 0; + if (ret < 0) + pm_runtime_set_suspended(dwc->dev); + return ret; } if (dwc->pullups_connected == is_on) { -- 2.40.0