Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp436975ybb; Thu, 28 Mar 2019 05:40:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqzwQzUM5NDZHjSfGGQaraA/S0SeiMYyMm5EpupLSHRHnc/+AUZfOB8fjMSPy2QuAAKjncOS X-Received: by 2002:a17:902:599d:: with SMTP id p29mr7655012pli.156.1553776850945; Thu, 28 Mar 2019 05:40:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553776850; cv=none; d=google.com; s=arc-20160816; b=GIoEV23wgxJatYnaPPczXE4ELjtnCCbUesOAFXTcO/ZkwuGhLX6fjzCf5avu9rE5VX 5+TXBRXl+617LczUf1IL2OWHlvoU4P4IvVKchnv4pClLKXfhQMyokKbaBCBL0wbuZAog 2mqFu+K13MPzxw5aKWZCKqW3EU5wYGQW2iEEPy0fR971r5/Z3P/wPPZlyoD7gemczO5A bmEIidyoRzWYnebt55mz+vApLJhGtBLy3+hkkwdLnSTEgzpaQEihB9tSExT80C44x7ae bY+G3G0VO+ZZT3wVMip0MEeeia1LafTbXTwIOFszFR4y579QpDbEwnSSoLuLH1fpWVfY aYpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=k3wPPEhP9vMzhm6zRaYLehJ8UYj6ZpezDjeIZEdC7yY=; b=cCiZwRcOYf/EzwkzT/S+WaDvZmXm0C09UCQprAT6yQ8GdlJE2H93Z8qcU7C3mhgRiY iMpoGmzPk7qHMojxR8bZay4Onx3p242T4ycGWfLvKN5Lt+aVV0wby6BPdswFN/NRCA7V hNPvk/0gEGyfNa/+DhWnY/1moeOhsIiRLTtbe5OkcPzFKPgDEl4O/yLSRA+iFrH6pt2v R99O35IgMa4mE1M+kLWRtnq8ErYqVhixhbk+gbCRMxpdcx3TFhcYqDVkbyRFifjI3Dbw trXmJOLx71o0dN5/FViS9Ryd02+KweONeeFZpQMfgsRPAlBKk2Et/dZxZAlV3RjqvDWi BBVQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o4si18644890pgr.158.2019.03.28.05.40.35; Thu, 28 Mar 2019 05:40:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727849AbfC1MjI (ORCPT + 99 others); Thu, 28 Mar 2019 08:39:08 -0400 Received: from mga11.intel.com ([192.55.52.93]:35010 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727213AbfC1Mgq (ORCPT ); Thu, 28 Mar 2019 08:36:46 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Mar 2019 05:36:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,280,1549958400"; d="scan'208";a="126619161" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga007.jf.intel.com with ESMTP; 28 Mar 2019 05:36:42 -0700 Received: by black.fi.intel.com (Postfix, from userid 1001) id DD77BF9C; Thu, 28 Mar 2019 14:36:34 +0200 (EET) From: Mika Westerberg To: linux-kernel@vger.kernel.org Cc: Michael Jamet , Yehezkel Bernat , Andreas Noever , Lukas Wunner , "David S . Miller" , Andy Shevchenko , Christian Kellner , Mario.Limonciello@dell.com, Mika Westerberg , netdev@vger.kernel.org Subject: [PATCH v3 23/36] thunderbolt: Scan only valid NULL adapter ports in hotplug Date: Thu, 28 Mar 2019 15:36:20 +0300 Message-Id: <20190328123633.42882-24-mika.westerberg@linux.intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190328123633.42882-1-mika.westerberg@linux.intel.com> References: <20190328123633.42882-1-mika.westerberg@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The only way to expand Thunderbolt topology is through the NULL adapter ports (typically ports 1, 2, 3 and 4). There is no point handling Thunderbolt hotplug events on any other port. Add a helper function (tb_port_is_null()) that can be used to determine if the port is NULL port, and use it in software connection manager code when hotplug event is handled. Signed-off-by: Mika Westerberg --- drivers/thunderbolt/tb.c | 10 ++++++---- drivers/thunderbolt/tb.h | 5 +++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c index cfc451c938fd..fb01396a62a9 100644 --- a/drivers/thunderbolt/tb.c +++ b/drivers/thunderbolt/tb.c @@ -356,10 +356,12 @@ static void tb_handle_hotplug(struct work_struct *work) tb_port_info(port, "got plug event for connected port, ignoring\n"); } else { - tb_port_info(port, "hotplug: scanning\n"); - tb_scan_port(port); - if (!port->remote) - tb_port_info(port, "hotplug: no switch found\n"); + if (tb_port_is_null(port)) { + tb_port_info(port, "hotplug: scanning\n"); + tb_scan_port(port); + if (!port->remote) + tb_port_info(port, "hotplug: no switch found\n"); + } } put_sw: diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h index d810fb188937..5ca8be0db310 100644 --- a/drivers/thunderbolt/tb.h +++ b/drivers/thunderbolt/tb.h @@ -320,6 +320,11 @@ static inline bool tb_port_has_remote(const struct tb_port *port) return true; } +static inline bool tb_port_is_null(const struct tb_port *port) +{ + return port && port->port && port->config.type == TB_TYPE_PORT; +} + static inline bool tb_port_is_pcie_down(const struct tb_port *port) { return port && port->config.type == TB_TYPE_PCIE_DOWN; -- 2.20.1