Skip to contentSkip to conversation

RFC: Make thunderbolt NHI driver work with kexec

PATCH In review Maxim Levitsky 1 participant 3 messages May 20, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover RFC: Make thunderbolt NHI driver work with kexec

While trying to use kexec on my desktop, which has Titan Ridge Thunderbolt add-on card, I noticed that after a kexec, system hangs for about a minute in the 'wating for udev devices to settle' phase of the boot.

I found out that if I unload the thunderbolt driver prior to the kexec, then it works just fine.

Looking at the code I see that the driver doeesn't implement .shutdown method, so this on-liner patch points it to the same method that is used on device removal.

I don't know if this is the right solution, but it does appear to work just fine with this patch.

What do you think?

Best regards,
Maxim Levitsky

Maxim Levitsky (1):
thunderbolt: add trivial .shutdown

 drivers/thunderbolt/nhi.c | 1 +
 1 file changed, 1 insertion(+)
Signature · 1 line
2.25.4
#1 lore raw

PATCH 1/1 thunderbolt: add trivial .shutdown

On my machine, a kexec with this driver loaded in the old kernel causes a very long delay on boot in the kexec'ed kernel, most likely due to unclean shutdown prior to that.

Unloading thunderbolt driver prior to kexec allows kexec to work as fast as regular kernel boot, as well as adding this .shutdown pointer.

Shutting a device prior to the shutdown completely is always a good idea IMHO to help with kexec,
and this one-liner patch implements it.

---
 drivers/thunderbolt/nhi.c | 1 +
 1 file changed, 1 insertion(+)
drivers/thunderbolt/nhi.c +1 -0
index 1be491ecbb45..4046642e6aec 100644
@@ -1285,6 +1285,7 @@ static struct pci_driver nhi_driver = {
 	.id_table = nhi_ids,
 	.probe = nhi_probe,
 	.remove = nhi_remove,
+	.shutdown = nhi_remove,
 	.driver.pm = &nhi_pm_ops,
 };
 
Signature · 1 line
2.25.4
#2 lore raw

Re: [PATCH 1/1] thunderbolt: add trivial .shutdown

Quoted 21 lines · Maxim Levitsky

On my machine, a kexec with this driver loaded in the old kernel causes a very long delay on boot in the kexec'ed kernel, most likely due to unclean shutdown prior to that.

Unloading thunderbolt driver prior to kexec allows kexec to work as fast as regular kernel boot, as well as adding this .shutdown pointer.

Shutting a device prior to the shutdown completely is always a good idea IMHO to help with kexec,
and this one-liner patch implements it.

---
 drivers/thunderbolt/nhi.c | 1 +
 1 file changed, 1 insertion(+)
drivers/thunderbolt/nhi.c +0 -0
index 1be491ecbb45..4046642e6aec 100644

drivers/thunderbolt/nhi.c static struct pci_driver nhi_driver = { · line 1291

Quoted 7 lines
drivers/thunderbolt/nhi.c +1 -0
@@ -1285,6 +1285,7 @@ static struct pci_driver nhi_driver = {
 	.id_table = nhi_ids,
 	.probe = nhi_probe,
 	.remove = nhi_remove,
+	.shutdown = nhi_remove,
 	.driver.pm = &nhi_pm_ops,
 };
 

Oops, I see that I posted this little fix on a wrong mailing list. I didn't update the script correctly.
Sorry for the noise!

Best regards,
Maxim Levitsky