From patchwork Mon Nov 17 10:21:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wangyijing X-Patchwork-Id: 40886 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2E03C24035 for ; Mon, 17 Nov 2014 09:42:19 +0000 (UTC) Received: by mail-wi0-f199.google.com with SMTP id bs8sf905365wib.6 for ; Mon, 17 Nov 2014 01:42:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=zMZRcwzeKHimUEWAyUGs4V9m9mT3NhlxiQ5X4L1e+gg=; b=YH3XUE7TqZ4ORbD7al/SKeWge0Gt7crhtnbt/HB4tYtD4LdeBHz+CQy6mo8IrqDYjJ wPXbc/fGt8F9oOZWQX0ib6ZP8z6TfWbJl/HqTKo2lWPg5N/Y/tZI3dg97noyHXKDYC/m SJRZ0Sww04a3y1MHbC5Z2/HSGDG08NUKBKKoQ0knKbl+on8b61c00j2NnPHbuQIDBBMd IyHI4q34vYLWMcw0L5nHxOh+VWaVdnMR9egAsvYaX8BBh4VJXUv/iAtIg2PHOxw7SCe4 JSMlYfiVbRVbL5Xj1sXQgkonmhLJgLuSFj2AJi9V6m/xJBsZP3JkBUD6YWrPeeWi5eP4 ZPaw== X-Gm-Message-State: ALoCoQmXMxlEAFvi+ZiIfmspBthFQM88x6scyQqEm31bYUu2RQY9ez0Ws/nIYpsXFzy2hRZjAYKU X-Received: by 10.180.8.9 with SMTP id n9mr4179894wia.6.1416217338415; Mon, 17 Nov 2014 01:42:18 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.23.130 with SMTP id m2ls730768laf.63.gmail; Mon, 17 Nov 2014 01:42:18 -0800 (PST) X-Received: by 10.152.37.69 with SMTP id w5mr25645301laj.67.1416217338109; Mon, 17 Nov 2014 01:42:18 -0800 (PST) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com. [209.85.217.180]) by mx.google.com with ESMTPS id ay11si50966537lab.132.2014.11.17.01.42.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 17 Nov 2014 01:42:18 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) client-ip=209.85.217.180; Received: by mail-lb0-f180.google.com with SMTP id z11so8923457lbi.11 for ; Mon, 17 Nov 2014 01:42:18 -0800 (PST) X-Received: by 10.152.6.228 with SMTP id e4mr9022392laa.71.1416217337976; Mon, 17 Nov 2014 01:42:17 -0800 (PST) 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.184.201 with SMTP id ew9csp1127269lbc; Mon, 17 Nov 2014 01:42:17 -0800 (PST) X-Received: by 10.70.129.104 with SMTP id nv8mr27991721pdb.81.1416217336307; Mon, 17 Nov 2014 01:42:16 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id rc17si34774184pab.100.2014.11.17.01.42.15 for ; Mon, 17 Nov 2014 01:42:16 -0800 (PST) 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 S1752310AbaKQJmO (ORCPT + 26 others); Mon, 17 Nov 2014 04:42:14 -0500 Received: from szxga02-in.huawei.com ([119.145.14.65]:28887 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752088AbaKQJk5 (ORCPT ); Mon, 17 Nov 2014 04:40:57 -0500 Received: from 172.24.2.119 (EHLO szxeml462-hub.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CCM04939; Mon, 17 Nov 2014 17:40:49 +0800 (CST) Received: from localhost.localdomain (10.175.100.166) by szxeml462-hub.china.huawei.com (10.82.67.205) with Microsoft SMTP Server id 14.3.158.1; Mon, 17 Nov 2014 17:40:40 +0800 From: Yijing Wang To: Bjorn Helgaas CC: , , Xinwei Hu , Wuyun , , Russell King , , Thomas Gleixner , Benjamin Herrenschmidt , , Tony Luck , , Thierry Reding , Liviu Dudau , , Yijing Wang Subject: [RFC PATCH 15/16] arm/PCI: Use pci_scan_host_bridge() instead of pci_scan_root_bus() Date: Mon, 17 Nov 2014 18:21:49 +0800 Message-ID: <1416219710-26088-16-git-send-email-wangyijing@huawei.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1416219710-26088-1-git-send-email-wangyijing@huawei.com> References: <1416219710-26088-1-git-send-email-wangyijing@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.100.166] X-CFilter-Loop: Reflected 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: wangyijing@huawei.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.217.180 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: , Signed-off-by: Yijing Wang --- arch/arm/include/asm/mach/pci.h | 1 + arch/arm/kernel/bios32.c | 52 +++++++++++++++++++++++--------------- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/arch/arm/include/asm/mach/pci.h b/arch/arm/include/asm/mach/pci.h index 370b3bd..a26eb3a 100644 --- a/arch/arm/include/asm/mach/pci.h +++ b/arch/arm/include/asm/mach/pci.h @@ -46,6 +46,7 @@ struct hw_pci { struct pci_sys_data { struct list_head node; int busnr; /* primary bus number */ + u8 nr; u64 mem_offset; /* bus->cpu memory mapping offset */ unsigned long io_offset; /* bus->cpu IO mapping offset */ struct pci_bus *bus; /* PCI bus */ diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c index 3fe56f1..535d7ec 100644 --- a/arch/arm/kernel/bios32.c +++ b/arch/arm/kernel/bios32.c @@ -426,33 +426,41 @@ static int pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) return irq; } -static int pcibios_init_resources(int busnr, struct pci_sys_data *sys) +static int pcibios_init_resources(struct pci_host_bridge *host, + struct pci_host_info *info) { int ret; - struct pci_host_bridge_window *window; + struct pci_sys_data *sys = info->arg; + struct pci_host_bridge_window *window, *n; if (list_empty(&sys->resources)) { - pci_add_resource_offset(&sys->resources, + pci_add_resource_offset(&host->windows, &iomem_resource, sys->mem_offset); + } else { + list_for_each_entry_safe(window, n, + &sys->resources, list) { + list_move_tail(&window->list, + &host->windows); + } } - list_for_each_entry(window, &sys->resources, list) { + list_for_each_entry(window, &host->windows, list) { if (resource_type(window->res) == IORESOURCE_IO) return 0; } - sys->io_res.start = (busnr * SZ_64K) ? : pcibios_min_io; - sys->io_res.end = (busnr + 1) * SZ_64K - 1; + sys->io_res.start = (sys->nr * SZ_64K) ? : pcibios_min_io; + sys->io_res.end = (sys->nr + 1) * SZ_64K - 1; sys->io_res.flags = IORESOURCE_IO; sys->io_res.name = sys->io_res_name; - sprintf(sys->io_res_name, "PCI%d I/O", busnr); + sprintf(sys->io_res_name, "PCI%d I/O", sys->nr); ret = request_resource(&ioport_resource, &sys->io_res); if (ret) { pr_err("PCI: unable to allocate I/O port region (%d)\n", ret); return ret; } - pci_add_resource_offset(&sys->resources, &sys->io_res, + pci_add_resource_offset(&host->windows, &sys->io_res, sys->io_offset); return 0; @@ -462,8 +470,9 @@ static void pcibios_init_hw(struct device *parent, struct hw_pci *hw, struct list_head *head) { struct pci_sys_data *sys = NULL; - int ret; - int nr, busnr; + int ret, nr, busnr, domain; + struct pci_host_bridge *host; + struct pci_host_info info; for (nr = busnr = 0; nr < hw->nr_controllers; nr++) { sys = kzalloc(sizeof(struct pci_sys_data), GFP_KERNEL); @@ -471,6 +480,7 @@ static void pcibios_init_hw(struct device *parent, struct hw_pci *hw, panic("PCI: unable to allocate sys data!"); sys->busnr = busnr; + sys->nr = nr; sys->swizzle = hw->swizzle; sys->map_irq = hw->map_irq; sys->align_resource = hw->align_resource; @@ -482,25 +492,25 @@ static void pcibios_init_hw(struct device *parent, struct hw_pci *hw, sys->private_data = hw->private_data[nr]; ret = hw->setup(nr, sys); - if (ret > 0) { - ret = pcibios_init_resources(nr, sys); - if (ret) { - kfree(sys); - break; - } - + init_pci_host_info(&info); + info.arg = sys; + info.init_res = pcibios_init_resources; + domain = pci_get_domain_nr(parent); if (hw->scan) sys->bus = hw->scan(nr, sys); - else - sys->bus = pci_scan_root_bus(parent, sys->busnr, - hw->ops, sys, &sys->resources); + else { + host = pci_scan_host_bridge(parent, + PCI_DOMBUS(domain, sys->busnr), + hw->ops, &info); + if (host) + sys->bus = host->bus; + } if (!sys->bus) panic("PCI: unable to scan bus!"); busnr = sys->bus->busn_res.end + 1; - list_add(&sys->node, head); } else { kfree(sys);