From patchwork Thu Aug 3 05:18:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linyu Yuan X-Patchwork-Id: 710826 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 F2F9EC04A6A for ; Thu, 3 Aug 2023 05:18:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232346AbjHCFS4 (ORCPT ); Thu, 3 Aug 2023 01:18:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232321AbjHCFSx (ORCPT ); Thu, 3 Aug 2023 01:18:53 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8248E43 for ; Wed, 2 Aug 2023 22:18:52 -0700 (PDT) Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3731oILv000778; Thu, 3 Aug 2023 05:18:51 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=MHKC2O5Ca6zwOFezTeDj0xpV/G/veq0lBWgAS7sp7fc=; b=NnEF+HzEFwHy0odA+tpd9q+epApnrA1CRaZRchSp9+XxBfRtN7FXR4L9GqjMwcazoaLr z4b7eBhcCRDBZ0y0OuWkbQ6jPYvU2pMi5yCcU6mbt/LUvAlIX7YJrguRD9k0Ilt70NqK RbFY6lmzrHr44A3uiUfCGk8Ve46MMpl07Fsdv9tqAjYx620Z7Ooqj/T5mqdX5D76GttN fk2zLJuuwT6POKwveHPLlcq25J5viKByORNXD1C8LR27QX8z4VAYqjFQpKu/ynecX+sI XRvyrC0kZaMpBfDFBJ4qzFR1q5RQlXkfaQLl89+bNWf4PLRlcuQSVtu/vd4M0nQG3SHJ bg== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3s82wx892b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 03 Aug 2023 05:18:51 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3735Io5q025555 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 3 Aug 2023 05:18:50 GMT Received: from linyyuan-gv.qualcomm.com (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Wed, 2 Aug 2023 22:18:48 -0700 From: Linyu Yuan To: Greg Kroah-Hartman CC: , Linyu Yuan Subject: [PATCH 1/7] usb: gadget: f_ecm: fix ecm_bitrate() for SuperSpeed and above Date: Thu, 3 Aug 2023 13:18:04 +0800 Message-ID: <20230803051810.2974-2-quic_linyyuan@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230803051810.2974-1-quic_linyyuan@quicinc.com> References: <20230803051810.2974-1-quic_linyyuan@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: yRAjCyJ3I_iLjlifRn1ul0-yKRbaWCwy X-Proofpoint-GUID: yRAjCyJ3I_iLjlifRn1ul0-yKRbaWCwy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-03_02,2023-08-01_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 spamscore=0 lowpriorityscore=0 impostorscore=0 adultscore=0 mlxscore=0 bulkscore=0 priorityscore=1501 mlxlogscore=613 phishscore=0 clxscore=1015 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308030048 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org In function ecm_bitrate(), it is not good to report same speed as super speed when gadget work at super speed plus. Change report speed same as commit 986499b1569a ("usb: gadget: f_ncm: fix ncm_bitrate for SuperSpeed and above."). Signed-off-by: Linyu Yuan --- drivers/usb/gadget/function/f_ecm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/function/f_ecm.c b/drivers/usb/gadget/function/f_ecm.c index c6e63ad77a40..8da7d314602c 100644 --- a/drivers/usb/gadget/function/f_ecm.c +++ b/drivers/usb/gadget/function/f_ecm.c @@ -68,8 +68,10 @@ static inline struct f_ecm *func_to_ecm(struct usb_function *f) /* peak (theoretical) bulk transfer rate in bits-per-second */ static inline unsigned ecm_bitrate(struct usb_gadget *g) { - if (gadget_is_superspeed(g) && g->speed == USB_SPEED_SUPER) - return 13 * 1024 * 8 * 1000 * 8; + if (gadget_is_superspeed(g) && g->speed >= USB_SPEED_SUPER_PLUS) + return 4250000000U; + else if (gadget_is_superspeed(g) && g->speed == USB_SPEED_SUPER) + return 3750000000U; else if (gadget_is_dualspeed(g) && g->speed == USB_SPEED_HIGH) return 13 * 512 * 8 * 1000 * 8; else From patchwork Thu Aug 3 05:18:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linyu Yuan X-Patchwork-Id: 710823 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 7E2BDEB64DD for ; Thu, 3 Aug 2023 05:20:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232418AbjHCFUg (ORCPT ); Thu, 3 Aug 2023 01:20:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232662AbjHCFT4 (ORCPT ); Thu, 3 Aug 2023 01:19:56 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43713422F for ; Wed, 2 Aug 2023 22:19:20 -0700 (PDT) Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3734HQ6D021632; Thu, 3 Aug 2023 05:19:17 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=922iD0fp4GbdaiDh3bA05K9id+fDvD+QoW67nPw2mVk=; b=o9Rh4YuaD+cShBYuRC3C3Rva/W6OLmRCmYgCOleiPUTKV3uM9En+dOy5TitrNEt90gqz bFN9ii/8nX2UunhG6pOgTlsjtM7lyngGAAQ2M2eTcNYo3l7UsRm5Wbw49Big5xpQIuDC WNOzDF5vkDw3l0duX8t9y/qMpmCIRz6GTHlfKgVoH+xAIPZwGouMOl/VNU3xHiawy1AP IpZQq5TRL/RWD9Gq7oUKibskX9dkYr+JUcn3BFeX0cv48CvcI3+adQhfOy8a6Wn3iEd+ JHnfXOJ46+VTnarxBnkgQIGmxJbaDMds7jeJUDF2I/rkjYlLSVAQ0fQCMzL2IxleOMjY rg== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3s7upp12um-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 03 Aug 2023 05:19:17 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3735Ipdp025565 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 3 Aug 2023 05:18:51 GMT Received: from linyyuan-gv.qualcomm.com (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Wed, 2 Aug 2023 22:18:50 -0700 From: Linyu Yuan To: Greg Kroah-Hartman CC: , Linyu Yuan Subject: [PATCH 2/7] usb: gaget: use working speed to calcaulate network bitrate and qlen Date: Thu, 3 Aug 2023 13:18:05 +0800 Message-ID: <20230803051810.2974-3-quic_linyyuan@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230803051810.2974-1-quic_linyyuan@quicinc.com> References: <20230803051810.2974-1-quic_linyyuan@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: 4jL2c9i-JFyaT5F6WuPiFOKI4-3PIQqQ X-Proofpoint-ORIG-GUID: 4jL2c9i-JFyaT5F6WuPiFOKI4-3PIQqQ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-03_02,2023-08-01_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 clxscore=1015 malwarescore=0 spamscore=0 lowpriorityscore=0 mlxlogscore=417 bulkscore=0 impostorscore=0 priorityscore=1501 adultscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308030048 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Take ecm_bitrate() as example, it will be called after gadget device link speed negotiation, consider code if (gadget_is_superspeed(g) && g->speed >= USB_SPEED_SUPER_PLUS), if a gadget device link speed is USB_SPEED_SUPER_PLUS, gadget_is_superspeed(g) must be true, or not it is cleary wrong configuration of gadget max support speed. Remove gadget_is_superspeed(g) checking should be safe, and remove other similar operation in ncm, rndis, u_ether. Signed-off-by: Linyu Yuan --- drivers/usb/gadget/function/f_ecm.c | 6 +++--- drivers/usb/gadget/function/f_ncm.c | 6 +++--- drivers/usb/gadget/function/f_rndis.c | 6 +++--- drivers/usb/gadget/function/u_ether.c | 5 ++--- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/usb/gadget/function/f_ecm.c b/drivers/usb/gadget/function/f_ecm.c index 8da7d314602c..b1cb944559d4 100644 --- a/drivers/usb/gadget/function/f_ecm.c +++ b/drivers/usb/gadget/function/f_ecm.c @@ -68,11 +68,11 @@ static inline struct f_ecm *func_to_ecm(struct usb_function *f) /* peak (theoretical) bulk transfer rate in bits-per-second */ static inline unsigned ecm_bitrate(struct usb_gadget *g) { - if (gadget_is_superspeed(g) && g->speed >= USB_SPEED_SUPER_PLUS) + if (g->speed >= USB_SPEED_SUPER_PLUS) return 4250000000U; - else if (gadget_is_superspeed(g) && g->speed == USB_SPEED_SUPER) + else if (g->speed == USB_SPEED_SUPER) return 3750000000U; - else if (gadget_is_dualspeed(g) && g->speed == USB_SPEED_HIGH) + else if (g->speed == USB_SPEED_HIGH) return 13 * 512 * 8 * 1000 * 8; else return 19 * 64 * 1 * 1000 * 8; diff --git a/drivers/usb/gadget/function/f_ncm.c b/drivers/usb/gadget/function/f_ncm.c index 424bb3b666db..e6dac5510540 100644 --- a/drivers/usb/gadget/function/f_ncm.c +++ b/drivers/usb/gadget/function/f_ncm.c @@ -85,11 +85,11 @@ static inline unsigned ncm_bitrate(struct usb_gadget *g) { if (!g) return 0; - else if (gadget_is_superspeed(g) && g->speed >= USB_SPEED_SUPER_PLUS) + else if (g->speed >= USB_SPEED_SUPER_PLUS) return 4250000000U; - else if (gadget_is_superspeed(g) && g->speed == USB_SPEED_SUPER) + else if (g->speed == USB_SPEED_SUPER) return 3750000000U; - else if (gadget_is_dualspeed(g) && g->speed == USB_SPEED_HIGH) + else if (g->speed == USB_SPEED_HIGH) return 13 * 512 * 8 * 1000 * 8; else return 19 * 64 * 1 * 1000 * 8; diff --git a/drivers/usb/gadget/function/f_rndis.c b/drivers/usb/gadget/function/f_rndis.c index ee95e8f5f9d4..eff5d7cbce00 100644 --- a/drivers/usb/gadget/function/f_rndis.c +++ b/drivers/usb/gadget/function/f_rndis.c @@ -87,11 +87,11 @@ static inline struct f_rndis *func_to_rndis(struct usb_function *f) /* peak (theoretical) bulk transfer rate in bits-per-second */ static unsigned int bitrate(struct usb_gadget *g) { - if (gadget_is_superspeed(g) && g->speed >= USB_SPEED_SUPER_PLUS) + if (g->speed >= USB_SPEED_SUPER_PLUS) return 4250000000U; - if (gadget_is_superspeed(g) && g->speed == USB_SPEED_SUPER) + if (g->speed == USB_SPEED_SUPER) return 3750000000U; - else if (gadget_is_dualspeed(g) && g->speed == USB_SPEED_HIGH) + else if (g->speed == USB_SPEED_HIGH) return 13 * 512 * 8 * 1000 * 8; else return 19 * 64 * 1 * 1000 * 8; diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c index a366abb45623..4bb0553da658 100644 --- a/drivers/usb/gadget/function/u_ether.c +++ b/drivers/usb/gadget/function/u_ether.c @@ -93,11 +93,10 @@ struct eth_dev { #define DEFAULT_QLEN 2 /* double buffering by default */ -/* for dual-speed hardware, use deeper queues at high/super speed */ +/* use deeper queues at high/super speed */ static inline int qlen(struct usb_gadget *gadget, unsigned qmult) { - if (gadget_is_dualspeed(gadget) && (gadget->speed == USB_SPEED_HIGH || - gadget->speed >= USB_SPEED_SUPER)) + if (gadget->speed == USB_SPEED_HIGH || gadget->speed >= USB_SPEED_SUPER) return qmult * DEFAULT_QLEN; else return DEFAULT_QLEN; From patchwork Thu Aug 3 05:18:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linyu Yuan X-Patchwork-Id: 710187 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 EDC43C41513 for ; Thu, 3 Aug 2023 05:19:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232394AbjHCFTB (ORCPT ); Thu, 3 Aug 2023 01:19:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231909AbjHCFS4 (ORCPT ); Thu, 3 Aug 2023 01:18:56 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83B661B4 for ; Wed, 2 Aug 2023 22:18:55 -0700 (PDT) Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3733qsLC015505; Thu, 3 Aug 2023 05:18:54 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=RhYsP5sxHehKatYLFPs9z+3WxMJnATus3xr70JAT1Kg=; b=TH1mqgF2ZkGae3l8f2D6VrqsKiMYjI5DMaFkwyXTeIknp0FWY7xaJ08b0jyRXCrQKd2n CxjfmJ6T1WIlooBbaFMERt8IgtMcnmjXfDKdvJr1HkB74X64J1XXAhp9XJdkdyB3KEOY kw1smb60QPx4LuH1+/Ya3vKSkpPlCQPJxnxRocfaiZbaJvh2VViAAN4m2GvinPDQGXuE LmXz0LmJE36j9rcbNvlR0Mn+3SGesLpq5Rl54Ib0qNkyh8RvaD0RuxrUa3wxUEy/CLwd hrxDmsjShVAq0ybC0a0/vP+wf9Nt7iDNH7AH9ceLg6Dp8paI4GEn7hcx1jWSnI0uIGPS MQ== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3s7fre33pm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 03 Aug 2023 05:18:54 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3735IqMK006266 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 3 Aug 2023 05:18:52 GMT Received: from linyyuan-gv.qualcomm.com (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Wed, 2 Aug 2023 22:18:51 -0700 From: Linyu Yuan To: Greg Kroah-Hartman CC: , Linyu Yuan Subject: [PATCH 3/7] usb: gadget: f_uvc: change endpoint allocation in uvc_function_bind() Date: Thu, 3 Aug 2023 13:18:06 +0800 Message-ID: <20230803051810.2974-4-quic_linyyuan@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230803051810.2974-1-quic_linyyuan@quicinc.com> References: <20230803051810.2974-1-quic_linyyuan@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: NLGVcD_mtX2XfTOuNisiZCYkg-aMJG6P X-Proofpoint-ORIG-GUID: NLGVcD_mtX2XfTOuNisiZCYkg-aMJG6P X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-03_02,2023-08-01_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 priorityscore=1501 impostorscore=0 phishscore=0 clxscore=1015 mlxlogscore=283 bulkscore=0 lowpriorityscore=0 mlxscore=0 adultscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308030048 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org when call uvc_function_bind(), gadget still have no connection speed, just follow other gadget function, use fs endpoint descriptor to allocate a video endpoint, remove gadget_is_{super|dual}speed() API call. Signed-off-by: Linyu Yuan --- drivers/usb/gadget/function/f_uvc.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c index 5e919fb65833..c8e149f8315f 100644 --- a/drivers/usb/gadget/function/f_uvc.c +++ b/drivers/usb/gadget/function/f_uvc.c @@ -719,21 +719,13 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f) } uvc->enable_interrupt_ep = opts->enable_interrupt_ep; - if (gadget_is_superspeed(c->cdev->gadget)) - ep = usb_ep_autoconfig_ss(cdev->gadget, &uvc_ss_streaming_ep, - &uvc_ss_streaming_comp); - else if (gadget_is_dualspeed(cdev->gadget)) - ep = usb_ep_autoconfig(cdev->gadget, &uvc_hs_streaming_ep); - else - ep = usb_ep_autoconfig(cdev->gadget, &uvc_fs_streaming_ep); - + ep = usb_ep_autoconfig(cdev->gadget, &uvc_fs_streaming_ep); if (!ep) { uvcg_info(f, "Unable to allocate streaming EP\n"); goto error; } uvc->video.ep = ep; - uvc_fs_streaming_ep.bEndpointAddress = uvc->video.ep->address; uvc_hs_streaming_ep.bEndpointAddress = uvc->video.ep->address; uvc_ss_streaming_ep.bEndpointAddress = uvc->video.ep->address; From patchwork Thu Aug 3 05:18:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linyu Yuan X-Patchwork-Id: 710186 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 1E0D4C001DF for ; Thu, 3 Aug 2023 05:19:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232665AbjHCFT1 (ORCPT ); Thu, 3 Aug 2023 01:19:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232418AbjHCFTQ (ORCPT ); Thu, 3 Aug 2023 01:19:16 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B921B3A8D for ; Wed, 2 Aug 2023 22:19:02 -0700 (PDT) Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3733PcCO022218; Thu, 3 Aug 2023 05:19:00 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=aXD+C7rsOZOpQUtRLtjBxOQGRNNvzmKnuHC3UxPYmGE=; b=Q2O/lj/BO9MUTMaQGRAyFk38uFpVqQNtLt5Cmbnpjk7Xt3yKyd0hq8patDUwceJiuDyc nsV4mF0uRdQgha/sC/kMJQlBNdFWXHT/u56wwvBdizb4bPNn7PzSUv1tGli8oHhjSoP7 Gq4Ra/yPud2+x0NJypIy3JsB40C5Qb5rTcaZpyrVw2S0f5rBl1MqcjyeIs6j4+UJkxYz myduOo/a8CFnVBSVRmFgHqw76RjYSmLxT5zgoLKI5p49v5YUKJkkdMVWYt5vRaMoWQ5+ LskNRW+nwHc+c4fv6ifhml9PNCvgwYxvxZ9QLMRNJLx7yFxAGrskJQr5EwqqBb6mFcrz fw== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3s75dgc6ab-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 03 Aug 2023 05:19:00 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3735Isfa006287 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 3 Aug 2023 05:18:55 GMT Received: from linyyuan-gv.qualcomm.com (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Wed, 2 Aug 2023 22:18:52 -0700 From: Linyu Yuan To: Greg Kroah-Hartman CC: , Linyu Yuan Subject: [PATCH 4/7] usb: gadget: unconditionally allocate hs/ss descriptor in bind operation Date: Thu, 3 Aug 2023 13:18:07 +0800 Message-ID: <20230803051810.2974-5-quic_linyyuan@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230803051810.2974-1-quic_linyyuan@quicinc.com> References: <20230803051810.2974-1-quic_linyyuan@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: jxiUjK2VlBEcc_hNe-eRNDtZRQZHA9MY X-Proofpoint-ORIG-GUID: jxiUjK2VlBEcc_hNe-eRNDtZRQZHA9MY X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-03_02,2023-08-01_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 phishscore=0 priorityscore=1501 clxscore=1015 malwarescore=0 suspectscore=0 bulkscore=0 adultscore=0 impostorscore=0 spamscore=0 mlxlogscore=271 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308030048 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Take f_midi_bind() for example, when composite layer call it, it will allocate hs descriptor by calling gadget_is_dualspeed() API to check gadget max support speed capability, but most other gadget function didn't do like this. To follow other function drivers, it is safe to remove the check which mean support all possible link speed by default in function driver. Similar change apply to midi2 and uvc. Also in midi and midi2, as there is no descriptor difference between super speed and super speed plus, follow other gadget function drivers, do not allocate descriptor for super speed plus, composite layer will handle it properly. Signed-off-by: Linyu Yuan --- drivers/usb/gadget/function/f_midi.c | 56 +++++++++++---------------- drivers/usb/gadget/function/f_midi2.c | 44 ++++++++------------- drivers/usb/gadget/function/f_uvc.c | 26 ++++++------- 3 files changed, 51 insertions(+), 75 deletions(-) diff --git a/drivers/usb/gadget/function/f_midi.c b/drivers/usb/gadget/function/f_midi.c index fddf539008a9..2d02f25f9597 100644 --- a/drivers/usb/gadget/function/f_midi.c +++ b/drivers/usb/gadget/function/f_midi.c @@ -1023,40 +1023,30 @@ static int f_midi_bind(struct usb_configuration *c, struct usb_function *f) if (!f->fs_descriptors) goto fail_f_midi; - if (gadget_is_dualspeed(c->cdev->gadget)) { - bulk_in_desc.wMaxPacketSize = cpu_to_le16(512); - bulk_out_desc.wMaxPacketSize = cpu_to_le16(512); - f->hs_descriptors = usb_copy_descriptors(midi_function); - if (!f->hs_descriptors) - goto fail_f_midi; - } + bulk_in_desc.wMaxPacketSize = cpu_to_le16(512); + bulk_out_desc.wMaxPacketSize = cpu_to_le16(512); + f->hs_descriptors = usb_copy_descriptors(midi_function); + if (!f->hs_descriptors) + goto fail_f_midi; - if (gadget_is_superspeed(c->cdev->gadget)) { - bulk_in_desc.wMaxPacketSize = cpu_to_le16(1024); - bulk_out_desc.wMaxPacketSize = cpu_to_le16(1024); - i = endpoint_descriptor_index; - midi_function[i++] = (struct usb_descriptor_header *) - &bulk_out_desc; - midi_function[i++] = (struct usb_descriptor_header *) - &bulk_out_ss_comp_desc; - midi_function[i++] = (struct usb_descriptor_header *) - &ms_out_desc; - midi_function[i++] = (struct usb_descriptor_header *) - &bulk_in_desc; - midi_function[i++] = (struct usb_descriptor_header *) - &bulk_in_ss_comp_desc; - midi_function[i++] = (struct usb_descriptor_header *) - &ms_in_desc; - f->ss_descriptors = usb_copy_descriptors(midi_function); - if (!f->ss_descriptors) - goto fail_f_midi; - - if (gadget_is_superspeed_plus(c->cdev->gadget)) { - f->ssp_descriptors = usb_copy_descriptors(midi_function); - if (!f->ssp_descriptors) - goto fail_f_midi; - } - } + bulk_in_desc.wMaxPacketSize = cpu_to_le16(1024); + bulk_out_desc.wMaxPacketSize = cpu_to_le16(1024); + i = endpoint_descriptor_index; + midi_function[i++] = (struct usb_descriptor_header *) + &bulk_out_desc; + midi_function[i++] = (struct usb_descriptor_header *) + &bulk_out_ss_comp_desc; + midi_function[i++] = (struct usb_descriptor_header *) + &ms_out_desc; + midi_function[i++] = (struct usb_descriptor_header *) + &bulk_in_desc; + midi_function[i++] = (struct usb_descriptor_header *) + &bulk_in_ss_comp_desc; + midi_function[i++] = (struct usb_descriptor_header *) + &ms_in_desc; + f->ss_descriptors = usb_copy_descriptors(midi_function); + if (!f->ss_descriptors) + goto fail_f_midi; kfree(midi_function); diff --git a/drivers/usb/gadget/function/f_midi2.c b/drivers/usb/gadget/function/f_midi2.c index 5a971ba600fe..ec8cd7c7bbfc 100644 --- a/drivers/usb/gadget/function/f_midi2.c +++ b/drivers/usb/gadget/function/f_midi2.c @@ -1731,7 +1731,6 @@ static int f_midi2_create_usb_configs(struct f_midi2 *midi2, midi1_out_eps = midi2_midi1_ep_out_descs; break; case USB_SPEED_SUPER: - case USB_SPEED_SUPER_PLUS: midi2_midi1_ep_out_desc.wMaxPacketSize = cpu_to_le16(1024); midi2_midi1_ep_in_desc.wMaxPacketSize = cpu_to_le16(1024); for (i = 0; i < midi2->num_eps; i++) @@ -2001,36 +2000,25 @@ static int f_midi2_bind(struct usb_configuration *c, struct usb_function *f) } f_midi2_free_usb_configs(&config); - if (gadget_is_dualspeed(midi2->gadget)) { - status = f_midi2_create_usb_configs(midi2, &config, USB_SPEED_HIGH); - if (status < 0) - goto fail; - f->hs_descriptors = usb_copy_descriptors(config.list); - if (!f->hs_descriptors) { - status = -ENOMEM; - goto fail; - } - f_midi2_free_usb_configs(&config); + status = f_midi2_create_usb_configs(midi2, &config, USB_SPEED_HIGH); + if (status < 0) + goto fail; + f->hs_descriptors = usb_copy_descriptors(config.list); + if (!f->hs_descriptors) { + status = -ENOMEM; + goto fail; } + f_midi2_free_usb_configs(&config); - if (gadget_is_superspeed(midi2->gadget)) { - status = f_midi2_create_usb_configs(midi2, &config, USB_SPEED_SUPER); - if (status < 0) - goto fail; - f->ss_descriptors = usb_copy_descriptors(config.list); - if (!f->ss_descriptors) { - status = -ENOMEM; - goto fail; - } - if (gadget_is_superspeed_plus(midi2->gadget)) { - f->ssp_descriptors = usb_copy_descriptors(config.list); - if (!f->ssp_descriptors) { - status = -ENOMEM; - goto fail; - } - } - f_midi2_free_usb_configs(&config); + status = f_midi2_create_usb_configs(midi2, &config, USB_SPEED_SUPER); + if (status < 0) + goto fail; + f->ss_descriptors = usb_copy_descriptors(config.list); + if (!f->ss_descriptors) { + status = -ENOMEM; + goto fail; } + f_midi2_free_usb_configs(&config); mutex_unlock(&f_midi2_desc_mutex); return 0; diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c index c8e149f8315f..faa398109431 100644 --- a/drivers/usb/gadget/function/f_uvc.c +++ b/drivers/usb/gadget/function/f_uvc.c @@ -780,21 +780,19 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f) f->fs_descriptors = NULL; goto error; } - if (gadget_is_dualspeed(cdev->gadget)) { - f->hs_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_HIGH); - if (IS_ERR(f->hs_descriptors)) { - ret = PTR_ERR(f->hs_descriptors); - f->hs_descriptors = NULL; - goto error; - } + + f->hs_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_HIGH); + if (IS_ERR(f->hs_descriptors)) { + ret = PTR_ERR(f->hs_descriptors); + f->hs_descriptors = NULL; + goto error; } - if (gadget_is_superspeed(c->cdev->gadget)) { - f->ss_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_SUPER); - if (IS_ERR(f->ss_descriptors)) { - ret = PTR_ERR(f->ss_descriptors); - f->ss_descriptors = NULL; - goto error; - } + + f->ss_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_SUPER); + if (IS_ERR(f->ss_descriptors)) { + ret = PTR_ERR(f->ss_descriptors); + f->ss_descriptors = NULL; + goto error; } /* Preallocate control endpoint request. */ From patchwork Thu Aug 3 05:18:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linyu Yuan X-Patchwork-Id: 710825 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 8F5F2EB64DD for ; Thu, 3 Aug 2023 05:19:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232457AbjHCFTN (ORCPT ); Thu, 3 Aug 2023 01:19:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231909AbjHCFTI (ORCPT ); Thu, 3 Aug 2023 01:19:08 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FAD93582 for ; Wed, 2 Aug 2023 22:18:58 -0700 (PDT) Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3732hCZ4006422; Thu, 3 Aug 2023 05:18:57 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=fStjR+Kyu92pwdIYQfxnCNhvTg+51yYHAY5pRCDHHXY=; b=k6t/B9BbXoteSpuoNv4MQKQkkWCTS1NNY1SiJGa1Pe+5IUE5AsLF7l7DZm7rxf9zNCMi r6jYl1eILQXx2c8+c8V0ceZKMDtlr6LU0qsQC84G+N9wUWZBUpQx22unHeU/qLoVI6TM +Z1rE5l9cJeg2S11gFu+nfMQVPXrWemQOfCGfRbKzVqDzb9zKNUXfPI8GSs1HjeYH7Cc DjqnuCIGbAsR9WlSOiEe0ME4qTwKId/O37wEx2fdXmwXMpJ+LU9ES8XjnFrYm9ydRrWC svMddFGwHuAaKCs7yUnWhUriojxvfiNOrWMXmyTWrdbTA6JqX+itdgwqTDQ2STaY5TyO lQ== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3s82wx892g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 03 Aug 2023 05:18:57 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3735Isfb006287 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 3 Aug 2023 05:18:55 GMT Received: from linyyuan-gv.qualcomm.com (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Wed, 2 Aug 2023 22:18:54 -0700 From: Linyu Yuan To: Greg Kroah-Hartman CC: , Linyu Yuan Subject: [PATCH 5/7] usb: gadget: config: remove max speed check in usb_assign_descriptors() Date: Thu, 3 Aug 2023 13:18:08 +0800 Message-ID: <20230803051810.2974-6-quic_linyyuan@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230803051810.2974-1-quic_linyyuan@quicinc.com> References: <20230803051810.2974-1-quic_linyyuan@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: 125MAu7GbpaFa0bc0YO88W5rHD-ANWyf X-Proofpoint-GUID: 125MAu7GbpaFa0bc0YO88W5rHD-ANWyf X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-03_02,2023-08-01_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 spamscore=0 lowpriorityscore=0 impostorscore=0 adultscore=0 mlxscore=0 bulkscore=0 priorityscore=1501 mlxlogscore=595 phishscore=0 clxscore=1015 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308030048 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org usb_assign_descriptors() usally called inside function bind operation, and gadget still have no working connection speed, let's support all speed at this point, it may possible allocate extra memory to store descriptors, but it is small and acceptable. Remove gadget_is_{*}speed() API checking to allow support all speed. Signed-off-by: Linyu Yuan --- drivers/usb/gadget/config.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c index 05507606b2b4..b1f625245713 100644 --- a/drivers/usb/gadget/config.c +++ b/drivers/usb/gadget/config.c @@ -162,8 +162,6 @@ int usb_assign_descriptors(struct usb_function *f, struct usb_descriptor_header **ss, struct usb_descriptor_header **ssp) { - struct usb_gadget *g = f->config->cdev->gadget; - /* super-speed-plus descriptor falls back to super-speed one, * if such a descriptor was provided, thus avoiding a NULL * pointer dereference if a 5gbps capable gadget is used with @@ -177,17 +175,17 @@ int usb_assign_descriptors(struct usb_function *f, if (!f->fs_descriptors) goto err; } - if (hs && gadget_is_dualspeed(g)) { + if (hs) { f->hs_descriptors = usb_copy_descriptors(hs); if (!f->hs_descriptors) goto err; } - if (ss && gadget_is_superspeed(g)) { + if (ss) { f->ss_descriptors = usb_copy_descriptors(ss); if (!f->ss_descriptors) goto err; } - if (ssp && gadget_is_superspeed_plus(g)) { + if (ssp) { f->ssp_descriptors = usb_copy_descriptors(ssp); if (!f->ssp_descriptors) goto err; From patchwork Thu Aug 3 05:18:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linyu Yuan X-Patchwork-Id: 710185 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 B35CDC04A6A for ; Thu, 3 Aug 2023 05:19:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232481AbjHCFTw (ORCPT ); Thu, 3 Aug 2023 01:19:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232659AbjHCFT0 (ORCPT ); Thu, 3 Aug 2023 01:19:26 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DE1A3C3A for ; Wed, 2 Aug 2023 22:19:06 -0700 (PDT) Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3735GGwU014004; Thu, 3 Aug 2023 05:19:04 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=n7zPuMulRoXm6vdnssx/oJcawQOWpeKCED1X/4IRxb0=; b=CuhgO3zsaxGNbjZL/Or1Z4kzK7+aD8wR6htsW4CoTf5QAJuFD5IB9wm1toKiStZpV7VR m/wq7RaFv/aJEjcxo9RVuRT36cHDlnzM/nMsmhdCYqxWt8U9abh8fj5BBlZ+c82RG4UQ 3hrYU2JzXBhpPeHDvAK8wyTAYOIr/DzR0w/g1UhjEWOYiwh1liLc9U6Queq1UbwenPmv QUxIg4Fl32YER2eN32TSLP/xfqGc1USV21O2F9xVKe005rt/ZLUIji/j8zJB/+the2l9 6abOJQ9y3aGpxQPPFO2jFY6tUbS8ZUG5bdvXYUcTLD1Re7aL6HZ2uQ0inar+hnbwy2OK ng== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3s7sgnhbgn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 03 Aug 2023 05:19:04 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3735Iuw0007313 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 3 Aug 2023 05:18:56 GMT Received: from linyyuan-gv.qualcomm.com (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Wed, 2 Aug 2023 22:18:55 -0700 From: Linyu Yuan To: Greg Kroah-Hartman CC: , Linyu Yuan Subject: [PATCH 6/7] usb: gadget: composite: cleanup function config_ep_by_speed_and_alt() Date: Thu, 3 Aug 2023 13:18:09 +0800 Message-ID: <20230803051810.2974-7-quic_linyyuan@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230803051810.2974-1-quic_linyyuan@quicinc.com> References: <20230803051810.2974-1-quic_linyyuan@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: 1Tt89mZIA6_lX3pT3MGhznYULVCCERE9 X-Proofpoint-GUID: 1Tt89mZIA6_lX3pT3MGhznYULVCCERE9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-03_03,2023-08-01_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 lowpriorityscore=0 spamscore=0 mlxscore=0 mlxlogscore=673 priorityscore=1501 impostorscore=0 adultscore=0 bulkscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308030048 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org When call this function, gadget already have working speed, if it is USB_SPEED_SUPER_PLUS, in theroy gadget_is_superspeed_plus() checking should be true, so there is no need to call it. it is same for other working speed. Remove all gadget_is_{*}speed_plus() API call to clean it up. Signed-off-by: Linyu Yuan --- drivers/usb/gadget/composite.c | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index dd9b90481b4c..0ace45b66a31 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -170,33 +170,27 @@ int config_ep_by_speed_and_alt(struct usb_gadget *g, /* select desired speed */ switch (g->speed) { case USB_SPEED_SUPER_PLUS: - if (gadget_is_superspeed_plus(g)) { - if (f->ssp_descriptors) { - speed_desc = f->ssp_descriptors; - want_comp_desc = 1; - break; - } - incomplete_desc = true; + if (f->ssp_descriptors) { + speed_desc = f->ssp_descriptors; + want_comp_desc = 1; + break; } + incomplete_desc = true; fallthrough; case USB_SPEED_SUPER: - if (gadget_is_superspeed(g)) { - if (f->ss_descriptors) { - speed_desc = f->ss_descriptors; - want_comp_desc = 1; - break; - } - incomplete_desc = true; + if (f->ss_descriptors) { + speed_desc = f->ss_descriptors; + want_comp_desc = 1; + break; } + incomplete_desc = true; fallthrough; case USB_SPEED_HIGH: - if (gadget_is_dualspeed(g)) { - if (f->hs_descriptors) { - speed_desc = f->hs_descriptors; - break; - } - incomplete_desc = true; + if (f->hs_descriptors) { + speed_desc = f->hs_descriptors; + break; } + incomplete_desc = true; fallthrough; default: speed_desc = f->fs_descriptors; From patchwork Thu Aug 3 05:18:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linyu Yuan X-Patchwork-Id: 710824 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 52082EB64DD for ; Thu, 3 Aug 2023 05:19:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232769AbjHCFTu (ORCPT ); Thu, 3 Aug 2023 01:19:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232400AbjHCFTZ (ORCPT ); Thu, 3 Aug 2023 01:19:25 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A32083C3C for ; Wed, 2 Aug 2023 22:19:06 -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 37357uaW009998; Thu, 3 Aug 2023 05:19:04 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=nI+KfOofYlPleGJYyUj9T95++Dj9KvSzi1rHi0s7t2Q=; b=N0pIWWtc0tdDGPXghKp7xTCoUvNMI+RRtYZnrjnNz/fzbRmGR1O65+sJnCD5Xj+Y+Cso 3LppI4dWuetYEFo7Lji9xv3gMH3YjUWJHV4bGB+WA5E8VkIS9esbVk/pzPIPOBr0elKz mxS2AE5qhQ9myD1rV1Pj/ZLsGscmuJD9p4oqJLY04ZqSRnHD0FsxxXGv0WNrhvpXv1ch 9yxJZS3xS/zPwPAwnWXedbiQ1VJanrgu8FqcXWD5IdFAsiwWxa/eOcx3o9vb1cvJ3WY3 mVc2CKq3u8lYh4l3C37r0FXRpuK7qnEE0sE+s9AkBFyjb1QB5Lwtnrn+IVG/dFve2wNA 3Q== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3s7vxsruxn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 03 Aug 2023 05:19:04 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3735IwwJ025637 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 3 Aug 2023 05:18:58 GMT Received: from linyyuan-gv.qualcomm.com (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Wed, 2 Aug 2023 22:18:57 -0700 From: Linyu Yuan To: Greg Kroah-Hartman CC: , Linyu Yuan Subject: [PATCH 7/7] usb: gadget: remove max support speed info in bind operation Date: Thu, 3 Aug 2023 13:18:10 +0800 Message-ID: <20230803051810.2974-8-quic_linyyuan@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230803051810.2974-1-quic_linyyuan@quicinc.com> References: <20230803051810.2974-1-quic_linyyuan@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: 7FhWclbkQeP0lBlnWWaGWhD8fKVRtYOe X-Proofpoint-GUID: 7FhWclbkQeP0lBlnWWaGWhD8fKVRtYOe X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-03_02,2023-08-01_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 suspectscore=0 adultscore=0 priorityscore=1501 clxscore=1015 malwarescore=0 bulkscore=0 mlxlogscore=712 phishscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308030048 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Take ecm_bind() for example, it call gadget_is_{*}speed() API to show gadget max support speed, it is not much help, remove the API usage here is safe. Similar change apply to acm,eem,loopback,ncm,obex,rndis,serial, sourcesink,subset functions. Signed-off-by: Linyu Yuan --- drivers/usb/gadget/function/f_acm.c | 4 +--- drivers/usb/gadget/function/f_ecm.c | 4 +--- drivers/usb/gadget/function/f_eem.c | 4 +--- drivers/usb/gadget/function/f_loopback.c | 4 +--- drivers/usb/gadget/function/f_ncm.c | 4 +--- drivers/usb/gadget/function/f_obex.c | 3 +-- drivers/usb/gadget/function/f_rndis.c | 4 +--- drivers/usb/gadget/function/f_serial.c | 4 +--- drivers/usb/gadget/function/f_sourcesink.c | 4 +--- drivers/usb/gadget/function/f_subset.c | 4 +--- 10 files changed, 10 insertions(+), 29 deletions(-) diff --git a/drivers/usb/gadget/function/f_acm.c b/drivers/usb/gadget/function/f_acm.c index cb523f118f04..f616059c5e1e 100644 --- a/drivers/usb/gadget/function/f_acm.c +++ b/drivers/usb/gadget/function/f_acm.c @@ -691,10 +691,8 @@ acm_bind(struct usb_configuration *c, struct usb_function *f) goto fail; dev_dbg(&cdev->gadget->dev, - "acm ttyGS%d: %s speed IN/%s OUT/%s NOTIFY/%s\n", + "acm ttyGS%d: IN/%s OUT/%s NOTIFY/%s\n", acm->port_num, - gadget_is_superspeed(c->cdev->gadget) ? "super" : - gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full", acm->port.in->name, acm->port.out->name, acm->notify->name); return 0; diff --git a/drivers/usb/gadget/function/f_ecm.c b/drivers/usb/gadget/function/f_ecm.c index b1cb944559d4..28ee1029a212 100644 --- a/drivers/usb/gadget/function/f_ecm.c +++ b/drivers/usb/gadget/function/f_ecm.c @@ -801,9 +801,7 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f) ecm->port.open = ecm_open; ecm->port.close = ecm_close; - DBG(cdev, "CDC Ethernet: %s speed IN/%s OUT/%s NOTIFY/%s\n", - gadget_is_superspeed(c->cdev->gadget) ? "super" : - gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full", + DBG(cdev, "CDC Ethernet: IN/%s OUT/%s NOTIFY/%s\n", ecm->port.in_ep->name, ecm->port.out_ep->name, ecm->notify->name); return 0; diff --git a/drivers/usb/gadget/function/f_eem.c b/drivers/usb/gadget/function/f_eem.c index 5d38f29bda72..3b445bd88498 100644 --- a/drivers/usb/gadget/function/f_eem.c +++ b/drivers/usb/gadget/function/f_eem.c @@ -311,9 +311,7 @@ static int eem_bind(struct usb_configuration *c, struct usb_function *f) if (status) goto fail; - DBG(cdev, "CDC Ethernet (EEM): %s speed IN/%s OUT/%s\n", - gadget_is_superspeed(c->cdev->gadget) ? "super" : - gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full", + DBG(cdev, "CDC Ethernet (EEM): IN/%s OUT/%s\n", eem->port.in_ep->name, eem->port.out_ep->name); return 0; diff --git a/drivers/usb/gadget/function/f_loopback.c b/drivers/usb/gadget/function/f_loopback.c index ae41f556eb75..17ac6ace0cff 100644 --- a/drivers/usb/gadget/function/f_loopback.c +++ b/drivers/usb/gadget/function/f_loopback.c @@ -211,9 +211,7 @@ static int loopback_bind(struct usb_configuration *c, struct usb_function *f) if (ret) return ret; - DBG(cdev, "%s speed %s: IN/%s, OUT/%s\n", - (gadget_is_superspeed(c->cdev->gadget) ? "super" : - (gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full")), + DBG(cdev, "%s: IN/%s, OUT/%s\n", f->name, loop->in_ep->name, loop->out_ep->name); return 0; } diff --git a/drivers/usb/gadget/function/f_ncm.c b/drivers/usb/gadget/function/f_ncm.c index e6dac5510540..433d278e40ff 100644 --- a/drivers/usb/gadget/function/f_ncm.c +++ b/drivers/usb/gadget/function/f_ncm.c @@ -1544,9 +1544,7 @@ static int ncm_bind(struct usb_configuration *c, struct usb_function *f) hrtimer_init(&ncm->task_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_SOFT); ncm->task_timer.function = ncm_tx_timeout; - DBG(cdev, "CDC Network: %s speed IN/%s OUT/%s NOTIFY/%s\n", - gadget_is_superspeed(c->cdev->gadget) ? "super" : - gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full", + DBG(cdev, "CDC Network: IN/%s OUT/%s NOTIFY/%s\n", ncm->port.in_ep->name, ncm->port.out_ep->name, ncm->notify->name); return 0; diff --git a/drivers/usb/gadget/function/f_obex.c b/drivers/usb/gadget/function/f_obex.c index ab26d84ed95e..dcb093210305 100644 --- a/drivers/usb/gadget/function/f_obex.c +++ b/drivers/usb/gadget/function/f_obex.c @@ -365,9 +365,8 @@ static int obex_bind(struct usb_configuration *c, struct usb_function *f) if (status) goto fail; - dev_dbg(&cdev->gadget->dev, "obex ttyGS%d: %s speed IN/%s OUT/%s\n", + dev_dbg(&cdev->gadget->dev, "obex ttyGS%d: IN/%s OUT/%s\n", obex->port_num, - gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full", obex->port.in->name, obex->port.out->name); return 0; diff --git a/drivers/usb/gadget/function/f_rndis.c b/drivers/usb/gadget/function/f_rndis.c index eff5d7cbce00..f0fa332e679a 100644 --- a/drivers/usb/gadget/function/f_rndis.c +++ b/drivers/usb/gadget/function/f_rndis.c @@ -811,9 +811,7 @@ rndis_bind(struct usb_configuration *c, struct usb_function *f) * until we're activated via set_alt(). */ - DBG(cdev, "RNDIS: %s speed IN/%s OUT/%s NOTIFY/%s\n", - gadget_is_superspeed(c->cdev->gadget) ? "super" : - gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full", + DBG(cdev, "RNDIS: IN/%s OUT/%s NOTIFY/%s\n", rndis->port.in_ep->name, rndis->port.out_ep->name, rndis->notify->name); return 0; diff --git a/drivers/usb/gadget/function/f_serial.c b/drivers/usb/gadget/function/f_serial.c index a9480b9e312e..65c50092aea2 100644 --- a/drivers/usb/gadget/function/f_serial.c +++ b/drivers/usb/gadget/function/f_serial.c @@ -236,10 +236,8 @@ static int gser_bind(struct usb_configuration *c, struct usb_function *f) gser_ss_function, gser_ss_function); if (status) goto fail; - dev_dbg(&cdev->gadget->dev, "generic ttyGS%d: %s speed IN/%s OUT/%s\n", + dev_dbg(&cdev->gadget->dev, "generic ttyGS%d: IN/%s OUT/%s\n", gser->port_num, - gadget_is_superspeed(c->cdev->gadget) ? "super" : - gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full", gser->port.in->name, gser->port.out->name); return 0; diff --git a/drivers/usb/gadget/function/f_sourcesink.c b/drivers/usb/gadget/function/f_sourcesink.c index 6803cd60cc6d..2edbd9b510d6 100644 --- a/drivers/usb/gadget/function/f_sourcesink.c +++ b/drivers/usb/gadget/function/f_sourcesink.c @@ -436,9 +436,7 @@ sourcesink_bind(struct usb_configuration *c, struct usb_function *f) if (ret) return ret; - DBG(cdev, "%s speed %s: IN/%s, OUT/%s, ISO-IN/%s, ISO-OUT/%s\n", - (gadget_is_superspeed(c->cdev->gadget) ? "super" : - (gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full")), + DBG(cdev, "%s: IN/%s, OUT/%s, ISO-IN/%s, ISO-OUT/%s\n", f->name, ss->in_ep->name, ss->out_ep->name, ss->iso_in_ep ? ss->iso_in_ep->name : "", ss->iso_out_ep ? ss->iso_out_ep->name : ""); diff --git a/drivers/usb/gadget/function/f_subset.c b/drivers/usb/gadget/function/f_subset.c index 51c1cae162d9..8ae9689ef2a0 100644 --- a/drivers/usb/gadget/function/f_subset.c +++ b/drivers/usb/gadget/function/f_subset.c @@ -367,9 +367,7 @@ geth_bind(struct usb_configuration *c, struct usb_function *f) * until we're activated via set_alt(). */ - DBG(cdev, "CDC Subset: %s speed IN/%s OUT/%s\n", - gadget_is_superspeed(c->cdev->gadget) ? "super" : - gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full", + DBG(cdev, "CDC Subset: IN/%s OUT/%s\n", geth->port.in_ep->name, geth->port.out_ep->name); return 0;