Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Zgemma H9 CPU info #1659

Closed
wants to merge 2 commits into from
Closed

Fix Zgemma H9 CPU info #1659

wants to merge 2 commits into from

Conversation

persianpros
Copy link
Contributor

@persianpros persianpros commented Jul 29, 2018

Each commit has descriptions.

I'm going to use this for Zgemma h9 CPU info problem (undefined) but we can use this in future for any hisilicon related thing so it's not box specific.
/proc/cpuinfo won't give us what we need for h9 instead /proc/stb/info/chipset give us hi3798mv200 which is the right info for cpu model.
/proc/cpuinfo won't give us what we need for h9 instead /proc/stb/info/chipset give us hi3798mv200
After this you will see 1600 MHz (4 cores) too.
It seems HiSilicon has this problem so you could use this for future models too.
Screenshot: https://forums.openpli.org/topic/28532-merge-requests-for-plis-git/?view=findpost&p=912860
littlesat didn't accepted my old PR: #1658 but I won't give up.
Thanks PLi anyway I'm still your fan.
@littlesat
Copy link
Member

The systeminfo is likely not needed... when the correct CPU grabber does not have output then just use chipinfo avoiding an if box x then y in systeminfo and also make the code usefull when other boxes do the same

@athoik
Copy link
Contributor

athoik commented Jul 29, 2018

What /proc/cpuinfo displays for that model?

Also lscpu shows what? (opkg install util-linux-lscpu)

@littlesat
Copy link
Member

PP, what is the current response on the h9? Sorry I don’t have one... ;)

@persianpros
Copy link
Contributor Author

persianpros commented Jul 30, 2018

@athoik

cat /proc/cpuinfo:

processor : 0
Processor : ARMv7 Processor rev 4 (v7l)
BogoMIPS : 3170.30
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae aes pmull sha1 sha2 crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xd03
CPU revision : 4

processor : 1
Processor : ARMv7 Processor rev 4 (v7l)
BogoMIPS : 3170.30
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae aes pmull sha1 sha2 crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xd03
CPU revision : 4

processor : 2
Processor : ARMv7 Processor rev 4 (v7l)
BogoMIPS : 3170.30
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae aes pmull sha1 sha2 crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xd03
CPU revision : 4

processor : 3
Processor : ARMv7 Processor rev 4 (v7l)
BogoMIPS : 3170.30
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae aes pmull sha1 sha2 crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xd03
CPU revision : 4

Hardware : bigfish
Revision : 0000
Serial : 0000000000000000

lscpu:

Architecture: armv7l
Byte Order: Little Endian
CPU(s): 4
On-line CPU(s) list: 0-3
Thread(s) per core: 1
Core(s) per socket: 4
Socket(s): 1
Model: 4
CPU max MHz: 1600.0000
CPU min MHz: 400.0000
BogoMIPS: 3170.30
Flags: half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae aes pmull sha1 sha2 crc32

Also I need to add /proc/stb/fp/temp_sensor for cpu temperature ...

@persianpros
Copy link
Contributor Author

persianpros commented Jul 30, 2018

@littlesat

This works for me too: #1660

Is it ok for other brands/models or it breaks something?

@littlesat
Copy link
Member

What is the current output as I see the cpu’s Are also mentioned in the proc

@littlesat
Copy link
Member

With that output no need is changes as far I can see... What is shown now?

@littlesat
Copy link
Member

littlesat commented Jul 30, 2018

This is my phython comment line test code for this one...

# -*- coding: utf-8 -*-
import os
cpu_count = cpu_speed = processor = 0

for line in open("/proc/cpuinfo").readlines():
        line = [x.strip() for x in line.strip().split(":")]
        if line[0] in ("system type", "model name"):
                processor = line[1].split()[0]
        elif line[0] == "cpu MHz":
                cpu_speed = "%1.0f" % float(line[1])
        elif line[0] == "processor":
                cpu_count += 1

if not cpu_speed:
        try:
                cpu_speed = int(open("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq").read()) / 1000
        except:
                try:
                        import binascii
                        cpu_speed = int(int(binascii.hexlify(open('/sys/firmware/devicetree/base/cpus/cpu@0/clock-frequency', 'rb').read()), 16) / 100000000) * 100
                except:
                        cpu_speed = "-"

temperature = None
if os.path.isfile('/proc/stb/fp/temp_sensor_avs'):
        temperature = open("/proc/stb/fp/temp_sensor_avs").readline().replace('\n','')
elif os.path.isfile('/proc/stb/power/avs'):
        temperature = open("/proc/stb/power/avs").readline().replace('\n','')
elif os.path.isfile("/sys/devices/virtual/thermal/thermal_zone0/temp"):
        try:
                temperature = int(open("/sys/devices/virtual/thermal/thermal_zone0/temp").read().strip())/1000
        except:
                pass
if temperature:
        print "%s %s MHz (%s) %s°C" % (processor, cpu_speed, "%d cores" % cpu_count, temperature)
else:
        print "%s %s MHz (%s)" % (processor, cpu_speed, "%d cores" % cpu_count)

@persianpros
Copy link
Contributor Author

persianpros commented Jul 30, 2018

Current PLi shows : "undefined" without cores without speed without temp.

With my changes: hi3798mv200 1600 4 core and temp

I can't test your code right now but tomorrow I will ...

@littlesat
Copy link
Member

We need to investigate why the info is not there
Instead of work a round it...

@littlesat
Copy link
Member

I think it is more related to cases... I think it should be fixed when we force the line[0] to lower case...

@littlesat
Copy link
Member

And I see it has max and min MHZ for
CPU speed so we need to parse CPU MHz
And CPU max MHz (but then in lower cAse)

@persianpros
Copy link
Contributor Author

persianpros commented Jul 30, 2018

I think you missed it, you're looking for "model name" in /proc/cpuinfo but there isn't one for hisilicon as you can see the output.

The second part is from lscpu (see where I wrote lscpu:) which is available only when you install util-linux-lscpu so don't consider it (athoik asked for it).

Also when I add #1660 undefined no more (correct cpu model) and with speed and cores. so speed and core detection is ok but cpu model is only available in /proc/stb/info/chipset

For temp we don't have the correct proc file which is /proc/stb/fp/temp_sensor

Please only test this #1660 on your machines as it's ok for hisilicon and h9, I just wan't to know if it doesn't break anything we can use it.

@littlesat
Copy link
Member

Then when the current parser has no output do the thing you want to do... then no if box x then do y is required....

@persianpros
Copy link
Contributor Author

persianpros commented Jul 31, 2018

@littlesat forget about this PR just check #1660 please, which does the job for h9 and I want to know if it's ok for other models too (please test it on your boxes).

Thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants