From patchwork Mon May 30 15:14:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Nowicki X-Patchwork-Id: 9141673 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 361AC60777 for ; Mon, 30 May 2016 15:17:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2742028222 for ; Mon, 30 May 2016 15:17:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B94F28224; Mon, 30 May 2016 15:17:57 +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 9D23528222 for ; Mon, 30 May 2016 15:17:56 +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 1b7Ovh-0002uf-Jw; Mon, 30 May 2016 15:16:33 +0000 Received: from mail-lf0-x22c.google.com ([2a00:1450:4010:c07::22c]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1b7Oue-00026Y-9r for linux-arm-kernel@lists.infradead.org; Mon, 30 May 2016 15:15:29 +0000 Received: by mail-lf0-x22c.google.com with SMTP id w16so61778366lfd.2 for ; Mon, 30 May 2016 08:15:07 -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=8NnXVrYh20LQEyb9JNIDeNSOHz7ejfJRr710I1hBtfE=; b=JXiv4AMG/tI93jvDFpxbpRuvHgthBr/tHxMlvPTSQ939K39A98tAT1WuB7SEjUBqGA mS5PJuQo8E03yMPIpID0AaK2ZRvJeJ7Dp+Mg6cX7BjUTJT5jJRgKPFbCvbKznzbiIjNW oSuhyhmCys+UbSXbYddVD7gLBG/dd0n0J2ZVmSnvr25BP5vaSOuC3KFiVEyUGRJoYSMb WRbMYo5zTeTGT5Gz9yox1dDRzig2GwxvQ034GydJ2gXgzFGK8V/5WIVko6vcCybR11su QU4/WGscqE8sPCle+dzQ0z3Ei5nAnnU9/tLabj9h5mcEhBtXsqudoUY0YABNMpmWEJ7H U9Mg== 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=8NnXVrYh20LQEyb9JNIDeNSOHz7ejfJRr710I1hBtfE=; b=QfJv+IP2pH8SY3/1Wt2t9a3fZQy8MbNGmyfDMsxCP9Anm+bHDTDfFUokmh1EMHnV+r +wJDxhD3XyQqlAt0K/nbngjcVdaU3LIZvLXaIG/Cw6JL5dGOUnrQggNM8eBrKxRWKZnJ rBNTul2FoOAsXUv1AHGVf7ZSMijojXlEiDLpSFjCpI9XD2TxqSBXgrPc0VGzYfUshYTH 8H1HPryrsEttHlTAEFw9d/FEuh1fSye1yK6u+xFkrCOtYFLw7JjbckYL2GlFKQpouZXJ lTHRCwlIUVYMu1de9Rx2YD+FUzTCRcUFwpgiuCK4QP7j3NP1wxsC9oGVZcaUSUsgs/b+ 5FlQ== X-Gm-Message-State: ALyK8tJjbAqrkdrmJSSTDzPUS7Jm4hE3LqZ8mf8uPeLAlyceXtnADE3a2N8VdHU4YM2EZQ== X-Received: by 10.25.142.196 with SMTP id q187mr1605866lfd.11.1464621306254; Mon, 30 May 2016 08:15:06 -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 n13sm1392264lfb.33.2016.05.30.08.15.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 30 May 2016 08:15:05 -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 V8 5/9] pci, acpi: add acpi hook to assign domain number. Date: Mon, 30 May 2016 17:14:18 +0200 Message-Id: <1464621262-26770-6-git-send-email-tn@semihalf.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1464621262-26770-1-git-send-email-tn@semihalf.com> References: <1464621262-26770-1-git-send-email-tn@semihalf.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160530_081528_702156_C594D99E X-CRM114-Status: GOOD ( 16.92 ) 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, this patch introduces a dummy acpi_pci_bus_domain_nr() hook in preparation for per-arch implementation of the same to retrieve the domain number on a per-arch basis when the system boots through ACPI. For the sake of code clarity the current code implementing generic domain number assignment (ie pci_bus_assign_domain_nr(), selected by CONFIG_PCI_DOMAINS_GENERIC) is reshuffled so that the code implementing the DT domain assignment function is stubbed out into a corresponding helper, so that DT and ACPI functions are clearly separated in preparation for arches acpi_pci_bus_domain_nr() implementations. Signed-off-by: Tomasz Nowicki Signed-off-by: Lorenzo Pieralisi --- drivers/pci/pci.c | 11 +++++++++-- include/linux/pci.h | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index eb431b5..2b52178 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -7,6 +7,7 @@ * Copyright 1997 -- 2000 Martin Mares */ +#include #include #include #include @@ -4941,7 +4942,7 @@ int pci_get_new_domain_nr(void) } #ifdef CONFIG_PCI_DOMAINS_GENERIC -void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent) +static int of_pci_bus_domain_nr(struct device *parent) { static int use_dt_domains = -1; int domain = -1; @@ -4985,7 +4986,13 @@ void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent) domain = -1; } - bus->domain_nr = domain; + return domain; +} + +void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent) +{ + bus->domain_nr = acpi_disabled ? of_pci_bus_domain_nr(parent) : + acpi_pci_bus_domain_nr(bus); } #endif #endif diff --git a/include/linux/pci.h b/include/linux/pci.h index 12349de..bba4053 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1390,6 +1390,7 @@ static inline int pci_domain_nr(struct pci_bus *bus) { return bus->domain_nr; } +static inline int acpi_pci_bus_domain_nr(struct pci_bus *bus) { return -1; } void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent); #else static inline void pci_bus_assign_domain_nr(struct pci_bus *bus,