Re: [PATCH] thunderbolt: Don't display retimers unless nvm was initialized

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/9/2024 00:24, Mika Westerberg wrote:
Hi Mario,

On Fri, Dec 06, 2024 at 12:33:18PM -0600, Mario Limonciello wrote:
From: Mario Limonciello <mario.limonciello@xxxxxxx>

The read will never succeed if nvm wasn't initialized.

Okay but we would need to understand why it was not initialized in the
first place?

Oh sorry I should have included that/

https://gist.github.com/superm1/c3763840fefa54298258a6fbec399007

As you can see it's an unknown retimer NVM format. So this ends up down the path of "NVM upgrade disabled". So that's why I'm thinking the visibility is the right move to adjust here (IE this patch).


I see this is ThinkPad Thunderbolt 4 Dock so probably Intel hardware? You
say you can reproduce this too so can you send me full dmesg with
thunderbolt dynamic debugging enabled? I would like to understand this bit
more deeper before we add any workarounds.

Reported-by: Richard Hughes <hughsient@xxxxxxxxx>
Closes: https://github.com/fwupd/fwupd/issues/8200
Signed-off-by: Mario Limonciello <mario.limonciello@xxxxxxx>
---
  drivers/thunderbolt/retimer.c | 17 ++++++++++++++---
  1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/thunderbolt/retimer.c b/drivers/thunderbolt/retimer.c
index 89d2919d0193e..7be435aee7217 100644
--- a/drivers/thunderbolt/retimer.c
+++ b/drivers/thunderbolt/retimer.c
@@ -321,9 +321,7 @@ static ssize_t nvm_version_show(struct device *dev,
  	if (!mutex_trylock(&rt->tb->lock))
  		return restart_syscall();
- if (!rt->nvm)
-		ret = -EAGAIN;
-	else if (rt->no_nvm_upgrade)
+	if (rt->no_nvm_upgrade)
  		ret = -EOPNOTSUPP;
  	else
  		ret = sysfs_emit(buf, "%x.%x\n", rt->nvm->major, rt->nvm->minor);
@@ -342,6 +340,18 @@ static ssize_t vendor_show(struct device *dev, struct device_attribute *attr,
  }
  static DEVICE_ATTR_RO(vendor);
+static umode_t retimer_is_visible(struct kobject *kobj,
+				      struct attribute *attr, int n)
+{
+	struct device *dev = kobj_to_dev(kobj);
+	struct tb_retimer *rt = tb_to_retimer(dev);
+
+	if (!rt->nvm)
+		return 0;
+	return attr->mode;
+
+}

I just noticed I had a spurious newline here. If we end up taking this patch would you mind just fixing it up? If there is other feedback I'll fix it on a v2.

+
  static struct attribute *retimer_attrs[] = {
  	&dev_attr_device.attr,
  	&dev_attr_nvm_authenticate.attr,
@@ -351,6 +361,7 @@ static struct attribute *retimer_attrs[] = {
  };
static const struct attribute_group retimer_group = {
+	.is_visible = retimer_is_visible,
  	.attrs = retimer_attrs,
  };
--
2.43.0





[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux