From patchwork Tue Feb 2 03:42:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thinh Nguyen X-Patchwork-Id: 375785 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0228C433E0 for ; Tue, 2 Feb 2021 03:43:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B273864ECC for ; Tue, 2 Feb 2021 03:43:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231488AbhBBDnb (ORCPT ); Mon, 1 Feb 2021 22:43:31 -0500 Received: from smtprelay-out1.synopsys.com ([149.117.87.133]:36102 "EHLO smtprelay-out1.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229621AbhBBDn2 (ORCPT ); Mon, 1 Feb 2021 22:43:28 -0500 Received: from mailhost.synopsys.com (sv2-mailhost1.synopsys.com [10.205.2.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id 3E6EEC008C; Tue, 2 Feb 2021 03:42:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1612237348; bh=mzYoA3OuE9tA+wg/ep4FQSq0uQq2/R8W58LnupIYsss=; h=Date:In-Reply-To:References:From:Subject:To:From; b=F4SK1670PcFzKJAJ8VkKw/yIeX7QfxoKgMWM8coLP/DX4267qlLqPYEgW1yGj6QcY xFC7v1ZaC1GMSQDHx1eA+y2U+1NMsz4wVMFXoXqYSCsWgIa54bm70nZog4HlISjl6F QDymRwtfeGdNS7RQsKZNjEHefyICWpbLgOYQbn34rozC07WCk2CcU+YzdpuAWcNrdY JnXxUMnPUewNVxJ1HDIXmY1DX0aptnTNDgGcQ+AQJxTSnfnQoIJU/adTj0keynRnPG uuRDsLJtwFyYiwv248O738/rUrZbL8KpzIUabBB1QyVTYUpYO4uUbyulhM2sx8k8SU jH7SZdPCCLrcg== Received: from te-lab16 (unknown [10.10.52.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mailhost.synopsys.com (Postfix) with ESMTPSA id 0D8E2A007C; Tue, 2 Feb 2021 03:42:27 +0000 (UTC) Received: by te-lab16 (sSMTP sendmail emulation); Mon, 01 Feb 2021 19:42:27 -0800 Date: Mon, 01 Feb 2021 19:42:27 -0800 Message-Id: <6b8c24bdb10552ae8029b4b2828ba3a1c6e57dac.1612237179.git.Thinh.Nguyen@synopsys.com> In-Reply-To: References: X-SNPS-Relay: synopsys.com From: Thinh Nguyen Subject: [RFC PATCH 2/8] usb: core: hub: Remove port_speed_is_ssp() To: Greg Kroah-Hartman , Thinh.Nguyen@synopsys.com, linux-usb@vger.kernel.org, Alan Stern , Eugeniu Rosca , Hardik Gajjar , "Gustavo A. R. Silva" , Oliver Neukum Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The get_port_ssp_rate() can replace port_speed_is_ssp(). If the port speed is detected to be in gen2x1, gen1x2, or gen2x2, then the port is operating at SuperSpeed Plus. Signed-off-by: Thinh Nguyen --- drivers/usb/core/hub.c | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index e78b2dd7801a..823470607d58 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -2744,33 +2744,6 @@ static enum usb_ssp_rate get_port_ssp_rate(struct usb_device *hdev, return USB_SSP_GEN_UNKNOWN; } -/* - * Return 1 if port speed is SuperSpeedPlus, 0 otherwise - * check it from the link protocol field of the current speed ID attribute. - * current speed ID is got from ext port status request. Sublink speed attribute - * table is returned with the hub BOS SSP device capability descriptor - */ -static int port_speed_is_ssp(struct usb_device *hdev, int speed_id) -{ - int ssa_count; - u32 ss_attr; - int i; - struct usb_ssp_cap_descriptor *ssp_cap = hdev->bos->ssp_cap; - - if (!ssp_cap) - return 0; - - ssa_count = le32_to_cpu(ssp_cap->bmAttributes) & - USB_SSP_SUBLINK_SPEED_ATTRIBS; - - for (i = 0; i <= ssa_count; i++) { - ss_attr = le32_to_cpu(ssp_cap->bmSublinkSpeedAttr[i]); - if (speed_id == (ss_attr & USB_SSP_SUBLINK_SPEED_SSID)) - return !!(ss_attr & USB_SSP_SUBLINK_SPEED_LP); - } - return 0; -} - /* Returns 1 if @hub is a WUSB root hub, 0 otherwise */ static unsigned hub_is_wusb(struct usb_hub *hub) { @@ -2934,9 +2907,7 @@ static int hub_port_wait_reset(struct usb_hub *hub, int port1, } if (hub_is_wusb(hub)) udev->speed = USB_SPEED_WIRELESS; - else if (hub_is_superspeedplus(hub->hdev) && - port_speed_is_ssp(hub->hdev, ext_portstatus & - USB_EXT_PORT_STAT_RX_SPEED_ID)) + else if (udev->ssp_rate != USB_SSP_GEN_UNKNOWN) udev->speed = USB_SPEED_SUPER_PLUS; else if (hub_is_superspeed(hub->hdev)) udev->speed = USB_SPEED_SUPER;