]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.17-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 25 Apr 2022 12:51:46 +0000 (14:51 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 25 Apr 2022 12:51:46 +0000 (14:51 +0200)
added patches:
asoc-sof-topology-cleanup-dailinks-on-widget-unload.patch
jbd2-fix-a-potential-race-while-discarding-reserved-buffers-after-an-abort.patch
spi-atmel-quadspi-fix-the-buswidth-adjustment-between-spi-mem-and-controller.patch

queue-5.17/asoc-sof-topology-cleanup-dailinks-on-widget-unload.patch [new file with mode: 0644]
queue-5.17/jbd2-fix-a-potential-race-while-discarding-reserved-buffers-after-an-abort.patch [new file with mode: 0644]
queue-5.17/series
queue-5.17/spi-atmel-quadspi-fix-the-buswidth-adjustment-between-spi-mem-and-controller.patch [new file with mode: 0644]

diff --git a/queue-5.17/asoc-sof-topology-cleanup-dailinks-on-widget-unload.patch b/queue-5.17/asoc-sof-topology-cleanup-dailinks-on-widget-unload.patch
new file mode 100644 (file)
index 0000000..9d5aa7e
--- /dev/null
@@ -0,0 +1,88 @@
+From 20744617bdbafe2e7fb7bf5401f616e24bde4471 Mon Sep 17 00:00:00 2001
+From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
+Date: Wed, 6 Apr 2022 14:16:06 -0500
+Subject: ASoC: SOF: topology: cleanup dailinks on widget unload
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
+
+commit 20744617bdbafe2e7fb7bf5401f616e24bde4471 upstream.
+
+We set the cpu_dai capture_ or playback_widget on widget_ready but
+never clear them, which leads to failures when unloading/reloading a
+topology in modprobe/rmmod tests
+
+BugLink: https://github.com/thesofproject/linux/issues/3535
+Fixes: 311ce4fe7637 ("ASoC: SOF: Add support for loading topologies")
+Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
+Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
+Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
+Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
+Link: https://lore.kernel.org/r/20220406191606.254576-1-pierre-louis.bossart@linux.intel.com
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ sound/soc/sof/topology.c |   43 +++++++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 43 insertions(+)
+
+--- a/sound/soc/sof/topology.c
++++ b/sound/soc/sof/topology.c
+@@ -1569,6 +1569,46 @@ static int sof_widget_load_buffer(struct
+       return 0;
+ }
++static void sof_disconnect_dai_widget(struct snd_soc_component *scomp,
++                                    struct snd_soc_dapm_widget *w)
++{
++      struct snd_soc_card *card = scomp->card;
++      struct snd_soc_pcm_runtime *rtd;
++      struct snd_soc_dai *cpu_dai;
++      int i;
++
++      if (!w->sname)
++              return;
++
++      list_for_each_entry(rtd, &card->rtd_list, list) {
++              /* does stream match DAI link ? */
++              if (!rtd->dai_link->stream_name ||
++                  strcmp(w->sname, rtd->dai_link->stream_name))
++                      continue;
++
++              switch (w->id) {
++              case snd_soc_dapm_dai_out:
++                      for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
++                              if (cpu_dai->capture_widget == w) {
++                                      cpu_dai->capture_widget = NULL;
++                                      break;
++                              }
++                      }
++                      break;
++              case snd_soc_dapm_dai_in:
++                      for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
++                              if (cpu_dai->playback_widget == w) {
++                                      cpu_dai->playback_widget = NULL;
++                                      break;
++                              }
++                      }
++                      break;
++              default:
++                      break;
++              }
++      }
++}
++
+ /* bind PCM ID to host component ID */
+ static int spcm_bind(struct snd_soc_component *scomp, struct snd_sof_pcm *spcm,
+                    int dir)
+@@ -2449,6 +2489,9 @@ static int sof_widget_unload(struct snd_
+                       kfree(dai->dai_config);
+                       list_del(&dai->list);
+               }
++
++              sof_disconnect_dai_widget(scomp, widget);
++
+               break;
+       default:
+               break;
diff --git a/queue-5.17/jbd2-fix-a-potential-race-while-discarding-reserved-buffers-after-an-abort.patch b/queue-5.17/jbd2-fix-a-potential-race-while-discarding-reserved-buffers-after-an-abort.patch
new file mode 100644 (file)
index 0000000..26f87e2
--- /dev/null
@@ -0,0 +1,116 @@
+From 23e3d7f7061f8682c751c46512718f47580ad8f0 Mon Sep 17 00:00:00 2001
+From: Ye Bin <yebin10@huawei.com>
+Date: Thu, 17 Mar 2022 22:21:37 +0800
+Subject: jbd2: fix a potential race while discarding reserved buffers after an abort
+
+From: Ye Bin <yebin10@huawei.com>
+
+commit 23e3d7f7061f8682c751c46512718f47580ad8f0 upstream.
+
+we got issue as follows:
+[   72.796117] EXT4-fs error (device sda): ext4_journal_check_start:83: comm fallocate: Detected aborted journal
+[   72.826847] EXT4-fs (sda): Remounting filesystem read-only
+fallocate: fallocate failed: Read-only file system
+[   74.791830] jbd2_journal_commit_transaction: jh=0xffff9cfefe725d90 bh=0x0000000000000000 end delay
+[   74.793597] ------------[ cut here ]------------
+[   74.794203] kernel BUG at fs/jbd2/transaction.c:2063!
+[   74.794886] invalid opcode: 0000 [#1] PREEMPT SMP PTI
+[   74.795533] CPU: 4 PID: 2260 Comm: jbd2/sda-8 Not tainted 5.17.0-rc8-next-20220315-dirty #150
+[   74.798327] RIP: 0010:__jbd2_journal_unfile_buffer+0x3e/0x60
+[   74.801971] RSP: 0018:ffffa828c24a3cb8 EFLAGS: 00010202
+[   74.802694] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
+[   74.803601] RDX: 0000000000000001 RSI: ffff9cfefe725d90 RDI: ffff9cfefe725d90
+[   74.804554] RBP: ffff9cfefe725d90 R08: 0000000000000000 R09: ffffa828c24a3b20
+[   74.805471] R10: 0000000000000001 R11: 0000000000000001 R12: ffff9cfefe725d90
+[   74.806385] R13: ffff9cfefe725d98 R14: 0000000000000000 R15: ffff9cfe833a4d00
+[   74.807301] FS:  0000000000000000(0000) GS:ffff9d01afb00000(0000) knlGS:0000000000000000
+[   74.808338] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
+[   74.809084] CR2: 00007f2b81bf4000 CR3: 0000000100056000 CR4: 00000000000006e0
+[   74.810047] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
+[   74.810981] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
+[   74.811897] Call Trace:
+[   74.812241]  <TASK>
+[   74.812566]  __jbd2_journal_refile_buffer+0x12f/0x180
+[   74.813246]  jbd2_journal_refile_buffer+0x4c/0xa0
+[   74.813869]  jbd2_journal_commit_transaction.cold+0xa1/0x148
+[   74.817550]  kjournald2+0xf8/0x3e0
+[   74.819056]  kthread+0x153/0x1c0
+[   74.819963]  ret_from_fork+0x22/0x30
+
+Above issue may happen as follows:
+        write                   truncate                   kjournald2
+generic_perform_write
+ ext4_write_begin
+  ext4_walk_page_buffers
+   do_journal_get_write_access ->add BJ_Reserved list
+ ext4_journalled_write_end
+  ext4_walk_page_buffers
+   write_end_fn
+    ext4_handle_dirty_metadata
+                ***************JBD2 ABORT**************
+     jbd2_journal_dirty_metadata
+ -> return -EROFS, jh in reserved_list
+                                                   jbd2_journal_commit_transaction
+                                                    while (commit_transaction->t_reserved_list)
+                                                      jh = commit_transaction->t_reserved_list;
+                        truncate_pagecache_range
+                         do_invalidatepage
+                         ext4_journalled_invalidatepage
+                          jbd2_journal_invalidatepage
+                           journal_unmap_buffer
+                            __dispose_buffer
+                             __jbd2_journal_unfile_buffer
+                              jbd2_journal_put_journal_head ->put last ref_count
+                               __journal_remove_journal_head
+                                bh->b_private = NULL;
+                                jh->b_bh = NULL;
+                                                     jbd2_journal_refile_buffer(journal, jh);
+                                                       bh = jh2bh(jh);
+                                                       ->bh is NULL, later will trigger null-ptr-deref
+                                journal_free_journal_head(jh);
+
+After commit 96f1e0974575, we no longer hold the j_state_lock while
+iterating over the list of reserved handles in
+jbd2_journal_commit_transaction().  This potentially allows the
+journal_head to be freed by journal_unmap_buffer while the commit
+codepath is also trying to free the BJ_Reserved buffers.  Keeping
+j_state_lock held while trying extends hold time of the lock
+minimally, and solves this issue.
+
+Fixes: 96f1e0974575("jbd2: avoid long hold times of j_state_lock while committing a transaction")
+Signed-off-by: Ye Bin <yebin10@huawei.com>
+Reviewed-by: Jan Kara <jack@suse.cz>
+Link: https://lore.kernel.org/r/20220317142137.1821590-1-yebin10@huawei.com
+Signed-off-by: Theodore Ts'o <tytso@mit.edu>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/jbd2/commit.c |    4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+--- a/fs/jbd2/commit.c
++++ b/fs/jbd2/commit.c
+@@ -488,7 +488,6 @@ void jbd2_journal_commit_transaction(jou
+       jbd2_journal_wait_updates(journal);
+       commit_transaction->t_state = T_SWITCH;
+-      write_unlock(&journal->j_state_lock);
+       J_ASSERT (atomic_read(&commit_transaction->t_outstanding_credits) <=
+                       journal->j_max_transaction_buffers);
+@@ -508,6 +507,8 @@ void jbd2_journal_commit_transaction(jou
+        * has reserved.  This is consistent with the existing behaviour
+        * that multiple jbd2_journal_get_write_access() calls to the same
+        * buffer are perfectly permissible.
++       * We use journal->j_state_lock here to serialize processing of
++       * t_reserved_list with eviction of buffers from journal_unmap_buffer().
+        */
+       while (commit_transaction->t_reserved_list) {
+               jh = commit_transaction->t_reserved_list;
+@@ -527,6 +528,7 @@ void jbd2_journal_commit_transaction(jou
+               jbd2_journal_refile_buffer(journal, jh);
+       }
++      write_unlock(&journal->j_state_lock);
+       /*
+        * Now try to drop any written-back buffers from the journal's
+        * checkpoint lists.  We do this *before* commit because it potentially
index f320eff02b63f8fbb81a11ae88895a71720a3107..5510093a86e75f9672b6dabfe55e5a4cb651b86b 100644 (file)
@@ -139,3 +139,6 @@ ext4-doc-fix-incorrect-h_reserved-size.patch
 ext4-fix-overhead-calculation-to-account-for-the-reserved-gdt-blocks.patch
 ext4-force-overhead-calculation-if-the-s_overhead_cluster-makes-no-sense.patch
 ext4-update-the-cached-overhead-value-in-the-superblock.patch
+jbd2-fix-a-potential-race-while-discarding-reserved-buffers-after-an-abort.patch
+spi-atmel-quadspi-fix-the-buswidth-adjustment-between-spi-mem-and-controller.patch
+asoc-sof-topology-cleanup-dailinks-on-widget-unload.patch
diff --git a/queue-5.17/spi-atmel-quadspi-fix-the-buswidth-adjustment-between-spi-mem-and-controller.patch b/queue-5.17/spi-atmel-quadspi-fix-the-buswidth-adjustment-between-spi-mem-and-controller.patch
new file mode 100644 (file)
index 0000000..4df3f04
--- /dev/null
@@ -0,0 +1,34 @@
+From 8c235cc25087495c4288d94f547e9d3061004991 Mon Sep 17 00:00:00 2001
+From: Tudor Ambarus <tudor.ambarus@microchip.com>
+Date: Wed, 6 Apr 2022 16:36:03 +0300
+Subject: spi: atmel-quadspi: Fix the buswidth adjustment between spi-mem and controller
+
+From: Tudor Ambarus <tudor.ambarus@microchip.com>
+
+commit 8c235cc25087495c4288d94f547e9d3061004991 upstream.
+
+Use the spi_mem_default_supports_op() core helper in order to take into
+account the buswidth specified by the user in device tree.
+
+Cc: <stable@vger.kernel.org>
+Fixes: 0e6aae08e9ae ("spi: Add QuadSPI driver for Atmel SAMA5D2")
+Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
+Link: https://lore.kernel.org/r/20220406133604.455356-1-tudor.ambarus@microchip.com
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/spi/atmel-quadspi.c |    3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/drivers/spi/atmel-quadspi.c
++++ b/drivers/spi/atmel-quadspi.c
+@@ -277,6 +277,9 @@ static int atmel_qspi_find_mode(const st
+ static bool atmel_qspi_supports_op(struct spi_mem *mem,
+                                  const struct spi_mem_op *op)
+ {
++      if (!spi_mem_default_supports_op(mem, op))
++              return false;
++
+       if (atmel_qspi_find_mode(op) < 0)
+               return false;