Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp141655imi; Wed, 20 Jul 2022 19:28:48 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v2j1FOJqc9hPCFA0370q9zcSQZaV7eTIUXOgudEyqrqvicgo0flXfS91i5cQ0mq3DJEP3F X-Received: by 2002:a17:90b:1c0d:b0:1f2:2939:9ad with SMTP id oc13-20020a17090b1c0d00b001f2293909admr2837089pjb.124.1658370528722; Wed, 20 Jul 2022 19:28:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658370528; cv=none; d=google.com; s=arc-20160816; b=ZqErnlaeHDu7WJxiDA33RgLkBk4p3f/e84UhlCACOOauMNQ6bGlDsBYawnBVBcjJib 0IEML2DsLiiEyDhiUT0MAIn/ZKOo5K/5dzZybeSLRV6pF/+vsAJ8f6I5jPo538DaZ3Ic eXyXOl43uxxoX36TLZ1juAddP/J/TjKNXPsxn4shtt8SILQmSoKMrSZgz9JGaCUIDR89 J83kvc7+Q1E0Dy/Kr6C+YamU/dUAaHNY4JLYmv7AtGaVPTND76x1sXslrzkGJb4bFMOE 0qSt+xZN479FqR30Hi2DNoAvp9x6uGNuocbWf6+IDlFp+Bb/ldl0WKAV/ZVIaR87qhew 2S1A== 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=iXMHw5Asl7oU6fyDe5ffouo+oBUrAhNmZtBQxZRHC/I=; b=iUbSMf/Z+hymzX9ycxJYKli/Hek1Gtoy8PWHNeDqMExILjrHGkwVjpab0z19iz5lNt URSHPebjCGGtOQKNE5isENB2Xo/fJkRp91T2HL10QtPsCKDWi4iQpvI2Di/wEbrOgXbK MidxzQ1p/fWPX0FVtkG5o1QVRgZtLeAgCG3rIGNG73OTr4u2h8UDgiL80MR4p/1PjAWU nDnmcYD/nCkFPV6Hnxj8C0VZATS6bSnUKCrs+aBZOMQq0OSXqAskl7noQvfY2ALkjm91 sPjvlyooEUJRTsgi81FpC3nmArnE8u7fs6Gd2YdGp31UP5I1xEC3jCLlLvt3c+AOuDBI XqAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=BLtGR5rj; 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 v186-20020a6389c3000000b0041228c62bc2si581740pgd.457.2022.07.20.19.28.34; Wed, 20 Jul 2022 19:28:48 -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=qcdkim header.b=BLtGR5rj; 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 S230240AbiGUBsb (ORCPT + 99 others); Wed, 20 Jul 2022 21:48:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229510AbiGUBs3 (ORCPT ); Wed, 20 Jul 2022 21:48:29 -0400 Received: from alexa-out-sd-01.qualcomm.com (alexa-out-sd-01.qualcomm.com [199.106.114.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3648C15A14; Wed, 20 Jul 2022 18:48:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1658368108; x=1689904108; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=iXMHw5Asl7oU6fyDe5ffouo+oBUrAhNmZtBQxZRHC/I=; b=BLtGR5rjjCIxVX0Nz7V7djzURA1HCqPBGnQv0/twq2DmpdqDnwSJVSb7 xcatyx5VTrBCDWgl/WbBF1NRSe4QKfAlFYpiq9o75rmaG+4YtRMxohGOi AIxULJBrEggXyrHTg3rE0rlzptI9xf4AcXdsi+BQiemYbMnMD6zmDIPTM U=; Received: from unknown (HELO ironmsg03-sd.qualcomm.com) ([10.53.140.143]) by alexa-out-sd-01.qualcomm.com with ESMTP; 20 Jul 2022 18:48:27 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg03-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2022 18:48:27 -0700 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Wed, 20 Jul 2022 18:48:27 -0700 Received: from jackp-linux.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.22; Wed, 20 Jul 2022 18:48:26 -0700 From: Jack Pham To: Greg KH CC: <3090101217@zju.edu.cn>, , , , , , , , , , Jack Pham Subject: [PATCH v5] usb: gadget: f_uac2: fix superspeed transfer Date: Wed, 20 Jul 2022 18:48:15 -0700 Message-ID: <20220721014815.14453-1-quic_jackp@quicinc.com> X-Mailer: git-send-email 2.24.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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: X-Mailing-List: linux-kernel@vger.kernel.org From: Jing Leng On page 362 of the USB3.2 specification ( https://usb.org/sites/default/files/usb_32_20210125.zip), The 'SuperSpeed Endpoint Companion Descriptor' shall only be returned by Enhanced SuperSpeed devices that are operating at Gen X speed. Each endpoint described in an interface is followed by a 'SuperSpeed Endpoint Companion Descriptor'. If users use SuperSpeed UDC, host can't recognize the device if endpoint doesn't have 'SuperSpeed Endpoint Companion Descriptor' followed. Currently in the uac2 driver code: 1. ss_epout_desc_comp follows ss_epout_desc; 2. ss_epin_fback_desc_comp follows ss_epin_fback_desc; 3. ss_epin_desc_comp follows ss_epin_desc; 4. Only ss_ep_int_desc endpoint doesn't have 'SuperSpeed Endpoint Companion Descriptor' followed, so we should add it. Fixes: eaf6cbe09920 ("usb: gadget: f_uac2: add volume and mute support") Signed-off-by: Jing Leng Signed-off-by: Jack Pham --- v5: Revived from https://lore.kernel.org/linux-usb/20220218095948.4077-1-3090101217@zju.edu.cn/ and rebased on Greg's usb-linus ChangeLog v3->v4: - Add "Fixes:" tag in the changelog area ChangeLog v2->v3: - Remove static variables which are explicitly initialized to 0 - Remove redundant modification "case USB_SPEED_SUPER_PLUS:" ChangeLog v1->v2: - Update more detailed description of the PATCH drivers/usb/gadget/function/f_uac2.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c index 1905a8d8e0c9..08726e4c68a5 100644 --- a/drivers/usb/gadget/function/f_uac2.c +++ b/drivers/usb/gadget/function/f_uac2.c @@ -291,6 +291,12 @@ static struct usb_endpoint_descriptor ss_ep_int_desc = { .bInterval = 4, }; +static struct usb_ss_ep_comp_descriptor ss_ep_int_desc_comp = { + .bLength = sizeof(ss_ep_int_desc_comp), + .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, + .wBytesPerInterval = cpu_to_le16(6), +}; + /* Audio Streaming OUT Interface - Alt0 */ static struct usb_interface_descriptor std_as_out_if0_desc = { .bLength = sizeof std_as_out_if0_desc, @@ -604,7 +610,8 @@ static struct usb_descriptor_header *ss_audio_desc[] = { (struct usb_descriptor_header *)&in_feature_unit_desc, (struct usb_descriptor_header *)&io_out_ot_desc, - (struct usb_descriptor_header *)&ss_ep_int_desc, + (struct usb_descriptor_header *)&ss_ep_int_desc, + (struct usb_descriptor_header *)&ss_ep_int_desc_comp, (struct usb_descriptor_header *)&std_as_out_if0_desc, (struct usb_descriptor_header *)&std_as_out_if1_desc, @@ -800,6 +807,7 @@ static void setup_headers(struct f_uac2_opts *opts, struct usb_ss_ep_comp_descriptor *epout_desc_comp = NULL; struct usb_ss_ep_comp_descriptor *epin_desc_comp = NULL; struct usb_ss_ep_comp_descriptor *epin_fback_desc_comp = NULL; + struct usb_ss_ep_comp_descriptor *ep_int_desc_comp = NULL; struct usb_endpoint_descriptor *epout_desc; struct usb_endpoint_descriptor *epin_desc; struct usb_endpoint_descriptor *epin_fback_desc; @@ -827,6 +835,7 @@ static void setup_headers(struct f_uac2_opts *opts, epin_fback_desc = &ss_epin_fback_desc; epin_fback_desc_comp = &ss_epin_fback_desc_comp; ep_int_desc = &ss_ep_int_desc; + ep_int_desc_comp = &ss_ep_int_desc_comp; } i = 0; @@ -855,8 +864,11 @@ static void setup_headers(struct f_uac2_opts *opts, if (EPOUT_EN(opts)) headers[i++] = USBDHDR(&io_out_ot_desc); - if (FUOUT_EN(opts) || FUIN_EN(opts)) + if (FUOUT_EN(opts) || FUIN_EN(opts)) { headers[i++] = USBDHDR(ep_int_desc); + if (ep_int_desc_comp) + headers[i++] = USBDHDR(ep_int_desc_comp); + } if (EPOUT_EN(opts)) { headers[i++] = USBDHDR(&std_as_out_if0_desc); -- 2.24.0