Received: by 2002:ac0:8c8e:0:0:0:0:0 with SMTP id r14csp594010ima; Wed, 6 Feb 2019 05:22:26 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ/YGHR86SXRCh0/T/oc8cNOuU1X8tCpUKRWFUsgVZlOfZF5u3UhHnV1+W+KCk78BOKR+nm X-Received: by 2002:a17:902:c5:: with SMTP id a63mr10823177pla.267.1549459346501; Wed, 06 Feb 2019 05:22:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549459346; cv=none; d=google.com; s=arc-20160816; b=quNbMy4sY/TkXcPaQZ8co1GuGQtCQ/ZH+VtHwQUjRu1KSRFXVve7ic2cdCDnzLoJTb /fpY4JBbGtA5i/9mBYOt9eWX5DMamWQKPeV/x2zxEn0GDK06CQ8B/hv/JdCMSX1oHekC dl56inSV9rlGRtGUnPnG2fDSk+4Udqjhlu+aJ8iYlqSW2vCGC/y3Jf7ILxxHXHtCvnhX ye+x6GQbxz35K98Antw2gW4bfIjybR5TYA3gVGOwlJxV/O/WWXnCSYF+GjLHXlpOge2G sJ37MzsLT7VCmh8gxr5gawd3g7Hyem6c2LMz2lmIDrT0ecpc+XCyI4A6IpozkSUcMcY9 mrAQ== 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=c5saVhUZdu9T7dHSuHRMCzS89gf09Fdu01ZUisZ99ig=; b=JxlcrP4R4Nwh9PnLrt0/R3jP8Mrgc2K5dYs7MPMTLueZ4I8zZIlR4Z6ymrx3BtXyb1 yAplIVT66m5ZVgmQnAK/W7WupM/S8fI1Bi3NOpAEYSWGqQek8ty0n9sr6lacR8QhVZoT Mh68svpuL2a4YW0SQQEAz+1/E57yz95XtGcmEbqjIxGKjkxWHAz8m4gnCG3mE9T0G8fr VCQatCL6yfWjIvmUAzysebfX8XfoCWofOjKRUmm6eRagmIXq+5SbF6Vzmr6jZReULauf yUb1SN/19mkcfFkS7NK1G7b16QnZPATSe+wSLlqTxDeIL3bROyRFZ29NmgGchkiQGG67 gnuA== 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 j11si4768819pgk.265.2019.02.06.05.22.10; Wed, 06 Feb 2019 05:22:26 -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 S1730972AbfBFNTw (ORCPT + 99 others); Wed, 6 Feb 2019 08:19:52 -0500 Received: from mga17.intel.com ([192.55.52.151]:45127 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730605AbfBFNRs (ORCPT ); Wed, 6 Feb 2019 08:17:48 -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 fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Feb 2019 05:17:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,340,1544515200"; d="scan'208";a="131998014" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga002.jf.intel.com with ESMTP; 06 Feb 2019 05:17:46 -0800 Received: by black.fi.intel.com (Postfix, from userid 1001) id 41D0B85B; Wed, 6 Feb 2019 15:17:39 +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 v2 18/28] thunderbolt: Scan only valid NULL adapter ports in hotplug Date: Wed, 6 Feb 2019 16:17:28 +0300 Message-Id: <20190206131738.43696-19-mika.westerberg@linux.intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190206131738.43696-1-mika.westerberg@linux.intel.com> References: <20190206131738.43696-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 f2b23b290b63..a450bebfeb92 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 5a0b831a37ad..8906ee0a8a6a 100644 --- a/drivers/thunderbolt/tb.h +++ b/drivers/thunderbolt/tb.h @@ -286,6 +286,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