Skip to content

Commit

Permalink
Use virtual address buffer to read mvpd rings
Browse files Browse the repository at this point in the history
Fragmented memory may prevent mallocing multiple pages when
getting mvpd rings in xip_customize. Pass in and use
a previously allocated virtual memory buffer instead.

Change-Id: I43f70aab7787d2849dca5add6d4a777b5f49b62e
CQ:SW451916
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/71099
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: Hostboot CI <hostboot-ci+hostboot@us.ibm.com>
Reviewed-by: Jennifer A. Stofer <stofer@us.ibm.com>
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/71105
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
  • Loading branch information
cvswen authored and dcrowell77 committed Feb 7, 2019
1 parent 39cba20 commit 3c093dc
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 17 deletions.
10 changes: 7 additions & 3 deletions src/import/chips/p9/procedures/hwp/accessors/p9_get_mvpd_ring.C
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2016,2017 */
/* Contributors Listed Below - COPYRIGHT 2016,2019 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -57,7 +57,9 @@ extern "C"
const uint8_t i_evenOdd,
const RingId_t i_ringId,
uint8_t* o_pRingBuf,
uint32_t& io_rRingBufsize )
uint32_t& io_rRingBufsize,
uint8_t* i_pTempBuf,
uint32_t i_tempBufsize )
{
fapi2::ReturnCode l_fapirc;

Expand All @@ -76,7 +78,9 @@ extern "C"
i_evenOdd,
i_ringId,
o_pRingBuf,
io_rRingBufsize );
io_rRingBufsize,
i_pTempBuf,
i_tempBufsize );


FAPI_DBG("getMvpdRing: exit rc=0x%x",
Expand Down
15 changes: 12 additions & 3 deletions src/import/chips/p9/procedures/hwp/accessors/p9_get_mvpd_ring.H
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2016,2017 */
/* Contributors Listed Below - COPYRIGHT 2016,2019 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -47,7 +47,9 @@ typedef ReturnCode (*getMvpdRing_FP_t) (
const uint64_t,
const RingId_t,
uint8_t*,
uint32_t& );
uint32_t&,
uint8_t*,
uint32_t );

extern "C"
{
Expand Down Expand Up @@ -88,6 +90,11 @@ extern "C"
* byte x0 CompressedScanData structure (rs4 header)
* byte x0C compressed data (sizeof CompressedScanData is 0x0C)
* byte xNN last byte of compressed data
* Optional Parameters
* @param i_pTempBuf - pointer to a temp buffer allocated by the caller
* and must be large enough to fit the largest
* vpd record that contains ring data
* @param i_tempBufsize - size of temp buffer that caller has allocated
*
* @return fapi2::ReturnCode - FAPI_RC_SUCCESS if success,
* relevant error code for failure.
Expand All @@ -100,7 +107,9 @@ extern "C"
const uint8_t i_evenOdd,
const RingId_t i_ringId,
uint8_t* o_pRingBuf,
uint32_t& io_rRingBufsize );
uint32_t& io_rRingBufsize,
uint8_t* i_pTempBuf = nullptr,
uint32_t i_tempBufsize = 0 );

}
}
Expand Down
42 changes: 36 additions & 6 deletions src/import/chips/p9/procedures/hwp/accessors/p9_mvpd_ring_funcs.C
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2016,2018 */
/* Contributors Listed Below - COPYRIGHT 2016,2019 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -193,6 +193,13 @@ extern "C"
* @param[in/out] io_rRingBufsize
* Size of ring buffer
*
* @param[in] i_pTempBuf
* Pointer to temp buffer
*
* @param[in] i_TempBufsize
* Size of temp buffer, must be large enough to fit the
* largest vpd record that contains ring data
*
* @note: io_rRingBufsize is only an 'output' for get function.
*
* @return fapi2::ReturnCode
Expand All @@ -206,7 +213,9 @@ extern "C"
const uint8_t i_evenOdd,
const RingId_t i_ringId,
uint8_t* o_pRingBuf,
uint32_t& io_rRingBufsize )
uint32_t& io_rRingBufsize,
uint8_t* i_pTempBuf,
uint32_t i_tempBufsize )
{
fapi2::ReturnCode l_fapirc = fapi2::FAPI2_RC_SUCCESS;
uint32_t l_recordLen = 0;
Expand Down Expand Up @@ -274,8 +283,29 @@ extern "C"
FAPI_DBG( "mvpdRingFunc: getMvpdField returned record len=0x%x",
l_recordLen );

// allocate buffer for the record. Always works
l_recordBuf = static_cast<uint8_t*>(malloc((size_t)l_recordLen));
// use already allocated buffer if available
if (i_pTempBuf != nullptr)
{
// Make sure the record fits into the temp buffer
FAPI_ASSERT(l_recordLen <= i_tempBufsize,
fapi2::MVPD_INSUFFICIENT_RING_BUFFER_SPACE().
set_CHIP_TARGET(i_fapiTarget).
set_RING_ID(i_ringId).
set_CHIPLET_ID(i_chipletId).
set_BUFFER_SIZE(i_tempBufsize).
set_RING_SIZE(l_recordLen).
set_OCCURRENCE(1),
"mvpdRingFuncFindHdr: Not enough temp buffer space to contain record: "
"ringId=0x%x, chipletId=0x%x, bufferSize=0x%x, recordLen=0x%x",
i_ringId, i_chipletId, i_tempBufsize, l_recordLen );

l_recordBuf = i_pTempBuf;
}
// else allocate space for the record buffer
else
{
l_recordBuf = static_cast<uint8_t*>(malloc((size_t)l_recordLen));
}

// load ring from MVPD for this target
FAPI_TRY(getMvpdField(i_record,
Expand Down Expand Up @@ -368,8 +398,8 @@ extern "C"
// get current error
l_fapirc = fapi2::current_err;

// unload the repair ring if allocated
if(l_recordBuf)
// free the temp buffer if allocated
if((i_pTempBuf == nullptr) && l_recordBuf)
{
free(static_cast<void*>(l_recordBuf));
l_recordBuf = NULL;
Expand Down
13 changes: 10 additions & 3 deletions src/import/chips/p9/procedures/hwp/accessors/p9_mvpd_ring_funcs.H
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2016,2017 */
/* Contributors Listed Below - COPYRIGHT 2016,2019 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -57,7 +57,9 @@ typedef ReturnCode (*mvpdRingFuncs_FP_t) (
const uint64_t,
const RingId_t,
uint8_t*,
uint32_t& );
uint32_t&,
uint8_t*,
uint32_t );

extern "C"
{
Expand All @@ -78,6 +80,9 @@ extern "C"
* @param i_ringId - Ring ID
* @param o_pRingBuf - The buffer to receive or send the ring
* @param io_rRingBufsize - Size of ring / ring buffer
* @param i_pTempBuf - Temp buffer, must be large enough to fit the
* largest vpd record that contains ring data
* @param i_tempBufsize - Size of temp buffer
*
* @return fapi2::ReturnCode - FAPI_RC_SUCCESS if success,
* relevant error code for failure.
Expand All @@ -91,7 +96,9 @@ extern "C"
const uint8_t i_evenOdd,
const RingId_t i_ringId,
uint8_t* o_pRingBuf,
uint32_t& io_rRingBufsize );
uint32_t& io_rRingBufsize,
uint8_t* i_pTempBuf = nullptr,
uint32_t i_tempBufsize = 0 );

} // extern "C"
} // namespace fapi
Expand Down
10 changes: 8 additions & 2 deletions src/import/chips/p9/procedures/hwp/customize/p9_xip_customize.C
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2016,2018 */
/* Contributors Listed Below - COPYRIGHT 2016,2019 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -727,6 +727,7 @@ fapi2::ReturnCode _fetch_and_insert_vpd_rings(

/////////////////////////////////////////////////////////////////////
// Fetch rings from the MVPD:
// Use i_ringBuf2 as temp buffer space
/////////////////////////////////////////////////////////////////////
l_fapiRc = getMvpdRing( i_procTarget,
MVPD_RECORD_CP00,
Expand All @@ -735,7 +736,12 @@ fapi2::ReturnCode _fetch_and_insert_vpd_rings(
i_evenOdd,
i_ring.ringId,
(uint8_t*)i_vpdRing,
l_vpdRingSize );
l_vpdRingSize,
(uint8_t*)i_ringBuf2,
i_ringBufSize2);

// Reset the temp buffer that was used to gather ring data from vpd
memset(i_ringBuf2, 0, i_ringBufSize2);

///////////////////////////////////////////////////////////////////////
// Append VPD ring to the ring section
Expand Down

0 comments on commit 3c093dc

Please sign in to comment.