Received: by 2002:ac0:8c8e:0:0:0:0:0 with SMTP id r14csp595449ima; Wed, 6 Feb 2019 05:23:40 -0800 (PST) X-Google-Smtp-Source: AHgI3IaHRMYj95D9PgVaCFy3MoO5DNVSbVCkRfgcQ3c8gyLowH4Xk4ls08BIaQDLBdUVVRdCMmmU X-Received: by 2002:a17:902:2aa8:: with SMTP id j37mr10370634plb.226.1549459420269; Wed, 06 Feb 2019 05:23:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549459420; cv=none; d=google.com; s=arc-20160816; b=lJK+fp252UFtjFd6XtF4mrBFE2lgNy92ugNpnbfhhVX5+dQf54f+bqN+yGkghRRovJ 8oFahNbN/rvSquj5xt8+6brk7Wq02PPsmg2GBrnXwswSNffzAdbiOAdsNnsaGFgLCYhA DVVyr5k0z8GKwje2jjYVr2AequqTifgfE+RArc2R6qp9TLCco30ZuKxq2+a8mUT45PWK sUrLBNw0VcOEGHaR+OeVbNWYfQ3y9wIjbDI5aUdtkNhJQyHRwYQtiZsmAsF1siD1HM5T MWS9gfRVyynjEnWSzWyY2KWISSiyMhM93Z3va3yRme1S+Q0njVSHRQ3tgSwlYiw/hPhF O0Sg== 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=zCrDhqwkb2PtMpJWuB341Nfa+8yEwWTOlik+0c0JVBI=; b=kLna42C5aTSrcnzyI3Kk10DCSAO6keYd2lRFGaBc3zGmLdj58wTp2SHxv00CgzN6b9 OUfTh0XdiYYGeeZHyeEEqdDq3M76nboBo+Xm+t7if+iVKgb+s948KNeTgfu5mw0Ry+/9 /eDzlcy4dr8xOrMHnLl4+Xhx+h+p9/NaJePFfD79njR9Qcist+xmgQgFmOEfkBKQYekH RsM3TvG/1nGSA7ge2cc3WujqasiXAJ9MFPl7e1Rr8mr93HXDtK9N07W2dGykSdVZeSZX D3Sw9526s9+faQgJFfexCWcWeSMpUvubX4M1eqSkyohgdEvik67BRaf8rqS17niJBm6h 8xPA== 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 21si1676731pgk.74.2019.02.06.05.23.23; Wed, 06 Feb 2019 05:23:40 -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 S1730985AbfBFNVu (ORCPT + 99 others); Wed, 6 Feb 2019 08:21:50 -0500 Received: from mga03.intel.com ([134.134.136.65]:26750 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730244AbfBFNRr (ORCPT ); Wed, 6 Feb 2019 08:17:47 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Feb 2019 05:17:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,340,1544515200"; d="scan'208";a="136336022" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 06 Feb 2019 05:17:42 -0800 Received: by black.fi.intel.com (Postfix, from userid 1001) id DE0984ED; Wed, 6 Feb 2019 15:17:38 +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 09/28] thunderbolt: Cache adapter specific capability offset into struct port Date: Wed, 6 Feb 2019 16:17:19 +0300 Message-Id: <20190206131738.43696-10-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 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 1eee2502b5ba..ec3c274ff278 100644 --- a/drivers/thunderbolt/switch.c +++ b/drivers/thunderbolt/switch.c @@ -593,6 +593,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 30e02c716f6c..7fd88b41d082 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 3160169389cc..bab451ab31ff 100644 --- a/drivers/thunderbolt/tb.h +++ b/drivers/thunderbolt/tb.h @@ -124,6 +124,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 @@ -136,6 +137,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