From patchwork Wed Jan 13 13:20:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Nowicki X-Patchwork-Id: 8025041 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 27C25BEEE5 for ; Wed, 13 Jan 2016 13:25:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4BC3820351 for ; Wed, 13 Jan 2016 13:25:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0278720498 for ; Wed, 13 Jan 2016 13:25:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756652AbcAMNZB (ORCPT ); Wed, 13 Jan 2016 08:25:01 -0500 Received: from mail-wm0-f52.google.com ([74.125.82.52]:38625 "EHLO mail-wm0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933101AbcAMNVo (ORCPT ); Wed, 13 Jan 2016 08:21:44 -0500 Received: by mail-wm0-f52.google.com with SMTP id b14so371534729wmb.1 for ; Wed, 13 Jan 2016 05:21:44 -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=lOLgLr6E0z565rS815Jw3DepveXwkfAg8geTNHpNmyc=; b=ZNwzTEV+AO8BwMeXhdZBBn73ztRpN+5m/qWF+ZRmtmvJ1jjKX+i9Vv2Rz/DVX6ujWh QV2SbEhFsBvcjTX3ZCL+uaNmbvbLSAD29Fsf77VhQjKj4Hb62fr0kHgrElcjuwJiMR8q hEagJBtrnb7f4MJtAWXlZIm2VM7ktMHNw7mYnMmARM2rRT8UqxCahTA2AFIizFTZaVwY BpREimJcF6ElPzEEt1aWIoRsIOCs9tlkwE+hi4MJu7Kk6AkkJeidjDioP9Cid50L6gTF JfIRyZpb0ixcld1DeGgETWwYTaqjS6JRke8F2S7yCB2v97h3oCboKHT2je5cKyqHlJsi bIeA== 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=lOLgLr6E0z565rS815Jw3DepveXwkfAg8geTNHpNmyc=; b=GxxkTmAgLBx4Mhmw4D/1vldlLyBkwULXBgH71Hh6Z8AVGsJ9ZjjBCTmnmVLhUXRE7j CJRJ6bSp9yeYoKpBQYOS+qFh/7fQAPymV09crIBrcfdoR0Vi8jpv3LO12AC3+yBzq2ug Yr/aWSUYI3/RmvmIWV4nOBcWEP6OWkFnq70HgUh+eEEmkPwB8/Z41SdTlc7ycCLiUsWe ZxrfZTtkD9LzwhijYx/0LYDgbZ9IsRQ22iGoo1O5mnLB7s4beVMn3AbN4BcrK2++H8+s wQWu3LSg0ga1YWqv8YbPbjV9F7cCKxt1kP8sWp4vGKK1y/27apxjVME8hTKe8oXsxKx8 wvyw== X-Gm-Message-State: ALoCoQl8wrylpBLdhoK4EEIvcs1AUoipGANB1l0LDwHEodfNMJaNeCCalfT4o27FjK0iOS0a6HhNNrfR8FaeFjvtEzIE1v2V6Q== X-Received: by 10.194.60.231 with SMTP id k7mr37751460wjr.61.1452691303712; Wed, 13 Jan 2016 05:21:43 -0800 (PST) Received: from tn-HP-4.semihalf.local (cardhu.semihalf.com. [213.17.239.108]) by smtp.gmail.com with ESMTPSA id y124sm8858741wmg.3.2016.01.13.05.21.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 13 Jan 2016 05:21:43 -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 Cc: robert.richter@caviumnetworks.com, mw@semihalf.com, Liviu.Dudau@arm.com, ddaney@caviumnetworks.com, tglx@linutronix.de, 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, jchandra@broadcom.com, jcm@redhat.com, Tomasz Nowicki Subject: [PATCH V3 13/21] pci, acpi: Provide generic way to assign bus domain number. Date: Wed, 13 Jan 2016 14:20:59 +0100 Message-Id: <1452691267-32240-14-git-send-email-tn@semihalf.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1452691267-32240-1-git-send-email-tn@semihalf.com> References: <1452691267-32240-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=-5.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_BRBL_LASTEXT, 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. Signed-off-by: Tomasz Nowicki Reviewed-by: Liviu Dudau Tested-by: Suravee Suthikulpanit Tested-by: Jeremy Linton --- drivers/pci/pci.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 7274006..39a985b 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -4796,14 +4797,34 @@ void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent) * API and update the use_dt_domains value to keep track of method we * are using to assign domain numbers (use_dt_domains = 0). * + * IF ACPI, we expect non-DT method (use_dt_domains == -1) + * and call _SEG method for corresponding host bridge device. + * If _SEG method does not exist, following ACPI spec (6.5.6) + * all PCI buses belong to domain 0. + * * All other combinations imply we have a platform that is trying - * to mix domain numbers obtained from DT and pci_get_new_domain_nr(), - * which is a recipe for domain mishandling and it is prevented by - * invalidating the domain value (domain = -1) and printing a - * corresponding error. + * to mix domain numbers obtained from DT, ACPI and + * pci_get_new_domain_nr(), which is a recipe for domain mishandling and + * it is prevented by invalidating the domain value (domain = -1) and + * printing a corresponding error. */ + if (domain >= 0 && use_dt_domains) { use_dt_domains = 1; +#ifdef CONFIG_ACPI + } else if (!acpi_disabled && use_dt_domains == -1) { + struct acpi_device *acpi_dev = to_acpi_device(parent); + unsigned long long segment = 0; + acpi_status status; + + 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"); + + domain = segment; +#endif } else if (domain < 0 && use_dt_domains != 1) { use_dt_domains = 0; domain = pci_get_new_domain_nr();