From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C4192F8D761 for ; Thu, 16 Apr 2026 18:02:49 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4fxQnd3vNBz3bfR; Fri, 17 Apr 2026 04:01:57 +1000 (AEST) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip="2600:3c04:e001:324:0:1991:8:25" ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1776362517; cv=none; b=Oyv46f0gZlF1Qtnk0Jblejh7Xqq+Rc1MaC+Prh3ZhoSf2ItpR1s0yXuZJKQEbAiQRlPqIyVc8l5ypxFrYtOvww9F2vlKO+7aHV/L3KD1Gf4NR7HuIeWIDNwd4znvBlNf+dwtuzxptKWB1CcBTpNte35qtPjbB80rqBbKI0h5dNsmg1CWZJLH2TkZnlqTgu5J0AS4OJBpY3qHns8v/dL0NDyaxDq94Ox3qsmKNPZtW3GVeUU7qIs8g7oz4gkOnEAdiKJgwPMBtxsYpu243ABx5LPlRXhSvqNwpuWxQvDiSfRV7da5zlwoygyB7TfpaaqC0b1uVlhilCN+mxqcmRSBVQ== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1776362517; c=relaxed/relaxed; bh=OvKsssP7HnqkEINU2UUP0w3ze1Gas3fbifEGwTWs8o4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GuGn2TEZgPF/LbKWN3bBsDOqooni3EgZMdK1aSRkbUSo2aDry4fpEBeMdpOL0fYAfbMThg8ZUrN4QEt5lxXCko5BIrRzunVr/TtJaxXYx8rk2PVp2WUYEpc1Xl+arHJALlxmi0AEJlFI+G2BO8ZQlPy8EeuGtyFgrbMXHjLVFkpsMexVuh6L9vH4Op+M/Bh5Gh62n5hv/jJO0rQUZjUSjttKOesCeZ3amE9VibnB8+E5TVRmfpjKa7d3bgEh+tDVeQWQxlXVGok7V05XJewnwGPuCmA7C0idWHwEWnFuBhotsC/SOwcgiaj3ss2RiN7zzq2AQWHcIfaVErIPkC2KbQ== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=OiGTWIqp; dkim-atps=neutral; spf=pass (client-ip=2600:3c04:e001:324:0:1991:8:25; helo=tor.source.kernel.org; envelope-from=kwilczynski@kernel.org; receiver=lists.ozlabs.org) smtp.mailfrom=kernel.org Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=OiGTWIqp; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=2600:3c04:e001:324:0:1991:8:25; helo=tor.source.kernel.org; envelope-from=kwilczynski@kernel.org; receiver=lists.ozlabs.org) Received: from tor.source.kernel.org (tor.source.kernel.org [IPv6:2600:3c04:e001:324:0:1991:8:25]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4fxQnc4j7pz3bfV for ; Fri, 17 Apr 2026 04:01:56 +1000 (AEST) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 8BDB460127; Thu, 16 Apr 2026 18:01:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17CB5C2BCB5; Thu, 16 Apr 2026 18:01:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776362514; bh=LSXfSjgBz15fSxwbvqqVboBWJc4CbgupbkaWY3yx6kA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OiGTWIqpmv4YGnWuufZIAg9U6Mv3LXjBtSjahu2SURo0/CKF7KTFO1fzqBRV1muaM WEm/ZZZDlGzSivb66L9p0h/cU4SVd/le0juBJhskNSGPxhe7yLWQTdweFqSuajcIl1 HDwLhSOXK2CJsAyMYvb+X9CJ5yzMLkUt7dPmhE9um67LS2KOffaArsYp+cFLt1t0h6 Sn26D9YUYUOpOfxmuQp4YoobCYPeJIl6Iq3LUvUVy8cwVk4NHSFpgbWLU6PnCwfHcX qsW6tiii16rqzpUz8zXPbxC73G7J56SDc76vcM3JK/loOeeD5qgpMTl7ixb7PjcUSr d36CWK6ktDTKg== From: =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= To: Bjorn Helgaas Cc: Bjorn Helgaas , Manivannan Sadhasivam , Lorenzo Pieralisi , Magnus Lindholm , Matt Turner , Richard Henderson , Christophe Leroy , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Dexuan Cui , =?UTF-8?q?Krzysztof=20Ha=C5=82asa?= , Lukas Wunner , "Oliver O'Halloran" , Saurabh Singh Sengar , Shuan He , Srivatsa Bhat , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , linux-pci@vger.kernel.org, linux-alpha@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH v5 12/23] alpha/PCI: Use BAR index in sysfs attr->private instead of resource pointer Date: Thu, 16 Apr 2026 18:00:56 +0000 Message-ID: <20260416180107.777065-13-kwilczynski@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260416180107.777065-1-kwilczynski@kernel.org> References: <20260416180107.777065-1-kwilczynski@kernel.org> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, Alpha's pci_create_one_attr() stores a resource pointer in attr->private, and pci_mmap_resource() loops through all BARs to find the matching index. Thus, store the BAR index directly in attr->private and retrieve the resource via pci_resource_n(). This eliminates the loop and aligns with the convention used by the generic PCI sysfs code. The PCI core change was first added in the commit dca40b186b75 ("PCI: Use BAR index in sysfs attr->private instead of resource pointer"). Tested-by: Magnus Lindholm Reviewed-by: Ilpo Järvinen Acked-by: Magnus Lindholm Signed-off-by: Krzysztof Wilczyński --- arch/alpha/kernel/pci-sysfs.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/arch/alpha/kernel/pci-sysfs.c b/arch/alpha/kernel/pci-sysfs.c index 2324720c3e83..2330ab84d59c 100644 --- a/arch/alpha/kernel/pci-sysfs.c +++ b/arch/alpha/kernel/pci-sysfs.c @@ -69,25 +69,20 @@ static int pci_mmap_resource(struct kobject *kobj, struct vm_area_struct *vma, int sparse) { struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj)); - struct resource *res = attr->private; + int barno = (unsigned long)attr->private; + struct resource *res = pci_resource_n(pdev, barno); enum pci_mmap_state mmap_type; struct pci_bus_region bar; - int i, ret; + int ret; ret = security_locked_down(LOCKDOWN_PCI_ACCESS); if (ret) return ret; - for (i = 0; i < PCI_STD_NUM_BARS; i++) - if (res == &pdev->resource[i]) - break; - if (i >= PCI_STD_NUM_BARS) - return -ENODEV; - if (res->flags & IORESOURCE_MEM && iomem_is_exclusive(res->start)) return -EINVAL; - if (!__pci_mmap_fits(pdev, i, vma, sparse)) + if (!__pci_mmap_fits(pdev, barno, vma, sparse)) return -EINVAL; pcibios_resource_to_bus(pdev->bus, &bar, res); @@ -170,7 +165,7 @@ static int pci_create_one_attr(struct pci_dev *pdev, int num, char *name, res_attr->attr.name = name; res_attr->attr.mode = S_IRUSR | S_IWUSR; res_attr->size = sparse ? size << 5 : size; - res_attr->private = &pdev->resource[num]; + res_attr->private = (void *)(unsigned long)num; return sysfs_create_bin_file(&pdev->dev.kobj, res_attr); } -- 2.53.0