Skip to content

Commit e829e80

Browse files
authored
Adding ro.soc.model support to cpuinfo to detect Qualcomm SM8850 SoC (pytorch#381)
* Adding ro.soc.model support to cpuinfo to detect Qualcomm SM8850 SoC. * style: format src/riscv/linux/riscv-hw.c with clang-format
1 parent d05fbcd commit e829e80

6 files changed

Lines changed: 66 additions & 25 deletions

File tree

src/arm/android/api.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ enum cpuinfo_android_chipset_property {
1313
cpuinfo_android_chipset_property_ro_arch,
1414
cpuinfo_android_chipset_property_ro_chipname,
1515
cpuinfo_android_chipset_property_ro_hardware_chipname,
16+
cpuinfo_android_chipset_property_ro_soc_model,
1617
cpuinfo_android_chipset_property_max,
1718
};
1819

src/arm/android/properties.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,7 @@ void cpuinfo_arm_android_parse_properties(struct cpuinfo_android_properties prop
6363
cpuinfo_android_property_get("ro.hardware.chipname", properties->ro_hardware_chipname);
6464
cpuinfo_log_debug(
6565
"read ro.hardware.chipname = \"%.*s\"", ro_hardware_chipname_length, properties->ro_hardware_chipname);
66+
67+
const int ro_soc_model_length = cpuinfo_android_property_get("ro.soc.model", properties->ro_soc_model);
68+
cpuinfo_log_debug("read ro.soc.model = \"%.*s\"", ro_soc_model_length, properties->ro_soc_model);
6669
}

src/arm/api.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ enum cpuinfo_arm_chipset_series {
4545
cpuinfo_arm_chipset_series_qualcomm_msm,
4646
cpuinfo_arm_chipset_series_qualcomm_apq,
4747
cpuinfo_arm_chipset_series_qualcomm_snapdragon,
48+
cpuinfo_arm_chipset_series_qualcomm_sm,
4849
cpuinfo_arm_chipset_series_mediatek_mt,
4950
cpuinfo_arm_chipset_series_samsung_exynos,
5051
cpuinfo_arm_chipset_series_hisilicon_k3v,

src/arm/linux/api.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ struct cpuinfo_android_properties {
2929
char ro_arch[CPUINFO_BUILD_PROP_VALUE_MAX];
3030
char ro_chipname[CPUINFO_BUILD_PROP_VALUE_MAX];
3131
char ro_hardware_chipname[CPUINFO_BUILD_PROP_VALUE_MAX];
32+
char ro_soc_model[CPUINFO_BUILD_PROP_VALUE_MAX];
3233
};
3334
#endif
3435

@@ -364,6 +365,8 @@ CPUINFO_INTERNAL struct cpuinfo_arm_chipset cpuinfo_arm_android_decode_chipset_f
364365
const char ro_chipname[restrict static CPUINFO_BUILD_PROP_VALUE_MAX]);
365366
CPUINFO_INTERNAL struct cpuinfo_arm_chipset cpuinfo_arm_android_decode_chipset_from_ro_hardware_chipname(
366367
const char ro_hardware_chipname[restrict static CPUINFO_BUILD_PROP_VALUE_MAX]);
368+
CPUINFO_INTERNAL struct cpuinfo_arm_chipset cpuinfo_arm_android_decode_chipset_from_ro_soc_model(
369+
const char ro_soc_model[restrict static CPUINFO_BUILD_PROP_VALUE_MAX]);
367370
#else
368371
CPUINFO_INTERNAL struct cpuinfo_arm_chipset cpuinfo_arm_linux_decode_chipset_from_proc_cpuinfo_revision(
369372
const char proc_cpuinfo_revision[restrict static CPUINFO_REVISION_VALUE_MAX]);

src/arm/linux/chipset.c

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ static bool match_sm(const char* start, const char* end, struct cpuinfo_arm_chip
264264
/* Return parsed chipset. */
265265
*chipset = (struct cpuinfo_arm_chipset){
266266
.vendor = cpuinfo_arm_chipset_vendor_qualcomm,
267-
.series = cpuinfo_arm_chipset_series_qualcomm_snapdragon,
267+
.series = cpuinfo_arm_chipset_series_qualcomm_sm,
268268
.model = model,
269269
};
270270
return true;
@@ -3491,6 +3491,36 @@ struct cpuinfo_arm_chipset cpuinfo_arm_android_decode_chipset_from_ro_chipname(
34913491
.series = cpuinfo_arm_chipset_series_unknown,
34923492
};
34933493
}
3494+
3495+
struct cpuinfo_arm_chipset cpuinfo_arm_android_decode_chipset_from_ro_soc_model(
3496+
const char soc_model[restrict static CPUINFO_BUILD_PROP_VALUE_MAX]) {
3497+
struct cpuinfo_arm_chipset chipset;
3498+
const size_t soc_model_length = strnlen(soc_model, CPUINFO_BUILD_PROP_VALUE_MAX);
3499+
const char* soc_model_end = soc_model + soc_model_length;
3500+
3501+
/* Check Qualcomm SMxxxx signature */
3502+
if (match_sm(soc_model, soc_model_end, &chipset)) {
3503+
cpuinfo_log_debug(
3504+
"matched Qualcomm SM signature in ro.soc.model string \"%.*s\"",
3505+
(int)soc_model_length,
3506+
soc_model);
3507+
return chipset;
3508+
}
3509+
3510+
/* Check Qualcomm MSM/APQ signatures */
3511+
if (match_msm_apq(soc_model, soc_model_end, &chipset)) {
3512+
cpuinfo_log_debug(
3513+
"matched Qualcomm MSM/APQ signature in ro.soc.model string \"%.*s\"",
3514+
(int)soc_model_length,
3515+
soc_model);
3516+
return chipset;
3517+
}
3518+
3519+
return (struct cpuinfo_arm_chipset){
3520+
.vendor = cpuinfo_arm_chipset_vendor_unknown,
3521+
.series = cpuinfo_arm_chipset_series_unknown,
3522+
};
3523+
}
34943524
#endif /* __ANDROID__ */
34953525

34963526
/*
@@ -3837,6 +3867,7 @@ static const char* chipset_series_string[cpuinfo_arm_chipset_series_max] = {
38373867
[cpuinfo_arm_chipset_series_qualcomm_msm] = "MSM",
38383868
[cpuinfo_arm_chipset_series_qualcomm_apq] = "APQ",
38393869
[cpuinfo_arm_chipset_series_qualcomm_snapdragon] = "Snapdragon ",
3870+
[cpuinfo_arm_chipset_series_qualcomm_sm] = "SM",
38403871
[cpuinfo_arm_chipset_series_mediatek_mt] = "MT",
38413872
[cpuinfo_arm_chipset_series_samsung_exynos] = "Exynos ",
38423873
[cpuinfo_arm_chipset_series_hisilicon_k3v] = "K3V",
@@ -4074,6 +4105,8 @@ struct cpuinfo_arm_chipset cpuinfo_arm_android_decode_chipset(
40744105
cpuinfo_arm_android_decode_chipset_from_ro_chipname(properties->ro_chipname),
40754106
[cpuinfo_android_chipset_property_ro_hardware_chipname] =
40764107
cpuinfo_arm_android_decode_chipset_from_ro_chipname(properties->ro_hardware_chipname),
4108+
[cpuinfo_android_chipset_property_ro_soc_model] =
4109+
cpuinfo_arm_android_decode_chipset_from_ro_soc_model(properties->ro_soc_model),
40774110
};
40784111
enum cpuinfo_arm_chipset_vendor vendor = cpuinfo_arm_chipset_vendor_unknown;
40794112
for (size_t i = 0; i < cpuinfo_android_chipset_property_max; i++) {

src/riscv/linux/riscv-hw.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -53,30 +53,30 @@ struct riscv_hwprobe {
5353
#define RISCV_HWPROBE_EXT_ZBB (1 << 4)
5454
#define RISCV_HWPROBE_EXT_ZBS (1 << 5)
5555
#define RISCV_HWPROBE_EXT_ZICBOZ (1 << 6)
56-
#define RISCV_HWPROBE_EXT_ZBC (1 << 7)
57-
#define RISCV_HWPROBE_EXT_ZBKB (1 << 8)
58-
#define RISCV_HWPROBE_EXT_ZBKC (1 << 9)
59-
#define RISCV_HWPROBE_EXT_ZBKX (1 << 10)
60-
#define RISCV_HWPROBE_EXT_ZKND (1 << 11)
61-
#define RISCV_HWPROBE_EXT_ZKNE (1 << 12)
62-
#define RISCV_HWPROBE_EXT_ZKNH (1 << 13)
63-
#define RISCV_HWPROBE_EXT_ZKSED (1 << 14)
64-
#define RISCV_HWPROBE_EXT_ZKSH (1 << 15)
65-
#define RISCV_HWPROBE_EXT_ZKT (1 << 16)
66-
#define RISCV_HWPROBE_EXT_ZVBB (1 << 17)
67-
#define RISCV_HWPROBE_EXT_ZVBC (1 << 18)
68-
#define RISCV_HWPROBE_EXT_ZVKB (1 << 19)
69-
#define RISCV_HWPROBE_EXT_ZVKG (1 << 20)
70-
#define RISCV_HWPROBE_EXT_ZVKNED (1 << 21)
71-
#define RISCV_HWPROBE_EXT_ZVKNHA (1 << 22)
72-
#define RISCV_HWPROBE_EXT_ZVKNHB (1 << 23)
73-
#define RISCV_HWPROBE_EXT_ZVKSED (1 << 24)
74-
#define RISCV_HWPROBE_EXT_ZVKSH (1 << 25)
75-
#define RISCV_HWPROBE_EXT_ZVKT (1 << 26)
76-
#define RISCV_HWPROBE_EXT_ZFH (1 << 27)
77-
#define RISCV_HWPROBE_EXT_ZFHMIN (1 << 28)
78-
#define RISCV_HWPROBE_EXT_ZIHINTNTL (1 << 29)
79-
#define RISCV_HWPROBE_EXT_ZVFH (1 << 30)
56+
#define RISCV_HWPROBE_EXT_ZBC (1 << 7)
57+
#define RISCV_HWPROBE_EXT_ZBKB (1 << 8)
58+
#define RISCV_HWPROBE_EXT_ZBKC (1 << 9)
59+
#define RISCV_HWPROBE_EXT_ZBKX (1 << 10)
60+
#define RISCV_HWPROBE_EXT_ZKND (1 << 11)
61+
#define RISCV_HWPROBE_EXT_ZKNE (1 << 12)
62+
#define RISCV_HWPROBE_EXT_ZKNH (1 << 13)
63+
#define RISCV_HWPROBE_EXT_ZKSED (1 << 14)
64+
#define RISCV_HWPROBE_EXT_ZKSH (1 << 15)
65+
#define RISCV_HWPROBE_EXT_ZKT (1 << 16)
66+
#define RISCV_HWPROBE_EXT_ZVBB (1 << 17)
67+
#define RISCV_HWPROBE_EXT_ZVBC (1 << 18)
68+
#define RISCV_HWPROBE_EXT_ZVKB (1 << 19)
69+
#define RISCV_HWPROBE_EXT_ZVKG (1 << 20)
70+
#define RISCV_HWPROBE_EXT_ZVKNED (1 << 21)
71+
#define RISCV_HWPROBE_EXT_ZVKNHA (1 << 22)
72+
#define RISCV_HWPROBE_EXT_ZVKNHB (1 << 23)
73+
#define RISCV_HWPROBE_EXT_ZVKSED (1 << 24)
74+
#define RISCV_HWPROBE_EXT_ZVKSH (1 << 25)
75+
#define RISCV_HWPROBE_EXT_ZVKT (1 << 26)
76+
#define RISCV_HWPROBE_EXT_ZFH (1 << 27)
77+
#define RISCV_HWPROBE_EXT_ZFHMIN (1 << 28)
78+
#define RISCV_HWPROBE_EXT_ZIHINTNTL (1 << 29)
79+
#define RISCV_HWPROBE_EXT_ZVFH (1 << 30)
8080
#define RISCV_HWPROBE_KEY_CPUPERF_0 5
8181
#define RISCV_HWPROBE_MISALIGNED_UNKNOWN (0 << 0)
8282
#define RISCV_HWPROBE_MISALIGNED_EMULATED (1 << 0)

0 commit comments

Comments
 (0)