Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp4211691imj; Tue, 12 Feb 2019 11:44:52 -0800 (PST) X-Google-Smtp-Source: AHgI3IaDrTO9pH9uf8cwOyXjE9f0r3SXPaGLECmf3wqJxnnNV+IiH1XZiwTtB/DBMHV3hfalv2VB X-Received: by 2002:a63:2bcd:: with SMTP id r196mr3571888pgr.355.1550000692904; Tue, 12 Feb 2019 11:44:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550000692; cv=none; d=google.com; s=arc-20160816; b=HDxY9GwNbn+k0AB0voRQ9tQnpF+IoQ+lQhGYmw0ZMbY9tXT1u/2yHfyuqWN1qOGcOC L9EQR5PF+MGa1mRI6RJQ8Qo7y805z7qV84EDDYLw3tKji9d0wB/Tn+9eDYodjukC+Ijh zdNH94EjRqztn+BGElSOtbkT0fk2OR9L/7UVE9F42tpQ1MNb0QnN+cVObLXr7nv8w632 Qby+QN/p8yqymqPy8AaokrfLtVfwyYikhaKp0ZUAXjCeL+3V4idHf1HVoLtWoF6GSiqr uvyz9LHCKZOULz0iIHM4A94nlEztAAgp9cZjXTErSRUgMz3eJOKA3oiEyotJhiFw03M2 Qywg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=2eHp2T6kBGJ6nF8wWknwhU2qfp0sUpwGEPXG0yqRX58=; b=erQWj5RGDfbGfMryMOThIH76z4WWfdwGFkKYgoJgHXh3ciR+wJ8XuTPncSMSS02Dlg rlR3YCN423hOTsW43+q3dZzld1ourlMoAz/QZNAWur9q7+uFFEpcbExrNhUNT7OQY4Yg jD1VAj+xIgNe0rFsvkvnSTSpUsxCVbQr2U0rj81xQV6YPCMhqEkIYpxwWz/q9Vrs9Wmw 54fcS3AaHzmI4WXCUlCLHB9/XiGC/kTL60QA8WG9CXqrWA7nFfrE9ssDTg2wA+90Bmrr Gl7DSJoHyTLxt8rZIpqIHk1KZqGCh8VvXEVeVXdKV8KOLpmhWN9dtxVga3yGa+zfz40i Zazw== 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 j97si6108902plb.292.2019.02.12.11.44.37; Tue, 12 Feb 2019 11:44:52 -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 S1732080AbfBLSqs (ORCPT + 99 others); Tue, 12 Feb 2019 13:46:48 -0500 Received: from mga06.intel.com ([134.134.136.31]:34920 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729007AbfBLSqr (ORCPT ); Tue, 12 Feb 2019 13:46:47 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Feb 2019 10:46:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,362,1544515200"; d="scan'208";a="133742515" Received: from lahna.fi.intel.com (HELO lahna) ([10.237.72.157]) by orsmga002.jf.intel.com with SMTP; 12 Feb 2019 10:46:44 -0800 Received: by lahna (sSMTP sendmail emulation); Tue, 12 Feb 2019 20:46:43 +0200 Date: Tue, 12 Feb 2019 20:46:43 +0200 From: Mika Westerberg To: Lukas Wunner Cc: linux-kernel@vger.kernel.org, Michael Jamet , Yehezkel Bernat , Andreas Noever , Andy Shevchenko Subject: Re: [PATCH v2 18/28] thunderbolt: Scan only valid NULL adapter ports in hotplug Message-ID: <20190212184643.GJ7875@lahna.fi.intel.com> References: <20190206131738.43696-1-mika.westerberg@linux.intel.com> <20190206131738.43696-19-mika.westerberg@linux.intel.com> <20190212140422.hiwll4cilgs7ruev@wunner.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190212140422.hiwll4cilgs7ruev@wunner.de> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 12, 2019 at 03:04:22PM +0100, Lukas Wunner wrote: > On Wed, Feb 06, 2019 at 04:17:28PM +0300, Mika Westerberg wrote: > > 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. > > Andreas called these ports TB_TYPE_PORT. If the official name is NULL, > then renaming to TB_TYPE_NULL might be a useful cleanup. (Though it > seems the control port, i.e. port 0, is also of type TB_TYPE_PORT?) Yes, they are called NULL ports. The control port does not have port config space but is still accounted in max port number of the switch and also has the type TB_TYPE_PORT but you access it when you talk to switch config space. Since the type is the same, I would like to keep it like this and differentiate control port using the port number 0 where needed. > > --- 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"); > > + } > > There's several other sanity checks further up in this function. > Why not move the tb_port_is_null() check near them, e.g. below the > check for tb_is_upstream_port()? DP adapters also get hotplug events and in subsequent patches we add handling for those in this function as well.