From 590eae144831bf004a983c4d4586c170f377b1ad Mon Sep 17 00:00:00 2001 From: ferreo Date: Fri, 20 Dec 2024 01:16:21 +0100 Subject: [PATCH] Update patches/0001-cachyos-base-all.patch --- patches/0001-cachyos-base-all.patch | 871 ++++++++++++++-------------- 1 file changed, 448 insertions(+), 423 deletions(-) diff --git a/patches/0001-cachyos-base-all.patch b/patches/0001-cachyos-base-all.patch index d6fc64d..eaa4eac 100644 --- a/patches/0001-cachyos-base-all.patch +++ b/patches/0001-cachyos-base-all.patch @@ -1,6 +1,6 @@ -From 38a8955fa71213cff57097dcfbb2481836e058d7 Mon Sep 17 00:00:00 2001 +From a89e358d449153fa1a741edc60a8f9a143e5d297 Mon Sep 17 00:00:00 2001 From: Peter Jung -Date: Sat, 14 Dec 2024 20:32:17 +0100 +Date: Thu, 19 Dec 2024 18:49:54 +0100 Subject: [PATCH 01/12] amd-cache-optimizer Signed-off-by: Peter Jung @@ -272,29 +272,45 @@ index 000000000000..0f6d3c54d879 -- 2.47.1 -From 3a5b34f19437da9b33aee10ba5c5273e25e4eb76 Mon Sep 17 00:00:00 2001 +From 5b24edbe81299a51cf1694d0e33c33d995e2c04d Mon Sep 17 00:00:00 2001 From: Peter Jung -Date: Sat, 14 Dec 2024 20:32:51 +0100 +Date: Thu, 19 Dec 2024 18:50:07 +0100 Subject: [PATCH 02/12] amd-pstate Signed-off-by: Peter Jung --- - arch/x86/include/asm/cpufeatures.h | 3 +- - arch/x86/include/asm/intel-family.h | 6 + - arch/x86/include/asm/processor.h | 18 ++ - arch/x86/include/asm/topology.h | 9 + - arch/x86/kernel/acpi/cppc.c | 23 +++ - arch/x86/kernel/cpu/debugfs.c | 1 + - arch/x86/kernel/cpu/scattered.c | 3 +- - arch/x86/kernel/cpu/topology_amd.c | 3 + - arch/x86/kernel/cpu/topology_common.c | 34 ++++ - arch/x86/kernel/smpboot.c | 14 +- - arch/x86/mm/init.c | 23 ++- - drivers/cpufreq/amd-pstate-ut.c | 6 +- - drivers/cpufreq/amd-pstate.c | 205 ++++++++++------------- - tools/arch/x86/include/asm/cpufeatures.h | 2 +- - 14 files changed, 222 insertions(+), 128 deletions(-) + Documentation/admin-guide/pm/amd-pstate.rst | 4 +- + arch/x86/include/asm/cpufeatures.h | 3 +- + arch/x86/include/asm/intel-family.h | 6 + + arch/x86/include/asm/processor.h | 18 ++ + arch/x86/include/asm/topology.h | 9 + + arch/x86/kernel/acpi/cppc.c | 23 ++ + arch/x86/kernel/cpu/debugfs.c | 1 + + arch/x86/kernel/cpu/scattered.c | 3 +- + arch/x86/kernel/cpu/topology_amd.c | 3 + + arch/x86/kernel/cpu/topology_common.c | 34 +++ + arch/x86/kernel/smpboot.c | 14 +- + arch/x86/mm/init.c | 23 +- + drivers/cpufreq/amd-pstate-ut.c | 6 +- + drivers/cpufreq/amd-pstate.c | 235 +++++++++----------- + tools/arch/x86/include/asm/cpufeatures.h | 2 +- + 15 files changed, 239 insertions(+), 145 deletions(-) +diff --git a/Documentation/admin-guide/pm/amd-pstate.rst b/Documentation/admin-guide/pm/amd-pstate.rst +index 210a808b74ec..412423c54f25 100644 +--- a/Documentation/admin-guide/pm/amd-pstate.rst ++++ b/Documentation/admin-guide/pm/amd-pstate.rst +@@ -251,9 +251,7 @@ performance supported in `AMD CPPC Performance Capability `_). + In some ASICs, the highest CPPC performance is not the one in the ``_CPC`` + table, so we need to expose it to sysfs. If boost is not active, but + still supported, this maximum frequency will be larger than the one in +-``cpuinfo``. On systems that support preferred core, the driver will have +-different values for some cores than others and this will reflect the values +-advertised by the platform at bootup. ++``cpuinfo``. + This attribute is read-only. + + ``amd_pstate_lowest_nonlinear_freq`` diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index 913fd3a7bac6..a7c93191b7c6 100644 --- a/arch/x86/include/asm/cpufeatures.h @@ -325,7 +341,7 @@ index 1a42f829667a..736764472048 100644 + #endif /* _ASM_X86_INTEL_FAMILY_H */ diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h -index 4a686f0e5dbf..c0975815980c 100644 +index 2d776635aa53..20e6009381ed 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -105,6 +105,24 @@ struct cpuinfo_topology { @@ -633,7 +649,7 @@ index f66701514d90..a261d7300951 100644 } diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c -index 91d3c3b1c2d3..d7630bab2516 100644 +index 91d3c3b1c2d3..66e5dfc711c0 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -233,7 +233,7 @@ static int amd_pstate_get_energy_pref_index(struct amd_cpudata *cpudata) @@ -682,7 +698,7 @@ index 91d3c3b1c2d3..d7630bab2516 100644 { int cpu, ret = 0; struct cppc_perf_ctrls perf_ctrls; -@@ -359,14 +365,14 @@ static int cppc_enable(bool enable) +@@ -359,24 +365,28 @@ static int cppc_enable(bool enable) return ret; } @@ -699,9 +715,26 @@ index 91d3c3b1c2d3..d7630bab2516 100644 -static int pstate_init_perf(struct amd_cpudata *cpudata) +static int msr_init_perf(struct amd_cpudata *cpudata) { - u64 cap1; +- u64 cap1; ++ u64 cap1, numerator; -@@ -385,7 +391,7 @@ static int pstate_init_perf(struct amd_cpudata *cpudata) + int ret = rdmsrl_safe_on_cpu(cpudata->cpu, MSR_AMD_CPPC_CAP1, + &cap1); + if (ret) + return ret; + +- WRITE_ONCE(cpudata->highest_perf, AMD_CPPC_HIGHEST_PERF(cap1)); +- WRITE_ONCE(cpudata->max_limit_perf, AMD_CPPC_HIGHEST_PERF(cap1)); ++ ret = amd_get_boost_ratio_numerator(cpudata->cpu, &numerator); ++ if (ret) ++ return ret; ++ ++ WRITE_ONCE(cpudata->highest_perf, numerator); ++ WRITE_ONCE(cpudata->max_limit_perf, numerator); + WRITE_ONCE(cpudata->nominal_perf, AMD_CPPC_NOMINAL_PERF(cap1)); + WRITE_ONCE(cpudata->lowest_nonlinear_perf, AMD_CPPC_LOWNONLIN_PERF(cap1)); + WRITE_ONCE(cpudata->lowest_perf, AMD_CPPC_LOWEST_PERF(cap1)); +@@ -385,16 +395,21 @@ static int pstate_init_perf(struct amd_cpudata *cpudata) return 0; } @@ -709,8 +742,24 @@ index 91d3c3b1c2d3..d7630bab2516 100644 +static int shmem_init_perf(struct amd_cpudata *cpudata) { struct cppc_perf_caps cppc_perf; ++ u64 numerator; -@@ -420,14 +426,14 @@ static int cppc_init_perf(struct amd_cpudata *cpudata) + int ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf); + if (ret) + return ret; + +- WRITE_ONCE(cpudata->highest_perf, cppc_perf.highest_perf); +- WRITE_ONCE(cpudata->max_limit_perf, cppc_perf.highest_perf); ++ ret = amd_get_boost_ratio_numerator(cpudata->cpu, &numerator); ++ if (ret) ++ return ret; ++ ++ WRITE_ONCE(cpudata->highest_perf, numerator); ++ WRITE_ONCE(cpudata->max_limit_perf, numerator); + WRITE_ONCE(cpudata->nominal_perf, cppc_perf.nominal_perf); + WRITE_ONCE(cpudata->lowest_nonlinear_perf, + cppc_perf.lowest_nonlinear_perf); +@@ -420,14 +435,14 @@ static int cppc_init_perf(struct amd_cpudata *cpudata) return ret; } @@ -727,7 +776,7 @@ index 91d3c3b1c2d3..d7630bab2516 100644 u32 min_perf, u32 des_perf, u32 max_perf, bool fast_switch) { -@@ -527,9 +533,28 @@ static void amd_pstate_update(struct amd_cpudata *cpudata, u32 min_perf, +@@ -527,25 +542,41 @@ static void amd_pstate_update(struct amd_cpudata *cpudata, u32 min_perf, cpufreq_cpu_put(policy); } @@ -758,7 +807,28 @@ index 91d3c3b1c2d3..d7630bab2516 100644 return 0; } -@@ -825,7 +850,7 @@ static u32 amd_pstate_get_transition_delay_us(unsigned int cpu) + + static int amd_pstate_update_min_max_limit(struct cpufreq_policy *policy) + { +- u32 max_limit_perf, min_limit_perf, lowest_perf, max_perf; ++ u32 max_limit_perf, min_limit_perf, lowest_perf, max_perf, max_freq; + struct amd_cpudata *cpudata = policy->driver_data; + +- if (cpudata->boost_supported && !policy->boost_enabled) +- max_perf = READ_ONCE(cpudata->nominal_perf); +- else +- max_perf = READ_ONCE(cpudata->highest_perf); +- +- max_limit_perf = div_u64(policy->max * max_perf, policy->cpuinfo.max_freq); +- min_limit_perf = div_u64(policy->min * max_perf, policy->cpuinfo.max_freq); ++ max_perf = READ_ONCE(cpudata->highest_perf); ++ max_freq = READ_ONCE(cpudata->max_freq); ++ max_limit_perf = div_u64(policy->max * max_perf, max_freq); ++ min_limit_perf = div_u64(policy->min * max_perf, max_freq); + + lowest_perf = READ_ONCE(cpudata->lowest_perf); + if (min_limit_perf < lowest_perf) +@@ -825,7 +856,7 @@ static u32 amd_pstate_get_transition_delay_us(unsigned int cpu) transition_delay_ns = cppc_get_transition_latency(cpu); if (transition_delay_ns == CPUFREQ_ETERNAL) { @@ -767,7 +837,27 @@ index 91d3c3b1c2d3..d7630bab2516 100644 return AMD_PSTATE_FAST_CPPC_TRANSITION_DELAY; else return AMD_PSTATE_TRANSITION_DELAY; -@@ -979,7 +1004,7 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy) +@@ -864,7 +895,6 @@ static int amd_pstate_init_freq(struct amd_cpudata *cpudata) + { + int ret; + u32 min_freq, max_freq; +- u64 numerator; + u32 nominal_perf, nominal_freq; + u32 lowest_nonlinear_perf, lowest_nonlinear_freq; + u32 boost_ratio, lowest_nonlinear_ratio; +@@ -886,10 +916,7 @@ static int amd_pstate_init_freq(struct amd_cpudata *cpudata) + + nominal_perf = READ_ONCE(cpudata->nominal_perf); + +- ret = amd_get_boost_ratio_numerator(cpudata->cpu, &numerator); +- if (ret) +- return ret; +- boost_ratio = div_u64(numerator << SCHED_CAPACITY_SHIFT, nominal_perf); ++ boost_ratio = div_u64(cpudata->highest_perf << SCHED_CAPACITY_SHIFT, nominal_perf); + max_freq = (nominal_freq * boost_ratio >> SCHED_CAPACITY_SHIFT) * 1000; + + lowest_nonlinear_perf = READ_ONCE(cpudata->lowest_nonlinear_perf); +@@ -979,7 +1006,7 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy) policy->fast_switch_possible = true; ret = freq_qos_add_request(&policy->constraints, &cpudata->req[0], @@ -776,7 +866,7 @@ index 91d3c3b1c2d3..d7630bab2516 100644 if (ret < 0) { dev_err(dev, "Failed to add min-freq constraint (%d)\n", ret); goto free_cpudata1; -@@ -1023,7 +1048,7 @@ static int amd_pstate_cpu_resume(struct cpufreq_policy *policy) +@@ -1023,7 +1050,7 @@ static int amd_pstate_cpu_resume(struct cpufreq_policy *policy) { int ret; @@ -785,7 +875,7 @@ index 91d3c3b1c2d3..d7630bab2516 100644 if (ret) pr_err("failed to enable amd-pstate during resume, return %d\n", ret); -@@ -1034,7 +1059,7 @@ static int amd_pstate_cpu_suspend(struct cpufreq_policy *policy) +@@ -1034,7 +1061,7 @@ static int amd_pstate_cpu_suspend(struct cpufreq_policy *policy) { int ret; @@ -794,7 +884,7 @@ index 91d3c3b1c2d3..d7630bab2516 100644 if (ret) pr_err("failed to disable amd-pstate during suspend, return %d\n", ret); -@@ -1167,25 +1192,41 @@ static ssize_t show_energy_performance_preference( +@@ -1167,25 +1194,41 @@ static ssize_t show_energy_performance_preference( static void amd_pstate_driver_cleanup(void) { @@ -844,7 +934,7 @@ index 91d3c3b1c2d3..d7630bab2516 100644 if (ret) { pr_err("failed to enable cppc during amd-pstate driver registration, return %d\n", ret); -@@ -1463,6 +1504,8 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy) +@@ -1463,6 +1506,8 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy) WRITE_ONCE(cpudata->cppc_cap1_cached, value); } @@ -853,7 +943,7 @@ index 91d3c3b1c2d3..d7630bab2516 100644 return 0; free_cpudata1: -@@ -1485,26 +1528,13 @@ static void amd_pstate_epp_cpu_exit(struct cpufreq_policy *policy) +@@ -1485,26 +1530,13 @@ static void amd_pstate_epp_cpu_exit(struct cpufreq_policy *policy) static int amd_pstate_epp_update_limit(struct cpufreq_policy *policy) { struct amd_cpudata *cpudata = policy->driver_data; @@ -883,7 +973,7 @@ index 91d3c3b1c2d3..d7630bab2516 100644 max_perf = clamp_t(unsigned long, max_perf, cpudata->min_limit_perf, cpudata->max_limit_perf); -@@ -1541,12 +1571,6 @@ static int amd_pstate_epp_update_limit(struct cpufreq_policy *policy) +@@ -1541,12 +1573,6 @@ static int amd_pstate_epp_update_limit(struct cpufreq_policy *policy) if (cpudata->policy == CPUFREQ_POLICY_PERFORMANCE) epp = 0; @@ -896,7 +986,7 @@ index 91d3c3b1c2d3..d7630bab2516 100644 WRITE_ONCE(cpudata->cppc_req_cached, value); return amd_pstate_set_epp(cpudata, epp); } -@@ -1583,7 +1607,7 @@ static void amd_pstate_epp_reenable(struct amd_cpudata *cpudata) +@@ -1583,7 +1609,7 @@ static void amd_pstate_epp_reenable(struct amd_cpudata *cpudata) u64 value, max_perf; int ret; @@ -905,7 +995,7 @@ index 91d3c3b1c2d3..d7630bab2516 100644 if (ret) pr_err("failed to enable amd pstate during resume, return %d\n", ret); -@@ -1594,8 +1618,9 @@ static void amd_pstate_epp_reenable(struct amd_cpudata *cpudata) +@@ -1594,8 +1620,9 @@ static void amd_pstate_epp_reenable(struct amd_cpudata *cpudata) wrmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, value); } else { perf_ctrls.max_perf = max_perf; @@ -916,7 +1006,7 @@ index 91d3c3b1c2d3..d7630bab2516 100644 } } -@@ -1635,9 +1660,11 @@ static void amd_pstate_epp_offline(struct cpufreq_policy *policy) +@@ -1635,9 +1662,11 @@ static void amd_pstate_epp_offline(struct cpufreq_policy *policy) wrmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, value); } else { perf_ctrls.desired_perf = 0; @@ -929,7 +1019,7 @@ index 91d3c3b1c2d3..d7630bab2516 100644 } mutex_unlock(&amd_pstate_limits_lock); } -@@ -1657,13 +1684,6 @@ static int amd_pstate_epp_cpu_offline(struct cpufreq_policy *policy) +@@ -1657,13 +1686,6 @@ static int amd_pstate_epp_cpu_offline(struct cpufreq_policy *policy) return 0; } @@ -943,7 +1033,7 @@ index 91d3c3b1c2d3..d7630bab2516 100644 static int amd_pstate_epp_suspend(struct cpufreq_policy *policy) { struct amd_cpudata *cpudata = policy->driver_data; -@@ -1677,7 +1697,7 @@ static int amd_pstate_epp_suspend(struct cpufreq_policy *policy) +@@ -1677,7 +1699,7 @@ static int amd_pstate_epp_suspend(struct cpufreq_policy *policy) cpudata->suspended = true; /* disable CPPC in lowlevel firmware */ @@ -952,7 +1042,7 @@ index 91d3c3b1c2d3..d7630bab2516 100644 if (ret) pr_err("failed to suspend, return %d\n", ret); -@@ -1719,7 +1739,7 @@ static struct cpufreq_driver amd_pstate_driver = { +@@ -1719,7 +1741,7 @@ static struct cpufreq_driver amd_pstate_driver = { static struct cpufreq_driver amd_pstate_epp_driver = { .flags = CPUFREQ_CONST_LOOPS, @@ -961,7 +1051,7 @@ index 91d3c3b1c2d3..d7630bab2516 100644 .setpolicy = amd_pstate_epp_set_policy, .init = amd_pstate_epp_cpu_init, .exit = amd_pstate_epp_cpu_exit, -@@ -1733,26 +1753,7 @@ static struct cpufreq_driver amd_pstate_epp_driver = { +@@ -1733,26 +1755,7 @@ static struct cpufreq_driver amd_pstate_epp_driver = { .attr = amd_pstate_epp_attr, }; @@ -989,7 +1079,7 @@ index 91d3c3b1c2d3..d7630bab2516 100644 * CPPC function is not supported for family ID 17H with model_ID ranging from 0x10 to 0x2F. * show the debug message that helps to check if the CPU has CPPC support for loading issue. */ -@@ -1842,10 +1843,10 @@ static int __init amd_pstate_init(void) +@@ -1842,10 +1845,10 @@ static int __init amd_pstate_init(void) if (cppc_state == AMD_PSTATE_UNDEFINED) { /* Disable on the following configs by default: * 1. Undefined platforms @@ -1002,7 +1092,7 @@ index 91d3c3b1c2d3..d7630bab2516 100644 pr_info("driver load is disabled, boot with specific mode to enable this\n"); return -ENODEV; } -@@ -1853,50 +1854,31 @@ static int __init amd_pstate_init(void) +@@ -1853,31 +1856,19 @@ static int __init amd_pstate_init(void) cppc_state = CONFIG_X86_AMD_PSTATE_DEFAULT_MODE; } @@ -1032,38 +1122,33 @@ index 91d3c3b1c2d3..d7630bab2516 100644 - static_call_update(amd_pstate_enable, cppc_enable); - static_call_update(amd_pstate_init_perf, cppc_init_perf); - static_call_update(amd_pstate_update_perf, cppc_update_perf); -- } -- -- if (amd_pstate_prefcore) { -- ret = amd_detect_prefcore(&amd_pstate_prefcore); -- if (ret) -- return ret; + static_call_update(amd_pstate_cppc_enable, shmem_cppc_enable); + static_call_update(amd_pstate_init_perf, shmem_init_perf); + static_call_update(amd_pstate_update_perf, shmem_update_perf); } -- /* enable amd pstate feature */ -- ret = amd_pstate_enable(true); -+ ret = amd_pstate_register_driver(cppc_state); - if (ret) { -- pr_err("failed to enable driver mode(%d)\n", cppc_state); -+ pr_err("failed to register with return %d\n", ret); - return ret; + if (amd_pstate_prefcore) { +@@ -1886,17 +1877,10 @@ static int __init amd_pstate_init(void) + return ret; } -- ret = cpufreq_register_driver(current_pstate_driver); +- /* enable amd pstate feature */ +- ret = amd_pstate_enable(true); - if (ret) { -- pr_err("failed to register with return %d\n", ret); +- pr_err("failed to enable driver mode(%d)\n", cppc_state); +- return ret; +- } +- +- ret = cpufreq_register_driver(current_pstate_driver); ++ ret = amd_pstate_register_driver(cppc_state); + if (ret) { + pr_err("failed to register with return %d\n", ret); - goto disable_driver; -+ if (amd_pstate_prefcore) { -+ ret = amd_detect_prefcore(&amd_pstate_prefcore); -+ if (ret) -+ return ret; ++ return ret; } dev_root = bus_get_dev_root(&cpu_subsys); -@@ -1913,8 +1895,7 @@ static int __init amd_pstate_init(void) +@@ -1913,8 +1897,7 @@ static int __init amd_pstate_init(void) global_attr_free: cpufreq_unregister_driver(current_pstate_driver); @@ -1089,9 +1174,9 @@ index dd4682857c12..23698d0f4bb4 100644 -- 2.47.1 -From 8a702df415ee3a8241544231f440e8fcc99a9504 Mon Sep 17 00:00:00 2001 +From c335f50994128543c8e019b8cc913d7fb0e98f2b Mon Sep 17 00:00:00 2001 From: Peter Jung -Date: Sat, 14 Dec 2024 20:33:03 +0100 +Date: Thu, 19 Dec 2024 18:50:18 +0100 Subject: [PATCH 03/12] autofdo Signed-off-by: Peter Jung @@ -1505,7 +1590,7 @@ index a578178468f1..a2d251917629 100644 M: Petr Mladek R: Steven Rostedt diff --git a/Makefile b/Makefile -index f158bfe6407a..2cf706b8a662 100644 +index c10952585c14..a0229efbf8e3 100644 --- a/Makefile +++ b/Makefile @@ -1019,6 +1019,8 @@ include-$(CONFIG_KMSAN) += scripts/Makefile.kmsan @@ -1793,10 +1878,10 @@ index 000000000000..344190717e47 + +export CFLAGS_PROPELLER_CLANG diff --git a/tools/objtool/check.c b/tools/objtool/check.c -index 6604f5d038aa..05a0fb4a3d1a 100644 +index f0d8796b984a..634a67dba86c 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c -@@ -4557,6 +4557,8 @@ static int validate_ibt(struct objtool_file *file) +@@ -4560,6 +4560,8 @@ static int validate_ibt(struct objtool_file *file) !strcmp(sec->name, "__jump_table") || !strcmp(sec->name, "__mcount_loc") || !strcmp(sec->name, ".kcfi_traps") || @@ -1835,9 +1920,9 @@ index 3d27983dc908..6f64d611faea 100644 -- 2.47.1 -From 2d69e2e30799bf3e0caead19977351b572c7ed7e Mon Sep 17 00:00:00 2001 +From d03dc7618d35c0c3e5ab7373cff2032a8c3ecf9f Mon Sep 17 00:00:00 2001 From: Peter Jung -Date: Sat, 14 Dec 2024 20:33:16 +0100 +Date: Thu, 19 Dec 2024 18:50:32 +0100 Subject: [PATCH 04/12] bbr3 Signed-off-by: Peter Jung @@ -5016,7 +5101,7 @@ index bb1fe1ba867a..050a80769de6 100644 const struct tcp_congestion_ops *ca; diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c -index 68804fd01daf..afdb62febe42 100644 +index 8efc58716ce9..5798ce3db487 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -336,10 +336,9 @@ static void tcp_ecn_send_syn(struct sock *sk, struct sk_buff *skb) @@ -5051,7 +5136,7 @@ index 68804fd01daf..afdb62febe42 100644 /* ACK or retransmitted segment: clear ECT|CE */ INET_ECN_dontxmit(sk); } -@@ -1601,7 +1604,7 @@ int tcp_fragment(struct sock *sk, enum tcp_queue tcp_queue, +@@ -1603,7 +1606,7 @@ int tcp_fragment(struct sock *sk, enum tcp_queue tcp_queue, { struct tcp_sock *tp = tcp_sk(sk); struct sk_buff *buff; @@ -5060,7 +5145,7 @@ index 68804fd01daf..afdb62febe42 100644 long limit; int nlen; u8 flags; -@@ -1676,6 +1679,30 @@ int tcp_fragment(struct sock *sk, enum tcp_queue tcp_queue, +@@ -1678,6 +1681,30 @@ int tcp_fragment(struct sock *sk, enum tcp_queue tcp_queue, if (diff) tcp_adjust_pcount(sk, skb, diff); @@ -5091,7 +5176,7 @@ index 68804fd01daf..afdb62febe42 100644 } /* Link BUFF into the send queue. */ -@@ -2033,13 +2060,12 @@ static u32 tcp_tso_autosize(const struct sock *sk, unsigned int mss_now, +@@ -2035,13 +2062,12 @@ static u32 tcp_tso_autosize(const struct sock *sk, unsigned int mss_now, static u32 tcp_tso_segs(struct sock *sk, unsigned int mss_now) { const struct tcp_congestion_ops *ca_ops = inet_csk(sk)->icsk_ca_ops; @@ -5110,7 +5195,7 @@ index 68804fd01daf..afdb62febe42 100644 return min_t(u32, tso_segs, sk->sk_gso_max_segs); } -@@ -2765,6 +2791,7 @@ static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle, +@@ -2767,6 +2793,7 @@ static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle, skb_set_delivery_time(skb, tp->tcp_wstamp_ns, SKB_CLOCK_MONOTONIC); list_move_tail(&skb->tcp_tsorted_anchor, &tp->tsorted_sent_queue); tcp_init_tso_segs(skb, mss_now); @@ -5118,7 +5203,7 @@ index 68804fd01daf..afdb62febe42 100644 goto repair; /* Skip network transmission */ } -@@ -2979,6 +3006,7 @@ void tcp_send_loss_probe(struct sock *sk) +@@ -2981,6 +3008,7 @@ void tcp_send_loss_probe(struct sock *sk) if (WARN_ON(!skb || !tcp_skb_pcount(skb))) goto rearm_timer; @@ -5221,9 +5306,9 @@ index 79064580c8c0..697270ce1ea6 100644 -- 2.47.1 -From 3dffd4e0cf293fcb908c5445d978270bd69a3553 Mon Sep 17 00:00:00 2001 +From 2b16de2dc6156279f389d532824a302d212f2611 Mon Sep 17 00:00:00 2001 From: Peter Jung -Date: Sat, 14 Dec 2024 22:05:08 +0100 +Date: Thu, 19 Dec 2024 18:50:43 +0100 Subject: [PATCH 05/12] cachy Signed-off-by: Peter Jung @@ -5453,7 +5538,7 @@ index 6d942b5c58f0..1768a106aab1 100644 ====== diff --git a/Makefile b/Makefile -index 2cf706b8a662..71868ccbe05a 100644 +index a0229efbf8e3..201faadca07f 100644 --- a/Makefile +++ b/Makefile @@ -802,11 +802,19 @@ KBUILD_CFLAGS += -fno-delete-null-pointer-checks @@ -6839,7 +6924,7 @@ index a93739688071..5fa58ef65371 100644 smu_v13_0_0_set_supported_od_feature_mask(smu); diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c -index d0e6d051e9cf..31996f8c6e3a 100644 +index 1aedfafa507f..d19c63a8459a 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c @@ -83,6 +83,8 @@ @@ -13485,9 +13570,9 @@ index fe7947f77406..99e138cfdd95 100644 -- 2.47.1 -From c492258a11ab0bc1bde53661d97744a46a7a6df0 Mon Sep 17 00:00:00 2001 +From 03450504df5c4fe2d2ba5981aff7a532ab1ebf17 Mon Sep 17 00:00:00 2001 From: Peter Jung -Date: Sat, 14 Dec 2024 20:33:51 +0100 +Date: Thu, 19 Dec 2024 18:51:01 +0100 Subject: [PATCH 06/12] crypto Signed-off-by: Peter Jung @@ -15091,9 +15176,9 @@ index bbcff1fb78cb..752812bc4991 100644 -- 2.47.1 -From 4ab3a2f9373cdc772c944419add5b7ed1a310f66 Mon Sep 17 00:00:00 2001 +From 3e7168943409ace243e6d4b10896d6e71b5e0c4d Mon Sep 17 00:00:00 2001 From: Peter Jung -Date: Sat, 14 Dec 2024 21:57:10 +0100 +Date: Thu, 19 Dec 2024 18:51:12 +0100 Subject: [PATCH 07/12] fixes Signed-off-by: Peter Jung @@ -15183,10 +15268,10 @@ index b0678d59ebdb..a2becb85bea7 100644 cpumask_set_cpu(cpu, mm_cpumask(next)); diff --git a/drivers/bluetooth/btmtk.c b/drivers/bluetooth/btmtk.c -index 480e4adba9fa..3626faab9c91 100644 +index 85e99641eaae..c1b6bcc6f7dd 100644 --- a/drivers/bluetooth/btmtk.c +++ b/drivers/bluetooth/btmtk.c -@@ -1325,7 +1325,6 @@ int btmtk_usb_setup(struct hci_dev *hdev) +@@ -1329,7 +1329,6 @@ int btmtk_usb_setup(struct hci_dev *hdev) fwname = FIRMWARE_MT7668; break; case 0x7922: @@ -15194,7 +15279,7 @@ index 480e4adba9fa..3626faab9c91 100644 case 0x7925: /* Reset the device to ensure it's in the initial state before * downloading the firmware to ensure. -@@ -1333,7 +1332,8 @@ int btmtk_usb_setup(struct hci_dev *hdev) +@@ -1337,7 +1336,8 @@ int btmtk_usb_setup(struct hci_dev *hdev) if (!test_bit(BTMTK_FIRMWARE_LOADED, &btmtk_data->flags)) btmtk_usb_subsys_reset(hdev, dev_id); @@ -16031,10 +16116,10 @@ index f83493838cf9..4010899652b8 100644 mkdir -p "${builddir}" cp System.map "${builddir}/System.map" diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c -index 973671e0cdb0..bfb3e95ccfaf 100644 +index 192fc75b51e6..d88fc0ca893d 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c -@@ -10603,6 +10603,8 @@ static const struct hda_quirk alc269_fixup_tbl[] = { +@@ -10604,6 +10604,8 @@ static const struct hda_quirk alc269_fixup_tbl[] = { SND_PCI_QUIRK(0x1043, 0x1e1f, "ASUS Vivobook 15 X1504VAP", ALC2XX_FIXUP_HEADSET_MIC), SND_PCI_QUIRK(0x1043, 0x1e51, "ASUS Zephyrus M15", ALC294_FIXUP_ASUS_GU502_PINS), SND_PCI_QUIRK(0x1043, 0x1e5e, "ASUS ROG Strix G513", ALC294_FIXUP_ASUS_G513_PINS), @@ -16046,25 +16131,25 @@ index 973671e0cdb0..bfb3e95ccfaf 100644 -- 2.47.1 -From b3513ce6ece39de866fb62d08a8a9500ff402cca Mon Sep 17 00:00:00 2001 +From 46225020f04e55a29ae30473a9a8cf0d15f0979e Mon Sep 17 00:00:00 2001 From: Peter Jung -Date: Sat, 14 Dec 2024 21:57:23 +0100 +Date: Thu, 19 Dec 2024 18:51:57 +0100 Subject: [PATCH 08/12] ntsync Signed-off-by: Peter Jung --- Documentation/userspace-api/index.rst | 1 + - Documentation/userspace-api/ntsync.rst | 398 +++++ + Documentation/userspace-api/ntsync.rst | 385 +++++ MAINTAINERS | 9 + drivers/misc/Kconfig | 1 - - drivers/misc/ntsync.c | 989 +++++++++++- - include/uapi/linux/ntsync.h | 39 + + drivers/misc/ntsync.c | 992 +++++++++++- + include/uapi/linux/ntsync.h | 42 +- tools/testing/selftests/Makefile | 1 + .../selftests/drivers/ntsync/.gitignore | 1 + .../testing/selftests/drivers/ntsync/Makefile | 7 + tools/testing/selftests/drivers/ntsync/config | 1 + - .../testing/selftests/drivers/ntsync/ntsync.c | 1407 +++++++++++++++++ - 11 files changed, 2850 insertions(+), 4 deletions(-) + .../testing/selftests/drivers/ntsync/ntsync.c | 1343 +++++++++++++++++ + 11 files changed, 2767 insertions(+), 16 deletions(-) create mode 100644 Documentation/userspace-api/ntsync.rst create mode 100644 tools/testing/selftests/drivers/ntsync/.gitignore create mode 100644 tools/testing/selftests/drivers/ntsync/Makefile @@ -16085,10 +16170,10 @@ index 274cc7546efc..9c1b15cd89ab 100644 diff --git a/Documentation/userspace-api/ntsync.rst b/Documentation/userspace-api/ntsync.rst new file mode 100644 -index 000000000000..767844637a7d +index 000000000000..25e7c4aef968 --- /dev/null +++ b/Documentation/userspace-api/ntsync.rst -@@ -0,0 +1,398 @@ +@@ -0,0 +1,385 @@ +=================================== +NT synchronization primitive driver +=================================== @@ -16164,19 +16249,16 @@ index 000000000000..767844637a7d +structures used in ioctl calls:: + + struct ntsync_sem_args { -+ __u32 sem; + __u32 count; + __u32 max; + }; + + struct ntsync_mutex_args { -+ __u32 mutex; + __u32 owner; + __u32 count; + }; + + struct ntsync_event_args { -+ __u32 event; + __u32 signaled; + __u32 manual; + }; @@ -16193,7 +16275,7 @@ index 000000000000..767844637a7d + }; + +Depending on the ioctl, members of the structure may be used as input, -+output, or not at all. All ioctls return 0 on success. ++output, or not at all. + +The ioctls on the device file are as follows: + @@ -16204,14 +16286,13 @@ index 000000000000..767844637a7d + + .. list-table:: + -+ * - ``sem`` -+ - On output, contains a file descriptor to the created semaphore. + * - ``count`` + - Initial count of the semaphore. + * - ``max`` + - Maximum count of the semaphore. + + Fails with ``EINVAL`` if ``count`` is greater than ``max``. ++ On success, returns a file descriptor the created semaphore. + +.. c:macro:: NTSYNC_IOC_CREATE_MUTEX + @@ -16220,8 +16301,6 @@ index 000000000000..767844637a7d + + .. list-table:: + -+ * - ``mutex`` -+ - On output, contains a file descriptor to the created mutex. + * - ``count`` + - Initial recursion count of the mutex. + * - ``owner`` @@ -16229,6 +16308,7 @@ index 000000000000..767844637a7d + + If ``owner`` is nonzero and ``count`` is zero, or if ``owner`` is + zero and ``count`` is nonzero, the function fails with ``EINVAL``. ++ On success, returns a file descriptor the created mutex. + +.. c:macro:: NTSYNC_IOC_CREATE_EVENT + @@ -16237,8 +16317,6 @@ index 000000000000..767844637a7d + + .. list-table:: + -+ * - ``event`` -+ - On output, contains a file descriptor to the created event. + * - ``signaled`` + - If nonzero, the event is initially signaled, otherwise + nonsignaled. @@ -16246,6 +16324,8 @@ index 000000000000..767844637a7d + - If nonzero, the event is a manual-reset event, otherwise + auto-reset. + ++ On success, returns a file descriptor the created event. ++ +The ioctls on the individual objects are as follows: + +.. c:macro:: NTSYNC_IOC_SEM_POST @@ -16268,8 +16348,6 @@ index 000000000000..767844637a7d + + .. list-table:: + -+ * - ``mutex`` -+ - Ignored. + * - ``owner`` + - Specifies the owner trying to release this mutex. + * - ``count`` @@ -16318,8 +16396,6 @@ index 000000000000..767844637a7d + + .. list-table:: + -+ * - ``sem`` -+ - Ignored. + * - ``count`` + - On output, contains the current count of the semaphore. + * - ``max`` @@ -16332,8 +16408,6 @@ index 000000000000..767844637a7d + + .. list-table:: + -+ * - ``mutex`` -+ - Ignored. + * - ``owner`` + - On output, contains the current owner of the mutex, or zero + if the mutex is not currently owned. @@ -16351,8 +16425,6 @@ index 000000000000..767844637a7d + + .. list-table:: + -+ * - ``event`` -+ - Ignored. + * - ``signaled`` + - On output, contains the current state of the event. + * - ``manual`` @@ -16520,7 +16592,7 @@ index 3fe7e2a9bd29..6c8b999a5e08 100644 This module provides kernel support for emulation of Windows NT synchronization primitives. It is not a hardware driver. diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c -index 4954553b7baa..3fac06270549 100644 +index 4954553b7baa..457ff28b789f 100644 --- a/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c @@ -6,11 +6,17 @@ @@ -16564,7 +16636,7 @@ index 4954553b7baa..3fac06270549 100644 enum ntsync_type type; -@@ -46,13 +57,335 @@ struct ntsync_obj { +@@ -46,22 +57,344 @@ struct ntsync_obj { __u32 count; __u32 max; } sem; @@ -16900,7 +16972,9 @@ index 4954553b7baa..3fac06270549 100644 /* * Actually change the semaphore state, returning -EOVERFLOW if it is made * invalid. -@@ -61,7 +394,7 @@ static int post_sem_state(struct ntsync_obj *sem, __u32 count) + */ +-static int post_sem_state(struct ntsync_obj *sem, __u32 count) ++static int release_sem_state(struct ntsync_obj *sem, __u32 count) { __u32 sum; @@ -16909,9 +16983,12 @@ index 4954553b7baa..3fac06270549 100644 if (check_add_overflow(sem->u.sem.count, count, &sum) || sum > sem->u.sem.max) -@@ -73,9 +406,11 @@ static int post_sem_state(struct ntsync_obj *sem, __u32 count) +@@ -71,11 +404,13 @@ static int post_sem_state(struct ntsync_obj *sem, __u32 count) + return 0; + } - static int ntsync_sem_post(struct ntsync_obj *sem, void __user *argp) +-static int ntsync_sem_post(struct ntsync_obj *sem, void __user *argp) ++static int ntsync_sem_release(struct ntsync_obj *sem, void __user *argp) { + struct ntsync_device *dev = sem->dev; __u32 __user *user_args = argp; @@ -16929,7 +17006,8 @@ index 4954553b7baa..3fac06270549 100644 + all = ntsync_lock_obj(dev, sem); prev_count = sem->u.sem.count; - ret = post_sem_state(sem, args); +- ret = post_sem_state(sem, args); ++ ret = release_sem_state(sem, args); + if (!ret) { + if (all) + try_wake_all_obj(dev, sem); @@ -16941,7 +17019,7 @@ index 4954553b7baa..3fac06270549 100644 if (!ret && put_user(prev_count, user_args)) ret = -EFAULT; -@@ -97,6 +437,226 @@ static int ntsync_sem_post(struct ntsync_obj *sem, void __user *argp) +@@ -97,6 +437,220 @@ static int ntsync_sem_post(struct ntsync_obj *sem, void __user *argp) return ret; } @@ -17101,8 +17179,6 @@ index 4954553b7baa..3fac06270549 100644 + if (sem->type != NTSYNC_TYPE_SEM) + return -EINVAL; + -+ args.sem = 0; -+ + all = ntsync_lock_obj(dev, sem); + + args.count = sem->u.sem.count; @@ -17126,8 +17202,6 @@ index 4954553b7baa..3fac06270549 100644 + if (mutex->type != NTSYNC_TYPE_MUTEX) + return -EINVAL; + -+ args.mutex = 0; -+ + all = ntsync_lock_obj(dev, mutex); + + args.count = mutex->u.mutex.count; @@ -17151,8 +17225,6 @@ index 4954553b7baa..3fac06270549 100644 + if (event->type != NTSYNC_TYPE_EVENT) + return -EINVAL; + -+ args.event = 0; -+ + all = ntsync_lock_obj(dev, event); + + args.manual = event->u.event.manual; @@ -17168,10 +17240,14 @@ index 4954553b7baa..3fac06270549 100644 static int ntsync_obj_release(struct inode *inode, struct file *file) { struct ntsync_obj *obj = file->private_data; -@@ -116,6 +676,22 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd, +@@ -114,8 +668,24 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd, + void __user *argp = (void __user *)parm; + switch (cmd) { - case NTSYNC_IOC_SEM_POST: - return ntsync_sem_post(obj, argp); +- case NTSYNC_IOC_SEM_POST: +- return ntsync_sem_post(obj, argp); ++ case NTSYNC_IOC_SEM_RELEASE: ++ return ntsync_sem_release(obj, argp); + case NTSYNC_IOC_SEM_READ: + return ntsync_sem_read(obj, argp); + case NTSYNC_IOC_MUTEX_UNLOCK: @@ -17191,7 +17267,7 @@ index 4954553b7baa..3fac06270549 100644 default: return -ENOIOCTLCMD; } -@@ -140,6 +716,9 @@ static struct ntsync_obj *ntsync_alloc_obj(struct ntsync_device *dev, +@@ -140,6 +710,9 @@ static struct ntsync_obj *ntsync_alloc_obj(struct ntsync_device *dev, obj->dev = dev; get_file(dev->file); spin_lock_init(&obj->lock); @@ -17201,13 +17277,28 @@ index 4954553b7baa..3fac06270549 100644 return obj; } -@@ -190,6 +769,400 @@ static int ntsync_create_sem(struct ntsync_device *dev, void __user *argp) - return put_user(fd, &user_args->sem); - } +@@ -165,7 +738,6 @@ static int ntsync_obj_get_fd(struct ntsync_obj *obj) + static int ntsync_create_sem(struct ntsync_device *dev, void __user *argp) + { +- struct ntsync_sem_args __user *user_args = argp; + struct ntsync_sem_args args; + struct ntsync_obj *sem; + int fd; +@@ -182,12 +754,398 @@ static int ntsync_create_sem(struct ntsync_device *dev, void __user *argp) + sem->u.sem.count = args.count; + sem->u.sem.max = args.max; + fd = ntsync_obj_get_fd(sem); +- if (fd < 0) { ++ if (fd < 0) + kfree(sem); +- return fd; ++ ++ return fd; ++} ++ +static int ntsync_create_mutex(struct ntsync_device *dev, void __user *argp) +{ -+ struct ntsync_mutex_args __user *user_args = argp; + struct ntsync_mutex_args args; + struct ntsync_obj *mutex; + int fd; @@ -17224,17 +17315,14 @@ index 4954553b7baa..3fac06270549 100644 + mutex->u.mutex.count = args.count; + mutex->u.mutex.owner = args.owner; + fd = ntsync_obj_get_fd(mutex); -+ if (fd < 0) { ++ if (fd < 0) + kfree(mutex); -+ return fd; -+ } + -+ return put_user(fd, &user_args->mutex); ++ return fd; +} + +static int ntsync_create_event(struct ntsync_device *dev, void __user *argp) +{ -+ struct ntsync_event_args __user *user_args = argp; + struct ntsync_event_args args; + struct ntsync_obj *event; + int fd; @@ -17248,12 +17336,10 @@ index 4954553b7baa..3fac06270549 100644 + event->u.event.manual = args.manual; + event->u.event.signaled = args.signaled; + fd = ntsync_obj_get_fd(event); -+ if (fd < 0) { ++ if (fd < 0) + kfree(event); -+ return fd; -+ } + -+ return put_user(fd, &user_args->event); ++ return fd; +} + +static struct ntsync_obj *get_obj(struct ntsync_device *dev, int fd) @@ -17267,8 +17353,9 @@ index 4954553b7baa..3fac06270549 100644 + if (file->f_op != &ntsync_obj_fops) { + fput(file); + return NULL; -+ } -+ + } + +- return put_user(fd, &user_args->sem); + obj = file->private_data; + if (obj->dev != dev) { + fput(file); @@ -17597,12 +17684,10 @@ index 4954553b7baa..3fac06270549 100644 + + kfree(q); + return ret; -+} -+ + } + static int ntsync_char_open(struct inode *inode, struct file *file) - { - struct ntsync_device *dev; -@@ -198,6 +1171,8 @@ static int ntsync_char_open(struct inode *inode, struct file *file) +@@ -198,6 +1156,8 @@ static int ntsync_char_open(struct inode *inode, struct file *file) if (!dev) return -ENOMEM; @@ -17611,7 +17696,7 @@ index 4954553b7baa..3fac06270549 100644 file->private_data = dev; dev->file = file; return nonseekable_open(inode, file); -@@ -219,8 +1194,16 @@ static long ntsync_char_ioctl(struct file *file, unsigned int cmd, +@@ -219,8 +1179,16 @@ static long ntsync_char_ioctl(struct file *file, unsigned int cmd, void __user *argp = (void __user *)parm; switch (cmd) { @@ -17629,21 +17714,25 @@ index 4954553b7baa..3fac06270549 100644 return -ENOIOCTLCMD; } diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h -index dcfa38fdc93c..4a8095a3fc34 100644 +index dcfa38fdc93c..6d06793512b1 100644 --- a/include/uapi/linux/ntsync.h +++ b/include/uapi/linux/ntsync.h -@@ -16,8 +16,47 @@ struct ntsync_sem_args { +@@ -11,13 +11,49 @@ + #include + + struct ntsync_sem_args { +- __u32 sem; + __u32 count; __u32 max; }; +-#define NTSYNC_IOC_CREATE_SEM _IOWR('N', 0x80, struct ntsync_sem_args) +struct ntsync_mutex_args { -+ __u32 mutex; + __u32 owner; + __u32 count; +}; + +struct ntsync_event_args { -+ __u32 event; + __u32 manual; + __u32 signaled; +}; @@ -17663,13 +17752,14 @@ index dcfa38fdc93c..4a8095a3fc34 100644 + +#define NTSYNC_MAX_WAIT_COUNT 64 + - #define NTSYNC_IOC_CREATE_SEM _IOWR('N', 0x80, struct ntsync_sem_args) ++#define NTSYNC_IOC_CREATE_SEM _IOW ('N', 0x80, struct ntsync_sem_args) +#define NTSYNC_IOC_WAIT_ANY _IOWR('N', 0x82, struct ntsync_wait_args) +#define NTSYNC_IOC_WAIT_ALL _IOWR('N', 0x83, struct ntsync_wait_args) -+#define NTSYNC_IOC_CREATE_MUTEX _IOWR('N', 0x84, struct ntsync_sem_args) -+#define NTSYNC_IOC_CREATE_EVENT _IOWR('N', 0x87, struct ntsync_event_args) ++#define NTSYNC_IOC_CREATE_MUTEX _IOW ('N', 0x84, struct ntsync_mutex_args) ++#define NTSYNC_IOC_CREATE_EVENT _IOW ('N', 0x87, struct ntsync_event_args) - #define NTSYNC_IOC_SEM_POST _IOWR('N', 0x81, __u32) +-#define NTSYNC_IOC_SEM_POST _IOWR('N', 0x81, __u32) ++#define NTSYNC_IOC_SEM_RELEASE _IOWR('N', 0x81, __u32) +#define NTSYNC_IOC_MUTEX_UNLOCK _IOWR('N', 0x85, struct ntsync_mutex_args) +#define NTSYNC_IOC_MUTEX_KILL _IOW ('N', 0x86, __u32) +#define NTSYNC_IOC_EVENT_SET _IOR ('N', 0x88, __u32) @@ -17721,10 +17811,10 @@ index 000000000000..60539c826d06 +CONFIG_WINESYNC=y diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c new file mode 100644 -index 000000000000..5fa2c9a0768c +index 000000000000..3aad311574c4 --- /dev/null +++ b/tools/testing/selftests/drivers/ntsync/ntsync.c -@@ -0,0 +1,1407 @@ +@@ -0,0 +1,1343 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Various unit tests for the "ntsync" synchronization primitive driver. @@ -17762,9 +17852,9 @@ index 000000000000..5fa2c9a0768c + EXPECT_EQ((max), __max); \ + }) + -+static int post_sem(int sem, __u32 *count) ++static int release_sem(int sem, __u32 *count) +{ -+ return ioctl(sem, NTSYNC_IOC_SEM_POST, count); ++ return ioctl(sem, NTSYNC_IOC_SEM_RELEASE, count); +} + +static int read_mutex_state(int mutex, __u32 *count, __u32 *owner) @@ -17879,28 +17969,24 @@ index 000000000000..5fa2c9a0768c + + sem_args.count = 3; + sem_args.max = 2; -+ sem_args.sem = 0xdeadbeef; -+ ret = ioctl(fd, NTSYNC_IOC_CREATE_SEM, &sem_args); -+ EXPECT_EQ(-1, ret); ++ sem = ioctl(fd, NTSYNC_IOC_CREATE_SEM, &sem_args); ++ EXPECT_EQ(-1, sem); + EXPECT_EQ(EINVAL, errno); + + sem_args.count = 2; + sem_args.max = 2; -+ sem_args.sem = 0xdeadbeef; -+ ret = ioctl(fd, NTSYNC_IOC_CREATE_SEM, &sem_args); -+ EXPECT_EQ(0, ret); -+ EXPECT_NE(0xdeadbeef, sem_args.sem); -+ sem = sem_args.sem; ++ sem = ioctl(fd, NTSYNC_IOC_CREATE_SEM, &sem_args); ++ EXPECT_LE(0, sem); + check_sem_state(sem, 2, 2); + + count = 0; -+ ret = post_sem(sem, &count); ++ ret = release_sem(sem, &count); + EXPECT_EQ(0, ret); + EXPECT_EQ(2, count); + check_sem_state(sem, 2, 2); + + count = 1; -+ ret = post_sem(sem, &count); ++ ret = release_sem(sem, &count); + EXPECT_EQ(-1, ret); + EXPECT_EQ(EOVERFLOW, errno); + check_sem_state(sem, 2, 2); @@ -17920,13 +18006,13 @@ index 000000000000..5fa2c9a0768c + EXPECT_EQ(ETIMEDOUT, errno); + + count = 3; -+ ret = post_sem(sem, &count); ++ ret = release_sem(sem, &count); + EXPECT_EQ(-1, ret); + EXPECT_EQ(EOVERFLOW, errno); + check_sem_state(sem, 0, 2); + + count = 2; -+ ret = post_sem(sem, &count); ++ ret = release_sem(sem, &count); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, count); + check_sem_state(sem, 2, 2); @@ -17937,13 +18023,13 @@ index 000000000000..5fa2c9a0768c + EXPECT_EQ(0, ret); + + count = 1; -+ ret = post_sem(sem, &count); ++ ret = release_sem(sem, &count); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, count); + check_sem_state(sem, 1, 2); + + count = ~0u; -+ ret = post_sem(sem, &count); ++ ret = release_sem(sem, &count); + EXPECT_EQ(-1, ret); + EXPECT_EQ(EOVERFLOW, errno); + check_sem_state(sem, 1, 2); @@ -17967,23 +18053,20 @@ index 000000000000..5fa2c9a0768c + + mutex_args.owner = 123; + mutex_args.count = 0; -+ ret = ioctl(fd, NTSYNC_IOC_CREATE_MUTEX, &mutex_args); -+ EXPECT_EQ(-1, ret); ++ mutex = ioctl(fd, NTSYNC_IOC_CREATE_MUTEX, &mutex_args); ++ EXPECT_EQ(-1, mutex); + EXPECT_EQ(EINVAL, errno); + + mutex_args.owner = 0; + mutex_args.count = 2; -+ ret = ioctl(fd, NTSYNC_IOC_CREATE_MUTEX, &mutex_args); -+ EXPECT_EQ(-1, ret); ++ mutex = ioctl(fd, NTSYNC_IOC_CREATE_MUTEX, &mutex_args); ++ EXPECT_EQ(-1, mutex); + EXPECT_EQ(EINVAL, errno); + + mutex_args.owner = 123; + mutex_args.count = 2; -+ mutex_args.mutex = 0xdeadbeef; -+ ret = ioctl(fd, NTSYNC_IOC_CREATE_MUTEX, &mutex_args); -+ EXPECT_EQ(0, ret); -+ EXPECT_NE(0xdeadbeef, mutex_args.mutex); -+ mutex = mutex_args.mutex; ++ mutex = ioctl(fd, NTSYNC_IOC_CREATE_MUTEX, &mutex_args); ++ EXPECT_LE(0, mutex); + check_mutex_state(mutex, 2, 123); + + ret = unlock_mutex(mutex, 0, &count); @@ -18084,11 +18167,8 @@ index 000000000000..5fa2c9a0768c + + mutex_args.owner = 0; + mutex_args.count = 0; -+ mutex_args.mutex = 0xdeadbeef; -+ ret = ioctl(fd, NTSYNC_IOC_CREATE_MUTEX, &mutex_args); -+ EXPECT_EQ(0, ret); -+ EXPECT_NE(0xdeadbeef, mutex_args.mutex); -+ mutex = mutex_args.mutex; ++ mutex = ioctl(fd, NTSYNC_IOC_CREATE_MUTEX, &mutex_args); ++ EXPECT_LE(0, mutex); + check_mutex_state(mutex, 0, 0); + + ret = wait_any(fd, 1, &mutex, 123, &index); @@ -18100,11 +18180,8 @@ index 000000000000..5fa2c9a0768c + + mutex_args.owner = 123; + mutex_args.count = ~0u; -+ mutex_args.mutex = 0xdeadbeef; -+ ret = ioctl(fd, NTSYNC_IOC_CREATE_MUTEX, &mutex_args); -+ EXPECT_EQ(0, ret); -+ EXPECT_NE(0xdeadbeef, mutex_args.mutex); -+ mutex = mutex_args.mutex; ++ mutex = ioctl(fd, NTSYNC_IOC_CREATE_MUTEX, &mutex_args); ++ EXPECT_LE(0, mutex); + check_mutex_state(mutex, ~0u, 123); + + ret = wait_any(fd, 1, &mutex, 123, &index); @@ -18127,11 +18204,8 @@ index 000000000000..5fa2c9a0768c + + event_args.manual = 1; + event_args.signaled = 0; -+ event_args.event = 0xdeadbeef; -+ ret = ioctl(fd, NTSYNC_IOC_CREATE_EVENT, &event_args); -+ EXPECT_EQ(0, ret); -+ EXPECT_NE(0xdeadbeef, event_args.event); -+ event = event_args.event; ++ event = ioctl(fd, NTSYNC_IOC_CREATE_EVENT, &event_args); ++ EXPECT_LE(0, event); + check_event_state(event, 0, 1); + + signaled = 0xdeadbeef; @@ -18195,11 +18269,8 @@ index 000000000000..5fa2c9a0768c + + event_args.manual = 0; + event_args.signaled = 1; -+ event_args.event = 0xdeadbeef; -+ ret = ioctl(fd, NTSYNC_IOC_CREATE_EVENT, &event_args); -+ EXPECT_EQ(0, ret); -+ EXPECT_NE(0xdeadbeef, event_args.event); -+ event = event_args.event; ++ event = ioctl(fd, NTSYNC_IOC_CREATE_EVENT, &event_args); ++ EXPECT_LE(0, event); + + check_event_state(event, 1, 0); + @@ -18258,62 +18329,55 @@ index 000000000000..5fa2c9a0768c + + sem_args.count = 2; + sem_args.max = 3; -+ sem_args.sem = 0xdeadbeef; -+ ret = ioctl(fd, NTSYNC_IOC_CREATE_SEM, &sem_args); -+ EXPECT_EQ(0, ret); -+ EXPECT_NE(0xdeadbeef, sem_args.sem); ++ objs[0] = ioctl(fd, NTSYNC_IOC_CREATE_SEM, &sem_args); ++ EXPECT_LE(0, objs[0]); + + mutex_args.owner = 0; + mutex_args.count = 0; -+ mutex_args.mutex = 0xdeadbeef; -+ ret = ioctl(fd, NTSYNC_IOC_CREATE_MUTEX, &mutex_args); -+ EXPECT_EQ(0, ret); -+ EXPECT_NE(0xdeadbeef, mutex_args.mutex); -+ -+ objs[0] = sem_args.sem; -+ objs[1] = mutex_args.mutex; ++ objs[1] = ioctl(fd, NTSYNC_IOC_CREATE_MUTEX, &mutex_args); ++ EXPECT_LE(0, objs[1]); + + ret = wait_any(fd, 2, objs, 123, &index); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, index); -+ check_sem_state(sem_args.sem, 1, 3); -+ check_mutex_state(mutex_args.mutex, 0, 0); ++ check_sem_state(objs[0], 1, 3); ++ check_mutex_state(objs[1], 0, 0); + + ret = wait_any(fd, 2, objs, 123, &index); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, index); -+ check_sem_state(sem_args.sem, 0, 3); -+ check_mutex_state(mutex_args.mutex, 0, 0); ++ check_sem_state(objs[0], 0, 3); ++ check_mutex_state(objs[1], 0, 0); + + ret = wait_any(fd, 2, objs, 123, &index); + EXPECT_EQ(0, ret); + EXPECT_EQ(1, index); -+ check_sem_state(sem_args.sem, 0, 3); -+ check_mutex_state(mutex_args.mutex, 1, 123); ++ check_sem_state(objs[0], 0, 3); ++ check_mutex_state(objs[1], 1, 123); + + count = 1; -+ ret = post_sem(sem_args.sem, &count); ++ ret = release_sem(objs[0], &count); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, count); + + ret = wait_any(fd, 2, objs, 123, &index); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, index); -+ check_sem_state(sem_args.sem, 0, 3); -+ check_mutex_state(mutex_args.mutex, 1, 123); ++ check_sem_state(objs[0], 0, 3); ++ check_mutex_state(objs[1], 1, 123); + + ret = wait_any(fd, 2, objs, 123, &index); + EXPECT_EQ(0, ret); + EXPECT_EQ(1, index); -+ check_sem_state(sem_args.sem, 0, 3); -+ check_mutex_state(mutex_args.mutex, 2, 123); ++ check_sem_state(objs[0], 0, 3); ++ check_mutex_state(objs[1], 2, 123); + + ret = wait_any(fd, 2, objs, 456, &index); + EXPECT_EQ(-1, ret); + EXPECT_EQ(ETIMEDOUT, errno); + + owner = 123; -+ ret = ioctl(mutex_args.mutex, NTSYNC_IOC_MUTEX_KILL, &owner); ++ ret = ioctl(objs[1], NTSYNC_IOC_MUTEX_KILL, &owner); + EXPECT_EQ(0, ret); + + ret = wait_any(fd, 2, objs, 456, &index); @@ -18325,24 +18389,27 @@ index 000000000000..5fa2c9a0768c + EXPECT_EQ(0, ret); + EXPECT_EQ(1, index); + ++ close(objs[1]); ++ + /* test waiting on the same object twice */ ++ + count = 2; -+ ret = post_sem(sem_args.sem, &count); ++ ret = release_sem(objs[0], &count); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, count); + -+ objs[0] = objs[1] = sem_args.sem; ++ objs[1] = objs[0]; + ret = wait_any(fd, 2, objs, 456, &index); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, index); -+ check_sem_state(sem_args.sem, 1, 3); ++ check_sem_state(objs[0], 1, 3); + + ret = wait_any(fd, 0, NULL, 456, &index); + EXPECT_EQ(-1, ret); + EXPECT_EQ(ETIMEDOUT, errno); + -+ for (i = 0; i < NTSYNC_MAX_WAIT_COUNT + 1; ++i) -+ objs[i] = sem_args.sem; ++ for (i = 1; i < NTSYNC_MAX_WAIT_COUNT + 1; ++i) ++ objs[i] = objs[0]; + + ret = wait_any(fd, NTSYNC_MAX_WAIT_COUNT, objs, 123, &index); + EXPECT_EQ(0, ret); @@ -18356,8 +18423,7 @@ index 000000000000..5fa2c9a0768c + EXPECT_EQ(-1, ret); + EXPECT_EQ(EINVAL, errno); + -+ close(sem_args.sem); -+ close(mutex_args.mutex); ++ close(objs[0]); + + close(fd); +} @@ -18375,88 +18441,81 @@ index 000000000000..5fa2c9a0768c + + sem_args.count = 2; + sem_args.max = 3; -+ sem_args.sem = 0xdeadbeef; -+ ret = ioctl(fd, NTSYNC_IOC_CREATE_SEM, &sem_args); -+ EXPECT_EQ(0, ret); -+ EXPECT_NE(0xdeadbeef, sem_args.sem); ++ objs[0] = ioctl(fd, NTSYNC_IOC_CREATE_SEM, &sem_args); ++ EXPECT_LE(0, objs[0]); + + mutex_args.owner = 0; + mutex_args.count = 0; -+ mutex_args.mutex = 0xdeadbeef; -+ ret = ioctl(fd, NTSYNC_IOC_CREATE_MUTEX, &mutex_args); -+ EXPECT_EQ(0, ret); -+ EXPECT_NE(0xdeadbeef, mutex_args.mutex); -+ -+ event_args.manual = true; -+ event_args.signaled = true; -+ ret = ioctl(fd, NTSYNC_IOC_CREATE_EVENT, &event_args); -+ EXPECT_EQ(0, ret); -+ -+ objs[0] = sem_args.sem; -+ objs[1] = mutex_args.mutex; ++ objs[1] = ioctl(fd, NTSYNC_IOC_CREATE_MUTEX, &mutex_args); ++ EXPECT_LE(0, objs[1]); + + ret = wait_all(fd, 2, objs, 123, &index); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, index); -+ check_sem_state(sem_args.sem, 1, 3); -+ check_mutex_state(mutex_args.mutex, 1, 123); ++ check_sem_state(objs[0], 1, 3); ++ check_mutex_state(objs[1], 1, 123); + + ret = wait_all(fd, 2, objs, 456, &index); + EXPECT_EQ(-1, ret); + EXPECT_EQ(ETIMEDOUT, errno); -+ check_sem_state(sem_args.sem, 1, 3); -+ check_mutex_state(mutex_args.mutex, 1, 123); ++ check_sem_state(objs[0], 1, 3); ++ check_mutex_state(objs[1], 1, 123); + + ret = wait_all(fd, 2, objs, 123, &index); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, index); -+ check_sem_state(sem_args.sem, 0, 3); -+ check_mutex_state(mutex_args.mutex, 2, 123); ++ check_sem_state(objs[0], 0, 3); ++ check_mutex_state(objs[1], 2, 123); + + ret = wait_all(fd, 2, objs, 123, &index); + EXPECT_EQ(-1, ret); + EXPECT_EQ(ETIMEDOUT, errno); -+ check_sem_state(sem_args.sem, 0, 3); -+ check_mutex_state(mutex_args.mutex, 2, 123); ++ check_sem_state(objs[0], 0, 3); ++ check_mutex_state(objs[1], 2, 123); + + count = 3; -+ ret = post_sem(sem_args.sem, &count); ++ ret = release_sem(objs[0], &count); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, count); + + ret = wait_all(fd, 2, objs, 123, &index); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, index); -+ check_sem_state(sem_args.sem, 2, 3); -+ check_mutex_state(mutex_args.mutex, 3, 123); ++ check_sem_state(objs[0], 2, 3); ++ check_mutex_state(objs[1], 3, 123); + + owner = 123; -+ ret = ioctl(mutex_args.mutex, NTSYNC_IOC_MUTEX_KILL, &owner); ++ ret = ioctl(objs[1], NTSYNC_IOC_MUTEX_KILL, &owner); + EXPECT_EQ(0, ret); + + ret = wait_all(fd, 2, objs, 123, &index); + EXPECT_EQ(-1, ret); + EXPECT_EQ(EOWNERDEAD, errno); -+ check_sem_state(sem_args.sem, 1, 3); -+ check_mutex_state(mutex_args.mutex, 1, 123); ++ check_sem_state(objs[0], 1, 3); ++ check_mutex_state(objs[1], 1, 123); ++ ++ close(objs[1]); ++ ++ event_args.manual = true; ++ event_args.signaled = true; ++ objs[1] = ioctl(fd, NTSYNC_IOC_CREATE_EVENT, &event_args); ++ EXPECT_LE(0, objs[1]); + -+ objs[0] = sem_args.sem; -+ objs[1] = event_args.event; + ret = wait_all(fd, 2, objs, 123, &index); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, index); -+ check_sem_state(sem_args.sem, 0, 3); -+ check_event_state(event_args.event, 1, 1); ++ check_sem_state(objs[0], 0, 3); ++ check_event_state(objs[1], 1, 1); ++ ++ close(objs[1]); + + /* test waiting on the same object twice */ -+ objs[0] = objs[1] = sem_args.sem; ++ objs[1] = objs[0]; + ret = wait_all(fd, 2, objs, 123, &index); + EXPECT_EQ(-1, ret); + EXPECT_EQ(EINVAL, errno); + -+ close(sem_args.sem); -+ close(mutex_args.mutex); -+ close(event_args.event); ++ close(objs[0]); + + close(fd); +} @@ -18517,20 +18576,13 @@ index 000000000000..5fa2c9a0768c + + sem_args.count = 0; + sem_args.max = 3; -+ sem_args.sem = 0xdeadbeef; -+ ret = ioctl(fd, NTSYNC_IOC_CREATE_SEM, &sem_args); -+ EXPECT_EQ(0, ret); -+ EXPECT_NE(0xdeadbeef, sem_args.sem); ++ objs[0] = ioctl(fd, NTSYNC_IOC_CREATE_SEM, &sem_args); ++ EXPECT_LE(0, objs[0]); + + mutex_args.owner = 123; + mutex_args.count = 1; -+ mutex_args.mutex = 0xdeadbeef; -+ ret = ioctl(fd, NTSYNC_IOC_CREATE_MUTEX, &mutex_args); -+ EXPECT_EQ(0, ret); -+ EXPECT_NE(0xdeadbeef, mutex_args.mutex); -+ -+ objs[0] = sem_args.sem; -+ objs[1] = mutex_args.mutex; ++ objs[1] = ioctl(fd, NTSYNC_IOC_CREATE_MUTEX, &mutex_args); ++ EXPECT_LE(0, objs[1]); + + /* test waking the semaphore */ + @@ -18549,10 +18601,10 @@ index 000000000000..5fa2c9a0768c + EXPECT_EQ(ETIMEDOUT, ret); + + count = 1; -+ ret = post_sem(sem_args.sem, &count); ++ ret = release_sem(objs[0], &count); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, count); -+ check_sem_state(sem_args.sem, 0, 3); ++ check_sem_state(objs[0], 0, 3); + + ret = wait_for_thread(thread, 100); + EXPECT_EQ(0, ret); @@ -18562,7 +18614,7 @@ index 000000000000..5fa2c9a0768c + /* test waking the mutex */ + + /* first grab it again for owner 123 */ -+ ret = wait_any(fd, 1, &mutex_args.mutex, 123, &index); ++ ret = wait_any(fd, 1, &objs[1], 123, &index); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, index); + @@ -18574,31 +18626,32 @@ index 000000000000..5fa2c9a0768c + ret = wait_for_thread(thread, 100); + EXPECT_EQ(ETIMEDOUT, ret); + -+ ret = unlock_mutex(mutex_args.mutex, 123, &count); ++ ret = unlock_mutex(objs[1], 123, &count); + EXPECT_EQ(0, ret); + EXPECT_EQ(2, count); + + ret = pthread_tryjoin_np(thread, NULL); + EXPECT_EQ(EBUSY, ret); + -+ ret = unlock_mutex(mutex_args.mutex, 123, &count); ++ ret = unlock_mutex(objs[1], 123, &count); + EXPECT_EQ(0, ret); + EXPECT_EQ(1, mutex_args.count); -+ check_mutex_state(mutex_args.mutex, 1, 456); ++ check_mutex_state(objs[1], 1, 456); + + ret = wait_for_thread(thread, 100); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, thread_args.ret); + EXPECT_EQ(1, wait_args.index); + ++ close(objs[1]); ++ + /* test waking events */ + + event_args.manual = false; + event_args.signaled = false; -+ ret = ioctl(fd, NTSYNC_IOC_CREATE_EVENT, &event_args); -+ EXPECT_EQ(0, ret); ++ objs[1] = ioctl(fd, NTSYNC_IOC_CREATE_EVENT, &event_args); ++ EXPECT_LE(0, objs[1]); + -+ objs[1] = event_args.event; + wait_args.timeout = get_abs_timeout(1000); + ret = pthread_create(&thread, NULL, wait_thread, &thread_args); + EXPECT_EQ(0, ret); @@ -18606,10 +18659,10 @@ index 000000000000..5fa2c9a0768c + ret = wait_for_thread(thread, 100); + EXPECT_EQ(ETIMEDOUT, ret); + -+ ret = ioctl(event_args.event, NTSYNC_IOC_EVENT_SET, &signaled); ++ ret = ioctl(objs[1], NTSYNC_IOC_EVENT_SET, &signaled); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, signaled); -+ check_event_state(event_args.event, 0, 0); ++ check_event_state(objs[1], 0, 0); + + ret = wait_for_thread(thread, 100); + EXPECT_EQ(0, ret); @@ -18623,24 +18676,23 @@ index 000000000000..5fa2c9a0768c + ret = wait_for_thread(thread, 100); + EXPECT_EQ(ETIMEDOUT, ret); + -+ ret = ioctl(event_args.event, NTSYNC_IOC_EVENT_PULSE, &signaled); ++ ret = ioctl(objs[1], NTSYNC_IOC_EVENT_PULSE, &signaled); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, signaled); -+ check_event_state(event_args.event, 0, 0); ++ check_event_state(objs[1], 0, 0); + + ret = wait_for_thread(thread, 100); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, thread_args.ret); + EXPECT_EQ(1, wait_args.index); + -+ close(event_args.event); ++ close(objs[1]); + + event_args.manual = true; + event_args.signaled = false; -+ ret = ioctl(fd, NTSYNC_IOC_CREATE_EVENT, &event_args); -+ EXPECT_EQ(0, ret); ++ objs[1] = ioctl(fd, NTSYNC_IOC_CREATE_EVENT, &event_args); ++ EXPECT_LE(0, objs[1]); + -+ objs[1] = event_args.event; + wait_args.timeout = get_abs_timeout(1000); + ret = pthread_create(&thread, NULL, wait_thread, &thread_args); + EXPECT_EQ(0, ret); @@ -18648,17 +18700,17 @@ index 000000000000..5fa2c9a0768c + ret = wait_for_thread(thread, 100); + EXPECT_EQ(ETIMEDOUT, ret); + -+ ret = ioctl(event_args.event, NTSYNC_IOC_EVENT_SET, &signaled); ++ ret = ioctl(objs[1], NTSYNC_IOC_EVENT_SET, &signaled); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, signaled); -+ check_event_state(event_args.event, 1, 1); ++ check_event_state(objs[1], 1, 1); + + ret = wait_for_thread(thread, 100); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, thread_args.ret); + EXPECT_EQ(1, wait_args.index); + -+ ret = ioctl(event_args.event, NTSYNC_IOC_EVENT_RESET, &signaled); ++ ret = ioctl(objs[1], NTSYNC_IOC_EVENT_RESET, &signaled); + EXPECT_EQ(0, ret); + EXPECT_EQ(1, signaled); + @@ -18669,31 +18721,28 @@ index 000000000000..5fa2c9a0768c + ret = wait_for_thread(thread, 100); + EXPECT_EQ(ETIMEDOUT, ret); + -+ ret = ioctl(event_args.event, NTSYNC_IOC_EVENT_PULSE, &signaled); ++ ret = ioctl(objs[1], NTSYNC_IOC_EVENT_PULSE, &signaled); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, signaled); -+ check_event_state(event_args.event, 0, 1); ++ check_event_state(objs[1], 0, 1); + + ret = wait_for_thread(thread, 100); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, thread_args.ret); + EXPECT_EQ(1, wait_args.index); + -+ close(event_args.event); -+ + /* delete an object while it's being waited on */ + + wait_args.timeout = get_abs_timeout(200); + wait_args.owner = 123; -+ objs[1] = mutex_args.mutex; + ret = pthread_create(&thread, NULL, wait_thread, &thread_args); + EXPECT_EQ(0, ret); + + ret = wait_for_thread(thread, 100); + EXPECT_EQ(ETIMEDOUT, ret); + -+ close(sem_args.sem); -+ close(mutex_args.mutex); ++ close(objs[0]); ++ close(objs[1]); + + ret = wait_for_thread(thread, 200); + EXPECT_EQ(0, ret); @@ -18720,32 +18769,23 @@ index 000000000000..5fa2c9a0768c + + sem_args.count = 0; + sem_args.max = 3; -+ sem_args.sem = 0xdeadbeef; -+ ret = ioctl(fd, NTSYNC_IOC_CREATE_SEM, &sem_args); -+ EXPECT_EQ(0, ret); -+ EXPECT_NE(0xdeadbeef, sem_args.sem); ++ objs[0] = ioctl(fd, NTSYNC_IOC_CREATE_SEM, &sem_args); ++ EXPECT_LE(0, objs[0]); + + mutex_args.owner = 123; + mutex_args.count = 1; -+ mutex_args.mutex = 0xdeadbeef; -+ ret = ioctl(fd, NTSYNC_IOC_CREATE_MUTEX, &mutex_args); -+ EXPECT_EQ(0, ret); -+ EXPECT_NE(0xdeadbeef, mutex_args.mutex); ++ objs[1] = ioctl(fd, NTSYNC_IOC_CREATE_MUTEX, &mutex_args); ++ EXPECT_LE(0, objs[1]); + + manual_event_args.manual = true; + manual_event_args.signaled = true; -+ ret = ioctl(fd, NTSYNC_IOC_CREATE_EVENT, &manual_event_args); -+ EXPECT_EQ(0, ret); ++ objs[2] = ioctl(fd, NTSYNC_IOC_CREATE_EVENT, &manual_event_args); ++ EXPECT_LE(0, objs[2]); + + auto_event_args.manual = false; + auto_event_args.signaled = true; -+ ret = ioctl(fd, NTSYNC_IOC_CREATE_EVENT, &auto_event_args); -+ EXPECT_EQ(0, ret); -+ -+ objs[0] = sem_args.sem; -+ objs[1] = mutex_args.mutex; -+ objs[2] = manual_event_args.event; -+ objs[3] = auto_event_args.event; ++ objs[3] = ioctl(fd, NTSYNC_IOC_CREATE_EVENT, &auto_event_args); ++ EXPECT_EQ(0, objs[3]); + + wait_args.timeout = get_abs_timeout(1000); + wait_args.objs = (uintptr_t)objs; @@ -18761,54 +18801,54 @@ index 000000000000..5fa2c9a0768c + EXPECT_EQ(ETIMEDOUT, ret); + + count = 1; -+ ret = post_sem(sem_args.sem, &count); ++ ret = release_sem(objs[0], &count); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, count); + + ret = pthread_tryjoin_np(thread, NULL); + EXPECT_EQ(EBUSY, ret); + -+ check_sem_state(sem_args.sem, 1, 3); ++ check_sem_state(objs[0], 1, 3); + -+ ret = wait_any(fd, 1, &sem_args.sem, 123, &index); ++ ret = wait_any(fd, 1, &objs[0], 123, &index); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, index); + -+ ret = unlock_mutex(mutex_args.mutex, 123, &count); ++ ret = unlock_mutex(objs[1], 123, &count); + EXPECT_EQ(0, ret); + EXPECT_EQ(1, count); + + ret = pthread_tryjoin_np(thread, NULL); + EXPECT_EQ(EBUSY, ret); + -+ check_mutex_state(mutex_args.mutex, 0, 0); ++ check_mutex_state(objs[1], 0, 0); + -+ ret = ioctl(manual_event_args.event, NTSYNC_IOC_EVENT_RESET, &signaled); ++ ret = ioctl(objs[2], NTSYNC_IOC_EVENT_RESET, &signaled); + EXPECT_EQ(0, ret); + EXPECT_EQ(1, signaled); + + count = 2; -+ ret = post_sem(sem_args.sem, &count); ++ ret = release_sem(objs[0], &count); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, count); -+ check_sem_state(sem_args.sem, 2, 3); ++ check_sem_state(objs[0], 2, 3); + -+ ret = ioctl(auto_event_args.event, NTSYNC_IOC_EVENT_RESET, &signaled); ++ ret = ioctl(objs[3], NTSYNC_IOC_EVENT_RESET, &signaled); + EXPECT_EQ(0, ret); + EXPECT_EQ(1, signaled); + -+ ret = ioctl(manual_event_args.event, NTSYNC_IOC_EVENT_SET, &signaled); ++ ret = ioctl(objs[2], NTSYNC_IOC_EVENT_SET, &signaled); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, signaled); + -+ ret = ioctl(auto_event_args.event, NTSYNC_IOC_EVENT_SET, &signaled); ++ ret = ioctl(objs[3], NTSYNC_IOC_EVENT_SET, &signaled); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, signaled); + -+ check_sem_state(sem_args.sem, 1, 3); -+ check_mutex_state(mutex_args.mutex, 1, 456); -+ check_event_state(manual_event_args.event, 1, 1); -+ check_event_state(auto_event_args.event, 0, 0); ++ check_sem_state(objs[0], 1, 3); ++ check_mutex_state(objs[1], 1, 456); ++ check_event_state(objs[2], 1, 1); ++ check_event_state(objs[3], 0, 0); + + ret = wait_for_thread(thread, 100); + EXPECT_EQ(0, ret); @@ -18824,10 +18864,10 @@ index 000000000000..5fa2c9a0768c + ret = wait_for_thread(thread, 100); + EXPECT_EQ(ETIMEDOUT, ret); + -+ close(sem_args.sem); -+ close(mutex_args.mutex); -+ close(manual_event_args.event); -+ close(auto_event_args.event); ++ close(objs[0]); ++ close(objs[1]); ++ close(objs[2]); ++ close(objs[3]); + + ret = wait_for_thread(thread, 200); + EXPECT_EQ(0, ret); @@ -18844,7 +18884,7 @@ index 000000000000..5fa2c9a0768c + struct ntsync_sem_args sem_args = {0}; + __u32 index, count, signaled; + struct wait_args thread_args; -+ int objs[2], fd, ret; ++ int objs[2], event, fd, ret; + pthread_t thread; + + fd = open("/dev/ntsync", O_CLOEXEC | O_RDONLY); @@ -18852,50 +18892,44 @@ index 000000000000..5fa2c9a0768c + + sem_args.count = 0; + sem_args.max = 2; -+ sem_args.sem = 0xdeadbeef; -+ ret = ioctl(fd, NTSYNC_IOC_CREATE_SEM, &sem_args); -+ EXPECT_EQ(0, ret); -+ EXPECT_NE(0xdeadbeef, sem_args.sem); -+ objs[0] = sem_args.sem; ++ objs[0] = ioctl(fd, NTSYNC_IOC_CREATE_SEM, &sem_args); ++ EXPECT_LE(0, objs[0]); + + sem_args.count = 1; + sem_args.max = 2; -+ sem_args.sem = 0xdeadbeef; -+ ret = ioctl(fd, NTSYNC_IOC_CREATE_SEM, &sem_args); -+ EXPECT_EQ(0, ret); -+ EXPECT_NE(0xdeadbeef, sem_args.sem); -+ objs[1] = sem_args.sem; ++ objs[1] = ioctl(fd, NTSYNC_IOC_CREATE_SEM, &sem_args); ++ EXPECT_LE(0, objs[1]); + + event_args.manual = true; + event_args.signaled = true; -+ ret = ioctl(fd, NTSYNC_IOC_CREATE_EVENT, &event_args); -+ EXPECT_EQ(0, ret); ++ event = ioctl(fd, NTSYNC_IOC_CREATE_EVENT, &event_args); ++ EXPECT_LE(0, event); + -+ ret = wait_any_alert(fd, 0, NULL, 123, event_args.event, &index); ++ ret = wait_any_alert(fd, 0, NULL, 123, event, &index); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, index); + -+ ret = ioctl(event_args.event, NTSYNC_IOC_EVENT_RESET, &signaled); ++ ret = ioctl(event, NTSYNC_IOC_EVENT_RESET, &signaled); + EXPECT_EQ(0, ret); + -+ ret = wait_any_alert(fd, 0, NULL, 123, event_args.event, &index); ++ ret = wait_any_alert(fd, 0, NULL, 123, event, &index); + EXPECT_EQ(-1, ret); + EXPECT_EQ(ETIMEDOUT, errno); + -+ ret = ioctl(event_args.event, NTSYNC_IOC_EVENT_SET, &signaled); ++ ret = ioctl(event, NTSYNC_IOC_EVENT_SET, &signaled); + EXPECT_EQ(0, ret); + -+ ret = wait_any_alert(fd, 2, objs, 123, event_args.event, &index); ++ ret = wait_any_alert(fd, 2, objs, 123, event, &index); + EXPECT_EQ(0, ret); + EXPECT_EQ(1, index); + -+ ret = wait_any_alert(fd, 2, objs, 123, event_args.event, &index); ++ ret = wait_any_alert(fd, 2, objs, 123, event, &index); + EXPECT_EQ(0, ret); + EXPECT_EQ(2, index); + + /* test wakeup via alert */ + -+ ret = ioctl(event_args.event, NTSYNC_IOC_EVENT_RESET, &signaled); ++ ret = ioctl(event, NTSYNC_IOC_EVENT_RESET, &signaled); + EXPECT_EQ(0, ret); + + wait_args.timeout = get_abs_timeout(1000); @@ -18903,7 +18937,7 @@ index 000000000000..5fa2c9a0768c + wait_args.count = 2; + wait_args.owner = 123; + wait_args.index = 0xdeadbeef; -+ wait_args.alert = event_args.event; ++ wait_args.alert = event; + thread_args.fd = fd; + thread_args.args = &wait_args; + thread_args.request = NTSYNC_IOC_WAIT_ANY; @@ -18913,7 +18947,7 @@ index 000000000000..5fa2c9a0768c + ret = wait_for_thread(thread, 100); + EXPECT_EQ(ETIMEDOUT, ret); + -+ ret = ioctl(event_args.event, NTSYNC_IOC_EVENT_SET, &signaled); ++ ret = ioctl(event, NTSYNC_IOC_EVENT_SET, &signaled); + EXPECT_EQ(0, ret); + + ret = wait_for_thread(thread, 100); @@ -18921,32 +18955,32 @@ index 000000000000..5fa2c9a0768c + EXPECT_EQ(0, thread_args.ret); + EXPECT_EQ(2, wait_args.index); + -+ close(event_args.event); ++ close(event); + + /* test with an auto-reset event */ + + event_args.manual = false; + event_args.signaled = true; -+ ret = ioctl(fd, NTSYNC_IOC_CREATE_EVENT, &event_args); -+ EXPECT_EQ(0, ret); ++ event = ioctl(fd, NTSYNC_IOC_CREATE_EVENT, &event_args); ++ EXPECT_LE(0, event); + + count = 1; -+ ret = post_sem(objs[0], &count); ++ ret = release_sem(objs[0], &count); + EXPECT_EQ(0, ret); + -+ ret = wait_any_alert(fd, 2, objs, 123, event_args.event, &index); ++ ret = wait_any_alert(fd, 2, objs, 123, event, &index); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, index); + -+ ret = wait_any_alert(fd, 2, objs, 123, event_args.event, &index); ++ ret = wait_any_alert(fd, 2, objs, 123, event, &index); + EXPECT_EQ(0, ret); + EXPECT_EQ(2, index); + -+ ret = wait_any_alert(fd, 2, objs, 123, event_args.event, &index); ++ ret = wait_any_alert(fd, 2, objs, 123, event, &index); + EXPECT_EQ(-1, ret); + EXPECT_EQ(ETIMEDOUT, errno); + -+ close(event_args.event); ++ close(event); + + close(objs[0]); + close(objs[1]); @@ -18961,7 +18995,7 @@ index 000000000000..5fa2c9a0768c + struct ntsync_sem_args sem_args = {0}; + struct wait_args thread_args; + __u32 index, count, signaled; -+ int objs[2], fd, ret; ++ int objs[2], event, fd, ret; + pthread_t thread; + + fd = open("/dev/ntsync", O_CLOEXEC | O_RDONLY); @@ -18969,36 +19003,30 @@ index 000000000000..5fa2c9a0768c + + sem_args.count = 2; + sem_args.max = 2; -+ sem_args.sem = 0xdeadbeef; -+ ret = ioctl(fd, NTSYNC_IOC_CREATE_SEM, &sem_args); -+ EXPECT_EQ(0, ret); -+ EXPECT_NE(0xdeadbeef, sem_args.sem); -+ objs[0] = sem_args.sem; ++ objs[0] = ioctl(fd, NTSYNC_IOC_CREATE_SEM, &sem_args); ++ EXPECT_LE(0, objs[0]); + + sem_args.count = 1; + sem_args.max = 2; -+ sem_args.sem = 0xdeadbeef; -+ ret = ioctl(fd, NTSYNC_IOC_CREATE_SEM, &sem_args); -+ EXPECT_EQ(0, ret); -+ EXPECT_NE(0xdeadbeef, sem_args.sem); -+ objs[1] = sem_args.sem; ++ objs[1] = ioctl(fd, NTSYNC_IOC_CREATE_SEM, &sem_args); ++ EXPECT_LE(0, objs[1]); + + event_args.manual = true; + event_args.signaled = true; -+ ret = ioctl(fd, NTSYNC_IOC_CREATE_EVENT, &event_args); -+ EXPECT_EQ(0, ret); ++ event = ioctl(fd, NTSYNC_IOC_CREATE_EVENT, &event_args); ++ EXPECT_LE(0, event); + -+ ret = wait_all_alert(fd, 2, objs, 123, event_args.event, &index); ++ ret = wait_all_alert(fd, 2, objs, 123, event, &index); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, index); + -+ ret = wait_all_alert(fd, 2, objs, 123, event_args.event, &index); ++ ret = wait_all_alert(fd, 2, objs, 123, event, &index); + EXPECT_EQ(0, ret); + EXPECT_EQ(2, index); + + /* test wakeup via alert */ + -+ ret = ioctl(event_args.event, NTSYNC_IOC_EVENT_RESET, &signaled); ++ ret = ioctl(event, NTSYNC_IOC_EVENT_RESET, &signaled); + EXPECT_EQ(0, ret); + + wait_args.timeout = get_abs_timeout(1000); @@ -19006,7 +19034,7 @@ index 000000000000..5fa2c9a0768c + wait_args.count = 2; + wait_args.owner = 123; + wait_args.index = 0xdeadbeef; -+ wait_args.alert = event_args.event; ++ wait_args.alert = event; + thread_args.fd = fd; + thread_args.args = &wait_args; + thread_args.request = NTSYNC_IOC_WAIT_ALL; @@ -19016,7 +19044,7 @@ index 000000000000..5fa2c9a0768c + ret = wait_for_thread(thread, 100); + EXPECT_EQ(ETIMEDOUT, ret); + -+ ret = ioctl(event_args.event, NTSYNC_IOC_EVENT_SET, &signaled); ++ ret = ioctl(event, NTSYNC_IOC_EVENT_SET, &signaled); + EXPECT_EQ(0, ret); + + ret = wait_for_thread(thread, 100); @@ -19024,32 +19052,32 @@ index 000000000000..5fa2c9a0768c + EXPECT_EQ(0, thread_args.ret); + EXPECT_EQ(2, wait_args.index); + -+ close(event_args.event); ++ close(event); + + /* test with an auto-reset event */ + + event_args.manual = false; + event_args.signaled = true; -+ ret = ioctl(fd, NTSYNC_IOC_CREATE_EVENT, &event_args); -+ EXPECT_EQ(0, ret); ++ event = ioctl(fd, NTSYNC_IOC_CREATE_EVENT, &event_args); ++ EXPECT_LE(0, event); + + count = 2; -+ ret = post_sem(objs[1], &count); ++ ret = release_sem(objs[1], &count); + EXPECT_EQ(0, ret); + -+ ret = wait_all_alert(fd, 2, objs, 123, event_args.event, &index); ++ ret = wait_all_alert(fd, 2, objs, 123, event, &index); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, index); + -+ ret = wait_all_alert(fd, 2, objs, 123, event_args.event, &index); ++ ret = wait_all_alert(fd, 2, objs, 123, event, &index); + EXPECT_EQ(0, ret); + EXPECT_EQ(2, index); + -+ ret = wait_all_alert(fd, 2, objs, 123, event_args.event, &index); ++ ret = wait_all_alert(fd, 2, objs, 123, event, &index); + EXPECT_EQ(-1, ret); + EXPECT_EQ(ETIMEDOUT, errno); + -+ close(event_args.event); ++ close(event); + + close(objs[0]); + close(objs[1]); @@ -19103,15 +19131,13 @@ index 000000000000..5fa2c9a0768c + + mutex_args.owner = 0; + mutex_args.count = 0; -+ ret = ioctl(stress_device, NTSYNC_IOC_CREATE_MUTEX, &mutex_args); -+ EXPECT_EQ(0, ret); -+ stress_mutex = mutex_args.mutex; ++ stress_mutex = ioctl(stress_device, NTSYNC_IOC_CREATE_MUTEX, &mutex_args); ++ EXPECT_LE(0, stress_mutex); + + event_args.manual = 1; + event_args.signaled = 0; -+ ret = ioctl(stress_device, NTSYNC_IOC_CREATE_EVENT, &event_args); -+ EXPECT_EQ(0, ret); -+ stress_start_event = event_args.event; ++ stress_start_event = ioctl(stress_device, NTSYNC_IOC_CREATE_EVENT, &event_args); ++ EXPECT_LE(0, stress_start_event); + + for (i = 0; i < STRESS_THREADS; ++i) + pthread_create(&threads[i], NULL, stress_thread, NULL); @@ -19135,9 +19161,9 @@ index 000000000000..5fa2c9a0768c -- 2.47.1 -From fb33044b3a0ebbf02bec836b1d1c2b807a4ab9fa Mon Sep 17 00:00:00 2001 +From 7bb6922864744721217f728cc01dcb53dcdcc2da Mon Sep 17 00:00:00 2001 From: Peter Jung -Date: Sat, 14 Dec 2024 21:57:34 +0100 +Date: Thu, 19 Dec 2024 18:52:26 +0100 Subject: [PATCH 09/12] perf-per-core Signed-off-by: Peter Jung @@ -20070,7 +20096,7 @@ index a481a939862e..d3bb3865c1b1 100644 } module_exit(intel_rapl_exit); diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h -index c0975815980c..cfd8a5591421 100644 +index 20e6009381ed..c0cd10182e90 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -98,6 +98,7 @@ struct cpuinfo_topology { @@ -20132,9 +20158,9 @@ index 2361ed4d2b15..37a9afffb59e 100644 -- 2.47.1 -From 190a32a5dd6b10d684aeaeea89fbf0b1c2c86d4b Mon Sep 17 00:00:00 2001 +From 607312cadf367e1baf1362f85e0568ebae5b6d59 Mon Sep 17 00:00:00 2001 From: Peter Jung -Date: Sat, 14 Dec 2024 21:57:46 +0100 +Date: Thu, 19 Dec 2024 18:52:41 +0100 Subject: [PATCH 10/12] pksm Signed-off-by: Peter Jung @@ -20565,9 +20591,9 @@ index 01071182763e..7394bad8178e 100644 -- 2.47.1 -From 04068224b8a0bd214ffbaacc59feec0e879a9bd1 Mon Sep 17 00:00:00 2001 +From 6b556061a9210594131186c61ecb345ab247923e Mon Sep 17 00:00:00 2001 From: Peter Jung -Date: Sat, 14 Dec 2024 21:58:21 +0100 +Date: Thu, 19 Dec 2024 18:53:09 +0100 Subject: [PATCH 11/12] t2 Signed-off-by: Peter Jung @@ -30814,9 +30840,9 @@ index b03d526e4c45..66d09cbec5a8 100755 -- 2.47.1 -From 781deabfa06299fed3510fad2006d01635718b60 Mon Sep 17 00:00:00 2001 +From a7a211a9bf51bfd07e645e8362b40f249d00d13b Mon Sep 17 00:00:00 2001 From: Peter Jung -Date: Sat, 14 Dec 2024 21:58:35 +0100 +Date: Thu, 19 Dec 2024 18:53:34 +0100 Subject: [PATCH 12/12] zstd Signed-off-by: Peter Jung @@ -49465,4 +49491,3 @@ index 469fc3059be0..0ae819f0c927 100644 -- 2.47.1 -