Skip to content

Commit

Permalink
Reduce memory fragmentation during SBE updates
Browse files Browse the repository at this point in the history
  - Original code was repeatedly allocating/freeing 256K chunks of
    heap memory
  - Other tasks in the background fragmented the allocations and
    could lead to out of memory conditions on large core number
    parts
  - Fix is to allocation one large chunk up front and use that for
    all operations

Change-Id: Ie6df7eb9ebce526d87480425e842f8d1be8d78d4
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/36920
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: William G. Hoffa <wghoffa@us.ibm.com>
Reviewed-by: Martin Gloff <mgloff@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
  • Loading branch information
sannerd authored and dcrowell77 committed Feb 27, 2017
1 parent 2e7f87d commit ec04768
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/include/usr/vmmconst.h
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2011,2016 */
/* Contributors Listed Below - COPYRIGHT 2011,2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -100,7 +100,7 @@

/** SBE Update process is at 3GB, uses 512KB */
#define VMM_VADDR_SBE_UPDATE (3 * GIGABYTE)
#define VMM_SBE_UPDATE_SIZE (512 * KILOBYTE)
#define VMM_SBE_UPDATE_SIZE (900 * KILOBYTE)
#define VMM_VADDR_SBE_UPDATE_END (VMM_VADDR_SBE_UPDATE + VMM_SBE_UPDATE_SIZE)

/** Attribute Resource Provider */
Expand Down
10 changes: 3 additions & 7 deletions src/usr/sbe/sbe_update.C
Expand Up @@ -910,7 +910,7 @@ namespace SBE

// Call p9_xip_delete_section to delete existing HBBL image
// from SBE image
void *l_imageBuf = malloc(io_image_size);
void *l_imageBuf =malloc(io_image_size);
xip_rc = p9_xip_delete_section(
i_image,
l_imageBuf,
Expand Down Expand Up @@ -1149,13 +1149,12 @@ namespace SBE
procIOMask = coreMask;

uint32_t l_ringSectionBufSize = MAX_SEEPROM_IMAGE_SIZE;
void* l_ringSectionBuf = malloc(l_ringSectionBufSize);
FAPI_INVOKE_HWP( err,
p9_xip_customize,
l_fapiTarg,
io_imgPtr, //image in/out
tmpImgSize,
l_ringSectionBuf,
(void*)RING_SEC_VADDR,
l_ringSectionBufSize,
SYSPHASE_HB_SBE,
MODEBUILD_IPL,
Expand All @@ -1164,7 +1163,6 @@ namespace SBE
(void*)RING_BUF2_VADDR,
(uint32_t)MAX_RING_BUF_SIZE,
procIOMask ); // Bits(8:31) = EC00:EC23
free(l_ringSectionBuf);

// Check for no error and use of input cores
if ( (NULL == err) && (procIOMask == coreMask))
Expand Down Expand Up @@ -1986,7 +1984,7 @@ namespace SBE
static_cast<uint32_t>(sbePnorImageSize + hbblCachelineSize);

// copy SBE image from PNOR to memory
sbeHbblImgPtr = malloc(sbeHbblImgSize);
sbeHbblImgPtr = (void*)SBE_HBBL_IMG_VADDR;
memcpy ( sbeHbblImgPtr,
sbePnorPtr,
sbePnorImageSize);
Expand Down Expand Up @@ -2128,8 +2126,6 @@ namespace SBE

}while(0);

free(sbeHbblImgPtr);

return err;

}
Expand Down
12 changes: 11 additions & 1 deletion src/usr/sbe/sbe_update.H
Expand Up @@ -135,16 +135,26 @@ namespace SBE
/******************************************/
/* Enums */
/******************************************/
// SBE VADDR Layout
// 000K - 256K = Dest for Customized SBE image
//
// 256K - 316K = Ring buf1
// 316K - 376K = Ring buf2
// 376K - 632K = Ring Section buf
// ---- ALT use 256K-632K for SBE ECC image
// 632K - 888K = SBE + HBBL image
enum {
FIXED_SEEPROM_WORK_SPACE = 256 * 1024,
SBE_IMG_VADDR = VMM_VADDR_SBE_UPDATE,
RING_BUF1_VADDR = FIXED_SEEPROM_WORK_SPACE + SBE_IMG_VADDR,
RING_BUF2_VADDR = RING_BUF1_VADDR + MAX_RING_BUF_SIZE,
RING_SEC_VADDR = RING_BUF2_VADDR + MAX_RING_BUF_SIZE,
//NOTE: recycling the same memory space for different
//steps in the process.
SBE_ECC_IMG_VADDR = VMM_VADDR_SBE_UPDATE + (VMM_SBE_UPDATE_SIZE / 2),
SBE_ECC_IMG_VADDR = RING_BUF1_VADDR,
SBE_ECC_IMG_MAX_SIZE = (MAX_SEEPROM_IMAGE_SIZE * 9 / 8) +
(3 * SBE_SEEPROM_ECC_PAD),
SBE_HBBL_IMG_VADDR = RING_SEC_VADDR + FIXED_SEEPROM_WORK_SPACE,
};

// Used for MVPD function
Expand Down

0 comments on commit ec04768

Please sign in to comment.