From patchwork Fri Apr 15 17:06: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: 611076 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3qmkfm2Nf9z9t6X for ; Sat, 16 Apr 2016 03:14:24 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=semihalf-com.20150623.gappssmtp.com header.i=@semihalf-com.20150623.gappssmtp.com header.b=tf8jDjCK; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753035AbcDORHT (ORCPT ); Fri, 15 Apr 2016 13:07:19 -0400 Received: from mail-wm0-f42.google.com ([74.125.82.42]:36859 "EHLO mail-wm0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752601AbcDORHP (ORCPT ); Fri, 15 Apr 2016 13:07:15 -0400 Received: by mail-wm0-f42.google.com with SMTP id v188so39791040wme.1 for ; Fri, 15 Apr 2016 10:07:15 -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=sOxMJndyOvw01evJxfRYeiFsFFf7zJEl/oW2H8dNBGs=; b=tf8jDjCKeqG9ah50IYsqX/basojAoDlKJxsD5eIsIVQu3LgQ/7Nl+yEA/y0QLuqOLW FlSMbtfuABCJ5PU6JskyYHVyA92NmuagKedfL3ppt2SY+g+V+UV4HQixa5887xRZrN6l JsZNSnLQZYTWOJq5rBQWN8WSQEcb0B4YnrjKi2nL8VHNHPkzIYmC9GBSIgBDHmFVTJ+G r6KAyNCTgFMLmzMnaBrLufuVReS0ry4jhqJmMNFsNBelcUVHvaYYt8w1Jrgcm6b8L1u0 uLwPbvz2KwhlZCnvl4PrZ+uhctOYQWrOLxjjh0n1uh5kH5CAy2CsYoEKcM3sGbeB61/M eMrg== 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=sOxMJndyOvw01evJxfRYeiFsFFf7zJEl/oW2H8dNBGs=; b=FXMPeECPOHDNtHxzdophCQ85ruFdHs1Zf+dyoERUzne9p077+rTOzlhZCl67FcxISa hYgJsB7U1IzW31XNlO+UeZRsizs3OnNuQVQLO78CY8ArrYwsPWIbYsBk59u2obXt9vlK ALSITny8ugBZqgYSISb6NVVx9lZ3LwNbzxC000ZXNXaDkZrUA0EiGdtooeUdHGJAfCWe +9R73WkBi60qliFuySfmizMfEykOi61uaEQlOxylrMiKYo3hJ2nADuOoAjgkXu2wUIx6 PXbz6lMaZNmlaAjls9zytkv7VLg+ZuZwkqk12jEG+125dN80wyyTRuqL8Rb0P1a0pqCM +BfA== X-Gm-Message-State: AOPr4FURj/Jr62vJNqqAEzF9ZcWvrKqcxpLU9INIAuCmFlQZGMDD6WvYZ9otC6+rDur7kw== X-Received: by 10.194.23.65 with SMTP id k1mr17102635wjf.31.1460740034161; Fri, 15 Apr 2016 10:07:14 -0700 (PDT) Received: from tn-HP-4.semihalf.local (cardhu.semihalf.com. [213.17.239.108]) by smtp.gmail.com with ESMTPSA id gr4sm14282723wjd.23.2016.04.15.10.07.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 15 Apr 2016 10:07:13 -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, jiang.liu@linux.intel.com, 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, Tomasz Nowicki Subject: [PATCH V6 02/13] pci, acpi: Provide generic way to assign bus domain number. Date: Fri, 15 Apr 2016 19:06:37 +0200 Message-Id: <1460740008-19489-3-git-send-email-tn@semihalf.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1460740008-19489-1-git-send-email-tn@semihalf.com> References: <1460740008-19489-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 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 4581e0e..d9a70c4 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 25e0327..1a74e87 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -4779,7 +4780,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; @@ -4823,7 +4824,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