Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3788094imm; Mon, 18 Jun 2018 04:11:28 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIQA6LNGqOaJN394T9Zi6ATdJOifzW6aTIWgwaUo6jBzCb8tXLRaseRgtMuDcgAcq43GYMk X-Received: by 2002:aa7:85c9:: with SMTP id z9-v6mr12865438pfn.55.1529320288436; Mon, 18 Jun 2018 04:11:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529320288; cv=none; d=google.com; s=arc-20160816; b=lhtomVFbt6czZqu5SH1P15/W9cVFkq+yi34APo4aDd2YlG3in2QVG4b/uIvUwcCXpf HuUzROtL1rLHzEIlRe4m9iYUygtLmOJ9xhCdvjGzCDmSWE5ObiF2GW09Bv4MWB4RcN87 YZjPIQOuf0AexHr/fiqM0P9ykhS2OtptUlLS4aVIAV0DhtQjetl00CeseBDd+GnE9gL9 8Jkbrtz0GJ5L26LjAvW9E5Gtn+IzK8Adb09qKKKPyJS7V8eqbERZyJAhl07GGpiQXFi0 BqfrHQmt0Ug1cGcrcZgD6Js1zhbKw8w0N/+8OGa/pbZebXI0BSqQu7niNMuZhH22b1zT 26eA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=FHYHn8BfSFMamEEQV3Htxo19zAfLkjccHwMwysaCoP0=; b=TcKPuXtvfedZTicTyOB/1rWOpmSL4vuUBBEqZVGDL66X88DMwNYr978WwlKyIg+xR/ 5VA4yjM6Qsv8+Q7nj8bkoBDF0Ovxo0kAvC2C4w3G47f4FhbuNjqnYpR6ZFk6Jz9zk8b+ a3FYf4na96z2GMLxc/WvLDffROYtTgJ4jPu6QmL0AFWo441wqhLsgMPNzv7MAs6cGJJu stYbKmpH61GQ5tv7vKz4LJ6CG32bZzz6VLlkipxcA09i0Nn3BdWe8XimmuQ8quyW1fdQ W16kzponhjon32fxl/YdQJA57rNxw6CZGiyThaXp9V0bf0aejtOCeaGOcRphRTwL82xr RCzw== 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 y198-v6si14520081pfg.246.2018.06.18.04.11.14; Mon, 18 Jun 2018 04:11:28 -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 S936050AbeFRLHh (ORCPT + 99 others); Mon, 18 Jun 2018 07:07:37 -0400 Received: from mga14.intel.com ([192.55.52.115]:37633 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933537AbeFRLHd (ORCPT ); Mon, 18 Jun 2018 07:07:33 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Jun 2018 04:07:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,238,1526367600"; d="scan'208";a="65472672" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 18 Jun 2018 04:07:30 -0700 Received: by black.fi.intel.com (Postfix, from userid 1001) id 8BC09182; Mon, 18 Jun 2018 14:07:31 +0300 (EEST) From: Mika Westerberg To: linux-kernel@vger.kernel.org Cc: Andreas Noever , Michael Jamet , Yehezkel Bernat , Lukas Wunner , "Rafael J. Wysocki" , Christian Kellner , Mario Limonciello , Mika Westerberg Subject: [PATCH 2/5] thunderbolt: Do not unnecessarily call ICM get route Date: Mon, 18 Jun 2018 14:07:28 +0300 Message-Id: <20180618110731.57427-3-mika.westerberg@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618110731.57427-1-mika.westerberg@linux.intel.com> References: <20180618110731.57427-1-mika.westerberg@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This command is not really fast and can make resume time slower. We only need to get route again if the link was changed and during initial device connected message. Signed-off-by: Mika Westerberg --- drivers/thunderbolt/icm.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/drivers/thunderbolt/icm.c b/drivers/thunderbolt/icm.c index 500911f16498..ad4eeaa59b16 100644 --- a/drivers/thunderbolt/icm.c +++ b/drivers/thunderbolt/icm.c @@ -534,20 +534,13 @@ icm_fr_device_connected(struct tb *tb, const struct icm_pkg_header *hdr) return; } - ret = icm->get_route(tb, link, depth, &route); - if (ret) { - tb_err(tb, "failed to find route string for switch at %u.%u\n", - link, depth); - return; - } - sw = tb_switch_find_by_uuid(tb, &pkg->ep_uuid); if (sw) { u8 phy_port, sw_phy_port; parent_sw = tb_to_switch(sw->dev.parent); - sw_phy_port = phy_port_from_route(tb_route(sw), sw->depth); - phy_port = phy_port_from_route(route, depth); + sw_phy_port = tb_phy_port_from_link(sw->link); + phy_port = tb_phy_port_from_link(link); /* * On resume ICM will send us connected events for the @@ -559,6 +552,22 @@ icm_fr_device_connected(struct tb *tb, const struct icm_pkg_header *hdr) */ if (sw->depth == depth && sw_phy_port == phy_port && !!sw->authorized == authorized) { + /* + * It was enumerated through another link so update + * route string accordingly. + */ + if (sw->link != link) { + ret = icm->get_route(tb, link, depth, &route); + if (ret) { + tb_err(tb, "failed to update route string for switch at %u.%u\n", + link, depth); + tb_switch_put(sw); + return; + } + } else { + route = tb_route(sw); + } + update_switch(parent_sw, sw, route, pkg->connection_id, pkg->connection_key, link, depth, boot); tb_switch_put(sw); @@ -607,6 +616,14 @@ icm_fr_device_connected(struct tb *tb, const struct icm_pkg_header *hdr) return; } + ret = icm->get_route(tb, link, depth, &route); + if (ret) { + tb_err(tb, "failed to find route string for switch at %u.%u\n", + link, depth); + tb_switch_put(parent_sw); + return; + } + add_switch(parent_sw, route, &pkg->ep_uuid, pkg->connection_id, pkg->connection_key, link, depth, security_level, authorized, boot); -- 2.17.1