From: Gerd Bayer <gbayer@linux.ibm.com>
To: Saeed Mahameed <saeedm@nvidia.com>,
Leon Romanovsky <leon@kernel.org>,
Tariq Toukan <tariqt@nvidia.com>, Mark Bloch <mbloch@nvidia.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Moshe Shemesh <moshe@nvidia.com>, Shay Drori <shayd@nvidia.com>
Cc: Niklas Schnelle <schnelle@linux.ibm.com>,
Alexandra Winter <wintera@linux.ibm.com>,
Gerd Bayer <gbayer@linux.ibm.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Yuanyuan Zhong <yzhong@purestorage.com>,
Mohamed Khalfella <mkhalfella@purestorage.com>,
netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH net] net/mlx5: Avoid deadlock between PCI error recovery and health reporter
Date: Thu, 7 Aug 2025 15:11:30 +0200 [thread overview]
Message-ID: <20250807131130.4056349-1-gbayer@linux.ibm.com> (raw)
During error recovery testing a pair of tasks was reported to be hung
due to a dead-lock situation:
- mlx5_unload_one() trying to acquire devlink lock while the PCI error
recovery code had acquired the pci_cfg_access_lock().
- mlx5_crdump_collect() trying to acquire the pci_cfg_access_lock()
while devlink_health_report() had acquired the devlink lock.
Move the check for pci_channel_offline prior to acquiring the
pci_cfg_access_lock in mlx5_vsc_gw_lock since collecting the crdump will
fail anyhow while PCI error recovery is running.
Fixes: 33afbfcc105a ("net/mlx5: Stop waiting for PCI if pci channel is offline")
Signed-off-by: Gerd Bayer <gbayer@linux.ibm.com>
---
Hi all,
while the initial hit was recorded during "random" testing, where PCI
error recovery and poll_health() tripped almost simultaneously, I found
a way to reproduce a very similar hang at will on s390:
Inject a PCI error recovery event on a Physical Function <BDF> with
zpcictl --reset-fw <BDF>
then request a crdump with
devlink health dump show pci/<BDF> reporter fw_fatal
With the patch applied I didn't get the hang but kernel logs showed:
[ 792.885743] mlx5_core 000a:00:00.0: mlx5_crdump_collect:51:(pid 1415): crdump: failed to lock vsc gw err -13
and the crdump request ended with:
kernel answers: Permission denied
Thanks, Gerd
---
drivers/net/ethernet/mellanox/mlx5/core/lib/pci_vsc.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/pci_vsc.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/pci_vsc.c
index 432c98f2626d..d2d3b57a57d5 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/pci_vsc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/pci_vsc.c
@@ -73,16 +73,15 @@ int mlx5_vsc_gw_lock(struct mlx5_core_dev *dev)
u32 lock_val;
int ret;
+ if (pci_channel_offline(dev->pdev))
+ return -EACCES;
+
pci_cfg_access_lock(dev->pdev);
do {
if (retries > VSC_MAX_RETRIES) {
ret = -EBUSY;
goto pci_unlock;
}
- if (pci_channel_offline(dev->pdev)) {
- ret = -EACCES;
- goto pci_unlock;
- }
/* Check if semaphore is already locked */
ret = vsc_read(dev, VSC_SEMAPHORE_OFFSET, &lock_val);
--
2.48.1
next reply other threads:[~2025-08-07 13:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-07 13:11 Gerd Bayer [this message]
2025-08-10 11:51 ` Shay Drori
2025-08-11 7:29 ` Gerd Bayer
2025-08-11 12:04 ` Shay Drori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250807131130.4056349-1-gbayer@linux.ibm.com \
--to=gbayer@linux.ibm.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=mbloch@nvidia.com \
--cc=mkhalfella@purestorage.com \
--cc=moshe@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=saeedm@nvidia.com \
--cc=schnelle@linux.ibm.com \
--cc=shayd@nvidia.com \
--cc=tariqt@nvidia.com \
--cc=wintera@linux.ibm.com \
--cc=yzhong@purestorage.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®