From patchwork Thu Feb 4 17:28:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Nowicki X-Patchwork-Id: 8226581 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 01F3F9F1C0 for ; Thu, 4 Feb 2016 17:40:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A844E20395 for ; Thu, 4 Feb 2016 17:40:33 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 9EEB42015A for ; Thu, 4 Feb 2016 17:40:32 +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 1aRNrg-0000Tg-44; Thu, 04 Feb 2016 17:38:44 +0000 Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aRNiw-0006mJ-J1 for linux-arm-kernel@lists.infradead.org; Thu, 04 Feb 2016 17:29:47 +0000 Received: by mail-wm0-x234.google.com with SMTP id r129so222658750wmr.0 for ; Thu, 04 Feb 2016 09:29:24 -0800 (PST) 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=U6ro4W5nMAN6b1xzAv249ZBPF+ilUYtWZu5gr6h4k9Q=; b=hA57eHujiaySDVFcQgnWxUu2oYRIsCYMrfYhYwp/Q6yD5Rfn/YaTn3wc8X9gOwF0zD /3BMqLEWbahNkJuQDbjVInNH5NAeA+gJ0dIdWw7/R/e9zMfwBxv06dTRMbPTJBanH0Dy oZBcDOVmpeIEwNMSBQJm4sTRe7M6JbDafIPl7AQm6iomUWYa4Yh4JmqBl8QTsKjt5hiJ Hc4KibYnsDD7izvjJdJPhUAREb6qJy7krqaAK6U9MyoJzuJU5/A+jT7OfWvfj5zCg86U zPLvGr2h3RJlsTf1mSLpFa4CRjZ2ZiJlsHxXXtzu7CkYeOT+3LnVd3Jl4oylWoONi94E RJ1g== 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=U6ro4W5nMAN6b1xzAv249ZBPF+ilUYtWZu5gr6h4k9Q=; b=WVqB3X3Eitc2lyGIk554cmtz1qn52kxvONvSsU4BtpKmEYvC7hoK8sXNjsVwG3aJTy d87/5seLthpNZ1C79vgNr+3iQYvjC1fkRoDSAPCcBSq+dttBWt/OiVHalDCWZwykEiS/ PnNTtgODrkWJ8eL6s5PuyNOt/Qtg8hQ97CgokusmImjXklRKoC7nToCZ2PmjTcdRVTla dHKIfgsUFj1dP31a91qX0ZiFy2srhUES7IkBH2UhC2mEAquXW13Hc1buJ7KaDwMLCI4z gi8MpGWX4AYG6xlXjY4MybXGy2lcjWt6gc7jg30sQmE8CR4S1whagFp9Mo/xWowJYvD/ p2dg== X-Gm-Message-State: AG10YOR/ozXZq1GR3peRFJnc0uSYOcm+A12RF3PG+yJQKOGsZbdI+y46M/8Ct5FBTYVcKw== X-Received: by 10.28.47.9 with SMTP id v9mr5525608wmv.69.1454606963492; Thu, 04 Feb 2016 09:29:23 -0800 (PST) Received: from tn-HP-4.semihalf.local (cardhu.semihalf.com. [213.17.239.108]) by smtp.gmail.com with ESMTPSA id w8sm12238889wjx.21.2016.02.04.09.29.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Feb 2016 09:29:22 -0800 (PST) From: Tomasz Nowicki To: bhelgaas@google.com, arnd@arndb.de, will.deacon@arm.com, catalin.marinas@arm.com, rjw@rjwysocki.net, hanjun.guo@linaro.org, Lorenzo.Pieralisi@arm.com, okaya@codeaurora.org, jiang.liu@linux.intel.com, Stefano.Stabellini@eu.citrix.com Subject: [PATCH V4 13/23] pci, acpi: Provide generic way to assign bus domain number. Date: Thu, 4 Feb 2016 18:28:51 +0100 Message-Id: <1454606941-9523-14-git-send-email-tn@semihalf.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1454606941-9523-1-git-send-email-tn@semihalf.com> References: <1454606941-9523-1-git-send-email-tn@semihalf.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160204_092942_974814_C75BDA6C X-CRM114-Status: GOOD ( 15.59 ) X-Spam-Score: -2.6 (--) 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: jchandra@broadcom.com, jcm@redhat.com, linaro-acpi@lists.linaro.org, linux-pci@vger.kernel.org, Liviu.Dudau@arm.com, ddaney@caviumnetworks.com, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, robert.richter@caviumnetworks.com, Suravee.Suthikulpanit@amd.com, msalter@redhat.com, wangyijing@huawei.com, Tomasz Nowicki , mw@semihalf.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As we now have valid PCI host bridge device reference we can introduce code that is going to find its bus domain number using ACPI _SEG method. Note that _SEG method is optional, therefore _SEG absence means that all PCI buses belong to domain 0. While at it, for the sake of code clarity we put ACPI and DT domain assign methods into the corresponding helpers. Signed-off-by: Tomasz Nowicki Reviewed-by: Liviu Dudau Tested-by: Suravee Suthikulpanit Tested-by: Jeremy Linton Tested-by: Duc Dang Tested-by: Dongdong Liu Tested-by: Hanjun Guo Tested-by: Graeme Gregory Tested-by: Sinan Kaya --- drivers/acpi/pci_root.c | 18 ++++++++++++++++++ drivers/pci/pci.c | 11 +++++++++-- include/linux/pci-acpi.h | 2 ++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index a65c8c2..cc2c73a 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c @@ -419,6 +419,24 @@ out: } EXPORT_SYMBOL(acpi_pci_osc_control_set); +int acpi_pci_bus_domain_nr(struct device *parent) +{ + struct acpi_device *acpi_dev = to_acpi_device(parent); + unsigned long long segment = 0; + acpi_status status; + + /* + * If _SEG method does not exist, following ACPI spec (6.5.6) + * all PCI buses belong to domain 0. + */ + status = acpi_evaluate_integer(acpi_dev->handle, METHOD_NAME__SEG, NULL, + &segment); + if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) + dev_err(&acpi_dev->dev, "can't evaluate _SEG\n"); + + return segment; +} + static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm) { u32 support, control, requested; diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 602eb42..d6c768e 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -4769,7 +4770,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 = of_get_pci_domain_nr(parent->of_node); @@ -4811,7 +4812,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(parent); } #endif #endif diff --git a/include/linux/pci-acpi.h b/include/linux/pci-acpi.h index 89ab057..a72e22d 100644 --- a/include/linux/pci-acpi.h +++ b/include/linux/pci-acpi.h @@ -22,6 +22,7 @@ static inline acpi_status pci_acpi_remove_pm_notifier(struct acpi_device *dev) { return acpi_remove_pm_notifier(dev); } +extern int acpi_pci_bus_domain_nr(struct device *parent); extern phys_addr_t acpi_pci_root_get_mcfg_addr(acpi_handle handle); static inline acpi_handle acpi_find_root_bridge_handle(struct pci_dev *pdev) @@ -109,6 +110,7 @@ extern const u8 pci_acpi_dsm_uuid[]; #else /* CONFIG_ACPI */ static inline void acpi_pci_add_bus(struct pci_bus *bus) { } static inline void acpi_pci_remove_bus(struct pci_bus *bus) { } +static inline int acpi_pci_bus_domain_nr(struct device *parent) { return -1; } #endif /* CONFIG_ACPI */ #ifdef CONFIG_ACPI_APEI