[{"id":3685000,"web_url":"http://patchwork.ozlabs.org/comment/3685000/","msgid":"<20260501010127.GA990551@rocinante>","list_archive_url":null,"date":"2026-05-01T01:22:56","subject":"Re: [PATCH] PCI/proc: Fix race between pci_proc_init() and\n pci_bus_add_device()","submitter":{"id":86709,"url":"http://patchwork.ozlabs.org/api/people/86709/","name":"Krzysztof Wilczyński","email":"kwilczynski@kernel.org"},"content":"Hello,\n\n> Thus, wrap the for_each_pci_dev() loop with pci_lock_rescan_remove() to\n> serialise against concurrent PCI bus operations.  Add an early return in\n> pci_proc_attach_device() when dev->procent is already set, making the\n> function idempotent and symmetric with pci_proc_detach_device() which\n> clears this field.\n\nA note on testing:\n\n  0-day bot (recent test runs; newer builds will arrive later):\n    - https://lore.kernel.org/linux-pci/202603162306.2oKy0qcP-lkp@intel.com\n\n  Sashiko's feedback:\n    - https://sashiko.dev/#/patchset/20260430003542.455198-1-kwilczynski%40kernel.org\n\nLorenzo Pieralisi did some testing reported outside the mailing list (we\ntalked on IRC) on the platform he had some boot issues.  With this patch\napplied, the problems seen before were resolved.\n\nThank you!\n\n\tKrzysztof","headers":{"Return-Path":"\n <linux-pci+bounces-53570-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-pci@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=drWLaSsW;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c09:e001:a7::12fc:5321; helo=sto.lore.kernel.org;\n envelope-from=linux-pci+bounces-53570-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=\"drWLaSsW\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"Received":["from sto.lore.kernel.org (sto.lore.kernel.org\n [IPv6:2600:3c09:e001:a7::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g6CwB4Jflz1yGq\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 01 May 2026 11:23:06 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sto.lore.kernel.org (Postfix) with ESMTP id A3F103002B0F\n\tfor <incoming@patchwork.ozlabs.org>; Fri,  1 May 2026 01:23:01 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id CC5921DF751;\n\tFri,  1 May 2026 01:22:58 +0000 (UTC)","from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org\n [10.30.226.201])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id A9B9A196C7C\n\tfor <linux-pci@vger.kernel.org>; Fri,  1 May 2026 01:22:58 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 0E718C2BCB3;\n\tFri,  1 May 2026 01:22:57 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777598578; cv=none;\n b=Uxx9UVptcfubsjeJL1awjNDtopsWiktXxQv7Hd7C6HHpheCOz4vohKkTf0NdUiYveFMRyUC0d6l6kKC4tSKuEFwWh9P8gEUPpEfD8SeusORfz/3XS166iJbkfBRGvp/SP1SOih/ffubv9no9YyOXgTYQXCs11NlW8vDGdptLMY0=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777598578; c=relaxed/simple;\n\tbh=CJicru/fWCwFUGV/6UVVlaBFv5vn8lon3daaPVOxKwc=;\n\th=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:\n\t Content-Type:Content-Disposition:In-Reply-To;\n b=AFsDxUe2gfC8hlQtdUbs2k0EX0WS9dNFny9Jl27TYiK+SRODed+z3SdYjWmg8kn4IbK2JjBtf1LRsrxBdJ/IFKZk8RxNXeEHT7eKm0vVSF6F8mhmkxHvJJNbjRg1eD0d5UXbU37L/YYhknVf9M4Pr/LjZZWM+YcDg/+LjZ3qCN8=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=drWLaSsW; arc=none smtp.client-ip=10.30.226.201","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1777598578;\n\tbh=CJicru/fWCwFUGV/6UVVlaBFv5vn8lon3daaPVOxKwc=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=drWLaSsWdozW1FMZ8RFoosMiSTob0PlOz+j5Z2kUNB52EG27hATafJKsBbEpCZ95q\n\t iwazRiYdjpUlaXwTKL1qBHenbh+VPD1PtF2IcgYUhevHQ757xIROwLWplv4uXA4zMf\n\t 1d7eB6m4W1xdEug0qkNTLMI+INRVhZGrELb6Y489qt1IBcknWOV/mAW9MmAMP5fXUc\n\t urOVSmFSV7HEUZ/+aANmmysV8BMte33g6LZSFdKY73Si4+pbICuQawGg16GCp8qEeL\n\t Yezb4vG9/Yk2XIaUNMrrOFUP+3pLzgdCsgDyNzGr3AipDE5uoHv8R2OtaZB78lEUcn\n\t FBHd+HnPn9bTQ==","Date":"Fri, 1 May 2026 10:22:56 +0900","From":"Krzysztof =?utf-8?q?Wilczy=C5=84ski?= <kwilczynski@kernel.org>","To":"Bjorn Helgaas <bhelgaas@google.com>","Cc":"Bjorn Helgaas <helgaas@kernel.org>,\n  Manivannan Sadhasivam <mani@kernel.org>,\n Lorenzo Pieralisi <lpieralisi@kernel.org>,\n  Ilpo =?utf-8?b?SsOkcnZpbmVu?= <ilpo.jarvinen@linux.intel.com>,\n Lukas Wunner <lukas@wunner.de>, Shuan He <heshuan@bytedance.com>,\n  linux-pci@vger.kernel.org","Subject":"Re: [PATCH] PCI/proc: Fix race between pci_proc_init() and\n pci_bus_add_device()","Message-ID":"<20260501010127.GA990551@rocinante>","References":"<20260430003542.455198-1-kwilczynski@kernel.org>","Precedence":"bulk","X-Mailing-List":"linux-pci@vger.kernel.org","List-Id":"<linux-pci.vger.kernel.org>","List-Subscribe":"<mailto:linux-pci+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-pci+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20260430003542.455198-1-kwilczynski@kernel.org>"}},{"id":3685214,"web_url":"http://patchwork.ozlabs.org/comment/3685214/","msgid":"<20260501193721.GA511830@bhelgaas>","list_archive_url":null,"date":"2026-05-01T19:37:21","subject":"Re: [PATCH] PCI/proc: Fix race between pci_proc_init() and\n pci_bus_add_device()","submitter":{"id":67298,"url":"http://patchwork.ozlabs.org/api/people/67298/","name":"Bjorn Helgaas","email":"helgaas@kernel.org"},"content":"On Fri, May 01, 2026 at 10:22:56AM +0900, Krzysztof Wilczyński wrote:\n> Hello,\n> \n> > Thus, wrap the for_each_pci_dev() loop with pci_lock_rescan_remove() to\n> > serialise against concurrent PCI bus operations.  Add an early return in\n> > pci_proc_attach_device() when dev->procent is already set, making the\n> > function idempotent and symmetric with pci_proc_detach_device() which\n> > clears this field.\n> \n> A note on testing:\n> \n>   0-day bot (recent test runs; newer builds will arrive later):\n>     - https://lore.kernel.org/linux-pci/202603162306.2oKy0qcP-lkp@intel.com\n> \n>   Sashiko's feedback:\n>     - https://sashiko.dev/#/patchset/20260430003542.455198-1-kwilczynski%40kernel.org\n> \n> Lorenzo Pieralisi did some testing reported outside the mailing list (we\n> talked on IRC) on the platform he had some boot issues.  With this patch\n> applied, the problems seen before were resolved.\n\nThanks!  Can we include a link to the problem report and maybe a\ncouple lines of the symptoms?\n\nAlso the analysis of Sashiko feedback?\n\nSashiko worried about pci_lock_rescan_remove() deadlock between\npci_proc_init() and PCI controller drivers with async probing.\npci_proc_init() is a device initcall.  Some drivers are also device\ninitcalls (imx_pcie_init(), ks_pcie_init(), rcar_pcie_init()), and it\nlooks like they can use async probing.\n\nDoes this rely on the pci_proc_init() device_initcall happening before\nany of the driver device_initcalls?  That would be non-obvious and\nfragile.\n\nThe second sashiko issue (concurrent calls of\npci_proc_attach_device()) also seems worth a look.  The\npci_enable_sriov() path isn't serialized by pci_lock_rescan_remove():\n\n  pci_enable_sriov\n    sriov_enable\n      sriov_add_vfs\n        pci_iov_add_virtfn\n          pci_bus_add_device\n            pci_proc_attach_device\n              bus->procdir = proc_mkdir()\n\nIf two threads race for devices on the same bus, it looks like the\nloser can set bus->procdir back to NULL when proc_mkdir() fails with\n\"duplicate entry\".\n\nThis is a per-device path, but we're creating a per-bus directory.  I\nwonder if that proc_mkdir() could/should be done in a bus creation\npath?","headers":{"Return-Path":"\n <linux-pci+bounces-53604-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-pci@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=XRrKsHd0;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.105.105.114; helo=tor.lore.kernel.org;\n envelope-from=linux-pci+bounces-53604-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=\"XRrKsHd0\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"Received":["from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g6hBv1N2Xz1xvV\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 02 May 2026 05:37:27 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby tor.lore.kernel.org (Postfix) with ESMTP id 79E88300DA70\n\tfor <incoming@patchwork.ozlabs.org>; Fri,  1 May 2026 19:37:24 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id D0D8D40B6E8;\n\tFri,  1 May 2026 19:37:23 +0000 (UTC)","from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org\n [10.30.226.201])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id AD011346E46\n\tfor <linux-pci@vger.kernel.org>; Fri,  1 May 2026 19:37:23 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 3F1BBC2BCB4;\n\tFri,  1 May 2026 19:37:23 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777664243; cv=none;\n b=VHSQEYjMv2kwXzQ8UPmz1pqlQ759iyCxZah3CAJN33UsoimZmmIMm2NHym9Fkupz0aHAVGSHk/MZwuT7R2krZ6gLIr178ZUhsI4a5qWsP9Ml2gp5ZymZ8d4vkQndP9YzukoFECtL6AVYdqc5MkK+TXrpniBrw/qLff8JGrJ1HKY=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777664243; c=relaxed/simple;\n\tbh=a1HVvxBli67IFW2LWFabcWygSyAIX9i8lmA4uyxDfZo=;\n\th=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type:\n\t Content-Disposition:In-Reply-To;\n b=C2s2fyWtcOezqGBBFnWuN26QBbJr7SMj/tvZayEHhgbvxKWCYFcM+c3IgwY85TwCdm7Ngpv3OHHoDjJ7sq5CC3RRrn59Y+es0fwMonNdI8O6/JZ0SZEdvQz7q09qyuJufdpCWs9adM5wwVxsQejrOAaU2eRG7EycftHaRBqM2WQ=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=XRrKsHd0; arc=none smtp.client-ip=10.30.226.201","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1777664243;\n\tbh=a1HVvxBli67IFW2LWFabcWygSyAIX9i8lmA4uyxDfZo=;\n\th=Date:From:To:Cc:Subject:In-Reply-To:From;\n\tb=XRrKsHd0k7kTGf+plnf/j0Dw2fiTN/KOiqASjs7GWJmzgoteNrbKOxfloY/xo4BAb\n\t o45r277c1Ge6mRg+8t4nJdkxx+Extujj1nsOxKc+EngKnoJLDUgq43ub4ynp++Aar6\n\t 1PJWl48QaN9DDs/rTDTsyFQylcWI3qjjE8M/Em83424mhfa2rvoJkiAajegC3l8vfs\n\t E1NoFiKmRbNOAXEbndBWyGCIqrJu++Ii8vMApxX0eSzlbZKVHk9U1KDUYRcIZrsFPu\n\t i6OsttY0soEidqXOyRrUo8j99fs2Qd8TYWfSmHR4x+II3lGOJDizlYaICdimfuyvV2\n\t nc5dm1aKpjh4Q==","Date":"Fri, 1 May 2026 14:37:21 -0500","From":"Bjorn Helgaas <helgaas@kernel.org>","To":"Krzysztof =?utf-8?q?Wilczy=C5=84ski?= <kwilczynski@kernel.org>","Cc":"Bjorn Helgaas <bhelgaas@google.com>,\n Manivannan Sadhasivam <mani@kernel.org>,\n Lorenzo Pieralisi <lpieralisi@kernel.org>,\n Ilpo =?utf-8?b?SsOkcnZpbmVu?= <ilpo.jarvinen@linux.intel.com>,\n Lukas Wunner <lukas@wunner.de>, Shuan He <heshuan@bytedance.com>,\n linux-pci@vger.kernel.org","Subject":"Re: [PATCH] PCI/proc: Fix race between pci_proc_init() and\n pci_bus_add_device()","Message-ID":"<20260501193721.GA511830@bhelgaas>","Precedence":"bulk","X-Mailing-List":"linux-pci@vger.kernel.org","List-Id":"<linux-pci.vger.kernel.org>","List-Subscribe":"<mailto:linux-pci+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-pci+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20260501010127.GA990551@rocinante>"}}]