From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: linux-usb@vger.kernel.org
Cc: Yehezkel Bernat <YehezkelShB@gmail.com>,
Lukas Wunner <lukas@wunner.de>,
Andreas Noever <andreas.noever@gmail.com>,
Rene Sapiens <rene.sapiens@linux.intel.com>,
Mika Westerberg <mika.westerberg@linux.intel.com>
Subject: [PATCH 1/2] thunderbolt: Read router NVM version before applying quirks
Date: Tue, 24 Feb 2026 08:01:49 +0100 [thread overview]
Message-ID: <20260224070150.3320641-2-mika.westerberg@linux.intel.com> (raw)
In-Reply-To: <20260224070150.3320641-1-mika.westerberg@linux.intel.com>
From: Rene Sapiens <rene.sapiens@linux.intel.com>
The router NVM version is currently only available after the NVMem devices
have been registered. This is too late for firmware-dependent quirks that
are evaluated during tb_switch_add() before device registration.
Split router NVM handling into two phases:
- tb_switch_nvm_init() allocates the NVM object and reads the version
- tb_switch_nvm_add() registers the NVMem devices using the pre-read NVM
This makes the NVM major/minor version available before tb_check_quirks()
without changing when the NVMem devices are registered.
Signed-off-by: Rene Sapiens <rene.sapiens@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
drivers/thunderbolt/switch.c | 30 ++++++++++++++++++++++++++----
1 file changed, 26 insertions(+), 4 deletions(-)
diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c
index e5b48a331c58..c2ad58b19e7b 100644
--- a/drivers/thunderbolt/switch.c
+++ b/drivers/thunderbolt/switch.c
@@ -347,7 +347,7 @@ static int nvm_write(void *priv, unsigned int offset, void *val, size_t bytes)
return ret;
}
-static int tb_switch_nvm_add(struct tb_switch *sw)
+static int tb_switch_nvm_init(struct tb_switch *sw)
{
struct tb_nvm *nvm;
int ret;
@@ -365,6 +365,26 @@ static int tb_switch_nvm_add(struct tb_switch *sw)
if (ret)
goto err_nvm;
+ sw->nvm = nvm;
+ return 0;
+
+err_nvm:
+ tb_sw_dbg(sw, "NVM upgrade disabled\n");
+ sw->no_nvm_upgrade = true;
+ if (!IS_ERR(nvm))
+ tb_nvm_free(nvm);
+
+ return ret;
+}
+
+static int tb_switch_nvm_add(struct tb_switch *sw)
+{
+ struct tb_nvm *nvm = sw->nvm;
+ int ret;
+
+ if (!nvm)
+ return 0;
+
/*
* If the switch is in safe-mode the only accessible portion of
* the NVM is the non-active one where userspace is expected to
@@ -383,14 +403,12 @@ static int tb_switch_nvm_add(struct tb_switch *sw)
goto err_nvm;
}
- sw->nvm = nvm;
return 0;
err_nvm:
tb_sw_dbg(sw, "NVM upgrade disabled\n");
sw->no_nvm_upgrade = true;
- if (!IS_ERR(nvm))
- tb_nvm_free(nvm);
+ tb_nvm_free(nvm);
return ret;
}
@@ -3311,6 +3329,10 @@ int tb_switch_add(struct tb_switch *sw)
return ret;
}
+ ret = tb_switch_nvm_init(sw);
+ if (ret)
+ return ret;
+
if (!sw->safe_mode) {
tb_switch_credits_init(sw);
--
2.50.1
next prev parent reply other threads:[~2026-02-24 7:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-24 7:01 [PATCH 0/2] thunderbolt: Disable CL states on older Titan Ridge firmware Mika Westerberg
2026-02-24 7:01 ` Mika Westerberg [this message]
2026-02-24 7:01 ` [PATCH 2/2] thunderbolt: Disable CLx on Titan Ridge-based devices with old firmware Mika Westerberg
2026-03-02 6:52 ` [PATCH 0/2] thunderbolt: Disable CL states on older Titan Ridge firmware 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=20260224070150.3320641-2-mika.westerberg@linux.intel.com \
--to=mika.westerberg@linux.intel.com \
--cc=YehezkelShB@gmail.com \
--cc=andreas.noever@gmail.com \
--cc=linux-usb@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=rene.sapiens@linux.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox