From patchwork Tue Feb 16 13:53:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Nowicki X-Patchwork-Id: 8326141 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 50098C02AA for ; Tue, 16 Feb 2016 13:58:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 48E012027D for ; Tue, 16 Feb 2016 13:58:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 20B6720268 for ; Tue, 16 Feb 2016 13:58:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932624AbcBPN5U (ORCPT ); Tue, 16 Feb 2016 08:57:20 -0500 Received: from mail-wm0-f41.google.com ([74.125.82.41]:37734 "EHLO mail-wm0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932572AbcBPNyI (ORCPT ); Tue, 16 Feb 2016 08:54:08 -0500 Received: by mail-wm0-f41.google.com with SMTP id g62so153827110wme.0 for ; Tue, 16 Feb 2016 05:54:07 -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=L4To2Rnwbzt+D9ecbys/+fuwvW823Zko+s1qNjGMj7U=; b=viIHPIrgJiU8+eCx5Vrbxc2RXOotoNf1iWZzV+9kHB7V9vEAjApN4ik71l6A62wbG8 byFD1JULfa7CfVlMlE6qEc/S1fDtsiKqiI98KVvFH2puVhmH/H/BmDTYAMVLzsljqsVW rsfppLUUST5LPehVq6msiAJNxG0kXEg2w3I3tbcoswOOhtj/8jyMzUFyZg0m2hpy8bgl zxyfJtM6Ngy9Jj1TBOPh40mfgasUOB49Q1E6ybD7gtJbvPRGVeH5xiYzqEJTfGgzMJyk aWvdEaHOwik3FdKp+VbtOVmcZtAHoJ/uqXt9dEhM8pYfgyFLjN5GRr5JMHOQhwgZC2Bi JHyg== 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=L4To2Rnwbzt+D9ecbys/+fuwvW823Zko+s1qNjGMj7U=; b=XVFeDQcVZtqf4ODxPIEyCJV409Q9DNdF7hPQog3vPRt2rsxF1Vc0j40KtSXA5qzTUK UDnaeRQLBFtTCJf2A8F6m59WVTelvvd8/JZX4oh/9NSMBD5t+RWkf4icFq6ewPDdQc4d tkpfeNmQICPWNV37fLCuhjEjgltl2l2M9YHaWtfbKDjlgoXRK4RDtF2sa8km2h5I7VtC IEFFk2DkdlM65nIeaiw9akz1NgO55I6Qm2crrDlxzbtDqOGsWbbunKDoX7dOwr556lOF Bv+I7l5GZCcF1yb1IqZqvzuFBbPoFxG2LiYof6SgfKnNI+bJLQjbHS5dTcfcoV00i4pE XdHw== X-Gm-Message-State: AG10YOSs8N/DX1kuW0CAih2rYCB4nR+O6L3Bz0Mvr6GusjVmGGV9QOogYts3iqXYBOiH6Q== X-Received: by 10.28.238.144 with SMTP id j16mr18343913wmi.43.1455630845860; Tue, 16 Feb 2016 05:54:05 -0800 (PST) Received: from tn-HP-4.semihalf.local ([80.82.22.190]) by smtp.gmail.com with ESMTPSA id q129sm20833462wmd.14.2016.02.16.05.54.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 16 Feb 2016 05:54:05 -0800 (PST) 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, jiang.liu@linux.intel.com, jchandra@broadcom.com, Stefano.Stabellini@eu.citrix.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, Tomasz Nowicki Subject: [PATCH V5 07/15] pci, acpi: Provide generic way to assign bus domain number. Date: Tue, 16 Feb 2016 14:53:37 +0100 Message-Id: <1455630825-27253-8-git-send-email-tn@semihalf.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1455630825-27253-1-git-send-email-tn@semihalf.com> References: <1455630825-27253-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-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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 c2bd6dd..3b284dc 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 94d8f38..b4f87ba9 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) @@ -143,6 +144,7 @@ extern struct list_head pci_mmcfg_list; #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