{"id":2221710,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2221710/?format=json","web_url":"http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20260410055040.39233-7-kwilczynski@kernel.org/","project":{"id":2,"url":"http://patchwork.ozlabs.org/api/1.1/projects/2/?format=json","name":"Linux PPC development","link_name":"linuxppc-dev","list_id":"linuxppc-dev.lists.ozlabs.org","list_email":"linuxppc-dev@lists.ozlabs.org","web_url":"https://github.com/linuxppc/wiki/wiki","scm_url":"https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git","webscm_url":"https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/"},"msgid":"<20260410055040.39233-7-kwilczynski@kernel.org>","date":"2026-04-10T05:50:26","name":"[06/20] PCI/sysfs: Convert PCI resource files to static attributes","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"21d2dd3fb86629dd5fb02dcfa0154efb54662018","submitter":{"id":86709,"url":"http://patchwork.ozlabs.org/api/1.1/people/86709/?format=json","name":"Krzysztof Wilczyński","email":"kwilczynski@kernel.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20260410055040.39233-7-kwilczynski@kernel.org/mbox/","series":[{"id":499413,"url":"http://patchwork.ozlabs.org/api/1.1/series/499413/?format=json","web_url":"http://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=499413","date":"2026-04-10T05:50:20","name":"PCI: Convert all dynamic sysfs attributes to static","version":1,"mbox":"http://patchwork.ozlabs.org/series/499413/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2221710/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2221710/checks/","tags":{},"headers":{"Return-Path":"\n <linuxppc-dev+bounces-19539-incoming=patchwork.ozlabs.org@lists.ozlabs.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linuxppc-dev@lists.ozlabs.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=UEym+wkK;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org\n (client-ip=2404:9400:21b9:f100::1; helo=lists.ozlabs.org;\n envelope-from=linuxppc-dev+bounces-19539-incoming=patchwork.ozlabs.org@lists.ozlabs.org;\n receiver=patchwork.ozlabs.org)","lists.ozlabs.org;\n arc=none smtp.remote-ip=\"2600:3c0a:e001:78e:0:1991:8:25\"","lists.ozlabs.org;\n dmarc=pass (p=quarantine dis=none) header.from=kernel.org","lists.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=UEym+wkK;\n\tdkim-atps=neutral","lists.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org\n (client-ip=2600:3c0a:e001:78e:0:1991:8:25; helo=sea.source.kernel.org;\n envelope-from=kwilczynski@kernel.org; receiver=lists.ozlabs.org)"],"Received":["from lists.ozlabs.org (lists.ozlabs.org\n [IPv6:2404:9400:21b9:f100::1])\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 4fsSj83W4wz1y2d\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 10 Apr 2026 17:14:20 +1000 (AEST)","from boromir.ozlabs.org (localhost [127.0.0.1])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 4fsSj808b7z2ymg;\n\tFri, 10 Apr 2026 17:14:20 +1000 (AEST)","from sea.source.kernel.org (sea.source.kernel.org\n [IPv6:2600:3c0a:e001:78e:0:1991:8:25])\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 lists.ozlabs.org (Postfix) with ESMTPS id 4fsQs81bqRz2yRl\n\tfor <linuxppc-dev@lists.ozlabs.org>; Fri, 10 Apr 2026 15:51:08 +1000 (AEST)","from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58])\n\tby sea.source.kernel.org (Postfix) with ESMTP id A8B8043E28;\n\tFri, 10 Apr 2026 05:51:06 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id DBCD8C2BCAF;\n\tFri, 10 Apr 2026 05:51:02 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1775800269;\n\tcv=none;\n b=Ybe91rQ2aPH0yopOlERgHSU4aCmy349Cp4f0auuuFNgU5kcJ6mgHb7SiXj6sCt8TgOSQeYuZ4L3+CCuLrGwrXliXHr95dfBP2FSnnlsgmBejYROc5UsE9mGNK3RAFJkS5pf/QODr9wV8R0Lr8JyKFntxl0GxHc66/D5jD9OZn4Ytmznbl3p/gRTVFo7r54p9lfQPvlw0iQ2IijTOvX1dICp4Xsg0aCUJdWf1hwMXFK+sQZbrUHStnl4jUJu4yL9zaJnVIt5eonJiG0BXAoDXL3jlisvN1+lexI2pdeAWYFFM671p2StMlzwFD6L1ALibhIAZkcjOZ5l8VmA91NCEcA==","ARC-Message-Signature":"i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707;\n\tt=1775800269; c=relaxed/relaxed;\n\tbh=7yuFROen8Mh93k48NdFogMOj9+O8qxySLeCynEm+GjM=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version:Content-Type;\n b=HRzARQnWCOe8SjmNM08gCmYqx78l6VLveP1PkY/LzbxphCeksdxsmHTqJj2bzlk1AQjRB/H8mFH4DDieXRaRfYfIKsHxM7yjVL1D64r2LuLvIBYcT4U99iqmzeaBGNnbAcGCrfy2xZH0pqFviEtlSnAe6La8z4yRS9aY9LzhPES1VFqGPbcsho4nDW2b82q0z2wiACsVJCpFw4y/NtPKqMA0W/mLpZ24iQPTTGk3I34LNLVdWtP+m6ZuHiNAKiu/DPl7Jr5Y8HJvzNV/r71HX3/cG1yzx0UKNuQ80mqWZIiSkaMxIazOTdkoh5jm1fsJ8O/E2m3g7T/MVH2DV46VOQ==","ARC-Authentication-Results":"i=1; lists.ozlabs.org;\n dmarc=pass (p=quarantine dis=none) header.from=kernel.org;\n dkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=UEym+wkK; dkim-atps=neutral;\n spf=pass (client-ip=2600:3c0a:e001:78e:0:1991:8:25;\n helo=sea.source.kernel.org; envelope-from=kwilczynski@kernel.org;\n receiver=lists.ozlabs.org) smtp.mailfrom=kernel.org","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1775800266;\n\tbh=RX84AOGhnQdH9CGDmJbIPMB5gZIx1iAxD/szIytsyBQ=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=UEym+wkKOuwAcNoXVrfDiGaCBVZ2+pWzzawijRvVzHqsuRH2UaBKfp4SPsh6ag29/\n\t 2WnefhdZBk9GdStGxSpCDmEmcuU1C6hAI1VZrd70K1csKfvkXCJOmMvOGvG+0Nwske\n\t 1TV3gyn5mp4wVojjWNZ/d7AZcALOomO+tdxY+CkgyFc3vMr14uvLBGdmVKQi50402I\n\t ou7QClqLTT3Q0wg7rmRQ7kmnYRVNItShnPmGUWkB8Ve27W5XZxYirALzzRAoOR3lMW\n\t qmSuiPcR3aTC46a4QeE1TLLKu5N3chYbHBp0/a04RryOcqchBEtFtwEdcgHkBH9jiQ\n\t xSb1CFBi8XdUQ==","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 06/20] PCI/sysfs: Convert PCI resource files to static\n attributes","Date":"Fri, 10 Apr 2026 05:50:26 +0000","Message-ID":"<20260410055040.39233-7-kwilczynski@kernel.org>","X-Mailer":"git-send-email 2.53.0","In-Reply-To":"<20260410055040.39233-1-kwilczynski@kernel.org>","References":"<20260410055040.39233-1-kwilczynski@kernel.org>","X-Mailing-List":"linuxppc-dev@lists.ozlabs.org","List-Id":"<linuxppc-dev.lists.ozlabs.org>","List-Help":"<mailto:linuxppc-dev+help@lists.ozlabs.org>","List-Owner":"<mailto:linuxppc-dev+owner@lists.ozlabs.org>","List-Post":"<mailto:linuxppc-dev@lists.ozlabs.org>","List-Archive":"<https://lore.kernel.org/linuxppc-dev/>,\n  <https://lists.ozlabs.org/pipermail/linuxppc-dev/>","List-Subscribe":"<mailto:linuxppc-dev+subscribe@lists.ozlabs.org>,\n  <mailto:linuxppc-dev+subscribe-digest@lists.ozlabs.org>,\n  <mailto:linuxppc-dev+subscribe-nomail@lists.ozlabs.org>","List-Unsubscribe":"<mailto:linuxppc-dev+unsubscribe@lists.ozlabs.org>","Precedence":"list","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","X-Spam-Status":"No, score=-0.2 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED,\n\tDKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS\n\tautolearn=disabled version=4.0.1 OzLabs 8","X-Spam-Checker-Version":"SpamAssassin 4.0.1 (2024-03-25) on lists.ozlabs.org"},"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  - 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\nSigned-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>\n---\n drivers/pci/pci-sysfs.c | 242 +++++++++++++++++++++-------------------\n include/linux/pci.h     |   2 -\n 2 files changed, 127 insertions(+), 117 deletions(-)","diff":"diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c\nindex d29d79be8ee5..e56fddbe7914 100644\n--- a/drivers/pci/pci-sysfs.c\n+++ b/drivers/pci/pci-sysfs.c\n@@ -1200,14 +1200,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@@ -1261,129 +1261,136 @@ 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 #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@@ -1861,6 +1868,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 1c270f1d5123..a7a104427b07 100644\n--- a/include/linux/pci.h\n+++ b/include/linux/pci.h\n@@ -2501,10 +2501,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":["06/20"]}