Skip to content

Commit d943029

Browse files
Mike KleinSkia Commit-Bot
authored andcommitted
blacklist Samsung Mongoose 3 from ASIMDHP
The big cores on Exynos 9810 (intl. Galaxy S9) are Mongoose 3, and report to support ASIMDHP but don't (unless you like crashing.) Tested locally with an intl. Galaxy S9 and a Pixel 3. See https://en.wikichip.org/wiki/samsung/exynos/9810, and golang/go#28431 for a similar bug with the same chip. Change-Id: Iddb4ff569f216508c5283e32f3411c49cd76fee0 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215948 Reviewed-by: Herb Derby <[email protected]> Commit-Queue: Mike Klein <[email protected]>
1 parent 1403ec8 commit d943029

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/core/SkCpu.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* found in the LICENSE file.
66
*/
77

8+
#include "include/core/SkStream.h"
9+
#include "include/core/SkString.h"
810
#include "include/private/SkOnce.h"
911
#include "src/core/SkCpu.h"
1012

@@ -81,6 +83,34 @@
8183
uint32_t hwcaps = getauxval(AT_HWCAP);
8284
if (hwcaps & kHWCAP_CRC32 ) { features |= SkCpu::CRC32; }
8385
if (hwcaps & kHWCAP_ASIMDHP) { features |= SkCpu::ASIMDHP; }
86+
87+
// The Samsung Mongoose 3 core sets the ASIMDHP bit but doesn't support it.
88+
for (int core = 0; features & SkCpu::ASIMDHP; core++) {
89+
// These /sys files contain the core's MIDR_EL1 register, the source of
90+
// CPU {implementer, variant, part, revision} you'd see in /proc/cpuinfo.
91+
SkString path =
92+
SkStringPrintf("/sys/devices/system/cpu/cpu%d/regs/identification/midr_el1", core);
93+
94+
// Can't use SkData::MakeFromFileName() here, I think because /sys can't be mmap()'d.
95+
SkFILEStream midr_el1(path.c_str());
96+
if (!midr_el1.isValid()) {
97+
// This is our ordinary exit path.
98+
// If we ask for MIDR_EL1 from a core that doesn't exist, we've checked all cores.
99+
if (core == 0) {
100+
// On the other hand, if we can't read MIDR_EL1 from any core, assume the worst.
101+
features &= ~(SkCpu::ASIMDHP);
102+
}
103+
break;
104+
}
105+
106+
const char kMongoose3[] = "0x00000000531f0020"; // 53 == Samsung.
107+
char buf[SK_ARRAY_COUNT(kMongoose3) - 1]; // No need for the terminating \0.
108+
109+
if (SK_ARRAY_COUNT(buf) != midr_el1.read(buf, SK_ARRAY_COUNT(buf))
110+
|| 0 == memcmp(kMongoose3, buf, SK_ARRAY_COUNT(buf))) {
111+
features &= ~(SkCpu::ASIMDHP);
112+
}
113+
}
84114
return features;
85115
}
86116

0 commit comments

Comments
 (0)