PCI/pwrctrl: tc9563: Use gpiod_set_value_cansleep() for RESX
Subsystems (2)
PATCH 1/1 PCI/pwrctrl: tc9563: Use gpiod_set_value_cansleep() for RESX
The RESX GPIO may be provided by a sleeping GPIO controller, such as an I2C or SPI I/O expander. Calling gpiod_set_value() for such a GPIO triggers the following warning:
WARNING: ... drivers/gpio/gpiolib.c:4030 at gpiod_set_value()
The TC9563 power-on and power-off callbacks already sleep while enabling or disabling regulators and while waiting for oscillator stabilization. Use gpiod_set_value_cansleep() for RESX so it can be driven without triggering the warning.
--- drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c +2 -2
@@ -481,7 +481,7 @@ static int tc9563_pwrctrl_power_off(struct pci_pwrctrl *pwrctrl)struct tc9563_pwrctrl *tc9563 =container_of (pwrctrl, struct tc9563_pwrctrl, pwrctrl); -gpiod_set_value (tc9563->reset_gpio,1 ); +gpiod_set_value_cansleep (tc9563->reset_gpio,1 );regulator_bulk_disable (ARRAY_SIZE (tc9563->supplies), tc9563->supplies);
@@ -501,7 +501,7 @@ static int tc9563_pwrctrl_power_on(struct pci_pwrctrl *pwrctrl)if (ret <0 )return dev_err_probe (dev, ret,"cannot enable regulators\n" ); -gpiod_set_value (tc9563->reset_gpio,0 ); +gpiod_set_value_cansleep (tc9563->reset_gpio,0 );fsleep (TC9563_OSC_STAB_DELAY_US );
---
base-commit: 4b18edbd8e70f7e6860d56370f13244896d0f95c
change-id: 20260825-pci-pwrctl-tc9563-use-cansleep-for-resx-f6e1f65547fc
Best regards,
Signature · 1 line
Abel Vesa <[email protected]>
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] I2C/SPI transfers during the noirq phase of system suspend/resume will timeout and fail if the host controller relies on interrupts. --
--- Patch [1]: [PATCH] PCI/pwrctrl: tc9563: Use gpiod_set_value_cansleep() for RESX --- commit cc5d1431bebcee3e75ac6e1b5150b5971fe40f41
Author: Abel Vesa <[email protected]>
PCI/pwrctrl: tc9563: Use gpiod_set_value_cansleep() for RESX
This patch changes gpiod_set_value() to gpiod_set_value_cansleep() for the RESX GPIO in the TC9563 power-on and power-off callbacks. This prevents warnings when the GPIO is provided by a sleeping controller, such as an I2C or SPI I/O expander.
Quoted 14 lines
drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c +1
-1@@ -481,7 +481,7 @@ static int tc9563_pwrctrl_power_off(struct pci_pwrctrl *pwrctrl)struct tc9563_pwrctrl *tc9563 =container_of (pwrctrl, struct tc9563_pwrctrl, pwrctrl); -gpiod_set_value (tc9563->reset_gpio,1 ); +gpiod_set_value_cansleep (tc9563->reset_gpio,1 );regulator_bulk_disable (ARRAY_SIZE (tc9563->supplies), tc9563->supplies);
drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c static int tc9563_pwrctrl_power_on(struct pci_pwrctrl *pwrctrl) · line 504
Quoted 5 lines
drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c +1
-1@@ -501,7 +501,7 @@ static int tc9563_pwrctrl_power_on(struct pci_pwrctrl *pwrctrl)if (ret <0 )return dev_err_probe (dev, ret,"cannot enable regulators\n" ); -gpiod_set_value (tc9563->reset_gpio,0 ); +gpiod_set_value_cansleep (tc9563->reset_gpio,0 );
[Severity: High]
This isn't a bug introduced by this patch, but it makes a pre-existing issue more apparent by acknowledging the GPIO's I2C/SPI dependency.
Will I2C/SPI transfers during the noirq phase of system suspend/resume timeout and fail if the host controller relies on interrupts?
During system suspend/resume, the PCIe host controller executes qcom_pcie_suspend_noirq() or qcom_pcie_resume_noirq(), which eventually call pci_pwrctrl_power_off_devices() or pci_pwrctrl_power_on_devices(). These invoke tc9563_pwrctrl_power_off() and tc9563_pwrctrl_power_on().
During the noirq phase, device interrupts are disabled system-wide via suspend_device_irqs(). Because local CPU interrupts remain enabled, i2c_in_atomic_xfer_mode() evaluates to false, causing the I2C core to use the standard interrupt-driven master_xfer() rather than master_xfer_atomic().
Since the I2C controller's device interrupt is disabled, won't the transfer time out and fail, potentially causing a system freeze or suspend/resume failure?
This would affect both the sleeping GPIO expander and the I2C bulk writes performed later in tc9563_pwrctrl_power_on() when calling tc9563_pwrctrl_disable_port().
[ ... ]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20260825-pci-pwrctl-tc9563-use-cansleep-for-resx-v1-1-0dbe7cfd8200@oss.qualcomm.com?part=1
Quoted 54 lines · On 26-08-25 11:52:46, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] I2C/SPI transfers during the noirq phase of system suspend/resume will timeout and fail if the host controller relies on interrupts. ----- Patch [1]: [PATCH] PCI/pwrctrl: tc9563: Use
gpiod_set_value_cansleep()for RESX --- commitcc5d1431bebcee3e75ac6e1b5150b5971fe40f41
Author: Abel Vesa <[email protected]>PCI/pwrctrl: tc9563: Use
gpiod_set_value_cansleep()for RESXThis patch changes
gpiod_set_value()togpiod_set_value_cansleep()for the RESX GPIO in the TC9563 power-on and power-off callbacks. This prevents warnings when the GPIO is provided by a sleeping controller, such as an I2C or SPI I/O expander.Quoted 14 lines
drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c +1
-1@@ -481,7 +481,7 @@ static int tc9563_pwrctrl_power_off(struct pci_pwrctrl *pwrctrl)struct tc9563_pwrctrl *tc9563 =container_of (pwrctrl, struct tc9563_pwrctrl, pwrctrl); -gpiod_set_value (tc9563->reset_gpio,1 ); +gpiod_set_value_cansleep (tc9563->reset_gpio,1 );regulator_bulk_disable (ARRAY_SIZE (tc9563->supplies), tc9563->supplies);drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c static int tc9563_pwrctrl_power_on(struct pci_pwrctrl *pwrctrl) · line 504
Quoted 5 lines
drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c +1
-1@@ -501,7 +501,7 @@ static int tc9563_pwrctrl_power_on(struct pci_pwrctrl *pwrctrl)if (ret <0 )return dev_err_probe (dev, ret,"cannot enable regulators\n" ); -gpiod_set_value (tc9563->reset_gpio,0 ); +gpiod_set_value_cansleep (tc9563->reset_gpio,0 );[Severity: High]
This isn't a bug introduced by this patch, but it makes a pre-existing issue more apparent by acknowledging the GPIO's I2C/SPI dependency.Will I2C/SPI transfers during the noirq phase of system suspend/resume timeout and fail if the host controller relies on interrupts?
During system suspend/resume, the PCIe host controller executes
qcom_pcie_suspend_noirq()orqcom_pcie_resume_noirq(), which eventually callpci_pwrctrl_power_off_devices()orpci_pwrctrl_power_on_devices(). These invoketc9563_pwrctrl_power_off()andtc9563_pwrctrl_power_on().During the noirq phase, device interrupts are disabled system-wide via
suspend_device_irqs(). Because local CPU interrupts remain enabled,i2c_in_atomic_xfer_mode()evaluates to false, causing the I2C core to use the standard interrupt-drivenmaster_xfer()rather thanmaster_xfer_atomic().
Quoted 7 lines
Since the I2C controller's device interrupt is disabled, won't the transfer time out and fail, potentially causing a system freeze or suspend/resume failure?
This would affect both the sleeping GPIO expander and the I2C bulk writes performed later in
tc9563_pwrctrl_power_on()when callingtc9563_pwrctrl_disable_port().
Duly noted.
Needs to be addressed separately.
Quoted 6 lines · Abel Vesa
The RESX GPIO may be provided by a sleeping GPIO controller, such as an I2C or SPI I/O expander. Calling
gpiod_set_value()for such a GPIO triggers the following warning:WARNING: ...
drivers/gpio/gpiolib.c:4030atgpiod_set_value()
Quoted 8 lines
The TC9563 power-on and power-off callbacks already sleep while enabling or disabling regulators and while waiting for oscillator stabilization. Use
gpiod_set_value_cansleep()for RESX so it can be driven without triggering the warning.Fixes 4c9c7be47310 ("PCI: pwrctrl: Add power control driver for TC9563")Signed-off-by Abel Vesa <[email protected]>---
Quoted 6 lines · Abel Vesa
The RESX GPIO may be provided by a sleeping GPIO controller, such as an I2C or SPI I/O expander. Calling
gpiod_set_value()for such a GPIO triggers the following warning:WARNING: ...
drivers/gpio/gpiolib.c:4030atgpiod_set_value()
Quoted 7 lines
The TC9563 power-on and power-off callbacks already sleep while enabling or disabling regulators and while waiting for oscillator stabilization. Use
gpiod_set_value_cansleep()for RESX so it can be driven without triggering the warning.Fixes 4c9c7be47310 ("PCI: pwrctrl: Add power control driver for TC9563")Signed-off-by Abel Vesa <[email protected]>
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Bjorn Helgaas
AppliedQuoted 6 lines · Abel Vesa
The RESX GPIO may be provided by a sleeping GPIO controller, such as an I2C or SPI I/O expander. Calling
gpiod_set_value()for such a GPIO triggers the following warning:WARNING: ...
drivers/gpio/gpiolib.c:4030atgpiod_set_value()
Quoted 7 lines
The TC9563 power-on and power-off callbacks already sleep while enabling or disabling regulators and while waiting for oscillator stabilization. Use
gpiod_set_value_cansleep()for RESX so it can be driven without triggering the warning.Fixes 4c9c7be47310 ("PCI: pwrctrl: Add power control driver for TC9563")Signed-off-by Abel Vesa <[email protected]>
Applied to pci/pwrctrl for v7.4 with subject line:
PCI/pwrctrl: tc9563: Allow RESX reset assertion to sleep
to focus on the behavioral change. Let me know if this doesn't capture it correctly.
Quoted 35 lines
--- drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c +2
-3@@ -481,7 +481,7 @@ static int tc9563_pwrctrl_power_off(struct pci_pwrctrl *pwrctrl)struct tc9563_pwrctrl *tc9563 =container_of (pwrctrl, struct tc9563_pwrctrl, pwrctrl); -gpiod_set_value (tc9563->reset_gpio,1 ); +gpiod_set_value_cansleep (tc9563->reset_gpio,1 );regulator_bulk_disable (ARRAY_SIZE (tc9563->supplies), tc9563->supplies);@@ -501,7 +501,7 @@ static int tc9563_pwrctrl_power_on(struct pci_pwrctrl *pwrctrl)if (ret <0 )return dev_err_probe (dev, ret,"cannot enable regulators\n" ); -gpiod_set_value (tc9563->reset_gpio,0 ); +gpiod_set_value_cansleep (tc9563->reset_gpio,0 );fsleep (TC9563_OSC_STAB_DELAY_US ); ---base-commit:
4b18edbd8e70f7e6860d56370f13244896d0f95c
change-id: 20260825-pci-pwrctl-tc9563-use-cansleep-for-resx-f6e1f65547fcBest regards,
Signature · 1 line
Abel Vesa <[email protected]>