summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLijuan Gao <lijuang@codeaurora.org>2021-09-15 17:51:28 +0800
committerLijuan Gao <lijuang@codeaurora.org>2021-09-24 10:03:25 +0800
commit705882c409a3178517118e6164f20a8d1778390a (patch)
tree8f3381d21c6231ec94c0bf08adf2faede8f55827
parent220a7d84a99b5db076748e9d12ee7d1a55444d7d (diff)
QcomModulePkg: Using an array for updating DDr region property value
Calling the fdt function to update the ddr region property repeatedly takes more time, so using an array to update the property once for improving boot time. Change-Id: I719848b9763a1a436d97b2404a67f900a3382031
-rw-r--r--QcomModulePkg/Include/Library/UpdateDeviceTree.h9
-rw-r--r--[-rwxr-xr-x]QcomModulePkg/Library/BootLib/UpdateDeviceTree.c125
2 files changed, 61 insertions, 73 deletions
diff --git a/QcomModulePkg/Include/Library/UpdateDeviceTree.h b/QcomModulePkg/Include/Library/UpdateDeviceTree.h
index 6abe59fc13..bf544b8644 100644
--- a/QcomModulePkg/Include/Library/UpdateDeviceTree.h
+++ b/QcomModulePkg/Include/Library/UpdateDeviceTree.h
@@ -55,6 +55,15 @@
/* Return True if integer overflow will occur */
#define CHECK_ADD64(a, b) ((MAX_UINT64 - b < a) ? TRUE : FALSE)
+/* DDR region information have the layout like below, each item have 32bit:
+ * region = < StartAddr_high StartAddr_low
+ * RegionsSize_high RegionsSize_low
+ * SegmentsStartOffset_high SegmentsStartOffset_low
+ * SegmentsStartIndex_high SegmentsStartIndex_low
+ * GranuleSize_high GranuleSize_low
+*/
+#define MAX_DDR_REGION_PROP_MEM 10
+
/* Look up table for fstab node */
struct FstabNode {
CONST CHAR8 *ParentNode; /* Parent Node name */
diff --git a/QcomModulePkg/Library/BootLib/UpdateDeviceTree.c b/QcomModulePkg/Library/BootLib/UpdateDeviceTree.c
index 17637f2777..9948c961da 100755..100644
--- a/QcomModulePkg/Library/BootLib/UpdateDeviceTree.c
+++ b/QcomModulePkg/Library/BootLib/UpdateDeviceTree.c
@@ -730,10 +730,12 @@ STATIC INT32 AddDDrRegionNodeProp (struct ddr_regions_data_info *DdrRegionsInfo,
VOID *Fdt, UINT32 Offset)
{
INT32 Ret;
- UINT32 Idx;
+ UINT32 Idx, Count;
UINT32 MaxDDrRegions;
CHAR8 RegionName[DDR_REGION_NAME_LEN] = {""};
CHAR8 RegionNameSuffix[DDR_REGION_NAME_SUFFIX] = {""};
+ UINT32 RegionPropArray[MAX_DDR_REGION_PROP_MEM];
+ UINT32 RegionPropArraySize = 0;
if (DdrRegionsInfo == NULL ||
Fdt == NULL) {
@@ -749,6 +751,8 @@ STATIC INT32 AddDDrRegionNodeProp (struct ddr_regions_data_info *DdrRegionsInfo,
return -1;
}
+ RegionPropArraySize = ARRAY_SIZE (RegionPropArray) *
+ sizeof (RegionPropArray[0]);
for (Idx = 0; Idx < MaxDDrRegions; Idx++) {
AsciiStrnCpyS (RegionName, DDR_REGION_NAME_LEN, "region",
AsciiStrLen ("region"));
@@ -756,89 +760,64 @@ STATIC INT32 AddDDrRegionNodeProp (struct ddr_regions_data_info *DdrRegionsInfo,
AsciiStrnCatS (RegionName, DDR_REGION_NAME_LEN, RegionNameSuffix,
DDR_REGION_NAME_SUFFIX);
- /* Add StartAddr Property */
- FdtPropUpdateFunc (Fdt, Offset, RegionName,
- DdrRegionsInfo->ddr_region[Idx].start_address >>
- DDR_REGIONS_MASK, fdt_setprop_u32, Ret);
- if (Ret) {
- DEBUG ((EFI_D_ERROR,
- "Failed to add start address(H) for %a\n", RegionName));
- return Ret;
- }
- FdtPropUpdateFunc (Fdt, Offset, RegionName,
- DdrRegionsInfo->ddr_region[Idx].start_address &
- DDR_REGIONS_LOW_MASK, fdt_appendprop_u32, Ret);
- if (Ret) {
- DEBUG ((EFI_D_ERROR,
- "Failed to add start address(L) for %a\n", RegionName));
- return Ret;
- }
+ Count = 0;
+ gBS->SetMem (RegionPropArray, RegionPropArraySize, 0);
+ /* Add StartAddr Property */
+ RegionPropArray[Count] = cpu_to_fdt32 (
+ DdrRegionsInfo->ddr_region[Idx].start_address >>
+ DDR_REGIONS_MASK);
+ Count++;
+ RegionPropArray[Count] = cpu_to_fdt32 (
+ DdrRegionsInfo->ddr_region[Idx].start_address &
+ DDR_REGIONS_LOW_MASK);
+ Count++;
/* Add RegionsSize Property */
- FdtPropUpdateFunc (Fdt, Offset, RegionName,
- DdrRegionsInfo->ddr_region[Idx].size >>
- DDR_REGIONS_MASK, fdt_appendprop_u32, Ret);
- if (Ret) {
- DEBUG ((EFI_D_ERROR,
- "Failed to add region size(H) for %a\n", RegionName));
- return Ret;
- }
- FdtPropUpdateFunc (Fdt, Offset, RegionName,
- DdrRegionsInfo->ddr_region[Idx].size &
- DDR_REGIONS_LOW_MASK, fdt_appendprop_u32, Ret);
- if (Ret) {
- DEBUG ((EFI_D_ERROR,
- "Failed to add region size(L) for %a\n", RegionName));
- return Ret;
- }
+ RegionPropArray[Count] = cpu_to_fdt32 (
+ DdrRegionsInfo->ddr_region[Idx].size >>
+ DDR_REGIONS_MASK);
+ Count++;
+ RegionPropArray[Count] = cpu_to_fdt32 (
+ DdrRegionsInfo->ddr_region[Idx].size &
+ DDR_REGIONS_LOW_MASK);
+ Count++;
/* Add SegmentsStartOffset Property */
- FdtPropUpdateFunc (Fdt, Offset, RegionName,
- DdrRegionsInfo->ddr_region[Idx].segments_start_offset >>
- DDR_REGIONS_MASK, fdt_appendprop_u32, Ret);
- if (Ret) {
- DEBUG ((EFI_D_ERROR,
- "Failed to add segments start offset(H) for %a\n", RegionName));
- return Ret;
- }
- FdtPropUpdateFunc (Fdt, Offset, RegionName,
- DdrRegionsInfo->ddr_region[Idx].segments_start_offset &
- DDR_REGIONS_LOW_MASK, fdt_appendprop_u32, Ret);
- if (Ret) {
- DEBUG ((EFI_D_ERROR,
- "Failed to add segments start offset(L) for %a\n", RegionName));
- return Ret;
- }
+ RegionPropArray[Count] = cpu_to_fdt32 (
+ DdrRegionsInfo->ddr_region[Idx].segments_start_offset >>
+ DDR_REGIONS_MASK);
+ Count++;
+ RegionPropArray[Count] = cpu_to_fdt32 (
+ DdrRegionsInfo->ddr_region[Idx].segments_start_offset &
+ DDR_REGIONS_LOW_MASK);
+ Count++;
/* Add SegmentsStartIndex Property */
- FdtPropUpdateFunc (Fdt, Offset, RegionName, 0, fdt_appendprop_u32, Ret);
- if (Ret) {
- DEBUG ((EFI_D_ERROR,
- "Failed to add segments start index(H) for %a\n", RegionName));
- return Ret;
- }
- FdtPropUpdateFunc (Fdt, Offset, RegionName,
- DdrRegionsInfo->ddr_region[Idx].segments_start_index &
- DDR_REGIONS_LOW_MASK, fdt_appendprop_u32, Ret);
- if (Ret) {
- DEBUG ((EFI_D_ERROR,
- "Failed to add segments start index(L) for %a\n", RegionName));
- return Ret;
- }
+ RegionPropArray[Count] = 0;
+ Count++;
+ RegionPropArray[Count] = cpu_to_fdt32 (
+ DdrRegionsInfo->ddr_region[Idx].segments_start_index &
+ DDR_REGIONS_LOW_MASK);
+ Count++;
/* Add GranuleSize Property */
- FdtPropUpdateFunc (Fdt, Offset, RegionName, 0, fdt_appendprop_u32, Ret);
- if (Ret) {
- DEBUG ((EFI_D_ERROR,
- "Failed to add granule size(H) for %a\n", RegionName));
- return Ret;
+ RegionPropArray[Count] = 0;
+ Count++;
+ RegionPropArray[Count] = cpu_to_fdt32 (
+ DdrRegionsInfo->ddr_region[Idx].granule_size &
+ DDR_REGIONS_LOW_MASK);
+ Count++;
+
+ if (Count > MAX_DDR_REGION_PROP_MEM) {
+ DEBUG ((EFI_D_ERROR, "ERROR: Wrong number of DDR Region member\n"));
+ return -1;
}
- FdtPropUpdateFunc (Fdt, Offset, RegionName,
- DdrRegionsInfo->ddr_region[Idx].granule_size &
- DDR_REGIONS_LOW_MASK, fdt_appendprop_u32, Ret);
+
+ Ret = FdtSetProp (Fdt, Offset, RegionName, RegionPropArray,
+ RegionPropArraySize);
if (Ret) {
DEBUG ((EFI_D_ERROR,
- "Failed to add granule size(L) for %a\n", RegionName));
+ "ERROR: Failed to add DDR Regions : %a\n", RegionName));
return Ret;
}
}