{"id":2226602,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2226602/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-pci/patch/20260422161407.118748-5-kwilczynski@kernel.org/","project":{"id":28,"url":"http://patchwork.ozlabs.org/api/1.1/projects/28/?format=json","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":"<20260422161407.118748-5-kwilczynski@kernel.org>","date":"2026-04-22T16:13:47","name":"[v6,04/24] PCI/sysfs: Use BAR length in pci_llseek_resource() when attr->size is zero","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"1910392f6627cf5a11bf392d9c1d701ac8cc5710","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/linux-pci/patch/20260422161407.118748-5-kwilczynski@kernel.org/mbox/","series":[{"id":501041,"url":"http://patchwork.ozlabs.org/api/1.1/series/501041/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-pci/list/?series=501041","date":"2026-04-22T16:13:46","name":"PCI: Convert all dynamic sysfs attributes to static","version":6,"mbox":"http://patchwork.ozlabs.org/series/501041/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2226602/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2226602/checks/","tags":{},"headers":{"Return-Path":"\n <linux-pci+bounces-52990-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=oZmYMt3v;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.234.253.10; helo=sea.lore.kernel.org;\n envelope-from=linux-pci+bounces-52990-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=\"oZmYMt3v\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])\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 4g14G01rBjz1yCv\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 23 Apr 2026 02:20:40 +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 4D59E3055D77\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 16:14:27 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 8120E3603E8;\n\tWed, 22 Apr 2026 16:14:26 +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 5DC59325495;\n\tWed, 22 Apr 2026 16:14:26 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id C8425C19425;\n\tWed, 22 Apr 2026 16:14:22 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776874466; cv=none;\n b=Xiz/x0DGrb6wEO1prb6yLvqniuzWXRUkY+ZXKlheAkwJvJ76DFUZ2H3EsieSxrkMo7D61TIbE2v5JbK4laM1183b6izq+n/8RIikI7v2PlkC9B0EPcVokOm3DGrUJmsuW/nAmhvZwDyWO5tKyU24olOEYUZ1RGMRi5rRQh+0YMQ=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776874466; c=relaxed/simple;\n\tbh=GioqcjyAYkzeNaoaWV/yTLAqCcEigQz8/u7cr2rMnc8=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version:Content-Type;\n b=MyyH7HFuhGyfzsDc+eUSlPXWd1rUAaxdFsGYhjozd1lGnQs84NBOS56ljrrOKrB8gzUXeidOCmG5USm6FoswZfpI9z/69uNW+JCxTGsJGBcf9PWlpfBGiO5lAawqbxojnAR5er75Y2C00j29XtWOPCRItWyNLtN/F8YIg+Z2Tnc=","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=oZmYMt3v; 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=1776874465;\n\tbh=GioqcjyAYkzeNaoaWV/yTLAqCcEigQz8/u7cr2rMnc8=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=oZmYMt3vSkz56Z8rLpH+K90dmXwn4BUAeWHGiJ3ndH9Y4yMhWvUGb+dlqqmuv2Mr0\n\t 9PgI21cgFqzb+orUd5x7KUqBuAFX6vnVlqWob3bKuNa0hXlzfsVm+dOmQ0TJa/ohG/\n\t s56wRDye0/px4B0LpXxk9LnKOP6ichgChl4igX/XjycyIxfCPKeynyVf22UOhugUmM\n\t WLtaz5Yxzu4tsjV0z+TdTwwnHc0eHgj86rPbDuMxacRAIkrRzQgaZ6mENEbQf9YAPk\n\t XQnWfjdaZwucRFoHTGHMJdgmH4Fg5jpmv8iScWI1UJkfEA5hFShfmk1SIWZ6s12Y08\n\t bwjJJknO5ptcg==","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 v6 04/24] PCI/sysfs: Use BAR length in pci_llseek_resource()\n when attr->size is zero","Date":"Wed, 22 Apr 2026 16:13:47 +0000","Message-ID":"<20260422161407.118748-5-kwilczynski@kernel.org>","X-Mailer":"git-send-email 2.54.0","In-Reply-To":"<20260422161407.118748-1-kwilczynski@kernel.org>","References":"<20260422161407.118748-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":"Both legacy and resource attributes set .f_mapping = iomem_get_mapping,\nso the default generic_file_llseek() would consult iomem_inode for the\nfile size, which knows nothing about the attribute.  That is why this\ncustom llseek callback exists.\n\nCurrently, the legacy and resource attributes have .size set at creation\ntime, as such, using the attr->size is sufficient.  However, the upcoming\nstatic resource attributes will have .size == 0 set, since they are const,\nand the .bin_size callback will be used to provide the real size to kernfs\ninstead.\n\nThus, update pci_llseek_resource() to derive the file size from the\nBAR using pci_resource_len() instead of reading the attr->size directly.\n\nThe custom pci_llseek_resource() helper has been added in commit\n24de09c16f97 (\"PCI: Implement custom llseek for sysfs resource\nentries\").\n\nSigned-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>\n---\n drivers/pci/pci-sysfs.c | 14 ++++++++++++--\n 1 file changed, 12 insertions(+), 2 deletions(-)","diff":"diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c\nindex 6783c6168445..73a9ae9d289b 100644\n--- a/drivers/pci/pci-sysfs.c\n+++ b/drivers/pci/pci-sysfs.c\n@@ -909,11 +909,21 @@ static const struct attribute_group pci_dev_config_attr_group = {\n  */\n static __maybe_unused loff_t\n pci_llseek_resource(struct file *filep,\n-\t\t    struct kobject *kobj __always_unused,\n+\t\t    struct kobject *kobj,\n \t\t    const struct bin_attribute *attr,\n \t\t    loff_t offset, int whence)\n {\n-\treturn fixed_size_llseek(filep, offset, whence, attr->size);\n+\tstruct pci_dev *pdev;\n+\tint bar;\n+\n+\tif (attr->size)\n+\t\treturn fixed_size_llseek(filep, offset, whence, attr->size);\n+\n+\tpdev = to_pci_dev(kobj_to_dev(kobj));\n+\tbar = (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","prefixes":["v6","04/24"]}