[PATCH net v7 2/6] net: wwan: t7xx: fix runtime PM usage count underflow on -EACCES

From: Tim JH Chen

Date: Thu Nov 19 2026 - 20:56:27 EST


t7xx_dpmaif_tx_hw_push_thread(), t7xx_dpmaif_tx_done(),
t7xx_dpmaif_bat_release_work() and t7xx_dpmaif_irq_rx_done() treat
-EACCES from pm_runtime_resume_and_get() as success and proceed to
access the hardware. That is intentional, but
pm_runtime_resume_and_get() has already dropped the usage count it
took before returning -EACCES, so the pm_runtime_put_autosuspend() at
the end of each context (in t7xx_dpmaif_napi_rx_poll() for the RX
interrupt) drops a reference that was never held.

Take the reference with pm_runtime_get_noresume() and resume with
pm_runtime_resume(), so that exactly one reference is held on every
path that touches the hardware, and drop it only on the errors that
abort the operation.

-EACCES is only returned while runtime PM is disabled and the device is
not active. Not observed; found by review.

Fixes: 46e8f49ed7b3 ("net: wwan: t7xx: Introduce power management")
Signed-off-by: Tim JH Chen <tim770802@xxxxxxxxx>
---
drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c | 11 ++++++++---
drivers/net/wwan/t7xx/t7xx_hif_dpmaif_tx.c | 14 ++++++++++----
2 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c b/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c
index 5af90ca6e063..77770869d575 100644
--- a/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c
+++ b/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c
@@ -911,8 +911,10 @@ void t7xx_dpmaif_irq_rx_done(struct dpmaif_ctrl *dpmaif_ctrl, const unsigned int
* which can't be done from softirq context the poll function
* is running in.
*/
- ret = pm_runtime_resume_and_get(ctrl->dev);
+ pm_runtime_get_noresume(ctrl->dev);
+ ret = pm_runtime_resume(ctrl->dev);
if (ret < 0 && ret != -EACCES) {
+ pm_runtime_put_noidle(ctrl->dev);
dev_err(ctrl->dev, "Failed to resume device: %d\n", ret);
return;
}
@@ -1068,9 +1070,12 @@ static void t7xx_dpmaif_bat_release_work(struct work_struct *work)
struct dpmaif_rx_queue *rxq;
int ret;

- ret = pm_runtime_resume_and_get(dpmaif_ctrl->dev);
- if (ret < 0 && ret != -EACCES)
+ pm_runtime_get_noresume(dpmaif_ctrl->dev);
+ ret = pm_runtime_resume(dpmaif_ctrl->dev);
+ if (ret < 0 && ret != -EACCES) {
+ pm_runtime_put_noidle(dpmaif_ctrl->dev);
return;
+ }

t7xx_pci_disable_sleep(dpmaif_ctrl->t7xx_dev);

diff --git a/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_tx.c b/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_tx.c
index 798e4e95004f..48558b98e7c6 100644
--- a/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_tx.c
+++ b/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_tx.c
@@ -162,9 +162,12 @@ static void t7xx_dpmaif_tx_done(struct work_struct *work)
struct dpmaif_hw_info *hw_info;
int ret;

- ret = pm_runtime_resume_and_get(dpmaif_ctrl->dev);
- if (ret < 0 && ret != -EACCES)
+ pm_runtime_get_noresume(dpmaif_ctrl->dev);
+ ret = pm_runtime_resume(dpmaif_ctrl->dev);
+ if (ret < 0 && ret != -EACCES) {
+ pm_runtime_put_noidle(dpmaif_ctrl->dev);
return;
+ }

/* The device may be in low power state. Disable sleep if needed */
t7xx_pci_disable_sleep(dpmaif_ctrl->t7xx_dev);
@@ -461,9 +464,12 @@ static int t7xx_dpmaif_tx_hw_push_thread(void *arg)
break;
}

- ret = pm_runtime_resume_and_get(dpmaif_ctrl->dev);
- if (ret < 0 && ret != -EACCES)
+ pm_runtime_get_noresume(dpmaif_ctrl->dev);
+ ret = pm_runtime_resume(dpmaif_ctrl->dev);
+ if (ret < 0 && ret != -EACCES) {
+ pm_runtime_put_noidle(dpmaif_ctrl->dev);
return ret;
+ }

/* A runtime suspended device was resumed above and had its queues
* restarted, so a stopped queue here belongs to a system suspend
--
2.43.0