From: "Chunfeng Yun (云春峰)" <Chunfeng.Yun@mediatek.com>
To: "mika.westerberg@linux.intel.com" <mika.westerberg@linux.intel.com>
Cc: "konrad.dybcio@oss.qualcomm.com" <konrad.dybcio@oss.qualcomm.com>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"westeri@kernel.org" <westeri@kernel.org>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
"YehezkelShB@gmail.com" <YehezkelShB@gmail.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"sven@kernel.org" <sven@kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"andreas.noever@gmail.com" <andreas.noever@gmail.com>,
"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
"linux-mediatek@lists.infradead.org"
<linux-mediatek@lists.infradead.org>
Subject: Re: [PATCH 1/4] thunderbolt: add platform nhi driver
Date: Thu, 5 Nov 2026 09:13:02 +0000 [thread overview]
Message-ID: <bf8472b20b9732874804cc497b85ac52844b9c3d.camel@mediatek.com> (raw)
In-Reply-To: <20261104074823.GA176724@black.igk.intel.com>
On Wed, 2026-11-04 at 08:48 +0100, mika.westerberg@linux.intel.com
wrote:
> Hi,
>
> On Wed, Nov 04, 2026 at 07:34:07AM +0000, Chunfeng Yun (云春峰) wrote:
> > >
> > > > +{
> > > > + /*
> > > > + * avoid device link fail for pcie tunnel
> > > > + */
> > >
> > > What's this?
> > explain why call these functions, without enable pm of nhi->dev,
> > tb_acpi_add_link() -> device_link_add() will fail
>
> Do you have the _DSD with the "usb4-host-interface"?
> tb_acpi_add_link()
> should take care of runtime resuming both.
Yes, add it in pcie/usb3 nodes in ACPI.
>
> > > And the comment style is not the expected.
> > will fix it.
> >
> > >
> > > > + pm_runtime_set_active(nhi->dev);
> > > > + pm_runtime_get_noresume(nhi->dev);
> > > > + devm_pm_runtime_enable(nhi->dev);
> > >
> > > This means we never runtime suspend? Then this is not good.
> > No, just enable the device's pm and get a count to link pcie/usb4's
> > device, and will release later.
> >
> > >
> > > > +
> > > > + return 0;
> > > > +}
> > > > +
> > > > +static irqreturn_t nhi_plat_isr(int irq, void *data)
> > > > +{
> > > > + struct tb_nhi *nhi = data;
> > >
> > > Did you run checkpatch.pl against this? If not please do.
> > >
> > > > + schedule_work(&nhi->interrupt_work);
> > > > + return IRQ_HANDLED;
> > > > +}
> > > > +
> > > > +static int nhi_plat_init_irq(struct tb_nhi *nhi)
> > > > +{
> > > > + int ret;
> > > > +
> > > > + INIT_WORK(&nhi->interrupt_work, nhi_interrupt_work);
> > > > +
> > > > + ret = devm_request_irq(nhi->dev, nhi->irq,
> > > > nhi_plat_isr,
> > > > IRQF_NO_SUSPEND,
> > > > + dev_name(nhi->dev), nhi);
> > > > + if (ret)
> > > > + return dev_err_probe(nhi->dev, ret, "request
> > > > irq
> > > > failed\n");
> > > > +
> > > > + return 0;
> > > > +}
> > > > +
> > > > +static void nhi_plat_exit(struct tb_nhi *nhi)
> > > > +{
> > > > + devm_free_irq(nhi->dev, nhi->irq, nhi);
> > > > + flush_work(&nhi->interrupt_work);
> > > > +
> > > > + pm_runtime_put_noidle(nhi->dev);
> > > > + pm_runtime_disable(nhi->dev);
> > > > + pm_runtime_set_suspended(nhi->dev);
> > > > +}
> > > > +
> > > > +static const struct tb_nhi_ops nhi_plat_default_ops = {
> > > > + .init = nhi_plat_init,
> > > > + .shutdown = nhi_plat_exit,
> > > > + .init_interrupts = nhi_plat_init_irq,
> > > > +};
> > > > +
> > > > +static int nhi_plat_probe(struct platform_device *pdev)
> > > > +{
> > > > + struct device *dev = &pdev->dev;
> > > > + struct tb_nhi *nhi;
> > > > +
> > > > + nhi = devm_kzalloc(dev, sizeof(*nhi), GFP_KERNEL);
> > > > + if (!nhi)
> > > > + return -ENOMEM;
> > > > +
> > > > + nhi->dev = dev;
> > > > + nhi->ops = &nhi_plat_default_ops;
> > > > +
> > > > + nhi->iobase = devm_platform_ioremap_resource(pdev, 0);
> > > > + if (IS_ERR(nhi->iobase))
> > > > + return PTR_ERR(nhi->iobase);
> > > > +
> > > > + nhi->irq = platform_get_irq(pdev, 0);
> > > > + if (nhi->irq < 0)
> > > > + return dev_err_probe(dev, nhi->irq, "get irq
> > > > failed\n");
> > > > +
> > > > + return nhi_probe(nhi);
> > > > +}
> > > > +
> > > > +static void nhi_plat_do_remove(struct platform_device *pdev,
> > > > bool
> > > > reset)
> > > > +{
> > > > + struct device *dev = &pdev->dev;
> > > > + struct tb *tb = platform_get_drvdata(pdev);
> > > > + struct tb_nhi *nhi = tb->nhi;
> > > > +
> > > > + /*
> > > > + * On system shutdown/reboot force a host router reset
> > > > so
> > > > the
> > > > + * CM asserts DPR on connected tbt3 devices before the
> > > > router tree
> > > > + * is removed (see tb_stop()).
> > > > + */
> > > > + if (reset)
> > > > + nhi->host_reset = true;
> > > > +
> > > > + pm_runtime_get_sync(dev);
> > > > + pm_runtime_dont_use_autosuspend(dev);
> > > > +
> > > > + tb_domain_remove(tb);
> > > > + wait_for_completion(&nhi->domain_released);
> > > > + nhi_shutdown(nhi);
> > > > +}
> > > > +
> > > > +static void nhi_plat_remove(struct platform_device *pdev)
> > > > +{
> > > > + nhi_plat_do_remove(pdev, false);
> > > > +}
> > > > +
> > > > +static void nhi_plat_shutdown(struct platform_device *pdev)
> > > > +{
> > > > + nhi_plat_do_remove(pdev, true);
> > > > +}
> > > > +
> > > > +
> > > > +#ifdef CONFIG_OF
> > > > +static const struct of_device_id nhi_plat_of_match[] = {
> > > > + { .compatible = "thunderbolt-platform" },
> > >
> > > Not sure if this is correct? Should this have mediatek,... ?
> > still need a common one, and also add a mediatek,thunderbolt?
> >
> > but the current platform is running on uefi/acpi but not based on
> > dts,
> >
> > should I add a dt-binding for it?
>
> Then no, that will be added when there is user for that.
>
> > > > + { }
> > > > +};
> > > > +MODULE_DEVICE_TABLE(of, nhi_plat_of_match);
> > > > +#endif
> > > > +
> > > > +#ifdef CONFIG_ACPI
> > > > +static const struct acpi_device_id nhi_plat_acpi_match[] = {
> > > > + { "ACPI0015", 0 },
> > >
> > > Same here, where is this ID defined in the ACPI spec?
> > see acpi spec release 6.5, section 5.6.7 Device Class-Specific
> > Objects,
> > Table 5.205: ACPI Device IDs
> >
> > ACPI0015
> > USB4 host interface device. See Links to ACPI-Related Documents
> > under
> > the heading “USB4 Host Interface Specification”
>
> Okay, I missed that. Then this is fine. Thanks.
>
> > > > + { }
> > > > +};
> > > > +MODULE_DEVICE_TABLE(acpi, nhi_plat_acpi_match);
> > > > +#endif
> > > > +
> > > > +static struct platform_driver nhi_plat_driver = {
> > > > + .probe = nhi_plat_probe,
> > > > + .remove = nhi_plat_remove,
> > > > + .shutdown = nhi_plat_shutdown,
> > > > + .driver = {
> > > > + .name = "thunderbolt",
> > > > + .of_match_table =
> > > > of_match_ptr(nhi_plat_of_match),
> > > > + .acpi_match_table =
> > > > ACPI_PTR(nhi_plat_acpi_match),
> > > > + .pm = &nhi_pm_ops,
> > > > + },
> > > > +};
> > > > +
> > > > +module_platform_driver(nhi_plat_driver);
> > > > +MODULE_ALIAS("platform:thunderbolt");
> > > > +MODULE_DESCRIPTION("Thunderbolt/USB4 platform host interface
> > > > driver");
> > > > +MODULE_LICENSE("GPL v2");
> > > > diff --git a/drivers/thunderbolt/tb.h
> > > > b/drivers/thunderbolt/tb.h
> > > > index e86845762e22..6dfdc47e05d2 100644
> > > > --- a/drivers/thunderbolt/tb.h
> > > > +++ b/drivers/thunderbolt/tb.h
> > > > @@ -768,8 +768,6 @@ extern const struct device_type
> > > > tb_retimer_type;
> > > > extern const struct device_type tb_switch_type;
> > > > extern const struct device_type usb4_port_device_type;
> > > >
> > > > -int tb_domain_init(void);
> > > > -void tb_domain_exit(void);
> > > > int tb_xdomain_init(void);
> > > > void tb_xdomain_exit(void);
> > > >
> > > > diff --git a/include/linux/thunderbolt.h
> > > > b/include/linux/thunderbolt.h
> > > > index 57502da29080..212c8fea6571 100644
> > > > --- a/include/linux/thunderbolt.h
> > > > +++ b/include/linux/thunderbolt.h
> > > > @@ -532,6 +532,7 @@ struct tb_nhi {
> > > > u32 *interrupt_mask;
> > > > bool going_away;
> > > > bool iommu_dma_protection;
> > > > + int irq;
> > >
> > > You are missing kernel-doc.
> > will fix it.
> >
> > Thanks
> >
> > >
> > > > struct work_struct interrupt_work;
> > > > u32 hop_count;
> > > > unsigned long quirks;
> > > > --
> > > > 2.43.0
> > >
> >
next prev parent reply other threads:[~2026-11-05 9:13 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-30 8:25 [PATCH 0/4] add support " Chunfeng Yun
2026-10-30 8:25 ` [PATCH 1/4] thunderbolt: add " Chunfeng Yun
2026-10-30 8:47 ` Mika Westerberg
2026-11-04 7:34 ` Chunfeng Yun (云春峰)
2026-11-04 7:48 ` mika.westerberg
2026-11-05 9:13 ` Chunfeng Yun (云春峰) [this message]
2026-10-31 3:41 ` kernel test robot
2026-10-31 20:03 ` kernel test robot
2026-10-30 8:25 ` [PATCH 2/4] thunderbolt: add support optional dedicated wakeup irq Chunfeng Yun
2026-10-30 8:48 ` Mika Westerberg
2026-11-03 9:05 ` Chunfeng Yun (云春峰)
2026-11-03 11:59 ` mika.westerberg
2026-11-04 7:05 ` Chunfeng Yun (云春峰)
2026-10-30 8:25 ` [PATCH 3/4] thunderbolt: improve usb3 adapter link up timeout value Chunfeng Yun
2026-10-30 8:50 ` Mika Westerberg
2026-11-03 8:13 ` Chunfeng Yun (云春峰)
2026-10-30 8:25 ` [PATCH 4/4] thunderbolt: prevent pcie tunnel activation/teardown warnings Chunfeng Yun
2026-10-30 8:56 ` Mika Westerberg
2026-11-03 8:33 ` Chunfeng Yun (云春峰)
2026-11-03 12:48 ` mika.westerberg
2026-11-04 7:09 ` Chunfeng Yun (云春峰)
2026-11-04 8:08 ` mika.westerberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bf8472b20b9732874804cc497b85ac52844b9c3d.camel@mediatek.com \
--to=chunfeng.yun@mediatek.com \
--cc=YehezkelShB@gmail.com \
--cc=andreas.noever@gmail.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=gregkh@linuxfoundation.org \
--cc=konrad.dybcio@oss.qualcomm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-usb@vger.kernel.org \
--cc=matthias.bgg@gmail.com \
--cc=mika.westerberg@linux.intel.com \
--cc=sven@kernel.org \
--cc=westeri@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®