5.9.2-rc1 review
Subsystems (5)
Greg Kroah-Hartman
maintainerPATCH 442/757 powerpc/watchpoint: Add hw_len wherever missing
In reply to Greg Kroah-HartmanFrom: Ravi Bangoria <[email protected]>
[ Upstream commit 58da5984d2ea6d95f3f9d9e8dd9f7e1b0dddfb3c ]
There are couple of places where we set len but not hw_len. For ptrace/perf watchpoints, when CONFIG_HAVE_HW_BREAKPOINT=Y, hw_len will be calculated and set internally while parsing watchpoint. But when CONFIG_HAVE_HW_BREAKPOINT=N, we need to manually set 'hw_len'. Similarly for xmon as well, hw_len needs to be set directly.
--- arch/powerpc/kernel/ptrace/ptrace-noadv.c | 1 + arch/powerpc/xmon/xmon.c | 1 + 2 files changed, 2 insertions(+)
arch/powerpc/kernel/ptrace/ptrace-noadv.c +1 -0
@@ -219,6 +219,7 @@ long ppc_set_hwdebug(struct task_struct *child, struct ppc_hw_breakpoint *bp_inf brk.address =ALIGN_DOWN (bp_info->addr,HW_BREAKPOINT_SIZE ); brk.type =HW_BRK_TYPE_TRANSLATE ; brk.len =DABR_MAX_LEN ; + brk.hw_len =DABR_MAX_LEN ;if (bp_info->trigger_type &PPC_BREAKPOINT_TRIGGER_READ ) brk.type |=HW_BRK_TYPE_READ ;if (bp_info->trigger_type &PPC_BREAKPOINT_TRIGGER_WRITE )
arch/powerpc/xmon/xmon.c +1 -0
@@ -969,6 +969,7 @@ static void insert_cpu_bpts(void) brk.address = dabr[i].address; brk.type = (dabr[i].enabled &HW_BRK_TYPE_DABR ) |HW_BRK_TYPE_PRIV_ALL ; brk.len =8 ; + brk.hw_len =8 ;__set_breakpoint (i, &brk); } }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 443/757 powerpc/book3s64/hash/4k: Support large linear mapping range with 4K
In reply to Greg Kroah-HartmanFrom: Aneesh Kumar K.V <[email protected]>
[ Upstream commit 7746406baa3bc9e23fdd7b7da2f04d86e25ab837 ]
With commit: 0034d395f89d ("powerpc/mm/hash64: Map all the kernel regions in the same 0xc range"), we now split the 64TB address range into 4 contexts each of 16TB. That implies we can do only 16TB linear mapping.
On some systems, eg. Power9, memory attached to nodes > 0 will appear above 16TB in the linear mapping. This resulted in kernel crash when we boot such systems in hash translation mode with 4K PAGE_SIZE.
This patch updates the kernel mapping such that we now start supporting upto 61TB of memory with 4K. The kernel mapping now looks like below 4K PAGE_SIZE and hash translation.
vmalloc start = 0xc0003d0000000000
IO start = 0xc0003e0000000000
vmemmap start = 0xc0003f0000000000Our MAX_PHYSMEM_BITS for 4K is still 64TB even though we can only map 61TB. We prevent bolt mapping anything outside 61TB range by checking against H_VMALLOC_START.
--- arch/powerpc/include/asm/book3s/64/hash-4k.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
arch/powerpc/include/asm/book3s/64/hash-4k.h +6 -7
@@ -13,20 +13,19 @@*/ #define MAX_EA_BITS_PER_CONTEXT 46 -#define REGION_SHIFT (MAX_EA_BITS_PER_CONTEXT - 2)/* -* Our page table limit us to 64TB. Hence for the kernel mapping, -* each MAP area is limited to 16 TB. -* The four map areas are: linear mapping, vmap, IO and vmemmap +* Our page table limit us to 64TB. For 64TB physical memory, we only need 64GB +* of vmemmap space. To better support sparse memory layout, we use 61TB +* linear map range, 1TB of vmalloc, 1TB of I/O and 1TB of vmememmap. */ +#define REGION_SHIFT (40)#define H_KERN_MAP_SIZE (ASM_CONST(1) << REGION_SHIFT)/* -* Define the address range of the kernel non-linear virtual area -* 16TB +* Define the address range of the kernel non-linear virtual area (61TB) */ -#define H_KERN_VIRT_START ASM_CONST(0xc000100000000000) +#define H_KERN_VIRT_START ASM_CONST(0xc0003d0000000000)#ifndef __ASSEMBLY__#define H_PTE_TABLE_SIZE (sizeof(pte_t) << H_PTE_INDEX_SIZE)
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 444/757 powerpc/tau: Use appropriate temperature sample interval
In reply to Greg Kroah-HartmanFrom: Finn Thain <[email protected]>
[ Upstream commit 66943005cc41f48e4d05614e8f76c0ca1812f0fd ]
According to the MPC750 Users Manual, the SITV value in Thermal Management Register 3 is 13 bits long. The present code calculates the SITV value as 60 * 500 cycles. This would overflow to give 10 us on a 500 MHz CPU rather than the intended 60 us. (But according to the Microprocessor Datasheet, there is also a factor of 266 that has to be applied to this value on certain parts i.e. speed sort above 266 MHz.) Always use the maximum cycle count, as recommended by the Datasheet.
--- arch/powerpc/include/asm/reg.h | 2 +- arch/powerpc/kernel/tau_6xx.c | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-)
arch/powerpc/include/asm/reg.h +1 -1
@@ -817,7 +817,7 @@#define THRM1_TIN (1 << 31)#define THRM1_TIV (1 << 30)#define THRM1_THRES (x) ((x&0x7f)<<23) -#define THRM3_SITV (x) ((x&0x3fff)<<1) +#define THRM3_SITV (x) ((x & 0x1fff) << 1)#define THRM1_TID (1<<2)#define THRM1_TIE (1<<1)#define THRM1_V (1<<0)
arch/powerpc/kernel/tau_6xx.c +4 -8
@@ -178,15 +178,11 @@ static void tau_timeout(void * info)* complex sleep code needs to be added. One mtspr every time * tau_timeout is called is probably not a big deal. * -* Enable thermal sensor and set up sample interval timer -* need 20 us to do the compare.. until a nice 'cpu_speed' function -* call is implemented, just assume a 500 mhz clock. It doesn't really -* matter if we take too long for a compare since it's all interrupt -* driven anyway. -* -* use a extra long time.. (60 us @ 500 mhz) +* The "PowerPC 740 and PowerPC 750 Microprocessor Datasheet" +* recommends that "the maximum value be set in THRM3 under all +* conditions." */ -mtspr (SPRN_THRM3 ,THRM3_SITV (500 *60 ) |THRM3_E ); +mtspr (SPRN_THRM3 ,THRM3_SITV (0x1fff ) |THRM3_E );local_irq_restore (flags); }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 445/757 powerpc/tau: Convert from timer to workqueue
In reply to Greg Kroah-HartmanFrom: Finn Thain <[email protected]>
[ Upstream commit b1c6a0a10bfaf36ec82fde6f621da72407fa60a1 ]
Since commit 19dbdcb8039cf ("smp: Warn on function calls from softirq context") the Thermal Assist Unit driver causes a warning like the following when CONFIG_SMP is enabled.
------------[ cut here ]------------
WARNING: CPU: 0 PID: 0 at kernel/smp.c:428 smp_call_function_many_cond+0xf4/0x38c
Modules linked in:
CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.7.0-pmac #3
NIP: c00b37a8 LR: c00b3abc CTR: c001218c
REGS: c0799c60 TRAP: 0700 Not tainted (5.7.0-pmac)
MSR: 00029032 <EE,ME,IR,DR,RI> CR: 42000224 XER: 00000000
GPR00: c00b3abc c0799d18 c076e300 c079ef5c c0011fec 00000000 00000000 00000000
GPR08: 00000100 00000100 00008000 ffffffff 42000224 00000000 c079d040 c079d044
GPR16: 00000001 00000000 00000004 c0799da0 c079f054 c07a0000 c07a0000 00000000
GPR24: c0011fec 00000000 c079ef5c c079ef5c 00000000 00000000 00000000 00000000
NIP [c00b37a8] smp_call_function_many_cond+0xf4/0x38c
LR [c00b3abc] on_each_cpu+0x38/0x68
Call Trace:
[c0799d18] [ffffffff] 0xffffffff (unreliable)
[c0799d68] [c00b3abc] on_each_cpu+0x38/0x68
[c0799d88] [c0096704] call_timer_fn.isra.26+0x20/0x7c
[c0799d98] [c0096b40] run_timer_softirq+0x1d4/0x3fc
[c0799df8] [c05b4368] __do_softirq+0x118/0x240
[c0799e58] [c0039c44] irq_exit+0xc4/0xcc
[c0799e68] [c000ade8] timer_interrupt+0x1b0/0x230
[c0799ea8] [c0013520] ret_from_except+0x0/0x14
--- interrupt: 901 at arch_cpu_idle+0x24/0x6c
LR = arch_cpu_idle+0x24/0x6c
[c0799f70] [00000001] 0x1 (unreliable)
[c0799f80] [c0060990] do_idle+0xd8/0x17c
[c0799fa0] [c0060ba8] cpu_startup_entry+0x24/0x28
[c0799fb0] [c072d220] start_kernel+0x434/0x44c
[c0799ff0] [00003860] 0x3860
Instruction dump:
8129f204 2f890000 40beff98 3d20c07a 8929eec4 2f890000 40beff88 0fe00000
81220000 552805de 550802ef 4182ff84 <0fe00000> 3860ffff 7f65db78 7f44d378
---[ end trace 34a886e47819c2eb ]---Don't call on_each_cpu() from a timer callback, call it from a worker thread instead.
--- arch/powerpc/kernel/tau_6xx.c | 38 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 20 deletions(-)
arch/powerpc/kernel/tau_6xx.c +18 -20
@@ -13,13 +13,14 @@*/ #include <linux/errno.h> -#include <linux/jiffies.h> #include <linux/kernel.h> #include <linux/param.h> #include <linux/string.h> #include <linux/mm.h> #include <linux/interrupt.h> #include <linux/init.h> +#include <linux/delay.h> +#include <linux/workqueue.h> #include <asm/io.h> #include <asm/reg.h>
@@ -39,8 +40,6 @@ static struct tau_tempunsigned char grew; } tau[NR_CPUS ]; -struct timer_list tau_timer; -#undef DEBUG/* TODO: put these in a /proc interface, with some sanity checks, and maybe
@@ -50,7 +49,7 @@ struct timer_list tau_timer;#define step_size 2/* step size when temp goes out of range */ #define window_expand 1/* expand the window by this much */ /* configurable values for shrinking the window */ -#define shrink_timer 2*HZ/* period between shrinking the window */ +#define shrink_timer 2000/* period between shrinking the window */ #define min_window 2/* minimum window size, degrees C */ static void set_thresholds (unsigned long cpu)
@@ -187,14 +186,18 @@ static void tau_timeout(void * info)local_irq_restore (flags); } -static void tau_timeout_smp (struct timer_list *unused) -{ +static struct workqueue_struct *tau_workq; -/* schedule ourselves to be run again */ -mod_timer (&tau_timer, jiffies + shrink_timer) ; +static void tau_work_func (struct work_struct *work) +{ +msleep (shrink_timer);on_each_cpu (tau_timeout,NULL ,0 ); +/* schedule ourselves to be run again */ +queue_work (tau_workq, work); } +DECLARE_WORK (tau_work, tau_work_func); +/* * setup the TAU *
@@ -227,21 +230,16 @@ static int __init TAU_init(void)return 1 ; } - -/* first, set up the window shrinking timer */ -timer_setup (&tau_timer, tau_timeout_smp,0 ); - tau_timer.expires = jiffies + shrink_timer; -add_timer (&tau_timer); + tau_workq =alloc_workqueue ("tau" ,WQ_UNBOUND ,1 ,0 ); +if (!tau_workq) +return -ENOMEM ;on_each_cpu (TAU_init_smp,NULL ,0 ); -printk ("Thermal assist unit " ); -#ifdef CONFIG_TAU_INT -printk ("using interrupts, " ); -#else -printk ("using timers, " ); -#endif -printk ("shrink_timer: %d jiffies\n" , shrink_timer); +queue_work (tau_workq, &tau_work); + +pr_info ("Thermal assist unit using %s, shrink_timer: %d ms\n" , +IS_ENABLED (CONFIG_TAU_INT ) ?"interrupts" :"workqueue" , shrink_timer); tau_initialized =1 ;return 0 ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 446/757 powerpc/tau: Remove duplicated set_thresholds() call
In reply to Greg Kroah-HartmanFrom: Finn Thain <[email protected]>
[ Upstream commit 420ab2bc7544d978a5d0762ee736412fe9c796ab ]
The commentary at the call site seems to disagree with the code. The conditional prevents calling set_thresholds() via the exception handler, which appears to crash. Perhaps that's because it immediately triggers another TAU exception. Anyway, calling set_thresholds() from TAUupdate() is redundant because tau_timeout() does so.
--- arch/powerpc/kernel/tau_6xx.c | 5 ----- 1 file changed, 5 deletions(-)
arch/powerpc/kernel/tau_6xx.c +0 -5
@@ -110,11 +110,6 @@ static void TAUupdate(int cpu)#ifdef DEBUG printk ("grew = %d\n" , tau[cpu].grew);#endif - -#ifndef CONFIG_TAU_INT /* tau_timeout will do this if not using interrupts */ -set_thresholds (cpu); -#endif - }#ifdef CONFIG_TAU_INT
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 447/757 powerpc/tau: Check processor type before enabling TAU interrupt
In reply to Greg Kroah-HartmanFrom: Finn Thain <[email protected]>
[ Upstream commit 5e3119e15fed5b9a9a7e528665ff098a4a8dbdbc ]
According to Freescale's documentation, MPC74XX processors have an erratum that prevents the TAU interrupt from working, so don't try to use it when running on those processors.
--- arch/powerpc/kernel/tau_6xx.c | 33 ++++++++++++++------------------- arch/powerpc/platforms/Kconfig | 5 ++--- 2 files changed, 16 insertions(+), 22 deletions(-)
arch/powerpc/kernel/tau_6xx.c +14 -19
@@ -40,6 +40,8 @@ static struct tau_tempunsigned char grew; } tau[NR_CPUS ]; +static bool tau_int_enable; +#undef DEBUG/* TODO: put these in a /proc interface, with some sanity checks, and maybe
@@ -54,22 +56,13 @@ static struct tau_tempstatic void set_thresholds (unsigned long cpu) { -#ifdef CONFIG_TAU_INT -/* -* setup THRM1, -* threshold, valid bit, enable interrupts, interrupt when below threshold -*/ -mtspr (SPRN_THRM1 ,THRM1_THRES (tau[cpu].low) |THRM1_V |THRM1_TIE |THRM1_TID ); +u32 maybe_tie = tau_int_enable ?THRM1_TIE :0 ; -/* setup THRM2, -* threshold, valid bit, enable interrupts, interrupt when above threshold -*/ -mtspr (SPRN_THRM2 ,THRM1_THRES (tau[cpu].high) |THRM1_V |THRM1_TIE ); -#else -/* same thing but don't enable interrupts */ -mtspr (SPRN_THRM1 ,THRM1_THRES (tau[cpu].low) |THRM1_V |THRM1_TID ); -mtspr (SPRN_THRM2 ,THRM1_THRES (tau[cpu].high) |THRM1_V ); -#endif +/* setup THRM1, threshold, valid bit, interrupt when below threshold */ +mtspr (SPRN_THRM1 ,THRM1_THRES (tau[cpu].low) |THRM1_V | maybe_tie |THRM1_TID ); + +/* setup THRM2, threshold, valid bit, interrupt when above threshold */ +mtspr (SPRN_THRM2 ,THRM1_THRES (tau[cpu].high) |THRM1_V | maybe_tie); }static void TAUupdate (int cpu)
@@ -142,9 +135,8 @@ static void tau_timeout(void * info)local_irq_save (flags); cpu =smp_processor_id (); -#ifndef CONFIG_TAU_INT -TAUupdate (cpu); -#endif +if (!tau_int_enable) +TAUupdate (cpu); size = tau[cpu].high - tau[cpu].low;if (size > min_window && ! tau[cpu].grew) {
@@ -225,6 +217,9 @@ static int __init TAU_init(void)return 1 ; } + tau_int_enable =IS_ENABLED (CONFIG_TAU_INT ) && + !strcmp (cur_cpu_spec->platform,"ppc750" ); + tau_workq =alloc_workqueue ("tau" ,WQ_UNBOUND ,1 ,0 );if (!tau_workq)return -ENOMEM ;
@@ -234,7 +229,7 @@ static int __init TAU_init(void)queue_work (tau_workq, &tau_work);pr_info ("Thermal assist unit using %s, shrink_timer: %d ms\n" , -IS_ENABLED (CONFIG_TAU_INT ) ?"interrupts" :"workqueue" , shrink_timer); + tau_int_enable ?"interrupts" :"workqueue" , shrink_timer); tau_initialized =1 ;return 0 ;
arch/powerpc/platforms/Kconfig +2 -3
@@ -223,9 +223,8 @@ config TAU temperature within 2-4 degrees Celsius. This option shows the current on-die temperature in /proc/cpuinfo if the cpu supports it. - Unfortunately, on some chip revisions, this sensor is very inaccurate - and in many cases, does not work at all, so don't assume the cpu - temp is actually what /proc/cpuinfo says it is. + Unfortunately, this sensor is very inaccurate when uncalibrated, so + don't assume the cpu temp is actually what /proc/cpuinfo says it is. config TAU_INT bool "Interrupt driven TAU driver (DANGEROUS)"
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 448/757 powerpc/tau: Disable TAU between measurements
In reply to Greg Kroah-HartmanFrom: Finn Thain <[email protected]>
[ Upstream commit e63d6fb5637e92725cf143559672a34b706bca4f ]
Enabling CONFIG_TAU_INT causes random crashes:
Unrecoverable exception 1700 at c0009414 (msr=1000)
Oops: Unrecoverable exception, sig: 6 [#1] BE PAGE_SIZE=4K MMU=Hash SMP NR_CPUS=2 PowerMac Modules linked in: CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.7.0-pmac-00043-gd5f545e1a8593 #5 NIP: c0009414 LR: c0009414 CTR: c00116fc REGS: c0799eb8 TRAP: 1700 Not tainted (5.7.0-pmac-00043-gd5f545e1a8593) MSR: 00001000 <ME> CR: 22000228 XER: 00000100
GPR00: 00000000 c0799f70 c076e300 00800000 0291c0ac 00e00000 c076e300 00049032
GPR08: 00000001 c00116fc 00000000 dfbd3200 ffffffff 007f80a8 00000000 00000000
GPR16: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 c075ce04
GPR24: c075ce04 dfff8880 c07b0000 c075ce04 00080000 00000001 c079ef98 c079ef5c NIP [c0009414] arch_cpu_idle+0x24/0x6c
LR [c0009414] arch_cpu_idle+0x24/0x6c
Call Trace:
[c0799f70] [00000001] 0x1 (unreliable)
[c0799f80] [c0060990] do_idle+0xd8/0x17c
[c0799fa0] [c0060ba4] cpu_startup_entry+0x20/0x28
[c0799fb0] [c072d220] start_kernel+0x434/0x44c
[c0799ff0] [00003860] 0x3860
Instruction dump:
XXXXXXXX XXXXXXXX XXXXXXXX 3d20c07b XXXXXXXX XXXXXXXX XXXXXXXX 7c0802a6 XXXXXXXX XXXXXXXX XXXXXXXX 4e800421 XXXXXXXX XXXXXXXX XXXXXXXX 7d2000a6
---[ end trace 3a0c9b5cb216db6b ]---
Resolve this problem by disabling each THRMn comparator when handling the associated THRMn interrupt and by disabling the TAU entirely when updating THRMn thresholds.
--- arch/powerpc/kernel/tau_6xx.c | 65 +++++++++++++--------------------- arch/powerpc/platforms/Kconfig | 9 ++--- 2 files changed, 26 insertions(+), 48 deletions(-)
arch/powerpc/kernel/tau_6xx.c +24 -41
@@ -42,8 +42,6 @@ static struct tau_tempstatic bool tau_int_enable; -#undef DEBUG -/* TODO: put these in a /proc interface, with some sanity checks, and maybe * dynamic adjustment to minimize # of interrupts */ /* configurable values for step size and how much to expand the window when
@@ -67,42 +65,33 @@ static void set_thresholds(unsigned long cpu)static void TAUupdate (int cpu) { -unsigned thrm; - -#ifdef DEBUG -printk ("TAUupdate " ); -#endif +u32 thrm; +u32 bits =THRM1_TIV |THRM1_TIN |THRM1_V ;/* if both thresholds are crossed, the step_sizes cancel out * and the window winds up getting expanded twice. */ -if ((thrm =mfspr (SPRN_THRM1 )) &THRM1_TIV ){/* is valid? */ -if (thrm &THRM1_TIN ){/* crossed low threshold */ -if (tau[cpu].low >= step_size){ - tau[cpu].low -= step_size; - tau[cpu].high -= (step_size - window_expand); - } - tau[cpu].grew =1 ; -#ifdef DEBUG -printk ("low threshold crossed " ); -#endif + thrm =mfspr (SPRN_THRM1 ); +if ((thrm & bits) == bits) { +mtspr (SPRN_THRM1 ,0 ); + +if (tau[cpu].low >= step_size) { + tau[cpu].low -= step_size; + tau[cpu].high -= (step_size - window_expand); } + tau[cpu].grew =1 ; +pr_debug ("%s: low threshold crossed\n" , __func__); } -if ((thrm =mfspr (SPRN_THRM2 )) &THRM1_TIV ){/* is valid? */ -if (thrm &THRM1_TIN ){/* crossed high threshold */ -if (tau[cpu].high <=127 -step_size){ - tau[cpu].low += (step_size - window_expand); - tau[cpu].high += step_size; - } - tau[cpu].grew =1 ; -#ifdef DEBUG -printk ("high threshold crossed " ); -#endif + thrm =mfspr (SPRN_THRM2 ); +if ((thrm & bits) == bits) { +mtspr (SPRN_THRM2 ,0 ); + +if (tau[cpu].high <=127 - step_size) { + tau[cpu].low += (step_size - window_expand); + tau[cpu].high += step_size; } + tau[cpu].grew =1 ; +pr_debug ("%s: high threshold crossed\n" , __func__); } - -#ifdef DEBUG -printk ("grew = %d\n" , tau[cpu].grew); -#endif }#ifdef CONFIG_TAU_INT
@@ -127,17 +116,17 @@ void TAUException(struct pt_regs * regs)static void tau_timeout (void * info) {int cpu; -unsigned long flags;int size;int shrink; -/* disabling interrupts *should* be okay */ -local_irq_save (flags); cpu =smp_processor_id ();if (!tau_int_enable)TAUupdate (cpu); +/* Stop thermal sensor comparisons and interrupts */ +mtspr (SPRN_THRM3 ,0 ); + size = tau[cpu].high - tau[cpu].low;if (size > min_window && ! tau[cpu].grew) {/* do an exponential shrink of half the amount currently over size */
@@ -159,18 +148,12 @@ static void tau_timeout(void * info)set_thresholds (cpu); -/* -* Do the enable every time, since otherwise a bunch of (relatively) -* complex sleep code needs to be added. One mtspr every time -* tau_timeout is called is probably not a big deal. -* +/* Restart thermal sensor comparisons and interrupts. * The "PowerPC 740 and PowerPC 750 Microprocessor Datasheet" * recommends that "the maximum value be set in THRM3 under all * conditions." */ mtspr (SPRN_THRM3 ,THRM3_SITV (0x1fff ) |THRM3_E ); - -local_irq_restore (flags); }static struct workqueue_struct *tau_workq;
arch/powerpc/platforms/Kconfig +2 -7
@@ -227,7 +227,7 @@ config TAU don't assume the cpu temp is actually what /proc/cpuinfo says it is. config TAU_INT - bool "Interrupt driven TAU driver (DANGEROUS)" + bool "Interrupt driven TAU driver (EXPERIMENTAL)" depends on TAU help The TAU supports an interrupt driven mode which causes an interrupt
@@ -235,12 +235,7 @@ config TAU_INT to get notified the temp has exceeded a range. With this option off, a timer is used to re-check the temperature periodically. - However, on some cpus it appears that the TAU interrupt hardware - is buggy and can cause a situation which would lead unexplained hard - lockups. - - Unless you are extending the TAU driver, or enjoy kernel/hardware - debugging, leave this option off. + If in doubt, say N here. config TAU_AVERAGE bool "Average high and low temp"
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 449/757 powerpc/kasan: Fix CONFIG_KASAN_VMALLOC for 8xx
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
[ Upstream commit 4c42dc5c69a8f24c467a6c997909d2f1d4efdc7f ]
Before the commit identified below, pages tables allocation was performed after the allocation of final shadow area for linear memory. But that commit switched the order, leading to page tables being already allocated at the time 8xx kasan_init_shadow_8M() is called. Due to this, kasan_init_shadow_8M() doesn't map the needed shadow entries because there are already page tables.
kasan_init_shadow_8M() installs huge PMD entries instead of page tables. We could at that time free the page tables, but there is no point in creating page tables that get freed before being used.
Only book3s/32 hash needs early allocation of page tables. For other variants, we can keep the initial order and create remaining page tables after the allocation of final shadow memory for linear mem.
Move back the allocation of shadow page tables for CONFIG_KASAN_VMALLOC into kasan_init() after the loop which creates final shadow memory for linear mem.
--- arch/powerpc/mm/kasan/kasan_init_32.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
arch/powerpc/mm/kasan/kasan_init_32.c +9 -3
@@ -127,8 +127,7 @@ void __init kasan_mmu_init(void) {int ret; -if (early_mmu_has_feature (MMU_FTR_HPTE_TABLE ) || -IS_ENABLED (CONFIG_KASAN_VMALLOC )) { +if (early_mmu_has_feature (MMU_FTR_HPTE_TABLE )) { ret =kasan_init_shadow_page_tables (KASAN_SHADOW_START ,KASAN_SHADOW_END );if (ret)
@@ -139,11 +138,11 @@ void __init kasan_mmu_init(void)void __init kasan_init (void ) {struct memblock_region *reg; +int ret;for_each_memblock (memory, reg) {phys_addr_t base = reg->base;phys_addr_t top =min (base + reg->size, total_lowmem); -int ret;if (base >= top)continue ;
@@ -153,6 +152,13 @@ void __init kasan_init(void)panic ("kasan: kasan_init_region() failed" ); } +if (IS_ENABLED (CONFIG_KASAN_VMALLOC )) { + ret =kasan_init_shadow_page_tables (KASAN_SHADOW_START ,KASAN_SHADOW_END ); + +if (ret) +panic ("kasan: kasan_init_shadow_page_tables() failed" ); + } +kasan_remap_early_shadow_ro ();clear_page (kasan_early_shadow_page);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 450/757 powerpc/64s/radix: Fix mm_cpumask trimming race vs kthread_use_mm
In reply to Greg Kroah-HartmanFrom: Nicholas Piggin <[email protected]>
[ Upstream commit a665eec0a22e11cdde708c1c256a465ebe768047 ]
Commit 0cef77c7798a7 ("powerpc/64s/radix: flush remote CPUs out of single-threaded mm_cpumask") added a mechanism to trim the mm_cpumask of a process under certain conditions. One of the assumptions is that mm_users would not be incremented via a reference outside the process context with mmget_not_zero() then go on to kthread_use_mm() via that reference.
That invariant was broken by io_uring code (see previous sparc64 fix), but I'll point Fixes: to the original powerpc commit because we are changing that assumption going forward, so this will make backports match up.
Fix this by no longer relying on that assumption, but by having each CPU check the mm is not being used, and clearing their own bit from the mask only if it hasn't been switched-to by the time the IPI is processed.
This relies on commit 38cf307c1f20 ("mm: fix kthread_use_mm() vs TLB invalidate") and ARCH_WANT_IRQS_OFF_ACTIVATE_MM to disable irqs over mm switch sequences.
Depends-on: 38cf307c1f20 ("mm: fix kthread_use_mm() vs TLB invalidate")
--- arch/powerpc/include/asm/tlb.h | 13 ------------- arch/powerpc/mm/book3s64/radix_tlb.c | 23 ++++++++++++++++------- 2 files changed, 16 insertions(+), 20 deletions(-)
arch/powerpc/include/asm/tlb.h +0 -13
@@ -66,19 +66,6 @@ static inline int mm_is_thread_local(struct mm_struct *mm)return false; return cpumask_test_cpu(smp_processor_id(), mm_cpumask(mm)); } -static inline void mm_reset_thread_local (struct mm_struct *mm) -{ -WARN_ON (atomic_read (&mm->context.copros) >0 ); -/* -* It's possible for mm_access to take a reference on mm_users to -* access the remote mm from another thread, but it's not allowed -* to set mm_cpumask, so mm_users may be > 1 here. -*/ -WARN_ON (current->mm != mm); -atomic_set (&mm->context.active_cpus,1 ); -cpumask_clear (mm_cpumask (mm)); -cpumask_set_cpu (smp_processor_id (),mm_cpumask (mm)); -}#else /* CONFIG_PPC_BOOK3S_64 */ static inline int mm_is_thread_local (struct mm_struct *mm) {
arch/powerpc/mm/book3s64/radix_tlb.c +16 -7
@@ -645,19 +645,29 @@ static void do_exit_flush_lazy_tlb(void *arg)struct mm_struct *mm = arg;unsigned long pid = mm->context.id; +/* +* A kthread could have done a mmget_not_zero() after the flushing CPU +* checked mm_is_singlethreaded, and be in the process of +* kthread_use_mm when interrupted here. In that case, current->mm will +* be set to mm, because kthread_use_mm() setting ->mm and switching to +* the mm is done with interrupts off. +*/ if (current->mm == mm) -return ;/* Local CPU */ + goto out_flush;if (current->active_mm == mm) { -/* -* Must be a kernel thread because sender is single-threaded. -*/ -BUG_ON (current->mm); +WARN_ON_ONCE (current->mm !=NULL ); +/* Is a kernel thread and is using mm as the lazy tlb */ mmgrab (&init_mm); -switch_mm (mm, &init_mm, current); current->active_mm = &init_mm; +switch_mm_irqs_off (mm, &init_mm, current);mmdrop (mm); } + +atomic_dec (&mm->context.active_cpus); +cpumask_clear_cpu (smp_processor_id (),mm_cpumask (mm)); + +out_flush:_tlbiel_pid (pid,RIC_FLUSH_ALL ); }
@@ -672,7 +682,6 @@ static void exit_flush_lazy_tlbs(struct mm_struct *mm)*/ smp_call_function_many (mm_cpumask (mm), do_exit_flush_lazy_tlb, (void *)mm,1 ); -mm_reset_thread_local (mm); }void radix__flush_tlb_mm (struct mm_struct *mm)
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 451/757 powerpc/papr_scm: Fix warning triggered by perf_stats_show()
In reply to Greg Kroah-HartmanFrom: Vaibhav Jain <[email protected]>
[ Upstream commit ca78ef2f08ccfa29b711d644964cdf9d7ace15e5 ]
A warning is reported by the kernel in case perf_stats_show() returns an error code. The warning is of the form below:
papr_scm ibm,persistent-memory:ibm,pmemory@44100001:
Failed to query performance stats, Err:-10
dev_attr_show: perf_stats_show+0x0/0x1c0 [papr_scm] returned bad count
fill_read_buffer: dev_attr_show+0x0/0xb0 returned bad count
On investigation it looks like that the compiler is silently truncating the return value of drc_pmem_query_stats() from 'long' to 'int', since the variable used to store the return code 'rc' is an 'int'. This truncated value is then returned back as a 'ssize_t' back from perf_stats_show() to 'dev_attr_show()' which thinks of it as a large unsigned number and triggers this warning..
To fix this we update the type of variable 'rc' from 'int' to 'ssize_t' that prevents the compiler from truncating the return value of drc_pmem_query_stats() and returning correct signed value back from perf_stats_show().
--- arch/powerpc/platforms/pseries/papr_scm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/powerpc/platforms/pseries/papr_scm.c +3 -2
@@ -785,7 +785,8 @@ static int papr_scm_ndctl(struct nvdimm_bus_descriptor *nd_desc,static ssize_t perf_stats_show (struct device *dev,struct device_attribute *attr,char *buf) { -int index, rc; +int index; +ssize_t rc;struct seq_buf s;struct papr_scm_perf_stat *stat;struct papr_scm_perf_stats *stats;
@@ -820,7 +821,7 @@ static ssize_t perf_stats_show(struct device *dev, free_stats:kfree (stats); -return rc ? rc :seq_buf_used (&s); +return rc ? rc : (ssize_t )seq_buf_used (&s); }DEVICE_ATTR_ADMIN_RO (perf_stats);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 452/757 RDMA/cma: Combine cma_ndev_work with cma_work
In reply to Greg Kroah-HartmanFrom: Jason Gunthorpe <[email protected]>
[ Upstream commit 7e85bcda8bfe883f4244672ed79f81b7762a1a7e ]
These are the same thing, except that cma_ndev_work doesn't have a state transition. Signal no state transition by setting old_state and new_state == 0.
In all cases the handler function should not be called once rdma_destroy_id() has progressed passed setting the state.
--- drivers/infiniband/core/cma.c | 38 +++++++---------------------------- 1 file changed, 7 insertions(+), 31 deletions(-)
drivers/infiniband/core/cma.c +7 -31
@@ -363,12 +363,6 @@ struct cma_work {struct rdma_cm_event event; }; -struct cma_ndev_work { -struct work_struct work; -struct rdma_id_private *id; -struct rdma_cm_event event; -}; -struct iboe_mcast_work {struct work_struct work;struct rdma_id_private *id;
@@ -2647,32 +2641,14 @@ static void cma_work_handler(struct work_struct *_work)struct rdma_id_private *id_priv = work->id;mutex_lock (&id_priv->handler_mutex); -if (!cma_comp_exch (id_priv, work->old_state, work->new_state)) +if (READ_ONCE (id_priv->state) ==RDMA_CM_DESTROYING || +READ_ONCE (id_priv->state) ==RDMA_CM_DEVICE_REMOVAL ) goto out_unlock; - -if (cma_cm_event_handler (id_priv, &work->event)) { -cma_id_put (id_priv); -destroy_id_handler_unlock (id_priv); - goto out_free; +if (work->old_state !=0 || work->new_state !=0 ) { +if (!cma_comp_exch (id_priv, work->old_state, work->new_state)) + goto out_unlock; } -out_unlock: -mutex_unlock (&id_priv->handler_mutex); -cma_id_put (id_priv); -out_free: -kfree (work); -} - -static void cma_ndev_work_handler (struct work_struct *_work) -{ - struct cma_ndev_work *work = container_of(_work, struct cma_ndev_work, work); -struct rdma_id_private *id_priv = work->id; - -mutex_lock (&id_priv->handler_mutex); -if (id_priv->state ==RDMA_CM_DESTROYING || - id_priv->state ==RDMA_CM_DEVICE_REMOVAL ) - goto out_unlock; -if (cma_cm_event_handler (id_priv, &work->event)) {cma_id_put (id_priv);destroy_id_handler_unlock (id_priv);
@@ -4656,7 +4632,7 @@ EXPORT_SYMBOL(rdma_leave_multicast);static int cma_netdev_change (struct net_device *ndev,struct rdma_id_private *id_priv) {struct rdma_dev_addr *dev_addr; -struct cma_ndev_work *work; +struct cma_work *work; dev_addr = &id_priv->id.route.addr.dev_addr;
@@ -4669,7 +4645,7 @@ static int cma_netdev_change(struct net_device *ndev, struct rdma_id_private *idif (!work)return -ENOMEM ; -INIT_WORK (&work->work, cma_ndev_work_handler); +INIT_WORK (&work->work, cma_work_handler); work->id = id_priv; work->event.event =RDMA_CM_EVENT_ADDR_CHANGE ;cma_id_get (id_priv);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 453/757 RDMA/cma: Remove dead code for kernel rdmacm multicast
In reply to Greg Kroah-HartmanFrom: Jason Gunthorpe <[email protected]>
[ Upstream commit 1bb5091def706732c749df9aae45fbca003696f2 ]
There is no kernel user of RDMA CM multicast so this code managing the multicast subscription of the kernel-only internal QP is dead. Remove it.
This makes the bug fixes in the next patches much simpler.
--- drivers/infiniband/core/cma.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-)
drivers/infiniband/core/cma.c +4 -15
@@ -4293,16 +4293,6 @@ static int cma_ib_mc_handler(int status, struct ib_sa_multicast *multicast)else pr_debug_ratelimited ("RDMA CM: MULTICAST_ERROR: failed to join multicast. status %d\n" , status); -mutex_lock (&id_priv->qp_mutex); -if (!status && id_priv->id.qp) { - status =ib_attach_mcast (id_priv->id.qp, &multicast->rec.mgid, -be16_to_cpu (multicast->rec.mlid)); -if (status) -pr_debug_ratelimited ("RDMA CM: MULTICAST_ERROR: failed to attach QP. status %d\n" , - status); - } -mutex_unlock (&id_priv->qp_mutex); - event.status = status; event.param.ud.private_data = mc->context;if (!status) {
@@ -4555,6 +4545,10 @@ int rdma_join_multicast(struct rdma_cm_id *id, struct sockaddr *addr,struct cma_multicast *mc;int ret; +/* Not supported for kernel QPs */ +if (WARN_ON (id->qp)) +return -EINVAL ; +if (!id->device)return -EINVAL ;
@@ -4609,11 +4603,6 @@ void rdma_leave_multicast(struct rdma_cm_id *id, struct sockaddr *addr)list_del (&mc->list);spin_unlock_irq (&id_priv->lock); -if (id->qp) -ib_detach_mcast (id->qp, - &mc->multicast.ib->rec.mgid, -be16_to_cpu (mc->multicast.ib->rec.mlid)); -BUG_ON (id_priv->cma_dev->device != id->device);if (rdma_cap_ib_mcast (id->device, id->port_num)) {
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 454/757 RDMA/cma: Consolidate the destruction of a cma_multicast in one place
In reply to Greg Kroah-HartmanFrom: Jason Gunthorpe <[email protected]>
[ Upstream commit 3788d2997bc0150ea911a964d5b5a2e11808a936 ]
Two places were open coding this sequence, and also pull in cma_leave_roce_mc_group() which was called only once.
--- drivers/infiniband/core/cma.c | 63 +++++++++++++++++------------------ 1 file changed, 31 insertions(+), 32 deletions(-)
drivers/infiniband/core/cma.c +31 -32
@@ -1777,19 +1777,30 @@ static void cma_release_port(struct rdma_id_private *id_priv)mutex_unlock (&lock); } -static void cma_leave_roce_mc_group (struct rdma_id_private *id_priv, -struct cma_multicast *mc) +static void destroy_mc (struct rdma_id_private *id_priv, +struct cma_multicast *mc) { -struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr; -struct net_device *ndev =NULL ; +if (rdma_cap_ib_mcast (id_priv->id.device, id_priv->id.port_num)) { +ib_sa_free_multicast (mc->multicast.ib); +kfree (mc); +return ; + } -if (dev_addr->bound_dev_if) - ndev =dev_get_by_index (dev_addr->net, dev_addr->bound_dev_if); -if (ndev) { -cma_igmp_send (ndev, &mc->multicast.ib->rec.mgid, false); -dev_put (ndev); +if (rdma_protocol_roce (id_priv->id.device, + id_priv->id.port_num)) { +struct rdma_dev_addr *dev_addr = + &id_priv->id.route.addr.dev_addr; +struct net_device *ndev =NULL ; + +if (dev_addr->bound_dev_if) + ndev =dev_get_by_index (dev_addr->net, + dev_addr->bound_dev_if); +if (ndev) { +cma_igmp_send (ndev, &mc->multicast.ib->rec.mgid, false); +dev_put (ndev); + } +kref_put (&mc->mcref, release_mc); } -kref_put (&mc->mcref, release_mc); }static void cma_leave_mc_groups (struct rdma_id_private *id_priv)
@@ -1797,16 +1808,10 @@ static void cma_leave_mc_groups(struct rdma_id_private *id_priv)struct cma_multicast *mc;while (!list_empty (&id_priv->mc_list)) { - mc =container_of (id_priv->mc_list.next, - struct cma_multicast, list); + mc = list_first_entry(&id_priv->mc_list, struct cma_multicast, + list);list_del (&mc->list); -if (rdma_cap_ib_mcast (id_priv->cma_dev->device, - id_priv->id.port_num)) { -ib_sa_free_multicast (mc->multicast.ib); -kfree (mc); - }else { -cma_leave_roce_mc_group (id_priv, mc); - } +destroy_mc (id_priv, mc); } }
@@ -4599,20 +4604,14 @@ void rdma_leave_multicast(struct rdma_cm_id *id, struct sockaddr *addr) id_priv = container_of(id, struct rdma_id_private, id);spin_lock_irq (&id_priv->lock);list_for_each_entry (mc, &id_priv->mc_list, list) { -if (!memcmp (&mc->addr, addr,rdma_addr_size (addr))) { -list_del (&mc->list); -spin_unlock_irq (&id_priv->lock); - -BUG_ON (id_priv->cma_dev->device != id->device); +if (memcmp (&mc->addr, addr,rdma_addr_size (addr)) !=0 ) +continue ; +list_del (&mc->list); +spin_unlock_irq (&id_priv->lock); -if (rdma_cap_ib_mcast (id->device, id->port_num)) { -ib_sa_free_multicast (mc->multicast.ib); -kfree (mc); - }else if (rdma_protocol_roce (id->device, id->port_num)) { -cma_leave_roce_mc_group (id_priv, mc); - } -return ; - } +WARN_ON (id_priv->cma_dev->device != id->device); +destroy_mc (id_priv, mc); +return ; }spin_unlock_irq (&id_priv->lock); }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 455/757 RDMA/cma: Fix use after free race in roce multicast join
In reply to Greg Kroah-HartmanFrom: Jason Gunthorpe <[email protected]>
[ Upstream commit b5de0c60cc30c2a3513c7188c73f3f29acc29234 ]
The roce path triggers a work queue that continues to touch the id_priv but doesn't hold any reference on it. Futher, unlike in the IB case, the work queue is not fenced during rdma_destroy_id().
This can trigger a use after free if a destroy is triggered in the incredibly narrow window after the queue_work and the work starting and obtaining the handler_mutex.
The only purpose of this work queue is to run the ULP event callback from the standard context, so switch the design to use the existing cma_work_handler() scheme. This simplifies quite a lot of the flow:
- Use the cma_work_handler() callback to launch the work for roce. This requires generating the event synchronously inside the rdma_join_multicast(), which in turn means the dummy struct ib_sa_multicast can become a simple stack variable.
- cm_work_handler() used the id_priv kref, so we can entirely eliminate the kref inside struct cma_multicast. Since the cma_multicast never leaks into an unprotected work queue the kfree can be done at the same time as for IB.
- Eliminating the general multicast.ib requires using cma_set_mgid() in a few places to recompute the mgid.
--- drivers/infiniband/core/cma.c | 196 +++++++++++++++------------------- 1 file changed, 88 insertions(+), 108 deletions(-)
drivers/infiniband/core/cma.c +88 -108
@@ -68,6 +68,9 @@ static const char * const cma_events[] = { [RDMA_CM_EVENT_TIMEWAIT_EXIT] = "timewait exit", }; +static void cma_set_mgid (struct rdma_id_private *id_priv,struct sockaddr *addr, +union ib_gid *mgid); + const char *__attribute_const__ rdma_event_msg(enum rdma_cm_event_type event) {size_t index = event;
@@ -345,13 +348,10 @@ struct ib_device *cma_get_ib_dev(struct cma_device *cma_dev)struct cma_multicast {struct rdma_id_private *id_priv; -union { -struct ib_sa_multicast *ib; - } multicast; +struct ib_sa_multicast *sa_mc;struct list_head list;void *context;struct sockaddr_storage addr; -struct kref mcref;u8 join_state; };
@@ -363,12 +363,6 @@ struct cma_work {struct rdma_cm_event event; }; -struct iboe_mcast_work { -struct work_struct work; -struct rdma_id_private *id; -struct cma_multicast *mc; -}; -union cma_ip_addr {struct in6_addr ip6;struct {
@@ -477,14 +471,6 @@ static void cma_attach_to_dev(struct rdma_id_private *id_priv, rdma_start_port(cma_dev->device)]; } -static inline void release_mc (struct kref *kref) -{ - struct cma_multicast *mc = container_of(kref, struct cma_multicast, mcref); - -kfree (mc->multicast.ib); -kfree (mc); -} -static void cma_release_dev (struct rdma_id_private *id_priv) {mutex_lock (&lock);
@@ -1780,14 +1766,10 @@ static void cma_release_port(struct rdma_id_private *id_priv)static void destroy_mc (struct rdma_id_private *id_priv,struct cma_multicast *mc) { -if (rdma_cap_ib_mcast (id_priv->id.device, id_priv->id.port_num)) { -ib_sa_free_multicast (mc->multicast.ib); -kfree (mc); -return ; - } +if (rdma_cap_ib_mcast (id_priv->id.device, id_priv->id.port_num)) +ib_sa_free_multicast (mc->sa_mc); -if (rdma_protocol_roce (id_priv->id.device, - id_priv->id.port_num)) { +if (rdma_protocol_roce (id_priv->id.device, id_priv->id.port_num)) {struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr;struct net_device *ndev =NULL ;
@@ -1796,11 +1778,15 @@ static void destroy_mc(struct rdma_id_private *id_priv, ndev =dev_get_by_index (dev_addr->net, dev_addr->bound_dev_if);if (ndev) { -cma_igmp_send (ndev, &mc->multicast.ib->rec.mgid, false); +union ib_gid mgid; + +cma_set_mgid (id_priv, (struct sockaddr *)&mc->addr, + &mgid); +cma_igmp_send (ndev, &mgid, false);dev_put (ndev); } -kref_put (&mc->mcref, release_mc); } +kfree (mc); }static void cma_leave_mc_groups (struct rdma_id_private *id_priv)
@@ -2664,6 +2650,8 @@ static void cma_work_handler(struct work_struct *_work)mutex_unlock (&id_priv->handler_mutex);cma_id_put (id_priv); out_free: +if (work->event.event ==RDMA_CM_EVENT_MULTICAST_JOIN ) +rdma_destroy_ah_attr (&work->event.param.ud.ah_attr);kfree (work); }
@@ -4280,53 +4268,66 @@ int rdma_disconnect(struct rdma_cm_id *id) }EXPORT_SYMBOL (rdma_disconnect); +static void cma_make_mc_event (int status,struct rdma_id_private *id_priv, +struct ib_sa_multicast *multicast, +struct rdma_cm_event *event, +struct cma_multicast *mc) +{ +struct rdma_dev_addr *dev_addr; +enum ib_gid_type gid_type; +struct net_device *ndev; + +if (!status) + status =cma_set_qkey (id_priv,be32_to_cpu (multicast->rec.qkey)); +else +pr_debug_ratelimited ("RDMA CM: MULTICAST_ERROR: failed to join multicast. status %d\n" , + status); + + event->status = status; + event->param.ud.private_data = mc->context; +if (status) { + event->event =RDMA_CM_EVENT_MULTICAST_ERROR ; +return ; + } + + dev_addr = &id_priv->id.route.addr.dev_addr; + ndev =dev_get_by_index (dev_addr->net, dev_addr->bound_dev_if); + gid_type = + id_priv->cma_dev + ->default_gid_type[id_priv->id.port_num - +rdma_start_port ( + id_priv->cma_dev->device)]; + + event->event =RDMA_CM_EVENT_MULTICAST_JOIN ; +if (ib_init_ah_from_mcmember (id_priv->id.device, id_priv->id.port_num, + &multicast->rec, ndev, gid_type, + &event->param.ud.ah_attr)) { + event->event =RDMA_CM_EVENT_MULTICAST_ERROR ; + goto out; + } + + event->param.ud.qp_num =0xFFFFFF ; + event->param.ud.qkey =be32_to_cpu (multicast->rec.qkey); + +out: +if (ndev) +dev_put (ndev); +} +static int cma_ib_mc_handler (int status,struct ib_sa_multicast *multicast) { -struct rdma_id_private *id_priv;struct cma_multicast *mc = multicast->context; +struct rdma_id_private *id_priv = mc->id_priv;struct rdma_cm_event event = {};int ret =0 ; - id_priv = mc->id_priv;mutex_lock (&id_priv->handler_mutex);if (id_priv->state !=RDMA_CM_ADDR_BOUND && id_priv->state !=RDMA_CM_ADDR_RESOLVED ) goto out; -if (!status) - status =cma_set_qkey (id_priv,be32_to_cpu (multicast->rec.qkey)); -else -pr_debug_ratelimited ("RDMA CM: MULTICAST_ERROR: failed to join multicast. status %d\n" , - status); - event.status = status; - event.param.ud.private_data = mc->context; -if (!status) { -struct rdma_dev_addr *dev_addr = - &id_priv->id.route.addr.dev_addr; -struct net_device *ndev = -dev_get_by_index (dev_addr->net, dev_addr->bound_dev_if); -enum ib_gid_type gid_type = - id_priv->cma_dev->default_gid_type[id_priv->id.port_num - -rdma_start_port (id_priv->cma_dev->device)]; - - event.event =RDMA_CM_EVENT_MULTICAST_JOIN ; - ret =ib_init_ah_from_mcmember (id_priv->id.device, - id_priv->id.port_num, - &multicast->rec, - ndev, gid_type, - &event.param.ud.ah_attr); -if (ret) - event.event =RDMA_CM_EVENT_MULTICAST_ERROR ; - - event.param.ud.qp_num =0xFFFFFF ; - event.param.ud.qkey =be32_to_cpu (multicast->rec.qkey); -if (ndev) -dev_put (ndev); - }else - event.event =RDMA_CM_EVENT_MULTICAST_ERROR ; - +cma_make_mc_event (status, id_priv, multicast, &event, mc); ret =cma_cm_event_handler (id_priv, &event); -rdma_destroy_ah_attr (&event.param.ud.ah_attr);if (ret) {destroy_id_handler_unlock (id_priv);
@@ -4416,23 +4417,10 @@ static int cma_join_ib_multicast(struct rdma_id_private *id_priv,IB_SA_MCMEMBER_REC_MTU |IB_SA_MCMEMBER_REC_HOP_LIMIT ; - mc->multicast.ib =ib_sa_join_multicast (&sa_client, id_priv->id.device, - id_priv->id.port_num, &rec, - comp_mask,GFP_KERNEL , - cma_ib_mc_handler, mc); -return PTR_ERR_OR_ZERO (mc->multicast.ib); -} - -static void iboe_mcast_work_handler (struct work_struct *work) -{ - struct iboe_mcast_work *mw = container_of(work, struct iboe_mcast_work, work); -struct cma_multicast *mc = mw->mc; -struct ib_sa_multicast *m = mc->multicast.ib; - - mc->multicast.ib->context = mc; -cma_ib_mc_handler (0 , m); -kref_put (&mc->mcref, release_mc); -kfree (mw); + mc->sa_mc =ib_sa_join_multicast (&sa_client, id_priv->id.device, + id_priv->id.port_num, &rec, comp_mask, +GFP_KERNEL , cma_ib_mc_handler, mc); +return PTR_ERR_OR_ZERO (mc->sa_mc); } static void cma_iboe_set_mgid(struct sockaddr *addr, union ib_gid *mgid,
@@ -4467,52 +4455,47 @@ static void cma_iboe_set_mgid(struct sockaddr *addr, union ib_gid *mgid,static int cma_iboe_join_multicast (struct rdma_id_private *id_priv,struct cma_multicast *mc) { -struct iboe_mcast_work *work; +struct cma_work *work;struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr;int err =0 ;struct sockaddr *addr = (struct sockaddr *)&mc->addr;struct net_device *ndev =NULL ; +struct ib_sa_multicast ib;enum ib_gid_type gid_type;bool send_only; send_only = mc->join_state ==BIT (SENDONLY_FULLMEMBER_JOIN ); -if (cma_zero_addr ((struct sockaddr *)&mc->addr)) +if (cma_zero_addr (addr))return -EINVAL ; work =kzalloc (sizeof *work,GFP_KERNEL );if (!work)return -ENOMEM ; - mc->multicast.ib =kzalloc (sizeof (struct ib_sa_multicast ),GFP_KERNEL ); -if (!mc->multicast.ib) { - err = -ENOMEM ; - goto out1; - } - gid_type = id_priv->cma_dev->default_gid_type[id_priv->id.port_num -rdma_start_port (id_priv->cma_dev->device)]; -cma_iboe_set_mgid (addr, &mc->multicast.ib->rec.mgid, gid_type); +cma_iboe_set_mgid (addr, &ib.rec.mgid, gid_type); - mc->multicast.ib->rec.pkey =cpu_to_be16 (0xffff ); + ib.rec.pkey =cpu_to_be16 (0xffff );if (id_priv->id.ps ==RDMA_PS_UDP ) - mc->multicast.ib->rec.qkey =cpu_to_be32 (RDMA_UDP_QKEY ); + ib.rec.qkey =cpu_to_be32 (RDMA_UDP_QKEY );if (dev_addr->bound_dev_if) ndev =dev_get_by_index (dev_addr->net, dev_addr->bound_dev_if);if (!ndev) { err = -ENODEV ; - goto out2; + goto err_free; } - mc->multicast.ib->rec.rate =iboe_get_rate (ndev); - mc->multicast.ib->rec.hop_limit =1 ; - mc->multicast.ib->rec.mtu =iboe_get_mtu (ndev->mtu); + ib.rec.rate =iboe_get_rate (ndev); + ib.rec.hop_limit =1 ; + ib.rec.mtu =iboe_get_mtu (ndev->mtu);if (addr->sa_family ==AF_INET ) {if (gid_type ==IB_GID_TYPE_ROCE_UDP_ENCAP ) { - mc->multicast.ib->rec.hop_limit =IPV6_DEFAULT_HOPLIMIT ; + ib.rec.hop_limit =IPV6_DEFAULT_HOPLIMIT ;if (!send_only) { - err =cma_igmp_send (ndev, &mc->multicast.ib->rec.mgid, + err =cma_igmp_send (ndev, &ib.rec.mgid, true); } }
@@ -4521,24 +4504,22 @@ static int cma_iboe_join_multicast(struct rdma_id_private *id_priv, err = -ENOTSUPP ; }dev_put (ndev); -if (err || !mc->multicast.ib->rec.mtu) { +if (err || !ib.rec.mtu) {if (!err) err = -EINVAL ; - goto out2; + goto err_free; }rdma_ip2gid ((struct sockaddr *)&id_priv->id.route.addr.src_addr, - &mc->multicast.ib->rec.port_gid); + &ib.rec.port_gid); work->id = id_priv; - work->mc = mc; -INIT_WORK (&work->work, iboe_mcast_work_handler); -kref_get (&mc->mcref); +INIT_WORK (&work->work, cma_work_handler); +cma_make_mc_event (0 , id_priv, &ib, &work->event, mc); +/* Balances with cma_id_put() in cma_work_handler */ +cma_id_get (id_priv);queue_work (cma_wq, &work->work); -return 0 ; -out2: -kfree (mc->multicast.ib); -out1: +err_free:kfree (work);return err; }
@@ -4562,7 +4543,7 @@ int rdma_join_multicast(struct rdma_cm_id *id, struct sockaddr *addr, !cma_comp(id_priv, RDMA_CM_ADDR_RESOLVED))return -EINVAL ; - mc =kmalloc (sizeof *mc,GFP_KERNEL ); + mc =kzalloc (sizeof (*mc),GFP_KERNEL );if (!mc)return -ENOMEM ;
@@ -4572,7 +4553,6 @@ int rdma_join_multicast(struct rdma_cm_id *id, struct sockaddr *addr, mc->join_state = join_state;if (rdma_protocol_roce (id->device, id->port_num)) { -kref_init (&mc->mcref); ret =cma_iboe_join_multicast (id_priv, mc);if (ret) goto out_err;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 456/757 perf intel-pt: Fix "context_switch event has no tid" error
In reply to Greg Kroah-HartmanFrom: Adrian Hunter <[email protected]>
[ Upstream commit 7d537a8d2e76bc4fc71e34545ceaa463ac2cd928 ]
A context_switch event can have no tid because pids can be detached from a task while the task is still running (in do_exit()). Note this won't happen with per-task contexts because then tracing stops at perf_event_exit_task()
If a task with no tid gets preempted, or a dying task gets preempted and its parent releases it, when it subsequently gets switched back in, Intel PT will not be able to determine what task is running and prints an error "context_switch event has no tid". However, it is not really an error because the task is in kernel space and the decoder can continue to decode successfully. Fix by changing the error to be only a logged message, and make allowance for tid == -1.
Example:
Using 5.9-rc4 with Preemptible Kernel (Low-Latency Desktop) e.g.
$ uname -r 5.9.0-rc4 $ grep PREEMPT .config # CONFIG_PREEMPT_NONE is not set # CONFIG_PREEMPT_VOLUNTARY is not set CONFIG_PREEMPT=y CONFIG_PREEMPT_COUNT=y CONFIG_PREEMPTION=y CONFIG_PREEMPT_RCU=y CONFIG_PREEMPT_NOTIFIERS=y CONFIG_DRM_I915_PREEMPT_TIMEOUT=640 CONFIG_DEBUG_PREEMPT=y # CONFIG_PREEMPT_TRACER is not set # CONFIG_PREEMPTIRQ_DELAY_TEST is not set
Before:
$ cat forkit.c
#include <sys/types.h>
#include <unistd.h>
#include <sys/wait.h>
int main()
{
pid_t child;
int status = 0; child = fork();
if (child == 0)
return 123;
wait(&status);
return 0;}
$ gcc -o forkit forkit.c $ sudo ~/bin/perf record --kcore -a -m,64M -e intel_pt/cyc/k & [1] 11016 $ taskset 2 ./forkit $ sudo pkill perf $ [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 17.262 MB perf.data ]
[1]+ Terminated sudo ~/bin/perf record --kcore -a -m,64M -e intel_pt/cyc/k
$ sudo ~/bin/perf script --show-task-events --show-switch-events --itrace=iqqe-o -C 1 --ns | grep -C 2 forkit
context_switch event has no tid
taskset 11019 [001] 66663.270045029: 1 instructions:k: ffffffffb1d9f844 strnlen_user+0xb4 ([kernel.kallsyms])
taskset 11019 [001] 66663.270201816: 1 instructions:k: ffffffffb1a83121 unmap_page_range+0x561 ([kernel.kallsyms])
forkit 11019 [001] 66663.270327553: PERF_RECORD_COMM exec: forkit:11019/11019
forkit 11019 [001] 66663.270420028: 1 instructions:k: ffffffffb1db9537 __clear_user+0x27 ([kernel.kallsyms])
forkit 11019 [001] 66663.270648704: 1 instructions:k: ffffffffb18829e6 do_user_addr_fault+0xf6 ([kernel.kallsyms])
forkit 11019 [001] 66663.270833163: 1 instructions:k: ffffffffb230a825 irqentry_exit_to_user_mode+0x15 ([kernel.kallsyms])
forkit 11019 [001] 66663.271092359: 1 instructions:k: ffffffffb1aea3d9 lock_page_memcg+0x9 ([kernel.kallsyms])
forkit 11019 [001] 66663.271207092: PERF_RECORD_FORK(11020:11020):(11019:11019)
forkit 11019 [001] 66663.271234775: PERF_RECORD_SWITCH_CPU_WIDE OUT next pid/tid: 11020/11020
forkit 11020 [001] 66663.271238407: PERF_RECORD_SWITCH_CPU_WIDE IN prev pid/tid: 11019/11019
forkit 11020 [001] 66663.271312066: 1 instructions:k: ffffffffb1a88140 handle_mm_fault+0x10 ([kernel.kallsyms])
forkit 11020 [001] 66663.271476225: PERF_RECORD_EXIT(11020:11020):(11019:11019)
forkit 11020 [001] 66663.271497488: PERF_RECORD_SWITCH_CPU_WIDE OUT preempt next pid/tid: 11019/11019
forkit 11019 [001] 66663.271500523: PERF_RECORD_SWITCH_CPU_WIDE IN prev pid/tid: 11020/11020
forkit 11019 [001] 66663.271517241: 1 instructions:k: ffffffffb24012cd error_entry+0x6d ([kernel.kallsyms])
forkit 11019 [001] 66663.271664080: PERF_RECORD_EXIT(11019:11019):(1386:1386)After:
$ sudo ~/bin/perf script --show-task-events --show-switch-events --itrace=iqqe-o -C 1 --ns | grep -C 2 forkit
taskset 11019 [001] 66663.270045029: 1 instructions:k: ffffffffb1d9f844 strnlen_user+0xb4 ([kernel.kallsyms])
taskset 11019 [001] 66663.270201816: 1 instructions:k: ffffffffb1a83121 unmap_page_range+0x561 ([kernel.kallsyms])
forkit 11019 [001] 66663.270327553: PERF_RECORD_COMM exec: forkit:11019/11019
forkit 11019 [001] 66663.270420028: 1 instructions:k: ffffffffb1db9537 __clear_user+0x27 ([kernel.kallsyms])
forkit 11019 [001] 66663.270648704: 1 instructions:k: ffffffffb18829e6 do_user_addr_fault+0xf6 ([kernel.kallsyms])
forkit 11019 [001] 66663.270833163: 1 instructions:k: ffffffffb230a825 irqentry_exit_to_user_mode+0x15 ([kernel.kallsyms])
forkit 11019 [001] 66663.271092359: 1 instructions:k: ffffffffb1aea3d9 lock_page_memcg+0x9 ([kernel.kallsyms])
forkit 11019 [001] 66663.271207092: PERF_RECORD_FORK(11020:11020):(11019:11019)
forkit 11019 [001] 66663.271234775: PERF_RECORD_SWITCH_CPU_WIDE OUT next pid/tid: 11020/11020
forkit 11020 [001] 66663.271238407: PERF_RECORD_SWITCH_CPU_WIDE IN prev pid/tid: 11019/11019
forkit 11020 [001] 66663.271312066: 1 instructions:k: ffffffffb1a88140 handle_mm_fault+0x10 ([kernel.kallsyms])
forkit 11020 [001] 66663.271476225: PERF_RECORD_EXIT(11020:11020):(11019:11019)
forkit 11020 [001] 66663.271497488: PERF_RECORD_SWITCH_CPU_WIDE OUT preempt next pid/tid: 11019/11019
forkit 11019 [001] 66663.271500523: PERF_RECORD_SWITCH_CPU_WIDE IN prev pid/tid: 11020/11020
forkit 11019 [001] 66663.271517241: 1 instructions:k: ffffffffb24012cd error_entry+0x6d ([kernel.kallsyms])
forkit 11019 [001] 66663.271664080: PERF_RECORD_EXIT(11019:11019):(1386:1386)
forkit 11019 [001] 66663.271688752: PERF_RECORD_SWITCH_CPU_WIDE OUT next pid/tid: -1/-1
:-1 -1 [001] 66663.271692086: PERF_RECORD_SWITCH_CPU_WIDE IN prev pid/tid: 11019/11019
:-1 -1 [001] 66663.271707466: 1 instructions:k: ffffffffb18eb096 update_load_avg+0x306 ([kernel.kallsyms])--- tools/perf/util/intel-pt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
tools/perf/util/intel-pt.c +4 -4
@@ -1101,6 +1101,8 @@ static void intel_pt_set_pid_tid_cpu(struct intel_pt *pt,if (queue->tid ==-1 || pt->have_sched_switch) { ptq->tid =machine__get_current_tid (pt->machine, ptq->cpu); +if (ptq->tid ==-1 ) + ptq->pid =-1 ;thread__zput (ptq->thread); }
@@ -2603,10 +2605,8 @@ static int intel_pt_context_switch(struct intel_pt *pt, union perf_event *event, tid = sample->tid; } -if (tid ==-1 ) { -pr_err ("context_switch event has no tid\n" ); -return -EINVAL ; - } +if (tid ==-1 ) +intel_pt_log ("context_switch event has no tid\n" ); ret =intel_pt_sync_switch (pt, cpu, tid, sample->time);if (ret <=0 )
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 457/757 perf metricgroup: Fix uncore metric expressions
In reply to Greg Kroah-HartmanFrom: Ian Rogers <[email protected]>
[ Upstream commit dcc81be0fc4e66943041e6e19a5faf8f8704a27e ]
A metric like DRAM_BW_Use has on SkylakeX events uncore_imc/cas_count_read/ and uncore_imc/case_count_write/.
These events open 6 events per socket with pmu names of uncore_imc_[0-5].
The current metric setup code in find_evsel_group assumes one ID will map to 1 event to be recorded in metric_events.
For events with multiple matches, the first event is recorded in metric_events (avoiding matching >1 event with the same name) and the evlist_used updated so that duplicate events aren't removed when the evlist has unused events removed.
Before this change:
$ /tmp/perf/perf stat -M DRAM_BW_Use -a -- sleep 1
Performance counter stats for 'system wide':
41.14 MiB uncore_imc/cas_count_read/
1,002,614,251 ns duration_time
1.002614251 seconds time elapsedAfter this change:
$ /tmp/perf/perf stat -M DRAM_BW_Use -a -- sleep 1
Performance counter stats for 'system wide':
157.47 MiB uncore_imc/cas_count_read/ # 0.00 DRAM_BW_Use
126.97 MiB uncore_imc/cas_count_write/
1,003,019,728 ns duration_timeErroneous duplication introduced in:
commit 2440689d62e9 ("perf metricgroup: Remove duped metric group events").
--- tools/perf/util/metricgroup.c | 75 ++++++++++++++++++++++++++--------- 1 file changed, 56 insertions(+), 19 deletions(-)
tools/perf/util/metricgroup.c +56 -19
@@ -150,6 +150,18 @@ static void expr_ids__exit(struct expr_ids *ids)free (ids->id[i].id); } +static bool contains_event (struct evsel **metric_events,int num_events, +const char *event_name) +{ +int i; + +for (i =0 ; i < num_events; i++) { +if (!strcmp (metric_events[i]->name, event_name)) +return true; + } +return false; +} +/** * Find a group of events in perf_evlist that correpond to those from a parsed * metric expression. Note, as find_evsel_group is called in the same order as
@@ -180,7 +192,11 @@ static struct evsel *find_evsel_group(struct evlist *perf_evlist,int i =0 , matched_events =0 , events_to_match;const int idnum = (int )hashmap__size (&pctx->ids); -/* duration_time is grouped separately. */ +/* +* duration_time is always grouped separately, when events are grouped +* (ie has_constraint is false) then ignore it in the matching loop and +* add it to metric_events at the end. +*/ if (!has_constraint &&hashmap__find (&pctx->ids,"duration_time" , (void **)&val_ptr)) events_to_match = idnum -1 ;
@@ -207,23 +223,20 @@ static struct evsel *find_evsel_group(struct evlist *perf_evlist, sizeof(struct evsel *) * idnum); current_leader = ev->leader; } -if (hashmap__find (&pctx->ids, ev->name, (void **)&val_ptr)) { -if (has_constraint) { -/* -* Events aren't grouped, ensure the same event -* isn't matched from two groups. -*/ -for (i =0 ; i < matched_events; i++) { -if (!strcmp (ev->name, - metric_events[i]->name)) { -break ; - } - } -if (i != matched_events) -continue ; - } +/* +* Check for duplicate events with the same name. For example, +* uncore_imc/cas_count_read/ will turn into 6 events per socket +* on skylakex. Only the first such event is placed in +* metric_events. If events aren't grouped then this also +* ensures that the same event in different sibling groups +* aren't both added to metric_events. +*/ +if (contains_event (metric_events, matched_events, ev->name)) +continue ; +/* Does this event belong to the parse context? */ +if (hashmap__find (&pctx->ids, ev->name, (void **)&val_ptr)) metric_events[matched_events++] = ev; - } +if (matched_events == events_to_match)break ; }
@@ -239,7 +252,7 @@ static struct evsel *find_evsel_group(struct evlist *perf_evlist, }if (matched_events != idnum) { -/* Not whole match */ +/* Not a whole match */ return NULL ; }
@@ -247,8 +260,32 @@ static struct evsel *find_evsel_group(struct evlist *perf_evlist,for (i =0 ; i < idnum; i++) { ev = metric_events[i]; - ev->metric_leader = ev; +/* Don't free the used events. */ set_bit (ev->idx, evlist_used); +/* +* The metric leader points to the identically named event in +* metric_events. +*/ + ev->metric_leader = ev; +/* +* Mark two events with identical names in the same group (or +* globally) as being in use as uncore events may be duplicated +* for each pmu. Set the metric leader of such events to be the +* event that appears in metric_events. +*/ +evlist__for_each_entry_continue (perf_evlist, ev) { +/* +* If events are grouped then the search can terminate +* when then group is left. +*/ +if (!has_constraint && + ev->leader != metric_events[i]->leader) +break ; +if (!strcmp (metric_events[i]->name, ev->name)) { +set_bit (ev->idx, evlist_used); + ev->metric_leader = metric_events[i]; + } + } }return metric_events[0 ];
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 458/757 RDMA/qedr: Fix resource leak in qedr_create_qp
In reply to Greg Kroah-HartmanFrom: Keita Suzuki <[email protected]>
[ Upstream commit 3e45410fe3c202ffb619f301beff0644f717e132 ]
When xa_insert() fails, the acquired resource in qedr_create_qp should also be freed. However, current implementation does not handle the error.
Fix this by adding a new goto label that calls qedr_free_qp_resources.
--- drivers/infiniband/hw/qedr/verbs.c | 52 ++++++++++++++++-------------- 1 file changed, 27 insertions(+), 25 deletions(-)
drivers/infiniband/hw/qedr/verbs.c +27 -25
@@ -2113,6 +2113,28 @@ static int qedr_create_kernel_qp(struct qedr_dev *dev,return rc; } +static int qedr_free_qp_resources (struct qedr_dev *dev,struct qedr_qp *qp, +struct ib_udata *udata) +{ +struct qedr_ucontext *ctx = + rdma_udata_to_drv_context(udata, struct qedr_ucontext, + ibucontext); +int rc; + +if (qp->qp_type !=IB_QPT_GSI ) { + rc = dev->ops->rdma_destroy_qp (dev->rdma_ctx, qp->qed_qp); +if (rc) +return rc; + } + +if (qp->create_type ==QEDR_QP_CREATE_USER ) +qedr_cleanup_user (dev, ctx, qp); +else +qedr_cleanup_kernel (dev, qp); + +return 0 ; +} +struct ib_qp *qedr_create_qp (struct ib_pd *ibpd,struct ib_qp_init_attr *attrs,struct ib_udata *udata)
@@ -2159,19 +2181,21 @@ struct ib_qp *qedr_create_qp(struct ib_pd *ibpd, rc =qedr_create_kernel_qp (dev, qp, ibpd, attrs);if (rc) - goto err; + goto out_free_qp; qp->ibqp.qp_num = qp->qp_id;if (rdma_protocol_iwarp (&dev->ibdev,1 )) { rc =xa_insert (&dev->qps, qp->qp_id, qp,GFP_KERNEL );if (rc) - goto err; + goto out_free_qp_resources; }return &qp->ibqp; -err: +out_free_qp_resources: +qedr_free_qp_resources (dev, qp, udata); +out_free_qp:kfree (qp);return ERR_PTR (-EFAULT );
@@ -2672,28 +2696,6 @@ int qedr_query_qp(struct ib_qp *ibqp,return rc; } -static int qedr_free_qp_resources (struct qedr_dev *dev,struct qedr_qp *qp, -struct ib_udata *udata) -{ -struct qedr_ucontext *ctx = - rdma_udata_to_drv_context(udata, struct qedr_ucontext, - ibucontext); -int rc; - -if (qp->qp_type !=IB_QPT_GSI ) { - rc = dev->ops->rdma_destroy_qp (dev->rdma_ctx, qp->qed_qp); -if (rc) -return rc; - } - -if (qp->create_type ==QEDR_QP_CREATE_USER ) -qedr_cleanup_user (dev, ctx, qp); -else -qedr_cleanup_kernel (dev, qp); - -return 0 ; -} -int qedr_destroy_qp (struct ib_qp *ibqp,struct ib_udata *udata) {struct qedr_qp *qp =get_qedr_qp (ibqp);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 459/757 RDMA/hns: Set the unsupported wr opcode
In reply to Greg Kroah-HartmanFrom: Lijun Ou <[email protected]>
[ Upstream commit 22d3e1ed2cc837af87f76c3c8a4ccf4455e225c5 ]
hip06 does not support IB_WR_LOCAL_INV, so the ps_opcode should be set to an invalid value instead of being left uninitialized.
--- drivers/infiniband/hw/hns/hns_roce_hw_v1.c | 1 - 1 file changed, 1 deletion(-)
drivers/infiniband/hw/hns/hns_roce_hw_v1.c +0 -1
@@ -271,7 +271,6 @@ static int hns_roce_v1_post_send(struct ib_qp *ibqp, ps_opcode =HNS_ROCE_WQE_OPCODE_SEND ;break ;case IB_WR_LOCAL_INV : -break ;case IB_WR_ATOMIC_CMP_AND_SWP :case IB_WR_ATOMIC_FETCH_AND_ADD :case IB_WR_LSO :
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 460/757 RDMA/mlx5: Use set_mkc_access_pd_addr_fields() in reg_create()
In reply to Greg Kroah-HartmanFrom: Jason Gunthorpe <[email protected]>
[ Upstream commit 1c97ca3da0d12e0156a177f48ed3184c3f202002 ]
reg_create() open codes this helper, use the shared code.
--- drivers/infiniband/hw/mlx5/mr.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-)
drivers/infiniband/hw/mlx5/mr.c +1 -14
@@ -1190,29 +1190,16 @@ static struct mlx5_ib_mr *reg_create(struct ib_mr *ibmr, struct ib_pd *pd,MLX5_SET (create_mkey_in, in, pg_access, !!(pg_cap)); mkc =MLX5_ADDR_OF (create_mkey_in, in, memory_key_mkey_entry); +set_mkc_access_pd_addr_fields (mkc, access_flags, virt_addr, pd);MLX5_SET (mkc, mkc, free, !populate);MLX5_SET (mkc, mkc, access_mode_1_0,MLX5_MKC_ACCESS_MODE_MTT ); -if (MLX5_CAP_GEN (dev->mdev, relaxed_ordering_write)) -MLX5_SET (mkc, mkc, relaxed_ordering_write, - !!(access_flags &IB_ACCESS_RELAXED_ORDERING )); -if (MLX5_CAP_GEN (dev->mdev, relaxed_ordering_read)) -MLX5_SET (mkc, mkc, relaxed_ordering_read, - !!(access_flags &IB_ACCESS_RELAXED_ORDERING )); -MLX5_SET (mkc, mkc, a, !!(access_flags &IB_ACCESS_REMOTE_ATOMIC )); -MLX5_SET (mkc, mkc, rw, !!(access_flags &IB_ACCESS_REMOTE_WRITE )); -MLX5_SET (mkc, mkc, rr, !!(access_flags &IB_ACCESS_REMOTE_READ )); -MLX5_SET (mkc, mkc, lw, !!(access_flags &IB_ACCESS_LOCAL_WRITE )); -MLX5_SET (mkc, mkc, lr,1 );MLX5_SET (mkc, mkc, umr_en,1 ); -MLX5_SET64 (mkc, mkc, start_addr, virt_addr);MLX5_SET64 (mkc, mkc, len, length); -MLX5_SET (mkc, mkc, pd,to_mpd (pd)->pdn);MLX5_SET (mkc, mkc, bsf_octword_size,0 );MLX5_SET (mkc, mkc, translations_octword_size,get_octo_len (virt_addr, length, page_shift));MLX5_SET (mkc, mkc, log_page_size, page_shift); -MLX5_SET (mkc, mkc, qpn,0xffffff );if (populate) {MLX5_SET (create_mkey_in, in, translations_octword_actual_size,get_octo_len (virt_addr, length, page_shift));
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 461/757 RDMA/mlx5: Make mkeys always owned by the kernels PD when not enabled
In reply to Greg Kroah-HartmanFrom: Jason Gunthorpe <[email protected]>
[ Upstream commit 5eb29f0d13a66502b91954597270003c90fb66c5 ]
Any mkey that is not enabled and assigned to userspace should have the PD set to a kernel owned PD.
When cache entries are created for the first time the PDN is set to 0, which is probably a kernel PD, but be explicit.
When a MR is registered using the hybrid reg_create with UMR xlt & enable the disabled mkey is pointing at the user PD, keep it pointing at the kernel until a UMR enables it and sets the user PD.
--- drivers/infiniband/hw/mlx5/mr.c | 51 +++++++++++++++++---------------- 1 file changed, 26 insertions(+), 25 deletions(-)
drivers/infiniband/hw/mlx5/mr.c +26 -25
@@ -50,6 +50,29 @@ enum {static void create_mkey_callback (int status,struct mlx5_async_work *context); +static void set_mkc_access_pd_addr_fields (void *mkc,int acc,u64 start_addr, +struct ib_pd *pd) +{ +struct mlx5_ib_dev *dev =to_mdev (pd->device); + +MLX5_SET (mkc, mkc, a, !!(acc &IB_ACCESS_REMOTE_ATOMIC )); +MLX5_SET (mkc, mkc, rw, !!(acc &IB_ACCESS_REMOTE_WRITE )); +MLX5_SET (mkc, mkc, rr, !!(acc &IB_ACCESS_REMOTE_READ )); +MLX5_SET (mkc, mkc, lw, !!(acc &IB_ACCESS_LOCAL_WRITE )); +MLX5_SET (mkc, mkc, lr,1 ); + +if (MLX5_CAP_GEN (dev->mdev, relaxed_ordering_write)) +MLX5_SET (mkc, mkc, relaxed_ordering_write, + !!(acc &IB_ACCESS_RELAXED_ORDERING )); +if (MLX5_CAP_GEN (dev->mdev, relaxed_ordering_read)) +MLX5_SET (mkc, mkc, relaxed_ordering_read, + !!(acc &IB_ACCESS_RELAXED_ORDERING )); + +MLX5_SET (mkc, mkc, pd,to_mpd (pd)->pdn); +MLX5_SET (mkc, mkc, qpn,0xffffff ); +MLX5_SET64 (mkc, mkc, start_addr, start_addr); +} +static void assign_mkey_variant (struct mlx5_ib_dev *dev,struct mlx5_core_mkey *mkey,u32 *in)
@@ -152,12 +175,12 @@ static struct mlx5_ib_mr *alloc_cache_mr(struct mlx5_cache_ent *ent, void *mkc) mr->cache_ent = ent; mr->dev = ent->dev; +set_mkc_access_pd_addr_fields (mkc,0 ,0 , ent->dev->umrc.pd);MLX5_SET (mkc, mkc, free,1 );MLX5_SET (mkc, mkc, umr_en,1 );MLX5_SET (mkc, mkc, access_mode_1_0, ent->access_mode &0x3 );MLX5_SET (mkc, mkc, access_mode_4_2, (ent->access_mode >>2 ) &0x7 ); -MLX5_SET (mkc, mkc, qpn,0xffffff );MLX5_SET (mkc, mkc, translations_octword_size, ent->xlt);MLX5_SET (mkc, mkc, log_page_size, ent->page);return mr;
@@ -774,29 +797,6 @@ int mlx5_mr_cache_cleanup(struct mlx5_ib_dev *dev)return 0 ; } -static void set_mkc_access_pd_addr_fields (void *mkc,int acc,u64 start_addr, -struct ib_pd *pd) -{ -struct mlx5_ib_dev *dev =to_mdev (pd->device); - -MLX5_SET (mkc, mkc, a, !!(acc &IB_ACCESS_REMOTE_ATOMIC )); -MLX5_SET (mkc, mkc, rw, !!(acc &IB_ACCESS_REMOTE_WRITE )); -MLX5_SET (mkc, mkc, rr, !!(acc &IB_ACCESS_REMOTE_READ )); -MLX5_SET (mkc, mkc, lw, !!(acc &IB_ACCESS_LOCAL_WRITE )); -MLX5_SET (mkc, mkc, lr,1 ); - -if (MLX5_CAP_GEN (dev->mdev, relaxed_ordering_write)) -MLX5_SET (mkc, mkc, relaxed_ordering_write, - !!(acc &IB_ACCESS_RELAXED_ORDERING )); -if (MLX5_CAP_GEN (dev->mdev, relaxed_ordering_read)) -MLX5_SET (mkc, mkc, relaxed_ordering_read, - !!(acc &IB_ACCESS_RELAXED_ORDERING )); - -MLX5_SET (mkc, mkc, pd,to_mpd (pd)->pdn); -MLX5_SET (mkc, mkc, qpn,0xffffff ); -MLX5_SET64 (mkc, mkc, start_addr, start_addr); -} -struct ib_mr *mlx5_ib_get_dma_mr (struct ib_pd *pd,int acc) {struct mlx5_ib_dev *dev =to_mdev (pd->device);
@@ -1190,7 +1190,8 @@ static struct mlx5_ib_mr *reg_create(struct ib_mr *ibmr, struct ib_pd *pd,MLX5_SET (create_mkey_in, in, pg_access, !!(pg_cap)); mkc =MLX5_ADDR_OF (create_mkey_in, in, memory_key_mkey_entry); -set_mkc_access_pd_addr_fields (mkc, access_flags, virt_addr, pd); +set_mkc_access_pd_addr_fields (mkc, access_flags, virt_addr, + populate ? pd : dev->umrc.pd);MLX5_SET (mkc, mkc, free, !populate);MLX5_SET (mkc, mkc, access_mode_1_0,MLX5_MKC_ACCESS_MODE_MTT );MLX5_SET (mkc, mkc, umr_en,1 );
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 462/757 RDMA/mlx5: Disable IB_DEVICE_MEM_MGT_EXTENSIONS if IB_WR_REG_MR cant work
In reply to Greg Kroah-HartmanFrom: Jason Gunthorpe <[email protected]>
[ Upstream commit 0ec52f0194638e2d284ad55eba5a7aff753de1b9 ]
set_reg_wr() always fails if !umr_modify_entity_size_disabled because mlx5_ib_can_use_umr() always fails. Without set_reg_wr() IB_WR_REG_MR doesn't work and that means the device should not advertise IB_DEVICE_MEM_MGT_EXTENSIONS.
--- drivers/infiniband/hw/mlx5/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/main.c +3 -1
@@ -840,7 +840,9 @@ static int mlx5_ib_query_device(struct ib_device *ibdev,/* We support 'Gappy' memory registration too */ props->device_cap_flags |=IB_DEVICE_SG_GAPS_REG ; } - props->device_cap_flags |=IB_DEVICE_MEM_MGT_EXTENSIONS ; +/* IB_WR_REG_MR always requires changing the entity size with UMR */ +if (!MLX5_CAP_GEN (dev->mdev, umr_modify_entity_size_disabled)) + props->device_cap_flags |=IB_DEVICE_MEM_MGT_EXTENSIONS ;if (MLX5_CAP_GEN (mdev, sho)) { props->device_cap_flags |=IB_DEVICE_INTEGRITY_HANDOVER ;/* At this stage no support for signature handover */
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 463/757 i40iw: Add support to make destroy QP synchronous
In reply to Greg Kroah-HartmanFrom: Sindhu, Devale <[email protected]>
[ Upstream commit f2334964e969762e266a616acf9377f6046470a2 ]
Occasionally ib_write_bw crash is seen due to access of a pd object in i40iw_sc_qp_destroy after it is freed. Destroy qp is not synchronous in i40iw and thus the iwqp object could be referencing a pd object that is freed by ib core as a result of successful return from i40iw_destroy_qp.
Wait in i40iw_destroy_qp till all QP references are released and destroy the QP and its associated resources before returning. Switch to use the refcount API vs atomic API for lifetime management of the qp.
RIP: 0010:i40iw_sc_qp_destroy+0x4b/0x120 [i40iw] [...] RSP: 0018:ffffb4a7042e3ba8 EFLAGS: 00010002 RAX: 0000000000000000 RBX: 0000000000000001 RCX: dead000000000122 RDX: ffffb4a7042e3bac RSI: ffff8b7ef9b1e940 RDI: ffff8b7efbf09080 RBP: 0000000000000000 R08: 0000000000000001 R09: 0000000000000000 R10: 8080808080808080 R11: 0000000000000010 R12: ffff8b7efbf08050 R13: 0000000000000001 R14: ffff8b7f15042928 R15: ffff8b7ef9b1e940 FS: 0000000000000000(0000) GS:ffff8b7f2fa00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000400 CR3: 000000020d60a006 CR4: 00000000001606e0 Call Trace: i40iw_exec_cqp_cmd+0x4d3/0x5c0 [i40iw] ? try_to_wake_up+0x1ea/0x5d0 ? __switch_to_asm+0x40/0x70 i40iw_process_cqp_cmd+0x95/0xa0 [i40iw] i40iw_handle_cqp_op+0x42/0x1a0 [i40iw] ? cm_event_handler+0x13c/0x1f0 [iw_cm] i40iw_rem_ref+0xa0/0xf0 [i40iw] cm_work_handler+0x99c/0xd10 [iw_cm] process_one_work+0x1a1/0x360 worker_thread+0x30/0x380 ? process_one_work+0x360/0x360 kthread+0x10c/0x130 ? kthread_park+0x80/0x80 ret_from_fork+0x35/0x40
--- drivers/infiniband/hw/i40iw/i40iw.h | 9 ++-- drivers/infiniband/hw/i40iw/i40iw_cm.c | 10 ++-- drivers/infiniband/hw/i40iw/i40iw_hw.c | 4 +- drivers/infiniband/hw/i40iw/i40iw_utils.c | 59 ++++------------------- drivers/infiniband/hw/i40iw/i40iw_verbs.c | 31 ++++++++---- drivers/infiniband/hw/i40iw/i40iw_verbs.h | 3 +- 6 files changed, 45 insertions(+), 71 deletions(-)
drivers/infiniband/hw/i40iw/i40iw.h +4 -5
@@ -409,8 +409,8 @@ static inline struct i40iw_qp *to_iwqp(struct ib_qp *ibqp) }/* i40iw.c */ -void i40iw_add_ref (struct ib_qp *); -void i40iw_rem_ref (struct ib_qp *); +void i40iw_qp_add_ref (struct ib_qp *ibqp); +void i40iw_qp_rem_ref (struct ib_qp *ibqp);struct ib_qp *i40iw_get_qp (struct ib_device *,int ); void i40iw_flush_wqes(struct i40iw_device *iwdev,
@@ -554,9 +554,8 @@ enum i40iw_status_code i40iw_manage_qhash(struct i40iw_device *iwdev, bool wait);void i40iw_receive_ilq (struct i40iw_sc_vsi *vsi,struct i40iw_puda_buf *rbuf);void i40iw_free_sqbuf (struct i40iw_sc_vsi *vsi,void *bufp); -void i40iw_free_qp_resources (struct i40iw_device *iwdev, -struct i40iw_qp *iwqp, -u32 qp_num); +void i40iw_free_qp_resources (struct i40iw_qp *iwqp); +enum i40iw_status_code i40iw_obj_aligned_mem (struct i40iw_device *iwdev,struct i40iw_dma_mem *memptr,u32 size,u32 mask);
drivers/infiniband/hw/i40iw/i40iw_cm.c +5 -5
@@ -2322,7 +2322,7 @@ static void i40iw_rem_ref_cm_node(struct i40iw_cm_node *cm_node) iwqp = cm_node->iwqp;if (iwqp) { iwqp->cm_node =NULL ; -i40iw_rem_ref (&iwqp->ibqp); +i40iw_qp_rem_ref (&iwqp->ibqp); cm_node->iwqp =NULL ; }else if (cm_node->qhash_set) {i40iw_get_addr_info (cm_node, &nfo);
@@ -3452,7 +3452,7 @@ void i40iw_cm_disconn(struct i40iw_qp *iwqp)kfree (work);return ; } -i40iw_add_ref (&iwqp->ibqp); +i40iw_qp_add_ref (&iwqp->ibqp);spin_unlock_irqrestore (&iwdev->qptable_lock, flags); work->iwqp = iwqp;
@@ -3623,7 +3623,7 @@ static void i40iw_disconnect_worker(struct work_struct *work)kfree (dwork);i40iw_cm_disconn_true (iwqp); -i40iw_rem_ref (&iwqp->ibqp); +i40iw_qp_rem_ref (&iwqp->ibqp); }/**
@@ -3745,7 +3745,7 @@ int i40iw_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) cm_node->lsmm_size = accept.size + conn_param->private_data_len;i40iw_cm_init_tsa_conn (iwqp, cm_node); cm_id->add_ref (cm_id); -i40iw_add_ref (&iwqp->ibqp); +i40iw_qp_add_ref (&iwqp->ibqp); attr.qp_state =IB_QPS_RTS ; cm_node->qhash_set = false;
@@ -3908,7 +3908,7 @@ int i40iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) iwqp->cm_node = cm_node; cm_node->iwqp = iwqp; iwqp->cm_id = cm_id; -i40iw_add_ref (&iwqp->ibqp); +i40iw_qp_add_ref (&iwqp->ibqp);if (cm_node->state !=I40IW_CM_STATE_OFFLOADED ) { cm_node->state =I40IW_CM_STATE_SYN_SENT ;
drivers/infiniband/hw/i40iw/i40iw_hw.c +2 -2
@@ -313,7 +313,7 @@ void i40iw_process_aeq(struct i40iw_device *iwdev) __func__, info->qp_cq_id);continue ; } -i40iw_add_ref (&iwqp->ibqp); +i40iw_qp_add_ref (&iwqp->ibqp);spin_unlock_irqrestore (&iwdev->qptable_lock, flags); qp = &iwqp->sc_qp;spin_lock_irqsave (&iwqp->lock, flags);
@@ -426,7 +426,7 @@ void i40iw_process_aeq(struct i40iw_device *iwdev)break ; }if (info->qp) -i40iw_rem_ref (&iwqp->ibqp); +i40iw_qp_rem_ref (&iwqp->ibqp); }while (1 );if (aeqcnt)
drivers/infiniband/hw/i40iw/i40iw_utils.c +10 -49
114 lines not on this page · raw message
drivers/infiniband/hw/i40iw/i40iw_verbs.c +22 -9
@@ -363,11 +363,11 @@ static struct i40iw_pbl *i40iw_get_pbl(unsigned long va,* @iwqp: qp ptr (user or kernel) * @qp_num: qp number assigned */ -void i40iw_free_qp_resources (struct i40iw_device *iwdev, -struct i40iw_qp *iwqp, -u32 qp_num) +void i40iw_free_qp_resources (struct i40iw_qp *iwqp) {struct i40iw_pbl *iwpbl = &iwqp->iwpbl; +struct i40iw_device *iwdev = iwqp->iwdev; +u32 qp_num = iwqp->ibqp.qp_num;i40iw_ieq_cleanup_qp (iwdev->vsi.ieq, &iwqp->sc_qp);i40iw_dealloc_push_page (iwdev, &iwqp->sc_qp);
@@ -401,6 +401,10 @@ static void i40iw_clean_cqes(struct i40iw_qp *iwqp, struct i40iw_cq *iwcq)static int i40iw_destroy_qp (struct ib_qp *ibqp,struct ib_udata *udata) {struct i40iw_qp *iwqp =to_iwqp (ibqp); +struct ib_qp_attr attr; +struct i40iw_device *iwdev = iwqp->iwdev; + +memset (&attr,0 ,sizeof (attr)); iwqp->destroyed =1 ;
@@ -415,7 +419,15 @@ static int i40iw_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata) } } -i40iw_rem_ref (&iwqp->ibqp); + attr.qp_state =IB_QPS_ERR ; +i40iw_modify_qp (&iwqp->ibqp, &attr,IB_QP_STATE ,NULL ); +i40iw_qp_rem_ref (&iwqp->ibqp); +wait_for_completion (&iwqp->free_qp); +i40iw_cqp_qp_destroy_cmd (&iwdev->sc_dev, &iwqp->sc_qp); +i40iw_rem_pdusecount (iwqp->iwpd, iwdev); +i40iw_free_qp_resources (iwqp); +i40iw_rem_devusecount (iwdev); +return 0 ; }
@@ -576,6 +588,7 @@ static struct ib_qp *i40iw_create_qp(struct ib_pd *ibpd, qp->back_qp = (void *)iwqp; qp->push_idx =I40IW_INVALID_PUSH_PAGE_INDEX ; + iwqp->iwdev = iwdev; iwqp->ctx_info.iwarp_info = &iwqp->iwarp_info; if (i40iw_allocate_dma_mem(dev->hw,
@@ -600,7 +613,6 @@ static struct ib_qp *i40iw_create_qp(struct ib_pd *ibpd, goto error; } - iwqp->iwdev = iwdev; iwqp->iwpd = iwpd; iwqp->ibqp.qp_num = qp_num; qp = &iwqp->sc_qp;
@@ -714,7 +726,7 @@ static struct ib_qp *i40iw_create_qp(struct ib_pd *ibpd, goto error; } -i40iw_add_ref (&iwqp->ibqp); +refcount_set (&iwqp->refcount,1 );spin_lock_init (&iwqp->lock); iwqp->sig_all = (init_attr->sq_sig_type ==IB_SIGNAL_ALL_WR ) ?1 :0 ; iwdev->qp_table[qp_num] = iwqp;
@@ -736,10 +748,11 @@ static struct ib_qp *i40iw_create_qp(struct ib_pd *ibpd, }init_completion (&iwqp->sq_drained);init_completion (&iwqp->rq_drained); +init_completion (&iwqp->free_qp);return &iwqp->ibqp; error: -i40iw_free_qp_resources (iwdev, iwqp, qp_num); +i40iw_free_qp_resources (iwqp);return ERR_PTR (err_code); }
@@ -2637,13 +2650,13 @@ static const struct ib_device_ops i40iw_dev_ops = { .get_hw_stats = i40iw_get_hw_stats, .get_port_immutable = i40iw_port_immutable, .iw_accept = i40iw_accept, - .iw_add_ref = i40iw_add_ref, + .iw_add_ref = i40iw_qp_add_ref, .iw_connect = i40iw_connect, .iw_create_listen = i40iw_create_listen, .iw_destroy_listen = i40iw_destroy_listen, .iw_get_qp = i40iw_get_qp, .iw_reject = i40iw_reject, - .iw_rem_ref = i40iw_rem_ref, + .iw_rem_ref = i40iw_qp_rem_ref, .map_mr_sg = i40iw_map_mr_sg, .mmap = i40iw_mmap, .modify_qp = i40iw_modify_qp,
drivers/infiniband/hw/i40iw/i40iw_verbs.h +2 -1
@@ -139,7 +139,7 @@ struct i40iw_qp {struct i40iw_qp_host_ctx_info ctx_info;struct i40iwarp_offload_info iwarp_info;void *allocated_buffer; -atomic_t refcount; +refcount_t refcount;struct iw_cm_id *cm_id;void *cm_node;struct ib_mr *lsmm_mr;
@@ -174,5 +174,6 @@ struct i40iw_qp {struct i40iw_dma_mem ietf_mem;struct completion sq_drained;struct completion rq_drained; + struct completion free_qp; };#endif
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 464/757 perf stat: Skip duration_time in setup_system_wide
In reply to Greg Kroah-HartmanFrom: Jin Yao <[email protected]>
[ Upstream commit 002a3d690f95804bdef6b70b26154103518e13d9 ]
Some metrics (such as DRAM_BW_Use) consists of uncore events and duration_time. For uncore events, counter->core.system_wide is true. But for duration_time, counter->core.system_wide is false so target.system_wide is set to false.
Then 'enable_on_exec' is set in perf_event_attr of uncore event. Kernel will return error when trying to open the uncore event.
This patch skips the duration_time in setup_system_wide then target.system_wide will be set to true for the evlist of uncore events + duration_time.
Before (tested on skylake desktop):
# perf stat -M DRAM_BW_Use -- sleep 1 Error: The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (arb/event=0x84,umask=0x1/). /bin/dmesg | grep -i perf may provide additional information.
After:
# perf stat -M DRAM_BW_Use -- sleep 1
Performance counter stats for 'system wide':
169 arb/event=0x84,umask=0x1/ # 0.00 DRAM_BW_Use
40,427 arb/event=0x81,umask=0x1/
1,000,902,197 ns duration_time1.000902197 seconds time elapsed
--- tools/perf/builtin-stat.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/perf/builtin-stat.c +3 -1
@@ -2063,8 +2063,10 @@ static void setup_system_wide(int forks)struct evsel *counter;evlist__for_each_entry (evsel_list, counter) { -if (!counter->core.system_wide) +if (!counter->core.system_wide && +strcmp (counter->name,"duration_time" )) {return ; + } }if (evsel_list->core.nr_entries)
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 465/757 RDMA/hns: Add check for the validity of sl configuration
In reply to Greg Kroah-HartmanFrom: Jiaran Zhang <[email protected]>
[ Upstream commit 172505cfa3a8ee98acaa569fd3be97697b333958 ]
According to the RoCE v1 specification, the sl (service level) 0-7 are mapped directly to priorities 0-7 respectively, sl 8-15 are reserved. The driver should verify whether the the value of sl is larger than 7, if so, an exception should be returned.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 12 ++++++++++-- drivers/infiniband/hw/hns/hns_roce_hw_v2.h | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +10 -2
@@ -4259,11 +4259,19 @@ static int hns_roce_v2_set_path(struct ib_qp *ibqp, V2_QPC_BYTE_28_FL_S, 0);memcpy (context->dgid, grh->dgid.raw,sizeof (grh->dgid.raw));memset (qpc_mask->dgid,0 ,sizeof (grh->dgid.raw)); + + hr_qp->sl =rdma_ah_get_sl (&attr->ah_attr); +if (unlikely (hr_qp->sl >MAX_SERVICE_LEVEL )) { +ibdev_err (ibdev, +"failed to fill QPC, sl (%d) shouldn't be larger than %d.\n" , + hr_qp->sl,MAX_SERVICE_LEVEL ); +return -EINVAL ; + } +roce_set_field (context->byte_28_at_fl,V2_QPC_BYTE_28_SL_M , -V2_QPC_BYTE_28_SL_S ,rdma_ah_get_sl (&attr->ah_attr)); +V2_QPC_BYTE_28_SL_S , hr_qp->sl);roce_set_field (qpc_mask->byte_28_at_fl,V2_QPC_BYTE_28_SL_M ,V2_QPC_BYTE_28_SL_S ,0 ); - hr_qp->sl =rdma_ah_get_sl (&attr->ah_attr);return 0 ; }
drivers/infiniband/hw/hns/hns_roce_hw_v2.h +2 -0
@@ -1941,6 +1941,8 @@ struct hns_roce_eq_context {#define HNS_ROCE_V2_AEQE_EVENT_QUEUE_NUM_S 0#define HNS_ROCE_V2_AEQE_EVENT_QUEUE_NUM_M GENMASK(23, 0) +#define MAX_SERVICE_LEVEL 0x7 +struct hns_roce_wqe_atomic_seg {__le64 fetchadd_swap_data;__le64 cmp_data;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 466/757 RDMA/hns: Solve the overflow of the calc_pg_sz()
In reply to Greg Kroah-HartmanFrom: Jiaran Zhang <[email protected]>
[ Upstream commit 768202a0825d447de785e87ff1ea1d3c86a71727 ]
calc_pg_sz() may gets a data calculation overflow if the PAGE_SIZE is 64 KB and hop_num is 2. It is because that all variables involved in calculation are defined in type of int. So change the type of bt_chunk_size, buf_chunk_size and obj_per_chunk_default to u64.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +3 -3
@@ -1770,9 +1770,9 @@ static void calc_pg_sz(int obj_num, int obj_size, int hop_num, int ctx_bt_num, int *buf_page_size, int *bt_page_size, u32 hem_type) { u64 obj_per_chunk; -int bt_chunk_size =1 <<PAGE_SHIFT ; -int buf_chunk_size =1 <<PAGE_SHIFT ; -int obj_per_chunk_default = buf_chunk_size / obj_size; +u64 bt_chunk_size =PAGE_SIZE ; +u64 buf_chunk_size =PAGE_SIZE ; +u64 obj_per_chunk_default = buf_chunk_size / obj_size; *buf_page_size =0 ; *bt_page_size =0 ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 467/757 RDMA/hns: Fix the wrong value of rnr_retry when querying qp
In reply to Greg Kroah-HartmanFrom: Wenpeng Liang <[email protected]>
[ Upstream commit 99fcf82521d91468ee6115a3c253aa032dc63cbc ]
The rnr_retry returned to the user is not correct, it should be got from another fields in QPC.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +3 -1
@@ -4767,7 +4767,9 @@ static int hns_roce_v2_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, qp_attr->retry_cnt =roce_get_field (context.byte_212_lsn,V2_QPC_BYTE_212_RETRY_CNT_M ,V2_QPC_BYTE_212_RETRY_CNT_S ); - qp_attr->rnr_retry =le32_to_cpu (context.rq_rnr_timer); + qp_attr->rnr_retry =roce_get_field (context.byte_244_rnr_rxack, +V2_QPC_BYTE_244_RNR_CNT_M , +V2_QPC_BYTE_244_RNR_CNT_S ); done: qp_attr->cur_qp_state = qp_attr->qp_state;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 468/757 RDMA/hns: Fix configuration of ack_req_freq in QPC
In reply to Greg Kroah-HartmanFrom: Weihang Li <[email protected]>
[ Upstream commit fbed9d2be292504e04caa2057e3a9477a1e1d040 ]
The hardware will add AckReq flag in BTH header according to the value of ack_req_freq to request ACK from responder for the packets with this flag. It should be greater than or equal to lp_pktn_ini instead of using a fixed value.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +12 -6
@@ -3641,9 +3641,6 @@ static void modify_qp_reset_to_init(struct ib_qp *ibqp, V2_QPC_BYTE_76_SRQ_EN_S, 1); } -roce_set_field (context->byte_172_sq_psn,V2_QPC_BYTE_172_ACK_REQ_FREQ_M , -V2_QPC_BYTE_172_ACK_REQ_FREQ_S ,4 ); -roce_set_bit (context->byte_172_sq_psn,V2_QPC_BYTE_172_FRE_S ,1 ); hr_qp->access_flags = attr->qp_access_flags;
@@ -3954,6 +3951,7 @@ static int modify_qp_init_to_rtr(struct ib_qp *ibqp,dma_addr_t trrl_ba;dma_addr_t irrl_ba;enum ib_mtu mtu; +u8 lp_pktn_ini;u8 port_num;u64 *mtts;u8 *dmac;
@@ -4061,13 +4059,21 @@ static int modify_qp_init_to_rtr(struct ib_qp *ibqp, }#define MAX_LP_MSG_LEN 65536 -/* MTU*(2^LP_PKTN_INI) shouldn't be bigger than 64kb */ +/* MTU * (2 ^ LP_PKTN_INI) shouldn't be bigger than 64KB */ + lp_pktn_ini =ilog2 (MAX_LP_MSG_LEN /ib_mtu_enum_to_int (mtu)); +roce_set_field (context->byte_56_dqpn_err,V2_QPC_BYTE_56_LP_PKTN_INI_M , -V2_QPC_BYTE_56_LP_PKTN_INI_S , -ilog2 (MAX_LP_MSG_LEN /ib_mtu_enum_to_int (mtu))); +V2_QPC_BYTE_56_LP_PKTN_INI_S , lp_pktn_ini);roce_set_field (qpc_mask->byte_56_dqpn_err,V2_QPC_BYTE_56_LP_PKTN_INI_M ,V2_QPC_BYTE_56_LP_PKTN_INI_S ,0 ); +/* ACK_REQ_FREQ should be larger than or equal to LP_PKTN_INI */ +roce_set_field (context->byte_172_sq_psn,V2_QPC_BYTE_172_ACK_REQ_FREQ_M , +V2_QPC_BYTE_172_ACK_REQ_FREQ_S , lp_pktn_ini); +roce_set_field (qpc_mask->byte_172_sq_psn, +V2_QPC_BYTE_172_ACK_REQ_FREQ_M , +V2_QPC_BYTE_172_ACK_REQ_FREQ_S ,0 ); +roce_set_bit (qpc_mask->byte_108_rx_reqepsn,V2_QPC_BYTE_108_RX_REQ_PSN_ERR_S ,0 ); roce_set_field(qpc_mask->byte_96_rx_reqmsn, V2_QPC_BYTE_96_RX_REQ_MSN_M,
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 469/757 RDMA/hns: Fix missing sq_sig_type when querying QP
In reply to Greg Kroah-HartmanFrom: Weihang Li <[email protected]>
[ Upstream commit 05df49279f8926178ecb3ce88e61b63104cd6293 ]
The sq_sig_type field should be filled when querying QP, or the users may get a wrong value.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 1 + 1 file changed, 1 insertion(+)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +1 -0
@@ -4791,6 +4791,7 @@ static int hns_roce_v2_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, } qp_init_attr->cap = qp_attr->cap; + qp_init_attr->sq_sig_type = hr_qp->sq_signal_bits; out:mutex_unlock (&hr_qp->mutex);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 470/757 RDMA/mlx5: Fix type warning of sizeof in __mlx5_ib_alloc_counters()
In reply to Greg Kroah-HartmanFrom: Liu Shixin <[email protected]>
[ Upstream commit b942fc0319a72b83146b79619eb578e989062911 ]
sizeof() when applied to a pointer typed expression should give the size of the pointed data, even if the data is a pointer.
--- drivers/infiniband/hw/mlx5/counters.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/hw/mlx5/counters.c +2 -2
@@ -456,12 +456,12 @@ static int __mlx5_ib_alloc_counters(struct mlx5_ib_dev *dev, cnts->num_ext_ppcnt_counters =ARRAY_SIZE (ext_ppcnt_cnts); num_counters +=ARRAY_SIZE (ext_ppcnt_cnts); } - cnts->names =kcalloc (num_counters,sizeof (cnts->names),GFP_KERNEL ); + cnts->names =kcalloc (num_counters,sizeof (*cnts->names),GFP_KERNEL );if (!cnts->names)return -ENOMEM ; cnts->offsets =kcalloc (num_counters, -sizeof (cnts->offsets),GFP_KERNEL ); +sizeof (*cnts->offsets),GFP_KERNEL );if (!cnts->offsets) goto err_names;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 471/757 mtd: hyperbus: hbmc-am654: Fix direct mapping setup flash access
In reply to Greg Kroah-HartmanFrom: Vignesh Raghavendra <[email protected]>
[ Upstream commit aca31ce96814c84d1a41aaa109c15abe61005af7 ]
Setting up of direct mapping should be done with flash node's IO address space and not with controller's IO region.
--- drivers/mtd/hyperbus/hbmc-am654.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/hyperbus/hbmc-am654.c +2 -2
@@ -70,7 +70,8 @@ static int am654_hbmc_probe(struct platform_device *pdev)platform_set_drvdata (pdev, priv); - ret =of_address_to_resource (np,0 , &res); + priv->hbdev.np =of_get_next_child (np,NULL ); + ret =of_address_to_resource (priv->hbdev.np,0 , &res);if (ret)return ret;
@@ -103,7 +104,6 @@ static int am654_hbmc_probe(struct platform_device *pdev) priv->ctlr.dev = dev; priv->ctlr.ops = &am654_hbmc_ops; priv->hbdev.ctlr = &priv->ctlr; - priv->hbdev.np =of_get_next_child (dev->of_node,NULL ); ret =hyperbus_register_device (&priv->hbdev);if (ret) {dev_err (dev,"failed to register controller\n" );
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 472/757 mtd: rawnand: stm32_fmc2: fix a buffer overflow
In reply to Greg Kroah-HartmanFrom: Christophe Kerello <[email protected]>
[ Upstream commit ab16f54ef3cdb6bbc06a36f636a89e6db8a6cea3 ]
This patch solves following static checker warning:drivers/mtd/nand/raw/stm32_fmc2_nand.c:350 stm32_fmc2_nfc_select_chip()
error: buffer overflow 'nfc->data_phys_addr' 2 <= 2
The CS value can only be 0 or 1.
--- drivers/mtd/nand/raw/stm32_fmc2_nand.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/raw/stm32_fmc2_nand.c +1 -1
@@ -1762,7 +1762,7 @@ static int stm32_fmc2_nfc_parse_child(struct stm32_fmc2_nfc *nfc,return ret; } -if (cs >FMC2_MAX_CE ) { +if (cs >=FMC2_MAX_CE ) {dev_err (nfc->dev,"invalid reg value: %d\n" , cs);return -EINVAL ; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 473/757 mtd: rawnand: vf610: disable clk on error handling path in probe
In reply to Greg Kroah-HartmanFrom: Evgeny Novikov <[email protected]>
[ Upstream commit cb7dc3178a9862614b1e7567d77f4679f027a074 ]
vf610_nfc_probe() does not invoke clk_disable_unprepare() on one error handling path. The patch fixes that.
Found by Linux Driver Verification project (linuxtesting.org).
--- drivers/mtd/nand/raw/vf610_nfc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/mtd/nand/raw/vf610_nfc.c +4 -2
@@ -852,8 +852,10 @@ static int vf610_nfc_probe(struct platform_device *pdev) } of_id =of_match_device (vf610_nfc_dt_ids, &pdev->dev); -if (!of_id) -return -ENODEV ; +if (!of_id) { + err = -ENODEV ; + goto err_disable_clk; + } nfc->variant = (enum vf610_nfc_variant )of_id->data;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 474/757 mtd: spinand: gigadevice: Only one dummy byte in QUADIO
In reply to Greg Kroah-HartmanFrom: Hauke Mehrtens <[email protected]>
[ Upstream commit 6387ad9caf8f09747a8569e5876086b72ee9382c ]
The datasheet only lists one dummy byte in the 0xEH operation for the following chips:
* GD5F1GQ4xExxG
* GD5F1GQ4xFxxG
* GD5F1GQ4UAYIG
* GD5F4GQ4UAYIG
--- drivers/mtd/nand/spi/gigadevice.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/nand/spi/gigadevice.c +2 -2
@@ -21,7 +21,7 @@#define GD5FXGQ4UXFXXG_STATUS_ECC_UNCOR_ERROR (7 << 4) static SPINAND_OP_VARIANTS(read_cache_variants, - SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 2, NULL, 0), + SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 1, NULL, 0),SPINAND_PAGE_READ_FROM_CACHE_X4_OP (0 ,1 ,NULL ,0 ),SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP (0 ,1 ,NULL ,0 ), SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0),
@@ -29,7 +29,7 @@ static SPINAND_OP_VARIANTS(read_cache_variants, SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0)); static SPINAND_OP_VARIANTS(read_cache_variants_f, - SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 2, NULL, 0), + SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 1, NULL, 0),SPINAND_PAGE_READ_FROM_CACHE_X4_OP_3A (0 ,1 ,NULL ,0 ),SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP (0 ,1 ,NULL ,0 ), SPINAND_PAGE_READ_FROM_CACHE_X2_OP_3A(0, 1, NULL, 0),
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 475/757 mtd: spinand: gigadevice: Add QE Bit
In reply to Greg Kroah-HartmanFrom: Hauke Mehrtens <[email protected]>
[ Upstream commit aea7687e77bebce5b67fab9d03347bd8df7933c7 ]
The following GigaDevice chips have the QE BIT in the feature flags, I checked the datasheets, but did not try this.
* GD5F1GQ4xExxG
* GD5F1GQ4xFxxG
* GD5F1GQ4UAYIG
* GD5F4GQ4UAYIG
The Quad operations like 0xEB mention that the QE bit has to be set.
--- drivers/mtd/nand/spi/gigadevice.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/mtd/nand/spi/gigadevice.c +5 -5
@@ -202,7 +202,7 @@ static const struct spinand_info gigadevice_spinand_table[] = { SPINAND_INFO_OP_VARIANTS(&read_cache_variants, &write_cache_variants, &update_cache_variants), - 0, + SPINAND_HAS_QE_BIT, SPINAND_ECCINFO(&gd5fxgq4xa_ooblayout, gd5fxgq4xa_ecc_get_status)), SPINAND_INFO("GD5F2GQ4xA",
@@ -212,7 +212,7 @@ static const struct spinand_info gigadevice_spinand_table[] = { SPINAND_INFO_OP_VARIANTS(&read_cache_variants, &write_cache_variants, &update_cache_variants), - 0, + SPINAND_HAS_QE_BIT, SPINAND_ECCINFO(&gd5fxgq4xa_ooblayout, gd5fxgq4xa_ecc_get_status)), SPINAND_INFO("GD5F4GQ4xA",
@@ -222,7 +222,7 @@ static const struct spinand_info gigadevice_spinand_table[] = { SPINAND_INFO_OP_VARIANTS(&read_cache_variants, &write_cache_variants, &update_cache_variants), - 0, + SPINAND_HAS_QE_BIT, SPINAND_ECCINFO(&gd5fxgq4xa_ooblayout, gd5fxgq4xa_ecc_get_status)), SPINAND_INFO("GD5F1GQ4UExxG",
@@ -232,7 +232,7 @@ static const struct spinand_info gigadevice_spinand_table[] = { SPINAND_INFO_OP_VARIANTS(&read_cache_variants, &write_cache_variants, &update_cache_variants), - 0, + SPINAND_HAS_QE_BIT, SPINAND_ECCINFO(&gd5fxgq4_variant2_ooblayout, gd5fxgq4uexxg_ecc_get_status)), SPINAND_INFO("GD5F1GQ4UFxxG",
@@ -242,7 +242,7 @@ static const struct spinand_info gigadevice_spinand_table[] = {SPINAND_INFO_OP_VARIANTS (&read_cache_variants_f, &write_cache_variants, &update_cache_variants), -0 , +SPINAND_HAS_QE_BIT ,SPINAND_ECCINFO (&gd5fxgq4_variant2_ooblayout, gd5fxgq4ufxxg_ecc_get_status)), };
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 476/757 mtd: rawnand: ams-delta: Fix non-OF build warning
In reply to Greg Kroah-HartmanFrom: Janusz Krzysztofik <[email protected]>
[ Upstream commit 6d11178762f7c8338a028b428198383b8978b280 ]
Commit 7c2f66a960fc ("mtd: rawnand: ams-delta: Add module device tables") introduced an OF module device table but wrapped a reference to it with of_match_ptr() which resolves to NULL in non-OF configs. That resulted in a clang compiler warning on unused variable in non-OF builds. Fix it.
drivers/mtd/nand/raw/ams-delta.c:373:34: warning: unused variable 'gpio_nand_of_id_table' [-Wunused-const-variable]
static const struct of_device_id gpio_nand_of_id_table[] = {
^1 warning generated.
--- drivers/mtd/nand/raw/ams-delta.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/mtd/nand/raw/ams-delta.c +2 -0
@@ -400,12 +400,14 @@ static int gpio_nand_remove(struct platform_device *pdev)return 0 ; } +#ifdef CONFIG_OF static const struct of_device_id gpio_nand_of_id_table[] = { {/* sentinel */ }, };MODULE_DEVICE_TABLE (of, gpio_nand_of_id_table); +#endif static const struct platform_device_id gpio_nand_plat_id_table[] = { {
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 477/757 kdb: Fix pager search for multi-line strings
In reply to Greg Kroah-HartmanFrom: Daniel Thompson <[email protected]>
[ Upstream commit d081a6e353168f15e63eb9e9334757f20343319f ]
Currently using forward search doesn't handle multi-line strings correctly. The search routine replaces line breaks with \0 during the search and, for regular searches ("help | grep Common\n"), there is code after the line has been discarded or printed to replace the break character.
However during a pager search ("help\n" followed by "/Common\n") when the string is matched we will immediately return to normal output and the code that should restore the \n becomes unreachable. Fix this by restoring the replaced character when we disable the search mode and update the comment accordingly.
--- kernel/debug/kdb/kdb_io.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
kernel/debug/kdb/kdb_io.c +6 -2
@@ -706,12 +706,16 @@ int vkdb_printf(enum kdb_msgsrc src, const char *fmt, va_list ap) size_avail =sizeof (kdb_buffer) - len; goto kdb_print_out; } -if (kdb_grepping_flag >=KDB_GREPPING_FLAG_SEARCH ) +if (kdb_grepping_flag >=KDB_GREPPING_FLAG_SEARCH ) {/* * This was a interactive search (using '/' at more -* prompt) and it has completed. Clear the flag. +* prompt) and it has completed. Replace the \0 with +* its original value to ensure multi-line strings +* are handled properly, and return to normal mode. */ + *cphold = replaced_byte; kdb_grepping_flag =0 ; + }/* * at this point the string is a full line and * should be printed, up to the null.
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 478/757 overflow: Include header file with SIZE_MAX declaration
In reply to Greg Kroah-HartmanFrom: Leon Romanovsky <[email protected]>
[ Upstream commit a4947e84f23474803b62a2759b5808147e4e15f9 ]
The various array_size functions use SIZE_MAX define, but missed limits.h causes to failure to compile code that needs overflow.h.
In file included from drivers/infiniband/core/uverbs_std_types_device.c:6:
./include/linux/overflow.h: In function 'array_size':
./include/linux/overflow.h:258:10: error: 'SIZE_MAX' undeclared (first use in this function)
258 | return SIZE_MAX;
| ^~~~~~~~--- include/linux/overflow.h | 1 + 1 file changed, 1 insertion(+)
include/linux/overflow.h +1 -0
@@ -3,6 +3,7 @@#define __LINUX_OVERFLOW_H#include <linux/compiler.h> +#include <linux/limits.h> /* * In the fallback code below, we need to compute the minimum and
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 479/757 mtd: parsers: bcm63xx: Do not make it modular
In reply to Greg Kroah-HartmanFrom: Florian Fainelli <[email protected]>
[ Upstream commit b597cc75f7fe76708bc6ab3f0e09bbff6f09ae4a ]
With commit 91e81150d388 ("mtd: parsers: bcm63xx: simplify CFE detection"), we generate a reference to fw_arg3 which is the fourth firmware/command line argument on MIPS platforms. That symbol is not exported and would cause a linking failure.
The parser is typically necessary to boot a BCM63xx-based system anyway so having it be part of the kernel image makes sense, therefore make it 'bool' instead of 'tristate'.
--- drivers/mtd/parsers/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/parsers/Kconfig +1 -1
@@ -12,7 +12,7 @@ config MTD_BCM47XX_PARTS boards. config MTD_BCM63XX_PARTS - tristate "BCM63XX CFE partitioning parser" + bool "BCM63XX CFE partitioning parser" depends on BCM63XX || BMIPS_GENERIC || COMPILE_TEST select CRC32 select MTD_PARSER_IMAGETAG
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 480/757 RDMA/ipoib: Set rtnl_link_ops for ipoib interfaces
In reply to Greg Kroah-HartmanFrom: Kamal Heib <[email protected]>
[ Upstream commit 5ce2dced8e95e76ff7439863a118a053a7fc6f91 ]
Report the "ipoib pkey", "mode" and "umcast" netlink attributes for every IPoiB interface type, not just children created with 'ip link add'.
After setting the rtnl_link_ops for the parent interface, implement the dellink() callback to block users from trying to remove it.
--- drivers/infiniband/ulp/ipoib/ipoib_main.c | 2 ++ drivers/infiniband/ulp/ipoib/ipoib_netlink.c | 11 +++++++++++ drivers/infiniband/ulp/ipoib/ipoib_vlan.c | 2 ++ 3 files changed, 15 insertions(+)
drivers/infiniband/ulp/ipoib/ipoib_main.c +2 -0
@@ -2480,6 +2480,8 @@ static struct net_device *ipoib_add_port(const char *format,/* call event handler to ensure pkey in sync */ queue_work (ipoib_workqueue, &priv->flush_heavy); + ndev->rtnl_link_ops =ipoib_get_link_ops (); + result =register_netdev (ndev);if (result) { pr_warn("%s: couldn't register ipoib port %d; error %d\n",
drivers/infiniband/ulp/ipoib/ipoib_netlink.c +11 -0
@@ -144,6 +144,16 @@ static int ipoib_new_child_link(struct net *src_net, struct net_device *dev,return 0 ; } +static void ipoib_del_child_link (struct net_device *dev,struct list_head *head) +{ +struct ipoib_dev_priv *priv =ipoib_priv (dev); + +if (!priv->parent) +return ; + +unregister_netdevice_queue (dev, head); +} +static size_t ipoib_get_size (const struct net_device *dev) { return nla_total_size(2) + /* IFLA_IPOIB_PKEY */
@@ -158,6 +168,7 @@ static struct rtnl_link_ops ipoib_link_ops __read_mostly = { .priv_size = sizeof(struct ipoib_dev_priv), .setup = ipoib_setup_common, .newlink = ipoib_new_child_link, + .dellink = ipoib_del_child_link, .changelink = ipoib_changelink, .get_size = ipoib_get_size, .fill_info = ipoib_fill_info,
drivers/infiniband/ulp/ipoib/ipoib_vlan.c +2 -0
@@ -195,6 +195,8 @@ int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey) } priv =ipoib_priv (ndev); + ndev->rtnl_link_ops =ipoib_get_link_ops (); + result =__ipoib_vlan_add (ppriv, priv, pkey,IPOIB_LEGACY_CHILD );if (result && ndev->reg_state ==NETREG_UNINITIALIZED )
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 481/757 powerpc/64: fix irq replay missing preempt
In reply to Greg Kroah-HartmanFrom: Nicholas Piggin <[email protected]>
[ Upstream commit 903fd31d3212ab72d564c68f6cfb5d04db68773e ]
Prior to commit 3282a3da25bd ("powerpc/64: Implement soft interrupt replay in C"), replayed interrupts returned by the regular interrupt exit code, which performs preemption in case an interrupt had set need_resched.
This logic was missed by the conversion. Adding preempt_disable/enable around the interrupt replay and final irq enable will reschedule if needed.
--- arch/powerpc/kernel/irq.c | 7 +++++++ 1 file changed, 7 insertions(+)
arch/powerpc/kernel/irq.c +7 -0
@@ -368,6 +368,12 @@ notrace void arch_local_irq_restore(unsigned long mask) } } +/* +* Disable preempt here, so that the below preempt_enable will +* perform resched if required (a replayed interrupt may set +* need_resched). +*/ +preempt_disable ();irq_soft_mask_set (IRQS_ALL_DISABLED );trace_hardirqs_off ();
@@ -377,6 +383,7 @@ notrace void arch_local_irq_restore(unsigned long mask)trace_hardirqs_on ();irq_soft_mask_set (IRQS_ENABLED );__hard_irq_enable (); +preempt_enable (); }EXPORT_SYMBOL (arch_local_irq_restore);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 482/757 powerpc/64: fix irq replay pt_regs->softe value
In reply to Greg Kroah-HartmanFrom: Nicholas Piggin <[email protected]>
[ Upstream commit 2b48e96be2f9f7151197fd25dc41487054bc6f5b ]
Replayed interrupts get an "artificial" struct pt_regs constructed to pass to interrupt handler functions. This did not get the softe field set correctly, it's as though the interrupt has hit while irqs are disabled. It should be IRQS_ENABLED.
This is possibly harmless, asynchronous handlers should not be testing if irqs were disabled, but it might be possible for example some code is shared with synchronous or NMI handlers, and it makes more sense if debug output looks at this.
--- arch/powerpc/kernel/irq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kernel/irq.c +1 -1
@@ -214,7 +214,7 @@ void replay_soft_interrupts(void)struct pt_regs regs;ppc_save_regs (®s); - regs.softe =IRQS_ALL_DISABLED ; + regs.softe =IRQS_ENABLED ; again:if (IS_ENABLED (CONFIG_PPC_IRQ_SOFT_MASK_DEBUG ))
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 483/757 powerpc: PPC_SECURE_BOOT should not require PowerNV
In reply to Greg Kroah-HartmanFrom: Daniel Axtens <[email protected]>
[ Upstream commit 5c5e46dad939b2bf4df04293ab9ac68abd7c1f55 ]
In commit 61f879d97ce4 ("powerpc/pseries: Detect secure and trusted boot state of the system.") we taught the kernel how to understand the secure-boot parameters used by a pseries guest.
However, CONFIG_PPC_SECURE_BOOT still requires PowerNV. I didn't catch this because pseries_le_defconfig includes support for PowerNV and so everything still worked. Indeed, most configs will. Nonetheless, technically PPC_SECURE_BOOT doesn't require PowerNV any more.
The secure variables support (PPC_SECVAR_SYSFS) doesn't do anything on pSeries yet, but I don't think it's worth adding a new condition - at some stage we'll want to add a backend for pSeries anyway.
--- arch/powerpc/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/Kconfig +1 -1
@@ -980,7 +980,7 @@ config PPC_MEM_KEYS config PPC_SECURE_BOOT prompt "Enable secure boot support" bool - depends on PPC_POWERNV + depends on PPC_POWERNV || PPC_PSERIES depends on IMA_ARCH_POLICY imply IMA_SECURE_AND_OR_TRUSTED_BOOT help
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 484/757 powerpc/perf: Exclude pmc5/6 from the irrelevant PMU group constraints
In reply to Greg Kroah-HartmanFrom: Athira Rajeev <[email protected]>
[ Upstream commit 3b6c3adbb2fa42749c3d38cfc4d4d0b7e096bb7b ]
PMU counter support functions enforces event constraints for group of events to check if all events in a group can be monitored. Incase of event codes using PMC5 and PMC6 ( 500fa and 600f4 respectively ), not all constraints are applicable, say the threshold or sample bits. But current code includes pmc5 and pmc6 in some group constraints (like IC_DC Qualifier bits) which is actually not applicable and hence results in those events not getting counted when scheduled along with group of other events. Patch fixes this by excluding PMC5/6 from constraints which are not relevant for it.
--- arch/powerpc/perf/isa207-common.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/powerpc/perf/isa207-common.c +10 -0
@@ -288,6 +288,15 @@ int isa207_get_constraint(u64 event, unsigned long *maskp, unsigned long *valp) mask |=CNST_PMC_MASK (pmc); value |=CNST_PMC_VAL (pmc); + +/* +* PMC5 and PMC6 are used to count cycles and instructions and +* they do not support most of the constraint bits. Add a check +* to exclude PMC5/6 from most of the constraints except for +* EBB/BHRB. +*/ +if (pmc >=5 ) + goto ebb_bhrb; }if (pmc <=4 ) {
@@ -357,6 +366,7 @@ int isa207_get_constraint(u64 event, unsigned long *maskp, unsigned long *valp) } } +ebb_bhrb:if (!pmc && ebb)/* EBB events must specify the PMC */ return -1 ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 485/757 powerpc/perf/hv-gpci: Fix starting index value
In reply to Greg Kroah-HartmanFrom: Kajol Jain <[email protected]>
[ Upstream commit 0f9866f7e85765bbda86666df56c92f377c3bc10 ]
Commit 9e9f60108423f ("powerpc/perf/{hv-gpci, hv-common}: generate requests with counters annotated") adds a framework for defining gpci counters.
In this patch, they adds starting_index value as '0xffffffffffffffff'. which is wrong as starting_index is of size 32 bits.
Because of this, incase we try to run hv-gpci event we get error.
In power9 machine:
command#: perf stat -e hv_gpci/system_tlbie_count_and_time_tlbie_instructions_issued/
-C 0 -I 1000
event syntax error: '..bie_count_and_time_tlbie_instructions_issued/'
\___ value too big for format, maximum is 4294967295This patch fix this issue and changes starting_index value to '0xffffffff'
After this patch:
command#: perf stat -e hv_gpci/system_tlbie_count_and_time_tlbie_instructions_issued/ -C 0 -I 1000
1.000085786 1,024 hv_gpci/system_tlbie_count_and_time_tlbie_instructions_issued/
2.000287818 1,024 hv_gpci/system_tlbie_count_and_time_tlbie_instructions_issued/
2.439113909 17,408 hv_gpci/system_tlbie_count_and_time_tlbie_instructions_issued/--- arch/powerpc/perf/hv-gpci-requests.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/powerpc/perf/hv-gpci-requests.h +3 -3
@@ -95,7 +95,7 @@ REQUEST(__field(0, 8, partition_id)#define REQUEST_NAME system_performance_capabilities#define REQUEST_NUM 0x40 -#define REQUEST_IDX_KIND "starting_index=0xffffffffffffffff" +#define REQUEST_IDX_KIND "starting_index=0xffffffff"#include I (REQUEST_BEGIN ) REQUEST(__field(0, 1, perf_collect_privileged) __field(0x1, 1, capability_mask)
@@ -223,7 +223,7 @@ REQUEST(__field(0, 2, partition_id)#define REQUEST_NAME system_hypervisor_times#define REQUEST_NUM 0xF0 -#define REQUEST_IDX_KIND "starting_index=0xffffffffffffffff" +#define REQUEST_IDX_KIND "starting_index=0xffffffff"#include I (REQUEST_BEGIN ) REQUEST(__count(0, 8, time_spent_to_dispatch_virtual_processors) __count(0x8, 8, time_spent_processing_virtual_processor_timers)
@@ -234,7 +234,7 @@ REQUEST(__count(0, 8, time_spent_to_dispatch_virtual_processors)#define REQUEST_NAME system_tlbie_count_and_time#define REQUEST_NUM 0xF4 -#define REQUEST_IDX_KIND "starting_index=0xffffffffffffffff" +#define REQUEST_IDX_KIND "starting_index=0xffffffff"#include I (REQUEST_BEGIN )REQUEST (__count (0 ,8 , tlbie_instructions_issued)/*
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 486/757 perf stat: Fix out of bounds CPU map access when handling armv8_pmu events
In reply to Greg Kroah-HartmanFrom: Namhyung Kim <[email protected]>
[ Upstream commit bef69bd7cfc363ab94b84ea29102f3e913ed3c6c ]
It was reported that 'perf stat' crashed when using with armv8_pmu (CPU) events with the task mode. As 'perf stat' uses an empty cpu map for task mode but armv8_pmu has its own cpu mask, it has confused which map it should use when accessing file descriptors and this causes segfaults:
(gdb) bt
#0 0x0000000000603fc8 in perf_evsel__close_fd_cpu (evsel=<optimized out>,
cpu=<optimized out>) at evsel.c:122
#1 perf_evsel__close_cpu (evsel=evsel@entry=0x716e950, cpu=7) at evsel.c:156
#2 0x00000000004d4718 in evlist__close (evlist=0x70a7cb0) at util/evlist.c:1242
#3 0x0000000000453404 in __run_perf_stat (argc=3, argc@entry=1, argv=0x30,
argv@entry=0xfffffaea2f90, run_idx=119, run_idx@entry=1701998435)
at builtin-stat.c:929
#4 0x0000000000455058 in run_perf_stat (run_idx=1701998435, argv=0xfffffaea2f90,
argc=1) at builtin-stat.c:947
#5 cmd_stat (argc=1, argv=0xfffffaea2f90) at builtin-stat.c:2357
#6 0x00000000004bb888 in run_builtin (p=p@entry=0x9764b8 <commands+288>,
argc=argc@entry=4, argv=argv@entry=0xfffffaea2f90) at perf.c:312
#7 0x00000000004bbb54 in handle_internal_command (argc=argc@entry=4,
argv=argv@entry=0xfffffaea2f90) at perf.c:364 #8 0x0000000000435378 in run_argv (argcp=<synthetic pointer>,
argv=<synthetic pointer>) at perf.c:408
#9 main (argc=4, argv=0xfffffaea2f90) at perf.c:538
To fix this, I simply used the given cpu map unless the evsel actually is not a system-wide event (like uncore events).
--- tools/lib/perf/evlist.c | 3 +++ 1 file changed, 3 insertions(+)
tools/lib/perf/evlist.c +3 -0
@@ -45,6 +45,9 @@ static void __perf_evlist__propagate_maps(struct perf_evlist *evlist,if (!evsel->own_cpus || evlist->has_user_cpus) {perf_cpu_map__put (evsel->cpus); evsel->cpus =perf_cpu_map__get (evlist->cpus); + }else if (!evsel->system_wide &&perf_cpu_map__empty (evlist->cpus)) { +perf_cpu_map__put (evsel->cpus); + evsel->cpus =perf_cpu_map__get (evlist->cpus); }else if (evsel->cpus != evsel->own_cpus) {perf_cpu_map__put (evsel->cpus); evsel->cpus =perf_cpu_map__get (evsel->own_cpus);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 487/757 i3c: master: Fix error return in cdns_i3c_master_probe()
In reply to Greg Kroah-HartmanFrom: Jing Xiangfeng <[email protected]>
[ Upstream commit abea14bfdebbe9bd02f2ad24a1f3a878ed21c8f0 ]
Fix to return negative error code -ENOMEM from the error handling case instead of 0.
--- drivers/i3c/master/i3c-master-cdns.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/i3c/master/i3c-master-cdns.c +3 -1
@@ -1635,8 +1635,10 @@ static int cdns_i3c_master_probe(struct platform_device *pdev) master->ibi.slots =devm_kcalloc (&pdev->dev, master->ibi.num_slots,sizeof (*master->ibi.slots),GFP_KERNEL ); -if (!master->ibi.slots) +if (!master->ibi.slots) { + ret = -ENOMEM ; goto err_disable_sysclk; + }writel (IBIR_THR (1 ), master->regs +CMD_IBI_THR_CTRL );writel (MST_INT_IBIR_THR , master->regs +MST_IER );
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 488/757 powerpc/security: Fix link stack flush instruction
In reply to Greg Kroah-HartmanFrom: Nicholas Piggin <[email protected]>
[ Upstream commit 792254a77201453d9a77479e63dc216ad90462d2 ]
The inline execution path for the hardware assisted branch flush instruction failed to set CTR to the correct value before bcctr, causing a crash when the feature is enabled.
--- arch/powerpc/include/asm/asm-prototypes.h | 4 ++- arch/powerpc/kernel/entry_64.S | 8 ++++-- arch/powerpc/kernel/security.c | 34 ++++++++++++++++------- 3 files changed, 33 insertions(+), 13 deletions(-)
arch/powerpc/include/asm/asm-prototypes.h +3 -1
@@ -144,7 +144,9 @@ void _kvmppc_restore_tm_pr(struct kvm_vcpu *vcpu, u64 guest_msr);void _kvmppc_save_tm_pr (struct kvm_vcpu *vcpu,u64 guest_msr);/* Patch sites */ -extern s32 patch__call_flush_branch_caches; +extern s32 patch__call_flush_branch_caches1; +extern s32 patch__call_flush_branch_caches2; +extern s32 patch__call_flush_branch_caches3;extern s32 patch__flush_count_cache_return;extern s32 patch__flush_link_stack_return;extern s32 patch__call_kvm_flush_link_stack;
arch/powerpc/kernel/entry_64.S +6 -2
@@ -430,7 +430,11 @@ _ASM_NOKPROBE_SYMBOL(save_nvgprs); #define FLUSH_COUNT_CACHE \ 1: nop; \ - patch_site 1b, patch__call_flush_branch_caches + patch_site 1b, patch__call_flush_branch_caches1; \ +1: nop; \ + patch_site 1b, patch__call_flush_branch_caches2; \ +1: nop; \ + patch_site 1b, patch__call_flush_branch_caches3 .macro nops number .rept \number
@@ -512,7 +516,7 @@ _GLOBAL(_switch) kuap_check_amr r9, r10 - FLUSH_COUNT_CACHE + FLUSH_COUNT_CACHE /* Clobbers r9, ctr */ /* * On SMP kernels, care must be taken because a task may be
arch/powerpc/kernel/security.c +24 -10
@@ -430,30 +430,44 @@ device_initcall(stf_barrier_debugfs_init);static void update_branch_cache_flush (void ) { +u32 *site; +#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE + site = &patch__call_kvm_flush_link_stack;// This controls the branch from guest_exit_cont to kvm_flush_link_stack if (link_stack_flush_type ==BRANCH_CACHE_FLUSH_NONE ) { -patch_instruction_site (&patch__call_kvm_flush_link_stack, -ppc_inst (PPC_INST_NOP )); +patch_instruction_site (site,ppc_inst (PPC_INST_NOP )); }else {// Could use HW flush, but that could also flush count cache -patch_branch_site (&patch__call_kvm_flush_link_stack, - (u64)&kvm_flush_link_stack,BRANCH_SET_LINK ); +patch_branch_site (site, (u64)&kvm_flush_link_stack,BRANCH_SET_LINK ); }#endif +// Patch out the bcctr first, then nop the rest + site = &patch__call_flush_branch_caches3; +patch_instruction_site (site,ppc_inst (PPC_INST_NOP )); + site = &patch__call_flush_branch_caches2; +patch_instruction_site (site,ppc_inst (PPC_INST_NOP )); + site = &patch__call_flush_branch_caches1; +patch_instruction_site (site,ppc_inst (PPC_INST_NOP )); +// This controls the branch from _switch to flush_branch_caches if (count_cache_flush_type ==BRANCH_CACHE_FLUSH_NONE && link_stack_flush_type ==BRANCH_CACHE_FLUSH_NONE ) { -patch_instruction_site (&patch__call_flush_branch_caches, -ppc_inst (PPC_INST_NOP )); +// Nothing to be done + }else if (count_cache_flush_type ==BRANCH_CACHE_FLUSH_HW && link_stack_flush_type ==BRANCH_CACHE_FLUSH_HW ) { -patch_instruction_site (&patch__call_flush_branch_caches, -ppc_inst (PPC_INST_BCCTR_FLUSH )); +// Patch in the bcctr last + site = &patch__call_flush_branch_caches1; +patch_instruction_site (site,ppc_inst (0x39207fff ));// li r9,0x7fff + site = &patch__call_flush_branch_caches2; +patch_instruction_site (site,ppc_inst (0x7d2903a6 ));// mtctr r9 + site = &patch__call_flush_branch_caches3; +patch_instruction_site (site,ppc_inst (PPC_INST_BCCTR_FLUSH )); + }else { -patch_branch_site (&patch__call_flush_branch_caches, - (u64)&flush_branch_caches,BRANCH_SET_LINK ); +patch_branch_site (site, (u64)&flush_branch_caches,BRANCH_SET_LINK );// If we just need to flush the link stack, early return if (count_cache_flush_type ==BRANCH_CACHE_FLUSH_NONE ) {
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 489/757 powerpc/book3s64/radix: Make radix_mem_block_size 64bit
In reply to Greg Kroah-HartmanFrom: Aneesh Kumar K.V <[email protected]>
[ Upstream commit 950805f4d90eda14325ceab56b0f00d034baa8bc ]
Similar to commit 89c140bbaeee ("pseries: Fix 64 bit logical memory block panic") make sure different variables tracking lmb_size are updated to be 64 bit.
--- arch/powerpc/include/asm/book3s/64/mmu.h | 2 +- arch/powerpc/mm/book3s64/radix_pgtable.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/book3s/64/mmu.h +1 -1
@@ -85,7 +85,7 @@ extern unsigned int mmu_base_pid;/* * memory block size used with radix translation. */ -extern unsigned int __ro_after_init radix_mem_block_size; +extern unsigned long __ro_after_init radix_mem_block_size;#define PRTB_SIZE_SHIFT (mmu_pid_bits + 4)#define PRTB_ENTRIES (1ul << mmu_pid_bits)
arch/powerpc/mm/book3s64/radix_pgtable.c +1 -1
@@ -34,7 +34,7 @@unsigned int mmu_pid_bits;unsigned int mmu_base_pid; -unsigned int radix_mem_block_size__ro_after_init ; +unsigned long radix_mem_block_size__ro_after_init ;static __ref void *early_alloc_pgtable (unsigned long size,int nid,unsigned long region_start,unsigned long region_end)
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 490/757 powerpc/papr_scm: Add PAPR command family to pass-through command-set
In reply to Greg Kroah-HartmanFrom: Vaibhav Jain <[email protected]>
[ Upstream commit 13135b461cf205941308984bd3271ec7d403dc40 ]
Add NVDIMM_FAMILY_PAPR to the list of valid 'dimm_family_mask' acceptable by papr_scm. This is needed as since commit 92fe2aa859f5 ("libnvdimm: Validate command family indices") libnvdimm performs a validation of 'nd_cmd_pkg.nd_family' received as part of ND_CMD_CALL processing to ensure only known command families can use the general ND_CMD_CALL pass-through functionality.
Without this change the ND_CMD_CALL pass-through targeting NVDIMM_FAMILY_PAPR error out with -EINVAL.
--- arch/powerpc/platforms/pseries/papr_scm.c | 3 +++ 1 file changed, 3 insertions(+)
arch/powerpc/platforms/pseries/papr_scm.c +3 -0
@@ -898,6 +898,9 @@ static int papr_scm_nvdimm_init(struct papr_scm_priv *p) p->bus_desc.of_node = p->pdev->dev.of_node; p->bus_desc.provider_name =kstrdup (p->pdev->name,GFP_KERNEL ); +/* Set the dimm command family mask to accept PDSMs */ +set_bit (NVDIMM_FAMILY_PAPR , &p->bus_desc.dimm_family_mask); +if (!p->bus_desc.provider_name)return -ENOMEM ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 491/757 cpufreq: powernv: Fix frame-size-overflow in powernv_cpufreq_reboot_notifier
In reply to Greg Kroah-HartmanFrom: Srikar Dronamraju <[email protected]>
[ Upstream commit a2d0230b91f7e23ceb5d8fb6a9799f30517ec33a ]
The patch avoids allocating cpufreq_policy on stack hence fixing frame size overflow in 'powernv_cpufreq_reboot_notifier':
drivers/cpufreq/powernv-cpufreq.c: In function powernv_cpufreq_reboot_notifier:
drivers/cpufreq/powernv-cpufreq.c:906:1: error: the frame size of 2064 bytes is larger than 2048 bytes
--- drivers/cpufreq/powernv-cpufreq.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/cpufreq/powernv-cpufreq.c +6 -3
@@ -885,12 +885,15 @@ static int powernv_cpufreq_reboot_notifier(struct notifier_block *nb, unsigned long action, void *unused) { int cpu; -struct cpufreq_policy cpu_policy; +struct cpufreq_policy *cpu_policy; rebooting = true;for_each_online_cpu (cpu) { -cpufreq_get_policy (&cpu_policy, cpu); -powernv_cpufreq_target_index (&cpu_policy,get_nominal_index ()); + cpu_policy =cpufreq_cpu_get (cpu); +if (!cpu_policy) +continue ; +powernv_cpufreq_target_index (cpu_policy,get_nominal_index ()); +cpufreq_cpu_put (cpu_policy); }return NOTIFY_DONE ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 492/757 IB/rdmavt: Fix sizeof mismatch
In reply to Greg Kroah-HartmanFrom: Colin Ian King <[email protected]>
[ Upstream commit 8e71f694e0c819db39af2336f16eb9689f1ae53f ]
An incorrect sizeof is being used, struct rvt_ibport ** is not correct, it should be struct rvt_ibport *. Note that since ** is the same size as
* this is not causing any issues. Improve this fix by using sizeof(*rdi->ports) as this allows us to not even reference the type of the pointer. Also remove line breaks as the entire statement can fit on one line.
Addresses-Coverity: ("Sizeof not portable (SIZEOF_MISMATCH)")
--- drivers/infiniband/sw/rdmavt/vt.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/infiniband/sw/rdmavt/vt.c +1 -3
@@ -95,9 +95,7 @@ struct rvt_dev_info *rvt_alloc_device(size_t size, int nports)if (!rdi)return rdi; - rdi->ports =kcalloc (nports, -sizeof (struct rvt_ibport **), -GFP_KERNEL ); + rdi->ports =kcalloc (nports,sizeof (*rdi->ports),GFP_KERNEL );if (!rdi->ports)ib_dealloc_device (&rdi->ibdev);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 493/757 RDMA/rxe: Fix skb lifetime in rxe_rcv_mcast_pkt()
In reply to Greg Kroah-HartmanFrom: Bob Pearson <[email protected]>
[ Upstream commit e7ec96fc7932f48a6d6cdd05bf82004a1a04285b ]
The changes referenced below replaced sbk_clone)_ by taking additional references, passing the skb along and then freeing the skb. This deleted the packets before they could be processed and additionally passed bad data in each packet. Since pkt is stored in skb->cb changing pkt->qp changed it for all the packets.
Replace skb_get() by sbk_clone() in rxe_rcv_mcast_pkt() for cases where multiple QPs are receiving multicast packets on the same address.
Delete kfree_skb() because the packets need to live until they have been processed by each QP. They are freed later.
--- drivers/infiniband/sw/rxe/rxe_recv.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/infiniband/sw/rxe/rxe_recv.c +12 -5
@@ -260,6 +260,8 @@ static void rxe_rcv_mcast_pkt(struct rxe_dev *rxe, struct sk_buff *skb)struct rxe_mc_elem *mce;struct rxe_qp *qp;union ib_gid dgid; +struct sk_buff *per_qp_skb; +struct rxe_pkt_info *per_qp_pkt;int err;if (skb->protocol ==htons (ETH_P_IP ))
@@ -288,21 +290,26 @@ static void rxe_rcv_mcast_pkt(struct rxe_dev *rxe, struct sk_buff *skb)if (err)continue ; -/* if *not* the last qp in the list -* increase the users of the skb then post to the next qp +/* for all but the last qp create a new clone of the +* skb and pass to the qp. */ if (mce->qp_list.next != &mcg->qp_list) -skb_get (skb); + per_qp_skb =skb_clone (skb,GFP_ATOMIC ); +else + per_qp_skb = skb; - pkt->qp = qp; + per_qp_pkt =SKB_TO_PKT (per_qp_skb); + per_qp_pkt->qp = qp;rxe_add_ref (qp); -rxe_rcv_pkt (pkt, skb); +rxe_rcv_pkt (per_qp_pkt, per_qp_skb); }spin_unlock_bh (&mcg->mcg_lock);rxe_drop_ref (mcg);/* drop ref from rxe_pool_get_key. */ +return ; + err1:kfree_skb (skb); }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 494/757 f2fs: reject CASEFOLD inode flag without casefold feature
In reply to Greg Kroah-HartmanFrom: Eric Biggers <[email protected]>
[ Upstream commit f6322f3f1212e005e7e6aa82ceb62be53030a64b ]
syzbot reported:
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: 6860 Comm: syz-executor835 Not tainted 5.9.0-rc8-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:utf8_casefold+0x43/0x1b0 fs/unicode/utf8-core.c:107
[...]
Call Trace:
f2fs_init_casefolded_name fs/f2fs/dir.c:85 [inline]
__f2fs_setup_filename fs/f2fs/dir.c:118 [inline]
f2fs_prepare_lookup+0x3bf/0x640 fs/f2fs/dir.c:163
f2fs_lookup+0x10d/0x920 fs/f2fs/namei.c:494
__lookup_hash+0x115/0x240 fs/namei.c:1445
filename_create+0x14b/0x630 fs/namei.c:3467
user_path_create fs/namei.c:3524 [inline]
do_mkdirat+0x56/0x310 fs/namei.c:3664
do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46
entry_SYSCALL_64_after_hwframe+0x44/0xa9
[...]The problem is that an inode has F2FS_CASEFOLD_FL set, but the filesystem doesn't have the casefold feature flag set, and therefore super_block::s_encoding is NULL.
Fix this by making sanity_check_inode() reject inodes that have F2FS_CASEFOLD_FL when the filesystem doesn't have the casefold feature.
--- fs/f2fs/inode.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/f2fs/inode.c +7 -0
@@ -287,6 +287,13 @@ static bool sanity_check_inode(struct inode *inode, struct page *node_page)return false; } +if ((fi->i_flags &F2FS_CASEFOLD_FL ) && !f2fs_sb_has_casefold (sbi)) { +set_sbi_flag (sbi,SBI_NEED_FSCK ); +f2fs_warn (sbi,"%s: inode (ino=%lx) has casefold flag, but casefold feature is off" , + __func__, inode->i_ino); +return false; + } +if (f2fs_has_extra_attr (inode) &&f2fs_sb_has_compression (sbi) && fi->i_flags &F2FS_COMPR_FL && F2FS_FITS_IN_INODE(ri, fi->i_extra_isize,
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 495/757 um: vector: Use GFP_ATOMIC under spin lock
In reply to Greg Kroah-HartmanFrom: Tiezhu Yang <[email protected]>
[ Upstream commit e4e721fe4ccb504a29d1e8d4047667557281d932 ]
Use GFP_ATOMIC instead of GFP_KERNEL under spin lock to fix possible sleep-in-atomic-context bugs.
--- arch/um/drivers/vector_kern.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/um/drivers/vector_kern.c +2 -2
@@ -1403,7 +1403,7 @@ static int vector_net_load_bpf_flash(struct net_device *dev,kfree (vp->bpf->filter); vp->bpf->filter =NULL ; }else { - vp->bpf =kmalloc (sizeof (struct sock_fprog ),GFP_KERNEL ); + vp->bpf =kmalloc (sizeof (struct sock_fprog ),GFP_ATOMIC );if (vp->bpf ==NULL ) {netdev_err (dev,"failed to allocate memory for firmware\n" ); goto flash_fail;
@@ -1415,7 +1415,7 @@ static int vector_net_load_bpf_flash(struct net_device *dev,if (request_firmware (&fw, efl->data, &vdevice->pdev.dev)) goto flash_fail; - vp->bpf->filter =kmemdup (fw->data, fw->size,GFP_KERNEL ); + vp->bpf->filter =kmemdup (fw->data, fw->size,GFP_ATOMIC );if (!vp->bpf->filter) goto free_buffer;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 496/757 um: time-travel: Fix IRQ handling in time_travel_handle_message()
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit ebef8ea2ba967026192a26f4529890893919bc57 ]
As the comment here indicates, we need to do the polling in the idle loop without blocking interrupts, since interrupts can be vhost-user messages that we must process even while in our idle loop.
I don't know why I explained one thing and implemented another, but we have indeed observed random hangs due to this, depending on the timing of the messages.
--- arch/um/kernel/time.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
arch/um/kernel/time.c +9 -5
@@ -70,13 +70,17 @@ static void time_travel_handle_message(struct um_timetravel_msg *msg,* read of the message and write of the ACK. */ if (mode !=TTMH_READ ) { +bool disabled =irqs_disabled (); + +BUG_ON (mode ==TTMH_IDLE && !disabled); + +if (disabled) +local_irq_enable ();while (os_poll (1 , &time_travel_ext_fd) !=0 ) { -if (mode ==TTMH_IDLE ) { -BUG_ON (!irqs_disabled ()); -local_irq_enable (); -local_irq_disable (); - } +/* nothing */ } +if (disabled) +local_irq_disable (); } ret =os_read_file (time_travel_ext_fd, msg,sizeof (*msg));
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 497/757 thermal: core: Adding missing nlmsg_free() in thermal_genl_sampling_temp()
In reply to Greg Kroah-HartmanFrom: Jing Xiangfeng <[email protected]>
[ Upstream commit 48b458591749d35c927351b4960b49e35af30fe6 ]
thermal_genl_sampling_temp() misses to call nlmsg_free() in an error path.
Jump to out_free to fix it.
--- drivers/thermal/thermal_netlink.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/thermal/thermal_netlink.c +2 -1
@@ -78,7 +78,7 @@ int thermal_genl_sampling_temp(int id, int temp) hdr =genlmsg_put (skb,0 ,0 , &thermal_gnl_family,0 ,THERMAL_GENL_SAMPLING_TEMP );if (!hdr) -return -EMSGSIZE ; + goto out_free;if (nla_put_u32 (skb,THERMAL_GENL_ATTR_TZ_ID , id)) goto out_cancel;
@@ -93,6 +93,7 @@ int thermal_genl_sampling_temp(int id, int temp)return 0 ; out_cancel:genlmsg_cancel (skb, hdr); +out_free:nlmsg_free (skb);return -EMSGSIZE ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 498/757 maiblox: mediatek: Fix handling of platform_get_irq() error
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit 558e4c36ec9f2722af4fe8ef84dc812bcdb5c43a ]
platform_get_irq() returns -ERRNO on error. In such case casting to u32 and comparing to 0 would pass the check.
--- drivers/mailbox/mtk-cmdq-mailbox.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/mailbox/mtk-cmdq-mailbox.c +3 -5
@@ -69,7 +69,7 @@ struct cmdq_task {struct cmdq {struct mbox_controller mbox;void __iomem *base; -u32 irq; +int irq;u32 thread_nr;u32 irq_mask;struct cmdq_thread *thread;
@@ -525,10 +525,8 @@ static int cmdq_probe(struct platform_device *pdev) } cmdq->irq =platform_get_irq (pdev,0 ); -if (!cmdq->irq) { -dev_err (dev,"failed to get irq\n" ); -return -EINVAL ; - } +if (cmdq->irq <0 ) +return cmdq->irq; plat_data = (struct gce_plat *)of_device_get_match_data (dev);if (!plat_data) {
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 499/757 perf trace: Fix off by ones in memset() after realloc() in arches using libaudit
In reply to Greg Kroah-HartmanFrom: Jiri Slaby <[email protected]>
[ Upstream commit f3013f7ed465479e60c1ab1921a5718fc541cc3b ]
'perf trace ls' started crashing after commit d21cb73a9025 on !HAVE_SYSCALL_TABLE_SUPPORT configs (armv7l here) like this:
0 strlen () at ../sysdeps/arm/armv6t2/strlen.S:126
1 0xb6800780 in __vfprintf_internal (s=0xbeff9908, s@entry=0xbeff9900, format=0xa27160 "]: %s()", ap=..., mode_flags=<optimized out>) at vfprintf-internal.c:1688
...
5 0x0056ecdc in fprintf (__fmt=0xa27160 "]: %s()", __stream=<optimized out>) at /usr/include/bits/stdio2.h:100 6 trace__sys_exit (trace=trace@entry=0xbeffc710, evsel=evsel@entry=0xd968d0, event=<optimized out>, sample=sample@entry=0xbeffc3e8) at builtin-trace.c:2475 7 0x00566d40 in trace__handle_event (sample=0xbeffc3e8, event=<optimized out>, trace=0xbeffc710) at builtin-trace.c:3122
...
15 main (argc=2, argv=0xbefff6e8) at perf.c:538
It is because memset in trace__read_syscall_info zeroes wrong memory:
1) when initializing for the first time, it does not reset the last id.
2) in other cases, it resets the last id of previous buffer.
ad 1) it causes the crash above as sc->name used in the fprintf above
contains garbage.
ad 2) it sets nonexistent from true back to false for id 11 here. Not
sure, what the consequences are.
So fix it by introducing a special case for the initial initialization and do the right +1 in both cases.
--- tools/perf/builtin-trace.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/perf/builtin-trace.c +5 -1
@@ -1762,7 +1762,11 @@ static int trace__read_syscall_info(struct trace *trace, int id)if (table ==NULL )return -ENOMEM ; -memset (table + trace->sctbl->syscalls.max_id,0 , (id - trace->sctbl->syscalls.max_id) *sizeof (*sc)); +// Need to memset from offset 0 and +1 members if brand new +if (trace->syscalls.table ==NULL ) +memset (table,0 , (id +1 ) *sizeof (*sc)); +else +memset (table + trace->sctbl->syscalls.max_id +1 ,0 , (id - trace->sctbl->syscalls.max_id) *sizeof (*sc)); trace->syscalls.table = table; trace->sctbl->syscalls.max_id = id;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 500/757 selftests/powerpc: Fix eeh-basic.sh exit codes
In reply to Greg Kroah-HartmanFrom: Oliver O'Halloran <[email protected]>
[ Upstream commit 996f9e0f93f16211945c8d5f18f296a88cb32f91 ]
The kselftests test running infrastructure expects tests to finish with an exit code of 4 if the test decided it should be skipped. Currently eeh-basic.sh exits with the number of devices that failed to recover, so if four devices didn't recover we'll report a skip instead of a fail.
Fix this by checking if the return code is non-zero and report success and failure by returning 0 or 1 respectively. For the cases where should actually skip return 4.
--- tools/testing/selftests/powerpc/eeh/eeh-basic.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
tools/testing/selftests/powerpc/eeh/eeh-basic.sh +6 -3
@@ -1,17 +1,19 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0-only +KSELFTESTS_SKIP=4 + . ./eeh-functions.sh if ! eeh_supported ; then echo "EEH not supported on this system, skipping" - exit 0; + exit $KSELFTESTS_SKIP; fi if [ ! -e "/sys/kernel/debug/powerpc/eeh_dev_check" ] && \ [ ! -e "/sys/kernel/debug/powerpc/eeh_dev_break" ] ; then echo "debugfs EEH testing files are missing. Is debugfs mounted?" - exit 1; + exit $KSELFTESTS_SKIP; fi pre_lspci=`mktemp`
@@ -84,4 +86,5 @@ echo "$failed devices failed to recover ($dev_count tested)" lspci | diff -u $pre_lspci - rm -f $pre_lspci -exit $failed +test "$failed" == 0 +exit $?
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 501/757 f2fs: wait for sysfs kobject removal before freeing f2fs_sb_info
In reply to Greg Kroah-HartmanFrom: Jamie Iles <[email protected]>
[ Upstream commit ae284d87abade58c8db7760c808f311ef1ce693c ]
syzkaller found that with CONFIG_DEBUG_KOBJECT_RELEASE=y, unmounting an f2fs filesystem could result in the following splat:
kobject: 'loop5' ((____ptrval____)): kobject_release, parent 0000000000000000 (delayed 250)
kobject: 'f2fs_xattr_entry-7:5' ((____ptrval____)): kobject_release, parent 0000000000000000 (delayed 750)
------------[ cut here ]------------ ODEBUG: free active (active state 0) object type: timer_list hint: delayed_work_timer_fn+0x0/0x98 WARNING: CPU: 0 PID: 699 at lib/debugobjects.c:485 debug_print_object+0x180/0x240 Kernel panic - not syncing: panic_on_warn set ... CPU: 0 PID: 699 Comm: syz-executor.5 Tainted: G S 5.9.0-rc8+ #101 Hardware name: linux,dummy-virt (DT) Call trace: dump_backtrace+0x0/0x4d8 show_stack+0x34/0x48 dump_stack+0x174/0x1f8 panic+0x360/0x7a0 __warn+0x244/0x2ec report_bug+0x240/0x398 bug_handler+0x50/0xc0 call_break_hook+0x160/0x1d8 brk_handler+0x30/0xc0 do_debug_exception+0x184/0x340 el1_dbg+0x48/0xb0 el1_sync_handler+0x170/0x1c8 el1_sync+0x80/0x100 debug_print_object+0x180/0x240 debug_check_no_obj_freed+0x200/0x430 slab_free_freelist_hook+0x190/0x210 kfree+0x13c/0x460 f2fs_put_super+0x624/0xa58 generic_shutdown_super+0x120/0x300 kill_block_super+0x94/0xf8 kill_f2fs_super+0x244/0x308 deactivate_locked_super+0x104/0x150 deactivate_super+0x118/0x148 cleanup_mnt+0x27c/0x3c0 __cleanup_mnt+0x28/0x38 task_work_run+0x10c/0x248 do_notify_resume+0x9d4/0x1188 work_pending+0x8/0x34c
Like the error handling for f2fs_register_sysfs(), we need to wait for the kobject to be destroyed before returning to prevent a potential use-after-free.
--- fs/f2fs/sysfs.c | 1 + 1 file changed, 1 insertion(+)
fs/f2fs/sysfs.c +1 -0
@@ -968,4 +968,5 @@ void f2fs_unregister_sysfs(struct f2fs_sb_info *sbi) }kobject_del (&sbi->s_kobj);kobject_put (&sbi->s_kobj); +wait_for_completion (&sbi->s_kobj_unregister); }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 502/757 afs: Fix rapid cell addition/removal by not using RCU on cells tree
In reply to Greg Kroah-HartmanFrom: David Howells <[email protected]>
[ Upstream commit 92e3cc91d8f51ce64a8b7c696377180953dd316e ]
There are a number of problems that are being seen by the rapidly mounting and unmounting an afs dynamic root with an explicit cell and volume specified (which should probably be rejected, but that's a separate issue):
What the tests are doing is to look up/create a cell record for the name given and then tear it down again without actually using it to try to talk to a server. This is repeated endlessly, very fast, and the new cell collides with the old one if it's not quick enough to reuse it.
It appears (as suggested by Hillf Danton) that the search through the RB tree under a read_seqbegin_or_lock() under RCU conditions isn't safe and that it's not blocking the write_seqlock(), despite taking two passes at it. He suggested that the code should take a ref on the cell it's attempting to look at - but this shouldn't be necessary until we've compared the cell names. It's possible that I'm missing a barrier somewhere.
However, using an RCU search for this is overkill, really - we only need to access the cell name in a few places, and they're places where we're may end up sleeping anyway.
Fix this by switching to an R/W semaphore instead.
Additionally, draw the down_read() call inside the function (renamed to afs_find_cell()) since all the callers were taking the RCU read lock (or should've been[*]).
[*] afs_probe_cell_name() should have been, but that doesn't appear to be involved in the bug reports.
The symptoms of this look like:
general protection fault, probably for non-canonical address 0xf27d208691691fdb: 0000 [#1] PREEMPT SMP KASAN KASAN: maybe wild-memory-access in range [0x93e924348b48fed8-0x93e924348b48fedf] ... RIP: 0010:strncasecmp lib/string.c:52 [inline] RIP: 0010:strncasecmp+0x5f/0x240 lib/string.c:43 afs_lookup_cell_rcu+0x313/0x720 fs/afs/cell.c:88 afs_lookup_cell+0x2ee/0x1440 fs/afs/cell.c:249 afs_parse_source fs/afs/super.c:290 [inline] ...
--- fs/afs/cell.c | 131 ++++++++++++++++++++-------------------------- fs/afs/dynroot.c | 21 +++----- fs/afs/internal.h | 6 +-- fs/afs/main.c | 2 +- fs/afs/super.c | 4 +- 5 files changed, 71 insertions(+), 93 deletions(-)
fs/afs/cell.c +58 -73
@@ -41,15 +41,15 @@ static void afs_set_cell_timer(struct afs_net *net, time64_t delay) }/* -* Look up and get an activation reference on a cell record under RCU -* conditions. The caller must hold the RCU read lock. +* Look up and get an activation reference on a cell record. The caller must +* hold net->cells_lock at least read-locked. */ -struct afs_cell *afs_lookup_cell_rcu (struct afs_net *net, -const char *name,unsigned int namesz) +static struct afs_cell *afs_find_cell_locked (struct afs_net *net, +const char *name,unsigned int namesz) {struct afs_cell *cell =NULL ;struct rb_node *p; -int n, seq =0 , ret =0 ; +int n;_enter ("%*.*s" , namesz, namesz, name);
@@ -58,61 +58,48 @@ struct afs_cell *afs_lookup_cell_rcu(struct afs_net *net,if (namesz >AFS_MAXCELLNAME )return ERR_PTR (-ENAMETOOLONG ); -do { -/* Unfortunately, rbtree walking doesn't give reliable results -* under just the RCU read lock, so we have to check for -* changes. -*/ -if (cell) -afs_put_cell (net, cell); - cell =NULL ; - ret = -ENOENT ; - -read_seqbegin_or_lock (&net->cells_lock, &seq); - -if (!name) { - cell =rcu_dereference_raw (net->ws_cell); -if (cell) { -afs_get_cell (cell); - ret =0 ; -break ; - } - ret = -EDESTADDRREQ ; -continue ; - } +if (!name) { + cell = net->ws_cell; +if (!cell) +return ERR_PTR (-EDESTADDRREQ ); +afs_get_cell (cell); +return cell; + } - p =rcu_dereference_raw (net->cells.rb_node); -while (p) { - cell = rb_entry(p, struct afs_cell, net_node); - - n =strncasecmp (cell->name, name, -min_t (size_t, cell->name_len, namesz)); -if (n ==0 ) - n = cell->name_len - namesz; -if (n <0 ) { - p =rcu_dereference_raw (p->rb_left); - }else if (n >0 ) { - p =rcu_dereference_raw (p->rb_right); - }else { -if (atomic_inc_not_zero (&cell->usage)) { - ret =0 ; -break ; - } -/* We want to repeat the search, this time with -* the lock properly locked. -*/ - } - cell =NULL ; - } + p = net->cells.rb_node; +while (p) { + cell = rb_entry(p, struct afs_cell, net_node); - }while (need_seqretry (&net->cells_lock, seq)); + n =strncasecmp (cell->name, name, +min_t (size_t, cell->name_len, namesz)); +if (n ==0 ) + n = cell->name_len - namesz; +if (n <0 ) + p = p->rb_left; +else if (n >0 ) + p = p->rb_right; +else + goto found; + } + +return ERR_PTR (-ENOENT ); -done_seqretry (&net->cells_lock, seq); +found: +if (!atomic_inc_not_zero (&cell->usage)) +return ERR_PTR (-ENOENT ); -if (ret !=0 && cell) -afs_put_cell (net, cell); +return cell; +} -return ret ==0 ? cell :ERR_PTR (ret); +struct afs_cell *afs_find_cell (struct afs_net *net, +const char *name,unsigned int namesz) +{ +struct afs_cell *cell; + +down_read (&net->cells_lock); + cell =afs_find_cell_locked (net, name, namesz); +up_read (&net->cells_lock); +return cell; }/*
@@ -245,9 +232,7 @@ struct afs_cell *afs_lookup_cell(struct afs_net *net,_enter ("%s,%s" , name, vllist);if (!excl) { -rcu_read_lock (); - cell =afs_lookup_cell_rcu (net, name, namesz); -rcu_read_unlock (); + cell =afs_find_cell (net, name, namesz);if (!IS_ERR (cell)) goto wait_for_cell; }
@@ -268,7 +253,7 @@ struct afs_cell *afs_lookup_cell(struct afs_net *net,/* Find the insertion point and check to see if someone else added a * cell whilst we were allocating. */ -write_seqlock (&net->cells_lock); +down_write (&net->cells_lock); pp = &net->cells.rb_node; parent =NULL ;
@@ -293,7 +278,7 @@ struct afs_cell *afs_lookup_cell(struct afs_net *net,rb_link_node_rcu (&cell->net_node, parent, pp);rb_insert_color (&cell->net_node, &net->cells);atomic_inc (&net->cells_outstanding); -write_sequnlock (&net->cells_lock); +up_write (&net->cells_lock);queue_work (afs_wq, &cell->manager);
@@ -323,7 +308,7 @@ struct afs_cell *afs_lookup_cell(struct afs_net *net,afs_get_cell (cursor); ret =0 ; } -write_sequnlock (&net->cells_lock); +up_write (&net->cells_lock);kfree (candidate);if (ret ==0 ) goto wait_for_cell;
@@ -377,10 +362,10 @@ int afs_cell_init(struct afs_net *net, const char *rootcell)afs_get_cell (new_root);/* install the new cell */ -write_seqlock (&net->cells_lock); - old_root =rcu_access_pointer (net->ws_cell); -rcu_assign_pointer (net->ws_cell, new_root); -write_sequnlock (&net->cells_lock); +down_write (&net->cells_lock); + old_root = net->ws_cell; + net->ws_cell = new_root; +up_write (&net->cells_lock);afs_put_cell (net, old_root);_leave (" = 0" );
@@ -674,12 +659,12 @@ static void afs_manage_cell(struct work_struct *work)switch (cell->state) {case AFS_CELL_INACTIVE :case AFS_CELL_FAILED : -write_seqlock (&net->cells_lock); +down_write (&net->cells_lock); usage =1 ; deleted =atomic_try_cmpxchg_relaxed (&cell->usage, &usage,0 );if (deleted)rb_erase (&cell->net_node, &net->cells); -write_sequnlock (&net->cells_lock); +up_write (&net->cells_lock);if (deleted) goto final_destruction;if (cell->state ==AFS_CELL_FAILED )
@@ -779,7 +764,7 @@ void afs_manage_cells(struct work_struct *work)* lack of use and cells whose DNS results have expired and dispatch * their managers. */ -read_seqlock_excl (&net->cells_lock); +down_read (&net->cells_lock);for (cursor =rb_first (&net->cells); cursor; cursor =rb_next (cursor)) { struct afs_cell *cell =
@@ -824,7 +809,7 @@ void afs_manage_cells(struct work_struct *work)queue_work (afs_wq, &cell->manager); } -read_sequnlock_excl (&net->cells_lock); +up_read (&net->cells_lock);/* Update the timer on the way out. We have to pass an increment on * cells_outstanding in the namespace that we are in to the timer or
@@ -854,10 +839,10 @@ void afs_cell_purge(struct afs_net *net)_enter ("" ); -write_seqlock (&net->cells_lock); - ws =rcu_access_pointer (net->ws_cell); -RCU_INIT_POINTER (net->ws_cell,NULL ); -write_sequnlock (&net->cells_lock); +down_write (&net->cells_lock); + ws = net->ws_cell; + net->ws_cell =NULL ; +up_write (&net->cells_lock);afs_put_cell (net, ws);_debug ("del timer" );
fs/afs/dynroot.c +8 -13
@@ -123,7 +123,7 @@ static int afs_probe_cell_name(struct dentry *dentry) len--; } - cell =afs_lookup_cell_rcu (net, name, len); + cell =afs_find_cell (net, name, len);if (!IS_ERR (cell)) {afs_put_cell (net, cell);return 0 ;
@@ -179,7 +179,6 @@ static struct dentry *afs_lookup_atcell(struct dentry *dentry)struct afs_cell *cell;struct afs_net *net =afs_d2net (dentry);struct dentry *ret; -unsigned int seq =0 ;char *name;int len;
@@ -191,17 +190,13 @@ static struct dentry *afs_lookup_atcell(struct dentry *dentry)if (!name) goto out_p; -rcu_read_lock (); -do { -read_seqbegin_or_lock (&net->cells_lock, &seq); - cell =rcu_dereference_raw (net->ws_cell); -if (cell) { - len = cell->name_len; -memcpy (name, cell->name, len +1 ); - } - }while (need_seqretry (&net->cells_lock, seq)); -done_seqretry (&net->cells_lock, seq); -rcu_read_unlock (); +down_read (&net->cells_lock); + cell = net->ws_cell; +if (cell) { + len = cell->name_len; +memcpy (name, cell->name, len +1 ); + } +up_read (&net->cells_lock); ret =ERR_PTR (-ENOENT );if (!cell)
fs/afs/internal.h +3 -3
@@ -263,11 +263,11 @@ struct afs_net {/* Cell database */ struct rb_root cells; -struct afs_cell __rcu *ws_cell; +struct afs_cell *ws_cell;struct work_struct cells_manager;struct timer_list cells_timer;atomic_t cells_outstanding; -seqlock_t cells_lock; +struct rw_semaphore cells_lock;struct mutex cells_alias_lock;struct mutex proc_cells_lock;
@@ -917,7 +917,7 @@ static inline bool afs_cb_is_broken(unsigned int cb_break,* cell.c */ extern int afs_cell_init (struct afs_net *,const char *); -extern struct afs_cell *afs_lookup_cell_rcu (struct afs_net *,const char *,unsigned ); +extern struct afs_cell *afs_find_cell (struct afs_net *,const char *,unsigned );extern struct afs_cell *afs_lookup_cell (struct afs_net *,const char *,unsigned ,const char *,bool );extern struct afs_cell *afs_get_cell (struct afs_cell *);
fs/afs/main.c +1 -1
@@ -78,7 +78,7 @@ static int __net_init afs_net_init(struct net *net_ns)mutex_init (&net->socket_mutex); net->cells =RB_ROOT ; -seqlock_init (&net->cells_lock); +init_rwsem (&net->cells_lock);INIT_WORK (&net->cells_manager, afs_manage_cells);timer_setup (&net->cells_timer, afs_cells_timer,0 );
fs/afs/super.c +1 -3
@@ -634,9 +634,7 @@ static int afs_init_fs_context(struct fs_context *fc) ctx->net =afs_net (fc->net_ns);/* Default to the workstation cell. */ -rcu_read_lock (); - cell =afs_lookup_cell_rcu (ctx->net,NULL ,0 ); -rcu_read_unlock (); + cell =afs_find_cell (ctx->net,NULL ,0 );if (IS_ERR (cell)) cell =NULL ; ctx->cell = cell;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 503/757 afs: Fix cell refcounting by splitting the usage counter
In reply to Greg Kroah-HartmanFrom: David Howells <[email protected]>
[ Upstream commit 88c853c3f5c0a07c5db61b494ee25152535cfeee ]
Management of the lifetime of afs_cell struct has some problems due to the usage counter being used to determine whether objects of that type are in use in addition to whether anyone might be interested in the structure.
This is made trickier by cell objects being cached for a period of time in case they're quickly reused as they hold the result of a setup process that may be slow (DNS lookups, AFS RPC ops).
Problems include the cached root volume from alias resolution pinning its parent cell record, rmmod occasionally hanging and occasionally producing assertion failures.
Fix this by splitting the count of active users from the struct reference count. Things then work as follows:
(1) The cell cache keeps +1 on the cell's activity count and this has to be dropped before the cell can be removed. afs_manage_cell() tries to exchange the 1 to a 0 with the cells_lock write-locked, and if successful, the record is removed from the net->cells.
(2) One struct ref is 'owned' by the activity count. That is put when the active count is reduced to 0 (final_destruction label).
(3) A ref can be held on a cell whilst it is queued for management on a work queue without confusing the active count. afs_queue_cell() is added to wrap this.
(4) The queue's ref is dropped at the end of the management. This is split out into a separate function, afs_manage_cell_work().
(5) The root volume record is put after a cell is removed (at the final_destruction label) rather then in the RCU destruction routine.
(6) Volumes hold struct refs, but aren't active users.
(7) Both counts are displayed in /proc/net/afs/cells.
There are some management function changes:
(*) afs_put_cell() now just decrements the refcount and triggers the RCU
destruction if it becomes 0. It no longer sets a timer to have the manager do this.
(*) afs_use_cell() and afs_unuse_cell() are added to increase and decrease
the active count. afs_unuse_cell() sets the management timer.
(*) afs_queue_cell() is added to queue a cell with approprate refs.
There are also some other fixes:
(*) Don't let /proc/net/afs/cells access a cell's vllist if it's NULL.
(*) Make sure that candidate cells in lookups are properly destroyed
rather than being simply kfree'd. This ensures the bits it points to are destroyed also.
(*) afs_dec_cells_outstanding() is now called in cell destruction rather
than at "final_destruction". This ensures that cell->net is still valid to the end of the destructor.
(*) As a consequence of the previous two changes, move the increment of
net->cells_outstanding that was at the point of insertion into the tree to the allocation routine to correctly balance things.
--- fs/afs/cell.c | 149 +++++++++++++++++++++++++++++++-------------- fs/afs/dynroot.c | 2 +- fs/afs/internal.h | 8 ++- fs/afs/mntpt.c | 4 +- fs/afs/proc.c | 23 ++++--- fs/afs/super.c | 12 ++-- fs/afs/vl_alias.c | 8 +-- fs/afs/vl_rotate.c | 2 +- fs/afs/volume.c | 4 +- 9 files changed, 136 insertions(+), 76 deletions(-)
fs/afs/cell.c +103 -46
@@ -19,7 +19,7 @@ static unsigned __read_mostly afs_cell_gc_delay = 10;static unsigned __read_mostly afs_cell_min_ttl =10 *60 ;static unsigned __read_mostly afs_cell_max_ttl =24 *60 *60 ; -static void afs_manage_cell (struct work_struct *); +static void afs_manage_cell_work (struct work_struct *);static void afs_dec_cells_outstanding (struct afs_net *net) {
@@ -62,8 +62,7 @@ static struct afs_cell *afs_find_cell_locked(struct afs_net *net, cell = net->ws_cell;if (!cell)return ERR_PTR (-EDESTADDRREQ ); -afs_get_cell (cell); -return cell; + goto found; } p = net->cells.rb_node;
@@ -85,12 +84,12 @@ static struct afs_cell *afs_find_cell_locked(struct afs_net *net,return ERR_PTR (-ENOENT ); found: -if (!atomic_inc_not_zero (&cell->usage)) -return ERR_PTR (-ENOENT ); - -return cell; +return afs_use_cell (cell); } +/* +* Look up and get an activation reference on a cell record. +*/ struct afs_cell *afs_find_cell (struct afs_net *net,const char *name,unsigned int namesz) {
@@ -153,8 +152,9 @@ static struct afs_cell *afs_alloc_cell(struct afs_net *net, cell->name[i] =tolower (name[i]); cell->name[i] =0 ; -atomic_set (&cell->usage,2 ); -INIT_WORK (&cell->manager, afs_manage_cell); +atomic_set (&cell->ref,1 ); +atomic_set (&cell->active,0 ); +INIT_WORK (&cell->manager, afs_manage_cell_work); cell->volumes =RB_ROOT ;INIT_HLIST_HEAD (&cell->proc_volumes);seqlock_init (&cell->volume_lock);
@@ -193,6 +193,7 @@ static struct afs_cell *afs_alloc_cell(struct afs_net *net, cell->dns_source = vllist->source; cell->dns_status = vllist->status;smp_store_release (&cell->dns_lookup_count,1 );/* vs source/status */ +atomic_inc (&net->cells_outstanding);_leave (" = %p" , cell);return cell;
@@ -275,12 +276,12 @@ struct afs_cell *afs_lookup_cell(struct afs_net *net, cell = candidate; candidate =NULL ; +atomic_set (&cell->active,2 );rb_link_node_rcu (&cell->net_node, parent, pp);rb_insert_color (&cell->net_node, &net->cells); -atomic_inc (&net->cells_outstanding);up_write (&net->cells_lock); -queue_work (afs_wq, &cell->manager); +afs_queue_cell (cell); wait_for_cell:_debug ("wait_for_cell" );
@@ -305,16 +306,17 @@ struct afs_cell *afs_lookup_cell(struct afs_net *net,if (excl) { ret = -EEXIST ; }else { -afs_get_cell (cursor); +afs_use_cell (cursor); ret =0 ; }up_write (&net->cells_lock); -kfree (candidate); +if (candidate) +afs_put_cell (candidate);if (ret ==0 ) goto wait_for_cell; goto error_noput; error: -afs_put_cell (net, cell); +afs_unuse_cell (net, cell); error_noput:_leave (" = %d [error]" , ret);return ERR_PTR (ret);
@@ -359,7 +361,7 @@ int afs_cell_init(struct afs_net *net, const char *rootcell) }if (!test_and_set_bit (AFS_CELL_FL_NO_GC , &new_root->flags)) -afs_get_cell (new_root); +afs_use_cell (new_root);/* install the new cell */ down_write (&net->cells_lock);
@@ -367,7 +369,7 @@ int afs_cell_init(struct afs_net *net, const char *rootcell) net->ws_cell = new_root;up_write (&net->cells_lock); -afs_put_cell (net, old_root); +afs_unuse_cell (net, old_root);_leave (" = 0" );return 0 ; }
@@ -473,18 +475,21 @@ static int afs_update_cell(struct afs_cell *cell)static void afs_cell_destroy (struct rcu_head *rcu) { struct afs_cell *cell = container_of(rcu, struct afs_cell, rcu); +struct afs_net *net = cell->net; +int u;_enter ("%p{%s}" , cell, cell->name); - ASSERTCMP(atomic_read(&cell->usage), ==, 0); + u =atomic_read (&cell->ref); + ASSERTCMP(u, ==, 0); -afs_put_volume (cell->net, cell->root_volume, afs_volume_trace_put_cell_root); -afs_put_vlserverlist (cell->net,rcu_access_pointer (cell->vl_servers)); -afs_put_cell (cell->net, cell->alias_of); +afs_put_vlserverlist (net,rcu_access_pointer (cell->vl_servers)); +afs_unuse_cell (net, cell->alias_of);key_put (cell->anonymous_key);kfree (cell->name);kfree (cell); +afs_dec_cells_outstanding (net);_leave (" [destroyed]" ); }
@@ -519,16 +524,50 @@ void afs_cells_timer(struct timer_list *timer)*/ struct afs_cell *afs_get_cell (struct afs_cell *cell) { -atomic_inc (&cell->usage); +if (atomic_read (&cell->ref) <=0 ) +BUG (); + +atomic_inc (&cell->ref);return cell; }/* * Drop a reference on a cell record. */ -void afs_put_cell (struct afs_net *net,struct afs_cell *cell) +void afs_put_cell (struct afs_cell *cell) +{ +if (cell) { +unsigned int u, a; + + u =atomic_dec_return (&cell->ref); +if (u ==0 ) { + a =atomic_read (&cell->active); +WARN (a !=0 ,"Cell active count %u > 0\n" , a); +call_rcu (&cell->rcu, afs_cell_destroy); + } + } +} + +/* +* Note a cell becoming more active. +*/ +struct afs_cell *afs_use_cell (struct afs_cell *cell) +{ +if (atomic_read (&cell->ref) <=0 ) +BUG (); + +atomic_inc (&cell->active); +return cell; +} + +/* +* Record a cell becoming less active. When the active counter reaches 1, it +* is scheduled for destruction, but may get reactivated. +*/ +void afs_unuse_cell (struct afs_net *net,struct afs_cell *cell) {time64_t now, expire_delay; +int a;if (!cell)return ;
@@ -541,11 +580,21 @@ void afs_put_cell(struct afs_net *net, struct afs_cell *cell)if (cell->vl_servers->nr_servers) expire_delay = afs_cell_gc_delay; -if (atomic_dec_return (&cell->usage) >1 ) -return ; + a =atomic_dec_return (&cell->active); +WARN_ON (a ==0 ); +if (a ==1 ) +/* 'cell' may now be garbage collected. */ +afs_set_cell_timer (net, expire_delay); +} -/* 'cell' may now be garbage collected. */ -afs_set_cell_timer (net, expire_delay); +/* +* Queue a cell for management, giving the workqueue a ref to hold. +*/ +void afs_queue_cell (struct afs_cell *cell) +{ +afs_get_cell (cell); +if (!queue_work (afs_wq, &cell->manager)) +afs_put_cell (cell); }/*
@@ -645,12 +694,11 @@ static void afs_deactivate_cell(struct afs_net *net, struct afs_cell *cell)* Manage a cell record, initialising and destroying it, maintaining its DNS * records. */ -static void afs_manage_cell (struct work_struct *work) +static void afs_manage_cell (struct afs_cell *cell) { - struct afs_cell *cell = container_of(work, struct afs_cell, manager);struct afs_net *net = cell->net;bool deleted; -int ret, usage; +int ret, active;_enter ("%s" , cell->name);
@@ -660,10 +708,11 @@ static void afs_manage_cell(struct work_struct *work)case AFS_CELL_INACTIVE :case AFS_CELL_FAILED :down_write (&net->cells_lock); - usage =1 ; - deleted =atomic_try_cmpxchg_relaxed (&cell->usage, &usage,0 ); -if (deleted) + active =1 ; + deleted =atomic_try_cmpxchg_relaxed (&cell->active, &active,0 ); +if (deleted) {rb_erase (&cell->net_node, &net->cells); + }up_write (&net->cells_lock);if (deleted) goto final_destruction;
@@ -688,7 +737,7 @@ static void afs_manage_cell(struct work_struct *work) goto again;case AFS_CELL_ACTIVE : -if (atomic_read (&cell->usage) >1 ) { +if (atomic_read (&cell->active) >1 ) {if (test_and_clear_bit (AFS_CELL_FL_DO_LOOKUP , &cell->flags)) { ret =afs_update_cell (cell);if (ret <0 )
@@ -701,7 +750,7 @@ static void afs_manage_cell(struct work_struct *work) goto again;case AFS_CELL_DEACTIVATING : -if (atomic_read (&cell->usage) >1 ) +if (atomic_read (&cell->active) >1 ) goto reverse_deactivation;afs_deactivate_cell (net, cell);smp_store_release (&cell->state,AFS_CELL_INACTIVE );
@@ -733,9 +782,18 @@ static void afs_manage_cell(struct work_struct *work)return ; final_destruction: -call_rcu (&cell->rcu, afs_cell_destroy); -afs_dec_cells_outstanding (net); -_leave (" [destruct %d]" ,atomic_read (&net->cells_outstanding)); +/* The root volume is pinning the cell */ +afs_put_volume (cell->net, cell->root_volume, afs_volume_trace_put_cell_root); + cell->root_volume =NULL ; +afs_put_cell (cell); +} + +static void afs_manage_cell_work (struct work_struct *work) +{ + struct afs_cell *cell = container_of(work, struct afs_cell, manager); + +afs_manage_cell (cell); +afs_put_cell (cell); }/*
@@ -769,21 +827,20 @@ void afs_manage_cells(struct work_struct *work)for (cursor =rb_first (&net->cells); cursor; cursor =rb_next (cursor)) {struct afs_cell *cell = rb_entry(cursor, struct afs_cell, net_node); -unsigned usage; +unsigned active;bool sched_cell = false; - usage =atomic_read (&cell->usage); -_debug ("manage %s %u" , cell->name, usage); + active =atomic_read (&cell->active); +_debug ("manage %s %u %u" , cell->name,atomic_read (&cell->ref), active); - ASSERTCMP(usage, >=, 1); + ASSERTCMP(active, >=, 1);if (purging) {if (test_and_clear_bit (AFS_CELL_FL_NO_GC , &cell->flags)) - usage =atomic_dec_return (&cell->usage); - ASSERTCMP(usage, ==, 1); +atomic_dec (&cell->active); } -if (usage ==1 ) { +if (active ==1 ) {struct afs_vlserver_list *vllist;time64_t expire_at = cell->last_inactive;
@@ -806,7 +863,7 @@ void afs_manage_cells(struct work_struct *work) }if (sched_cell) -queue_work (afs_wq, &cell->manager); +afs_queue_cell (cell); }up_read (&net->cells_lock);
@@ -843,7 +900,7 @@ void afs_cell_purge(struct afs_net *net) ws = net->ws_cell; net->ws_cell =NULL ;up_write (&net->cells_lock); -afs_put_cell (net, ws); +afs_unuse_cell (net, ws);_debug ("del timer" );if (del_timer_sync (&net->cells_timer))
fs/afs/dynroot.c +1 -1
@@ -125,7 +125,7 @@ static int afs_probe_cell_name(struct dentry *dentry) cell =afs_find_cell (net, name, len);if (!IS_ERR (cell)) { -afs_put_cell (net, cell); +afs_unuse_cell (net, cell);return 0 ; }
fs/afs/internal.h +6 -2
@@ -363,7 +363,8 @@ struct afs_cell {#endif time64_t dns_expiry;/* Time AFSDB/SRV record expires */ time64_t last_inactive;/* Time of last drop of usage count */ -atomic_t usage; +atomic_t ref;/* Struct refcount */ +atomic_t active;/* Active usage counter */ unsigned long flags;#define AFS_CELL_FL_NO_GC 0/* The cell was added manually, don't auto-gc */ #define AFS_CELL_FL_DO_LOOKUP 1/* DNS lookup requested */
@@ -920,8 +921,11 @@ extern int afs_cell_init(struct afs_net *, const char *);extern struct afs_cell *afs_find_cell (struct afs_net *,const char *,unsigned );extern struct afs_cell *afs_lookup_cell (struct afs_net *,const char *,unsigned ,const char *,bool ); +extern struct afs_cell *afs_use_cell (struct afs_cell *); +extern void afs_unuse_cell (struct afs_net *,struct afs_cell *);extern struct afs_cell *afs_get_cell (struct afs_cell *); -extern void afs_put_cell (struct afs_net *,struct afs_cell *); +extern void afs_put_cell (struct afs_cell *); +extern void afs_queue_cell (struct afs_cell *);extern void afs_manage_cells (struct work_struct *);extern void afs_cells_timer (struct timer_list *); extern void __net_exit afs_cell_purge(struct afs_net *);
fs/afs/mntpt.c +2 -2
@@ -88,7 +88,7 @@ static int afs_mntpt_set_params(struct fs_context *fc, struct dentry *mntpt) ctx->force = true; }if (ctx->cell) { -afs_put_cell (ctx->net, ctx->cell); +afs_unuse_cell (ctx->net, ctx->cell); ctx->cell =NULL ; }if (test_bit (AFS_VNODE_PSEUDODIR , &vnode->flags)) {
@@ -124,7 +124,7 @@ static int afs_mntpt_set_params(struct fs_context *fc, struct dentry *mntpt)char *buf;if (src_as->cell) - ctx->cell =afs_get_cell (src_as->cell); + ctx->cell =afs_use_cell (src_as->cell);if (size <2 || size >PAGE_SIZE -1 )return -EINVAL ;
fs/afs/proc.c +11 -12
@@ -38,7 +38,7 @@ static int afs_proc_cells_show(struct seq_file *m, void *v)if (v ==SEQ_START_TOKEN ) {/* display header on line 1 */ -seq_puts (m,"USE TTL SV ST NAME\n" ); +seq_puts (m,"USE ACT TTL SV ST NAME\n" );return 0 ; }
@@ -46,10 +46,11 @@ static int afs_proc_cells_show(struct seq_file *m, void *v) vllist =rcu_dereference (cell->vl_servers);/* display one cell per line on subsequent lines */ -seq_printf (m,"%3u %6lld %2u %2u %s\n" , -atomic_read (&cell->usage), +seq_printf (m,"%3u %3u %6lld %2u %2u %s\n" , +atomic_read (&cell->ref), +atomic_read (&cell->active), cell->dns_expiry -ktime_get_real_seconds (), - vllist->nr_servers, + vllist ? vllist->nr_servers :0 , cell->state, cell->name);return 0 ;
@@ -128,7 +129,7 @@ static int afs_proc_cells_write(struct file *file, char *buf, size_t size) }if (test_and_set_bit (AFS_CELL_FL_NO_GC , &cell->flags)) -afs_put_cell (net, cell); +afs_unuse_cell (net, cell); }else { goto inval; }
@@ -154,13 +155,11 @@ static int afs_proc_rootcell_show(struct seq_file *m, void *v)struct afs_net *net; net =afs_seq2net_single (m); -if (rcu_access_pointer (net->ws_cell)) { -rcu_read_lock (); - cell =rcu_dereference (net->ws_cell); -if (cell) -seq_printf (m,"%s\n" , cell->name); -rcu_read_unlock (); - } +down_read (&net->cells_lock); + cell = net->ws_cell; +if (cell) +seq_printf (m,"%s\n" , cell->name); +up_read (&net->cells_lock);return 0 ; }
fs/afs/super.c +6 -6
@@ -294,7 +294,7 @@ static int afs_parse_source(struct fs_context *fc, struct fs_parameter *param) cellnamesz, cellnamesz, cellname ?: "");return PTR_ERR (cell); } -afs_put_cell (ctx->net, ctx->cell); +afs_unuse_cell (ctx->net, ctx->cell); ctx->cell = cell; }
@@ -389,8 +389,8 @@ static int afs_validate_fc(struct fs_context *fc)_debug ("switch to alias" );key_put (ctx->key); ctx->key =NULL ; - cell =afs_get_cell (ctx->cell->alias_of); -afs_put_cell (ctx->net, ctx->cell); + cell =afs_use_cell (ctx->cell->alias_of); +afs_unuse_cell (ctx->net, ctx->cell); ctx->cell = cell; goto reget_key; }
@@ -508,7 +508,7 @@ static struct afs_super_info *afs_alloc_sbi(struct fs_context *fc)if (ctx->dyn_root) { as->dyn_root = true; }else { - as->cell =afs_get_cell (ctx->cell); + as->cell =afs_use_cell (ctx->cell); as->volume =afs_get_volume (ctx->volume, afs_volume_trace_get_alloc_sbi); }
@@ -521,7 +521,7 @@ static void afs_destroy_sbi(struct afs_super_info *as)if (as) {struct afs_net *net =afs_net (as->net_ns);afs_put_volume (net, as->volume, afs_volume_trace_put_destroy_sbi); -afs_put_cell (net, as->cell); +afs_unuse_cell (net, as->cell);put_net (as->net_ns);kfree (as); }
@@ -607,7 +607,7 @@ static void afs_free_fc(struct fs_context *fc)afs_destroy_sbi (fc->s_fs_info);afs_put_volume (ctx->net, ctx->volume, afs_volume_trace_put_free_fc); -afs_put_cell (ctx->net, ctx->cell); +afs_unuse_cell (ctx->net, ctx->cell);key_put (ctx->key);kfree (ctx); }
fs/afs/vl_alias.c +4 -4
@@ -177,7 +177,7 @@ static int afs_compare_cell_roots(struct afs_cell *cell) is_alias:rcu_read_unlock (); - cell->alias_of =afs_get_cell (p); + cell->alias_of =afs_use_cell (p);return 1 ; }
@@ -247,18 +247,18 @@ static int afs_query_for_alias(struct afs_cell *cell, struct key *key)continue ;if (p->root_volume)continue ;/* Ignore cells that have a root.cell volume. */ -afs_get_cell (p); +afs_use_cell (p);mutex_unlock (&cell->net->proc_cells_lock);if (afs_query_for_alias_one (cell, key, p) !=0 ) goto is_alias;if (mutex_lock_interruptible (&cell->net->proc_cells_lock) <0 ) { -afs_put_cell (cell->net, p); +afs_unuse_cell (cell->net, p);return -ERESTARTSYS ; } -afs_put_cell (cell->net, p); +afs_unuse_cell (cell->net, p); }mutex_unlock (&cell->net->proc_cells_lock);
fs/afs/vl_rotate.c +1 -1
@@ -45,7 +45,7 @@ static bool afs_start_vl_iteration(struct afs_vl_cursor *vc) cell->dns_expiry <= ktime_get_real_seconds()) { dns_lookup_count =smp_load_acquire (&cell->dns_lookup_count);set_bit (AFS_CELL_FL_DO_LOOKUP , &cell->flags); -queue_work (afs_wq, &cell->manager); +afs_queue_cell (cell);if (cell->dns_source ==DNS_RECORD_UNAVAILABLE ) { if (wait_var_event_interruptible(
fs/afs/volume.c +2 -2
@@ -106,7 +106,7 @@ static struct afs_volume *afs_alloc_volume(struct afs_fs_context *params,return volume; error_1: -afs_put_cell (params->net, volume->cell); +afs_put_cell (volume->cell);kfree (volume); error_0:return ERR_PTR (ret);
@@ -228,7 +228,7 @@ static void afs_destroy_volume(struct afs_net *net, struct afs_volume *volume)afs_remove_volume_from_cell (volume);afs_put_serverlist (net,rcu_access_pointer (volume->servers)); -afs_put_cell (net, volume->cell); +afs_put_cell (volume->cell);trace_afs_volume (volume->vid,atomic_read (&volume->usage), afs_volume_trace_free);kfree_rcu (volume, rcu);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 504/757 afs: Fix cell purging with aliases
In reply to Greg Kroah-HartmanFrom: David Howells <[email protected]>
[ Upstream commit 286377f6bdf71568a4cf07104fe44006ae0dba6d ]
When the afs module is removed, one of the things that has to be done is to purge the cell database. afs_cell_purge() cancels the management timer and then starts the cell manager work item to do the purging. This does a single run through and then assumes that all cells are now purged - but this is no longer the case.
With the introduction of alias detection, a later cell in the database can now be holding an active count on an earlier cell (cell->alias_of). The purge scan passes by the earlier cell first, but this can't be got rid of until it has discarded the alias. Ordinarily, afs_unuse_cell() would handle this by setting the management timer to trigger another pass - but afs_set_cell_timer() doesn't do anything if the namespace is being removed (net->live == false). rmmod then hangs in the wait on cells_outstanding in afs_cell_purge().
Fix this by making afs_set_cell_timer() directly queue the cell manager if net->live is false. This causes additional management passes.
Queueing the cell manager increments cells_outstanding to make sure the wait won't complete until all cells are destroyed.
--- fs/afs/cell.c | 3 +++ 1 file changed, 3 insertions(+)
fs/afs/cell.c +3 -0
@@ -19,6 +19,7 @@ static unsigned __read_mostly afs_cell_gc_delay = 10;static unsigned __read_mostly afs_cell_min_ttl =10 *60 ;static unsigned __read_mostly afs_cell_max_ttl =24 *60 *60 ; +static void afs_queue_cell_manager (struct afs_net *);static void afs_manage_cell_work (struct work_struct *);static void afs_dec_cells_outstanding (struct afs_net *net)
@@ -37,6 +38,8 @@ static void afs_set_cell_timer(struct afs_net *net, time64_t delay)atomic_inc (&net->cells_outstanding);if (timer_reduce (&net->cells_timer, jiffies + delay *HZ ))afs_dec_cells_outstanding (net); + }else { +afs_queue_cell_manager (net); } }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 505/757 afs: Fix cell removal
In reply to Greg Kroah-HartmanFrom: David Howells <[email protected]>
[ Upstream commit 1d0e850a49a5b56f8f3cb51e74a11e2fedb96be6 ]
Fix cell removal by inserting a more final state than AFS_CELL_FAILED that indicates that the cell has been unpublished in case the manager is already requeued and will go through again. The new AFS_CELL_REMOVED state will just immediately leave the manager function.
Going through a second time in the AFS_CELL_FAILED state will cause it to try to remove the cell again, potentially leading to the proc list being removed.
--- fs/afs/cell.c | 16 ++++++++++------ fs/afs/internal.h | 1 + 2 files changed, 11 insertions(+), 6 deletions(-)
fs/afs/cell.c +10 -6
@@ -291,11 +291,11 @@ struct afs_cell *afs_lookup_cell(struct afs_net *net,wait_var_event (&cell->state, ({ state =smp_load_acquire (&cell->state);/* vs error */ - state ==AFS_CELL_ACTIVE || state ==AFS_CELL_FAILED ; + state ==AFS_CELL_ACTIVE || state ==AFS_CELL_REMOVED ; }));/* Check the state obtained from the wait check. */ -if (state ==AFS_CELL_FAILED ) { +if (state ==AFS_CELL_REMOVED ) { ret = cell->error; goto error; }
@@ -700,7 +700,6 @@ static void afs_deactivate_cell(struct afs_net *net, struct afs_cell *cell)static void afs_manage_cell (struct afs_cell *cell) {struct afs_net *net = cell->net; -bool deleted;int ret, active;_enter ("%s" , cell->name);
@@ -712,13 +711,15 @@ static void afs_manage_cell(struct afs_cell *cell)case AFS_CELL_FAILED :down_write (&net->cells_lock); active =1 ; - deleted =atomic_try_cmpxchg_relaxed (&cell->active, &active,0 ); -if (deleted) { +if (atomic_try_cmpxchg_relaxed (&cell->active, &active,0 )) {rb_erase (&cell->net_node, &net->cells); +smp_store_release (&cell->state,AFS_CELL_REMOVED ); }up_write (&net->cells_lock); -if (deleted) +if (cell->state ==AFS_CELL_REMOVED ) { +wake_up_var (&cell->state); goto final_destruction; + }if (cell->state ==AFS_CELL_FAILED ) goto done;smp_store_release (&cell->state,AFS_CELL_UNSET );
@@ -760,6 +761,9 @@ static void afs_manage_cell(struct afs_cell *cell)wake_up_var (&cell->state); goto again; +case AFS_CELL_REMOVED : + goto done; +default :break ; }
fs/afs/internal.h +1 -0
@@ -326,6 +326,7 @@ enum afs_cell_state {AFS_CELL_DEACTIVATING ,AFS_CELL_INACTIVE ,AFS_CELL_FAILED , + AFS_CELL_REMOVED, };/*
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 506/757 RDMA/rxe: Handle skb_clone() failure in rxe_recv.c
In reply to Greg Kroah-HartmanFrom: Bob Pearson <[email protected]>
[ Upstream commit 71abf20b28ff87fee6951ec2218d5ce7969c4e87 ]
If skb_clone() is unable to allocate memory for a new sk_buff this is not detected by the current code.
Check for a NULL return and continue. This is similar to other errors in this loop over QPs attached to the multicast address and consistent with the unreliable UD transport.
Addresses-Coverity-ID: 1497804: Null pointer dereferences (NULL_RETURNS)
--- drivers/infiniband/sw/rxe/rxe_recv.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/infiniband/sw/rxe/rxe_recv.c +3 -0
@@ -298,6 +298,9 @@ static void rxe_rcv_mcast_pkt(struct rxe_dev *rxe, struct sk_buff *skb)else per_qp_skb = skb; +if (unlikely (!per_qp_skb)) +continue ; + per_qp_pkt =SKB_TO_PKT (per_qp_skb); per_qp_pkt->qp = qp;rxe_add_ref (qp);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 507/757 mm/page_owner: change split_page_owner to take a count
In reply to Greg Kroah-HartmanFrom: Matthew Wilcox (Oracle) <[email protected]>
[ Upstream commit 8fb156c9ee2db94f7127c930c89917634a1a9f56 ]
The implementation of split_page_owner() prefers a count rather than the old order of the page. When we support a variable size THP, we won't have the order at this point, but we will have the number of pages. So change the interface to what the caller and callee would prefer.
--- include/linux/page_owner.h | 6 +++--- mm/huge_memory.c | 2 +- mm/page_alloc.c | 2 +- mm/page_owner.c | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-)
include/linux/page_owner.h +3 -3
@@ -11,7 +11,7 @@ extern struct page_ext_operations page_owner_ops;extern void __reset_page_owner (struct page *page,unsigned int order);extern void __set_page_owner (struct page *page,unsigned int order,gfp_t gfp_mask); -extern void __split_page_owner (struct page *page,unsigned int order); +extern void __split_page_owner (struct page *page,unsigned int nr);extern void __copy_page_owner (struct page *oldpage,struct page *newpage);extern void __set_page_owner_migrate_reason (struct page *page,int reason);extern void __dump_page_owner (struct page *page);
@@ -31,10 +31,10 @@ static inline void set_page_owner(struct page *page,__set_page_owner (page, order, gfp_mask); } -static inline void split_page_owner (struct page *page,unsigned int order) +static inline void split_page_owner (struct page *page,unsigned int nr) {if (static_branch_unlikely (&page_owner_inited)) -__split_page_owner (page, order); +__split_page_owner (page, nr); }static inline void copy_page_owner (struct page *oldpage,struct page *newpage) {
mm/huge_memory.c +1 -1
@@ -2451,7 +2451,7 @@ static void __split_huge_page(struct page *page, struct list_head *list,ClearPageCompound (head); -split_page_owner (head,HPAGE_PMD_ORDER ); +split_page_owner (head,HPAGE_PMD_NR );/* See comment in __split_huge_page_tail() */ if (PageAnon (head)) {
mm/page_alloc.c +1 -1
@@ -3209,7 +3209,7 @@ void split_page(struct page *page, unsigned int order)for (i =1 ; i < (1 << order); i++)set_page_refcounted (page + i); -split_page_owner (page, order); +split_page_owner (page,1 << order); }EXPORT_SYMBOL_GPL (split_page);
mm/page_owner.c +2 -2
@@ -204,7 +204,7 @@ void __set_page_owner_migrate_reason(struct page *page, int reason) page_owner->last_migrate_reason = reason; } -void __split_page_owner (struct page *page,unsigned int order) +void __split_page_owner (struct page *page,unsigned int nr) {int i;struct page_ext *page_ext =lookup_page_ext (page);
@@ -213,7 +213,7 @@ void __split_page_owner(struct page *page, unsigned int order)if (unlikely (!page_ext))return ; -for (i =0 ; i < (1 << order); i++) { +for (i =0 ; i < nr; i++) { page_owner =get_page_owner (page_ext); page_owner->order =0 ; page_ext =page_ext_next (page_ext);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 508/757 mm/huge_memory: fix split assumption of page size
In reply to Greg Kroah-HartmanFrom: Kirill A. Shutemov <[email protected]>
[ Upstream commit 8cce54756806e5777069c46011c5f54f9feac717 ]
File THPs may now be of arbitrary size, and we can't rely on that size after doing the split so remember the number of pages before we start the split.
--- mm/huge_memory.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
mm/huge_memory.c +8 -7
@@ -2335,13 +2335,13 @@ static void unmap_page(struct page *page)VM_BUG_ON_PAGE (!unmap_success, page); } -static void remap_page (struct page *page) +static void remap_page (struct page *page,unsigned int nr) {int i;if (PageTransHuge (page)) {remove_migration_ptes (page, page, true); }else { -for (i =0 ; i <HPAGE_PMD_NR ; i++) +for (i =0 ; i < nr; i++)remove_migration_ptes (page + i, page + i, true); } }
@@ -2416,6 +2416,7 @@ static void __split_huge_page(struct page *page, struct list_head *list,struct lruvec *lruvec;struct address_space *swap_cache =NULL ;unsigned long offset =0 ; +unsigned int nr =thp_nr_pages (head);int i; lruvec =mem_cgroup_page_lruvec (head, pgdat);
@@ -2431,7 +2432,7 @@ static void __split_huge_page(struct page *page, struct list_head *list,xa_lock (&swap_cache->i_pages); } -for (i =HPAGE_PMD_NR -1 ; i >=1 ; i--) { +for (i = nr -1 ; i >=1 ; i--) {__split_huge_page_tail (head, i, lruvec, list);/* Some pages can be beyond i_size: drop them from page cache */ if (head[i].index >= end) {
@@ -2451,7 +2452,7 @@ static void __split_huge_page(struct page *page, struct list_head *list,ClearPageCompound (head); -split_page_owner (head,HPAGE_PMD_NR ); +split_page_owner (head, nr);/* See comment in __split_huge_page_tail() */ if (PageAnon (head)) {
@@ -2470,9 +2471,9 @@ static void __split_huge_page(struct page *page, struct list_head *list,spin_unlock_irqrestore (&pgdat->lru_lock, flags); -remap_page (head); +remap_page (head, nr); -for (i =0 ; i <HPAGE_PMD_NR ; i++) { +for (i =0 ; i < nr; i++) {struct page *subpage = head + i;if (subpage == page)continue ;
@@ -2725,7 +2726,7 @@ int split_huge_page_to_list(struct page *page, struct list_head *list) fail:if (mapping)xa_unlock (&mapping->i_pages);spin_unlock_irqrestore (&pgdata->lru_lock, flags); -remap_page (head); +remap_page (head,thp_nr_pages (head)); ret = -EBUSY ; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 509/757 mm: fix a race during THP splitting
In reply to Greg Kroah-HartmanFrom: Huang Ying <[email protected]>
[ Upstream commit c4f9c701f9b44299e6adbc58d1a4bb2c40383494 ]
It is reported that the following bug is triggered if the HDD is used as swap device,
[ 5758.157556] BUG: kernel NULL pointer dereference, address: 0000000000000007 [ 5758.165331] #PF: supervisor write access in kernel mode [ 5758.171161] #PF: error_code(0x0002) - not-present page [ 5758.176894] PGD 0 P4D 0 [ 5758.179721] Oops: 0002 [#1] SMP PTI [ 5758.183614] CPU: 10 PID: 316 Comm: kswapd1 Kdump: loaded Tainted: G S --------- --- 5.9.0-0.rc3.1.tst.el8.x86_64 #1 [ 5758.196717] Hardware name: Intel Corporation S2600CP/S2600CP, BIOS SE5C600.86B.02.01.0002.082220131453 08/22/2013 [ 5758.208176] RIP: 0010:split_swap_cluster+0x47/0x60 [ 5758.213522] Code: c1 e3 06 48 c1 eb 0f 48 8d 1c d8 48 89 df e8 d0 20 6a 00 80 63 07 fb 48 85 db 74 16 48 89 df c6 07 00 66 66 66 90 31 c0 5b c3 <80> 24 25 07 00 00 00 fb 31 c0 5b c3 b8 f0 ff ff ff 5b c3 66 0f 1f [ 5758.234478] RSP: 0018:ffffb147442d7af0 EFLAGS: 00010246 [ 5758.240309] RAX: 0000000000000000 RBX: 000000000014b217 RCX: ffffb14779fd9000 [ 5758.248281] RDX: 000000000014b217 RSI: ffff9c52f2ab1400 RDI: 000000000014b217 [ 5758.256246] RBP: ffffe00c51168080 R08: ffffe00c5116fe08 R09: ffff9c52fffd3000 [ 5758.264208] R10: ffffe00c511537c8 R11: ffff9c52fffd3c90 R12: 0000000000000000 [ 5758.272172] R13: ffffe00c51170000 R14: ffffe00c51170000 R15: ffffe00c51168040 [ 5758.280134] FS: 0000000000000000(0000) GS:ffff9c52f2a80000(0000) knlGS:0000000000000000 [ 5758.289163] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 5758.295575] CR2: 0000000000000007 CR3: 0000000022a0e003 CR4: 00000000000606e0 [ 5758.303538] Call Trace: [ 5758.306273] split_huge_page_to_list+0x88b/0x950 [ 5758.311433] deferred_split_scan+0x1ca/0x310 [ 5758.316202] do_shrink_slab+0x12c/0x2a0 [ 5758.320491] shrink_slab+0x20f/0x2c0 [ 5758.324482] shrink_node+0x240/0x6c0 [ 5758.328469] balance_pgdat+0x2d1/0x550 [ 5758.332652] kswapd+0x201/0x3c0 [ 5758.336157] ? finish_wait+0x80/0x80 [ 5758.340147] ? balance_pgdat+0x550/0x550 [ 5758.344525] kthread+0x114/0x130 [ 5758.348126] ? kthread_park+0x80/0x80 [ 5758.352214] ret_from_fork+0x22/0x30 [ 5758.356203] Modules linked in: fuse zram rfkill sunrpc intel_rapl_msr intel_rapl_common sb_edac x86_pkg_temp_thermal intel_powerclamp coretemp mgag200 iTCO_wdt crct10dif_pclmul iTCO_vendor_support drm_kms_helper crc32_pclmul ghash_clmulni_intel syscopyarea sysfillrect sysimgblt fb_sys_fops cec rapl joydev intel_cstate ipmi_si ipmi_devintf drm intel_uncore i2c_i801 ipmi_msghandler pcspkr lpc_ich mei_me i2c_smbus mei ioatdma ip_tables xfs libcrc32c sr_mod sd_mod cdrom t10_pi sg igb ahci libahci i2c_algo_bit crc32c_intel libata dca wmi dm_mirror dm_region_hash dm_log dm_mod [ 5758.412673] CR2: 0000000000000007 [ 0.000000] Linux version 5.9.0-0.rc3.1.tst.el8.x86_64 ([email protected]) (gcc (GCC) 8.3.1 20191121 (Red Hat 8.3.1-5), GNU ld version 2.30-79.el8) #1 SMP Wed Sep 9 16:03:34 EDT 2020
After further digging it's found that the following race condition exists in the original implementation,
CPU1 CPU2
---- ----deferred_split_scan()
split_huge_page(page) /* page isn't compound head */
split_huge_page_to_list(page, NULL)
__split_huge_page(page, )
ClearPageCompound(head)
/* unlock all subpages except page (not head) */
add_to_swap(head) /* not THP */
get_swap_page(head)
add_to_swap_cache(head, )
SetPageSwapCache(head)
if PageSwapCache(head)
split_swap_cluster(/* swap entry of head */)
/* Deref sis->cluster_info: NULL accessing! */So, in split_huge_page_to_list(), PageSwapCache() is called for the already split and unlocked "head", which may be added to swap cache in another CPU. So split_swap_cluster() may be called wrongly.
To fix the race, the call to split_swap_cluster() is moved to __split_huge_page() before all subpages are unlocked. So that the PageSwapCache() is stable.
--- mm/huge_memory.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
mm/huge_memory.c +7 -6
@@ -2473,6 +2473,12 @@ static void __split_huge_page(struct page *page, struct list_head *list,remap_page (head, nr); +if (PageSwapCache (head)) { +swp_entry_t entry = { .val =page_private (head) }; + +split_swap_cluster (entry); + } +for (i =0 ; i < nr; i++) {struct page *subpage = head + i;if (subpage == page)
@@ -2707,12 +2713,7 @@ int split_huge_page_to_list(struct page *page, struct list_head *list) }__split_huge_page (page, list, end, flags); -if (PageSwapCache (head)) { -swp_entry_t entry = { .val =page_private (head) }; - - ret =split_swap_cluster (entry); - }else - ret =0 ; + ret =0 ; }else {if (IS_ENABLED (CONFIG_DEBUG_VM ) && mapcount) { pr_alert("total_mapcount: %u, page_count(): %u\n",
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 510/757 lib/crc32.c: fix trivial typo in preprocessor condition
In reply to Greg Kroah-HartmanFrom: Tobias Jordan <[email protected]>
[ Upstream commit 904542dc56524f921a6bab0639ff6249c01e775f ]
Whether crc32_be needs a lookup table is chosen based on CRC_LE_BITS. Obviously, the _be function should be governed by the _BE_ define.
This probably never pops up as it's hard to come up with a configuration where CRC_BE_BITS isn't the same as CRC_LE_BITS and as nobody is using bitwise CRC anyway.
--- lib/crc32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/crc32.c +1 -1
@@ -331,7 +331,7 @@ static inline u32 __pure crc32_be_generic(u32 crc, unsigned char const *p,return crc; } -#if CRC_LE_BITS ==1 +#if CRC_BE_BITS ==1 u32 __pure crc32_be (u32 crc,unsigned char const *p,size_t len) {return crc32_be_generic (crc, p, len,NULL ,CRC32_POLY_BE );
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 511/757 ramfs: fix nommu mmap with gaps in the page cache
In reply to Greg Kroah-HartmanFrom: Matthew Wilcox (Oracle) <[email protected]>
[ Upstream commit 50b7d85680086126d7bd91dae81d57d4cb1ab6b7 ]
ramfs needs to check that pages are both physically contiguous and contiguous in the file. If the page cache happens to have, eg, page A for index 0 of the file, no page for index 1, and page A+1 for index 2, then an mmap of the first two pages of the file will succeed when it should fail.
--- fs/ramfs/file-nommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ramfs/file-nommu.c +1 -1
@@ -224,7 +224,7 @@ static unsigned long ramfs_nommu_get_unmapped_area(struct file *file,if (!pages) goto out_free; - nr =find_get_pages (inode->i_mapping, &pgoff, lpages, pages); + nr =find_get_pages_contig (inode->i_mapping, pgoff, lpages, pages);if (nr != lpages) goto out_free_pages;/* leave if some pages were missing */
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 512/757 rapidio: fix error handling path
In reply to Greg Kroah-HartmanFrom: Souptick Joarder <[email protected]>
[ Upstream commit fa63f083b3492b5ed5332b8d7c90b03b5ef24a1d ]
rio_dma_transfer() attempts to clamp the return value of pin_user_pages_fast() to be >= 0. However, the attempt fails because nr_pages is overridden a few lines later, and restored to the undesirable -ERRNO value.
The return value is ultimately stored in nr_pages, which in turn is passed to unpin_user_pages(), which expects nr_pages >= 0, else, disaster.
Fix this by fixing the nesting of the assignment to nr_pages: nr_pages should be clamped to zero if pin_user_pages_fast() returns -ERRNO, or set to the return value of pin_user_pages_fast(), otherwise.
[[email protected]: new changelog]
--- drivers/rapidio/devices/rio_mport_cdev.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/rapidio/devices/rio_mport_cdev.c +7 -6
@@ -871,15 +871,16 @@ rio_dma_transfer(struct file *filp, u32 transfer_mode,rmcd_error ("pin_user_pages_fast err=%ld" , pinned); nr_pages =0 ; - }else + }else {rmcd_error ("pinned %ld out of %ld pages" , pinned, nr_pages); +/* +* Set nr_pages up to mean "how many pages to unpin, in +* the error handler: +*/ + nr_pages = pinned; + } ret = -EFAULT ; -/* -* Set nr_pages up to mean "how many pages to unpin, in -* the error handler: -*/ - nr_pages = pinned; goto err_pg; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 513/757 rapidio: fix the missed put_device() for rio_mport_add_riodev
In reply to Greg Kroah-HartmanFrom: Jing Xiangfeng <[email protected]>
[ Upstream commit 85094c05eeb47d195a74a25366a2db066f1c9d47 ]
rio_mport_add_riodev() misses to call put_device() when the device already exists. Add the missed function call to fix it.
--- drivers/rapidio/devices/rio_mport_cdev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/rapidio/devices/rio_mport_cdev.c +4 -1
@@ -1680,6 +1680,7 @@ static int rio_mport_add_riodev(struct mport_cdev_priv *priv,struct rio_dev *rdev;struct rio_switch *rswitch =NULL ;struct rio_mport *mport; +struct device *dev;size_t size;u32 rval;u32 swpinfo =0 ;
@@ -1694,8 +1695,10 @@ static int rio_mport_add_riodev(struct mport_cdev_priv *priv,rmcd_debug (RDEV ,"name:%s ct:0x%x did:0x%x hc:0x%x" , dev_info.name, dev_info.comptag, dev_info.destid, dev_info.hopcount); -if (bus_find_device_by_name (&rio_bus_type,NULL , dev_info.name)) { + dev =bus_find_device_by_name (&rio_bus_type,NULL , dev_info.name); +if (dev) {rmcd_debug (RDEV ,"device %s already exists" , dev_info.name); +put_device (dev);return -EEXIST ; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 514/757 mailbox: avoid timer start from callback
In reply to Greg Kroah-HartmanFrom: Jassi Brar <[email protected]>
[ Upstream commit c7dacf5b0f32957b24ef29df1207dc2cd8307743 ]
If the txdone is done by polling, it is possible for msg_submit() to start the timer while txdone_hrtimer() callback is running. If the timer needs recheduling, it could already be enqueued by the time hrtimer_forward_now() is called, leading hrtimer to loudly complain.
WARNING: CPU: 3 PID: 74 at kernel/time/hrtimer.c:932 hrtimer_forward+0xc4/0x110 CPU: 3 PID: 74 Comm: kworker/u8:1 Not tainted 5.9.0-rc2-00236-gd3520067d01c-dirty #5 Hardware name: Libre Computer AML-S805X-AC (DT) Workqueue: events_freezable_power_ thermal_zone_device_check pstate: 20000085 (nzCv daIf -PAN -UAO BTYPE=--) pc : hrtimer_forward+0xc4/0x110 lr : txdone_hrtimer+0xf8/0x118
[...]
This can be fixed by not starting the timer from the callback path. Which requires the timer reloading as long as any message is queued on the channel, and not just when current tx is not done yet.
--- drivers/mailbox/mailbox.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/mailbox/mailbox.c +7 -5
@@ -82,9 +82,12 @@ static void msg_submit(struct mbox_chan *chan) exit:spin_unlock_irqrestore (&chan->lock, flags); -if (!err && (chan->txdone_method &TXDONE_BY_POLL )) -/* kick start the timer immediately to avoid delays */ -hrtimer_start (&chan->mbox->poll_hrt,0 ,HRTIMER_MODE_REL ); +/* kick start the timer immediately to avoid delays */ +if (!err && (chan->txdone_method &TXDONE_BY_POLL )) { +/* but only if not already active */ +if (!hrtimer_active (&chan->mbox->poll_hrt)) +hrtimer_start (&chan->mbox->poll_hrt,0 ,HRTIMER_MODE_REL ); + } }static void tx_tick (struct mbox_chan *chan,int r)
@@ -122,11 +125,10 @@ static enum hrtimer_restart txdone_hrtimer(struct hrtimer *hrtimer)struct mbox_chan *chan = &mbox->chans[i];if (chan->active_req && chan->cl) { + resched = true; txdone = chan->mbox->ops->last_tx_done (chan);if (txdone)tx_tick (chan,0 ); -else - resched = true; } }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 515/757 clk: meson: axg-audio: separate axg and g12a regmap tables
In reply to Greg Kroah-HartmanFrom: Jerome Brunet <[email protected]>
[ Upstream commit cdabb1ffc7c2349b8930f752df1edcafc1d37cc1 ]
There are more differences than what we initially thought. Let's keeps things clear and separate the axg and g12a regmap tables of the audio clock controller.
--- drivers/clk/meson/axg-audio.c | 135 ++++++++++++++++++++++++++++++++-- 1 file changed, 127 insertions(+), 8 deletions(-)
drivers/clk/meson/axg-audio.c +127 -8
@@ -1209,13 +1209,132 @@ static struct clk_hw_onecell_data sm1_audio_hw_onecell_data = { }; -/* Convenience table to populate regmap in .probe() -* Note that this table is shared between both AXG and G12A, -* with spdifout_b clocks being exclusive to G12A. Since those -* clocks are not declared within the AXG onecell table, we do not -* feel the need to have separate AXG/G12A regmap tables. -*/ +/* Convenience table to populate regmap in .probe(). */ static struct clk_regmap *const axg_clk_regmaps[] = { + &ddr_arb, + &pdm, + &tdmin_a, + &tdmin_b, + &tdmin_c, + &tdmin_lb, + &tdmout_a, + &tdmout_b, + &tdmout_c, + &frddr_a, + &frddr_b, + &frddr_c, + &toddr_a, + &toddr_b, + &toddr_c, + &loopback, + &spdifin, + &spdifout, + &resample, + &power_detect, + &mst_a_mclk_sel, + &mst_b_mclk_sel, + &mst_c_mclk_sel, + &mst_d_mclk_sel, + &mst_e_mclk_sel, + &mst_f_mclk_sel, + &mst_a_mclk_div, + &mst_b_mclk_div, + &mst_c_mclk_div, + &mst_d_mclk_div, + &mst_e_mclk_div, + &mst_f_mclk_div, + &mst_a_mclk, + &mst_b_mclk, + &mst_c_mclk, + &mst_d_mclk, + &mst_e_mclk, + &mst_f_mclk, + &spdifout_clk_sel, + &spdifout_clk_div, + &spdifout_clk, + &spdifin_clk_sel, + &spdifin_clk_div, + &spdifin_clk, + &pdm_dclk_sel, + &pdm_dclk_div, + &pdm_dclk, + &pdm_sysclk_sel, + &pdm_sysclk_div, + &pdm_sysclk, + &mst_a_sclk_pre_en, + &mst_b_sclk_pre_en, + &mst_c_sclk_pre_en, + &mst_d_sclk_pre_en, + &mst_e_sclk_pre_en, + &mst_f_sclk_pre_en, + &mst_a_sclk_div, + &mst_b_sclk_div, + &mst_c_sclk_div, + &mst_d_sclk_div, + &mst_e_sclk_div, + &mst_f_sclk_div, + &mst_a_sclk_post_en, + &mst_b_sclk_post_en, + &mst_c_sclk_post_en, + &mst_d_sclk_post_en, + &mst_e_sclk_post_en, + &mst_f_sclk_post_en, + &mst_a_sclk, + &mst_b_sclk, + &mst_c_sclk, + &mst_d_sclk, + &mst_e_sclk, + &mst_f_sclk, + &mst_a_lrclk_div, + &mst_b_lrclk_div, + &mst_c_lrclk_div, + &mst_d_lrclk_div, + &mst_e_lrclk_div, + &mst_f_lrclk_div, + &mst_a_lrclk, + &mst_b_lrclk, + &mst_c_lrclk, + &mst_d_lrclk, + &mst_e_lrclk, + &mst_f_lrclk, + &tdmin_a_sclk_sel, + &tdmin_b_sclk_sel, + &tdmin_c_sclk_sel, + &tdmin_lb_sclk_sel, + &tdmout_a_sclk_sel, + &tdmout_b_sclk_sel, + &tdmout_c_sclk_sel, + &tdmin_a_sclk_pre_en, + &tdmin_b_sclk_pre_en, + &tdmin_c_sclk_pre_en, + &tdmin_lb_sclk_pre_en, + &tdmout_a_sclk_pre_en, + &tdmout_b_sclk_pre_en, + &tdmout_c_sclk_pre_en, + &tdmin_a_sclk_post_en, + &tdmin_b_sclk_post_en, + &tdmin_c_sclk_post_en, + &tdmin_lb_sclk_post_en, + &tdmout_a_sclk_post_en, + &tdmout_b_sclk_post_en, + &tdmout_c_sclk_post_en, + &tdmin_a_sclk, + &tdmin_b_sclk, + &tdmin_c_sclk, + &tdmin_lb_sclk, + &tdmout_a_sclk, + &tdmout_b_sclk, + &tdmout_c_sclk, + &tdmin_a_lrclk, + &tdmin_b_lrclk, + &tdmin_c_lrclk, + &tdmin_lb_lrclk, + &tdmout_a_lrclk, + &tdmout_b_lrclk, + &tdmout_c_lrclk, +}; + +static struct clk_regmap *const g12a_clk_regmaps[] = { &ddr_arb, &pdm, &tdmin_a,
@@ -1713,8 +1832,8 @@ static const struct audioclk_data axg_audioclk_data = { };static const struct audioclk_data g12a_audioclk_data = { - .regmap_clks = axg_clk_regmaps, - .regmap_clk_num =ARRAY_SIZE (axg_clk_regmaps), + .regmap_clks = g12a_clk_regmaps, + .regmap_clk_num =ARRAY_SIZE (g12a_clk_regmaps), .hw_onecell_data = &g12a_audio_hw_onecell_data, .reset_offset =AUDIO_SW_RESET , .reset_num =26 ,
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 516/757 rtc: ds1307: Clear OSF flag on DS1388 when setting time
In reply to Greg Kroah-HartmanFrom: Chris Packham <[email protected]>
[ Upstream commit f471b05f76e4b1b6ba07ebc7681920a5c5b97c5d ]
Ensure the OSF flag is cleared on the DS1388 when the clock is set.
--- drivers/rtc/rtc-ds1307.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/rtc/rtc-ds1307.c +4 -0
@@ -352,6 +352,10 @@ static int ds1307_set_time(struct device *dev, struct rtc_time *t)regmap_update_bits (ds1307->regmap,DS1340_REG_FLAG ,DS1340_BIT_OSF ,0 );break ; +case ds_1388: +regmap_update_bits (ds1307->regmap,DS1388_REG_FLAG , +DS1388_BIT_OSF ,0 ); +break ;case mcp794xx:/* * these bits were cleared when preparing the date/time
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 517/757 i2c: rcar: Auto select RESET_CONTROLLER
In reply to Greg Kroah-HartmanFrom: Dirk Behme <[email protected]>
[ Upstream commit 5b9bacf28a973a6b16510493416baeefa2c06289 ]
The i2c-rcar driver utilizes the Generic Reset Controller kernel feature, so select the RESET_CONTROLLER option when the I2C_RCAR option is selected with a Gen3 SoC.
--- drivers/i2c/busses/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/i2c/busses/Kconfig +1 -0
@@ -1181,6 +1181,7 @@ config I2C_RCAR tristate "Renesas R-Car I2C Controller" depends on ARCH_RENESAS || COMPILE_TEST select I2C_SLAVE + select RESET_CONTROLLER if ARCH_RCAR_GEN3 help If you say yes to this option, support will be included for the R-Car I2C controller.
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 518/757 clk: meson: g12a: mark fclk_div2 as critical
In reply to Greg Kroah-HartmanFrom: Stefan Agner <[email protected]>
[ Upstream commit 2c4e80e06790cb49ad2603855d30c5aac2209c47 ]
On Amlogic Meson G12b platform, similar to fclk_div3, the fclk_div2 seems to be necessary for the system to operate correctly as well.
Typically, the clock also gets chosen by the eMMC peripheral. This probably masked the problem so far. However, when booting from a SD card the clock seems to get disabled which leads to a system freeze.
Let's mark this clock as critical, fixing boot from SD card on G12b platforms.
--- drivers/clk/meson/g12a.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/clk/meson/g12a.c +11 -0
@@ -298,6 +298,17 @@ static struct clk_regmap g12a_fclk_div2 = { &g12a_fclk_div2_div.hw }, .num_parents = 1, +/* +* Similar to fclk_div3, it seems that this clock is used by +* the resident firmware and is required by the platform to +* operate correctly. +* Until the following condition are met, we need this clock to +* be marked as critical: +* a) Mark the clock used by a firmware resource, if possible +* b) CCF has a clock hand-off mechanism to make the sure the +* clock stays on until the proper driver comes along +*/ + .flags = CLK_IS_CRITICAL, }, };
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 519/757 PCI: designware-ep: Fix the Header Type check
In reply to Greg Kroah-HartmanFrom: Hou Zhiqiang <[email protected]>
[ Upstream commit 16270a92355722e387e9ca19627c5a4d7bae1354 ]
The current check will result in the multiple function device fails to initialize. So fix the check by masking out the multiple function bit.
--- drivers/pci/controller/dwc/pcie-designware-ep.c | 3 ++- include/uapi/linux/pci_regs.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/pci/controller/dwc/pcie-designware-ep.c +2 -1
@@ -505,7 +505,8 @@ int dw_pcie_ep_init_complete(struct dw_pcie_ep *ep)u32 reg;int i; - hdr_type =dw_pcie_readb_dbi (pci,PCI_HEADER_TYPE ); + hdr_type =dw_pcie_readb_dbi (pci,PCI_HEADER_TYPE ) & +PCI_HEADER_TYPE_MASK ;if (hdr_type !=PCI_HEADER_TYPE_NORMAL ) { dev_err(pci->dev, "PCIe controller is not set to EP mode (hdr_type:0x%x)!\n",
include/uapi/linux/pci_regs.h +1 -0
@@ -76,6 +76,7 @@#define PCI_CACHE_LINE_SIZE 0x0c/* 8 bits */ #define PCI_LATENCY_TIMER 0x0d/* 8 bits */ #define PCI_HEADER_TYPE 0x0e/* 8 bits */ +#define PCI_HEADER_TYPE_MASK 0x7f#define PCI_HEADER_TYPE_NORMAL 0#define PCI_HEADER_TYPE_BRIDGE 1#define PCI_HEADER_TYPE_CARDBUS 2
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 520/757 PCI: aardvark: Fix compilation on s390
In reply to Greg Kroah-HartmanFrom: Pali Rohár <[email protected]>
[ Upstream commit b32c012e4b98f0126aa327be2d1f409963057643 ]
Include linux/gpio/consumer.h instead of linux/gpio.h, as is said in the latter file.
This was reported by kernel test bot when compiling for s390.
drivers/pci/controller/pci-aardvark.c:350:2: error: implicit declaration of function 'gpiod_set_value_cansleep' [-Werror,-Wimplicit-function-declaration] drivers/pci/controller/pci-aardvark.c:1074:21: error: implicit declaration of function 'devm_gpiod_get_from_of_node' [-Werror,-Wimplicit-function-declaration] drivers/pci/controller/pci-aardvark.c:1076:14: error: use of undeclared identifier 'GPIOD_OUT_LOW'
--- drivers/pci/controller/pci-aardvark.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/pci-aardvark.c +1 -1
@@ -9,7 +9,7 @@*/ #include <linux/delay.h> -#include <linux/gpio.h> +#include <linux/gpio/consumer.h> #include <linux/interrupt.h> #include <linux/irq.h> #include <linux/irqdomain.h>
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 521/757 PCI: aardvark: Check for errors from pci_bridge_emul_init() call
In reply to Greg Kroah-HartmanFrom: Pali Rohár <[email protected]>
[ Upstream commit 7862a6134456c8b4f8c39e8c94aa97e5c2f7f2b7 ]
Function pci_bridge_emul_init() may fail so correctly check for errors.
--- drivers/pci/controller/pci-aardvark.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/pci/controller/pci-aardvark.c +7 -4
@@ -607,7 +607,7 @@ static struct pci_bridge_emul_ops advk_pci_bridge_emul_ops = {* Initialize the configuration space of the PCI-to-PCI bridge * associated with the given PCIe interface. */ -static void advk_sw_pci_bridge_init (struct advk_pcie *pcie) +static int advk_sw_pci_bridge_init (struct advk_pcie *pcie) {struct pci_bridge_emul *bridge = &pcie->bridge;
@@ -633,8 +633,7 @@ static void advk_sw_pci_bridge_init(struct advk_pcie *pcie) bridge->data = pcie; bridge->ops = &advk_pci_bridge_emul_ops; -pci_bridge_emul_init (bridge,0 ); - +return pci_bridge_emul_init (bridge,0 ); } static bool advk_pcie_valid_device(struct advk_pcie *pcie, struct pci_bus *bus,
@@ -1167,7 +1166,11 @@ static int advk_pcie_probe(struct platform_device *pdev)advk_pcie_setup_hw (pcie); -advk_sw_pci_bridge_init (pcie); + ret =advk_sw_pci_bridge_init (pcie); +if (ret) { +dev_err (dev,"Failed to register emulated root PCI bridge\n" ); +return ret; + } ret =advk_pcie_init_irq_domain (pcie);if (ret) {
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 522/757 PCI: iproc: Set affinity mask on MSI interrupts
In reply to Greg Kroah-HartmanFrom: Mark Tomlinson <[email protected]>
[ Upstream commit eb7eacaa5b9e4f665bd08d416c8f88e63d2f123c ]
The core interrupt code expects the irq_set_affinity call to update the effective affinity for the interrupt. This was not being done, so update iproc_msi_irq_set_affinity() to do so.
--- drivers/pci/controller/pcie-iproc-msi.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/pci/controller/pcie-iproc-msi.c +9 -4
@@ -209,15 +209,20 @@ static int iproc_msi_irq_set_affinity(struct irq_data *data,struct iproc_msi *msi =irq_data_get_irq_chip_data (data);int target_cpu =cpumask_first (mask);int curr_cpu; +int ret; curr_cpu =hwirq_to_cpu (msi, data->hwirq);if (curr_cpu == target_cpu) -return IRQ_SET_MASK_OK_DONE ; + ret =IRQ_SET_MASK_OK_DONE ; +else { +/* steer MSI to the target CPU */ + data->hwirq =hwirq_to_canonical_hwirq (msi, data->hwirq) + target_cpu; + ret =IRQ_SET_MASK_OK ; + } -/* steer MSI to the target CPU */ - data->hwirq =hwirq_to_canonical_hwirq (msi, data->hwirq) + target_cpu; +irq_data_update_effective_affinity (data,cpumask_of (target_cpu)); -return IRQ_SET_MASK_OK ; +return ret; } static void iproc_msi_irq_compose_msi_msg(struct irq_data *data,
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 523/757 rpmsg: smd: Fix a kobj leak in in qcom_smd_parse_edge()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit e69ee0cf655e8e0c4a80f4319e36019b74f17639 ]
We need to call of_node_put(node) on the error paths for this function.
--- drivers/rpmsg/qcom_smd.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-)
drivers/rpmsg/qcom_smd.c +22 -10
@@ -1338,7 +1338,7 @@ static int qcom_smd_parse_edge(struct device *dev, ret =of_property_read_u32 (node, key, &edge->edge_id);if (ret) {dev_err (dev,"edge missing %s property\n" , key); -return -EINVAL ; + goto put_node; } edge->remote_pid =QCOM_SMEM_HOST_ANY ;
@@ -1349,32 +1349,37 @@ static int qcom_smd_parse_edge(struct device *dev, edge->mbox_client.knows_txdone = true; edge->mbox_chan =mbox_request_channel (&edge->mbox_client,0 );if (IS_ERR (edge->mbox_chan)) { -if (PTR_ERR (edge->mbox_chan) != -ENODEV ) -return PTR_ERR (edge->mbox_chan); +if (PTR_ERR (edge->mbox_chan) != -ENODEV ) { + ret =PTR_ERR (edge->mbox_chan); + goto put_node; + } edge->mbox_chan =NULL ; syscon_np =of_parse_phandle (node,"qcom,ipc" ,0 );if (!syscon_np) {dev_err (dev,"no qcom,ipc node\n" ); -return -ENODEV ; + ret = -ENODEV ; + goto put_node; } edge->ipc_regmap =syscon_node_to_regmap (syscon_np); -if (IS_ERR (edge->ipc_regmap)) -return PTR_ERR (edge->ipc_regmap); +if (IS_ERR (edge->ipc_regmap)) { + ret =PTR_ERR (edge->ipc_regmap); + goto put_node; + } key ="qcom,ipc" ; ret =of_property_read_u32_index (node, key,1 , &edge->ipc_offset);if (ret <0 ) {dev_err (dev,"no offset in %s\n" , key); -return -EINVAL ; + goto put_node; } ret =of_property_read_u32_index (node, key,2 , &edge->ipc_bit);if (ret <0 ) {dev_err (dev,"no bit in %s\n" , key); -return -EINVAL ; + goto put_node; } }
@@ -1385,7 +1390,8 @@ static int qcom_smd_parse_edge(struct device *dev, irq =irq_of_parse_and_map (node,0 );if (irq <0 ) {dev_err (dev,"required smd interrupt missing\n" ); -return -EINVAL ; + ret = irq; + goto put_node; } ret = devm_request_irq(dev, irq,
@@ -1393,12 +1399,18 @@ static int qcom_smd_parse_edge(struct device *dev, node->name, edge);if (ret) {dev_err (dev,"failed to request smd irq\n" ); -return ret; + goto put_node; } edge->irq = irq;return 0 ; + +put_node: +of_node_put (node); + edge->of_node =NULL ; + +return ret; }/*
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 524/757 rpmsg: Avoid double-free in mtk_rpmsg_register_device
In reply to Greg Kroah-HartmanFrom: Nicolas Boichat <[email protected]>
[ Upstream commit 231331b2dbd71487159a0400d9ffd967eb0d0e08 ]
If rpmsg_register_device fails, it will call mtk_rpmsg_release_device which already frees mdev.
--- drivers/rpmsg/mtk_rpmsg.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/rpmsg/mtk_rpmsg.c +1 -8
@@ -200,7 +200,6 @@ static int mtk_rpmsg_register_device(struct mtk_rpmsg_rproc_subdev *mtk_subdev,struct rpmsg_device *rpdev;struct mtk_rpmsg_device *mdev;struct platform_device *pdev = mtk_subdev->pdev; -int ret; mdev =kzalloc (sizeof (*mdev),GFP_KERNEL );if (!mdev)
@@ -219,13 +218,7 @@ static int mtk_rpmsg_register_device(struct mtk_rpmsg_rproc_subdev *mtk_subdev, rpdev->dev.parent = &pdev->dev; rpdev->dev.release = mtk_rpmsg_release_device; - ret =rpmsg_register_device (rpdev); -if (ret) { -kfree (mdev); -return ret; - } - -return 0 ; +return rpmsg_register_device (rpdev); }static void mtk_register_device_work_function (struct work_struct *register_work)
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 525/757 remoteproc: stm32: Fix pointer assignement
In reply to Greg Kroah-HartmanFrom: Mathieu Poirier <[email protected]>
[ Upstream commit cb2d8d5b196c2e96e29343383c8c8d8db68b934e ]
Fix the assignment of the @state pointer - it is obviously wrong.
--- drivers/remoteproc/stm32_rproc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/stm32_rproc.c +1 -1
@@ -685,7 +685,7 @@ static int stm32_rproc_get_m4_status(struct stm32_rproc *ddata,* We couldn't get the coprocessor's state, assume * it is not running. */ - state =M4_STATE_OFF ; + *state =M4_STATE_OFF ;return 0 ; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 526/757 PCI/IOV: Mark VFs as not implementing PCI_COMMAND_MEMORY
In reply to Greg Kroah-HartmanFrom: Matthew Rosato <[email protected]>
[ Upstream commit 12856e7acde4702b7c3238c15fcba86ff6aa507f ]
For VFs, the Memory Space Enable bit in the Command Register is hard-wired to 0.
Add a new bit to signify devices where the Command Register Memory Space Enable bit does not control the device's response to MMIO accesses.
--- drivers/pci/iov.c | 1 + include/linux/pci.h | 1 + 2 files changed, 2 insertions(+)
drivers/pci/iov.c +1 -0
@@ -180,6 +180,7 @@ int pci_iov_add_virtfn(struct pci_dev *dev, int id) virtfn->device = iov->vf_device; virtfn->is_virtfn =1 ; virtfn->physfn =pci_dev_get (dev); + virtfn->no_command_memory =1 ;if (id ==0 )pci_read_vf_config_common (virtfn);
include/linux/pci.h +1 -0
@@ -445,6 +445,7 @@ struct pci_dev { unsigned int is_probed:1; /* Device probing in progress */ unsigned int link_active_reporting:1;/* Device capable of reporting link active */ unsigned int no_vf_scan:1; /* Don't scan for VFs after IOV enablement */ + unsigned int no_command_memory:1; /* No PCI_COMMAND_MEMORY */pci_dev_flags_t dev_flags;atomic_t enable_cnt;/* pci_enable_device has been called */
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 527/757 vfio: add a singleton check for vfio_group_pin_pages
In reply to Greg Kroah-HartmanFrom: Yan Zhao <[email protected]>
[ Upstream commit 7ef32e52368f62a4e041a4f0abefb4fb64e7fd4a ]
Page pinning is used both to translate and pin device mappings for DMA purpose, as well as to indicate to the IOMMU backend to limit the dirty page scope to those pages that have been pinned, in the case of an IOMMU backed device.
To support this, the vfio_pin_pages() interface limits itself to only singleton groups such that the IOMMU backend can consider dirty page scope only at the group level. Implement the same requirement for the vfio_group_pin_pages() interface.
--- drivers/vfio/vfio.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/vfio/vfio.c +3 -0
@@ -2051,6 +2051,9 @@ int vfio_group_pin_pages(struct vfio_group *group,if (!group || !user_iova_pfn || !phys_pfn || !npage)return -EINVAL ; +if (group->dev_counter >1 ) +return -EINVAL ; +if (npage >VFIO_PIN_PAGES_MAX_ENTRIES )return -E2BIG ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 528/757 s390/pci: Mark all VFs as not implementing PCI_COMMAND_MEMORY
In reply to Greg Kroah-HartmanFrom: Matthew Rosato <[email protected]>
[ Upstream commit 08b6e22b850c28b6032da1e4d767a33116e23dfb ]
For s390 we can have VFs that are passed-through without the associated PF. Firmware provides an emulation layer to allow these devices to operate independently, but is missing emulation of the Memory Space Enable bit. For these as well as linked VFs, set no_command_memory which specifies these devices do not implement PCI_COMMAND_MEMORY.
--- arch/s390/pci/pci_bus.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/s390/pci/pci_bus.c +3 -2
@@ -197,9 +197,10 @@ void pcibios_bus_add_device(struct pci_dev *pdev)* With pdev->no_vf_scan the common PCI probing code does not * perform PF/VF linking. */ -if (zdev->vfn) +if (zdev->vfn) {zpci_bus_setup_virtfn (zdev->zbus, pdev, zdev->vfn); - + pdev->no_command_memory =1 ; + } }static int zpci_bus_add_device (struct zpci_bus *zbus,struct zpci_dev *zdev)
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 529/757 vfio/pci: Decouple PCI_COMMAND_MEMORY bit checks from is_virtfn
In reply to Greg Kroah-HartmanFrom: Matthew Rosato <[email protected]>
[ Upstream commit 515ecd5368f1510152fa4f9b9ce55b66ac56c334 ]
While it is true that devices with is_virtfn=1 will have a Memory Space Enable bit that is hard-wired to 0, this is not the only case where we see this behavior -- For example some bare-metal hypervisors lack Memory Space Enable bit emulation for devices not setting is_virtfn (s390). Fix this by instead checking for the newly-added no_command_memory bit which directly denotes the need for PCI_COMMAND_MEMORY emulation in vfio.
--- drivers/vfio/pci/vfio_pci_config.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-)
drivers/vfio/pci/vfio_pci_config.c +14 -10
@@ -406,7 +406,7 @@ bool __vfio_pci_memory_enabled(struct vfio_pci_device *vdev)* PF SR-IOV capability, there's therefore no need to trigger * faults based on the virtual value. */ -return pdev->is_virtfn || (cmd &PCI_COMMAND_MEMORY ); +return pdev->no_command_memory || (cmd &PCI_COMMAND_MEMORY ); }/*
@@ -520,8 +520,8 @@ static int vfio_basic_config_read(struct vfio_pci_device *vdev, int pos, count =vfio_default_config_read (vdev, pos, count, perm, offset, val); -/* Mask in virtual memory enable for SR-IOV devices */ -if (offset ==PCI_COMMAND && vdev->pdev->is_virtfn) { +/* Mask in virtual memory enable */ +if (offset ==PCI_COMMAND && vdev->pdev->no_command_memory) {u16 cmd =le16_to_cpu (*(__le16 *)&vdev->vconfig[PCI_COMMAND ]);u32 tmp_val =le32_to_cpu (*val);
@@ -589,9 +589,11 @@ static int vfio_basic_config_write(struct vfio_pci_device *vdev, int pos,* shows it disabled (phys_mem/io, then the device has * undergone some kind of backdoor reset and needs to be * restored before we allow it to enable the bars. -* SR-IOV devices will trigger this, but we catch them later +* SR-IOV devices will trigger this - for mem enable let's +* catch this now and for io enable it will be caught later */ -if ((new_mem && virt_mem && !phys_mem) || +if ((new_mem && virt_mem && !phys_mem && + !pdev->no_command_memory) || (new_io && virt_io && !phys_io) ||vfio_need_bar_restore (vdev))vfio_bar_restore (vdev);
@@ -1734,12 +1736,14 @@ int vfio_config_init(struct vfio_pci_device *vdev) vconfig[PCI_INTERRUPT_PIN]); vconfig[PCI_INTERRUPT_PIN ] =0 ;/* Gratuitous for good VFs */ - + } +if (pdev->no_command_memory) {/* -* VFs do no implement the memory enable bit of the COMMAND -* register therefore we'll not have it set in our initial -* copy of config space after pci_enable_device(). For -* consistency with PFs, set the virtual enable bit here. +* VFs and devices that set pdev->no_command_memory do not +* implement the memory enable bit of the COMMAND register +* therefore we'll not have it set in our initial copy of +* config space after pci_enable_device(). For consistency +* with PFs, set the virtual enable bit here. */ *(__le16 *)&vconfig[PCI_COMMAND ] |=cpu_to_le16 (PCI_COMMAND_MEMORY );
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 530/757 vfio: fix a missed vfio group put in vfio_pin_pages
In reply to Greg Kroah-HartmanFrom: Yan Zhao <[email protected]>
[ Upstream commit 28b130244061863cf0437b7af1625fb45ec1a71e ]
When error occurs, need to put vfio group after a successful get.
--- drivers/vfio/vfio.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/vfio/vfio.c +4 -2
@@ -1949,8 +1949,10 @@ int vfio_pin_pages(struct device *dev, unsigned long *user_pfn, int npage,if (!group)return -ENODEV ; -if (group->dev_counter >1 ) -return -EINVAL ; +if (group->dev_counter >1 ) { + ret = -EINVAL ; + goto err_pin_pages; + } ret =vfio_group_add_container_user (group);if (ret)
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 531/757 vfio/type1: fix dirty bitmap calculation in vfio_dma_rw
In reply to Greg Kroah-HartmanFrom: Yan Zhao <[email protected]>
[ Upstream commit 2c5af98592f65517170c7bcc714566590d3f7397 ]
The count of dirtied pages is not only determined by count of copied pages, but also by the start offset.
e.g. if offset = PAGE_SIZE - 1, and *copied=2, the dirty pages count is 2, instead of 1 or 0.
--- drivers/vfio/vfio_iommu_type1.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/vfio/vfio_iommu_type1.c +2 -1
@@ -2933,7 +2933,8 @@ static int vfio_iommu_type1_dma_rw_chunk(struct vfio_iommu *iommu,* size */ bitmap_set (dma->bitmap, offset >> pgshift, - *copied >> pgshift); + ((offset + *copied -1 ) >> pgshift) - + (offset >> pgshift) +1 ); } }else *copied = copy_from_user(data, (void __user *)vaddr,
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 532/757 clk: qcom: gcc-sdm660: Fix wrong parent_map
In reply to Greg Kroah-HartmanFrom: Konrad Dybcio <[email protected]>
[ Upstream commit d46e5a39f9be9288f1ce2170c4c7f8098f4e7f68 ]
This was likely overlooked while porting the driver upstream.
--- drivers/clk/qcom/gcc-sdm660.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/qcom/gcc-sdm660.c +1 -1
@@ -666,7 +666,7 @@ static struct clk_rcg2 hmss_rbcpr_clk_src = { .cmd_rcgr = 0x48044, .mnd_width = 0, .hid_width = 5, - .parent_map = gcc_parent_map_xo_gpll0_gpll0_early_div, + .parent_map = gcc_parent_map_xo_gpll0, .freq_tbl = ftbl_hmss_rbcpr_clk_src, .clkr.hw.init = &(struct clk_init_data ){ .name ="hmss_rbcpr_clk_src" ,
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 533/757 clk: keystone: sci-clk: fix parsing assigned-clock data during probe
In reply to Greg Kroah-HartmanFrom: Tero Kristo <[email protected]>
[ Upstream commit 2f05cced7307489faab873367fb20cd212e1d890 ]
The DT clock probe loop incorrectly terminates after processing "clocks" only, fix this by re-starting the loop when all entries for current DT property have been parsed.
--- drivers/clk/keystone/sci-clk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/keystone/sci-clk.c +1 -1
@@ -522,7 +522,7 @@ static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider) np =of_find_node_with_property (np, *clk_name);if (!np) { clk_name++; -break ; +continue ; }if (!of_device_is_available (np))
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 534/757 pwm: rockchip: Keep enabled PWMs running while probing
In reply to Greg Kroah-HartmanFrom: Simon South <[email protected]>
[ Upstream commit 457f74abbed060a0395f75ab5297f2d76cada516 ]
Following commit cfc4c189bc70 ("pwm: Read initial hardware state at request time") the Rockchip PWM driver can no longer assume a device's pwm_state structure has been populated after a call to pwmchip_add(). Consequently, the test in rockchip_pwm_probe() intended to prevent the driver from stopping PWM devices already enabled by the bootloader no longer functions reliably and this can lead to the kernel hanging during startup, particularly on devices like the Pinebook Pro that use a PWM-controlled backlight for their display.
Avoid this by querying the device directly at probe time to determine whether or not it is enabled.
--- drivers/pwm/pwm-rockchip.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/pwm/pwm-rockchip.c +4 -1
@@ -288,6 +288,7 @@ static int rockchip_pwm_probe(struct platform_device *pdev)const struct of_device_id *id;struct rockchip_pwm_chip *pc;struct resource *r; +u32 enable_conf, ctrl;int ret, count; id =of_match_device (rockchip_pwm_dt_ids, &pdev->dev);
@@ -362,7 +363,9 @@ static int rockchip_pwm_probe(struct platform_device *pdev) }/* Keep the PWM clk enabled if the PWM appears to be up and running. */ -if (!pwm_is_enabled (pc->chip.pwms)) + enable_conf = pc->data->enable_conf; + ctrl =readl_relaxed (pc->base + pc->data->regs.ctrl); +if ((ctrl & enable_conf) != enable_conf)clk_disable (pc->clk);return 0 ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 535/757 pwm: img: Fix null pointer access in probe
In reply to Greg Kroah-HartmanFrom: Hauke Mehrtens <[email protected]>
[ Upstream commit b39c0615d0667b3a6f2f5c4bf99ffadf3b518bb1 ]
dev_get_drvdata() is called in img_pwm_runtime_resume() before the driver data is set.
When pm_runtime_enabled() returns false in img_pwm_probe() it calls img_pwm_runtime_resume() which results in a null pointer access.
This patch fixes the problem by setting the driver data earlier in the img_pwm_probe() function.
This crash was seen when booting the Imagination Technologies Creator Ci40 (Marduk) with kernel 5.4 in OpenWrt.
--- drivers/pwm/pwm-img.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pwm/pwm-img.c +2 -1
@@ -277,6 +277,8 @@ static int img_pwm_probe(struct platform_device *pdev)return PTR_ERR (pwm->pwm_clk); } +platform_set_drvdata (pdev, pwm); +pm_runtime_set_autosuspend_delay (&pdev->dev,IMG_PWM_PM_TIMEOUT );pm_runtime_use_autosuspend (&pdev->dev);pm_runtime_enable (&pdev->dev);
@@ -313,7 +315,6 @@ static int img_pwm_probe(struct platform_device *pdev) goto err_suspend; } -platform_set_drvdata (pdev, pwm);return 0 ; err_suspend:
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 536/757 nfsd: Cache R, RW, and W opens separately
In reply to Greg Kroah-HartmanFrom: J. Bruce Fields <[email protected]>
[ Upstream commit ae3c57b5ca47665dc3416447a5534a9796096d86 ]
The nfsd open code has always kept separate read-only, read-write, and write-only opens as necessary to ensure that when a client closes or downgrades, we don't retain more access than necessary.
Also, I didn't realize the cache behaved this way when I wrote 94415b06eb8a "nfsd4: a client's own opens needn't prevent delegations". There I assumed fi_fds[O_WRONLY] and fi_fds[O_RDWR] would always be distinct. The violation of that assumption is triggering a WARN_ON_ONCE() and could also cause the server to give out a delegation when it shouldn't.
--- fs/nfsd/filecache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfsd/filecache.c +1 -1
@@ -889,7 +889,7 @@ nfsd_file_find_locked(struct inode *inode, unsigned int may_flags,hlist_for_each_entry_rcu (nf, &nfsd_file_hashtbl[hashval].nfb_head, nf_node,lockdep_is_held (&nfsd_file_hashtbl[hashval].nfb_lock)) { -if ((need & nf->nf_may) != need) +if (nf->nf_may != need)continue ;if (nf->nf_inode != inode)continue ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 537/757 remoteproc/mediatek: fix null pointer dereference on null scp pointer
In reply to Greg Kroah-HartmanFrom: Colin Ian King <[email protected]>
[ Upstream commit 434ac4d51407ce3764a6ae96a89d90b8ae2826fb ]
Currently when pointer scp is null a dev_err is being called that references the pointer which is the very thing we are trying to avoid doing. Remove the extraneous error message to avoid this issue.
Addresses-Coverity: ("Dereference after null check")
--- drivers/remoteproc/mtk_scp_ipi.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/remoteproc/mtk_scp_ipi.c +1 -3
@@ -30,10 +30,8 @@ int scp_ipi_register(struct mtk_scp *scp, scp_ipi_handler_t handler, void *priv) { -if (!scp) { -dev_err (scp->dev,"scp device is not ready\n" ); +if (!scp)return -EPROBE_DEFER ; - }if (WARN_ON (id >=SCP_IPI_MAX ) ||WARN_ON (handler ==NULL ))return -EINVAL ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 538/757 PCI: hv: Fix hibernation in case interrupts are not re-created
In reply to Greg Kroah-HartmanFrom: Dexuan Cui <[email protected]>
[ Upstream commit 915cff7f38c5e4d47f187f8049245afc2cb3e503 ]
pci_restore_msi_state() directly writes the MSI/MSI-X related registers via MMIO. On a physical machine, this works perfectly; for a Linux VM running on a hypervisor, which typically enables IOMMU interrupt remapping, the hypervisor usually should trap and emulate the MMIO accesses in order to re-create the necessary interrupt remapping table entries in the IOMMU, otherwise the interrupts can not work in the VM after hibernation.
Hyper-V is different from other hypervisors in that it does not trap and emulate the MMIO accesses, and instead it uses a para-virtualized method, which requires the VM to call hv_compose_msi_msg() to notify the hypervisor of the info that would be passed to the hypervisor in the case of the trap-and-emulate method. This is not an issue to a lot of PCI device drivers, which destroy and re-create the interrupts across hibernation, so hv_compose_msi_msg() is called automatically. However, some PCI device drivers (e.g. the in-tree GPU driver nouveau and the out-of-tree Nvidia proprietary GPU driver) do not destroy and re-create MSI/MSI-X interrupts across hibernation, so hv_pci_resume() has to call hv_compose_msi_msg(), otherwise the PCI device drivers can no longer receive interrupts after the VM resumes from hibernation.
Hyper-V is also different in that chip->irq_unmask() may fail in a Linux VM running on Hyper-V (on a physical machine, chip->irq_unmask() can not fail because unmasking an MSI/MSI-X register just means an MMIO write): during hibernation, when a CPU is offlined, the kernel tries to move the interrupt to the remaining CPUs that haven't been offlined yet. In this case, hv_irq_unmask() -> hv_do_hypercall() always fails because the vmbus channel has been closed: here the early "return" in hv_irq_unmask() means the pci_msi_unmask_irq() is not called, i.e. the desc->masked remains "true", so later after hibernation, the MSI interrupt always remains masked, which is incorrect. Refer to cpu_disable_common() -> fixup_irqs() -> irq_migrate_all_off_this_cpu() -> migrate_one_irq():
static bool migrate_one_irq(struct irq_desc *desc) {
...
if (maskchip && chip->irq_mask)
chip->irq_mask(d);
...
err = irq_do_set_affinity(d, affinity, false);
...
if (maskchip && chip->irq_unmask)
chip->irq_unmask(d);Fix the issue by calling pci_msi_unmask_irq() unconditionally in hv_irq_unmask(). Also suppress the error message for hibernation because the hypercall failure during hibernation does not matter (at this time all the devices have been frozen). Note: the correct affinity info is still updated into the irqdata data structure in migrate_one_irq() -> irq_do_set_affinity() -> hv_set_affinity(), so later when the VM resumes, hv_pci_restore_msi_state() is able to correctly restore the interrupt with the correct affinity.
--- drivers/pci/controller/pci-hyperv.c | 50 +++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 3 deletions(-)
drivers/pci/controller/pci-hyperv.c +47 -3
@@ -1276,11 +1276,25 @@ static void hv_irq_unmask(struct irq_data *data) exit_unlock:spin_unlock_irqrestore (&hbus->retarget_msi_interrupt_lock, flags); -if (res) { +/* +* During hibernation, when a CPU is offlined, the kernel tries +* to move the interrupt to the remaining CPUs that haven't +* been offlined yet. In this case, the below hv_do_hypercall() +* always fails since the vmbus channel has been closed: +* refer to cpu_disable_common() -> fixup_irqs() -> +* irq_migrate_all_off_this_cpu() -> migrate_one_irq(). +* +* Suppress the error message for hibernation because the failure +* during hibernation does not matter (at this time all the devices +* have been frozen). Note: the correct affinity info is still updated +* into the irqdata data structure in migrate_one_irq() -> +* irq_do_set_affinity() -> hv_set_affinity(), so later when the VM +* resumes, hv_pci_restore_msi_state() is able to correctly restore +* the interrupt with the correct affinity. +*/ +if (res && hbus->state != hv_pcibus_removing)dev_err (&hbus->hdev->device,"%s() failed: %#llx" , __func__, res); -return ; - }pci_msi_unmask_irq (data); }
@@ -3372,6 +3386,34 @@ static int hv_pci_suspend(struct hv_device *hdev)return 0 ; } +static int hv_pci_restore_msi_msg (struct pci_dev *pdev,void *arg) +{ +struct msi_desc *entry; +struct irq_data *irq_data; + +for_each_pci_msi_entry (entry, pdev) { + irq_data =irq_get_irq_data (entry->irq); +if (WARN_ON_ONCE (!irq_data)) +return -EINVAL ; + +hv_compose_msi_msg (irq_data, &entry->msg); + } + +return 0 ; +} + +/* +* Upon resume, pci_restore_msi_state() -> ... -> __pci_write_msi_msg() +* directly writes the MSI/MSI-X registers via MMIO, but since Hyper-V +* doesn't trap and emulate the MMIO accesses, here hv_compose_msi_msg() +* must be used to ask Hyper-V to re-create the IOMMU Interrupt Remapping +* Table entries. +*/ +static void hv_pci_restore_msi_state (struct hv_pcibus_device *hbus) +{ +pci_walk_bus (hbus->pci_bus, hv_pci_restore_msi_msg,NULL ); +} +static int hv_pci_resume (struct hv_device *hdev) {struct hv_pcibus_device *hbus =hv_get_drvdata (hdev);
@@ -3405,6 +3447,8 @@ static int hv_pci_resume(struct hv_device *hdev)prepopulate_bars (hbus); +hv_pci_restore_msi_state (hbus); + hbus->state = hv_pcibus_installed;return 0 ; out:
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 539/757 clk: rockchip: Initialize hw to error to avoid undefined behavior
In reply to Greg Kroah-HartmanFrom: Stephen Boyd <[email protected]>
[ Upstream commit b608f11d49ec671739604cc763248d8e8fadbbeb ]
We can get down to this return value from ERR_CAST() without initializing hw. Set it to -ENOMEM so that we always return something sane.
Fixes the following smatch warning:
drivers/clk/rockchip/clk-half-divider.c:228 rockchip_clk_register_halfdiv() error: uninitialized symbol 'hw'. drivers/clk/rockchip/clk-half-divider.c:228 rockchip_clk_register_halfdiv() warn: passing zero to 'ERR_CAST'
--- drivers/clk/rockchip/clk-half-divider.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/rockchip/clk-half-divider.c +1 -1
@@ -166,7 +166,7 @@ struct clk *rockchip_clk_register_halfdiv(const char *name,unsigned long flags, spinlock_t *lock) { - struct clk *clk; + struct clk *clk = ERR_PTR(-ENOMEM);struct clk_mux *mux =NULL ;struct clk_gate *gate =NULL ;struct clk_divider *div =NULL ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 540/757 clk: mediatek: add UART0 clock support
In reply to Greg Kroah-HartmanFrom: Hanks Chen <[email protected]>
[ Upstream commit 804a892456b73604b7ecfb1b00a96a29f3d2aedf ]
Add MT6779 UART0 clock support.
--- drivers/clk/mediatek/clk-mt6779.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/clk/mediatek/clk-mt6779.c +2 -0
@@ -919,6 +919,8 @@ static const struct mtk_gate infra_clks[] = { "pwm_sel", 19),GATE_INFRA0 (CLK_INFRA_PWM ,"infra_pwm" ,"pwm_sel" ,21 ), +GATE_INFRA0 (CLK_INFRA_UART0 ,"infra_uart0" , +"uart_sel" ,22 ),GATE_INFRA0 (CLK_INFRA_UART1 ,"infra_uart1" ,"uart_sel" ,23 ), GATE_INFRA0(CLK_INFRA_UART2, "infra_uart2",
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 541/757 module: statically initialize init section freeing data
In reply to Greg Kroah-HartmanFrom: Daniel Jordan <[email protected]>
[ Upstream commit fdf09ab887829cd1b671e45d9549f8ec1ffda0fa ]
Corentin hit the following workqueue warning when running with CRYPTO_MANAGER_EXTRA_TESTS:
WARNING: CPU: 2 PID: 147 at kernel/workqueue.c:1473 __queue_work+0x3b8/0x3d0
Modules linked in: ghash_generic
CPU: 2 PID: 147 Comm: modprobe Not tainted
5.6.0-rc1-next-20200214-00068-g166c9264f0b1-dirty #545
Hardware name: Pine H64 model A (DT)
pc : __queue_work+0x3b8/0x3d0
Call trace:
__queue_work+0x3b8/0x3d0
queue_work_on+0x6c/0x90
do_init_module+0x188/0x1f0
load_module+0x1d00/0x22b0I wasn't able to reproduce on x86 or rpi 3b+.
This is
WARN_ON(!list_empty(&work->entry))
from __queue_work(), and it happens because the init_free_wq work item isn't initialized in time for a crypto test that requests the gcm module. Some crypto tests were recently moved earlier in boot as explained in commit c4741b230597 ("crypto: run initcalls for generic implementations earlier"), which went into mainline less than two weeks before the Fixes commit.
Avoid the warning by statically initializing init_free_wq and the corresponding llist.
Tested-on: sun50i-h6-pine-h64
Tested-on: imx8mn-ddr4-evk
Tested-on: sun50i-a64-bananapi-m64
--- kernel/module.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)
kernel/module.c +3 -10
@@ -91,8 +91,9 @@ EXPORT_SYMBOL_GPL(module_mutex);static LIST_HEAD (modules);/* Work queue for freeing init sections in success case */ -static struct work_struct init_free_wq; -static struct llist_head init_free_list; +static void do_free_init (struct work_struct *w); +static DECLARE_WORK(init_free_wq, do_free_init); +static LLIST_HEAD (init_free_list);#ifdef CONFIG_MODULES_TREE_LOOKUP
@@ -3579,14 +3580,6 @@ static void do_free_init(struct work_struct *w) } } -static int __init modules_wq_init (void ) -{ -INIT_WORK (&init_free_wq, do_free_init); -init_llist_head (&init_free_list); -return 0 ; -} -module_init (modules_wq_init); -/* * This is where the real work happens. *
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 542/757 clk: at91: clk-main: update key before writing AT91_CKGR_MOR
In reply to Greg Kroah-HartmanFrom: Claudiu Beznea <[email protected]>
[ Upstream commit 85d071e7f19a6a9abf30476b90b3819642568756 ]
SAMA5D2 datasheet specifies on chapter 33.22.8 (PMC Clock Generator Main Oscillator Register) that writing any value other than 0x37 on KEY field aborts the write operation. Use the key when selecting main clock parent.
--- drivers/clk/at91/clk-main.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/clk/at91/clk-main.c +8 -3
@@ -437,12 +437,17 @@ static int clk_sam9x5_main_set_parent(struct clk_hw *hw, u8 index)return -EINVAL ;regmap_read (regmap,AT91_CKGR_MOR , &tmp); - tmp &= ~MOR_KEY_MASK ;if (index && !(tmp &AT91_PMC_MOSCSEL )) -regmap_write (regmap,AT91_CKGR_MOR , tmp |AT91_PMC_MOSCSEL ); + tmp =AT91_PMC_MOSCSEL ;else if (!index && (tmp &AT91_PMC_MOSCSEL )) -regmap_write (regmap,AT91_CKGR_MOR , tmp & ~AT91_PMC_MOSCSEL ); + tmp =0 ; +else +return 0 ; + +regmap_update_bits (regmap,AT91_CKGR_MOR , +AT91_PMC_MOSCSEL |MOR_KEY_MASK , + tmp |AT91_PMC_KEY );while (!clk_sam9x5_main_ready (regmap))cpu_relax ();
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 543/757 clk: bcm2835: add missing release if devm_clk_hw_register fails
In reply to Greg Kroah-HartmanFrom: Navid Emamdoost <[email protected]>
[ Upstream commit f6c992ca7dd4f49042eec61f3fb426c94d901675 ]
In the implementation of bcm2835_register_pll(), the allocated pll is leaked if devm_clk_hw_register() fails to register hw. Release pll if devm_clk_hw_register() fails.
--- drivers/clk/bcm/clk-bcm2835.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clk/bcm/clk-bcm2835.c +3 -1
@@ -1338,8 +1338,10 @@ static struct clk_hw *bcm2835_register_pll(struct bcm2835_cprman *cprman, pll->hw.init = &init; ret =devm_clk_hw_register (cprman->dev, &pll->hw); -if (ret) +if (ret) { +kfree (pll);return NULL ; + }return &pll->hw; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 544/757 kbuild: deb-pkg: do not build linux-headers package if CONFIG_MODULES=n
In reply to Greg Kroah-HartmanFrom: Masahiro Yamada <[email protected]>
[ Upstream commit bac977cbc0d6731fb8e67c2be0e4acbd959e10b3 ]
Since commit 269a535ca931 ("modpost: generate vmlinux.symvers and reuse it for the second modpost"), with CONFIG_MODULES disabled, "make deb-pkg" (or "make bindeb-pkg") fails with:
find: ‘Module.symvers’: No such file or directory
If CONFIG_MODULES is disabled, it doesn't really make sense to build the linux-headers package.
--- scripts/package/builddeb | 6 ++++-- scripts/package/mkdebian | 19 ++++++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-)
scripts/package/builddeb +4 -2
@@ -202,8 +202,10 @@ EOF done if [ "$ARCH" != "um" ]; then - deploy_kernel_headers debian/linux-headers - create_package linux-headers-$version debian/linux-headers + if is_enabled CONFIG_MODULES; then + deploy_kernel_headers debian/linux-headers + create_package linux-headers-$version debian/linux-headers + fi deploy_libc_headers debian/linux-libc-dev create_package linux-libc-dev debian/linux-libc-dev
scripts/package/mkdebian +12 -7
@@ -183,13 +183,6 @@ Description: Linux kernel, version $version This package contains the Linux kernel, modules and corresponding other files, version: $version. -Package: $kernel_headers_packagename -Architecture: $debarch -Description: Linux kernel headers for $version on $debarch - This package provides kernel header files for $version on $debarch - . - This is useful for people who need to build external modules - Package: linux-libc-dev Section: devel Provides: linux-kernel-headers
@@ -200,6 +193,18 @@ Description: Linux support headers for userspace development Multi-Arch: same EOF +if is_enabled CONFIG_MODULES; then +cat <<EOF >> debian/control + +Package: $kernel_headers_packagename +Architecture: $debarch +Description: Linux kernel headers for $version on $debarch + This package provides kernel header files for $version on $debarch + . + This is useful for people who need to build external modules +EOF +fi + if is_enabled CONFIG_DEBUG_INFO; then cat <<EOF >> debian/control
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 545/757 watchdog: Fix memleak in watchdog_cdev_register
In reply to Greg Kroah-HartmanFrom: Dinghao Liu <[email protected]>
[ Upstream commit 5afb6d203d0293512aa2c6ae098274a2a4f6ed02 ]
When watchdog_kworker is NULL, we should free wd_data before the function returns to prevent memleak.
--- drivers/watchdog/watchdog_dev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/watchdog/watchdog_dev.c +3 -1
@@ -994,8 +994,10 @@ static int watchdog_cdev_register(struct watchdog_device *wdd) wd_data->wdd = wdd; wdd->wd_data = wd_data; -if (IS_ERR_OR_NULL (watchdog_kworker)) +if (IS_ERR_OR_NULL (watchdog_kworker)) { +kfree (wd_data);return -ENODEV ; + }device_initialize (&wd_data->dev); wd_data->dev.devt =MKDEV (MAJOR (watchdog_devt), wdd->id);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 546/757 watchdog: Use put_device on error
In reply to Greg Kroah-HartmanFrom: Dinghao Liu <[email protected]>
[ Upstream commit 937425d4cd3ae4e2882b41e332bbbab616bcf0ad ]
We should use put_device() instead of freeing device directly after device_initialize().
--- drivers/watchdog/watchdog_dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/watchdog/watchdog_dev.c +1 -1
@@ -1023,7 +1023,7 @@ static int watchdog_cdev_register(struct watchdog_device *wdd)pr_err ("%s: a legacy watchdog module is probably present.\n" , wdd->info->identity); old_wd_data =NULL ; -kfree (wd_data); +put_device (&wd_data->dev);return err; } }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 547/757 watchdog: sp5100: Fix definition of EFCH_PM_DECODEEN3
In reply to Greg Kroah-HartmanFrom: Guenter Roeck <[email protected]>
[ Upstream commit 08c619b4923056b5dd2d5045757468c76ad0e3fe ]
EFCH_PM_DECODEEN3 is supposed to access DECODEEN register bits 24..31, in other words the register at byte offset 3.
--- drivers/watchdog/sp5100_tco.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/watchdog/sp5100_tco.h +1 -1
@@ -70,7 +70,7 @@#define EFCH_PM_DECODEEN_WDT_TMREN BIT(7) -#define EFCH_PM_DECODEEN3 0x00 +#define EFCH_PM_DECODEEN3 0x03#define EFCH_PM_DECODEEN_SECOND_RES GENMASK(1, 0)#define EFCH_PM_WATCHDOG_DISABLE ((u8)GENMASK(3, 2))
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 548/757 clk: at91: sam9x60: support only two programmable clocks
In reply to Greg Kroah-HartmanFrom: Claudiu Beznea <[email protected]>
[ Upstream commit fcedb589b5a88d73d3155c4a8690d6dda91a3156 ]
According to datasheet (Chapter 29.16.13, PMC Programmable Clock Register) there are only two programmable clocks on SAM9X60.
--- drivers/clk/at91/sam9x60.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/at91/sam9x60.c +1 -1
@@ -279,7 +279,7 @@ static void __init sam9x60_pmc_setup(struct device_node *np) parent_names[3 ] ="masterck" ; parent_names[4 ] ="pllack_divck" ; parent_names[5 ] ="upllck_divck" ; -for (i =0 ; i <8 ; i++) { +for (i =0 ; i <2 ; i++) {char name[6 ];snprintf (name,sizeof (name),"prog%d" , i);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 549/757 svcrdma: fix bounce buffers for unaligned offsets and multiple pages
In reply to Greg Kroah-HartmanFrom: Dan Aloni <[email protected]>
[ Upstream commit c327a310ec4d6ecbea13185ed56c11def441d9ab ]
This was discovered using O_DIRECT at the client side, with small unaligned file offsets or IOs that span multiple file pages.
--- net/sunrpc/xprtrdma/svc_rdma_sendto.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/sunrpc/xprtrdma/svc_rdma_sendto.c +2 -1
@@ -638,10 +638,11 @@ static int svc_rdma_pull_up_reply_msg(struct svcxprt_rdma *rdma,while (remaining) { len =min_t (u32,PAGE_SIZE - pageoff, remaining); -memcpy (dst,page_address (*ppages), len); +memcpy (dst,page_address (*ppages) + pageoff, len); remaining -= len; dst += len; pageoff =0 ; + ppages++; } }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 550/757 ext4: fix dead loop in ext4_mb_new_blocks
In reply to Greg Kroah-HartmanFrom: Ye Bin <[email protected]>
[ Upstream commit 70022da804f0f3f152115688885608c39182082e ]
As we test disk offline/online with running fsstress, we find fsstress process is keeping running state.
kworker/u32:3-262 [004] ...1 140.787471: ext4_mb_discard_preallocations: dev 8,32 needed 114
....
kworker/u32:3-262 [004] ...1 140.787471: ext4_mb_discard_preallocations: dev 8,32 needed 114
ext4_mb_new_blocks
repeat:
ext4_mb_discard_preallocations_should_retry(sb, ac, &seq)
freed = ext4_mb_discard_preallocations
ext4_mb_discard_group_preallocations
this_cpu_inc(discard_pa_seq);
---> freed == 0
seq_retry = ext4_get_discard_pa_seq_sum
for_each_possible_cpu(__cpu)
__seq += per_cpu(discard_pa_seq, __cpu);
if (seq_retry != *seq) {
*seq = seq_retry;
ret = true;
}As we see seq_retry is sum of discard_pa_seq every cpu, if ext4_mb_discard_group_preallocations return zero discard_pa_seq in this cpu maybe increase one, so condition "seq_retry != *seq" have always been met.
Ritesh Harjani suggest to in ext4_mb_discard_group_preallocations function we only increase discard_pa_seq when there is some PA to free.
--- fs/ext4/mballoc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/ext4/mballoc.c +3 -1
@@ -4189,7 +4189,6 @@ ext4_mb_discard_group_preallocations(struct super_block *sb,INIT_LIST_HEAD (&list); repeat:ext4_lock_group (sb, group); -this_cpu_inc (discard_pa_seq);list_for_each_entry_safe (pa, tmp, &grp->bb_prealloc_list, pa_group_list) {spin_lock (&pa->pa_lock);
@@ -4206,6 +4205,9 @@ ext4_mb_discard_group_preallocations(struct super_block *sb,/* seems this one can be freed ... */ ext4_mb_mark_pa_deleted (sb, pa); +if (!free) +this_cpu_inc (discard_pa_seq); +/* we can trust pa_free ... */ free += pa->pa_free;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 551/757 ext4: discard preallocations before releasing group lock
In reply to Greg Kroah-HartmanFrom: Jan Kara <[email protected]>
[ Upstream commit 5b3dc19dda6691e8ab574e8eede1aef6f02a4f1c ]
ext4_mb_discard_group_preallocations() can be releasing group lock with preallocations accumulated on its local list. Thus although discard_pa_seq was incremented and concurrent allocating processes will be retrying allocations, it can happen that premature ENOSPC error is returned because blocks used for preallocations are not available for reuse yet. Make sure we always free locally accumulated preallocations before releasing group lock.
--- fs/ext4/mballoc.c | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-)
fs/ext4/mballoc.c +13 -20
@@ -4160,7 +4160,7 @@ ext4_mb_discard_group_preallocations(struct super_block *sb,struct ext4_buddy e4b;int err;int busy =0 ; -int free =0 ; +int free, free_total =0 ;mb_debug (sb,"discard preallocation for group %u\n" , group);if (list_empty (&grp->bb_prealloc_list))
@@ -4188,6 +4188,7 @@ ext4_mb_discard_group_preallocations(struct super_block *sb,INIT_LIST_HEAD (&list); repeat: + free =0 ;ext4_lock_group (sb, group);list_for_each_entry_safe (pa, tmp, &grp->bb_prealloc_list, pa_group_list) {
@@ -4217,22 +4218,6 @@ ext4_mb_discard_group_preallocations(struct super_block *sb,list_add (&pa->u.pa_tmp_list, &list); } -/* if we still need more blocks and some PAs were used, try again */ -if (free < needed && busy) { - busy =0 ; -ext4_unlock_group (sb, group); -cond_resched (); - goto repeat; - } - -/* found anything to free? */ -if (list_empty (&list)) { -BUG_ON (free !=0 ); -mb_debug (sb,"Someone else may have freed PA for this group %u\n" , - group); - goto out; - } -/* now free all selected PAs */ list_for_each_entry_safe (pa, tmp, &list, u.pa_tmp_list) {
@@ -4250,14 +4235,22 @@ ext4_mb_discard_group_preallocations(struct super_block *sb,call_rcu (&(pa)->u.pa_rcu, ext4_mb_pa_callback); } -out: + free_total += free; + +/* if we still need more blocks and some PAs were used, try again */ +if (free_total < needed && busy) { +ext4_unlock_group (sb, group); +cond_resched (); + busy =0 ; + goto repeat; + }ext4_unlock_group (sb, group);ext4_mb_unload_buddy (&e4b);put_bh (bitmap_bh); out_dbg:mb_debug (sb,"discarded (%d) blocks preallocated for group %u bb_free (%d)\n" , - free, group, grp->bb_free); -return free; + free_total, group, grp->bb_free); +return free_total; }/*
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 552/757 ext4: disallow modifying DAX inode flag if inline_data has been set
In reply to Greg Kroah-HartmanFrom: Xiao Yang <[email protected]>
[ Upstream commit aa2f77920b743c44e02e2dc8474bbf8bd30007a2 ]
inline_data is mutually exclusive to DAX so enabling both of them triggers the following issue:
------------------------------------------
# mkfs.ext4 -F -O inline_data /dev/pmem1 ... # mount /dev/pmem1 /mnt # echo 'test' >/mnt/file # lsattr -l /mnt/file /mnt/file Inline_Data # xfs_io -c "chattr +x" /mnt/file # xfs_io -c "lsattr -v" /mnt/file [dax] /mnt/file # umount /mnt # mount /dev/pmem1 /mnt # cat /mnt/file cat: /mnt/file: Numerical result out of range ------------------------------------------
--- fs/ext4/ext4.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/ext4.h +1 -1
@@ -492,7 +492,7 @@ struct flex_groups {/* Flags which are mutually exclusive to DAX */ #define EXT4_DAX_MUT_EXCL (EXT4_VERITY_FL | EXT4_ENCRYPT_FL |\ - EXT4_JOURNAL_DATA_FL) + EXT4_JOURNAL_DATA_FL | EXT4_INLINE_DATA_FL)/* Mask out flags that are inappropriate for the given type of inode. */ static inline __u32 ext4_mask_flags (umode_t mode,__u32 flags)
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 553/757 ext4: limit entries returned when counting fsmap records
In reply to Greg Kroah-HartmanFrom: Darrick J. Wong <[email protected]>
[ Upstream commit af8c53c8bc087459b1aadd4c94805d8272358d79 ]
If userspace asked fsmap to try to count the number of entries, we cannot return more than UINT_MAX entries because fmh_entries is u32. Therefore, stop counting if we hit this limit or else we will waste time to return truncated results.
--- fs/ext4/fsmap.c | 3 +++ 1 file changed, 3 insertions(+)
fs/ext4/fsmap.c +3 -0
@@ -108,6 +108,9 @@ static int ext4_getfsmap_helper(struct super_block *sb,/* Are we just counting mappings? */ if (info->gfi_head->fmh_count ==0 ) { +if (info->gfi_head->fmh_entries ==UINT_MAX ) +return EXT4_QUERY_RANGE_ABORT ; +if (rec_fsblk > info->gfi_next_fsblk) info->gfi_head->fmh_entries++;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 554/757 vfio/pci: Clear token on bypass registration failure
In reply to Greg Kroah-HartmanFrom: Alex Williamson <[email protected]>
[ Upstream commit 852b1beecb6ff9326f7ca4bc0fe69ae860ebdb9e ]
The eventfd context is used as our irqbypass token, therefore if an eventfd is re-used, our token is the same. The irqbypass code will return an -EBUSY in this case, but we'll still attempt to unregister the producer, where if that duplicate token still exists, results in removing the wrong object. Clear the token of failed producers so that they harmlessly fall out when unregistered.
--- drivers/vfio/pci/vfio_pci_intrs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/vfio/pci/vfio_pci_intrs.c +3 -1
@@ -352,11 +352,13 @@ static int vfio_msi_set_vector_signal(struct vfio_pci_device *vdev, vdev->ctx[vector].producer.token = trigger; vdev->ctx[vector].producer.irq = irq; ret =irq_bypass_register_producer (&vdev->ctx[vector].producer); -if (unlikely (ret)) +if (unlikely (ret)) {dev_info (&pdev->dev,"irq bypass producer (token %p) registration fails: %d\n" , vdev->ctx[vector].producer.token, ret); + vdev->ctx[vector].producer.token =NULL ; + } vdev->ctx[vector].trigger = trigger;return 0 ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 555/757 vfio iommu type1: Fix memory leak in vfio_iommu_type1_pin_pages
In reply to Greg Kroah-HartmanFrom: Xiaoyang Xu <[email protected]>
[ Upstream commit 2e6cfd496f5b57034cf2aec738799571b5a52124 ]
pfn is not added to pfn_list when vfio_add_to_pfn_list fails. vfio_unpin_page_external will exit directly without calling vfio_iova_put_vfio_pfn. This will lead to a memory leak.
--- drivers/vfio/vfio_iommu_type1.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/vfio/vfio_iommu_type1.c +2 -1
@@ -693,7 +693,8 @@ static int vfio_iommu_type1_pin_pages(void *iommu_data, ret =vfio_add_to_pfn_list (dma, iova, phys_pfn[i]);if (ret) { -vfio_unpin_page_external (dma, iova, do_accounting); +if (put_pfn (phys_pfn[i], dma->prot) && do_accounting) +vfio_lock_acct (dma,-1 , true); goto pin_unwind; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 556/757 clk: qcom: gdsc: Keep RETAIN_FF bit set if gdsc is already on
In reply to Greg Kroah-HartmanFrom: Stephen Boyd <[email protected]>
[ Upstream commit fda48bf5c86d88fd7074e318f290ad636dff4eaa ]
If the GDSC is enabled out of boot but doesn't have the retain ff bit set we will get confusing results where the registers that are powered by the GDSC lose their contents on the first power off of the GDSC but thereafter they retain their contents. This is because gdsc_init() fails to make sure the RETAIN_FF bit is set when it probes the GDSC the first time and thus powering off the GDSC causes the register contents to be reset. We do set the RETAIN_FF bit the next time we power on the GDSC, see gdsc_enable(), so that subsequent GDSC power off's don't lose register contents state.
Forcibly set the bit at device probe time so that the kernel's assumed view of the GDSC is consistent with the state of the hardware. This fixes a problem where the audio PLL doesn't work on sc7180 when the bootloader leaves the lpass_core_hm GDSC enabled at boot (e.g. to make a noise) but critically doesn't set the RETAIN_FF bit.
--- drivers/clk/qcom/gdsc.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/clk/qcom/gdsc.c +8 -0
@@ -358,6 +358,14 @@ static int gdsc_init(struct gdsc *sc)if ((sc->flags &VOTABLE ) && on)gdsc_enable (&sc->pd); +/* +* Make sure the retain bit is set if the GDSC is already on, otherwise +* we end up turning off the GDSC and destroying all the register +* contents that we thought we were saving. +*/ +if ((sc->flags &RETAIN_FF_ENABLE ) && on) +gdsc_retain_ff_on (sc); +/* If ALWAYS_ON GDSCs are not ON, turn them ON */ if (sc->flags &ALWAYS_ON ) {if (!on)
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 557/757 clk: imx8mq: Fix usdhc parents order
In reply to Greg Kroah-HartmanFrom: Abel Vesa <[email protected]>
[ Upstream commit b159c63d82ff8ffddc6c6f0eb881b113b36ecad7 ]
According to the latest RM (see Table 5-1. Clock Root Table), both usdhc root clocks have the parent order as follows:
000 - 25M_REF_CLK
001 - SYSTEM_PLL1_DIV2
010 - SYSTEM_PLL1_CLK
011 - SYSTEM_PLL2_DIV2
100 - SYSTEM_PLL3_CLK
101 - SYSTEM_PLL1_DIV3
110 - AUDIO_PLL2_CLK
111 - SYSTEM_PLL1_DIV8
So the audio_pll2_out and sys3_pll_out have to be swapped.
--- drivers/clk/imx/clk-imx8mq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/imx/clk-imx8mq.c +2 -2
@@ -157,10 +157,10 @@ static const char * const imx8mq_qspi_sels[] = {"osc_25m", "sys1_pll_400m", "sys "audio_pll2_out", "sys1_pll_266m", "sys3_pll_out", "sys1_pll_100m", };static const char *const imx8mq_usdhc1_sels[] = {"osc_25m" ,"sys1_pll_400m" ,"sys1_pll_800m" ,"sys2_pll_500m" , -"audio_pll2_out" ,"sys1_pll_266m" ,"sys3_pll_out" ,"sys1_pll_100m" , }; +"sys3_pll_out" ,"sys1_pll_266m" ,"audio_pll2_out" ,"sys1_pll_100m" , };static const char *const imx8mq_usdhc2_sels[] = {"osc_25m" ,"sys1_pll_400m" ,"sys1_pll_800m" ,"sys2_pll_500m" , -"audio_pll2_out" ,"sys1_pll_266m" ,"sys3_pll_out" ,"sys1_pll_100m" , }; +"sys3_pll_out" ,"sys1_pll_266m" ,"audio_pll2_out" ,"sys1_pll_100m" , };static const char *const imx8mq_i2c1_sels[] = {"osc_25m" ,"sys1_pll_160m" ,"sys2_pll_50m" ,"sys3_pll_out" ,"audio_pll1_out" ,"video_pll1_out" ,"audio_pll2_out" ,"sys1_pll_133m" , };
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 558/757 SUNRPC: fix copying of multiple pages in gss_read_proxy_verf()
In reply to Greg Kroah-HartmanFrom: Martijn de Gouw <[email protected]>
[ Upstream commit d48c8124749c9a5081fe68680f83605e272c984b ]
When the passed token is longer than 4032 bytes, the remaining part of the token must be copied from the rqstp->rq_arg.pages. But the copy must make sure it happens in a consecutive way.
With the existing code, the first memcpy copies 'length' bytes from argv->iobase, but since the header is in front, this never fills the whole first page of in_token->pages.
The mecpy in the loop copies the following bytes, but starts writing at the next page of in_token->pages. This leaves the last bytes of page 0 unwritten.
Symptoms were that users with many groups were not able to access NFS exports, when using Active Directory as the KDC.
--- net/sunrpc/auth_gss/svcauth_gss.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-)
net/sunrpc/auth_gss/svcauth_gss.c +17 -10
@@ -1147,9 +1147,9 @@ static int gss_read_proxy_verf(struct svc_rqst *rqstp, struct gssp_in_token *in_token) {struct kvec *argv = &rqstp->rq_arg.head[0 ]; -unsigned int page_base, length; -int pages, i, res; -size_t inlen; +unsigned int length, pgto_offs, pgfrom_offs; +int pages, i, res, pgto, pgfrom; +size_t inlen, to_offs, from_offs; res =gss_read_common_verf (gc, argv, authp, in_handle);if (res)
@@ -1177,17 +1177,24 @@ static int gss_read_proxy_verf(struct svc_rqst *rqstp,memcpy (page_address (in_token->pages[0 ]), argv->iov_base, length); inlen -= length; - i =1 ; - page_base = rqstp->rq_arg.page_base; + to_offs = length; + from_offs = rqstp->rq_arg.page_base;while (inlen) { - length = min_t(unsigned int, inlen, PAGE_SIZE); -memcpy (page_address (in_token->pages[i]), -page_address (rqstp->rq_arg.pages[i]) + page_base, + pgto = to_offs >>PAGE_SHIFT ; + pgfrom = from_offs >>PAGE_SHIFT ; + pgto_offs = to_offs & ~PAGE_MASK ; + pgfrom_offs = from_offs & ~PAGE_MASK ; + + length = min_t(unsigned int, inlen, + min_t(unsigned int, PAGE_SIZE - pgto_offs, +PAGE_SIZE - pgfrom_offs)); +memcpy (page_address (in_token->pages[pgto]) + pgto_offs, +page_address (rqstp->rq_arg.pages[pgfrom]) + pgfrom_offs, length); + to_offs += length; + from_offs += length; inlen -= length; - page_base =0 ; - i++; }return 0 ; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 559/757 NFSv4.2: Fix NFS4ERR_STALE error when doing inter server copy
In reply to Greg Kroah-HartmanFrom: Dai Ngo <[email protected]>
[ Upstream commit 0cfcd405e758ba1d277e58436fb32f06888c3e41 ]
NFS_FS=y as dependency of CONFIG_NFSD_V4_2_INTER_SSC still have build errors and some configs with NFSD=m to get NFS4ERR_STALE error when doing inter server copy.
Added ops table in nfs_common for knfsd to access NFS client modules.
--- fs/nfs/nfs4file.c | 38 ++++++++++++++--- fs/nfs/nfs4super.c | 5 +++ fs/nfs/super.c | 17 ++++++++ fs/nfs_common/Makefile | 1 + fs/nfs_common/nfs_ssc.c | 94 +++++++++++++++++++++++++++++++++++++++++ fs/nfsd/Kconfig | 2 +- fs/nfsd/nfs4proc.c | 3 +- include/linux/nfs_ssc.h | 67 +++++++++++++++++++++++++++++ 8 files changed, 219 insertions(+), 8 deletions(-) create mode 100644 fs/nfs_common/nfs_ssc.c create mode 100644 include/linux/nfs_ssc.h
fs/nfs/nfs4file.c +32 -6
@@ -9,6 +9,7 @@#include <linux/falloc.h> #include <linux/mount.h> #include <linux/nfs_fs.h> +#include <linux/nfs_ssc.h> #include "delegation.h" #include "internal.h" #include "iostat.h"
@@ -314,9 +315,8 @@ static loff_t nfs42_remap_file_range(struct file *src_file, loff_t src_off,static int read_name_gen =1 ;#define SSC_READ_NAME_BODY "ssc_read_%d" -struct file * -nfs42_ssc_open (struct vfsmount *ss_mnt,struct nfs_fh *src_fh, -nfs4_stateid *stateid) +static struct file *__nfs42_ssc_open (struct vfsmount *ss_mnt, +struct nfs_fh *src_fh,nfs4_stateid *stateid) {struct nfs_fattr fattr;struct file *filep, *res;
@@ -398,14 +398,40 @@ nfs42_ssc_open(struct vfsmount *ss_mnt, struct nfs_fh *src_fh,fput (filep); goto out_free_name; } -EXPORT_SYMBOL_GPL (nfs42_ssc_open); -void nfs42_ssc_close (struct file *filep) + +static void __nfs42_ssc_close (struct file *filep) {struct nfs_open_context *ctx =nfs_file_open_context (filep); ctx->state->flags =0 ; } -EXPORT_SYMBOL_GPL (nfs42_ssc_close); + +static const struct nfs4_ssc_client_ops nfs4_ssc_clnt_ops_tbl = { + .sco_open = __nfs42_ssc_open, + .sco_close = __nfs42_ssc_close, +}; + +/** +* nfs42_ssc_register_ops - Wrapper to register NFS_V4 ops in nfs_common +* +* Return values: +* None +*/ +void nfs42_ssc_register_ops (void ) +{ +nfs42_ssc_register (&nfs4_ssc_clnt_ops_tbl); +} + +/** +* nfs42_ssc_unregister_ops - wrapper to un-register NFS_V4 ops in nfs_common +* +* Return values: +* None. +*/ +void nfs42_ssc_unregister_ops (void ) +{ +nfs42_ssc_unregister (&nfs4_ssc_clnt_ops_tbl); +}#endif /* CONFIG_NFS_V4_2 */ const struct file_operations nfs4_file_operations = {
fs/nfs/nfs4super.c +5 -0
@@ -7,6 +7,7 @@#include <linux/mount.h> #include <linux/nfs4_mount.h> #include <linux/nfs_fs.h> +#include <linux/nfs_ssc.h> #include "delegation.h" #include "internal.h" #include "nfs4_fs.h"
@@ -279,6 +280,9 @@ static int __init init_nfs_v4(void)if (err) goto out2; +#ifdef CONFIG_NFS_V4_2 +nfs42_ssc_register_ops (); +#endif register_nfs_version (&nfs_v4);return 0 ; out2:
@@ -297,6 +301,7 @@ static void __exit exit_nfs_v4(void)unregister_nfs_version (&nfs_v4);#ifdef CONFIG_NFS_V4_2 nfs4_xattr_cache_exit (); +nfs42_ssc_unregister_ops ();#endif nfs4_unregister_sysctl ();nfs_idmap_quit ();
fs/nfs/super.c +17 -0
@@ -57,6 +57,7 @@#include <linux/rcupdate.h> #include <linux/uaccess.h> +#include <linux/nfs_ssc.h> #include "nfs4_fs.h" #include "callback.h"
@@ -85,6 +86,10 @@ const struct super_operations nfs_sops = { };EXPORT_SYMBOL_GPL (nfs_sops); +static const struct nfs_ssc_client_ops nfs_ssc_clnt_ops_tbl = { + .sco_sb_deactive = nfs_sb_deactive, +}; +#if IS_ENABLED (CONFIG_NFS_V4 )static int __init register_nfs4_fs (void ) {
@@ -106,6 +111,16 @@ static void unregister_nfs4_fs(void) }#endif +static void nfs_ssc_register_ops (void ) +{ +nfs_ssc_register (&nfs_ssc_clnt_ops_tbl); +} + +static void nfs_ssc_unregister_ops (void ) +{ +nfs_ssc_unregister (&nfs_ssc_clnt_ops_tbl); +} +static struct shrinker acl_shrinker = { .count_objects = nfs_access_cache_count, .scan_objects = nfs_access_cache_scan,
@@ -133,6 +148,7 @@ int __init register_nfs_fs(void) ret =register_shrinker (&acl_shrinker);if (ret <0 ) goto error_3; +nfs_ssc_register_ops ();return 0 ; error_3:nfs_unregister_sysctl ();
@@ -152,6 +168,7 @@ void __exit unregister_nfs_fs(void)unregister_shrinker (&acl_shrinker);nfs_unregister_sysctl ();unregister_nfs4_fs (); +nfs_ssc_unregister_ops ();unregister_filesystem (&nfs_fs_type); }
fs/nfs_common/Makefile +1 -0
@@ -7,3 +7,4 @@ obj-$(CONFIG_NFS_ACL_SUPPORT) += nfs_acl.o nfs_acl-objs := nfsacl.o obj-$(CONFIG_GRACE_PERIOD) += grace.o +obj-$(CONFIG_GRACE_PERIOD) += nfs_ssc.o
fs/nfs_common/nfs_ssc.c new file +94 -0
94 lines not on this page · raw message
fs/nfsd/Kconfig +1 -1
@@ -136,7 +136,7 @@ config NFSD_FLEXFILELAYOUT config NFSD_V4_2_INTER_SSC bool "NFSv4.2 inter server to server COPY" - depends on NFSD_V4 && NFS_V4_1 && NFS_V4_2 && NFS_FS=y + depends on NFSD_V4 && NFS_V4_1 && NFS_V4_2 help This option enables support for NFSv4.2 inter server to server copy where the destination server calls the NFSv4.2
fs/nfsd/nfs4proc.c +2 -1
@@ -38,6 +38,7 @@#include <linux/slab.h> #include <linux/kthread.h> #include <linux/sunrpc/addr.h> +#include <linux/nfs_ssc.h> #include "idmap.h" #include "cache.h"
@@ -1247,7 +1248,7 @@ nfsd4_interssc_connect(struct nl4_server *nss, struct svc_rqst *rqstp,static void nfsd4_interssc_disconnect (struct vfsmount *ss_mnt) { -nfs_sb_deactive (ss_mnt->mnt_sb); +nfs_do_sb_deactive (ss_mnt->mnt_sb);mntput (ss_mnt); }
include/linux/nfs_ssc.h new file +67 -0
67 lines not on this page · raw message
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 560/757 platform/chrome: cros_ec_typec: Send enum values to usb_role_switch_set_role()
In reply to Greg Kroah-HartmanFrom: Azhar Shaikh <[email protected]>
[ Upstream commit 5381b0ed54b6af3c0e8184b43e34154e17904848 ]
usb_role_switch_set_role() has the second argument as enum for usb_role. Currently depending upon the data role i.e. UFP(0) or DFP(1) is sent. This eventually translates to USB_ROLE_NONE in case of UFP and USB_ROLE_DEVICE in case of DFP. Correct this by sending correct enum values as USB_ROLE_DEVICE in case of UFP and USB_ROLE_HOST in case of DFP.
--- drivers/platform/chrome/cros_ec_typec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/platform/chrome/cros_ec_typec.c +2 -1
@@ -591,7 +591,8 @@ static int cros_typec_port_update(struct cros_typec_data *typec, int port_num)dev_warn (typec->dev,"Configure muxes failed, err = %d\n" , ret);return usb_role_switch_set_role (typec->ports[port_num]->role_sw, - !!(resp.role &PD_CTRL_RESP_ROLE_DATA )); + resp.role &PD_CTRL_RESP_ROLE_DATA + ?USB_ROLE_HOST :USB_ROLE_DEVICE ); }static int cros_typec_get_cmd_version (struct cros_typec_data *typec)
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 561/757 platform/chrome: cros_ec_lightbar: Reduce ligthbar get version command
In reply to Greg Kroah-HartmanFrom: Gwendal Grignou <[email protected]>
[ Upstream commit 1e7913ff5f9f1b73146ad8522958bd266f22a510 ]
By default, the lightbar commands are set to the biggest lightbar command and response. That length is greater than 128 bytes and may not work on all machines. But all EC are probed for lightbar by sending a get version request. Set that request size precisely.
Before the command would be:
cros_ec_cmd: version: 0, command: EC_CMD_LIGHTBAR_CMD, outsize: 194, insize: 128, result: 0
Afer:
cros_ec_cmd: version: 0, command: EC_CMD_LIGHTBAR_CMD, outsize: 1, insize: 8, result: 0
--- drivers/platform/chrome/cros_ec_lightbar.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/platform/chrome/cros_ec_lightbar.c +2 -0
@@ -116,6 +116,8 @@ static int get_lightbar_version(struct cros_ec_dev *ec, param = (struct ec_params_lightbar *)msg->data; param->cmd =LIGHTBAR_CMD_VERSION ; + msg->outsize =sizeof (param->cmd); + msg->result =sizeof (resp->version); ret =cros_ec_cmd_xfer_status (ec->ec_dev, msg);if (ret <0 ) { ret =0 ;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 562/757 Input: elants_i2c - fix typo for an attribute to show calibration count
In reply to Greg Kroah-HartmanFrom: Johnny Chuang <[email protected]>
[ Upstream commit 93f634069707cfe562c38739f5062feccbe9a834 ]
Fixed typo for command from 0xE0 to 0xD0.
--- drivers/input/touchscreen/elants_i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/touchscreen/elants_i2c.c +1 -1
@@ -90,7 +90,7 @@/* FW read command, 0x53 0x?? 0x0, 0x01 */ #define E_ELAN_INFO_FW_VER 0x00#define E_ELAN_INFO_BC_VER 0x10 -#define E_ELAN_INFO_REK 0xE0 +#define E_ELAN_INFO_REK 0xD0#define E_ELAN_INFO_TEST_VER 0xE0#define E_ELAN_INFO_FW_ID 0xF0#define E_INFO_OSR 0xD6
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 563/757 Input: imx6ul_tsc - clean up some errors in imx6ul_tsc_resume()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 30df23c5ecdfb8da5b0bc17ceef67eff9e1b0957 ]
If imx6ul_tsc_init() fails then we need to clean up the clocks.
I reversed the "if (input_dev->users) {" condition to make the code a bit simpler.
--- drivers/input/touchscreen/imx6ul_tsc.c | 27 +++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-)
drivers/input/touchscreen/imx6ul_tsc.c +16 -11
@@ -530,20 +530,25 @@ static int __maybe_unused imx6ul_tsc_resume(struct device *dev)mutex_lock (&input_dev->mutex); -if (input_dev->users) { - retval =clk_prepare_enable (tsc->adc_clk); -if (retval) - goto out; - - retval =clk_prepare_enable (tsc->tsc_clk); -if (retval) { -clk_disable_unprepare (tsc->adc_clk); - goto out; - } +if (!input_dev->users) + goto out; - retval =imx6ul_tsc_init (tsc); + retval =clk_prepare_enable (tsc->adc_clk); +if (retval) + goto out; + + retval =clk_prepare_enable (tsc->tsc_clk); +if (retval) { +clk_disable_unprepare (tsc->adc_clk); + goto out; } + retval =imx6ul_tsc_init (tsc); +if (retval) { +clk_disable_unprepare (tsc->tsc_clk); +clk_disable_unprepare (tsc->adc_clk); + goto out; + } out:mutex_unlock (&input_dev->mutex);return retval;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 564/757 Input: stmfts - fix a & vs && typo
In reply to Greg Kroah-HartmanFrom: YueHaibing <[email protected]>
[ Upstream commit d04afe14b23651e7a8bc89727a759e982a8458e4 ]
In stmfts_sysfs_hover_enable_write(), we should check value and sdata->hover_enabled is all true.
--- drivers/input/touchscreen/stmfts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/touchscreen/stmfts.c +1 -1
@@ -479,7 +479,7 @@ static ssize_t stmfts_sysfs_hover_enable_write(struct device *dev,mutex_lock (&sdata->mutex); -if (value & sdata->hover_enabled) +if (value && sdata->hover_enabled) goto out;if (sdata->running)
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 565/757 Input: ep93xx_keypad - fix handling of platform_get_irq() error
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit 7d50f6656dacf085a00beeedbc48b19a37d17881 ]
platform_get_irq() returns -ERRNO on error. In such case comparison to 0 would pass the check.
--- drivers/input/keyboard/ep93xx_keypad.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/input/keyboard/ep93xx_keypad.c +2 -2
@@ -250,8 +250,8 @@ static int ep93xx_keypad_probe(struct platform_device *pdev) } keypad->irq =platform_get_irq (pdev,0 ); -if (!keypad->irq) { - err = -ENXIO ; +if (keypad->irq <0 ) { + err = keypad->irq; goto failed_free; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 566/757 Input: omap4-keypad - fix handling of platform_get_irq() error
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit 4738dd1992fa13acfbbd71800c71c612f466fa44 ]
platform_get_irq() returns -ERRNO on error. In such case comparison to 0 would pass the check.
--- drivers/input/keyboard/omap4-keypad.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/input/keyboard/omap4-keypad.c +2 -4
@@ -240,10 +240,8 @@ static int omap4_keypad_probe(struct platform_device *pdev) } irq =platform_get_irq (pdev,0 ); -if (!irq) { -dev_err (&pdev->dev,"no keyboard irq assigned\n" ); -return -EINVAL ; - } +if (irq <0 ) +return irq; keypad_data =kzalloc (sizeof (struct omap4_keypad ),GFP_KERNEL );if (!keypad_data) {
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 567/757 Input: twl4030_keypad - fix handling of platform_get_irq() error
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit c277e1f0dc3c7d7b5b028e20dd414df241642036 ]
platform_get_irq() returns -ERRNO on error. In such case casting to unsigned and comparing to 0 would pass the check.
--- drivers/input/keyboard/twl4030_keypad.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/input/keyboard/twl4030_keypad.c +3 -5
@@ -50,7 +50,7 @@ struct twl4030_keypad {bool autorepeat;unsigned int n_rows;unsigned int n_cols; -unsigned int irq; +int irq;struct device *dbg_dev;struct input_dev *input;
@@ -376,10 +376,8 @@ static int twl4030_kp_probe(struct platform_device *pdev) } kp->irq =platform_get_irq (pdev,0 ); -if (!kp->irq) { -dev_err (&pdev->dev,"no keyboard irq assigned\n" ); -return -EINVAL ; - } +if (kp->irq <0 ) +return kp->irq; error = matrix_keypad_build_keymap(keymap_data, NULL, TWL4030_MAX_ROWS,
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 568/757 Input: sun4i-ps2 - fix handling of platform_get_irq() error
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit cafb3abea6136e59ea534004e5773361e196bb94 ]
platform_get_irq() returns -ERRNO on error. In such case comparison to 0 would pass the check.
--- drivers/input/serio/sun4i-ps2.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/input/serio/sun4i-ps2.c +3 -6
@@ -211,7 +211,6 @@ static int sun4i_ps2_probe(struct platform_device *pdev)struct sun4i_ps2data *drvdata;struct serio *serio;struct device *dev = &pdev->dev; -unsigned int irq;int error; drvdata =kzalloc (sizeof (struct sun4i_ps2data ),GFP_KERNEL );
@@ -264,14 +263,12 @@ static int sun4i_ps2_probe(struct platform_device *pdev)writel (0 , drvdata->reg_base +PS2_REG_GCTL );/* Get IRQ for the device */ - irq =platform_get_irq (pdev,0 ); -if (!irq) { -dev_err (dev,"no IRQ found\n" ); - error = -ENXIO ; + drvdata->irq =platform_get_irq (pdev,0 ); +if (drvdata->irq <0 ) { + error = drvdata->irq; goto err_disable_clk; } - drvdata->irq = irq; drvdata->serio = serio; drvdata->dev = dev;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 569/757 KVM: x86: emulating RDPID failure shall return #UD rather than #GP
In reply to Greg Kroah-HartmanFrom: Robert Hoo <[email protected]>
[ Upstream commit a9e2e0ae686094571378c72d8146b5a1a92d0652 ]
Per Intel's SDM, RDPID takes a #UD if it is unsupported, which is more or less what KVM is emulating when MSR_TSC_AUX is not available. In fact, there are no scenarios in which RDPID is supposed to #GP.
Message-Id: <[email protected]>
--- arch/x86/kvm/emulate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/emulate.c +1 -1
@@ -3606,7 +3606,7 @@ static int em_rdpid(struct x86_emulate_ctxt *ctxt)u64 tsc_aux =0 ;if (ctxt->ops->get_msr (ctxt,MSR_TSC_AUX , &tsc_aux)) -return emulate_gp (ctxt,0 ); +return emulate_ud (ctxt); ctxt->dst.val = tsc_aux;return X86EMUL_CONTINUE ; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 570/757 KVM: nSVM: CR3 MBZ bits are only 63:52
In reply to Greg Kroah-HartmanFrom: Krish Sadhukhan <[email protected]>
[ Upstream commit fb0f33fdefe9f473dc5f7b71345096c8d60ab9dd ]
Commit 761e4169346553c180bbd4a383aedd72f905bc9a created a wrong mask for the CR3 MBZ bits. According to APM vol 2, only the upper 12 bits are MBZ.
Message-Id: <[email protected]>
--- arch/x86/kvm/svm/nested.c | 2 +- arch/x86/kvm/svm/svm.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/kvm/svm/nested.c +1 -1
@@ -243,7 +243,7 @@ static bool nested_vmcb_checks(struct vcpu_svm *svm, struct vmcb *vmcb) }else {if (!(vmcb->save.cr4 &X86_CR4_PAE ) || !(vmcb->save.cr0 &X86_CR0_PE ) || - (vmcb->save.cr3 &MSR_CR3_LONG_RESERVED_MASK )) + (vmcb->save.cr3 &MSR_CR3_LONG_MBZ_MASK ))return false; }if (kvm_valid_cr4 (&svm->vcpu, vmcb->save.cr4))
arch/x86/kvm/svm/svm.h +1 -1
@@ -345,7 +345,7 @@ static inline bool gif_set(struct vcpu_svm *svm)/* svm.c */ #define MSR_CR3_LEGACY_RESERVED_MASK 0xfe7U#define MSR_CR3_LEGACY_PAE_RESERVED_MASK 0x7U -#define MSR_CR3_LONG_RESERVED_MASK 0xfff0000000000fe7U +#define MSR_CR3_LONG_MBZ_MASK 0xfff0000000000000U#define MSR_INVALID 0xffffffffUu32 svm_msrpm_offset (u32 msr);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 571/757 scsi: bfa: Fix error return in bfad_pci_init()
In reply to Greg Kroah-HartmanFrom: Jing Xiangfeng <[email protected]>
[ Upstream commit f0f6c3a4fcb80fcbcce4ff6739996dd98c228afd ]
Fix to return error code -ENODEV from the error handling case instead of 0.
--- drivers/scsi/bfa/bfad.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/bfa/bfad.c +1 -0
@@ -749,6 +749,7 @@ bfad_pci_init(struct pci_dev *pdev, struct bfad_s *bfad)if (bfad->pci_bar0_kva ==NULL ) {printk (KERN_ERR "Fail to map bar0\n" ); + rc = -ENODEV ; goto out_release_region; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 572/757 arm64: mm: use single quantity to represent the PA to VA translation
In reply to Greg Kroah-HartmanFrom: Ard Biesheuvel <[email protected]>
[ Upstream commit 7bc1a0f9e1765830e945669c99c59c35cf9bca82 ]
On arm64, the global variable memstart_addr represents the physical address of PAGE_OFFSET, and so physical to virtual translations or vice versa used to come down to simple additions or subtractions involving the values of PAGE_OFFSET and memstart_addr.
When support for 52-bit virtual addressing was introduced, we had to deal with PAGE_OFFSET potentially being outside of the region that can be covered by the virtual range (as the 52-bit VA capable build needs to be able to run on systems that are only 48-bit VA capable), and for this reason, another translation was introduced, and recorded in the global variable physvirt_offset.
However, if we go back to the original definition of memstart_addr, i.e., the physical address of PAGE_OFFSET, it turns out that there is no need for two separate translations: instead, we can simply subtract the size of the unaddressable VA space from memstart_addr to make the available physical memory appear in the 48-bit addressable VA region.
This simplifies things, but also fixes a bug on KASLR builds, which may update memstart_addr later on in arm64_memblock_init(), but fails to update vmemmap and physvirt_offset accordingly.
--- arch/arm64/include/asm/memory.h | 5 ++--- arch/arm64/include/asm/pgtable.h | 4 ++-- arch/arm64/mm/init.c | 30 ++++++++++-------------------- 3 files changed, 14 insertions(+), 25 deletions(-)
arch/arm64/include/asm/memory.h +2 -3
@@ -164,7 +164,6 @@extern u64 vabits_actual;#define PAGE_END (_PAGE_END(vabits_actual)) -extern s64 physvirt_offset;extern s64 memstart_addr;/* PHYS_OFFSET - the physical address of the start of memory. */ #define PHYS_OFFSET ({ VM_BUG_ON(memstart_addr & 1); memstart_addr; })
@@ -240,7 +239,7 @@ static inline const void *__tag_set(const void *addr, u8 tag)*/ #define __is_lm_address (addr) (!(((u64)addr) & BIT(vabits_actual - 1))) -#define __lm_to_phys (addr) (((addr) + physvirt_offset)) +#define __lm_to_phys (addr) (((addr) & ~PAGE_OFFSET) + PHYS_OFFSET)#define __kimg_to_phys (addr) ((addr) - kimage_voffset)#define __virt_to_phys_nodebug (x) ({ \
@@ -258,7 +257,7 @@ extern phys_addr_t __phys_addr_symbol(unsigned long x);#define __phys_addr_symbol (x) __pa_symbol_nodebug(x)#endif /* CONFIG_DEBUG_VIRTUAL */ -#define __phys_to_virt (x) ((unsigned long)((x) - physvirt_offset)) +#define __phys_to_virt (x) ((unsigned long)((x) - PHYS_OFFSET) | PAGE_OFFSET)#define __phys_to_kimg (x) ((unsigned long)((x) + kimage_voffset))/*
arch/arm64/include/asm/pgtable.h +2 -2
@@ -23,6 +23,8 @@#define VMALLOC_START (MODULES_END)#define VMALLOC_END (- PUD_SIZE - VMEMMAP_SIZE - SZ_64K) +#define vmemmap ((struct page *)VMEMMAP_START - (memstart_addr >> PAGE_SHIFT)) +#define FIRST_USER_ADDRESS 0UL#ifndef __ASSEMBLY__
@@ -33,8 +35,6 @@#include <linux/mm_types.h> #include <linux/sched.h> -extern struct page *vmemmap; -extern void __pte_error (const char *file,int line,unsigned long val);extern void __pmd_error (const char *file,int line,unsigned long val);extern void __pud_error (const char *file,int line,unsigned long val);
arch/arm64/mm/init.c +10 -20
@@ -54,12 +54,6 @@s64 memstart_addr__ro_after_init =-1 ;EXPORT_SYMBOL (memstart_addr); -s64 physvirt_offset__ro_after_init ; -EXPORT_SYMBOL (physvirt_offset); - -struct page *vmemmap__ro_after_init ; -EXPORT_SYMBOL (vmemmap); -/* * We create both ZONE_DMA and ZONE_DMA32. ZONE_DMA covers the first 1G of * memory as some devices, namely the Raspberry Pi 4, have peripherals with
@@ -290,20 +284,6 @@ void __init arm64_memblock_init(void) memstart_addr =round_down (memblock_start_of_DRAM (),ARM64_MEMSTART_ALIGN ); - physvirt_offset =PHYS_OFFSET -PAGE_OFFSET ; - - vmemmap = ((struct page *)VMEMMAP_START - (memstart_addr >>PAGE_SHIFT )); - -/* -* If we are running with a 52-bit kernel VA config on a system that -* does not support it, we have to offset our vmemmap and physvirt_offset -* s.t. we avoid the 52-bit portion of the direct linear map -*/ -if (IS_ENABLED (CONFIG_ARM64_VA_BITS_52 ) && (vabits_actual !=52 )) { - vmemmap += (_PAGE_OFFSET (48 ) -_PAGE_OFFSET (52 )) >>PAGE_SHIFT ; - physvirt_offset =PHYS_OFFSET -_PAGE_OFFSET (48 ); - } -/* * Remove the memory that we will not be able to cover with the * linear mapping. Take care not to clip the kernel which may be
@@ -318,6 +298,16 @@ void __init arm64_memblock_init(void)memblock_remove (0 , memstart_addr); } +/* +* If we are running with a 52-bit kernel VA config on a system that +* does not support it, we have to place the available physical +* memory in the 48-bit addressable part of the linear region, i.e., +* we have to move it upward. Since memstart_addr represents the +* physical address of PAGE_OFFSET, we have to *subtract* from it. +*/ +if (IS_ENABLED (CONFIG_ARM64_VA_BITS_52 ) && (vabits_actual !=52 )) + memstart_addr -=_PAGE_OFFSET (48 ) -_PAGE_OFFSET (52 ); +/* * Apply the memory limit if it was set. Since the kernel may be loaded * high up in memory, add back the kernel region that must be accessible
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 573/757 bpf: Enforce id generation for all may-be-null register type
In reply to Greg Kroah-HartmanFrom: Martin KaFai Lau <[email protected]>
[ Upstream commit 93c230e3f5bd6e1d2b2759d582fdfe9c2731473b ]
The commit af7ec1383361 ("bpf: Add bpf_skc_to_tcp6_sock() helper") introduces RET_PTR_TO_BTF_ID_OR_NULL and
the commit eaa6bcb71ef6 ("bpf: Introduce bpf_per_cpu_ptr()") introduces RET_PTR_TO_MEM_OR_BTF_ID_OR_NULL.
Note that for RET_PTR_TO_MEM_OR_BTF_ID_OR_NULL, the reg0->type could become PTR_TO_MEM_OR_NULL which is not covered by BPF_PROBE_MEM.
The BPF_REG_0 will then hold a _OR_NULL pointer type. This _OR_NULL pointer type requires the bpf program to explicitly do a NULL check first. After NULL check, the verifier will mark all registers having the same reg->id as safe to use. However, the reg->id
is not set for those new _OR_NULL return types. One of the ways that may be wrong is, checking NULL for one btf_id typed pointer will end up validating all other btf_id typed pointers because
all of them have id == 0. The later tests will exercise
this path.
To fix it and also avoid similar issue in the future, this patch moves the id generation logic out of each individual RET type test in check_helper_call(). Instead, it does one reg_type_may_be_null() test and then do the id generation if needed.
This patch also adds a WARN_ON_ONCE in mark_ptr_or_null_reg() to catch future breakage.
The _OR_NULL pointer usage in the bpf_iter_reg.ctx_arg_info is fine because it just happens that the existing id generation after check_ctx_access() has covered it. It is also using the reg_type_may_be_null() to decide if id generation is needed or not.
--- kernel/bpf/verifier.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
kernel/bpf/verifier.c +5 -6
@@ -4885,24 +4885,19 @@ static int check_helper_call(struct bpf_verifier_env *env, int func_id, int insn regs[BPF_REG_0 ].id = ++env->id_gen; }else { regs[BPF_REG_0 ].type =PTR_TO_MAP_VALUE_OR_NULL ; - regs[BPF_REG_0 ].id = ++env->id_gen; } }else if (fn->ret_type ==RET_PTR_TO_SOCKET_OR_NULL ) {mark_reg_known_zero (env, regs,BPF_REG_0 ); regs[BPF_REG_0 ].type =PTR_TO_SOCKET_OR_NULL ; - regs[BPF_REG_0 ].id = ++env->id_gen; }else if (fn->ret_type ==RET_PTR_TO_SOCK_COMMON_OR_NULL ) {mark_reg_known_zero (env, regs,BPF_REG_0 ); regs[BPF_REG_0 ].type =PTR_TO_SOCK_COMMON_OR_NULL ; - regs[BPF_REG_0 ].id = ++env->id_gen; }else if (fn->ret_type ==RET_PTR_TO_TCP_SOCK_OR_NULL ) {mark_reg_known_zero (env, regs,BPF_REG_0 ); regs[BPF_REG_0 ].type =PTR_TO_TCP_SOCK_OR_NULL ; - regs[BPF_REG_0 ].id = ++env->id_gen; }else if (fn->ret_type ==RET_PTR_TO_ALLOC_MEM_OR_NULL ) {mark_reg_known_zero (env, regs,BPF_REG_0 ); regs[BPF_REG_0 ].type =PTR_TO_MEM_OR_NULL ; - regs[BPF_REG_0 ].id = ++env->id_gen; regs[BPF_REG_0 ].mem_size = meta.mem_size; }else if (fn->ret_type ==RET_PTR_TO_BTF_ID_OR_NULL ) {int ret_btf_id;
@@ -4922,6 +4917,9 @@ static int check_helper_call(struct bpf_verifier_env *env, int func_id, int insnreturn -EINVAL ; } +if (reg_type_may_be_null (regs[BPF_REG_0 ].type)) + regs[BPF_REG_0 ].id = ++env->id_gen; +if (is_ptr_cast_function (func_id)) {/* For release_reference() */ regs[BPF_REG_0 ].ref_obj_id = meta.ref_obj_id;
@@ -6847,7 +6845,8 @@ static void mark_ptr_or_null_reg(struct bpf_func_state *state, struct bpf_reg_state *reg, u32 id, bool is_null) { - if (reg_type_may_be_null(reg->type) && reg->id == id) { + if (reg_type_may_be_null(reg->type) && reg->id == id && + !WARN_ON_ONCE(!reg->id)) {/* Old offset (both fixed and variable parts) should * have been known-zero, because we don't allow pointer * arithmetic on pointers that might be NULL.
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 574/757 net: dsa: seville: the packet buffer is 2 megabits, not megabytes
In reply to Greg Kroah-HartmanFrom: Maxim Kochetkov <[email protected]>
[ Upstream commit a15a6afb3bf9388eb83a4b876d3453f305fba909 ]
The VSC9953 Seville switch has 2 megabits of buffer split into 4360 words of 60 bytes each. 2048 * 1024 is 2 megabytes instead of 2 megabits. 2 megabits is (2048 / 8) * 1024 = 256 * 1024.
--- drivers/net/dsa/ocelot/seville_vsc9953.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dsa/ocelot/seville_vsc9953.c +1 -1
@@ -1010,7 +1010,7 @@ static const struct felix_info seville_info_vsc9953 = { .vcap_is2_keys = vsc9953_vcap_is2_keys, .vcap_is2_actions = vsc9953_vcap_is2_actions, .vcap = vsc9953_vcap_props, - .shared_queue_sz = 2048 * 1024, + .shared_queue_sz = 256 * 1024, .num_mact_rows = 2048, .num_ports = 10, .mdio_bus_alloc = vsc9953_mdio_bus_alloc,
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 575/757 netfilter: conntrack: connection timeout after re-register
In reply to Greg Kroah-HartmanFrom: Francesco Ruggeri <[email protected]>
[ Upstream commit 4f25434bccc28cf8a07876ef5142a2869a674353 ]
If the first packet conntrack sees after a re-register is an outgoing keepalive packet with no data (SEG.SEQ = SND.NXT-1), td_end is set to SND.NXT-1.
When the peer correctly acknowledges SND.NXT, tcp_in_window fails check III (Upper bound for valid (s)ack: sack <= receiver.td_end) and returns false, which cascades into nf_conntrack_in setting skb->_nfct = 0 and in later conntrack iptables rules not matching. In cases where iptables are dropping packets that do not match conntrack rules this can result in idle tcp connections to time out.
v2: adjust td_end when getting the reply rather than when sending out
the keepalive packet.
--- net/netfilter/nf_conntrack_proto_tcp.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
net/netfilter/nf_conntrack_proto_tcp.c +13 -6
@@ -541,13 +541,20 @@ static bool tcp_in_window(const struct nf_conn *ct, swin = win << sender->td_scale; sender->td_maxwin = (swin ==0 ?1 : swin); sender->td_maxend = end + sender->td_maxwin; -/* -* We haven't seen traffic in the other direction yet -* but we have to tweak window tracking to pass III -* and IV until that happens. -*/ -if (receiver->td_maxwin ==0 ) +if (receiver->td_maxwin ==0 ) { +/* We haven't seen traffic in the other +* direction yet but we have to tweak window +* tracking to pass III and IV until that +* happens. +*/ receiver->td_end = receiver->td_maxend = sack; + }else if (sack == receiver->td_end +1 ) { +/* Likely a reply to a keepalive. +* Needed for III. +*/ + receiver->td_end++; + } + } } else if (((state->state == TCP_CONNTRACK_SYN_SENT && dir == IP_CT_DIR_ORIGINAL)
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 576/757 netfilter: ebtables: Fixes dropping of small packets in bridge nat
In reply to Greg Kroah-HartmanFrom: Timothée COCAULT <[email protected]>
[ Upstream commit 63137bc5882a1882c553d389fdeeeace86ee1741 ]
Fixes an error causing small packets to get dropped. skb_ensure_writable expects the second parameter to be a length in the ethernet payload.=20 If we want to write the ethernet header (src, dst), we should pass 0. Otherwise, packets with small payloads (< ETH_ALEN) will get dropped.
--- net/bridge/netfilter/ebt_dnat.c | 2 +- net/bridge/netfilter/ebt_redirect.c | 2 +- net/bridge/netfilter/ebt_snat.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
net/bridge/netfilter/ebt_dnat.c +1 -1
@@ -21,7 +21,7 @@ ebt_dnat_tg(struct sk_buff *skb, const struct xt_action_param *par) {const struct ebt_nat_info *info = par->targinfo; -if (skb_ensure_writable (skb,ETH_ALEN )) +if (skb_ensure_writable (skb,0 ))return EBT_DROP ;ether_addr_copy (eth_hdr (skb)->h_dest, info->mac);
net/bridge/netfilter/ebt_redirect.c +1 -1
@@ -21,7 +21,7 @@ ebt_redirect_tg(struct sk_buff *skb, const struct xt_action_param *par) {const struct ebt_redirect_info *info = par->targinfo; -if (skb_ensure_writable (skb,ETH_ALEN )) +if (skb_ensure_writable (skb,0 ))return EBT_DROP ;if (xt_hooknum (par) !=NF_BR_BROUTING )
net/bridge/netfilter/ebt_snat.c +1 -1
@@ -22,7 +22,7 @@ ebt_snat_tg(struct sk_buff *skb, const struct xt_action_param *par) {const struct ebt_nat_info *info = par->targinfo; -if (skb_ensure_writable (skb,ETH_ALEN *2 )) +if (skb_ensure_writable (skb,0 ))return EBT_DROP ;ether_addr_copy (eth_hdr (skb)->h_source, info->mac);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 577/757 vdpa/mlx5: Make use of a specific 16 bit endianness API
In reply to Greg Kroah-HartmanFrom: Eli Cohen <[email protected]>
[ Upstream commit 36bdcf318bc21af24de10b68e32cdea6b9a8d17f ]
Introduce a dedicated function to be used for setting 16 bit fields per virio endianness requirements and use it to set the mtu field.
--- drivers/vdpa/mlx5/net/mlx5_vnet.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/vdpa/mlx5/net/mlx5_vnet.c +6 -2
@@ -1522,6 +1522,11 @@ static inline bool mlx5_vdpa_is_little_endian(struct mlx5_vdpa_dev *mvdev) (mvdev->actual_features & (1ULL <<VIRTIO_F_VERSION_1 )); } +static __virtio16 cpu_to_mlx5vdpa16 (struct mlx5_vdpa_dev *mvdev,u16 val) +{ +return __cpu_to_virtio16 (mlx5_vdpa_is_little_endian (mvdev), val); +} +static int mlx5_vdpa_set_features (struct vdpa_device *vdev,u64 features) {struct mlx5_vdpa_dev *mvdev =to_mvdev (vdev);
@@ -1535,8 +1540,7 @@ static int mlx5_vdpa_set_features(struct vdpa_device *vdev, u64 features)return err; ndev->mvdev.actual_features = features & ndev->mvdev.mlx_features; - ndev->config.mtu =__cpu_to_virtio16 (mlx5_vdpa_is_little_endian (mvdev), - ndev->mtu); + ndev->config.mtu =cpu_to_mlx5vdpa16 (mvdev, ndev->mtu);return err; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 578/757 vdpa/mlx5: Fix failure to bring link up
In reply to Greg Kroah-HartmanFrom: Eli Cohen <[email protected]>
[ Upstream commit 36b02df2d204da9f7a571f16ed9e91a4d083f207 ]
Set VIRTIO_NET_S_LINK_UP in config status to allow the get the bring the net device's link up.
--- drivers/vdpa/mlx5/net/mlx5_vnet.c | 1 + 1 file changed, 1 insertion(+)
drivers/vdpa/mlx5/net/mlx5_vnet.c +1 -0
@@ -1541,6 +1541,7 @@ static int mlx5_vdpa_set_features(struct vdpa_device *vdev, u64 features) ndev->mvdev.actual_features = features & ndev->mvdev.mlx_features; ndev->config.mtu =cpu_to_mlx5vdpa16 (mvdev, ndev->mtu); + ndev->config.status |=cpu_to_mlx5vdpa16 (mvdev,VIRTIO_NET_S_LINK_UP );return err; }
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 579/757 vdpa/mlx5: Setup driver only if VIRTIO_CONFIG_S_DRIVER_OK
In reply to Greg Kroah-HartmanFrom: Eli Cohen <[email protected]>
[ Upstream commit 1897f0b618b0af0eb9dca709ab6bdf9ef1969ef7 ]
set_map() is used by mlx5 vdpa to create a memory region based on the address map passed by the iotlb argument. If we get successive calls, we will destroy the current memory region and build another one based on the new address mapping. We also need to setup the hardware resources since they depend on the memory region.
If these calls happen before DRIVER_OK, It means that driver VQs may also not been setup and we may not create them yet. In this case we want to avoid setting up the other resources and defer this till we get DRIVER OK.
--- drivers/vdpa/mlx5/net/mlx5_vnet.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/vdpa/mlx5/net/mlx5_vnet.c +3 -0
@@ -1658,6 +1658,9 @@ static int mlx5_vdpa_change_map(struct mlx5_vdpa_net *ndev, struct vhost_iotlb *if (err) goto err_mr; +if (!(ndev->mvdev.status &VIRTIO_CONFIG_S_DRIVER_OK )) +return 0 ; +restore_channels_info (ndev); err =setup_driver (ndev);if (err)
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 580/757 selftests: mptcp: depends on built-in IPv6
In reply to Greg Kroah-HartmanFrom: Matthieu Baerts <[email protected]>
[ Upstream commit 287d35405989cfe0090e3059f7788dc531879a8d ]
Recently, CONFIG_MPTCP_IPV6 no longer selects CONFIG_IPV6. As a consequence, if CONFIG_MPTCP_IPV6=y is added to the kconfig, it will no longer ensure CONFIG_IPV6=y. If it is not enabled, CONFIG_MPTCP_IPV6 will stay disabled and selftests will fail.
We also need CONFIG_IPV6 to be built-in. For more details, please see commit 0ed37ac586c0 ("mptcp: depends on IPV6 but not as a module").
Note that 'make kselftest-merge' will take all 'config' files found in 'tools/testsing/selftests'. Because some of them already set CONFIG_IPV6=y, MPTCP selftests were still passing. But they will fail if MPTCP selftests are launched manually after having executed this command to prepare the kernel config:
./scripts/kconfig/merge_config.sh -m .config \
./tools/testing/selftests/net/mptcp/config--- tools/testing/selftests/net/mptcp/config | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/net/mptcp/config +1 -0
@@ -1,4 +1,5 @@ CONFIG_MPTCP=y +CONFIG_IPV6=y CONFIG_MPTCP_IPV6=y CONFIG_INET_DIAG=m CONFIG_INET_MPTCP_DIAG=m
Signature · 1 line
2.25.1
Re: [PATCH 5.9 580/757] selftests: mptcp: depends on built-in IPv6
Hi Greg,
Quoted 8 lines · Greg Kroah-Hartman
From: Matthieu Baerts <[email protected]>
[ Upstream commit
287d35405989cfe0090e3059f7788dc531879a8d]Recently,
CONFIG_MPTCP_IPV6no longer selectsCONFIG_IPV6. As a consequence, ifCONFIG_MPTCP_IPV6=yis added to the kconfig, it will no longer ensureCONFIG_IPV6=y. If it is not enabled,CONFIG_MPTCP_IPV6will stay disabled and selftests will fail.
I think Sasha wanted to drop this patch [1]. But as I said earlier [2], this patch is not wrong, it is just not needed in v5.9 because the "Fixes" commit 010b430d5df5 ("mptcp: MPTCP_IPV6 should depend on IPV6 instead of selecting it") is not in v5.9.
I guess it is certainly easier to keep it because it is not wrong and doesn't hurt.
[1] https://lore.kernel.org/stable/20201026142329.GJ4060117@sasha-vm/
[2] https://lore.kernel.org/stable/[email protected]/
Cheers,
Matt
Signature · 2 lines
Tessares | Belgium | Hybrid Access Solutions www.tessares.net
Sasha Levin
maintainerRe: [PATCH 5.9 580/757] selftests: mptcp: depends on built-in IPv6
Quoted 7 lines · Matthieu Baerts
Hi Greg,
Quoted 4 lines · Greg Kroah-Hartman
From: Matthieu Baerts <[email protected]>
[ Upstream commit
287d35405989cfe0090e3059f7788dc531879a8d]
Quoted 8 lines
Quoted 4 lines
Recently,
CONFIG_MPTCP_IPV6no longer selectsCONFIG_IPV6. As a consequence, ifCONFIG_MPTCP_IPV6=yis added to the kconfig, it will no longer ensureCONFIG_IPV6=y. If it is not enabled,CONFIG_MPTCP_IPV6will stay disabled and selftests will fail.I think Sasha wanted to drop this patch [1]. But as I said earlier [2], this patch is not wrong, it is just not needed in v5.9 because the "Fixes" commit
010b430d5df5("mptcp:MPTCP_IPV6should depend on IPV6 instead of selecting it") is not in v5.9.I guess it is certainly easier to keep it because it is not wrong and doesn't hurt.
I dropped a wrong patch by accident :(
Fixing this up... Thanks for pointing it out!
Signature · 2 lines
Thanks, Sasha
Greg Kroah-Hartman
maintainerPATCH 581/757 netfilter: nf_fwd_netdev: clear timestamp in forwarding path
In reply to Greg Kroah-HartmanFrom: Pablo Neira Ayuso <[email protected]>
[ Upstream commit c77761c8a59405cb7aa44188b30fffe13fbdd02d ]
Similar to 7980d2eabde8 ("ipvs: clear skb->tstamp in forwarding path"). fq qdisc requires tstamp to be cleared in forwarding path.
--- net/netfilter/nf_dup_netdev.c | 1 + net/netfilter/nft_fwd_netdev.c | 1 + 2 files changed, 2 insertions(+)
net/netfilter/nf_dup_netdev.c +1 -0
@@ -19,6 +19,7 @@ static void nf_do_netdev_egress(struct sk_buff *skb, struct net_device *dev)skb_push (skb, skb->mac_len); skb->dev = dev; + skb->tstamp =0 ;dev_queue_xmit (skb); }
net/netfilter/nft_fwd_netdev.c +1 -0
@@ -138,6 +138,7 @@ static void nft_fwd_neigh_eval(const struct nft_expr *expr,return ; skb->dev = dev; + skb->tstamp =0 ;neigh_xmit (neigh_table, dev, addr, skb); out: regs->verdict.code = verdict;
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 582/757 soc: xilinx: Fix error code in zynqmp_pm_probe()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit a6f2f0fdc73aacc6e10ae48ae78634dba26702d4 ]
This should be returning PTR_ERR() but it returns IS_ERR() instead.
--- drivers/soc/xilinx/zynqmp_power.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/xilinx/zynqmp_power.c +1 -1
@@ -205,7 +205,7 @@ static int zynqmp_pm_probe(struct platform_device *pdev) rx_chan =mbox_request_channel_byname (client,"rx" );if (IS_ERR (rx_chan)) {dev_err (&pdev->dev,"Failed to request rx channel\n" ); -return IS_ERR (rx_chan); +return PTR_ERR (rx_chan); } }else if (of_find_property (pdev->dev.of_node,"interrupts" ,NULL )) { irq =platform_get_irq (pdev,0 );
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 583/757 arm64: dts: meson: vim3: correct led polarity
In reply to Greg Kroah-HartmanFrom: Jerome Brunet <[email protected]>
[ Upstream commit 1f9d87d08e4a2299e86f8a1600aedf87ecd3b636 ]
The LEDs on the vim3 are active when the gpio is high, not low.
--- arch/arm64/boot/dts/amlogic/meson-khadas-vim3.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/amlogic/meson-khadas-vim3.dtsi +2 -2
@@ -41,13 +41,13 @@ leds { led-white { label = "vim3:white:sys"; - gpios = <&gpio_ao GPIOAO_4 GPIO_ACTIVE_LOW>; + gpios = <&gpio_ao GPIOAO_4 GPIO_ACTIVE_HIGH>; linux,default-trigger = "heartbeat"; }; led-red { label = "vim3:red"; - gpios = <&gpio_expander 5 GPIO_ACTIVE_LOW>; + gpios = <&gpio_expander 5 GPIO_ACTIVE_HIGH>; }; };
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 584/757 ARM: dts: imx6sl: fix rng node
In reply to Greg Kroah-HartmanFrom: Horia Geantă <[email protected]>
[ Upstream commit 82ffb35c2ce63ef8e0325f75eb48022abcf8edbe ]
rng DT node was added without a compatible string.
i.MX driver for RNGC (drivers/char/hw_random/imx-rngc.c) also claims support for RNGB, and is currently used for i.MX25.
Let's use this driver also for RNGB block in i.MX6SL.
--- arch/arm/boot/dts/imx6sl.dtsi | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/boot/dts/imx6sl.dtsi +2 -0
@@ -939,8 +939,10 @@ memory-controller@21b0000 { }; rngb: rngb@21b4000 { + compatible = "fsl,imx6sl-rngb", "fsl,imx25-rngb"; reg = <0x021b4000 0x4000>; interrupts = <0 5 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&clks IMX6SL_CLK_DUMMY>; }; weim: weim@21b8000 {
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerPATCH 585/757 ARM: at91: pm: of_node_put() after its usage
In reply to Greg Kroah-HartmanFrom: Claudiu Beznea <[email protected]>
[ Upstream commit e222f943519564978e082c152b4140a47e93392c ]
Put node after it has been used.
--- arch/arm/mach-at91/pm.c | 1 + 1 file changed, 1 insertion(+)
arch/arm/mach-at91/pm.c +1 -0
@@ -800,6 +800,7 @@ static void __init at91_pm_init(void (*pm_idle)(void)) pmc_np =of_find_matching_node_and_match (NULL , atmel_pmc_ids, &of_id); soc_pm.data.pmc =of_iomap (pmc_np,0 ); +of_node_put (pmc_np);if (!soc_pm.data.pmc) {pr_err ("AT91: PM not supported, PMC not found\n" );return ;
Signature · 1 line
2.25.1