Message ID | 1677156121-30364-3-git-send-email-quic_prashk@quicinc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp290605wrd; Thu, 23 Feb 2023 04:45:24 -0800 (PST) X-Google-Smtp-Source: AK7set/8pXQB2fG6aYrlZyqrBLI8wDKQkwYkgghKYrhHvMfirTnBAMN8teg0QgxbO1LgOVzIGzPF X-Received: by 2002:a05:6a20:3d1e:b0:c7:af88:3dd8 with SMTP id y30-20020a056a203d1e00b000c7af883dd8mr14064880pzi.6.1677156324095; Thu, 23 Feb 2023 04:45:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677156324; cv=none; d=google.com; s=arc-20160816; b=QeV0/d3bmuX7pm8jzPLmSkgK4kOqaTBCjtj3A0hoRkCktrLh/7pr8no//nQGIe84qe w2XoRV5AHPPY3BfrBBgckrEi/D9ATCI1q0juKWyXg503YEjKSL+GfNJyMWik3hdC4t+a lZ59z0AoDm03wDeTIQ12HJT2OXf1CeqZZQpQE8blmlnQD3yoZr954KGnmQqCrBRzVDiY RS+3jG2MqZI0/CyQxK/LHAD4gCU38aGI3OKrIEkTy6BFivz8fhqPFNsd9E2NV+ij9ZVc QH8yNzHcJesMnP4lDnDCO7ZTeBjcjvq5x/oG4Wms4BBsYuN3xiHuxLSTXgJT5nffXvfE vzNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=MM0qQty+voAnaENBBVdRbuianxgy+a6YzP501pjWE/8=; b=xd9jeXnyHsXGvRcfKdSgF+IycKxn4leaP3W+Zn2e/y+2xoC3jJaZKjnUa0iYEOmCQ8 Vb0yE4YrYnLD8TF+H9EtW0irqy2xi/Yw9MBDkmNFZ7y+gQFA2FrFw6rkWOuIaopdaZ5b aYtbxO39kyYuSI0cmH3cnTBDRAIcberWL2jbh8mFHVTOZERe/gseRBPjA09wi53ieEll fd/CGFXuGKfsf82knRazOVqQLm+hlyRGRDZ5iir3e5szZNY+jpexFivxDxBufCTgaSaj h5sTblHC/HRbVc8v8RNxegE3+aPWzS71qEOr8Xd9gpsJ0lTWGXwMBqlem6YuLlOzSHlb vB4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Fsvtn6bl; 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 k16-20020a056a00135000b005a8cdb17b9bsi8546026pfu.102.2023.02.23.04.45.10; Thu, 23 Feb 2023 04:45:24 -0800 (PST) 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=Fsvtn6bl; 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 S234109AbjBWMm2 (ORCPT <rfc822;cambridge8321@gmail.com> + 99 others); Thu, 23 Feb 2023 07:42:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234073AbjBWMm0 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 23 Feb 2023 07:42:26 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8876954A3E; Thu, 23 Feb 2023 04:42:22 -0800 (PST) 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 31NCO52u019294; Thu, 23 Feb 2023 12:42:18 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=MM0qQty+voAnaENBBVdRbuianxgy+a6YzP501pjWE/8=; b=Fsvtn6blOcOlLdJwdm0eECdRKGcn6pKPvTWxxQepjdEqqayFU9u8jQuL23M0aATavvPA DuWLmvJEkhux1H2ZR7mgDfWnL6zPILSffIKFG0gKpLA9Mu2EMlcKnBsDujP7hqy3D+L9 HEOOZGUkjy/3KlmrbIZd5x1sytF9L+cVKON7XCp2tGSggH1NPSfh8jGSckq1LtolwPQm ABJqueTtnlGkJoFMLGsqjw/erJ1qVU9VeQYeMUhXFChGWbIIqSU8o60WUdUUVXjWmgv5 3OFeKjMcYf0C6Pp9TcBWfRUQAaeYzgKlyAWYQ61wiAyf5X7BbXLFa/evXu2ZXuyvM/Bk vQ== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3nwy9gha7q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Feb 2023 12:42:18 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 31NCgHuT016399 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Feb 2023 12:42:17 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; Thu, 23 Feb 2023 04:42:13 -0800 From: Prashanth K <quic_prashk@quicinc.com> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Thinh Nguyen <Thinh.Nguyen@synopsys.com>, Jakob Koschel <jakobkoschel@gmail.com>, =?utf-8?b?SsOzIMOBZ2lsYSBCaXRzY2g=?= <jgilab@gmail.com>, Alan Stern <stern@rowland.harvard.edu> CC: Pratham Pratap <quic_ppratap@quicinc.com>, Jack Pham <quic_jackp@quicinc.com>, <linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>, Prashanth K <quic_prashk@quicinc.com> Subject: [PATCH v3 2/2] usb: gadget: composite: Draw 100mA current if not configured Date: Thu, 23 Feb 2023 18:12:01 +0530 Message-ID: <1677156121-30364-3-git-send-email-quic_prashk@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1677156121-30364-1-git-send-email-quic_prashk@quicinc.com> References: <1677156121-30364-1-git-send-email-quic_prashk@quicinc.com> MIME-Version: 1.0 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: arqHJS_I9qyKZNVlz-FYHgcn3QxI3bSO X-Proofpoint-ORIG-GUID: arqHJS_I9qyKZNVlz-FYHgcn3QxI3bSO 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_07,2023-02-23_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 mlxlogscore=646 spamscore=0 malwarescore=0 adultscore=0 impostorscore=0 mlxscore=0 suspectscore=0 lowpriorityscore=0 clxscore=1015 priorityscore=1501 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302230103 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 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?1758625869835381623?= X-GMAIL-MSGID: =?utf-8?q?1758625869835381623?= |
Series |
Fix vbus draw of dwc3 gadget
|
|
Commit Message
Prashanth K
Feb. 23, 2023, 12:42 p.m. UTC
Currently we don't change the current value if device isn't in
configured state. But the battery charging specification says,
device can draw up to 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 <quic_prashk@quicinc.com>
---
drivers/usb/gadget/composite.c | 4 ++++
1 file changed, 4 insertions(+)
Comments
On Thu, Feb 23, 2023, Prashanth K wrote: > Currently we don't change the current value if device isn't in > configured state. But the battery charging specification says, Can you provide the spec section also? > device can draw up to 100mA of current if its in unconfigured Is this related to being self-powered? > state. Hence add a Vbus_draw work in composite_resume to draw > 100mA if the device isn't configured. > > Signed-off-by: Prashanth K <quic_prashk@quicinc.com> > --- > drivers/usb/gadget/composite.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c > index 403563c..386140f 100644 > --- a/drivers/usb/gadget/composite.c > +++ b/drivers/usb/gadget/composite.c > @@ -2449,6 +2449,10 @@ void composite_resume(struct usb_gadget *gadget) > usb_gadget_clear_selfpowered(gadget); > > usb_gadget_vbus_draw(gadget, maxpower); > + } else { > + maxpower = CONFIG_USB_GADGET_VBUS_DRAW; > + maxpower = min(maxpower, 100U); > + usb_gadget_vbus_draw(gadget, maxpower); > } > > cdev->suspended = 0; > -- > 2.7.4 > Thanks, Thinh
On 24-02-23 01:40 am, Thinh Nguyen wrote: > On Thu, Feb 23, 2023, Prashanth K wrote: >> Currently we don't change the current value if device isn't in >> configured state. But the battery charging specification says, > > Can you provide the spec section also? > 1.2 Background 1.4.13 Standard Downstream Port Did you mean to add these in the commit message? >> device can draw up to 100mA of current if its in unconfigured > > Is this related to being self-powered? I think its applicable for bus-powered devices. Thanks Prashanth K
On Fri, Feb 24, 2023, Prashanth K wrote: > > > On 24-02-23 01:40 am, Thinh Nguyen wrote: > > On Thu, Feb 23, 2023, Prashanth K wrote: > > > Currently we don't change the current value if device isn't in > > > configured state. But the battery charging specification says, > > > > Can you provide the spec section also? > > > 1.2 Background > 1.4.13 Standard Downstream Port > > Did you mean to add these in the commit message? Yes, it's better to have the reference in case we need to revisit this. > > > device can draw up to 100mA of current if its in unconfigured > > > > Is this related to being self-powered? > I think its applicable for bus-powered devices. No, I mean before configured state, is the device considered self-powered? Since being self-powered means drawing 100mA or less, we can use USB_SELF_POWER_VBUS_MAX_DRAW to provide more context. If it's totally unrelated, then you can ignore this. Thanks, Thinh
On 25-02-23 12:08 am, Thinh Nguyen wrote: > On Fri, Feb 24, 2023, Prashanth K wrote: >> >> >> On 24-02-23 01:40 am, Thinh Nguyen wrote: >>> On Thu, Feb 23, 2023, Prashanth K wrote: >>>> Currently we don't change the current value if device isn't in >>>> configured state. But the battery charging specification says, >>> >>> Can you provide the spec section also? >>> >> 1.2 Background >> 1.4.13 Standard Downstream Port >> >> Did you mean to add these in the commit message? > > Yes, it's better to have the reference in case we need to revisit this. I have added it in v4 patch, thanks for pointing it out. > >>>> device can draw up to 100mA of current if its in unconfigured >>> >>> Is this related to being self-powered? > >> I think its applicable for bus-powered devices. > > No, I mean before configured state, is the device considered > self-powered? Since being self-powered means drawing 100mA or less, we > can use USB_SELF_POWER_VBUS_MAX_DRAW to provide more context. If it's > totally unrelated, then you can ignore this. > > Thanks, > Thinh As per my understanding, those are 2 different things. A self-powered device isn't allowed to draw more than 100mA. And an unconfigured device isn't allowed to draw more than 100mA (in HS). One thing that I recently found out is that, as per usb3.0 spec, SS device can only draw up to 150mA if its unconfigured state. So i have to check the speed and set the current values accordingly. Thanks, Prashanth K
On Sat, Feb 25, 2023, Prashanth K wrote: > > > On 25-02-23 12:08 am, Thinh Nguyen wrote: > > On Fri, Feb 24, 2023, Prashanth K wrote: > > > > > > > > > On 24-02-23 01:40 am, Thinh Nguyen wrote: > > > > On Thu, Feb 23, 2023, Prashanth K wrote: > > > > > Currently we don't change the current value if device isn't in > > > > > configured state. But the battery charging specification says, > > > > > > > > Can you provide the spec section also? > > > > > > > 1.2 Background > > > 1.4.13 Standard Downstream Port > > > > > > Did you mean to add these in the commit message? > > > > Yes, it's better to have the reference in case we need to revisit this. > I have added it in v4 patch, thanks for pointing it out. > > > > > > > device can draw up to 100mA of current if its in unconfigured > > > > > > > > Is this related to being self-powered? > > > > > I think its applicable for bus-powered devices. > > > > No, I mean before configured state, is the device considered > > self-powered? Since being self-powered means drawing 100mA or less, we > > can use USB_SELF_POWER_VBUS_MAX_DRAW to provide more context. If it's > > totally unrelated, then you can ignore this. > > > > Thanks, > > Thinh > As per my understanding, those are 2 different things. A self-powered device > isn't allowed to draw more than 100mA. And an unconfigured device > isn't allowed to draw more than 100mA (in HS). One thing that I recently > found out is that, as per usb3.0 spec, SS device can only draw up to 150mA > if its unconfigured state. So i have to check the speed and set the current > values accordingly. I see. Thanks for the info. Thanks, Thinh
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 403563c..386140f 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -2449,6 +2449,10 @@ void composite_resume(struct usb_gadget *gadget) usb_gadget_clear_selfpowered(gadget); usb_gadget_vbus_draw(gadget, maxpower); + } else { + maxpower = CONFIG_USB_GADGET_VBUS_DRAW; + maxpower = min(maxpower, 100U); + usb_gadget_vbus_draw(gadget, maxpower); } cdev->suspended = 0;