Message ID | 20230614134922.23516-1-quic_kriskura@quicinc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1298963vqr; Wed, 14 Jun 2023 07:22:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ76uzdMNAkdfgBdhs3EnFC8sOnP50/4KfNkA8N3ZtYNgQhQ5zQPgVui7jxIL4jJCpWXbIwV X-Received: by 2002:a05:6a00:16c7:b0:645:ac97:5295 with SMTP id l7-20020a056a0016c700b00645ac975295mr1958623pfc.9.1686752574732; Wed, 14 Jun 2023 07:22:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686752574; cv=none; d=google.com; s=arc-20160816; b=dvaQQyN+ebOrR6StnrjPF11R8iQeWta6YykCf92Lh9H1sgyhwQM5shd3ZjJxnPfteU Zi9tcZon6/yQqZV2FXOUSBlHvqZGrfHjBKPOlLL+Vsk9VphKbaKeQxL5QguJkacLdqwH zhmywWCa+XV0MdvbImW3w9WO8COymhPY1tQm67UpsZgYZBKsBA0lgnNtzIXBT+NvW5Xl D7Sw3cuacKjqQ8lavnxJT2bC2gXcjL5kSjRpkoPsrhr5S+mRTBmFGjOH61F3zOjaKHzn /89RXS7spVltRpK5VYpPU8CPmIslT3jhAU+qWK0I2AC76M/g55oW7bYt4WOCbxf4mq1K b7Ow== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l64-20020a638843000000b0054481da6ee5si108680pgd.418.2023.06.14.07.22.31; Wed, 14 Jun 2023 07:22:54 -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 S245187AbjFNNuD (ORCPT <rfc822;n2h9z4@gmail.com> + 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <quic_kriskura@quicinc.com> To: Thinh Nguyen <Thinh.Nguyen@synopsys.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org> CC: <linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <quic_ppratap@quicinc.com>, <quic_wcheng@quicinc.com>, <quic_jackp@quicinc.com>, <quic_ugoswami@quicinc.com>, Krishna Kurapati <quic_kriskura@quicinc.com> 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768688267557183335?= X-GMAIL-MSGID: =?utf-8?q?1768688267557183335?= |
Series |
usb: dwc3: gadget: Propagate core init errors to UDC during pullup
|
|
Commit Message
Krishna Kurapati
June 14, 2023, 1:49 p.m. UTC
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 <quic_kriskura@quicinc.com>
---
drivers/usb/dwc3/gadget.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
Comments
On Wed, Jun 14, 2023, Krishna Kurapati wrote: > 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 <quic_kriskura@quicinc.com> > --- > 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 > Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com> Thanks, Thinh
On Thu, Jun 15, 2023, Thinh Nguyen wrote: > On Wed, Jun 14, 2023, Krishna Kurapati wrote: > > 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 <quic_kriskura@quicinc.com> > > --- > > 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 > > > > Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com> > I think this patch qualifies as a fix. Can you also add a fixes tag? Thanks! Thinh
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) {