Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp438490ybb; Thu, 28 Mar 2019 05:42:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqz9HN078JvX1CYFvthvIpWt/EJz/aRqF02gpfV6liNe569WZciejwiX1rvdsOrHif7pjrtb X-Received: by 2002:a63:195:: with SMTP id 143mr39999459pgb.54.1553776963128; Thu, 28 Mar 2019 05:42:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553776963; cv=none; d=google.com; s=arc-20160816; b=hw70G9FqHcio7G2TUo5KV8yIMYpJ0eBgXACE6YEY0q9itkJfGnSQHq2Af+9IbXyY0C M/new9F7O78bzqtQ+0dKJZVREyUj76q367F6s9rn3eMUTx1FNkUIdSAfbo5hu08eAWbm N0uKHvIwPrzPhThPNV88YnAq24Rp/DSaJLq6kh5pL42i0yaq91f00ujAZ7s06VcyDZe4 hZ/AqaAIYY4mzxwMixL98Oi3twhTb2eTVViJ7wPSi93QfrIDw2cjQ7zeRfpoblgy6QUN evAPja+GzIlJy5gzOmpJd/AfqnImlSLyTn5+6nTGZxQeYLeiygVHFetUt+aueJa7048p NNOA== 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=oQ1HEq4ZBMdkPLfNDLFfGWAlxqTl8FMWxhXGcLfo63I=; b=iKh+2SLDlWaSosBKCy4aS/B2kkxExiW7kF+WyD8ZK8JUD6WHADbU6K1WW5KfIWYWei Dn6SRB3BZwpygI2mL5+crJbgOYr4TQoJ242KoiflQkbFAa9eH3mbvzNL/p17foBf9q0l rhb3KRCcwiLjNPU8hvdsa43RMDr/OH7f2GyI7QDlT9RZDs1xpO9Crrij30t6824ST0hI tFQRP89zXI7B1R813uyXMlQSMYy2AxkoGa4LVP2V1vJoJhRxeqzo5Bg1iXjYBjpuLuPi cQm4bbvQnnqAQs73EsxWvj7GBoaC15+epW9hBt5PIIGMTb2OtIfAsyXA53Bbh/OwLtJR T4/Q== 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 z2si13984027plo.368.2019.03.28.05.42.27; Thu, 28 Mar 2019 05:42:43 -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 S1727135AbfC1Mgn (ORCPT + 99 others); Thu, 28 Mar 2019 08:36:43 -0400 Received: from mga11.intel.com ([192.55.52.93]:35002 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726059AbfC1Mgl (ORCPT ); Thu, 28 Mar 2019 08:36:41 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.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="126619146" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga007.jf.intel.com with ESMTP; 28 Mar 2019 05:36:38 -0700 Received: by black.fi.intel.com (Postfix, from userid 1001) id 26B4185E; 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 08/36] thunderbolt: Add dummy read after port capability list walk on Light Ridge Date: Thu, 28 Mar 2019 15:36:05 +0300 Message-Id: <20190328123633.42882-9-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 Light Ridge has an issue where reading the next capability pointer location in port config space the read data is not cleared. It is fine to read capabilities each after another so only thing we need to do is to make sure we issue dummy read after tb_port_find_cap() is finished to avoid the issue in next read. Signed-off-by: Mika Westerberg --- drivers/thunderbolt/cap.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/thunderbolt/cap.c b/drivers/thunderbolt/cap.c index a58585b4e6d9..8bf8e031f0bc 100644 --- a/drivers/thunderbolt/cap.c +++ b/drivers/thunderbolt/cap.c @@ -52,6 +52,21 @@ static int tb_port_enable_tmu(struct tb_port *port, bool enable) return tb_sw_write(sw, &value, TB_CFG_SWITCH, offset, 1); } +static void tb_port_dummy_read(struct tb_port *port) +{ + /* + * When reading from next capability pointer location in port + * config space the read data is not cleared on LR. To avoid + * reading stale data on next read perform one dummy read after + * port capabilities are walked. + */ + if (tb_switch_is_lr(port->sw)) { + u32 dummy; + + tb_port_read(port, &dummy, TB_CFG_PORT, 0, 1); + } +} + static int __tb_port_find_cap(struct tb_port *port, enum tb_port_cap cap) { u32 offset = 1; @@ -92,6 +107,7 @@ int tb_port_find_cap(struct tb_port *port, enum tb_port_cap cap) ret = __tb_port_find_cap(port, cap); + tb_port_dummy_read(port); tb_port_enable_tmu(port, false); return ret; -- 2.20.1