summaryrefslogtreecommitdiffstats
path: root/src/usr/i2c
diff options
context:
space:
mode:
authorMatt Derksen <mderkse1@us.ibm.com>2019-03-14 12:56:21 -0500
committerDaniel M. Crowell <dcrowell@us.ibm.com>2019-03-15 14:18:49 -0500
commita5c403221e3e469c8d1fb26a56c5eb44228589e1 (patch)
tree760e11ae60260c58f5886860d0fc4f157e81171e /src/usr/i2c
parent3830dc6e8fb052cdf2738cd473d5653c4682e063 (diff)
downloadtalos-hostboot-a5c403221e3e469c8d1fb26a56c5eb44228589e1.tar.gz
talos-hostboot-a5c403221e3e469c8d1fb26a56c5eb44228589e1.zip
Fixing runtime i2c operation
Base i2c operations were updated with new parameter for UCD work, but runtime i2c was not updated. Also fixing orphaning error log memory and potentially calling toString on a nullptr. Change-Id: I6c912e71b22da80b166e13dc66bdf0e5a51abfbb CQ:SW459731 Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/73361 Reviewed-by: Christian R. Geddes <crgeddes@us.ibm.com> Reviewed-by: Corey V. Swenson <cswenson@us.ibm.com> Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> 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>
Diffstat (limited to 'src/usr/i2c')
-rw-r--r--src/usr/i2c/errlud_i2c.C30
-rwxr-xr-xsrc/usr/i2c/runtime/rt_i2c.C20
2 files changed, 37 insertions, 13 deletions
diff --git a/src/usr/i2c/errlud_i2c.C b/src/usr/i2c/errlud_i2c.C
index 121905e5c..980d5274f 100644
--- a/src/usr/i2c/errlud_i2c.C
+++ b/src/usr/i2c/errlud_i2c.C
@@ -71,8 +71,13 @@ UdI2CParms::UdI2CParms( uint8_t i_opType,
// N bytes : I2C MUX path in string form
// Cache the MUX path in string form for reference and easy access
- char *l_muxPath = i_args.i2cMuxPath->toString();
-
+ char* l_muxPath{nullptr};
+ size_t l_muxPathSize = 0;
+ if (i_args.i2cMuxPath)
+ {
+ l_muxPath = i_args.i2cMuxPath->toString();
+ l_muxPathSize = strlen(l_muxPath);
+ }
char * l_pBuf = reinterpret_cast<char *>(
reallocUsrBuf(sizeof(uint8_t)*2
+sizeof(uint32_t)
@@ -84,7 +89,7 @@ UdI2CParms::UdI2CParms( uint8_t i_opType,
+sizeof(uint16_t)
+sizeof(uint64_t)*2
+sizeof(uint8_t)
- +(strlen(l_muxPath) +1) ) );
+ +l_muxPathSize + 1) );
uint64_t tmp64 = 0;
uint32_t tmp32 = 0;
uint16_t tmp16 = 0;
@@ -166,13 +171,18 @@ UdI2CParms::UdI2CParms( uint8_t i_opType,
memcpy(l_pBuf, &tmp8, sizeof(tmp8));
l_pBuf += sizeof(tmp8);
- memcpy(l_pBuf, l_muxPath, strlen(l_muxPath));
- l_pBuf += strlen(l_muxPath);
- l_pBuf = '\0'; // add a terminator for ease of parsing
- ++l_pBuf;
+ if (l_muxPathSize > 0)
+ {
+ memcpy(l_pBuf, l_muxPath, strlen(l_muxPath));
+ l_pBuf += strlen(l_muxPath);
- free(l_muxPath);
- l_muxPath = nullptr;
+ // done with muxPath so free it here
+ free(l_muxPath);
+ l_muxPath = nullptr;
+ l_muxPathSize = 0;
+ }
+ *l_pBuf = '\0'; // add a terminator for ease of parsing
+ ++l_pBuf;
}
//------------------------------------------------------------------------------
@@ -308,7 +318,7 @@ UdEepromParms::UdEepromParms( uint8_t i_opType,
memcpy(l_pBuf, l_muxPath, strlen(l_muxPath));
l_pBuf += strlen(l_muxPath);
- l_pBuf = '\0'; // add a terminator for ease of parsing
+ *l_pBuf = '\0'; // add a terminator for ease of parsing
++l_pBuf;
free(l_muxPath);
diff --git a/src/usr/i2c/runtime/rt_i2c.C b/src/usr/i2c/runtime/rt_i2c.C
index 9ae1e7b44..16f62c76e 100755
--- a/src/usr/i2c/runtime/rt_i2c.C
+++ b/src/usr/i2c/runtime/rt_i2c.C
@@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
-/* Contributors Listed Below - COPYRIGHT 2015,2016 */
+/* Contributors Listed Below - COPYRIGHT 2015,2019 */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -37,6 +37,7 @@
#include <errl/errlentry.H>
#include <errl/errlmanager.H>
#include <errl/errludtarget.H>
+#include <errl/hberrltypes.H>
#include <devicefw/driverif.H>
#include <i2c/i2creasoncodes.H>
#include <runtime/interface.h>
@@ -81,6 +82,11 @@ errlHndl_t i2cPerformOp( DeviceFW::OperationType i_opType,
// Address, Port, Engine, Device Addr.
// Other args set below
misc_args_t args;
+
+ // Read in the sub-operation
+ const auto subop =
+ static_cast<DeviceFW::I2C_SUBOP>(va_arg(i_args,uint64_t));
+
args.port = va_arg( i_args, uint64_t );
args.engine = va_arg( i_args, uint64_t );
args.devAddr = va_arg( i_args, uint64_t );
@@ -111,22 +117,30 @@ errlHndl_t i2cPerformOp( DeviceFW::OperationType i_opType,
}
else
{
+ TRACFCOMP(g_trac_i2c, ERR_MRK"Invalid Offset length: 0x%.8X."
+ "Previous parameters: i2c subop 0x%.8X, "
+ "port 0x%.8X, engine 0x%.8X, deviceAddr 0x%.8X",
+ args.offset_length, subop,
+ args.port, args.engine, args.devAddr);
/*@
* @errortype
* @moduleid I2C_PERFORM_OP
* @reasoncode I2C_RUNTIME_INVALID_OFFSET_LENGTH
* @userdata1 Offset length
- * @userdata2 Op type
+ * @userdata2[0:31] Operation Type
+ * @userdata2[32:64] Target
* @devdesc I2C offset length is invalid
*/
err = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_INFORMATIONAL,
I2C_PERFORM_OP,
I2C_RUNTIME_INVALID_OFFSET_LENGTH,
args.offset_length,
- i_opType);
+ TWO_UINT32_TO_UINT64(i_opType,
+ TARGETING::get_huid(i_target)));
err->addProcedureCallout(HWAS::EPUB_PRC_HB_CODE,
HWAS::SRCI_PRIORITY_HIGH);
+ return err;
}
}
OpenPOWER on IntegriCloud