summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/makefile6
-rwxr-xr-xsrc/usr/i2c/eepromdd.C9
-rwxr-xr-xsrc/usr/i2c/i2c.C59
-rw-r--r--src/usr/targeting/xmltohb/attribute_types.xml39
-rw-r--r--src/usr/targeting/xmltohb/simics_SALERNO.system.xml2
-rw-r--r--src/usr/targeting/xmltohb/simics_VENICE.system.xml2
-rw-r--r--src/usr/targeting/xmltohb/target_types.xml12
7 files changed, 97 insertions, 32 deletions
diff --git a/src/makefile b/src/makefile
index 74c324f5f..626f1b05c 100644
--- a/src/makefile
+++ b/src/makefile
@@ -45,10 +45,10 @@ DIRECT_BOOT_OBJECTS = start.o kernel.o taskmgr.o cpumgr.o syscall.o \
RUNTIME_OBJECTS =
BASE_MODULES = trace errl devicefw scom xscom initservice taskargs \
- pnor vfs i2c
+ pnor vfs
-EXTENDED_MODULES = targeting ecmddatabuffer fapi hwp plat \
- extinitsvc istepdisp hwas fsi fsiscom
+EXTENDED_MODULES = targeting ecmddatabuffer fapi hwp plat \
+ extinitsvc istepdisp hwas fsi fsiscom i2c
DIRECT_BOOT_MODULES = example
RUNTIME_MODULES =
diff --git a/src/usr/i2c/eepromdd.C b/src/usr/i2c/eepromdd.C
index b046d109a..f472a72f2 100755
--- a/src/usr/i2c/eepromdd.C
+++ b/src/usr/i2c/eepromdd.C
@@ -46,8 +46,7 @@
// ----------------------------------------------
// Globals
// ----------------------------------------------
-mutex_t g_eepromMutex;
-bool g_initEepromMutex = true;
+mutex_t g_eepromMutex = MUTEX_INITIALIZER;
// ----------------------------------------------
// Trace definitions
@@ -111,12 +110,6 @@ errlHndl_t eepromPerformOp( DeviceFW::OperationType i_opType,
do
{
- if( g_initEepromMutex )
- {
- mutex_init( &g_eepromMutex );
- g_initEepromMutex = false;
- }
-
// Read Attributes needed to complete the operation
err = eepromReadAttributes( i_target,
i2cInfo );
diff --git a/src/usr/i2c/i2c.C b/src/usr/i2c/i2c.C
index 9d7c64464..a503e97cf 100755
--- a/src/usr/i2c/i2c.C
+++ b/src/usr/i2c/i2c.C
@@ -44,11 +44,6 @@
// ----------------------------------------------
// Globals
// ----------------------------------------------
-// TODO - These are temporary until we get some sort of locking mutex
-// in the attributes for each master target. All operations will be
-// sequential no matter what target or what engine.
-mutex_t g_i2cMutex;
-bool g_initI2CMutex = true;
// ----------------------------------------------
// Trace definitions
@@ -58,6 +53,7 @@ TRAC_INIT( & g_trac_i2c, "I2C", 4096 );
trace_desc_t* g_trac_i2cr = NULL;
TRAC_INIT( & g_trac_i2cr, "I2CR", 4096 );
+
// Easy macro replace for unit testing
//#define TRACUCOMP(args...) TRACFCOMP(args)
#define TRACUCOMP(args...)
@@ -67,6 +63,7 @@ TRAC_INIT( & g_trac_i2cr, "I2CR", 4096 );
// ----------------------------------------------
#define I2C_COMMAND_ATTEMPTS 2 // 1 Retry on failure
#define I2C_RETRY_DELAY 10000000 // Sleep for 10 ms before retrying
+#define MAX_I2C_ENGINES 3 // Maximum of 3 engines per I2C Master
// ----------------------------------------------
namespace I2C
@@ -108,12 +105,6 @@ errlHndl_t i2cPerformOp( DeviceFW::OperationType i_opType,
do
{
- if( g_initI2CMutex )
- {
- mutex_init( &g_i2cMutex );
- g_initI2CMutex = false;
- }
-
// Check for Master Sentinel chip
if( TARGETING::MASTER_PROCESSOR_CHIP_TARGET_SENTINEL == i_target )
{
@@ -140,13 +131,38 @@ errlHndl_t i2cPerformOp( DeviceFW::OperationType i_opType,
break;
}
- // TODO - Locking needs to be implemented for each engine on each
- // possible chip. The details of this still need to be worked out.
- // This will be implemented with the bad machine path story (3629).
- // TODO - Locking will be waiting on Story 4158 to see how we can
- // handle the mutexes in the attributes... Use the global mutex
- // until then.
- mutex_lock( &g_i2cMutex );
+ // Get the mutex for the requested engine
+ mutex_t * engineLock = NULL;
+ switch( args.engine )
+ {
+ case 0:
+ engineLock = i_target->getHbMutexAttr<TARGETING::ATTR_I2C_ENGINE_MUTEX_0>();
+ break;
+
+ case 1:
+ engineLock = i_target->getHbMutexAttr<TARGETING::ATTR_I2C_ENGINE_MUTEX_1>();
+ break;
+
+ case 2:
+ engineLock = i_target->getHbMutexAttr<TARGETING::ATTR_I2C_ENGINE_MUTEX_2>();
+ break;
+
+ default:
+ TRACFCOMP( g_trac_i2c,
+ ERR_MRK"Invalid engine for getting Mutex!" );
+ // TODO - Create an error here
+ break;
+ };
+
+ // Lock on this engine
+ TRACUCOMP( g_trac_i2c,
+ INFO_MRK"Obtaining lock for engine: %d",
+ args.engine );
+ (void)mutex_lock( engineLock );
+ TRACUCOMP( g_trac_i2c,
+ INFO_MRK"Locked on engine: %d",
+ args.engine );
+
for( int attempt = 0; attempt < I2C_COMMAND_ATTEMPTS; attempt++ )
{
if( err )
@@ -222,7 +238,12 @@ errlHndl_t i2cPerformOp( DeviceFW::OperationType i_opType,
break;
}
}
- mutex_unlock( &g_i2cMutex );
+
+ // Unlock
+ (void) mutex_unlock( engineLock );
+ TRACUCOMP( g_trac_i2c,
+ INFO_MRK"Unlocked engine: %d",
+ args.engine );
if( err )
{
diff --git a/src/usr/targeting/xmltohb/attribute_types.xml b/src/usr/targeting/xmltohb/attribute_types.xml
index 471aa78f4..56eccf2a0 100644
--- a/src/usr/targeting/xmltohb/attribute_types.xml
+++ b/src/usr/targeting/xmltohb/attribute_types.xml
@@ -1024,5 +1024,44 @@
<readable/>
</attribute>
+<attribute>
+ <id>I2C_ENGINE_MUTEX_0</id>
+ <description>Mutex for I2C Master engine 0</description>
+ <simpleType>
+ <hbmutex>
+ <default>0</default>
+ </hbmutex>
+ </simpleType>
+ <persistency>volatile-zeroed</persistency>
+ <readable/>
+ <writeable/>
+</attribute>
+
+<attribute>
+ <id>I2C_ENGINE_MUTEX_1</id>
+ <description>Mutex for I2C Master engine 1</description>
+ <simpleType>
+ <hbmutex>
+ <default>0</default>
+ </hbmutex>
+ </simpleType>
+ <persistency>volatile-zeroed</persistency>
+ <readable/>
+ <writeable/>
+</attribute>
+
+<attribute>
+ <id>I2C_ENGINE_MUTEX_2</id>
+ <description>Mutex for I2C Master engine 2</description>
+ <simpleType>
+ <hbmutex>
+ <default>0</default>
+ </hbmutex>
+ </simpleType>
+ <persistency>volatile-zeroed</persistency>
+ <readable/>
+ <writeable/>
+</attribute>
+
</attributes>
diff --git a/src/usr/targeting/xmltohb/simics_SALERNO.system.xml b/src/usr/targeting/xmltohb/simics_SALERNO.system.xml
index 9dfa90433..afcdf1a98 100644
--- a/src/usr/targeting/xmltohb/simics_SALERNO.system.xml
+++ b/src/usr/targeting/xmltohb/simics_SALERNO.system.xml
@@ -85,7 +85,7 @@
<attribute>
<id>AFFINITY_PATH</id>
<default>affinity:sys-0/node-0/proc-0</default>
- </attribute>
+ </attribute>
</targetInstance>
<targetInstance>
diff --git a/src/usr/targeting/xmltohb/simics_VENICE.system.xml b/src/usr/targeting/xmltohb/simics_VENICE.system.xml
index 196d449a2..7d31d4d87 100644
--- a/src/usr/targeting/xmltohb/simics_VENICE.system.xml
+++ b/src/usr/targeting/xmltohb/simics_VENICE.system.xml
@@ -88,7 +88,7 @@
<attribute>
<id>AFFINITY_PATH</id>
<default>affinity:sys-0/node-0/proc-0</default>
- </attribute>
+ </attribute>
</targetInstance>
<!-- Venice n0p0 EX units -->
diff --git a/src/usr/targeting/xmltohb/target_types.xml b/src/usr/targeting/xmltohb/target_types.xml
index 22808e144..d2655574d 100644
--- a/src/usr/targeting/xmltohb/target_types.xml
+++ b/src/usr/targeting/xmltohb/target_types.xml
@@ -148,6 +148,18 @@
</attribute>
<attribute><id>DUMMY_RW</id></attribute>
<attribute><id>DUMMY_HEAP_ZERO_DEFAULT</id></attribute>
+ <attribute>
+ <id>I2C_ENGINE_MUTEX_0</id>
+ <default>0</default>
+ </attribute>
+ <attribute>
+ <id>I2C_ENGINE_MUTEX_1</id>
+ <default>0</default>
+ </attribute>
+ <attribute>
+ <id>I2C_ENGINE_MUTEX_2</id>
+ <default>0</default>
+ </attribute>
</targetType>
<targetType>
OpenPOWER on IntegriCloud