5.15.27-rc1 review
Subsystems (5)
Greg Kroah-Hartman
maintainerPATCH 112/262 bpf: Use u64_stats_t in struct bpf_prog_stats
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 61a0abaee2092eee69e44fe60336aa2f5b578938 ]
Commit 316580b69d0a ("u64_stats: provide u64_stats_t type") fixed possible load/store tearing on 64bit arches.
For instance the following C code
stats->nsecs += sched_clock() - start;
Could be rightfully implemented like this by a compiler, confusing concurrent readers a lot:
stats->nsecs += sched_clock();
// arbitrary delaystats->nsecs -= start;
--- include/linux/filter.h | 10 +++++----- kernel/bpf/syscall.c | 18 ++++++++++++------ kernel/bpf/trampoline.c | 6 +++--- 3 files changed, 20 insertions(+), 14 deletions(-)
include/linux/filter.h +5 -5
@@ -554,9 +554,9 @@ struct bpf_binary_header { };struct bpf_prog_stats { -u64 cnt; -u64 nsecs; -u64 misses; +u64_stats_t cnt; +u64_stats_t nsecs; +u64_stats_t misses;struct u64_stats_sync syncp; }__aligned(2 * sizeof(u64)) ;
@@ -618,8 +618,8 @@ static __always_inline u32 __bpf_prog_run(const struct bpf_prog *prog, ret =dfunc (ctx, prog->insnsi, prog->bpf_func); stats =this_cpu_ptr (prog->stats); flags =u64_stats_update_begin_irqsave (&stats->syncp); - stats->cnt++; - stats->nsecs +=sched_clock () - start; +u64_stats_inc (&stats->cnt); +u64_stats_add (&stats->nsecs,sched_clock () - start);u64_stats_update_end_irqrestore (&stats->syncp, flags); }else { ret =dfunc (ctx, prog->insnsi, prog->bpf_func);
kernel/bpf/syscall.c +12 -6
@@ -1824,8 +1824,14 @@ static int bpf_prog_release(struct inode *inode, struct file *filp)return 0 ; } +struct bpf_prog_kstats { +u64 nsecs; +u64 cnt; +u64 misses; +}; +static void bpf_prog_get_stats (const struct bpf_prog *prog, -struct bpf_prog_stats *stats) +struct bpf_prog_kstats *stats) {u64 nsecs =0 , cnt =0 , misses =0 ;int cpu;
@@ -1838,9 +1844,9 @@ static void bpf_prog_get_stats(const struct bpf_prog *prog, st =per_cpu_ptr (prog->stats, cpu);do { start =u64_stats_fetch_begin_irq (&st->syncp); - tnsecs = st->nsecs; - tcnt = st->cnt; - tmisses = st->misses; + tnsecs =u64_stats_read (&st->nsecs); + tcnt =u64_stats_read (&st->cnt); + tmisses =u64_stats_read (&st->misses); }while (u64_stats_fetch_retry_irq (&st->syncp, start)); nsecs += tnsecs; cnt += tcnt;
@@ -1856,7 +1862,7 @@ static void bpf_prog_show_fdinfo(struct seq_file *m, struct file *filp) {const struct bpf_prog *prog = filp->private_data;char prog_tag[sizeof (prog->tag) *2 +1 ] = { }; -struct bpf_prog_stats stats; +struct bpf_prog_kstats stats;bpf_prog_get_stats (prog, &stats);bin2hex (prog_tag, prog->tag,sizeof (prog->tag));
@@ -3595,7 +3601,7 @@ static int bpf_prog_get_info_by_fd(struct file *file,struct bpf_prog_info __user *uinfo =u64_to_user_ptr (attr->info.info);struct bpf_prog_info info;u32 info_len = attr->info.info_len; -struct bpf_prog_stats stats; +struct bpf_prog_kstats stats;char __user *uinsns;u32 ulen;int err;
kernel/bpf/trampoline.c +3 -3
@@ -544,7 +544,7 @@ static void notrace inc_misses_counter(struct bpf_prog *prog) stats =this_cpu_ptr (prog->stats);u64_stats_update_begin (&stats->syncp); - stats->misses++; +u64_stats_inc (&stats->misses);u64_stats_update_end (&stats->syncp); }
@@ -589,8 +589,8 @@ static void notrace update_prog_stats(struct bpf_prog *prog, stats =this_cpu_ptr (prog->stats); flags =u64_stats_update_begin_irqsave (&stats->syncp); - stats->cnt++; - stats->nsecs +=sched_clock () - start; +u64_stats_inc (&stats->cnt); +u64_stats_add (&stats->nsecs,sched_clock () - start);u64_stats_update_end_irqrestore (&stats->syncp, flags); } }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 113/262 bpf: Fix possible race in inc_misses_counter
In reply to Greg Kroah-HartmanFrom: He Fengqing <[email protected]>
[ Upstream commit 0e3135d3bfa5dfb658145238d2bc723a8e30c3a3 ]
It seems inc_misses_counter() suffers from same issue fixed in the commit d979617aa84d ("bpf: Fixes possible race in update_prog_stats() for 32bit arches"):
As it can run while interrupts are enabled, it could
be re-entered and the u64_stats syncp could be mangled.
--- kernel/bpf/trampoline.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/bpf/trampoline.c +3 -2
@@ -541,11 +541,12 @@ static u64 notrace bpf_prog_start_time(void) static void notrace inc_misses_counter(struct bpf_prog *prog) {struct bpf_prog_stats *stats; +unsigned int flags; stats =this_cpu_ptr (prog->stats); -u64_stats_update_begin (&stats->syncp); + flags =u64_stats_update_begin_irqsave (&stats->syncp);u64_stats_inc (&stats->misses); -u64_stats_update_end (&stats->syncp); +u64_stats_update_end_irqrestore (&stats->syncp, flags); }/* The logic is similar to bpf_prog_run(), but with an explicit
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 114/262 drm/amd/display: Update watermark values for DCN301
In reply to Greg Kroah-HartmanFrom: Agustin Gutierrez <[email protected]>
[ Upstream commit 2d8ae25d233767171942a9fba5fd8f4a620996be ]
[Why]
There is underflow / visual corruption DCN301, for high bandwidth MST DSC configurations such as 2x1440p144 or 2x4k60.
[How]
Use up-to-date watermark values for DCN301.
--- .../amd/display/dc/clk_mgr/dcn301/vg_clk_mgr.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn301/vg_clk_mgr.c +8 -8
@@ -582,32 +582,32 @@ static struct wm_table lpddr5_wm_table = { .wm_inst = WM_A, .wm_type = WM_TYPE_PSTATE_CHG, .pstate_latency_us = 11.65333, - .sr_exit_time_us = 7.95, - .sr_enter_plus_exit_time_us = 9, + .sr_exit_time_us = 13.5, + .sr_enter_plus_exit_time_us = 16.5, .valid = true, }, { .wm_inst = WM_B, .wm_type = WM_TYPE_PSTATE_CHG, .pstate_latency_us = 11.65333, - .sr_exit_time_us = 9.82, - .sr_enter_plus_exit_time_us = 11.196, + .sr_exit_time_us = 13.5, + .sr_enter_plus_exit_time_us = 16.5, .valid = true, }, { .wm_inst = WM_C, .wm_type = WM_TYPE_PSTATE_CHG, .pstate_latency_us = 11.65333, - .sr_exit_time_us = 9.89, - .sr_enter_plus_exit_time_us = 11.24, + .sr_exit_time_us = 13.5, + .sr_enter_plus_exit_time_us = 16.5, .valid = true, }, { .wm_inst = WM_D, .wm_type = WM_TYPE_PSTATE_CHG, .pstate_latency_us = 11.65333, - .sr_exit_time_us = 9.748, - .sr_enter_plus_exit_time_us = 11.102, + .sr_exit_time_us = 13.5, + .sr_enter_plus_exit_time_us = 16.5, .valid = true, }, }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 115/262 drm: mxsfb: Set fallback bus format when the bridge doesnt provide one
In reply to Greg Kroah-HartmanFrom: Guido Günther <[email protected]>
[ Upstream commit 1db060509903b29d63fe2e39c14fd0f99c4a447e ]
If a bridge doesn't do any bus format handling MEDIA_BUS_FMT_FIXED is returned. Fallback to a reasonable default (MEDIA_BUS_FMT_RGB888_1X24) in that case.
This unbreaks e.g. using mxsfb with the nwl bridge and mipi dsi panels.
--- drivers/gpu/drm/mxsfb/mxsfb_kms.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/mxsfb/mxsfb_kms.c +6 -0
@@ -362,6 +362,12 @@ static void mxsfb_crtc_atomic_enable(struct drm_crtc *crtc,drm_atomic_get_new_bridge_state (state, mxsfb->bridge); bus_format = bridge_state->input_bus_cfg.format; +if (bus_format ==MEDIA_BUS_FMT_FIXED ) { +dev_warn_once (drm->dev, +"Bridge does not provide bus format, assuming MEDIA_BUS_FMT_RGB888_1X24.\n" +"Please fix bridge driver by handling atomic_get_input_bus_fmts.\n" ); + bus_format =MEDIA_BUS_FMT_RGB888_1X24 ; + } }/* If there is no bridge, use bus format from connector */
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 116/262 drm: mxsfb: Fix NULL pointer dereference
In reply to Greg Kroah-HartmanFrom: Alexander Stein <[email protected]>
[ Upstream commit 622c9a3a7868e1eeca39c55305ca3ebec4742b64 ]
mxsfb should not ever dereference the NULL pointer which drm_atomic_get_new_bridge_state is allowed to return. Assume a fixed format instead.
--- drivers/gpu/drm/mxsfb/mxsfb_kms.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/mxsfb/mxsfb_kms.c +5 -1
@@ -361,7 +361,11 @@ static void mxsfb_crtc_atomic_enable(struct drm_crtc *crtc, bridge_state =drm_atomic_get_new_bridge_state (state, mxsfb->bridge); - bus_format = bridge_state->input_bus_cfg.format; +if (!bridge_state) + bus_format =MEDIA_BUS_FMT_FIXED ; +else + bus_format = bridge_state->input_bus_cfg.format; +if (bus_format ==MEDIA_BUS_FMT_FIXED ) {dev_warn_once (drm->dev, "Bridge does not provide bus format, assuming MEDIA_BUS_FMT_RGB888_1X24.\n"
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 117/262 riscv/mm: Add XIP_FIXUP for phys_ram_base
In reply to Greg Kroah-HartmanFrom: Palmer Dabbelt <[email protected]>
[ Upstream commit 4b1c70aa8ed8249608bb991380cb8ff423edf49e ]
This manifests as a crash early in boot on VexRiscv.
--- arch/riscv/mm/init.c | 1 + 1 file changed, 1 insertion(+)
arch/riscv/mm/init.c +1 -0
@@ -451,6 +451,7 @@ static uintptr_t __init best_map_size(phys_addr_t base, phys_addr_t size) }#ifdef CONFIG_XIP_KERNEL +#define phys_ram_base (*(phys_addr_t *)XIP_FIXUP(&phys_ram_base))/* called from head.S with MMU off */ asmlinkage void __init __copy_data(void) {
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 118/262 drm/i915/display: split out dpt out of intel_display.c
In reply to Greg Kroah-HartmanFrom: Jani Nikula <[email protected]>
[ Upstream commit dc6d6158a6e8b11a11544a541583296d9323050f ]
Let's try to reduce the size of intel_display.c, not increase it.
--- drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/display/intel_display.c | 220 +----------------- drivers/gpu/drm/i915/display/intel_dpt.c | 229 +++++++++++++++++++ drivers/gpu/drm/i915/display/intel_dpt.h | 19 ++ 4 files changed, 250 insertions(+), 219 deletions(-) create mode 100644 drivers/gpu/drm/i915/display/intel_dpt.c create mode 100644 drivers/gpu/drm/i915/display/intel_dpt.h
drivers/gpu/drm/i915/Makefile +1 -0
@@ -211,6 +211,7 @@ i915-y += \ display/intel_dpio_phy.o \ display/intel_dpll.o \ display/intel_dpll_mgr.o \ + display/intel_dpt.o \ display/intel_dsb.o \ display/intel_fb.o \ display/intel_fbc.o \
drivers/gpu/drm/i915/display/intel_display.c +1 -219
238 lines not on this page · raw message
drivers/gpu/drm/i915/display/intel_dpt.c new file +229 -0
229 lines not on this page · raw message
drivers/gpu/drm/i915/display/intel_dpt.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2021 Intel Corporation +*/ + +#ifndef __INTEL_DPT_H__ +#define __INTEL_DPT_H__ + +struct i915_address_space ; +struct i915_vma ; +struct intel_framebuffer ; + +void intel_dpt_destroy (struct i915_address_space *vm); +struct i915_vma *intel_dpt_pin (struct i915_address_space *vm); +void intel_dpt_unpin (struct i915_address_space *vm); +struct i915_address_space * +intel_dpt_create (struct intel_framebuffer *fb); + +#endif /* __INTEL_DPT_H__ */
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 119/262 drm/i915/display: Move DRRS code its own file
In reply to Greg Kroah-HartmanFrom: José Roberto de Souza <[email protected]>
[ Upstream commit a1b63119ee839c8ff622407aab25c9723943638a ]
intel_dp.c is a 5k lines monster, so moving DRRS out of it to reduce some lines from it.
--- Documentation/gpu/i915.rst | 14 +- drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/display/intel_ddi.c | 1 + .../drm/i915/display/intel_display_debugfs.c | 1 + drivers/gpu/drm/i915/display/intel_dp.c | 467 +---------------- drivers/gpu/drm/i915/display/intel_dp.h | 11 - drivers/gpu/drm/i915/display/intel_drrs.c | 477 ++++++++++++++++++ drivers/gpu/drm/i915/display/intel_drrs.h | 32 ++ .../gpu/drm/i915/display/intel_frontbuffer.c | 1 + 9 files changed, 521 insertions(+), 484 deletions(-) create mode 100644 drivers/gpu/drm/i915/display/intel_drrs.c create mode 100644 drivers/gpu/drm/i915/display/intel_drrs.h
Documentation/gpu/i915.rst +7 -7
@@ -183,25 +183,25 @@ Frame Buffer Compression (FBC) Display Refresh Rate Switching (DRRS) ------------------------------------- -.. kernel-doc:: drivers/gpu/drm/i915/display/intel_dp.c +.. kernel-doc:: drivers/gpu/drm/i915/display/intel_drrs.c :doc: Display Refresh Rate Switching (DRRS) -.. kernel-doc:: drivers/gpu/drm/i915/display/intel_dp.c +.. kernel-doc:: drivers/gpu/drm/i915/display/intel_drrs.c :functions: intel_dp_set_drrs_state -.. kernel-doc:: drivers/gpu/drm/i915/display/intel_dp.c +.. kernel-doc:: drivers/gpu/drm/i915/display/intel_drrs.c :functions: intel_edp_drrs_enable -.. kernel-doc:: drivers/gpu/drm/i915/display/intel_dp.c +.. kernel-doc:: drivers/gpu/drm/i915/display/intel_drrs.c :functions: intel_edp_drrs_disable -.. kernel-doc:: drivers/gpu/drm/i915/display/intel_dp.c +.. kernel-doc:: drivers/gpu/drm/i915/display/intel_drrs.c :functions: intel_edp_drrs_invalidate -.. kernel-doc:: drivers/gpu/drm/i915/display/intel_dp.c +.. kernel-doc:: drivers/gpu/drm/i915/display/intel_drrs.c :functions: intel_edp_drrs_flush -.. kernel-doc:: drivers/gpu/drm/i915/display/intel_dp.c +.. kernel-doc:: drivers/gpu/drm/i915/display/intel_drrs.c :functions: intel_dp_drrs_init DPIO
drivers/gpu/drm/i915/Makefile +1 -0
@@ -212,6 +212,7 @@ i915-y += \ display/intel_dpll.o \ display/intel_dpll_mgr.o \ display/intel_dpt.o \ + display/intel_drrs.o \ display/intel_dsb.o \ display/intel_fb.o \ display/intel_fbc.o \
drivers/gpu/drm/i915/display/intel_ddi.c +1 -0
@@ -40,6 +40,7 @@#include "intel_dp_link_training.h" #include "intel_dp_mst.h" #include "intel_dpio_phy.h" +#include "intel_drrs.h" #include "intel_dsi.h" #include "intel_fdi.h" #include "intel_fifo_underrun.h"
drivers/gpu/drm/i915/display/intel_display_debugfs.c +1 -0
@@ -13,6 +13,7 @@#include "intel_display_types.h" #include "intel_dmc.h" #include "intel_dp.h" +#include "intel_drrs.h" #include "intel_fbc.h" #include "intel_hdcp.h" #include "intel_hdmi.h"
drivers/gpu/drm/i915/display/intel_dp.c +1 -466
485 lines not on this page · raw message
drivers/gpu/drm/i915/display/intel_dp.h +0 -11
@@ -70,17 +70,6 @@ int intel_dp_max_link_rate(struct intel_dp *intel_dp);int intel_dp_max_lane_count (struct intel_dp *intel_dp);int intel_dp_rate_select (struct intel_dp *intel_dp,int rate); -void intel_edp_drrs_enable (struct intel_dp *intel_dp, -const struct intel_crtc_state *crtc_state); -void intel_edp_drrs_disable (struct intel_dp *intel_dp, -const struct intel_crtc_state *crtc_state); -void intel_edp_drrs_update (struct intel_dp *intel_dp, -const struct intel_crtc_state *crtc_state); -void intel_edp_drrs_invalidate (struct drm_i915_private *dev_priv, -unsigned int frontbuffer_bits); -void intel_edp_drrs_flush (struct drm_i915_private *dev_priv, -unsigned int frontbuffer_bits); -void intel_dp_compute_rate (struct intel_dp *intel_dp,int port_clock,u8 *link_bw,u8 *rate_select);bool intel_dp_source_supports_hbr2 (struct intel_dp *intel_dp);
drivers/gpu/drm/i915/display/intel_drrs.c new file +477 -0
477 lines not on this page · raw message
drivers/gpu/drm/i915/display/intel_drrs.h new file +32 -0
@@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2021 Intel Corporation +*/ + +#ifndef __INTEL_DRRS_H__ +#define __INTEL_DRRS_H__ + +#include <linux/types.h> + +struct drm_i915_private ; +struct intel_crtc_state ; +struct intel_connector ; +struct intel_dp ; + +void intel_edp_drrs_enable (struct intel_dp *intel_dp, +const struct intel_crtc_state *crtc_state); +void intel_edp_drrs_disable (struct intel_dp *intel_dp, +const struct intel_crtc_state *crtc_state); +void intel_edp_drrs_update (struct intel_dp *intel_dp, +const struct intel_crtc_state *crtc_state); +void intel_edp_drrs_invalidate (struct drm_i915_private *dev_priv, +unsigned int frontbuffer_bits); +void intel_edp_drrs_flush (struct drm_i915_private *dev_priv, +unsigned int frontbuffer_bits); +void intel_dp_drrs_compute_config (struct intel_dp *intel_dp, +struct intel_crtc_state *pipe_config, +int output_bpp,bool constant_n); +struct drm_display_mode *intel_dp_drrs_init (struct intel_connector *connector, +struct drm_display_mode *fixed_mode); + +#endif /* __INTEL_DRRS_H__ */
drivers/gpu/drm/i915/display/intel_frontbuffer.c +1 -0
@@ -62,6 +62,7 @@#include "intel_display_types.h" #include "intel_fbc.h" #include "intel_frontbuffer.h" +#include "intel_drrs.h" #include "intel_psr.h" /**
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 120/262 drm/i915: Disable DRRS on IVB/HSW port != A
In reply to Greg Kroah-HartmanFrom: Ville Syrjälä <[email protected]>
[ Upstream commit ee59792c97176f12c1da31f29fc4c2aab187f06e ]
Currently we allow DRRS on IVB PCH ports, but we're missing a few programming steps meaning it is guaranteed to not work. And on HSW DRRS is not supported on anything but port A ever as only transcoder EDP has the M2/N2 registers (though I'm not sure if HSW ever has eDP on any other port).
Starting from BDW all transcoders have the dynamically reprogrammable M/N registers so DRRS could work on any port.
Stop initializing DRRS on ports where it cannot possibly work.
--- drivers/gpu/drm/i915/display/intel_drrs.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/gpu/drm/i915/display/intel_drrs.c +8 -0
@@ -445,6 +445,7 @@ intel_dp_drrs_init(struct intel_connector *connector, struct drm_display_mode *fixed_mode) {struct drm_i915_private *dev_priv =to_i915 (connector->base.dev); +struct intel_encoder *encoder = connector->encoder;struct drm_display_mode *downclock_mode =NULL ;INIT_DELAYED_WORK (&dev_priv->drrs.work, intel_edp_drrs_downclock_work);
@@ -456,6 +457,13 @@ intel_dp_drrs_init(struct intel_connector *connector,return NULL ; } +if ((DISPLAY_VER (dev_priv) <8 && !HAS_GMCH (dev_priv)) && + encoder->port !=PORT_A ) { +drm_dbg_kms (&dev_priv->drm, +"DRRS only supported on eDP port A\n" ); +return NULL ; + } +if (dev_priv->vbt.drrs_type !=SEAMLESS_DRRS_SUPPORT ) {drm_dbg_kms (&dev_priv->drm,"VBT doesn't support DRRS\n" );return NULL ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 121/262 gve: Recording rx queue before sending to napi
In reply to Greg Kroah-HartmanFrom: Tao Liu <[email protected]>
[ Upstream commit 084cbb2ec3af2d23be9de65fcc9493e21e265859 ]
This caused a significant performance degredation when using generic XDP with multiple queues.
--- drivers/net/ethernet/google/gve/gve_rx.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/google/gve/gve_rx.c +1 -0
@@ -450,6 +450,7 @@ static bool gve_rx(struct gve_rx_ring *rx, struct gve_rx_desc *rx_desc,skb_set_hash (skb,be32_to_cpu (rx_desc->rss_hash),gve_rss_type (rx_desc->flags_seq)); +skb_record_rx_queue (skb, rx->q_num);if (skb_is_nonlinear (skb))napi_gro_frags (napi);else
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 122/262 net: dsa: ocelot: seville: utilize of_mdiobus_register
In reply to Greg Kroah-HartmanFrom: Colin Foster <[email protected]>
[ Upstream commit 5186c4a05b9713138b762a49467a8ab9753cdb36 ]
Switch seville to use of_mdiobus_register(bus, NULL) instead of just mdiobus_register. This code is about to be pulled into a separate module that can optionally define ports by the device_node.
--- drivers/net/dsa/ocelot/seville_vsc9953.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/dsa/ocelot/seville_vsc9953.c +2 -1
@@ -10,6 +10,7 @@#include <linux/pcs-lynx.h> #include <linux/dsa/ocelot.h> #include <linux/iopoll.h> +#include <linux/of_mdio.h> #include "felix.h" #define MSCC_MIIM_CMD_OPR_WRITE BIT(1)
@@ -1110,7 +1111,7 @@ static int vsc9953_mdio_bus_alloc(struct ocelot *ocelot)snprintf (bus->id,MII_BUS_ID_SIZE ,"%s-imdio" ,dev_name (dev));/* Needed in order to initialize the bus mutex lock */ - rc =mdiobus_register (bus); + rc =of_mdiobus_register (bus,NULL );if (rc <0 ) {dev_err (dev,"failed to register MDIO bus\n" );return rc;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 123/262 net: dsa: seville: register the mdiobus under devres
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit bd488afc3b39e045ba71aab472233f2a78726e7b ]
As explained in commits:74b6d7d13307 ("net: dsa: realtek: register the MDIO bus under devres") 5135e96a3dd2 ("net: dsa: don't allocate the slave_mii_bus using devres")
mdiobus_free() will panic when called from devm_mdiobus_free() <- devres_release_all() <- __device_release_driver(), and that mdiobus was not previously unregistered.
The Seville VSC9959 switch is a platform device, so the initial set of constraints that I thought would cause this (I2C or SPI buses which call ->remove on ->shutdown) do not apply. But there is one more which applies here.
If the DSA master itself is on a bus that calls ->remove from ->shutdown (like dpaa2-eth, which is on the fsl-mc bus), there is a device link between the switch and the DSA master, and device_links_unbind_consumers() will unbind the seville switch driver on shutdown.
So the same treatment must be applied to all DSA switch drivers, which
is: either use devres for both the mdiobus allocation and registration, or don't use devres at all.
The seville driver has a code structure that could accommodate both the mdiobus_unregister and mdiobus_free calls, but it has an external dependency upon mscc_miim_setup() from mdio-mscc-miim.c, which calls devm_mdiobus_alloc_size() on its behalf. So rather than restructuring that, and exporting yet one more symbol mscc_miim_teardown(), let's work with devres and replace of_mdiobus_register with the devres variant. When we use all-devres, we can ensure that devres doesn't free a still-registered bus (it either runs both callbacks, or none).
--- drivers/net/dsa/ocelot/seville_vsc9953.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/dsa/ocelot/seville_vsc9953.c +3 -2
@@ -1111,7 +1111,7 @@ static int vsc9953_mdio_bus_alloc(struct ocelot *ocelot)snprintf (bus->id,MII_BUS_ID_SIZE ,"%s-imdio" ,dev_name (dev));/* Needed in order to initialize the bus mutex lock */ - rc =of_mdiobus_register (bus,NULL ); + rc =devm_of_mdiobus_register (dev, bus,NULL );if (rc <0 ) {dev_err (dev,"failed to register MDIO bus\n" );return rc;
@@ -1163,7 +1163,8 @@ static void vsc9953_mdio_bus_free(struct ocelot *ocelot)mdio_device_free (pcs->mdio);lynx_pcs_destroy (pcs); } -mdiobus_unregister (felix->imdio); + +/* mdiobus_unregister and mdiobus_free handled by devres */ }static const struct felix_info seville_info_vsc9953 = {
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 124/262 ibmvnic: dont release napi in __ibmvnic_open()
In reply to Greg Kroah-HartmanFrom: Sukadev Bhattiprolu <[email protected]>
[ Upstream commit 61772b0908c640d0309c40f7d41d062ca4e979fa ]
If __ibmvnic_open() encounters an error such as when setting link state, it calls release_resources() which frees the napi structures needlessly. Instead, have __ibmvnic_open() only clean up the work it did so far (i.e. disable napi and irqs) and leave the rest to the callers.
If caller of __ibmvnic_open() is ibmvnic_open(), it should release the resources immediately. If the caller is do_reset() or do_hard_reset(), they will release the resources on the next reset.
This fixes following crash that occurred when running the drmgr command several times to add/remove a vnic interface:
[102056] ibmvnic 30000003 env3: Disabling rx_scrq[6] irq [102056] ibmvnic 30000003 env3: Disabling rx_scrq[7] irq [102056] ibmvnic 30000003 env3: Replenished 8 pools Kernel attempted to read user page (10) - exploit attempt? (uid: 0) BUG: Kernel NULL pointer dereference on read at 0x00000010 Faulting instruction address: 0xc000000000a3c840 Oops: Kernel access of bad area, sig: 11 [#1] LE PAGE_SIZE=64K MMU=Radix SMP NR_CPUS=2048 NUMA pSeries ... CPU: 9 PID: 102056 Comm: kworker/9:2 Kdump: loaded Not tainted 5.16.0-rc5-autotest-g6441998e2e37 #1 Workqueue: events_long __ibmvnic_reset [ibmvnic] NIP: c000000000a3c840 LR: c0080000029b5378 CTR: c000000000a3c820 REGS: c0000000548e37e0 TRAP: 0300 Not tainted (5.16.0-rc5-autotest-g6441998e2e37) MSR: 8000000000009033 <SF,EE,ME,IR,DR,RI,LE> CR: 28248484 XER: 00000004 CFAR: c0080000029bdd24 DAR: 0000000000000010 DSISR: 40000000 IRQMASK: 0 GPR00: c0080000029b55d0 c0000000548e3a80 c0000000028f0200 0000000000000000 ... NIP [c000000000a3c840] napi_enable+0x20/0xc0 LR [c0080000029b5378] __ibmvnic_open+0xf0/0x430 [ibmvnic] Call Trace: [c0000000548e3a80] [0000000000000006] 0x6 (unreliable) [c0000000548e3ab0] [c0080000029b55d0] __ibmvnic_open+0x348/0x430 [ibmvnic] [c0000000548e3b40] [c0080000029bcc28] __ibmvnic_reset+0x500/0xdf0 [ibmvnic] [c0000000548e3c60] [c000000000176228] process_one_work+0x288/0x570 [c0000000548e3d00] [c000000000176588] worker_thread+0x78/0x660 [c0000000548e3da0] [c0000000001822f0] kthread+0x1c0/0x1d0 [c0000000548e3e10] [c00000000000cf64] ret_from_kernel_thread+0x5c/0x64 Instruction dump: 7d2948f8 792307e0 4e800020 60000000 3c4c01eb 384239e0 f821ffd1 39430010 38a0fff6 e92d1100 f9210028 39200000 <e9030010> f9010020 60420000 e9210020 ---[ end trace 5f8033b08fd27706 ]---
--- drivers/net/ethernet/ibm/ibmvnic.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/net/ethernet/ibm/ibmvnic.c +7 -2
@@ -108,6 +108,7 @@ static int init_crq_queue(struct ibmvnic_adapter *adapter);static int send_query_phys_parms (struct ibmvnic_adapter *adapter);static void ibmvnic_tx_scrq_clean_buffer (struct ibmvnic_adapter *adapter,struct ibmvnic_sub_crq_queue *tx_scrq); +static void ibmvnic_disable_irqs (struct ibmvnic_adapter *adapter);struct ibmvnic_stat {char name[ETH_GSTRING_LEN ];
@@ -1245,7 +1246,7 @@ static int __ibmvnic_open(struct net_device *netdev) rc =set_link_state (adapter,IBMVNIC_LOGICAL_LNK_UP );if (rc) {ibmvnic_napi_disable (adapter); -release_resources (adapter); +ibmvnic_disable_irqs (adapter);return rc; }
@@ -1295,7 +1296,6 @@ static int ibmvnic_open(struct net_device *netdev) rc =init_resources (adapter);if (rc) {netdev_err (netdev,"failed to initialize resources\n" ); -release_resources (adapter); goto out; } }
@@ -1312,6 +1312,11 @@ static int ibmvnic_open(struct net_device *netdev) adapter->state =VNIC_OPEN ; rc =0 ; } + +if (rc) { +release_resources (adapter); + } +return rc; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 125/262 of: net: move of_net under net/
In reply to Greg Kroah-HartmanFrom: Jakub Kicinski <[email protected]>
[ Upstream commit e330fb14590c5c80f7195c3d8c9b4bcf79e1a5cd ]
Rob suggests to move of_net.c from under drivers/of/ somewhere to the networking code.
---
drivers/net/ethernet/amd/Kconfig | 2 +-
drivers/net/ethernet/arc/Kconfig | 4 ++--
drivers/net/ethernet/ezchip/Kconfig | 2 +-
drivers/net/ethernet/litex/Kconfig | 2 +-
drivers/net/ethernet/mscc/Kconfig | 2 +-
drivers/of/Kconfig | 4 ----
drivers/of/Makefile | 1 -
include/linux/of_net.h | 2 +-
net/core/Makefile | 1 +
net/core/net-sysfs.c | 2 +-
{drivers/of => net/core}/of_net.c | 0
11 files changed, 9 insertions(+), 13 deletions(-)
rename {drivers/of => net/core}/of_net.c (100%)drivers/net/ethernet/amd/Kconfig +1 -1
@@ -168,7 +168,7 @@ config SUNLANCE config AMD_XGBE tristate "AMD 10GbE Ethernet driver" - depends on ((OF_NET && OF_ADDRESS) || ACPI || PCI) && HAS_IOMEM + depends on (OF_ADDRESS || ACPI || PCI) && HAS_IOMEM depends on X86 || ARM64 || COMPILE_TEST depends on PTP_1588_CLOCK_OPTIONAL select BITREVERSE
drivers/net/ethernet/arc/Kconfig +2 -2
@@ -26,7 +26,7 @@ config ARC_EMAC_CORE config ARC_EMAC tristate "ARC EMAC support" select ARC_EMAC_CORE - depends on OF_IRQ && OF_NET + depends on OF_IRQ depends on ARC || COMPILE_TEST help On some legacy ARC (Synopsys) FPGA boards such as ARCAngel4/ML50x
@@ -36,7 +36,7 @@ config ARC_EMAC config EMAC_ROCKCHIP tristate "Rockchip EMAC support" select ARC_EMAC_CORE - depends on OF_IRQ && OF_NET && REGULATOR + depends on OF_IRQ && REGULATOR depends on ARCH_ROCKCHIP || COMPILE_TEST help Support for Rockchip RK3036/RK3066/RK3188 EMAC ethernet controllers.
drivers/net/ethernet/ezchip/Kconfig +1 -1
@@ -18,7 +18,7 @@ if NET_VENDOR_EZCHIP config EZCHIP_NPS_MANAGEMENT_ENET tristate "EZchip NPS management enet support" - depends on OF_IRQ && OF_NET + depends on OF_IRQ depends on HAS_IOMEM help Simple LAN device for debug or management purposes.
drivers/net/ethernet/litex/Kconfig +1 -1
@@ -17,7 +17,7 @@ if NET_VENDOR_LITEX config LITEX_LITEETH tristate "LiteX Ethernet support" - depends on OF_NET + depends on OF help If you wish to compile a kernel for hardware with a LiteX LiteEth device then you should answer Y to this.
drivers/net/ethernet/mscc/Kconfig +1 -1
@@ -28,7 +28,7 @@ config MSCC_OCELOT_SWITCH depends on BRIDGE || BRIDGE=n depends on NET_SWITCHDEV depends on HAS_IOMEM - depends on OF_NET + depends on OF select MSCC_OCELOT_SWITCH_LIB select GENERIC_PHY help
drivers/of/Kconfig +0 -4
@@ -70,10 +70,6 @@ config OF_IRQ def_bool y depends on !SPARC && IRQ_DOMAIN -config OF_NET - depends on NETDEVICES - def_bool y - config OF_RESERVED_MEM def_bool OF_EARLY_FLATTREE
drivers/of/Makefile +0 -1
@@ -7,7 +7,6 @@ obj-$(CONFIG_OF_EARLY_FLATTREE) += fdt_address.o obj-$(CONFIG_OF_PROMTREE) += pdt.o obj-$(CONFIG_OF_ADDRESS) += address.o obj-$(CONFIG_OF_IRQ) += irq.o -obj-$(CONFIG_OF_NET) += of_net.o obj-$(CONFIG_OF_UNITTEST) += unittest.o obj-$(CONFIG_OF_RESERVED_MEM) += of_reserved_mem.o obj-$(CONFIG_OF_RESOLVE) += resolver.o
include/linux/of_net.h +1 -1
@@ -8,7 +8,7 @@#include <linux/phy.h> -#ifdef CONFIG_OF_NET +#ifdef CONFIG_OF #include <linux/of.h> struct net_device ;
net/core/Makefile +1 -0
@@ -36,3 +36,4 @@ obj-$(CONFIG_FAILOVER) += failover.o obj-$(CONFIG_NET_SOCK_MSG) += skmsg.o obj-$(CONFIG_BPF_SYSCALL) += sock_map.o obj-$(CONFIG_BPF_SYSCALL) += bpf_sk_storage.o +obj-$(CONFIG_OF) += of_net.o
net/core/net-sysfs.c +1 -1
@@ -1927,7 +1927,7 @@ static struct class net_class __ro_after_init = { .get_ownership = net_get_ownership, }; -#ifdef CONFIG_OF_NET +#ifdef CONFIG_OF static int of_dev_node_match (struct device *dev,const void *data) {for (; dev; dev = dev->parent) {
net/core/of_net.c renamed from drivers/of/of_net.c +0 -0
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 126/262 net: ethernet: litex: Add the dependency on HAS_IOMEM
In reply to Greg Kroah-HartmanFrom: Cai Huoqing <[email protected]>
[ Upstream commit 2427f03fb42f9dc14c53108f2c9b5563eb37e770 ]
The LiteX driver uses devm io function API which needs HAS_IOMEM enabled, so add the dependency on HAS_IOMEM.
--- drivers/net/ethernet/litex/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/litex/Kconfig +1 -1
@@ -17,7 +17,7 @@ if NET_VENDOR_LITEX config LITEX_LITEETH tristate "LiteX Ethernet support" - depends on OF + depends on OF && HAS_IOMEM help If you wish to compile a kernel for hardware with a LiteX LiteEth device then you should answer Y to this.
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 127/262 drm/mediatek: mtk_dsi: Reset the dsi0 hardware
In reply to Greg Kroah-HartmanFrom: Enric Balletbo i Serra <[email protected]>
[ Upstream commit 605c83753d97946aab176735020a33ebfb0b4615 ]
Reset dsi0 HW to default when power on. This prevents to have different settingis between the bootloader and the kernel.
As not all Mediatek boards have the reset consumer configured in their board description, also is not needed on all of them, the reset is optional, so the change is compatible with all boards.
--- drivers/gpu/drm/mediatek/mtk_dsi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/mediatek/mtk_dsi.c +4 -1
@@ -11,6 +11,7 @@#include <linux/of_platform.h> #include <linux/phy/phy.h> #include <linux/platform_device.h> +#include <linux/reset.h> #include <video/mipi_display.h> #include <video/videomode.h>
@@ -980,8 +981,10 @@ static int mtk_dsi_bind(struct device *dev, struct device *master, void *data)struct mtk_dsi *dsi =dev_get_drvdata (dev); ret =mtk_dsi_encoder_init (drm, dsi); +if (ret) +return ret; -return ret; +return device_reset_optional (dev); } static void mtk_dsi_unbind(struct device *dev, struct device *master,
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 128/262 drm/mediatek: mtk_dsi: Avoid EPROBE_DEFER loop with external bridge
In reply to Greg Kroah-HartmanFrom: AngeloGioacchino Del Regno <[email protected]>
[ Upstream commit 647474b8d980256b26b1cd112d7333a4dbd4260a ]
DRM bridge drivers are now attaching their DSI device at probe time, which requires us to register our DSI host in order to let the bridge to probe: this recently started producing an endless -EPROBE_DEFER loop on some machines that are using external bridges, like the parade-ps8640, found on the ACER Chromebook R13.
Now that the DSI hosts/devices probe sequence is documented, we can do adjustments to the mtk_dsi driver as to both fix now and make sure to avoid this situation in the future: for this, following what is documented in drm_bridge.c, move the mtk_dsi component_add() to the mtk_dsi_ops.attach callback and delete it in the detach callback; keeping in mind that we are registering a drm_bridge for our DSI, which is only used/attached if the DSI Host is bound, it wouldn't make sense to keep adding our bridge at probe time (as it would be useless to have it if mtk_dsi_ops.attach() fails!), so also move that one to the dsi host attach function (and remove it in detach).
--- drivers/gpu/drm/mediatek/mtk_dsi.c | 167 +++++++++++++++-------------- 1 file changed, 84 insertions(+), 83 deletions(-)
drivers/gpu/drm/mediatek/mtk_dsi.c +84 -83
@@ -786,18 +786,101 @@ void mtk_dsi_ddp_stop(struct device *dev)mtk_dsi_poweroff (dsi); } +static int mtk_dsi_encoder_init (struct drm_device *drm,struct mtk_dsi *dsi) +{ +int ret; + + ret =drm_simple_encoder_init (drm, &dsi->encoder, +DRM_MODE_ENCODER_DSI ); +if (ret) { +DRM_ERROR ("Failed to encoder init to drm\n" ); +return ret; + } + + dsi->encoder.possible_crtcs =mtk_drm_find_possible_crtc_by_comp (drm, dsi->host.dev); + + ret =drm_bridge_attach (&dsi->encoder, &dsi->bridge,NULL , +DRM_BRIDGE_ATTACH_NO_CONNECTOR ); +if (ret) + goto err_cleanup_encoder; + + dsi->connector =drm_bridge_connector_init (drm, &dsi->encoder); +if (IS_ERR (dsi->connector)) { +DRM_ERROR ("Unable to create bridge connector\n" ); + ret =PTR_ERR (dsi->connector); + goto err_cleanup_encoder; + } +drm_connector_attach_encoder (dsi->connector, &dsi->encoder); + +return 0 ; + +err_cleanup_encoder: +drm_encoder_cleanup (&dsi->encoder); +return ret; +} + +static int mtk_dsi_bind (struct device *dev,struct device *master,void *data) +{ +int ret; +struct drm_device *drm = data; +struct mtk_dsi *dsi =dev_get_drvdata (dev); + + ret =mtk_dsi_encoder_init (drm, dsi); +if (ret) +return ret; + +return device_reset_optional (dev); +} + +static void mtk_dsi_unbind (struct device *dev,struct device *master, +void *data) +{ +struct mtk_dsi *dsi =dev_get_drvdata (dev); + +drm_encoder_cleanup (&dsi->encoder); +} + +static const struct component_ops mtk_dsi_component_ops = { + .bind = mtk_dsi_bind, + .unbind = mtk_dsi_unbind, +}; +static int mtk_dsi_host_attach (struct mipi_dsi_host *host,struct mipi_dsi_device *device) {struct mtk_dsi *dsi =host_to_dsi (host); +struct device *dev = host->dev; +int ret; dsi->lanes = device->lanes; dsi->format = device->format; dsi->mode_flags = device->mode_flags; + dsi->next_bridge =devm_drm_of_get_bridge (dev, dev->of_node,0 ,0 ); +if (IS_ERR (dsi->next_bridge)) +return PTR_ERR (dsi->next_bridge); + +drm_bridge_add (&dsi->bridge); + + ret =component_add (host->dev, &mtk_dsi_component_ops); +if (ret) { +DRM_ERROR ("failed to add dsi_host component: %d\n" , ret); +drm_bridge_remove (&dsi->bridge); +return ret; + }return 0 ; } +static int mtk_dsi_host_detach (struct mipi_dsi_host *host, +struct mipi_dsi_device *device) +{ +struct mtk_dsi *dsi =host_to_dsi (host); + +component_del (host->dev, &mtk_dsi_component_ops); +drm_bridge_remove (&dsi->bridge); +return 0 ; +} +static void mtk_dsi_wait_for_idle (struct mtk_dsi *dsi) {int ret;
@@ -938,73 +1021,14 @@ static ssize_t mtk_dsi_host_transfer(struct mipi_dsi_host *host,static const struct mipi_dsi_host_ops mtk_dsi_ops = { .attach = mtk_dsi_host_attach, + .detach = mtk_dsi_host_detach, .transfer = mtk_dsi_host_transfer, }; -static int mtk_dsi_encoder_init (struct drm_device *drm,struct mtk_dsi *dsi) -{ -int ret; - - ret =drm_simple_encoder_init (drm, &dsi->encoder, -DRM_MODE_ENCODER_DSI ); -if (ret) { -DRM_ERROR ("Failed to encoder init to drm\n" ); -return ret; - } - - dsi->encoder.possible_crtcs =mtk_drm_find_possible_crtc_by_comp (drm, dsi->host.dev); - - ret =drm_bridge_attach (&dsi->encoder, &dsi->bridge,NULL , -DRM_BRIDGE_ATTACH_NO_CONNECTOR ); -if (ret) - goto err_cleanup_encoder; - - dsi->connector =drm_bridge_connector_init (drm, &dsi->encoder); -if (IS_ERR (dsi->connector)) { -DRM_ERROR ("Unable to create bridge connector\n" ); - ret =PTR_ERR (dsi->connector); - goto err_cleanup_encoder; - } -drm_connector_attach_encoder (dsi->connector, &dsi->encoder); - -return 0 ; - -err_cleanup_encoder: -drm_encoder_cleanup (&dsi->encoder); -return ret; -} - -static int mtk_dsi_bind (struct device *dev,struct device *master,void *data) -{ -int ret; -struct drm_device *drm = data; -struct mtk_dsi *dsi =dev_get_drvdata (dev); - - ret =mtk_dsi_encoder_init (drm, dsi); -if (ret) -return ret; - -return device_reset_optional (dev); -} - -static void mtk_dsi_unbind (struct device *dev,struct device *master, -void *data) -{ -struct mtk_dsi *dsi =dev_get_drvdata (dev); - -drm_encoder_cleanup (&dsi->encoder); -} - -static const struct component_ops mtk_dsi_component_ops = { - .bind = mtk_dsi_bind, - .unbind = mtk_dsi_unbind, -}; -static int mtk_dsi_probe (struct platform_device *pdev) {struct mtk_dsi *dsi;struct device *dev = &pdev->dev; -struct drm_panel *panel;struct resource *regs;int irq_num;int ret;
@@ -1021,19 +1045,6 @@ static int mtk_dsi_probe(struct platform_device *pdev)return ret; } - ret =drm_of_find_panel_or_bridge (dev->of_node,0 ,0 , - &panel, &dsi->next_bridge); -if (ret) - goto err_unregister_host; - -if (panel) { - dsi->next_bridge =devm_drm_panel_bridge_add (dev, panel); -if (IS_ERR (dsi->next_bridge)) { - ret =PTR_ERR (dsi->next_bridge); - goto err_unregister_host; - } - } - dsi->driver_data =of_device_get_match_data (dev); dsi->engine_clk =devm_clk_get (dev,"engine" );
@@ -1098,14 +1109,6 @@ static int mtk_dsi_probe(struct platform_device *pdev) dsi->bridge.of_node = dev->of_node; dsi->bridge.type =DRM_MODE_CONNECTOR_DSI ; -drm_bridge_add (&dsi->bridge); - - ret =component_add (&pdev->dev, &mtk_dsi_component_ops); -if (ret) { -dev_err (&pdev->dev,"failed to add component: %d\n" , ret); - goto err_unregister_host; - } -return 0 ; err_unregister_host:
@@ -1118,8 +1121,6 @@ static int mtk_dsi_remove(struct platform_device *pdev)struct mtk_dsi *dsi =platform_get_drvdata (pdev);mtk_output_dsi_disable (dsi); -drm_bridge_remove (&dsi->bridge); -component_del (&pdev->dev, &mtk_dsi_component_ops);mipi_dsi_host_unregister (&dsi->host);return 0 ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 129/262 cifs: protect session channel fields with chan_lock
In reply to Greg Kroah-HartmanFrom: Shyam Prasad N <[email protected]>
[ Upstream commit 724244cdb3828522109c88e56a0242537aefabe9 ]
Introducing a new spin lock to protect all the channel related fields in a cifs_ses struct. This lock should be taken whenever dealing with the channel fields, and should be held only for very short intervals which will not sleep.
Currently, all channel related fields in cifs_ses structure are protected by session_mutex. However, this mutex is held for long periods (sometimes while waiting for a reply from server). This makes the codepath quite tricky to change.
--- fs/cifs/cifs_debug.c | 2 ++ fs/cifs/cifsglob.h | 5 +++++ fs/cifs/connect.c | 25 +++++++++++++++++++--- fs/cifs/misc.c | 1 + fs/cifs/sess.c | 50 +++++++++++++++++++++++++++++++++----------- fs/cifs/transport.c | 3 +++ 6 files changed, 71 insertions(+), 15 deletions(-)
fs/cifs/cifs_debug.c +2 -0
@@ -414,12 +414,14 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)from_kuid (&init_user_ns, ses->linux_uid), from_kuid(&init_user_ns, ses->cred_uid)); +spin_lock (&ses->chan_lock);if (ses->chan_count >1 ) {seq_printf (m,"\n\n\tExtra Channels: %zu " , ses->chan_count-1 );for (j =1 ; j < ses->chan_count; j++)cifs_dump_channel (m, j, &ses->chans[j]); } +spin_unlock (&ses->chan_lock);seq_puts (m,"\n\n\tShares: " ); j =0 ;
fs/cifs/cifsglob.h +5 -0
@@ -934,16 +934,21 @@ struct cifs_ses {* iface_lock should be taken when accessing any of these fields */ spinlock_t iface_lock; +/* ========= begin: protected by iface_lock ======== */ struct cifs_server_iface *iface_list;size_t iface_count;unsigned long iface_last_update;/* jiffies */ +/* ========= end: protected by iface_lock ======== */ +spinlock_t chan_lock; +/* ========= begin: protected by chan_lock ======== */ #define CIFS_MAX_CHANNELS 16struct cifs_chan chans[CIFS_MAX_CHANNELS ];struct cifs_chan *binding_chan;size_t chan_count;size_t chan_max;atomic_t chan_seq;/* round robin state */ +/* ========= end: protected by chan_lock ======== */ };/*
fs/cifs/connect.c +22 -3
@@ -1526,8 +1526,12 @@ static int match_session(struct cifs_ses *ses, struct smb3_fs_context *ctx)* If an existing session is limited to less channels than * requested, it should not be reused */ -if (ses->chan_max < ctx->max_channels) +spin_lock (&ses->chan_lock); +if (ses->chan_max < ctx->max_channels) { +spin_unlock (&ses->chan_lock);return 0 ; + } +spin_unlock (&ses->chan_lock);switch (ses->sectype) {case Kerberos:
@@ -1662,6 +1666,7 @@ cifs_find_smb_ses(struct TCP_Server_Info *server, struct smb3_fs_context *ctx)void cifs_put_smb_ses (struct cifs_ses *ses) {unsigned int rc, xid; +unsigned int chan_count;struct TCP_Server_Info *server = ses->server;cifs_dbg (FYI ,"%s: ses_count=%d\n" , __func__, ses->ses_count);
@@ -1703,12 +1708,24 @@ void cifs_put_smb_ses(struct cifs_ses *ses)list_del_init (&ses->smb_ses_list);spin_unlock (&cifs_tcp_ses_lock); +spin_lock (&ses->chan_lock); + chan_count = ses->chan_count; +spin_unlock (&ses->chan_lock); +/* close any extra channels */ -if (ses->chan_count >1 ) { +if (chan_count >1 ) {int i; -for (i =1 ; i < ses->chan_count; i++) +for (i =1 ; i < chan_count; i++) { +/* +* note: for now, we're okay accessing ses->chans +* without chan_lock. But when chans can go away, we'll +* need to introduce ref counting to make sure that chan +* is not freed from under us. +*/ cifs_put_tcp_session (ses->chans[i].server,0 ); + ses->chans[i].server =NULL ; + } }sesInfoFree (ses);
@@ -1959,9 +1976,11 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb3_fs_context *ctx)mutex_lock (&ses->session_mutex);/* add server as first channel */ +spin_lock (&ses->chan_lock); ses->chans[0 ].server = server; ses->chan_count =1 ; ses->chan_max = ctx->multichannel ? ctx->max_channels:1 ; +spin_unlock (&ses->chan_lock); rc =cifs_negotiate_protocol (xid, ses);if (!rc)
fs/cifs/misc.c +1 -0
@@ -75,6 +75,7 @@ sesInfoAlloc(void)INIT_LIST_HEAD (&ret_buf->tcon_list);mutex_init (&ret_buf->session_mutex);spin_lock_init (&ret_buf->iface_lock); +spin_lock_init (&ret_buf->chan_lock); }return ret_buf; }
fs/cifs/sess.c +38 -12
128 lines not on this page · raw message
fs/cifs/transport.c +3 -0
@@ -1044,14 +1044,17 @@ struct TCP_Server_Info *cifs_pick_channel(struct cifs_ses *ses)if (!ses)return NULL ; +spin_lock (&ses->chan_lock);if (!ses->binding) {/* round robin */ if (ses->chan_count >1 ) { index = (uint )atomic_inc_return (&ses->chan_seq); index %= ses->chan_count; } +spin_unlock (&ses->chan_lock);return ses->chans[index].server; }else { +spin_unlock (&ses->chan_lock);return cifs_ses_server (ses); } }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 130/262 cifs: fix confusing unneeded warning message on smb2.1 and earlier
In reply to Greg Kroah-HartmanFrom: Steve French <[email protected]>
[ Upstream commit 53923e0fe2098f90f339510aeaa0e1413ae99a16 ]
When mounting with SMB2.1 or earlier, even with nomultichannel, we
log the confusing warning message:
"CIFS: VFS: multichannel is not supported on this protocol version, use 3.0 or above"
Fix this so that we don't log this unless they really are trying to mount with multichannel.
--- fs/cifs/sess.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
fs/cifs/sess.c +6 -5
@@ -76,11 +76,6 @@ int cifs_try_adding_channels(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses)struct cifs_server_iface *ifaces =NULL ;size_t iface_count; -if (ses->server->dialect <SMB30_PROT_ID ) { -cifs_dbg (VFS ,"multichannel is not supported on this protocol version, use 3.0 or above\n" ); -return 0 ; - } -spin_lock (&ses->chan_lock); new_chan_count = old_chan_count = ses->chan_count;
@@ -94,6 +89,12 @@ int cifs_try_adding_channels(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses)return 0 ; } +if (ses->server->dialect <SMB30_PROT_ID ) { +spin_unlock (&ses->chan_lock); +cifs_dbg (VFS ,"multichannel is not supported on this protocol version, use 3.0 or above\n" ); +return 0 ; + } +if (!(ses->server->capabilities &SMB2_GLOBAL_CAP_MULTI_CHANNEL )) {cifs_dbg (VFS ,"server %s does not support multichannel\n" , ses->server->hostname); ses->chan_max =1 ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 131/262 drm/amd/display: Fix stream->link_enc unassigned during stream removal
In reply to Greg Kroah-HartmanFrom: Nicholas Kazlauskas <[email protected]>
[ Upstream commit 3743e7f6fcb938b7d8b7967e6a9442805e269b3d ]
[Why]
Found when running igt@kms_atomic.
Userspace attempts to do a TEST_COMMIT when 0 streams which calls dc_remove_stream_from_ctx. This in turn calls link_enc_unassign which ends up modifying stream->link = NULL directly, causing the global link_enc to be removed preventing further link activity and future link validation from passing.
[How]
We take care of link_enc unassignment at the start of link_enc_cfg_link_encs_assign so this call is no longer necessary.
Fixes global state from being modified while unlocked.
--- drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 3 --- 1 file changed, 3 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc_resource.c +0 -3
@@ -1799,9 +1799,6 @@ enum dc_status dc_remove_stream_from_ctx( dc->res_pool, del_pipe->stream_res.stream_enc, false); -/* Release link encoder from stream in new dc_state. */ -if (dc->res_pool->funcs->link_enc_unassign) - dc->res_pool->funcs->link_enc_unassign (new_ctx, del_pipe->stream);if (del_pipe->stream_res.audio) update_audio_usage(
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 132/262 bnxt_en: Fix occasional ethtool -t loopback test failures
In reply to Greg Kroah-HartmanFrom: Michael Chan <[email protected]>
[ Upstream commit cfcab3b3b61584a02bb523ffa99564eafa761dfe ]
In the current code, we setup the port to PHY or MAC loopback mode and then transmit a test broadcast packet for the loopback test. This scheme fails sometime if the port is shared with management firmware that can also send packets. The driver may receive the management firmware's packet and the test will fail when the contents don't match the test packet.
Change the test packet to use it's own MAC address as the destination and setup the port to only receive it's own MAC address. This should filter out other packets sent by management firmware.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 7 +++++++ drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 + drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +7 -0
@@ -8617,6 +8617,9 @@ static int bnxt_init_chip(struct bnxt *bp, bool irq_re_init) vnic->uc_filter_count =1 ; vnic->rx_mask =0 ; +if (test_bit (BNXT_STATE_HALF_OPEN , &bp->state)) + goto skip_rx_mask; +if (bp->dev->flags &IFF_BROADCAST ) vnic->rx_mask |=CFA_L2_SET_RX_MASK_REQ_MASK_BCAST ;
@@ -8637,6 +8640,7 @@ static int bnxt_init_chip(struct bnxt *bp, bool irq_re_init)if (rc) goto err_out; +skip_rx_mask: rc =bnxt_hwrm_set_coal (bp);if (rc) netdev_warn(bp->dev, "HWRM set coalescing failure rc: %x\n",
@@ -10302,8 +10306,10 @@ int bnxt_half_open_nic(struct bnxt *bp)netdev_err (bp->dev,"bnxt_alloc_mem err: %x\n" , rc); goto half_open_err; } +set_bit (BNXT_STATE_HALF_OPEN , &bp->state); rc =bnxt_init_nic (bp, true);if (rc) { +clear_bit (BNXT_STATE_HALF_OPEN , &bp->state);netdev_err (bp->dev,"bnxt_init_nic err: %x\n" , rc); goto half_open_err; }
@@ -10324,6 +10330,7 @@ void bnxt_half_close_nic(struct bnxt *bp)bnxt_hwrm_resource_free (bp, false, true);bnxt_free_skbs (bp);bnxt_free_mem (bp, true); +clear_bit (BNXT_STATE_HALF_OPEN , &bp->state); }static void bnxt_reenable_sriov (struct bnxt *bp)
drivers/net/ethernet/broadcom/bnxt/bnxt.h +1 -0
@@ -1840,6 +1840,7 @@ struct bnxt {#define BNXT_STATE_DRV_REGISTERED 7#define BNXT_STATE_PCI_CHANNEL_IO_FROZEN 8#define BNXT_STATE_NAPI_DISABLED 9 +#define BNXT_STATE_HALF_OPEN 15/* For offline ethtool tests */ #define BNXT_NO_FW_ACCESS (bp) \ (test_bit(BNXT_STATE_FW_FATAL_COND, &(bp)->state) || \
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +1 -1
@@ -3409,7 +3409,7 @@ static int bnxt_run_loopback(struct bnxt *bp)if (!skb)return -ENOMEM ; data =skb_put (skb, pkt_size); -eth_broadcast_addr (data); +ether_addr_copy (&data[i], bp->dev->dev_addr); i +=ETH_ALEN ;ether_addr_copy (&data[i], bp->dev->dev_addr); i +=ETH_ALEN ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 133/262 drm/amd/display: For vblank_disable_immediate, check PSR is really used
In reply to Greg Kroah-HartmanFrom: Michel Dänzer <[email protected]>
[ Upstream commit 4d22336f903930eb94588b939c310743a3640276 ]
Even if PSR is allowed for a present GPU, there might be no eDP link which supports PSR.
--- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +9 -8
@@ -3812,6 +3812,9 @@ static int amdgpu_dm_initialize_drm_device(struct amdgpu_device *adev) }#endif +/* Disable vblank IRQs aggressively for power-saving. */ +adev_to_drm (adev)->vblank_disable_immediate = true; +/* loops over all connectors on the board */ for (i =0 ; i < link_cnt; i++) {struct dc_link *link =NULL ;
@@ -3858,19 +3861,17 @@ static int amdgpu_dm_initialize_drm_device(struct amdgpu_device *adev)update_connector_ext_caps (aconnector);if (amdgpu_dc_feature_mask &DC_PSR_MASK )amdgpu_dm_set_psr_caps (link); + +/* TODO: Fix vblank control helpers to delay PSR entry to allow this when +* PSR is also supported. +*/ +if (link->psr_settings.psr_feature_enabled) +adev_to_drm (adev)->vblank_disable_immediate = false; } } -/* -* Disable vblank IRQs aggressively for power-saving. -* -* TODO: Fix vblank control helpers to delay PSR entry to allow this when PSR -* is also supported. -*/ -adev_to_drm (adev)->vblank_disable_immediate = !psr_feature_enabled; -/* Software is initialized. Now we can register interrupt handlers. */ switch (adev->asic_type) {#if defined(CONFIG_DRM_AMD_DC_SI )
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 134/262 PCI: mvebu: Fix device enumeration regression
In reply to Greg Kroah-HartmanFrom: Pali Rohár <[email protected]>
[ Upstream commit c49ae619905eebd3f54598a84e4cd2bd58ba8fe9 ]
Jan reported that on Turris Omnia (Armada 385), no PCIe devices were detected after upgrading from v5.16.1 to v5.16.3 and identified the cause as the backport of 91a8d79fc797 ("PCI: mvebu: Fix configuring secondary bus of PCIe Root Port via emulated bridge"), which appeared in v5.17-rc1.
91a8d79fc797 was incorrectly applied from mailing list patch [1] to the linux git repository [2] probably due to resolving merge conflicts incorrectly. Fix it now.
[1] https://lore.kernel.org/r/[email protected]
[2] https://git.kernel.org/linus/91a8d79fc797
--- drivers/pci/controller/pci-mvebu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pci/controller/pci-mvebu.c +2 -1
@@ -1288,7 +1288,8 @@ static int mvebu_pcie_probe(struct platform_device *pdev)* indirectly via kernel emulated PCI bridge driver. */ mvebu_pcie_setup_hw (port); -mvebu_pcie_set_local_dev_nr (port,0 ); +mvebu_pcie_set_local_dev_nr (port,1 ); +mvebu_pcie_set_local_bus_nr (port,0 ); } pcie->nports = i;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 135/262 net: of: fix stub of_net helpers for CONFIG_NET=n
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 8b017fbe0bbb98dd71fb4850f6b9cc0e136a26b8 ]
Moving the of_net code from drivers/of/ to net/core means we no longer stub out the helpers when networking is disabled, which leads to a randconfig build failure with at least one ARM platform that calls this from non-networking code:
arm-linux-gnueabi-ld: arch/arm/mach-mvebu/kirkwood.o: in function `kirkwood_dt_eth_fixup':
kirkwood.c:(.init.text+0x54): undefined reference to `of_get_mac_address'
Restore the way this worked before by changing that #ifdef check back to testing for both CONFIG_OF and CONFIG_NET.
--- include/linux/of_net.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/of_net.h +1 -1
@@ -8,7 +8,7 @@#include <linux/phy.h> -#ifdef CONFIG_OF +#if defined(CONFIG_OF ) && defined(CONFIG_NET )#include <linux/of.h> struct net_device ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 136/262 ALSA: intel_hdmi: Fix reference to PCM buffer address
In reply to Greg Kroah-HartmanFrom: Zhen Ni <[email protected]>
commit 0aa6b294b312d9710804679abd2c0c8ca52cc2bc upstream.
PCM buffers might be allocated dynamically when the buffer preallocation failed or a larger buffer is requested, and it's not guaranteed that substream->dma_buffer points to the actually used buffer. The driver needs to refer to substream->runtime->dma_addr instead for the buffer address.
--- sound/x86/intel_hdmi_audio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/x86/intel_hdmi_audio.c +1 -1
@@ -1261,7 +1261,7 @@ static int had_pcm_mmap(struct snd_pcm_s { vma->vm_page_prot =pgprot_noncached (vma->vm_page_prot);return remap_pfn_range (vma, vma->vm_start, - substream->dma_buffer.addr >>PAGE_SHIFT , + substream->runtime->dma_addr >>PAGE_SHIFT , vma->vm_end - vma->vm_start, vma->vm_page_prot); }
Greg Kroah-Hartman
maintainerPATCH 137/262 ucounts: Fix systemd LimitNPROC with private users regression
In reply to Greg Kroah-HartmanFrom: Eric W. Biederman <[email protected]>
commit 0ac983f512033cb7b5e210c9589768ad25b1e36b upstream.
Long story short recursively enforcing RLIMIT_NPROC when it is not enforced on the process that creates a new user namespace, causes currently working code to fail. There is no reason to enforce RLIMIT_NPROC recursively when we don't enforce it normally so update the code to detect this case.
I would like to simply use capable(CAP_SYS_RESOURCE) to detect when RLIMIT_NPROC is not enforced upon the caller. Unfortunately because RLIMIT_NPROC is charged and checked for enforcement based upon the real uid, using capable() which is euid based is inconsistent with reality. Come as close as possible to testing for capable(CAP_SYS_RESOURCE) by testing for when the real uid would match the conditions when CAP_SYS_RESOURCE would be present if the real uid was the effective uid.
--- kernel/user_namespace.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
kernel/user_namespace.c +13 -1
@@ -58,6 +58,18 @@ static void set_cred_user_ns(struct cred cred->user_ns = user_ns; } +static unsigned long enforced_nproc_rlimit (void ) +{ +unsigned long limit =RLIM_INFINITY ; + +/* Is RLIMIT_NPROC currently enforced? */ +if (!uid_eq (current_uid (),GLOBAL_ROOT_UID ) || + (current_user_ns () != &init_user_ns)) + limit =rlimit (RLIMIT_NPROC ); + +return limit; +} +/* * Create a new user namespace, deriving the creator from the user in the * passed credentials, and replacing that user with the new root user for the
@@ -122,7 +134,7 @@ int create_user_ns(struct cred *new)for (i =0 ; i <MAX_PER_NAMESPACE_UCOUNTS ; i++) { ns->ucount_max[i] =INT_MAX ; } -set_rlimit_ucount_max (ns,UCOUNT_RLIMIT_NPROC ,rlimit (RLIMIT_NPROC )); +set_rlimit_ucount_max (ns,UCOUNT_RLIMIT_NPROC ,enforced_nproc_rlimit ());set_rlimit_ucount_max (ns,UCOUNT_RLIMIT_MSGQUEUE ,rlimit (RLIMIT_MSGQUEUE ));set_rlimit_ucount_max (ns,UCOUNT_RLIMIT_SIGPENDING ,rlimit (RLIMIT_SIGPENDING ));set_rlimit_ucount_max (ns,UCOUNT_RLIMIT_MEMLOCK ,rlimit (RLIMIT_MEMLOCK ));
Greg Kroah-Hartman
maintainerPATCH 138/262 riscv/efi_stub: Fix get_boot_hartid_from_fdt() return value
In reply to Greg Kroah-HartmanFrom: Sunil V L <[email protected]>
commit dcf0c838854c86e1f41fb1934aea906845d69782 upstream.
The get_boot_hartid_from_fdt() function currently returns U32_MAX for failure case which is not correct because U32_MAX is a valid hartid value. This patch fixes the issue by returning error code.
--- drivers/firmware/efi/libstub/riscv-stub.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/firmware/efi/libstub/riscv-stub.c +10 -7
@@ -25,7 +25,7 @@ typedef void __noreturn (*jump_kernel_fustatic u32 hartid; -static u32 get_boot_hartid_from_fdt (void ) +static int get_boot_hartid_from_fdt (void ) {const void *fdt;int chosen_node, len;
@@ -33,23 +33,26 @@ static u32 get_boot_hartid_from_fdt(void fdt =get_efi_config_table (DEVICE_TREE_GUID );if (!fdt) -return U32_MAX ; +return -EINVAL ; chosen_node =fdt_path_offset (fdt,"/chosen" );if (chosen_node <0 ) -return U32_MAX ; +return -EINVAL ; prop =fdt_getprop ((void *)fdt, chosen_node,"boot-hartid" , &len);if (!prop || len !=sizeof (u32)) -return U32_MAX ; +return -EINVAL ; -return fdt32_to_cpu (*prop); + hartid =fdt32_to_cpu (*prop); +return 0 ; }efi_status_t check_platform_features (void ) { - hartid =get_boot_hartid_from_fdt (); -if (hartid ==U32_MAX ) { +int ret; + + ret =get_boot_hartid_from_fdt (); +if (ret) {efi_err ("/chosen/boot-hartid missing or invalid!\n" );return EFI_UNSUPPORTED ; }
Greg Kroah-Hartman
maintainerPATCH 139/262 riscv: Fix config KASAN && SPARSEMEM && !SPARSE_VMEMMAP
In reply to Greg Kroah-HartmanFrom: Alexandre Ghiti <[email protected]>
commit a3d328037846d013bb4c7f3777241e190e4c75e1 upstream.
In order to get the pfn of a struct page* when sparsemem is enabled without vmemmap, the mem_section structures need to be initialized which happens in sparse_init.
But kasan_early_init calls pfn_to_page way before sparse_init is called, which then tries to dereference a null mem_section pointer.
Fix this by removing the usage of this function in kasan_early_init.
--- arch/riscv/mm/kasan_init.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/riscv/mm/kasan_init.c +1 -2
@@ -22,8 +22,7 @@ asmlinkage void __init kasan_early_init(for (i =0 ; i <PTRS_PER_PTE ; ++i)set_pte (kasan_early_shadow_pte + i, -mk_pte (virt_to_page (kasan_early_shadow_page), -PAGE_KERNEL )); +pfn_pte (virt_to_pfn (kasan_early_shadow_page),PAGE_KERNEL ));for (i =0 ; i <PTRS_PER_PMD ; ++i) set_pmd(kasan_early_shadow_pmd + i,
Greg Kroah-Hartman
maintainerPATCH 140/262 riscv: Fix config KASAN && DEBUG_VIRTUAL
In reply to Greg Kroah-HartmanFrom: Alexandre Ghiti <[email protected]>
commit c648c4bb7d02ceb53ee40172fdc4433b37cee9c6 upstream.
__virt_to_phys function is called very early in the boot process (ie kasan_early_init) so it should not be instrumented by KASAN otherwise it bugs.
Fix this by declaring phys_addr.c as non-kasan instrumentable.
--- arch/riscv/mm/Makefile | 3 +++ 1 file changed, 3 insertions(+)
arch/riscv/mm/Makefile +3 -0
@@ -24,6 +24,9 @@ obj-$(CONFIG_KASAN) += kasan_init.o ifdef CONFIG_KASAN KASAN_SANITIZE_kasan_init.o := n KASAN_SANITIZE_init.o := n +ifdef CONFIG_DEBUG_VIRTUAL +KASAN_SANITIZE_physaddr.o := n +endif endif obj-$(CONFIG_DEBUG_VIRTUAL) += physaddr.o
Greg Kroah-Hartman
maintainerPATCH 141/262 iwlwifi: mvm: check debugfs_dir ptr before use
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
commit 5a6248c0a22352f09ea041665d3bd3e18f6f872c upstream.
When "debugfs=off" is used on the kernel command line, iwiwifi's mvm module uses an invalid/unchecked debugfs_dir pointer and causes a BUG:
BUG: kernel NULL pointer dereference, address: 000000000000004f #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 0 P4D 0 Oops: 0000 [#1] PREEMPT SMP CPU: 1 PID: 503 Comm: modprobe Tainted: G W 5.17.0-rc5 #7 Hardware name: Dell Inc. Inspiron 15 5510/076F7Y, BIOS 2.4.1 11/05/2021 RIP: 0010:iwl_mvm_dbgfs_register+0x692/0x700 [iwlmvm] Code: 69 a0 be 80 01 00 00 48 c7 c7 50 73 6a a0 e8 95 cf ee e0 48 8b 83 b0 1e 00 00 48 c7 c2 54 73 6a a0 be 64 00 00 00 48 8d 7d 8c <48> 8b 48 50 e8 15 22 07 e1 48 8b 43 28 48 8d 55 8c 48 c7 c7 5f 73 RSP: 0018:ffffc90000a0ba68 EFLAGS: 00010246 RAX: ffffffffffffffff RBX: ffff88817d6e3328 RCX: ffff88817d6e3328 RDX: ffffffffa06a7354 RSI: 0000000000000064 RDI: ffffc90000a0ba6c RBP: ffffc90000a0bae0 R08: ffffffff824e4880 R09: ffffffffa069d620 R10: ffffc90000a0ba00 R11: ffffffffffffffff R12: 0000000000000000 R13: ffffc90000a0bb28 R14: ffff88817d6e3328 R15: ffff88817d6e3320 FS: 00007f64dd92d740(0000) GS:ffff88847f640000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000000000000004f CR3: 000000016fc79001 CR4: 0000000000770ee0 PKRU: 55555554 Call Trace: <TASK> ? iwl_mvm_mac_setup_register+0xbdc/0xda0 [iwlmvm] iwl_mvm_start_post_nvm+0x71/0x100 [iwlmvm] iwl_op_mode_mvm_start+0xab8/0xb30 [iwlmvm] _iwl_op_mode_start+0x6f/0xd0 [iwlwifi] iwl_opmode_register+0x6a/0xe0 [iwlwifi] ? 0xffffffffa0231000 iwl_mvm_init+0x35/0x1000 [iwlmvm] ? 0xffffffffa0231000 do_one_initcall+0x5a/0x1b0 ? kmem_cache_alloc+0x1e5/0x2f0 ? do_init_module+0x1e/0x220 do_init_module+0x48/0x220 load_module+0x2602/0x2bc0 ? __kernel_read+0x145/0x2e0 ? kernel_read_file+0x229/0x290 __do_sys_finit_module+0xc5/0x130 ? __do_sys_finit_module+0xc5/0x130 __x64_sys_finit_module+0x13/0x20 do_syscall_64+0x38/0x90 entry_SYSCALL_64_after_hwframe+0x44/0xae RIP: 0033:0x7f64dda564dd Code: 5b 41 5c c3 66 0f 1f 84 00 00 00 00 00 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 1b 29 0f 00 f7 d8 64 89 01 48 RSP: 002b:00007ffdba393f88 EFLAGS: 00000246 ORIG_RAX: 0000000000000139 RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f64dda564dd RDX: 0000000000000000 RSI: 00005575399e2ab2 RDI: 0000000000000001 RBP: 000055753a91c5e0 R08: 0000000000000000 R09: 0000000000000002 R10: 0000000000000001 R11: 0000000000000246 R12: 00005575399e2ab2 R13: 000055753a91ceb0 R14: 0000000000000000 R15: 000055753a923018 </TASK> Modules linked in: btintel(+) btmtk bluetooth vfat snd_hda_codec_hdmi fat snd_hda_codec_realtek snd_hda_codec_generic iwlmvm(+) snd_sof_pci_intel_tgl mac80211 snd_sof_intel_hda_common soundwire_intel soundwire_generic_allocation soundwire_cadence soundwire_bus snd_sof_intel_hda snd_sof_pci snd_sof snd_sof_xtensa_dsp snd_soc_hdac_hda snd_hda_ext_core snd_soc_acpi_intel_match snd_soc_acpi snd_soc_core btrfs snd_compress snd_hda_intel snd_intel_dspcfg snd_intel_sdw_acpi snd_hda_codec raid6_pq iwlwifi snd_hda_core snd_pcm snd_timer snd soundcore cfg80211 intel_ish_ipc(+) thunderbolt rfkill intel_ishtp ucsi_acpi wmi i2c_hid_acpi i2c_hid evdev CR2: 000000000000004f ---[ end trace 0000000000000000 ]---
Check the debugfs_dir pointer for an error before using it.
--- drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c +8 -3
@@ -5,6 +5,7 @@* Copyright (C) 2016-2017 Intel Deutschland GmbH */ #include <linux/vmalloc.h> +#include <linux/err.h> #include <linux/ieee80211.h> #include <linux/netdevice.h>
@@ -2044,7 +2045,6 @@ void iwl_mvm_sta_add_debugfs(struct ieeevoid iwl_mvm_dbgfs_register (struct iwl_mvm *mvm) {struct dentry *bcast_dir__maybe_unused ; -char buf[100 ];spin_lock_init (&mvm->drv_stats_lock);
@@ -2140,6 +2140,11 @@ void iwl_mvm_dbgfs_register(struct iwl_m* Create a symlink with mac80211. It will be removed when mac80211 * exists (before the opmode exists which removes the target.) */ -snprintf (buf,100 ,"../../%pd2" , mvm->debugfs_dir->d_parent); -debugfs_create_symlink ("iwlwifi" , mvm->hw->wiphy->debugfsdir, buf); +if (!IS_ERR (mvm->debugfs_dir)) { +char buf[100 ]; + +snprintf (buf,100 ,"../../%pd2" , mvm->debugfs_dir->d_parent); +debugfs_create_symlink ("iwlwifi" , mvm->hw->wiphy->debugfsdir, + buf); + } }
Greg Kroah-Hartman
maintainerPATCH 142/262 ASoC: ops: Shift tested values in snd_soc_put_volsw() by +min
In reply to Greg Kroah-HartmanFrom: Marek Vasut <[email protected]>
commit 9bdd10d57a8807dba0003af0325191f3cec0f11c upstream.
While the $val/$val2 values passed in from userspace are always >= 0 integers, the limits of the control can be signed integers and the $min can be non-zero and less than zero. To correctly validate $val/$val2 against platform_max, add the $min offset to val first.
--- sound/soc/soc-ops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/soc-ops.c +2 -2
@@ -317,7 +317,7 @@ int snd_soc_put_volsw(struct snd_kcontro mask =BIT (sign_bit +1 ) -1 ; val = ucontrol->value.integer.value[0 ]; -if (mc->platform_max && val > mc->platform_max) +if (mc->platform_max && ((int )val + min) > mc->platform_max)return -EINVAL ;if (val > max - min)return -EINVAL ;
@@ -330,7 +330,7 @@ int snd_soc_put_volsw(struct snd_kcontro val = val << shift;if (snd_soc_volsw_is_stereo (mc)) { val2 = ucontrol->value.integer.value[1 ]; -if (mc->platform_max && val2 > mc->platform_max) +if (mc->platform_max && ((int )val2 + min) > mc->platform_max)return -EINVAL ;if (val2 > max - min)return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 143/262 iommu/vt-d: Fix double list_add when enabling VMD in scalable mode
In reply to Greg Kroah-HartmanFrom: Adrian Huang <[email protected]>
commit b00833768e170a31af09268f7ab96aecfcca9623 upstream.
When enabling VMD and IOMMU scalable mode, the following kernel panic call trace/kernel log is shown in Eagle Stream platform (Sapphire Rapids CPU) during booting:
pci 0000:59:00.5: Adding to iommu group 42
...
vmd 0000:59:00.5: PCI host bridge to bus 10000:80 pci 10000:80:01.0: [8086:352a] type 01 class 0x060400 pci 10000:80:01.0: reg 0x10: [mem 0x00000000-0x0001ffff 64bit] pci 10000:80:01.0: enabling Extended Tags
pci 10000:80:01.0: PME# supported from D0 D3hot D3cold pci 10000:80:01.0: DMAR: Setup RID2PASID failed
pci 10000:80:01.0: Failed to add to iommu group 42: -16 pci 10000:80:03.0: [8086:352b] type 01 class 0x060400 pci 10000:80:03.0: reg 0x10: [mem 0x00000000-0x0001ffff 64bit] pci 10000:80:03.0: enabling Extended Tags
pci 10000:80:03.0: PME# supported from D0 D3hot D3cold
------------[ cut here ]------------
kernel BUG at lib/list_debug.c:29!
invalid opcode: 0000 [#1] PREEMPT SMP NOPTI
CPU: 0 PID: 7 Comm: kworker/0:1 Not tainted 5.17.0-rc3+ #7
Hardware name: Lenovo ThinkSystem SR650V3/SB27A86647, BIOS ESE101Y-1.00 01/13/2022
Workqueue: events work_for_cpu_fn
RIP: 0010:__list_add_valid.cold+0x26/0x3f
Code: 9a 4a ab ff 4c 89 c1 48 c7 c7 40 0c d9 9e e8 b9 b1 fe ff 0f
0b 48 89 f2 4c 89 c1 48 89 fe 48 c7 c7 f0 0c d9 9e e8 a2 b1
fe ff <0f> 0b 48 89 d1 4c 89 c6 4c 89 ca 48 c7 c7 98 0c d9
9e e8 8b b1 fe
RSP: 0000:ff5ad434865b3a40 EFLAGS: 00010246
RAX: 0000000000000058 RBX: ff4d61160b74b880 RCX: ff4d61255e1fffa8
RDX: 0000000000000000 RSI: 00000000fffeffff RDI: ffffffff9fd34f20
RBP: ff4d611d8e245c00 R08: 0000000000000000 R09: ff5ad434865b3888
R10: ff5ad434865b3880 R11: ff4d61257fdc6fe8 R12: ff4d61160b74b8a0
R13: ff4d61160b74b8a0 R14: ff4d611d8e245c10 R15: ff4d611d8001ba70
FS: 0000000000000000(0000) GS:ff4d611d5ea00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ff4d611fa1401000 CR3: 0000000aa0210001 CR4: 0000000000771ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe07f0 DR7: 0000000000000400
PKRU: 55555554
Call Trace:
<TASK>
intel_pasid_alloc_table+0x9c/0x1d0
dmar_insert_one_dev_info+0x423/0x540
? device_to_iommu+0x12d/0x2f0
intel_iommu_attach_device+0x116/0x290
__iommu_attach_device+0x1a/0x90
iommu_group_add_device+0x190/0x2c0
__iommu_probe_device+0x13e/0x250
iommu_probe_device+0x24/0x150
iommu_bus_notifier+0x69/0x90
blocking_notifier_call_chain+0x5a/0x80
device_add+0x3db/0x7b0
? arch_memremap_can_ram_remap+0x19/0x50
? memremap+0x75/0x140
pci_device_add+0x193/0x1d0
pci_scan_single_device+0xb9/0xf0
pci_scan_slot+0x4c/0x110
pci_scan_child_bus_extend+0x3a/0x290
vmd_enable_domain.constprop.0+0x63e/0x820
vmd_probe+0x163/0x190
local_pci_probe+0x42/0x80
work_for_cpu_fn+0x13/0x20
process_one_work+0x1e2/0x3b0
worker_thread+0x1c4/0x3a0
? rescuer_thread+0x370/0x370
kthread+0xc7/0xf0
? kthread_complete_and_exit+0x20/0x20
ret_from_fork+0x1f/0x30
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
...
Kernel panic - not syncing: Fatal exception
Kernel Offset: 0x1ca00000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff)
---[ end Kernel panic - not syncing: Fatal exception ]---The following 'lspci' output shows devices '10000:80:*' are subdevices of the VMD device 0000:59:00.5:
$ lspci ... 0000:59:00.5 RAID bus controller: Intel Corporation Volume Management Device NVMe RAID Controller (rev 20) ... 10000:80:01.0 PCI bridge: Intel Corporation Device 352a (rev 03) 10000:80:03.0 PCI bridge: Intel Corporation Device 352b (rev 03) 10000:80:05.0 PCI bridge: Intel Corporation Device 352c (rev 03) 10000:80:07.0 PCI bridge: Intel Corporation Device 352d (rev 03) 10000:81:00.0 Non-Volatile memory controller: Intel Corporation NVMe Datacenter SSD [3DNAND, Beta Rock Controller] 10000:82:00.0 Non-Volatile memory controller: Intel Corporation NVMe Datacenter SSD [3DNAND, Beta Rock Controller]
The symptom 'list_add double add' is caused by the following failure message:
pci 10000:80:01.0: DMAR: Setup RID2PASID failed pci 10000:80:01.0: Failed to add to iommu group 42: -16 pci 10000:80:03.0: [8086:352b] type 01 class 0x060400
Device 10000:80:01.0 is the subdevice of the VMD device 0000:59:00.5, so invoking intel_pasid_alloc_table() gets the pasid_table of the VMD device 0000:59:00.5. Here is call path:
intel_pasid_alloc_table
pci_for_each_dma_alias
get_alias_pasid_table
search_pasid_table
pci_real_dma_dev() in pci_for_each_dma_alias() gets the real dma device which is the VMD device 0000:59:00.5. However, pte of the VMD device 0000:59:00.5 has been configured during this message "pci 0000:59:00.5:
Adding to iommu group 42". So, the status -EBUSY is returned when configuring pasid entry for device 10000:80:01.0.
It then invokes dmar_remove_one_dev_info() to release 'struct device_domain_info *' from iommu_devinfo_cache. But, the pasid table is not released because of the following statement in __dmar_remove_one_dev_info():
if (info->dev && !dev_is_real_dma_subdevice(info->dev)) {
...
intel_pasid_free_table(info->dev);
}The subsequent dmar_insert_one_dev_info() operation of device 10000:80:03.0 allocates 'struct device_domain_info *' from iommu_devinfo_cache. The allocated address is the same address that is released previously for device 10000:80:01.0. Finally, invoking device_attach_pasid_table() causes the issue.
git bisect points to the offending commit 474dd1c65064 ("iommu/vt-d:
Fix clearing real DMA device's scalable-mode context entries"), which releases the pasid table if the device is not the subdevice by checking the returned status of dev_is_real_dma_subdevice(). Reverting the offending commit can work around the issue.
The solution is to prevent from allocating pasid table if those devices are subdevices of the VMD device.
--- drivers/iommu/intel/iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/intel/iommu.c +1 -1
@@ -2651,7 +2651,7 @@ static struct dmar_domain *dmar_insert_ospin_unlock_irqrestore (&device_domain_lock, flags);/* PASID table is mandatory for a PCI device in scalable mode. */ -if (dev &&dev_is_pci (dev) &&sm_supported (iommu)) { +if (sm_supported (iommu) && !dev_is_real_dma_subdevice (dev)) { ret =intel_pasid_alloc_table (dev);if (ret) {dev_err (dev,"PASID table allocation failed\n" );
Greg Kroah-Hartman
maintainerPATCH 144/262 iommu/amd: Recover from event log overflow
In reply to Greg Kroah-HartmanFrom: Lennert Buytenhek <[email protected]>
commit 5ce97f4ec5e0f8726a5dda1710727b1ee9badcac upstream.
The AMD IOMMU logs I/O page faults and such to a ring buffer in system memory, and this ring buffer can overflow. The AMD IOMMU spec has the following to say about the interrupt status bit that signals this overflow condition:
EventOverflow: Event log overflow. RW1C. Reset 0b. 1 = IOMMU event log overflow has occurred. This bit is set when a new event is to be written to the event log and there is no usable entry in the event log, causing the new event information to be discarded. An interrupt is generated when EventOverflow = 1b and MMIO Offset 0018h[EventIntEn] = 1b. No new event log entries are written while this bit is set. Software Note: To resume logging, clear EventOverflow (W1C), and write a 1 to MMIO Offset 0018h[EventLogEn].
The AMD IOMMU driver doesn't currently implement this recovery sequence, meaning that if a ring buffer overflow occurs, logging of EVT/PPR/GA events will cease entirely.
This patch implements the spec-mandated reset sequence, with the minor tweak that the hardware seems to want to have a 0 written to MMIO Offset 0018h[EventLogEn] first, before writing an 1 into this field, or the IOMMU won't actually resume logging events.
--- drivers/iommu/amd/amd_iommu.h | 1 + drivers/iommu/amd/amd_iommu_types.h | 1 + drivers/iommu/amd/init.c | 10 ++++++++++ drivers/iommu/amd/iommu.c | 10 ++++++++-- 4 files changed, 20 insertions(+), 2 deletions(-)
drivers/iommu/amd/amd_iommu.h +1 -0
@@ -14,6 +14,7 @@extern irqreturn_t amd_iommu_int_thread (int irq,void *data);extern irqreturn_t amd_iommu_int_handler (int irq,void *data);extern void amd_iommu_apply_erratum_63 (u16 devid); +extern void amd_iommu_restart_event_logging (struct amd_iommu *iommu);extern void amd_iommu_reset_cmd_buffer (struct amd_iommu *iommu);extern int amd_iommu_init_devices (void );extern void amd_iommu_uninit_devices (void );
drivers/iommu/amd/amd_iommu_types.h +1 -0
@@ -110,6 +110,7 @@#define PASID_MASK 0x0000ffff/* MMIO status bits */ +#define MMIO_STATUS_EVT_OVERFLOW_INT_MASK (1 << 0)#define MMIO_STATUS_EVT_INT_MASK (1 << 1)#define MMIO_STATUS_COM_WAIT_INT_MASK (1 << 2)#define MMIO_STATUS_PPR_INT_MASK (1 << 6)
drivers/iommu/amd/init.c +10 -0
@@ -656,6 +656,16 @@ static int __init alloc_command_buffer(s }/* +* This function restarts event logging in case the IOMMU experienced +* an event log buffer overflow. +*/ +void amd_iommu_restart_event_logging (struct amd_iommu *iommu) +{ +iommu_feature_disable (iommu,CONTROL_EVT_LOG_EN ); +iommu_feature_enable (iommu,CONTROL_EVT_LOG_EN ); +} + +/* * This function resets the command buffer if the IOMMU stopped fetching * commands from it. */
drivers/iommu/amd/iommu.c +8 -2
@@ -742,7 +742,8 @@ amd_iommu_set_pci_msi_domain(struct devi#endif /* !CONFIG_IRQ_REMAP */ #define AMD_IOMMU_INT_MASK \ - (MMIO_STATUS_EVT_INT_MASK | \ + (MMIO_STATUS_EVT_OVERFLOW_INT_MASK | \ + MMIO_STATUS_EVT_INT_MASK | \ MMIO_STATUS_PPR_INT_MASK | \ MMIO_STATUS_GALOG_INT_MASK)
@@ -752,7 +753,7 @@ irqreturn_t amd_iommu_int_thread(int irqu32 status =readl (iommu->mmio_base +MMIO_STATUS_OFFSET );while (status &AMD_IOMMU_INT_MASK ) { -/* Enable EVT and PPR and GA interrupts again */ +/* Enable interrupt sources again */ writel (AMD_IOMMU_INT_MASK , iommu->mmio_base +MMIO_STATUS_OFFSET );
@@ -773,6 +774,11 @@ irqreturn_t amd_iommu_int_thread(int irq }#endif +if (status &MMIO_STATUS_EVT_OVERFLOW_INT_MASK ) { +pr_info_ratelimited ("IOMMU event log overflow\n" ); +amd_iommu_restart_event_logging (iommu); + } +/* * Hardware bug: ERBT1312 * When re-enabling interrupt (by writing 1
Greg Kroah-Hartman
maintainerPATCH 145/262 drm/i915: s/JSP2/ICP2/ PCH
In reply to Greg Kroah-HartmanFrom: Ville Syrjälä <[email protected]>
commit 08783aa7693f55619859f4f63f384abf17cb58c5 upstream.
This JSP2 PCH actually seems to be some special Apple specific ICP variant rather than a JSP. Make it so. Or at least all the references to it seem to be some Apple ICL machines. Didn't manage to find these PCI IDs in any public chipset docs unfortunately.
The only thing we're losing here with this JSP->ICP change is Wa_14011294188, but based on the HSD that isn't actually needed on any ICP based design (including JSP), only TGP based stuff (including MCC) really need it. The documented w/a just never made that distinction because Windows didn't want to differentiate between JSP and MCC (not sure how they handle hpd/ddc/etc. then though...).
--- drivers/gpu/drm/i915/intel_pch.c | 2 +- drivers/gpu/drm/i915/intel_pch.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_pch.c +1 -1
@@ -108,6 +108,7 @@ intel_pch_type(const struct drm_i915_pri/* Comet Lake V PCH is based on KBP, which is SPT compatible */ return PCH_SPT ;case INTEL_PCH_ICP_DEVICE_ID_TYPE : +case INTEL_PCH_ICP2_DEVICE_ID_TYPE :drm_dbg_kms (&dev_priv->drm,"Found Ice Lake PCH\n" );drm_WARN_ON (&dev_priv->drm, !IS_ICELAKE (dev_priv));return PCH_ICP ;
@@ -123,7 +124,6 @@ intel_pch_type(const struct drm_i915_pri !IS_GEN9_BC(dev_priv));return PCH_TGP ;case INTEL_PCH_JSP_DEVICE_ID_TYPE : -case INTEL_PCH_JSP2_DEVICE_ID_TYPE :drm_dbg_kms (&dev_priv->drm,"Found Jasper Lake PCH\n" );drm_WARN_ON (&dev_priv->drm, !IS_JSL_EHL (dev_priv));return PCH_JSP ;
drivers/gpu/drm/i915/intel_pch.h +1 -1
@@ -50,11 +50,11 @@ enum intel_pch {#define INTEL_PCH_CMP2_DEVICE_ID_TYPE 0x0680#define INTEL_PCH_CMP_V_DEVICE_ID_TYPE 0xA380#define INTEL_PCH_ICP_DEVICE_ID_TYPE 0x3480 +#define INTEL_PCH_ICP2_DEVICE_ID_TYPE 0x3880#define INTEL_PCH_MCC_DEVICE_ID_TYPE 0x4B00#define INTEL_PCH_TGP_DEVICE_ID_TYPE 0xA080#define INTEL_PCH_TGP2_DEVICE_ID_TYPE 0x4380#define INTEL_PCH_JSP_DEVICE_ID_TYPE 0x4D80 -#define INTEL_PCH_JSP2_DEVICE_ID_TYPE 0x3880#define INTEL_PCH_ADP_DEVICE_ID_TYPE 0x7A80#define INTEL_PCH_ADP2_DEVICE_ID_TYPE 0x5180#define INTEL_PCH_P2X_DEVICE_ID_TYPE 0x7100
Greg Kroah-Hartman
maintainerPATCH 146/262 drm/amd/display: Reduce dmesg error to a debug print
In reply to Greg Kroah-HartmanFrom: Leo (Hanghong) Ma <[email protected]>
commit 1d925758ba1a5d2716a847903e2fd04efcbd9862 upstream.
[Why & How]
Dmesg errors are found on dcn3.1 during reset test, but it's not a really failure. So reduce it to a debug print.
--- drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 4 +++- drivers/gpu/drm/amd/display/include/logger_types.h | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c +3 -1
@@ -3650,7 +3650,9 @@ bool dp_retrieve_lttpr_cap(struct dc_lin lttpr_dpcd_data, sizeof(lttpr_dpcd_data));if (status !=DC_OK ) { -dm_error ("%s: Read LTTPR caps data failed.\n" , __func__); +#if defined(CONFIG_DRM_AMD_DC_DCN ) +DC_LOG_DP2 ("%s: Read LTTPR caps data failed.\n" , __func__); +#endif return false; }
drivers/gpu/drm/amd/display/include/logger_types.h +3 -0
@@ -72,6 +72,9 @@#define DC_LOG_DSC (...) DRM_DEBUG_KMS(__VA_ARGS__)#define DC_LOG_SMU (...) pr_debug("[SMU_MSG]:"__VA_ARGS__)#define DC_LOG_DWB (...) DRM_DEBUG_KMS(__VA_ARGS__) +#if defined(CONFIG_DRM_AMD_DC_DCN ) +#define DC_LOG_DP2 (...) DRM_DEBUG_KMS(__VA_ARGS__) +#endif struct dal_logger ;
Greg Kroah-Hartman
maintainerPATCH 147/262 xen/netfront: destroy queues before real_num_tx_queues is zeroed
In reply to Greg Kroah-HartmanFrom: Marek Marczykowski-Górecki <[email protected]>
commit dcf4ff7a48e7598e6b10126cc02177abb8ae4f3f upstream.
xennet_destroy_queues() relies on info->netdev->real_num_tx_queues to delete queues. Since d7dac083414eb5bb99a6d2ed53dc2c1b405224e5 ("net-sysfs: update the queue counts in the unregistration path"), unregister_netdev() indirectly sets real_num_tx_queues to 0. Those two facts together means, that xennet_destroy_queues() called from xennet_remove() cannot do its job, because it's called after unregister_netdev(). This results in kfree-ing queues that are still linked in napi, which ultimately crashes:
BUG: kernel NULL pointer dereference, address: 0000000000000000
#PF: supervisor read access in kernel mode
#PF: error_code(0x0000) - not-present page
PGD 0 P4D 0
Oops: 0000 [#1] PREEMPT SMP PTI
CPU: 1 PID: 52 Comm: xenwatch Tainted: G W 5.16.10-1.32.fc32.qubes.x86_64+ #226
RIP: 0010:free_netdev+0xa3/0x1a0
Code: ff 48 89 df e8 2e e9 00 00 48 8b 43 50 48 8b 08 48 8d b8 a0 fe ff ff 48 8d a9 a0 fe ff ff 49 39 c4 75 26 eb 47 e8 ed c1 66 ff <48> 8b 85 60 01 00 00 48 8d 95 60 01 00 00 48 89 ef 48 2d 60 01 00
RSP: 0000:ffffc90000bcfd00 EFLAGS: 00010286
RAX: 0000000000000000 RBX: ffff88800edad000 RCX: 0000000000000000
RDX: 0000000000000001 RSI: ffffc90000bcfc30 RDI: 00000000ffffffff
RBP: fffffffffffffea0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000001 R12: ffff88800edad050
R13: ffff8880065f8f88 R14: 0000000000000000 R15: ffff8880066c6680
FS: 0000000000000000(0000) GS:ffff8880f3300000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000000 CR3: 00000000e998c006 CR4: 00000000003706e0
Call Trace:
<TASK>
xennet_remove+0x13d/0x300 [xen_netfront]
xenbus_dev_remove+0x6d/0xf0
__device_release_driver+0x17a/0x240
device_release_driver+0x24/0x30
bus_remove_device+0xd8/0x140
device_del+0x18b/0x410
? _raw_spin_unlock+0x16/0x30
? klist_iter_exit+0x14/0x20
? xenbus_dev_request_and_reply+0x80/0x80
device_unregister+0x13/0x60
xenbus_dev_changed+0x18e/0x1f0
xenwatch_thread+0xc0/0x1a0
? do_wait_intr_irq+0xa0/0xa0
kthread+0x16b/0x190
? set_kthread_struct+0x40/0x40
ret_from_fork+0x22/0x30
</TASK>Fix this by calling xennet_destroy_queues() from xennet_uninit(), when real_num_tx_queues is still available. This ensures that queues are destroyed when real_num_tx_queues is set to 0, regardless of how unregister_netdev() was called.
Originally reported at
https://github.com/QubesOS/qubes-issues/issues/7257
--- drivers/net/xen-netfront.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-)
drivers/net/xen-netfront.c +23 -16
@@ -842,6 +842,28 @@ static int xennet_close(struct net_devicreturn 0 ; } +static void xennet_destroy_queues (struct netfront_info *info) +{ +unsigned int i; + +for (i =0 ; i < info->netdev->real_num_tx_queues; i++) { +struct netfront_queue *queue = &info->queues[i]; + +if (netif_running (info->netdev)) +napi_disable (&queue->napi); +netif_napi_del (&queue->napi); + } + +kfree (info->queues); + info->queues =NULL ; +} + +static void xennet_uninit (struct net_device *dev) +{ +struct netfront_info *np =netdev_priv (dev); +xennet_destroy_queues (np); +} +static void xennet_set_rx_rsp_cons (struct netfront_queue *queue,RING_IDX val) {unsigned long flags;
@@ -1611,6 +1633,7 @@ static int xennet_xdp(struct net_device }static const struct net_device_ops xennet_netdev_ops = { + .ndo_uninit = xennet_uninit, .ndo_open = xennet_open, .ndo_stop = xennet_close, .ndo_start_xmit = xennet_start_xmit,
@@ -2103,22 +2126,6 @@ error:return err; } -static void xennet_destroy_queues (struct netfront_info *info) -{ -unsigned int i; - -for (i =0 ; i < info->netdev->real_num_tx_queues; i++) { -struct netfront_queue *queue = &info->queues[i]; - -if (netif_running (info->netdev)) -napi_disable (&queue->napi); -netif_napi_del (&queue->napi); - } - -kfree (info->queues); - info->queues =NULL ; -} -static int xennet_create_page_pool (struct netfront_queue *queue)
Greg Kroah-Hartman
maintainerPATCH 148/262 thermal: core: Fix TZ_GET_TRIP NULL pointer dereference
In reply to Greg Kroah-HartmanFrom: Nicolas Cavallari <[email protected]>
commit 5838a14832d447990827d85e90afe17e6fb9c175 upstream.
Do not call get_trip_hyst() from thermal_genl_cmd_tz_get_trip() if the thermal zone does not define one.
--- drivers/thermal/thermal_netlink.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/thermal/thermal_netlink.c +3 -2
@@ -418,11 +418,12 @@ static int thermal_genl_cmd_tz_get_trip(for (i =0 ; i < tz->trips; i++) {enum thermal_trip_type type; -int temp, hyst; +int temp, hyst =0 ; tz->ops->get_trip_type (tz, i, &type); tz->ops->get_trip_temp (tz, i, &temp); - tz->ops->get_trip_hyst (tz, i, &hyst); +if (tz->ops->get_trip_hyst) + tz->ops->get_trip_hyst (tz, i, &hyst); if (nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_ID, i) || nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_TYPE, type) ||
Greg Kroah-Hartman
maintainerPATCH 149/262 mac80211: fix EAPoL rekey fail in 802.3 rx path
In reply to Greg Kroah-HartmanFrom: Deren Wu <[email protected]>
commit 610d086d6df0b15c3732a7b4a5b0f1c3e1b84d4c upstream.
mac80211 set capability NL80211_EXT_FEATURE_CONTROL_PORT_OVER_NL80211 to upper layer by default. That means we should pass EAPoL packets through nl80211 path only, and should not send the EAPoL skb to netdevice diretly. At the meanwhile, wpa_supplicant would not register sock to listen EAPoL skb on the netdevice.
However, there is no control_port_protocol handler in mac80211 for 802.3 RX packets, mac80211 driver would pass up the EAPoL rekey frame to netdevice and wpa_supplicant would be never interactive with this kind of packets, if SUPPORTS_RX_DECAP_OFFLOAD is enabled. This causes STA always rekey fail if EAPoL frame go through 802.3 path.
To avoid this problem, align the same process as 802.11 type to handle this frame before put it into network stack.
This also addresses a potential security issue in 802.3 RX mode that was previously fixed in commit a8c4d76a8dd4 ("mac80211: do not accept/forward invalid EAPOL frames").
--- net/mac80211/rx.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
net/mac80211/rx.c +3 -7
@@ -2602,7 +2602,8 @@ static void ieee80211_deliver_skb_to_loc* address, so that the authenticator (e.g. hostapd) will see * the frame, but bridge won't forward it anywhere else. Note * that due to earlier filtering, the only other address can -* be the PAE group address. +* be the PAE group address, unless the hardware allowed them +* through in 802.3 offloaded mode. */ if (unlikely (skb->protocol == sdata->control_port_protocol && !ether_addr_equal (ehdr->h_dest, sdata->vif.addr)))
@@ -4518,12 +4519,7 @@ static void ieee80211_rx_8023(struct iee/* deliver to local stack */ skb->protocol =eth_type_trans (skb, fast_rx->dev); -memset (skb->cb,0 ,sizeof (skb->cb)); -if (rx->list) -list_add_tail (&skb->list, rx->list); -else -netif_receive_skb (skb); - +ieee80211_deliver_skb_to_local_stack (skb, rx); } static bool ieee80211_invoke_fast_rx(struct ieee80211_rx_data *rx,
Greg Kroah-Hartman
maintainerPATCH 150/262 blktrace: fix use after free for struct blk_trace
In reply to Greg Kroah-HartmanFrom: Yu Kuai <[email protected]>
commit 30939293262eb433c960c4532a0d59c4073b2b84 upstream.
When tracing the whole disk, 'dropped' and 'msg' will be created under 'q->debugfs_dir' and 'bt->dir' is NULL, thus blk_trace_free() won't remove those files. What's worse, the following UAF can be triggered because of accessing stale 'dropped' and 'msg':
==================================================================
BUG: KASAN: use-after-free in blk_dropped_read+0x89/0x100
Read of size 4 at addr ffff88816912f3d8 by task blktrace/1188
CPU: 27 PID: 1188 Comm: blktrace Not tainted 5.17.0-rc4-next-20220217+ #469
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS ?-20190727_073836-4
Call Trace:
<TASK>
dump_stack_lvl+0x34/0x44
print_address_description.constprop.0.cold+0xab/0x381
? blk_dropped_read+0x89/0x100
? blk_dropped_read+0x89/0x100
kasan_report.cold+0x83/0xdf
? blk_dropped_read+0x89/0x100
kasan_check_range+0x140/0x1b0
blk_dropped_read+0x89/0x100
? blk_create_buf_file_callback+0x20/0x20
? kmem_cache_free+0xa1/0x500
? do_sys_openat2+0x258/0x460
full_proxy_read+0x8f/0xc0
vfs_read+0xc6/0x260
ksys_read+0xb9/0x150
? vfs_write+0x3d0/0x3d0
? fpregs_assert_state_consistent+0x55/0x60
? exit_to_user_mode_prepare+0x39/0x1e0
do_syscall_64+0x35/0x80
entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7fbc080d92fd
Code: ce 20 00 00 75 10 b8 00 00 00 00 0f 05 48 3d 01 f0 ff ff 73 31 c3 48 83 1
RSP: 002b:00007fbb95ff9cb0 EFLAGS: 00000293 ORIG_RAX: 0000000000000000
RAX: ffffffffffffffda RBX: 00007fbb95ff9dc0 RCX: 00007fbc080d92fd
RDX: 0000000000000100 RSI: 00007fbb95ff9cc0 RDI: 0000000000000045
RBP: 0000000000000045 R08: 0000000000406299 R09: 00000000fffffffd
R10: 000000000153afa0 R11: 0000000000000293 R12: 00007fbb780008c0
R13: 00007fbb78000938 R14: 0000000000608b30 R15: 00007fbb780029c8
</TASK>
Allocated by task 1050:
kasan_save_stack+0x1e/0x40
__kasan_kmalloc+0x81/0xa0
do_blk_trace_setup+0xcb/0x410
__blk_trace_setup+0xac/0x130
blk_trace_ioctl+0xe9/0x1c0
blkdev_ioctl+0xf1/0x390
__x64_sys_ioctl+0xa5/0xe0
do_syscall_64+0x35/0x80
entry_SYSCALL_64_after_hwframe+0x44/0xae
Freed by task 1050:
kasan_save_stack+0x1e/0x40
kasan_set_track+0x21/0x30
kasan_set_free_info+0x20/0x30
__kasan_slab_free+0x103/0x180
kfree+0x9a/0x4c0
__blk_trace_remove+0x53/0x70
blk_trace_ioctl+0x199/0x1c0
blkdev_common_ioctl+0x5e9/0xb30
blkdev_ioctl+0x1a5/0x390
__x64_sys_ioctl+0xa5/0xe0
do_syscall_64+0x35/0x80
entry_SYSCALL_64_after_hwframe+0x44/0xae
The buggy address belongs to the object at ffff88816912f380
which belongs to the cache kmalloc-96 of size 96
The buggy address is located 88 bytes inside of
96-byte region [ffff88816912f380, ffff88816912f3e0)
The buggy address belongs to the page:
page:000000009a1b4e7c refcount:1 mapcount:0 mapping:0000000000000000 index:0x0f
flags: 0x17ffffc0000200(slab|node=0|zone=2|lastcpupid=0x1fffff)
raw: 0017ffffc0000200 ffffea00044f1100 dead000000000002 ffff88810004c780
raw: 0000000000000000 0000000000200020 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff88816912f280: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
ffff88816912f300: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
>ffff88816912f380: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
^
ffff88816912f400: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
ffff88816912f480: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
==================================================================--- kernel/trace/blktrace.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-)
kernel/trace/blktrace.c +18 -8
@@ -310,10 +310,20 @@ record_it:local_irq_restore (flags); } -static void blk_trace_free (struct blk_trace *bt) +static void blk_trace_free (struct request_queue *q,struct blk_trace *bt) {relay_close (bt->rchan); -debugfs_remove (bt->dir); + +/* +* If 'bt->dir' is not set, then both 'dropped' and 'msg' are created +* under 'q->debugfs_dir', thus lookup and remove them. +*/ +if (!bt->dir) { +debugfs_remove (debugfs_lookup ("dropped" , q->debugfs_dir)); +debugfs_remove (debugfs_lookup ("msg" , q->debugfs_dir)); + }else { +debugfs_remove (bt->dir); + }free_percpu (bt->sequence);free_percpu (bt->msg_data);kfree (bt);
@@ -335,10 +345,10 @@ static void put_probe_ref(void)mutex_unlock (&blk_probe_mutex); } -static void blk_trace_cleanup (struct blk_trace *bt) +static void blk_trace_cleanup (struct request_queue *q,struct blk_trace *bt) {synchronize_rcu (); -blk_trace_free (bt); +blk_trace_free (q, bt);put_probe_ref (); }
@@ -352,7 +362,7 @@ static int __blk_trace_remove(struct reqreturn -EINVAL ;if (bt->trace_state != Blktrace_running) -blk_trace_cleanup (bt); +blk_trace_cleanup (q, bt);return 0 ; }
@@ -572,7 +582,7 @@ static int do_blk_trace_setup(struct req ret =0 ; err:if (ret) -blk_trace_free (bt); +blk_trace_free (q, bt);return ret; }
@@ -1615,7 +1625,7 @@ static int blk_trace_remove_queue(structput_probe_ref ();synchronize_rcu (); -blk_trace_free (bt); +blk_trace_free (q, bt);return 0 ; }
@@ -1646,7 +1656,7 @@ static int blk_trace_setup_queue(structreturn 0 ; free_bt: -blk_trace_free (bt); +blk_trace_free (q, bt);return ret; }
Greg Kroah-Hartman
maintainerPATCH 151/262 ntb: intel: fix port config status offset for SPR
In reply to Greg Kroah-HartmanFrom: Dave Jiang <[email protected]>
commit d5081bf5dcfb1cb83fb538708b0ac07a10a79cc4 upstream.
The field offset for port configuration status on SPR has been changed to bit 14 from ICX where it resides at bit 12. By chance link status detection continued to work on SPR. This is due to bit 12 being a configuration bit which is in sync with the status bit. Fix this by checking for a SPR device and checking correct status bit.
--- drivers/ntb/hw/intel/ntb_hw_gen4.c | 17 ++++++++++++++++- drivers/ntb/hw/intel/ntb_hw_gen4.h | 16 ++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-)
drivers/ntb/hw/intel/ntb_hw_gen4.c +16 -1
@@ -168,6 +168,18 @@ static enum ntb_topo gen4_ppd_topo(strucreturn NTB_TOPO_NONE ; } +static enum ntb_topo spr_ppd_topo (struct intel_ntb_dev *ndev,u32 ppd) +{ +switch (ppd &SPR_PPD_TOPO_MASK ) { +case SPR_PPD_TOPO_B2B_USD : +return NTB_TOPO_B2B_USD ; +case SPR_PPD_TOPO_B2B_DSD : +return NTB_TOPO_B2B_DSD ; + } + +return NTB_TOPO_NONE ; +} +int gen4_init_dev (struct intel_ntb_dev *ndev) {struct pci_dev *pdev = ndev->ntb.pdev;
@@ -183,7 +195,10 @@ int gen4_init_dev(struct intel_ntb_dev * } ppd1 =ioread32 (ndev->self_mmio +GEN4_PPD1_OFFSET ); - ndev->ntb.topo =gen4_ppd_topo (ndev, ppd1); +if (pdev_is_ICX (pdev)) + ndev->ntb.topo =gen4_ppd_topo (ndev, ppd1); +else if (pdev_is_SPR (pdev)) + ndev->ntb.topo =spr_ppd_topo (ndev, ppd1);dev_dbg (&pdev->dev,"ppd %#x topo %s\n" , ppd1,ntb_topo_string (ndev->ntb.topo));if (ndev->ntb.topo ==NTB_TOPO_NONE )
drivers/ntb/hw/intel/ntb_hw_gen4.h +16 -0
@@ -49,10 +49,14 @@#define GEN4_PPD_CLEAR_TRN 0x0001#define GEN4_PPD_LINKTRN 0x0008#define GEN4_PPD_CONN_MASK 0x0300 +#define SPR_PPD_CONN_MASK 0x0700#define GEN4_PPD_CONN_B2B 0x0200#define GEN4_PPD_DEV_MASK 0x1000#define GEN4_PPD_DEV_DSD 0x1000#define GEN4_PPD_DEV_USD 0x0000 +#define SPR_PPD_DEV_MASK 0x4000 +#define SPR_PPD_DEV_DSD 0x4000 +#define SPR_PPD_DEV_USD 0x0000#define GEN4_LINK_CTRL_LINK_DISABLE 0x0010#define GEN4_SLOTSTS 0xb05a
@@ -62,6 +66,10 @@#define GEN4_PPD_TOPO_B2B_USD (GEN4_PPD_CONN_B2B | GEN4_PPD_DEV_USD)#define GEN4_PPD_TOPO_B2B_DSD (GEN4_PPD_CONN_B2B | GEN4_PPD_DEV_DSD) +#define SPR_PPD_TOPO_MASK (SPR_PPD_CONN_MASK | SPR_PPD_DEV_MASK) +#define SPR_PPD_TOPO_B2B_USD (GEN4_PPD_CONN_B2B | SPR_PPD_DEV_USD) +#define SPR_PPD_TOPO_B2B_DSD (GEN4_PPD_CONN_B2B | SPR_PPD_DEV_DSD) +#define GEN4_DB_COUNT 32#define GEN4_DB_LINK 32#define GEN4_DB_LINK_BIT BIT_ULL(GEN4_DB_LINK)
@@ -111,5 +119,13 @@ static inline int pdev_is_ICX(struct pcireturn 1 ; return 0; } + +static inline int pdev_is_SPR (struct pci_dev *pdev) +{ +if (pdev_is_gen4 (pdev) && + pdev->revision >PCI_DEVICE_REVISION_ICX_MAX ) +return 1 ; +return 0 ; +}#endif
Greg Kroah-Hartman
maintainerPATCH 152/262 mm: Consider __GFP_NOWARN flag for oversized kvmalloc() calls
In reply to Greg Kroah-HartmanFrom: Daniel Borkmann <[email protected]>
commit 0708a0afe291bdfe1386d74d5ec1f0c27e8b9168 upstream.
syzkaller was recently triggering an oversized kvmalloc() warning via xdp_umem_create().
The triggered warning was added back in 7661809d493b ("mm: don't allow oversized kvmalloc() calls"). The rationale for the warning for huge kvmalloc sizes was as a reaction to a security bug where the size was more than UINT_MAX but not everything was prepared to handle unsigned long sizes.
Anyway, the AF_XDP related call trace from this syzkaller report was:
kvmalloc include/linux/mm.h:806 [inline] kvmalloc_array include/linux/mm.h:824 [inline] kvcalloc include/linux/mm.h:829 [inline] xdp_umem_pin_pages net/xdp/xdp_umem.c:102 [inline] xdp_umem_reg net/xdp/xdp_umem.c:219 [inline] xdp_umem_create+0x6a5/0xf00 net/xdp/xdp_umem.c:252 xsk_setsockopt+0x604/0x790 net/xdp/xsk.c:1068 __sys_setsockopt+0x1fd/0x4e0 net/socket.c:2176 __do_sys_setsockopt net/socket.c:2187 [inline] __se_sys_setsockopt net/socket.c:2184 [inline] __x64_sys_setsockopt+0xb5/0x150 net/socket.c:2184 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae
Björn mentioned that requests for >2GB allocation can still be valid:
The structure that is being allocated is the page-pinning accounting. AF_XDP has an internal limit of U32_MAX pages, which is *a lot*, but still fewer than what memcg allows (PAGE_COUNTER_MAX is a LONG_MAX/ PAGE_SIZE on 64 bit systems). [...]
I could just change from U32_MAX to INT_MAX, but as I stated earlier that has a hacky feeling to it. [...] From my perspective, the code isn't broken, with the memcg limits in consideration. [...]
Linus says:
[...] Pretty much every time this has come up, the kernel warning has shown that yes, the code was broken and there really wasn't a reason for doing allocations that big.
Of course, some people would be perfectly fine with the allocation failing, they just don't want the warning. I didn't want __GFP_NOWARN to shut it up originally because I wanted people to see all those cases, but these days I think we can just say "yeah, people can shut it up explicitly by saying 'go ahead and fail this allocation, don't warn about it'".
So enough time has passed that by now I'd certainly be ok with [it].
Thus allow call-sites to silence such userspace triggered splats if the allocation requests have __GFP_NOWARN. For xdp_umem_pin_pages()'s call to kvcalloc() this is already the case, so nothing else needed there.
--- mm/util.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
mm/util.c +3 -1
@@ -594,8 +594,10 @@ void *kvmalloc_node(size_t size, gfp_t freturn ret;/* Don't even allow crazy sizes */ -if (WARN_ON_ONCE (size >INT_MAX )) +if (unlikely (size >INT_MAX )) { +WARN_ON_ONCE (!(flags & __GFP_NOWARN));return NULL ; + }return __vmalloc_node (size,1 , flags, node,__builtin_return_address (0 ));
Greg Kroah-Hartman
maintainerPATCH 153/262 xfrm: fix MTU regression
In reply to Greg Kroah-HartmanFrom: Jiri Bohac <[email protected]>
commit 6596a0229541270fb8d38d989f91b78838e5e9da upstream.
Commit 749439bfac6e1a2932c582e2699f91d329658196 ("ipv6: fix udpv6 sendmsg crash caused by too small MTU") breaks PMTU for xfrm.
A Packet Too Big ICMPv6 message received in response to an ESP packet will prevent all further communication through the tunnel if the reported MTU minus the ESP overhead is smaller than 1280.
E.g. in a case of a tunnel-mode ESP with sha256/aes the overhead is 92 bytes. Receiving a PTB with MTU of 1371 or less will result in all further packets in the tunnel dropped. A ping through the tunnel fails with "ping: sendmsg: Invalid argument".
Apparently the MTU on the xfrm route is smaller than 1280 and fails the check inside ip6_setup_cork() added by 749439bf.
We found this by debugging USGv6/ipv6ready failures. Failing tests are: "Phase-2 Interoperability Test Scenario IPsec" / 5.3.11 and 5.4.11 (Tunnel Mode: Fragmentation).
Commit b515d2637276a3810d6595e10ab02c13bfd0b63a ("xfrm:xfrm_state_mtu should return at least 1280 for ipv6") attempted to fix this but caused another regression in TCP MSS calculations and had to be reverted.
The patch below fixes the situation by dropping the MTU check and instead checking for the underflows described in the 749439bf commit message.
--- net/ipv6/ip6_output.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
net/ipv6/ip6_output.c +7 -4
@@ -1408,8 +1408,6 @@ static int ip6_setup_cork(struct sock *sif (np->frag_size) mtu = np->frag_size; } -if (mtu <IPV6_MIN_MTU ) -return -EINVAL ; cork->base.fragsize = mtu; cork->base.gso_size = ipc6->gso_size; cork->base.tx_flags =0 ;
@@ -1471,8 +1469,6 @@ static int __ip6_append_data(struct sock fragheaderlen =sizeof (struct ipv6hdr ) + rt->rt6i_nfheader_len + (opt ? opt->opt_nflen :0 ); - maxfraglen = ((mtu - fragheaderlen) & ~7 ) + fragheaderlen - -sizeof (struct frag_hdr ); headersize =sizeof (struct ipv6hdr ) + (opt ? opt->opt_flen + opt->opt_nflen : 0) +
@@ -1480,6 +1476,13 @@ static int __ip6_append_data(struct sock sizeof(struct frag_hdr) : 0) + rt->rt6i_nfheader_len; +if (mtu < fragheaderlen || + ((mtu - fragheaderlen) & ~7 ) + fragheaderlen <sizeof (struct frag_hdr )) + goto emsgsize; + + maxfraglen = ((mtu - fragheaderlen) & ~7 ) + fragheaderlen - +sizeof (struct frag_hdr ); +/* as per RFC 7112 section 5, the entire IPv6 Header Chain must fit * the first fragment */
Greg Kroah-Hartman
maintainerPATCH 154/262 netfilter: fix use-after-free in __nf_register_net_hook()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
commit 56763f12b0f02706576a088e85ef856deacc98a0 upstream.
We must not dereference @new_hooks after nf_hook_mutex has been released, because other threads might have freed our allocated hooks already.
BUG: KASAN: use-after-free in nf_hook_entries_get_hook_ops include/linux/netfilter.h:130 [inline]
BUG: KASAN: use-after-free in hooks_validate net/netfilter/core.c:171 [inline]
BUG: KASAN: use-after-free in __nf_register_net_hook+0x77a/0x820 net/netfilter/core.c:438
Read of size 2 at addr ffff88801c1a8000 by task syz-executor237/4430
CPU: 1 PID: 4430 Comm: syz-executor237 Not tainted 5.17.0-rc5-syzkaller-00306-g2293be58d6a1 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
print_address_description.constprop.0.cold+0x8d/0x336 mm/kasan/report.c:255
__kasan_report mm/kasan/report.c:442 [inline]
kasan_report.cold+0x83/0xdf mm/kasan/report.c:459
nf_hook_entries_get_hook_ops include/linux/netfilter.h:130 [inline]
hooks_validate net/netfilter/core.c:171 [inline]
__nf_register_net_hook+0x77a/0x820 net/netfilter/core.c:438
nf_register_net_hook+0x114/0x170 net/netfilter/core.c:571
nf_register_net_hooks+0x59/0xc0 net/netfilter/core.c:587
nf_synproxy_ipv6_init+0x85/0xe0 net/netfilter/nf_synproxy_core.c:1218
synproxy_tg6_check+0x30d/0x560 net/ipv6/netfilter/ip6t_SYNPROXY.c:81
xt_check_target+0x26c/0x9e0 net/netfilter/x_tables.c:1038
check_target net/ipv6/netfilter/ip6_tables.c:530 [inline]
find_check_entry.constprop.0+0x7f1/0x9e0 net/ipv6/netfilter/ip6_tables.c:573
translate_table+0xc8b/0x1750 net/ipv6/netfilter/ip6_tables.c:735
do_replace net/ipv6/netfilter/ip6_tables.c:1153 [inline]
do_ip6t_set_ctl+0x56e/0xb90 net/ipv6/netfilter/ip6_tables.c:1639
nf_setsockopt+0x83/0xe0 net/netfilter/nf_sockopt.c:101
ipv6_setsockopt+0x122/0x180 net/ipv6/ipv6_sockglue.c:1024
rawv6_setsockopt+0xd3/0x6a0 net/ipv6/raw.c:1084
__sys_setsockopt+0x2db/0x610 net/socket.c:2180
__do_sys_setsockopt net/socket.c:2191 [inline]
__se_sys_setsockopt net/socket.c:2188 [inline]
__x64_sys_setsockopt+0xba/0x150 net/socket.c:2188
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7f65a1ace7d9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 71 15 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f65a1a7f308 EFLAGS: 00000246 ORIG_RAX: 0000000000000036
RAX: ffffffffffffffda RBX: 0000000000000006 RCX: 00007f65a1ace7d9
RDX: 0000000000000040 RSI: 0000000000000029 RDI: 0000000000000003
RBP: 00007f65a1b574c8 R08: 0000000000000001 R09: 0000000000000000
R10: 0000000020000000 R11: 0000000000000246 R12: 00007f65a1b55130
R13: 00007f65a1b574c0 R14: 00007f65a1b24090 R15: 0000000000022000
</TASK>
The buggy address belongs to the page:
page:ffffea0000706a00 refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1c1a8
flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000000 ffffea0001c1b108 ffffea000046dd08 0000000000000000
raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as freed
page last allocated via order 2, migratetype Unmovable, gfp_mask 0x52dc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_ZERO), pid 4430, ts 1061781545818, free_ts 1061791488993
prep_new_page mm/page_alloc.c:2434 [inline]
get_page_from_freelist+0xa72/0x2f50 mm/page_alloc.c:4165
__alloc_pages+0x1b2/0x500 mm/page_alloc.c:5389
__alloc_pages_node include/linux/gfp.h:572 [inline]
alloc_pages_node include/linux/gfp.h:595 [inline]
kmalloc_large_node+0x62/0x130 mm/slub.c:4438
__kmalloc_node+0x35a/0x4a0 mm/slub.c:4454
kmalloc_node include/linux/slab.h:604 [inline]
kvmalloc_node+0x97/0x100 mm/util.c:580
kvmalloc include/linux/slab.h:731 [inline]
kvzalloc include/linux/slab.h:739 [inline]
allocate_hook_entries_size net/netfilter/core.c:61 [inline]
nf_hook_entries_grow+0x140/0x780 net/netfilter/core.c:128
__nf_register_net_hook+0x144/0x820 net/netfilter/core.c:429
nf_register_net_hook+0x114/0x170 net/netfilter/core.c:571
nf_register_net_hooks+0x59/0xc0 net/netfilter/core.c:587
nf_synproxy_ipv6_init+0x85/0xe0 net/netfilter/nf_synproxy_core.c:1218
synproxy_tg6_check+0x30d/0x560 net/ipv6/netfilter/ip6t_SYNPROXY.c:81
xt_check_target+0x26c/0x9e0 net/netfilter/x_tables.c:1038
check_target net/ipv6/netfilter/ip6_tables.c:530 [inline]
find_check_entry.constprop.0+0x7f1/0x9e0 net/ipv6/netfilter/ip6_tables.c:573
translate_table+0xc8b/0x1750 net/ipv6/netfilter/ip6_tables.c:735
do_replace net/ipv6/netfilter/ip6_tables.c:1153 [inline]
do_ip6t_set_ctl+0x56e/0xb90 net/ipv6/netfilter/ip6_tables.c:1639
nf_setsockopt+0x83/0xe0 net/netfilter/nf_sockopt.c:101
page last free stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1352 [inline]
free_pcp_prepare+0x374/0x870 mm/page_alloc.c:1404
free_unref_page_prepare mm/page_alloc.c:3325 [inline]
free_unref_page+0x19/0x690 mm/page_alloc.c:3404
kvfree+0x42/0x50 mm/util.c:613
rcu_do_batch kernel/rcu/tree.c:2527 [inline]
rcu_core+0x7b1/0x1820 kernel/rcu/tree.c:2778
__do_softirq+0x29b/0x9c2 kernel/softirq.c:558
Memory state around the buggy address:
ffff88801c1a7f00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff88801c1a7f80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff88801c1a8000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
^
ffff88801c1a8080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff88801c1a8100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff--- net/netfilter/core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
net/netfilter/core.c +3 -2
@@ -406,14 +406,15 @@ static int __nf_register_net_hook(struct p =nf_entry_dereference (*pp); new_hooks =nf_hook_entries_grow (p, reg); -if (!IS_ERR (new_hooks)) +if (!IS_ERR (new_hooks)) { +hooks_validate (new_hooks);rcu_assign_pointer (*pp, new_hooks); + }mutex_unlock (&nf_hook_mutex);if (IS_ERR (new_hooks))return PTR_ERR (new_hooks); -hooks_validate (new_hooks);#ifdef CONFIG_NETFILTER_INGRESS if (nf_ingress_hook (reg, pf))net_inc_ingress_queue ();
Greg Kroah-Hartman
maintainerPATCH 155/262 bpf, sockmap: Do not ignore orig_len parameter
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
commit 60ce37b03917e593d8e5d8bcc7ec820773daf81d upstream.
Currently, sk_psock_verdict_recv() returns skb->len
This is problematic because tcp_read_sock() might have passed orig_len < skb->len, due to the presence of TCP urgent data.
This causes an infinite loop from tcp_read_sock()
Followup patch will make tcp_read_sock() more robust vs bad actors.
--- net/core/skmsg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/skmsg.c +1 -1
@@ -1153,7 +1153,7 @@ static int sk_psock_verdict_recv(read_destruct sk_psock *psock;struct bpf_prog *prog;int ret = __SK_DROP; -int len = skb->len; +int len = orig_len;/* clone here so sk_eat_skb() in tcp_read_sock does not drop our data */ skb =skb_clone (skb,GFP_ATOMIC );
Greg Kroah-Hartman
maintainerPATCH 156/262 xfrm: fix the if_id check in changelink
In reply to Greg Kroah-HartmanFrom: Antony Antony <[email protected]>
commit 6d0d95a1c2b07270870e7be16575c513c29af3f1 upstream.
if_id will be always 0, because it was not yet initialized.
--- net/xfrm/xfrm_interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/xfrm/xfrm_interface.c +1 -1
@@ -673,12 +673,12 @@ static int xfrmi_changelink(struct net_dstruct net *net = xi->net;struct xfrm_if_parms p = {}; +xfrmi_netlink_parms (data, &p);if (!p.if_id) {NL_SET_ERR_MSG (extack,"if_id must be non zero" );return -EINVAL ; } -xfrmi_netlink_parms (data, &p); xi =xfrmi_locate (net, &p);if (!xi) { xi =netdev_priv (dev);
Greg Kroah-Hartman
maintainerPATCH 157/262 xfrm: enforce validity of offload input flags
In reply to Greg Kroah-HartmanFrom: Leon Romanovsky <[email protected]>
commit 7c76ecd9c99b6e9a771d813ab1aa7fa428b3ade1 upstream.
struct xfrm_user_offload has flags variable that received user input, but kernel didn't check if valid bits were provided. It caused a situation where not sanitized input was forwarded directly to the drivers.
For example, XFRM_OFFLOAD_IPV6 define that was exposed, was used by strongswan, but not implemented in the kernel at all.
As a solution, check and sanitize input flags to forward XFRM_OFFLOAD_INBOUND to the drivers.
--- include/uapi/linux/xfrm.h | 6 ++++++ net/xfrm/xfrm_device.c | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-)
include/uapi/linux/xfrm.h +6 -0
@@ -511,6 +511,12 @@ struct xfrm_user_offload {int ifindex;__u8 flags; }; +/* This flag was exposed without any kernel code that supporting it. +* Unfortunately, strongswan has the code that uses sets this flag, +* which makes impossible to reuse this bit. +* +* So leave it here to make sure that it won't be reused by mistake. +*/ #define XFRM_OFFLOAD_IPV6 1#define XFRM_OFFLOAD_INBOUND 2
net/xfrm/xfrm_device.c +5 -1
@@ -223,6 +223,9 @@ int xfrm_dev_state_add(struct net *net,if (x->encap || x->tfcpad)return -EINVAL ; +if (xuo->flags & ~(XFRM_OFFLOAD_IPV6 |XFRM_OFFLOAD_INBOUND )) +return -EINVAL ; + dev =dev_get_by_index (net, xuo->ifindex);if (!dev) {if (!(xuo->flags &XFRM_OFFLOAD_INBOUND )) {
@@ -261,7 +264,8 @@ int xfrm_dev_state_add(struct net *net, xso->dev = dev; xso->real_dev = dev; xso->num_exthdrs =1 ; - xso->flags = xuo->flags; +/* Don't forward bit that is not implemented */ + xso->flags = xuo->flags & ~XFRM_OFFLOAD_IPV6 ; err = dev->xfrmdev_ops->xdo_dev_state_add (x);if (err) {
Greg Kroah-Hartman
maintainerPATCH 158/262 e1000e: Correct NVM checksum verification flow
In reply to Greg Kroah-HartmanFrom: Sasha Neftin <[email protected]>
commit ffd24fa2fcc76ecb2e61e7a4ef8588177bcb42a6 upstream.
Update MAC type check e1000_pch_tgp because for e1000_pch_cnp, NVM checksum update is still possible.
Emit a more detailed warning message.
Bugzilla: https://bugzilla.opensuse.org/show_bug.cgi?id=1191663
--- drivers/net/ethernet/intel/e1000e/ich8lan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/e1000e/ich8lan.c +2 -2
@@ -4136,9 +4136,9 @@ static s32 e1000_validate_nvm_checksum_ireturn ret_val;if (!(data & valid_csum_mask)) { -e_dbg ("NVM Checksum Invalid\n" ); +e_dbg ("NVM Checksum valid bit not set\n" ); -if (hw->mac.type < e1000_pch_cnp) { +if (hw->mac.type < e1000_pch_tgp) { data |= valid_csum_mask; ret_val =e1000_write_nvm (hw, word,1 , &data);if (ret_val)
Greg Kroah-Hartman
maintainerPATCH 159/262 net: fix up skbs delta_truesize in UDP GRO frag_list
In reply to Greg Kroah-HartmanFrom: lena wang <[email protected]>
commit 224102de2ff105a2c05695e66a08f4b5b6b2d19c upstream.
The truesize for a UDP GRO packet is added by main skb and skbs in main skb's frag_list:skb_gro_receive_list
p->truesize += skb->truesize;
The commit 53475c5dd856 ("net: fix use-after-free when UDP GRO with shared fraglist") introduced a truesize increase for frag_list skbs. When uncloning skb, it will call pskb_expand_head and trusesize for frag_list skbs may increase. This can occur when allocators uses __netdev_alloc_skb and not jump into __alloc_skb. This flow does not use ksize(len) to calculate truesize while pskb_expand_head uses. skb_segment_list
err = skb_unclone(nskb, GFP_ATOMIC);pskb_expand_head
if (!skb->sk || skb->destructor == sock_edemux)
skb->truesize += size - osize;If we uses increased truesize adding as delta_truesize, it will be larger than before and even larger than previous total truesize value if skbs in frag_list are abundant. The main skb truesize will become smaller and even a minus value or a huge value for an unsigned int parameter. Then the following memory check will drop this abnormal skb.
To avoid this error we should use the original truesize to segment the main skb.
--- net/core/skbuff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/skbuff.c +1 -1
@@ -3853,6 +3853,7 @@ struct sk_buff *skb_segment_list(struct list_skb = list_skb->next; err =0 ; + delta_truesize += nskb->truesize;if (skb_shared (nskb)) { tmp =skb_clone (nskb,GFP_ATOMIC );if (tmp) {
@@ -3877,7 +3878,6 @@ struct sk_buff *skb_segment_list(struct tail = nskb; delta_len += nskb->len; - delta_truesize += nskb->truesize;skb_push (nskb, -skb_network_offset (nskb) + offset);
Greg Kroah-Hartman
maintainerPATCH 160/262 netfilter: nf_queue: dont assume sk is full socket
In reply to Greg Kroah-HartmanFrom: Florian Westphal <[email protected]>
commit 747670fd9a2d1b7774030dba65ca022ba442ce71 upstream.
There is no guarantee that state->sk refers to a full socket.
If refcount transitions to 0, sock_put calls sk_free which then ends up with garbage fields.
I'd like to thank Oleksandr Natalenko and Jiri Benc for considerable debug work and pointing out state->sk oddities.
--- net/netfilter/nf_queue.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
net/netfilter/nf_queue.c +10 -1
@@ -46,6 +46,15 @@ void nf_unregister_queue_handler(void) }EXPORT_SYMBOL (nf_unregister_queue_handler); +static void nf_queue_sock_put (struct sock *sk) +{ +#ifdef CONFIG_INET +sock_gen_put (sk); +#else +sock_put (sk); +#endif +} +static void nf_queue_entry_release_refs (struct nf_queue_entry *entry) {struct nf_hook_state *state = &entry->state;
@@ -54,7 +63,7 @@ static void nf_queue_entry_release_refs(dev_put (state->in);dev_put (state->out);if (state->sk) -sock_put (state->sk); +nf_queue_sock_put (state->sk);#if IS_ENABLED (CONFIG_BRIDGE_NETFILTER )dev_put (entry->physin);
Greg Kroah-Hartman
maintainerPATCH 161/262 netfilter: nf_queue: fix possible use-after-free
In reply to Greg Kroah-HartmanFrom: Florian Westphal <[email protected]>
commit c3873070247d9e3c7a6b0cf9bf9b45e8018427b1 upstream.
Eric Dumazet says:
The sock_hold() side seems suspect, because there is no guarantee that sk_refcnt is not already 0.
On failure, we cannot queue the packet and need to indicate an error. The packet will be dropped by the caller.
v2: split skb prefetch hunk into separate change
--- include/net/netfilter/nf_queue.h | 2 +- net/netfilter/nf_queue.c | 13 +++++++++---- net/netfilter/nfnetlink_queue.c | 12 +++++++++--- 3 files changed, 19 insertions(+), 8 deletions(-)
include/net/netfilter/nf_queue.h +1 -1
@@ -37,7 +37,7 @@ void nf_register_queue_handler(const strvoid nf_unregister_queue_handler (void );void nf_reinject (struct nf_queue_entry *entry,unsigned int verdict); -void nf_queue_entry_get_refs (struct nf_queue_entry *entry); +bool nf_queue_entry_get_refs (struct nf_queue_entry *entry);void nf_queue_entry_free (struct nf_queue_entry *entry);static inline void init_hashrandom (u32 *jhash_initval)
net/netfilter/nf_queue.c +9 -4
@@ -96,19 +96,21 @@ static void __nf_queue_entry_init_physde }/* Bump dev refs so they don't vanish while packet is out */ -void nf_queue_entry_get_refs (struct nf_queue_entry *entry) +bool nf_queue_entry_get_refs (struct nf_queue_entry *entry) {struct nf_hook_state *state = &entry->state; +if (state->sk && !refcount_inc_not_zero (&state->sk->sk_refcnt)) +return false; +dev_hold (state->in);dev_hold (state->out); -if (state->sk) -sock_hold (state->sk);#if IS_ENABLED (CONFIG_BRIDGE_NETFILTER )dev_hold (entry->physin);dev_hold (entry->physout);#endif +return true; }EXPORT_SYMBOL_GPL (nf_queue_entry_get_refs);
@@ -196,7 +198,10 @@ static int __nf_queue(struct sk_buff *sk__nf_queue_entry_init_physdevs (entry); -nf_queue_entry_get_refs (entry); +if (!nf_queue_entry_get_refs (entry)) { +kfree (entry); +return -ENOTCONN ; + }switch (entry->state.pf) {case AF_INET :
net/netfilter/nfnetlink_queue.c +9 -3
@@ -710,9 +710,15 @@ static struct nf_queue_entry * nf_queue_entry_dup(struct nf_queue_entry *e) {struct nf_queue_entry *entry =kmemdup (e, e->size,GFP_ATOMIC ); -if (entry) -nf_queue_entry_get_refs (entry); -return entry; + +if (!entry) +return NULL ; + +if (nf_queue_entry_get_refs (entry)) +return entry; + +kfree (entry); +return NULL ; }#if IS_ENABLED (CONFIG_BRIDGE_NETFILTER )
Greg Kroah-Hartman
maintainerPATCH 162/262 netfilter: nf_queue: handle socket prefetch
In reply to Greg Kroah-HartmanFrom: Florian Westphal <[email protected]>
commit 3b836da4081fa585cf6c392f62557496f2cb0efe upstream.
In case someone combines bpf socket assign and nf_queue, then we will queue an skb who references a struct sock that did not have its reference count incremented.
As we leave rcu protection, there is no guarantee that skb->sk is still valid.
For refcount-less skb->sk case, try to increment the reference count and then override the destructor.
In case of failure we have two choices: orphan the skb and 'delete' preselect or let nf_queue() drop the packet.
Do the latter, it should not happen during normal operation.
--- net/netfilter/nf_queue.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
net/netfilter/nf_queue.c +12 -0
@@ -180,6 +180,18 @@ static int __nf_queue(struct sk_buff *skbreak ; } +if (skb_sk_is_prefetched (skb)) { +struct sock *sk = skb->sk; + +if (!sk_is_refcounted (sk)) { +if (!refcount_inc_not_zero (&sk->sk_refcnt)) +return -ENOTCONN ; + +/* drop refcount on skb_orphan */ + skb->destructor = sock_edemux; + } + } + entry =kmalloc (sizeof (*entry) + route_key_size,GFP_ATOMIC );if (!entry)return -ENOMEM ;
Greg Kroah-Hartman
maintainerPATCH 163/262 batman-adv: Request iflink once in batadv-on-batadv check
In reply to Greg Kroah-HartmanFrom: Sven Eckelmann <[email protected]>
commit 690bb6fb64f5dc7437317153902573ecad67593d upstream.
There is no need to call dev_get_iflink multiple times for the same net_device in batadv_is_on_batman_iface. And since some of the .ndo_get_iflink callbacks are dynamic (for example via RCUs like in vxcan_get_iflink), it could easily happen that the returned values are not stable. The pre-checks before __dev_get_by_index are then of course bogus.
--- net/batman-adv/hard-interface.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
net/batman-adv/hard-interface.c +5 -4
@@ -149,22 +149,23 @@ static bool batadv_is_on_batman_iface(costruct net *net =dev_net (net_dev);struct net_device *parent_dev;struct net *parent_net; +int iflink;bool ret;/* check if this is a batman-adv mesh interface */ if (batadv_softif_is_valid (net_dev))return true; + iflink =dev_get_iflink (net_dev); +/* no more parents..stop recursion */ -if (dev_get_iflink (net_dev) ==0 || -dev_get_iflink (net_dev) == net_dev->ifindex) +if (iflink ==0 || iflink == net_dev->ifindex)return false; parent_net =batadv_getlink_net (net_dev, net);/* recurse over the parent device */ - parent_dev =__dev_get_by_index ((struct net *)parent_net, -dev_get_iflink (net_dev)); + parent_dev =__dev_get_by_index ((struct net *)parent_net, iflink);/* if we got a NULL parent_dev there is something broken.. */ if (!parent_dev) {pr_err ("Cannot find parent device\n" );
Greg Kroah-Hartman
maintainerPATCH 164/262 batman-adv: Request iflink once in batadv_get_real_netdevice
In reply to Greg Kroah-HartmanFrom: Sven Eckelmann <[email protected]>
commit 6116ba09423f7d140f0460be6a1644dceaad00da upstream.
There is no need to call dev_get_iflink multiple times for the same net_device in batadv_get_real_netdevice. And since some of the ndo_get_iflink callbacks are dynamic (for example via RCUs like in vxcan_get_iflink), it could easily happen that the returned values are not stable. The pre-checks before __dev_get_by_index are then of course bogus.
--- net/batman-adv/hard-interface.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
net/batman-adv/hard-interface.c +5 -4
@@ -215,14 +215,16 @@ static struct net_device *batadv_get_reastruct net_device *real_netdev =NULL ;struct net *real_net;struct net *net; -int ifindex; +int iflink;ASSERT_RTNL ();if (!netdev)return NULL ; -if (netdev->ifindex ==dev_get_iflink (netdev)) { + iflink =dev_get_iflink (netdev); + +if (netdev->ifindex == iflink) {dev_hold (netdev);return netdev; }
@@ -232,9 +234,8 @@ static struct net_device *batadv_get_rea goto out; net =dev_net (hard_iface->soft_iface); - ifindex =dev_get_iflink (netdev); real_net =batadv_getlink_net (netdev, net); - real_netdev =dev_get_by_index (real_net, ifindex); + real_netdev =dev_get_by_index (real_net, iflink); out:batadv_hardif_put (hard_iface);
Greg Kroah-Hartman
maintainerPATCH 165/262 batman-adv: Dont expect inter-netns unique iflink indices
In reply to Greg Kroah-HartmanFrom: Sven Eckelmann <[email protected]>
commit 6c1f41afc1dbe59d9d3c8bb0d80b749c119aa334 upstream.
The ifindex doesn't have to be unique for multiple network namespaces on the same machine.
$ ip netns add test1 $ ip -net test1 link add dummy1 type dummy $ ip netns add test2 $ ip -net test2 link add dummy2 type dummy
$ ip -net test1 link show dev dummy1
6: dummy1: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether 96:81:55:1e:dd:85 brd ff:ff:ff:ff:ff:ff
$ ip -net test2 link show dev dummy2
6: dummy2: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether 5a:3c:af:35:07:c3 brd ff:ff:ff:ff:ff:ffBut the batman-adv code to walk through the various layers of virtual interfaces uses this assumption because dev_get_iflink handles it internally and doesn't return the actual netns of the iflink. And dev_get_iflink only documents the situation where ifindex == iflink for physical devices.
But only checking for dev->netdev_ops->ndo_get_iflink is also not an option because ipoib_get_iflink implements it even when it sometimes returns an iflink != ifindex and sometimes iflink == ifindex. The caller must therefore make sure itself to check both netns and iflink + ifindex for equality. Only when they are equal, a "physical" interface was detected which should stop the traversal. On the other hand, vxcan_get_iflink can also return 0 in case there was currently no valid peer. In this case, it is still necessary to stop.
--- net/batman-adv/hard-interface.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)
net/batman-adv/hard-interface.c +14 -5
@@ -157,13 +157,15 @@ static bool batadv_is_on_batman_iface(coreturn true; iflink =dev_get_iflink (net_dev); - -/* no more parents..stop recursion */ -if (iflink ==0 || iflink == net_dev->ifindex) +if (iflink ==0 )return false; parent_net =batadv_getlink_net (net_dev, net); +/* iflink to itself, most likely physical device */ +if (net == parent_net && iflink == net_dev->ifindex) +return false; +/* recurse over the parent device */ parent_dev =__dev_get_by_index ((struct net *)parent_net, iflink);/* if we got a NULL parent_dev there is something broken.. */
@@ -223,8 +225,7 @@ static struct net_device *batadv_get_reareturn NULL ; iflink =dev_get_iflink (netdev); - -if (netdev->ifindex == iflink) { +if (iflink ==0 ) {dev_hold (netdev);return netdev; }
@@ -235,6 +236,14 @@ static struct net_device *batadv_get_rea net =dev_net (hard_iface->soft_iface); real_net =batadv_getlink_net (netdev, net); + +/* iflink to itself, most likely physical device */ +if (net == real_net && netdev->ifindex == iflink) { + real_netdev = netdev; +dev_hold (real_netdev); + goto out; + } + real_netdev =dev_get_by_index (real_net, iflink); out:
Greg Kroah-Hartman
maintainerPATCH 166/262 net: ipv6: ensure we call ipv6_mc_down() at most once
In reply to Greg Kroah-HartmanFrom: [email protected] <[email protected]>
commit 9995b408f17ff8c7f11bc725c8aa225ba3a63b1c upstream.
There are two reasons for addrconf_notify() to be called with NETDEV_DOWN:
either the network device is actually going down, or IPv6 was disabled on the interface.
If either of them stays down while the other is toggled, we repeatedly call the code for NETDEV_DOWN, including ipv6_mc_down(), while never calling the corresponding ipv6_mc_up() in between. This will cause a new entry in idev->mc_tomb to be allocated for each multicast group the interface is subscribed to, which in turn leaks one struct ifmcaddr6 per nontrivial multicast group the interface is subscribed to.
The following reproducer will leak at least $n objects:
ip addr add ff2e::4242/32 dev eth0 autojoin sysctl -w net.ipv6.conf.eth0.disable_ipv6=1 for i in $(seq 1 $n); do
ip link set up eth0; ip link set down eth0
done
Joining groups with IPV6_ADD_MEMBERSHIP (unprivileged) or setting the sysctl net.ipv6.conf.eth0.forwarding to 1 (=> subscribing to ff02::2) can also be used to create a nontrivial idev->mc_list, which will the leak objects with the right up-down-sequence.
Based on both sources for NETDEV_DOWN events the interface IPv6 state should be considered:
- not ready if the network interface is not ready OR IPv6 is disabled for it
- ready if the network interface is ready AND IPv6 is enabled for it
The functions ipv6_mc_up() and ipv6_down() should only be run when this state changes.
Implement this by remembering when the IPv6 state is ready, and only run ipv6_mc_down() if it actually changed from ready to not ready.
The other direction (not ready -> ready) already works correctly, as:
- the interface notification triggered codepath for NETDEV_UP / NETDEV_CHANGE returns early if ipv6 is disabled, and
- the disable_ipv6=0 triggered codepath skips fully initializing the interface as long as addrconf_link_ready(dev) returns false
- calling ipv6_mc_up() repeatedly does not leak anything
--- net/ipv6/addrconf.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
net/ipv6/addrconf.c +6 -2
@@ -3730,6 +3730,7 @@ static int addrconf_ifdown(struct net_destruct inet6_dev *idev;struct inet6_ifaddr *ifa, *tmp;bool keep_addr = false; +bool was_ready;int state, i;ASSERT_RTNL ();
@@ -3795,7 +3796,10 @@ restart:addrconf_del_rs_timer (idev); -/* Step 2: clear flags for stateless addrconf */ +/* Step 2: clear flags for stateless addrconf, repeated down +* detection +*/ + was_ready = idev->if_flags &IF_READY ;if (!unregister) idev->if_flags &= ~(IF_RS_SENT |IF_RA_RCVD |IF_READY );
@@ -3869,7 +3873,7 @@ restart:if (unregister) {ipv6_ac_destroy_dev (idev);ipv6_mc_destroy_dev (idev); - }else { + }else if (was_ready) {ipv6_mc_down (idev); }
Greg Kroah-Hartman
maintainerPATCH 167/262 net: dcb: flush lingering app table entries for unregistered devices
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
commit 91b0383fef06f20b847fa9e4f0e3054ead0b1a1b upstream.
If I'm not mistaken (and I don't think I am), the way in which the dcbnl_ops work is that drivers call dcb_ieee_setapp() and this populates the application table with dynamically allocated struct dcb_app_type entries that are kept in the module-global dcb_app_list.
However, nobody keeps exact track of these entries, and although dcb_ieee_delapp() is supposed to remove them, nobody does so when the interface goes away (example: driver unbinds from device). So the dcb_app_list will contain lingering entries with an ifindex that no longer matches any device in dcb_app_lookup().
Reclaim the lost memory by listening for the NETDEV_UNREGISTER event and flushing the app table entries of interfaces that are now gone.
In fact something like this used to be done as part of the initial commit (blamed below), but it was done in dcbnl_exit() -> dcb_flushapp(), essentially at module_exit time. That became dead code after commit 7a6b6f515f77 ("DCB: fix kconfig option") which essentially merged "tristate config DCB" and "bool config DCBNL" into a single "bool config DCB", so net/dcb/dcbnl.c could not be built as a module anymore.
Commit 36b9ad8084bd ("net/dcb: make dcbnl.c explicitly non-modular") recognized this and deleted dcbnl_exit() and dcb_flushapp() altogether, leaving us with the version we have today.
Since flushing application table entries can and should be done as soon as the netdevice disappears, fundamentally the commit that is to blame is the one that introduced the design of this API.
--- net/dcb/dcbnl.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+)
net/dcb/dcbnl.c +44 -0
@@ -2073,8 +2073,52 @@ u8 dcb_ieee_getapp_default_prio_mask(con }EXPORT_SYMBOL (dcb_ieee_getapp_default_prio_mask); +static void dcbnl_flush_dev (struct net_device *dev) +{ +struct dcb_app_type *itr, *tmp; + +spin_lock (&dcb_lock); + +list_for_each_entry_safe (itr, tmp, &dcb_app_list, list) { +if (itr->ifindex == dev->ifindex) { +list_del (&itr->list); +kfree (itr); + } + } + +spin_unlock (&dcb_lock); +} + +static int dcbnl_netdevice_event (struct notifier_block *nb, +unsigned long event,void *ptr) +{ +struct net_device *dev =netdev_notifier_info_to_dev (ptr); + +switch (event) { +case NETDEV_UNREGISTER : +if (!dev->dcbnl_ops) +return NOTIFY_DONE ; + +dcbnl_flush_dev (dev); + +return NOTIFY_OK ; +default : +return NOTIFY_DONE ; + } +} + +static struct notifier_block dcbnl_nb__read_mostly = { + .notifier_call = dcbnl_netdevice_event, +}; +static int __init dcbnl_init (void ) { +int err; + + err =register_netdevice_notifier (&dcbnl_nb); +if (err) +return err; +rtnl_register (PF_UNSPEC ,RTM_GETDCB , dcb_doit,NULL ,0 );rtnl_register (PF_UNSPEC ,RTM_SETDCB , dcb_doit,NULL ,0 );
Greg Kroah-Hartman
maintainerPATCH 168/262 net: ipa: add an interconnect dependency
In reply to Greg Kroah-HartmanFrom: Alex Elder <[email protected]>
commit 1dba41c9d2e2dc94b543394974f63d55aa195bfe upstream.
In order to function, the IPA driver very clearly requires the interconnect framework to be enabled in the kernel configuration. State that dependency in the Kconfig file.
This became a problem when CONFIG_COMPILE_TEST support was added. Non-Qualcomm platforms won't necessarily enable CONFIG_INTERCONNECT.
--- drivers/net/ipa/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/net/ipa/Kconfig +1 -0
@@ -2,6 +2,7 @@ config QCOM_IPA tristate "Qualcomm IPA support" depends on NET && QCOM_SMEM depends on ARCH_QCOM || COMPILE_TEST + depends on INTERCONNECT depends on QCOM_RPROC_COMMON || (QCOM_RPROC_COMMON=n && COMPILE_TEST) select QCOM_MDT_LOADER if ARCH_QCOM select QCOM_SCM
Greg Kroah-Hartman
maintainerPATCH 169/262 net/smc: fix connection leak
In reply to Greg Kroah-HartmanFrom: D. Wythe <[email protected]>
commit 9f1c50cf39167ff71dc5953a3234f3f6eeb8fcb5 upstream.
There's a potential leak issue under following execution sequence :
smc_release smc_connect_work
if (sk->sk_state == SMC_INIT)
send_clc_confirim tcp_abort(); ... sk.sk_state = SMC_ACTIVE
smc_close_activeswitch(sk->sk_state) {
...
case SMC_ACTIVE:
smc_close_final() // then wait peer closed
Unfortunately, tcp_abort() may discard CLC CONFIRM messages that are still in the tcp send buffer, in which case our connection token cannot be delivered to the server side, which means that we cannot get a passive close message at all. Therefore, it is impossible for the to be disconnected at all.
This patch tries a very simple way to avoid this issue, once the state has changed to SMC_ACTIVE after tcp_abort(), we can actively abort the smc connection, considering that the state is SMC_INIT before tcp_abort(), abandoning the complete disconnection process should not cause too much problem.
In fact, this problem may exist as long as the CLC CONFIRM message is not received by the server. Whether a timer should be added after smc_close_final() needs to be discussed in the future. But even so, this patch provides a faster release for connection in above case, it should also be valuable.
--- net/smc/af_smc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
net/smc/af_smc.c +8 -2
@@ -182,7 +182,7 @@ static int smc_release(struct socket *so {struct sock *sk = sock->sk;struct smc_sock *smc; -int rc =0 ; +int old_state, rc =0 ;if (!sk) goto out;
@@ -190,8 +190,10 @@ static int smc_release(struct socket *sosock_hold (sk);/* sock_put below */ smc =smc_sk (sk); + old_state = sk->sk_state; +/* cleanup for a dangling non-blocking connect */ -if (smc->connect_nonblock && sk->sk_state ==SMC_INIT ) +if (smc->connect_nonblock && old_state ==SMC_INIT )tcp_abort (smc->clcsock->sk,ECONNABORTED );if (cancel_work_sync (&smc->connect_work))
@@ -205,6 +207,10 @@ static int smc_release(struct socket *soelse lock_sock (sk); +if (old_state ==SMC_INIT && sk->sk_state ==SMC_ACTIVE && + !smc->use_fallback) +smc_close_active_abort (smc); + rc =__smc_release (smc);/* detach socket */
Greg Kroah-Hartman
maintainerPATCH 170/262 net/smc: fix unexpected SMC_CLC_DECL_ERR_REGRMB error generated by client
In reply to Greg Kroah-HartmanFrom: D. Wythe <[email protected]>
commit 0537f0a2151375dcf90c1bbfda6a0aaf57164e89 upstream.
The main reason for this unexpected SMC_CLC_DECL_ERR_REGRMB in client dues to following execution sequence:
Server Conn A: Server Conn B: Client Conn B:
smc_lgr_unregister_conn
smc_lgr_register_conn
smc_clc_send_accept ->
smc_rtoken_add
smcr_buf_unuse
-> Client Conn A:
smc_rtoken_deletesmc_lgr_unregister_conn() makes current link available to assigned to new incoming connection, while smcr_buf_unuse() has not executed yet, which means that smc_rtoken_add may fail because of insufficient rtoken_entry, reversing their execution order will avoid this problem.
--- net/smc/smc_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/smc/smc_core.c +1 -1
@@ -1061,8 +1061,8 @@ void smc_conn_free(struct smc_connectioncancel_work_sync (&conn->abort_work); }if (!list_empty (&lgr->list)) { -smc_lgr_unregister_conn (conn);smc_buf_unuse (conn, lgr);/* allow buffer reuse */ +smc_lgr_unregister_conn (conn); }if (!lgr->conns_num)
Greg Kroah-Hartman
maintainerPATCH 171/262 net/smc: fix unexpected SMC_CLC_DECL_ERR_REGRMB error cause by server
In reply to Greg Kroah-HartmanFrom: D. Wythe <[email protected]>
commit 4940a1fdf31c39f0806ac831cde333134862030b upstream.
The problem of SMC_CLC_DECL_ERR_REGRMB on the server is very clear. Based on the fact that whether a new SMC connection can be accepted or not depends on not only the limit of conn nums, but also the available entries of rtoken. Since the rtoken release is trigger by peer, while the conn nums is decrease by local, tons of thing can happen in this time difference.
This only thing that needs to be mentioned is that now all connection creations are completely protected by smc_server_lgr_pending lock, it's enough to check only the available entries in rtokens_used_mask.
--- net/smc/smc_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/smc/smc_core.c +2 -1
@@ -1701,7 +1701,8 @@ int smc_conn_create(struct smc_sock *smc (ini->smcd_version ==SMC_V2 || lgr->vlan_id == ini->vlan_id) && (role ==SMC_CLNT || ini->is_smcd || - lgr->conns_num < SMC_RMBS_PER_LGR_MAX)) { + (lgr->conns_num <SMC_RMBS_PER_LGR_MAX && + !bitmap_full(lgr->rtokens_used_mask, SMC_RMBS_PER_LGR_MAX)))) { /* link group found */ ini->first_contact_local = 0; conn->lgr = lgr;
Greg Kroah-Hartman
maintainerPATCH 172/262 btrfs: fix ENOSPC failure when attempting direct IO write into NOCOW range
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
commit f0bfa76a11e93d0fe2c896fcb566568c5e8b5d3f upstream.
When doing a direct IO write against a file range that either has preallocated extents in that range or has regular extents and the file has the NOCOW attribute set, the write fails with -ENOSPC when all of the following conditions are met:
1) There are no data blocks groups with enough free space matching the size of the write;
2) There's not enough unallocated space for allocating a new data block group;
3) The extents in the target file range are not shared, neither through snapshots nor through reflinks.
This is wrong because a NOCOW write can be done in such case, and in fact it's possible to do it using a buffered IO write, since when failing to allocate data space, the buffered IO path checks if a NOCOW write is possible.
The failure in direct IO write path comes from the fact that early on, at btrfs_dio_iomap_begin(), we try to allocate data space for the write and if it that fails we return the error and stop - we never check if we can do NOCOW. But later, at btrfs_get_blocks_direct_write(), we check if we can do a NOCOW write into the range, or a subset of the range, and then release the previously reserved data space.
Fix this by doing the data reservation only if needed, when we must COW, at btrfs_get_blocks_direct_write() instead of doing it at btrfs_dio_iomap_begin(). This also simplifies a bit the logic and removes the inneficiency of doing unnecessary data reservations.
The following example test script reproduces the problem:
$ cat dio-nocow-enospc.sh #!/bin/bash
DEV=/dev/sdj
MNT=/mnt/sdj
# Use a small fixed size (1G) filesystem so that it's quick to fill # it up. # Make sure the mixed block groups feature is not enabled because we # later want to not have more space available for allocating data # extents but still have enough metadata space free for the file writes. mkfs.btrfs -f -b $((1024 * 1024 * 1024)) -O ^mixed-bg $DEV mount $DEV $MNT
# Create our test file with the NOCOW attribute set. touch $MNT/foobar
chattr +C $MNT/foobar
# Now fill in all unallocated space with data for our test file. # This will allocate a data block group that will be full and leave
# no (or a very small amount of) unallocated space in the device, so # that it will not be possible to allocate a new block group later. echo echo "Creating test file with initial data..." xfs_io -c "pwrite -S 0xab -b 1M 0 900M" $MNT/foobar
# Now try a direct IO write against file range [0, 10M[.
# This should succeed since this is a NOCOW file and an extent for the
# range was previously allocated. echo echo "Trying direct IO write over allocated space..." xfs_io -d -c "pwrite -S 0xcd -b 10M 0 10M" $MNT/foobar
umount $MNT
When running the test:
$ ./dio-nocow-enospc.sh (...)
Creating test file with initial data...
wrote 943718400/943718400 bytes at offset 0
900 MiB, 900 ops; 0:00:01.43 (625.526 MiB/sec and 625.5265 ops/sec)
Trying direct IO write over allocated space...
pwrite: No space left on device
A test case for fstests will follow, testing both this direct IO write scenario as well as the buffered IO write scenario to make it less likely to get future regressions on the buffered IO case.
--- fs/btrfs/inode.c | 142 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 78 insertions(+), 64 deletions(-)
fs/btrfs/inode.c +78 -64
@@ -60,8 +60,6 @@ struct btrfs_iget_args { };struct btrfs_dio_data { -u64 reserve; -loff_t length;ssize_t submitted;struct extent_changeset *data_reserved; };
@@ -7763,6 +7761,10 @@ static int btrfs_get_blocks_direct_write {struct btrfs_fs_info *fs_info =btrfs_sb (inode->i_sb);struct extent_map *em = *map; +int type; +u64 block_start, orig_start, orig_block_len, ram_bytes; +bool can_nocow = false; +bool space_reserved = false;int ret =0 ;/*
@@ -7777,9 +7779,6 @@ static int btrfs_get_blocks_direct_writeif (test_bit (EXTENT_FLAG_PREALLOC , &em->flags) || ((BTRFS_I (inode)->flags &BTRFS_INODE_NODATACOW ) && em->block_start !=EXTENT_MAP_HOLE )) { -int type; -u64 block_start, orig_start, orig_block_len, ram_bytes; -if (test_bit (EXTENT_FLAG_PREALLOC , &em->flags)) type =BTRFS_ORDERED_PREALLOC ;else
@@ -7789,53 +7788,92 @@ static int btrfs_get_blocks_direct_writeif (can_nocow_extent (inode, start, &len, &orig_start, &orig_block_len, &ram_bytes, false) ==1 && -btrfs_inc_nocow_writers (fs_info, block_start)) { -struct extent_map *em2; +btrfs_inc_nocow_writers (fs_info, block_start)) + can_nocow = true; + } - em2 =btrfs_create_dio_extent (BTRFS_I (inode), start, len, - orig_start, block_start, - len, orig_block_len, - ram_bytes, type); +if (can_nocow) { +struct extent_map *em2; + +/* We can NOCOW, so only need to reserve metadata space. */ + ret =btrfs_delalloc_reserve_metadata (BTRFS_I (inode), len); +if (ret <0 ) { +/* Our caller expects us to free the input extent map. */ +free_extent_map (em); + *map =NULL ;btrfs_dec_nocow_writers (fs_info, block_start); -if (type ==BTRFS_ORDERED_PREALLOC ) { -free_extent_map (em); - *map = em = em2; - } + goto out; + } + space_reserved = true; -if (em2 &&IS_ERR (em2)) { - ret =PTR_ERR (em2); - goto out; - } -/* -* For inode marked NODATACOW or extent marked PREALLOC, -* use the existing or preallocated extent, so does not -* need to adjust btrfs_space_info's bytes_may_use. -*/ -btrfs_free_reserved_data_space_noquota (fs_info, len); - goto skip_cow; + em2 =btrfs_create_dio_extent (BTRFS_I (inode), start, len, + orig_start, block_start, + len, orig_block_len, + ram_bytes, type); +btrfs_dec_nocow_writers (fs_info, block_start); +if (type ==BTRFS_ORDERED_PREALLOC ) { +free_extent_map (em); + *map = em = em2; } - } -/* this will cow the extent */ -free_extent_map (em); - *map = em =btrfs_new_extent_direct (BTRFS_I (inode), start, len); -if (IS_ERR (em)) { - ret =PTR_ERR (em); - goto out; +if (IS_ERR (em2)) { + ret =PTR_ERR (em2); + goto out; + } + }else { +const u64 prev_len = len; + +/* Our caller expects us to free the input extent map. */ +free_extent_map (em); + *map =NULL ; + +/* We have to COW, so need to reserve metadata and data space. */ + ret =btrfs_delalloc_reserve_space (BTRFS_I (inode), + &dio_data->data_reserved, + start, len); +if (ret <0 ) + goto out; + space_reserved = true; + + em =btrfs_new_extent_direct (BTRFS_I (inode), start, len); +if (IS_ERR (em)) { + ret =PTR_ERR (em); + goto out; + } + *map = em; + len =min (len, em->len - (start - em->start)); +if (len < prev_len) +btrfs_delalloc_release_space (BTRFS_I (inode), + dio_data->data_reserved, + start + len, prev_len - len, + true); } - len =min (len, em->len - (start - em->start)); +/* +* We have created our ordered extent, so we can now release our reservation +* for an outstanding extent. +*/ +btrfs_delalloc_release_extents (BTRFS_I (inode), len); -skip_cow:/* * Need to update the i_size under the extent lock so buffered * readers will get the updated i_size when we unlock. */ if (start + len >i_size_read (inode))i_size_write (inode, start + len); - - dio_data->reserve -= len; out: +if (ret && space_reserved) { +btrfs_delalloc_release_extents (BTRFS_I (inode), len); +if (can_nocow) { +btrfs_delalloc_release_metadata (BTRFS_I (inode), len, true); + }else { +btrfs_delalloc_release_space (BTRFS_I (inode), + dio_data->data_reserved, + start, len, true); +extent_changeset_free (dio_data->data_reserved); + dio_data->data_reserved =NULL ; + } + }return ret; }
@@ -7877,18 +7915,6 @@ static int btrfs_dio_iomap_begin(structif (!dio_data)return -ENOMEM ; - dio_data->length = length; -if (write) { - dio_data->reserve =round_up (length, fs_info->sectorsize); - ret =btrfs_delalloc_reserve_space (BTRFS_I (inode), - &dio_data->data_reserved, - start, dio_data->reserve); -if (ret) { -extent_changeset_free (dio_data->data_reserved); -kfree (dio_data); -return ret; - } - } iomap->private = dio_data;
@@ -7981,14 +8007,8 @@ unlock_err:unlock_extent_cached (&BTRFS_I (inode)->io_tree, lockstart, lockend, &cached_state); err: -if (dio_data) { -btrfs_delalloc_release_space (BTRFS_I (inode), - dio_data->data_reserved, start, - dio_data->reserve, true); -btrfs_delalloc_release_extents (BTRFS_I (inode), dio_data->reserve); -extent_changeset_free (dio_data->data_reserved); -kfree (dio_data); - } +kfree (dio_data); +return ret; }
@@ -8018,14 +8038,8 @@ static int btrfs_dio_iomap_end(struct in ret = -ENOTBLK ; } -if (write) { -if (dio_data->reserve) -btrfs_delalloc_release_space (BTRFS_I (inode), - dio_data->data_reserved, pos, - dio_data->reserve, true); -btrfs_delalloc_release_extents (BTRFS_I (inode), dio_data->length); +if (write)extent_changeset_free (dio_data->data_reserved); - } out:kfree (dio_data); iomap->private =NULL ;
Greg Kroah-Hartman
maintainerPATCH 173/262 mac80211: fix forwarded mesh frames AC & queue selection
In reply to Greg Kroah-HartmanFrom: Nicolas Escande <[email protected]>
commit 859ae7018316daa4adbc496012dcbbb458d7e510 upstream.
There are two problems with the current code that have been highlighted with the AQL feature that is now enbaled by default.
First problem is in ieee80211_rx_h_mesh_fwding(), ieee80211_select_queue_80211() is used on received packets to choose the sending AC queue of the forwarding packet although this function should only be called on TX packet (it uses ieee80211_tx_info). This ends with forwarded mesh packets been sent on unrelated random AC queue. To fix that, AC queue can directly be infered from skb->priority which has been extracted from QOS info (see ieee80211_parse_qos()).
Second problem is the value of queue_mapping set on forwarded mesh frames via skb_set_queue_mapping() is not the AC of the packet but a hardware queue index. This may or may not work depending on AC to HW queue mapping which is driver specific.
Both of these issues lead to improper AC selection while forwarding mesh packets but more importantly due to improper airtime accounting (which is done on a per STA, per AC basis) caused traffic stall with the introduction of AQL.
--- net/mac80211/rx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/mac80211/rx.c +2 -2
@@ -2918,13 +2918,13 @@ ieee80211_rx_h_mesh_fwding(struct ieee80 ether_addr_equal(sdata->vif.addr, hdr->addr3))return RX_CONTINUE ; - ac =ieee80211_select_queue_80211 (sdata, skb, hdr); + ac = ieee802_1d_to_ac[skb->priority]; q = sdata->vif.hw_queue[ac];if (ieee80211_queue_stopped (&local->hw, q)) {IEEE80211_IFSTA_MESH_CTR_INC (ifmsh, dropped_frames_congestion);return RX_DROP_MONITOR ; } -skb_set_queue_mapping (skb, q); +skb_set_queue_mapping (skb, ac);if (!--mesh_hdr->ttl) {if (!is_multicast_ether_addr (hdr->addr1))
Greg Kroah-Hartman
maintainerPATCH 174/262 net: stmmac: fix return value of __setup handler
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
commit e01b042e580f1fbf4fd8da467442451da00c7a90 upstream.
__setup() handlers should return 1 on success, i.e., the parameter has been handled. A return of 0 causes the "option=value" string to be added to init's environment strings, polluting it.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +3 -3
@@ -7336,7 +7336,7 @@ static int __init stmmac_cmdline_opt(chachar *opt;if (!str || !*str) -return -EINVAL ; +return 1 ;while ((opt =strsep (&str,"," )) !=NULL ) {if (!strncmp (opt,"debug:" ,6 )) {if (kstrtoint (opt +6 ,0 , &debug))
@@ -7367,11 +7367,11 @@ static int __init stmmac_cmdline_opt(cha goto err; } } -return 0 ; +return 1 ; err:pr_err ("%s: ERROR broken module parameter conversion" , __func__); -return -EINVAL ; +return 1 ; }__setup ("stmmaceth=" , stmmac_cmdline_opt);
Greg Kroah-Hartman
maintainerPATCH 175/262 mac80211: treat some SAE auth steps as final
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
commit 94d9864cc86f572f881db9b842a78e9d075493ae upstream.
When we get anti-clogging token required (added by the commit mentioned below), or the other status codes added by the later commit 4e56cde15f7d ("mac80211: Handle special status codes in SAE commit") we currently just pretend (towards the internal state machine of authentication) that we didn't receive anything.
This has the undesirable consequence of retransmitting the prior frame, which is not expected, because the timer is still armed.
If we just disarm the timer at that point, it would result in the undesirable side effect of being in this state indefinitely if userspace crashes, or so.
So to fix this, reset the timer and set a new auth_data->waiting in order to have no more retransmissions, but to have the data destroyed when the timer actually fires, which will only happen if userspace didn't continue (i.e. crashed or abandoned it.)
--- net/mac80211/ieee80211_i.h | 2 +- net/mac80211/mlme.c | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-)
net/mac80211/ieee80211_i.h +1 -1
@@ -376,7 +376,7 @@ struct ieee80211_mgd_auth_data {u8 key[WLAN_KEY_LEN_WEP104 ];u8 key_len, key_idx; -bool done; +bool done, waiting;bool peer_confirmed;bool timeout_started;
net/mac80211/mlme.c +12 -4
@@ -37,6 +37,7 @@#define IEEE80211_AUTH_TIMEOUT_SAE (HZ * 2)#define IEEE80211_AUTH_MAX_TRIES 3#define IEEE80211_AUTH_WAIT_ASSOC (HZ * 5) +#define IEEE80211_AUTH_WAIT_SAE_RETRY (HZ * 2)#define IEEE80211_ASSOC_TIMEOUT (HZ / 5)#define IEEE80211_ASSOC_TIMEOUT_LONG (HZ / 2)#define IEEE80211_ASSOC_TIMEOUT_SHORT (HZ / 10)
@@ -2994,8 +2995,15 @@ static void ieee80211_rx_mgmt_auth(struc (status_code ==WLAN_STATUS_ANTI_CLOG_REQUIRED || (auth_transaction ==1 && (status_code ==WLAN_STATUS_SAE_HASH_TO_ELEMENT || - status_code == WLAN_STATUS_SAE_PK)))) + status_code == WLAN_STATUS_SAE_PK)))) { + /* waiting for userspace now */ + ifmgd->auth_data->waiting = true; + ifmgd->auth_data->timeout = + jiffies +IEEE80211_AUTH_WAIT_SAE_RETRY ; + ifmgd->auth_data->timeout_started = true; +run_again (sdata, ifmgd->auth_data->timeout); goto notify_driver; + }sdata_info (sdata,"%pM denied authentication (status %d)\n" , mgmt->sa, status_code);
@@ -4557,10 +4565,10 @@ void ieee80211_sta_work(struct ieee80211if (ifmgd->auth_data && ifmgd->auth_data->timeout_started &&time_after (jiffies, ifmgd->auth_data->timeout)) { -if (ifmgd->auth_data->done) { +if (ifmgd->auth_data->done || ifmgd->auth_data->waiting) {/* -* ok ... we waited for assoc but userspace didn't, -* so let's just kill the auth data +* ok ... we waited for assoc or continuation but +* userspace didn't do it, so kill the auth data */ ieee80211_destroy_auth_data (sdata, false); }else if (ieee80211_auth (sdata)) {
Greg Kroah-Hartman
maintainerPATCH 176/262 iavf: Fix missing check for running netdev
In reply to Greg Kroah-HartmanFrom: Slawomir Laba <[email protected]>
commit d2c0f45fcceb0995f208c441d9c9a453623f9ccf upstream.
The driver was queueing reset_task regardless of the netdev state.
Do not queue the reset task in iavf_change_mtu if netdev is not running.
--- drivers/net/ethernet/intel/iavf/iavf_main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +5 -2
@@ -3373,8 +3373,11 @@ static int iavf_change_mtu(struct net_deiavf_notify_client_l2_params (&adapter->vsi); adapter->flags |=IAVF_FLAG_SERVICE_CLIENT_REQUESTED ; } - adapter->flags |=IAVF_FLAG_RESET_NEEDED ; -queue_work (iavf_wq, &adapter->reset_task); + +if (netif_running (netdev)) { + adapter->flags |=IAVF_FLAG_RESET_NEEDED ; +queue_work (iavf_wq, &adapter->reset_task); + }return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 177/262 net: sxgbe: fix return value of __setup handler
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
commit 50e06ddceeea263f57fe92baa677c638ecd65bb6 upstream.
__setup() handlers should return 1 on success, i.e., the parameter has been handled. A return of 0 causes the "option=value" string to be added to init's environment strings, polluting it.
--- drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c +3 -3
@@ -2282,18 +2282,18 @@ static int __init sxgbe_cmdline_opt(charchar *opt;if (!str || !*str) -return -EINVAL ; +return 1 ;while ((opt =strsep (&str,"," )) !=NULL ) {if (!strncmp (opt,"eee_timer:" ,10 )) {if (kstrtoint (opt +10 ,0 , &eee_timer)) goto err; } } -return 0 ; +return 1 ; err:pr_err ("%s: ERROR broken module parameter conversion\n" , __func__); -return -EINVAL ; +return 1 ; }__setup ("sxgbeeth=" , sxgbe_cmdline_opt);
Greg Kroah-Hartman
maintainerPATCH 178/262 ibmvnic: register netdev after init of adapter
In reply to Greg Kroah-HartmanFrom: Sukadev Bhattiprolu <[email protected]>
commit 570425f8c7c18b14fa8a2a58a0adb431968ad118 upstream.
Finish initializing the adapter before registering netdev so state is consistent.
--- drivers/net/ethernet/ibm/ibmvnic.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/net/ethernet/ibm/ibmvnic.c +8 -6
@@ -5632,12 +5632,6 @@ static int ibmvnic_probe(struct vio_dev goto ibmvnic_dev_file_err;netif_carrier_off (netdev); - rc =register_netdev (netdev); -if (rc) { -dev_err (&dev->dev,"failed to register netdev rc=%d\n" , rc); - goto ibmvnic_register_fail; - } -dev_info (&dev->dev,"ibmvnic registered\n" );if (init_success) { adapter->state =VNIC_PROBED ;
@@ -5650,6 +5644,14 @@ static int ibmvnic_probe(struct vio_dev adapter->wait_for_reset = false; adapter->last_reset_time = jiffies; + + rc =register_netdev (netdev); +if (rc) { +dev_err (&dev->dev,"failed to register netdev rc=%d\n" , rc); + goto ibmvnic_register_fail; + } +dev_info (&dev->dev,"ibmvnic registered\n" ); +return 0 ; ibmvnic_register_fail:
Greg Kroah-Hartman
maintainerPATCH 179/262 net: arcnet: com20020: Fix null-ptr-deref in com20020pci_probe()
In reply to Greg Kroah-HartmanFrom: Zheyu Ma <[email protected]>
commit bd6f1fd5d33dfe5d1b4f2502d3694a7cc13f166d upstream.
During driver initialization, the pointer of card info, i.e. the variable 'ci' is required. However, the definition of 'com20020pci_id_table' reveals that this field is empty for some devices, which will cause null pointer dereference when initializing these devices.
The following log reveals it:
[ 3.973806] KASAN: null-ptr-deref in range [0x0000000000000028-0x000000000000002f] [ 3.973819] RIP: 0010:com20020pci_probe+0x18d/0x13e0 [com20020_pci] [ 3.975181] Call Trace: [ 3.976208] local_pci_probe+0x13f/0x210 [ 3.977248] pci_device_probe+0x34c/0x6d0 [ 3.977255] ? pci_uevent+0x470/0x470 [ 3.978265] really_probe+0x24c/0x8d0 [ 3.978273] __driver_probe_device+0x1b3/0x280 [ 3.979288] driver_probe_device+0x50/0x370
Fix this by checking whether the 'ci' is a null pointer first.
--- drivers/net/arcnet/com20020-pci.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/arcnet/com20020-pci.c +3 -0
@@ -138,6 +138,9 @@ static int com20020pci_probe(struct pci_return -ENOMEM ; ci = (struct com20020_pci_card_info *)id->driver_data; +if (!ci) +return -EINVAL ; + priv->ci = ci; mm = &ci->misc_map;
Greg Kroah-Hartman
maintainerPATCH 180/262 ixgbe: xsk: change !netif_carrier_ok() handling in ixgbe_xmit_zc()
In reply to Greg Kroah-HartmanFrom: Maciej Fijalkowski <[email protected]>
commit 6c7273a266759d9d36f7c862149f248bcdeddc0f upstream.
Commit c685c69fba71 ("ixgbe: don't do any AF_XDP zero-copy transmit if netif is not OK") addressed the ring transient state when MEM_TYPE_XSK_BUFF_POOL was being configured which in turn caused the interface to through down/up. Maurice reported that when carrier is not ok and xsk_pool is present on ring pair, ksoftirqd will consume 100% CPU cycles due to the constant NAPI rescheduling as ixgbe_poll() states that there is still some work to be done.
To fix this, do not set work_done to false for a !netif_carrier_ok().
--- drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c +4 -2
@@ -388,12 +388,14 @@ static bool ixgbe_xmit_zc(struct ixgbe_ru32 cmd_type;while (budget-- >0 ) { -if (unlikely (!ixgbe_desc_unused (xdp_ring)) || - !netif_carrier_ok (xdp_ring->netdev)) { +if (unlikely (!ixgbe_desc_unused (xdp_ring))) { work_done = false;break ; } +if (!netif_carrier_ok (xdp_ring->netdev)) +break ; +if (!xsk_tx_peek_desc (pool, &desc))break ;
Greg Kroah-Hartman
maintainerPATCH 181/262 iavf: Fix deadlock in iavf_reset_task
In reply to Greg Kroah-HartmanFrom: Slawomir Laba <[email protected]>
commit e85ff9c631e1bf109ce8428848dfc8e8b0041f48 upstream.
There exists a missing mutex_unlock call on crit_lock in iavf_reset_task call path.
Unlock the crit_lock before returning from reset task.
--- drivers/net/ethernet/intel/iavf/iavf_main.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/intel/iavf/iavf_main.c +1 -0
@@ -2206,6 +2206,7 @@ static void iavf_reset_task(struct work_ reg_val);iavf_disable_vf (adapter);mutex_unlock (&adapter->client_lock); +mutex_unlock (&adapter->crit_lock);return ;/* Do not attempt to reinit. It's dead, Jim. */ }
Greg Kroah-Hartman
maintainerPATCH 182/262 efivars: Respect "block" flag in efivar_entry_set_safe()
In reply to Greg Kroah-HartmanFrom: Jann Horn <[email protected]>
commit 258dd902022cb10c83671176688074879517fd21 upstream.
When the "block" flag is false, the old code would sometimes still call check_var_size(), which wrongly tells ->query_variable_store() that it can block.
As far as I can tell, this can't really materialize as a bug at the moment, because ->query_variable_store only does something on X86 with generic EFI, and in that configuration we always take the efivar_entry_set_nonblocking() path.
--- drivers/firmware/efi/vars.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/firmware/efi/vars.c +4 -1
@@ -742,6 +742,7 @@ int efivar_entry_set_safe(efi_char16_t * {const struct efivar_operations *ops;efi_status_t status; +unsigned long varsize;if (!__efivars)return -EINVAL ;
@@ -764,15 +765,17 @@ int efivar_entry_set_safe(efi_char16_t *return efivar_entry_set_nonblocking (name, vendor, attributes, size, data); + varsize = size +ucs2_strsize (name,1024 );if (!block) {if (down_trylock (&efivars_lock))return -EBUSY ; + status =check_var_size_nonblocking (attributes, varsize); }else {if (down_interruptible (&efivars_lock))return -EINTR ; + status =check_var_size (attributes, varsize); } - status =check_var_size (attributes, size +ucs2_strsize (name,1024 ));if (status !=EFI_SUCCESS ) {up (&efivars_lock);return -ENOSPC ;
Greg Kroah-Hartman
maintainerPATCH 183/262 auxdisplay: lcd2s: Fix lcd2s_redefine_char() feature
In reply to Greg Kroah-HartmanFrom: Andy Shevchenko <[email protected]>
commit 4424c35ead667ba2e8de7ab8206da66453e6f728 upstream.
It seems that the lcd2s_redefine_char() has never been properly tested. The buffer is filled by DEF_CUSTOM_CHAR command followed by the character number (from 0 to 7), but immediately after that these bytes are rewritten by the decoded hex stream.
Fix the index to fill the buffer after the command and number.
--- drivers/auxdisplay/lcd2s.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/auxdisplay/lcd2s.c +1 -1
@@ -238,7 +238,7 @@ static int lcd2s_redefine_char(struct chif (buf[1 ] >7 )return 1 ; - i =0 ; + i =2 ; shift =0 ; value =0 ;while (*esc && i <LCD2S_CHARACTER_SIZE +2 ) {
Greg Kroah-Hartman
maintainerPATCH 184/262 firmware: arm_scmi: Remove space in MODULE_ALIAS name
In reply to Greg Kroah-HartmanFrom: Alyssa Ross <[email protected]>
commit 1ba603f56568c3b4c2542dfba07afa25f21dcff3 upstream.
modprobe can't handle spaces in aliases. Get rid of it to fix the issue.
--- drivers/firmware/arm_scmi/driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/arm_scmi/driver.c +1 -1
@@ -2112,7 +2112,7 @@ static void __exit scmi_driver_exit(void }module_exit (scmi_driver_exit); -MODULE_ALIAS ("platform: arm-scmi" ); +MODULE_ALIAS ("platform:arm-scmi" );MODULE_AUTHOR ("Sudeep Holla <[email protected]>" );MODULE_DESCRIPTION ("ARM SCMI protocol driver" );MODULE_LICENSE ("GPL v2" );
Greg Kroah-Hartman
maintainerPATCH 185/262 ASoC: cs4265: Fix the duplicated control name
In reply to Greg Kroah-HartmanFrom: Fabio Estevam <[email protected]>
commit c5487b9cdea5c1ede38a7ec94db0fc59963c8e86 upstream.
Currently, the following error messages are seen during boot:
asoc-simple-card sound: control 2:0:0:SPDIF Switch:0 is already present cs4265 1-004f: ASoC: failed to add widget SPDIF dapm kcontrol SPDIF Switch: -16
Quoting Mark Brown:
"The driver is just plain buggy, it defines both a regular SPIDF Switch control and a SND_SOC_DAPM_SWITCH() called SPDIF both of which will create an identically named control, it can never have loaded without error. One or both of those has to be renamed or they need to be merged into one thing."
Fix the duplicated control name by combining the two SPDIF controls here and move the register bits onto the DAPM widget and have DAPM control them.
--- sound/soc/codecs/cs4265.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
sound/soc/codecs/cs4265.c +1 -2
@@ -150,7 +150,6 @@ static const struct snd_kcontrol_new cs4SOC_SINGLE ("E to F Buffer Disable Switch" ,CS4265_SPDIF_CTL1 ,6 ,1 ,0 ),SOC_ENUM ("C Data Access" , cam_mode_enum), -SOC_SINGLE ("SPDIF Switch" ,CS4265_SPDIF_CTL2 ,5 ,1 ,1 ),SOC_SINGLE ("Validity Bit Control Switch" ,CS4265_SPDIF_CTL2 ,3 ,1 ,0 ), SOC_ENUM("SPDIF Mono/Stereo", spdif_mono_stereo_enum),
@@ -186,7 +185,7 @@ static const struct snd_soc_dapm_widgetSND_SOC_DAPM_SWITCH ("Loopback" ,SND_SOC_NOPM ,0 ,0 , &loopback_ctl), -SND_SOC_DAPM_SWITCH ("SPDIF" ,SND_SOC_NOPM ,0 ,0 , +SND_SOC_DAPM_SWITCH ("SPDIF" ,CS4265_SPDIF_CTL2 ,5 ,1 , &spdif_switch),SND_SOC_DAPM_SWITCH ("DAC" ,CS4265_PWRCTL ,1 ,1 , &dac_switch),
Greg Kroah-Hartman
maintainerPATCH 186/262 auxdisplay: lcd2s: Fix memory leak in ->remove()
In reply to Greg Kroah-HartmanFrom: Andy Shevchenko <[email protected]>
commit 898c0a15425a5bcaa8d44bd436eae5afd2483796 upstream.
Once allocated the struct lcd2s_data is never freed. Fix the memory leak by switching to devm_kzalloc().
--- drivers/auxdisplay/lcd2s.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)
drivers/auxdisplay/lcd2s.c +7 -11
@@ -298,6 +298,10 @@ static int lcd2s_i2c_probe(struct i2c_cl I2C_FUNC_SMBUS_WRITE_BLOCK_DATA))return -EIO ; + lcd2s =devm_kzalloc (&i2c->dev,sizeof (*lcd2s),GFP_KERNEL ); +if (!lcd2s) +return -ENOMEM ; +/* Test, if the display is responding */ err =lcd2s_i2c_smbus_write_byte (i2c,LCD2S_CMD_DISPLAY_OFF );if (err <0 )
@@ -307,12 +311,6 @@ static int lcd2s_i2c_probe(struct i2c_clif (!lcd)return -ENOMEM ; - lcd2s =kzalloc (sizeof (struct lcd2s_data ),GFP_KERNEL ); -if (!lcd2s) { - err = -ENOMEM ; - goto fail1; - } - lcd->drvdata = lcd2s; lcd2s->i2c = i2c; lcd2s->charlcd = lcd;
@@ -321,24 +319,22 @@ static int lcd2s_i2c_probe(struct i2c_cl err =device_property_read_u32 (&i2c->dev,"display-height-chars" , &lcd->height);if (err) - goto fail2; + goto fail1; err =device_property_read_u32 (&i2c->dev,"display-width-chars" , &lcd->width);if (err) - goto fail2; + goto fail1; lcd->ops = &lcd2s_ops; err =charlcd_register (lcd2s->charlcd);if (err) - goto fail2; + goto fail1;i2c_set_clientdata (i2c, lcd2s);return 0 ; -fail2: -kfree (lcd2s); fail1:kfree (lcd);return err;
Greg Kroah-Hartman
maintainerPATCH 187/262 auxdisplay: lcd2s: Use proper API to free the instance of charlcd object
In reply to Greg Kroah-HartmanFrom: Andy Shevchenko <[email protected]>
commit 9ed331f8a0fb674f4f06edf05a1687bf755af27b upstream.
While it might work, the current approach is fragile in a few ways:
- whenever members in the structure are shuffled, the pointer will be wrong
- the resource freeing may include more than covered by kfree()
Fix this by using charlcd_free() call instead of kfree().
--- drivers/auxdisplay/lcd2s.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/auxdisplay/lcd2s.c +2 -2
@@ -336,7 +336,7 @@ static int lcd2s_i2c_probe(struct i2c_clreturn 0 ; fail1: -kfree (lcd); +charlcd_free (lcd2s->charlcd);return err; }
@@ -345,7 +345,7 @@ static int lcd2s_i2c_remove(struct i2c_cstruct lcd2s_data *lcd2s =i2c_get_clientdata (i2c);charlcd_unregister (lcd2s->charlcd); -kfree (lcd2s->charlcd); +charlcd_free (lcd2s->charlcd);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 188/262 can: gs_usb: change active_channelss type from atomic_t to u8
In reply to Greg Kroah-HartmanFrom: Vincent Mailhol <[email protected]>
commit 035b0fcf02707d3c9c2890dc1484b11aa5335eb1 upstream.
The driver uses an atomic_t variable: gs_usb:active_channels to keep track of the number of opened channels in order to only allocate memory for the URBs when this count changes from zero to one.
However, the driver does not decrement the counter when an error occurs in gs_can_open(). This issue is fixed by changing the type from atomic_t to u8 and by simplifying the logic accordingly.
It is safe to use an u8 here because the network stack big kernel lock (a.k.a. rtnl_mutex) is being hold. For details, please refer to [1].
--- drivers/net/can/usb/gs_usb.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/can/usb/gs_usb.c +5 -5
@@ -191,8 +191,8 @@ struct gs_can {struct gs_usb {struct gs_can *canch[GS_MAX_INTF ];struct usb_anchor rx_submitted; -atomic_t active_channels;struct usb_device *udev; +u8 active_channels; };/* 'allocate' a tx context.
@@ -590,7 +590,7 @@ static int gs_can_open(struct net_deviceif (rc)return rc; -if (atomic_add_return (1 , &parent->active_channels) ==1 ) { +if (!parent->active_channels) {for (i =0 ; i <GS_MAX_RX_URBS ; i++) {struct urb *urb;u8 *buf;
@@ -691,6 +691,7 @@ static int gs_can_open(struct net_device dev->can.state =CAN_STATE_ERROR_ACTIVE ; + parent->active_channels++;if (!(dev->can.ctrlmode &CAN_CTRLMODE_LISTENONLY ))netif_start_queue (netdev);
@@ -706,7 +707,8 @@ static int gs_can_close(struct net_devicnetif_stop_queue (netdev);/* Stop polling */ -if (atomic_dec_and_test (&parent->active_channels)) + parent->active_channels--; +if (!parent->active_channels)usb_kill_anchored_urbs (&parent->rx_submitted);/* Stop sending URBs */
@@ -985,8 +987,6 @@ static int gs_usb_probe(struct usb_interinit_usb_anchor (&dev->rx_submitted); -atomic_set (&dev->active_channels,0 ); -usb_set_intfdata (intf, dev); dev->udev =interface_to_usbdev (intf);
Greg Kroah-Hartman
maintainerPATCH 189/262 iommu/tegra-smmu: Fix missing put_device() call in tegra_smmu_find
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
commit 9826e393e4a8c3df474e7f9eacd3087266f74005 upstream.
The reference taken by 'of_find_device_by_node()' must be released when not needed anymore.
Add the corresponding 'put_device()' in the error handling path.
--- drivers/iommu/tegra-smmu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iommu/tegra-smmu.c +3 -1
@@ -808,8 +808,10 @@ static struct tegra_smmu *tegra_smmu_finreturn NULL ; mc =platform_get_drvdata (pdev); -if (!mc) +if (!mc) { +put_device (&pdev->dev);return NULL ; + }return mc->smmu; }
Greg Kroah-Hartman
maintainerPATCH 190/262 arm64: dts: rockchip: Switch RK3399-Gru DP to SPDIF output
In reply to Greg Kroah-HartmanFrom: Brian Norris <[email protected]>
commit b5fbaf7d779f5f02b7f75b080e7707222573be2a upstream.
Commit b18c6c3c7768 ("ASoC: rockchip: cdn-dp sound output use spdif") switched the platform to SPDIF, but we didn't fix up the device tree.
Drop the pinctrl settings, because the 'spdif_bus' pins are either:
* unused (on kevin, bob), so the settings is ~harmless
* used by a different function (on scarlet), which causes probe failures (!!)
--- arch/arm64/boot/dts/rockchip/rk3399-gru.dtsi | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
arch/arm64/boot/dts/rockchip/rk3399-gru.dtsi +12 -5
@@ -286,7 +286,7 @@ sound: sound { compatible = "rockchip,rk3399-gru-sound"; - rockchip,cpu = <&i2s0 &i2s2>; + rockchip,cpu = <&i2s0 &spdif>; }; };
@@ -437,10 +437,6 @@ ap_i2c_audio: &i2c8 { status = "okay"; }; -&i2s2 { - status = "okay"; -}; - &io_domains { status = "okay";
@@ -537,6 +533,17 @@ ap_i2c_audio: &i2c8 { vqmmc-supply = <&ppvar_sd_card_io>; }; +&spdif { + status = "okay"; + + /* + * SPDIF is routed internally to DP; we either don't use these pins, or + * mux them to something else. + */ + /delete-property/ pinctrl-0; + /delete-property/ pinctrl-names; +}; + &spi1 { status = "okay";
Greg Kroah-Hartman
maintainerPATCH 191/262 igc: igc_read_phy_reg_gpy: drop premature return
In reply to Greg Kroah-HartmanFrom: Corinna Vinschen <[email protected]>
commit fda2635466cd26ad237e1bc5d3f6a60f97ad09b6 upstream.
igc_read_phy_reg_gpy checks the return value from igc_read_phy_reg_mdic and if it's not 0, returns immediately. By doing this, it leaves the HW semaphore in the acquired state.
Drop this premature return statement, the function returns after releasing the semaphore immediately anyway.
--- drivers/net/ethernet/intel/igc/igc_phy.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/ethernet/intel/igc/igc_phy.c +0 -2
@@ -779,8 +779,6 @@ s32 igc_read_phy_reg_gpy(struct igc_hw *if (ret_val)return ret_val; ret_val =igc_read_phy_reg_mdic (hw, offset, data); -if (ret_val) -return ret_val; hw->phy.ops.release (hw); }else { ret_val = igc_read_xmdio_reg(hw, (u16)offset, dev_addr,
Greg Kroah-Hartman
maintainerPATCH 192/262 ARM: Fix kgdb breakpoint for Thumb2
In reply to Greg Kroah-HartmanFrom: Russell King (Oracle) <[email protected]>
commit d920eaa4c4559f59be7b4c2d26fa0a2e1aaa3da9 upstream.
The kgdb code needs to register an undef hook for the Thumb UDF instruction that will fault in order to be functional on Thumb2 platforms.
--- arch/arm/kernel/kgdb.c | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-)
arch/arm/kernel/kgdb.c +28 -8
@@ -154,22 +154,38 @@ static int kgdb_compiled_brk_fn(struct preturn 0 ; } -static struct undef_hook kgdb_brkpt_hook = { +static struct undef_hook kgdb_brkpt_arm_hook = { .instr_mask =0xffffffff , .instr_val =KGDB_BREAKINST , - .cpsr_mask =MODE_MASK , + .cpsr_mask =PSR_T_BIT |MODE_MASK , .cpsr_val =SVC_MODE , .fn = kgdb_brk_fn }; -static struct undef_hook kgdb_compiled_brkpt_hook = { +static struct undef_hook kgdb_brkpt_thumb_hook = { + .instr_mask =0xffff , + .instr_val =KGDB_BREAKINST &0xffff , + .cpsr_mask =PSR_T_BIT |MODE_MASK , + .cpsr_val =PSR_T_BIT |SVC_MODE , + .fn = kgdb_brk_fn +}; + +static struct undef_hook kgdb_compiled_brkpt_arm_hook = { .instr_mask =0xffffffff , .instr_val =KGDB_COMPILED_BREAK , - .cpsr_mask =MODE_MASK , + .cpsr_mask =PSR_T_BIT |MODE_MASK , .cpsr_val =SVC_MODE , .fn = kgdb_compiled_brk_fn }; +static struct undef_hook kgdb_compiled_brkpt_thumb_hook = { + .instr_mask =0xffff , + .instr_val =KGDB_COMPILED_BREAK &0xffff , + .cpsr_mask =PSR_T_BIT |MODE_MASK , + .cpsr_val =PSR_T_BIT |SVC_MODE , + .fn = kgdb_compiled_brk_fn +}; +static int __kgdb_notify (struct die_args *args,unsigned long cmd) {struct pt_regs *regs = args->regs;
@@ -210,8 +226,10 @@ int kgdb_arch_init(void)if (ret !=0 )return ret; -register_undef_hook (&kgdb_brkpt_hook); -register_undef_hook (&kgdb_compiled_brkpt_hook); +register_undef_hook (&kgdb_brkpt_arm_hook); +register_undef_hook (&kgdb_brkpt_thumb_hook); +register_undef_hook (&kgdb_compiled_brkpt_arm_hook); +register_undef_hook (&kgdb_compiled_brkpt_thumb_hook);return 0 ; }
@@ -224,8 +242,10 @@ int kgdb_arch_init(void)*/ void kgdb_arch_exit (void ) { -unregister_undef_hook (&kgdb_brkpt_hook); -unregister_undef_hook (&kgdb_compiled_brkpt_hook); +unregister_undef_hook (&kgdb_brkpt_arm_hook); +unregister_undef_hook (&kgdb_brkpt_thumb_hook); +unregister_undef_hook (&kgdb_compiled_brkpt_arm_hook); +unregister_undef_hook (&kgdb_compiled_brkpt_thumb_hook);unregister_die_notifier (&kgdb_notifier); }
Greg Kroah-Hartman
maintainerPATCH 193/262 mips: setup: fix setnocoherentio() boolean setting
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
commit 1e6ae0e46e32749b130f1823da30cea9aa2a59a0 upstream.
Correct a typo/pasto: setnocoherentio() should set dma_default_coherent to false, not true.
--- arch/mips/kernel/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/kernel/setup.c +1 -1
@@ -803,7 +803,7 @@ early_param("coherentio", setcoherentio)static int __init setnocoherentio (char *str) { - dma_default_coherent = true; + dma_default_coherent = false;pr_info ("Software DMA cache coherency (command line)\n" );return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 194/262 ARM: 9182/1: mmu: fix returns from early_param() and __setup() functions
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
commit 7b83299e5b9385943a857d59e15cba270df20d7e upstream.
early_param() handlers should return 0 on success. __setup() handlers should return 1 on success, i.e., the parameter has been handled. A return of 0 would cause the "option=value" string to be added to init's environment strings, polluting it.
../arch/arm/mm/mmu.c: In function 'test_early_cachepolicy':../arch/arm/mm/mmu.c:215:1: error: no return statement in function returning non-void [-Werror=return-type] ../arch/arm/mm/mmu.c: In function 'test_noalign_setup':../arch/arm/mm/mmu.c:221:1: error: no return statement in function returning non-void [-Werror=return-type]
--- arch/arm/mm/mmu.c | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/mm/mmu.c +2 -0
@@ -212,12 +212,14 @@ early_param("ecc", early_ecc);static int __init early_cachepolicy (char *p) {pr_warn ("cachepolicy kernel parameter not supported without cp15\n" ); +return 0 ; }early_param ("cachepolicy" , early_cachepolicy);static int __init noalign_setup (char *__unused) {pr_warn ("noalign kernel parameter not supported without cp15\n" ); +return 1 ; }__setup ("noalign" , noalign_setup);
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Greg Kroah-Hartman
maintainerPATCH 195/262 mptcp: Correctly set DATA_FIN timeout when number of retransmits is large
In reply to Greg Kroah-HartmanFrom: Mat Martineau <[email protected]>
commit 877d11f0332cd2160e19e3313e262754c321fa36 upstream.
Syzkaller with UBSAN uncovered a scenario where a large number of DATA_FIN retransmits caused a shift-out-of-bounds in the DATA_FIN timeout calculation:
================================================================================
UBSAN: shift-out-of-bounds in net/mptcp/protocol.c:470:29 shift exponent 32 is too large for 32-bit type 'unsigned int' CPU: 1 PID: 13059 Comm: kworker/1:0 Not tainted 5.17.0-rc2-00630-g5fbf21c90c60 #1 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014 Workqueue: events mptcp_worker Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106 ubsan_epilogue+0xb/0x5a lib/ubsan.c:151 __ubsan_handle_shift_out_of_bounds.cold+0xb2/0x20e lib/ubsan.c:330 mptcp_set_datafin_timeout net/mptcp/protocol.c:470 [inline] __mptcp_retrans.cold+0x72/0x77 net/mptcp/protocol.c:2445 mptcp_worker+0x58a/0xa70 net/mptcp/protocol.c:2528 process_one_work+0x9df/0x16d0 kernel/workqueue.c:2307 worker_thread+0x95/0xe10 kernel/workqueue.c:2454 kthread+0x2f4/0x3b0 kernel/kthread.c:377 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295 </TASK> ================================================================================
This change limits the maximum timeout by limiting the size of the shift, which keeps all intermediate values in-bounds.
--- net/mptcp/protocol.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
net/mptcp/protocol.c +5 -2
@@ -406,9 +406,12 @@ static bool mptcp_pending_data_fin(strucstatic void mptcp_set_datafin_timeout (const struct sock *sk) {struct inet_connection_sock *icsk =inet_csk (sk); +u32 retransmits; -mptcp_sk (sk)->timer_ival =min (TCP_RTO_MAX , -TCP_RTO_MIN << icsk->icsk_retransmits); + retransmits =min_t (u32, icsk->icsk_retransmits, +ilog2 (TCP_RTO_MAX /TCP_RTO_MIN )); + +mptcp_sk (sk)->timer_ival =TCP_RTO_MIN << retransmits; }static void __mptcp_set_timeout (struct sock *sk,long tout)
Greg Kroah-Hartman
maintainerPATCH 196/262 selftests: mlxsw: tc_police_scale: Make test more robust
In reply to Greg Kroah-HartmanFrom: Amit Cohen <[email protected]>
commit dc9752075341e7beb653e37c6f4a3723074dc8bc upstream.
The test adds tc filters and checks how many of them were offloaded by grepping for 'in_hw'.
iproute2 commit f4cd4f127047 ("tc: add skip_hw and skip_sw to control action offload") added offload indication to tc actions, producing the following output:
$ tc filter show dev swp2 ingress
...
filter protocol ipv6 pref 1000 flower chain 0 handle 0x7c0
eth_type ipv6
dst_ip 2001:db8:1::7bf
skip_sw
in_hw in_hw_count 1
action order 1: police 0x7c0 rate 10Mbit burst 100Kb mtu 2Kb action drop overhead 0b
ref 1 bind 1
not_in_hw
used_hw_stats immediateThe current grep expression matches on both 'in_hw' and 'not_in_hw', resulting in incorrect results.
Fix that by using JSON output instead.
--- tools/testing/selftests/drivers/net/mlxsw/tc_police_scale.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/drivers/net/mlxsw/tc_police_scale.sh +2 -1
@@ -60,7 +60,8 @@ __tc_police_test() tc_police_rules_create $count $should_fail - offload_count=$(tc filter show dev $swp1 ingress | grep in_hw | wc -l) + offload_count=$(tc -j filter show dev $swp1 ingress | + jq "[.[] | select(.options.in_hw == true)] | length") ((offload_count == count)) check_err_fail $should_fail $? "tc police offload count" }
Greg Kroah-Hartman
maintainerPATCH 197/262 pinctrl: sunxi: Use unique lockdep classes for IRQs
In reply to Greg Kroah-HartmanFrom: Samuel Holland <[email protected]>
commit bac129dbc6560dfeb634c03f0c08b78024e71915 upstream.
This driver, like several others, uses a chained IRQ for each GPIO bank, and forwards .irq_set_wake to the GPIO bank's upstream IRQ. As a result, a call to irq_set_irq_wake() needs to lock both the upstream and downstream irq_desc's. Lockdep considers this to be a possible deadlock when the irq_desc's share lockdep classes, which they do by default:
============================================
WARNING: possible recursive locking detected 5.17.0-rc3-00394-gc849047c2473 #1 Not tainted
--------------------------------------------
init/307 is trying to acquire lock:
c2dfe27c (&irq_desc_lock_class){-.-.}-{2:2}, at: __irq_get_desc_lock+0x58/0xa0
but task is already holding lock:
c3c0ac7c (&irq_desc_lock_class){-.-.}-{2:2}, at: __irq_get_desc_lock+0x58/0xa0
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
---- lock(&irq_desc_lock_class);
lock(&irq_desc_lock_class);
*** DEADLOCK ***
May be due to missing lock nesting notation
4 locks held by init/307:
#0: c1f29f18 (system_transition_mutex){+.+.}-{3:3}, at: __do_sys_reboot+0x90/0x23c #1: c20f7760 (&dev->mutex){....}-{3:3}, at: device_shutdown+0xf4/0x224 #2: c2e804d8 (&dev->mutex){....}-{3:3}, at: device_shutdown+0x104/0x224 #3: c3c0ac7c (&irq_desc_lock_class){-.-.}-{2:2}, at: __irq_get_desc_lock+0x58/0xa0
stack backtrace:
CPU: 0 PID: 307 Comm: init Not tainted 5.17.0-rc3-00394-gc849047c2473 #1
Hardware name: Allwinner sun8i Family
unwind_backtrace from show_stack+0x10/0x14
show_stack from dump_stack_lvl+0x68/0x90
dump_stack_lvl from __lock_acquire+0x1680/0x31a0
__lock_acquire from lock_acquire+0x148/0x3dc
lock_acquire from _raw_spin_lock_irqsave+0x50/0x6c
_raw_spin_lock_irqsave from __irq_get_desc_lock+0x58/0xa0
__irq_get_desc_lock from irq_set_irq_wake+0x2c/0x19c
irq_set_irq_wake from irq_set_irq_wake+0x13c/0x19c
[tail call from sunxi_pinctrl_irq_set_wake]
irq_set_irq_wake from gpio_keys_suspend+0x80/0x1a4
gpio_keys_suspend from gpio_keys_shutdown+0x10/0x2c
gpio_keys_shutdown from device_shutdown+0x180/0x224
device_shutdown from __do_sys_reboot+0x134/0x23c
__do_sys_reboot from ret_fast_syscall+0x0/0x1cHowever, this can never deadlock because the upstream and downstream IRQs are never the same (nor do they even involve the same irqchip).
Silence this erroneous lockdep splat by applying what appears to be the usual fix of moving the GPIO IRQs to separate lockdep classes.
--- drivers/pinctrl/sunxi/pinctrl-sunxi.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/pinctrl/sunxi/pinctrl-sunxi.c +9 -0
@@ -36,6 +36,13 @@#include "../core.h" #include "pinctrl-sunxi.h" +/* +* These lock classes tell lockdep that GPIO IRQs are in a different +* category than their parents, so it won't report false recursion. +*/ +static struct lock_class_key sunxi_pinctrl_irq_lock_class; +static struct lock_class_key sunxi_pinctrl_irq_request_class; +static struct irq_chip sunxi_pinctrl_edge_irq_chip;static struct irq_chip sunxi_pinctrl_level_irq_chip;
@@ -1551,6 +1558,8 @@ int sunxi_pinctrl_init_with_variant(strufor (i =0 ; i < (pctl->desc->irq_banks *IRQ_PER_BANK ); i++) {int irqno =irq_create_mapping (pctl->domain, i); +irq_set_lockdep_class (irqno, &sunxi_pinctrl_irq_lock_class, + &sunxi_pinctrl_irq_request_class);irq_set_chip_and_handler (irqno, &sunxi_pinctrl_edge_irq_chip, handle_edge_irq);irq_set_chip_data (irqno, pctl);
Greg Kroah-Hartman
maintainerPATCH 198/262 igc: igc_write_phy_reg_gpy: drop premature return
In reply to Greg Kroah-HartmanFrom: Sasha Neftin <[email protected]>
commit c4208653a327a09da1e9e7b10299709b6d9b17bf upstream.
Similar to "igc_read_phy_reg_gpy: drop premature return" patch. igc_write_phy_reg_gpy checks the return value from igc_write_phy_reg_mdic and if it's not 0, returns immediately. By doing this, it leaves the HW semaphore in the acquired state.
Drop this premature return statement, the function returns after releasing the semaphore immediately anyway.
--- drivers/net/ethernet/intel/igc/igc_phy.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/ethernet/intel/igc/igc_phy.c +0 -2
@@ -746,8 +746,6 @@ s32 igc_write_phy_reg_gpy(struct igc_hwif (ret_val)return ret_val; ret_val =igc_write_phy_reg_mdic (hw, offset, data); -if (ret_val) -return ret_val; hw->phy.ops.release (hw); }else { ret_val = igc_write_xmdio_reg(hw, (u16)offset, dev_addr,
Greg Kroah-Hartman
maintainerPATCH 199/262 ibmvnic: free reset-work-item when flushing
In reply to Greg Kroah-HartmanFrom: Sukadev Bhattiprolu <[email protected]>
commit 8d0657f39f487d904fca713e0bc39c2707382553 upstream.
Fix a tiny memory leak when flushing the reset work queue.
--- drivers/net/ethernet/ibm/ibmvnic.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/ibm/ibmvnic.c +3 -1
@@ -2606,8 +2606,10 @@ static int ibmvnic_reset(struct ibmvnic_* flush reset queue and process this reset */ if (adapter->force_reset_recovery && !list_empty (&adapter->rwi_list)) { -list_for_each_safe (entry, tmp_entry, &adapter->rwi_list) +list_for_each_safe (entry, tmp_entry, &adapter->rwi_list) {list_del (entry); +kfree (list_entry(entry ,struct ibmvnic_rwi ,list )); + } } rwi->reset_reason = reason;list_add_tail (&rwi->list, &adapter->rwi_list);
Greg Kroah-Hartman
maintainerPATCH 200/262 memfd: fix F_SEAL_WRITE after shmem huge page allocated
In reply to Greg Kroah-HartmanFrom: Hugh Dickins <[email protected]>
commit f2b277c4d1c63a85127e8aa2588e9cc3bd21cb99 upstream.
Wangyong reports: after enabling tmpfs filesystem to support transparent hugepage with the following command:
echo always > /sys/kernel/mm/transparent_hugepage/shmem_enabled
the docker program tries to add F_SEAL_WRITE through the following command, but it fails unexpectedly with errno EBUSY:
fcntl(5, F_ADD_SEALS, F_SEAL_WRITE) = -1.
That is because memfd_tag_pins() and memfd_wait_for_pins() were never updated for shmem huge pages: checking page_mapcount() against page_count() is hopeless on THP subpages - they need to check total_mapcount() against page_count() on THP heads only.
Make memfd_tag_pins() (compared > 1) as strict as memfd_wait_for_pins() (compared != 1): either can be justified, but given the non-atomic total_mapcount() calculation, it is better now to be strict. Bear in mind that total_mapcount() itself scans all of the THP subpages, when choosing to take an XA_CHECK_SCHED latency break.
Also fix the unlikely xa_is_value() case in memfd_wait_for_pins(): if a page has been swapped out since memfd_tag_pins(), then its refcount must have fallen, and so it can safely be untagged.
--- mm/memfd.c | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-)
mm/memfd.c +28 -12
@@ -31,20 +31,28 @@static void memfd_tag_pins (struct xa_state *xas) {struct page *page; -unsigned int tagged =0 ; +int latency =0 ; +int cache_count;lru_add_drain ();xas_lock_irq (xas);xas_for_each (xas, page,ULONG_MAX ) { -if (xa_is_value (page)) -continue ; - page =find_subpage (page, xas->xa_index); -if (page_count (page) -page_mapcount (page) >1 ) + cache_count =1 ; +if (!xa_is_value (page) && +PageTransHuge (page) && !PageHuge (page)) + cache_count =HPAGE_PMD_NR ; + +if (!xa_is_value (page) && +page_count (page) -total_mapcount (page) != cache_count)xas_set_mark (xas,MEMFD_TAG_PINNED ); +if (cache_count !=1 ) +xas_set (xas, page->index + cache_count); -if (++tagged %XA_CHECK_SCHED ) + latency += cache_count; +if (latency <XA_CHECK_SCHED )continue ; + latency =0 ;xas_pause (xas);xas_unlock_irq (xas);
@@ -73,7 +81,8 @@ static int memfd_wait_for_pins(struct ad error =0 ;for (scan =0 ; scan <=LAST_SCAN ; scan++) { -unsigned int tagged =0 ; +int latency =0 ; +int cache_count;if (!xas_marked (&xas,MEMFD_TAG_PINNED ))break ;
@@ -87,10 +96,14 @@ static int memfd_wait_for_pins(struct adxas_lock_irq (&xas);xas_for_each_marked (&xas, page,ULONG_MAX ,MEMFD_TAG_PINNED ) {bool clear = true; -if (xa_is_value (page)) -continue ; - page =find_subpage (page, xas.xa_index); -if (page_count (page) -page_mapcount (page) !=1 ) { + + cache_count =1 ; +if (!xa_is_value (page) && +PageTransHuge (page) && !PageHuge (page)) + cache_count =HPAGE_PMD_NR ; + +if (!xa_is_value (page) && cache_count != +page_count (page) -total_mapcount (page)) {/* * On the last scan, we clean up all those tags * we inserted; but make a note that we still
@@ -103,8 +116,11 @@ static int memfd_wait_for_pins(struct ad }if (clear)xas_clear_mark (&xas,MEMFD_TAG_PINNED ); -if (++tagged %XA_CHECK_SCHED ) + + latency += cache_count; +if (latency <XA_CHECK_SCHED )continue ; + latency =0 ;xas_pause (&xas);xas_unlock_irq (&xas);
Greg Kroah-Hartman
maintainerPATCH 201/262 s390/extable: fix exception table sorting
In reply to Greg Kroah-HartmanFrom: Heiko Carstens <[email protected]>
commit c194dad21025dfd043210912653baab823bdff67 upstream.
s390 has a swap_ex_entry_fixup function, however it is not being used since common code expects a swap_ex_entry_fixup define. If it is not defined the default implementation will be used. So fix this by adding a proper define.
However also the implementation of the function must be fixed, since a NULL value for handler has a special meaning and must not be adjusted.
Luckily all of this doesn't fix a real bug currently: the main extable is correctly sorted during build time, and for runtime sorting there is currently no case where the handler field is not NULL.
--- arch/s390/include/asm/extable.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/s390/include/asm/extable.h +7 -2
@@ -69,8 +69,13 @@ static inline void swap_ex_entry_fixup(s { a->fixup = b->fixup + delta; b->fixup = tmp.fixup - delta; - a->handler = b->handler + delta; - b->handler = tmp.handler - delta; + a->handler = b->handler; +if (a->handler) + a->handler += delta; + b->handler = tmp.handler; +if (b->handler) + b->handler -= delta; } +#define swap_ex_entry_fixup swap_ex_entry_fixup#endif
Greg Kroah-Hartman
maintainerPATCH 202/262 sched: Fix yet more sched_fork() races
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
commit b1e8206582f9d680cff7d04828708c8b6ab32957 upstream.
Where commit 4ef0c5c6b5ba ("kernel/sched: Fix sched_fork() access an invalid sched_task_group") fixed a fork race vs cgroup, it opened up a race vs syscalls by not placing the task on the runqueue before it gets exposed through the pidhash.
Commit 13765de8148f ("sched/fair: Fix fault in reweight_entity") is trying to fix a single instance of this, instead fix the whole class of issues, effectively reverting this commit.
--- include/linux/sched/task.h | 4 ++-- kernel/fork.c | 13 ++++++++++++- kernel/sched/core.c | 34 +++++++++++++++++++++------------- 3 files changed, 35 insertions(+), 16 deletions(-)
include/linux/sched/task.h +2 -2
@@ -54,8 +54,8 @@ extern asmlinkage void schedule_tail(strextern void init_idle (struct task_struct *idle,int cpu);extern int sched_fork (unsigned long clone_flags,struct task_struct *p); -extern void sched_post_fork (struct task_struct *p, -struct kernel_clone_args *kargs); +extern void sched_cgroup_fork (struct task_struct *p,struct kernel_clone_args *kargs); +extern void sched_post_fork (struct task_struct *p);extern void sched_dead (struct task_struct *p);void __noreturn do_task_dead (void );
kernel/fork.c +12 -1
@@ -2297,6 +2297,17 @@ static __latent_entropy struct task_stru goto bad_fork_put_pidfd;/* +* Now that the cgroups are pinned, re-clone the parent cgroup and put +* the new task on the correct runqueue. All this *before* the task +* becomes visible. +* +* This isn't part of ->can_fork() because while the re-cloning is +* cgroup specific, it unconditionally needs to place the task on a +* runqueue. +*/ +sched_cgroup_fork (p, args); + +/* * From this point on we must avoid any synchronous user-space * communication until we take the tasklist-lock. In particular, we do * not want user-space to be able to predict the process start-time by
@@ -2405,7 +2416,7 @@ static __latent_entropy struct task_strufd_install (pidfd, pidfile);proc_fork_connector (p); -sched_post_fork (p, args); +sched_post_fork (p);cgroup_post_fork (p, args);perf_event_fork (p);
kernel/sched/core.c +21 -13
@@ -1199,9 +1199,8 @@ int tg_nop(struct task_group *tg, void * }#endif -static void set_load_weight (struct task_struct *p) +static void set_load_weight (struct task_struct *p,bool update_load) { -bool update_load = !(READ_ONCE (p->__state) &TASK_NEW );int prio = p->static_prio -MAX_RT_PRIO ;struct load_weight *load = &p->se.load;
@@ -4359,7 +4358,7 @@ int sched_fork(unsigned long clone_flags p->static_prio =NICE_TO_PRIO (0 ); p->prio = p->normal_prio = p->static_prio; -set_load_weight (p); +set_load_weight (p, false);/* * We don't need the reset flag anymore after the fork. It has
@@ -4377,6 +4376,7 @@ int sched_fork(unsigned long clone_flagsinit_entity_runnable_average (&p->se); +#ifdef CONFIG_SCHED_INFO if (likely (sched_info_on ()))memset (&p->sched_info,0 ,sizeof (p->sched_info));
@@ -4392,18 +4392,23 @@ int sched_fork(unsigned long clone_flagsreturn 0 ; } -void sched_post_fork (struct task_struct *p,struct kernel_clone_args *kargs) +void sched_cgroup_fork (struct task_struct *p,struct kernel_clone_args *kargs) {unsigned long flags; -#ifdef CONFIG_CGROUP_SCHED -struct task_group *tg; -#endif +/* +* Because we're not yet on the pid-hash, p->pi_lock isn't strictly +* required yet, but lockdep gets upset if rules are violated. +*/ raw_spin_lock_irqsave (&p->pi_lock, flags);#ifdef CONFIG_CGROUP_SCHED - tg =container_of (kargs->cset->subsys[cpu_cgrp_id], - struct task_group, css); - p->sched_task_group =autogroup_task_group (p, tg); +if (1 ) { +struct task_group *tg; + tg =container_of (kargs->cset->subsys[cpu_cgrp_id], + struct task_group, css); + tg =autogroup_task_group (p, tg); + p->sched_task_group = tg; + }#endif rseq_migrate (p);/*
@@ -4414,7 +4419,10 @@ void sched_post_fork(struct task_structif (p->sched_class->task_fork) p->sched_class->task_fork (p);raw_spin_unlock_irqrestore (&p->pi_lock, flags); +} +void sched_post_fork (struct task_struct *p) +{uclamp_post_fork (p); }
@@ -6903,7 +6911,7 @@ void set_user_nice(struct task_struct *pput_prev_task (rq, p); p->static_prio =NICE_TO_PRIO (nice); -set_load_weight (p); +set_load_weight (p, true); old_prio = p->prio; p->prio =effective_prio (p);
@@ -7194,7 +7202,7 @@ static void __setscheduler_params(struct*/ p->rt_priority = attr->sched_priority; p->normal_prio =normal_prio (p); -set_load_weight (p); +set_load_weight (p, true); }/*
@@ -9432,7 +9440,7 @@ void __init sched_init(void)#endif } -set_load_weight (&init_task); +set_load_weight (&init_task, false);/* * The boot idle thread does lazy MMU switching as well:
Greg Kroah-Hartman
maintainerPATCH 203/262 arm64: dts: juno: Remove GICv2m dma-range
In reply to Greg Kroah-HartmanFrom: Robin Murphy <[email protected]>
[ Upstream commit 31eeb6b09f4053f32a30ce9fbcdfca31f713028d ]
Although it is painstakingly honest to describe all 3 PCI windows in "dma-ranges", it misses the the subtle distinction that the window for the GICv2m range is normally programmed for Device memory attributes rather than Normal Cacheable like the DRAM windows. Since MMU-401 only offers stage 2 translation, this means that when the PCI SMMU is enabled, accesses through that IPA range unexpectedly lose coherency if mapped as cacheable at the SMMU, due to the attribute combining rules. Since an extra 256KB is neither here nor there when we still have 10GB worth of usable address space, rather than attempting to describe and cope with this detail let's just remove the offending range. If the SMMU is not used then it makes no difference anyway.
--- arch/arm64/boot/dts/arm/juno-base.dtsi | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm64/boot/dts/arm/juno-base.dtsi +1 -2
@@ -543,8 +543,7 @@ <0x02000000 0x00 0x50000000 0x00 0x50000000 0x0 0x08000000>, <0x42000000 0x40 0x00000000 0x40 0x00000000 0x1 0x00000000>; /* Standard AXI Translation entries as programmed by EDK2 */ - dma-ranges = <0x02000000 0x0 0x2c1c0000 0x0 0x2c1c0000 0x0 0x00040000>, - <0x02000000 0x0 0x80000000 0x0 0x80000000 0x0 0x80000000>, + dma-ranges = <0x02000000 0x0 0x80000000 0x0 0x80000000 0x0 0x80000000>, <0x43000000 0x8 0x00000000 0x8 0x00000000 0x2 0x00000000>; #interrupt-cells = <1>; interrupt-map-mask = <0 0 0 7>;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 204/262 iommu/amd: Simplify pagetable freeing
In reply to Greg Kroah-HartmanFrom: Robin Murphy <[email protected]>
[ Upstream commit 6b3106e9ba2de7320a71291cedcefdcf1195ad58 ]
For reasons unclear, pagetable freeing is an effectively recursive method implemented via an elaborate system of templated functions that turns out to account for 25% of the object file size. Implementing it using regular straightforward recursion makes the code simpler, and seems like a good thing to do before we work on it further. As part of that, also fix the types to avoid all the needless casting back and forth which just gets in the way.
--- drivers/iommu/amd/io_pgtable.c | 82 ++++++++++++++-------------------- 1 file changed, 34 insertions(+), 48 deletions(-)
drivers/iommu/amd/io_pgtable.c +34 -48
@@ -84,49 +84,45 @@ static void free_page_list(struct page *freelist) } } -static struct page *free_pt_page (unsigned long pt,struct page *freelist) +static struct page *free_pt_page (u64 *pt,struct page *freelist) { -struct page *p =virt_to_page ((void *)pt); +struct page *p =virt_to_page (pt); p->freelist = freelist;return p; } -#define DEFINE_FREE_PT_FN (LVL ,FN ) \ -static struct page *free_pt_##LVL (unsigned long __pt, struct page *freelist) \ -{ \ - unsigned long p; \ - u64 *pt; \ - int i; \ - \ - pt = (u64 *)__pt; \ - \ - for (i = 0; i < 512; ++i) { \ -/* PTE present? */ \ -if (!IOMMU_PTE_PRESENT (pt[i])) \ -continue ; \ - \ -/* Large PTE? */ \ -if (PM_PTE_LEVEL (pt[i]) ==0 || \ -PM_PTE_LEVEL (pt[i]) ==7 ) \ -continue ; \ - \ - p = (unsigned long )IOMMU_PTE_PAGE (pt[i]); \ - freelist =FN (p, freelist); \ - } \ - \ -return free_pt_page ((unsigned long )pt, freelist); \ -} +static struct page *free_pt_lvl (u64 *pt,struct page *freelist,int lvl) +{ +u64 *p; +int i; + +for (i =0 ; i <512 ; ++i) { +/* PTE present? */ +if (!IOMMU_PTE_PRESENT (pt[i])) +continue ; -DEFINE_FREE_PT_FN(l2, free_pt_page) -DEFINE_FREE_PT_FN(l3, free_pt_l2) -DEFINE_FREE_PT_FN(l4, free_pt_l3) -DEFINE_FREE_PT_FN(l5, free_pt_l4) -DEFINE_FREE_PT_FN(l6, free_pt_l5) +/* Large PTE? */ +if (PM_PTE_LEVEL (pt[i]) ==0 || +PM_PTE_LEVEL (pt[i]) ==7 ) +continue ; -static struct page *free_sub_pt (unsigned long root,int mode, -struct page *freelist) +/* +* Free the next level. No need to look at l1 tables here since +* they can only contain leaf PTEs; just free them directly. +*/ + p =IOMMU_PTE_PAGE (pt[i]); +if (lvl >2 ) + freelist =free_pt_lvl (p, freelist, lvl -1 ); +else + freelist =free_pt_page (p, freelist); + } + +return free_pt_page (pt, freelist); +} + +static struct page *free_sub_pt (u64 *root,int mode,struct page *freelist) {switch (mode) {case PAGE_MODE_NONE :
@@ -136,19 +132,11 @@ static struct page *free_sub_pt(unsigned long root, int mode, freelist =free_pt_page (root, freelist);break ;case PAGE_MODE_2_LEVEL : - freelist =free_pt_l2 (root, freelist); -break ;case PAGE_MODE_3_LEVEL : - freelist =free_pt_l3 (root, freelist); -break ;case PAGE_MODE_4_LEVEL : - freelist =free_pt_l4 (root, freelist); -break ;case PAGE_MODE_5_LEVEL : - freelist =free_pt_l5 (root, freelist); -break ;case PAGE_MODE_6_LEVEL : - freelist =free_pt_l6 (root, freelist); +free_pt_lvl (root, freelist, mode);break ;default :BUG ();
@@ -364,7 +352,7 @@ static u64 *fetch_pte(struct amd_io_pgtable *pgtable,static struct page *free_clear_pte (u64 *pte,u64 pteval,struct page *freelist) { -unsigned long pt; +u64 *pt;int mode;while (cmpxchg64 (pte, pteval,0 ) != pteval) {
@@ -375,7 +363,7 @@ static struct page *free_clear_pte(u64 *pte, u64 pteval, struct page *freelist)if (!IOMMU_PTE_PRESENT (pteval))return freelist; - pt = (unsigned long )IOMMU_PTE_PAGE (pteval); + pt =IOMMU_PTE_PAGE (pteval); mode =IOMMU_PTE_MODE (pteval);return free_sub_pt (pt, mode, freelist);
@@ -512,7 +500,6 @@ static void v1_free_pgtable(struct io_pgtable *iop) struct amd_io_pgtable *pgtable = container_of(iop, struct amd_io_pgtable, iop);struct protection_domain *dom;struct page *freelist =NULL ; -unsigned long root;if (pgtable->mode ==PAGE_MODE_NONE )return ;
@@ -529,8 +516,7 @@ static void v1_free_pgtable(struct io_pgtable *iop)BUG_ON (pgtable->mode <PAGE_MODE_NONE || pgtable->mode >PAGE_MODE_6_LEVEL ); - root = (unsigned long )pgtable->root; - freelist =free_sub_pt (root, pgtable->mode, freelist); + freelist =free_sub_pt (pgtable->root, pgtable->mode, freelist);free_page_list (freelist); }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 205/262 iommu/amd: Use put_pages_list
In reply to Greg Kroah-HartmanFrom: Matthew Wilcox (Oracle) <[email protected]>
[ Upstream commit ce00eece6909c266da123fd147172d745a4f14a0 ]
page->freelist is for the use of slab. We already have the ability to free a list of pages in the core mm, but it requires the use of a list_head and for the pages to be chained together through page->lru. Switch the AMD IOMMU code over to using free_pages_list().
--- drivers/iommu/amd/io_pgtable.c | 50 ++++++++++++---------------------- 1 file changed, 18 insertions(+), 32 deletions(-)
drivers/iommu/amd/io_pgtable.c +18 -32
@@ -74,26 +74,14 @@ static u64 *first_pte_l7(u64 *pte, unsigned long *page_size,* ****************************************************************************/ -static void free_page_list (struct page *freelist) -{ -while (freelist !=NULL ) { -unsigned long p = (unsigned long )page_address (freelist); - - freelist = freelist->freelist; -free_page (p); - } -} - -static struct page *free_pt_page (u64 *pt,struct page *freelist) +static void free_pt_page (u64 *pt,struct list_head *freelist) {struct page *p =virt_to_page (pt); - p->freelist = freelist; - -return p; +list_add_tail (&p->lru, freelist); } -static struct page *free_pt_lvl (u64 *pt,struct page *freelist,int lvl) +static void free_pt_lvl (u64 *pt,struct list_head *freelist,int lvl) {u64 *p;int i;
@@ -114,22 +102,22 @@ static struct page *free_pt_lvl(u64 *pt, struct page *freelist, int lvl)*/ p =IOMMU_PTE_PAGE (pt[i]);if (lvl >2 ) - freelist =free_pt_lvl (p, freelist, lvl -1 ); +free_pt_lvl (p, freelist, lvl -1 );else - freelist =free_pt_page (p, freelist); +free_pt_page (p, freelist); } -return free_pt_page (pt, freelist); +free_pt_page (pt, freelist); } -static struct page *free_sub_pt (u64 *root,int mode,struct page *freelist) +static void free_sub_pt (u64 *root,int mode,struct list_head *freelist) {switch (mode) {case PAGE_MODE_NONE :case PAGE_MODE_7_LEVEL :break ;case PAGE_MODE_1_LEVEL : - freelist =free_pt_page (root, freelist); +free_pt_page (root, freelist);break ;case PAGE_MODE_2_LEVEL :case PAGE_MODE_3_LEVEL :
@@ -141,8 +129,6 @@ static struct page *free_sub_pt(u64 *root, int mode, struct page *freelist)default :BUG (); } - -return freelist; } void amd_iommu_domain_set_pgtable(struct protection_domain *domain,
@@ -350,7 +336,7 @@ static u64 *fetch_pte(struct amd_io_pgtable *pgtable,return pte; } -static struct page *free_clear_pte (u64 *pte,u64 pteval,struct page *freelist) +static void free_clear_pte (u64 *pte,u64 pteval,struct list_head *freelist) {u64 *pt;int mode;
@@ -361,12 +347,12 @@ static struct page *free_clear_pte(u64 *pte, u64 pteval, struct page *freelist) }if (!IOMMU_PTE_PRESENT (pteval)) -return freelist; +return ; pt =IOMMU_PTE_PAGE (pteval); mode =IOMMU_PTE_MODE (pteval); -return free_sub_pt (pt, mode, freelist); +free_sub_pt (pt, mode, freelist); }/*
@@ -380,7 +366,7 @@ static int iommu_v1_map_page(struct io_pgtable_ops *ops, unsigned long iova, phys_addr_t paddr, size_t size, int prot, gfp_t gfp) { struct protection_domain *dom = io_pgtable_ops_to_domain(ops); -struct page *freelist =NULL ; +LIST_HEAD (freelist);bool updated = false;u64 __pte, *pte;int ret, i, count;
@@ -400,9 +386,9 @@ static int iommu_v1_map_page(struct io_pgtable_ops *ops, unsigned long iova, goto out;for (i =0 ; i < count; ++i) - freelist =free_clear_pte (&pte[i], pte[i], freelist); +free_clear_pte (&pte[i], pte[i], &freelist); -if (freelist !=NULL ) +if (!list_empty (&freelist)) updated = true;if (count >1 ) {
@@ -437,7 +423,7 @@ static int iommu_v1_map_page(struct io_pgtable_ops *ops, unsigned long iova, }/* Everything flushed out, free pages now */ -free_page_list (freelist); +put_pages_list (&freelist);return ret; }
@@ -499,7 +485,7 @@ static void v1_free_pgtable(struct io_pgtable *iop) { struct amd_io_pgtable *pgtable = container_of(iop, struct amd_io_pgtable, iop);struct protection_domain *dom; -struct page *freelist =NULL ; +LIST_HEAD (freelist);if (pgtable->mode ==PAGE_MODE_NONE )return ;
@@ -516,9 +502,9 @@ static void v1_free_pgtable(struct io_pgtable *iop)BUG_ON (pgtable->mode <PAGE_MODE_NONE || pgtable->mode >PAGE_MODE_6_LEVEL ); - freelist =free_sub_pt (pgtable->root, pgtable->mode, freelist); +free_sub_pt (pgtable->root, pgtable->mode, &freelist); -free_page_list (freelist); +put_pages_list (&freelist); }static struct io_pgtable *v1_alloc_pgtable (struct io_pgtable_cfg *cfg,void *cookie)
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 206/262 iommu/amd: Fix I/O page table memory leak
In reply to Greg Kroah-HartmanFrom: Suravee Suthikulpanit <[email protected]>
[ Upstream commit 6b0b2d9a6a308bcd9300c2d83000a82812c56cea ]
The current logic updates the I/O page table mode for the domain before calling the logic to free memory used for the page table. This results in IOMMU page table memory leak, and can be observed when launching VM w/ pass-through devices.
Fix by freeing the memory used for page table before updating the mode.
--- drivers/iommu/amd/io_pgtable.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/iommu/amd/io_pgtable.c +6 -6
@@ -492,18 +492,18 @@ static void v1_free_pgtable(struct io_pgtable *iop) dom = container_of(pgtable, struct protection_domain, iop); -/* Update data structure */ -amd_iommu_domain_clr_pt_root (dom); - -/* Make changes visible to IOMMUs */ -amd_iommu_domain_update (dom); -/* Page-table is not visible to IOMMU anymore, so free it */ BUG_ON (pgtable->mode <PAGE_MODE_NONE || pgtable->mode >PAGE_MODE_6_LEVEL );free_sub_pt (pgtable->root, pgtable->mode, &freelist); +/* Update data structure */ +amd_iommu_domain_clr_pt_root (dom); + +/* Make changes visible to IOMMUs */ +amd_iommu_domain_update (dom); +put_pages_list (&freelist); }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 207/262 MIPS: ralink: mt7621: do memory detection on KSEG1
In reply to Greg Kroah-HartmanFrom: Chuanhong Guo <[email protected]>
[ Upstream commit cc19db8b312a6c75645645f5cc1b45166b109006 ]
It's reported that current memory detection code occasionally detects larger memory under some bootloaders.
Current memory detection code tests whether address space wraps around on KSEG0, which is unreliable because it's cached.
Rewrite memory size detection to perform the same test on KSEG1 instead. While at it, this patch also does the following two things:
1. use a fixed pattern instead of a random function pointer as the magic value.
2. add an additional memory write and a second comparison as part of the test to prevent possible smaller memory detection result due to leftover values in memory.
--- arch/mips/ralink/mt7621.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-)
arch/mips/ralink/mt7621.c +23 -13
@@ -20,31 +20,41 @@#include "common.h" -static void *detect_magic__initdata = detect_memory_region; +#define MT7621_MEM_TEST_PATTERN 0xaa5555aa + +static u32 detect_magic__initdata ;phys_addr_t mips_cpc_default_phys_base (void ) {panic ("Cannot detect cpc address" ); } +static bool __init mt7621_addr_wraparound_test (phys_addr_t size) +{ +void *dm = (void *)KSEG1ADDR (&detect_magic); + +if (CPHYSADDR (dm + size) >=MT7621_LOWMEM_MAX_SIZE ) +return true; +__raw_writel (MT7621_MEM_TEST_PATTERN , dm); +if (__raw_readl (dm) !=__raw_readl (dm + size)) +return false; +__raw_writel (!MT7621_MEM_TEST_PATTERN , dm); +return __raw_readl (dm) ==__raw_readl (dm + size); +} +static void __init mt7621_memory_detect (void ) { -void *dm = &detect_magic;phys_addr_t size; -for (size =32 *SZ_1M ; size <256 *SZ_1M ; size <<=1 ) { -if (!__builtin_memcmp (dm, dm + size,sizeof (detect_magic))) -break ; +for (size =32 *SZ_1M ; size <=256 *SZ_1M ; size <<=1 ) { +if (mt7621_addr_wraparound_test (size)) { +memblock_add (MT7621_LOWMEM_BASE , size); +return ; + } } -if ((size ==256 *SZ_1M ) && - (CPHYSADDR (dm + size) <MT7621_LOWMEM_MAX_SIZE ) && -__builtin_memcmp (dm, dm + size,sizeof (detect_magic))) { -memblock_add (MT7621_LOWMEM_BASE ,MT7621_LOWMEM_MAX_SIZE ); -memblock_add (MT7621_HIGHMEM_BASE ,MT7621_HIGHMEM_SIZE ); - }else { -memblock_add (MT7621_LOWMEM_BASE , size); - } +memblock_add (MT7621_LOWMEM_BASE ,MT7621_LOWMEM_MAX_SIZE ); +memblock_add (MT7621_HIGHMEM_BASE ,MT7621_HIGHMEM_SIZE ); }void __init ralink_of_remap (void )
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 208/262 ARM: dts: switch timer config to common devkit8000 devicetree
In reply to Greg Kroah-HartmanFrom: Anthoine Bourgeois <[email protected]>
[ Upstream commit 64324ef337d0caa5798fa8fa3f6bbfbd3245868a ]
This patch allow lcd43 and lcd70 flavors to benefit from timer evolution.
--- .../arm/boot/dts/omap3-devkit8000-common.dtsi | 33 +++++++++++++++++++ arch/arm/boot/dts/omap3-devkit8000.dts | 33 ------------------- 2 files changed, 33 insertions(+), 33 deletions(-)
arch/arm/boot/dts/omap3-devkit8000-common.dtsi +33 -0
@@ -158,6 +158,39 @@ status = "disabled"; }; +/* Unusable as clocksource because of unreliable oscillator */ +&counter32k { + status = "disabled"; +}; + +/* Unusable as clockevent because if unreliable oscillator, allow to idle */ +&timer1_target { + /delete-property/ti,no-reset-on-init; + /delete-property/ti,no-idle; + timer@0 { + /delete-property/ti,timer-alwon; + }; +}; + +/* Preferred always-on timer for clocksource */ +&timer12_target { + ti,no-reset-on-init; + ti,no-idle; + timer@0 { + /* Always clocked by secure_32k_fck */ + }; +}; + +/* Preferred timer for clockevent */ +&timer2_target { + ti,no-reset-on-init; + ti,no-idle; + timer@0 { + assigned-clocks = <&gpt2_fck>; + assigned-clock-parents = <&sys_ck>; + }; +}; + &twl_gpio { ti,use-leds; /*
arch/arm/boot/dts/omap3-devkit8000.dts +0 -33
@@ -14,36 +14,3 @@ display2 = &tv0; }; }; - -/* Unusable as clocksource because of unreliable oscillator */ -&counter32k { - status = "disabled"; -}; - -/* Unusable as clockevent because if unreliable oscillator, allow to idle */ -&timer1_target { - /delete-property/ti,no-reset-on-init; - /delete-property/ti,no-idle; - timer@0 { - /delete-property/ti,timer-alwon; - }; -}; - -/* Preferred always-on timer for clocksource */ -&timer12_target { - ti,no-reset-on-init; - ti,no-idle; - timer@0 { - /* Always clocked by secure_32k_fck */ - }; -}; - -/* Preferred timer for clockevent */ -&timer2_target { - ti,no-reset-on-init; - ti,no-idle; - timer@0 { - assigned-clocks = <&gpt2_fck>; - assigned-clock-parents = <&sys_ck>; - }; -};
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 209/262 ARM: dts: Use 32KiHz oscillator on devkit8000
In reply to Greg Kroah-HartmanFrom: Anthoine Bourgeois <[email protected]>
[ Upstream commit 8840f5460a23759403f1f2860429dcbcc2f04a65 ]
Devkit8000 board seems to always used 32k_counter as clocksource. Restore this behavior.
If clocksource is back to 32k_counter, timer12 is now the clockevent source (as before) and timer2 is not longer needed here.
This commit fixes the same issue observed with commit 23885389dbbb ("ARM: dts: Fix timer regression for beagleboard revision c") when sleep is blocked until hitting keys over serial console.
--- arch/arm/boot/dts/omap3-devkit8000-common.dtsi | 17 +---------------- drivers/clocksource/timer-ti-dm-systimer.c | 3 +-- 2 files changed, 2 insertions(+), 18 deletions(-)
arch/arm/boot/dts/omap3-devkit8000-common.dtsi +1 -16
@@ -158,11 +158,6 @@ status = "disabled"; }; -/* Unusable as clocksource because of unreliable oscillator */ -&counter32k { - status = "disabled"; -}; - /* Unusable as clockevent because if unreliable oscillator, allow to idle */ &timer1_target { /delete-property/ti,no-reset-on-init;
@@ -172,7 +167,7 @@ }; }; -/* Preferred always-on timer for clocksource */ +/* Preferred timer for clockevent */ &timer12_target { ti,no-reset-on-init; ti,no-idle;
@@ -181,16 +176,6 @@ }; }; -/* Preferred timer for clockevent */ -&timer2_target { - ti,no-reset-on-init; - ti,no-idle; - timer@0 { - assigned-clocks = <&gpt2_fck>; - assigned-clock-parents = <&sys_ck>; - }; -}; - &twl_gpio { ti,use-leds; /*
drivers/clocksource/timer-ti-dm-systimer.c +1 -2
@@ -241,8 +241,7 @@ static void __init dmtimer_systimer_assign_alwon(void)bool quirk_unreliable_oscillator = false;/* Quirk unreliable 32 KiHz oscillator with incomplete dts */ -if (of_machine_is_compatible ("ti,omap3-beagle-ab4" ) || -of_machine_is_compatible ("timll,omap3-devkit8000" )) { +if (of_machine_is_compatible ("ti,omap3-beagle-ab4" )) { quirk_unreliable_oscillator = true; counter_32k = -ENODEV ; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 210/262 soc: fsl: guts: Revert commit 3c0d64e867ed
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit b113737cf12964a20cc3ba1ddabe6229099661c6 ]
This reverts commit 3c0d64e867ed
("soc: fsl: guts: reuse machine name from device tree").
A following patch will fix the missing memory allocation failure check instead.
--- drivers/soc/fsl/guts.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/soc/fsl/guts.c +3 -4
@@ -28,7 +28,6 @@ struct fsl_soc_die_attr {static struct guts *guts;static struct soc_device_attribute soc_dev_attr;static struct soc_device *soc_dev; -static struct device_node *root;/* SoC die attribute definition for QorIQ platform */
@@ -138,7 +137,7 @@ static u32 fsl_guts_get_svr(void)static int fsl_guts_probe (struct platform_device *pdev) { -struct device_node *np = pdev->dev.of_node; +struct device_node *root, *np = pdev->dev.of_node;struct device *dev = &pdev->dev;struct resource *res;const struct fsl_soc_die_attr *soc_die;
@@ -161,8 +160,9 @@ static int fsl_guts_probe(struct platform_device *pdev) root =of_find_node_by_path ("/" );if (of_property_read_string (root,"model" , &machine))of_property_read_string_index (root,"compatible" ,0 , &machine); +of_node_put (root);if (machine) - soc_dev_attr.machine = machine; + soc_dev_attr.machine =devm_kstrdup (dev, machine,GFP_KERNEL ); svr =fsl_guts_get_svr (); soc_die =fsl_soc_die_match (svr, fsl_soc_die);
@@ -197,7 +197,6 @@ static int fsl_guts_probe(struct platform_device *pdev)static int fsl_guts_remove (struct platform_device *dev) {soc_device_unregister (soc_dev); -of_node_put (root);return 0 ; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 211/262 soc: fsl: guts: Add a missing memory allocation failure check
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit b9abe942cda43a1d46a0fd96efb54f1aa909f757 ]
If 'devm_kstrdup()' fails, we should return -ENOMEM.
While at it, move the 'of_node_put()' call in the error handling path and after the 'machine' has been copied.
Better safe than sorry.
Depends-on: fddacc7ff4dd ("soc: fsl: guts: Revert commit 3c0d64e867ed")
--- drivers/soc/fsl/guts.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/soc/fsl/guts.c +7 -2
@@ -160,9 +160,14 @@ static int fsl_guts_probe(struct platform_device *pdev) root =of_find_node_by_path ("/" );if (of_property_read_string (root,"model" , &machine))of_property_read_string_index (root,"compatible" ,0 , &machine); -of_node_put (root); -if (machine) +if (machine) { soc_dev_attr.machine =devm_kstrdup (dev, machine,GFP_KERNEL ); +if (!soc_dev_attr.machine) { +of_node_put (root); +return -ENOMEM ; + } + } +of_node_put (root); svr =fsl_guts_get_svr (); soc_die =fsl_soc_die_match (svr, fsl_soc_die);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 212/262 soc: fsl: qe: Check of ioremap return value
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit a222fd8541394b36b13c89d1698d9530afd59a9c ]
As the possible failure of the ioremap(), the par_io could be NULL. Therefore it should be better to check it and return error in order to guarantee the success of the initiation.
But, I also notice that all the caller like mpc85xx_qe_par_io_init() in arch/powerpc/platforms/85xx/common.c don't check the return value of the par_io_init().
Actually, par_io_init() needs to check to handle the potential error. I will submit another patch to fix that.
Anyway, par_io_init() itsely should be fixed.
--- drivers/soc/fsl/qe/qe_io.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/soc/fsl/qe/qe_io.c +2 -0
@@ -35,6 +35,8 @@ int par_io_init(struct device_node *np)if (ret)return ret; par_io =ioremap (res.start,resource_size (&res)); +if (!par_io) +return -ENOMEM ;if (!of_property_read_u32 (np,"num-ports" , &num_ports)) num_par_io_ports = num_ports;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 213/262 netfilter: nf_tables: prefer kfree_rcu(ptr, rcu) variant
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit ae089831ff28a115908b8d796f667c2dadef1637 ]
While kfree_rcu(ptr) _is_ supported, it has some limitations.
Given that 99.99% of kfree_rcu() users [1] use the legacy two parameters variant, and @catchall objects do have an rcu head, simply use it.
Choice of kfree_rcu(ptr) variant was probably not intentional.
[1] including calls from net/netfilter/nf_tables_api.c
--- net/netfilter/nf_tables_api.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/nf_tables_api.c +2 -2
@@ -4486,7 +4486,7 @@ static void nft_set_catchall_destroy(const struct nft_ctx *ctx,list_for_each_entry_safe (catchall, next, &set->catchall_list, list) {list_del_rcu (&catchall->list);nft_set_elem_destroy (set, catchall->elem, true); -kfree_rcu (catchall); +kfree_rcu (catchall, rcu); } }
@@ -5653,7 +5653,7 @@ static void nft_setelem_catchall_remove(const struct net *net,list_for_each_entry_safe (catchall, next, &set->catchall_list, list) {if (catchall->elem == elem->priv) {list_del_rcu (&catchall->list); -kfree_rcu (catchall); +kfree_rcu (catchall, rcu);break ; } }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 214/262 ARM: tegra: Move panels to AUX bus
In reply to Greg Kroah-HartmanFrom: Thierry Reding <[email protected]>
[ Upstream commit 8d3b01e0d4bb54368d73d0984466d72c2eeeac74 ]
Move the eDP panel on Venice 2 and Nyan boards into the corresponding AUX bus device tree node. This allows us to avoid a nasty circular dependency that would otherwise be created between the DPAUX and panel nodes via the DDC/I2C phandle.
--- arch/arm/boot/dts/tegra124-nyan-big.dts | 15 +++++++++------ arch/arm/boot/dts/tegra124-nyan-blaze.dts | 15 +++++++++------ arch/arm/boot/dts/tegra124-venice2.dts | 14 +++++++------- 3 files changed, 25 insertions(+), 19 deletions(-)
arch/arm/boot/dts/tegra124-nyan-big.dts +9 -6
@@ -13,12 +13,15 @@ "google,nyan-big-rev1", "google,nyan-big-rev0", "google,nyan-big", "google,nyan", "nvidia,tegra124"; - panel: panel { - compatible = "auo,b133xtn01"; - - power-supply = <&vdd_3v3_panel>; - backlight = <&backlight>; - ddc-i2c-bus = <&dpaux>; + host1x@50000000 { + dpaux@545c0000 { + aux-bus { + panel: panel { + compatible = "auo,b133xtn01"; + backlight = <&backlight>; + }; + }; + }; }; mmc@700b0400 { /* SD Card on this bus */
arch/arm/boot/dts/tegra124-nyan-blaze.dts +9 -6
@@ -15,12 +15,15 @@ "google,nyan-blaze-rev0", "google,nyan-blaze", "google,nyan", "nvidia,tegra124"; - panel: panel { - compatible = "samsung,ltn140at29-301"; - - power-supply = <&vdd_3v3_panel>; - backlight = <&backlight>; - ddc-i2c-bus = <&dpaux>; + host1x@50000000 { + dpaux@545c0000 { + aux-bus { + panel: panel { + compatible = "samsung,ltn140at29-301"; + backlight = <&backlight>; + }; + }; + }; }; sound {
arch/arm/boot/dts/tegra124-venice2.dts +7 -7
@@ -48,6 +48,13 @@ dpaux@545c0000 { vdd-supply = <&vdd_3v3_panel>; status = "okay"; + + aux-bus { + panel: panel { + compatible = "lg,lp129qe"; + backlight = <&backlight>; + }; + }; }; };
@@ -1079,13 +1086,6 @@ }; }; - panel: panel { - compatible = "lg,lp129qe"; - power-supply = <&vdd_3v3_panel>; - backlight = <&backlight>; - ddc-i2c-bus = <&dpaux>; - }; - vdd_mux: regulator@0 { compatible = "regulator-fixed"; regulator-name = "+VDD_MUX";
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 215/262 can: etas_es58x: change opened_channel_cnts type from atomic_t to u8
In reply to Greg Kroah-HartmanFrom: Vincent Mailhol <[email protected]>
[ Upstream commit f4896248e9025ff744b4147e6758274a1cb8cbae ]
The driver uses an atomic_t variable: struct es58x_device::opened_channel_cnt to keep track of the number of opened channels in order to only allocate memory for the URBs when this count changes from zero to one.
While the intent was to prevent race conditions, the choice of an atomic_t turns out to be a bad idea for several reasons:
- implementation is incorrect and fails to decrement opened_channel_cnt when the URB allocation fails as reported in [1].
- even if opened_channel_cnt were to be correctly decremented, atomic_t is insufficient to cover edge cases: there can be a race condition in which 1/ a first process fails to allocate URBs memory 2/ a second process enters es58x_open() before the first process does its cleanup and decrements opened_channed_cnt. In which case, the second process would successfully return despite the URBs memory not being allocated.
- actually, any kind of locking mechanism was useless here because it is redundant with the network stack big kernel lock (a.k.a. rtnl_lock) which is being hold by all the callers of net_device_ops:ndo_open() and net_device_ops:ndo_close(). c.f. the ASSERST_RTNL() calls in __dev_open() [2] and __dev_close_many() [3].
The atmomic_t is thus replaced by a simple u8 type and the logic to increment and decrement es58x_device:opened_channel_cnt is simplified accordingly fixing the bug reported in [1]. We do not check again for ASSERST_RTNL() as this is already done by the callers.
[1] https://lore.kernel.org/linux-can/20220201140351.GA2548@kili/T/#u
[2] https://elixir.bootlin.com/linux/v5.16/source/net/core/dev.c#L1463
[3] https://elixir.bootlin.com/linux/v5.16/source/net/core/dev.c#L1541
--- drivers/net/can/usb/etas_es58x/es58x_core.c | 9 +++++---- drivers/net/can/usb/etas_es58x/es58x_core.h | 8 +++++--- 2 files changed, 10 insertions(+), 7 deletions(-)
drivers/net/can/usb/etas_es58x/es58x_core.c +5 -4
@@ -1794,7 +1794,7 @@ static int es58x_open(struct net_device *netdev)struct es58x_device *es58x_dev =es58x_priv (netdev)->es58x_dev;int ret; -if (atomic_inc_return (&es58x_dev->opened_channel_cnt) ==1 ) { +if (!es58x_dev->opened_channel_cnt) { ret =es58x_alloc_rx_urbs (es58x_dev);if (ret)return ret;
@@ -1812,12 +1812,13 @@ static int es58x_open(struct net_device *netdev)if (ret) goto free_urbs; + es58x_dev->opened_channel_cnt++;netif_start_queue (netdev);return ret; free_urbs: -if (atomic_dec_and_test (&es58x_dev->opened_channel_cnt)) +if (!es58x_dev->opened_channel_cnt)es58x_free_urbs (es58x_dev);netdev_err (netdev,"%s: Could not open the network device: %pe\n" , __func__,ERR_PTR (ret));
@@ -1852,7 +1853,8 @@ static int es58x_stop(struct net_device *netdev)es58x_flush_pending_tx_msg (netdev); -if (atomic_dec_and_test (&es58x_dev->opened_channel_cnt)) + es58x_dev->opened_channel_cnt--; +if (!es58x_dev->opened_channel_cnt)es58x_free_urbs (es58x_dev);return 0 ;
@@ -2221,7 +2223,6 @@ static struct es58x_device *es58x_init_es58x_dev(struct usb_interface *intf,init_usb_anchor (&es58x_dev->tx_urbs_idle);init_usb_anchor (&es58x_dev->tx_urbs_busy);atomic_set (&es58x_dev->tx_urbs_idle_cnt,0 ); -atomic_set (&es58x_dev->opened_channel_cnt,0 );usb_set_intfdata (intf, es58x_dev); es58x_dev->rx_pipe = usb_rcvbulkpipe(es58x_dev->udev,
drivers/net/can/usb/etas_es58x/es58x_core.h +5 -3
@@ -373,8 +373,6 @@ struct es58x_operators {* queue wake/stop logic should prevent this URB from getting * empty. Please refer to es58x_get_tx_urb() for more details. * @tx_urbs_idle_cnt: number of urbs in @tx_urbs_idle. -* @opened_channel_cnt: number of channels opened (c.f. es58x_open() -* and es58x_stop()). * @ktime_req_ns: kernel timestamp when es58x_set_realtime_diff_ns() * was called. * @realtime_diff_ns: difference in nanoseconds between the clocks of
@@ -384,6 +382,10 @@ struct es58x_operators {* in RX branches. * @rx_max_packet_size: Maximum length of bulk-in URB. * @num_can_ch: Number of CAN channel (i.e. number of elements of @netdev). +* @opened_channel_cnt: number of channels opened. Free of race +* conditions because its two users (net_device_ops:ndo_open() +* and net_device_ops:ndo_close()) guarantee that the network +* stack big kernel lock (a.k.a. rtnl_mutex) is being hold. * @rx_cmd_buf_len: Length of @rx_cmd_buf. * @rx_cmd_buf: The device might split the URB commands in an * arbitrary amount of pieces. This buffer is used to concatenate
@@ -406,7 +408,6 @@ struct es58x_device {struct usb_anchor tx_urbs_busy;struct usb_anchor tx_urbs_idle;atomic_t tx_urbs_idle_cnt; -atomic_t opened_channel_cnt;u64 ktime_req_ns;s64 realtime_diff_ns;
@@ -415,6 +416,7 @@ struct es58x_device {u16 rx_max_packet_size;u8 num_can_ch; +u8 opened_channel_cnt;u16 rx_cmd_buf_len;union es58x_urb_cmd rx_cmd_buf;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 216/262 net: stmmac: enhance XDP ZC driver level switching performance
In reply to Greg Kroah-HartmanFrom: Ong Boon Leong <[email protected]>
[ Upstream commit ac746c8520d9d056b6963ecca8ff1da9929d02f1 ]
The previous stmmac_xdp_set_prog() implementation uses stmmac_release() and stmmac_open() which tear down the PHY device and causes undesirable autonegotiation which causes a delay whenever AFXDP ZC is setup.
This patch introduces two new functions that just sufficiently tear down DMA descriptors, buffer, NAPI process, and IRQs and reestablish them accordingly in both stmmac_xdp_release() and stammac_xdp_open().
As the results of this enhancement, we get rid of transient state introduced by the link auto-negotiation:
$ ./xdpsock -i eth0 -t -z
sock0@eth0:0 txonly xdp-drv
pps pkts 1.00 rx 0 0 tx 634444 634560
sock0@eth0:0 txonly xdp-drv
pps pkts 1.00 rx 0 0 tx 632330 1267072
sock0@eth0:0 txonly xdp-drv
pps pkts 1.00 rx 0 0 tx 632438 1899584
sock0@eth0:0 txonly xdp-drv
pps pkts 1.00 rx 0 0 tx 632502 2532160
--- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 4 +- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 137 +++++++++++++++++- .../net/ethernet/stmicro/stmmac/stmmac_xdp.c | 4 +- 3 files changed, 139 insertions(+), 6 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac.h +2 -2
@@ -334,8 +334,8 @@ void stmmac_set_ethtool_ops(struct net_device *netdev);int stmmac_init_tstamp_counter (struct stmmac_priv *priv,u32 systime_flags);void stmmac_ptp_register (struct stmmac_priv *priv);void stmmac_ptp_unregister (struct stmmac_priv *priv); -int stmmac_open (struct net_device *dev); -int stmmac_release (struct net_device *dev); +int stmmac_xdp_open (struct net_device *dev); +void stmmac_xdp_release (struct net_device *dev);int stmmac_resume (struct device *dev);int stmmac_suspend (struct device *dev);int stmmac_dvr_remove (struct device *dev);
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +135 -2
155 lines not on this page · raw message
drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c +2 -2
@@ -119,7 +119,7 @@ int stmmac_xdp_set_prog(struct stmmac_priv *priv, struct bpf_prog *prog, need_update = !!priv->xdp_prog != !!prog;if (if_running && need_update) -stmmac_release (dev); +stmmac_xdp_release (dev); old_prog =xchg (&priv->xdp_prog, prog);if (old_prog)
@@ -129,7 +129,7 @@ int stmmac_xdp_set_prog(struct stmmac_priv *priv, struct bpf_prog *prog, priv->sph = priv->sph_cap && !stmmac_xdp_is_enabled (priv);if (if_running && need_update) -stmmac_open (dev); +stmmac_xdp_open (dev);return 0 ; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 217/262 net: stmmac: only enable DMA interrupts when ready
In reply to Greg Kroah-HartmanFrom: Vincent Whitchurch <[email protected]>
[ Upstream commit 087a7b944c5db409f7c1a68bf4896c56ba54eaff ]
In this driver's ->ndo_open() callback, it enables DMA interrupts, starts the DMA channels, then requests interrupts with request_irq(), and then finally enables napi.
If RX DMA interrupts are received before napi is enabled, no processing is done because napi_schedule_prep() will return false. If the network has a lot of broadcast/multicast traffic, then the RX ring could fill up completely before napi is enabled. When this happens, no further RX interrupts will be delivered, and the driver will fail to receive any packets.
Fix this by only enabling DMA interrupts after all other initialization is complete.
--- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +26 -2
@@ -2268,6 +2268,23 @@ static void stmmac_stop_tx_dma(struct stmmac_priv *priv, u32 chan)stmmac_stop_tx (priv, priv->ioaddr, chan); } +static void stmmac_enable_all_dma_irq (struct stmmac_priv *priv) +{ +u32 rx_channels_count = priv->plat->rx_queues_to_use; +u32 tx_channels_count = priv->plat->tx_queues_to_use; +u32 dma_csr_ch =max (rx_channels_count, tx_channels_count); +u32 chan; + +for (chan =0 ; chan < dma_csr_ch; chan++) { +struct stmmac_channel *ch = &priv->channel[chan]; +unsigned long flags; + +spin_lock_irqsave (&ch->lock, flags); +stmmac_enable_dma_irq (priv, priv->ioaddr, chan,1 ,1 ); +spin_unlock_irqrestore (&ch->lock, flags); + } +} +/** * stmmac_start_all_dma - start all RX and TX DMA channels * @priv: driver private structure
@@ -2903,8 +2920,10 @@ static int stmmac_init_dma_engine(struct stmmac_priv *priv)stmmac_axi (priv, priv->ioaddr, priv->plat->axi);/* DMA CSR Channel configuration */ -for (chan =0 ; chan < dma_csr_ch; chan++) +for (chan =0 ; chan < dma_csr_ch; chan++) {stmmac_init_chan (priv, priv->ioaddr, priv->plat->dma_cfg, chan); +stmmac_disable_dma_irq (priv, priv->ioaddr, chan,1 ,1 ); + }/* DMA RX Channel Configuration */ for (chan =0 ; chan < rx_channels_count; chan++) {
@@ -3756,6 +3775,7 @@ static int stmmac_open(struct net_device *dev)stmmac_enable_all_queues (priv);netif_tx_start_all_queues (priv->dev); +stmmac_enable_all_dma_irq (priv);return 0 ;
@@ -6514,8 +6534,10 @@ int stmmac_xdp_open(struct net_device *dev) }/* DMA CSR Channel configuration */ -for (chan =0 ; chan < dma_csr_ch; chan++) +for (chan =0 ; chan < dma_csr_ch; chan++) {stmmac_init_chan (priv, priv->ioaddr, priv->plat->dma_cfg, chan); +stmmac_disable_dma_irq (priv, priv->ioaddr, chan,1 ,1 ); + }/* Adjust Split header */ sph_en = (priv->hw->rx_csum >0 ) && priv->sph;
@@ -6575,6 +6597,7 @@ int stmmac_xdp_open(struct net_device *dev)stmmac_enable_all_queues (priv);netif_carrier_on (dev);netif_tx_start_all_queues (dev); +stmmac_enable_all_dma_irq (priv);return 0 ;
@@ -7453,6 +7476,7 @@ int stmmac_resume(struct device *dev)stmmac_restore_hw_vlan_rx_fltr (priv, ndev, priv->hw);stmmac_enable_all_queues (priv); +stmmac_enable_all_dma_irq (priv);mutex_unlock (&priv->lock);rtnl_unlock ();
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 218/262 ibmvnic: initialize rc before completing wait
In reply to Greg Kroah-HartmanFrom: Sukadev Bhattiprolu <[email protected]>
[ Upstream commit 765559b10ce514eb1576595834f23cdc92125fee ]
We should initialize ->init_done_rc before calling complete(). Otherwise the waiting thread may see ->init_done_rc as 0 before we have updated it and may assume that the CRQ was successful.
--- drivers/net/ethernet/ibm/ibmvnic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/ibm/ibmvnic.c +1 -1
@@ -5145,9 +5145,9 @@ static void ibmvnic_handle_crq(union ibmvnic_crq *crq, }if (!completion_done (&adapter->init_done)) { -complete (&adapter->init_done);if (!adapter->init_done_rc) adapter->init_done_rc = -EAGAIN ; +complete (&adapter->init_done); }break ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 219/262 ibmvnic: define flush_reset_queue helper
In reply to Greg Kroah-HartmanFrom: Sukadev Bhattiprolu <[email protected]>
[ Upstream commit 83da53f7e4bd86dca4b2edc1e2bb324fb3c033a1 ]
Define and use a helper to flush the reset queue.
--- drivers/net/ethernet/ibm/ibmvnic.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
drivers/net/ethernet/ibm/ibmvnic.c +16 -8
@@ -2557,12 +2557,23 @@ static void __ibmvnic_delayed_reset(struct work_struct *work)__ibmvnic_reset (&adapter->ibmvnic_reset); } +static void flush_reset_queue (struct ibmvnic_adapter *adapter) +{ +struct list_head *entry, *tmp_entry; + +if (!list_empty (&adapter->rwi_list)) { +list_for_each_safe (entry, tmp_entry, &adapter->rwi_list) { +list_del (entry); +kfree (list_entry(entry ,struct ibmvnic_rwi ,list )); + } + } +} +static int ibmvnic_reset (struct ibmvnic_adapter *adapter,enum ibmvnic_reset_reason reason) { -struct list_head *entry, *tmp_entry; -struct ibmvnic_rwi *rwi, *tmp;struct net_device *netdev = adapter->netdev; +struct ibmvnic_rwi *rwi, *tmp;unsigned long flags;int ret;
@@ -2605,12 +2616,9 @@ static int ibmvnic_reset(struct ibmvnic_adapter *adapter,/* if we just received a transport event, * flush reset queue and process this reset */ -if (adapter->force_reset_recovery && !list_empty (&adapter->rwi_list)) { -list_for_each_safe (entry, tmp_entry, &adapter->rwi_list) { -list_del (entry); -kfree (list_entry(entry ,struct ibmvnic_rwi ,list )); - } - } +if (adapter->force_reset_recovery) +flush_reset_queue (adapter); + rwi->reset_reason = reason;list_add_tail (&rwi->list, &adapter->rwi_list); netdev_dbg(adapter->netdev, "Scheduling reset (reason %s)\n",
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 220/262 ibmvnic: complete init_done on transport events
In reply to Greg Kroah-HartmanFrom: Sukadev Bhattiprolu <[email protected]>
[ Upstream commit 36491f2df9ad2501e5a4ec25d3d95d72bafd2781 ]
If we get a transport event, set the error and mark the init as complete so the attempt to send crq-init or login fail sooner rather than wait for the timeout.
--- drivers/net/ethernet/ibm/ibmvnic.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/ethernet/ibm/ibmvnic.c +7 -0
@@ -5178,6 +5178,13 @@ static void ibmvnic_handle_crq(union ibmvnic_crq *crq, adapter->fw_done_rc = -EIO ;complete (&adapter->fw_done); } + +/* if we got here during crq-init, retry crq-init */ +if (!completion_done (&adapter->init_done)) { + adapter->init_done_rc = -EAGAIN ; +complete (&adapter->init_done); + } +if (!completion_done (&adapter->stats_done))complete (&adapter->stats_done);if (test_bit (0 , &adapter->resetting))
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 221/262 net: chelsio: cxgb3: check the return value of pci_find_capability()
In reply to Greg Kroah-HartmanFrom: Jia-Ju Bai <[email protected]>
[ Upstream commit 767b9825ed1765894e569a3d698749d40d83762a ]
The function pci_find_capability() in t3_prep_adapter() can fail, so its return value should be checked.
--- drivers/net/ethernet/chelsio/cxgb3/t3_hw.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/chelsio/cxgb3/t3_hw.c +2 -0
@@ -3678,6 +3678,8 @@ int t3_prep_adapter(struct adapter *adapter, const struct adapter_info *ai, MAC_STATS_ACCUM_SECS : (MAC_STATS_ACCUM_SECS *10 ); adapter->params.pci.vpd_cap_addr =pci_find_capability (adapter->pdev,PCI_CAP_ID_VPD ); +if (!adapter->params.pci.vpd_cap_addr) +return -ENODEV ; ret =get_vpd_params (adapter, &adapter->params.vpd);if (ret <0 )return ret;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 222/262 net: sparx5: Fix add vlan when invalid operation
In reply to Greg Kroah-HartmanFrom: Casper Andersson <[email protected]>
[ Upstream commit b3a34dc362c03215031b268fcc0b988e69490231 ]
Check if operation is valid before changing any settings in hardware. Otherwise it results in changes being made despite it not being a valid operation.
--- .../ethernet/microchip/sparx5/sparx5_vlan.c | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/net/ethernet/microchip/sparx5/sparx5_vlan.c +10 -10
@@ -58,16 +58,6 @@ int sparx5_vlan_vid_add(struct sparx5_port *port, u16 vid, bool pvid,struct sparx5 *sparx5 = port->sparx5;int ret; -/* Make the port a member of the VLAN */ -set_bit (port->portno, sparx5->vlan_mask[vid]); - ret =sparx5_vlant_set_mask (sparx5, vid); -if (ret) -return ret; - -/* Default ingress vlan classification */ -if (pvid) - port->pvid = vid; -/* Untagged egress vlan classification */ if (untagged && port->vid != vid) {if (port->vid) {
@@ -79,6 +69,16 @@ int sparx5_vlan_vid_add(struct sparx5_port *port, u16 vid, bool pvid, port->vid = vid; } +/* Make the port a member of the VLAN */ +set_bit (port->portno, sparx5->vlan_mask[vid]); + ret =sparx5_vlant_set_mask (sparx5, vid); +if (ret) +return ret; + +/* Default ingress vlan classification */ +if (pvid) + port->pvid = vid; +sparx5_vlan_port_apply (sparx5, port);return 0 ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 223/262 iavf: Refactor iavf state machine tracking
In reply to Greg Kroah-HartmanFrom: Mateusz Palczewski <[email protected]>
[ Upstream commit 45eebd62999d37d13568723524b99d828e0ce22c ]
Replace state changes of iavf state machine
with a method that also tracks the previous
state the machine was on.
This change is required for further work with
refactoring init and watchdog state machines.
Tracking of previous state would help us
recover iavf after failure has occurred.
--- drivers/net/ethernet/intel/iavf/iavf.h | 10 +++++ drivers/net/ethernet/intel/iavf/iavf_main.c | 37 ++++++++++--------- .../net/ethernet/intel/iavf/iavf_virtchnl.c | 2 +- 3 files changed, 31 insertions(+), 18 deletions(-)
drivers/net/ethernet/intel/iavf/iavf.h +10 -0
@@ -314,6 +314,7 @@ struct iavf_adapter {struct iavf_hw hw;/* defined in iavf_type.h */ enum iavf_state_t state; +enum iavf_state_t last_state;unsigned long crit_section;struct delayed_work watchdog_task;
@@ -395,6 +396,15 @@ struct iavf_device {extern char iavf_driver_name[];extern struct workqueue_struct *iavf_wq; +static inline void iavf_change_state (struct iavf_adapter *adapter, +enum iavf_state_t state) +{ +if (adapter->state != state) { + adapter->last_state = adapter->state; + adapter->state = state; + } +} +int iavf_up (struct iavf_adapter *adapter);void iavf_down (struct iavf_adapter *adapter);int iavf_process_config (struct iavf_adapter *adapter);
drivers/net/ethernet/intel/iavf/iavf_main.c +20 -17
@@ -990,7 +990,7 @@ static void iavf_configure(struct iavf_adapter *adapter)**/ static void iavf_up_complete (struct iavf_adapter *adapter) { - adapter->state = __IAVF_RUNNING; +iavf_change_state (adapter, __IAVF_RUNNING);clear_bit (__IAVF_VSI_DOWN, adapter->vsi.state);iavf_napi_enable_all (adapter);
@@ -1763,7 +1763,7 @@ static int iavf_startup(struct iavf_adapter *adapter)iavf_shutdown_adminq (hw); goto err; } - adapter->state = __IAVF_INIT_VERSION_CHECK; +iavf_change_state (adapter, __IAVF_INIT_VERSION_CHECK); err:return err; }
@@ -1787,7 +1787,7 @@ static int iavf_init_version_check(struct iavf_adapter *adapter)if (!iavf_asq_done (hw)) {dev_err (&pdev->dev,"Admin queue command never completed\n" );iavf_shutdown_adminq (hw); - adapter->state = __IAVF_STARTUP; +iavf_change_state (adapter, __IAVF_STARTUP); goto err; }
@@ -1810,8 +1810,7 @@ static int iavf_init_version_check(struct iavf_adapter *adapter) err); goto err; } - adapter->state = __IAVF_INIT_GET_RESOURCES; - +iavf_change_state (adapter, __IAVF_INIT_GET_RESOURCES); err:return err; }
@@ -1927,7 +1926,7 @@ static int iavf_init_get_resources(struct iavf_adapter *adapter)if (netdev->features &NETIF_F_GRO )dev_info (&pdev->dev,"GRO is enabled\n" ); - adapter->state = __IAVF_DOWN; +iavf_change_state (adapter, __IAVF_DOWN);set_bit (__IAVF_VSI_DOWN, adapter->vsi.state);rtnl_unlock ();
@@ -1975,7 +1974,7 @@ static void iavf_watchdog_task(struct work_struct *work) goto restart_watchdog;if (adapter->flags &IAVF_FLAG_PF_COMMS_FAILED ) - adapter->state = __IAVF_COMM_FAILED; +iavf_change_state (adapter, __IAVF_COMM_FAILED);switch (adapter->state) {case __IAVF_COMM_FAILED:
@@ -1986,7 +1985,7 @@ static void iavf_watchdog_task(struct work_struct *work)/* A chance for redemption! */ dev_err (&adapter->pdev->dev,"Hardware came out of reset. Attempting reinit.\n" ); - adapter->state = __IAVF_STARTUP; +iavf_change_state (adapter, __IAVF_STARTUP); adapter->flags &= ~IAVF_FLAG_PF_COMMS_FAILED ;queue_delayed_work (iavf_wq, &adapter->init_task,10 );mutex_unlock (&adapter->crit_lock);
@@ -2033,9 +2032,10 @@ static void iavf_watchdog_task(struct work_struct *work) goto restart_watchdog; } -/* check for hw reset */ +/* check for hw reset */ reg_val =rd32 (hw,IAVF_VF_ARQLEN1 ) &IAVF_VF_ARQLEN1_ARQENABLE_MASK ;if (!reg_val) { +iavf_change_state (adapter, __IAVF_RESETTING); adapter->flags |=IAVF_FLAG_RESET_PENDING ; adapter->aq_required =0 ; adapter->current_op =VIRTCHNL_OP_UNKNOWN ;
@@ -2115,7 +2115,7 @@ static void iavf_disable_vf(struct iavf_adapter *adapter) adapter->netdev->flags &= ~IFF_UP ;mutex_unlock (&adapter->crit_lock); adapter->flags &= ~IAVF_FLAG_RESET_PENDING ; - adapter->state = __IAVF_DOWN; +iavf_change_state (adapter, __IAVF_DOWN);wake_up (&adapter->down_waitqueue);dev_info (&adapter->pdev->dev,"Reset task did not complete, VF disabled\n" ); }
@@ -2226,7 +2226,7 @@ static void iavf_reset_task(struct work_struct *work) }iavf_irq_disable (adapter); - adapter->state = __IAVF_RESETTING; +iavf_change_state (adapter, __IAVF_RESETTING); adapter->flags &= ~IAVF_FLAG_RESET_PENDING ;/* free the Tx/Rx rings and descriptors, might be better to just
@@ -2320,11 +2320,14 @@ static void iavf_reset_task(struct work_struct *work)iavf_configure (adapter); +/* iavf_up_complete() will switch device back +* to __IAVF_RUNNING +*/ iavf_up_complete (adapter);iavf_irq_enable (adapter, true); }else { - adapter->state = __IAVF_DOWN; +iavf_change_state (adapter, __IAVF_DOWN);wake_up (&adapter->down_waitqueue); }mutex_unlock (&adapter->client_lock);
@@ -3334,7 +3337,7 @@ static int iavf_close(struct net_device *netdev) adapter->flags |=IAVF_FLAG_CLIENT_NEEDS_CLOSE ;iavf_down (adapter); - adapter->state = __IAVF_DOWN_PENDING; +iavf_change_state (adapter, __IAVF_DOWN_PENDING);iavf_free_traffic_irqs (adapter);mutex_unlock (&adapter->crit_lock);
@@ -3725,7 +3728,7 @@ static void iavf_init_task(struct work_struct *work) "Failed to communicate with PF; waiting before retry\n"); adapter->flags |=IAVF_FLAG_PF_COMMS_FAILED ;iavf_shutdown_adminq (hw); - adapter->state = __IAVF_STARTUP; +iavf_change_state (adapter, __IAVF_STARTUP);queue_delayed_work (iavf_wq, &adapter->init_task,HZ *5 ); goto out; }
@@ -3751,7 +3754,7 @@ static void iavf_shutdown(struct pci_dev *pdev)if (iavf_lock_timeout (&adapter->crit_lock,5000 ))dev_warn (&adapter->pdev->dev,"failed to acquire crit_lock in %s\n" , __FUNCTION__);/* Prevent the watchdog from running. */ - adapter->state = __IAVF_REMOVE; +iavf_change_state (adapter, __IAVF_REMOVE); adapter->aq_required =0 ;mutex_unlock (&adapter->crit_lock);
@@ -3824,7 +3827,7 @@ static int iavf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) hw->back = adapter; adapter->msg_enable =BIT (DEFAULT_DEBUG_LEVEL_SHIFT ) -1 ; - adapter->state = __IAVF_STARTUP; +iavf_change_state (adapter, __IAVF_STARTUP);/* Call save state here because it relies on the adapter struct. */ pci_save_state (pdev);
@@ -4000,7 +4003,7 @@ static void iavf_remove(struct pci_dev *pdev)dev_warn (&adapter->pdev->dev,"failed to acquire crit_lock in %s\n" , __FUNCTION__);/* Shut down all the garbage mashers on the detention level */ - adapter->state = __IAVF_REMOVE; +iavf_change_state (adapter, __IAVF_REMOVE); adapter->aq_required =0 ; adapter->flags &= ~IAVF_FLAG_REINIT_ITR_NEEDED ;iavf_free_all_tx_resources (adapter);
drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +1 -1
@@ -1776,7 +1776,7 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter,iavf_free_all_tx_resources (adapter);iavf_free_all_rx_resources (adapter);if (adapter->state == __IAVF_DOWN_PENDING) { - adapter->state = __IAVF_DOWN; +iavf_change_state (adapter, __IAVF_DOWN);wake_up (&adapter->down_waitqueue); }break ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 224/262 iavf: Add __IAVF_INIT_FAILED state
In reply to Greg Kroah-HartmanFrom: Mateusz Palczewski <[email protected]>
[ Upstream commit 59756ad6948be91d66867ce458083b820c59b8ba ]
This commit adds a new state, __IAVF_INIT_FAILED to the state machine.
Quoted 1 line
From now on initialization functions report errors not by returning an
error value, but by changing the state to indicate that something went wrong.
--- drivers/net/ethernet/intel/iavf/iavf.h | 1 + drivers/net/ethernet/intel/iavf/iavf_main.c | 35 ++++++++++++--------- 2 files changed, 21 insertions(+), 15 deletions(-)
drivers/net/ethernet/intel/iavf/iavf.h +1 -0
@@ -178,6 +178,7 @@ enum iavf_state_t { __IAVF_INIT_VERSION_CHECK,/* aq msg sent, awaiting reply */ __IAVF_INIT_GET_RESOURCES,/* aq msg sent, awaiting reply */ __IAVF_INIT_SW,/* got resources, setting up structs */ + __IAVF_INIT_FAILED,/* init failed, restarting procedure */ __IAVF_RESETTING,/* in reset */ __IAVF_COMM_FAILED, /* communication with PF failed *//* Below here, watchdog is running */
drivers/net/ethernet/intel/iavf/iavf_main.c +20 -15
@@ -14,7 +14,7 @@static int iavf_setup_all_tx_resources (struct iavf_adapter *adapter);static int iavf_setup_all_rx_resources (struct iavf_adapter *adapter);static int iavf_close (struct net_device *netdev); -static int iavf_init_get_resources (struct iavf_adapter *adapter); +static void iavf_init_get_resources (struct iavf_adapter *adapter);static int iavf_check_reset_complete (struct iavf_hw *hw);char iavf_driver_name[] ="iavf" ;
@@ -1722,9 +1722,9 @@ static int iavf_process_aq_command(struct iavf_adapter *adapter)* * Function process __IAVF_STARTUP driver state. * When success the state is changed to __IAVF_INIT_VERSION_CHECK -* when fails it returns -EAGAIN +* when fails the state is changed to __IAVF_INIT_FAILED **/ -static int iavf_startup (struct iavf_adapter *adapter) +static void iavf_startup (struct iavf_adapter *adapter) {struct pci_dev *pdev = adapter->pdev;struct iavf_hw *hw = &adapter->hw;
@@ -1764,8 +1764,9 @@ static int iavf_startup(struct iavf_adapter *adapter) goto err; }iavf_change_state (adapter, __IAVF_INIT_VERSION_CHECK); +return ; err: -return err; +iavf_change_state (adapter, __IAVF_INIT_FAILED); }/**
@@ -1774,9 +1775,9 @@ static int iavf_startup(struct iavf_adapter *adapter)* * Function process __IAVF_INIT_VERSION_CHECK driver state. * When success the state is changed to __IAVF_INIT_GET_RESOURCES -* when fails it returns -EAGAIN +* when fails the state is changed to __IAVF_INIT_FAILED **/ -static int iavf_init_version_check (struct iavf_adapter *adapter) +static void iavf_init_version_check (struct iavf_adapter *adapter) {struct pci_dev *pdev = adapter->pdev;struct iavf_hw *hw = &adapter->hw;
@@ -1811,8 +1812,9 @@ static int iavf_init_version_check(struct iavf_adapter *adapter) goto err; }iavf_change_state (adapter, __IAVF_INIT_GET_RESOURCES); +return ; err: -return err; +iavf_change_state (adapter, __IAVF_INIT_FAILED); }/**
@@ -1822,9 +1824,9 @@ static int iavf_init_version_check(struct iavf_adapter *adapter)* Function process __IAVF_INIT_GET_RESOURCES driver state and * finishes driver initialization procedure. * When success the state is changed to __IAVF_DOWN -* when fails it returns -EAGAIN +* when fails the state is changed to __IAVF_INIT_FAILED **/ -static int iavf_init_get_resources (struct iavf_adapter *adapter) +static void iavf_init_get_resources (struct iavf_adapter *adapter) {struct net_device *netdev = adapter->netdev;struct pci_dev *pdev = adapter->pdev;
@@ -1852,7 +1854,7 @@ static int iavf_init_get_resources(struct iavf_adapter *adapter)*/ iavf_shutdown_adminq (hw);dev_err (&pdev->dev,"Unable to get VF config due to PF error condition, not retrying\n" ); -return 0 ; +return ; }if (err) {dev_err (&pdev->dev,"Unable to get VF config (%d)\n" , err);
@@ -1944,7 +1946,7 @@ static int iavf_init_get_resources(struct iavf_adapter *adapter)else iavf_init_rss (adapter); -return err; +return ; err_mem:iavf_free_rss (adapter); err_register:
@@ -1955,7 +1957,7 @@ static int iavf_init_get_resources(struct iavf_adapter *adapter)kfree (adapter->vf_res); adapter->vf_res =NULL ; err: -return err; +iavf_change_state (adapter, __IAVF_INIT_FAILED); }/**
@@ -3704,15 +3706,18 @@ static void iavf_init_task(struct work_struct *work) }switch (adapter->state) {case __IAVF_STARTUP: -if (iavf_startup (adapter) <0 ) +iavf_startup (adapter); +if (adapter->state == __IAVF_INIT_FAILED) goto init_failed;break ;case __IAVF_INIT_VERSION_CHECK: -if (iavf_init_version_check (adapter) <0 ) +iavf_init_version_check (adapter); +if (adapter->state == __IAVF_INIT_FAILED) goto init_failed;break ;case __IAVF_INIT_GET_RESOURCES: -if (iavf_init_get_resources (adapter) <0 ) +iavf_init_get_resources (adapter); +if (adapter->state == __IAVF_INIT_FAILED) goto init_failed; goto out;default :
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 225/262 iavf: Combine init and watchdog state machines
In reply to Greg Kroah-HartmanFrom: Mateusz Palczewski <[email protected]>
[ Upstream commit 898ef1cb1cb24040c3e89263e02c605af70c776a ]
Use single state machine for driver initialization and for service initialized driver. The init state machine implemented in init_task() is merged into the watchdog_task(). The init_task() function is removed.
--- drivers/net/ethernet/intel/iavf/iavf.h | 1 - drivers/net/ethernet/intel/iavf/iavf_main.c | 136 ++++++++------------ 2 files changed, 57 insertions(+), 80 deletions(-)
drivers/net/ethernet/intel/iavf/iavf.h +0 -1
@@ -227,7 +227,6 @@ struct iavf_adapter {struct work_struct reset_task;struct work_struct adminq_task;struct delayed_work client_task; -struct delayed_work init_task;wait_queue_head_t down_waitqueue;struct iavf_q_vector *q_vectors;struct list_head vlan_filter_list;
drivers/net/ethernet/intel/iavf/iavf_main.c +57 -79
210 lines not on this page · raw message
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 226/262 iavf: Add trace while removing device
In reply to Greg Kroah-HartmanFrom: Jedrzej Jagielski <[email protected]>
[ Upstream commit bdb9e5c7aec73a7b8b5acab37587b6de1203e68d ]
Add kernel trace that device was removed.
Currently there is no such information.
I.e. Host admin removes a PCI device from a VM,
than on VM shall be info about the event.
This patch adds info log to iavf_remove function.
--- drivers/net/ethernet/intel/iavf/iavf_main.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/intel/iavf/iavf_main.c +1 -0
@@ -3985,6 +3985,7 @@ static void iavf_remove(struct pci_dev *pdev)if (iavf_lock_timeout (&adapter->crit_lock,5000 ))dev_warn (&adapter->pdev->dev,"failed to acquire crit_lock in %s\n" , __FUNCTION__); +dev_info (&adapter->pdev->dev,"Removing device\n" );/* Shut down all the garbage mashers on the detention level */ iavf_change_state (adapter, __IAVF_REMOVE); adapter->aq_required =0 ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 227/262 iavf: Rework mutexes for better synchronisation
In reply to Greg Kroah-HartmanFrom: Slawomir Laba <[email protected]>
[ Upstream commit fc2e6b3b132a907378f6af08356b105a4139c4fb ]
The driver used to crash in multiple spots when put to stress testing of the init, reset and remove paths.
The user would experience call traces or hangs when creating, resetting, removing VFs. Depending on the machines, the call traces are happening in random spots, like reset restoring resources racing with driver remove.
Make adapter->crit_lock mutex a mandatory lock for guarding the operations performed on all workqueues and functions dealing with resource allocation and disposal.
Make __IAVF_REMOVE a final state of the driver respected by workqueues that shall not requeue, when they fail to obtain the crit_lock.
Make the IRQ handler not to queue the new work for adminq_task when the __IAVF_REMOVE state is set.
--- drivers/net/ethernet/intel/iavf/iavf.h | 1 - drivers/net/ethernet/intel/iavf/iavf_main.c | 66 +++++++++++---------- 2 files changed, 36 insertions(+), 31 deletions(-)
drivers/net/ethernet/intel/iavf/iavf.h +0 -1
@@ -233,7 +233,6 @@ struct iavf_adapter {struct list_head mac_filter_list;struct mutex crit_lock;struct mutex client_lock; -struct mutex remove_lock;/* Lock to protect accesses to MAC and VLAN lists */ spinlock_t mac_vlan_list_lock;char misc_vector_name[IFNAMSIZ +9 ];
drivers/net/ethernet/intel/iavf/iavf_main.c +36 -30
146 lines not on this page · raw message
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 228/262 iavf: Add helper function to go from pci_dev to adapter
In reply to Greg Kroah-HartmanFrom: Karen Sornek <[email protected]>
[ Upstream commit 247aa001b72b6c8a89df9d108a2ec6f274a6b64d ]
Add helper function to go from pci_dev to adapter to make work simple - to go from a pci_dev to the adapter structure and make netdev assignment instead of having to go to the net_device then the adapter.
--- drivers/net/ethernet/intel/iavf/iavf_main.c | 24 +++++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +17 -7
@@ -51,6 +51,15 @@ MODULE_LICENSE("GPL v2");static const struct net_device_ops iavf_netdev_ops;struct workqueue_struct *iavf_wq; +/** +* iavf_pdev_to_adapter - go from pci_dev to adapter +* @pdev: pci_dev pointer +*/ +static struct iavf_adapter *iavf_pdev_to_adapter (struct pci_dev *pdev) +{ +return netdev_priv (pci_get_drvdata (pdev)); +} +/** * iavf_allocate_dma_mem_d - OS specific memory alloc for shared code * @hw: pointer to the HW structure
@@ -3739,8 +3748,8 @@ int iavf_process_config(struct iavf_adapter *adapter)**/ static void iavf_shutdown (struct pci_dev *pdev) { -struct net_device *netdev =pci_get_drvdata (pdev); -struct iavf_adapter *adapter =netdev_priv (netdev); +struct iavf_adapter *adapter =iavf_pdev_to_adapter (pdev); +struct net_device *netdev = adapter->netdev;netif_device_detach (netdev);
@@ -3923,10 +3932,11 @@ static int __maybe_unused iavf_suspend(struct device *dev_d)static int __maybe_unused iavf_resume (struct device *dev_d) {struct pci_dev *pdev =to_pci_dev (dev_d); -struct net_device *netdev =pci_get_drvdata (pdev); -struct iavf_adapter *adapter =netdev_priv (netdev); +struct iavf_adapter *adapter;u32 err; + adapter =iavf_pdev_to_adapter (pdev); +pci_set_master (pdev);rtnl_lock ();
@@ -3945,7 +3955,7 @@ static int __maybe_unused iavf_resume(struct device *dev_d)queue_work (iavf_wq, &adapter->reset_task); -netif_device_attach (netdev); +netif_device_attach (adapter->netdev);return err; }
@@ -3961,8 +3971,8 @@ static int __maybe_unused iavf_resume(struct device *dev_d)**/ static void iavf_remove (struct pci_dev *pdev) { -struct net_device *netdev =pci_get_drvdata (pdev); -struct iavf_adapter *adapter =netdev_priv (netdev); +struct iavf_adapter *adapter =iavf_pdev_to_adapter (pdev); +struct net_device *netdev = adapter->netdev;struct iavf_fdir_fltr *fdir, *fdirtmp;struct iavf_vlan_filter *vlf, *vlftmp;struct iavf_adv_rss *rss, *rsstmp;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 229/262 iavf: Fix kernel BUG in free_msi_irqs
In reply to Greg Kroah-HartmanFrom: Przemyslaw Patynowski <[email protected]>
[ Upstream commit 605ca7c5c670762e36ccb475cfa089d7ad0698e0 ]
Fix driver not freeing VF's traffic irqs, prior to calling pci_disable_msix in iavf_remove.
There were possible 2 erroneous states in which, iavf_close would not be called.
One erroneous state is fixed by allowing netdev to register, when state is already running. It was possible for VF adapter to enter state loop from running to resetting, where iavf_open would subsequently fail. If user would then unload driver/remove VF pci, iavf_close would not be called, as the netdev was not registered, leaving traffic pcis still allocated.
Fixed this by breaking loop, allowing netdev to open device when adapter state is __IAVF_RUNNING and it is not explicitily downed. Other possiblity is entering to iavf_remove from __IAVF_RESETTING state, where iavf_close would not free irqs, but just return 0. Fixed this by checking for last adapter state and then removing irqs.
Kernel panic: [ 2773.628585] kernel BUG at drivers/pci/msi.c:375! ... [ 2773.631567] RIP: 0010:free_msi_irqs+0x180/0x1b0 ... [ 2773.640939] Call Trace: [ 2773.641572] pci_disable_msix+0xf7/0x120 [ 2773.642224] iavf_reset_interrupt_capability.part.41+0x15/0x30 [iavf] [ 2773.642897] iavf_remove+0x12e/0x500 [iavf] [ 2773.643578] pci_device_remove+0x3b/0xc0 [ 2773.644266] device_release_driver_internal+0x103/0x1f0 [ 2773.644948] pci_stop_bus_device+0x69/0x90 [ 2773.645576] pci_stop_and_remove_bus_device+0xe/0x20 [ 2773.646215] pci_iov_remove_virtfn+0xba/0x120 [ 2773.646862] sriov_disable+0x2f/0xe0 [ 2773.647531] ice_free_vfs+0x2f8/0x350 [ice] [ 2773.648207] ice_sriov_configure+0x94/0x960 [ice] [ 2773.648883] ? _kstrtoull+0x3b/0x90 [ 2773.649560] sriov_numvfs_store+0x10a/0x190 [ 2773.650249] kernfs_fop_write+0x116/0x190 [ 2773.650948] vfs_write+0xa5/0x1a0 [ 2773.651651] ksys_write+0x4f/0xb0 [ 2773.652358] do_syscall_64+0x5b/0x1a0 [ 2773.653075] entry_SYSCALL_64_after_hwframe+0x65/0xca
--- drivers/net/ethernet/intel/iavf/iavf.h | 36 +++++++++++++++++++++ drivers/net/ethernet/intel/iavf/iavf_main.c | 20 ++++++++++++ 2 files changed, 56 insertions(+)
drivers/net/ethernet/intel/iavf/iavf.h +36 -0
@@ -395,6 +395,38 @@ struct iavf_device {extern char iavf_driver_name[];extern struct workqueue_struct *iavf_wq; +static inline const char *iavf_state_str (enum iavf_state_t state) +{ +switch (state) { +case __IAVF_STARTUP: +return "__IAVF_STARTUP" ; +case __IAVF_REMOVE: +return "__IAVF_REMOVE" ; +case __IAVF_INIT_VERSION_CHECK: +return "__IAVF_INIT_VERSION_CHECK" ; +case __IAVF_INIT_GET_RESOURCES: +return "__IAVF_INIT_GET_RESOURCES" ; +case __IAVF_INIT_SW: +return "__IAVF_INIT_SW" ; +case __IAVF_INIT_FAILED: +return "__IAVF_INIT_FAILED" ; +case __IAVF_RESETTING: +return "__IAVF_RESETTING" ; +case __IAVF_COMM_FAILED: +return "__IAVF_COMM_FAILED" ; +case __IAVF_DOWN: +return "__IAVF_DOWN" ; +case __IAVF_DOWN_PENDING: +return "__IAVF_DOWN_PENDING" ; +case __IAVF_TESTING: +return "__IAVF_TESTING" ; +case __IAVF_RUNNING: +return "__IAVF_RUNNING" ; +default : +return "__IAVF_UNKNOWN_STATE" ; + } +} +static inline void iavf_change_state (struct iavf_adapter *adapter,enum iavf_state_t state) {
@@ -402,6 +434,10 @@ static inline void iavf_change_state(struct iavf_adapter *adapter, adapter->last_state = adapter->state; adapter->state = state; } +dev_dbg (&adapter->pdev->dev, +"state transition from:%s to:%s\n" , +iavf_state_str (adapter->last_state), +iavf_state_str (adapter->state)); }int iavf_up (struct iavf_adapter *adapter);
drivers/net/ethernet/intel/iavf/iavf_main.c +20 -0
@@ -3325,6 +3325,13 @@ static int iavf_open(struct net_device *netdev) goto err_unlock; } +if (adapter->state == __IAVF_RUNNING && + !test_bit (__IAVF_VSI_DOWN, adapter->vsi.state)) { +dev_dbg (&adapter->pdev->dev,"VF is already open.\n" ); + err =0 ; + goto err_unlock; + } +/* allocate transmit descriptors */ err =iavf_setup_all_tx_resources (adapter);if (err)
@@ -3972,6 +3979,7 @@ static int __maybe_unused iavf_resume(struct device *dev_d)static void iavf_remove (struct pci_dev *pdev) {struct iavf_adapter *adapter =iavf_pdev_to_adapter (pdev); +enum iavf_state_t prev_state = adapter->last_state;struct net_device *netdev = adapter->netdev;struct iavf_fdir_fltr *fdir, *fdirtmp;struct iavf_vlan_filter *vlf, *vlftmp;
@@ -4013,9 +4021,21 @@ static void iavf_remove(struct pci_dev *pdev) adapter->aq_required =0 ; adapter->flags &= ~IAVF_FLAG_REINIT_ITR_NEEDED ; +iavf_free_all_tx_resources (adapter);iavf_free_all_rx_resources (adapter);iavf_free_misc_irq (adapter); + +/* In case we enter iavf_remove from erroneous state, free traffic irqs +* here, so as to not cause a kernel crash, when calling +* iavf_reset_interrupt_capability. +*/ +if ((adapter->last_state == __IAVF_RESETTING && + prev_state != __IAVF_DOWN) || + (adapter->last_state == __IAVF_RUNNING && + !(netdev->flags &IFF_UP ))) +iavf_free_traffic_irqs (adapter); +iavf_reset_interrupt_capability (adapter);iavf_free_q_vectors (adapter);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 230/262 iavf: Add waiting so the port is initialized in remove
In reply to Greg Kroah-HartmanFrom: Slawomir Laba <[email protected]>
[ Upstream commit 974578017fc1fdd06cea8afb9dfa32602e8529ed ]
There exist races when port is being configured and remove is triggered.
unregister_netdev is not and can't be called under crit_lock mutex since it is calling ndo_stop -> iavf_close which requires this lock. Depending on init state the netdev could be still unregistered so unregister_netdev never cleans up, when shortly after that the device could become registered.
Make iavf_remove wait until port finishes initialization. All critical state changes are atomic (under crit_lock). Crashes that come from iavf_reset_interrupt_capability and iavf_free_traffic_irqs should now be solved in a graceful manner.
--- drivers/net/ethernet/intel/iavf/iavf_main.c | 27 ++++++++++++--------- 1 file changed, 16 insertions(+), 11 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +16 -11
@@ -3979,7 +3979,6 @@ static int __maybe_unused iavf_resume(struct device *dev_d)static void iavf_remove (struct pci_dev *pdev) {struct iavf_adapter *adapter =iavf_pdev_to_adapter (pdev); -enum iavf_state_t prev_state = adapter->last_state;struct net_device *netdev = adapter->netdev;struct iavf_fdir_fltr *fdir, *fdirtmp;struct iavf_vlan_filter *vlf, *vlftmp;
@@ -3989,6 +3988,22 @@ static void iavf_remove(struct pci_dev *pdev)struct iavf_hw *hw = &adapter->hw;int err; +/* Wait until port initialization is complete. +* There are flows where register/unregister netdev may race. +*/ +while (1 ) { +mutex_lock (&adapter->crit_lock); +if (adapter->state == __IAVF_RUNNING || + adapter->state == __IAVF_DOWN) { +mutex_unlock (&adapter->crit_lock); +break ; + } + +mutex_unlock (&adapter->crit_lock); +usleep_range (500 ,1000 ); + } +cancel_delayed_work_sync (&adapter->watchdog_task); +if (adapter->netdev_registered) {unregister_netdev (netdev); adapter->netdev_registered = false;
@@ -4026,16 +4041,6 @@ static void iavf_remove(struct pci_dev *pdev)iavf_free_all_rx_resources (adapter);iavf_free_misc_irq (adapter); -/* In case we enter iavf_remove from erroneous state, free traffic irqs -* here, so as to not cause a kernel crash, when calling -* iavf_reset_interrupt_capability. -*/ -if ((adapter->last_state == __IAVF_RESETTING && - prev_state != __IAVF_DOWN) || - (adapter->last_state == __IAVF_RUNNING && - !(netdev->flags &IFF_UP ))) -iavf_free_traffic_irqs (adapter); -iavf_reset_interrupt_capability (adapter);iavf_free_q_vectors (adapter);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 231/262 iavf: Fix init state closure on remove
In reply to Greg Kroah-HartmanFrom: Slawomir Laba <[email protected]>
[ Upstream commit 3ccd54ef44ebfa0792c5441b6d9c86618f3378d1 ]
When init states of the adapter work, the errors like lack of communication with the PF might hop in. If such events occur the driver restores previous states in order to retry initialization in a proper way. When remove task kicks in, this situation could lead to races with unregistering the netdevice as well as resources cleanup. With the commit introducing the waiting in remove for init to complete, this problem turns into an endless waiting if init never recovers from errors.
Introduce __IAVF_IN_REMOVE_TASK bit to indicate that the remove thread has started.
Make __IAVF_COMM_FAILED adapter state respect the __IAVF_IN_REMOVE_TASK bit and set the __IAVF_INIT_FAILED state and return without any action instead of trying to recover.
Make __IAVF_INIT_FAILED adapter state respect the __IAVF_IN_REMOVE_TASK bit and return without any further actions.
Make the loop in the remove handler break when adapter has __IAVF_INIT_FAILED state set.
--- drivers/net/ethernet/intel/iavf/iavf.h | 4 ++++ drivers/net/ethernet/intel/iavf/iavf_main.c | 24 ++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/iavf/iavf.h +4 -0
@@ -188,6 +188,10 @@ enum iavf_state_t { __IAVF_RUNNING, /* opened, working */ }; +enum iavf_critical_section_t { + __IAVF_IN_REMOVE_TASK,/* device being removed */ +}; +#define IAVF_CLOUD_FIELD_OMAC 0x01#define IAVF_CLOUD_FIELD_IMAC 0x02#define IAVF_CLOUD_FIELD_IVLAN 0x04
drivers/net/ethernet/intel/iavf/iavf_main.c +23 -1
@@ -2019,6 +2019,15 @@ static void iavf_watchdog_task(struct work_struct *work) msecs_to_jiffies(1));return ;case __IAVF_INIT_FAILED: +if (test_bit (__IAVF_IN_REMOVE_TASK, + &adapter->crit_section)) { +/* Do not update the state and do not reschedule +* watchdog task, iavf_remove should handle this state +* as it can loop forever +*/ +mutex_unlock (&adapter->crit_lock); +return ; + }if (++adapter->aq_wait_count >IAVF_AQ_MAX_ERR ) {dev_err (&adapter->pdev->dev,"Failed to communicate with PF; waiting before retry\n" );
@@ -2035,6 +2044,17 @@ static void iavf_watchdog_task(struct work_struct *work)queue_delayed_work (iavf_wq, &adapter->watchdog_task,HZ );return ;case __IAVF_COMM_FAILED: +if (test_bit (__IAVF_IN_REMOVE_TASK, + &adapter->crit_section)) { +/* Set state to __IAVF_INIT_FAILED and perform remove +* steps. Remove IAVF_FLAG_PF_COMMS_FAILED so the task +* doesn't bring the state back to __IAVF_COMM_FAILED. +*/ +iavf_change_state (adapter, __IAVF_INIT_FAILED); + adapter->flags &= ~IAVF_FLAG_PF_COMMS_FAILED ; +mutex_unlock (&adapter->crit_lock); +return ; + } reg_val =rd32 (hw,IAVF_VFGEN_RSTAT ) &IAVF_VFGEN_RSTAT_VFR_STATE_MASK ; if (reg_val == VIRTCHNL_VFR_VFACTIVE ||
@@ -3988,13 +4008,15 @@ static void iavf_remove(struct pci_dev *pdev)struct iavf_hw *hw = &adapter->hw;int err; +set_bit (__IAVF_IN_REMOVE_TASK, &adapter->crit_section);/* Wait until port initialization is complete. * There are flows where register/unregister netdev may race. */ while (1 ) {mutex_lock (&adapter->crit_lock);if (adapter->state == __IAVF_RUNNING || - adapter->state == __IAVF_DOWN) { + adapter->state == __IAVF_DOWN || + adapter->state == __IAVF_INIT_FAILED) {mutex_unlock (&adapter->crit_lock);break ; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 232/262 iavf: Fix locking for VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS
In reply to Greg Kroah-HartmanFrom: Slawomir Laba <[email protected]>
[ Upstream commit 0579fafd37fb7efe091f0e6c8ccf968864f40f3e ]
iavf_virtchnl_completion is called under crit_lock but when the code for VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS is called, this lock is released in order to obtain rtnl_lock to avoid ABBA deadlock with unregister_netdev.
Along with the new way iavf_remove behaves, there exist many risks related to the lock release and attmepts to regrab it. The driver faces crashes related to races between unregister_netdev and netdev_update_features. Yet another risk is that the driver could already obtain the crit_lock in order to destroy it and iavf_virtchnl_completion could crash or block forever.
Make iavf_virtchnl_completion never relock crit_lock in it's call paths.
Extract rtnl_lock locking logic to the driver for unregister_netdev in order to set the netdev_registered flag inside the lock.
Introduce a new flag that will inform adminq_task to perform the code from VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS right after it finishes processing messages. Guard this code with remove flags so it's never called when the driver is in remove state.
--- drivers/net/ethernet/intel/iavf/iavf.h | 1 + drivers/net/ethernet/intel/iavf/iavf_main.c | 16 +++++++++++++++- drivers/net/ethernet/intel/iavf/iavf_virtchnl.c | 14 +------------- 3 files changed, 17 insertions(+), 14 deletions(-)
drivers/net/ethernet/intel/iavf/iavf.h +1 -0
@@ -274,6 +274,7 @@ struct iavf_adapter {#define IAVF_FLAG_LEGACY_RX BIT(15)#define IAVF_FLAG_REINIT_ITR_NEEDED BIT(16)#define IAVF_FLAG_QUEUES_DISABLED BIT(17) +#define IAVF_FLAG_SETUP_NETDEV_FEATURES BIT(18)/* duplicates for common code */ #define IAVF_FLAG_DCB_ENABLED 0/* flags for admin queue service task */
drivers/net/ethernet/intel/iavf/iavf_main.c +15 -1
@@ -2463,6 +2463,18 @@ static void iavf_adminq_task(struct work_struct *work) }while (pending);mutex_unlock (&adapter->crit_lock); +if ((adapter->flags &IAVF_FLAG_SETUP_NETDEV_FEATURES )) { +if (adapter->netdev_registered || + !test_bit (__IAVF_IN_REMOVE_TASK, &adapter->crit_section)) { +struct net_device *netdev = adapter->netdev; + +rtnl_lock (); +netdev_update_features (netdev); +rtnl_unlock (); + } + + adapter->flags &= ~IAVF_FLAG_SETUP_NETDEV_FEATURES ; + }if ((adapter->flags & (IAVF_FLAG_RESET_PENDING |IAVF_FLAG_RESET_NEEDED )) || adapter->state == __IAVF_RESETTING)
@@ -4027,8 +4039,10 @@ static void iavf_remove(struct pci_dev *pdev)cancel_delayed_work_sync (&adapter->watchdog_task);if (adapter->netdev_registered) { -unregister_netdev (netdev); +rtnl_lock (); +unregister_netdevice (netdev); adapter->netdev_registered = false; +rtnl_unlock (); }if (CLIENT_ALLOWED (adapter)) { err =iavf_lan_del_device (adapter);
drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +1 -13
@@ -1752,19 +1752,7 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter,spin_unlock_bh (&adapter->mac_vlan_list_lock);iavf_process_config (adapter); - -/* unlock crit_lock before acquiring rtnl_lock as other -* processes holding rtnl_lock could be waiting for the same -* crit_lock -*/ -mutex_unlock (&adapter->crit_lock); -rtnl_lock (); -netdev_update_features (adapter->netdev); -rtnl_unlock (); -if (iavf_lock_timeout (&adapter->crit_lock,10000 )) -dev_warn (&adapter->pdev->dev,"failed to acquire crit_lock in %s\n" , - __FUNCTION__); - + adapter->flags |=IAVF_FLAG_SETUP_NETDEV_FEATURES ; }break ;case VIRTCHNL_OP_ENABLE_QUEUES :
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 233/262 iavf: Fix race in init state
In reply to Greg Kroah-HartmanFrom: Slawomir Laba <[email protected]>
[ Upstream commit a472eb5cbaebb5774672c565e024336c039e9128 ]
When iavf_init_version_check sends VIRTCHNL_OP_GET_VF_RESOURCES message, the driver will wait for the response after requeueing the watchdog task in iavf_init_get_resources call stack. The logic is implemented this way that iavf_init_get_resources has to be called in order to allocate adapter->vf_res. It is polling for the AQ response in iavf_get_vf_config function. Expect a call trace from kernel when adminq_task worker handles this message first. adapter->vf_res will be NULL in iavf_virtchnl_completion.
Make the watchdog task not queue the adminq_task if the init process is not finished yet.
--- drivers/net/ethernet/intel/iavf/iavf_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +2 -1
@@ -2125,7 +2125,8 @@ static void iavf_watchdog_task(struct work_struct *work)schedule_delayed_work (&adapter->client_task,msecs_to_jiffies (5 ));mutex_unlock (&adapter->crit_lock); restart_watchdog: -queue_work (iavf_wq, &adapter->adminq_task); +if (adapter->state >= __IAVF_DOWN) +queue_work (iavf_wq, &adapter->adminq_task);if (adapter->aq_required)queue_delayed_work (iavf_wq, &adapter->watchdog_task,msecs_to_jiffies (20 ));
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 234/262 iavf: Fix __IAVF_RESETTING state usage
In reply to Greg Kroah-HartmanFrom: Slawomir Laba <[email protected]>
[ Upstream commit 14756b2ae265d526b8356e86729090b01778fdf6 ]
The setup of __IAVF_RESETTING state in watchdog task had no effect and could lead to slow resets in the driver as the task for __IAVF_RESETTING state only requeues watchdog. Till now the __IAVF_RESETTING was interpreted by reset task as running state which could lead to errors with allocating and resources disposal.
Make watchdog_task queue the reset task when it's necessary. Do not update the state to __IAVF_RESETTING so the reset task knows exactly what is the current state of the adapter.
--- drivers/net/ethernet/intel/iavf/iavf_main.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +6 -7
@@ -1073,8 +1073,7 @@ void iavf_down(struct iavf_adapter *adapter) rss->state =IAVF_ADV_RSS_DEL_REQUEST ;spin_unlock_bh (&adapter->adv_rss_lock); -if (!(adapter->flags &IAVF_FLAG_PF_COMMS_FAILED ) && - adapter->state != __IAVF_RESETTING) { +if (!(adapter->flags &IAVF_FLAG_PF_COMMS_FAILED )) {/* cancel any current operation */ adapter->current_op =VIRTCHNL_OP_UNKNOWN ;/* Schedule operations to close down the HW. Don't wait
@@ -1992,11 +1991,12 @@ static void iavf_watchdog_task(struct work_struct *work)if (adapter->flags &IAVF_FLAG_PF_COMMS_FAILED )iavf_change_state (adapter, __IAVF_COMM_FAILED); -if (adapter->flags &IAVF_FLAG_RESET_NEEDED && - adapter->state != __IAVF_RESETTING) { -iavf_change_state (adapter, __IAVF_RESETTING); +if (adapter->flags &IAVF_FLAG_RESET_NEEDED ) { adapter->aq_required =0 ; adapter->current_op =VIRTCHNL_OP_UNKNOWN ; +mutex_unlock (&adapter->crit_lock); +queue_work (iavf_wq, &adapter->reset_task); +return ; }switch (adapter->state) {
@@ -2290,8 +2290,7 @@ static void iavf_reset_task(struct work_struct *work)* ndo_open() returning, so we can't assume it means all our open * tasks have finished, since we're not holding the rtnl_lock here. */ - running = ((adapter->state == __IAVF_RUNNING) || - (adapter->state == __IAVF_RESETTING)); + running = adapter->state == __IAVF_RUNNING;if (running) {netif_carrier_off (netdev);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 235/262 drm/i915/guc/slpc: Correct the param count for unset param
In reply to Greg Kroah-HartmanFrom: Vinay Belgaumkar <[email protected]>
[ Upstream commit 1b279f6ad467535c3b8a66b4edefaca2cdd5bdc3 ]
SLPC unset param H2G only needs one parameter - the id of the param.
--- drivers/gpu/drm/i915/gt/uc/intel_guc_slpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/gt/uc/intel_guc_slpc.c +1 -1
@@ -133,7 +133,7 @@ static int guc_action_slpc_unset_param(struct intel_guc *guc, u8 id) {u32 request[] = {GUC_ACTION_HOST2GUC_PC_SLPC_REQUEST , -SLPC_EVENT (SLPC_EVENT_PARAMETER_UNSET ,2 ), +SLPC_EVENT (SLPC_EVENT_PARAMETER_UNSET ,1 ), id, };
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 236/262 drm/bridge: ti-sn65dsi86: Properly undo autosuspend
In reply to Greg Kroah-HartmanFrom: Douglas Anderson <[email protected]>
[ Upstream commit 26d3474348293dc752c55fe6d41282199f73714c ]
The PM Runtime docs say:
Drivers in ->remove() callback should undo the runtime PM changes done in ->probe(). Usually this means calling pm_runtime_disable(), pm_runtime_dont_use_autosuspend() etc.
We weren't doing that for autosuspend. Let's do it.
--- drivers/gpu/drm/bridge/ti-sn65dsi86.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/ti-sn65dsi86.c +3 -2
@@ -1473,6 +1473,7 @@ static inline void ti_sn_gpio_unregister(void) {}static void ti_sn65dsi86_runtime_disable (void *data) { +pm_runtime_dont_use_autosuspend (data);pm_runtime_disable (data); }
@@ -1532,11 +1533,11 @@ static int ti_sn65dsi86_probe(struct i2c_client *client, "failed to get reference clock\n");pm_runtime_enable (dev); +pm_runtime_set_autosuspend_delay (pdata->dev,500 ); +pm_runtime_use_autosuspend (pdata->dev); ret =devm_add_action_or_reset (dev, ti_sn65dsi86_runtime_disable, dev);if (ret)return ret; -pm_runtime_set_autosuspend_delay (pdata->dev,500 ); -pm_runtime_use_autosuspend (pdata->dev);ti_sn65dsi86_debugfs_init (pdata);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 237/262 e1000e: Fix possible HW unit hang after an s0ix exit
In reply to Greg Kroah-HartmanFrom: Sasha Neftin <[email protected]>
[ Upstream commit 1866aa0d0d6492bc2f8d22d0df49abaccf50cddd ]
Disable the OEM bit/Gig Disable/restart AN impact and disable the PHY LAN connected device (LCD) reset during power management flows. This fixes possible HW unit hangs on the s0ix exit on some corporate ADL platforms.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=214821
--- drivers/net/ethernet/intel/e1000e/hw.h | 1 + drivers/net/ethernet/intel/e1000e/ich8lan.c | 4 ++++ drivers/net/ethernet/intel/e1000e/ich8lan.h | 1 + drivers/net/ethernet/intel/e1000e/netdev.c | 26 +++++++++++++++++++++ 4 files changed, 32 insertions(+)
drivers/net/ethernet/intel/e1000e/hw.h +1 -0
@@ -630,6 +630,7 @@ struct e1000_phy_info {bool disable_polarity_correction;bool is_mdix;bool polarity_correction; +bool reset_disable;bool speed_downgraded;bool autoneg_wait_to_complete; };
drivers/net/ethernet/intel/e1000e/ich8lan.c +4 -0
@@ -2050,6 +2050,10 @@ static s32 e1000_check_reset_block_ich8lan(struct e1000_hw *hw)bool blocked = false;int i =0 ; +/* Check the PHY (LCD) reset flag */ +if (hw->phy.reset_disable) +return true; +while ((blocked = !(er32 (FWSM ) &E1000_ICH_FWSM_RSPCIPHY )) && (i++ <30 ))usleep_range (10000 ,11000 );
drivers/net/ethernet/intel/e1000e/ich8lan.h +1 -0
@@ -271,6 +271,7 @@#define I217_CGFREG_ENABLE_MTA_RESET 0x0002#define I217_MEMPWR PHY_REG(772, 26)#define I217_MEMPWR_DISABLE_SMB_RELEASE 0x0010 +#define I217_MEMPWR_MOEM 0x1000/* Receive Address Initial CRC Calculation */ #define E1000_PCH_RAICC (_n) (0x05F50 + ((_n) * 4))
drivers/net/ethernet/intel/e1000e/netdev.c +26 -0
@@ -6992,8 +6992,21 @@ static __maybe_unused int e1000e_pm_suspend(struct device *dev)struct net_device *netdev =pci_get_drvdata (to_pci_dev (dev));struct e1000_adapter *adapter =netdev_priv (netdev);struct pci_dev *pdev =to_pci_dev (dev); +struct e1000_hw *hw = &adapter->hw; +u16 phy_data;int rc; +if (er32 (FWSM ) &E1000_ICH_FWSM_FW_VALID && + hw->mac.type >= e1000_pch_adp) { +/* Mask OEM Bits / Gig Disable / Restart AN (772_26[12] = 1) */ +e1e_rphy (hw,I217_MEMPWR , &phy_data); + phy_data |=I217_MEMPWR_MOEM ; +e1e_wphy (hw,I217_MEMPWR , phy_data); + +/* Disable LCD reset */ + hw->phy.reset_disable = true; + } +e1000e_flush_lpic (pdev);e1000e_pm_freeze (dev);
@@ -7015,6 +7028,8 @@ static __maybe_unused int e1000e_pm_resume(struct device *dev)struct net_device *netdev =pci_get_drvdata (to_pci_dev (dev));struct e1000_adapter *adapter =netdev_priv (netdev);struct pci_dev *pdev =to_pci_dev (dev); +struct e1000_hw *hw = &adapter->hw; +u16 phy_data;int rc;/* Introduce S0ix implementation */
@@ -7025,6 +7040,17 @@ static __maybe_unused int e1000e_pm_resume(struct device *dev)if (rc)return rc; +if (er32 (FWSM ) &E1000_ICH_FWSM_FW_VALID && + hw->mac.type >= e1000_pch_adp) { +/* Unmask OEM Bits / Gig Disable / Restart AN 772_26[12] = 0 */ +e1e_rphy (hw,I217_MEMPWR , &phy_data); + phy_data &= ~I217_MEMPWR_MOEM ; +e1e_wphy (hw,I217_MEMPWR , phy_data); + +/* Enable LCD reset */ + hw->phy.reset_disable = false; + } +return e1000e_pm_thaw (dev); }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 238/262 MIPS: ralink: mt7621: use bitwise NOT instead of logical
In reply to Greg Kroah-HartmanFrom: Ilya Lipnitskiy <[email protected]>
[ Upstream commit 5d8965704fe5662e2e4a7e4424a2cbe53e182670 ]
It was the intention to reverse the bits, not make them all zero by using logical NOT operator.
--- arch/mips/ralink/mt7621.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/ralink/mt7621.c +1 -1
@@ -38,7 +38,7 @@ static bool __init mt7621_addr_wraparound_test(phys_addr_t size)__raw_writel (MT7621_MEM_TEST_PATTERN , dm);if (__raw_readl (dm) !=__raw_readl (dm + size))return false; -__raw_writel (!MT7621_MEM_TEST_PATTERN , dm); +__raw_writel (~MT7621_MEM_TEST_PATTERN , dm);return __raw_readl (dm) ==__raw_readl (dm + size); }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 239/262 nl80211: Handle nla_memdup failures in handle_nan_filter
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit 6ad27f522cb3b210476daf63ce6ddb6568c0508b ]
As there's potential for failure of the nla_memdup(), check the return value.
--- net/wireless/nl80211.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
net/wireless/nl80211.c +12 -0
@@ -13177,6 +13177,9 @@ static int handle_nan_filter(struct nlattr *attr_filter, i =0 ;nla_for_each_nested (attr, attr_filter, rem) { filter[i].filter =nla_memdup (attr,GFP_KERNEL ); +if (!filter[i].filter) + goto err; + filter[i].len =nla_len (attr); i++; }
@@ -13189,6 +13192,15 @@ static int handle_nan_filter(struct nlattr *attr_filter, }return 0 ; + +err: + i =0 ; +nla_for_each_nested (attr, attr_filter, rem) { +kfree (filter[i].filter); + i++; + } +kfree (filter); +return -ENOMEM ; } static int nl80211_nan_add_func(struct sk_buff *skb,
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 240/262 drm/amdgpu: fix suspend/resume hang regression
In reply to Greg Kroah-HartmanFrom: Qiang Yu <[email protected]>
[ Upstream commit f1ef17011c765495c876fa75435e59eecfdc1ee4 ]
Regression has been reported that suspend/resume may hang with the previous vm ready check commit.
So bring back the evicted list check as a temp fix.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -1
@@ -777,7 +777,8 @@ bool amdgpu_vm_ready(struct amdgpu_vm *vm)amdgpu_vm_eviction_lock (vm); ret = !vm->evicting;amdgpu_vm_eviction_unlock (vm); -return ret; + +return ret &&list_empty (&vm->evicted); }/**
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 241/262 net: dcb: disable softirqs in dcbnl_flush_dev()
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit 10b6bb62ae1a49ee818fc479cf57b8900176773e ]
Ido Schimmel points out that since commit 52cff74eef5d ("dcbnl : Disable software interrupts before taking dcb_lock"), the DCB API can be called by drivers from softirq context.
One such in-tree example is the chelsio cxgb4 driver:dcb_rpl
-> cxgb4_dcb_handle_fw_update
-> dcb_ieee_setapp
If the firmware for this driver happened to send an event which resulted in a call to dcb_ieee_setapp() at the exact same time as another DCB-enabled interface was unregistering on the same CPU, the softirq would deadlock, because the interrupted process was already holding the dcb_lock in dcbnl_flush_dev().
Fix this unlikely event by using spin_lock_bh() in dcbnl_flush_dev() as in the rest of the dcbnl code.
--- net/dcb/dcbnl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/dcb/dcbnl.c +2 -2
@@ -2077,7 +2077,7 @@ static void dcbnl_flush_dev(struct net_device *dev) {struct dcb_app_type *itr, *tmp; -spin_lock (&dcb_lock); +spin_lock_bh (&dcb_lock);list_for_each_entry_safe (itr, tmp, &dcb_app_list, list) {if (itr->ifindex == dev->ifindex) {
@@ -2086,7 +2086,7 @@ static void dcbnl_flush_dev(struct net_device *dev) } } -spin_unlock (&dcb_lock); +spin_unlock_bh (&dcb_lock); } static int dcbnl_netdevice_event(struct notifier_block *nb,
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 242/262 selftests: mlxsw: resource_scale: Fix return value
In reply to Greg Kroah-HartmanFrom: Amit Cohen <[email protected]>
[ Upstream commit 196f9bc050cbc5085b4cbb61cce2efe380bc66d0 ]
The test runs several test cases and is supposed to return an error in case at least one of them failed.
Currently, the check of the return value of each test case is in the wrong place, which can result in the wrong return value. For example:
# TESTS='tc_police' ./resource_scale.sh
TEST: 'tc_police' [default] 968 [FAIL]
tc police offload count failed
Error: mlxsw_spectrum: Failed to allocate policer index. We have an error talking to the kernel
Command failed /tmp/tmp.i7Oc5HwmXY:969
TEST: 'tc_police' [default] overflow 969 [ OK ]
...
TEST: 'tc_police' [ipv4_max] overflow 969 [ OK ]
$ echo $? 0
Fix this by moving the check to be done after each test case.
--- .../selftests/drivers/net/mlxsw/spectrum/resource_scale.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/drivers/net/mlxsw/spectrum/resource_scale.sh +1 -1
@@ -50,8 +50,8 @@ for current_test in ${TESTS:-$ALL_TESTS}; do else log_test "'$current_test' [$profile] overflow $target" fi + RET_FIN=$(( RET_FIN || RET )) done - RET_FIN=$(( RET_FIN || RET )) done done current_test=""
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 243/262 net: stmmac: perserve TX and RX coalesce value during XDP setup
In reply to Greg Kroah-HartmanFrom: Ong Boon Leong <[email protected]>
commit 61da6ac715700bcfeef50d187e15c6cc7c9d079b upstream.
When XDP program is loaded, it is desirable that the previous TX and RX coalesce values are not re-inited to its default value. This prevents unnecessary re-configurig the coalesce values that were working fine before.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +3 -2
@@ -6579,6 +6579,9 @@ int stmmac_xdp_open(struct net_device *d tx_q->tx_tail_addr = tx_q->dma_tx_phy;stmmac_set_tx_tail_ptr (priv, priv->ioaddr, tx_q->tx_tail_addr, chan); + +hrtimer_init (&tx_q->txtimer,CLOCK_MONOTONIC ,HRTIMER_MODE_REL ); + tx_q->txtimer.function = stmmac_tx_timer; }/* Enable the MAC Rx/Tx */
@@ -6587,8 +6590,6 @@ int stmmac_xdp_open(struct net_device *d/* Start Rx & Tx DMA Channels */ stmmac_start_all_dma (priv); -stmmac_init_coalesce (priv); - ret =stmmac_request_irq (dev);if (ret) goto irq_error;
Greg Kroah-Hartman
maintainerPATCH 244/262 iavf: do not override the adapter state in the watchdog task (again)
In reply to Greg Kroah-HartmanFrom: Stefan Assmann <[email protected]>
commit fe523d7c9a8332855376ad5eb1aa301091129ba4 upstream.
The watchdog task incorrectly changes the state to __IAVF_RESETTING, instead of letting the reset task take care of that. This was already resolved by commit 22c8fd71d3a5 ("iavf: do not override the adapter state in the watchdog task") but the problem was reintroduced by the recent code refactoring in commit 45eebd62999d ("iavf: Refactor iavf state machine tracking").
--- drivers/net/ethernet/intel/iavf/iavf_main.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +0 -1
@@ -2110,7 +2110,6 @@ static void iavf_watchdog_task(struct wo/* check for hw reset */ reg_val =rd32 (hw,IAVF_VF_ARQLEN1 ) &IAVF_VF_ARQLEN1_ARQENABLE_MASK ;if (!reg_val) { -iavf_change_state (adapter, __IAVF_RESETTING); adapter->flags |=IAVF_FLAG_RESET_PENDING ; adapter->aq_required =0 ; adapter->current_op =VIRTCHNL_OP_UNKNOWN ;
Greg Kroah-Hartman
maintainerPATCH 245/262 iavf: missing unlocks in iavf_watchdog_task()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
commit bc2f39a6252ee40d9bfc2743d4437d420aec5f6e upstream.
This code was re-organized and there some unlocks missing now.
--- drivers/net/ethernet/intel/iavf/iavf_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +2 -2
@@ -2071,6 +2071,7 @@ static void iavf_watchdog_task(struct wo } adapter->aq_required =0 ; adapter->current_op =VIRTCHNL_OP_UNKNOWN ; +mutex_unlock (&adapter->crit_lock);queue_delayed_work (iavf_wq, &adapter->watchdog_task,msecs_to_jiffies (10 ));
@@ -2101,9 +2102,8 @@ static void iavf_watchdog_task(struct woiavf_detect_recover_hung (&adapter->vsi);break ;case __IAVF_REMOVE: -mutex_unlock (&adapter->crit_lock); -return ;default : +mutex_unlock (&adapter->crit_lock);return ; }
Greg Kroah-Hartman
maintainerPATCH 246/262 MAINTAINERS: adjust file entry for of_net.c after movement
In reply to Greg Kroah-HartmanFrom: Lukas Bulwahn <[email protected]>
commit f616447034a120b18f6e612814641e7d8f5d7f0a upstream.
Commit e330fb14590c ("of: net: move of_net under net/") moves of_net.c to ./net/core/, but misses to adjust the reference to this file in MAINTAINERS.
Hence, ./scripts/get_maintainer.pl --self-test=patterns complains:
warning: no file matches F: drivers/of/of_net.c
Adjust the file entry after this file movement.
--- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
MAINTAINERS +1 -1
@@ -7024,7 +7024,6 @@ F: drivers/net/mdio/fwnode_mdio.c F: drivers/net/mdio/of_mdio.c F: drivers/net/pcs/ F: drivers/net/phy/ -F: drivers/of/of_net.c F: include/dt-bindings/net/qca-ar803x.h F: include/linux/*mdio*.h F: include/linux/mdio/*.h
@@ -7036,6 +7035,7 @@ F: include/linux/platform_data/mdio-gpio F: include/trace/events/mdio.h F: include/uapi/linux/mdio.h F: include/uapi/linux/mii.h +F: net/core/of_net.c EXFAT FILE SYSTEM M: Namjae Jeon <[email protected]>
Greg Kroah-Hartman
maintainerPATCH 247/262 Input: elan_i2c - move regulator_[en|dis]able() out of elan_[en|dis]able_power()
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
commit 81a36d8ce554b82b0a08e2b95d0bd44fcbff339b upstream.
elan_disable_power() is called conditionally on suspend, where as elan_enable_power() is always called on resume. This leads to an imbalance in the regulator's enable count.
Move the regulator_[en|dis]able() calls out of elan_[en|dis]able_power() in preparation of fixing this.
No functional changes intended.
--- drivers/input/mouse/elan_i2c_core.c | 62 ++++++++++++------------------------ 1 file changed, 22 insertions(+), 40 deletions(-)
drivers/input/mouse/elan_i2c_core.c +22 -40
@@ -186,55 +186,21 @@ static int elan_get_fwinfo(u16 ic_type,return 0 ; } -static int elan_enable_power (struct elan_tp_data *data) +static int elan_set_power (struct elan_tp_data *data,bool on) {int repeat =ETP_RETRY_COUNT ;int error; - error =regulator_enable (data->vcc); -if (error) { -dev_err (&data->client->dev, -"failed to enable regulator: %d\n" , error); -return error; - } -do { - error = data->ops->power_control (data->client, true); + error = data->ops->power_control (data->client, on);if (error >=0 )return 0 ;msleep (30 ); }while (--repeat >0 ); -dev_err (&data->client->dev,"failed to enable power: %d\n" , error); -return error; -} - -static int elan_disable_power (struct elan_tp_data *data) -{ -int repeat =ETP_RETRY_COUNT ; -int error; - -do { - error = data->ops->power_control (data->client, false); -if (!error) { - error =regulator_disable (data->vcc); -if (error) { -dev_err (&data->client->dev, -"failed to disable regulator: %d\n" , - error); -/* Attempt to power the chip back up */ - data->ops->power_control (data->client, true); -break ; - } - -return 0 ; - } - -msleep (30 ); - }while (--repeat >0 ); - -dev_err (&data->client->dev,"failed to disable power: %d\n" , error); +dev_err (&data->client->dev,"failed to set power %s: %d\n" , + on ?"on" :"off" , error);return error; }
@@ -1399,9 +1365,19 @@ static int __maybe_unused elan_suspend(s/* Enable wake from IRQ */ data->irq_wake = (enable_irq_wake (client->irq) ==0 ); }else { - ret =elan_disable_power (data); + ret =elan_set_power (data, false); +if (ret) + goto err; + + ret =regulator_disable (data->vcc); +if (ret) { +dev_err (dev,"error %d disabling regulator\n" , ret); +/* Attempt to power the chip back up */ +elan_set_power (data, true); + } } +err:mutex_unlock (&data->sysfs_mutex);return ret; }
@@ -1417,7 +1393,13 @@ static int __maybe_unused elan_resume(st data->irq_wake = false; } - error =elan_enable_power (data); + error =regulator_enable (data->vcc); +if (error) { +dev_err (dev,"error %d enabling regulator\n" , error); + goto err; + } + + error =elan_set_power (data, true);if (error) {dev_err (dev,"power up when resuming failed: %d\n" , error); goto err;
Greg Kroah-Hartman
maintainerPATCH 248/262 Input: elan_i2c - fix regulator enable count imbalance after suspend/resume
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
commit 04b7762e37c95d9b965d16bb0e18dbd1fa2e2861 upstream.
Before these changes elan_suspend() would only disable the regulator when device_may_wakeup() returns false; whereas elan_resume() would unconditionally enable it, leading to an enable count imbalance when device_may_wakeup() returns true.
This triggers the "WARN_ON(regulator->enable_count)" in regulator_put() when the elan_i2c driver gets unbound, this happens e.g. with the hot-plugable dock with Elan I2C touchpad for the Asus TF103C 2-in-1.
Fix this by making the regulator_enable() call also be conditional on device_may_wakeup() returning false.
--- drivers/input/mouse/elan_i2c_core.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/input/mouse/elan_i2c_core.c +7 -7
@@ -1388,17 +1388,17 @@ static int __maybe_unused elan_resume(ststruct elan_tp_data *data =i2c_get_clientdata (client);int error; -if (device_may_wakeup (dev) && data->irq_wake) { +if (!device_may_wakeup (dev)) { + error =regulator_enable (data->vcc); +if (error) { +dev_err (dev,"error %d enabling regulator\n" , error); + goto err; + } + }else if (data->irq_wake) {disable_irq_wake (client->irq); data->irq_wake = false; } - error =regulator_enable (data->vcc); -if (error) { -dev_err (dev,"error %d enabling regulator\n" , error); - goto err; - } - error =elan_set_power (data, true);if (error) {dev_err (dev,"power up when resuming failed: %d\n" , error);
Greg Kroah-Hartman
maintainerPATCH 249/262 Input: samsung-keypad - properly state IOMEM dependency
In reply to Greg Kroah-HartmanFrom: David Gow <[email protected]>
commit ba115adf61b36b8c167126425a62b0efc23f72c0 upstream.
Make the samsung-keypad driver explicitly depend on CONFIG_HAS_IOMEM, as it calls devm_ioremap(). This prevents compile errors in some configs (e.g, allyesconfig/randconfig under UML):
/usr/bin/ld: drivers/input/keyboard/samsung-keypad.o: in function `samsung_keypad_probe':
samsung-keypad.c:(.text+0xc60): undefined reference to `devm_ioremap'
--- drivers/input/keyboard/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/keyboard/Kconfig +1 -1
@@ -556,7 +556,7 @@ config KEYBOARD_PMIC8XXX config KEYBOARD_SAMSUNG tristate "Samsung keypad support" - depends on HAVE_CLK + depends on HAS_IOMEM && HAVE_CLK select INPUT_MATRIXKMAP help Say Y here if you want to use the keypad on your Samsung mobile
Greg Kroah-Hartman
maintainerPATCH 250/262 HID: add mapping for KEY_DICTATE
In reply to Greg Kroah-HartmanFrom: William Mahon <[email protected]>
commit bfa26ba343c727e055223be04e08f2ebdd43c293 upstream.
Numerous keyboards are adding dictate keys which allows for text messages to be dictated by a microphone.
This patch adds a new key definition KEY_DICTATE and maps 0x0c/0x0d8 usage code to this new keycode. Additionally hid-debug is adjusted to recognize this new usage code as well.
--- drivers/hid/hid-debug.c | 1 + drivers/hid/hid-input.c | 1 + include/uapi/linux/input-event-codes.h | 1 + 3 files changed, 3 insertions(+)
drivers/hid/hid-debug.c +1 -0
@@ -934,6 +934,7 @@ static const char *keys[KEY_MAX + 1] = { [KEY_ASSISTANT] = "Assistant", [KEY_KBD_LAYOUT_NEXT] = "KbdLayoutNext", [KEY_EMOJI_PICKER] = "EmojiPicker", + [KEY_DICTATE] = "Dictate", [KEY_BRIGHTNESS_MIN] = "BrightnessMin", [KEY_BRIGHTNESS_MAX] = "BrightnessMax", [KEY_BRIGHTNESS_AUTO] = "BrightnessAuto",
drivers/hid/hid-input.c +1 -0
@@ -991,6 +991,7 @@ static void hidinput_configure_usage(strcase 0x0cd :map_key_clear (KEY_PLAYPAUSE );break ;case 0x0cf :map_key_clear (KEY_VOICECOMMAND );break ; +case 0x0d8 :map_key_clear (KEY_DICTATE );break ;case 0x0d9 :map_key_clear (KEY_EMOJI_PICKER );break ;case 0x0e0 :map_abs_clear (ABS_VOLUME );break ;
include/uapi/linux/input-event-codes.h +1 -0
@@ -612,6 +612,7 @@#define KEY_ASSISTANT 0x247/* AL Context-aware desktop assistant */ #define KEY_KBD_LAYOUT_NEXT 0x248/* AC Next Keyboard Layout Select */ #define KEY_EMOJI_PICKER 0x249/* Show/hide emoji picker (HUTRR101) */ +#define KEY_DICTATE 0x24a/* Start or Stop Voice Dictation Session (HUTRR99) */ #define KEY_BRIGHTNESS_MIN 0x250/* Set Brightness to Minimum */ #define KEY_BRIGHTNESS_MAX 0x251/* Set Brightness to Maximum */
Greg Kroah-Hartman
maintainerPATCH 251/262 HID: add mapping for KEY_ALL_APPLICATIONS
In reply to Greg Kroah-HartmanFrom: William Mahon <[email protected]>
commit 327b89f0acc4c20a06ed59e4d9af7f6d804dc2e2 upstream.
This patch adds a new key definition for KEY_ALL_APPLICATIONS and aliases KEY_DASHBOARD to it.
It also maps the 0x0c/0x2a2 usage code to KEY_ALL_APPLICATIONS.
--- drivers/hid/hid-debug.c | 4 +++- drivers/hid/hid-input.c | 2 ++ include/uapi/linux/input-event-codes.h | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-)
drivers/hid/hid-debug.c +3 -1
@@ -825,7 +825,9 @@ static const char *keys[KEY_MAX + 1] = { [KEY_F22] = "F22", [KEY_F23] = "F23", [KEY_F24] = "F24", [KEY_PLAYCD] = "PlayCD", [KEY_PAUSECD] = "PauseCD", [KEY_PROG3] = "Prog3", - [KEY_PROG4] = "Prog4", [KEY_SUSPEND] = "Suspend", + [KEY_PROG4] = "Prog4", + [KEY_ALL_APPLICATIONS] = "AllApplications", + [KEY_SUSPEND] = "Suspend", [KEY_CLOSE] = "Close", [KEY_PLAY] = "Play", [KEY_FASTFORWARD] = "FastForward", [KEY_BASSBOOST] = "BassBoost", [KEY_PRINT] = "Print", [KEY_HP] = "HP",
drivers/hid/hid-input.c +2 -0
@@ -1083,6 +1083,8 @@ static void hidinput_configure_usage(strcase 0x29d :map_key_clear (KEY_KBD_LAYOUT_NEXT );break ; +case 0x2a2 :map_key_clear (KEY_ALL_APPLICATIONS );break ; +case 0x2c7 :map_key_clear (KEY_KBDINPUTASSIST_PREV );break ;case 0x2c8 :map_key_clear (KEY_KBDINPUTASSIST_NEXT );break ;case 0x2c9 :map_key_clear (KEY_KBDINPUTASSIST_PREVGROUP );break ;
include/uapi/linux/input-event-codes.h +2 -1
@@ -278,7 +278,8 @@#define KEY_PAUSECD 201#define KEY_PROG3 202#define KEY_PROG4 203 -#define KEY_DASHBOARD 204/* AL Dashboard */ +#define KEY_ALL_APPLICATIONS 204/* AC Desktop Show All Applications */ +#define KEY_DASHBOARD KEY_ALL_APPLICATIONS#define KEY_SUSPEND 205#define KEY_CLOSE 206/* AC Close */ #define KEY_PLAY 207
Greg Kroah-Hartman
maintainerPATCH 252/262 tracing/histogram: Fix sorting on old "cpu" value
In reply to Greg Kroah-HartmanFrom: Steven Rostedt (Google) <[email protected]>
commit 1d1898f65616c4601208963c3376c1d828cbf2c7 upstream.
When trying to add a histogram against an event with the "cpu" field, it was impossible due to "cpu" being a keyword to key off of the running CPU. So to fix this, it was changed to "common_cpu" to match the other generic fields (like "common_pid"). But since some scripts used "cpu" for keying off of the CPU (for events that did not have "cpu" as a field, which is most of them), a backward compatibility trick was added such that if "cpu" was used as a key, and the event did not have "cpu" as a field name, then it would fallback and switch over to "common_cpu".
This fix has a couple of subtle bugs. One was that when switching over to "common_cpu", it did not change the field name, it just set a flag. But the code still found a "cpu" field. The "cpu" field is used for filtering and is returned when the event does not have a "cpu" field.
This was found by:
# cd /sys/kernel/tracing # echo hist:key=cpu,pid:sort=cpu > events/sched/sched_wakeup/trigger # cat events/sched/sched_wakeup/hist
Which showed the histogram unsorted:
{ cpu: 19, pid: 1175 } hitcount: 1
{ cpu: 6, pid: 239 } hitcount: 2
{ cpu: 23, pid: 1186 } hitcount: 14
{ cpu: 12, pid: 249 } hitcount: 2
{ cpu: 3, pid: 994 } hitcount: 5Instead of hard coding the "cpu" checks, take advantage of the fact that trace_event_field_field() returns a special field for "cpu" and "CPU" if the event does not have "cpu" as a field. This special field has the "filter_type" of "FILTER_CPU". Check that to test if the returned field is of the CPU type instead of doing the string compare.
Also, fix the sorting bug by testing for the hist_field flag of HIST_FIELD_FL_CPU when setting up the sort routine. Otherwise it will use the special CPU field to know what compare routine to use, and since that special field does not have a size, it returns tracing_map_cmp_none.
--- kernel/trace/trace_events_hist.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/trace/trace_events_hist.c +3 -3
@@ -2049,9 +2049,9 @@ parse_field(struct hist_trigger_data *hi/* * For backward compatibility, if field_name * was "cpu", then we treat this the same as -* common_cpu. +* common_cpu. This also works for "CPU". */ -if (strcmp (field_name,"cpu" ) ==0 ) { +if (field && field->filter_type ==FILTER_CPU ) { *flags |=HIST_FIELD_FL_CPU ; }else { hist_err(tr, HIST_ERR_FIELD_NOT_FOUND,
@@ -4478,7 +4478,7 @@ static int create_tracing_map_fields(strif (hist_field->flags &HIST_FIELD_FL_STACKTRACE ) cmp_fn = tracing_map_cmp_none; -else if (!field) +else if (!field || hist_field->flags &HIST_FIELD_FL_CPU ) cmp_fn =tracing_map_cmp_num (hist_field->size, hist_field->is_signed);else if (is_string_field (field))
Greg Kroah-Hartman
maintainerPATCH 253/262 tracing: Fix return value of __setup handlers
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
commit 1d02b444b8d1345ea4708db3bab4db89a7784b55 upstream.
__setup() handlers should generally return 1 to indicate that the boot options have been handled.
Using invalid option values causes the entire kernel boot option string to be reported as Unknown and added to init's environment strings, polluting it.
Unknown kernel command line parameters "BOOT_IMAGE=/boot/bzImage-517rc6
kprobe_event=p,syscall_any,$arg1 trace_options=quiet trace_clock=jiffies", will be passed to user space.
Run /sbin/init as init process
with arguments:
/sbin/init
with environment:
HOME=/
TERM=linux
BOOT_IMAGE=/boot/bzImage-517rc6
kprobe_event=p,syscall_any,$arg1
trace_options=quiet
trace_clock=jiffiesReturn 1 from the __setup() handlers so that init's environment is not polluted with kernel boot options.
--- kernel/trace/trace.c | 4 ++-- kernel/trace/trace_kprobe.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
kernel/trace/trace.c +2 -2
@@ -235,7 +235,7 @@ static char trace_boot_options_buf[MAX_Tstatic int __init set_trace_boot_options (char *str) {strlcpy (trace_boot_options_buf, str,MAX_TRACER_SIZE ); -return 0 ; +return 1 ; }__setup ("trace_options=" , set_trace_boot_options);
@@ -246,7 +246,7 @@ static int __init set_trace_boot_clock(c {strlcpy (trace_boot_clock_buf, str,MAX_TRACER_SIZE ); trace_boot_clock = trace_boot_clock_buf; -return 0 ; +return 1 ; }__setup ("trace_clock=" , set_trace_boot_clock);
kernel/trace/trace_kprobe.c +1 -1
@@ -31,7 +31,7 @@ static int __init set_kprobe_boot_eventsstrlcpy (kprobe_boot_events_buf, str,COMMAND_LINE_SIZE );disable_tracing_selftest ("running kprobe events" ); -return 0 ; +return 1 ; }__setup ("kprobe_event=" , set_kprobe_boot_events);
Greg Kroah-Hartman
maintainerPATCH 254/262 btrfs: fix lost prealloc extents beyond eof after full fsync
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
commit d99478874355d3a7b9d86dfb5d7590d5b1754b1f upstream.
When doing a full fsync, if we have prealloc extents beyond (or at) eof, and the leaves that contain them were not modified in the current transaction, we end up not logging them. This results in losing those extents when we replay the log after a power failure, since the inode is truncated to the current value of the logged i_size.
Just like for the fast fsync path, we need to always log all prealloc extents starting at or beyond i_size. The fast fsync case was fixed in commit 471d557afed155 ("Btrfs: fix loss of prealloc extents past i_size after fsync log replay") but it missed the full fsync path. The problem exists since the very early days, when the log tree was added by commit e02119d5a7b439 ("Btrfs: Add a write ahead tree log to optimize synchronous operations").
Example reproducer:
$ mkfs.btrfs -f /dev/sdc $ mount /dev/sdc /mnt
# Create our test file with many file extent items, so that they span
# several leaves of metadata, even if the node/page size is 64K. Use # direct IO and not fsync/O_SYNC because it's both faster and it avoids # clearing the full sync flag from the inode - we want the fsync below # to trigger the slow full sync code path. $ xfs_io -f -d -c "pwrite -b 4K 0 16M" /mnt/foo
# Now add two preallocated extents to our file without extending the # file's size. One right at i_size, and another further beyond, leaving
# a gap between the two prealloc extents. $ xfs_io -c "falloc -k 16M 1M" /mnt/foo $ xfs_io -c "falloc -k 20M 1M" /mnt/foo
# Make sure everything is durably persisted and the transaction is
# committed. This makes all created extents to have a generation lower # than the generation of the transaction used by the next write and # fsync. sync
# Now overwrite only the first extent, which will result in modifying
# only the first leaf of metadata for our inode. Then fsync it. This # fsync will use the slow code path (inode full sync bit is set) because # it's the first fsync since the inode was created/loaded. $ xfs_io -c "pwrite 0 4K" -c "fsync" /mnt/foo
# Extent list before power failure.
$ xfs_io -c "fiemap -v" /mnt/foo
/mnt/foo:
EXT: FILE-OFFSET BLOCK-RANGE TOTAL FLAGS
0: [0..7]: 2178048..2178055 8 0x0
1: [8..16383]: 26632..43007 16376 0x0
2: [16384..32767]: 2156544..2172927 16384 0x0
3: [32768..34815]: 2172928..2174975 2048 0x800
4: [34816..40959]: hole 6144
5: [40960..43007]: 2174976..2177023 2048 0x801<power fail>
# Mount fs again, trigger log replay.
$ mount /dev/sdc /mnt
# Extent list after power failure and log replay.
$ xfs_io -c "fiemap -v" /mnt/foo
/mnt/foo:
EXT: FILE-OFFSET BLOCK-RANGE TOTAL FLAGS
0: [0..7]: 2178048..2178055 8 0x0
1: [8..16383]: 26632..43007 16376 0x0
2: [16384..32767]: 2156544..2172927 16384 0x1# The prealloc extents at file offsets 16M and 20M are missing.
So fix this by calling btrfs_log_prealloc_extents() when we are doing a full fsync, so that we always log all prealloc extents beyond eof.
A test case for fstests will follow soon.
--- fs/btrfs/tree-log.c | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-)
fs/btrfs/tree-log.c +31 -12
@@ -4423,7 +4423,7 @@ static int log_one_extent(struct btrfs_t/* * Log all prealloc extents beyond the inode's i_size to make sure we do not -* lose them after doing a fast fsync and replaying the log. We scan the +* lose them after doing a full/fast fsync and replaying the log. We scan the * subvolume's root instead of iterating the inode's extent map tree because * otherwise we can log incorrect extent items based on extent map conversion. * That can happen due to the fact that extent maps are merged when they
@@ -5208,6 +5208,7 @@ static int copy_inode_items_to_log(strucstruct btrfs_log_ctx *ctx, bool *need_log_inode_item) { + const u64 i_size = i_size_read(&inode->vfs_inode);struct btrfs_root *root = inode->root;int ins_start_slot =0 ;int ins_nr =0 ;
@@ -5228,13 +5229,21 @@ again:if (min_key->type > max_key->type)break ; -if (min_key->type ==BTRFS_INODE_ITEM_KEY ) +if (min_key->type ==BTRFS_INODE_ITEM_KEY ) { *need_log_inode_item = false; - -if ((min_key->type ==BTRFS_INODE_REF_KEY || - min_key->type ==BTRFS_INODE_EXTREF_KEY ) && - inode->generation == trans->transid && - !recursive_logging) { + }else if (min_key->type ==BTRFS_EXTENT_DATA_KEY && + min_key->offset >= i_size) { +/* +* Extents at and beyond eof are logged with +* btrfs_log_prealloc_extents(). +* Only regular files have BTRFS_EXTENT_DATA_KEY keys, +* and no keys greater than that, so bail out. +*/ +break ; + }else if ((min_key->type ==BTRFS_INODE_REF_KEY || + min_key->type ==BTRFS_INODE_EXTREF_KEY ) && + inode->generation == trans->transid && + !recursive_logging) {u64 other_ino =0 ;u64 other_parent =0 ;
@@ -5265,10 +5274,8 @@ again:btrfs_release_path (path); goto next_key; } - } - -/* Skip xattrs, we log them later with btrfs_log_all_xattrs() */ -if (min_key->type ==BTRFS_XATTR_ITEM_KEY ) { + }else if (min_key->type ==BTRFS_XATTR_ITEM_KEY ) { +/* Skip xattrs, logged later with btrfs_log_all_xattrs() */ if (ins_nr ==0 ) goto next_slot; ret = copy_items(trans, inode, dst_path, path,
@@ -5321,9 +5328,21 @@ next_key:break ; } } -if (ins_nr) +if (ins_nr) { ret =copy_items (trans, inode, dst_path, path, ins_start_slot, ins_nr, inode_only, logged_isize); +if (ret) +return ret; + } + +if (inode_only ==LOG_INODE_ALL &&S_ISREG (inode->vfs_inode.i_mode)) { +/* +* Release the path because otherwise we might attempt to double +* lock the same leaf with btrfs_log_prealloc_extents() below. +*/ +btrfs_release_path (path); + ret =btrfs_log_prealloc_extents (trans, inode, dst_path); + }return ret; }
Greg Kroah-Hartman
maintainerPATCH 255/262 btrfs: fix relocation crash due to premature return from btrfs_commit_transaction()
In reply to Greg Kroah-HartmanFrom: Omar Sandoval <[email protected]>
commit 5fd76bf31ccfecc06e2e6b29f8c809e934085b99 upstream.
We are seeing crashes similar to the following trace:
[38.969182] WARNING: CPU: 20 PID: 2105 at fs/btrfs/relocation.c:4070 btrfs_relocate_block_group+0x2dc/0x340 [btrfs] [38.973556] CPU: 20 PID: 2105 Comm: btrfs Not tainted 5.17.0-rc4 #54 [38.974580] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.0-59-gc9ba5276e321-prebuilt.qemu.org 04/01/2014 [38.976539] RIP: 0010:btrfs_relocate_block_group+0x2dc/0x340 [btrfs] [38.980336] RSP: 0000:ffffb0dd42e03c20 EFLAGS: 00010206 [38.981218] RAX: ffff96cfc4ede800 RBX: ffff96cfc3ce0000 RCX: 000000000002ca14 [38.982560] RDX: 0000000000000000 RSI: 4cfd109a0bcb5d7f RDI: ffff96cfc3ce0360 [38.983619] RBP: ffff96cfc309c000 R08: 0000000000000000 R09: 0000000000000000 [38.984678] R10: ffff96cec0000001 R11: ffffe84c80000000 R12: ffff96cfc4ede800 [38.985735] R13: 0000000000000000 R14: 0000000000000000 R15: ffff96cfc3ce0360 [38.987146] FS: 00007f11c15218c0(0000) GS:ffff96d6dfb00000(0000) knlGS:0000000000000000 [38.988662] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [38.989398] CR2: 00007ffc922c8e60 CR3: 00000001147a6001 CR4: 0000000000370ee0 [38.990279] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [38.991219] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [38.992528] Call Trace: [38.992854] <TASK> [38.993148] btrfs_relocate_chunk+0x27/0xe0 [btrfs] [38.993941] btrfs_balance+0x78e/0xea0 [btrfs] [38.994801] ? vsnprintf+0x33c/0x520 [38.995368] ? __kmalloc_track_caller+0x351/0x440 [38.996198] btrfs_ioctl_balance+0x2b9/0x3a0 [btrfs] [38.997084] btrfs_ioctl+0x11b0/0x2da0 [btrfs] [38.997867] ? mod_objcg_state+0xee/0x340 [38.998552] ? seq_release+0x24/0x30 [38.999184] ? proc_nr_files+0x30/0x30 [38.999654] ? call_rcu+0xc8/0x2f0 [39.000228] ? __x64_sys_ioctl+0x84/0xc0 [39.000872] ? btrfs_ioctl_get_supported_features+0x30/0x30 [btrfs] [39.001973] __x64_sys_ioctl+0x84/0xc0 [39.002566] do_syscall_64+0x3a/0x80 [39.003011] entry_SYSCALL_64_after_hwframe+0x44/0xae [39.003735] RIP: 0033:0x7f11c166959b [39.007324] RSP: 002b:00007fff2543e998 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 [39.008521] RAX: ffffffffffffffda RBX: 00007f11c1521698 RCX: 00007f11c166959b [39.009833] RDX: 00007fff2543ea40 RSI: 00000000c4009420 RDI: 0000000000000003 [39.011270] RBP: 0000000000000003 R08: 0000000000000013 R09: 00007f11c16f94e0 [39.012581] R10: 0000000000000000 R11: 0000000000000246 R12: 00007fff25440df3 [39.014046] R13: 0000000000000000 R14: 00007fff2543ea40 R15: 0000000000000001 [39.015040] </TASK> [39.015418] ---[ end trace 0000000000000000 ]--- [43.131559] ------------[ cut here ]------------ [43.132234] kernel BUG at fs/btrfs/extent-tree.c:2717! [43.133031] invalid opcode: 0000 [#1] PREEMPT SMP PTI [43.133702] CPU: 1 PID: 1839 Comm: btrfs Tainted: G W 5.17.0-rc4 #54 [43.134863] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.0-59-gc9ba5276e321-prebuilt.qemu.org 04/01/2014 [43.136426] RIP: 0010:unpin_extent_range+0x37a/0x4f0 [btrfs] [43.139913] RSP: 0000:ffffb0dd4216bc70 EFLAGS: 00010246 [43.140629] RAX: 0000000000000000 RBX: ffff96cfc34490f8 RCX: 0000000000000001 [43.141604] RDX: 0000000080000001 RSI: 0000000051d00000 RDI: 00000000ffffffff [43.142645] RBP: 0000000000000000 R08: 0000000000000000 R09: ffff96cfd07dca50 [43.143669] R10: ffff96cfc46e8a00 R11: fffffffffffec000 R12: 0000000041d00000 [43.144657] R13: ffff96cfc3ce0000 R14: ffffb0dd4216bd08 R15: 0000000000000000 [43.145686] FS: 00007f7657dd68c0(0000) GS:ffff96d6df640000(0000) knlGS:0000000000000000 [43.146808] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [43.147584] CR2: 00007f7fe81bf5b0 CR3: 00000001093ee004 CR4: 0000000000370ee0 [43.148589] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [43.149581] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [43.150559] Call Trace: [43.150904] <TASK> [43.151253] btrfs_finish_extent_commit+0x88/0x290 [btrfs] [43.152127] btrfs_commit_transaction+0x74f/0xaa0 [btrfs] [43.152932] ? btrfs_attach_transaction_barrier+0x1e/0x50 [btrfs] [43.153786] btrfs_ioctl+0x1edc/0x2da0 [btrfs] [43.154475] ? __check_object_size+0x150/0x170 [43.155170] ? preempt_count_add+0x49/0xa0 [43.155753] ? __x64_sys_ioctl+0x84/0xc0 [43.156437] ? btrfs_ioctl_get_supported_features+0x30/0x30 [btrfs] [43.157456] __x64_sys_ioctl+0x84/0xc0 [43.157980] do_syscall_64+0x3a/0x80 [43.158543] entry_SYSCALL_64_after_hwframe+0x44/0xae [43.159231] RIP: 0033:0x7f7657f1e59b [43.161819] RSP: 002b:00007ffda5cd1658 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 [43.162702] RAX: ffffffffffffffda RBX: 0000000000000001 RCX: 00007f7657f1e59b [43.163526] RDX: 0000000000000000 RSI: 0000000000009408 RDI: 0000000000000003 [43.164358] RBP: 0000000000000003 R08: 0000000000000000 R09: 0000000000000000 [43.165208] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 [43.166029] R13: 00005621b91c3232 R14: 00005621b91ba580 R15: 00007ffda5cd1800 [43.166863] </TASK> [43.167125] Modules linked in: btrfs blake2b_generic xor pata_acpi ata_piix libata raid6_pq scsi_mod libcrc32c virtio_net virtio_rng net_failover rng_core failover scsi_common [43.169552] ---[ end trace 0000000000000000 ]--- [43.171226] RIP: 0010:unpin_extent_range+0x37a/0x4f0 [btrfs] [43.174767] RSP: 0000:ffffb0dd4216bc70 EFLAGS: 00010246 [43.175600] RAX: 0000000000000000 RBX: ffff96cfc34490f8 RCX: 0000000000000001 [43.176468] RDX: 0000000080000001 RSI: 0000000051d00000 RDI: 00000000ffffffff [43.177357] RBP: 0000000000000000 R08: 0000000000000000 R09: ffff96cfd07dca50 [43.178271] R10: ffff96cfc46e8a00 R11: fffffffffffec000 R12: 0000000041d00000 [43.179178] R13: ffff96cfc3ce0000 R14: ffffb0dd4216bd08 R15: 0000000000000000 [43.180071] FS: 00007f7657dd68c0(0000) GS:ffff96d6df800000(0000) knlGS:0000000000000000 [43.181073] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [43.181808] CR2: 00007fe09905f010 CR3: 00000001093ee004 CR4: 0000000000370ee0 [43.182706] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [43.183591] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
We first hit the WARN_ON(rc->block_group->pinned > 0) in btrfs_relocate_block_group() and then the BUG_ON(!cache) in unpin_extent_range(). This tells us that we are exiting relocation and removing the block group with bytes still pinned for that block group. This is supposed to be impossible: the last thing relocate_block_group() does is commit the transaction to get rid of pinned extents.
Commit d0c2f4fa555e ("btrfs: make concurrent fsyncs wait less when waiting for a transaction commit") introduced an optimization so that commits from fsync don't have to wait for the previous commit to unpin extents. This was only intended to affect fsync, but it inadvertently made it possible for any commit to skip waiting for the previous commit to unpin. This is because if a call to btrfs_commit_transaction() finds that another thread is already committing the transaction, it waits for the other thread to complete the commit and then returns. If that other thread was in fsync, then it completes the commit without completing the previous commit. This makes the following sequence of events possible:
Thread 1____________________|Thread 2 (fsync)_____________________|Thread 3 (balance)___________________
btrfs_commit_transaction(N) | |
btrfs_run_delayed_refs | |
pin extents | |
... | |
state = UNBLOCKED |btrfs_sync_file |
| btrfs_start_transaction(N + 1) |relocate_block_group
| | btrfs_join_transaction(N + 1)
| btrfs_commit_transaction(N + 1) |
... | trans->state = COMMIT_START |
| | btrfs_commit_transaction(N + 1)
| | wait_for_commit(N + 1, COMPLETED)
| wait_for_commit(N, SUPER_COMMITTED)|
state = SUPER_COMMITTED | ... |
btrfs_finish_extent_commit| |
unpin_extent_range() | trans->state = COMPLETED |
| | return
| |
... | |Thread 1 isn't done, so pinned > 0
| |and we WARN
| |
| |btrfs_remove_block_group
unpin_extent_range() | |
Thread 3 removed the | |
block group, so we BUG| |There are other sequences involving SUPER_COMMITTED transactions that can cause a similar outcome.
We could fix this by making relocation explicitly wait for unpinning, but there may be other cases that need it. Josef mentioned ENOSPC flushing and the free space cache inode as other potential victims. Rather than playing whack-a-mole, this fix is conservative and makes all commits not in fsync wait for all previous transactions, which is what the optimization intended.
--- fs/btrfs/transaction.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-)
fs/btrfs/transaction.c +31 -1
@@ -846,7 +846,37 @@ btrfs_attach_transaction_barrier(struct static noinline void wait_for_commit(struct btrfs_transaction *commit,const enum btrfs_trans_state min_state) { -wait_event (commit->commit_wait, commit->state >= min_state); +struct btrfs_fs_info *fs_info = commit->fs_info; +u64 transid = commit->transid; +bool put = false; + +while (1 ) { +wait_event (commit->commit_wait, commit->state >= min_state); +if (put) +btrfs_put_transaction (commit); + +if (min_state <TRANS_STATE_COMPLETED ) +break ; + +/* +* A transaction isn't really completed until all of the +* previous transactions are completed, but with fsync we can +* end up with SUPER_COMMITTED transactions before a COMPLETED +* transaction. Wait for those. +*/ + +spin_lock (&fs_info->trans_lock); + commit =list_first_entry_or_null (&fs_info->trans_list, + struct btrfs_transaction, + list); +if (!commit || commit->transid > transid) { +spin_unlock (&fs_info->trans_lock); +break ; + } +refcount_inc (&commit->use_count); + put = true; +spin_unlock (&fs_info->trans_lock); + } }int btrfs_wait_for_commit (struct btrfs_fs_info *fs_info,u64 transid)
Greg Kroah-Hartman
maintainerPATCH 256/262 btrfs: do not WARN_ON() if we have PageError set
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
commit a50e1fcbc9b85fd4e95b89a75c0884cb032a3e06 upstream.
Whenever we do any extent buffer operations we call assert_eb_page_uptodate() to complain loudly if we're operating on an non-uptodate page. Our overnight tests caught this warning earlier this week
WARNING: CPU: 1 PID: 553508 at fs/btrfs/extent_io.c:6849 assert_eb_page_uptodate+0x3f/0x50 CPU: 1 PID: 553508 Comm: kworker/u4:13 Tainted: G W 5.17.0-rc3+ #564 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.13.0-2.fc32 04/01/2014 Workqueue: btrfs-cache btrfs_work_helper RIP: 0010:assert_eb_page_uptodate+0x3f/0x50 RSP: 0018:ffffa961440a7c68 EFLAGS: 00010246 RAX: 0017ffffc0002112 RBX: ffffe6e74453f9c0 RCX: 0000000000001000 RDX: ffffe6e74467c887 RSI: ffffe6e74453f9c0 RDI: ffff8d4c5efc2fc0 RBP: 0000000000000d56 R08: ffff8d4d4a224000 R09: 0000000000000000 R10: 00015817fa9d1ef0 R11: 000000000000000c R12: 00000000000007b1 R13: ffff8d4c5efc2fc0 R14: 0000000001500000 R15: 0000000001cb1000 FS: 0000000000000000(0000) GS:ffff8d4dbbd00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007ff31d3448d8 CR3: 0000000118be8004 CR4: 0000000000370ee0 Call Trace: extent_buffer_test_bit+0x3f/0x70 free_space_test_bit+0xa6/0xc0 load_free_space_tree+0x1f6/0x470 caching_thread+0x454/0x630 ? rcu_read_lock_sched_held+0x12/0x60 ? rcu_read_lock_sched_held+0x12/0x60 ? rcu_read_lock_sched_held+0x12/0x60 ? lock_release+0x1f0/0x2d0 btrfs_work_helper+0xf2/0x3e0 ? lock_release+0x1f0/0x2d0 ? finish_task_switch.isra.0+0xf9/0x3a0 process_one_work+0x26d/0x580 ? process_one_work+0x580/0x580 worker_thread+0x55/0x3b0 ? process_one_work+0x580/0x580 kthread+0xf0/0x120 ? kthread_complete_and_exit+0x20/0x20 ret_from_fork+0x1f/0x30
This was partially fixed by c2e39305299f01 ("btrfs: clear extent buffer uptodate when we fail to write it"), however all that fix did was keep us from finding extent buffers after a failed writeout. It didn't keep us from continuing to use a buffer that we already had found.
In this case we're searching the commit root to cache the block group, so we can start committing the transaction and switch the commit root and then start writing. After the switch we can look up an extent buffer that hasn't been written yet and start processing that block group. Then we fail to write that block out and clear Uptodate on the page, and then we start spewing these errors.
Normally we're protected by the tree lock to a certain degree here. If we read a block we have that block read locked, and we block the writer from locking the block before we submit it for the write. However this isn't necessarily fool proof because the read could happen before we do the submit_bio and after we locked and unlocked the extent buffer.
Also in this particular case we have path->skip_locking set, so that won't save us here. We'll simply get a block that was valid when we read it, but became invalid while we were using it.
What we really want is to catch the case where we've "read" a block but it's not marked Uptodate. On read we ClearPageError(), so if we're !Uptodate and !Error we know we didn't do the right thing for reading the page.
Fix this by checking !Uptodate && !Error, this way we will not complain if our buffer gets invalidated while we're using it, and we'll maintain the spirit of the check which is to make sure we have a fully in-cache block while we're messing with it.
--- fs/btrfs/extent_io.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
fs/btrfs/extent_io.c +13 -3
@@ -6801,14 +6801,24 @@ static void assert_eb_page_uptodate(cons {struct btrfs_fs_info *fs_info = eb->fs_info; +/* +* If we are using the commit root we could potentially clear a page +* Uptodate while we're using the extent buffer that we've previously +* looked up. We don't want to complain in this case, as the page was +* valid before, we just didn't write it out. Instead we want to catch +* the case where we didn't actually read the block properly, which +* would have !PageUptodate && !PageError, as we clear PageError before +* reading. +*/ if (fs_info->sectorsize <PAGE_SIZE ) { -bool uptodate; +bool uptodate, error; uptodate =btrfs_subpage_test_uptodate (fs_info, page, eb->start, eb->len); -WARN_ON (!uptodate); + error =btrfs_subpage_test_error (fs_info, page, eb->start, eb->len); +WARN_ON (!uptodate && !error); }else { -WARN_ON (!PageUptodate (page)); +WARN_ON (!PageUptodate (page) && !PageError (page)); } }
Greg Kroah-Hartman
maintainerPATCH 257/262 btrfs: qgroup: fix deadlock between rescan worker and remove qgroup
In reply to Greg Kroah-HartmanFrom: Sidong Yang <[email protected]>
commit d4aef1e122d8bbdc15ce3bd0bc813d6b44a7d63a upstream.
The commit e804861bd4e6 ("btrfs: fix deadlock between quota disable and qgroup rescan worker") by Kawasaki resolves deadlock between quota disable and qgroup rescan worker. But also there is a deadlock case like it. It's about enabling or disabling quota and creating or removing qgroup. It can be reproduced in simple script below.
for i in {1..100}
do
btrfs quota enable /mnt &
btrfs qgroup create 1/0 /mnt &
btrfs qgroup destroy 1/0 /mnt &
btrfs quota disable /mnt &
done
Here's why the deadlock happens:
1) The quota rescan task is running.
2) Task A calls btrfs_quota_disable(), locks the qgroup_ioctl_lock mutex, and then calls btrfs_qgroup_wait_for_completion(), to wait for the quota rescan task to complete.
3) Task B calls btrfs_remove_qgroup() and it blocks when trying to lock the qgroup_ioctl_lock mutex, because it's being held by task A. At that point task B is holding a transaction handle for the current transaction.
4) The quota rescan task calls btrfs_commit_transaction(). This results in it waiting for all other tasks to release their handles on the transaction, but task B is blocked on the qgroup_ioctl_lock mutex while holding a handle on the transaction, and that mutex is being held by task A, which is waiting for the quota rescan task to complete, resulting in a deadlock between these 3 tasks.
To resolve this issue, the thread disabling quota should unlock qgroup_ioctl_lock before waiting rescan completion. Move btrfs_qgroup_wait_for_completion() after unlock of qgroup_ioctl_lock.
--- fs/btrfs/qgroup.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
fs/btrfs/qgroup.c +8 -1
@@ -1197,13 +1197,20 @@ int btrfs_quota_disable(struct btrfs_fs_ goto out;/* +* Unlock the qgroup_ioctl_lock mutex before waiting for the rescan worker to +* complete. Otherwise we can deadlock because btrfs_remove_qgroup() needs +* to lock that mutex while holding a transaction handle and the rescan +* worker needs to commit a transaction. +*/ +mutex_unlock (&fs_info->qgroup_ioctl_lock); + +/* * Request qgroup rescan worker to complete and wait for it. This wait * must be done before transaction start for quota disable since it may * deadlock with transaction by the qgroup rescan worker. */ clear_bit (BTRFS_FS_QUOTA_ENABLED , &fs_info->flags);btrfs_qgroup_wait_for_completion (fs_info, false); -mutex_unlock (&fs_info->qgroup_ioctl_lock);/* * 1 For the root item
Greg Kroah-Hartman
maintainerPATCH 258/262 btrfs: add missing run of delayed items after unlink during log replay
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
commit 4751dc99627e4d1465c5bfa8cb7ab31ed418eff5 upstream.
During log replay, whenever we need to check if a name (dentry) exists in a directory we do searches on the subvolume tree for inode references or or directory entries (BTRFS_DIR_INDEX_KEY keys, and BTRFS_DIR_ITEM_KEY keys as well, before kernel 5.17). However when during log replay we unlink a name, through btrfs_unlink_inode(), we may not delete inode references and dir index keys from a subvolume tree and instead just add the deletions to the delayed inode's delayed items, which will only be run when we commit the transaction used for log replay. This means that after an unlink operation during log replay, if we attempt to search for the same name during log replay, we will not see that the name was already deleted, since the deletion is recorded only on the delayed items.
We run delayed items after every unlink operation during log replay, except at unlink_old_inode_refs() and at add_inode_ref(). This was due to an overlook, as delayed items should be run after evert unlink, for the reasons stated above.
So fix those two cases.
--- fs/btrfs/tree-log.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
fs/btrfs/tree-log.c +18 -0
@@ -1329,6 +1329,15 @@ again: inode, name, namelen);kfree (name);iput (dir); +/* +* Whenever we need to check if a name exists or not, we +* check the subvolume tree. So after an unlink we must +* run delayed items, so that future checks for a name +* during log replay see that the name does not exists +* anymore. +*/ +if (!ret) + ret =btrfs_run_delayed_items (trans);if (ret) goto out; goto again;
@@ -1580,6 +1589,15 @@ static noinline int add_inode_ref(struct*/ if (!ret && inode->i_nlink ==0 )inc_nlink (inode); +/* +* Whenever we need to check if a name exists or +* not, we check the subvolume tree. So after an +* unlink we must run delayed items, so that future +* checks for a name during log replay see that the +* name does not exists anymore. +*/ +if (!ret) + ret =btrfs_run_delayed_items (trans); }if (ret <0 ) goto out;
Greg Kroah-Hartman
maintainerPATCH 259/262 btrfs: do not start relocation until in progress drops are done
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
commit b4be6aefa73c9a6899ef3ba9c5faaa8a66e333ef upstream.
We hit a bug with a recovering relocation on mount for one of our file systems in production. I reproduced this locally by injecting errors into snapshot delete with balance running at the same time. This presented as an error while looking up an extent item
WARNING: CPU: 5 PID: 1501 at fs/btrfs/extent-tree.c:866 lookup_inline_extent_backref+0x647/0x680 CPU: 5 PID: 1501 Comm: btrfs-balance Not tainted 5.16.0-rc8+ #8 RIP: 0010:lookup_inline_extent_backref+0x647/0x680 RSP: 0018:ffffae0a023ab960 EFLAGS: 00010202 RAX: 0000000000000001 RBX: 0000000000000000 RCX: 0000000000000000 RDX: 0000000000000000 RSI: 000000000000000c RDI: 0000000000000000 RBP: ffff943fd2a39b60 R08: 0000000000000000 R09: 0000000000000001 R10: 0001434088152de0 R11: 0000000000000000 R12: 0000000001d05000 R13: ffff943fd2a39b60 R14: ffff943fdb96f2a0 R15: ffff9442fc923000 FS: 0000000000000000(0000) GS:ffff944e9eb40000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f1157b1fca8 CR3: 000000010f092000 CR4: 0000000000350ee0 Call Trace: <TASK> insert_inline_extent_backref+0x46/0xd0 __btrfs_inc_extent_ref.isra.0+0x5f/0x200 ? btrfs_merge_delayed_refs+0x164/0x190 __btrfs_run_delayed_refs+0x561/0xfa0 ? btrfs_search_slot+0x7b4/0xb30 ? btrfs_update_root+0x1a9/0x2c0 btrfs_run_delayed_refs+0x73/0x1f0 ? btrfs_update_root+0x1a9/0x2c0 btrfs_commit_transaction+0x50/0xa50 ? btrfs_update_reloc_root+0x122/0x220 prepare_to_merge+0x29f/0x320 relocate_block_group+0x2b8/0x550 btrfs_relocate_block_group+0x1a6/0x350 btrfs_relocate_chunk+0x27/0xe0 btrfs_balance+0x777/0xe60 balance_kthread+0x35/0x50 ? btrfs_balance+0xe60/0xe60 kthread+0x16b/0x190 ? set_kthread_struct+0x40/0x40 ret_from_fork+0x22/0x30 </TASK>
Normally snapshot deletion and relocation are excluded from running at the same time by the fs_info->cleaner_mutex. However if we had a pending balance waiting to get the ->cleaner_mutex, and a snapshot deletion was running, and then the box crashed, we would come up in a state where we have a half deleted snapshot.
Again, in the normal case the snapshot deletion needs to complete before relocation can start, but in this case relocation could very well start before the snapshot deletion completes, as we simply add the root to the dead roots list and wait for the next time the cleaner runs to clean up the snapshot.
Fix this by setting a bit on the fs_info if we have any DEAD_ROOT's that had a pending drop_progress key. If they do then we know we were in the middle of the drop operation and set a flag on the fs_info. Then balance can wait until this flag is cleared to start up again.
If there are DEAD_ROOT's that don't have a drop_progress set then we're safe to start balance right away as we'll be properly protected by the cleaner_mutex.
--- fs/btrfs/ctree.h | 10 ++++++++++ fs/btrfs/disk-io.c | 10 ++++++++++ fs/btrfs/extent-tree.c | 10 ++++++++++ fs/btrfs/relocation.c | 13 +++++++++++++ fs/btrfs/root-tree.c | 15 +++++++++++++++ fs/btrfs/transaction.c | 33 ++++++++++++++++++++++++++++++++- fs/btrfs/transaction.h | 1 + 7 files changed, 91 insertions(+), 1 deletion(-)
fs/btrfs/ctree.h +10 -0
@@ -593,6 +593,9 @@ enum {/* Indicate whether there are any tree modification log users */ BTRFS_FS_TREE_MOD_LOG_USERS , +/* Indicate we have half completed snapshot deletions pending. */ +BTRFS_FS_UNFINISHED_DROPS , + #if BITS_PER_LONG == 32/* Indicate if we have error/warn message printed on 32bit systems */ BTRFS_FS_32BIT_ERROR,
@@ -1098,8 +1101,15 @@ enum {BTRFS_ROOT_HAS_LOG_TREE ,/* Qgroup flushing is in progress */ BTRFS_ROOT_QGROUP_FLUSHING , +/* This root has a drop operation that was started previously. */ + BTRFS_ROOT_UNFINISHED_DROP, }; +static inline void btrfs_wake_unfinished_drop (struct btrfs_fs_info *fs_info) +{ +clear_and_wake_up_bit (BTRFS_FS_UNFINISHED_DROPS , &fs_info->flags); +} +/* * Record swapped tree blocks of a subvolume tree for delayed subtree trace * code. For detail check comment in fs/btrfs/qgroup.c.
fs/btrfs/disk-io.c +10 -0
@@ -3659,6 +3659,10 @@ int __cold open_ctree(struct super_blockset_bit (BTRFS_FS_OPEN , &fs_info->flags); +/* Kick the cleaner thread so it'll start deleting snapshots. */ +if (test_bit (BTRFS_FS_UNFINISHED_DROPS , &fs_info->flags)) +wake_up_process (fs_info->cleaner_kthread); + clear_oneshot:btrfs_clear_oneshot_options (fs_info);return 0 ;
@@ -4340,6 +4344,12 @@ void __cold close_ctree(struct btrfs_fs_*/ kthread_park (fs_info->cleaner_kthread); +/* +* If we had UNFINISHED_DROPS we could still be processing them, so +* clear that bit and wake up relocation so it can stop. +*/ +btrfs_wake_unfinished_drop (fs_info); +/* wait for the qgroup rescan worker to stop */ btrfs_qgroup_wait_for_completion (fs_info, false);
fs/btrfs/extent-tree.c +10 -0
@@ -5541,6 +5541,7 @@ int btrfs_drop_snapshot(struct btrfs_rooint ret;int level;bool root_dropped = false; +bool unfinished_drop = false;btrfs_debug (fs_info,"Drop subvolume %llu" , root->root_key.objectid);
@@ -5583,6 +5584,8 @@ int btrfs_drop_snapshot(struct btrfs_roo* already dropped. */ set_bit (BTRFS_ROOT_DELETING , &root->state); + unfinished_drop =test_bit (BTRFS_ROOT_UNFINISHED_DROP , &root->state); +if (btrfs_disk_key_objectid (&root_item->drop_progress) ==0 ) { level =btrfs_header_level (root->node); path->nodes[level] =btrfs_lock_root_node (root);
@@ -5758,6 +5761,13 @@ out_free:btrfs_free_path (path); out:/* +* We were an unfinished drop root, check to see if there are any +* pending, and if not clear and wake up any waiters. +*/ +if (!err && unfinished_drop) +btrfs_maybe_wake_unfinished_drop (fs_info); + +/* * So if we need to stop dropping the snapshot for whatever reason we * need to make sure to add it back to the dead root list so that we * keep trying to do the work later. This also cleans up roots if we
fs/btrfs/relocation.c +13 -0
@@ -3967,6 +3967,19 @@ int btrfs_relocate_block_group(struct btint rw =0 ;int err =0 ; +/* +* This only gets set if we had a half-deleted snapshot on mount. We +* cannot allow relocation to start while we're still trying to clean up +* these pending deletions. +*/ + ret =wait_on_bit (&fs_info->flags,BTRFS_FS_UNFINISHED_DROPS ,TASK_INTERRUPTIBLE ); +if (ret) +return ret; + +/* We may have been woken up by close_ctree, so bail if we're closing. */ +if (btrfs_fs_closing (fs_info)) +return -EINTR ; + bg =btrfs_lookup_block_group (fs_info, group_start);if (!bg)return -ENOENT ;
fs/btrfs/root-tree.c +15 -0
@@ -280,6 +280,21 @@ int btrfs_find_orphan_roots(struct btrfsWARN_ON (!test_bit (BTRFS_ROOT_ORPHAN_ITEM_INSERTED , &root->state));if (btrfs_root_refs (&root->root_item) ==0 ) { +struct btrfs_key drop_key; + +btrfs_disk_key_to_cpu (&drop_key, &root->root_item.drop_progress); +/* +* If we have a non-zero drop_progress then we know we +* made it partly through deleting this snapshot, and +* thus we need to make sure we block any balance from +* happening until this snapshot is completely dropped. +*/ +if (drop_key.objectid !=0 || drop_key.type !=0 || + drop_key.offset !=0 ) { +set_bit (BTRFS_FS_UNFINISHED_DROPS , &fs_info->flags); +set_bit (BTRFS_ROOT_UNFINISHED_DROP , &root->state); + } +set_bit (BTRFS_ROOT_DEAD_TREE , &root->state);btrfs_add_dead_root (root); }
fs/btrfs/transaction.c +32 -1
@@ -1341,6 +1341,32 @@ again: }/* +* If we had a pending drop we need to see if there are any others left in our +* dead roots list, and if not clear our bit and wake any waiters. +*/ +void btrfs_maybe_wake_unfinished_drop (struct btrfs_fs_info *fs_info) +{ +/* +* We put the drop in progress roots at the front of the list, so if the +* first entry doesn't have UNFINISHED_DROP set we can wake everybody +* up. +*/ +spin_lock (&fs_info->trans_lock); +if (!list_empty (&fs_info->dead_roots)) { +struct btrfs_root *root =list_first_entry (&fs_info->dead_roots, + struct btrfs_root, + root_list); +if (test_bit (BTRFS_ROOT_UNFINISHED_DROP , &root->state)) { +spin_unlock (&fs_info->trans_lock); +return ; + } + } +spin_unlock (&fs_info->trans_lock); + +btrfs_wake_unfinished_drop (fs_info); +} + +/* * dead roots are old snapshots that need to be deleted. This allocates * a dirty root struct and adds it into the list of dead roots that need to * be deleted
@@ -1352,7 +1378,12 @@ void btrfs_add_dead_root(struct btrfs_rospin_lock (&fs_info->trans_lock);if (list_empty (&root->root_list)) {btrfs_grab_root (root); -list_add_tail (&root->root_list, &fs_info->dead_roots); + +/* We want to process the partially complete drops first. */ +if (test_bit (BTRFS_ROOT_UNFINISHED_DROP , &root->state)) +list_add (&root->root_list, &fs_info->dead_roots); +else +list_add_tail (&root->root_list, &fs_info->dead_roots); }spin_unlock (&fs_info->trans_lock); }
fs/btrfs/transaction.h +1 -0
@@ -217,6 +217,7 @@ int btrfs_wait_for_commit(struct btrfs_fvoid btrfs_add_dead_root (struct btrfs_root *root);int btrfs_defrag_root (struct btrfs_root *root); +void btrfs_maybe_wake_unfinished_drop (struct btrfs_fs_info *fs_info);int btrfs_clean_one_deleted_snapshot (struct btrfs_root *root);int btrfs_commit_transaction (struct btrfs_trans_handle *trans);int btrfs_commit_transaction_async (struct btrfs_trans_handle *trans);