From patchwork Mon Sep 29 14:29:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liviu Dudau X-Patchwork-Id: 38072 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 49E76201F1 for ; Mon, 29 Sep 2014 14:31:12 +0000 (UTC) Received: by mail-la0-f69.google.com with SMTP id q1sf4345482lam.8 for ; Mon, 29 Sep 2014 07:31:11 -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=tz21w60v+uDbbUSzrK4uGp4LnoO1hhOjy6miyjwHRtI=; b=PSLfqEhSKE5JB1qExys+39lb/wdUbCDJ3y+vhjpeMwUP1UbmYForE30rXFGWMpSAnS +4lTyp34QKKXKuwmn47/9Yk0aDCTEnuWKL0TIug066PzyCZIyDkWKu+OQc4Ue3rGQyq/ kk7i87kz5yTpMjjUBI7ZOIu6Go0OX7R7UCaTtb7j0ATz/0XBONSabR0wfX0wkV0NM7jt miCdYsq0Fy0R9BBxv/+561miq+HssG6YiXF5HNl6+TE9HRt+D746+erKEwOuu1azHz1Q vOf+YGmY1c4oaB3OinoMooqsOtuJPULqlBvMH7hsCVV05hWkoO8rsbh1l5/+hygypddw MviA== X-Gm-Message-State: ALoCoQl6jQFKMJnqZSsD5mi7gjGzU7zDE0NiBLOYWOaIadq9LUeBLJfdKQ9aPnvy1HhbDYUT6PHY X-Received: by 10.112.145.136 with SMTP id su8mr566039lbb.9.1412001071008; Mon, 29 Sep 2014 07:31:11 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.137 with SMTP id s9ls638687las.13.gmail; Mon, 29 Sep 2014 07:31:10 -0700 (PDT) X-Received: by 10.152.21.42 with SMTP id s10mr40420366lae.61.1412001070831; Mon, 29 Sep 2014 07:31:10 -0700 (PDT) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com [209.85.215.51]) by mx.google.com with ESMTPS id f7si2836940laa.67.2014.09.29.07.31.10 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 29 Sep 2014 07:31:10 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by mail-la0-f51.google.com with SMTP id pv20so8566677lab.10 for ; Mon, 29 Sep 2014 07:31:10 -0700 (PDT) X-Received: by 10.152.5.168 with SMTP id t8mr39461479lat.67.1412001070182; Mon, 29 Sep 2014 07:31:10 -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 of9csp184262lbb; Mon, 29 Sep 2014 07:31:09 -0700 (PDT) X-Received: by 10.70.96.237 with SMTP id dv13mr73932223pdb.66.1412001068649; Mon, 29 Sep 2014 07:31:08 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j2si23329768pdr.83.2014.09.29.07.31.08 for ; Mon, 29 Sep 2014 07:31:08 -0700 (PDT) Received-SPF: none (google.com: devicetree-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 S1753665AbaI2ObG (ORCPT + 5 others); Mon, 29 Sep 2014 10:31:06 -0400 Received: from fw-tnat.cambridge.arm.com ([217.140.96.21]:50437 "EHLO cam-smtp0.cambridge.arm.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752540AbaI2ObF (ORCPT ); Mon, 29 Sep 2014 10:31:05 -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 s8TETVYI004719; Mon, 29 Sep 2014 15:29:35 +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 , Yinghai Lu , Jiang Liu , Catalin Marinas Subject: [PATCH v13 07/12] PCI: Add generic domain handling Date: Mon, 29 Sep 2014 15:29:26 +0100 Message-Id: <1412000971-9242-8-git-send-email-Liviu.Dudau@arm.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1412000971-9242-1-git-send-email-Liviu.Dudau@arm.com> References: <1412000971-9242-1-git-send-email-Liviu.Dudau@arm.com> Sender: devicetree-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: devicetree@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.51 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: , From: Catalin Marinas 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 wants 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 buses except the root bus will inherit the domain_nr value from their parent. Signed-off-by: Catalin Marinas [Renamed pci_set_domain_nr() to pci_bus_assign_domain_nr()] Signed-off-by: Liviu Dudau Signed-off-by: Bjorn Helgaas CC: Arnd Bergmann --- 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 e3cf8a2..636d1c9 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; } @@ -671,7 +675,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; @@ -1761,13 +1765,14 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus, char bus_addr[64]; char *fmt; - b = pci_alloc_bus(); + b = pci_alloc_bus(NULL); if (!b) return NULL; 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 61978a4..a494e5d 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);