[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <035c0d66-bddd-495c-bd23-e1d98570ba7f@oss.qualcomm.com>
Date: Thu, 18 Sep 2025 11:05:42 +0200
From: Konrad Dybcio <konrad.dybcio@....qualcomm.com>
To: Mika Westerberg <mika.westerberg@...ux.intel.com>
Cc: Konrad Dybcio <konradybcio@...nel.org>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley
<conor+dt@...nel.org>,
Bjorn Andersson <bjorn.andersson@....qualcomm.com>,
Wesley Cheng <quic_wcheng@...cinc.com>,
Jack Pham <quic_jackp@...cinc.com>,
Raghavendra Thoorpu <rthoorpu@....qualcomm.com>,
Dmitry Baryshkov <dmitry.baryshkov@....qualcomm.com>,
Mayank Rana <mayank.rana@....qualcomm.com>,
Krishna Kurapati <krishna.kurapati@....qualcomm.com>,
Manivannan Sadhasivam <manivannan.sadhasivam@....qualcomm.com>,
linux-arm-msm@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org,
Andreas Noever <andreas.noever@...il.com>,
Mika Westerberg <westeri@...nel.org>,
Yehezkel Bernat
<YehezkelShB@...il.com>, linux-usb@...r.kernel.org
Subject: Re: [PATCH RFC] dt-bindings: thunderbolt: Add Qualcomm USB4 Host
Router
On 9/18/25 7:12 AM, Mika Westerberg wrote:
> Hi,
>
> On Wed, Sep 17, 2025 at 08:36:19PM +0200, Konrad Dybcio wrote:
>> On 9/17/25 8:12 AM, Mika Westerberg wrote:
>>> Hi Konrad,
>>>
>>> On Tue, Sep 16, 2025 at 10:06:01PM +0200, Konrad Dybcio wrote:
>>>> From: Konrad Dybcio <konrad.dybcio@....qualcomm.com>
[...]
>> struct tb_nhi {
>> spinlock_t lock;
>> - struct pci_dev *pdev;
>> + struct device *dev;
>> const struct tb_nhi_ops *ops;
>> void __iomem *iobase;
>> struct tb_ring **tx_rings;
>> struct tb_ring **rx_rings;
>> - struct ida msix_ida;
>> bool going_away;
>> bool iommu_dma_protection;
>> struct work_struct interrupt_work;
>> u32 hop_count;
>> unsigned long quirks;
>> + bool is_pcie;
>> };
>>
>> +struct tb_nhi_pci {
>> + struct pci_dev *pdev;
>> + struct ida msix_ida;
>> + struct tb_nhi nhi;
>> +};
>> +
>> +static inline struct tb_nhi_pci *nhi_to_pci(struct tb_nhi *nhi)
>> +{
>> + if (WARN_ON(!nhi->is_pcie))
>> + return NULL;
>> +
>> + return container_of(nhi, struct tb_nhi_pci, nhi);
>> +}
>>
>> I suppose I can probably get this decoupling sent in advance of the rest..
>> It's quite delicate so I'm hoping I won't cause any random nullptrs for you
>
> Instead of the above is_pcie thing, can you split it so that the PCI parts
> live in pci.c and the "platform" parts live in platform.c (or perhaps this
> is fauxbus now). Then the core part of the NHI code (nhi.c) just works
> regardless of how the controller is wired to the SoC.
I'll simply try to get this decoupling sent soon, so we can debate
over material changes
> There are plenty of examples in the kernel how to do this.
>
>> - Additional steps are necessary to take the hardware out of reset, set
>> some magic values here and there, load the firmware (i.e. memcpy_toio())
>> wake up the MCU and perform Type-C magic (more on that below), all of
>> which is handled in a new qcom_usb4.c, which does that and ends its probe
>> function with a nhi_probe_common(). PM of the hardware and its providers
>> also takes place in Linux, just like with any other IP block on embedded
>> systems
>
> Call it qcom.c. But please try to move all the non-PCI generic parts into
> platform.c and then only the Qualcomm specific things live in qcom.c. Idea
> is that we can re-use all that when for example Apple Silicon support is
> added and so on.
That's the plan
[...]
>>>> +
>>>> + interrupts:
>>>> + items:
>>>> + - description: Combined event interrupt for all three rings
>>>> + - description: OOB Firmware interrupt
>>>
>>> No MSI? If not then at least I suggest to support it in the DT description.
>>
>> No, it seems like across the SoC we only have MSIs on the PCIe RCs
>>
>> Because I don't know what a valid MSI setup would look like, I'd like
>> to defer adding that description to when a platform with them pops up
>
> I it hard to change these DT bindings later on? If yes then I would
> definitely think forward and make this support MSI from the get-go.
dt-bindings (attempt to) promise an ABI-like interface, so bindings
for *a given IP block* ("dt-bindings describe the hardware") should
not change, unless there's something critically wrong (e.g. "this
could have never really worked").
Adding new properties is always OK, marking the new properties as
'required' is not (unless it falls into the aforementioned case).
It's also totally OK to add MSI properties to e.g. Apple Host Router
bindings specifically when they come around, as it's simply a different
piece of hardware. It's also OK to create a usb4-host-router.yaml down
the line, which will act as a common include and perform any
maintenance/code churn, so long as it doesn't end up in the bindings
for any specific hw block (e.g. this QC one) becoming more strict
than they were on HEAD^.
>
>> [...]
>>
>>>> + wakeup-source: true
>>>
>>> What about the "power contract"? Are you using the existing we have for
>>> ACPI:
>>>
>>> https://learn.microsoft.com/en-us/windows-hardware/drivers/pci/dsd-for-pcie-root-ports#map-native-protocols-pcie-displayport-tunneled-through-usb4-to-usb4-host-routers
>>>
>>> It was designed DT in mind but I don't think we have DT bindings for it.
>>> This is needed to make sure the driver (Connection Manager) creates the
>>> tunnels before the native protocol stacks get enumerated (e.g during power
>>> transitions).
>>
>> I added a custom entry to drivers/of/property.c, matching that name.
>> Seems to work fine (tm) so far, but then we haven't yet tested sus/res
>> much..
>>
>> Just to make sure - are we expected to ensure that the NHI device is
>> resumed before any protocol controller drivers (at runtime), or do the
>> latter have to *probe* only after they're necessary? I firmly believe
>> the former, but doesn't hurt to ask..
>
> The former. The TB driver needs to setup tunnels before native protocol
> stacks and their drivers (e.g PCIe and the like) resume. We have the
> device_link from the native "port" / device to the NHI that deals with it
> but it expects the property to be there.
OK then we're on the same page, good
>
>> [...]
>>>> + port {
>>>> + usb4_0_mode_in: endpoint {
>>>> + };
>>>
>>> This describes the Downstream Facing Port (e.g USB4 port), right? We have
>>> something similar used in Chromebooks so it would be good if we can make
>>> the bindings close to each other if possible. This allows binding firmware
>>> description to retimers (and also to "fixed/embedded" device routers as
>>> recent changes to the USB4 spec makes possible).
>>>
>>> See drivers/thunderbolt/acpi.c::tb_acpi_find_companion().
>>
>> Yes, this binding assumes the Host Router has precisely 1 DFP (Linux
>> Type-C infra isn't ready for anything more, at least not on the DT side
>> to my knowledge) and this port (which isn't necessarily the same as a
>> connector, i.e. a physical receptacle in DT speak, it simply refers to
>> an abstract data connection between two devices)
>
> Okay I'm not too familiar with the current DT bindings.
>
>> Notably, I don't think we currently describe the USB4 port (as in, the
>> usb4_port.c meaning of it) at all, but for on-SoC HRs we know all about
>> them, so perhaps a subnode description could make sense. This way we
>> could also point them to the compatible = "usb-c-connector" node
>
> It should be something (eventually at least :-)) that allows us to describe the
> USB4 ports and on-board retimers (to make it possible to upgrade firmwares
> on those even if there is no link). But also if there is "embedded link"
> device router.
FWIW on DT platforms, onboard retimers (such as the PS883x) are often
described as children of the I2C bus (see e.g. "parade,ps8830" in:
arch/arm64/boot/dts/qcom/x1-crd.dtsi), marked as 'retimer-switch',
which then typec_retimer_xxx() APIs look for using of/fwnode_graph.
Because they're not opaque, but rather self-contained platform
devices, FW updates can/will happen without the tbt subsystem in the
picture.
That said, the retimer being TBT-compliant, still shows up in the
topology:
thunderbolt 1-0:2.1: new retimer found, vendor=0x1da0 device=0x8830
I think adding description of a usb4 port should be quite simple,
I'll look into that.
Konrad
Powered by blists - more mailing lists