From: Sasha Levin Date: Sat, 5 Oct 2024 18:29:09 +0000 (-0400) Subject: Fixes for 6.11 X-Git-Tag: v6.6.55~149 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=056c4d2b7cc6a7f89562d76321d05d3e1875b9e6;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 6.11 Signed-off-by: Sasha Levin --- diff --git a/queue-6.11/alsa-gus-fix-some-error-handling-paths-related-to-ge.patch b/queue-6.11/alsa-gus-fix-some-error-handling-paths-related-to-ge.patch new file mode 100644 index 00000000000..95ae1a28240 --- /dev/null +++ b/queue-6.11/alsa-gus-fix-some-error-handling-paths-related-to-ge.patch @@ -0,0 +1,46 @@ +From e9c1f8b4fbc40c49804e1686a1d8aa826590322c Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 3 Oct 2024 21:34:01 +0200 +Subject: ALSA: gus: Fix some error handling paths related to get_bpos() usage + +From: Christophe JAILLET + +[ Upstream commit 9df39a872c462ea07a3767ebd0093c42b2ff78a2 ] + +If get_bpos() fails, it is likely that the corresponding error code should +be returned. + +Fixes: a6970bb1dd99 ("ALSA: gus: Convert to the new PCM ops") +Signed-off-by: Christophe JAILLET +Link: https://patch.msgid.link/d9ca841edad697154afa97c73a5d7a14919330d9.1727984008.git.christophe.jaillet@wanadoo.fr +Signed-off-by: Takashi Iwai +Signed-off-by: Sasha Levin +--- + sound/isa/gus/gus_pcm.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/sound/isa/gus/gus_pcm.c b/sound/isa/gus/gus_pcm.c +index 850544725da79..d55c3dc229c0e 100644 +--- a/sound/isa/gus/gus_pcm.c ++++ b/sound/isa/gus/gus_pcm.c +@@ -378,7 +378,7 @@ static int snd_gf1_pcm_playback_copy(struct snd_pcm_substream *substream, + + bpos = get_bpos(pcmp, voice, pos, len); + if (bpos < 0) +- return pos; ++ return bpos; + if (copy_from_iter(runtime->dma_area + bpos, len, src) != len) + return -EFAULT; + return playback_copy_ack(substream, bpos, len); +@@ -395,7 +395,7 @@ static int snd_gf1_pcm_playback_silence(struct snd_pcm_substream *substream, + + bpos = get_bpos(pcmp, voice, pos, len); + if (bpos < 0) +- return pos; ++ return bpos; + snd_pcm_format_set_silence(runtime->format, runtime->dma_area + bpos, + bytes_to_samples(runtime, count)); + return playback_copy_ack(substream, bpos, len); +-- +2.43.0 + diff --git a/queue-6.11/alsa-hda-conexant-fix-conflicting-quirk-for-system76.patch b/queue-6.11/alsa-hda-conexant-fix-conflicting-quirk-for-system76.patch new file mode 100644 index 00000000000..6ccf1c511b6 --- /dev/null +++ b/queue-6.11/alsa-hda-conexant-fix-conflicting-quirk-for-system76.patch @@ -0,0 +1,72 @@ +From 2e338cdae382b305553d5f3349bb2a265d782e7a Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 4 Oct 2024 10:25:58 +0200 +Subject: ALSA: hda/conexant: Fix conflicting quirk for System76 Pangolin + +From: Takashi Iwai + +[ Upstream commit b3ebb007060f89d5a45c9b99f06a55e36a1945b5 ] + +We received a regression report for System76 Pangolin (pang14) due to +the recent fix for Tuxedo Sirius devices to support the top speaker. +The reason was the conflicting PCI SSID, as often seen. + +As a workaround, now the codec SSID is checked and the quirk is +applied conditionally only to Sirius devices. + +Fixes: 4178d78cd7a8 ("ALSA: hda/conexant: Add pincfg quirk to enable top speakers on Sirius devices") +Reported-by: Christian Heusel +Reported-by: Jerry +Closes: https://lore.kernel.org/c930b6a6-64e5-498f-b65a-1cd5e0a1d733@heusel.eu +Link: https://patch.msgid.link/20241004082602.29016-1-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Sasha Levin +--- + sound/pci/hda/patch_conexant.c | 24 +++++++++++++++++++----- + 1 file changed, 19 insertions(+), 5 deletions(-) + +diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c +index e851785ff0581..4a2c8274c3df7 100644 +--- a/sound/pci/hda/patch_conexant.c ++++ b/sound/pci/hda/patch_conexant.c +@@ -816,6 +816,23 @@ static const struct hda_pintbl cxt_pincfg_sws_js201d[] = { + {} + }; + ++/* pincfg quirk for Tuxedo Sirius; ++ * unfortunately the (PCI) SSID conflicts with System76 Pangolin pang14, ++ * which has incompatible pin setup, so we check the codec SSID (luckily ++ * different one!) and conditionally apply the quirk here ++ */ ++static void cxt_fixup_sirius_top_speaker(struct hda_codec *codec, ++ const struct hda_fixup *fix, ++ int action) ++{ ++ /* ignore for incorrectly picked-up pang14 */ ++ if (codec->core.subsystem_id == 0x278212b3) ++ return; ++ /* set up the top speaker pin */ ++ if (action == HDA_FIXUP_ACT_PRE_PROBE) ++ snd_hda_codec_set_pincfg(codec, 0x1d, 0x82170111); ++} ++ + static const struct hda_fixup cxt_fixups[] = { + [CXT_PINCFG_LENOVO_X200] = { + .type = HDA_FIXUP_PINS, +@@ -976,11 +993,8 @@ static const struct hda_fixup cxt_fixups[] = { + .v.pins = cxt_pincfg_sws_js201d, + }, + [CXT_PINCFG_TOP_SPEAKER] = { +- .type = HDA_FIXUP_PINS, +- .v.pins = (const struct hda_pintbl[]) { +- { 0x1d, 0x82170111 }, +- { } +- }, ++ .type = HDA_FIXUP_FUNC, ++ .v.func = cxt_fixup_sirius_top_speaker, + }, + }; + +-- +2.43.0 + diff --git a/queue-6.11/alsa-hda-generic-unconditionally-prefer-preferred_da.patch b/queue-6.11/alsa-hda-generic-unconditionally-prefer-preferred_da.patch new file mode 100644 index 00000000000..d58dca32b80 --- /dev/null +++ b/queue-6.11/alsa-hda-generic-unconditionally-prefer-preferred_da.patch @@ -0,0 +1,60 @@ +From 9104317316ac9c7817b35431e22a0f17d9bc03fe Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 1 Oct 2024 14:14:36 +0200 +Subject: ALSA: hda/generic: Unconditionally prefer preferred_dacs pairs + +From: Takashi Iwai + +[ Upstream commit 1c801e7f77445bc56e5e1fec6191fd4503534787 ] + +Some time ago, we introduced the obey_preferred_dacs flag for choosing +the DAC/pin pairs specified by the driver instead of parsing the +paths. This works as expected, per se, but there have been a few +cases where we forgot to set this flag while preferred_dacs table is +already set up. It ended up with incorrect wiring and made us +wondering why it doesn't work. + +Basically, when the preferred_dacs table is provided, it means that +the driver really wants to wire up to follow that. That is, the +presence of the preferred_dacs table itself is already a "do-it" +flag. + +In this patch, we simply replace the evaluation of obey_preferred_dacs +flag with the presence of preferred_dacs table for fixing the +misbehavior. Another patch to drop of the obsoleted flag will +follow. + +Fixes: 242d990c158d ("ALSA: hda/generic: Add option to enforce preferred_dacs pairs") +Link: https://bugzilla.suse.com/show_bug.cgi?id=1219803 +Link: https://patch.msgid.link/20241001121439.26060-1-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Sasha Levin +--- + sound/pci/hda/hda_generic.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c +index 9cff87dfbecbb..b34d84fedcc8a 100644 +--- a/sound/pci/hda/hda_generic.c ++++ b/sound/pci/hda/hda_generic.c +@@ -1383,7 +1383,7 @@ static int try_assign_dacs(struct hda_codec *codec, int num_outs, + struct nid_path *path; + hda_nid_t pin = pins[i]; + +- if (!spec->obey_preferred_dacs) { ++ if (!spec->preferred_dacs) { + path = snd_hda_get_path_from_idx(codec, path_idx[i]); + if (path) { + badness += assign_out_path_ctls(codec, path); +@@ -1395,7 +1395,7 @@ static int try_assign_dacs(struct hda_codec *codec, int num_outs, + if (dacs[i]) { + if (is_dac_already_used(codec, dacs[i])) + badness += bad->shared_primary; +- } else if (spec->obey_preferred_dacs) { ++ } else if (spec->preferred_dacs) { + badness += BAD_NO_PRIMARY_DAC; + } + +-- +2.43.0 + diff --git a/queue-6.11/alsa-hda-realtek-fix-the-push-button-function-for-th.patch b/queue-6.11/alsa-hda-realtek-fix-the-push-button-function-for-th.patch new file mode 100644 index 00000000000..9351d176524 --- /dev/null +++ b/queue-6.11/alsa-hda-realtek-fix-the-push-button-function-for-th.patch @@ -0,0 +1,36 @@ +From d3a65ed8d4ef2ba4bab2cbc546096682316fecf4 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 30 Sep 2024 18:50:39 +0800 +Subject: ALSA: hda/realtek: Fix the push button function for the ALC257 + +From: Oder Chiou + +[ Upstream commit 05df9732a0894846c46d0062d4af535c5002799d ] + +The headset push button cannot work properly in case of the ALC257. +This patch reverted the previous commit to correct the side effect. + +Fixes: ef9718b3d54e ("ALSA: hda/realtek: Fix noise from speakers on Lenovo IdeaPad 3 15IAU7") +Signed-off-by: Oder Chiou +Link: https://patch.msgid.link/20240930105039.3473266-1-oder_chiou@realtek.com +Signed-off-by: Takashi Iwai +Signed-off-by: Sasha Levin +--- + sound/pci/hda/patch_realtek.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c +index 452c6e7c20e20..4035ec31e1baf 100644 +--- a/sound/pci/hda/patch_realtek.c ++++ b/sound/pci/hda/patch_realtek.c +@@ -586,6 +586,7 @@ static void alc_shutup_pins(struct hda_codec *codec) + switch (codec->core.vendor_id) { + case 0x10ec0236: + case 0x10ec0256: ++ case 0x10ec0257: + case 0x19e58326: + case 0x10ec0283: + case 0x10ec0285: +-- +2.43.0 + diff --git a/queue-6.11/alsa-mixer_oss-remove-some-incorrect-kfree_const-usa.patch b/queue-6.11/alsa-mixer_oss-remove-some-incorrect-kfree_const-usa.patch new file mode 100644 index 00000000000..734b47470be --- /dev/null +++ b/queue-6.11/alsa-mixer_oss-remove-some-incorrect-kfree_const-usa.patch @@ -0,0 +1,44 @@ +From 9290878e0b844b7998519ad2e0168edca11c7c42 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 26 Sep 2024 20:17:36 +0200 +Subject: ALSA: mixer_oss: Remove some incorrect kfree_const() usages + +From: Christophe JAILLET + +[ Upstream commit 368e4663c557de4a33f321b44e7eeec0a21b2e4e ] + +"assigned" and "assigned->name" are allocated in snd_mixer_oss_proc_write() +using kmalloc() and kstrdup(), so there is no point in using kfree_const() +to free these resources. + +Switch to the more standard kfree() to free these resources. + +This could avoid a memory leak. + +Fixes: 454f5ec1d2b7 ("ALSA: mixer: oss: Constify snd_mixer_oss_assign_table definition") +Signed-off-by: Christophe JAILLET +Link: https://patch.msgid.link/63ac20f64234b7c9ea87a7fa9baf41e8255852f7.1727374631.git.christophe.jaillet@wanadoo.fr +Signed-off-by: Takashi Iwai +Signed-off-by: Sasha Levin +--- + sound/core/oss/mixer_oss.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c +index 6a0508093ea68..81af725ea40e5 100644 +--- a/sound/core/oss/mixer_oss.c ++++ b/sound/core/oss/mixer_oss.c +@@ -901,8 +901,8 @@ static void snd_mixer_oss_slot_free(struct snd_mixer_oss_slot *chn) + struct slot *p = chn->private_data; + if (p) { + if (p->allocated && p->assigned) { +- kfree_const(p->assigned->name); +- kfree_const(p->assigned); ++ kfree(p->assigned->name); ++ kfree(p->assigned); + } + kfree(p); + } +-- +2.43.0 + diff --git a/queue-6.11/asoc-atmel-mchp-pdmc-skip-alsa-restoration-if-substr.patch b/queue-6.11/asoc-atmel-mchp-pdmc-skip-alsa-restoration-if-substr.patch new file mode 100644 index 00000000000..b0ae7bca038 --- /dev/null +++ b/queue-6.11/asoc-atmel-mchp-pdmc-skip-alsa-restoration-if-substr.patch @@ -0,0 +1,41 @@ +From 364d4be2c93701b2783e6318011bfb50d2c5788f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 24 Sep 2024 11:12:38 +0300 +Subject: ASoC: atmel: mchp-pdmc: Skip ALSA restoration if substream runtime is + uninitialized + +From: Andrei Simion + +[ Upstream commit 09cfc6a532d249a51d3af5022d37ebbe9c3d31f6 ] + +Update the driver to prevent alsa-restore.service from failing when +reading data from /var/lib/alsa/asound.state at boot. Ensure that the +restoration of ALSA mixer configurations is skipped if substream->runtime +is NULL. + +Fixes: 50291652af52 ("ASoC: atmel: mchp-pdmc: add PDMC driver") +Signed-off-by: Andrei Simion +Link: https://patch.msgid.link/20240924081237.50046-1-andrei.simion@microchip.com +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + sound/soc/atmel/mchp-pdmc.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/sound/soc/atmel/mchp-pdmc.c b/sound/soc/atmel/mchp-pdmc.c +index dcc4e14b3dde2..206bbb5aaab5d 100644 +--- a/sound/soc/atmel/mchp-pdmc.c ++++ b/sound/soc/atmel/mchp-pdmc.c +@@ -285,6 +285,9 @@ static int mchp_pdmc_chmap_ctl_put(struct snd_kcontrol *kcontrol, + if (!substream) + return -ENODEV; + ++ if (!substream->runtime) ++ return 0; /* just for avoiding error from alsactl restore */ ++ + map = mchp_pdmc_chmap_get(substream, info); + if (!map) + return -EINVAL; +-- +2.43.0 + diff --git a/queue-6.11/asoc-imx-card-set-card.owner-to-avoid-a-warning-call.patch b/queue-6.11/asoc-imx-card-set-card.owner-to-avoid-a-warning-call.patch new file mode 100644 index 00000000000..3c1379983c6 --- /dev/null +++ b/queue-6.11/asoc-imx-card-set-card.owner-to-avoid-a-warning-call.patch @@ -0,0 +1,46 @@ +From 7a45a1469d9ca27bd8d7f2b410134911eff4055e Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 2 Oct 2024 10:56:59 +0800 +Subject: ASoC: imx-card: Set card.owner to avoid a warning calltrace if SND=m + +From: Hui Wang + +[ Upstream commit 47d7d3fd72afc7dcd548806291793ee6f3848215 ] + +In most Linux distribution kernels, the SND is set to m, in such a +case, when booting the kernel on i.MX8MP EVK board, there is a +warning calltrace like below: + Call trace: + snd_card_init+0x484/0x4cc [snd] + snd_card_new+0x70/0xa8 [snd] + snd_soc_bind_card+0x310/0xbd0 [snd_soc_core] + snd_soc_register_card+0xf0/0x108 [snd_soc_core] + devm_snd_soc_register_card+0x4c/0xa4 [snd_soc_core] + +That is because the card.owner is not set, a warning calltrace is +raised in the snd_card_init() due to it. + +Fixes: aa736700f42f ("ASoC: imx-card: Add imx-card machine driver") +Signed-off-by: Hui Wang +Link: https://patch.msgid.link/20241002025659.723544-1-hui.wang@canonical.com +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + sound/soc/fsl/imx-card.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/sound/soc/fsl/imx-card.c b/sound/soc/fsl/imx-card.c +index 0e18ccabe28c3..ce0d8cec375a8 100644 +--- a/sound/soc/fsl/imx-card.c ++++ b/sound/soc/fsl/imx-card.c +@@ -713,6 +713,7 @@ static int imx_card_probe(struct platform_device *pdev) + + data->plat_data = plat_data; + data->card.dev = &pdev->dev; ++ data->card.owner = THIS_MODULE; + + dev_set_drvdata(&pdev->dev, &data->card); + snd_soc_card_set_drvdata(&data->card, data); +-- +2.43.0 + diff --git a/queue-6.11/asoc-intel-soc-acpi-intel-rpl-match-add-missing-empt.patch b/queue-6.11/asoc-intel-soc-acpi-intel-rpl-match-add-missing-empt.patch new file mode 100644 index 00000000000..20158c4306d --- /dev/null +++ b/queue-6.11/asoc-intel-soc-acpi-intel-rpl-match-add-missing-empt.patch @@ -0,0 +1,42 @@ +From 9343a7085394381b410e0474a82ea87026d04db2 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 1 Oct 2024 14:17:37 +0800 +Subject: ASoC: Intel: soc-acpi-intel-rpl-match: add missing empty item +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Bard Liao + +[ Upstream commit 5afc29ba44fdd1bcbad4e07246c395d946301580 ] + +There is no links_num in struct snd_soc_acpi_mach {}, and we test +!link->num_adr as a condition to end the loop in hda_sdw_machine_select(). +So an empty item in struct snd_soc_acpi_link_adr array is required. + +Fixes: 65ab45b90656 ("ASoC: Intel: soc-acpi: Add match entries for some cs42l43 laptops") +Signed-off-by: Bard Liao +Reviewed-by: Péter Ujfalusi +Reviewed-by: Charles Keepax +Link: https://patch.msgid.link/20241001061738.34854-2-yung-chuan.liao@linux.intel.com +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + sound/soc/intel/common/soc-acpi-intel-rpl-match.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/sound/soc/intel/common/soc-acpi-intel-rpl-match.c b/sound/soc/intel/common/soc-acpi-intel-rpl-match.c +index bc8817633b81b..b83ac2e6337cf 100644 +--- a/sound/soc/intel/common/soc-acpi-intel-rpl-match.c ++++ b/sound/soc/intel/common/soc-acpi-intel-rpl-match.c +@@ -198,6 +198,7 @@ static const struct snd_soc_acpi_link_adr rpl_cs42l43_l0[] = { + .num_adr = ARRAY_SIZE(cs42l43_0_adr), + .adr_d = cs42l43_0_adr, + }, ++ {} + }; + + static const struct snd_soc_acpi_link_adr rpl_sdca_3_in_1[] = { +-- +2.43.0 + diff --git a/queue-6.11/asoc-topology-fix-incorrect-addressing-assignments.patch b/queue-6.11/asoc-topology-fix-incorrect-addressing-assignments.patch new file mode 100644 index 00000000000..45f86b096eb --- /dev/null +++ b/queue-6.11/asoc-topology-fix-incorrect-addressing-assignments.patch @@ -0,0 +1,54 @@ +From eb4acd8aea3fb87abfc5e70595e3f2849a12c13b Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 14 Sep 2024 16:16:08 +0800 +Subject: ASoC: topology: Fix incorrect addressing assignments +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Tang Bin + +[ Upstream commit 85109780543b5100aba1d0842b6a7c3142be74d2 ] + +The variable 'kc' is handled in the function +soc_tplg_control_dbytes_create(), and 'kc->private_value' +is assigned to 'sbe', so In the function soc_tplg_dbytes_create(), +the right 'sbe' should be 'kc.private_value', the same logical error +in the function soc_tplg_dmixer_create(), thus fix them. + +Fixes: 0867278200f7 ("ASoC: topology: Unify code for creating standalone and widget bytes control") +Fixes: 4654ca7cc8d6 ("ASoC: topology: Unify code for creating standalone and widget mixer control") +Signed-off-by: Tang Bin +Reviewed-by: Amadeusz Sławiński +Link: https://patch.msgid.link/20240914081608.3514-1-tangbin@cmss.chinamobile.com +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + sound/soc/soc-topology.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c +index af5d42b57be7e..3d82570293b29 100644 +--- a/sound/soc/soc-topology.c ++++ b/sound/soc/soc-topology.c +@@ -889,7 +889,7 @@ static int soc_tplg_dbytes_create(struct soc_tplg *tplg, size_t size) + return ret; + + /* register dynamic object */ +- sbe = (struct soc_bytes_ext *)&kc.private_value; ++ sbe = (struct soc_bytes_ext *)kc.private_value; + + INIT_LIST_HEAD(&sbe->dobj.list); + sbe->dobj.type = SND_SOC_DOBJ_BYTES; +@@ -923,7 +923,7 @@ static int soc_tplg_dmixer_create(struct soc_tplg *tplg, size_t size) + return ret; + + /* register dynamic object */ +- sm = (struct soc_mixer_control *)&kc.private_value; ++ sm = (struct soc_mixer_control *)kc.private_value; + + INIT_LIST_HEAD(&sm->dobj.list); + sm->dobj.type = SND_SOC_DOBJ_MIXER; +-- +2.43.0 + diff --git a/queue-6.11/cifs-do-not-convert-delimiter-when-parsing-nfs-style.patch b/queue-6.11/cifs-do-not-convert-delimiter-when-parsing-nfs-style.patch new file mode 100644 index 00000000000..1a4d63bd75c --- /dev/null +++ b/queue-6.11/cifs-do-not-convert-delimiter-when-parsing-nfs-style.patch @@ -0,0 +1,48 @@ +From e87c5248002e56a9ccc71fb85e526d8fa5146a84 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 28 Sep 2024 23:59:46 +0200 +Subject: cifs: Do not convert delimiter when parsing NFS-style symlinks +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Pali Rohár + +[ Upstream commit d3a49f60917323228f8fdeee313260ef14f94df7 ] + +NFS-style symlinks have target location always stored in NFS/UNIX form +where backslash means the real UNIX backslash and not the SMB path +separator. + +So do not mangle slash and backslash content of NFS-style symlink during +readlink() syscall as it is already in the correct Linux form. + +This fixes interoperability of NFS-style symlinks with backslashes created +by Linux NFS3 client throw Windows NFS server and retrieved by Linux SMB +client throw Windows SMB server, where both Windows servers exports the +same directory. + +Fixes: d5ecebc4900d ("smb3: Allow query of symlinks stored as reparse points") +Acked-by: Paulo Alcantara (Red Hat) +Signed-off-by: Pali Rohár +Signed-off-by: Steve French +Signed-off-by: Sasha Levin +--- + fs/smb/client/reparse.c | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/fs/smb/client/reparse.c b/fs/smb/client/reparse.c +index cfa03c166de8c..ad0e0de9a165d 100644 +--- a/fs/smb/client/reparse.c ++++ b/fs/smb/client/reparse.c +@@ -335,7 +335,6 @@ static int parse_reparse_posix(struct reparse_posix_data *buf, + cifs_sb->local_nls); + if (!data->symlink_target) + return -ENOMEM; +- convert_delimiter(data->symlink_target, '/'); + cifs_dbg(FYI, "%s: target path: %s\n", + __func__, data->symlink_target); + break; +-- +2.43.0 + diff --git a/queue-6.11/cifs-fix-buffer-overflow-when-parsing-nfs-reparse-po.patch b/queue-6.11/cifs-fix-buffer-overflow-when-parsing-nfs-reparse-po.patch new file mode 100644 index 00000000000..9a6cc5c545f --- /dev/null +++ b/queue-6.11/cifs-fix-buffer-overflow-when-parsing-nfs-reparse-po.patch @@ -0,0 +1,81 @@ +From 31807236790b28a56632647fb0e61daef4d56d6a Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 29 Sep 2024 12:22:40 +0200 +Subject: cifs: Fix buffer overflow when parsing NFS reparse points +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Pali Rohár + +[ Upstream commit e2a8910af01653c1c268984855629d71fb81f404 ] + +ReparseDataLength is sum of the InodeType size and DataBuffer size. +So to get DataBuffer size it is needed to subtract InodeType's size from +ReparseDataLength. + +Function cifs_strndup_from_utf16() is currentlly accessing buf->DataBuffer +at position after the end of the buffer because it does not subtract +InodeType size from the length. Fix this problem and correctly subtract +variable len. + +Member InodeType is present only when reparse buffer is large enough. Check +for ReparseDataLength before accessing InodeType to prevent another invalid +memory access. + +Major and minor rdev values are present also only when reparse buffer is +large enough. Check for reparse buffer size before calling reparse_mkdev(). + +Fixes: d5ecebc4900d ("smb3: Allow query of symlinks stored as reparse points") +Reviewed-by: Paulo Alcantara (Red Hat) +Signed-off-by: Pali Rohár +Signed-off-by: Steve French +Signed-off-by: Sasha Levin +--- + fs/smb/client/reparse.c | 15 ++++++++++++++- + 1 file changed, 14 insertions(+), 1 deletion(-) + +diff --git a/fs/smb/client/reparse.c b/fs/smb/client/reparse.c +index 48c27581ec511..cfa03c166de8c 100644 +--- a/fs/smb/client/reparse.c ++++ b/fs/smb/client/reparse.c +@@ -320,9 +320,16 @@ static int parse_reparse_posix(struct reparse_posix_data *buf, + unsigned int len; + u64 type; + ++ len = le16_to_cpu(buf->ReparseDataLength); ++ if (len < sizeof(buf->InodeType)) { ++ cifs_dbg(VFS, "srv returned malformed nfs buffer\n"); ++ return -EIO; ++ } ++ ++ len -= sizeof(buf->InodeType); ++ + switch ((type = le64_to_cpu(buf->InodeType))) { + case NFS_SPECFILE_LNK: +- len = le16_to_cpu(buf->ReparseDataLength); + data->symlink_target = cifs_strndup_from_utf16(buf->DataBuffer, + len, true, + cifs_sb->local_nls); +@@ -482,12 +489,18 @@ bool cifs_reparse_point_to_fattr(struct cifs_sb_info *cifs_sb, + u32 tag = data->reparse.tag; + + if (tag == IO_REPARSE_TAG_NFS && buf) { ++ if (le16_to_cpu(buf->ReparseDataLength) < sizeof(buf->InodeType)) ++ return false; + switch (le64_to_cpu(buf->InodeType)) { + case NFS_SPECFILE_CHR: ++ if (le16_to_cpu(buf->ReparseDataLength) != sizeof(buf->InodeType) + 8) ++ return false; + fattr->cf_mode |= S_IFCHR; + fattr->cf_rdev = reparse_nfs_mkdev(buf); + break; + case NFS_SPECFILE_BLK: ++ if (le16_to_cpu(buf->ReparseDataLength) != sizeof(buf->InodeType) + 8) ++ return false; + fattr->cf_mode |= S_IFBLK; + fattr->cf_rdev = reparse_nfs_mkdev(buf); + break; +-- +2.43.0 + diff --git a/queue-6.11/cifs-remove-intermediate-object-of-failed-create-rep.patch b/queue-6.11/cifs-remove-intermediate-object-of-failed-create-rep.patch new file mode 100644 index 00000000000..8abc15f8f45 --- /dev/null +++ b/queue-6.11/cifs-remove-intermediate-object-of-failed-create-rep.patch @@ -0,0 +1,89 @@ +From 98d0374e09996ce32589d82073435a6b630abc79 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 30 Sep 2024 22:25:10 +0200 +Subject: cifs: Remove intermediate object of failed create reparse call +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Pali Rohár + +[ Upstream commit c9432ad5e32f066875b1bf95939c363bc46d6a45 ] + +If CREATE was successful but SMB2_OP_SET_REPARSE failed then remove the +intermediate object created by CREATE. Otherwise empty object stay on the +server when reparse call failed. + +This ensures that if the creating of special files is unsupported by the +server then no empty file stay on the server as a result of unsupported +operation. + +Fixes: 102466f303ff ("smb: client: allow creating special files via reparse points") +Signed-off-by: Pali Rohár +Acked-by: Paulo Alcantara (Red Hat) +Signed-off-by: Steve French +Signed-off-by: Sasha Levin +--- + fs/smb/client/smb2inode.c | 24 ++++++++++++++++++++++-- + 1 file changed, 22 insertions(+), 2 deletions(-) + +diff --git a/fs/smb/client/smb2inode.c b/fs/smb/client/smb2inode.c +index 11a1c53c64e0b..a6dab60e2c01e 100644 +--- a/fs/smb/client/smb2inode.c ++++ b/fs/smb/client/smb2inode.c +@@ -1205,9 +1205,12 @@ struct inode *smb2_get_reparse_inode(struct cifs_open_info_data *data, + struct cifs_sb_info *cifs_sb = CIFS_SB(sb); + struct cifsFileInfo *cfile; + struct inode *new = NULL; ++ int out_buftype[4] = {}; ++ struct kvec out_iov[4] = {}; + struct kvec in_iov[2]; + int cmds[2]; + int rc; ++ int i; + + oparms = CIFS_OPARMS(cifs_sb, tcon, full_path, + SYNCHRONIZE | DELETE | +@@ -1228,7 +1231,7 @@ struct inode *smb2_get_reparse_inode(struct cifs_open_info_data *data, + cmds[1] = SMB2_OP_POSIX_QUERY_INFO; + cifs_get_writable_path(tcon, full_path, FIND_WR_ANY, &cfile); + rc = smb2_compound_op(xid, tcon, cifs_sb, full_path, &oparms, +- in_iov, cmds, 2, cfile, NULL, NULL, NULL); ++ in_iov, cmds, 2, cfile, out_iov, out_buftype, NULL); + if (!rc) { + rc = smb311_posix_get_inode_info(&new, full_path, + data, sb, xid); +@@ -1237,12 +1240,29 @@ struct inode *smb2_get_reparse_inode(struct cifs_open_info_data *data, + cmds[1] = SMB2_OP_QUERY_INFO; + cifs_get_writable_path(tcon, full_path, FIND_WR_ANY, &cfile); + rc = smb2_compound_op(xid, tcon, cifs_sb, full_path, &oparms, +- in_iov, cmds, 2, cfile, NULL, NULL, NULL); ++ in_iov, cmds, 2, cfile, out_iov, out_buftype, NULL); + if (!rc) { + rc = cifs_get_inode_info(&new, full_path, + data, sb, xid, NULL); + } + } ++ ++ ++ /* ++ * If CREATE was successful but SMB2_OP_SET_REPARSE failed then ++ * remove the intermediate object created by CREATE. Otherwise ++ * empty object stay on the server when reparse call failed. ++ */ ++ if (rc && ++ out_iov[0].iov_base != NULL && out_buftype[0] != CIFS_NO_BUFFER && ++ ((struct smb2_hdr *)out_iov[0].iov_base)->Status == STATUS_SUCCESS && ++ (out_iov[1].iov_base == NULL || out_buftype[1] == CIFS_NO_BUFFER || ++ ((struct smb2_hdr *)out_iov[1].iov_base)->Status != STATUS_SUCCESS)) ++ smb2_unlink(xid, tcon, full_path, cifs_sb, NULL); ++ ++ for (i = 0; i < ARRAY_SIZE(out_buftype); i++) ++ free_rsp_buf(out_buftype[i], out_iov[i].iov_base); ++ + return rc ? ERR_PTR(rc) : new; + } + +-- +2.43.0 + diff --git a/queue-6.11/drm-amd-display-disable-replay-if-vrr-capability-is-.patch b/queue-6.11/drm-amd-display-disable-replay-if-vrr-capability-is-.patch new file mode 100644 index 00000000000..dc6d34faf56 --- /dev/null +++ b/queue-6.11/drm-amd-display-disable-replay-if-vrr-capability-is-.patch @@ -0,0 +1,48 @@ +From 2102471b0af09e4d208db62cedd4fe344861f364 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 26 Jun 2024 16:14:24 +0800 +Subject: drm/amd/display: Disable replay if VRR capability is false + +From: Tom Chung + +[ Upstream commit b68417613d4134b9e39fff95e72ca726268b47db ] + +[Why] +The VRR need to be supported for panel replay feature. +If VRR capability is false, panel replay capability also +need to be disabled. + +[How] +After update the vrr capability, the panel replay capability +also need to be check if need. + +Reviewed-by: Wayne Lin +Signed-off-by: Jerry Zuo +Signed-off-by: Tom Chung +Tested-by: Daniel Wheeler +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +index 74bb1e0e91348..a705e7fa18c06 100644 +--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c ++++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +@@ -12240,6 +12240,12 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector, + if (dm_con_state) + dm_con_state->freesync_capable = freesync_capable; + ++ if (connector->state && amdgpu_dm_connector->dc_link && !freesync_capable && ++ amdgpu_dm_connector->dc_link->replay_settings.config.replay_supported) { ++ amdgpu_dm_connector->dc_link->replay_settings.config.replay_supported = false; ++ amdgpu_dm_connector->dc_link->replay_settings.replay_feature_enabled = false; ++ } ++ + if (connector->vrr_capable_property) + drm_connector_set_vrr_capable_property(connector, + freesync_capable); +-- +2.43.0 + diff --git a/queue-6.11/drm-amd-display-fix-vrr-cannot-enable.patch b/queue-6.11/drm-amd-display-fix-vrr-cannot-enable.patch new file mode 100644 index 00000000000..bdf03063c7a --- /dev/null +++ b/queue-6.11/drm-amd-display-fix-vrr-cannot-enable.patch @@ -0,0 +1,84 @@ +From 0bab536fec7ba5d5bc256828b9eda7e30e817f3c Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 3 Jul 2024 16:47:57 +0800 +Subject: drm/amd/display: Fix VRR cannot enable + +From: Tom Chung + +[ Upstream commit f91a9af09dea850d83d4b217b8acbafd97b5c61f ] + +[Why] +Sometimes the VRR cannot enable after login to the desktop. + +User space may call the DRM_IOCTL_MODE_GETCONNECTOR right after +the DRM_IOCTL_MODE_RMFB. + +After calling DRM_IOCTL_MODE_RMFB to remove all the frame buffer +and it will cause the driver to disable the crtc and disable the +link while calling the link_set_dpms_off(). + +It will cause the dpcd read failed in amdgpu_dm_update_freesync_caps() +while try to get the DP_MSA_TIMING_PAR_IGNORED capability and think +the sink side does not support VRR. + +[How] +Use the dpcd_caps.allow_invalid_MSA_timing_param flag instead of +reading from dpcd directly. + +dpcd_caps.allow_invalid_MSA_timing_param flag is updated during HPD. +It is safe to replace the original method. + +Reviewed-by: Rodrigo Siqueira +Signed-off-by: Jerry Zuo +Signed-off-by: Tom Chung +Tested-by: Daniel Wheeler +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 23 ++----------------- + 1 file changed, 2 insertions(+), 21 deletions(-) + +diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +index a705e7fa18c06..9ee54c5ce4a61 100644 +--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c ++++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +@@ -11812,25 +11812,6 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev, + return ret; + } + +-static bool is_dp_capable_without_timing_msa(struct dc *dc, +- struct amdgpu_dm_connector *amdgpu_dm_connector) +-{ +- u8 dpcd_data; +- bool capable = false; +- +- if (amdgpu_dm_connector->dc_link && +- dm_helpers_dp_read_dpcd( +- NULL, +- amdgpu_dm_connector->dc_link, +- DP_DOWN_STREAM_PORT_COUNT, +- &dpcd_data, +- sizeof(dpcd_data))) { +- capable = (dpcd_data & DP_MSA_TIMING_PAR_IGNORED) ? true:false; +- } +- +- return capable; +-} +- + static bool dm_edid_parser_send_cea(struct amdgpu_display_manager *dm, + unsigned int offset, + unsigned int total_length, +@@ -12133,8 +12114,8 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector, + sink->sink_signal == SIGNAL_TYPE_EDP)) { + bool edid_check_required = false; + +- if (is_dp_capable_without_timing_msa(adev->dm.dc, +- amdgpu_dm_connector)) { ++ if (amdgpu_dm_connector->dc_link && ++ amdgpu_dm_connector->dc_link->dpcd_caps.allow_invalid_MSA_timing_param) { + if (edid->features & DRM_EDID_FEATURE_CONTINUOUS_FREQ) { + amdgpu_dm_connector->min_vfreq = connector->display_info.monitor_range.min_vfreq; + amdgpu_dm_connector->max_vfreq = connector->display_info.monitor_range.max_vfreq; +-- +2.43.0 + diff --git a/queue-6.11/drm-amd-display-re-enable-panel-replay-feature.patch b/queue-6.11/drm-amd-display-re-enable-panel-replay-feature.patch new file mode 100644 index 00000000000..75d56ced4b6 --- /dev/null +++ b/queue-6.11/drm-amd-display-re-enable-panel-replay-feature.patch @@ -0,0 +1,58 @@ +From 65a64ccbd9cfc7ddc1415863d993b036780ca107 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 26 Jun 2024 17:02:23 +0800 +Subject: drm/amd/display: Re-enable panel replay feature + +From: Tom Chung + +[ Upstream commit be64336307a6c3ee71fe1337c1b9f0495aa83c50 ] + +[Why & How] +Fixed the replay issues and now re-enable the panel replay feature. + +Reported-by: Arthur Borsboom +Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3344 +Reviewed-by: Sun peng Li +Signed-off-by: Tom Chung +Signed-off-by: Wayne Lin +Tested-by: Daniel Wheeler +Signed-off-by: Alex Deucher +Signed-off-by: Sasha Levin +--- + .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 20 ++++++++----------- + 1 file changed, 8 insertions(+), 12 deletions(-) + +diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +index 9ee54c5ce4a61..f6cbff0ed6f94 100644 +--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c ++++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +@@ -4919,18 +4919,14 @@ static int amdgpu_dm_initialize_drm_device(struct amdgpu_device *adev) + /* Determine whether to enable Replay support by default. */ + if (!(amdgpu_dc_debug_mask & DC_DISABLE_REPLAY)) { + switch (amdgpu_ip_version(adev, DCE_HWIP, 0)) { +-/* +- * Disabled by default due to https://gitlab.freedesktop.org/drm/amd/-/issues/3344 +- * case IP_VERSION(3, 1, 4): +- * case IP_VERSION(3, 1, 5): +- * case IP_VERSION(3, 1, 6): +- * case IP_VERSION(3, 2, 0): +- * case IP_VERSION(3, 2, 1): +- * case IP_VERSION(3, 5, 0): +- * case IP_VERSION(3, 5, 1): +- * replay_feature_enabled = true; +- * break; +- */ ++ case IP_VERSION(3, 1, 4): ++ case IP_VERSION(3, 2, 0): ++ case IP_VERSION(3, 2, 1): ++ case IP_VERSION(3, 5, 0): ++ case IP_VERSION(3, 5, 1): ++ replay_feature_enabled = true; ++ break; ++ + default: + replay_feature_enabled = amdgpu_dc_feature_mask & DC_REPLAY_MASK; + break; +-- +2.43.0 + diff --git a/queue-6.11/drm-connector-hdmi-fix-writing-dynamic-range-masteri.patch b/queue-6.11/drm-connector-hdmi-fix-writing-dynamic-range-masteri.patch new file mode 100644 index 00000000000..bdec37f1d83 --- /dev/null +++ b/queue-6.11/drm-connector-hdmi-fix-writing-dynamic-range-masteri.patch @@ -0,0 +1,106 @@ +From 840f57c9acefe0b99323e49df8172594e771d806 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 27 Aug 2024 11:39:04 -0500 +Subject: drm/connector: hdmi: Fix writing Dynamic Range Mastering infoframes + +From: Derek Foreman + +[ Upstream commit f0fa69b5011a45394554fb8061d74fee4d7cd72c ] + +The largest infoframe we create is the DRM (Dynamic Range Mastering) +infoframe which is 26 bytes + a 4 byte header, for a total of 30 +bytes. + +With HDMI_MAX_INFOFRAME_SIZE set to 29 bytes, as it is now, we +allocate too little space to pack a DRM infoframe in +write_device_infoframe(), leading to an ENOSPC return from +hdmi_infoframe_pack(), and never calling the connector's +write_infoframe() vfunc. + +Instead of having HDMI_MAX_INFOFRAME_SIZE defined in two places, +replace HDMI_MAX_INFOFRAME_SIZE with HDMI_INFOFRAME_SIZE(MAX) and make +MAX 27 bytes - which is defined by the HDMI specification to be the +largest infoframe payload. + +Fixes: f378b77227bc ("drm/connector: hdmi: Add Infoframes generation") +Fixes: c602e4959a0c ("drm/connector: hdmi: Create Infoframe DebugFS entries") + +Signed-off-by: Derek Foreman +Acked-by: Maxime Ripard +Reviewed-by: Jani Nikula +Link: https://patchwork.freedesktop.org/patch/msgid/20240827163918.48160-1-derek.foreman@collabora.com +Signed-off-by: Maxime Ripard +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/display/drm_hdmi_state_helper.c | 4 +--- + drivers/gpu/drm/drm_debugfs.c | 4 +--- + include/linux/hdmi.h | 9 +++++++++ + 3 files changed, 11 insertions(+), 6 deletions(-) + +diff --git a/drivers/gpu/drm/display/drm_hdmi_state_helper.c b/drivers/gpu/drm/display/drm_hdmi_state_helper.c +index 7854820089ec6..feb7a3a759811 100644 +--- a/drivers/gpu/drm/display/drm_hdmi_state_helper.c ++++ b/drivers/gpu/drm/display/drm_hdmi_state_helper.c +@@ -521,8 +521,6 @@ int drm_atomic_helper_connector_hdmi_check(struct drm_connector *connector, + } + EXPORT_SYMBOL(drm_atomic_helper_connector_hdmi_check); + +-#define HDMI_MAX_INFOFRAME_SIZE 29 +- + static int clear_device_infoframe(struct drm_connector *connector, + enum hdmi_infoframe_type type) + { +@@ -563,7 +561,7 @@ static int write_device_infoframe(struct drm_connector *connector, + { + const struct drm_connector_hdmi_funcs *funcs = connector->hdmi.funcs; + struct drm_device *dev = connector->dev; +- u8 buffer[HDMI_MAX_INFOFRAME_SIZE]; ++ u8 buffer[HDMI_INFOFRAME_SIZE(MAX)]; + int ret; + int len; + +diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c +index 6b239a24f1dff..9d3e6dd68810e 100644 +--- a/drivers/gpu/drm/drm_debugfs.c ++++ b/drivers/gpu/drm/drm_debugfs.c +@@ -520,8 +520,6 @@ static const struct file_operations drm_connector_fops = { + .write = connector_write + }; + +-#define HDMI_MAX_INFOFRAME_SIZE 29 +- + static ssize_t + audio_infoframe_read(struct file *filp, char __user *ubuf, size_t count, loff_t *ppos) + { +@@ -579,7 +577,7 @@ static ssize_t _f##_read_infoframe(struct file *filp, \ + struct drm_connector *connector; \ + union hdmi_infoframe *frame; \ + struct drm_device *dev; \ +- u8 buf[HDMI_MAX_INFOFRAME_SIZE]; \ ++ u8 buf[HDMI_INFOFRAME_SIZE(MAX)]; \ + ssize_t len = 0; \ + \ + connector = filp->private_data; \ +diff --git a/include/linux/hdmi.h b/include/linux/hdmi.h +index 3bb87bf6bc658..455f855bc0848 100644 +--- a/include/linux/hdmi.h ++++ b/include/linux/hdmi.h +@@ -59,6 +59,15 @@ enum hdmi_infoframe_type { + #define HDMI_DRM_INFOFRAME_SIZE 26 + #define HDMI_VENDOR_INFOFRAME_SIZE 4 + ++/* ++ * HDMI 1.3a table 5-14 states that the largest InfoFrame_length is 27, ++ * not including the packet header or checksum byte. We include the ++ * checksum byte in HDMI_INFOFRAME_HEADER_SIZE, so this should allow ++ * HDMI_INFOFRAME_SIZE(MAX) to be the largest buffer we could ever need ++ * for any HDMI infoframe. ++ */ ++#define HDMI_MAX_INFOFRAME_SIZE 27 ++ + #define HDMI_INFOFRAME_SIZE(type) \ + (HDMI_INFOFRAME_HEADER_SIZE + HDMI_ ## type ## _INFOFRAME_SIZE) + +-- +2.43.0 + diff --git a/queue-6.11/drm-panthor-fix-race-when-converting-group-handle-to.patch b/queue-6.11/drm-panthor-fix-race-when-converting-group-handle-to.patch new file mode 100644 index 00000000000..60404e29ceb --- /dev/null +++ b/queue-6.11/drm-panthor-fix-race-when-converting-group-handle-to.patch @@ -0,0 +1,72 @@ +From b5640218806ab4bfa995e6c3a42a353fa3353899 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 23 Sep 2024 11:34:06 +0100 +Subject: drm/panthor: Fix race when converting group handle to group object + +From: Steven Price + +[ Upstream commit cac075706f298948898b1f63e81709df42afa75d ] + +XArray provides it's own internal lock which protects the internal array +when entries are being simultaneously added and removed. However there +is still a race between retrieving the pointer from the XArray and +incrementing the reference count. + +To avoid this race simply hold the internal XArray lock when +incrementing the reference count, this ensures there cannot be a racing +call to xa_erase(). + +Fixes: de8548813824 ("drm/panthor: Add the scheduler logical block") +Signed-off-by: Steven Price +Reviewed-by: Boris Brezillon +Reviewed-by: Liviu Dudau +Link: https://patchwork.freedesktop.org/patch/msgid/20240923103406.2509906-1-steven.price@arm.com +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/panthor/panthor_sched.c | 16 ++++++++++++++-- + 1 file changed, 14 insertions(+), 2 deletions(-) + +diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c +index 12b272a912f86..d21fe63ae2281 100644 +--- a/drivers/gpu/drm/panthor/panthor_sched.c ++++ b/drivers/gpu/drm/panthor/panthor_sched.c +@@ -3242,6 +3242,18 @@ int panthor_group_destroy(struct panthor_file *pfile, u32 group_handle) + return 0; + } + ++static struct panthor_group *group_from_handle(struct panthor_group_pool *pool, ++ u32 group_handle) ++{ ++ struct panthor_group *group; ++ ++ xa_lock(&pool->xa); ++ group = group_get(xa_load(&pool->xa, group_handle)); ++ xa_unlock(&pool->xa); ++ ++ return group; ++} ++ + int panthor_group_get_state(struct panthor_file *pfile, + struct drm_panthor_group_get_state *get_state) + { +@@ -3253,7 +3265,7 @@ int panthor_group_get_state(struct panthor_file *pfile, + if (get_state->pad) + return -EINVAL; + +- group = group_get(xa_load(&gpool->xa, get_state->group_handle)); ++ group = group_from_handle(gpool, get_state->group_handle); + if (!group) + return -EINVAL; + +@@ -3384,7 +3396,7 @@ panthor_job_create(struct panthor_file *pfile, + job->call_info.latest_flush = qsubmit->latest_flush; + INIT_LIST_HEAD(&job->node); + +- job->group = group_get(xa_load(&gpool->xa, group_handle)); ++ job->group = group_from_handle(gpool, group_handle); + if (!job->group) { + ret = -EINVAL; + goto err_put_job; +-- +2.43.0 + diff --git a/queue-6.11/drm-panthor-lock-the-vm-resv-before-calling-drm_gpuv.patch b/queue-6.11/drm-panthor-lock-the-vm-resv-before-calling-drm_gpuv.patch new file mode 100644 index 00000000000..41a6e065edc --- /dev/null +++ b/queue-6.11/drm-panthor-lock-the-vm-resv-before-calling-drm_gpuv.patch @@ -0,0 +1,51 @@ +From ed789bcc0f8ea18bc9d102e3fb36b302fc460ac2 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 13 Sep 2024 13:27:22 +0200 +Subject: drm/panthor: Lock the VM resv before calling + drm_gpuvm_bo_obtain_prealloc() + +From: Boris Brezillon + +[ Upstream commit fa998a9eac8809da4f219aad49836fcad2a9bf5c ] + +drm_gpuvm_bo_obtain_prealloc() will call drm_gpuvm_bo_put() on our +pre-allocated BO if the association exists. Given we +only have one ref on preallocated_vm_bo, drm_gpuvm_bo_destroy() will +be called immediately, and we have to hold the VM resv lock when +calling this function. + +Fixes: 647810ec2476 ("drm/panthor: Add the MMU/VM logical block") +Signed-off-by: Boris Brezillon +Reviewed-by: Liviu Dudau +Reviewed-by: Steven Price +Link: https://patchwork.freedesktop.org/patch/msgid/20240913112722.492144-1-boris.brezillon@collabora.com +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/panthor/panthor_mmu.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/drivers/gpu/drm/panthor/panthor_mmu.c b/drivers/gpu/drm/panthor/panthor_mmu.c +index cc6e13a977835..ce8e8a93d7076 100644 +--- a/drivers/gpu/drm/panthor/panthor_mmu.c ++++ b/drivers/gpu/drm/panthor/panthor_mmu.c +@@ -1251,9 +1251,17 @@ static int panthor_vm_prepare_map_op_ctx(struct panthor_vm_op_ctx *op_ctx, + goto err_cleanup; + } + ++ /* drm_gpuvm_bo_obtain_prealloc() will call drm_gpuvm_bo_put() on our ++ * pre-allocated BO if the association exists. Given we ++ * only have one ref on preallocated_vm_bo, drm_gpuvm_bo_destroy() will ++ * be called immediately, and we have to hold the VM resv lock when ++ * calling this function. ++ */ ++ dma_resv_lock(panthor_vm_resv(vm), NULL); + mutex_lock(&bo->gpuva_list_lock); + op_ctx->map.vm_bo = drm_gpuvm_bo_obtain_prealloc(preallocated_vm_bo); + mutex_unlock(&bo->gpuva_list_lock); ++ dma_resv_unlock(panthor_vm_resv(vm)); + + /* If the a vm_bo for this combination exists, it already + * retains a pin ref, and we can release the one we took earlier. +-- +2.43.0 + diff --git a/queue-6.11/drm-xe-guc_submit-add-missing-locking-in-wedged_fini.patch b/queue-6.11/drm-xe-guc_submit-add-missing-locking-in-wedged_fini.patch new file mode 100644 index 00000000000..1586f35714c --- /dev/null +++ b/queue-6.11/drm-xe-guc_submit-add-missing-locking-in-wedged_fini.patch @@ -0,0 +1,53 @@ +From 703306b2019445a8e36aca5c794865f660656bb2 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 24 Sep 2024 16:09:48 +0100 +Subject: drm/xe/guc_submit: add missing locking in wedged_fini + +From: Matthew Auld + +[ Upstream commit 790533e44bfc7af929842fccd9674c9f424d4627 ] + +Any non-wedged queue can have a zero refcount here and can be running +concurrently with an async queue destroy, therefore dereferencing the +queue ptr to check wedge status after the lookup can trigger UAF if +queue is not wedged. Fix this by keeping the submission_state lock held +around the check to postpone the free and make the check safe, before +dropping again around the put() to avoid the deadlock. + +Fixes: 8ed9aaae39f3 ("drm/xe: Force wedged state and block GT reset upon any GPU hang") +Signed-off-by: Matthew Auld +Cc: Matthew Brost +Reviewed-by: Matthew Brost +Link: https://patchwork.freedesktop.org/patch/msgid/20240924150947.118433-2-matthew.auld@intel.com +(cherry picked from commit d28af0b6b9580b9f90c265a7da0315b0ad20bbfd) +Signed-off-by: Lucas De Marchi +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/xe/xe_guc_submit.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c b/drivers/gpu/drm/xe/xe_guc_submit.c +index 59b36c7998c24..3d91734980110 100644 +--- a/drivers/gpu/drm/xe/xe_guc_submit.c ++++ b/drivers/gpu/drm/xe/xe_guc_submit.c +@@ -290,9 +290,15 @@ static void guc_submit_wedged_fini(void *arg) + struct xe_exec_queue *q; + unsigned long index; + +- xa_for_each(&guc->submission_state.exec_queue_lookup, index, q) +- if (exec_queue_wedged(q)) ++ mutex_lock(&guc->submission_state.lock); ++ xa_for_each(&guc->submission_state.exec_queue_lookup, index, q) { ++ if (exec_queue_wedged(q)) { ++ mutex_unlock(&guc->submission_state.lock); + xe_exec_queue_put(q); ++ mutex_lock(&guc->submission_state.lock); ++ } ++ } ++ mutex_unlock(&guc->submission_state.lock); + } + + static const struct xe_exec_queue_ops guc_exec_queue_ops; +-- +2.43.0 + diff --git a/queue-6.11/drm-xe-prevent-null-pointer-access-in-xe_migrate_cop.patch b/queue-6.11/drm-xe-prevent-null-pointer-access-in-xe_migrate_cop.patch new file mode 100644 index 00000000000..38516d5b507 --- /dev/null +++ b/queue-6.11/drm-xe-prevent-null-pointer-access-in-xe_migrate_cop.patch @@ -0,0 +1,129 @@ +From e350828c691a401b291917265fdde25ebdcfbbc4 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 27 Sep 2024 09:13:08 -0700 +Subject: drm/xe: Prevent null pointer access in xe_migrate_copy +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Zhanjun Dong + +[ Upstream commit 7257d9c9a3c6cfe26c428e9b7ae21d61f2f55a79 ] + +xe_migrate_copy designed to copy content of TTM resources. When source +resource is null, it will trigger a NULL pointer dereference in +xe_migrate_copy. To avoid this situation, update lacks source flag to +true for this case, the flag will trigger xe_migrate_clear rather than +xe_migrate_copy. + +Issue trace: +<7> [317.089847] xe 0000:00:02.0: [drm:xe_migrate_copy [xe]] Pass 14, + sizes: 4194304 & 4194304 +<7> [317.089945] xe 0000:00:02.0: [drm:xe_migrate_copy [xe]] Pass 15, + sizes: 4194304 & 4194304 +<1> [317.128055] BUG: kernel NULL pointer dereference, address: + 0000000000000010 +<1> [317.128064] #PF: supervisor read access in kernel mode +<1> [317.128066] #PF: error_code(0x0000) - not-present page +<6> [317.128069] PGD 0 P4D 0 +<4> [317.128071] Oops: Oops: 0000 [#1] PREEMPT SMP NOPTI +<4> [317.128074] CPU: 1 UID: 0 PID: 1440 Comm: kunit_try_catch Tainted: + G U N 6.11.0-rc7-xe #1 +<4> [317.128078] Tainted: [U]=USER, [N]=TEST +<4> [317.128080] Hardware name: Intel Corporation Lunar Lake Client + Platform/LNL-M LP5 RVP1, BIOS LNLMFWI1.R00.3221.D80.2407291239 07/29/2024 +<4> [317.128082] RIP: 0010:xe_migrate_copy+0x66/0x13e0 [xe] +<4> [317.128158] Code: 00 00 48 89 8d e0 fe ff ff 48 8b 40 10 4c 89 85 c8 + fe ff ff 44 88 8d bd fe ff ff 65 48 8b 3c 25 28 00 00 00 48 89 7d d0 31 + ff <8b> 79 10 48 89 85 a0 fe ff ff 48 8b 00 48 89 b5 d8 fe ff ff 83 ff +<4> [317.128162] RSP: 0018:ffffc9000167f9f0 EFLAGS: 00010246 +<4> [317.128164] RAX: ffff8881120d8028 RBX: ffff88814d070428 RCX: + 0000000000000000 +<4> [317.128166] RDX: ffff88813cb99c00 RSI: 0000000004000000 RDI: + 0000000000000000 +<4> [317.128168] RBP: ffffc9000167fbb8 R08: ffff88814e7b1f08 R09: + 0000000000000001 +<4> [317.128170] R10: 0000000000000001 R11: 0000000000000001 R12: + ffff88814e7b1f08 +<4> [317.128172] R13: ffff88814e7b1f08 R14: ffff88813cb99c00 R15: + 0000000000000001 +<4> [317.128174] FS: 0000000000000000(0000) GS:ffff88846f280000(0000) + knlGS:0000000000000000 +<4> [317.128176] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 +<4> [317.128178] CR2: 0000000000000010 CR3: 000000011f676004 CR4: + 0000000000770ef0 +<4> [317.128180] DR0: 0000000000000000 DR1: 0000000000000000 DR2: + 0000000000000000 +<4> [317.128182] DR3: 0000000000000000 DR6: 00000000ffff07f0 DR7: + 0000000000000400 +<4> [317.128184] PKRU: 55555554 +<4> [317.128185] Call Trace: +<4> [317.128187] +<4> [317.128189] ? show_regs+0x67/0x70 +<4> [317.128194] ? __die_body+0x20/0x70 +<4> [317.128196] ? __die+0x2b/0x40 +<4> [317.128198] ? page_fault_oops+0x15f/0x4e0 +<4> [317.128203] ? do_user_addr_fault+0x3fb/0x970 +<4> [317.128205] ? lock_acquire+0xc7/0x2e0 +<4> [317.128209] ? exc_page_fault+0x87/0x2b0 +<4> [317.128212] ? asm_exc_page_fault+0x27/0x30 +<4> [317.128216] ? xe_migrate_copy+0x66/0x13e0 [xe] +<4> [317.128263] ? __lock_acquire+0xb9d/0x26f0 +<4> [317.128265] ? __lock_acquire+0xb9d/0x26f0 +<4> [317.128267] ? sg_free_append_table+0x20/0x80 +<4> [317.128271] ? lock_acquire+0xc7/0x2e0 +<4> [317.128273] ? mark_held_locks+0x4d/0x80 +<4> [317.128275] ? trace_hardirqs_on+0x1e/0xd0 +<4> [317.128278] ? _raw_spin_unlock_irqrestore+0x31/0x60 +<4> [317.128281] ? __pm_runtime_resume+0x60/0xa0 +<4> [317.128284] xe_bo_move+0x682/0xc50 [xe] +<4> [317.128315] ? lock_is_held_type+0xaa/0x120 +<4> [317.128318] ttm_bo_handle_move_mem+0xe5/0x1a0 [ttm] +<4> [317.128324] ttm_bo_validate+0xd1/0x1a0 [ttm] +<4> [317.128328] shrink_test_run_device+0x721/0xc10 [xe] +<4> [317.128360] ? find_held_lock+0x31/0x90 +<4> [317.128363] ? lock_release+0xd1/0x2a0 +<4> [317.128365] ? __pfx_kunit_generic_run_threadfn_adapter+0x10/0x10 + [kunit] +<4> [317.128370] xe_bo_shrink_kunit+0x11/0x20 [xe] +<4> [317.128397] kunit_try_run_case+0x6e/0x150 [kunit] +<4> [317.128400] ? trace_hardirqs_on+0x1e/0xd0 +<4> [317.128402] ? _raw_spin_unlock_irqrestore+0x31/0x60 +<4> [317.128404] kunit_generic_run_threadfn_adapter+0x1e/0x40 [kunit] +<4> [317.128407] kthread+0xf5/0x130 +<4> [317.128410] ? __pfx_kthread+0x10/0x10 +<4> [317.128412] ret_from_fork+0x39/0x60 +<4> [317.128415] ? __pfx_kthread+0x10/0x10 +<4> [317.128416] ret_from_fork_asm+0x1a/0x30 +<4> [317.128420] + +Fixes: 266c85885263 ("drm/xe/xe2: Handle flat ccs move for igfx.") +Signed-off-by: Zhanjun Dong +Reviewed-by: Thomas Hellström +Signed-off-by: Matt Roper +Link: https://patchwork.freedesktop.org/patch/msgid/20240927161308.862323-2-zhanjun.dong@intel.com +(cherry picked from commit 59a1c9c7e1d02b43b415ea92627ce095b7c79e47) +Signed-off-by: Lucas De Marchi +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/xe/xe_bo.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c +index 261d3d6c8a931..e147ef1d0578f 100644 +--- a/drivers/gpu/drm/xe/xe_bo.c ++++ b/drivers/gpu/drm/xe/xe_bo.c +@@ -680,8 +680,8 @@ static int xe_bo_move(struct ttm_buffer_object *ttm_bo, bool evict, + tt_has_data = ttm && (ttm_tt_is_populated(ttm) || + (ttm->page_flags & TTM_TT_FLAG_SWAPPED)); + +- move_lacks_source = handle_system_ccs ? (!bo->ccs_cleared) : +- (!mem_type_is_vram(old_mem_type) && !tt_has_data); ++ move_lacks_source = !old_mem || (handle_system_ccs ? (!bo->ccs_cleared) : ++ (!mem_type_is_vram(old_mem_type) && !tt_has_data)); + + needs_clear = (ttm && ttm->page_flags & TTM_TT_FLAG_ZERO_ALLOC) || + (!ttm && ttm_bo->type == ttm_bo_type_device); +-- +2.43.0 + diff --git a/queue-6.11/drm-xe-restore-pci-state-upon-resume.patch b/queue-6.11/drm-xe-restore-pci-state-upon-resume.patch new file mode 100644 index 00000000000..0e170e6ca76 --- /dev/null +++ b/queue-6.11/drm-xe-restore-pci-state-upon-resume.patch @@ -0,0 +1,46 @@ +From b16a4f1839b39ede9233931e112f9eead7da44f3 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 12 Sep 2024 17:45:07 -0400 +Subject: drm/xe: Restore pci state upon resume + +From: Rodrigo Vivi + +[ Upstream commit cffa8e83df9fe525afad1e1099097413f9174f57 ] + +The pci state was saved, but not restored. Restore +right after the power state transition request like +every other driver. + +v2: Use right fixes tag, since this was there initialy, but + accidentally removed. + +Fixes: f6761c68c0ac ("drm/xe/display: Improve s2idle handling.") +Cc: Maarten Lankhorst +Cc: Lucas De Marchi +Reviewed-by: Jonathan Cavitt +Signed-off-by: Rodrigo Vivi +Link: https://patchwork.freedesktop.org/patch/msgid/20240912214507.456897-1-rodrigo.vivi@intel.com +Signed-off-by: Maarten Lankhorst +(cherry picked from commit ec2d1539e159f53eae708e194c449cfefa004994) +Signed-off-by: Lucas De Marchi +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/xe/xe_pci.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/drivers/gpu/drm/xe/xe_pci.c b/drivers/gpu/drm/xe/xe_pci.c +index 732ee0d02124f..5929ac61dbe0a 100644 +--- a/drivers/gpu/drm/xe/xe_pci.c ++++ b/drivers/gpu/drm/xe/xe_pci.c +@@ -924,6 +924,8 @@ static int xe_pci_resume(struct device *dev) + if (err) + return err; + ++ pci_restore_state(pdev); ++ + err = pci_enable_device(pdev); + if (err) + return err; +-- +2.43.0 + diff --git a/queue-6.11/drm-xe-resume-tdr-after-gt-reset.patch b/queue-6.11/drm-xe-resume-tdr-after-gt-reset.patch new file mode 100644 index 00000000000..42920bcc7e3 --- /dev/null +++ b/queue-6.11/drm-xe-resume-tdr-after-gt-reset.patch @@ -0,0 +1,70 @@ +From 2fc40a92b37bb98b667be6a81ea1dc3eee94a2fb Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 24 Jul 2024 16:59:19 -0700 +Subject: drm/xe: Resume TDR after GT reset + +From: Matthew Brost + +[ Upstream commit 1b30f87e088b499eb74298db256da5c98e8276e2 ] + +Not starting the TDR after GT reset on exec queue which have been +restarted can lead to jobs being able to be run forever. Fix this by +restarting the TDR. + +Fixes: dd08ebf6c352 ("drm/xe: Introduce a new DRM driver for Intel GPUs") +Signed-off-by: Matthew Brost +Reviewed-by: Nirmoy Das +Link: https://patchwork.freedesktop.org/patch/msgid/20240724235919.1917216-1-matthew.brost@intel.com +(cherry picked from commit 8ec5a4e5ce97d6ee9f5eb5b4ce4cfc831976fdec) +Signed-off-by: Lucas De Marchi +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/xe/xe_gpu_scheduler.c | 5 +++++ + drivers/gpu/drm/xe/xe_gpu_scheduler.h | 2 ++ + drivers/gpu/drm/xe/xe_guc_submit.c | 1 + + 3 files changed, 8 insertions(+) + +diff --git a/drivers/gpu/drm/xe/xe_gpu_scheduler.c b/drivers/gpu/drm/xe/xe_gpu_scheduler.c +index e4ad1d6ce1d5f..7f24e58cc992f 100644 +--- a/drivers/gpu/drm/xe/xe_gpu_scheduler.c ++++ b/drivers/gpu/drm/xe/xe_gpu_scheduler.c +@@ -90,6 +90,11 @@ void xe_sched_submission_stop(struct xe_gpu_scheduler *sched) + cancel_work_sync(&sched->work_process_msg); + } + ++void xe_sched_submission_resume_tdr(struct xe_gpu_scheduler *sched) ++{ ++ drm_sched_resume_timeout(&sched->base, sched->base.timeout); ++} ++ + void xe_sched_add_msg(struct xe_gpu_scheduler *sched, + struct xe_sched_msg *msg) + { +diff --git a/drivers/gpu/drm/xe/xe_gpu_scheduler.h b/drivers/gpu/drm/xe/xe_gpu_scheduler.h +index 10c6bb9c93868..6aac7fe686735 100644 +--- a/drivers/gpu/drm/xe/xe_gpu_scheduler.h ++++ b/drivers/gpu/drm/xe/xe_gpu_scheduler.h +@@ -22,6 +22,8 @@ void xe_sched_fini(struct xe_gpu_scheduler *sched); + void xe_sched_submission_start(struct xe_gpu_scheduler *sched); + void xe_sched_submission_stop(struct xe_gpu_scheduler *sched); + ++void xe_sched_submission_resume_tdr(struct xe_gpu_scheduler *sched); ++ + void xe_sched_add_msg(struct xe_gpu_scheduler *sched, + struct xe_sched_msg *msg); + +diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c b/drivers/gpu/drm/xe/xe_guc_submit.c +index 3d91734980110..64b3a7848f4ab 100644 +--- a/drivers/gpu/drm/xe/xe_guc_submit.c ++++ b/drivers/gpu/drm/xe/xe_guc_submit.c +@@ -1740,6 +1740,7 @@ static void guc_exec_queue_start(struct xe_exec_queue *q) + } + + xe_sched_submission_start(sched); ++ xe_sched_submission_resume_tdr(sched); + } + + int xe_guc_submit_start(struct xe_guc *guc) +-- +2.43.0 + diff --git a/queue-6.11/e1000e-avoid-failing-the-system-during-pm_suspend.patch b/queue-6.11/e1000e-avoid-failing-the-system-during-pm_suspend.patch new file mode 100644 index 00000000000..1ecb82d8f36 --- /dev/null +++ b/queue-6.11/e1000e-avoid-failing-the-system-during-pm_suspend.patch @@ -0,0 +1,104 @@ +From f50f239864703cb8da1f70febba09e5e14ad531c Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 6 Aug 2024 16:23:48 +0300 +Subject: e1000e: avoid failing the system during pm_suspend + +From: Vitaly Lifshits + +[ Upstream commit 0a6ad4d9e1690c7faa3a53f762c877e477093657 ] + +Occasionally when the system goes into pm_suspend, the suspend might fail +due to a PHY access error on the network adapter. Previously, this would +have caused the whole system to fail to go to a low power state. +An example of this was reported in the following Bugzilla: +https://bugzilla.kernel.org/show_bug.cgi?id=205015 + +[ 1663.694828] e1000e 0000:00:19.0 eth0: Failed to disable ULP +[ 1664.731040] asix 2-3:1.0 eth1: link up, 100Mbps, full-duplex, lpa 0xC1E1 +[ 1665.093513] e1000e 0000:00:19.0 eth0: Hardware Error +[ 1665.596760] e1000e 0000:00:19.0: pci_pm_resume+0x0/0x80 returned 0 after 2975399 usecs + +and then the system never recovers from it, and all the following suspend failed due to this +[22909.393854] PM: pci_pm_suspend(): e1000e_pm_suspend+0x0/0x760 [e1000e] returns -2 +[22909.393858] PM: dpm_run_callback(): pci_pm_suspend+0x0/0x160 returns -2 +[22909.393861] PM: Device 0000:00:1f.6 failed to suspend async: error -2 + +This can be avoided by changing the return values of __e1000_shutdown and +e1000e_pm_suspend functions so that they always return 0 (success). This +is consistent with what other drivers do. + +If the e1000e driver encounters a hardware error during suspend, potential +side effects include slightly higher power draw or non-working wake on +LAN. This is preferred to a system-level suspend failure, and a warning +message is written to the system log, so that the user can be aware that +the LAN controller experienced a problem during suspend. + +Link: https://bugzilla.kernel.org/show_bug.cgi?id=205015 +Suggested-by: Dima Ruinskiy +Signed-off-by: Vitaly Lifshits +Tested-by: Mor Bar-Gabay +Signed-off-by: Tony Nguyen +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/intel/e1000e/netdev.c | 19 +++++++++++-------- + 1 file changed, 11 insertions(+), 8 deletions(-) + +diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c +index 360ee26557f77..f103249b12fac 100644 +--- a/drivers/net/ethernet/intel/e1000e/netdev.c ++++ b/drivers/net/ethernet/intel/e1000e/netdev.c +@@ -6671,8 +6671,10 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool runtime) + if (adapter->flags2 & FLAG2_HAS_PHY_WAKEUP) { + /* enable wakeup by the PHY */ + retval = e1000_init_phy_wakeup(adapter, wufc); +- if (retval) +- return retval; ++ if (retval) { ++ e_err("Failed to enable wakeup\n"); ++ goto skip_phy_configurations; ++ } + } else { + /* enable wakeup by the MAC */ + ew32(WUFC, wufc); +@@ -6693,8 +6695,10 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool runtime) + * or broadcast. + */ + retval = e1000_enable_ulp_lpt_lp(hw, !runtime); +- if (retval) +- return retval; ++ if (retval) { ++ e_err("Failed to enable ULP\n"); ++ goto skip_phy_configurations; ++ } + } + } + +@@ -6726,6 +6730,7 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool runtime) + hw->phy.ops.release(hw); + } + ++skip_phy_configurations: + /* Release control of h/w to f/w. If f/w is AMT enabled, this + * would have already happened in close and is redundant. + */ +@@ -6968,15 +6973,13 @@ static int e1000e_pm_suspend(struct device *dev) + e1000e_pm_freeze(dev); + + rc = __e1000_shutdown(pdev, false); +- if (rc) { +- e1000e_pm_thaw(dev); +- } else { ++ if (!rc) { + /* Introduce S0ix implementation */ + if (adapter->flags2 & FLAG2_ENABLE_S0IX_FLOWS) + e1000e_s0ix_entry_flow(adapter); + } + +- return rc; ++ return 0; + } + + static int e1000e_pm_resume(struct device *dev) +-- +2.43.0 + diff --git a/queue-6.11/gpiolib-fix-potential-null-pointer-dereference-in-gp.patch b/queue-6.11/gpiolib-fix-potential-null-pointer-dereference-in-gp.patch new file mode 100644 index 00000000000..83ff840ff6d --- /dev/null +++ b/queue-6.11/gpiolib-fix-potential-null-pointer-dereference-in-gp.patch @@ -0,0 +1,52 @@ +From 151ece6029a1e607a4c2a338cd6bf0f4a084b183 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 3 Oct 2024 14:13:51 +0100 +Subject: gpiolib: Fix potential NULL pointer dereference in gpiod_get_label() + +From: Lad Prabhakar + +[ Upstream commit 7b99b5ab885993bff010ebcd93be5e511c56e28a ] + +In `gpiod_get_label()`, it is possible that `srcu_dereference_check()` may +return a NULL pointer, leading to a scenario where `label->str` is accessed +without verifying if `label` itself is NULL. + +This patch adds a proper NULL check for `label` before accessing +`label->str`. The check for `label->str != NULL` is removed because +`label->str` can never be NULL if `label` is not NULL. + +This fixes the issue where the label name was being printed as `(efault)` +when dumping the sysfs GPIO file when `label == NULL`. + +Fixes: 5a646e03e956 ("gpiolib: Return label, if set, for IRQ only line") +Fixes: a86d27693066 ("gpiolib: fix the speed of descriptor label setting with SRCU") +Signed-off-by: Lad Prabhakar +Link: https://lore.kernel.org/r/20241003131351.472015-1-prabhakar.mahadev-lad.rj@bp.renesas.com +Signed-off-by: Bartosz Golaszewski +Signed-off-by: Sasha Levin +--- + drivers/gpio/gpiolib.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c +index 3a9668cc100df..148bcfbf98e02 100644 +--- a/drivers/gpio/gpiolib.c ++++ b/drivers/gpio/gpiolib.c +@@ -115,12 +115,12 @@ const char *gpiod_get_label(struct gpio_desc *desc) + srcu_read_lock_held(&desc->gdev->desc_srcu)); + + if (test_bit(FLAG_USED_AS_IRQ, &flags)) +- return label->str ?: "interrupt"; ++ return label ? label->str : "interrupt"; + + if (!test_bit(FLAG_REQUESTED, &flags)) + return NULL; + +- return label->str; ++ return label ? label->str : NULL; + } + + static void desc_free_label(struct rcu_head *rh) +-- +2.43.0 + diff --git a/queue-6.11/io_uring-fix-memory-leak-when-cache-init-fail.patch b/queue-6.11/io_uring-fix-memory-leak-when-cache-init-fail.patch new file mode 100644 index 00000000000..865771b66f4 --- /dev/null +++ b/queue-6.11/io_uring-fix-memory-leak-when-cache-init-fail.patch @@ -0,0 +1,48 @@ +From f95ffedcfbea6a0f5271d0729da57cb9dc12e1a5 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 23 Sep 2024 18:05:12 +0800 +Subject: io_uring: fix memory leak when cache init fail + +From: Guixin Liu + +[ Upstream commit 3a87e264290d71ec86a210ab3e8d23b715ad266d ] + +Exit the percpu ref when cache init fails to free the data memory with +in struct percpu_ref. + +Fixes: 206aefde4f88 ("io_uring: reduce/pack size of io_ring_ctx") +Signed-off-by: Guixin Liu +Reviewed-by: Gabriel Krisman Bertazi +Link: https://lore.kernel.org/r/20240923100512.64638-1-kanie@linux.alibaba.com +Signed-off-by: Jens Axboe +Signed-off-by: Sasha Levin +--- + io_uring/io_uring.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c +index 25112cf78e2b3..7a166120a45c3 100644 +--- a/io_uring/io_uring.c ++++ b/io_uring/io_uring.c +@@ -321,7 +321,7 @@ static __cold struct io_ring_ctx *io_ring_ctx_alloc(struct io_uring_params *p) + sizeof(struct io_kiocb)); + ret |= io_futex_cache_init(ctx); + if (ret) +- goto err; ++ goto free_ref; + init_completion(&ctx->ref_comp); + xa_init_flags(&ctx->personalities, XA_FLAGS_ALLOC1); + mutex_init(&ctx->uring_lock); +@@ -349,6 +349,9 @@ static __cold struct io_ring_ctx *io_ring_ctx_alloc(struct io_uring_params *p) + io_napi_init(ctx); + + return ctx; ++ ++free_ref: ++ percpu_ref_exit(&ctx->refs); + err: + io_alloc_cache_free(&ctx->rsrc_node_cache, kfree); + io_alloc_cache_free(&ctx->apoll_cache, kfree); +-- +2.43.0 + diff --git a/queue-6.11/rust-kbuild-auto-generate-helper-exports.patch b/queue-6.11/rust-kbuild-auto-generate-helper-exports.patch new file mode 100644 index 00000000000..907e4a943ce --- /dev/null +++ b/queue-6.11/rust-kbuild-auto-generate-helper-exports.patch @@ -0,0 +1,327 @@ +From 3cf53551b2ad67508ebc7da27b4df3570043977b Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 17 Aug 2024 17:51:32 +0100 +Subject: rust: kbuild: auto generate helper exports + +From: Gary Guo + +[ Upstream commit e26fa546042add70944d018b930530d16b3cf626 ] + +This removes the need to explicitly export all symbols. + +Generate helper exports similarly to what's currently done for Rust +crates. These helpers are exclusively called from within Rust code and +therefore can be treated similar as other Rust symbols. + +Signed-off-by: Gary Guo +Reviewed-by: Boqun Feng +Tested-by: Boqun Feng +Link: https://lore.kernel.org/r/20240817165302.3852499-1-gary@garyguo.net +[ Fixed dependency path, reworded slightly, edited comment a bit and + rebased on top of the changes made when applying Andreas' patch + (e.g. no `README.md` anymore, so moved the edits). - Miguel ] +Signed-off-by: Miguel Ojeda +Stable-dep-of: d065cc76054d ("rust: mutex: fix __mutex_init() usage in case of PREEMPT_RT") +Signed-off-by: Sasha Levin +--- + rust/Makefile | 16 ++++++++++++++-- + rust/exports.c | 1 + + rust/helpers/blk.c | 2 -- + rust/helpers/bug.c | 1 - + rust/helpers/build_bug.c | 1 - + rust/helpers/err.c | 3 --- + rust/helpers/helpers.c | 13 ------------- + rust/helpers/kunit.c | 1 - + rust/helpers/mutex.c | 1 - + rust/helpers/page.c | 3 --- + rust/helpers/refcount.c | 3 --- + rust/helpers/signal.c | 1 - + rust/helpers/slab.c | 1 - + rust/helpers/spinlock.c | 3 --- + rust/helpers/task.c | 3 --- + rust/helpers/uaccess.c | 2 -- + rust/helpers/wait.c | 1 - + rust/helpers/workqueue.c | 1 - + 18 files changed, 15 insertions(+), 42 deletions(-) + +diff --git a/rust/Makefile b/rust/Makefile +index acfb8d7feba7e..2aa93007aacae 100644 +--- a/rust/Makefile ++++ b/rust/Makefile +@@ -16,8 +16,8 @@ no-clean-files += libmacros.so + + always-$(CONFIG_RUST) += bindings/bindings_generated.rs bindings/bindings_helpers_generated.rs + obj-$(CONFIG_RUST) += alloc.o bindings.o kernel.o +-always-$(CONFIG_RUST) += exports_alloc_generated.h exports_bindings_generated.h \ +- exports_kernel_generated.h ++always-$(CONFIG_RUST) += exports_alloc_generated.h exports_helpers_generated.h \ ++ exports_bindings_generated.h exports_kernel_generated.h + + always-$(CONFIG_RUST) += uapi/uapi_generated.rs + obj-$(CONFIG_RUST) += uapi.o +@@ -313,6 +313,18 @@ $(obj)/exports_core_generated.h: $(obj)/core.o FORCE + $(obj)/exports_alloc_generated.h: $(obj)/alloc.o FORCE + $(call if_changed,exports) + ++# Even though Rust kernel modules should never use the bindings directly, ++# symbols from the `bindings` crate and the C helpers need to be exported ++# because Rust generics and inlined functions may not get their code generated ++# in the crate where they are defined. Other helpers, called from non-inline ++# functions, may not be exported, in principle. However, in general, the Rust ++# compiler does not guarantee codegen will be performed for a non-inline ++# function either. Therefore, we export all symbols from helpers and bindings. ++# In the future, this may be revisited to reduce the number of exports after ++# the compiler is informed about the places codegen is required. ++$(obj)/exports_helpers_generated.h: $(obj)/helpers/helpers.o FORCE ++ $(call if_changed,exports) ++ + $(obj)/exports_bindings_generated.h: $(obj)/bindings.o FORCE + $(call if_changed,exports) + +diff --git a/rust/exports.c b/rust/exports.c +index 3803c21d1403e..e5695f3b45b7a 100644 +--- a/rust/exports.c ++++ b/rust/exports.c +@@ -17,6 +17,7 @@ + + #include "exports_core_generated.h" + #include "exports_alloc_generated.h" ++#include "exports_helpers_generated.h" + #include "exports_bindings_generated.h" + #include "exports_kernel_generated.h" + +diff --git a/rust/helpers/blk.c b/rust/helpers/blk.c +index d99c965eb59bf..cc9f4e6a2d234 100644 +--- a/rust/helpers/blk.c ++++ b/rust/helpers/blk.c +@@ -7,10 +7,8 @@ void *rust_helper_blk_mq_rq_to_pdu(struct request *rq) + { + return blk_mq_rq_to_pdu(rq); + } +-EXPORT_SYMBOL_GPL(rust_helper_blk_mq_rq_to_pdu); + + struct request *rust_helper_blk_mq_rq_from_pdu(void *pdu) + { + return blk_mq_rq_from_pdu(pdu); + } +-EXPORT_SYMBOL_GPL(rust_helper_blk_mq_rq_from_pdu); +diff --git a/rust/helpers/bug.c b/rust/helpers/bug.c +index e2afbad23dcda..e2d13babc7371 100644 +--- a/rust/helpers/bug.c ++++ b/rust/helpers/bug.c +@@ -6,4 +6,3 @@ __noreturn void rust_helper_BUG(void) + { + BUG(); + } +-EXPORT_SYMBOL_GPL(rust_helper_BUG); +diff --git a/rust/helpers/build_bug.c b/rust/helpers/build_bug.c +index f3106f248485a..e994f7b5928c0 100644 +--- a/rust/helpers/build_bug.c ++++ b/rust/helpers/build_bug.c +@@ -7,4 +7,3 @@ const char *rust_helper_errname(int err) + { + return errname(err); + } +-EXPORT_SYMBOL_GPL(rust_helper_errname); +diff --git a/rust/helpers/err.c b/rust/helpers/err.c +index fba4e0be64f59..be3d45ef78a25 100644 +--- a/rust/helpers/err.c ++++ b/rust/helpers/err.c +@@ -7,16 +7,13 @@ __force void *rust_helper_ERR_PTR(long err) + { + return ERR_PTR(err); + } +-EXPORT_SYMBOL_GPL(rust_helper_ERR_PTR); + + bool rust_helper_IS_ERR(__force const void *ptr) + { + return IS_ERR(ptr); + } +-EXPORT_SYMBOL_GPL(rust_helper_IS_ERR); + + long rust_helper_PTR_ERR(__force const void *ptr) + { + return PTR_ERR(ptr); + } +-EXPORT_SYMBOL_GPL(rust_helper_PTR_ERR); +diff --git a/rust/helpers/helpers.c b/rust/helpers/helpers.c +index 2b54f22e87741..173533616c917 100644 +--- a/rust/helpers/helpers.c ++++ b/rust/helpers/helpers.c +@@ -4,19 +4,6 @@ + * cannot be called either. This file explicitly creates functions ("helpers") + * that wrap those so that they can be called from Rust. + * +- * Even though Rust kernel modules should never use the bindings directly, some +- * of these helpers need to be exported because Rust generics and inlined +- * functions may not get their code generated in the crate where they are +- * defined. Other helpers, called from non-inline functions, may not be +- * exported, in principle. However, in general, the Rust compiler does not +- * guarantee codegen will be performed for a non-inline function either. +- * Therefore, this file exports all the helpers. In the future, this may be +- * revisited to reduce the number of exports after the compiler is informed +- * about the places codegen is required. +- * +- * All symbols are exported as GPL-only to guarantee no GPL-only feature is +- * accidentally exposed. +- * + * Sorted alphabetically. + */ + +diff --git a/rust/helpers/kunit.c b/rust/helpers/kunit.c +index 905e4ff4424a5..9d725067eb3bc 100644 +--- a/rust/helpers/kunit.c ++++ b/rust/helpers/kunit.c +@@ -7,4 +7,3 @@ struct kunit *rust_helper_kunit_get_current_test(void) + { + return kunit_get_current_test(); + } +-EXPORT_SYMBOL_GPL(rust_helper_kunit_get_current_test); +diff --git a/rust/helpers/mutex.c b/rust/helpers/mutex.c +index 29fd141c387d7..200db7e6279f0 100644 +--- a/rust/helpers/mutex.c ++++ b/rust/helpers/mutex.c +@@ -7,4 +7,3 @@ void rust_helper_mutex_lock(struct mutex *lock) + { + mutex_lock(lock); + } +-EXPORT_SYMBOL_GPL(rust_helper_mutex_lock); +diff --git a/rust/helpers/page.c b/rust/helpers/page.c +index 7fd333411a88f..b3f2b8fbf87fc 100644 +--- a/rust/helpers/page.c ++++ b/rust/helpers/page.c +@@ -7,16 +7,13 @@ struct page *rust_helper_alloc_pages(gfp_t gfp_mask, unsigned int order) + { + return alloc_pages(gfp_mask, order); + } +-EXPORT_SYMBOL_GPL(rust_helper_alloc_pages); + + void *rust_helper_kmap_local_page(struct page *page) + { + return kmap_local_page(page); + } +-EXPORT_SYMBOL_GPL(rust_helper_kmap_local_page); + + void rust_helper_kunmap_local(const void *addr) + { + kunmap_local(addr); + } +-EXPORT_SYMBOL_GPL(rust_helper_kunmap_local); +diff --git a/rust/helpers/refcount.c b/rust/helpers/refcount.c +index 13ab64805f779..f47afc148ec36 100644 +--- a/rust/helpers/refcount.c ++++ b/rust/helpers/refcount.c +@@ -7,16 +7,13 @@ refcount_t rust_helper_REFCOUNT_INIT(int n) + { + return (refcount_t)REFCOUNT_INIT(n); + } +-EXPORT_SYMBOL_GPL(rust_helper_REFCOUNT_INIT); + + void rust_helper_refcount_inc(refcount_t *r) + { + refcount_inc(r); + } +-EXPORT_SYMBOL_GPL(rust_helper_refcount_inc); + + bool rust_helper_refcount_dec_and_test(refcount_t *r) + { + return refcount_dec_and_test(r); + } +-EXPORT_SYMBOL_GPL(rust_helper_refcount_dec_and_test); +diff --git a/rust/helpers/signal.c b/rust/helpers/signal.c +index d44e8096b8a96..63c407f80c26b 100644 +--- a/rust/helpers/signal.c ++++ b/rust/helpers/signal.c +@@ -7,4 +7,3 @@ int rust_helper_signal_pending(struct task_struct *t) + { + return signal_pending(t); + } +-EXPORT_SYMBOL_GPL(rust_helper_signal_pending); +diff --git a/rust/helpers/slab.c b/rust/helpers/slab.c +index 3e0a1a173d8a7..f043e087f9d66 100644 +--- a/rust/helpers/slab.c ++++ b/rust/helpers/slab.c +@@ -7,4 +7,3 @@ rust_helper_krealloc(const void *objp, size_t new_size, gfp_t flags) + { + return krealloc(objp, new_size, flags); + } +-EXPORT_SYMBOL_GPL(rust_helper_krealloc); +diff --git a/rust/helpers/spinlock.c b/rust/helpers/spinlock.c +index 04fd8ddb4986d..acc1376b833c7 100644 +--- a/rust/helpers/spinlock.c ++++ b/rust/helpers/spinlock.c +@@ -12,16 +12,13 @@ void rust_helper___spin_lock_init(spinlock_t *lock, const char *name, + spin_lock_init(lock); + #endif + } +-EXPORT_SYMBOL_GPL(rust_helper___spin_lock_init); + + void rust_helper_spin_lock(spinlock_t *lock) + { + spin_lock(lock); + } +-EXPORT_SYMBOL_GPL(rust_helper_spin_lock); + + void rust_helper_spin_unlock(spinlock_t *lock) + { + spin_unlock(lock); + } +-EXPORT_SYMBOL_GPL(rust_helper_spin_unlock); +diff --git a/rust/helpers/task.c b/rust/helpers/task.c +index b176c347f0d41..7ac789232d11c 100644 +--- a/rust/helpers/task.c ++++ b/rust/helpers/task.c +@@ -7,16 +7,13 @@ struct task_struct *rust_helper_get_current(void) + { + return current; + } +-EXPORT_SYMBOL_GPL(rust_helper_get_current); + + void rust_helper_get_task_struct(struct task_struct *t) + { + get_task_struct(t); + } +-EXPORT_SYMBOL_GPL(rust_helper_get_task_struct); + + void rust_helper_put_task_struct(struct task_struct *t) + { + put_task_struct(t); + } +-EXPORT_SYMBOL_GPL(rust_helper_put_task_struct); +diff --git a/rust/helpers/uaccess.c b/rust/helpers/uaccess.c +index 3d004ac1c1805..f49076f813cd6 100644 +--- a/rust/helpers/uaccess.c ++++ b/rust/helpers/uaccess.c +@@ -7,11 +7,9 @@ unsigned long rust_helper_copy_from_user(void *to, const void __user *from, + { + return copy_from_user(to, from, n); + } +-EXPORT_SYMBOL_GPL(rust_helper_copy_from_user); + + unsigned long rust_helper_copy_to_user(void __user *to, const void *from, + unsigned long n) + { + return copy_to_user(to, from, n); + } +-EXPORT_SYMBOL_GPL(rust_helper_copy_to_user); +diff --git a/rust/helpers/wait.c b/rust/helpers/wait.c +index bf361f40c7cbc..c7336bbf27507 100644 +--- a/rust/helpers/wait.c ++++ b/rust/helpers/wait.c +@@ -7,4 +7,3 @@ void rust_helper_init_wait(struct wait_queue_entry *wq_entry) + { + init_wait(wq_entry); + } +-EXPORT_SYMBOL_GPL(rust_helper_init_wait); +diff --git a/rust/helpers/workqueue.c b/rust/helpers/workqueue.c +index 12e2ee66aa4f6..f59427acc3237 100644 +--- a/rust/helpers/workqueue.c ++++ b/rust/helpers/workqueue.c +@@ -13,4 +13,3 @@ void rust_helper_init_work_with_key(struct work_struct *work, work_func_t func, + INIT_LIST_HEAD(&work->entry); + work->func = func; + } +-EXPORT_SYMBOL_GPL(rust_helper_init_work_with_key); +-- +2.43.0 + diff --git a/queue-6.11/rust-kbuild-split-up-helpers.c.patch b/queue-6.11/rust-kbuild-split-up-helpers.c.patch new file mode 100644 index 00000000000..0dfaf129fb4 --- /dev/null +++ b/queue-6.11/rust-kbuild-split-up-helpers.c.patch @@ -0,0 +1,768 @@ +From 834fa4ea8f3b4db22d4df5f27171de85bae52393 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 15 Aug 2024 10:30:26 +0000 +Subject: rust: kbuild: split up helpers.c + +From: Andreas Hindborg + +[ Upstream commit 876346536c1b59a5b1b5e44477b1b3ece77647fd ] + +This patch splits up the rust helpers C file. When rebasing patch sets on +upstream linux, merge conflicts in helpers.c is common and time consuming +[1]. Thus, split the file so that each kernel component can live in a +separate file. + +This patch lists helper files explicitly and thus conflicts in the file +list is still likely. However, they should be more simple to resolve than +the conflicts usually seen in helpers.c. + +[ Removed `README.md` and undeleted the original comment since now, + in v3 of the series, we have a `helpers.c` again; which also allows + us to keep the "Sorted alphabetically" line and makes the diff easier. + + In addition, updated the Documentation/ mentions of the file, reworded + title and removed blank lines at the end of `page.c`. - Miguel ] + +Link: https://rust-for-linux.zulipchat.com/#narrow/stream/288089-General/topic/Splitting.20up.20helpers.2Ec/near/426694012 [1] +Signed-off-by: Andreas Hindborg +Reviewed-by: Gary Guo +Acked-by: Dirk Behme +Reviewed-by: Alice Ryhl +Reviewed-by: Benno Lossin +Link: https://lore.kernel.org/r/20240815103016.2771842-1-nmi@metaspace.dk +Signed-off-by: Miguel Ojeda +Stable-dep-of: d065cc76054d ("rust: mutex: fix __mutex_init() usage in case of PREEMPT_RT") +Signed-off-by: Sasha Levin +--- + Documentation/rust/general-information.rst | 4 +- + rust/Makefile | 6 +- + rust/helpers.c | 239 --------------------- + rust/helpers/blk.c | 16 ++ + rust/helpers/bug.c | 9 + + rust/helpers/build_assert.c | 25 +++ + rust/helpers/build_bug.c | 10 + + rust/helpers/err.c | 22 ++ + rust/helpers/helpers.c | 38 ++++ + rust/helpers/kunit.c | 10 + + rust/helpers/mutex.c | 10 + + rust/helpers/page.c | 22 ++ + rust/helpers/refcount.c | 22 ++ + rust/helpers/signal.c | 10 + + rust/helpers/slab.c | 10 + + rust/helpers/spinlock.c | 27 +++ + rust/helpers/task.c | 22 ++ + rust/helpers/uaccess.c | 17 ++ + rust/helpers/wait.c | 10 + + rust/helpers/workqueue.c | 16 ++ + 20 files changed, 301 insertions(+), 244 deletions(-) + delete mode 100644 rust/helpers.c + create mode 100644 rust/helpers/blk.c + create mode 100644 rust/helpers/bug.c + create mode 100644 rust/helpers/build_assert.c + create mode 100644 rust/helpers/build_bug.c + create mode 100644 rust/helpers/err.c + create mode 100644 rust/helpers/helpers.c + create mode 100644 rust/helpers/kunit.c + create mode 100644 rust/helpers/mutex.c + create mode 100644 rust/helpers/page.c + create mode 100644 rust/helpers/refcount.c + create mode 100644 rust/helpers/signal.c + create mode 100644 rust/helpers/slab.c + create mode 100644 rust/helpers/spinlock.c + create mode 100644 rust/helpers/task.c + create mode 100644 rust/helpers/uaccess.c + create mode 100644 rust/helpers/wait.c + create mode 100644 rust/helpers/workqueue.c + +diff --git a/Documentation/rust/general-information.rst b/Documentation/rust/general-information.rst +index e3f388ef4ee42..a82926d7b379b 100644 +--- a/Documentation/rust/general-information.rst ++++ b/Documentation/rust/general-information.rst +@@ -75,7 +75,7 @@ should provide as-safe-as-possible abstractions as needed. + .. code-block:: + + rust/bindings/ +- (rust/helpers.c) ++ (rust/helpers/) + + include/ -----+ <-+ + | | +@@ -112,7 +112,7 @@ output files in the ``rust/bindings/`` directory. + + For parts of the C header that ``bindgen`` does not auto generate, e.g. C + ``inline`` functions or non-trivial macros, it is acceptable to add a small +-wrapper function to ``rust/helpers.c`` to make it available for the Rust side as ++wrapper function to ``rust/helpers/`` to make it available for the Rust side as + well. + + Abstractions +diff --git a/rust/Makefile b/rust/Makefile +index f168d2c98a15f..acfb8d7feba7e 100644 +--- a/rust/Makefile ++++ b/rust/Makefile +@@ -8,8 +8,8 @@ always-$(CONFIG_RUST) += exports_core_generated.h + + # Missing prototypes are expected in the helpers since these are exported + # for Rust only, thus there is no header nor prototypes. +-obj-$(CONFIG_RUST) += helpers.o +-CFLAGS_REMOVE_helpers.o = -Wmissing-prototypes -Wmissing-declarations ++obj-$(CONFIG_RUST) += helpers/helpers.o ++CFLAGS_REMOVE_helpers/helpers.o = -Wmissing-prototypes -Wmissing-declarations + + always-$(CONFIG_RUST) += libmacros.so + no-clean-files += libmacros.so +@@ -299,7 +299,7 @@ $(obj)/bindings/bindings_helpers_generated.rs: private bindgen_target_cflags = \ + -I$(objtree)/$(obj) -Wno-missing-prototypes -Wno-missing-declarations + $(obj)/bindings/bindings_helpers_generated.rs: private bindgen_target_extra = ; \ + sed -Ei 's/pub fn rust_helper_([a-zA-Z0-9_]*)/#[link_name="rust_helper_\1"]\n pub fn \1/g' $@ +-$(obj)/bindings/bindings_helpers_generated.rs: $(src)/helpers.c FORCE ++$(obj)/bindings/bindings_helpers_generated.rs: $(src)/helpers/helpers.c FORCE + $(call if_changed_dep,bindgen) + + quiet_cmd_exports = EXPORTS $@ +diff --git a/rust/helpers.c b/rust/helpers.c +deleted file mode 100644 +index 92d3c03ae1bd5..0000000000000 +--- a/rust/helpers.c ++++ /dev/null +@@ -1,239 +0,0 @@ +-// SPDX-License-Identifier: GPL-2.0 +-/* +- * Non-trivial C macros cannot be used in Rust. Similarly, inlined C functions +- * cannot be called either. This file explicitly creates functions ("helpers") +- * that wrap those so that they can be called from Rust. +- * +- * Even though Rust kernel modules should never use the bindings directly, some +- * of these helpers need to be exported because Rust generics and inlined +- * functions may not get their code generated in the crate where they are +- * defined. Other helpers, called from non-inline functions, may not be +- * exported, in principle. However, in general, the Rust compiler does not +- * guarantee codegen will be performed for a non-inline function either. +- * Therefore, this file exports all the helpers. In the future, this may be +- * revisited to reduce the number of exports after the compiler is informed +- * about the places codegen is required. +- * +- * All symbols are exported as GPL-only to guarantee no GPL-only feature is +- * accidentally exposed. +- * +- * Sorted alphabetically. +- */ +- +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +- +-__noreturn void rust_helper_BUG(void) +-{ +- BUG(); +-} +-EXPORT_SYMBOL_GPL(rust_helper_BUG); +- +-unsigned long rust_helper_copy_from_user(void *to, const void __user *from, +- unsigned long n) +-{ +- return copy_from_user(to, from, n); +-} +-EXPORT_SYMBOL_GPL(rust_helper_copy_from_user); +- +-unsigned long rust_helper_copy_to_user(void __user *to, const void *from, +- unsigned long n) +-{ +- return copy_to_user(to, from, n); +-} +-EXPORT_SYMBOL_GPL(rust_helper_copy_to_user); +- +-void rust_helper_mutex_lock(struct mutex *lock) +-{ +- mutex_lock(lock); +-} +-EXPORT_SYMBOL_GPL(rust_helper_mutex_lock); +- +-void rust_helper___spin_lock_init(spinlock_t *lock, const char *name, +- struct lock_class_key *key) +-{ +-#ifdef CONFIG_DEBUG_SPINLOCK +- __raw_spin_lock_init(spinlock_check(lock), name, key, LD_WAIT_CONFIG); +-#else +- spin_lock_init(lock); +-#endif +-} +-EXPORT_SYMBOL_GPL(rust_helper___spin_lock_init); +- +-void rust_helper_spin_lock(spinlock_t *lock) +-{ +- spin_lock(lock); +-} +-EXPORT_SYMBOL_GPL(rust_helper_spin_lock); +- +-void rust_helper_spin_unlock(spinlock_t *lock) +-{ +- spin_unlock(lock); +-} +-EXPORT_SYMBOL_GPL(rust_helper_spin_unlock); +- +-void rust_helper_init_wait(struct wait_queue_entry *wq_entry) +-{ +- init_wait(wq_entry); +-} +-EXPORT_SYMBOL_GPL(rust_helper_init_wait); +- +-int rust_helper_signal_pending(struct task_struct *t) +-{ +- return signal_pending(t); +-} +-EXPORT_SYMBOL_GPL(rust_helper_signal_pending); +- +-struct page *rust_helper_alloc_pages(gfp_t gfp_mask, unsigned int order) +-{ +- return alloc_pages(gfp_mask, order); +-} +-EXPORT_SYMBOL_GPL(rust_helper_alloc_pages); +- +-void *rust_helper_kmap_local_page(struct page *page) +-{ +- return kmap_local_page(page); +-} +-EXPORT_SYMBOL_GPL(rust_helper_kmap_local_page); +- +-void rust_helper_kunmap_local(const void *addr) +-{ +- kunmap_local(addr); +-} +-EXPORT_SYMBOL_GPL(rust_helper_kunmap_local); +- +-refcount_t rust_helper_REFCOUNT_INIT(int n) +-{ +- return (refcount_t)REFCOUNT_INIT(n); +-} +-EXPORT_SYMBOL_GPL(rust_helper_REFCOUNT_INIT); +- +-void rust_helper_refcount_inc(refcount_t *r) +-{ +- refcount_inc(r); +-} +-EXPORT_SYMBOL_GPL(rust_helper_refcount_inc); +- +-bool rust_helper_refcount_dec_and_test(refcount_t *r) +-{ +- return refcount_dec_and_test(r); +-} +-EXPORT_SYMBOL_GPL(rust_helper_refcount_dec_and_test); +- +-__force void *rust_helper_ERR_PTR(long err) +-{ +- return ERR_PTR(err); +-} +-EXPORT_SYMBOL_GPL(rust_helper_ERR_PTR); +- +-bool rust_helper_IS_ERR(__force const void *ptr) +-{ +- return IS_ERR(ptr); +-} +-EXPORT_SYMBOL_GPL(rust_helper_IS_ERR); +- +-long rust_helper_PTR_ERR(__force const void *ptr) +-{ +- return PTR_ERR(ptr); +-} +-EXPORT_SYMBOL_GPL(rust_helper_PTR_ERR); +- +-const char *rust_helper_errname(int err) +-{ +- return errname(err); +-} +-EXPORT_SYMBOL_GPL(rust_helper_errname); +- +-struct task_struct *rust_helper_get_current(void) +-{ +- return current; +-} +-EXPORT_SYMBOL_GPL(rust_helper_get_current); +- +-void rust_helper_get_task_struct(struct task_struct *t) +-{ +- get_task_struct(t); +-} +-EXPORT_SYMBOL_GPL(rust_helper_get_task_struct); +- +-void rust_helper_put_task_struct(struct task_struct *t) +-{ +- put_task_struct(t); +-} +-EXPORT_SYMBOL_GPL(rust_helper_put_task_struct); +- +-struct kunit *rust_helper_kunit_get_current_test(void) +-{ +- return kunit_get_current_test(); +-} +-EXPORT_SYMBOL_GPL(rust_helper_kunit_get_current_test); +- +-void rust_helper_init_work_with_key(struct work_struct *work, work_func_t func, +- bool onstack, const char *name, +- struct lock_class_key *key) +-{ +- __init_work(work, onstack); +- work->data = (atomic_long_t)WORK_DATA_INIT(); +- lockdep_init_map(&work->lockdep_map, name, key, 0); +- INIT_LIST_HEAD(&work->entry); +- work->func = func; +-} +-EXPORT_SYMBOL_GPL(rust_helper_init_work_with_key); +- +-void * __must_check __realloc_size(2) +-rust_helper_krealloc(const void *objp, size_t new_size, gfp_t flags) +-{ +- return krealloc(objp, new_size, flags); +-} +-EXPORT_SYMBOL_GPL(rust_helper_krealloc); +- +-/* +- * `bindgen` binds the C `size_t` type as the Rust `usize` type, so we can +- * use it in contexts where Rust expects a `usize` like slice (array) indices. +- * `usize` is defined to be the same as C's `uintptr_t` type (can hold any +- * pointer) but not necessarily the same as `size_t` (can hold the size of any +- * single object). Most modern platforms use the same concrete integer type for +- * both of them, but in case we find ourselves on a platform where +- * that's not true, fail early instead of risking ABI or +- * integer-overflow issues. +- * +- * If your platform fails this assertion, it means that you are in +- * danger of integer-overflow bugs (even if you attempt to add +- * `--no-size_t-is-usize`). It may be easiest to change the kernel ABI on +- * your platform such that `size_t` matches `uintptr_t` (i.e., to increase +- * `size_t`, because `uintptr_t` has to be at least as big as `size_t`). +- */ +-static_assert( +- sizeof(size_t) == sizeof(uintptr_t) && +- __alignof__(size_t) == __alignof__(uintptr_t), +- "Rust code expects C `size_t` to match Rust `usize`" +-); +- +-// This will soon be moved to a separate file, so no need to merge with above. +-#include +-#include +- +-void *rust_helper_blk_mq_rq_to_pdu(struct request *rq) +-{ +- return blk_mq_rq_to_pdu(rq); +-} +-EXPORT_SYMBOL_GPL(rust_helper_blk_mq_rq_to_pdu); +- +-struct request *rust_helper_blk_mq_rq_from_pdu(void *pdu) +-{ +- return blk_mq_rq_from_pdu(pdu); +-} +-EXPORT_SYMBOL_GPL(rust_helper_blk_mq_rq_from_pdu); +diff --git a/rust/helpers/blk.c b/rust/helpers/blk.c +new file mode 100644 +index 0000000000000..d99c965eb59bf +--- /dev/null ++++ b/rust/helpers/blk.c +@@ -0,0 +1,16 @@ ++// SPDX-License-Identifier: GPL-2.0 ++ ++#include ++#include ++ ++void *rust_helper_blk_mq_rq_to_pdu(struct request *rq) ++{ ++ return blk_mq_rq_to_pdu(rq); ++} ++EXPORT_SYMBOL_GPL(rust_helper_blk_mq_rq_to_pdu); ++ ++struct request *rust_helper_blk_mq_rq_from_pdu(void *pdu) ++{ ++ return blk_mq_rq_from_pdu(pdu); ++} ++EXPORT_SYMBOL_GPL(rust_helper_blk_mq_rq_from_pdu); +diff --git a/rust/helpers/bug.c b/rust/helpers/bug.c +new file mode 100644 +index 0000000000000..e2afbad23dcda +--- /dev/null ++++ b/rust/helpers/bug.c +@@ -0,0 +1,9 @@ ++// SPDX-License-Identifier: GPL-2.0 ++ ++#include ++ ++__noreturn void rust_helper_BUG(void) ++{ ++ BUG(); ++} ++EXPORT_SYMBOL_GPL(rust_helper_BUG); +diff --git a/rust/helpers/build_assert.c b/rust/helpers/build_assert.c +new file mode 100644 +index 0000000000000..6a54b2680b145 +--- /dev/null ++++ b/rust/helpers/build_assert.c +@@ -0,0 +1,25 @@ ++// SPDX-License-Identifier: GPL-2.0 ++ ++#include ++ ++/* ++ * `bindgen` binds the C `size_t` type as the Rust `usize` type, so we can ++ * use it in contexts where Rust expects a `usize` like slice (array) indices. ++ * `usize` is defined to be the same as C's `uintptr_t` type (can hold any ++ * pointer) but not necessarily the same as `size_t` (can hold the size of any ++ * single object). Most modern platforms use the same concrete integer type for ++ * both of them, but in case we find ourselves on a platform where ++ * that's not true, fail early instead of risking ABI or ++ * integer-overflow issues. ++ * ++ * If your platform fails this assertion, it means that you are in ++ * danger of integer-overflow bugs (even if you attempt to add ++ * `--no-size_t-is-usize`). It may be easiest to change the kernel ABI on ++ * your platform such that `size_t` matches `uintptr_t` (i.e., to increase ++ * `size_t`, because `uintptr_t` has to be at least as big as `size_t`). ++ */ ++static_assert( ++ sizeof(size_t) == sizeof(uintptr_t) && ++ __alignof__(size_t) == __alignof__(uintptr_t), ++ "Rust code expects C `size_t` to match Rust `usize`" ++); +diff --git a/rust/helpers/build_bug.c b/rust/helpers/build_bug.c +new file mode 100644 +index 0000000000000..f3106f248485a +--- /dev/null ++++ b/rust/helpers/build_bug.c +@@ -0,0 +1,10 @@ ++// SPDX-License-Identifier: GPL-2.0 ++ ++#include ++#include ++ ++const char *rust_helper_errname(int err) ++{ ++ return errname(err); ++} ++EXPORT_SYMBOL_GPL(rust_helper_errname); +diff --git a/rust/helpers/err.c b/rust/helpers/err.c +new file mode 100644 +index 0000000000000..fba4e0be64f59 +--- /dev/null ++++ b/rust/helpers/err.c +@@ -0,0 +1,22 @@ ++// SPDX-License-Identifier: GPL-2.0 ++ ++#include ++#include ++ ++__force void *rust_helper_ERR_PTR(long err) ++{ ++ return ERR_PTR(err); ++} ++EXPORT_SYMBOL_GPL(rust_helper_ERR_PTR); ++ ++bool rust_helper_IS_ERR(__force const void *ptr) ++{ ++ return IS_ERR(ptr); ++} ++EXPORT_SYMBOL_GPL(rust_helper_IS_ERR); ++ ++long rust_helper_PTR_ERR(__force const void *ptr) ++{ ++ return PTR_ERR(ptr); ++} ++EXPORT_SYMBOL_GPL(rust_helper_PTR_ERR); +diff --git a/rust/helpers/helpers.c b/rust/helpers/helpers.c +new file mode 100644 +index 0000000000000..2b54f22e87741 +--- /dev/null ++++ b/rust/helpers/helpers.c +@@ -0,0 +1,38 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/* ++ * Non-trivial C macros cannot be used in Rust. Similarly, inlined C functions ++ * cannot be called either. This file explicitly creates functions ("helpers") ++ * that wrap those so that they can be called from Rust. ++ * ++ * Even though Rust kernel modules should never use the bindings directly, some ++ * of these helpers need to be exported because Rust generics and inlined ++ * functions may not get their code generated in the crate where they are ++ * defined. Other helpers, called from non-inline functions, may not be ++ * exported, in principle. However, in general, the Rust compiler does not ++ * guarantee codegen will be performed for a non-inline function either. ++ * Therefore, this file exports all the helpers. In the future, this may be ++ * revisited to reduce the number of exports after the compiler is informed ++ * about the places codegen is required. ++ * ++ * All symbols are exported as GPL-only to guarantee no GPL-only feature is ++ * accidentally exposed. ++ * ++ * Sorted alphabetically. ++ */ ++ ++#include "blk.c" ++#include "bug.c" ++#include "build_assert.c" ++#include "build_bug.c" ++#include "err.c" ++#include "kunit.c" ++#include "mutex.c" ++#include "page.c" ++#include "refcount.c" ++#include "signal.c" ++#include "slab.c" ++#include "spinlock.c" ++#include "task.c" ++#include "uaccess.c" ++#include "wait.c" ++#include "workqueue.c" +diff --git a/rust/helpers/kunit.c b/rust/helpers/kunit.c +new file mode 100644 +index 0000000000000..905e4ff4424a5 +--- /dev/null ++++ b/rust/helpers/kunit.c +@@ -0,0 +1,10 @@ ++// SPDX-License-Identifier: GPL-2.0 ++ ++#include ++#include ++ ++struct kunit *rust_helper_kunit_get_current_test(void) ++{ ++ return kunit_get_current_test(); ++} ++EXPORT_SYMBOL_GPL(rust_helper_kunit_get_current_test); +diff --git a/rust/helpers/mutex.c b/rust/helpers/mutex.c +new file mode 100644 +index 0000000000000..29fd141c387d7 +--- /dev/null ++++ b/rust/helpers/mutex.c +@@ -0,0 +1,10 @@ ++// SPDX-License-Identifier: GPL-2.0 ++ ++#include ++#include ++ ++void rust_helper_mutex_lock(struct mutex *lock) ++{ ++ mutex_lock(lock); ++} ++EXPORT_SYMBOL_GPL(rust_helper_mutex_lock); +diff --git a/rust/helpers/page.c b/rust/helpers/page.c +new file mode 100644 +index 0000000000000..7fd333411a88f +--- /dev/null ++++ b/rust/helpers/page.c +@@ -0,0 +1,22 @@ ++// SPDX-License-Identifier: GPL-2.0 ++ ++#include ++#include ++ ++struct page *rust_helper_alloc_pages(gfp_t gfp_mask, unsigned int order) ++{ ++ return alloc_pages(gfp_mask, order); ++} ++EXPORT_SYMBOL_GPL(rust_helper_alloc_pages); ++ ++void *rust_helper_kmap_local_page(struct page *page) ++{ ++ return kmap_local_page(page); ++} ++EXPORT_SYMBOL_GPL(rust_helper_kmap_local_page); ++ ++void rust_helper_kunmap_local(const void *addr) ++{ ++ kunmap_local(addr); ++} ++EXPORT_SYMBOL_GPL(rust_helper_kunmap_local); +diff --git a/rust/helpers/refcount.c b/rust/helpers/refcount.c +new file mode 100644 +index 0000000000000..13ab64805f779 +--- /dev/null ++++ b/rust/helpers/refcount.c +@@ -0,0 +1,22 @@ ++// SPDX-License-Identifier: GPL-2.0 ++ ++#include ++#include ++ ++refcount_t rust_helper_REFCOUNT_INIT(int n) ++{ ++ return (refcount_t)REFCOUNT_INIT(n); ++} ++EXPORT_SYMBOL_GPL(rust_helper_REFCOUNT_INIT); ++ ++void rust_helper_refcount_inc(refcount_t *r) ++{ ++ refcount_inc(r); ++} ++EXPORT_SYMBOL_GPL(rust_helper_refcount_inc); ++ ++bool rust_helper_refcount_dec_and_test(refcount_t *r) ++{ ++ return refcount_dec_and_test(r); ++} ++EXPORT_SYMBOL_GPL(rust_helper_refcount_dec_and_test); +diff --git a/rust/helpers/signal.c b/rust/helpers/signal.c +new file mode 100644 +index 0000000000000..d44e8096b8a96 +--- /dev/null ++++ b/rust/helpers/signal.c +@@ -0,0 +1,10 @@ ++// SPDX-License-Identifier: GPL-2.0 ++ ++#include ++#include ++ ++int rust_helper_signal_pending(struct task_struct *t) ++{ ++ return signal_pending(t); ++} ++EXPORT_SYMBOL_GPL(rust_helper_signal_pending); +diff --git a/rust/helpers/slab.c b/rust/helpers/slab.c +new file mode 100644 +index 0000000000000..3e0a1a173d8a7 +--- /dev/null ++++ b/rust/helpers/slab.c +@@ -0,0 +1,10 @@ ++// SPDX-License-Identifier: GPL-2.0 ++ ++#include ++ ++void * __must_check __realloc_size(2) ++rust_helper_krealloc(const void *objp, size_t new_size, gfp_t flags) ++{ ++ return krealloc(objp, new_size, flags); ++} ++EXPORT_SYMBOL_GPL(rust_helper_krealloc); +diff --git a/rust/helpers/spinlock.c b/rust/helpers/spinlock.c +new file mode 100644 +index 0000000000000..04fd8ddb4986d +--- /dev/null ++++ b/rust/helpers/spinlock.c +@@ -0,0 +1,27 @@ ++// SPDX-License-Identifier: GPL-2.0 ++ ++#include ++#include ++ ++void rust_helper___spin_lock_init(spinlock_t *lock, const char *name, ++ struct lock_class_key *key) ++{ ++#ifdef CONFIG_DEBUG_SPINLOCK ++ __raw_spin_lock_init(spinlock_check(lock), name, key, LD_WAIT_CONFIG); ++#else ++ spin_lock_init(lock); ++#endif ++} ++EXPORT_SYMBOL_GPL(rust_helper___spin_lock_init); ++ ++void rust_helper_spin_lock(spinlock_t *lock) ++{ ++ spin_lock(lock); ++} ++EXPORT_SYMBOL_GPL(rust_helper_spin_lock); ++ ++void rust_helper_spin_unlock(spinlock_t *lock) ++{ ++ spin_unlock(lock); ++} ++EXPORT_SYMBOL_GPL(rust_helper_spin_unlock); +diff --git a/rust/helpers/task.c b/rust/helpers/task.c +new file mode 100644 +index 0000000000000..b176c347f0d41 +--- /dev/null ++++ b/rust/helpers/task.c +@@ -0,0 +1,22 @@ ++// SPDX-License-Identifier: GPL-2.0 ++ ++#include ++#include ++ ++struct task_struct *rust_helper_get_current(void) ++{ ++ return current; ++} ++EXPORT_SYMBOL_GPL(rust_helper_get_current); ++ ++void rust_helper_get_task_struct(struct task_struct *t) ++{ ++ get_task_struct(t); ++} ++EXPORT_SYMBOL_GPL(rust_helper_get_task_struct); ++ ++void rust_helper_put_task_struct(struct task_struct *t) ++{ ++ put_task_struct(t); ++} ++EXPORT_SYMBOL_GPL(rust_helper_put_task_struct); +diff --git a/rust/helpers/uaccess.c b/rust/helpers/uaccess.c +new file mode 100644 +index 0000000000000..3d004ac1c1805 +--- /dev/null ++++ b/rust/helpers/uaccess.c +@@ -0,0 +1,17 @@ ++// SPDX-License-Identifier: GPL-2.0 ++ ++#include ++ ++unsigned long rust_helper_copy_from_user(void *to, const void __user *from, ++ unsigned long n) ++{ ++ return copy_from_user(to, from, n); ++} ++EXPORT_SYMBOL_GPL(rust_helper_copy_from_user); ++ ++unsigned long rust_helper_copy_to_user(void __user *to, const void *from, ++ unsigned long n) ++{ ++ return copy_to_user(to, from, n); ++} ++EXPORT_SYMBOL_GPL(rust_helper_copy_to_user); +diff --git a/rust/helpers/wait.c b/rust/helpers/wait.c +new file mode 100644 +index 0000000000000..bf361f40c7cbc +--- /dev/null ++++ b/rust/helpers/wait.c +@@ -0,0 +1,10 @@ ++// SPDX-License-Identifier: GPL-2.0 ++ ++#include ++#include ++ ++void rust_helper_init_wait(struct wait_queue_entry *wq_entry) ++{ ++ init_wait(wq_entry); ++} ++EXPORT_SYMBOL_GPL(rust_helper_init_wait); +diff --git a/rust/helpers/workqueue.c b/rust/helpers/workqueue.c +new file mode 100644 +index 0000000000000..12e2ee66aa4f6 +--- /dev/null ++++ b/rust/helpers/workqueue.c +@@ -0,0 +1,16 @@ ++// SPDX-License-Identifier: GPL-2.0 ++ ++#include ++#include ++ ++void rust_helper_init_work_with_key(struct work_struct *work, work_func_t func, ++ bool onstack, const char *name, ++ struct lock_class_key *key) ++{ ++ __init_work(work, onstack); ++ work->data = (atomic_long_t)WORK_DATA_INIT(); ++ lockdep_init_map(&work->lockdep_map, name, key, 0); ++ INIT_LIST_HEAD(&work->entry); ++ work->func = func; ++} ++EXPORT_SYMBOL_GPL(rust_helper_init_work_with_key); +-- +2.43.0 + diff --git a/queue-6.11/rust-mutex-fix-__mutex_init-usage-in-case-of-preempt.patch b/queue-6.11/rust-mutex-fix-__mutex_init-usage-in-case-of-preempt.patch new file mode 100644 index 00000000000..4013859cbb9 --- /dev/null +++ b/queue-6.11/rust-mutex-fix-__mutex_init-usage-in-case-of-preempt.patch @@ -0,0 +1,80 @@ +From b02ff80e55d1439c24dd1b86b5797f02ebac190d Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 16 Sep 2024 09:37:52 +0200 +Subject: rust: mutex: fix __mutex_init() usage in case of PREEMPT_RT + +From: Dirk Behme + +[ Upstream commit d065cc76054d21e48a839a2a19ba99dbc51a4d11 ] + +In case CONFIG_PREEMPT_RT is enabled __mutex_init() becomes a macro +instead of an extern function (simplified from +include/linux/mutex.h): + + #ifndef CONFIG_PREEMPT_RT + extern void __mutex_init(struct mutex *lock, const char *name, + struct lock_class_key *key); + #else + #define __mutex_init(mutex, name, key) \ + do { \ + rt_mutex_base_init(&(mutex)->rtmutex); \ + __mutex_rt_init((mutex), name, key); \ + } while (0) + #endif + +The macro isn't resolved by bindgen, then. What results in a build +error: + +error[E0425]: cannot find function `__mutex_init` in crate `bindings` + --> rust/kernel/sync/lock/mutex.rs:104:28 + | +104 | unsafe { bindings::__mutex_init(ptr, name, key) } + | ^^^^^^^^^^^^ help: a function with a similar name exists: `__mutex_rt_init` + | + ::: rust/bindings/bindings_generated.rs:23722:5 + | +23722 | / pub fn __mutex_rt_init( +23723 | | lock: *mut mutex, +23724 | | name: *const core::ffi::c_char, +23725 | | key: *mut lock_class_key, +23726 | | ); + | |_____- similarly named function `__mutex_rt_init` defined here + +Fix this by adding a helper. + +As explained by Gary Guo in [1] no #ifdef CONFIG_PREEMPT_RT +is needed here as rust/bindings/lib.rs prefers externed function to +helpers if an externed function exists. + +Reported-by: Conor Dooley +Link: https://lore.kernel.org/rust-for-linux/20240913-shack-estate-b376a65921b1@spud/ +Link: https://lore.kernel.org/rust-for-linux/20240915123626.1a170103.gary@garyguo.net/ [1] +Fixes: 6d20d629c6d8 ("rust: lock: introduce `Mutex`") +Signed-off-by: Dirk Behme +Tested-by: Conor Dooley +Reviewed-by: Gary Guo +Link: https://lore.kernel.org/r/20240916073752.3123484-1-dirk.behme@de.bosch.com +[ Reworded to include the proper example by Dirk. - Miguel ] +Signed-off-by: Miguel Ojeda +Signed-off-by: Sasha Levin +--- + rust/helpers/mutex.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/rust/helpers/mutex.c b/rust/helpers/mutex.c +index 200db7e6279f0..a17ca8cdb50ca 100644 +--- a/rust/helpers/mutex.c ++++ b/rust/helpers/mutex.c +@@ -7,3 +7,9 @@ void rust_helper_mutex_lock(struct mutex *lock) + { + mutex_lock(lock); + } ++ ++void rust_helper___mutex_init(struct mutex *mutex, const char *name, ++ struct lock_class_key *key) ++{ ++ __mutex_init(mutex, name, key); ++} +-- +2.43.0 + diff --git a/queue-6.11/series b/queue-6.11/series index 81dc5f36b99..e4ae7ef3cce 100644 --- a/queue-6.11/series +++ b/queue-6.11/series @@ -52,3 +52,32 @@ net-ncsi-disable-the-ncsi-work-before-freeing-the-as.patch iomap-constrain-the-file-range-passed-to-iomap_file_.patch dt-bindings-net-xlnx-axi-ethernet-add-missing-reg-mi.patch sctp-set-sk_state-back-to-closed-if-autobind-fails-i.patch +asoc-topology-fix-incorrect-addressing-assignments.patch +drm-panthor-fix-race-when-converting-group-handle-to.patch +asoc-atmel-mchp-pdmc-skip-alsa-restoration-if-substr.patch +drm-connector-hdmi-fix-writing-dynamic-range-masteri.patch +io_uring-fix-memory-leak-when-cache-init-fail.patch +rust-kbuild-split-up-helpers.c.patch +rust-kbuild-auto-generate-helper-exports.patch +rust-mutex-fix-__mutex_init-usage-in-case-of-preempt.patch +alsa-mixer_oss-remove-some-incorrect-kfree_const-usa.patch +alsa-hda-realtek-fix-the-push-button-function-for-th.patch +cifs-remove-intermediate-object-of-failed-create-rep.patch +asoc-intel-soc-acpi-intel-rpl-match-add-missing-empt.patch +drm-panthor-lock-the-vm-resv-before-calling-drm_gpuv.patch +alsa-hda-generic-unconditionally-prefer-preferred_da.patch +asoc-imx-card-set-card.owner-to-avoid-a-warning-call.patch +drm-xe-restore-pci-state-upon-resume.patch +drm-xe-guc_submit-add-missing-locking-in-wedged_fini.patch +drm-xe-resume-tdr-after-gt-reset.patch +drm-xe-prevent-null-pointer-access-in-xe_migrate_cop.patch +cifs-fix-buffer-overflow-when-parsing-nfs-reparse-po.patch +cifs-do-not-convert-delimiter-when-parsing-nfs-style.patch +gpiolib-fix-potential-null-pointer-dereference-in-gp.patch +tools-rtla-fix-installation-from-out-of-tree-build.patch +alsa-gus-fix-some-error-handling-paths-related-to-ge.patch +alsa-hda-conexant-fix-conflicting-quirk-for-system76.patch +drm-amd-display-disable-replay-if-vrr-capability-is-.patch +drm-amd-display-fix-vrr-cannot-enable.patch +drm-amd-display-re-enable-panel-replay-feature.patch +e1000e-avoid-failing-the-system-during-pm_suspend.patch diff --git a/queue-6.11/tools-rtla-fix-installation-from-out-of-tree-build.patch b/queue-6.11/tools-rtla-fix-installation-from-out-of-tree-build.patch new file mode 100644 index 00000000000..708a5dd8be3 --- /dev/null +++ b/queue-6.11/tools-rtla-fix-installation-from-out-of-tree-build.patch @@ -0,0 +1,40 @@ +From aa0435f91b1523bb71b5322c9513cee69fafa0f9 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 16 Sep 2024 01:31:58 +0200 +Subject: tools/rtla: Fix installation from out-of-tree build + +From: Ben Hutchings + +[ Upstream commit f771d5369f1dbfe32c93bcb4f5d7ca8322b15389 ] + +rtla now supports out-of-tree builds, but installation fails as it +still tries to install the rtla binary from the source tree. Use the +existing macro $(RTLA) to refer to the binary. + +Link: https://lore.kernel.org/ZudubuoU_JHjPZ7w@decadent.org.uk +Fixes: 01474dc706ca ("tools/rtla: Use tools/build makefiles to build rtla") +Reviewed-by: Tomas Glozar +Tested-by: Tomas Glozar +Signed-off-by: Ben Hutchings +Signed-off-by: Steven Rostedt (Google) +Signed-off-by: Sasha Levin +--- + tools/tracing/rtla/Makefile.rtla | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tools/tracing/rtla/Makefile.rtla b/tools/tracing/rtla/Makefile.rtla +index 3ff0b8970896f..cc1d6b615475f 100644 +--- a/tools/tracing/rtla/Makefile.rtla ++++ b/tools/tracing/rtla/Makefile.rtla +@@ -38,7 +38,7 @@ BINDIR := /usr/bin + .PHONY: install + install: doc_install + @$(MKDIR) -p $(DESTDIR)$(BINDIR) +- $(call QUIET_INSTALL,rtla)$(INSTALL) rtla -m 755 $(DESTDIR)$(BINDIR) ++ $(call QUIET_INSTALL,rtla)$(INSTALL) $(RTLA) -m 755 $(DESTDIR)$(BINDIR) + @$(STRIP) $(DESTDIR)$(BINDIR)/rtla + @test ! -f $(DESTDIR)$(BINDIR)/osnoise || $(RM) $(DESTDIR)$(BINDIR)/osnoise + @$(LN) rtla $(DESTDIR)$(BINDIR)/osnoise +-- +2.43.0 +