Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp1230938pxb; Fri, 18 Feb 2022 03:33:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJzQCLYDkLWo4guFHin+N4Al+a5SteUjI9MhngPeZiM7PcjuMTS5OE5bdoJvsXM8XqfJ9jko X-Received: by 2002:a17:906:b04:b0:6bd:bf71:ed08 with SMTP id u4-20020a1709060b0400b006bdbf71ed08mr6195503ejg.585.1645183988018; Fri, 18 Feb 2022 03:33:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645183988; cv=none; d=google.com; s=arc-20160816; b=eRm9TcHMZqjRwBEegoS82pxlPW/SmJsrbtmEQjeCLiZ0LSbdvDXT50SMqQFlFWZX+s USJl+nfW+CZ7Zne9O3OkzYIVsBQHM00/xkVjXhA2JXbOYbWlX9vYtXdKRqBhAK82wHEg bEVA/L7XDzH0UVKJ4debygfRW44HOaOaHTW1IwPKLGK2IZVnYjJ13iUMZHvgsPm4EygR N6mEFiWjyE+kvhYF/Dx3af+efPboZvGZKW9n7mAb1br+GCTqA+15W8R8c9M78v0MsP9q suNdkrwaVeZHp8St7XRMwjb0C+CRFjJ12WTdqrvBAYiFXTZUcRSYfBAg5rWnHCsjLdEZ 2EOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=StLK/4fGVBQKkk0aPEI3SWuQT/lP2GbEsYPPd7KbZIw=; b=gAzGaoCjTxXLv/vSxMAogIQBc4rPHcz0u0f75JntLu0zeTDEbrJHDzjfXtu3RvaqBE XlWVDHFKmJOBVuigQsfpGWjwBScQctnxDTkNHmE0pJLLKnwx6gZTf/wHBMqMlTbeeSTQ 3mx6WDFG8dgc6/DVYLqy63Fw3LuoWcDbl56euxizcaaegqbzk7G0CeVMVstPdxnpkiJT 8Q2tOHVWy30BV0gAADcRpUhrNUVYUte43C9/DhflQB96PpWVE7LuINV2sVuC3Pxt4Svd AUPBX3xgKP5pH1Kt44xZSin4yVwT128/o55d5XaqYV8CEysidRwp/xzwUuu1RgERoPDB +VAQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i8si3430940ejj.319.2022.02.18.03.32.45; Fri, 18 Feb 2022 03:33:07 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233825AbiBRKAt (ORCPT + 99 others); Fri, 18 Feb 2022 05:00:49 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:54490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229993AbiBRKAs (ORCPT ); Fri, 18 Feb 2022 05:00:48 -0500 Received: from zg8tmty1ljiyny4xntqumjca.icoremail.net (zg8tmty1ljiyny4xntqumjca.icoremail.net [165.227.154.27]) by lindbergh.monkeyblade.net (Postfix) with SMTP id D456B2AEDB8; Fri, 18 Feb 2022 02:00:30 -0800 (PST) Received: from jleng.ambarella.net (unknown [180.169.129.130]) by mail-app3 (Coremail) with SMTP id cC_KCgDXv_IXbg9iV4Z4DQ--.27261S2; Fri, 18 Feb 2022 17:59:56 +0800 (CST) From: 3090101217@zju.edu.cn To: gregkh@linuxfoundation.org Cc: balbi@kernel.org, colin.king@intel.com, jackp@codeaurora.org, jbrunet@baylibre.com, jleng@ambarella.com, pavel.hofman@ivitera.com, pawell@cadence.com, ruslan.bilovol@gmail.com, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Subject: [PATCH v4] usb: gadget: f_uac2: fix superspeed transfer Date: Fri, 18 Feb 2022 17:59:48 +0800 Message-Id: <20220218095948.4077-1-3090101217@zju.edu.cn> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-CM-TRANSID: cC_KCgDXv_IXbg9iV4Z4DQ--.27261S2 X-Coremail-Antispam: 1UD129KBjvJXoWxXw1UWFWxtFykAF1UGryxAFb_yoWrGrW3pw n8C39rtrW5Ar1a9a1rAr48Ar43AFWIyayYkw4Ivw1YvF4Sq34ktF1IyryYkFyDAFyjyw10 vF4jkw47u3Zrur7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPGb7Iv0xC_tr1lb4IE77IF4wAFF20E14v26r4j6ryUM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Cr1j6rxdM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I 8E87Iv6xkF7I0E14v26rxl6s0DM2vYz4IE04k24VAvwVAKI4IrM2vYz4IE4I80cI0F6IAv xc0EwIxC4wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ew Av7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY 6r1j6r4UM4x0Y48IcxkI7VAKI48JM4IIrI8v6xkF7I0E8cxan2IY04v7M4kE6xkIj40Ew7 xC0wCY02Avz4vE14v_GFWl42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1l x2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14 v26r1q6r43MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IY x2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87 Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIF yTuYvjxUx189DUUUU X-CM-SenderInfo: qtqziiyqrsilo62m3hxhgxhubq/1tbiAwMFBVNG3FklugABsO X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 --- 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 097a709549d6..b5baefe14013 100644 --- a/drivers/usb/gadget/function/f_uac2.c +++ b/drivers/usb/gadget/function/f_uac2.c @@ -282,6 +282,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, @@ -595,7 +601,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, @@ -723,6 +730,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; @@ -750,6 +758,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; @@ -778,8 +787,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.17.1