summaryrefslogtreecommitdiff
path: root/drivers/thunderbolt
diff options
context:
space:
mode:
authorMika Westerberg <mika.westerberg@linux.intel.com>2021-04-21 17:14:10 +0300
committerMika Westerberg <mika.westerberg@linux.intel.com>2021-06-01 10:53:32 +0300
commit25335b30daf66f4cc03715c2ac9cdc3258fb5531 (patch)
tree98eee4560f68d23d48317016b80239e01148fd57 /drivers/thunderbolt
parentfaa1c615f0bdd4f3ac5288bf2952f49dfeac916c (diff)
thunderbolt: Check for NVM authentication status after the operation started
If the NVM authentication fails immediately, like if the firmware detects that the image is not valid for some reason, better to read the status once and if set to non-zero fail the operation accordingly. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/thunderbolt')
-rw-r--r--drivers/thunderbolt/retimer.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/drivers/thunderbolt/retimer.c b/drivers/thunderbolt/retimer.c
index 3aa790aa6500..722694052f4a 100644
--- a/drivers/thunderbolt/retimer.c
+++ b/drivers/thunderbolt/retimer.c
@@ -151,6 +151,7 @@ static int tb_retimer_nvm_validate_and_write(struct tb_retimer *rt)
static int tb_retimer_nvm_authenticate(struct tb_retimer *rt, bool auth_only)
{
+ u32 status;
int ret;
if (auth_only) {
@@ -159,7 +160,24 @@ static int tb_retimer_nvm_authenticate(struct tb_retimer *rt, bool auth_only)
return ret;
}
- return usb4_port_retimer_nvm_authenticate(rt->port, rt->index);
+ ret = usb4_port_retimer_nvm_authenticate(rt->port, rt->index);
+ if (ret)
+ return ret;
+
+ usleep_range(100, 150);
+
+ /*
+ * Check the status now if we still can access the retimer. It
+ * is expected that the below fails.
+ */
+ ret = usb4_port_retimer_nvm_authenticate_status(rt->port, rt->index,
+ &status);
+ if (!ret) {
+ rt->auth_status = status;
+ return status ? -EINVAL : 0;
+ }
+
+ return 0;
}
static ssize_t device_show(struct device *dev, struct device_attribute *attr,