summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2015-10-08 10:43:07 -0600
committerStephen Warren <swarren@nvidia.com>2015-10-08 10:47:49 -0600
commit42f282565f8dd8fe9fb51bc5c0f5eb9adf813f67 (patch)
treef9b1aeaa37f0982b49fe1fdb17aa85846547c23c /src/main.c
parentd8eb1cef0885d936df271e8f96b8a036bc8a7411 (diff)
downloadtegrarcm-42f282565f8dd8fe9fb51bc5c0f5eb9adf813f67.tar.gz
Match USB port ID on re-enumeration
When executing the RCM process, the Tegra device will be re-enumerated on the USB bus once the miniloader is booted. This requires tegrarcm to search for it again. In a system with multiple attached Tegra boards, all being booted/shutdown in parallel, it is possible that the second call to usb_open() will find a different Tegra device. Solve this issue by having usb_open() record the exact physical USB port path of the device, and match only that path on subsequent searches. This will be robust except in the case where the device being operated on is physically unplugged and replaced (not simply power-cycled) while tegrarcm is executing. This is much less likely that the previous failure modes. This feature also enables the next patch in this series. Signed-off-by: Stephen Warren <swarren@nvidia.com>
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/main.c b/src/main.c
index 50adc14..4936d02 100644
--- a/src/main.c
+++ b/src/main.c
@@ -136,6 +136,12 @@ int main(int argc, char **argv)
int do_read = 0;
char *mlfile = NULL;
uint32_t mlentry = 0;
+#ifdef HAVE_USB_PORT_MATCH
+ bool match_port = false;
+ uint8_t match_bus;
+ uint8_t match_ports[PORT_MATCH_MAX_PORTS];
+ int match_ports_len;
+#endif
static struct option long_options[] = {
[OPT_BCT] = {"bct", 1, 0, 0},
@@ -232,7 +238,11 @@ int main(int argc, char **argv)
printf("entry addr 0x%x\n", entryaddr);
}
- usb = usb_open(USB_VENID_NVIDIA, &devid);
+ usb = usb_open(USB_VENID_NVIDIA, &devid
+#ifdef HAVE_USB_PORT_MATCH
+ , &match_port, &match_bus, match_ports, &match_ports_len
+#endif
+ );
if (!usb)
error(1, errno, "could not open USB device");
printf("device id: 0x%x\n", devid);
@@ -259,7 +269,11 @@ int main(int argc, char **argv)
// device may have re-enumerated, so reopen USB
usb_close(usb);
- usb = usb_open(USB_VENID_NVIDIA, &devid);
+ usb = usb_open(USB_VENID_NVIDIA, &devid
+#ifdef HAVE_USB_PORT_MATCH
+ , &match_port, &match_bus, match_ports, &match_ports_len
+#endif
+ );
if (!usb)
error(1, errno, "could not open USB device");
}