Skip to content

Commit

Permalink
Merge pull request #265 from GregoryComer/ums312-dot-disable
Browse files Browse the repository at this point in the history
Disable neon dot  on Unisoc UMS312
  • Loading branch information
GregoryComer authored Oct 29, 2024
2 parents dff2616 + 5ca8ae1 commit 8df4496
Show file tree
Hide file tree
Showing 6 changed files with 158 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/arm/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ enum cpuinfo_arm_chipset_series {
cpuinfo_arm_chipset_series_telechips_tcc,
cpuinfo_arm_chipset_series_texas_instruments_omap,
cpuinfo_arm_chipset_series_unisoc_t,
cpuinfo_arm_chipset_series_unisoc_ums,
cpuinfo_arm_chipset_series_wondermedia_wm,
cpuinfo_arm_chipset_series_max,
};
Expand Down
2 changes: 2 additions & 0 deletions src/arm/linux/aarch32-isa.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ void cpuinfo_arm_linux_decode_isa_from_proc_cpuinfo(
"VDOT instructions disabled: cause occasional SIGILL on Spreadtrum SC9863A");
} else if (chipset->series == cpuinfo_arm_chipset_series_unisoc_t && chipset->model == 310) {
cpuinfo_log_warning("VDOT instructions disabled: cause occasional SIGILL on Unisoc T310");
} else if (chipset->series == cpuinfo_arm_chipset_series_unisoc_ums && chipset->model == 312) {
cpuinfo_log_warning("VDOT instructions disabled: cause occasional SIGILL on Unisoc UMS312");
} else {
switch (midr & (CPUINFO_ARM_MIDR_IMPLEMENTER_MASK | CPUINFO_ARM_MIDR_PART_MASK)) {
case UINT32_C(0x4100D0B0): /* Cortex-A76 */
Expand Down
76 changes: 76 additions & 0 deletions src/arm/linux/chipset.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ static enum cpuinfo_arm_chipset_vendor chipset_series_vendor[cpuinfo_arm_chipset
[cpuinfo_arm_chipset_series_telechips_tcc] = cpuinfo_arm_chipset_vendor_telechips,
[cpuinfo_arm_chipset_series_texas_instruments_omap] = cpuinfo_arm_chipset_vendor_texas_instruments,
[cpuinfo_arm_chipset_series_unisoc_t] = cpuinfo_arm_chipset_vendor_unisoc,
[cpuinfo_arm_chipset_series_unisoc_ums] = cpuinfo_arm_chipset_vendor_unisoc,
[cpuinfo_arm_chipset_series_wondermedia_wm] = cpuinfo_arm_chipset_vendor_wondermedia,
};

Expand Down Expand Up @@ -959,6 +960,70 @@ static bool match_t(const char* start, const char* end, struct cpuinfo_arm_chips
return true;
}

/**
* Tries to match, case-sentitively, /Unisoc UMS\d{3,4}/ signature for Unisoc UMS
* chipset. If match successful, extracts model information into \p chipset
* argument.
*
* @param start - start of the platform identifier (/proc/cpuinfo Hardware
* string, ro.product.board, ro.board.platform, or ro.chipname) to match.
* @param end - end of the platform identifier (/proc/cpuinfo Hardware string,
* ro.product.board, ro.board.platform, or ro.chipname) to match.
* @param[out] chipset - location where chipset information will be stored upon
* a successful match.
*
* @returns true if signature matched, false otherwise.
*/
static bool match_ums(const char* start, const char* end, struct cpuinfo_arm_chipset chipset[restrict static 1]) {
/* Expect 13-14 symbols: "Unisoc UMS" (10 symbols) + 3-4-digit model number
*/
const size_t length = end - start;
switch (length) {
case 13:
case 14:
break;
default:
return false;
}

/* Check that string starts with "Unisoc UMS". The first four characters
* are loaded as 32-bit little endian word */
const uint32_t expected_unis = load_u32le(start);
if (expected_unis != UINT32_C(0x73696E55) /* "sinU" = reverse("Unis") */) {
return false;
}

/* The next four characters are loaded as 32-bit little endian word */
const uint32_t expected_oc_u = load_u32le(start + 4);
if (expected_oc_u != UINT32_C(0x5520636F) /* "U co" = reverse("oc U") */) {
return false;
}

/* The next four characters are loaded as 16-bit little endian word */
const uint16_t expected_ms = load_u16le(start + 8);
if (expected_ms != UINT16_C(0x534D) /* "SM" = reverse("MS") */) {
return false;
}

/* Validate and parse 3-4 digit model number */
uint32_t model = 0;
for (uint32_t i = 10; i < length; i++) {
const uint32_t digit = (uint32_t)(uint8_t)start[i] - '0';
if (digit >= 10) {
/* Not really a digit */
return false;
}
model = model * 10 + digit;
}

*chipset = (struct cpuinfo_arm_chipset){
.vendor = cpuinfo_arm_chipset_vendor_unisoc,
.series = cpuinfo_arm_chipset_series_unisoc_ums,
.model = model,
};
return true;
}

/**
* Tries to match /lc\d{4}[a-z]?$/ signature for Leadcore LC chipsets.
* If match successful, extracts model information into \p chipset argument.
Expand Down Expand Up @@ -2508,6 +2573,16 @@ struct cpuinfo_arm_chipset cpuinfo_arm_linux_decode_chipset_from_proc_cpuinfo_ha
return chipset;
}

/* Check Unisoc UMS signature */
if (match_ums(hardware, hardware_end, &chipset)) {
cpuinfo_log_debug(
"matched Unisoc UMS signature in /proc/cpuinfo Hardware string \"%.*s\"",
(int)hardware_length,
hardware);

return chipset;
}

#if CPUINFO_ARCH_ARM
/* Check Marvell PXA signature */
if (match_pxa(hardware, hardware_end, &chipset)) {
Expand Down Expand Up @@ -3726,6 +3801,7 @@ static const char* chipset_series_string[cpuinfo_arm_chipset_series_max] = {
[cpuinfo_arm_chipset_series_telechips_tcc] = "TCC",
[cpuinfo_arm_chipset_series_texas_instruments_omap] = "OMAP",
[cpuinfo_arm_chipset_series_unisoc_t] = "T",
[cpuinfo_arm_chipset_series_unisoc_ums] = "UMS",
[cpuinfo_arm_chipset_series_wondermedia_wm] = "WM",
};

Expand Down
31 changes: 31 additions & 0 deletions test/build.prop/astro_55r.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# begin build properties
# autogenerated by buildinfo.sh
ro.build.id=RP1A.201005.001
ro.build.display.id=Maxwest_Astro_55R_V07_01052022
ro.build.version.incremental=1634868762
ro.build.version.sdk=30
ro.build.version.codename=REL
ro.build.version.release=11
ro.build.date=Wed Jan 5 10:40:24 CST 2022
ro.build.date.utc=1641350424
ro.build.type=user
ro.build.user=lxc
ro.build.host=Astro__55R
ro.build.tags=release-keys
ro.product.model=Astro 55R
ro.product.brand=Maxwest
ro.product.name=Astro_55R
ro.product.device=Astro_55R
ro.product.board=Maxwest
ro.product.cpu.abi=armeabi-v7a
ro.product.manufacturer=Maxwest
ro.product.locale.language=
ro.product.locale.region=
ro.wifi.channels=
ro.board.platform=ums312
# ro.build.product is obsolete; use ro.product.device
ro.build.product=Astro__55R
# Do not try to parse ro.build.description or .fingerprint
ro.build.description=ums312_2h10_1239SWQ_T5513A_A1_MV1616-user 11 RP1A.201005.001 1634868762 release-keys
ro.build.fingerprint=Maxwest/Astro_55R/Astro_55R:11/RP1A.201005.001/1634868762:user/release-keys
# end build properties
43 changes: 43 additions & 0 deletions test/cpuinfo/astro-55r.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
processor : 0
model name : ARMv8 Processor
BogoMIPS : 41.60
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm aes pmull sha1 sha2 crc32
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x1
CPU part : 0xd05
CPU revision : 0

processor : 1
model name : ARMv8 Processor
BogoMIPS : 41.60
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm aes pmull sha1 sha2 crc32
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x1
CPU part : 0xd05
CPU revision : 0

processor : 2
model name : ARMv8 Processor
BogoMIPS : 41.60
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm aes pmull sha1 sha2 crc32
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x1
CPU part : 0xd05
CPU revision : 0

processor : 3
model name : ARMv8 Processor
BogoMIPS : 62.71
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm aes pmull sha1 sha2 crc32
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x3
CPU part : 0xd0a
CPU revision : 1

Hardware : Unisoc UMS312
Revision : 0000
Serial : c9fb2689fd35cfe34d8d2523c9d3c439e8250fb06aaaafb732fe57478326d6cd
5 changes: 5 additions & 0 deletions test/name/proc-cpuinfo-hardware.cc
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,11 @@ TEST(PROC_CPUINFO_HARDWARE, telechips) {
EXPECT_EQ("Telechips TCC893X", parse_proc_cpuinfo_hardware("tcc893x"));
}

TEST(PROC_CPUINFO_HARDWARE, unisoc) {
EXPECT_EQ("Unisoc T301", parse_proc_cpuinfo_hardware("Unisoc T301", 4, 1800000));
EXPECT_EQ("Unisoc UMS312", parse_proc_cpuinfo_hardware("Unisoc UMS312", 4, 1800000));
}

#if CPUINFO_ARCH_ARM
TEST(PROC_CPUINFO_HARDWARE, texas_instruments_omap) {
EXPECT_EQ("Texas Instruments OMAP4430", parse_proc_cpuinfo_hardware("OMAP4430"));
Expand Down

0 comments on commit 8df4496

Please sign in to comment.