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: 9170401 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 35E206048F for ; Fri, 10 Jun 2016 19:58:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 26F8928363 for ; Fri, 10 Jun 2016 19:58:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B51928367; Fri, 10 Jun 2016 19:58:55 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9D5AA28363 for ; Fri, 10 Jun 2016 19:58:54 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1bBSYa-00028H-I8; Fri, 10 Jun 2016 19:57:28 +0000 Received: from mail-lf0-x234.google.com ([2a00:1450:4010:c07::234]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1bBSXX-00013C-6Q for linux-arm-kernel@lists.infradead.org; Fri, 10 Jun 2016 19:56:24 +0000 Received: by mail-lf0-x234.google.com with SMTP id q132so14582439lfe.3 for ; Fri, 10 Jun 2016 12:56:02 -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=ZUGYQbAWE1tLeLrrs/ZpgdmHgABeodVqu7A/xJtklULOaDgUraVQyEcbvIxc+by32M JYIE0rulz+pnXp3sNSA4gjbZ5HAkragES0pc/f0R3On/A6vHfE9QOMjreI7auY8S5CqJ RlF201xtiMNMkmZ3MueuBtLTCSjU+jFdj98hj28Y3pcYKMq0ov7blz3mB0O6ZGy4BVEn qj86l5/2VLko4WhnfX/zvRBQI95B4tbdrnVbh27ZqX0Y/OnxlPP2BsgujVC4/9U2cuCQ u8usVlRUPsAjrwMxYdjGHM+u3FeSPn9xANnh0qW3J8wUboGQSKc3wO87PjaNnD5lg359 dnQw== X-Gm-Message-State: ALyK8tJdssaqwepdALkfDjylGiflAHRKC8AmMDEBGDnk632nVfm1YzzjNGFuYFi2EmIb5A== 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160610_125623_543049_E9E69F31 X-CRM114-Status: GOOD ( 15.51 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lorenzo Pieralisi , jcm@redhat.com, linaro-acpi@lists.linaro.org, linux-pci@vger.kernel.org, dhdang@apm.com, Liviu.Dudau@arm.com, ddaney@caviumnetworks.com, jeremy.linton@arm.com, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, robert.richter@caviumnetworks.com, cov@codeaurora.org, Suravee.Suthikulpanit@amd.com, msalter@redhat.com, wangyijing@huawei.com, Tomasz Nowicki , mw@semihalf.com, andrea.gallo@linaro.org, linux-arm-kernel@lists.infradead.org, liudongdong3@huawei.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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