[{"id":3676681,"web_url":"http://patchwork.ozlabs.org/comment/3676681/","msgid":"<36cdf28b-281f-46c7-d4b5-083675b61660@linux.intel.com>","date":"2026-04-13T11:51:47","subject":"Re: [PATCH v4 12/24] alpha/PCI: Use BAR index in sysfs attr->private\n instead of resource pointer","submitter":{"id":83553,"url":"http://patchwork.ozlabs.org/api/people/83553/","name":"Ilpo Järvinen","email":"ilpo.jarvinen@linux.intel.com"},"content":"On Sat, 11 Apr 2026, Krzysztof Wilczyński wrote:\n\n> Currently, Alpha's pci_create_one_attr() stores a resource pointer in\n> attr->private, and pci_mmap_resource() loops through all BARs to find\n> the matching index.\n> \n> Thus, store the BAR index directly in attr->private and retrieve the\n> resource via pci_resource_n().  This eliminates the loop and aligns\n> with the convention used by the generic PCI sysfs code.\n> \n> While at it, add parentheses around the bitwise flag test in\n> pci_mmap_resource() to make the precedence explicit, and to\n> match the preferred style.\n\nProbably not necessary to touch this line now at all as you're going to \nreplace it two patches later anyway so it just adds noise.\n\nReviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>\n\n> The PCI core change was first added in the commit dca40b186b75 (\"PCI:\n> Use BAR index in sysfs attr->private instead of resource pointer\").\n> \n> Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>\n> ---\n>  arch/alpha/kernel/pci-sysfs.c | 17 ++++++-----------\n>  1 file changed, 6 insertions(+), 11 deletions(-)\n> \n> diff --git a/arch/alpha/kernel/pci-sysfs.c b/arch/alpha/kernel/pci-sysfs.c\n> index 2324720c3e83..c84867ce31f5 100644\n> --- a/arch/alpha/kernel/pci-sysfs.c\n> +++ b/arch/alpha/kernel/pci-sysfs.c\n> @@ -69,25 +69,20 @@ static int pci_mmap_resource(struct kobject *kobj,\n>  \t\t\t     struct vm_area_struct *vma, int sparse)\n>  {\n>  \tstruct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));\n> -\tstruct resource *res = attr->private;\n> +\tint barno = (unsigned long)attr->private;\n> +\tstruct resource *res = pci_resource_n(pdev, barno);\n>  \tenum pci_mmap_state mmap_type;\n>  \tstruct pci_bus_region bar;\n> -\tint i, ret;\n> +\tint ret;\n>  \n>  \tret = security_locked_down(LOCKDOWN_PCI_ACCESS);\n>  \tif (ret)\n>  \t\treturn ret;\n>  \n> -\tfor (i = 0; i < PCI_STD_NUM_BARS; i++)\n> -\t\tif (res == &pdev->resource[i])\n> -\t\t\tbreak;\n> -\tif (i >= PCI_STD_NUM_BARS)\n> -\t\treturn -ENODEV;\n> -\n> -\tif (res->flags & IORESOURCE_MEM && iomem_is_exclusive(res->start))\n> +\tif ((res->flags & IORESOURCE_MEM) && iomem_is_exclusive(res->start))\n>  \t\treturn -EINVAL;\n>  \n> -\tif (!__pci_mmap_fits(pdev, i, vma, sparse))\n> +\tif (!__pci_mmap_fits(pdev, barno, vma, sparse))\n>  \t\treturn -EINVAL;\n>  \n>  \tpcibios_resource_to_bus(pdev->bus, &bar, res);\n> @@ -170,7 +165,7 @@ static int pci_create_one_attr(struct pci_dev *pdev, int num, char *name,\n>  \tres_attr->attr.name = name;\n>  \tres_attr->attr.mode = S_IRUSR | S_IWUSR;\n>  \tres_attr->size = sparse ? size << 5 : size;\n> -\tres_attr->private = &pdev->resource[num];\n> +\tres_attr->private = (void *)(unsigned long)num;\n>  \treturn sysfs_create_bin_file(&pdev->dev.kobj, res_attr);\n>  }\n>  \n>","headers":{"Return-Path":"\n <linuxppc-dev+bounces-19685-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=intel.com header.i=@intel.com header.a=rsa-sha256\n header.s=Intel header.b=NoV4IGcG;\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-19685-incoming=patchwork.ozlabs.org@lists.ozlabs.org;\n receiver=patchwork.ozlabs.org)","lists.ozlabs.org;\n arc=none smtp.remote-ip=192.198.163.13","lists.ozlabs.org;\n dmarc=pass (p=none dis=none) header.from=linux.intel.com","lists.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256\n header.s=Intel header.b=NoV4IGcG;\n\tdkim-atps=neutral","lists.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=linux.intel.com\n (client-ip=192.198.163.13; helo=mgamail.intel.com;\n envelope-from=ilpo.jarvinen@linux.intel.com; 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 4fvQkF4Zdzz1yDF\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 13 Apr 2026 21:52:04 +1000 (AEST)","from boromir.ozlabs.org (localhost [127.0.0.1])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 4fvQkD12zRz2yjV;\n\tMon, 13 Apr 2026 21:52:04 +1000 (AEST)","from mgamail.intel.com (mgamail.intel.com [192.198.163.13])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 4fvQkB2kQ6z2yDk\n\tfor <linuxppc-dev@lists.ozlabs.org>; Mon, 13 Apr 2026 21:52:01 +1000 (AEST)","from orviesa004.jf.intel.com ([10.64.159.144])\n  by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 13 Apr 2026 04:51:58 -0700","from ijarvine-mobl1.ger.corp.intel.com (HELO localhost)\n ([10.245.245.63])\n  by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 13 Apr 2026 04:51:50 -0700"],"ARC-Seal":"i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1776081124;\n\tcv=none;\n b=dTKDDQYrLUFGo4e/KBSpdyoC3wPim4RdPn6yeNsDtBEPPygwXkOGDdgkbHiXDWSIj57e3ala/f9oUcZFEe0Smutv2YDBuUJ/H9+rSW4f/6GXZlcFFSX9Tus5Hd6mYLjnhv+rmgSx8sg/FvnPyPwhR6z5+604YaHMTIa3KtciZkpPf1O1HgdgqNru/jszJYi1cIEJto4zqVi54DWwpKEvoZzpNaRRhiklwumKEkt4CIg/pH6bLMhJJOB/MnjM60fO8nzuaY+w5c1TGN3Tnlt5BkKbjvftrAbiDsxvsqXu+geiC42XOajwKOmIMPbGtk+bmmmddByn6cz0FeTUrVTLCQ==","ARC-Message-Signature":"i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707;\n\tt=1776081124; c=relaxed/relaxed;\n\tbh=nuI2OunpgjM6LQJd2UoZSd3r4wK8ScZ0JLSA7ncgcu0=;\n\th=From:Date:To:cc:Subject:In-Reply-To:Message-ID:References:\n\t MIME-Version:Content-Type;\n b=MbJOBT614/j7yqoQePHazTGZcDpT/FUulf58y80MIkmSF2+6ZVrgVEta3uKgyMQbj3NvYtTOOIwmrM2g6+2NJIsPKl3X8AZJhRDayo5NmRpj61y7UvtB6DxobZ4Yg07msqVFiLQ5rACrMp+nyxT+3ygtzvsH9n8MzWODJFKNwbdygxdB2BJpMG4zGHBshn/KBX0JW9zGb6QWQw1TNHpWu5XtICnh6j2AjJsorCLntIwXCeiG38W/vMMpNZzGteSsPm2D/E2XhMxUqOdRtrTku6vExF1+GaK1TWPG+aHibOHMcAoPrNma/nEvXqCfVImg7ntsucGAIAYwmvtbFzl/Nw==","ARC-Authentication-Results":"i=1; lists.ozlabs.org;\n dmarc=pass (p=none dis=none) header.from=linux.intel.com;\n dkim=pass (2048-bit key;\n unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256\n header.s=Intel header.b=NoV4IGcG; dkim-atps=neutral;\n spf=pass (client-ip=192.198.163.13; helo=mgamail.intel.com;\n envelope-from=ilpo.jarvinen@linux.intel.com;\n receiver=lists.ozlabs.org) smtp.mailfrom=linux.intel.com","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple;\n  d=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n  t=1776081123; x=1807617123;\n  h=from:date:to:cc:subject:in-reply-to:message-id:\n   references:mime-version;\n  bh=fpOAaZKfotFu8HPdtyLtTcGQEsJqFpCbjJlbK0uwLl4=;\n  b=NoV4IGcGfwAjXSeJz9yFjdrLXVd59Hs3zA1sG7xakyH7ZXEbYbGE+kq+\n   MWfGBn7TqhnlcdxziSAbaB6OTFkPPRqk16Dk04mK2SrFgupCFsFQb1h4p\n   IlGV+MB5M9q2GHoCOa/4NVtNWLprmU7GkQKj3/FZlZIBqr50Km3SHZB0V\n   GO+L0QE9LFetPhRaq6EHiBvEMRc+h2VYfrbD1D9Lon/AXk/dGP9igNL8u\n   72wbevRPb1K2aFbMcNQGcE2It3m1//y0pm6pUsGYquQGzQcKR+O8YOHP/\n   xRhCP9RY1zUct29XDKkgZ+3RPsDixSzpHFvIJeiQUwhohj6v07bbTIzQy\n   A==;","X-CSE-ConnectionGUID":["q2ePwg/ATiiF9Jv1fLaU9Q==","i/Lq7BnxRFiQWIqqO/VyQw=="],"X-CSE-MsgGUID":["IGfgdbvcRbKI53nyGIkK0w==","lhiRzlaYThGfHhcJw4GQnw=="],"X-IronPort-AV":["E=McAfee;i=\"6800,10657,11757\"; a=\"79594851\"","E=Sophos;i=\"6.23,177,1770624000\";\n   d=\"scan'208\";a=\"79594851\"","E=Sophos;i=\"6.23,177,1770624000\";\n   d=\"scan'208\";a=\"234182329\""],"X-ExtLoop1":"1","From":"=?utf-8?q?Ilpo_J=C3=A4rvinen?= <ilpo.jarvinen@linux.intel.com>","Date":"Mon, 13 Apr 2026 14:51:47 +0300 (EEST)","To":"=?iso-8859-2?q?Krzysztof_Wilczy=F1ski?= <kwilczynski@kernel.org>","cc":"Bjorn Helgaas <bhelgaas@google.com>, 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 =?iso-8859-2?q?Krzysztof_Ha=B3asa?= <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>,\n  Srivatsa Bhat <srivatsabhat@microsoft.com>, linux-pci@vger.kernel.org,\n  linux-alpha@vger.kernel.org, linuxppc-dev@lists.ozlabs.org","Subject":"Re: [PATCH v4 12/24] alpha/PCI: Use BAR index in sysfs attr->private\n instead of resource pointer","In-Reply-To":"<20260411080148.471335-13-kwilczynski@kernel.org>","Message-ID":"<36cdf28b-281f-46c7-d4b5-083675b61660@linux.intel.com>","References":"<20260411080148.471335-1-kwilczynski@kernel.org>\n <20260411080148.471335-13-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":"multipart/mixed; boundary=\"8323328-1179895439-1776081107=:962\"","X-Spam-Status":"No, score=-2.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED,\n\tDKIM_VALID,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=disabled\n\tversion=4.0.1 OzLabs 8","X-Spam-Checker-Version":"SpamAssassin 4.0.1 (2024-03-25) on lists.ozlabs.org"}}]