From patchwork Tue Oct 27 16:38:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Nowicki X-Patchwork-Id: 7497911 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@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 7B9969F327 for ; Tue, 27 Oct 2015 16:39:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0D74B208AF for ; Tue, 27 Oct 2015 16:39:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0CB4F2087A for ; Tue, 27 Oct 2015 16:39:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965197AbbJ0Qjh (ORCPT ); Tue, 27 Oct 2015 12:39:37 -0400 Received: from mail-lf0-f42.google.com ([209.85.215.42]:34461 "EHLO mail-lf0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965154AbbJ0Qje (ORCPT ); Tue, 27 Oct 2015 12:39:34 -0400 Received: by lfaz124 with SMTP id z124so175672833lfa.1 for ; Tue, 27 Oct 2015 09:39:32 -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=i5gPO02x2WW2rJOnY6tsxO/1ja8p02dP3cgGSTS5G4E=; b=E018N5MC3HE5y8KvECNA760EI+A2LSjDBdbEspNdmDlRhdTQlwkx3QcZPhNOzwdAF0 0WQzKenvCYxGA6eSuMPjs+xmYR9nxyX6ja6SHDWpbCn9deMp1zrFO/mnVEZglkbN3dnC GZG3T1Cheer5vrShRTfZNej4IN3cDUQAGHdyEi/A3LGHhZikKUSIx8LQWsJlRHaDj27R ygdeIxAUAD+QTnpKsoMZsaGvb9RHc7QvjLK3tWGTPrA+5lPW1QjVKCA9f/uOAHpj/BAP axIHff9PoWK5VDLaw8gPA0QQtBPls/PJvXBygPgQFTQZi7cIsAFVESeLmGeRJzWfiwpO JAXg== 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=i5gPO02x2WW2rJOnY6tsxO/1ja8p02dP3cgGSTS5G4E=; b=MDiG87v2tiv2y2gcGNszQCD3qKJdICT6Yk6aYmgJM19AVaTNiswM1UrTuKPW0r6e93 OL3nKjIuniqi+qq0K2f1u61lnntkgYTdwejQJeSP947XSfvUwvmbTwpPafLJ+bgYzk/j 1KdUmGLqgtz31ycGOIso+UWzJhZpYrLK7HQraMSC9g3CMZeKaWY9OTnz95oZr+ICGwnW M0Vpwl0zZlQj2ZseBT0mNCqOgEtqDom/iwOKh8LJTFbueFJf8cTLZROboYpGp4K3SHGk jZA1gIyAh+EwTuJjoMaPqkoUQG/VHZZ1S+JiZN9Ha/WbZjSq/FZbozy1f3SDZsNrWrdD F3lw== X-Gm-Message-State: ALoCoQn9JOxGdpojLZtDJsbn3GegQk03KL6S6JG3SiHAeZDNwZn9/ajiHzDfcLwUKmX86vZdizvR X-Received: by 10.25.32.140 with SMTP id g134mr3598897lfg.26.1445963972465; Tue, 27 Oct 2015 09:39:32 -0700 (PDT) Received: from tn-HP-4.semihalf.local ([80.82.22.190]) by smtp.gmail.com with ESMTPSA id kk6sm6988609lbc.48.2015.10.27.09.39.31 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Oct 2015 09:39:32 -0700 (PDT) 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 Cc: jiang.liu@linux.intel.com, robert.richter@caviumnetworks.com, Narinder.Dhillon@caviumnetworks.com, ddaney@caviumnetworks.com, Liviu.Dudau@arm.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, Tomasz Nowicki Subject: [PATCH V1 10/11] pci, acpi: Provide generic way to assign bus domain number. Date: Tue, 27 Oct 2015 17:38:41 +0100 Message-Id: <1445963922-22711-11-git-send-email-tn@semihalf.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1445963922-22711-1-git-send-email-tn@semihalf.com> References: <1445963922-22711-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 Architectures which support PCI_DOMAINS_GENERIC (like ARM64) cannot call pci_bus_assign_domain_nr along ACPI PCI host bridge initialization since this function needs valid parent device reference to be able to retrieve domain number (aka segment). We can omit that blocker and pass down host bridge device via pci_create_root_bus parameter and then be able to evaluate _SEG method being in pci_bus_assign_domain_nr. 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 --- drivers/acpi/pci_root.c | 2 +- drivers/pci/pci.c | 32 +++++++++++++++++++++++++++----- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 850d7bf..e682dc6 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c @@ -839,7 +839,7 @@ struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root, pci_acpi_root_add_resources(info); pci_add_resource(&info->resources, &root->secondary); - bus = pci_create_root_bus(NULL, busnum, ops->pci_ops, + bus = pci_create_root_bus(&device->dev, busnum, ops->pci_ops, sysdata, &info->resources); if (!bus) goto out_release_info; diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 6a9a111..17d1857 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include "pci.h" @@ -4501,7 +4502,7 @@ int pci_get_new_domain_nr(void) void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent) { static int use_dt_domains = -1; - int domain = of_get_pci_domain_nr(parent->of_node); + int domain; /* * Check DT domain and use_dt_domains values. @@ -4523,14 +4524,35 @@ 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. */ + + domain = of_get_pci_domain_nr(parent->of_node); 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();