From patchwork Fri Jun 10 19:55:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Nowicki X-Patchwork-Id: 9170337 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 399A060890 for ; Fri, 10 Jun 2016 19:56:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 288DB2833F for ; Fri, 10 Jun 2016 19:56:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1D2BB28325; Fri, 10 Jun 2016 19:56:30 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham 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 7591C2833F for ; Fri, 10 Jun 2016 19:56:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753259AbcFJT4R (ORCPT ); Fri, 10 Jun 2016 15:56:17 -0400 Received: from mail-lf0-f47.google.com ([209.85.215.47]:34457 "EHLO mail-lf0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753228AbcFJT4N (ORCPT ); Fri, 10 Jun 2016 15:56:13 -0400 Received: by mail-lf0-f47.google.com with SMTP id j7so28543166lfg.1 for ; Fri, 10 Jun 2016 12:56:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BPtZJW6VuNpFVslGRRGd7h94tZR9hXTK5wR3tRiJbDk=; b=rJFVHAkKiN4krRJLDPOOdfMN8WdCZ8K1JkdhdUEUyd8s5iJIKjH9k63l6PDp92XZ69 riOwOhg2NAl/z2PoIpBRvW6mPeE2l86Rx/eMGtrS2mZsDqdVxIJ6MliyIUsnkeW/OgnH 7b5Jt1oUGR/nBhU+GEecW6MSH3XAbL06j2T7efrRnLmOiUXRUVc9Pk6DUJWwDMg4H6DJ nCYeFVqbZ3S3OST3lEtW3KpS/7UqVcBCHBWH05xItlOjSuyGDSV4w5tS8CiEu76conJ6 R6AKsRifTWrE4KSgecVGRk+pLpvIACwhXhhryWddEPiV0+GDydQFvSEGCTmn/pUOXIKO G9uA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BPtZJW6VuNpFVslGRRGd7h94tZR9hXTK5wR3tRiJbDk=; b=X5K2bH5KekBGGFkwqOFZgQexrn8/Q2D4JQ+fJGo9hu/PQycL2XAbgFL/bvJQt/Z4lL g3hnZnPpKzl9i9Mw5WKsfKzacBM5AlU60+KOb1EfmuVNIwUJS0s9A3Kus+0XopYV7F6W W5EpkP5f/REmq9hqG/kkQ4u9buTyVMIJGqa9C3PKx6wO4gEWFmHiTJPJgDbG3YSNLxhT zdfj1amchzRsAzN+gJTYThwmAI48miqlGRKhseB6PUeYfPV2vP97BlPxI2833C7qXWtY 1ivIZWfcsGMT1I4qhcmJBGt6wTpO3wSPlNXVjxzmkwVmBwu8D60lCtC3ykr2PbSnTJfy /8Ww== X-Gm-Message-State: ALyK8tKQUaABa7OAoRbPMV/zpp0NzFHMsYjGUlfNxY5x/+nQa1fEeUEOF4aBi5u2ZtxIYg== X-Received: by 10.25.146.208 with SMTP id u199mr893522lfd.222.1465588561352; Fri, 10 Jun 2016 12:56:01 -0700 (PDT) Received: from tn-HP-4.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id a190sm1377175lfe.21.2016.06.10.12.55.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 10 Jun 2016 12:56:00 -0700 (PDT) From: Tomasz Nowicki To: helgaas@kernel.org, arnd@arndb.de, will.deacon@arm.com, catalin.marinas@arm.com, rafael@kernel.org, hanjun.guo@linaro.org, Lorenzo.Pieralisi@arm.com, okaya@codeaurora.org, jchandra@broadcom.com Cc: robert.richter@caviumnetworks.com, mw@semihalf.com, Liviu.Dudau@arm.com, ddaney@caviumnetworks.com, wangyijing@huawei.com, Suravee.Suthikulpanit@amd.com, msalter@redhat.com, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linaro-acpi@lists.linaro.org, jcm@redhat.com, andrea.gallo@linaro.org, dhdang@apm.com, jeremy.linton@arm.com, liudongdong3@huawei.com, cov@codeaurora.org, Tomasz Nowicki , Lorenzo Pieralisi Subject: [PATCH V9 08/11] ARM64/PCI: Add ACPI hook to assign domain number Date: Fri, 10 Jun 2016 21:55:16 +0200 Message-Id: <1465588519-11334-9-git-send-email-tn@semihalf.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1465588519-11334-1-git-send-email-tn@semihalf.com> References: <1465588519-11334-1-git-send-email-tn@semihalf.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 PCI core code provides a config option (CONFIG_PCI_DOMAINS_GENERIC) that allows assigning the PCI bus domain number generically by relying on device tree bindings, and falling back to a simple counter when the respective DT properties (ie "linux,pci-domain") are not specified in the host bridge device tree node. In a similar way, when a system is booted through ACPI, architectures that are selecting CONFIG_PCI_DOMAINS_GENERIC (ie ARM64) require kernel hooks to retrieve the domain number so that the PCI bus domain number set-up can be handled seamlessly with DT and ACPI in generic core code when CONFIG_PCI_DOMAINS_GENERIC is selected. Since currently it is not possible to retrieve a pointer to the PCI host bridge ACPI device backing the host bridge from core PCI code (which would allow retrieving the domain number in an arch agnostic way through the ACPI _SEG method), an arch specific ACPI hook has to be declared and implemented by all arches that rely on CONFIG_PCI_DOMAINS_GENERIC to retrieve the domain number and set it up in core PCI code. For the aforementioned reasons, introduce acpi_pci_bus_find_domain_nr() hook to retrieve the domain number on a per-arch basis when the system boots through ACPI. ARM64 dummy implementation of the same is provided in first place in preparation for ARM64 ACPI based PCI host controller driver. acpi_pci_bus_find_domain_nr() is called from generic pci_bus_find_domain_nr() as an ACPI option to DT domain assignment. Signed-off-by: Tomasz Nowicki Signed-off-by: Lorenzo Pieralisi --- arch/arm64/kernel/pci.c | 7 +++++++ drivers/pci/pci.c | 4 +++- include/linux/pci.h | 7 +++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c index 3c4e308..d5d3d26 100644 --- a/arch/arm64/kernel/pci.c +++ b/arch/arm64/kernel/pci.c @@ -17,6 +17,7 @@ #include #include #include +#include #include /* @@ -85,6 +86,12 @@ EXPORT_SYMBOL(pcibus_to_node); #endif #ifdef CONFIG_ACPI + +int acpi_pci_bus_find_domain_nr(struct pci_bus *bus) +{ + return 0; +} + /* Root bridge scanning */ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) { diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 327828d..4834cee 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -7,6 +7,7 @@ * Copyright 1997 -- 2000 Martin Mares */ +#include #include #include #include @@ -4990,7 +4991,8 @@ static int of_pci_bus_find_domain_nr(struct device *parent) int pci_bus_find_domain_nr(struct pci_bus *bus, struct device *parent) { - return of_pci_bus_find_domain_nr(parent) ; + return acpi_disabled ? of_pci_bus_find_domain_nr(parent) : + acpi_pci_bus_find_domain_nr(bus); } #endif #endif diff --git a/include/linux/pci.h b/include/linux/pci.h index 48839e8..49ba8af 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1390,6 +1390,13 @@ static inline int pci_domain_nr(struct pci_bus *bus) { return bus->domain_nr; } +/* Arch specific ACPI hook to set-up domain number */ +#ifdef CONFIG_ACPI +int acpi_pci_bus_find_domain_nr(struct pci_bus *bus); +#else +static inline int acpi_pci_bus_find_domain_nr(struct pci_bus *bus) +{ return 0; } +#endif int pci_bus_find_domain_nr(struct pci_bus *bus, struct device *parent); #endif