Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp439468ybb; Thu, 28 Mar 2019 05:43:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqwDeEgUxjh2/bVmC3H96YARfVGm0Yp7hqSsu4Azr2Wk5VnFW78V2R3kV+7p5XaWu8Lq/4pz X-Received: by 2002:aa7:8190:: with SMTP id g16mr13896828pfi.92.1553777036732; Thu, 28 Mar 2019 05:43:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553777036; cv=none; d=google.com; s=arc-20160816; b=iq5IWlHxubXCjD8hYYocWnlvIHtSQOCdBY8v1QYvjgC6YvPguZ1lbOeZ0F1jJnZwku cd2x6mpfVdjCG5wrZvn5TLbHqTnS+bTv/ThPiL0G7nHsfTIflGBBxyBSPxcYr2ZeO74A Ekkt9Co8vTj7tbeb/UHciloXuZ1JgQgcfhmjLT0hoDbD9+rqk30gDniNxMOcHmlwy6z8 fXU4ztuK0dw9drSMWSPx5zikDJg+lUKhwLuY7tmZTtCt3+ASea13hXZ3Bk7eRue6IsHC ALl88tiRLNmIA5+OVilNuh5DS8OOB4ldSIxy0CQ6vV2bgh80bAPefq1a4tBA8q8Fp9w4 o2nA== 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=aZjNaCNNLyjLGMH5YalRd+51VEwG4ooNtqbA7CKaOks=; b=bSvsQG+/P0SNSMqN9tUtWMTVC1iorZyzKvwPu8cUpAVPcI+RQohBDmcm85fyIr6rHI OJq31L7JCySEsb5Fh39akSuKh9wcKZkrn6uvsifxb/5gBh0bgeSCJ32dmB0pNpzamfEl 5JOgbksO+VnBTjkateQl/8wZ9p+RlD5XhS0agsynX7FD2YxOzkl357p7oxxzO6OqB5Dp qJLtX735o5/fZjeHMscDu5c70KecKBSOS/jBBLNZQlAxRf2T65WztuqaqyHI8u5Ush0G W3FNZKt7+1qKRIj8ITrUz+onfyLIIgAAOiqmkk/4X7ZCAX8YUWvo6ovUfAHrHqzMF3zG DcOw== 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 f36si7433126pgf.332.2019.03.28.05.43.41; Thu, 28 Mar 2019 05:43:56 -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 S1727720AbfC1MlV (ORCPT + 99 others); Thu, 28 Mar 2019 08:41:21 -0400 Received: from mga14.intel.com ([192.55.52.115]:13995 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726949AbfC1Mgl (ORCPT ); Thu, 28 Mar 2019 08:36:41 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Mar 2019 05:36:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,280,1549958400"; d="scan'208";a="332831910" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 28 Mar 2019 05:36:38 -0700 Received: by black.fi.intel.com (Postfix, from userid 1001) id 5DCF28E0; Thu, 28 Mar 2019 14:36:34 +0200 (EET) From: Mika Westerberg To: linux-kernel@vger.kernel.org Cc: Michael Jamet , Yehezkel Bernat , Andreas Noever , Lukas Wunner , "David S . Miller" , Andy Shevchenko , Christian Kellner , Mario.Limonciello@dell.com, Mika Westerberg , netdev@vger.kernel.org Subject: [PATCH v3 13/36] thunderbolt: Cache adapter specific capability offset into struct port Date: Thu, 28 Mar 2019 15:36:10 +0300 Message-Id: <20190328123633.42882-14-mika.westerberg@linux.intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190328123633.42882-1-mika.westerberg@linux.intel.com> References: <20190328123633.42882-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 adapter specific capability either is there or not if the port does not hold an adapter. Instead of always finding it on-demand we read the offset just once when the port is initialized. While there we update the struct port documentation to follow kernel-doc format. Signed-off-by: Mika Westerberg --- drivers/thunderbolt/switch.c | 4 ++++ drivers/thunderbolt/tb.c | 8 ++++---- drivers/thunderbolt/tb.h | 2 ++ drivers/thunderbolt/tunnel_pci.c | 9 +++------ 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c index b3f93ebe6e39..9756e6279dc9 100644 --- a/drivers/thunderbolt/switch.c +++ b/drivers/thunderbolt/switch.c @@ -586,6 +586,10 @@ static int tb_init_port(struct tb_port *port) port->cap_phy = cap; else tb_port_WARN(port, "non switch port without a PHY\n"); + } else if (port->port != 0) { + cap = tb_port_find_cap(port, TB_PORT_CAP_ADAP); + if (cap > 0) + port->cap_adap = cap; } tb_dump_port(port->sw->tb, &port->config); diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c index d8f4ed0f2ef8..e71530d0af65 100644 --- a/drivers/thunderbolt/tb.c +++ b/drivers/thunderbolt/tb.c @@ -151,8 +151,8 @@ static struct tb_port *tb_find_unused_down_port(struct tb_switch *sw) continue; if (sw->ports[i].config.type != TB_TYPE_PCIE_DOWN) continue; - cap = tb_port_find_cap(&sw->ports[i], TB_PORT_CAP_ADAP); - if (cap < 0) + cap = sw->ports[i].cap_adap; + if (!cap) continue; res = tb_port_read(&sw->ports[i], &data, TB_CFG_PORT, cap, 1); if (res < 0) @@ -197,8 +197,8 @@ static void tb_activate_pcie_devices(struct tb *tb) } /* check whether port is already activated */ - cap = tb_port_find_cap(up_port, TB_PORT_CAP_ADAP); - if (cap < 0) + cap = up_port->cap_adap; + if (!cap) continue; if (tb_port_read(up_port, &data, TB_CFG_PORT, cap, 1)) continue; diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h index 985a48a67a43..b4d7c4d408bd 100644 --- a/drivers/thunderbolt/tb.h +++ b/drivers/thunderbolt/tb.h @@ -121,6 +121,7 @@ struct tb_switch { * @remote: Remote port (%NULL if not connected) * @xdomain: Remote host (%NULL if not connected) * @cap_phy: Offset, zero if not found + * @cap_adap: Offset of the adapter specific capability (%0 if not present) * @port: Port number on switch * @disabled: Disabled by eeprom * @dual_link_port: If the switch is connected using two ports, points @@ -133,6 +134,7 @@ struct tb_port { struct tb_port *remote; struct tb_xdomain *xdomain; int cap_phy; + int cap_adap; u8 port; bool disabled; struct tb_port *dual_link_port; diff --git a/drivers/thunderbolt/tunnel_pci.c b/drivers/thunderbolt/tunnel_pci.c index 0637537ea53f..2de4edccbd6d 100644 --- a/drivers/thunderbolt/tunnel_pci.c +++ b/drivers/thunderbolt/tunnel_pci.c @@ -148,12 +148,9 @@ bool tb_pci_is_invalid(struct tb_pci_tunnel *tunnel) static int tb_pci_port_active(struct tb_port *port, bool active) { u32 word = active ? 0x80000000 : 0x0; - int cap = tb_port_find_cap(port, TB_PORT_CAP_ADAP); - if (cap < 0) { - tb_port_warn(port, "TB_PORT_CAP_ADAP not found: %d\n", cap); - return cap; - } - return tb_port_write(port, &word, TB_CFG_PORT, cap, 1); + if (!port->cap_adap) + return -ENXIO; + return tb_port_write(port, &word, TB_CFG_PORT, port->cap_adap, 1); } /** -- 2.20.1