5.16.19-rc1 review
Subsystems (11)
Greg Kroah-Hartman
maintainerPATCH 824/1017 media: atomisp: fix dummy_ptr check to avoid duplicate active_bo
In reply to Greg Kroah-HartmanFrom: Tsuchiya Yuto <[email protected]>
[ Upstream commit 127efdbc51fe6064336c0452ce9c910b3e107cf0 ]
The dummy_ptr check in hmm_init() [1] results in the following "hmm_init Failed to create sysfs" error exactly once every two times on atomisp reload by rmmod/insmod (although atomisp module loads and works fine regardless of this error):
[ 140.230662] sysfs: cannot create duplicate filename '/devices/pci0000:00/0000:00:03.0/active_bo' [ 140.230668] CPU: 1 PID: 2502 Comm: insmod Tainted: G C OE 5.15.0-rc4-1-surface-mainline #1 b8acf6eb64994414b2e20bad312a7a2c45f748f9 [ 140.230675] Hardware name: OEMB OEMB/OEMB, BIOS 1.51116.238 03/09/2015 [ 140.230678] Call Trace: [ 140.230687] dump_stack_lvl+0x46/0x5a [ 140.230702] sysfs_warn_dup.cold+0x17/0x24 [ 140.230710] sysfs_add_file_mode_ns+0x160/0x170 [ 140.230717] internal_create_group+0x126/0x390 [ 140.230723] hmm_init+0x5c/0x70 [atomisp 7a6a680bf400629363d2a6f58fd10e7299678b99] [ 140.230811] atomisp_pci_probe.cold+0x1136/0x148e [atomisp 7a6a680bf400629363d2a6f58fd10e7299678b99] [ 140.230875] local_pci_probe+0x45/0x80 [ 140.230882] ? pci_match_device+0xd7/0x130 [ 140.230887] pci_device_probe+0xfa/0x1b0 [ 140.230892] really_probe+0x1f5/0x3f0 [ 140.230899] __driver_probe_device+0xfe/0x180 [ 140.230903] driver_probe_device+0x1e/0x90 [ 140.230908] __driver_attach+0xc0/0x1c0 [ 140.230912] ? __device_attach_driver+0xe0/0xe0 [ 140.230915] ? __device_attach_driver+0xe0/0xe0 [ 140.230919] bus_for_each_dev+0x89/0xd0 [ 140.230924] bus_add_driver+0x12b/0x1e0 [ 140.230929] driver_register+0x8f/0xe0 [ 140.230933] ? 0xffffffffc153f000 [ 140.230937] do_one_initcall+0x57/0x220 [ 140.230945] do_init_module+0x5c/0x260 [ 140.230952] load_module+0x24bd/0x26a0 [ 140.230962] ? __do_sys_finit_module+0xae/0x110 [ 140.230966] __do_sys_finit_module+0xae/0x110 [ 140.230972] do_syscall_64+0x5c/0x80 [ 140.230979] ? syscall_exit_to_user_mode+0x23/0x40 [ 140.230983] ? do_syscall_64+0x69/0x80 [ 140.230988] ? exc_page_fault+0x72/0x170 [ 140.230991] entry_SYSCALL_64_after_hwframe+0x44/0xae [ 140.230997] RIP: 0033:0x7f7fd5d8718d [ 140.231003] Code: b4 0c 00 0f 05 eb a9 66 0f 1f 44 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 b3 6c 0c 00 f7 d8 64 89 01 48 [ 140.231006] RSP: 002b:00007ffefc25f0e8 EFLAGS: 00000246 ORIG_RAX: 0000000000000139 [ 140.231012] RAX: ffffffffffffffda RBX: 000055ac3edcd7f0 RCX: 00007f7fd5d8718d [ 140.231015] RDX: 0000000000000000 RSI: 000055ac3d723270 RDI: 0000000000000003 [ 140.231017] RBP: 0000000000000000 R08: 0000000000000000 R09: 00007f7fd5e52380 [ 140.231019] R10: 0000000000000003 R11: 0000000000000246 R12: 000055ac3d723270 [ 140.231021] R13: 0000000000000000 R14: 000055ac3edd06e0 R15: 0000000000000000 [ 140.231038] atomisp-isp2 0000:00:03.0: hmm_init Failed to create sysfs
The problem is that dummy_ptr == 0 is a valid value. So, change the logic which checks if dummy_ptr was allocated.
At this point, atomisp now gives WARN_ON() in hmm_free() [2] on atomisp reload by rmmod/insmod. Again, the check is wrong there.
So, change both checks for mmgr_EXCEPTION, which is the error value when HMM allocation fails, and initialize dummy_ptr with such value.
[1] added on commit
d9ab83953fa7 ("media: atomisp: don't cause a warn if probe failed")
[2] added on commit
b83cc378dfc4 ("atomisp: clean up the hmm init/cleanup indirections")
--- drivers/staging/media/atomisp/pci/hmm/hmm.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/staging/media/atomisp/pci/hmm/hmm.c +4 -3
@@ -39,7 +39,7 @@struct hmm_bo_device bo_device;struct hmm_pool dynamic_pool;struct hmm_pool reserved_pool; -static ia_css_ptr dummy_ptr; +static ia_css_ptr dummy_ptr = mmgr_EXCEPTION;static bool hmm_initialized;struct _hmm_mem_stat hmm_mem_stat;
@@ -209,7 +209,7 @@ int hmm_init(void)void hmm_cleanup (void ) { -if (!dummy_ptr) +if (dummy_ptr == mmgr_EXCEPTION)return ;sysfs_remove_group (&atomisp_dev->kobj, atomisp_attribute_group);
@@ -288,7 +288,8 @@ void hmm_free(ia_css_ptr virt)dev_dbg (atomisp_dev,"%s: free 0x%08x\n" , __func__, virt); -WARN_ON (!virt); +if (WARN_ON (virt == mmgr_EXCEPTION)) +return ; bo =hmm_bo_device_search_start (&bo_device, (unsigned int )virt);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 825/1017 ARM: ftrace: avoid redundant loads or clobbering IP
In reply to Greg Kroah-HartmanFrom: Ard Biesheuvel <[email protected]>
[ Upstream commit d11967870815b5ab89843980e35aab616c97c463 ]
Tweak the ftrace return paths to avoid redundant loads of SP, as well as unnecessary clobbering of IP.
This also fixes the inconsistency of using MOV to perform a function return, which is sub-optimal on recent micro-architectures but more importantly, does not perform an interworking return, unlike compiler generated function returns in Thumb2 builds.
Let's fix this by popping PC from the stack like most ordinary code does.
--- arch/arm/kernel/entry-ftrace.S | 51 +++++++++++++++------------------- 1 file changed, 22 insertions(+), 29 deletions(-)
arch/arm/kernel/entry-ftrace.S +22 -29
@@ -22,10 +22,7 @@ * mcount can be thought of as a function called in the middle of a subroutine * call. As such, it needs to be transparent for both the caller and the * callee: the original lr needs to be restored when leaving mcount, and no - * registers should be clobbered. (In the __gnu_mcount_nc implementation, we - * clobber the ip register. This is OK because the ARM calling convention - * allows it to be clobbered in subroutines and doesn't use it to hold - * parameters.) + * registers should be clobbered. * * When using dynamic ftrace, we patch out the mcount call by a "pop {lr}" * instead of the __gnu_mcount_nc call (see arch/arm/kernel/ftrace.c).
@@ -70,26 +67,25 @@ .macro __ftrace_regs_caller - sub sp, sp, #8 @ space for PC and CPSR OLD_R0, + str lr, [sp, #-8]! @ store LR as PC and make space for CPSR/OLD_R0, @ OLD_R0 will overwrite previous LR - add ip, sp, #12 @ move in IP the value of SP as it was - @ before the push {lr} of the mcount mechanism + ldr lr, [sp, #8] @ get previous LR - str lr, [sp, #0] @ store LR instead of PC + str r0, [sp, #8] @ write r0 as OLD_R0 over previous LR - ldr lr, [sp, #8] @ get previous LR + str lr, [sp, #-4]! @ store previous LR as LR - str r0, [sp, #8] @ write r0 as OLD_R0 over previous LR + add lr, sp, #16 @ move in LR the value of SP as it was + @ before the push {lr} of the mcount mechanism - stmdb sp!, {ip, lr} - stmdb sp!, {r0-r11, lr} + push {r0-r11, ip, lr} @ stack content at this point: @ 0 4 48 52 56 60 64 68 72 - @ R0 | R1 | ... | LR | SP + 4 | previous LR | LR | PSR | OLD_R0 | + @ R0 | R1 | ... | IP | SP + 4 | previous LR | LR | PSR | OLD_R0 | - mov r3, sp @ struct pt_regs* + mov r3, sp @ struct pt_regs* ldr r2, =function_trace_op ldr r2, [r2] @ pointer to the current
@@ -112,11 +108,9 @@ ftrace_graph_regs_call: #endif @ pop saved regs - ldmia sp!, {r0-r12} @ restore r0 through r12 - ldr ip, [sp, #8] @ restore PC - ldr lr, [sp, #4] @ restore LR - ldr sp, [sp, #0] @ restore SP - mov pc, ip @ return + pop {r0-r11, ip, lr} @ restore r0 through r12 + ldr lr, [sp], #4 @ restore LR + ldr pc, [sp], #12 .endm #ifdef CONFIG_FUNCTION_GRAPH_TRACER
@@ -132,11 +126,9 @@ ftrace_graph_regs_call: bl prepare_ftrace_return @ pop registers saved in ftrace_regs_caller - ldmia sp!, {r0-r12} @ restore r0 through r12 - ldr ip, [sp, #8] @ restore PC - ldr lr, [sp, #4] @ restore LR - ldr sp, [sp, #0] @ restore SP - mov pc, ip @ return + pop {r0-r11, ip, lr} @ restore r0 through r12 + ldr lr, [sp], #4 @ restore LR + ldr pc, [sp], #12 .endm #endif
@@ -202,16 +194,17 @@ ftrace_graph_call\suffix: .endm .macro mcount_exit - ldmia sp!, {r0-r3, ip, lr} - ret ip + ldmia sp!, {r0-r3} + ldr lr, [sp, #4] + ldr pc, [sp], #8 .endm ENTRY(__gnu_mcount_nc) UNWIND(.fnstart) #ifdef CONFIG_DYNAMIC_FTRACE - mov ip, lr - ldmia sp!, {lr} - ret ip + push {lr} + ldr lr, [sp, #4] + ldr pc, [sp], #8 #else __mcount #endif
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 826/1017 ALSA: hda: Fix driver index handling at re-binding
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
[ Upstream commit 69458e2c27800da7697c87ed908b65323ef3f3bd ]
HD-audio driver handles the multiple instances and keeps the static index that is incremented at each probe. This becomes a problem when user tries to re-bind the device via sysfs multiple times; as the device index isn't cleared unlike rmmod case, it points to the next element at re-binding, and eventually later you can't probe any more when it reaches to SNDRV_CARDS_MAX (usually 32).
This patch is an attempt to improve the handling at rebinding. Instead of a static device index, now we keep a bitmap and assigns to the first zero bit position. At the driver remove, in return, the bitmap slot is cleared again, so that it'll be available for the next probe.
--- sound/pci/hda/hda_intel.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
sound/pci/hda/hda_intel.c +7 -3
@@ -2061,14 +2061,16 @@ static const struct hda_controller_ops pci_hda_ops = { .position_check = azx_position_check, }; +static DECLARE_BITMAP(probed_devs, SNDRV_CARDS); +static int azx_probe (struct pci_dev *pci,const struct pci_device_id *pci_id) { -static int dev;struct snd_card *card;struct hda_intel *hda;struct azx *chip;bool schedule_probe; +int dev;int err;if (pci_match_id (driver_denylist, pci)) {
@@ -2076,10 +2078,11 @@ static int azx_probe(struct pci_dev *pci,return -ENODEV ; } + dev =find_first_zero_bit (probed_devs,SNDRV_CARDS );if (dev >=SNDRV_CARDS )return -ENODEV ;if (!enable[dev]) { - dev++; +set_bit (dev, probed_devs);return -ENOENT ; }
@@ -2146,7 +2149,7 @@ static int azx_probe(struct pci_dev *pci,if (schedule_probe)schedule_delayed_work (&hda->probe_work,0 ); - dev++; +set_bit (dev, probed_devs);if (chip->disabled)complete_all (&hda->probe_wait);return 0 ;
@@ -2369,6 +2372,7 @@ static void azx_remove(struct pci_dev *pci)cancel_delayed_work_sync (&hda->probe_work);device_lock (&pci->dev); +clear_bit (chip->dev_index, probed_devs);pci_set_drvdata (pci,NULL );snd_card_free (card); }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 827/1017 ARM: dts: imx7: Use audio_mclk_post_div instead audio_mclk_root_clk
In reply to Greg Kroah-HartmanFrom: Abel Vesa <[email protected]>
[ Upstream commit 4cb7df64c732b2b9918424095c11660c2a8c4a33 ]
The audio_mclk_root_clk was added as a gate with the CCGR121 (0x4790), but according to the reference manual, there is no such gate. Moreover, the consumer driver of the mentioned clock might gate it and leave the ECSPI2 (the true owner of that gate) hanging. So lets use the audio_mclk_post_div, which is the parent.
--- arch/arm/boot/dts/imx7-colibri.dtsi | 4 ++-- arch/arm/boot/dts/imx7-mba7.dtsi | 2 +- arch/arm/boot/dts/imx7d-nitrogen7.dts | 2 +- arch/arm/boot/dts/imx7d-pico-hobbit.dts | 4 ++-- arch/arm/boot/dts/imx7d-pico-pi.dts | 4 ++-- arch/arm/boot/dts/imx7d-sdb.dts | 4 ++-- arch/arm/boot/dts/imx7s-warp.dts | 4 ++-- 7 files changed, 12 insertions(+), 12 deletions(-)
arch/arm/boot/dts/imx7-colibri.dtsi +2 -2
@@ -40,7 +40,7 @@ dailink_master: simple-audio-card,codec { sound-dai = <&codec>; - clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_CLK>; + clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_DIV>; }; }; };
@@ -293,7 +293,7 @@ compatible = "fsl,sgtl5000"; #sound-dai-cells = <0>; reg = <0x0a>; - clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_CLK>; + clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_DIV>; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_sai1_mclk>; VDDA-supply = <®_module_3v3_avdd>;
arch/arm/boot/dts/imx7-mba7.dtsi +1 -1
@@ -302,7 +302,7 @@ tlv320aic32x4: audio-codec@18 { compatible = "ti,tlv320aic32x4"; reg = <0x18>; - clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_CLK>; + clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_DIV>; clock-names = "mclk"; ldoin-supply = <®_audio_3v3>; iov-supply = <®_audio_3v3>;
arch/arm/boot/dts/imx7d-nitrogen7.dts +1 -1
@@ -288,7 +288,7 @@ codec: wm8960@1a { compatible = "wlf,wm8960"; reg = <0x1a>; - clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_CLK>; + clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_DIV>; clock-names = "mclk"; wlf,shared-lrclk; };
arch/arm/boot/dts/imx7d-pico-hobbit.dts +2 -2
@@ -31,7 +31,7 @@ dailink_master: simple-audio-card,codec { sound-dai = <&sgtl5000>; - clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_CLK>; + clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_DIV>; }; }; };
@@ -41,7 +41,7 @@ #sound-dai-cells = <0>; reg = <0x0a>; compatible = "fsl,sgtl5000"; - clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_CLK>; + clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_DIV>; VDDA-supply = <®_2p5v>; VDDIO-supply = <®_vref_1v8>; };
arch/arm/boot/dts/imx7d-pico-pi.dts +2 -2
@@ -31,7 +31,7 @@ dailink_master: simple-audio-card,codec { sound-dai = <&sgtl5000>; - clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_CLK>; + clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_DIV>; }; }; };
@@ -41,7 +41,7 @@ #sound-dai-cells = <0>; reg = <0x0a>; compatible = "fsl,sgtl5000"; - clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_CLK>; + clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_DIV>; VDDA-supply = <®_2p5v>; VDDIO-supply = <®_vref_1v8>; };
arch/arm/boot/dts/imx7d-sdb.dts +2 -2
@@ -385,14 +385,14 @@ codec: wm8960@1a { compatible = "wlf,wm8960"; reg = <0x1a>; - clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_CLK>; + clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_DIV>; clock-names = "mclk"; wlf,shared-lrclk; wlf,hp-cfg = <2 2 3>; wlf,gpio-cfg = <1 3>; assigned-clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_SRC>, <&clks IMX7D_PLL_AUDIO_POST_DIV>, - <&clks IMX7D_AUDIO_MCLK_ROOT_CLK>; + <&clks IMX7D_AUDIO_MCLK_ROOT_DIV>; assigned-clock-parents = <&clks IMX7D_PLL_AUDIO_POST_DIV>; assigned-clock-rates = <0>, <884736000>, <12288000>; };
arch/arm/boot/dts/imx7s-warp.dts +2 -2
@@ -75,7 +75,7 @@ dailink_master: simple-audio-card,codec { sound-dai = <&codec>; - clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_CLK>; + clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_DIV>; }; }; };
@@ -232,7 +232,7 @@ #sound-dai-cells = <0>; reg = <0x0a>; compatible = "fsl,sgtl5000"; - clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_CLK>; + clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_DIV>; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_sai1_mclk>; VDDA-supply = <&vgen4_reg>;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 828/1017 arm64: defconfig: build imx-sdma as a module
In reply to Greg Kroah-HartmanFrom: Marcel Ziswiler <[email protected]>
[ Upstream commit e95622289f263662240544a9f0009b25c19e64d4 ]
This avoids firmware load error and sysfs fallback reported as follows:
[ 0.199448] imx-sdma 302c0000.dma-controller: Direct firmware load for imx/sdma/sdma-imx7d.bin failed with error -2 [ 0.199487] imx-sdma 302c0000.dma-controller: Falling back to sysfs fallback for: imx/sdma/sdma-imx7d.bin
--- arch/arm64/configs/defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/configs/defconfig +1 -1
@@ -931,7 +931,7 @@ CONFIG_DMADEVICES=y CONFIG_DMA_BCM2835=y CONFIG_DMA_SUN6I=m CONFIG_FSL_EDMA=y -CONFIG_IMX_SDMA=y +CONFIG_IMX_SDMA=m CONFIG_K3_DMA=y CONFIG_MV_XOR=y CONFIG_MV_XOR_V2=y
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 829/1017 video: fbdev: omapfb: panel-dsi-cm: Use sysfs_emit() instead of snprintf()
In reply to Greg Kroah-HartmanFrom: Jing Yao <[email protected]>
[ Upstream commit f63658a59c3d439c8ad7b290f8ec270980e0f384 ]
Use sysfs_emit instead of scnprintf, snprintf or sprintf.
--- drivers/video/fbdev/omap2/omapfb/displays/panel-dsi-cm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/video/fbdev/omap2/omapfb/displays/panel-dsi-cm.c +4 -4
@@ -409,7 +409,7 @@ static ssize_t dsicm_num_errors_show(struct device *dev,if (r)return r; -return snprintf (buf,PAGE_SIZE ,"%d\n" , errors); +return sysfs_emit (buf,"%d\n" , errors); } static ssize_t dsicm_hw_revision_show(struct device *dev,
@@ -439,7 +439,7 @@ static ssize_t dsicm_hw_revision_show(struct device *dev,if (r)return r; -return snprintf (buf,PAGE_SIZE ,"%02x.%02x.%02x\n" , id1, id2, id3); +return sysfs_emit (buf,"%02x.%02x.%02x\n" , id1, id2, id3); } static ssize_t dsicm_store_ulps(struct device *dev,
@@ -487,7 +487,7 @@ static ssize_t dsicm_show_ulps(struct device *dev, t = ddata->ulps_enabled;mutex_unlock (&ddata->lock); -return snprintf (buf,PAGE_SIZE ,"%u\n" , t); +return sysfs_emit (buf,"%u\n" , t); } static ssize_t dsicm_store_ulps_timeout(struct device *dev,
@@ -532,7 +532,7 @@ static ssize_t dsicm_show_ulps_timeout(struct device *dev, t = ddata->ulps_timeout;mutex_unlock (&ddata->lock); -return snprintf (buf,PAGE_SIZE ,"%u\n" , t); +return sysfs_emit (buf,"%u\n" , t); } static DEVICE_ATTR(num_dsi_errors, S_IRUGO, dsicm_num_errors_show, NULL);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 830/1017 video: fbdev: omapfb: panel-tpo-td043mtea1: Use sysfs_emit() instead of snprintf()
In reply to Greg Kroah-HartmanFrom: Jing Yao <[email protected]>
[ Upstream commit c07a039cbb96748f54c02995bae8131cc9a73b0a ]
Use sysfs_emit instead of scnprintf, snprintf or sprintf.
--- .../video/fbdev/omap2/omapfb/displays/panel-tpo-td043mtea1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/video/fbdev/omap2/omapfb/displays/panel-tpo-td043mtea1.c +2 -2
@@ -169,7 +169,7 @@ static ssize_t tpo_td043_vmirror_show(struct device *dev, {struct panel_drv_data *ddata =dev_get_drvdata (dev); -return snprintf (buf,PAGE_SIZE ,"%d\n" , ddata->vmirror); +return sysfs_emit (buf,"%d\n" , ddata->vmirror); } static ssize_t tpo_td043_vmirror_store(struct device *dev,
@@ -199,7 +199,7 @@ static ssize_t tpo_td043_mode_show(struct device *dev, {struct panel_drv_data *ddata =dev_get_drvdata (dev); -return snprintf (buf,PAGE_SIZE ,"%d\n" , ddata->mode); +return sysfs_emit (buf,"%d\n" , ddata->mode); } static ssize_t tpo_td043_mode_store(struct device *dev,
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 831/1017 video: fbdev: udlfb: replace snprintf in show functions with sysfs_emit
In reply to Greg Kroah-HartmanFrom: Jing Yao <[email protected]>
[ Upstream commit 81a998288956d09d7a7a2303d47e4d60ad55c401 ]
Use sysfs_emit instead of scnprintf, snprintf or sprintf.
--- drivers/video/fbdev/udlfb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/video/fbdev/udlfb.c +4 -4
@@ -1426,7 +1426,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev, struct device_attribute *a, char *buf) { struct fb_info *fb_info = dev_get_drvdata(fbdev);struct dlfb_data *dlfb = fb_info->par; -return snprintf (buf,PAGE_SIZE ,"%u\n" , +return sysfs_emit (buf,"%u\n" ,atomic_read (&dlfb->bytes_rendered)); }
@@ -1434,7 +1434,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev, struct device_attribute *a, char *buf) { struct fb_info *fb_info = dev_get_drvdata(fbdev);struct dlfb_data *dlfb = fb_info->par; -return snprintf (buf,PAGE_SIZE ,"%u\n" , +return sysfs_emit (buf,"%u\n" ,atomic_read (&dlfb->bytes_identical)); }
@@ -1442,7 +1442,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev, struct device_attribute *a, char *buf) { struct fb_info *fb_info = dev_get_drvdata(fbdev);struct dlfb_data *dlfb = fb_info->par; -return snprintf (buf,PAGE_SIZE ,"%u\n" , +return sysfs_emit (buf,"%u\n" ,atomic_read (&dlfb->bytes_sent)); }
@@ -1450,7 +1450,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev, struct device_attribute *a, char *buf) { struct fb_info *fb_info = dev_get_drvdata(fbdev);struct dlfb_data *dlfb = fb_info->par; -return snprintf (buf,PAGE_SIZE ,"%u\n" , +return sysfs_emit (buf,"%u\n" ,atomic_read (&dlfb->cpu_kcycles_used)); }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 832/1017 ARM: dts: bcm2711: Add the missing L1/L2 cache information
In reply to Greg Kroah-HartmanFrom: Richard Schleich <[email protected]>
[ Upstream commit 618682b350990f8f1bee718949c4b3858711eb58 ]
This patch fixes the kernel warning "cacheinfo: Unable to detect cache hierarchy for CPU 0" for the bcm2711 on newer kernel versions.
--- arch/arm/boot/dts/bcm2711.dtsi | 50 ++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+)
arch/arm/boot/dts/bcm2711.dtsi +50 -0
@@ -459,12 +459,26 @@ #size-cells = <0>; enable-method = "brcm,bcm2836-smp"; // for ARM 32-bit + /* Source for d/i-cache-line-size and d/i-cache-sets + * https://developer.arm.com/documentation/100095/0003 + * /Level-1-Memory-System/About-the-L1-memory-system?lang=en + * Source for d/i-cache-size + * https://www.raspberrypi.com/documentation/computers + * /processors.html#bcm2711 + */ cpu0: cpu@0 { device_type = "cpu"; compatible = "arm,cortex-a72"; reg = <0>; enable-method = "spin-table"; cpu-release-addr = <0x0 0x000000d8>; + d-cache-size = <0x8000>; + d-cache-line-size = <64>; + d-cache-sets = <256>; // 32KiB(size)/64(line-size)=512ways/2-way set + i-cache-size = <0xc000>; + i-cache-line-size = <64>; + i-cache-sets = <256>; // 48KiB(size)/64(line-size)=768ways/3-way set + next-level-cache = <&l2>; }; cpu1: cpu@1 {
@@ -473,6 +487,13 @@ reg = <1>; enable-method = "spin-table"; cpu-release-addr = <0x0 0x000000e0>; + d-cache-size = <0x8000>; + d-cache-line-size = <64>; + d-cache-sets = <256>; // 32KiB(size)/64(line-size)=512ways/2-way set + i-cache-size = <0xc000>; + i-cache-line-size = <64>; + i-cache-sets = <256>; // 48KiB(size)/64(line-size)=768ways/3-way set + next-level-cache = <&l2>; }; cpu2: cpu@2 {
@@ -481,6 +502,13 @@ reg = <2>; enable-method = "spin-table"; cpu-release-addr = <0x0 0x000000e8>; + d-cache-size = <0x8000>; + d-cache-line-size = <64>; + d-cache-sets = <256>; // 32KiB(size)/64(line-size)=512ways/2-way set + i-cache-size = <0xc000>; + i-cache-line-size = <64>; + i-cache-sets = <256>; // 48KiB(size)/64(line-size)=768ways/3-way set + next-level-cache = <&l2>; }; cpu3: cpu@3 {
@@ -489,6 +517,28 @@ reg = <3>; enable-method = "spin-table"; cpu-release-addr = <0x0 0x000000f0>; + d-cache-size = <0x8000>; + d-cache-line-size = <64>; + d-cache-sets = <256>; // 32KiB(size)/64(line-size)=512ways/2-way set + i-cache-size = <0xc000>; + i-cache-line-size = <64>; + i-cache-sets = <256>; // 48KiB(size)/64(line-size)=768ways/3-way set + next-level-cache = <&l2>; + }; + + /* Source for d/i-cache-line-size and d/i-cache-sets + * https://developer.arm.com/documentation/100095/0003 + * /Level-2-Memory-System/About-the-L2-memory-system?lang=en + * Source for d/i-cache-size + * https://www.raspberrypi.com/documentation/computers + * /processors.html#bcm2711 + */ + l2: l2-cache0 { + compatible = "cache"; + cache-size = <0x100000>; + cache-line-size = <64>; + cache-sets = <1024>; // 1MiB(size)/64(line-size)=16384ways/16-way set + cache-level = <2>; }; };
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 833/1017 ASoC: soc-core: skip zero num_dai component in searching dai name
In reply to Greg Kroah-HartmanFrom: Shengjiu Wang <[email protected]>
[ Upstream commit f7d344a2bd5ec81fbd1ce76928fd059e57ec9bea ]
In the case like dmaengine which's not a dai but as a component, the num_dai is zero, dmaengine component has the same component_of_node as cpu dai, when cpu dai component is not ready, but dmaengine component is ready, try to get cpu dai name, the snd_soc_get_dai_name() return -EINVAL, not -EPROBE_DEFER, that cause below error:
asoc-simple-card <card name>: parse error -22
asoc-simple-card: probe of <card name> failed with error -22
The sound card failed to probe.
So this patch fixes the issue above by skipping the zero num_dai component in searching dai name.
--- sound/soc/soc-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/soc-core.c +1 -1
@@ -3184,7 +3184,7 @@ int snd_soc_get_dai_name(const struct of_phandle_args *args,for_each_component (pos) {struct device_node *component_of_node =soc_component_to_node (pos); -if (component_of_node != args->np) +if (component_of_node != args->np || !pos->num_dai)continue ; ret =snd_soc_component_of_xlate_dai_name (pos, args, dai_name);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 834/1017 ASoC: Intel: sof_es8336: add quirk for Huawei D15 2021
In reply to Greg Kroah-HartmanFrom: Mauro Carvalho Chehab <[email protected]>
[ Upstream commit ce6a70bfce21bb4edb7c0f29ecfb0522fa34ab71 ]
Huawei D15 uses SSP_CODEC(0).
--- sound/soc/intel/boards/sof_es8336.c | 8 ++++++++ 1 file changed, 8 insertions(+)
sound/soc/intel/boards/sof_es8336.c +8 -0
@@ -247,6 +247,14 @@ static const struct dmi_system_id sof_es8336_quirk_table[] = { SOF_ES8336_TGL_GPIO_QUIRK | SOF_ES8336_ENABLE_DMIC) }, + { + .callback = sof_es8336_quirk_cb, + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "HUAWEI"), + DMI_MATCH(DMI_BOARD_NAME, "BOHB-WAX9-PCB-B2"), + }, + .driver_data = (void *)SOF_ES8336_SSP_CODEC(0) + }, {} };
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 835/1017 media: imx-jpeg: fix a bug of accessing array out of bounds
In reply to Greg Kroah-HartmanFrom: Ming Qian <[email protected]>
[ Upstream commit 97558d170a1236280407e8d29a7d095d2c2ed554 ]
When error occurs in parsing jpeg, the slot isn't acquired yet, it may be the default value MXC_MAX_SLOTS.
If the driver access the slot using the incorrect slot number, it will access array out of bounds.
The result is the driver will change num_domains, which follows slot_data in struct mxc_jpeg_dev.
Then the driver won't detach the pm domain at rmmod, which will lead to kernel panic when trying to insmod again.
--- drivers/media/platform/imx-jpeg/mxc-jpeg.c | 1 - 1 file changed, 1 deletion(-)
drivers/media/platform/imx-jpeg/mxc-jpeg.c +0 -1
@@ -954,7 +954,6 @@ static void mxc_jpeg_device_run(void *priv) jpeg_src_buf->jpeg_parse_error = true; }if (jpeg_src_buf->jpeg_parse_error) { - jpeg->slot_data[ctx->slot].used = false;v4l2_m2m_src_buf_remove (ctx->fh.m2m_ctx);v4l2_m2m_dst_buf_remove (ctx->fh.m2m_ctx);v4l2_m2m_buf_done (src_buf,VB2_BUF_STATE_ERROR );
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 836/1017 media: cx88-mpeg: clear interrupt status register before streaming video
In reply to Greg Kroah-HartmanFrom: Daniel González Cabanelas <[email protected]>
[ Upstream commit 56cb61f70e547e1b0cdfe6ff5a1f1ce6242e6d96 ]
Some cx88 video cards may have transport stream status interrupts set to 1 from cold start, causing errors like this:
cx88xx: cx88_print_irqbits: core:irq mpeg [0x100000] ts_err?*
cx8802: cx8802_mpeg_irq: mpeg:general errors: 0x00100000
According to CX2388x datasheet, the interrupt status register should be cleared before enabling IRQs to stream video.
Fix it by clearing the Transport Stream Interrupt Status register.
--- drivers/media/pci/cx88/cx88-mpeg.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/media/pci/cx88/cx88-mpeg.c +3 -0
@@ -162,6 +162,9 @@ int cx8802_start_dma(struct cx8802_dev *dev,cx_write (MO_TS_GPCNTRL ,GP_COUNT_CONTROL_RESET ); q->count =0 ; +/* clear interrupt status register */ +cx_write (MO_TS_INTSTAT ,0x1f1111 ); +/* enable irqs */ dprintk (1 ,"setting the interrupt mask\n" );cx_set (MO_PCI_INTMSK , core->pci_irqmask |PCI_INT_TSINT );
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 837/1017 ASoC: rt5682s: Fix the wrong jack type detected
In reply to Greg Kroah-HartmanFrom: Derek Fang <[email protected]>
[ Upstream commit c07ac3ee76e5e5506bca9c03fbbb15e40ab28430 ]
Some powers were changed during the jack insert detection and clk's enable/disable in CCF.
If in parallel, the influence has a chance to detect the wrong jack type.
We refer to the below commit of the variant codec (rt5682) to fix this issue.
ASoC: rt5682: Fix deadlock on resume
1. Remove rt5682s_headset_detect in rt5682s_jd_check_handler and use jack_detect_work instead of.
2. Use dapm mutex used in CCF to protect most of jack_detect_work.
--- sound/soc/codecs/rt5682s.c | 26 +++++++++----------------- sound/soc/codecs/rt5682s.h | 1 - 2 files changed, 9 insertions(+), 18 deletions(-)
sound/soc/codecs/rt5682s.c +9 -17
@@ -822,6 +822,7 @@ static void rt5682s_jack_detect_handler(struct work_struct *work) {struct rt5682s_priv *rt5682s = container_of(work, struct rt5682s_priv, jack_detect_work.work); +struct snd_soc_dapm_context *dapm;int val, btn_type; if (!rt5682s->component || !rt5682s->component->card ||
@@ -832,7 +833,9 @@ static void rt5682s_jack_detect_handler(struct work_struct *work)return ; } -mutex_lock (&rt5682s->jdet_mutex); + dapm =snd_soc_component_get_dapm (rt5682s->component); + +snd_soc_dapm_mutex_lock (dapm);mutex_lock (&rt5682s->calibrate_mutex); val =snd_soc_component_read (rt5682s->component,RT5682S_AJD1_CTRL )
@@ -889,6 +892,9 @@ static void rt5682s_jack_detect_handler(struct work_struct *work) rt5682s->irq_work_delay_time =50 ; } +mutex_unlock (&rt5682s->calibrate_mutex); +snd_soc_dapm_mutex_unlock (dapm); +snd_soc_jack_report (rt5682s->hs_jack, rt5682s->jack_type,SND_JACK_HEADSET |SND_JACK_BTN_0 |SND_JACK_BTN_1 |SND_JACK_BTN_2 |SND_JACK_BTN_3 );
@@ -898,9 +904,6 @@ static void rt5682s_jack_detect_handler(struct work_struct *work)schedule_delayed_work (&rt5682s->jd_check_work,0 ); else cancel_delayed_work_sync(&rt5682s->jd_check_work); - -mutex_unlock (&rt5682s->calibrate_mutex); -mutex_unlock (&rt5682s->jdet_mutex); }static void rt5682s_jd_check_handler (struct work_struct *work)
@@ -908,14 +911,9 @@ static void rt5682s_jd_check_handler(struct work_struct *work)struct rt5682s_priv *rt5682s = container_of(work, struct rt5682s_priv, jd_check_work.work); -if (snd_soc_component_read (rt5682s->component,RT5682S_AJD1_CTRL ) - &RT5682S_JDH_RS_MASK ) { +if (snd_soc_component_read (rt5682s->component,RT5682S_AJD1_CTRL ) &RT5682S_JDH_RS_MASK ) {/* jack out */ - rt5682s->jack_type =rt5682s_headset_detect (rt5682s->component,0 ); - -snd_soc_jack_report (rt5682s->hs_jack, rt5682s->jack_type, -SND_JACK_HEADSET |SND_JACK_BTN_0 |SND_JACK_BTN_1 | -SND_JACK_BTN_2 |SND_JACK_BTN_3 ); +schedule_delayed_work (&rt5682s->jack_detect_work,0 ); }else {schedule_delayed_work (&rt5682s->jd_check_work,500 ); }
@@ -1323,7 +1321,6 @@ static int rt5682s_hp_amp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) {struct snd_soc_component *component =snd_soc_dapm_to_component (w->dapm); -struct rt5682s_priv *rt5682s =snd_soc_component_get_drvdata (component);switch (event) {case SND_SOC_DAPM_POST_PMU :
@@ -1339,8 +1336,6 @@ static int rt5682s_hp_amp_event(struct snd_soc_dapm_widget *w,snd_soc_component_write (component,RT5682S_BIAS_CUR_CTRL_11 ,0x6666 );snd_soc_component_write (component,RT5682S_BIAS_CUR_CTRL_12 ,0xa82a ); -mutex_lock (&rt5682s->jdet_mutex); - snd_soc_component_update_bits(component, RT5682S_HP_CTRL_2, RT5682S_HPO_L_PATH_MASK | RT5682S_HPO_R_PATH_MASK | RT5682S_HPO_SEL_IP_EN_SW, RT5682S_HPO_L_PATH_EN |
@@ -1348,8 +1343,6 @@ static int rt5682s_hp_amp_event(struct snd_soc_dapm_widget *w,usleep_range (5000 ,10000 );snd_soc_component_update_bits (component,RT5682S_HP_AMP_DET_CTL_1 ,RT5682S_CP_SW_SIZE_MASK ,RT5682S_CP_SW_SIZE_L |RT5682S_CP_SW_SIZE_S ); - -mutex_unlock (&rt5682s->jdet_mutex);break ;case SND_SOC_DAPM_POST_PMD :
@@ -3075,7 +3068,6 @@ static int rt5682s_i2c_probe(struct i2c_client *i2c,mutex_init (&rt5682s->calibrate_mutex);mutex_init (&rt5682s->sar_mutex); -mutex_init (&rt5682s->jdet_mutex);rt5682s_calibrate (rt5682s); regmap_update_bits(rt5682s->regmap, RT5682S_MICBIAS_2,
sound/soc/codecs/rt5682s.h +0 -1
@@ -1446,7 +1446,6 @@ struct rt5682s_priv {struct delayed_work jd_check_work;struct mutex calibrate_mutex;struct mutex sar_mutex; -struct mutex jdet_mutex;#ifdef CONFIG_COMMON_CLK struct clk_hw dai_clks_hw[RT5682S_DAI_NUM_CLKS ];
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 838/1017 uaccess: fix type mismatch warnings from access_ok()
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 23fc539e81295b14b50c6ccc5baeb4f3d59d822d ]
On some architectures, access_ok() does not do any argument type checking, so replacing the definition with a generic one causes a few warnings for harmless issues that were never caught before.
Fix the ones that I found either through my own test builds or that were reported by the 0-day bot.
--- arch/arc/kernel/process.c | 2 +- arch/arm/kernel/swp_emulate.c | 2 +- arch/arm/kernel/traps.c | 2 +- arch/csky/kernel/perf_callchain.c | 2 +- arch/csky/kernel/signal.c | 2 +- arch/nios2/kernel/signal.c | 20 +++++++++++--------- arch/powerpc/lib/sstep.c | 4 ++-- arch/riscv/kernel/perf_callchain.c | 4 ++-- arch/sparc/kernel/signal_32.c | 2 +- lib/test_lockup.c | 4 ++-- 10 files changed, 23 insertions(+), 21 deletions(-)
arch/arc/kernel/process.c +1 -1
@@ -43,7 +43,7 @@ SYSCALL_DEFINE0(arc_gettls)return task_thread_info (current)->thr_ptr; } -SYSCALL_DEFINE3(arc_usr_cmpxchg, int *, uaddr, int, expected, int, new) +SYSCALL_DEFINE3(arc_usr_cmpxchg, int __user *, uaddr, int, expected, int, new) {struct pt_regs *regs =current_pt_regs ();u32 uval;
arch/arm/kernel/swp_emulate.c +1 -1
@@ -195,7 +195,7 @@ static int swp_handler(struct pt_regs *regs, unsigned int instr) destreg, EXTRACT_REG_NUM(instr, RT2_OFFSET), data);/* Check access in reasonable access range for both SWP and SWPB */ -if (!access_ok ((address & ~3 ),4 )) { +if (!access_ok ((void __user *)(address & ~3 ),4 )) {pr_debug ("SWP{B} emulation: access to %p not allowed!\n" , (void *)address); res = -EFAULT ;
arch/arm/kernel/traps.c +1 -1
@@ -575,7 +575,7 @@ do_cache_op(unsigned long start, unsigned long end, int flags)if (end < start || flags)return -EINVAL ; -if (!access_ok (start, end - start)) +if (!access_ok ((void __user *)start, end - start))return -EFAULT ;return __do_cache_op (start, end);
arch/csky/kernel/perf_callchain.c +1 -1
@@ -49,7 +49,7 @@ static unsigned long user_backtrace(struct perf_callchain_entry_ctx *entry, {struct stackframe buftail;unsigned long lr =0 ; -unsigned long *user_frame_tail = (unsigned long *)fp; +unsigned long __user *user_frame_tail = (unsigned long __user *)fp;/* Check accessibility of one struct frame_tail beyond */ if (!access_ok (user_frame_tail,sizeof (buftail)))
arch/csky/kernel/signal.c +1 -1
@@ -136,7 +136,7 @@ static inline void __user *get_sigframe(struct ksignal *ksig,static int setup_rt_frame (struct ksignal *ksig,sigset_t *set,struct pt_regs *regs) { -struct rt_sigframe *frame; +struct rt_sigframe __user *frame;int err =0 ; frame =get_sigframe (ksig, regs,sizeof (*frame));
arch/nios2/kernel/signal.c +11 -9
@@ -36,10 +36,10 @@ struct rt_sigframe {static inline int rt_restore_ucontext (struct pt_regs *regs,struct switch_stack *sw, -struct ucontext *uc,int *pr2) +struct ucontext __user *uc,int *pr2) {int temp; -unsigned long *gregs = uc->uc_mcontext.gregs; +unsigned long __user *gregs = uc->uc_mcontext.gregs;int err;/* Always make any pending restarted system calls return -EINTR */
@@ -102,10 +102,11 @@ asmlinkage int do_rt_sigreturn(struct switch_stack *sw) {struct pt_regs *regs = (struct pt_regs *)(sw +1 );/* Verify, can we follow the stack back */ -struct rt_sigframe *frame = (struct rt_sigframe *) regs->sp; +struct rt_sigframe __user *frame;sigset_t set;int rval; + frame = (struct rt_sigframe __user *) regs->sp;if (!access_ok (frame,sizeof (*frame))) goto badframe;
@@ -124,10 +125,10 @@ asmlinkage int do_rt_sigreturn(struct switch_stack *sw)return 0 ; } -static inline int rt_setup_ucontext (struct ucontext *uc,struct pt_regs *regs) +static inline int rt_setup_ucontext (struct ucontext __user *uc,struct pt_regs *regs) {struct switch_stack *sw = (struct switch_stack *)regs -1 ; -unsigned long *gregs = uc->uc_mcontext.gregs; +unsigned long __user *gregs = uc->uc_mcontext.gregs;int err =0 ; err |=__put_user (MCONTEXT_VERSION , &uc->uc_mcontext.version);
@@ -162,8 +163,9 @@ static inline int rt_setup_ucontext(struct ucontext *uc, struct pt_regs *regs)return err; } -static inline void *get_sigframe (struct ksignal *ksig,struct pt_regs *regs, -size_t frame_size) +static inline void __user *get_sigframe (struct ksignal *ksig, +struct pt_regs *regs, +size_t frame_size) {unsigned long usp;
@@ -174,13 +176,13 @@ static inline void *get_sigframe(struct ksignal *ksig, struct pt_regs *regs, usp =sigsp (usp, ksig);/* Verify, is it 32 or 64 bit aligned */ -return (void *)((usp - frame_size) &-8UL ); +return (void __user *)((usp - frame_size) &-8UL ); }static int setup_rt_frame (struct ksignal *ksig,sigset_t *set,struct pt_regs *regs) { -struct rt_sigframe *frame; +struct rt_sigframe __user *frame;int err =0 ; frame =get_sigframe (ksig, regs,sizeof (*frame));
arch/powerpc/lib/sstep.c +2 -2
@@ -112,9 +112,9 @@ static nokprobe_inline long address_ok(struct pt_regs *regs, {if (!user_mode (regs))return 1 ; -if (__access_ok (ea, nb)) +if (access_ok ((void __user *)ea, nb))return 1 ; -if (__access_ok (ea,1 )) +if (access_ok ((void __user *)ea,1 ))/* Access overlaps the end of the user region */ regs->dar =TASK_SIZE_MAX -1 ;else
arch/riscv/kernel/perf_callchain.c +2 -2
@@ -15,8 +15,8 @@ static unsigned long user_backtrace(struct perf_callchain_entry_ctx *entry, {struct stackframe buftail;unsigned long ra =0 ; -unsigned long *user_frame_tail = - (unsigned long *)(fp -sizeof (struct stackframe )); +unsigned long __user *user_frame_tail = + (unsigned long __user *)(fp -sizeof (struct stackframe ));/* Check accessibility of one struct frame_tail beyond */ if (!access_ok (user_frame_tail,sizeof (buftail)))
arch/sparc/kernel/signal_32.c +1 -1
@@ -65,7 +65,7 @@ struct rt_signal_frame {*/ static inline bool invalid_frame_pointer (void __user *fp,int fplen) { -if ((((unsigned long ) fp) &15 ) || !__access_ok ((unsigned long )fp, fplen)) +if ((((unsigned long ) fp) &15 ) || !access_ok (fp, fplen))return true;return false;
lib/test_lockup.c +2 -2
@@ -417,8 +417,8 @@ static bool test_kernel_ptr(unsigned long addr, int size)return false;/* should be at least readable kernel address */ -if (access_ok (ptr,1 ) || -access_ok (ptr + size -1 ,1 ) || +if (access_ok ((void __user *)ptr,1 ) || +access_ok ((void __user *)ptr + size -1 ,1 ) ||get_kernel_nofault (buf, ptr) ||get_kernel_nofault (buf, ptr + size -1 )) {pr_err ("invalid kernel ptr: %#lx\n" , addr);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 839/1017 lib/test_lockup: fix kernel pointer check for separate address spaces
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 5a06fcb15b43d1f7bf740c672950122331cb5655 ]
test_kernel_ptr() uses access_ok() to figure out if a given address points to user space instead of kernel space. However on architectures that set CONFIG_ALTERNATE_USER_ADDRESS_SPACE, a pointer can be valid for both, and the check always fails because access_ok() returns true.
Make the check for user space pointers conditional on the type of address space layout.
--- lib/test_lockup.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
lib/test_lockup.c +8 -3
@@ -417,9 +417,14 @@ static bool test_kernel_ptr(unsigned long addr, int size)return false;/* should be at least readable kernel address */ -if (access_ok ((void __user *)ptr,1 ) || -access_ok ((void __user *)ptr + size -1 ,1 ) || -get_kernel_nofault (buf, ptr) || +if (!IS_ENABLED (CONFIG_ALTERNATE_USER_ADDRESS_SPACE ) && + (access_ok ((void __user *)ptr,1 ) || +access_ok ((void __user *)ptr + size -1 ,1 ))) { +pr_err ("user space ptr invalid in kernel: %#lx\n" , addr); +return true; + } + +if (get_kernel_nofault (buf, ptr) ||get_kernel_nofault (buf, ptr + size -1 )) {pr_err ("invalid kernel ptr: %#lx\n" , addr);return true;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 840/1017 ARM: tegra: tamonten: Fix I2C3 pad setting
In reply to Greg Kroah-HartmanFrom: Richard Leitner <[email protected]>
[ Upstream commit 0092c25b541a5422d7e71892a13c55ee91abc34b ]
This patch fixes the tristate configuration for i2c3 function assigned to the dtf pins on the Tamonten Tegra20 SoM.
--- arch/arm/boot/dts/tegra20-tamonten.dtsi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm/boot/dts/tegra20-tamonten.dtsi +3 -3
@@ -183,8 +183,8 @@ }; conf_ata { nvidia,pins = "ata", "atb", "atc", "atd", "ate", - "cdev1", "cdev2", "dap1", "dtb", "gma", - "gmb", "gmc", "gmd", "gme", "gpu7", + "cdev1", "cdev2", "dap1", "dtb", "dtf", + "gma", "gmb", "gmc", "gmd", "gme", "gpu7", "gpv", "i2cp", "irrx", "irtx", "pta", "rm", "slxa", "slxk", "spia", "spib", "uac";
@@ -203,7 +203,7 @@ }; conf_crtp { nvidia,pins = "crtp", "dap2", "dap3", "dap4", - "dtc", "dte", "dtf", "gpu", "sdio1", + "dtc", "dte", "gpu", "sdio1", "slxc", "slxd", "spdi", "spdo", "spig", "uda"; nvidia,pull = <TEGRA_PIN_PULL_NONE>;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 841/1017 ARM: mmp: Fix failure to remove sram device
In reply to Greg Kroah-HartmanFrom: Uwe Kleine-König <[email protected]>
[ Upstream commit 4036b29a146b2749af3bb213b003eb69f3e5ecc4 ]
Make sure in .probe() to set driver data before the function is left to make it possible in .remove() to undo the actions done.
This fixes a potential memory leak and stops returning an error code in .remove() that is ignored by the driver core anyhow.
--- arch/arm/mach-mmp/sram.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
arch/arm/mach-mmp/sram.c +12 -10
@@ -72,6 +72,8 @@ static int sram_probe(struct platform_device *pdev)if (!info)return -ENOMEM ; +platform_set_drvdata (pdev, info); + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );if (res ==NULL ) {dev_err (&pdev->dev,"no memory resource defined\n" );
@@ -107,8 +109,6 @@ static int sram_probe(struct platform_device *pdev)list_add (&info->node, &sram_bank_list);mutex_unlock (&sram_lock); -platform_set_drvdata (pdev, info); -dev_info (&pdev->dev,"initialized\n" );return 0 ;
@@ -127,17 +127,19 @@ static int sram_remove(struct platform_device *pdev)struct sram_bank_info *info; info =platform_get_drvdata (pdev); -if (info ==NULL ) -return -ENODEV ; -mutex_lock (&sram_lock); -list_del (&info->node); -mutex_unlock (&sram_lock); +if (info->sram_size) { +mutex_lock (&sram_lock); +list_del (&info->node); +mutex_unlock (&sram_lock); + +gen_pool_destroy (info->gpool); +iounmap (info->sram_virt); +kfree (info->pool_name); + } -gen_pool_destroy (info->gpool); -iounmap (info->sram_virt); -kfree (info->pool_name);kfree (info); +return 0 ; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 842/1017 ASoC: amd: vg: fix for pm resume callback sequence
In reply to Greg Kroah-HartmanFrom: Vijendar Mukunda <[email protected]>
[ Upstream commit 83b713619ee1b15e09eae11a92a7f3305534223d ]
The previous condition is used to cross check only the active stream status for I2S HS instance playback and capture use cases.
Modified logic to invoke sequence for two i2s controller instances.
This also fixes warnings reported by kernel robot:
"warning: variable 'frmt_val' set but not used" "warning: variable 'reg_val' set but not used"
--- sound/soc/amd/vangogh/acp5x-pcm-dma.c | 66 +++++++++++++-------------- 1 file changed, 33 insertions(+), 33 deletions(-)
sound/soc/amd/vangogh/acp5x-pcm-dma.c +33 -33
@@ -426,51 +426,51 @@ static int acp5x_audio_remove(struct platform_device *pdev)static int __maybe_unused acp5x_pcm_resume (struct device *dev) {struct i2s_dev_data *adata; -u32 val, reg_val, frmt_val; +struct i2s_stream_instance *rtd; +u32 val; - reg_val =0 ; - frmt_val =0 ; adata =dev_get_drvdata (dev);if (adata->play_stream && adata->play_stream->runtime) { -struct i2s_stream_instance *rtd = - adata->play_stream->runtime->private_data; + rtd = adata->play_stream->runtime->private_data;config_acp5x_dma (rtd,SNDRV_PCM_STREAM_PLAYBACK ); -switch (rtd->i2s_instance) { -case I2S_HS_INSTANCE : - reg_val =ACP_HSTDM_ITER ; - frmt_val =ACP_HSTDM_TXFRMT ; -break ; -case I2S_SP_INSTANCE : -default : - reg_val =ACP_I2STDM_ITER ; - frmt_val =ACP_I2STDM_TXFRMT ; +acp_writel ((rtd->xfer_resolution <<3 ), rtd->acp5x_base +ACP_HSTDM_ITER ); +if (adata->tdm_mode ==TDM_ENABLE ) { +acp_writel (adata->tdm_fmt, adata->acp5x_base +ACP_HSTDM_TXFRMT ); + val =acp_readl (adata->acp5x_base +ACP_HSTDM_ITER ); +acp_writel (val |0x2 , adata->acp5x_base +ACP_HSTDM_ITER ); + } + } +if (adata->i2ssp_play_stream && adata->i2ssp_play_stream->runtime) { + rtd = adata->i2ssp_play_stream->runtime->private_data; +config_acp5x_dma (rtd,SNDRV_PCM_STREAM_PLAYBACK ); +acp_writel ((rtd->xfer_resolution <<3 ), rtd->acp5x_base +ACP_I2STDM_ITER ); +if (adata->tdm_mode ==TDM_ENABLE ) { +acp_writel (adata->tdm_fmt, adata->acp5x_base +ACP_I2STDM_TXFRMT ); + val =acp_readl (adata->acp5x_base +ACP_I2STDM_ITER ); +acp_writel (val |0x2 , adata->acp5x_base +ACP_I2STDM_ITER ); } -acp_writel ((rtd->xfer_resolution <<3 ), - rtd->acp5x_base + reg_val); }if (adata->capture_stream && adata->capture_stream->runtime) { -struct i2s_stream_instance *rtd = - adata->capture_stream->runtime->private_data; + rtd = adata->capture_stream->runtime->private_data;config_acp5x_dma (rtd,SNDRV_PCM_STREAM_CAPTURE ); -switch (rtd->i2s_instance) { -case I2S_HS_INSTANCE : - reg_val =ACP_HSTDM_IRER ; - frmt_val =ACP_HSTDM_RXFRMT ; -break ; -case I2S_SP_INSTANCE : -default : - reg_val =ACP_I2STDM_IRER ; - frmt_val =ACP_I2STDM_RXFRMT ; +acp_writel ((rtd->xfer_resolution <<3 ), rtd->acp5x_base +ACP_HSTDM_IRER ); +if (adata->tdm_mode ==TDM_ENABLE ) { +acp_writel (adata->tdm_fmt, adata->acp5x_base +ACP_HSTDM_RXFRMT ); + val =acp_readl (adata->acp5x_base +ACP_HSTDM_IRER ); +acp_writel (val |0x2 , adata->acp5x_base +ACP_HSTDM_IRER ); } -acp_writel ((rtd->xfer_resolution <<3 ), - rtd->acp5x_base + reg_val); } -if (adata->tdm_mode ==TDM_ENABLE ) { -acp_writel (adata->tdm_fmt, adata->acp5x_base + frmt_val); - val =acp_readl (adata->acp5x_base + reg_val); -acp_writel (val |0x2 , adata->acp5x_base + reg_val); +if (adata->i2ssp_capture_stream && adata->i2ssp_capture_stream->runtime) { + rtd = adata->i2ssp_capture_stream->runtime->private_data; +config_acp5x_dma (rtd,SNDRV_PCM_STREAM_CAPTURE ); +acp_writel ((rtd->xfer_resolution <<3 ), rtd->acp5x_base +ACP_I2STDM_IRER ); +if (adata->tdm_mode ==TDM_ENABLE ) { +acp_writel (adata->tdm_fmt, adata->acp5x_base +ACP_I2STDM_RXFRMT ); + val =acp_readl (adata->acp5x_base +ACP_I2STDM_IRER ); +acp_writel (val |0x2 , adata->acp5x_base +ACP_I2STDM_IRER ); + } }acp_writel (1 , adata->acp5x_base +ACP_EXTERNAL_INTR_ENB );return 0 ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 843/1017 ASoC: amd: vangogh: fix uninitialized symbol warning in machine driver
In reply to Greg Kroah-HartmanFrom: Vijendar Mukunda <[email protected]>
[ Upstream commit 6f989800639a7a29ab9a02e165b04dc144dd4f2b ]
Fixed below smatch static checker warning. sound/soc/amd/vangogh/acp5x-mach.c:190 acp5x_cs35l41_hw_params()
error: uninitialized symbol 'ret'.
--- sound/soc/amd/vangogh/acp5x-mach.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/amd/vangogh/acp5x-mach.c +1 -0
@@ -165,6 +165,7 @@ static int acp5x_cs35l41_hw_params(struct snd_pcm_substream *substream,unsigned int num_codecs = rtd->num_codecs;unsigned int bclk_val; + ret =0 ;for (i =0 ; i < num_codecs; i++) { codec_dai =asoc_rtd_to_codec (rtd, i); if ((strcmp(codec_dai->name, "spi-VLV1776:00") == 0) ||
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 844/1017 video: fbdev: sm712fb: Fix crash in smtcfb_write()
In reply to Greg Kroah-HartmanFrom: Zheyu Ma <[email protected]>
[ Upstream commit 4f01d09b2bbfbcb47b3eb305560a7f4857a32260 ]
When the sm712fb driver writes three bytes to the framebuffer, the driver will crash:
BUG: unable to handle page fault for address: ffffc90001ffffff
RIP: 0010:smtcfb_write+0x454/0x5b0
Call Trace:
vfs_write+0x291/0xd60
? do_sys_openat2+0x27d/0x350
? __fget_light+0x54/0x340
ksys_write+0xce/0x190
do_syscall_64+0x43/0x90
entry_SYSCALL_64_after_hwframe+0x44/0xaeFix it by removing the open-coded endianness fixup-code.
--- drivers/video/fbdev/sm712fb.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-)
drivers/video/fbdev/sm712fb.c +4 -17
@@ -1119,7 +1119,7 @@ static ssize_t smtcfb_write(struct fb_in count = total_size - p; } - buffer =kmalloc ((count >PAGE_SIZE ) ?PAGE_SIZE : count,GFP_KERNEL ); + buffer =kmalloc (PAGE_SIZE ,GFP_KERNEL );if (!buffer)return -ENOMEM ;
@@ -1137,24 +1137,11 @@ static ssize_t smtcfb_write(struct fb_inbreak ; } -for (i = c >>2 ; i--;) { -fb_writel (big_swap (*src), dst++); +for (i = (c +3 ) >>2 ; i--;) { +fb_writel (big_swap (*src), dst); + dst++; src++; } -if (c &3 ) { -u8 *src8 = (u8 *)src; -u8 __iomem *dst8 = (u8 __iomem *)dst; - -for (i = c &3 ; i--;) { -if (i &1 ) { -fb_writeb (*src8++, ++dst8); - }else { -fb_writeb (*src8++, --dst8); - dst8 +=2 ; - } - } - dst = (u32 __iomem *)dst8; - } *ppos += c; buf += c;
Greg Kroah-Hartman
maintainerPATCH 845/1017 media: i2c: ov5648: Fix lockdep error
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
[ Upstream commit d4cb5d3c4cee28aa89b02bc33d930a6cf75e7f79 ]
ov5648_state_init() calls ov5648_state_mipi_configure() which uses __v4l2_ctrl_s_ctrl[_int64](). This means that sensor->mutex (which is also sensor->ctrls.handler.lock) must be locked before calling ov5648_state_init().
ov5648_state_mipi_configure() is also used in other places where the lock is already held so it cannot be changed itself.
Note this is based on an identical (tested) fix for the ov8865 driver, this has only been compile-tested.
--- drivers/media/i2c/ov5648.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/media/i2c/ov5648.c +8 -2
@@ -1778,8 +1778,14 @@ static int ov5648_state_configure(struct ov5648_sensor *sensor,static int ov5648_state_init (struct ov5648_sensor *sensor) { -return ov5648_state_configure (sensor, &ov5648_modes[0 ], - ov5648_mbus_codes[0 ]); +int ret; + +mutex_lock (&sensor->mutex); + ret =ov5648_state_configure (sensor, &ov5648_modes[0 ], + ov5648_mbus_codes[0 ]); +mutex_unlock (&sensor->mutex); + +return ret; }/* Sensor Base */
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 846/1017 media: Revert "media: em28xx: add missing em28xx_close_extension"
In reply to Greg Kroah-HartmanFrom: Pavel Skripkin <[email protected]>
[ Upstream commit fde18c3bac3f964d8333ae53b304d8fee430502b ]
This reverts commit 2c98b8a3458df03abdc6945bbef67ef91d181938.
Reverted patch causes problems with Hauppauge WinTV dualHD as Maximilian reported [1]. Since quick solution didn't come up let's just revert it to make this device work with upstream kernels.
--- drivers/media/usb/em28xx/em28xx-cards.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/media/usb/em28xx/em28xx-cards.c +1 -4
@@ -4150,11 +4150,8 @@ static void em28xx_usb_disconnect(struct usb_interface *intf)em28xx_close_extension (dev); -if (dev->dev_next) { -em28xx_close_extension (dev->dev_next); +if (dev->dev_next)em28xx_release_resources (dev->dev_next); - } -em28xx_release_resources (dev);if (dev->dev_next) {
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 847/1017 media: hdpvr: initialize dev->worker at hdpvr_register_videodev
In reply to Greg Kroah-HartmanFrom: Dongliang Mu <[email protected]>
[ Upstream commit 07922937e9a580825f9965c46fd15e23ba5754b6 ]
hdpvr_register_videodev is responsible to initialize a worker in hdpvr_device. However, the worker is only initialized at hdpvr_start_streaming other than hdpvr_register_videodev. When hdpvr_probe does not initialize its worker, the hdpvr_disconnect will encounter one WARN in flush_work.The stack trace is as follows:
hdpvr_disconnect+0xb8/0xf2 drivers/media/usb/hdpvr/hdpvr-core.c:425 usb_unbind_interface+0xbf/0x3a0 drivers/usb/core/driver.c:458 __device_release_driver drivers/base/dd.c:1206 [inline] device_release_driver_internal+0x22a/0x230 drivers/base/dd.c:1237 bus_remove_device+0x108/0x160 drivers/base/bus.c:529 device_del+0x1fe/0x510 drivers/base/core.c:3592 usb_disable_device+0xd1/0x1d0 drivers/usb/core/message.c:1419 usb_disconnect+0x109/0x330 drivers/usb/core/hub.c:2228
Fix this by moving the initialization of dev->worker to the starting of hdpvr_register_videodev
--- drivers/media/usb/hdpvr/hdpvr-video.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/usb/hdpvr/hdpvr-video.c +3 -1
@@ -308,7 +308,6 @@ static int hdpvr_start_streaming(struct hdpvr_device *dev) dev->status =STATUS_STREAMING ; -INIT_WORK (&dev->worker, hdpvr_transmit_buffers);schedule_work (&dev->worker); v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev,
@@ -1165,6 +1164,9 @@ int hdpvr_register_videodev(struct hdpvr_device *dev, struct device *parent,bool ac3 = dev->flags &HDPVR_FLAG_AC3_CAP ;int res; +// initialize dev->worker +INIT_WORK (&dev->worker, hdpvr_transmit_buffers); + dev->cur_std =V4L2_STD_525_60 ; dev->width =720 ; dev->height =480 ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 848/1017 ASoC: Intel: sof_sdw: fix quirks for 2022 HP Spectre x360 13"
In reply to Greg Kroah-HartmanFrom: Anthony I Gilea <[email protected]>
[ Upstream commit ce73ef6ec67104d1fcc4c5911d77ce83288a0998 ]
HP changed the DMI identification for 2022 devices:
Product Name: HP Spectre x360 Conv 13-ap0001na
Product Name: 8709
This patch relaxes the DMI_MATCH criterion to work with all versions of this product.
--- drivers/soundwire/dmi-quirks.c | 2 +- sound/soc/intel/boards/sof_sdw.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/soundwire/dmi-quirks.c +1 -1
@@ -59,7 +59,7 @@ static const struct dmi_system_id adr_remap_quirk_table[] = { { .matches = { DMI_MATCH(DMI_SYS_VENDOR, "HP"), - DMI_MATCH(DMI_PRODUCT_NAME, "HP Spectre x360 Convertible"), + DMI_MATCH(DMI_PRODUCT_NAME, "HP Spectre x360 Conv"), }, .driver_data = (void *)intel_tgl_bios, },
sound/soc/intel/boards/sof_sdw.c +1 -1
@@ -184,7 +184,7 @@ static const struct dmi_system_id sof_sdw_quirk_table[] = { .callback = sof_sdw_quirk_cb, .matches = {DMI_MATCH (DMI_SYS_VENDOR ,"HP" ), - DMI_MATCH(DMI_PRODUCT_NAME, "HP Spectre x360 Convertible"), + DMI_MATCH(DMI_PRODUCT_NAME, "HP Spectre x360 Conv"), }, .driver_data = (void *)(SOF_SDW_TGL_HDMI | SOF_SDW_PCH_DMIC |
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 849/1017 ASoC: Intel: soc-acpi: add more ACPI HIDs for ES83x6 devices
In reply to Greg Kroah-HartmanFrom: Pierre-Louis Bossart <[email protected]>
[ Upstream commit 1cedb6eabf0f2dd8285d3bb0ce1abd2369529084 ]
We only saw ESSX8336 so far, but now with reports of 'ESSX8326' we need to expand to a full list. Let's reuse the 'snd_soc_acpi_codecs' structure to store the information.
Note that ES8326 will need a dedicated codec driver, but the plan is to use the same machine driver for all Everest Audio devices.
--- sound/soc/intel/common/soc-acpi-intel-bxt-match.c | 7 ++++++- sound/soc/intel/common/soc-acpi-intel-cml-match.c | 7 ++++++- sound/soc/intel/common/soc-acpi-intel-glk-match.c | 7 ++++++- sound/soc/intel/common/soc-acpi-intel-jsl-match.c | 7 ++++++- sound/soc/intel/common/soc-acpi-intel-tgl-match.c | 7 ++++++- 5 files changed, 30 insertions(+), 5 deletions(-)
sound/soc/intel/common/soc-acpi-intel-bxt-match.c +6 -1
@@ -41,6 +41,11 @@ static struct snd_soc_acpi_mach *apl_quirk(void *arg)return mach; } +static const struct snd_soc_acpi_codecs essx_83x6 = { + .num_codecs =3 , + .codecs = {"ESSX8316" ,"ESSX8326" ,"ESSX8336" }, +}; +static const struct snd_soc_acpi_codecs bxt_codecs = { .num_codecs =1 , .codecs = {"MX98357A" }
@@ -83,7 +88,7 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_bxt_machines[] = { .sof_tplg_filename = "sof-apl-tdf8532.tplg", }, { - .id = "ESSX8336", + .comp_ids = &essx_83x6, .drv_name = "sof-essx8336", .sof_fw_filename = "sof-apl.ri", .sof_tplg_filename = "sof-apl-es8336.tplg",
sound/soc/intel/common/soc-acpi-intel-cml-match.c +6 -1
@@ -9,6 +9,11 @@#include <sound/soc-acpi.h> #include <sound/soc-acpi-intel-match.h> +static const struct snd_soc_acpi_codecs essx_83x6 = { + .num_codecs =3 , + .codecs = {"ESSX8316" ,"ESSX8326" ,"ESSX8336" }, +}; +static const struct snd_soc_acpi_codecs rt1011_spk_codecs = { .num_codecs =1 , .codecs = {"10EC1011" }
@@ -82,7 +87,7 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_cml_machines[] = { .sof_tplg_filename = "sof-cml-da7219-max98390.tplg", }, { - .id = "ESSX8336", + .comp_ids = &essx_83x6, .drv_name = "sof-essx8336", .sof_fw_filename = "sof-cml.ri", .sof_tplg_filename = "sof-cml-es8336.tplg",
sound/soc/intel/common/soc-acpi-intel-glk-match.c +6 -1
@@ -9,6 +9,11 @@#include <sound/soc-acpi.h> #include <sound/soc-acpi-intel-match.h> +static const struct snd_soc_acpi_codecs essx_83x6 = { + .num_codecs =3 , + .codecs = {"ESSX8316" ,"ESSX8326" ,"ESSX8336" }, +}; +static const struct snd_soc_acpi_codecs glk_codecs = { .num_codecs =1 , .codecs = {"MX98357A" }
@@ -58,7 +63,7 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_glk_machines[] = { .sof_tplg_filename = "sof-glk-cs42l42.tplg", }, { - .id = "ESSX8336", + .comp_ids = &essx_83x6, .drv_name = "sof-essx8336", .sof_fw_filename = "sof-glk.ri", .sof_tplg_filename = "sof-glk-es8336.tplg",
sound/soc/intel/common/soc-acpi-intel-jsl-match.c +6 -1
@@ -9,6 +9,11 @@#include <sound/soc-acpi.h> #include <sound/soc-acpi-intel-match.h> +static const struct snd_soc_acpi_codecs essx_83x6 = { + .num_codecs =3 , + .codecs = {"ESSX8316" ,"ESSX8326" ,"ESSX8336" }, +}; +static const struct snd_soc_acpi_codecs jsl_7219_98373_codecs = { .num_codecs =1 , .codecs = {"MX98373" }
@@ -87,7 +92,7 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_jsl_machines[] = { .sof_tplg_filename = "sof-jsl-cs42l42-mx98360a.tplg", }, { - .id = "ESSX8336", + .comp_ids = &essx_83x6, .drv_name = "sof-essx8336", .sof_fw_filename = "sof-jsl.ri", .sof_tplg_filename = "sof-jsl-es8336.tplg",
sound/soc/intel/common/soc-acpi-intel-tgl-match.c +6 -1
@@ -10,6 +10,11 @@#include <sound/soc-acpi-intel-match.h> #include "soc-acpi-intel-sdw-mockup-match.h" +static const struct snd_soc_acpi_codecs essx_83x6 = { + .num_codecs =3 , + .codecs = {"ESSX8316" ,"ESSX8326" ,"ESSX8336" }, +}; +static const struct snd_soc_acpi_codecs tgl_codecs = { .num_codecs =1 , .codecs = {"MX98357A" }
@@ -389,7 +394,7 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_tgl_machines[] = { .sof_tplg_filename = "sof-tgl-rt1011-rt5682.tplg", }, { - .id = "ESSX8336", + .comp_ids = &essx_83x6, .drv_name = "sof-essx8336", .sof_fw_filename = "sof-tgl.ri", .sof_tplg_filename = "sof-tgl-es8336.tplg",
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 850/1017 ASoC: Intel: Revert "ASoC: Intel: sof_es8336: add quirk for Huawei D15 2021"
In reply to Greg Kroah-HartmanFrom: Pierre-Louis Bossart <[email protected]>
[ Upstream commit 1b5283483a782f6560999d8d5965b1874d104812 ]
This reverts commit ce6a70bfce21bb4edb7c0f29ecfb0522fa34ab71.
The next patch will add run-time detection of the required SSP and this hard-coded quirk is not needed.
--- sound/soc/intel/boards/sof_es8336.c | 8 -------- 1 file changed, 8 deletions(-)
sound/soc/intel/boards/sof_es8336.c +0 -8
@@ -247,14 +247,6 @@ static const struct dmi_system_id sof_es8336_quirk_table[] = { SOF_ES8336_TGL_GPIO_QUIRK | SOF_ES8336_ENABLE_DMIC) }, - { - .callback = sof_es8336_quirk_cb, - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "HUAWEI"), - DMI_MATCH(DMI_BOARD_NAME, "BOHB-WAX9-PCB-B2"), - }, - .driver_data = (void *)SOF_ES8336_SSP_CODEC(0) - }, {} };
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 851/1017 ASoC: Intel: sof_es8336: use NHLT information to set dmic and SSP
In reply to Greg Kroah-HartmanFrom: Pierre-Louis Bossart <[email protected]>
[ Upstream commit 651c304df7f6e3fbb4779527efa3eb128ef91329 ]
Since we see a proliferation of devices with various configurations, we want to automatically set the DMIC and SSP information. This patch relies on the information extracted from NHLT and partially reverts existing DMI quirks added by commit a164137ce91a ("ASoC: Intel: add machine driver for SOF+ES8336")
Note that NHLT can report multiple SSPs, choosing from the ssp_link_mask in an MSB-first manner was found experimentally to work fine.
The only thing that cannot be detected is the GPIO type, and users may want to use the quirk override parameter if the 'wrong' solution is provided.
--- sound/soc/intel/boards/sof_es8336.c | 56 +++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 15 deletions(-)
sound/soc/intel/boards/sof_es8336.c +41 -15
@@ -228,24 +228,25 @@ static int sof_es8336_quirk_cb(const struct dmi_system_id *id)return 1 ; } +/* +* this table should only be used to add GPIO or jack-detection quirks +* that cannot be detected from ACPI tables. The SSP and DMIC +* information are providing by the platform driver and are aligned +* with the topology used. +* +* If the GPIO support is missing, the quirk parameter can be used to +* enable speakers. In that case it's recommended to keep the SSP and DMIC +* information consistent, overriding the SSP and DMIC can only be done +* if the topology file is modified as well. +*/ static const struct dmi_system_id sof_es8336_quirk_table[] = { - { - .callback = sof_es8336_quirk_cb, - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"CHUWI Innovation And Technology" ), -DMI_MATCH (DMI_BOARD_NAME ,"Hi10 X" ), - }, - .driver_data = (void *)SOF_ES8336_SSP_CODEC (2 ) - }, { .callback = sof_es8336_quirk_cb, .matches = {DMI_MATCH (DMI_SYS_VENDOR ,"IP3 tech" ),DMI_MATCH (DMI_BOARD_NAME ,"WN1" ), }, - .driver_data = (void *)(SOF_ES8336_SSP_CODEC (0 ) | -SOF_ES8336_TGL_GPIO_QUIRK | -SOF_ES8336_ENABLE_DMIC ) + .driver_data = (void *)(SOF_ES8336_TGL_GPIO_QUIRK ) }, {} };
@@ -470,11 +471,33 @@ static int sof_es8336_probe(struct platform_device *pdev) card = &sof_es8336_card; card->dev = dev; -if (!dmi_check_system (sof_es8336_quirk_table)) - quirk =SOF_ES8336_SSP_CODEC (2 ); +/* check GPIO DMI quirks */ +dmi_check_system (sof_es8336_quirk_table); -if (quirk &SOF_ES8336_ENABLE_DMIC ) - dmic_be_num =2 ; +if (!mach->mach_params.i2s_link_mask) { +dev_warn (dev,"No I2S link information provided, using SSP0. This may need to be modified with the quirk module parameter\n" ); + }else { +/* +* Set configuration based on platform NHLT. +* In this machine driver, we can only support one SSP for the +* ES8336 link, the else-if below are intentional. +* In some cases multiple SSPs can be reported by NHLT, starting MSB-first +* seems to pick the right connection. +*/ +unsigned long ssp =0 ; + +if (mach->mach_params.i2s_link_mask &BIT (2 )) + ssp =SOF_ES8336_SSP_CODEC (2 ); +else if (mach->mach_params.i2s_link_mask &BIT (1 )) + ssp =SOF_ES8336_SSP_CODEC (1 ); +else if (mach->mach_params.i2s_link_mask &BIT (0 )) + ssp =SOF_ES8336_SSP_CODEC (0 ); + + quirk |= ssp; + } + +if (mach->mach_params.dmic_num) + quirk |=SOF_ES8336_ENABLE_DMIC ;if (quirk_override !=-1 ) { dev_info(dev, "Overriding quirk 0x%lx => 0x%x\n",
@@ -483,6 +506,9 @@ static int sof_es8336_probe(struct platform_device *pdev) }log_quirks (dev); +if (quirk &SOF_ES8336_ENABLE_DMIC ) + dmic_be_num =2 ; + sof_es8336_card.num_links += dmic_be_num + hdmi_num; dai_links = sof_card_dai_links_create(dev, SOF_ES8336_SSP_CODEC(quirk),
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 852/1017 ASoC: Intel: sof_es8336: log all quirks
In reply to Greg Kroah-HartmanFrom: Pierre-Louis Bossart <[email protected]>
[ Upstream commit 9c818d849192491a8799b1cb14ca0f7aead4fb09 ]
We only logged the SSP quirk, make sure the GPIO and DMIC quirks are exposed.
--- sound/soc/intel/boards/sof_es8336.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
sound/soc/intel/boards/sof_es8336.c +6 -1
@@ -63,7 +63,12 @@ static const struct acpi_gpio_mapping *gpio_mapping = acpi_es8336_gpios;static void log_quirks (struct device *dev) { -dev_info (dev,"quirk SSP%ld" ,SOF_ES8336_SSP_CODEC (quirk)); +dev_info (dev,"quirk mask %#lx\n" , quirk); +dev_info (dev,"quirk SSP%ld\n" ,SOF_ES8336_SSP_CODEC (quirk)); +if (quirk &SOF_ES8336_ENABLE_DMIC ) +dev_info (dev,"quirk DMIC enabled\n" ); +if (quirk &SOF_ES8336_TGL_GPIO_QUIRK ) +dev_info (dev,"quirk TGL GPIO enabled\n" ); } static int sof_es8316_speaker_power_event(struct snd_soc_dapm_widget *w,
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 853/1017 tracing: Have TRACE_DEFINE_ENUM affect trace event types as well
In reply to Greg Kroah-HartmanFrom: Steven Rostedt (Google) <[email protected]>
[ Upstream commit b3bc8547d3be60898818885f5bf22d0a62e2eb48 ]
The macro TRACE_DEFINE_ENUM is used to convert enums in the kernel to their actual value when they are exported to user space via the trace event format file.
Currently only the enums in the "print fmt" (TP_printk in the TRACE_EVENT macro) have the enums converted. But the enums can be used to denote array size:
field:unsigned int fc_ineligible_rc[EXT4_FC_REASON_MAX]; offset:12; size:36; signed:0;
The EXT4_FC_REASON_MAX has no meaning to userspace but it needs to know that information to know how to parse the array.
Have the array indexes also be parsed as well.
--- kernel/trace/trace_events.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
kernel/trace/trace_events.c +28 -0
@@ -2637,6 +2637,33 @@ static void update_event_printk(struct trace_event_call *call, } } +static void update_event_fields (struct trace_event_call *call, +struct trace_eval_map *map) +{ +struct ftrace_event_field *field; +struct list_head *head; +char *ptr; +int len =strlen (map->eval_string); + + head =trace_get_fields (call); +list_for_each_entry (field, head, link) { + ptr =strchr (field->type,'[' ); +if (!ptr) +continue ; + ptr++; + +if (!isalpha (*ptr) && *ptr !='_' ) +continue ; + +if (strncmp (map->eval_string, ptr, len) !=0 ) +continue ; + + ptr =eval_replace (ptr, map, len); +/* enum/sizeof string smaller than value */ +WARN_ON_ONCE (!ptr); + } +} +void trace_event_eval_update (struct trace_eval_map **map,int len) {struct trace_event_call *call, *p;
@@ -2672,6 +2699,7 @@ void trace_event_eval_update(struct trace_eval_map **map, int len) first = false; }update_event_printk (call, map[i]); +update_event_fields (call, map[i]); } } }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 854/1017 mmc: host: Return an error when ->enable_sdio_irq() ops is missing
In reply to Greg Kroah-HartmanFrom: Ulf Hansson <[email protected]>
[ Upstream commit d6c9219ca1139b74541b2a98cee47a3426d754a9 ]
Even if the current WARN() notifies the user that something is severely wrong, we can still end up in a PANIC() when trying to invoke the missing ->enable_sdio_irq() ops. Therefore, let's also return an error code and prevent the host from being added.
While at it, move the code into a separate function to prepare for subsequent changes and for further host caps validations.
--- drivers/mmc/core/host.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/mmc/core/host.c +13 -2
@@ -588,6 +588,16 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)EXPORT_SYMBOL (mmc_alloc_host); +static int mmc_validate_host_caps (struct mmc_host *host) +{ +if (host->caps &MMC_CAP_SDIO_IRQ && !host->ops->enable_sdio_irq) { +dev_warn (host->parent,"missing ->enable_sdio_irq() ops\n" ); +return -EINVAL ; + } + +return 0 ; +} +/** * mmc_add_host - initialise host hardware * @host: mmc host
@@ -600,8 +610,9 @@ int mmc_add_host(struct mmc_host *host) {int err; -WARN_ON ((host->caps &MMC_CAP_SDIO_IRQ ) && - !host->ops->enable_sdio_irq); + err =mmc_validate_host_caps (host); +if (err) +return err; err =device_add (&host->class_dev);if (err)
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 855/1017 media: atomisp: fix bad usage at error handling logic
In reply to Greg Kroah-HartmanFrom: Mauro Carvalho Chehab <[email protected]>
[ Upstream commit fc0b582c858ed73f94c8f3375c203ea46f1f7402 ]
As warned by sparse:
atomisp: drivers/staging/media/atomisp/pci/atomisp_acc.c:508 atomisp_acc_load_extensions() warn: iterator used outside loop: 'acc_fw'
The acc_fw interactor is used outside the loop, at the error handling logic. On most cases, this is actually safe there, but, if atomisp_css_set_acc_parameters() has an error, an attempt to use it will pick an invalid value for acc_fw.
--- .../staging/media/atomisp/pci/atomisp_acc.c | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_acc.c +19 -9
@@ -439,6 +439,18 @@ int atomisp_acc_s_mapped_arg(struct atomisp_sub_device *asd,return 0 ; } +static void atomisp_acc_unload_some_extensions (struct atomisp_sub_device *asd, +int i, +struct atomisp_acc_fw *acc_fw) +{ +while (--i >=0 ) { +if (acc_fw->flags & acc_flag_to_pipe[i].flag) { +atomisp_css_unload_acc_extension (asd, acc_fw->fw, + acc_flag_to_pipe[i].pipe_id); + } + } +} +/* * Appends the loaded acceleration binary extensions to the * current ISP mode. Must be called just before sh_css_start().
@@ -479,16 +491,20 @@ int atomisp_acc_load_extensions(struct atomisp_sub_device *asd) acc_fw->fw, acc_flag_to_pipe[i].pipe_id, acc_fw->type); -if (ret) +if (ret) { +atomisp_acc_unload_some_extensions (asd, i, acc_fw); goto error; + } ext_loaded = true; } } ret =atomisp_css_set_acc_parameters (acc_fw); -if (ret <0 ) +if (ret <0 ) { +atomisp_acc_unload_some_extensions (asd, i, acc_fw); goto error; + } }if (!ext_loaded)
@@ -497,6 +513,7 @@ int atomisp_acc_load_extensions(struct atomisp_sub_device *asd) ret =atomisp_css_update_stream (asd);if (ret) {dev_err (isp->dev,"%s: update stream failed.\n" , __func__); +atomisp_acc_unload_extensions (asd); goto error; }
@@ -504,13 +521,6 @@ int atomisp_acc_load_extensions(struct atomisp_sub_device *asd)return 0 ; error: -while (--i >=0 ) { -if (acc_fw->flags & acc_flag_to_pipe[i].flag) { -atomisp_css_unload_acc_extension (asd, acc_fw->fw, - acc_flag_to_pipe[i].pipe_id); - } - } -list_for_each_entry_continue_reverse (acc_fw, &asd->acc.fw, list) {if (acc_fw->type !=ATOMISP_ACC_FW_LOAD_TYPE_OUTPUT && acc_fw->type !=ATOMISP_ACC_FW_LOAD_TYPE_VIEWFINDER )
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 856/1017 ALSA: hda/realtek: Add alc256-samsung-headphone fixup
In reply to Greg Kroah-HartmanFrom: Matt Kramer <[email protected]>
[ Upstream commit ef248d9bd616b04df8be25539a4dc5db4b6c56f4 ]
This fixes the near-silence of the headphone jack on the ALC256-based Samsung Galaxy Book Flex Alpha (NP730QCJ). The magic verbs were found through trial and error, using known ALC298 hacks as inspiration. The fixup is auto-enabled only when the NP730QCJ is detected. It can be manually enabled using model=alc256-samsung-headphone.
--- Documentation/sound/hd-audio/models.rst | 4 ++++ sound/pci/hda/patch_realtek.c | 11 +++++++++++ 2 files changed, 15 insertions(+)
Documentation/sound/hd-audio/models.rst +4 -0
@@ -261,6 +261,10 @@ alc-sense-combo huawei-mbx-stereo Enable initialization verbs for Huawei MBX stereo speakers; might be risky, try this at your own risk +alc298-samsung-headphone + Samsung laptops with ALC298 +alc256-samsung-headphone + Samsung laptops with ALC256 ALC66x/67x/892 ==============
sound/pci/hda/patch_realtek.c +11 -0
@@ -6816,6 +6816,7 @@ enum {ALC236_FIXUP_HP_MUTE_LED ,ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF ,ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET , +ALC256_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET ,ALC295_FIXUP_ASUS_MIC_NO_PRESENCE ,ALC269VC_FIXUP_ACER_VCOPPERBOX_PINS , ALC269VC_FIXUP_ACER_HEADSET_MIC,
@@ -8138,6 +8139,14 @@ static const struct hda_fixup alc269_fixups[] = { { } }, }, + [ALC256_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET] = { + .type = HDA_FIXUP_VERBS, + .v.verbs = (const struct hda_verb[]) { + { 0x20, AC_VERB_SET_COEF_INDEX, 0x08}, + { 0x20, AC_VERB_SET_PROC_COEF, 0x2fcf}, + { } + }, + }, [ALC295_FIXUP_ASUS_MIC_NO_PRESENCE] = { .type = HDA_FIXUP_PINS, .v.pins = (const struct hda_pintbl[]) {
@@ -8900,6 +8909,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x144d ,0xc740 ,"Samsung Ativ book 8 (NP870Z5G)" ,ALC269_FIXUP_ATIV_BOOK_8 ),SND_PCI_QUIRK (0x144d ,0xc812 ,"Samsung Notebook Pen S (NT950SBE-X58)" ,ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET ),SND_PCI_QUIRK (0x144d ,0xc830 ,"Samsung Galaxy Book Ion (NT950XCJ-X716A)" ,ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET ), +SND_PCI_QUIRK (0x144d ,0xc832 ,"Samsung Galaxy Book Flex Alpha (NP730QCJ)" ,ALC256_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET ),SND_PCI_QUIRK (0x1458 ,0xfa53 ,"Gigabyte BXBT-2807" ,ALC283_FIXUP_HEADSET_MIC ),SND_PCI_QUIRK (0x1462 ,0xb120 ,"MSI Cubi MS-B120" ,ALC283_FIXUP_HEADSET_MIC ), SND_PCI_QUIRK(0x1462, 0xb171, "Cubi N 8GL (MS-B171)", ALC283_FIXUP_HEADSET_MIC),
@@ -9242,6 +9252,7 @@ static const struct hda_model_fixup alc269_fixup_models[] = { {.id = ALC298_FIXUP_HUAWEI_MBX_STEREO, .name = "huawei-mbx-stereo"}, {.id = ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE, .name = "alc256-medion-headset"}, {.id = ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET, .name = "alc298-samsung-headphone"}, + {.id = ALC256_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET, .name = "alc256-samsung-headphone"}, {.id = ALC255_FIXUP_XIAOMI_HEADSET_MIC, .name = "alc255-xiaomi-headset"}, {.id = ALC274_FIXUP_HP_MIC, .name = "alc274-hp-mic-detect"}, {.id = ALC245_FIXUP_HP_X360_AMP, .name = "alc245-hp-x360-amp"},
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 857/1017 KVM: x86: Reinitialize context if host userspace toggles EFER.LME
In reply to Greg Kroah-HartmanFrom: Paolo Bonzini <[email protected]>
commit d6174299365ddbbf491620c0b8c5ca1a6ef2eea5 upstream.
While the guest runs, EFER.LME cannot change unless CR0.PG is clear, and therefore EFER.NX is the only bit that can affect the MMU role. However, set_efer accepts a host-initiated change to EFER.LME even with CR0.PG=1. In that case, the MMU has to be reset.
--- arch/x86/kvm/mmu.h | 1 + arch/x86/kvm/x86.c | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/kvm/mmu.h +1 -0
@@ -48,6 +48,7 @@ X86_CR4_SMEP | X86_CR4_SMAP | X86_CR4_PKE)#define KVM_MMU_CR0_ROLE_BITS (X86_CR0_PG | X86_CR0_WP) +#define KVM_MMU_EFER_ROLE_BITS (EFER_LME | EFER_NX) static __always_inline u64 rsvd_bits(int s, int e) {
arch/x86/kvm/x86.c +1 -2
@@ -1614,8 +1614,7 @@ static int set_efer(struct kvm_vcpu *vcpreturn r; } -/* Update reserved bits */ -if ((efer ^ old_efer) &EFER_NX ) +if ((efer ^ old_efer) &KVM_MMU_EFER_ROLE_BITS )kvm_mmu_reset_context (vcpu);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 858/1017 KVM: x86/mmu: Use common TDP MMU zap helper for MMU notifier unmap hook
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit 83b83a02073ec8d18c77a9bbe0881d710f7a9d32 upstream.
Use the common TDP MMU zap helper when handling an MMU notifier unmap event, the two flows are semantically identical. Consolidate the code in preparation for a future bug fix, as both kvm_tdp_mmu_unmap_gfn_range() and __kvm_tdp_mmu_zap_gfn_range() are guilty of not zapping SPTEs in invalid roots.
No functional change intended.
Message-Id: <[email protected]>
--- arch/x86/kvm/mmu/tdp_mmu.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
arch/x86/kvm/mmu/tdp_mmu.c +2 -7
@@ -1032,13 +1032,8 @@ int kvm_tdp_mmu_map(struct kvm_vcpu *vcpbool kvm_tdp_mmu_unmap_gfn_range (struct kvm *kvm,struct kvm_gfn_range *range,bool flush) { -struct kvm_mmu_page *root; - -for_each_tdp_mmu_root_yield_safe (kvm, root, range->slot->as_id, false) - flush =zap_gfn_range (kvm, root, range->start, range->end, - range->may_block, flush, false); - -return flush; +return __kvm_tdp_mmu_zap_gfn_range (kvm, range->slot->as_id, range->start, + range->end, range->may_block, flush); } typedef bool (*tdp_handler_t)(struct kvm *kvm, struct tdp_iter *iter,
Greg Kroah-Hartman
maintainerPATCH 859/1017 KVM: x86/mmu: Move "invalid" check out of kvm_tdp_mmu_get_root()
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit 04dc4e6ce274fa729feda32aa957b27388a3870c upstream.
Move the check for an invalid root out of kvm_tdp_mmu_get_root() and into the one place it actually matters, tdp_mmu_next_root(), as the other user already has an implicit validity check. A future bug fix will need to get references to invalid roots to honor mmu_notifier requests; there's no point in forcing what will be a common path to open code getting a reference to a root.
No functional change intended.
Message-Id: <[email protected]>
--- arch/x86/kvm/mmu/tdp_mmu.c | 12 ++++++++++-- arch/x86/kvm/mmu/tdp_mmu.h | 3 --- 2 files changed, 10 insertions(+), 5 deletions(-)
arch/x86/kvm/mmu/tdp_mmu.c +10 -2
@@ -121,9 +121,14 @@ static struct kvm_mmu_page *tdp_mmu_next next_root =list_first_or_null_rcu (&kvm->arch.tdp_mmu_roots,typeof (*next_root), link); -while (next_root && !kvm_tdp_mmu_get_root (kvm, next_root)) +while (next_root) { +if (!next_root->role.invalid && +kvm_tdp_mmu_get_root (kvm, next_root)) +break ; + next_root =list_next_or_null_rcu (&kvm->arch.tdp_mmu_roots, &next_root->link,typeof (*next_root), link); + }rcu_read_unlock ();
@@ -200,7 +205,10 @@ hpa_t kvm_tdp_mmu_get_vcpu_root_hpa(stru role =page_role_for_level (vcpu, vcpu->arch.mmu->shadow_root_level); -/* Check for an existing root before allocating a new one. */ +/* +* Check for an existing root before allocating a new one. Note, the +* role check prevents consuming an invalid root. +*/ for_each_tdp_mmu_root (kvm, root,kvm_mmu_role_as_id (role)) {if (root->role.word == role.word &&kvm_tdp_mmu_get_root (kvm, root))
arch/x86/kvm/mmu/tdp_mmu.h +0 -3
@@ -10,9 +10,6 @@ hpa_t kvm_tdp_mmu_get_vcpu_root_hpa(stru__must_check static inline bool kvm_tdp_mmu_get_root (struct kvm *kvm,struct kvm_mmu_page *root) { -if (root->role.invalid) -return false; -return refcount_inc_not_zero (&root->tdp_mmu_root_count); }
Greg Kroah-Hartman
maintainerPATCH 860/1017 KVM: x86/mmu: Zap _all_ roots when unmapping gfn range in TDP MMU
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit d62007edf01f5c11f75d0f4b1e538fc52a5b1982 upstream.
Zap both valid and invalid roots when zapping/unmapping a gfn range, as KVM must ensure it holds no references to the freed page after returning from the unmap operation. Most notably, the TDP MMU doesn't zap invalid roots in mmu_notifier callbacks. This leads to use-after-free and other issues if the mmu_notifier runs to completion while an invalid root zapper yields as KVM fails to honor the requirement that there must be _no_ references to the page after the mmu_notifier returns.
The bug is most easily reproduced by hacking KVM to cause a collision between set_nx_huge_pages() and kvm_mmu_notifier_release(), but the bug exists between kvm_mmu_notifier_invalidate_range_start() and memslot updates as well. Invalidating a root ensures pages aren't accessible by the guest, and KVM won't read or write page data itself, but KVM will trigger e.g. kvm_set_pfn_dirty() when zapping SPTEs, and thus completing a zap of an invalid root _after_ the mmu_notifier returns is fatal.
WARNING: CPU: 24 PID: 1496 at arch/x86/kvm/../../../virt/kvm/kvm_main.c:173 [kvm] RIP: 0010:kvm_is_zone_device_pfn+0x96/0xa0 [kvm] Call Trace: <TASK> kvm_set_pfn_dirty+0xa8/0xe0 [kvm] __handle_changed_spte+0x2ab/0x5e0 [kvm] __handle_changed_spte+0x2ab/0x5e0 [kvm] __handle_changed_spte+0x2ab/0x5e0 [kvm] zap_gfn_range+0x1f3/0x310 [kvm] kvm_tdp_mmu_zap_invalidated_roots+0x50/0x90 [kvm] kvm_mmu_zap_all_fast+0x177/0x1a0 [kvm] set_nx_huge_pages+0xb4/0x190 [kvm] param_attr_store+0x70/0x100 module_attr_store+0x19/0x30 kernfs_fop_write_iter+0x119/0x1b0 new_sync_write+0x11c/0x1b0 vfs_write+0x1cc/0x270 ksys_write+0x5f/0xe0 do_syscall_64+0x38/0xc0 entry_SYSCALL_64_after_hwframe+0x44/0xae </TASK>
Message-Id: <[email protected]>
--- arch/x86/kvm/mmu/tdp_mmu.c | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-)
arch/x86/kvm/mmu/tdp_mmu.c +24 -15
@@ -99,15 +99,18 @@ void kvm_tdp_mmu_put_root(struct kvm *kv }/* -* Finds the next valid root after root (or the first valid root if root -* is NULL), takes a reference on it, and returns that next root. If root -* is not NULL, this thread should have already taken a reference on it, and -* that reference will be dropped. If no valid root is found, this -* function will return NULL. +* Returns the next root after @prev_root (or the first root if @prev_root is +* NULL). A reference to the returned root is acquired, and the reference to +* @prev_root is released (the caller obviously must hold a reference to +* @prev_root if it's non-NULL). +* +* If @only_valid is true, invalid roots are skipped. +* +* Returns NULL if the end of tdp_mmu_roots was reached. */ static struct kvm_mmu_page *tdp_mmu_next_root (struct kvm *kvm,struct kvm_mmu_page *prev_root, -bool shared) +bool shared,bool only_valid) {struct kvm_mmu_page *next_root;
@@ -122,7 +125,7 @@ static struct kvm_mmu_page *tdp_mmu_next typeof(*next_root), link);while (next_root) { -if (!next_root->role.invalid && +if ((!only_valid || !next_root->role.invalid) &&kvm_tdp_mmu_get_root (kvm, next_root))break ;
@@ -148,13 +151,19 @@ static struct kvm_mmu_page *tdp_mmu_next* mode. In the unlikely event that this thread must free a root, the lock * will be temporarily dropped and reacquired in write mode. */ -#define for_each_tdp_mmu_root_yield_safe (_kvm, _root, _as_id, _shared) \ - for (_root = tdp_mmu_next_root(_kvm, NULL, _shared); \ - _root; \ - _root = tdp_mmu_next_root(_kvm, _root, _shared)) \ - if (kvm_mmu_page_as_id(_root) != _as_id) { \ +#define __for_each_tdp_mmu_root_yield_safe (_kvm, _root, _as_id, _shared, _only_valid)\ + for (_root = tdp_mmu_next_root(_kvm, NULL, _shared, _only_valid); \ + _root; \ + _root = tdp_mmu_next_root(_kvm, _root, _shared, _only_valid)) \ + if (kvm_mmu_page_as_id(_root) != _as_id) { \ } else +#define for_each_valid_tdp_mmu_root_yield_safe (_kvm, _root, _as_id, _shared) \ + __for_each_tdp_mmu_root_yield_safe(_kvm, _root, _as_id, _shared, true) + +#define for_each_tdp_mmu_root_yield_safe (_kvm, _root, _as_id, _shared) \ + __for_each_tdp_mmu_root_yield_safe(_kvm, _root, _as_id, _shared, false) +#define for_each_tdp_mmu_root (_kvm, _root, _as_id) \ list_for_each_entry_rcu(_root, &_kvm->arch.tdp_mmu_roots, link, \ lockdep_is_held_type(&kvm->mmu_lock, 0) || \
@@ -1224,7 +1233,7 @@ bool kvm_tdp_mmu_wrprot_slot(struct kvmlockdep_assert_held_read (&kvm->mmu_lock); -for_each_tdp_mmu_root_yield_safe (kvm, root, slot->as_id, true) +for_each_valid_tdp_mmu_root_yield_safe (kvm, root, slot->as_id, true) spte_set |=wrprot_gfn_range (kvm, root, slot->base_gfn, slot->base_gfn + slot->npages, min_level);
@@ -1294,7 +1303,7 @@ bool kvm_tdp_mmu_clear_dirty_slot(structlockdep_assert_held_read (&kvm->mmu_lock); -for_each_tdp_mmu_root_yield_safe (kvm, root, slot->as_id, true) +for_each_valid_tdp_mmu_root_yield_safe (kvm, root, slot->as_id, true) spte_set |=clear_dirty_gfn_range (kvm, root, slot->base_gfn, slot->base_gfn + slot->npages);
@@ -1419,7 +1428,7 @@ void kvm_tdp_mmu_zap_collapsible_sptes(slockdep_assert_held_read (&kvm->mmu_lock); -for_each_tdp_mmu_root_yield_safe (kvm, root, slot->as_id, true) +for_each_valid_tdp_mmu_root_yield_safe (kvm, root, slot->as_id, true)zap_collapsible_spte_range (kvm, root, slot); }
Greg Kroah-Hartman
maintainerPATCH 861/1017 KVM: x86/mmu: Check for present SPTE when clearing dirty bit in TDP MMU
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit 3354ef5a592d219364cf442c2f784ce7ad7629fd upstream.
Explicitly check for present SPTEs when clearing dirty bits in the TDP MMU. This isn't strictly required for correctness, as setting the dirty bit in a defunct SPTE will not change the SPTE from !PRESENT to PRESENT. However, the guarded MMU_WARN_ON() in spte_ad_need_write_protect() would complain if anyone actually turned on KVM's MMU debugging.
Message-Id: <[email protected]>
--- arch/x86/kvm/mmu/tdp_mmu.c | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/kvm/mmu/tdp_mmu.c +3 -0
@@ -1261,6 +1261,9 @@ retry:if (tdp_mmu_iter_cond_resched (kvm, &iter, false, true))continue ; +if (!is_shadow_present_pte (iter.old_spte)) +continue ; +if (spte_ad_need_write_protect (iter.old_spte)) {if (is_writable_pte (iter.old_spte)) new_spte = iter.old_spte & ~PT_WRITABLE_MASK ;
Greg Kroah-Hartman
maintainerPATCH 862/1017 KVM: x86: hyper-v: Drop redundant ex parameter from kvm_hv_send_ipi()
In reply to Greg Kroah-HartmanFrom: Vitaly Kuznetsov <[email protected]>
commit 50e523dd79f6a856d793ce5711719abe27cffbf2 upstream.
'struct kvm_hv_hcall' has all the required information already, there's no need to pass 'ex' additionally.
No functional change intended.
Message-Id: <[email protected]>
--- arch/x86/kvm/hyperv.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/x86/kvm/hyperv.c +4 -4
@@ -1874,7 +1874,7 @@ static void kvm_send_ipi_to_many(struct } } -static u64 kvm_hv_send_ipi (struct kvm_vcpu *vcpu,struct kvm_hv_hcall *hc,bool ex) +static u64 kvm_hv_send_ipi (struct kvm_vcpu *vcpu,struct kvm_hv_hcall *hc) {struct kvm *kvm = vcpu->kvm;struct hv_send_ipi_ex send_ipi_ex;
@@ -1888,7 +1888,7 @@ static u64 kvm_hv_send_ipi(struct kvm_vcu32 vector;bool all_cpus; -if (!ex) { +if (hc->code ==HVCALL_SEND_IPI ) {if (!hc->fast) {if (unlikely (kvm_read_guest (kvm, hc->ingpa, &send_ipi,sizeof (send_ipi))))
@@ -2278,14 +2278,14 @@ int kvm_hv_hypercall(struct kvm_vcpu *vc ret =HV_STATUS_INVALID_HYPERCALL_INPUT ;break ; } - ret =kvm_hv_send_ipi (vcpu, &hc, false); + ret =kvm_hv_send_ipi (vcpu, &hc);break ;case HVCALL_SEND_IPI_EX :if (unlikely (hc.fast || hc.rep)) { ret =HV_STATUS_INVALID_HYPERCALL_INPUT ;break ; } - ret =kvm_hv_send_ipi (vcpu, &hc, true); + ret =kvm_hv_send_ipi (vcpu, &hc);break ;case HVCALL_POST_DEBUG_DATA :case HVCALL_RETRIEVE_DEBUG_DATA :
Greg Kroah-Hartman
maintainerPATCH 863/1017 KVM: x86: hyper-v: Drop redundant ex parameter from kvm_hv_flush_tlb()
In reply to Greg Kroah-HartmanFrom: Vitaly Kuznetsov <[email protected]>
commit 82c1ead0d678af31e5d883656c12096a0004178b upstream.
'struct kvm_hv_hcall' has all the required information already, there's no need to pass 'ex' additionally.
No functional change intended.
Message-Id: <[email protected]>
--- arch/x86/kvm/hyperv.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-)
arch/x86/kvm/hyperv.c +6 -17
@@ -1749,7 +1749,7 @@ struct kvm_hv_hcall {sse128_t xmm[HV_HYPERCALL_MAX_XMM_REGISTERS ]; }; -static u64 kvm_hv_flush_tlb (struct kvm_vcpu *vcpu,struct kvm_hv_hcall *hc,bool ex) +static u64 kvm_hv_flush_tlb (struct kvm_vcpu *vcpu,struct kvm_hv_hcall *hc) {int i;gpa_t gpa;
@@ -1764,7 +1764,8 @@ static u64 kvm_hv_flush_tlb(struct kvm_vint sparse_banks_len;bool all_cpus; -if (!ex) { +if (hc->code ==HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST || + hc->code ==HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE ) {if (hc->fast) { flush.address_space = hc->ingpa; flush.flags = hc->outgpa;
@@ -2246,32 +2247,20 @@ int kvm_hv_hypercall(struct kvm_vcpu *vc kvm_hv_hypercall_complete_userspace;return 0 ;case HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST : -if (unlikely (!hc.rep_cnt || hc.rep_idx)) { - ret =HV_STATUS_INVALID_HYPERCALL_INPUT ; -break ; - } - ret =kvm_hv_flush_tlb (vcpu, &hc, false); -break ; -case HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE : -if (unlikely (hc.rep)) { - ret =HV_STATUS_INVALID_HYPERCALL_INPUT ; -break ; - } - ret =kvm_hv_flush_tlb (vcpu, &hc, false); -break ;case HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST_EX :if (unlikely (!hc.rep_cnt || hc.rep_idx)) { ret =HV_STATUS_INVALID_HYPERCALL_INPUT ;break ; } - ret =kvm_hv_flush_tlb (vcpu, &hc, true); + ret =kvm_hv_flush_tlb (vcpu, &hc);break ; +case HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE :case HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE_EX :if (unlikely (hc.rep)) { ret =HV_STATUS_INVALID_HYPERCALL_INPUT ;break ; } - ret =kvm_hv_flush_tlb (vcpu, &hc, true); + ret =kvm_hv_flush_tlb (vcpu, &hc);break ;case HVCALL_SEND_IPI :if (unlikely (hc.rep)) {
Greg Kroah-Hartman
maintainerPATCH 864/1017 KVM: x86: hyper-v: Fix the maximum number of sparse banks for XMM fast TLB flush hypercalls
In reply to Greg Kroah-HartmanFrom: Vitaly Kuznetsov <[email protected]>
commit 7321f47eada53a395fb3086d49297eebb19e8e58 upstream.
When TLB flush hypercalls (HVCALL_FLUSH_VIRTUAL_ADDRESS_{LIST,SPACE}_EX are issued in 'XMM fast' mode, the maximum number of allowed sparse_banks is not 'HV_HYPERCALL_MAX_XMM_REGISTERS - 1' (5) but twice as many (10) as each XMM register is 128 bit long and can hold two 64 bit long banks.
Message-Id: <[email protected]>
--- arch/x86/kvm/hyperv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kvm/hyperv.c +2 -1
@@ -1819,7 +1819,8 @@ static u64 kvm_hv_flush_tlb(struct kvm_vif (!all_cpus) {if (hc->fast) { -if (sparse_banks_len >HV_HYPERCALL_MAX_XMM_REGISTERS -1 ) +/* XMM0 is already consumed, each XMM holds two sparse banks. */ +if (sparse_banks_len >2 * (HV_HYPERCALL_MAX_XMM_REGISTERS -1 ))return HV_STATUS_INVALID_HYPERCALL_INPUT ;for (i =0 ; i < sparse_banks_len; i +=2 ) { sparse_banks[i] =sse128_lo (hc->xmm[i /2 +1 ]);
Greg Kroah-Hartman
maintainerPATCH 865/1017 KVM: x86: hyper-v: HVCALL_SEND_IPI_EX is an XMM fast hypercall
In reply to Greg Kroah-HartmanFrom: Vitaly Kuznetsov <[email protected]>
commit 47d3e5cdfe607ec6883eb0faa7acf05b8cb3f92a upstream.
It has been proven on practice that at least Windows Server 2019 tries using HVCALL_SEND_IPI_EX in 'XMM fast' mode when it has more than 64 vCPUs and it needs to send an IPI to a vCPU > 63. Similarly to other XMM Fast hypercalls (HVCALL_FLUSH_VIRTUAL_ADDRESS_{LIST,SPACE}{,_EX}), this information is missing in TLFS as of 6.0b. Currently, KVM returns an error (HV_STATUS_INVALID_HYPERCALL_INPUT) and Windows crashes.
Note, HVCALL_SEND_IPI is a 'standard' fast hypercall (not 'XMM fast') as all its parameters fit into RDX:R8 and this is handled by KVM correctly.
Message-Id: <[email protected]>
--- arch/x86/kvm/hyperv.c | 52 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 18 deletions(-)
arch/x86/kvm/hyperv.c +34 -18
@@ -1889,6 +1889,7 @@ static u64 kvm_hv_send_ipi(struct kvm_vcint sparse_banks_len;u32 vector;bool all_cpus; +int i;if (hc->code ==HVCALL_SEND_IPI ) {if (!hc->fast) {
@@ -1909,9 +1910,15 @@ static u64 kvm_hv_send_ipi(struct kvm_vctrace_kvm_hv_send_ipi (vector, sparse_banks[0 ]); }else { -if (unlikely (kvm_read_guest (kvm, hc->ingpa, &send_ipi_ex, -sizeof (send_ipi_ex)))) -return HV_STATUS_INVALID_HYPERCALL_INPUT ; +if (!hc->fast) { +if (unlikely (kvm_read_guest (kvm, hc->ingpa, &send_ipi_ex, +sizeof (send_ipi_ex)))) +return HV_STATUS_INVALID_HYPERCALL_INPUT ; + }else { + send_ipi_ex.vector = (u32 )hc->ingpa; + send_ipi_ex.vp_set.format = hc->outgpa; + send_ipi_ex.vp_set.valid_bank_mask =sse128_lo (hc->xmm[0 ]); + } trace_kvm_hv_send_ipi_ex(send_ipi_ex.vector, send_ipi_ex.vp_set.format,
@@ -1919,8 +1926,7 @@ static u64 kvm_hv_send_ipi(struct kvm_vc vector = send_ipi_ex.vector; valid_bank_mask = send_ipi_ex.vp_set.valid_bank_mask; - sparse_banks_len =bitmap_weight (&valid_bank_mask,64 ) * -sizeof (sparse_banks[0 ]); + sparse_banks_len =bitmap_weight (&valid_bank_mask,64 ); all_cpus = send_ipi_ex.vp_set.format ==HV_GENERIC_SET_ALL ;
@@ -1930,12 +1936,27 @@ static u64 kvm_hv_send_ipi(struct kvm_vcif (!sparse_banks_len) goto ret_success; -if (kvm_read_guest (kvm, - hc->ingpa + offsetof(struct hv_send_ipi_ex , - vp_set.bank_contents), - sparse_banks, - sparse_banks_len)) -return HV_STATUS_INVALID_HYPERCALL_INPUT ; +if (!hc->fast) { +if (kvm_read_guest (kvm, + hc->ingpa + offsetof(struct hv_send_ipi_ex , + vp_set.bank_contents), + sparse_banks, + sparse_banks_len * sizeof(sparse_banks[0]))) +return HV_STATUS_INVALID_HYPERCALL_INPUT ; + }else { +/* +* The lower half of XMM0 is already consumed, each XMM holds +* two sparse banks. +*/ +if (sparse_banks_len > (2 *HV_HYPERCALL_MAX_XMM_REGISTERS -1 )) +return HV_STATUS_INVALID_HYPERCALL_INPUT ; +for (i =0 ; i < sparse_banks_len; i++) { +if (i %2 ) + sparse_banks[i] =sse128_lo (hc->xmm[(i +1 ) /2 ]); +else + sparse_banks[i] =sse128_hi (hc->xmm[i /2 ]); + } + } } check_and_send_ipi:
@@ -2097,6 +2118,7 @@ static bool is_xmm_fast_hypercall(structcase HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE :case HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST_EX :case HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE_EX : +case HVCALL_SEND_IPI_EX :return true; }
@@ -2264,14 +2286,8 @@ int kvm_hv_hypercall(struct kvm_vcpu *vc ret =kvm_hv_flush_tlb (vcpu, &hc);break ;case HVCALL_SEND_IPI : -if (unlikely (hc.rep)) { - ret =HV_STATUS_INVALID_HYPERCALL_INPUT ; -break ; - } - ret =kvm_hv_send_ipi (vcpu, &hc); -break ;case HVCALL_SEND_IPI_EX : -if (unlikely (hc.fast || hc.rep)) { +if (unlikely (hc.rep)) { ret =HV_STATUS_INVALID_HYPERCALL_INPUT ;break ; }
Greg Kroah-Hartman
maintainerPATCH 866/1017 powerpc/kasan: Fix early region not updated correctly
In reply to Greg Kroah-HartmanFrom: Chen Jingwen <[email protected]>
commit dd75080aa8409ce10d50fb58981c6b59bf8707d3 upstream.
The shadow's page table is not updated when PTE_RPN_SHIFT is 24 and PAGE_SHIFT is 12. It not only causes false positives but also false negative as shown the following text.
Fix it by bringing the logic of kasan_early_shadow_page_entry here.
1. False Positive:
==================================================================
BUG: KASAN: vmalloc-out-of-bounds in pcpu_alloc+0x508/0xa50
Write of size 16 at addr f57f3be0 by task swapper/0/1
CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.15.0-12267-gdebe436e77c7 #1
Call Trace:
[c80d1c20] [c07fe7b8] dump_stack_lvl+0x4c/0x6c (unreliable)
[c80d1c40] [c02ff668] print_address_description.constprop.0+0x88/0x300
[c80d1c70] [c02ff45c] kasan_report+0x1ec/0x200
[c80d1cb0] [c0300b20] kasan_check_range+0x160/0x2f0
[c80d1cc0] [c03018a4] memset+0x34/0x90
[c80d1ce0] [c0280108] pcpu_alloc+0x508/0xa50
[c80d1d40] [c02fd7bc] __kmem_cache_create+0xfc/0x570
[c80d1d70] [c0283d64] kmem_cache_create_usercopy+0x274/0x3e0
[c80d1db0] [c2036580] init_sd+0xc4/0x1d0
[c80d1de0] [c00044a0] do_one_initcall+0xc0/0x33c
[c80d1eb0] [c2001624] kernel_init_freeable+0x2c8/0x384
[c80d1ef0] [c0004b14] kernel_init+0x24/0x170
[c80d1f10] [c001b26c] ret_from_kernel_thread+0x5c/0x64
Memory state around the buggy address:
f57f3a80: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
f57f3b00: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
>f57f3b80: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
^
f57f3c00: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
f57f3c80: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
==================================================================2. False Negative (with KASAN tests):
==================================================================
Before fix:
ok 45 - kmalloc_double_kzfree
# vmalloc_oob: EXPECTATION FAILED at lib/test_kasan.c:1039 KASAN failure expected in "((volatile char *)area)[3100]", but none occurred not ok 46 - vmalloc_oob
not ok 1 - kasan
==================================================================
After fix:
ok 1 - kasan
--- arch/powerpc/mm/kasan/kasan_init_32.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/powerpc/mm/kasan/kasan_init_32.c +1 -2
@@ -83,13 +83,12 @@ void __init kasan_update_early_region(unsigned long k_start, unsigned long k_end, pte_t pte) {unsigned long k_cur; -phys_addr_t pa =__pa (kasan_early_shadow_page);for (k_cur = k_start; k_cur != k_end; k_cur +=PAGE_SIZE ) {pmd_t *pmd =pmd_off_k (k_cur);pte_t *ptep =pte_offset_kernel (pmd, k_cur); -if ((pte_val (*ptep) &PTE_RPN_MASK ) != pa) +if (pte_page (*ptep) !=virt_to_page (lm_alias (kasan_early_shadow_page)))continue ;__set_pte_at (&init_mm, k_cur, ptep, pte,0 );
Greg Kroah-Hartman
maintainerPATCH 867/1017 powerpc/lib/sstep: Fix sthcx instruction
In reply to Greg Kroah-HartmanFrom: Anders Roxell <[email protected]>
commit a633cb1edddaa643fadc70abc88f89a408fa834a upstream.
Looks like there been a copy paste mistake when added the instruction 'stbcx' twice and one was probably meant to be 'sthcx'. Changing to 'sthcx' from 'stbcx'.
--- arch/powerpc/lib/sstep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/lib/sstep.c +1 -1
@@ -3389,7 +3389,7 @@ int emulate_loadstore(struct pt_regs *re__put_user_asmx (op->val, ea, err,"stbcx." , cr);break ;case 2 : -__put_user_asmx (op->val, ea, err,"stbcx." , cr); +__put_user_asmx (op->val, ea, err,"sthcx." , cr);break ;#endif case 4 :
Greg Kroah-Hartman
maintainerPATCH 868/1017 powerpc/lib/sstep: Fix build errors with newer binutils
In reply to Greg Kroah-HartmanFrom: Anders Roxell <[email protected]>
commit 8219d31effa7be5dbc7ff915d7970672e028c701 upstream.
Building tinyconfig with gcc (Debian 11.2.0-16) and assembler (Debian 2.37.90.20220207) the following build error shows up:
{standard input}: Assembler messages:
{standard input}:10576: Error: unrecognized opcode: stbcx.' {standard input}:10680: Error: unrecognized opcode: lharx' {standard input}:10694: Error: unrecognized opcode: `lbarx'
Rework to add assembler directives [1] around the instruction. The problem with this might be that we can trick a power6 into single-stepping through an stbcx. for instance, and it will execute that in kernel mode.
[1] https://sourceware.org/binutils/docs/as/PowerPC_002dPseudo.html#PowerPC_002dPseudo
--- arch/powerpc/lib/sstep.c | 6 ++++++ 1 file changed, 6 insertions(+)
arch/powerpc/lib/sstep.c +6 -0
@@ -1097,7 +1097,10 @@ NOKPROBE_SYMBOL(emulate_dcbz);#define __put_user_asmx (x, addr, err, op, cr) \ __asm__ __volatile__( \ + ".machine push\n" \ + ".machine power8\n" \ "1: " op " %2,0,%3\n" \ + ".machine pop\n" \ " mfcr %1\n" \ "2:\n" \ ".section .fixup,\"ax\"\n" \
@@ -1110,7 +1113,10 @@ NOKPROBE_SYMBOL(emulate_dcbz);#define __get_user_asmx (x, addr, err, op) \ __asm__ __volatile__( \ + ".machine push\n" \ + ".machine power8\n" \ "1: "op" %1,0,%2\n" \ + ".machine pop\n" \ "2:\n" \ ".section .fixup,\"ax\"\n" \ "3: li %0,%3\n" \
Greg Kroah-Hartman
maintainerPATCH 869/1017 powerpc: Add set_memory_{p/np}() and remove set_memory_attr()
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
commit f222ab83df92acf72691a2021e1f0d99880dcdf1 upstream.
set_memory_attr() was implemented by commit 4d1755b6a762 ("powerpc/mm:
implement set_memory_attr()") because the set_memory_xx() couldn't be used at that time to modify memory "on the fly" as explained it the commit.
But set_memory_attr() uses set_pte_at() which leads to warnings when CONFIG_DEBUG_VM is selected, because set_pte_at() is unexpected for updating existing page table entries.
The check could be bypassed by using __set_pte_at() instead, as it was the case before commit c988cfd38e48 ("powerpc/32:
use set_memory_attr()") but since commit 9f7853d7609d ("powerpc/mm:
Fix set_memory_*() against concurrent accesses") it is now possible to use set_memory_xx() functions to update page table entries "on the fly" because the update is now atomic.
For DEBUG_PAGEALLOC we need to clear and set back _PAGE_PRESENT. Add set_memory_np() and set_memory_p() for that.
Replace all uses of set_memory_attr() by the relevant set_memory_xx() and remove set_memory_attr().
Depends-on: 9f7853d7609d ("powerpc/mm: Fix set_memory_*() against concurrent accesses")
--- arch/powerpc/include/asm/set_memory.h | 12 +++++++++- arch/powerpc/mm/pageattr.c | 39 +++++----------------------------- arch/powerpc/mm/pgtable_32.c | 24 +++++++++----------- 3 files changed, 28 insertions(+), 47 deletions(-)
arch/powerpc/include/asm/set_memory.h +11 -1
@@ -6,6 +6,8 @@#define SET_MEMORY_RW 1#define SET_MEMORY_NX 2#define SET_MEMORY_X 3 +#define SET_MEMORY_NP 4/* Set memory non present */ +#define SET_MEMORY_P 5/* Set memory present */ int change_memory_attr (unsigned long addr,int numpages,long action);
@@ -29,6 +31,14 @@ static inline int set_memory_x(unsigned return change_memory_attr(addr, numpages, SET_MEMORY_X); } -int set_memory_attr (unsigned long addr,int numpages,pgprot_t prot); +static inline int set_memory_np (unsigned long addr,int numpages) +{ +return change_memory_attr (addr, numpages,SET_MEMORY_NP ); +} + +static inline int set_memory_p (unsigned long addr,int numpages) +{ +return change_memory_attr (addr, numpages,SET_MEMORY_P ); +}#endif
arch/powerpc/mm/pageattr.c +6 -33
@@ -48,6 +48,12 @@ static int change_page_attr(pte_t *ptep,case SET_MEMORY_X : pte =pte_mkexec (pte);break ; +case SET_MEMORY_NP : +pte_update (&init_mm, addr, ptep, _PAGE_PRESENT,0 ,0 ); +break ; +case SET_MEMORY_P : +pte_update (&init_mm, addr, ptep,0 , _PAGE_PRESENT,0 ); +break ;default :WARN_ON_ONCE (1 );break ;
@@ -96,36 +102,3 @@ int change_memory_attr(unsigned long addreturn apply_to_existing_page_range (&init_mm, start, size, change_page_attr, (void *)action); } - -/* -* Set the attributes of a page: -* -* This function is used by PPC32 at the end of init to set final kernel memory -* protection. It includes changing the maping of the page it is executing from -* and data pages it is using. -*/ -static int set_page_attr (pte_t *ptep,unsigned long addr,void *data) -{ -pgprot_t prot =__pgprot ((unsigned long )data); - -spin_lock (&init_mm.page_table_lock); - -set_pte_at (&init_mm, addr, ptep,pte_modify (*ptep, prot)); -flush_tlb_kernel_range (addr, addr +PAGE_SIZE ); - -spin_unlock (&init_mm.page_table_lock); - -return 0 ; -} - -int set_memory_attr (unsigned long addr,int numpages,pgprot_t prot) -{ -unsigned long start =ALIGN_DOWN (addr,PAGE_SIZE ); -unsigned long sz = numpages *PAGE_SIZE ; - -if (numpages <=0 ) -return 0 ; - -return apply_to_existing_page_range (&init_mm, start, sz, set_page_attr, - (void *)pgprot_val (prot)); -}
arch/powerpc/mm/pgtable_32.c +11 -13
@@ -135,10 +135,12 @@ void mark_initmem_nx(void)unsigned long numpages =PFN_UP ((unsigned long )_einittext) -PFN_DOWN ((unsigned long )_sinittext); -if (v_block_mapped ((unsigned long )_sinittext)) +if (v_block_mapped ((unsigned long )_sinittext)) {mmu_mark_initmem_nx (); -else -set_memory_attr ((unsigned long )_sinittext, numpages,PAGE_KERNEL ); + }else { +set_memory_nx ((unsigned long )_sinittext, numpages); +set_memory_rw ((unsigned long )_sinittext, numpages); + } }#ifdef CONFIG_STRICT_KERNEL_RWX
@@ -152,18 +154,14 @@ void mark_rodata_ro(void)return ; } - numpages =PFN_UP ((unsigned long )_etext) - -PFN_DOWN ((unsigned long )_stext); - -set_memory_attr ((unsigned long )_stext, numpages,PAGE_KERNEL_ROX );/* -* mark .rodata as read only. Use __init_begin rather than __end_rodata -* to cover NOTES and EXCEPTION_TABLE. +* mark .text and .rodata as read only. Use __init_begin rather than +* __end_rodata to cover NOTES and EXCEPTION_TABLE. */ numpages =PFN_UP ((unsigned long )__init_begin) - -PFN_DOWN ((unsigned long )__start_rodata); +PFN_DOWN ((unsigned long )_stext); -set_memory_attr ((unsigned long )__start_rodata, numpages,PAGE_KERNEL_RO ); +set_memory_ro ((unsigned long )_stext, numpages);// mark_initmem_nx() should have already run by now ptdump_check_wx ();
@@ -179,8 +177,8 @@ void __kernel_map_pages(struct page *pagreturn ;if (enable) -set_memory_attr (addr, numpages,PAGE_KERNEL ); +set_memory_p (addr, numpages);else - set_memory_attr(addr, numpages, __pgprot(0)); + set_memory_np(addr, numpages); }#endif /* CONFIG_DEBUG_PAGEALLOC */
Greg Kroah-Hartman
maintainerPATCH 870/1017 powerpc: Fix build errors with newer binutils
In reply to Greg Kroah-HartmanFrom: Anders Roxell <[email protected]>
commit 8667d0d64dd1f84fd41b5897fd87fa9113ae05e3 upstream.
Building tinyconfig with gcc (Debian 11.2.0-16) and assembler (Debian 2.37.90.20220207) the following build error shows up:
{standard input}: Assembler messages:
{standard input}:1190: Error: unrecognized opcode: stbcix' {standard input}:1433: Error: unrecognized opcode: lwzcix' {standard input}:1453: Error: unrecognized opcode: stbcix' {standard input}:1460: Error: unrecognized opcode: stwcix' {standard input}:1596: Error: unrecognized opcode: `stbcix'
...
Rework to add assembler directives [1] around the instruction. Going through them one by one shows that the changes should be safe. Like __get_user_atomic_128_aligned() is only called in p9_hmi_special_emu(), which according to the name is specific to power9. And __raw_rm_read*() are only called in things that are powernv or book3s_hv specific.
[1] https://sourceware.org/binutils/docs/as/PowerPC_002dPseudo.html#PowerPC_002dPseudo
--- arch/powerpc/include/asm/io.h | 40 ++++++++++++++++++++++++++++------- arch/powerpc/include/asm/uaccess.h | 3 ++ arch/powerpc/platforms/powernv/rng.c | 6 ++++- 3 files changed, 40 insertions(+), 9 deletions(-)
arch/powerpc/include/asm/io.h +32 -8
@@ -359,25 +359,37 @@ static inline void __raw_writeq_be(unsig*/ static inline void __raw_rm_writeb (u8 val,volatile void __iomem *paddr) { - __asm__ __volatile__("stbcix %0,0,%1" + __asm__ __volatile__(".machine push; \ +.machine power6; \ +stbcix %0,0,%1; \ +.machine pop;" : :"r" (val),"r" (paddr) :"memory" ); }static inline void __raw_rm_writew (u16 val,volatile void __iomem *paddr) { - __asm__ __volatile__("sthcix %0,0,%1" + __asm__ __volatile__(".machine push; \ +.machine power6; \ +sthcix %0,0,%1; \ +.machine pop;" : :"r" (val),"r" (paddr) :"memory" ); }static inline void __raw_rm_writel (u32 val,volatile void __iomem *paddr) { - __asm__ __volatile__("stwcix %0,0,%1" + __asm__ __volatile__(".machine push; \ +.machine power6; \ +stwcix %0,0,%1; \ +.machine pop;" : :"r" (val),"r" (paddr) :"memory" ); }static inline void __raw_rm_writeq (u64 val,volatile void __iomem *paddr) { - __asm__ __volatile__("stdcix %0,0,%1" + __asm__ __volatile__(".machine push; \ +.machine power6; \ +stdcix %0,0,%1; \ +.machine pop;" : :"r" (val),"r" (paddr) :"memory" ); }
@@ -389,7 +401,10 @@ static inline void __raw_rm_writeq_be(u6static inline u8 __raw_rm_readb (volatile void __iomem *paddr) {u8 ret; - __asm__ __volatile__("lbzcix %0,0, %1" + __asm__ __volatile__(".machine push; \ +.machine power6; \ +lbzcix %0,0, %1; \ +.machine pop;" :"=r" (ret) :"r" (paddr) :"memory" );return ret; }
@@ -397,7 +412,10 @@ static inline u8 __raw_rm_readb(volatilestatic inline u16 __raw_rm_readw (volatile void __iomem *paddr) {u16 ret; - __asm__ __volatile__("lhzcix %0,0, %1" + __asm__ __volatile__(".machine push; \ +.machine power6; \ +lhzcix %0,0, %1; \ +.machine pop;" :"=r" (ret) :"r" (paddr) :"memory" );return ret; }
@@ -405,7 +423,10 @@ static inline u16 __raw_rm_readw(volatilstatic inline u32 __raw_rm_readl (volatile void __iomem *paddr) {u32 ret; - __asm__ __volatile__("lwzcix %0,0, %1" + __asm__ __volatile__(".machine push; \ +.machine power6; \ +lwzcix %0,0, %1; \ +.machine pop;" :"=r" (ret) :"r" (paddr) :"memory" );return ret; }
@@ -413,7 +434,10 @@ static inline u32 __raw_rm_readl(volatilstatic inline u64 __raw_rm_readq (volatile void __iomem *paddr) {u64 ret; - __asm__ __volatile__("ldcix %0,0, %1" + __asm__ __volatile__(".machine push; \ +.machine power6; \ +ldcix %0,0, %1; \ +.machine pop;" :"=r" (ret) :"r" (paddr) :"memory" );return ret; }
arch/powerpc/include/asm/uaccess.h +3 -0
@@ -125,8 +125,11 @@ do { \*/ #define __get_user_atomic_128_aligned (kaddr, uaddr, err) \ __asm__ __volatile__( \ + ".machine push\n" \ + ".machine altivec\n" \ "1: lvx 0,0,%1 # get user\n" \ " stvx 0,0,%2 # put kernel\n" \ + ".machine pop\n" \ "2:\n" \ ".section .fixup,\"ax\"\n" \ "3: li %0,%3\n" \
arch/powerpc/platforms/powernv/rng.c +5 -1
@@ -43,7 +43,11 @@ static unsigned long rng_whiten(struct punsigned long parity;/* Calculate the parity of the value */ - asm ("popcntd %0,%1" :"=r" (parity) :"r" (val)); + asm (".machine push; \ +.machine power7; \ +popcntd %0,%1; \ +.machine pop;" + :"=r" (parity) :"r" (val));/* xor our value with the previous mask */ val ^= rng->mask;
Greg Kroah-Hartman
maintainerPATCH 871/1017 drm/dp: Fix off-by-one in register cache size
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
commit d4da1f27396fb1dde079447a3612f4f512caed07 upstream.
The pcon_dsc_dpcd array holds 13 registers (0x92 through 0x9E). Fix the math to calculate the max size. Found from a -Warray-bounds build:
drivers/gpu/drm/drm_dp_helper.c: In function 'drm_dp_pcon_dsc_bpp_incr':drivers/gpu/drm/drm_dp_helper.c:3130:28: error: array subscript 12 is outside array bounds of 'const u8[12]' {aka 'const unsigned char[12]'} [-Werror=array-bounds]
3130 | buf = pcon_dsc_dpcd[DP_PCON_DSC_BPP_INCR - DP_PCON_DSC_ENCODER];
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/drm_dp_helper.c:3126:39: note: while referencing 'pcon_dsc_dpcd'
3126 | int drm_dp_pcon_dsc_bpp_incr(const u8 pcon_dsc_dpcd[DP_PCON_DSC_ENCODER_CAP_SIZE])
| ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~--- include/drm/drm_dp_helper.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/drm/drm_dp_helper.h +1 -1
@@ -456,7 +456,7 @@ struct drm_panel;#define DP_FEC_CAPABILITY_1 0x091/* 2.0 */ /* DP-HDMI2.1 PCON DSC ENCODER SUPPORT */ -#define DP_PCON_DSC_ENCODER_CAP_SIZE 0xC/* 0x9E - 0x92 */ +#define DP_PCON_DSC_ENCODER_CAP_SIZE 0xD/* 0x92 through 0x9E */ #define DP_PCON_DSC_ENCODER 0x092# define DP_PCON_DSC_ENCODER_SUPPORTED (1 << 0)# define DP_PCON_DSC_PPS_ENC_OVERRIDE (1 << 1)
Greg Kroah-Hartman
maintainerPATCH 872/1017 drm/i915: Treat SAGV block time 0 as SAGV disabled
In reply to Greg Kroah-HartmanFrom: Ville Syrjälä <[email protected]>
commit 1937f3feb0e84089ae4065e09c871b8ab4676f01 upstream.
For modern platforms the spec explicitly states that a SAGV block time of zero means that SAGV is not supported. Let's extend that to all platforms. Supposedly there should be no systems where this isn't true, and it'll allow us to:
- use the same code regardless of older vs. newer platform
- wm latencies already treat 0 as disabled, so this fits well with other related code
- make it a bit more clear when SAGV is used vs. not
- avoid overflows from adding U32_MAX with a u16 wm0 latency value which could cause us to miscalculate the SAGV watermarks on tgl+
--- drivers/gpu/drm/i915/intel_pm.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/intel_pm.c +6 -4
@@ -3712,8 +3712,7 @@ skl_setup_sagv_block_time(struct drm_i91MISSING_CASE (DISPLAY_VER (dev_priv)); } -/* Default to an unusable block time */ - dev_priv->sagv_block_time_us =-1 ; + dev_priv->sagv_block_time_us =0 ; }/*
@@ -5634,7 +5633,7 @@ static void skl_compute_plane_wm(const s result->min_ddb_alloc =max (min_ddb_alloc, blocks) +1 ; result->enable = true; -if (DISPLAY_VER (dev_priv) <12 ) +if (DISPLAY_VER (dev_priv) <12 && dev_priv->sagv_block_time_us) result->can_sagv = latency >= dev_priv->sagv_block_time_us; }
@@ -5665,7 +5664,10 @@ static void tgl_compute_sagv_wm(const ststruct drm_i915_private *dev_priv =to_i915 (crtc_state->uapi.crtc->dev);struct skl_wm_level *sagv_wm = &plane_wm->sagv.wm0;struct skl_wm_level *levels = plane_wm->wm; -unsigned int latency = dev_priv->wm.skl_latency[0 ] + dev_priv->sagv_block_time_us; +unsigned int latency =0 ; + +if (dev_priv->sagv_block_time_us) + latency = dev_priv->sagv_block_time_us + dev_priv->wm.skl_latency[0 ]; skl_compute_plane_wm(crtc_state, 0, latency, wm_params, &levels[0],
Greg Kroah-Hartman
maintainerPATCH 873/1017 drm/i915: Fix PSF GV point mask when SAGV is not possible
In reply to Greg Kroah-HartmanFrom: Ville Syrjälä <[email protected]>
commit 3ef8b5e19ead5a79600ea55f9549658281415893 upstream.
Don't just mask off all the PSF GV points when SAGV gets disabled. This should in fact cause the Pcode to reject the request since at least one PSF point must remain enabled at all times.
--- drivers/gpu/drm/i915/display/intel_bw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/display/intel_bw.c +2 -1
@@ -819,7 +819,8 @@ int intel_bw_atomic_check(struct intel_a* cause. */ if (!intel_can_enable_sagv (dev_priv, new_bw_state)) { - allowed_points =BIT (max_bw_point); + allowed_points &=ADLS_PSF_PT_MASK ; + allowed_points |=BIT (max_bw_point);drm_dbg_kms (&dev_priv->drm,"No SAGV, using single QGV point %d\n" , max_bw_point); }
Greg Kroah-Hartman
maintainerPATCH 874/1017 drm/i915: Reject unsupported TMDS rates on ICL+
In reply to Greg Kroah-HartmanFrom: Ville Syrjälä <[email protected]>
commit 9cddf03b2af07443bebdc73cba21acb360c079e8 upstream.
ICL+ PLLs can't genenerate certain frequencies. Running the PLL algorithms through for all frequencies 25-594MHz we see a gap just above 500 MHz. Specifically 500-522.8MHZ for TC PLLs, and 500-533.2 MHz for combo PHY PLLs. Reject those frequencies hdmi_port_clock_valid() so that we properly filter out unsupported modes and/or color depths for HDMI.
--- drivers/gpu/drm/i915/display/intel_hdmi.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/gpu/drm/i915/display/intel_hdmi.c +9 -0
@@ -1831,6 +1831,7 @@ hdmi_port_clock_valid(struct intel_hdmi bool has_hdmi_sink) {struct drm_i915_private *dev_priv =intel_hdmi_to_i915 (hdmi); +enum phy phy =intel_port_to_phy (dev_priv,hdmi_to_dig_port (hdmi)->base.port);if (clock <25000 )return MODE_CLOCK_LOW ;
@@ -1851,6 +1852,14 @@ hdmi_port_clock_valid(struct intel_hdmiif (IS_CHERRYVIEW (dev_priv) && clock >216000 && clock <240000 )return MODE_CLOCK_RANGE ; +/* ICL+ combo PHY PLL can't generate 500-533.2 MHz */ +if (intel_phy_is_combo (dev_priv, phy) && clock >500000 && clock <533200 ) +return MODE_CLOCK_RANGE ; + +/* ICL+ TC PHY PLL can't generate 500-532.8 MHz */ +if (intel_phy_is_tc (dev_priv, phy) && clock >500000 && clock <532800 ) +return MODE_CLOCK_RANGE ; +/* * SNPS PHYs' MPLLB table-based programming can only handle a fixed * set of link rates.
Greg Kroah-Hartman
maintainerPATCH 875/1017 scsi: qla2xxx: Refactor asynchronous command initialization
In reply to Greg Kroah-HartmanFrom: Daniel Wagner <[email protected]>
commit d4523bd6fd5d3afa9f08a86038a8a92176089f5b upstream.
Move common open-coded asynchronous command initializing code such as setting up the timer and the done callback into one function. This is a preparation step and allows us later on to change the low level error flow handling at a central place.
--- drivers/scsi/qla2xxx/qla_gbl.h | 3 - drivers/scsi/qla2xxx/qla_gs.c | 70 ++++++++++------------------------ drivers/scsi/qla2xxx/qla_init.c | 77 ++++++++++++-------------------------- drivers/scsi/qla2xxx/qla_iocb.c | 29 +++++++------- drivers/scsi/qla2xxx/qla_mbx.c | 11 +---- drivers/scsi/qla2xxx/qla_mid.c | 5 -- drivers/scsi/qla2xxx/qla_mr.c | 7 +-- drivers/scsi/qla2xxx/qla_target.c | 6 -- 8 files changed, 76 insertions(+), 132 deletions(-)
drivers/scsi/qla2xxx/qla_gbl.h +2 -1
@@ -316,7 +316,8 @@ extern int qla2x00_start_sp(srb_t *);extern int qla24xx_dif_start_scsi (srb_t *);extern int qla2x00_start_bidir (srb_t *,struct scsi_qla_host *,uint32_t );extern int qla2xxx_dif_start_scsi_mq (srb_t *); -extern void qla2x00_init_timer (srb_t *sp,unsigned long tmo); +extern void qla2x00_init_async_sp (srb_t *sp,unsigned long tmo, +void (*done)(struct srb *,int ));extern unsigned long qla2x00_get_async_timeout (struct scsi_qla_host *);extern void *qla2x00_alloc_iocbs (struct scsi_qla_host *,srb_t *);
drivers/scsi/qla2xxx/qla_gs.c +22 -48
202 lines not on this page · raw message
drivers/scsi/qla2xxx/qla_init.c +25 -52
183 lines not on this page · raw message
drivers/scsi/qla2xxx/qla_iocb.c +16 -13
@@ -2560,11 +2560,15 @@ qla24xx_tm_iocb(srb_t *sp, struct tsk_mg } } -void qla2x00_init_timer (srb_t *sp,unsigned long tmo) +void +qla2x00_init_async_sp (srb_t *sp,unsigned long tmo, +void (*done)(struct srb *sp,int res)) {timer_setup (&sp->u.iocb_cmd.timer, qla2x00_sp_timeout,0 ); - sp->u.iocb_cmd.timer.expires = jiffies + tmo *HZ ; + sp->done = done; sp->free = qla2x00_sp_free; + sp->u.iocb_cmd.timeout = qla2x00_async_iocb_timeout; + sp->u.iocb_cmd.timer.expires = jiffies + tmo *HZ ;if (IS_QLAFX00 (sp->vha->hw) && sp->type ==SRB_FXIOCB_DCMD )init_completion (&sp->u.iocb_cmd.u.fxiocb.fxiocb_comp); sp->start_timer =1 ;
@@ -2672,11 +2676,11 @@ qla24xx_els_dcmd_iocb(scsi_qla_host_t *v sp->type =SRB_ELS_DCMD ; sp->name ="ELS_DCMD" ; sp->fcport = fcport; - elsio->timeout = qla2x00_els_dcmd_iocb_timeout; -qla2x00_init_timer (sp,ELS_DCMD_TIMEOUT ); -init_completion (&sp->u.iocb_cmd.u.els_logo.comp); - sp->done = qla2x00_els_dcmd_sp_done; +qla2x00_init_async_sp (sp,ELS_DCMD_TIMEOUT , + qla2x00_els_dcmd_sp_done); sp->free = qla2x00_els_dcmd_sp_free; + sp->u.iocb_cmd.timeout = qla2x00_els_dcmd_iocb_timeout; +init_completion (&sp->u.iocb_cmd.u.els_logo.comp); elsio->u.els_logo.els_logo_pyld = dma_alloc_coherent(&ha->pdev->dev, DMA_POOL_SIZE, &elsio->u.els_logo.els_logo_pyld_dma,
@@ -2993,17 +2997,16 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *ql_dbg (ql_dbg_io, vha,0x3073 ,"%s Enter: PLOGI portid=%06x\n" , __func__, fcport->d_id.b24); - sp->type =SRB_ELS_DCMD ; - sp->name ="ELS_DCMD" ; - sp->fcport = fcport; - - elsio->timeout = qla2x00_els_dcmd2_iocb_timeout;if (wait) sp->flags =SRB_WAKEUP_ON_COMP ; -qla2x00_init_timer (sp,ELS_DCMD_TIMEOUT +2 ); + sp->type =SRB_ELS_DCMD ; + sp->name ="ELS_DCMD" ; + sp->fcport = fcport; +qla2x00_init_async_sp (sp,ELS_DCMD_TIMEOUT +2 , + qla2x00_els_dcmd2_sp_done); + sp->u.iocb_cmd.timeout = qla2x00_els_dcmd2_iocb_timeout; - sp->done = qla2x00_els_dcmd2_sp_done; elsio->u.els_plogi.tx_size = elsio->u.els_plogi.rx_size =DMA_POOL_SIZE ; ptr = elsio->u.els_plogi.els_plogi_pyld =
drivers/scsi/qla2xxx/qla_mbx.c +4 -7
@@ -6483,19 +6483,16 @@ int qla24xx_send_mb_cmd(struct scsi_qla_if (!sp) goto done; - sp->type =SRB_MB_IOCB ; - sp->name =mb_to_str (mcp->mb[0 ]); - c = &sp->u.iocb_cmd; - c->timeout = qla2x00_async_iocb_timeout;init_completion (&c->u.mbx.comp); -qla2x00_init_timer (sp,qla2x00_get_async_timeout (vha) +2 ); + sp->type =SRB_MB_IOCB ; + sp->name =mb_to_str (mcp->mb[0 ]); +qla2x00_init_async_sp (sp,qla2x00_get_async_timeout (vha) +2 , + qla2x00_async_mb_sp_done);memcpy (sp->u.iocb_cmd.u.mbx.out_mb, mcp->mb,SIZEOF_IOCB_MB_REG ); - sp->done = qla2x00_async_mb_sp_done; - rval =qla2x00_start_sp (sp);if (rval !=QLA_SUCCESS ) { ql_dbg(ql_dbg_mbx, vha, 0x1018,
drivers/scsi/qla2xxx/qla_mid.c +2 -3
@@ -972,9 +972,8 @@ int qla24xx_control_vp(scsi_qla_host_t * sp->type =SRB_CTRL_VP ; sp->name ="ctrl_vp" ; sp->comp = ∁ - sp->done = qla_ctrlvp_sp_done; - sp->u.iocb_cmd.timeout = qla2x00_async_iocb_timeout; -qla2x00_init_timer (sp,qla2x00_get_async_timeout (vha) +2 ); +qla2x00_init_async_sp (sp,qla2x00_get_async_timeout (vha) +2 , + qla_ctrlvp_sp_done); sp->u.iocb_cmd.u.ctrlvp.cmd = cmd; sp->u.iocb_cmd.u.ctrlvp.vp_index = vp_index;
drivers/scsi/qla2xxx/qla_mr.c +3 -4
@@ -1793,11 +1793,11 @@ qlafx00_fx_disc(scsi_qla_host_t *vha, fc sp->type =SRB_FXIOCB_DCMD ; sp->name ="fxdisc" ; +qla2x00_init_async_sp (sp,FXDISC_TIMEOUT , + qla2x00_fxdisc_sp_done); + sp->u.iocb_cmd.timeout = qla2x00_fxdisc_iocb_timeout; fdisc = &sp->u.iocb_cmd; - fdisc->timeout = qla2x00_fxdisc_iocb_timeout; -qla2x00_init_timer (sp,FXDISC_TIMEOUT ); -switch (fx_type) {case FXDISC_GET_CONFIG_INFO : fdisc->u.fxiocb.flags =
@@ -1898,7 +1898,6 @@ qlafx00_fx_disc(scsi_qla_host_t *vha, fc } fdisc->u.fxiocb.req_func_type =cpu_to_le16 (fx_type); - sp->done = qla2x00_fxdisc_sp_done; rval =qla2x00_start_sp (sp);if (rval !=QLA_SUCCESS )
drivers/scsi/qla2xxx/qla_target.c +2 -4
@@ -656,12 +656,10 @@ int qla24xx_async_notify_ack(scsi_qla_ho sp->type = type; sp->name ="nack" ; - - sp->u.iocb_cmd.timeout = qla2x00_async_iocb_timeout; -qla2x00_init_timer (sp,qla2x00_get_async_timeout (vha)+2 ); +qla2x00_init_async_sp (sp,qla2x00_get_async_timeout (vha) +2 , + qla2x00_async_nack_sp_done); sp->u.iocb_cmd.u.nack.ntfy = ntfy; - sp->done = qla2x00_async_nack_sp_done; ql_dbg(ql_dbg_disc, vha, 0x20f4, "Async-%s %8phC hndl %x %s\n",
Greg Kroah-Hartman
maintainerPATCH 876/1017 scsi: qla2xxx: Implement ref count for SRB
In reply to Greg Kroah-HartmanFrom: Saurav Kashyap <[email protected]>
commit 31e6cdbe0eae37badceb5e0d4f06cf051432fd77 upstream.
The timeout handler and the done function are racing. When qla2x00_async_iocb_timeout() starts to run it can be preempted by the normal response path (via the firmware?). qla24xx_async_gpsc_sp_done() releases the SRB unconditionally. When scheduling back to qla2x00_async_iocb_timeout() qla24xx_async_abort_cmd() will access an freed sp->qpair pointer:
qla2xxx [0000:83:00.0]-2871:0: Async-gpsc timeout - hdl=63d portid=234500 50:06:0e:80:08:77:b6:21. qla2xxx [0000:83:00.0]-2853:0: Async done-gpsc res 0, WWPN 50:06:0e:80:08:77:b6:21
qla2xxx [0000:83:00.0]-2854:0: Async-gpsc OUT WWPN 20:45:00:27:f8:75:33:00 speeds=2c00 speed=0400. qla2xxx [0000:83:00.0]-28d8:0: qla24xx_handle_gpsc_event 50:06:0e:80:08:77:b6:21 DS 7 LS 6 rc 0 login 1|1 rscn 1|0 lid 5
BUG: unable to handle kernel NULL pointer dereference at 0000000000000004 IP: qla24xx_async_abort_cmd+0x1b/0x1c0 [qla2xxx]
Obvious solution to this is to introduce a reference counter. One reference is taken for the normal code path (the 'good' case) and one for the timeout path. As we always race between the normal good case and the timeout/abort handler we need to serialize it. Also we cannot assume any order between the handlers. Since this is slow path we can use proper synchronization via locks.
When we are able to cancel a timer (del_timer returns 1) we know there can't be any error handling in progress because the timeout handler hasn't expired yet, thus we can safely decrement the refcounter by one.
If we are not able to cancel the timer, we know an abort handler is running. We have to make sure we call sp->done() in the abort handlers before calling kref_put().
--- drivers/scsi/qla2xxx/qla_bsg.c | 6 +- drivers/scsi/qla2xxx/qla_def.h | 5 ++ drivers/scsi/qla2xxx/qla_edif.c | 3 - drivers/scsi/qla2xxx/qla_gbl.h | 1 drivers/scsi/qla2xxx/qla_gs.c | 85 +++++++++++++++++++++++++------------- drivers/scsi/qla2xxx/qla_init.c | 70 +++++++++++++++++++++---------- drivers/scsi/qla2xxx/qla_inline.h | 2 drivers/scsi/qla2xxx/qla_iocb.c | 41 ++++++++++++++---- drivers/scsi/qla2xxx/qla_mbx.c | 4 + drivers/scsi/qla2xxx/qla_mid.c | 4 + drivers/scsi/qla2xxx/qla_mr.c | 4 + drivers/scsi/qla2xxx/qla_os.c | 14 ++++-- drivers/scsi/qla2xxx/qla_target.c | 4 - 13 files changed, 173 insertions(+), 70 deletions(-)
drivers/scsi/qla2xxx/qla_bsg.c +4 -2
@@ -29,7 +29,8 @@ void qla2x00_bsg_job_done(srb_t *sp, int"%s: sp hdl %x, result=%x bsg ptr %p\n" , __func__, sp->handle, res, bsg_job); - sp->free (sp); +/* ref: INIT */ +kref_put (&sp->cmd_kref, qla2x00_sp_release); bsg_reply->result = res; bsg_job_done(bsg_job, bsg_reply->result,
@@ -3013,7 +3014,8 @@ qla24xx_bsg_timeout(struct bsg_job *bsg_ done:spin_unlock_irqrestore (&ha->hardware_lock, flags); - sp->free (sp); +/* ref: INIT */ +kref_put (&sp->cmd_kref, qla2x00_sp_release);return 0 ; }
drivers/scsi/qla2xxx/qla_def.h +5 -0
@@ -726,6 +726,11 @@ typedef struct srb {* code. */ void (*put_fn)(struct kref *kref); + +/* +* Report completion for asynchronous commands. +*/ +void (*async_done)(struct srb *sp,int res); } srb_t;#define GET_CMD_SP (sp) (sp->u.scmd.cmd)
drivers/scsi/qla2xxx/qla_edif.c +2 -1
@@ -2146,7 +2146,8 @@ edif_doorbell_show(struct device *dev, sstatic void qla_noop_sp_done (srb_t *sp,int res) { - sp->free (sp); +/* ref: INIT */ +kref_put (&sp->cmd_kref, qla2x00_sp_release); }/*
drivers/scsi/qla2xxx/qla_gbl.h +1 -0
@@ -333,6 +333,7 @@ extern int qla24xx_get_one_block_sg(uintextern int qla24xx_configure_prot_mode (srb_t *,uint16_t *);extern int qla24xx_issue_sa_replace_iocb (scsi_qla_host_t *vha,struct qla_work_evt *e); +void qla2x00_sp_release (struct kref *kref);/* * Global Function Prototypes in qla_mbx.c source file.
drivers/scsi/qla2xxx/qla_gs.c +57 -28
289 lines not on this page · raw message
drivers/scsi/qla2xxx/qla_init.c +49 -21
236 lines not on this page · raw message
drivers/scsi/qla2xxx/qla_inline.h +2 -0
@@ -184,6 +184,8 @@ static void qla2xxx_init_sp(srb_t *sp, s sp->vha = vha; sp->qpair = qpair; sp->cmd_type =TYPE_SRB ; +/* ref : INIT - normal flow */ +kref_init (&sp->cmd_kref);INIT_LIST_HEAD (&sp->elem); }
drivers/scsi/qla2xxx/qla_iocb.c +32 -9
102 lines not on this page · raw message
drivers/scsi/qla2xxx/qla_mbx.c +3 -1
@@ -6479,6 +6479,7 @@ int qla24xx_send_mb_cmd(struct scsi_qla_if (!vha->hw->flags.fw_started) goto done; +/* ref: INIT */ sp =qla2x00_get_sp (vha,NULL ,GFP_KERNEL );if (!sp) goto done;
@@ -6524,7 +6525,8 @@ int qla24xx_send_mb_cmd(struct scsi_qla_ } done_free_sp: - sp->free (sp); +/* ref: INIT */ +kref_put (&sp->cmd_kref, qla2x00_sp_release); done:return rval; }
drivers/scsi/qla2xxx/qla_mid.c +3 -1
@@ -965,6 +965,7 @@ int qla24xx_control_vp(scsi_qla_host_t *if (vp_index ==0 || vp_index >= ha->max_npiv_vports)return QLA_PARAMETER_ERROR ; +/* ref: INIT */ sp =qla2x00_get_sp (base_vha,NULL ,GFP_KERNEL );if (!sp)return rval;
@@ -1007,6 +1008,7 @@ int qla24xx_control_vp(scsi_qla_host_t *break ; } done: - sp->free (sp); +/* ref: INIT */ +kref_put (&sp->cmd_kref, qla2x00_sp_release);return rval; }
drivers/scsi/qla2xxx/qla_mr.c +3 -1
@@ -1787,6 +1787,7 @@ qlafx00_fx_disc(scsi_qla_host_t *vha, fcstruct register_host_info *preg_hsi;struct new_utsname *p_sysid =NULL ; +/* ref: INIT */ sp =qla2x00_get_sp (vha, fcport,GFP_KERNEL );if (!sp) goto done;
@@ -1973,7 +1974,8 @@ done_unmap_req:dma_free_coherent (&ha->pdev->dev, fdisc->u.fxiocb.req_len, fdisc->u.fxiocb.req_addr, fdisc->u.fxiocb.req_dma_handle); done_free_sp: - sp->free (sp); +/* ref: INIT */ +kref_put (&sp->cmd_kref, qla2x00_sp_release); done:return rval; }
drivers/scsi/qla2xxx/qla_os.c +10 -4
@@ -728,7 +728,8 @@ void qla2x00_sp_compl(srb_t *sp, int resstruct scsi_cmnd *cmd =GET_CMD_SP (sp);struct completion *comp = sp->comp; - sp->free (sp); +/* kref: INIT */ +kref_put (&sp->cmd_kref, qla2x00_sp_release); cmd->result = res;CMD_SP (cmd) =NULL ;scsi_done (cmd);
@@ -819,7 +820,8 @@ void qla2xxx_qpair_sp_compl(srb_t *sp, istruct scsi_cmnd *cmd =GET_CMD_SP (sp);struct completion *comp = sp->comp; - sp->free (sp); +/* ref: INIT */ +kref_put (&sp->cmd_kref, qla2x00_sp_release); cmd->result = res;CMD_SP (cmd) =NULL ;scsi_done (cmd);
@@ -919,6 +921,7 @@ qla2xxx_queuecommand(struct Scsi_Host *h goto qc24_target_busy; sp =scsi_cmd_priv (cmd); +/* ref: INIT */ qla2xxx_init_sp (sp, vha, vha->hw->base_qpair, fcport); sp->u.scmd.cmd = cmd;
@@ -938,7 +941,8 @@ qla2xxx_queuecommand(struct Scsi_Host *hreturn 0 ; qc24_host_busy_free_sp: - sp->free (sp); +/* ref: INIT */ +kref_put (&sp->cmd_kref, qla2x00_sp_release); qc24_target_busy:return SCSI_MLQUEUE_TARGET_BUSY ;
@@ -1008,6 +1012,7 @@ qla2xxx_mqueuecommand(struct Scsi_Host * goto qc24_target_busy; sp =scsi_cmd_priv (cmd); +/* ref: INIT */ qla2xxx_init_sp (sp, vha, qpair, fcport); sp->u.scmd.cmd = cmd;
@@ -1026,7 +1031,8 @@ qla2xxx_mqueuecommand(struct Scsi_Host *return 0 ; qc24_host_busy_free_sp: - sp->free (sp); +/* ref: INIT */ +kref_put (&sp->cmd_kref, qla2x00_sp_release); qc24_target_busy:return SCSI_MLQUEUE_TARGET_BUSY ;
drivers/scsi/qla2xxx/qla_target.c +2 -2
@@ -620,7 +620,7 @@ static void qla2x00_async_nack_sp_done(s }spin_unlock_irqrestore (&vha->hw->tgt.sess_lock, flags); - sp->free (sp); +kref_put (&sp->cmd_kref, qla2x00_sp_release); } int qla24xx_async_notify_ack(scsi_qla_host_t *vha, fc_port_t *fcport,
@@ -672,7 +672,7 @@ int qla24xx_async_notify_ack(scsi_qla_horeturn rval; done_free_sp: - sp->free (sp); +kref_put (&sp->cmd_kref, qla2x00_sp_release); done: fcport->flags &= ~FCF_ASYNC_SENT ;return rval;
Greg Kroah-Hartman
maintainerPATCH 877/1017 scsi: qla2xxx: Fix stuck session in gpdb
In reply to Greg Kroah-HartmanFrom: Quinn Tran <[email protected]>
commit 725d3a0d31a51c0debf970011e05f585e805165b upstream.
Fix stuck sessions in get port database. When a thread is in the process of re-establishing a session, a flag is set to prevent multiple threads / triggers from doing the same task. This flag was left on, where any attempt to relogin was locked out. Clear this flag, if the attempt has failed.
--- drivers/scsi/qla2xxx/qla_init.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/qla2xxx/qla_init.c +3 -3
@@ -1332,9 +1332,9 @@ int qla24xx_async_gpdb(struct scsi_qla_hif (!vha->flags.online || (fcport->flags &FCF_ASYNC_SENT ) || fcport->loop_id ==FC_NO_LOOP_ID ) {ql_log (ql_log_warn, vha,0xffff , -"%s: %8phC - not sending command.\n" , - __func__, fcport->port_name); -return rval; +"%s: %8phC online %d flags %x - not sending command.\n" , + __func__, fcport->port_name, vha->flags.online, fcport->flags); + goto done; } sp =qla2x00_get_sp (vha, fcport,GFP_KERNEL );
Greg Kroah-Hartman
maintainerPATCH 878/1017 scsi: qla2xxx: Fix warning message due to adisc being flushed
In reply to Greg Kroah-HartmanFrom: Quinn Tran <[email protected]>
commit 64f24af75b79cba3b86b0760e27e0fa904db570f upstream.
Fix warning message due to adisc being flushed. Linux kernel triggered a warning message where a different error code type is not matching up with the expected type. Add additional translation of one error code type to another.
WARNING: CPU: 2 PID: 1131623 at drivers/scsi/qla2xxx/qla_init.c:498 qla2x00_async_adisc_sp_done+0x294/0x2b0 [qla2xxx] CPU: 2 PID: 1131623 Comm: drmgr Not tainted 5.13.0-rc1-autotest #1
..
GPR28: c000000aaa9c8890 c0080000079ab678 c00000140a104800 c00000002bd19000 NIP [c00800000790857c] qla2x00_async_adisc_sp_done+0x294/0x2b0 [qla2xxx] LR [c008000007908578] qla2x00_async_adisc_sp_done+0x290/0x2b0 [qla2xxx]
Call Trace: [c00000001cdc3620] [c008000007908578] qla2x00_async_adisc_sp_done+0x290/0x2b0 [qla2xxx] (unreliable) [c00000001cdc3710] [c0080000078f3080] __qla2x00_abort_all_cmds+0x1b8/0x580 [qla2xxx] [c00000001cdc3840] [c0080000078f589c] qla2x00_abort_all_cmds+0x34/0xd0 [qla2xxx] [c00000001cdc3880] [c0080000079153d8] qla2x00_abort_isp_cleanup+0x3f0/0x570 [qla2xxx] [c00000001cdc3920] [c0080000078fb7e8] qla2x00_remove_one+0x3d0/0x480 [qla2xxx] [c00000001cdc39b0] [c00000000071c274] pci_device_remove+0x64/0x120 [c00000001cdc39f0] [c0000000007fb818] device_release_driver_internal+0x168/0x2a0 [c00000001cdc3a30] [c00000000070e304] pci_stop_bus_device+0xb4/0x100 [c00000001cdc3a70] [c00000000070e4f0] pci_stop_and_remove_bus_device+0x20/0x40 [c00000001cdc3aa0] [c000000000073940] pci_hp_remove_devices+0x90/0x130 [c00000001cdc3b30] [c0080000070704d0] disable_slot+0x38/0x90 [rpaphp] [ c00000001cdc3b60] [c00000000073eb4c] power_write_file+0xcc/0x180 [c00000001cdc3be0] [c0000000007354bc] pci_slot_attr_store+0x3c/0x60 [c00000001cdc3c00] [c00000000055f820] sysfs_kf_write+0x60/0x80 [c00000001cdc3c20] [c00000000055df10] kernfs_fop_write_iter+0x1a0/0x290 [c00000001cdc3c70] [c000000000447c4c] new_sync_write+0x14c/0x1d0 [c00000001cdc3d10] [c00000000044b134] vfs_write+0x224/0x330 [c00000001cdc3d60] [c00000000044b3f4] ksys_write+0x74/0x130 [c00000001cdc3db0] [c00000000002df70] system_call_exception+0x150/0x2d0 [c00000001cdc3e10] [c00000000000d45c] system_call_common+0xec/0x278
--- drivers/scsi/qla2xxx/qla_init.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/scsi/qla2xxx/qla_init.c +6 -0
@@ -295,6 +295,8 @@ static void qla2x00_async_login_sp_done( ea.iop[0 ] = lio->u.logio.iop[0 ]; ea.iop[1 ] = lio->u.logio.iop[1 ]; ea.sp = sp; +if (res) + ea.data[0 ] =MBS_COMMAND_ERROR ;qla24xx_handle_plogi_done_event (vha, &ea); }
@@ -557,6 +559,8 @@ static void qla2x00_async_adisc_sp_done( ea.iop[1 ] = lio->u.logio.iop[1 ]; ea.fcport = sp->fcport; ea.sp = sp; +if (res) + ea.data[0 ] =MBS_COMMAND_ERROR ;qla24xx_handle_adisc_event (vha, &ea);/* ref: INIT */
@@ -1237,6 +1241,8 @@ static void qla2x00_async_prli_sp_done(s ea.sp = sp;if (res ==QLA_OS_TIMER_EXPIRED ) ea.data[0 ] =QLA_OS_TIMER_EXPIRED ; +else if (res) + ea.data[0 ] =MBS_COMMAND_ERROR ;qla24xx_handle_prli_done_event (vha, &ea); }
Greg Kroah-Hartman
maintainerPATCH 879/1017 scsi: qla2xxx: Fix scheduling while atomic
In reply to Greg Kroah-HartmanFrom: Quinn Tran <[email protected]>
commit afd438ff874ca40b74321b3fa19bd61adfd7ca0c upstream.
The driver makes a call into midlayer (fc_remote_port_delete) which can put the thread to sleep. The thread that originates the call is in interrupt context. The combination of the two trigger a crash. Schedule the call in non-interrupt context where it is more safe.
kernel: BUG: scheduling while atomic: swapper/7/0/0x00010000 kernel: Call Trace: kernel: <IRQ> kernel: dump_stack+0x66/0x81 kernel: __schedule_bug.cold.90+0x5/0x1d kernel: __schedule+0x7af/0x960 kernel: schedule+0x28/0x80 kernel: schedule_timeout+0x26d/0x3b0 kernel: wait_for_completion+0xb4/0x140 kernel: ? wake_up_q+0x70/0x70 kernel: __wait_rcu_gp+0x12c/0x160 kernel: ? sdev_evt_alloc+0xc0/0x180 [scsi_mod] kernel: synchronize_sched+0x6c/0x80 kernel: ? call_rcu_bh+0x20/0x20 kernel: ? __bpf_trace_rcu_invoke_callback+0x10/0x10 kernel: sdev_evt_alloc+0xfd/0x180 [scsi_mod] kernel: starget_for_each_device+0x85/0xb0 [scsi_mod] kernel: ? scsi_init_io+0x360/0x3d0 [scsi_mod] kernel: scsi_init_io+0x388/0x3d0 [scsi_mod] kernel: device_for_each_child+0x54/0x90 kernel: fc_remote_port_delete+0x70/0xe0 [scsi_transport_fc] kernel: qla2x00_schedule_rport_del+0x62/0xf0 [qla2xxx] kernel: qla2x00_mark_device_lost+0x9c/0xd0 [qla2xxx] kernel: qla24xx_handle_plogi_done_event+0x55f/0x570 [qla2xxx] kernel: qla2x00_async_login_sp_done+0xd2/0x100 [qla2xxx] kernel: qla24xx_logio_entry+0x13a/0x3c0 [qla2xxx] kernel: qla24xx_process_response_queue+0x306/0x400 [qla2xxx] kernel: qla24xx_msix_rsp_q+0x3f/0xb0 [qla2xxx] kernel: __handle_irq_event_percpu+0x40/0x180 kernel: handle_irq_event_percpu+0x30/0x80 kernel: handle_irq_event+0x36/0x60
--- drivers/scsi/qla2xxx/qla_init.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/scsi/qla2xxx/qla_init.c +1 -6
@@ -2231,12 +2231,7 @@ qla24xx_handle_plogi_done_event(struct sql_dbg (ql_dbg_disc, vha,0x20eb ,"%s %d %8phC cmd error %x\n" , __func__, __LINE__, ea->fcport->port_name, ea->data[1 ]); - ea->fcport->flags &= ~FCF_ASYNC_SENT ; -qla2x00_set_fcport_disc_state (ea->fcport,DSC_LOGIN_FAILED ); -if (ea->data[1 ] &QLA_LOGIO_LOGIN_RETRIED ) -set_bit (RELOGIN_NEEDED , &vha->dpc_flags); -else -qla2x00_mark_device_lost (vha, ea->fcport,1 ); +qlt_schedule_sess_for_deletion (ea->fcport);break ;case MBS_LOOP_ID_USED :/* data[1] = IO PARAM 1 = nport ID */
Greg Kroah-Hartman
maintainerPATCH 880/1017 scsi: qla2xxx: Fix premature hw access after PCI error
In reply to Greg Kroah-HartmanFrom: Quinn Tran <[email protected]>
commit e35920ab7874d5e2faeb4f958a74bfa793f1ce5a upstream.
After a recoverable PCI error has been detected and recovered, qla driver needs to check to see if the error condition still persist and/or wait for the OS to give the resume signal.
Sep 8 22:26:03 localhost kernel: WARNING: CPU: 9 PID: 124606 at qla_tmpl.c:440 qla27xx_fwdt_entry_t266+0x55/0x60 [qla2xxx] Sep 8 22:26:03 localhost kernel: RIP: 0010:qla27xx_fwdt_entry_t266+0x55/0x60 [qla2xxx] Sep 8 22:26:03 localhost kernel: Call Trace: Sep 8 22:26:03 localhost kernel: ? qla27xx_walk_template+0xb1/0x1b0 [qla2xxx] Sep 8 22:26:03 localhost kernel: ? qla27xx_execute_fwdt_template+0x12a/0x160 [qla2xxx] Sep 8 22:26:03 localhost kernel: ? qla27xx_fwdump+0xa0/0x1c0 [qla2xxx] Sep 8 22:26:03 localhost kernel: ? qla2xxx_pci_mmio_enabled+0xfb/0x120 [qla2xxx] Sep 8 22:26:03 localhost kernel: ? report_mmio_enabled+0x44/0x80 Sep 8 22:26:03 localhost kernel: ? report_slot_reset+0x80/0x80 Sep 8 22:26:03 localhost kernel: ? pci_walk_bus+0x70/0x90 Sep 8 22:26:03 localhost kernel: ? aer_dev_correctable_show+0xc0/0xc0 Sep 8 22:26:03 localhost kernel: ? pcie_do_recovery+0x1bb/0x240 Sep 8 22:26:03 localhost kernel: ? aer_recover_work_func+0xaa/0xd0 Sep 8 22:26:03 localhost kernel: ? process_one_work+0x1a7/0x360 .. Sep 8 22:26:03 localhost kernel: qla2xxx [0000:42:00.2]-8041:22: detected PCI disconnect. Sep 8 22:26:03 localhost kernel: qla2xxx [0000:42:00.2]-107ff:22: qla27xx_fwdt_entry_t262: dump ram MB failed. Area 5h start 198013h end 198013h Sep 8 22:26:03 localhost kernel: qla2xxx [0000:42:00.2]-107ff:22: Unable to capture FW dump Sep 8 22:26:03 localhost kernel: qla2xxx [0000:42:00.2]-1015:22: cmd=0x0, waited 5221 msecs Sep 8 22:26:03 localhost kernel: qla2xxx [0000:42:00.2]-680d:22: mmio enabled returning. Sep 8 22:26:03 localhost kernel: qla2xxx [0000:42:00.2]-d04c:22: MBX
Command timeout for cmd 0, iocontrol=ffffffff jiffies=10140f2e5 mb[0-3]=[0xffff 0xffff 0xffff 0xffff]
--- drivers/scsi/qla2xxx/qla_os.c | 10 +++++++++- drivers/scsi/qla2xxx/qla_tmpl.c | 9 +++++++-- 2 files changed, 16 insertions(+), 3 deletions(-)
drivers/scsi/qla2xxx/qla_os.c +9 -1
@@ -7639,7 +7639,7 @@ qla2xxx_pci_error_detected(struct pci_deswitch (state) {case pci_channel_io_normal: - ha->flags.eeh_busy =0 ; +qla_pci_set_eeh_busy (vha);if (ql2xmqsupport || ql2xnvmeenable) {set_bit (QPAIR_ONLINE_CHECK_NEEDED , &vha->dpc_flags);qla2xxx_wake_dpc (vha);
@@ -7680,9 +7680,16 @@ qla2xxx_pci_mmio_enabled(struct pci_dev "mmio enabled\n"); ha->pci_error_state =QLA_PCI_MMIO_ENABLED ; +if (IS_QLA82XX (ha))return PCI_ERS_RESULT_RECOVERED ; +if (qla2x00_isp_reg_stat (ha)) { +ql_log (ql_log_info, base_vha,0x803f , +"During mmio enabled, PCI/Register disconnect still detected.\n" ); + goto out; + } +spin_lock_irqsave (&ha->hardware_lock, flags);if (IS_QLA2100 (ha) ||IS_QLA2200 (ha)){ stat =rd_reg_word (®->hccr);
@@ -7704,6 +7711,7 @@ qla2xxx_pci_mmio_enabled(struct pci_dev "RISC paused -- mmio_enabled, Dumping firmware.\n");qla2xxx_dump_fw (base_vha); } +out:/* set PCI_ERS_RESULT_NEED_RESET to trigger call to qla2xxx_pci_slot_reset */ ql_dbg (ql_dbg_aer, base_vha,0x600d ,"mmio enabled returning.\n" );
drivers/scsi/qla2xxx/qla_tmpl.c +7 -2
@@ -435,8 +435,13 @@ qla27xx_fwdt_entry_t266(struct scsi_qla_ {ql_dbg (ql_dbg_misc, vha,0xd20a ,"%s: reset risc [%lx]\n" , __func__, *len); -if (buf) -WARN_ON_ONCE (qla24xx_soft_reset (vha->hw) !=QLA_SUCCESS ); +if (buf) { +if (qla24xx_soft_reset (vha->hw) !=QLA_SUCCESS ) { +ql_dbg (ql_dbg_async, vha,0x5001 , +"%s: unable to soft reset\n" , __func__); +return INVALID_ENTRY ; + } + }return qla27xx_next_entry (ent); }
Greg Kroah-Hartman
maintainerPATCH 881/1017 scsi: qla2xxx: Fix wrong FDMI data for 64G adapter
In reply to Greg Kroah-HartmanFrom: Bikash Hazarika <[email protected]>
commit 1cfbbacbee2d6ea3816386a483e3c7a96e5bd657 upstream.
Corrected transmission speed mask values for FC.
Supported Speed: 16 32 20 Gb/s ===> Should be 64 instead of 20
Supported Speed: 16G 32G 48G ===> Should be 64G instead of 48G
--- drivers/scsi/qla2xxx/qla_def.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_def.h +5 -1
@@ -2891,7 +2891,11 @@ struct ct_fdmi2_hba_attributes {#define FDMI_PORT_SPEED_8GB 0x10#define FDMI_PORT_SPEED_16GB 0x20#define FDMI_PORT_SPEED_32GB 0x40 -#define FDMI_PORT_SPEED_64GB 0x80 +#define FDMI_PORT_SPEED_20GB 0x80 +#define FDMI_PORT_SPEED_40GB 0x100 +#define FDMI_PORT_SPEED_128GB 0x200 +#define FDMI_PORT_SPEED_64GB 0x400 +#define FDMI_PORT_SPEED_256GB 0x800#define FDMI_PORT_SPEED_UNKNOWN 0x8000#define FC_CLASS_2 0x04
Greg Kroah-Hartman
maintainerPATCH 882/1017 scsi: qla2xxx: Fix warning for missing error code
In reply to Greg Kroah-HartmanFrom: Nilesh Javali <[email protected]>
commit 14cb838d245ae0d523b2f7804af5a02c22e79f5a upstream.
Fix smatch-reported warning message:
drivers/scsi/qla2xxx/qla_target.c:3324 qlt_xmit_response() warn: missing error code 'res'
--- drivers/scsi/qla2xxx/qla_target.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/qla2xxx/qla_target.c +1 -0
@@ -3318,6 +3318,7 @@ int qlt_xmit_response(struct qla_tgt_cmd"RESET-RSP online/active/old-count/new-count = %d/%d/%d/%d.\n" , vha->flags.online,qla2x00_reset_active (vha), cmd->reset_count, qpair->chip_reset); + res =0 ; goto out_unmap_unlock; }
Greg Kroah-Hartman
maintainerPATCH 883/1017 scsi: qla2xxx: Fix device reconnect in loop topology
In reply to Greg Kroah-HartmanFrom: Arun Easi <[email protected]>
commit 8ad4be3d15cf144b5834bdb00d5bbe4050938dc7 upstream.
A device logout in loop topology initiates a device connection teardown which loses the FW device handle. In loop topo, the device handle is not regrabbed leading to device login failures and eventually to loss of the device. Fix this by taking the main login path that does it.
--- drivers/scsi/qla2xxx/qla_init.c | 15 +++++++++++++++ drivers/scsi/qla2xxx/qla_os.c | 5 +++++ 2 files changed, 20 insertions(+)
drivers/scsi/qla2xxx/qla_init.c +15 -0
@@ -974,6 +974,9 @@ static void qla24xx_handle_gnl_done_evenset_bit (RELOGIN_NEEDED , &vha->dpc_flags); }break ; +case ISP_CFG_NL : +qla24xx_fcport_handle_login (vha, fcport); +break ;default :break ; }
@@ -1563,6 +1566,11 @@ static void qla_chk_n2n_b4_login(structu8 login =0 ;int rc; +ql_dbg (ql_dbg_disc, vha,0x307b , +"%s %8phC DS %d LS %d lid %d retries=%d\n" , + __func__, fcport->port_name, fcport->disc_state, + fcport->fw_login_state, fcport->loop_id, fcport->login_retry); +if (qla_tgt_mode_enabled (vha))return ;
@@ -5604,6 +5612,13 @@ qla2x00_configure_local_loop(scsi_qla_homemcpy (fcport->node_name, new_fcport->node_name,WWN_SIZE ); fcport->scan_state =QLA_FCPORT_FOUND ; +if (fcport->login_retry ==0 ) { + fcport->login_retry = vha->hw->login_retry_count; +ql_dbg (ql_dbg_disc, vha,0x2135 , +"Port login retry %8phN, lid 0x%04x retry cnt=%d.\n" , + fcport->port_name, fcport->loop_id, + fcport->login_retry); + } found++;break ; }
drivers/scsi/qla2xxx/qla_os.c +5 -0
@@ -5533,6 +5533,11 @@ void qla2x00_relogin(struct scsi_qla_hos ea.fcport = fcport;qla24xx_handle_relogin_event (vha, &ea); }else if (vha->hw->current_topology == +ISP_CFG_NL && +IS_QLA2XXX_MIDTYPE (vha->hw)) { + (void )qla24xx_fcport_handle_login (vha, + fcport); + }else if (vha->hw->current_topology ==ISP_CFG_NL ) { fcport->login_retry--; status =
Greg Kroah-Hartman
maintainerPATCH 884/1017 scsi: qla2xxx: edif: Fix clang warning
In reply to Greg Kroah-HartmanFrom: Quinn Tran <[email protected]>
commit 73825fd7a37c1a685e9e9e27c9dc91ef1f3e2971 upstream.
Silence compile warning due to unaligned memory access.
qla_edif.c:713:45: warning: taking address of packed member 'u' of class or
structure 'auth_complete_cmd' may result in an unaligned pointer value [-Waddress-of-packed-member]
fcport = qla2x00_find_fcport_by_pid(vha, &appplogiok.u.d_id);
--- drivers/scsi/qla2xxx/qla_edif.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)
drivers/scsi/qla2xxx/qla_edif.c +19 -3
@@ -668,6 +668,11 @@ qla_edif_app_authok(scsi_qla_host_t *vha bsg_job->request_payload.sg_cnt, &appplogiok, sizeof(struct auth_complete_cmd)); +/* silent unaligned access warning */ + portid.b.domain = appplogiok.u.d_id.b.domain; + portid.b.area = appplogiok.u.d_id.b.area; + portid.b.al_pa = appplogiok.u.d_id.b.al_pa; +switch (appplogiok.type) {case PL_TYPE_WWPN : fcport = qla2x00_find_fcport_by_wwpn(vha,
@@ -678,7 +683,7 @@ qla_edif_app_authok(scsi_qla_host_t *vha __func__, appplogiok.u.wwpn);break ;case PL_TYPE_DID : - fcport =qla2x00_find_fcport_by_pid (vha, &appplogiok.u.d_id); + fcport =qla2x00_find_fcport_by_pid (vha, &portid);if (!fcport) ql_dbg(ql_dbg_edif, vha, 0x911d, "%s d_id lookup failed: %x\n", __func__,
@@ -777,6 +782,11 @@ qla_edif_app_authfail(scsi_qla_host_t *v bsg_job->request_payload.sg_cnt, &appplogifail, sizeof(struct auth_complete_cmd)); +/* silent unaligned access warning */ + portid.b.domain = appplogifail.u.d_id.b.domain; + portid.b.area = appplogifail.u.d_id.b.area; + portid.b.al_pa = appplogifail.u.d_id.b.al_pa; +/* * TODO: edif: app has failed this plogi. Inform driver to * take any action (if any).
@@ -788,7 +798,7 @@ qla_edif_app_authfail(scsi_qla_host_t *vSET_DID_STATUS (bsg_reply->result,DID_OK );break ;case PL_TYPE_DID : - fcport =qla2x00_find_fcport_by_pid (vha, &appplogifail.u.d_id); + fcport =qla2x00_find_fcport_by_pid (vha, &portid);if (!fcport) ql_dbg(ql_dbg_edif, vha, 0x911d, "%s d_id lookup failed: %x\n", __func__,
@@ -1253,6 +1263,7 @@ qla24xx_sadb_update(struct bsg_job *bsg_int result =0 ;struct qla_sa_update_frame sa_frame;struct srb_iocb *iocb_cmd; +port_id_t portid;ql_dbg (ql_dbg_edif + ql_dbg_verbose, vha,0x911d ,"%s entered, vha: 0x%p\n" , __func__, vha);
@@ -1276,7 +1287,12 @@ qla24xx_sadb_update(struct bsg_job *bsg_ goto done; } - fcport =qla2x00_find_fcport_by_pid (vha, &sa_frame.port_id); +/* silent unaligned access warning */ + portid.b.domain = sa_frame.port_id.b.domain; + portid.b.area = sa_frame.port_id.b.area; + portid.b.al_pa = sa_frame.port_id.b.al_pa; + + fcport =qla2x00_find_fcport_by_pid (vha, &portid);if (fcport) { found =1 ;if (sa_frame.flags ==QLA_SA_UPDATE_FLAGS_TX_KEY )
Greg Kroah-Hartman
maintainerPATCH 885/1017 scsi: qla2xxx: Fix T10 PI tag escape and IP guard options for 28XX adapters
In reply to Greg Kroah-HartmanFrom: Joe Carnuccio <[email protected]>
commit 4c103a802c69fca63976af6b372ccba39ed74370 upstream.
28XX adapters are capable of detecting both T10 PI tag escape values as well as IP guard. This was missed due to the adapter type missed in the corresponding macros. Fix this by adding support for 28xx in those macros.
--- drivers/scsi/qla2xxx/qla_def.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/scsi/qla2xxx/qla_def.h +4 -2
@@ -4271,8 +4271,10 @@ struct qla_hw_data {#define QLA_ABTS_WAIT_ENABLED (_sp) \ (QLA_NVME_IOS(_sp) && QLA_ABTS_FW_ENABLED(_sp->fcport->vha->hw)) -#define IS_PI_UNINIT_CAPABLE (ha) (IS_QLA83XX(ha) || IS_QLA27XX(ha)) -#define IS_PI_IPGUARD_CAPABLE (ha) (IS_QLA83XX(ha) || IS_QLA27XX(ha)) +#define IS_PI_UNINIT_CAPABLE (ha) (IS_QLA83XX(ha) || IS_QLA27XX(ha) || \ + IS_QLA28XX(ha)) +#define IS_PI_IPGUARD_CAPABLE (ha) (IS_QLA83XX(ha) || IS_QLA27XX(ha) || \ + IS_QLA28XX(ha))#define IS_PI_DIFB_DIX0_CAPABLE (ha) (0)#define IS_PI_SPLIT_DET_CAPABLE_HBA (ha) (IS_QLA83XX(ha) || IS_QLA27XX(ha) || \ IS_QLA28XX(ha))
Greg Kroah-Hartman
maintainerPATCH 886/1017 scsi: qla2xxx: Add devids and conditionals for 28xx
In reply to Greg Kroah-HartmanFrom: Joe Carnuccio <[email protected]>
commit 0d6a536cb1fcabb6c3e9c94871c8d0b29bb5813b upstream.
This is an update to the original 28xx adapter enablement. Add a bunch of conditionals that are applicable for 28xx.
--- drivers/scsi/qla2xxx/qla_attr.c | 7 ++----- drivers/scsi/qla2xxx/qla_init.c | 8 +++----- drivers/scsi/qla2xxx/qla_mbx.c | 14 +++++++++++--- drivers/scsi/qla2xxx/qla_os.c | 3 +-- drivers/scsi/qla2xxx/qla_sup.c | 4 ++-- drivers/scsi/qla2xxx/qla_target.c | 3 +-- 6 files changed, 20 insertions(+), 19 deletions(-)
drivers/scsi/qla2xxx/qla_attr.c +2 -5
@@ -555,7 +555,7 @@ qla2x00_sysfs_read_vpd(struct file *filpif (!capable (CAP_SYS_ADMIN ))return -EINVAL ; -if (IS_NOCACHE_VPD_TYPE (ha)) +if (!IS_NOCACHE_VPD_TYPE (ha)) goto skip; faddr = ha->flt_region_vpd <<2 ;
@@ -745,7 +745,7 @@ qla2x00_sysfs_write_reset(struct file *fql_log (ql_log_info, vha,0x706f ,"Issuing MPI reset.\n" ); -if (IS_QLA83XX (ha) ||IS_QLA27XX (ha) ||IS_QLA28XX (ha)) { +if (IS_QLA83XX (ha)) {uint32_t idc_control;qla83xx_idc_lock (vha,0 );
@@ -1056,9 +1056,6 @@ qla2x00_free_sysfs_attr(scsi_qla_host_tcontinue ;if (iter->type ==3 && !(IS_CNA_CAPABLE (ha)))continue ; -if (iter->type ==0x27 && - (!IS_QLA27XX (ha) || !IS_QLA28XX (ha))) -continue ;sysfs_remove_bin_file (&host->shost_gendev.kobj, iter->attr);
drivers/scsi/qla2xxx/qla_init.c +3 -5
@@ -3492,7 +3492,7 @@ qla2x00_alloc_fw_dump(scsi_qla_host_t *v mem_size = (ha->fw_memory_size -0x11000 +1 ) *sizeof (uint16_t ); }else if (IS_FWI2_CAPABLE (ha)) { -if (IS_QLA83XX (ha) ||IS_QLA27XX (ha) ||IS_QLA28XX (ha)) +if (IS_QLA83XX (ha)) fixed_size = offsetof(struct qla83xx_fw_dump , ext_mem);else if (IS_QLA81XX (ha)) fixed_size = offsetof(struct qla81xx_fw_dump , ext_mem);
@@ -3504,8 +3504,7 @@ qla2x00_alloc_fw_dump(scsi_qla_host_t *v mem_size = (ha->fw_memory_size -0x100000 +1 ) *sizeof (uint32_t );if (ha->mqenable) { -if (!IS_QLA83XX (ha) && !IS_QLA27XX (ha) && - !IS_QLA28XX (ha)) +if (!IS_QLA83XX (ha)) mq_size =sizeof (struct qla2xxx_mq_chain );/* * Allocate maximum buffer size for all queues - Q0.
@@ -4066,8 +4065,7 @@ enable_82xx_npiv: ha->fw_major_version, ha->fw_minor_version, ha->fw_subminor_version); -if (IS_QLA83XX (ha) ||IS_QLA27XX (ha) || -IS_QLA28XX (ha)) { +if (IS_QLA83XX (ha)) { ha->flags.fac_supported =0 ; rval =QLA_SUCCESS ; }
drivers/scsi/qla2xxx/qla_mbx.c +11 -3
@@ -9,6 +9,12 @@#include <linux/delay.h> #include <linux/gfp.h> +#ifdef CONFIG_PPC +#define IS_PPCARCH true +#else +#define IS_PPCARCH false +#endif + static struct mb_cmd_name { uint16_t cmd; const char *str;
@@ -728,6 +734,9 @@ again: vha->min_supported_speed = nv->min_supported_speed; } + +if (IS_PPCARCH ) + mcp->mb[11 ] |=BIT_4 ; }if (ha->flags.exlogins_enabled)
@@ -3029,8 +3038,7 @@ qla2x00_get_resource_cnts(scsi_qla_host_ ha->orig_fw_iocb_count = mcp->mb[10 ];if (ha->flags.npiv_supported) ha->max_npiv_vports = mcp->mb[11 ]; -if (IS_QLA81XX (ha) ||IS_QLA83XX (ha) ||IS_QLA27XX (ha) || -IS_QLA28XX (ha)) +if (IS_QLA81XX (ha) ||IS_QLA83XX (ha)) ha->fw_max_fcf_count = mcp->mb[12 ]; }
@@ -5621,7 +5629,7 @@ qla2x00_get_data_rate(scsi_qla_host_t *v mcp->out_mb =MBX_1 |MBX_0 ; mcp->in_mb =MBX_2 |MBX_1 |MBX_0 ;if (IS_QLA83XX (ha) ||IS_QLA27XX (ha) ||IS_QLA28XX (ha)) - mcp->in_mb |=MBX_3 ; + mcp->in_mb |=MBX_4 |MBX_3 ; mcp->tov =MBX_TOV_SECONDS ; mcp->flags =0 ; rval =qla2x00_mailbox_command (vha, mcp);
drivers/scsi/qla2xxx/qla_os.c +1 -2
@@ -3754,8 +3754,7 @@ qla2x00_unmap_iobases(struct qla_hw_dataif (ha->mqiobase)iounmap (ha->mqiobase); -if ((IS_QLA83XX (ha) ||IS_QLA27XX (ha) ||IS_QLA28XX (ha)) && - ha->msixbase) +if (ha->msixbase)iounmap (ha->msixbase); } }
drivers/scsi/qla2xxx/qla_sup.c +2 -2
@@ -844,7 +844,7 @@ qla2xxx_get_flt_info(scsi_qla_host_t *vh ha->flt_region_nvram = start;break ;case FLT_REG_IMG_PRI_27XX : -if (IS_QLA27XX (ha) && !IS_QLA28XX (ha)) +if (IS_QLA27XX (ha) ||IS_QLA28XX (ha)) ha->flt_region_img_status_pri = start;break ;case FLT_REG_IMG_SEC_27XX :
@@ -1356,7 +1356,7 @@ next: flash_data_addr(ha, faddr), le32_to_cpu(*dwptr));if (ret) {ql_dbg (ql_dbg_user, vha,0x7006 , -"Failed slopw write %x (%x)\n" , faddr, *dwptr); +"Failed slow write %x (%x)\n" , faddr, *dwptr);break ; } }
drivers/scsi/qla2xxx/qla_target.c +1 -2
@@ -7220,8 +7220,7 @@ qlt_probe_one_stage1(struct scsi_qla_hosif (!QLA_TGT_MODE_ENABLED ())return ; -if ((ql2xenablemsix ==0 ) ||IS_QLA83XX (ha) ||IS_QLA27XX (ha) || -IS_QLA28XX (ha)) { +if (ha->mqenable ||IS_QLA83XX (ha) ||IS_QLA27XX (ha) ||IS_QLA28XX (ha)) {ISP_ATIO_Q_IN (base_vha) = &ha->mqiobase->isp25mq.atio_q_in;ISP_ATIO_Q_OUT (base_vha) = &ha->mqiobase->isp25mq.atio_q_out; }else {
Greg Kroah-Hartman
maintainerPATCH 887/1017 scsi: qla2xxx: Check for firmware dump already collected
In reply to Greg Kroah-HartmanFrom: Joe Carnuccio <[email protected]>
commit cfbafad7c6032d449a5a07f2d273acd2437bbc6a upstream.
While allocating firmware dump, check if dump is already collected and do not re-allocate the buffer.
--- drivers/scsi/qla2xxx/qla_init.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/scsi/qla2xxx/qla_init.c +8 -0
@@ -3482,6 +3482,14 @@ qla2x00_alloc_fw_dump(scsi_qla_host_t *vstruct rsp_que *rsp = ha->rsp_q_map[0 ];struct qla2xxx_fw_dump *fw_dump; +if (ha->fw_dump) { +ql_dbg (ql_dbg_init, vha,0x00bd , +"Firmware dump already allocated.\n" ); +return ; + } + + ha->fw_dumped =0 ; + ha->fw_dump_cap_flags =0 ; dump_size = fixed_size = mem_size = eft_size = fce_size = mq_size =0 ; req_q_size = rsp_q_size =0 ;
Greg Kroah-Hartman
maintainerPATCH 888/1017 scsi: qla2xxx: Suppress a kernel complaint in qla_create_qpair()
In reply to Greg Kroah-HartmanFrom: Saurav Kashyap <[email protected]>
commit a60447e7d451df42c7bde43af53b34f10f34f469 upstream.
[ 12.323788] BUG: using smp_processor_id() in preemptible [00000000] code: systemd-udevd/1020 [ 12.332297] caller is qla2xxx_create_qpair+0x32a/0x5d0 [qla2xxx] [ 12.338417] CPU: 7 PID: 1020 Comm: systemd-udevd Tainted: G I --------- --- 5.14.0-29.el9.x86_64 #1 [ 12.348827] Hardware name: Dell Inc. PowerEdge R610/0F0XJ6, BIOS 6.6.0 05/22/2018 [ 12.356356] Call Trace: [ 12.358821] dump_stack_lvl+0x34/0x44 [ 12.362514] check_preemption_disabled+0xd9/0xe0 [ 12.367164] qla2xxx_create_qpair+0x32a/0x5d0 [qla2xxx] [ 12.372481] qla2x00_probe_one+0xa3a/0x1b80 [qla2xxx] [ 12.377617] ? _raw_spin_lock_irqsave+0x19/0x40 [ 12.384284] local_pci_probe+0x42/0x80 [ 12.390162] ? pci_match_device+0xd7/0x110 [ 12.396366] pci_device_probe+0xfd/0x1b0 [ 12.402372] really_probe+0x1e7/0x3e0 [ 12.408114] __driver_probe_device+0xfe/0x180 [ 12.414544] driver_probe_device+0x1e/0x90 [ 12.420685] __driver_attach+0xc0/0x1c0 [ 12.426536] ? __device_attach_driver+0xe0/0xe0 [ 12.433061] ? __device_attach_driver+0xe0/0xe0 [ 12.439538] bus_for_each_dev+0x78/0xc0 [ 12.445294] bus_add_driver+0x12b/0x1e0 [ 12.451021] driver_register+0x8f/0xe0 [ 12.456631] ? 0xffffffffc07bc000 [ 12.461773] qla2x00_module_init+0x1be/0x229 [qla2xxx] [ 12.468776] do_one_initcall+0x44/0x200 [ 12.474401] ? load_module+0xad3/0xba0 [ 12.479908] ? kmem_cache_alloc_trace+0x45/0x410 [ 12.486268] do_init_module+0x5c/0x280 [ 12.491730] __do_sys_init_module+0x12e/0x1b0 [ 12.497785] do_syscall_64+0x3b/0x90 [ 12.503029] entry_SYSCALL_64_after_hwframe+0x44/0xae [ 12.509764] RIP: 0033:0x7f554f73ab2e
--- drivers/scsi/qla2xxx/qla_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_init.c +1 -1
@@ -9417,7 +9417,7 @@ struct qla_qpair *qla2xxx_create_qpair(s qpair->rsp->req = qpair->req; qpair->rsp->qpair = qpair;/* init qpair to this cpu. Will adjust at run time. */ -qla_cpu_update (qpair,smp_processor_id ()); +qla_cpu_update (qpair,raw_smp_processor_id ());if (IS_T10_PI_CAPABLE (ha) && ql2xenabledif) {if (ha->fw_attributes &BIT_4 )
Greg Kroah-Hartman
maintainerPATCH 889/1017 scsi: qla2xxx: Fix disk failure to rediscover
In reply to Greg Kroah-HartmanFrom: Quinn Tran <[email protected]>
commit 6a45c8e137d4e2c72eecf1ac7cf64f2fdfcead99 upstream.
User experienced some of the LUN failed to get rediscovered after long cable pull test. The issue is triggered by a race condition between driver setting session online state vs starting the LUN scan process at the same time. Current code set the online state after notifying the session is available. In this case, trigger to start the LUN scan process happened before driver could set the session in online state. LUN scan ends up with failure due to the session online check was failing.
Set the online state before reporting of the availability of the session.
--- drivers/scsi/qla2xxx/qla_init.c | 5 +++-- drivers/scsi/qla2xxx/qla_nvme.c | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-)
drivers/scsi/qla2xxx/qla_init.c +3 -2
@@ -5758,6 +5758,8 @@ qla2x00_reg_remote_port(scsi_qla_host_tif (atomic_read (&fcport->state) ==FCS_ONLINE )return ; +qla2x00_set_fcport_state (fcport,FCS_ONLINE ); + rport_ids.node_name =wwn_to_u64 (fcport->node_name); rport_ids.port_name =wwn_to_u64 (fcport->port_name); rport_ids.port_id = fcport->d_id.b.domain << 16 |
@@ -5865,6 +5867,7 @@ qla2x00_update_fcport(scsi_qla_host_t *vqla2x00_reg_remote_port (vha, fcport);break ;case MODE_TARGET : +qla2x00_set_fcport_state (fcport,FCS_ONLINE );if (!vha->vha_tgt.qla_tgt->tgt_stop && !vha->vha_tgt.qla_tgt->tgt_stopped)qlt_fc_port_added (vha, fcport);
@@ -5879,8 +5882,6 @@ qla2x00_update_fcport(scsi_qla_host_t *vbreak ; } -qla2x00_set_fcport_state (fcport,FCS_ONLINE ); -if (IS_IIDMA_CAPABLE (vha->hw) && vha->hw->flags.gpsc_supported) {if (fcport->id_changed) { fcport->id_changed =0 ;
drivers/scsi/qla2xxx/qla_nvme.c +5 -0
@@ -37,6 +37,11 @@ int qla_nvme_register_remote(struct scsi (fcport->nvme_flag & NVME_FLAG_REGISTERED))return 0 ; +if (atomic_read (&fcport->state) ==FCS_ONLINE ) +return 0 ; + +qla2x00_set_fcport_state (fcport,FCS_ONLINE ); + fcport->nvme_flag &= ~NVME_FLAG_RESETTING ;memset (&req,0 ,sizeof (struct nvme_fc_port_info ));
Greg Kroah-Hartman
maintainerPATCH 890/1017 scsi: qla2xxx: Fix incorrect reporting of task management failure
In reply to Greg Kroah-HartmanFrom: Quinn Tran <[email protected]>
commit 58ca5999e0367d131de82a75257fbfd5aed0195d upstream.
User experienced no task management error while target device is responding with error. The RSP_CODE field in the status IOCB is in little endian. Driver assumes it's big endian and it picked up erroneous data.
Convert the data back to big endian as is on the wire.
--- drivers/scsi/qla2xxx/qla_isr.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/qla2xxx/qla_isr.c +1 -0
@@ -2498,6 +2498,7 @@ qla24xx_tm_iocb_entry(scsi_qla_host_t *v iocb->u.tmf.data =QLA_FUNCTION_FAILED ; }else if ((le16_to_cpu (sts->scsi_status) &SS_RESPONSE_INFO_LEN_VALID )) { +host_to_fcp_swap (sts->data,sizeof (sts->data));if (le32_to_cpu (sts->rsp_data_len) <4 ) { ql_log(ql_log_warn, fcport->vha, 0x503b, "Async-%s error - hdl=%x not enough response(%d).\n",
Greg Kroah-Hartman
maintainerPATCH 891/1017 scsi: qla2xxx: Fix hang due to session stuck
In reply to Greg Kroah-HartmanFrom: Quinn Tran <[email protected]>
commit c02aada06d19a215c8291bd968a99a270e96f734 upstream.
User experienced device lost. The log shows Get port data base command was queued up, failed, and requeued again. Every time it is requeued, it set the FCF_ASYNC_ACTIVE. This prevents any recovery code from occurring because driver thinks a recovery is in progress for this session. In essence, this session is hung. The reason it gets into this place is the session deletion got in front of this call due to link perturbation.
Break the requeue cycle and exit. The session deletion code will trigger a session relogin.
--- drivers/scsi/qla2xxx/qla_def.h | 4 ++++ drivers/scsi/qla2xxx/qla_init.c | 19 +++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-)
drivers/scsi/qla2xxx/qla_def.h +4 -0
@@ -5438,4 +5438,8 @@ struct ql_vnd_tgt_stats_resp {#include "qla_gbl.h" #include "qla_dbg.h" #include "qla_inline.h" + +#define IS_SESSION_DELETED (_fcport) (_fcport->disc_state == DSC_DELETE_PEND || \ + _fcport->disc_state == DSC_DELETED) +#endif
drivers/scsi/qla2xxx/qla_init.c +17 -2
@@ -575,6 +575,14 @@ qla2x00_async_adisc(struct scsi_qla_hoststruct srb_iocb *lio;int rval =QLA_FUNCTION_FAILED ; +if (IS_SESSION_DELETED (fcport)) { +ql_log (ql_log_warn, vha,0xffff , +"%s: %8phC is being delete - not sending command.\n" , + __func__, fcport->port_name); + fcport->flags &= ~FCF_ASYNC_ACTIVE ; +return rval; + } +if (!vha->flags.online || (fcport->flags &FCF_ASYNC_SENT ))return rval;
@@ -1338,8 +1346,15 @@ int qla24xx_async_gpdb(struct scsi_qla_hstruct port_database_24xx *pd;struct qla_hw_data *ha = vha->hw; -if (!vha->flags.online || (fcport->flags &FCF_ASYNC_SENT ) || - fcport->loop_id ==FC_NO_LOOP_ID ) { +if (IS_SESSION_DELETED (fcport)) { +ql_log (ql_log_warn, vha,0xffff , +"%s: %8phC is being delete - not sending command.\n" , + __func__, fcport->port_name); + fcport->flags &= ~FCF_ASYNC_ACTIVE ; +return rval; + } + +if (!vha->flags.online || fcport->flags &FCF_ASYNC_SENT ) {ql_log (ql_log_warn, vha,0xffff ,"%s: %8phC online %d flags %x - not sending command.\n" , __func__, fcport->port_name, vha->flags.online, fcport->flags);
Greg Kroah-Hartman
maintainerPATCH 892/1017 scsi: qla2xxx: Fix laggy FC remote port session recovery
In reply to Greg Kroah-HartmanFrom: Quinn Tran <[email protected]>
commit 713b415726f100f6644971e75ebfe1edbef1a390 upstream.
For session recovery, driver relies on the dpc thread to initiate certain operations. The dpc thread runs exclusively without the Mailbox interface being occupied. A recent code change for heartbeat check via mailbox cmd 0 is preventing the dpc thread from carrying out its operation. This patch allows the higher priority error recovery to run first before running the lower priority heartbeat check.
--- drivers/scsi/qla2xxx/qla_def.h | 1 + drivers/scsi/qla2xxx/qla_os.c | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-)
drivers/scsi/qla2xxx/qla_def.h +1 -0
@@ -4621,6 +4621,7 @@ struct qla_hw_data {struct workqueue_struct *wq;struct work_struct heartbeat_work;struct qlfc_fw fw_buf; +unsigned long last_heartbeat_run_jiffies;/* FCP_CMND priority support */ struct qla_fcp_prio_cfg *fcp_prio_cfg;
drivers/scsi/qla2xxx/qla_os.c +17 -3
@@ -7209,7 +7209,7 @@ skip:return do_heartbeat; } -static void qla_heart_beat (struct scsi_qla_host *vha) +static void qla_heart_beat (struct scsi_qla_host *vha,u16 dpc_started) {struct qla_hw_data *ha = vha->hw;
@@ -7219,8 +7219,19 @@ static void qla_heart_beat(struct scsi_qif (vha->hw->flags.eeh_busy ||qla2x00_chip_is_down (vha))return ; -if (qla_do_heartbeat (vha)) +/* +* dpc thread cannot run if heartbeat is running at the same time. +* We also do not want to starve heartbeat task. Therefore, do +* heartbeat task at least once every 5 seconds. +*/ +if (dpc_started && +time_before (jiffies, ha->last_heartbeat_run_jiffies +5 *HZ )) +return ; + +if (qla_do_heartbeat (vha)) { + ha->last_heartbeat_run_jiffies = jiffies;queue_work (ha->wq, &ha->heartbeat_work); + } }/**************************************************************************
@@ -7411,6 +7422,8 @@ qla2x00_timer(struct timer_list *t) start_dpc++; } +/* borrowing w to signify dpc will run */ + w =0 ;/* Schedule the DPC routine if needed */ if ((test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) || test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags) ||
@@ -7443,9 +7456,10 @@ qla2x00_timer(struct timer_list *t)test_bit (RELOGIN_NEEDED , &vha->dpc_flags), test_bit(PROCESS_PUREX_IOCB, &vha->dpc_flags));qla2xxx_wake_dpc (vha); + w =1 ; } -qla_heart_beat (vha); +qla_heart_beat (vha, w);qla2x00_restart_timer (vha,WATCH_INTERVAL ); }
Greg Kroah-Hartman
maintainerPATCH 893/1017 scsi: qla2xxx: Fix missed DMA unmap for NVMe ls requests
In reply to Greg Kroah-HartmanFrom: Arun Easi <[email protected]>
commit c85ab7d9e27a80e48d5b7d7fb2fe2b0fdb2de523 upstream.
At NVMe ELS request time, request structure is DMA mapped and never unmapped. Fix this by calling the unmap on ELS completion.
--- drivers/scsi/qla2xxx/qla_nvme.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/scsi/qla2xxx/qla_nvme.c +17 -0
@@ -172,6 +172,18 @@ out:qla2xxx_rel_qpair_sp (sp->qpair, sp); } +static void qla_nvme_ls_unmap (struct srb *sp,struct nvmefc_ls_req *fd) +{ +if (sp->flags &SRB_DMA_VALID ) { +struct srb_iocb *nvme = &sp->u.iocb_cmd; +struct qla_hw_data *ha = sp->fcport->vha->hw; + +dma_unmap_single (&ha->pdev->dev, nvme->u.nvme.cmd_dma, + fd->rqstlen,DMA_TO_DEVICE ); + sp->flags &= ~SRB_DMA_VALID ; + } +} +static void qla_nvme_release_ls_cmd_kref (struct kref *kref) { struct srb *sp = container_of(kref, struct srb, cmd_kref);
@@ -188,6 +200,8 @@ static void qla_nvme_release_ls_cmd_krefspin_unlock_irqrestore (&priv->cmd_lock, flags); fd = priv->fd; + +qla_nvme_ls_unmap (sp, fd); fd->done (fd, priv->comp_status); out:qla2x00_rel_sp (sp);
@@ -358,6 +372,8 @@ static int qla_nvme_ls_req(struct nvme_fdma_sync_single_for_device (&ha->pdev->dev, nvme->u.nvme.cmd_dma, fd->rqstlen,DMA_TO_DEVICE ); + sp->flags |=SRB_DMA_VALID ; + rval =qla2x00_start_sp (sp);if (rval !=QLA_SUCCESS ) { ql_log(ql_log_warn, vha, 0x700e,
@@ -365,6 +381,7 @@ static int qla_nvme_ls_req(struct nvme_fwake_up (&sp->nvme_ls_waitq); sp->priv =NULL ; priv->sp =NULL ; +qla_nvme_ls_unmap (sp, fd);qla2x00_rel_sp (sp);return rval; }
Greg Kroah-Hartman
maintainerPATCH 894/1017 scsi: qla2xxx: Fix crash during module load unload test
In reply to Greg Kroah-HartmanFrom: Arun Easi <[email protected]>
commit 0972252450f90db56dd5415a20e2aec21a08d036 upstream.
During purex packet handling the driver was incorrectly freeing a pre-allocated structure. Fix this by skipping that entry.
System crashed with the following stack during a module unload test.
Call Trace: sbitmap_init_node+0x7f/0x1e0 sbitmap_queue_init_node+0x24/0x150 blk_mq_init_bitmaps+0x3d/0xa0 blk_mq_init_tags+0x68/0x90 blk_mq_alloc_map_and_rqs+0x44/0x120 blk_mq_alloc_set_map_and_rqs+0x63/0x150 blk_mq_alloc_tag_set+0x11b/0x230 scsi_add_host_with_dma.cold+0x3f/0x245 qla2x00_probe_one+0xd5a/0x1b80 [qla2xxx]
Call Trace with slub_debug and debug kernel:
kasan_report_invalid_free+0x50/0x80 __kasan_slab_free+0x137/0x150 slab_free_freelist_hook+0xc6/0x190 kfree+0xe8/0x2e0 qla2x00_free_device+0x3bb/0x5d0 [qla2xxx] qla2x00_remove_one+0x668/0xcf0 [qla2xxx]
--- drivers/scsi/qla2xxx/qla_os.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/scsi/qla2xxx/qla_os.c +2 -0
@@ -3896,6 +3896,8 @@ qla24xx_free_purex_list(struct purex_lisspin_lock_irqsave (&list->lock, flags);list_for_each_entry_safe (item, next, &list->head, list) {list_del (&item->list); +if (item == &item->vha->default_item) +continue ;kfree (item); }spin_unlock_irqrestore (&list->lock, flags);
Greg Kroah-Hartman
maintainerPATCH 895/1017 scsi: qla2xxx: Fix N2N inconsistent PLOGI
In reply to Greg Kroah-HartmanFrom: Quinn Tran <[email protected]>
commit c13ce47c64ea8f14e77eecb40d1e7c2ac667f898 upstream.
For N2N topology, ELS Passthrough is used to send PLOGI. On failure of ELS pass through PLOGI, driver flipped over to using LLIOCB PLOGI for N2N. This is not consistent. Delete the session to restart the connection where ELS pass through PLOGI would be used consistently.
--- drivers/scsi/qla2xxx/qla_iocb.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/scsi/qla2xxx/qla_iocb.c +3 -5
@@ -2943,6 +2943,7 @@ static void qla2x00_els_dcmd2_sp_done(srset_bit (ISP_ABORT_NEEDED , &vha->dpc_flags);qla2xxx_wake_dpc (vha); +break ; } fallthrough;default :
@@ -2952,9 +2953,7 @@ static void qla2x00_els_dcmd2_sp_done(sr fw_status[0], fw_status[1], fw_status[2]); fcport->flags &= ~FCF_ASYNC_SENT ; -qla2x00_set_fcport_disc_state (fcport, -DSC_LOGIN_FAILED ); -set_bit (RELOGIN_NEEDED , &vha->dpc_flags); +qlt_schedule_sess_for_deletion (fcport);break ; }break ;
@@ -2966,8 +2965,7 @@ static void qla2x00_els_dcmd2_sp_done(sr fw_status[0], fw_status[1], fw_status[2]); sp->fcport->flags &= ~FCF_ASYNC_SENT ; -qla2x00_set_fcport_disc_state (fcport,DSC_LOGIN_FAILED ); -set_bit (RELOGIN_NEEDED , &vha->dpc_flags); +qlt_schedule_sess_for_deletion (fcport);break ; }
Greg Kroah-Hartman
maintainerPATCH 896/1017 scsi: qla2xxx: Fix stuck session of PRLI reject
In reply to Greg Kroah-HartmanFrom: Quinn Tran <[email protected]>
commit f3502e2e98a92981601edc3dadf4b0f43c79836b upstream.
Remove stale recovery code that prevents normal path recovery.
--- drivers/scsi/qla2xxx/qla_init.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/scsi/qla2xxx/qla_init.c +0 -7
@@ -2104,13 +2104,6 @@ qla24xx_handle_prli_done_event(struct scqla24xx_post_gpdb_work (vha, ea->fcport,0 );break ;default : -if ((ea->iop[0 ] ==LSC_SCODE_ELS_REJECT ) && - (ea->iop[1 ] ==0x50000 )) {/* reson 5=busy expl:0x0 */ -set_bit (RELOGIN_NEEDED , &vha->dpc_flags); - ea->fcport->fw_login_state =DSC_LS_PLOGI_COMP ; -break ; - } - sp = ea->sp; ql_dbg(ql_dbg_disc, vha, 0x2118, "%s %d %8phC priority %s, fc4type %x prev try %s\n",
Greg Kroah-Hartman
maintainerPATCH 897/1017 scsi: qla2xxx: Reduce false trigger to login
In reply to Greg Kroah-HartmanFrom: Quinn Tran <[email protected]>
commit d2646eed7b19a206912f49101178cbbaa507256c upstream.
While a session is in the middle of a relogin, a late RSCN can be delivered from switch. RSCN trigger fabric scan where the scan logic can trigger another session login while a login is in progress. Reduce the extra trigger to prevent multiple logins to the same session.
--- drivers/scsi/qla2xxx/qla_init.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/scsi/qla2xxx/qla_init.c +3 -2
@@ -1644,7 +1644,8 @@ int qla24xx_fcport_handle_login(struct s fcport->login_gen, fcport->loop_id, fcport->scan_state, fcport->fc4_type); -if (fcport->scan_state !=QLA_FCPORT_FOUND ) +if (fcport->scan_state !=QLA_FCPORT_FOUND || + fcport->disc_state ==DSC_DELETE_PEND )return 0 ; if ((fcport->loop_id != FC_NO_LOOP_ID) &&
@@ -1665,7 +1666,7 @@ int qla24xx_fcport_handle_login(struct sif (vha->host->active_mode ==MODE_TARGET && !N2N_TOPO (vha->hw))return 0 ; -if (fcport->flags &FCF_ASYNC_SENT ) { +if (fcport->flags & (FCF_ASYNC_SENT |FCF_ASYNC_ACTIVE )) {set_bit (RELOGIN_NEEDED , &vha->dpc_flags);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 898/1017 scsi: qla2xxx: Use correct feature type field during RFF_ID processing
In reply to Greg Kroah-HartmanFrom: Manish Rangankar <[email protected]>
commit a7e05f7a1bcbe4ee055479242de46c5c16ab03b1 upstream.
During SNS Register FC-4 Features (RFF_ID) the initiator driver was sending incorrect type field for NVMe supported device. Use correct feature type field.
--- drivers/scsi/qla2xxx/qla_gs.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/scsi/qla2xxx/qla_gs.c +2 -3
@@ -676,8 +676,7 @@ qla2x00_rff_id(scsi_qla_host_t *vha, u8return (QLA_SUCCESS ); } -return qla_async_rffid (vha, &vha->d_id,qlt_rff_id (vha), -FC4_TYPE_FCP_SCSI ); +return qla_async_rffid (vha, &vha->d_id,qlt_rff_id (vha), type); } static int qla_async_rffid(scsi_qla_host_t *vha, port_id_t *d_id,
@@ -729,7 +728,7 @@ static int qla_async_rffid(scsi_qla_host/* Prepare CT arguments -- port_id, FC-4 feature, FC-4 type */ ct_req->req.rff_id.port_id =port_id_to_be_id (*d_id); ct_req->req.rff_id.fc4_feature = fc4feature; - ct_req->req.rff_id.fc4_type = fc4type;/* SCSI - FCP */ + ct_req->req.rff_id.fc4_type = fc4type;/* SCSI-FCP or FC-NVMe */ sp->u.iocb_cmd.u.ctarg.req_size =RFF_ID_REQ_SIZE ; sp->u.iocb_cmd.u.ctarg.rsp_size =RFF_ID_RSP_SIZE ;
Greg Kroah-Hartman
maintainerPATCH 899/1017 platform: chrome: Split trace include file
In reply to Greg Kroah-HartmanFrom: Gwendal Grignou <[email protected]>
commit eabd9a3807e17e211690e6c40f1405b427b64c48 upstream.
cros_ec_trace.h defined 5 tracing events, 2 for cros_ec_proto and 3 for cros_ec_sensorhub_ring.
These 2 files are in different kernel modules, the traces are defined twice in the kernel which leads to problem enabling only some traces.
Move sensorhub traces from cros_ec_trace.h to cros_ec_sensorhub_trace.h and enable them only in cros_ec_sensorhub kernel module.
Check we can now enable any single traces: without this patch, we can only enable all sensorhub traces or none.
--- drivers/platform/chrome/Makefile | 3 drivers/platform/chrome/cros_ec_sensorhub_ring.c | 3 drivers/platform/chrome/cros_ec_sensorhub_trace.h | 123 ++++++++++++++++++++++ drivers/platform/chrome/cros_ec_trace.h | 95 ---------------- 4 files changed, 127 insertions(+), 97 deletions(-) create mode 100644 drivers/platform/chrome/cros_ec_sensorhub_trace.h
drivers/platform/chrome/Makefile +2 -1
@@ -2,6 +2,7 @@ # tell define_trace.h where to find the cros ec trace header CFLAGS_cros_ec_trace.o:= -I$(src) +CFLAGS_cros_ec_sensorhub_ring.o:= -I$(src) obj-$(CONFIG_CHROMEOS_LAPTOP) += chromeos_laptop.o obj-$(CONFIG_CHROMEOS_PSTORE) += chromeos_pstore.o
@@ -20,7 +21,7 @@ obj-$(CONFIG_CROS_EC_CHARDEV) += cros_e obj-$(CONFIG_CROS_EC_LIGHTBAR) += cros_ec_lightbar.o obj-$(CONFIG_CROS_EC_VBC) += cros_ec_vbc.o obj-$(CONFIG_CROS_EC_DEBUGFS) += cros_ec_debugfs.o -cros-ec-sensorhub-objs := cros_ec_sensorhub.o cros_ec_sensorhub_ring.o cros_ec_trace.o +cros-ec-sensorhub-objs := cros_ec_sensorhub.o cros_ec_sensorhub_ring.o obj-$(CONFIG_CROS_EC_SENSORHUB) += cros-ec-sensorhub.o obj-$(CONFIG_CROS_EC_SYSFS) += cros_ec_sysfs.o obj-$(CONFIG_CROS_USBPD_LOGGER) += cros_usbpd_logger.o
drivers/platform/chrome/cros_ec_sensorhub_ring.c +2 -1
@@ -17,7 +17,8 @@#include <linux/sort.h> #include <linux/slab.h> -#include "cros_ec_trace.h" +#define CREATE_TRACE_POINTS +#include "cros_ec_sensorhub_trace.h" /* Precision of fixed point for the m values from the filter */ #define M_PRECISION BIT(23)
drivers/platform/chrome/cros_ec_sensorhub_trace.h new file +123 -0
123 lines not on this page · raw message
drivers/platform/chrome/cros_ec_trace.h +0 -95
107 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 900/1017 MIPS: crypto: Fix CRC32 code
In reply to Greg Kroah-HartmanFrom: Paul Cercueil <[email protected]>
commit 41022eff9c2d21e658c7a6fcd31005bf514d28b7 upstream.
Commit 67512a8cf5a7 ("MIPS: Avoid macro redefinitions") changed how the MIPS register macros were defined, in order to allow the code to compile under LLVM/Clang.
The MIPS CRC32 code however wasn't updated accordingly, causing a build bug when using a MIPS32r6 toolchain without CRC support.
Update the CRC32 code to use the macros correctly, to fix the build failures.
--- arch/mips/crypto/crc32-mips.c | 46 +++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 20 deletions(-)
arch/mips/crypto/crc32-mips.c +26 -20
@@ -28,7 +28,7 @@ enum crc_type { };#ifndef TOOLCHAIN_SUPPORTS_CRC -#define _ASM_MACRO_CRC32 (OP ,SZ ,TYPE ) \ +#define _ASM_SET_CRC (OP ,SZ ,TYPE ) \ _ASM_MACRO_3R(OP, rt, rs, rt2, \ ".ifnc \\rt, \\rt2\n\t" \ ".error \"invalid operands \\\"" #OP " \\rt,\\rs,\\rt2\\\"\"\n\t" \
@@ -37,30 +37,36 @@ _ASM_MACRO_3R(OP, rt, rs, rt2, \ ((SZ) << 6) | ((TYPE) << 8)) \ _ASM_INSN32_IF_MM(0x00000030 | (__rs << 16) | (__rt << 21) | \ ((SZ) << 14) | ((TYPE) << 3))) -_ASM_MACRO_CRC32 (crc32b,0 ,0 ); -_ASM_MACRO_CRC32 (crc32h,1 ,0 ); -_ASM_MACRO_CRC32 (crc32w,2 ,0 ); -_ASM_MACRO_CRC32 (crc32d,3 ,0 ); -_ASM_MACRO_CRC32 (crc32cb,0 ,1 ); -_ASM_MACRO_CRC32 (crc32ch,1 ,1 ); -_ASM_MACRO_CRC32 (crc32cw,2 ,1 ); -_ASM_MACRO_CRC32 (crc32cd,3 ,1 ); -#define _ASM_SET_CRC "" +#define _ASM_UNSET_CRC (op,SZ ,TYPE ) ".purgem " #op "\n\t"#else /* !TOOLCHAIN_SUPPORTS_CRC */ -#define _ASM_SET_CRC ".set\tcrc\n\t" +#define _ASM_SET_CRC (op,SZ ,TYPE ) ".set\tcrc\n\t" +#define _ASM_UNSET_CRC (op,SZ ,TYPE )#endif -#define _CRC32 (crc, value, size, type) \ -do { \ - __asm__ __volatile__( \ - ".set push\n\t" \ - _ASM_SET_CRC \ - #type #size " %0, %1, %0\n\t" \ - ".set pop" \ - : "+r" (crc) \ - : "r" (value)); \ +#define __CRC32 (crc, value, op,SZ ,TYPE ) \ +do { \ + __asm__ __volatile__( \ + ".set push\n\t" \ + _ASM_SET_CRC(op, SZ, TYPE) \ + #op " %0, %1, %0\n\t" \ + _ASM_UNSET_CRC(op, SZ, TYPE) \ + ".set pop" \ + : "+r" (crc) \ + : "r" (value)); \ } while (0) +#define _CRC32_crc32b (crc, value) __CRC32(crc, value, crc32b, 0, 0) +#define _CRC32_crc32h (crc, value) __CRC32(crc, value, crc32h, 1, 0) +#define _CRC32_crc32w (crc, value) __CRC32(crc, value, crc32w, 2, 0) +#define _CRC32_crc32d (crc, value) __CRC32(crc, value, crc32d, 3, 0) +#define _CRC32_crc32cb (crc, value) __CRC32(crc, value, crc32cb, 0, 1) +#define _CRC32_crc32ch (crc, value) __CRC32(crc, value, crc32ch, 1, 1) +#define _CRC32_crc32cw (crc, value) __CRC32(crc, value, crc32cw, 2, 1) +#define _CRC32_crc32cd (crc, value) __CRC32(crc, value, crc32cd, 3, 1) + +#define _CRC32 (crc, value, size, op) \ + _CRC32_##op##size(crc, value) +#define CRC32 (crc, value, size) \ _CRC32(crc, value, size, crc32)
Greg Kroah-Hartman
maintainerPATCH 901/1017 KVM: x86: Check lapic_in_kernel() before attempting to set a SynIC irq
In reply to Greg Kroah-HartmanFrom: Vitaly Kuznetsov <[email protected]>
commit 7ec37d1cbe17d8189d9562178d8b29167fe1c31a upstream.
When KVM_CAP_HYPERV_SYNIC{,2} is activated, KVM already checks for irqchip_in_kernel() so normally SynIC irqs should never be set. It is, however, possible for a misbehaving VMM to write to SYNIC/STIMER MSRs causing erroneous behavior.
The immediate issue being fixed is that kvm_irq_delivery_to_apic() (kvm_irq_delivery_to_apic_fast()) crashes when called with 'irq.shorthand = APIC_DEST_SELF' and 'src == NULL'.
Message-Id: <[email protected]>
--- arch/x86/kvm/hyperv.c | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/kvm/hyperv.c +3 -0
@@ -446,6 +446,9 @@ static int synic_set_irq(struct kvm_vcpustruct kvm_lapic_irq irq;int ret, vector; +if (KVM_BUG_ON (!lapic_in_kernel (vcpu), vcpu->kvm)) +return -EINVAL ; +if (sint >=ARRAY_SIZE (synic->sint))return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 902/1017 KVM: x86: Avoid theoretical NULL pointer dereference in kvm_irq_delivery_to_apic_fast()
In reply to Greg Kroah-HartmanFrom: Vitaly Kuznetsov <[email protected]>
commit 00b5f37189d24ac3ed46cb7f11742094778c46ce upstream.
When kvm_irq_delivery_to_apic_fast() is called with APIC_DEST_SELF shorthand, 'src' must not be NULL. Crash the VM with KVM_BUG_ON() instead of crashing the host.
Message-Id: <[email protected]>
--- arch/x86/kvm/lapic.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/x86/kvm/lapic.c +4 -0
@@ -987,6 +987,10 @@ bool kvm_irq_delivery_to_apic_fast(struc *r =-1 ;if (irq->shorthand ==APIC_DEST_SELF ) { +if (KVM_BUG_ON (!src, kvm)) { + *r =0 ; +return true; + } *r =kvm_apic_set_irq (src->vcpu, irq, dest_map);return true; }
Greg Kroah-Hartman
maintainerPATCH 903/1017 KVM: x86: Forbid VMM to set SYNIC/STIMER MSRs when SynIC wasnt activated
In reply to Greg Kroah-HartmanFrom: Vitaly Kuznetsov <[email protected]>
commit b1e34d325397a33d97d845e312d7cf2a8b646b44 upstream.
Setting non-zero values to SYNIC/STIMER MSRs activates certain features, this should not happen when KVM_CAP_HYPERV_SYNIC{,2} was not activated.
Note, it would've been better to forbid writing anything to SYNIC/STIMER MSRs, including zeroes, however, at least QEMU tries clearing HV_X64_MSR_STIMER0_CONFIG without SynIC. HV_X64_MSR_EOM MSR is somewhat 'special' as writing zero there triggers an action, this also should not happen when SynIC wasn't activated.
Message-Id: <[email protected]>
--- arch/x86/kvm/hyperv.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
arch/x86/kvm/hyperv.c +6 -3
@@ -236,7 +236,7 @@ static int synic_set_msr(struct kvm_vcpustruct kvm_vcpu *vcpu =hv_synic_to_vcpu (synic);int ret; -if (!synic->active && !host) +if (!synic->active && (!host || data))return 1 ;trace_kvm_hv_synic_set_msr (vcpu->vcpu_id, msr, data, host);
@@ -282,6 +282,9 @@ static int synic_set_msr(struct kvm_vcpucase HV_X64_MSR_EOM : {int i; +if (!synic->active) +break ; +for (i =0 ; i <ARRAY_SIZE (synic->sint); i++)kvm_hv_notify_acked_sint (vcpu, i);break ;
@@ -661,7 +664,7 @@ static int stimer_set_config(struct kvm_struct kvm_vcpu_hv *hv_vcpu =to_hv_vcpu (vcpu);struct kvm_vcpu_hv_synic *synic =to_hv_synic (vcpu); -if (!synic->active && !host) +if (!synic->active && (!host || config))return 1 ; if (unlikely(!host && hv_vcpu->enforce_cpuid && new_config.direct_mode &&
@@ -690,7 +693,7 @@ static int stimer_set_count(struct kvm_vstruct kvm_vcpu *vcpu =hv_stimer_to_vcpu (stimer);struct kvm_vcpu_hv_synic *synic =to_hv_synic (vcpu); -if (!synic->active && !host) +if (!synic->active && (!host || count))return 1 ; trace_kvm_hv_stimer_set_count(hv_stimer_to_vcpu(stimer)->vcpu_id,
Greg Kroah-Hartman
maintainerPATCH 904/1017 KVM: Prevent module exit until all VMs are freed
In reply to Greg Kroah-HartmanFrom: David Matlack <[email protected]>
commit 5f6de5cbebee925a612856fce6f9182bb3eee0db upstream.
Tie the lifetime the KVM module to the lifetime of each VM via kvm.users_count. This way anything that grabs a reference to the VM via kvm_get_kvm() cannot accidentally outlive the KVM module.
Prior to this commit, the lifetime of the KVM module was tied to the lifetime of /dev/kvm file descriptors, VM file descriptors, and vCPU file descriptors by their respective file_operations "owner" field. This approach is insufficient because references grabbed via kvm_get_kvm() do not prevent closing any of the aforementioned file descriptors.
This fixes a long standing theoretical bug in KVM that at least affects async page faults. kvm_setup_async_pf() grabs a reference via kvm_get_kvm(), and drops it in an asynchronous work callback. Nothing prevents the VM file descriptor from being closed and the KVM module from being unloaded before this callback runs.
Message-Id: <[email protected]>
--- virt/kvm/kvm_main.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
virt/kvm/kvm_main.c +13 -0
@@ -117,6 +117,8 @@ EXPORT_SYMBOL_GPL(kvm_debugfs_dir);static const struct file_operations stat_fops_per_vm; +static struct file_operations kvm_chardev_ops; +static long kvm_vcpu_ioctl (struct file *file,unsigned int ioctl,unsigned long arg);#ifdef CONFIG_KVM_COMPAT
@@ -1107,6 +1109,16 @@ static struct kvm *kvm_create_vm(unsignepreempt_notifier_inc ();kvm_init_pm_notifier (kvm); +/* +* When the fd passed to this ioctl() is opened it pins the module, +* but try_module_get() also prevents getting a reference if the module +* is in MODULE_STATE_GOING (e.g. if someone ran "rmmod --wait"). +*/ +if (!try_module_get (kvm_chardev_ops.owner)) { + r = -ENODEV ; + goto out_err; + } +return kvm; out_err:
@@ -1196,6 +1208,7 @@ static void kvm_destroy_vm(struct kvm *kpreempt_notifier_dec ();hardware_disable_all ();mmdrop (mm); +module_put (kvm_chardev_ops.owner); }void kvm_get_kvm (struct kvm *kvm)
Greg Kroah-Hartman
maintainerPATCH 905/1017 KVM: x86: fix sending PV IPI
In reply to Greg Kroah-HartmanFrom: Li RongQing <[email protected]>
commit c15e0ae42c8e5a61e9aca8aac920517cf7b3e94e upstream.
If apic_id is less than min, and (max - apic_id) is greater than KVM_IPI_CLUSTER_SIZE, then the third check condition is satisfied but the new apic_id does not fit the bitmask. In this case __send_ipi_mask should send the IPI.
This is mostly theoretical, but it can happen if the apic_ids on three iterations of the loop are for example 1, KVM_IPI_CLUSTER_SIZE, 0.
Message-Id: <[email protected]>
--- arch/x86/kernel/kvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/kvm.c +1 -1
@@ -515,7 +515,7 @@ static void __send_ipi_mask(const struct }else if (apic_id < min && max - apic_id <KVM_IPI_CLUSTER_SIZE ) { ipi_bitmap <<= min - apic_id; min = apic_id; - }else if (apic_id < min +KVM_IPI_CLUSTER_SIZE ) { + }else if (apic_id > min && apic_id < min +KVM_IPI_CLUSTER_SIZE ) { max = apic_id < max ? max : apic_id; }else { ret = kvm_hypercall4(KVM_HC_SEND_IPI, (unsigned long)ipi_bitmap,
Greg Kroah-Hartman
maintainerPATCH 906/1017 KVM: SVM: fix panic on out-of-bounds guest IRQ
In reply to Greg Kroah-HartmanFrom: Yi Wang <[email protected]>
commit a80ced6ea514000d34bf1239d47553de0d1ee89e upstream.
As guest_irq is coming from KVM_IRQFD API call, it may trigger crash in svm_update_pi_irte() due to out-of-bounds:
crash> bt
PID: 22218 TASK: ffff951a6ad74980 CPU: 73 COMMAND: "vcpu8"
#0 [ffffb1ba6707fa40] machine_kexec at ffffffff8565b397 #1 [ffffb1ba6707fa90] __crash_kexec at ffffffff85788a6d #2 [ffffb1ba6707fb58] crash_kexec at ffffffff8578995d #3 [ffffb1ba6707fb70] oops_end at ffffffff85623c0d #4 [ffffb1ba6707fb90] no_context at ffffffff856692c9 #5 [ffffb1ba6707fbf8] exc_page_fault at ffffffff85f95b51 #6 [ffffb1ba6707fc50] asm_exc_page_fault at ffffffff86000ace
[exception RIP: svm_update_pi_irte+227]
RIP: ffffffffc0761b53 RSP: ffffb1ba6707fd08 RFLAGS: 00010086
RAX: ffffb1ba6707fd78 RBX: ffffb1ba66d91000 RCX: 0000000000000001
RDX: 00003c803f63f1c0 RSI: 000000000000019a RDI: ffffb1ba66db2ab8
RBP: 000000000000019a R8: 0000000000000040 R9: ffff94ca41b82200
R10: ffffffffffffffcf R11: 0000000000000001 R12: 0000000000000001
R13: 0000000000000001 R14: ffffffffffffffcf R15: 000000000000005f
ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018
#7 [ffffb1ba6707fdb8] kvm_irq_routing_update at ffffffffc09f19a1 [kvm]
#8 [ffffb1ba6707fde0] kvm_set_irq_routing at ffffffffc09f2133 [kvm]
#9 [ffffb1ba6707fe18] kvm_vm_ioctl at ffffffffc09ef544 [kvm]
RIP: 00007f143c36488b RSP: 00007f143a4e04b8 RFLAGS: 00000246
RAX: ffffffffffffffda RBX: 00007f05780041d0 RCX: 00007f143c36488b
RDX: 00007f05780041d0 RSI: 000000004008ae6a RDI: 0000000000000020
RBP: 00000000000004e8 R8: 0000000000000008 R9: 00007f05780041e0
R10: 00007f0578004560 R11: 0000000000000246 R12: 00000000000004e0
R13: 000000000000001a R14: 00007f1424001c60 R15: 00007f0578003bc0
ORIG_RAX: 0000000000000010 CS: 0033 SS: 002bVmx have been fix this in commit 3a8b0677fc61 (KVM: VMX: Do not BUG() on out-of-bounds guest IRQ), so we can just copy source from that to fix this.
Message-Id: <[email protected]>
--- arch/x86/kvm/svm/avic.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
arch/x86/kvm/svm/avic.c +8 -2
@@ -799,7 +799,7 @@ int svm_update_pi_irte(struct kvm *kvm, {struct kvm_kernel_irq_routing_entry *e;struct kvm_irq_routing_table *irq_rt; -int idx, ret = -EINVAL ; +int idx, ret =0 ;if (!kvm_arch_has_assigned_device (kvm) || !irq_remapping_cap (IRQ_POSTING_CAP ))
@@ -810,7 +810,13 @@ int svm_update_pi_irte(struct kvm *kvm, idx =srcu_read_lock (&kvm->irq_srcu); irq_rt =srcu_dereference (kvm->irq_routing, &kvm->irq_srcu); -WARN_ON (guest_irq >= irq_rt->nr_rt_entries); + +if (guest_irq >= irq_rt->nr_rt_entries || +hlist_empty (&irq_rt->map[guest_irq])) { +pr_warn_once ("no route for guest_irq %u/%u (broken user space?)\n" , + guest_irq, irq_rt->nr_rt_entries); + goto out; + }hlist_for_each_entry (e, &irq_rt->map[guest_irq], link) {struct vcpu_data vcpu_info;
Greg Kroah-Hartman
maintainerPATCH 907/1017 ubifs: rename_whiteout: Fix double free for whiteout_ui->data
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
commit 40a8f0d5e7b3999f096570edab71c345da812e3e upstream.
'whiteout_ui->data' will be freed twice if space budget fail for rename whiteout operation as following process:
rename_whiteout
dev = kmalloc
whiteout_ui->data = dev
kfree(whiteout_ui->data) // Free first time
iput(whiteout)
ubifs_free_inode
kfree(ui->data) // Double free!KASAN reports:
==================================================================
BUG: KASAN: double-free or invalid-free in ubifs_free_inode+0x4f/0x70 Call Trace: kfree+0x117/0x490 ubifs_free_inode+0x4f/0x70 [ubifs] i_callback+0x30/0x60 rcu_do_batch+0x366/0xac0 __do_softirq+0x133/0x57f Allocated by task 1506: kmem_cache_alloc_trace+0x3c2/0x7a0 do_rename+0x9b7/0x1150 [ubifs] ubifs_rename+0x106/0x1f0 [ubifs] do_syscall_64+0x35/0x80 Freed by task 1506: kfree+0x117/0x490 do_rename.cold+0x53/0x8a [ubifs] ubifs_rename+0x106/0x1f0 [ubifs] do_syscall_64+0x35/0x80 The buggy address belongs to the object at ffff88810238bed8 which
belongs to the cache kmalloc-8 of size 8
==================================================================
Let ubifs_free_inode() free 'whiteout_ui->data'. BTW, delete unused assignment 'whiteout_ui->data_len = 0', process 'ubifs_evict_inode() -> ubifs_jnl_delete_inode() -> ubifs_jnl_write_inode()' doesn't need it (because 'inc_nlink(whiteout)' won't be excuted by 'goto out_release',
and the nlink of whiteout inode is 0).
--- fs/ubifs/dir.c | 2 -- 1 file changed, 2 deletions(-)
fs/ubifs/dir.c +0 -2
@@ -1425,8 +1425,6 @@ static int do_rename(struct inode *old_d err =ubifs_budget_space (c, &wht_req);if (err) { -kfree (whiteout_ui->data); - whiteout_ui->data_len =0 ;iput (whiteout); goto out_release; }
Greg Kroah-Hartman
maintainerPATCH 908/1017 ubifs: Fix deadlock in concurrent rename whiteout and inode writeback
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
commit afd427048047e8efdedab30e8888044e2be5aa9c upstream.
Following hung tasks:
[ 77.028764] task:kworker/u8:4 state:D stack: 0 pid: 132 [ 77.028820] Call Trace: [ 77.029027] schedule+0x8c/0x1b0 [ 77.029067] mutex_lock+0x50/0x60 [ 77.029074] ubifs_write_inode+0x68/0x1f0 [ubifs] [ 77.029117] __writeback_single_inode+0x43c/0x570 [ 77.029128] writeback_sb_inodes+0x259/0x740 [ 77.029148] wb_writeback+0x107/0x4d0 [ 77.029163] wb_workfn+0x162/0x7b0
[ 92.390442] task:aa state:D stack: 0 pid: 1506 [ 92.390448] Call Trace: [ 92.390458] schedule+0x8c/0x1b0 [ 92.390461] wb_wait_for_completion+0x82/0xd0 [ 92.390469] __writeback_inodes_sb_nr+0xb2/0x110 [ 92.390472] writeback_inodes_sb_nr+0x14/0x20 [ 92.390476] ubifs_budget_space+0x705/0xdd0 [ubifs] [ 92.390503] do_rename.cold+0x7f/0x187 [ubifs] [ 92.390549] ubifs_rename+0x8b/0x180 [ubifs] [ 92.390571] vfs_rename+0xdb2/0x1170 [ 92.390580] do_renameat2+0x554/0x770
, are caused by concurrent rename whiteout and inode writeback processes:
rename_whiteout(Thread 1) wb_workfn(Thread2)ubifs_rename
do_rename
lock_4_inodes (Hold ui_mutex)
ubifs_budget_space
make_free_space
shrink_liability
__writeback_inodes_sb_nr
bdi_split_work_to_wbs (Queue new wb work)
wb_do_writeback(wb work)
__writeback_single_inode
ubifs_write_inode
LOCK(ui_mutex)
↑
wb_wait_for_completion (Wait wb work) <-- deadlock!
Reproducer (Detail program in [Link]):
1. SYS_renameat2("/mp/dir/file", "/mp/dir/whiteout", RENAME_WHITEOUT)
2. Consume out of space before kernel(mdelay) doing budget for whiteout
Fix it by doing whiteout space budget before locking ubifs inodes. BTW, it also fixes wrong goto tag 'out_release' in whiteout budget error handling path(It should at least recover dir i_size and unlock 4 ubifs inodes).
--- fs/ubifs/dir.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)
fs/ubifs/dir.c +15 -10
@@ -1324,6 +1324,7 @@ static int do_rename(struct inode *old_dif (flags &RENAME_WHITEOUT ) {union ubifs_dev_desc *dev =NULL ; +struct ubifs_budget_req wht_req; dev =kmalloc (sizeof (union ubifs_dev_desc ),GFP_NOFS );if (!dev) {
@@ -1345,6 +1346,20 @@ static int do_rename(struct inode *old_d whiteout_ui->data = dev; whiteout_ui->data_len =ubifs_encode_dev (dev,MKDEV (0 ,0 ));ubifs_assert (c, !whiteout_ui->dirty); + +memset (&wht_req,0 ,sizeof (struct ubifs_budget_req )); + wht_req.dirtied_ino =1 ; + wht_req.dirtied_ino_d =ALIGN (whiteout_ui->data_len,8 ); +/* +* To avoid deadlock between space budget (holds ui_mutex and +* waits wb work) and writeback work(waits ui_mutex), do space +* budget before ubifs inodes locked. +*/ + err =ubifs_budget_space (c, &wht_req); +if (err) { +iput (whiteout); + goto out_release; + } }lock_4_inodes (old_dir, new_dir, new_inode, whiteout);
@@ -1419,16 +1434,6 @@ static int do_rename(struct inode *old_d }if (whiteout) { -struct ubifs_budget_req wht_req = { .dirtied_ino =1 , - .dirtied_ino_d = \ -ALIGN (ubifs_inode (whiteout)->data_len,8 ) }; - - err =ubifs_budget_space (c, &wht_req); -if (err) { -iput (whiteout); - goto out_release; - } -inc_nlink (whiteout);mark_inode_dirty (whiteout);
Greg Kroah-Hartman
maintainerPATCH 909/1017 ubifs: Add missing iput if do_tmpfile() failed in rename whiteout
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
commit 716b4573026bcbfa7b58ed19fe15554bac66b082 upstream.
whiteout inode should be put when do_tmpfile() failed if inode has been initialized. Otherwise we will get following warning during umount:
UBIFS error (ubi0:0 pid 1494): ubifs_assert_failed [ubifs]: UBIFS assert failed: c->bi.dd_growth == 0, in fs/ubifs/super.c:1930
VFS: Busy inodes after unmount of ubifs. Self-destruct in 5 seconds.
--- fs/ubifs/dir.c | 2 ++ 1 file changed, 2 insertions(+)
fs/ubifs/dir.c +2 -0
@@ -432,6 +432,8 @@ out_inode:make_bad_inode (inode);if (!instantiated)iput (inode); +else if (whiteout) +iput (*whiteout); out_budg:ubifs_release_budget (c, &req);if (!instantiated)
Greg Kroah-Hartman
maintainerPATCH 910/1017 ubifs: Rename whiteout atomically
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
commit 278d9a243635f26c05ad95dcf9c5a593b9e04dc6 upstream.
Currently, rename whiteout has 3 steps:
1. create tmpfile(which associates old dentry to tmpfile inode) for whiteout, and store tmpfile to disk
2. link whiteout, associate whiteout inode to old dentry agagin and store old dentry, old inode, new dentry on disk
3. writeback dirty whiteout inode to disk
Suddenly power-cut or error occurring(eg. ENOSPC returned by budget, memory allocation failure) during above steps may cause kinds of problems:
Problem 1: ENOSPC returned by whiteout space budget (before step 2),
old dentry will disappear after rename syscall, whiteout file cannot be found either.
ls dir // we get file, whiteout
rename(dir/file, dir/whiteout, REANME_WHITEOUT) ENOSPC = ubifs_budget_space(&wht_req) // return
ls dir // empty (no file, no whiteout)
Problem 2: Power-cut happens before step 3, whiteout inode with 'nlink=1'
is not stored on disk, whiteout dentry(old dentry) is written on disk, whiteout file is lost on next mount (We get "dead directory entry" after executing 'ls -l' on whiteout file).
Now, we use following 3 steps to finish rename whiteout:
1. create an in-mem inode with 'nlink = 1' as whiteout
2. ubifs_jnl_rename (Write on disk to finish associating old dentry to whiteout inode, associating new dentry with old inode)
3. iput(whiteout)
Rely writing in-mem inode on disk by ubifs_jnl_rename() to finish rename whiteout, which avoids middle disk state caused by suddenly power-cut and error occurring.
--- fs/ubifs/dir.c | 144 +++++++++++++++++++++++++++++++++-------------------- fs/ubifs/journal.c | 52 ++++++++++++++++--- 2 files changed, 136 insertions(+), 60 deletions(-)
fs/ubifs/dir.c +92 -52
@@ -349,8 +349,56 @@ out_budg:return err; } -static int do_tmpfile (struct inode *dir,struct dentry *dentry, -umode_t mode,struct inode **whiteout) +static struct inode *create_whiteout (struct inode *dir,struct dentry *dentry) +{ +int err; +umode_t mode =S_IFCHR |WHITEOUT_MODE ; +struct inode *inode; +struct ubifs_info *c = dir->i_sb->s_fs_info; +struct fscrypt_name nm; + +/* +* Create an inode('nlink = 1') for whiteout without updating journal, +* let ubifs_jnl_rename() store it on flash to complete rename whiteout +* atomically. +*/ + +dbg_gen ("dent '%pd', mode %#hx in dir ino %lu" , + dentry, mode, dir->i_ino); + + err =fscrypt_setup_filename (dir, &dentry->d_name,0 , &nm); +if (err) +return ERR_PTR (err); + + inode =ubifs_new_inode (c, dir, mode); +if (IS_ERR (inode)) { + err =PTR_ERR (inode); + goto out_free; + } + +init_special_inode (inode, inode->i_mode,WHITEOUT_DEV ); +ubifs_assert (c, inode->i_op == &ubifs_file_inode_operations); + + err =ubifs_init_security (dir, inode, &dentry->d_name); +if (err) + goto out_inode; + +/* The dir size is updated by do_rename. */ +insert_inode_hash (inode); + +return inode; + +out_inode: +make_bad_inode (inode); +iput (inode); +out_free: +fscrypt_free_filename (&nm); +ubifs_err (c,"cannot create whiteout file, error %d" , err); +return ERR_PTR (err); +} + +static int ubifs_tmpfile (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode) {struct inode *inode;struct ubifs_info *c = dir->i_sb->s_fs_info;
@@ -392,25 +440,13 @@ static int do_tmpfile(struct inode *dir, } ui =ubifs_inode (inode); -if (whiteout) { -init_special_inode (inode, inode->i_mode,WHITEOUT_DEV ); -ubifs_assert (c, inode->i_op == &ubifs_file_inode_operations); - } - err =ubifs_init_security (dir, inode, &dentry->d_name);if (err) goto out_inode;mutex_lock (&ui->ui_mutex);insert_inode_hash (inode); - -if (whiteout) { -mark_inode_dirty (inode); -drop_nlink (inode); - *whiteout = inode; - }else { -d_tmpfile (dentry, inode); - } +d_tmpfile (dentry, inode);ubifs_assert (c, ui->dirty); instantiated =1 ;
@@ -432,8 +468,6 @@ out_inode:make_bad_inode (inode);if (!instantiated)iput (inode); -else if (whiteout) -iput (*whiteout); out_budg:ubifs_release_budget (c, &req);if (!instantiated)
@@ -443,12 +477,6 @@ out_budg:return err; } -static int ubifs_tmpfile (struct user_namespace *mnt_userns,struct inode *dir, -struct dentry *dentry,umode_t mode) -{ -return do_tmpfile (dir, dentry, mode,NULL ); -} -/** * vfs_dent_type - get VFS directory entry type. * @type: UBIFS directory entry type
@@ -1266,17 +1294,19 @@ static int do_rename(struct inode *old_d .dirtied_ino = 3 };struct ubifs_budget_req ino_req = { .dirtied_ino =1 , .dirtied_ino_d =ALIGN (old_inode_ui->data_len,8 ) }; +struct ubifs_budget_req wht_req;struct timespec64 time;unsigned int saved_nlink;struct fscrypt_name old_nm, new_nm;/* -* Budget request settings: deletion direntry, new direntry, removing -* the old inode, and changing old and new parent directory inodes. +* Budget request settings: +* req: deletion direntry, new direntry, removing the old inode, +* and changing old and new parent directory inodes. +* +* wht_req: new whiteout inode for RENAME_WHITEOUT. * -* However, this operation also marks the target inode as dirty and -* does not write it, so we allocate budget for the target inode -* separately. +* ino_req: marks the target inode as dirty and does not write it. */ dbg_gen("dent '%pd' ino %lu in dir ino %lu to dent '%pd' in dir ino %lu flags 0x%x",
@@ -1326,7 +1356,6 @@ static int do_rename(struct inode *old_dif (flags &RENAME_WHITEOUT ) {union ubifs_dev_desc *dev =NULL ; -struct ubifs_budget_req wht_req; dev =kmalloc (sizeof (union ubifs_dev_desc ),GFP_NOFS );if (!dev) {
@@ -1334,24 +1363,26 @@ static int do_rename(struct inode *old_d goto out_release; } - err =do_tmpfile (old_dir, old_dentry,S_IFCHR |WHITEOUT_MODE , &whiteout); -if (err) { +/* +* The whiteout inode without dentry is pinned in memory, +* umount won't happen during rename process because we +* got parent dentry. +*/ + whiteout =create_whiteout (old_dir, old_dentry); +if (IS_ERR (whiteout)) { + err =PTR_ERR (whiteout);kfree (dev); goto out_release; } -spin_lock (&whiteout->i_lock); - whiteout->i_state |=I_LINKABLE ; -spin_unlock (&whiteout->i_lock); - whiteout_ui =ubifs_inode (whiteout); whiteout_ui->data = dev; whiteout_ui->data_len =ubifs_encode_dev (dev,MKDEV (0 ,0 ));ubifs_assert (c, !whiteout_ui->dirty);memset (&wht_req,0 ,sizeof (struct ubifs_budget_req )); - wht_req.dirtied_ino =1 ; - wht_req.dirtied_ino_d =ALIGN (whiteout_ui->data_len,8 ); + wht_req.new_ino =1 ; + wht_req.new_ino_d =ALIGN (whiteout_ui->data_len,8 );/* * To avoid deadlock between space budget (holds ui_mutex and * waits wb work) and writeback work(waits ui_mutex), do space
@@ -1359,6 +1390,11 @@ static int do_rename(struct inode *old_d*/ err =ubifs_budget_space (c, &wht_req);if (err) { +/* +* Whiteout inode can not be written on flash by +* ubifs_jnl_write_inode(), because it's neither +* dirty nor zero-nlink. +*/ iput (whiteout); goto out_release; }
@@ -1433,17 +1469,11 @@ static int do_rename(struct inode *old_d sync =IS_DIRSYNC (old_dir) ||IS_DIRSYNC (new_dir);if (unlink &&IS_SYNC (new_inode)) sync =1 ; - } - -if (whiteout) { -inc_nlink (whiteout); -mark_inode_dirty (whiteout); - -spin_lock (&whiteout->i_lock); - whiteout->i_state &= ~I_LINKABLE ; -spin_unlock (&whiteout->i_lock); - -iput (whiteout); +/* +* S_SYNC flag of whiteout inherits from the old_dir, and we +* have already checked the old dir inode. So there is no need +* to check whiteout. +*/ } err = ubifs_jnl_rename(c, old_dir, old_inode, &old_nm, new_dir,
@@ -1454,6 +1484,11 @@ static int do_rename(struct inode *old_dunlock_4_inodes (old_dir, new_dir, new_inode, whiteout);ubifs_release_budget (c, &req); +if (whiteout) { +ubifs_release_budget (c, &wht_req); +iput (whiteout); + } +mutex_lock (&old_inode_ui->ui_mutex); release = old_inode_ui->dirty;mark_inode_dirty_sync (old_inode);
@@ -1462,11 +1497,16 @@ static int do_rename(struct inode *old_dif (release)ubifs_release_budget (c, &ino_req);if (IS_SYNC (old_inode)) - err = old_inode->i_sb->s_op->write_inode (old_inode,NULL ); +/* +* Rename finished here. Although old inode cannot be updated +* on flash, old ctime is not a big problem, don't return err +* code to userspace. +*/ + old_inode->i_sb->s_op->write_inode (old_inode,NULL );fscrypt_free_filename (&old_nm);fscrypt_free_filename (&new_nm); -return err; +return 0 ; out_cancel:if (unlink) {
@@ -1487,11 +1527,11 @@ out_cancel:inc_nlink (old_dir); } } +unlock_4_inodes (old_dir, new_dir, new_inode, whiteout);if (whiteout) { -drop_nlink (whiteout); +ubifs_release_budget (c, &wht_req);iput (whiteout); } -unlock_4_inodes (old_dir, new_dir, new_inode, whiteout); out_release:ubifs_release_budget (c, &ino_req);ubifs_release_budget (c, &req);
fs/ubifs/journal.c +44 -8
108 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 911/1017 ubifs: Fix ui->dirty race between do_tmpfile() and writeback work
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
commit 60eb3b9c9f11206996f57cb89521824304b305ad upstream.
'ui->dirty' is not protected by 'ui_mutex' in function do_tmpfile() which may race with ubifs_write_inode[wb_workfn] to access/update 'ui->dirty', finally dirty space is released twice.
open(O_TMPFILE) wb_workfndo_tmpfile
ubifs_budget_space(ino_req = { .dirtied_ino = 1}) d_tmpfile // mark inode(tmpfile) dirty ubifs_jnl_update // without holding tmpfile's ui_mutex
mark_inode_clean(ui)
if (ui->dirty)
ubifs_release_dirty_inode_budget(ui) // release first time
ubifs_write_inode
mutex_lock(&ui->ui_mutex)
ubifs_release_dirty_inode_budget(ui)
// release second time
mutex_unlock(&ui->ui_mutex)
ui->dirty = 0Run generic/476 can reproduce following message easily (See reproducer in [Link]):
UBIFS error (ubi0:0 pid 2578): ubifs_assert_failed [ubifs]: UBIFS assert
failed: c->bi.dd_growth >= 0, in fs/ubifs/budget.c:554
UBIFS warning (ubi0:0 pid 2578): ubifs_ro_mode [ubifs]: switched to read-only mode, error -22
Workqueue: writeback wb_workfn (flush-ubifs_0_0)
Call Trace:
ubifs_ro_mode+0x54/0x60 [ubifs]
ubifs_assert_failed+0x4b/0x80 [ubifs]
ubifs_release_budget+0x468/0x5a0 [ubifs]
ubifs_release_dirty_inode_budget+0x53/0x80 [ubifs]
ubifs_write_inode+0x121/0x1f0 [ubifs]
...
wb_workfn+0x283/0x7b0Fix it by holding tmpfile ubifs inode lock during ubifs_jnl_update(). Similar problem exists in whiteout renaming, but previous fix("ubifs:
Rename whiteout atomically") has solved the problem.
--- fs/ubifs/dir.c | 60 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 30 insertions(+), 30 deletions(-)
fs/ubifs/dir.c +30 -30
@@ -397,6 +397,32 @@ out_free:return ERR_PTR (err); } +/** +* lock_2_inodes - a wrapper for locking two UBIFS inodes. +* @inode1: first inode +* @inode2: second inode +* +* We do not implement any tricks to guarantee strict lock ordering, because +* VFS has already done it for us on the @i_mutex. So this is just a simple +* wrapper function. +*/ +static void lock_2_inodes (struct inode *inode1,struct inode *inode2) +{ +mutex_lock_nested (&ubifs_inode (inode1)->ui_mutex,WB_MUTEX_1 ); +mutex_lock_nested (&ubifs_inode (inode2)->ui_mutex,WB_MUTEX_2 ); +} + +/** +* unlock_2_inodes - a wrapper for unlocking two UBIFS inodes. +* @inode1: first inode +* @inode2: second inode +*/ +static void unlock_2_inodes (struct inode *inode1,struct inode *inode2) +{ +mutex_unlock (&ubifs_inode (inode2)->ui_mutex); +mutex_unlock (&ubifs_inode (inode1)->ui_mutex); +} +static int ubifs_tmpfile (struct user_namespace *mnt_userns,struct inode *dir,struct dentry *dentry,umode_t mode) {
@@ -404,7 +430,7 @@ static int ubifs_tmpfile(struct user_namstruct ubifs_info *c = dir->i_sb->s_fs_info;struct ubifs_budget_req req = { .new_ino =1 , .new_dent =1 };struct ubifs_budget_req ino_req = { .dirtied_ino =1 }; -struct ubifs_inode *ui, *dir_ui =ubifs_inode (dir); +struct ubifs_inode *ui;int err, instantiated =0 ;struct fscrypt_name nm;
@@ -452,18 +478,18 @@ static int ubifs_tmpfile(struct user_nam instantiated =1 ;mutex_unlock (&ui->ui_mutex); -mutex_lock (&dir_ui->ui_mutex); +lock_2_inodes (dir, inode); err =ubifs_jnl_update (c, dir, &nm, inode,1 ,0 );if (err) goto out_cancel; -mutex_unlock (&dir_ui->ui_mutex); +unlock_2_inodes (dir, inode);ubifs_release_budget (c, &req);return 0 ; out_cancel: -mutex_unlock (&dir_ui->ui_mutex); +unlock_2_inodes (dir, inode); out_inode:make_bad_inode (inode);if (!instantiated)
@@ -690,32 +716,6 @@ static int ubifs_dir_release(struct inodreturn 0 ; } -/** -* lock_2_inodes - a wrapper for locking two UBIFS inodes. -* @inode1: first inode -* @inode2: second inode -* -* We do not implement any tricks to guarantee strict lock ordering, because -* VFS has already done it for us on the @i_mutex. So this is just a simple -* wrapper function. -*/ -static void lock_2_inodes (struct inode *inode1,struct inode *inode2) -{ -mutex_lock_nested (&ubifs_inode (inode1)->ui_mutex,WB_MUTEX_1 ); -mutex_lock_nested (&ubifs_inode (inode2)->ui_mutex,WB_MUTEX_2 ); -} - -/** -* unlock_2_inodes - a wrapper for unlocking two UBIFS inodes. -* @inode1: first inode -* @inode2: second inode -*/ -static void unlock_2_inodes (struct inode *inode1,struct inode *inode2) -{ -mutex_unlock (&ubifs_inode (inode2)->ui_mutex); -mutex_unlock (&ubifs_inode (inode1)->ui_mutex); -} -static int ubifs_link (struct dentry *old_dentry,struct inode *dir,struct dentry *dentry) {
Greg Kroah-Hartman
maintainerPATCH 912/1017 ubifs: Rectify space amount budget for mkdir/tmpfile operations
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
commit a6dab6607d4681d227905d5198710b575dbdb519 upstream.
UBIFS should make sure the flash has enough space to store dirty (Data that is newer than disk) data (in memory), space budget is exactly designed to do that. If space budget calculates less data than we need, 'make_reservation()' will do more work(return -ENOSPC if no free space lelf, sometimes we can see "cannot reserve xxx bytes in jhead xxx, error -28" in ubifs error messages) with ubifs inodes locked, which may effect other syscalls.
A simple way to decide how much space do we need when make a budget:
See how much space is needed by 'make_reservation()' in ubifs_jnl_xxx() function according to corresponding operation.
It's better to report ENOSPC in ubifs_budget_space(), as early as we can.
--- fs/ubifs/dir.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
fs/ubifs/dir.c +8 -4
@@ -428,15 +428,18 @@ static int ubifs_tmpfile(struct user_nam {struct inode *inode;struct ubifs_info *c = dir->i_sb->s_fs_info; -struct ubifs_budget_req req = { .new_ino =1 , .new_dent =1 }; +struct ubifs_budget_req req = { .new_ino =1 , .new_dent =1 , + .dirtied_ino =1 };struct ubifs_budget_req ino_req = { .dirtied_ino =1 };struct ubifs_inode *ui;int err, instantiated =0 ;struct fscrypt_name nm;/* -* Budget request settings: new dirty inode, new direntry, -* budget for dirtied inode will be released via writeback. +* Budget request settings: new inode, new direntry, changing the +* parent directory inode. +* Allocate budget separately for new dirtied inode, the budget will +* be released via writeback. */ dbg_gen("dent '%pd', mode %#hx in dir ino %lu",
@@ -979,7 +982,8 @@ static int ubifs_mkdir(struct user_namesstruct ubifs_inode *dir_ui =ubifs_inode (dir);struct ubifs_info *c = dir->i_sb->s_fs_info;int err, sz_change; -struct ubifs_budget_req req = { .new_ino =1 , .new_dent =1 }; +struct ubifs_budget_req req = { .new_ino =1 , .new_dent =1 , + .dirtied_ino =1 };struct fscrypt_name nm;/*
Greg Kroah-Hartman
maintainerPATCH 913/1017 ubifs: setflags: Make dirtied_ino_d 8 bytes aligned
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
commit 1b83ec057db16b4d0697dc21ef7a9743b6041f72 upstream.
Make 'ui->data_len' aligned with 8 bytes before it is assigned to dirtied_ino_d. Since 8871d84c8f8b0c6b("ubifs: convert to fileattr") applied, 'setflags()' only affects regular files and directories, only xattr inode, symlink inode and special inode(pipe/char_dev/block_dev) have none- zero 'ui->data_len' field, so assertion '!(req->dirtied_ino_d & 7)' cannot fail in ubifs_budget_space(). To avoid assertion fails in future evolution(eg. setflags can operate special inodes), it's better to make dirtied_ino_d 8 bytes aligned, after all aligned size is still zero for regular files.
--- fs/ubifs/ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ubifs/ioctl.c +1 -1
@@ -108,7 +108,7 @@ static int setflags(struct inode *inode,struct ubifs_inode *ui =ubifs_inode (inode);struct ubifs_info *c = inode->i_sb->s_fs_info;struct ubifs_budget_req req = { .dirtied_ino =1 , - .dirtied_ino_d = ui->data_len }; + .dirtied_ino_d =ALIGN (ui->data_len,8 ) }; err =ubifs_budget_space (c, &req);if (err)
Greg Kroah-Hartman
maintainerPATCH 914/1017 ubifs: Fix read out-of-bounds in ubifs_wbuf_write_nolock()
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
commit 4f2262a334641e05f645364d5ade1f565c85f20b upstream.
Function ubifs_wbuf_write_nolock() may access buf out of bounds in following process:
ubifs_wbuf_write_nolock():
aligned_len = ALIGN(len, 8); // Assume len = 4089, aligned_len = 4096
if (aligned_len <= wbuf->avail) ... // Not satisfy
if (wbuf->used) {
ubifs_leb_write() // Fill some data in avail wbuf
len -= wbuf->avail; // len is still not 8-bytes aligned
aligned_len -= wbuf->avail;
}
n = aligned_len >> c->max_write_shift;
if (n) {
n <<= c->max_write_shift;
err = ubifs_leb_write(c, wbuf->lnum, buf + written,
wbuf->offs, n);
// n > len, read out of bounds less than 8(n-len) bytes}
, which can be catched by KASAN:
=========================================================
BUG: KASAN: slab-out-of-bounds in ecc_sw_hamming_calculate+0x1dc/0x7d0
Read of size 4 at addr ffff888105594ff8 by task kworker/u8:4/128
Workqueue: writeback wb_workfn (flush-ubifs_0_0)
Call Trace:
kasan_report.cold+0x81/0x165
nand_write_page_swecc+0xa9/0x160
ubifs_leb_write+0xf2/0x1b0 [ubifs]
ubifs_wbuf_write_nolock+0x421/0x12c0 [ubifs]
write_head+0xdc/0x1c0 [ubifs]
ubifs_jnl_write_inode+0x627/0x960 [ubifs]
wb_workfn+0x8af/0xb80Function ubifs_wbuf_write_nolock() accepts that parameter 'len' is not 8 bytes aligned, the 'len' represents the true length of buf (which is allocated in 'ubifs_jnl_xxx', eg. ubifs_jnl_write_inode), so ubifs_wbuf_write_nolock() must handle the length read from 'buf' carefully to write leb safely.
Fetch a reproducer in [Link].
--- fs/ubifs/io.c | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-)
fs/ubifs/io.c +30 -4
@@ -833,16 +833,42 @@ int ubifs_wbuf_write_nolock(struct ubifs*/ n = aligned_len >> c->max_write_shift;if (n) { - n <<= c->max_write_shift; +int m = n -1 ; +dbg_io ("write %d bytes to LEB %d:%d" , n, wbuf->lnum, wbuf->offs); - err =ubifs_leb_write (c, wbuf->lnum, buf + written, - wbuf->offs, n); + +if (m) { +/* '(n-1)<<c->max_write_shift < len' is always true. */ + m <<= c->max_write_shift; + err =ubifs_leb_write (c, wbuf->lnum, buf + written, + wbuf->offs, m); +if (err) + goto out; + wbuf->offs += m; + aligned_len -= m; + len -= m; + written += m; + } + +/* +* The non-written len of buf may be less than 'n' because +* parameter 'len' is not 8 bytes aligned, so here we read +* min(len, n) bytes from buf. +*/ + n =1 << c->max_write_shift; +memcpy (wbuf->buf, buf + written,min (len, n)); +if (n > len) { +ubifs_assert (c, n - len <8 ); +ubifs_pad (c, wbuf->buf + len, n - len); + } + + err =ubifs_leb_write (c, wbuf->lnum, wbuf->buf, wbuf->offs, n);if (err) goto out; wbuf->offs += n; aligned_len -= n; - len -= n; + len -=min (len, n); written += n; }
Greg Kroah-Hartman
maintainerPATCH 915/1017 ubifs: Fix to add refcount once page is set private
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
commit 3b67db8a6ca83e6ff90b756d3da0c966f61cd37b upstream.
MM defined the rule [1] very clearly that once page was set with PG_private flag, we should increment the refcount in that page, also main flows like pageout(), migrate_page() will assume there is one additional page reference count if page_has_private() returns true. Otherwise, we may get a BUG in page migration:
page:0000000080d05b9d refcount:-1 mapcount:0 mapping:000000005f4d82a8 index:0xe2 pfn:0x14c12
aops:ubifs_file_address_operations [ubifs] ino:8f1 dentry name:"f30e"
flags: 0x1fffff80002405(locked|uptodate|owner_priv_1|private|node=0| zone=1|lastcpupid=0x1fffff)
page dumped because: VM_BUG_ON_PAGE(page_count(page) != 0)
------------[ cut here ]------------
kernel BUG at include/linux/page_ref.h:184!
invalid opcode: 0000 [#1] SMP
CPU: 3 PID: 38 Comm: kcompactd0 Not tainted 5.15.0-rc5
RIP: 0010:migrate_page_move_mapping+0xac3/0xe70
Call Trace:
ubifs_migrate_page+0x22/0xc0 [ubifs]
move_to_new_page+0xb4/0x600
migrate_pages+0x1523/0x1cc0
compact_zone+0x8c5/0x14b0
kcompactd+0x2bc/0x560
kthread+0x18c/0x1e0
ret_from_fork+0x1f/0x30Before the time, we should make clean a concept, what does refcount means in page gotten from grab_cache_page_write_begin(). There are 2 situations:
Situation 1: refcount is 3, page is created by __page_cache_alloc.
TYPE_A - the write process is using this page
TYPE_B - page is assigned to one certain mapping by calling
__add_to_page_cache_locked()
TYPE_C - page is added into pagevec list corresponding current cpu by
calling lru_cache_add()
Situation 2: refcount is 2, page is gotten from the mapping's tree
TYPE_B - page has been assigned to one certain mapping TYPE_A - the write process is using this page (by calling
page_cache_get_speculative())
Filesystem releases one refcount by calling put_page() in xxx_write_end(), the released refcount corresponds to TYPE_A (write task is using it). If there are any processes using a page, page migration process will skip the page by judging whether expected_page_refs() equals to page refcount.
The BUG is caused by following process:
PA(cpu 0) kcompactd(cpu 1)
compact_zoneubifs_write_begin
page_a = grab_cache_page_write_begin
add_to_page_cache_lru
lru_cache_add
pagevec_add // put page into cpu 0's pagevec
(refcnf = 3, for page creation process)ubifs_write_end
SetPagePrivate(page_a) // doesn't increase page count ! unlock_page(page_a)
put_page(page_a) // refcnt = 2
[...]
PB(cpu 0)filemap_read
filemap_get_pages
add_to_page_cache_lru
lru_cache_add
__pagevec_lru_add // traverse all pages in cpu 0's pagevec
__pagevec_lru_add_fn
SetPageLRU(page_a)
isolate_migratepages
isolate_migratepages_block
get_page_unless_zero(page_a) // refcnt = 3
list_add(page_a, from_list)
migrate_pages(from_list)
__unmap_and_move
move_to_new_page
ubifs_migrate_page(page_a)
migrate_page_move_mapping
expected_page_refs get 3
(migration[1] + mapping[1] + private[1])
release_pages
put_page_testzero(page_a) // refcnt = 3
page_ref_freeze // refcnt = 0
page_ref_dec_and_test(0 - 1 = -1)
page_ref_unfreeze
VM_BUG_ON_PAGE(-1 != 0, page)
UBIFS doesn't increase the page refcount after setting private flag, which leads to page migration task believes the page is not used by any other processes, so the page is migrated. This causes concurrent accessing on page refcount between put_page() called by other process(eg. read process calls lru_cache_add) and page_ref_unfreeze() called by migration task.
Actually zhangjun has tried to fix this problem [2] by recalculating page refcnt in ubifs_migrate_page(). It's better to follow MM rules [1], because just like Kirill suggested in [2], we need to check all users of page_has_private() helper. Like f2fs does in [3], fix it by adding/deleting refcount when setting/clearing private for a page. BTW, according to [4], we set 'page->private' as 1 because ubifs just simply SetPagePrivate(). And, [5] provided a common helper to set/clear page private, ubifs can use this helper following the example of iomap, afs, btrfs, etc.
Jump [6] to find a reproducer.
[1] https://lore.kernel.org/lkml/[email protected]
[2] https://www.spinics.net/lists/linux-mtd/msg04018.html
[3] http://lkml.iu.edu/hypermail/linux/kernel/1903.0/03313.html
[4] https://lore.kernel.org/linux-f2fs-devel/[email protected]
[5] https://lore.kernel.org/all/[email protected]
[6] https://bugzilla.kernel.org/show_bug.cgi?id=214961
--- fs/ubifs/file.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
fs/ubifs/file.c +7 -7
@@ -570,7 +570,7 @@ static int ubifs_write_end(struct file * }if (!PagePrivate (page)) { -SetPagePrivate (page); +attach_page_private (page, (void *)1 );atomic_long_inc (&c->dirty_pg_cnt);__set_page_dirty_nobuffers (page); }
@@ -947,7 +947,7 @@ static int do_writepage(struct page *pagrelease_existing_page_budget (c);atomic_long_dec (&c->dirty_pg_cnt); -ClearPagePrivate (page); +detach_page_private (page);ClearPageChecked (page);kunmap (page);
@@ -1304,7 +1304,7 @@ static void ubifs_invalidatepage(structrelease_existing_page_budget (c);atomic_long_dec (&c->dirty_pg_cnt); -ClearPagePrivate (page); +detach_page_private (page);ClearPageChecked (page); }
@@ -1471,8 +1471,8 @@ static int ubifs_migrate_page(struct addreturn rc;if (PagePrivate (page)) { -ClearPagePrivate (page); -SetPagePrivate (newpage); +detach_page_private (page); +attach_page_private (newpage, (void *)1 ); }if (mode !=MIGRATE_SYNC_NO_COPY )
@@ -1496,7 +1496,7 @@ static int ubifs_releasepage(struct pagereturn 0 ;ubifs_assert (c,PagePrivate (page));ubifs_assert (c,0 ); -ClearPagePrivate (page); +detach_page_private (page);ClearPageChecked (page);return 1 ; }
@@ -1567,7 +1567,7 @@ static vm_fault_t ubifs_vm_page_mkwrite(else {if (!PageChecked (page))ubifs_convert_page_budget (c); -SetPagePrivate (page); +attach_page_private (page, (void *)1 );atomic_long_inc (&c->dirty_pg_cnt);__set_page_dirty_nobuffers (page); }
Greg Kroah-Hartman
maintainerPATCH 916/1017 ubifs: rename_whiteout: correct old_dir size computing
In reply to Greg Kroah-HartmanFrom: Baokun Li <[email protected]>
commit 705757274599e2e064dd3054aabc74e8af31a095 upstream.
When renaming the whiteout file, the old whiteout file is not deleted. Therefore, we add the old dentry size to the old dir like XFS. Otherwise, an error may be reported due to fscki->calc_sz != fscki->size in check_indes.
--- fs/ubifs/dir.c | 3 +++ 1 file changed, 3 insertions(+)
fs/ubifs/dir.c +3 -0
@@ -1402,6 +1402,9 @@ static int do_rename(struct inode *old_diput (whiteout); goto out_release; } + +/* Add the old_dentry size to the old_dir size. */ + old_sz -=CALC_DENT_SIZE (fname_len (&old_nm)); }lock_4_inodes (old_dir, new_dir, new_inode, whiteout);
Greg Kroah-Hartman
maintainerPATCH 917/1017 nvme: allow duplicate NSIDs for private namespaces
In reply to Greg Kroah-HartmanFrom: Sungup Moon <[email protected]>
commit 5974ea7ce0f9a5987fc8cf5e08ad6e3e70bb542e upstream.
A NVMe subsystem with multiple controller can have private namespaces that use the same NSID under some conditions:
"If Namespace Management, ANA Reporting, or NVM Sets are supported, the
NSIDs shall be unique within the NVM subsystem. If the Namespace Management, ANA Reporting, and NVM Sets are not supported, then NSIDs:
a) for shared namespace shall be unique; and
b) for private namespace are not required to be unique."
Reference: Section 6.1.6 NSID and Namespace Usage; NVM Express 1.4c spec.
Make sure this specific setup is supported in Linux.
[hch: refactored and fixed the controller vs subsystem based naming
conflict]
--- drivers/nvme/host/core.c | 15 ++++++++++----- drivers/nvme/host/multipath.c | 7 ++++--- drivers/nvme/host/nvme.h | 19 +++++++++++++++++++ include/linux/nvme.h | 1 + 4 files changed, 34 insertions(+), 8 deletions(-)
drivers/nvme/host/core.c +10 -5
@@ -3581,15 +3581,20 @@ static const struct attribute_group *nvm NULL, }; -static struct nvme_ns_head *nvme_find_ns_head (struct nvme_subsystem *subsys, +static struct nvme_ns_head *nvme_find_ns_head (struct nvme_ctrl *ctrl,unsigned nsid) {struct nvme_ns_head *h; -lockdep_assert_held (&subsys->lock); +lockdep_assert_held (&ctrl->subsys->lock); -list_for_each_entry (h, &subsys->nsheads, entry) { -if (h->ns_id != nsid) +list_for_each_entry (h, &ctrl->subsys->nsheads, entry) { +/* +* Private namespaces can share NSIDs under some conditions. +* In that case we can't use the same ns_head for namespaces +* with the same NSID. +*/ +if (h->ns_id != nsid || !nvme_is_unique_nsid (ctrl, h))continue ;if (!list_empty (&h->list) &&nvme_tryget_ns_head (h))return h;
@@ -3757,7 +3762,7 @@ static int nvme_init_ns_head(struct nvmeint ret =0 ;mutex_lock (&ctrl->subsys->lock); - head =nvme_find_ns_head (ctrl->subsys, nsid); + head =nvme_find_ns_head (ctrl, nsid);if (!head) { head =nvme_alloc_ns_head (ctrl, nsid, ids);if (IS_ERR (head)) {
drivers/nvme/host/multipath.c +4 -3
@@ -468,10 +468,11 @@ int nvme_mpath_alloc_disk(struct nvme_ct/* * Add a multipath node if the subsystems supports multiple controllers. -* We also do this for private namespaces as the namespace sharing data could -* change after a rescan. +* We also do this for private namespaces as the namespace sharing flag +* could change after a rescan. */ -if (!(ctrl->subsys->cmic &NVME_CTRL_CMIC_MULTI_CTRL ) || !multipath) +if (!(ctrl->subsys->cmic &NVME_CTRL_CMIC_MULTI_CTRL ) || + !nvme_is_unique_nsid (ctrl, head) || !multipath)return 0 ; head->disk =blk_alloc_disk (ctrl->numa_node);
drivers/nvme/host/nvme.h +19 -0
@@ -712,6 +712,25 @@ static inline bool nvme_check_ready(strureturn queue_live;return __nvme_check_ready (ctrl, rq, queue_live); } + +/* +* NSID shall be unique for all shared namespaces, or if at least one of the +* following conditions is met: +* 1. Namespace Management is supported by the controller +* 2. ANA is supported by the controller +* 3. NVM Set are supported by the controller +* +* In other case, private namespace are not required to report a unique NSID. +*/ +static inline bool nvme_is_unique_nsid (struct nvme_ctrl *ctrl, +struct nvme_ns_head *head) +{ +return head->shared || + (ctrl->oacs &NVME_CTRL_OACS_NS_MNGT_SUPP ) || + (ctrl->subsys->cmic &NVME_CTRL_CMIC_ANA ) || + (ctrl->ctratt &NVME_CTRL_CTRATT_NVM_SETS ); +} +int nvme_submit_sync_cmd (struct request_queue *q,struct nvme_command *cmd,void *buf,unsigned bufflen); int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
include/linux/nvme.h +1 -0
@@ -337,6 +337,7 @@ enum {NVME_CTRL_ONCS_TIMESTAMP =1 <<6 ,NVME_CTRL_VWC_PRESENT =1 <<0 ,NVME_CTRL_OACS_SEC_SUPP =1 <<0 , +NVME_CTRL_OACS_NS_MNGT_SUPP =1 <<3 ,NVME_CTRL_OACS_DIRECTIVES =1 <<5 ,NVME_CTRL_OACS_DBBUF_SUPP =1 <<8 , NVME_CTRL_LPA_CMD_EFFECTS_LOG = 1 << 1,
Greg Kroah-Hartman
maintainerPATCH 918/1017 nvme: fix the read-only state for zoned namespaces with unsupposed features
In reply to Greg Kroah-HartmanFrom: Pankaj Raghav <[email protected]>
commit 726be2c72efc0a64c206e854b8996ad3ab9c7507 upstream.
commit 2f4c9ba23b88 ("nvme: export zoned namespaces without Zone Append support read-only") marks zoned namespaces without append support read-only. It does iso by setting NVME_NS_FORCE_RO in ns->flags in nvme_update_zone_info and checking for that flag later in nvme_update_disk_info to mark the disk as read-only.
But commit 73d90386b559 ("nvme: cleanup zone information initialization") rearranged nvme_update_disk_info to be called before nvme_update_zone_info and thus not marking the disk as read-only. The call order cannot be just reverted because nvme_update_zone_info sets certain queue parameters such as zone_write_granularity that depend on the prior call to nvme_update_disk_info.
Remove the call to set_disk_ro in nvme_update_disk_info. and call set_disk_ro after nvme_update_zone_info and nvme_update_disk_info to set the permission for ZNS drives correctly. The same applies to the multipath disk path.
--- drivers/nvme/host/core.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/nvme/host/core.c +5 -3
@@ -1860,9 +1860,6 @@ static void nvme_update_disk_info(structnvme_config_discard (disk, ns);blk_queue_max_write_zeroes_sectors (disk->queue, ns->ctrl->max_zeroes_sectors); - -set_disk_ro (disk, (id->nsattr &NVME_NS_ATTR_RO ) || -test_bit (NVME_NS_FORCE_RO , &ns->flags)); }static inline bool nvme_first_scan (struct gendisk *disk)
@@ -1923,6 +1920,8 @@ static int nvme_update_ns_info(struct nv goto out_unfreeze; } +set_disk_ro (ns->disk, (id->nsattr &NVME_NS_ATTR_RO ) || +test_bit (NVME_NS_FORCE_RO , &ns->flags));set_bit (NVME_NS_READY , &ns->flags);blk_mq_unfreeze_queue (ns->disk->queue);
@@ -1935,6 +1934,9 @@ static int nvme_update_ns_info(struct nvif (nvme_ns_head_multipath (ns->head)) {blk_mq_freeze_queue (ns->head->disk->queue);nvme_update_disk_info (ns->head->disk, ns, id); +set_disk_ro (ns->head->disk, + (id->nsattr &NVME_NS_ATTR_RO ) || +test_bit (NVME_NS_FORCE_RO , &ns->flags));nvme_mpath_revalidate_paths (ns);blk_stack_limits (&ns->head->disk->queue->limits, &ns->queue->limits,0 );
Greg Kroah-Hartman
maintainerPATCH 919/1017 wireguard: queueing: use CFI-safe ptr_ring cleanup function
In reply to Greg Kroah-HartmanFrom: Jason A. Donenfeld <[email protected]>
commit ec59f128a9bd4255798abb1e06ac3b442f46ef68 upstream.
We make too nuanced use of ptr_ring to entirely move to the skb_array wrappers, but we at least should avoid the naughty function pointer cast when cleaning up skbs. Otherwise RAP/CFI will honk at us. This patch uses the __skb_array_destroy_skb wrapper for the cleanup, rather than directly providing kfree_skb, which is what other drivers in the same situation do too.
--- drivers/net/wireguard/queueing.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireguard/queueing.c +2 -1
@@ -4,6 +4,7 @@*/ #include "queueing.h" +#include <linux/skb_array.h> struct multicore_worker __percpu *wg_packet_percpu_multicore_worker_alloc (work_func_t function,void *ptr)
@@ -42,7 +43,7 @@ void wg_packet_queue_free(struct crypt_q {free_percpu (queue->worker);WARN_ON (!purge && !__ptr_ring_empty (&queue->ring)); -ptr_ring_cleanup (&queue->ring, purge ? (void (*)(void *))kfree_skb :NULL ); +ptr_ring_cleanup (&queue->ring, purge ? __skb_array_destroy_skb :NULL ); }#define NEXT (skb) ((skb)->prev)
Greg Kroah-Hartman
maintainerPATCH 920/1017 wireguard: socket: free skb in send6 when ipv6 is disabled
In reply to Greg Kroah-HartmanFrom: Wang Hai <[email protected]>
commit bbbf962d9460194993ee1943a793a0a0af4a7fbf upstream.
I got a memory leak report:
unreferenced object 0xffff8881191fc040 (size 232):
comm "kworker/u17:0", pid 23193, jiffies 4295238848 (age 3464.870s) hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<ffffffff814c3ef4>] slab_post_alloc_hook+0x84/0x3b0
[<ffffffff814c8977>] kmem_cache_alloc_node+0x167/0x340
[<ffffffff832974fb>] __alloc_skb+0x1db/0x200
[<ffffffff82612b5d>] wg_socket_send_buffer_to_peer+0x3d/0xc0
[<ffffffff8260e94a>] wg_packet_send_handshake_initiation+0xfa/0x110
[<ffffffff8260ec81>] wg_packet_handshake_send_worker+0x21/0x30
[<ffffffff8119c558>] process_one_work+0x2e8/0x770
[<ffffffff8119ca2a>] worker_thread+0x4a/0x4b0
[<ffffffff811a88e0>] kthread+0x120/0x160
[<ffffffff8100242f>] ret_from_fork+0x1f/0x30In function wg_socket_send_buffer_as_reply_to_skb() or wg_socket_send_ buffer_to_peer(), the semantics of send6() is required to free skb. But when CONFIG_IPV6 is disable, kfree_skb() is missing. This patch adds it to fix this bug.
--- drivers/net/wireguard/socket.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireguard/socket.c +1 -0
@@ -160,6 +160,7 @@ out:rcu_read_unlock_bh ();return ret;#else +kfree_skb (skb);return -EAFNOSUPPORT ;#endif }
Greg Kroah-Hartman
maintainerPATCH 921/1017 wireguard: socket: ignore v6 endpoints when ipv6 is disabled
In reply to Greg Kroah-HartmanFrom: Jason A. Donenfeld <[email protected]>
commit 77fc73ac89be96ec8f39e8efa53885caa7cb3645 upstream.
The previous commit fixed a memory leak on the send path in the event that IPv6 is disabled at compile time, but how did a packet even arrive there to begin with? It turns out we have previously allowed IPv6 endpoints even when IPv6 support is disabled at compile time. This is awkward and inconsistent. Instead, let's just ignore all things IPv6, the same way we do other malformed endpoints, in the case where IPv6 is disabled.
--- drivers/net/wireguard/socket.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireguard/socket.c +2 -2
@@ -242,7 +242,7 @@ int wg_socket_endpoint_from_skb(struct e endpoint->addr4.sin_addr.s_addr =ip_hdr (skb)->saddr; endpoint->src4.s_addr =ip_hdr (skb)->daddr; endpoint->src_if4 = skb->skb_iif; - }else if (skb->protocol ==htons (ETH_P_IPV6 )) { + }else if (IS_ENABLED (CONFIG_IPV6 ) && skb->protocol ==htons (ETH_P_IPV6 )) { endpoint->addr6.sin6_family =AF_INET6 ; endpoint->addr6.sin6_port =udp_hdr (skb)->source; endpoint->addr6.sin6_addr =ipv6_hdr (skb)->saddr;
@@ -285,7 +285,7 @@ void wg_socket_set_peer_endpoint(struct peer->endpoint.addr4 = endpoint->addr4; peer->endpoint.src4 = endpoint->src4; peer->endpoint.src_if4 = endpoint->src_if4; - }else if (endpoint->addr.sa_family ==AF_INET6 ) { + }else if (IS_ENABLED (CONFIG_IPV6 ) && endpoint->addr.sa_family ==AF_INET6 ) { peer->endpoint.addr6 = endpoint->addr6; peer->endpoint.src6 = endpoint->src6; }else {
Greg Kroah-Hartman
maintainerPATCH 922/1017 XArray: Fix xas_create_range() when multi-order entry present
In reply to Greg Kroah-HartmanFrom: Matthew Wilcox (Oracle) <[email protected]>
commit 3e3c658055c002900982513e289398a1aad4a488 upstream.
If there is already an entry present that is of order >= XA_CHUNK_SHIFT when we call xas_create_range(), xas_create_range() will misinterpret that entry as a node and dereference xa_node->parent, generally leading to a crash that looks something like this:
general protection fault, probably for non-canonical address 0xdffffc0000000001: 0000 [#1] PREEMPT SMP KASAN KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f] CPU: 0 PID: 32 Comm: khugepaged Not tainted 5.17.0-rc8-syzkaller-00003-g56e337f2cf13 #0 RIP: 0010:xa_parent_locked include/linux/xarray.h:1207 [inline] RIP: 0010:xas_create_range+0x2d9/0x6e0 lib/xarray.c:725
It's deterministically reproducable once you know what the problem is, but producing it in a live kernel requires khugepaged to hit a race. While the problem has been present since xas_create_range() was introduced, I'm not aware of a way to hit it before the page cache was converted to use multi-index entries.
--- lib/test_xarray.c | 22 ++++++++++++++++++++++ lib/xarray.c | 2 ++ 2 files changed, 24 insertions(+)
lib/test_xarray.c +22 -0
@@ -1463,6 +1463,25 @@ unlock:XA_BUG_ON (xa, !xa_empty (xa)); } +static noinline void check_create_range_5(struct xarray *xa, +unsigned long index,unsigned int order) +{ +XA_STATE_ORDER (xas, xa, index, order); +unsigned int i; + +xa_store_order (xa, index, order,xa_mk_index (index),GFP_KERNEL ); + +for (i =0 ; i < order +10 ; i++) { +do { +xas_lock (&xas); +xas_create_range (&xas); +xas_unlock (&xas); + }while (xas_nomem (&xas,GFP_KERNEL )); + } + +xa_destroy (xa); +} + static noinline void check_create_range(struct xarray *xa) {unsigned int order;
@@ -1490,6 +1509,9 @@ static noinline void check_create_range(check_create_range_4 (xa, (3U << order) +1 , order);check_create_range_4 (xa, (3U << order) -1 , order);check_create_range_4 (xa, (1U <<24 ) +1 , order); + +check_create_range_5 (xa,0 , order); +check_create_range_5 (xa, (1U << order), order); }check_create_range_3 ();
lib/xarray.c +2 -0
@@ -722,6 +722,8 @@ void xas_create_range(struct xa_state *xfor (;;) {struct xa_node *node = xas->xa_node; +if (node->shift >= shift) +break ; xas->xa_node =xa_parent_locked (xas->xa, node); xas->xa_offset = node->offset -1 ;if (node->offset !=0 )
Greg Kroah-Hartman
maintainerPATCH 923/1017 can: mcba_usb: mcba_usb_start_xmit(): fix double dev_kfree_skb in error path
In reply to Greg Kroah-HartmanFrom: Hangyu Hua <[email protected]>
commit 04c9b00ba83594a29813d6b1fb8fdc93a3915174 upstream.
There is no need to call dev_kfree_skb() when usb_submit_urb() fails because can_put_echo_skb() deletes original skb and can_free_echo_skb() deletes the cloned skb.
--- drivers/net/can/usb/mcba_usb.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/can/usb/mcba_usb.c +0 -1
@@ -368,7 +368,6 @@ static netdev_tx_t mcba_usb_start_xmit(s xmit_failed:can_free_echo_skb (priv->netdev, ctx->ndx,NULL );mcba_usb_free_ctx (ctx); -dev_kfree_skb (skb); stats->tx_dropped++;return NETDEV_TX_OK ;
Greg Kroah-Hartman
maintainerPATCH 924/1017 can: mcba_usb: properly check endpoint type
In reply to Greg Kroah-HartmanFrom: Pavel Skripkin <[email protected]>
commit 136bed0bfd3bc9c95c88aafff2d22ecb3a919f23 upstream.
Syzbot reported warning in usb_submit_urb() which is caused by wrong endpoint type. We should check that in endpoint is actually present to prevent this warning.
Found pipes are now saved to struct mcba_priv and code uses them directly instead of making pipes in place.
Fail log:
| usb 5-1: BOGUS urb xfer, pipe 3 != type 1 | WARNING: CPU: 1 PID: 49 at drivers/usb/core/urb.c:502 usb_submit_urb+0xed2/0x18a0 drivers/usb/core/urb.c:502 | Modules linked in: | CPU: 1 PID: 49 Comm: kworker/1:2 Not tainted 5.17.0-rc6-syzkaller-00184-g38f80f42147f #0 | Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.14.0-2 04/01/2014 | Workqueue: usb_hub_wq hub_event | RIP: 0010:usb_submit_urb+0xed2/0x18a0 drivers/usb/core/urb.c:502 | ... | Call Trace: | <TASK> | mcba_usb_start drivers/net/can/usb/mcba_usb.c:662 [inline] | mcba_usb_probe+0x8a3/0xc50 drivers/net/can/usb/mcba_usb.c:858 | usb_probe_interface+0x315/0x7f0 drivers/usb/core/driver.c:396 | call_driver_probe drivers/base/dd.c:517 [inline]
--- drivers/net/can/usb/mcba_usb.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)
drivers/net/can/usb/mcba_usb.c +16 -10
@@ -33,10 +33,6 @@#define MCBA_USB_RX_BUFF_SIZE 64#define MCBA_USB_TX_BUFF_SIZE (sizeof(struct mcba_usb_msg)) -/* MCBA endpoint numbers */ -#define MCBA_USB_EP_IN 1 -#define MCBA_USB_EP_OUT 1 -/* Microchip command id */ #define MBCA_CMD_RECEIVE_MESSAGE 0xE3#define MBCA_CMD_I_AM_ALIVE_FROM_CAN 0xF5
@@ -84,6 +80,8 @@ struct mcba_priv {atomic_t free_ctx_cnt;void *rxbuf[MCBA_MAX_RX_URBS ];dma_addr_t rxbuf_dma[MCBA_MAX_RX_URBS ]; +int rx_pipe; +int tx_pipe; };/* CAN frame */
@@ -272,10 +270,8 @@ static netdev_tx_t mcba_usb_xmit(structmemcpy (buf, usb_msg,MCBA_USB_TX_BUFF_SIZE ); -usb_fill_bulk_urb (urb, priv->udev, -usb_sndbulkpipe (priv->udev,MCBA_USB_EP_OUT ), buf, -MCBA_USB_TX_BUFF_SIZE , mcba_usb_write_bulk_callback, - ctx); +usb_fill_bulk_urb (urb, priv->udev, priv->tx_pipe, buf,MCBA_USB_TX_BUFF_SIZE , + mcba_usb_write_bulk_callback, ctx); urb->transfer_flags |=URB_NO_TRANSFER_DMA_MAP ;usb_anchor_urb (urb, &priv->tx_submitted);
@@ -610,7 +606,7 @@ static void mcba_usb_read_bulk_callback( resubmit_urb:usb_fill_bulk_urb (urb, priv->udev, -usb_rcvbulkpipe (priv->udev,MCBA_USB_EP_OUT ), + priv->rx_pipe, urb->transfer_buffer,MCBA_USB_RX_BUFF_SIZE , mcba_usb_read_bulk_callback, priv);
@@ -655,7 +651,7 @@ static int mcba_usb_start(struct mcba_pr urb->transfer_dma = buf_dma;usb_fill_bulk_urb (urb, priv->udev, -usb_rcvbulkpipe (priv->udev,MCBA_USB_EP_IN ), + priv->rx_pipe, buf,MCBA_USB_RX_BUFF_SIZE , mcba_usb_read_bulk_callback, priv); urb->transfer_flags |=URB_NO_TRANSFER_DMA_MAP ;
@@ -809,6 +805,13 @@ static int mcba_usb_probe(struct usb_intstruct mcba_priv *priv;int err;struct usb_device *usbdev =interface_to_usbdev (intf); +struct usb_endpoint_descriptor *in, *out; + + err =usb_find_common_endpoints (intf->cur_altsetting, &in, &out,NULL ,NULL ); +if (err) { +dev_err (&intf->dev,"Can't find endpoints\n" ); +return err; + } netdev =alloc_candev (sizeof (struct mcba_priv ),MCBA_MAX_TX_URBS );if (!netdev) {
@@ -854,6 +857,9 @@ static int mcba_usb_probe(struct usb_int goto cleanup_free_candev; } + priv->rx_pipe =usb_rcvbulkpipe (priv->udev, in->bEndpointAddress); + priv->tx_pipe =usb_sndbulkpipe (priv->udev, out->bEndpointAddress); +devm_can_led_init (netdev);/* Start USB dev only if we have successfully registered CAN device */
Greg Kroah-Hartman
maintainerPATCH 925/1017 can: mcp251xfd: mcp251xfd_register_get_dev_id(): fix return of error value
In reply to Greg Kroah-HartmanFrom: Tom Rix <[email protected]>
commit fa7b514d2b2894e052b8e94c7a29feb98e90093f upstream.
Clang static analysis reports this issue:
| mcp251xfd-core.c:1813:7: warning: The left operand | of '&' is a garbage value | FIELD_GET(MCP251XFD_REG_DEVID_ID_MASK, dev_id), | ^ ~~~~~~
dev_id is set in a successful call to mcp251xfd_register_get_dev_id(). Though the status of calls made by mcp251xfd_register_get_dev_id() are checked and handled, their status' are not returned. So return err.
--- drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c +1 -1
@@ -2706,7 +2706,7 @@ mcp251xfd_register_get_dev_id(const stru out_kfree_buf_rx:kfree (buf_rx); -return 0 ; +return err; }#define MCP251XFD_QUIRK_ACTIVE (quirk) \
Greg Kroah-Hartman
maintainerPATCH 926/1017 XArray: Update the LRU list in xas_split()
In reply to Greg Kroah-HartmanFrom: Matthew Wilcox (Oracle) <[email protected]>
commit 3ed4bb77156da0bc732847c8c9df92454c1fbeea upstream.
When splitting a value entry, we may need to add the new nodes to the LRU list and remove the parent node from the LRU list. The WARN_ON checks in shadow_lru_isolate() catch this oversight. This bug was latent until we stopped splitting folios in shrink_page_list() with commit 820c4e2e6f51 ("mm/vmscan: Free non-shmem folios without splitting them"). That allows the creation of large shadow entries, and subsequently when trying to page in a small page, we will split the large shadow entry in __filemap_add_folio().
--- lib/xarray.c | 2 ++ 1 file changed, 2 insertions(+)
lib/xarray.c +2 -0
@@ -1081,6 +1081,7 @@ void xas_split(struct xa_state *xas, voi xa_mk_node(child));if (xa_is_value (curr)) values--; +xas_update (xas, child); }else {unsigned int canon = offset - xas->xa_sibs;
@@ -1095,6 +1096,7 @@ void xas_split(struct xa_state *xas, voi } while (offset-- > xas->xa_offset); node->nr_values += values; +xas_update (xas, node); }EXPORT_SYMBOL_GPL (xas_split);#endif
Greg Kroah-Hartman
maintainerPATCH 927/1017 modpost: restore the warning message for missing symbol versions
In reply to Greg Kroah-HartmanFrom: Masahiro Yamada <[email protected]>
commit bf5c0c2231bcab677e5cdfb7f73e6c79f6d8c2d4 upstream.
This log message was accidentally chopped off.
I was wondering why this happened, but checking the ML log, Mark precisely followed my suggestion [1].
I just used "..." because I was too lazy to type the sentence fully. Sorry for the confusion.
[1]: https://lore.kernel.org/all/CAK7LNAR6bXXk9-ZzZYpTqzFqdYbQsZHmiWspu27rtsFxvfRuVA@mail.gmail.com/
--- scripts/mod/modpost.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/mod/modpost.c +1 -1
@@ -669,7 +669,7 @@ static void handle_modversion(const struunsigned int crc;if (sym->st_shndx ==SHN_UNDEF ) { -warn ("EXPORT symbol \"%s\" [%s%s] version ...\n" +warn ("EXPORT symbol \"%s\" [%s%s] version generation failed, symbol will not be versioned.\n" "Is \"%s\" prototyped in <asm/asm-prototypes.h>?\n" , symname, mod->name, mod->is_vmlinux ?"" :".ko" , symname);
Greg Kroah-Hartman
maintainerPATCH 928/1017 rtc: check if __rtc_read_time was successful
In reply to Greg Kroah-HartmanFrom: Tom Rix <[email protected]>
commit 915593a7a663b2ad08b895a5f3ba8b19d89d4ebf upstream.
Clang static analysis reports this issue interface.c:810:8: warning: Passed-by-value struct
argument contains uninitialized data
now = rtc_tm_to_ktime(tm);
^~~~~~~~~~~~~~~~~~~tm is set by a successful call to __rtc_read_time() but its return status is not checked. Check if it was successful before setting the enabled flag. Move the decl of err to function scope.
--- drivers/rtc/interface.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/rtc/interface.c +5 -2
@@ -804,9 +804,13 @@ static int rtc_timer_enqueue(struct rtc_struct timerqueue_node *next =timerqueue_getnext (&rtc->timerqueue);struct rtc_time tm;ktime_t now; +int err; + + err =__rtc_read_time (rtc, &tm); +if (err) +return err; timer->enabled =1 ; -__rtc_read_time (rtc, &tm); now =rtc_tm_to_ktime (tm);/* Skip over expired timers */
@@ -820,7 +824,6 @@ static int rtc_timer_enqueue(struct rtc_trace_rtc_timer_enqueue (timer);if (!next ||ktime_before (timer->node.expires, next->expires)) {struct rtc_wkalrm alarm; -int err; alarm.time =rtc_ktime_to_tm (timer->node.expires); alarm.enabled =1 ;
Greg Kroah-Hartman
maintainerPATCH 929/1017 loop: fix ioctl calls using compat_loop_info
In reply to Greg Kroah-HartmanFrom: Carlos Llamas <[email protected]>
commit f941c51eeac7ebe0f8ec30943bf78e7f60aad039 upstream.
Support for cryptoloop was deleted in commit 47e9624616c8 ("block:
remove support for cryptoloop and the xor transfer"), making the usage of loop_info->lo_encrypt_type obsolete. However, this member was also removed from the compat_loop_info definition and this breaks userspace ioctl calls for 32-bit binaries and CONFIG_COMPAT=y.
This patch restores the compat_loop_info->lo_encrypt_type member and marks it obsolete as well as in the uapi header definitions.
--- drivers/block/loop.c | 1 + include/uapi/linux/loop.h | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/block/loop.c +1 -0
@@ -1603,6 +1603,7 @@ struct compat_loop_info {compat_ulong_t lo_inode;/* ioctl r/o */ compat_dev_t lo_rdevice;/* ioctl r/o */ compat_int_t lo_offset; +compat_int_t lo_encrypt_type;/* obsolete, ignored */ compat_int_t lo_encrypt_key_size;/* ioctl w/o */ compat_int_t lo_flags;/* ioctl r/o */ char lo_name[LO_NAME_SIZE ];
include/uapi/linux/loop.h +2 -2
@@ -45,7 +45,7 @@ struct loop_info {unsigned long lo_inode;/* ioctl r/o */ __kernel_old_dev_t lo_rdevice;/* ioctl r/o */ int lo_offset; -int lo_encrypt_type; +int lo_encrypt_type;/* obsolete, ignored */ int lo_encrypt_key_size;/* ioctl w/o */ int lo_flags;char lo_name[LO_NAME_SIZE ];
@@ -61,7 +61,7 @@ struct loop_info64 {__u64 lo_offset;__u64 lo_sizelimit;/* bytes, 0 == max available */ __u32 lo_number;/* ioctl r/o */ -__u32 lo_encrypt_type; +__u32 lo_encrypt_type;/* obsolete, ignored */ __u32 lo_encrypt_key_size;/* ioctl w/o */ __u32 lo_flags;__u8 lo_file_name[LO_NAME_SIZE ];
Greg Kroah-Hartman
maintainerPATCH 930/1017 gfs2: gfs2_setattr_size error path fix
In reply to Greg Kroah-HartmanFrom: Andreas Gruenbacher <[email protected]>
commit 7336905a89f19173bf9301cd50a24421162f417c upstream.
When gfs2_setattr_size() fails, it calls gfs2_rs_delete(ip, NULL) to get rid of any reservations the inode may have. Instead, it should pass in the inode's write count as the second parameter to allow gfs2_rs_delete() to figure out if the inode has any writers left.
In a next step, there are two instances of gfs2_rs_delete(ip, NULL) left where we know that there can be no other users of the inode. Replace those with gfs2_rs_deltree(&ip->i_res) to avoid the unnecessary write count check.
With that, gfs2_rs_delete() is only called with the inode's actual write count, so get rid of the second parameter.
--- fs/gfs2/bmap.c | 2 +- fs/gfs2/file.c | 2 +- fs/gfs2/inode.c | 2 +- fs/gfs2/rgrp.c | 7 ++++--- fs/gfs2/rgrp.h | 2 +- fs/gfs2/super.c | 2 +- 6 files changed, 9 insertions(+), 8 deletions(-)
fs/gfs2/bmap.c +1 -1
@@ -2146,7 +2146,7 @@ int gfs2_setattr_size(struct inode *inod ret =do_shrink (inode, newsize); out: -gfs2_rs_delete (ip,NULL ); +gfs2_rs_delete (ip);gfs2_qa_put (ip);return ret; }
fs/gfs2/file.c +1 -1
@@ -706,7 +706,7 @@ static int gfs2_release(struct inode *inif (file->f_mode &FMODE_WRITE ) {if (gfs2_rs_active (&ip->i_res)) -gfs2_rs_delete (ip, &inode->i_writecount); +gfs2_rs_delete (ip);gfs2_qa_put (ip); }return 0 ;
fs/gfs2/inode.c +1 -1
@@ -793,7 +793,7 @@ fail_free_inode:if (free_vfs_inode)/* else evict will do the put for us */ gfs2_glock_put (ip->i_gl); } -gfs2_rs_delete (ip,NULL ); +gfs2_rs_deltree (&ip->i_res);gfs2_qa_put (ip); fail_free_acls:posix_acl_release (default_acl);
fs/gfs2/rgrp.c +4 -3
@@ -680,13 +680,14 @@ void gfs2_rs_deltree(struct gfs2_blkrese/** * gfs2_rs_delete - delete a multi-block reservation * @ip: The inode for this reservation -* @wcount: The inode's write count, or NULL * */ -void gfs2_rs_delete (struct gfs2_inode *ip,atomic_t *wcount) +void gfs2_rs_delete (struct gfs2_inode *ip) { +struct inode *inode = &ip->i_inode; +down_write (&ip->i_rw_mutex); -if ((wcount ==NULL ) || (atomic_read (wcount) <=1 )) +if (atomic_read (&inode->i_writecount) <=1 )gfs2_rs_deltree (&ip->i_res);up_write (&ip->i_rw_mutex); }
fs/gfs2/rgrp.h +1 -1
@@ -45,7 +45,7 @@ extern int gfs2_alloc_blocks(struct gfs2 bool dinode, u64 *generation);extern void gfs2_rs_deltree (struct gfs2_blkreserv *rs); -extern void gfs2_rs_delete (struct gfs2_inode *ip,atomic_t *wcount); +extern void gfs2_rs_delete (struct gfs2_inode *ip);extern void __gfs2_free_blocks (struct gfs2_inode *ip,struct gfs2_rgrpd *rgd,u64 bstart,u32 blen,int meta); extern void gfs2_free_meta(struct gfs2_inode *ip, struct gfs2_rgrpd *rgd,
fs/gfs2/super.c +1 -1
@@ -1398,7 +1398,7 @@ out:truncate_inode_pages_final (&inode->i_data);if (ip->i_qadata)gfs2_assert_warn (sdp, ip->i_qadata->qa_ref ==0 ); -gfs2_rs_delete (ip,NULL ); +gfs2_rs_deltree (&ip->i_res);gfs2_ordered_del_inode (ip);clear_inode (inode);gfs2_dir_hash_inval (ip);
Greg Kroah-Hartman
maintainerPATCH 931/1017 gfs2: Fix gfs2_file_buffered_write endless loop workaround
In reply to Greg Kroah-HartmanFrom: Andreas Gruenbacher <[email protected]>
commit 46f3e0421ccb5474b5c006b0089b9dfd42534bb6 upstream.
Since commit 554c577cee95b, gfs2_file_buffered_write() can accidentally return a truncated iov_iter, which might confuse callers. Fix that.
--- fs/gfs2/file.c | 1 + 1 file changed, 1 insertion(+)
fs/gfs2/file.c +1 -0
@@ -1083,6 +1083,7 @@ out_uninit:gfs2_holder_uninit (gh);if (statfs_gh)kfree (statfs_gh); + from->count = orig_count - read;return read ? read : ret; }
Greg Kroah-Hartman
maintainerPATCH 932/1017 gfs2: Make sure FITRIM minlen is rounded up to fs block size
In reply to Greg Kroah-HartmanFrom: Andrew Price <[email protected]>
commit 27ca8273fda398638ca994a207323a85b6d81190 upstream.
Per fstrim(8) we must round up the minlen argument to the fs block size. The current calculation doesn't take into account devices that have a discard granularity and requested minlen less than 1 fs block, so the value can get shifted away to zero in the translation to fs blocks.
The zero minlen passed to gfs2_rgrp_send_discards() then allows sb_issue_discard() to be called with nr_sects == 0 which returns -EINVAL and results in gfs2_rgrp_send_discards() returning -EIO.
Make sure minlen is never < 1 fs block by taking the max of the requested minlen and the fs block size before comparing to the device's discard granularity and shifting to fs blocks.
--- fs/gfs2/rgrp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/gfs2/rgrp.c +2 -1
@@ -1416,7 +1416,8 @@ int gfs2_fitrim(struct file *filp, void start = r.start >> bs_shift; end = start + (r.len >> bs_shift); - minlen =max_t (u64, r.minlen, + minlen =max_t (u64, r.minlen, sdp->sd_sb.sb_bsize); + minlen =max_t (u64, minlen, q->limits.discard_granularity) >> bs_shift;if (end <= start || minlen > sdp->sd_max_rg_data)
Greg Kroah-Hartman
maintainerPATCH 933/1017 net: hns3: fix the concurrency between functions reading debugfs
In reply to Greg Kroah-HartmanFrom: Yufeng Mo <[email protected]>
commit 9c9a04212fa380d2e7d1412bb281309955c0a781 upstream.
Currently, the debugfs mechanism is that all functions share a global variable to save the pointer for obtaining data. When different functions concurrently access the same file node, repeated release exceptions occur. Therefore, the granularity of the pointer for storing the obtained data is adjusted to be private for each function.
--- drivers/net/ethernet/hisilicon/hns3/hnae3.h | 1 + drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c | 15 +++++++++++---- drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.h | 1 - 3 files changed, 12 insertions(+), 5 deletions(-)
drivers/net/ethernet/hisilicon/hns3/hnae3.h +1 -0
@@ -844,6 +844,7 @@ struct hnae3_handle {struct dentry *hnae3_dbgfs;/* protects concurrent contention between debugfs commands */ struct mutex dbgfs_lock; +char **dbgfs_buf;/* Network interface message level enabled bits */ u32 msg_enable;
drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c +11 -4
@@ -1227,7 +1227,7 @@ static ssize_t hns3_dbg_read(struct filereturn ret;mutex_lock (&handle->dbgfs_lock); - save_buf = &hns3_dbg_cmd[index].buf; + save_buf = &handle->dbgfs_buf[index];if (!test_bit (HNS3_NIC_STATE_INITED , &priv->state) ||test_bit (HNS3_NIC_STATE_RESETTING , &priv->state)) {
@@ -1332,6 +1332,13 @@ int hns3_dbg_init(struct hnae3_handle *hint ret;u32 i; + handle->dbgfs_buf =devm_kcalloc (&handle->pdev->dev, +ARRAY_SIZE (hns3_dbg_cmd), +sizeof (*handle->dbgfs_buf), +GFP_KERNEL ); +if (!handle->dbgfs_buf) +return -ENOMEM ; + hns3_dbg_dentry[HNS3_DBG_DENTRY_COMMON ].dentry =debugfs_create_dir (name, hns3_dbgfs_root); handle->hnae3_dbgfs = hns3_dbg_dentry[HNS3_DBG_DENTRY_COMMON ].dentry;
@@ -1380,9 +1387,9 @@ void hns3_dbg_uninit(struct hnae3_handleu32 i;for (i =0 ; i <ARRAY_SIZE (hns3_dbg_cmd); i++) -if (hns3_dbg_cmd[i].buf) { -kvfree (hns3_dbg_cmd[i].buf); - hns3_dbg_cmd[i].buf =NULL ; +if (handle->dbgfs_buf[i]) { +kvfree (handle->dbgfs_buf[i]); + handle->dbgfs_buf[i] =NULL ; }mutex_destroy (&handle->dbgfs_lock);
drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.h +0 -1
@@ -47,7 +47,6 @@ struct hns3_dbg_cmd_info {enum hnae3_dbg_cmd cmd;enum hns3_dbg_dentry_type dentry;u32 buf_len; -char *buf;int (*init)(struct hnae3_handle *handle,unsigned int cmd); };
Greg Kroah-Hartman
maintainerPATCH 934/1017 net: hns3: fix software vlan talbe of vlan 0 inconsistent with hardware
In reply to Greg Kroah-HartmanFrom: Guangbin Huang <[email protected]>
commit 7ed258f12ec5ce855f15cdfb5710361dc82fe899 upstream.
When user delete vlan 0, as driver will not delete vlan 0 for hardware in function hclge_set_vlan_filter_hw(), so vlan 0 in software vlan talbe should not be deleted.
--- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +3 -3
@@ -10754,11 +10754,11 @@ int hclge_set_vlan_filter(struct hnae3_h }if (!ret) { -if (is_kill) -hclge_rm_vport_vlan_table (vport, vlan_id, false); -else +if (!is_kill)hclge_add_vport_vlan_table (vport, vlan_id, writen_to_tbl); +else if (is_kill && vlan_id !=0 ) +hclge_rm_vport_vlan_table (vport, vlan_id, false); }else if (is_kill) {/* when remove hw vlan filter failed, record the vlan id, * and try to remove it from hw later, to be consistence
Greg Kroah-Hartman
maintainerPATCH 935/1017 rxrpc: fix some null-ptr-deref bugs in server_key.c
In reply to Greg Kroah-HartmanFrom: Xiaolong Huang <[email protected]>
commit ff8376ade4f668130385839cef586a0990f8ef87 upstream.
Some function calls are not implemented in rxrpc_no_security, there are preparse_server_key, free_preparse_server_key and destroy_server_key. When rxrpc security type is rxrpc_no_security, user can easily trigger a null-ptr-deref bug via ioctl. So judgment should be added to prevent it
The crash log:
user@syzkaller:~$ ./rxrpc_preparse_s [ 37.956878][T15626] BUG: kernel NULL pointer dereference, address: 0000000000000000 [ 37.957645][T15626] #PF: supervisor instruction fetch in kernel mode [ 37.958229][T15626] #PF: error_code(0x0010) - not-present page [ 37.958762][T15626] PGD 4aadf067 P4D 4aadf067 PUD 4aade067 PMD 0 [ 37.959321][T15626] Oops: 0010 [#1] PREEMPT SMP [ 37.959739][T15626] CPU: 0 PID: 15626 Comm: rxrpc_preparse_ Not tainted 5.17.0-01442-gb47d5a4f6b8d #43 [ 37.960588][T15626] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1 04/01/2014 [ 37.961474][T15626] RIP: 0010:0x0 [ 37.961787][T15626] Code: Unable to access opcode bytes at RIP 0xffffffffffffffd6. [ 37.962480][T15626] RSP: 0018:ffffc9000d9abdc0 EFLAGS: 00010286 [ 37.963018][T15626] RAX: ffffffff84335200 RBX: ffff888012a1ce80 RCX: 0000000000000000 [ 37.963727][T15626] RDX: 0000000000000000 RSI: ffffffff84a736dc RDI: ffffc9000d9abe48 [ 37.964425][T15626] RBP: ffffc9000d9abe48 R08: 0000000000000000 R09: 0000000000000002 [ 37.965118][T15626] R10: 000000000000000a R11: f000000000000000 R12: ffff888013145680 [ 37.965836][T15626] R13: 0000000000000000 R14: ffffffffffffffec R15: ffff8880432aba80 [ 37.966441][T15626] FS: 00007f2177907700(0000) GS:ffff88803ec00000(0000) knlGS:0000000000000000 [ 37.966979][T15626] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 37.967384][T15626] CR2: ffffffffffffffd6 CR3: 000000004aaf1000 CR4: 00000000000006f0 [ 37.967864][T15626] Call Trace: [ 37.968062][T15626] <TASK> [ 37.968240][T15626] rxrpc_preparse_s+0x59/0x90 [ 37.968541][T15626] key_create_or_update+0x174/0x510 [ 37.968863][T15626] __x64_sys_add_key+0x139/0x1d0 [ 37.969165][T15626] do_syscall_64+0x35/0xb0 [ 37.969451][T15626] entry_SYSCALL_64_after_hwframe+0x44/0xae [ 37.969824][T15626] RIP: 0033:0x43a1f9
--- net/rxrpc/server_key.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
net/rxrpc/server_key.c +5 -2
@@ -84,6 +84,9 @@ static int rxrpc_preparse_s(struct key_p prep->payload.data[1 ] = (struct rxrpc_security *)sec; +if (!sec->preparse_server_key) +return -EINVAL ; +return sec->preparse_server_key (prep); }
@@ -91,7 +94,7 @@ static void rxrpc_free_preparse_s(struct {const struct rxrpc_security *sec = prep->payload.data[1 ]; -if (sec) +if (sec && sec->free_preparse_server_key) sec->free_preparse_server_key (prep); }
@@ -99,7 +102,7 @@ static void rxrpc_destroy_s(struct key * {const struct rxrpc_security *sec = key->payload.data[1 ]; -if (sec) +if (sec && sec->destroy_server_key) sec->destroy_server_key (key); }
Greg Kroah-Hartman
maintainerPATCH 936/1017 rxrpc: Fix call timer start racing with call destruction
In reply to Greg Kroah-HartmanFrom: David Howells <[email protected]>
commit 4a7f62f91933c8ae5308f9127fd8ea48188b6bc3 upstream.
The rxrpc_call struct has a timer used to handle various timed events relating to a call. This timer can get started from the packet input routines that are run in softirq mode with just the RCU read lock held. Unfortunately, because only the RCU read lock is held - and neither ref or other lock is taken - the call can start getting destroyed at the same time a packet comes in addressed to that call. This causes the timer - which was already stopped - to get restarted. Later, the timer dispatch code may then oops if the timer got deallocated first.
Fix this by trying to take a ref on the rxrpc_call struct and, if successful, passing that ref along to the timer. If the timer was already running, the ref is discarded.
The timer completion routine can then pass the ref along to the call's work item when it queues it. If the timer or work item where already queued/running, the extra ref is discarded.
--- include/trace/events/rxrpc.h | 8 +++++++- net/rxrpc/ar-internal.h | 15 +++++++-------- net/rxrpc/call_event.c | 2 +- net/rxrpc/call_object.c | 40 +++++++++++++++++++++++++++++++++++----- 4 files changed, 50 insertions(+), 15 deletions(-)
include/trace/events/rxrpc.h +7 -1
@@ -83,12 +83,15 @@ enum rxrpc_call_trace { rxrpc_call_error, rxrpc_call_got, rxrpc_call_got_kernel, + rxrpc_call_got_timer, rxrpc_call_got_userid, rxrpc_call_new_client, rxrpc_call_new_service, rxrpc_call_put, rxrpc_call_put_kernel, rxrpc_call_put_noqueue, + rxrpc_call_put_notimer, + rxrpc_call_put_timer, rxrpc_call_put_userid, rxrpc_call_queued, rxrpc_call_queued_ref,
@@ -278,12 +281,15 @@ enum rxrpc_tx_point { EM(rxrpc_call_error, "*E*") \ EM(rxrpc_call_got, "GOT") \ EM(rxrpc_call_got_kernel, "Gke") \ + EM(rxrpc_call_got_timer, "GTM") \ EM(rxrpc_call_got_userid, "Gus") \ EM(rxrpc_call_new_client, "NWc") \ EM(rxrpc_call_new_service, "NWs") \ EM(rxrpc_call_put, "PUT") \ EM(rxrpc_call_put_kernel, "Pke") \ - EM(rxrpc_call_put_noqueue, "PNQ") \ + EM(rxrpc_call_put_noqueue, "PnQ") \ + EM(rxrpc_call_put_notimer, "PnT") \ + EM(rxrpc_call_put_timer, "PTM") \ EM(rxrpc_call_put_userid, "Pus") \ EM(rxrpc_call_queued, "QUE") \EM (rxrpc_call_queued_ref,"QUR" ) \
net/rxrpc/ar-internal.h +7 -8
@@ -777,14 +777,12 @@ void rxrpc_propose_ACK(struct rxrpc_call enum rxrpc_propose_ack_trace);void rxrpc_process_call (struct work_struct *); -static inline void rxrpc_reduce_call_timer (struct rxrpc_call *call, -unsigned long expire_at, -unsigned long now, -enum rxrpc_timer_trace why) -{ -trace_rxrpc_timer (call, why, now); -timer_reduce (&call->timer, expire_at); -} +void rxrpc_reduce_call_timer (struct rxrpc_call *call, +unsigned long expire_at, +unsigned long now, +enum rxrpc_timer_trace why); + +void rxrpc_delete_call_timer (struct rxrpc_call *call);/* * call_object.c
@@ -808,6 +806,7 @@ void rxrpc_release_calls_on_socket(strucbool __rxrpc_queue_call (struct rxrpc_call *);bool rxrpc_queue_call (struct rxrpc_call *);void rxrpc_see_call (struct rxrpc_call *); +bool rxrpc_try_get_call (struct rxrpc_call *call,enum rxrpc_call_trace op);void rxrpc_get_call (struct rxrpc_call *,enum rxrpc_call_trace );void rxrpc_put_call (struct rxrpc_call *,enum rxrpc_call_trace );void rxrpc_cleanup_call (struct rxrpc_call *);
net/rxrpc/call_event.c +1 -1
@@ -310,7 +310,7 @@ recheck_state: }if (call->state ==RXRPC_CALL_COMPLETE ) { -del_timer_sync (&call->timer); +rxrpc_delete_call_timer (call); goto out_put; }
net/rxrpc/call_object.c +35 -5
@@ -53,10 +53,30 @@ static void rxrpc_call_timer_expired(strif (call->state <RXRPC_CALL_COMPLETE ) {trace_rxrpc_timer (call, rxrpc_timer_expired, jiffies); -rxrpc_queue_call (call); +__rxrpc_queue_call (call); + }else { +rxrpc_put_call (call, rxrpc_call_put); + } +} + +void rxrpc_reduce_call_timer (struct rxrpc_call *call, +unsigned long expire_at, +unsigned long now, +enum rxrpc_timer_trace why) +{ +if (rxrpc_try_get_call (call, rxrpc_call_got_timer)) { +trace_rxrpc_timer (call, why, now); +if (timer_reduce (&call->timer, expire_at)) +rxrpc_put_call (call, rxrpc_call_put_notimer); } } +void rxrpc_delete_call_timer (struct rxrpc_call *call) +{ +if (del_timer_sync (&call->timer)) +rxrpc_put_call (call, rxrpc_call_put_timer); +} +static struct lock_class_key rxrpc_call_user_mutex_lock_class_key;/*
@@ -463,6 +483,17 @@ void rxrpc_see_call(struct rxrpc_call *c } } +bool rxrpc_try_get_call (struct rxrpc_call *call,enum rxrpc_call_trace op) +{ +const void *here =__builtin_return_address (0 ); +int n =atomic_fetch_add_unless (&call->usage,1 ,0 ); + +if (n ==0 ) +return false; +trace_rxrpc_call (call->debug_id, op, n, here,NULL ); +return true; +} +/* * Note the addition of a ref on a call. */
@@ -510,8 +541,7 @@ void rxrpc_release_call(struct rxrpc_socspin_unlock_bh (&call->lock);rxrpc_put_call_slot (call); - -del_timer_sync (&call->timer); +rxrpc_delete_call_timer (call);/* Make sure we don't get any more notifications */ write_lock_bh (&rx->recvmsg_lock);
@@ -618,6 +648,8 @@ static void rxrpc_destroy_call(struct wo struct rxrpc_call *call = container_of(work, struct rxrpc_call, processor);struct rxrpc_net *rxnet = call->rxnet; +rxrpc_delete_call_timer (call); +rxrpc_put_connection (call->conn);rxrpc_put_peer (call->peer);kfree (call->rxtx_buffer);
@@ -652,8 +684,6 @@ void rxrpc_cleanup_call(struct rxrpc_calmemset (&call->sock_node,0xcd ,sizeof (call->sock_node)); -del_timer_sync (&call->timer); - ASSERTCMP(call->state, ==, RXRPC_CALL_COMPLETE);ASSERT (test_bit (RXRPC_CALL_RELEASED , &call->flags));
Greg Kroah-Hartman
maintainerPATCH 937/1017 mailbox: imx: fix wakeup failure from freeze mode
In reply to Greg Kroah-HartmanFrom: Robin Gong <[email protected]>
commit 892cb524ae8a27bf5e42f711318371acd9a9f74a upstream.
Since IRQF_NO_SUSPEND used for imx mailbox driver, that means this irq can't be used for wakeup source so that can't wakeup from freeze mode. Add pm_system_wakeup() to wakeup from freeze mode.
--- drivers/mailbox/imx-mailbox.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/mailbox/imx-mailbox.c +9 -0
@@ -14,6 +14,7 @@#include <linux/module.h> #include <linux/of_device.h> #include <linux/pm_runtime.h> +#include <linux/suspend.h> #include <linux/slab.h> #define IMX_MU_CHANS 16
@@ -76,6 +77,7 @@ struct imx_mu_priv {const struct imx_mu_dcfg *dcfg;struct clk *clk;int irq; +bool suspend;u32 xcr[4 ];
@@ -334,6 +336,9 @@ static irqreturn_t imx_mu_isr(int irq, vreturn IRQ_NONE ; } +if (priv->suspend) +pm_system_wakeup (); +return IRQ_HANDLED ; }
@@ -702,6 +707,8 @@ static int __maybe_unused imx_mu_suspend priv->xcr[i] =imx_mu_read (priv, priv->dcfg->xCR[i]); } + priv->suspend = true; +return 0 ; }
@@ -723,6 +730,8 @@ static int __maybe_unused imx_mu_resume_imx_mu_write (priv, priv->xcr[i], priv->dcfg->xCR[i]); } + priv->suspend = false; +return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 938/1017 crypto: arm/aes-neonbs-cbc - Select generic cbc and aes
In reply to Greg Kroah-HartmanFrom: Herbert Xu <[email protected]>
commit c8bd296cca3434b13b28b074eaeb78a23284de77 upstream.
The algorithm __cbc-aes-neonbs requires a fallback so we need to select the config options for them or otherwise it will fail to register on boot-up.
--- arch/arm/crypto/Kconfig | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/crypto/Kconfig +2 -0
@@ -102,6 +102,8 @@ config CRYPTO_AES_ARM_BS depends on KERNEL_MODE_NEON select CRYPTO_SKCIPHER select CRYPTO_LIB_AES + select CRYPTO_AES + select CRYPTO_CBC select CRYPTO_SIMD help Use a faster and more secure NEON based implementation of AES in CBC,
Greg Kroah-Hartman
maintainerPATCH 939/1017 watch_queue: Free the page array when watch_queue is dismantled
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
commit b490207017ba237d97b735b2aa66dc241ccd18f5 upstream.
Commit 7ea1a0124b6d ("watch_queue: Free the alloc bitmap when the watch_queue is torn down") took care of the bitmap, but not the page array.
BUG: memory leak
unreferenced object 0xffff88810d9bc140 (size 32):
comm "syz-executor335", pid 3603, jiffies 4294946994 (age 12.840s)
hex dump (first 32 bytes):
40 a7 40 04 00 ea ff ff 00 00 00 00 00 00 00 00 @.@.............
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
kmalloc_array include/linux/slab.h:621 [inline]
kcalloc include/linux/slab.h:652 [inline]
watch_queue_set_size+0x12f/0x2e0 kernel/watch_queue.c:251
pipe_ioctl+0x82/0x140 fs/pipe.c:632
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:874 [inline]
__se_sys_ioctl fs/ioctl.c:860 [inline]
__x64_sys_ioctl+0xfc/0x140 fs/ioctl.c:860
do_syscall_x64 arch/x86/entry/common.c:50 [inline]--- kernel/watch_queue.c | 1 + 1 file changed, 1 insertion(+)
kernel/watch_queue.c +1 -0
@@ -373,6 +373,7 @@ static void __put_watch_queue(struct krefor (i =0 ; i < wqueue->nr_pages; i++)__free_page (wqueue->notes[i]); +kfree (wqueue->notes);bitmap_free (wqueue->notes_bitmap); wfilter =rcu_access_pointer (wqueue->filter);
Greg Kroah-Hartman
maintainerPATCH 940/1017 pinctrl: pinconf-generic: Print arguments for bias-pull-*
In reply to Greg Kroah-HartmanFrom: Chen-Yu Tsai <[email protected]>
commit 188e5834b930acd03ad3cf7c5e7aa24db9665a29 upstream.
The bias-pull-* properties, or PIN_CONFIG_BIAS_PULL_* pin config parameters, accept optional arguments in ohms denoting the strength of the pin bias.
Print these values out in debugfs as well.
--- drivers/pinctrl/pinconf-generic.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/pinctrl/pinconf-generic.c +3 -3
@@ -30,10 +30,10 @@ static const struct pin_config_item confPCONFDUMP (PIN_CONFIG_BIAS_BUS_HOLD ,"input bias bus hold" ,NULL , false),PCONFDUMP (PIN_CONFIG_BIAS_DISABLE ,"input bias disabled" ,NULL , false),PCONFDUMP (PIN_CONFIG_BIAS_HIGH_IMPEDANCE ,"input bias high impedance" ,NULL , false), -PCONFDUMP (PIN_CONFIG_BIAS_PULL_DOWN ,"input bias pull down" ,NULL , false), +PCONFDUMP (PIN_CONFIG_BIAS_PULL_DOWN ,"input bias pull down" ,"ohms" , true),PCONFDUMP (PIN_CONFIG_BIAS_PULL_PIN_DEFAULT , -"input bias pull to pin specific state" ,NULL , false), -PCONFDUMP (PIN_CONFIG_BIAS_PULL_UP ,"input bias pull up" ,NULL , false), +"input bias pull to pin specific state" ,"ohms" , true), +PCONFDUMP (PIN_CONFIG_BIAS_PULL_UP ,"input bias pull up" ,"ohms" , true),PCONFDUMP (PIN_CONFIG_DRIVE_OPEN_DRAIN ,"output drive open drain" ,NULL , false),PCONFDUMP (PIN_CONFIG_DRIVE_OPEN_SOURCE ,"output drive open source" ,NULL , false), PCONFDUMP(PIN_CONFIG_DRIVE_PUSH_PULL, "output drive push pull", NULL, false),
Greg Kroah-Hartman
maintainerPATCH 941/1017 watchdog: rti-wdt: Add missing pm_runtime_disable() in probe function
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
commit d055ef3a2c6919cff504ae3b710c96318d545fd2 upstream.
If the probe fails, we should use pm_runtime_disable() to balance pm_runtime_enable().
--- drivers/watchdog/rti_wdt.c | 1 + 1 file changed, 1 insertion(+)
drivers/watchdog/rti_wdt.c +1 -0
@@ -228,6 +228,7 @@ static int rti_wdt_probe(struct platform ret =pm_runtime_get_sync (dev);if (ret) {pm_runtime_put_noidle (dev); +pm_runtime_disable (&pdev->dev);return dev_err_probe (dev, ret,"runtime pm failed\n" ); }
Greg Kroah-Hartman
maintainerPATCH 942/1017 net: sparx5: uses, depends on BRIDGE or !BRIDGE
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
commit f9512d654f62604664251dedd437a22fe484974a upstream.
Fix build errors when BRIDGE=m and SPARX5_SWITCH=y:
riscv64-linux-ld: drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.o: in function `.L305':
sparx5_switchdev.c:(.text+0xdb0): undefined reference to `br_vlan_enabled'
riscv64-linux-ld: drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.o: in function `.L283':
sparx5_switchdev.c:(.text+0xee0): undefined reference to `br_vlan_enabled'
--- drivers/net/ethernet/microchip/sparx5/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/microchip/sparx5/Kconfig +1 -0
@@ -5,6 +5,7 @@ config SPARX5_SWITCH depends on OF depends on ARCH_SPARX5 || COMPILE_TEST depends on PTP_1588_CLOCK_OPTIONAL + depends on BRIDGE || BRIDGE=n select PHYLINK select PHY_SPARX5_SERDES select RESET_CONTROLLER
Greg Kroah-Hartman
maintainerPATCH 943/1017 pinctrl: nuvoton: npcm7xx: Rename DS() macro to DSTR()
In reply to Greg Kroah-HartmanFrom: Jonathan Neuschäfer <[email protected]>
commit 603501c16431c56f74eaef1ee1390f60a30c2187 upstream.
The name "DS" is defined in arch/x86/um/shared/sysdep/ptrace_64.h, which results in a compiler warning when build-testing on ARCH=um. Rename this driver's "DS" macro to DSTR so avoid this collision.
--- drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c | 156 +++++++++++++++--------------- 1 file changed, 78 insertions(+), 78 deletions(-)
drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c +78 -78
@@ -904,7 +904,7 @@ static struct npcm7xx_func npcm7xx_funcs#define DRIVE_STRENGTH_HI_SHIFT 12#define DRIVE_STRENGTH_MASK 0x0000FF00 -#define DS (lo, hi) (((lo) << DRIVE_STRENGTH_LO_SHIFT) | \ +#define DSTR (lo, hi) (((lo) << DRIVE_STRENGTH_LO_SHIFT) | \ ((hi) << DRIVE_STRENGTH_HI_SHIFT))#define DSLO (x) (((x) >> DRIVE_STRENGTH_LO_SHIFT) & 0xF)#define DSHI (x) (((x) >> DRIVE_STRENGTH_HI_SHIFT) & 0xF)
@@ -924,31 +924,31 @@ struct npcm7xx_pincfg {static const struct npcm7xx_pincfg pincfg[] = {/* PIN FUNCTION 1 FUNCTION 2 FUNCTION 3 FLAGS */ NPCM7XX_PINCFG (0 , iox1,MFSEL1 ,30 , none,NONE ,0 , none,NONE ,0 ,0 ), -NPCM7XX_PINCFG (1 , iox1,MFSEL1 ,30 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 )), -NPCM7XX_PINCFG (2 , iox1,MFSEL1 ,30 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 )), +NPCM7XX_PINCFG (1 , iox1,MFSEL1 ,30 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 )), +NPCM7XX_PINCFG (2 , iox1,MFSEL1 ,30 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 )),NPCM7XX_PINCFG (3 , iox1,MFSEL1 ,30 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (4 , iox2,MFSEL3 ,14 , smb1d,I2CSEGSEL ,7 , none,NONE ,0 ,SLEW ),NPCM7XX_PINCFG (5 , iox2,MFSEL3 ,14 , smb1d,I2CSEGSEL ,7 , none,NONE ,0 ,SLEW ),NPCM7XX_PINCFG (6 , iox2,MFSEL3 ,14 , smb2d,I2CSEGSEL ,10 , none,NONE ,0 ,SLEW ),NPCM7XX_PINCFG (7 , iox2,MFSEL3 ,14 , smb2d,I2CSEGSEL ,10 , none,NONE ,0 ,SLEW ), -NPCM7XX_PINCFG (8 , lkgpo1,FLOCKR1 ,4 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 )), -NPCM7XX_PINCFG (9 , lkgpo2,FLOCKR1 ,8 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 )), -NPCM7XX_PINCFG (10 , ioxh,MFSEL3 ,18 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 )), -NPCM7XX_PINCFG (11 , ioxh,MFSEL3 ,18 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 )), +NPCM7XX_PINCFG (8 , lkgpo1,FLOCKR1 ,4 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 )), +NPCM7XX_PINCFG (9 , lkgpo2,FLOCKR1 ,8 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 )), +NPCM7XX_PINCFG (10 , ioxh,MFSEL3 ,18 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 )), +NPCM7XX_PINCFG (11 , ioxh,MFSEL3 ,18 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 )),NPCM7XX_PINCFG (12 , gspi,MFSEL1 ,24 , smb5b,I2CSEGSEL ,19 , none,NONE ,0 ,SLEW ),NPCM7XX_PINCFG (13 , gspi,MFSEL1 ,24 , smb5b,I2CSEGSEL ,19 , none,NONE ,0 ,SLEW ),NPCM7XX_PINCFG (14 , gspi,MFSEL1 ,24 , smb5c,I2CSEGSEL ,20 , none,NONE ,0 ,SLEW ),NPCM7XX_PINCFG (15 , gspi,MFSEL1 ,24 , smb5c,I2CSEGSEL ,20 , none,NONE ,0 ,SLEW ), -NPCM7XX_PINCFG (16 , lkgpo0,FLOCKR1 ,0 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 )), -NPCM7XX_PINCFG (17 , pspi2,MFSEL3 ,13 , smb4den,I2CSEGSEL ,23 , none,NONE ,0 ,DS (8 ,12 )), -NPCM7XX_PINCFG (18 , pspi2,MFSEL3 ,13 , smb4b,I2CSEGSEL ,14 , none,NONE ,0 ,DS (8 ,12 )), -NPCM7XX_PINCFG (19 , pspi2,MFSEL3 ,13 , smb4b,I2CSEGSEL ,14 , none,NONE ,0 ,DS (8 ,12 )), +NPCM7XX_PINCFG (16 , lkgpo0,FLOCKR1 ,0 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 )), +NPCM7XX_PINCFG (17 , pspi2,MFSEL3 ,13 , smb4den,I2CSEGSEL ,23 , none,NONE ,0 ,DSTR (8 ,12 )), +NPCM7XX_PINCFG (18 , pspi2,MFSEL3 ,13 , smb4b,I2CSEGSEL ,14 , none,NONE ,0 ,DSTR (8 ,12 )), +NPCM7XX_PINCFG (19 , pspi2,MFSEL3 ,13 , smb4b,I2CSEGSEL ,14 , none,NONE ,0 ,DSTR (8 ,12 )),NPCM7XX_PINCFG (20 , smb4c,I2CSEGSEL ,15 , smb15,MFSEL3 ,8 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (21 , smb4c,I2CSEGSEL ,15 , smb15,MFSEL3 ,8 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (22 , smb4d,I2CSEGSEL ,16 , smb14,MFSEL3 ,7 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (23 , smb4d,I2CSEGSEL ,16 , smb14,MFSEL3 ,7 , none,NONE ,0 ,0 ), -NPCM7XX_PINCFG (24 , ioxh,MFSEL3 ,18 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 )), -NPCM7XX_PINCFG (25 , ioxh,MFSEL3 ,18 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 )), +NPCM7XX_PINCFG (24 , ioxh,MFSEL3 ,18 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 )), +NPCM7XX_PINCFG (25 , ioxh,MFSEL3 ,18 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 )),NPCM7XX_PINCFG (26 , smb5,MFSEL1 ,2 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (27 , smb5,MFSEL1 ,2 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (28 , smb4,MFSEL1 ,1 , none,NONE ,0 , none,NONE ,0 ,0 ),
@@ -964,12 +964,12 @@ static const struct npcm7xx_pincfg pincfNPCM7XX_PINCFG (39 , smb3b,I2CSEGSEL ,11 , none,NONE ,0 , none,NONE ,0 ,SLEW ),NPCM7XX_PINCFG (40 , smb3b,I2CSEGSEL ,11 , none,NONE ,0 , none,NONE ,0 ,SLEW ),NPCM7XX_PINCFG (41 , bmcuart0a,MFSEL1 ,9 , none,NONE ,0 , none,NONE ,0 ,0 ), -NPCM7XX_PINCFG (42 , bmcuart0a,MFSEL1 ,9 , none,NONE ,0 , none,NONE ,0 ,DS (2 ,4 ) |GPO ), +NPCM7XX_PINCFG (42 , bmcuart0a,MFSEL1 ,9 , none,NONE ,0 , none,NONE ,0 ,DSTR (2 ,4 ) |GPO ),NPCM7XX_PINCFG (43 , uart1,MFSEL1 ,10 , jtag2,MFSEL4 ,0 , bmcuart1,MFSEL3 ,24 ,0 ),NPCM7XX_PINCFG (44 , uart1,MFSEL1 ,10 , jtag2,MFSEL4 ,0 , bmcuart1,MFSEL3 ,24 ,0 ),NPCM7XX_PINCFG (45 , uart1,MFSEL1 ,10 , jtag2,MFSEL4 ,0 , none,NONE ,0 ,0 ), -NPCM7XX_PINCFG (46 , uart1,MFSEL1 ,10 , jtag2,MFSEL4 ,0 , none,NONE ,0 ,DS (2 ,8 )), -NPCM7XX_PINCFG (47 , uart1,MFSEL1 ,10 , jtag2,MFSEL4 ,0 , none,NONE ,0 ,DS (2 ,8 )), +NPCM7XX_PINCFG (46 , uart1,MFSEL1 ,10 , jtag2,MFSEL4 ,0 , none,NONE ,0 ,DSTR (2 ,8 )), +NPCM7XX_PINCFG (47 , uart1,MFSEL1 ,10 , jtag2,MFSEL4 ,0 , none,NONE ,0 ,DSTR (2 ,8 )),NPCM7XX_PINCFG (48 , uart2,MFSEL1 ,11 , bmcuart0b,MFSEL4 ,1 , none,NONE ,0 ,GPO ),NPCM7XX_PINCFG (49 , uart2,MFSEL1 ,11 , bmcuart0b,MFSEL4 ,1 , none,NONE ,0 ,0 ), NPCM7XX_PINCFG(50, uart2, MFSEL1, 11, none, NONE, 0, none, NONE, 0, 0),
@@ -979,8 +979,8 @@ static const struct npcm7xx_pincfg pincfNPCM7XX_PINCFG (54 , uart2,MFSEL1 ,11 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (55 , uart2,MFSEL1 ,11 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (56 , r1err,MFSEL1 ,12 , none,NONE ,0 , none,NONE ,0 ,0 ), -NPCM7XX_PINCFG (57 , r1md,MFSEL1 ,13 , none,NONE ,0 , none,NONE ,0 ,DS (2 ,4 )), -NPCM7XX_PINCFG (58 , r1md,MFSEL1 ,13 , none,NONE ,0 , none,NONE ,0 ,DS (2 ,4 )), +NPCM7XX_PINCFG (57 , r1md,MFSEL1 ,13 , none,NONE ,0 , none,NONE ,0 ,DSTR (2 ,4 )), +NPCM7XX_PINCFG (58 , r1md,MFSEL1 ,13 , none,NONE ,0 , none,NONE ,0 ,DSTR (2 ,4 )),NPCM7XX_PINCFG (59 , smb3d,I2CSEGSEL ,13 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (60 , smb3d,I2CSEGSEL ,13 , none,NONE ,0 , none,NONE ,0 ,0 ), NPCM7XX_PINCFG(61, uart1, MFSEL1, 10, none, NONE, 0, none, NONE, 0, GPO),
@@ -1003,19 +1003,19 @@ static const struct npcm7xx_pincfg pincfNPCM7XX_PINCFG (77 , fanin13,MFSEL2 ,13 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (78 , fanin14,MFSEL2 ,14 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (79 , fanin15,MFSEL2 ,15 , none,NONE ,0 , none,NONE ,0 ,0 ), -NPCM7XX_PINCFG (80 , pwm0,MFSEL2 ,16 , none,NONE ,0 , none,NONE ,0 ,DS (4 ,8 )), -NPCM7XX_PINCFG (81 , pwm1,MFSEL2 ,17 , none,NONE ,0 , none,NONE ,0 ,DS (4 ,8 )), -NPCM7XX_PINCFG (82 , pwm2,MFSEL2 ,18 , none,NONE ,0 , none,NONE ,0 ,DS (4 ,8 )), -NPCM7XX_PINCFG (83 , pwm3,MFSEL2 ,19 , none,NONE ,0 , none,NONE ,0 ,DS (4 ,8 )), -NPCM7XX_PINCFG (84 , r2,MFSEL1 ,14 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (85 , r2,MFSEL1 ,14 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (86 , r2,MFSEL1 ,14 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (80 , pwm0,MFSEL2 ,16 , none,NONE ,0 , none,NONE ,0 ,DSTR (4 ,8 )), +NPCM7XX_PINCFG (81 , pwm1,MFSEL2 ,17 , none,NONE ,0 , none,NONE ,0 ,DSTR (4 ,8 )), +NPCM7XX_PINCFG (82 , pwm2,MFSEL2 ,18 , none,NONE ,0 , none,NONE ,0 ,DSTR (4 ,8 )), +NPCM7XX_PINCFG (83 , pwm3,MFSEL2 ,19 , none,NONE ,0 , none,NONE ,0 ,DSTR (4 ,8 )), +NPCM7XX_PINCFG (84 , r2,MFSEL1 ,14 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (85 , r2,MFSEL1 ,14 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (86 , r2,MFSEL1 ,14 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ),NPCM7XX_PINCFG (87 , r2,MFSEL1 ,14 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (88 , r2,MFSEL1 ,14 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (89 , r2,MFSEL1 ,14 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (90 , r2err,MFSEL1 ,15 , none,NONE ,0 , none,NONE ,0 ,0 ), -NPCM7XX_PINCFG (91 , r2md,MFSEL1 ,16 , none,NONE ,0 , none,NONE ,0 ,DS (2 ,4 )), -NPCM7XX_PINCFG (92 , r2md,MFSEL1 ,16 , none,NONE ,0 , none,NONE ,0 ,DS (2 ,4 )), +NPCM7XX_PINCFG (91 , r2md,MFSEL1 ,16 , none,NONE ,0 , none,NONE ,0 ,DSTR (2 ,4 )), +NPCM7XX_PINCFG (92 , r2md,MFSEL1 ,16 , none,NONE ,0 , none,NONE ,0 ,DSTR (2 ,4 )),NPCM7XX_PINCFG (93 , ga20kbc,MFSEL1 ,17 , smb5d,I2CSEGSEL ,21 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (94 , ga20kbc,MFSEL1 ,17 , smb5d,I2CSEGSEL ,21 , none,NONE ,0 ,0 ), NPCM7XX_PINCFG(95, lpc, NONE, 0, espi, MFSEL4, 8, gpio, MFSEL1, 26, 0),
@@ -1061,34 +1061,34 @@ static const struct npcm7xx_pincfg pincfNPCM7XX_PINCFG (133 , smb10,MFSEL4 ,13 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (134 , smb11,MFSEL4 ,14 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (135 , smb11,MFSEL4 ,14 , none,NONE ,0 , none,NONE ,0 ,0 ), -NPCM7XX_PINCFG (136 , sd1,MFSEL3 ,12 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (137 , sd1,MFSEL3 ,12 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (138 , sd1,MFSEL3 ,12 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (139 , sd1,MFSEL3 ,12 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (140 , sd1,MFSEL3 ,12 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (136 , sd1,MFSEL3 ,12 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (137 , sd1,MFSEL3 ,12 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (138 , sd1,MFSEL3 ,12 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (139 , sd1,MFSEL3 ,12 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (140 , sd1,MFSEL3 ,12 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ),NPCM7XX_PINCFG (141 , sd1,MFSEL3 ,12 , none,NONE ,0 , none,NONE ,0 ,0 ), -NPCM7XX_PINCFG (142 , sd1,MFSEL3 ,12 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (142 , sd1,MFSEL3 ,12 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ),NPCM7XX_PINCFG (143 , sd1,MFSEL3 ,12 , sd1pwr,MFSEL4 ,5 , none,NONE ,0 ,0 ), -NPCM7XX_PINCFG (144 , pwm4,MFSEL2 ,20 , none,NONE ,0 , none,NONE ,0 ,DS (4 ,8 )), -NPCM7XX_PINCFG (145 , pwm5,MFSEL2 ,21 , none,NONE ,0 , none,NONE ,0 ,DS (4 ,8 )), -NPCM7XX_PINCFG (146 , pwm6,MFSEL2 ,22 , none,NONE ,0 , none,NONE ,0 ,DS (4 ,8 )), -NPCM7XX_PINCFG (147 , pwm7,MFSEL2 ,23 , none,NONE ,0 , none,NONE ,0 ,DS (4 ,8 )), -NPCM7XX_PINCFG (148 , mmc8,MFSEL3 ,11 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (149 , mmc8,MFSEL3 ,11 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (150 , mmc8,MFSEL3 ,11 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (151 , mmc8,MFSEL3 ,11 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (152 , mmc,MFSEL3 ,10 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (144 , pwm4,MFSEL2 ,20 , none,NONE ,0 , none,NONE ,0 ,DSTR (4 ,8 )), +NPCM7XX_PINCFG (145 , pwm5,MFSEL2 ,21 , none,NONE ,0 , none,NONE ,0 ,DSTR (4 ,8 )), +NPCM7XX_PINCFG (146 , pwm6,MFSEL2 ,22 , none,NONE ,0 , none,NONE ,0 ,DSTR (4 ,8 )), +NPCM7XX_PINCFG (147 , pwm7,MFSEL2 ,23 , none,NONE ,0 , none,NONE ,0 ,DSTR (4 ,8 )), +NPCM7XX_PINCFG (148 , mmc8,MFSEL3 ,11 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (149 , mmc8,MFSEL3 ,11 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (150 , mmc8,MFSEL3 ,11 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (151 , mmc8,MFSEL3 ,11 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (152 , mmc,MFSEL3 ,10 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ),NPCM7XX_PINCFG (153 , mmcwp,FLOCKR1 ,24 , none,NONE ,0 , none,NONE ,0 ,0 ),/* Z1/A1 */ -NPCM7XX_PINCFG (154 , mmc,MFSEL3 ,10 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (154 , mmc,MFSEL3 ,10 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ),NPCM7XX_PINCFG (155 , mmccd,MFSEL3 ,25 , mmcrst,MFSEL4 ,6 , none,NONE ,0 ,0 ),/* Z1/A1 */ -NPCM7XX_PINCFG (156 , mmc,MFSEL3 ,10 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (157 , mmc,MFSEL3 ,10 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (158 , mmc,MFSEL3 ,10 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (159 , mmc,MFSEL3 ,10 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), - -NPCM7XX_PINCFG (160 , clkout,MFSEL1 ,21 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (161 , lpc,NONE ,0 , espi,MFSEL4 ,8 , gpio,MFSEL1 ,26 ,DS (8 ,12 )), -NPCM7XX_PINCFG (162 , serirq,NONE ,0 , gpio,MFSEL1 ,31 , none,NONE ,0 ,DS (8 ,12 )), +NPCM7XX_PINCFG (156 , mmc,MFSEL3 ,10 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (157 , mmc,MFSEL3 ,10 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (158 , mmc,MFSEL3 ,10 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (159 , mmc,MFSEL3 ,10 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), + +NPCM7XX_PINCFG (160 , clkout,MFSEL1 ,21 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (161 , lpc,NONE ,0 , espi,MFSEL4 ,8 , gpio,MFSEL1 ,26 ,DSTR (8 ,12 )), +NPCM7XX_PINCFG (162 , serirq,NONE ,0 , gpio,MFSEL1 ,31 , none,NONE ,0 ,DSTR (8 ,12 )),NPCM7XX_PINCFG (163 , lpc,NONE ,0 , espi,MFSEL4 ,8 , gpio,MFSEL1 ,26 ,0 ),NPCM7XX_PINCFG (164 , lpc,NONE ,0 , espi,MFSEL4 ,8 , gpio,MFSEL1 ,26 ,SLEWLPC ), NPCM7XX_PINCFG(165, lpc, NONE, 0, espi, MFSEL4, 8, gpio, MFSEL1, 26, SLEWLPC),
@@ -1101,25 +1101,25 @@ static const struct npcm7xx_pincfg pincfNPCM7XX_PINCFG (172 , smb6,MFSEL3 ,1 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (173 , smb7,MFSEL3 ,2 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (174 , smb7,MFSEL3 ,2 , none,NONE ,0 , none,NONE ,0 ,0 ), -NPCM7XX_PINCFG (175 , pspi1,MFSEL3 ,4 , faninx,MFSEL3 ,3 , none,NONE ,0 ,DS (8 ,12 )), -NPCM7XX_PINCFG (176 , pspi1,MFSEL3 ,4 , faninx,MFSEL3 ,3 , none,NONE ,0 ,DS (8 ,12 )), -NPCM7XX_PINCFG (177 , pspi1,MFSEL3 ,4 , faninx,MFSEL3 ,3 , none,NONE ,0 ,DS (8 ,12 )), -NPCM7XX_PINCFG (178 , r1,MFSEL3 ,9 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (179 , r1,MFSEL3 ,9 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (180 , r1,MFSEL3 ,9 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (175 , pspi1,MFSEL3 ,4 , faninx,MFSEL3 ,3 , none,NONE ,0 ,DSTR (8 ,12 )), +NPCM7XX_PINCFG (176 , pspi1,MFSEL3 ,4 , faninx,MFSEL3 ,3 , none,NONE ,0 ,DSTR (8 ,12 )), +NPCM7XX_PINCFG (177 , pspi1,MFSEL3 ,4 , faninx,MFSEL3 ,3 , none,NONE ,0 ,DSTR (8 ,12 )), +NPCM7XX_PINCFG (178 , r1,MFSEL3 ,9 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (179 , r1,MFSEL3 ,9 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (180 , r1,MFSEL3 ,9 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ),NPCM7XX_PINCFG (181 , r1,MFSEL3 ,9 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (182 , r1,MFSEL3 ,9 , none,NONE ,0 , none,NONE ,0 ,0 ), -NPCM7XX_PINCFG (183 , spi3,MFSEL4 ,16 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (184 , spi3,MFSEL4 ,16 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW |GPO ), -NPCM7XX_PINCFG (185 , spi3,MFSEL4 ,16 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW |GPO ), -NPCM7XX_PINCFG (186 , spi3,MFSEL4 ,16 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 )), -NPCM7XX_PINCFG (187 , spi3cs1,MFSEL4 ,17 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 )), -NPCM7XX_PINCFG (188 , spi3quad,MFSEL4 ,20 , spi3cs2,MFSEL4 ,18 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (189 , spi3quad,MFSEL4 ,20 , spi3cs3,MFSEL4 ,19 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (190 , gpio,FLOCKR1 ,20 , nprd_smi,NONE ,0 , none,NONE ,0 ,DS (2 ,4 )), -NPCM7XX_PINCFG (191 , none,NONE ,0 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 )),/* XX */ +NPCM7XX_PINCFG (183 , spi3,MFSEL4 ,16 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (184 , spi3,MFSEL4 ,16 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW |GPO ), +NPCM7XX_PINCFG (185 , spi3,MFSEL4 ,16 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW |GPO ), +NPCM7XX_PINCFG (186 , spi3,MFSEL4 ,16 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 )), +NPCM7XX_PINCFG (187 , spi3cs1,MFSEL4 ,17 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 )), +NPCM7XX_PINCFG (188 , spi3quad,MFSEL4 ,20 , spi3cs2,MFSEL4 ,18 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (189 , spi3quad,MFSEL4 ,20 , spi3cs3,MFSEL4 ,19 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (190 , gpio,FLOCKR1 ,20 , nprd_smi,NONE ,0 , none,NONE ,0 ,DSTR (2 ,4 )), +NPCM7XX_PINCFG (191 , none,NONE ,0 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 )),/* XX */ -NPCM7XX_PINCFG (192 , none,NONE ,0 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 )),/* XX */ +NPCM7XX_PINCFG (192 , none,NONE ,0 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 )),/* XX */ NPCM7XX_PINCFG (193 , r1,MFSEL3 ,9 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (194 , smb0b,I2CSEGSEL ,0 , none,NONE ,0 , none,NONE ,0 ,0 ), NPCM7XX_PINCFG(195, smb0b, I2CSEGSEL, 0, none, NONE, 0, none, NONE, 0, 0),
@@ -1130,11 +1130,11 @@ static const struct npcm7xx_pincfg pincfNPCM7XX_PINCFG (200 , r2,MFSEL1 ,14 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (201 , r1,MFSEL3 ,9 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (202 , smb0c,I2CSEGSEL ,1 , none,NONE ,0 , none,NONE ,0 ,0 ), -NPCM7XX_PINCFG (203 , faninx,MFSEL3 ,3 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 )), +NPCM7XX_PINCFG (203 , faninx,MFSEL3 ,3 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 )),NPCM7XX_PINCFG (204 , ddc,NONE ,0 , gpio,MFSEL3 ,22 , none,NONE ,0 ,SLEW ),NPCM7XX_PINCFG (205 , ddc,NONE ,0 , gpio,MFSEL3 ,22 , none,NONE ,0 ,SLEW ), -NPCM7XX_PINCFG (206 , ddc,NONE ,0 , gpio,MFSEL3 ,22 , none,NONE ,0 ,DS (4 ,8 )), -NPCM7XX_PINCFG (207 , ddc,NONE ,0 , gpio,MFSEL3 ,22 , none,NONE ,0 ,DS (4 ,8 )), +NPCM7XX_PINCFG (206 , ddc,NONE ,0 , gpio,MFSEL3 ,22 , none,NONE ,0 ,DSTR (4 ,8 )), +NPCM7XX_PINCFG (207 , ddc,NONE ,0 , gpio,MFSEL3 ,22 , none,NONE ,0 ,DSTR (4 ,8 )),NPCM7XX_PINCFG (208 , rg2,MFSEL4 ,24 , ddr,MFSEL3 ,26 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (209 , rg2,MFSEL4 ,24 , ddr,MFSEL3 ,26 , none,NONE ,0 ,0 ), NPCM7XX_PINCFG(210, rg2, MFSEL4, 24, ddr, MFSEL3, 26, none, NONE, 0, 0),
@@ -1146,20 +1146,20 @@ static const struct npcm7xx_pincfg pincfNPCM7XX_PINCFG (216 , rg2mdio,MFSEL4 ,23 , ddr,MFSEL3 ,26 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (217 , rg2mdio,MFSEL4 ,23 , ddr,MFSEL3 ,26 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (218 , wdog1,MFSEL3 ,19 , none,NONE ,0 , none,NONE ,0 ,0 ), -NPCM7XX_PINCFG (219 , wdog2,MFSEL3 ,20 , none,NONE ,0 , none,NONE ,0 ,DS (4 ,8 )), +NPCM7XX_PINCFG (219 , wdog2,MFSEL3 ,20 , none,NONE ,0 , none,NONE ,0 ,DSTR (4 ,8 )),NPCM7XX_PINCFG (220 , smb12,MFSEL3 ,5 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (221 , smb12,MFSEL3 ,5 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (222 , smb13,MFSEL3 ,6 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (223 , smb13,MFSEL3 ,6 , none,NONE ,0 , none,NONE ,0 ,0 ),NPCM7XX_PINCFG (224 , spix,MFSEL4 ,27 , none,NONE ,0 , none,NONE ,0 ,SLEW ), -NPCM7XX_PINCFG (225 , spix,MFSEL4 ,27 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW |GPO ), -NPCM7XX_PINCFG (226 , spix,MFSEL4 ,27 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW |GPO ), -NPCM7XX_PINCFG (227 , spix,MFSEL4 ,27 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (228 , spixcs1,MFSEL4 ,28 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (229 , spix,MFSEL4 ,27 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (230 , spix,MFSEL4 ,27 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 ) |SLEW ), -NPCM7XX_PINCFG (231 , clkreq,MFSEL4 ,9 , none,NONE ,0 , none,NONE ,0 ,DS (8 ,12 )), +NPCM7XX_PINCFG (225 , spix,MFSEL4 ,27 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW |GPO ), +NPCM7XX_PINCFG (226 , spix,MFSEL4 ,27 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW |GPO ), +NPCM7XX_PINCFG (227 , spix,MFSEL4 ,27 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (228 , spixcs1,MFSEL4 ,28 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (229 , spix,MFSEL4 ,27 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (230 , spix,MFSEL4 ,27 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 ) |SLEW ), +NPCM7XX_PINCFG (231 , clkreq,MFSEL4 ,9 , none,NONE ,0 , none,NONE ,0 ,DSTR (8 ,12 )),NPCM7XX_PINCFG (253 , none,NONE ,0 , none,NONE ,0 , none,NONE ,0 ,GPI ),/* SDHC1 power */ NPCM7XX_PINCFG (254 , none,NONE ,0 , none,NONE ,0 , none,NONE ,0 ,GPI ),/* SDHC2 power */ NPCM7XX_PINCFG(255, none, NONE, 0, none, NONE, 0, none, NONE, 0, GPI), /* DACOSEL */
Greg Kroah-Hartman
maintainerPATCH 944/1017 pinctrl: nuvoton: npcm7xx: Use %zu printk format for ARRAY_SIZE()
In reply to Greg Kroah-HartmanFrom: Jonathan Neuschäfer <[email protected]>
commit 9d0f18bca3b557ae5d2128661ac06d33b3f45c0a upstream.
When compile-testing on 64-bit architectures, GCC complains about the mismatch of types between the %d format specifier and value returned by ARRAY_LENGTH(). Use %zu, which is correct everywhere.
--- drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c +1 -1
@@ -1560,7 +1560,7 @@ static int npcm7xx_get_groups_count(stru {struct npcm7xx_pinctrl *npcm =pinctrl_dev_get_drvdata (pctldev); -dev_dbg (npcm->dev,"group size: %d\n" ,ARRAY_SIZE (npcm7xx_groups)); +dev_dbg (npcm->dev,"group size: %zu\n" ,ARRAY_SIZE (npcm7xx_groups));return ARRAY_SIZE (npcm7xx_groups); }
Greg Kroah-Hartman
maintainerPATCH 945/1017 ASoC: rockchip: i2s_tdm: Fixup config for SND_SOC_DAIFMT_DSP_A/B
In reply to Greg Kroah-HartmanFrom: Meng Tang <[email protected]>
commit 2f45a4e2897793cc6ae25f5fe78b485ce7fd01d0 upstream.
SND_SOC_DAIFMT_DSP_A: PCM delay 1 bit mode, L data MSB after FRM LRCSND_SOC_DAIFMT_DSP_B: PCM no delay mode, L data MSB during FRM LRC
--- sound/soc/rockchip/rockchip_i2s_tdm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
sound/soc/rockchip/rockchip_i2s_tdm.c +5 -5
@@ -469,14 +469,14 @@ static int rockchip_i2s_tdm_set_fmt(stru txcr_val =I2S_TXCR_IBM_NORMAL ; rxcr_val =I2S_RXCR_IBM_NORMAL ;break ; -case SND_SOC_DAIFMT_DSP_A :/* PCM no delay mode */ - txcr_val =I2S_TXCR_TFS_PCM ; - rxcr_val =I2S_RXCR_TFS_PCM ; -break ; -case SND_SOC_DAIFMT_DSP_B :/* PCM delay 1 mode */ +case SND_SOC_DAIFMT_DSP_A :/* PCM delay 1 mode */ txcr_val =I2S_TXCR_TFS_PCM |I2S_TXCR_PBM_MODE (1 ); rxcr_val =I2S_RXCR_TFS_PCM |I2S_RXCR_PBM_MODE (1 );break ; +case SND_SOC_DAIFMT_DSP_B :/* PCM no delay mode */ + txcr_val =I2S_TXCR_TFS_PCM ; + rxcr_val =I2S_RXCR_TFS_PCM ; +break ;default : ret = -EINVAL ; goto err_pm_put;
Greg Kroah-Hartman
maintainerPATCH 946/1017 ASoC: mediatek: mt6358: add missing EXPORT_SYMBOLs
In reply to Greg Kroah-HartmanFrom: Jiaxin Yu <[email protected]>
commit a7663c89f4193dbf717572e46e5a3251940dbdc8 upstream.
Fixes the following build errors when mt6358 is configured as module:
Quoted 4 lines
Quoted 4 lines
ERROR: modpost: "
mt6358_set_mtkaif_protocol" [sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.ko] undefined!
ERROR: modpost: "mt6358_set_mtkaif_protocol" [sound/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357.ko] undefined!
--- sound/soc/codecs/mt6358.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/soc/codecs/mt6358.c +4 -0
@@ -107,6 +107,7 @@ int mt6358_set_mtkaif_protocol(struct sn priv->mtkaif_protocol = mtkaif_protocol;return 0 ; } +EXPORT_SYMBOL_GPL (mt6358_set_mtkaif_protocol);static void playback_gpio_set (struct mt6358_priv *priv) {
@@ -273,6 +274,7 @@ int mt6358_mtkaif_calibration_enable(str 1 << RG_AUD_PAD_TOP_DAT_MISO_LOOPBACK_SFT);return 0 ; } +EXPORT_SYMBOL_GPL (mt6358_mtkaif_calibration_enable);int mt6358_mtkaif_calibration_disable (struct snd_soc_component *cmpnt) {
@@ -296,6 +298,7 @@ int mt6358_mtkaif_calibration_disable(stcapture_gpio_reset (priv);return 0 ; } +EXPORT_SYMBOL_GPL (mt6358_mtkaif_calibration_disable);int mt6358_set_mtkaif_calibration_phase (struct snd_soc_component *cmpnt,int phase_1,int phase_2)
@@ -310,6 +313,7 @@ int mt6358_set_mtkaif_calibration_phase( phase_2 << RG_AUD_PAD_TOP_PHASE_MODE2_SFT);return 0 ; } +EXPORT_SYMBOL_GPL (mt6358_set_mtkaif_calibration_phase);/* dl pga gain */ enum {
Greg Kroah-Hartman
maintainerPATCH 947/1017 ubi: Fix race condition between ctrl_cdev_ioctl and ubi_cdev_ioctl
In reply to Greg Kroah-HartmanFrom: Baokun Li <[email protected]>
commit 3cbf0e392f173ba0ce425968c8374a6aa3e90f2e upstream.
Hulk Robot reported a KASAN report about use-after-free:
==================================================================
BUG: KASAN: use-after-free in __list_del_entry_valid+0x13d/0x160 Read of size 8 at addr ffff888035e37d98 by task ubiattach/1385 [...] Call Trace: klist_dec_and_del+0xa7/0x4a0 klist_put+0xc7/0x1a0 device_del+0x4d4/0xed0 cdev_device_del+0x1a/0x80 ubi_attach_mtd_dev+0x2951/0x34b0 [ubi] ctrl_cdev_ioctl+0x286/0x2f0 [ubi] Allocated by task 1414: device_add+0x60a/0x18b0 cdev_device_add+0x103/0x170 ubi_create_volume+0x1118/0x1a10 [ubi] ubi_cdev_ioctl+0xb7f/0x1ba0 [ubi] Freed by task 1385: cdev_device_del+0x1a/0x80 ubi_remove_volume+0x438/0x6c0 [ubi] ubi_cdev_ioctl+0xbf4/0x1ba0 [ubi] [...] ==================================================================
The lock held by ctrl_cdev_ioctl is ubi_devices_mutex, but the lock held by ubi_cdev_ioctl is ubi->device_mutex. Therefore, the two locks can be concurrent.
ctrl_cdev_ioctl contains two operations: ubi_attach and ubi_detach. ubi_detach is bug-free because it uses reference counting to prevent concurrency. However, uif_init and uif_close in ubi_attach may race with ubi_cdev_ioctl.
uif_init will race with ubi_cdev_ioctl as in the following stack.
cpu1 cpu2 cpu3
_______________________|________________________|______________________ ctrl_cdev_ioctl
ubi_attach_mtd_dev
uif_init
ubi_cdev_ioctl
ubi_create_volume
cdev_device_add
ubi_add_volume
// sysfs exist
kill_volumes
ubi_cdev_ioctl
ubi_remove_volume
cdev_device_del
// first free
ubi_free_volume
cdev_del
// double free cdev_device_del
And uif_close will race with ubi_cdev_ioctl as in the following stack.
cpu1 cpu2 cpu3
_______________________|________________________|______________________ ctrl_cdev_ioctl
ubi_attach_mtd_dev
uif_init
ubi_cdev_ioctl
ubi_create_volume
cdev_device_add
ubi_debugfs_init_dev
//error goto out_uif;
uif_close
kill_volumes
ubi_cdev_ioctl
ubi_remove_volume
cdev_device_del
// first free
ubi_free_volume
// double freeThe cause of this problem is that commit 714fb87e8bc0 make device "available" before it becomes accessible via sysfs. Therefore, we roll back the modification. We will fix the race condition between ubi device creation and udev by removing ubi_get_device in vol_attribute_show and dev_attribute_show.This avoids accessing uninitialized ubi_devices[ubi_num].
ubi_get_device is used to prevent devices from being deleted during sysfs execution. However, now kernfs ensures that devices will not be deleted before all reference counting are released. The key process is shown in the following stack.
device_del
device_remove_attrs
device_remove_groups
sysfs_remove_groups
sysfs_remove_group
remove_files
kernfs_remove_by_name
kernfs_remove_by_name_ns
__kernfs_remove
kernfs_drain
--- drivers/mtd/ubi/build.c | 9 +-------- drivers/mtd/ubi/vmt.c | 8 +------- 2 files changed, 2 insertions(+), 15 deletions(-)
drivers/mtd/ubi/build.c +1 -8
@@ -351,9 +351,6 @@ static ssize_t dev_attribute_show(struct* we still can use 'ubi->ubi_num'. */ ubi = container_of(dev, struct ubi_device, dev); - ubi =ubi_get_device (ubi->ubi_num); -if (!ubi) -return -ENODEV ;if (attr == &dev_eraseblock_size) ret =sprintf (buf,"%d\n" , ubi->leb_size);
@@ -382,7 +379,6 @@ static ssize_t dev_attribute_show(structelse ret = -EINVAL ; -ubi_put_device (ubi);return ret; }
@@ -979,9 +975,6 @@ int ubi_attach_mtd_dev(struct mtd_info * goto out_detach; } -/* Make device "available" before it becomes accessible via sysfs */ - ubi_devices[ubi_num] = ubi; - err =uif_init (ubi);if (err) goto out_detach;
@@ -1026,6 +1019,7 @@ int ubi_attach_mtd_dev(struct mtd_info *wake_up_process (ubi->bgt_thread);spin_unlock (&ubi->wl_lock); + ubi_devices[ubi_num] = ubi;ubi_notify_all (ubi,UBI_VOLUME_ADDED ,NULL );return ubi_num;
@@ -1034,7 +1028,6 @@ out_debugfs: out_uif:uif_close (ubi); out_detach: - ubi_devices[ubi_num] =NULL ;ubi_wl_close (ubi);ubi_free_all_volumes (ubi);vfree (ubi->vtbl);
drivers/mtd/ubi/vmt.c +1 -7
@@ -56,16 +56,11 @@ static ssize_t vol_attribute_show(struct {int ret; struct ubi_volume *vol = container_of(dev, struct ubi_volume, dev); -struct ubi_device *ubi; - - ubi =ubi_get_device (vol->ubi->ubi_num); -if (!ubi) -return -ENODEV ; +struct ubi_device *ubi = vol->ubi;spin_lock (&ubi->volumes_lock);if (!ubi->volumes[vol->vol_id]) {spin_unlock (&ubi->volumes_lock); -ubi_put_device (ubi);return -ENODEV ; }/* Take a reference to prevent volume removal */
@@ -103,7 +98,6 @@ static ssize_t vol_attribute_show(struct vol->ref_count -=1 ;ubi_assert (vol->ref_count >=0 );spin_unlock (&ubi->volumes_lock); -ubi_put_device (ubi);return ret; }
Greg Kroah-Hartman
maintainerPATCH 948/1017 ARM: iop32x: offset IRQ numbers by 1
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
commit 9d67412f24cc3a2c05f35f7c856addb07a2960ce upstream.
iop32x is one of the last platforms to use IRQ 0, and this has apparently stopped working in a 2014 cleanup without anyone noticing. This interrupt is used for the DMA engine, so most likely this has not actually worked in the past 7 years, but it's also not essential for using this board.
I'm splitting out this change from my GENERIC_IRQ_MULTI_HANDLER conversion so it can be backported if anyone cares.
--- arch/arm/mach-iop32x/include/mach/entry-macro.S | 2 arch/arm/mach-iop32x/include/mach/irqs.h | 2 arch/arm/mach-iop32x/irq.c | 6 +- arch/arm/mach-iop32x/irqs.h | 60 ++++++++++++------------ 4 files changed, 37 insertions(+), 33 deletions(-)
arch/arm/mach-iop32x/include/mach/entry-macro.S +1 -1
@@ -20,7 +20,7 @@ mrc p6, 0, \irqstat, c8, c0, 0 @ Read IINTSRC cmp \irqstat, #0 clzne \irqnr, \irqstat - rsbne \irqnr, \irqnr, #31 + rsbne \irqnr, \irqnr, #32 .endm .macro arch_ret_to_user, tmp1, tmp2
arch/arm/mach-iop32x/include/mach/irqs.h +1 -1
@@ -9,6 +9,6 @@#ifndef __IRQS_H#define __IRQS_H -#define NR_IRQS 32 +#define NR_IRQS 33#endif
arch/arm/mach-iop32x/irq.c +3 -3
@@ -32,14 +32,14 @@ static void intstr_write(u32 val)static void iop32x_irq_mask (struct irq_data *d) { - iop32x_mask &= ~(1 << d->irq); + iop32x_mask &= ~(1 << (d->irq -1 ));intctl_write (iop32x_mask); }static void iop32x_irq_unmask (struct irq_data *d) { - iop32x_mask |=1 << d->irq; + iop32x_mask |=1 << (d->irq -1 );intctl_write (iop32x_mask); }
@@ -65,7 +65,7 @@ void __init iop32x_init_irq(void) machine_is_em7210()) *IOP3XX_PCIIRSR =0x0f ; -for (i =0 ; i <NR_IRQS ; i++) { +for (i =1 ; i <NR_IRQS ; i++) {irq_set_chip_and_handler (i, &ext_chip, handle_level_irq);irq_clear_status_flags (i,IRQ_NOREQUEST |IRQ_NOPROBE ); }
arch/arm/mach-iop32x/irqs.h +32 -28
68 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 949/1017 block: Fix the maximum minor value is blk_alloc_ext_minor()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
commit d1868328dec5ae2cf210111025fcbc71f78dd5ca upstream.
ida_alloc_range(..., min, max, ...) returns values from min to max, inclusive.
So, NR_EXT_DEVT is a valid idx returned by blk_alloc_ext_minor().
This is an issue because in device_add_disk(), this value is used in:
ddev->devt = MKDEV(disk->major, disk->first_minor);
and NR_EXT_DEVT is '(1 << MINORBITS)'.
So, should 'disk->first_minor' be NR_EXT_DEVT, it would overflow.
--- block/genhd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/genhd.c +1 -1
@@ -328,7 +328,7 @@ int blk_alloc_ext_minor(void) {int idx; - idx =ida_alloc_range (&ext_devt_ida,0 ,NR_EXT_DEVT ,GFP_KERNEL ); + idx =ida_alloc_range (&ext_devt_ida,0 ,NR_EXT_DEVT -1 ,GFP_KERNEL );if (idx == -ENOSPC )return -EBUSY ;return idx;
Greg Kroah-Hartman
maintainerPATCH 950/1017 Revert "virtio-pci: harden INTX interrupts"
In reply to Greg Kroah-HartmanFrom: Jason Wang <[email protected]>
commit 7b79edfb862d6b1ecc66479419ae67a7db2d02e3 upstream.
This reverts commit 080cd7c3ac8701081d143a15ba17dd9475313188. Since the MSI-X interrupts hardening will be reverted in the next patch. We will rework the interrupt hardening in the future.
--- drivers/virtio/virtio_pci_common.c | 23 ++--------------------- drivers/virtio/virtio_pci_common.h | 1 - 2 files changed, 2 insertions(+), 22 deletions(-)
drivers/virtio/virtio_pci_common.c +2 -21
@@ -30,16 +30,8 @@ void vp_disable_cbs(struct virtio_devicestruct virtio_pci_device *vp_dev =to_vp_device (vdev);int i; -if (vp_dev->intx_enabled) { -/* -* The below synchronize() guarantees that any -* interrupt for this line arriving after -* synchronize_irq() has completed is guaranteed to see -* intx_soft_enabled == false. -*/ -WRITE_ONCE (vp_dev->intx_soft_enabled, false); +if (vp_dev->intx_enabled)synchronize_irq (vp_dev->pci_dev->irq); - }for (i =0 ; i < vp_dev->msix_vectors; ++i)disable_irq (pci_irq_vector (vp_dev->pci_dev, i));
@@ -51,16 +43,8 @@ void vp_enable_cbs(struct virtio_devicestruct virtio_pci_device *vp_dev =to_vp_device (vdev);int i; -if (vp_dev->intx_enabled) { -disable_irq (vp_dev->pci_dev->irq); -/* -* The above disable_irq() provides TSO ordering and -* as such promotes the below store to store-release. -*/ -WRITE_ONCE (vp_dev->intx_soft_enabled, true); -enable_irq (vp_dev->pci_dev->irq); +if (vp_dev->intx_enabled)return ; - }for (i =0 ; i < vp_dev->msix_vectors; ++i)enable_irq (pci_irq_vector (vp_dev->pci_dev, i));
@@ -113,9 +97,6 @@ static irqreturn_t vp_interrupt(int irq,struct virtio_pci_device *vp_dev = opaque;u8 isr; -if (!READ_ONCE (vp_dev->intx_soft_enabled)) -return IRQ_NONE ; -/* reading the ISR has the effect of also clearing it so it's very * important to save off the value. */ isr =ioread8 (vp_dev->isr);
drivers/virtio/virtio_pci_common.h +0 -1
@@ -63,7 +63,6 @@ struct virtio_pci_device {/* MSI-X support */ int msix_enabled;int intx_enabled; -bool intx_soft_enabled;cpumask_var_t *msix_affinity_masks;/* Name strings for interrupts. This size should be enough, * and I'm too lazy to allocate each name separately. */
Greg Kroah-Hartman
maintainerPATCH 951/1017 Revert "virtio_pci: harden MSI-X interrupts"
In reply to Greg Kroah-HartmanFrom: Jason Wang <[email protected]>
commit eb4cecb453a19b34d5454b49532e09e9cb0c1529 upstream.
This reverts commit 9e35276a5344f74d4a3600fc4100b3dd251d5c56. Issue were reported for the drivers that are using affinity managed IRQ where manually toggling IRQ status is not expected. And we forget to enable the interrupts in the restore path as well.
In the future, we will rework on the interrupt hardening.
--- drivers/virtio/virtio_pci_common.c | 27 ++++++--------------------- drivers/virtio/virtio_pci_common.h | 6 ++---- drivers/virtio/virtio_pci_legacy.c | 5 ++--- drivers/virtio/virtio_pci_modern.c | 6 ++---- 4 files changed, 12 insertions(+), 32 deletions(-)
drivers/virtio/virtio_pci_common.c +6 -21
@@ -24,8 +24,8 @@ MODULE_PARM_DESC(force_legacy, "Force legacy mode for transitional virtio 1 devices");#endif -/* disable irq handlers */ -void vp_disable_cbs (struct virtio_device *vdev) +/* wait for pending irq handlers */ +void vp_synchronize_vectors (struct virtio_device *vdev) {struct virtio_pci_device *vp_dev =to_vp_device (vdev);int i;
@@ -34,20 +34,7 @@ void vp_disable_cbs(struct virtio_devicesynchronize_irq (vp_dev->pci_dev->irq);for (i =0 ; i < vp_dev->msix_vectors; ++i) -disable_irq (pci_irq_vector (vp_dev->pci_dev, i)); -} - -/* enable irq handlers */ -void vp_enable_cbs (struct virtio_device *vdev) -{ -struct virtio_pci_device *vp_dev =to_vp_device (vdev); -int i; - -if (vp_dev->intx_enabled) -return ; - -for (i =0 ; i < vp_dev->msix_vectors; ++i) -enable_irq (pci_irq_vector (vp_dev->pci_dev, i)); +synchronize_irq (pci_irq_vector (vp_dev->pci_dev, i)); }/* the notify function used when creating a virt queue */
@@ -154,8 +141,7 @@ static int vp_request_msix_vectors(strucsnprintf (vp_dev->msix_names[v],sizeof *vp_dev->msix_names,"%s-config" , name); err =request_irq (pci_irq_vector (vp_dev->pci_dev, v), - vp_config_changed,IRQF_NO_AUTOEN , - vp_dev->msix_names[v], + vp_config_changed,0 , vp_dev->msix_names[v], vp_dev);if (err) goto error;
@@ -174,8 +160,7 @@ static int vp_request_msix_vectors(strucsnprintf (vp_dev->msix_names[v],sizeof *vp_dev->msix_names,"%s-virtqueues" , name); err =request_irq (pci_irq_vector (vp_dev->pci_dev, v), - vp_vring_interrupt,IRQF_NO_AUTOEN , - vp_dev->msix_names[v], + vp_vring_interrupt,0 , vp_dev->msix_names[v], vp_dev);if (err) goto error;
@@ -352,7 +337,7 @@ static int vp_find_vqs_msix(struct virti"%s-%s" , dev_name(&vp_dev->vdev.dev), names[i]); err =request_irq (pci_irq_vector (vp_dev->pci_dev, msix_vec), - vring_interrupt,IRQF_NO_AUTOEN , + vring_interrupt,0 , vp_dev->msix_names[msix_vec], vqs[i]);if (err)
drivers/virtio/virtio_pci_common.h +2 -4
@@ -101,10 +101,8 @@ static struct virtio_pci_device *to_vp_d return container_of(vdev, struct virtio_pci_device, vdev); } -/* disable irq handlers */ -void vp_disable_cbs (struct virtio_device *vdev); -/* enable irq handlers */ -void vp_enable_cbs (struct virtio_device *vdev); +/* wait for pending irq handlers */ +void vp_synchronize_vectors (struct virtio_device *vdev);/* the notify function used when creating a virt queue */ bool vp_notify (struct virtqueue *vq);/* the config->del_vqs() implementation */
drivers/virtio/virtio_pci_legacy.c +2 -3
@@ -98,8 +98,8 @@ static void vp_reset(struct virtio_devic/* Flush out the status write, and flush in device writes, * including MSi-X interrupts, if any. */ vp_legacy_get_status (&vp_dev->ldev); -/* Disable VQ/configuration callbacks. */ -vp_disable_cbs (vdev); +/* Flush pending VQ/configuration callbacks. */ +vp_synchronize_vectors (vdev); }static u16 vp_config_vector (struct virtio_pci_device *vp_dev,u16 vector)
@@ -185,7 +185,6 @@ static void del_vq(struct virtio_pci_vq_ }static const struct virtio_config_ops virtio_pci_config_ops = { - .enable_cbs = vp_enable_cbs, .get = vp_get, .set = vp_set, .get_status = vp_get_status,
drivers/virtio/virtio_pci_modern.c +2 -4
@@ -172,8 +172,8 @@ static void vp_reset(struct virtio_devic*/ while (vp_modern_get_status (mdev))msleep (1 ); -/* Disable VQ/configuration callbacks. */ -vp_disable_cbs (vdev); +/* Flush pending VQ/configuration callbacks. */ +vp_synchronize_vectors (vdev); }static u16 vp_config_vector (struct virtio_pci_device *vp_dev,u16 vector)
@@ -380,7 +380,6 @@ static bool vp_get_shm_region(struct vir }static const struct virtio_config_ops virtio_pci_config_nodev_ops = { - .enable_cbs = vp_enable_cbs, .get =NULL , .set =NULL , .generation = vp_generation,
@@ -398,7 +397,6 @@ static const struct virtio_config_ops vi };static const struct virtio_config_ops virtio_pci_config_ops = { - .enable_cbs = vp_enable_cbs, .get = vp_get, .set = vp_set, .generation = vp_generation,