Cover Letter Detail
Show a cover letter.
GET /api/1.1/covers/2221681/?format=api
{ "id": 2221681, "url": "http://patchwork.ozlabs.org/api/1.1/covers/2221681/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-pci/cover/20260410055040.39233-1-kwilczynski@kernel.org/", "project": { "id": 28, "url": "http://patchwork.ozlabs.org/api/1.1/projects/28/?format=api", "name": "Linux PCI development", "link_name": "linux-pci", "list_id": "linux-pci.vger.kernel.org", "list_email": "linux-pci@vger.kernel.org", "web_url": null, "scm_url": null, "webscm_url": null }, "msgid": "<20260410055040.39233-1-kwilczynski@kernel.org>", "date": "2026-04-10T05:50:20", "name": "[00/20] PCI: Convert all dynamic sysfs attributes to static", "submitter": { "id": 86709, "url": "http://patchwork.ozlabs.org/api/1.1/people/86709/?format=api", "name": "Krzysztof Wilczyński", "email": "kwilczynski@kernel.org" }, "mbox": "http://patchwork.ozlabs.org/project/linux-pci/cover/20260410055040.39233-1-kwilczynski@kernel.org/mbox/", "series": [ { "id": 499398, "url": "http://patchwork.ozlabs.org/api/1.1/series/499398/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-pci/list/?series=499398", "date": "2026-04-10T05:50:21", "name": "PCI: Convert all dynamic sysfs attributes to static", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/499398/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/covers/2221681/comments/", "headers": { "Return-Path": "\n <linux-pci+bounces-52262-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=TdZG2f9t;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=linux-pci+bounces-52262-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=\"TdZG2f9t\"", "smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201" ], "Received": [ "from sea.lore.kernel.org (sea.lore.kernel.org\n [IPv6:2600:3c0a:e001:db::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 4fsQtB2D1nz1yGb\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 10 Apr 2026 15:52:02 +1000 (AEST)", "from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 060B4301AA54\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 10 Apr 2026 05:50:46 +0000 (UTC)", "from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 6AC7930F52A;\n\tFri, 10 Apr 2026 05:50:45 +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 4531D30BF5C;\n\tFri, 10 Apr 2026 05:50:45 +0000 (UTC)", "by smtp.kernel.org (Postfix) with ESMTPSA id B723BC19421;\n\tFri, 10 Apr 2026 05:50:41 +0000 (UTC)" ], "ARC-Seal": "i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1775800245; cv=none;\n b=XOKr1dSzw25J/Fs7QuyS2zpR6ldtb0ia9Iir2SM9PRXD4gaDJrUjVm+H1DOKjptjrufvkJ4W3xwehy4Czt4nUze0odzxSVehbqPuddLeCFXR//6zeiRcBqvsnfamrVMGJfPsiFfQ9MQyfEfOGFPXTPScq+QBIpLHLjD4y7OQ2VQ=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1775800245; c=relaxed/simple;\n\tbh=heNFs70N3BP1J7/YAXV0i5l1cHEi6uhW1IDN/z9Cms0=;\n\th=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type;\n b=Z2mrTYjAxgyr/xUhTLXcyemYTDAFjYWWNaOLXAo/n4kIPn6VuZSJ10S3VzZXOjhVkIN9PwTFU08wx2Ry5LjL/MJUI/karuLiT1qY2dq5PiDkgYJ2C8HhB6POouPKQlCtJb2q3yJg9uyV//PgaeTRLU/4laYKmmnO2iOGWsJBLIg=", "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=TdZG2f9t; 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=1775800244;\n\tbh=heNFs70N3BP1J7/YAXV0i5l1cHEi6uhW1IDN/z9Cms0=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=TdZG2f9txWpdj7lY67wEZFVQXWBe+rLFAMovErKrjBn6+8wWffZgTOjB0EUSFV8bU\n\t xvP+MIZPndc6dlAsTGQVncui+vuuY8GzJUI/p7K1ZLLrXIhyObLCt8VjBHYI13lFj8\n\t seKMHcHg2hsuKm586Myz1bqU0SjwxlqGO6OXshoYBUa7n04PTJkoKo/BAXAFeVEhyB\n\t ojCBMdpG5+V/psVi7tdM+uv2iK8yoXCpoJQi1JkhhH09Z8iQB/HkmkeI7lfEJUau57\n\t wjD5UBH1KQgjs526NJql8iCUdJboPZw4qw3Q34UPLMm5sBIAjAGviCn1T4rBiS2rP1\n\t s1LT9RZ6z3+DA==", "From": "=?utf-8?q?Krzysztof_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 Magnus Lindholm <linmag7@gmail.com>, Matt Turner <mattst88@gmail.com>,\n Richard Henderson <richard.henderson@linaro.org>,\n Christophe Leroy <chleroy@kernel.org>,\n Madhavan Srinivasan <maddy@linux.ibm.com>,\n Michael Ellerman <mpe@ellerman.id.au>, Nicholas Piggin <npiggin@gmail.com>,\n Dexuan Cui <decui@microsoft.com>,\n =?utf-8?q?Krzysztof_Ha=C5=82asa?= <khalasa@piap.pl>,\n Lukas Wunner <lukas@wunner.de>, \"Oliver O'Halloran\" <oohall@gmail.com>,\n Saurabh Singh Sengar <ssengar@microsoft.com>,\n Shuan He <heshuan@bytedance.com>, Srivatsa Bhat <srivatsabhat@microsoft.com>,\n\t=?utf-8?q?Ilpo_J=C3=A4rvinen?= <ilpo.jarvinen@linux.intel.com>,\n linux-pci@vger.kernel.org, linux-alpha@vger.kernel.org,\n linuxppc-dev@lists.ozlabs.org", "Subject": "[PATCH 00/20] PCI: Convert all dynamic sysfs attributes to static", "Date": "Fri, 10 Apr 2026 05:50:20 +0000", "Message-ID": "<20260410055040.39233-1-kwilczynski@kernel.org>", "X-Mailer": "git-send-email 2.53.0", "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-Transfer-Encoding": "8bit" }, "content": "Hello,\n\nThis series converts every dynamically allocated PCI sysfs attribute to\na static const definition. After the full series, pci_sysfs_init() and\nsysfs_initialized are gone, and every sysfs file is created by the\ndriver model at device_add() time.\n\nCurrently, the PCI resource files (resourceN, resourceN_wc) and the\nlegacy bus files (legacy_io, legacy_mem) are created dynamically\nfrom two unsynchronised paths:\n\nPath A: late_initcall\n\n pci_sysfs_init (late_initcall)\n sysfs_initialized = 1\n for_each_pci_dev\n pci_create_sysfs_dev_files\n sysfs_create_bin_file (resourceN, resourceN_wc)\n pci_find_next_bus\n pci_create_legacy_files\n sysfs_create_bin_file (legacy_io, legacy_mem)\n\nPath B: device registration / hotplug\n\n pci_bus_add_devices\n pci_bus_add_device\n pci_create_sysfs_dev_files\n if (!sysfs_initialized) return <- only guard\n sysfs_create_bin_file (resourceN, resourceN_wc)\n\nOn most ACPI systems this does not race because PCI enumeration\ncompletes at subsys_initcall time, before pci_sysfs_init() runs:\n\n subsys_initcall (level 4):\n acpi_pci_root_add\n pci_bus_add_device\n pci_create_sysfs_dev_files\n if (!sysfs_initialized) <- not yet set\n return -EACCES\n\n late_initcall (level 7):\n pci_sysfs_init\n sysfs_initialized = 1\n for_each_pci_dev\n pci_create_sysfs_dev_files <- creates the files, no race\n\nOn Devicetree platforms the host controller is a platform driver that\nprobes via the driver model, often on a workqueue, and overlaps with the\nlate_initcall:\n\n CPU 0 (late_initcall) CPU 1 (driver probe)\n --------------------------- ----------------------------\n pci_sysfs_init()\n sysfs_initialized = 1\n for_each_pci_dev(pdev) pci_bus_add_device(pdev)\n pci_create_sysfs_dev_files() pci_create_sysfs_dev_files()\n sysfs_create_bin_file() sysfs_create_bin_file()\n -> \"duplicate filename\"\n\nThe same happens on ACPI when probing is asynchronous (hv_pci on\nAzure, RISC-V with ACPI).\n\nThe duplicate causes sysfs_create_bin_file() to fail with -EEXIST.\npci_create_resource_files() then calls pci_remove_resource_files() in\nits error unwind, tearing down files the other thread created and\nstill references through pdev->res_attr[]. This has caused kernel\npanics on i.MX6 and boot failures on other platforms.\n\nSeveral different fixes have been proposed over the years: reordering\nthe sysfs_initialized assignment, adding locks, checking\npci_dev_is_added(), setting pdev->res_attr[] to NULL after kfree\n(which only prevents a double-free on the teardown path, not the\nerror unwind removing the other thread's files). None would address the\nroot cause.\n\nThis has been reported a few times:\n\n - https://lore.kernel.org/linux-pci/20250702155112.40124-1-heshuan@bytedance.com/\n - https://lore.kernel.org/linux-pci/b51519d6-ce45-4b6d-8135-c70169bd110e@h-partners.com/\n - https://lore.kernel.org/linux-pci/1702093576-30405-1-git-send-email-ssengar@linux.microsoft.com/\n - https://lore.kernel.org/linux-pci/SY0P300MB04687548090B73E40AF97D8897B82@SY0P300MB0468.AUSP300.PROD.OUTLOOK.COM/\n - https://lore.kernel.org/linux-pci/20230105174736.GA1154719@bhelgaas/\n - https://lore.kernel.org/linux-pci/m3eebg9puj.fsf@t19.piap.pl/\n - https://lore.kernel.org/linux-pci/20200716110423.xtfyb3n6tn5ixedh@pali/\n - https://lore.kernel.org/linux-pci/1366196798-15929-1-git-send-email-artem.savkov@gmail.com/\n - https://bugzilla.kernel.org/show_bug.cgi?id=215515\n - https://bugzilla.kernel.org/show_bug.cgi?id=216888\n\nWith static attributes the driver model creates sysfs entries once per\ndevice at device_add() time, under the device lock, eliminating the\nlate_initcall iteration and the race along with it.\n\n\tKrzysztof\n\n---\nChanges in v3:\n https://lore.kernel.org/linux-pci/20210910202623.2293708-1-kw@linux.com/\n\n - Updated for modern kernel releases and expanded scope. The\n v2 only covered the generic resource files. This version\n also converts Alpha's sparse/dense resource files and the\n legacy bus attributes, removing pci_sysfs_init() entirely.\n - Split the single macro definition into three distinct ones\n (per I/O, UC, and WC), to make sure that each carries only\n the callbacks its resource type needs.\n - Updated to use the new .bin_size callback, as the attributes\n are const, to replace using a->size directly, which was not\n ideal. This required changes to pci_llseek_resource(), to\n ensure that it would work for device and bus-level attributes.\n - Updated the __resource_resize_store() to include CAP_SYS_ADMIN\n capabilities check.\n - Added the security_locked_down() check to Alpha's\n pci_mmap_resource(), to align with other architectures.\n\nChanges in v2:\n https://lore.kernel.org/linux-pci/20210825212255.878043-1-kw@linux.com/\n\n - Refactored code so that the macros, helpers and internal\n functions can be used to correctly leverage the read(),\n write() and mmap() callbacks rather than to use the\n .is_bin_visible() callback to set up sysfs objects\n internals as this is not supported.\n - Refactored some if-statements to check for a resource\n flag first, and then call either arch_can_pci_mmap_io()\n or arch_can_pci_mmap_wc(), plus store result of testing\n for IORESOURCE_MEM and IORESOURCE_PREFETCH flags into\n a boolean variable, as per Bjorn Helgaas' suggestion.\n - Renamed pci_read_resource_io() and pci_write_resource_io()\n callbacks so that these are not specifically tied to I/O\n BARs read() and write() operations also as per Bjorn\n Helgaas' suggestion.\n - Updated style for code handling bitwise operations to\n match the style that is preferred as per Bjorn Helgaas'\n suggestion.\n - Updated commit messages adding more details about the\n implementation as requested by Bjorn Helgaas.\n\nKrzysztof Wilczyński (20):\n PCI/sysfs: Use PCI resource accessor macros\n PCI/sysfs: Only allow supported resource types in I/O and MMIO helpers\n PCI/sysfs: Use BAR length in pci_llseek_resource() when attr->size is\n zero\n PCI/sysfs: Add CAP_SYS_ADMIN check to __resource_resize_store()\n PCI/sysfs: Add static PCI resource attribute macros\n PCI/sysfs: Convert PCI resource files to static attributes\n PCI/sysfs: Convert __resource_resize_store() to use static attributes\n PCI/sysfs: Add stubs for pci_{create,remove}_sysfs_dev_files()\n PCI/sysfs: Limit pci_sysfs_init() late_initcall compile scope\n alpha/PCI: Add security_locked_down() check to pci_mmap_resource()\n alpha/PCI: Use BAR index in sysfs attr->private instead of resource\n pointer\n alpha/PCI: Use PCI resource accessor macros\n alpha/PCI: Clean up __pci_mmap_fits()\n alpha/PCI: Add static PCI resource attribute macros\n alpha/PCI: Convert resource files to static attributes\n PCI/sysfs: Remove pci_{create,remove}_sysfs_dev_files()\n alpha/PCI: Compute legacy size in pci_mmap_legacy_page_range()\n PCI/sysfs: Add __weak pci_legacy_has_sparse() helper\n PCI/sysfs: Convert legacy I/O and memory attributes to static\n definitions\n PCI/sysfs: Remove pci_create_legacy_files() and pci_sysfs_init()\n\n arch/alpha/include/asm/pci.h | 13 +-\n arch/alpha/kernel/pci-sysfs.c | 369 +++++++++++----------\n arch/powerpc/include/asm/pci.h | 2 -\n drivers/pci/bus.c | 1 -\n drivers/pci/pci-sysfs.c | 575 +++++++++++++++++++--------------\n drivers/pci/pci.h | 16 +-\n drivers/pci/probe.c | 6 -\n drivers/pci/remove.c | 3 -\n include/linux/pci.h | 9 -\n 9 files changed, 545 insertions(+), 449 deletions(-)\n\n--\n2.53.0" }