]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
6.3-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 1 Jun 2023 10:27:52 +0000 (11:27 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 1 Jun 2023 10:27:52 +0000 (11:27 +0100)
added patches:
cpufreq-amd-pstate-add-fast_switch-callback.patch
cpufreq-amd-pstate-update-policy-cur-in-amd_pstate_adjust_perf.patch
netfilter-ctnetlink-support-offloaded-conntrack-entry-deletion.patch

queue-6.3/cpufreq-amd-pstate-add-fast_switch-callback.patch [new file with mode: 0644]
queue-6.3/cpufreq-amd-pstate-update-policy-cur-in-amd_pstate_adjust_perf.patch [new file with mode: 0644]
queue-6.3/netfilter-ctnetlink-support-offloaded-conntrack-entry-deletion.patch [new file with mode: 0644]
queue-6.3/series

diff --git a/queue-6.3/cpufreq-amd-pstate-add-fast_switch-callback.patch b/queue-6.3/cpufreq-amd-pstate-add-fast_switch-callback.patch
new file mode 100644 (file)
index 0000000..be34a9c
--- /dev/null
@@ -0,0 +1,96 @@
+From 4badf2eb1e986bdbf34dd2f5d4c979553a86fe54 Mon Sep 17 00:00:00 2001
+From: "Gautham R. Shenoy" <gautham.shenoy@amd.com>
+Date: Wed, 17 May 2023 16:28:15 +0000
+Subject: cpufreq: amd-pstate: Add ->fast_switch() callback
+
+From: Gautham R. Shenoy <gautham.shenoy@amd.com>
+
+commit 4badf2eb1e986bdbf34dd2f5d4c979553a86fe54 upstream.
+
+Schedutil normally calls the adjust_perf callback for drivers with
+adjust_perf callback available and fast_switch_possible flag set.
+However, when frequency invariance is disabled and schedutil tries to
+invoke fast_switch. So, there is a chance of kernel crash if this
+function pointer is not set. To protect against this scenario add
+fast_switch callback to amd_pstate driver.
+
+Fixes: 1d215f0319c2 ("cpufreq: amd-pstate: Add fast switch function for AMD P-State")
+Signed-off-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
+Signed-off-by: Wyes Karny <wyes.karny@amd.com>
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/cpufreq/amd-pstate.c |   37 ++++++++++++++++++++++++++++++-------
+ 1 file changed, 30 insertions(+), 7 deletions(-)
+
+--- a/drivers/cpufreq/amd-pstate.c
++++ b/drivers/cpufreq/amd-pstate.c
+@@ -422,9 +422,8 @@ static int amd_pstate_verify(struct cpuf
+       return 0;
+ }
+-static int amd_pstate_target(struct cpufreq_policy *policy,
+-                           unsigned int target_freq,
+-                           unsigned int relation)
++static int amd_pstate_update_freq(struct cpufreq_policy *policy,
++                                unsigned int target_freq, bool fast_switch)
+ {
+       struct cpufreq_freqs freqs;
+       struct amd_cpudata *cpudata = policy->driver_data;
+@@ -443,14 +442,36 @@ static int amd_pstate_target(struct cpuf
+       des_perf = DIV_ROUND_CLOSEST(target_freq * cap_perf,
+                                    cpudata->max_freq);
+-      cpufreq_freq_transition_begin(policy, &freqs);
+-      amd_pstate_update(cpudata, min_perf, des_perf,
+-                        max_perf, false);
+-      cpufreq_freq_transition_end(policy, &freqs, false);
++      WARN_ON(fast_switch && !policy->fast_switch_enabled);
++      /*
++       * If fast_switch is desired, then there aren't any registered
++       * transition notifiers. See comment for
++       * cpufreq_enable_fast_switch().
++       */
++      if (!fast_switch)
++              cpufreq_freq_transition_begin(policy, &freqs);
++
++      amd_pstate_update(cpudata, min_perf, des_perf, max_perf, fast_switch);
++
++      if (!fast_switch)
++              cpufreq_freq_transition_end(policy, &freqs, false);
+       return 0;
+ }
++static int amd_pstate_target(struct cpufreq_policy *policy,
++                           unsigned int target_freq,
++                           unsigned int relation)
++{
++      return amd_pstate_update_freq(policy, target_freq, false);
++}
++
++static unsigned int amd_pstate_fast_switch(struct cpufreq_policy *policy,
++                                unsigned int target_freq)
++{
++      return amd_pstate_update_freq(policy, target_freq, true);
++}
++
+ static void amd_pstate_adjust_perf(unsigned int cpu,
+                                  unsigned long _min_perf,
+                                  unsigned long target_perf,
+@@ -698,6 +719,7 @@ static int amd_pstate_cpu_exit(struct cp
+       freq_qos_remove_request(&cpudata->req[1]);
+       freq_qos_remove_request(&cpudata->req[0]);
++      policy->fast_switch_possible = false;
+       kfree(cpudata);
+       return 0;
+@@ -1230,6 +1252,7 @@ static struct cpufreq_driver amd_pstate_
+       .flags          = CPUFREQ_CONST_LOOPS | CPUFREQ_NEED_UPDATE_LIMITS,
+       .verify         = amd_pstate_verify,
+       .target         = amd_pstate_target,
++      .fast_switch    = amd_pstate_fast_switch,
+       .init           = amd_pstate_cpu_init,
+       .exit           = amd_pstate_cpu_exit,
+       .suspend        = amd_pstate_cpu_suspend,
diff --git a/queue-6.3/cpufreq-amd-pstate-update-policy-cur-in-amd_pstate_adjust_perf.patch b/queue-6.3/cpufreq-amd-pstate-update-policy-cur-in-amd_pstate_adjust_perf.patch
new file mode 100644 (file)
index 0000000..26b9262
--- /dev/null
@@ -0,0 +1,76 @@
+From 3bf8c6307bad5c0cc09cde982e146d847859b651 Mon Sep 17 00:00:00 2001
+From: Wyes Karny <wyes.karny@amd.com>
+Date: Thu, 18 May 2023 05:58:19 +0000
+Subject: cpufreq: amd-pstate: Update policy->cur in amd_pstate_adjust_perf()
+
+From: Wyes Karny <wyes.karny@amd.com>
+
+commit 3bf8c6307bad5c0cc09cde982e146d847859b651 upstream.
+
+Driver should update policy->cur after updating the frequency.
+Currently amd_pstate doesn't update policy->cur when `adjust_perf`
+is used. Which causes /proc/cpuinfo to show wrong cpu frequency.
+Fix this by updating policy->cur with correct frequency value in
+adjust_perf function callback.
+
+- Before the fix: (setting min freq to 1.5 MHz)
+
+[root@amd]# cat /proc/cpuinfo | grep "cpu MHz" | sort | uniq --count
+      1 cpu MHz         : 1777.016
+      1 cpu MHz         : 1797.160
+      1 cpu MHz         : 1797.270
+    189 cpu MHz         : 400.000
+
+- After the fix: (setting min freq to 1.5 MHz)
+
+[root@amd]# cat /proc/cpuinfo | grep "cpu MHz" | sort | uniq --count
+      1 cpu MHz         : 1753.353
+      1 cpu MHz         : 1756.838
+      1 cpu MHz         : 1776.466
+      1 cpu MHz         : 1776.873
+      1 cpu MHz         : 1777.308
+      1 cpu MHz         : 1779.900
+    183 cpu MHz         : 1805.231
+      1 cpu MHz         : 1956.815
+      1 cpu MHz         : 2246.203
+      1 cpu MHz         : 2259.984
+
+Fixes: 1d215f0319c2 ("cpufreq: amd-pstate: Add fast switch function for AMD P-State")
+Signed-off-by: Wyes Karny <wyes.karny@amd.com>
+[ rjw: Subject edits ]
+Cc: 5.17+ <stable@vger.kernel.org> # 5.17+
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/cpufreq/amd-pstate.c |    8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+--- a/drivers/cpufreq/amd-pstate.c
++++ b/drivers/cpufreq/amd-pstate.c
+@@ -457,12 +457,14 @@ static void amd_pstate_adjust_perf(unsig
+                                  unsigned long capacity)
+ {
+       unsigned long max_perf, min_perf, des_perf,
+-                    cap_perf, lowest_nonlinear_perf;
++                    cap_perf, lowest_nonlinear_perf, max_freq;
+       struct cpufreq_policy *policy = cpufreq_cpu_get(cpu);
+       struct amd_cpudata *cpudata = policy->driver_data;
++      unsigned int target_freq;
+       cap_perf = READ_ONCE(cpudata->highest_perf);
+       lowest_nonlinear_perf = READ_ONCE(cpudata->lowest_nonlinear_perf);
++      max_freq = READ_ONCE(cpudata->max_freq);
+       des_perf = cap_perf;
+       if (target_perf < capacity)
+@@ -479,6 +481,10 @@ static void amd_pstate_adjust_perf(unsig
+       if (max_perf < min_perf)
+               max_perf = min_perf;
++      des_perf = clamp_t(unsigned long, des_perf, min_perf, max_perf);
++      target_freq = div_u64(des_perf * max_freq, max_perf);
++      policy->cur = target_freq;
++
+       amd_pstate_update(cpudata, min_perf, des_perf, max_perf, true);
+       cpufreq_cpu_put(policy);
+ }
diff --git a/queue-6.3/netfilter-ctnetlink-support-offloaded-conntrack-entry-deletion.patch b/queue-6.3/netfilter-ctnetlink-support-offloaded-conntrack-entry-deletion.patch
new file mode 100644 (file)
index 0000000..cf15cb4
--- /dev/null
@@ -0,0 +1,57 @@
+From 9b7c68b3911aef84afa4cbfc31bce20f10570d51 Mon Sep 17 00:00:00 2001
+From: Paul Blakey <paulb@nvidia.com>
+Date: Wed, 22 Mar 2023 09:35:32 +0200
+Subject: netfilter: ctnetlink: Support offloaded conntrack entry deletion
+
+From: Paul Blakey <paulb@nvidia.com>
+
+commit 9b7c68b3911aef84afa4cbfc31bce20f10570d51 upstream.
+
+Currently, offloaded conntrack entries (flows) can only be deleted
+after they are removed from offload, which is either by timeout,
+tcp state change or tc ct rule deletion. This can cause issues for
+users wishing to manually delete or flush existing entries.
+
+Support deletion of offloaded conntrack entries.
+
+Example usage:
+ # Delete all offloaded (and non offloaded) conntrack entries
+ # whose source address is 1.2.3.4
+ $ conntrack -D -s 1.2.3.4
+ # Delete all entries
+ $ conntrack -F
+
+Signed-off-by: Paul Blakey <paulb@nvidia.com>
+Reviewed-by: Simon Horman <simon.horman@corigine.com>
+Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
+Signed-off-by: Florian Westphal <fw@strlen.de>
+Cc: Demi Marie Obenour <demi@invisiblethingslab.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ net/netfilter/nf_conntrack_netlink.c |    8 --------
+ 1 file changed, 8 deletions(-)
+
+--- a/net/netfilter/nf_conntrack_netlink.c
++++ b/net/netfilter/nf_conntrack_netlink.c
+@@ -1559,9 +1559,6 @@ static const struct nla_policy ct_nla_po
+ static int ctnetlink_flush_iterate(struct nf_conn *ct, void *data)
+ {
+-      if (test_bit(IPS_OFFLOAD_BIT, &ct->status))
+-              return 0;
+-
+       return ctnetlink_filter_match(ct, data);
+ }
+@@ -1631,11 +1628,6 @@ static int ctnetlink_del_conntrack(struc
+       ct = nf_ct_tuplehash_to_ctrack(h);
+-      if (test_bit(IPS_OFFLOAD_BIT, &ct->status)) {
+-              nf_ct_put(ct);
+-              return -EBUSY;
+-      }
+-
+       if (cda[CTA_ID]) {
+               __be32 id = nla_get_be32(cda[CTA_ID]);
index 1fa4d800b7db894dfe0a93001c5f5256a0df6d4f..803a63194f9ea0adcfcd2c03d4cae43164c38e99 100644 (file)
@@ -40,3 +40,6 @@ vfio-type1-check-pfn-valid-before-converting-to-stru.patch
 cpufreq-amd-pstate-remove-fast_switch_possible-flag-.patch
 net-phy-mscc-enable-vsc8501-2-rgmii-rx-clock.patch
 bluetooth-add-cmd-validity-checks-at-the-start-of-hci_sock_ioctl.patch
+cpufreq-amd-pstate-update-policy-cur-in-amd_pstate_adjust_perf.patch
+cpufreq-amd-pstate-add-fast_switch-callback.patch
+netfilter-ctnetlink-support-offloaded-conntrack-entry-deletion.patch