From 254e16714f91a6041f29b36ee547be98572643e5 Mon Sep 17 00:00:00 2001 From: Werner Sembach Date: Fri, 14 Apr 2023 20:19:08 +0200 Subject: [PATCH 1/6] Add check that enforces TUXEDO dmi string on the newest devices --- src/tuxedo_keyboard.c | 109 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) diff --git a/src/tuxedo_keyboard.c b/src/tuxedo_keyboard.c index fb1d097..cbb23c3 100644 --- a/src/tuxedo_keyboard.c +++ b/src/tuxedo_keyboard.c @@ -22,6 +22,9 @@ #include "clevo_keyboard.h" #include "uniwill_keyboard.h" #include +#include +#include +#include MODULE_AUTHOR("TUXEDO Computers GmbH "); MODULE_DESCRIPTION("TUXEDO Computers keyboard & keyboard backlight Driver"); @@ -158,9 +161,115 @@ void tuxedo_keyboard_remove_driver(struct tuxedo_keyboard_driver *tk_driver) } EXPORT_SYMBOL(tuxedo_keyboard_remove_driver); +static const struct x86_cpu_id skip_tuxedo_dmi_string_check_match[] __initconst = { + X86_MATCH_INTEL_FAM6_MODEL(CORE_YONAH, NULL), + X86_MATCH_INTEL_FAM6_MODEL(CORE2_MEROM, NULL), + X86_MATCH_INTEL_FAM6_MODEL(CORE2_MEROM_L, NULL), + X86_MATCH_INTEL_FAM6_MODEL(CORE2_PENRYN, NULL), + X86_MATCH_INTEL_FAM6_MODEL(CORE2_DUNNINGTON, NULL), + X86_MATCH_INTEL_FAM6_MODEL(NEHALEM, NULL), + X86_MATCH_INTEL_FAM6_MODEL(NEHALEM_G, NULL), + X86_MATCH_INTEL_FAM6_MODEL(NEHALEM_EP, NULL), + X86_MATCH_INTEL_FAM6_MODEL(NEHALEM_EX, NULL), + X86_MATCH_INTEL_FAM6_MODEL(WESTMERE, NULL), + X86_MATCH_INTEL_FAM6_MODEL(WESTMERE_EP, NULL), + X86_MATCH_INTEL_FAM6_MODEL(WESTMERE_EX, NULL), + X86_MATCH_INTEL_FAM6_MODEL(SANDYBRIDGE, NULL), + X86_MATCH_INTEL_FAM6_MODEL(SANDYBRIDGE_X, NULL), + X86_MATCH_INTEL_FAM6_MODEL(IVYBRIDGE, NULL), + X86_MATCH_INTEL_FAM6_MODEL(IVYBRIDGE_X, NULL), + X86_MATCH_INTEL_FAM6_MODEL(HASWELL, NULL), + X86_MATCH_INTEL_FAM6_MODEL(HASWELL_X, NULL), + X86_MATCH_INTEL_FAM6_MODEL(HASWELL_L, NULL), + X86_MATCH_INTEL_FAM6_MODEL(HASWELL_G, NULL), + X86_MATCH_INTEL_FAM6_MODEL(BROADWELL, NULL), + X86_MATCH_INTEL_FAM6_MODEL(BROADWELL_G, NULL), + X86_MATCH_INTEL_FAM6_MODEL(BROADWELL_X, NULL), + X86_MATCH_INTEL_FAM6_MODEL(BROADWELL_D, NULL), + X86_MATCH_INTEL_FAM6_MODEL(SKYLAKE_L, NULL), + X86_MATCH_INTEL_FAM6_MODEL(SKYLAKE, NULL), + X86_MATCH_INTEL_FAM6_MODEL(SKYLAKE_X, NULL), + X86_MATCH_INTEL_FAM6_MODEL(KABYLAKE_L, NULL), + X86_MATCH_INTEL_FAM6_MODEL(KABYLAKE, NULL), + X86_MATCH_INTEL_FAM6_MODEL(COMETLAKE, NULL), + X86_MATCH_INTEL_FAM6_MODEL(COMETLAKE_L, NULL), + X86_MATCH_INTEL_FAM6_MODEL(CANNONLAKE_L, NULL), + X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_X, NULL), + X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_D, NULL), + X86_MATCH_INTEL_FAM6_MODEL(ICELAKE, NULL), + X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_L, NULL), + X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_NNPI, NULL), + X86_MATCH_INTEL_FAM6_MODEL(LAKEFIELD, NULL), + X86_MATCH_INTEL_FAM6_MODEL(ROCKETLAKE, NULL), + X86_MATCH_INTEL_FAM6_MODEL(TIGERLAKE_L, NULL), + X86_MATCH_INTEL_FAM6_MODEL(TIGERLAKE, NULL), + X86_MATCH_INTEL_FAM6_MODEL(SAPPHIRERAPIDS_X, NULL), // 12th Gen Xeon + //X86_MATCH_INTEL_FAM6_MODEL(EMERALDRAPIDS_X, NULL), // 13th Gen Xeon + X86_MATCH_INTEL_FAM6_MODEL(ALDERLAKE, NULL), // 12th Gen + X86_MATCH_INTEL_FAM6_MODEL(ALDERLAKE_L, NULL), // 12th Gen + X86_MATCH_INTEL_FAM6_MODEL(ALDERLAKE_N, NULL), // 12th Gen Atom + //X86_MATCH_INTEL_FAM6_MODEL(RAPTORLAKE, NULL), // 13th Gen + //X86_MATCH_INTEL_FAM6_MODEL(RAPTORLAKE_P, NULL), // 13th Gen + //X86_MATCH_INTEL_FAM6_MODEL(RAPTORLAKE_S, NULL), // 13th Gen + X86_MATCH_INTEL_FAM6_MODEL(ATOM_BONNELL, NULL), + X86_MATCH_INTEL_FAM6_MODEL(ATOM_BONNELL_MID, NULL), + X86_MATCH_INTEL_FAM6_MODEL(ATOM_SALTWELL, NULL), + X86_MATCH_INTEL_FAM6_MODEL(ATOM_SALTWELL_MID, NULL), + X86_MATCH_INTEL_FAM6_MODEL(ATOM_SALTWELL_TABLET, NULL), + X86_MATCH_INTEL_FAM6_MODEL(ATOM_SILVERMONT, NULL), + X86_MATCH_INTEL_FAM6_MODEL(ATOM_SILVERMONT_D, NULL), + X86_MATCH_INTEL_FAM6_MODEL(ATOM_SILVERMONT_MID, NULL), + X86_MATCH_INTEL_FAM6_MODEL(ATOM_AIRMONT, NULL), + X86_MATCH_INTEL_FAM6_MODEL(ATOM_AIRMONT_MID, NULL), + X86_MATCH_INTEL_FAM6_MODEL(ATOM_AIRMONT_NP, NULL), + X86_MATCH_INTEL_FAM6_MODEL(ATOM_GOLDMONT, NULL), + X86_MATCH_INTEL_FAM6_MODEL(ATOM_GOLDMONT_D, NULL), + X86_MATCH_INTEL_FAM6_MODEL(ATOM_GOLDMONT_PLUS, NULL), + X86_MATCH_INTEL_FAM6_MODEL(ATOM_TREMONT_D, NULL), + X86_MATCH_INTEL_FAM6_MODEL(ATOM_TREMONT, NULL), + X86_MATCH_INTEL_FAM6_MODEL(ATOM_TREMONT_L, NULL), + X86_MATCH_INTEL_FAM6_MODEL(XEON_PHI_KNL, NULL), + X86_MATCH_INTEL_FAM6_MODEL(XEON_PHI_KNM, NULL), + X86_MATCH_VENDOR_FAM_MODEL(INTEL, 5, INTEL_FAM5_QUARK_X1000, NULL), + X86_MATCH_VENDOR_FAM(AMD, 5, NULL), + X86_MATCH_VENDOR_FAM(AMD, 6, NULL), + X86_MATCH_VENDOR_FAM(AMD, 15, NULL), + X86_MATCH_VENDOR_FAM(AMD, 16, NULL), + X86_MATCH_VENDOR_FAM(AMD, 17, NULL), + X86_MATCH_VENDOR_FAM(AMD, 18, NULL), + X86_MATCH_VENDOR_FAM(AMD, 19, NULL), + X86_MATCH_VENDOR_FAM(AMD, 20, NULL), + X86_MATCH_VENDOR_FAM(AMD, 21, NULL), + X86_MATCH_VENDOR_FAM(AMD, 22, NULL), + X86_MATCH_VENDOR_FAM(AMD, 23, NULL), // Zen, Zen+, Zen 2 + X86_MATCH_VENDOR_FAM(AMD, 24, NULL), // Zen + //X86_MATCH_VENDOR_FAM(AMD, 25, NULL), // Zen 3, Zen 4 + { } +}; + +static const struct dmi_system_id tuxedo_dmi_string_match[] __initconst = { + { + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "TUXEDO"), + }, + }, + { + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "TUXEDO"), + }, + }, + { } +}; + static int __init tuxedo_keyboard_init(void) { TUXEDO_INFO("module init\n"); + + if (!x86_match_cpu(skip_tuxedo_dmi_string_check_match) + && !dmi_check_system(tuxedo_dmi_string_match)) { + return -EINVAL; + } + return 0; } From ad6f2808f6f760ffdada863b415a89a1346c2ae4 Mon Sep 17 00:00:00 2001 From: Werner Sembach Date: Mon, 17 Apr 2023 15:44:58 +0200 Subject: [PATCH 2/6] Make cutoff between Zen3 and Zen4 --- src/tuxedo_keyboard.c | 44 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/src/tuxedo_keyboard.c b/src/tuxedo_keyboard.c index cbb23c3..acb14ea 100644 --- a/src/tuxedo_keyboard.c +++ b/src/tuxedo_keyboard.c @@ -243,7 +243,44 @@ static const struct x86_cpu_id skip_tuxedo_dmi_string_check_match[] __initconst X86_MATCH_VENDOR_FAM(AMD, 22, NULL), X86_MATCH_VENDOR_FAM(AMD, 23, NULL), // Zen, Zen+, Zen 2 X86_MATCH_VENDOR_FAM(AMD, 24, NULL), // Zen - //X86_MATCH_VENDOR_FAM(AMD, 25, NULL), // Zen 3, Zen 4 + X86_MATCH_VENDOR_FAM(AMD, 25, NULL), // Zen 3, Zen 4 + { } +}; + +static const struct x86_cpu_id force_tuxedo_dmi_string_check_match[] __initconst = { + // Zen 4 model numbers + X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x60, NULL), + X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x61, NULL), + X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x62, NULL), + X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x63, NULL), + X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x64, NULL), + X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x65, NULL), + X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x66, NULL), + X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x67, NULL), + X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x68, NULL), + X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x69, NULL), + X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x6a, NULL), + X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x6b, NULL), + X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x6c, NULL), + X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x6d, NULL), + X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x6e, NULL), + X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x6f, NULL), + X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x70, NULL), + X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x71, NULL), + X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x72, NULL), + X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x73, NULL), + X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x74, NULL), + X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x75, NULL), + X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x76, NULL), + X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x77, NULL), + X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x78, NULL), + X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x79, NULL), + X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x7a, NULL), + X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x7b, NULL), + X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x7c, NULL), + X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x7d, NULL), + X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x7e, NULL), + X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x7f, NULL), { } }; @@ -265,8 +302,9 @@ static int __init tuxedo_keyboard_init(void) { TUXEDO_INFO("module init\n"); - if (!x86_match_cpu(skip_tuxedo_dmi_string_check_match) - && !dmi_check_system(tuxedo_dmi_string_match)) { + if (!(dmi_check_system(tuxedo_dmi_string_match) + || (x86_match_cpu(skip_tuxedo_dmi_string_check_match) + && !x86_match_cpu(force_tuxedo_dmi_string_check_match)) { return -EINVAL; } From 2a164b65642a5e5e6b16677604a55e55e3aadcf3 Mon Sep 17 00:00:00 2001 From: Werner Sembach Date: Mon, 17 Apr 2023 16:17:15 +0200 Subject: [PATCH 3/6] Better return value --- src/tuxedo_keyboard.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tuxedo_keyboard.c b/src/tuxedo_keyboard.c index acb14ea..d87d670 100644 --- a/src/tuxedo_keyboard.c +++ b/src/tuxedo_keyboard.c @@ -305,7 +305,7 @@ static int __init tuxedo_keyboard_init(void) if (!(dmi_check_system(tuxedo_dmi_string_match) || (x86_match_cpu(skip_tuxedo_dmi_string_check_match) && !x86_match_cpu(force_tuxedo_dmi_string_check_match)) { - return -EINVAL; + return -ENODEV; } return 0; From 1f2944ee292a4a0a4957f76faa31b703ec4e08a1 Mon Sep 17 00:00:00 2001 From: Werner Sembach Date: Mon, 17 Apr 2023 16:23:46 +0200 Subject: [PATCH 4/6] Fix missing ')' --- src/tuxedo_keyboard.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tuxedo_keyboard.c b/src/tuxedo_keyboard.c index d87d670..7fe0f70 100644 --- a/src/tuxedo_keyboard.c +++ b/src/tuxedo_keyboard.c @@ -304,7 +304,7 @@ static int __init tuxedo_keyboard_init(void) if (!(dmi_check_system(tuxedo_dmi_string_match) || (x86_match_cpu(skip_tuxedo_dmi_string_check_match) - && !x86_match_cpu(force_tuxedo_dmi_string_check_match)) { + && !x86_match_cpu(force_tuxedo_dmi_string_check_match)))) { return -ENODEV; } From 3858c12f91c64239030d21e7c990e5a022d543b1 Mon Sep 17 00:00:00 2001 From: Werner Sembach Date: Mon, 17 Apr 2023 16:35:27 +0200 Subject: [PATCH 5/6] Add chassis vendor to TUXEDO string check --- src/tuxedo_keyboard.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/tuxedo_keyboard.c b/src/tuxedo_keyboard.c index 7fe0f70..d755269 100644 --- a/src/tuxedo_keyboard.c +++ b/src/tuxedo_keyboard.c @@ -295,6 +295,11 @@ static const struct dmi_system_id tuxedo_dmi_string_match[] __initconst = { DMI_MATCH(DMI_BOARD_VENDOR, "TUXEDO"), }, }, + { + .matches = { + DMI_MATCH(DMI_CHASSIS_VENDOR, "TUXEDO"), + }, + }, { } }; From e3f67245327edb9119f6f50dd25e2b09effcc2f4 Mon Sep 17 00:00:00 2001 From: Werner Sembach Date: Tue, 18 Apr 2023 14:52:41 +0200 Subject: [PATCH 6/6] Whitelist AMD Zen 3 instead of blacklisting Zen 4 --- src/tuxedo_keyboard.c | 40 ++++++---------------------------------- 1 file changed, 6 insertions(+), 34 deletions(-) diff --git a/src/tuxedo_keyboard.c b/src/tuxedo_keyboard.c index d755269..55181e0 100644 --- a/src/tuxedo_keyboard.c +++ b/src/tuxedo_keyboard.c @@ -243,44 +243,16 @@ static const struct x86_cpu_id skip_tuxedo_dmi_string_check_match[] __initconst X86_MATCH_VENDOR_FAM(AMD, 22, NULL), X86_MATCH_VENDOR_FAM(AMD, 23, NULL), // Zen, Zen+, Zen 2 X86_MATCH_VENDOR_FAM(AMD, 24, NULL), // Zen - X86_MATCH_VENDOR_FAM(AMD, 25, NULL), // Zen 3, Zen 4 + X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x01, NULL), // Zen 3 Epyc + X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x08, NULL), // Zen 3 Threadripper + X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x21, NULL), // Zen 3 Vermeer + X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x40, NULL), // Zen 3+ Rembrandt + X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x44, NULL), // Zen 3+ Rembrandt + X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x50, NULL), // Zen 3 Cezanne { } }; static const struct x86_cpu_id force_tuxedo_dmi_string_check_match[] __initconst = { - // Zen 4 model numbers - X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x60, NULL), - X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x61, NULL), - X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x62, NULL), - X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x63, NULL), - X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x64, NULL), - X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x65, NULL), - X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x66, NULL), - X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x67, NULL), - X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x68, NULL), - X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x69, NULL), - X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x6a, NULL), - X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x6b, NULL), - X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x6c, NULL), - X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x6d, NULL), - X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x6e, NULL), - X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x6f, NULL), - X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x70, NULL), - X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x71, NULL), - X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x72, NULL), - X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x73, NULL), - X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x74, NULL), - X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x75, NULL), - X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x76, NULL), - X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x77, NULL), - X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x78, NULL), - X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x79, NULL), - X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x7a, NULL), - X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x7b, NULL), - X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x7c, NULL), - X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x7d, NULL), - X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x7e, NULL), - X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 0x7f, NULL), { } };