All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: linux-usb@vger.kernel.org
Cc: Yehezkel Bernat <YehezkelShB@gmail.com>,
	Michael Jamet <michael.jamet@intel.com>,
	Lukas Wunner <lukas@wunner.de>,
	Andreas Noever <andreas.noever@gmail.com>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	kernel test robot <lkp@intel.com>, Gil Fine <gil.fine@intel.com>,
	Azhar Shaikh <azhar.shaikh@intel.com>
Subject: [PATCH 3/5] thunderbolt: Poll 10ms for REG_FW_STS_NVM_AUTH_DONE to be set
Date: Mon,  7 Jun 2021 14:00:28 +0300	[thread overview]
Message-ID: <20210607110030.38664-4-mika.westerberg@linux.intel.com> (raw)
In-Reply-To: <20210607110030.38664-1-mika.westerberg@linux.intel.com>

From: Gil Fine <gil.fine@intel.com>

In Intel Tiger Lake and beyond it takes some time after the force power
is set until the firmware connection manager is ready. So instead of
reading it once we poll it for 10ms before giving up.

Signed-off-by: Gil Fine <gil.fine@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/thunderbolt/icm.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/thunderbolt/icm.c b/drivers/thunderbolt/icm.c
index 2f30b816705a..0f25cf9fe519 100644
--- a/drivers/thunderbolt/icm.c
+++ b/drivers/thunderbolt/icm.c
@@ -1677,14 +1677,18 @@ static void icm_icl_rtd3_veto(struct tb *tb, const struct icm_pkg_header *hdr)
 
 static bool icm_tgl_is_supported(struct tb *tb)
 {
-	u32 val;
+	unsigned long end = jiffies + msecs_to_jiffies(10);
 
-	/*
-	 * If the firmware is not running use software CM. This platform
-	 * should fully support both.
-	 */
-	val = ioread32(tb->nhi->iobase + REG_FW_STS);
-	return !!(val & REG_FW_STS_NVM_AUTH_DONE);
+	do {
+		u32 val;
+
+		val = ioread32(tb->nhi->iobase + REG_FW_STS);
+		if (val & REG_FW_STS_NVM_AUTH_DONE)
+			return true;
+		usleep_range(100, 500);
+	} while (time_before(jiffies, end));
+
+	return false;
 }
 
 static void icm_handle_notification(struct work_struct *work)
-- 
2.30.2


  parent reply	other threads:[~2021-06-07 11:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-07 11:00 [PATCH 0/5] thunderbolt: Support for Intel Alder Lake and improvements Mika Westerberg
2021-06-07 11:00 ` [PATCH 1/5] thunderbolt: Bond lanes only when dual_link_port != NULL in alloc_dev_default() Mika Westerberg
2021-06-07 11:00 ` [PATCH 2/5] thunderbolt: Add device links only when software connection manager is used Mika Westerberg
2021-06-07 11:00 ` Mika Westerberg [this message]
2021-06-07 11:00 ` [PATCH 4/5] thunderbolt: No need to include <linux/acpi.h> in usb4_port.c Mika Westerberg
2021-06-07 11:00 ` [PATCH 5/5] thunderbolt: Add support for Intel Alder Lake Mika Westerberg
2021-06-07 11:52 ` [PATCH 0/5] thunderbolt: Support for Intel Alder Lake and improvements Yehezkel Bernat
2021-06-11  8:46   ` Mika Westerberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210607110030.38664-4-mika.westerberg@linux.intel.com \
    --to=mika.westerberg@linux.intel.com \
    --cc=YehezkelShB@gmail.com \
    --cc=andreas.noever@gmail.com \
    --cc=azhar.shaikh@intel.com \
    --cc=dan.carpenter@oracle.com \
    --cc=gil.fine@intel.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=lukas@wunner.de \
    --cc=michael.jamet@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.