From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C5B0540F397; Sat, 28 Feb 2026 17:44:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772300689; cv=none; b=O9x3N4aF7C+Ev+R0vyy6BNQV3n4h5Ql+zi+1DGUSKswgZOi0p9R5FoUKJwp76H4gKS+NXbCK5l/BuLVYVH0G6jC3f0T2IfZxd1SlVZrW9NIWXmqexXbp+T641eEZB8eHcgnYdoinBUN0BxX9ynYOPivmN5t4l/qSnk26U8AoPV4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772300689; c=relaxed/simple; bh=WZFSXAUJDe6g1AzSqwFAPL0xXDLsa7xxrDe5oto/pqI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jmOz1C0qGhE9wrg3U+xv2kDj+LEwEawM/o7dUi8MMT6RwuhEUqJBRXGtE+BWacw8ZvkFLW7fYqsDJo7lqT8pNAnsWr5tXteLsn5zp/uhsQnvNpuibuXufOHm15lI/9XIG/e3ZYjtxZX0WZq2EDdFpqQrg3oiiXK3t/35QpUZ/bs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GYkWXTcv; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GYkWXTcv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE23CC19424; Sat, 28 Feb 2026 17:44:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772300689; bh=WZFSXAUJDe6g1AzSqwFAPL0xXDLsa7xxrDe5oto/pqI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GYkWXTcvcL7vNeRpn01rw/bi59L2w+F57MQTm5r5lGCeNAOHwSo2S83qvkSDqD65M SEXLbu3MsBxVxuGd424V4PPoM2GkSS4sSVmLfsK9musnDGKAn2hHzsGZme01G2MfGS 2rcSGzs0SaUORnXPBBgJDmAqAj2u6UZjpCzb+6G08zpLv77X7dSMTJ8qmFva+lj0e0 qoRnZFZaAg4FrXvU1qz2PTXqkcfvNgESjTf6hA15PUMhU5t1ldijTuv1WPfCQd4vZc GvJt+1/SPplLfN0CTyO6zebHkdExDZ05C0RnLD1FSd1mrtKULDYhO2eEqLEEnaltzK 933h9JPvE4W/Q== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Niklas Schnelle , Benjamin Block , Bjorn Helgaas , Gerd Bayer , Sasha Levin Subject: [PATCH 6.19 725/844] PCI/IOV: Fix race between SR-IOV enable/disable and hotplug Date: Sat, 28 Feb 2026 12:30:38 -0500 Message-ID: <20260228173244.1509663-726-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260228173244.1509663-1-sashal@kernel.org> References: <20260228173244.1509663-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Niklas Schnelle [ Upstream commit a5338e365c4559d7b4d7356116b0eb95b12e08d5 ] Commit 05703271c3cd ("PCI/IOV: Add PCI rescan-remove locking when enabling/disabling SR-IOV") tried to fix a race between the VF removal inside sriov_del_vfs() and concurrent hot unplug by taking the PCI rescan/remove lock in sriov_del_vfs(). Similarly the PCI rescan/remove lock was also taken in sriov_add_vfs() to protect addition of VFs. This approach however causes deadlock on trying to remove PFs with SR-IOV enabled because PFs disable SR-IOV during removal and this removal happens under the PCI rescan/remove lock. So the original fix had to be reverted. Instead of taking the PCI rescan/remove lock in sriov_add_vfs() and sriov_del_vfs(), fix the race that occurs with SR-IOV enable and disable vs hotplug higher up in the callchain by taking the lock in sriov_numvfs_store() before calling into the driver's sriov_configure() callback. Fixes: 05703271c3cd ("PCI/IOV: Add PCI rescan-remove locking when enabling/disabling SR-IOV") Reported-by: Benjamin Block Signed-off-by: Niklas Schnelle Signed-off-by: Bjorn Helgaas Reviewed-by: Benjamin Block Reviewed-by: Gerd Bayer Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20251216-revert_sriov_lock-v3-2-dac4925a7621@linux.ibm.com Signed-off-by: Sasha Levin --- drivers/pci/iov.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index 7de5b18647beb..4a659c34935e1 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c @@ -495,7 +495,9 @@ static ssize_t sriov_numvfs_store(struct device *dev, if (num_vfs == 0) { /* disable VFs */ + pci_lock_rescan_remove(); ret = pdev->driver->sriov_configure(pdev, 0); + pci_unlock_rescan_remove(); goto exit; } @@ -507,7 +509,9 @@ static ssize_t sriov_numvfs_store(struct device *dev, goto exit; } + pci_lock_rescan_remove(); ret = pdev->driver->sriov_configure(pdev, num_vfs); + pci_unlock_rescan_remove(); if (ret < 0) goto exit; -- 2.51.0