From patchwork Mon May 22 16:39:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oza Pawandeep X-Patchwork-Id: 9741051 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E4E8E60388 for ; Mon, 22 May 2017 16:41:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D80822871C for ; Mon, 22 May 2017 16:41:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB2D72871F; Mon, 22 May 2017 16:41:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C52A2871C for ; Mon, 22 May 2017 16:41:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934843AbdEVQlc (ORCPT ); Mon, 22 May 2017 12:41:32 -0400 Received: from mail-pf0-f170.google.com ([209.85.192.170]:33377 "EHLO mail-pf0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934780AbdEVQkC (ORCPT ); Mon, 22 May 2017 12:40:02 -0400 Received: by mail-pf0-f170.google.com with SMTP id e193so87508129pfh.0 for ; Mon, 22 May 2017 09:40:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2WrbP70p8VOLAFQjGJuMMLFnBajAsvloK4122GGYjY0=; b=Z+H91evXGAwZoOXEpPaY9eCEAd78fktkchEEWpnpLaGrWxvMlcOHaX/oUOqAZ1gZ1c vHaoZlNU7vQHImw5upBoLflGItfVs6F7cZwVADJReTH8+5qpfCiai078fUT9Vonuq7pg eQPjugZDD6HYNirUCKqBGK6XXzQRpFffNUwRM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2WrbP70p8VOLAFQjGJuMMLFnBajAsvloK4122GGYjY0=; b=RMrB42cumISa0I9t448U65fURDk0q0yRBdeh95VBHNQsBjlxvfx86YOhOOwwizdszv BQkrmUAwgNab9dpdyogLDSYHHhNSTYnZC8owdErPak8idvYBg6/iRvZnQQI9t5FtOT4X cO/M2SeM3Tdu0cEfkD60sXG7EjGdJMaBldKHM0BgC182IKHXo+He93RM56aMTIlXZpbO jinosQ2SoLbgq3r+yQknm5GEUBfpiAEzuLUERgjCELC6oHOQONQ9h6DvDQR68eYAjhMD /wxxGixCITpn3PgIHw+pEbMBC7Sn59EXhghBAf8Fi+EjX6Zf+mRwq9xUa46tN20zhE5H Fm1Q== X-Gm-Message-State: AODbwcCsfgfSt39F5GnGZoSJZFTvHU5wZPhbAZgXU2HlRdieRZ0hOVF8 7CwTwB5LHuTqubgu X-Received: by 10.84.224.1 with SMTP id r1mr29719778plj.78.1495471201832; Mon, 22 May 2017 09:40:01 -0700 (PDT) Received: from anjanavk-OptiPlex-7010.dhcp.avagotech.net ([192.19.237.250]) by smtp.gmail.com with ESMTPSA id x198sm26538853pgx.28.2017.05.22.09.39.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 May 2017 09:40:01 -0700 (PDT) From: Oza Pawandeep To: Joerg Roedel , Robin Murphy Cc: iommu@lists.linux-foundation.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com, Oza Pawandeep , Oza Pawandeep Subject: [PATCH v7 2/3] PCI: Add support for PCI inbound windows resources Date: Mon, 22 May 2017 22:09:41 +0530 Message-Id: <1495471182-12490-3-git-send-email-oza.oza@broadcom.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1495471182-12490-1-git-send-email-oza.oza@broadcom.com> References: <1495471182-12490-1-git-send-email-oza.oza@broadcom.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds support for inbound memory window for PCI RC drivers. It defines new function pci_create_root_bus2 which takes inbound resources as an argument and fills in the memory resource to PCI internal host bridge structure as inbound_windows. Legacy RC driver could continue to use pci_create_root_bus, but any RC driver who wants to reseve IOVAS for their inbound memory holes, should use new API pci_create_root_bus2. Signed-off-by: Oza Pawandeep diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 19c8950..a95b9bb 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -531,6 +531,7 @@ struct pci_host_bridge *pci_alloc_host_bridge(size_t priv) return NULL; INIT_LIST_HEAD(&bridge->windows); + INIT_LIST_HEAD(&bridge->inbound_windows); return bridge; } @@ -726,6 +727,7 @@ int pci_register_host_bridge(struct pci_host_bridge *bridge) struct pci_bus *bus, *b; resource_size_t offset; LIST_HEAD(resources); + LIST_HEAD(inbound_resources); struct resource *res; char addr[64], *fmt; const char *name; @@ -739,6 +741,8 @@ int pci_register_host_bridge(struct pci_host_bridge *bridge) /* temporarily move resources off the list */ list_splice_init(&bridge->windows, &resources); + list_splice_init(&bridge->inbound_windows, &inbound_resources); + bus->sysdata = bridge->sysdata; bus->msi = bridge->msi; bus->ops = bridge->ops; @@ -794,6 +798,10 @@ int pci_register_host_bridge(struct pci_host_bridge *bridge) else pr_info("PCI host bridge to bus %s\n", name); + /* Add inbound mem resource. */ + resource_list_for_each_entry_safe(window, n, &inbound_resources) + list_move_tail(&window->node, &bridge->inbound_windows); + /* Add initial resources to the bus */ resource_list_for_each_entry_safe(window, n, &resources) { list_move_tail(&window->node, &bridge->windows); @@ -2300,7 +2308,8 @@ void __weak pcibios_remove_bus(struct pci_bus *bus) static struct pci_bus *pci_create_root_bus_msi(struct device *parent, int bus, struct pci_ops *ops, void *sysdata, - struct list_head *resources, struct msi_controller *msi) + struct list_head *resources, struct list_head *in_res, + struct msi_controller *msi) { int error; struct pci_host_bridge *bridge; @@ -2313,6 +2322,9 @@ static struct pci_bus *pci_create_root_bus_msi(struct device *parent, bridge->dev.release = pci_release_host_bridge_dev; list_splice_init(resources, &bridge->windows); + if (in_res) + list_splice_init(in_res, &bridge->inbound_windows); + bridge->sysdata = sysdata; bridge->busnr = bus; bridge->ops = ops; @@ -2329,11 +2341,20 @@ static struct pci_bus *pci_create_root_bus_msi(struct device *parent, return NULL; } +struct pci_bus *pci_create_root_bus2(struct device *parent, int bus, + struct pci_ops *ops, void *sysdata, struct list_head *resources, + struct list_head *in_res) +{ + return pci_create_root_bus_msi(parent, bus, ops, sysdata, + resources, in_res, NULL); +} +EXPORT_SYMBOL_GPL(pci_create_root_bus2); + struct pci_bus *pci_create_root_bus(struct device *parent, int bus, struct pci_ops *ops, void *sysdata, struct list_head *resources) { - return pci_create_root_bus_msi(parent, bus, ops, sysdata, resources, - NULL); + return pci_create_root_bus_msi(parent, bus, ops, sysdata, + resources, NULL, NULL); } EXPORT_SYMBOL_GPL(pci_create_root_bus); @@ -2415,7 +2436,8 @@ struct pci_bus *pci_scan_root_bus_msi(struct device *parent, int bus, break; } - b = pci_create_root_bus_msi(parent, bus, ops, sysdata, resources, msi); + b = pci_create_root_bus_msi(parent, bus, ops, sysdata, + resources, NULL, msi); if (!b) return NULL; diff --git a/include/linux/pci.h b/include/linux/pci.h index 33c2b0b..d2df107 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -432,6 +432,7 @@ struct pci_host_bridge { void *sysdata; int busnr; struct list_head windows; /* resource_entry */ + struct list_head inbound_windows; /* inbound memory */ void (*release_fn)(struct pci_host_bridge *); void *release_data; struct msi_controller *msi;