From: Greg Kroah-Hartman Date: Mon, 18 Apr 2022 09:57:52 +0000 (+0200) Subject: 5.10-stable patches X-Git-Tag: v4.9.311~15 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ee965f8c74a2213d2a6f3d251a540cb3ebb292ae;p=thirdparty%2Fkernel%2Fstable-queue.git 5.10-stable patches added patches: dma-direct-avoid-redundant-memory-sync-for-swiotlb.patch i2c-pasemi-wait-for-write-xfers-to-finish.patch smp-fix-offline-cpu-check-in-flush_smp_call_function_queue.patch timers-fix-warning-condition-in-__run_timers.patch --- diff --git a/queue-5.10/dma-direct-avoid-redundant-memory-sync-for-swiotlb.patch b/queue-5.10/dma-direct-avoid-redundant-memory-sync-for-swiotlb.patch new file mode 100644 index 00000000000..9d28d7b8a15 --- /dev/null +++ b/queue-5.10/dma-direct-avoid-redundant-memory-sync-for-swiotlb.patch @@ -0,0 +1,47 @@ +From 9e02977bfad006af328add9434c8bffa40e053bb Mon Sep 17 00:00:00 2001 +From: Chao Gao +Date: Wed, 13 Apr 2022 08:32:22 +0200 +Subject: dma-direct: avoid redundant memory sync for swiotlb + +From: Chao Gao + +commit 9e02977bfad006af328add9434c8bffa40e053bb upstream. + +When we looked into FIO performance with swiotlb enabled in VM, we found +swiotlb_bounce() is always called one more time than expected for each DMA +read request. + +It turns out that the bounce buffer is copied to original DMA buffer twice +after the completion of a DMA request (one is done by in +dma_direct_sync_single_for_cpu(), the other by swiotlb_tbl_unmap_single()). +But the content in bounce buffer actually doesn't change between the two +rounds of copy. So, one round of copy is redundant. + +Pass DMA_ATTR_SKIP_CPU_SYNC flag to swiotlb_tbl_unmap_single() to +skip the memory copy in it. + +This fix increases FIO 64KB sequential read throughput in a guest with +swiotlb=force by 5.6%. + +Fixes: 55897af63091 ("dma-direct: merge swiotlb_dma_ops into the dma_direct code") +Reported-by: Wang Zhaoyang1 +Reported-by: Gao Liang +Signed-off-by: Chao Gao +Reviewed-by: Kevin Tian +Signed-off-by: Christoph Hellwig +Signed-off-by: Greg Kroah-Hartman +--- + kernel/dma/direct.h | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/kernel/dma/direct.h ++++ b/kernel/dma/direct.h +@@ -114,6 +114,7 @@ static inline void dma_direct_unmap_page + dma_direct_sync_single_for_cpu(dev, addr, size, dir); + + if (unlikely(is_swiotlb_buffer(phys))) +- swiotlb_tbl_unmap_single(dev, phys, size, size, dir, attrs); ++ swiotlb_tbl_unmap_single(dev, phys, size, size, dir, ++ attrs | DMA_ATTR_SKIP_CPU_SYNC); + } + #endif /* _KERNEL_DMA_DIRECT_H */ diff --git a/queue-5.10/i2c-pasemi-wait-for-write-xfers-to-finish.patch b/queue-5.10/i2c-pasemi-wait-for-write-xfers-to-finish.patch new file mode 100644 index 00000000000..97aaa0006d8 --- /dev/null +++ b/queue-5.10/i2c-pasemi-wait-for-write-xfers-to-finish.patch @@ -0,0 +1,53 @@ +From bd8963e602c77adc76dbbbfc3417c3cf14fed76b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Martin=20Povi=C5=A1er?= +Date: Tue, 29 Mar 2022 20:38:17 +0200 +Subject: i2c: pasemi: Wait for write xfers to finish +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Martin Povišer + +commit bd8963e602c77adc76dbbbfc3417c3cf14fed76b upstream. + +Wait for completion of write transfers before returning from the driver. +At first sight it may seem advantageous to leave write transfers queued +for the controller to carry out on its own time, but there's a couple of +issues with it: + + * Driver doesn't check for FIFO space. + + * The queued writes can complete while the driver is in its I2C read + transfer path which means it will get confused by the raising of + XEN (the 'transaction ended' signal). This can cause a spurious + ENODATA error due to premature reading of the MRXFIFO register. + +Adding the wait fixes some unreliability issues with the driver. There's +some efficiency cost to it (especially with pasemi_smb_waitready doing +its polling), but that will be alleviated once the driver receives +interrupt support. + +Fixes: beb58aa39e6e ("i2c: PA Semi SMBus driver") +Signed-off-by: Martin Povišer +Reviewed-by: Sven Peter +Signed-off-by: Wolfram Sang +Signed-off-by: Greg Kroah-Hartman +--- + drivers/i2c/busses/i2c-pasemi.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +--- a/drivers/i2c/busses/i2c-pasemi.c ++++ b/drivers/i2c/busses/i2c-pasemi.c +@@ -137,6 +137,12 @@ static int pasemi_i2c_xfer_msg(struct i2 + + TXFIFO_WR(smbus, msg->buf[msg->len-1] | + (stop ? MTXFIFO_STOP : 0)); ++ ++ if (stop) { ++ err = pasemi_smb_waitready(smbus); ++ if (err) ++ goto reset_out; ++ } + } + + return 0; diff --git a/queue-5.10/series b/queue-5.10/series index aa19b4206b0..9c93c5e9ecb 100644 --- a/queue-5.10/series +++ b/queue-5.10/series @@ -89,3 +89,7 @@ genirq-affinity-consider-that-cpus-on-nodes-can-be-unbalanced.patch tick-nohz-use-warn_on_once-to-prevent-console-saturation.patch arm-davinci-da850-evm-avoid-null-pointer-dereference.patch dm-integrity-fix-memory-corruption-when-tag_size-is-less-than-digest-size.patch +smp-fix-offline-cpu-check-in-flush_smp_call_function_queue.patch +i2c-pasemi-wait-for-write-xfers-to-finish.patch +timers-fix-warning-condition-in-__run_timers.patch +dma-direct-avoid-redundant-memory-sync-for-swiotlb.patch diff --git a/queue-5.10/smp-fix-offline-cpu-check-in-flush_smp_call_function_queue.patch b/queue-5.10/smp-fix-offline-cpu-check-in-flush_smp_call_function_queue.patch new file mode 100644 index 00000000000..2aafb5feb6d --- /dev/null +++ b/queue-5.10/smp-fix-offline-cpu-check-in-flush_smp_call_function_queue.patch @@ -0,0 +1,42 @@ +From 9e949a3886356fe9112c6f6f34a6e23d1d35407f Mon Sep 17 00:00:00 2001 +From: Nadav Amit +Date: Sat, 19 Mar 2022 00:20:15 -0700 +Subject: smp: Fix offline cpu check in flush_smp_call_function_queue() + +From: Nadav Amit + +commit 9e949a3886356fe9112c6f6f34a6e23d1d35407f upstream. + +The check in flush_smp_call_function_queue() for callbacks that are sent +to offline CPUs currently checks whether the queue is empty. + +However, flush_smp_call_function_queue() has just deleted all the +callbacks from the queue and moved all the entries into a local list. +This checks would only be positive if some callbacks were added in the +short time after llist_del_all() was called. This does not seem to be +the intention of this check. + +Change the check to look at the local list to which the entries were +moved instead of the queue from which all the callbacks were just +removed. + +Fixes: 8d056c48e4862 ("CPU hotplug, smp: flush any pending IPI callbacks before CPU offline") +Signed-off-by: Nadav Amit +Signed-off-by: Thomas Gleixner +Link: https://lore.kernel.org/r/20220319072015.1495036-1-namit@vmware.com +Signed-off-by: Greg Kroah-Hartman +--- + kernel/smp.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/kernel/smp.c ++++ b/kernel/smp.c +@@ -346,7 +346,7 @@ static void flush_smp_call_function_queu + + /* There shouldn't be any pending callbacks on an offline CPU. */ + if (unlikely(warn_cpu_offline && !cpu_online(smp_processor_id()) && +- !warned && !llist_empty(head))) { ++ !warned && entry != NULL)) { + warned = true; + WARN(1, "IPI on offline CPU %d\n", smp_processor_id()); + diff --git a/queue-5.10/timers-fix-warning-condition-in-__run_timers.patch b/queue-5.10/timers-fix-warning-condition-in-__run_timers.patch new file mode 100644 index 00000000000..63b722770f9 --- /dev/null +++ b/queue-5.10/timers-fix-warning-condition-in-__run_timers.patch @@ -0,0 +1,50 @@ +From c54bc0fc84214b203f7a0ebfd1bd308ce2abe920 Mon Sep 17 00:00:00 2001 +From: Anna-Maria Behnsen +Date: Tue, 5 Apr 2022 21:17:32 +0200 +Subject: timers: Fix warning condition in __run_timers() + +From: Anna-Maria Behnsen + +commit c54bc0fc84214b203f7a0ebfd1bd308ce2abe920 upstream. + +When the timer base is empty, base::next_expiry is set to base::clk + +NEXT_TIMER_MAX_DELTA and base::next_expiry_recalc is false. When no timer +is queued until jiffies reaches base::next_expiry value, the warning for +not finding any expired timer and base::next_expiry_recalc is false in +__run_timers() triggers. + +To prevent triggering the warning in this valid scenario +base::timers_pending needs to be added to the warning condition. + +Fixes: 31cd0e119d50 ("timers: Recalculate next timer interrupt only when necessary") +Reported-by: Johannes Berg +Signed-off-by: Anna-Maria Behnsen +Signed-off-by: Thomas Gleixner +Reviewed-by: Frederic Weisbecker +Link: https://lore.kernel.org/r/20220405191732.7438-3-anna-maria@linutronix.de +Signed-off-by: Greg Kroah-Hartman +--- + kernel/time/timer.c | 11 +++++++---- + 1 file changed, 7 insertions(+), 4 deletions(-) + +--- a/kernel/time/timer.c ++++ b/kernel/time/timer.c +@@ -1738,11 +1738,14 @@ static inline void __run_timers(struct t + time_after_eq(jiffies, base->next_expiry)) { + levels = collect_expired_timers(base, heads); + /* +- * The only possible reason for not finding any expired +- * timer at this clk is that all matching timers have been +- * dequeued. ++ * The two possible reasons for not finding any expired ++ * timer at this clk are that all matching timers have been ++ * dequeued or no timer has been queued since ++ * base::next_expiry was set to base::clk + ++ * NEXT_TIMER_MAX_DELTA. + */ +- WARN_ON_ONCE(!levels && !base->next_expiry_recalc); ++ WARN_ON_ONCE(!levels && !base->next_expiry_recalc ++ && base->timers_pending); + base->clk++; + base->next_expiry = __next_timer_interrupt(base); +