From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj2-f38.google.com (mail-pj2-f38.google.com [74.125.227.166]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8584433374F for ; Fri, 2 Oct 2026 01:46:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.227.166 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790905618; cv=none; b=bSNBq9SSWqroYI14IiRWJhosof4y7G3LCTC8rnjNH1V+tawbaTXMPOrFBO28Nktl/JV4whCxlENXYGpyF6/s/0Q8EJYS+czTJ4oPPB/jxMv/MrkVra7DOpK/tD2nfb4UROSvQlg+w7G72OnFe5DuUHCxCOeKgGdGxGsNj3An07o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790905618; c=relaxed/simple; bh=+LmznV4vqKZKlzaALnt13HVXmJnjozQyZpMusn1fuJA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IXqf+HxYRkDozjV+BP9C6XHQvwnGl5+p4z7GQJr6tA96vIlZqu6CVFlIOmR37v5yFpAv2eRYuWf16KedlYv6P1WXRAvNdxGH9KrC7nBt95FOp4/G25jnSt1QRHX0wK8SDGo2+p9pSgbkdFL0nsmAq37jj2S0BvOBzi1NbRgvB3I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=BCAbVkI3; arc=none smtp.client-ip=74.125.227.166 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BCAbVkI3" Received: by mail-pj2-f38.google.com with SMTP id d9443c01a7336-2e2d9fdf798so14229645ad.0 for ; Thu, 01 Oct 2026 18:46:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790905617; x=1791510417; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=3tFfU5pIfaYR6a5rnUAElWbpWv0wF5OoVzykxSyz4sc=; b=BCAbVkI3ZW8FnTYkj5KuF5FHW4hTOiPWQ9epZMSKQn1ChrJ5gFpBjoKcQHcPISeFvu 4xjSIC3Xr4A1QziHB0i5HgOoEVSkrpoSRRlwUHPKHSc1WFX/tFQavKkPNmG0grN5z+kz otdgEWJfnzyGYBsfilEhQBYPejS/8r5jpJeoW45QNiHsA5kzDpLwEZTEcVeue60+rcGS MoB+EMGdaQWA+DQ1t3slSR3X0yj9Cbarzsle4WmRKXOGeSipfQIQwd366+hz1uiTAQtq 4rftgixlFTM6+1BHtTyjzfx5LAYYpPLocwfdm/XaC1cLB+qfGYwda8w4aYoyb8noK4Ds a6UQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790905617; x=1791510417; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=3tFfU5pIfaYR6a5rnUAElWbpWv0wF5OoVzykxSyz4sc=; b=NYQK8TLshgo53P8CGfpzybP4kQzX6YYBIApID71EnvQhaD4qcGuZ1moGIe7jyflOyk kW05F6ogdiHHuxWI2A47JMITd4N4cY2nJM3ZfziIfJtWApCIZAd1f4D0HDFO7q7wxdmI IDBERae/3VIOA+tIJhJBsCxSvhFAqNQkkQjQiRBSr+tM8mUzR8n3mr8W41ukuoSdLGxV lWd8fpw01ll7J63QaTqWeuhTsjR+3Rx7KDuO1JoR3tPf6j8ImrbWU8pkmPEmrq09dVe7 qoKHloTvoc+UkkoNzPeihOAg4SzTO9pCUy+kuZsESmLnAGY75OwXQmozYQqG+aaaiDVR Yb8Q== X-Forwarded-Encrypted: i=1; AKwUvBxeWkPUCGcqOnrFIJ2VgurFTrV4/JPjDi6V1Eu3htHiHA/tN+gbkjBEPhpQuIrxL71eXjlelM1y9NcYb5c=@vger.kernel.org X-Gm-Message-State: AFq9FYJR6u0tCtXNRMZhQX7W7IZkXd3PsPprpHGp/NOFO/QBzspJr104 80tWzfkfdfZqPDffzZK4mIMj/f79QtP8t68d9e7aC5cdjrTFUAdZMvID X-Gm-Gg: AYBFou28BtBbkTgea2BkdVJq0eKX05OzWmyOLrYESH8uYo80oic+ok8nq2PSTCrw743 PyzFObBc9n1+y3DT7yGBAstXKNexh8gw9Nb0RQqmKw00yuPjvFl2eMF4q37P+f0qF5A3LzOBPWt yQqBvVSBgUU/dRTILOQrgSYT5IeU/4YxONSIbj98+4TFErhTVNliL6YjrhMHGaqHCndTZjCziqs rFUVsyIiTLoY/SGPJmOwdAioc5vCnHwWOJt6w3ZfgP3WVJC/9s+oIp9trhy7j3l5hkrTCQcSdw1 ZM+deHcNWMLMbFldNewdF+W0PnqQL25iOedcGiIXPtGsS7RhTEl5bLkAcsxK+/SvQx96qT91mtT StC4Jf7NLiQ1/wi0UOErVqm+xUa+lfQRkeWcFwGesdHrnyB0cNxTHgmHo/hj8UenBtBkX0Geg0W nThhZcvpQvZpNOPJ2XUvLNMP9y/4RUlM9YELqeXwiUizy1OmNtErjAh+1PAvIDzm+BRzOG/WtjW 4XvR5xOzQZhwzi/yPCbFrLm04LUUW0= X-Received: by 2002:a17:902:e5c4:b0:2dd:ad73:5b6b with SMTP id d9443c01a7336-2e49b6808f6mr11142355ad.27.1790905616570; Thu, 01 Oct 2026 18:46:56 -0700 (PDT) Received: from u.. (61-222-64-201.hinet-ip.hinet.net. [61.222.64.201]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2e49f6ceaedsm2675645ad.49.2026.10.01.18.46.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2026 18:46:55 -0700 (PDT) From: Tim JH Chen To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, andrew+netdev@lunn.ch, horms@kernel.org, ilpo.jarvinen@linux.intel.com, johannes@sipsolutions.net, loic.poulain@oss.qualcomm.com, ryazanov.s.a@gmail.com, chandrashekar.devegowda@intel.com, haijun.liu@mediatek.com, ricardo.martinez@linux.intel.com, linux-kernel@vger.kernel.org, tim.jh.chen@wnc.com.tw, Chih.Hung.Huang@wnc.com.tw, Tim JH Chen Subject: [PATCH net v6 1/4] net: wwan: t7xx: fix runtime PM usage count underflow on -EACCES Date: Fri, 2 Oct 2026 09:46:35 +0800 Message-ID: <20261002014638.47981-2-tim770802@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261002014638.47981-1-tim770802@gmail.com> References: <20261002014638.47981-1-tim770802@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit t7xx_dpmaif_tx_hw_push_thread(), t7xx_dpmaif_tx_done() and t7xx_dpmaif_bat_release_work() 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 unconditional pm_runtime_put_autosuspend() at the end of each context drops a reference that was never held and drives the usage count negative. Only balance the reference when it was actually taken. Fixes: 46e8f49ed7b3 ("net: wwan: t7xx: Introduce power management") Signed-off-by: Tim JH Chen --- drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c | 3 ++- drivers/net/wwan/t7xx/t7xx_hif_dpmaif_tx.c | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 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..0e1174ee611d 100644 --- a/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c +++ b/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c @@ -1082,7 +1082,8 @@ static void t7xx_dpmaif_bat_release_work(struct work_struct *work) } t7xx_pci_enable_sleep(dpmaif_ctrl->t7xx_dev); - pm_runtime_put_autosuspend(dpmaif_ctrl->dev); + if (ret != -EACCES) + pm_runtime_put_autosuspend(dpmaif_ctrl->dev); } int t7xx_dpmaif_bat_rel_wq_alloc(struct dpmaif_ctrl *dpmaif_ctrl) diff --git a/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_tx.c b/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_tx.c index 236d632cf591..bd6116a8c541 100644 --- a/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_tx.c +++ b/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_tx.c @@ -160,12 +160,16 @@ static void t7xx_dpmaif_tx_done(struct work_struct *work) struct dpmaif_tx_queue *txq = container_of(work, struct dpmaif_tx_queue, dpmaif_tx_work); struct dpmaif_ctrl *dpmaif_ctrl = txq->dpmaif_ctrl; struct dpmaif_hw_info *hw_info; + bool pm_ref; int ret; ret = pm_runtime_resume_and_get(dpmaif_ctrl->dev); if (ret < 0 && ret != -EACCES) return; + /* -EACCES means no reference was taken; only balance a real one. */ + pm_ref = !ret; + /* The device may be in low power state. Disable sleep if needed */ t7xx_pci_disable_sleep(dpmaif_ctrl->t7xx_dev); if (t7xx_pci_sleep_disable_complete(dpmaif_ctrl->t7xx_dev)) { @@ -185,7 +189,8 @@ static void t7xx_dpmaif_tx_done(struct work_struct *work) } t7xx_pci_enable_sleep(dpmaif_ctrl->t7xx_dev); - pm_runtime_put_autosuspend(dpmaif_ctrl->dev); + if (pm_ref) + pm_runtime_put_autosuspend(dpmaif_ctrl->dev); } static void t7xx_setup_msg_drb(struct dpmaif_ctrl *dpmaif_ctrl, unsigned int q_num, @@ -467,7 +472,8 @@ static int t7xx_dpmaif_tx_hw_push_thread(void *arg) t7xx_pci_disable_sleep(dpmaif_ctrl->t7xx_dev); t7xx_do_tx_hw_push(dpmaif_ctrl); t7xx_pci_enable_sleep(dpmaif_ctrl->t7xx_dev); - pm_runtime_put_autosuspend(dpmaif_ctrl->dev); + if (ret != -EACCES) + pm_runtime_put_autosuspend(dpmaif_ctrl->dev); } return 0; -- 2.43.0