From patchwork Tue Jan 2 09:28:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manish Jaggi X-Patchwork-Id: 123099 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp8755009qgn; Tue, 2 Jan 2018 01:31:05 -0800 (PST) X-Google-Smtp-Source: ACJfBouEBz4Yli00irMOClKp986VK1WwqX1tDTE2Qg/ZtcHMG80NnCu94C8bX1iQjF/X4ndWWd/0 X-Received: by 10.36.43.207 with SMTP id h198mr61814770ita.23.1514885465796; Tue, 02 Jan 2018 01:31:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514885465; cv=none; d=google.com; s=arc-20160816; b=kvFyMrE0akvwVi9mNJ3SVW7ThZeNbdIeaEtKj5FZSDoeNpU6yilDE+hiRzcb9nJh0B vUFMg17vXS1s+ArRtCeBTBs9iuR9yY0Te+Dp/rtwd7pcIQDWkFjtZTkSFwHN7UX//cNb RhZpMJWy13H7PUhJfGsNv8kW6k9ILL86CYraj6XkI+VTT+GXKIiuQwlKFAPyUOItDVW/ vuKnU/PEfeQSFvZex778JC1T4XXkktnVbWszEHprIE7krzOGfnpEfN7E07Mcftw8O9lv ZgVZ4/7W6fTMJ/8DC9MRl9Zv8nyWIZOiZ7i1hj7hXEn7HkpJesgftHtL5Y/aFy5Do8Y/ 7F7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=qwa8sYKw7NgwnBIVHEY7sc3CpDCkOkXw08WKkcxIt98=; b=P2vrNsCySq3uRO4W/L65LK1LfyxihmMEbqDDmeAaN3uVILZfcZAZ6gs1FwCJSPTZY1 fCUS55AFPvHviYZMUZoTwkg0W1SNlMXrz25xj7JMp7yRRHPAme/PW1yoai1w4uROFLO4 ko11GZx2Rgp6G20g/qHT6Xdm+zRIIcJA3JrmgE8mgW8Q8FWI4vxWn2P6bseFG5D8rnVb IW2RqfmNfTYG5RneXFg9/sEyXMIvOp52aWAd1d6NgTyQhsLaicheqnh4cktkBqhe6fvs stP1QdIQOSfSVztKGrT2ooxfHE6Z5f3yng7HsQ5YubZ83GTEUMOYBMG2MfL27fbGuI7J EkeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=GLilOdsA; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id p62si133097ioe.153.2018.01.02.01.31.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Jan 2018 01:31:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=GLilOdsA; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eWIsA-0002Qs-Fi; Tue, 02 Jan 2018 09:28:38 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eWIsA-0002QN-0e for xen-devel@lists.xenproject.org; Tue, 02 Jan 2018 09:28:38 +0000 X-Inumbo-ID: 270d1b16-ef9f-11e7-b4a6-bc764e045a96 Received: from mail-pl0-x242.google.com (unknown [2607:f8b0:400e:c01::242]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 270d1b16-ef9f-11e7-b4a6-bc764e045a96; Tue, 02 Jan 2018 10:27:29 +0100 (CET) Received: by mail-pl0-x242.google.com with SMTP id bi12so28336780plb.6 for ; Tue, 02 Jan 2018 01:28:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lf3xxboQn1wcqeeunjFpaeVaR/cB51zeMLtt9bdpb24=; b=GLilOdsAib/+mlxIKkXbG18Y6AOOFjgQyYsZykOOgRvdDUPlYFyksQ0itG1yma4iWU OWFd/ZQjHWcJLDHTPloUck3qivhJoSas1e1MRFoK0AQmTpPQzQvgNvod4ZxyvONn1zz7 CymJ+WtvVtARKe+PRxdr/JtGsasDXO3lM/5wo= 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=lf3xxboQn1wcqeeunjFpaeVaR/cB51zeMLtt9bdpb24=; b=eXrtSoVeC/Tkw14MtAt/8H3kYtZL2+7KEHBRqui4GzDYUHoMAuXSM9D5hsoW/N58/z 31f5h7/ldGVuaX16bsvyqxxi+S4PUnZRGWMeGFtfEbjI38NsLy/GcAhm4aPh15i43WiC ZmHOySIi9QZ0lq8+b0qOp08rY7iRYKq5QvVRVdVHFe31gMauMQI4qyuEPsjPvXnGyFud WyiwFhxmAbivIbxGNUC3pni7iAz0CzhpAQDWBCN7wbbbcqaDFdI3BJbVeagRvcb6CiRZ g4vOty+ml82M6Lyp7bA9LxzK86ayXDWLEF52vNuOMpGNhbetvb1U62n2uDxwZfryvgMU qQgw== X-Gm-Message-State: AKGB3mLkIuhxAXU08ZWBf5tL71clnbXo0ZfOIEXVZeu2RUqwfUcEyn6D rXeoA/wbrUzhLZYkZot3XwMbvczn9ws= X-Received: by 10.84.171.193 with SMTP id l59mr43894231plb.163.1514885314710; Tue, 02 Jan 2018 01:28:34 -0800 (PST) Received: from thunder-dev-box.domain.name ([111.93.218.67]) by smtp.gmail.com with ESMTPSA id e8sm22065207pgs.44.2018.01.02.01.28.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Jan 2018 01:28:34 -0800 (PST) From: manish.jaggi@linaro.org To: xen-devel@lists.xenproject.org, julien.grall@linaro.org, sameer.goel@linaro.org, andre.przywara@linaro.org Date: Tue, 2 Jan 2018 14:58:00 +0530 Message-Id: <20180102092809.1841-3-manish.jaggi@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180102092809.1841-1-manish.jaggi@linaro.org> References: <20180102092809.1841-1-manish.jaggi@linaro.org> Cc: Manish Jaggi , manish.jaggi@cavium.com Subject: [Xen-devel] [RFC 02/11] acpi: arm: API to query estimated size of hardware domain's IORT X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Manish Jaggi Code to query estimated IORT size for hardware domain. IORT for hardware domain is generated using the requesterId and deviceId map. Signed-off-by: Manish Jaggi --- xen/arch/arm/domain_build.c | 12 ++++- xen/drivers/acpi/arm/Makefile | 1 + xen/drivers/acpi/arm/gen-iort.c | 101 ++++++++++++++++++++++++++++++++++++++++ xen/include/acpi/gen-iort.h | 6 +++ 4 files changed, 119 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index c74f4dd69d..f5d5e3d271 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -1799,7 +1800,7 @@ static int acpi_create_fadt(struct domain *d, struct membank tbl_add[]) static int estimate_acpi_efi_size(struct domain *d, struct kernel_info *kinfo) { - size_t efi_size, acpi_size, madt_size; + size_t efi_size, acpi_size, madt_size, iort_size; u64 addr; struct acpi_table_rsdp *rsdp_tbl; struct acpi_table_header *table; @@ -1840,6 +1841,15 @@ static int estimate_acpi_efi_size(struct domain *d, struct kernel_info *kinfo) acpi_os_unmap_memory(table, sizeof(struct acpi_table_header)); acpi_size += ROUNDUP(sizeof(struct acpi_table_rsdp), 8); + + if( estimate_iort_size(&iort_size) ) + { + printk("Unable to get hwdom iort size\n"); + return -EINVAL; + } + + acpi_size += ROUNDUP(iort_size, 8); + d->arch.efi_acpi_len = PAGE_ALIGN(ROUNDUP(efi_size, 8) + ROUNDUP(acpi_size, 8)); diff --git a/xen/drivers/acpi/arm/Makefile b/xen/drivers/acpi/arm/Makefile index 046fad5e3d..13f1a9159f 100644 --- a/xen/drivers/acpi/arm/Makefile +++ b/xen/drivers/acpi/arm/Makefile @@ -1 +1,2 @@ obj-y = ridmap.o +obj-y += gen-iort.o diff --git a/xen/drivers/acpi/arm/gen-iort.c b/xen/drivers/acpi/arm/gen-iort.c new file mode 100644 index 0000000000..3fc32959c6 --- /dev/null +++ b/xen/drivers/acpi/arm/gen-iort.c @@ -0,0 +1,101 @@ +/* + * xen/drivers/acpi/arm/gen-iort.c + * + * Code to generate IORT for hardware domain using the requesterId + * and deviceId map. + * + * Manish Jaggi + * Copyright (c) 2018 Linaro. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include + +/* + * Size of hardware domains iort is calulcated based on the number of + * mappings in the requesterId - deviceId mapping list. + */ +int estimate_iort_size(size_t *iort_size) +{ + int count = 0; + int pcirc_count = 0; + int itsg_count = 0; + uint64_t *pcirc_array; + uint64_t *itsg_array; + struct rid_deviceid_map *rmap; + + list_for_each_entry(rmap, &rid_deviceid_map_list, entry) + count++; + + pcirc_array = xzalloc_bytes(sizeof(uint64_t)*count); + if ( !pcirc_array ) + return -ENOMEM; + + itsg_array = xzalloc_bytes(sizeof(uint64_t)*count); + if ( !itsg_array ) + return -ENOMEM; + + list_for_each_entry(rmap, &rid_deviceid_map_list, entry) + { + int i = 0; + + for (i=0; i <= pcirc_count; i++) + { + if ( pcirc_array[i] == (uint64_t)rmap->pcirc_node ) + break; + if ( i == pcirc_count ) + { + pcirc_array[i] = (uint64_t)rmap->pcirc_node; + pcirc_count++; + break; + } + } + + for ( i=0; i <= itsg_count; i++ ) + { + if ( itsg_array[i] == (uint64_t) rmap->its_node ) + break; + if ( i == itsg_count ) + { + itsg_array[i] = (uint64_t)rmap->its_node; + itsg_count++; + break; + } + } + } + + /* Size of IORT + * = Size of IORT Table Header + Size of PCIRC Header Nodes + + * Size of PCIRC nodes + Size of ITS Header nodes + Size of ITS Nodes + * + Size of Idmap nodes + */ + *iort_size = sizeof(struct acpi_table_iort) + + pcirc_count*( (sizeof(struct acpi_iort_node) -1) + + sizeof(struct acpi_iort_root_complex) ) + + itsg_count*( (sizeof(struct acpi_iort_node) -1) + + sizeof(struct acpi_iort_its_group) ) + + count*( sizeof(struct acpi_iort_id_mapping) ); + + xfree(itsg_array); + xfree(pcirc_array); + + return 0; +} +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/include/acpi/gen-iort.h b/xen/include/acpi/gen-iort.h new file mode 100644 index 0000000000..68e666fdce --- /dev/null +++ b/xen/include/acpi/gen-iort.h @@ -0,0 +1,6 @@ +#ifndef _GEN_IORT_H +#define _GEN_IORT_H + +int estimate_iort_size(size_t *iort_size); + +#endif