Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9041798pxu; Mon, 28 Dec 2020 05:12:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJxMTuaS9Qn8z7Nyw6FmWIqnD09h6PYMtcX455F3MGwABVFUejPF6FclkIqs5nqGAij9R/wk X-Received: by 2002:a17:906:eca9:: with SMTP id qh9mr25044814ejb.188.1609161152752; Mon, 28 Dec 2020 05:12:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609161152; cv=none; d=google.com; s=arc-20160816; b=pge3m9Sj7mzXEywfxltzUs+zLSpb4Sic5mmoVfVzWIuEvKxO0RccwLPvh00tb2adk8 saoocyMI35fzyG4D2FjLD0C6XDz8eMxziOrncZVbC9UDa0wDU9cE5nDE5XQkLnBGxBvV Gbr7l7PUGUYpBVDOdsJDJJZ5VpPje8n2VMBxqBj8V2yqNWvm1D9EGQnv/74hcCxjTxMd Mme/ao0xbSa3fgRtGhjFqRrjUo21QIgPUeHKdNL2KIwb23obXZHt4X7hvD2evY7MDGSu x4g/ySXrRnhKs1Lpgf0z5PLBE5qoFLeEM6Z5v22jT5U3HFhAFuk3h6W5ou0kZ1Ev/H3y vo0w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PAP9BBnJr3CBvCMCauFGgSTCNXQTNrFeHLHUOAndzoQ=; b=ZzKGLPkWme9XP2WowHt5Bsdmiuzad6VqCemRikdT92DM6Z3nN9AutcRuIcZyD5zQ1u yWDPeT1LOofVCm5yGm72QAQVEEEOqEKWL/5ONRN/iOxJ1iyLOp2ywWI+KNCn4cKRAbdS HaTZpot3lf6uRQvGZZh7Qc6jH5SEHekEMe72iULDXUxKcglpa+XywAay7BZ1WPwLbtqW e0w6Bs7FnEUx6lrQYhzlhWVXEyj1T2PqfWvNOUg4I+kraas0wxOIqxcpD8u0jWn7CdSG Q4cijLzLAlqBa2SSd51xjR+zortvLxEG6mZUYRX9tOgz41EGFXr1TRt+BNJ5gFvNZcwX daRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MfG4QAUX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gn22si17826113ejc.749.2020.12.28.05.12.09; Mon, 28 Dec 2020 05:12:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MfG4QAUX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731256AbgL1NJ6 (ORCPT + 99 others); Mon, 28 Dec 2020 08:09:58 -0500 Received: from mail.kernel.org ([198.145.29.99]:37698 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731244AbgL1NJ5 (ORCPT ); Mon, 28 Dec 2020 08:09:57 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id A2BDE208BA; Mon, 28 Dec 2020 13:09:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609160956; bh=cj5sgS/Minp5KVuWIjmrxGnsQ0SEpKr8dj4vTk6yJy0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MfG4QAUXXFPY8lqwlLrTHDDc4HaK6N/tVbTEzDECfJkt1TzOHtitTQLBTg8e+vbiF MhLd74nrU4BTMOHFB01wlAfkfV0h9nLROCEqcC/fF0l8EoGEzEkZbQFCAtOMxNabac az3v1xS3khLQmG7s9+aj1xsppjIbibQ1Hb5ue1tw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jack Pham Subject: [PATCH 4.14 052/242] usb: gadget: f_fs: Re-use SS descriptors for SuperSpeedPlus Date: Mon, 28 Dec 2020 13:47:37 +0100 Message-Id: <20201228124907.243090287@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124904.654293249@linuxfoundation.org> References: <20201228124904.654293249@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jack Pham commit a353397b0d5dfa3c99b372505db3378fc919c6c6 upstream. In many cases a function that supports SuperSpeed can very well operate in SuperSpeedPlus, if a gadget controller supports it, as the endpoint descriptors (and companion descriptors) are generally identical and can be re-used. This is true for two commonly used functions: Android's ADB and MTP. So we can simply assign the usb_function's ssp_descriptors array to point to its ss_descriptors, if available. Similarly, we need to allow an epfile's ioctl for FUNCTIONFS_ENDPOINT_DESC to correctly return the corresponding SuperSpeed endpoint descriptor in case the connected speed is SuperSpeedPlus as well. The only exception is if a function wants to implement an Isochronous endpoint capable of transferring more than 48KB per service interval when operating at greater than USB 3.1 Gen1 speed, in which case it would require an additional SuperSpeedPlus Isochronous Endpoint Companion descriptor to be returned as part of the Configuration Descriptor. Support for that would need to be separately added to the userspace-facing FunctionFS API which may not be a trivial task--likely a new descriptor format (v3?) may need to be devised to allow for separate SS and SSP descriptors to be supplied. Signed-off-by: Jack Pham Cc: stable Link: https://lore.kernel.org/r/20201027230731.9073-1-jackp@codeaurora.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/function/f_fs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -1248,6 +1248,7 @@ static long ffs_epfile_ioctl(struct file switch (epfile->ffs->gadget->speed) { case USB_SPEED_SUPER: + case USB_SPEED_SUPER_PLUS: desc_idx = 2; break; case USB_SPEED_HIGH: @@ -3067,7 +3068,8 @@ static int _ffs_func_bind(struct usb_con } if (likely(super)) { - func->function.ss_descriptors = vla_ptr(vlabuf, d, ss_descs); + func->function.ss_descriptors = func->function.ssp_descriptors = + vla_ptr(vlabuf, d, ss_descs); ss_len = ffs_do_descs(ffs->ss_descs_count, vla_ptr(vlabuf, d, raw_descs) + fs_len + hs_len, d_raw_descs__sz - fs_len - hs_len, @@ -3477,6 +3479,7 @@ static void ffs_func_unbind(struct usb_c func->function.fs_descriptors = NULL; func->function.hs_descriptors = NULL; func->function.ss_descriptors = NULL; + func->function.ssp_descriptors = NULL; func->interfaces_nums = NULL; ffs_event_add(ffs, FUNCTIONFS_UNBIND);