From patchwork Sat Mar 5 05:11:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lizhi Hou X-Patchwork-Id: 548620 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 25570C433F5 for ; Sat, 5 Mar 2022 05:11:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231174AbiCEFM0 (ORCPT ); Sat, 5 Mar 2022 00:12:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231151AbiCEFM0 (ORCPT ); Sat, 5 Mar 2022 00:12:26 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2065.outbound.protection.outlook.com [40.107.223.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E67A56C1E8; Fri, 4 Mar 2022 21:11:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MeRWOuaZhLj1jryVWj41XnDo1zPop2WSrrQaCOIXieco6SRrBD9Jr0v9H3n1PjJfqSgWs5l8O6AM/hbvfwGuohjwEr3T48w0JsWH1Y3hI7Z0CL0NTuKjoUUWtxjhIRMq3CwC13HHeI0m8nApuE4qf2vcWBb1FknFQSlBScVmZuq+espk0nvwoHK71RC9Q0PWnwiKchrRP+k2TQS568YNZI6KQePlrCRK+cgz/dKuPH3kMdiQli3i3PEFdLRikYwdeGWT94DNixx+4p/xPiY6A80f9RddMbQnaFnDRBYZdU/QCnx4uvrgR7ZnhVGD+1CrOjebOaXc1QYMlN6r0AZ0jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9YaIMcnkqkA7VrLiz5PDiYFwijwL2DpD7MCfhu9ZTGc=; b=DT55FFxOiqq9Uwl4ZbLm6jsEWUEwfqyaKb31dW9IiQW1592UziEUFOdfOhbGQhbUNiaFPrMf2+hcoCKp9Cv0ESCIB2K/MuL1VenU1HqFSAkrY9XZ3s07gw7eTUBukJXnQbwmsPrWkmBZe28u42gvNbkZnaSUZILhj2/GxFrMJQBvstiUTGaz04mig38t3I5/osfYEjtxxDi4edSxUfn8hkpF3j4lX8GO3jQvmwLrCDy63+SxJI2eKjjHTcfFlGxEHy6Q2r8DgIsvOfdYzAmdhITrwX989bFYy9lqdW+UuBW5ihQpQjG8Ah/kl/GnAPCx7YvKYPpbALePaTqK9dB6pg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=infradead.org smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9YaIMcnkqkA7VrLiz5PDiYFwijwL2DpD7MCfhu9ZTGc=; b=h1K0GhZl4MP8p8LEbldvNdQnN2SbQHIaexh6vSRY9NXQ9/i8Sg1pVhZHY/15NRrdo8ztIARceJPC9HfMDHPYuKVhyjOs/6y420iKtA0eO9q3F7YG8uyjhL19vNY9rFnu6IZc1kHmpkamf3NkfcDyk83rS82R9lEwtS4DazX0KDg= Received: from DM5PR06CA0062.namprd06.prod.outlook.com (2603:10b6:3:37::24) by CY4PR02MB2456.namprd02.prod.outlook.com (2603:10b6:903:6b::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.16; Sat, 5 Mar 2022 05:11:34 +0000 Received: from DM3NAM02FT022.eop-nam02.prod.protection.outlook.com (2603:10b6:3:37:cafe::a9) by DM5PR06CA0062.outlook.office365.com (2603:10b6:3:37::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14 via Frontend Transport; Sat, 5 Mar 2022 05:11:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch02.xlnx.xilinx.com; Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by DM3NAM02FT022.mail.protection.outlook.com (10.13.5.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5038.14 via Frontend Transport; Sat, 5 Mar 2022 05:11:33 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Fri, 4 Mar 2022 21:11:32 -0800 Received: from smtp.xilinx.com (172.19.127.95) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Fri, 4 Mar 2022 21:11:32 -0800 Envelope-to: dwmw2@infradead.org, yilun.xu@intel.com, mdf@kernel.org, robh@kernel.org, trix@redhat.com, devicetree@vger.kernel.org, linux-pci@vger.kernel.org Received: from [172.19.72.93] (port=44414 helo=xsj-xw9400.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1nQMhY-0008c2-KP; Fri, 04 Mar 2022 21:11:32 -0800 Received: by xsj-xw9400.xilinx.com (Postfix, from userid 21952) id 4EF8D600197; Fri, 4 Mar 2022 21:11:08 -0800 (PST) From: Lizhi Hou To: , , CC: Lizhi Hou , , , , , , , , , , Max Zhen Subject: [PATCH V1 1/4] pci: add interface to create pci-ep device tree node Date: Fri, 4 Mar 2022 21:11:02 -0800 Message-ID: <20220305051105.725838-2-lizhi.hou@xilinx.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220305051105.725838-1-lizhi.hou@xilinx.com> References: <20220305051105.725838-1-lizhi.hou@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 62ffac46-b71a-476d-6a05-08d9fe669db2 X-MS-TrafficTypeDiagnostic: CY4PR02MB2456:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LXmfiXfzXHDxYUb6NHY5VZr1Mba6efGhQHlhPWz/PbecKGFrc0T21NBsaKy7t7RTHjW9IKrcNptnmrQIG4MyYR+Hi4d0/9szUlOtmYkyLzde1sUl3uXVf9S5xRDNeq2YwMugCZtdwHZxcJbkcGd9X8MSEdFyk7SCcd4zwmiRNfg49KotC34wdLzj2pDoKgRGusi3Kp6huIvalITzqOWzgDYtZRfoNv1BNH/lqZN1viz4xyFTzgJxQc5E71h17XSSMb5WhIsk6S2qdBf/cJNQ7ZW1+ta1DZWLkK9Q8RUwpibhof1sq4UPZJxmrj1UMcbOOSl89GAVprpETnDGOmp2rgviSrsfI4h0GdfMBgNPw4ZwqUIObeLM716EKLO8TMVNLk4QYz8g6v6g5QS9Zjw6UmOgTJxA6Z1klo4+8ZMbHIfsXY6YzeX/jRgeoOT4wddAM95uVB5YDDwX6hJU3hnIsoFURTlBMZeScxerdwHB0i288iy42xMhtA7VnD3/Myrw95syGBH7oaWw99ayp8LrGkB3A4MG7PnOz2hadsp+7kh7Nd7n/pNsIGTIiHy/32chbEl1nAD41MmQsLTms3Cua85xVQV20aDyM1N0/RP6vGurGsLFIjbw5n7VdQ8T9/BLVCT9FM4RROS3ca8CLp7GUg== X-Forefront-Antispam-Report: CIP:149.199.62.198; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:xsj-pvapexch02.xlnx.xilinx.com; PTR:unknown-62-198.xilinx.com; CAT:NONE; SFS:(13230001)(4636009)(36840700001)(46966006)(83380400001)(44832011)(8936002)(42186006)(70586007)(4326008)(70206006)(8676002)(54906003)(36756003)(5660300002)(110136005)(316002)(47076005)(2906002)(7636003)(6666004)(82310400004)(107886003)(2616005)(6266002)(26005)(426003)(1076003)(186003)(36860700001)(336012)(356005)(508600001); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2022 05:11:33.4533 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 62ffac46-b71a-476d-6a05-08d9fe669db2 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.62.198]; Helo=[xsj-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: DM3NAM02FT022.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR02MB2456 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org This patch enables PCIe device to uses flattened device tree to describe apertures in its PCIe BARs. The aperture address consists of PCIe BAR index and offset. For this kind of device, the driver probe routine calls the new added interface to create a device tree node. This device tree node is attached under system device tree root. Then the driver may load the flatten device tree overlay and attach it under this node. And the node also contains 'ranges' property which is used to translate aperture address(BAR index and offset) to CPU address. Signed-off-by: Sonal Santan Signed-off-by: Max Zhen Signed-off-by: Lizhi Hou --- drivers/pci/of.c | 180 +++++++++++++++++++++++++++++++++++++++++ include/linux/of_pci.h | 15 ++++ 2 files changed, 195 insertions(+) diff --git a/drivers/pci/of.c b/drivers/pci/of.c index cb2e8351c2cc..198f08351070 100644 --- a/drivers/pci/of.c +++ b/drivers/pci/of.c @@ -605,6 +605,186 @@ int devm_of_pci_bridge_init(struct device *dev, struct pci_host_bridge *bridge) return pci_parse_request_of_pci_ranges(dev, bridge); } +#if IS_ENABLED(CONFIG_OF_DYNAMIC) + +static void devm_of_pci_destroy_bus_endpoint(struct device *dev, void *res) +{ + struct device_node *node = res; + + of_detach_node(node); +} + +static int of_ep_add_property(struct device *dev, struct property **proplist, const char *name, + const int length, void *value) +{ + struct property *new; + + new = devm_kzalloc(dev, sizeof(*new), GFP_KERNEL); + if (!new) + return -ENOMEM; + + new->name = devm_kstrdup(dev, name, GFP_KERNEL); + if (!new->name) + return -ENOMEM; + + new->value = devm_kmalloc(dev, length, GFP_KERNEL); + if (!new->value) + return -ENOMEM; + + memcpy(new->value, value, length); + new->length = length; + new->next = *proplist; + *proplist = new; + + return 0; +} + +static struct device_node *of_ep_alloc_node(struct pci_dev *pdev, const char *name) +{ + struct device_node *node; + char *full_name; + + node = devres_alloc(devm_of_pci_destroy_bus_endpoint, sizeof(*node), GFP_KERNEL); + if (!node) + return NULL; + + full_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "/%s@%llx", name, + (u64)pci_resource_start(pdev, 0)); + if (!full_name) + return NULL; + + node->parent = of_root; + node->full_name = full_name; + of_node_set_flag(node, OF_DYNAMIC); + of_node_init(node); + + return node; +} + +/** + * devm_of_pci_create_bus_endpoint - Create a device node for the given pci device. + * @pdev: PCI device pointer. + * + * For PCI device which uses flattened device tree to describe apertures in its BARs, + * a device node for the given pci device is required. Then the flattened device tree + * overlay from the device can be applied to the base tree. + * The device node is under root node and act like bus node. It contains a "ranges" + * property which is used for address translation of its children. Each child node + * corresponds an aperture and use BAR index and offset as its address. + + * Returns 0 on success or a negative error-code on failure. + */ +int devm_of_pci_create_bus_endpoint(struct pci_dev *pdev) +{ + struct property *proplist = NULL; + struct device *dev = &pdev->dev; + int range_ncells, addr_ncells; + struct device_node *node; + void *prop = NULL; + u32 *range_cell; + __be32 val; + int i, ret; + + node = of_ep_alloc_node(pdev, "pci-ep-bus"); + if (!node) + return -ENOMEM; + + /* the endpoint node works as 'simple-bus' to translate aperture addresses. */ + prop = "simple-bus"; + ret = of_ep_add_property(dev, &proplist, "compatible", strlen(prop) + 1, prop); + if (ret) + goto cleanup; + + /* The address and size cells of nodes underneath are 2 */ + val = cpu_to_be32(2); + ret = of_ep_add_property(dev, &proplist, "#address-cells", sizeof(u32), &val); + if (ret) + goto cleanup; + + ret = of_ep_add_property(dev, &proplist, "#size-cells", sizeof(u32), &val); + if (ret) + goto cleanup; + + /* child address format: 0xIooooooo oooooooo, I = bar index, o = offset on bar */ + addr_ncells = of_n_addr_cells(node); + if (addr_ncells > 2) { + /* does not support number of address cells greater than 2 */ + ret = -EINVAL; + goto cleanup; + } + + /* range cells include */ + range_ncells = addr_ncells + 4; + prop = kzalloc(range_ncells * sizeof(u32) * PCI_STD_NUM_BARS, GFP_KERNEL); + if (!prop) { + ret = -ENOMEM; + goto cleanup; + } + + range_cell = prop; + for (i = 0; i < PCI_STD_NUM_BARS; i++) { + if (!pci_resource_len(pdev, i)) + continue; + /* highest 4 bits of address are bar index */ + *(__be64 *)range_cell = cpu_to_be64((u64)i << 60); + range_cell += 2; + if (addr_ncells == 2) + *(__be64 *)range_cell = cpu_to_be64((u64)pci_resource_start(pdev, i)); + else + *(__be32 *)range_cell = cpu_to_be32((u32)pci_resource_start(pdev, i)); + + range_cell += addr_ncells; + *(__be64 *)range_cell = cpu_to_be64((u64)pci_resource_len(pdev, i)); + range_cell += 2; + } + + /* error out if there is not PCI BAR been found */ + if ((void *)range_cell == prop) { + ret = -EINVAL; + goto cleanup; + } + + ret = of_ep_add_property(dev, &proplist, "ranges", (void *)range_cell - prop, prop); + kfree(prop); + if (ret) + goto cleanup; + + node->properties = proplist; + ret = of_attach_node(node); + if (ret) + goto cleanup; + + devres_add(dev, node); + + return 0; + +cleanup: + kfree(prop); + if (node) + devres_free(node); + + return ret; +} +EXPORT_SYMBOL_GPL(devm_of_pci_create_bus_endpoint); + +struct device_node *of_pci_find_bus_endpoint(struct pci_dev *pdev) +{ + struct device_node *dn; + char *path; + + path = kasprintf(GFP_KERNEL, "/pci-ep-bus@%llx", + (u64)pci_resource_start(pdev, 0)); + if (!path) + return NULL; + + dn = of_find_node_by_path(path); + kfree(path); + + return dn; +} +EXPORT_SYMBOL_GPL(of_pci_find_bus_endpoint); +#endif /* CONFIG_OF_DYNAMIC */ + #endif /* CONFIG_PCI */ /** diff --git a/include/linux/of_pci.h b/include/linux/of_pci.h index 29658c0ee71f..c1d86be321b2 100644 --- a/include/linux/of_pci.h +++ b/include/linux/of_pci.h @@ -38,4 +38,19 @@ of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin) } #endif +#if IS_ENABLED(CONFIG_OF_DYNAMIC) && IS_ENABLED(CONFIG_PCI) +int devm_of_pci_create_bus_endpoint(struct pci_dev *pdev); +struct device_node *of_pci_find_bus_endpoint(struct pci_dev *pdev); +#else +static inline int devm_of_pci_create_bus_endpoint(struct pci_dev *pdev) +{ + return -EINVAL; +} + +static inline struct device_node *of_pci_find_bus_endpoint(struct pci_dev *pdev) +{ + return NULL; +} +#endif + #endif From patchwork Sat Mar 5 05:23:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lizhi Hou X-Patchwork-Id: 548618 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D591C433F5 for ; Sat, 5 Mar 2022 05:23:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229495AbiCEFYQ (ORCPT ); Sat, 5 Mar 2022 00:24:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230077AbiCEFYQ (ORCPT ); Sat, 5 Mar 2022 00:24:16 -0500 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam07on2077.outbound.protection.outlook.com [40.107.95.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82104162000; Fri, 4 Mar 2022 21:23:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SWjBcEQg3CaG6xasRYSpAak9G2SlMC+8pdEFGj+Vy7YvRiouW/tOVPrE4/C+PCA3y0xm7I+w/nmhtXf3MQTdR5mNRTQuAt8Tt4LyzsJCmsYkka+B293tf13+D5KJyJCzf48WI1ZMbl/LSJ9iD1BHL9T6U2MOwSnEktPv6ZbUtTnc2mmzClQ5j5IhzOUrSz91f6G/CvLDhh847bDHgpEC3M8rm2IfJXGu3Yan3M9VjU7MRGoP7EFovsVTS2NYAONFdG6l+qovBgBUt5y8dICUJ0svZLt/lYuoEA6SIG4Gh3Oz6hyCARkaSJVqjsNdcxK1xRvbVliD0lFufXDIFAUIcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=F+LJXBmaDbKZVsVzVqhgP5YWio/nOvHhdeAjOWMBEy0=; b=KofJA+cecRHBROGLCfuIq5JeohANZeTHJnxpOlXCw/eERyIX7xNrBiHJAH6uXXpNZFC4Wf3VxmiUXlq067dDT/WkE+usV/dBAdxyD25nH6qMI9V2fVlOaEYbuK8rkHVVZKdjBNkZrrNnBKEK3Gg8SJ2qbx3/PB5ySJvlfkEwj8PXpXi3ig3/jgRz/WHkzhZPa+dyvgDL/uB4bqH40g0C9qxGug32P5ib/1DG2GFa4VBZkPi9fo7N2HBq+/ynrp4i/8iqjHilDk3d84SYgU+NXUmh088V4orV4GVgIydQz8ugrMwETlJI6o5SFCRapgCslBaI1RZSeVJS6yBSjV2mUg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=infradead.org smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=F+LJXBmaDbKZVsVzVqhgP5YWio/nOvHhdeAjOWMBEy0=; b=jfSvIQ0qKWz/FK/QSh444wAp/eS/4XGFP/+ihjDL5j7dPec/Js5hq0BXY5Nd55RiNwYFrzWRNkX+0XpDRDzdK89MF2UI+SzQjc8ElUS0Yauoeb3GSR0/+PfiDSLbsAYyQo6ePEDmBU/oP64wOHbL3zNOm8JYrHtdJlto+TT1YqU= Received: from SA0PR11CA0014.namprd11.prod.outlook.com (2603:10b6:806:d3::19) by BN8PR02MB5906.namprd02.prod.outlook.com (2603:10b6:408:ba::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14; Sat, 5 Mar 2022 05:23:23 +0000 Received: from SN1NAM02FT0064.eop-nam02.prod.protection.outlook.com (2603:10b6:806:d3:cafe::4f) by SA0PR11CA0014.outlook.office365.com (2603:10b6:806:d3::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14 via Frontend Transport; Sat, 5 Mar 2022 05:23:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch01.xlnx.xilinx.com; Received: from xsj-pvapexch01.xlnx.xilinx.com (149.199.62.198) by SN1NAM02FT0064.mail.protection.outlook.com (10.97.4.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5038.14 via Frontend Transport; Sat, 5 Mar 2022 05:23:23 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch01.xlnx.xilinx.com (172.19.86.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Fri, 4 Mar 2022 21:23:22 -0800 Received: from smtp.xilinx.com (172.19.127.95) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Fri, 4 Mar 2022 21:23:22 -0800 Envelope-to: dwmw2@infradead.org, yilun.xu@intel.com, mdf@kernel.org, robh@kernel.org, trix@redhat.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Received: from [172.19.72.93] (port=44428 helo=xsj-xw9400.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1nQMt0-000BYJ-DR; Fri, 04 Mar 2022 21:23:22 -0800 Received: by xsj-xw9400.xilinx.com (Postfix, from userid 21952) id 08BB0600131; Fri, 4 Mar 2022 21:23:09 -0800 (PST) From: Lizhi Hou To: , , CC: Lizhi Hou , , , , , , , , , , , Max Zhen Subject: [PATCH V1 RESEND 2/4] Documentation: devicetree: bindings: add binding for PCIe endpoint bus Date: Fri, 4 Mar 2022 21:23:02 -0800 Message-ID: <20220305052304.726050-3-lizhi.hou@xilinx.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220305052304.726050-1-lizhi.hou@xilinx.com> References: <20220305052304.726050-1-lizhi.hou@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e5a47673-2634-41f9-466c-08d9fe6844b3 X-MS-TrafficTypeDiagnostic: BN8PR02MB5906:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nj8c0R4+gafCeAD4nIcAAfohLbpMAjVVG3aiau3z+yv1VzfL+vCQRkSefkiPDdSuaBdpkb3y2FW0/y1XDgZhD2d9qZqm8BvDWVz2SSTtG/6b1GUnmfeROCxg5myICXR96HWIhuGo2+X0NcHXbCwMCxcTkwudVwnuRAkNK5QF9Bbxyz45l8W+KVmvm/lolitBLdAswa0/zIWCQi2mAF3jEcfx/itqio1aRA4uxYy6iX+bgs0DIwGHqhWx0SuYeMx78AS/ENJ4Hd5UES6PL6BxUZ0MMJJtrYbH03X1g+wsrdE3AAouKuDTy2DQn6X6W7cCUlcoPiTPjkwwrkN4MRGXrlIx9MMM3ODaNJwMbEL5E+Qo5kxc8wgSxuR0Ns9Z2cfGDIywjROKG4FoI8f5f+eb899So18B+GH6P2FtwdSv/oNHNU67wrLDZVw6h2RiB42EhQ8zXR8fFlKfUf4kQBDeWlVJVf/enK8HftlcRvVegd/hOzMsw8FiE/Kt+bjo9nuMC8NS049TnJJ/gDRKkNDmmqhshjtdvaCmVK8G3rZJNxrUyl9GWaWgZY6LB0YXiep5ghl5mleU5SH0C55hmDsbvYebfUO+oLuNzk7T2NnGlNkvc4psubaB3a+CDfjMmItei7zPst0n2ue3ko33PAh6fdt76esCn9azBf1iRr0cmFn+QuzyIRlqng3HW5eGCfNgeczx0Q6BL64Td123ZR7qHWzolN9dY+137/RyJGgqJXtZKyax41eS9G/jqkGiO1VAmjEHH59foyST2+qbKwOAdg== X-Forefront-Antispam-Report: CIP:149.199.62.198; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:xsj-pvapexch01.xlnx.xilinx.com; PTR:unknown-62-198.xilinx.com; CAT:NONE; SFS:(13230001)(4636009)(36840700001)(46966006)(82310400004)(2906002)(36860700001)(70586007)(966005)(47076005)(508600001)(4326008)(8676002)(26005)(186003)(6266002)(8936002)(356005)(107886003)(42186006)(36756003)(7636003)(70206006)(110136005)(44832011)(54906003)(2616005)(1076003)(426003)(5660300002)(6666004)(336012)(316002); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2022 05:23:23.1351 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e5a47673-2634-41f9-466c-08d9fe6844b3 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.62.198]; Helo=[xsj-pvapexch01.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: SN1NAM02FT0064.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR02MB5906 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Create device tree binding document for PCIe endpoint bus. Signed-off-by: Sonal Santan Signed-off-by: Max Zhen Signed-off-by: Lizhi Hou --- .../devicetree/bindings/bus/pci-ep-bus.yaml | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 Documentation/devicetree/bindings/bus/pci-ep-bus.yaml diff --git a/Documentation/devicetree/bindings/bus/pci-ep-bus.yaml b/Documentation/devicetree/bindings/bus/pci-ep-bus.yaml new file mode 100644 index 000000000000..0ca96298db6f --- /dev/null +++ b/Documentation/devicetree/bindings/bus/pci-ep-bus.yaml @@ -0,0 +1,72 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/bus/pci-ep-bus.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: PCIe Endpoint Bus binding + +description: | + PCIe device may use flattened device tree to describe apertures in its + PCIe BARs. The Bus PCIe endpoint node is created and attached under the + device tree root node for this kind of device. Then the flatten device + tree overlay for this device is attached under the endpoint node. + + The aperture address which is under the endpoint node consists of BAR + index and offset. It uses the following encoding: + + 0xIooooooo 0xoooooooo + + Where: + + I = BAR index + oooooo oooooooo = BAR offset + + The endpoint is compatible with 'simple-bus' and contains 'ranges' + property for translating aperture address to CPU address. + +allOf: + - $ref: /schemas/simple-bus.yaml# + +maintainers: + - Lizhi Hou + +properties: + compatible: + contains: + const: pci-ep-bus + + "#address-cells": + const: 2 + + "#size-cells": + const: 2 + + ranges: true + +patternProperties: + "^.*@[0-9a-f]+$": + description: hardware apertures belong to this device. + type: object + +required: + - compatible + - "#address-cells" + - "#size-cells" + - ranges + +additionalProperties: false + +examples: + - | + bus { + #address-cells = <2>; + #size-cells = <2>; + pci-ep-bus@e0000000 { + compatible = "pci-ep-bus", "simple-bus"; + #address-cells = <2>; + #size-cells = <2>; + ranges = <0x0 0x0 0x0 0xe0000000 0x0 0x2000000 + 0x20000000 0x0 0x0 0xe4200000 0x0 0x40000>; + }; + }; From patchwork Sat Mar 5 05:11:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lizhi Hou X-Patchwork-Id: 548619 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A861C433EF for ; Sat, 5 Mar 2022 05:13:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229938AbiCEFNs (ORCPT ); Sat, 5 Mar 2022 00:13:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229526AbiCEFNr (ORCPT ); Sat, 5 Mar 2022 00:13:47 -0500 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam08on2062.outbound.protection.outlook.com [40.107.101.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3571A6328; Fri, 4 Mar 2022 21:12:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nX844+PonHnfTa4XVygu3trYQYOtWs9KjTssq4LM40JaJLczQ/s9ZvXZUUvKY9PTwZaBiq9NVYYLN63kOTsHiIl92ySpNU43rBqCqz9KeB/SwzwcQt/bGOda9+gsF2hAlz1PWzKXq9C+3M5WnF1xVqSdew7tfR8UoEOHHbW6a8cg5jKmYKcF8uVWXaPSjcAimcAs6xVQSGyVQkOnjwJmeqHHmEfOc9e8k6/rqoLpnwe/kt4Zm5hajrCNRp9FGl+fzjTqdQ/Cd8epCNKsydMTzZfGtyZn0Cx9i3JawFHUgX6CxQfUWlMm54UaDEhBSugpdAf1hEk04LvDYqSHo+/RbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Gc0SpTpdIrx0OGld9RoOfkU9CGjX+wp30x6rP3/Av+Q=; b=TR0+fKr8D4gDgJYtQkNfO9HuG34aISs7sKP+lpQTpKsJPrPaNDMq7NX3/0LKqbFWDG7gT2ziFyncjMW9Vc+MEOPKW6lwbJQAECY3bjv/sqBjHpTVa9/i39GiLowbKUD3ITU87usAJ1EjLDrt8ArFYOEM7/pSXlHK0JrNdottfjT7O+5kTGmvIw/OBftdgNp+vdpKdrJBaNVicpjlljg86AGjYWqPA6txGHO6Yq6vI5YJh5zoPOoaXlLwYPXw0cYw2CmOFbCbzIDnhN2ymFA+EGJJaFsWzkw5U1W4Ky9OvInObszMG4ADXGl8R9d43izZymym9fUz4l6HnEi9/bfJWQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=infradead.org smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Gc0SpTpdIrx0OGld9RoOfkU9CGjX+wp30x6rP3/Av+Q=; b=s+b+6CCe3po8CWSWAKcZhp9hkHXj2myEOJqon4oqYk4uUG8DIeCyHsjl3Jtx/DX97PflXIPiYBwNWzg7Dl1U6NTpgE4nTL4Ym9lsrG39Olh4hAHJHVwJyvrwSuwpRhcWJVno12ZRbDbWnWXxtaOw6mj07o34ccmCtXpw1IJjsto= Received: from DM5PR13CA0032.namprd13.prod.outlook.com (2603:10b6:3:7b::18) by DM6PR02MB3929.namprd02.prod.outlook.com (2603:10b6:5:9f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14; Sat, 5 Mar 2022 05:12:53 +0000 Received: from DM3NAM02FT003.eop-nam02.prod.protection.outlook.com (2603:10b6:3:7b:cafe::d9) by DM5PR13CA0032.outlook.office365.com (2603:10b6:3:7b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5061.7 via Frontend Transport; Sat, 5 Mar 2022 05:12:53 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch02.xlnx.xilinx.com; Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by DM3NAM02FT003.mail.protection.outlook.com (10.13.4.168) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5038.14 via Frontend Transport; Sat, 5 Mar 2022 05:12:53 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Fri, 4 Mar 2022 21:11:56 -0800 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Fri, 4 Mar 2022 21:11:56 -0800 Envelope-to: dwmw2@infradead.org, yilun.xu@intel.com, mdf@kernel.org, robh@kernel.org, trix@redhat.com, devicetree@vger.kernel.org, linux-pci@vger.kernel.org Received: from [172.19.72.93] (port=44418 helo=xsj-xw9400.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1nQMhw-000GyI-NO; Fri, 04 Mar 2022 21:11:56 -0800 Received: by xsj-xw9400.xilinx.com (Postfix, from userid 21952) id 755CA60019A; Fri, 4 Mar 2022 21:11:08 -0800 (PST) From: Lizhi Hou To: , , CC: Lizhi Hou , , , , , , , , , , Max Zhen Subject: [PATCH V1 3/4] fpga: xrt: management physical function driver Date: Fri, 4 Mar 2022 21:11:04 -0800 Message-ID: <20220305051105.725838-4-lizhi.hou@xilinx.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220305051105.725838-1-lizhi.hou@xilinx.com> References: <20220305051105.725838-1-lizhi.hou@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 68b07a5f-d7ee-4c56-99c4-08d9fe66cd58 X-MS-TrafficTypeDiagnostic: DM6PR02MB3929:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ECYFXmlrDL4T+ZHNf7PdAPbYqoEMwn0NQ+4aGcMTOwo7OwbcC9ymlrKlGoEydaLxqoq5iFuxVmxNUb7YjCJovLcCM7k0sBGxnd3FERD0u1ZgIFjaS+c7jqdRRq5tUstFo/txRdS1dxHaV2UdbZ33XYVi7IpAR4mQa1U1gG2W+BAFBOJc1V2Ch1xMbfghBHhSCtYiaSSDYEJv0GOimF5Ws1qDpxTE8H9J0gf0WFLjAZZesZkR8C6lV9zvZSbvNbdvM5XXeIvM/aqAcz8WTjTM+aM+vHumzz/2x3Hv1i999ZeFM4Gn/ws2kI2qjo5FGU8jz5/naEUOwn9aI+XJU4m1F8cOcI5VJ6m5xIFpFqV1aoclOPIzU3pe+GOxdYB4quKw02BJNWEPQR7JBgE7orbHwStcC0It8OnbFYO+cqeFYiKKCVegE7QIuKjdAx3ZGU6Ds0Yb89+1eC5KDE32KcEReiiOBWby79Qkw/pitE2YtiWtQkKlN03DSkFbOOKAo7PqRNGAAVQQVDBcUqkHpIP9iM/5kszqzYk2KImYp2lmlxUXwVQHTFzv9dppUf+5YqtN6OHL8H8KlZta4pWoalSKIomRPzpUHNmkJyq/zJsEuLLa9Fw1ShKoqgLComeEpZMk1qzrKTBGCAYolV0z1uhR0A== X-Forefront-Antispam-Report: CIP:149.199.62.198; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:xsj-pvapexch02.xlnx.xilinx.com; PTR:unknown-62-198.xilinx.com; CAT:NONE; SFS:(13230001)(4636009)(36840700001)(46966006)(70586007)(4326008)(8676002)(508600001)(36756003)(316002)(47076005)(36860700001)(83380400001)(70206006)(7636003)(336012)(8936002)(356005)(6666004)(6266002)(26005)(186003)(42186006)(426003)(107886003)(5660300002)(1076003)(2616005)(44832011)(110136005)(82310400004)(54906003)(2906002); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2022 05:12:53.3953 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 68b07a5f-d7ee-4c56-99c4-08d9fe66cd58 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.62.198]; Helo=[xsj-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: DM3NAM02FT003.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR02MB3929 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The PCIe device driver which attaches to management function on Alveo devices. The first version of this driver demonstrates calling PCIe interface to create device tree node. Signed-off-by: Sonal Santan Signed-off-by: Max Zhen Signed-off-by: Lizhi Hou --- drivers/fpga/Kconfig | 3 ++ drivers/fpga/Makefile | 3 ++ drivers/fpga/xrt/Kconfig | 24 ++++++++++++ drivers/fpga/xrt/Makefile | 8 ++++ drivers/fpga/xrt/mgmt/Makefile | 12 ++++++ drivers/fpga/xrt/mgmt/xmgmt-drv.c | 63 +++++++++++++++++++++++++++++++ 6 files changed, 113 insertions(+) create mode 100644 drivers/fpga/xrt/Kconfig create mode 100644 drivers/fpga/xrt/Makefile create mode 100644 drivers/fpga/xrt/mgmt/Makefile create mode 100644 drivers/fpga/xrt/mgmt/xmgmt-drv.c diff --git a/drivers/fpga/Kconfig b/drivers/fpga/Kconfig index 991b3f361ec9..93ae387c97c5 100644 --- a/drivers/fpga/Kconfig +++ b/drivers/fpga/Kconfig @@ -243,4 +243,7 @@ config FPGA_MGR_VERSAL_FPGA configure the programmable logic(PL). To compile this as a module, choose M here. + +source "drivers/fpga/xrt/Kconfig" + endif # FPGA diff --git a/drivers/fpga/Makefile b/drivers/fpga/Makefile index 0bff783d1b61..81ea43c40c64 100644 --- a/drivers/fpga/Makefile +++ b/drivers/fpga/Makefile @@ -49,3 +49,6 @@ obj-$(CONFIG_FPGA_DFL_NIOS_INTEL_PAC_N3000) += dfl-n3000-nios.o # Drivers for FPGAs which implement DFL obj-$(CONFIG_FPGA_DFL_PCI) += dfl-pci.o + +# XRT drivers for Xilinx Alveo platforms +obj-$(CONFIG_FPGA_XRT) += xrt/ diff --git a/drivers/fpga/xrt/Kconfig b/drivers/fpga/xrt/Kconfig new file mode 100644 index 000000000000..47efc8f71cec --- /dev/null +++ b/drivers/fpga/xrt/Kconfig @@ -0,0 +1,24 @@ + +# XRT Alveo FPGA device configuration +# + +config FPGA_XRT + tristate "XRT Alveo Drivers" + depends on OF + select OF_EMPTY_ROOT + select OF_OVERLAY + help + Select this option to enable Xilinx XRT Alveo drivers. Xilinx Alveo + card is PCIe device and has two PCIe functions. The first function + performs board manangement and XRT management driver will be attached + to it. The second function performs data movement, compute unit + scheduling etc. And an XRT user driver will be attached to it. + +config FPGA_XRT_XMGMT + tristate "Xilinx Alveo Management Driver" + depends on FPGA_XRT + help + Select this option to enable XRT PCIe driver for Xilinx Alveo FPGA. + This driver provides interfaces for userspace application to access + Alveo FPGA device, such as: downloading FPGA bitstream, query card + information, hot reset card etc. diff --git a/drivers/fpga/xrt/Makefile b/drivers/fpga/xrt/Makefile new file mode 100644 index 000000000000..2d251b5653bb --- /dev/null +++ b/drivers/fpga/xrt/Makefile @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Copyright (C) 2020-2022 Xilinx, Inc. All rights reserved. +# +# Authors: Lizhi.Hou@xilinx.com +# + +obj-$(CONFIG_FPGA_XRT_XMGMT) += mgmt/ diff --git a/drivers/fpga/xrt/mgmt/Makefile b/drivers/fpga/xrt/mgmt/Makefile new file mode 100644 index 000000000000..b893c7293d70 --- /dev/null +++ b/drivers/fpga/xrt/mgmt/Makefile @@ -0,0 +1,12 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Copyright (C) 2020-2022 Xilinx, Inc. All rights reserved. +# +# Authors: Sonal.Santan@xilinx.com +# Lizhi.Hou@xilinx.com +# + +obj-$(CONFIG_FPGA_XRT_XMGMT) += xrt-mgmt.o + +xrt-mgmt-objs := \ + xmgmt-drv.o diff --git a/drivers/fpga/xrt/mgmt/xmgmt-drv.c b/drivers/fpga/xrt/mgmt/xmgmt-drv.c new file mode 100644 index 000000000000..60742a478a43 --- /dev/null +++ b/drivers/fpga/xrt/mgmt/xmgmt-drv.c @@ -0,0 +1,63 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Xilinx Alveo Management Function Driver + * + * Copyright (C) 2020-2022 Xilinx, Inc. + * + * Authors: + * Cheng Zhen + * Lizhi Hou + */ + +#include +#include +#include +#include +#include +#include + +#define XMGMT_MODULE_NAME "xrt-mgmt" + +/* PCI Device IDs */ +#define PCI_DEVICE_ID_U50 0x5020 +static const struct pci_device_id xmgmt_pci_ids[] = { + { PCI_DEVICE(PCI_VENDOR_ID_XILINX, PCI_DEVICE_ID_U50), }, /* Alveo U50 */ + { 0, } +}; + +static int xmgmt_probe(struct pci_dev *pdev, const struct pci_device_id *id) +{ + devm_of_pci_create_bus_endpoint(pdev); + + return 0; +} + +static struct pci_driver xmgmt_driver = { + .name = XMGMT_MODULE_NAME, + .id_table = xmgmt_pci_ids, + .probe = xmgmt_probe, +}; + +static int __init xmgmt_init(void) +{ + int res; + + res = pci_register_driver(&xmgmt_driver); + if (res) + return res; + + return 0; +} + +static __exit void xmgmt_exit(void) +{ + pci_unregister_driver(&xmgmt_driver); +} + +module_init(xmgmt_init); +module_exit(xmgmt_exit); + +MODULE_DEVICE_TABLE(pci, xmgmt_pci_ids); +MODULE_AUTHOR("XRT Team "); +MODULE_DESCRIPTION("Xilinx Alveo management function driver"); +MODULE_LICENSE("GPL v2"); From patchwork Sat Mar 5 05:23:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lizhi Hou X-Patchwork-Id: 548617 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16070C433EF for ; Sat, 5 Mar 2022 05:23:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231178AbiCEFYn (ORCPT ); Sat, 5 Mar 2022 00:24:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231276AbiCEFYl (ORCPT ); Sat, 5 Mar 2022 00:24:41 -0500 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2074.outbound.protection.outlook.com [40.107.237.74]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E33FA1965C1; Fri, 4 Mar 2022 21:23:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FH20IXb/zSitqlUDKnsLFRks7//jU7eyQPPAw1W3LBNrPsFYq/vdjCoSlY1zU8poN8MDnqnzksfgB0U7X0oxb9KAE56pb9/fxoN6q8GeXZ+GPiLkWPrEc4co0wS262NBAc7cyPZBj2/t/w4yc5k1mQys/hSIvvOUe9Xg9ymbIpH7ePnt+CqSqzAg6z8I8MnUAk1Cq6rw9WoGYdTgfM4bwIVDrjxA+aaP20lXojXmFElQCW85tjbui5mzxNJ8BKjsH3CjT8RrNvLz9/Ad50nj1OwK0MEhKEe1EW24NRRZRtlaQ6QUbu7uDhMfdTtQX+Fi9jzBEu+08U6LSnRMVFcz+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qdmgBRgPiavesm0saAo05tNSNGEzTR1CbgfRdTnIAxc=; b=FRKlAjMlE0K15dvmgYatdQjAfG/YmXbYuO/gcmTyUNOYkRNWDDWNcmSF9KeqTA/dfS1G4iXCiNoz8L35wd69LPPZvt0vzeVv2Z6ElBO95Gp52gcX9CzmpkMHAdhodmLKuS5rBz+h3ldHFA9h1dNqOnYzj5PfnJaAn2CG3XJpy/cET9j3FJ9z3p2U0cu6W0beXULJ7aj2zzcv93siij9cGwsfLo7mTxw9Y8PsrMxw9TV5YhdRMVnFPhCsixNJRZ5YA9AB6GtCVH2zpfAL6cYMHJgXqw3Ytb0J/SNXlpX+V5u/GLQvypMxtABArK4vMr4AJixFc546CGKYx5YqMP0whg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=infradead.org smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qdmgBRgPiavesm0saAo05tNSNGEzTR1CbgfRdTnIAxc=; b=Acwv36unsXQUpRPfGRFoc5c5+CokFICwBAgBayKD0WssRPon6V7fc301ONbNXa2yBdcIkVwTvioCwJJi4O5dPL7Giq8HTlXWVYN2MDgOlyVt2rB0QQchhrqVGmVvhw538LTfVc5jVh0rSOHQVDpeY9t2dQ/F8EohQJ9T/jLdHhQ= Received: from SA9PR11CA0006.namprd11.prod.outlook.com (2603:10b6:806:6e::11) by PH0PR02MB8730.namprd02.prod.outlook.com (2603:10b6:510:d9::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.15; Sat, 5 Mar 2022 05:23:47 +0000 Received: from SN1NAM02FT0043.eop-nam02.prod.protection.outlook.com (2603:10b6:806:6e:cafe::40) by SA9PR11CA0006.outlook.office365.com (2603:10b6:806:6e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14 via Frontend Transport; Sat, 5 Mar 2022 05:23:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch02.xlnx.xilinx.com; Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by SN1NAM02FT0043.mail.protection.outlook.com (10.97.5.57) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5038.14 via Frontend Transport; Sat, 5 Mar 2022 05:23:47 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Fri, 4 Mar 2022 21:23:46 -0800 Received: from smtp.xilinx.com (172.19.127.95) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Fri, 4 Mar 2022 21:23:46 -0800 Envelope-to: dwmw2@infradead.org, yilun.xu@intel.com, mdf@kernel.org, robh@kernel.org, trix@redhat.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Received: from [172.19.72.93] (port=44432 helo=xsj-xw9400.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1nQMtO-000BZ8-Lt; Fri, 04 Mar 2022 21:23:46 -0800 Received: by xsj-xw9400.xilinx.com (Postfix, from userid 21952) id 39BAE600196; Fri, 4 Mar 2022 21:23:10 -0800 (PST) From: Lizhi Hou To: , , CC: Lizhi Hou , , , , , , , , , , , Max Zhen Subject: [PATCH V1 RESEND 4/4] of: enhance overlay applying interface to specific target base node Date: Fri, 4 Mar 2022 21:23:04 -0800 Message-ID: <20220305052304.726050-5-lizhi.hou@xilinx.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220305052304.726050-1-lizhi.hou@xilinx.com> References: <20220305052304.726050-1-lizhi.hou@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f8381eb2-dc22-4284-8d3e-08d9fe6852fa X-MS-TrafficTypeDiagnostic: PH0PR02MB8730:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6hmkloC6VHpLZ7F6CCoi3iozinOWw66Rsthi+kfo6gVro2Nmhw170UOXVnGrPv42WNUNOJWo45uH7BZ7ku6yZ3loNWpGEwxysVPIaKWTVGwCKRL/1uRYGUXZiZp2n9lZbu45SvJrUMwVsT7yzJvRFxeZ6Q/DREFzU7qxWMT6mp9sISoIFAmGvx2gNxThjyv3naa1pBQ+NpPmkmUUxvHxwMI4GJa2zCJD+kxxNI0kiKVzdUebm4ugRuMM+5Dr+RMNsCiPpa34fZmyJHvM7RMaqaQ82ihgncIAlZVvf77zaJ87W51PWRY1Wu4yp55xnD1zjse8L/hFA6eM3ekOVrI7D3zvCOLjp5g48LNRhFioE7IEX4g1XYCmc1KUki7f7tyRMnDk6OW9KJVQTMcThYeVfFEOmziOj2l7yw6Zkh9J1qYCnXK+nMGJZG4naBt7HXfrMY7C25cvG0ILpcNBPu76v/We3aS50LEGYzxK5AChG3mpPzov9waBZf4APSfERmqLGaxGev8GNCMLozwtm1yTfH4gORWlStNBi+QWMtnDx6APWYtXx75QnOzVFvR3dGFUrPSGuHK3Q+RY3Uu+UaEBZKBVP66KubV7aAjJwbjxyVoMMvPufnCwtDTniePGc7HBirvkXplhbpCNuix45sZKww== X-Forefront-Antispam-Report: CIP:149.199.62.198; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:xsj-pvapexch02.xlnx.xilinx.com; PTR:unknown-62-198.xilinx.com; CAT:NONE; SFS:(13230001)(4636009)(46966006)(36840700001)(336012)(426003)(83380400001)(5660300002)(2906002)(42186006)(7636003)(36756003)(26005)(44832011)(6266002)(356005)(1076003)(8936002)(186003)(107886003)(2616005)(8676002)(508600001)(70206006)(70586007)(110136005)(54906003)(82310400004)(36860700001)(47076005)(4326008)(316002)(6666004); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2022 05:23:47.1060 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f8381eb2-dc22-4284-8d3e-08d9fe6852fa X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.62.198]; Helo=[xsj-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: SN1NAM02FT0043.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR02MB8730 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The self discovered device, e.g. PCIe device, may carry a device tree overlay to describe its downstream devices. In this case, the device node is created dynamically by device driver. And in the overlay it does not specify a fixed target path. Instead, a relative path to the device node is specified. Thus, a new parameter is added to overlay applying interface. This parameter is the pointer of target base node. Then the entire overlay target path is target base node path plus the relative path specified in the device tree overlay. Signed-off-by: Sonal Santan Signed-off-by: Max Zhen Signed-off-by: Lizhi Hou --- drivers/fpga/xrt/mgmt/Makefile | 1 + drivers/fpga/xrt/mgmt/dt-test.dts | 15 ++++++++++ drivers/fpga/xrt/mgmt/dt-test.h | 15 ++++++++++ drivers/fpga/xrt/mgmt/xmgmt-drv.c | 41 +++++++++++++++++++++++++++- drivers/gpu/drm/rcar-du/rcar_du_of.c | 2 +- drivers/of/overlay.c | 37 +++++++++++++++++-------- drivers/of/unittest.c | 2 +- include/linux/of.h | 2 +- 8 files changed, 100 insertions(+), 15 deletions(-) create mode 100644 drivers/fpga/xrt/mgmt/dt-test.dts create mode 100644 drivers/fpga/xrt/mgmt/dt-test.h diff --git a/drivers/fpga/xrt/mgmt/Makefile b/drivers/fpga/xrt/mgmt/Makefile index b893c7293d70..a87ab1f6b403 100644 --- a/drivers/fpga/xrt/mgmt/Makefile +++ b/drivers/fpga/xrt/mgmt/Makefile @@ -9,4 +9,5 @@ obj-$(CONFIG_FPGA_XRT_XMGMT) += xrt-mgmt.o xrt-mgmt-objs := \ + dt-test.dtb.o \ xmgmt-drv.o diff --git a/drivers/fpga/xrt/mgmt/dt-test.dts b/drivers/fpga/xrt/mgmt/dt-test.dts new file mode 100644 index 000000000000..3bc3d0c95180 --- /dev/null +++ b/drivers/fpga/xrt/mgmt/dt-test.dts @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: GPL-2.0 +/dts-v1/; + +/ { + fragment@0 { + target-path=""; + __overlay__ { + pr_isolate_ulp@0,41000 { + compatible = "xlnx,alveo-pr-isolation"; + reg = <0x0 0x41000 0x0 0x1000>; + }; + }; + }; +}; + diff --git a/drivers/fpga/xrt/mgmt/dt-test.h b/drivers/fpga/xrt/mgmt/dt-test.h new file mode 100644 index 000000000000..dee0de570c8a --- /dev/null +++ b/drivers/fpga/xrt/mgmt/dt-test.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2020-2022 Xilinx, Inc. + * + * Authors: + * Lizhi Hou + */ + +#ifndef _DT_TEST_H_ +#define _DT_TEST_H_ + +extern u8 __dtb_dt_test_begin[]; +extern u8 __dtb_dt_test_end[]; + +#endif /* _DT_TEST_H_ */ diff --git a/drivers/fpga/xrt/mgmt/xmgmt-drv.c b/drivers/fpga/xrt/mgmt/xmgmt-drv.c index 60742a478a43..54078ffe37fe 100644 --- a/drivers/fpga/xrt/mgmt/xmgmt-drv.c +++ b/drivers/fpga/xrt/mgmt/xmgmt-drv.c @@ -14,8 +14,11 @@ #include #include #include +#include #include +#include "dt-test.h" + #define XMGMT_MODULE_NAME "xrt-mgmt" /* PCI Device IDs */ @@ -25,17 +28,53 @@ static const struct pci_device_id xmgmt_pci_ids[] = { { 0, } }; +struct xmgmt { + int ovcs_id; +}; + static int xmgmt_probe(struct pci_dev *pdev, const struct pci_device_id *id) { - devm_of_pci_create_bus_endpoint(pdev); + struct device_node *dn; + struct xmgmt *xm; + int ret; + + xm = devm_kzalloc(&pdev->dev, sizeof(*xm), GFP_KERNEL); + if (!xm) + return -ENOMEM; + pci_set_drvdata(pdev, xm); + + ret = devm_of_pci_create_bus_endpoint(pdev); + if (ret) + return ret; + + dn = of_pci_find_bus_endpoint(pdev); + if (!dn) { + dev_err(&pdev->dev, "does not find bus endpoint"); + return -EINVAL; + } + + ret = of_overlay_fdt_apply(__dtb_dt_test_begin, + (u32)(__dtb_dt_test_end - __dtb_dt_test_begin), + &xm->ovcs_id, dn); + of_node_put(dn); + if (ret) + return ret; return 0; } +static void xmgmt_remove(struct pci_dev *pdev) +{ + struct xmgmt *xm = pci_get_drvdata(pdev); + + of_overlay_remove(&xm->ovcs_id); +} + static struct pci_driver xmgmt_driver = { .name = XMGMT_MODULE_NAME, .id_table = xmgmt_pci_ids, .probe = xmgmt_probe, + .remove = xmgmt_remove, }; static int __init xmgmt_init(void) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_of.c b/drivers/gpu/drm/rcar-du/rcar_du_of.c index afef69669bb4..8799ed235f83 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_of.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_of.c @@ -60,7 +60,7 @@ static int __init rcar_du_of_apply_overlay(const struct rcar_du_of_overlay *dtbs ovcs_id = 0; return of_overlay_fdt_apply(dtb->begin, dtb->end - dtb->begin, - &ovcs_id); + &ovcs_id, NULL); } static int __init rcar_du_of_add_property(struct of_changeset *ocs, diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c index d80160cf34bb..4d192dff5055 100644 --- a/drivers/of/overlay.c +++ b/drivers/of/overlay.c @@ -686,9 +686,11 @@ static int build_changeset(struct overlay_changeset *ovcs) * 1) "target" property containing the phandle of the target * 2) "target-path" property containing the path of the target */ -static struct device_node *find_target(struct device_node *info_node) +static struct device_node *find_target(struct device_node *info_node, + struct device_node *target_base) { struct device_node *node; + char *target_path; const char *path; u32 val; int ret; @@ -704,10 +706,23 @@ static struct device_node *find_target(struct device_node *info_node) ret = of_property_read_string(info_node, "target-path", &path); if (!ret) { - node = of_find_node_by_path(path); - if (!node) - pr_err("find target, node: %pOF, path '%s' not found\n", - info_node, path); + if (target_base) { + target_path = kasprintf(GFP_KERNEL, "%pOF%s", target_base, path); + if (!target_path) + return NULL; + node = of_find_node_by_path(target_path); + if (!node) { + pr_err("find target, node: %pOF, path '%s' not found\n", + info_node, target_path); + } + kfree(target_path); + } else { + node = of_find_node_by_path(path); + if (!node) { + pr_err("find target, node: %pOF, path '%s' not found\n", + info_node, path); + } + } return node; } @@ -730,7 +745,7 @@ static struct device_node *find_target(struct device_node *info_node) * detected in @tree, or -ENOSPC if idr_alloc() error. */ static int init_overlay_changeset(struct overlay_changeset *ovcs, - const void *fdt, struct device_node *tree) + const void *fdt, struct device_node *tree, struct device_node *target_base) { struct device_node *node, *overlay_node; struct fragment *fragment; @@ -792,7 +807,7 @@ static int init_overlay_changeset(struct overlay_changeset *ovcs, fragment = &fragments[cnt]; fragment->overlay = overlay_node; - fragment->target = find_target(node); + fragment->target = find_target(node, target_base); if (!fragment->target) { of_node_put(fragment->overlay); ret = -EINVAL; @@ -914,7 +929,7 @@ static void free_overlay_changeset(struct overlay_changeset *ovcs) */ static int of_overlay_apply(const void *fdt, struct device_node *tree, - int *ovcs_id) + int *ovcs_id, struct device_node *base) { struct overlay_changeset *ovcs; int ret = 0, ret_revert, ret_tmp; @@ -947,7 +962,7 @@ static int of_overlay_apply(const void *fdt, struct device_node *tree, if (ret) goto err_free_tree; - ret = init_overlay_changeset(ovcs, fdt, tree); + ret = init_overlay_changeset(ovcs, fdt, tree, base); if (ret) goto err_free_tree; @@ -1015,7 +1030,7 @@ static int of_overlay_apply(const void *fdt, struct device_node *tree, } int of_overlay_fdt_apply(const void *overlay_fdt, u32 overlay_fdt_size, - int *ovcs_id) + int *ovcs_id, struct device_node *base) { void *new_fdt; void *new_fdt_align; @@ -1053,7 +1068,7 @@ int of_overlay_fdt_apply(const void *overlay_fdt, u32 overlay_fdt_size, goto out_free_new_fdt; } - ret = of_overlay_apply(new_fdt, overlay_root, ovcs_id); + ret = of_overlay_apply(new_fdt, overlay_root, ovcs_id, base); if (ret < 0) { /* * new_fdt and overlay_root now belong to the overlay diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 70992103c07d..471bf6f2ec9a 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -3010,7 +3010,7 @@ static int __init overlay_data_apply(const char *overlay_name, int *ovcs_id) if (!size) pr_err("no overlay data for %s\n", overlay_name); - ret = of_overlay_fdt_apply(info->dtb_begin, size, &info->ovcs_id); + ret = of_overlay_fdt_apply(info->dtb_begin, size, &info->ovcs_id, NULL); if (ovcs_id) *ovcs_id = info->ovcs_id; if (ret < 0) diff --git a/include/linux/of.h b/include/linux/of.h index 2dc77430a91a..7c5ecafb98c8 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -1567,7 +1567,7 @@ struct of_overlay_notify_data { #ifdef CONFIG_OF_OVERLAY int of_overlay_fdt_apply(const void *overlay_fdt, u32 overlay_fdt_size, - int *ovcs_id); + int *ovcs_id, struct device_node *target_base); int of_overlay_remove(int *ovcs_id); int of_overlay_remove_all(void);