]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.15-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 15 May 2023 12:49:09 +0000 (14:49 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 15 May 2023 12:49:09 +0000 (14:49 +0200)
added patches:
drbd-correctly-submit-flush-bio-on-barrier.patch
risc-v-fix-up-a-cherry-pick-warning-in-setup_vm_final.patch
serial-8250-fix-serial8250_tx_empty-race-with-dma-tx.patch

queue-5.15/drbd-correctly-submit-flush-bio-on-barrier.patch [new file with mode: 0644]
queue-5.15/risc-v-fix-up-a-cherry-pick-warning-in-setup_vm_final.patch [new file with mode: 0644]
queue-5.15/serial-8250-fix-serial8250_tx_empty-race-with-dma-tx.patch [new file with mode: 0644]
queue-5.15/series

diff --git a/queue-5.15/drbd-correctly-submit-flush-bio-on-barrier.patch b/queue-5.15/drbd-correctly-submit-flush-bio-on-barrier.patch
new file mode 100644 (file)
index 0000000..3213a36
--- /dev/null
@@ -0,0 +1,49 @@
+From 3899d94e3831ee07ea6821c032dc297aec80586a Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Christoph=20B=C3=B6hmwalder?=
+ <christoph.boehmwalder@linbit.com>
+Date: Wed, 3 May 2023 14:19:37 +0200
+Subject: drbd: correctly submit flush bio on barrier
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Christoph Böhmwalder <christoph.boehmwalder@linbit.com>
+
+commit 3899d94e3831ee07ea6821c032dc297aec80586a upstream.
+
+When we receive a flush command (or "barrier" in DRBD), we currently use
+a REQ_OP_FLUSH with the REQ_PREFLUSH flag set.
+
+The correct way to submit a flush bio is by using a REQ_OP_WRITE without
+any data, and set the REQ_PREFLUSH flag.
+
+Since commit b4a6bb3a67aa ("block: add a sanity check for non-write
+flush/fua bios"), this triggers a warning in the block layer, but this
+has been broken for quite some time before that.
+
+So use the correct set of flags to actually make the flush happen.
+
+Cc: Christoph Hellwig <hch@infradead.org>
+Cc: stable@vger.kernel.org
+Fixes: f9ff0da56437 ("drbd: allow parallel flushes for multi-volume resources")
+Reported-by: Thomas Voegtle <tv@lio96.de>
+Signed-off-by: Christoph Böhmwalder <christoph.boehmwalder@linbit.com>
+Reviewed-by: Christoph Hellwig <hch@lst.de>
+Link: https://lore.kernel.org/r/20230503121937.17232-1-christoph.boehmwalder@linbit.com
+Signed-off-by: Jens Axboe <axboe@kernel.dk>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/block/drbd/drbd_receiver.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/block/drbd/drbd_receiver.c
++++ b/drivers/block/drbd/drbd_receiver.c
+@@ -1301,7 +1301,7 @@ static void submit_one_flush(struct drbd
+       bio_set_dev(bio, device->ldev->backing_bdev);
+       bio->bi_private = octx;
+       bio->bi_end_io = one_flush_endio;
+-      bio->bi_opf = REQ_OP_FLUSH | REQ_PREFLUSH;
++      bio->bi_opf = REQ_OP_WRITE | REQ_PREFLUSH;
+       device->flush_jif = jiffies;
+       set_bit(FLUSH_PENDING, &device->flags);
diff --git a/queue-5.15/risc-v-fix-up-a-cherry-pick-warning-in-setup_vm_final.patch b/queue-5.15/risc-v-fix-up-a-cherry-pick-warning-in-setup_vm_final.patch
new file mode 100644 (file)
index 0000000..acd1806
--- /dev/null
@@ -0,0 +1,47 @@
+From alexghiti@rivosinc.com  Mon May 15 14:41:21 2023
+From: Alexandre Ghiti <alexghiti@rivosinc.com>
+Date: Tue,  9 May 2023 14:51:41 +0200
+Subject: RISC-V: Fix up a cherry-pick warning in setup_vm_final()
+To: stable@vger.kernel.org
+Cc: Alexandre Ghiti <alexghiti@rivosinc.com>, kernel test robot <lkp@intel.com>, Palmer Dabbelt <palmer@rivosinc.com>
+Message-ID: <20230509125141.95587-1-alexghiti@rivosinc.com>
+
+
+This triggers a -Wdeclaration-after-statement as the code has changed a
+bit since upstream.  It might be better to hoist the whole block up, but
+this is a smaller change so I went with it.
+
+arch/riscv/mm/init.c:755:16: warning: mixing declarations and code is a C99 extension [-Wdeclaration-after-statement]
+             unsigned long idx = pgd_index(__fix_to_virt(FIX_FDT));
+                           ^
+     1 warning generated.
+
+Fixes: bbf94b042155 ("riscv: Move early dtb mapping into the fixmap region")
+Reported-by: kernel test robot <lkp@intel.com>
+Link: https://lore.kernel.org/oe-kbuild-all/202304300429.SXZOA5up-lkp@intel.com/
+Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
+Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/riscv/mm/init.c |    3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+--- a/arch/riscv/mm/init.c
++++ b/arch/riscv/mm/init.c
+@@ -714,6 +714,7 @@ static void __init setup_vm_final(void)
+ {
+       uintptr_t va, map_size;
+       phys_addr_t pa, start, end;
++      unsigned long idx __maybe_unused;
+       u64 i;
+       /**
+@@ -733,7 +734,7 @@ static void __init setup_vm_final(void)
+        * directly in swapper_pg_dir in addition to the pgd entry that points
+        * to fixmap_pte.
+        */
+-      unsigned long idx = pgd_index(__fix_to_virt(FIX_FDT));
++      idx = pgd_index(__fix_to_virt(FIX_FDT));
+       set_pgd(&swapper_pg_dir[idx], early_pg_dir[idx]);
+ #endif
diff --git a/queue-5.15/serial-8250-fix-serial8250_tx_empty-race-with-dma-tx.patch b/queue-5.15/serial-8250-fix-serial8250_tx_empty-race-with-dma-tx.patch
new file mode 100644 (file)
index 0000000..bd0a512
--- /dev/null
@@ -0,0 +1,97 @@
+From 146a37e05d620cef4ad430e5d1c9c077fe6fa76f Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= <ilpo.jarvinen@linux.intel.com>
+Date: Fri, 17 Mar 2023 13:33:18 +0200
+Subject: serial: 8250: Fix serial8250_tx_empty() race with DMA Tx
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
+
+commit 146a37e05d620cef4ad430e5d1c9c077fe6fa76f upstream.
+
+There's a potential race before THRE/TEMT deasserts when DMA Tx is
+starting up (or the next batch of continuous Tx is being submitted).
+This can lead to misdetecting Tx empty condition.
+
+It is entirely normal for THRE/TEMT to be set for some time after the
+DMA Tx had been setup in serial8250_tx_dma(). As Tx side is definitely
+not empty at that point, it seems incorrect for serial8250_tx_empty()
+claim Tx is empty.
+
+Fix the race by also checking in serial8250_tx_empty() whether there's
+DMA Tx active.
+
+Note: This fix only addresses in-kernel race mainly to make using
+TCSADRAIN/FLUSH robust. Userspace can still cause other races but they
+seem userspace concurrency control problems.
+
+Fixes: 9ee4b83e51f74 ("serial: 8250: Add support for dmaengine")
+Cc: stable@vger.kernel.org
+Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
+Link: https://lore.kernel.org/r/20230317113318.31327-3-ilpo.jarvinen@linux.intel.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/tty/serial/8250/8250.h      |   12 ++++++++++++
+ drivers/tty/serial/8250/8250_port.c |   12 +++++++++---
+ 2 files changed, 21 insertions(+), 3 deletions(-)
+
+--- a/drivers/tty/serial/8250/8250.h
++++ b/drivers/tty/serial/8250/8250.h
+@@ -349,6 +349,13 @@ static inline void serial8250_do_prepare
+       if (dma->prepare_rx_dma)
+               dma->prepare_rx_dma(p);
+ }
++
++static inline bool serial8250_tx_dma_running(struct uart_8250_port *p)
++{
++      struct uart_8250_dma *dma = p->dma;
++
++      return dma && dma->tx_running;
++}
+ #else
+ static inline int serial8250_tx_dma(struct uart_8250_port *p)
+ {
+@@ -364,6 +371,11 @@ static inline int serial8250_request_dma
+       return -1;
+ }
+ static inline void serial8250_release_dma(struct uart_8250_port *p) { }
++
++static inline bool serial8250_tx_dma_running(struct uart_8250_port *p)
++{
++      return false;
++}
+ #endif
+ static inline int ns16550a_goto_highspeed(struct uart_8250_port *up)
+--- a/drivers/tty/serial/8250/8250_port.c
++++ b/drivers/tty/serial/8250/8250_port.c
+@@ -1988,19 +1988,25 @@ static int serial8250_tx_threshold_handl
+ static unsigned int serial8250_tx_empty(struct uart_port *port)
+ {
+       struct uart_8250_port *up = up_to_u8250p(port);
++      unsigned int result = 0;
+       unsigned long flags;
+       unsigned int lsr;
+       serial8250_rpm_get(up);
+       spin_lock_irqsave(&port->lock, flags);
+-      lsr = serial_port_in(port, UART_LSR);
+-      up->lsr_saved_flags |= lsr & LSR_SAVE_FLAGS;
++      if (!serial8250_tx_dma_running(up)) {
++              lsr = serial_port_in(port, UART_LSR);
++              up->lsr_saved_flags |= lsr & LSR_SAVE_FLAGS;
++
++              if ((lsr & BOTH_EMPTY) == BOTH_EMPTY)
++                      result = TIOCSER_TEMT;
++      }
+       spin_unlock_irqrestore(&port->lock, flags);
+       serial8250_rpm_put(up);
+-      return (lsr & BOTH_EMPTY) == BOTH_EMPTY ? TIOCSER_TEMT : 0;
++      return result;
+ }
+ unsigned int serial8250_do_get_mctrl(struct uart_port *port)
index bc2d905454d8b8a1b3b5790a02109e7b974ed72e..4a81fa648d7554431bd3d19279bd7738b1fba922 100644 (file)
@@ -128,3 +128,6 @@ ext4-bail-out-of-ext4_xattr_ibody_get-fails-for-any-reason.patch
 ext4-remove-a-bug_on-in-ext4_mb_release_group_pa.patch
 ext4-fix-invalid-free-tracking-in-ext4_xattr_move_to_block.patch
 drm-msm-adreno-adreno_gpu-use-suspend-instead-of-idle-on-load-error.patch
+serial-8250-fix-serial8250_tx_empty-race-with-dma-tx.patch
+drbd-correctly-submit-flush-bio-on-barrier.patch
+risc-v-fix-up-a-cherry-pick-warning-in-setup_vm_final.patch