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: 8025591 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 690D09F96D for ; Wed, 13 Jan 2016 13:32:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7ACB72049C for ; Wed, 13 Jan 2016 13:32:26 +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 A006220461 for ; Wed, 13 Jan 2016 13:32:25 +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 1aJLVq-0002uI-UG; Wed, 13 Jan 2016 13:30:58 +0000 Received: from mail-wm0-x22e.google.com ([2a00:1450:400c:c09::22e]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aJLNE-0001GV-9o for linux-arm-kernel@lists.infradead.org; Wed, 13 Jan 2016 13:22:06 +0000 Received: by mail-wm0-x22e.google.com with SMTP id f206so295444246wmf.0 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=SO7l39DmmTwb08EAnBLJCmsieqYbdvuAP0Vs2fo04BPhGrYTtOCQaiUJycKKgkxiGb pZl6jl2/H0WEYly70Z28Vpdimq6t3cmDrgpISy5P7N6WAhxbnz51lg4GhzK6RhHfWmW/ /HoZPFg31ekn6uUT9U21IpycfnsjKV8PloF+ITAdxNeuPSotaQ7PwonvZcq6UuxuY1Uo 9NAByF34I0jbiccFqaQPPq9dccTrovvebpzcSD/RdW0tyDkMmMnBTDbiiPh2I+L7P4i+ VtS/8TTj5sbuTbOahb3GZe7+cRfU/4ig478mFumK0UsMvVxNz1lnRAwp8sHnqJwt+Cl9 b4Rw== X-Gm-Message-State: ALoCoQmcJX+AkSGDiUw/GqVI4uHyr74W3LkvlpbK51cDSPCFGk1xQO5ywAx5fN4Hv2+3ev9meZIuPI7OdKJcyXp+WeiXZxZBmw== 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160113_052204_653648_68A0E788 X-CRM114-Status: GOOD ( 14.73 ) 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: jchandra@broadcom.com, jcm@redhat.com, linaro-acpi@lists.linaro.org, linux-pci@vger.kernel.org, Liviu.Dudau@arm.com, ddaney@caviumnetworks.com, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, robert.richter@caviumnetworks.com, Suravee.Suthikulpanit@amd.com, msalter@redhat.com, wangyijing@huawei.com, Tomasz Nowicki , tglx@linutronix.de, mw@semihalf.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 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();