From: manish.jaggi@linaro.org
To: xen-devel@lists.xenproject.org, julien.grall@linaro.org,
sameer.goel@linaro.org, andre.przywara@linaro.org
Cc: Manish Jaggi <manish.jaggi@linaro.org>, manish.jaggi@cavium.com
Subject: [RFC 02/11] acpi: arm: API to query estimated size of hardware domain's IORT
Date: Tue, 2 Jan 2018 14:58:00 +0530 [thread overview]
Message-ID: <20180102092809.1841-3-manish.jaggi@linaro.org> (raw)
In-Reply-To: <20180102092809.1841-1-manish.jaggi@linaro.org>
From: Manish Jaggi <manish.jaggi@linaro.org>
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 <manish.jaggi@linaro.com>
---
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 <xen/acpi.h>
#include <xen/warning.h>
#include <acpi/actables.h>
+#include <acpi/gen-iort.h>
#include <asm/device.h>
#include <asm/setup.h>
#include <asm/platform.h>
@@ -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 <manish.jaggi@linaro.com>
+ * 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 <acpi/ridmap.h>
+#include <xen/acpi.h>
+
+/*
+ * 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
--
2.14.1
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2018-01-02 9:28 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-02 9:27 [RFC 00/11] acpi: arm: IORT Support for Xen manish.jaggi
2018-01-02 9:27 ` [RFC 01/11] acpi: arm: Public API for populating and query based on requesterid manish.jaggi
2018-01-16 17:53 ` Julien Grall
2018-01-16 18:31 ` Julien Grall
2018-01-19 6:05 ` Manish Jaggi
2018-01-19 12:03 ` Julien Grall
2018-01-22 5:07 ` Manish Jaggi
2018-01-22 13:40 ` Julien Grall
2018-01-02 9:28 ` manish.jaggi [this message]
2018-01-16 18:52 ` [RFC 02/11] acpi: arm: API to query estimated size of hardware domain's IORT Julien Grall
2018-01-19 6:10 ` Manish Jaggi
2018-01-22 13:45 ` Julien Grall
2018-01-02 9:28 ` [RFC 03/11] acpi: arm: Code to generate Hardware Domains IORT manish.jaggi
2018-01-18 18:32 ` Julien Grall
2018-01-02 9:28 ` [RFC 04/11] Import iort.c and acpi_iort.h manish.jaggi
2018-01-02 9:28 ` [RFC 05/11] Import fwnode.h from linux manish.jaggi
2018-01-02 9:28 ` [RFC 06/11] fwnode xen spacific changes manish.jaggi
2018-01-18 18:51 ` Julien Grall
2018-03-06 10:27 ` Manish Jaggi
2018-03-06 14:29 ` Julien Grall
2018-03-06 13:43 ` Manish Jaggi
2018-03-06 13:44 ` Manish Jaggi
2018-03-06 14:22 ` Julien Grall
2018-01-02 9:28 ` [RFC 07/11] Add kernel helper functions manish.jaggi
2018-01-18 18:55 ` Julien Grall
2018-01-19 9:33 ` Jan Beulich
2018-02-08 21:56 ` Sameer Goel
2018-01-02 9:28 ` [RFC 08/11] Add ACPI_IORT config manish.jaggi
2018-01-18 19:01 ` Julien Grall
2018-01-02 9:28 ` [RFC 09/11] Xen IORT Changes manish.jaggi
2018-01-18 19:10 ` Julien Grall
2018-01-02 9:28 ` [RFC 10/11] IORT parsing functions to prepare requesterId maps manish.jaggi
2018-01-02 9:28 ` [RFC 11/11] Add to_pci_dev macro manish.jaggi
2018-01-18 19:15 ` Julien Grall
2018-02-08 21:54 ` Sameer Goel
2018-01-16 17:53 ` [RFC 00/11] acpi: arm: IORT Support for Xen Julien Grall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180102092809.1841-3-manish.jaggi@linaro.org \
--to=manish.jaggi@linaro.org \
--cc=andre.przywara@linaro.org \
--cc=julien.grall@linaro.org \
--cc=manish.jaggi@cavium.com \
--cc=sameer.goel@linaro.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).