Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+19 -1
+19 -1
drivers/thunderbolt/retimer.c
··· 151 151 152 152 static int tb_retimer_nvm_authenticate(struct tb_retimer *rt, bool auth_only) 153 153 { 154 + u32 status; 154 155 int ret; 155 156 156 157 if (auth_only) { ··· 160 159 return ret; 161 160 } 162 161 163 - return usb4_port_retimer_nvm_authenticate(rt->port, rt->index); 162 + ret = usb4_port_retimer_nvm_authenticate(rt->port, rt->index); 163 + if (ret) 164 + return ret; 165 + 166 + usleep_range(100, 150); 167 + 168 + /* 169 + * Check the status now if we still can access the retimer. It 170 + * is expected that the below fails. 171 + */ 172 + ret = usb4_port_retimer_nvm_authenticate_status(rt->port, rt->index, 173 + &status); 174 + if (!ret) { 175 + rt->auth_status = status; 176 + return status ? -EINVAL : 0; 177 + } 178 + 179 + return 0; 164 180 } 165 181 166 182 static ssize_t device_show(struct device *dev, struct device_attribute *attr,