Re: [PATCH v3 5/8] thunderbolt: Add platform NHI driver

From: Chunfeng Yun (云春峰)

Date: Tue Dec 01 2026 - 03:54:10 EST


hi,
On 二, 2026-11-24 at 16:55 +0100, Mika Westerberg wrote:
>
> >  thunderbolt-${CONFIG_ACPI} += acpi.o
> >  thunderbolt-$(CONFIG_DEBUG_FS) += debugfs.o
> >  thunderbolt-$(CONFIG_USB4_CONFIGFS) += configfs.o
> > diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c
> > index f687b37aac91..e083493c50e0 100644
> > --- a/drivers/thunderbolt/nhi.c
> > +++ b/drivers/thunderbolt/nhi.c
> > @@ -1107,6 +1107,14 @@ static int nhi_suspend(struct device *dev)
> >  {
> >   struct tb *tb = dev_get_drvdata(dev);
> >  
> > + /*
> > + * Unlike the PCI bus, the platform bus does not
> > automatically
> > + * runtime-resume the device before invoking system
> > suspend callbacks.
> > + * Ensure the device is runtime-active before suspending
> > the domain.
> > + */
> > + if (pm_runtime_suspended(dev))
> > + pm_runtime_resume(dev);
>
> PCI does not do that either if the drivers allow that and I don't
> think we
> should do it here. There is no reason to wake it up here. The domain
> sleep
> is same for both cases anyway.

The deciding factor is the attached PM domain.

• Device Tree platform device: The platform bus and a typical genpd
power domain do not guarantee a runtime resume before the driver’s
system suspend callback. If the NHI callback needs the controller
active, it should resume it and check for failure.

• ACPI platform device: When the general ACPI PM domain is attached,
its suspend callback calls pm_runtime_resume() before the driver
callback, much like PCI does.

Due to only test on platform based on ACPI, I will drop it. may add it
back if need it when use DTS.

>
> > +
> >   return tb_domain_suspend(tb);
> >  }
> >  
> >
> > +
> > +static const struct tb_nhi_ops nhi_platform_default_ops = {
> > + .init = nhi_platform_init,
> > + .shutdown = nhi_platform_exit,
>
> nhi_platform_shutdown? Okay you use it below already but we should
> really
> look at what goes into these "ops" structs so that they actually make
> sense. It is not just a garbage bin where we can throw all random
> callbacks. I feel we are already crossing that line :-(
>
I will try to simplify struct tb_nhi_ops by handling the interrupt
setup and teardown directly in the PCI/platform glue layers
(prior to calling tb_nhi_probe() and during remove/shutdown), instead
of routing them through .init_interrupts and .shutdown callbacks.

That way, we can drop .init_interrupts, keep .shutdown strictly for
hardware-specific quirks (like icl_nhi_ops), and the platform driver
won't need its own tb_nhi_ops at all.

Thanks

> > + .init_interrupts = nhi_platform_init_irq,
> > +};
> > +
> >
>
>
> > --
> > 2.45.2
>