@ -656,8 +656,6 @@ void TDEHardwareDevices::processModifiedCPUs() {
time1 = time2 ;
time1 = time2 ;
# endif
# endif
TDECPUDevice * firstCPU = NULL ;
// Read in other information from cpufreq, if available
// Read in other information from cpufreq, if available
for ( processorNumber = 0 ; processorNumber < processorCount ; processorNumber + + ) {
for ( processorNumber = 0 ; processorNumber < processorCount ; processorNumber + + ) {
cdevice = dynamic_cast < TDECPUDevice * > ( findCPUBySystemPath ( TQString ( " /sys/devices/system/cpu/cpu%1 " ) . arg ( processorNumber ) ) ) ;
cdevice = dynamic_cast < TDECPUDevice * > ( findCPUBySystemPath ( TQString ( " /sys/devices/system/cpu/cpu%1 " ) . arg ( processorNumber ) ) ) ;
@ -672,79 +670,62 @@ void TDEHardwareDevices::processModifiedCPUs() {
TQStringList governorlist ;
TQStringList governorlist ;
if ( cpufreq_dir . exists ( ) ) {
if ( cpufreq_dir . exists ( ) ) {
TQString nodename ;
TQString nodename ;
if ( ( processorNumber = = 0 ) | | ( ! firstCPU ) ) {
nodename = cpufreq_dir . path ( ) ;
// Remember the first CPU options so that we can reuse it later.
nodename . append ( " /scaling_governor " ) ;
firstCPU = cdevice ;
TQFile scalinggovernorfile ( nodename ) ;
if ( scalinggovernorfile . open ( IO_ReadOnly ) ) {
nodename = cpufreq_dir . path ( ) ;
TQTextStream stream ( & scalinggovernorfile ) ;
nodename . append ( " /scaling_governor " ) ;
scalinggovernor = stream . readLine ( ) ;
TQFile scalinggovernorfile ( nodename ) ;
scalinggovernorfile . close ( ) ;
if ( scalinggovernorfile . open ( IO_ReadOnly ) ) {
TQTextStream stream ( & scalinggovernorfile ) ;
scalinggovernor = stream . readLine ( ) ;
scalinggovernorfile . close ( ) ;
}
nodename = cpufreq_dir . path ( ) ;
nodename . append ( " /scaling_driver " ) ;
TQFile scalingdriverfile ( nodename ) ;
if ( scalingdriverfile . open ( IO_ReadOnly ) ) {
TQTextStream stream ( & scalingdriverfile ) ;
scalingdriver = stream . readLine ( ) ;
scalingdriverfile . close ( ) ;
}
nodename = cpufreq_dir . path ( ) ;
nodename . append ( " /cpuinfo_min_freq " ) ;
TQFile minfrequencyfile ( nodename ) ;
if ( minfrequencyfile . open ( IO_ReadOnly ) ) {
TQTextStream stream ( & minfrequencyfile ) ;
minfrequency = stream . readLine ( ) . toDouble ( ) / 1000.0 ;
minfrequencyfile . close ( ) ;
}
nodename = cpufreq_dir . path ( ) ;
nodename . append ( " /cpuinfo_max_freq " ) ;
TQFile maxfrequencyfile ( nodename ) ;
if ( maxfrequencyfile . open ( IO_ReadOnly ) ) {
TQTextStream stream ( & maxfrequencyfile ) ;
maxfrequency = stream . readLine ( ) . toDouble ( ) / 1000.0 ;
maxfrequencyfile . close ( ) ;
}
nodename = cpufreq_dir . path ( ) ;
nodename . append ( " /cpuinfo_transition_latency " ) ;
TQFile trlatencyfile ( nodename ) ;
if ( trlatencyfile . open ( IO_ReadOnly ) ) {
TQTextStream stream ( & trlatencyfile ) ;
trlatency = stream . readLine ( ) . toDouble ( ) / 1000.0 ;
trlatencyfile . close ( ) ;
}
nodename = cpufreq_dir . path ( ) ;
nodename . append ( " /scaling_available_frequencies " ) ;
TQFile availfreqsfile ( nodename ) ;
if ( availfreqsfile . open ( IO_ReadOnly ) ) {
TQTextStream stream ( & availfreqsfile ) ;
frequencylist = TQStringList : : split ( " " , stream . readLine ( ) ) ;
availfreqsfile . close ( ) ;
}
nodename = cpufreq_dir . path ( ) ;
nodename . append ( " /scaling_available_governors " ) ;
TQFile availgvrnsfile ( nodename ) ;
if ( availgvrnsfile . open ( IO_ReadOnly ) ) {
TQTextStream stream ( & availgvrnsfile ) ;
governorlist = TQStringList : : split ( " " , stream . readLine ( ) ) ;
availgvrnsfile . close ( ) ;
}
}
}
// Other CPU should have the same values as the first one. Simply copy them.
nodename = cpufreq_dir . path ( ) ;
else {
nodename . append ( " /scaling_driver " ) ;
scalinggovernor = firstCPU - > governor ( ) ;
TQFile scalingdriverfile ( nodename ) ;
scalingdriver = firstCPU - > scalingDriver ( ) ;
if ( scalingdriverfile . open ( IO_ReadOnly ) ) {
minfrequency = firstCPU - > minFrequency ( ) ;
TQTextStream stream ( & scalingdriverfile ) ;
maxfrequency = firstCPU - > maxFrequency ( ) ;
scalingdriver = stream . readLine ( ) ;
trlatency = firstCPU - > transitionLatency ( ) ;
scalingdriverfile . close ( ) ;
frequencylist = firstCPU - > availableFrequencies ( ) ;
}
governorlist = firstCPU - > availableGovernors ( ) ;
nodename = cpufreq_dir . path ( ) ;
nodename . append ( " /cpuinfo_min_freq " ) ;
TQFile minfrequencyfile ( nodename ) ;
if ( minfrequencyfile . open ( IO_ReadOnly ) ) {
TQTextStream stream ( & minfrequencyfile ) ;
minfrequency = stream . readLine ( ) . toDouble ( ) / 1000.0 ;
minfrequencyfile . close ( ) ;
}
nodename = cpufreq_dir . path ( ) ;
nodename . append ( " /cpuinfo_max_freq " ) ;
TQFile maxfrequencyfile ( nodename ) ;
if ( maxfrequencyfile . open ( IO_ReadOnly ) ) {
TQTextStream stream ( & maxfrequencyfile ) ;
maxfrequency = stream . readLine ( ) . toDouble ( ) / 1000.0 ;
maxfrequencyfile . close ( ) ;
}
nodename = cpufreq_dir . path ( ) ;
nodename . append ( " /cpuinfo_transition_latency " ) ;
TQFile trlatencyfile ( nodename ) ;
if ( trlatencyfile . open ( IO_ReadOnly ) ) {
TQTextStream stream ( & trlatencyfile ) ;
trlatency = stream . readLine ( ) . toDouble ( ) / 1000.0 ;
trlatencyfile . close ( ) ;
}
nodename = cpufreq_dir . path ( ) ;
nodename . append ( " /scaling_available_frequencies " ) ;
TQFile availfreqsfile ( nodename ) ;
if ( availfreqsfile . open ( IO_ReadOnly ) ) {
TQTextStream stream ( & availfreqsfile ) ;
frequencylist = TQStringList : : split ( " " , stream . readLine ( ) ) ;
availfreqsfile . close ( ) ;
}
nodename = cpufreq_dir . path ( ) ;
nodename . append ( " /scaling_available_governors " ) ;
TQFile availgvrnsfile ( nodename ) ;
if ( availgvrnsfile . open ( IO_ReadOnly ) ) {
TQTextStream stream ( & availgvrnsfile ) ;
governorlist = TQStringList : : split ( " " , stream . readLine ( ) ) ;
availgvrnsfile . close ( ) ;
}
}
// The following data are different on each CPU
nodename = cpufreq_dir . path ( ) ;
nodename = cpufreq_dir . path ( ) ;
nodename . append ( " /affected_cpus " ) ;
nodename . append ( " /affected_cpus " ) ;
TQFile tiedcpusfile ( nodename ) ;
TQFile tiedcpusfile ( nodename ) ;
@ -756,16 +737,29 @@ void TDEHardwareDevices::processModifiedCPUs() {
// We may already have the CPU Mhz information in '/proc/cpuinfo'
// We may already have the CPU Mhz information in '/proc/cpuinfo'
if ( ! have_frequency ) {
if ( ! have_frequency ) {
bool cpufreq_have_frequency = false ;
nodename = cpufreq_dir . path ( ) ;
nodename = cpufreq_dir . path ( ) ;
nodename . append ( " / cpuinfo _cur_freq" ) ;
nodename . append ( " / scaling _cur_freq" ) ;
TQFile cpufreqfile ( nodename ) ;
TQFile cpufreqfile ( nodename ) ;
if ( cpufreqfile . open ( IO_ReadOnly ) ) {
if ( cpufreqfile . open ( IO_ReadOnly ) ) {
cpufreq_have_frequency = true ;
}
else {
nodename = cpufreq_dir . path ( ) ;
nodename . append ( " /cpuinfo_cur_freq " ) ;
cpufreqfile . setName ( nodename ) ;
if ( cpufreqfile . open ( IO_ReadOnly ) ) {
cpufreq_have_frequency = true ;
}
}
if ( cpufreq_have_frequency ) {
TQTextStream stream ( & cpufreqfile ) ;
TQTextStream stream ( & cpufreqfile ) ;
if ( cdevice ) {
double cpuinfo_cur_freq = stream . readLine ( ) . toDouble ( ) / 1000.0 ;
cdevice - > internalSetFrequency ( stream . readLine ( ) . toDouble ( ) / 1000.0 ) ;
if ( cdevice & & cdevice - > frequency ( ) ! = cpuinfo_cur_freq ) {
modified = true ;
cdevice - > internalSetFrequency ( cpuinfo_cur_freq ) ;
}
}
cpufreqfile . close ( ) ;
cpufreqfile . close ( ) ;
have_frequency = true ;
}
}
}
}