From 10945466f95561c4b8698110c5e84f46fb74e125 Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikegami Date: Mon, 9 Nov 2026 17:56:55 +0900 Subject: [PATCH 1/5] PCI: dwc: gs201-cp: refuse system sleep while the modem's link is up The modem stays powered across s2idle, as on stock: CPIF lets the AP sleep only after CP2AP_WAKEUP has dropped and the idle link has been powered down (it holds a wake lock while the link is up, and its suspend returns -EBUSY while the line is high), and stock's root complex does no link-down at suspend either, only isolating a link that is already down, which link_down does here. This driver had no sleep callbacks. Add noirq ones that refuse while the driver's own state says the link is up or the PHY is out of isolation, should those paths ever race. This is a late abort rather than a guard: the root port and the modem are this device's children, so the PM core has run their suspend_noirq, and the PCI core has handled them, before this callback runs; a refusal makes the PM core resume them and fails the sleep. The refusal is logged; the link-down edges at suspend and resume, with the PMU's isolation register, are debug messages. The isolation register is not used to refuse: a phone whose modem never started never isolated the PHY and must still sleep. Only gs201 sets the new sleep_guard match data, so on the Pixel 9a (zumapro), where sleep with the modem up has not been tried and the PHY stays out of isolation after the first link up, the callbacks do nothing and its behaviour is unchanged. On gs201 the modem link node is disabled in gs201.dtsi and only the Pixel 7 Pro (cheetah) enables it, through its device overlay; that is the board this changes. Seen on a Pixel 7 Pro with the modem up (7.3.0-rc6, before this change): the cp2ap_wakeup IRQ (gpa8-3, level) is wake-enabled by CPIF, and the link's MSIs are not. Assisted-by: LLM Signed-off-by: Hiroyuki Ikegami --- drivers/pci/controller/dwc/pcie-gs201-cp.c | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/drivers/pci/controller/dwc/pcie-gs201-cp.c b/drivers/pci/controller/dwc/pcie-gs201-cp.c index 1d1cacce4f..3c32853be7 100644 --- a/drivers/pci/controller/dwc/pcie-gs201-cp.c +++ b/drivers/pci/controller/dwc/pcie-gs201-cp.c @@ -99,6 +99,7 @@ #include #include #include +#include #include #include #include @@ -245,12 +246,15 @@ static const char * const cp_input_names[CP_NUM_INPUTS] = { * @host_atu: no secure-ATU SMC; the host programs the outbound iATU * @sysreg_optional: without samsung,sysreg the link runs without I/O * coherency + * @sleep_guard: system sleep with the modem up has been tried on this SoC + * (gs201): the noirq sleep callbacks run; elsewhere they do nothing */ struct gs201_pcie_cp_data { bool zuma_ctrl; bool phy_bypass_once; bool host_atu; bool sysreg_optional; + bool sleep_guard; }; struct gs201_pcie_cp { @@ -2298,12 +2302,72 @@ static void gs201_pcie_cp_remove(struct platform_device *pdev) cancel_work_sync(&cp->event_work); } +/* + * System sleep (s2idle) with the modem up, on gs201 only (sleep_guard). + * The modem stays powered; its driver lets the AP sleep only once + * CP2AP_WAKEUP has dropped and the idle link has been powered down (cpif + * holds a wake lock while the link is up, and its suspend refuses while + * the line is high), as on stock, whose root complex does no link-down at + * suspend either and only isolates a link that is already down, as + * link_down does here. Should those paths ever race, this refuses the + * sleep. It is a late abort, not a guard: the root port and the modem are + * children of this device, so the PM core has already run their + * suspend_noirq when this runs, and the PCI core has already handled + * them; the refusal makes the PM core resume them and the sleep fails. The PMU's isolation bit is + * only logged: a phone whose modem never started has never isolated the + * PHY, and must still sleep. + */ +static int gs201_pcie_cp_suspend_noirq(struct device *dev) +{ + struct gs201_pcie_cp *cp = dev_get_drvdata(dev); + unsigned int iso = 0; + int ret = 0; + + if (!cp->data->sleep_guard) + return 0; + if (!mutex_trylock(&cp->lock)) { + dev_info(dev, "sleep refused: a link step is running\n"); + return -EBUSY; + } + if (cp->link_up || cp->dbi_ok) { + dev_info(dev, "sleep refused: link %s, PHY %s\n", + cp->link_up ? "up" : "down", + cp->dbi_ok ? "out of isolation" : "isolated"); + ret = -EBUSY; + } + mutex_unlock(&cp->lock); + if (ret) + return ret; + + if (regmap_read(cp->pmu, cp->pmu_offset, &iso)) + dev_dbg(dev, "sleep: link down\n"); + else + dev_dbg(dev, "sleep: link down, PMU %#x = %#x\n", + cp->pmu_offset, iso); + return 0; +} + +static int gs201_pcie_cp_resume_noirq(struct device *dev) +{ + struct gs201_pcie_cp *cp = dev_get_drvdata(dev); + + if (cp->data->sleep_guard) + dev_dbg(dev, "resume: link down\n"); + return 0; +} + +static const struct dev_pm_ops gs201_pcie_cp_pm_ops = { + NOIRQ_SYSTEM_SLEEP_PM_OPS(gs201_pcie_cp_suspend_noirq, + gs201_pcie_cp_resume_noirq) +}; + static void gs201_pcie_cp_shutdown(struct platform_device *pdev) { gs201_pcie_cp_remove(pdev); } static const struct gs201_pcie_cp_data gs201_pcie_cp_data = { + .sleep_guard = true, }; static const struct gs201_pcie_cp_data zumapro_pcie_cp_data = { @@ -2327,6 +2391,7 @@ static struct platform_driver gs201_pcie_cp_driver = { .driver = { .name = "gs201-pcie-cp", .of_match_table = gs201_pcie_cp_of_match, + .pm = pm_sleep_ptr(&gs201_pcie_cp_pm_ops), .suppress_bind_attrs = true, /* the modem driver uses it */ }, }; From 9a54a2d118a2b34eb8d3de2e60ef0168d9307b43 Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikegami Date: Mon, 9 Nov 2026 20:15:16 +0900 Subject: [PATCH 2/5] PCI: dwc: gs201-cp: keep the PCI core's sleep handling off the modem's root port The modem keeps its link down between transfers, and the root port's configuration space is unreachable while it is down. The first suspend-to-idle with the modem online (link down at the time) went: pcieport 0001:00:00.0: Unable to change power state from D0 to D3hot, device inaccessible pcieport 0001:00:00.0: Unable to change power state from D3cold to D0, device inaccessible pcieport 0001:00:00.0: Data Link Layer Link Active not set in 100 msec The failed D3hot left the port marked D3cold, so resume waited for the link, which only comes back when the modem driver asks for it, and marked the modem disconnected. When the modem driver raised the link 3 s later, every kernel config read of the modem returned 0xffff (a config read from user space still saw its vendor ID), and CPIF could not ring its doorbell again. Mark the root port PCI_DEV_FLAGS_NO_D3. It stays in D0, the PCI core skips its bus PM in suspend-to-idle (skip_bus_pm), and resume leaves the link to the modem driver, as at runtime. Only with sleep_guard (gs201), as the sleep callbacks: the Pixel 9a's root port is handled as before. Assisted-by: LLM Signed-off-by: Hiroyuki Ikegami --- drivers/pci/controller/dwc/pcie-gs201-cp.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-gs201-cp.c b/drivers/pci/controller/dwc/pcie-gs201-cp.c index 3c32853be7..de79237874 100644 --- a/drivers/pci/controller/dwc/pcie-gs201-cp.c +++ b/drivers/pci/controller/dwc/pcie-gs201-cp.c @@ -247,7 +247,8 @@ static const char * const cp_input_names[CP_NUM_INPUTS] = { * @sysreg_optional: without samsung,sysreg the link runs without I/O * coherency * @sleep_guard: system sleep with the modem up has been tried on this SoC - * (gs201): the noirq sleep callbacks run; elsewhere they do nothing + * (gs201): the noirq sleep callbacks run, and the root port is kept out + * of the PCI core's D3 handling; elsewhere neither happens */ struct gs201_pcie_cp_data { bool zuma_ctrl; @@ -808,6 +809,7 @@ static void cp_root_win_restore(struct gs201_pcie_cp *cp) static int cp_bus(struct gs201_pcie_cp *cp) { + struct pci_dev *rp; int ret; if (!cp->link_up || !cp->atu_done) @@ -826,6 +828,18 @@ static int cp_bus(struct gs201_pcie_cp *cp) ret = pci_host_probe(cp->bridge); if (ret) return ret; + /* + * The link is down between transfers, and with it the root port's + * configuration space. Its power state is the modem driver's call: + * left to the PCI core, a system sleep with the link down marked the + * root port D3cold, and resume then took the modem as disconnected, + * since the link only comes back when the modem driver asks for it. + * Only where system sleep with the modem up has been tried + * (sleep_guard, gs201). + */ + if (cp->data->sleep_guard) + list_for_each_entry(rp, &cp->bridge->bus->devices, bus_list) + rp->dev_flags |= PCI_DEV_FLAGS_NO_D3; pci_walk_bus(cp->bridge->bus, cp_bus_report, cp); cp_root_win_save(cp); @@ -2313,7 +2327,8 @@ static void gs201_pcie_cp_remove(struct platform_device *pdev) * sleep. It is a late abort, not a guard: the root port and the modem are * children of this device, so the PM core has already run their * suspend_noirq when this runs, and the PCI core has already handled - * them; the refusal makes the PM core resume them and the sleep fails. The PMU's isolation bit is + * them (harmlessly, with PCI_DEV_FLAGS_NO_D3 on the port, see cp_bus()); + * the refusal makes the PM core resume them and the sleep fails. The PMU's isolation bit is * only logged: a phone whose modem never started has never isolated the * PHY, and must still sleep. */ From b857fd28dd3602f8bb041337baaf6710f9fc5bd3 Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikegami Date: Mon, 9 Nov 2026 20:34:57 +0900 Subject: [PATCH 3/5] PCI: dwc: gs201-cp: don't let resume wait for the modem's link PCI_DEV_FLAGS_NO_D3 kept the root port out of D3hot, but it can still be marked D3cold. The read that does it is pci_power_up()'s read of the port's PM control register: with the link down, cp_root_map_bus() maps nothing, the read returns all ones, and pci_power_up() marks the port D3cold: pcieport 0001:00:00.0: Unable to change power state from D3cold to D0, device inaccessible The suspend-to-idle after that one started from D3cold, so resume again waited for the link, which only the modem driver raises, and marked the modem disconnected: pcieport 0001:00:00.0: Data Link Layer Link Active not set in 100 msec cpif: s51xx_pcie_restore_state: Can't set D0 state!!!! cpif: s51xx_pcie_send_doorbell_int: BME is not set(cnt=10) Give the devices below the port a zero d3cold_delay, so pci_bridge_wait_for_secondary_bus() returns at once and the link stays the modem driver's business, as at runtime. This makes the stale D3cold mark harmless rather than avoiding it, since the modem's power belongs to CPIF. Skipping the wait is safe because the modem is never powered down across s2idle, and the modem driver waits for its own link up and restores the endpoint's state before it touches the modem. The wait could only time out and mark a working modem disconnected, so the zero d3cold_delay must stay. Only with sleep_guard (gs201): the Pixel 9a's devices keep their d3cold_delay. With this and the two changes before it, on a Pixel 7 Pro with the modem registered on LTE: eight suspend-to-idle cycles in one boot, all resumed, woken by the RTC alarm or the modem's cp2ap_wakeup (an incoming SMS among them, received in the second it woke), mobile data working after each, no UFS error. Assisted-by: LLM Signed-off-by: Hiroyuki Ikegami --- drivers/pci/controller/dwc/pcie-gs201-cp.c | 27 ++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-gs201-cp.c b/drivers/pci/controller/dwc/pcie-gs201-cp.c index de79237874..a730f543c3 100644 --- a/drivers/pci/controller/dwc/pcie-gs201-cp.c +++ b/drivers/pci/controller/dwc/pcie-gs201-cp.c @@ -762,6 +762,12 @@ static int cp_msi_setup(struct gs201_pcie_cp *cp) return 0; } +static int cp_no_d3cold_wait(struct pci_dev *pdev, void *data) +{ + pdev->d3cold_delay = 0; + return 0; +} + static int cp_bus_report(struct pci_dev *pdev, void *data) { struct gs201_pcie_cp *cp = data; @@ -834,12 +840,25 @@ static int cp_bus(struct gs201_pcie_cp *cp) * left to the PCI core, a system sleep with the link down marked the * root port D3cold, and resume then took the modem as disconnected, * since the link only comes back when the modem driver asks for it. - * Only where system sleep with the modem up has been tried - * (sleep_guard, gs201). + * PCI_DEV_FLAGS_NO_D3 keeps it in D0, but a read of its PM control + * register with the link down (pci_power_up() at resume, through + * cp_root_map_bus(), which maps nothing then, so the read is all + * ones) still marks it D3cold, and the next resume would wait up to + * d3cold_delay for a link only the modem driver raises, then mark the + * modem disconnected. The modem keeps its power across s2idle, and + * its driver waits for its own link up and restores the endpoint + * before any access, so that wait has nothing to wait for: keep + * d3cold_delay zero below the port. Both only where system sleep with + * the modem up has been tried (sleep_guard, gs201). */ - if (cp->data->sleep_guard) - list_for_each_entry(rp, &cp->bridge->bus->devices, bus_list) + if (cp->data->sleep_guard) { + list_for_each_entry(rp, &cp->bridge->bus->devices, bus_list) { rp->dev_flags |= PCI_DEV_FLAGS_NO_D3; + if (rp->subordinate) + pci_walk_bus(rp->subordinate, + cp_no_d3cold_wait, NULL); + } + } pci_walk_bus(cp->bridge->bus, cp_bus_report, cp); cp_root_win_save(cp); From f4e5e4846c39b8adb7fbd7e4955c79916fcd9682 Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikegami Date: Thu, 12 Nov 2026 12:36:43 +0900 Subject: [PATCH 4/5] PCI: dwc: gs201-cp: leave the modem itself out of system sleep On a Pixel 7 Pro a suspend-to-idle was refused twice in a row: by the sleep callback (the link came up 8 ms in), then by the modem driver with the link down. That resume logged s51xx 0001:01:00.0: Unable to change power state from D3hot to D0, device inaccessible and the modem stopped answering until a reboot. Its driver has no PM ops, so the PCI core disabled, saved, powered up, restored and re-enabled it behind the driver's back, while the driver manages the modem's power and PCI state itself. Make the devices below the root port syscore devices, so the PM core skips them. PCI_DEV_FLAGS_NO_D3 would also refuse the driver's own runtime D3hot. With this: 60 refused attempts with data after each, and 8 quiet cycles woken by cp2ap_wakeup. Only with sleep_guard (gs201). Assisted-by: LLM Signed-off-by: Hiroyuki Ikegami --- drivers/pci/controller/dwc/pcie-gs201-cp.c | 27 ++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-gs201-cp.c b/drivers/pci/controller/dwc/pcie-gs201-cp.c index a730f543c3..8c5597da9d 100644 --- a/drivers/pci/controller/dwc/pcie-gs201-cp.c +++ b/drivers/pci/controller/dwc/pcie-gs201-cp.c @@ -762,9 +762,10 @@ static int cp_msi_setup(struct gs201_pcie_cp *cp) return 0; } -static int cp_no_d3cold_wait(struct pci_dev *pdev, void *data) +static int cp_ep_sleep_setup(struct pci_dev *pdev, void *data) { pdev->d3cold_delay = 0; + dev_pm_syscore_device(&pdev->dev, true); return 0; } @@ -848,15 +849,21 @@ static int cp_bus(struct gs201_pcie_cp *cp) * modem disconnected. The modem keeps its power across s2idle, and * its driver waits for its own link up and restores the endpoint * before any access, so that wait has nothing to wait for: keep - * d3cold_delay zero below the port. Both only where system sleep with - * the modem up has been tried (sleep_guard, gs201). + * d3cold_delay zero below the port. The modem itself is left out of + * system sleep altogether (a syscore device for the PM core): its + * driver keeps the modem's power and PCI state, and the PCI core's + * own suspend and resume of it (disable and save, then the power-up + * read, restore and re-enable) ran behind that driver's back when a + * sleep was aborted, after which the driver could not reach the modem. + * All of this only where system sleep with the modem up has been + * tried (sleep_guard, gs201). */ if (cp->data->sleep_guard) { list_for_each_entry(rp, &cp->bridge->bus->devices, bus_list) { rp->dev_flags |= PCI_DEV_FLAGS_NO_D3; if (rp->subordinate) pci_walk_bus(rp->subordinate, - cp_no_d3cold_wait, NULL); + cp_ep_sleep_setup, NULL); } } pci_walk_bus(cp->bridge->bus, cp_bus_report, cp); @@ -2345,11 +2352,13 @@ static void gs201_pcie_cp_remove(struct platform_device *pdev) * link_down does here. Should those paths ever race, this refuses the * sleep. It is a late abort, not a guard: the root port and the modem are * children of this device, so the PM core has already run their - * suspend_noirq when this runs, and the PCI core has already handled - * them (harmlessly, with PCI_DEV_FLAGS_NO_D3 on the port, see cp_bus()); - * the refusal makes the PM core resume them and the sleep fails. The PMU's isolation bit is - * only logged: a phone whose modem never started has never isolated the - * PHY, and must still sleep. + * suspend_noirq when this runs. The PCI core has handled the root port + * by then (harmlessly, with PCI_DEV_FLAGS_NO_D3 on it) and leaves the + * modem alone (a syscore device, see cp_bus()); the refusal makes the PM + * core resume them and the sleep fails, with the modem driver's state of + * the modem untouched. The PMU's isolation bit is only logged: a phone + * whose modem never started has never isolated the PHY, and must still + * sleep. */ static int gs201_pcie_cp_suspend_noirq(struct device *dev) { From fef165e7496fe907be2180e7579da0aa2c2cca67 Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikegami Date: Sat, 14 Nov 2026 19:55:19 +0900 Subject: [PATCH 5/5] PCI: dwc: gs201-cp: refuse system sleep before the freeze while the link is up With the modem online, systemd's sleeps were refused only in this driver's noirq callback: after every task was frozen and every device suspended, which the PM core then resumed again. On the maintainer's Pixel 7 Pro (2026-11-13) six such refusals in a row were followed by a downlink that received nothing until a reboot, and each real sleep logged "pcieport ... Unable to change power state from D3cold to D0": the root port had been marked D3cold by a sleep with the link down, so the next sleep, a refused one included, ran the PCI core's whole resume of it on a live link. Refuse earlier, from a PM_SUSPEND_PREPARE notifier, while the link is up or the PHY is out of isolation: a refusal then costs one notifier call, before the freeze. Stock gets the same from CPIF's wake lock under Android's autosleep, which systemd doesn't use. The noirq check stays, for a link that comes up during the freeze. Leave the root port out of system sleep too (dev_pm_syscore_device()), as the previous commit does for the modem. Its windows are this driver's and are restored at every link up (cp_root_win_restore()); PCI_DEV_FLAGS_NO_D3 stays for runtime PM. Tested on a second Pixel 7 Pro (2026-11-14, on top of omamobile at 2db2bc35beec): three real sleeps (9.7 s, 43.7 s to the RTC, 4.2 s), then five requests under a 1 s ping, all ten attempts refused before the freeze, ping 138 of 141 and 3 of 3 afterwards, no pcieport line. On a Pixel 9a with sleep_guard set for zumapro (W4HO): 14 refusals with data alive, then 22 of 23 sleeps entered. The notifier and the root port change are Derek Ross's, from his review of this series. Suggested-by: Derek Ross Assisted-by: LLM Signed-off-by: Hiroyuki Ikegami --- drivers/pci/controller/dwc/pcie-gs201-cp.c | 68 +++++++++++++++++++--- 1 file changed, 60 insertions(+), 8 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-gs201-cp.c b/drivers/pci/controller/dwc/pcie-gs201-cp.c index 8c5597da9d..7ed4650b2c 100644 --- a/drivers/pci/controller/dwc/pcie-gs201-cp.c +++ b/drivers/pci/controller/dwc/pcie-gs201-cp.c @@ -100,6 +100,7 @@ #include #include #include +#include #include #include #include @@ -281,6 +282,7 @@ struct gs201_pcie_cp { struct pci_host_bridge *bridge; struct resource msi_page; /* memory-region: the modem's MSI page */ struct dentry *debugfs; + struct notifier_block pm_nb; /* sleep_guard: the early refusal */ struct mutex lock; /* serializes the steps */ raw_spinlock_t cfg_lock; /* config accesses against link changes */ bool cfg_root_ok; /* root port (DBI) accessible */ @@ -855,12 +857,20 @@ static int cp_bus(struct gs201_pcie_cp *cp) * own suspend and resume of it (disable and save, then the power-up * read, restore and re-enable) ran behind that driver's back when a * sleep was aborted, after which the driver could not reach the modem. + * The root port is left out of system sleep the same way: once a + * sleep with the link down had marked it D3cold, the next sleep, a + * refused one included, ran the PCI core's whole resume of it on a + * live link (power-up, config restore, PME restore, then a resume of + * the bus below), and with the link down its suspend only saved and + * read back all ones. Its windows are this driver's, restored at + * every link up (cp_root_win_restore()). * All of this only where system sleep with the modem up has been * tried (sleep_guard, gs201). */ if (cp->data->sleep_guard) { list_for_each_entry(rp, &cp->bridge->bus->devices, bus_list) { rp->dev_flags |= PCI_DEV_FLAGS_NO_D3; + dev_pm_syscore_device(&rp->dev, true); if (rp->subordinate) pci_walk_bus(rp->subordinate, cp_ep_sleep_setup, NULL); @@ -2175,6 +2185,39 @@ static int cp_get_sysreg(struct gs201_pcie_cp *cp) return 0; } +/* + * The same check before anything is frozen or suspended (sleep_guard): a + * sleep refused here costs one notifier call, where the noirq refusal + * (gs201_pcie_cp_suspend_noirq()) comes after every task was frozen and + * every device suspended, and resumes them all again. Stock gets the + * early refusal from CPIF's wake lock, held while the link is up; that + * lock holds a sleep off only for a caller that wrote + * /sys/power/wakeup_count (Android's autosleep), which systemd doesn't. + * The noirq check stays for a link that comes up while the system is + * being frozen. + */ +static int gs201_pcie_cp_pm_notify(struct notifier_block *nb, + unsigned long event, void *unused) +{ + struct gs201_pcie_cp *cp = container_of(nb, struct gs201_pcie_cp, + pm_nb); + int ret = 0; + + if (event != PM_SUSPEND_PREPARE) + return NOTIFY_DONE; + + mutex_lock(&cp->lock); + if (cp->link_up || cp->dbi_ok) { + dev_info(cp->dev, "sleep refused before the freeze: link %s, PHY %s\n", + cp->link_up ? "up" : "down", + cp->dbi_ok ? "out of isolation" : "isolated"); + ret = -EBUSY; + } + mutex_unlock(&cp->lock); + + return notifier_from_errno(ret); +} + static int gs201_pcie_cp_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -2307,6 +2350,15 @@ static int gs201_pcie_cp_probe(struct platform_device *pdev) gs201_cp = cp; mutex_unlock(&gs201_cp_lock); + if (IS_ENABLED(CONFIG_PM_SLEEP) && cp->data->sleep_guard) { + cp->pm_nb.notifier_call = gs201_pcie_cp_pm_notify; + ret = register_pm_notifier(&cp->pm_nb); + if (ret) { + cp->pm_nb.notifier_call = NULL; + dev_warn(dev, "no early sleep refusal: %d\n", ret); + } + } + dev_info(dev, "modem PCIe ch0 bring-up: %u lanes, steps %s, modem lines %s\n", cp->num_lanes, allow_hw ? "enabled" : "disabled (allow_hw=0)", cp->has_lines ? "here" : "left to the modem driver"); @@ -2318,6 +2370,8 @@ static void gs201_pcie_cp_remove(struct platform_device *pdev) { struct gs201_pcie_cp *cp = platform_get_drvdata(pdev); + if (cp->pm_nb.notifier_call) + unregister_pm_notifier(&cp->pm_nb); mutex_lock(&gs201_cp_lock); gs201_cp = NULL; mutex_unlock(&gs201_cp_lock); @@ -2351,14 +2405,12 @@ static void gs201_pcie_cp_remove(struct platform_device *pdev) * suspend either and only isolates a link that is already down, as * link_down does here. Should those paths ever race, this refuses the * sleep. It is a late abort, not a guard: the root port and the modem are - * children of this device, so the PM core has already run their - * suspend_noirq when this runs. The PCI core has handled the root port - * by then (harmlessly, with PCI_DEV_FLAGS_NO_D3 on it) and leaves the - * modem alone (a syscore device, see cp_bus()); the refusal makes the PM - * core resume them and the sleep fails, with the modem driver's state of - * the modem untouched. The PMU's isolation bit is only logged: a phone - * whose modem never started has never isolated the PHY, and must still - * sleep. + * children of this device, but both are syscore devices (see cp_bus()), + * so the PM core leaves them alone; the refusal fails the sleep with the + * modem driver's state of the link and the modem untouched. Most refusals + * come earlier, from gs201_pcie_cp_pm_notify(). The PMU's isolation bit + * is only logged: a phone whose modem never started has never isolated + * the PHY, and must still sleep. */ static int gs201_pcie_cp_suspend_noirq(struct device *dev) {