6.9.3-rc1 review
Subsystems (4)
Greg Kroah-Hartman
maintainerPATCH 149/427 x86/pat: Fix W^X violation false-positives when running as Xen PV guest
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Juergen Gross <[email protected]>
[ Upstream commit 5bc8b0f5dac04cd4ebe47f8090a5942f2f2647ef ]
When running as Xen PV guest in some cases W^X violation WARN()s have been observed. Those WARN()s are produced by verify_rwx(), which looks into the PTE to verify that writable kernel pages have the NX bit set in order to avoid code modifications of the kernel by rogue code.
As the NX bits of all levels of translation entries are or-ed and the RW bits of all levels are and-ed, looking just into the PTE isn't enough for the decision that a writable page is executable, too.
When running as a Xen PV guest, the direct map PMDs and kernel high map PMDs share the same set of PTEs. Xen kernel initialization will set the NX bit in the direct map PMD entries, and not the shared PTEs.
--- arch/x86/mm/pat/set_memory.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-)
arch/x86/mm/pat/set_memory.c +18 -8
@@ -619,7 +619,8 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long start,* Validate strict W^X semantics. */ static inline pgprot_t verify_rwx (pgprot_t old,pgprot_t new,unsigned long start, -unsigned long pfn,unsigned long npg) +unsigned long pfn,unsigned long npg, +bool nx,bool rw) {unsigned long end;
@@ -641,6 +642,10 @@ static inline pgprot_t verify_rwx(pgprot_t old, pgprot_t new, unsigned long starif ((pgprot_val (new) & (_PAGE_RW | _PAGE_NX)) != _PAGE_RW)return new; +/* Non-leaf translation entries can disable writing or execution. */ +if (!rw || nx) +return new; + end = start + npg *PAGE_SIZE -1 ; WARN_ONCE(1, "CPA detected W^X violation: %016llx -> %016llx range: 0x%016lx - 0x%016lx PFN %lx\n", (unsigned long long)pgprot_val(old),
@@ -742,7 +747,7 @@ pte_t *lookup_address(unsigned long address, unsigned int *level)EXPORT_SYMBOL_GPL (lookup_address);static pte_t *_lookup_address_cpa (struct cpa_data *cpa,unsigned long address, -unsigned int *level) +unsigned int *level,bool *nx,bool *rw) {pgd_t *pgd;
@@ -751,7 +756,7 @@ static pte_t *_lookup_address_cpa(struct cpa_data *cpa, unsigned long address,else pgd = cpa->pgd +pgd_index (address); -return lookup_address_in_pgd (pgd, address, level); +return lookup_address_in_pgd_attr (pgd, address, level, nx, rw); }/*
@@ -879,12 +884,13 @@ static int __should_split_large_page(pte_t *kpte, unsigned long address,pgprot_t old_prot, new_prot, req_prot, chk_prot;pte_t new_pte, *tmp;enum pg_level level; +bool nx, rw;/* * Check for races, another CPU might have split this page * up already: */ - tmp =_lookup_address_cpa (cpa, address, &level); + tmp =_lookup_address_cpa (cpa, address, &level, &nx, &rw);if (tmp != kpte)return 1 ;
@@ -995,7 +1001,8 @@ static int __should_split_large_page(pte_t *kpte, unsigned long address, new_prot =static_protections (req_prot, lpaddr, old_pfn, numpages, psize,CPA_DETECT ); - new_prot =verify_rwx (old_prot, new_prot, lpaddr, old_pfn, numpages); + new_prot =verify_rwx (old_prot, new_prot, lpaddr, old_pfn, numpages, + nx, rw);/* * If there is a conflict, split the large page.
@@ -1076,6 +1083,7 @@ __split_large_page(struct cpa_data *cpa, pte_t *kpte, unsigned long address,pte_t *pbase = (pte_t *)page_address (base);unsigned int i, level;pgprot_t ref_prot; +bool nx, rw;pte_t *tmp;spin_lock (&pgd_lock);
@@ -1083,7 +1091,7 @@ __split_large_page(struct cpa_data *cpa, pte_t *kpte, unsigned long address,* Check for races, another CPU might have split this page * up for us already: */ - tmp =_lookup_address_cpa (cpa, address, &level); + tmp =_lookup_address_cpa (cpa, address, &level, &nx, &rw);if (tmp != kpte) {spin_unlock (&pgd_lock);return 1 ;
@@ -1624,10 +1632,11 @@ static int __change_page_attr(struct cpa_data *cpa, int primary)int do_split, err;unsigned int level;pte_t *kpte, old_pte; +bool nx, rw; address =__cpa_addr (cpa, cpa->curpage); repeat: - kpte =_lookup_address_cpa (cpa, address, &level); + kpte =_lookup_address_cpa (cpa, address, &level, &nx, &rw);if (!kpte)return __cpa_process_fault (cpa, address, primary);
@@ -1649,7 +1658,8 @@ static int __change_page_attr(struct cpa_data *cpa, int primary) new_prot =static_protections (new_prot, address, pfn,1 ,0 ,CPA_PROTECT ); - new_prot =verify_rwx (old_prot, new_prot, address, pfn,1 ); + new_prot =verify_rwx (old_prot, new_prot, address, pfn,1 , + nx, rw); new_prot =pgprot_clear_protnone_bits (new_prot);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 150/427 udp: Avoid call to compute_score on multiple sites
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gabriel Krisman Bertazi <[email protected]>
[ Upstream commit 50aee97d15113b95a68848db1f0cb2a6c09f753a ]
We've observed a 7-12% performance regression in iperf3 UDP ipv4 and ipv6 tests with multiple sockets on Zen3 cpus, which we traced back to commit f0ea27e7bfe1 ("udp: re-score reuseport groups when connected sockets are present"). The failing tests were those that would spawn UDP sockets per-cpu on systems that have a high number of cpus.
Unsurprisingly, it is not caused by the extra re-scoring of the reused socket, but due to the compiler no longer inlining compute_score, once it has the extra call site in udp4_lib_lookup2. This is augmented by the "Safe RET" mitigation for SRSO, needed in our Zen3 cpus.
We could just explicitly inline it, but compute_score() is quite a large function, around 300b. Inlining in two sites would almost double udp4_lib_lookup2, which is a silly thing to do just to workaround a mitigation. Instead, this patch shuffles the code a bit to avoid the multiple calls to compute_score. Since it is a static function used in one spot, the compiler can safely fold it in, as it did before, without increasing the text size.
With this patch applied I ran my original iperf3 testcases. The failing cases all looked like this (ipv4):
iperf3 -c 127.0.0.1 --udp -4 -f K -b $R -l 8920 -t 30 -i 5 -P 64 -O 2
where $R is either 1G/10G/0 (max, unlimited). I ran 3 times each. baseline is v6.9-rc3. harmean == harmonic mean; CV == coefficient of variation.
ipv4:
1G 10G MAX
HARMEAN (CV) HARMEAN (CV) HARMEAN (CV)
baseline 1743852.66(0.0208) 1725933.02(0.0167) 1705203.78(0.0386) patched 1968727.61(0.0035) 1962283.22(0.0195) 1923853.50(0.0256)
ipv6:
1G 10G MAX
HARMEAN (CV) HARMEAN (CV) HARMEAN (CV)
baseline 1729020.03(0.0028) 1691704.49(0.0243) 1692251.34(0.0083) patched 1900422.19(0.0067) 1900968.01(0.0067) 1568532.72(0.1519)
This restores the performance we had before the change above with this benchmark. We obviously don't expect any real impact when mitigations are disabled, but just to be sure it also doesn't regresses:
mitigations=off ipv4:
1G 10G MAX
HARMEAN (CV) HARMEAN (CV) HARMEAN (CV)
baseline 3230279.97(0.0066) 3229320.91(0.0060) 2605693.19(0.0697) patched 3242802.36(0.0073) 3239310.71(0.0035) 2502427.19(0.0882)
--- net/ipv4/udp.c | 21 ++++++++++++++++----- net/ipv6/udp.c | 20 ++++++++++++++++---- 2 files changed, 32 insertions(+), 9 deletions(-)
net/ipv4/udp.c +16 -5
@@ -427,15 +427,21 @@ static struct sock *udp4_lib_lookup2(struct net *net, {struct sock *sk, *result;int score, badness; +bool need_rescore; result =NULL ; badness =0 ;udp_portaddr_for_each_entry_rcu (sk, &hslot2->head) { - score =compute_score (sk, net, saddr, sport, - daddr, hnum, dif, sdif); + need_rescore = false; +rescore: + score =compute_score (need_rescore ? result : sk, net, saddr, + sport, daddr, hnum, dif, sdif);if (score > badness) { badness = score; +if (need_rescore) +continue ; +if (sk->sk_state ==TCP_ESTABLISHED ) { result = sk;continue ;
@@ -456,9 +462,14 @@ static struct sock *udp4_lib_lookup2(struct net *net,if (IS_ERR (result))continue ; - badness =compute_score (result, net, saddr, sport, - daddr, hnum, dif, sdif); - +/* compute_score is too long of a function to be +* inlined, and calling it again here yields +* measureable overhead for some +* workloads. Work around it by jumping +* backwards to rescore 'result'. +*/ + need_rescore = true; + goto rescore; } }return result;
net/ipv6/udp.c +16 -4
@@ -168,15 +168,21 @@ static struct sock *udp6_lib_lookup2(struct net *net, {struct sock *sk, *result;int score, badness; +bool need_rescore; result =NULL ; badness =-1 ;udp_portaddr_for_each_entry_rcu (sk, &hslot2->head) { - score =compute_score (sk, net, saddr, sport, - daddr, hnum, dif, sdif); + need_rescore = false; +rescore: + score =compute_score (need_rescore ? result : sk, net, saddr, + sport, daddr, hnum, dif, sdif);if (score > badness) { badness = score; +if (need_rescore) +continue ; +if (sk->sk_state ==TCP_ESTABLISHED ) { result = sk;continue ;
@@ -197,8 +203,14 @@ static struct sock *udp6_lib_lookup2(struct net *net,if (IS_ERR (result))continue ; - badness =compute_score (sk, net, saddr, sport, - daddr, hnum, dif, sdif); +/* compute_score is too long of a function to be +* inlined, and calling it again here yields +* measureable overhead for some +* workloads. Work around it by jumping +* backwards to rescore 'result'. +*/ + need_rescore = true; + goto rescore; } }return result;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 151/427 openrisc: Use do_kernel_power_off()
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stafford Horne <[email protected]>
[ Upstream commit c94195a34e09dacfe2feef03602c911e82f49994 ]
After commit 14c5678720bd ("power: reset: syscon-poweroff: Use devm_register_sys_off_handler(POWER_OFF)") setting up of pm_power_off was removed from the driver, this causes OpenRISC platforms using syscon-poweroff to no longer shutdown.
The kernel now supports chained power-off handlers. Use do_kernel_power_off() that invokes chained power-off handlers. All architectures have moved away from using pm_power_off except OpenRISC.
This patch migrates openrisc to use do_kernel_power_off() instead of the legacy pm_power_off().
--- arch/openrisc/kernel/process.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
arch/openrisc/kernel/process.c +3 -5
@@ -65,7 +65,7 @@ void machine_restart(char *cmd) }/* -* This is used if pm_power_off has not been set by a power management +* This is used if a sys-off handler was not set by a power management * driver, in this case we can assume we are on a simulator. On * OpenRISC simulators l.nop 1 will trigger the simulator exit. */
@@ -89,10 +89,8 @@ void machine_halt(void)void machine_power_off (void ) {printk (KERN_INFO "*** MACHINE POWER OFF ***\n" ); -if (pm_power_off !=NULL ) -pm_power_off (); -else -default_power_off (); +do_kernel_power_off (); +default_power_off (); }/*
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 152/427 openrisc: traps: Dont send signals to kernel mode threads
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stafford Horne <[email protected]>
[ Upstream commit c88cfb5cea5f8f9868ef02cc9ce9183a26dcf20f ]
OpenRISC exception handling sends signals to user processes on floating point exceptions and trap instructions (for debugging) among others. There is a bug where the trap handling logic may send signals to kernel threads, we should not send these signals to kernel threads, if that happens we treat it as an error.
This patch adds conditions to die if the kernel receives these exceptions in kernel mode code.
--- arch/openrisc/kernel/traps.c | 48 ++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 19 deletions(-)
arch/openrisc/kernel/traps.c +29 -19
@@ -180,29 +180,39 @@ asmlinkage void unhandled_exception(struct pt_regs *regs, int ea, int vector) asmlinkage void do_fpe_trap(struct pt_regs *regs, unsigned long address) { -int code =FPE_FLTUNK ; -unsigned long fpcsr = regs->fpcsr; - -if (fpcsr &SPR_FPCSR_IVF ) - code =FPE_FLTINV ; -else if (fpcsr &SPR_FPCSR_OVF ) - code =FPE_FLTOVF ; -else if (fpcsr &SPR_FPCSR_UNF ) - code =FPE_FLTUND ; -else if (fpcsr &SPR_FPCSR_DZF ) - code =FPE_FLTDIV ; -else if (fpcsr &SPR_FPCSR_IXF ) - code =FPE_FLTRES ; - -/* Clear all flags */ - regs->fpcsr &= ~SPR_FPCSR_ALLF ; - -force_sig_fault (SIGFPE , code, (void __user *)regs->pc); +if (user_mode (regs)) { +int code =FPE_FLTUNK ; +unsigned long fpcsr = regs->fpcsr; + +if (fpcsr &SPR_FPCSR_IVF ) + code =FPE_FLTINV ; +else if (fpcsr &SPR_FPCSR_OVF ) + code =FPE_FLTOVF ; +else if (fpcsr &SPR_FPCSR_UNF ) + code =FPE_FLTUND ; +else if (fpcsr &SPR_FPCSR_DZF ) + code =FPE_FLTDIV ; +else if (fpcsr &SPR_FPCSR_IXF ) + code =FPE_FLTRES ; + +/* Clear all flags */ + regs->fpcsr &= ~SPR_FPCSR_ALLF ; + +force_sig_fault (SIGFPE , code, (void __user *)regs->pc); + }else { +pr_emerg ("KERNEL: Illegal fpe exception 0x%.8lx\n" , regs->pc); +die ("Die:" , regs,SIGFPE ); + } } asmlinkage void do_trap(struct pt_regs *regs, unsigned long address) { -force_sig_fault (SIGTRAP ,TRAP_BRKPT , (void __user *)regs->pc); +if (user_mode (regs)) { +force_sig_fault (SIGTRAP ,TRAP_BRKPT , (void __user *)regs->pc); + }else { +pr_emerg ("KERNEL: Illegal trap exception 0x%.8lx\n" , regs->pc); +die ("Die:" , regs,SIGILL ); + } } asmlinkage void do_unaligned_access(struct pt_regs *regs, unsigned long address)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 153/427 cppc_cpufreq: Fix possible null pointer dereference
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aleksandr Mishin <[email protected]>
[ Upstream commit cf7de25878a1f4508c69dc9f6819c21ba177dbfe ]
cppc_cpufreq_get_rate() and hisi_cppc_cpufreq_get_rate() can be called from different places with various parameters. So cpufreq_cpu_get() can return null as 'policy' in some circumstances.
Fix this bug by adding null return check.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/cpufreq/cppc_cpufreq.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/cpufreq/cppc_cpufreq.c +12 -2
@@ -741,10 +741,15 @@ static unsigned int cppc_cpufreq_get_rate(unsigned int cpu) {struct cppc_perf_fb_ctrs fb_ctrs_t0 = {0 }, fb_ctrs_t1 = {0 };struct cpufreq_policy *policy =cpufreq_cpu_get (cpu); -struct cppc_cpudata *cpu_data = policy->driver_data; +struct cppc_cpudata *cpu_data;u64 delivered_perf;int ret; +if (!policy) +return -ENODEV ; + + cpu_data = policy->driver_data; +cpufreq_cpu_put (policy); ret =cppc_get_perf_ctrs (cpu, &fb_ctrs_t0);
@@ -822,10 +827,15 @@ static struct cpufreq_driver cppc_cpufreq_driver = {static unsigned int hisi_cppc_cpufreq_get_rate (unsigned int cpu) {struct cpufreq_policy *policy =cpufreq_cpu_get (cpu); -struct cppc_cpudata *cpu_data = policy->driver_data; +struct cppc_cpudata *cpu_data;u64 desired_perf;int ret; +if (!policy) +return -ENODEV ; + + cpu_data = policy->driver_data; +cpufreq_cpu_put (policy); ret =cppc_get_desired_perf (cpu, &desired_perf);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 154/427 wifi: mac80211: transmit deauth only if link is available
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 570944a094c24ee3a09b2cb5e580063cfde64d7a ]
There's an issue in that when we disconnect from an AP due to the AP switching to an unsupported channel, we might not tell the driver about this before we try to send the deauth. If the underlying implementation has detected the quiet CSA, this may cause issues if this is the only active link. Avoid this by transmitting (and flushing) the deauth only when there's an active link available that's not affected by quiet CSA.
Since this introduces link->u.mgd.csa_blocked_tx and we no longer check sdata->csa_blocked_tx for the TX itself also rename the latter to csa_blocked_queues.
--- net/mac80211/cfg.c | 12 ++++----- net/mac80211/ieee80211_i.h | 3 ++- net/mac80211/iface.c | 4 +-- net/mac80211/mlme.c | 53 ++++++++++++++++++++++++++------------ 4 files changed, 46 insertions(+), 26 deletions(-)
net/mac80211/cfg.c +6 -6
@@ -1607,10 +1607,10 @@ static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev,/* abort any running channel switch or color change */ link_conf->csa_active = false; link_conf->color_change_active = false; -if (sdata->csa_blocked_tx) { +if (sdata->csa_blocked_queues) {ieee80211_wake_vif_queues (local, sdata,IEEE80211_QUEUE_STOP_REASON_CSA ); - sdata->csa_blocked_tx = false; + sdata->csa_blocked_queues = false; }ieee80211_free_next_beacon (link);
@@ -3648,7 +3648,7 @@ void ieee80211_channel_switch_disconnect(struct ieee80211_vif *vif, bool block_tstruct ieee80211_if_managed *ifmgd = &sdata->u.mgd;struct ieee80211_local *local = sdata->local; - sdata->csa_blocked_tx = block_tx; + sdata->csa_blocked_queues = block_tx;sdata_info (sdata,"channel switch failed, disconnecting\n" );wiphy_work_queue (local->hw.wiphy, &ifmgd->csa_connection_drop_work); }
@@ -3734,10 +3734,10 @@ static int __ieee80211_csa_finalize(struct ieee80211_link_data *link_data)ieee80211_link_info_change_notify (sdata, link_data, changed); -if (sdata->csa_blocked_tx) { +if (sdata->csa_blocked_queues) {ieee80211_wake_vif_queues (local, sdata,IEEE80211_QUEUE_STOP_REASON_CSA ); - sdata->csa_blocked_tx = false; + sdata->csa_blocked_queues = false; } err =drv_post_channel_switch (link_data);
@@ -4019,7 +4019,7 @@ __ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev, !ieee80211_hw_check(&local->hw, HANDLES_QUIET_CSA)) {ieee80211_stop_vif_queues (local, sdata,IEEE80211_QUEUE_STOP_REASON_CSA ); - sdata->csa_blocked_tx = true; + sdata->csa_blocked_queues = true; } cfg80211_ch_switch_started_notify(sdata->dev,
net/mac80211/ieee80211_i.h +2 -1
@@ -974,6 +974,7 @@ struct ieee80211_link_data_managed {bool csa_waiting_bcn;bool csa_ignored_same_chan; +bool csa_blocked_tx;struct wiphy_delayed_work chswitch_work;struct wiphy_work request_smps_work;
@@ -1092,7 +1093,7 @@ struct ieee80211_sub_if_data {unsigned long state; -bool csa_blocked_tx; +bool csa_blocked_queues;char name[IFNAMSIZ ];
net/mac80211/iface.c +2 -2
@@ -544,10 +544,10 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_do sdata->vif.bss_conf.csa_active = false;if (sdata->vif.type ==NL80211_IFTYPE_STATION ) sdata->deflink.u.mgd.csa_waiting_bcn = false; -if (sdata->csa_blocked_tx) { +if (sdata->csa_blocked_queues) {ieee80211_wake_vif_queues (local, sdata,IEEE80211_QUEUE_STOP_REASON_CSA ); - sdata->csa_blocked_tx = false; + sdata->csa_blocked_queues = false; }wiphy_work_cancel (local->hw.wiphy, &sdata->deflink.csa_finalize_work);
net/mac80211/mlme.c +36 -17
122 lines not on this page · raw message
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 155/427 wifi: iwlwifi: mvm: introduce esr_disable_reason
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Emmanuel Grumbach <[email protected]>
[ Upstream commit 76f9864d7ac6d04036ba85a8616e2361f2d2d06c ]
This will maintain a bitmap of reasons for which we want to avoid enabling EMLSR.
For now, we have a single reason: BT coexistence, but we will add soon more reasons. Make it a bitmap to make it easier to manage.
Since we'll impact the parameters that impact the enablement / disablement of EMLSR from several places, introduce a generic function that takes into account the current state and execute the decision that must be taken.
Stable-dep-of: 585ba158233f ("wifi: iwlwifi: mvm: don't always disable EMLSR due to BT coex")
--- drivers/net/wireless/intel/iwlwifi/mvm/coex.c | 32 +++++-------------- .../wireless/intel/iwlwifi/mvm/mld-mac80211.c | 29 ++++++++++++++++- drivers/net/wireless/intel/iwlwifi/mvm/mvm.h | 18 +++++++++-- 3 files changed, 51 insertions(+), 28 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/coex.c +8 -24
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause /* -* Copyright (C) 2013-2014, 2018-2020, 2022-2023 Intel Corporation +* Copyright (C) 2013-2014, 2018-2020, 2022-2024 Intel Corporation * Copyright (C) 2013-2015 Intel Mobile Communications GmbH */ #include <linux/ieee80211.h>
@@ -259,7 +259,6 @@ static void iwl_mvm_bt_coex_enable_esr(struct iwl_mvm *mvm, struct ieee80211_vif *vif, bool enable) {struct iwl_mvm_vif *mvmvif =iwl_mvm_vif_from_mac80211 (vif); -int link_id;lockdep_assert_held (&mvm->mutex);
@@ -267,30 +266,15 @@ static void iwl_mvm_bt_coex_enable_esr(struct iwl_mvm *mvm,return ;/* Done already */ -if (mvmvif->bt_coex_esr_disabled == !enable) +if ((mvmvif->esr_disable_reason &IWL_MVM_ESR_DISABLE_COEX ) == !enable)return ; - mvmvif->bt_coex_esr_disabled = !enable; - -/* Nothing to do */ -if (mvmvif->esr_active == enable) -return ; - -if (enable) { -/* Try to re-enable eSR*/ -iwl_mvm_mld_select_links (mvm, vif, false); -return ; - } - -/* -* Find the primary link, as we want to switch to it and drop the -* secondary one. -*/ - link_id =iwl_mvm_mld_get_primary_link (mvm, vif, vif->active_links); -WARN_ON (link_id <0 ); +if (enable) + mvmvif->esr_disable_reason &= ~IWL_MVM_ESR_DISABLE_COEX ; +else + mvmvif->esr_disable_reason |=IWL_MVM_ESR_DISABLE_COEX ; -ieee80211_set_active_links_async (vif, - vif->active_links &BIT (link_id)); +iwl_mvm_recalc_esr (mvm, vif); }/*
@@ -338,7 +322,7 @@ iwl_mvm_bt_coex_calculate_esr_mode(struct iwl_mvm *mvm,if (!link_rssi) wifi_loss_rate = mvm->last_bt_notif.wifi_loss_mid_high_rssi; -else if (!mvmvif->bt_coex_esr_disabled) +else if (!(mvmvif->esr_disable_reason &IWL_MVM_ESR_DISABLE_COEX ))/* RSSI needs to get really low to disable eSR... */ wifi_loss_rate = link_rssi <= -IWL_MVM_BT_COEX_DISABLE_ESR_THRESH ?
drivers/net/wireless/intel/iwlwifi/mvm/mld-mac80211.c +28 -1
@@ -1258,6 +1258,33 @@ int iwl_mvm_mld_get_primary_link(struct iwl_mvm *mvm,return data[1 ].link_id; } +void iwl_mvm_recalc_esr (struct iwl_mvm *mvm,struct ieee80211_vif *vif) +{ +struct iwl_mvm_vif *mvmvif =iwl_mvm_vif_from_mac80211 (vif); +bool enable = !mvmvif->esr_disable_reason; +int link_id; + +/* Nothing to do */ +if (mvmvif->esr_active == enable) +return ; + +if (enable) { +/* Try to re-enable eSR */ +iwl_mvm_mld_select_links (mvm, vif, false); +return ; + } + +/* +* Find the primary link, as we want to switch to it and drop the +* secondary one. +*/ + link_id =iwl_mvm_mld_get_primary_link (mvm, vif, vif->active_links); +WARN_ON (link_id <0 ); + +ieee80211_set_active_links_async (vif, + vif->active_links &BIT (link_id)); +} +/* * This function receives a bitmap of usable links and check if we can enter * eSR on those links.
@@ -1300,7 +1327,7 @@ static bool iwl_mvm_can_enter_esr(struct iwl_mvm *mvm, primary_link);// Mark eSR as disabled for the next time if (!ret) - mvmvif->bt_coex_esr_disabled = true; + mvmvif->esr_disable_reason |=IWL_MVM_ESR_DISABLE_COEX ;break ; }
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h +15 -3
@@ -346,6 +346,14 @@ struct iwl_mvm_vif_link_info {u16 mgmt_queue; }; +/** +* enum iwl_mvm_esr_disable_reason - reasons for which we can't enable EMLSR +* @IWL_MVM_ESR_DISABLE_COEX: COEX is preventing the enablement of EMLSR +*/ +enum iwl_mvm_esr_disable_reason { +IWL_MVM_ESR_DISABLE_COEX =BIT (0 ), +}; +/** * struct iwl_mvm_vif - data per Virtual Interface, it is a MAC context * @mvm: pointer back to the mvm struct
@@ -361,7 +369,6 @@ struct iwl_mvm_vif_link_info {* @pm_enabled - indicate if MAC power management is allowed * @monitor_active: indicates that monitor context is configured, and that the * interface should get quota etc. -* @bt_coex_esr_disabled: indicates if esr is disabled due to bt coex * @low_latency: bit flags for low latency * see enum &iwl_mvm_low_latency_cause for causes. * @low_latency_actual: boolean, indicates low latency is set,
@@ -378,6 +385,7 @@ struct iwl_mvm_vif_link_info {* @deflink: default link data for use in non-MLO * @link: link data for each link in MLO * @esr_active: indicates eSR mode is active +* @esr_disable_reason: a bitmap of enum iwl_mvm_esr_disable_reason * @pm_enabled: indicates powersave is enabled */ struct iwl_mvm_vif {
@@ -392,7 +400,6 @@ struct iwl_mvm_vif {bool pm_enabled;bool monitor_active;bool esr_active; -bool bt_coex_esr_disabled; u8 low_latency: 6; u8 low_latency_actual: 1;
@@ -400,6 +407,7 @@ struct iwl_mvm_vif { u8 authorized:1;bool ps_disabled; +u32 esr_disable_reason;u32 ap_beacon_time;struct iwl_mvm_vif_bf_data bf_data;
@@ -1578,7 +1586,7 @@ static inline int iwl_mvm_max_active_links(struct iwl_mvm *mvm,return mvm->fw->ucode_capa.num_beacons;if ((iwl_mvm_is_esr_supported (trans) && - !mvmvif->bt_coex_esr_disabled) || + !mvmvif->esr_disable_reason) || ((CSR_HW_RFID_TYPE (trans->hw_rf_id) ==IWL_CFG_RF_TYPE_FM &&CSR_HW_RFID_IS_CDB (trans->hw_rf_id))))return IWL_MVM_FW_MAX_ACTIVE_LINKS_NUM ;
@@ -2779,4 +2787,8 @@ int iwl_mvm_roc_add_cmd(struct iwl_mvm *mvm,struct ieee80211_channel *channel, struct ieee80211_vif *vif, int duration, u32 activity); + +/* EMLSR */ +void iwl_mvm_recalc_esr (struct iwl_mvm *mvm,struct ieee80211_vif *vif); +#endif /* __IWL_MVM_H__ */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 156/427 wifi: iwlwifi: mvm: calculate EMLSR mode after connection
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miri Korenblit <[email protected]>
[ Upstream commit 9c6921121961cc0cecccb95652be6d98116f854b ]
The function iwl_mvm_can_enter_esr() is (among others) calculating if EMLSR mode is disabled due to BT coex by calling iwl_mvm_bt_coex_calculate_esr_mode(), then stores the decision in mvmvif::esr_disable_reason.
But there is no need to calculate this every time iwl_mvm_can_enter_esr is called. Fix this by calculating it once after authorization, and in iwl_mvm_can_enter_esr only check mvmvif::esr_disable_reason.
Stable-dep-of: 585ba158233f ("wifi: iwlwifi: mvm: don't always disable EMLSR due to BT coex")
--- drivers/net/wireless/intel/iwlwifi/mvm/coex.c | 10 ++++----- .../net/wireless/intel/iwlwifi/mvm/mac80211.c | 21 +++++++++++++++++++ .../wireless/intel/iwlwifi/mvm/mld-mac80211.c | 13 ++++-------- drivers/net/wireless/intel/iwlwifi/mvm/mvm.h | 9 +++----- drivers/net/wireless/intel/iwlwifi/mvm/rx.c | 4 ++-- 5 files changed, 35 insertions(+), 22 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/coex.c +5 -5
@@ -281,7 +281,7 @@ static void iwl_mvm_bt_coex_enable_esr(struct iwl_mvm *mvm,* This function receives the LB link id and checks if eSR should be * enabled or disabled (due to BT coex) */ -bool +static bool iwl_mvm_bt_coex_calculate_esr_mode (struct iwl_mvm *mvm,struct ieee80211_vif *vif,int link_id,int primary_link)
@@ -338,9 +338,9 @@ iwl_mvm_bt_coex_calculate_esr_mode(struct iwl_mvm *mvm,return wifi_loss_rate <=IWL_MVM_BT_COEX_WIFI_LOSS_THRESH ; } -void iwl_mvm_bt_coex_update_vif_esr (struct iwl_mvm *mvm, -struct ieee80211_vif *vif, -int link_id) +void iwl_mvm_bt_coex_update_link_esr (struct iwl_mvm *mvm, +struct ieee80211_vif *vif, +int link_id) {unsigned long usable_links =ieee80211_vif_usable_links (vif); int primary_link = iwl_mvm_mld_get_primary_link(mvm, vif,
@@ -402,7 +402,7 @@ static void iwl_mvm_bt_notif_per_link(struct iwl_mvm *mvm,return ; } -iwl_mvm_bt_coex_update_vif_esr (mvm, vif, link_id); +iwl_mvm_bt_coex_update_link_esr (mvm, vif, link_id);if (fw_has_capa (&mvm->fw->ucode_capa,IWL_UCODE_TLV_CAPA_COEX_SCHEMA_2 )) min_ag_for_static_smps =BT_VERY_HIGH_TRAFFIC ;
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c +21 -0
@@ -3789,6 +3789,24 @@ iwl_mvm_sta_state_auth_to_assoc(struct ieee80211_hw *hw,return callbacks->update_sta (mvm, vif, sta); } +static void iwl_mvm_bt_coex_update_vif_esr (struct iwl_mvm *mvm, +struct ieee80211_vif *vif) +{ +unsigned long usable_links =ieee80211_vif_usable_links (vif); +u8 link_id; + +for_each_set_bit (link_id, &usable_links,IEEE80211_MLD_MAX_NUM_LINKS ) { +struct ieee80211_bss_conf *link_conf = +link_conf_dereference_protected (vif, link_id); + +if (WARN_ON_ONCE (!link_conf)) +return ; + +if (link_conf->chanreq.oper.chan->band ==NL80211_BAND_2GHZ ) +iwl_mvm_bt_coex_update_link_esr (mvm, vif, link_id); + } +} + static int iwl_mvm_sta_state_assoc_to_authorized(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
@@ -3816,6 +3834,9 @@ iwl_mvm_sta_state_assoc_to_authorized(struct iwl_mvm *mvm, callbacks->mac_ctxt_changed (mvm, vif, false);iwl_mvm_mei_host_associated (mvm, vif, mvm_sta); +/* Calculate eSR mode due to BT coex */ +iwl_mvm_bt_coex_update_vif_esr (mvm, vif); +/* when client is authorized (AP station marked as such), * try to enable more links */
drivers/net/wireless/intel/iwlwifi/mvm/mld-mac80211.c +4 -9
@@ -1294,13 +1294,13 @@ static bool iwl_mvm_can_enter_esr(struct iwl_mvm *mvm, unsigned long desired_links) {struct iwl_mvm_vif *mvmvif =iwl_mvm_vif_from_mac80211 (vif); -int primary_link =iwl_mvm_mld_get_primary_link (mvm, vif, - desired_links); +u16 usable_links =ieee80211_vif_usable_links (vif);const struct wiphy_iftype_ext_capab *ext_capa;bool ret = true;int link_id; -if (primary_link <0 ) +if (!ieee80211_vif_is_mld (vif) || !vif->cfg.assoc || +hweight16 (usable_links) <=1 )return false;if (!(vif->cfg.eml_cap &IEEE80211_EML_CAP_EMLSR_SUPP ))
@@ -1323,12 +1323,7 @@ static bool iwl_mvm_can_enter_esr(struct iwl_mvm *mvm,if (link_conf->chanreq.oper.chan->band !=NL80211_BAND_2GHZ )continue ; - ret =iwl_mvm_bt_coex_calculate_esr_mode (mvm, vif, link_id, - primary_link); -// Mark eSR as disabled for the next time -if (!ret) - mvmvif->esr_disable_reason |=IWL_MVM_ESR_DISABLE_COEX ; -break ; +return !(mvmvif->esr_disable_reason &IWL_MVM_ESR_DISABLE_COEX ); }return ret;
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h +3 -6
@@ -2141,12 +2141,9 @@ bool iwl_mvm_bt_coex_is_tpc_allowed(struct iwl_mvm *mvm,u8 iwl_mvm_bt_coex_get_single_ant_msk (struct iwl_mvm *mvm,u8 enabled_ants);u8 iwl_mvm_bt_coex_tx_prio (struct iwl_mvm *mvm,struct ieee80211_hdr *hdr,struct ieee80211_tx_info *info,u8 ac); -bool iwl_mvm_bt_coex_calculate_esr_mode (struct iwl_mvm *mvm, -struct ieee80211_vif *vif, -int link_id,int primary_link); -void iwl_mvm_bt_coex_update_vif_esr (struct iwl_mvm *mvm, -struct ieee80211_vif *vif, -int link_id); +void iwl_mvm_bt_coex_update_link_esr (struct iwl_mvm *mvm, +struct ieee80211_vif *vif, +int link_id);/* beacon filtering */ #ifdef CONFIG_IWLWIFI_DEBUGFS
drivers/net/wireless/intel/iwlwifi/mvm/rx.c +2 -2
@@ -889,8 +889,8 @@ iwl_mvm_stat_iterator_all_links(struct iwl_mvm *mvm,if (link_info->phy_ctxt && link_info->phy_ctxt->channel->band ==NL80211_BAND_2GHZ ) -iwl_mvm_bt_coex_update_vif_esr (mvm, bss_conf->vif, - link_id); +iwl_mvm_bt_coex_update_link_esr (mvm, bss_conf->vif, + link_id);/* make sure that beacon statistics don't go backwards with TCM * request to clear statistics
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 157/427 wifi: iwlwifi: mvm: dont always disable EMLSR due to BT coex
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miri Korenblit <[email protected]>
[ Upstream commit 585ba158233f97da05d9bcc59d13ddf45135c8c9 ]
2.4 GHz/LB (low band) link can't be used in an EMLSR links pair when BT is on. But EMLSR is still allowed for a pair of links which none of them operates in LB.
In the existing code, EMLSR will always be disabled if one of the usable links is in LB (and BT is on).
Move this check to the code that verifies a specific pair of links, and only if one of these links operates on LB - disable EMLSR.
--- .../wireless/intel/iwlwifi/mvm/mld-mac80211.c | 89 +++++++++++-------- drivers/net/wireless/intel/iwlwifi/mvm/mvm.h | 9 +- 2 files changed, 56 insertions(+), 42 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/mld-mac80211.c +52 -37
@@ -602,10 +602,49 @@ struct iwl_mvm_link_sel_data {bool active; }; -static bool iwl_mvm_mld_valid_link_pair (struct iwl_mvm_link_sel_data *a, +static bool iwl_mvm_mld_valid_link_pair (struct ieee80211_vif *vif, +struct iwl_mvm_link_sel_data *a,struct iwl_mvm_link_sel_data *b) { -return a->band != b->band; +struct iwl_mvm_vif *mvmvif =iwl_mvm_vif_from_mac80211 (vif); + +if (a->band == b->band) +return false; + +/* BT Coex effects eSR mode only if one of the link is on LB */ +if (a->band ==NL80211_BAND_2GHZ || b->band ==NL80211_BAND_2GHZ ) +return !(mvmvif->esr_disable_reason &IWL_MVM_ESR_DISABLE_COEX ); + +return true; +} + +static u8 +iwl_mvm_set_link_selection_data (struct ieee80211_vif *vif, +struct iwl_mvm_link_sel_data *data, +unsigned long usable_links) +{ +u8 n_data =0 ; +unsigned long link_id; + +rcu_read_lock (); + +for_each_set_bit (link_id, &usable_links,IEEE80211_MLD_MAX_NUM_LINKS ) { +struct ieee80211_bss_conf *link_conf = +rcu_dereference (vif->link_conf[link_id]); + +if (WARN_ON_ONCE (!link_conf)) +continue ; + + data[n_data].link_id = link_id; + data[n_data].band = link_conf->chanreq.oper.chan->band; + data[n_data].width = link_conf->chanreq.oper.width; + data[n_data].active = vif->active_links &BIT (link_id); + n_data++; + } + +rcu_read_unlock (); + +return n_data; } void iwl_mvm_mld_select_links(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
@@ -615,7 +654,7 @@ void iwl_mvm_mld_select_links(struct iwl_mvm *mvm, struct ieee80211_vif *vif,unsigned long usable_links =ieee80211_vif_usable_links (vif);u32 max_active_links =iwl_mvm_max_active_links (mvm, vif);u16 new_active_links; -u8 link_id, n_data =0 , i, j; +u8 n_data, i, j;if (!IWL_MVM_AUTO_EML_ENABLE )return ;
@@ -640,23 +679,7 @@ void iwl_mvm_mld_select_links(struct iwl_mvm *mvm, struct ieee80211_vif *vif,if (hweight16 (vif->active_links) == max_active_links)return ; -rcu_read_lock (); - -for_each_set_bit (link_id, &usable_links,IEEE80211_MLD_MAX_NUM_LINKS ) { -struct ieee80211_bss_conf *link_conf = -rcu_dereference (vif->link_conf[link_id]); - -if (WARN_ON_ONCE (!link_conf)) -continue ; - - data[n_data].link_id = link_id; - data[n_data].band = link_conf->chanreq.oper.chan->band; - data[n_data].width = link_conf->chanreq.oper.width; - data[n_data].active = vif->active_links &BIT (link_id); - n_data++; - } - -rcu_read_unlock (); + n_data =iwl_mvm_set_link_selection_data (vif, data, usable_links);/* this is expected to be the current active link */ if (n_data ==1 )
@@ -680,7 +703,8 @@ void iwl_mvm_mld_select_links(struct iwl_mvm *mvm, struct ieee80211_vif *vif,if (i == j)continue ; -if (iwl_mvm_mld_valid_link_pair (&data[i], &data[j])) +if (iwl_mvm_mld_valid_link_pair (vif, &data[i], + &data[j]))break ; }
@@ -696,7 +720,7 @@ void iwl_mvm_mld_select_links(struct iwl_mvm *mvm, struct ieee80211_vif *vif,if (i == j)continue ; -if (iwl_mvm_mld_valid_link_pair (&data[i], +if (iwl_mvm_mld_valid_link_pair (vif, &data[i], &data[j]))break ; }
@@ -1293,11 +1317,10 @@ static bool iwl_mvm_can_enter_esr(struct iwl_mvm *mvm,struct ieee80211_vif *vif, unsigned long desired_links) { - struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); u16 usable_links = ieee80211_vif_usable_links(vif); +struct iwl_mvm_link_sel_data data[IEEE80211_MLD_MAX_NUM_LINKS ];const struct wiphy_iftype_ext_capab *ext_capa; -bool ret = true; -int link_id; +u8 n_data;if (!ieee80211_vif_is_mld (vif) || !vif->cfg.assoc ||hweight16 (usable_links) <=1 )
@@ -1312,21 +1335,13 @@ static bool iwl_mvm_can_enter_esr(struct iwl_mvm *mvm, !(ext_capa->eml_capabilities & IEEE80211_EML_CAP_EMLSR_SUPP))return false; -for_each_set_bit (link_id, &desired_links,IEEE80211_MLD_MAX_NUM_LINKS ) { -struct ieee80211_bss_conf *link_conf = -link_conf_dereference_protected (vif, link_id); - -if (WARN_ON_ONCE (!link_conf)) -continue ; + n_data =iwl_mvm_set_link_selection_data (vif, data, desired_links); -/* BT Coex effects eSR mode only if one of the link is on LB */ -if (link_conf->chanreq.oper.chan->band !=NL80211_BAND_2GHZ ) -continue ; +if (n_data !=2 ) +return false; -return !(mvmvif->esr_disable_reason &IWL_MVM_ESR_DISABLE_COEX ); - } -return ret; +return iwl_mvm_mld_valid_link_pair (vif, &data[0 ], &data[1 ]); } static bool iwl_mvm_mld_can_activate_links(struct ieee80211_hw *hw,
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h +4 -5
@@ -1580,15 +1580,14 @@ static inline int iwl_mvm_max_active_links(struct iwl_mvm *mvm,struct iwl_trans *trans = mvm->fwrt.trans;struct iwl_mvm_vif *mvmvif =iwl_mvm_vif_from_mac80211 (vif); -lockdep_assert_held (&mvm->mutex); -if (vif->type ==NL80211_IFTYPE_AP )return mvm->fw->ucode_capa.num_beacons; +/* Check if HW supports eSR or STR */ if ((iwl_mvm_is_esr_supported (trans) && - !mvmvif->esr_disable_reason) || - ((CSR_HW_RFID_TYPE (trans->hw_rf_id) ==IWL_CFG_RF_TYPE_FM && -CSR_HW_RFID_IS_CDB (trans->hw_rf_id)))) + !(mvmvif->esr_disable_reason & ~IWL_MVM_ESR_DISABLE_COEX )) || + (CSR_HW_RFID_TYPE (trans->hw_rf_id) ==IWL_CFG_RF_TYPE_FM && +CSR_HW_RFID_IS_CDB (trans->hw_rf_id)))return IWL_MVM_FW_MAX_ACTIVE_LINKS_NUM ;return 1 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 158/427 wifi: iwlwifi: mvm: init vif works only once
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 0bcc2155983e03c41b21a356af87ae839a6b3ead ]
It's dangerous to re-initialize works repeatedly, especially delayed ones that have an associated timer, and even more so if they're not necessarily canceled inbetween. This can be the case for these workers here during FW restart scenarios, so make sure to initialize it only once.
While at it, also ensure it is cancelled correctly.
--- .../net/wireless/intel/iwlwifi/mvm/mac80211.c | 19 +++++++++++++++++-- .../wireless/intel/iwlwifi/mvm/mld-mac80211.c | 2 ++ drivers/net/wireless/intel/iwlwifi/mvm/mvm.h | 2 ++ 3 files changed, 21 insertions(+), 2 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c +17 -2
@@ -1564,6 +1564,17 @@ static int iwl_mvm_alloc_bcast_mcast_sta(struct iwl_mvm *mvm, IWL_STA_MULTICAST); } +void iwl_mvm_mac_init_mvmvif (struct iwl_mvm *mvm,struct iwl_mvm_vif *mvmvif) +{ +lockdep_assert_held (&mvm->mutex); + +if (test_bit (IWL_MVM_STATUS_IN_HW_RESTART , &mvm->status)) +return ; + +INIT_DELAYED_WORK (&mvmvif->csa_work, + iwl_mvm_channel_switch_disconnect_wk); +} +static int iwl_mvm_mac_add_interface (struct ieee80211_hw *hw,struct ieee80211_vif *vif) {
@@ -1574,6 +1585,8 @@ static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw,mutex_lock (&mvm->mutex); +iwl_mvm_mac_init_mvmvif (mvm, mvmvif); + mvmvif->mvm = mvm;/* the first link always points to the default one */
@@ -1655,8 +1668,6 @@ static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw, mvm->p2p_device_vif = vif;iwl_mvm_tcm_add_vif (mvm, vif); -INIT_DELAYED_WORK (&mvmvif->csa_work, - iwl_mvm_channel_switch_disconnect_wk);if (vif->type ==NL80211_IFTYPE_MONITOR ) { mvm->monitor_on = true;
@@ -1694,6 +1705,8 @@ static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw,void iwl_mvm_prepare_mac_removal (struct iwl_mvm *mvm,struct ieee80211_vif *vif) { +struct iwl_mvm_vif *mvmvif =iwl_mvm_vif_from_mac80211 (vif); +if (vif->type ==NL80211_IFTYPE_P2P_DEVICE ) {/* * Flush the ROC worker which will flush the OFFCHANNEL queue.
@@ -1702,6 +1715,8 @@ void iwl_mvm_prepare_mac_removal(struct iwl_mvm *mvm,*/ flush_work (&mvm->roc_done_wk); } + +cancel_delayed_work_sync (&mvmvif->csa_work); }/* This function is doing the common part of removing the interface for
drivers/net/wireless/intel/iwlwifi/mvm/mld-mac80211.c +2 -0
@@ -14,6 +14,8 @@ static int iwl_mvm_mld_mac_add_interface(struct ieee80211_hw *hw,mutex_lock (&mvm->mutex); +iwl_mvm_mac_init_mvmvif (mvm, mvmvif); + mvmvif->mvm = mvm;/* Not much to do here. The stack will not allow interface
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h +2 -0
@@ -1783,6 +1783,8 @@ int iwl_mvm_load_d3_fw(struct iwl_mvm *mvm);int iwl_mvm_mac_setup_register (struct iwl_mvm *mvm); +void iwl_mvm_mac_init_mvmvif (struct iwl_mvm *mvm,struct iwl_mvm_vif *mvmvif); +/* * FW notifications / CMD responses handlers * Convention: iwl_mvm_rx_<NAME OF THE CMD>
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 159/427 scsi: libsas: Fix the failure of adding phy with zero-address to port
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xingui Yang <[email protected]>
[ Upstream commit 06036a0a5db34642c5dbe22021a767141f010b7a ]
As of commit 7d1d86518118 ("[SCSI] libsas: fix false positive 'device attached' conditions"), reset the phy->entacted_sas_addr address to a zero-address when the link rate is less than 1.5G.
Currently we find that when a new device is attached, and the link rate is less than 1.5G, but the device type is not NO_DEVICE, for example: the link rate is SAS_PHY_RESET_IN_PROGRESS and the device type is stp. After setting the phy->entacted_sas_addr address to the zero address, the port will continue to be created for the phy with the zero-address, and other phys with the zero-address will be tried to be added to the new port:
[562240.051197] sas: ex 500e004aaaaaaa1f phy19:U:0 attached: 0000000000000000 (no device) // phy19 is deleted but still on the parent port's phy_list [562240.062536] sas: ex 500e004aaaaaaa1f phy0 new device attached [562240.062616] sas: ex 500e004aaaaaaa1f phy00:U:5 attached: 0000000000000000 (stp) [562240.062680] port-7:7:0: trying to add phy phy-7:7:19 fails: it's already part of another port
Therefore, it should be the same as sas_get_phy_attached_dev(). Only when device_type is SAS_PHY_UNUSED, sas_address is set to the 0 address.
--- drivers/scsi/libsas/sas_expander.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/libsas/sas_expander.c +1 -2
@@ -239,8 +239,7 @@ static void sas_set_ex_phy(struct domain_device *dev, int phy_id,/* help some expanders that fail to zero sas_address in the 'no * device' case */ -if (phy->attached_dev_type ==SAS_PHY_UNUSED || - phy->linkrate <SAS_LINK_RATE_1_5_GBPS ) +if (phy->attached_dev_type ==SAS_PHY_UNUSED )memset (phy->attached_sas_addr,0 ,SAS_ADDR_SIZE );else memcpy (phy->attached_sas_addr, dr->attached_sas_addr,SAS_ADDR_SIZE );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 160/427 scsi: hpsa: Fix allocation size for Scsi_Host private data
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuri Karpov <[email protected]>
[ Upstream commit 504e2bed5d50610c1836046c0c195b0a6dba9c72 ]
struct Scsi_Host private data contains pointer to struct ctlr_info.
Restore allocation of only 8 bytes to store pointer in struct Scsi_Host private data area.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/scsi/hpsa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/hpsa.c +1 -1
@@ -5850,7 +5850,7 @@ static int hpsa_scsi_host_alloc(struct ctlr_info *h) {struct Scsi_Host *sh; - sh =scsi_host_alloc (&hpsa_driver_template,sizeof (struct ctlr_info )); + sh =scsi_host_alloc (&hpsa_driver_template,sizeof (struct ctlr_info *));if (sh ==NULL ) {dev_err (&h->pdev->dev,"scsi_host_alloc failed\n" );return -ENOMEM ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 161/427 x86/purgatory: Switch to the position-independent small code model
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
[ Upstream commit cba786af84a0f9716204e09f518ce3b7ada8555e ]
On x86, the ordinary, position dependent small and kernel code models only support placement of the executable in 32-bit addressable memory, due to the use of 32-bit signed immediates to generate references to global variables. For the kernel, this implies that all global variables must reside in the top 2 GiB of the kernel virtual address space, where the implicit address bits 63:32 are equal to sign bit 31.
This means the kernel code model is not suitable for other bare metal executables such as the kexec purgatory, which can be placed arbitrarily in the physical address space, where its address may no longer be representable as a sign extended 32-bit quantity. For this reason, commit
e16c2983fba0 ("x86/purgatory: Change compiler flags from -mcmodel=kernel to -mcmodel=large to fix kexec relocation errors")
switched to the large code model, which uses 64-bit immediates for all symbol references, including function calls, in order to avoid relying on any assumptions regarding proximity of symbols in the final executable.
The large code model is rarely used, clunky and the least likely to operate in a similar fashion when comparing GCC and Clang, so it is best avoided. This is especially true now that Clang 18 has started to emit executable code in two separate sections (.text and .ltext), which triggers an issue in the kexec loading code at runtime.
The SUSE bugzilla fixes tag points to gcc 13 having issues with the large model too and that perhaps the large model should simply not be used at all.
Instead, use the position independent small code model, which makes no assumptions about placement but only about proximity, where all referenced symbols must be within -/+ 2 GiB, i.e., in range for a RIP-relative reference. Use hidden visibility to suppress the use of a GOT, which carries absolute addresses that are not covered by static ELF relocations, and is therefore incompatible with the kexec loader's relocation logic.
[ bp: Massage commit message. ]
--- arch/x86/purgatory/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/purgatory/Makefile +2 -1
@@ -42,7 +42,8 @@ KCOV_INSTRUMENT := n # make up the standalone purgatory.ro PURGATORY_CFLAGS_REMOVE := -mcmodel=kernel -PURGATORY_CFLAGS := -mcmodel=large -ffreestanding -fno-zero-initialized-in-bss -g0 +PURGATORY_CFLAGS := -mcmodel=small -ffreestanding -fno-zero-initialized-in-bss -g0 +PURGATORY_CFLAGS += -fpic -fvisibility=hidden PURGATORY_CFLAGS += $(DISABLE_STACKLEAK_PLUGIN) -DDISABLE_BRANCH_PROFILING PURGATORY_CFLAGS += -fno-stack-protector
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 162/427 wifi: ath12k: fix out-of-bound access of qmi_invoke_handler()
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karthikeyan Kathirvel <[email protected]>
[ Upstream commit e1bdff48a1bb4a4ac660c19c55a820968c48b3f2 ]
Currently, there is no terminator entry for ath12k_qmi_msg_handlers hence facing below KASAN warning,
==================================================================
BUG: KASAN: global-out-of-bounds in qmi_invoke_handler+0xa4/0x148 Read of size 8 at addr ffffffd00a6428d8 by task kworker/u8:2/1273 CPU: 0 PID: 1273 Comm: kworker/u8:2 Not tainted 5.4.213 #0 Workqueue: qmi_msg_handler qmi_data_ready_work Call trace: dump_backtrace+0x0/0x20c show_stack+0x14/0x1c dump_stack+0xe0/0x138 print_address_description.isra.5+0x30/0x330 __kasan_report+0x16c/0x1bc kasan_report+0xc/0x14 __asan_load8+0xa8/0xb0 qmi_invoke_handler+0xa4/0x148 qmi_handle_message+0x18c/0x1bc qmi_data_ready_work+0x4ec/0x528 process_one_work+0x2c0/0x440 worker_thread+0x324/0x4b8 kthread+0x210/0x228 ret_from_fork+0x10/0x18
The address belongs to the variable:
ath12k_mac_mon_status_filter_default+0x4bd8/0xfffffffffffe2300 [ath12k] [...] ==================================================================
Add a dummy terminator entry at the end to assist the qmi_invoke_handler() in traversing up to the terminator entry without accessing an out-of-boundary index.
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
--- drivers/net/wireless/ath/ath12k/qmi.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/ath/ath12k/qmi.c +3 -0
@@ -3178,6 +3178,9 @@ static const struct qmi_msg_handler ath12k_qmi_msg_handlers[] = { .decoded_size = sizeof(struct qmi_wlanfw_fw_ready_ind_msg_v01), .fn = ath12k_qmi_msg_fw_ready_cb, }, + +/* end of list */ + {}, }; static int ath12k_qmi_ops_new_server(struct qmi_handle *qmi_hdl,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 163/427 thermal/drivers/mediatek/lvts_thermal: Add coeff for mt8192
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hsin-Te Yuan <[email protected]>
[ Upstream commit 7954c92ede882b0dfd52a5db90291a4151b44c1a ]
In order for lvts_raw_to_temp to function properly on mt8192, temperature coefficients for mt8192 need to be added.
--- drivers/thermal/mediatek/lvts_thermal.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/thermal/mediatek/lvts_thermal.c +4 -0
@@ -1530,11 +1530,15 @@ static const struct lvts_data mt7988_lvts_ap_data = {static const struct lvts_data mt8192_lvts_mcu_data = { .lvts_ctrl = mt8192_lvts_mcu_data_ctrl, .num_lvts_ctrl =ARRAY_SIZE (mt8192_lvts_mcu_data_ctrl), + .temp_factor =LVTS_COEFF_A_MT8195 , + .temp_offset =LVTS_COEFF_B_MT8195 , };static const struct lvts_data mt8192_lvts_ap_data = { .lvts_ctrl = mt8192_lvts_ap_data_ctrl, .num_lvts_ctrl =ARRAY_SIZE (mt8192_lvts_ap_data_ctrl), + .temp_factor =LVTS_COEFF_A_MT8195 , + .temp_offset =LVTS_COEFF_B_MT8195 , };static const struct lvts_data mt8195_lvts_mcu_data = {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 164/427 thermal/drivers/tsens: Fix null pointer dereference
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aleksandr Mishin <[email protected]>
[ Upstream commit d998ddc86a27c92140b9f7984ff41e3d1d07a48f ]
compute_intercept_slope() is called from calibrate_8960() (in tsens-8960.c) as compute_intercept_slope(priv, p1, NULL, ONE_PT_CALIB) which lead to null pointer dereference (if DEBUG or DYNAMIC_DEBUG set).
Fix this bug by adding null pointer check.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/thermal/qcom/tsens.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/qcom/tsens.c +1 -1
@@ -264,7 +264,7 @@ void compute_intercept_slope(struct tsens_priv *priv, u32 *p1,for (i =0 ; i < priv->num_sensors; i++) {dev_dbg (priv->dev,"%s: sensor%d - data_point1:%#x data_point2:%#x\n" , - __func__, i, p1[i], p2[i]); + __func__, i, p1[i], p2 ? p2[i] :0 );if (!priv->sensor[i].slope) priv->sensor[i].slope =SLOPE_DEFAULT ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 165/427 dt-bindings: thermal: loongson,ls2k-thermal: Add Loongson-2K0500 compatible
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Binbin Zhou <[email protected]>
[ Upstream commit 25c7d8472f6e90390931e93f59135478af3e5d86 ]
The thermal on the Loongson-2K0500 shares the design with the Loongson-2K1000. Define corresponding compatible string, having the loongson,ls2k1000-thermal as a fallback.
Stable-dep-of: c8c435368577 ("dt-bindings: thermal: loongson,ls2k-thermal: Fix incorrect compatible definition")
--- .../devicetree/bindings/thermal/loongson,ls2k-thermal.yaml | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/thermal/loongson,ls2k-thermal.yaml +1 -0
@@ -20,6 +20,7 @@ properties: - loongson,ls2k1000-thermal - items: - enum: + - loongson,ls2k0500-thermal - loongson,ls2k2000-thermal - const: loongson,ls2k1000-thermal
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 166/427 dt-bindings: thermal: loongson,ls2k-thermal: Fix incorrect compatible definition
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Binbin Zhou <[email protected]>
[ Upstream commit c8c4353685778e75e186103411e9d01a4a3f2b90 ]
The temperature output register of the Loongson-2K2000 is defined in the chip configuration domain, which is different from the Loongson-2K1000, so it can't be fallbacked.
We need to use two groups of registers to describe it: the first group is the high and low temperature threshold setting register; the second group is the temperature output register.
It is true that this fix will cause ABI corruption, but it is necessary otherwise the Loongson-2K2000 temperature sensor will not work properly.
--- .../thermal/loongson,ls2k-thermal.yaml | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/thermal/loongson,ls2k-thermal.yaml +21 -2
@@ -18,14 +18,15 @@ properties: oneOf: - enum: - loongson,ls2k1000-thermal + - loongson,ls2k2000-thermal - items: - enum: - loongson,ls2k0500-thermal - - loongson,ls2k2000-thermal - const: loongson,ls2k1000-thermal reg: - maxItems: 1 + minItems: 1 + maxItems: 2 interrupts: maxItems: 1
@@ -39,6 +40,24 @@ required: - interrupts - '#thermal-sensor-cells' +if: + properties: + compatible: + contains: + enum: + - loongson,ls2k2000-thermal + +then: + properties: + reg: + minItems: 2 + maxItems: 2 + +else: + properties: + reg: + maxItems: 1 + unevaluatedProperties: false examples:
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 167/427 wifi: ath10k: Fix an error code problem in ath10k_dbg_sta_write_peer_debug_trigger()
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Su Hui <[email protected]>
[ Upstream commit c511a9c12674d246916bb16c479d496b76983193 ]
Clang Static Checker (scan-build) warns:
drivers/net/wireless/ath/ath10k/debugfs_sta.c:line 429, column 3 Value stored to 'ret' is never read.
Return 'ret' rather than 'count' when 'ret' stores an error code.
--- drivers/net/wireless/ath/ath10k/debugfs_sta.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath10k/debugfs_sta.c +1 -1
@@ -439,7 +439,7 @@ ath10k_dbg_sta_write_peer_debug_trigger(struct file *file, } out:mutex_unlock (&ar->conf_mutex); -return count; +return ret ?: count; }static const struct file_operations fops_peer_debug_trigger = {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 168/427 gfs2: Remove ill-placed consistency check
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andreas Gruenbacher <[email protected]>
[ Upstream commit 59f60005797b4018d7b46620037e0c53d690795e ]
This consistency check was originally added by commit 9287c6452d2b1 ("gfs2: Fix occasional glock use-after-free"). It is ill-placed in gfs2_glock_free() because if it holds there, it must equally hold in __gfs2_glock_put() already. Either way, the check doesn't seem necessary anymore.
Stable-dep-of: d98779e68772 ("gfs2: Fix potential glock use-after-free on unmount")
--- fs/gfs2/glock.c | 1 - 1 file changed, 1 deletion(-)
fs/gfs2/glock.c +0 -1
@@ -170,7 +170,6 @@ void gfs2_glock_free(struct gfs2_glock *gl) {struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; -gfs2_glock_assert_withdraw (gl,atomic_read (&gl->gl_revokes) ==0 );rhashtable_remove_fast (&gl_hash_table, &gl->gl_node, ht_parms);smp_mb ();wake_up_glock (gl);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 169/427 gfs2: Fix potential glock use-after-free on unmount
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andreas Gruenbacher <[email protected]>
[ Upstream commit d98779e687726d8f8860f1c54b5687eec5f63a73 ]
When a DLM lockspace is released and there ares still locks in that lockspace, DLM will unlock those locks automatically. Commit fb6791d100d1b started exploiting this behavior to speed up filesystem
unmount: gfs2 would simply free glocks it didn't want to unlock and then release the lockspace. This didn't take the bast callbacks for asynchronous lock contention notifications into account, which remain active until until a lock is unlocked or its lockspace is released.
To prevent those callbacks from accessing deallocated objects, put the glocks that should not be unlocked on the sd_dead_glocks list, release the lockspace, and only then free those glocks.
As an additional measure, ignore unexpected ast and bast callbacks if the receiving glock is dead.
--- fs/gfs2/glock.c | 35 ++++++++++++++++++++++++++++++++--- fs/gfs2/glock.h | 1 + fs/gfs2/incore.h | 1 + fs/gfs2/lock_dlm.c | 32 ++++++++++++++++++++++---------- fs/gfs2/ops_fstype.c | 1 + fs/gfs2/super.c | 3 --- 6 files changed, 57 insertions(+), 16 deletions(-)
fs/gfs2/glock.c +32 -3
@@ -166,18 +166,45 @@ static bool glock_blocked_by_withdraw(struct gfs2_glock *gl)return true; } -void gfs2_glock_free (struct gfs2_glock *gl) +static void __gfs2_glock_free (struct gfs2_glock *gl) { -struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; -rhashtable_remove_fast (&gl_hash_table, &gl->gl_node, ht_parms);smp_mb ();wake_up_glock (gl);call_rcu (&gl->gl_rcu, gfs2_glock_dealloc); +} + +void gfs2_glock_free (struct gfs2_glock *gl) { +struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; + +__gfs2_glock_free (gl);if (atomic_dec_and_test (&sdp->sd_glock_disposal))wake_up (&sdp->sd_kill_wait); } +void gfs2_glock_free_later (struct gfs2_glock *gl) { +struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; + +spin_lock (&lru_lock); +list_add (&gl->gl_lru, &sdp->sd_dead_glocks); +spin_unlock (&lru_lock); +if (atomic_dec_and_test (&sdp->sd_glock_disposal)) +wake_up (&sdp->sd_kill_wait); +} + +static void gfs2_free_dead_glocks (struct gfs2_sbd *sdp) +{ +struct list_head *list = &sdp->sd_dead_glocks; + +while (!list_empty (list)) { +struct gfs2_glock *gl; + + gl = list_first_entry(list, struct gfs2_glock, gl_lru); +list_del_init (&gl->gl_lru); +__gfs2_glock_free (gl); + } +} +/** * gfs2_glock_hold() - increment reference count on glock * @gl: The glock to hold
@@ -2226,6 +2253,8 @@ void gfs2_gl_hash_clear(struct gfs2_sbd *sdp)wait_event_timeout (sdp->sd_kill_wait,atomic_read (&sdp->sd_glock_disposal) ==0 ,HZ *600 ); +gfs2_lm_unmount (sdp); +gfs2_free_dead_glocks (sdp);glock_hash_walk (dump_glock_func, sdp); }
fs/gfs2/glock.h +1 -0
@@ -252,6 +252,7 @@ void gfs2_gl_dq_holders(struct gfs2_sbd *sdp);void gfs2_glock_thaw (struct gfs2_sbd *sdp);void gfs2_glock_add_to_lru (struct gfs2_glock *gl);void gfs2_glock_free (struct gfs2_glock *gl); +void gfs2_glock_free_later (struct gfs2_glock *gl);int __init gfs2_glock_init (void );void gfs2_glock_exit (void );
fs/gfs2/incore.h +1 -0
@@ -838,6 +838,7 @@ struct gfs2_sbd {/* For quiescing the filesystem */ struct gfs2_holder sd_freeze_gh;struct mutex sd_freeze_mutex; +struct list_head sd_dead_glocks;char sd_fsname[GFS2_FSNAME_LEN +3 *sizeof (int ) +2 ];char sd_table_name[GFS2_FSNAME_LEN ];
fs/gfs2/lock_dlm.c +22 -10
@@ -121,6 +121,11 @@ static void gdlm_ast(void *arg)struct gfs2_glock *gl = arg;unsigned ret = gl->gl_state; +/* If the glock is dead, we only react to a dlm_unlock() reply. */ +if (__lockref_is_dead (&gl->gl_lockref) && + gl->gl_lksb.sb_status != -DLM_EUNLOCK ) +return ; +gfs2_update_reply_times (gl);BUG_ON (gl->gl_lksb.sb_flags &DLM_SBF_DEMOTED );
@@ -171,6 +176,9 @@ static void gdlm_bast(void *arg, int mode) {struct gfs2_glock *gl = arg; +if (__lockref_is_dead (&gl->gl_lockref)) +return ; +switch (mode) {case DLM_LOCK_EX :gfs2_glock_cb (gl,LM_ST_UNLOCKED );
@@ -291,8 +299,12 @@ static void gdlm_put_lock(struct gfs2_glock *gl)struct lm_lockstruct *ls = &sdp->sd_lockstruct;int error; -if (gl->gl_lksb.sb_lkid ==0 ) - goto out_free; +BUG_ON (!__lockref_is_dead (&gl->gl_lockref)); + +if (gl->gl_lksb.sb_lkid ==0 ) { +gfs2_glock_free (gl); +return ; + }clear_bit (GLF_BLOCKING , &gl->gl_flags);gfs2_glstats_inc (gl,GFS2_LKS_DCOUNT );
@@ -300,13 +312,17 @@ static void gdlm_put_lock(struct gfs2_glock *gl)gfs2_update_request_times (gl);/* don't want to call dlm if we've unmounted the lock protocol */ -if (test_bit (DFL_UNMOUNT , &ls->ls_recover_flags)) - goto out_free; +if (test_bit (DFL_UNMOUNT , &ls->ls_recover_flags)) { +gfs2_glock_free (gl); +return ; + }/* don't want to skip dlm_unlock writing the lvb when lock has one */ if (test_bit (SDF_SKIP_DLM_UNLOCK , &sdp->sd_flags) && - !gl->gl_lksb.sb_lvbptr) - goto out_free; + !gl->gl_lksb.sb_lvbptr) { +gfs2_glock_free_later (gl); +return ; + } again: error = dlm_unlock(ls->ls_dlm, gl->gl_lksb.sb_lkid, DLM_LKF_VALBLK,
@@ -321,10 +337,6 @@ static void gdlm_put_lock(struct gfs2_glock *gl) gl->gl_name.ln_type, (unsigned long long)gl->gl_name.ln_number, error); } -return ; - -out_free: -gfs2_glock_free (gl); }static void gdlm_cancel (struct gfs2_glock *gl)
fs/gfs2/ops_fstype.c +1 -0
@@ -136,6 +136,7 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb)atomic_set (&sdp->sd_log_in_flight,0 );init_waitqueue_head (&sdp->sd_log_flush_wait);mutex_init (&sdp->sd_freeze_mutex); +INIT_LIST_HEAD (&sdp->sd_dead_glocks);return sdp;
fs/gfs2/super.c +0 -3
@@ -646,10 +646,7 @@ static void gfs2_put_super(struct super_block *sb)gfs2_gl_hash_clear (sdp);truncate_inode_pages_final (&sdp->sd_aspace);gfs2_delete_debugfs_file (sdp); -/* Unmount the locking protocol */ -gfs2_lm_unmount (sdp); -/* At this point, we're through participating in the lockspace */ gfs2_sys_fs_del (sdp);free_sbd (sdp); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 170/427 gfs2: finish_xmote cleanup
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andreas Gruenbacher <[email protected]>
[ Upstream commit 1cd28e15864054f3c48baee9eecda1c0441c48ac ]
Currently, function finish_xmote() takes and releases the glock spinlock. However, all of its callers immediately take that spinlock again, so it makes more sense to take the spin lock before calling finish_xmote() already.
With that, thaw_glock() is the only place that sets the GLF_HAVE_REPLY flag outside of the glock spinlock, but it also takes that spinlock immediately thereafter. Change that to set the bit when the spinlock is already held. This allows to switch from test_and_clear_bit() to test_bit() and clear_bit() in glock_work_func().
Stable-dep-of: 9947a06d29c0 ("gfs2: do_xmote fixes")
--- fs/gfs2/glock.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
fs/gfs2/glock.c +13 -8
@@ -617,7 +617,6 @@ static void finish_xmote(struct gfs2_glock *gl, unsigned int ret)struct gfs2_holder *gh;unsigned state = ret &LM_OUT_ST_MASK ; -spin_lock (&gl->gl_lockref.lock);trace_gfs2_glock_state_change (gl, state);state_change (gl, state); gh =find_first_waiter (gl);
@@ -665,7 +664,6 @@ static void finish_xmote(struct gfs2_glock *gl, unsigned int ret) gl->gl_target, state);GLOCK_BUG_ON (gl,1 ); } -spin_unlock (&gl->gl_lockref.lock);return ; }
@@ -688,7 +686,6 @@ static void finish_xmote(struct gfs2_glock *gl, unsigned int ret) } out:clear_bit (GLF_LOCK , &gl->gl_flags); -spin_unlock (&gl->gl_lockref.lock); }static bool is_system_glock (struct gfs2_glock *gl)
@@ -835,15 +832,19 @@ __acquires(&gl->gl_lockref.lock)if (ret == -EINVAL && gl->gl_target ==LM_ST_UNLOCKED && target ==LM_ST_UNLOCKED &&test_bit (DFL_UNMOUNT , &ls->ls_recover_flags)) { +spin_lock (&gl->gl_lockref.lock);finish_xmote (gl, target); -gfs2_glock_queue_work (gl,0 ); +__gfs2_glock_queue_work (gl,0 ); +spin_unlock (&gl->gl_lockref.lock); }else if (ret) {fs_err (sdp,"lm_lock ret %d\n" , ret);GLOCK_BUG_ON (gl, !gfs2_withdrawing_or_withdrawn (sdp)); } }else {/* lock_nolock */ +spin_lock (&gl->gl_lockref.lock);finish_xmote (gl, target); -gfs2_glock_queue_work (gl,0 ); +__gfs2_glock_queue_work (gl,0 ); +spin_unlock (&gl->gl_lockref.lock); } out:spin_lock (&gl->gl_lockref.lock);
@@ -1099,11 +1100,12 @@ static void glock_work_func(struct work_struct *work) struct gfs2_glock *gl = container_of(work, struct gfs2_glock, gl_work.work);unsigned int drop_refs =1 ; -if (test_and_clear_bit (GLF_REPLY_PENDING , &gl->gl_flags)) { +spin_lock (&gl->gl_lockref.lock); +if (test_bit (GLF_REPLY_PENDING , &gl->gl_flags)) { +clear_bit (GLF_REPLY_PENDING , &gl->gl_flags);finish_xmote (gl, gl->gl_reply); drop_refs++; } -spin_lock (&gl->gl_lockref.lock);if (test_bit (GLF_PENDING_DEMOTE , &gl->gl_flags) && gl->gl_state !=LM_ST_UNLOCKED && gl->gl_demote_state !=LM_ST_EXCLUSIVE ) {
@@ -2176,8 +2178,11 @@ static void thaw_glock(struct gfs2_glock *gl)return ;if (!lockref_get_not_dead (&gl->gl_lockref))return ; + +spin_lock (&gl->gl_lockref.lock);set_bit (GLF_REPLY_PENDING , &gl->gl_flags); -gfs2_glock_queue_work (gl,0 ); +__gfs2_glock_queue_work (gl,0 ); +spin_unlock (&gl->gl_lockref.lock); }/**
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 171/427 gfs2: do_xmote fixes
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andreas Gruenbacher <[email protected]>
[ Upstream commit 9947a06d29c0a30da88cdc6376ca5fd87083e130 ]
Function do_xmote() is called with the glock spinlock held. Commit 86934198eefa added a 'goto skip_inval' statement at the beginning of the function to further below where the glock spinlock is expected not to be held anymore. Then it added code there that requires the glock spinlock to be held. This doesn't make sense; fix this up by dropping and retaking the spinlock where needed.
In addition, when ->lm_lock() returned an error, do_xmote() didn't fail the locking operation, and simply left the glock hanging; fix that as well. (This is a much older error.)
--- fs/gfs2/glock.c | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-)
fs/gfs2/glock.c +25 -19
@@ -713,6 +713,7 @@ __acquires(&gl->gl_lockref.lock) {const struct gfs2_glock_operations *glops = gl->gl_ops;struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; +struct lm_lockstruct *ls = &sdp->sd_lockstruct;unsigned int lck_flags = (unsigned int )(gh ? gh->gh_flags :0 );int ret;
@@ -741,6 +742,9 @@ __acquires(&gl->gl_lockref.lock) (gl->gl_state == LM_ST_EXCLUSIVE) || (lck_flags & (LM_FLAG_TRY|LM_FLAG_TRY_1CB)))clear_bit (GLF_BLOCKING , &gl->gl_flags); +if (!glops->go_inval && !glops->go_sync) + goto skip_inval; +spin_unlock (&gl->gl_lockref.lock);if (glops->go_sync) { ret = glops->go_sync (gl);
@@ -753,6 +757,7 @@ __acquires(&gl->gl_lockref.lock)fs_err (sdp,"Error %d syncing glock \n" , ret);gfs2_dump_glock (NULL , gl, true); } +spin_lock (&gl->gl_lockref.lock); goto skip_inval; } }
@@ -773,9 +778,10 @@ __acquires(&gl->gl_lockref.lock) glops->go_inval (gl, target ==LM_ST_DEFERRED ?0 :DIO_METADATA );clear_bit (GLF_INVALIDATE_IN_PROGRESS , &gl->gl_flags); } +spin_lock (&gl->gl_lockref.lock); skip_inval: -gfs2_glock_hold (gl); + gl->gl_lockref.count++;/* * Check for an error encountered since we called go_sync and go_inval. * If so, we can't withdraw from the glock code because the withdraw
@@ -817,37 +823,37 @@ __acquires(&gl->gl_lockref.lock)*/ clear_bit (GLF_LOCK , &gl->gl_flags);clear_bit (GLF_DEMOTE_IN_PROGRESS , &gl->gl_flags); -gfs2_glock_queue_work (gl,GL_GLOCK_DFT_HOLD ); - goto out; +__gfs2_glock_queue_work (gl,GL_GLOCK_DFT_HOLD ); +return ; }else {clear_bit (GLF_INVALIDATE_IN_PROGRESS , &gl->gl_flags); } } -if (sdp->sd_lockstruct.ls_ops->lm_lock) { -struct lm_lockstruct *ls = &sdp->sd_lockstruct; +if (ls->ls_ops->lm_lock) { +spin_unlock (&gl->gl_lockref.lock); + ret = ls->ls_ops->lm_lock (gl, target, lck_flags); +spin_lock (&gl->gl_lockref.lock); -/* lock_dlm */ - ret = sdp->sd_lockstruct.ls_ops->lm_lock (gl, target, lck_flags);if (ret == -EINVAL && gl->gl_target ==LM_ST_UNLOCKED && target ==LM_ST_UNLOCKED &&test_bit (DFL_UNMOUNT , &ls->ls_recover_flags)) { -spin_lock (&gl->gl_lockref.lock); -finish_xmote (gl, target); -__gfs2_glock_queue_work (gl,0 ); -spin_unlock (&gl->gl_lockref.lock); +/* +* The lockspace has been released and the lock has +* been unlocked implicitly. +*/ }else if (ret) {fs_err (sdp,"lm_lock ret %d\n" , ret); -GLOCK_BUG_ON (gl, !gfs2_withdrawing_or_withdrawn (sdp)); + target = gl->gl_state |LM_OUT_ERROR ; + }else { +/* The operation will be completed asynchronously. */ +return ; } - }else {/* lock_nolock */ -spin_lock (&gl->gl_lockref.lock); -finish_xmote (gl, target); -__gfs2_glock_queue_work (gl,0 ); -spin_unlock (&gl->gl_lockref.lock); } -out: -spin_lock (&gl->gl_lockref.lock); + +/* Complete the operation now. */ +finish_xmote (gl, target); +__gfs2_glock_queue_work (gl,0 ); }/**
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 172/427 thermal/debugfs: Avoid excessive updates of trip point statistics
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit 0a293c77580581c4b058eb40287acadac6ffd14a ]
Since thermal_debug_update_temp() is called before invoking thermal_debug_tz_trip_down() for the trips that were crossed by the zone temperature on the way up, it updates the statistics for them as though the current zone temperature was above the low temperature of each of them. However, if a given trip has just been crossed on the way down, the zone temperature is in fact below its low temperature, but this is handled by thermal_debug_tz_trip_down() running after the update of the trip statistics.
The remedy is to call thermal_debug_update_temp() after thermal_debug_tz_trip_down() has been invoked for all of the trips in question, but then thermal_debug_tz_trip_up() needs to be adjusted, so it does not update the statistics for the trips that has just been crossed on the way up, as that will be taken care of by thermal_debug_update_temp() down the road.
Modify the code accordingly.
--- drivers/thermal/thermal_core.c | 3 ++- drivers/thermal/thermal_debugfs.c | 7 ------- 2 files changed, 2 insertions(+), 8 deletions(-)
drivers/thermal/thermal_core.c +2 -1
@@ -431,7 +431,6 @@ static void update_temperature(struct thermal_zone_device *tz)trace_thermal_temperature (tz);thermal_genl_sampling_temp (tz->id, temp); -thermal_debug_update_temp (tz); }static void thermal_zone_device_check (struct work_struct *work)
@@ -475,6 +474,8 @@ void __thermal_zone_device_update(struct thermal_zone_device *tz,for_each_trip (tz, trip)handle_thermal_trip (tz, trip); +thermal_debug_update_temp (tz); +monitor_thermal_zone (tz); }
drivers/thermal/thermal_debugfs.c +0 -7
@@ -555,7 +555,6 @@ void thermal_debug_tz_trip_up(struct thermal_zone_device *tz,struct tz_episode *tze;struct tz_debugfs *tz_dbg;struct thermal_debugfs *thermal_dbg = tz->debugfs; -int temperature = tz->temperature;int trip_id =thermal_zone_trip_id (tz, trip);ktime_t now =ktime_get ();
@@ -624,12 +623,6 @@ void thermal_debug_tz_trip_up(struct thermal_zone_device *tz, tze = list_first_entry(&tz_dbg->tz_episodes, struct tz_episode, node); tze->trip_stats[trip_id].timestamp = now; - tze->trip_stats[trip_id].max =max (tze->trip_stats[trip_id].max, temperature); - tze->trip_stats[trip_id].min =min (tze->trip_stats[trip_id].min, temperature); - tze->trip_stats[trip_id].count++; - tze->trip_stats[trip_id].avg = tze->trip_stats[trip_id].avg + - (temperature - tze->trip_stats[trip_id].avg) / - tze->trip_stats[trip_id].count; unlock:mutex_unlock (&thermal_dbg->lock);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 173/427 selftests/bpf: Fix a fd leak in error paths in open_netns
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geliang Tang <[email protected]>
[ Upstream commit 151f7442436658ee84076681d8f52e987fe147ea ]
As Martin mentioned in review comment, there is an existing bug that orig_netns_fd will be leaked in the later "goto fail;" case after open("/proc/self/ns/net") in open_netns() in network_helpers.c. This patch adds "close(token->orig_netns_fd);" before "free(token);" to fix it.
--- tools/testing/selftests/bpf/network_helpers.c | 2 ++ 1 file changed, 2 insertions(+)
tools/testing/selftests/bpf/network_helpers.c +2 -0
@@ -461,6 +461,8 @@ struct nstoken *open_netns(const char *name)return token; fail: +if (token->orig_netns_fd !=-1 ) +close (token->orig_netns_fd);free (token);return NULL ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 174/427 scsi: ufs: core: mcq: Fix ufshcd_mcq_sqe_search()
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <[email protected]>
[ Upstream commit 3c5d0dce8ce0a2781ac306b9ad1492b005ecbab5 ]
Fix the calculation of the utrd pointer. This patch addresses the following Coverity complaint:
CID 1538170: (#1 of 1): Extra sizeof expression (SIZEOF_MISMATCH) suspicious_pointer_arithmetic: Adding sq_head_slot * 32UL /* sizeof (struct utp_transfer_req_desc) */ to pointer hwq->sqe_base_addr of type struct utp_transfer_req_desc * is suspicious because adding an integral value to this pointer automatically scales that value by the size, 32 bytes, of the pointed-to type, struct utp_transfer_req_desc. Most likely, the multiplication by sizeof (struct utp_transfer_req_desc) in this expression is extraneous and should be eliminated.
--- drivers/ufs/core/ufs-mcq.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/ufs/core/ufs-mcq.c +1 -2
@@ -601,8 +601,7 @@ static bool ufshcd_mcq_sqe_search(struct ufs_hba *hba, addr =le64_to_cpu (cmd_desc_base_addr) &CQE_UCD_BA ;while (sq_head_slot != hwq->sq_tail_slot) { - utrd = hwq->sqe_base_addr + - sq_head_slot *sizeof (struct utp_transfer_req_desc ); + utrd = hwq->sqe_base_addr + sq_head_slot; match =le64_to_cpu (utrd->command_desc_base_addr) &CQE_UCD_BA ;if (addr == match) {ufshcd_mcq_nullify_sqe (utrd);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 175/427 cpufreq: brcmstb-avs-cpufreq: ISO C90 forbids mixed declarations
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Portia Stephens <[email protected]>
[ Upstream commit fa7bd98f3c8b33fb68c6b2bc69cff32b63db69f8 ]
There is a compile warning because a NULL pointer check was added before a struct was declared. This moves the NULL pointer check to after the struct is declared and moves the struct assignment to after the NULL pointer check.
--- drivers/cpufreq/brcmstb-avs-cpufreq.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/cpufreq/brcmstb-avs-cpufreq.c +4 -1
@@ -481,9 +481,12 @@ static bool brcm_avs_is_firmware_loaded(struct private_data *priv)static unsigned int brcm_avs_cpufreq_get (unsigned int cpu) {struct cpufreq_policy *policy =cpufreq_cpu_get (cpu); +struct private_data *priv; +if (!policy)return 0 ; -struct private_data *priv = policy->driver_data; + + priv = policy->driver_data;cpufreq_cpu_put (policy);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 176/427 wifi: ath10k: populate board data for WCN3990
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
[ Upstream commit f1f1b5b055c9f27a2f90fd0f0521f5920e9b3c18 ]
Specify board data size (and board.bin filename) for the WCN3990 platform.
--- drivers/net/wireless/ath/ath10k/core.c | 3 +++ drivers/net/wireless/ath/ath10k/hw.h | 1 + drivers/net/wireless/ath/ath10k/targaddrs.h | 3 +++ 3 files changed, 7 insertions(+)
drivers/net/wireless/ath/ath10k/core.c +3 -0
@@ -720,6 +720,9 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .max_spatial_stream = 4, .fw = { .dir = WCN3990_HW_1_0_FW_DIR, + .board = WCN3990_HW_1_0_BOARD_DATA_FILE, + .board_size = WCN3990_BOARD_DATA_SZ, + .board_ext_size = WCN3990_BOARD_EXT_DATA_SZ, }, .sw_decrypt_mcast_mgmt = true, .rx_desc_ops = &wcn3990_rx_desc_ops,
drivers/net/wireless/ath/ath10k/hw.h +1 -0
@@ -133,6 +133,7 @@ enum qca9377_chip_id_rev {/* WCN3990 1.0 definitions */ #define WCN3990_HW_1_0_DEV_VERSION ATH10K_HW_WCN3990#define WCN3990_HW_1_0_FW_DIR ATH10K_FW_DIR "/WCN3990/hw1.0" +#define WCN3990_HW_1_0_BOARD_DATA_FILE "board.bin"#define ATH10K_FW_FILE_BASE "firmware"#define ATH10K_FW_API_MAX 6
drivers/net/wireless/ath/ath10k/targaddrs.h +3 -0
@@ -491,4 +491,7 @@ struct host_interest {#define QCA4019_BOARD_DATA_SZ 12064#define QCA4019_BOARD_EXT_DATA_SZ 0 +#define WCN3990_BOARD_DATA_SZ 26328 +#define WCN3990_BOARD_EXT_DATA_SZ 0 +#endif /* __TARGADDRS_H__ */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 177/427 net: dsa: mv88e6xxx: Add support for model-specific pre- and post-reset handlers
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthias Schiffer <[email protected]>
[ Upstream commit 0fdd27b9d6d7c60bd319d3497ad797934bab13cb ]
Instead of calling mv88e6xxx_g2_eeprom_wait() directly from mv88e6xxx_hardware_reset(), add configurable pre- and post-reset hard reset handlers. Initially, the handlers are set to mv88e6xxx_g2_eeprom_wait() for all families that have get/set_eeprom() to match the existing behavior. No functional change intended (except for additional error messages on failure).
--- drivers/net/dsa/mv88e6xxx/chip.c | 50 +++++++++++++++++++++++++++++--- drivers/net/dsa/mv88e6xxx/chip.h | 6 ++++ 2 files changed, 52 insertions(+), 4 deletions(-)
drivers/net/dsa/mv88e6xxx/chip.c +46 -4
@@ -3146,6 +3146,7 @@ static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)static void mv88e6xxx_hardware_reset (struct mv88e6xxx_chip *chip) {struct gpio_desc *gpiod = chip->reset; +int err;/* If there is a GPIO connected to the reset pin, toggle it */ if (gpiod) {
@@ -3154,17 +3155,26 @@ static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)* mid-byte, causing the first EEPROM read after the reset * from the wrong location resulting in the switch booting * to wrong mode and inoperable. +* For this reason, switch families with EEPROM support +* generally wait for EEPROM loads to complete as their pre- +* and post-reset handlers. */ -if (chip->info->ops->get_eeprom) -mv88e6xxx_g2_eeprom_wait (chip); +if (chip->info->ops->hardware_reset_pre) { + err = chip->info->ops->hardware_reset_pre (chip); +if (err) +dev_err (chip->dev,"pre-reset error: %d\n" , err); + }gpiod_set_value_cansleep (gpiod,1 );usleep_range (10000 ,20000 );gpiod_set_value_cansleep (gpiod,0 );usleep_range (10000 ,20000 ); -if (chip->info->ops->get_eeprom) -mv88e6xxx_g2_eeprom_wait (chip); +if (chip->info->ops->hardware_reset_post) { + err = chip->info->ops->hardware_reset_post (chip); +if (err) +dev_err (chip->dev,"post-reset error: %d\n" , err); + } } }
@@ -4394,6 +4404,8 @@ static const struct mv88e6xxx_ops mv88e6141_ops = { .watchdog_ops = &mv88e6390_watchdog_ops, .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, .pot_clear = mv88e6xxx_g2_pot_clear, + .hardware_reset_pre = mv88e6xxx_g2_eeprom_wait, + .hardware_reset_post = mv88e6xxx_g2_eeprom_wait, .reset = mv88e6352_g1_reset, .rmu_disable = mv88e6390_g1_rmu_disable, .atu_get_hash = mv88e6165_g1_atu_get_hash,
@@ -4584,6 +4596,8 @@ static const struct mv88e6xxx_ops mv88e6172_ops = { .watchdog_ops = &mv88e6097_watchdog_ops, .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, .pot_clear = mv88e6xxx_g2_pot_clear, + .hardware_reset_pre = mv88e6xxx_g2_eeprom_wait, + .hardware_reset_post = mv88e6xxx_g2_eeprom_wait, .reset = mv88e6352_g1_reset, .rmu_disable = mv88e6352_g1_rmu_disable, .atu_get_hash = mv88e6165_g1_atu_get_hash,
@@ -4684,6 +4698,8 @@ static const struct mv88e6xxx_ops mv88e6176_ops = { .watchdog_ops = &mv88e6097_watchdog_ops, .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, .pot_clear = mv88e6xxx_g2_pot_clear, + .hardware_reset_pre = mv88e6xxx_g2_eeprom_wait, + .hardware_reset_post = mv88e6xxx_g2_eeprom_wait, .reset = mv88e6352_g1_reset, .rmu_disable = mv88e6352_g1_rmu_disable, .atu_get_hash = mv88e6165_g1_atu_get_hash,
@@ -4778,6 +4794,8 @@ static const struct mv88e6xxx_ops mv88e6190_ops = { .watchdog_ops = &mv88e6390_watchdog_ops, .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, .pot_clear = mv88e6xxx_g2_pot_clear, + .hardware_reset_pre = mv88e6xxx_g2_eeprom_wait, + .hardware_reset_post = mv88e6xxx_g2_eeprom_wait, .reset = mv88e6352_g1_reset, .rmu_disable = mv88e6390_g1_rmu_disable, .atu_get_hash = mv88e6165_g1_atu_get_hash,
@@ -4836,6 +4854,8 @@ static const struct mv88e6xxx_ops mv88e6190x_ops = { .watchdog_ops = &mv88e6390_watchdog_ops, .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, .pot_clear = mv88e6xxx_g2_pot_clear, + .hardware_reset_pre = mv88e6xxx_g2_eeprom_wait, + .hardware_reset_post = mv88e6xxx_g2_eeprom_wait, .reset = mv88e6352_g1_reset, .rmu_disable = mv88e6390_g1_rmu_disable, .atu_get_hash = mv88e6165_g1_atu_get_hash,
@@ -4892,6 +4912,8 @@ static const struct mv88e6xxx_ops mv88e6191_ops = { .watchdog_ops = &mv88e6390_watchdog_ops, .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, .pot_clear = mv88e6xxx_g2_pot_clear, + .hardware_reset_pre = mv88e6xxx_g2_eeprom_wait, + .hardware_reset_post = mv88e6xxx_g2_eeprom_wait, .reset = mv88e6352_g1_reset, .rmu_disable = mv88e6390_g1_rmu_disable, .atu_get_hash = mv88e6165_g1_atu_get_hash,
@@ -4951,6 +4973,8 @@ static const struct mv88e6xxx_ops mv88e6240_ops = { .watchdog_ops = &mv88e6097_watchdog_ops, .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, .pot_clear = mv88e6xxx_g2_pot_clear, + .hardware_reset_pre = mv88e6xxx_g2_eeprom_wait, + .hardware_reset_post = mv88e6xxx_g2_eeprom_wait, .reset = mv88e6352_g1_reset, .rmu_disable = mv88e6352_g1_rmu_disable, .atu_get_hash = mv88e6165_g1_atu_get_hash,
@@ -5004,6 +5028,8 @@ static const struct mv88e6xxx_ops mv88e6250_ops = { .watchdog_ops = &mv88e6250_watchdog_ops, .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, .pot_clear = mv88e6xxx_g2_pot_clear, + .hardware_reset_pre = mv88e6xxx_g2_eeprom_wait, + .hardware_reset_post = mv88e6xxx_g2_eeprom_wait, .reset = mv88e6250_g1_reset, .vtu_getnext = mv88e6185_g1_vtu_getnext, .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
@@ -5051,6 +5077,8 @@ static const struct mv88e6xxx_ops mv88e6290_ops = { .watchdog_ops = &mv88e6390_watchdog_ops, .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, .pot_clear = mv88e6xxx_g2_pot_clear, + .hardware_reset_pre = mv88e6xxx_g2_eeprom_wait, + .hardware_reset_post = mv88e6xxx_g2_eeprom_wait, .reset = mv88e6352_g1_reset, .rmu_disable = mv88e6390_g1_rmu_disable, .atu_get_hash = mv88e6165_g1_atu_get_hash,
@@ -5110,6 +5138,8 @@ static const struct mv88e6xxx_ops mv88e6320_ops = { .watchdog_ops = &mv88e6390_watchdog_ops, .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, .pot_clear = mv88e6xxx_g2_pot_clear, + .hardware_reset_pre = mv88e6xxx_g2_eeprom_wait, + .hardware_reset_post = mv88e6xxx_g2_eeprom_wait, .reset = mv88e6352_g1_reset, .vtu_getnext = mv88e6185_g1_vtu_getnext, .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
@@ -5156,6 +5186,8 @@ static const struct mv88e6xxx_ops mv88e6321_ops = { .set_egress_port = mv88e6095_g1_set_egress_port, .watchdog_ops = &mv88e6390_watchdog_ops, .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, + .hardware_reset_pre = mv88e6xxx_g2_eeprom_wait, + .hardware_reset_post = mv88e6xxx_g2_eeprom_wait, .reset = mv88e6352_g1_reset, .vtu_getnext = mv88e6185_g1_vtu_getnext, .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
@@ -5206,6 +5238,8 @@ static const struct mv88e6xxx_ops mv88e6341_ops = { .watchdog_ops = &mv88e6390_watchdog_ops, .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, .pot_clear = mv88e6xxx_g2_pot_clear, + .hardware_reset_pre = mv88e6xxx_g2_eeprom_wait, + .hardware_reset_post = mv88e6xxx_g2_eeprom_wait, .reset = mv88e6352_g1_reset, .rmu_disable = mv88e6390_g1_rmu_disable, .atu_get_hash = mv88e6165_g1_atu_get_hash,
@@ -5361,6 +5395,8 @@ static const struct mv88e6xxx_ops mv88e6352_ops = { .watchdog_ops = &mv88e6097_watchdog_ops, .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, .pot_clear = mv88e6xxx_g2_pot_clear, + .hardware_reset_pre = mv88e6xxx_g2_eeprom_wait, + .hardware_reset_post = mv88e6xxx_g2_eeprom_wait, .reset = mv88e6352_g1_reset, .rmu_disable = mv88e6352_g1_rmu_disable, .atu_get_hash = mv88e6165_g1_atu_get_hash,
@@ -5423,6 +5459,8 @@ static const struct mv88e6xxx_ops mv88e6390_ops = { .watchdog_ops = &mv88e6390_watchdog_ops, .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, .pot_clear = mv88e6xxx_g2_pot_clear, + .hardware_reset_pre = mv88e6xxx_g2_eeprom_wait, + .hardware_reset_post = mv88e6xxx_g2_eeprom_wait, .reset = mv88e6352_g1_reset, .rmu_disable = mv88e6390_g1_rmu_disable, .atu_get_hash = mv88e6165_g1_atu_get_hash,
@@ -5485,6 +5523,8 @@ static const struct mv88e6xxx_ops mv88e6390x_ops = { .watchdog_ops = &mv88e6390_watchdog_ops, .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, .pot_clear = mv88e6xxx_g2_pot_clear, + .hardware_reset_pre = mv88e6xxx_g2_eeprom_wait, + .hardware_reset_post = mv88e6xxx_g2_eeprom_wait, .reset = mv88e6352_g1_reset, .rmu_disable = mv88e6390_g1_rmu_disable, .atu_get_hash = mv88e6165_g1_atu_get_hash,
@@ -5550,6 +5590,8 @@ static const struct mv88e6xxx_ops mv88e6393x_ops = { .watchdog_ops = &mv88e6393x_watchdog_ops, .mgmt_rsvd2cpu = mv88e6393x_port_mgmt_rsvd2cpu, .pot_clear = mv88e6xxx_g2_pot_clear, + .hardware_reset_pre = mv88e6xxx_g2_eeprom_wait, + .hardware_reset_post = mv88e6xxx_g2_eeprom_wait, .reset = mv88e6352_g1_reset, .rmu_disable = mv88e6390_g1_rmu_disable, .atu_get_hash = mv88e6165_g1_atu_get_hash,
drivers/net/dsa/mv88e6xxx/chip.h +6 -0
@@ -487,6 +487,12 @@ struct mv88e6xxx_ops {int (*ppu_enable)(struct mv88e6xxx_chip *chip);int (*ppu_disable)(struct mv88e6xxx_chip *chip); +/* Additional handlers to run before and after hard reset, to make sure +* that the switch and EEPROM are in a good state. +*/ +int (*hardware_reset_pre)(struct mv88e6xxx_chip *chip); +int (*hardware_reset_post)(struct mv88e6xxx_chip *chip); +/* Switch Software Reset */ int (*reset)(struct mv88e6xxx_chip *chip);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 178/427 net: dsa: mv88e6xxx: Avoid EEPROM timeout without EEPROM on 88E6250-family switches
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthias Schiffer <[email protected]>
[ Upstream commit e44894e2aa4eb311ceda134de8b6f51ff979211b ]
88E6250-family switches have the quirk that the EEPROM Running flag can get stuck at 1 when no EEPROM is connected, causing mv88e6xxx_g2_eeprom_wait() to time out. We still want to wait for the EEPROM however, to avoid interrupting a transfer and leaving the EEPROM in an invalid state.
The condition to wait for recommended by the hardware spec is the EEInt flag, however this flag is cleared on read, so before the hardware reset, is may have been cleared already even though the EEPROM has been read successfully.
For this reason, we revive the mv88e6xxx_g1_wait_eeprom_done() function that was removed in commit 6ccf50d4d474
("net: dsa: mv88e6xxx: Avoid EEPROM timeout when EEPROM is absent") in a slightly refactored form, and introduce a new mv88e6xxx_g1_wait_eeprom_done_prereset() that additionally handles this case by triggering another EEPROM reload that can be waited on.
On other switch models without this quirk, mv88e6xxx_g2_eeprom_wait() is kept, as it avoids the additional reload.
--- drivers/net/dsa/mv88e6xxx/chip.c | 4 +- drivers/net/dsa/mv88e6xxx/global1.c | 89 +++++++++++++++++++++++++++++ drivers/net/dsa/mv88e6xxx/global1.h | 2 + 3 files changed, 93 insertions(+), 2 deletions(-)
drivers/net/dsa/mv88e6xxx/chip.c +2 -2
@@ -5028,8 +5028,8 @@ static const struct mv88e6xxx_ops mv88e6250_ops = { .watchdog_ops = &mv88e6250_watchdog_ops, .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, .pot_clear = mv88e6xxx_g2_pot_clear, - .hardware_reset_pre = mv88e6xxx_g2_eeprom_wait, - .hardware_reset_post = mv88e6xxx_g2_eeprom_wait, + .hardware_reset_pre = mv88e6250_g1_wait_eeprom_done_prereset, + .hardware_reset_post = mv88e6xxx_g1_wait_eeprom_done, .reset = mv88e6250_g1_reset, .vtu_getnext = mv88e6185_g1_vtu_getnext, .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
drivers/net/dsa/mv88e6xxx/global1.c +89 -0
95 lines not on this page · raw message
drivers/net/dsa/mv88e6xxx/global1.h +2 -0
@@ -282,6 +282,8 @@ int mv88e6xxx_g1_set_switch_mac(struct mv88e6xxx_chip *chip, u8 *addr);int mv88e6185_g1_reset (struct mv88e6xxx_chip *chip);int mv88e6352_g1_reset (struct mv88e6xxx_chip *chip);int mv88e6250_g1_reset (struct mv88e6xxx_chip *chip); +int mv88e6xxx_g1_wait_eeprom_done (struct mv88e6xxx_chip *chip); +int mv88e6250_g1_wait_eeprom_done_prereset (struct mv88e6xxx_chip *chip);int mv88e6185_g1_ppu_enable (struct mv88e6xxx_chip *chip);int mv88e6185_g1_ppu_disable (struct mv88e6xxx_chip *chip);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 179/427 tcp: avoid premature drops in tcp_add_backlog()
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit ec00ed472bdb7d0af840da68c8c11bff9f4d9caa ]
While testing TCP performance with latest trees,
I saw suspect SOCKET_BACKLOG drops.
tcp_add_backlog() computes its limit with :
limit = (u32)READ_ONCE(sk->sk_rcvbuf) +
(u32)(READ_ONCE(sk->sk_sndbuf) >> 1);
limit += 64 * 1024;This does not take into account that sk->sk_backlog.len is reset only at the very end of __release_sock().
Both sk->sk_backlog.len and sk->sk_rmem_alloc could reach sk_rcvbuf in normal conditions.
We should double sk->sk_rcvbuf contribution in the formula to absorb bubbles in the backlog, which happen more often for very fast flows.
This change maintains decent protection against abuses.
--- net/ipv4/tcp_ipv4.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
net/ipv4/tcp_ipv4.c +11 -2
@@ -2001,7 +2001,7 @@ int tcp_v4_early_demux(struct sk_buff *skb)bool tcp_add_backlog (struct sock *sk,struct sk_buff *skb,enum skb_drop_reason *reason) { -u32 limit, tail_gso_size, tail_gso_segs; +u32 tail_gso_size, tail_gso_segs;struct skb_shared_info *shinfo;const struct tcphdr *th;struct tcphdr *thtail;
@@ -2010,6 +2010,7 @@ bool tcp_add_backlog(struct sock *sk, struct sk_buff *skb,bool fragstolen;u32 gso_segs;u32 gso_size; +u64 limit;int delta;/* In case all data was pulled from skb frags (in __pskb_pull_tail()),
@@ -2107,7 +2108,13 @@ bool tcp_add_backlog(struct sock *sk, struct sk_buff *skb,__skb_push (skb, hdrlen); no_coalesce: - limit = (u32 )READ_ONCE (sk->sk_rcvbuf) + (u32)(READ_ONCE (sk->sk_sndbuf) >>1 ); +/* sk->sk_backlog.len is reset only at the end of __release_sock(). +* Both sk->sk_backlog.len and sk->sk_rmem_alloc could reach +* sk_rcvbuf in normal conditions. +*/ + limit = ((u64 )READ_ONCE (sk->sk_rcvbuf)) <<1 ; + + limit += ((u32 )READ_ONCE (sk->sk_sndbuf)) >>1 ;/* Only socket owner can try to collapse/prune rx queues * to reduce memory overhead, so add a little headroom here.
@@ -2115,6 +2122,8 @@ bool tcp_add_backlog(struct sock *sk, struct sk_buff *skb,*/ limit +=64 *1024 ; + limit =min_t (u64, limit,UINT_MAX ); +if (unlikely (sk_add_backlog (sk, skb, limit))) {bh_unlock_sock (sk); *reason =SKB_DROP_REASON_SOCKET_BACKLOG ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 180/427 thermal/debugfs: Create records for cdev states as they get used
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit f4ae18fcb652c6cccc834ded525ac37f91d5cdb1 ]
Because thermal_debug_cdev_state_update() only creates a duration record for the old state of a cooling device, if its new state is used for the first time, there will be no record for it and cdev_dt_seq_show() will not print the duration information for it even though it contains code to compute the duration value in that case.
Address this by making thermal_debug_cdev_state_update() create a duration record for the new state if there is none.
--- drivers/thermal/thermal_debugfs.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/thermal/thermal_debugfs.c +8 -0
@@ -435,6 +435,14 @@ void thermal_debug_cdev_state_update(const struct thermal_cooling_device *cdev, } cdev_dbg->current_state = new_state; + +/* +* Create a record for the new state if it is not there, so its +* duration will be printed by cdev_dt_seq_show() as expected if it +* runs before the next state transition. +*/ +thermal_debugfs_cdev_record_get (thermal_dbg, cdev_dbg->durations, new_state); + transition = (old_state <<16 ) | new_state;/*
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 181/427 thermal/debugfs: Pass cooling device state to thermal_debug_cdev_add()
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit 31a0fa0019b022024cc082ae292951a596b06f8c ]
If cdev_dt_seq_show() runs before the first state transition of a cooling device, it will not print any state residency information for it, even though it might be reasonably expected to print residency information for the initial state of the cooling device.
For this reason, rearrange the code to get the initial state of a cooling device at the registration time and pass it to thermal_debug_cdev_add(), so that the latter can create a duration record for that state which will allow cdev_dt_seq_show() to print its residency information.
--- drivers/thermal/thermal_core.c | 9 +++++++-- drivers/thermal/thermal_debugfs.c | 12 ++++++++++-- drivers/thermal/thermal_debugfs.h | 4 ++-- 3 files changed, 19 insertions(+), 6 deletions(-)
drivers/thermal/thermal_core.c +7 -2
@@ -898,6 +898,7 @@ __thermal_cooling_device_register(struct device_node *np, {struct thermal_cooling_device *cdev;struct thermal_zone_device *pos =NULL ; +unsigned long current_state;int id, ret; if (!ops || !ops->get_max_state || !ops->get_cur_state ||
@@ -935,6 +936,10 @@ __thermal_cooling_device_register(struct device_node *np,if (ret) goto out_cdev_type; + ret = cdev->ops->get_cur_state (cdev, ¤t_state); +if (ret) + goto out_cdev_type; +thermal_cooling_device_setup_sysfs (cdev); ret =dev_set_name (&cdev->device,"cooling_device%d" , cdev->id);
@@ -948,6 +953,8 @@ __thermal_cooling_device_register(struct device_node *np,return ERR_PTR (ret); } +thermal_debug_cdev_add (cdev, current_state); +/* Add 'this' new cdev to the global cdev list */ mutex_lock (&thermal_list_lock);
@@ -963,8 +970,6 @@ __thermal_cooling_device_register(struct device_node *np,mutex_unlock (&thermal_list_lock); -thermal_debug_cdev_add (cdev); -return cdev; out_cooling_dev:
drivers/thermal/thermal_debugfs.c +10 -2
@@ -468,8 +468,9 @@ void thermal_debug_cdev_state_update(const struct thermal_cooling_device *cdev,* Allocates a cooling device object for debug, initializes the * statistics and create the entries in sysfs. * @cdev: a pointer to a cooling device +* @state: current state of the cooling device */ -void thermal_debug_cdev_add (struct thermal_cooling_device *cdev) +void thermal_debug_cdev_add (struct thermal_cooling_device *cdev,int state) {struct thermal_debugfs *thermal_dbg;struct cdev_debugfs *cdev_dbg;
@@ -486,9 +487,16 @@ void thermal_debug_cdev_add(struct thermal_cooling_device *cdev)INIT_LIST_HEAD (&cdev_dbg->durations[i]); } - cdev_dbg->current_state =0 ; + cdev_dbg->current_state = state; cdev_dbg->timestamp =ktime_get (); +/* +* Create a record for the initial cooling device state, so its +* duration will be printed by cdev_dt_seq_show() as expected if it +* runs before the first state transition. +*/ +thermal_debugfs_cdev_record_get (thermal_dbg, cdev_dbg->durations, state); +debugfs_create_file ("trans_table" ,0400 , thermal_dbg->d_top, thermal_dbg, &tt_fops);
drivers/thermal/thermal_debugfs.h +2 -2
@@ -2,7 +2,7 @@#ifdef CONFIG_THERMAL_DEBUGFS void thermal_debug_init (void ); -void thermal_debug_cdev_add (struct thermal_cooling_device *cdev); +void thermal_debug_cdev_add (struct thermal_cooling_device *cdev,int state);void thermal_debug_cdev_remove (struct thermal_cooling_device *cdev);void thermal_debug_cdev_state_update (const struct thermal_cooling_device *cdev,int state);void thermal_debug_tz_add (struct thermal_zone_device *tz);
@@ -14,7 +14,7 @@ void thermal_debug_tz_trip_down(struct thermal_zone_device *tz,void thermal_debug_update_temp (struct thermal_zone_device *tz);#else static inline void thermal_debug_init (void ) {} -static inline void thermal_debug_cdev_add (struct thermal_cooling_device *cdev) {} +static inline void thermal_debug_cdev_add (struct thermal_cooling_device *cdev,int state) {}static inline void thermal_debug_cdev_remove (struct thermal_cooling_device *cdev) {}static inline void thermal_debug_cdev_state_update (const struct thermal_cooling_device *cdev,int state) {}
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 182/427 pwm: sti: Simplify probe function using devm functions
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit 5bb0b194aeee5d5da6881232f4e9989b35957c25 ]
Instead of of_clk_get_by_name() use devm_clk_get_prepared() which has several advantages:
- Combines getting the clock and a call to clk_prepare(). The latter can be dropped from sti_pwm_probe() accordingly.
- Cares for calling clk_put() which is missing in both probe's error path and the remove function.
- Cares for calling clk_unprepare() which can be dropped from the error paths and the remove function. (Note that not all error path got this right.)
With additionally using devm_pwmchip_add() instead of pwmchip_add() the remove callback can be dropped completely. With it the last user of platform_get_drvdata() goes away and so platform_set_drvdata() can be dropped from the probe function, too.
--- drivers/pwm/pwm-sti.c | 39 +++------------------------------------ 1 file changed, 3 insertions(+), 36 deletions(-)
drivers/pwm/pwm-sti.c +3 -36
@@ -624,32 +624,20 @@ static int sti_pwm_probe(struct platform_device *pdev)return ret;if (cdata->pwm_num_devs) { - pc->pwm_clk =of_clk_get_by_name (dev->of_node,"pwm" ); + pc->pwm_clk =devm_clk_get_prepared (dev,"pwm" );if (IS_ERR (pc->pwm_clk)) {dev_err (dev,"failed to get PWM clock\n" );return PTR_ERR (pc->pwm_clk); } - - ret =clk_prepare (pc->pwm_clk); -if (ret) { -dev_err (dev,"failed to prepare clock\n" ); -return ret; - } }if (cdata->cpt_num_devs) { - pc->cpt_clk =of_clk_get_by_name (dev->of_node,"capture" ); + pc->cpt_clk =devm_clk_get_prepared (dev,"capture" );if (IS_ERR (pc->cpt_clk)) {dev_err (dev,"failed to get PWM capture clock\n" );return PTR_ERR (pc->cpt_clk); } - ret =clk_prepare (pc->cpt_clk); -if (ret) { -dev_err (dev,"failed to prepare clock\n" ); -return ret; - } - cdata->ddata =devm_kzalloc (dev, cdata->cpt_num_devs *sizeof (*cdata->ddata),GFP_KERNEL );if (!cdata->ddata)return -ENOMEM ;
@@ -664,27 +652,7 @@ static int sti_pwm_probe(struct platform_device *pdev)mutex_init (&ddata->lock); } - ret =pwmchip_add (chip); -if (ret <0 ) { -clk_unprepare (pc->pwm_clk); -clk_unprepare (pc->cpt_clk); -return ret; - } - -platform_set_drvdata (pdev, chip); - -return 0 ; -} - -static void sti_pwm_remove (struct platform_device *pdev) -{ -struct pwm_chip *chip =platform_get_drvdata (pdev); -struct sti_pwm_chip *pc =to_sti_pwmchip (chip); - -pwmchip_remove (chip); - -clk_unprepare (pc->pwm_clk); -clk_unprepare (pc->cpt_clk); +return devm_pwmchip_add (dev, chip); }static const struct of_device_id sti_pwm_of_match[] = {
@@ -699,7 +667,6 @@ static struct platform_driver sti_pwm_driver = { .of_match_table = sti_pwm_of_match, }, .probe = sti_pwm_probe, - .remove_new = sti_pwm_remove, };module_platform_driver (sti_pwm_driver);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 183/427 drivers/perf: hisi_pcie: Fix out-of-bound access when valid event group
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junhao He <[email protected]>
[ Upstream commit 77fce82678ea5fd51442e62febec2004f79e041b ]
The perf tool allows users to create event groups through following cmd [1], but the driver does not check whether the array index is out of bounds when writing data to the event_group array. If the number of events in an event_group is greater than HISI_PCIE_MAX_COUNTERS, the memory write overflow of event_group array occurs.
Add array index check to fix the possible array out of bounds violation, and return directly when write new events are written to array bounds.
There are 9 different events in an event_group.
[1] perf stat -e '{pmu/event1/, ... ,pmu/event9/}'
--- drivers/perf/hisilicon/hisi_pcie_pmu.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/perf/hisilicon/hisi_pcie_pmu.c +13 -1
@@ -350,15 +350,27 @@ static bool hisi_pcie_pmu_validate_event_group(struct perf_event *event)return false;for (num =0 ; num < counters; num++) { +/* +* If we find a related event, then it's a valid group +* since we don't need to allocate a new counter for it. +*/ if (hisi_pcie_pmu_cmp_event (event_group[num], sibling))break ; } +/* +* Otherwise it's a new event but if there's no available counter, +* fail the check since we cannot schedule all the events in +* the group simultaneously. +*/ +if (num ==HISI_PCIE_MAX_COUNTERS ) +return false; +if (num == counters) event_group[counters++] = sibling; } -return counters <=HISI_PCIE_MAX_COUNTERS ; +return true; }static int hisi_pcie_pmu_event_init (struct perf_event *event)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 184/427 drivers/perf: hisi: hns3: Fix out-of-bound access when valid event group
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junhao He <[email protected]>
[ Upstream commit 81bdd60a3d1d3b05e6cc6674845afb1694dd3a0e ]
The perf tool allows users to create event groups through following cmd [1], but the driver does not check whether the array index is out of bounds when writing data to the event_group array. If the number of events in an event_group is greater than HNS3_PMU_MAX_HW_EVENTS, the memory write overflow of event_group array occurs.
Add array index check to fix the possible array out of bounds violation, and return directly when write new events are written to array bounds.
There are 9 different events in an event_group.
[1] perf stat -e '{pmu/event1/, ... ,pmu/event9/}
--- drivers/perf/hisilicon/hns3_pmu.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/perf/hisilicon/hns3_pmu.c +13 -1
@@ -1085,15 +1085,27 @@ static bool hns3_pmu_validate_event_group(struct perf_event *event)return false;for (num =0 ; num < counters; num++) { +/* +* If we find a related event, then it's a valid group +* since we don't need to allocate a new counter for it. +*/ if (hns3_pmu_cmp_event (event_group[num], sibling))break ; } +/* +* Otherwise it's a new event but if there's no available counter, +* fail the check since we cannot schedule all the events in +* the group simultaneously. +*/ +if (num ==HNS3_PMU_MAX_HW_EVENTS ) +return false; +if (num == counters) event_group[counters++] = sibling; } -return counters <=HNS3_PMU_MAX_HW_EVENTS ; +return true; }static u32 hns3_pmu_get_filter_condition (struct perf_event *event)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 185/427 drivers/perf: hisi: hns3: Actually use devm_add_action_or_reset()
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hao Chen <[email protected]>
[ Upstream commit 582c1aeee0a9e73010cf1c4cef338709860deeb0 ]
pci_alloc_irq_vectors() allocates an irq vector. When devm_add_action() fails, the irq vector is not freed, which leads to a memory leak.
Replace the devm_add_action with devm_add_action_or_reset to ensure the irq vector can be destroyed when it fails.
--- drivers/perf/hisilicon/hns3_pmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/perf/hisilicon/hns3_pmu.c +1 -1
@@ -1527,7 +1527,7 @@ static int hns3_pmu_irq_register(struct pci_dev *pdev,return ret; } - ret =devm_add_action (&pdev->dev, hns3_pmu_free_irq, pdev); + ret =devm_add_action_or_reset (&pdev->dev, hns3_pmu_free_irq, pdev);if (ret) {pci_err (pdev,"failed to add free irq action, ret = %d.\n" , ret);return ret;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 186/427 net: give more chances to rcu in netdev_wait_allrefs_any()
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit cd42ba1c8ac9deb9032add6adf491110e7442040 ]
This came while reviewing commit c4e86b4363ac ("net: add two more call_rcu_hurry()").
Paolo asked if adding one synchronize_rcu() would help.
While synchronize_rcu() does not help, making sure to call rcu_barrier() before msleep(wait) is definitely helping to make sure lazy call_rcu() are completed.
Instead of waiting ~100 seconds in my tests, the ref_tracker splats occurs one time only, and netdev_wait_allrefs_any() latency is reduced to the strict minimum.
Ideally we should audit our call_rcu() users to make sure no refcount (or cascading call_rcu()) is held too long, because rcu_barrier() is quite expensive.
--- net/core/dev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/core/dev.c +2 -1
@@ -10488,8 +10488,9 @@ static struct net_device *netdev_wait_allrefs_any(struct list_head *list) rebroadcast_time = jiffies; } +rcu_barrier (); +if (!wait) { -rcu_barrier (); wait =WAIT_REFS_MIN_MSECS ; }else {msleep (wait);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 187/427 macintosh/via-macii: Fix "BUG: sleeping function called from invalid context"
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Finn Thain <[email protected]>
[ Upstream commit d301a71c76ee4c384b4e03cdc320a55f5cf1df05 ]
The via-macii ADB driver calls request_irq() after disabling hard interrupts. But disabling interrupts isn't necessary here because the VIA shift register interrupt was masked during VIA1 initialization.
--- drivers/macintosh/via-macii.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/macintosh/via-macii.c +3 -8
@@ -140,24 +140,19 @@ static int macii_probe(void)/* Initialize the driver */ static int macii_init (void ) { -unsigned long flags;int err; -local_irq_save (flags); - err =macii_init_via ();if (err) - goto out; +return err; err =request_irq (IRQ_MAC_ADB , macii_interrupt,0 ,"ADB" , macii_interrupt);if (err) - goto out; +return err; macii_state = idle; -out: -local_irq_restore (flags); -return err; +return 0 ; }/* initialize the hardware */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 188/427 wifi: carl9170: add a proper sanity check for endpoints
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikita Zhandarovich <[email protected]>
[ Upstream commit b6dd09b3dac89b45d1ea3e3bd035a3859c0369a0 ]
Syzkaller reports [1] hitting a warning which is caused by presence of a wrong endpoint type at the URB sumbitting stage. While there was a check for a specific 4th endpoint, since it can switch types between bulk and interrupt, other endpoints are trusted implicitly. Similar warning is triggered in a couple of other syzbot issues [2].
Fix the issue by doing a comprehensive check of all endpoints taking into account difference between high- and full-speed configuration.
[1] Syzkaller report:
...
WARNING: CPU: 0 PID: 4721 at drivers/usb/core/urb.c:504 usb_submit_urb+0xed6/0x1880 drivers/usb/core/urb.c:504 ... Call Trace: <TASK> carl9170_usb_send_rx_irq_urb+0x273/0x340 drivers/net/wireless/ath/carl9170/usb.c:504 carl9170_usb_init_device drivers/net/wireless/ath/carl9170/usb.c:939 [inline] carl9170_usb_firmware_finish drivers/net/wireless/ath/carl9170/usb.c:999 [inline] carl9170_usb_firmware_step2+0x175/0x240 drivers/net/wireless/ath/carl9170/usb.c:1028 request_firmware_work_func+0x130/0x240 drivers/base/firmware_loader/main.c:1107 process_one_work+0x9bf/0x1710 kernel/workqueue.c:2289 worker_thread+0x669/0x1090 kernel/workqueue.c:2436 kthread+0x2e8/0x3a0 kernel/kthread.c:376 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308 </TASK>
[2] Related syzkaller crashes:
--- drivers/net/wireless/ath/carl9170/usb.c | 32 +++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
drivers/net/wireless/ath/carl9170/usb.c +32 -0
@@ -1069,6 +1069,38 @@ static int carl9170_usb_probe(struct usb_interface *intf, ar->usb_ep_cmd_is_bulk = true; } +/* Verify that all expected endpoints are present */ +if (ar->usb_ep_cmd_is_bulk) { +u8 bulk_ep_addr[] = { +AR9170_USB_EP_RX |USB_DIR_IN , +AR9170_USB_EP_TX |USB_DIR_OUT , +AR9170_USB_EP_CMD |USB_DIR_OUT , +0 }; +u8 int_ep_addr[] = { +AR9170_USB_EP_IRQ |USB_DIR_IN , +0 }; +if (!usb_check_bulk_endpoints (intf, bulk_ep_addr) || + !usb_check_int_endpoints (intf, int_ep_addr)) + err = -ENODEV ; + }else { +u8 bulk_ep_addr[] = { +AR9170_USB_EP_RX |USB_DIR_IN , +AR9170_USB_EP_TX |USB_DIR_OUT , +0 }; +u8 int_ep_addr[] = { +AR9170_USB_EP_IRQ |USB_DIR_IN , +AR9170_USB_EP_CMD |USB_DIR_OUT , +0 }; +if (!usb_check_bulk_endpoints (intf, bulk_ep_addr) || + !usb_check_int_endpoints (intf, int_ep_addr)) + err = -ENODEV ; + } + +if (err) { +carl9170_free (ar); +return err; + } +usb_set_intfdata (intf, ar);SET_IEEE80211_DEV (ar->hw, &intf->dev);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 189/427 bpf: Fix verifier assumptions about socket->sk
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <[email protected]>
[ Upstream commit 0db63c0b86e981a1e97d2596d64ceceba1a5470e ]
The verifier assumes that 'sk' field in 'struct socket' is valid and non-NULL when 'socket' pointer itself is trusted and non-NULL. That may not be the case when socket was just created and passed to LSM socket_accept hook.
Fix this verifier assumption and adjust tests.
--- kernel/bpf/verifier.c | 23 +++++++++++++++---- .../bpf/progs/bench_local_storage_create.c | 5 ++-- .../selftests/bpf/progs/local_storage.c | 20 ++++++++-------- .../testing/selftests/bpf/progs/lsm_cgroup.c | 8 +++++-- 4 files changed, 38 insertions(+), 18 deletions(-)
kernel/bpf/verifier.c +18 -5
@@ -2359,6 +2359,8 @@ static void mark_btf_ld_reg(struct bpf_verifier_env *env, regs[regno].type =PTR_TO_BTF_ID | flag; regs[regno].btf = btf; regs[regno].btf_id = btf_id; +if (type_may_be_null (flag)) + regs[regno].id = ++env->id_gen; }#define DEF_NOT_SUBREG (0)
@@ -5388,8 +5390,6 @@ static int check_map_kptr_access(struct bpf_verifier_env *env, u32 regno,*/ mark_btf_ld_reg (env,cur_regs (env), value_regno,PTR_TO_BTF_ID , kptr_field->kptr.btf, kptr_field->kptr.btf_id,btf_ld_kptr_type (env, kptr_field)); -/* For mark_ptr_or_null_reg */ - val_reg->id = ++env->id_gen; }else if (class ==BPF_STX ) { val_reg =reg_state (env, value_regno); if (!register_is_null(val_reg) &&
@@ -5707,7 +5707,8 @@ static bool is_trusted_reg(const struct bpf_reg_state *reg)return true;/* Types listed in the reg2btf_ids are always trusted */ -if (reg2btf_ids[base_type (reg->type)]) +if (reg2btf_ids[base_type (reg->type)] && + !bpf_type_has_unsafe_modifiers (reg->type))return true;/* If a register is not referenced, it is trusted if it has the
@@ -6327,6 +6328,7 @@ static int bpf_map_direct_read(struct bpf_map *map, int off, int size, u64 *val,#define BTF_TYPE_SAFE_RCU (__type) __PASTE(__type, __safe_rcu)#define BTF_TYPE_SAFE_RCU_OR_NULL (__type) __PASTE(__type, __safe_rcu_or_null)#define BTF_TYPE_SAFE_TRUSTED (__type) __PASTE(__type, __safe_trusted) +#define BTF_TYPE_SAFE_TRUSTED_OR_NULL (__type) __PASTE(__type, __safe_trusted_or_null)/* * Allow list few fields as RCU trusted or full trusted.
@@ -6390,7 +6392,7 @@ BTF_TYPE_SAFE_TRUSTED(struct dentry) {struct inode *d_inode; }; -BTF_TYPE_SAFE_TRUSTED(struct socket) { +BTF_TYPE_SAFE_TRUSTED_OR_NULL(struct socket) {struct sock *sk; };
@@ -6425,11 +6427,20 @@ static bool type_is_trusted(struct bpf_verifier_env *env,BTF_TYPE_EMIT (BTF_TYPE_SAFE_TRUSTED(struct linux_binprm ));BTF_TYPE_EMIT (BTF_TYPE_SAFE_TRUSTED(struct file ));BTF_TYPE_EMIT (BTF_TYPE_SAFE_TRUSTED(struct dentry )); -BTF_TYPE_EMIT (BTF_TYPE_SAFE_TRUSTED(struct socket ));return btf_nested_type_is_trusted (&env->log, reg, field_name, btf_id,"__safe_trusted" ); } +static bool type_is_trusted_or_null (struct bpf_verifier_env *env, +struct bpf_reg_state *reg, +const char *field_name,u32 btf_id) +{ +BTF_TYPE_EMIT (BTF_TYPE_SAFE_TRUSTED_OR_NULL(struct socket )); + +return btf_nested_type_is_trusted (&env->log, reg, field_name, btf_id, +"__safe_trusted_or_null" ); +} + static int check_ptr_to_btf_access(struct bpf_verifier_env *env, struct bpf_reg_state *regs, int regno, int off, int size,
@@ -6538,6 +6549,8 @@ static int check_ptr_to_btf_access(struct bpf_verifier_env *env,*/ if (type_is_trusted (env, reg, field_name, btf_id)) { flag |=PTR_TRUSTED ; + }else if (type_is_trusted_or_null (env, reg, field_name, btf_id)) { + flag |=PTR_TRUSTED |PTR_MAYBE_NULL ; }else if (in_rcu_cs (env) && !type_may_be_null (reg->type)) {if (type_is_rcu (env, reg, field_name, btf_id)) {/* ignore __rcu tag and mark it MEM_RCU */
tools/testing/selftests/bpf/progs/bench_local_storage_create.c +3 -2
@@ -61,14 +61,15 @@ SEC("lsm.s/socket_post_create")int BPF_PROG (socket_post_create ,struct socket *sock,int family,int type,int protocol,int kern) { +struct sock *sk = sock->sk;struct storage *stg;__u32 pid; pid =bpf_get_current_pid_tgid () >>32 ; -if (pid != bench_pid) +if (pid != bench_pid || !sk)return 0 ; - stg =bpf_sk_storage_get (&sk_storage_map, sock->sk,NULL , + stg =bpf_sk_storage_get (&sk_storage_map, sk,NULL ,BPF_LOCAL_STORAGE_GET_F_CREATE );if (stg)
tools/testing/selftests/bpf/progs/local_storage.c +11 -9
@@ -140,11 +140,12 @@ int BPF_PROG(socket_bind, struct socket *sock, struct sockaddr *address, {__u32 pid =bpf_get_current_pid_tgid () >>32 ;struct local_storage *storage; +struct sock *sk = sock->sk; -if (pid != monitored_pid) +if (pid != monitored_pid || !sk)return 0 ; - storage =bpf_sk_storage_get (&sk_storage_map, sock->sk,0 ,0 ); + storage =bpf_sk_storage_get (&sk_storage_map, sk,0 ,0 );if (!storage)return 0 ;
@@ -155,24 +156,24 @@ int BPF_PROG(socket_bind, struct socket *sock, struct sockaddr *address,/* This tests that we can associate multiple elements * with the local storage. */ - storage =bpf_sk_storage_get (&sk_storage_map2, sock->sk,0 , + storage =bpf_sk_storage_get (&sk_storage_map2, sk,0 ,BPF_LOCAL_STORAGE_GET_F_CREATE );if (!storage)return 0 ; -if (bpf_sk_storage_delete (&sk_storage_map2, sock->sk)) +if (bpf_sk_storage_delete (&sk_storage_map2, sk))return 0 ; - storage =bpf_sk_storage_get (&sk_storage_map2, sock->sk,0 , + storage =bpf_sk_storage_get (&sk_storage_map2, sk,0 ,BPF_LOCAL_STORAGE_GET_F_CREATE );if (!storage)return 0 ; -if (bpf_sk_storage_delete (&sk_storage_map, sock->sk)) +if (bpf_sk_storage_delete (&sk_storage_map, sk))return 0 ;/* Ensure that the sk_storage_map is disconnected from the storage. */ -if (!sock->sk->sk_bpf_storage || sock->sk->sk_bpf_storage->smap) +if (!sk->sk_bpf_storage || sk->sk_bpf_storage->smap)return 0 ; sk_storage_result =0 ;
@@ -185,11 +186,12 @@ int BPF_PROG(socket_post_create, struct socket *sock, int family, int type, {__u32 pid =bpf_get_current_pid_tgid () >>32 ;struct local_storage *storage; +struct sock *sk = sock->sk; -if (pid != monitored_pid) +if (pid != monitored_pid || !sk)return 0 ; - storage =bpf_sk_storage_get (&sk_storage_map, sock->sk,0 , + storage =bpf_sk_storage_get (&sk_storage_map, sk,0 ,BPF_LOCAL_STORAGE_GET_F_CREATE );if (!storage)return 0 ;
tools/testing/selftests/bpf/progs/lsm_cgroup.c +6 -2
@@ -103,11 +103,15 @@ static __always_inline int real_bind(struct socket *sock, int addrlen) {struct sockaddr_ll sa = {}; +struct sock *sk = sock->sk; -if (sock->sk->__sk_common.skc_family !=AF_PACKET ) +if (!sk) +return 1 ; + +if (sk->__sk_common.skc_family !=AF_PACKET )return 1 ; -if (sock->sk->sk_kern_sock) +if (sk->sk_kern_sock)return 1 ;bpf_probe_read_kernel (&sa,sizeof (sa), address);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 190/427 selftests/bpf: Run cgroup1_hierarchy test in own mount namespace
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Viktor Malik <[email protected]>
[ Upstream commit 19468ed51488dae19254e8a67c75d583b05fa5e3 ]
The cgroup1_hierarchy test uses setup_classid_environment to setup cgroupv1 environment. The problem is that the environment is set in /sys/fs/cgroup and therefore, if not run under an own mount namespace, effectively deletes all system cgroups:
$ ls /sys/fs/cgroup | wc -l
27
$ sudo ./test_progs -t cgroup1_hierarchy
#41/1 cgroup1_hierarchy/test_cgroup1_hierarchy:OK
#41/2 cgroup1_hierarchy/test_root_cgid:OK
#41/3 cgroup1_hierarchy/test_invalid_level:OK
#41/4 cgroup1_hierarchy/test_invalid_cgid:OK
#41/5 cgroup1_hierarchy/test_invalid_hid:OK
#41/6 cgroup1_hierarchy/test_invalid_cgrp_name:OK
#41/7 cgroup1_hierarchy/test_invalid_cgrp_name2:OK
#41/8 cgroup1_hierarchy/test_sleepable_prog:OK
#41 cgroup1_hierarchy:OK
Summary: 1/8 PASSED, 0 SKIPPED, 0 FAILED
$ ls /sys/fs/cgroup | wc -l
1To avoid this, run setup_cgroup_environment first which will create an own mount namespace. This only affects the cgroupv1_hierarchy test as all other cgroup1 test progs already run setup_cgroup_environment prior to running setup_classid_environment.
Also add a comment to the header of setup_classid_environment to warn against this invalid usage in future.
--- tools/testing/selftests/bpf/cgroup_helpers.c | 3 +++ tools/testing/selftests/bpf/prog_tests/cgroup1_hierarchy.c | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-)
tools/testing/selftests/bpf/cgroup_helpers.c +3 -0
@@ -508,6 +508,9 @@ int cgroup_setup_and_join(const char *path) {/** * setup_classid_environment() - Setup the cgroupv1 net_cls environment * +* This function should only be called in a custom mount namespace, e.g. +* created by running setup_cgroup_environment. +* * After calling this function, cleanup_classid_environment should be called * once testing is complete. *
tools/testing/selftests/bpf/prog_tests/cgroup1_hierarchy.c +6 -1
@@ -87,9 +87,12 @@ void test_cgroup1_hierarchy(void) goto destroy;/* Setup cgroup1 hierarchy */ + err =setup_cgroup_environment (); +if (!ASSERT_OK (err,"setup_cgroup_environment" )) + goto destroy; err =setup_classid_environment ();if (!ASSERT_OK (err,"setup_classid_environment" )) - goto destroy; + goto cleanup_cgroup; err =join_classid ();if (!ASSERT_OK (err,"join_cgroup1" ))
@@ -153,6 +156,8 @@ void test_cgroup1_hierarchy(void) cleanup:cleanup_classid_environment (); +cleanup_cgroup: +cleanup_cgroup_environment (); destroy:test_cgroup1_hierarchy__destroy (skel); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 191/427 wifi: ar5523: enable proper endpoint verification
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikita Zhandarovich <[email protected]>
[ Upstream commit e120b6388d7d88635d67dcae6483f39c37111850 ]
Syzkaller reports [1] hitting a warning about an endpoint in use not having an expected type to it.
Fix the issue by checking for the existence of all proper endpoints with their according types intact.
Sadly, this patch has not been tested on real hardware.
[1] Syzkaller report:
------------[ cut here ]------------ usb 1-1: BOGUS urb xfer, pipe 3 != type 1 WARNING: CPU: 0 PID: 3643 at drivers/usb/core/urb.c:504 usb_submit_urb+0xed6/0x1880 drivers/usb/core/urb.c:504 ... Call Trace: <TASK> ar5523_cmd+0x41b/0x780 drivers/net/wireless/ath/ar5523/ar5523.c:275 ar5523_cmd_read drivers/net/wireless/ath/ar5523/ar5523.c:302 [inline] ar5523_host_available drivers/net/wireless/ath/ar5523/ar5523.c:1376 [inline] ar5523_probe+0x14b0/0x1d10 drivers/net/wireless/ath/ar5523/ar5523.c:1655 usb_probe_interface+0x30f/0x7f0 drivers/usb/core/driver.c:396 call_driver_probe drivers/base/dd.c:560 [inline] really_probe+0x249/0xb90 drivers/base/dd.c:639 __driver_probe_device+0x1df/0x4d0 drivers/base/dd.c:778 driver_probe_device+0x4c/0x1a0 drivers/base/dd.c:808 __device_attach_driver+0x1d4/0x2e0 drivers/base/dd.c:936 bus_for_each_drv+0x163/0x1e0 drivers/base/bus.c:427 __device_attach+0x1e4/0x530 drivers/base/dd.c:1008 bus_probe_device+0x1e8/0x2a0 drivers/base/bus.c:487 device_add+0xbd9/0x1e90 drivers/base/core.c:3517 usb_set_configuration+0x101d/0x1900 drivers/usb/core/message.c:2170 usb_generic_driver_probe+0xbe/0x100 drivers/usb/core/generic.c:238 usb_probe_device+0xd8/0x2c0 drivers/usb/core/driver.c:293 call_driver_probe drivers/base/dd.c:560 [inline] really_probe+0x249/0xb90 drivers/base/dd.c:639 __driver_probe_device+0x1df/0x4d0 drivers/base/dd.c:778 driver_probe_device+0x4c/0x1a0 drivers/base/dd.c:808 __device_attach_driver+0x1d4/0x2e0 drivers/base/dd.c:936 bus_for_each_drv+0x163/0x1e0 drivers/base/bus.c:427 __device_attach+0x1e4/0x530 drivers/base/dd.c:1008 bus_probe_device+0x1e8/0x2a0 drivers/base/bus.c:487 device_add+0xbd9/0x1e90 drivers/base/core.c:3517 usb_new_device.cold+0x685/0x10ad drivers/usb/core/hub.c:2573 hub_port_connect drivers/usb/core/hub.c:5353 [inline] hub_port_connect_change drivers/usb/core/hub.c:5497 [inline] port_event drivers/usb/core/hub.c:5653 [inline] hub_event+0x26cb/0x45d0 drivers/usb/core/hub.c:5735 process_one_work+0x9bf/0x1710 kernel/workqueue.c:2289 worker_thread+0x669/0x1090 kernel/workqueue.c:2436 kthread+0x2e8/0x3a0 kernel/kthread.c:376 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306 </TASK>
--- drivers/net/wireless/ath/ar5523/ar5523.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/net/wireless/ath/ar5523/ar5523.c +14 -0
@@ -1594,6 +1594,20 @@ static int ar5523_probe(struct usb_interface *intf,struct ar5523 *ar;int error = -ENOMEM ; +static const u8 bulk_ep_addr[] = { +AR5523_CMD_TX_PIPE |USB_DIR_OUT , +AR5523_DATA_TX_PIPE |USB_DIR_OUT , +AR5523_CMD_RX_PIPE |USB_DIR_IN , +AR5523_DATA_RX_PIPE |USB_DIR_IN , +0 }; + +if (!usb_check_bulk_endpoints (intf, bulk_ep_addr)) { +dev_err (&dev->dev, +"Could not find all expected endpoints\n" ); + error = -ENODEV ; + goto out; + } +/* * Load firmware if the device requires it. This will return * -ENXIO on success and we'll get called back afer the usb
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 192/427 pwm: meson: Add check for error from clk_round_rate()
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: George Stark <[email protected]>
[ Upstream commit 3e551115aee079931b82e1ec78c05f3d5033473f ]
clk_round_rate() can return not only zero if requested frequency can not be provided but also negative error code so add check for it too.
Also change type of variable holding clk_round_rate() result from unsigned long to long. It's safe due to clk_round_rate() returns long.
--- drivers/pwm/pwm-meson.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/pwm/pwm-meson.c +6 -5
@@ -147,7 +147,7 @@ static int meson_pwm_calc(struct pwm_chip *chip, struct pwm_device *pwm,struct meson_pwm *meson =to_meson_pwm (chip);struct meson_pwm_channel *channel = &meson->channels[pwm->hwpwm];unsigned int cnt, duty_cnt; -unsigned long fin_freq; +long fin_freq;u64 duty, period, freq; duty = state->duty_cycle;
@@ -167,12 +167,13 @@ static int meson_pwm_calc(struct pwm_chip *chip, struct pwm_device *pwm, freq =ULONG_MAX ; fin_freq =clk_round_rate (channel->clk, freq); -if (fin_freq ==0 ) { -dev_err (pwmchip_parent (chip),"invalid source clock frequency\n" ); -return -EINVAL ; +if (fin_freq <=0 ) { +dev_err (pwmchip_parent (chip), +"invalid source clock frequency %llu\n" , freq); +return fin_freq ? fin_freq : -EINVAL ; } -dev_dbg (pwmchip_parent (chip),"fin_freq: %lu Hz\n" , fin_freq); +dev_dbg (pwmchip_parent (chip),"fin_freq: %ld Hz\n" , fin_freq); cnt =div_u64 (fin_freq * period,NSEC_PER_SEC );if (cnt >0xffff ) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 193/427 pwm: meson: Use mul_u64_u64_div_u64() for frequency calculating
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: George Stark <[email protected]>
[ Upstream commit 32c44e1fa921aebf8a5ef9f778534a30aab39313 ]
While calculating frequency for the given period u64 numbers are multiplied before division what can lead to overflow in theory so use secure mul_u64_u64_div_u64() which handles overflow correctly.
--- drivers/pwm/pwm-meson.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pwm/pwm-meson.c +2 -2
@@ -175,7 +175,7 @@ static int meson_pwm_calc(struct pwm_chip *chip, struct pwm_device *pwm,dev_dbg (pwmchip_parent (chip),"fin_freq: %ld Hz\n" , fin_freq); - cnt =div_u64 (fin_freq * period,NSEC_PER_SEC ); + cnt =mul_u64_u64_div_u64 (fin_freq, period,NSEC_PER_SEC );if (cnt >0xffff ) {dev_err (pwmchip_parent (chip),"unable to get period cnt\n" );return -EINVAL ;
@@ -190,7 +190,7 @@ static int meson_pwm_calc(struct pwm_chip *chip, struct pwm_device *pwm, channel->hi =0 ; channel->lo = cnt; }else { - duty_cnt =div_u64 (fin_freq * duty,NSEC_PER_SEC ); + duty_cnt =mul_u64_u64_div_u64 (fin_freq, duty,NSEC_PER_SEC );dev_dbg (pwmchip_parent (chip),"duty=%llu duty_cnt=%u\n" , duty, duty_cnt);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 194/427 bpf: Add BPF_PROG_TYPE_CGROUP_SKB attach type enforcement in BPF_LINK_CREATE
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanislav Fomichev <[email protected]>
[ Upstream commit 543576ec15b17c0c93301ac8297333c7b6e84ac7 ]
bpf_prog_attach uses attach_type_to_prog_type to enforce proper attach type for BPF_PROG_TYPE_CGROUP_SKB. link_create uses bpf_prog_get and relies on bpf_prog_attach_check_attach_type to properly verify prog_type <> attach_type association.
Add missing attach_type enforcement for the link_create case. Otherwise, it's currently possible to attach cgroup_skb prog types to other cgroup hooks.
--- kernel/bpf/syscall.c | 5 +++++ 1 file changed, 5 insertions(+)
kernel/bpf/syscall.c +5 -0
@@ -3985,6 +3985,11 @@ static int bpf_prog_attach_check_attach_type(const struct bpf_prog *prog,* check permissions at attach time. */ return -EPERM ; + + ptype =attach_type_to_prog_type (attach_type); +if (prog->type != ptype) +return -EINVAL ; +return prog->enforce_expected_attach_type && prog->expected_attach_type != attach_type ? -EINVAL :0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 195/427 sh: kprobes: Merge arch_copy_kprobe() into arch_prepare_kprobe()
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <[email protected]>
[ Upstream commit 1422ae080b66134fe192082d9b721ab7bd93fcc5 ]
arch/sh/kernel/kprobes.c:52:16: warning: no previous prototype for 'arch_copy_kprobe' [-Wmissing-prototypes]
Although SH kprobes support was only merged in v2.6.28, it missed the earlier removal of the arch_copy_kprobe() callback in v2.6.15.
Based on the powerpc part of commit 49a2a1b83ba6fa40 ("[PATCH] kprobes:
changed from using spinlock to mutex").
--- arch/sh/kernel/kprobes.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
arch/sh/kernel/kprobes.c +1 -6
@@ -44,17 +44,12 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)if (OPCODE_RTE (opcode))return -EFAULT ;/* Bad breakpoint */ +memcpy (p->ainsn.insn, p->addr,MAX_INSN_SIZE *sizeof (kprobe_opcode_t)); p->opcode = opcode;return 0 ; } -void __kprobes arch_copy_kprobe (struct kprobe *p) -{ -memcpy (p->ainsn.insn, p->addr,MAX_INSN_SIZE *sizeof (kprobe_opcode_t)); - p->opcode = *p->addr; -} -void __kprobes arch_arm_kprobe (struct kprobe *p) { *p->addr =BREAKPOINT_INSTRUCTION ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 196/427 Revert "sh: Handle calling csum_partial with misaligned data"
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
[ Upstream commit b5319c96292ff877f6b58d349acf0a9dc8d3b454 ]
This reverts commit cadc4e1a2b4d20d0cc0e81f2c6ba0588775e54e5.
Commit cadc4e1a2b4d ("sh: Handle calling csum_partial with misaligned data") causes bad checksum calculations on unaligned data. Reverting it fixes the problem.
# Subtest: checksum
# module: checksum_kunit
1..5
# test_csum_fixed_random_inputs: ASSERTION FAILED at lib/checksum_kunit.c:500 Expected ( u64)result == ( u64)expec, but
( u64)result == 53378 (0xd082)
( u64)expec == 33488 (0x82d0)
# test_csum_fixed_random_inputs: pass:0 fail:1 skip:0 total:1 not ok 1 test_csum_fixed_random_inputs
# test_csum_all_carry_inputs: ASSERTION FAILED at lib/checksum_kunit.c:525 Expected ( u64)result == ( u64)expec, but
( u64)result == 65281 (0xff01)
( u64)expec == 65280 (0xff00)
# test_csum_all_carry_inputs: pass:0 fail:1 skip:0 total:1
not ok 2 test_csum_all_carry_inputs
# test_csum_no_carry_inputs: ASSERTION FAILED at lib/checksum_kunit.c:573 Expected ( u64)result == ( u64)expec, but
( u64)result == 65535 (0xffff)
( u64)expec == 65534 (0xfffe)
# test_csum_no_carry_inputs: pass:0 fail:1 skip:0 total:1
not ok 3 test_csum_no_carry_inputs
# test_ip_fast_csum: pass:1 fail:0 skip:0 total:1
ok 4 test_ip_fast_csum
# test_csum_ipv6_magic: pass:1 fail:0 skip:0 total:1
ok 5 test_csum_ipv6_magic
# checksum: pass:2 fail:3 skip:0 total:5
# Totals: pass:2 fail:3 skip:0 total:5
not ok 22 checksum
--- arch/sh/lib/checksum.S | 67 ++++++++++++------------------------------ 1 file changed, 18 insertions(+), 49 deletions(-)
arch/sh/lib/checksum.S +18 -49
@@ -33,7 +33,8 @@ */ /* - * asmlinkage __wsum csum_partial(const void *buf, int len, __wsum sum); + * unsigned int csum_partial(const unsigned char *buf, int len, + * unsigned int sum); */ .text
@@ -45,31 +46,11 @@ ENTRY(csum_partial) * Fortunately, it is easy to convert 2-byte alignment to 4-byte * alignment for the unrolled loop. */ + mov r5, r1 mov r4, r0 - tst #3, r0 ! Check alignment. - bt/s 2f ! Jump if alignment is ok. - mov r4, r7 ! Keep a copy to check for alignment + tst #2, r0 ! Check alignment. + bt 2f ! Jump if alignment is ok. ! - tst #1, r0 ! Check alignment. - bt 21f ! Jump if alignment is boundary of 2bytes. - - ! buf is odd - tst r5, r5 - add #-1, r5 - bt 9f - mov.b @r4+, r0 - extu.b r0, r0 - addc r0, r6 ! t=0 from previous tst - mov r6, r0 - shll8 r6 - shlr16 r0 - shlr8 r0 - or r0, r6 - mov r4, r0 - tst #2, r0 - bt 2f -21: - ! buf is 2 byte aligned (len could be 0) add #-2, r5 ! Alignment uses up two bytes. cmp/pz r5 ! bt/s 1f ! Jump if we had at least two bytes.
@@ -77,17 +58,16 @@ ENTRY(csum_partial) bra 6f add #2, r5 ! r5 was < 2. Deal with it. 1: + mov r5, r1 ! Save new len for later use. mov.w @r4+, r0 extu.w r0, r0 addc r0, r6 bf 2f add #1, r6 2: - ! buf is 4 byte aligned (len could be 0) - mov r5, r1 mov #-5, r0 - shld r0, r1 - tst r1, r1 + shld r0, r5 + tst r5, r5 bt/s 4f ! if it's =0, go to 4f clrt .align 2
@@ -109,31 +89,30 @@ ENTRY(csum_partial) addc r0, r6 addc r2, r6 movt r0 - dt r1 + dt r5 bf/s 3b cmp/eq #1, r0 - ! here, we know r1==0 - addc r1, r6 ! add carry to r6 + ! here, we know r5==0 + addc r5, r6 ! add carry to r6 4: - mov r5, r0 + mov r1, r0 and #0x1c, r0 tst r0, r0 - bt 6f - ! 4 bytes or more remaining - mov r0, r1 - shlr2 r1 + bt/s 6f + mov r0, r5 + shlr2 r5 mov #0, r2 5: addc r2, r6 mov.l @r4+, r2 movt r0 - dt r1 + dt r5 bf/s 5b cmp/eq #1, r0 addc r2, r6 - addc r1, r6 ! r1==0 here, so it means add carry-bit + addc r5, r6 ! r5==0 here, so it means add carry-bit 6: - ! 3 bytes or less remaining + mov r1, r5 mov #3, r0 and r0, r5 tst r5, r5
@@ -159,16 +138,6 @@ ENTRY(csum_partial) mov #0, r0 addc r0, r6 9: - ! Check if the buffer was misaligned, if so realign sum - mov r7, r0 - tst #1, r0 - bt 10f - mov r6, r0 - shll8 r6 - shlr16 r0 - shlr8 r0 - or r0, r6 -10: rts mov r6, r0
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 197/427 wifi: mt76: mt7603: fix tx queue of loopback packets
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Fietkau <[email protected]>
[ Upstream commit b473c0e47f04d3b4ee9d05d2e79234134aad14d5 ]
Use the correct WMM AC queue instead of the MGMT one to fix potential issues with aggregation sequence number tracking. Drop non-bufferable packets.
--- .../net/wireless/mediatek/mt76/mt7603/dma.c | 46 +++++++++++++------ 1 file changed, 32 insertions(+), 14 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7603/dma.c +32 -14
@@ -4,6 +4,13 @@#include "mac.h" #include "../dma.h" +static const u8 wmm_queue_map[] = { + [IEEE80211_AC_BK ] =0 , + [IEEE80211_AC_BE ] =1 , + [IEEE80211_AC_VI ] =2 , + [IEEE80211_AC_VO ] =3 , +}; +static void mt7603_rx_loopback_skb (struct mt7603_dev *dev,struct sk_buff *skb) {
@@ -22,10 +29,10 @@ mt7603_rx_loopback_skb(struct mt7603_dev *dev, struct sk_buff *skb)struct ieee80211_sta *sta;struct mt7603_sta *msta;struct mt76_wcid *wcid; +u8 tid =0 , hwq =0 ;void *priv;int idx;u32 val; -u8 tid =0 ;if (skb->len <MT_TXD_SIZE +sizeof (struct ieee80211_hdr )) goto free;
@@ -42,19 +49,36 @@ mt7603_rx_loopback_skb(struct mt7603_dev *dev, struct sk_buff *skb) goto free; priv = msta = container_of(wcid, struct mt7603_sta, wcid); - val =le32_to_cpu (txd[0 ]); - val &= ~(MT_TXD0_P_IDX |MT_TXD0_Q_IDX ); - val |=FIELD_PREP (MT_TXD0_Q_IDX ,MT_TX_HW_QUEUE_MGMT ); - txd[0 ] =cpu_to_le32 (val); sta = container_of(priv, struct ieee80211_sta, drv_priv); hdr = (struct ieee80211_hdr *)&skb->data[MT_TXD_SIZE ]; -if (ieee80211_is_data_qos (hdr->frame_control)) + + hwq = wmm_queue_map[IEEE80211_AC_BE ]; +if (ieee80211_is_data_qos (hdr->frame_control)) { tid = *ieee80211_get_qos_ctl (hdr) & -IEEE80211_QOS_CTL_TAG1D_MASK ; -skb_set_queue_mapping (skb, tid_to_ac[tid]); +IEEE80211_QOS_CTL_TAG1D_MASK ; +u8 qid = tid_to_ac[tid]; + hwq = wmm_queue_map[qid]; +skb_set_queue_mapping (skb, qid); + }else if (ieee80211_is_data (hdr->frame_control)) { +skb_set_queue_mapping (skb,IEEE80211_AC_BE ); + hwq = wmm_queue_map[IEEE80211_AC_BE ]; + }else { +skb_pull (skb,MT_TXD_SIZE ); +if (!ieee80211_is_bufferable_mmpdu (skb)) + goto free; +skb_push (skb,MT_TXD_SIZE ); +skb_set_queue_mapping (skb,MT_TXQ_PSD ); + hwq =MT_TX_HW_QUEUE_MGMT ; + } +ieee80211_sta_set_buffered (sta, tid, true); + val =le32_to_cpu (txd[0 ]); + val &= ~(MT_TXD0_P_IDX |MT_TXD0_Q_IDX ); + val |=FIELD_PREP (MT_TXD0_Q_IDX , hwq); + txd[0 ] =cpu_to_le32 (val); +spin_lock_bh (&dev->ps_lock);__skb_queue_tail (&msta->psq, skb);if (skb_queue_len (&msta->psq) >=64 ) {
@@ -151,12 +175,6 @@ static int mt7603_poll_tx(struct napi_struct *napi, int budget)int mt7603_dma_init (struct mt7603_dev *dev) { -static const u8 wmm_queue_map[] = { - [IEEE80211_AC_BK ] =0 , - [IEEE80211_AC_BE ] =1 , - [IEEE80211_AC_VI ] =2 , - [IEEE80211_AC_VO ] =3 , - };int ret;int i;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 198/427 wifi: mt76: mt7603: add wpdma tx eof flag for PSE client reset
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Fietkau <[email protected]>
[ Upstream commit 21de5f72260b4246e2415bc900c18139bc52ea80 ]
This flag is needed for the PSE client reset. Fixes watchdog reset issues.
--- drivers/net/wireless/mediatek/mt76/mt7603/mac.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/mediatek/mt76/mt7603/mac.c +1 -0
@@ -1393,6 +1393,7 @@ void mt7603_pse_client_reset(struct mt7603_dev *dev) MT_CLIENT_RESET_TX_R_E_2_S);/* Start PSE client TX abort */ +mt76_set (dev,MT_WPDMA_GLO_CFG ,MT_WPDMA_GLO_CFG_FORCE_TX_EOF );mt76_set (dev, addr,MT_CLIENT_RESET_TX_R_E_1 );mt76_poll_msec (dev, addr,MT_CLIENT_RESET_TX_R_E_1_S ,MT_CLIENT_RESET_TX_R_E_1_S ,500 );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 199/427 wifi: mt76: connac: check for null before dereferencing
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Muhammad Usama Anjum <[email protected]>
[ Upstream commit cb47c7be0e93dd5acda078163799401ac3a78e10 ]
The wcid can be NULL. It should be checked for validity before dereferencing it to avoid crash.
--- drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +1 -1
@@ -283,7 +283,7 @@ __mt76_connac_mcu_alloc_sta_req(struct mt76_dev *dev, struct mt76_vif *mvif, };struct sk_buff *skb; -if (is_mt799x (dev) && !wcid->sta) +if (is_mt799x (dev) && wcid && !wcid->sta) hdr.muar_idx =0xe ; mt76_connac_mcu_get_wlan_idx(dev, wcid, &hdr.wlan_idx_lo,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 200/427 wifi: mt76: mt7996: fix size of txpower MCU command
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chad Monroe <[email protected]>
[ Upstream commit 66ffcb9abae68625c704b247c7d15cbbc7837391 ]
Fixes issues with scanning and low power output at some rates.
--- drivers/net/wireless/mediatek/mt76/mt7996/mcu.c | 7 +++++-- drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h | 1 + 2 files changed, 6 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c +5 -2
@@ -4464,7 +4464,7 @@ int mt7996_mcu_set_txpower_sku(struct mt7996_phy *phy)u8 band_idx; }__packed req = { .tag =cpu_to_le16 (UNI_TXPOWER_POWER_LIMIT_TABLE_CTRL ), - .len =cpu_to_le16 (sizeof (req) +MT7996_SKU_RATE_NUM -4 ), + .len =cpu_to_le16 (sizeof (req) +MT7996_SKU_PATH_NUM -4 ), .power_ctrl_id =UNI_TXPOWER_POWER_LIMIT_TABLE_CTRL , .power_limit_type =TX_POWER_LIMIT_TABLE_RATE , .band_idx = phy->mt76->band_idx,
@@ -4479,7 +4479,7 @@ int mt7996_mcu_set_txpower_sku(struct mt7996_phy *phy) mphy->txpower_cur = tx_power; skb =mt76_mcu_msg_alloc (&dev->mt76,NULL , -sizeof (req) +MT7996_SKU_RATE_NUM ); +sizeof (req) +MT7996_SKU_PATH_NUM );if (!skb)return -ENOMEM ;
@@ -4503,6 +4503,9 @@ int mt7996_mcu_set_txpower_sku(struct mt7996_phy *phy)/* eht */ skb_put_data (skb, &la.eht[0 ],sizeof (la.eht)); +/* padding */ +skb_put_zero (skb,MT7996_SKU_PATH_NUM -MT7996_SKU_RATE_NUM ); +return mt76_mcu_skb_send_msg (&dev->mt76, skb,MCU_WM_UNI_CMD (TXPOWER ), true); }
drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h +1 -0
@@ -50,6 +50,7 @@#define MT7996_CFEND_RATE_11B 0x03/* 11B LP, 11M */ #define MT7996_SKU_RATE_NUM 417 +#define MT7996_SKU_PATH_NUM 494#define MT7996_MAX_TWT_AGRT 16#define MT7996_MAX_STA_TWT_AGRT 8
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 201/427 wifi: mt76: mt7925: ensure 4-byte alignment for suspend & wow command
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Yen Hsieh <[email protected]>
[ Upstream commit fa46bd62c9a8ab195d9c5108a91abf0680fec10e ]
Before sending suspend & wow command to FW, its length should be 4-bytes alignd.
--- drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c | 1 + drivers/net/wireless/mediatek/mt76/mt7925/mcu.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +1 -0
@@ -2527,6 +2527,7 @@ int mt76_connac_mcu_set_hif_suspend(struct mt76_dev *dev, bool suspend)__le16 tag;__le16 len;u8 suspend; +u8 pad[7 ]; }__packed hif_suspend; } req = { .hif_suspend = {
drivers/net/wireless/mediatek/mt76/mt7925/mcu.h +1 -1
@@ -535,7 +535,7 @@ struct mt7925_wow_pattern_tlv {u8 offset;u8 mask[MT76_CONNAC_WOW_MASK_MAX_LEN ];u8 pattern[MT76_CONNAC_WOW_PATTEN_MAX_LEN ]; -u8 rsv[4 ]; +u8 rsv[7 ]; } __packed; static inline enum connac3_mcu_cipher_type
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 202/427 wifi: mt76: mt7996: fix uninitialized variable in mt7996_irq_tasklet()
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Bianconi <[email protected]>
[ Upstream commit 1ac710a6e8545c6df7a292f167dd088880a74c05 ]
Set intr1 to 0 in mt7996_irq_tasklet() in order to avoid possible uninitialized variable usage if wed is not active for hif2.
--- drivers/net/wireless/mediatek/mt76/mt7996/mmio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7996/mmio.c +1 -1
@@ -519,7 +519,7 @@ static void mt7996_irq_tasklet(struct tasklet_struct *t)struct mt7996_dev *dev =from_tasklet (dev, t, mt76.irq_tasklet);struct mtk_wed_device *wed = &dev->mt76.mmio.wed;struct mtk_wed_device *wed_hif2 = &dev->mt76.mmio.wed_hif2; -u32 i, intr, mask, intr1; +u32 i, intr, mask, intr1 =0 ;if (dev->hif2 &&mtk_wed_device_active (wed_hif2)) {mtk_wed_device_irq_set_mask (wed_hif2,0 );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 203/427 wifi: mt76: mt7996: fix potential memory leakage when reading chip temperature
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Howard Hsu <[email protected]>
[ Upstream commit 474b9412f33be87076b40a49756662594598a85e ]
Without this commit, reading chip temperature will cause memory leakage.
--- drivers/net/wireless/mediatek/mt76/mt7996/mcu.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c +4 -1
@@ -3729,6 +3729,7 @@ int mt7996_mcu_get_temperature(struct mt7996_phy *phy) }__packed * res;struct sk_buff *skb;int ret; +u32 temp; ret =mt76_mcu_send_and_get_msg (&phy->dev->mt76,MCU_WM_UNI_CMD (THERMAL ), &req,sizeof (req), true, &skb);
@@ -3736,8 +3737,10 @@ int mt7996_mcu_get_temperature(struct mt7996_phy *phy)return ret; res = (void *)skb->data; + temp =le32_to_cpu (res->temperature); +dev_kfree_skb (skb); -return le32_to_cpu (res->temperature); +return temp; }int mt7996_mcu_set_thermal_throttling (struct mt7996_phy *phy,u8 state)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 204/427 wifi: mt76: connac: use muar idx 0xe for non-mt799x as well
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Fietkau <[email protected]>
[ Upstream commit 64bfcdbe025699d3d81ec11af24bd4895c0f6ddd ]
This is expected by the firmware of older chipsets as well, though it may not have been as strongly required as on mt799x
--- drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +1 -1
@@ -283,7 +283,7 @@ __mt76_connac_mcu_alloc_sta_req(struct mt76_dev *dev, struct mt76_vif *mvif, };struct sk_buff *skb; -if (is_mt799x (dev) && wcid && !wcid->sta) +if (wcid && !wcid->sta) hdr.muar_idx =0xe ; mt76_connac_mcu_get_wlan_idx(dev, wcid, &hdr.wlan_idx_lo,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 205/427 libbpf: Fix error message in attach_kprobe_multi
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Olsa <[email protected]>
[ Upstream commit 7c13ef16e87ac2e44d16c0468b1191bceb06f95c ]
We just failed to retrieve pattern, so we need to print spec instead.
--- tools/lib/bpf/libbpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/bpf/libbpf.c +1 -1
@@ -11475,7 +11475,7 @@ static int attach_kprobe_multi(const struct bpf_program *prog, long cookie, stru n =sscanf (spec,"%m[a-zA-Z0-9_.*?]" , &pattern);if (n <1 ) { -pr_warn ("kprobe multi pattern is invalid: %s\n" , pattern); +pr_warn ("kprobe multi pattern is invalid: %s\n" , spec);return -EINVAL ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 206/427 wifi: nl80211: Avoid address calculations via out of bounds array indexing
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
[ Upstream commit 838c7b8f1f278404d9d684c34a8cb26dc41aaaa1 ]
Before request->channels[] can be used, request->n_channels must be set. Additionally, address calculations for memory after the "channels" array need to be calculated from the allocation base ("request") rather than via the first "out of bounds" index of "channels", otherwise run-time bounds checking will throw a warning.
--- net/wireless/nl80211.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
net/wireless/nl80211.c +7 -7
@@ -9162,6 +9162,7 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)struct wiphy *wiphy;int err, tmp, n_ssids =0 , n_channels, i;size_t ie_len, size; +size_t ssids_offset, ie_offset; wiphy = &rdev->wiphy;
@@ -9207,21 +9208,20 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)return -EINVAL ; size =struct_size (request, channels, n_channels); + ssids_offset = size; size =size_add (size,array_size (sizeof (*request->ssids), n_ssids)); + ie_offset = size; size =size_add (size, ie_len); request =kzalloc (size,GFP_KERNEL );if (!request)return -ENOMEM ; + request->n_channels = n_channels;if (n_ssids) - request->ssids = (void *)&request->channels[n_channels]; + request->ssids = (void *)request + ssids_offset; request->n_ssids = n_ssids; -if (ie_len) { -if (n_ssids) - request->ie = (void *)(request->ssids + n_ssids); -else - request->ie = (void *)(request->channels + n_channels); - } +if (ie_len) + request->ie = (void *)request + ie_offset; i =0 ;if (scan_freqs) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 207/427 wifi: rtw89: wow: refine WoWLAN flows of HCI interrupts and low power mode
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chih-Kang Chang <[email protected]>
[ Upstream commit baaf806e4632a259cc959fd1c516c2d9ed48df6d ]
After enabling packet offload, the TX will be stuck after resume from WoWLAN mode. And the 8852c gets error messages like
rtw89_8852ce 0000:04:00.0: No busy txwd pages available rtw89_8852ce 0000:04:00.0: queue 0 txwd 100 is not idle rtw89_8852ce 0000:04:00.0: queue 0 txwd 101 is not idle rtw89_8852ce 0000:04:00.0: queue 0 txwd 102 is not idle rtw89_8852ce 0000:04:00.0: queue 0 txwd 103 is not idle
If suspend/resume many times that firmware will download failed and disconnection.
To fix these issues, We removed the rtw89_hci_disable_intr() and rtw89_hci_enable_intr() during rtw89_wow_swap_fw() to prevent add packet offload can't receive c2h back due to interrupt disable. Only 8852C and 8922A needs to disable interrupt before downloading fw.
Furthermore, we avoid using low power HCI mode on WoWLAN mode, to prevent interrupt enabled, then get interrupt and calculate RXBD mismatched due to software RXBD index already reset but hardware RXBD index not yet.
--- drivers/net/wireless/realtek/rtw89/ps.c | 3 ++- drivers/net/wireless/realtek/rtw89/wow.c | 12 ++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-)
drivers/net/wireless/realtek/rtw89/ps.c +2 -1
@@ -55,7 +55,8 @@ static void rtw89_ps_power_mode_change_with_hci(struct rtw89_dev *rtwdev,static void rtw89_ps_power_mode_change (struct rtw89_dev *rtwdev,bool enter) { -if (rtwdev->chip->low_power_hci_modes &BIT (rtwdev->ps_mode)) +if (rtwdev->chip->low_power_hci_modes &BIT (rtwdev->ps_mode) && + !test_bit (RTW89_FLAG_WOWLAN , rtwdev->flags))rtw89_ps_power_mode_change_with_hci (rtwdev, enter);else rtw89_mac_power_mode_change (rtwdev, enter);
drivers/net/wireless/realtek/rtw89/wow.c +10 -2
@@ -457,14 +457,17 @@ static int rtw89_wow_swap_fw(struct rtw89_dev *rtwdev, bool wow)struct rtw89_wow_param *rtw_wow = &rtwdev->wow;struct ieee80211_vif *wow_vif = rtw_wow->wow_vif;struct rtw89_vif *rtwvif = (struct rtw89_vif *)wow_vif->drv_priv; +enum rtw89_core_chip_id chip_id = rtwdev->chip->chip_id;const struct rtw89_chip_info *chip = rtwdev->chip;bool include_bb = !!chip->bbmcu_nr; +bool disable_intr_for_dlfw = false;struct ieee80211_sta *wow_sta;struct rtw89_sta *rtwsta =NULL ;bool is_conn = true;int ret; -rtw89_hci_disable_intr (rtwdev); +if (chip_id ==RTL8852C || chip_id ==RTL8922A ) + disable_intr_for_dlfw = true; wow_sta =ieee80211_find_sta (wow_vif, rtwvif->bssid);if (wow_sta)
@@ -472,12 +475,18 @@ static int rtw89_wow_swap_fw(struct rtw89_dev *rtwdev, bool wow)else is_conn = false; +if (disable_intr_for_dlfw) +rtw89_hci_disable_intr (rtwdev); + ret =rtw89_fw_download (rtwdev, fw_type, include_bb);if (ret) {rtw89_warn (rtwdev,"download fw failed\n" );return ret; } +if (disable_intr_for_dlfw) +rtw89_hci_enable_intr (rtwdev); +rtw89_phy_init_rf_reg (rtwdev, true); ret = rtw89_fw_h2c_role_maintain(rtwdev, rtwvif, rtwsta,
@@ -520,7 +529,6 @@ static int rtw89_wow_swap_fw(struct rtw89_dev *rtwdev, bool wow) }rtw89_mac_hw_mgnt_sec (rtwdev, wow); -rtw89_hci_enable_intr (rtwdev);return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 208/427 selftests: ktap_helpers: Make it POSIX-compliant
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nícolas F. R. A. Prado <[email protected]>
[ Upstream commit 45d5a2b1886a3ff0fe5627ebee84c089db7ff5f2 ]
There are a couple uses of bash specific syntax in the script. Change them to the equivalent POSIX syntax. This doesn't change functionality and allows non-bash test scripts to make use of these helpers.
--- tools/testing/selftests/kselftest/ktap_helpers.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/kselftest/ktap_helpers.sh +2 -2
@@ -43,7 +43,7 @@ __ktap_test() { directive="$3" # optional local directive_str= - [[ ! -z "$directive" ]] && directive_str="# $directive" + [ ! -z "$directive" ] && directive_str="# $directive" echo $result $KTAP_TESTNO $description $directive_str
@@ -99,7 +99,7 @@ ktap_exit_fail_msg() { ktap_finished() { ktap_print_totals - if [ $(("$KTAP_CNT_PASS" + "$KTAP_CNT_SKIP")) -eq "$KSFT_NUM_TESTS" ]; then + if [ $((KTAP_CNT_PASS + KTAP_CNT_SKIP)) -eq "$KSFT_NUM_TESTS" ]; then exit "$KSFT_PASS" else exit "$KSFT_FAIL"
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 209/427 selftests: power_supply: Make it POSIX-compliant
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nícolas F. R. A. Prado <[email protected]>
[ Upstream commit 5b1c8b1e56ff8b5e9c1a09606af3627bb55933cf ]
There is one use of bash specific syntax in the script. Change it to the equivalent POSIX syntax. This doesn't change functionality and allows the test to be run on shells other than bash.
--- .../selftests/power_supply/test_power_supply_properties.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/power_supply/test_power_supply_properties.sh +1 -1
@@ -23,7 +23,7 @@ count_tests() { total_tests=0 for i in $SUPPLIES; do - total_tests=$(("$total_tests" + "$NUM_TESTS")) + total_tests=$((total_tests + NUM_TESTS)) done echo "$total_tests"
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 210/427 selftests/binderfs: use the Makefiles rules, not Makes implicit rules
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Hubbard <[email protected]>
[ Upstream commit 019baf635eb6ffe8d6c1343f81788f02a7e0ed98 ]
First of all, in order to build with clang at all, one must first apply Valentin Obst's build fix for LLVM [1]. Once that is done, then when building with clang, via:
make LLVM=1 -C tools/testing/selftests
...the following error occurs:
clang: error: cannot specify -o when generating multiple output files
This is because clang, unlike gcc, won't accept invocations of this form:
clang file1.c header2.h
While trying to fix this, I noticed that:
a) selftests/lib.mk already avoids the problem, and
b) The binderfs Makefile indavertently bypasses the selftests/lib.mk build system, and quitely uses Make's implicit build rules for .c files instead.
The Makefile attempts to set up both a dependency and a source file, neither of which was needed, because lib.mk is able to automatically handle both. This line:
binderfs_test: binderfs_test.c
...causes Make's implicit rules to run, which builds binderfs_test without ever looking at lib.mk.
Fix this by simply deleting the "binderfs_test:" Makefile target and letting lib.mk handle it instead.
[1] https://lore.kernel.org/all/20240329-selftests-libmk-llvm-rfc-v1-1-2f9ed7d1c49f@valentinobst.de/
--- tools/testing/selftests/filesystems/binderfs/Makefile | 2 -- 1 file changed, 2 deletions(-)
tools/testing/selftests/filesystems/binderfs/Makefile +0 -2
@@ -3,6 +3,4 @@ CFLAGS += $(KHDR_INCLUDES) -pthread TEST_GEN_PROGS := binderfs_test -binderfs_test: binderfs_test.c ../../kselftest.h ../../kselftest_harness.h - include ../../lib.mk
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 211/427 selftests/resctrl: fix clang build failure: use LOCAL_HDRS
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Hubbard <[email protected]>
[ Upstream commit d8171aa4ca72f1a67bf3c14c59441d63c1d2585f ]
First of all, in order to build with clang at all, one must first apply Valentin Obst's build fix for LLVM [1]. Once that is done, then when building with clang, via:
make LLVM=1 -C tools/testing/selftests
...the following error occurs:
clang: error: cannot specify -o when generating multiple output files
This is because clang, unlike gcc, won't accept invocations of this form:
clang file1.c header2.h
Fix this by using selftests/lib.mk facilities for tracking local header file dependencies: add them to LOCAL_HDRS, leaving only the .c files to be passed to the compiler.
[1] https://lore.kernel.org/all/20240329-selftests-libmk-llvm-rfc-v1-1-2f9ed7d1c49f@valentinobst.de/
--- tools/testing/selftests/resctrl/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/testing/selftests/resctrl/Makefile +3 -1
@@ -5,6 +5,8 @@ CFLAGS += $(KHDR_INCLUDES) TEST_GEN_PROGS := resctrl_tests +LOCAL_HDRS += $(wildcard *.h) + include ../lib.mk -$(OUTPUT)/resctrl_tests: $(wildcard *.[ch]) +$(OUTPUT)/resctrl_tests: $(wildcard *.c)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 212/427 selftests: default to host arch for LLVM builds
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Valentin Obst <[email protected]>
[ Upstream commit d4e6fbd245c48b272cc591d1c5e7c07aedd7f071 ]
Align the behavior for gcc and clang builds by interpreting unset ARCH and CROSS_COMPILE variables in LLVM builds as a sign that the user wants to build for the host architecture.
This patch preserves the properties that setting the ARCH variable to an unknown value will trigger an error that complains about insufficient information, and that a set CROSS_COMPILE variable will override the target triple that is determined based on presence/absence of ARCH.
When compiling with clang, i.e., LLVM is set, an unset ARCH variable in combination with an unset CROSS_COMPILE variable, i.e., compiling for the host architecture, leads to compilation failures since lib.mk can not determine the clang target triple. In this case, the following error message is displayed for each subsystem that does not set ARCH in its own Makefile before including lib.mk (lines wrapped at 75 chrs):
make[1]: Entering directory '/mnt/build/linux/tools/testing/selftests/
sysctl'
../lib.mk:33: *** Specify CROSS_COMPILE or add '--target=' option to
lib.mk. Stop.
make[1]: Leaving directory '/mnt/build/linux/tools/testing/selftests/
sysctl'
In the same scenario a gcc build would default to the host architecture, i.e., it would use plain gcc.
--- tools/testing/selftests/lib.mk | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
tools/testing/selftests/lib.mk +10 -2
@@ -7,6 +7,8 @@ else ifneq ($(filter -%,$(LLVM)),) LLVM_SUFFIX := $(LLVM) endif +CLANG := $(LLVM_PREFIX)clang$(LLVM_SUFFIX) + CLANG_TARGET_FLAGS_arm := arm-linux-gnueabi CLANG_TARGET_FLAGS_arm64 := aarch64-linux-gnu CLANG_TARGET_FLAGS_hexagon := hexagon-linux-musl
@@ -18,7 +20,13 @@ CLANG_TARGET_FLAGS_riscv := riscv64-linux-gnu CLANG_TARGET_FLAGS_s390 := s390x-linux-gnu CLANG_TARGET_FLAGS_x86 := x86_64-linux-gnu CLANG_TARGET_FLAGS_x86_64 := x86_64-linux-gnu -CLANG_TARGET_FLAGS := $(CLANG_TARGET_FLAGS_$(ARCH)) + +# Default to host architecture if ARCH is not explicitly given. +ifeq ($(ARCH),) +CLANG_TARGET_FLAGS := $(shell $(CLANG) -print-target-triple) +else +CLANG_TARGET_FLAGS := $(CLANG_TARGET_FLAGS_$(ARCH)) +endif ifeq ($(CROSS_COMPILE),) ifeq ($(CLANG_TARGET_FLAGS),)
@@ -30,7 +38,7 @@ else CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) endif # CROSS_COMPILE -CC := $(LLVM_PREFIX)clang$(LLVM_SUFFIX) $(CLANG_FLAGS) -fintegrated-as +CC := $(CLANG) $(CLANG_FLAGS) -fintegrated-as else CC := $(CROSS_COMPILE)gcc endif # LLVM
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 213/427 kunit: Fix kthread reference
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mickaël Salaün <[email protected]>
[ Upstream commit f8aa1b98ce40184521ed95ec26cc115a255183b2 ]
There is a race condition when a kthread finishes after the deadline and before the call to kthread_stop(), which may lead to use after free.
--- lib/kunit/try-catch.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
lib/kunit/try-catch.c +6 -3
@@ -11,6 +11,7 @@#include <linux/completion.h> #include <linux/kernel.h> #include <linux/kthread.h> +#include <linux/sched/task.h> #include "try-catch-impl.h"
@@ -65,13 +66,14 @@ void kunit_try_catch_run(struct kunit_try_catch *try_catch, void *context) try_catch->context = context; try_catch->try_completion = &try_completion; try_catch->try_result =0 ; - task_struct =kthread_run (kunit_generic_run_threadfn_adapter, - try_catch, -"kunit_try_catch_thread" ); + task_struct =kthread_create (kunit_generic_run_threadfn_adapter, + try_catch,"kunit_try_catch_thread" );if (IS_ERR (task_struct)) { try_catch->catch (try_catch->context);return ; } +get_task_struct (task_struct); +wake_up_process (task_struct); time_remaining =wait_for_completion_timeout (&try_completion,kunit_test_timeout ());
@@ -81,6 +83,7 @@ void kunit_try_catch_run(struct kunit_try_catch *try_catch, void *context)kthread_stop (task_struct); } +put_task_struct (task_struct); exit_code = try_catch->try_result;if (!exit_code)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 214/427 kunit: unregister the device on error
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wander Lairson Costa <[email protected]>
[ Upstream commit fabd480b721eb30aa4e2c89507b53933069f9f6e ]
kunit_init_device() should unregister the device on bus register error, but mistakenly it tries to unregister the bus.
Unregister the device instead of the bus.
--- lib/kunit/device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/kunit/device.c +1 -1
@@ -51,7 +51,7 @@ int kunit_bus_init(void) error =bus_register (&kunit_bus_type);if (error) -bus_unregister (&kunit_bus_type); +root_device_unregister (kunit_bus_device);return error; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 215/427 kunit: bail out early in __kunit_test_suites_init() if there are no suites to test
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Scott Mayhew <[email protected]>
[ Upstream commit 5496b9b77d7420652202b73cf036e69760be5deb ]
Commit c72a870926c2 added a mutex to prevent kunit tests from running concurrently. Unfortunately that mutex gets locked during module load regardless of whether the module actually has any kunit tests. This causes a problem for kunit tests that might need to load other kernel modules (e.g. gss_krb5_test loading the camellia module).
So check to see if there are actually any tests to run before locking the kunit_run_lock mutex.
--- lib/kunit/test.c | 3 +++ 1 file changed, 3 insertions(+)
lib/kunit/test.c +3 -0
@@ -712,6 +712,9 @@ int __kunit_test_suites_init(struct kunit_suite * const * const suites, int num_ {unsigned int i; +if (num_suites ==0 ) +return 0 ; +if (!kunit_enabled () && num_suites >0 ) {pr_info ("kunit: disabled\n" );return 0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 216/427 selftests/bpf: Fix pointer arithmetic in test_xdp_do_redirect
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Schmidt <[email protected]>
[ Upstream commit e549b39a0ab8880d7ae6c6495b00fc1cb8f36174 ]
Cast operation has a higher precedence than addition. The code here wants to zero the 2nd half of the 64-bit metadata, but due to a pointer arithmetic mistake, it writes the zero at offset 16 instead.
Just adding parentheses around "data + 4" would fix this, but I think this will be slightly better readable with array syntax.
I was unable to test this with tools/testing/selftests/bpf/vmtest.sh, because my glibc is newer than glibc in the provided VM image. So I just checked the difference in the compiled code. objdump -S tools/testing/selftests/bpf/xdp_do_redirect.test.o:
- *((__u32 *)data) = 0x42; /* metadata test value */
+ ((__u32 *)data)[0] = 0x42; /* metadata test value */
be7: 48 8d 85 30 fc ff ff lea -0x3d0(%rbp),%rax
bee: c7 00 42 00 00 00 movl $0x42,(%rax)
- *((__u32 *)data + 4) = 0;
+ ((__u32 *)data)[1] = 0;
bf4: 48 8d 85 30 fc ff ff lea -0x3d0(%rbp),%rax
- bfb: 48 83 c0 10 add $0x10,%rax
+ bfb: 48 83 c0 04 add $0x4,%rax
bff: c7 00 00 00 00 00 movl $0x0,(%rax)--- tools/testing/selftests/bpf/prog_tests/xdp_do_redirect.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/prog_tests/xdp_do_redirect.c +2 -2
@@ -107,8 +107,8 @@ void test_xdp_do_redirect(void) .attach_point = BPF_TC_INGRESS);memcpy (&data[sizeof (__u64)], &pkt_udp,sizeof (pkt_udp)); - *((__u32 *)data) =0x42 ;/* metadata test value */ - *((__u32 *)data +4 ) =0 ; + ((__u32 *)data)[0 ] =0x42 ;/* metadata test value */ + ((__u32 *)data)[1 ] =0 ; skel =test_xdp_do_redirect__open ();if (!ASSERT_OK_PTR (skel,"skel" ))
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 217/427 HID: intel-ish-hid: ipc: Add check for pci_alloc_irq_vectors
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Ni <[email protected]>
[ Upstream commit 6baa4524027fd64d7ca524e1717c88c91a354b93 ]
Add a check for the return value of pci_alloc_irq_vectors() and return error if it fails.
--- drivers/hid/intel-ish-hid/ipc/pci-ish.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/hid/intel-ish-hid/ipc/pci-ish.c +5 -0
@@ -173,6 +173,11 @@ static int ish_probe(struct pci_dev *pdev, const struct pci_device_id *ent)/* request and enable interrupt */ ret =pci_alloc_irq_vectors (pdev,1 ,1 ,PCI_IRQ_ALL_TYPES ); +if (ret <0 ) { +dev_err (dev,"ISH: Failed to allocate IRQ vectors\n" ); +return ret; + } +if (!pdev->msi_enabled && !pdev->msix_enabled) irq_flag =IRQF_SHARED ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 218/427 scsi: bfa: Ensure the copied buf is NUL terminated
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bui Quang Minh <[email protected]>
[ Upstream commit 13d0cecb4626fae67c00c84d3c7851f6b62f7df3 ]
Currently, we allocate a nbytes-sized kernel buffer and copy nbytes from userspace to that buffer. Later, we use sscanf on this buffer but we don't ensure that the string is terminated inside the buffer, this can lead to OOB read when using sscanf. Fix this issue by using memdup_user_nul instead of memdup_user.
--- drivers/scsi/bfa/bfad_debugfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/bfa/bfad_debugfs.c +2 -2
@@ -250,7 +250,7 @@ bfad_debugfs_write_regrd(struct file *file, const char __user *buf,unsigned long flags;void *kern_buf; - kern_buf =memdup_user (buf, nbytes); + kern_buf =memdup_user_nul (buf, nbytes);if (IS_ERR (kern_buf))return PTR_ERR (kern_buf);
@@ -317,7 +317,7 @@ bfad_debugfs_write_regwr(struct file *file, const char __user *buf,unsigned long flags;void *kern_buf; - kern_buf =memdup_user (buf, nbytes); + kern_buf =memdup_user_nul (buf, nbytes);if (IS_ERR (kern_buf))return PTR_ERR (kern_buf);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 219/427 scsi: qedf: Ensure the copied buf is NUL terminated
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bui Quang Minh <[email protected]>
[ Upstream commit d0184a375ee797eb657d74861ba0935b6e405c62 ]
Currently, we allocate a count-sized kernel buffer and copy count from userspace to that buffer. Later, we use kstrtouint on this buffer but we don't ensure that the string is terminated inside the buffer, this can lead to OOB read when using kstrtouint. Fix this issue by using memdup_user_nul instead of memdup_user.
--- drivers/scsi/qedf/qedf_debugfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/qedf/qedf_debugfs.c +1 -1
@@ -170,7 +170,7 @@ qedf_dbg_debug_cmd_write(struct file *filp, const char __user *buffer,if (!count || *ppos)return 0 ; - kern_buf =memdup_user (buffer, count); + kern_buf =memdup_user_nul (buffer, count);if (IS_ERR (kern_buf))return PTR_ERR (kern_buf);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 220/427 scsi: qla2xxx: Fix debugfs output for fw_resource_count
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Himanshu Madhani <[email protected]>
[ Upstream commit 998d09c5ef6183bd8137d1a892ba255b15978bb4 ]
DebugFS output for fw_resource_count shows:
estimate exchange used[0] high water limit [1945] n estimate iocb2 used [0] high water limit [5141]
estimate exchange2 used[0] high water limit [1945]
Which shows incorrect display due to missing newline in seq_print().
[mkp: fix checkpatch warning about space before newline]
--- drivers/scsi/qla2xxx/qla_dfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_dfs.c +1 -1
@@ -274,7 +274,7 @@ qla_dfs_fw_resource_cnt_show(struct seq_file *s, void *unused)seq_printf (s,"Driver: estimate iocb used [%d] high water limit [%d]\n" , iocbs_used, ha->base_qpair->fwres.iocbs_limit); -seq_printf (s,"estimate exchange used[%d] high water limit [%d] n" , +seq_printf (s,"estimate exchange used[%d] high water limit [%d]\n" , exch_used, ha->base_qpair->fwres.exch_limit);if (ql2xenforce_iocb_limit ==2 ) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 221/427 gpio: nuvoton: Fix sgpio irq handle error
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jim Liu <[email protected]>
[ Upstream commit 7f45fe2ea3b8c85787976293126a4a7133b107de ]
The generic_handle_domain_irq() function calls irq_resolve_mapping(). Thus delete a duplicative irq_find_mapping() call
so that a stack trace and an RCU stall will be avoided.
--- drivers/gpio/gpio-npcm-sgpio.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/gpio/gpio-npcm-sgpio.c +4 -6
@@ -434,7 +434,7 @@ static void npcm_sgpio_irq_handler(struct irq_desc *desc)struct gpio_chip *gc =irq_desc_get_handler_data (desc);struct irq_chip *ic =irq_desc_get_chip (desc);struct npcm_sgpio *gpio =gpiochip_get_data (gc); -unsigned int i, j, girq; +unsigned int i, j;unsigned long reg;chained_irq_enter (ic, desc);
@@ -443,11 +443,9 @@ static void npcm_sgpio_irq_handler(struct irq_desc *desc)const struct npcm_sgpio_bank *bank = &npcm_sgpio_banks[i]; reg =ioread8 (bank_reg (gpio, bank,EVENT_STS )); -for_each_set_bit (j, ®,8 ) { - girq =irq_find_mapping (gc->irq.domain, - i *8 + gpio->nout_sgpio + j); -generic_handle_domain_irq (gc->irq.domain, girq); - } +for_each_set_bit (j, ®,8 ) +generic_handle_domain_irq (gc->irq.domain, + i *8 + gpio->nout_sgpio + j); }chained_irq_exit (ic, desc);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 222/427 x86/numa: Fix SRAT lookup of CFMWS ranges with numa_fill_memblks()
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Robert Richter <[email protected]>
[ Upstream commit f9f67e5adc8dc2e1cc51ab2d3d6382fa97f074d4 ]
For configurations that have the kconfig option NUMA_KEEP_MEMINFO disabled, numa_fill_memblks() only returns with NUMA_NO_MEMBLK (-1). SRAT lookup fails then because an existing SRAT memory range cannot be found for a CFMWS address range. This causes the addition of a duplicate numa_memblk with a different node id and a subsequent page fault and kernel crash during boot.
Fix this by making numa_fill_memblks() always available regardless of NUMA_KEEP_MEMINFO.
As Dan suggested, the fix is implemented to remove numa_fill_memblks() from sparsemem.h and alos using __weak for the function.
Note that the issue was initially introduced with [1]. But since phys_to_target_node() was originally used that returned the valid node 0, an additional numa_memblk was not added. Though, the node id was wrong too, a message is seen then in the logs:
kernel/numa.c: pr_info_once("Unknown target node for memory at 0x%llx, assuming node 0\n",
[1] commit fd49f99c1809 ("ACPI: NUMA: Add a node and memblk for each CFMWS not in SRAT")
--- arch/x86/include/asm/sparsemem.h | 2 -- arch/x86/mm/numa.c | 4 ++-- drivers/acpi/numa/srat.c | 5 +++++ include/linux/numa.h | 7 +------ 4 files changed, 8 insertions(+), 10 deletions(-)
arch/x86/include/asm/sparsemem.h +0 -2
@@ -37,8 +37,6 @@ extern int phys_to_target_node(phys_addr_t start);#define phys_to_target_node phys_to_target_nodeextern int memory_add_physaddr_to_nid (u64 start);#define memory_add_physaddr_to_nid memory_add_physaddr_to_nid -extern int numa_fill_memblks (u64 start,u64 end); -#define numa_fill_memblks numa_fill_memblks#endif #endif /* __ASSEMBLY__ */
arch/x86/mm/numa.c +2 -2
@@ -929,6 +929,8 @@ int memory_add_physaddr_to_nid(u64 start) }EXPORT_SYMBOL_GPL (memory_add_physaddr_to_nid); +#endif +static int __init cmp_memblk (const void *a,const void *b) {const struct numa_memblk *ma = *(const struct numa_memblk **)a;
@@ -1001,5 +1003,3 @@ int __init numa_fill_memblks(u64 start, u64 end) }return 0 ; } - -#endif
drivers/acpi/numa/srat.c +5 -0
@@ -208,6 +208,11 @@ int __init srat_disabled(void)return acpi_numa <0 ; } +__weak int __init numa_fill_memblks (u64 start,u64 end) +{ +return NUMA_NO_MEMBLK ; +} +#if defined(CONFIG_X86 ) || defined(CONFIG_ARM64 ) || defined(CONFIG_LOONGARCH )/* * Callback for SLIT parsing. pxm_to_node() returns NUMA_NO_NODE for
include/linux/numa.h +1 -6
@@ -36,12 +36,7 @@ int memory_add_physaddr_to_nid(u64 start);int phys_to_target_node (u64 start);#endif -#ifndef numa_fill_memblks -static inline int __init numa_fill_memblks (u64 start,u64 end) -{ -return NUMA_NO_MEMBLK ; -} -#endif +int numa_fill_memblks (u64 start,u64 end);#else /* !CONFIG_NUMA */ static inline int numa_nearest_node (int node,unsigned int state)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 223/427 wifi: mwl8k: initialize cmd->addr[] properly
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 1d60eabb82694e58543e2b6366dae3e7465892a5 ]
This loop is supposed to copy the mac address to cmd->addr but the i++ increment is missing so it copies everything to cmd->addr[0] and only the last address is recorded.
--- drivers/net/wireless/marvell/mwl8k.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/marvell/mwl8k.c +1 -1
@@ -2718,7 +2718,7 @@ __mwl8k_cmd_mac_multicast_adr(struct ieee80211_hw *hw, int allmulti, cmd->action |=cpu_to_le16 (MWL8K_ENABLE_RX_MULTICAST ); cmd->numaddr =cpu_to_le16 (mc_count);netdev_hw_addr_list_for_each (ha, mc_list) { -memcpy (cmd->addr[i], ha->addr,ETH_ALEN ); +memcpy (cmd->addr[i++], ha->addr,ETH_ALEN ); } }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 224/427 HID: amd_sfh: Handle "no sensors" in PM operations
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Basavaraj Natikar <[email protected]>
[ Upstream commit 077e3e3bc84a51891e732507bbbd9acf6e0e4c8b ]
Resume or suspend each sensor device based on the num_hid_devices. Therefore, add a check to handle the special case where no sensors are present.
--- drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c +10 -0
@@ -227,6 +227,11 @@ static void amd_sfh_resume(struct amd_mp2_dev *mp2)struct amd_mp2_sensor_info info;int i, status; +if (!cl_data->is_any_sensor_enabled) { +amd_sfh_clear_intr (mp2); +return ; + } +for (i =0 ; i < cl_data->num_hid_devices; i++) {if (cl_data->sensor_sts[i] ==SENSOR_DISABLED ) { info.sensor_idx = cl_data->sensor_idx[i];
@@ -252,6 +257,11 @@ static void amd_sfh_suspend(struct amd_mp2_dev *mp2)struct amdtp_cl_data *cl_data = mp2->cl_data;int i, status; +if (!cl_data->is_any_sensor_enabled) { +amd_sfh_clear_intr (mp2); +return ; + } +for (i =0 ; i < cl_data->num_hid_devices; i++) {if (cl_data->sensor_idx[i] !=HPD_IDX && cl_data->sensor_sts[i] ==SENSOR_ENABLED ) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 225/427 btrfs: set start on clone before calling copy_extent_buffer_full
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
[ Upstream commit 53e24158684b527d013b5b2204ccb34d1f94c248 ]
Our subpage testing started hanging on generic/560 and I bisected it down to 1cab1375ba6d ("btrfs: reuse cloned extent buffer during fiemap to avoid re-allocations"). This is subtle because we use eb->start to figure out where in the folio we're copying to when we're subpage, as our ->start may refer to an area inside of the folio.
For example, assume a 16K page size machine with a 4K node size, and assume that we already have a cloned extent buffer when we cloned the previous search.
copy_extent_buffer_full() will do the following when copying the extent buffer path->nodes[0] (src) into cloned (dest):
src->start = 8k; // this is the new leaf we're cloning cloned->start = 4k; // this is left over from the previous clone
src_addr = folio_address(src->folios[0]); dest_addr = folio_address(dest->folios[0]);
memcpy(dest_addr + get_eb_offset_in_folio(dst, 0),
src_addr + get_eb_offset_in_folio(src, 0), src->len);
Now get_eb_offset_in_folio() is where the problems occur, because for sub-pagesize blocksize we can have multiple eb's per folio, the code for this is as follows
size_t get_eb_offset_in_folio(eb, offset) {
return (eb->start + offset & (folio_size(eb->folio[0]) - 1));}
So in the above example we are copying into offset 4K inside the folio. However once we update cloned->start to 8K to match the src the math for get_eb_offset_in_folio() changes, and any subsequent reads (i.e. btrfs_item_key_to_cpu()) will start reading from the offset 8K instead of 4K where we copied to, giving us garbage.
Fix this by setting start before we co copy_extent_buffer_full() to make sure that we're copying into the same offset inside of the folio that we will read from later.
All other sites of copy_extent_buffer_full() are correct because we either set ->start beforehand or we simply don't change it in the case of the tree-log usage.
With this fix we now pass generic/560 on our subpage tests.
--- fs/btrfs/extent_io.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
fs/btrfs/extent_io.c +8 -2
@@ -2773,13 +2773,19 @@ static int fiemap_next_leaf_item(struct btrfs_inode *inode, struct btrfs_path *p goto out; } -/* See the comment at fiemap_search_slot() about why we clone. */ -copy_extent_buffer_full (clone, path->nodes[0 ]);/* * Important to preserve the start field, for the optimizations when * checking if extents are shared (see extent_fiemap()). +* +* We must set ->start before calling copy_extent_buffer_full(). If we +* are on sub-pagesize blocksize, we use ->start to determine the offset +* into the folio where our eb exists, and if we update ->start after +* the fact then any subsequent reads of the eb may read from a +* different offset in the folio than where we originally copied into. */ clone->start = path->nodes[0 ]->start; +/* See the comment at fiemap_search_slot() about why we clone. */ +copy_extent_buffer_full (clone, path->nodes[0 ]); slot = path->slots[0 ];btrfs_release_path (path);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 226/427 usb: aqc111: stop lying about skb->truesize
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 9aad6e45c4e7d16b2bb7c3794154b828fb4384b4 ]
Some usb drivers try to set small skb->truesize and break core networking stacks.
I replace one skb_clone() by an allocation of a fresh and small skb, to get minimally sized skbs, like we did in commit 1e2c61172342 ("net: cdc_ncm: reduce skb truesize in rx path") and 4ce62d5b2f7a ("net: usb: ax88179_178a:
stop lying about skb->truesize")
--- drivers/net/usb/aqc111.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/net/usb/aqc111.c +3 -5
@@ -1141,17 +1141,15 @@ static int aqc111_rx_fixup(struct usbnet *dev, struct sk_buff *skb)continue ; } -/* Clone SKB */ - new_skb =skb_clone (skb,GFP_ATOMIC ); + new_skb =netdev_alloc_skb_ip_align (dev->net, pkt_len);if (!new_skb) goto err; - new_skb->len = pkt_len; +skb_put (new_skb, pkt_len); +memcpy (new_skb->data, skb->data, pkt_len);skb_pull (new_skb,AQ_RX_HW_PAD ); -skb_set_tail_pointer (new_skb, new_skb->len); - new_skb->truesize =SKB_TRUESIZE (new_skb->len);if (aqc111_data->rx_checksum)aqc111_rx_checksum (new_skb, pkt_desc);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 227/427 net: usb: sr9700: stop lying about skb->truesize
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 05417aa9c0c038da2464a0c504b9d4f99814a23b ]
Some usb drivers set small skb->truesize and break core networking stacks.
In this patch, I removed one of the skb->truesize override.
I also replaced one skb_clone() by an allocation of a fresh and small skb, to get minimally sized skbs, like we did in commit 1e2c61172342 ("net: cdc_ncm: reduce skb truesize in rx path") and 4ce62d5b2f7a ("net: usb: ax88179_178a:
stop lying about skb->truesize")
--- drivers/net/usb/sr9700.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/net/usb/sr9700.c +3 -7
@@ -421,19 +421,15 @@ static int sr9700_rx_fixup(struct usbnet *dev, struct sk_buff *skb)skb_pull (skb,3 ); skb->len = len;skb_set_tail_pointer (skb, len); - skb->truesize = len +sizeof (struct sk_buff );return 2 ; } -/* skb_clone is used for address align */ - sr_skb =skb_clone (skb,GFP_ATOMIC ); + sr_skb =netdev_alloc_skb_ip_align (dev->net, len);if (!sr_skb)return 0 ; - sr_skb->len = len; - sr_skb->data = skb->data +3 ; -skb_set_tail_pointer (sr_skb, len); - sr_skb->truesize = len +sizeof (struct sk_buff ); +skb_put (sr_skb, len); +memcpy (sr_skb->data, skb->data +3 , len);usbnet_skb_return (dev, sr_skb);skb_pull (skb, len +SR_RX_OVERHEAD );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 228/427 m68k: Fix spinlock race in kernel thread creation
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Schmitz <[email protected]>
[ Upstream commit da89ce46f02470ef08f0f580755d14d547da59ed ]
Context switching does take care to retain the correct lock owner across the switch from 'prev' to 'next' tasks. This does rely on interrupts remaining disabled for the entire duration of the switch.
This condition is guaranteed for normal process creation and context switching between already running processes, because both 'prev' and 'next' already have interrupts disabled in their saved copies of the status register.
The situation is different for newly created kernel threads. The status register is set to PS_S in copy_thread(), which does leave the IPL at 0. Upon restoring the 'next' thread's status register in switch_to() aka resume(), interrupts then become enabled prematurely. resume() then returns via ret_from_kernel_thread() and schedule_tail() where run queue lock is released (see finish_task_switch() and finish_lock_switch()).
A timer interrupt calling scheduler_tick() before the lock is released in finish_task_switch() will find the lock already taken, with the current task as lock owner. This causes a spinlock recursion warning as reported by Guenter Roeck.
As far as I can ascertain, this race has been opened in commit 533e6903bea0 ("m68k: split ret_from_fork(), simplify kernel_thread()") but I haven't done a detailed study of kernel history so it may well predate that commit.
Interrupts cannot be disabled in the saved status register copy for kernel threads (init will complain about interrupts disabled when finally starting user space). Disable interrupts temporarily when switching the tasks' register sets in resume().
Note that a simple oriw 0x700,%sr after restoring sr is not enough here
- this leaves enough of a race for the 'spinlock recursion' warning to still be observed.
Tested on ARAnyM and qemu (Quadra 800 emulation).
--- arch/m68k/kernel/entry.S | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/m68k/kernel/entry.S +3 -1
@@ -430,7 +430,9 @@ resume: movec %a0,%dfc /* restore status register */ - movew %a1@(TASK_THREAD+THREAD_SR),%sr + movew %a1@(TASK_THREAD+THREAD_SR),%d0 + oriw #0x0700,%d0 + movew %d0,%sr rts
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 229/427 m68k: mac: Fix reboot hang on Mac IIci
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Finn Thain <[email protected]>
[ Upstream commit 265a3b322df9a973ff1fc63da70af456ab6ae1d6 ]
Calling mac_reset() on a Mac IIci does reset the system, but what follows is a POST failure that requires a manual reset to resolve. Avoid that by using the 68030 asm implementation instead of the C implementation.
Apparently the SE/30 has a similar problem as it has used the asm implementation since before git. This patch extends that solution to other systems with a similar ROM.
After this patch, the only systems still using the C implementation are 68040 systems where adb_type is either MAC_ADB_IOP or MAC_ADB_II. This implies a 1 MiB Quadra ROM.
This now includes the Quadra 900/950, which previously fell through to the "should never get here" catch-all.
--- arch/m68k/mac/misc.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-)
arch/m68k/mac/misc.c +18 -18
@@ -453,30 +453,18 @@ void mac_poweroff(void)void mac_reset (void ) { -if (macintosh_config->adb_type ==MAC_ADB_II && - macintosh_config->ident !=MAC_MODEL_SE30 ) { -/* need ROMBASE in booter */ -/* indeed, plus need to MAP THE ROM !! */ - -if (mac_bi_data.rombase ==0 ) - mac_bi_data.rombase =0x40800000 ; - -/* works on some */ - rom_reset = (void *) (mac_bi_data.rombase +0xa ); - -local_irq_disable (); -rom_reset ();#ifdef CONFIG_ADB_CUDA - }else if (macintosh_config->adb_type ==MAC_ADB_EGRET || - macintosh_config->adb_type ==MAC_ADB_CUDA ) { +if (macintosh_config->adb_type ==MAC_ADB_EGRET || + macintosh_config->adb_type ==MAC_ADB_CUDA ) {cuda_restart (); + } else#endif #ifdef CONFIG_ADB_PMU - }else if (macintosh_config->adb_type ==MAC_ADB_PB2 ) { +if (macintosh_config->adb_type ==MAC_ADB_PB2 ) {pmu_restart (); + } else#endif - }else if (CPU_IS_030 ) { - +if (CPU_IS_030 ) {/* 030-specific reset routine. The idea is general, but the * specific registers to reset are '030-specific. Until I * have a non-030 machine, I can't test anything else.
@@ -524,6 +512,18 @@ void mac_reset(void) "jmp %/a0@\n\t" /* jump to the reset vector */ ".chip 68k" : : "r" (offset), "a" (rombase) : "a0"); + }else { +/* need ROMBASE in booter */ +/* indeed, plus need to MAP THE ROM !! */ + +if (mac_bi_data.rombase ==0 ) + mac_bi_data.rombase =0x40800000 ; + +/* works on some */ + rom_reset = (void *)(mac_bi_data.rombase +0xa ); + +local_irq_disable (); +rom_reset (); }/* should never get here */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 230/427 m68k: Move ARCH_HAS_CPU_CACHE_ALIASING
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <[email protected]>
[ Upstream commit c66b7b950bbf45eadcdee467e53f80568f4a0a7f ]
Move the recently added ARCH_HAS_CPU_CACHE_ALIASING to restore alphabetical sort order.
--- arch/m68k/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/m68k/Kconfig +1 -1
@@ -3,8 +3,8 @@ config M68K bool default y select ARCH_32BIT_OFF_T - select ARCH_HAS_CPU_CACHE_ALIASING select ARCH_HAS_BINFMT_FLAT + select ARCH_HAS_CPU_CACHE_ALIASING select ARCH_HAS_CPU_FINALIZE_INIT if MMU select ARCH_HAS_CURRENT_STACK_POINTER select ARCH_HAS_DMA_PREP_COHERENT if M68K_NONCOHERENT_DMA && !COLDFIRE
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 231/427 selftests: Compile kselftest headers with -D_GNU_SOURCE
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Edward Liaw <[email protected]>
[ Upstream commit daef47b89efd0b745e8478d69a3ad724bd8b4dc6 ]
Add the -D_GNU_SOURCE flag to KHDR_INCLUDES so that it is defined in a central location.
Commit 809216233555 ("selftests/harness: remove use of LINE_MAX") introduced asprintf into kselftest_harness.h, which is a GNU extension and needs _GNU_SOURCE to either be defined prior to including headers or with the -D_GNU_SOURCE flag passed to the compiler.
Fixed up commit log:
Shuah Khan <[email protected]>
--- tools/testing/selftests/Makefile | 4 ++-- tools/testing/selftests/kselftest_harness.h | 2 +- tools/testing/selftests/lib.mk | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
tools/testing/selftests/Makefile +2 -2
@@ -161,11 +161,11 @@ ifneq ($(KBUILD_OUTPUT),) # $(realpath ...) resolves symlinks abs_objtree := $(realpath $(abs_objtree)) BUILD := $(abs_objtree)/kselftest - KHDR_INCLUDES := -isystem ${abs_objtree}/usr/include + KHDR_INCLUDES := -D_GNU_SOURCE -isystem ${abs_objtree}/usr/include else BUILD := $(CURDIR) abs_srctree := $(shell cd $(top_srcdir) && pwd) - KHDR_INCLUDES := -isystem ${abs_srctree}/usr/include + KHDR_INCLUDES := -D_GNU_SOURCE -isystem ${abs_srctree}/usr/include DEFAULT_INSTALL_HDR_PATH := 1 endif
tools/testing/selftests/kselftest_harness.h +1 -1
@@ -51,7 +51,7 @@#define __KSELFTEST_HARNESS_H#ifndef _GNU_SOURCE -#define _GNU_SOURCE +static_assert (0 ,"kselftest harness requires _GNU_SOURCE to be defined" );#endif #include <asm/types.h> #include <ctype.h>
tools/testing/selftests/lib.mk +1 -1
@@ -53,7 +53,7 @@ selfdir = $(realpath $(dir $(filter %/lib.mk,$(MAKEFILE_LIST)))) top_srcdir = $(selfdir)/../../.. ifeq ($(KHDR_INCLUDES),) -KHDR_INCLUDES := -isystem $(top_srcdir)/usr/include +KHDR_INCLUDES := -D_GNU_SOURCE -isystem $(top_srcdir)/usr/include endif # The following are built by lib.mk common compile rules.
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 232/427 selftests/sgx: Include KHDR_INCLUDES in Makefile
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Edward Liaw <[email protected]>
[ Upstream commit 2c3b8f8f37c6c0c926d584cf4158db95e62b960c ]
Add KHDR_INCLUDES to the CFLAGS to pull in the kselftest harness dependencies (-D_GNU_SOURCE).
Also, remove redefinitions of _GNU_SOURCE in the source code.
--- tools/testing/selftests/sgx/Makefile | 2 +- tools/testing/selftests/sgx/sigstruct.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-)
tools/testing/selftests/sgx/Makefile +1 -1
@@ -12,7 +12,7 @@ OBJCOPY := $(CROSS_COMPILE)objcopy endif INCLUDES := -I$(top_srcdir)/tools/include -HOST_CFLAGS := -Wall -Werror -g $(INCLUDES) -fPIC +HOST_CFLAGS := -Wall -Werror $(KHDR_INCLUDES) -g $(INCLUDES) -fPIC HOST_LDFLAGS := -z noexecstack -lcrypto ENCL_CFLAGS += -Wall -Werror -static-pie -nostdlib -ffreestanding -fPIE \ -fno-stack-protector -mrdrnd $(INCLUDES)
tools/testing/selftests/sgx/sigstruct.c +0 -1
@@ -1,7 +1,6 @@// SPDX-License-Identifier: GPL-2.0 /* Copyright(c) 2016-20 Intel Corporation. */ -#define _GNU_SOURCE#include <assert.h> #include <getopt.h> #include <stdbool.h>
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 233/427 dm-delay: fix workqueue delay_timer race
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Marzinski <[email protected]>
[ Upstream commit 8d24790ed08ab4e619ce58ed4a1b353ab77ffdc5 ]
delay_timer could be pending when delay_dtr() is called. It needs to be shut down before kdelayd_wq is destroyed, so it won't try queueing more work to kdelayd_wq while that's getting destroyed.
Also the del_timer_sync() call in delay_presuspend() doesn't protect against the timer getting immediately rearmed by the queued call to flush_delayed_bios(), but there's no real harm if that does happen. timer_delete() is less work, and is basically just as likely to stop a pointless call to flush_delayed_bios().
--- drivers/md/dm-delay.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/md/dm-delay.c +4 -2
@@ -154,8 +154,10 @@ static void delay_dtr(struct dm_target *ti) {struct delay_c *dc = ti->private; -if (dc->kdelayd_wq) +if (dc->kdelayd_wq) { +timer_shutdown_sync (&dc->delay_timer);destroy_workqueue (dc->kdelayd_wq); + }if (dc->read.dev)dm_put_device (ti, dc->read.dev);
@@ -335,7 +337,7 @@ static void delay_presuspend(struct dm_target *ti)mutex_unlock (&delayed_bios_lock);if (!delay_is_fast (dc)) -del_timer_sync (&dc->delay_timer); +timer_delete (&dc->delay_timer);flush_delayed_bios (dc, true); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 234/427 dm-delay: fix hung task introduced by kthread mode
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joel Colledge <[email protected]>
[ Upstream commit d14646f23300a5fc85be867bafdc0702c2002789 ]
If the worker thread is not woken due to a bio, then it is not woken at all. This causes the hung task check to trigger. This occurs, for instance, when no bios are submitted. Also when a delay of 0 is configured, delay_bio() returns without waking the worker.
Prevent the hung task check from triggering by creating the thread with kthread_run() instead of using kthread_create() directly.
--- drivers/md/dm-delay.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/md/dm-delay.c +1 -2
@@ -269,8 +269,7 @@ static int delay_ctr(struct dm_target *ti, unsigned int argc, char **argv)* In case of small requested delays, use kthread instead of * timers and workqueue to achieve better latency. */ - dc->worker =kthread_create (&flush_worker_fn, dc, -"dm-delay-flush-worker" ); + dc->worker =kthread_run (&flush_worker_fn, dc,"dm-delay-flush-worker" );if (IS_ERR (dc->worker)) { ret =PTR_ERR (dc->worker); dc->worker =NULL ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 235/427 dm-delay: fix max_delay calculations
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Marzinski <[email protected]>
[ Upstream commit 64eb88d6caee2c8eb806a68dab3f184f14f818a4 ]
delay_ctr() pointlessly compared max_delay in cases where multiple delay classes were initialized identically. Also, when write delays were configured different than read delays, delay_ctr() never compared their value against max_delay. Fix these issues.
--- drivers/md/dm-delay.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/md/dm-delay.c +2 -3
@@ -242,19 +242,18 @@ static int delay_ctr(struct dm_target *ti, unsigned int argc, char **argv) ret =delay_class_ctr (ti, &dc->flush, argv);if (ret) goto bad; - max_delay =max (max_delay, dc->write.delay); - max_delay =max (max_delay, dc->flush.delay); goto out; } ret =delay_class_ctr (ti, &dc->write, argv +3 );if (ret) goto bad; + max_delay =max (max_delay, dc->write.delay); +if (argc ==6 ) { ret =delay_class_ctr (ti, &dc->flush, argv +3 );if (ret) goto bad; - max_delay =max (max_delay, dc->flush.delay); goto out; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 236/427 ptp: ocp: fix DPLL functions
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vadim Fedorenko <[email protected]>
[ Upstream commit a2c78977950da00aca83a3f8865d1f54e715770d ]
In ptp_ocp driver pin actions assume sma_nr starts with 1, but for DPLL subsystem callback 0-based index was used. Fix it providing proper index.
--- drivers/ptp/ptp_ocp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/ptp/ptp_ocp.c +3 -3
@@ -4562,7 +4562,7 @@ static int ptp_ocp_dpll_direction_set(const struct dpll_pin *pin,return -EOPNOTSUPP ; mode = direction ==DPLL_PIN_DIRECTION_INPUT ?SMA_MODE_IN :SMA_MODE_OUT ; -return ptp_ocp_sma_store_val (bp,0 , mode, sma_nr); +return ptp_ocp_sma_store_val (bp,0 , mode, sma_nr +1 ); } static int ptp_ocp_dpll_frequency_set(const struct dpll_pin *pin,
@@ -4583,7 +4583,7 @@ static int ptp_ocp_dpll_frequency_set(const struct dpll_pin *pin, tbl = bp->sma_op->tbl[sma->mode];for (i =0 ; tbl[i].name; i++)if (tbl[i].frequency == frequency) -return ptp_ocp_sma_store_val (bp, i, sma->mode, sma_nr); +return ptp_ocp_sma_store_val (bp, i, sma->mode, sma_nr +1 );return -EINVAL ; }
@@ -4600,7 +4600,7 @@ static int ptp_ocp_dpll_frequency_get(const struct dpll_pin *pin,u32 val;int i; - val = bp->sma_op->get (bp, sma_nr); + val = bp->sma_op->get (bp, sma_nr +1 ); tbl = bp->sma_op->tbl[sma->mode];for (i =0 ; tbl[i].name; i++)if (val == tbl[i].value) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 237/427 net: ipv6: fix wrong start position when receive hop-by-hop fragment
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: gaoxingwang <[email protected]>
[ Upstream commit 1cd354fe1e4864eeaff62f66ee513080ec946f20 ]
In IPv6, ipv6_rcv_core will parse the hop-by-hop type extension header and increase skb->transport_header by one extension header length. But if there are more other extension headers like fragment header at this time, the skb->transport_header points to the second extension header, not the transport layer header or the first extension header.
This will result in the start and nexthdrp variable not pointing to the same position in ipv6frag_thdr_trunced,
and ipv6_skip_exthdr returning incorrect offset and frag_off.Sometimes,the length of the last sharded packet is smaller than the calculated incorrect offset, resulting in packet loss. We can use network header to offset and calculate the correct position to solve this problem.
--- net/ipv6/reassembly.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/reassembly.c +1 -1
@@ -369,7 +369,7 @@ static int ipv6_frag_rcv(struct sk_buff *skb)* the source of the fragment, with the Pointer field set to zero. */ nexthdr = hdr->nexthdr; -if (ipv6frag_thdr_truncated (skb,skb_transport_offset (skb), &nexthdr)) { +if (ipv6frag_thdr_truncated (skb,skb_network_offset (skb) +sizeof (struct ipv6hdr ), &nexthdr)) {__IP6_INC_STATS (net,__in6_dev_get_safely (skb->dev),IPSTATS_MIB_INHDRERRORS );icmpv6_param_prob (skb,ICMPV6_HDR_INCOMP ,0 );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 238/427 eth: sungem: remove .ndo_poll_controller to avoid deadlocks
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit ac0a230f719b02432d8c7eba7615ebd691da86f4 ]
Erhard reports netpoll warnings from sungem:
netpoll_send_skb_on_dev(): eth0 enabled interrupts in poll (gem_start_xmit+0x0/0x398)
WARNING: CPU: 1 PID: 1 at net/core/netpoll.c:370 netpoll_send_skb+0x1fc/0x20c
gem_poll_controller() disables interrupts, which may sleep. We can't sleep in netpoll, it has interrupts disabled completely. Strangely, gem_poll_controller() doesn't even poll the completions, and instead acts as if an interrupt has fired so it just schedules NAPI and exits. None of this has been necessary for years, since netpoll invokes NAPI directly.
--- drivers/net/ethernet/sun/sungem.c | 14 -------------- 1 file changed, 14 deletions(-)
drivers/net/ethernet/sun/sungem.c +0 -14
@@ -949,17 +949,6 @@ static irqreturn_t gem_interrupt(int irq, void *dev_id)return IRQ_HANDLED ; } -#ifdef CONFIG_NET_POLL_CONTROLLER -static void gem_poll_controller (struct net_device *dev) -{ -struct gem *gp =netdev_priv (dev); - -disable_irq (gp->pdev->irq); -gem_interrupt (gp->pdev->irq, dev); -enable_irq (gp->pdev->irq); -} -#endif -static void gem_tx_timeout (struct net_device *dev,unsigned int txqueue) {struct gem *gp =netdev_priv (dev);
@@ -2839,9 +2828,6 @@ static const struct net_device_ops gem_netdev_ops = { .ndo_change_mtu = gem_change_mtu, .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = gem_set_mac_address, -#ifdef CONFIG_NET_POLL_CONTROLLER - .ndo_poll_controller = gem_poll_controller, -#endif };static int gem_init_one (struct pci_dev *pdev,const struct pci_device_id *ent)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 239/427 selftests: net: add missing config for amt.sh
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit c499fe96d3f75a5cf50de6089dd8f1cddd1301a9 ]
Test needs IPv6 multicast. smcroute currently crashes when trying to install a route in a kernel without IPv6 multicast.
--- tools/testing/selftests/net/config | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/net/config +1 -0
@@ -30,6 +30,7 @@ CONFIG_IP_GRE=m CONFIG_NETFILTER=y CONFIG_NETFILTER_ADVANCED=y CONFIG_NF_CONNTRACK=m +CONFIG_IPV6_MROUTE=y CONFIG_IPV6_SIT=y CONFIG_IP_DCCP=m CONFIG_NF_NAT=m
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 240/427 selftests: net: move amt to socat for better compatibility
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit 4c639b6a7b9db236c0907aca8e92d1537076f2cd ]
The test seems to expect that nc will exit after the first received message. This is not the case with Ncat 7.94. There are multiple versions of nc out there, switch to socat for better compatibility.
Tell socat to exit after 128 bytes and pad the message.
Since the test sets -e make sure we don't set exit code (|| true) and print the pass / fail rather then silently moving over the test and just setting non-zero exit code with no output indicating what failed.
--- tools/testing/selftests/net/amt.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
tools/testing/selftests/net/amt.sh +6 -6
@@ -210,8 +210,8 @@ check_features() test_ipv4_forward() { - RESULT4=$(ip netns exec "${LISTENER}" nc -w 1 -l -u 239.0.0.1 4000) - if [ "$RESULT4" == "172.17.0.2" ]; then + RESULT4=$(ip netns exec "${LISTENER}" timeout 15 socat - UDP4-LISTEN:4000,readbytes=128 || true) + if echo "$RESULT4" | grep -q "172.17.0.2"; then printf "TEST: %-60s [ OK ]\n" "IPv4 amt multicast forwarding" exit 0 else
@@ -222,8 +222,8 @@ test_ipv4_forward() test_ipv6_forward() { - RESULT6=$(ip netns exec "${LISTENER}" nc -w 1 -l -u ff0e::5:6 6000) - if [ "$RESULT6" == "2001:db8:3::2" ]; then + RESULT6=$(ip netns exec "${LISTENER}" timeout 15 socat - UDP6-LISTEN:6000,readbytes=128 || true) + if echo "$RESULT6" | grep -q "2001:db8:3::2"; then printf "TEST: %-60s [ OK ]\n" "IPv6 amt multicast forwarding" exit 0 else
@@ -236,14 +236,14 @@ send_mcast4() { sleep 2 ip netns exec "${SOURCE}" bash -c \ - 'echo 172.17.0.2 | nc -w 1 -u 239.0.0.1 4000' & + 'printf "%s %128s" 172.17.0.2 | nc -w 1 -u 239.0.0.1 4000' & } send_mcast6() { sleep 2 ip netns exec "${SOURCE}" bash -c \ - 'echo 2001:db8:3::2 | nc -w 1 -u ff0e::5:6 6000' & + 'printf "%s %128s" 2001:db8:3::2 | nc -w 1 -u ff0e::5:6 6000' & } check_features
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 241/427 net: ethernet: mediatek: split tx and rx fields in mtk_soc_data struct
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Bianconi <[email protected]>
[ Upstream commit ecb51fa37ee22f137a87fa140b1e9f1759949f9a ]
Split tx and rx fields in mtk_soc_data struct. This is a preliminary patch to roll back to ADMAv1 for MT7986 and MT7981 SoC in order to fix a hw hang if the device receives a corrupted packet when using ADMAv2.0.
--- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 210 ++++++++++++-------- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 29 +-- 2 files changed, 139 insertions(+), 100 deletions(-)
drivers/net/ethernet/mediatek/mtk_eth_soc.c +123 -87
@@ -1139,7 +1139,7 @@ static int mtk_init_fq_dma(struct mtk_eth *eth) eth->scratch_ring = eth->sram_base; else eth->scratch_ring = dma_alloc_coherent(eth->dma_dev, - cnt * soc->txrx.txd_size, + cnt * soc->tx.desc_size, ð->phy_scratch_ring,GFP_KERNEL );if (unlikely (!eth->scratch_ring))
@@ -1155,17 +1155,17 @@ static int mtk_init_fq_dma(struct mtk_eth *eth)if (unlikely (dma_mapping_error (eth->dma_dev, dma_addr)))return -ENOMEM ; - phy_ring_tail = eth->phy_scratch_ring + soc->txrx.txd_size * (cnt -1 ); + phy_ring_tail = eth->phy_scratch_ring + soc->tx.desc_size * (cnt -1 );for (i =0 ; i < cnt; i++) {dma_addr_t addr = dma_addr + i *MTK_QDMA_PAGE_SIZE ;struct mtk_tx_dma_v2 *txd; - txd = eth->scratch_ring + i * soc->txrx.txd_size; + txd = eth->scratch_ring + i * soc->tx.desc_size; txd->txd1 = addr;if (i < cnt -1 ) txd->txd2 = eth->phy_scratch_ring + - (i +1 ) * soc->txrx.txd_size; + (i +1 ) * soc->tx.desc_size; txd->txd3 =TX_DMA_PLEN0 (MTK_QDMA_PAGE_SIZE );if (MTK_HAS_CAPS (soc->caps,MTK_36BIT_DMA ))
@@ -1416,7 +1416,7 @@ static int mtk_tx_map(struct sk_buff *skb, struct net_device *dev,if (itxd == ring->last_free)return -ENOMEM ; - itx_buf =mtk_desc_to_tx_buf (ring, itxd, soc->txrx.txd_size); + itx_buf =mtk_desc_to_tx_buf (ring, itxd, soc->tx.desc_size);memset (itx_buf,0 ,sizeof (*itx_buf)); txd_info.addr = dma_map_single(eth->dma_dev, skb->data, txd_info.size,
@@ -1457,7 +1457,7 @@ static int mtk_tx_map(struct sk_buff *skb, struct net_device *dev,memset (&txd_info,0 ,sizeof (struct mtk_tx_dma_desc_info )); txd_info.size = min_t(unsigned int, frag_size, - soc->txrx.dma_max_len); + soc->tx.dma_max_len); txd_info.qid = queue; txd_info.last = i ==skb_shinfo (skb)->nr_frags -1 && !(frag_size - txd_info.size);
@@ -1470,7 +1470,7 @@ static int mtk_tx_map(struct sk_buff *skb, struct net_device *dev,mtk_tx_set_dma_desc (dev, txd, &txd_info); tx_buf =mtk_desc_to_tx_buf (ring, txd, - soc->txrx.txd_size); + soc->tx.desc_size);if (new_desc)memset (tx_buf,0 ,sizeof (*tx_buf)); tx_buf->data = (void *)MTK_DMA_DUMMY_DESC ;
@@ -1513,7 +1513,7 @@ static int mtk_tx_map(struct sk_buff *skb, struct net_device *dev, }else {int next_idx; - next_idx =NEXT_DESP_IDX (txd_to_idx (ring, txd, soc->txrx.txd_size), + next_idx =NEXT_DESP_IDX (txd_to_idx (ring, txd, soc->tx.desc_size), ring->dma_size);mtk_w32 (eth, next_idx,MT7628_TX_CTX_IDX0 ); }
@@ -1522,7 +1522,7 @@ static int mtk_tx_map(struct sk_buff *skb, struct net_device *dev, err_dma: do { - tx_buf = mtk_desc_to_tx_buf(ring, itxd, soc->txrx.txd_size); + tx_buf = mtk_desc_to_tx_buf(ring, itxd, soc->tx.desc_size); /* unmap dma */ mtk_tx_unmap(eth, tx_buf, NULL, false);
@@ -1547,7 +1547,7 @@ static int mtk_cal_txd_req(struct mtk_eth *eth, struct sk_buff *skb)for (i =0 ; i <skb_shinfo (skb)->nr_frags; i++) { frag = &skb_shinfo (skb)->frags[i]; nfrags +=DIV_ROUND_UP (skb_frag_size (frag), - eth->soc->txrx.dma_max_len); + eth->soc->tx.dma_max_len); } }else { nfrags +=skb_shinfo (skb)->nr_frags;
@@ -1654,7 +1654,7 @@ static struct mtk_rx_ring *mtk_get_rx_ring(struct mtk_eth *eth) ring = ð->rx_ring[i]; idx =NEXT_DESP_IDX (ring->calc_idx, ring->dma_size); - rxd = ring->dma + idx * eth->soc->txrx.rxd_size; + rxd = ring->dma + idx * eth->soc->rx.desc_size;if (rxd->rxd2 &RX_DMA_DONE ) { ring->calc_idx_update = true;return ring;
@@ -1822,7 +1822,7 @@ static int mtk_xdp_submit_frame(struct mtk_eth *eth, struct xdp_frame *xdpf, } htxd = txd; - tx_buf =mtk_desc_to_tx_buf (ring, txd, soc->txrx.txd_size); + tx_buf =mtk_desc_to_tx_buf (ring, txd, soc->tx.desc_size);memset (tx_buf,0 ,sizeof (*tx_buf)); htx_buf = tx_buf;
@@ -1841,7 +1841,7 @@ static int mtk_xdp_submit_frame(struct mtk_eth *eth, struct xdp_frame *xdpf, goto unmap; tx_buf =mtk_desc_to_tx_buf (ring, txd, - soc->txrx.txd_size); + soc->tx.desc_size);memset (tx_buf,0 ,sizeof (*tx_buf)); n_desc++; }
@@ -1879,7 +1879,7 @@ static int mtk_xdp_submit_frame(struct mtk_eth *eth, struct xdp_frame *xdpf, }else {int idx; - idx =txd_to_idx (ring, txd, soc->txrx.txd_size); + idx =txd_to_idx (ring, txd, soc->tx.desc_size);mtk_w32 (eth,NEXT_DESP_IDX (idx, ring->dma_size),MT7628_TX_CTX_IDX0 ); }
@@ -1890,7 +1890,7 @@ static int mtk_xdp_submit_frame(struct mtk_eth *eth, struct xdp_frame *xdpf, unmap:while (htxd != txd) { - tx_buf =mtk_desc_to_tx_buf (ring, htxd, soc->txrx.txd_size); + tx_buf =mtk_desc_to_tx_buf (ring, htxd, soc->tx.desc_size);mtk_tx_unmap (eth, tx_buf,NULL , false); htxd->txd3 =TX_DMA_LS0 |TX_DMA_OWNER_CPU ;
@@ -2021,7 +2021,7 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget, goto rx_done; idx =NEXT_DESP_IDX (ring->calc_idx, ring->dma_size); - rxd = ring->dma + idx * eth->soc->txrx.rxd_size; + rxd = ring->dma + idx * eth->soc->rx.desc_size; data = ring->data[idx];if (!mtk_rx_get_desc (eth, &trxd, rxd))
@@ -2156,7 +2156,7 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget, rxdcsum = &trxd.rxd4; } -if (*rxdcsum & eth->soc->txrx.rx_dma_l4_valid) +if (*rxdcsum & eth->soc->rx.dma_l4_valid) skb->ip_summed =CHECKSUM_UNNECESSARY ;else skb_checksum_none_assert (skb);
@@ -2280,7 +2280,7 @@ static int mtk_poll_tx_qdma(struct mtk_eth *eth, int budget,break ; tx_buf =mtk_desc_to_tx_buf (ring, desc, - eth->soc->txrx.txd_size); + eth->soc->tx.desc_size);if (!tx_buf->data)break ;
@@ -2331,7 +2331,7 @@ static int mtk_poll_tx_pdma(struct mtk_eth *eth, int budget, }mtk_tx_unmap (eth, tx_buf, &bq, true); - desc = ring->dma + cpu * eth->soc->txrx.txd_size; + desc = ring->dma + cpu * eth->soc->tx.desc_size; ring->last_free = desc;atomic_inc (&ring->free_count);
@@ -2421,7 +2421,7 @@ static int mtk_napi_rx(struct napi_struct *napi, int budget) do { int rx_done; - mtk_w32(eth, eth->soc->txrx.rx_irq_done_mask, + mtk_w32(eth, eth->soc->rx.irq_done_mask, reg_map->pdma.irq_status); rx_done = mtk_poll_rx(napi, budget - rx_done_total, eth); rx_done_total += rx_done;
@@ -2437,10 +2437,10 @@ static int mtk_napi_rx(struct napi_struct *napi, int budget)return budget; }while (mtk_r32 (eth, reg_map->pdma.irq_status) & - eth->soc->txrx.rx_irq_done_mask); + eth->soc->rx.irq_done_mask);if (napi_complete_done (napi, rx_done_total)) -mtk_rx_irq_enable (eth, eth->soc->txrx.rx_irq_done_mask); +mtk_rx_irq_enable (eth, eth->soc->rx.irq_done_mask);return rx_done_total; }
@@ -2449,7 +2449,7 @@ static int mtk_tx_alloc(struct mtk_eth *eth) {const struct mtk_soc_data *soc = eth->soc;struct mtk_tx_ring *ring = ð->tx_ring; -int i, sz = soc->txrx.txd_size; +int i, sz = soc->tx.desc_size;struct mtk_tx_dma_v2 *txd;int ring_size;u32 ofs, val;
@@ -2572,14 +2572,14 @@ static void mtk_tx_clean(struct mtk_eth *eth) }if (!MTK_HAS_CAPS (soc->caps,MTK_SRAM ) && ring->dma) {dma_free_coherent (eth->dma_dev, - ring->dma_size * soc->txrx.txd_size, + ring->dma_size * soc->tx.desc_size, ring->dma, ring->phys); ring->dma =NULL ; }if (ring->dma_pdma) {dma_free_coherent (eth->dma_dev, - ring->dma_size * soc->txrx.txd_size, + ring->dma_size * soc->tx.desc_size, ring->dma_pdma, ring->phys_pdma); ring->dma_pdma =NULL ; }
@@ -2634,15 +2634,15 @@ static int mtk_rx_alloc(struct mtk_eth *eth, int ring_no, int rx_flag)if (!MTK_HAS_CAPS (eth->soc->caps,MTK_SRAM ) || rx_flag !=MTK_RX_FLAGS_NORMAL ) { ring->dma =dma_alloc_coherent (eth->dma_dev, - rx_dma_size * eth->soc->txrx.rxd_size, - &ring->phys,GFP_KERNEL ); + rx_dma_size * eth->soc->rx.desc_size, + &ring->phys,GFP_KERNEL ); }else {struct mtk_tx_ring *tx_ring = ð->tx_ring; ring->dma = tx_ring->dma + tx_ring_size * - eth->soc->txrx.txd_size * (ring_no +1 ); + eth->soc->tx.desc_size * (ring_no +1 ); ring->phys = tx_ring->phys + tx_ring_size * - eth->soc->txrx.txd_size * (ring_no +1 ); + eth->soc->tx.desc_size * (ring_no +1 ); }if (!ring->dma)
@@ -2653,7 +2653,7 @@ static int mtk_rx_alloc(struct mtk_eth *eth, int ring_no, int rx_flag)dma_addr_t dma_addr;void *data; - rxd = ring->dma + i * eth->soc->txrx.rxd_size; + rxd = ring->dma + i * eth->soc->rx.desc_size;if (ring->page_pool) { data =mtk_page_pool_get_buff (ring->page_pool, &dma_addr,GFP_KERNEL );
@@ -2744,7 +2744,7 @@ static void mtk_rx_clean(struct mtk_eth *eth, struct mtk_rx_ring *ring, bool in_if (!ring->data[i])continue ; - rxd = ring->dma + i * eth->soc->txrx.rxd_size; + rxd = ring->dma + i * eth->soc->rx.desc_size;if (!rxd->rxd1)continue ;
@@ -2761,7 +2761,7 @@ static void mtk_rx_clean(struct mtk_eth *eth, struct mtk_rx_ring *ring, bool in_if (!in_sram && ring->dma) {dma_free_coherent (eth->dma_dev, - ring->dma_size * eth->soc->txrx.rxd_size, + ring->dma_size * eth->soc->rx.desc_size, ring->dma, ring->phys); ring->dma =NULL ; }
@@ -3124,7 +3124,7 @@ static void mtk_dma_free(struct mtk_eth *eth)netdev_reset_queue (eth->netdev[i]);if (!MTK_HAS_CAPS (soc->caps,MTK_SRAM ) && eth->scratch_ring) {dma_free_coherent (eth->dma_dev, -MTK_QDMA_RING_SIZE * soc->txrx.txd_size, +MTK_QDMA_RING_SIZE * soc->tx.desc_size, eth->scratch_ring, eth->phy_scratch_ring); eth->scratch_ring =NULL ; eth->phy_scratch_ring =0 ;
@@ -3174,7 +3174,7 @@ static irqreturn_t mtk_handle_irq_rx(int irq, void *_eth) eth->rx_events++;if (likely (napi_schedule_prep (ð->rx_napi))) { -mtk_rx_irq_disable (eth, eth->soc->txrx.rx_irq_done_mask); +mtk_rx_irq_disable (eth, eth->soc->rx.irq_done_mask);__napi_schedule (ð->rx_napi); }
@@ -3200,9 +3200,9 @@ static irqreturn_t mtk_handle_irq(int irq, void *_eth)const struct mtk_reg_map *reg_map = eth->soc->reg_map;if (mtk_r32 (eth, reg_map->pdma.irq_mask) & - eth->soc->txrx.rx_irq_done_mask) { + eth->soc->rx.irq_done_mask) {if (mtk_r32 (eth, reg_map->pdma.irq_status) & - eth->soc->txrx.rx_irq_done_mask) + eth->soc->rx.irq_done_mask)mtk_handle_irq_rx (irq, _eth); }if (mtk_r32 (eth, reg_map->tx_irq_mask) &MTK_TX_DONE_INT ) {
@@ -3220,10 +3220,10 @@ static void mtk_poll_controller(struct net_device *dev)struct mtk_eth *eth = mac->hw;mtk_tx_irq_disable (eth,MTK_TX_DONE_INT ); -mtk_rx_irq_disable (eth, eth->soc->txrx.rx_irq_done_mask); +mtk_rx_irq_disable (eth, eth->soc->rx.irq_done_mask);mtk_handle_irq_rx (eth->irq[2 ], dev);mtk_tx_irq_enable (eth,MTK_TX_DONE_INT ); - mtk_rx_irq_enable(eth, eth->soc->txrx.rx_irq_done_mask); + mtk_rx_irq_enable(eth, eth->soc->rx.irq_done_mask); }#endif
@@ -3387,7 +3387,7 @@ static int mtk_open(struct net_device *dev)napi_enable (ð->tx_napi);napi_enable (ð->rx_napi);mtk_tx_irq_enable (eth,MTK_TX_DONE_INT ); -mtk_rx_irq_enable (eth, soc->txrx.rx_irq_done_mask); +mtk_rx_irq_enable (eth, soc->rx.irq_done_mask);refcount_set (ð->dma_refcnt,1 ); }else
@@ -3471,7 +3471,7 @@ static int mtk_stop(struct net_device *dev)mtk_gdm_config (eth,MTK_GDMA_DROP_ALL );mtk_tx_irq_disable (eth,MTK_TX_DONE_INT ); -mtk_rx_irq_disable (eth, eth->soc->txrx.rx_irq_done_mask); +mtk_rx_irq_disable (eth, eth->soc->rx.irq_done_mask);napi_disable (ð->tx_napi);napi_disable (ð->rx_napi);
@@ -3947,9 +3947,9 @@ static int mtk_hw_init(struct mtk_eth *eth, bool reset)/* FE int grouping */ mtk_w32 (eth,MTK_TX_DONE_INT , reg_map->pdma.int_grp); -mtk_w32 (eth, eth->soc->txrx.rx_irq_done_mask, reg_map->pdma.int_grp +4 ); +mtk_w32 (eth, eth->soc->rx.irq_done_mask, reg_map->pdma.int_grp +4 );mtk_w32 (eth,MTK_TX_DONE_INT , reg_map->qdma.int_grp); -mtk_w32 (eth, eth->soc->txrx.rx_irq_done_mask, reg_map->qdma.int_grp +4 ); +mtk_w32 (eth, eth->soc->rx.irq_done_mask, reg_map->qdma.int_grp +4 );mtk_w32 (eth,0x21021000 ,MTK_FE_INT_GRP );if (mtk_is_netsys_v3_or_greater (eth)) {
@@ -5039,11 +5039,15 @@ static const struct mtk_soc_data mt2701_data = { .required_clks = MT7623_CLKS_BITMAP, .required_pctl = true, .version = 1, - .txrx = { - .txd_size = sizeof(struct mtk_tx_dma), - .rxd_size = sizeof(struct mtk_rx_dma), - .rx_irq_done_mask = MTK_RX_DONE_INT, - .rx_dma_l4_valid = RX_DMA_L4_VALID, + .tx = { + .desc_size = sizeof(struct mtk_tx_dma), + .dma_max_len = MTK_TX_DMA_BUF_LEN, + .dma_len_offset = 16, + }, + .rx = { + .desc_size = sizeof(struct mtk_rx_dma), + .irq_done_mask = MTK_RX_DONE_INT, + .dma_l4_valid = RX_DMA_L4_VALID, .dma_max_len = MTK_TX_DMA_BUF_LEN, .dma_len_offset = 16, },
@@ -5059,11 +5063,15 @@ static const struct mtk_soc_data mt7621_data = { .offload_version = 1, .hash_offset = 2, .foe_entry_size = MTK_FOE_ENTRY_V1_SIZE, - .txrx = { - .txd_size = sizeof(struct mtk_tx_dma), - .rxd_size = sizeof(struct mtk_rx_dma), - .rx_irq_done_mask = MTK_RX_DONE_INT, - .rx_dma_l4_valid = RX_DMA_L4_VALID, + .tx = { + .desc_size = sizeof(struct mtk_tx_dma), + .dma_max_len = MTK_TX_DMA_BUF_LEN, + .dma_len_offset = 16, + }, + .rx = { + .desc_size = sizeof(struct mtk_rx_dma), + .irq_done_mask = MTK_RX_DONE_INT, + .dma_l4_valid = RX_DMA_L4_VALID, .dma_max_len = MTK_TX_DMA_BUF_LEN, .dma_len_offset = 16, },
@@ -5081,11 +5089,15 @@ static const struct mtk_soc_data mt7622_data = { .hash_offset = 2, .has_accounting = true, .foe_entry_size = MTK_FOE_ENTRY_V1_SIZE, - .txrx = { - .txd_size = sizeof(struct mtk_tx_dma), - .rxd_size = sizeof(struct mtk_rx_dma), - .rx_irq_done_mask = MTK_RX_DONE_INT, - .rx_dma_l4_valid = RX_DMA_L4_VALID, + .tx = { + .desc_size = sizeof(struct mtk_tx_dma), + .dma_max_len = MTK_TX_DMA_BUF_LEN, + .dma_len_offset = 16, + }, + .rx = { + .desc_size = sizeof(struct mtk_rx_dma), + .irq_done_mask = MTK_RX_DONE_INT, + .dma_l4_valid = RX_DMA_L4_VALID, .dma_max_len = MTK_TX_DMA_BUF_LEN, .dma_len_offset = 16, },
@@ -5102,11 +5114,15 @@ static const struct mtk_soc_data mt7623_data = { .hash_offset = 2, .foe_entry_size = MTK_FOE_ENTRY_V1_SIZE, .disable_pll_modes = true, - .txrx = { - .txd_size = sizeof(struct mtk_tx_dma), - .rxd_size = sizeof(struct mtk_rx_dma), - .rx_irq_done_mask = MTK_RX_DONE_INT, - .rx_dma_l4_valid = RX_DMA_L4_VALID, + .tx = { + .desc_size = sizeof(struct mtk_tx_dma), + .dma_max_len = MTK_TX_DMA_BUF_LEN, + .dma_len_offset = 16, + }, + .rx = { + .desc_size = sizeof(struct mtk_rx_dma), + .irq_done_mask = MTK_RX_DONE_INT, + .dma_l4_valid = RX_DMA_L4_VALID, .dma_max_len = MTK_TX_DMA_BUF_LEN, .dma_len_offset = 16, },
@@ -5121,11 +5137,15 @@ static const struct mtk_soc_data mt7629_data = { .required_pctl = false, .has_accounting = true, .version = 1, - .txrx = { - .txd_size = sizeof(struct mtk_tx_dma), - .rxd_size = sizeof(struct mtk_rx_dma), - .rx_irq_done_mask = MTK_RX_DONE_INT, - .rx_dma_l4_valid = RX_DMA_L4_VALID, + .tx = { + .desc_size = sizeof(struct mtk_tx_dma), + .dma_max_len = MTK_TX_DMA_BUF_LEN, + .dma_len_offset = 16, + }, + .rx = { + .desc_size = sizeof(struct mtk_rx_dma), + .irq_done_mask = MTK_RX_DONE_INT, + .dma_l4_valid = RX_DMA_L4_VALID, .dma_max_len = MTK_TX_DMA_BUF_LEN, .dma_len_offset = 16, },
@@ -5143,11 +5163,15 @@ static const struct mtk_soc_data mt7981_data = { .hash_offset = 4, .has_accounting = true, .foe_entry_size = MTK_FOE_ENTRY_V2_SIZE, - .txrx = { - .txd_size = sizeof(struct mtk_tx_dma_v2), - .rxd_size = sizeof(struct mtk_rx_dma_v2), - .rx_irq_done_mask = MTK_RX_DONE_INT_V2, - .rx_dma_l4_valid = RX_DMA_L4_VALID_V2, + .tx = { + .desc_size = sizeof(struct mtk_tx_dma_v2), + .dma_max_len = MTK_TX_DMA_BUF_LEN_V2, + .dma_len_offset = 8, + }, + .rx = { + .desc_size = sizeof(struct mtk_rx_dma_v2), + .irq_done_mask = MTK_RX_DONE_INT_V2, + .dma_l4_valid = RX_DMA_L4_VALID_V2, .dma_max_len = MTK_TX_DMA_BUF_LEN_V2, .dma_len_offset = 8, },
@@ -5165,11 +5189,15 @@ static const struct mtk_soc_data mt7986_data = { .hash_offset = 4, .has_accounting = true, .foe_entry_size = MTK_FOE_ENTRY_V2_SIZE, - .txrx = { - .txd_size = sizeof(struct mtk_tx_dma_v2), - .rxd_size = sizeof(struct mtk_rx_dma_v2), - .rx_irq_done_mask = MTK_RX_DONE_INT_V2, - .rx_dma_l4_valid = RX_DMA_L4_VALID_V2, + .tx = { + .desc_size = sizeof(struct mtk_tx_dma_v2), + .dma_max_len = MTK_TX_DMA_BUF_LEN_V2, + .dma_len_offset = 8, + }, + .rx = { + .desc_size = sizeof(struct mtk_rx_dma_v2), + .irq_done_mask = MTK_RX_DONE_INT_V2, + .dma_l4_valid = RX_DMA_L4_VALID_V2, .dma_max_len = MTK_TX_DMA_BUF_LEN_V2, .dma_len_offset = 8, },
@@ -5187,11 +5215,15 @@ static const struct mtk_soc_data mt7988_data = { .hash_offset = 4, .has_accounting = true, .foe_entry_size = MTK_FOE_ENTRY_V3_SIZE, - .txrx = { - .txd_size = sizeof(struct mtk_tx_dma_v2), - .rxd_size = sizeof(struct mtk_rx_dma_v2), - .rx_irq_done_mask = MTK_RX_DONE_INT_V2, - .rx_dma_l4_valid = RX_DMA_L4_VALID_V2, + .tx = { + .desc_size = sizeof(struct mtk_tx_dma_v2), + .dma_max_len = MTK_TX_DMA_BUF_LEN_V2, + .dma_len_offset = 8, + }, + .rx = { + .desc_size = sizeof(struct mtk_rx_dma_v2), + .irq_done_mask = MTK_RX_DONE_INT_V2, + .dma_l4_valid = RX_DMA_L4_VALID_V2, .dma_max_len = MTK_TX_DMA_BUF_LEN_V2, .dma_len_offset = 8, },
@@ -5204,11 +5236,15 @@ static const struct mtk_soc_data rt5350_data = { .required_clks = MT7628_CLKS_BITMAP, .required_pctl = false, .version = 1, - .txrx = { - .txd_size = sizeof(struct mtk_tx_dma), - .rxd_size = sizeof(struct mtk_rx_dma), - .rx_irq_done_mask = MTK_RX_DONE_INT, - .rx_dma_l4_valid = RX_DMA_L4_VALID_PDMA, + .tx = { + .desc_size = sizeof(struct mtk_tx_dma), + .dma_max_len = MTK_TX_DMA_BUF_LEN, + .dma_len_offset = 16, + }, + .rx = { + .desc_size = sizeof(struct mtk_rx_dma), + .irq_done_mask = MTK_RX_DONE_INT, + .dma_l4_valid = RX_DMA_L4_VALID_PDMA, .dma_max_len = MTK_TX_DMA_BUF_LEN, .dma_len_offset = 16, },
drivers/net/ethernet/mediatek/mtk_eth_soc.h +16 -13
@@ -327,8 +327,8 @@/* QDMA descriptor txd3 */ #define TX_DMA_OWNER_CPU BIT(31)#define TX_DMA_LS0 BIT(30) -#define TX_DMA_PLEN0 (x) (((x) & eth->soc->txrx.dma_max_len) << eth->soc->txrx.dma_len_offset) -#define TX_DMA_PLEN1 (x) ((x) & eth->soc->txrx.dma_max_len) +#define TX_DMA_PLEN0 (x) (((x) & eth->soc->tx.dma_max_len) << eth->soc->tx.dma_len_offset) +#define TX_DMA_PLEN1 (x) ((x) & eth->soc->tx.dma_max_len)#define TX_DMA_SWC BIT(14)#define TX_DMA_PQID GENMASK(3, 0)#define TX_DMA_ADDR64_MASK GENMASK(3, 0)
@@ -348,8 +348,8 @@/* QDMA descriptor rxd2 */ #define RX_DMA_DONE BIT(31)#define RX_DMA_LSO BIT(30) -#define RX_DMA_PREP_PLEN0 (x) (((x) & eth->soc->txrx.dma_max_len) << eth->soc->txrx.dma_len_offset) -#define RX_DMA_GET_PLEN0 (x) (((x) >> eth->soc->txrx.dma_len_offset) & eth->soc->txrx.dma_max_len) +#define RX_DMA_PREP_PLEN0 (x) (((x) & eth->soc->rx.dma_max_len) << eth->soc->rx.dma_len_offset) +#define RX_DMA_GET_PLEN0 (x) (((x) >> eth->soc->rx.dma_len_offset) & eth->soc->rx.dma_max_len)#define RX_DMA_VTAG BIT(15)#define RX_DMA_ADDR64_MASK GENMASK(3, 0)#if IS_ENABLED (CONFIG_64BIT )
@@ -1153,10 +1153,9 @@ struct mtk_reg_map {* @foe_entry_size Foe table entry size. * @has_accounting Bool indicating support for accounting of * offloaded flows. -* @txd_size Tx DMA descriptor size. -* @rxd_size Rx DMA descriptor size. -* @rx_irq_done_mask Rx irq done register mask. -* @rx_dma_l4_valid Rx DMA valid register mask. +* @desc_size Tx/Rx DMA descriptor size. +* @irq_done_mask Rx irq done register mask. +* @dma_l4_valid Rx DMA valid register mask. * @dma_max_len Max DMA tx/rx buffer length. * @dma_len_offset Tx/Rx DMA length field offset. */
@@ -1174,13 +1173,17 @@ struct mtk_soc_data {bool has_accounting;bool disable_pll_modes;struct { -u32 txd_size; -u32 rxd_size; -u32 rx_irq_done_mask; -u32 rx_dma_l4_valid; +u32 desc_size;u32 dma_max_len;u32 dma_len_offset; - } txrx; + } tx; +struct { +u32 desc_size; +u32 irq_done_mask; +u32 dma_l4_valid; +u32 dma_max_len; +u32 dma_len_offset; + } rx; };#define MTK_DMA_MONITOR_TIMEOUT msecs_to_jiffies(1000)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 242/427 net: ethernet: mediatek: use ADMAv1 instead of ADMAv2.0 on MT7981 and MT7986
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Golle <[email protected]>
[ Upstream commit 5e69ff84f3e6cc54502a902043847b37ed78afd4 ]
ADMAv2.0 is plagued by RX hangs which can't easily detected and happen upon receival of a corrupted Ethernet frame.
Use ADMAv1 instead which is also still present and usable, and doesn't suffer from that problem.
--- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 46 ++++++++++----------- 1 file changed, 23 insertions(+), 23 deletions(-)
drivers/net/ethernet/mediatek/mtk_eth_soc.c +23 -23
@@ -110,16 +110,16 @@ static const struct mtk_reg_map mt7986_reg_map = { .tx_irq_mask = 0x461c, .tx_irq_status = 0x4618, .pdma = { - .rx_ptr = 0x6100, - .rx_cnt_cfg = 0x6104, - .pcrx_ptr = 0x6108, - .glo_cfg = 0x6204, - .rst_idx = 0x6208, - .delay_irq = 0x620c, - .irq_status = 0x6220, - .irq_mask = 0x6228, - .adma_rx_dbg0 = 0x6238, - .int_grp = 0x6250, + .rx_ptr = 0x4100, + .rx_cnt_cfg = 0x4104, + .pcrx_ptr = 0x4108, + .glo_cfg = 0x4204, + .rst_idx = 0x4208, + .delay_irq = 0x420c, + .irq_status = 0x4220, + .irq_mask = 0x4228, + .adma_rx_dbg0 = 0x4238, + .int_grp = 0x4250, }, .qdma = { .qtx_cfg = 0x4400,
@@ -1107,7 +1107,7 @@ static bool mtk_rx_get_desc(struct mtk_eth *eth, struct mtk_rx_dma_v2 *rxd, rxd->rxd1 =READ_ONCE (dma_rxd->rxd1); rxd->rxd3 =READ_ONCE (dma_rxd->rxd3); rxd->rxd4 =READ_ONCE (dma_rxd->rxd4); -if (mtk_is_netsys_v2_or_greater (eth)) { +if (mtk_is_netsys_v3_or_greater (eth)) { rxd->rxd5 =READ_ONCE (dma_rxd->rxd5); rxd->rxd6 =READ_ONCE (dma_rxd->rxd6); }
@@ -2028,7 +2028,7 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,break ;/* find out which mac the packet come from. values start at 1 */ -if (mtk_is_netsys_v2_or_greater (eth)) { +if (mtk_is_netsys_v3_or_greater (eth)) {u32 val =RX_DMA_GET_SPORT_V2 (trxd.rxd5);switch (val) {
@@ -2140,7 +2140,7 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget, skb->dev = netdev; bytes += skb->len; -if (mtk_is_netsys_v2_or_greater (eth)) { +if (mtk_is_netsys_v3_or_greater (eth)) { reason =FIELD_GET (MTK_RXD5_PPE_CPU_REASON , trxd.rxd5); hash = trxd.rxd5 &MTK_RXD5_FOE_ENTRY ;if (hash !=MTK_RXD5_FOE_ENTRY )
@@ -2690,7 +2690,7 @@ static int mtk_rx_alloc(struct mtk_eth *eth, int ring_no, int rx_flag) rxd->rxd3 =0 ; rxd->rxd4 =0 ; -if (mtk_is_netsys_v2_or_greater (eth)) { +if (mtk_is_netsys_v3_or_greater (eth)) { rxd->rxd5 =0 ; rxd->rxd6 =0 ; rxd->rxd7 =0 ;
@@ -3893,7 +3893,7 @@ static int mtk_hw_init(struct mtk_eth *eth, bool reset)else mtk_hw_reset (eth); -if (mtk_is_netsys_v2_or_greater (eth)) { +if (mtk_is_netsys_v3_or_greater (eth)) {/* Set FE to PDMAv2 if necessary */ val =mtk_r32 (eth,MTK_FE_GLO_MISC );mtk_w32 (eth, val |BIT (4 ),MTK_FE_GLO_MISC );
@@ -5169,11 +5169,11 @@ static const struct mtk_soc_data mt7981_data = { .dma_len_offset = 8, }, .rx = { - .desc_size = sizeof(struct mtk_rx_dma_v2), - .irq_done_mask = MTK_RX_DONE_INT_V2, + .desc_size = sizeof(struct mtk_rx_dma), + .irq_done_mask = MTK_RX_DONE_INT, .dma_l4_valid = RX_DMA_L4_VALID_V2, - .dma_max_len = MTK_TX_DMA_BUF_LEN_V2, - .dma_len_offset = 8, + .dma_max_len = MTK_TX_DMA_BUF_LEN, + .dma_len_offset = 16, }, };
@@ -5195,11 +5195,11 @@ static const struct mtk_soc_data mt7986_data = { .dma_len_offset = 8, }, .rx = { - .desc_size = sizeof(struct mtk_rx_dma_v2), - .irq_done_mask = MTK_RX_DONE_INT_V2, + .desc_size = sizeof(struct mtk_rx_dma), + .irq_done_mask = MTK_RX_DONE_INT, .dma_l4_valid = RX_DMA_L4_VALID_V2, - .dma_max_len = MTK_TX_DMA_BUF_LEN_V2, - .dma_len_offset = 8, + .dma_max_len = MTK_TX_DMA_BUF_LEN, + .dma_len_offset = 16, }, };
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 243/427 ice: Fix package download algorithm
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Nowlin <[email protected]>
[ Upstream commit 6d51d44ecddb5c2962688ef06e55e4fbc949f04a ]
Previously, the driver assumed that all signature segments would contain one or more buffers to download. In the future, there will be signature segments that will contain no buffers to download.
Correct download flow to allow for signature segments that have zero download buffers and skip the download in this case.
--- drivers/net/ethernet/intel/ice/ice_ddp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/ice/ice_ddp.c +4 -4
@@ -1424,14 +1424,14 @@ ice_dwnld_sign_and_cfg_segs(struct ice_hw *hw, struct ice_pkg_hdr *pkg_hdr, goto exit; } - conf_idx =le32_to_cpu (seg->signed_seg_idx); - start =le32_to_cpu (seg->signed_buf_start); count =le32_to_cpu (seg->signed_buf_count); - state =ice_download_pkg_sig_seg (hw, seg); -if (state) +if (state || !count) goto exit; + conf_idx =le32_to_cpu (seg->signed_seg_idx); + start =le32_to_cpu (seg->signed_buf_start); + state =ice_download_pkg_config_seg (hw, pkg_hdr, conf_idx, start, count);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 244/427 net: ethernet: cortina: Locking fixes
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 812552808f7ff71133fc59768cdc253c5b8ca1bf ]
This fixes a probably long standing problem in the Cortina Gemini ethernet driver: there are some paths in the code where the IRQ registers are written without taking the proper locks.
--- drivers/net/ethernet/cortina/gemini.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/net/ethernet/cortina/gemini.c +10 -2
@@ -1107,10 +1107,13 @@ static void gmac_tx_irq_enable(struct net_device *netdev, {struct gemini_ethernet_port *port =netdev_priv (netdev);struct gemini_ethernet *geth = port->geth; +unsigned long flags;u32 val, mask;netdev_dbg (netdev,"%s device %d\n" , __func__, netdev->dev_id); +spin_lock_irqsave (&geth->irq_lock, flags); + mask =GMAC0_IRQ0_TXQ0_INTS << (6 * netdev->dev_id + txq);if (en)
@@ -1119,6 +1122,8 @@ static void gmac_tx_irq_enable(struct net_device *netdev, val =readl (geth->base +GLOBAL_INTERRUPT_ENABLE_0_REG ); val = en ? val | mask : val & ~mask;writel (val, geth->base +GLOBAL_INTERRUPT_ENABLE_0_REG ); + +spin_unlock_irqrestore (&geth->irq_lock, flags); }static void gmac_tx_irq (struct net_device *netdev,unsigned int txq_num)
@@ -1415,15 +1420,19 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget)union gmac_rxdesc_3 word3;struct page *page =NULL ;unsigned int page_offs; +unsigned long flags;unsigned short r, w;union dma_rwptr rw;dma_addr_t mapping;int frag_nr =0 ; +spin_lock_irqsave (&geth->irq_lock, flags); rw.bits32 =readl (ptr_reg);/* Reset interrupt as all packages until here are taken into account */ writel (DEFAULT_Q0_INT_BIT << netdev->dev_id, geth->base +GLOBAL_INTERRUPT_STATUS_1_REG ); +spin_unlock_irqrestore (&geth->irq_lock, flags); + r = rw.bits.rptr; w = rw.bits.wptr;
@@ -1726,10 +1735,9 @@ static irqreturn_t gmac_irq(int irq, void *data)gmac_update_hw_stats (netdev);if (val & (GMAC0_RX_OVERRUN_INT_BIT << (netdev->dev_id *8 ))) { +spin_lock (&geth->irq_lock);writel (GMAC0_RXDERR_INT_BIT << (netdev->dev_id *8 ), geth->base +GLOBAL_INTERRUPT_STATUS_4_REG ); - -spin_lock (&geth->irq_lock);u64_stats_update_begin (&port->ir_stats_syncp); ++port->stats.rx_fifo_errors;u64_stats_update_end (&port->ir_stats_syncp);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 245/427 af_unix: Fix data races in unix_release_sock/unix_stream_sendmsg
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <[email protected]>
[ Upstream commit 540bf24fba16b88c1b3b9353927204b4f1074e25 ]
A data-race condition has been identified in af_unix. In one data path, the write function unix_release_sock() atomically writes to sk->sk_shutdown using WRITE_ONCE. However, on the reader side, unix_stream_sendmsg() does not read it atomically. Consequently, this issue is causing the following KCSAN splat to occur:
BUG: KCSAN: data-race in unix_release_sock / unix_stream_sendmsg
write (marked) to 0xffff88867256ddbb of 1 bytes by task 7270 on cpu 28: unix_release_sock (net/unix/af_unix.c:640) unix_release (net/unix/af_unix.c:1050) sock_close (net/socket.c:659 net/socket.c:1421) __fput (fs/file_table.c:422) __fput_sync (fs/file_table.c:508) __se_sys_close (fs/open.c:1559 fs/open.c:1541) __x64_sys_close (fs/open.c:1541) x64_sys_call (arch/x86/entry/syscall_64.c:33) do_syscall_64 (arch/x86/entry/common.c:?) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:130) read to 0xffff88867256ddbb of 1 bytes by task 989 on cpu 14: unix_stream_sendmsg (net/unix/af_unix.c:2273) __sock_sendmsg (net/socket.c:730 net/socket.c:745) ____sys_sendmsg (net/socket.c:2584) __sys_sendmmsg (net/socket.c:2638 net/socket.c:2724) __x64_sys_sendmmsg (net/socket.c:2753 net/socket.c:2750 net/socket.c:2750) x64_sys_call (arch/x86/entry/syscall_64.c:33) do_syscall_64 (arch/x86/entry/common.c:?) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:130) value changed: 0x01 -> 0x03
The line numbers are related to commit dd5a440a31fa ("Linux 6.9-rc7").
Commit e1d09c2c2f57 ("af_unix: Fix data races around sk->sk_shutdown.") addressed a comparable issue in the past regarding sk->sk_shutdown. However, it overlooked resolving this particular data path. This patch only offending unix_stream_sendmsg() function, since the other reads seem to be protected by unix_state_lock() as discussed in
--- net/unix/af_unix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/unix/af_unix.c +1 -1
@@ -2270,7 +2270,7 @@ static int unix_stream_sendmsg(struct socket *sock, struct msghdr *msg, goto out_err; } -if (sk->sk_shutdown &SEND_SHUTDOWN ) +if (READ_ONCE (sk->sk_shutdown) &SEND_SHUTDOWN ) goto pipe_err;while (sent < len) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 246/427 net: usb: smsc95xx: stop lying about skb->truesize
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit d50729f1d60bca822ef6d9c1a5fb28d486bd7593 ]
Some usb drivers try to set small skb->truesize and break core networking stacks.
In this patch, I removed one of the skb->truesize override.
I also replaced one skb_clone() by an allocation of a fresh and small skb, to get minimally sized skbs, like we did in commit 1e2c61172342 ("net: cdc_ncm: reduce skb truesize in rx path") and 4ce62d5b2f7a ("net: usb: ax88179_178a:
stop lying about skb->truesize")
v3: also fix a sparse error ( https://lore.kernel.org/oe-kbuild-all/[email protected]/ )
v2: leave the skb_trim() game because smsc95xx_rx_csum_offload()
needs the csum part. (Jakub)
While we are it, use get_unaligned() in smsc95xx_rx_csum_offload().
--- drivers/net/usb/smsc95xx.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/net/usb/smsc95xx.c +7 -8
@@ -1810,9 +1810,11 @@ static int smsc95xx_reset_resume(struct usb_interface *intf)static void smsc95xx_rx_csum_offload (struct sk_buff *skb) { - skb->csum = *(u16 *)(skb_tail_pointer (skb) -2 ); +u16 *csum_ptr = (u16 *)(skb_tail_pointer (skb) -2 ); + + skb->csum = (__force __wsum )get_unaligned (csum_ptr); skb->ip_summed =CHECKSUM_COMPLETE ; -skb_trim (skb, skb->len -2 ); +skb_trim (skb, skb->len -2 );/* remove csum */ }static int smsc95xx_rx_fixup (struct usbnet *dev,struct sk_buff *skb)
@@ -1870,25 +1872,22 @@ static int smsc95xx_rx_fixup(struct usbnet *dev, struct sk_buff *skb)if (dev->net->features &NETIF_F_RXCSUM )smsc95xx_rx_csum_offload (skb);skb_trim (skb, skb->len -4 );/* remove fcs */ - skb->truesize = size +sizeof (struct sk_buff );return 1 ; } - ax_skb =skb_clone (skb,GFP_ATOMIC ); + ax_skb =netdev_alloc_skb_ip_align (dev->net, size);if (unlikely (!ax_skb)) {netdev_warn (dev->net,"Error allocating skb\n" );return 0 ; } - ax_skb->len = size; - ax_skb->data = packet; -skb_set_tail_pointer (ax_skb, size); +skb_put (ax_skb, size); +memcpy (ax_skb->data, packet, size);if (dev->net->features &NETIF_F_RXCSUM )smsc95xx_rx_csum_offload (ax_skb);skb_trim (ax_skb, ax_skb->len -4 );/* remove fcs */ - ax_skb->truesize = size +sizeof (struct sk_buff );usbnet_skb_return (dev, ax_skb); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 247/427 net: openvswitch: fix overwriting ct original tuple for ICMPv6
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Maximets <[email protected]>
[ Upstream commit 7c988176b6c16c516474f6fceebe0f055af5eb56 ]
OVS_PACKET_CMD_EXECUTE has 3 main attributes:
- OVS_PACKET_ATTR_KEY - Packet metadata in a netlink format.
- OVS_PACKET_ATTR_PACKET - Binary packet content.
- OVS_PACKET_ATTR_ACTIONS - Actions to execute on the packet.
OVS_PACKET_ATTR_KEY is parsed first to populate sw_flow_key structure with the metadata like conntrack state, input port, recirculation id, etc. Then the packet itself gets parsed to populate the rest of the keys from the packet headers.
Whenever the packet parsing code starts parsing the ICMPv6 header, it first zeroes out fields in the key corresponding to Neighbor Discovery information even if it is not an ND packet.
It is an 'ipv6.nd' field. However, the 'ipv6' is a union that shares the space between 'nd' and 'ct_orig' that holds the original tuple conntrack metadata parsed from the OVS_PACKET_ATTR_KEY.
ND packets should not normally have conntrack state, so it's fine to share the space, but normal ICMPv6 Echo packets or maybe other types of ICMPv6 can have the state attached and it should not be overwritten.
The issue results in all but the last 4 bytes of the destination address being wiped from the original conntrack tuple leading to incorrect packet matching and potentially executing wrong actions in case this packet recirculates within the datapath or goes back to userspace.
ND fields should not be accessed in non-ND packets, so not clearing them should be fine. Executing memset() only for actual ND packets to avoid the issue.
Initializing the whole thing before parsing is needed because ND packet may not contain all the options.
The issue only affects the OVS_PACKET_CMD_EXECUTE path and doesn't affect packets entering OVS datapath from network interfaces, because in this case CT metadata is populated from skb after the packet is already parsed.
--- net/openvswitch/flow.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/openvswitch/flow.c +2 -1
@@ -561,7 +561,6 @@ static int parse_icmpv6(struct sk_buff *skb, struct sw_flow_key *key,*/ key->tp.src =htons (icmp->icmp6_type); key->tp.dst =htons (icmp->icmp6_code); -memset (&key->ipv6.nd,0 ,sizeof (key->ipv6.nd)); if (icmp->icmp6_code == 0 && (icmp->icmp6_type == NDISC_NEIGHBOUR_SOLICITATION ||
@@ -570,6 +569,8 @@ static int parse_icmpv6(struct sk_buff *skb, struct sw_flow_key *key,struct nd_msg *nd;int offset; +memset (&key->ipv6.nd,0 ,sizeof (key->ipv6.nd)); +/* In order to process neighbor discovery options, we need the * entire packet. */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 248/427 ipv6: sr: add missing seg6_local_exit
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hangbin Liu <[email protected]>
[ Upstream commit 3321687e321307629c71b664225b861ebf3e5753 ]
Currently, we only call seg6_local_exit() in seg6_init() if seg6_local_init() failed. But forgot to call it in seg6_exit().
--- net/ipv6/seg6.c | 1 + 1 file changed, 1 insertion(+)
net/ipv6/seg6.c +1 -0
@@ -564,6 +564,7 @@ void seg6_exit(void)seg6_hmac_exit ();#endif #ifdef CONFIG_IPV6_SEG6_LWTUNNEL +seg6_local_exit ();seg6_iptunnel_exit ();#endif unregister_pernet_subsys (&ip6_segments_ops);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 249/427 ipv6: sr: fix incorrect unregister order
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hangbin Liu <[email protected]>
[ Upstream commit 6e370a771d2985107e82d0f6174381c1acb49c20 ]
Commit 5559cea2d5aa ("ipv6: sr: fix possible use-after-free and null-ptr-deref") changed the register order in seg6_init(). But the unregister order in seg6_exit() is not updated.
--- net/ipv6/seg6.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/seg6.c +1 -1
@@ -567,6 +567,6 @@ void seg6_exit(void)seg6_local_exit ();seg6_iptunnel_exit ();#endif -unregister_pernet_subsys (&ip6_segments_ops);genl_unregister_family (&seg6_genl_family); +unregister_pernet_subsys (&ip6_segments_ops); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 250/427 ipv6: sr: fix invalid unregister error path
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hangbin Liu <[email protected]>
[ Upstream commit 160e9d2752181fcf18c662e74022d77d3164cd45 ]
The error path of seg6_init() is wrong in case CONFIG_IPV6_SEG6_LWTUNNEL is not defined. In that case if seg6_hmac_init() fails, the genl_unregister_family() isn't called.
This issue exist since commit 46738b1317e1 ("ipv6: sr: add option to control lwtunnel support"), and commit 5559cea2d5aa ("ipv6: sr: fix possible use-after-free and null-ptr-deref") replaced unregister_pernet_subsys() with genl_unregister_family() in this error path.
--- net/ipv6/seg6.c | 2 ++ 1 file changed, 2 insertions(+)
net/ipv6/seg6.c +2 -0
@@ -551,6 +551,8 @@ int __init seg6_init(void)#endif #ifdef CONFIG_IPV6_SEG6_LWTUNNEL out_unregister_genl: +#endif +#if IS_ENABLED (CONFIG_IPV6_SEG6_LWTUNNEL ) ||IS_ENABLED (CONFIG_IPV6_SEG6_HMAC )genl_unregister_family (&seg6_genl_family);#endif out_unregister_pernet:
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 251/427 net/mlx5e: Fix netif state handling
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shay Drory <[email protected]>
[ Upstream commit 3d5918477f94e4c2f064567875c475468e264644 ]
mlx5e_suspend cleans resources only if netif_device_present() returns true. However, mlx5e_resume changes the state of netif, via mlx5e_nic_enable, only if reg_state == NETREG_REGISTERED. In the below case, the above leads to NULL-ptr Oops[1] and memory leaks:
mlx5e_probe
_mlx5e_resume
mlx5e_attach_netdev
mlx5e_nic_enable <-- netdev not reg, not calling netif_device_attach()
register_netdev <-- failed for some reason.ERROR_FLOW:
_mlx5e_suspend <-- netif_device_present return false, resources aren't freed :(
Hence, clean resources in this case as well.
[1]
BUG: kernel NULL pointer dereference, address: 0000000000000000 PGD 0 P4D 0 Oops: 0010 [#1] SMP CPU: 2 PID: 9345 Comm: test-ovs-ct-gen Not tainted 6.5.0_for_upstream_min_debug_2023_09_05_16_01 #1 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014 RIP: 0010:0x0 Code: Unable to access opcode bytes at0xffffffffffffffd6. RSP: 0018:ffff888178aaf758 EFLAGS: 00010246 Call Trace: <TASK> ? __die+0x20/0x60 ? page_fault_oops+0x14c/0x3c0 ? exc_page_fault+0x75/0x140 ? asm_exc_page_fault+0x22/0x30 notifier_call_chain+0x35/0xb0 blocking_notifier_call_chain+0x3d/0x60 mlx5_blocking_notifier_call_chain+0x22/0x30 [mlx5_core] mlx5_core_uplink_netdev_event_replay+0x3e/0x60 [mlx5_core] mlx5_mdev_netdev_track+0x53/0x60 [mlx5_ib] mlx5_ib_roce_init+0xc3/0x340 [mlx5_ib] __mlx5_ib_add+0x34/0xd0 [mlx5_ib] mlx5r_probe+0xe1/0x210 [mlx5_ib] ? auxiliary_match_id+0x6a/0x90 auxiliary_bus_probe+0x38/0x80 ? driver_sysfs_add+0x51/0x80 really_probe+0xc9/0x3e0 ? driver_probe_device+0x90/0x90 __driver_probe_device+0x80/0x160 driver_probe_device+0x1e/0x90 __device_attach_driver+0x7d/0x100 bus_for_each_drv+0x80/0xd0 __device_attach+0xbc/0x1f0 bus_probe_device+0x86/0xa0 device_add+0x637/0x840 __auxiliary_device_add+0x3b/0xa0 add_adev+0xc9/0x140 [mlx5_core] mlx5_rescan_drivers_locked+0x22a/0x310 [mlx5_core] mlx5_register_device+0x53/0xa0 [mlx5_core] mlx5_init_one_devl_locked+0x5c4/0x9c0 [mlx5_core] mlx5_init_one+0x3b/0x60 [mlx5_core] probe_one+0x44c/0x730 [mlx5_core] local_pci_probe+0x3e/0x90 pci_device_probe+0xbf/0x210 ? kernfs_create_link+0x5d/0xa0 ? sysfs_do_create_link_sd+0x60/0xc0 really_probe+0xc9/0x3e0 ? driver_probe_device+0x90/0x90 __driver_probe_device+0x80/0x160 driver_probe_device+0x1e/0x90 __device_attach_driver+0x7d/0x100 bus_for_each_drv+0x80/0xd0 __device_attach+0xbc/0x1f0 pci_bus_add_device+0x54/0x80 pci_iov_add_virtfn+0x2e6/0x320 sriov_enable+0x208/0x420 mlx5_core_sriov_configure+0x9e/0x200 [mlx5_core] sriov_numvfs_store+0xae/0x1a0 kernfs_fop_write_iter+0x10c/0x1a0 vfs_write+0x291/0x3c0 ksys_write+0x5f/0xe0 do_syscall_64+0x3d/0x90 entry_SYSCALL_64_after_hwframe+0x46/0xb0 CR2: 0000000000000000 ---[ end trace 0000000000000000 ]---
--- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +5 -5
@@ -6058,7 +6058,7 @@ static int mlx5e_resume(struct auxiliary_device *adev)return 0 ; } -static int _mlx5e_suspend (struct auxiliary_device *adev) +static int _mlx5e_suspend (struct auxiliary_device *adev,bool pre_netdev_reg) {struct mlx5e_dev *mlx5e_dev =auxiliary_get_drvdata (adev);struct mlx5e_priv *priv = mlx5e_dev->priv;
@@ -6067,7 +6067,7 @@ static int _mlx5e_suspend(struct auxiliary_device *adev)struct mlx5_core_dev *pos;int i; -if (!netif_device_present (netdev)) { +if (!pre_netdev_reg && !netif_device_present (netdev)) {if (test_bit (MLX5E_STATE_DESTROYING , &priv->state))mlx5_sd_for_each_dev (i, mdev, pos)mlx5e_destroy_mdev_resources (pos);
@@ -6090,7 +6090,7 @@ static int mlx5e_suspend(struct auxiliary_device *adev, pm_message_t state) actual_adev =mlx5_sd_get_adev (mdev, adev, edev->idx);if (actual_adev) - err =_mlx5e_suspend (actual_adev); + err =_mlx5e_suspend (actual_adev, false);mlx5_sd_cleanup (mdev);return err;
@@ -6157,7 +6157,7 @@ static int _mlx5e_probe(struct auxiliary_device *adev)return 0 ; err_resume: -_mlx5e_suspend (adev); +_mlx5e_suspend (adev, true); err_profile_cleanup: profile->cleanup (priv); err_destroy_netdev:
@@ -6197,7 +6197,7 @@ static void _mlx5e_remove(struct auxiliary_device *adev)mlx5_core_uplink_netdev_set (mdev,NULL );mlx5e_dcbnl_delete_app (priv);unregister_netdev (priv->netdev); -_mlx5e_suspend (adev); +_mlx5e_suspend (adev, false); priv->profile->cleanup (priv);mlx5e_destroy_netdev (priv);mlx5e_devlink_port_unregister (mlx5e_dev);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 252/427 net/mlx5: Fix peer devlink set for SF representor devlink port
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shay Drory <[email protected]>
[ Upstream commit 3c453e8cc672de1f9c662948dba43176bc68d7f0 ]
The cited patch change register devlink flow, and neglect to reflect the changes for peer devlink set logic. Peer devlink set is triggering a call trace if done after devl_register.[1]
Hence, align peer devlink set logic with register devlink flow.
[1]
WARNING: CPU: 4 PID: 3394 at net/devlink/core.c:155 devlink_rel_nested_in_add+0x177/0x180 CPU: 4 PID: 3394 Comm: kworker/u40:1 Not tainted 6.9.0-rc4_for_linust_min_debug_2024_04_16_14_08 #1 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014 Workqueue: mlx5_vhca_event0 mlx5_vhca_state_work_handler [mlx5_core] RIP: 0010:devlink_rel_nested_in_add+0x177/0x180 Call Trace: <TASK> ? __warn+0x78/0x120 ? devlink_rel_nested_in_add+0x177/0x180 ? report_bug+0x16d/0x180 ? handle_bug+0x3c/0x60 ? exc_invalid_op+0x14/0x70 ? asm_exc_invalid_op+0x16/0x20 ? devlink_port_init+0x30/0x30 ? devlink_port_type_clear+0x50/0x50 ? devlink_rel_nested_in_add+0x177/0x180 ? devlink_rel_nested_in_add+0xdd/0x180 mlx5_sf_mdev_event+0x74/0xb0 [mlx5_core] notifier_call_chain+0x35/0xb0 blocking_notifier_call_chain+0x3d/0x60 mlx5_blocking_notifier_call_chain+0x22/0x30 [mlx5_core] mlx5_sf_dev_probe+0x185/0x3e0 [mlx5_core] auxiliary_bus_probe+0x38/0x80 ? driver_sysfs_add+0x51/0x80 really_probe+0xc5/0x3a0 ? driver_probe_device+0x90/0x90 __driver_probe_device+0x80/0x160 driver_probe_device+0x1e/0x90 __device_attach_driver+0x7d/0x100 bus_for_each_drv+0x80/0xd0 __device_attach+0xbc/0x1f0 bus_probe_device+0x86/0xa0 device_add+0x64f/0x860 __auxiliary_device_add+0x3b/0xa0 mlx5_sf_dev_add+0x139/0x330 [mlx5_core] mlx5_sf_dev_state_change_handler+0x1e4/0x250 [mlx5_core] notifier_call_chain+0x35/0xb0 blocking_notifier_call_chain+0x3d/0x60 mlx5_vhca_state_work_handler+0x151/0x200 [mlx5_core] process_one_work+0x13f/0x2e0 worker_thread+0x2bd/0x3c0 ? rescuer_thread+0x410/0x410 kthread+0xc4/0xf0 ? kthread_complete_and_exit+0x20/0x20 ret_from_fork+0x2d/0x50 ? kthread_complete_and_exit+0x20/0x20 ret_from_fork_asm+0x11/0x20 </TASK>
--- .../net/ethernet/mellanox/mlx5/core/main.c | 14 +++++--------- .../mellanox/mlx5/core/sf/dev/driver.c | 19 ++++++++----------- 2 files changed, 13 insertions(+), 20 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/main.c +5 -9
@@ -1680,6 +1680,8 @@ int mlx5_init_one_light(struct mlx5_core_dev *dev)struct devlink *devlink =priv_to_devlink (dev);int err; +devl_lock (devlink); +devl_register (devlink); dev->state =MLX5_DEVICE_STATE_UP ; err =mlx5_function_enable (dev, true,mlx5_tout_ms (dev,FW_PRE_INIT_TIMEOUT ));if (err) {
@@ -1693,27 +1695,21 @@ int mlx5_init_one_light(struct mlx5_core_dev *dev) goto query_hca_caps_err; } -devl_lock (devlink); -devl_register (devlink); - err =mlx5_devlink_params_register (priv_to_devlink (dev));if (err) {mlx5_core_warn (dev,"mlx5_devlink_param_reg err = %d\n" , err); - goto params_reg_err; + goto query_hca_caps_err; }devl_unlock (devlink);return 0 ; -params_reg_err: -devl_unregister (devlink); -devl_unlock (devlink); query_hca_caps_err: -devl_unregister (devlink); -devl_unlock (devlink);mlx5_function_disable (dev, true); out: dev->state =MLX5_DEVICE_STATE_INTERNAL_ERROR ; +devl_unregister (devlink); +devl_unlock (devlink);return err; }
drivers/net/ethernet/mellanox/mlx5/core/sf/dev/driver.c +8 -11
@@ -60,6 +60,13 @@ static int mlx5_sf_dev_probe(struct auxiliary_device *adev, const struct auxilia goto remap_err; } +/* Peer devlink logic expects to work on unregistered devlink instance. */ + err =mlx5_core_peer_devlink_set (sf_dev, devlink); +if (err) { +mlx5_core_warn (mdev,"mlx5_core_peer_devlink_set err=%d\n" , err); + goto peer_devlink_set_err; + } +if (MLX5_ESWITCH_MANAGER (sf_dev->parent_mdev)) err =mlx5_init_one_light (mdev);else
@@ -69,20 +76,10 @@ static int mlx5_sf_dev_probe(struct auxiliary_device *adev, const struct auxilia goto init_one_err; } - err =mlx5_core_peer_devlink_set (sf_dev, devlink); -if (err) { -mlx5_core_warn (mdev,"mlx5_core_peer_devlink_set err=%d\n" , err); - goto peer_devlink_set_err; - } -return 0 ; -peer_devlink_set_err: -if (mlx5_dev_is_lightweight (sf_dev->mdev)) -mlx5_uninit_one_light (sf_dev->mdev); -else -mlx5_uninit_one (sf_dev->mdev); init_one_err: +peer_devlink_set_err:iounmap (mdev->iseg); remap_err:mlx5_mdev_uninit (mdev);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 253/427 net/mlx5: Reload only IB representors upon lag disable/enable
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maher Sanalla <[email protected]>
[ Upstream commit 0f06228d4a2dcc1fca5b3ddb0eefa09c05b102c4 ]
On lag disable, the bond IB device along with all of its representors are destroyed, and then the slaves' representors get reloaded.
In case the slave IB representor load fails, the eswitch error flow unloads all representors, including ethernet representors, where the netdevs get detached and removed from lag bond. Such flow is inaccurate as the lag driver is not responsible for loading/unloading ethernet representors. Furthermore, the flow described above begins by holding lag lock to prevent bond changes during disable flow. However, when reaching the ethernet representors detachment from lag, the lag lock is required again, triggering the following deadlock:
Call trace: __switch_to+0xf4/0x148 __schedule+0x2c8/0x7d0 schedule+0x50/0xe0 schedule_preempt_disabled+0x18/0x28 __mutex_lock.isra.13+0x2b8/0x570 __mutex_lock_slowpath+0x1c/0x28 mutex_lock+0x4c/0x68 mlx5_lag_remove_netdev+0x3c/0x1a0 [mlx5_core] mlx5e_uplink_rep_disable+0x70/0xa0 [mlx5_core] mlx5e_detach_netdev+0x6c/0xb0 [mlx5_core] mlx5e_netdev_change_profile+0x44/0x138 [mlx5_core] mlx5e_netdev_attach_nic_profile+0x28/0x38 [mlx5_core] mlx5e_vport_rep_unload+0x184/0x1b8 [mlx5_core] mlx5_esw_offloads_rep_load+0xd8/0xe0 [mlx5_core] mlx5_eswitch_reload_reps+0x74/0xd0 [mlx5_core] mlx5_disable_lag+0x130/0x138 [mlx5_core] mlx5_lag_disable_change+0x6c/0x70 [mlx5_core] // hold ldev->lock mlx5_devlink_eswitch_mode_set+0xc0/0x410 [mlx5_core] devlink_nl_cmd_eswitch_set_doit+0xdc/0x180 genl_family_rcv_msg_doit.isra.17+0xe8/0x138 genl_rcv_msg+0xe4/0x220 netlink_rcv_skb+0x44/0x108 genl_rcv+0x40/0x58 netlink_unicast+0x198/0x268 netlink_sendmsg+0x1d4/0x418 sock_sendmsg+0x54/0x60 __sys_sendto+0xf4/0x120 __arm64_sys_sendto+0x30/0x40 el0_svc_common+0x8c/0x120 do_el0_svc+0x30/0xa0 el0_svc+0x20/0x30 el0_sync_handler+0x90/0xb8 el0_sync+0x160/0x180
Thus, upon lag enable/disable, load and unload only the IB representors of the slaves preventing the deadlock mentioned above.
While at it, refactor the mlx5_esw_offloads_rep_load() function to have a static helper method for its internal logic, in symmetry with the representor unload design.
--- .../net/ethernet/mellanox/mlx5/core/eswitch.h | 4 +-- .../mellanox/mlx5/core/eswitch_offloads.c | 28 ++++++++++++------- .../net/ethernet/mellanox/mlx5/core/lag/lag.c | 6 ++-- .../ethernet/mellanox/mlx5/core/lag/mpesw.c | 4 +-- 4 files changed, 25 insertions(+), 17 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +2 -2
@@ -833,7 +833,7 @@ int mlx5_eswitch_offloads_single_fdb_add_one(struct mlx5_eswitch *master_esw, struct mlx5_eswitch *slave_esw, int max_slaves);void mlx5_eswitch_offloads_single_fdb_del_one (struct mlx5_eswitch *master_esw,struct mlx5_eswitch *slave_esw); -int mlx5_eswitch_reload_reps (struct mlx5_eswitch *esw); +int mlx5_eswitch_reload_ib_reps (struct mlx5_eswitch *esw);bool mlx5_eswitch_block_encap (struct mlx5_core_dev *dev);void mlx5_eswitch_unblock_encap (struct mlx5_core_dev *dev);
@@ -925,7 +925,7 @@ mlx5_eswitch_offloads_single_fdb_del_one(struct mlx5_eswitch *master_esw,static inline int mlx5_eswitch_get_npeers (struct mlx5_eswitch *esw) {return 0 ; }static inline int -mlx5_eswitch_reload_reps (struct mlx5_eswitch *esw) +mlx5_eswitch_reload_ib_reps (struct mlx5_eswitch *esw) {return 0 ; }
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +18 -10
@@ -2502,6 +2502,16 @@ void esw_offloads_cleanup(struct mlx5_eswitch *esw)esw_offloads_cleanup_reps (esw); } +static int __esw_offloads_load_rep (struct mlx5_eswitch *esw, +struct mlx5_eswitch_rep *rep,u8 rep_type) +{ +if (atomic_cmpxchg (&rep->rep_data[rep_type].state, +REP_REGISTERED ,REP_LOADED ) ==REP_REGISTERED ) +return esw->offloads.rep_ops[rep_type]->load (esw->dev, rep); + +return 0 ; +} +static void __esw_offloads_unload_rep (struct mlx5_eswitch *esw,struct mlx5_eswitch_rep *rep,u8 rep_type) {
@@ -2526,13 +2536,11 @@ static int mlx5_esw_offloads_rep_load(struct mlx5_eswitch *esw, u16 vport_num)int err; rep =mlx5_eswitch_get_rep (esw, vport_num); -for (rep_type =0 ; rep_type <NUM_REP_TYPES ; rep_type++) -if (atomic_cmpxchg (&rep->rep_data[rep_type].state, -REP_REGISTERED ,REP_LOADED ) ==REP_REGISTERED ) { - err = esw->offloads.rep_ops[rep_type]->load (esw->dev, rep); -if (err) - goto err_reps; - } +for (rep_type =0 ; rep_type <NUM_REP_TYPES ; rep_type++) { + err =__esw_offloads_load_rep (esw, rep, rep_type); +if (err) + goto err_reps; + }return 0 ;
@@ -3277,7 +3285,7 @@ static void esw_destroy_offloads_acl_tables(struct mlx5_eswitch *esw)esw_vport_destroy_offloads_acl_tables (esw, vport); } -int mlx5_eswitch_reload_reps (struct mlx5_eswitch *esw) +int mlx5_eswitch_reload_ib_reps (struct mlx5_eswitch *esw) {struct mlx5_eswitch_rep *rep;unsigned long i;
@@ -3290,13 +3298,13 @@ int mlx5_eswitch_reload_reps(struct mlx5_eswitch *esw)if (atomic_read (&rep->rep_data[REP_ETH ].state) !=REP_LOADED )return 0 ; - ret =mlx5_esw_offloads_rep_load (esw,MLX5_VPORT_UPLINK ); + ret =__esw_offloads_load_rep (esw, rep,REP_IB );if (ret)return ret;mlx5_esw_for_each_rep (esw, i, rep) {if (atomic_read (&rep->rep_data[REP_ETH ].state) ==REP_LOADED ) -mlx5_esw_offloads_rep_load (esw, rep->vport); +__esw_offloads_load_rep (esw, rep,REP_IB ); }return 0 ;
drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c +3 -3
@@ -814,7 +814,7 @@ void mlx5_disable_lag(struct mlx5_lag *ldev)if (shared_fdb)for (i =0 ; i < ldev->ports; i++)if (!(ldev->pf[i].dev->priv.flags &MLX5_PRIV_FLAGS_DISABLE_ALL_ADEV )) -mlx5_eswitch_reload_reps (ldev->pf[i].dev->priv.eswitch); +mlx5_eswitch_reload_ib_reps (ldev->pf[i].dev->priv.eswitch); }static bool mlx5_shared_fdb_supported (struct mlx5_lag *ldev)
@@ -922,7 +922,7 @@ static void mlx5_do_bond(struct mlx5_lag *ldev)mlx5_rescan_drivers_locked (dev0);for (i =0 ; i < ldev->ports; i++) { - err =mlx5_eswitch_reload_reps (ldev->pf[i].dev->priv.eswitch); + err =mlx5_eswitch_reload_ib_reps (ldev->pf[i].dev->priv.eswitch);if (err)break ; }
@@ -933,7 +933,7 @@ static void mlx5_do_bond(struct mlx5_lag *ldev)mlx5_deactivate_lag (ldev);mlx5_lag_add_devices (ldev);for (i =0 ; i < ldev->ports; i++) -mlx5_eswitch_reload_reps (ldev->pf[i].dev->priv.eswitch); +mlx5_eswitch_reload_ib_reps (ldev->pf[i].dev->priv.eswitch);mlx5_core_err (dev0,"Failed to enable lag\n" );return ; }
drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.c +2 -2
@@ -99,7 +99,7 @@ static int enable_mpesw(struct mlx5_lag *ldev) dev0->priv.flags &= ~MLX5_PRIV_FLAGS_DISABLE_IB_ADEV ;mlx5_rescan_drivers_locked (dev0);for (i =0 ; i < ldev->ports; i++) { - err =mlx5_eswitch_reload_reps (ldev->pf[i].dev->priv.eswitch); + err =mlx5_eswitch_reload_ib_reps (ldev->pf[i].dev->priv.eswitch);if (err) goto err_rescan_drivers; }
@@ -113,7 +113,7 @@ static int enable_mpesw(struct mlx5_lag *ldev) err_add_devices:mlx5_lag_add_devices (ldev);for (i =0 ; i < ldev->ports; i++) -mlx5_eswitch_reload_reps (ldev->pf[i].dev->priv.eswitch); +mlx5_eswitch_reload_ib_reps (ldev->pf[i].dev->priv.eswitch);mlx5_mpesw_metadata_cleanup (ldev);return err; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 254/427 net/mlx5: Add a timeout to acquire the command queue semaphore
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Akiva Goldberger <[email protected]>
[ Upstream commit 485d65e1357123a697c591a5aeb773994b247ad7 ]
Prevent forced completion handling on an entry that has not yet been assigned an index, causing an out of bounds access on idx = -22. Instead of waiting indefinitely for the sem, blocking flow now waits for index to be allocated or a sem acquisition timeout before beginning the timer for FW completion.
Kernel log example:mlx5_core 0000:06:00.0: wait_func_handle_exec_timeout:1128:(pid 185911): cmd[-22]: CREATE_UCTX(0xa04) No done completion
--- drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 41 +++++++++++++++---- include/linux/mlx5/driver.h | 1 + 2 files changed, 33 insertions(+), 9 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/cmd.c +32 -9
@@ -969,19 +969,32 @@ static void cmd_work_handler(struct work_struct *work)bool poll_cmd = ent->polling;struct mlx5_cmd_layout *lay;struct mlx5_core_dev *dev; -unsigned long cb_timeout; -struct semaphore *sem; +unsigned long timeout;unsigned long flags;int alloc_ret;int cmd_mode; +complete (&ent->handling); + dev = container_of(cmd, struct mlx5_core_dev, cmd); - cb_timeout =msecs_to_jiffies (mlx5_tout_ms (dev,CMD )); + timeout =msecs_to_jiffies (mlx5_tout_ms (dev,CMD )); -complete (&ent->handling); - sem = ent->page_queue ? &cmd->vars.pages_sem : &cmd->vars.sem; -down (sem);if (!ent->page_queue) { +if (down_timeout (&cmd->vars.sem, timeout)) { +mlx5_core_warn (dev,"%s(0x%x) timed out while waiting for a slot.\n" , +mlx5_command_str (ent->op), ent->op); +if (ent->callback) { + ent->callback (-EBUSY , ent->context); +mlx5_free_cmd_msg (dev, ent->out); +free_msg (dev, ent->in); +cmd_ent_put (ent); + }else { + ent->ret = -EBUSY ; +complete (&ent->done); + } +complete (&ent->slotted); +return ; + } alloc_ret =cmd_alloc_index (cmd, ent);if (alloc_ret <0 ) {mlx5_core_err_rl (dev,"failed to allocate command entry\n" );
@@ -994,10 +1007,11 @@ static void cmd_work_handler(struct work_struct *work) ent->ret = -EAGAIN ;complete (&ent->done); } -up (sem); +up (&cmd->vars.sem);return ; } }else { +down (&cmd->vars.pages_sem); ent->idx = cmd->vars.max_reg_cmds;spin_lock_irqsave (&cmd->alloc_lock, flags);clear_bit (ent->idx, &cmd->vars.bitmask);
@@ -1005,6 +1019,8 @@ static void cmd_work_handler(struct work_struct *work)spin_unlock_irqrestore (&cmd->alloc_lock, flags); } +complete (&ent->slotted); + lay =get_inst (cmd, ent->idx); ent->lay = lay;memset (lay,0 ,sizeof (*lay));
@@ -1023,7 +1039,7 @@ static void cmd_work_handler(struct work_struct *work) ent->ts1 =ktime_get_ns (); cmd_mode = cmd->mode; -if (ent->callback &&schedule_delayed_work (&ent->cb_timeout_work, cb_timeout)) +if (ent->callback &&schedule_delayed_work (&ent->cb_timeout_work, timeout))cmd_ent_get (ent);set_bit (MLX5_CMD_ENT_STATE_PENDING_COMP , &ent->state);
@@ -1143,6 +1159,9 @@ static int wait_func(struct mlx5_core_dev *dev, struct mlx5_cmd_work_ent *ent) ent->ret = -ECANCELED ; goto out_err; } + +wait_for_completion (&ent->slotted); +if (cmd->mode ==CMD_MODE_POLLING || ent->polling)wait_for_completion (&ent->done);else if (!wait_for_completion_timeout (&ent->done, timeout))
@@ -1157,6 +1176,9 @@ static int wait_func(struct mlx5_core_dev *dev, struct mlx5_cmd_work_ent *ent) }else if (err == -ECANCELED ) {mlx5_core_warn (dev,"%s(0x%x) canceled on out of queue timeout.\n" ,mlx5_command_str (ent->op), ent->op); + }else if (err == -EBUSY ) { +mlx5_core_warn (dev,"%s(0x%x) timeout while waiting for command semaphore.\n" , +mlx5_command_str (ent->op), ent->op); }mlx5_core_dbg (dev,"err %d, delivery status %s(%d)\n" , err,deliv_status_to_str (ent->status), ent->status);
@@ -1208,6 +1230,7 @@ static int mlx5_cmd_invoke(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *in, ent->polling = force_polling;init_completion (&ent->handling); +init_completion (&ent->slotted);if (!callback)init_completion (&ent->done);
@@ -1225,7 +1248,7 @@ static int mlx5_cmd_invoke(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *in,return 0 ;/* mlx5_cmd_comp_handler() will put(ent) */ err =wait_func (dev, ent); -if (err == -ETIMEDOUT || err == -ECANCELED ) +if (err == -ETIMEDOUT || err == -ECANCELED || err == -EBUSY ) goto out_free; ds = ent->ts2 - ent->ts1;
include/linux/mlx5/driver.h +1 -0
@@ -862,6 +862,7 @@ struct mlx5_cmd_work_ent {void *context;int idx;struct completion handling; +struct completion slotted;struct completion done;struct mlx5_cmd *cmd;struct work_struct work;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 255/427 net/mlx5: Discard command completions in internal error
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Akiva Goldberger <[email protected]>
[ Upstream commit db9b31aa9bc56ff0d15b78f7e827d61c4a096e40 ]
Fix use after free when FW completion arrives while device is in internal error state. Avoid calling completion handler in this case, since the device will flush the command interface and trigger all completions manually.
Kernel log:
------------[ cut here ]------------ refcount_t: underflow; use-after-free. ... RIP: 0010:refcount_warn_saturate+0xd8/0xe0 ... Call Trace: <IRQ> ? __warn+0x79/0x120 ? refcount_warn_saturate+0xd8/0xe0 ? report_bug+0x17c/0x190 ? handle_bug+0x3c/0x60 ? exc_invalid_op+0x14/0x70 ? asm_exc_invalid_op+0x16/0x20 ? refcount_warn_saturate+0xd8/0xe0 cmd_ent_put+0x13b/0x160 [mlx5_core] mlx5_cmd_comp_handler+0x5f9/0x670 [mlx5_core] cmd_comp_notifier+0x1f/0x30 [mlx5_core] notifier_call_chain+0x35/0xb0 atomic_notifier_call_chain+0x16/0x20 mlx5_eq_async_int+0xf6/0x290 [mlx5_core] notifier_call_chain+0x35/0xb0 atomic_notifier_call_chain+0x16/0x20 irq_int_handler+0x19/0x30 [mlx5_core] __handle_irq_event_percpu+0x4b/0x160 handle_irq_event+0x2e/0x80 handle_edge_irq+0x98/0x230 __common_interrupt+0x3b/0xa0 common_interrupt+0x7b/0xa0 </IRQ> <TASK> asm_common_interrupt+0x22/0x40
--- drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/cmd.c +3 -0
@@ -1634,6 +1634,9 @@ static int cmd_comp_notifier(struct notifier_block *nb, dev = container_of(cmd, struct mlx5_core_dev, cmd); eqe = data; +if (dev->state ==MLX5_DEVICE_STATE_INTERNAL_ERROR ) +return NOTIFY_DONE ; +mlx5_cmd_comp_handler (dev,be32_to_cpu (eqe->data.cmd.vector), false);return NOTIFY_OK ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 256/427 s390/bpf: Emit a barrier for BPF_FETCH instructions
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Leoshkevich <[email protected]>
[ Upstream commit 68378982f0b21de02ac3c6a11e2420badefcb4bc ]
BPF_ATOMIC_OP() macro documentation states that "BPF_ADD | BPF_FETCH" should be the same as atomic_fetch_add(), which is currently not the case on s390x: the serialization instruction "bcr 14,0" is missing. This applies to "and", "or" and "xor" variants too.
s390x is allowed to reorder stores with subsequent fetches from different addresses, so code relying on BPF_FETCH acting as a barrier, for example:
stw [%r0], 1
afadd [%r1], %r2
ldxw %r3, [%r4]
may be broken. Fix it by emitting "bcr 14,0".
Note that a separate serialization instruction is not needed for BPF_XCHG and BPF_CMPXCHG, because COMPARE AND SWAP performs serialization itself.
--- arch/s390/net/bpf_jit_comp.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
arch/s390/net/bpf_jit_comp.c +6 -2
@@ -1427,8 +1427,12 @@ static noinline int bpf_jit_insn(struct bpf_jit *jit, struct bpf_prog *fp,EMIT6_DISP_LH (0xeb000000 , is32 ? (op32) : (op64), \ (insn->imm &BPF_FETCH ) ? src_reg :REG_W0 , \ src_reg, dst_reg, off); \ -if (is32 && (insn->imm &BPF_FETCH )) \ -EMIT_ZERO (src_reg); \ +if (insn->imm &BPF_FETCH ) { \ +/* bcr 14,0 - see atomic_fetch_{add,and,or,xor}() */ \ +_EMIT2 (0x07e0 ); \ +if (is32) \ +EMIT_ZERO (src_reg); \ + } \ }while (0 )case BPF_ADD :case BPF_ADD |BPF_FETCH :
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 257/427 riscv, bpf: make some atomic operations fully ordered
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Puranjay Mohan <[email protected]>
[ Upstream commit 20a759df3bba35bf5c3ddec0c02ad69b603b584c ]
The BPF atomic operations with the BPF_FETCH modifier along with BPF_XCHG and BPF_CMPXCHG are fully ordered but the RISC-V JIT implements all atomic operations except BPF_CMPXCHG with relaxed ordering.
Section 8.1 of the "The RISC-V Instruction Set Manual Volume I:
Unprivileged ISA" [1], titled, "Specifying Ordering of Atomic Instructions" says:
| To provide more efficient support for release consistency [5], each | atomic instruction has two bits, aq and rl, used to specify additional | memory ordering constraints as viewed by other RISC-V harts.
and
| If only the aq bit is set, the atomic memory operation is treated as | an acquire access. | If only the rl bit is set, the atomic memory operation is treated as a | release access. | | If both the aq and rl bits are set, the atomic memory operation is | sequentially consistent.
Fix this by setting both aq and rl bits as 1 for operations with BPF_FETCH and BPF_XCHG.
[1] https://riscv.org/wp-content/uploads/2017/05/riscv-spec-v2.2.pdf
--- arch/riscv/net/bpf_jit_comp64.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
arch/riscv/net/bpf_jit_comp64.c +10 -10
@@ -498,33 +498,33 @@ static void emit_atomic(u8 rd, u8 rs, s16 off, s32 imm, bool is64,break ;/* src_reg = atomic_fetch_<op>(dst_reg + off16, src_reg) */ case BPF_ADD |BPF_FETCH : -emit (is64 ?rv_amoadd_d (rs, rs, rd,0 ,0 ) : -rv_amoadd_w (rs, rs, rd,0 ,0 ), ctx); +emit (is64 ?rv_amoadd_d (rs, rs, rd,1 ,1 ) : +rv_amoadd_w (rs, rs, rd,1 ,1 ), ctx);if (!is64)emit_zextw (rs, rs, ctx);break ;case BPF_AND |BPF_FETCH : -emit (is64 ?rv_amoand_d (rs, rs, rd,0 ,0 ) : -rv_amoand_w (rs, rs, rd,0 ,0 ), ctx); +emit (is64 ?rv_amoand_d (rs, rs, rd,1 ,1 ) : +rv_amoand_w (rs, rs, rd,1 ,1 ), ctx);if (!is64)emit_zextw (rs, rs, ctx);break ;case BPF_OR |BPF_FETCH : -emit (is64 ?rv_amoor_d (rs, rs, rd,0 ,0 ) : -rv_amoor_w (rs, rs, rd,0 ,0 ), ctx); +emit (is64 ?rv_amoor_d (rs, rs, rd,1 ,1 ) : +rv_amoor_w (rs, rs, rd,1 ,1 ), ctx);if (!is64)emit_zextw (rs, rs, ctx);break ;case BPF_XOR |BPF_FETCH : -emit (is64 ?rv_amoxor_d (rs, rs, rd,0 ,0 ) : -rv_amoxor_w (rs, rs, rd,0 ,0 ), ctx); +emit (is64 ?rv_amoxor_d (rs, rs, rd,1 ,1 ) : +rv_amoxor_w (rs, rs, rd,1 ,1 ), ctx);if (!is64)emit_zextw (rs, rs, ctx);break ;/* src_reg = atomic_xchg(dst_reg + off16, src_reg); */ case BPF_XCHG : -emit (is64 ?rv_amoswap_d (rs, rs, rd,0 ,0 ) : -rv_amoswap_w (rs, rs, rd,0 ,0 ), ctx); +emit (is64 ?rv_amoswap_d (rs, rs, rd,1 ,1 ) : +rv_amoswap_w (rs, rs, rd,1 ,1 ), ctx);if (!is64)emit_zextw (rs, rs, ctx);break ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 258/427 inet: fix inet_fill_ifaddr() flags truncation
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 1af7f88af269c4e06a4dc3bc920ff6cdf7471124 ]
I missed that (struct ifaddrmsg)->ifa_flags was only 8bits, while (struct in_ifaddr)->ifa_flags is 32bits.
Use a temporary 32bit variable as I did in set_ifa_lifetime() and check_lifetime().
--- net/ipv4/devinet.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
net/ipv4/devinet.c +10 -3
@@ -1683,6 +1683,7 @@ static int inet_fill_ifaddr(struct sk_buff *skb, const struct in_ifaddr *ifa,struct nlmsghdr *nlh;unsigned long tstamp;u32 preferred, valid; +u32 flags; nlh =nlmsg_put (skb, args->portid, args->seq, args->event,sizeof (*ifm), args->flags);
@@ -1692,7 +1693,13 @@ static int inet_fill_ifaddr(struct sk_buff *skb, const struct in_ifaddr *ifa, ifm =nlmsg_data (nlh); ifm->ifa_family =AF_INET ; ifm->ifa_prefixlen = ifa->ifa_prefixlen; - ifm->ifa_flags =READ_ONCE (ifa->ifa_flags); + + flags =READ_ONCE (ifa->ifa_flags); +/* Warning : ifm->ifa_flags is an __u8, it holds only 8 bits. +* The 32bit value is given in IFA_FLAGS attribute. +*/ + ifm->ifa_flags = (__u8 )flags; + ifm->ifa_scope = ifa->ifa_scope; ifm->ifa_index = ifa->ifa_dev->dev->ifindex;
@@ -1701,7 +1708,7 @@ static int inet_fill_ifaddr(struct sk_buff *skb, const struct in_ifaddr *ifa, goto nla_put_failure; tstamp =READ_ONCE (ifa->ifa_tstamp); -if (!(ifm->ifa_flags &IFA_F_PERMANENT )) { +if (!(flags &IFA_F_PERMANENT )) { preferred =READ_ONCE (ifa->ifa_preferred_lft); valid =READ_ONCE (ifa->ifa_valid_lft);if (preferred !=INFINITY_LIFE_TIME ) {
@@ -1732,7 +1739,7 @@ static int inet_fill_ifaddr(struct sk_buff *skb, const struct in_ifaddr *ifa, nla_put_string(skb, IFA_LABEL, ifa->ifa_label)) || (ifa->ifa_proto &&nla_put_u8 (skb,IFA_PROTO , ifa->ifa_proto)) || -nla_put_u32 (skb,IFA_FLAGS , ifm->ifa_flags) || +nla_put_u32 (skb,IFA_FLAGS , flags) || (ifa->ifa_rt_priority &&nla_put_u32 (skb,IFA_RT_PRIORITY , ifa->ifa_rt_priority)) || put_cacheinfo(skb, READ_ONCE(ifa->ifa_cstamp), tstamp,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 259/427 ax25: Use kernel universal linked list to implement ax25_dev_list
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Duoming Zhou <[email protected]>
[ Upstream commit a7d6e36b9ad052926ba2ecba3a59d8bb67dabcb4 ]
The origin ax25_dev_list implements its own single linked list, which is complicated and error-prone. For example, when deleting the node of ax25_dev_list in ax25_dev_device_down(), we have to operate on the head node and other nodes separately.
This patch uses kernel universal linked list to replace original ax25_dev_list, which make the operation of ax25_dev_list easier.
We should do "dev->ax25_ptr = ax25_dev;" and "dev->ax25_ptr = NULL;" while holding the spinlock, otherwise the ax25_dev_device_up() and ax25_dev_device_down() could race.
Stable-dep-of: b505e0319852 ("ax25: Fix reference count leak issues of ax25_dev")
--- include/net/ax25.h | 3 +-- net/ax25/ax25_dev.c | 40 +++++++++++++++------------------------- 2 files changed, 16 insertions(+), 27 deletions(-)
include/net/ax25.h +1 -2
@@ -216,7 +216,7 @@ typedef struct {struct ctl_table ; typedef struct ax25_dev { - struct ax25_dev *next; + struct list_head list; struct net_device *dev; netdevice_tracker dev_tracker;
@@ -330,7 +330,6 @@ int ax25_addr_size(const ax25_digi *);void ax25_digi_invert (const ax25_digi *,ax25_digi *);/* ax25_dev.c */ -extern ax25_dev *ax25_dev_list;extern spinlock_t ax25_dev_lock;#if IS_ENABLED (CONFIG_AX25 )
net/ax25/ax25_dev.c +15 -25
@@ -22,11 +22,12 @@#include <net/sock.h> #include <linux/uaccess.h> #include <linux/fcntl.h> +#include <linux/list.h> #include <linux/mm.h> #include <linux/interrupt.h> #include <linux/init.h> -ax25_dev *ax25_dev_list; +static LIST_HEAD (ax25_dev_list);DEFINE_SPINLOCK (ax25_dev_lock);ax25_dev *ax25_addr_ax25dev (ax25_address *addr)
@@ -34,7 +35,7 @@ ax25_dev *ax25_addr_ax25dev(ax25_address *addr)ax25_dev *ax25_dev, *res =NULL ;spin_lock_bh (&ax25_dev_lock); -for (ax25_dev = ax25_dev_list; ax25_dev !=NULL ; ax25_dev = ax25_dev->next) +list_for_each_entry (ax25_dev, &ax25_dev_list, list)if (ax25cmp (addr, (const ax25_address *)ax25_dev->dev->dev_addr) ==0 ) { res = ax25_dev;ax25_dev_hold (ax25_dev);
@@ -59,7 +60,6 @@ void ax25_dev_device_up(struct net_device *dev) }refcount_set (&ax25_dev->refcount,1 ); - dev->ax25_ptr = ax25_dev; ax25_dev->dev = dev;netdev_hold (dev, &ax25_dev->dev_tracker,GFP_KERNEL ); ax25_dev->forward =NULL ;
@@ -85,8 +85,8 @@ void ax25_dev_device_up(struct net_device *dev)#endif spin_lock_bh (&ax25_dev_lock); - ax25_dev->next = ax25_dev_list; - ax25_dev_list = ax25_dev; +list_add (&ax25_dev->list, &ax25_dev_list); + dev->ax25_ptr = ax25_dev;spin_unlock_bh (&ax25_dev_lock);ax25_dev_hold (ax25_dev);
@@ -111,32 +111,25 @@ void ax25_dev_device_down(struct net_device *dev)/* * Remove any packet forwarding that points to this device. */ -for (s = ax25_dev_list; s !=NULL ; s = s->next) +list_for_each_entry (s, &ax25_dev_list, list)if (s->forward == dev) s->forward =NULL ; -if ((s = ax25_dev_list) == ax25_dev) { - ax25_dev_list = s->next; - goto unlock_put; - } - -while (s !=NULL && s->next !=NULL ) { -if (s->next == ax25_dev) { - s->next = ax25_dev->next; +list_for_each_entry (s, &ax25_dev_list, list) { +if (s == ax25_dev) { +list_del (&s->list); goto unlock_put; } - - s = s->next; } -spin_unlock_bh (&ax25_dev_lock); dev->ax25_ptr =NULL ; +spin_unlock_bh (&ax25_dev_lock);ax25_dev_put (ax25_dev);return ; unlock_put: + dev->ax25_ptr =NULL ;spin_unlock_bh (&ax25_dev_lock);ax25_dev_put (ax25_dev); - dev->ax25_ptr =NULL ;netdev_put (dev, &ax25_dev->dev_tracker);ax25_dev_put (ax25_dev); }
@@ -200,16 +193,13 @@ struct net_device *ax25_fwd_dev(struct net_device *dev)*/ void __exit ax25_dev_free(void) { -ax25_dev *s, *ax25_dev; +ax25_dev *s, *n;spin_lock_bh (&ax25_dev_lock); - ax25_dev = ax25_dev_list; -while (ax25_dev !=NULL ) { - s = ax25_dev; -netdev_put (ax25_dev->dev, &ax25_dev->dev_tracker); - ax25_dev = ax25_dev->next; +list_for_each_entry_safe (s, n, &ax25_dev_list, list) { +netdev_put (s->dev, &s->dev_tracker); +list_del (&s->list);kfree (s); } - ax25_dev_list =NULL ;spin_unlock_bh (&ax25_dev_lock); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 260/427 ax25: Fix reference count leak issues of ax25_dev
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Duoming Zhou <[email protected]>
[ Upstream commit b505e0319852b08a3a716b64620168eab21f4ced ]
The ax25_addr_ax25dev() and ax25_dev_device_down() exist a reference count leak issue of the object "ax25_dev".
Memory leak issue in ax25_addr_ax25dev():
The reference count of the object "ax25_dev" can be increased multiple times in ax25_addr_ax25dev(). This will cause a memory leak.
Memory leak issues in ax25_dev_device_down():
The reference count of ax25_dev is set to 1 in ax25_dev_device_up() and then increase the reference count when ax25_dev is added to ax25_dev_list. As a result, the reference count of ax25_dev is 2. But when the device is shutting down. The ax25_dev_device_down() drops the reference count once or twice depending on if we goto unlock_put or not, which will cause memory leak.
As for the issue of ax25_addr_ax25dev(), it is impossible for one pointer to be on a list twice. So add a break in ax25_addr_ax25dev(). As for the issue of ax25_dev_device_down(), increase the reference count of ax25_dev once in ax25_dev_device_up() and decrease the reference count of ax25_dev after it is removed from the ax25_dev_list.
--- net/ax25/ax25_dev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/ax25/ax25_dev.c +1 -2
@@ -39,6 +39,7 @@ ax25_dev *ax25_addr_ax25dev(ax25_address *addr)if (ax25cmp (addr, (const ax25_address *)ax25_dev->dev->dev_addr) ==0 ) { res = ax25_dev;ax25_dev_hold (ax25_dev); +break ; }spin_unlock_bh (&ax25_dev_lock);
@@ -88,7 +89,6 @@ void ax25_dev_device_up(struct net_device *dev)list_add (&ax25_dev->list, &ax25_dev_list); dev->ax25_ptr = ax25_dev;spin_unlock_bh (&ax25_dev_lock); -ax25_dev_hold (ax25_dev);ax25_register_dev_sysctl (ax25_dev); }
@@ -129,7 +129,6 @@ void ax25_dev_device_down(struct net_device *dev) unlock_put: dev->ax25_ptr =NULL ;spin_unlock_bh (&ax25_dev_lock); -ax25_dev_put (ax25_dev);netdev_put (dev, &ax25_dev->dev_tracker);ax25_dev_put (ax25_dev); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 261/427 ax25: Fix reference count leak issue of net_device
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Duoming Zhou <[email protected]>
[ Upstream commit 36e56b1b002bb26440403053f19f9e1a8bc075b2 ]
There is a reference count leak issue of the object "net_device" in ax25_dev_device_down(). When the ax25 device is shutting down, the ax25_dev_device_down() drops the reference count of net_device one or zero times depending on if we goto unlock_put or not, which will cause memory leak.
In order to solve the above issue, decrease the reference count of net_device after dev->ax25_ptr is set to null.
--- net/ax25/ax25_dev.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
net/ax25/ax25_dev.c +1 -6
@@ -118,15 +118,10 @@ void ax25_dev_device_down(struct net_device *dev)list_for_each_entry (s, &ax25_dev_list, list) {if (s == ax25_dev) {list_del (&s->list); - goto unlock_put; +break ; } } - dev->ax25_ptr =NULL ; -spin_unlock_bh (&ax25_dev_lock); -ax25_dev_put (ax25_dev); -return ; -unlock_put: dev->ax25_ptr =NULL ;spin_unlock_bh (&ax25_dev_lock);netdev_put (dev, &ax25_dev->dev_tracker);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 262/427 dpll: fix return value check for kmemdup
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Ni <[email protected]>
[ Upstream commit ad506586cb69292b6ac59ab95468aadd54b19ab7 ]
The return value of kmemdup() is dst->freq_supported, not src->freq_supported. Update the check accordingly.
--- drivers/dpll/dpll_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dpll/dpll_core.c +1 -1
@@ -449,7 +449,7 @@ static int dpll_pin_prop_dup(const struct dpll_pin_properties *src,sizeof (*src->freq_supported); dst->freq_supported =kmemdup (src->freq_supported, freq_size,GFP_KERNEL ); -if (!src->freq_supported) +if (!dst->freq_supported)return -ENOMEM ; }if (src->board_label) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 263/427 net: fec: remove .ndo_poll_controller to avoid deadlocks
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wei Fang <[email protected]>
[ Upstream commit c2e0c58b25a0a0c37ec643255558c5af4450c9f5 ]
There is a deadlock issue found in sungem driver, please refer to the commit ac0a230f719b ("eth: sungem: remove .ndo_poll_controller to avoid deadlocks"). The root cause of the issue is that netpoll is in atomic context and disable_irq() is called by .ndo_poll_controller interface of sungem driver, however, disable_irq() might sleep. After analyzing the implementation of fec_poll_controller(), the fec driver should have the same issue. Due to the fec driver uses NAPI for TX completions, the .ndo_poll_controller is unnecessary to be implemented in the fec driver, so fec_poll_controller() can be safely removed.
--- drivers/net/ethernet/freescale/fec_main.c | 26 ----------------------- 1 file changed, 26 deletions(-)
drivers/net/ethernet/freescale/fec_main.c +0 -26
@@ -3674,29 +3674,6 @@ fec_set_mac_address(struct net_device *ndev, void *p)return 0 ; } -#ifdef CONFIG_NET_POLL_CONTROLLER -/** -* fec_poll_controller - FEC Poll controller function -* @dev: The FEC network adapter -* -* Polled functionality used by netconsole and others in non interrupt mode -* -*/ -static void fec_poll_controller (struct net_device *dev) -{ -int i; -struct fec_enet_private *fep =netdev_priv (dev); - -for (i =0 ; i <FEC_IRQ_NUM ; i++) { -if (fep->irq[i] >0 ) { -disable_irq (fep->irq[i]); -fec_enet_interrupt (fep->irq[i], dev); -enable_irq (fep->irq[i]); - } - } -} -#endif -static inline void fec_enet_set_netdev_features (struct net_device *netdev,netdev_features_t features) {
@@ -4003,9 +3980,6 @@ static const struct net_device_ops fec_netdev_ops = { .ndo_tx_timeout = fec_timeout, .ndo_set_mac_address = fec_set_mac_address, .ndo_eth_ioctl = phy_do_ioctl_running, -#ifdef CONFIG_NET_POLL_CONTROLLER - .ndo_poll_controller = fec_poll_controller, -#endif .ndo_set_features = fec_set_features, .ndo_bpf = fec_enet_bpf, .ndo_xdp_xmit = fec_enet_xdp_xmit,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 264/427 mptcp: SO_KEEPALIVE: fix getsockopt support
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthieu Baerts (NGI0) <[email protected]>
[ Upstream commit a65198136eaa15b74ee0abf73f12ef83d469a334 ]
SO_KEEPALIVE support has to be set on each subflow: on each TCP socket, where sk_prot->keepalive is defined. Technically, nothing has to be done on the MPTCP socket. That's why mptcp_sol_socket_sync_intval() was called instead of mptcp_sol_socket_intval().
Except that when nothing is done on the MPTCP socket, the getsockopt(SO_KEEPALIVE), handled in net/core/sock.c:sk_getsockopt(), will not know if SO_KEEPALIVE has been set on the different subflows or not.
The fix is simple: simply call mptcp_sol_socket_intval() which will end up calling net/core/sock.c:sk_setsockopt() where the SOCK_KEEPOPEN flag will be set, the one used in sk_getsockopt().
So now, getsockopt(SO_KEEPALIVE) on an MPTCP socket will return the same value as the one previously set with setsockopt(SO_KEEPALIVE).
--- net/mptcp/sockopt.c | 2 -- 1 file changed, 2 deletions(-)
net/mptcp/sockopt.c +0 -2
@@ -181,8 +181,6 @@ static int mptcp_setsockopt_sol_socket_int(struct mptcp_sock *msk, int optname,switch (optname) {case SO_KEEPALIVE : -mptcp_sol_socket_sync_intval (msk, optname, val); -return 0 ;case SO_DEBUG :case SO_MARK :case SO_PRIORITY :
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 265/427 mptcp: fix full TCP keep-alive support
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthieu Baerts (NGI0) <[email protected]>
[ Upstream commit bd11dc4fb969ec148e50cd87f88a78246dbc4d0b ]
SO_KEEPALIVE support has been added a while ago, as part of a series "adding SOL_SOCKET" support. To have a full control of this keep-alive feature, it is important to also support TCP_KEEP* socket options at the SOL_TCP level.
Supporting them on the setsockopt() part is easy, it is just a matter of remembering each value in the MPTCP sock structure, and calling tcp_sock_set_keep*() helpers on each subflow. If the value is not modified (0), calling these helpers will not do anything. For the getsockopt() part, the corresponding value from the MPTCP sock structure or the default one is simply returned. All of this is very similar to other TCP_* socket options supported by MPTCP.
It looks important for kernels supporting SO_KEEPALIVE, to also support TCP_KEEP* options as well: some apps seem to (wrongly) consider that if the former is supported, the latter ones will be supported as well. But also, not having this simple and isolated change is preventing MPTCP support in some apps, and libraries like GoLang [1]. This is why this patch is seen as a fix.
--- net/mptcp/protocol.h | 3 +++ net/mptcp/sockopt.c | 58 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+)
net/mptcp/protocol.h +3 -0
@@ -308,6 +308,9 @@ struct mptcp_sock { free_first:1 , rcvspace_init:1;u32 notsent_lowat; +int keepalive_cnt; +int keepalive_idle; +int keepalive_intvl;struct work_struct work;struct sk_buff *ooo_last_skb;struct rb_root out_of_order_queue;
net/mptcp/sockopt.c +58 -0
88 lines not on this page · raw message
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 266/427 net: stmmac: move the EST lock to struct stmmac_priv
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiaolei Wang <[email protected]>
[ Upstream commit 36ac9e7f2e5786bd37c5cd91132e1f39c29b8197 ]
Reinitialize the whole EST structure would also reset the mutex lock which is embedded in the EST structure, and then trigger the following warning. To address this, move the lock to struct stmmac_priv. We also need to reacquire the mutex lock when doing this initialization.
DEBUG_LOCKS_WARN_ON(lock->magic != lock)
WARNING: CPU: 3 PID: 505 at kernel/locking/mutex.c:587 __mutex_lock+0xd84/0x1068 Modules linked in: CPU: 3 PID: 505 Comm: tc Not tainted 6.9.0-rc6-00053-g0106679839f7-dirty #29 Hardware name: NXP i.MX8MPlus EVK board (DT) pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : __mutex_lock+0xd84/0x1068 lr : __mutex_lock+0xd84/0x1068 sp : ffffffc0864e3570 x29: ffffffc0864e3570 x28: ffffffc0817bdc78 x27: 0000000000000003 x26: ffffff80c54f1808 x25: ffffff80c9164080 x24: ffffffc080d723ac x23: 0000000000000000 x22: 0000000000000002 x21: 0000000000000000 x20: 0000000000000000 x19: ffffffc083bc3000 x18: ffffffffffffffff x17: ffffffc08117b080 x16: 0000000000000002 x15: ffffff80d2d40000 x14: 00000000000002da x13: ffffff80d2d404b8 x12: ffffffc082b5a5c8 x11: ffffffc082bca680 x10: ffffffc082bb2640 x9 : ffffffc082bb2698 x8 : 0000000000017fe8 x7 : c0000000ffffefff x6 : 0000000000000001 x5 : ffffff8178fe0d48 x4 : 0000000000000000 x3 : 0000000000000027 x2 : ffffff8178fe0d50 x1 : 0000000000000000 x0 : 0000000000000000 Call trace: __mutex_lock+0xd84/0x1068 mutex_lock_nested+0x28/0x34 tc_setup_taprio+0x118/0x68c stmmac_setup_tc+0x50/0xf0 taprio_change+0x868/0xc9c
--- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 2 ++ .../net/ethernet/stmicro/stmmac/stmmac_ptp.c | 8 ++++---- .../net/ethernet/stmicro/stmmac/stmmac_tc.c | 18 ++++++++++-------- include/linux/stmmac.h | 1 - 4 files changed, 16 insertions(+), 13 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac.h +2 -0
@@ -261,6 +261,8 @@ struct stmmac_priv {struct stmmac_extra_stats xstats____cacheline_aligned_in_smp ;struct stmmac_safety_stats sstats;struct plat_stmmacenet_data *plat; +/* Protect est parameters */ +struct mutex est_lock;struct dma_features dma_cap;struct stmmac_counters mmc;int hw_cap_support;
drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c +4 -4
@@ -70,11 +70,11 @@ static int stmmac_adjust_time(struct ptp_clock_info *ptp, s64 delta)/* If EST is enabled, disabled it before adjust ptp time. */ if (priv->plat->est && priv->plat->est->enable) { est_rst = true; -mutex_lock (&priv->plat->est->lock); +mutex_lock (&priv->est_lock); priv->plat->est->enable = false;stmmac_est_configure (priv, priv, priv->plat->est, priv->plat->clk_ptp_rate); -mutex_unlock (&priv->plat->est->lock); +mutex_unlock (&priv->est_lock); }write_lock_irqsave (&priv->ptp_lock, flags);
@@ -87,7 +87,7 @@ static int stmmac_adjust_time(struct ptp_clock_info *ptp, s64 delta)ktime_t current_time_ns, basetime;u64 cycle_time; -mutex_lock (&priv->plat->est->lock); +mutex_lock (&priv->est_lock); priv->ptp_clock_ops.gettime64 (&priv->ptp_clock_ops, ¤t_time); current_time_ns =timespec64_to_ktime (current_time); time.tv_nsec = priv->plat->est->btr_reserve[0 ];
@@ -104,7 +104,7 @@ static int stmmac_adjust_time(struct ptp_clock_info *ptp, s64 delta) priv->plat->est->enable = true; ret =stmmac_est_configure (priv, priv, priv->plat->est, priv->plat->clk_ptp_rate); -mutex_unlock (&priv->plat->est->lock); +mutex_unlock (&priv->est_lock);if (ret)netdev_err (priv->dev,"failed to configure EST\n" ); }
drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +10 -8
@@ -1004,17 +1004,19 @@ static int tc_taprio_configure(struct stmmac_priv *priv,if (!plat->est)return -ENOMEM ; -mutex_init (&priv->plat->est->lock); +mutex_init (&priv->est_lock); }else { +mutex_lock (&priv->est_lock);memset (plat->est,0 ,sizeof (*plat->est)); +mutex_unlock (&priv->est_lock); } size = qopt->num_entries; -mutex_lock (&priv->plat->est->lock); +mutex_lock (&priv->est_lock); priv->plat->est->gcl_size = size; priv->plat->est->enable = qopt->cmd ==TAPRIO_CMD_REPLACE ; -mutex_unlock (&priv->plat->est->lock); +mutex_unlock (&priv->est_lock);for (i =0 ; i < size; i++) {s64 delta_ns = qopt->entries[i].interval;
@@ -1045,7 +1047,7 @@ static int tc_taprio_configure(struct stmmac_priv *priv, priv->plat->est->gcl[i] = delta_ns | (gates << wid); } -mutex_lock (&priv->plat->est->lock); +mutex_lock (&priv->est_lock);/* Adjust for real system time */ priv->ptp_clock_ops.gettime64 (&priv->ptp_clock_ops, ¤t_time); current_time_ns =timespec64_to_ktime (current_time);
@@ -1068,7 +1070,7 @@ static int tc_taprio_configure(struct stmmac_priv *priv,tc_taprio_map_maxsdu_txq (priv, qopt);if (fpe && !priv->dma_cap.fpesel) { -mutex_unlock (&priv->plat->est->lock); +mutex_unlock (&priv->est_lock);return -EOPNOTSUPP ; }
@@ -1079,7 +1081,7 @@ static int tc_taprio_configure(struct stmmac_priv *priv, ret =stmmac_est_configure (priv, priv, priv->plat->est, priv->plat->clk_ptp_rate); -mutex_unlock (&priv->plat->est->lock); +mutex_unlock (&priv->est_lock);if (ret) {netdev_err (priv->dev,"failed to configure EST\n" ); goto disable;
@@ -1096,7 +1098,7 @@ static int tc_taprio_configure(struct stmmac_priv *priv, disable:if (priv->plat->est) { -mutex_lock (&priv->plat->est->lock); +mutex_lock (&priv->est_lock); priv->plat->est->enable = false;stmmac_est_configure (priv, priv, priv->plat->est, priv->plat->clk_ptp_rate);
@@ -1105,7 +1107,7 @@ static int tc_taprio_configure(struct stmmac_priv *priv, priv->xstats.max_sdu_txq_drop[i] =0 ; priv->xstats.mtl_est_txq_hlbf[i] =0 ; } -mutex_unlock (&priv->plat->est->lock); +mutex_unlock (&priv->est_lock); } priv->plat->fpe_cfg->enable = false;
include/linux/stmmac.h +0 -1
@@ -117,7 +117,6 @@ struct stmmac_axi {#define EST_GCL 1024struct stmmac_est { -struct mutex lock;int enable;u32 btr_reserve[2 ];u32 btr_offset[2 ];
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 267/427 net: micrel: Fix receiving the timestamp in the frame for lan8841
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Horatiu Vultur <[email protected]>
[ Upstream commit aea27a92a41dae14843f92c79e9e42d8f570105c ]
The blamed commit started to use the ptp workqueue to get the second part of the timestamp. And when the port was set down, then this workqueue is stopped. But if the config option NETWORK_PHY_TIMESTAMPING is not enabled, then the ptp_clock is not initialized so then it would crash when it would try to access the delayed work.
So then basically by setting up and then down the port, it would crash. The fix consists in checking if the ptp_clock is initialized and only then cancel the delayed work.
--- drivers/net/phy/micrel.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/phy/micrel.c +2 -1
@@ -4676,7 +4676,8 @@ static int lan8841_suspend(struct phy_device *phydev)struct kszphy_priv *priv = phydev->priv;struct kszphy_ptp_priv *ptp_priv = &priv->ptp_priv; -ptp_cancel_worker_sync (ptp_priv->ptp_clock); +if (ptp_priv->ptp_clock) +ptp_cancel_worker_sync (ptp_priv->ptp_clock);return genphy_suspend (phydev); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 268/427 Bluetooth: compute LE flow credits based on recvbuf space
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Urban <[email protected]>
[ Upstream commit ce60b9231b66710b6ee24042ded26efee120ecfc ]
Previously LE flow credits were returned to the sender even if the socket's receive buffer was full. This meant that no back-pressure
was applied to the sender, thus it continued to send data, resulting in data loss without any error being reported. Furthermore, the amount of credits was essentially fixed to a small amount, leading to reduced performance.
This is fixed by computing the number of returned LE flow credits based on the estimated available space in the receive buffer of an L2CAP socket. Consequently, if the receive buffer is full, no credits are returned until the buffer is read and thus cleared by user-space.
Since the computation of available receive buffer space can only be performed approximately (due to sk_buff overhead) and the receive buffer size may be changed by user-space after flow credits have been sent, superfluous received data is temporary stored within l2cap_pinfo. This is necessary because Bluetooth LE provides no retransmission mechanism once the data has been acked by the physical layer.
If receive buffer space estimation is not possible at the moment, we fall back to providing credits for one full packet as before. This is currently the case during connection setup, when MPS is not yet available.
--- include/net/bluetooth/l2cap.h | 11 ++++- net/bluetooth/l2cap_core.c | 56 ++++++++++++++++++--- net/bluetooth/l2cap_sock.c | 91 ++++++++++++++++++++++++++++------- 3 files changed, 132 insertions(+), 26 deletions(-)
include/net/bluetooth/l2cap.h +10 -1
@@ -548,6 +548,9 @@ struct l2cap_chan {__u16 tx_credits;__u16 rx_credits; +/* estimated available receive buffer space or -1 if unknown */ +ssize_t rx_avail; +__u8 tx_state;__u8 rx_state;
@@ -682,10 +685,15 @@ struct l2cap_user {/* ----- L2CAP socket info ----- */ #define l2cap_pi (sk) ((struct l2cap_pinfo *) sk) +struct l2cap_rx_busy { +struct list_head list; +struct sk_buff *skb; +}; +struct l2cap_pinfo {struct bt_sock bt;struct l2cap_chan *chan; -struct sk_buff *rx_busy_skb; +struct list_head rx_busy; };enum {
@@ -943,6 +951,7 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,int l2cap_chan_reconfigure (struct l2cap_chan *chan,__u16 mtu);int l2cap_chan_send (struct l2cap_chan *chan,struct msghdr *msg,size_t len);void l2cap_chan_busy (struct l2cap_chan *chan,int busy); +void l2cap_chan_rx_avail (struct l2cap_chan *chan,ssize_t rx_avail);int l2cap_chan_check_security (struct l2cap_chan *chan,bool initiator);void l2cap_chan_set_defaults (struct l2cap_chan *chan);int l2cap_ertm_init (struct l2cap_chan *chan);
net/bluetooth/l2cap_core.c +49 -7
104 lines not on this page · raw message
net/bluetooth/l2cap_sock.c +73 -18
166 lines not on this page · raw message
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 269/427 Bluetooth: qca: Fix error code in qca_read_fw_build_info()
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit a189f0ee6685457528db7a36ded3085e5d13ddc3 ]
Return -ENOMEM on allocation failure. Don't return success.
--- drivers/bluetooth/btqca.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/bluetooth/btqca.c +3 -1
@@ -148,8 +148,10 @@ static int qca_read_fw_build_info(struct hci_dev *hdev) } build_label =kstrndup (&edl->data[1 ], build_lbl_len,GFP_KERNEL ); -if (!build_label) +if (!build_label) { + err = -ENOMEM ; goto out; + }hci_set_fw_info (hdev,"%s" , build_label);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 270/427 Bluetooth: ISO: Make iso_get_sock_listen generic
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Iulia Tanasescu <[email protected]>
[ Upstream commit 311527e9dafdcae0c5a20d62f4f84ad01b33b5f4 ]
This makes iso_get_sock_listen more generic, to return matching socket in the state provided as argument.
Stable-dep-of: a5b862c6a221 ("Bluetooth: L2CAP: Fix div-by-zero in l2cap_le_flowctl_init()")
--- include/net/bluetooth/bluetooth.h | 2 +- net/bluetooth/iso.c | 75 +++++++++++++++++-------------- 2 files changed, 43 insertions(+), 34 deletions(-)
include/net/bluetooth/bluetooth.h +1 -1
@@ -285,7 +285,7 @@ void bt_err_ratelimited(const char *fmt, ...); bt_err_ratelimited("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__) /* Connection and socket states */ -enum { +enum bt_sock_state {BT_CONNECTED =1 ,/* Equal to TCP_ESTABLISHED to make net code happy */ BT_OPEN ,BT_BOUND ,
net/bluetooth/iso.c +42 -33
149 lines not on this page · raw message
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 271/427 Bluetooth: HCI: Remove HCI_AMP support
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit 84a4bb6548a29326564f0e659fb8064503ecc1c7 ]
Since BT_HS has been remove HCI_AMP controllers no longer has any use so remove it along with the capability of creating AMP controllers.
Since we no longer need to differentiate between AMP and Primary controllers, as only HCI_PRIMARY is left, this also remove hdev->dev_type altogether.
--- drivers/bluetooth/btmrvl_main.c | 9 -- drivers/bluetooth/btrsi.c | 1 - drivers/bluetooth/btsdio.c | 8 -- drivers/bluetooth/btusb.c | 5 -- drivers/bluetooth/hci_bcm4377.c | 1 - drivers/bluetooth/hci_ldisc.c | 6 -- drivers/bluetooth/hci_serdev.c | 5 -- drivers/bluetooth/hci_uart.h | 1 - drivers/bluetooth/hci_vhci.c | 10 +-- drivers/bluetooth/virtio_bt.c | 2 - include/net/bluetooth/hci.h | 114 ------------------------ include/net/bluetooth/hci_core.h | 46 +--------- include/uapi/linux/virtio_bt.h | 1 - net/bluetooth/hci_conn.c | 3 +- net/bluetooth/hci_core.c | 132 +++------------------------ net/bluetooth/hci_event.c | 147 ------------------------------- net/bluetooth/hci_sock.c | 5 +- net/bluetooth/hci_sync.c | 112 +---------------------- net/bluetooth/l2cap_core.c | 21 +---- net/bluetooth/mgmt.c | 84 ++++++------------ 20 files changed, 49 insertions(+), 664 deletions(-)
drivers/bluetooth/btmrvl_main.c +0 -9
@@ -121,13 +121,6 @@ int btmrvl_process_event(struct btmrvl_private *priv, struct sk_buff *skb) ((event->data[2 ] ==MODULE_BROUGHT_UP ) || (event->data[2 ] ==MODULE_ALREADY_UP )) ? "Bring-up succeed" : "Bring-up failed"); - -if (event->length >3 && event->data[3 ]) - priv->btmrvl_dev.dev_type =HCI_AMP ; -else - priv->btmrvl_dev.dev_type =HCI_PRIMARY ; - -BT_DBG ("dev_type: %d" , priv->btmrvl_dev.dev_type); }else if (priv->btmrvl_dev.sendcmdflag && event->data[1 ] ==MODULE_SHUTDOWN_REQ ) { BT_DBG("EVENT:%s", (event->data[2]) ?
@@ -686,8 +679,6 @@ int btmrvl_register_hdev(struct btmrvl_private *priv) hdev->wakeup = btmrvl_wakeup;SET_HCIDEV_DEV (hdev, &card->func->dev); - hdev->dev_type = priv->btmrvl_dev.dev_type; - ret =hci_register_dev (hdev);if (ret <0 ) {BT_ERR ("Can not register HCI device" );
drivers/bluetooth/btrsi.c +0 -1
@@ -134,7 +134,6 @@ static int rsi_hci_attach(void *priv, struct rsi_proto_ops *ops) hdev->bus =HCI_USB ;hci_set_drvdata (hdev, h_adapter); - hdev->dev_type =HCI_PRIMARY ; hdev->open = rsi_hci_open; hdev->close = rsi_hci_close; hdev->flush = rsi_hci_flush;
drivers/bluetooth/btsdio.c +0 -8
@@ -32,9 +32,6 @@ static const struct sdio_device_id btsdio_table[] = {/* Generic Bluetooth Type-B SDIO device */ { SDIO_DEVICE_CLASS(SDIO_CLASS_BT_B) }, -/* Generic Bluetooth AMP controller */ - { SDIO_DEVICE_CLASS(SDIO_CLASS_BT_AMP) }, - { }/* Terminating entry */ };
@@ -319,11 +316,6 @@ static int btsdio_probe(struct sdio_func *func, hdev->bus =HCI_SDIO ;hci_set_drvdata (hdev, data); -if (id->class ==SDIO_CLASS_BT_AMP ) - hdev->dev_type =HCI_AMP ; -else - hdev->dev_type =HCI_PRIMARY ; - data->hdev = hdev;SET_HCIDEV_DEV (hdev, &func->dev);
drivers/bluetooth/btusb.c +0 -5
@@ -4332,11 +4332,6 @@ static int btusb_probe(struct usb_interface *intf, hdev->bus =HCI_USB ;hci_set_drvdata (hdev, data); -if (id->driver_info &BTUSB_AMP ) - hdev->dev_type =HCI_AMP ; -else - hdev->dev_type =HCI_PRIMARY ; - data->hdev = hdev;SET_HCIDEV_DEV (hdev, &intf->dev);
drivers/bluetooth/hci_bcm4377.c +0 -1
@@ -2361,7 +2361,6 @@ static int bcm4377_probe(struct pci_dev *pdev, const struct pci_device_id *id) bcm4377->hdev = hdev; hdev->bus =HCI_PCI ; - hdev->dev_type =HCI_PRIMARY ; hdev->open = bcm4377_hci_open; hdev->close = bcm4377_hci_close; hdev->send = bcm4377_hci_send_frame;
drivers/bluetooth/hci_ldisc.c +0 -6
@@ -667,11 +667,6 @@ static int hci_uart_register_dev(struct hci_uart *hu)if (!test_bit (HCI_UART_RESET_ON_INIT , &hu->hdev_flags))set_bit (HCI_QUIRK_RESET_ON_CLOSE , &hdev->quirks); -if (test_bit (HCI_UART_CREATE_AMP , &hu->hdev_flags)) - hdev->dev_type =HCI_AMP ; -else - hdev->dev_type =HCI_PRIMARY ; -/* Only call open() for the protocol after hdev is fully initialized as * open() (or a timer/workqueue it starts) may attempt to reference it. */
@@ -722,7 +717,6 @@ static int hci_uart_set_flags(struct hci_uart *hu, unsigned long flags) {unsigned long valid_flags =BIT (HCI_UART_RAW_DEVICE ) |BIT (HCI_UART_RESET_ON_INIT ) | -BIT (HCI_UART_CREATE_AMP ) |BIT (HCI_UART_INIT_PENDING ) |BIT (HCI_UART_EXT_CONFIG ) |BIT (HCI_UART_VND_DETECT );
drivers/bluetooth/hci_serdev.c +0 -5
@@ -366,11 +366,6 @@ int hci_uart_register_device_priv(struct hci_uart *hu,if (test_bit (HCI_UART_EXT_CONFIG , &hu->hdev_flags))set_bit (HCI_QUIRK_EXTERNAL_CONFIG , &hdev->quirks); -if (test_bit (HCI_UART_CREATE_AMP , &hu->hdev_flags)) - hdev->dev_type =HCI_AMP ; -else - hdev->dev_type =HCI_PRIMARY ; -if (test_bit (HCI_UART_INIT_PENDING , &hu->hdev_flags))return 0 ;
drivers/bluetooth/hci_uart.h +0 -1
@@ -37,7 +37,6 @@#define HCI_UART_RAW_DEVICE 0#define HCI_UART_RESET_ON_INIT 1 -#define HCI_UART_CREATE_AMP 2#define HCI_UART_INIT_PENDING 3#define HCI_UART_EXT_CONFIG 4#define HCI_UART_VND_DETECT 5
drivers/bluetooth/hci_vhci.c +1 -9
@@ -384,17 +384,10 @@ static int __vhci_create_device(struct vhci_data *data, __u8 opcode) {struct hci_dev *hdev;struct sk_buff *skb; -__u8 dev_type;if (data->hdev)return -EBADFD ; -/* bits 0-1 are dev_type (Primary or AMP) */ - dev_type = opcode &0x03 ; - -if (dev_type !=HCI_PRIMARY && dev_type !=HCI_AMP ) -return -EINVAL ; -/* bits 2-5 are reserved (must be zero) */ if (opcode &0x3c )return -EINVAL ;
@@ -412,7 +405,6 @@ static int __vhci_create_device(struct vhci_data *data, __u8 opcode) data->hdev = hdev; hdev->bus =HCI_VIRTUAL ; - hdev->dev_type = dev_type;hci_set_drvdata (hdev, data); hdev->open = vhci_open_dev;
@@ -634,7 +626,7 @@ static void vhci_open_timeout(struct work_struct *work) struct vhci_data *data = container_of(work, struct vhci_data, open_timeout.work); -vhci_create_device (data, amp ?HCI_AMP :HCI_PRIMARY ); +vhci_create_device (data,0x00 ); }static int vhci_open (struct inode *inode,struct file *file)
drivers/bluetooth/virtio_bt.c +0 -2
@@ -274,7 +274,6 @@ static int virtbt_probe(struct virtio_device *vdev)switch (type) {case VIRTIO_BT_CONFIG_TYPE_PRIMARY : -case VIRTIO_BT_CONFIG_TYPE_AMP :break ;default :return -EINVAL ;
@@ -303,7 +302,6 @@ static int virtbt_probe(struct virtio_device *vdev) vbt->hdev = hdev; hdev->bus =HCI_VIRTIO ; - hdev->dev_type = type;hci_set_drvdata (hdev, vbt); hdev->open = virtbt_open;
include/net/bluetooth/hci.h +0 -114
144 lines not on this page · raw message
include/net/bluetooth/hci_core.h +1 -45
118 lines not on this page · raw message
include/uapi/linux/virtio_bt.h +0 -1
@@ -13,7 +13,6 @@enum virtio_bt_config_type {VIRTIO_BT_CONFIG_TYPE_PRIMARY =0 , -VIRTIO_BT_CONFIG_TYPE_AMP =1 , };enum virtio_bt_config_vendor {
net/bluetooth/hci_conn.c +1 -2
@@ -1173,8 +1173,7 @@ struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src, uint8_t src_type)list_for_each_entry (d, &hci_dev_list, list) {if (!test_bit (HCI_UP , &d->flags) || -hci_dev_test_flag (d,HCI_USER_CHANNEL ) || - d->dev_type !=HCI_PRIMARY ) +hci_dev_test_flag (d,HCI_USER_CHANNEL ))continue ;/* Simple routing:
net/bluetooth/hci_core.c +10 -122
199 lines not on this page · raw message
net/bluetooth/hci_event.c +0 -147
189 lines not on this page · raw message
net/bluetooth/hci_sock.c +1 -4
@@ -485,7 +485,7 @@ static struct sk_buff *create_monitor_event(struct hci_dev *hdev, int event)return NULL ; ni =skb_put (skb,HCI_MON_NEW_INDEX_SIZE ); - ni->type = hdev->dev_type; + ni->type =0x00 ;/* Old hdev->dev_type */ ni->bus = hdev->bus;bacpy (&ni->bdaddr, &hdev->bdaddr); memcpy_and_pad(ni->name, sizeof(ni->name), hdev->name,
@@ -1007,9 +1007,6 @@ static int hci_sock_bound_ioctl(struct sock *sk, unsigned int cmd,if (hci_dev_test_flag (hdev,HCI_UNCONFIGURED ))return -EOPNOTSUPP ; -if (hdev->dev_type !=HCI_PRIMARY ) -return -EOPNOTSUPP ; -switch (cmd) {case HCISETRAW :if (!capable (CAP_NET_ADMIN ))
net/bluetooth/hci_sync.c +4 -108
187 lines not on this page · raw message
net/bluetooth/l2cap_core.c +4 -17
@@ -3930,7 +3930,7 @@ static inline int l2cap_command_rej(struct l2cap_conn *conn, }static void l2cap_connect (struct l2cap_conn *conn,struct l2cap_cmd_hdr *cmd, -u8 *data,u8 rsp_code,u8 amp_id) +u8 *data,u8 rsp_code) {struct l2cap_conn_req *req = (struct l2cap_conn_req *) data;struct l2cap_conn_rsp rsp;
@@ -4009,17 +4009,8 @@ static void l2cap_connect(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, status =L2CAP_CS_AUTHOR_PEND ; chan->ops->defer (chan); }else { -/* Force pending result for AMP controllers. -* The connection will succeed after the -* physical link is up. -*/ -if (amp_id ==AMP_ID_BREDR ) { -l2cap_state_change (chan,BT_CONFIG ); - result =L2CAP_CR_SUCCESS ; - }else { -l2cap_state_change (chan,BT_CONNECT2 ); - result =L2CAP_CR_PEND ; - } +l2cap_state_change (chan,BT_CONNECT2 ); + result =L2CAP_CR_PEND ; status =L2CAP_CS_NO_INFO ; } }else {
@@ -4084,7 +4075,7 @@ static int l2cap_connect_req(struct l2cap_conn *conn,mgmt_device_connected (hdev, hcon,NULL ,0 );hci_dev_unlock (hdev); -l2cap_connect (conn, cmd, data,L2CAP_CONN_RSP ,0 ); +l2cap_connect (conn, cmd, data,L2CAP_CONN_RSP );return 0 ; }
@@ -7495,10 +7486,6 @@ void l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags)struct l2cap_conn *conn = hcon->l2cap_data;int len; -/* For AMP controller do not create l2cap conn */ -if (!conn && hcon->hdev->dev_type !=HCI_PRIMARY ) - goto drop; -if (!conn) conn =l2cap_conn_add (hcon);
net/bluetooth/mgmt.c +27 -57
133 lines not on this page · raw message
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 272/427 Bluetooth: hci_conn, hci_sync: Use __counted_by() to avoid -Wfamnae warnings
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gustavo A. R. Silva <[email protected]>
[ Upstream commit c4585edf708edb5277a3cc4b8581ccb833f3307d ]
Prepare for the coming implementation by GCC and Clang of the __counted_by attribute. Flexible array members annotated with __counted_by can have their accesses bounds-checked at run-time via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family functions).
Also, -Wflex-array-member-not-at-end is coming in GCC-14, and we are getting ready to enable it globally.
So, use the DEFINE_FLEX() helper for multiple on-stack definitions of a flexible structure where the size of the flexible-array member is known at compile-time, and refactor the rest of the code, accordingly.
Notice that, due to the use of __counted_by() in struct hci_cp_le_create_cis, the for loop in function hci_cs_le_create_cis() had to be modified. Once the index i, through which cp->cis[i] is accessed, falls in the interval [0, cp->num_cis), cp->num_cis cannot be decremented all the way down to zero while accessing cp->cis[]:
net/bluetooth/hci_event.c:4310:
4310 for (i = 0; cp->num_cis; cp->num_cis--, i++) {
...4314 handle = __le16_to_cpu(cp->cis[i].cis_handle);
otherwise, only half (one iteration before cp->num_cis == i) or half plus one (one iteration before cp->num_cis < i) of the items in the array will be accessed before running into an out-of-bounds issue. So, in order to avoid this, set cp->num_cis to zero just after the for loop.
Also, make use of aux_num_cis variable to update cmd->num_cis after a list_for_each_entry_rcu() loop.
With these changes, fix the following warnings:net/bluetooth/hci_sync.c:1239:56: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] net/bluetooth/hci_sync.c:1415:51: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] net/bluetooth/hci_sync.c:1731:51: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] net/bluetooth/hci_sync.c:6497:45: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
Stable-dep-of: e77f43d531af ("Bluetooth: hci_core: Fix not handling hdev->le_num_of_adv_sets=1")
--- include/net/bluetooth/hci.h | 8 ++-- net/bluetooth/hci_event.c | 3 +- net/bluetooth/hci_sync.c | 84 +++++++++++++++---------------------- 3 files changed, 40 insertions(+), 55 deletions(-)
include/net/bluetooth/hci.h +4 -4
@@ -1921,7 +1921,7 @@ struct hci_cp_le_set_ext_adv_data {__u8 operation;__u8 frag_pref;__u8 length; -__u8 data[]; + __u8 data[] __counted_by(length); } __packed;#define HCI_OP_LE_SET_EXT_SCAN_RSP_DATA 0x2038
@@ -1930,7 +1930,7 @@ struct hci_cp_le_set_ext_scan_rsp_data {__u8 operation;__u8 frag_pref;__u8 length; -__u8 data[]; + __u8 data[] __counted_by(length); } __packed;#define HCI_OP_LE_SET_EXT_ADV_ENABLE 0x2039
@@ -1956,7 +1956,7 @@ struct hci_cp_le_set_per_adv_data {__u8 handle;__u8 operation;__u8 length; -__u8 data[]; + __u8 data[] __counted_by(length); } __packed;#define HCI_OP_LE_SET_PER_ADV_ENABLE 0x2040
@@ -2057,7 +2057,7 @@ struct hci_cis {struct hci_cp_le_create_cis {__u8 num_cis; -struct hci_cis cis[]; + struct hci_cis cis[] __counted_by(num_cis); } __packed;#define HCI_OP_LE_REMOVE_CIG 0x2065
net/bluetooth/hci_event.c +2 -1
@@ -4250,7 +4250,7 @@ static void hci_cs_le_create_cis(struct hci_dev *hdev, u8 status)hci_dev_lock (hdev);/* Remove connection if command failed */ -for (i =0 ; cp->num_cis; cp->num_cis--, i++) { +for (i =0 ; i < cp->num_cis; i++) {struct hci_conn *conn;u16 handle;
@@ -4266,6 +4266,7 @@ static void hci_cs_le_create_cis(struct hci_dev *hdev, u8 status)hci_conn_del (conn); } } + cp->num_cis =0 ;if (pending)hci_le_create_cis_pending (hdev);
net/bluetooth/hci_sync.c +34 -50
188 lines not on this page · raw message
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 273/427 Bluetooth: hci_core: Fix not handling hdev->le_num_of_adv_sets=1
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit e77f43d531af41e9ce299eab10dcae8fa5dbc293 ]
If hdev->le_num_of_adv_sets is set to 1 it means that only handle 0x00 can be used, but since the MGMT interface instances start from 1 (instance 0 means all instances in case of MGMT_OP_REMOVE_ADVERTISING) the code needs to map the instance to handle otherwise users will not be able to advertise as instance 1 would attempt to use handle 0x01.
--- include/net/bluetooth/hci_core.h | 1 + net/bluetooth/hci_core.c | 9 +++++++++ net/bluetooth/hci_sync.c | 17 ++++++++--------- 3 files changed, 18 insertions(+), 9 deletions(-)
include/net/bluetooth/hci_core.h +1 -0
@@ -246,6 +246,7 @@ struct adv_info {bool periodic;__u8 mesh;__u8 instance; +__u8 handle;__u32 flags;__u16 timeout;__u16 remaining_time;
net/bluetooth/hci_core.c +9 -0
@@ -1758,6 +1758,15 @@ struct adv_info *hci_add_adv_instance(struct hci_dev *hdev, u8 instance, adv->pending = true; adv->instance = instance; + +/* If controller support only one set and the instance is set to +* 1 then there is no option other than using handle 0x00. +*/ +if (hdev->le_num_of_adv_sets ==1 && instance ==1 ) + adv->handle =0x00 ; +else + adv->handle = instance; +list_add (&adv->list, &hdev->adv_instances); hdev->adv_instance_cnt++; }
net/bluetooth/hci_sync.c +8 -9
@@ -1043,11 +1043,10 @@ static int hci_disable_ext_adv_instance_sync(struct hci_dev *hdev, u8 instance)struct hci_cp_ext_adv_set *set;u8 data[sizeof (*cp) +sizeof (*set) *1 ];u8 size; +struct adv_info *adv =NULL ;/* If request specifies an instance that doesn't exist, fail */ if (instance >0 ) { -struct adv_info *adv; - adv =hci_find_adv_instance (hdev, instance);if (!adv)return -EINVAL ;
@@ -1066,7 +1065,7 @@ static int hci_disable_ext_adv_instance_sync(struct hci_dev *hdev, u8 instance) cp->num_of_sets = !!instance; cp->enable =0x00 ; - set->handle = instance; + set->handle = adv ? adv->handle : instance; size =sizeof (*cp) +sizeof (*set) * cp->num_of_sets;
@@ -1249,7 +1248,7 @@ static int hci_set_ext_scan_rsp_data_sync(struct hci_dev *hdev, u8 instance) len =eir_create_scan_rsp (hdev, instance, pdu->data); - pdu->handle = instance; + pdu->handle = adv ? adv->handle : instance; pdu->length = len; pdu->operation =LE_SET_ADV_DATA_OP_COMPLETE ; pdu->frag_pref =LE_SET_ADV_DATA_NO_FRAG ;
@@ -1331,7 +1330,7 @@ int hci_enable_ext_advertising_sync(struct hci_dev *hdev, u8 instance)memset (set,0 ,sizeof (*set)); - set->handle = instance; + set->handle = adv ? adv->handle : instance;/* Set duration per instance since controller is responsible for * scheduling it.
@@ -1410,10 +1409,10 @@ static int hci_set_per_adv_data_sync(struct hci_dev *hdev, u8 instance) DEFINE_FLEX(struct hci_cp_le_set_per_adv_data, pdu, data, length, HCI_MAX_PER_AD_LENGTH);u8 len; +struct adv_info *adv =NULL ;if (instance) { -struct adv_info *adv =hci_find_adv_instance (hdev, instance); - + adv =hci_find_adv_instance (hdev, instance);if (!adv || !adv->periodic)return 0 ; }
@@ -1421,7 +1420,7 @@ static int hci_set_per_adv_data_sync(struct hci_dev *hdev, u8 instance) len =eir_create_per_adv_data (hdev, instance, pdu->data); pdu->length = len; - pdu->handle = instance; + pdu->handle = adv ? adv->handle : instance; pdu->operation =LE_SET_ADV_DATA_OP_COMPLETE ; return __hci_cmd_sync_status(hdev, HCI_OP_LE_SET_PER_ADV_DATA,
@@ -1734,7 +1733,7 @@ static int hci_set_ext_adv_data_sync(struct hci_dev *hdev, u8 instance) len =eir_create_adv_data (hdev, instance, pdu->data); pdu->length = len; - pdu->handle = instance; + pdu->handle = adv ? adv->handle : instance; pdu->operation =LE_SET_ADV_DATA_OP_COMPLETE ; pdu->frag_pref =LE_SET_ADV_DATA_NO_FRAG ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 274/427 drm/panel-edp: Add prepare_to_enable to 200ms for MNC207QS1-1
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhengqiao Xia <[email protected]>
[ Upstream commit e635b7eb7062b464bbd9795308b1a80eac0b01f5 ]
For MNC207QS1-1 panel, Splash screen occur when switch from VT1 to VT2. The BL_EN signal does not conform to the VESA protocol. BL_EN signal needs to be pulled high after video signal.
So add prepare_to_enable to 200ms.
[ dianders: Adjusted subject prefix and added Fixes tag ]
--- drivers/gpu/drm/panel/panel-edp.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/panel/panel-edp.c +8 -1
@@ -1865,6 +1865,13 @@ static const struct panel_delay delay_200_500_e50 = { .enable = 50, }; +static const struct panel_delay delay_200_500_e50_p2e200 = { + .hpd_absent =200 , + .unprepare =500 , + .enable =50 , + .prepare_to_enable =200 , +}; +static const struct panel_delay delay_200_500_e80 = { .hpd_absent =200 , .unprepare =500 ,
@@ -2034,7 +2041,7 @@ static const struct edp_panel_entry edp_panels[] = {EDP_PANEL_ENTRY ('C' ,'M' ,'N' ,0x14d6 , &delay_200_500_e80_d50,"N140BGA-EA4" ),EDP_PANEL_ENTRY ('C' ,'M' ,'N' ,0x14e5 , &delay_200_500_e80_d50,"N140HGA-EA1" ), -EDP_PANEL_ENTRY ('C' ,'S' ,'O' ,0x1200 , &delay_200_500_e50,"MNC207QS1-1" ), +EDP_PANEL_ENTRY ('C' ,'S' ,'O' ,0x1200 , &delay_200_500_e50_p2e200,"MNC207QS1-1" ),EDP_PANEL_ENTRY ('H' ,'K' ,'C' ,0x2d51 , &delay_200_500_e200,"Unknown" ), EDP_PANEL_ENTRY('H', 'K', 'C', 0x2d5b, &delay_200_500_e200, "Unknown"),
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 275/427 drm/bridge: Fix improper bridge init order with pre_enable_prev_first
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jagan Teki <[email protected]>
[ Upstream commit e18aeeda0b6905c333df5a0566b99f5c84426098 ]
For a given bridge pipeline if any bridge sets pre_enable_prev_first flag then the pre_enable for the previous bridge will be called before pre_enable of this bridge and opposite is done for post_disable.
These are the potential bridge flags to alter bridge init order in order to satisfy the MIPI DSI host and downstream panel or bridge to function. However the existing pre_enable_prev_first logic with associated bridge ordering has broken for both pre_enable and post_disable calls.
[pre_enable]
The altered bridge ordering has failed if two consecutive bridges on a given pipeline enables the pre_enable_prev_first flag.
Example:
- Panel
- Bridge 1
- Bridge 2 pre_enable_prev_first
- Bridge 3
- Bridge 4 pre_enable_prev_first
- Bridge 5 pre_enable_prev_first
- Bridge 6
- Encoder
In this example, Bridge 4 and Bridge 5 have pre_enable_prev_first.
The logic looks for a bridge which enabled pre_enable_prev_first flag on each iteration and assigned the previou bridge to limit pointer if the bridge doesn't enable pre_enable_prev_first flags.
If control found Bridge 2 is pre_enable_prev_first then the iteration looks for Bridge 3 and found it is not pre_enable_prev_first and assigns it's previous Bridge 4 to limit pointer and calls pre_enable of Bridge 3 and Bridge 2 and assign iter pointer with limit which is Bridge 4.
Here is the actual problem, for the next iteration control look for Bridge 5 instead of Bridge 4 has iter pointer in previous iteration moved to Bridge 4 so this iteration skips the Bridge 4. The iteration found Bridge 6 doesn't pre_enable_prev_first flags so the limit assigned to Encoder. From next iteration Encoder skips as it is the last bridge for reverse order pipeline.
So, the resulting pre_enable bridge order would be,
- Panel, Bridge 1, Bridge 3, Bridge 2, Bridge 6, Bridge 5.
This patch fixes this by assigning limit to next pointer instead of previous bridge since the iteration always looks for bridge that does NOT request prev so assigning next makes sure the last bridge on a given iteration what exactly the limit bridge is.
So, the resulting pre_enable bridge order with fix would be,
- Panel, Bridge 1, Bridge 3, Bridge 2, Bridge 6, Bridge 5, Bridge 4, Encoder.
[post_disable]
The altered bridge ordering has failed if two consecutive bridges on a given pipeline enables the pre_enable_prev_first flag.
Example:
- Panel
- Bridge 1
- Bridge 2 pre_enable_prev_first
- Bridge 3
- Bridge 4 pre_enable_prev_first
- Bridge 5 pre_enable_prev_first
- Bridge 6
- Encoder
In this example Bridge 5 and Bridge 4 have pre_enable_prev_first.
The logic looks for a bridge which enabled pre_enable_prev_first flags on each iteration and assigned the previou bridge to next and next to limit pointer if the bridge does enable pre_enable_prev_first flag.
If control starts from Bridge 6 then it found next Bridge 5 is pre_enable_prev_first and immediately the next assigned to previous Bridge 6 and limit assignments to next Bridge 6 and call post_enable of Bridge 6 even though the next consecutive Bridge 5 is enabled with pre_enable_prev_first. This clearly misses the logic to find the state of next conducive bridge as everytime the next and limit assigns previous bridge if given bridge enabled pre_enable_prev_first.
So, the resulting post_disable bridge order would be,
- Encoder, Bridge 6, Bridge 5, Bridge 4, Bridge 3, Bridge 2, Bridge 1, Panel.
This patch fixes this by assigning next with previou bridge only if the bridge doesn't enable pre_enable_prev_first flag and the next further assign it to limit. This way we can find the bridge that NOT requested prev to disable last.
So, the resulting pre_enable bridge order with fix would be,
- Encoder, Bridge 4, Bridge 5, Bridge 6, Bridge 2, Bridge 3, Bridge 1, Panel.
Validated the bridge init ordering by incorporating dummy bridges in the sun6i-mipi-dsi pipeline
--- drivers/gpu/drm/drm_bridge.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_bridge.c +8 -2
@@ -687,11 +687,17 @@ void drm_atomic_bridge_chain_post_disable(struct drm_bridge *bridge,*/ list_for_each_entry_from (next, &encoder->bridge_chain, chain_node) { -if (next->pre_enable_prev_first) { +if (!next->pre_enable_prev_first) { next =list_prev_entry (next, chain_node); limit = next;break ; } + +if (list_is_last (&next->chain_node, + &encoder->bridge_chain)) { + limit = next; +break ; + } }/* Call these bridges in reverse order */
@@ -774,7 +780,7 @@ void drm_atomic_bridge_chain_pre_enable(struct drm_bridge *bridge,/* Found first bridge that does NOT * request prev to be enabled first */ - limit =list_prev_entry (next, chain_node); + limit = next;break ; } }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 276/427 drm/ci: update device type for volteer devices
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vignesh Raman <[email protected]>
[ Upstream commit a2c71b711e7efc6478976233768bdbc3386e6dce ]
Volteer devices in the collabora lab are categorized under the asus-cx9400-volteer device type. The majority of these units has an Intel Core i5-1130G7 CPU, while some of them have a Intel Core i7-1160G7 CPU instead. So due to this difference, new device type template is added for the Intel Core i5-1130G7 and i7-1160G7 variants of the Acer Chromebook Spin 514 (CP514-2H) volteer Chromebooks. So update the same in drm-ci.
https://gitlab.collabora.com/lava/lava/-/merge_requests/149
--- drivers/gpu/drm/ci/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/ci/test.yml +3 -3
@@ -252,11 +252,11 @@ i915:cml: i915:tgl: extends: - .i915 - parallel: 8 + parallel: 5 variables: - DEVICE_TYPE: asus-cx9400-volteer + DEVICE_TYPE: acer-cp514-2h-1130g7-volteer GPU_VERSION: tgl - RUNNER_TAG: mesa-ci-x86-64-lava-asus-cx9400-volteer + RUNNER_TAG: mesa-ci-x86-64-lava-acer-cp514-2h-1130g7-volteer .amdgpu: extends:
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 277/427 drm/nouveau/dp: Fix incorrect return code in r535_dp_aux_xfer()
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lyude Paul <[email protected]>
[ Upstream commit 97252d0a4bfbb07079503d059f7522d305fe0f7a ]
I've recently been seeing some unexplained GSP errors on my RTX 6000 from failed aux transactions:
[ 132.915867] nouveau 0000:1f:00.0: gsp: cli:0xc1d00002 obj:0x00730000 ctrl cmd:0x00731341 failed: 0x0000ffff
While the cause of these is not yet clear, these messages made me notice that the aux transactions causing these transactions were succeeding - not failing. As it turns out, this is because we're currently not returning the correct variable when r535_dp_aux_xfer() hits an error - causing us to never propagate GSP errors for failed aux transactions to userspace.
So, let's fix that.
--- drivers/gpu/drm/nouveau/nvkm/engine/disp/r535.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nvkm/engine/disp/r535.c +1 -1
@@ -1080,7 +1080,7 @@ r535_dp_aux_xfer(struct nvkm_outp *outp, u8 type, u32 addr, u8 *data, u8 *psize) ret =nvkm_gsp_rm_ctrl_push (&disp->rm.objcom, &ctrl,sizeof (*ctrl));if (ret) {nvkm_gsp_rm_ctrl_done (&disp->rm.objcom, ctrl); -return PTR_ERR (ctrl); +return ret; }memcpy (data, ctrl->data, size);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 278/427 drm/omapdrm: Fix console by implementing fb_dirty
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Lindgren <[email protected]>
[ Upstream commit 632bac50544c0929ced9eed41e7d04c08adecbb0 ]
The framebuffer console stopped updating with commit f231af498c29 ("drm/fb-helper: Disconnect damage worker from update logic").
Let's fix the issue by implementing fb_dirty similar to what was done with commit 039a72ce7e57 ("drm/i915/fbdev: Implement fb_dirty for intel custom fb helper").
--- drivers/gpu/drm/omapdrm/omap_fbdev.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/gpu/drm/omapdrm/omap_fbdev.c +12 -0
@@ -238,8 +238,20 @@ static int omap_fbdev_create(struct drm_fb_helper *helper,return ret; } +static int omap_fbdev_dirty (struct drm_fb_helper *helper,struct drm_clip_rect *clip) +{ +if (!(clip->x1 < clip->x2 && clip->y1 < clip->y2)) +return 0 ; + +if (helper->fb->funcs->dirty) +return helper->fb->funcs->dirty (helper->fb,NULL ,0 ,0 , clip,1 ); + +return 0 ; +} +static const struct drm_fb_helper_funcs omap_fb_helper_funcs = { .fb_probe = omap_fbdev_create, + .fb_dirty = omap_fbdev_dirty, };static struct drm_fb_helper *get_fb (struct fb_info *fbi)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 279/427 drm/omapdrm: Fix console with deferred ops
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Lindgren <[email protected]>
[ Upstream commit 01c0cce88c5480cc2505b79330246ef12eda938f ]
Commit 95da53d63dcf ("drm/omapdrm: Use regular fbdev I/O helpers") stopped console from updating for command mode displays because there is no damage handling in fb_sys_write() unlike we had earlier in drm_fb_helper_sys_write().
Let's fix the issue by adding FB_GEN_DEFAULT_DEFERRED_DMAMEM_OPS and FB_DMAMEM_HELPERS_DEFERRED as suggested by Thomas. We cannot use the FB_DEFAULT_DEFERRED_OPS as fb_deferred_io_mmap() won't work properly for write-combine.
--- drivers/gpu/drm/omapdrm/Kconfig | 2 +- drivers/gpu/drm/omapdrm/omap_fbdev.c | 28 ++++++++++++++++++++++------ drivers/video/fbdev/core/Kconfig | 6 ++++++ include/linux/fb.h | 4 ++++ 4 files changed, 33 insertions(+), 7 deletions(-)
drivers/gpu/drm/omapdrm/Kconfig +1 -1
@@ -4,7 +4,7 @@ config DRM_OMAP depends on DRM && OF depends on ARCH_OMAP2PLUS select DRM_KMS_HELPER - select FB_DMAMEM_HELPERS if DRM_FBDEV_EMULATION + select FB_DMAMEM_HELPERS_DEFERRED if DRM_FBDEV_EMULATION select VIDEOMODE_HELPERS select HDMI default n
drivers/gpu/drm/omapdrm/omap_fbdev.c +22 -6
@@ -51,6 +51,10 @@ static void pan_worker(struct work_struct *work)omap_gem_roll (bo, fbi->var.yoffset * npages); } +FB_GEN_DEFAULT_DEFERRED_DMAMEM_OPS (omap_fbdev, + drm_fb_helper_damage_range, + drm_fb_helper_damage_area) +static int omap_fbdev_pan_display (struct fb_var_screeninfo *var,struct fb_info *fbi) {
@@ -78,11 +82,9 @@ static int omap_fbdev_pan_display(struct fb_var_screeninfo *var,static int omap_fbdev_fb_mmap (struct fb_info *info,struct vm_area_struct *vma) { -struct drm_fb_helper *helper = info->par; -struct drm_framebuffer *fb = helper->fb; -struct drm_gem_object *bo =drm_gem_fb_get_obj (fb,0 ); + vma->vm_page_prot =pgprot_writecombine (vm_get_page_prot (vma->vm_flags)); -return drm_gem_mmap_obj (bo,omap_gem_mmap_size (bo), vma); +return fb_deferred_io_mmap (info, vma); }static void omap_fbdev_fb_destroy (struct fb_info *info)
@@ -94,6 +96,7 @@ static void omap_fbdev_fb_destroy(struct fb_info *info)DBG (); +fb_deferred_io_cleanup (info);drm_fb_helper_fini (helper);omap_gem_unpin (bo);
@@ -104,15 +107,19 @@ static void omap_fbdev_fb_destroy(struct fb_info *info)kfree (fbdev); } +/* +* For now, we cannot use FB_DEFAULT_DEFERRED_OPS and fb_deferred_io_mmap() +* because we use write-combine. +*/ static const struct fb_ops omap_fb_ops = { .owner =THIS_MODULE , - __FB_DEFAULT_DMAMEM_OPS_RDWR, +__FB_DEFAULT_DEFERRED_OPS_RDWR (omap_fbdev), .fb_check_var = drm_fb_helper_check_var, .fb_set_par = drm_fb_helper_set_par, .fb_setcmap = drm_fb_helper_setcmap, .fb_blank = drm_fb_helper_blank, .fb_pan_display = omap_fbdev_pan_display, - __FB_DEFAULT_DMAMEM_OPS_DRAW, +__FB_DEFAULT_DEFERRED_OPS_DRAW (omap_fbdev), .fb_ioctl = drm_fb_helper_ioctl, .fb_mmap = omap_fbdev_fb_mmap, .fb_destroy = omap_fbdev_fb_destroy,
@@ -213,6 +220,15 @@ static int omap_fbdev_create(struct drm_fb_helper *helper, fbi->fix.smem_start = dma_addr; fbi->fix.smem_len = bo->size; +/* deferred I/O */ + helper->fbdefio.delay =HZ /20 ; + helper->fbdefio.deferred_io = drm_fb_helper_deferred_io; + + fbi->fbdefio = &helper->fbdefio; + ret =fb_deferred_io_init (fbi); +if (ret) + goto fail; +/* if we have DMM, then we can use it for scrolling by just * shuffling pages around in DMM rather than doing sw blit. */
drivers/video/fbdev/core/Kconfig +6 -0
@@ -144,6 +144,12 @@ config FB_DMAMEM_HELPERS select FB_SYS_IMAGEBLIT select FB_SYSMEM_FOPS +config FB_DMAMEM_HELPERS_DEFERRED + bool + depends on FB_CORE + select FB_DEFERRED_IO + select FB_DMAMEM_HELPERS + config FB_IOMEM_FOPS tristate depends on FB_CORE
include/linux/fb.h +4 -0
@@ -694,6 +694,10 @@ extern int fb_deferred_io_fsync(struct file *file, loff_t start, __FB_GEN_DEFAULT_DEFERRED_OPS_RDWR(__prefix, __damage_range, sys) \ __FB_GEN_DEFAULT_DEFERRED_OPS_DRAW(__prefix, __damage_area, sys) +#define FB_GEN_DEFAULT_DEFERRED_DMAMEM_OPS (__prefix, __damage_range, __damage_area) \ + __FB_GEN_DEFAULT_DEFERRED_OPS_RDWR(__prefix, __damage_range, sys) \ + __FB_GEN_DEFAULT_DEFERRED_OPS_DRAW(__prefix, __damage_area, sys) +/* * Initializes struct fb_ops for deferred I/O. */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 280/427 printk: Let no_printk() use _printk()
In reply to Greg Kroah-Hartman6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <[email protected]>
[ Upstream commit 8522f6b760ca588928eede740d5d69dd1e936b49 ]
When printk-indexing is enabled, each printk() invocation emits a pi_entry structure, containing the format string and other information related to its location in the kernel sources. This is even true for no_printk(): while the actual code to print the message is optimized out by the compiler due to the always-false check, the pi_entry structure is still emitted.
As the main purpose of no_printk() is to provide a helper to maintain printf()-style format checking when debugging is disabled, this leads to the inclusion in the index of lots of printk formats that cannot be emitted by the current kernel.
Fix this by switching no_printk() from printk() to _printk().
This reduces the size of an arm64 defconfig kernel with CONFIG_PRINTK_INDEX=y by 576 KiB.
--- include/linux/printk.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/printk.h +1 -1
@@ -126,7 +126,7 @@ struct va_format {#define no_printk (fmt, ...) \ ({ \ if (0) \ - printk(fmt, ##__VA_ARGS__); \ + _printk(fmt, ##__VA_ARGS__); \ 0; \ })
Signature · 1 line
2.43.0