refactor: SP manifest defines
This patch makes the partition manifest defines related to number of
memory regions, device regions, interrupts and streams pre device region
into platform build options, as opposed to being defined in header
files.
Large SoCs tend to have many memory regions and device regions that need
to be covered in SPs. An example SP is a RAS SP which requires access to
large number of memory regions and device regions to triage RAS issues.
Moreover, such SPs need to handle a large number of interrupts as well
and the current limits of 8 memory regions, 8 device regions and 4
interrupts per device regions are inadequate.
By making this a platform specific build option, it allows freedom for
platforms to choose the right number of regions and interrupts per
device.
This patch extends the allowed limit of memory and device regions to 64K
and have up to 256 interrupts and streams per device region.
Also note that the new defines are in platform.gni as opposed to in
architecture specific build/args gni files since SP specific details
have leaked into manifest.h, which is included in many architecture
agnostic files. Adding it into args.gni in the aarch64 folder yielded
compile errors which require further modification to many other
unrelated BUILD.gn files.
Change-Id: If71e154319e66f2864b18c33936a049d8cde4db4
Signed-off-by: Raghu Krishnamurthy <raghu.ncstate@gmail.com>
diff --git a/build/BUILD.gn b/build/BUILD.gn
index 1baac1b..73a73e1 100644
--- a/build/BUILD.gn
+++ b/build/BUILD.gn
@@ -27,6 +27,23 @@
# Platform configuration.
config("platform") {
+ assert(
+ plat_partition_max_memory_regions > 0 &&
+ plat_partition_max_memory_regions < 65536,
+ "Maximum SP memory regions must be between 1 and 65535: current = ${plat_partition_max_memory_regions}")
+ assert(
+ plat_partition_max_device_regions > 0 &&
+ plat_partition_max_device_regions < 65536,
+ "Maximum SP device regions must be between 1 and 65535: current = ${plat_partition_max_device_regions}")
+ assert(
+ plat_partition_max_intr_per_device > 0 &&
+ plat_partition_max_intr_per_device < 256,
+ "Maximum interrupts per device regions must be between 1 and 255: current = ${plat_partition_max_intr_per_device}")
+ assert(
+ plat_partition_max_streams_per_device > 0 &&
+ plat_partition_max_streams_per_device < 256,
+ "Maximum streams per device regions must be between 1 and 255: current = ${plat_partition_max_streams_per_device}")
+
include_dirs = [
"//inc",
"//inc/vmapi",
@@ -42,5 +59,9 @@
"MAX_VMS=${plat_max_vms}",
"LOG_LEVEL=${log_level}",
"ENABLE_ASSERTIONS=${enable_assertions}",
+ "PARTITION_MAX_MEMORY_REGIONS=${plat_partition_max_memory_regions}",
+ "PARTITION_MAX_DEVICE_REGIONS=${plat_partition_max_device_regions}",
+ "PARTITION_MAX_INTERRUPTS_PER_DEVICE=${plat_partition_max_intr_per_device}",
+ "PARTITION_MAX_STREAMS_PER_DEVICE=${plat_partition_max_streams_per_device}",
]
}
diff --git a/build/toolchain/platform.gni b/build/toolchain/platform.gni
index 33e01c2..adcfb68 100644
--- a/build/toolchain/platform.gni
+++ b/build/toolchain/platform.gni
@@ -32,4 +32,16 @@
# The maximum number of VMs required for the platform.
plat_max_vms = 0
+
+ # The maximum number of memory regions allowed per partition, in the partition manifest
+ plat_partition_max_memory_regions = 8
+
+ # The maximum number of device regions allower per partition, in the partition manifest
+ plat_partition_max_device_regions = 8
+
+ # The maximum number of interrupts allowed per device, per partition, in the partition manifest
+ plat_partition_max_intr_per_device = 4
+
+ # the maximum number of streams allowed per device, per partition, in the partition manifest
+ plat_partition_max_streams_per_device = 4
}
diff --git a/inc/hf/manifest.h b/inc/hf/manifest.h
index f3c5989..30d79cc 100644
--- a/inc/hf/manifest.h
+++ b/inc/hf/manifest.h
@@ -20,11 +20,6 @@
#define SP_RTX_BUF_NAME_SIZE 10
-#define SP_MAX_MEMORY_REGIONS 8
-#define SP_MAX_DEVICE_REGIONS 8
-#define SP_MAX_INTERRUPTS_PER_DEVICE 4
-#define SP_MAX_STREAMS_PER_DEVICE 4
-
/** FF-A manifest memory and device regions attributes. */
#define MANIFEST_REGION_ATTR_READ (UINT32_C(1) << 0)
#define MANIFEST_REGION_ATTR_WRITE (UINT32_C(1) << 1)
@@ -85,7 +80,7 @@
/** Memory attributes - mandatory */
uint32_t attributes;
/** List of physical interrupt ID's and their attributes - optional */
- struct interrupt interrupts[SP_MAX_INTERRUPTS_PER_DEVICE];
+ struct interrupt interrupts[PARTITION_MAX_INTERRUPTS_PER_DEVICE];
/** Count of physical interrupts - optional */
uint8_t interrupt_count;
/** SMMU ID - optional */
@@ -93,7 +88,7 @@
/** Count of Stream IDs assigned to device - optional */
uint8_t stream_count;
/** List of Stream IDs assigned to device - optional */
- uint32_t stream_ids[SP_MAX_STREAMS_PER_DEVICE];
+ uint32_t stream_ids[PARTITION_MAX_STREAMS_PER_DEVICE];
/** Exclusive access to an endpoint - optional */
bool exclusive_access;
/** Name of Device region - optional */
@@ -166,11 +161,11 @@
uint32_t stream_ep_ids[1];
/** Memory regions */
- uint8_t mem_region_count;
- struct memory_region mem_regions[SP_MAX_MEMORY_REGIONS];
+ uint16_t mem_region_count;
+ struct memory_region mem_regions[PARTITION_MAX_MEMORY_REGIONS];
/** Device regions */
- uint8_t dev_region_count;
- struct device_region dev_regions[SP_MAX_DEVICE_REGIONS];
+ uint16_t dev_region_count;
+ struct device_region dev_regions[PARTITION_MAX_DEVICE_REGIONS];
};
/**
diff --git a/src/load.c b/src/load.c
index 770f860..431d82c 100644
--- a/src/load.c
+++ b/src/load.c
@@ -163,11 +163,11 @@
vm_locked.vm->uuid = manifest_vm->partition.uuid;
/* Populate the interrupt descriptor for current VM. */
- for (uint8_t i = 0; i < SP_MAX_DEVICE_REGIONS; i++) {
+ for (uint16_t i = 0; i < PARTITION_MAX_DEVICE_REGIONS; i++) {
dev_region = manifest_vm->partition.dev_regions[i];
CHECK(dev_region.interrupt_count <=
- SP_MAX_INTERRUPTS_PER_DEVICE);
+ PARTITION_MAX_INTERRUPTS_PER_DEVICE);
for (uint8_t j = 0; j < dev_region.interrupt_count; j++) {
struct interrupt_descriptor int_desc;
diff --git a/src/manifest.c b/src/manifest.c
index 80f5b40..d8350fc 100644
--- a/src/manifest.c
+++ b/src/manifest.c
@@ -357,10 +357,10 @@
static enum manifest_return_code parse_ffa_memory_region_node(
struct fdt_node *mem_node, struct memory_region *mem_regions,
- uint8_t *count, struct rx_tx *rxtx)
+ uint16_t *count, struct rx_tx *rxtx)
{
uint32_t phandle;
- uint8_t i = 0;
+ uint16_t i = 0;
dlog_verbose(" Partition memory regions\n");
@@ -430,7 +430,8 @@
}
i++;
- } while (fdt_next_sibling(mem_node) && (i < SP_MAX_MEMORY_REGIONS));
+ } while (fdt_next_sibling(mem_node) &&
+ (i < PARTITION_MAX_MEMORY_REGIONS));
if (rxtx->available &&
(rxtx->rx_buffer->page_count != rxtx->tx_buffer->page_count)) {
@@ -444,10 +445,10 @@
static enum manifest_return_code parse_ffa_device_region_node(
struct fdt_node *dev_node, struct device_region *dev_regions,
- uint8_t *count)
+ uint16_t *count)
{
struct uint32list_iter list;
- uint8_t i = 0;
+ uint16_t i = 0;
uint32_t j = 0;
dlog_verbose(" Partition Device Regions\n");
@@ -507,7 +508,7 @@
dlog_verbose(" Interrupt List:\n");
j = 0;
while (uint32list_has_next(&list) &&
- j < SP_MAX_INTERRUPTS_PER_DEVICE) {
+ j < PARTITION_MAX_INTERRUPTS_PER_DEVICE) {
TRY(uint32list_get_next(
&list, &dev_regions[i].interrupts[j].id));
if (uint32list_has_next(&list)) {
@@ -543,7 +544,7 @@
j = 0;
while (uint32list_has_next(&list) &&
- j < SP_MAX_STREAMS_PER_DEVICE) {
+ j < PARTITION_MAX_STREAMS_PER_DEVICE) {
TRY(uint32list_get_next(&list,
&dev_regions[i].stream_ids[j]));
dlog_verbose(" %u\n",
@@ -561,7 +562,8 @@
dev_regions[i].exclusive_access);
i++;
- } while (fdt_next_sibling(dev_node) && (i < SP_MAX_DEVICE_REGIONS));
+ } while (fdt_next_sibling(dev_node) &&
+ (i < PARTITION_MAX_DEVICE_REGIONS));
*count = i;
@@ -627,12 +629,13 @@
ret_code = MANIFEST_ERROR_NOT_COMPATIBLE;
}
- for (uint8_t i = 0; i < vm->partition.dev_region_count; i++) {
+ for (uint16_t i = 0; i < vm->partition.dev_region_count; i++) {
struct device_region dev_region;
dev_region = vm->partition.dev_regions[i];
- if (dev_region.interrupt_count > SP_MAX_INTERRUPTS_PER_DEVICE) {
+ if (dev_region.interrupt_count >
+ PARTITION_MAX_INTERRUPTS_PER_DEVICE) {
dlog_error(
"Interrupt count for device region exceeds "
"limit.\n");