From patchwork Thu Feb 23 05:18:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashanth K X-Patchwork-Id: 13149864 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11F0BC61DA4 for ; Thu, 23 Feb 2023 05:18:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233182AbjBWFS4 (ORCPT ); Thu, 23 Feb 2023 00:18:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233179AbjBWFSx (ORCPT ); Thu, 23 Feb 2023 00:18:53 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 024A73C78F; Wed, 22 Feb 2023 21:18:51 -0800 (PST) Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31N2RjqX020464; Thu, 23 Feb 2023 05:18:48 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-type; s=qcppdkim1; bh=+Lw7UTc4O0iuLiYFsUORHobiA42VjkXdjQpQhes49ho=; b=bI///UeGhIKYY1lnlyRDHCOcKr0MDotugA0dfmBp3bnKA8PgP0iiwpF82U+mIJ/w7FIV 6vaDahqv//d1T5Kgy9I+vHn+JczodW5p6NCqjDIf1ZKpQxxyMr6VAtEexAnQgfHzAmUg Z5tXvrvAZXnr2vqFYtW1sHZQbK8JpsFnmq+QNt9/XgyFSxrgRk/3Yq0bXQxuLwKR+9kS 1g2tom6wfzCMiLIXytgoI+hSTkUwBO5HpCksFXptmXpUUcvVDZeSABQqsXBc3mBrWfzt AlRKCDSEKGH5T/J4bmjz1JBolcXjqvBtWnmjl7AofEcDsVeGSHh36W5E61AUtimFKT0N yg== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3nwyc5gb8h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Feb 2023 05:18:48 +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 31N5Il0Z017975 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Feb 2023 05:18:47 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.986.41; Wed, 22 Feb 2023 21:18:44 -0800 From: Prashanth K To: Greg Kroah-Hartman , Thinh Nguyen , Jakob Koschel , =?utf-8?b?SsOzIMOBZ2lsYSBCaXRzY2g=?= , Alan Stern CC: Pratham Pratap , Jack Pham , , , Prashanth K Subject: [PATCH v1 1/2] usb: dwc3: gadget: Change condition for processing suspend event Date: Thu, 23 Feb 2023 10:48:29 +0530 Message-ID: <1677129510-10283-2-git-send-email-quic_prashk@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1677129510-10283-1-git-send-email-quic_prashk@quicinc.com> References: <1677129510-10283-1-git-send-email-quic_prashk@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] 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: OC8oiRRx223cOZ4fNAOhk93aYCKFIJU- X-Proofpoint-GUID: OC8oiRRx223cOZ4fNAOhk93aYCKFIJU- X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-23_02,2023-02-22_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 phishscore=0 spamscore=0 mlxlogscore=634 bulkscore=0 adultscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 impostorscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302230045 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Currently we process the suspend interrupt event only if the device is in configured state. Consider a case where device is not configured and got suspend interrupt, in that case our gadget will still use 100mA as composite_suspend didn't happen. But battery charging specification (BC1.2) expects a downstream device to draw less than 2.5mA when unconnected OR suspended. Fix this by removing the condition for processing suspend event, and thus composite_resume would set vbus draw to 2. Fixes: 72704f876f50 ("dwc3: gadget: Implement the suspend entry event handler") Signed-off-by: Prashanth K --- drivers/usb/dwc3/gadget.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 3c63fa9..07989c6 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -4239,15 +4239,8 @@ static void dwc3_gadget_interrupt(struct dwc3 *dwc, break; case DWC3_DEVICE_EVENT_SUSPEND: /* It changed to be suspend event for version 2.30a and above */ - if (!DWC3_VER_IS_PRIOR(DWC3, 230A)) { - /* - * Ignore suspend event until the gadget enters into - * USB_STATE_CONFIGURED state. - */ - if (dwc->gadget->state >= USB_STATE_CONFIGURED) - dwc3_gadget_suspend_interrupt(dwc, - event->event_info); - } + if (!DWC3_VER_IS_PRIOR(DWC3, 230A)) + dwc3_gadget_suspend_interrupt(dwc, event->event_info); break; case DWC3_DEVICE_EVENT_SOF: case DWC3_DEVICE_EVENT_ERRATIC_ERROR: From patchwork Thu Feb 23 05:18:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashanth K X-Patchwork-Id: 13149865 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05FC4C636D7 for ; Thu, 23 Feb 2023 05:19:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233259AbjBWFTG (ORCPT ); Thu, 23 Feb 2023 00:19:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232085AbjBWFS5 (ORCPT ); Thu, 23 Feb 2023 00:18:57 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7ADF3474FC; Wed, 22 Feb 2023 21:18:56 -0800 (PST) Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31N42FMc030284; Thu, 23 Feb 2023 05:18:53 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-type; s=qcppdkim1; bh=luXeSi3oGE0B76cYBdKMJWZZbG8GVrkQJyPg4MmcMH4=; b=LoP5uFPMwV9afpZRmNqeHZrpSewUbdkCSpvcEFzgOcE2tWz4Gg1L90BnmLWe6JPHz94T Po+IHtNdRQQ+cI7a52ajf1KebWO6jOXl2pC+d5jYU4o1E4///T3gWiDPCk8OALcBkQIJ o/bywRXE6jMcPcZRsIF6A50L1qnVeN68tX2lJyMofh408XUMcRHT7pnaBe9EidL03H+F ZD/pc54N1ZNdfhzj4aPmWBTvH+l8Zw7qBmniizNroQI+Z/8uDxBoA7voDecGp/+XxlL8 xkbyTDeUYKpYevsESmczrvbmWhNd7eylpGhzzhESYuyIvDAZSpuvfL1I3vUOfQN93Sdo 0w== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3nwybm0bg7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Feb 2023 05:18:53 +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 31N5Iqth018033 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Feb 2023 05:18:52 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.986.41; Wed, 22 Feb 2023 21:18:49 -0800 From: Prashanth K To: Greg Kroah-Hartman , Thinh Nguyen , Jakob Koschel , =?utf-8?b?SsOzIMOBZ2lsYSBCaXRzY2g=?= , Alan Stern CC: Pratham Pratap , Jack Pham , , , Prashanth K Subject: [PATCH v1 2/2] usb: gadget: composite: Draw 100mA current if not configured Date: Thu, 23 Feb 2023 10:48:30 +0530 Message-ID: <1677129510-10283-3-git-send-email-quic_prashk@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1677129510-10283-1-git-send-email-quic_prashk@quicinc.com> References: <1677129510-10283-1-git-send-email-quic_prashk@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] 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: hftI9Gdu0Wx7XuC_6tbObtQgQw1bpJJ7 X-Proofpoint-GUID: hftI9Gdu0Wx7XuC_6tbObtQgQw1bpJJ7 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-23_02,2023-02-22_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=550 suspectscore=0 phishscore=0 spamscore=0 priorityscore=1501 adultscore=0 impostorscore=0 bulkscore=0 lowpriorityscore=0 malwarescore=0 mlxscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302230045 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Currently we don't change the current value if device isn't in configured state. But the battery charging specification says, the device can draw upto 100mA of current if its in unconfigured state. Hence add a Vbus_draw work in composite_resume to draw 100mA if the device isn't configured. Signed-off-by: Prashanth K --- drivers/usb/gadget/composite.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index fa7dd6c..147d278 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -2531,6 +2531,8 @@ void composite_resume(struct usb_gadget *gadget) usb_gadget_clear_selfpowered(gadget); usb_gadget_vbus_draw(gadget, maxpower); + } else { + usb_gadget_vbus_draw(gadget, 100); } cdev->suspended = 0;