From: Sasha Levin Date: Sat, 1 Oct 2022 22:03:38 +0000 (-0400) Subject: Fixes for 5.10 X-Git-Tag: v5.19.13~57 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=60be24592c0e49ce19e79155aa0bd20f886285ce;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 5.10 Signed-off-by: Sasha Levin --- diff --git a/queue-5.10/alsa-hda-fix-nvidia-dp-infoframe.patch b/queue-5.10/alsa-hda-fix-nvidia-dp-infoframe.patch new file mode 100644 index 00000000000..45403cd0883 --- /dev/null +++ b/queue-5.10/alsa-hda-fix-nvidia-dp-infoframe.patch @@ -0,0 +1,100 @@ +From db6de710826923c058afc745098f73d7be4a79f5 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 13 Sep 2022 12:28:18 +0530 +Subject: ALSA: hda: Fix Nvidia dp infoframe + +From: Mohan Kumar + +[ Upstream commit f89e409402e2aeb3bc3aa44d2b7a597959e4e6af ] + +Nvidia HDA HW expects infoframe data bytes order same for both +HDMI and DP i.e infoframe data starts from 5th bytes offset. As +dp infoframe structure has 4th byte as valid infoframe data, use +hdmi infoframe structure for nvidia dp infoframe to match HW behvaior. + +Signed-off-by: Mohan Kumar +Cc: +Link: https://lore.kernel.org/r/20220913065818.13015-1-mkumard@nvidia.com +Signed-off-by: Takashi Iwai +Signed-off-by: Sasha Levin +--- + sound/pci/hda/patch_hdmi.c | 23 +++++++++++++++++++---- + 1 file changed, 19 insertions(+), 4 deletions(-) + +diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c +index 6110370f874d..99dd31335f6a 100644 +--- a/sound/pci/hda/patch_hdmi.c ++++ b/sound/pci/hda/patch_hdmi.c +@@ -158,6 +158,8 @@ struct hdmi_spec { + bool dyn_pin_out; + bool dyn_pcm_assign; + bool dyn_pcm_no_legacy; ++ bool nv_dp_workaround; /* workaround DP audio infoframe for Nvidia */ ++ + bool intel_hsw_fixup; /* apply Intel platform-specific fixups */ + /* + * Non-generic VIA/NVIDIA specific +@@ -667,15 +669,24 @@ static void hdmi_pin_setup_infoframe(struct hda_codec *codec, + int ca, int active_channels, + int conn_type) + { ++ struct hdmi_spec *spec = codec->spec; + union audio_infoframe ai; + + memset(&ai, 0, sizeof(ai)); +- if (conn_type == 0) { /* HDMI */ ++ if ((conn_type == 0) || /* HDMI */ ++ /* Nvidia DisplayPort: Nvidia HW expects same layout as HDMI */ ++ (conn_type == 1 && spec->nv_dp_workaround)) { + struct hdmi_audio_infoframe *hdmi_ai = &ai.hdmi; + +- hdmi_ai->type = 0x84; +- hdmi_ai->ver = 0x01; +- hdmi_ai->len = 0x0a; ++ if (conn_type == 0) { /* HDMI */ ++ hdmi_ai->type = 0x84; ++ hdmi_ai->ver = 0x01; ++ hdmi_ai->len = 0x0a; ++ } else {/* Nvidia DP */ ++ hdmi_ai->type = 0x84; ++ hdmi_ai->ver = 0x1b; ++ hdmi_ai->len = 0x11 << 2; ++ } + hdmi_ai->CC02_CT47 = active_channels - 1; + hdmi_ai->CA = ca; + hdmi_checksum_audio_infoframe(hdmi_ai); +@@ -3526,6 +3537,7 @@ static int patch_nvhdmi_2ch(struct hda_codec *codec) + spec->pcm_playback.rates = SUPPORTED_RATES; + spec->pcm_playback.maxbps = SUPPORTED_MAXBPS; + spec->pcm_playback.formats = SUPPORTED_FORMATS; ++ spec->nv_dp_workaround = true; + return 0; + } + +@@ -3665,6 +3677,7 @@ static int patch_nvhdmi(struct hda_codec *codec) + spec->chmap.ops.chmap_cea_alloc_validate_get_type = + nvhdmi_chmap_cea_alloc_validate_get_type; + spec->chmap.ops.chmap_validate = nvhdmi_chmap_validate; ++ spec->nv_dp_workaround = true; + + codec->link_down_at_suspend = 1; + +@@ -3688,6 +3701,7 @@ static int patch_nvhdmi_legacy(struct hda_codec *codec) + spec->chmap.ops.chmap_cea_alloc_validate_get_type = + nvhdmi_chmap_cea_alloc_validate_get_type; + spec->chmap.ops.chmap_validate = nvhdmi_chmap_validate; ++ spec->nv_dp_workaround = true; + + codec->link_down_at_suspend = 1; + +@@ -3861,6 +3875,7 @@ static int patch_tegra_hdmi(struct hda_codec *codec) + spec->chmap.ops.chmap_cea_alloc_validate_get_type = + nvhdmi_chmap_cea_alloc_validate_get_type; + spec->chmap.ops.chmap_validate = nvhdmi_chmap_validate; ++ spec->nv_dp_workaround = true; + + return 0; + } +-- +2.35.1 + diff --git a/queue-5.10/alsa-hda-hdmi-let-new-platforms-assign-the-pcm-slot-.patch b/queue-5.10/alsa-hda-hdmi-let-new-platforms-assign-the-pcm-slot-.patch new file mode 100644 index 00000000000..6608a3ed0b6 --- /dev/null +++ b/queue-5.10/alsa-hda-hdmi-let-new-platforms-assign-the-pcm-slot-.patch @@ -0,0 +1,89 @@ +From 5f942a8563f450334b902bc1140209ec313cb8b2 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 1 Mar 2021 19:12:02 +0800 +Subject: ALSA: hda/hdmi: let new platforms assign the pcm slot dynamically + +From: Hui Wang + +[ Upstream commit 13046370c4d143b629adc1a51659a8a6497fbbe6 ] + +If the platform set the dyn_pcm_assign to true, it will call +hdmi_find_pcm_slot() to find a pcm slot when hdmi/dp monitor is +connected and need to create a pcm. + +So far only intel_hsw_common_init() and patch_nvhdmi() set the +dyn_pcm_assign to true, here we let tgl platforms assign the pcm slot +dynamically first, if the driver runs for a period of time and there +is no regression reported, we could set no_fixed_assgin to true in +the intel_hsw_common_init(), and then set it to true in the +patch_nvhdmi(). + +This change comes from the discussion between Takashi and +Kai Vehmanen. Please refer to: +https://github.com/alsa-project/alsa-lib/pull/118 + +Suggested-and-reviewed-by: Takashi Iwai +Suggested-and-reviewed-by: Kai Vehmanen +Signed-off-by: Hui Wang +Link: https://lore.kernel.org/r/20210301111202.2684-1-hui.wang@canonical.com +Signed-off-by: Takashi Iwai +Stable-dep-of: f89e409402e2 ("ALSA: hda: Fix Nvidia dp infoframe") +Signed-off-by: Sasha Levin +--- + sound/pci/hda/patch_hdmi.c | 18 +++++++++++++++++- + 1 file changed, 17 insertions(+), 1 deletion(-) + +diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c +index 7551cdf3b452..6110370f874d 100644 +--- a/sound/pci/hda/patch_hdmi.c ++++ b/sound/pci/hda/patch_hdmi.c +@@ -157,6 +157,7 @@ struct hdmi_spec { + + bool dyn_pin_out; + bool dyn_pcm_assign; ++ bool dyn_pcm_no_legacy; + bool intel_hsw_fixup; /* apply Intel platform-specific fixups */ + /* + * Non-generic VIA/NVIDIA specific +@@ -1348,6 +1349,12 @@ static int hdmi_find_pcm_slot(struct hdmi_spec *spec, + { + int i; + ++ /* on the new machines, try to assign the pcm slot dynamically, ++ * not use the preferred fixed map (legacy way) anymore. ++ */ ++ if (spec->dyn_pcm_no_legacy) ++ goto last_try; ++ + /* + * generic_hdmi_build_pcms() may allocate extra PCMs on some + * platforms (with maximum of 'num_nids + dev_num - 1') +@@ -1377,6 +1384,7 @@ static int hdmi_find_pcm_slot(struct hdmi_spec *spec, + return i; + } + ++ last_try: + /* the last try; check the empty slots in pins */ + for (i = 0; i < spec->num_nids; i++) { + if (!test_bit(i, &spec->pcm_bitmap)) +@@ -3010,8 +3018,16 @@ static int patch_i915_tgl_hdmi(struct hda_codec *codec) + * the index indicate the port number. + */ + static const int map[] = {0x4, 0x6, 0x8, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf}; ++ int ret; + +- return intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map)); ++ ret = intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map)); ++ if (!ret) { ++ struct hdmi_spec *spec = codec->spec; ++ ++ spec->dyn_pcm_no_legacy = true; ++ } ++ ++ return ret; + } + + /* Intel Baytrail and Braswell; with eld notifier */ +-- +2.35.1 + diff --git a/queue-5.10/alsa-hda-tegra-reset-hardware.patch b/queue-5.10/alsa-hda-tegra-reset-hardware.patch new file mode 100644 index 00000000000..77117210f6d --- /dev/null +++ b/queue-5.10/alsa-hda-tegra-reset-hardware.patch @@ -0,0 +1,86 @@ +From 5f6eac8eafc1590a4088a562b7e76ff4a8553029 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 20 Jan 2021 03:31:50 +0300 +Subject: ALSA: hda/tegra: Reset hardware + +From: Dmitry Osipenko + +[ Upstream commit 87f0e46e7559beb6f1d1ff99f8f48b1b9d86db52 ] + +Reset hardware on RPM-resume in order to bring it into a predictable +state. + +Tested-by: Peter Geis # Ouya T30 audio works +Tested-by: Matt Merhar # Ouya T30 boot-tested +Tested-by: Nicolas Chauvet # TK1 boot-tested +Signed-off-by: Dmitry Osipenko +Link: https://lore.kernel.org/r/20210120003154.26749-3-digetx@gmail.com +Signed-off-by: Takashi Iwai +Stable-dep-of: f89e409402e2 ("ALSA: hda: Fix Nvidia dp infoframe") +Signed-off-by: Sasha Levin +--- + sound/pci/hda/hda_tegra.c | 20 ++++++++++++++++++++ + 1 file changed, 20 insertions(+) + +diff --git a/sound/pci/hda/hda_tegra.c b/sound/pci/hda/hda_tegra.c +index 957a7a9aaab0..17b06f7b69ee 100644 +--- a/sound/pci/hda/hda_tegra.c ++++ b/sound/pci/hda/hda_tegra.c +@@ -17,6 +17,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -70,6 +71,7 @@ + struct hda_tegra { + struct azx chip; + struct device *dev; ++ struct reset_control *reset; + struct clk_bulk_data clocks[3]; + unsigned int nclocks; + void __iomem *regs; +@@ -167,6 +169,12 @@ static int __maybe_unused hda_tegra_runtime_resume(struct device *dev) + struct hda_tegra *hda = container_of(chip, struct hda_tegra, chip); + int rc; + ++ if (!chip->running) { ++ rc = reset_control_assert(hda->reset); ++ if (rc) ++ return rc; ++ } ++ + rc = clk_bulk_prepare_enable(hda->nclocks, hda->clocks); + if (rc != 0) + return rc; +@@ -176,6 +184,12 @@ static int __maybe_unused hda_tegra_runtime_resume(struct device *dev) + /* disable controller wake up event*/ + azx_writew(chip, WAKEEN, azx_readw(chip, WAKEEN) & + ~STATESTS_INT_MASK); ++ } else { ++ usleep_range(10, 100); ++ ++ rc = reset_control_deassert(hda->reset); ++ if (rc) ++ return rc; + } + + return 0; +@@ -445,6 +459,12 @@ static int hda_tegra_probe(struct platform_device *pdev) + return err; + } + ++ hda->reset = devm_reset_control_array_get_exclusive(&pdev->dev); ++ if (IS_ERR(hda->reset)) { ++ err = PTR_ERR(hda->reset); ++ goto out_free; ++ } ++ + hda->clocks[hda->nclocks++].id = "hda"; + hda->clocks[hda->nclocks++].id = "hda2hdmi"; + hda->clocks[hda->nclocks++].id = "hda2codec_2x"; +-- +2.35.1 + diff --git a/queue-5.10/alsa-hda-tegra-use-clk_bulk-helpers.patch b/queue-5.10/alsa-hda-tegra-use-clk_bulk-helpers.patch new file mode 100644 index 00000000000..0a0f091a35c --- /dev/null +++ b/queue-5.10/alsa-hda-tegra-use-clk_bulk-helpers.patch @@ -0,0 +1,143 @@ +From 7007e94fd43de31de34799a0827070d2223464c3 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 20 Jan 2021 03:31:49 +0300 +Subject: ALSA: hda/tegra: Use clk_bulk helpers + +From: Dmitry Osipenko + +[ Upstream commit 3a465f027a33cbd2af74f882ad41729583195e8f ] + +Use clk_bulk helpers to make code cleaner. Note that this patch changed +the order in which clocks are enabled to make code look nicer, but this +doesn't matter in terms of hardware. + +Tested-by: Peter Geis # Ouya T30 audio works +Tested-by: Matt Merhar # Ouya T30 boot-tested +Tested-by: Nicolas Chauvet # TK1 boot-tested +Acked-by: Thierry Reding +Signed-off-by: Dmitry Osipenko +Link: https://lore.kernel.org/r/20210120003154.26749-2-digetx@gmail.com +Signed-off-by: Takashi Iwai +Stable-dep-of: f89e409402e2 ("ALSA: hda: Fix Nvidia dp infoframe") +Signed-off-by: Sasha Levin +--- + sound/pci/hda/hda_tegra.c | 68 ++++++--------------------------------- + 1 file changed, 9 insertions(+), 59 deletions(-) + +diff --git a/sound/pci/hda/hda_tegra.c b/sound/pci/hda/hda_tegra.c +index 1e44e337986e..957a7a9aaab0 100644 +--- a/sound/pci/hda/hda_tegra.c ++++ b/sound/pci/hda/hda_tegra.c +@@ -70,9 +70,8 @@ + struct hda_tegra { + struct azx chip; + struct device *dev; +- struct clk *hda_clk; +- struct clk *hda2codec_2x_clk; +- struct clk *hda2hdmi_clk; ++ struct clk_bulk_data clocks[3]; ++ unsigned int nclocks; + void __iomem *regs; + struct work_struct probe_work; + }; +@@ -113,36 +112,6 @@ static void hda_tegra_init(struct hda_tegra *hda) + writel(v, hda->regs + HDA_IPFS_INTR_MASK); + } + +-static int hda_tegra_enable_clocks(struct hda_tegra *data) +-{ +- int rc; +- +- rc = clk_prepare_enable(data->hda_clk); +- if (rc) +- return rc; +- rc = clk_prepare_enable(data->hda2codec_2x_clk); +- if (rc) +- goto disable_hda; +- rc = clk_prepare_enable(data->hda2hdmi_clk); +- if (rc) +- goto disable_codec_2x; +- +- return 0; +- +-disable_codec_2x: +- clk_disable_unprepare(data->hda2codec_2x_clk); +-disable_hda: +- clk_disable_unprepare(data->hda_clk); +- return rc; +-} +- +-static void hda_tegra_disable_clocks(struct hda_tegra *data) +-{ +- clk_disable_unprepare(data->hda2hdmi_clk); +- clk_disable_unprepare(data->hda2codec_2x_clk); +- clk_disable_unprepare(data->hda_clk); +-} +- + /* + * power management + */ +@@ -186,7 +155,7 @@ static int __maybe_unused hda_tegra_runtime_suspend(struct device *dev) + azx_stop_chip(chip); + azx_enter_link_reset(chip); + } +- hda_tegra_disable_clocks(hda); ++ clk_bulk_disable_unprepare(hda->nclocks, hda->clocks); + + return 0; + } +@@ -198,7 +167,7 @@ static int __maybe_unused hda_tegra_runtime_resume(struct device *dev) + struct hda_tegra *hda = container_of(chip, struct hda_tegra, chip); + int rc; + +- rc = hda_tegra_enable_clocks(hda); ++ rc = clk_bulk_prepare_enable(hda->nclocks, hda->clocks); + if (rc != 0) + return rc; + if (chip && chip->running) { +@@ -268,29 +237,6 @@ static int hda_tegra_init_chip(struct azx *chip, struct platform_device *pdev) + return 0; + } + +-static int hda_tegra_init_clk(struct hda_tegra *hda) +-{ +- struct device *dev = hda->dev; +- +- hda->hda_clk = devm_clk_get(dev, "hda"); +- if (IS_ERR(hda->hda_clk)) { +- dev_err(dev, "failed to get hda clock\n"); +- return PTR_ERR(hda->hda_clk); +- } +- hda->hda2codec_2x_clk = devm_clk_get(dev, "hda2codec_2x"); +- if (IS_ERR(hda->hda2codec_2x_clk)) { +- dev_err(dev, "failed to get hda2codec_2x clock\n"); +- return PTR_ERR(hda->hda2codec_2x_clk); +- } +- hda->hda2hdmi_clk = devm_clk_get(dev, "hda2hdmi"); +- if (IS_ERR(hda->hda2hdmi_clk)) { +- dev_err(dev, "failed to get hda2hdmi clock\n"); +- return PTR_ERR(hda->hda2hdmi_clk); +- } +- +- return 0; +-} +- + static int hda_tegra_first_init(struct azx *chip, struct platform_device *pdev) + { + struct hda_tegra *hda = container_of(chip, struct hda_tegra, chip); +@@ -499,7 +445,11 @@ static int hda_tegra_probe(struct platform_device *pdev) + return err; + } + +- err = hda_tegra_init_clk(hda); ++ hda->clocks[hda->nclocks++].id = "hda"; ++ hda->clocks[hda->nclocks++].id = "hda2hdmi"; ++ hda->clocks[hda->nclocks++].id = "hda2codec_2x"; ++ ++ err = devm_clk_bulk_get(&pdev->dev, hda->nclocks, hda->clocks); + if (err < 0) + goto out_free; + +-- +2.35.1 + diff --git a/queue-5.10/btrfs-fix-hang-during-unmount-when-stopping-a-space-.patch b/queue-5.10/btrfs-fix-hang-during-unmount-when-stopping-a-space-.patch new file mode 100644 index 00000000000..f3487704746 --- /dev/null +++ b/queue-5.10/btrfs-fix-hang-during-unmount-when-stopping-a-space-.patch @@ -0,0 +1,165 @@ +From b1c77b8165ebf027f4c962d3262f8d45a3fe25c0 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 8 Sep 2022 12:31:51 +0100 +Subject: btrfs: fix hang during unmount when stopping a space reclaim worker + +From: Filipe Manana + +[ Upstream commit a362bb864b8db4861977d00bd2c3222503ccc34b ] + +Often when running generic/562 from fstests we can hang during unmount, +resulting in a trace like this: + + Sep 07 11:52:00 debian9 unknown: run fstests generic/562 at 2022-09-07 11:52:00 + Sep 07 11:55:32 debian9 kernel: INFO: task umount:49438 blocked for more than 120 seconds. + Sep 07 11:55:32 debian9 kernel: Not tainted 6.0.0-rc2-btrfs-next-122 #1 + Sep 07 11:55:32 debian9 kernel: "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. + Sep 07 11:55:32 debian9 kernel: task:umount state:D stack: 0 pid:49438 ppid: 25683 flags:0x00004000 + Sep 07 11:55:32 debian9 kernel: Call Trace: + Sep 07 11:55:32 debian9 kernel: + Sep 07 11:55:32 debian9 kernel: __schedule+0x3c8/0xec0 + Sep 07 11:55:32 debian9 kernel: ? rcu_read_lock_sched_held+0x12/0x70 + Sep 07 11:55:32 debian9 kernel: schedule+0x5d/0xf0 + Sep 07 11:55:32 debian9 kernel: schedule_timeout+0xf1/0x130 + Sep 07 11:55:32 debian9 kernel: ? lock_release+0x224/0x4a0 + Sep 07 11:55:32 debian9 kernel: ? lock_acquired+0x1a0/0x420 + Sep 07 11:55:32 debian9 kernel: ? trace_hardirqs_on+0x2c/0xd0 + Sep 07 11:55:32 debian9 kernel: __wait_for_common+0xac/0x200 + Sep 07 11:55:32 debian9 kernel: ? usleep_range_state+0xb0/0xb0 + Sep 07 11:55:32 debian9 kernel: __flush_work+0x26d/0x530 + Sep 07 11:55:32 debian9 kernel: ? flush_workqueue_prep_pwqs+0x140/0x140 + Sep 07 11:55:32 debian9 kernel: ? trace_clock_local+0xc/0x30 + Sep 07 11:55:32 debian9 kernel: __cancel_work_timer+0x11f/0x1b0 + Sep 07 11:55:32 debian9 kernel: ? close_ctree+0x12b/0x5b3 [btrfs] + Sep 07 11:55:32 debian9 kernel: ? __trace_bputs+0x10b/0x170 + Sep 07 11:55:32 debian9 kernel: close_ctree+0x152/0x5b3 [btrfs] + Sep 07 11:55:32 debian9 kernel: ? evict_inodes+0x166/0x1c0 + Sep 07 11:55:32 debian9 kernel: generic_shutdown_super+0x71/0x120 + Sep 07 11:55:32 debian9 kernel: kill_anon_super+0x14/0x30 + Sep 07 11:55:32 debian9 kernel: btrfs_kill_super+0x12/0x20 [btrfs] + Sep 07 11:55:32 debian9 kernel: deactivate_locked_super+0x2e/0xa0 + Sep 07 11:55:32 debian9 kernel: cleanup_mnt+0x100/0x160 + Sep 07 11:55:32 debian9 kernel: task_work_run+0x59/0xa0 + Sep 07 11:55:32 debian9 kernel: exit_to_user_mode_prepare+0x1a6/0x1b0 + Sep 07 11:55:32 debian9 kernel: syscall_exit_to_user_mode+0x16/0x40 + Sep 07 11:55:32 debian9 kernel: do_syscall_64+0x48/0x90 + Sep 07 11:55:32 debian9 kernel: entry_SYSCALL_64_after_hwframe+0x63/0xcd + Sep 07 11:55:32 debian9 kernel: RIP: 0033:0x7fcde59a57a7 + Sep 07 11:55:32 debian9 kernel: RSP: 002b:00007ffe914217c8 EFLAGS: 00000246 ORIG_RAX: 00000000000000a6 + Sep 07 11:55:32 debian9 kernel: RAX: 0000000000000000 RBX: 00007fcde5ae8264 RCX: 00007fcde59a57a7 + Sep 07 11:55:32 debian9 kernel: RDX: 0000000000000000 RSI: 0000000000000000 RDI: 000055b57556cdd0 + Sep 07 11:55:32 debian9 kernel: RBP: 000055b57556cba0 R08: 0000000000000000 R09: 00007ffe91420570 + Sep 07 11:55:32 debian9 kernel: R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 + Sep 07 11:55:32 debian9 kernel: R13: 000055b57556cdd0 R14: 000055b57556ccb8 R15: 0000000000000000 + Sep 07 11:55:32 debian9 kernel: + +What happens is the following: + +1) The cleaner kthread tries to start a transaction to delete an unused + block group, but the metadata reservation can not be satisfied right + away, so a reservation ticket is created and it starts the async + metadata reclaim task (fs_info->async_reclaim_work); + +2) Writeback for all the filler inodes with an i_size of 2K starts + (generic/562 creates a lot of 2K files with the goal of filling + metadata space). We try to create an inline extent for them, but we + fail when trying to insert the inline extent with -ENOSPC (at + cow_file_range_inline()) - since this is not critical, we fallback + to non-inline mode (back to cow_file_range()), reserve extents, create + extent maps and create the ordered extents; + +3) An unmount starts, enters close_ctree(); + +4) The async reclaim task is flushing stuff, entering the flush states one + by one, until it reaches RUN_DELAYED_IPUTS. There it runs all current + delayed iputs. + + After running the delayed iputs and before calling + btrfs_wait_on_delayed_iputs(), one or more ordered extents complete, + and btrfs_add_delayed_iput() is called for each one through + btrfs_finish_ordered_io() -> btrfs_put_ordered_extent(). This results + in bumping fs_info->nr_delayed_iputs from 0 to some positive value. + + So the async reclaim task blocks at btrfs_wait_on_delayed_iputs() waiting + for fs_info->nr_delayed_iputs to become 0; + +5) The current transaction is committed by the transaction kthread, we then + start unpinning extents and end up calling btrfs_try_granting_tickets() + through unpin_extent_range(), since we released some space. + This results in satisfying the ticket created by the cleaner kthread at + step 1, waking up the cleaner kthread; + +6) At close_ctree() we ask the cleaner kthread to park; + +7) The cleaner kthread starts the transaction, deletes the unused block + group, and then calls kthread_should_park(), which returns true, so it + parks. And at this point we have the delayed iputs added by the + completion of the ordered extents still pending; + +8) Then later at close_ctree(), when we call: + + cancel_work_sync(&fs_info->async_reclaim_work); + + We hang forever, since the cleaner was parked and no one else can run + delayed iputs after that, while the reclaim task is waiting for the + remaining delayed iputs to be completed. + +Fix this by waiting for all ordered extents to complete and running the +delayed iputs before attempting to stop the async reclaim tasks. Note that +we can not wait for ordered extents with btrfs_wait_ordered_roots() (or +other similar functions) because that waits for the BTRFS_ORDERED_COMPLETE +flag to be set on an ordered extent, but the delayed iput is added after +that, when doing the final btrfs_put_ordered_extent(). So instead wait for +the work queues used for executing ordered extent completion to be empty, +which works because we do the final put on an ordered extent at +btrfs_finish_ordered_io() (while we are in the unmount context). + +Fixes: d6fd0ae25c6495 ("Btrfs: fix missing delayed iputs on unmount") +CC: stable@vger.kernel.org # 5.15+ +Reviewed-by: Josef Bacik +Signed-off-by: Filipe Manana +Signed-off-by: David Sterba +Signed-off-by: Sasha Levin +--- + fs/btrfs/disk-io.c | 25 +++++++++++++++++++++++++ + 1 file changed, 25 insertions(+) + +diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c +index 2c7e50980a70..f2abd8bfd4a0 100644 +--- a/fs/btrfs/disk-io.c ++++ b/fs/btrfs/disk-io.c +@@ -4105,6 +4105,31 @@ void __cold close_ctree(struct btrfs_fs_info *fs_info) + /* clear out the rbtree of defraggable inodes */ + btrfs_cleanup_defrag_inodes(fs_info); + ++ /* ++ * After we parked the cleaner kthread, ordered extents may have ++ * completed and created new delayed iputs. If one of the async reclaim ++ * tasks is running and in the RUN_DELAYED_IPUTS flush state, then we ++ * can hang forever trying to stop it, because if a delayed iput is ++ * added after it ran btrfs_run_delayed_iputs() and before it called ++ * btrfs_wait_on_delayed_iputs(), it will hang forever since there is ++ * no one else to run iputs. ++ * ++ * So wait for all ongoing ordered extents to complete and then run ++ * delayed iputs. This works because once we reach this point no one ++ * can either create new ordered extents nor create delayed iputs ++ * through some other means. ++ * ++ * Also note that btrfs_wait_ordered_roots() is not safe here, because ++ * it waits for BTRFS_ORDERED_COMPLETE to be set on an ordered extent, ++ * but the delayed iput for the respective inode is made only when doing ++ * the final btrfs_put_ordered_extent() (which must happen at ++ * btrfs_finish_ordered_io() when we are unmounting). ++ */ ++ btrfs_flush_workqueue(fs_info->endio_write_workers); ++ /* Ordered extents for free space inodes. */ ++ btrfs_flush_workqueue(fs_info->endio_freespace_worker); ++ btrfs_run_delayed_iputs(fs_info); ++ + cancel_work_sync(&fs_info->async_reclaim_work); + cancel_work_sync(&fs_info->async_data_reclaim_work); + +-- +2.35.1 + diff --git a/queue-5.10/series b/queue-5.10/series new file mode 100644 index 00000000000..daf79d3941c --- /dev/null +++ b/queue-5.10/series @@ -0,0 +1,7 @@ +thunderbolt-add-support-for-intel-maple-ridge.patch +thunderbolt-add-support-for-intel-maple-ridge-single.patch +alsa-hda-tegra-use-clk_bulk-helpers.patch +alsa-hda-tegra-reset-hardware.patch +alsa-hda-hdmi-let-new-platforms-assign-the-pcm-slot-.patch +alsa-hda-fix-nvidia-dp-infoframe.patch +btrfs-fix-hang-during-unmount-when-stopping-a-space-.patch diff --git a/queue-5.10/thunderbolt-add-support-for-intel-maple-ridge-single.patch b/queue-5.10/thunderbolt-add-support-for-intel-maple-ridge-single.patch new file mode 100644 index 00000000000..0c92e5dfa3b --- /dev/null +++ b/queue-5.10/thunderbolt-add-support-for-intel-maple-ridge-single.patch @@ -0,0 +1,49 @@ +From ccd301367f2fb2aedc4ae5e3894580255682f1f2 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 8 Sep 2022 13:43:20 +0300 +Subject: thunderbolt: Add support for Intel Maple Ridge single port controller + +From: Gil Fine + +[ Upstream commit 14c7d905283744809e6b82efae2f490660a11cda ] + +Add support for Maple Ridge discrete USB4 host controller from Intel +which has a single USB4 port (versus the already supported dual port +Maple Ridge USB4 host controller). + +Cc: stable@vger.kernel.org +Signed-off-by: Gil Fine +Signed-off-by: Mika Westerberg +Signed-off-by: Sasha Levin +--- + drivers/thunderbolt/icm.c | 1 + + drivers/thunderbolt/nhi.h | 1 + + 2 files changed, 2 insertions(+) + +diff --git a/drivers/thunderbolt/icm.c b/drivers/thunderbolt/icm.c +index fa24ea8cae75..b2fb3397310e 100644 +--- a/drivers/thunderbolt/icm.c ++++ b/drivers/thunderbolt/icm.c +@@ -2301,6 +2301,7 @@ struct tb *icm_probe(struct tb_nhi *nhi) + tb->cm_ops = &icm_icl_ops; + break; + ++ case PCI_DEVICE_ID_INTEL_MAPLE_RIDGE_2C_NHI: + case PCI_DEVICE_ID_INTEL_MAPLE_RIDGE_4C_NHI: + icm->is_supported = icm_tgl_is_supported; + icm->get_mode = icm_ar_get_mode; +diff --git a/drivers/thunderbolt/nhi.h b/drivers/thunderbolt/nhi.h +index 69770beca792..7ad6d3f0583b 100644 +--- a/drivers/thunderbolt/nhi.h ++++ b/drivers/thunderbolt/nhi.h +@@ -55,6 +55,7 @@ extern const struct tb_nhi_ops icl_nhi_ops; + * need for the PCI quirk anymore as we will use ICM also on Apple + * hardware. + */ ++#define PCI_DEVICE_ID_INTEL_MAPLE_RIDGE_2C_NHI 0x1134 + #define PCI_DEVICE_ID_INTEL_MAPLE_RIDGE_4C_NHI 0x1137 + #define PCI_DEVICE_ID_INTEL_WIN_RIDGE_2C_NHI 0x157d + #define PCI_DEVICE_ID_INTEL_WIN_RIDGE_2C_BRIDGE 0x157e +-- +2.35.1 + diff --git a/queue-5.10/thunderbolt-add-support-for-intel-maple-ridge.patch b/queue-5.10/thunderbolt-add-support-for-intel-maple-ridge.patch new file mode 100644 index 00000000000..234dab8a88f --- /dev/null +++ b/queue-5.10/thunderbolt-add-support-for-intel-maple-ridge.patch @@ -0,0 +1,58 @@ +From 437c65c4bd49459a47344985e66cd3e2375291bf Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 31 Jan 2020 19:24:30 +0300 +Subject: thunderbolt: Add support for Intel Maple Ridge + +From: Mika Westerberg + +[ Upstream commit db0746e3399ee87ee5f957880811da16faa89fb8 ] + +Maple Ridge is first discrete USB4 host controller from Intel. It comes +with firmware based connection manager and the flows are similar as used +in Intel Titan Ridge. + +Signed-off-by: Mika Westerberg +Stable-dep-of: 14c7d9052837 ("thunderbolt: Add support for Intel Maple Ridge single port controller") +Signed-off-by: Sasha Levin +--- + drivers/thunderbolt/icm.c | 11 +++++++++++ + drivers/thunderbolt/nhi.h | 1 + + 2 files changed, 12 insertions(+) + +diff --git a/drivers/thunderbolt/icm.c b/drivers/thunderbolt/icm.c +index 82c46b200c34..fa24ea8cae75 100644 +--- a/drivers/thunderbolt/icm.c ++++ b/drivers/thunderbolt/icm.c +@@ -2300,6 +2300,17 @@ struct tb *icm_probe(struct tb_nhi *nhi) + icm->rtd3_veto = icm_icl_rtd3_veto; + tb->cm_ops = &icm_icl_ops; + break; ++ ++ case PCI_DEVICE_ID_INTEL_MAPLE_RIDGE_4C_NHI: ++ icm->is_supported = icm_tgl_is_supported; ++ icm->get_mode = icm_ar_get_mode; ++ icm->driver_ready = icm_tr_driver_ready; ++ icm->device_connected = icm_tr_device_connected; ++ icm->device_disconnected = icm_tr_device_disconnected; ++ icm->xdomain_connected = icm_tr_xdomain_connected; ++ icm->xdomain_disconnected = icm_tr_xdomain_disconnected; ++ tb->cm_ops = &icm_tr_ops; ++ break; + } + + if (!icm->is_supported || !icm->is_supported(tb)) { +diff --git a/drivers/thunderbolt/nhi.h b/drivers/thunderbolt/nhi.h +index 4e0861d75072..69770beca792 100644 +--- a/drivers/thunderbolt/nhi.h ++++ b/drivers/thunderbolt/nhi.h +@@ -55,6 +55,7 @@ extern const struct tb_nhi_ops icl_nhi_ops; + * need for the PCI quirk anymore as we will use ICM also on Apple + * hardware. + */ ++#define PCI_DEVICE_ID_INTEL_MAPLE_RIDGE_4C_NHI 0x1137 + #define PCI_DEVICE_ID_INTEL_WIN_RIDGE_2C_NHI 0x157d + #define PCI_DEVICE_ID_INTEL_WIN_RIDGE_2C_BRIDGE 0x157e + #define PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_LP_NHI 0x15bf +-- +2.35.1 +