From patchwork Tue Sep 23 19:01:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liviu Dudau X-Patchwork-Id: 37759 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f72.google.com (mail-ee0-f72.google.com [74.125.83.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B5A2620970 for ; Tue, 23 Sep 2014 20:02:01 +0000 (UTC) Received: by mail-ee0-f72.google.com with SMTP id c13sf3260687eek.3 for ; Tue, 23 Sep 2014 13:02:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=vGyfSX91WcLTVnpJAuHMSPm7P76DEeByi+prR9RH0jI=; b=b1gFOpFFJeiYJpvIZbqzqPoPZyIjKS7gIWxfQmj1po+3ihSIl+Sv48yDQn1lGgTnfK 7YbQww5J0zDk+8YQXQ0o3YtVfMG+6kb0Fy4EWqwKBUIKe28HG8QQtl9maKUtULm9XN43 WR1E47nD3c2extP+KRpEsnB0WL3hePIs296w+skrwiwBJRwU3iZ0EAJQHqUutPv4hAPX 11G+k9tM/brHXZgUm7JyooO4DDST2/PPilLk+4EHY9uTzPU9iQQvbdJxmvLaFhIbHAUM w2L4xeXLeOE4E/doZF/zV+TJgg81ORypKcvIK+meuQ4Z4IOQAdb+1xXS+LTy24b/vISb bbWA== X-Gm-Message-State: ALoCoQnK2CpeAD4FMaucV0osHRbgweH7VWIV5NsU02HE9c8dDyhqyio6oK2FZf6QNwpw6u1Qj2M3 X-Received: by 10.194.7.199 with SMTP id l7mr279316wja.2.1411502520921; Tue, 23 Sep 2014 13:02:00 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.87.44 with SMTP id u12ls88602laz.16.gmail; Tue, 23 Sep 2014 13:02:00 -0700 (PDT) X-Received: by 10.112.209.70 with SMTP id mk6mr1864985lbc.44.1411502520726; Tue, 23 Sep 2014 13:02:00 -0700 (PDT) Received: from mail-la0-f42.google.com (mail-la0-f42.google.com [209.85.215.42]) by mx.google.com with ESMTPS id pf1si20063752lbc.94.2014.09.23.13.02.00 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 23 Sep 2014 13:02:00 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by mail-la0-f42.google.com with SMTP id hz20so9556021lab.29 for ; Tue, 23 Sep 2014 13:02:00 -0700 (PDT) X-Received: by 10.152.246.6 with SMTP id xs6mr1910657lac.56.1411502520486; Tue, 23 Sep 2014 13:02:00 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.130.169 with SMTP id of9csp476780lbb; Tue, 23 Sep 2014 13:01:59 -0700 (PDT) X-Received: by 10.68.139.232 with SMTP id rb8mr2772234pbb.20.1411502518833; Tue, 23 Sep 2014 13:01:58 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c2si24873pdj.97.2014.09.23.13.01.58 for ; Tue, 23 Sep 2014 13:01:58 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756781AbaIWUB4 (ORCPT + 27 others); Tue, 23 Sep 2014 16:01:56 -0400 Received: from fw-tnat.cambridge.arm.com ([217.140.96.21]:54638 "EHLO cam-smtp0.cambridge.arm.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755830AbaIWUBx (ORCPT ); Tue, 23 Sep 2014 16:01:53 -0400 Received: from e106497-lin.cambridge.arm.com (e106497-lin.cambridge.arm.com [10.1.195.53]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id s8NJ1Eh3027659; Tue, 23 Sep 2014 20:01:23 +0100 From: Liviu Dudau To: Bjorn Helgaas , Arnd Bergmann , Rob Herring , Jason Gunthorpe , Benjamin Herrenschmidt , Catalin Marinas , Will Deacon , Russell King , linux-pci , Linus Walleij Cc: Tanmay Inamdar , Grant Likely , Sinan Kaya , Jingoo Han , Kukjin Kim , Suravee Suthikulanit , linux-arch , LKML , Device Tree ML , LAKML Subject: [PATCH v12 06/12] PCI: Create pci_host_bridge before its associated bus in pci_create_root_bus. Date: Tue, 23 Sep 2014 20:01:08 +0100 Message-Id: <1411498874-9864-7-git-send-email-Liviu.Dudau@arm.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1411498874-9864-1-git-send-email-Liviu.Dudau@arm.com> References: <1411498874-9864-1-git-send-email-Liviu.Dudau@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: liviu.dudau@arm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Before commit 7b5436635800 the pci_host_bridge was created before the root bus. As that commit has added a needless dependency on the bus for pci_alloc_host_bridge() the creation order has been changed for no good reason. Revert the order of creation as we are going to depend on the pci_host_bridge structure to retrieve the domain number of the root bus. Cc: Bjorn Helgaas Signed-off-by: Liviu Dudau Acked-by: Grant Likely Reviewed-by: Catalin Marinas Tested-by: Tanmay Inamdar --- drivers/pci/probe.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index e3cf8a2..5ff72ec 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -515,7 +515,7 @@ static void pci_release_host_bridge_dev(struct device *dev) kfree(bridge); } -static struct pci_host_bridge *pci_alloc_host_bridge(struct pci_bus *b) +static struct pci_host_bridge *pci_alloc_host_bridge(void) { struct pci_host_bridge *bridge; @@ -524,7 +524,8 @@ static struct pci_host_bridge *pci_alloc_host_bridge(struct pci_bus *b) return NULL; INIT_LIST_HEAD(&bridge->windows); - bridge->bus = b; + bridge->dev.release = pci_release_host_bridge_dev; + return bridge; } @@ -1761,9 +1762,15 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus, char bus_addr[64]; char *fmt; + bridge = pci_alloc_host_bridge(); + if (!bridge) + return NULL; + + bridge->dev.parent = parent; + b = pci_alloc_bus(); if (!b) - return NULL; + goto err_out; b->sysdata = sysdata; b->ops = ops; @@ -1772,26 +1779,19 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus, if (b2) { /* If we already got to this bus through a different bridge, ignore it */ dev_dbg(&b2->dev, "bus already known\n"); - goto err_out; + goto err_bus_out; } - bridge = pci_alloc_host_bridge(b); - if (!bridge) - goto err_out; - - bridge->dev.parent = parent; - bridge->dev.release = pci_release_host_bridge_dev; + bridge->bus = b; dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus); error = pcibios_root_bridge_prepare(bridge); - if (error) { - kfree(bridge); + if (error) goto err_out; - } error = device_register(&bridge->dev); if (error) { put_device(&bridge->dev); - goto err_out; + goto err_bus_out; } b->bridge = get_device(&bridge->dev); device_enable_async_suspend(b->bridge); @@ -1848,8 +1848,10 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus, class_dev_reg_err: put_device(&bridge->dev); device_unregister(&bridge->dev); -err_out: +err_bus_out: kfree(b); +err_out: + kfree(bridge); return NULL; }