Comment 82 for bug 1766076

Revision history for this message
Greg Woodward (grw) wrote :

I'm running into a similar issue with an HP Zbook Studio G4 running Ubuntu 18.04, HP Thunderbolt 3 dock and an IOGEAR 3.0/4 Port Peripheral Sharing Switch (GUS434). Often shortly after I switch back to the HP using the USB switch I get the xHCI host controller not responding, assume dead message. Based on Oded's input above I created the following service to fix it for me:

/lib/systemd/system/xhci-watch.service
```
[Unit]
Description=Restart xhci when it dies

[Service]
ExecStart=/path/to/restart-xhci.sh

[Install]
WantedBy=multi-user.target
```

script:
```
#!/bin/bash
dmesg -l err -w -T | awk -F " " '
        /xhci_hcd.*dead/ {
                system("sleep 1");
                device=substr($7, 1, length($7)-1);

                cmd="echo -n \""device"\" | tee /sys/bus/pci/drivers/xhci_hcd/unbind";
                system(cmd);

                system("sleep 1");

                cmd="echo -n \""device"\" | tee /sys/bus/pci/drivers/xhci_hcd/bind";
                system(cmd);

                notify="notify-send \"restarting "device" \" \""$0"\" -u critical -i face-worried";
                system(notify);
         }'

```

obviously this is an ugly hack, but it might help some while a better fix is developed. My bash/awk skills are not the best, so please feel free to offer suggestions for improvement