Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp632427rwb; Thu, 22 Sep 2022 04:39:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6NCf0tqR58BKJ2W4HLLQ6xHxb1c3nUAJyTMt0Sp9qxWVM9REdXSdJn/mb8BW6CZZ6QNxO4 X-Received: by 2002:a17:906:fe09:b0:77a:52b3:da5d with SMTP id wy9-20020a170906fe0900b0077a52b3da5dmr2330762ejb.57.1663846787736; Thu, 22 Sep 2022 04:39:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663846787; cv=none; d=google.com; s=arc-20160816; b=J4UOesPc61Qdbe2luTGX4eEgyrM3oqu9v2sseeujAfMy2djUKC+S6aXEnDKnwvKPqo M4aTsZLn/V84M3La3vjmxK9ANCW+IF7nI2xxsMocqudW7CJ840pnBmfB/W39Mjl6aQRM 6SERpCGIz/7uOokc5HbO6Gwnzo0hanE5BJ7xwv4xao4w+SYTN5IXRETIOW9Vx9Yg3txF 7I/Htv3B6oNn9M2wtiGjIBH3uQn32xzIMgmtHmOYwHmtee+Hlp1grUcewEo1/lB53KOP 5hTlPM51Pbbb25Xzrq98f0dbIZiEetsVeAR/vGMcAJCAdT9TpaFq/NumVonrWLiuz6v3 Uv5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=3YPdDceAOhXpvVj6/ZRD51BGjIgDOahodMJXcXiBJjc=; b=Ke7/6jS/jqhoeVR52uvJHjoA0Lh8nzBJvAF/wlcVtuVjaTxSMf92LAvokOeHb/LadR rJFkAWFUdKo5nfkJCF63VVGh5Z5/6xiwWKq21mhfkD00MmYHkPlTIO8MBtBOQE/hQ8k2 pBBm6Ghf5gUkYpozhP5bP/nHKi2N9IZZkm1jc6kUEVtIBFJFjrO36JQVPBx9Z2/5wBIS hWU0vV+PekR/ZAWaksxEhQ2pVlyEd0T7OjJExrMTLwEMCWgmkyPBEGVAH2fbjuLRlcLl bATPLoygx1O9SKti9lTpNTwz8fFrgql91UGWZvpCxEmWXsK/mScgmilf76+BNnnXxS0x fZ0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jK+OEmkL; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x11-20020a056402414b00b0044ea553d7cdsi4938442eda.105.2022.09.22.04.39.19; Thu, 22 Sep 2022 04:39:47 -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=@intel.com header.s=Intel header.b=jK+OEmkL; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231302AbiIVLaa (ORCPT + 99 others); Thu, 22 Sep 2022 07:30:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229973AbiIVLaV (ORCPT ); Thu, 22 Sep 2022 07:30:21 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66F8E1CB11; Thu, 22 Sep 2022 04:30:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663846220; x=1695382220; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=rQehm9/mvaB86nLSf3V97DpHWGDoVI9t2ENatdOSoX8=; b=jK+OEmkLWTZCuOrSpB0Bcu2h4qTrUpr9Ac4eQDSHGEme2sCx5Uh5CMk9 d9tWA8u9AEsID96xaINFn5bgaN/z6LvVcLGKLjHXfjG++hPQoKsO7T4VH rN0DK9y58/G1HaA+pb7004aRRvq2gdqRsy/NZ6kYVvGlm+pj1vWXEepw4 anL1h8ksZv5J9GvudMfzg4+OGTHIOQrxf0O9E5uGg8F6xVUyFKQw3DtL2 CBIXotu8m9cJFFuCjzSIXQS4/3aFJ0k64rXT5/5/TtzBBemulH2EMFSpB lpXCBschBlLqe4ITGBMh/llZQObybAGLu/4St63b68VXtSBWD2HAaZWVn w==; X-IronPort-AV: E=McAfee;i="6500,9779,10477"; a="297869489" X-IronPort-AV: E=Sophos;i="5.93,335,1654585200"; d="scan'208";a="297869489" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2022 04:30:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,335,1654585200"; d="scan'208";a="795049641" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga005.jf.intel.com with ESMTP; 22 Sep 2022 04:30:17 -0700 Received: by black.fi.intel.com (Postfix, from userid 1001) id 0CEFE238; Thu, 22 Sep 2022 14:30:34 +0300 (EEST) Date: Thu, 22 Sep 2022 14:30:34 +0300 From: Mika Westerberg To: Mario Limonciello Cc: Andreas Noever , Michael Jamet , Yehezkel Bernat , sanju.mehta@amd.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] thunderbolt: Explicitly enable lane adapter hotplug events at startup Message-ID: References: <20220921145434.21659-1-mario.limonciello@amd.com> <20220921145434.21659-3-mario.limonciello@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220921145434.21659-3-mario.limonciello@amd.com> X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_NONE 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 Hi Mario, On Wed, Sep 21, 2022 at 09:54:33AM -0500, Mario Limonciello wrote: > 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". > > Signed-off-by: Mario Limonciello > --- > drivers/thunderbolt/switch.c | 4 ++++ > drivers/thunderbolt/tb.h | 1 + > drivers/thunderbolt/tb_regs.h | 1 + > drivers/thunderbolt/usb4.c | 19 +++++++++++++++++++ > 4 files changed, 25 insertions(+) > > diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c > index 77d7f07ca075..65f65cfe1101 100644 > --- a/drivers/thunderbolt/switch.c > +++ b/drivers/thunderbolt/switch.c > @@ -792,6 +792,10 @@ static int tb_init_port(struct tb_port *port) > (port->config.nfc_credits & ADP_CS_4_TOTAL_BUFFERS_MASK) >> > ADP_CS_4_TOTAL_BUFFERS_SHIFT; > > + res = usb4_enable_hotplug(port); Is this something that needs to be done only for the lane adapters? And not say PCIe or USB adapter? > + if (res) > + return res; > + > tb_dump_port(port->sw->tb, port); > return 0; > } > diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h > index 5db76de40cc1..b66781ae9c16 100644 > --- a/drivers/thunderbolt/tb.h > +++ b/drivers/thunderbolt/tb.h > @@ -1174,6 +1174,7 @@ int usb4_switch_add_ports(struct tb_switch *sw); > void usb4_switch_remove_ports(struct tb_switch *sw); > > int usb4_port_unlock(struct tb_port *port); > +int usb4_enable_hotplug(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); > diff --git a/drivers/thunderbolt/tb_regs.h b/drivers/thunderbolt/tb_regs.h > index 166054110388..bbe38b2d9057 100644 > --- a/drivers/thunderbolt/tb_regs.h > +++ b/drivers/thunderbolt/tb_regs.h > @@ -308,6 +308,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 > diff --git a/drivers/thunderbolt/usb4.c b/drivers/thunderbolt/usb4.c > index 3a2e7126db9d..40ba14e8e227 100644 > --- a/drivers/thunderbolt/usb4.c > +++ b/drivers/thunderbolt/usb4.c > @@ -1046,6 +1046,25 @@ int usb4_port_unlock(struct tb_port *port) > return tb_port_write(port, &val, TB_CFG_PORT, ADP_CS_4, 1); > } > > +/** > + * usb4_enable_hotplug() - Enables hotplug for a port > + * @port: USB4 port to operate on > + * > + * Enables hot plug events on a given port. > + */ > +int usb4_enable_hotplug(struct tb_port *port) usb4_port_hotplug_enable() > +{ > + int ret; > + u32 val; > + And this one needs to check if this is suitable adapter or if not then at least mention it in the documentation. > + 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; > -- > 2.34.1