From: sashiko-bot@kernel.org
To: "Chunfeng Yun" <chunfeng.yun@mediatek.com>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH v4 05/14] thunderbolt: Move rpm_complete bus walk to domain.c
Date: Sat, 05 Dec 2026 08:50:22 +0000 [thread overview]
Message-ID: <sashiko-outbox-251305@kernel.org> (raw)
In-Reply-To: <20261205083342.4009278-6-chunfeng.yun@mediatek.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Low] thunderbolt: commit message wrongly claims tb_bus_type is
private to domain.c
- [Low] thunderbolt: tb_domain_complete_rpm() leaks ICM internals into
domain core
--
commit b67cb4b97423964ddf1ba9a2c60a06a557299bdc
Author: Chunfeng Yun <chunfeng.yun@mediatek.com>
thunderbolt: Move rpm_complete bus walk to domain.c
This commit moves the rpm_complete bus walk from icm.c into a new
tb_domain_complete_rpm() helper in domain.c so icm.c no longer references
tb_bus_type directly.
> Encapsulate this bus traversal inside domain.c as tb_domain_complete_rpm().
> This keeps tb_bus_type private to domain.c and eliminates the need to
> export the bus structure.
[Severity: Low]
Is tb_bus_type actually private to domain.c? It remains a non-static
global declared extern in include/linux/thunderbolt.h and used directly
by retimer.c, switch.c, and xdomain.c. The commit message should say
this keeps tb_bus_type internal to the thunderbolt core module instead.
[ ... ]
> diff --git a/drivers/thunderbolt/domain.c b/drivers/thunderbolt/domain.c
> index 24611f05b3cda..075e0f8af1e8f 100644
> --- a/drivers/thunderbolt/domain.c
> +++ b/drivers/thunderbolt/domain.c
> @@ -881,6 +881,30 @@ int tb_domain_unregister_unplugged_xdomains(struct tb *tb)
> return ctx.n;
> }
>
> +static int complete_rpm(struct device *dev, void *data)
> +{
> + struct tb_switch *sw = tb_to_switch(dev);
> +
> + if (sw && sw->tb == data)
> + complete(&sw->rpm_complete);
> +
> + return 0;
> +}
> +
> +/**
> + * tb_domain_complete_rpm() - Signal runtime resume completion for router and below
> + * @tb: Domain the router belongs to
> + * @sw: Router to complete runtime resume
> + *
> + * Signal @sw and routers below for rpm_complete because
> + * tb_switch_remove() calls pm_runtime_get_sync() that then waits for it.
> + */
> +void tb_domain_complete_rpm(struct tb *tb, struct tb_switch *sw)
> +{
> + complete_rpm(&sw->dev, tb);
> + bus_for_each_dev(&tb_bus_type, &sw->dev, tb, complete_rpm);
> +}
[Severity: Low]
Does tb_domain_complete_rpm() belong in domain.c when sw->rpm_complete is
only initialized in icm.c alloc_switch() and used by icm.c? Moving it
here (and later exporting it in commit "thunderbolt: Make PCIe NHI
support opt-in") leaks icm.c internals into the generic domain core.
The tb parameter is also redundant with sw->tb, and the kerneldoc omits
that sw and subsequent switches on the bus must be non-root switches
with initialized rpm_complete.
Walking the subtree locally in icm.c via tb_switch_for_each_port() and
tb_port_has_remote() (matching icm_unplug_children() and
tb_switch_remove()) drops the tb_bus_type dependency without adding a
domain helper or signaling unrelated switches registered after sw.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261205083342.4009278-1-chunfeng.yun@mediatek.com?part=5
next prev parent reply other threads:[~2026-12-05 8:50 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-05 8:33 [PATCH v4 00/14] thunderbolt: Add platform NHI driver and modularize PCIe NHI Chunfeng Yun
2026-12-05 8:33 ` [PATCH v4 01/14] thunderbolt: Fix error handling and unwind paths in nhi_probe() Chunfeng Yun
2026-12-05 8:50 ` sashiko-bot
2026-12-05 8:33 ` [PATCH v4 02/14] thunderbolt: Prefix NHI core symbols with tb_ and tb_ring_ Chunfeng Yun
2026-12-05 8:33 ` [PATCH v4 03/14] thunderbolt: Internalize non-MSI-X interrupt request and work in NHI core Chunfeng Yun
2026-12-05 8:51 ` sashiko-bot
2026-12-05 8:33 ` [PATCH v4 04/14] thunderbolt: Encapsulate router device type checks in switch.c Chunfeng Yun
2026-12-05 8:41 ` sashiko-bot
2026-12-05 8:33 ` [PATCH v4 05/14] thunderbolt: Move rpm_complete bus walk to domain.c Chunfeng Yun
2026-12-05 8:50 ` sashiko-bot [this message]
2026-12-05 8:33 ` [PATCH v4 06/14] thunderbolt: Consolidate domain and NHI teardown into tb_nhi_remove() Chunfeng Yun
2026-12-05 8:50 ` sashiko-bot
2026-12-05 8:33 ` [PATCH v4 07/14] thunderbolt: Move ICM mailbox functions to icm.c Chunfeng Yun
2026-12-05 8:33 ` [PATCH v4 08/14] thunderbolt: Decouple ICM probe from NHI core via .select_cm hook Chunfeng Yun
2026-12-05 8:33 ` [PATCH v4 09/14] thunderbolt: Make PCIe NHI support opt-in Chunfeng Yun
2026-12-05 8:58 ` sashiko-bot
2026-12-05 8:33 ` [PATCH v4 10/14] thunderbolt: Make nhi->ops optional Chunfeng Yun
2026-12-05 8:33 ` [PATCH v4 11/14] thunderbolt: Add platform NHI driver Chunfeng Yun
2026-12-05 8:56 ` sashiko-bot
2026-12-05 8:33 ` [PATCH v4 12/14] thunderbolt: Increase the lane adapter link-up timeout value Chunfeng Yun
2026-12-05 8:33 ` [PATCH v4 13/14] thunderbolt: Decouple the waiting time of TB_PORT_UNPLUGGED and TB_PORT_UP Chunfeng Yun
2026-12-05 8:56 ` sashiko-bot
2026-12-05 8:33 ` [PATCH v4 14/14] thunderbolt: Drop WARN_ON() in tb_disconnect_pci() Chunfeng Yun
2026-12-05 8:55 ` sashiko-bot
2026-12-05 8:58 ` [PATCH v4 00/14] thunderbolt: Add platform NHI driver and modularize PCIe NHI sashiko-bot
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=sashiko-outbox-251305@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=chunfeng.yun@mediatek.com \
--cc=linux-usb@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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