From patchwork Mon Oct 24 11:29:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9209 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp459193wru; Mon, 24 Oct 2022 06:39:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5c4+LXWME2NBTk9OqMiNNNd7bhDVWCMEHH74VbZTNUBr78bZ90eRrA+T+GVrMl9C6ucv1h X-Received: by 2002:a17:907:2d1f:b0:78e:174d:2ce0 with SMTP id gs31-20020a1709072d1f00b0078e174d2ce0mr27821246ejc.638.1666618732905; Mon, 24 Oct 2022 06:38:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666618732; cv=none; d=google.com; s=arc-20160816; b=Suzgb7YbSar3+xxiWm8YVWnTZjtQfFgtf8x5j7buBJN+Nu9OdZj255qOCp9nm4+iAG zVivbeqEbsDpp7gatGqlyixmcx8oc84vXugIweHPMAO4JYQPbqN5FNe0cIT76oV+ItID W/q5cL3orF4KVoFhxRHPH+fWz7fWjC8w1JOUITVcihbkfKQbQ5KXhw4pVuEn7tZHBCqT jAn+t4bhcuplwaRKyCcVmbpat6Wsgsf7HOzqBWfspBBxAa8LxZFlaQN++5GFK3U2HVtv UruMd+zBaIvQMOR3jipEccvRQFanNsvryneMnj6mkU9uYmqUbgaElJCs87VSyBU2/LZ6 K/1w== 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=U1iqRrLHdm2hHeTLynp2HFbIOzOFRwjx8eo9cjPXxP4=; b=jgkPbUYv0LSvX5QZ7w2Xm0SMtuo1iSZ3B30qoeRxFVuBdstJejSdsHQJ5aL37jYfcS C/OAQeNd/CuLbIByJMkovJvTRoFxKV3i1Inz/NN90JstF0potaboEtUIE/p9L8ba66kZ 0VT0ax54Oa6YYUAbqEJ8HU8t9TuHsO0P29vcPKzcUyCsyA4aPNe6oCfuXQviGV9t8Lie JyrOdwA4za1h6kxM/3wEE67UUGLLgt3+ud4O/eODOuT9yKyHqaehZFSTOcmxKaeAr/f2 Ay3tPCBQViP9Ffh/xjL6OGZmfcHn7KHMekUGD1htbQTvZ/4JOOaOqw1pYTmxpv166CYM KjFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pkMgd1Xu; 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=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v5-20020a50d585000000b0045bcf2bdcf2si28251214edi.464.2022.10.24.06.38.22; Mon, 24 Oct 2022 06:38:52 -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=@linuxfoundation.org header.s=korg header.b=pkMgd1Xu; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236286AbiJXNfO (ORCPT + 99 others); Mon, 24 Oct 2022 09:35:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236279AbiJXNaV (ORCPT ); Mon, 24 Oct 2022 09:30:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B9C6AC480; Mon, 24 Oct 2022 05:33:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1844F61297; Mon, 24 Oct 2022 12:24:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B7FBC433C1; Mon, 24 Oct 2022 12:24:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666614255; bh=Gxa3rXUFxkd8SLn9Ts36YPdcxnaQL3Du9o3r46StfhE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pkMgd1XuOIlzzeMyZW3/NwIwI9sOAGuyxPP+adhfOJnSbY2ugkMScHyC/auVOi7kt JwL6vaqlqEIryJWBWjeLHZvUhUu85tyheWmwDo3rH+IZS+ovjslhkIdxv9w1bbjz5A BrSvqR17k49M97E8ul9t9XzJTPl6rHsZBV2j61O8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thinh Nguyen , Sasha Levin Subject: [PATCH 5.10 192/390] usb: common: Parse for USB SSP genXxY Date: Mon, 24 Oct 2022 13:29:49 +0200 Message-Id: <20221024113030.942254530@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747576404268522049?= X-GMAIL-MSGID: =?utf-8?q?1747576404268522049?= From: Thinh Nguyen [ Upstream commit 52c2d15703c3a900d5f78cd599b823db40d5100b ] The USB "maximum-speed" property can now take the SSP signaling rate generation and lane count with these new strings: "super-speed-plus-gen2x2" "super-speed-plus-gen2x1" "super-speed-plus-gen1x2" Introduce usb_get_maximum_ssp_rate() to parse for the corresponding usb_ssp_rate enum. The original usb_get_maximum_speed() will return USB_SPEED_SUPER_PLUS if it matches one of these new strings. Signed-off-by: Thinh Nguyen Link: https://lore.kernel.org/r/f8ed896313d8cd8e2d2b540fc82db92b3ddf8a47.1611106162.git.Thinh.Nguyen@synopsys.com Signed-off-by: Greg Kroah-Hartman Stable-dep-of: b6155eaf6b05 ("usb: common: debug: Check non-standard control requests") Signed-off-by: Sasha Levin --- drivers/usb/common/common.c | 26 +++++++++++++++++++++++++- include/linux/usb/ch9.h | 11 +++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c index 1433260d99b4..fc21cf2d36f6 100644 --- a/drivers/usb/common/common.c +++ b/drivers/usb/common/common.c @@ -69,6 +69,13 @@ static const char *const speed_names[] = { [USB_SPEED_SUPER_PLUS] = "super-speed-plus", }; +static const char *const ssp_rate[] = { + [USB_SSP_GEN_UNKNOWN] = "UNKNOWN", + [USB_SSP_GEN_2x1] = "super-speed-plus-gen2x1", + [USB_SSP_GEN_1x2] = "super-speed-plus-gen1x2", + [USB_SSP_GEN_2x2] = "super-speed-plus-gen2x2", +}; + const char *usb_speed_string(enum usb_device_speed speed) { if (speed < 0 || speed >= ARRAY_SIZE(speed_names)) @@ -86,12 +93,29 @@ enum usb_device_speed usb_get_maximum_speed(struct device *dev) if (ret < 0) return USB_SPEED_UNKNOWN; - ret = match_string(speed_names, ARRAY_SIZE(speed_names), maximum_speed); + ret = match_string(ssp_rate, ARRAY_SIZE(ssp_rate), maximum_speed); + if (ret > 0) + return USB_SPEED_SUPER_PLUS; + ret = match_string(speed_names, ARRAY_SIZE(speed_names), maximum_speed); return (ret < 0) ? USB_SPEED_UNKNOWN : ret; } EXPORT_SYMBOL_GPL(usb_get_maximum_speed); +enum usb_ssp_rate usb_get_maximum_ssp_rate(struct device *dev) +{ + const char *maximum_speed; + int ret; + + ret = device_property_read_string(dev, "maximum-speed", &maximum_speed); + if (ret < 0) + return USB_SSP_GEN_UNKNOWN; + + ret = match_string(ssp_rate, ARRAY_SIZE(ssp_rate), maximum_speed); + return (ret < 0) ? USB_SSP_GEN_UNKNOWN : ret; +} +EXPORT_SYMBOL_GPL(usb_get_maximum_ssp_rate); + const char *usb_state_string(enum usb_device_state state) { static const char *const names[] = { diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h index 86c50907634e..abdd310c77f0 100644 --- a/include/linux/usb/ch9.h +++ b/include/linux/usb/ch9.h @@ -71,6 +71,17 @@ extern const char *usb_speed_string(enum usb_device_speed speed); */ extern enum usb_device_speed usb_get_maximum_speed(struct device *dev); +/** + * usb_get_maximum_ssp_rate - Get the signaling rate generation and lane count + * of a SuperSpeed Plus capable device. + * @dev: Pointer to the given USB controller device + * + * If the string from "maximum-speed" property is super-speed-plus-genXxY where + * 'X' is the generation number and 'Y' is the number of lanes, then this + * function returns the corresponding enum usb_ssp_rate. + */ +extern enum usb_ssp_rate usb_get_maximum_ssp_rate(struct device *dev); + /** * usb_state_string - Returns human readable name for the state. * @state: The state to return a human-readable name for. If it's not