fix(drivers): never load a KGSL-only display driver on a GPU without KGSL, and report the drivers actually in use (#2588)

* fix(drivers): never load a KGSL-only display driver on a GPU without KGSL, and report the drivers actually in use

* fix(drivers): gate KGSL-only drivers on the KGSL kernel node, not Adreno detection
This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-11-15 09:36:47 -05:00
1 parent 1570d4457c
commit b424bfa353
5 files changed
+96 -7

No files matched your search

@@ -96,6 +96,55 @@ class TurnipDriverAutoTest {
assertEquals("test-pinned", TurnipDriver(context) { error("manual choice must precede detection") }.install())
}
private fun pin(library: String): String {
val context = RuntimeEnvironment.getApplication()
val dir = File(context.filesDir, "graphics_driver/test-pinned").apply { mkdirs() }
File(dir, "meta.json").writeText("""{"libraryName":"test.so"}""")
File(dir, "test.so").writeText(library)
SessionPrefs.setAndroidDriver(context, "test-pinned")
return "test-pinned"
}
@Test fun aPickedDriverThatNeedsKgslFallsBackToTheSystemLoaderWithoutKgsl() {
val context = RuntimeEnvironment.getApplication()
pin("\u0000tu_kgsl\u0000/dev/kgsl-3d0\u0000")
val driver = TurnipDriver(context) { error("manual choice must precede detection") }
assertEquals(null, driver.install())
assertEquals("system", driver.effectiveId())
assertEquals(false, driver.reachesGpu("test-pinned"))
}
@Test fun aPickedDriverForAnotherKernelInterfaceIsStillLoaded() {
val context = RuntimeEnvironment.getApplication()
val id = pin("\u0000panvk\u0000/dev/mali0\u0000")
val driver = TurnipDriver(context) { error("manual choice must precede detection") }
assertEquals(id, driver.install())
assertEquals(id, driver.effectiveId())
}
@Test fun kgslDriversStayUsableWhereKgslExists() {
val lib = File(RuntimeEnvironment.getApplication().filesDir, "graphics_driver/test-pinned/test.so")
lib.parentFile!!.mkdirs()
lib.writeText("/dev/kgsl-3d0")
assertEquals(false, TurnipDriver.needsMissingKgsl(lib, true))
assertEquals(true, TurnipDriver.needsMissingKgsl(lib, false))
lib.writeText("/dev/mali0")
assertEquals(false, TurnipDriver.needsMissingKgsl(lib, false))
assertEquals(false, TurnipDriver.needsMissingKgsl(File(lib.parentFile, "absent.so"), false))
}
@Test fun kgslIsTheKernelInterfaceNotTheVendorVulkanLibrary() {
val root = File(RuntimeEnvironment.getApplication().filesDir, "kgsl-probe").apply { mkdirs() }
val node = File(root, "dev-kgsl-3d0")
val sysfs = File(root, "sys-kgsl-3d0")
assertEquals(false, TurnipDriver.kgslPresent(node, sysfs))
node.writeText("")
assertEquals(true, TurnipDriver.kgslPresent(node, sysfs))
node.delete()
sysfs.mkdirs()
assertEquals(true, TurnipDriver.kgslPresent(node, sysfs))
}
@Test fun normalizedGpuModelsSelectExistingGenerationDrivers() {
for (sdk in listOf(28, 36)) {
assertEquals("turnip26.3.0-a6xx", TurnipDriver.chooseByModel(650, sdk))