Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp3865362imj; Tue, 12 Feb 2019 06:05:35 -0800 (PST) X-Google-Smtp-Source: AHgI3Ibi44EMcLrBav4kwQFF2evY40L6XK3Xp6Qu5z537mDshVGJmLgMRoqQzQO5r9ptW+akCvHx X-Received: by 2002:a63:db02:: with SMTP id e2mr3833747pgg.419.1549980335037; Tue, 12 Feb 2019 06:05:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549980335; cv=none; d=google.com; s=arc-20160816; b=soRE8+jPVNYqsEX2kniszhGV7aq9CzNd8T2pLaVnARsR4nRiMEd8IIdkqbwOanl4pw U9D5RY4dy4Z98Cngbm8mf+oiCvIwrfaFUzPFnIcenoNnHiImmroW4eHwx/bQI1eKkL/u acbY9/TfqEkymMYl3Zb6SOpqOGZ5P9+kT0ywTraHbttqirZm+iyJikFkswVlWiwNg2jW 1Cc4w/Tvdmlc3dRGSlLs5ofA8A0rB4K51qz1gGGM5/gqYX8IJk7fZ409LOsM1GHqbOZW WE2HAYWiF0uNTBawqRRfUMQZKAvmB/J4YEiZL1mTZq/99G/wP0BaYkgUYRoFnsv4RI9Z aMVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=37tlQwLKNgUvyfFmhew57qYAqP7nd4gaBVL/62BjCSE=; b=y3q//SAOL3RMhDCwVBheyw0CF1KibXBxpH6Ss7h61v9uAkE2Mr+qqzYYpVcbtokm5k XBfEr2RywJDWtsdBgJ5gEJ+PtuQ9xQmqA9mIVxHhdNHyBqIBSjSu36NKAWwBUuOQFy7N 6AtiDGlARAQ2LeOiW26dmCg9q7o8zxmj+XPID85DOATHUkctDDrUR67E3rgLv8Fgcf65 VFVJnsiFilHxEF0oIW4QNghXsoh5kMgrOsC+v3xS7BDK8Ortr6eo5SlRhH4aadhY9/rQ ILA0caWWM81oE9awjwkS6OgArHAS3IsVX16AHtcNvm2sCH8jST1B/PeAQrvFxwq03Bcg HV4w== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b12si12856349pls.32.2019.02.12.06.05.07; Tue, 12 Feb 2019 06:05:35 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730091AbfBLOEY (ORCPT + 99 others); Tue, 12 Feb 2019 09:04:24 -0500 Received: from bmailout2.hostsharing.net ([83.223.90.240]:33545 "EHLO bmailout2.hostsharing.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729923AbfBLOEY (ORCPT ); Tue, 12 Feb 2019 09:04:24 -0500 Received: from h08.hostsharing.net (h08.hostsharing.net [IPv6:2a01:37:1000::53df:5f1c:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.hostsharing.net", Issuer "COMODO RSA Domain Validation Secure Server CA" (not verified)) by bmailout2.hostsharing.net (Postfix) with ESMTPS id A35A72800B6DE; Tue, 12 Feb 2019 15:04:22 +0100 (CET) Received: by h08.hostsharing.net (Postfix, from userid 100393) id 5DE1313BC1A; Tue, 12 Feb 2019 15:04:22 +0100 (CET) Date: Tue, 12 Feb 2019 15:04:22 +0100 From: Lukas Wunner To: Mika Westerberg 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: <20190212140422.hiwll4cilgs7ruev@wunner.de> References: <20190206131738.43696-1-mika.westerberg@linux.intel.com> <20190206131738.43696-19-mika.westerberg@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190206131738.43696-19-mika.westerberg@linux.intel.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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?) > --- 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()? Thanks, Lukas