Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4755691imu; Tue, 29 Jan 2019 07:02:59 -0800 (PST) X-Google-Smtp-Source: ALg8bN54I34v8w5rdXZSZFeuVjZMM6PiIeHoMqq+3PMkEWH+wDvU/8xdvTvd8HqVcU0FCLOpzeNH X-Received: by 2002:a63:df50:: with SMTP id h16mr24259800pgj.421.1548774179398; Tue, 29 Jan 2019 07:02:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548774179; cv=none; d=google.com; s=arc-20160816; b=pnRApZuGgfbu/wWYU3NC5ZVtRZcpUq5t4DB16Lj5JkKvJ3k0HNOHbJKORlT9D7glF7 s4yrTxXpLWIGmQemZ2elCFmLZdAZKWKNSnurkjknpkqPfSSmnoaa8CPnyKIB7DVZ9Vna SAyM77u/ZPIRxyTgJIYtEFHIKYBt1+K7elo33khPF2Mgp04bWS4iPX5F4gAmpPOF2nyi IfCvIh6CCaIKIBUmw+Qy3f/3MLc2P9zBoq7vOaLmsyYEeSkZrBVYyEp+uFGNeNXHJONt DdwaMRvxQHYQxFvfMN83EQ248lBxjJ4CZYmrRn6UCKHqi99nk2AwZJh81g1tkgI80eLD H1Hg== 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=R1/ckQqo7mmyzVfESuwfJdg8sePsEByBaFqQtUoeI0I=; b=fJTt/gYMw1SZUd0AhpeecK3+K9cuJ84pAWYoqzXDDfVLKZbfIa4htWYei8noLggkEz 7k0ZzMAJLr9Us8VmynsbUaMhyVQgAck748jFjjZPo//yBCWKsHvX3aTodHVglB8m+N4H 3QSTNDgRu2nYfVocPzstDNokrP2zBJdL//tuN2Kd3tRxyVjJmTu16wwyO9aULWbElrj7 9AD73q1mK1H9F3EZ5ljgKHoVqYSAwFN5QG6/ATaBnh6P96Dai87AKp9Ux29sT/Ycy7qq yCDIpin51w+vI9GmMsQXwuonhqmwlfsoCc1hTLciaF3IZ17GApoC7luLjJ7KIDkX00Os YByw== 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 9si36688259pfq.129.2019.01.29.07.02.41; Tue, 29 Jan 2019 07:02:59 -0800 (PST) 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 S1728593AbfA2PB6 (ORCPT + 99 others); Tue, 29 Jan 2019 10:01:58 -0500 Received: from mga04.intel.com ([192.55.52.120]:40215 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728390AbfA2PBy (ORCPT ); Tue, 29 Jan 2019 10:01:54 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Jan 2019 07:01:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,537,1539673200"; d="scan'208";a="129839226" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga002.jf.intel.com with ESMTP; 29 Jan 2019 07:01:51 -0800 Received: by black.fi.intel.com (Postfix, from userid 1001) id 14BB5A2E; Tue, 29 Jan 2019 17:01:45 +0200 (EET) From: Mika Westerberg To: linux-kernel@vger.kernel.org Cc: Michael Jamet , Yehezkel Bernat , Andreas Noever , Lukas Wunner , "David S . Miller" , Mika Westerberg , Andy Shevchenko , netdev@vger.kernel.org Subject: [PATCH 18/28] thunderbolt: Scan only valid NULL adapter ports in hotplug Date: Tue, 29 Jan 2019 18:01:33 +0300 Message-Id: <20190129150143.12681-19-mika.westerberg@linux.intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190129150143.12681-1-mika.westerberg@linux.intel.com> References: <20190129150143.12681-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 c2e102f55ee0..1dcdf619d0f1 100644 --- a/drivers/thunderbolt/tb.c +++ b/drivers/thunderbolt/tb.c @@ -344,10 +344,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"); + } } out: mutex_unlock(&tb->lock); diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h index f476c3f0cb9a..b3a422ab4b4e 100644 --- a/drivers/thunderbolt/tb.h +++ b/drivers/thunderbolt/tb.h @@ -287,6 +287,11 @@ static inline struct tb_port *tb_port_at(u64 route, struct tb_switch *sw) return &sw->ports[port]; } +static inline bool tb_port_is_null(const struct tb_port *port) +{ + return port->port && port->config.type == TB_TYPE_PORT; +} + static inline int tb_sw_read(struct tb_switch *sw, void *buffer, enum tb_cfg_space space, u32 offset, u32 length) { -- 2.20.1