get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/1.2/patches/2234789/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2234789,
    "url": "http://patchwork.ozlabs.org/api/1.2/patches/2234789/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/linux-pci/patch/20260508043543.217179-8-kwilczynski@kernel.org/",
    "project": {
        "id": 28,
        "url": "http://patchwork.ozlabs.org/api/1.2/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,
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20260508043543.217179-8-kwilczynski@kernel.org>",
    "list_archive_url": null,
    "date": "2026-05-08T04:35:26",
    "name": "[v7,07/24] PCI/sysfs: Convert PCI resource files to static attributes",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "e0de93a7f3e09f6c70d30da06737ddcedd58a691",
    "submitter": {
        "id": 86709,
        "url": "http://patchwork.ozlabs.org/api/1.2/people/86709/?format=api",
        "name": "Krzysztof Wilczyński",
        "email": "kwilczynski@kernel.org"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/linux-pci/patch/20260508043543.217179-8-kwilczynski@kernel.org/mbox/",
    "series": [
        {
            "id": 503321,
            "url": "http://patchwork.ozlabs.org/api/1.2/series/503321/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/linux-pci/list/?series=503321",
            "date": "2026-05-08T04:35:19",
            "name": "PCI: Convert all dynamic sysfs attributes to static",
            "version": 7,
            "mbox": "http://patchwork.ozlabs.org/series/503321/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2234789/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2234789/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "\n <linux-pci+bounces-54200-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=CxeVAKrr;\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-54200-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=\"CxeVAKrr\"",
            "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)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4gBbst6f62z1yJq\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 08 May 2026 14:36:18 +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 73E453021719\n\tfor <incoming@patchwork.ozlabs.org>; Fri,  8 May 2026 04:36:15 +0000 (UTC)",
            "from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id BFCFA258CD7;\n\tFri,  8 May 2026 04:36:14 +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 9BE9A2F8EAC;\n\tFri,  8 May 2026 04:36:14 +0000 (UTC)",
            "by smtp.kernel.org (Postfix) with ESMTPSA id F3BE2C2BCF4;\n\tFri,  8 May 2026 04:36:10 +0000 (UTC)"
        ],
        "ARC-Seal": "i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1778214974; cv=none;\n b=kwODe1GYmJRo7RF04iOcu2J1ikwTZ+Vdcb0v7aeiElnW023cnRTjR9c39G+GSO+Q6hJ1Y9Vk35N64wHZVezNAd2SPc6XH5CYnVbE0QJ1Jog0njbaygIK2Ezx+iq27zqeMfTIH0xmmb93ESfQtwYkhNABjcgP2I/N0YrfMYTT2oc=",
        "ARC-Message-Signature": "i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1778214974; c=relaxed/simple;\n\tbh=u34HA8GUgFv6zCZeg3IzRMrDFX+zMF+zCeHli3MppuE=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version:Content-Type;\n b=Zc0IDh94YFoYYJeA2V9DNFZCjfOSXZtBr5y2oAL4+yvUg3fE5MCeTcGr1x7lqF0qmEjjN8wCwPujkZ6mzznFnH6Gme1QC5/K//QhOnFJo+r9rVFqhKdbnCpbw/vZgrXogLbiQoB/PzcvC5G0PJ/RbPREw0IY3I2C0skvOJCVN4M=",
        "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=CxeVAKrr; 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=1778214974;\n\tbh=u34HA8GUgFv6zCZeg3IzRMrDFX+zMF+zCeHli3MppuE=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=CxeVAKrrq/lM9ruipiJ4KIU/pCPt4YVAFsBBwkogyBteYdqXfQQTS5Vt3eorOh3Lu\n\t sKNR2mHjhl5uGsPchUHaRkPwj4cqIwkMHtnUsztQQo/s7+AGNTTZ/IEL6j9uh24EeD\n\t yxM0WShYi94VSUt8gwpnwfvUuAoQhDKHyqOxevWBRlUmJBteMIfz68VsMoQKMnVNFm\n\t r2sN/popRPheq6ZV9I1iokIllL8QwO2HvxM9WwA2D84TnG+4qoeFFl9DBvx1igv1Hs\n\t +HBHjYf8uajT5TfVTcm44yr6wsP9Ypa7/tsOWd6iwms2wXjeVvB38tav4WzolqHqSC\n\t dKA7dWbWUaEFw==",
        "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 Alex Williamson <alex@shazbot.org>, Magnus Lindholm <linmag7@gmail.com>,\n 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 v7 07/24] PCI/sysfs: Convert PCI resource files to static\n attributes",
        "Date": "Fri,  8 May 2026 04:35:26 +0000",
        "Message-ID": "<20260508043543.217179-8-kwilczynski@kernel.org>",
        "X-Mailer": "git-send-email 2.54.0",
        "In-Reply-To": "<20260508043543.217179-1-kwilczynski@kernel.org>",
        "References": "<20260508043543.217179-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=UTF-8",
        "Content-Transfer-Encoding": "8bit"
    },
    "content": "Currently, the PCI resource files (resourceN, resourceN_wc) are\ndynamically created by pci_create_sysfs_dev_files(), called from\nboth pci_bus_add_device() and the pci_sysfs_init() late_initcall,\nwith only a sysfs_initialized flag for synchronisation.  This has\ncaused \"duplicate filename\" warnings and boot panics when both\npaths race on the same device.\n\nThis is especially likely on Devicetree-based platforms, where the\nPCI host controllers are platform drivers that probe via the driver\nmodel, which can happen during or after the late_initcall.  As such,\npci_bus_add_device() and pci_sysfs_init() are more likely to overlap.\n\nThus, convert to static const attributes with three attribute groups\n(I/O, UC, WC), each with an .is_bin_visible callback that checks\nresource flags, BAR length, and non_mappable_bars.  A .bin_size\ncallback provides pci_resource_len() to the kernfs node for correct\nstat and lseek behaviour.\n\nAs part of this conversion:\n\n  - Rename pci_read_resource_io() and pci_write_resource_io() to\n    pci_read_resource() and pci_write_resource() since the callbacks\n    are no longer I/O-specific in the static attribute context.\n\n  - Update __resource_resize_store() to use sysfs_create_groups() and\n    sysfs_remove_groups(), which re-evaluates visibility and runs the\n    .bin_size callback for the static resource attribute groups.\n\n  - Remove pci_create_resource_files(), pci_remove_resource_files(),\n    and pci_create_attr() which are no longer needed.\n\n  - Move the __weak stubs outside the #if guard so they remain\n    available for callers converted in subsequent commits.\n\nPlatforms that do not define the HAVE_PCI_MMAP macro or the\nARCH_GENERIC_PCI_MMAP_RESOURCE macro, such as Alpha architecture,\ncontinue using their platform-specific resource file creation.\n\nFor reference, the dynamic creation dates back to the pre-Git era:\n\n  https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git/commit/drivers/pci/pci-sysfs.c?id=42298be0eeb5ae98453b3374c36161b05a46c5dc\n\nThe write-combine support was added in commit 45aec1ae72fc (\"x86: PAT\nexport resource_wc in pci sysfs\").\n\nTested-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>\nSigned-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>\n---\n drivers/pci/pci-sysfs.c | 285 +++++++++++++++++++++-------------------\n include/linux/pci.h     |   2 -\n 2 files changed, 152 insertions(+), 135 deletions(-)",
    "diff": "diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c\nindex d50b8fe1498c..0fa126d46e35 100644\n--- a/drivers/pci/pci-sysfs.c\n+++ b/drivers/pci/pci-sysfs.c\n@@ -890,19 +890,6 @@ pci_llseek_resource_legacy(struct file *filep,\n \treturn fixed_size_llseek(filep, offset, whence, attr->size);\n }\n \n-static __maybe_unused loff_t\n-pci_llseek_resource(struct file *filep,\n-\t\t    struct kobject *kobj,\n-\t\t    const struct bin_attribute *attr,\n-\t\t    loff_t offset, int whence)\n-{\n-\tstruct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));\n-\tint bar = (unsigned long)attr->private;\n-\n-\treturn fixed_size_llseek(filep, offset, whence,\n-\t\t\t\t pci_resource_len(pdev, bar));\n-}\n-\n #ifdef HAVE_PCI_LEGACY\n /**\n  * pci_read_legacy_io - read byte(s) from legacy I/O port space\n@@ -1177,14 +1164,14 @@ static ssize_t pci_resource_io(struct file *filp, struct kobject *kobj,\n #endif\n }\n \n-static ssize_t pci_read_resource_io(struct file *filp, struct kobject *kobj,\n+static ssize_t pci_read_resource(struct file *filp, struct kobject *kobj,\n \t\t\t\t    const struct bin_attribute *attr, char *buf,\n \t\t\t\t    loff_t off, size_t count)\n {\n \treturn pci_resource_io(filp, kobj, attr, buf, off, count, false);\n }\n \n-static ssize_t pci_write_resource_io(struct file *filp, struct kobject *kobj,\n+static ssize_t pci_write_resource(struct file *filp, struct kobject *kobj,\n \t\t\t\t     const struct bin_attribute *attr, char *buf,\n \t\t\t\t     loff_t off, size_t count)\n {\n@@ -1197,6 +1184,18 @@ static ssize_t pci_write_resource_io(struct file *filp, struct kobject *kobj,\n \treturn pci_resource_io(filp, kobj, attr, buf, off, count, true);\n }\n \n+static loff_t pci_llseek_resource(struct file *filep,\n+\t\t\t\t  struct kobject *kobj,\n+\t\t\t\t  const struct bin_attribute *attr,\n+\t\t\t\t  loff_t offset, int whence)\n+{\n+\tstruct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));\n+\tint bar = (unsigned long)attr->private;\n+\n+\treturn fixed_size_llseek(filep, offset, whence,\n+\t\t\t\t pci_resource_len(pdev, bar));\n+}\n+\n /*\n  * generic_file_llseek() consults f_mapping->host to determine\n  * the file size. As iomem_inode knows nothing about the\n@@ -1215,8 +1214,8 @@ static ssize_t pci_write_resource_io(struct file *filp, struct kobject *kobj,\n static const struct bin_attribute dev_resource##_bar##_io_attr = {\t\\\n \t.attr = { .name = \"resource\" __stringify(_bar), .mode = 0600 },\t\\\n \t.private = (void *)(unsigned long)(_bar),\t\t\t\\\n-\t.read = pci_read_resource_io,\t\t\t\t\t\\\n-\t.write = pci_write_resource_io,\t\t\t\t\t\\\n+\t.read = pci_read_resource,\t\t\t\t\t\\\n+\t.write = pci_write_resource,\t\t\t\t\t\\\n \t__PCI_RESOURCE_IO_MMAP_ATTRS\t\t\t\t\t\\\n }\n \n@@ -1238,129 +1237,144 @@ static const struct bin_attribute dev_resource##_bar##_wc_attr = {\t\t\\\n \t.mmap = pci_mmap_resource_wc,\t\t\t\t\t\t\\\n }\n \n-/**\n- * pci_remove_resource_files - cleanup resource files\n- * @pdev: dev to cleanup\n- *\n- * If we created resource files for @pdev, remove them from sysfs and\n- * free their resources.\n- */\n-static void pci_remove_resource_files(struct pci_dev *pdev)\n+static inline umode_t\n+__pci_resource_attr_is_visible(struct kobject *kobj,\n+\t\t\t       const struct bin_attribute *a,\n+\t\t\t       int bar, bool write_combine,\n+\t\t\t       unsigned long flags)\n {\n-\tint i;\n+\tstruct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));\n \n-\tfor (i = 0; i < PCI_STD_NUM_BARS; i++) {\n-\t\tstruct bin_attribute *res_attr;\n-\n-\t\tres_attr = pdev->res_attr[i];\n-\t\tif (res_attr) {\n-\t\t\tsysfs_remove_bin_file(&pdev->dev.kobj, res_attr);\n-\t\t\tkfree(res_attr);\n-\t\t}\n-\n-\t\tres_attr = pdev->res_attr_wc[i];\n-\t\tif (res_attr) {\n-\t\t\tsysfs_remove_bin_file(&pdev->dev.kobj, res_attr);\n-\t\t\tkfree(res_attr);\n-\t\t}\n-\t}\n-}\n-\n-static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)\n-{\n-\t/* allocate attribute structure, piggyback attribute name */\n-\tint name_len = write_combine ? 13 : 10;\n-\tstruct bin_attribute *res_attr;\n-\tchar *res_attr_name;\n-\tint retval;\n-\n-\tres_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);\n-\tif (!res_attr)\n-\t\treturn -ENOMEM;\n-\n-\tres_attr_name = (char *)(res_attr + 1);\n-\n-\tsysfs_bin_attr_init(res_attr);\n-\tif (write_combine) {\n-\t\tsprintf(res_attr_name, \"resource%d_wc\", num);\n-\t\tres_attr->mmap = pci_mmap_resource_wc;\n-\t} else {\n-\t\tsprintf(res_attr_name, \"resource%d\", num);\n-\t\tif (pci_resource_flags(pdev, num) & IORESOURCE_IO) {\n-\t\t\tres_attr->read = pci_read_resource_io;\n-\t\t\tres_attr->write = pci_write_resource_io;\n-\t\t\tif (arch_can_pci_mmap_io())\n-\t\t\t\tres_attr->mmap = pci_mmap_resource_uc;\n-\t\t} else {\n-\t\t\tres_attr->mmap = pci_mmap_resource_uc;\n-\t\t}\n-\t}\n-\tif (res_attr->mmap) {\n-\t\tres_attr->f_mapping = iomem_get_mapping;\n-\t\t/*\n-\t\t * generic_file_llseek() consults f_mapping->host to determine\n-\t\t * the file size. As iomem_inode knows nothing about the\n-\t\t * attribute, it's not going to work, so override it as well.\n-\t\t */\n-\t\tres_attr->llseek = pci_llseek_resource;\n-\t}\n-\tres_attr->attr.name = res_attr_name;\n-\tres_attr->attr.mode = 0600;\n-\tres_attr->size = pci_resource_len(pdev, num);\n-\tres_attr->private = (void *)(unsigned long)num;\n-\tretval = sysfs_create_bin_file(&pdev->dev.kobj, res_attr);\n-\tif (retval) {\n-\t\tkfree(res_attr);\n-\t\treturn retval;\n-\t}\n-\n-\tif (write_combine)\n-\t\tpdev->res_attr_wc[num] = res_attr;\n-\telse\n-\t\tpdev->res_attr[num] = res_attr;\n-\n-\treturn 0;\n-}\n-\n-/**\n- * pci_create_resource_files - create resource files in sysfs for @dev\n- * @pdev: dev in question\n- *\n- * Walk the resources in @pdev creating files for each resource available.\n- */\n-static int pci_create_resource_files(struct pci_dev *pdev)\n-{\n-\tint i;\n-\tint retval;\n-\n-\t/* Skip devices with non-mappable BARs */\n \tif (pdev->non_mappable_bars)\n \t\treturn 0;\n \n-\t/* Expose the PCI resources from this device as files */\n-\tfor (i = 0; i < PCI_STD_NUM_BARS; i++) {\n+\tif (!pci_resource_len(pdev, bar))\n+\t\treturn 0;\n \n-\t\t/* skip empty resources */\n-\t\tif (!pci_resource_len(pdev, i))\n-\t\t\tcontinue;\n+\tif ((pci_resource_flags(pdev, bar) & flags) != flags)\n+\t\treturn 0;\n \n-\t\tretval = pci_create_attr(pdev, i, 0);\n-\t\t/* for prefetchable resources, create a WC mappable file */\n-\t\tif (!retval && arch_can_pci_mmap_wc() &&\n-\t\t    pci_resource_flags(pdev, i) & IORESOURCE_PREFETCH)\n-\t\t\tretval = pci_create_attr(pdev, i, 1);\n-\t\tif (retval) {\n-\t\t\tpci_remove_resource_files(pdev);\n-\t\t\treturn retval;\n-\t\t}\n-\t}\n-\treturn 0;\n+\tif (write_combine && !arch_can_pci_mmap_wc())\n+\t\treturn 0;\n+\n+\treturn a->attr.mode;\n }\n-#else /* !(defined(HAVE_PCI_MMAP) || defined(ARCH_GENERIC_PCI_MMAP_RESOURCE)) */\n-int __weak pci_create_resource_files(struct pci_dev *dev) { return 0; }\n-void __weak pci_remove_resource_files(struct pci_dev *dev) { return; }\n+\n+static umode_t pci_dev_resource_io_is_visible(struct kobject *kobj,\n+\t\t\t\t\t      const struct bin_attribute *a,\n+\t\t\t\t\t      int n)\n+{\n+\treturn __pci_resource_attr_is_visible(kobj, a, n, false,\n+\t\t\t\t\t      IORESOURCE_IO);\n+}\n+\n+static umode_t pci_dev_resource_uc_is_visible(struct kobject *kobj,\n+\t\t\t\t\t      const struct bin_attribute *a,\n+\t\t\t\t\t      int n)\n+{\n+\treturn __pci_resource_attr_is_visible(kobj, a, n, false,\n+\t\t\t\t\t      IORESOURCE_MEM);\n+}\n+\n+static umode_t pci_dev_resource_wc_is_visible(struct kobject *kobj,\n+\t\t\t\t\t      const struct bin_attribute *a,\n+\t\t\t\t\t      int n)\n+{\n+\treturn __pci_resource_attr_is_visible(kobj, a, n, true,\n+\t\t\t\t\t      IORESOURCE_MEM | IORESOURCE_PREFETCH);\n+}\n+\n+static size_t pci_dev_resource_bin_size(struct kobject *kobj,\n+\t\t\t\t\tconst struct bin_attribute *a,\n+\t\t\t\t\tint n)\n+{\n+\tstruct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));\n+\n+\treturn pci_resource_len(pdev, n);\n+}\n+\n+pci_dev_resource_io_attr(0);\n+pci_dev_resource_io_attr(1);\n+pci_dev_resource_io_attr(2);\n+pci_dev_resource_io_attr(3);\n+pci_dev_resource_io_attr(4);\n+pci_dev_resource_io_attr(5);\n+\n+pci_dev_resource_uc_attr(0);\n+pci_dev_resource_uc_attr(1);\n+pci_dev_resource_uc_attr(2);\n+pci_dev_resource_uc_attr(3);\n+pci_dev_resource_uc_attr(4);\n+pci_dev_resource_uc_attr(5);\n+\n+pci_dev_resource_wc_attr(0);\n+pci_dev_resource_wc_attr(1);\n+pci_dev_resource_wc_attr(2);\n+pci_dev_resource_wc_attr(3);\n+pci_dev_resource_wc_attr(4);\n+pci_dev_resource_wc_attr(5);\n+\n+static const struct bin_attribute *const pci_dev_resource_io_attrs[] = {\n+\t&dev_resource0_io_attr,\n+\t&dev_resource1_io_attr,\n+\t&dev_resource2_io_attr,\n+\t&dev_resource3_io_attr,\n+\t&dev_resource4_io_attr,\n+\t&dev_resource5_io_attr,\n+\tNULL,\n+};\n+\n+static const struct bin_attribute *const pci_dev_resource_uc_attrs[] = {\n+\t&dev_resource0_uc_attr,\n+\t&dev_resource1_uc_attr,\n+\t&dev_resource2_uc_attr,\n+\t&dev_resource3_uc_attr,\n+\t&dev_resource4_uc_attr,\n+\t&dev_resource5_uc_attr,\n+\tNULL,\n+};\n+\n+static const struct bin_attribute *const pci_dev_resource_wc_attrs[] = {\n+\t&dev_resource0_wc_attr,\n+\t&dev_resource1_wc_attr,\n+\t&dev_resource2_wc_attr,\n+\t&dev_resource3_wc_attr,\n+\t&dev_resource4_wc_attr,\n+\t&dev_resource5_wc_attr,\n+\tNULL,\n+};\n+\n+static const struct attribute_group pci_dev_resource_io_attr_group = {\n+\t.bin_attrs = pci_dev_resource_io_attrs,\n+\t.is_bin_visible = pci_dev_resource_io_is_visible,\n+\t.bin_size = pci_dev_resource_bin_size,\n+};\n+\n+static const struct attribute_group pci_dev_resource_uc_attr_group = {\n+\t.bin_attrs = pci_dev_resource_uc_attrs,\n+\t.is_bin_visible = pci_dev_resource_uc_is_visible,\n+\t.bin_size = pci_dev_resource_bin_size,\n+};\n+\n+static const struct attribute_group pci_dev_resource_wc_attr_group = {\n+\t.bin_attrs = pci_dev_resource_wc_attrs,\n+\t.is_bin_visible = pci_dev_resource_wc_is_visible,\n+\t.bin_size = pci_dev_resource_bin_size,\n+};\n+\n+static const struct attribute_group *pci_dev_resource_attr_groups[] = {\n+\t&pci_dev_resource_io_attr_group,\n+\t&pci_dev_resource_uc_attr_group,\n+\t&pci_dev_resource_wc_attr_group,\n+\tNULL,\n+};\n+#else\n+#define pci_dev_resource_attr_groups NULL\n #endif\n \n+int __weak pci_create_resource_files(struct pci_dev *dev) { return 0; }\n+void __weak pci_remove_resource_files(struct pci_dev *dev) { }\n+\n /**\n  * pci_write_rom - used to enable access to the PCI ROM display\n  * @filp: sysfs file\n@@ -1662,14 +1676,14 @@ static ssize_t __resource_resize_store(struct device *dev, int n,\n \tpci_write_config_word(pdev, PCI_COMMAND,\n \t\t\t      cmd & ~PCI_COMMAND_MEMORY);\n \n-\tpci_remove_resource_files(pdev);\n+\tsysfs_remove_groups(&pdev->dev.kobj, pci_dev_resource_attr_groups);\n \n \tret = pci_resize_resource(pdev, n, size, 0);\n \n \tpci_assign_unassigned_bus_resources(bus);\n \n-\tif (pci_create_resource_files(pdev))\n-\t\tpci_warn(pdev, \"Failed to recreate resource files after BAR resizing\\n\");\n+\tif (sysfs_create_groups(&pdev->dev.kobj, pci_dev_resource_attr_groups))\n+\t\tpci_warn(pdev, \"Failed to recreate resource groups after BAR resizing\\n\");\n \n \tpci_write_config_word(pdev, PCI_COMMAND, cmd);\n pm_put:\n@@ -1838,6 +1852,11 @@ static const struct attribute_group pci_dev_group = {\n \n const struct attribute_group *pci_dev_groups[] = {\n \t&pci_dev_group,\n+#if defined(HAVE_PCI_MMAP) || defined(ARCH_GENERIC_PCI_MMAP_RESOURCE)\n+\t&pci_dev_resource_io_attr_group,\n+\t&pci_dev_resource_uc_attr_group,\n+\t&pci_dev_resource_wc_attr_group,\n+#endif\n \t&pci_dev_config_attr_group,\n \t&pci_dev_rom_attr_group,\n \t&pci_dev_reset_attr_group,\ndiff --git a/include/linux/pci.h b/include/linux/pci.h\nindex e93fbe6b57fe..974605c9fce2 100644\n--- a/include/linux/pci.h\n+++ b/include/linux/pci.h\n@@ -2531,10 +2531,8 @@ int pcibios_alloc_irq(struct pci_dev *dev);\n void pcibios_free_irq(struct pci_dev *dev);\n resource_size_t pcibios_default_alignment(void);\n \n-#if !defined(HAVE_PCI_MMAP) && !defined(ARCH_GENERIC_PCI_MMAP_RESOURCE)\n extern int pci_create_resource_files(struct pci_dev *dev);\n extern void pci_remove_resource_files(struct pci_dev *dev);\n-#endif\n \n #if defined(CONFIG_PCI_MMCONFIG) || defined(CONFIG_ACPI_MCFG)\n void __init pci_mmcfg_early_init(void);\n",
    "prefixes": [
        "v7",
        "07/24"
    ]
}