From patchwork Tue Aug 12 16:25:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liviu Dudau X-Patchwork-Id: 35292 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f69.google.com (mail-pa0-f69.google.com [209.85.220.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 602FF203C5 for ; Tue, 12 Aug 2014 16:27:53 +0000 (UTC) Received: by mail-pa0-f69.google.com with SMTP id kx10sf72417156pab.0 for ; Tue, 12 Aug 2014 09:27:52 -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=6GL2hDeeagSeAZPaillawdJMnItq4OXUQdG4HM4ASkw=; b=EUjLGaR1w98JDku/iRxS5pcjhU6vrg3sHfSHerDH3bvH6rWzP9sMhUJiwKCKf9eHnd 59f0Eo2GLmbblDCp6rlyhg8NiJtHLWc0gEikEnD7aGYA8TESBlmFlUMLfJZPDWsv/WMl Rv0VKTNyEYOAIT+e91YeZ5sho0f1cLGkg/V7ceChnp48kT69WOAdpx2jq4bTr1aSs7bW jCZ7w6oNLw7cHdMGUOfOBA3WQnzOy45A0/qQ/dOH9Gacj/aNab12WPxyRA/B9hlQ7Yv6 B5skgC5znHOIYXoz13w1pET9+DLX1p4XYfYaT51ehDw8xLY2MOxkpASMXZVr8/wC4VqM vwpw== X-Gm-Message-State: ALoCoQkd4QRpMrn2uOETuH0S+PhhaPktlAGV6OY1fhth60fx/rXhWR2rE1r7HJpBKxLWsqOxGlGm X-Received: by 10.69.31.75 with SMTP id kk11mr2826983pbd.8.1407860872676; Tue, 12 Aug 2014 09:27:52 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.51.170 with SMTP id u39ls193146qga.21.gmail; Tue, 12 Aug 2014 09:27:52 -0700 (PDT) X-Received: by 10.220.202.9 with SMTP id fc9mr5114062vcb.40.1407860872580; Tue, 12 Aug 2014 09:27:52 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id t10si7375318vcj.42.2014.08.12.09.27.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 12 Aug 2014 09:27:52 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.182 as permitted sender) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id hy4so13724648vcb.13 for ; Tue, 12 Aug 2014 09:27:52 -0700 (PDT) X-Received: by 10.221.47.9 with SMTP id uq9mr2203171vcb.48.1407860872474; Tue, 12 Aug 2014 09:27:52 -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.221.37.5 with SMTP id tc5csp262596vcb; Tue, 12 Aug 2014 09:27:51 -0700 (PDT) X-Received: by 10.66.222.199 with SMTP id qo7mr2919799pac.134.1407860871488; Tue, 12 Aug 2014 09:27:51 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gn11si16382525pbd.105.2014.08.12.09.27.50 for ; Tue, 12 Aug 2014 09:27:51 -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 S1753961AbaHLQ1n (ORCPT + 26 others); Tue, 12 Aug 2014 12:27:43 -0400 Received: from fw-tnat.cambridge.arm.com ([217.140.96.21]:54818 "EHLO cam-smtp0.cambridge.arm.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753258AbaHLQ1A (ORCPT ); Tue, 12 Aug 2014 12:27:00 -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 s7CGPPgc026280; Tue, 12 Aug 2014 17:25:28 +0100 From: Liviu Dudau To: Bjorn Helgaas , Catalin Marinas , Will Deacon , Benjamin Herrenschmidt , Arnd Bergmann , Russell King , Tanmay Inamdar , Grant Likely , Sinan Kaya , Jingoo Han , Kukjin Kim , Suravee Suthikulanit , linux-pci Cc: linux-arch , LKML , Device Tree ML , LAKML Subject: [PATCH v9 08/12] PCI: Introduce generic domain handling for PCI busses. Date: Tue, 12 Aug 2014 17:25:21 +0100 Message-Id: <1407860725-25202-9-git-send-email-Liviu.Dudau@arm.com> X-Mailer: git-send-email 2.0.4 In-Reply-To: <1407860725-25202-1-git-send-email-Liviu.Dudau@arm.com> References: <1407860725-25202-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.220.182 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: , The handling of PCI domains (or PCI segments in ACPI speak) is usually a straightforward affair but its implementation is currently left to the architectural code, with pci_domain_nr(b) querying the value of the domain associated with bus b. This patch introduces CONFIG_PCI_DOMAINS_GENERIC as an option that can be selected if an architecture want a simple implementation where the value of the domain associated with a bus is stored in struct pci_bus. The architectures that select CONFIG_PCI_DOMAINS_GENERIC will then have to implement pci_bus_assign_domain_nr() as a way of setting the domain number associated with a root bus. All child busses except the root bus will inherit the domain_nr value from their parent. Cc: Bjorn Helgaas Cc: Arnd Bergmann Signed-off-by: Catalin Marinas [Renamed pci_set_domain_nr() to pci_bus_assign_domain_nr()] Signed-off-by: Liviu Dudau --- drivers/pci/probe.c | 11 ++++++++--- include/linux/pci.h | 21 +++++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 5ff72ec..ef891d2 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -485,7 +485,7 @@ void pci_read_bridge_bases(struct pci_bus *child) } } -static struct pci_bus *pci_alloc_bus(void) +static struct pci_bus *pci_alloc_bus(struct pci_bus *parent) { struct pci_bus *b; @@ -500,6 +500,10 @@ static struct pci_bus *pci_alloc_bus(void) INIT_LIST_HEAD(&b->resources); b->max_bus_speed = PCI_SPEED_UNKNOWN; b->cur_bus_speed = PCI_SPEED_UNKNOWN; +#ifdef CONFIG_PCI_DOMAINS_GENERIC + if (parent) + b->domain_nr = parent->domain_nr; +#endif return b; } @@ -672,7 +676,7 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent, /* * Allocate a new bus, and inherit stuff from the parent.. */ - child = pci_alloc_bus(); + child = pci_alloc_bus(parent); if (!child) return NULL; @@ -1768,13 +1772,14 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus, bridge->dev.parent = parent; - b = pci_alloc_bus(); + b = pci_alloc_bus(NULL); if (!b) goto err_out; b->sysdata = sysdata; b->ops = ops; b->number = b->busn_res.start = bus; + pci_bus_assign_domain_nr(b, parent); b2 = pci_find_bus(pci_domain_nr(b), bus); if (b2) { /* If we already got to this bus through a different bridge, ignore it */ diff --git a/include/linux/pci.h b/include/linux/pci.h index 466bcd1..1d0e0b5 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -456,6 +456,9 @@ struct pci_bus { unsigned char primary; /* number of primary bridge */ unsigned char max_bus_speed; /* enum pci_bus_speed */ unsigned char cur_bus_speed; /* enum pci_bus_speed */ +#ifdef CONFIG_PCI_DOMAINS_GENERIC + int domain_nr; +#endif char name[48]; @@ -1288,6 +1291,24 @@ static inline int pci_domain_nr(struct pci_bus *bus) { return 0; } static inline int pci_proc_domain(struct pci_bus *bus) { return 0; } #endif /* CONFIG_PCI_DOMAINS */ +/* + * Generic implementation for PCI domain support. If your + * architecture does not need custom management of PCI + * domains then this implementation will be used + */ +#ifdef CONFIG_PCI_DOMAINS_GENERIC +static inline int pci_domain_nr(struct pci_bus *bus) +{ + return bus->domain_nr; +} +void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent); +#else +static inline void pci_bus_assign_domain_nr(struct pci_bus *bus, + struct device *parent) +{ +} +#endif + /* some architectures require additional setup to direct VGA traffic */ typedef int (*arch_set_vga_state_t)(struct pci_dev *pdev, bool decode, unsigned int command_bits, u32 flags);