From patchwork Sat Oct 22 07:20:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7251 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1091486wrr; Sat, 22 Oct 2022 00:50:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM62TazfDQT6E4fL4RzqDoHyLLCPdLpjbKAchJlq020fqFvMrl0rAq/PNcQvwMwmnSR95dJr X-Received: by 2002:a65:6bcb:0:b0:44c:3e11:a7ac with SMTP id e11-20020a656bcb000000b0044c3e11a7acmr19975401pgw.274.1666425048095; Sat, 22 Oct 2022 00:50:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666425048; cv=none; d=google.com; s=arc-20160816; b=iqkD5vY5JREidiqRPg+/to51qfY47+mtcMfbY/Xbe1RaTJdcD11SCILhevR4+GwEhw ErBtK3bIhwPeRqJcMfyfzNdiJ+Y1QwWniDiy0HQfFNqboSCx9RQZM7Z5rcn3EHaZpmWB PJSwrMBO+krfhhb4puzBjw3+TjqDH69DHUoWqTZeyCpFC2rCceDqMBgbvc2dLSoUwywK L9PKTng+EzDCw9fxk5HZqfa5M2WSQ6sUVlBN4LVWKRWtIK3DpXI8mEGcS9Jaidsmq9sY p4priKheLZpouO6p7GWPH0JNL7Sro1hxfcaEbywUUKaCEdcvGIBU79LhH+65cAnAgFCa Fl3A== 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=zm4pR7X8KEtiEFOyqVODlcpUl39LkWPoDM6e3Roxevk=; b=UnFDHBFM+qh0nlsicsA6oqv0haa2S3fBGZS3wp6/boQD+A23w8SXpMfrzqKY0D50B0 I8VHhpn0ID1f5hf+V1aNCDbeNnqVypx1Phjp9bpwHoS/eTWIb98iKvXEK0fkan2T0cjK ZogmdVO1lfEvKCwNdkiYaIU/PezsaPKkn6wjGxaq6KpfWKMSgUT1qkBGGe9UaHICe4D8 IoZzZ87B/AbfJgE0TWBTXXdsjmvSBwmgiuUVAxjOuEbo/PvWQ63DfQaqzho+EYFx6NN2 jUGuafjKLuZfDQ0DYMhYk9ETR8ezM6DpP6beInKQpXeyVzaKK9XMRvIVOAkjCYYKt5em vFJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lIJVNRKs; 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 v10-20020a1709029a0a00b001768452d4d0si26599364plp.30.2022.10.22.00.50.35; Sat, 22 Oct 2022 00:50: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=@linuxfoundation.org header.s=korg header.b=lIJVNRKs; 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 S231635AbiJVHuB (ORCPT + 99 others); Sat, 22 Oct 2022 03:50:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231532AbiJVHsm (ORCPT ); Sat, 22 Oct 2022 03:48:42 -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 17AA616D56C; Sat, 22 Oct 2022 00:45:23 -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 BD5AD60B49; Sat, 22 Oct 2022 07:41:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CCF2FC433D6; Sat, 22 Oct 2022 07:41:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424461; bh=e6EujxveYGGxtCmLnZxMjQZJohrw+5FNgNJh9TVA5Bk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lIJVNRKs2zCavZTrjxxO1cQZOx01g+nTxmVAVzjY50FNxE0MXXdhkBQCO4WE/oycJ JZfxHxvwB+6fgfEc8SU0J1G9azusrNcjLLGg29YSYKGj1pkrjKH+IWd1YMgn+WW499 /dedqbNwe1dhdazyzC5WvL1bNxQbq5bcOa1k8+mk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mario Limonciello , Mika Westerberg Subject: [PATCH 5.19 154/717] thunderbolt: Explicitly enable lane adapter hotplug events at startup Date: Sat, 22 Oct 2022 09:20:33 +0200 Message-Id: <20221022072442.694867562@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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?1747373311537528395?= X-GMAIL-MSGID: =?utf-8?q?1747373311537528395?= From: Mario Limonciello commit 5d2569cb4a65c373896ec0217febdf88739ed295 upstream. Software that has run before the USB4 CM in Linux runs may have disabled hotplug events for a given lane adapter. Other CMs such as that one distributed with Windows 11 will enable hotplug events. Do the same thing in the Linux CM which fixes hotplug events on "AMD Pink Sardine". Cc: stable@vger.kernel.org Signed-off-by: Mario Limonciello Signed-off-by: Mika Westerberg Signed-off-by: Greg Kroah-Hartman --- drivers/thunderbolt/switch.c | 24 ++++++++++++++++++++++++ drivers/thunderbolt/tb.h | 1 + drivers/thunderbolt/tb_regs.h | 1 + drivers/thunderbolt/usb4.c | 20 ++++++++++++++++++++ 4 files changed, 46 insertions(+) --- a/drivers/thunderbolt/switch.c +++ b/drivers/thunderbolt/switch.c @@ -2822,6 +2822,26 @@ static void tb_switch_credits_init(struc tb_sw_info(sw, "failed to determine preferred buffer allocation, using defaults\n"); } +static int tb_switch_port_hotplug_enable(struct tb_switch *sw) +{ + struct tb_port *port; + + if (tb_switch_is_icm(sw)) + return 0; + + tb_switch_for_each_port(sw, port) { + int res; + + if (!port->cap_usb4) + continue; + + res = usb4_port_hotplug_enable(port); + if (res) + return res; + } + return 0; +} + /** * tb_switch_add() - Add a switch to the domain * @sw: Switch to add @@ -2891,6 +2911,10 @@ int tb_switch_add(struct tb_switch *sw) return ret; } + ret = tb_switch_port_hotplug_enable(sw); + if (ret) + return ret; + ret = device_add(&sw->dev); if (ret) { dev_err(&sw->dev, "failed to add device: %d\n", ret); --- a/drivers/thunderbolt/tb.h +++ b/drivers/thunderbolt/tb.h @@ -1170,6 +1170,7 @@ int usb4_switch_add_ports(struct tb_swit void usb4_switch_remove_ports(struct tb_switch *sw); int usb4_port_unlock(struct tb_port *port); +int usb4_port_hotplug_enable(struct tb_port *port); int usb4_port_configure(struct tb_port *port); void usb4_port_unconfigure(struct tb_port *port); int usb4_port_configure_xdomain(struct tb_port *port); --- a/drivers/thunderbolt/tb_regs.h +++ b/drivers/thunderbolt/tb_regs.h @@ -302,6 +302,7 @@ struct tb_regs_port_header { #define ADP_CS_5 0x05 #define ADP_CS_5_LCA_MASK GENMASK(28, 22) #define ADP_CS_5_LCA_SHIFT 22 +#define ADP_CS_5_DHP BIT(31) /* TMU adapter registers */ #define TMU_ADP_CS_3 0x03 --- a/drivers/thunderbolt/usb4.c +++ b/drivers/thunderbolt/usb4.c @@ -1046,6 +1046,26 @@ int usb4_port_unlock(struct tb_port *por return tb_port_write(port, &val, TB_CFG_PORT, ADP_CS_4, 1); } +/** + * usb4_port_hotplug_enable() - Enables hotplug for a port + * @port: USB4 port to operate on + * + * Enables hot plug events on a given port. This is only intended + * to be used on lane, DP-IN, and DP-OUT adapters. + */ +int usb4_port_hotplug_enable(struct tb_port *port) +{ + int ret; + u32 val; + + ret = tb_port_read(port, &val, TB_CFG_PORT, ADP_CS_5, 1); + if (ret) + return ret; + + val &= ~ADP_CS_5_DHP; + return tb_port_write(port, &val, TB_CFG_PORT, ADP_CS_5, 1); +} + static int usb4_port_set_configured(struct tb_port *port, bool configured) { int ret;