-
Notifications
You must be signed in to change notification settings - Fork 64
PCIe pwrctrl changes to support cascade switches #221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
krishnachaitanya-linux
wants to merge
30
commits into
qualcomm-linux:qcom-6.18.y
Choose a base branch
from
krishnachaitanya-linux:pwrctrl
base: qcom-6.18.y
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
PCIe pwrctrl changes to support cascade switches #221
krishnachaitanya-linux
wants to merge
30
commits into
qualcomm-linux:qcom-6.18.y
from
krishnachaitanya-linux:pwrctrl
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4cb9cc6 to
0f5a629
Compare
vbadigan
approved these changes
Feb 4, 2026
vbadigan
approved these changes
Feb 4, 2026
vbadigan
approved these changes
Feb 4, 2026
vbadigan
approved these changes
Feb 4, 2026
vbadigan
approved these changes
Feb 4, 2026
vbadigan
approved these changes
Feb 4, 2026
vbadigan
approved these changes
Feb 4, 2026
vbadigan
approved these changes
Feb 4, 2026
vbadigan
approved these changes
Feb 4, 2026
vbadigan
approved these changes
Feb 4, 2026
vbadigan
approved these changes
Feb 4, 2026
vbadigan
approved these changes
Feb 4, 2026
vbadigan
approved these changes
Feb 4, 2026
vbadigan
approved these changes
Feb 4, 2026
vbadigan
approved these changes
Feb 4, 2026
Test Matrix
|
shashim-quic
approved these changes
Feb 11, 2026
…Ie switch" This reverts commit aef67ef.
This reverts commit fa9614f.
… hooks for dwc glue drivers" This reverts commit cbaab6d.
This reverts commit eab34c8.
…start_link()" This reverts commit fddebfa.
…link is active" This reverts commit 499dae1.
This reverts commit c36944e.
Add a device tree binding for the Toshiba TC9563 PCIe switch, which provides an Ethernet MAC integrated to the 3rd downstream port and two downstream PCIe ports. Reviewed-by: Rob Herring (Arm) <[email protected]> Acked-by: Manivannan Sadhasivam <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Krishna Chaitanya Chundru <[email protected]>
Controller driver probes firsts, enables link training and scans the bus. When the PCI bridge is found, its child DT nodes will be scanned and pwrctrl devices will be created if needed. By the time pwrctrl driver probe gets called link training is already enabled by controller driver. Certain devices like TC9563 which uses PCI pwrctl framework needs to configure the device before PCI link is up. As the controller driver already enables link training as part of its probe, the moment device is powered on, controller and device participates in the link training and link can come up immediately and may not have time to configure the device. So we need to stop the link training by using assert_perst() by asserting the PERST# and de-assert the PERST# after device is configured. Acked-by: Manivannan Sadhasivam <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Krishna Chaitanya Chundru <[email protected]>
Add assert_perst() function hook for dwc glue drivers to register with assert_perst() of pci ops, allowing for better control over the link initialization and shutdown process. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Krishna Chaitanya Chundru <[email protected]>
Implement assert_perst() function op for dwc drivers. Acked-by: Manivannan Sadhasivam <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Krishna Chaitanya Chundru <[email protected]>
Add support for assert_perst() for switches like TC9563, which require configuration before the PCIe link is established. Such devices use this function op to assert the PERST# before configuring the device and once the configuration is done they de-assert the PERST#. Acked-by: Manivannan Sadhasivam <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Krishna Chaitanya Chundru <[email protected]>
TC9563 is a PCIe switch which has one upstream and three downstream ports. To one of the downstream ports integrated ethernet MAC is connected as endpoint device. Other two downstream ports are supposed to connect to external device. One Host can connect to TC9563 by upstream port. TC9563 switch needs to be configured after powering on and before the PCIe link was up. The PCIe controller driver already enables link training at the host side even before this driver probe happens, due to this when driver enables power to the switch it participates in the link training and PCIe link may come up before configuring the switch through I2C. Once the link is up the configuration done through I2C will not have any effect. To prevent the host from participating in link training, disable link training on the host side to ensure the link does not come up before the switch is configured via I2C. Based on dt property and type of the port, TC9563 is configured through I2C. Reviewed-by: Bjorn Andersson <[email protected]> Reviewed-by: Bartosz Golaszewski <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Krishna Chaitanya Chundru <[email protected]>
This driver depends on the I2C interface to configure the switch. So enforce the dependency in Kconfig so that the I2C interface is selected appropriately. This also avoids the build issues like the one reported by the LKP bot: alpha-linux-ld: alpha-linux-ld: DWARF error: could not find abbrev number 14070 drivers/pci/pwrctrl/pci-pwrctrl-tc9563.o: in function `tc9563_pwrctrl_remove': >> (.text+0x4c): undefined reference to `i2c_unregister_device' >> alpha-linux-ld: (.text+0x50): undefined reference to `i2c_unregister_device' >> alpha-linux-ld: (.text+0x60): undefined reference to `i2c_put_adapter' alpha-linux-ld: (.text+0x64): undefined reference to `i2c_put_adapter' Reported-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected] Signed-off-by: Manivannan Sadhasivam <[email protected]> Acked-by: Bartosz Golaszewski <[email protected]>
As reported by the LKP bot, semicolons are not needed at the end of the
switch and if blocks. Hence, remove them.
This fixes the below cocci warnings:
cocci warnings: (new ones prefixed by >>)
>> drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c:351:2-3: Unneeded semicolon
drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c:414:2-3: Unneeded semicolon
drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c:316:2-3: Unneeded semicolon
Reported-by: kernel test robot <[email protected]>
Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]
Signed-off-by: Manivannan Sadhasivam <[email protected]>
Acked-by: Bartosz Golaszewski <[email protected]>
… consistency
Previously the pwrseq, tc9563, and slot pwrctrl drivers used different
naming conventions for their private data structs and pointers to them,
which makes patches hard to read:
Previous names New names
------------------------------------ ----------------------------------
struct pci_pwrctrl_pwrseq_data { struct pci_pwrctrl_pwrseq {
struct pci_pwrctrl ctx; struct pci_pwrctrl pwrctrl;
struct pci_pwrctrl_pwrseq_data *data struct pci_pwrctrl_pwrseq *pwrseq
struct tc9563_pwrctrl_ctx { struct pci_pwrctrl_tc9563 {
struct tc9563_pwrctrl_ctx *ctx struct pci_pwrctrl_tc9563 *tc9563
struct pci_pwrctrl_slot_data { struct pci_pwrctrl_slot {
struct pci_pwrctrl ctx; struct pci_pwrctrl pwrctrl;
struct pci_pwrctrl_slot_data *slot struct pci_pwrctrl_slot *slot
Rename "struct pci_pwrctrl_pwrseq_data" to "pci_pwrctrl_pwrseq".
Rename the "struct pci_pwrctrl ctx" member to "struct pci_pwrctrl pwrctrl".
Rename pointers from "struct pci_pwrctrl_pwrseq_data *data" to
"struct pci_pwrctrl_pwrseq *pwrseq".
No functional change intended.
Link: https://lore.kernel.org/all/[email protected]/
Signed-off-by: Bjorn Helgaas <[email protected]>
Signed-off-by: Manivannan Sadhasivam <[email protected]>
Reviewed-by: Bartosz Golaszewski <[email protected]>
…onsistency
Previously the pwrseq, tc9563, and slot pwrctrl drivers used different
naming conventions for their private data structs and pointers to them,
which makes patches hard to read:
Previous names New names
------------------------------------ ----------------------------------
struct pci_pwrctrl_pwrseq_data { struct pci_pwrctrl_pwrseq {
struct pci_pwrctrl ctx; struct pci_pwrctrl pwrctrl;
struct pci_pwrctrl_pwrseq_data *data struct pci_pwrctrl_pwrseq *pwrseq
struct tc9563_pwrctrl_ctx { struct pci_pwrctrl_tc9563 {
struct tc9563_pwrctrl_ctx *ctx struct pci_pwrctrl_tc9563 *tc9563
struct pci_pwrctrl_slot_data { struct pci_pwrctrl_slot {
struct pci_pwrctrl ctx; struct pci_pwrctrl pwrctrl;
struct pci_pwrctrl_slot_data *slot struct pci_pwrctrl_slot *slot
Rename "struct pci_pwrctrl_slot_data" to "struct pci_pwrctrl_slot".
Rename the "struct pci_pwrctrl ctx" member to "struct pci_pwrctrl pwrctrl".
No functional change intended.
Link: https://lore.kernel.org/all/[email protected]/
Signed-off-by: Bjorn Helgaas <[email protected]>
Signed-off-by: Manivannan Sadhasivam <[email protected]>
Reviewed-by: Bartosz Golaszewski <[email protected]>
…apter() The API comment for of_find_i2c_adapter_by_node() recommends using put_device() to drop the reference count of I2C adapter instead of using i2c_put_adapter(). So replace i2c_put_adapter() with put_device(). Link: https://lore.kernel.org/all/[email protected]/ Fixes: 4c9c7be ("PCI: pwrctrl: Add power control driver for TC9563") Signed-off-by: Bjorn Helgaas <[email protected]> Signed-off-by: Manivannan Sadhasivam <[email protected]> Reviewed-by: Bartosz Golaszewski <[email protected]>
Most of pci-pwrctrl-tc9563.c fits in 80 columns. Wrap lines that are gratuitously longer. Whitespace changes only. Signed-off-by: Bjorn Helgaas <[email protected]> Signed-off-by: Manivannan Sadhasivam <[email protected]> Link: https://lore.kernel.org/r/[email protected]
Add local struct device * and struct device_node * variables to reduce repetitive pointer chasing. No functional changes intended. Signed-off-by: Bjorn Helgaas <[email protected]> Signed-off-by: Manivannan Sadhasivam <[email protected]> Link: https://lore.kernel.org/r/[email protected]
… consistency
Previously the pwrseq, tc9563, and slot pwrctrl drivers used different
naming conventions for their private data structs and pointers to them,
which makes patches hard to read:
Previous names New names
------------------------------------ ----------------------------------
struct pci_pwrctrl_pwrseq_data { struct pci_pwrctrl_pwrseq {
struct pci_pwrctrl ctx; struct pci_pwrctrl pwrctrl;
struct pci_pwrctrl_pwrseq_data *data struct pci_pwrctrl_pwrseq *pwrseq
struct tc9563_pwrctrl_ctx { struct pci_pwrctrl_tc9563 {
struct tc9563_pwrctrl_ctx *ctx struct pci_pwrctrl_tc9563 *tc9563
struct pci_pwrctrl_slot_data { struct pci_pwrctrl_slot {
struct pci_pwrctrl ctx; struct pci_pwrctrl pwrctrl;
struct pci_pwrctrl_slot_data *slot struct pci_pwrctrl_slot *slot
Rename "struct tc9563_pwrctrl_ctx" to "pci_pwrctrl_tc9563".
Move the struct pci_pwrctrl member to be the first element in struct
pci_pwrctrl_tc9563, as it is in the other drivers.
Rename pointers from "struct tc9563_pwrctrl_ctx *ctx" to
"struct pci_pwrctrl_tc9563 *tc9563".
No functional change intended.
Signed-off-by: Bjorn Helgaas <[email protected]>
Signed-off-by: Manivannan Sadhasivam <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
In order to allow the pwrctrl core to control the power on/off logic of the
pwrctrl slot driver, move the power on/off code to
pci_pwrctrl_slot_power_{off/on} helper functions.
Link: https://lore.kernel.org/all/[email protected]/
Signed-off-by: Manivannan Sadhasivam <[email protected]>
In order to allow the pwrctrl core to control the power on/off logic of the
pwrctrl pwrseq driver, move the power on/off code to
pci_pwrctrl_pwrseq_power_{off/on} helper functions.
Link: https://lore.kernel.org/all/[email protected]/
Signed-off-by: Manivannan Sadhasivam <[email protected]>
…acks
To allow the pwrctrl core to control the power on/off sequences of the
pwrctrl drivers, add the 'struct pci_pwrctrl::power_{on/off}' callbacks and
populate them in the respective pwrctrl drivers.
The pwrctrl drivers still power on the resources on their own now. So there
is no functional change.
Co-developed-by: Krishna Chaitanya Chundru <[email protected]>
Signed-off-by: Manivannan Sadhasivam <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
Tested-by: Chen-Yu Tsai <[email protected]>
Reviewed-by: Bartosz Golaszewski <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Krishna Chaitanya Chundru <[email protected]>
Previously, the PCI core created pwrctrl devices during pci_scan_device() on its own and then skipped enumeration of those devices, hoping the pwrctrl driver would power them on and trigger a bus rescan. This approach works for endpoint devices directly connected to Root Ports, but it fails for PCIe switches acting as bus extenders. When the switch requires pwrctrl support and the pwrctrl driver is not available during the pwrctrl device creation, its enumeration will be skipped during the initial PCI bus scan. This premature scan leads the PCI core to allocate resources (bridge windows, bus numbers) for the upstream bridge based on available downstream buses at scan time. For non-hotplug capable bridges, PCI core typically allocates resources based on the number of buses available during the initial bus scan, which happens to be just one if the switch is not powered on and enumerated at that time. When the switch gets enumerated later on, it will fail due to the lack of upstream resources. As a result, a PCIe switch powered on by the pwrctrl driver cannot be reliably enumerated currently. Either the switch has to be enabled in the bootloader or the switch pwrctrl driver has to be loaded during the pwrctrl device creation time to work around these issues. Introduce new APIs to explicitly create and destroy pwrctrl devices from controller drivers by recursively scanning the PCI child nodes of the controller. These APIs allow creating pwrctrl devices based on the original criteria and are intended to be called during controller probe and removal. These APIs, together with the upcoming APIs for power on/off will allow the controller drivers to power on all the devices before starting the initial bus scan, thereby solving the resource allocation issue. Link: https://lore.kernel.org/all/[email protected]/ Signed-off-by: Krishna Chaitanya Chundru <[email protected]> [mani: splitted the patch, cleaned up the code, and rewrote description] Reviewed-by: Bartosz Golaszewski <[email protected]> Signed-off-by: Manivannan Sadhasivam <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Tested-by: Chen-Yu Tsai <[email protected]>
To fix bridge resource allocation issues when powering PCI bridges with the
pwrctrl driver, introduce APIs to explicitly power on and off all related
devices simultaneously.
Previously, the individual pwrctrl drivers powered on/off the PCI devices
autonomously, without any control from the controller drivers. But to
enforce ordering with respect to powering on the devices, these APIs will
power on/off all the devices at the same time.
The pci_pwrctrl_power_on_devices() API recursively scans the PCI child
nodes, makes sure that pwrctrl drivers are bound to devices, and calls
their power_on() callbacks. If any pwrctrl driver is not bound, it will
return -EPROBE_DEFER.
Similarly, pci_pwrctrl_power_off_devices() API powers off devices
recursively via their power_off() callbacks.
These APIs are expected to be called during the controller probe and
suspend/resume time to power on/off the devices. But before calling these
APIs, the pwrctrl devices should be created using the
pci_pwrctrl_{create/destroy}_devices() APIs.
Link: https://lore.kernel.org/all/[email protected]/
Co-developed-by: Krishna Chaitanya Chundru <[email protected]>
Signed-off-by: Krishna Chaitanya Chundru <[email protected]>
Signed-off-by: Manivannan Sadhasivam <[email protected]>
[bhelgaas: return early when !pdev and unindent, move ctx.power_on/off here]
Signed-off-by: Bjorn Helgaas <[email protected]>
Tested-by: Chen-Yu Tsai <[email protected]>
Reviewed-by: Bartosz Golaszewski <[email protected]>
…y APIs Adopt pwrctrl APIs to create, power on/off, and destroy pwrctrl devices. In qcom_pcie_host_init(), call pci_pwrctrl_create_devices() to create devices, then pci_pwrctrl_power_on_devices() to power them on, both after controller resource initialization. Once successful, deassert PERST# for all devices. In qcom_pcie_host_deinit(), call pci_pwrctrl_power_off_devices() after asserting PERST#. Note that pci_pwrctrl_destroy_devices() is not called here, as deinit is only invoked during system suspend where device destruction is unnecessary. If the driver becomes removable in future, pci_pwrctrl_destroy_devices() should be called in the remove() handler. Remove the old pwrctrl framework code from the PCI core (including devlinks) as the new APIs are now the sole consumer of pwrctrl functionality. And also do not power on the pwrctrl drivers during probe() as this is now handled by the APIs. Co-developed-by: Krishna Chaitanya Chundru <[email protected]> Signed-off-by: Manivannan Sadhasivam <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Tested-by: Chen-Yu Tsai <[email protected]> Reviewed-by: Bartosz Golaszewski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Krishna Chaitanya Chundru <[email protected]>
Previously, the pcie-qcom driver probed first, deasserted PERST#, enabled link training and scanned the bus. By the time the pwrctrl driver probe got called, link training was already enabled by the controller driver. Thus the pwrctrl drivers had to call the .assert_perst() callback, to assert PERST#, power on the needed resources, and then call the .assert_perst() callback to deassert PERST#. Now since all pwrctrl drivers and this controller driver have been converted to the new pwrctrl design where the pwrctrl drivers will first power on the devices before this driver deasserts PERST# and scan the bus. So there is no longer a need for .assert_perst() callback in this driver and in DWC core driver. Hence, drop them. Signed-off-by: Manivannan Sadhasivam <[email protected]> Link: https://lore.kernel.org/r/[email protected]
Now since all .assert_callback() implementations have been removed from the controller drivers, drop the .assert_callback callback from pci.h. Reviewed-by: Bartosz Golaszewski <[email protected]> Signed-off-by: Manivannan Sadhasivam <[email protected]> Link: https://lore.kernel.org/r/[email protected]
…mity
Rename the PERST# assert/deassert helpers from
qcom_ep_reset_{assert/deassert}() to qcom_pcie_perst_{assert/deassert}() to
maintain uniformity.
Reviewed-by: Bartosz Golaszewski <[email protected]>
Signed-off-by: Manivannan Sadhasivam <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
0f5a629 to
5d29f82
Compare
vbadigan
approved these changes
Feb 11, 2026
Test Matrix
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
These changes are required to support cascade switches.
CRs-Fixed: 4426250