Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
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>,
	"westeri@kernel.org" <westeri@kernel.org>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.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 v3 3/8] thunderbolt: Make PCIe NHI support opt-in
Date: Wed, 25 Nov 2026 06:53:21 +0000	[thread overview]
Message-ID: <6b07ca9aca59e0e1fd94eef53f2f6fe06c2bc62d.camel@mediatek.com> (raw)
In-Reply-To: <20261124160613.GS229695@black.igk.intel.com>

On 二, 2026-11-24 at 17:06 +0100, Mika Westerberg wrote:
> On Mon, Nov 23, 2026 at 07:36:50PM +0800, Chunfeng Yun wrote:
> > From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
> > 
> > Currently, the USB4/Thunderbolt subsystem directly depends on PCI,
> > tightly bundling the core framework with the PCIe-attached Native
> > Host
> > Interface (NHI) driver (pci.c) and the Intel Connection Manager
> > (icm.c)
> > into a single module (thunderbolt.o).
> > 
> > With support for platform/SoC-attached USB4 host controllers coming
> > in
> > (such as on ARM64 systems), the core USB4 framework should no
> > longer
> > have a hard dependency on PCI. Furthermore, embedded or SoC systems
> > without PCIe-attached host routers should be able to omit PCIe NHI
> > support to reduce kernel footprint.
> > 
> > Decouple the PCIe NHI and ICM drivers from the core framework:
> > 
> > 1. Kconfig & Makefile:
> >    - Remove "depends on PCI" from CONFIG_USB4.
> >    - Introduce CONFIG_USB4_PCI to build PCIe NHI and ICM support as
> >      a separate module (thunderbolt_pci.ko).
> > 
> > 2. Driver Registration:
> >    - Make the core thunderbolt module standalone by converting
> >      tb_domain_init/exit() to postcore_initcall() and
> > module_exit().
> >    - Register the PCIe driver in thunderbolt_pci via
> > module_pci_driver().
> > 
> > 3. Connection Manager Selection:
> >    - Add an optional .select_cm() hook to struct tb_nhi_ops so that
> > the
> >      PCIe driver can invoke icm_probe() for legacy/firmware-CM
> > controllers
> >      without hardcoding ICM calls into the core nhi.c.
> > 
> > 4. Symbol Exports:
> >    - Export necessary APIs required by pci and platform drivers.
> > 
> > Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
> > Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> > ---
> > v3:
> > Added 'default USB4' to CONFIG_USB4_PCI in Kconfig;
> > Exported tb_xdomain_remove symbol immediately after its definition;
> > 
> > v2:
> > cherry-pick the patch of Konrad to fix the issues of this series,
> > and
> > also do some changes:
> > 
> > * Renamed CONFIG_USB4_PCIE and thunderbolt_pcie.ko to
> > CONFIG_USB4_PCI
> >   and thunderbolt_pci.ko.
> > * Updated exported NHI symbols to standard tb_ / tb_ring_ prefixes
> >   (e.g., ring_msix → tb_ring_msix, nhi_msi → tb_nhi_isr).
> > * Eliminated exports for nhi_mailbox_* and nhi_interrupt_work by
> >   keeping them internal/static (handled by preparatory patches in
> > v2).
> > * Added missing trailing semicolon to
> > module_pci_driver(nhi_driver);.
> > * Expanded the commit message;
> > * Fix cherry-pick conflict caused by .reset_interface();
> > ---
> >  drivers/thunderbolt/Kconfig   | 12 ++++++++++-
> >  drivers/thunderbolt/Makefile  |  7 +++++--
> >  drivers/thunderbolt/ctl.c     |  6 +++++-
> >  drivers/thunderbolt/domain.c  | 14 +++++++++++--
> >  drivers/thunderbolt/nhi.c     | 14 ++++++-------
> >  drivers/thunderbolt/nhi.h     |  2 ++
> >  drivers/thunderbolt/pci.c     | 39 +++++++++++++------------------
> > ----
> >  drivers/thunderbolt/switch.c  |  9 ++++++++
> >  drivers/thunderbolt/tb.h      |  2 --
> >  drivers/thunderbolt/tunnel.c  |  1 +
> >  drivers/thunderbolt/xdomain.c |  5 +++++
> >  11 files changed, 71 insertions(+), 40 deletions(-)
> > 
> > diff --git a/drivers/thunderbolt/Kconfig
> > b/drivers/thunderbolt/Kconfig
> > index 294b3227a545..80960555a364 100644
> > --- a/drivers/thunderbolt/Kconfig
> > +++ b/drivers/thunderbolt/Kconfig
> > @@ -1,7 +1,6 @@
> >  # SPDX-License-Identifier: GPL-2.0-only
> >  menuconfig USB4
> >  	tristate "Unified support for USB4 and Thunderbolt"
> > -	depends on PCI
> >  	select APPLE_PROPERTIES if EFI_STUB && X86
> >  	select CRC32
> >  	select CRYPTO_LIB_SHA256
> > @@ -18,6 +17,17 @@ menuconfig USB4
> >  
> >  if USB4
> >  
> > +config USB4_PCI
> > +	tristate "Support for PCIe-attached USB4 and Thunderbolt
> > controllers"
> > +	depends on PCI
> > +	default USB4
> > +	help
> > +	  Say Y here to add support for the USB4 and Thunderbolt
> > host
> > +	  routers attached over the PCIe bus, commonly found on
> > x86 PCs.
> > +
> > +	  To compile this driver a module, choose M here. The
> > module will be
> > +	  called thunderbolt_pci.
> > +
> >  config USB4_CONFIGFS
> >  	def_tristate USB4
> >  	depends on CONFIGFS_FS && !(USB4=y && CONFIGFS_FS=m)
> > diff --git a/drivers/thunderbolt/Makefile
> > b/drivers/thunderbolt/Makefile
> > index beb054c3126b..a563bf2b0345 100644
> > --- a/drivers/thunderbolt/Makefile
> > +++ b/drivers/thunderbolt/Makefile
> > @@ -1,10 +1,13 @@
> >  # SPDX-License-Identifier: GPL-2.0-only
> >  ccflags-y := -I$(src)
> >  obj-${CONFIG_USB4} := thunderbolt.o
> > -thunderbolt-objs := nhi.o ctl.o tb.o switch.o cap.o pci.o path.o
> > tunnel.o eeprom.o
> > -thunderbolt-objs += domain.o dma_port.o icm.o property.o xdomain.o
> > lc.o tmu.o usb4.o
> > +thunderbolt-objs := nhi.o ctl.o tb.o switch.o cap.o path.o
> > tunnel.o eeprom.o
> > +thunderbolt-objs += domain.o dma_port.o property.o xdomain.o lc.o
> > tmu.o usb4.o
> >  thunderbolt-objs += usb4_port.o nvm.o retimer.o quirks.o clx.o
> >  
> > +obj-${CONFIG_USB4_PCI} += thunderbolt_pci.o
> > +thunderbolt_pci-y := pci.o icm.o
> > +
> >  thunderbolt-${CONFIG_ACPI} += acpi.o
> >  thunderbolt-$(CONFIG_DEBUG_FS) += debugfs.o
> >  thunderbolt-$(CONFIG_USB4_CONFIGFS) += configfs.o
> > diff --git a/drivers/thunderbolt/ctl.c b/drivers/thunderbolt/ctl.c
> > index 965988b18608..96717a0a94b1 100644
> > --- a/drivers/thunderbolt/ctl.c
> > +++ b/drivers/thunderbolt/ctl.c
> > @@ -9,7 +9,6 @@
> >  #include <linux/crc32.h>
> >  #include <linux/delay.h>
> >  #include <linux/slab.h>
> > -#include <linux/pci.h>
> >  #include <linux/dmapool.h>
> >  #include <linux/workqueue.h>
> >  
> > @@ -96,6 +95,7 @@ struct tb_cfg_request *tb_cfg_request_alloc(void)
> >  
> >  	return req;
> >  }
> > +EXPORT_SYMBOL_GPL(tb_cfg_request_alloc);
> 
> Why these need to be exported? All the config stuff happens inside
> USB4
> fabric and that's not dependent on how the controller is connected to
> the
> SoC.
My bad, will remove it.
> 
> Can we get the absolute minimum that is needed? 
Sure, will double check all the exports.

Thanks
> The platform/PCI sides pretty
> much need to get the resources/interrupts and then call the core
> driver.


  reply	other threads:[~2026-11-25  9:16 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 11:36 [PATCH 0/8] thunderbolt: Add support platform NHI driver Chunfeng Yun
2026-11-23 11:36 ` [PATCH v3 1/8] thunderbolt: Prefix NHI core functions with tb_ and tb_ring_ Chunfeng Yun
2026-11-24 16:11   ` Mika Westerberg
2026-11-25  6:43     ` Chunfeng Yun (云春峰)
2026-11-25  7:13       ` mika.westerberg
2026-11-23 11:36 ` [PATCH v3 2/8] thunderbolt: Move ICM mailbox functions to icm.c and internalize interrupt work Chunfeng Yun
2026-11-23 11:36 ` [PATCH v3 3/8] thunderbolt: Make PCIe NHI support opt-in Chunfeng Yun
2026-11-24 16:06   ` Mika Westerberg
2026-11-25  6:53     ` Chunfeng Yun (云春峰) [this message]
2026-11-23 11:36 ` [PATCH v3 4/8] thunderbolt: Fix error handling and unwind paths in tb_nhi_probe() Chunfeng Yun
2026-11-23 11:36 ` [PATCH v3 5/8] thunderbolt: Add platform NHI driver Chunfeng Yun
2026-11-24 15:55   ` Mika Westerberg
2026-11-25  8:47     ` Chunfeng Yun (云春峰)
2026-11-23 11:36 ` [PATCH v3 6/8] thunderbolt: Increase the lane adapter link-up timeout value Chunfeng Yun
2026-11-23 11:36 ` [PATCH v3 7/8] thunderbolt: Decouple the waiting time of TB_PORT_UNPLUGGED and TB_PORT_UP Chunfeng Yun
2026-11-24 16:00   ` Mika Westerberg
2026-11-23 11:36 ` [PATCH v3 8/8] thunderbolt: Drop WARN_ON() in tb_disconnect_pci() Chunfeng Yun

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=6b07ca9aca59e0e1fd94eef53f2f6fe06c2bc62d.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