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: 7498111 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 0D1FD9F327 for ; Tue, 27 Oct 2015 16:43:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1B9132087A for ; Tue, 27 Oct 2015 16:43:35 +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 33F9A207C8 for ; Tue, 27 Oct 2015 16:43:34 +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 1Zr7Jm-0000bD-UB; Tue, 27 Oct 2015 16:41:50 +0000 Received: from mail-lf0-x22f.google.com ([2a00:1450:4010:c07::22f]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zr7Hq-0006RL-Lz for linux-arm-kernel@lists.infradead.org; Tue, 27 Oct 2015 16:39:54 +0000 Received: by lfbn126 with SMTP id n126so140180261lfb.2 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=m4URWHMyM5HJ0ipZ6vT1sr9NvpnToW0rZj3hyMpPhMzw/1fGrQHA5cAYAx9V4dkck7 5d1jL4tvmnyCmnbi5JEa0ozA79nFW+FDVaGN9LiDxuy++vPn9hPw4DIzicYhbkkPHUYz l52vZo+OMg5C/p3jf1SPYFdx+vPkWg26d36mwGeDgRQQL7x+4zDD2vAA1Vu6pj9dBFxZ eQOMOQDg3Kau2hYhn30GL8cUnZMiVTa6LmuuPPOTC5N2e9I2dMzDyFVWyzSJhGQ9Tei2 OtaCYXG+u4KWHdHaGuzJk9jot64rboX/QojQDogDoQ+dklb3UcFvr+jUm1nkBWksCppA vVcw== X-Gm-Message-State: ALoCoQlA0Y7AnSw3HWYyYzjiJhX7BeFigXA7IHeRy9Np4DzGFcUwpP/62lQTT9E1wSlz3XT7YofJ 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151027_093951_131555_9F50F801 X-CRM114-Status: GOOD ( 19.23 ) 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: linux-kernel@vger.kernel.org, linaro-acpi@lists.linaro.org, linux-pci@vger.kernel.org, Liviu.Dudau@arm.com, ddaney@caviumnetworks.com, Narinder.Dhillon@caviumnetworks.com, linux-acpi@vger.kernel.org, robert.richter@caviumnetworks.com, Suravee.Suthikulpanit@amd.com, msalter@redhat.com, wangyijing@huawei.com, Tomasz Nowicki , tglx@linutronix.de, jiang.liu@linux.intel.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.1 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 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();