From patchwork Mon May 15 13:22:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Pieralisi X-Patchwork-Id: 9726929 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DE96860380 for ; Mon, 15 May 2017 13:21:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D07FF2886A for ; Mon, 15 May 2017 13:21:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C333F2898D; Mon, 15 May 2017 13:21:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B9002886A for ; Mon, 15 May 2017 13:21:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934193AbdEONVO (ORCPT ); Mon, 15 May 2017 09:21:14 -0400 Received: from foss.arm.com ([217.140.101.70]:52468 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934130AbdEONVL (ORCPT ); Mon, 15 May 2017 09:21:11 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 47D0C164F; Mon, 15 May 2017 06:21:11 -0700 (PDT) Received: from red-moon.cambridge.arm.com (red-moon.cambridge.arm.com [10.1.206.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id ADAD13F23B; Mon, 15 May 2017 06:21:09 -0700 (PDT) From: Lorenzo Pieralisi To: linux-pci@vger.kernel.org Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Lorenzo Pieralisi , Bjorn Helgaas , Sergey Temerkhanov , Sinan Kaya , Zhou Wang , Vadim Lomovtsev Subject: [RFC/RFT PATCH v2 3/3] PCI/ACPI: Add ACPI pci_bus_find_numa_node() implementation Date: Mon, 15 May 2017 14:22:05 +0100 Message-Id: <20170515132205.19622-4-lorenzo.pieralisi@arm.com> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20170515132205.19622-1-lorenzo.pieralisi@arm.com> References: <20170515132205.19622-1-lorenzo.pieralisi@arm.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The introduction of pci_bus_find_numa_node(pci_bus) allows at PCI host bridge registration to detect the NUMA node for a given struct pci_bus.dev. Implement an ACPI method that, through the struct pci_bus.bridge ACPI companion, retrieve and return the NUMA node corresponding to a given struct pci_bus.dev. Signed-off-by: Lorenzo Pieralisi Cc: Bjorn Helgaas --- drivers/pci/pci-acpi.c | 20 ++++++++++++++++++++ drivers/pci/pci.c | 2 +- include/linux/pci.h | 6 ++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index 0018603..915da79 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -853,6 +854,25 @@ struct irq_domain *pci_host_bridge_acpi_msi_domain(struct pci_bus *bus) return irq_find_matching_fwnode(fwnode, DOMAIN_BUS_PCI_MSI); } +int acpi_pci_bus_find_numa_node(struct pci_bus *bus) +{ + int node = NUMA_NO_NODE; + struct device *bridge = get_device(bus->bridge); + + if (!bridge) + return node; + + if (has_acpi_companion(bridge)) { + struct acpi_device *adev = to_acpi_device_node(bridge->fwnode); + + node = acpi_get_node(adev->handle); + } + + put_device(bridge); + + return node; +} + static int __init acpi_pci_init(void) { int ret; diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index e9803c1..451342d 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -5406,7 +5406,7 @@ int pci_bus_find_domain_nr(struct pci_bus *bus, struct device *parent) int pci_bus_find_numa_node(struct pci_bus *bus) { - return NUMA_NO_NODE; + return acpi_disabled ? NUMA_NO_NODE : acpi_pci_bus_find_numa_node(bus); } /** diff --git a/include/linux/pci.h b/include/linux/pci.h index ccbeefd..ed89220 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1472,6 +1472,12 @@ static inline int acpi_pci_bus_find_domain_nr(struct pci_bus *bus) #endif int pci_bus_find_domain_nr(struct pci_bus *bus, struct device *parent); #endif +#ifdef CONFIG_ACPI +int acpi_pci_bus_find_numa_node(struct pci_bus *bus); +#else +static inline int acpi_pci_bus_find_numa_node(struct pci_bus *bus) +{ return NUMA_NO_NODE; } +#endif int pci_bus_find_numa_node(struct pci_bus *bus); /* some architectures require additional setup to direct VGA traffic */