From nobody Mon Feb 9 17:24:22 2026 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 1D3243557FD; Thu, 30 Oct 2025 10:26:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761819980; cv=none; b=dwl02D1m6u/wClGfr6nrcyIVWdD3tw/wQ4jmYfDVPi/yx9W45NeGq95FLBPNdOK6PlpX08dddKFI2ennEgaUUawSggZotRtBQzS9gAka1PO52GFCADPLdzhRGlUjfs0OZ/uT2EYA4368RVqfn6RsWQuPG725L0JlP3fTlk9BPuc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761819980; c=relaxed/simple; bh=hOOf6cXgc5T9zpXJADydtn2FEPtwwciHF8qIdnrdK18=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GZmPxG20Hd21Y2cKFKD+jl4KPGKEvH1ZzL8cVkFs66u2wpXNVaqRV4WYdFozEQZVkUiCriAHyWcuky3aKFdUGmu91bnWgFdIbpj8YiN7niAa9tlV1KyCNhUXu6yk/u2A35TlqpIjA5+Yi//kh3BRigGMXFk/iW2Wjumfwcq0vSA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=Y8YHD7lI; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="Y8YHD7lI" Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 59TNGUk3025645; Thu, 30 Oct 2025 10:26:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=JuKh8j hDl3jT3OEfhMEsr6AL7VMBfb5O0Vu7kn8sbMw=; b=Y8YHD7lIjRfZqcL8qVJez6 hgWgLZRQWKtc1SH8ftyQFtYQxx7wMYEQ99bScwcygn3caa5Yvu+lNu1N4L5uVdCz RFvq9qqXnHeubqkKPqGlxFfQHe9XSdoOx0qamiGY4ZOQ/joX41SSlsqjntFSZO3q DBqoUdMx92cO9c/yRyXqMa6TfHb43RzAWj+sJDtWWrrActft9h0RfADzKhyUMrvd ukig1S57WvkYyInRbI7li8c4n5PPwBPOcVzqLn3/rduhZS9S4ILOkeU4AM7OYEmb gJvksSPMYcjEdz/b3Yv9M7IrruTz7dubMI1pG6m6r0H02krVy+KviKlyvOKPKopQ == Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4a34acqryn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 30 Oct 2025 10:26:16 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 59U9AEdD018758; Thu, 30 Oct 2025 10:26:15 GMT Received: from smtprelay02.wdc07v.mail.ibm.com ([172.16.1.69]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4a33xwg52f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 30 Oct 2025 10:26:15 +0000 Received: from smtpav02.wdc07v.mail.ibm.com (smtpav02.wdc07v.mail.ibm.com [10.39.53.229]) by smtprelay02.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 59UAQE1314680606 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Oct 2025 10:26:14 GMT Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 01D3D5805C; Thu, 30 Oct 2025 10:26:14 +0000 (GMT) Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 89D355805B; Thu, 30 Oct 2025 10:26:11 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.wdc07v.mail.ibm.com (Postfix) with ESMTP; Thu, 30 Oct 2025 10:26:11 +0000 (GMT) From: Niklas Schnelle Date: Thu, 30 Oct 2025 11:26:01 +0100 Subject: [PATCH 1/2] Revert "PCI/IOV: Add PCI rescan-remove locking when enabling/disabling SR-IOV" Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251030-revert_sriov_lock-v1-1-70f82ade426f@linux.ibm.com> References: <20251030-revert_sriov_lock-v1-0-70f82ade426f@linux.ibm.com> In-Reply-To: <20251030-revert_sriov_lock-v1-0-70f82ade426f@linux.ibm.com> To: Bjorn Helgaas , Lukas Wunner Cc: Keith Busch , Gerd Bayer , Matthew Rosato , Benjamin Block , Halil Pasic , Farhan Ali , Julian Ruess , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Niklas Schnelle X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2128; i=schnelle@linux.ibm.com; h=from:subject:message-id; bh=hOOf6cXgc5T9zpXJADydtn2FEPtwwciHF8qIdnrdK18=; b=owGbwMvMwCX2Wz534YHOJ2GMp9WSGDKZbe1TNZm+zLxo/9/qj5KusXSm/6EbIVNYJITdfTW3v 3h590hqRykLgxgXg6yYIsuiLme/dQVTTPcE9XfAzGFlAhnCwMUpABNRjWdkeJ9V8+v7ab2Xx2cc rm/IeTCtwyqwTXU624GutTUGtZfVZzEyTJ7ZPf9JXvtC7fx1/KeSJ2oGB1W/5pCfGLzr3/VlJz4 pMQIA X-Developer-Key: i=schnelle@linux.ibm.com; a=openpgp; fpr=9DB000B2D2752030A5F72DDCAFE43F15E8C26090 X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=XbuEDY55 c=1 sm=1 tr=0 ts=69033d48 cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=IkcTkHD0fZMA:10 a=x6icFKpwvdMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=VwQbUJbxAAAA:8 a=VnNF1IyMAAAA:8 a=NwnTm4zaWNGWObc0R5cA:9 a=QEXdDO2ut3YA:10 a=cPQSjfK2_nFv0Q5t_7PE:22 X-Proofpoint-ORIG-GUID: S43Tko-NybwzGGxP7clNNIOqttcBsBjS X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDI4MDE2NiBTYWx0ZWRfX5DsuGeTAq+5Q 7gulDgXtynEKNgAcXogSlf9JNLVsHb5wWDMNBeuiIcJ8xJTbFG1Q0KRICnz1iHam6nRtL+VptfY 3rn8z7G5BLkNtOpNIpb8xz4ih1U7AV2bQiHQr1xkSe89pcb/vmET6D+1FWYpr7cCpr2M5xoVQe3 PfmuGIFV6tAJGbygKgShkIfwMAYcTOb9Kh5rrwll0yG+CPiZFH2i5BlCFOPX4+5Jqhy7Gk+U63f XUCCqcvXxcDTH4eky6BaBxagxtD0RqhNyQ0fKFMWu0tKv7d2X7+2tfVcVZR4vMdFHoEyz3jq3Ac c1DePguxeejLk1FPgoPYEpUfPURVv+vLz7wcMITABjYYHzgaPaMHG1zStkfaFEAoKXxdMULSLs6 Iq2fuLli0yIxQ1loVfqUIiCsUREvEg== X-Proofpoint-GUID: S43Tko-NybwzGGxP7clNNIOqttcBsBjS X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-10-30_03,2025-10-29_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 adultscore=0 suspectscore=0 bulkscore=0 spamscore=0 impostorscore=0 phishscore=0 priorityscore=1501 clxscore=1015 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2510280166 This reverts commit 05703271c3cd ("PCI/IOV: Add PCI rescan-remove locking when enabling/disabling SR-IOV") which causes a deadlock by recursively taking pci_rescan_remove_lock when sriov_del_vfs() is called as part of pci_stop_and_remove_bus_device(). For example with the following sequence of commands: $ echo > /sys/bus/pci/devices//sriov_numvfs $ echo 1 > /sys/bus/pci/devices//remove A trimmed trace of the deadlock on a mlx5 device is as below: mutex_lock_nested+0x3c/0x50 sriov_disable+0x34/0x140 mlx5_sriov_disable+0x50/0x80 [mlx5_core] remove_one+0x5e/0xf0 [mlx5_core] pci_device_remove+0x3c/0xa0 device_release_driver_internal+0x18e/0x280 pci_stop_bus_device+0x82/0xa0 pci_stop_and_remove_bus_device_locked+0x5e/0x80 remove_store+0x72/0x90 This is not a complete fix as it restores the issue the cited commit tried to solve. Cc: stable@vger.kernel.org Fixes: 05703271c3cd ("PCI/IOV: Add PCI rescan-remove locking when enabling/= disabling SR-IOV") Reported-by: Benjamin Block Signed-off-by: Niklas Schnelle Reviewed-by: Benjamin Block --- drivers/pci/iov.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index 77dee43b785838d215b58db2d22088e9346e0583..ac4375954c9479b5f4a0e666b52= 15094fdaeefc2 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c @@ -629,18 +629,15 @@ static int sriov_add_vfs(struct pci_dev *dev, u16 num= _vfs) if (dev->no_vf_scan) return 0; =20 - pci_lock_rescan_remove(); for (i =3D 0; i < num_vfs; i++) { rc =3D pci_iov_add_virtfn(dev, i); if (rc) goto failed; } - pci_unlock_rescan_remove(); return 0; failed: while (i--) pci_iov_remove_virtfn(dev, i); - pci_unlock_rescan_remove(); =20 return rc; } @@ -765,10 +762,8 @@ static void sriov_del_vfs(struct pci_dev *dev) struct pci_sriov *iov =3D dev->sriov; int i; =20 - pci_lock_rescan_remove(); for (i =3D 0; i < iov->num_VFs; i++) pci_iov_remove_virtfn(dev, i); - pci_unlock_rescan_remove(); } =20 static void sriov_disable(struct pci_dev *dev) --=20 2.48.1 From nobody Mon Feb 9 17:24:22 2026 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 EDB013559D6; Thu, 30 Oct 2025 10:26:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761819983; cv=none; b=rLZIawXntH+oRjWBEorgIa7meo6mhFXeNOzL+E6Us5KMb+v0BtZyGb6eoLkuv0pje/9qW8VPZRhZKIMj6TQW3gYnDkomvpllLS/+HGxisTKdxlgcX7U53R18W7JMkdziDCd/iqif2wK0bPMfBGtsiaqNtI5hmNkkKFl/Pd/+Cug= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761819983; c=relaxed/simple; bh=lbYSck5feS6luX5oZ+P/wQz/apqe3kVu3JeIJbJAoho=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sRop83aO6nbPOleNqyTzoSaT/g5z7l430eaUTvwF8EKCw6QnMPhgK9WQ0A6RzlyukTn2yZjUS+46wuujPDLx1dq17kr4WgWBWB5zg2H/x7lXaelem+U1uVGNsHl69e9TfM0RcB/e5Gm/9XUJC1j2UQNiNxWGLeFz0Q6AaEANlTs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=N/X0/4uB; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="N/X0/4uB" Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 59TKoDZK008744; Thu, 30 Oct 2025 10:26:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=7AexNm X2b7l4O63cFOSJuz3GMoAMoLTt5TZxmLKKAwo=; b=N/X0/4uBPXkqjeKSP5ixCj IpcWMWvsycgBpxpKqbQIeK61jGG6JJ4ChBeg/LjzBzFA0mKPkejADL9E4BsDcch3 gAZLFL25Q016U91N5OC5waus7IOtkXiWqPufQlYuc6pegK1U21HJEZ/xP/HSwj/A re9DmQmHyxFcQ+rw8zqwXOkwl6cYhxg+sZp0M7Mc4oi4aNvJZgL/ZuwP1+9n6TPf UVEsJKIc+kCXEjfIFeOm/cmu6OQ94+7X6ezjQE/JNq/n/MWdBa433cmS5d+4OkJJ /G4ah9ovNHwCtRS476pgy8O5DYlFkddeMG2yuvlwEgc5enIIn3BddF0QQ/mWeVdA == Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4a34afft0d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 30 Oct 2025 10:26:19 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 59U9e7mP030759; Thu, 30 Oct 2025 10:26:18 GMT Received: from smtprelay02.dal12v.mail.ibm.com ([172.16.1.4]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4a33wwr66w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 30 Oct 2025 10:26:18 +0000 Received: from smtpav02.wdc07v.mail.ibm.com (smtpav02.wdc07v.mail.ibm.com [10.39.53.229]) by smtprelay02.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 59UAQGI824707718 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Oct 2025 10:26:17 GMT Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AE68858059; Thu, 30 Oct 2025 10:26:16 +0000 (GMT) Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 49E4B58058; Thu, 30 Oct 2025 10:26:14 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.wdc07v.mail.ibm.com (Postfix) with ESMTP; Thu, 30 Oct 2025 10:26:14 +0000 (GMT) From: Niklas Schnelle Date: Thu, 30 Oct 2025 11:26:02 +0100 Subject: [PATCH 2/2] PCI/IOV: Fix race between SR-IOV enable/disable and hotplug Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251030-revert_sriov_lock-v1-2-70f82ade426f@linux.ibm.com> References: <20251030-revert_sriov_lock-v1-0-70f82ade426f@linux.ibm.com> In-Reply-To: <20251030-revert_sriov_lock-v1-0-70f82ade426f@linux.ibm.com> To: Bjorn Helgaas , Lukas Wunner Cc: Keith Busch , Gerd Bayer , Matthew Rosato , Benjamin Block , Halil Pasic , Farhan Ali , Julian Ruess , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Niklas Schnelle X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1889; i=schnelle@linux.ibm.com; h=from:subject:message-id; bh=lbYSck5feS6luX5oZ+P/wQz/apqe3kVu3JeIJbJAoho=; b=owGbwMvMwCX2Wz534YHOJ2GMp9WSGDKZbR2UdKbxhPVcnPno/+O0mQu/SJSV89c93sGy1EVwL VvXwj+7O0pZGMS4GGTFFFkWdTn7rSuYYronqL8DZg4rE8gQBi5OAZgI+x2G/7U/Qz7oHVM6F1ob w/6ExWWtD4MIR0LH9jduws/d8p1lLzH8d5L8L+B+aLbBr6qzlqmTA89wXHY2S0pj2DhJQXSro2o PHwA= X-Developer-Key: i=schnelle@linux.ibm.com; a=openpgp; fpr=9DB000B2D2752030A5F72DDCAFE43F15E8C26090 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Jmvck38pZcckWjGLfjIlRhVb2z26ent2 X-Authority-Analysis: v=2.4 cv=WPhyn3sR c=1 sm=1 tr=0 ts=69033d4b cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=IkcTkHD0fZMA:10 a=x6icFKpwvdMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=VwQbUJbxAAAA:8 a=VnNF1IyMAAAA:8 a=3aDRTbdq9RQ_ftGXbWIA:9 a=QEXdDO2ut3YA:10 a=cPQSjfK2_nFv0Q5t_7PE:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDI4MDE2NiBTYWx0ZWRfX5OzXWMKvndWt ot922/90WSyzv5EhnwM82c3VhN00Q6O7ZMtcBGSgso/vB9r1nHL6MnaWkDgIhRPYPwuwp2aQOGU ddToQT1UbtZGoS+eZhcEA9uiSHOBsBake3CUA1O3Jp+lZt2Q6kORYBWD/o8YVNSpdc1DkgEamAV 24/cbtEPDetFcAoAzWnYfVUgyzcnTNROFHbmeD2sTETAAokeCZfu+sS9Hai/YyKGLtL7o2dqMKB J2VQhguDOCHd+5IRcZjgDcRwSbA328DVrvyEA5UFZS6zJ3afm7u7hpq0ti59QRO13hgWpiQAKYM W3/87UvJHTUqJNFBssxPG8diGXcPrs9k5VH1X8IJjIKOS3QvsY/0mrLk2rpUOa9uT8DO9Q1phPJ UQo9FeSQ/A/TlFA/uqC351ZF6fhEew== X-Proofpoint-ORIG-GUID: Jmvck38pZcckWjGLfjIlRhVb2z26ent2 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-10-30_03,2025-10-29_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 adultscore=0 malwarescore=0 suspectscore=0 spamscore=0 impostorscore=0 lowpriorityscore=0 clxscore=1015 bulkscore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2510280166 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. Cc: stable@vger.kernel.org Fixes: 05703271c3cd ("PCI/IOV: Add PCI rescan-remove locking when enabling/= disabling SR-IOV") Reported-by: Benjamin Block Signed-off-by: Niklas Schnelle Reviewed-by: Benjamin Block --- drivers/pci/iov.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index ac4375954c9479b5f4a0e666b5215094fdaeefc2..c6dc1b44bf602a0b1785b684f76= 8fcd563f5b2aa 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c @@ -495,7 +495,9 @@ static ssize_t sriov_numvfs_store(struct device *dev, =20 if (num_vfs =3D=3D 0) { /* disable VFs */ + pci_lock_rescan_remove(); ret =3D pdev->driver->sriov_configure(pdev, 0); + pci_unlock_rescan_remove(); goto exit; } =20 @@ -507,7 +509,9 @@ static ssize_t sriov_numvfs_store(struct device *dev, goto exit; } =20 + pci_lock_rescan_remove(); ret =3D pdev->driver->sriov_configure(pdev, num_vfs); + pci_unlock_rescan_remove(); if (ret < 0) goto exit; =20 --=20 2.48.1