PCI: rockchip: Move PCIE_WAKE handling into rockchip pcie driver
v5 cover PCI: rockchip: Move PCIE_WAKE handling into rockchip pcie driver
Currently we are handling pcie wake in mrvl wifi driver. But Brian suggests to move it into rockchip pcie driver.
Tested on my chromebook bob(with cros 4.4 kernel and mrvl wifi).
Changes in v5:
Rebase
Move to pci.txt
Use "wakeup" instead of "wake"
Changes in v3:
Fix error handling
Changes in v2:
Use dev_pm_set_dedicated_wake_irq
-- Suggested by Brian Norris <[email protected]>
Jeffy Chen (3):
PCI: rockchip: Add support for pcie wake irq
dt-bindings: PCI: Add definition of pcie wake irq
arm64: dts: rockchip: Handle pcie wake in pcie driver for Gru
Documentation/devicetree/bindings/pci/pci.txt | 2 ++ arch/arm64/boot/dts/rockchip/rk3399-gru.dtsi | 15 +++++++++------ drivers/pci/host/pcie-rockchip.c | 19 +++++++++++++++++-- 3 files changed, 28 insertions(+), 8 deletions(-)
Signature · 1 line
2.11.0
PATCH v5 1/3 PCI: rockchip: Add support for pcie wake irq
Add support for PCIE_WAKE pin in rockchip pcie driver.
---
Changes in v5:
Rebase
Changes in v3:
Fix error handling
Changes in v2:
Use dev_pm_set_dedicated_wake_irq
-- Suggested by Brian Norris <[email protected]>
drivers/pci/host/pcie-rockchip.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
drivers/pci/host/pcie-rockchip.c +17 -2
@@ -37,6 +37,7 @@#include <linux/pci_ids.h> #include <linux/phy/phy.h> #include <linux/platform_device.h> +#include <linux/pm_wakeirq.h> #include <linux/reset.h> #include <linux/regmap.h>
@@ -995,6 +996,15 @@ static int rockchip_pcie_setup_irq(struct rockchip_pcie *rockchip)return err; } +/* Must init wakeup before setting dedicated wakeup irq. */ +device_init_wakeup (dev, true); + irq =platform_get_irq_byname (pdev,"wakeup" ); +if (irq >=0 ) { + err =dev_pm_set_dedicated_wake_irq (dev, irq); +if (err) +dev_err (dev,"failed to setup PCIe wakeup IRQ\n" ); + } +return 0 ; }
@@ -1542,11 +1552,11 @@ static int rockchip_pcie_probe(struct platform_device *pdev) err =rockchip_pcie_parse_dt (rockchip);if (err) -return err; + goto err_disable_wake; err =rockchip_pcie_enable_clocks (rockchip);if (err) -return err; + goto err_disable_wake; err =rockchip_pcie_set_vpcie (rockchip);if (err) {
@@ -1656,6 +1666,9 @@ static int rockchip_pcie_probe(struct platform_device *pdev)regulator_disable (rockchip->vpcie0v9); err_set_vpcie:rockchip_pcie_disable_clocks (rockchip); +err_disable_wake: +dev_pm_clear_wake_irq (dev); +device_init_wakeup (dev, false);return err; }
@@ -1682,6 +1695,8 @@ static int rockchip_pcie_remove(struct platform_device *pdev)if (!IS_ERR (rockchip->vpcie0v9))regulator_disable (rockchip->vpcie0v9); +dev_pm_clear_wake_irq (dev); +device_init_wakeup (dev, false);return 0 ; }
Signature · 1 line
2.11.0
PATCH v5 1/3 PCI: rockchip: Add support for pcie wake irq
Quoted 5 lines · Jeffy Chen
Add support for
PCIE_WAKEpin in rockchip pcie driver.Signed-off-by Jeffy Chen <[email protected]>---
LGTM,
Quoted 75 lines
Changes in v5:
RebaseChanges in v3:
Fix error handlingChanges in v2:
Usedev_pm_set_dedicated_wake_irq
-- Suggested by Brian Norris <[email protected]>drivers/pci/host/pcie-rockchip.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)drivers/pci/host/pcie-rockchip.c +17
-2@@ -37,6 +37,7 @@#include <linux/pci_ids.h> #include <linux/phy/phy.h> #include <linux/platform_device.h> +#include <linux/pm_wakeirq.h> #include <linux/reset.h> #include <linux/regmap.h> @@ -995,6 +996,15 @@ static int rockchip_pcie_setup_irq(struct rockchip_pcie *rockchip)return err; } +/* Must init wakeup before setting dedicated wakeup irq. */ +device_init_wakeup (dev, true); + irq =platform_get_irq_byname (pdev,"wakeup" ); +if (irq >=0 ) { + err =dev_pm_set_dedicated_wake_irq (dev, irq); +if (err) +dev_err (dev,"failed to setup PCIe wakeup IRQ\n" ); + } +return 0 ; }@@ -1542,11 +1552,11 @@ static int rockchip_pcie_probe(struct platform_device *pdev) err =rockchip_pcie_parse_dt (rockchip);if (err) -return err; + goto err_disable_wake; err =rockchip_pcie_enable_clocks (rockchip);if (err) -return err; + goto err_disable_wake; err =rockchip_pcie_set_vpcie (rockchip);if (err) {@@ -1656,6 +1666,9 @@ static int rockchip_pcie_probe(struct platform_device *pdev)regulator_disable (rockchip->vpcie0v9); err_set_vpcie:rockchip_pcie_disable_clocks (rockchip); +err_disable_wake: +dev_pm_clear_wake_irq (dev); +device_init_wakeup (dev, false);return err; }@@ -1682,6 +1695,8 @@ static int rockchip_pcie_remove(struct platform_device *pdev)if (!IS_ERR (rockchip->vpcie0v9))regulator_disable (rockchip->vpcie0v9); +dev_pm_clear_wake_irq (dev); +device_init_wakeup (dev, false);return 0 ; }
Re: [PATCH v5 1/3] PCI: rockchip: Add support for pcie wake irq
In reply to Jeffy ChenHi,
Quoted 31 lines · Jeffy Chen
Add support for
PCIE_WAKEpin in rockchip pcie driver.Signed-off-by Jeffy Chen <[email protected]>---
Changes in v5:
RebaseChanges in v3:
Fix error handlingChanges in v2:
Usedev_pm_set_dedicated_wake_irq
-- Suggested by Brian Norris <[email protected]>drivers/pci/host/pcie-rockchip.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)drivers/pci/host/pcie-rockchip.c +1
-0@@ -37,6 +37,7 @@#include <linux/pci_ids.h> #include <linux/phy/phy.h> #include <linux/platform_device.h> +#include <linux/pm_wakeirq.h> #include <linux/reset.h> #include <linux/regmap.h>
drivers/pci/host/pcie-rockchip.c static int rockchip_pcie_setup_irq(struct rockchip_pcie *rockchip) · line 1000
Quoted 5 lines
drivers/pci/host/pcie-rockchip.c +2
-0@@ -995,6 +996,15 @@ static int rockchip_pcie_setup_irq(struct rockchip_pcie *rockchip)return err; } +/* Must init wakeup before setting dedicated wakeup irq. */ +device_init_wakeup (dev, true);
Am I crazy, or should this go inside the 'irq >= 0' conditional? Otherwise, for the whole series:
Bjorn, were you planning to pick this up?
Also, the DT binding change conflicts (just simple context) with the PERST# series I just sent out. Would be good if we could land one or both :)
Thanks,
Brian
Quoted 47 lines
drivers/pci/host/pcie-rockchip.c +14
-2+ irq =platform_get_irq_byname (pdev,"wakeup" ); +if (irq >=0 ) { + err =dev_pm_set_dedicated_wake_irq (dev, irq); +if (err) +dev_err (dev,"failed to setup PCIe wakeup IRQ\n" ); + } +return 0 ; }@@ -1542,11 +1552,11 @@ static int rockchip_pcie_probe(struct platform_device *pdev) err =rockchip_pcie_parse_dt (rockchip);if (err) -return err; + goto err_disable_wake; err =rockchip_pcie_enable_clocks (rockchip);if (err) -return err; + goto err_disable_wake; err =rockchip_pcie_set_vpcie (rockchip);if (err) {@@ -1656,6 +1666,9 @@ static int rockchip_pcie_probe(struct platform_device *pdev)regulator_disable (rockchip->vpcie0v9); err_set_vpcie:rockchip_pcie_disable_clocks (rockchip); +err_disable_wake: +dev_pm_clear_wake_irq (dev); +device_init_wakeup (dev, false);return err; }@@ -1682,6 +1695,8 @@ static int rockchip_pcie_remove(struct platform_device *pdev)if (!IS_ERR (rockchip->vpcie0v9))regulator_disable (rockchip->vpcie0v9); +dev_pm_clear_wake_irq (dev); +device_init_wakeup (dev, false);return 0 ; }Signature · 1 line
2.11.0
Re: [PATCH v5 1/3] PCI: rockchip: Add support for pcie wake irq
Quoted 43 lines · Brian Norris
Hi,
Quoted 31 lines · Jeffy Chen
Add support for
PCIE_WAKEpin in rockchip pcie driver.Signed-off-by Jeffy Chen <[email protected]>---
Changes in v5:
RebaseChanges in v3:
Fix error handlingChanges in v2:
Usedev_pm_set_dedicated_wake_irq
-- Suggested by Brian Norris <[email protected]>drivers/pci/host/pcie-rockchip.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)drivers/pci/host/pcie-rockchip.c +1
-0@@ -37,6 +37,7 @@#include <linux/pci_ids.h> #include <linux/phy/phy.h> #include <linux/platform_device.h> +#include <linux/pm_wakeirq.h> #include <linux/reset.h> #include <linux/regmap.h> drivers/pci/host/pcie-rockchip.c static int rockchip_pcie_setup_irq(struct rockchip_pcie *rockchip) · line 1000
Quoted 5 lines
drivers/pci/host/pcie-rockchip.c +2
-0@@ -995,6 +996,15 @@ static int rockchip_pcie_setup_irq(struct rockchip_pcie *rockchip)return err; } +/* Must init wakeup before setting dedicated wakeup irq. */ +device_init_wakeup (dev, true);Am I crazy, or should this go inside the 'irq >= 0' conditional? Otherwise, for the whole series:
Quoted 4 lines
Reviewed-by Brian Norris <[email protected]>Tested-by Brian Norris <[email protected]>Bjorn, were you planning to pick this up?
I had already applied this to pci/host-rockchip, but I must have gotten interrupted before sending the email.
But now that you mention it, I looked at this again and have some questions. I'll respond to the original patch.
Quoted 59 lines
Also, the DT binding change conflicts (just simple context) with the PERST# series I just sent out. Would be good if we could land one or both :)
Thanks,
BrianQuoted 47 lines
drivers/pci/host/pcie-rockchip.c +14
-2+ irq =platform_get_irq_byname (pdev,"wakeup" ); +if (irq >=0 ) { + err =dev_pm_set_dedicated_wake_irq (dev, irq); +if (err) +dev_err (dev,"failed to setup PCIe wakeup IRQ\n" ); + } +return 0 ; }@@ -1542,11 +1552,11 @@ static int rockchip_pcie_probe(struct platform_device *pdev) err =rockchip_pcie_parse_dt (rockchip);if (err) -return err; + goto err_disable_wake; err =rockchip_pcie_enable_clocks (rockchip);if (err) -return err; + goto err_disable_wake; err =rockchip_pcie_set_vpcie (rockchip);if (err) {@@ -1656,6 +1666,9 @@ static int rockchip_pcie_probe(struct platform_device *pdev)regulator_disable (rockchip->vpcie0v9); err_set_vpcie:rockchip_pcie_disable_clocks (rockchip); +err_disable_wake: +dev_pm_clear_wake_irq (dev); +device_init_wakeup (dev, false);return err; }@@ -1682,6 +1695,8 @@ static int rockchip_pcie_remove(struct platform_device *pdev)if (!IS_ERR (rockchip->vpcie0v9))regulator_disable (rockchip->vpcie0v9); +dev_pm_clear_wake_irq (dev); +device_init_wakeup (dev, false);return 0 ; }Signature · 1 line
2.11.0_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v5 1/3] PCI: rockchip: Add support for pcie wake irq
Quoted 5 lines · Bjorn Helgaas
Quoted 1 line · Brian Norris
Bjorn, were you planning to pick this up?
I had already applied this to pci/host-rockchip, but I must have gotten interrupted before sending the email.
You also hadn't merged it into your /next branch either, which is where I was looking (and basing my other patch set).
Quoted 2 lines
But now that you mention it, I looked at this again and have some questions. I'll respond to the original patch.
Brian
Re: [PATCH v5 1/3] PCI: rockchip: Add support for pcie wake irq
In reply to Jeffy Chen[+cc Rafael, linux-pm]
Quoted 31 lines · Jeffy Chen
Add support for
PCIE_WAKEpin in rockchip pcie driver.Signed-off-by Jeffy Chen <[email protected]>---
Changes in v5:
RebaseChanges in v3:
Fix error handlingChanges in v2:
Usedev_pm_set_dedicated_wake_irq
-- Suggested by Brian Norris <[email protected]>drivers/pci/host/pcie-rockchip.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)drivers/pci/host/pcie-rockchip.c +1
-0@@ -37,6 +37,7 @@#include <linux/pci_ids.h> #include <linux/phy/phy.h> #include <linux/platform_device.h> +#include <linux/pm_wakeirq.h> #include <linux/reset.h> #include <linux/regmap.h>
drivers/pci/host/pcie-rockchip.c static int rockchip_pcie_setup_irq(struct rockchip_pcie *rockchip) · line 1003
Quoted 8 lines
drivers/pci/host/pcie-rockchip.c +5
-0@@ -995,6 +996,15 @@ static int rockchip_pcie_setup_irq(struct rockchip_pcie *rockchip)return err; } +/* Must init wakeup before setting dedicated wakeup irq. */ +device_init_wakeup (dev, true); + irq =platform_get_irq_byname (pdev,"wakeup" ); +if (irq >=0 ) { + err =dev_pm_set_dedicated_wake_irq (dev, irq);
I'm a little skeptical about dev_pm_set_dedicated_wake_irq(), not because I know anything at all about it, but because there are only five callers in the whole tree, three of which are in UART code, and none in anything resembling PCI code.
Is Rockchip really that special, or are we going about this the wrong way?
drivers/pci/host/pcie-rockchip.c static int rockchip_pcie_setup_irq(struct rockchip_pcie *rockchip) · line 1008
Quoted 5 lines
drivers/pci/host/pcie-rockchip.c +4
-0+if (err) +dev_err (dev,"failed to setup PCIe wakeup IRQ\n" ); + } +return 0 ;
The above could be structured as:
irq = platform_get_irq_byname(pdev, "wakeup");
if (irq < 0)
return 0;
device_init_wakeup(dev, true);
err = dev_pm_set_dedicated_wake_irq(dev, irq);
if (err) {
dev_pm_clear_wake_irq(dev);
device_init_wakeup(dev, false);
}return 0;
to unindent the mainline non-error code.
Quoted 17 lines
drivers/pci/host/pcie-rockchip.c +2
-2}@@ -1542,11 +1552,11 @@ static int rockchip_pcie_probe(struct platform_device *pdev) err =rockchip_pcie_parse_dt (rockchip);if (err) -return err; + goto err_disable_wake; err =rockchip_pcie_enable_clocks (rockchip);if (err) -return err; + goto err_disable_wake; err =rockchip_pcie_set_vpcie (rockchip);if (err) {
drivers/pci/host/pcie-rockchip.c static int rockchip_pcie_probe(struct platform_device *pdev) · line 1671
Quoted 6 lines
drivers/pci/host/pcie-rockchip.c +3
-0@@ -1656,6 +1666,9 @@ static int rockchip_pcie_probe(struct platform_device *pdev)regulator_disable (rockchip->vpcie0v9); err_set_vpcie:rockchip_pcie_disable_clocks (rockchip); +err_disable_wake: +dev_pm_clear_wake_irq (dev); +device_init_wakeup (dev, false);
I think this error cleanup should be done in rockchip_pcie_setup_irq() as shown above. There's no real connection between rockchip_pcie_probe() and the wake setup.
Quoted 21 lines
drivers/pci/host/pcie-rockchip.c +2
-0return err; }@@ -1682,6 +1695,8 @@ static int rockchip_pcie_remove(struct platform_device *pdev)if (!IS_ERR (rockchip->vpcie0v9))regulator_disable (rockchip->vpcie0v9); +dev_pm_clear_wake_irq (dev); +device_init_wakeup (dev, false);return 0 ; }Signature · 8 lines
2.11.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel at lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v5 1/3] PCI: rockchip: Add support for pcie wake irq
[+cc Tony]
Quoted 115 lines · CEST Bjorn Helgaas
[+cc Rafael, linux-pm]
Quoted 31 lines · Jeffy Chen
Add support for
PCIE_WAKEpin in rockchip pcie driver.Signed-off-by Jeffy Chen <[email protected]>---
Changes in v5:
RebaseChanges in v3:
Fix error handlingChanges in v2:
Usedev_pm_set_dedicated_wake_irq
-- Suggested by Brian Norris <[email protected]>drivers/pci/host/pcie-rockchip.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)drivers/pci/host/pcie-rockchip.c +1
-0@@ -37,6 +37,7 @@#include <linux/pci_ids.h> #include <linux/phy/phy.h> #include <linux/platform_device.h> +#include <linux/pm_wakeirq.h> #include <linux/reset.h> #include <linux/regmap.h> drivers/pci/host/pcie-rockchip.c static int rockchip_pcie_setup_irq(struct rockchip_pcie *rockchip) · line 1003
Quoted 8 lines
drivers/pci/host/pcie-rockchip.c +5
-0@@ -995,6 +996,15 @@ static int rockchip_pcie_setup_irq(struct rockchip_pcie *rockchip)return err; } +/* Must init wakeup before setting dedicated wakeup irq. */ +device_init_wakeup (dev, true); + irq =platform_get_irq_byname (pdev,"wakeup" ); +if (irq >=0 ) { + err =dev_pm_set_dedicated_wake_irq (dev, irq);I'm a little skeptical about
dev_pm_set_dedicated_wake_irq(), not because I know anything at all about it, but because there are only five callers in the whole tree, three of which are in UART code, and none in anything resembling PCI code.Is Rockchip really that special, or are we going about this the wrong way?
drivers/pci/host/pcie-rockchip.c static int rockchip_pcie_setup_irq(struct rockchip_pcie *rockchip) · line 1008
Quoted 5 lines
drivers/pci/host/pcie-rockchip.c +4
-0+if (err) +dev_err (dev,"failed to setup PCIe wakeup IRQ\n" ); + } +return 0 ;The above could be structured as:
irq = platform_get_irq_byname(pdev, "wakeup"); if (irq < 0) return 0; device_init_wakeup(dev, true); err = dev_pm_set_dedicated_wake_irq(dev, irq); if (err) { dev_pm_clear_wake_irq(dev); device_init_wakeup(dev, false); }return 0;
to unindent the mainline non-error code.
Quoted 17 lines
drivers/pci/host/pcie-rockchip.c +2
-2}@@ -1542,11 +1552,11 @@ static int rockchip_pcie_probe(struct platform_device *pdev) err =rockchip_pcie_parse_dt (rockchip);if (err) -return err; + goto err_disable_wake; err =rockchip_pcie_enable_clocks (rockchip);if (err) -return err; + goto err_disable_wake; err =rockchip_pcie_set_vpcie (rockchip);if (err) {drivers/pci/host/pcie-rockchip.c static int rockchip_pcie_probe(struct platform_device *pdev) · line 1671
Quoted 6 lines
drivers/pci/host/pcie-rockchip.c +3
-0@@ -1656,6 +1666,9 @@ static int rockchip_pcie_probe(struct platform_device *pdev)regulator_disable (rockchip->vpcie0v9); err_set_vpcie:rockchip_pcie_disable_clocks (rockchip); +err_disable_wake: +dev_pm_clear_wake_irq (dev); +device_init_wakeup (dev, false);I think this error cleanup should be done in
rockchip_pcie_setup_irq()as shown above. There's no real connection betweenrockchip_pcie_probe()and the wake setup.Quoted 12 lines
drivers/pci/host/pcie-rockchip.c +2
-0return err; }@@ -1682,6 +1695,8 @@ static int rockchip_pcie_remove(struct platform_device *pdev)if (!IS_ERR (rockchip->vpcie0v9))regulator_disable (rockchip->vpcie0v9); +dev_pm_clear_wake_irq (dev); +device_init_wakeup (dev, false);return 0 ; }
Re: [PATCH v5 1/3] PCI: rockchip: Add support for pcie wake irq
Quoted 6 lines · Rafael J. Wysocki
[+cc Tony]
Quoted 3 lines · CEST Bjorn Helgaas
[+cc Rafael, linux-pm]
Quoted 1 line · Jeffy Chen
Add support for
PCIE_WAKEpin in rockchip pcie driver.
...
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/pci/host/pcie-rockchip.c +0
-0@@ -995,6 +996,15 @@ static int rockchip_pcie_setup_irq(struct rockchip_pcie *rockchip)return err; }
Quoted 10 lines
Quoted 10 lines
drivers/pci/host/pcie-rockchip.c static int rockchip_pcie_setup_irq(struct rockchip_pcie *rockchip) · line 1003
Quoted 5 lines
drivers/pci/host/pcie-rockchip.c +5
-0+/* Must init wakeup before setting dedicated wakeup irq. */ +device_init_wakeup (dev, true); + irq =platform_get_irq_byname (pdev,"wakeup" ); +if (irq >=0 ) { + err =dev_pm_set_dedicated_wake_irq (dev, irq);I'm a little skeptical about
dev_pm_set_dedicated_wake_irq(), not because I know anything at all about it, but because there are only five callers in the whole tree, three of which are in UART code, and none in anything resembling PCI code.
Well it should work for any device that can provide an out of band wakeup interrupt such as a dedicated GPIO line.
Quoted 2 lines
Quoted 2 lines
Is Rockchip really that special, or are we going about this the wrong way?
Maybe this can be set up in a generic way somewhere similar to what the I2C bus is doing?
See i2c_device_probe() for dev_pm_set_dedicated_wake_irq() in drivers/i2c/i2c-core-base.c.
Regards,
Tony
Re: [PATCH v5 1/3] PCI: rockchip: Add support for pcie wake irq
In reply to Rafael J. WysockiHi Rafael,
Quoted 8 lines · Rafael J. Wysocki
Quoted 8 lines
I'm a little skeptical about
dev_pm_set_dedicated_wake_irq(), not because I know anything at all about it, but because there are only five callers in the whole tree, three of which are in UART code, and none in anything resembling PCI code.Is Rockchip really that special, or are we going about this the wrong way?
we used to put these codes in the wifi driver, but another wifi vendor suggests these should go into the pcie driver.
and as tony said, it could go into pcie common code :)
Quoted 13 lines
Quoted 13 lines
Quoted 6 lines
drivers/pci/host/pcie-rockchip.c static int rockchip_pcie_setup_irq(struct rockchip_pcie *rockchip) · line 1008
Quoted 6 lines
drivers/pci/host/pcie-rockchip.c +4
-0+if (err) +dev_err (dev,"failed to setup PCIe wakeup IRQ\n" ); + } +return 0 ;The above could be structured as:
irq = platform_get_irq_byname(pdev, "wakeup"); if (irq < 0) return 0;
Quoted 7 lines
Quoted 7 lines
device_init_wakeup(dev, true); err = dev_pm_set_dedicated_wake_irq(dev, irq); if (err) { dev_pm_clear_wake_irq(dev); device_init_wakeup(dev, false); }
there's no need to call dev_pm_clear_wake_irq when dev_pm_set_dedicated_wake_irq failed...and i agree the device_init_wakeup part, i'll add that in the next version(with brian's comment too)
Quoted 18 lines
Quoted 18 lines
return 0;
to unindent the mainline non-error code.
Quoted 14 lines
Quoted 14 lines
}
drivers/pci/host/pcie-rockchip.c +2
-2@@ -1542,11 +1552,11 @@ static int rockchip_pcie_probe(struct platform_device *pdev) err =rockchip_pcie_parse_dt (rockchip);if (err) -return err; + goto err_disable_wake; err =rockchip_pcie_enable_clocks (rockchip);if (err) -return err; + goto err_disable_wake;
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/pci/host/pcie-rockchip.c +0
-0err =rockchip_pcie_set_vpcie (rockchip);if (err) {@@ -1656,6 +1666,9 @@ static int rockchip_pcie_probe(struct platform_device *pdev)regulator_disable (rockchip->vpcie0v9); err_set_vpcie:Quoted 8 lines
Quoted 4 lines
drivers/pci/host/pcie-rockchip.c static int rockchip_pcie_probe(struct platform_device *pdev) · line 1671
Quoted 4 lines
drivers/pci/host/pcie-rockchip.c +3
-0rockchip_pcie_disable_clocks (rockchip); +err_disable_wake: +dev_pm_clear_wake_irq (dev); +device_init_wakeup (dev, false);I think this error cleanup should be done in
rockchip_pcie_setup_irq()as shown above. There's no real connection betweenrockchip_pcie_probe()and the wake setup.
this error handling is like inline "rockchip_pcie_cleanup_irq()", and they are harmless to be called even if we don't have the wakeup irq :)
Re: [PATCH v5 1/3] PCI: rockchip: Add support for pcie wake irq
Quoted 9 lines · jeffy
Hi Rafael,
Quoted 6 lines · Rafael J. Wysocki
Quoted 6 lines
I'm a little skeptical about
dev_pm_set_dedicated_wake_irq(), not because I know anything at all about it, but because there are only five callers in the whole tree, three of which are in UART code, and none in anything resembling PCI code.
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
Is Rockchip really that special, or are we going about this the wrong way?
we used to put these codes in the wifi driver, but another wifi vendor suggests these should go into the pcie driver.
and as tony said, it could go into pcie common code :)
I guess the implication (I'm speculating here) is that in most existing cases, the WAKE# signal is fielded by an ACPI BIOS, which knows how it's connected. I suppose that would end up being turned into an SCI that Linux already knows how to handle generically.
And further, that the non-ACPI drivers are relatively new and you're the first attempt to use WAKE# with a non-ACPI PCI host driver?
If this setup could be done somewhere in PCIe common code, that would be great. We have so much copy and pasted code already, it'd be nice to avoid adding more. I don't know if this would fit in pci_scan_root_bus_bridge(), doing something like dma_configure() does to get hold of a struct platform_device * or a struct device * so you could lookup the IRQ?
Quoted 55 lines
Quoted 12 lines
Quoted 12 lines
Quoted 5 lines
drivers/pci/host/pcie-rockchip.c static int rockchip_pcie_setup_irq(struct rockchip_pcie *rockchip) · line 1008
Quoted 5 lines
drivers/pci/host/pcie-rockchip.c +4
-0+if (err) +dev_err (dev,"failed to setup PCIe wakeup IRQ\n" ); + } +return 0 ;The above could be structured as:
irq =
platform_get_irq_byname(pdev, "wakeup");
if (irq < 0)
return 0;Quoted 7 lines
Quoted 7 lines
device_init_wakeup(dev, true);
err =dev_pm_set_dedicated_wake_irq(dev, irq);if (err) { dev_pm_clear_wake_irq(dev); device_init_wakeup(dev, false);}
there's no need to call
dev_pm_clear_wake_irqwhendev_pm_set_dedicated_wake_irqfailed...and i agree thedevice_init_wakeuppart, i'll add that in the next version(with brian's comment too)Quoted 18 lines
Quoted 18 lines
return 0;
to unindent the mainline non-error code.
Quoted 14 lines
Quoted 14 lines
}
drivers/pci/host/pcie-rockchip.c +2
-2@@ -1542,11 +1552,11 @@ static int rockchip_pcie_probe(struct platform_device *pdev) err =rockchip_pcie_parse_dt (rockchip);if (err) -return err; + goto err_disable_wake; err =rockchip_pcie_enable_clocks (rockchip);if (err) -return err; + goto err_disable_wake;Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/pci/host/pcie-rockchip.c +0
-0err =rockchip_pcie_set_vpcie (rockchip);if (err) {@@ -1656,6 +1666,9 @@ static int rockchip_pcie_probe(struct platform_device *pdev)regulator_disable (rockchip->vpcie0v9); err_set_vpcie:Quoted 8 lines
Quoted 4 lines
drivers/pci/host/pcie-rockchip.c static int rockchip_pcie_probe(struct platform_device *pdev) · line 1671
Quoted 4 lines
drivers/pci/host/pcie-rockchip.c +3
-0rockchip_pcie_disable_clocks (rockchip); +err_disable_wake: +dev_pm_clear_wake_irq (dev); +device_init_wakeup (dev, false);I think this error cleanup should be done in
rockchip_pcie_setup_irq()as shown above. There's no real connection betweenrockchip_pcie_probe()and the wake setup.
Quoted 3 lines
this error handling is like inline "
rockchip_pcie_cleanup_irq()", and they are harmless to be called even if we don't have the wakeup irq :)
I'm sure they're harmless. The point is that the cleanup should be done near the failure, not in the caller of the caller of the function where the failure was detected. You have:
rockchip_pcie_probe
rockchip_pcie_parse_dt
rockchip_pcie_setup_irq
err = dev_pm_set_dedicated_wake_irq
if (err)
dev_err(...)
So you detect the error in rockchip_pcie_setup_irq(), but you clean up from it in rockchip_pcie_probe(), which doesn't make sense because rockchip_pcie_probe() doesn't do anything related to wakeup interupts.
Bjorn
Re: [PATCH v5 1/3] PCI: rockchip: Add support for pcie wake irq
Hi Bjorn,
Quoted 11 lines · Bjorn Helgaas
I'm sure they're harmless. The point is that the cleanup should be done near the failure, not in the caller of the caller of the function where the failure was detected. You have:
rockchip_pcie_probe
rockchip_pcie_parse_dt
rockchip_pcie_setup_irq
err =dev_pm_set_dedicated_wake_irq
if (err)
dev_err(...)
Quoted 4 lines
So you detect the error in
rockchip_pcie_setup_irq(), but you clean up from it inrockchip_pcie_probe(), which doesn't make sense becauserockchip_pcie_probe()doesn't do anything related to wakeup interupts.
right, but if something wrong happens in rockchip_pcie_probe() later than rockchip_pcie_setup_irq(), we may still need to clean it up ;)
i think the error handling is a little like what we do in the remove callback
Quoted 4 lines
Bjorn
Re: [PATCH v5 1/3] PCI: rockchip: Add support for pcie wake irq
In reply to Bjorn HelgaasHi,
Quoted 16 lines · Bjorn Helgaas
Quoted 15 lines · jeffy
Hi Rafael,
Quoted 8 lines · Rafael J. Wysocki
Quoted 8 lines
I'm a little skeptical about
dev_pm_set_dedicated_wake_irq(), not because I know anything at all about it, but because there are only five callers in the whole tree, three of which are in UART code, and none in anything resembling PCI code.Is Rockchip really that special, or are we going about this the wrong way?
we used to put these codes in the wifi driver, but another wifi vendor suggests these should go into the pcie driver.
Quoted 6 lines
Quoted 1 line
and as tony said, it could go into pcie common code :)
I guess the implication (I'm speculating here) is that in most existing cases, the WAKE# signal is fielded by an ACPI BIOS, which knows how it's connected. I suppose that would end up being turned into an SCI that Linux already knows how to handle generically.
I wasn't sure how ACPI did this when I first suggested Rockchip take this approach, but since then I believe have figured it out. We have:
pci_prepare_to_sleep() -> pci_enable_wake()
where pci_enable_wake() will configure PME wakeup and/or "platform" wake (which presumably is the WAKE# signal). pci-acpi.c has registered hooks for the latter via pci_set_platform_pm().
This doesn't really make it any more generic for discovering this platform-specific detail. We'd have to set up some kind of platform ops that could be shared for any DT-based platforms.
But that *does* answer the question I had about conditionality: should we always enable WAKE# for platforms that have the pin hooked up to the host? Or is this configured on a per-device basis? IIUC, the intention is that there's only a single open-drain WAKE# pin for the whole system, and it's just pulled high for EPs that don't implement it.
Quoted 2 lines
And further, that the non-ACPI drivers are relatively new and you're the first attempt to use WAKE# with a non-ACPI PCI host driver?
Quite possibly. Or everyone just sidestepped this an configured the pin elsewhere (e.g., you could stick a GPIO like this into a gpio-keys device and it would mostly work).
Quoted 6 lines
If this setup could be done somewhere in PCIe common code, that would be great. We have so much copy and pasted code already, it'd be nice to avoid adding more. I don't know if this would fit in
pci_scan_root_bus_bridge(), doing something likedma_configure()does to get hold of a structplatform_device* or a struct device * so you could lookup the IRQ?
It looks like the infrastructure is in pci_set_platform_pm(), sort of. But that still doesn't help you for the repetition; you're just lucky you only have 2 controller drivers that call this right now :)
Side note: there's some dissonance between this statement, in Documentation/driver-api/pm/devices.rst:
"Device drivers, however, are not expected to call :c:func:device_set_wakeup_enable() directly in any case."
Yet:
$ git grep -l device_set_wakeup_enable drivers/ | wc -l 69
And particularly, I believe that was necessary for Wifi drivers like drivers/net/wireless/ath/ath10k/wow.c.
Brian
PATCH v5 2/3 dt-bindings: PCI: Add definition of pcie wake irq
In reply to Jeffy ChenAdd an optional interrupt for PCIE_WAKE pin.
---
Changes in v5:
Move to pci.txt
Changes in v3: None
Changes in v2: None
Documentation/devicetree/bindings/pci/pci.txt | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/pci/pci.txt +2 -0
@@ -24,3 +24,5 @@ driver implementation may support the following properties: unsupported link speed, for instance, trying to do training for unsupported link speed, etc. Must be '4' for gen4, '3' for gen3, '2' for gen2, and '1' for gen1. Any other values are invalid. +- interrupts: Interrupt specifier for each name in interrupt-names. +- interrupt-names: May contains "wakeup" for PCI WAKE# interrupt.
Signature · 1 line
2.11.0
Re: [PATCH v5 2/3] dt-bindings: PCI: Add definition of pcie wake irq
Quoted 5 lines · Jeffy Chen
Add an optional interrupt for
PCIE_WAKEpin.Signed-off-by Jeffy Chen <[email protected]>---
Quoted 8 lines
Changes in v5:
Move to pci.txtChanges in v3: None
Changes in v2: NoneDocumentation/devicetree/bindings/pci/pci.txt | 2 ++ 1 file changed, 2 insertions(+)
PATCH v5 3/3 arm64: dts: rockchip: Handle pcie wake in pcie driver for Gru
In reply to Jeffy ChenCurrently we are handling pcie wake irq in mrvl wifi driver. Move it to rockchip pcie driver for Gru boards.
---
Changes in v5:
Use "wakeup" instead of "wake"
Changes in v3: None
Changes in v2: None
arch/arm64/boot/dts/rockchip/rk3399-gru.dtsi | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
arch/arm64/boot/dts/rockchip/rk3399-gru.dtsi +9 -6
@@ -707,7 +707,15 @@ ap_i2c_audio: &i2c8 { ep-gpios = <&gpio2 27 GPIO_ACTIVE_HIGH>; pinctrl-names = "default"; - pinctrl-0 = <&pcie_clkreqn_cpm>, <&wifi_perst_l>; + pinctrl-0 = <&pcie_clkreqn_cpm>, <&wlan_host_wake_l>, <&wifi_perst_l>; + + interrupts-extended = <&gic GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH 0>, + <&gic GIC_SPI 50 IRQ_TYPE_LEVEL_HIGH 0>, + <&gic GIC_SPI 51 IRQ_TYPE_LEVEL_HIGH 0>, + <&gpio0 8 IRQ_TYPE_LEVEL_LOW>; + interrupt-names = "sys", "legacy", "client", "wakeup"; + /delete-property/ interrupts; + vpcie3v3-supply = <&pp3300_wifi_bt>; vpcie1v8-supply = <&wlan_pd_n>; /* HACK: see &wlan_pd_n */ vpcie0v9-supply = <&pp900_pcie>;
@@ -722,11 +730,6 @@ ap_i2c_audio: &i2c8 { compatible = "pci1b4b,2b42"; reg = <0x83010000 0x0 0x00000000 0x0 0x00100000 0x83010000 0x0 0x00100000 0x0 0x00100000>; - interrupt-parent = <&gpio0>; - interrupts = <8 IRQ_TYPE_LEVEL_LOW>; - pinctrl-names = "default"; - pinctrl-0 = <&wlan_host_wake_l>; - wakeup-source; }; }; };
Signature · 1 line
2.11.0
PATCH v5 3/3 arm64: dts: rockchip: Handle pcie wake in pcie driver for Gru
Quoted 6 lines · Jeffy Chen
Currently we are handling pcie wake irq in mrvl wifi driver. Move it to rockchip pcie driver for Gru boards.
Signed-off-by Jeffy Chen <[email protected]>---
Quoted 43 lines
Changes in v5:
Use "wakeup" instead of "wake"Changes in v3: None
Changes in v2: Nonearch/arm64/boot/dts/rockchip/rk3399-gru.dtsi | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)arch/arm64/boot/dts/rockchip/rk3399-gru.dtsi +9
-6@@ -707,7 +707,15 @@ ap_i2c_audio: &i2c8 { ep-gpios = <&gpio2 27 GPIO_ACTIVE_HIGH>; pinctrl-names = "default"; - pinctrl-0 = <&pcie_clkreqn_cpm>, <&wifi_perst_l>; + pinctrl-0 = <&pcie_clkreqn_cpm>, <&wlan_host_wake_l>, <&wifi_perst_l>; + + interrupts-extended = <&gic GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH 0>, + <&gic GIC_SPI 50 IRQ_TYPE_LEVEL_HIGH 0>, + <&gic GIC_SPI 51 IRQ_TYPE_LEVEL_HIGH 0>, + <&gpio0 8 IRQ_TYPE_LEVEL_LOW>; + interrupt-names = "sys", "legacy", "client", "wakeup"; + /delete-property/ interrupts; + vpcie3v3-supply = <&pp3300_wifi_bt>; vpcie1v8-supply = <&wlan_pd_n>; /* HACK: see &wlan_pd_n */ vpcie0v9-supply = <&pp900_pcie>;@@ -722,11 +730,6 @@ ap_i2c_audio: &i2c8 { compatible = "pci1b4b,2b42"; reg = <0x83010000 0x0 0x00000000 0x0 0x00100000 0x83010000 0x0 0x00100000 0x0 0x00100000>; - interrupt-parent = <&gpio0>; - interrupts = <8 IRQ_TYPE_LEVEL_LOW>; - pinctrl-names = "default"; - pinctrl-0 = <&wlan_host_wake_l>; - wakeup-source; }; }; };