From: Sasha Levin Date: Sun, 21 Nov 2021 23:00:31 +0000 (-0500) Subject: Fixes for 5.15 X-Git-Tag: v5.15.5~83 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=911efc5c2d9c66d49b6699799e393a4ce77f0652;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 5.15 Signed-off-by: Sasha Levin --- diff --git a/queue-5.15/alsa-gus-fix-null-pointer-dereference-on-pointer-blo.patch b/queue-5.15/alsa-gus-fix-null-pointer-dereference-on-pointer-blo.patch new file mode 100644 index 00000000000..77dc7df5ccd --- /dev/null +++ b/queue-5.15/alsa-gus-fix-null-pointer-dereference-on-pointer-blo.patch @@ -0,0 +1,37 @@ +From b5e41be139979251d52bc7370f4b846fd3dca0ee Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 24 Oct 2021 03:46:11 -0700 +Subject: ALSA: gus: fix null pointer dereference on pointer block + +From: Chengfeng Ye + +[ Upstream commit a0d21bb3279476c777434c40d969ea88ca64f9aa ] + +The pointer block return from snd_gf1_dma_next_block could be +null, so there is a potential null pointer dereference issue. +Fix this by adding a null check before dereference. + +Signed-off-by: Chengfeng Ye +Link: https://lore.kernel.org/r/20211024104611.9919-1-cyeaa@connect.ust.hk +Signed-off-by: Takashi Iwai +Signed-off-by: Sasha Levin +--- + sound/isa/gus/gus_dma.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/sound/isa/gus/gus_dma.c b/sound/isa/gus/gus_dma.c +index a1c770d826dda..6d664dd8dde0b 100644 +--- a/sound/isa/gus/gus_dma.c ++++ b/sound/isa/gus/gus_dma.c +@@ -126,6 +126,8 @@ static void snd_gf1_dma_interrupt(struct snd_gus_card * gus) + } + block = snd_gf1_dma_next_block(gus); + spin_unlock(&gus->dma_lock); ++ if (!block) ++ return; + snd_gf1_dma_program(gus, block->addr, block->buf_addr, block->count, (unsigned short) block->cmd); + kfree(block); + #if 0 +-- +2.33.0 + diff --git a/queue-5.15/alsa-intel-dsp-config-add-quirk-for-apl-glk-tgl-devi.patch b/queue-5.15/alsa-intel-dsp-config-add-quirk-for-apl-glk-tgl-devi.patch new file mode 100644 index 00000000000..e4f6579e0a8 --- /dev/null +++ b/queue-5.15/alsa-intel-dsp-config-add-quirk-for-apl-glk-tgl-devi.patch @@ -0,0 +1,103 @@ +From 1826f4829368e25dc584bbefdd3a6e25e805b0be Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 4 Oct 2021 16:35:09 -0500 +Subject: ALSA: intel-dsp-config: add quirk for APL/GLK/TGL devices based on + ES8336 codec + +From: Pierre-Louis Bossart + +[ Upstream commit 9d36ceab94151f07cf3fcb067213ac87937adf12 ] + +These devices are based on an I2C/I2S device, we need to force the use +of the SOF driver otherwise the legacy HDaudio driver will be loaded - +only HDMI will be supported. + +Co-developed-by: Huajun Li +Signed-off-by: Huajun Li +Signed-off-by: Pierre-Louis Bossart +Reviewed-by: Kai Vehmanen +Link: https://lore.kernel.org/r/20211004213512.220836-3-pierre-louis.bossart@linux.intel.com +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + sound/hda/intel-dsp-config.c | 22 ++++++++++++++++++++-- + 1 file changed, 20 insertions(+), 2 deletions(-) + +diff --git a/sound/hda/intel-dsp-config.c b/sound/hda/intel-dsp-config.c +index c9d0ba353463b..b9ac9e9e45a48 100644 +--- a/sound/hda/intel-dsp-config.c ++++ b/sound/hda/intel-dsp-config.c +@@ -31,6 +31,7 @@ struct config_entry { + u16 device; + u8 acpi_hid[ACPI_ID_LEN]; + const struct dmi_system_id *dmi_table; ++ u8 codec_hid[ACPI_ID_LEN]; + }; + + /* +@@ -56,7 +57,7 @@ static const struct config_entry config_table[] = { + /* + * Apollolake (Broxton-P) + * the legacy HDAudio driver is used except on Up Squared (SOF) and +- * Chromebooks (SST) ++ * Chromebooks (SST), as well as devices based on the ES8336 codec + */ + #if IS_ENABLED(CONFIG_SND_SOC_SOF_APOLLOLAKE) + { +@@ -73,6 +74,11 @@ static const struct config_entry config_table[] = { + {} + } + }, ++ { ++ .flags = FLAG_SOF, ++ .device = 0x5a98, ++ .codec_hid = "ESSX8336", ++ }, + #endif + #if IS_ENABLED(CONFIG_SND_SOC_INTEL_APL) + { +@@ -137,7 +143,7 @@ static const struct config_entry config_table[] = { + + /* + * Geminilake uses legacy HDAudio driver except for Google +- * Chromebooks ++ * Chromebooks and devices based on the ES8336 codec + */ + /* Geminilake */ + #if IS_ENABLED(CONFIG_SND_SOC_SOF_GEMINILAKE) +@@ -154,6 +160,11 @@ static const struct config_entry config_table[] = { + {} + } + }, ++ { ++ .flags = FLAG_SOF, ++ .device = 0x3198, ++ .codec_hid = "ESSX8336", ++ }, + #endif + + /* +@@ -311,6 +322,11 @@ static const struct config_entry config_table[] = { + .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, + .device = 0x43c8, + }, ++ { ++ .flags = FLAG_SOF, ++ .device = 0xa0c8, ++ .codec_hid = "ESSX8336", ++ }, + #endif + + /* Elkhart Lake */ +@@ -354,6 +370,8 @@ static const struct config_entry *snd_intel_dsp_find_config + continue; + if (table->dmi_table && !dmi_check_system(table->dmi_table)) + continue; ++ if (table->codec_hid[0] && !acpi_dev_present(table->codec_hid, NULL, -1)) ++ continue; + return table; + } + return NULL; +-- +2.33.0 + diff --git a/queue-5.15/alsa-isa-not-for-m68k.patch b/queue-5.15/alsa-isa-not-for-m68k.patch new file mode 100644 index 00000000000..3a2e46cb4d4 --- /dev/null +++ b/queue-5.15/alsa-isa-not-for-m68k.patch @@ -0,0 +1,88 @@ +From f400598bb485c81011c6c65e1e2b57683faca8ac Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 15 Oct 2021 23:26:02 -0700 +Subject: ALSA: ISA: not for M68K + +From: Randy Dunlap + +[ Upstream commit 3c05f1477e62ea5a0a8797ba6a545b1dc751fb31 ] + +On m68k, compiling drivers under SND_ISA causes build errors: + +../sound/core/isadma.c: In function 'snd_dma_program': +../sound/core/isadma.c:33:17: error: implicit declaration of function 'claim_dma_lock' [-Werror=implicit-function-declaration] + 33 | flags = claim_dma_lock(); + | ^~~~~~~~~~~~~~ +../sound/core/isadma.c:41:9: error: implicit declaration of function 'release_dma_lock' [-Werror=implicit-function-declaration] + 41 | release_dma_lock(flags); + | ^~~~~~~~~~~~~~~~ + +../sound/isa/sb/sb16_main.c: In function 'snd_sb16_playback_prepare': +../sound/isa/sb/sb16_main.c:253:72: error: 'DMA_AUTOINIT' undeclared (first use in this function) + 253 | snd_dma_program(dma, runtime->dma_addr, size, DMA_MODE_WRITE | DMA_AUTOINIT); + | ^~~~~~~~~~~~ +../sound/isa/sb/sb16_main.c:253:72: note: each undeclared identifier is reported only once for each function it appears in +../sound/isa/sb/sb16_main.c: In function 'snd_sb16_capture_prepare': +../sound/isa/sb/sb16_main.c:322:71: error: 'DMA_AUTOINIT' undeclared (first use in this function) + 322 | snd_dma_program(dma, runtime->dma_addr, size, DMA_MODE_READ | DMA_AUTOINIT); + | ^~~~~~~~~~~~ + +and more... + +Signed-off-by: Randy Dunlap +Cc: Jaroslav Kysela +Cc: Takashi Iwai +Cc: alsa-devel@alsa-project.org +Cc: linux-m68k@lists.linux-m68k.org +Cc: Geert Uytterhoeven +Link: https://lore.kernel.org/r/20211016062602.3588-1-rdunlap@infradead.org +Signed-off-by: Takashi Iwai +Signed-off-by: Sasha Levin +--- + sound/core/Makefile | 2 ++ + sound/isa/Kconfig | 2 +- + sound/pci/Kconfig | 1 + + 3 files changed, 4 insertions(+), 1 deletion(-) + +diff --git a/sound/core/Makefile b/sound/core/Makefile +index d774792850f31..79e1407cd0de7 100644 +--- a/sound/core/Makefile ++++ b/sound/core/Makefile +@@ -9,7 +9,9 @@ ifneq ($(CONFIG_SND_PROC_FS),) + snd-y += info.o + snd-$(CONFIG_SND_OSSEMUL) += info_oss.o + endif ++ifneq ($(CONFIG_M68K),y) + snd-$(CONFIG_ISA_DMA_API) += isadma.o ++endif + snd-$(CONFIG_SND_OSSEMUL) += sound_oss.o + snd-$(CONFIG_SND_VMASTER) += vmaster.o + snd-$(CONFIG_SND_JACK) += ctljack.o jack.o +diff --git a/sound/isa/Kconfig b/sound/isa/Kconfig +index 6ffa48dd59830..570b88e0b2018 100644 +--- a/sound/isa/Kconfig ++++ b/sound/isa/Kconfig +@@ -22,7 +22,7 @@ config SND_SB16_DSP + menuconfig SND_ISA + bool "ISA sound devices" + depends on ISA || COMPILE_TEST +- depends on ISA_DMA_API ++ depends on ISA_DMA_API && !M68K + default y + help + Support for sound devices connected via the ISA bus. +diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig +index 93bc9bef7641f..41ce125971777 100644 +--- a/sound/pci/Kconfig ++++ b/sound/pci/Kconfig +@@ -279,6 +279,7 @@ config SND_CS46XX_NEW_DSP + config SND_CS5530 + tristate "CS5530 Audio" + depends on ISA_DMA_API && (X86_32 || COMPILE_TEST) ++ depends on !M68K + select SND_SB16_DSP + help + Say Y here to include support for audio on Cyrix/NatSemi CS5530 chips. +-- +2.33.0 + diff --git a/queue-5.15/alsa-usb-audio-add-support-for-the-pioneer-djm-750mk.patch b/queue-5.15/alsa-usb-audio-add-support-for-the-pioneer-djm-750mk.patch new file mode 100644 index 00000000000..9d2aedcd4f1 --- /dev/null +++ b/queue-5.15/alsa-usb-audio-add-support-for-the-pioneer-djm-750mk.patch @@ -0,0 +1,162 @@ +From cf03fee5d68ff6017eefa035c874e0d12fea7d45 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 10 Oct 2021 15:58:41 +0100 +Subject: ALSA: usb-audio: Add support for the Pioneer DJM 750MK2 + Mixer/Soundcard + +From: William Overton + +[ Upstream commit 6d27788160362a7ee6c0d317636fe4b1ddbe59a7 ] + +The kernel already has support for very similar Pioneer djm products +and this work is based on that. + +Added device to quirks-table.h and added control info to +mixer_quirks.c. + +Tested on my hardware and all working. + +Signed-off-by: William Overton +Link: https://lore.kernel.org/r/20211010145841.11907-1-willovertonuk@gmail.com +Signed-off-by: Takashi Iwai +Signed-off-by: Sasha Levin +--- + sound/usb/mixer_quirks.c | 34 +++++++++++++++++++++++ + sound/usb/quirks-table.h | 58 ++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 92 insertions(+) + +diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c +index 46082dc57be09..d489c1de3baec 100644 +--- a/sound/usb/mixer_quirks.c ++++ b/sound/usb/mixer_quirks.c +@@ -2795,6 +2795,7 @@ static int snd_bbfpro_controls_create(struct usb_mixer_interface *mixer) + #define SND_DJM_750_IDX 0x1 + #define SND_DJM_850_IDX 0x2 + #define SND_DJM_900NXS2_IDX 0x3 ++#define SND_DJM_750MK2_IDX 0x4 + + + #define SND_DJM_CTL(_name, suffix, _default_value, _windex) { \ +@@ -2984,10 +2985,40 @@ static const struct snd_djm_ctl snd_djm_ctls_900nxs2[] = { + SND_DJM_CTL("Ch5 Input", 900nxs2_cap5, 3, SND_DJM_WINDEX_CAP) + }; + ++// DJM-750MK2 ++static const u16 snd_djm_opts_750mk2_cap1[] = { ++ 0x0100, 0x0102, 0x0103, 0x0106, 0x0107, 0x0108, 0x0109, 0x010a }; ++static const u16 snd_djm_opts_750mk2_cap2[] = { ++ 0x0200, 0x0202, 0x0203, 0x0206, 0x0207, 0x0208, 0x0209, 0x020a }; ++static const u16 snd_djm_opts_750mk2_cap3[] = { ++ 0x0300, 0x0302, 0x0303, 0x0306, 0x0307, 0x0308, 0x0309, 0x030a }; ++static const u16 snd_djm_opts_750mk2_cap4[] = { ++ 0x0400, 0x0402, 0x0403, 0x0406, 0x0407, 0x0408, 0x0409, 0x040a }; ++static const u16 snd_djm_opts_750mk2_cap5[] = { ++ 0x0507, 0x0508, 0x0509, 0x050a, 0x0511, 0x0512, 0x0513, 0x0514 }; ++ ++static const u16 snd_djm_opts_750mk2_pb1[] = { 0x0100, 0x0101, 0x0104 }; ++static const u16 snd_djm_opts_750mk2_pb2[] = { 0x0200, 0x0201, 0x0204 }; ++static const u16 snd_djm_opts_750mk2_pb3[] = { 0x0300, 0x0301, 0x0304 }; ++ ++ ++static const struct snd_djm_ctl snd_djm_ctls_750mk2[] = { ++ SND_DJM_CTL("Capture Level", cap_level, 0, SND_DJM_WINDEX_CAPLVL), ++ SND_DJM_CTL("Ch1 Input", 750mk2_cap1, 2, SND_DJM_WINDEX_CAP), ++ SND_DJM_CTL("Ch2 Input", 750mk2_cap2, 2, SND_DJM_WINDEX_CAP), ++ SND_DJM_CTL("Ch3 Input", 750mk2_cap3, 2, SND_DJM_WINDEX_CAP), ++ SND_DJM_CTL("Ch4 Input", 750mk2_cap4, 2, SND_DJM_WINDEX_CAP), ++ SND_DJM_CTL("Ch5 Input", 750mk2_cap5, 3, SND_DJM_WINDEX_CAP), ++ SND_DJM_CTL("Ch1 Output", 750mk2_pb1, 0, SND_DJM_WINDEX_PB), ++ SND_DJM_CTL("Ch2 Output", 750mk2_pb2, 1, SND_DJM_WINDEX_PB), ++ SND_DJM_CTL("Ch3 Output", 750mk2_pb3, 2, SND_DJM_WINDEX_PB) ++}; ++ + + static const struct snd_djm_device snd_djm_devices[] = { + SND_DJM_DEVICE(250mk2), + SND_DJM_DEVICE(750), ++ SND_DJM_DEVICE(750mk2), + SND_DJM_DEVICE(850), + SND_DJM_DEVICE(900nxs2) + }; +@@ -3235,6 +3266,9 @@ int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer) + case USB_ID(0x08e4, 0x017f): /* Pioneer DJ DJM-750 */ + err = snd_djm_controls_create(mixer, SND_DJM_750_IDX); + break; ++ case USB_ID(0x2b73, 0x001b): /* Pioneer DJ DJM-750MK2 */ ++ err = snd_djm_controls_create(mixer, SND_DJM_750MK2_IDX); ++ break; + case USB_ID(0x08e4, 0x0163): /* Pioneer DJ DJM-850 */ + err = snd_djm_controls_create(mixer, SND_DJM_850_IDX); + break; +diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h +index 2af8c68fac275..b1522e43173e1 100644 +--- a/sound/usb/quirks-table.h ++++ b/sound/usb/quirks-table.h +@@ -3892,6 +3892,64 @@ YAMAHA_DEVICE(0x7010, "UB99"), + } + } + }, ++{ ++ /* ++ * Pioneer DJ DJM-750MK2 ++ * 10 channels playback & 12 channels capture @ 48kHz S24LE ++ */ ++ USB_DEVICE_VENDOR_SPEC(0x2b73, 0x001b), ++ .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { ++ .ifnum = QUIRK_ANY_INTERFACE, ++ .type = QUIRK_COMPOSITE, ++ .data = (const struct snd_usb_audio_quirk[]) { ++ { ++ .ifnum = 0, ++ .type = QUIRK_AUDIO_FIXED_ENDPOINT, ++ .data = &(const struct audioformat) { ++ .formats = SNDRV_PCM_FMTBIT_S24_3LE, ++ .channels = 10, ++ .iface = 0, ++ .altsetting = 1, ++ .altset_idx = 1, ++ .endpoint = 0x01, ++ .ep_attr = USB_ENDPOINT_XFER_ISOC| ++ USB_ENDPOINT_SYNC_ASYNC, ++ .rates = SNDRV_PCM_RATE_48000, ++ .rate_min = 48000, ++ .rate_max = 48000, ++ .nr_rates = 1, ++ .rate_table = (unsigned int[]) { ++ 48000 ++ } ++ } ++ }, ++ { ++ .ifnum = 0, ++ .type = QUIRK_AUDIO_FIXED_ENDPOINT, ++ .data = &(const struct audioformat) { ++ .formats = SNDRV_PCM_FMTBIT_S24_3LE, ++ .channels = 12, ++ .iface = 0, ++ .altsetting = 1, ++ .altset_idx = 1, ++ .endpoint = 0x82, ++ .ep_idx = 1, ++ .ep_attr = USB_ENDPOINT_XFER_ISOC| ++ USB_ENDPOINT_SYNC_ASYNC| ++ USB_ENDPOINT_USAGE_IMPLICIT_FB, ++ .rates = SNDRV_PCM_RATE_48000, ++ .rate_min = 48000, ++ .rate_max = 48000, ++ .nr_rates = 1, ++ .rate_table = (unsigned int[]) { 48000 } ++ } ++ }, ++ { ++ .ifnum = -1 ++ } ++ } ++ } ++}, + { + /* + * Pioneer DJ DJM-850 +-- +2.33.0 + diff --git a/queue-5.15/alsa-usb-audio-disable-implicit-feedback-sync-for-be.patch b/queue-5.15/alsa-usb-audio-disable-implicit-feedback-sync-for-be.patch new file mode 100644 index 00000000000..a309b3c7c2d --- /dev/null +++ b/queue-5.15/alsa-usb-audio-disable-implicit-feedback-sync-for-be.patch @@ -0,0 +1,47 @@ +From 4fb8627b74d15302762064f54d16533b01ea6946 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 30 Sep 2021 16:40:14 -0300 +Subject: ALSA: usb-audio: disable implicit feedback sync for Behringer UFX1204 + and UFX1604 + +From: Geraldo Nascimento + +[ Upstream commit 28c369e60827f706cef4604a3e2848198f25bd26 ] + +Behringer UFX1204 and UFX1604 have Synchronous endpoints to which +current ALSA code applies implicit feedback sync as if they were +Asynchronous endpoints. This breaks UAC compliance and is unneeded. + +The commit 5e35dc0338d85ccebacf3f77eca1e5dea73155e8 and subsequent +1a15718b41df026cffd0e42cfdc38a1384ce19f9 were meant to clear up noise. + +Unfortunately, noise persisted for those using higher sample rates and +this was only solved by commit d2e8f641257d0d3af6e45d6ac2d6f9d56b8ea964 + +Since there are no more reports of noise, let's get rid of the +implicit-fb quirks breaking UAC compliance. + +Signed-off-by: Geraldo Nascimento +Link: https://lore.kernel.org/r/YVYSnoQ7nxLXT0Dq@geday +Signed-off-by: Takashi Iwai +Signed-off-by: Sasha Levin +--- + sound/usb/implicit.c | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/sound/usb/implicit.c b/sound/usb/implicit.c +index 23767a14d1266..70319c822c10b 100644 +--- a/sound/usb/implicit.c ++++ b/sound/usb/implicit.c +@@ -54,8 +54,6 @@ static const struct snd_usb_implicit_fb_match playback_implicit_fb_quirks[] = { + + /* Fixed EP */ + /* FIXME: check the availability of generic matching */ +- IMPLICIT_FB_FIXED_DEV(0x1397, 0x0001, 0x81, 1), /* Behringer UFX1604 */ +- IMPLICIT_FB_FIXED_DEV(0x1397, 0x0002, 0x81, 1), /* Behringer UFX1204 */ + IMPLICIT_FB_FIXED_DEV(0x2466, 0x8010, 0x81, 2), /* Fractal Audio Axe-Fx III */ + IMPLICIT_FB_FIXED_DEV(0x31e9, 0x0001, 0x81, 2), /* Solid State Logic SSL2 */ + IMPLICIT_FB_FIXED_DEV(0x31e9, 0x0002, 0x81, 2), /* Solid State Logic SSL2+ */ +-- +2.33.0 + diff --git a/queue-5.15/alsa-usb-audio-fix-null-pointer-dereference-on-point.patch b/queue-5.15/alsa-usb-audio-fix-null-pointer-dereference-on-point.patch new file mode 100644 index 00000000000..b7d93935790 --- /dev/null +++ b/queue-5.15/alsa-usb-audio-fix-null-pointer-dereference-on-point.patch @@ -0,0 +1,39 @@ +From cf2536e79d3ed64ec8276f43e49fa862f510153f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 24 Oct 2021 04:17:36 -0700 +Subject: ALSA: usb-audio: fix null pointer dereference on pointer cs_desc + +From: Chengfeng Ye + +[ Upstream commit b97053df0f04747c3c1e021ecbe99db675342954 ] + +The pointer cs_desc return from snd_usb_find_clock_source could +be null, so there is a potential null pointer dereference issue. +Fix this by adding a null check before dereference. + +Signed-off-by: Chengfeng Ye +Link: https://lore.kernel.org/r/20211024111736.11342-1-cyeaa@connect.ust.hk +Signed-off-by: Takashi Iwai +Signed-off-by: Sasha Levin +--- + sound/usb/clock.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/sound/usb/clock.c b/sound/usb/clock.c +index 81d5ce07d548b..98345a695dccb 100644 +--- a/sound/usb/clock.c ++++ b/sound/usb/clock.c +@@ -496,6 +496,10 @@ int snd_usb_set_sample_rate_v2v3(struct snd_usb_audio *chip, + union uac23_clock_source_desc *cs_desc; + + cs_desc = snd_usb_find_clock_source(chip, clock, fmt->protocol); ++ ++ if (!cs_desc) ++ return 0; ++ + if (fmt->protocol == UAC_VERSION_3) + bmControls = le32_to_cpu(cs_desc->v3.bmControls); + else +-- +2.33.0 + diff --git a/queue-5.15/arm-bcm53016-specify-switch-ports-for-meraki-mr32.patch b/queue-5.15/arm-bcm53016-specify-switch-ports-for-meraki-mr32.patch new file mode 100644 index 00000000000..b2831d1fb0b --- /dev/null +++ b/queue-5.15/arm-bcm53016-specify-switch-ports-for-meraki-mr32.patch @@ -0,0 +1,67 @@ +From 62d5cda815a70f2265adc3e468c0f1b6f3227448 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 18 Sep 2021 19:29:30 +0200 +Subject: ARM: BCM53016: Specify switch ports for Meraki MR32 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Christian Lamparter + +[ Upstream commit 6abc4ca5a28070945e0d68cb4160b309bfbf4b8b ] + +the switch identifies itself as a BCM53012 (rev 5)... +This patch has been tested & verified on OpenWrt's +snapshot with Linux 5.10 (didn't test any older kernels). +The MR32 is able to "talk to the network" as before with +OpenWrt's SWITCHDEV b53 driver. + +| b53-srab-switch 18007000.ethernet-switch: found switch: BCM53012, rev 5 +| libphy: dsa slave smi: probed +| b53-srab-switch 18007000.ethernet-switch poe (uninitialized): +| PHY [dsa-0.0:00] driver [Generic PHY] (irq=POLL) +| b53-srab-switch 18007000.ethernet-switch: Using legacy PHYLIB callbacks. +| Please migrate to PHYLINK! +| DSA: tree 0 setup + +Reported-by: Rafał Miłecki +Signed-off-by: Christian Lamparter +Signed-off-by: Florian Fainelli +Signed-off-by: Sasha Levin +--- + arch/arm/boot/dts/bcm53016-meraki-mr32.dts | 22 ++++++++++++++++++++++ + 1 file changed, 22 insertions(+) + +diff --git a/arch/arm/boot/dts/bcm53016-meraki-mr32.dts b/arch/arm/boot/dts/bcm53016-meraki-mr32.dts +index 612d61852bfb9..577a4dc604d93 100644 +--- a/arch/arm/boot/dts/bcm53016-meraki-mr32.dts ++++ b/arch/arm/boot/dts/bcm53016-meraki-mr32.dts +@@ -195,3 +195,25 @@ + }; + }; + }; ++ ++&srab { ++ status = "okay"; ++ ++ ports { ++ port@0 { ++ reg = <0>; ++ label = "poe"; ++ }; ++ ++ port@5 { ++ reg = <5>; ++ label = "cpu"; ++ ethernet = <&gmac0>; ++ ++ fixed-link { ++ speed = <1000>; ++ duplex-full; ++ }; ++ }; ++ }; ++}; +-- +2.33.0 + diff --git a/queue-5.15/arm-dts-bcm5301x-fix-mdio-mux-binding.patch b/queue-5.15/arm-dts-bcm5301x-fix-mdio-mux-binding.patch new file mode 100644 index 00000000000..9929b30b5b9 --- /dev/null +++ b/queue-5.15/arm-dts-bcm5301x-fix-mdio-mux-binding.patch @@ -0,0 +1,38 @@ +From 6ef9313e558ecf8dfc3c909a9e01668461b14d52 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 19 Aug 2021 08:57:01 +0200 +Subject: ARM: dts: BCM5301X: Fix MDIO mux binding +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Rafał Miłecki + +[ Upstream commit 6ee0b56f7530e0ebb496fe15d0b54c5f3a1b5e17 ] + +This fixes following error for all BCM5301X dts files: +mdio-bus-mux@18003000: compatible: ['mdio-mux-mmioreg'] is too short + +Signed-off-by: Rafał Miłecki +Signed-off-by: Florian Fainelli +Signed-off-by: Sasha Levin +--- + arch/arm/boot/dts/bcm5301x.dtsi | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/arch/arm/boot/dts/bcm5301x.dtsi b/arch/arm/boot/dts/bcm5301x.dtsi +index f9d3a53065ef7..d4f355015e3ca 100644 +--- a/arch/arm/boot/dts/bcm5301x.dtsi ++++ b/arch/arm/boot/dts/bcm5301x.dtsi +@@ -370,7 +370,7 @@ + }; + + mdio-mux@18003000 { +- compatible = "mdio-mux-mmioreg"; ++ compatible = "mdio-mux-mmioreg", "mdio-mux"; + mdio-parent-bus = <&mdio>; + #address-cells = <1>; + #size-cells = <0>; +-- +2.33.0 + diff --git a/queue-5.15/arm-dts-bcm5301x-fix-nodes-names.patch b/queue-5.15/arm-dts-bcm5301x-fix-nodes-names.patch new file mode 100644 index 00000000000..beca56eb6fe --- /dev/null +++ b/queue-5.15/arm-dts-bcm5301x-fix-nodes-names.patch @@ -0,0 +1,82 @@ +From 4d64d4ffa48549e2a7519c8718ea37ab38dc06cd Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 19 Aug 2021 08:57:00 +0200 +Subject: ARM: dts: BCM5301X: Fix nodes names +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Rafał Miłecki + +[ Upstream commit 9dba049b6d32e95c0dd2a0d607f593ea288ac140 ] + +This fixes following errors for all BCM5301X dts files: +chipcommonA@18000000: $nodename:0: 'chipcommonA@18000000' does not match '^([a-z][a-z0-9\\-]+-bus|bus|soc|axi|ahb|apb)(@[0-9a-f]+)?$' +mpcore@19000000: $nodename:0: 'mpcore@19000000' does not match '^([a-z][a-z0-9\\-]+-bus|bus|soc|axi|ahb|apb)(@[0-9a-f]+)?$' +mdio-bus-mux@18003000: $nodename:0: 'mdio-bus-mux@18003000' does not match '^mdio-mux[\\-@]?' +dmu@1800c000: $nodename:0: 'dmu@1800c000' does not match '^([a-z][a-z0-9\\-]+-bus|bus|soc|axi|ahb|apb)(@[0-9a-f]+)?$' + +Signed-off-by: Rafał Miłecki +Signed-off-by: Florian Fainelli +Signed-off-by: Sasha Levin +--- + arch/arm/boot/dts/bcm47094-linksys-panamera.dts | 2 +- + arch/arm/boot/dts/bcm5301x.dtsi | 8 ++++---- + 2 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/arch/arm/boot/dts/bcm47094-linksys-panamera.dts b/arch/arm/boot/dts/bcm47094-linksys-panamera.dts +index 05d4f2931772b..9bef6b9bfa8d9 100644 +--- a/arch/arm/boot/dts/bcm47094-linksys-panamera.dts ++++ b/arch/arm/boot/dts/bcm47094-linksys-panamera.dts +@@ -129,7 +129,7 @@ + }; + }; + +- mdio-bus-mux@18003000 { ++ mdio-mux@18003000 { + + /* BIT(9) = 1 => external mdio */ + mdio@200 { +diff --git a/arch/arm/boot/dts/bcm5301x.dtsi b/arch/arm/boot/dts/bcm5301x.dtsi +index f92089290ccd5..f9d3a53065ef7 100644 +--- a/arch/arm/boot/dts/bcm5301x.dtsi ++++ b/arch/arm/boot/dts/bcm5301x.dtsi +@@ -19,7 +19,7 @@ + #size-cells = <1>; + interrupt-parent = <&gic>; + +- chipcommonA@18000000 { ++ chipcommon-a-bus@18000000 { + compatible = "simple-bus"; + ranges = <0x00000000 0x18000000 0x00001000>; + #address-cells = <1>; +@@ -44,7 +44,7 @@ + }; + }; + +- mpcore@19000000 { ++ mpcore-bus@19000000 { + compatible = "simple-bus"; + ranges = <0x00000000 0x19000000 0x00023000>; + #address-cells = <1>; +@@ -369,7 +369,7 @@ + #address-cells = <1>; + }; + +- mdio-bus-mux@18003000 { ++ mdio-mux@18003000 { + compatible = "mdio-mux-mmioreg"; + mdio-parent-bus = <&mdio>; + #address-cells = <1>; +@@ -415,7 +415,7 @@ + status = "disabled"; + }; + +- dmu@1800c000 { ++ dmu-bus@1800c000 { + compatible = "simple-bus"; + ranges = <0 0x1800c000 0x1000>; + #address-cells = <1>; +-- +2.33.0 + diff --git a/queue-5.15/arm-dts-ls1021a-move-thermal-zones-node-out-of-soc.patch b/queue-5.15/arm-dts-ls1021a-move-thermal-zones-node-out-of-soc.patch new file mode 100644 index 00000000000..1c54b0ba27e --- /dev/null +++ b/queue-5.15/arm-dts-ls1021a-move-thermal-zones-node-out-of-soc.patch @@ -0,0 +1,105 @@ +From 9418b3768f814b973381a49ebc907414c4c9938b Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 12 Oct 2021 18:58:22 -0500 +Subject: ARM: dts: ls1021a: move thermal-zones node out of soc/ + +From: Li Yang + +[ Upstream commit 1ee1500ef717eefb5d9bdaf97905cb81b4e69aa4 ] + +This fixes dtbs-check error from simple-bus schema: +soc: thermal-zones: {'type': 'object'} is not allowed for {'cpu-thermal': ..... } + From schema: /home/leo/.local/lib/python3.8/site-packages/dtschema/schemas/simple-bus.yaml + +Signed-off-by: Li Yang +Signed-off-by: Shawn Guo +Signed-off-by: Sasha Levin +--- + arch/arm/boot/dts/ls1021a.dtsi | 66 +++++++++++++++++----------------- + 1 file changed, 33 insertions(+), 33 deletions(-) + +diff --git a/arch/arm/boot/dts/ls1021a.dtsi b/arch/arm/boot/dts/ls1021a.dtsi +index 4fce81422943b..f3b8540750b61 100644 +--- a/arch/arm/boot/dts/ls1021a.dtsi ++++ b/arch/arm/boot/dts/ls1021a.dtsi +@@ -329,39 +329,6 @@ + #thermal-sensor-cells = <1>; + }; + +- thermal-zones { +- cpu_thermal: cpu-thermal { +- polling-delay-passive = <1000>; +- polling-delay = <5000>; +- +- thermal-sensors = <&tmu 0>; +- +- trips { +- cpu_alert: cpu-alert { +- temperature = <85000>; +- hysteresis = <2000>; +- type = "passive"; +- }; +- cpu_crit: cpu-crit { +- temperature = <95000>; +- hysteresis = <2000>; +- type = "critical"; +- }; +- }; +- +- cooling-maps { +- map0 { +- trip = <&cpu_alert>; +- cooling-device = +- <&cpu0 THERMAL_NO_LIMIT +- THERMAL_NO_LIMIT>, +- <&cpu1 THERMAL_NO_LIMIT +- THERMAL_NO_LIMIT>; +- }; +- }; +- }; +- }; +- + dspi0: spi@2100000 { + compatible = "fsl,ls1021a-v1.0-dspi"; + #address-cells = <1>; +@@ -1016,4 +983,37 @@ + big-endian; + }; + }; ++ ++ thermal-zones { ++ cpu_thermal: cpu-thermal { ++ polling-delay-passive = <1000>; ++ polling-delay = <5000>; ++ ++ thermal-sensors = <&tmu 0>; ++ ++ trips { ++ cpu_alert: cpu-alert { ++ temperature = <85000>; ++ hysteresis = <2000>; ++ type = "passive"; ++ }; ++ cpu_crit: cpu-crit { ++ temperature = <95000>; ++ hysteresis = <2000>; ++ type = "critical"; ++ }; ++ }; ++ ++ cooling-maps { ++ map0 { ++ trip = <&cpu_alert>; ++ cooling-device = ++ <&cpu0 THERMAL_NO_LIMIT ++ THERMAL_NO_LIMIT>, ++ <&cpu1 THERMAL_NO_LIMIT ++ THERMAL_NO_LIMIT>; ++ }; ++ }; ++ }; ++ }; + }; +-- +2.33.0 + diff --git a/queue-5.15/arm-dts-ls1021a-tsn-use-generic-jedec-spi-nor-compat.patch b/queue-5.15/arm-dts-ls1021a-tsn-use-generic-jedec-spi-nor-compat.patch new file mode 100644 index 00000000000..363f9fe517a --- /dev/null +++ b/queue-5.15/arm-dts-ls1021a-tsn-use-generic-jedec-spi-nor-compat.patch @@ -0,0 +1,39 @@ +From b4233cb3c10b681f0c1b8b106bda744b667424e6 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 12 Oct 2021 18:58:23 -0500 +Subject: ARM: dts: ls1021a-tsn: use generic "jedec,spi-nor" compatible for + flash + +From: Li Yang + +[ Upstream commit 05e63b48b20fa70726be505a7660d1a07bc1cffb ] + +We cannot list all the possible chips used in different board revisions, +just use the generic "jedec,spi-nor" compatible instead. This also +fixes dtbs_check error: +['jedec,spi-nor', 's25fl256s1', 's25fl512s'] is too long + +Signed-off-by: Li Yang +Reviewed-by: Kuldeep Singh +Signed-off-by: Shawn Guo +Signed-off-by: Sasha Levin +--- + arch/arm/boot/dts/ls1021a-tsn.dts | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/arch/arm/boot/dts/ls1021a-tsn.dts b/arch/arm/boot/dts/ls1021a-tsn.dts +index 9d8f0c2a8aba3..aca78b5eddf20 100644 +--- a/arch/arm/boot/dts/ls1021a-tsn.dts ++++ b/arch/arm/boot/dts/ls1021a-tsn.dts +@@ -251,7 +251,7 @@ + + flash@0 { + /* Rev. A uses 64MB flash, Rev. B & C use 32MB flash */ +- compatible = "jedec,spi-nor", "s25fl256s1", "s25fl512s"; ++ compatible = "jedec,spi-nor"; + spi-max-frequency = <20000000>; + #address-cells = <1>; + #size-cells = <1>; +-- +2.33.0 + diff --git a/queue-5.15/arm-dts-nsp-fix-mpcore-mmc-node-names.patch b/queue-5.15/arm-dts-nsp-fix-mpcore-mmc-node-names.patch new file mode 100644 index 00000000000..f708de4416a --- /dev/null +++ b/queue-5.15/arm-dts-nsp-fix-mpcore-mmc-node-names.patch @@ -0,0 +1,50 @@ +From 82cf2d8af727224d20ece667327a6950fc7bce1a Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 29 Aug 2021 22:37:48 +0000 +Subject: ARM: dts: NSP: Fix mpcore, mmc node names + +From: Matthew Hagan + +[ Upstream commit 15a563d008ef9d04df525f0c476cd7d7127bb883 ] + +Running dtbs_check yielded the issues with bcm-nsp.dtsi. + +Firstly this patch fixes the following message by appending "-bus" to +the mpcore node name: +mpcore@19000000: $nodename:0: 'mpcore@19000000' does not match '^([a-z][a-z0-9\\-]+-bus|bus|soc|axi|ahb|apb)(@[0-9a-f]+)?$' + +Secondly mmc node name. The label name can remain as is. +sdhci@21000: $nodename:0: 'sdhci@21000' does not match '^mmc(@.*)?$' + +Signed-off-by: Matthew Hagan +Signed-off-by: Florian Fainelli +Signed-off-by: Sasha Levin +--- + arch/arm/boot/dts/bcm-nsp.dtsi | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/arch/arm/boot/dts/bcm-nsp.dtsi b/arch/arm/boot/dts/bcm-nsp.dtsi +index 748df7955ae67..e96ddb2e26e2c 100644 +--- a/arch/arm/boot/dts/bcm-nsp.dtsi ++++ b/arch/arm/boot/dts/bcm-nsp.dtsi +@@ -77,7 +77,7 @@ + interrupt-affinity = <&cpu0>, <&cpu1>; + }; + +- mpcore@19000000 { ++ mpcore-bus@19000000 { + compatible = "simple-bus"; + ranges = <0x00000000 0x19000000 0x00023000>; + #address-cells = <1>; +@@ -219,7 +219,7 @@ + status = "disabled"; + }; + +- sdio: sdhci@21000 { ++ sdio: mmc@21000 { + compatible = "brcm,sdhci-iproc-cygnus"; + reg = <0x21000 0x100>; + interrupts = ; +-- +2.33.0 + diff --git a/queue-5.15/arm-dts-omap-fix-gpmc-mux-add-data-type.patch b/queue-5.15/arm-dts-omap-fix-gpmc-mux-add-data-type.patch new file mode 100644 index 00000000000..e811da3ccca --- /dev/null +++ b/queue-5.15/arm-dts-omap-fix-gpmc-mux-add-data-type.patch @@ -0,0 +1,52 @@ +From 124c55e04efd26eddb2347f39a14341d433093f8 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 7 Oct 2021 15:08:30 +0300 +Subject: ARM: dts: omap: fix gpmc,mux-add-data type + +From: Roger Quadros + +[ Upstream commit 51b9e22ffd3c4c56cbb7caae9750f70e55ffa603 ] + +gpmc,mux-add-data is not boolean. + +Fixes the below errors flagged by dtbs_check. + +"ethernet@4,0:gpmc,mux-add-data: True is not of type 'array'" + +Signed-off-by: Roger Quadros +Signed-off-by: Tony Lindgren +Signed-off-by: Sasha Levin +--- + arch/arm/boot/dts/omap-gpmc-smsc9221.dtsi | 2 +- + arch/arm/boot/dts/omap3-overo-tobiduo-common.dtsi | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/arch/arm/boot/dts/omap-gpmc-smsc9221.dtsi b/arch/arm/boot/dts/omap-gpmc-smsc9221.dtsi +index 7f6aefd134514..e7534fe9c53cf 100644 +--- a/arch/arm/boot/dts/omap-gpmc-smsc9221.dtsi ++++ b/arch/arm/boot/dts/omap-gpmc-smsc9221.dtsi +@@ -29,7 +29,7 @@ + compatible = "smsc,lan9221","smsc,lan9115"; + bank-width = <2>; + +- gpmc,mux-add-data; ++ gpmc,mux-add-data = <0>; + gpmc,cs-on-ns = <0>; + gpmc,cs-rd-off-ns = <42>; + gpmc,cs-wr-off-ns = <36>; +diff --git a/arch/arm/boot/dts/omap3-overo-tobiduo-common.dtsi b/arch/arm/boot/dts/omap3-overo-tobiduo-common.dtsi +index e5da3bc6f1050..218a10c0d8159 100644 +--- a/arch/arm/boot/dts/omap3-overo-tobiduo-common.dtsi ++++ b/arch/arm/boot/dts/omap3-overo-tobiduo-common.dtsi +@@ -22,7 +22,7 @@ + compatible = "smsc,lan9221","smsc,lan9115"; + bank-width = <2>; + +- gpmc,mux-add-data; ++ gpmc,mux-add-data = <0>; + gpmc,cs-on-ns = <0>; + gpmc,cs-rd-off-ns = <42>; + gpmc,cs-wr-off-ns = <36>; +-- +2.33.0 + diff --git a/queue-5.15/arm-dts-qcom-fix-memory-and-mdio-nodes-naming-for-rb.patch b/queue-5.15/arm-dts-qcom-fix-memory-and-mdio-nodes-naming-for-rb.patch new file mode 100644 index 00000000000..fafbc2eaf5b --- /dev/null +++ b/queue-5.15/arm-dts-qcom-fix-memory-and-mdio-nodes-naming-for-rb.patch @@ -0,0 +1,51 @@ +From 6eeaf73693b472b2bb79d14e64fe4ee57aca822a Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 20 Oct 2021 23:47:41 +0200 +Subject: ARM: dts: qcom: fix memory and mdio nodes naming for RB3011 + +From: David Heidelberg + +[ Upstream commit 14a1f6c9d8017ffbf388e82e1a1f023196d98612 ] + +Fixes warnings regarding to memory and mdio nodes and +apply new naming following dt-schema. + +Signed-off-by: David Heidelberg +Signed-off-by: Bjorn Andersson +Link: https://lore.kernel.org/r/20211020214741.261509-1-david@ixit.cz +Signed-off-by: Sasha Levin +--- + arch/arm/boot/dts/qcom-ipq8064-rb3011.dts | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/arch/arm/boot/dts/qcom-ipq8064-rb3011.dts b/arch/arm/boot/dts/qcom-ipq8064-rb3011.dts +index f7ea2e5dd1914..971d2e2292600 100644 +--- a/arch/arm/boot/dts/qcom-ipq8064-rb3011.dts ++++ b/arch/arm/boot/dts/qcom-ipq8064-rb3011.dts +@@ -19,12 +19,12 @@ + stdout-path = "serial0:115200n8"; + }; + +- memory@0 { ++ memory@42000000 { + reg = <0x42000000 0x3e000000>; + device_type = "memory"; + }; + +- mdio0: mdio@0 { ++ mdio0: mdio-0 { + status = "okay"; + compatible = "virtual,mdio-gpio"; + gpios = <&qcom_pinmux 1 GPIO_ACTIVE_HIGH>, +@@ -91,7 +91,7 @@ + }; + }; + +- mdio1: mdio@1 { ++ mdio1: mdio-1 { + status = "okay"; + compatible = "virtual,mdio-gpio"; + gpios = <&qcom_pinmux 11 GPIO_ACTIVE_HIGH>, +-- +2.33.0 + diff --git a/queue-5.15/arm-dts-sunxi-fix-opps-node-name.patch b/queue-5.15/arm-dts-sunxi-fix-opps-node-name.patch new file mode 100644 index 00000000000..ec646b7ee4e --- /dev/null +++ b/queue-5.15/arm-dts-sunxi-fix-opps-node-name.patch @@ -0,0 +1,135 @@ +From 2a29f467bc8185673207c4e8cae776ed23ea43f5 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 1 Sep 2021 11:18:42 +0200 +Subject: ARM: dts: sunxi: Fix OPPs node name + +From: Maxime Ripard + +[ Upstream commit ffbe853a3f5a37fa0a511265b21abf097ffdbe45 ] + +The operating-points-v2 nodes are named inconsistently, but mostly +either opp_table0 or gpu-opp-table. However, the underscore is an +invalid character for a node name and the thermal zone binding +explicitly requires that zones are called opp-table-*. Let's fix it. + +Signed-off-by: Maxime Ripard +Acked-by: Jernej Skrabec +Link: https://lore.kernel.org/r/20210901091852.479202-43-maxime@cerno.tech +Signed-off-by: Sasha Levin +--- + arch/arm/boot/dts/sun8i-a33.dtsi | 4 ++-- + arch/arm/boot/dts/sun8i-a83t.dtsi | 4 ++-- + arch/arm/boot/dts/sun8i-h3.dtsi | 4 ++-- + arch/arm64/boot/dts/allwinner/sun50i-a64-cpu-opp.dtsi | 2 +- + arch/arm64/boot/dts/allwinner/sun50i-h5-cpu-opp.dtsi | 2 +- + arch/arm64/boot/dts/allwinner/sun50i-h6-cpu-opp.dtsi | 2 +- + 6 files changed, 9 insertions(+), 9 deletions(-) + +diff --git a/arch/arm/boot/dts/sun8i-a33.dtsi b/arch/arm/boot/dts/sun8i-a33.dtsi +index 2beddbb3c5183..b3d1bdfb5118e 100644 +--- a/arch/arm/boot/dts/sun8i-a33.dtsi ++++ b/arch/arm/boot/dts/sun8i-a33.dtsi +@@ -46,7 +46,7 @@ + #include + + / { +- cpu0_opp_table: opp_table0 { ++ cpu0_opp_table: opp-table-cpu { + compatible = "operating-points-v2"; + opp-shared; + +@@ -164,7 +164,7 @@ + io-channels = <&ths>; + }; + +- mali_opp_table: gpu-opp-table { ++ mali_opp_table: opp-table-gpu { + compatible = "operating-points-v2"; + + opp-144000000 { +diff --git a/arch/arm/boot/dts/sun8i-a83t.dtsi b/arch/arm/boot/dts/sun8i-a83t.dtsi +index ac97eac91349b..82fdb04122caa 100644 +--- a/arch/arm/boot/dts/sun8i-a83t.dtsi ++++ b/arch/arm/boot/dts/sun8i-a83t.dtsi +@@ -200,7 +200,7 @@ + status = "disabled"; + }; + +- cpu0_opp_table: opp_table0 { ++ cpu0_opp_table: opp-table-cluster0 { + compatible = "operating-points-v2"; + opp-shared; + +@@ -253,7 +253,7 @@ + }; + }; + +- cpu1_opp_table: opp_table1 { ++ cpu1_opp_table: opp-table-cluster1 { + compatible = "operating-points-v2"; + opp-shared; + +diff --git a/arch/arm/boot/dts/sun8i-h3.dtsi b/arch/arm/boot/dts/sun8i-h3.dtsi +index 4e89701df91f8..ae4f933abb895 100644 +--- a/arch/arm/boot/dts/sun8i-h3.dtsi ++++ b/arch/arm/boot/dts/sun8i-h3.dtsi +@@ -44,7 +44,7 @@ + #include + + / { +- cpu0_opp_table: opp_table0 { ++ cpu0_opp_table: opp-table-cpu { + compatible = "operating-points-v2"; + opp-shared; + +@@ -112,7 +112,7 @@ + }; + }; + +- gpu_opp_table: gpu-opp-table { ++ gpu_opp_table: opp-table-gpu { + compatible = "operating-points-v2"; + + opp-120000000 { +diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-cpu-opp.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64-cpu-opp.dtsi +index 578c37490d901..e39db51eb4489 100644 +--- a/arch/arm64/boot/dts/allwinner/sun50i-a64-cpu-opp.dtsi ++++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-cpu-opp.dtsi +@@ -4,7 +4,7 @@ + */ + + / { +- cpu0_opp_table: opp_table0 { ++ cpu0_opp_table: opp-table-cpu { + compatible = "operating-points-v2"; + opp-shared; + +diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h5-cpu-opp.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-h5-cpu-opp.dtsi +index b2657201957eb..1afad8b437d72 100644 +--- a/arch/arm64/boot/dts/allwinner/sun50i-h5-cpu-opp.dtsi ++++ b/arch/arm64/boot/dts/allwinner/sun50i-h5-cpu-opp.dtsi +@@ -2,7 +2,7 @@ + // Copyright (C) 2020 Chen-Yu Tsai + + / { +- cpu_opp_table: cpu-opp-table { ++ cpu_opp_table: opp-table-cpu { + compatible = "operating-points-v2"; + opp-shared; + +diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h6-cpu-opp.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-h6-cpu-opp.dtsi +index 8c6e8536b69fa..0baf0f8e4d272 100644 +--- a/arch/arm64/boot/dts/allwinner/sun50i-h6-cpu-opp.dtsi ++++ b/arch/arm64/boot/dts/allwinner/sun50i-h6-cpu-opp.dtsi +@@ -3,7 +3,7 @@ + // Copyright (C) 2020 Clément Péron + + / { +- cpu_opp_table: cpu-opp-table { ++ cpu_opp_table: opp-table-cpu { + compatible = "allwinner,sun50i-h6-operating-points"; + nvmem-cells = <&cpu_speed_grade>; + opp-shared; +-- +2.33.0 + diff --git a/queue-5.15/arm-dts-ux500-skomer-regulator-fixes.patch b/queue-5.15/arm-dts-ux500-skomer-regulator-fixes.patch new file mode 100644 index 00000000000..f116e19a82a --- /dev/null +++ b/queue-5.15/arm-dts-ux500-skomer-regulator-fixes.patch @@ -0,0 +1,50 @@ +From c4b232aeb4cdaf14c2dda66685519fdebdd52077 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 4 Jun 2021 00:00:04 +0200 +Subject: ARM: dts: ux500: Skomer regulator fixes + +From: Linus Walleij + +[ Upstream commit 7aee0288beab72cdfa35af51f62e94373fca595d ] + +AUX2 has slightly wrong voltage and AUX5 doesn't need to be +always on. + +Signed-off-by: Linus Walleij +Signed-off-by: Sasha Levin +--- + arch/arm/boot/dts/ste-ux500-samsung-skomer.dts | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/arch/arm/boot/dts/ste-ux500-samsung-skomer.dts b/arch/arm/boot/dts/ste-ux500-samsung-skomer.dts +index 264f3e9b5fce5..86e83639fadc1 100644 +--- a/arch/arm/boot/dts/ste-ux500-samsung-skomer.dts ++++ b/arch/arm/boot/dts/ste-ux500-samsung-skomer.dts +@@ -292,10 +292,10 @@ + }; + + ab8500_ldo_aux2 { +- /* Supplies the Cypress TMA140 touchscreen only with 3.3V */ ++ /* Supplies the Cypress TMA140 touchscreen only with 3.0V */ + regulator-name = "AUX2"; +- regulator-min-microvolt = <3300000>; +- regulator-max-microvolt = <3300000>; ++ regulator-min-microvolt = <3000000>; ++ regulator-max-microvolt = <3000000>; + }; + + ab8500_ldo_aux3 { +@@ -314,9 +314,9 @@ + + ab8500_ldo_aux5 { + regulator-name = "AUX5"; ++ /* Intended for 1V8 for touchscreen but actually left unused */ + regulator-min-microvolt = <1050000>; + regulator-max-microvolt = <2790000>; +- regulator-always-on; + }; + + ab8500_ldo_aux6 { +-- +2.33.0 + diff --git a/queue-5.15/arm64-dts-allwinner-a100-fix-thermal-zone-node-name.patch b/queue-5.15/arm64-dts-allwinner-a100-fix-thermal-zone-node-name.patch new file mode 100644 index 00000000000..4a4359f10c8 --- /dev/null +++ b/queue-5.15/arm64-dts-allwinner-a100-fix-thermal-zone-node-name.patch @@ -0,0 +1,52 @@ +From 983043acd89d545b0f33478a7b8a0f63899295ca Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 1 Sep 2021 11:18:49 +0200 +Subject: arm64: dts: allwinner: a100: Fix thermal zone node name + +From: Maxime Ripard + +[ Upstream commit 5c34c4e46e601554bfa370b23c8ae3c3c734e9f7 ] + +The thermal zones one the A100 are called $device-thermal-zone. + +However, the thermal zone binding explicitly requires that zones are +called *-thermal. Let's fix it. + +Signed-off-by: Maxime Ripard +Acked-by: Jernej Skrabec +Link: https://lore.kernel.org/r/20210901091852.479202-50-maxime@cerno.tech +Signed-off-by: Sasha Levin +--- + arch/arm64/boot/dts/allwinner/sun50i-a100.dtsi | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a100.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a100.dtsi +index cc321c04f1219..f6d7d7f7fdabe 100644 +--- a/arch/arm64/boot/dts/allwinner/sun50i-a100.dtsi ++++ b/arch/arm64/boot/dts/allwinner/sun50i-a100.dtsi +@@ -343,19 +343,19 @@ + }; + + thermal-zones { +- cpu-thermal-zone { ++ cpu-thermal { + polling-delay-passive = <0>; + polling-delay = <0>; + thermal-sensors = <&ths 0>; + }; + +- ddr-thermal-zone { ++ ddr-thermal { + polling-delay-passive = <0>; + polling-delay = <0>; + thermal-sensors = <&ths 2>; + }; + +- gpu-thermal-zone { ++ gpu-thermal { + polling-delay-passive = <0>; + polling-delay = <0>; + thermal-sensors = <&ths 1>; +-- +2.33.0 + diff --git a/queue-5.15/arm64-dts-allwinner-h5-fix-gpu-thermal-zone-node-nam.patch b/queue-5.15/arm64-dts-allwinner-h5-fix-gpu-thermal-zone-node-nam.patch new file mode 100644 index 00000000000..7bee46899aa --- /dev/null +++ b/queue-5.15/arm64-dts-allwinner-h5-fix-gpu-thermal-zone-node-nam.patch @@ -0,0 +1,37 @@ +From be41ae1fa2c7667342b4764f5947097af8f107db Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 1 Sep 2021 11:18:47 +0200 +Subject: arm64: dts: allwinner: h5: Fix GPU thermal zone node name + +From: Maxime Ripard + +[ Upstream commit 94a0f2b0e4e0953d8adf319c44244ef7a57de32c ] + +The GPU thermal zone is named gpu_thermal. However, the underscore is +an invalid character for a node name and the thermal zone binding +explicitly requires that zones are called *-thermal. Let's fix it. + +Signed-off-by: Maxime Ripard +Acked-by: Jernej Skrabec +Link: https://lore.kernel.org/r/20210901091852.479202-48-maxime@cerno.tech +Signed-off-by: Sasha Levin +--- + arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi +index 578a63dedf466..9988e87ea7b3d 100644 +--- a/arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi ++++ b/arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi +@@ -217,7 +217,7 @@ + }; + }; + +- gpu_thermal { ++ gpu-thermal { + polling-delay-passive = <0>; + polling-delay = <0>; + thermal-sensors = <&ths 1>; +-- +2.33.0 + diff --git a/queue-5.15/arm64-dts-broadcom-bcm4908-move-reboot-syscon-out-of.patch b/queue-5.15/arm64-dts-broadcom-bcm4908-move-reboot-syscon-out-of.patch new file mode 100644 index 00000000000..14a4d9a545f --- /dev/null +++ b/queue-5.15/arm64-dts-broadcom-bcm4908-move-reboot-syscon-out-of.patch @@ -0,0 +1,48 @@ +From a77a97c353dc8ab6e5e43aaec904cdb98330e1c6 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 19 Aug 2021 14:26:06 +0200 +Subject: arm64: dts: broadcom: bcm4908: Move reboot syscon out of bus +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Rafał Miłecki + +[ Upstream commit 6cf9f70255b90b540b9cbde062f18fea29024a75 ] + +This fixes following error for every bcm4908 DTS file: +bus@ff800000: reboot: {'type': 'object'} is not allowed for {'compatible': ['syscon-reboot'], 'regmap': [[15]], 'offset': [[52]], 'mask': [[1]]} + +Signed-off-by: Rafał Miłecki +Signed-off-by: Florian Fainelli +Signed-off-by: Sasha Levin +--- + arch/arm64/boot/dts/broadcom/bcm4908/bcm4908.dtsi | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/arch/arm64/boot/dts/broadcom/bcm4908/bcm4908.dtsi b/arch/arm64/boot/dts/broadcom/bcm4908/bcm4908.dtsi +index f6b93bbb49228..5118816b1ed76 100644 +--- a/arch/arm64/boot/dts/broadcom/bcm4908/bcm4908.dtsi ++++ b/arch/arm64/boot/dts/broadcom/bcm4908/bcm4908.dtsi +@@ -326,12 +326,12 @@ + #reset-cells = <1>; + }; + }; ++ }; + +- reboot { +- compatible = "syscon-reboot"; +- regmap = <&timer>; +- offset = <0x34>; +- mask = <1>; +- }; ++ reboot { ++ compatible = "syscon-reboot"; ++ regmap = <&timer>; ++ offset = <0x34>; ++ mask = <1>; + }; + }; +-- +2.33.0 + diff --git a/queue-5.15/arm64-dts-freescale-fix-arm-sp805-compatible-string.patch b/queue-5.15/arm64-dts-freescale-fix-arm-sp805-compatible-string.patch new file mode 100644 index 00000000000..42e41ee773d --- /dev/null +++ b/queue-5.15/arm64-dts-freescale-fix-arm-sp805-compatible-string.patch @@ -0,0 +1,178 @@ +From a37430a73522355b446463305ecca8376d190f4d Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 26 Aug 2021 14:35:28 +0200 +Subject: arm64: dts: freescale: fix arm,sp805 compatible string + +From: Michael Walle + +[ Upstream commit 99a7cacc66cae92db40139b57689be2af75fc6b8 ] + +According to Documentation/devicetree/bindings/watchdog/arm,sp805.yaml +the compatible is: + compatible = "arm,sp805", "arm,primecell"; + +The current compatible string doesn't exist at all. Fix it. + +Signed-off-by: Michael Walle +Signed-off-by: Shawn Guo +Signed-off-by: Sasha Levin +--- + arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi | 16 ++++++++-------- + arch/arm64/boot/dts/freescale/fsl-ls208xa.dtsi | 16 ++++++++-------- + 2 files changed, 16 insertions(+), 16 deletions(-) + +diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi +index f85e437f80b73..6050723172436 100644 +--- a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi ++++ b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi +@@ -847,7 +847,7 @@ + }; + + cluster1_core0_watchdog: wdt@c000000 { +- compatible = "arm,sp805-wdt", "arm,primecell"; ++ compatible = "arm,sp805", "arm,primecell"; + reg = <0x0 0xc000000 0x0 0x1000>; + clocks = <&clockgen QORIQ_CLK_PLATFORM_PLL + QORIQ_CLK_PLL_DIV(16)>, +@@ -857,7 +857,7 @@ + }; + + cluster1_core1_watchdog: wdt@c010000 { +- compatible = "arm,sp805-wdt", "arm,primecell"; ++ compatible = "arm,sp805", "arm,primecell"; + reg = <0x0 0xc010000 0x0 0x1000>; + clocks = <&clockgen QORIQ_CLK_PLATFORM_PLL + QORIQ_CLK_PLL_DIV(16)>, +@@ -867,7 +867,7 @@ + }; + + cluster1_core2_watchdog: wdt@c020000 { +- compatible = "arm,sp805-wdt", "arm,primecell"; ++ compatible = "arm,sp805", "arm,primecell"; + reg = <0x0 0xc020000 0x0 0x1000>; + clocks = <&clockgen QORIQ_CLK_PLATFORM_PLL + QORIQ_CLK_PLL_DIV(16)>, +@@ -877,7 +877,7 @@ + }; + + cluster1_core3_watchdog: wdt@c030000 { +- compatible = "arm,sp805-wdt", "arm,primecell"; ++ compatible = "arm,sp805", "arm,primecell"; + reg = <0x0 0xc030000 0x0 0x1000>; + clocks = <&clockgen QORIQ_CLK_PLATFORM_PLL + QORIQ_CLK_PLL_DIV(16)>, +@@ -887,7 +887,7 @@ + }; + + cluster2_core0_watchdog: wdt@c100000 { +- compatible = "arm,sp805-wdt", "arm,primecell"; ++ compatible = "arm,sp805", "arm,primecell"; + reg = <0x0 0xc100000 0x0 0x1000>; + clocks = <&clockgen QORIQ_CLK_PLATFORM_PLL + QORIQ_CLK_PLL_DIV(16)>, +@@ -897,7 +897,7 @@ + }; + + cluster2_core1_watchdog: wdt@c110000 { +- compatible = "arm,sp805-wdt", "arm,primecell"; ++ compatible = "arm,sp805", "arm,primecell"; + reg = <0x0 0xc110000 0x0 0x1000>; + clocks = <&clockgen QORIQ_CLK_PLATFORM_PLL + QORIQ_CLK_PLL_DIV(16)>, +@@ -907,7 +907,7 @@ + }; + + cluster2_core2_watchdog: wdt@c120000 { +- compatible = "arm,sp805-wdt", "arm,primecell"; ++ compatible = "arm,sp805", "arm,primecell"; + reg = <0x0 0xc120000 0x0 0x1000>; + clocks = <&clockgen QORIQ_CLK_PLATFORM_PLL + QORIQ_CLK_PLL_DIV(16)>, +@@ -917,7 +917,7 @@ + }; + + cluster2_core3_watchdog: wdt@c130000 { +- compatible = "arm,sp805-wdt", "arm,primecell"; ++ compatible = "arm,sp805", "arm,primecell"; + reg = <0x0 0xc130000 0x0 0x1000>; + clocks = <&clockgen QORIQ_CLK_PLATFORM_PLL + QORIQ_CLK_PLL_DIV(16)>, +diff --git a/arch/arm64/boot/dts/freescale/fsl-ls208xa.dtsi b/arch/arm64/boot/dts/freescale/fsl-ls208xa.dtsi +index 801ba9612d361..1282b61da8a55 100644 +--- a/arch/arm64/boot/dts/freescale/fsl-ls208xa.dtsi ++++ b/arch/arm64/boot/dts/freescale/fsl-ls208xa.dtsi +@@ -387,7 +387,7 @@ + }; + + cluster1_core0_watchdog: wdt@c000000 { +- compatible = "arm,sp805-wdt", "arm,primecell"; ++ compatible = "arm,sp805", "arm,primecell"; + reg = <0x0 0xc000000 0x0 0x1000>; + clocks = <&clockgen QORIQ_CLK_PLATFORM_PLL + QORIQ_CLK_PLL_DIV(4)>, +@@ -397,7 +397,7 @@ + }; + + cluster1_core1_watchdog: wdt@c010000 { +- compatible = "arm,sp805-wdt", "arm,primecell"; ++ compatible = "arm,sp805", "arm,primecell"; + reg = <0x0 0xc010000 0x0 0x1000>; + clocks = <&clockgen QORIQ_CLK_PLATFORM_PLL + QORIQ_CLK_PLL_DIV(4)>, +@@ -407,7 +407,7 @@ + }; + + cluster2_core0_watchdog: wdt@c100000 { +- compatible = "arm,sp805-wdt", "arm,primecell"; ++ compatible = "arm,sp805", "arm,primecell"; + reg = <0x0 0xc100000 0x0 0x1000>; + clocks = <&clockgen QORIQ_CLK_PLATFORM_PLL + QORIQ_CLK_PLL_DIV(4)>, +@@ -417,7 +417,7 @@ + }; + + cluster2_core1_watchdog: wdt@c110000 { +- compatible = "arm,sp805-wdt", "arm,primecell"; ++ compatible = "arm,sp805", "arm,primecell"; + reg = <0x0 0xc110000 0x0 0x1000>; + clocks = <&clockgen QORIQ_CLK_PLATFORM_PLL + QORIQ_CLK_PLL_DIV(4)>, +@@ -427,7 +427,7 @@ + }; + + cluster3_core0_watchdog: wdt@c200000 { +- compatible = "arm,sp805-wdt", "arm,primecell"; ++ compatible = "arm,sp805", "arm,primecell"; + reg = <0x0 0xc200000 0x0 0x1000>; + clocks = <&clockgen QORIQ_CLK_PLATFORM_PLL + QORIQ_CLK_PLL_DIV(4)>, +@@ -437,7 +437,7 @@ + }; + + cluster3_core1_watchdog: wdt@c210000 { +- compatible = "arm,sp805-wdt", "arm,primecell"; ++ compatible = "arm,sp805", "arm,primecell"; + reg = <0x0 0xc210000 0x0 0x1000>; + clocks = <&clockgen QORIQ_CLK_PLATFORM_PLL + QORIQ_CLK_PLL_DIV(4)>, +@@ -447,7 +447,7 @@ + }; + + cluster4_core0_watchdog: wdt@c300000 { +- compatible = "arm,sp805-wdt", "arm,primecell"; ++ compatible = "arm,sp805", "arm,primecell"; + reg = <0x0 0xc300000 0x0 0x1000>; + clocks = <&clockgen QORIQ_CLK_PLATFORM_PLL + QORIQ_CLK_PLL_DIV(4)>, +@@ -457,7 +457,7 @@ + }; + + cluster4_core1_watchdog: wdt@c310000 { +- compatible = "arm,sp805-wdt", "arm,primecell"; ++ compatible = "arm,sp805", "arm,primecell"; + reg = <0x0 0xc310000 0x0 0x1000>; + clocks = <&clockgen QORIQ_CLK_PLATFORM_PLL + QORIQ_CLK_PLL_DIV(4)>, +-- +2.33.0 + diff --git a/queue-5.15/arm64-dts-hisilicon-fix-arm-sp805-compatible-string.patch b/queue-5.15/arm64-dts-hisilicon-fix-arm-sp805-compatible-string.patch new file mode 100644 index 00000000000..1bb086879f2 --- /dev/null +++ b/queue-5.15/arm64-dts-hisilicon-fix-arm-sp805-compatible-string.patch @@ -0,0 +1,61 @@ +From faadc4616467ceb1000f2770ac92712e5fb7b1da Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 30 Aug 2021 18:51:13 +0200 +Subject: arm64: dts: hisilicon: fix arm,sp805 compatible string + +From: Michael Walle + +[ Upstream commit 894d4f1f77d0e88f1f81af2e1e37333c1c41b631 ] + +According to Documentation/devicetree/bindings/watchdog/arm,sp805.yaml +the compatible is: + compatible = "arm,sp805", "arm,primecell"; + +The current compatible string doesn't exist at all. Fix it. + +Signed-off-by: Michael Walle +Signed-off-by: Wei Xu +Signed-off-by: Sasha Levin +--- + arch/arm64/boot/dts/hisilicon/hi3660.dtsi | 4 ++-- + arch/arm64/boot/dts/hisilicon/hi6220.dtsi | 2 +- + 2 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi +index 2d5c1a348716a..6eabec2602e23 100644 +--- a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi ++++ b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi +@@ -1087,7 +1087,7 @@ + }; + + watchdog0: watchdog@e8a06000 { +- compatible = "arm,sp805-wdt", "arm,primecell"; ++ compatible = "arm,sp805", "arm,primecell"; + reg = <0x0 0xe8a06000 0x0 0x1000>; + interrupts = ; + clocks = <&crg_ctrl HI3660_OSC32K>, +@@ -1096,7 +1096,7 @@ + }; + + watchdog1: watchdog@e8a07000 { +- compatible = "arm,sp805-wdt", "arm,primecell"; ++ compatible = "arm,sp805", "arm,primecell"; + reg = <0x0 0xe8a07000 0x0 0x1000>; + interrupts = ; + clocks = <&crg_ctrl HI3660_OSC32K>, +diff --git a/arch/arm64/boot/dts/hisilicon/hi6220.dtsi b/arch/arm64/boot/dts/hisilicon/hi6220.dtsi +index dde9371dc5451..e4860b8a638ec 100644 +--- a/arch/arm64/boot/dts/hisilicon/hi6220.dtsi ++++ b/arch/arm64/boot/dts/hisilicon/hi6220.dtsi +@@ -840,7 +840,7 @@ + }; + + watchdog0: watchdog@f8005000 { +- compatible = "arm,sp805-wdt", "arm,primecell"; ++ compatible = "arm,sp805", "arm,primecell"; + reg = <0x0 0xf8005000 0x0 0x1000>; + interrupts = ; + clocks = <&ao_ctrl HI6220_WDT0_PCLK>, +-- +2.33.0 + diff --git a/queue-5.15/arm64-dts-imx8mm-kontron-fix-reset-delays-for-ethern.patch b/queue-5.15/arm64-dts-imx8mm-kontron-fix-reset-delays-for-ethern.patch new file mode 100644 index 00000000000..60d98e03e27 --- /dev/null +++ b/queue-5.15/arm64-dts-imx8mm-kontron-fix-reset-delays-for-ethern.patch @@ -0,0 +1,39 @@ +From c7edd4d16396d540b52c034edeb52d9e4e392c2b Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 30 Sep 2021 17:56:30 +0200 +Subject: arm64: dts: imx8mm-kontron: Fix reset delays for ethernet PHY + +From: Frieder Schrempf + +[ Upstream commit 315e7b884190a6c9c28e95ad3b724dde9e922b99 ] + +According to the datasheet the VSC8531 PHY expects a reset pulse of 100 ns +and a delay of 15 ms after the reset has been deasserted. Set the matching +values in the devicetree. + +Reported-by: Heiko Thiery +Signed-off-by: Frieder Schrempf +Signed-off-by: Shawn Guo +Signed-off-by: Sasha Levin +--- + arch/arm64/boot/dts/freescale/imx8mm-kontron-n801x-s.dts | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/arch/arm64/boot/dts/freescale/imx8mm-kontron-n801x-s.dts b/arch/arm64/boot/dts/freescale/imx8mm-kontron-n801x-s.dts +index e99e7644ff392..49d7470812eef 100644 +--- a/arch/arm64/boot/dts/freescale/imx8mm-kontron-n801x-s.dts ++++ b/arch/arm64/boot/dts/freescale/imx8mm-kontron-n801x-s.dts +@@ -123,8 +123,8 @@ + + ethphy: ethernet-phy@0 { + reg = <0>; +- reset-assert-us = <100>; +- reset-deassert-us = <100>; ++ reset-assert-us = <1>; ++ reset-deassert-us = <15000>; + reset-gpios = <&gpio4 27 GPIO_ACTIVE_LOW>; + }; + }; +-- +2.33.0 + diff --git a/queue-5.15/arm64-dts-ls1012a-add-serial-alias-for-ls1012a-rdb.patch b/queue-5.15/arm64-dts-ls1012a-add-serial-alias-for-ls1012a-rdb.patch new file mode 100644 index 00000000000..7c8352670b5 --- /dev/null +++ b/queue-5.15/arm64-dts-ls1012a-add-serial-alias-for-ls1012a-rdb.patch @@ -0,0 +1,53 @@ +From 2d01e4313eccbe72b11ea2f03f2784881d8dd211 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 9 Sep 2021 16:42:29 +0530 +Subject: arm64: dts: ls1012a: Add serial alias for ls1012a-rdb + +From: Kuldeep Singh + +[ Upstream commit 7f31ae6e01da140e34d6513815253e811019f016 ] + +U-boot atempts to read serial alias value for ls1012a-rdb but couldn't +do so as it is not initialised and thus, FDT_ERR_NOTFOUND error is +reported while booting linux. + +Loading fdt from FIT Image at a0000000 ... + Description: ls1012ardb-dtb + Type: Flat Device Tree + Data Start: 0xab111474 + Data Size: 11285 Bytes = 11 KiB + Architecture: AArch64 + Load Address: 0x90000000 + Loading fdt from 0xab111474 to 0x90000000 + Booting using the fdt blob at 0x90000000 + Uncompressing Kernel Image + Loading Device Tree to 000000008fffa000, end 000000008ffffc14 ... OK +WARNING: fdt_fixup_stdout: could not read serial0 alias: FDT_ERR_NOTFOUND +NOTICE: RNG: INSTANTIATED + +Starting kernel ... + +Fix the above error by specifying serial value to duart. + +Signed-off-by: Kuldeep Singh +Signed-off-by: Shawn Guo +Signed-off-by: Sasha Levin +--- + arch/arm64/boot/dts/freescale/fsl-ls1012a-rdb.dts | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1012a-rdb.dts b/arch/arm64/boot/dts/freescale/fsl-ls1012a-rdb.dts +index 79f155dedb2d0..e662677a6e28f 100644 +--- a/arch/arm64/boot/dts/freescale/fsl-ls1012a-rdb.dts ++++ b/arch/arm64/boot/dts/freescale/fsl-ls1012a-rdb.dts +@@ -15,6 +15,7 @@ + compatible = "fsl,ls1012a-rdb", "fsl,ls1012a"; + + aliases { ++ serial0 = &duart0; + mmc0 = &esdhc0; + mmc1 = &esdhc1; + }; +-- +2.33.0 + diff --git a/queue-5.15/arm64-dts-qcom-fix-node-name-of-rpm-msg-ram-device-n.patch b/queue-5.15/arm64-dts-qcom-fix-node-name-of-rpm-msg-ram-device-n.patch new file mode 100644 index 00000000000..db93977c7d8 --- /dev/null +++ b/queue-5.15/arm64-dts-qcom-fix-node-name-of-rpm-msg-ram-device-n.patch @@ -0,0 +1,125 @@ +From 39b6c2901f7791f10542265803ca91e2ac37d65a Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 18 Oct 2021 13:00:08 +0200 +Subject: arm64: dts: qcom: Fix node name of rpm-msg-ram device nodes + +From: Stephan Gerhold + +[ Upstream commit 179811bebc7b91e0f9d0adee9bfa3d2af9c43869 ] + +According to the new DT schema for qcom,rpm-msg-ram the node name +should be sram@. memory@ is reserved for definition of physical RAM +(usable by Linux). + +This fixes the following dtbs_check error on various device trees: +memory@60000: 'device_type' is a required property + From schema: dtschema/schemas/memory.yaml + +Signed-off-by: Stephan Gerhold +Signed-off-by: Bjorn Andersson +Link: https://lore.kernel.org/r/20211018110009.30837-1-stephan@gerhold.net +Signed-off-by: Sasha Levin +--- + arch/arm64/boot/dts/qcom/msm8916.dtsi | 2 +- + arch/arm64/boot/dts/qcom/msm8994.dtsi | 2 +- + arch/arm64/boot/dts/qcom/msm8996.dtsi | 2 +- + arch/arm64/boot/dts/qcom/msm8998.dtsi | 2 +- + arch/arm64/boot/dts/qcom/qcs404.dtsi | 2 +- + arch/arm64/boot/dts/qcom/sdm630.dtsi | 2 +- + arch/arm64/boot/dts/qcom/sm6125.dtsi | 2 +- + 7 files changed, 7 insertions(+), 7 deletions(-) + +diff --git a/arch/arm64/boot/dts/qcom/msm8916.dtsi b/arch/arm64/boot/dts/qcom/msm8916.dtsi +index 38d5f2a4f2ae9..5b5619b74d3a1 100644 +--- a/arch/arm64/boot/dts/qcom/msm8916.dtsi ++++ b/arch/arm64/boot/dts/qcom/msm8916.dtsi +@@ -453,7 +453,7 @@ + }; + }; + +- rpm_msg_ram: memory@60000 { ++ rpm_msg_ram: sram@60000 { + compatible = "qcom,rpm-msg-ram"; + reg = <0x00060000 0x8000>; + }; +diff --git a/arch/arm64/boot/dts/qcom/msm8994.dtsi b/arch/arm64/boot/dts/qcom/msm8994.dtsi +index 986fe60dec5fb..5a9a5ed0565f6 100644 +--- a/arch/arm64/boot/dts/qcom/msm8994.dtsi ++++ b/arch/arm64/boot/dts/qcom/msm8994.dtsi +@@ -715,7 +715,7 @@ + reg = <0xfc400000 0x2000>; + }; + +- rpm_msg_ram: memory@fc428000 { ++ rpm_msg_ram: sram@fc428000 { + compatible = "qcom,rpm-msg-ram"; + reg = <0xfc428000 0x4000>; + }; +diff --git a/arch/arm64/boot/dts/qcom/msm8996.dtsi b/arch/arm64/boot/dts/qcom/msm8996.dtsi +index 52df22ab3f6ae..f8d28dd76cfa8 100644 +--- a/arch/arm64/boot/dts/qcom/msm8996.dtsi ++++ b/arch/arm64/boot/dts/qcom/msm8996.dtsi +@@ -638,7 +638,7 @@ + }; + }; + +- rpm_msg_ram: memory@68000 { ++ rpm_msg_ram: sram@68000 { + compatible = "qcom,rpm-msg-ram"; + reg = <0x00068000 0x6000>; + }; +diff --git a/arch/arm64/boot/dts/qcom/msm8998.dtsi b/arch/arm64/boot/dts/qcom/msm8998.dtsi +index 5a221cfc41387..228339f81c327 100644 +--- a/arch/arm64/boot/dts/qcom/msm8998.dtsi ++++ b/arch/arm64/boot/dts/qcom/msm8998.dtsi +@@ -861,7 +861,7 @@ + reg = <0x00100000 0xb0000>; + }; + +- rpm_msg_ram: memory@778000 { ++ rpm_msg_ram: sram@778000 { + compatible = "qcom,rpm-msg-ram"; + reg = <0x00778000 0x7000>; + }; +diff --git a/arch/arm64/boot/dts/qcom/qcs404.dtsi b/arch/arm64/boot/dts/qcom/qcs404.dtsi +index 339790ba585de..ca5be16479809 100644 +--- a/arch/arm64/boot/dts/qcom/qcs404.dtsi ++++ b/arch/arm64/boot/dts/qcom/qcs404.dtsi +@@ -318,7 +318,7 @@ + status = "disabled"; + }; + +- rpm_msg_ram: memory@60000 { ++ rpm_msg_ram: sram@60000 { + compatible = "qcom,rpm-msg-ram"; + reg = <0x00060000 0x6000>; + }; +diff --git a/arch/arm64/boot/dts/qcom/sdm630.dtsi b/arch/arm64/boot/dts/qcom/sdm630.dtsi +index 9c7f87e42fccd..a8724fd60645f 100644 +--- a/arch/arm64/boot/dts/qcom/sdm630.dtsi ++++ b/arch/arm64/boot/dts/qcom/sdm630.dtsi +@@ -541,7 +541,7 @@ + <&sleep_clk>; + }; + +- rpm_msg_ram: memory@778000 { ++ rpm_msg_ram: sram@778000 { + compatible = "qcom,rpm-msg-ram"; + reg = <0x00778000 0x7000>; + }; +diff --git a/arch/arm64/boot/dts/qcom/sm6125.dtsi b/arch/arm64/boot/dts/qcom/sm6125.dtsi +index 2b37ce6a9f9c5..9f476e3d0720b 100644 +--- a/arch/arm64/boot/dts/qcom/sm6125.dtsi ++++ b/arch/arm64/boot/dts/qcom/sm6125.dtsi +@@ -380,7 +380,7 @@ + status = "disabled"; + }; + +- rpm_msg_ram: memory@45f0000 { ++ rpm_msg_ram: sram@45f0000 { + compatible = "qcom,rpm-msg-ram"; + reg = <0x045f0000 0x7000>; + }; +-- +2.33.0 + diff --git a/queue-5.15/arm64-dts-qcom-ipq6018-fix-qcom-controlled-remotely-.patch b/queue-5.15/arm64-dts-qcom-ipq6018-fix-qcom-controlled-remotely-.patch new file mode 100644 index 00000000000..34981e3a2ba --- /dev/null +++ b/queue-5.15/arm64-dts-qcom-ipq6018-fix-qcom-controlled-remotely-.patch @@ -0,0 +1,35 @@ +From 9a2b7a5b6e40a0b629a976349d7349fd22e04e2f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 29 Aug 2021 19:16:26 +0800 +Subject: arm64: dts: qcom: ipq6018: Fix qcom,controlled-remotely property + +From: Shawn Guo + +[ Upstream commit 3509de752ea14c7e5781b3a56a4a0bf832f5723a ] + +Property qcom,controlled-remotely should be boolean. Fix it. + +Signed-off-by: Shawn Guo +Signed-off-by: Bjorn Andersson +Link: https://lore.kernel.org/r/20210829111628.5543-2-shawn.guo@linaro.org +Signed-off-by: Sasha Levin +--- + arch/arm64/boot/dts/qcom/ipq6018.dtsi | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/arch/arm64/boot/dts/qcom/ipq6018.dtsi b/arch/arm64/boot/dts/qcom/ipq6018.dtsi +index d2fe58e0eb7aa..7b6205c180df1 100644 +--- a/arch/arm64/boot/dts/qcom/ipq6018.dtsi ++++ b/arch/arm64/boot/dts/qcom/ipq6018.dtsi +@@ -200,7 +200,7 @@ + clock-names = "bam_clk"; + #dma-cells = <1>; + qcom,ee = <1>; +- qcom,controlled-remotely = <1>; ++ qcom,controlled-remotely; + qcom,config-pipe-trust-reg = <0>; + }; + +-- +2.33.0 + diff --git a/queue-5.15/arm64-dts-qcom-ipq8074-fix-qcom-controlled-remotely-.patch b/queue-5.15/arm64-dts-qcom-ipq8074-fix-qcom-controlled-remotely-.patch new file mode 100644 index 00000000000..4ee9fa01f38 --- /dev/null +++ b/queue-5.15/arm64-dts-qcom-ipq8074-fix-qcom-controlled-remotely-.patch @@ -0,0 +1,35 @@ +From 3bc5c9e09b2ab12c0ae7af51b9a739506d25d038 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 29 Aug 2021 19:16:27 +0800 +Subject: arm64: dts: qcom: ipq8074: Fix qcom,controlled-remotely property + +From: Shawn Guo + +[ Upstream commit 8c97f0ac4dc8f1743eb8e8a49f66189e13ae45e9 ] + +Property qcom,controlled-remotely should be boolean. Fix it. + +Signed-off-by: Shawn Guo +Signed-off-by: Bjorn Andersson +Link: https://lore.kernel.org/r/20210829111628.5543-3-shawn.guo@linaro.org +Signed-off-by: Sasha Levin +--- + arch/arm64/boot/dts/qcom/ipq8074.dtsi | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/arch/arm64/boot/dts/qcom/ipq8074.dtsi b/arch/arm64/boot/dts/qcom/ipq8074.dtsi +index db333001df4d6..97f99663c132e 100644 +--- a/arch/arm64/boot/dts/qcom/ipq8074.dtsi ++++ b/arch/arm64/boot/dts/qcom/ipq8074.dtsi +@@ -220,7 +220,7 @@ + clock-names = "bam_clk"; + #dma-cells = <1>; + qcom,ee = <1>; +- qcom,controlled-remotely = <1>; ++ qcom,controlled-remotely; + status = "disabled"; + }; + +-- +2.33.0 + diff --git a/queue-5.15/arm64-dts-qcom-msm8916-add-cpu-acc-and-saw-spm.patch b/queue-5.15/arm64-dts-qcom-msm8916-add-cpu-acc-and-saw-spm.patch new file mode 100644 index 00000000000..e7fd21c5ef2 --- /dev/null +++ b/queue-5.15/arm64-dts-qcom-msm8916-add-cpu-acc-and-saw-spm.patch @@ -0,0 +1,131 @@ +From 4b41a4624fb79b1745e888594425ec592946fb80 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 4 Oct 2021 22:49:53 +0200 +Subject: arm64: dts: qcom: msm8916: Add CPU ACC and SAW/SPM + +From: Stephan Gerhold + +[ Upstream commit a22f9a766e1dc61f8f6ee2edfe83d4d23d78e059 ] + +Add the device tree nodes necessary for SMP bring-up and cpuidle +without PSCI on ARM32. The hardware is typically controlled by the +PSCI implementation in the TrustZone firmware and is therefore marked +as status = "reserved" by default (from the device tree specification): + + "Indicates that the device is operational, but should not be used. + Typically this is used for devices that are controlled by another + software component, such as platform firmware." + +Since this is part of the MSM8916 SoC it should be added to msm8916.dtsi +but in practice these nodes should only get enabled via an extra include +on ARM32. + +This is necessary for some devices with signed firmware which is missing +both ARM64 and PSCI support and can therefore only boot ARM32 kernels. + +Signed-off-by: Stephan Gerhold +Signed-off-by: Bjorn Andersson +Link: https://lore.kernel.org/r/20211004204955.21077-13-stephan@gerhold.net +Signed-off-by: Sasha Levin +--- + arch/arm64/boot/dts/qcom/msm8916.dtsi | 56 +++++++++++++++++++++++++++ + 1 file changed, 56 insertions(+) + +diff --git a/arch/arm64/boot/dts/qcom/msm8916.dtsi b/arch/arm64/boot/dts/qcom/msm8916.dtsi +index 519abec2430f0..38d5f2a4f2ae9 100644 +--- a/arch/arm64/boot/dts/qcom/msm8916.dtsi ++++ b/arch/arm64/boot/dts/qcom/msm8916.dtsi +@@ -124,6 +124,8 @@ + #cooling-cells = <2>; + power-domains = <&CPU_PD0>; + power-domain-names = "psci"; ++ qcom,acc = <&cpu0_acc>; ++ qcom,saw = <&cpu0_saw>; + }; + + CPU1: cpu@1 { +@@ -137,6 +139,8 @@ + #cooling-cells = <2>; + power-domains = <&CPU_PD1>; + power-domain-names = "psci"; ++ qcom,acc = <&cpu1_acc>; ++ qcom,saw = <&cpu1_saw>; + }; + + CPU2: cpu@2 { +@@ -150,6 +154,8 @@ + #cooling-cells = <2>; + power-domains = <&CPU_PD2>; + power-domain-names = "psci"; ++ qcom,acc = <&cpu2_acc>; ++ qcom,saw = <&cpu2_saw>; + }; + + CPU3: cpu@3 { +@@ -163,6 +169,8 @@ + #cooling-cells = <2>; + power-domains = <&CPU_PD3>; + power-domain-names = "psci"; ++ qcom,acc = <&cpu3_acc>; ++ qcom,saw = <&cpu3_saw>; + }; + + L2_0: l2-cache { +@@ -1877,6 +1885,54 @@ + status = "disabled"; + }; + }; ++ ++ cpu0_acc: power-manager@b088000 { ++ compatible = "qcom,msm8916-acc"; ++ reg = <0x0b088000 0x1000>; ++ status = "reserved"; /* Controlled by PSCI firmware */ ++ }; ++ ++ cpu0_saw: power-manager@b089000 { ++ compatible = "qcom,msm8916-saw2-v3.0-cpu", "qcom,saw2"; ++ reg = <0x0b089000 0x1000>; ++ status = "reserved"; /* Controlled by PSCI firmware */ ++ }; ++ ++ cpu1_acc: power-manager@b098000 { ++ compatible = "qcom,msm8916-acc"; ++ reg = <0x0b098000 0x1000>; ++ status = "reserved"; /* Controlled by PSCI firmware */ ++ }; ++ ++ cpu1_saw: power-manager@b099000 { ++ compatible = "qcom,msm8916-saw2-v3.0-cpu", "qcom,saw2"; ++ reg = <0x0b099000 0x1000>; ++ status = "reserved"; /* Controlled by PSCI firmware */ ++ }; ++ ++ cpu2_acc: power-manager@b0a8000 { ++ compatible = "qcom,msm8916-acc"; ++ reg = <0x0b0a8000 0x1000>; ++ status = "reserved"; /* Controlled by PSCI firmware */ ++ }; ++ ++ cpu2_saw: power-manager@b0a9000 { ++ compatible = "qcom,msm8916-saw2-v3.0-cpu", "qcom,saw2"; ++ reg = <0x0b0a9000 0x1000>; ++ status = "reserved"; /* Controlled by PSCI firmware */ ++ }; ++ ++ cpu3_acc: power-manager@b0b8000 { ++ compatible = "qcom,msm8916-acc"; ++ reg = <0x0b0b8000 0x1000>; ++ status = "reserved"; /* Controlled by PSCI firmware */ ++ }; ++ ++ cpu3_saw: power-manager@b0b9000 { ++ compatible = "qcom,msm8916-saw2-v3.0-cpu", "qcom,saw2"; ++ reg = <0x0b0b9000 0x1000>; ++ status = "reserved"; /* Controlled by PSCI firmware */ ++ }; + }; + + thermal-zones { +-- +2.33.0 + diff --git a/queue-5.15/arm64-dts-qcom-msm8916-add-unit-name-for-soc-node.patch b/queue-5.15/arm64-dts-qcom-msm8916-add-unit-name-for-soc-node.patch new file mode 100644 index 00000000000..fe331d01c95 --- /dev/null +++ b/queue-5.15/arm64-dts-qcom-msm8916-add-unit-name-for-soc-node.patch @@ -0,0 +1,38 @@ +From c63364a33920ceddf3d98c4eb80910b6d8f70c44 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 21 Sep 2021 17:21:18 +0200 +Subject: arm64: dts: qcom: msm8916: Add unit name for /soc node + +From: Stephan Gerhold + +[ Upstream commit 7a62bfebc8c94bdb6eb8f54f49889dc6b5b79601 ] + +This fixes the following warning when building with W=1: +Warning (unit_address_vs_reg): /soc: node has a reg or ranges property, +but no unit name + +Signed-off-by: Stephan Gerhold +Reviewed-by: Stephen Boyd +Signed-off-by: Bjorn Andersson +Link: https://lore.kernel.org/r/20210921152120.6710-1-stephan@gerhold.net +Signed-off-by: Sasha Levin +--- + arch/arm64/boot/dts/qcom/msm8916.dtsi | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/arch/arm64/boot/dts/qcom/msm8916.dtsi b/arch/arm64/boot/dts/qcom/msm8916.dtsi +index fbff712639513..519abec2430f0 100644 +--- a/arch/arm64/boot/dts/qcom/msm8916.dtsi ++++ b/arch/arm64/boot/dts/qcom/msm8916.dtsi +@@ -414,7 +414,7 @@ + }; + }; + +- soc: soc { ++ soc: soc@0 { + #address-cells = <1>; + #size-cells = <1>; + ranges = <0 0 0 0xffffffff>; +-- +2.33.0 + diff --git a/queue-5.15/arm64-dts-qcom-msm8998-fix-cpu-l2-idle-state-latency.patch b/queue-5.15/arm64-dts-qcom-msm8998-fix-cpu-l2-idle-state-latency.patch new file mode 100644 index 00000000000..171ab266de1 --- /dev/null +++ b/queue-5.15/arm64-dts-qcom-msm8998-fix-cpu-l2-idle-state-latency.patch @@ -0,0 +1,95 @@ +From 82824a8900191b78790abb27c286c1bae5a2ea95 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 1 Sep 2021 20:31:21 +0200 +Subject: arm64: dts: qcom: msm8998: Fix CPU/L2 idle state latency and + residency + +From: AngeloGioacchino Del Regno + +[ Upstream commit 3f1dcaff642e75c1d2ad03f783fa8a3b1f56dd50 ] + +The entry/exit latency and minimum residency in state for the idle +states of MSM8998 were ..bad: first of all, for all of them the +timings were written for CPU sleep but the min-residency-us param +was miscalculated (supposedly, while porting this from downstream); +Then, the power collapse states are setting PC on both the CPU +cluster *and* the L2 cache, which have different timings: in the +specific case of L2 the times are higher so these ones should be +taken into account instead of the CPU ones. + +This parameter misconfiguration was not giving particular issues +because on MSM8998 there was no CPU scaling at all, so cluster/L2 +power collapse was rarely (if ever) hit. +When CPU scaling is enabled, though, the wrong timings will produce +SoC unstability shown to the user as random, apparently error-less, +sudden reboots and/or lockups. + +This set of parameters are stabilizing the SoC when CPU scaling is +ON and when power collapse is frequently hit. + +Signed-off-by: AngeloGioacchino Del Regno +Signed-off-by: Bjorn Andersson +Link: https://lore.kernel.org/r/20210901183123.1087392-3-angelogioacchino.delregno@somainline.org +Signed-off-by: Sasha Levin +--- + arch/arm64/boot/dts/qcom/msm8998.dtsi | 20 ++++++++++++-------- + 1 file changed, 12 insertions(+), 8 deletions(-) + +diff --git a/arch/arm64/boot/dts/qcom/msm8998.dtsi b/arch/arm64/boot/dts/qcom/msm8998.dtsi +index 34039b5c80175..5a221cfc41387 100644 +--- a/arch/arm64/boot/dts/qcom/msm8998.dtsi ++++ b/arch/arm64/boot/dts/qcom/msm8998.dtsi +@@ -308,38 +308,42 @@ + LITTLE_CPU_SLEEP_0: cpu-sleep-0-0 { + compatible = "arm,idle-state"; + idle-state-name = "little-retention"; ++ /* CPU Retention (C2D), L2 Active */ + arm,psci-suspend-param = <0x00000002>; + entry-latency-us = <81>; + exit-latency-us = <86>; +- min-residency-us = <200>; ++ min-residency-us = <504>; + }; + + LITTLE_CPU_SLEEP_1: cpu-sleep-0-1 { + compatible = "arm,idle-state"; + idle-state-name = "little-power-collapse"; ++ /* CPU + L2 Power Collapse (C3, D4) */ + arm,psci-suspend-param = <0x40000003>; +- entry-latency-us = <273>; +- exit-latency-us = <612>; +- min-residency-us = <1000>; ++ entry-latency-us = <814>; ++ exit-latency-us = <4562>; ++ min-residency-us = <9183>; + local-timer-stop; + }; + + BIG_CPU_SLEEP_0: cpu-sleep-1-0 { + compatible = "arm,idle-state"; + idle-state-name = "big-retention"; ++ /* CPU Retention (C2D), L2 Active */ + arm,psci-suspend-param = <0x00000002>; + entry-latency-us = <79>; + exit-latency-us = <82>; +- min-residency-us = <200>; ++ min-residency-us = <1302>; + }; + + BIG_CPU_SLEEP_1: cpu-sleep-1-1 { + compatible = "arm,idle-state"; + idle-state-name = "big-power-collapse"; ++ /* CPU + L2 Power Collapse (C3, D4) */ + arm,psci-suspend-param = <0x40000003>; +- entry-latency-us = <336>; +- exit-latency-us = <525>; +- min-residency-us = <1000>; ++ entry-latency-us = <724>; ++ exit-latency-us = <2027>; ++ min-residency-us = <9419>; + local-timer-stop; + }; + }; +-- +2.33.0 + diff --git a/queue-5.15/arm64-dts-qcom-sdm845-fix-qcom-controlled-remotely-p.patch b/queue-5.15/arm64-dts-qcom-sdm845-fix-qcom-controlled-remotely-p.patch new file mode 100644 index 00000000000..7389ac68f86 --- /dev/null +++ b/queue-5.15/arm64-dts-qcom-sdm845-fix-qcom-controlled-remotely-p.patch @@ -0,0 +1,35 @@ +From ceec3cb04d56265fe5eb7086ebf87d36932fdc66 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 29 Aug 2021 19:16:28 +0800 +Subject: arm64: dts: qcom: sdm845: Fix qcom,controlled-remotely property + +From: Shawn Guo + +[ Upstream commit 1c8bf398b6b51eb085a49036ad8f9c000171cce1 ] + +Property qcom,controlled-remotely should be boolean. Fix it. + +Signed-off-by: Shawn Guo +Signed-off-by: Bjorn Andersson +Link: https://lore.kernel.org/r/20210829111628.5543-4-shawn.guo@linaro.org +Signed-off-by: Sasha Levin +--- + arch/arm64/boot/dts/qcom/sdm845.dtsi | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/arch/arm64/boot/dts/qcom/sdm845.dtsi b/arch/arm64/boot/dts/qcom/sdm845.dtsi +index a810adc1a707f..519ca9a705b4f 100644 +--- a/arch/arm64/boot/dts/qcom/sdm845.dtsi ++++ b/arch/arm64/boot/dts/qcom/sdm845.dtsi +@@ -2320,7 +2320,7 @@ + clock-names = "bam_clk"; + #dma-cells = <1>; + qcom,ee = <0>; +- qcom,controlled-remotely = <1>; ++ qcom,controlled-remotely; + iommus = <&apps_smmu 0x704 0x1>, + <&apps_smmu 0x706 0x1>, + <&apps_smmu 0x714 0x1>, +-- +2.33.0 + diff --git a/queue-5.15/arm64-dts-rockchip-disable-cdn-dp-on-pinebook-pro.patch b/queue-5.15/arm64-dts-rockchip-disable-cdn-dp-on-pinebook-pro.patch new file mode 100644 index 00000000000..d429846ca1b --- /dev/null +++ b/queue-5.15/arm64-dts-rockchip-disable-cdn-dp-on-pinebook-pro.patch @@ -0,0 +1,43 @@ +From c5290a76f9db8bb8e336edcc60454258acb53f53 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 15 Jul 2021 18:41:01 +0200 +Subject: arm64: dts: rockchip: Disable CDN DP on Pinebook Pro + +From: Matthias Brugger + +[ Upstream commit 2513fa5c25d42f55ca5f0f0ab247af7c9fbfa3b1 ] + +The CDN DP needs a PHY and a extcon to work correctly. But no extcon is +provided by the device-tree, which leads to an error: +cdn-dp fec00000.dp: [drm:cdn_dp_probe [rockchipdrm]] *ERROR* missing extcon or phy +cdn-dp: probe of fec00000.dp failed with error -22 + +Disable the CDN DP to make graphic work on the Pinebook Pro. + +Reported-by: Guillaume Gardet +Signed-off-by: Matthias Brugger +Link: https://lore.kernel.org/r/20210715164101.11486-1-matthias.bgg@kernel.org +Signed-off-by: Heiko Stuebner +Signed-off-by: Sasha Levin +--- + arch/arm64/boot/dts/rockchip/rk3399-pinebook-pro.dts | 4 ---- + 1 file changed, 4 deletions(-) + +diff --git a/arch/arm64/boot/dts/rockchip/rk3399-pinebook-pro.dts b/arch/arm64/boot/dts/rockchip/rk3399-pinebook-pro.dts +index 2b5f001ff4a61..9e5d07f5712e6 100644 +--- a/arch/arm64/boot/dts/rockchip/rk3399-pinebook-pro.dts ++++ b/arch/arm64/boot/dts/rockchip/rk3399-pinebook-pro.dts +@@ -385,10 +385,6 @@ + }; + }; + +-&cdn_dp { +- status = "okay"; +-}; +- + &cpu_b0 { + cpu-supply = <&vdd_cpu_b>; + }; +-- +2.33.0 + diff --git a/queue-5.15/arm64-zynqmp-do-not-duplicate-flash-partition-label-.patch b/queue-5.15/arm64-zynqmp-do-not-duplicate-flash-partition-label-.patch new file mode 100644 index 00000000000..6ecd0c7f81a --- /dev/null +++ b/queue-5.15/arm64-zynqmp-do-not-duplicate-flash-partition-label-.patch @@ -0,0 +1,54 @@ +From 586758a4d9365e4cdf07dd5e6427233461fe4a51 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 14 Jun 2021 17:25:10 +0200 +Subject: arm64: zynqmp: Do not duplicate flash partition label property + +From: Amit Kumar Mahapatra + +[ Upstream commit 167721a5909f867f8c18c8e78ea58e705ad9bbd4 ] + +In kernel 5.4, support has been added for reading MTD devices via the nvmem +API. +For this the mtd devices are registered as read-only NVMEM providers under +sysfs with the same name as the flash partition label property. + +So if flash partition label property of multiple flash devices are +identical then the second mtd device fails to get registered as a NVMEM +provider. + +This patch fixes the issue by having different label property for different +flashes. + +Signed-off-by: Amit Kumar Mahapatra +Signed-off-by: Michal Simek +Link: https://lore.kernel.org/r/6c4b9b9232b93d9e316a63c086540fd5bf6b8687.1623684253.git.michal.simek@xilinx.com +Signed-off-by: Sasha Levin +--- + arch/arm64/boot/dts/xilinx/zynqmp-zc1751-xm016-dc2.dts | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/arch/arm64/boot/dts/xilinx/zynqmp-zc1751-xm016-dc2.dts b/arch/arm64/boot/dts/xilinx/zynqmp-zc1751-xm016-dc2.dts +index 4a86efa32d687..f7124e15f0ff6 100644 +--- a/arch/arm64/boot/dts/xilinx/zynqmp-zc1751-xm016-dc2.dts ++++ b/arch/arm64/boot/dts/xilinx/zynqmp-zc1751-xm016-dc2.dts +@@ -131,7 +131,7 @@ + reg = <0>; + + partition@0 { +- label = "data"; ++ label = "spi0-data"; + reg = <0x0 0x100000>; + }; + }; +@@ -149,7 +149,7 @@ + reg = <0>; + + partition@0 { +- label = "data"; ++ label = "spi1-data"; + reg = <0x0 0x84000>; + }; + }; +-- +2.33.0 + diff --git a/queue-5.15/arm64-zynqmp-fix-serial-compatible-string.patch b/queue-5.15/arm64-zynqmp-fix-serial-compatible-string.patch new file mode 100644 index 00000000000..fe5e15704ed --- /dev/null +++ b/queue-5.15/arm64-zynqmp-fix-serial-compatible-string.patch @@ -0,0 +1,46 @@ +From 71727f55fa00b84a453cfbbdf745f0f5bdc24e5d Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 6 Aug 2021 10:58:29 +0200 +Subject: arm64: zynqmp: Fix serial compatible string + +From: Michal Simek + +[ Upstream commit 812fa2f0e9d33564bd0131a69750e0d165f4c82a ] + +Based on commit 65a2c14d4f00 ("dt-bindings: serial: convert Cadence UART +bindings to YAML") compatible string should look like differently that's +why fix it to be aligned with dt binding. + +Signed-off-by: Michal Simek +Reviewed-by: Laurent Pinchart +Link: https://lore.kernel.org/r/89b36e0a6187cc6b05b27a035efdf79173bd4486.1628240307.git.michal.simek@xilinx.com +Signed-off-by: Sasha Levin +--- + arch/arm64/boot/dts/xilinx/zynqmp.dtsi | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/arch/arm64/boot/dts/xilinx/zynqmp.dtsi b/arch/arm64/boot/dts/xilinx/zynqmp.dtsi +index 28dccb891a535..8278876ad33fa 100644 +--- a/arch/arm64/boot/dts/xilinx/zynqmp.dtsi ++++ b/arch/arm64/boot/dts/xilinx/zynqmp.dtsi +@@ -792,7 +792,7 @@ + }; + + uart0: serial@ff000000 { +- compatible = "cdns,uart-r1p12", "xlnx,xuartps"; ++ compatible = "xlnx,zynqmp-uart", "cdns,uart-r1p12"; + status = "disabled"; + interrupt-parent = <&gic>; + interrupts = <0 21 4>; +@@ -802,7 +802,7 @@ + }; + + uart1: serial@ff010000 { +- compatible = "cdns,uart-r1p12", "xlnx,xuartps"; ++ compatible = "xlnx,zynqmp-uart", "cdns,uart-r1p12"; + status = "disabled"; + interrupt-parent = <&gic>; + interrupts = <0 22 4>; +-- +2.33.0 + diff --git a/queue-5.15/asoc-es8316-use-irqf_no_autoen-when-requesting-the-i.patch b/queue-5.15/asoc-es8316-use-irqf_no_autoen-when-requesting-the-i.patch new file mode 100644 index 00000000000..8141d1214d0 --- /dev/null +++ b/queue-5.15/asoc-es8316-use-irqf_no_autoen-when-requesting-the-i.patch @@ -0,0 +1,45 @@ +From b0db06440f382650cf76062f895a864f68f793ba Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 3 Oct 2021 15:22:54 +0200 +Subject: ASoC: es8316: Use IRQF_NO_AUTOEN when requesting the IRQ + +From: Hans de Goede + +[ Upstream commit 1cf2aa665901054b140eb71748661ceae99b6b5a ] + +Use the new IRQF_NO_AUTOEN flag when requesting the IRQ, rather then +disabling it immediately after requesting it. + +This fixes a possible race where the IRQ might trigger between requesting +and disabling it; and this also leads to a small code cleanup. + +Signed-off-by: Hans de Goede +Link: https://lore.kernel.org/r/20211003132255.31743-1-hdegoede@redhat.com +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + sound/soc/codecs/es8316.c | 7 ++----- + 1 file changed, 2 insertions(+), 5 deletions(-) + +diff --git a/sound/soc/codecs/es8316.c b/sound/soc/codecs/es8316.c +index 067757d1d70a3..5fb02635c1406 100644 +--- a/sound/soc/codecs/es8316.c ++++ b/sound/soc/codecs/es8316.c +@@ -811,12 +811,9 @@ static int es8316_i2c_probe(struct i2c_client *i2c_client, + mutex_init(&es8316->lock); + + ret = devm_request_threaded_irq(dev, es8316->irq, NULL, es8316_irq, +- IRQF_TRIGGER_HIGH | IRQF_ONESHOT, ++ IRQF_TRIGGER_HIGH | IRQF_ONESHOT | IRQF_NO_AUTOEN, + "es8316", es8316); +- if (ret == 0) { +- /* Gets re-enabled by es8316_set_jack() */ +- disable_irq(es8316->irq); +- } else { ++ if (ret) { + dev_warn(dev, "Failed to get IRQ %d: %d\n", es8316->irq, ret); + es8316->irq = -ENXIO; + } +-- +2.33.0 + diff --git a/queue-5.15/asoc-intel-soc-acpi-add-missing-quirk-for-tgl-sdca-s.patch b/queue-5.15/asoc-intel-soc-acpi-add-missing-quirk-for-tgl-sdca-s.patch new file mode 100644 index 00000000000..032eaaed6f4 --- /dev/null +++ b/queue-5.15/asoc-intel-soc-acpi-add-missing-quirk-for-tgl-sdca-s.patch @@ -0,0 +1,91 @@ +From 1dded196dfedd7693662d610bbe1ae4a0c3aeae7 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 4 Oct 2021 16:35:11 -0500 +Subject: ASoC: Intel: soc-acpi: add missing quirk for TGL SDCA single amp + +From: Pierre-Louis Bossart + +[ Upstream commit f2470679b070a77ea22f8b791fae7084c2340c7d ] + +We don't have a configuration for a single amp on link1. + +BugLink: https://github.com/thesofproject/linux/issues/3161 +Signed-off-by: Pierre-Louis Bossart +Reviewed-by: Rander Wang +Reviewed-by: Bard Liao +Link: https://lore.kernel.org/r/20211004213512.220836-5-pierre-louis.bossart@linux.intel.com +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + .../intel/common/soc-acpi-intel-tgl-match.c | 41 +++++++++++++++++++ + 1 file changed, 41 insertions(+) + +diff --git a/sound/soc/intel/common/soc-acpi-intel-tgl-match.c b/sound/soc/intel/common/soc-acpi-intel-tgl-match.c +index 785d5f5f8a9c9..11801b905ecc2 100644 +--- a/sound/soc/intel/common/soc-acpi-intel-tgl-match.c ++++ b/sound/soc/intel/common/soc-acpi-intel-tgl-match.c +@@ -156,6 +156,15 @@ static const struct snd_soc_acpi_adr_device rt711_sdca_0_adr[] = { + } + }; + ++static const struct snd_soc_acpi_adr_device rt1316_1_single_adr[] = { ++ { ++ .adr = 0x000131025D131601ull, ++ .num_endpoints = 1, ++ .endpoints = &single_endpoint, ++ .name_prefix = "rt1316-1" ++ } ++}; ++ + static const struct snd_soc_acpi_adr_device rt1316_1_group1_adr[] = { + { + .adr = 0x000131025D131601ull, /* unique ID is set for some reason */ +@@ -320,6 +329,25 @@ static const struct snd_soc_acpi_link_adr tgl_3_in_1_sdca[] = { + {} + }; + ++static const struct snd_soc_acpi_link_adr tgl_3_in_1_sdca_mono[] = { ++ { ++ .mask = BIT(0), ++ .num_adr = ARRAY_SIZE(rt711_sdca_0_adr), ++ .adr_d = rt711_sdca_0_adr, ++ }, ++ { ++ .mask = BIT(1), ++ .num_adr = ARRAY_SIZE(rt1316_1_single_adr), ++ .adr_d = rt1316_1_single_adr, ++ }, ++ { ++ .mask = BIT(3), ++ .num_adr = ARRAY_SIZE(rt714_3_adr), ++ .adr_d = rt714_3_adr, ++ }, ++ {} ++}; ++ + static const struct snd_soc_acpi_codecs tgl_max98373_amp = { + .num_codecs = 1, + .codecs = {"MX98373"} +@@ -412,6 +440,19 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_tgl_sdw_machines[] = { + .drv_name = "sof_sdw", + .sof_tplg_filename = "sof-tgl-rt711-rt1316-rt714.tplg", + }, ++ { ++ /* ++ * link_mask should be 0xB, but all links are enabled by BIOS. ++ * This entry will be selected if there is no rt1316 amplifier exposed ++ * on link2 since it will fail to match the above entry. ++ */ ++ ++ .link_mask = 0xF, /* 4 active links required */ ++ .links = tgl_3_in_1_sdca_mono, ++ .drv_name = "sof_sdw", ++ .sof_tplg_filename = "sof-tgl-rt711-l0-rt1316-l1-mono-rt714-l3.tplg", ++ }, ++ + { + .link_mask = 0x3, /* rt711 on link 0 and 1 rt1308 on link 1 */ + .links = tgl_hp, +-- +2.33.0 + diff --git a/queue-5.15/asoc-intel-sof_sdw-add-missing-quirk-for-dell-sku-0a.patch b/queue-5.15/asoc-intel-sof_sdw-add-missing-quirk-for-dell-sku-0a.patch new file mode 100644 index 00000000000..8b1e85b5697 --- /dev/null +++ b/queue-5.15/asoc-intel-sof_sdw-add-missing-quirk-for-dell-sku-0a.patch @@ -0,0 +1,47 @@ +From 54566e96fb7ced04fbb5078beed292c0be080469 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 4 Oct 2021 16:35:12 -0500 +Subject: ASoC: Intel: sof_sdw: add missing quirk for Dell SKU 0A45 + +From: Pierre-Louis Bossart + +[ Upstream commit 64ba6d2ce72ffde70dc5a1794917bf1573203716 ] + +This device is based on SDCA codecs but with a single amplifier +instead of two. + +BugLink: https://github.com/thesofproject/linux/issues/3161 +Signed-off-by: Pierre-Louis Bossart +Reviewed-by: Rander Wang +Reviewed-by: Bard Liao +Link: https://lore.kernel.org/r/20211004213512.220836-6-pierre-louis.bossart@linux.intel.com +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + sound/soc/intel/boards/sof_sdw.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/sound/soc/intel/boards/sof_sdw.c b/sound/soc/intel/boards/sof_sdw.c +index 6b06248a9327a..f10496206ceed 100644 +--- a/sound/soc/intel/boards/sof_sdw.c ++++ b/sound/soc/intel/boards/sof_sdw.c +@@ -213,6 +213,16 @@ static const struct dmi_system_id sof_sdw_quirk_table[] = { + SOF_RT715_DAI_ID_FIX | + SOF_SDW_FOUR_SPK), + }, ++ { ++ .callback = sof_sdw_quirk_cb, ++ .matches = { ++ DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"), ++ DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "0A45") ++ }, ++ .driver_data = (void *)(SOF_SDW_TGL_HDMI | ++ RT711_JD2 | ++ SOF_RT715_DAI_ID_FIX), ++ }, + /* AlderLake devices */ + { + .callback = sof_sdw_quirk_cb, +-- +2.33.0 + diff --git a/queue-5.15/asoc-mediatek-mt8195-add-missing-of_node_put.patch b/queue-5.15/asoc-mediatek-mt8195-add-missing-of_node_put.patch new file mode 100644 index 00000000000..e55e8b3f9ce --- /dev/null +++ b/queue-5.15/asoc-mediatek-mt8195-add-missing-of_node_put.patch @@ -0,0 +1,49 @@ +From 81c639da071e5b32169ff6db662344b290349ec6 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 11 Sep 2021 16:12:46 +0800 +Subject: ASoC: mediatek: mt8195: Add missing of_node_put() + +From: Bixuan Cui + +[ Upstream commit b2fc2c92d2fd34d93268f677e514936f50dd6b5c ] + +The platform_node is returned by of_parse_phandle() should have +of_node_put() before return. + +Reported-by: Hulk Robot +Signed-off-by: Bixuan Cui +Link: https://lore.kernel.org/r/20210911081246.33867-1-cuibixuan@huawei.com +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + sound/soc/mediatek/mt8195/mt8195-mt6359-rt1019-rt5682.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/sound/soc/mediatek/mt8195/mt8195-mt6359-rt1019-rt5682.c b/sound/soc/mediatek/mt8195/mt8195-mt6359-rt1019-rt5682.c +index de09f67c04502..a3fa8efc8f81c 100644 +--- a/sound/soc/mediatek/mt8195/mt8195-mt6359-rt1019-rt5682.c ++++ b/sound/soc/mediatek/mt8195/mt8195-mt6359-rt1019-rt5682.c +@@ -1040,8 +1040,10 @@ static int mt8195_mt6359_rt1019_rt5682_dev_probe(struct platform_device *pdev) + } + + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); +- if (!priv) ++ if (!priv) { ++ of_node_put(platform_node); + return -ENOMEM; ++ } + + snd_soc_card_set_drvdata(card, priv); + +@@ -1049,6 +1051,8 @@ static int mt8195_mt6359_rt1019_rt5682_dev_probe(struct platform_device *pdev) + if (ret) + dev_err(&pdev->dev, "%s snd_soc_register_card fail %d\n", + __func__, ret); ++ ++ of_node_put(platform_node); + return ret; + } + +-- +2.33.0 + diff --git a/queue-5.15/asoc-nau8824-add-dmi-quirk-mechanism-for-active-high.patch b/queue-5.15/asoc-nau8824-add-dmi-quirk-mechanism-for-active-high.patch new file mode 100644 index 00000000000..4f7deeb6ee1 --- /dev/null +++ b/queue-5.15/asoc-nau8824-add-dmi-quirk-mechanism-for-active-high.patch @@ -0,0 +1,98 @@ +From 698696e1095cebad0dc87e9d1a54149a068eb2bf Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 2 Oct 2021 23:14:57 +0200 +Subject: ASoC: nau8824: Add DMI quirk mechanism for active-high jack-detect + +From: Hans de Goede + +[ Upstream commit 92d3360108f1839ca40451bad20ff67dd24a1964 ] + +Add a quirk mechanism to allow specifying that active-high jack-detection +should be used on platforms where this info is not available in devicetree. + +And add an entry for the Cyberbook T116 tablet to the DMI table, so that +jack-detection will work properly on this tablet. + +Signed-off-by: Hans de Goede +Link: https://lore.kernel.org/r/20211002211459.110124-2-hdegoede@redhat.com +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + sound/soc/codecs/nau8824.c | 40 ++++++++++++++++++++++++++++++++++++++ + 1 file changed, 40 insertions(+) + +diff --git a/sound/soc/codecs/nau8824.c b/sound/soc/codecs/nau8824.c +index f946ef65a4c19..f7018f2dd21fd 100644 +--- a/sound/soc/codecs/nau8824.c ++++ b/sound/soc/codecs/nau8824.c +@@ -8,6 +8,7 @@ + + #include + #include ++#include + #include + #include + #include +@@ -27,6 +28,12 @@ + + #include "nau8824.h" + ++#define NAU8824_JD_ACTIVE_HIGH BIT(0) ++ ++static int nau8824_quirk; ++static int quirk_override = -1; ++module_param_named(quirk, quirk_override, uint, 0444); ++MODULE_PARM_DESC(quirk, "Board-specific quirk override"); + + static int nau8824_config_sysclk(struct nau8824 *nau8824, + int clk_id, unsigned int freq); +@@ -1845,6 +1852,34 @@ static int nau8824_read_device_properties(struct device *dev, + return 0; + } + ++/* Please keep this list alphabetically sorted */ ++static const struct dmi_system_id nau8824_quirk_table[] = { ++ { ++ /* Cyberbook T116 rugged tablet */ ++ .matches = { ++ DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "Default string"), ++ DMI_EXACT_MATCH(DMI_BOARD_NAME, "Cherry Trail CR"), ++ DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "20170531"), ++ }, ++ .driver_data = (void *)(NAU8824_JD_ACTIVE_HIGH), ++ }, ++ {} ++}; ++ ++static void nau8824_check_quirks(void) ++{ ++ const struct dmi_system_id *dmi_id; ++ ++ if (quirk_override != -1) { ++ nau8824_quirk = quirk_override; ++ return; ++ } ++ ++ dmi_id = dmi_first_match(nau8824_quirk_table); ++ if (dmi_id) ++ nau8824_quirk = (unsigned long)dmi_id->driver_data; ++} ++ + static int nau8824_i2c_probe(struct i2c_client *i2c, + const struct i2c_device_id *id) + { +@@ -1869,6 +1904,11 @@ static int nau8824_i2c_probe(struct i2c_client *i2c, + nau8824->irq = i2c->irq; + sema_init(&nau8824->jd_sem, 1); + ++ nau8824_check_quirks(); ++ ++ if (nau8824_quirk & NAU8824_JD_ACTIVE_HIGH) ++ nau8824->jkdet_polarity = 0; ++ + nau8824_print_device_properties(nau8824); + + ret = regmap_read(nau8824->regmap, NAU8824_REG_I2C_DEVICE_ID, &value); +-- +2.33.0 + diff --git a/queue-5.15/asoc-rt5651-use-irqf_no_autoen-when-requesting-the-i.patch b/queue-5.15/asoc-rt5651-use-irqf_no_autoen-when-requesting-the-i.patch new file mode 100644 index 00000000000..650a108ea38 --- /dev/null +++ b/queue-5.15/asoc-rt5651-use-irqf_no_autoen-when-requesting-the-i.patch @@ -0,0 +1,44 @@ +From e49538645434d36fe52ae56261998567942c6278 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 3 Oct 2021 15:22:55 +0200 +Subject: ASoC: rt5651: Use IRQF_NO_AUTOEN when requesting the IRQ + +From: Hans de Goede + +[ Upstream commit 6e037b72cf4ea6c28a131ea021d63ee4e7e6fa64 ] + +Use the new IRQF_NO_AUTOEN flag when requesting the IRQ, rather then +disabling it immediately after requesting it. + +This fixes a possible race where the IRQ might trigger between requesting +and disabling it; and this also leads to a small code cleanup. + +Signed-off-by: Hans de Goede +Link: https://lore.kernel.org/r/20211003132255.31743-2-hdegoede@redhat.com +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + sound/soc/codecs/rt5651.c | 7 ++----- + 1 file changed, 2 insertions(+), 5 deletions(-) + +diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c +index fc0c83b73f099..93820561b9f5d 100644 +--- a/sound/soc/codecs/rt5651.c ++++ b/sound/soc/codecs/rt5651.c +@@ -2261,11 +2261,8 @@ static int rt5651_i2c_probe(struct i2c_client *i2c, + + ret = devm_request_irq(&i2c->dev, rt5651->irq, rt5651_irq, + IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING +- | IRQF_ONESHOT, "rt5651", rt5651); +- if (ret == 0) { +- /* Gets re-enabled by rt5651_set_jack() */ +- disable_irq(rt5651->irq); +- } else { ++ | IRQF_ONESHOT | IRQF_NO_AUTOEN, "rt5651", rt5651); ++ if (ret) { + dev_warn(&i2c->dev, "Failed to reguest IRQ %d: %d\n", + rt5651->irq, ret); + rt5651->irq = -ENXIO; +-- +2.33.0 + diff --git a/queue-5.15/asoc-rt5682-fix-a-little-pop-while-playback.patch b/queue-5.15/asoc-rt5682-fix-a-little-pop-while-playback.patch new file mode 100644 index 00000000000..64ab0083dc3 --- /dev/null +++ b/queue-5.15/asoc-rt5682-fix-a-little-pop-while-playback.patch @@ -0,0 +1,177 @@ +From 436127f4fbab824714d34f1bdccae66df234f819 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 14 Oct 2021 17:40:54 +0800 +Subject: ASoC: rt5682: fix a little pop while playback + +From: Derek Fang + +[ Upstream commit 4b19e4a77cc6baa0f840e8bae62ab974667f6207 ] + +A little pop can be heard obviously from HP while playing a silent. +This patch fixes it by using two functions: +1. Enable HP 1bit output mode. +2. Change the charge pump switch size during playback on and off. + +Signed-off-by: Derek Fang +Link: https://lore.kernel.org/r/20211014094054.811-1-derek.fang@realtek.com +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + sound/soc/codecs/rt5682.c | 56 +++++++++++++++++++++++++++++++++------ + sound/soc/codecs/rt5682.h | 20 ++++++++++++++ + 2 files changed, 68 insertions(+), 8 deletions(-) + +diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c +index 4a64cab99c55b..d550c0705c28b 100644 +--- a/sound/soc/codecs/rt5682.c ++++ b/sound/soc/codecs/rt5682.c +@@ -46,6 +46,8 @@ static const struct reg_sequence patch_list[] = { + {RT5682_SAR_IL_CMD_1, 0x22b7}, + {RT5682_SAR_IL_CMD_3, 0x0365}, + {RT5682_SAR_IL_CMD_6, 0x0110}, ++ {RT5682_CHARGE_PUMP_1, 0x0210}, ++ {RT5682_HP_LOGIC_CTRL_2, 0x0007}, + }; + + void rt5682_apply_patch_list(struct rt5682_priv *rt5682, struct device *dev) +@@ -1515,21 +1517,29 @@ static int rt5682_hp_event(struct snd_soc_dapm_widget *w, + + switch (event) { + case SND_SOC_DAPM_PRE_PMU: +- snd_soc_component_write(component, +- RT5682_HP_LOGIC_CTRL_2, 0x0012); +- snd_soc_component_write(component, +- RT5682_HP_CTRL_2, 0x6000); ++ snd_soc_component_update_bits(component, RT5682_HP_CTRL_2, ++ RT5682_HP_C2_DAC_AMP_MUTE, 0); ++ snd_soc_component_update_bits(component, RT5682_HP_LOGIC_CTRL_2, ++ RT5682_HP_LC2_SIG_SOUR2_MASK, RT5682_HP_LC2_SIG_SOUR2_REG); + snd_soc_component_update_bits(component, + RT5682_DEPOP_1, 0x60, 0x60); + snd_soc_component_update_bits(component, + RT5682_DAC_ADC_DIG_VOL1, 0x00c0, 0x0080); ++ snd_soc_component_update_bits(component, RT5682_HP_CTRL_2, ++ RT5682_HP_C2_DAC_L_EN | RT5682_HP_C2_DAC_R_EN, ++ RT5682_HP_C2_DAC_L_EN | RT5682_HP_C2_DAC_R_EN); ++ usleep_range(5000, 10000); ++ snd_soc_component_update_bits(component, RT5682_CHARGE_PUMP_1, ++ RT5682_CP_SW_SIZE_MASK, RT5682_CP_SW_SIZE_L); + break; + + case SND_SOC_DAPM_POST_PMD: ++ snd_soc_component_update_bits(component, RT5682_HP_CTRL_2, ++ RT5682_HP_C2_DAC_L_EN | RT5682_HP_C2_DAC_R_EN, 0); ++ snd_soc_component_update_bits(component, RT5682_CHARGE_PUMP_1, ++ RT5682_CP_SW_SIZE_MASK, RT5682_CP_SW_SIZE_M); + snd_soc_component_update_bits(component, + RT5682_DEPOP_1, 0x60, 0x0); +- snd_soc_component_write(component, +- RT5682_HP_CTRL_2, 0x0000); + snd_soc_component_update_bits(component, + RT5682_DAC_ADC_DIG_VOL1, 0x00c0, 0x0000); + break; +@@ -1637,6 +1647,23 @@ static SOC_VALUE_ENUM_SINGLE_DECL(rt5682_adcdat_pin_enum, + static const struct snd_kcontrol_new rt5682_adcdat_pin_ctrl = + SOC_DAPM_ENUM("ADCDAT", rt5682_adcdat_pin_enum); + ++static const unsigned int rt5682_hpo_sig_out_values[] = { ++ 2, ++ 7, ++}; ++ ++static const char * const rt5682_hpo_sig_out_mode[] = { ++ "Legacy", ++ "OneBit", ++}; ++ ++static SOC_VALUE_ENUM_SINGLE_DECL(rt5682_hpo_sig_out_enum, ++ RT5682_HP_LOGIC_CTRL_2, 0, RT5682_HP_LC2_SIG_SOUR1_MASK, ++ rt5682_hpo_sig_out_mode, rt5682_hpo_sig_out_values); ++ ++static const struct snd_kcontrol_new rt5682_hpo_sig_demux = ++ SOC_DAPM_ENUM("HPO Signal Demux", rt5682_hpo_sig_out_enum); ++ + static const struct snd_soc_dapm_widget rt5682_dapm_widgets[] = { + SND_SOC_DAPM_SUPPLY("LDO2", RT5682_PWR_ANLG_3, RT5682_PWR_LDO2_BIT, + 0, NULL, 0), +@@ -1820,6 +1847,10 @@ static const struct snd_soc_dapm_widget rt5682_dapm_widgets[] = { + SND_SOC_DAPM_SWITCH("HPOR Playback", SND_SOC_NOPM, 0, 0, + &hpor_switch), + ++ SND_SOC_DAPM_OUT_DRV("HPO Legacy", SND_SOC_NOPM, 0, 0, NULL, 0), ++ SND_SOC_DAPM_OUT_DRV("HPO OneBit", SND_SOC_NOPM, 0, 0, NULL, 0), ++ SND_SOC_DAPM_DEMUX("HPO Signal Demux", SND_SOC_NOPM, 0, 0, &rt5682_hpo_sig_demux), ++ + /* CLK DET */ + SND_SOC_DAPM_SUPPLY("CLKDET SYS", RT5682_CLK_DET, + RT5682_SYS_CLK_DET_SFT, 0, NULL, 0), +@@ -1987,10 +2018,19 @@ static const struct snd_soc_dapm_route rt5682_dapm_routes[] = { + {"HP Amp", NULL, "Charge Pump"}, + {"HP Amp", NULL, "CLKDET SYS"}, + {"HP Amp", NULL, "Vref1"}, +- {"HPOL Playback", "Switch", "HP Amp"}, +- {"HPOR Playback", "Switch", "HP Amp"}, ++ ++ {"HPO Signal Demux", NULL, "HP Amp"}, ++ ++ {"HPO Legacy", "Legacy", "HPO Signal Demux"}, ++ {"HPO OneBit", "OneBit", "HPO Signal Demux"}, ++ ++ {"HPOL Playback", "Switch", "HPO Legacy"}, ++ {"HPOR Playback", "Switch", "HPO Legacy"}, ++ + {"HPOL", NULL, "HPOL Playback"}, + {"HPOR", NULL, "HPOR Playback"}, ++ {"HPOL", NULL, "HPO OneBit"}, ++ {"HPOR", NULL, "HPO OneBit"}, + }; + + static int rt5682_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, +diff --git a/sound/soc/codecs/rt5682.h b/sound/soc/codecs/rt5682.h +index b59221048ebf9..8e3244a62c160 100644 +--- a/sound/soc/codecs/rt5682.h ++++ b/sound/soc/codecs/rt5682.h +@@ -375,6 +375,14 @@ + #define RT5682_R_VOL_MASK (0x3f) + #define RT5682_R_VOL_SFT 0 + ++/* Headphone Amp Control 2 (0x0003) */ ++#define RT5682_HP_C2_DAC_AMP_MUTE_SFT 15 ++#define RT5682_HP_C2_DAC_AMP_MUTE (0x1 << 15) ++#define RT5682_HP_C2_DAC_L_EN_SFT 14 ++#define RT5682_HP_C2_DAC_L_EN (0x1 << 14) ++#define RT5682_HP_C2_DAC_R_EN_SFT 13 ++#define RT5682_HP_C2_DAC_R_EN (0x1 << 13) ++ + /*Headphone Amp L/R Analog Gain and Digital NG2 Gain Control (0x0005 0x0006)*/ + #define RT5682_G_HP (0xf << 8) + #define RT5682_G_HP_SFT 8 +@@ -1265,6 +1273,10 @@ + #define RT5682_HPA_CP_BIAS_6UA (0x3 << 2) + + /* Charge Pump Internal Register1 (0x0125) */ ++#define RT5682_CP_SW_SIZE_MASK (0x7 << 8) ++#define RT5682_CP_SW_SIZE_L (0x4 << 8) ++#define RT5682_CP_SW_SIZE_M (0x2 << 8) ++#define RT5682_CP_SW_SIZE_S (0x1 << 8) + #define RT5682_CP_CLK_HP_MASK (0x3 << 4) + #define RT5682_CP_CLK_HP_100KHZ (0x0 << 4) + #define RT5682_CP_CLK_HP_200KHZ (0x1 << 4) +@@ -1315,6 +1327,14 @@ + #define RT5682_DEB_STO_DAC_MASK (0x7 << 4) + #define RT5682_DEB_80_MS (0x0 << 4) + ++/* HP Behavior Logic Control 2 (0x01db) */ ++#define RT5682_HP_LC2_SIG_SOUR2_MASK (0x1 << 4) ++#define RT5682_HP_LC2_SIG_SOUR2_REG (0x1 << 4) ++#define RT5682_HP_LC2_SIG_SOUR2_DC_CAL (0x0 << 4) ++#define RT5682_HP_LC2_SIG_SOUR1_MASK (0x7) ++#define RT5682_HP_LC2_SIG_SOUR1_1BIT (0x7) ++#define RT5682_HP_LC2_SIG_SOUR1_LEGA (0x2) ++ + /* SAR ADC Inline Command Control 1 (0x0210) */ + #define RT5682_SAR_BUTT_DET_MASK (0x1 << 15) + #define RT5682_SAR_BUTT_DET_EN (0x1 << 15) +-- +2.33.0 + diff --git a/queue-5.15/asoc-sof-intel-hda-dai-fix-potential-locking-issue.patch b/queue-5.15/asoc-sof-intel-hda-dai-fix-potential-locking-issue.patch new file mode 100644 index 00000000000..471b769bae1 --- /dev/null +++ b/queue-5.15/asoc-sof-intel-hda-dai-fix-potential-locking-issue.patch @@ -0,0 +1,53 @@ +From cc73c2ba3635be6afb8be8f5dae4d1296f1cfcce Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 24 Sep 2021 14:24:17 -0500 +Subject: ASoC: SOF: Intel: hda-dai: fix potential locking issue + +From: Pierre-Louis Bossart + +[ Upstream commit a20f3b10de61add5e14b6ce4df982f4df2a4cbbc ] + +The initial hdac_stream code was adapted a third time with the same +locking issues. Move the spin_lock outside the loops and make sure the +fields are protected on read/write. + +Signed-off-by: Pierre-Louis Bossart +Acked-by: Mark Brown +Link: https://lore.kernel.org/r/20210924192417.169243-5-pierre-louis.bossart@linux.intel.com +Signed-off-by: Takashi Iwai +Signed-off-by: Sasha Levin +--- + sound/soc/sof/intel/hda-dai.c | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +diff --git a/sound/soc/sof/intel/hda-dai.c b/sound/soc/sof/intel/hda-dai.c +index c1f9f0f584647..6704dbcd101cd 100644 +--- a/sound/soc/sof/intel/hda-dai.c ++++ b/sound/soc/sof/intel/hda-dai.c +@@ -68,6 +68,7 @@ static struct hdac_ext_stream * + return NULL; + } + ++ spin_lock_irq(&bus->reg_lock); + list_for_each_entry(stream, &bus->stream_list, list) { + struct hdac_ext_stream *hstream = + stream_to_hdac_ext_stream(stream); +@@ -107,12 +108,12 @@ static struct hdac_ext_stream * + * is updated in snd_hdac_ext_stream_decouple(). + */ + if (!res->decoupled) +- snd_hdac_ext_stream_decouple(bus, res, true); +- spin_lock_irq(&bus->reg_lock); ++ snd_hdac_ext_stream_decouple_locked(bus, res, true); ++ + res->link_locked = 1; + res->link_substream = substream; +- spin_unlock_irq(&bus->reg_lock); + } ++ spin_unlock_irq(&bus->reg_lock); + + return res; + } +-- +2.33.0 + diff --git a/queue-5.15/blkcg-remove-extra-blkcg_bio_issue_init.patch b/queue-5.15/blkcg-remove-extra-blkcg_bio_issue_init.patch new file mode 100644 index 00000000000..25f7b00010f --- /dev/null +++ b/queue-5.15/blkcg-remove-extra-blkcg_bio_issue_init.patch @@ -0,0 +1,147 @@ +From ae18a75f57f0f46ae0c49206d5021eedc1635b11 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 12 Nov 2021 17:33:54 +0800 +Subject: blkcg: Remove extra blkcg_bio_issue_init + +From: Laibin Qiu + +[ Upstream commit b781d8db580c058ecd54ed7d5dde7f8270b25f5b ] + +KASAN reports a use-after-free report when doing block test: + +================================================================== +[10050.967049] BUG: KASAN: use-after-free in +submit_bio_checks+0x1539/0x1550 + +[10050.977638] Call Trace: +[10050.978190] dump_stack+0x9b/0xce +[10050.979674] print_address_description.constprop.6+0x3e/0x60 +[10050.983510] kasan_report.cold.9+0x22/0x3a +[10050.986089] submit_bio_checks+0x1539/0x1550 +[10050.989576] submit_bio_noacct+0x83/0xc80 +[10050.993714] submit_bio+0xa7/0x330 +[10050.994435] mpage_readahead+0x380/0x500 +[10050.998009] read_pages+0x1c1/0xbf0 +[10051.002057] page_cache_ra_unbounded+0x4c2/0x6f0 +[10051.007413] do_page_cache_ra+0xda/0x110 +[10051.008207] force_page_cache_ra+0x23d/0x3d0 +[10051.009087] page_cache_sync_ra+0xca/0x300 +[10051.009970] generic_file_buffered_read+0xbea/0x2130 +[10051.012685] generic_file_read_iter+0x315/0x490 +[10051.014472] blkdev_read_iter+0x113/0x1b0 +[10051.015300] aio_read+0x2ad/0x450 +[10051.023786] io_submit_one+0xc8e/0x1d60 +[10051.029855] __se_sys_io_submit+0x125/0x350 +[10051.033442] do_syscall_64+0x2d/0x40 +[10051.034156] entry_SYSCALL_64_after_hwframe+0x44/0xa9 + +[10051.048733] Allocated by task 18598: +[10051.049482] kasan_save_stack+0x19/0x40 +[10051.050263] __kasan_kmalloc.constprop.1+0xc1/0xd0 +[10051.051230] kmem_cache_alloc+0x146/0x440 +[10051.052060] mempool_alloc+0x125/0x2f0 +[10051.052818] bio_alloc_bioset+0x353/0x590 +[10051.053658] mpage_alloc+0x3b/0x240 +[10051.054382] do_mpage_readpage+0xddf/0x1ef0 +[10051.055250] mpage_readahead+0x264/0x500 +[10051.056060] read_pages+0x1c1/0xbf0 +[10051.056758] page_cache_ra_unbounded+0x4c2/0x6f0 +[10051.057702] do_page_cache_ra+0xda/0x110 +[10051.058511] force_page_cache_ra+0x23d/0x3d0 +[10051.059373] page_cache_sync_ra+0xca/0x300 +[10051.060198] generic_file_buffered_read+0xbea/0x2130 +[10051.061195] generic_file_read_iter+0x315/0x490 +[10051.062189] blkdev_read_iter+0x113/0x1b0 +[10051.063015] aio_read+0x2ad/0x450 +[10051.063686] io_submit_one+0xc8e/0x1d60 +[10051.064467] __se_sys_io_submit+0x125/0x350 +[10051.065318] do_syscall_64+0x2d/0x40 +[10051.066082] entry_SYSCALL_64_after_hwframe+0x44/0xa9 + +[10051.067455] Freed by task 13307: +[10051.068136] kasan_save_stack+0x19/0x40 +[10051.068931] kasan_set_track+0x1c/0x30 +[10051.069726] kasan_set_free_info+0x1b/0x30 +[10051.070621] __kasan_slab_free+0x111/0x160 +[10051.071480] kmem_cache_free+0x94/0x460 +[10051.072256] mempool_free+0xd6/0x320 +[10051.072985] bio_free+0xe0/0x130 +[10051.073630] bio_put+0xab/0xe0 +[10051.074252] bio_endio+0x3a6/0x5d0 +[10051.074984] blk_update_request+0x590/0x1370 +[10051.075870] scsi_end_request+0x7d/0x400 +[10051.076667] scsi_io_completion+0x1aa/0xe50 +[10051.077503] scsi_softirq_done+0x11b/0x240 +[10051.078344] blk_mq_complete_request+0xd4/0x120 +[10051.079275] scsi_mq_done+0xf0/0x200 +[10051.080036] virtscsi_vq_done+0xbc/0x150 +[10051.080850] vring_interrupt+0x179/0x390 +[10051.081650] __handle_irq_event_percpu+0xf7/0x490 +[10051.082626] handle_irq_event_percpu+0x7b/0x160 +[10051.083527] handle_irq_event+0xcc/0x170 +[10051.084297] handle_edge_irq+0x215/0xb20 +[10051.085122] asm_call_irq_on_stack+0xf/0x20 +[10051.085986] common_interrupt+0xae/0x120 +[10051.086830] asm_common_interrupt+0x1e/0x40 + +================================================================== + +Bio will be checked at beginning of submit_bio_noacct(). If bio needs +to be throttled, it will start the timer and stop submit bio directly. +Bio will submit in blk_throtl_dispatch_work_fn() when the timer expires. +But in the current process, if bio is throttled, it will still set bio +issue->value by blkcg_bio_issue_init(). This is redundant and may cause +the above use-after-free. + +CPU0 CPU1 +submit_bio +submit_bio_noacct + submit_bio_checks + blk_throtl_bio() + <=mod_timer(&sq->pending_timer + blk_throtl_dispatch_work_fn + submit_bio_noacct() <= bio have + throttle tag, will throw directly + and bio issue->value will be set + here + + bio_endio() + bio_put() + bio_free() <= free this bio + + blkcg_bio_issue_init(bio) + <= bio has been freed and + will lead to UAF + return BLK_QC_T_NONE + +Fix this by remove extra blkcg_bio_issue_init. + +Fixes: e439bedf6b24 (blkcg: consolidate bio_issue_init() to be a part of core) +Signed-off-by: Laibin Qiu +Link: https://lore.kernel.org/r/20211112093354.3581504-1-qiulaibin@huawei.com +Reviewed-by: Christoph Hellwig +Signed-off-by: Jens Axboe +Signed-off-by: Sasha Levin +--- + block/blk-core.c | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +diff --git a/block/blk-core.c b/block/blk-core.c +index 4d8f5fe915887..12aa8c1da6003 100644 +--- a/block/blk-core.c ++++ b/block/blk-core.c +@@ -887,10 +887,8 @@ static noinline_for_stack bool submit_bio_checks(struct bio *bio) + if (unlikely(!current->io_context)) + create_task_io_context(current, GFP_ATOMIC, q->node); + +- if (blk_throtl_bio(bio)) { +- blkcg_bio_issue_init(bio); ++ if (blk_throtl_bio(bio)) + return false; +- } + + blk_cgroup_bio_start(bio); + blkcg_bio_issue_init(bio); +-- +2.33.0 + diff --git a/queue-5.15/bnxt_en-reject-indirect-blk-offload-when-hw-tc-offlo.patch b/queue-5.15/bnxt_en-reject-indirect-blk-offload-when-hw-tc-offlo.patch new file mode 100644 index 00000000000..d8a9598e2c9 --- /dev/null +++ b/queue-5.15/bnxt_en-reject-indirect-blk-offload-when-hw-tc-offlo.patch @@ -0,0 +1,46 @@ +From 11009cbac440179c5b83a96f7e42655fdf056c2e Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 15 Nov 2021 02:38:01 -0500 +Subject: bnxt_en: reject indirect blk offload when hw-tc-offload is off + +From: Sriharsha Basavapatna + +[ Upstream commit b0757491a118ae5727cf9f1c3a11544397d46596 ] + +The driver does not check if hw-tc-offload is enabled for the device +before offloading a flow in the context of indirect block callback. +Fix this by checking NETIF_F_HW_TC in the features flag and rejecting +the offload request. This will avoid unnecessary dmesg error logs when +hw-tc-offload is disabled, such as these: + +bnxt_en 0000:19:00.1 eno2np1: dev(ifindex=294) not on same switch +bnxt_en 0000:19:00.1 eno2np1: Error: bnxt_tc_add_flow: cookie=0xffff8dace1c88000 error=-22 +bnxt_en 0000:19:00.0 eno1np0: dev(ifindex=294) not on same switch +bnxt_en 0000:19:00.0 eno1np0: Error: bnxt_tc_add_flow: cookie=0xffff8dace1c88000 error=-22 + +Reported-by: Marcelo Ricardo Leitner +Fixes: 627c89d00fb9 ("bnxt_en: flow_offload: offload tunnel decap rules via indirect callbacks") +Signed-off-by: Sriharsha Basavapatna +Signed-off-by: Michael Chan +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c +index e6a4a768b10b2..1471b6130a2b9 100644 +--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c ++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c +@@ -1868,7 +1868,7 @@ static int bnxt_tc_setup_indr_block_cb(enum tc_setup_type type, + struct flow_cls_offload *flower = type_data; + struct bnxt *bp = priv->bp; + +- if (flower->common.chain_index) ++ if (!tc_cls_can_offload_and_chain0(bp->dev, type_data)) + return -EOPNOTSUPP; + + switch (type) { +-- +2.33.0 + diff --git a/queue-5.15/bpf-fix-inner-map-state-pruning-regression.patch b/queue-5.15/bpf-fix-inner-map-state-pruning-regression.patch new file mode 100644 index 00000000000..af1b814bac4 --- /dev/null +++ b/queue-5.15/bpf-fix-inner-map-state-pruning-regression.patch @@ -0,0 +1,44 @@ +From 81f3bb8e3c8a1c7f54f8c5347ab729f765627107 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 10 Nov 2021 09:25:56 -0800 +Subject: bpf: Fix inner map state pruning regression. + +From: Alexei Starovoitov + +[ Upstream commit 34d11a440c6167133201b7374065b59f259730d7 ] + +Introduction of map_uid made two lookups from outer map to be distinct. +That distinction is only necessary when inner map has an embedded timer. +Otherwise it will make the verifier state pruning to be conservative +which will cause complex programs to hit 1M insn_processed limit. +Tighten map_uid logic to apply to inner maps with timers only. + +Fixes: 3e8ce29850f1 ("bpf: Prevent pointer mismatch in bpf_timer_init.") +Reported-by: Lorenz Bauer +Signed-off-by: Alexei Starovoitov +Signed-off-by: Daniel Borkmann +Tested-by: Lorenz Bauer +Link: https://lore.kernel.org/bpf/CACAyw99hVEJFoiBH_ZGyy=+oO-jyydoz6v1DeKPKs2HVsUH28w@mail.gmail.com +Link: https://lore.kernel.org/bpf/20211110172556.20754-1-alexei.starovoitov@gmail.com +Signed-off-by: Sasha Levin +--- + kernel/bpf/verifier.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c +index ddba80554fef3..cba37d83451eb 100644 +--- a/kernel/bpf/verifier.c ++++ b/kernel/bpf/verifier.c +@@ -1143,7 +1143,8 @@ static void mark_ptr_not_null_reg(struct bpf_reg_state *reg) + /* transfer reg's id which is unique for every map_lookup_elem + * as UID of the inner map. + */ +- reg->map_uid = reg->id; ++ if (map_value_has_timer(map->inner_map_meta)) ++ reg->map_uid = reg->id; + } else if (map->map_type == BPF_MAP_TYPE_XSKMAP) { + reg->type = PTR_TO_XDP_SOCK; + } else if (map->map_type == BPF_MAP_TYPE_SOCKMAP || +-- +2.33.0 + diff --git a/queue-5.15/bpf-fix-toctou-on-read-only-map-s-constant-scalar-tr.patch b/queue-5.15/bpf-fix-toctou-on-read-only-map-s-constant-scalar-tr.patch new file mode 100644 index 00000000000..2e62af9d763 --- /dev/null +++ b/queue-5.15/bpf-fix-toctou-on-read-only-map-s-constant-scalar-tr.patch @@ -0,0 +1,310 @@ +From 437670700720b0ddcbac6f614636db87246e11fb Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 9 Nov 2021 18:48:08 +0000 +Subject: bpf: Fix toctou on read-only map's constant scalar tracking + +From: Daniel Borkmann + +[ Upstream commit 353050be4c19e102178ccc05988101887c25ae53 ] + +Commit a23740ec43ba ("bpf: Track contents of read-only maps as scalars") is +checking whether maps are read-only both from BPF program side and user space +side, and then, given their content is constant, reading out their data via +map->ops->map_direct_value_addr() which is then subsequently used as known +scalar value for the register, that is, it is marked as __mark_reg_known() +with the read value at verification time. Before a23740ec43ba, the register +content was marked as an unknown scalar so the verifier could not make any +assumptions about the map content. + +The current implementation however is prone to a TOCTOU race, meaning, the +value read as known scalar for the register is not guaranteed to be exactly +the same at a later point when the program is executed, and as such, the +prior made assumptions of the verifier with regards to the program will be +invalid which can cause issues such as OOB access, etc. + +While the BPF_F_RDONLY_PROG map flag is always fixed and required to be +specified at map creation time, the map->frozen property is initially set to +false for the map given the map value needs to be populated, e.g. for global +data sections. Once complete, the loader "freezes" the map from user space +such that no subsequent updates/deletes are possible anymore. For the rest +of the lifetime of the map, this freeze one-time trigger cannot be undone +anymore after a successful BPF_MAP_FREEZE cmd return. Meaning, any new BPF_* +cmd calls which would update/delete map entries will be rejected with -EPERM +since map_get_sys_perms() removes the FMODE_CAN_WRITE permission. This also +means that pending update/delete map entries must still complete before this +guarantee is given. This corner case is not an issue for loaders since they +create and prepare such program private map in successive steps. + +However, a malicious user is able to trigger this TOCTOU race in two different +ways: i) via userfaultfd, and ii) via batched updates. For i) userfaultfd is +used to expand the competition interval, so that map_update_elem() can modify +the contents of the map after map_freeze() and bpf_prog_load() were executed. +This works, because userfaultfd halts the parallel thread which triggered a +map_update_elem() at the time where we copy key/value from the user buffer and +this already passed the FMODE_CAN_WRITE capability test given at that time the +map was not "frozen". Then, the main thread performs the map_freeze() and +bpf_prog_load(), and once that had completed successfully, the other thread +is woken up to complete the pending map_update_elem() which then changes the +map content. For ii) the idea of the batched update is similar, meaning, when +there are a large number of updates to be processed, it can increase the +competition interval between the two. It is therefore possible in practice to +modify the contents of the map after executing map_freeze() and bpf_prog_load(). + +One way to fix both i) and ii) at the same time is to expand the use of the +map's map->writecnt. The latter was introduced in fc9702273e2e ("bpf: Add mmap() +support for BPF_MAP_TYPE_ARRAY") and further refined in 1f6cb19be2e2 ("bpf: +Prevent re-mmap()'ing BPF map as writable for initially r/o mapping") with +the rationale to make a writable mmap()'ing of a map mutually exclusive with +read-only freezing. The counter indicates writable mmap() mappings and then +prevents/fails the freeze operation. Its semantics can be expanded beyond +just mmap() by generally indicating ongoing write phases. This would essentially +span any parallel regular and batched flavor of update/delete operation and +then also have map_freeze() fail with -EBUSY. For the check_mem_access() in +the verifier we expand upon the bpf_map_is_rdonly() check ensuring that all +last pending writes have completed via bpf_map_write_active() test. Once the +map->frozen is set and bpf_map_write_active() indicates a map->writecnt of 0 +only then we are really guaranteed to use the map's data as known constants. +For map->frozen being set and pending writes in process of still being completed +we fall back to marking that register as unknown scalar so we don't end up +making assumptions about it. With this, both TOCTOU reproducers from i) and +ii) are fixed. + +Note that the map->writecnt has been converted into a atomic64 in the fix in +order to avoid a double freeze_mutex mutex_{un,}lock() pair when updating +map->writecnt in the various map update/delete BPF_* cmd flavors. Spanning +the freeze_mutex over entire map update/delete operations in syscall side +would not be possible due to then causing everything to be serialized. +Similarly, something like synchronize_rcu() after setting map->frozen to wait +for update/deletes to complete is not possible either since it would also +have to span the user copy which can sleep. On the libbpf side, this won't +break d66562fba1ce ("libbpf: Add BPF object skeleton support") as the +anonymous mmap()-ed "map initialization image" is remapped as a BPF map-backed +mmap()-ed memory where for .rodata it's non-writable. + +Fixes: a23740ec43ba ("bpf: Track contents of read-only maps as scalars") +Reported-by: w1tcher.bupt@gmail.com +Signed-off-by: Daniel Borkmann +Acked-by: Andrii Nakryiko +Signed-off-by: Alexei Starovoitov +Signed-off-by: Sasha Levin +--- + include/linux/bpf.h | 3 ++- + kernel/bpf/syscall.c | 57 +++++++++++++++++++++++++++---------------- + kernel/bpf/verifier.c | 17 ++++++++++++- + 3 files changed, 54 insertions(+), 23 deletions(-) + +diff --git a/include/linux/bpf.h b/include/linux/bpf.h +index 3db6f6c95489e..bca11ac818c1f 100644 +--- a/include/linux/bpf.h ++++ b/include/linux/bpf.h +@@ -190,7 +190,7 @@ struct bpf_map { + atomic64_t usercnt; + struct work_struct work; + struct mutex freeze_mutex; +- u64 writecnt; /* writable mmap cnt; protected by freeze_mutex */ ++ atomic64_t writecnt; + }; + + static inline bool map_value_has_spin_lock(const struct bpf_map *map) +@@ -1387,6 +1387,7 @@ void bpf_map_put(struct bpf_map *map); + void *bpf_map_area_alloc(u64 size, int numa_node); + void *bpf_map_area_mmapable_alloc(u64 size, int numa_node); + void bpf_map_area_free(void *base); ++bool bpf_map_write_active(const struct bpf_map *map); + void bpf_map_init_from_attr(struct bpf_map *map, union bpf_attr *attr); + int generic_map_lookup_batch(struct bpf_map *map, + const union bpf_attr *attr, +diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c +index 1cad6979a0d0f..ecd51a8a8680c 100644 +--- a/kernel/bpf/syscall.c ++++ b/kernel/bpf/syscall.c +@@ -132,6 +132,21 @@ static struct bpf_map *find_and_alloc_map(union bpf_attr *attr) + return map; + } + ++static void bpf_map_write_active_inc(struct bpf_map *map) ++{ ++ atomic64_inc(&map->writecnt); ++} ++ ++static void bpf_map_write_active_dec(struct bpf_map *map) ++{ ++ atomic64_dec(&map->writecnt); ++} ++ ++bool bpf_map_write_active(const struct bpf_map *map) ++{ ++ return atomic64_read(&map->writecnt) != 0; ++} ++ + static u32 bpf_map_value_size(const struct bpf_map *map) + { + if (map->map_type == BPF_MAP_TYPE_PERCPU_HASH || +@@ -596,11 +611,8 @@ static void bpf_map_mmap_open(struct vm_area_struct *vma) + { + struct bpf_map *map = vma->vm_file->private_data; + +- if (vma->vm_flags & VM_MAYWRITE) { +- mutex_lock(&map->freeze_mutex); +- map->writecnt++; +- mutex_unlock(&map->freeze_mutex); +- } ++ if (vma->vm_flags & VM_MAYWRITE) ++ bpf_map_write_active_inc(map); + } + + /* called for all unmapped memory region (including initial) */ +@@ -608,11 +620,8 @@ static void bpf_map_mmap_close(struct vm_area_struct *vma) + { + struct bpf_map *map = vma->vm_file->private_data; + +- if (vma->vm_flags & VM_MAYWRITE) { +- mutex_lock(&map->freeze_mutex); +- map->writecnt--; +- mutex_unlock(&map->freeze_mutex); +- } ++ if (vma->vm_flags & VM_MAYWRITE) ++ bpf_map_write_active_dec(map); + } + + static const struct vm_operations_struct bpf_map_default_vmops = { +@@ -663,7 +672,7 @@ static int bpf_map_mmap(struct file *filp, struct vm_area_struct *vma) + goto out; + + if (vma->vm_flags & VM_MAYWRITE) +- map->writecnt++; ++ bpf_map_write_active_inc(map); + out: + mutex_unlock(&map->freeze_mutex); + return err; +@@ -1122,6 +1131,7 @@ static int map_update_elem(union bpf_attr *attr, bpfptr_t uattr) + map = __bpf_map_get(f); + if (IS_ERR(map)) + return PTR_ERR(map); ++ bpf_map_write_active_inc(map); + if (!(map_get_sys_perms(map, f) & FMODE_CAN_WRITE)) { + err = -EPERM; + goto err_put; +@@ -1157,6 +1167,7 @@ free_value: + free_key: + kvfree(key); + err_put: ++ bpf_map_write_active_dec(map); + fdput(f); + return err; + } +@@ -1179,6 +1190,7 @@ static int map_delete_elem(union bpf_attr *attr) + map = __bpf_map_get(f); + if (IS_ERR(map)) + return PTR_ERR(map); ++ bpf_map_write_active_inc(map); + if (!(map_get_sys_perms(map, f) & FMODE_CAN_WRITE)) { + err = -EPERM; + goto err_put; +@@ -1209,6 +1221,7 @@ static int map_delete_elem(union bpf_attr *attr) + out: + kvfree(key); + err_put: ++ bpf_map_write_active_dec(map); + fdput(f); + return err; + } +@@ -1516,6 +1529,7 @@ static int map_lookup_and_delete_elem(union bpf_attr *attr) + map = __bpf_map_get(f); + if (IS_ERR(map)) + return PTR_ERR(map); ++ bpf_map_write_active_inc(map); + if (!(map_get_sys_perms(map, f) & FMODE_CAN_READ) || + !(map_get_sys_perms(map, f) & FMODE_CAN_WRITE)) { + err = -EPERM; +@@ -1580,6 +1594,7 @@ free_value: + free_key: + kvfree(key); + err_put: ++ bpf_map_write_active_dec(map); + fdput(f); + return err; + } +@@ -1607,8 +1622,7 @@ static int map_freeze(const union bpf_attr *attr) + } + + mutex_lock(&map->freeze_mutex); +- +- if (map->writecnt) { ++ if (bpf_map_write_active(map)) { + err = -EBUSY; + goto err_put; + } +@@ -4143,6 +4157,9 @@ static int bpf_map_do_batch(const union bpf_attr *attr, + union bpf_attr __user *uattr, + int cmd) + { ++ bool has_read = cmd == BPF_MAP_LOOKUP_BATCH || ++ cmd == BPF_MAP_LOOKUP_AND_DELETE_BATCH; ++ bool has_write = cmd != BPF_MAP_LOOKUP_BATCH; + struct bpf_map *map; + int err, ufd; + struct fd f; +@@ -4155,16 +4172,13 @@ static int bpf_map_do_batch(const union bpf_attr *attr, + map = __bpf_map_get(f); + if (IS_ERR(map)) + return PTR_ERR(map); +- +- if ((cmd == BPF_MAP_LOOKUP_BATCH || +- cmd == BPF_MAP_LOOKUP_AND_DELETE_BATCH) && +- !(map_get_sys_perms(map, f) & FMODE_CAN_READ)) { ++ if (has_write) ++ bpf_map_write_active_inc(map); ++ if (has_read && !(map_get_sys_perms(map, f) & FMODE_CAN_READ)) { + err = -EPERM; + goto err_put; + } +- +- if (cmd != BPF_MAP_LOOKUP_BATCH && +- !(map_get_sys_perms(map, f) & FMODE_CAN_WRITE)) { ++ if (has_write && !(map_get_sys_perms(map, f) & FMODE_CAN_WRITE)) { + err = -EPERM; + goto err_put; + } +@@ -4177,8 +4191,9 @@ static int bpf_map_do_batch(const union bpf_attr *attr, + BPF_DO_BATCH(map->ops->map_update_batch); + else + BPF_DO_BATCH(map->ops->map_delete_batch); +- + err_put: ++ if (has_write) ++ bpf_map_write_active_dec(map); + fdput(f); + return err; + } +diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c +index cba37d83451eb..2105b57c9c23a 100644 +--- a/kernel/bpf/verifier.c ++++ b/kernel/bpf/verifier.c +@@ -3885,7 +3885,22 @@ static void coerce_reg_to_size(struct bpf_reg_state *reg, int size) + + static bool bpf_map_is_rdonly(const struct bpf_map *map) + { +- return (map->map_flags & BPF_F_RDONLY_PROG) && map->frozen; ++ /* A map is considered read-only if the following condition are true: ++ * ++ * 1) BPF program side cannot change any of the map content. The ++ * BPF_F_RDONLY_PROG flag is throughout the lifetime of a map ++ * and was set at map creation time. ++ * 2) The map value(s) have been initialized from user space by a ++ * loader and then "frozen", such that no new map update/delete ++ * operations from syscall side are possible for the rest of ++ * the map's lifetime from that point onwards. ++ * 3) Any parallel/pending map update/delete operations from syscall ++ * side have been completed. Only after that point, it's safe to ++ * assume that map value(s) are immutable. ++ */ ++ return (map->map_flags & BPF_F_RDONLY_PROG) && ++ READ_ONCE(map->frozen) && ++ !bpf_map_write_active(map); + } + + static int bpf_map_direct_read(struct bpf_map *map, int off, int size, u64 *val) +-- +2.33.0 + diff --git a/queue-5.15/btrfs-make-1-bit-bit-fields-of-scrub_page-unsigned-i.patch b/queue-5.15/btrfs-make-1-bit-bit-fields-of-scrub_page-unsigned-i.patch new file mode 100644 index 00000000000..4e52168033b --- /dev/null +++ b/queue-5.15/btrfs-make-1-bit-bit-fields-of-scrub_page-unsigned-i.patch @@ -0,0 +1,42 @@ +From 68ce4cd1791950beb298dbb666bb3f10cbc03f95 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 10 Nov 2021 19:20:08 +0000 +Subject: btrfs: make 1-bit bit-fields of scrub_page unsigned int + +From: Colin Ian King + +[ Upstream commit d08e38b62327961295be1c63b562cd46ec97cd07 ] + +The bitfields have_csum and io_error are currently signed which is not +recommended as the representation is an implementation defined +behaviour. Fix this by making the bit-fields unsigned ints. + +Fixes: 2c36395430b0 ("btrfs: scrub: remove the anonymous structure from scrub_page") +Reviewed-by: Josef Bacik +Reviewed-by: Qu Wenruo +Signed-off-by: Colin Ian King +Reviewed-by: David Sterba +Signed-off-by: David Sterba +Signed-off-by: Sasha Levin +--- + fs/btrfs/scrub.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c +index 088641ba7a8e6..62f4bafbe54bb 100644 +--- a/fs/btrfs/scrub.c ++++ b/fs/btrfs/scrub.c +@@ -73,8 +73,8 @@ struct scrub_page { + u64 physical_for_dev_replace; + atomic_t refs; + u8 mirror_num; +- int have_csum:1; +- int io_error:1; ++ unsigned int have_csum:1; ++ unsigned int io_error:1; + u8 csum[BTRFS_CSUM_SIZE]; + + struct scrub_recover *recover; +-- +2.33.0 + diff --git a/queue-5.15/bus-ti-sysc-add-quirk-handling-for-reinit-on-context.patch b/queue-5.15/bus-ti-sysc-add-quirk-handling-for-reinit-on-context.patch new file mode 100644 index 00000000000..737db882b88 --- /dev/null +++ b/queue-5.15/bus-ti-sysc-add-quirk-handling-for-reinit-on-context.patch @@ -0,0 +1,229 @@ +From 96261295f7d04c4588d592860da1041e7fbf52d5 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 21 Sep 2021 12:42:25 +0300 +Subject: bus: ti-sysc: Add quirk handling for reinit on context lost + +From: Tony Lindgren + +[ Upstream commit 9d881361206ebcf6285c2ec2ef275aff80875347 ] + +Some interconnect target modules such as otg and gpmc on am335x need a +re-init after resume. As we also have PM runtime cases where the context +may be lost, let's handle these all with cpu_pm. + +For the am335x resume path, we already have cpu_pm_resume() call +cpu_pm_cluster_exit(). + +Signed-off-by: Tony Lindgren +Signed-off-by: Sasha Levin +--- + drivers/bus/ti-sysc.c | 108 ++++++++++++++++++++++++-- + include/linux/platform_data/ti-sysc.h | 1 + + 2 files changed, 103 insertions(+), 6 deletions(-) + +diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c +index f47c7e20cc271..7c645754a82b1 100644 +--- a/drivers/bus/ti-sysc.c ++++ b/drivers/bus/ti-sysc.c +@@ -6,6 +6,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -52,11 +53,18 @@ struct sysc_address { + struct list_head node; + }; + ++struct sysc_module { ++ struct sysc *ddata; ++ struct list_head node; ++}; ++ + struct sysc_soc_info { + unsigned long general_purpose:1; + enum sysc_soc soc; +- struct mutex list_lock; /* disabled modules list lock */ ++ struct mutex list_lock; /* disabled and restored modules list lock */ + struct list_head disabled_modules; ++ struct list_head restored_modules; ++ struct notifier_block nb; + }; + + enum sysc_clocks { +@@ -2442,6 +2450,79 @@ static struct dev_pm_domain sysc_child_pm_domain = { + } + }; + ++/* Caller needs to take list_lock if ever used outside of cpu_pm */ ++static void sysc_reinit_modules(struct sysc_soc_info *soc) ++{ ++ struct sysc_module *module; ++ struct list_head *pos; ++ struct sysc *ddata; ++ int error = 0; ++ ++ list_for_each(pos, &sysc_soc->restored_modules) { ++ module = list_entry(pos, struct sysc_module, node); ++ ddata = module->ddata; ++ error = sysc_reinit_module(ddata, ddata->enabled); ++ } ++} ++ ++/** ++ * sysc_context_notifier - optionally reset and restore module after idle ++ * @nb: notifier block ++ * @cmd: unused ++ * @v: unused ++ * ++ * Some interconnect target modules need to be restored, or reset and restored ++ * on CPU_PM CPU_PM_CLUSTER_EXIT notifier. This is needed at least for am335x ++ * OTG and GPMC target modules even if the modules are unused. ++ */ ++static int sysc_context_notifier(struct notifier_block *nb, unsigned long cmd, ++ void *v) ++{ ++ struct sysc_soc_info *soc; ++ ++ soc = container_of(nb, struct sysc_soc_info, nb); ++ ++ switch (cmd) { ++ case CPU_CLUSTER_PM_ENTER: ++ break; ++ case CPU_CLUSTER_PM_ENTER_FAILED: /* No need to restore context */ ++ break; ++ case CPU_CLUSTER_PM_EXIT: ++ sysc_reinit_modules(soc); ++ break; ++ } ++ ++ return NOTIFY_OK; ++} ++ ++/** ++ * sysc_add_restored - optionally add reset and restore quirk hanlling ++ * @ddata: device data ++ */ ++static void sysc_add_restored(struct sysc *ddata) ++{ ++ struct sysc_module *restored_module; ++ ++ restored_module = kzalloc(sizeof(*restored_module), GFP_KERNEL); ++ if (!restored_module) ++ return; ++ ++ restored_module->ddata = ddata; ++ ++ mutex_lock(&sysc_soc->list_lock); ++ ++ list_add(&restored_module->node, &sysc_soc->restored_modules); ++ ++ if (sysc_soc->nb.notifier_call) ++ goto out_unlock; ++ ++ sysc_soc->nb.notifier_call = sysc_context_notifier; ++ cpu_pm_register_notifier(&sysc_soc->nb); ++ ++out_unlock: ++ mutex_unlock(&sysc_soc->list_lock); ++} ++ + /** + * sysc_legacy_idle_quirk - handle children in omap_device compatible way + * @ddata: device driver data +@@ -2941,12 +3022,14 @@ static int sysc_add_disabled(unsigned long base) + } + + /* +- * One time init to detect the booted SoC and disable unavailable features. ++ * One time init to detect the booted SoC, disable unavailable features ++ * and initialize list for optional cpu_pm notifier. ++ * + * Note that we initialize static data shared across all ti-sysc instances + * so ddata is only used for SoC type. This can be called from module_init + * once we no longer need to rely on platform data. + */ +-static int sysc_init_soc(struct sysc *ddata) ++static int sysc_init_static_data(struct sysc *ddata) + { + const struct soc_device_attribute *match; + struct ti_sysc_platform_data *pdata; +@@ -2962,6 +3045,7 @@ static int sysc_init_soc(struct sysc *ddata) + + mutex_init(&sysc_soc->list_lock); + INIT_LIST_HEAD(&sysc_soc->disabled_modules); ++ INIT_LIST_HEAD(&sysc_soc->restored_modules); + sysc_soc->general_purpose = true; + + pdata = dev_get_platdata(ddata->dev); +@@ -3026,15 +3110,24 @@ static int sysc_init_soc(struct sysc *ddata) + return 0; + } + +-static void sysc_cleanup_soc(void) ++static void sysc_cleanup_static_data(void) + { ++ struct sysc_module *restored_module; + struct sysc_address *disabled_module; + struct list_head *pos, *tmp; + + if (!sysc_soc) + return; + ++ if (sysc_soc->nb.notifier_call) ++ cpu_pm_unregister_notifier(&sysc_soc->nb); ++ + mutex_lock(&sysc_soc->list_lock); ++ list_for_each_safe(pos, tmp, &sysc_soc->restored_modules) { ++ restored_module = list_entry(pos, struct sysc_module, node); ++ list_del(pos); ++ kfree(restored_module); ++ } + list_for_each_safe(pos, tmp, &sysc_soc->disabled_modules) { + disabled_module = list_entry(pos, struct sysc_address, node); + list_del(pos); +@@ -3102,7 +3195,7 @@ static int sysc_probe(struct platform_device *pdev) + ddata->dev = &pdev->dev; + platform_set_drvdata(pdev, ddata); + +- error = sysc_init_soc(ddata); ++ error = sysc_init_static_data(ddata); + if (error) + return error; + +@@ -3200,6 +3293,9 @@ static int sysc_probe(struct platform_device *pdev) + pm_runtime_put(&pdev->dev); + } + ++ if (ddata->cfg.quirks & SYSC_QUIRK_REINIT_ON_CTX_LOST) ++ sysc_add_restored(ddata); ++ + return 0; + + err: +@@ -3281,7 +3377,7 @@ static void __exit sysc_exit(void) + { + bus_unregister_notifier(&platform_bus_type, &sysc_nb); + platform_driver_unregister(&sysc_driver); +- sysc_cleanup_soc(); ++ sysc_cleanup_static_data(); + } + module_exit(sysc_exit); + +diff --git a/include/linux/platform_data/ti-sysc.h b/include/linux/platform_data/ti-sysc.h +index 9837fb011f2fb..989aa30c598dc 100644 +--- a/include/linux/platform_data/ti-sysc.h ++++ b/include/linux/platform_data/ti-sysc.h +@@ -50,6 +50,7 @@ struct sysc_regbits { + s8 emufree_shift; + }; + ++#define SYSC_QUIRK_REINIT_ON_CTX_LOST BIT(28) + #define SYSC_QUIRK_REINIT_ON_RESUME BIT(27) + #define SYSC_QUIRK_GPMC_DEBUG BIT(26) + #define SYSC_MODULE_QUIRK_ENA_RESETDONE BIT(25) +-- +2.33.0 + diff --git a/queue-5.15/bus-ti-sysc-use-context-lost-quirk-for-otg.patch b/queue-5.15/bus-ti-sysc-use-context-lost-quirk-for-otg.patch new file mode 100644 index 00000000000..152d160e8e8 --- /dev/null +++ b/queue-5.15/bus-ti-sysc-use-context-lost-quirk-for-otg.patch @@ -0,0 +1,35 @@ +From 2a44b1e4cd4138e1a538c89f7c5e1c29931891e0 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 21 Sep 2021 12:42:25 +0300 +Subject: bus: ti-sysc: Use context lost quirk for otg + +From: Tony Lindgren + +[ Upstream commit 9067839ff45a528bcb015cc2f24f656126b91e3f ] + +Let's use SYSC_QUIRK_REINIT_ON_CTX_LOST quirk for am335x otg instead of +SYSC_QUIRK_REINIT_ON_RESUME quirk as we can now handle the context loss +in a more generic way. + +Signed-off-by: Tony Lindgren +Signed-off-by: Sasha Levin +--- + drivers/bus/ti-sysc.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c +index 7c645754a82b1..bb377bb13564a 100644 +--- a/drivers/bus/ti-sysc.c ++++ b/drivers/bus/ti-sysc.c +@@ -1567,7 +1567,7 @@ static const struct sysc_revision_quirk sysc_revision_quirks[] = { + 0xffffffff, SYSC_QUIRK_SWSUP_SIDLE | SYSC_QUIRK_SWSUP_MSTANDBY), + SYSC_QUIRK("usb_otg_hs", 0, 0, 0x10, -ENODEV, 0x4ea2080d, 0xffffffff, + SYSC_QUIRK_SWSUP_SIDLE | SYSC_QUIRK_SWSUP_MSTANDBY | +- SYSC_QUIRK_REINIT_ON_RESUME), ++ SYSC_QUIRK_REINIT_ON_CTX_LOST), + SYSC_QUIRK("wdt", 0, 0, 0x10, 0x14, 0x502a0500, 0xfffff0f0, + SYSC_MODULE_QUIRK_WDT), + /* PRUSS on am3, am4 and am5 */ +-- +2.33.0 + diff --git a/queue-5.15/clk-ast2600-fix-soc-revision-for-ahb.patch b/queue-5.15/clk-ast2600-fix-soc-revision-for-ahb.patch new file mode 100644 index 00000000000..12ccbc05dbc --- /dev/null +++ b/queue-5.15/clk-ast2600-fix-soc-revision-for-ahb.patch @@ -0,0 +1,80 @@ +From cfe94e191993396e31a6578dc07b914a266b4d89 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 23 Sep 2021 09:24:49 +0930 +Subject: clk/ast2600: Fix soc revision for AHB + +From: Joel Stanley + +[ Upstream commit f45c5b1c27293f834682e89003f88b3512329ab4 ] + +Move the soc revision parsing to the initial probe, saving the driver +from parsing the register multiple times. + +Use this variable to select the correct divisor table for the AHB clock. +Before this fix the A2 would have used the A0 table. + +Fixes: 2d491066ccd4 ("clk: ast2600: Fix AHB clock divider for A1") +Signed-off-by: Joel Stanley +Link: https://lore.kernel.org/r/20210922235449.213631-1-joel@jms.id.au +Reviewed-by: Andrew Jeffery +Signed-off-by: Stephen Boyd +Signed-off-by: Sasha Levin +--- + drivers/clk/clk-ast2600.c | 12 +++++++----- + 1 file changed, 7 insertions(+), 5 deletions(-) + +diff --git a/drivers/clk/clk-ast2600.c b/drivers/clk/clk-ast2600.c +index bc3be5f3eae15..24dab2312bc6f 100644 +--- a/drivers/clk/clk-ast2600.c ++++ b/drivers/clk/clk-ast2600.c +@@ -51,6 +51,8 @@ static DEFINE_SPINLOCK(aspeed_g6_clk_lock); + static struct clk_hw_onecell_data *aspeed_g6_clk_data; + + static void __iomem *scu_g6_base; ++/* AST2600 revision: A0, A1, A2, etc */ ++static u8 soc_rev; + + /* + * Clocks marked with CLK_IS_CRITICAL: +@@ -191,9 +193,8 @@ static struct clk_hw *ast2600_calc_pll(const char *name, u32 val) + static struct clk_hw *ast2600_calc_apll(const char *name, u32 val) + { + unsigned int mult, div; +- u32 chip_id = readl(scu_g6_base + ASPEED_G6_SILICON_REV); + +- if (((chip_id & CHIP_REVISION_ID) >> 16) >= 2) { ++ if (soc_rev >= 2) { + if (val & BIT(24)) { + /* Pass through mode */ + mult = div = 1; +@@ -707,7 +708,7 @@ static const u32 ast2600_a1_axi_ahb200_tbl[] = { + static void __init aspeed_g6_cc(struct regmap *map) + { + struct clk_hw *hw; +- u32 val, div, divbits, chip_id, axi_div, ahb_div; ++ u32 val, div, divbits, axi_div, ahb_div; + + clk_hw_register_fixed_rate(NULL, "clkin", NULL, 0, 25000000); + +@@ -738,8 +739,7 @@ static void __init aspeed_g6_cc(struct regmap *map) + axi_div = 2; + + divbits = (val >> 11) & 0x3; +- regmap_read(map, ASPEED_G6_SILICON_REV, &chip_id); +- if (chip_id & BIT(16)) { ++ if (soc_rev >= 1) { + if (!divbits) { + ahb_div = ast2600_a1_axi_ahb200_tbl[(val >> 8) & 0x3]; + if (val & BIT(16)) +@@ -784,6 +784,8 @@ static void __init aspeed_g6_cc_init(struct device_node *np) + if (!scu_g6_base) + return; + ++ soc_rev = (readl(scu_g6_base + ASPEED_G6_SILICON_REV) & CHIP_REVISION_ID) >> 16; ++ + aspeed_g6_clk_data = kzalloc(struct_size(aspeed_g6_clk_data, hws, + ASPEED_G6_NUM_CLKS), GFP_KERNEL); + if (!aspeed_g6_clk_data) +-- +2.33.0 + diff --git a/queue-5.15/clk-at91-sama7g5-remove-prescaler-part-of-master-clo.patch b/queue-5.15/clk-at91-sama7g5-remove-prescaler-part-of-master-clo.patch new file mode 100644 index 00000000000..a685eb5e9f0 --- /dev/null +++ b/queue-5.15/clk-at91-sama7g5-remove-prescaler-part-of-master-clo.patch @@ -0,0 +1,54 @@ +From adff3fa030639595a0bdece633c0124a2058e338 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 11 Oct 2021 14:27:17 +0300 +Subject: clk: at91: sama7g5: remove prescaler part of master clock + +From: Claudiu Beznea + +[ Upstream commit facb87ad75603813bc3b1314f5a87377f020fcb8 ] + +On SAMA7G5 the prescaler part of master clock has been implemented as a +changeable one. Everytime the prescaler is changed the PMC_SR.MCKRDY bit +must be polled. Value 1 for PMC_SR.MCKRDY means the prescaler update is +done. Driver polls for this bit until it becomes 1. On SAMA7G5 it has +been discovered that in some conditions the PMC_SR.MCKRDY is not rising +but the rate it provides it's stable. The workaround is to add a timeout +when polling for PMC_SR.MCKRDY. At the moment, for SAMA7G5, the prescaler +will be removed from Linux clock tree as all the frequencies for CPU could +be obtained from PLL and also there will be less overhead when changing +frequency via DVFS. + +Signed-off-by: Claudiu Beznea +Link: https://lore.kernel.org/r/20211011112719.3951784-14-claudiu.beznea@microchip.com +Acked-by: Nicolas Ferre +Signed-off-by: Stephen Boyd +Signed-off-by: Sasha Levin +--- + drivers/clk/at91/sama7g5.c | 11 +---------- + 1 file changed, 1 insertion(+), 10 deletions(-) + +diff --git a/drivers/clk/at91/sama7g5.c b/drivers/clk/at91/sama7g5.c +index cf8c079aa086a..019e712f90d6f 100644 +--- a/drivers/clk/at91/sama7g5.c ++++ b/drivers/clk/at91/sama7g5.c +@@ -982,16 +982,7 @@ static void __init sama7g5_pmc_setup(struct device_node *np) + } + + parent_names[0] = "cpupll_divpmcck"; +- hw = at91_clk_register_master_pres(regmap, "cpuck", 1, parent_names, +- &mck0_layout, &mck0_characteristics, +- &pmc_mck0_lock, +- CLK_SET_RATE_PARENT, 0); +- if (IS_ERR(hw)) +- goto err_free; +- +- sama7g5_pmc->chws[PMC_CPU] = hw; +- +- hw = at91_clk_register_master_div(regmap, "mck0", "cpuck", ++ hw = at91_clk_register_master_div(regmap, "mck0", "cpupll_divpmcck", + &mck0_layout, &mck0_characteristics, + &pmc_mck0_lock, 0); + if (IS_ERR(hw)) +-- +2.33.0 + diff --git a/queue-5.15/clk-imx-imx6ul-move-csi_sel-mux-to-correct-base-regi.patch b/queue-5.15/clk-imx-imx6ul-move-csi_sel-mux-to-correct-base-regi.patch new file mode 100644 index 00000000000..8c30e88606a --- /dev/null +++ b/queue-5.15/clk-imx-imx6ul-move-csi_sel-mux-to-correct-base-regi.patch @@ -0,0 +1,51 @@ +From d4e07d27513b5b4cfc7fc6f91ca0257c00a1a6e1 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 27 Sep 2021 09:28:56 +0200 +Subject: clk: imx: imx6ul: Move csi_sel mux to correct base register + +From: Stefan Riedmueller + +[ Upstream commit 2f9d61869640f732599ec36b984c2b5c46067519 ] + +The csi_sel mux register is located in the CCM register base and not the +CCM_ANALOG register base. So move it to the correct position in code. + +Otherwise changing the parent of the csi clock can lead to a complete +system failure due to the CCM_ANALOG_PLL_SYS_TOG register being falsely +modified. + +Also remove the SET_RATE_PARENT flag since one possible supply for the +csi_sel mux is the system PLL which we don't want to modify. + +Signed-off-by: Stefan Riedmueller +Reviewed-by: Abel Vesa +Link: https://lore.kernel.org/r/20210927072857.3940880-1-s.riedmueller@phytec.de +Signed-off-by: Abel Vesa +Signed-off-by: Sasha Levin +--- + drivers/clk/imx/clk-imx6ul.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/clk/imx/clk-imx6ul.c b/drivers/clk/imx/clk-imx6ul.c +index 5dbb6a9377324..206e4c43f68f8 100644 +--- a/drivers/clk/imx/clk-imx6ul.c ++++ b/drivers/clk/imx/clk-imx6ul.c +@@ -161,7 +161,6 @@ static void __init imx6ul_clocks_init(struct device_node *ccm_node) + hws[IMX6UL_PLL5_BYPASS] = imx_clk_hw_mux_flags("pll5_bypass", base + 0xa0, 16, 1, pll5_bypass_sels, ARRAY_SIZE(pll5_bypass_sels), CLK_SET_RATE_PARENT); + hws[IMX6UL_PLL6_BYPASS] = imx_clk_hw_mux_flags("pll6_bypass", base + 0xe0, 16, 1, pll6_bypass_sels, ARRAY_SIZE(pll6_bypass_sels), CLK_SET_RATE_PARENT); + hws[IMX6UL_PLL7_BYPASS] = imx_clk_hw_mux_flags("pll7_bypass", base + 0x20, 16, 1, pll7_bypass_sels, ARRAY_SIZE(pll7_bypass_sels), CLK_SET_RATE_PARENT); +- hws[IMX6UL_CLK_CSI_SEL] = imx_clk_hw_mux_flags("csi_sel", base + 0x3c, 9, 2, csi_sels, ARRAY_SIZE(csi_sels), CLK_SET_RATE_PARENT); + + /* Do not bypass PLLs initially */ + clk_set_parent(hws[IMX6UL_PLL1_BYPASS]->clk, hws[IMX6UL_CLK_PLL1]->clk); +@@ -270,6 +269,7 @@ static void __init imx6ul_clocks_init(struct device_node *ccm_node) + hws[IMX6UL_CLK_ECSPI_SEL] = imx_clk_hw_mux("ecspi_sel", base + 0x38, 18, 1, ecspi_sels, ARRAY_SIZE(ecspi_sels)); + hws[IMX6UL_CLK_LCDIF_PRE_SEL] = imx_clk_hw_mux_flags("lcdif_pre_sel", base + 0x38, 15, 3, lcdif_pre_sels, ARRAY_SIZE(lcdif_pre_sels), CLK_SET_RATE_PARENT); + hws[IMX6UL_CLK_LCDIF_SEL] = imx_clk_hw_mux("lcdif_sel", base + 0x38, 9, 3, lcdif_sels, ARRAY_SIZE(lcdif_sels)); ++ hws[IMX6UL_CLK_CSI_SEL] = imx_clk_hw_mux("csi_sel", base + 0x3c, 9, 2, csi_sels, ARRAY_SIZE(csi_sels)); + + hws[IMX6UL_CLK_LDB_DI0_DIV_SEL] = imx_clk_hw_mux("ldb_di0", base + 0x20, 10, 1, ldb_di0_div_sels, ARRAY_SIZE(ldb_di0_div_sels)); + hws[IMX6UL_CLK_LDB_DI1_DIV_SEL] = imx_clk_hw_mux("ldb_di1", base + 0x20, 11, 1, ldb_di1_div_sels, ARRAY_SIZE(ldb_di1_div_sels)); +-- +2.33.0 + diff --git a/queue-5.15/clk-ingenic-fix-bugs-with-divided-dividers.patch b/queue-5.15/clk-ingenic-fix-bugs-with-divided-dividers.patch new file mode 100644 index 00000000000..6756cafeb6d --- /dev/null +++ b/queue-5.15/clk-ingenic-fix-bugs-with-divided-dividers.patch @@ -0,0 +1,58 @@ +From 81dadf66e1019c8d4449525d36a04a99b24fdc73 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 1 Oct 2021 18:20:33 +0100 +Subject: clk: ingenic: Fix bugs with divided dividers + +From: Paul Cercueil + +[ Upstream commit ed84ef1cd7eddf933d4ffce2caa8161d6f947245 ] + +Two fixes in one: + +- In the "impose hardware constraints" block, the "logical" divider + value (aka. not translated to the hardware) was clamped to fit in the + register area, but this totally ignored the fact that the divider + value can itself have a fixed divider. + +- The code that made sure that the divider value returned by the + function was a multiple of its own fixed divider could result in a + wrong value being calculated, because it was rounded down instead of + rounded up. + +Fixes: 4afe2d1a6ed5 ("clk: ingenic: Allow divider value to be divided") +Co-developed-by: Artur Rojek +Signed-off-by: Artur Rojek +Signed-off-by: Paul Cercueil +Link: https://lore.kernel.org/r/20211001172033.122329-1-paul@crapouillou.net +Signed-off-by: Stephen Boyd +Signed-off-by: Sasha Levin +--- + drivers/clk/ingenic/cgu.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/drivers/clk/ingenic/cgu.c b/drivers/clk/ingenic/cgu.c +index 266c7595d3302..af31633a8862e 100644 +--- a/drivers/clk/ingenic/cgu.c ++++ b/drivers/clk/ingenic/cgu.c +@@ -453,15 +453,15 @@ ingenic_clk_calc_div(struct clk_hw *hw, + } + + /* Impose hardware constraints */ +- div = min_t(unsigned, div, 1 << clk_info->div.bits); +- div = max_t(unsigned, div, 1); ++ div = clamp_t(unsigned int, div, clk_info->div.div, ++ clk_info->div.div << clk_info->div.bits); + + /* + * If the divider value itself must be divided before being written to + * the divider register, we must ensure we don't have any bits set that + * would be lost as a result of doing so. + */ +- div /= clk_info->div.div; ++ div = DIV_ROUND_UP(div, clk_info->div.div); + div *= clk_info->div.div; + + return div; +-- +2.33.0 + diff --git a/queue-5.15/clk-qcom-gcc-msm8996-drop-again-gcc_aggre1_pnoc_ahb_.patch b/queue-5.15/clk-qcom-gcc-msm8996-drop-again-gcc_aggre1_pnoc_ahb_.patch new file mode 100644 index 00000000000..84a8752b4b9 --- /dev/null +++ b/queue-5.15/clk-qcom-gcc-msm8996-drop-again-gcc_aggre1_pnoc_ahb_.patch @@ -0,0 +1,69 @@ +From a5fe324736d67931484ff9b598e4b0c2aa5dd55d Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 4 Nov 2021 04:11:55 +0300 +Subject: clk: qcom: gcc-msm8996: Drop (again) gcc_aggre1_pnoc_ahb_clk + +From: Dmitry Baryshkov + +[ Upstream commit 05cf3ec00d460b50088d421fb878a0f83f57e262 ] + +The gcc_aggre1_pnoc_ahb_clk is crucial for the proper MSM8996/APQ8096 +functioning. If it gets disabled, several subsytems will stop working +(including eMMC/SDCC and USB). There are no in-kernel users of this +clock, so it is much simpler to remove from the kernel. + +The clock was first removed in the commit 9e60de1cf270 ("clk: qcom: +Remove gcc_aggre1_pnoc_ahb_clk from msm8996") by Stephen Boyd, but got +added back in the commit b567752144e3 ("clk: qcom: Add some missing gcc +clks for msm8996") by Rajendra Nayak. + +Let's remove it again in hope that nobody adds it back. + +Reported-by: Vladimir Zapolskiy +Cc: Rajendra Nayak +Cc: Konrad Dybcio +Fixes: b567752144e3 ("clk: qcom: Add some missing gcc clks for msm8996") +Signed-off-by: Dmitry Baryshkov +Link: https://lore.kernel.org/r/20211104011155.2209654-1-dmitry.baryshkov@linaro.org +Signed-off-by: Stephen Boyd +Signed-off-by: Sasha Levin +--- + drivers/clk/qcom/gcc-msm8996.c | 15 --------------- + 1 file changed, 15 deletions(-) + +diff --git a/drivers/clk/qcom/gcc-msm8996.c b/drivers/clk/qcom/gcc-msm8996.c +index 3c3a7ff045621..9b1674b28d45d 100644 +--- a/drivers/clk/qcom/gcc-msm8996.c ++++ b/drivers/clk/qcom/gcc-msm8996.c +@@ -2937,20 +2937,6 @@ static struct clk_branch gcc_smmu_aggre0_ahb_clk = { + }, + }; + +-static struct clk_branch gcc_aggre1_pnoc_ahb_clk = { +- .halt_reg = 0x82014, +- .clkr = { +- .enable_reg = 0x82014, +- .enable_mask = BIT(0), +- .hw.init = &(struct clk_init_data){ +- .name = "gcc_aggre1_pnoc_ahb_clk", +- .parent_names = (const char *[]){ "periph_noc_clk_src" }, +- .num_parents = 1, +- .ops = &clk_branch2_ops, +- }, +- }, +-}; +- + static struct clk_branch gcc_aggre2_ufs_axi_clk = { + .halt_reg = 0x83014, + .clkr = { +@@ -3474,7 +3460,6 @@ static struct clk_regmap *gcc_msm8996_clocks[] = { + [GCC_AGGRE0_CNOC_AHB_CLK] = &gcc_aggre0_cnoc_ahb_clk.clkr, + [GCC_SMMU_AGGRE0_AXI_CLK] = &gcc_smmu_aggre0_axi_clk.clkr, + [GCC_SMMU_AGGRE0_AHB_CLK] = &gcc_smmu_aggre0_ahb_clk.clkr, +- [GCC_AGGRE1_PNOC_AHB_CLK] = &gcc_aggre1_pnoc_ahb_clk.clkr, + [GCC_AGGRE2_UFS_AXI_CLK] = &gcc_aggre2_ufs_axi_clk.clkr, + [GCC_AGGRE2_USB3_AXI_CLK] = &gcc_aggre2_usb3_axi_clk.clkr, + [GCC_QSPI_AHB_CLK] = &gcc_qspi_ahb_clk.clkr, +-- +2.33.0 + diff --git a/queue-5.15/clk-sunxi-ng-unregister-clocks-resets-when-unbinding.patch b/queue-5.15/clk-sunxi-ng-unregister-clocks-resets-when-unbinding.patch new file mode 100644 index 00000000000..7f14f0f1b12 --- /dev/null +++ b/queue-5.15/clk-sunxi-ng-unregister-clocks-resets-when-unbinding.patch @@ -0,0 +1,496 @@ +From deddaae3ec2de4288c618e4b6e005df118776562 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 1 Sep 2021 00:05:19 -0500 +Subject: clk: sunxi-ng: Unregister clocks/resets when unbinding + +From: Samuel Holland + +[ Upstream commit 9bec2b9c6134052994115d2d3374e96f2ccb9b9d ] + +Currently, unbinding a CCU driver unmaps the device's MMIO region, while +leaving its clocks/resets and their providers registered. This can cause +a page fault later when some clock operation tries to perform MMIO. Fix +this by separating the CCU initialization from the memory allocation, +and then using a devres callback to unregister the clocks and resets. + +This also fixes a memory leak of the `struct ccu_reset`, and uses the +correct owner (the specific platform driver) for the clocks and resets. + +Early OF clock providers are never unregistered, and limited error +handling is possible, so they are mostly unchanged. The error reporting +is made more consistent by moving the message inside of_sunxi_ccu_probe. + +Signed-off-by: Samuel Holland +Signed-off-by: Maxime Ripard +Link: https://lore.kernel.org/r/20210901050526.45673-2-samuel@sholland.org +Signed-off-by: Sasha Levin +--- + drivers/clk/sunxi-ng/ccu-sun4i-a10.c | 2 +- + drivers/clk/sunxi-ng/ccu-sun50i-a100-r.c | 2 +- + drivers/clk/sunxi-ng/ccu-sun50i-a100.c | 2 +- + drivers/clk/sunxi-ng/ccu-sun50i-a64.c | 2 +- + drivers/clk/sunxi-ng/ccu-sun50i-h6-r.c | 2 +- + drivers/clk/sunxi-ng/ccu-sun50i-h6.c | 2 +- + drivers/clk/sunxi-ng/ccu-sun50i-h616.c | 4 +- + drivers/clk/sunxi-ng/ccu-sun5i.c | 2 +- + drivers/clk/sunxi-ng/ccu-sun6i-a31.c | 2 +- + drivers/clk/sunxi-ng/ccu-sun8i-a23.c | 2 +- + drivers/clk/sunxi-ng/ccu-sun8i-a33.c | 2 +- + drivers/clk/sunxi-ng/ccu-sun8i-a83t.c | 2 +- + drivers/clk/sunxi-ng/ccu-sun8i-de2.c | 2 +- + drivers/clk/sunxi-ng/ccu-sun8i-h3.c | 2 +- + drivers/clk/sunxi-ng/ccu-sun8i-r.c | 2 +- + drivers/clk/sunxi-ng/ccu-sun8i-r40.c | 2 +- + drivers/clk/sunxi-ng/ccu-sun8i-v3s.c | 2 +- + drivers/clk/sunxi-ng/ccu-sun9i-a80-de.c | 3 +- + drivers/clk/sunxi-ng/ccu-sun9i-a80-usb.c | 3 +- + drivers/clk/sunxi-ng/ccu-sun9i-a80.c | 2 +- + drivers/clk/sunxi-ng/ccu-suniv-f1c100s.c | 2 +- + drivers/clk/sunxi-ng/ccu_common.c | 89 ++++++++++++++++++++---- + drivers/clk/sunxi-ng/ccu_common.h | 6 +- + 23 files changed, 100 insertions(+), 41 deletions(-) + +diff --git a/drivers/clk/sunxi-ng/ccu-sun4i-a10.c b/drivers/clk/sunxi-ng/ccu-sun4i-a10.c +index f32366d9336e7..bd9a8782fec3d 100644 +--- a/drivers/clk/sunxi-ng/ccu-sun4i-a10.c ++++ b/drivers/clk/sunxi-ng/ccu-sun4i-a10.c +@@ -1464,7 +1464,7 @@ static void __init sun4i_ccu_init(struct device_node *node, + val &= ~GENMASK(7, 6); + writel(val | (2 << 6), reg + SUN4I_AHB_REG); + +- sunxi_ccu_probe(node, reg, desc); ++ of_sunxi_ccu_probe(node, reg, desc); + } + + static void __init sun4i_a10_ccu_setup(struct device_node *node) +diff --git a/drivers/clk/sunxi-ng/ccu-sun50i-a100-r.c b/drivers/clk/sunxi-ng/ccu-sun50i-a100-r.c +index a56142b909938..6f2a589705561 100644 +--- a/drivers/clk/sunxi-ng/ccu-sun50i-a100-r.c ++++ b/drivers/clk/sunxi-ng/ccu-sun50i-a100-r.c +@@ -196,7 +196,7 @@ static int sun50i_a100_r_ccu_probe(struct platform_device *pdev) + if (IS_ERR(reg)) + return PTR_ERR(reg); + +- return sunxi_ccu_probe(pdev->dev.of_node, reg, &sun50i_a100_r_ccu_desc); ++ return devm_sunxi_ccu_probe(&pdev->dev, reg, &sun50i_a100_r_ccu_desc); + } + + static const struct of_device_id sun50i_a100_r_ccu_ids[] = { +diff --git a/drivers/clk/sunxi-ng/ccu-sun50i-a100.c b/drivers/clk/sunxi-ng/ccu-sun50i-a100.c +index 81b48c73d389f..913bb08e6dee8 100644 +--- a/drivers/clk/sunxi-ng/ccu-sun50i-a100.c ++++ b/drivers/clk/sunxi-ng/ccu-sun50i-a100.c +@@ -1247,7 +1247,7 @@ static int sun50i_a100_ccu_probe(struct platform_device *pdev) + writel(val, reg + sun50i_a100_usb2_clk_regs[i]); + } + +- ret = sunxi_ccu_probe(pdev->dev.of_node, reg, &sun50i_a100_ccu_desc); ++ ret = devm_sunxi_ccu_probe(&pdev->dev, reg, &sun50i_a100_ccu_desc); + if (ret) + return ret; + +diff --git a/drivers/clk/sunxi-ng/ccu-sun50i-a64.c b/drivers/clk/sunxi-ng/ccu-sun50i-a64.c +index 149cfde817cba..54f25c624f020 100644 +--- a/drivers/clk/sunxi-ng/ccu-sun50i-a64.c ++++ b/drivers/clk/sunxi-ng/ccu-sun50i-a64.c +@@ -955,7 +955,7 @@ static int sun50i_a64_ccu_probe(struct platform_device *pdev) + + writel(0x515, reg + SUN50I_A64_PLL_MIPI_REG); + +- ret = sunxi_ccu_probe(pdev->dev.of_node, reg, &sun50i_a64_ccu_desc); ++ ret = devm_sunxi_ccu_probe(&pdev->dev, reg, &sun50i_a64_ccu_desc); + if (ret) + return ret; + +diff --git a/drivers/clk/sunxi-ng/ccu-sun50i-h6-r.c b/drivers/clk/sunxi-ng/ccu-sun50i-h6-r.c +index f8909a7ed5539..f30d7eb5424d8 100644 +--- a/drivers/clk/sunxi-ng/ccu-sun50i-h6-r.c ++++ b/drivers/clk/sunxi-ng/ccu-sun50i-h6-r.c +@@ -232,7 +232,7 @@ static void __init sunxi_r_ccu_init(struct device_node *node, + return; + } + +- sunxi_ccu_probe(node, reg, desc); ++ of_sunxi_ccu_probe(node, reg, desc); + } + + static void __init sun50i_h6_r_ccu_setup(struct device_node *node) +diff --git a/drivers/clk/sunxi-ng/ccu-sun50i-h6.c b/drivers/clk/sunxi-ng/ccu-sun50i-h6.c +index bff446b782907..c0800da2fa3d7 100644 +--- a/drivers/clk/sunxi-ng/ccu-sun50i-h6.c ++++ b/drivers/clk/sunxi-ng/ccu-sun50i-h6.c +@@ -1240,7 +1240,7 @@ static int sun50i_h6_ccu_probe(struct platform_device *pdev) + val |= BIT(24); + writel(val, reg + SUN50I_H6_HDMI_CEC_CLK_REG); + +- return sunxi_ccu_probe(pdev->dev.of_node, reg, &sun50i_h6_ccu_desc); ++ return devm_sunxi_ccu_probe(&pdev->dev, reg, &sun50i_h6_ccu_desc); + } + + static const struct of_device_id sun50i_h6_ccu_ids[] = { +diff --git a/drivers/clk/sunxi-ng/ccu-sun50i-h616.c b/drivers/clk/sunxi-ng/ccu-sun50i-h616.c +index 225307305880e..22eb18079a154 100644 +--- a/drivers/clk/sunxi-ng/ccu-sun50i-h616.c ++++ b/drivers/clk/sunxi-ng/ccu-sun50i-h616.c +@@ -1141,9 +1141,7 @@ static void __init sun50i_h616_ccu_setup(struct device_node *node) + val |= BIT(24); + writel(val, reg + SUN50I_H616_HDMI_CEC_CLK_REG); + +- i = sunxi_ccu_probe(node, reg, &sun50i_h616_ccu_desc); +- if (i) +- pr_err("%pOF: probing clocks fails: %d\n", node, i); ++ of_sunxi_ccu_probe(node, reg, &sun50i_h616_ccu_desc); + } + + CLK_OF_DECLARE(sun50i_h616_ccu, "allwinner,sun50i-h616-ccu", +diff --git a/drivers/clk/sunxi-ng/ccu-sun5i.c b/drivers/clk/sunxi-ng/ccu-sun5i.c +index b78e9b507c1c6..1f4bc0e773a7e 100644 +--- a/drivers/clk/sunxi-ng/ccu-sun5i.c ++++ b/drivers/clk/sunxi-ng/ccu-sun5i.c +@@ -1012,7 +1012,7 @@ static void __init sun5i_ccu_init(struct device_node *node, + val &= ~GENMASK(7, 6); + writel(val | (2 << 6), reg + SUN5I_AHB_REG); + +- sunxi_ccu_probe(node, reg, desc); ++ of_sunxi_ccu_probe(node, reg, desc); + } + + static void __init sun5i_a10s_ccu_setup(struct device_node *node) +diff --git a/drivers/clk/sunxi-ng/ccu-sun6i-a31.c b/drivers/clk/sunxi-ng/ccu-sun6i-a31.c +index 9b40d53266a3f..3df5c0b415804 100644 +--- a/drivers/clk/sunxi-ng/ccu-sun6i-a31.c ++++ b/drivers/clk/sunxi-ng/ccu-sun6i-a31.c +@@ -1257,7 +1257,7 @@ static void __init sun6i_a31_ccu_setup(struct device_node *node) + val |= 0x3 << 12; + writel(val, reg + SUN6I_A31_AHB1_REG); + +- sunxi_ccu_probe(node, reg, &sun6i_a31_ccu_desc); ++ of_sunxi_ccu_probe(node, reg, &sun6i_a31_ccu_desc); + + ccu_mux_notifier_register(pll_cpu_clk.common.hw.clk, + &sun6i_a31_cpu_nb); +diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-a23.c b/drivers/clk/sunxi-ng/ccu-sun8i-a23.c +index 103aa504f6c8a..577bb235d6584 100644 +--- a/drivers/clk/sunxi-ng/ccu-sun8i-a23.c ++++ b/drivers/clk/sunxi-ng/ccu-sun8i-a23.c +@@ -745,7 +745,7 @@ static void __init sun8i_a23_ccu_setup(struct device_node *node) + val &= ~BIT(16); + writel(val, reg + SUN8I_A23_PLL_MIPI_REG); + +- sunxi_ccu_probe(node, reg, &sun8i_a23_ccu_desc); ++ of_sunxi_ccu_probe(node, reg, &sun8i_a23_ccu_desc); + } + CLK_OF_DECLARE(sun8i_a23_ccu, "allwinner,sun8i-a23-ccu", + sun8i_a23_ccu_setup); +diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-a33.c b/drivers/clk/sunxi-ng/ccu-sun8i-a33.c +index 91838cd110377..8f65cd03f5acc 100644 +--- a/drivers/clk/sunxi-ng/ccu-sun8i-a33.c ++++ b/drivers/clk/sunxi-ng/ccu-sun8i-a33.c +@@ -805,7 +805,7 @@ static void __init sun8i_a33_ccu_setup(struct device_node *node) + val &= ~BIT(16); + writel(val, reg + SUN8I_A33_PLL_MIPI_REG); + +- sunxi_ccu_probe(node, reg, &sun8i_a33_ccu_desc); ++ of_sunxi_ccu_probe(node, reg, &sun8i_a33_ccu_desc); + + /* Gate then ungate PLL CPU after any rate changes */ + ccu_pll_notifier_register(&sun8i_a33_pll_cpu_nb); +diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-a83t.c b/drivers/clk/sunxi-ng/ccu-sun8i-a83t.c +index 2b434521c5ccf..c2ddcd2ddab4e 100644 +--- a/drivers/clk/sunxi-ng/ccu-sun8i-a83t.c ++++ b/drivers/clk/sunxi-ng/ccu-sun8i-a83t.c +@@ -906,7 +906,7 @@ static int sun8i_a83t_ccu_probe(struct platform_device *pdev) + sun8i_a83t_cpu_pll_fixup(reg + SUN8I_A83T_PLL_C0CPUX_REG); + sun8i_a83t_cpu_pll_fixup(reg + SUN8I_A83T_PLL_C1CPUX_REG); + +- return sunxi_ccu_probe(pdev->dev.of_node, reg, &sun8i_a83t_ccu_desc); ++ return devm_sunxi_ccu_probe(&pdev->dev, reg, &sun8i_a83t_ccu_desc); + } + + static const struct of_device_id sun8i_a83t_ccu_ids[] = { +diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-de2.c b/drivers/clk/sunxi-ng/ccu-sun8i-de2.c +index 524f33275bc73..4b94b6041b271 100644 +--- a/drivers/clk/sunxi-ng/ccu-sun8i-de2.c ++++ b/drivers/clk/sunxi-ng/ccu-sun8i-de2.c +@@ -342,7 +342,7 @@ static int sunxi_de2_clk_probe(struct platform_device *pdev) + goto err_disable_mod_clk; + } + +- ret = sunxi_ccu_probe(pdev->dev.of_node, reg, ccu_desc); ++ ret = devm_sunxi_ccu_probe(&pdev->dev, reg, ccu_desc); + if (ret) + goto err_assert_reset; + +diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-h3.c b/drivers/clk/sunxi-ng/ccu-sun8i-h3.c +index 7e629a4493afd..d2fc2903787d8 100644 +--- a/drivers/clk/sunxi-ng/ccu-sun8i-h3.c ++++ b/drivers/clk/sunxi-ng/ccu-sun8i-h3.c +@@ -1154,7 +1154,7 @@ static void __init sunxi_h3_h5_ccu_init(struct device_node *node, + val &= ~GENMASK(19, 16); + writel(val | (0 << 16), reg + SUN8I_H3_PLL_AUDIO_REG); + +- sunxi_ccu_probe(node, reg, desc); ++ of_sunxi_ccu_probe(node, reg, desc); + + /* Gate then ungate PLL CPU after any rate changes */ + ccu_pll_notifier_register(&sun8i_h3_pll_cpu_nb); +diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-r.c b/drivers/clk/sunxi-ng/ccu-sun8i-r.c +index 4c8c491b87c27..9e754d1f754a1 100644 +--- a/drivers/clk/sunxi-ng/ccu-sun8i-r.c ++++ b/drivers/clk/sunxi-ng/ccu-sun8i-r.c +@@ -265,7 +265,7 @@ static void __init sunxi_r_ccu_init(struct device_node *node, + return; + } + +- sunxi_ccu_probe(node, reg, desc); ++ of_sunxi_ccu_probe(node, reg, desc); + } + + static void __init sun8i_a83t_r_ccu_setup(struct device_node *node) +diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-r40.c b/drivers/clk/sunxi-ng/ccu-sun8i-r40.c +index 84153418453f4..002e0c3a04dbe 100644 +--- a/drivers/clk/sunxi-ng/ccu-sun8i-r40.c ++++ b/drivers/clk/sunxi-ng/ccu-sun8i-r40.c +@@ -1346,7 +1346,7 @@ static int sun8i_r40_ccu_probe(struct platform_device *pdev) + if (IS_ERR(regmap)) + return PTR_ERR(regmap); + +- ret = sunxi_ccu_probe(pdev->dev.of_node, reg, &sun8i_r40_ccu_desc); ++ ret = devm_sunxi_ccu_probe(&pdev->dev, reg, &sun8i_r40_ccu_desc); + if (ret) + return ret; + +diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c b/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c +index f49724a22540e..ce150f83ab54e 100644 +--- a/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c ++++ b/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c +@@ -822,7 +822,7 @@ static void __init sun8i_v3_v3s_ccu_init(struct device_node *node, + val &= ~GENMASK(19, 16); + writel(val, reg + SUN8I_V3S_PLL_AUDIO_REG); + +- sunxi_ccu_probe(node, reg, ccu_desc); ++ of_sunxi_ccu_probe(node, reg, ccu_desc); + } + + static void __init sun8i_v3s_ccu_setup(struct device_node *node) +diff --git a/drivers/clk/sunxi-ng/ccu-sun9i-a80-de.c b/drivers/clk/sunxi-ng/ccu-sun9i-a80-de.c +index 6616e8114f623..261e64416f26a 100644 +--- a/drivers/clk/sunxi-ng/ccu-sun9i-a80-de.c ++++ b/drivers/clk/sunxi-ng/ccu-sun9i-a80-de.c +@@ -246,8 +246,7 @@ static int sun9i_a80_de_clk_probe(struct platform_device *pdev) + goto err_disable_clk; + } + +- ret = sunxi_ccu_probe(pdev->dev.of_node, reg, +- &sun9i_a80_de_clk_desc); ++ ret = devm_sunxi_ccu_probe(&pdev->dev, reg, &sun9i_a80_de_clk_desc); + if (ret) + goto err_assert_reset; + +diff --git a/drivers/clk/sunxi-ng/ccu-sun9i-a80-usb.c b/drivers/clk/sunxi-ng/ccu-sun9i-a80-usb.c +index 4b4a507d04edf..596243b3e0fa3 100644 +--- a/drivers/clk/sunxi-ng/ccu-sun9i-a80-usb.c ++++ b/drivers/clk/sunxi-ng/ccu-sun9i-a80-usb.c +@@ -117,8 +117,7 @@ static int sun9i_a80_usb_clk_probe(struct platform_device *pdev) + return ret; + } + +- ret = sunxi_ccu_probe(pdev->dev.of_node, reg, +- &sun9i_a80_usb_clk_desc); ++ ret = devm_sunxi_ccu_probe(&pdev->dev, reg, &sun9i_a80_usb_clk_desc); + if (ret) + goto err_disable_clk; + +diff --git a/drivers/clk/sunxi-ng/ccu-sun9i-a80.c b/drivers/clk/sunxi-ng/ccu-sun9i-a80.c +index ef29582676f6e..97aaed0e68500 100644 +--- a/drivers/clk/sunxi-ng/ccu-sun9i-a80.c ++++ b/drivers/clk/sunxi-ng/ccu-sun9i-a80.c +@@ -1231,7 +1231,7 @@ static int sun9i_a80_ccu_probe(struct platform_device *pdev) + sun9i_a80_cpu_pll_fixup(reg + SUN9I_A80_PLL_C0CPUX_REG); + sun9i_a80_cpu_pll_fixup(reg + SUN9I_A80_PLL_C1CPUX_REG); + +- return sunxi_ccu_probe(pdev->dev.of_node, reg, &sun9i_a80_ccu_desc); ++ return devm_sunxi_ccu_probe(&pdev->dev, reg, &sun9i_a80_ccu_desc); + } + + static const struct of_device_id sun9i_a80_ccu_ids[] = { +diff --git a/drivers/clk/sunxi-ng/ccu-suniv-f1c100s.c b/drivers/clk/sunxi-ng/ccu-suniv-f1c100s.c +index 7ecc3a5a5b5e1..61ad7ee91c114 100644 +--- a/drivers/clk/sunxi-ng/ccu-suniv-f1c100s.c ++++ b/drivers/clk/sunxi-ng/ccu-suniv-f1c100s.c +@@ -538,7 +538,7 @@ static void __init suniv_f1c100s_ccu_setup(struct device_node *node) + val &= ~GENMASK(19, 16); + writel(val | (3 << 16), reg + SUNIV_PLL_AUDIO_REG); + +- sunxi_ccu_probe(node, reg, &suniv_ccu_desc); ++ of_sunxi_ccu_probe(node, reg, &suniv_ccu_desc); + + /* Gate then ungate PLL CPU after any rate changes */ + ccu_pll_notifier_register(&suniv_pll_cpu_nb); +diff --git a/drivers/clk/sunxi-ng/ccu_common.c b/drivers/clk/sunxi-ng/ccu_common.c +index 2e20e650b6c01..88cb569e58358 100644 +--- a/drivers/clk/sunxi-ng/ccu_common.c ++++ b/drivers/clk/sunxi-ng/ccu_common.c +@@ -7,6 +7,7 @@ + + #include + #include ++#include + #include + #include + +@@ -14,6 +15,11 @@ + #include "ccu_gate.h" + #include "ccu_reset.h" + ++struct sunxi_ccu { ++ const struct sunxi_ccu_desc *desc; ++ struct ccu_reset reset; ++}; ++ + static DEFINE_SPINLOCK(ccu_lock); + + void ccu_helper_wait_for_lock(struct ccu_common *common, u32 lock) +@@ -79,12 +85,15 @@ int ccu_pll_notifier_register(struct ccu_pll_nb *pll_nb) + &pll_nb->clk_nb); + } + +-int sunxi_ccu_probe(struct device_node *node, void __iomem *reg, +- const struct sunxi_ccu_desc *desc) ++static int sunxi_ccu_probe(struct sunxi_ccu *ccu, struct device *dev, ++ struct device_node *node, void __iomem *reg, ++ const struct sunxi_ccu_desc *desc) + { + struct ccu_reset *reset; + int i, ret; + ++ ccu->desc = desc; ++ + for (i = 0; i < desc->num_ccu_clks; i++) { + struct ccu_common *cclk = desc->ccu_clks[i]; + +@@ -103,7 +112,10 @@ int sunxi_ccu_probe(struct device_node *node, void __iomem *reg, + continue; + + name = hw->init->name; +- ret = of_clk_hw_register(node, hw); ++ if (dev) ++ ret = clk_hw_register(dev, hw); ++ else ++ ret = of_clk_hw_register(node, hw); + if (ret) { + pr_err("Couldn't register clock %d - %s\n", i, name); + goto err_clk_unreg; +@@ -115,15 +127,10 @@ int sunxi_ccu_probe(struct device_node *node, void __iomem *reg, + if (ret) + goto err_clk_unreg; + +- reset = kzalloc(sizeof(*reset), GFP_KERNEL); +- if (!reset) { +- ret = -ENOMEM; +- goto err_alloc_reset; +- } +- ++ reset = &ccu->reset; + reset->rcdev.of_node = node; + reset->rcdev.ops = &ccu_reset_ops; +- reset->rcdev.owner = THIS_MODULE; ++ reset->rcdev.owner = dev ? dev->driver->owner : THIS_MODULE; + reset->rcdev.nr_resets = desc->num_resets; + reset->base = reg; + reset->lock = &ccu_lock; +@@ -131,13 +138,11 @@ int sunxi_ccu_probe(struct device_node *node, void __iomem *reg, + + ret = reset_controller_register(&reset->rcdev); + if (ret) +- goto err_of_clk_unreg; ++ goto err_del_provider; + + return 0; + +-err_of_clk_unreg: +- kfree(reset); +-err_alloc_reset: ++err_del_provider: + of_clk_del_provider(node); + err_clk_unreg: + while (--i >= 0) { +@@ -149,3 +154,59 @@ err_clk_unreg: + } + return ret; + } ++ ++static void devm_sunxi_ccu_release(struct device *dev, void *res) ++{ ++ struct sunxi_ccu *ccu = res; ++ const struct sunxi_ccu_desc *desc = ccu->desc; ++ int i; ++ ++ reset_controller_unregister(&ccu->reset.rcdev); ++ of_clk_del_provider(dev->of_node); ++ ++ for (i = 0; i < desc->hw_clks->num; i++) { ++ struct clk_hw *hw = desc->hw_clks->hws[i]; ++ ++ if (!hw) ++ continue; ++ clk_hw_unregister(hw); ++ } ++} ++ ++int devm_sunxi_ccu_probe(struct device *dev, void __iomem *reg, ++ const struct sunxi_ccu_desc *desc) ++{ ++ struct sunxi_ccu *ccu; ++ int ret; ++ ++ ccu = devres_alloc(devm_sunxi_ccu_release, sizeof(*ccu), GFP_KERNEL); ++ if (!ccu) ++ return -ENOMEM; ++ ++ ret = sunxi_ccu_probe(ccu, dev, dev->of_node, reg, desc); ++ if (ret) { ++ devres_free(ccu); ++ return ret; ++ } ++ ++ devres_add(dev, ccu); ++ ++ return 0; ++} ++ ++void of_sunxi_ccu_probe(struct device_node *node, void __iomem *reg, ++ const struct sunxi_ccu_desc *desc) ++{ ++ struct sunxi_ccu *ccu; ++ int ret; ++ ++ ccu = kzalloc(sizeof(*ccu), GFP_KERNEL); ++ if (!ccu) ++ return; ++ ++ ret = sunxi_ccu_probe(ccu, NULL, node, reg, desc); ++ if (ret) { ++ pr_err("%pOF: probing clocks failed: %d\n", node, ret); ++ kfree(ccu); ++ } ++} +diff --git a/drivers/clk/sunxi-ng/ccu_common.h b/drivers/clk/sunxi-ng/ccu_common.h +index 04e7a12200a21..98a1834b58bb4 100644 +--- a/drivers/clk/sunxi-ng/ccu_common.h ++++ b/drivers/clk/sunxi-ng/ccu_common.h +@@ -63,7 +63,9 @@ struct ccu_pll_nb { + + int ccu_pll_notifier_register(struct ccu_pll_nb *pll_nb); + +-int sunxi_ccu_probe(struct device_node *node, void __iomem *reg, +- const struct sunxi_ccu_desc *desc); ++int devm_sunxi_ccu_probe(struct device *dev, void __iomem *reg, ++ const struct sunxi_ccu_desc *desc); ++void of_sunxi_ccu_probe(struct device_node *node, void __iomem *reg, ++ const struct sunxi_ccu_desc *desc); + + #endif /* _COMMON_H_ */ +-- +2.33.0 + diff --git a/queue-5.15/cpuidle-tegra-check-whether-pmc-is-ready.patch b/queue-5.15/cpuidle-tegra-check-whether-pmc-is-ready.patch new file mode 100644 index 00000000000..a9f7ac68f49 --- /dev/null +++ b/queue-5.15/cpuidle-tegra-check-whether-pmc-is-ready.patch @@ -0,0 +1,39 @@ +From 916d5aca572e4c03d8341600eb237ddaa174d848 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 12 Sep 2021 23:29:07 +0300 +Subject: cpuidle: tegra: Check whether PMC is ready + +From: Dmitry Osipenko + +[ Upstream commit bdb1ffdad3b73e4d0538098fc02e2ea87a6b27cd ] + +Check whether PMC is ready before proceeding with the cpuidle registration. +This fixes racing with the PMC driver probe order, which results in a +disabled deepest CC6 idling state if cpuidle driver is probed before the +PMC. + +Acked-by: Daniel Lezcano +Signed-off-by: Dmitry Osipenko +Signed-off-by: Thierry Reding +Signed-off-by: Sasha Levin +--- + drivers/cpuidle/cpuidle-tegra.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/drivers/cpuidle/cpuidle-tegra.c b/drivers/cpuidle/cpuidle-tegra.c +index 508bd9f237929..9845629aeb6d4 100644 +--- a/drivers/cpuidle/cpuidle-tegra.c ++++ b/drivers/cpuidle/cpuidle-tegra.c +@@ -337,6 +337,9 @@ static void tegra_cpuidle_setup_tegra114_c7_state(void) + + static int tegra_cpuidle_probe(struct platform_device *pdev) + { ++ if (tegra_pmc_get_suspend_mode() == TEGRA_SUSPEND_NOT_READY) ++ return -EPROBE_DEFER; ++ + /* LP2 could be disabled in device-tree */ + if (tegra_pmc_get_suspend_mode() < TEGRA_SUSPEND_LP2) + tegra_cpuidle_disable_state(TEGRA_CC6); +-- +2.33.0 + diff --git a/queue-5.15/drm-nouveau-hdmigv100.c-fix-corrupted-hdmi-vendor-in.patch b/queue-5.15/drm-nouveau-hdmigv100.c-fix-corrupted-hdmi-vendor-in.patch new file mode 100644 index 00000000000..0c99e0bb552 --- /dev/null +++ b/queue-5.15/drm-nouveau-hdmigv100.c-fix-corrupted-hdmi-vendor-in.patch @@ -0,0 +1,41 @@ +From 3d04b857363d17af1144cd1100fd0ff25da1bfc6 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 10 Nov 2021 16:36:04 +0100 +Subject: drm/nouveau: hdmigv100.c: fix corrupted HDMI Vendor InfoFrame + +From: Hans Verkuil + +[ Upstream commit 3cc1ae1fa70ab369e4645e38ce335a19438093ad ] + +gv100_hdmi_ctrl() writes vendor_infoframe.subpack0_high to 0x6f0110, and +then overwrites it with 0. Just drop the overwrite with 0, that's clearly +a mistake. + +Because of this issue the HDMI VIC is 0 instead of 1 in the HDMI Vendor +InfoFrame when transmitting 4kp30. + +Signed-off-by: Hans Verkuil +Fixes: 290ffeafcc1a ("drm/nouveau/disp/gv100: initial support") +Reviewed-by: Ben Skeggs +Signed-off-by: Karol Herbst +Link: https://patchwork.freedesktop.org/patch/msgid/3d3bd0f7-c150-2479-9350-35d394ee772d@xs4all.nl +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigv100.c | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigv100.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigv100.c +index 6e3c450eaacef..3ff49344abc77 100644 +--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigv100.c ++++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigv100.c +@@ -62,7 +62,6 @@ gv100_hdmi_ctrl(struct nvkm_ior *ior, int head, bool enable, u8 max_ac_packet, + nvkm_wr32(device, 0x6f0108 + hdmi, vendor_infoframe.header); + nvkm_wr32(device, 0x6f010c + hdmi, vendor_infoframe.subpack0_low); + nvkm_wr32(device, 0x6f0110 + hdmi, vendor_infoframe.subpack0_high); +- nvkm_wr32(device, 0x6f0110 + hdmi, 0x00000000); + nvkm_wr32(device, 0x6f0114 + hdmi, 0x00000000); + nvkm_wr32(device, 0x6f0118 + hdmi, 0x00000000); + nvkm_wr32(device, 0x6f011c + hdmi, 0x00000000); +-- +2.33.0 + diff --git a/queue-5.15/e100-fix-device-suspend-resume.patch b/queue-5.15/e100-fix-device-suspend-resume.patch new file mode 100644 index 00000000000..76ac8c85cec --- /dev/null +++ b/queue-5.15/e100-fix-device-suspend-resume.patch @@ -0,0 +1,95 @@ +From 7b11a9bc2dd22d99c9c3995a439da9b9143eba48 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 17 Nov 2021 12:59:52 -0800 +Subject: e100: fix device suspend/resume + +From: Jesse Brandeburg + +[ Upstream commit 5d2ca2e12dfb2aff3388ca57b06f570fa6206ced ] + +As reported in [1], e100 was no longer working for suspend/resume +cycles. The previous commit mentioned in the fixes appears to have +broken things and this attempts to practice best known methods for +device power management and keep wake-up working while allowing +suspend/resume to work. To do this, I reorder a little bit of code +and fix the resume path to make sure the device is enabled. + +[1] https://bugzilla.kernel.org/show_bug.cgi?id=214933 + +Fixes: 69a74aef8a18 ("e100: use generic power management") +Cc: Vaibhav Gupta +Reported-by: Alexey Kuznetsov +Signed-off-by: Jesse Brandeburg +Tested-by: Alexey Kuznetsov +Signed-off-by: Tony Nguyen +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/intel/e100.c | 18 +++++++++++++----- + 1 file changed, 13 insertions(+), 5 deletions(-) + +diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c +index 09ae1939e6db4..36d52246bdc66 100644 +--- a/drivers/net/ethernet/intel/e100.c ++++ b/drivers/net/ethernet/intel/e100.c +@@ -3003,9 +3003,10 @@ static void __e100_shutdown(struct pci_dev *pdev, bool *enable_wake) + struct net_device *netdev = pci_get_drvdata(pdev); + struct nic *nic = netdev_priv(netdev); + ++ netif_device_detach(netdev); ++ + if (netif_running(netdev)) + e100_down(nic); +- netif_device_detach(netdev); + + if ((nic->flags & wol_magic) | e100_asf(nic)) { + /* enable reverse auto-negotiation */ +@@ -3022,7 +3023,7 @@ static void __e100_shutdown(struct pci_dev *pdev, bool *enable_wake) + *enable_wake = false; + } + +- pci_clear_master(pdev); ++ pci_disable_device(pdev); + } + + static int __e100_power_off(struct pci_dev *pdev, bool wake) +@@ -3042,8 +3043,6 @@ static int __maybe_unused e100_suspend(struct device *dev_d) + + __e100_shutdown(to_pci_dev(dev_d), &wake); + +- device_wakeup_disable(dev_d); +- + return 0; + } + +@@ -3051,6 +3050,14 @@ static int __maybe_unused e100_resume(struct device *dev_d) + { + struct net_device *netdev = dev_get_drvdata(dev_d); + struct nic *nic = netdev_priv(netdev); ++ int err; ++ ++ err = pci_enable_device(to_pci_dev(dev_d)); ++ if (err) { ++ netdev_err(netdev, "Resume cannot enable PCI device, aborting\n"); ++ return err; ++ } ++ pci_set_master(to_pci_dev(dev_d)); + + /* disable reverse auto-negotiation */ + if (nic->phy == phy_82552_v) { +@@ -3062,10 +3069,11 @@ static int __maybe_unused e100_resume(struct device *dev_d) + smartspeed & ~(E100_82552_REV_ANEG)); + } + +- netif_device_attach(netdev); + if (netif_running(netdev)) + e100_up(nic); + ++ netif_device_attach(netdev); ++ + return 0; + } + +-- +2.33.0 + diff --git a/queue-5.15/f2fs-compress-disallow-disabling-compress-on-non-emp.patch b/queue-5.15/f2fs-compress-disallow-disabling-compress-on-non-emp.patch new file mode 100644 index 00000000000..226f23fdeb2 --- /dev/null +++ b/queue-5.15/f2fs-compress-disallow-disabling-compress-on-non-emp.patch @@ -0,0 +1,43 @@ +From 677b88015f9a3798d27c1002b5d3df2d4c92c0bc Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 27 Oct 2021 13:16:00 +0900 +Subject: f2fs: compress: disallow disabling compress on non-empty compressed + file + +From: Hyeong-Jun Kim + +[ Upstream commit 02d58cd253d7536c412993573fc6b3b4454960eb ] + +Compresse file and normal file has differ in i_addr addressing, +specifically addrs per inode/block. So, we will face data loss, if we +disable the compression flag on non-empty files. Therefore we should +disallow not only enabling but disabling the compression flag on +non-empty files. + +Fixes: 4c8ff7095bef ("f2fs: support data compression") +Signed-off-by: Sungjong Seo +Signed-off-by: Hyeong-Jun Kim +Reviewed-by: Chao Yu +Signed-off-by: Jaegeuk Kim +Signed-off-by: Sasha Levin +--- + fs/f2fs/f2fs.h | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h +index b339ae89c1ad1..c242274e3479b 100644 +--- a/fs/f2fs/f2fs.h ++++ b/fs/f2fs/f2fs.h +@@ -4152,8 +4152,7 @@ static inline bool f2fs_disable_compressed_file(struct inode *inode) + + if (!f2fs_compressed_file(inode)) + return true; +- if (S_ISREG(inode->i_mode) && +- (get_dirty_pages(inode) || atomic_read(&fi->i_compr_blocks))) ++ if (S_ISREG(inode->i_mode) && F2FS_HAS_BLOCKS(inode)) + return false; + + fi->i_flags &= ~F2FS_COMPR_FL; +-- +2.33.0 + diff --git a/queue-5.15/f2fs-fix-incorrect-return-value-in-f2fs_sanity_check.patch b/queue-5.15/f2fs-fix-incorrect-return-value-in-f2fs_sanity_check.patch new file mode 100644 index 00000000000..82ce7d2fe45 --- /dev/null +++ b/queue-5.15/f2fs-fix-incorrect-return-value-in-f2fs_sanity_check.patch @@ -0,0 +1,46 @@ +From 4db2baec5fcdcd64a42bfaf604702c7878989425 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 28 Oct 2021 20:45:08 +0800 +Subject: f2fs: fix incorrect return value in f2fs_sanity_check_ckpt() + +From: Chao Yu + +[ Upstream commit ca98d72141dd81f42893a9a43d7ededab3355fba ] + +As Pavel Machek reported in [1] + +This code looks quite confused: part of function returns 1 on +corruption, part returns -errno. The problem is not stable-specific. + +[1] https://lkml.org/lkml/2021/9/19/207 + +Let's fix to make 'insane cp_payload case' to return 1 rater than +EFSCORRUPTED, so that return value can be kept consistent for all +error cases, it can avoid confusion of code logic. + +Fixes: 65ddf6564843 ("f2fs: fix to do sanity check for sb/cp fields correctly") +Reported-by: Pavel Machek +Reviewed-by: Pavel Machek +Signed-off-by: Chao Yu +Signed-off-by: Jaegeuk Kim +Signed-off-by: Sasha Levin +--- + fs/f2fs/super.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c +index 4d24146b4f471..8795a5a8d4e89 100644 +--- a/fs/f2fs/super.c ++++ b/fs/f2fs/super.c +@@ -3487,7 +3487,7 @@ skip_cross: + NR_CURSEG_PERSIST_TYPE + nat_bits_blocks >= blocks_per_seg)) { + f2fs_warn(sbi, "Insane cp_payload: %u, nat_bits_blocks: %u)", + cp_payload, nat_bits_blocks); +- return -EFSCORRUPTED; ++ return 1; + } + + if (unlikely(f2fs_cp_error(sbi))) { +-- +2.33.0 + diff --git a/queue-5.15/f2fs-fix-to-use-whint_mode.patch b/queue-5.15/f2fs-fix-to-use-whint_mode.patch new file mode 100644 index 00000000000..0c5e0b8ae45 --- /dev/null +++ b/queue-5.15/f2fs-fix-to-use-whint_mode.patch @@ -0,0 +1,43 @@ +From a0a0698139a7413c4652d9a0657a1321f96eeb0b Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 27 Sep 2021 15:06:48 +0900 +Subject: f2fs: fix to use WHINT_MODE + +From: Keoseong Park + +[ Upstream commit 011e0868e0cf1237675b22e36fffa958fb08f46e ] + +Since active_logs can be set to 2 or 4 or NR_CURSEG_PERSIST_TYPE(6), +it cannot be set to NR_CURSEG_TYPE(8). +That is, whint_mode is always off. + +Therefore, the condition is changed from NR_CURSEG_TYPE to NR_CURSEG_PERSIST_TYPE. + +Cc: Chao Yu +Fixes: d0b9e42ab615 (f2fs: introduce inmem curseg) +Reported-by: tanghuan +Signed-off-by: Keoseong Park +Signed-off-by: Fengnan Chang +Reviewed-by: Chao Yu +Signed-off-by: Jaegeuk Kim +Signed-off-by: Sasha Levin +--- + fs/f2fs/super.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c +index dbe040b66802c..4d24146b4f471 100644 +--- a/fs/f2fs/super.c ++++ b/fs/f2fs/super.c +@@ -1292,7 +1292,7 @@ default_check: + /* Not pass down write hints if the number of active logs is lesser + * than NR_CURSEG_PERSIST_TYPE. + */ +- if (F2FS_OPTION(sbi).active_logs != NR_CURSEG_TYPE) ++ if (F2FS_OPTION(sbi).active_logs != NR_CURSEG_PERSIST_TYPE) + F2FS_OPTION(sbi).whint_mode = WHINT_MODE_OFF; + + if (f2fs_sb_has_readonly(sbi) && !f2fs_readonly(sbi->sb)) { +-- +2.33.0 + diff --git a/queue-5.15/f2fs-fix-up-f2fs_lookup-tracepoints.patch b/queue-5.15/f2fs-fix-up-f2fs_lookup-tracepoints.patch new file mode 100644 index 00000000000..a0a63af5cdc --- /dev/null +++ b/queue-5.15/f2fs-fix-up-f2fs_lookup-tracepoints.patch @@ -0,0 +1,77 @@ +From 3ab791279fe0195f91488a11896d45682a8f92a1 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 21 Sep 2021 22:37:30 +0800 +Subject: f2fs: fix up f2fs_lookup tracepoints + +From: Gao Xiang + +[ Upstream commit 70a9ac36ffd807ac506ed0b849f3e8ce3c6623f2 ] + +Fix up a misuse that the filename pointer isn't always valid in +the ring buffer, and we should copy the content instead. + +Fixes: 0c5e36db17f5 ("f2fs: trace f2fs_lookup") +Signed-off-by: Gao Xiang +Signed-off-by: Jaegeuk Kim +Signed-off-by: Sasha Levin +--- + include/trace/events/f2fs.h | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h +index 4e881d91c8744..4cb055af1ec0b 100644 +--- a/include/trace/events/f2fs.h ++++ b/include/trace/events/f2fs.h +@@ -807,20 +807,20 @@ TRACE_EVENT(f2fs_lookup_start, + TP_STRUCT__entry( + __field(dev_t, dev) + __field(ino_t, ino) +- __field(const char *, name) ++ __string(name, dentry->d_name.name) + __field(unsigned int, flags) + ), + + TP_fast_assign( + __entry->dev = dir->i_sb->s_dev; + __entry->ino = dir->i_ino; +- __entry->name = dentry->d_name.name; ++ __assign_str(name, dentry->d_name.name); + __entry->flags = flags; + ), + + TP_printk("dev = (%d,%d), pino = %lu, name:%s, flags:%u", + show_dev_ino(__entry), +- __entry->name, ++ __get_str(name), + __entry->flags) + ); + +@@ -834,7 +834,7 @@ TRACE_EVENT(f2fs_lookup_end, + TP_STRUCT__entry( + __field(dev_t, dev) + __field(ino_t, ino) +- __field(const char *, name) ++ __string(name, dentry->d_name.name) + __field(nid_t, cino) + __field(int, err) + ), +@@ -842,14 +842,14 @@ TRACE_EVENT(f2fs_lookup_end, + TP_fast_assign( + __entry->dev = dir->i_sb->s_dev; + __entry->ino = dir->i_ino; +- __entry->name = dentry->d_name.name; ++ __assign_str(name, dentry->d_name.name); + __entry->cino = ino; + __entry->err = err; + ), + + TP_printk("dev = (%d,%d), pino = %lu, name:%s, ino:%u, err:%d", + show_dev_ino(__entry), +- __entry->name, ++ __get_str(name), + __entry->cino, + __entry->err) + ); +-- +2.33.0 + diff --git a/queue-5.15/f2fs-fix-wrong-condition-to-trigger-background-check.patch b/queue-5.15/f2fs-fix-wrong-condition-to-trigger-background-check.patch new file mode 100644 index 00000000000..69c53e59ff3 --- /dev/null +++ b/queue-5.15/f2fs-fix-wrong-condition-to-trigger-background-check.patch @@ -0,0 +1,38 @@ +From f4b99f9e5efd345a4ef290a0950c703be861d91f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 29 Sep 2021 03:19:14 +0800 +Subject: f2fs: fix wrong condition to trigger background checkpoint correctly + +From: Chao Yu + +[ Upstream commit cd6d697a6e2013a0a85f8b261b16c8cfd50c1f5f ] + +In f2fs_balance_fs_bg(), it needs to check both NAT_ENTRIES and INO_ENTRIES +memory usage to decide whether we should skip background checkpoint, otherwise +we may always skip checking INO_ENTRIES memory usage, so that INO_ENTRIES may +potentially cause high memory footprint. + +Fixes: 493720a48543 ("f2fs: fix to avoid REQ_TIME and CP_TIME collision") +Signed-off-by: Chao Yu +Signed-off-by: Jaegeuk Kim +Signed-off-by: Sasha Levin +--- + fs/f2fs/segment.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c +index a135d22474154..d716553bdc025 100644 +--- a/fs/f2fs/segment.c ++++ b/fs/f2fs/segment.c +@@ -561,7 +561,7 @@ void f2fs_balance_fs_bg(struct f2fs_sb_info *sbi, bool from_bg) + goto do_sync; + + /* checkpoint is the only way to shrink partial cached entries */ +- if (f2fs_available_free_memory(sbi, NAT_ENTRIES) || ++ if (f2fs_available_free_memory(sbi, NAT_ENTRIES) && + f2fs_available_free_memory(sbi, INO_ENTRIES)) + return; + +-- +2.33.0 + diff --git a/queue-5.15/firmware_loader-fix-pre-allocated-buf-built-in-firmw.patch b/queue-5.15/firmware_loader-fix-pre-allocated-buf-built-in-firmw.patch new file mode 100644 index 00000000000..e6b43c309dd --- /dev/null +++ b/queue-5.15/firmware_loader-fix-pre-allocated-buf-built-in-firmw.patch @@ -0,0 +1,83 @@ +From cf65cc2284e6c9e54134afcfe9f27d437ae2ae00 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 17 Sep 2021 11:22:13 -0700 +Subject: firmware_loader: fix pre-allocated buf built-in firmware use + +From: Luis Chamberlain + +[ Upstream commit f7a07f7b96033df7709042ff38e998720a3f7119 ] + +The firmware_loader can be used with a pre-allocated buffer +through the use of the API calls: + + o request_firmware_into_buf() + o request_partial_firmware_into_buf() + +If the firmware was built-in and present, our current check +for if the built-in firmware fits into the pre-allocated buffer +does not return any errors, and we proceed to tell the caller +that everything worked fine. It's a lie and no firmware would +end up being copied into the pre-allocated buffer. So if the +caller trust the result it may end up writing a bunch of 0's +to a device! + +Fix this by making the function that checks for the pre-allocated +buffer return non-void. Since the typical use case is when no +pre-allocated buffer is provided make this return successfully +for that case. If the built-in firmware does *not* fit into the +pre-allocated buffer size return a failure as we should have +been doing before. + +I'm not aware of users of the built-in firmware using the API +calls with a pre-allocated buffer, as such I doubt this fixes +any real life issue. But you never know... perhaps some oddball +private tree might use it. + +In so far as upstream is concerned this just fixes our code for +correctness. + +Signed-off-by: Luis Chamberlain +Link: https://lore.kernel.org/r/20210917182226.3532898-2-mcgrof@kernel.org +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Sasha Levin +--- + drivers/base/firmware_loader/main.c | 13 +++++++------ + 1 file changed, 7 insertions(+), 6 deletions(-) + +diff --git a/drivers/base/firmware_loader/main.c b/drivers/base/firmware_loader/main.c +index bdbedc6660a87..ef904b8b112e6 100644 +--- a/drivers/base/firmware_loader/main.c ++++ b/drivers/base/firmware_loader/main.c +@@ -100,12 +100,15 @@ static struct firmware_cache fw_cache; + extern struct builtin_fw __start_builtin_fw[]; + extern struct builtin_fw __end_builtin_fw[]; + +-static void fw_copy_to_prealloc_buf(struct firmware *fw, ++static bool fw_copy_to_prealloc_buf(struct firmware *fw, + void *buf, size_t size) + { +- if (!buf || size < fw->size) +- return; ++ if (!buf) ++ return true; ++ if (size < fw->size) ++ return false; + memcpy(buf, fw->data, fw->size); ++ return true; + } + + static bool fw_get_builtin_firmware(struct firmware *fw, const char *name, +@@ -117,9 +120,7 @@ static bool fw_get_builtin_firmware(struct firmware *fw, const char *name, + if (strcmp(name, b_fw->name) == 0) { + fw->size = b_fw->size; + fw->data = b_fw->data; +- fw_copy_to_prealloc_buf(fw, buf, size); +- +- return true; ++ return fw_copy_to_prealloc_buf(fw, buf, size); + } + } + +-- +2.33.0 + diff --git a/queue-5.15/gpio-rockchip-needs-generic_irq_chip-to-fix-build-er.patch b/queue-5.15/gpio-rockchip-needs-generic_irq_chip-to-fix-build-er.patch new file mode 100644 index 00000000000..7cc97ff4e5f --- /dev/null +++ b/queue-5.15/gpio-rockchip-needs-generic_irq_chip-to-fix-build-er.patch @@ -0,0 +1,50 @@ +From 825ca30c2f3deb6fb248a8fd7f5e65a2764c01ba Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 15 Nov 2021 22:46:27 -0800 +Subject: gpio: rockchip: needs GENERIC_IRQ_CHIP to fix build errors + +From: Randy Dunlap + +[ Upstream commit d6912b1251b47e6b04ea8c8881dfb35a6e7a3e29 ] + +gpio-rockchip uses interfaces that are provided by the Kconfig +symbol GENERIC_IRQ_CHIP, so the driver should select that symbol +in order to prevent build errors. + +Fixes these build errors (and more): + +aarch64-linux-ld: drivers/gpio/gpio-rockchip.o: in function `rockchip_irq_disable': +gpio-rockchip.c:(.text+0x454): undefined reference to `irq_gc_mask_set_bit' +aarch64-linux-ld: drivers/gpio/gpio-rockchip.o: in function `rockchip_irq_enable': +gpio-rockchip.c:(.text+0x478): undefined reference to `irq_gc_mask_clr_bit' +aarch64-linux-ld: drivers/gpio/gpio-rockchip.o: in function `rockchip_interrupts_register': +gpio-rockchip.c:(.text+0x518): undefined reference to `irq_generic_chip_ops' +aarch64-linux-ld: gpio-rockchip.c:(.text+0x594): undefined reference to `__irq_alloc_domain_generic_chips' +aarch64-linux-ld: gpio-rockchip.c:(.text+0x5cc): undefined reference to `irq_get_domain_generic_chip' +aarch64-linux-ld: gpio-rockchip.c:(.text+0x5e0): undefined reference to `irq_gc_ack_set_bit' +aarch64-linux-ld: gpio-rockchip.c:(.text+0x604): undefined reference to `irq_gc_set_wake' + +Fixes: 936ee2675eee ("gpio/rockchip: add driver for rockchip gpio") +Signed-off-by: Randy Dunlap +Reported-by: kernel test robot +Signed-off-by: Bartosz Golaszewski +Signed-off-by: Sasha Levin +--- + drivers/gpio/Kconfig | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig +index fae5141251e5d..947474f6abb45 100644 +--- a/drivers/gpio/Kconfig ++++ b/drivers/gpio/Kconfig +@@ -523,6 +523,7 @@ config GPIO_REG + config GPIO_ROCKCHIP + tristate "Rockchip GPIO support" + depends on ARCH_ROCKCHIP || COMPILE_TEST ++ select GENERIC_IRQ_CHIP + select GPIOLIB_IRQCHIP + default ARCH_ROCKCHIP + help +-- +2.33.0 + diff --git a/queue-5.15/hid-multitouch-disable-sticky-fingers-for-uperfect-y.patch b/queue-5.15/hid-multitouch-disable-sticky-fingers-for-uperfect-y.patch new file mode 100644 index 00000000000..02c781d4396 --- /dev/null +++ b/queue-5.15/hid-multitouch-disable-sticky-fingers-for-uperfect-y.patch @@ -0,0 +1,87 @@ +From 983f39aa58488294c23cb584b16c194efce3d5f4 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 1 Oct 2021 19:25:14 +0200 +Subject: HID: multitouch: disable sticky fingers for UPERFECT Y +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: José Expósito + +[ Upstream commit 08b9a61a87bc339a73c584d8924c86ab36d204a7 ] + +When a finger is on the screen, the UPERFECT Y portable touchscreen +monitor reports a contact in the first place. However, after this +initial report, contacts are not reported at the refresh rate of the +screen as required by the Windows 8 specs. + +This behaviour triggers the release_timer, removing the fingers even +though they are still present. + +To avoid it, add a new class, similar to MT_CLS_WIN_8 but without the +MT_QUIRK_STICKY_FINGERS quirk for this device. + +Suggested-by: Benjamin Tissoires +Signed-off-by: José Expósito +Signed-off-by: Jiri Kosina +Signed-off-by: Sasha Levin +--- + drivers/hid/hid-ids.h | 3 +++ + drivers/hid/hid-multitouch.c | 13 +++++++++++++ + 2 files changed, 16 insertions(+) + +diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h +index 29564b370341e..3706c635b12ee 100644 +--- a/drivers/hid/hid-ids.h ++++ b/drivers/hid/hid-ids.h +@@ -1276,6 +1276,9 @@ + #define USB_DEVICE_ID_WEIDA_8752 0xC300 + #define USB_DEVICE_ID_WEIDA_8755 0xC301 + ++#define USB_VENDOR_ID_WINBOND 0x0416 ++#define USB_DEVICE_ID_TSTP_MTOUCH 0xc168 ++ + #define USB_VENDOR_ID_WISEGROUP 0x0925 + #define USB_DEVICE_ID_SMARTJOY_PLUS 0x0005 + #define USB_DEVICE_ID_SUPER_JOY_BOX_3 0x8888 +diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c +index 3ea7cb1cda84c..e1afddb7b33d8 100644 +--- a/drivers/hid/hid-multitouch.c ++++ b/drivers/hid/hid-multitouch.c +@@ -193,6 +193,7 @@ static void mt_post_parse(struct mt_device *td, struct mt_application *app); + /* reserved 0x0014 */ + #define MT_CLS_WIN_8_FORCE_MULTI_INPUT 0x0015 + #define MT_CLS_WIN_8_DISABLE_WAKEUP 0x0016 ++#define MT_CLS_WIN_8_NO_STICKY_FINGERS 0x0017 + + /* vendor specific classes */ + #define MT_CLS_3M 0x0101 +@@ -294,6 +295,13 @@ static const struct mt_class mt_classes[] = { + MT_QUIRK_WIN8_PTP_BUTTONS | + MT_QUIRK_DISABLE_WAKEUP, + .export_all_inputs = true }, ++ { .name = MT_CLS_WIN_8_NO_STICKY_FINGERS, ++ .quirks = MT_QUIRK_ALWAYS_VALID | ++ MT_QUIRK_IGNORE_DUPLICATES | ++ MT_QUIRK_HOVERING | ++ MT_QUIRK_CONTACT_CNT_ACCURATE | ++ MT_QUIRK_WIN8_PTP_BUTTONS, ++ .export_all_inputs = true }, + + /* + * vendor specific classes +@@ -2120,6 +2128,11 @@ static const struct hid_device_id mt_devices[] = { + MT_USB_DEVICE(USB_VENDOR_ID_VTL, + USB_DEVICE_ID_VTL_MULTITOUCH_FF3F) }, + ++ /* Winbond Electronics Corp. */ ++ { .driver_data = MT_CLS_WIN_8_NO_STICKY_FINGERS, ++ HID_DEVICE(HID_BUS_ANY, HID_GROUP_MULTITOUCH_WIN_8, ++ USB_VENDOR_ID_WINBOND, USB_DEVICE_ID_TSTP_MTOUCH) }, ++ + /* Wistron panels */ + { .driver_data = MT_CLS_NSMU, + MT_USB_DEVICE(USB_VENDOR_ID_WISTRON, +-- +2.33.0 + diff --git a/queue-5.15/hid-playstation-require-multicolor-led-functionality.patch b/queue-5.15/hid-playstation-require-multicolor-led-functionality.patch new file mode 100644 index 00000000000..51f6b7cf757 --- /dev/null +++ b/queue-5.15/hid-playstation-require-multicolor-led-functionality.patch @@ -0,0 +1,33 @@ +From e3d2570f947ede21072fd5a08c0d4bc40b6688ea Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 1 Nov 2021 15:12:02 +0100 +Subject: HID: playstation: require multicolor LED functionality + +From: Jiri Kosina + +[ Upstream commit d7f1f9fec09adc1d77092cb2db0e56e2a4efd262 ] + +The driver requires multicolor LED support; express that in Kconfig. + +Reported-by: kernel test robot +Signed-off-by: Jiri Kosina +Signed-off-by: Sasha Levin +--- + drivers/hid/Kconfig | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig +index 3c33bf572d6d3..d78b1c1fb97e9 100644 +--- a/drivers/hid/Kconfig ++++ b/drivers/hid/Kconfig +@@ -868,6 +868,7 @@ config HID_PLANTRONICS + config HID_PLAYSTATION + tristate "PlayStation HID Driver" + depends on HID ++ depends on LEDS_CLASS_MULTICOLOR + select CRC32 + select POWER_SUPPLY + help +-- +2.33.0 + diff --git a/queue-5.15/i40e-fix-changing-previously-set-num_queue_pairs-for.patch b/queue-5.15/i40e-fix-changing-previously-set-num_queue_pairs-for.patch new file mode 100644 index 00000000000..dfb2f361a06 --- /dev/null +++ b/queue-5.15/i40e-fix-changing-previously-set-num_queue_pairs-for.patch @@ -0,0 +1,135 @@ +From 7377a6c217903e236e804c947c6b6b183ff38850 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 23 Apr 2021 13:43:25 +0200 +Subject: i40e: Fix changing previously set num_queue_pairs for PFs + +From: Eryk Rybak + +[ Upstream commit d2a69fefd75683004ffe87166de5635b3267ee07 ] + +Currently, the i40e_vsi_setup_queue_map is basing the count of queues in +TCs on a VSI's alloc_queue_pairs member which is not changed throughout +any user's action (for example via ethtool's set_channels callback). + +This implies that vsi->tc_config.tc_info[n].qcount value that is given +to the kernel via netdev_set_tc_queue() that notifies about the count of +queues per particular traffic class is constant even if user has changed +the total count of queues. + +This in turn caused the kernel warning after setting the queue count to +the lower value than the initial one: + +$ ethtool -l ens801f0 +Channel parameters for ens801f0: +Pre-set maximums: +RX: 0 +TX: 0 +Other: 1 +Combined: 64 +Current hardware settings: +RX: 0 +TX: 0 +Other: 1 +Combined: 64 + +$ ethtool -L ens801f0 combined 40 + +[dmesg] +Number of in use tx queues changed invalidating tc mappings. Priority +traffic classification disabled! + +Reason was that vsi->alloc_queue_pairs stayed at 64 value which was used +to set the qcount on TC0 (by default only TC0 exists so all of the +existing queues are assigned to TC0). we update the offset/qcount via +netdev_set_tc_queue() back to the old value but then the +netif_set_real_num_tx_queues() is using the vsi->num_queue_pairs as a +value which got set to 40. + +Fix it by using vsi->req_queue_pairs as a queue count that will be +distributed across TCs. Do it only for non-zero values, which implies +that user actually requested the new count of queues. + +For VSIs other than main, stay with the vsi->alloc_queue_pairs as we +only allow manipulating the queue count on main VSI. + +Fixes: bc6d33c8d93f ("i40e: Fix the number of queues available to be mapped for use") +Co-developed-by: Maciej Fijalkowski +Signed-off-by: Maciej Fijalkowski +Co-developed-by: Przemyslaw Patynowski +Signed-off-by: Przemyslaw Patynowski +Signed-off-by: Eryk Rybak +Tested-by: Tony Brelinski +Signed-off-by: Tony Nguyen +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/intel/i40e/i40e_main.c | 35 ++++++++++++++------- + 1 file changed, 23 insertions(+), 12 deletions(-) + +diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c +index 9777fa3535830..dc78ffac10371 100644 +--- a/drivers/net/ethernet/intel/i40e/i40e_main.c ++++ b/drivers/net/ethernet/intel/i40e/i40e_main.c +@@ -1790,6 +1790,7 @@ static void i40e_vsi_setup_queue_map(struct i40e_vsi *vsi, + bool is_add) + { + struct i40e_pf *pf = vsi->back; ++ u16 num_tc_qps = 0; + u16 sections = 0; + u8 netdev_tc = 0; + u16 numtc = 1; +@@ -1797,13 +1798,29 @@ static void i40e_vsi_setup_queue_map(struct i40e_vsi *vsi, + u8 offset; + u16 qmap; + int i; +- u16 num_tc_qps = 0; + + sections = I40E_AQ_VSI_PROP_QUEUE_MAP_VALID; + offset = 0; + ++ if (vsi->type == I40E_VSI_MAIN) { ++ /* This code helps add more queue to the VSI if we have ++ * more cores than RSS can support, the higher cores will ++ * be served by ATR or other filters. Furthermore, the ++ * non-zero req_queue_pairs says that user requested a new ++ * queue count via ethtool's set_channels, so use this ++ * value for queues distribution across traffic classes ++ */ ++ if (vsi->req_queue_pairs > 0) ++ vsi->num_queue_pairs = vsi->req_queue_pairs; ++ else if (pf->flags & I40E_FLAG_MSIX_ENABLED) ++ vsi->num_queue_pairs = pf->num_lan_msix; ++ } ++ + /* Number of queues per enabled TC */ +- num_tc_qps = vsi->alloc_queue_pairs; ++ if (vsi->type == I40E_VSI_MAIN) ++ num_tc_qps = vsi->num_queue_pairs; ++ else ++ num_tc_qps = vsi->alloc_queue_pairs; + if (enabled_tc && (vsi->back->flags & I40E_FLAG_DCB_ENABLED)) { + /* Find numtc from enabled TC bitmap */ + for (i = 0, numtc = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) { +@@ -1881,16 +1898,10 @@ static void i40e_vsi_setup_queue_map(struct i40e_vsi *vsi, + } + ctxt->info.tc_mapping[i] = cpu_to_le16(qmap); + } +- +- /* Set actual Tx/Rx queue pairs */ +- vsi->num_queue_pairs = offset; +- if ((vsi->type == I40E_VSI_MAIN) && (numtc == 1)) { +- if (vsi->req_queue_pairs > 0) +- vsi->num_queue_pairs = vsi->req_queue_pairs; +- else if (pf->flags & I40E_FLAG_MSIX_ENABLED) +- vsi->num_queue_pairs = pf->num_lan_msix; +- } +- ++ /* Do not change previously set num_queue_pairs for PFs */ ++ if ((vsi->type == I40E_VSI_MAIN && numtc != 1) || ++ vsi->type != I40E_VSI_MAIN) ++ vsi->num_queue_pairs = offset; + /* Scheduler section valid can only be set for ADD VSI */ + if (is_add) { + sections |= I40E_AQ_VSI_PROP_SCHED_VALID; +-- +2.33.0 + diff --git a/queue-5.15/i40e-fix-correct-max_pkt_size-on-vf-rx-queue.patch b/queue-5.15/i40e-fix-correct-max_pkt_size-on-vf-rx-queue.patch new file mode 100644 index 00000000000..d56ef5d9a2b --- /dev/null +++ b/queue-5.15/i40e-fix-correct-max_pkt_size-on-vf-rx-queue.patch @@ -0,0 +1,118 @@ +From 03626d30b14c0832811a5d05cd752bcfd118e291 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 21 Jan 2021 16:17:22 +0000 +Subject: i40e: Fix correct max_pkt_size on VF RX queue + +From: Eryk Rybak + +[ Upstream commit 6afbd7b3c53cb7417189f476e99d431daccb85b0 ] + +Setting VLAN port increasing RX queue max_pkt_size +by 4 bytes to take VLAN tag into account. +Trigger the VF reset when setting port VLAN for +VF to renegotiate its capabilities and reinitialize. + +Fixes: ba4e003d29c1 ("i40e: don't hold spinlock while resetting VF") +Signed-off-by: Sylwester Dziedziuch +Signed-off-by: Aleksandr Loktionov +Signed-off-by: Eryk Rybak +Tested-by: Konrad Jankowski +Signed-off-by: Tony Nguyen +Signed-off-by: Sasha Levin +--- + .../ethernet/intel/i40e/i40e_virtchnl_pf.c | 53 ++++--------------- + 1 file changed, 9 insertions(+), 44 deletions(-) + +diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +index 472f56b360b8c..815661632e7a7 100644 +--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c ++++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +@@ -674,14 +674,13 @@ static int i40e_config_vsi_rx_queue(struct i40e_vf *vf, u16 vsi_id, + u16 vsi_queue_id, + struct virtchnl_rxq_info *info) + { ++ u16 pf_queue_id = i40e_vc_get_pf_queue_id(vf, vsi_id, vsi_queue_id); + struct i40e_pf *pf = vf->pf; ++ struct i40e_vsi *vsi = pf->vsi[vf->lan_vsi_idx]; + struct i40e_hw *hw = &pf->hw; + struct i40e_hmc_obj_rxq rx_ctx; +- u16 pf_queue_id; + int ret = 0; + +- pf_queue_id = i40e_vc_get_pf_queue_id(vf, vsi_id, vsi_queue_id); +- + /* clear the context structure first */ + memset(&rx_ctx, 0, sizeof(struct i40e_hmc_obj_rxq)); + +@@ -719,6 +718,10 @@ static int i40e_config_vsi_rx_queue(struct i40e_vf *vf, u16 vsi_id, + } + rx_ctx.rxmax = info->max_pkt_size; + ++ /* if port VLAN is configured increase the max packet size */ ++ if (vsi->info.pvid) ++ rx_ctx.rxmax += VLAN_HLEN; ++ + /* enable 32bytes desc always */ + rx_ctx.dsize = 1; + +@@ -4169,34 +4172,6 @@ error_param: + return ret; + } + +-/** +- * i40e_vsi_has_vlans - True if VSI has configured VLANs +- * @vsi: pointer to the vsi +- * +- * Check if a VSI has configured any VLANs. False if we have a port VLAN or if +- * we have no configured VLANs. Do not call while holding the +- * mac_filter_hash_lock. +- */ +-static bool i40e_vsi_has_vlans(struct i40e_vsi *vsi) +-{ +- bool have_vlans; +- +- /* If we have a port VLAN, then the VSI cannot have any VLANs +- * configured, as all MAC/VLAN filters will be assigned to the PVID. +- */ +- if (vsi->info.pvid) +- return false; +- +- /* Since we don't have a PVID, we know that if the device is in VLAN +- * mode it must be because of a VLAN filter configured on this VSI. +- */ +- spin_lock_bh(&vsi->mac_filter_hash_lock); +- have_vlans = i40e_is_vsi_in_vlan(vsi); +- spin_unlock_bh(&vsi->mac_filter_hash_lock); +- +- return have_vlans; +-} +- + /** + * i40e_ndo_set_vf_port_vlan + * @netdev: network interface device structure +@@ -4253,19 +4228,9 @@ int i40e_ndo_set_vf_port_vlan(struct net_device *netdev, int vf_id, + /* duplicate request, so just return success */ + goto error_pvid; + +- if (i40e_vsi_has_vlans(vsi)) { +- dev_err(&pf->pdev->dev, +- "VF %d has already configured VLAN filters and the administrator is requesting a port VLAN override.\nPlease unload and reload the VF driver for this change to take effect.\n", +- vf_id); +- /* Administrator Error - knock the VF offline until he does +- * the right thing by reconfiguring his network correctly +- * and then reloading the VF driver. +- */ +- i40e_vc_disable_vf(vf); +- /* During reset the VF got a new VSI, so refresh the pointer. */ +- vsi = pf->vsi[vf->lan_vsi_idx]; +- } +- ++ i40e_vc_disable_vf(vf); ++ /* During reset the VF got a new VSI, so refresh a pointer. */ ++ vsi = pf->vsi[vf->lan_vsi_idx]; + /* Locked once because multiple functions below iterate list */ + spin_lock_bh(&vsi->mac_filter_hash_lock); + +-- +2.33.0 + diff --git a/queue-5.15/i40e-fix-creation-of-first-queue-by-omitting-it-if-i.patch b/queue-5.15/i40e-fix-creation-of-first-queue-by-omitting-it-if-i.patch new file mode 100644 index 00000000000..c2ef4a224b3 --- /dev/null +++ b/queue-5.15/i40e-fix-creation-of-first-queue-by-omitting-it-if-i.patch @@ -0,0 +1,117 @@ +From 54df701b1a9f7d645383cae75baba089c23c68c2 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 21 Jun 2021 08:37:31 +0000 +Subject: i40e: Fix creation of first queue by omitting it if is not power of + two + +From: Jedrzej Jagielski + +[ Upstream commit 2e6d218c1ec6fb9cd70693b78134cbc35ae0b5a9 ] + +Reject TCs creation with proper message if the first queue +assignment is not equal to the power of two. +The first queue number was checked too late in the second queue +iteration, if second queue was configured at all. Now if first queue value +is not a power of two, then trying to create qdisc will be rejected. + +Fixes: 8f88b3034db3 ("i40e: Add infrastructure for queue channel support") +Signed-off-by: Grzegorz Szczurek +Signed-off-by: Jedrzej Jagielski +Tested-by: Tony Brelinski +Signed-off-by: Tony Nguyen +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/intel/i40e/i40e_main.c | 59 +++++++-------------- + 1 file changed, 19 insertions(+), 40 deletions(-) + +diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c +index 42e26ee5b6d5f..83413999902e5 100644 +--- a/drivers/net/ethernet/intel/i40e/i40e_main.c ++++ b/drivers/net/ethernet/intel/i40e/i40e_main.c +@@ -5786,24 +5786,6 @@ static void i40e_remove_queue_channels(struct i40e_vsi *vsi) + INIT_LIST_HEAD(&vsi->ch_list); + } + +-/** +- * i40e_is_any_channel - channel exist or not +- * @vsi: ptr to VSI to which channels are associated with +- * +- * Returns true or false if channel(s) exist for associated VSI or not +- **/ +-static bool i40e_is_any_channel(struct i40e_vsi *vsi) +-{ +- struct i40e_channel *ch, *ch_tmp; +- +- list_for_each_entry_safe(ch, ch_tmp, &vsi->ch_list, list) { +- if (ch->initialized) +- return true; +- } +- +- return false; +-} +- + /** + * i40e_get_max_queues_for_channel + * @vsi: ptr to VSI to which channels are associated with +@@ -6310,26 +6292,15 @@ int i40e_create_queue_channel(struct i40e_vsi *vsi, + /* By default we are in VEPA mode, if this is the first VF/VMDq + * VSI to be added switch to VEB mode. + */ +- if ((!(pf->flags & I40E_FLAG_VEB_MODE_ENABLED)) || +- (!i40e_is_any_channel(vsi))) { +- if (!is_power_of_2(vsi->tc_config.tc_info[0].qcount)) { +- dev_dbg(&pf->pdev->dev, +- "Failed to create channel. Override queues (%u) not power of 2\n", +- vsi->tc_config.tc_info[0].qcount); +- return -EINVAL; +- } + +- if (!(pf->flags & I40E_FLAG_VEB_MODE_ENABLED)) { +- pf->flags |= I40E_FLAG_VEB_MODE_ENABLED; ++ if (!(pf->flags & I40E_FLAG_VEB_MODE_ENABLED)) { ++ pf->flags |= I40E_FLAG_VEB_MODE_ENABLED; + +- if (vsi->type == I40E_VSI_MAIN) { +- if (pf->flags & I40E_FLAG_TC_MQPRIO) +- i40e_do_reset(pf, I40E_PF_RESET_FLAG, +- true); +- else +- i40e_do_reset_safe(pf, +- I40E_PF_RESET_FLAG); +- } ++ if (vsi->type == I40E_VSI_MAIN) { ++ if (pf->flags & I40E_FLAG_TC_MQPRIO) ++ i40e_do_reset(pf, I40E_PF_RESET_FLAG, true); ++ else ++ i40e_do_reset_safe(pf, I40E_PF_RESET_FLAG); + } + /* now onwards for main VSI, number of queues will be value + * of TC0's queue count +@@ -7982,12 +7953,20 @@ config_tc: + vsi->seid); + need_reset = true; + goto exit; +- } else { +- dev_info(&vsi->back->pdev->dev, +- "Setup channel (id:%u) utilizing num_queues %d\n", +- vsi->seid, vsi->tc_config.tc_info[0].qcount); ++ } else if (enabled_tc && ++ (!is_power_of_2(vsi->tc_config.tc_info[0].qcount))) { ++ netdev_info(netdev, ++ "Failed to create channel. Override queues (%u) not power of 2\n", ++ vsi->tc_config.tc_info[0].qcount); ++ ret = -EINVAL; ++ need_reset = true; ++ goto exit; + } + ++ dev_info(&vsi->back->pdev->dev, ++ "Setup channel (id:%u) utilizing num_queues %d\n", ++ vsi->seid, vsi->tc_config.tc_info[0].qcount); ++ + if (pf->flags & I40E_FLAG_TC_MQPRIO) { + if (vsi->mqprio_qopt.max_rate[0]) { + u64 max_tx_rate = vsi->mqprio_qopt.max_rate[0]; +-- +2.33.0 + diff --git a/queue-5.15/i40e-fix-display-error-code-in-dmesg.patch b/queue-5.15/i40e-fix-display-error-code-in-dmesg.patch new file mode 100644 index 00000000000..0e49e9a2c94 --- /dev/null +++ b/queue-5.15/i40e-fix-display-error-code-in-dmesg.patch @@ -0,0 +1,42 @@ +From dbb789aa1ab0471f2f21dd9522d770d20f8f391f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 29 Oct 2021 11:26:01 +0200 +Subject: i40e: Fix display error code in dmesg + +From: Grzegorz Szczurek + +[ Upstream commit 5aff430d4e33a0b48a6b3d5beb06f79da23f9916 ] + +Fix misleading display error in dmesg if tc filter return fail. +Only i40e status error code should be converted to string, not linux +error code. Otherwise, we return false information about the error. + +Fixes: 2f4b411a3d67 ("i40e: Enable cloud filters via tc-flower") +Signed-off-by: Grzegorz Szczurek +Signed-off-by: Mateusz Palczewski +Tested-by: Dave Switzer +Signed-off-by: Tony Nguyen +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/intel/i40e/i40e_main.c | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c +index 83413999902e5..76d0b809d1340 100644 +--- a/drivers/net/ethernet/intel/i40e/i40e_main.c ++++ b/drivers/net/ethernet/intel/i40e/i40e_main.c +@@ -8531,9 +8531,8 @@ static int i40e_configure_clsflower(struct i40e_vsi *vsi, + err = i40e_add_del_cloud_filter(vsi, filter, true); + + if (err) { +- dev_err(&pf->pdev->dev, +- "Failed to add cloud filter, err %s\n", +- i40e_stat_str(&pf->hw, err)); ++ dev_err(&pf->pdev->dev, "Failed to add cloud filter, err %d\n", ++ err); + goto err; + } + +-- +2.33.0 + diff --git a/queue-5.15/i40e-fix-null-ptr-dereference-on-vsi-filter-sync.patch b/queue-5.15/i40e-fix-null-ptr-dereference-on-vsi-filter-sync.patch new file mode 100644 index 00000000000..7362a307549 --- /dev/null +++ b/queue-5.15/i40e-fix-null-ptr-dereference-on-vsi-filter-sync.patch @@ -0,0 +1,68 @@ +From f7dcae12c525f542a876d10fd9ffae8fd11b94b4 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 24 Feb 2021 12:07:48 +0000 +Subject: i40e: Fix NULL ptr dereference on VSI filter sync + +From: Michal Maloszewski + +[ Upstream commit 37d9e304acd903a445df8208b8a13d707902dea6 ] + +Remove the reason of null pointer dereference in sync VSI filters. +Added new I40E_VSI_RELEASING flag to signalize deleting and releasing +of VSI resources to sync this thread with sync filters subtask. +Without this patch it is possible to start update the VSI filter list +after VSI is removed, that's causing a kernel oops. + +Fixes: 41c445ff0f48 ("i40e: main driver core") +Signed-off-by: Grzegorz Szczurek +Signed-off-by: Michal Maloszewski +Reviewed-by: Przemyslaw Patynowski +Reviewed-by: Witold Fijalkowski +Reviewed-by: Jaroslaw Gawin +Reviewed-by: Aleksandr Loktionov +Tested-by: Tony Brelinski +Signed-off-by: Tony Nguyen +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/intel/i40e/i40e.h | 1 + + drivers/net/ethernet/intel/i40e/i40e_main.c | 5 +++-- + 2 files changed, 4 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h +index 39fb3d57c0574..d7db443abeafa 100644 +--- a/drivers/net/ethernet/intel/i40e/i40e.h ++++ b/drivers/net/ethernet/intel/i40e/i40e.h +@@ -161,6 +161,7 @@ enum i40e_vsi_state_t { + __I40E_VSI_OVERFLOW_PROMISC, + __I40E_VSI_REINIT_REQUESTED, + __I40E_VSI_DOWN_REQUESTED, ++ __I40E_VSI_RELEASING, + /* This must be last as it determines the size of the BITMAP */ + __I40E_VSI_STATE_SIZE__, + }; +diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c +index e04b540cedc85..9777fa3535830 100644 +--- a/drivers/net/ethernet/intel/i40e/i40e_main.c ++++ b/drivers/net/ethernet/intel/i40e/i40e_main.c +@@ -2623,7 +2623,8 @@ static void i40e_sync_filters_subtask(struct i40e_pf *pf) + + for (v = 0; v < pf->num_alloc_vsi; v++) { + if (pf->vsi[v] && +- (pf->vsi[v]->flags & I40E_VSI_FLAG_FILTER_CHANGED)) { ++ (pf->vsi[v]->flags & I40E_VSI_FLAG_FILTER_CHANGED) && ++ !test_bit(__I40E_VSI_RELEASING, pf->vsi[v]->state)) { + int ret = i40e_sync_vsi_filters(pf->vsi[v]); + + if (ret) { +@@ -13771,7 +13772,7 @@ int i40e_vsi_release(struct i40e_vsi *vsi) + dev_info(&pf->pdev->dev, "Can't remove PF VSI\n"); + return -ENODEV; + } +- ++ set_bit(__I40E_VSI_RELEASING, vsi->state); + uplink_seid = vsi->uplink_seid; + if (vsi->type != I40E_VSI_SRIOV) { + if (vsi->netdev_registered) { +-- +2.33.0 + diff --git a/queue-5.15/i40e-fix-ping-is-lost-after-configuring-adq-on-vf.patch b/queue-5.15/i40e-fix-ping-is-lost-after-configuring-adq-on-vf.patch new file mode 100644 index 00000000000..a1bbfe21a3e --- /dev/null +++ b/queue-5.15/i40e-fix-ping-is-lost-after-configuring-adq-on-vf.patch @@ -0,0 +1,184 @@ +From c27b4118336b749a0b7b3312959ef3b3df700cbd Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 23 Apr 2021 13:43:26 +0200 +Subject: i40e: Fix ping is lost after configuring ADq on VF + +From: Eryk Rybak + +[ Upstream commit 9e0a603cb7dce2a19d98116d42de84b6db26d716 ] + +Properly reconfigure VF VSIs after VF request ADQ. +Created new function to update queue mapping and queue pairs per TC +with AQ update VSI. This sets proper RSS size on NIC. +VFs num_queue_pairs should not be changed during setup of queue maps. +Previously, VF main VSI in ADQ had configured too many queues and had +wrong RSS size, which lead to packets not being consumed and drops in +connectivity. + +Fixes: bc6d33c8d93f ("i40e: Fix the number of queues available to be mapped for use") +Co-developed-by: Przemyslaw Patynowski +Signed-off-by: Przemyslaw Patynowski +Signed-off-by: Eryk Rybak +Tested-by: Tony Brelinski +Signed-off-by: Tony Nguyen +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/intel/i40e/i40e.h | 1 + + drivers/net/ethernet/intel/i40e/i40e_main.c | 64 ++++++++++++++++++- + .../ethernet/intel/i40e/i40e_virtchnl_pf.c | 17 +++-- + 3 files changed, 74 insertions(+), 8 deletions(-) + +diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h +index d7db443abeafa..b10bc59c5700f 100644 +--- a/drivers/net/ethernet/intel/i40e/i40e.h ++++ b/drivers/net/ethernet/intel/i40e/i40e.h +@@ -1248,6 +1248,7 @@ void i40e_ptp_restore_hw_time(struct i40e_pf *pf); + void i40e_ptp_init(struct i40e_pf *pf); + void i40e_ptp_stop(struct i40e_pf *pf); + int i40e_ptp_alloc_pins(struct i40e_pf *pf); ++int i40e_update_adq_vsi_queues(struct i40e_vsi *vsi, int vsi_offset); + int i40e_is_vsi_uplink_mode_veb(struct i40e_vsi *vsi); + i40e_status i40e_get_partition_bw_setting(struct i40e_pf *pf); + i40e_status i40e_set_partition_bw_setting(struct i40e_pf *pf); +diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c +index dc78ffac10371..42e26ee5b6d5f 100644 +--- a/drivers/net/ethernet/intel/i40e/i40e_main.c ++++ b/drivers/net/ethernet/intel/i40e/i40e_main.c +@@ -1801,6 +1801,8 @@ static void i40e_vsi_setup_queue_map(struct i40e_vsi *vsi, + + sections = I40E_AQ_VSI_PROP_QUEUE_MAP_VALID; + offset = 0; ++ /* zero out queue mapping, it will get updated on the end of the function */ ++ memset(ctxt->info.queue_mapping, 0, sizeof(ctxt->info.queue_mapping)); + + if (vsi->type == I40E_VSI_MAIN) { + /* This code helps add more queue to the VSI if we have +@@ -1817,10 +1819,12 @@ static void i40e_vsi_setup_queue_map(struct i40e_vsi *vsi, + } + + /* Number of queues per enabled TC */ +- if (vsi->type == I40E_VSI_MAIN) ++ if (vsi->type == I40E_VSI_MAIN || ++ (vsi->type == I40E_VSI_SRIOV && vsi->num_queue_pairs != 0)) + num_tc_qps = vsi->num_queue_pairs; + else + num_tc_qps = vsi->alloc_queue_pairs; ++ + if (enabled_tc && (vsi->back->flags & I40E_FLAG_DCB_ENABLED)) { + /* Find numtc from enabled TC bitmap */ + for (i = 0, numtc = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) { +@@ -1898,10 +1902,12 @@ static void i40e_vsi_setup_queue_map(struct i40e_vsi *vsi, + } + ctxt->info.tc_mapping[i] = cpu_to_le16(qmap); + } +- /* Do not change previously set num_queue_pairs for PFs */ ++ /* Do not change previously set num_queue_pairs for PFs and VFs*/ + if ((vsi->type == I40E_VSI_MAIN && numtc != 1) || +- vsi->type != I40E_VSI_MAIN) ++ (vsi->type == I40E_VSI_SRIOV && vsi->num_queue_pairs == 0) || ++ (vsi->type != I40E_VSI_MAIN && vsi->type != I40E_VSI_SRIOV)) + vsi->num_queue_pairs = offset; ++ + /* Scheduler section valid can only be set for ADD VSI */ + if (is_add) { + sections |= I40E_AQ_VSI_PROP_SCHED_VALID; +@@ -5438,6 +5444,58 @@ static void i40e_vsi_update_queue_map(struct i40e_vsi *vsi, + sizeof(vsi->info.tc_mapping)); + } + ++/** ++ * i40e_update_adq_vsi_queues - update queue mapping for ADq VSI ++ * @vsi: the VSI being reconfigured ++ * @vsi_offset: offset from main VF VSI ++ */ ++int i40e_update_adq_vsi_queues(struct i40e_vsi *vsi, int vsi_offset) ++{ ++ struct i40e_vsi_context ctxt = {}; ++ struct i40e_pf *pf; ++ struct i40e_hw *hw; ++ int ret; ++ ++ if (!vsi) ++ return I40E_ERR_PARAM; ++ pf = vsi->back; ++ hw = &pf->hw; ++ ++ ctxt.seid = vsi->seid; ++ ctxt.pf_num = hw->pf_id; ++ ctxt.vf_num = vsi->vf_id + hw->func_caps.vf_base_id + vsi_offset; ++ ctxt.uplink_seid = vsi->uplink_seid; ++ ctxt.connection_type = I40E_AQ_VSI_CONN_TYPE_NORMAL; ++ ctxt.flags = I40E_AQ_VSI_TYPE_VF; ++ ctxt.info = vsi->info; ++ ++ i40e_vsi_setup_queue_map(vsi, &ctxt, vsi->tc_config.enabled_tc, ++ false); ++ if (vsi->reconfig_rss) { ++ vsi->rss_size = min_t(int, pf->alloc_rss_size, ++ vsi->num_queue_pairs); ++ ret = i40e_vsi_config_rss(vsi); ++ if (ret) { ++ dev_info(&pf->pdev->dev, "Failed to reconfig rss for num_queues\n"); ++ return ret; ++ } ++ vsi->reconfig_rss = false; ++ } ++ ++ ret = i40e_aq_update_vsi_params(hw, &ctxt, NULL); ++ if (ret) { ++ dev_info(&pf->pdev->dev, "Update vsi config failed, err %s aq_err %s\n", ++ i40e_stat_str(hw, ret), ++ i40e_aq_str(hw, hw->aq.asq_last_status)); ++ return ret; ++ } ++ /* update the local VSI info with updated queue map */ ++ i40e_vsi_update_queue_map(vsi, &ctxt); ++ vsi->info.valid_sections = 0; ++ ++ return ret; ++} ++ + /** + * i40e_vsi_config_tc - Configure VSI Tx Scheduler for given TC map + * @vsi: VSI to be configured +diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +index 815661632e7a7..2102db11972a7 100644 +--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c ++++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +@@ -2220,11 +2220,12 @@ static int i40e_vc_config_queues_msg(struct i40e_vf *vf, u8 *msg) + struct virtchnl_vsi_queue_config_info *qci = + (struct virtchnl_vsi_queue_config_info *)msg; + struct virtchnl_queue_pair_info *qpi; +- struct i40e_pf *pf = vf->pf; + u16 vsi_id, vsi_queue_id = 0; +- u16 num_qps_all = 0; ++ struct i40e_pf *pf = vf->pf; + i40e_status aq_ret = 0; + int i, j = 0, idx = 0; ++ struct i40e_vsi *vsi; ++ u16 num_qps_all = 0; + + if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) { + aq_ret = I40E_ERR_PARAM; +@@ -2313,9 +2314,15 @@ static int i40e_vc_config_queues_msg(struct i40e_vf *vf, u8 *msg) + pf->vsi[vf->lan_vsi_idx]->num_queue_pairs = + qci->num_queue_pairs; + } else { +- for (i = 0; i < vf->num_tc; i++) +- pf->vsi[vf->ch[i].vsi_idx]->num_queue_pairs = +- vf->ch[i].num_qps; ++ for (i = 0; i < vf->num_tc; i++) { ++ vsi = pf->vsi[vf->ch[i].vsi_idx]; ++ vsi->num_queue_pairs = vf->ch[i].num_qps; ++ ++ if (i40e_update_adq_vsi_queues(vsi, i)) { ++ aq_ret = I40E_ERR_CONFIG; ++ goto error_param; ++ } ++ } + } + + error_param: +-- +2.33.0 + diff --git a/queue-5.15/i40e-fix-warning-message-and-call-stack-during-rmmod.patch b/queue-5.15/i40e-fix-warning-message-and-call-stack-during-rmmod.patch new file mode 100644 index 00000000000..79b229ed5b2 --- /dev/null +++ b/queue-5.15/i40e-fix-warning-message-and-call-stack-during-rmmod.patch @@ -0,0 +1,163 @@ +From 7b042f79e2a28d2f64fe918e3f04746d3975289f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 28 Apr 2021 10:19:41 +0200 +Subject: i40e: Fix warning message and call stack during rmmod i40e driver + +From: Karen Sornek + +[ Upstream commit 3a3b311e3881172fc8e019b6508f04bc40c92d9d ] + +Restore part of reset functionality used when reset is called +from the VF to reset itself. Without this fix warning message +is displayed when VF is being removed via sysfs. + +Fix the crash of the VF during reset by ensuring +that the PF receives the reset message successfully. +Refactor code to use one function instead of two. + +Fixes: 5c3c48ac6bf5 ("i40e: implement virtual device interface") +Signed-off-by: Grzegorz Szczurek +Signed-off-by: Karen Sornek +Tested-by: Tony Brelinski +Signed-off-by: Tony Nguyen +Signed-off-by: Sasha Levin +--- + .../ethernet/intel/i40e/i40e_virtchnl_pf.c | 53 ++++++++----------- + 1 file changed, 21 insertions(+), 32 deletions(-) + +diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +index 2102db11972a7..80ae264c99ba0 100644 +--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c ++++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +@@ -183,17 +183,18 @@ void i40e_vc_notify_vf_reset(struct i40e_vf *vf) + /***********************misc routines*****************************/ + + /** +- * i40e_vc_disable_vf ++ * i40e_vc_reset_vf + * @vf: pointer to the VF info +- * +- * Disable the VF through a SW reset. ++ * @notify_vf: notify vf about reset or not ++ * Reset VF handler. + **/ +-static inline void i40e_vc_disable_vf(struct i40e_vf *vf) ++static void i40e_vc_reset_vf(struct i40e_vf *vf, bool notify_vf) + { + struct i40e_pf *pf = vf->pf; + int i; + +- i40e_vc_notify_vf_reset(vf); ++ if (notify_vf) ++ i40e_vc_notify_vf_reset(vf); + + /* We want to ensure that an actual reset occurs initiated after this + * function was called. However, we do not want to wait forever, so +@@ -211,9 +212,14 @@ static inline void i40e_vc_disable_vf(struct i40e_vf *vf) + usleep_range(10000, 20000); + } + +- dev_warn(&vf->pf->pdev->dev, +- "Failed to initiate reset for VF %d after 200 milliseconds\n", +- vf->vf_id); ++ if (notify_vf) ++ dev_warn(&vf->pf->pdev->dev, ++ "Failed to initiate reset for VF %d after 200 milliseconds\n", ++ vf->vf_id); ++ else ++ dev_dbg(&vf->pf->pdev->dev, ++ "Failed to initiate reset for VF %d after 200 milliseconds\n", ++ vf->vf_id); + } + + /** +@@ -2108,20 +2114,6 @@ err: + return ret; + } + +-/** +- * i40e_vc_reset_vf_msg +- * @vf: pointer to the VF info +- * +- * called from the VF to reset itself, +- * unlike other virtchnl messages, PF driver +- * doesn't send the response back to the VF +- **/ +-static void i40e_vc_reset_vf_msg(struct i40e_vf *vf) +-{ +- if (test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) +- i40e_reset_vf(vf, false); +-} +- + /** + * i40e_vc_config_promiscuous_mode_msg + * @vf: pointer to the VF info +@@ -2617,8 +2609,7 @@ static int i40e_vc_request_queues_msg(struct i40e_vf *vf, u8 *msg) + } else { + /* successful request */ + vf->num_req_queues = req_pairs; +- i40e_vc_notify_vf_reset(vf); +- i40e_reset_vf(vf, false); ++ i40e_vc_reset_vf(vf, true); + return 0; + } + +@@ -3813,8 +3804,7 @@ static int i40e_vc_add_qch_msg(struct i40e_vf *vf, u8 *msg) + vf->num_req_queues = 0; + + /* reset the VF in order to allocate resources */ +- i40e_vc_notify_vf_reset(vf); +- i40e_reset_vf(vf, false); ++ i40e_vc_reset_vf(vf, true); + + return I40E_SUCCESS; + +@@ -3854,8 +3844,7 @@ static int i40e_vc_del_qch_msg(struct i40e_vf *vf, u8 *msg) + } + + /* reset the VF in order to allocate resources */ +- i40e_vc_notify_vf_reset(vf); +- i40e_reset_vf(vf, false); ++ i40e_vc_reset_vf(vf, true); + + return I40E_SUCCESS; + +@@ -3917,7 +3906,7 @@ int i40e_vc_process_vf_msg(struct i40e_pf *pf, s16 vf_id, u32 v_opcode, + i40e_vc_notify_vf_link_state(vf); + break; + case VIRTCHNL_OP_RESET_VF: +- i40e_vc_reset_vf_msg(vf); ++ i40e_vc_reset_vf(vf, false); + ret = 0; + break; + case VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE: +@@ -4171,7 +4160,7 @@ int i40e_ndo_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac) + /* Force the VF interface down so it has to bring up with new MAC + * address + */ +- i40e_vc_disable_vf(vf); ++ i40e_vc_reset_vf(vf, true); + dev_info(&pf->pdev->dev, "Bring down and up the VF interface to make this change effective.\n"); + + error_param: +@@ -4235,7 +4224,7 @@ int i40e_ndo_set_vf_port_vlan(struct net_device *netdev, int vf_id, + /* duplicate request, so just return success */ + goto error_pvid; + +- i40e_vc_disable_vf(vf); ++ i40e_vc_reset_vf(vf, true); + /* During reset the VF got a new VSI, so refresh a pointer. */ + vsi = pf->vsi[vf->lan_vsi_idx]; + /* Locked once because multiple functions below iterate list */ +@@ -4613,7 +4602,7 @@ int i40e_ndo_set_vf_trust(struct net_device *netdev, int vf_id, bool setting) + goto out; + + vf->trusted = setting; +- i40e_vc_disable_vf(vf); ++ i40e_vc_reset_vf(vf, true); + dev_info(&pf->pdev->dev, "VF %u is now %strusted\n", + vf_id, setting ? "" : "un"); + +-- +2.33.0 + diff --git a/queue-5.15/iavf-check-for-null-in-iavf_fix_features.patch b/queue-5.15/iavf-check-for-null-in-iavf_fix_features.patch new file mode 100644 index 00000000000..ff2059f105b --- /dev/null +++ b/queue-5.15/iavf-check-for-null-in-iavf_fix_features.patch @@ -0,0 +1,41 @@ +From 13c90c9ae229386b63ef31b13cbdef378c2fce18 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 4 Jun 2021 09:48:53 -0700 +Subject: iavf: check for null in iavf_fix_features + +From: Nicholas Nunley + +[ Upstream commit 8a4a126f4be88eb8b5f00a165ab58c35edf4ef76 ] + +If the driver has lost contact with the PF then it enters a disabled state +and frees adapter->vf_res. However, ndo_fix_features can still be called on +the interface, so we need to check for this condition first. Since we have +no information on the features at this time simply leave them unmodified +and return. + +Fixes: c4445aedfe09 ("i40evf: Fix VLAN features") +Signed-off-by: Nicholas Nunley +Tested-by: Tony Brelinski +Signed-off-by: Tony Nguyen +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/intel/iavf/iavf_main.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c +index cada4e0e40b48..12976ccca1b6e 100644 +--- a/drivers/net/ethernet/intel/iavf/iavf_main.c ++++ b/drivers/net/ethernet/intel/iavf/iavf_main.c +@@ -3442,7 +3442,8 @@ static netdev_features_t iavf_fix_features(struct net_device *netdev, + { + struct iavf_adapter *adapter = netdev_priv(netdev); + +- if (!(adapter->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_VLAN)) ++ if (adapter->vf_res && ++ !(adapter->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_VLAN)) + features &= ~(NETIF_F_HW_VLAN_CTAG_TX | + NETIF_F_HW_VLAN_CTAG_RX | + NETIF_F_HW_VLAN_CTAG_FILTER); +-- +2.33.0 + diff --git a/queue-5.15/iavf-don-t-clear-a-lock-we-don-t-hold.patch b/queue-5.15/iavf-don-t-clear-a-lock-we-don-t-hold.patch new file mode 100644 index 00000000000..6bb2e08ee31 --- /dev/null +++ b/queue-5.15/iavf-don-t-clear-a-lock-we-don-t-hold.patch @@ -0,0 +1,42 @@ +From 3badcd6af15dcfa851ebdc457a8859a9ba9fbcf6 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 4 Jun 2021 09:48:55 -0700 +Subject: iavf: don't clear a lock we don't hold + +From: Nicholas Nunley + +[ Upstream commit 2135a8d5c8186bc92901dc00f179ffd50e54c2ac ] + +In iavf_configure_clsflower() the function will bail out if it is unable +to obtain the crit_section lock in a reasonable time. However, it will +clear the lock when exiting, so fix this. + +Fixes: 640a8af5841f ("i40evf: Reorder configure_clsflower to avoid deadlock on error") +Signed-off-by: Nicholas Nunley +Tested-by: Tony Brelinski +Signed-off-by: Tony Nguyen +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/intel/iavf/iavf_main.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c +index 5664a1905e8bb..f64ccf6286ec1 100644 +--- a/drivers/net/ethernet/intel/iavf/iavf_main.c ++++ b/drivers/net/ethernet/intel/iavf/iavf_main.c +@@ -3041,8 +3041,10 @@ static int iavf_configure_clsflower(struct iavf_adapter *adapter, + return -ENOMEM; + + while (!mutex_trylock(&adapter->crit_lock)) { +- if (--count == 0) +- goto err; ++ if (--count == 0) { ++ kfree(filter); ++ return err; ++ } + udelay(1); + } + +-- +2.33.0 + diff --git a/queue-5.15/iavf-fix-failure-to-exit-out-from-last-all-multicast.patch b/queue-5.15/iavf-fix-failure-to-exit-out-from-last-all-multicast.patch new file mode 100644 index 00000000000..1abf0394966 --- /dev/null +++ b/queue-5.15/iavf-fix-failure-to-exit-out-from-last-all-multicast.patch @@ -0,0 +1,41 @@ +From 530a599c7841f0ec4efe812b2345fc52ee7fb562 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 4 Jun 2021 09:48:56 -0700 +Subject: iavf: Fix failure to exit out from last all-multicast mode + +From: Piotr Marczak + +[ Upstream commit 8905072a192fffe9389255489db250c73ecab008 ] + +The driver could only quit allmulti when allmulti and promisc modes are +turn on at the same time. If promisc had been off there was no way to turn +off allmulti mode. +The patch corrects this behavior. Switching allmulti does not depends on +promisc state mode anymore + +Fixes: f42a5c74da99 ("i40e: Add allmulti support for the VF") +Signed-off-by: Piotr Marczak +Tested-by: Tony Brelinski +Signed-off-by: Tony Nguyen +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/intel/iavf/iavf_main.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c +index f64ccf6286ec1..44ea67cb3716b 100644 +--- a/drivers/net/ethernet/intel/iavf/iavf_main.c ++++ b/drivers/net/ethernet/intel/iavf/iavf_main.c +@@ -1630,8 +1630,7 @@ static int iavf_process_aq_command(struct iavf_adapter *adapter) + iavf_set_promiscuous(adapter, FLAG_VF_MULTICAST_PROMISC); + return 0; + } +- +- if ((adapter->aq_required & IAVF_FLAG_AQ_RELEASE_PROMISC) && ++ if ((adapter->aq_required & IAVF_FLAG_AQ_RELEASE_PROMISC) || + (adapter->aq_required & IAVF_FLAG_AQ_RELEASE_ALLMULTI)) { + iavf_set_promiscuous(adapter, 0); + return 0; +-- +2.33.0 + diff --git a/queue-5.15/iavf-fix-for-setting-queues-to-0.patch b/queue-5.15/iavf-fix-for-setting-queues-to-0.patch new file mode 100644 index 00000000000..29c3cdcb2e8 --- /dev/null +++ b/queue-5.15/iavf-fix-for-setting-queues-to-0.patch @@ -0,0 +1,41 @@ +From 2ad0aad611dd3c591e2739d5a008c389c04932df Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 4 Jun 2021 09:49:00 -0700 +Subject: iavf: Fix for setting queues to 0 + +From: Grzegorz Szczurek + +[ Upstream commit 9a6e9e483a9684a34573fd9f9e30ecfb047cb8cb ] + +Now setting combine to 0 will be rejected with the +appropriate error code. +This has been implemented by adding a condition that checks +the value of combine equal to zero. +Without this patch, when the user requested it, no error was +returned and combine was set to the default value for VF. + +Fixes: 5520deb15326 ("iavf: Enable support for up to 16 queues") +Signed-off-by: Grzegorz Szczurek +Tested-by: Tony Brelinski +Signed-off-by: Tony Nguyen +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/intel/iavf/iavf_ethtool.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/ethernet/intel/iavf/iavf_ethtool.c b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c +index 25ee0606e625f..144a776793597 100644 +--- a/drivers/net/ethernet/intel/iavf/iavf_ethtool.c ++++ b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c +@@ -1787,7 +1787,7 @@ static int iavf_set_channels(struct net_device *netdev, + /* All of these should have already been checked by ethtool before this + * even gets to us, but just to be sure. + */ +- if (num_req > adapter->vsi_res->num_queue_pairs) ++ if (num_req == 0 || num_req > adapter->vsi_res->num_queue_pairs) + return -EINVAL; + + if (num_req == adapter->num_active_queues) +-- +2.33.0 + diff --git a/queue-5.15/iavf-fix-for-the-false-positive-asq-arq-errors-while.patch b/queue-5.15/iavf-fix-for-the-false-positive-asq-arq-errors-while.patch new file mode 100644 index 00000000000..4c11c261401 --- /dev/null +++ b/queue-5.15/iavf-fix-for-the-false-positive-asq-arq-errors-while.patch @@ -0,0 +1,43 @@ +From a4448545b7c6b5749910e199c8b639875797fac4 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 4 Jun 2021 09:48:59 -0700 +Subject: iavf: Fix for the false positive ASQ/ARQ errors while issuing VF + reset + +From: Surabhi Boob + +[ Upstream commit 321421b57a12e933f92b228e0e6d0b2c6541f41d ] + +While issuing VF Reset from the guest OS, the VF driver prints +logs about critical / Overflow error detection. This is not an +actual error since the VF_MBX_ARQLEN register is set to all FF's +for a short period of time and the VF would catch the bits set if +it was reading the register during that spike of time. +This patch introduces an additional check to ignore this condition +since the VF is in reset. + +Fixes: 19b73d8efaa4 ("i40evf: Add additional check for reset") +Signed-off-by: Surabhi Boob +Tested-by: Tony Brelinski +Signed-off-by: Tony Nguyen +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/intel/iavf/iavf_main.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c +index 43c33effd4177..d537d50525e3f 100644 +--- a/drivers/net/ethernet/intel/iavf/iavf_main.c ++++ b/drivers/net/ethernet/intel/iavf/iavf_main.c +@@ -2355,7 +2355,7 @@ static void iavf_adminq_task(struct work_struct *work) + + /* check for error indications */ + val = rd32(hw, hw->aq.arq.len); +- if (val == 0xdeadbeef) /* indicates device in reset */ ++ if (val == 0xdeadbeef || val == 0xffffffff) /* device in reset */ + goto freedom; + oldval = val; + if (val & IAVF_VF_ARQLEN1_ARQVFE_MASK) { +-- +2.33.0 + diff --git a/queue-5.15/iavf-fix-return-of-set-the-new-channel-count.patch b/queue-5.15/iavf-fix-return-of-set-the-new-channel-count.patch new file mode 100644 index 00000000000..fc4369abafd --- /dev/null +++ b/queue-5.15/iavf-fix-return-of-set-the-new-channel-count.patch @@ -0,0 +1,62 @@ +From b6495a05d5fe918a4dfe8b78ec2c078daf1f5e4f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 9 Feb 2021 11:59:38 +0000 +Subject: iavf: Fix return of set the new channel count + +From: Mateusz Palczewski + +[ Upstream commit 4e5e6b5d9d1334d3490326b6922a2daaf56a867f ] + +Fixed return correct code from set the new channel count. +Implemented by check if reset is done in appropriate time. +This solution give a extra time to pf for reset vf in case +when user want set new channel count for all vfs. +Without this patch it is possible to return misleading output +code to user and vf reset not to be correctly performed by pf. + +Fixes: 5520deb15326 ("iavf: Enable support for up to 16 queues") +Signed-off-by: Grzegorz Szczurek +Signed-off-by: Mateusz Palczewski +Tested-by: Konrad Jankowski +Signed-off-by: Tony Nguyen +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/intel/iavf/iavf_ethtool.c | 15 +++++++++++++++ + 1 file changed, 15 insertions(+) + +diff --git a/drivers/net/ethernet/intel/iavf/iavf_ethtool.c b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c +index 5a359a0a20ecc..136c801f5584a 100644 +--- a/drivers/net/ethernet/intel/iavf/iavf_ethtool.c ++++ b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c +@@ -1776,6 +1776,7 @@ static int iavf_set_channels(struct net_device *netdev, + { + struct iavf_adapter *adapter = netdev_priv(netdev); + u32 num_req = ch->combined_count; ++ int i; + + if ((adapter->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_ADQ) && + adapter->num_tc) { +@@ -1798,6 +1799,20 @@ static int iavf_set_channels(struct net_device *netdev, + adapter->num_req_queues = num_req; + adapter->flags |= IAVF_FLAG_REINIT_ITR_NEEDED; + iavf_schedule_reset(adapter); ++ ++ /* wait for the reset is done */ ++ for (i = 0; i < IAVF_RESET_WAIT_COMPLETE_COUNT; i++) { ++ msleep(IAVF_RESET_WAIT_MS); ++ if (adapter->flags & IAVF_FLAG_RESET_PENDING) ++ continue; ++ break; ++ } ++ if (i == IAVF_RESET_WAIT_COMPLETE_COUNT) { ++ adapter->flags &= ~IAVF_FLAG_REINIT_ITR_NEEDED; ++ adapter->num_active_queues = num_req; ++ return -EOPNOTSUPP; ++ } ++ + return 0; + } + +-- +2.33.0 + diff --git a/queue-5.15/iavf-free-q_vectors-before-queues-in-iavf_disable_vf.patch b/queue-5.15/iavf-free-q_vectors-before-queues-in-iavf_disable_vf.patch new file mode 100644 index 00000000000..631a5e13fe4 --- /dev/null +++ b/queue-5.15/iavf-free-q_vectors-before-queues-in-iavf_disable_vf.patch @@ -0,0 +1,41 @@ +From 49d8f20d4887d9f37ac70b332f325c6d4d716081 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 4 Jun 2021 09:48:54 -0700 +Subject: iavf: free q_vectors before queues in iavf_disable_vf + +From: Nicholas Nunley + +[ Upstream commit 89f22f129696ab53cfbc608e0a2184d0fea46ac1 ] + +iavf_free_queues() clears adapter->num_active_queues, which +iavf_free_q_vectors() relies on, so swap the order of these two function +calls in iavf_disable_vf(). This resolves a panic encountered when the +interface is disabled and then later brought up again after PF +communication is restored. + +Fixes: 65c7006f234c ("i40evf: assign num_active_queues inside i40evf_alloc_queues") +Signed-off-by: Nicholas Nunley +Tested-by: Tony Brelinski +Signed-off-by: Tony Nguyen +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/intel/iavf/iavf_main.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c +index 12976ccca1b6e..5664a1905e8bb 100644 +--- a/drivers/net/ethernet/intel/iavf/iavf_main.c ++++ b/drivers/net/ethernet/intel/iavf/iavf_main.c +@@ -2074,8 +2074,8 @@ static void iavf_disable_vf(struct iavf_adapter *adapter) + + iavf_free_misc_irq(adapter); + iavf_reset_interrupt_capability(adapter); +- iavf_free_queues(adapter); + iavf_free_q_vectors(adapter); ++ iavf_free_queues(adapter); + memset(adapter->vf_res, 0, IAVF_VIRTCHNL_VF_RESOURCE_SIZE); + iavf_shutdown_adminq(&adapter->hw); + adapter->netdev->flags &= ~IFF_UP; +-- +2.33.0 + diff --git a/queue-5.15/iavf-prevent-accidental-free-of-filter-structure.patch b/queue-5.15/iavf-prevent-accidental-free-of-filter-structure.patch new file mode 100644 index 00000000000..19a71258740 --- /dev/null +++ b/queue-5.15/iavf-prevent-accidental-free-of-filter-structure.patch @@ -0,0 +1,55 @@ +From 2fd238e19fedd42bf848f44206986d421a5e8038 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 4 Jun 2021 09:48:57 -0700 +Subject: iavf: prevent accidental free of filter structure + +From: Jacob Keller + +[ Upstream commit 4f0400803818f2642f066d3eacaf013f23554cc7 ] + +In iavf_config_clsflower, the filter structure could be accidentally +released at the end, if iavf_parse_cls_flower or iavf_handle_tclass ever +return a non-zero but positive value. + +In this case, the function continues through to the end, and will call +kfree() on the filter structure even though it has been added to the +linked list. + +This can actually happen because iavf_parse_cls_flower will return +a positive IAVF_ERR_CONFIG value instead of the traditional negative +error codes. + +Fix this by ensuring that the kfree() check and error checks are +similar. Use the more idiomatic "if (err)" to catch all non-zero error +codes. + +Fixes: 0075fa0fadd0 ("i40evf: Add support to apply cloud filters") +Signed-off-by: Jacob Keller +Tested-by: Tony Brelinski +Signed-off-by: Tony Nguyen +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/intel/iavf/iavf_main.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c +index 44ea67cb3716b..43c33effd4177 100644 +--- a/drivers/net/ethernet/intel/iavf/iavf_main.c ++++ b/drivers/net/ethernet/intel/iavf/iavf_main.c +@@ -3054,11 +3054,11 @@ static int iavf_configure_clsflower(struct iavf_adapter *adapter, + /* start out with flow type and eth type IPv4 to begin with */ + filter->f.flow_type = VIRTCHNL_TCP_V4_FLOW; + err = iavf_parse_cls_flower(adapter, cls_flower, filter); +- if (err < 0) ++ if (err) + goto err; + + err = iavf_handle_tclass(adapter, tc, filter); +- if (err < 0) ++ if (err) + goto err; + + /* add filter to the list */ +-- +2.33.0 + diff --git a/queue-5.15/iavf-restore-vlan-filters-after-link-down.patch b/queue-5.15/iavf-restore-vlan-filters-after-link-down.patch new file mode 100644 index 00000000000..e5b8145eff2 --- /dev/null +++ b/queue-5.15/iavf-restore-vlan-filters-after-link-down.patch @@ -0,0 +1,106 @@ +From 4a72b805a758eb40041b75e1ef9bd21448ee0710 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 4 Jun 2021 09:53:27 -0700 +Subject: iavf: Restore VLAN filters after link down + +From: Akeem G Abodunrin + +[ Upstream commit 4293014230b887d94b68aa460ff00153454a3709 ] + +Restore VLAN filters after the link is brought down, and up - since all +filters are deleted from HW during the netdev link down routine. + +Fixes: ed1f5b58ea01 ("i40evf: remove VLAN filters on close") +Signed-off-by: Akeem G Abodunrin +Tested-by: George Kuruvinakunnel +Signed-off-by: Tony Nguyen +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/intel/iavf/iavf.h | 1 + + drivers/net/ethernet/intel/iavf/iavf_main.c | 35 ++++++++++++++++++--- + 2 files changed, 31 insertions(+), 5 deletions(-) + +diff --git a/drivers/net/ethernet/intel/iavf/iavf.h b/drivers/net/ethernet/intel/iavf/iavf.h +index 68c80f04113c8..46312a4415baf 100644 +--- a/drivers/net/ethernet/intel/iavf/iavf.h ++++ b/drivers/net/ethernet/intel/iavf/iavf.h +@@ -39,6 +39,7 @@ + #include "iavf_txrx.h" + #include "iavf_fdir.h" + #include "iavf_adv_rss.h" ++#include + + #define DEFAULT_DEBUG_LEVEL_SHIFT 3 + #define PFX "iavf: " +diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c +index d537d50525e3f..aaf8a2f396e46 100644 +--- a/drivers/net/ethernet/intel/iavf/iavf_main.c ++++ b/drivers/net/ethernet/intel/iavf/iavf_main.c +@@ -687,6 +687,23 @@ static void iavf_del_vlan(struct iavf_adapter *adapter, u16 vlan) + spin_unlock_bh(&adapter->mac_vlan_list_lock); + } + ++/** ++ * iavf_restore_filters ++ * @adapter: board private structure ++ * ++ * Restore existing non MAC filters when VF netdev comes back up ++ **/ ++static void iavf_restore_filters(struct iavf_adapter *adapter) ++{ ++ /* re-add all VLAN filters */ ++ if (VLAN_ALLOWED(adapter)) { ++ u16 vid; ++ ++ for_each_set_bit(vid, adapter->vsi.active_vlans, VLAN_N_VID) ++ iavf_add_vlan(adapter, vid); ++ } ++} ++ + /** + * iavf_vlan_rx_add_vid - Add a VLAN filter to a device + * @netdev: network device struct +@@ -700,8 +717,11 @@ static int iavf_vlan_rx_add_vid(struct net_device *netdev, + + if (!VLAN_ALLOWED(adapter)) + return -EIO; ++ + if (iavf_add_vlan(adapter, vid) == NULL) + return -ENOMEM; ++ ++ set_bit(vid, adapter->vsi.active_vlans); + return 0; + } + +@@ -716,11 +736,13 @@ static int iavf_vlan_rx_kill_vid(struct net_device *netdev, + { + struct iavf_adapter *adapter = netdev_priv(netdev); + +- if (VLAN_ALLOWED(adapter)) { +- iavf_del_vlan(adapter, vid); +- return 0; +- } +- return -EIO; ++ if (!VLAN_ALLOWED(adapter)) ++ return -EIO; ++ ++ iavf_del_vlan(adapter, vid); ++ clear_bit(vid, adapter->vsi.active_vlans); ++ ++ return 0; + } + + /** +@@ -3248,6 +3270,9 @@ static int iavf_open(struct net_device *netdev) + + spin_unlock_bh(&adapter->mac_vlan_list_lock); + ++ /* Restore VLAN filters that were removed with IFF_DOWN */ ++ iavf_restore_filters(adapter); ++ + iavf_configure(adapter); + + iavf_up_complete(adapter); +-- +2.33.0 + diff --git a/queue-5.15/iavf-validate-pointers.patch b/queue-5.15/iavf-validate-pointers.patch new file mode 100644 index 00000000000..4be11982646 --- /dev/null +++ b/queue-5.15/iavf-validate-pointers.patch @@ -0,0 +1,50 @@ +From 48ec9d4e979170a121ddf341eede4536fad07465 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 4 Jun 2021 09:48:58 -0700 +Subject: iavf: validate pointers + +From: Mitch Williams + +[ Upstream commit 131b0edc4028bb88bb472456b1ddba526cfb7036 ] + +In some cases, the ethtool get_rxfh handler may be called with a null +key or indir parameter. So check these pointers, or you will have a very +bad day. + +Fixes: 43a3d9ba34c9 ("i40evf: Allow PF driver to configure RSS") +Signed-off-by: Mitch Williams +Tested-by: Tony Brelinski +Signed-off-by: Tony Nguyen +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/intel/iavf/iavf_ethtool.c | 13 ++++++------- + 1 file changed, 6 insertions(+), 7 deletions(-) + +diff --git a/drivers/net/ethernet/intel/iavf/iavf_ethtool.c b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c +index 136c801f5584a..25ee0606e625f 100644 +--- a/drivers/net/ethernet/intel/iavf/iavf_ethtool.c ++++ b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c +@@ -1859,14 +1859,13 @@ static int iavf_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key, + + if (hfunc) + *hfunc = ETH_RSS_HASH_TOP; +- if (!indir) +- return 0; +- +- memcpy(key, adapter->rss_key, adapter->rss_key_size); ++ if (key) ++ memcpy(key, adapter->rss_key, adapter->rss_key_size); + +- /* Each 32 bits pointed by 'indir' is stored with a lut entry */ +- for (i = 0; i < adapter->rss_lut_size; i++) +- indir[i] = (u32)adapter->rss_lut[i]; ++ if (indir) ++ /* Each 32 bits pointed by 'indir' is stored with a lut entry */ ++ for (i = 0; i < adapter->rss_lut_size; i++) ++ indir[i] = (u32)adapter->rss_lut[i]; + + return 0; + } +-- +2.33.0 + diff --git a/queue-5.15/iio-imu-st_lsm6dsx-avoid-potential-array-overflow-in.patch b/queue-5.15/iio-imu-st_lsm6dsx-avoid-potential-array-overflow-in.patch new file mode 100644 index 00000000000..9a3647cc8e1 --- /dev/null +++ b/queue-5.15/iio-imu-st_lsm6dsx-avoid-potential-array-overflow-in.patch @@ -0,0 +1,65 @@ +From bc55e0e3bef0a5ae2b85cb6a8184472aa72b7ec1 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 11 Oct 2021 19:40:03 +0800 +Subject: iio: imu: st_lsm6dsx: Avoid potential array overflow in + st_lsm6dsx_set_odr() + +From: Teng Qi + +[ Upstream commit 94be878c882d8d784ff44c639bf55f3b029f85af ] + +The length of hw->settings->odr_table is 2 and ref_sensor->id is an enum +variable whose value is between 0 and 5. +However, the value ST_LSM6DSX_ID_MAX (i.e. 5) is not caught properly in + switch (sensor->id) { + +If ref_sensor->id is ST_LSM6DSX_ID_MAX, an array overflow will ocurrs in +function st_lsm6dsx_check_odr(): + odr_table = &sensor->hw->settings->odr_table[sensor->id]; + +and in function st_lsm6dsx_set_odr(): + reg = &hw->settings->odr_table[ref_sensor->id].reg; + +To avoid this array overflow, handle ST_LSM6DSX_ID_GYRO explicitly and +return -EINVAL for the default case. + +The enum value ST_LSM6DSX_ID_MAX is only present as an easy way to check +the limit and as such is never used, however this is not locally obvious. + +Reported-by: TOTE Robot +Signed-off-by: Teng Qi +Acked-by: Lorenzo Bianconi +Link: https://lore.kernel.org/r/20211011114003.976221-1-starmiku1207184332@gmail.com +Signed-off-by: Jonathan Cameron +Signed-off-by: Sasha Levin +--- + drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +index db45f1fc0b817..8dbf744c5651f 100644 +--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c ++++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +@@ -1279,6 +1279,8 @@ st_lsm6dsx_set_odr(struct st_lsm6dsx_sensor *sensor, u32 req_odr) + int err; + + switch (sensor->id) { ++ case ST_LSM6DSX_ID_GYRO: ++ break; + case ST_LSM6DSX_ID_EXT0: + case ST_LSM6DSX_ID_EXT1: + case ST_LSM6DSX_ID_EXT2: +@@ -1304,8 +1306,8 @@ st_lsm6dsx_set_odr(struct st_lsm6dsx_sensor *sensor, u32 req_odr) + } + break; + } +- default: +- break; ++ default: /* should never occur */ ++ return -EINVAL; + } + + if (req_odr > 0) { +-- +2.33.0 + diff --git a/queue-5.15/iommu-dart-initialize-dart_streams_enable.patch b/queue-5.15/iommu-dart-initialize-dart_streams_enable.patch new file mode 100644 index 00000000000..629d127070d --- /dev/null +++ b/queue-5.15/iommu-dart-initialize-dart_streams_enable.patch @@ -0,0 +1,55 @@ +From 0b443412a45a9594a91649a6aa7cb93219e1673b Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 19 Oct 2021 18:22:53 +0200 +Subject: iommu/dart: Initialize DART_STREAMS_ENABLE +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Sven Peter + +[ Upstream commit 5a009fc1364170b240a4d351b345e69bb3728b3e ] + +DART has an additional global register to control which streams are +isolated. This register is a bit redundant since DART_TCR can already +be used to control isolation and is usually initialized to DART_STREAM_ALL +by the time we get control. Some DARTs (namely the one used for the audio +controller) however have some streams disabled initially. Make sure those +work by initializing DART_STREAMS_ENABLE during reset. + +Reported-by: Martin Povišer +Signed-off-by: Sven Peter +Reviewed-by: Hector Martin +Link: https://lore.kernel.org/r/20211019162253.45919-1-sven@svenpeter.dev +Signed-off-by: Joerg Roedel +Signed-off-by: Sasha Levin +--- + drivers/iommu/apple-dart.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c +index fdfa39ec2a4d4..ad69eeb5ac5ba 100644 +--- a/drivers/iommu/apple-dart.c ++++ b/drivers/iommu/apple-dart.c +@@ -70,6 +70,8 @@ + #define DART_ERROR_ADDR_HI 0x54 + #define DART_ERROR_ADDR_LO 0x50 + ++#define DART_STREAMS_ENABLE 0xfc ++ + #define DART_TCR(sid) (0x100 + 4 * (sid)) + #define DART_TCR_TRANSLATE_ENABLE BIT(7) + #define DART_TCR_BYPASS0_ENABLE BIT(8) +@@ -301,6 +303,9 @@ static int apple_dart_hw_reset(struct apple_dart *dart) + apple_dart_hw_disable_dma(&stream_map); + apple_dart_hw_clear_all_ttbrs(&stream_map); + ++ /* enable all streams globally since TCR is used to control isolation */ ++ writel(DART_STREAM_ALL, dart->regs + DART_STREAMS_ENABLE); ++ + /* clear any pending errors before the interrupt is unmasked */ + writel(readl(dart->regs + DART_ERROR), dart->regs + DART_ERROR); + +-- +2.33.0 + diff --git a/queue-5.15/iommu-vt-d-do-not-falsely-log-intel_iommu-is-unsuppo.patch b/queue-5.15/iommu-vt-d-do-not-falsely-log-intel_iommu-is-unsuppo.patch new file mode 100644 index 00000000000..9125ab6d97c --- /dev/null +++ b/queue-5.15/iommu-vt-d-do-not-falsely-log-intel_iommu-is-unsuppo.patch @@ -0,0 +1,61 @@ +From efce2b081658362d261ea4bc2b8440832b120d8d Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 14 Oct 2021 13:38:31 +0800 +Subject: iommu/vt-d: Do not falsely log intel_iommu is unsupported kernel + option + +From: Tvrtko Ursulin + +[ Upstream commit 5240aed2cd2594fb392239f11b9681e5e1591619 ] + +Handling of intel_iommu kernel command line option should return "true" to +indicate option is valid and so avoid logging it as unknown by the core +parsing code. + +Also log unknown sub-options at the notice level to let user know of +potential typos or similar. + +Reported-by: Eero Tamminen +Signed-off-by: Tvrtko Ursulin +Link: https://lore.kernel.org/r/20210831112947.310080-1-tvrtko.ursulin@linux.intel.com +Signed-off-by: Lu Baolu +Link: https://lore.kernel.org/r/20211014053839.727419-2-baolu.lu@linux.intel.com +Signed-off-by: Joerg Roedel +Signed-off-by: Sasha Levin +--- + drivers/iommu/intel/iommu.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c +index d75f59ae28e6e..9a356075d3450 100644 +--- a/drivers/iommu/intel/iommu.c ++++ b/drivers/iommu/intel/iommu.c +@@ -412,6 +412,7 @@ static int __init intel_iommu_setup(char *str) + { + if (!str) + return -EINVAL; ++ + while (*str) { + if (!strncmp(str, "on", 2)) { + dmar_disabled = 0; +@@ -441,13 +442,16 @@ static int __init intel_iommu_setup(char *str) + } else if (!strncmp(str, "tboot_noforce", 13)) { + pr_info("Intel-IOMMU: not forcing on after tboot. This could expose security risk for tboot\n"); + intel_iommu_tboot_noforce = 1; ++ } else { ++ pr_notice("Unknown option - '%s'\n", str); + } + + str += strcspn(str, ","); + while (*str == ',') + str++; + } +- return 0; ++ ++ return 1; + } + __setup("intel_iommu=", intel_iommu_setup); + +-- +2.33.0 + diff --git a/queue-5.15/kvm-arm64-fix-host-stage-2-finalization.patch b/queue-5.15/kvm-arm64-fix-host-stage-2-finalization.patch new file mode 100644 index 00000000000..0c153f22522 --- /dev/null +++ b/queue-5.15/kvm-arm64-fix-host-stage-2-finalization.patch @@ -0,0 +1,79 @@ +From 5fa615cf33cdb5f7132f470d043ae395e88bcfab Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 8 Nov 2021 15:46:32 +0000 +Subject: KVM: arm64: Fix host stage-2 finalization + +From: Quentin Perret + +[ Upstream commit 50a8d3315960c74095c59e204db44abd937d4b5d ] + +We currently walk the hypervisor stage-1 page-table towards the end of +hyp init in nVHE protected mode and adjust the host page ownership +attributes in its stage-2 in order to get a consistent state from both +point of views. The walk is done on the entire hyp VA space, and expects +to only ever find page-level mappings. While this expectation is +reasonable in the half of hyp VA space that maps memory with a fixed +offset (see the loop in pkvm_create_mappings_locked()), it can be +incorrect in the other half where nothing prevents the usage of block +mappings. For instance, on systems where memory is physically aligned at +an address that happens to maps to a PMD aligned VA in the hyp_vmemmap, +kvm_pgtable_hyp_map() will install block mappings when backing the +hyp_vmemmap, which will later cause finalize_host_mappings() to fail. +Furthermore, it should be noted that all pages backing the hyp_vmemmap +are also mapped in the 'fixed offset range' of the hypervisor, which +implies that finalize_host_mappings() will walk both aliases and update +the host stage-2 attributes twice. The order in which this happens is +unpredictable, though, since the hyp VA layout is highly dependent on +the position of the idmap page, hence resulting in a fragile mess at +best. + +In order to fix all of this, let's restrict the finalization walk to +only cover memory regions in the 'fixed-offset range' of the hyp VA +space and nothing else. This not only fixes a correctness issue, but +will also result in a slighlty faster hyp initialization overall. + +Fixes: 2c50166c62ba ("KVM: arm64: Mark host bss and rodata section as shared") +Signed-off-by: Quentin Perret +Signed-off-by: Marc Zyngier +Link: https://lore.kernel.org/r/20211108154636.393384-1-qperret@google.com +Signed-off-by: Sasha Levin +--- + arch/arm64/kvm/hyp/nvhe/setup.c | 14 ++++++++++++-- + 1 file changed, 12 insertions(+), 2 deletions(-) + +diff --git a/arch/arm64/kvm/hyp/nvhe/setup.c b/arch/arm64/kvm/hyp/nvhe/setup.c +index 57c27846320f4..58ad9c5ba3112 100644 +--- a/arch/arm64/kvm/hyp/nvhe/setup.c ++++ b/arch/arm64/kvm/hyp/nvhe/setup.c +@@ -177,7 +177,7 @@ static int finalize_host_mappings_walker(u64 addr, u64 end, u32 level, + + phys = kvm_pte_to_phys(pte); + if (!addr_is_memory(phys)) +- return 0; ++ return -EINVAL; + + /* + * Adjust the host stage-2 mappings to match the ownership attributes +@@ -206,8 +206,18 @@ static int finalize_host_mappings(void) + .cb = finalize_host_mappings_walker, + .flags = KVM_PGTABLE_WALK_LEAF, + }; ++ int i, ret; ++ ++ for (i = 0; i < hyp_memblock_nr; i++) { ++ struct memblock_region *reg = &hyp_memory[i]; ++ u64 start = (u64)hyp_phys_to_virt(reg->base); ++ ++ ret = kvm_pgtable_walk(&pkvm_pgtable, start, reg->size, &walker); ++ if (ret) ++ return ret; ++ } + +- return kvm_pgtable_walk(&pkvm_pgtable, 0, BIT(pkvm_pgtable.ia_bits), &walker); ++ return 0; + } + + void __noreturn __pkvm_init_finalise(void) +-- +2.33.0 + diff --git a/queue-5.15/mac80211-fix-monitor_sdata-rcu-locking-assertions.patch b/queue-5.15/mac80211-fix-monitor_sdata-rcu-locking-assertions.patch new file mode 100644 index 00000000000..a69aed28f46 --- /dev/null +++ b/queue-5.15/mac80211-fix-monitor_sdata-rcu-locking-assertions.patch @@ -0,0 +1,137 @@ +From ce2030b55c17f631eaf4d42af9ea8c13980c8291 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 12 Nov 2021 13:51:44 +0100 +Subject: mac80211: fix monitor_sdata RCU/locking assertions + +From: Johannes Berg + +[ Upstream commit 6dd2360334f3cb3b45fc1b8194c670090474b87c ] + +Since commit a05829a7222e ("cfg80211: avoid holding the RTNL when +calling the driver") we've not only been protecting the pointer +to monitor_sdata with the RTNL, but also with the wiphy->mtx. This +is relevant in a number of lockdep assertions, e.g. the one we hit +in ieee80211_set_monitor_channel(). However, we're now protecting +all the assignments/dereferences, even the one in interface iter, +with the wiphy->mtx, so switch over the lockdep assertions to that +lock. + +Fixes: a05829a7222e ("cfg80211: avoid holding the RTNL when calling the driver") +Signed-off-by: Johannes Berg +Link: https://lore.kernel.org/r/20211112135143.cb8e8ceffef3.Iaa210f16f6904c8a7a24954fb3396da0ef86ec08@changeid +Signed-off-by: Johannes Berg +Signed-off-by: Sasha Levin +--- + net/mac80211/cfg.c | 12 ++++++++---- + net/mac80211/iface.c | 4 +++- + net/mac80211/util.c | 7 ++++--- + 3 files changed, 15 insertions(+), 8 deletions(-) + +diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c +index d69b31c20fe28..d3f62fd12f0b5 100644 +--- a/net/mac80211/cfg.c ++++ b/net/mac80211/cfg.c +@@ -80,7 +80,8 @@ static int ieee80211_set_mon_options(struct ieee80211_sub_if_data *sdata, + } + + /* also validate MU-MIMO change */ +- monitor_sdata = rtnl_dereference(local->monitor_sdata); ++ monitor_sdata = wiphy_dereference(local->hw.wiphy, ++ local->monitor_sdata); + + if (!monitor_sdata && + (params->vht_mumimo_groups || params->vht_mumimo_follow_addr)) +@@ -810,7 +811,8 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy, + + mutex_lock(&local->mtx); + if (local->use_chanctx) { +- sdata = rtnl_dereference(local->monitor_sdata); ++ sdata = wiphy_dereference(local->hw.wiphy, ++ local->monitor_sdata); + if (sdata) { + ieee80211_vif_release_channel(sdata); + ret = ieee80211_vif_use_channel(sdata, chandef, +@@ -2669,7 +2671,8 @@ static int ieee80211_set_tx_power(struct wiphy *wiphy, + sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); + + if (sdata->vif.type == NL80211_IFTYPE_MONITOR) { +- sdata = rtnl_dereference(local->monitor_sdata); ++ sdata = wiphy_dereference(local->hw.wiphy, ++ local->monitor_sdata); + if (!sdata) + return -EOPNOTSUPP; + } +@@ -2729,7 +2732,8 @@ static int ieee80211_set_tx_power(struct wiphy *wiphy, + mutex_unlock(&local->iflist_mtx); + + if (has_monitor) { +- sdata = rtnl_dereference(local->monitor_sdata); ++ sdata = wiphy_dereference(local->hw.wiphy, ++ local->monitor_sdata); + if (sdata) { + sdata->user_power_level = local->user_power_level; + if (txp_type != sdata->vif.bss_conf.txpower_type) +diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c +index 62c95597704b4..041859b5b71d0 100644 +--- a/net/mac80211/iface.c ++++ b/net/mac80211/iface.c +@@ -588,7 +588,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_do + */ + if (local->suspended) { + WARN_ON(local->wowlan); +- WARN_ON(rtnl_dereference(local->monitor_sdata)); ++ WARN_ON(rcu_access_pointer(local->monitor_sdata)); + return; + } + +@@ -932,6 +932,7 @@ int ieee80211_add_virtual_monitor(struct ieee80211_local *local) + return 0; + + ASSERT_RTNL(); ++ lockdep_assert_wiphy(local->hw.wiphy); + + if (local->monitor_sdata) + return 0; +@@ -999,6 +1000,7 @@ void ieee80211_del_virtual_monitor(struct ieee80211_local *local) + return; + + ASSERT_RTNL(); ++ lockdep_assert_wiphy(local->hw.wiphy); + + mutex_lock(&local->iflist_mtx); + +diff --git a/net/mac80211/util.c b/net/mac80211/util.c +index 49cb96d251695..03ea4f929b997 100644 +--- a/net/mac80211/util.c ++++ b/net/mac80211/util.c +@@ -796,7 +796,7 @@ static void __iterate_interfaces(struct ieee80211_local *local, + + sdata = rcu_dereference_check(local->monitor_sdata, + lockdep_is_held(&local->iflist_mtx) || +- lockdep_rtnl_is_held()); ++ lockdep_is_held(&local->hw.wiphy->mtx)); + if (sdata && + (iter_flags & IEEE80211_IFACE_ITER_RESUME_ALL || !active_only || + sdata->flags & IEEE80211_SDATA_IN_DRIVER)) +@@ -2379,7 +2379,7 @@ int ieee80211_reconfig(struct ieee80211_local *local) + IEEE80211_TPT_LEDTRIG_FL_RADIO, 0); + + /* add interfaces */ +- sdata = rtnl_dereference(local->monitor_sdata); ++ sdata = wiphy_dereference(local->hw.wiphy, local->monitor_sdata); + if (sdata) { + /* in HW restart it exists already */ + WARN_ON(local->resuming); +@@ -2424,7 +2424,8 @@ int ieee80211_reconfig(struct ieee80211_local *local) + WARN_ON(drv_add_chanctx(local, ctx)); + mutex_unlock(&local->chanctx_mtx); + +- sdata = rtnl_dereference(local->monitor_sdata); ++ sdata = wiphy_dereference(local->hw.wiphy, ++ local->monitor_sdata); + if (sdata && ieee80211_sdata_running(sdata)) + ieee80211_assign_chanctx(local, sdata); + } +-- +2.33.0 + diff --git a/queue-5.15/maple-fix-wrong-return-value-of-maple_bus_init.patch b/queue-5.15/maple-fix-wrong-return-value-of-maple_bus_init.patch new file mode 100644 index 00000000000..14d6650dbb8 --- /dev/null +++ b/queue-5.15/maple-fix-wrong-return-value-of-maple_bus_init.patch @@ -0,0 +1,50 @@ +From d836471920bc5cfa40fc75f7dea35a1c01c54f30 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 26 Nov 2020 10:43:11 +0800 +Subject: maple: fix wrong return value of maple_bus_init(). + +From: Lu Wei + +[ Upstream commit bde82ee391fa6d3ad054313c4aa7b726d32515ce ] + +If KMEM_CACHE or maple_alloc_dev failed, the maple_bus_init() will return 0 +rather than error, because the retval is not changed after KMEM_CACHE or +maple_alloc_dev failed. + +Fixes: 17be2d2b1c33 ("sh: Add maple bus support for the SEGA Dreamcast.") +Reported-by: Hulk Robot +Signed-off-by: Lu Wei +Acked-by: John Paul Adrian Glaubitz +Signed-off-by: Rich Felker +Signed-off-by: Sasha Levin +--- + drivers/sh/maple/maple.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/drivers/sh/maple/maple.c b/drivers/sh/maple/maple.c +index bd0fbcdbdefe9..e24e220e56eea 100644 +--- a/drivers/sh/maple/maple.c ++++ b/drivers/sh/maple/maple.c +@@ -834,8 +834,10 @@ static int __init maple_bus_init(void) + + maple_queue_cache = KMEM_CACHE(maple_buffer, SLAB_HWCACHE_ALIGN); + +- if (!maple_queue_cache) ++ if (!maple_queue_cache) { ++ retval = -ENOMEM; + goto cleanup_bothirqs; ++ } + + INIT_LIST_HEAD(&maple_waitq); + INIT_LIST_HEAD(&maple_sentq); +@@ -848,6 +850,7 @@ static int __init maple_bus_init(void) + if (!mdev[i]) { + while (i-- > 0) + maple_free_dev(mdev[i]); ++ retval = -ENOMEM; + goto cleanup_cache; + } + baseunits[i] = mdev[i]; +-- +2.33.0 + diff --git a/queue-5.15/memory-tegra20-emc-add-runtime-dependency-on-devfreq.patch b/queue-5.15/memory-tegra20-emc-add-runtime-dependency-on-devfreq.patch new file mode 100644 index 00000000000..4d89651f449 --- /dev/null +++ b/queue-5.15/memory-tegra20-emc-add-runtime-dependency-on-devfreq.patch @@ -0,0 +1,38 @@ +From aa121a9e0ef9c3f1776aaf7e2354c7dd5f36dbe4 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 20 Oct 2021 02:15:24 +0300 +Subject: memory: tegra20-emc: Add runtime dependency on devfreq governor + module + +From: Dmitry Osipenko + +[ Upstream commit 14b43c20c283de36131da0cb44f3170b9ffa7630 ] + +Tegra20 EMC driver uses simple devfreq governor. Add simple devfreq +governor to the list of the Tegra20 EMC driver module softdeps to allow +userspace initramfs tools like dracut to automatically pull the devfreq +module into ramfs image together with the EMC module. + +Reported-by: Nicolas Chauvet +Suggested-by: Nicolas Chauvet +Signed-off-by: Dmitry Osipenko +Link: https://lore.kernel.org/r/20211019231524.888-1-digetx@gmail.com +Signed-off-by: Krzysztof Kozlowski +Signed-off-by: Sasha Levin +--- + drivers/memory/tegra/tegra20-emc.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/drivers/memory/tegra/tegra20-emc.c b/drivers/memory/tegra/tegra20-emc.c +index c3462dbc8c22b..6fc90f2160e93 100644 +--- a/drivers/memory/tegra/tegra20-emc.c ++++ b/drivers/memory/tegra/tegra20-emc.c +@@ -1117,4 +1117,5 @@ module_platform_driver(tegra_emc_driver); + + MODULE_AUTHOR("Dmitry Osipenko "); + MODULE_DESCRIPTION("NVIDIA Tegra20 EMC driver"); ++MODULE_SOFTDEP("pre: governor_simpleondemand"); + MODULE_LICENSE("GPL v2"); +-- +2.33.0 + diff --git a/queue-5.15/mips-bcm63xx-add-support-for-clk_get_parent.patch b/queue-5.15/mips-bcm63xx-add-support-for-clk_get_parent.patch new file mode 100644 index 00000000000..bf7c08d880d --- /dev/null +++ b/queue-5.15/mips-bcm63xx-add-support-for-clk_get_parent.patch @@ -0,0 +1,65 @@ +From ffeb244c9b434b15dc88e08e6d0978081297b1c4 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 14 Nov 2021 16:42:18 -0800 +Subject: mips: bcm63xx: add support for clk_get_parent() + +From: Randy Dunlap + +[ Upstream commit e8f67482e5a4bc8d0b65d606d08cb60ee123b468 ] + +BCM63XX selects HAVE_LEGACY_CLK but does not provide/support +clk_get_parent(), so add a simple implementation of that +function so that callers of it will build without errors. + +Fixes these build errors: + +mips-linux-ld: drivers/iio/adc/ingenic-adc.o: in function `jz4770_adc_init_clk_div': +ingenic-adc.c:(.text+0xe4): undefined reference to `clk_get_parent' +mips-linux-ld: drivers/iio/adc/ingenic-adc.o: in function `jz4725b_adc_init_clk_div': +ingenic-adc.c:(.text+0x1b8): undefined reference to `clk_get_parent' + +Fixes: e7300d04bd08 ("MIPS: BCM63xx: Add support for the Broadcom BCM63xx family of SOCs." ) +Signed-off-by: Randy Dunlap +Reported-by: kernel test robot +Suggested-by: Russell King (Oracle) +Cc: Artur Rojek +Cc: Paul Cercueil +Cc: linux-mips@vger.kernel.org +Cc: Jonathan Cameron +Cc: Lars-Peter Clausen +Cc: linux-iio@vger.kernel.org +Cc: Florian Fainelli +Cc: Andy Shevchenko +Cc: Russell King +Cc: bcm-kernel-feedback-list@broadcom.com +Cc: Jonas Gorski +Reviewed-by: Andy Shevchenko +Acked-by: Jonathan Cameron +Acked-by: Russell King (Oracle) +Acked-by: Florian Fainelli +Signed-off-by: Thomas Bogendoerfer +Signed-off-by: Sasha Levin +--- + arch/mips/bcm63xx/clk.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/arch/mips/bcm63xx/clk.c b/arch/mips/bcm63xx/clk.c +index 5a3e325275d0d..1c91064cb448b 100644 +--- a/arch/mips/bcm63xx/clk.c ++++ b/arch/mips/bcm63xx/clk.c +@@ -381,6 +381,12 @@ void clk_disable(struct clk *clk) + + EXPORT_SYMBOL(clk_disable); + ++struct clk *clk_get_parent(struct clk *clk) ++{ ++ return NULL; ++} ++EXPORT_SYMBOL(clk_get_parent); ++ + unsigned long clk_get_rate(struct clk *clk) + { + if (!clk) +-- +2.33.0 + diff --git a/queue-5.15/mips-bcm63xx-ensure-that-cpu_supports_32bit_kernel-i.patch b/queue-5.15/mips-bcm63xx-ensure-that-cpu_supports_32bit_kernel-i.patch new file mode 100644 index 00000000000..7bfb8b8faff --- /dev/null +++ b/queue-5.15/mips-bcm63xx-ensure-that-cpu_supports_32bit_kernel-i.patch @@ -0,0 +1,64 @@ +From 447df3e799f3e21579598f5f54c5b6b5b34000a7 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 6 Nov 2021 08:49:11 -0700 +Subject: mips: BCM63XX: ensure that CPU_SUPPORTS_32BIT_KERNEL is set + +From: Randy Dunlap + +[ Upstream commit 5eeaafc8d69373c095e461bdb39e5c9b62228ac5 ] + +Several header files need info on CONFIG_32BIT or CONFIG_64BIT, +but kconfig symbol BCM63XX does not provide that info. This leads +to many build errors, e.g.: + + arch/mips/include/asm/page.h:196:13: error: use of undeclared identifier 'CAC_BASE' + return x - PAGE_OFFSET + PHYS_OFFSET; + arch/mips/include/asm/mach-generic/spaces.h:91:23: note: expanded from macro 'PAGE_OFFSET' + #define PAGE_OFFSET (CAC_BASE + PHYS_OFFSET) + arch/mips/include/asm/io.h:134:28: error: use of undeclared identifier 'CAC_BASE' + return (void *)(address + PAGE_OFFSET - PHYS_OFFSET); + arch/mips/include/asm/mach-generic/spaces.h:91:23: note: expanded from macro 'PAGE_OFFSET' + #define PAGE_OFFSET (CAC_BASE + PHYS_OFFSET) + +arch/mips/include/asm/uaccess.h:82:10: error: use of undeclared identifier '__UA_LIMIT' + return (__UA_LIMIT & (addr | (addr + size) | __ua_size(size))) == 0; + +Selecting the SYS_HAS_CPU_BMIPS* symbols causes SYS_HAS_CPU_BMIPS to be +set, which then selects CPU_SUPPORT_32BIT_KERNEL, which causes +CONFIG_32BIT to be set. (a bit more indirect than v1 [RFC].) + +Fixes: e7300d04bd08 ("MIPS: BCM63xx: Add support for the Broadcom BCM63xx family of SOCs.") +Signed-off-by: Randy Dunlap +Reported-by: kernel test robot +Cc: Thomas Bogendoerfer +Cc: Florian Fainelli +Cc: bcm-kernel-feedback-list@broadcom.com +Cc: linux-mips@vger.kernel.org +Cc: Paul Burton +Cc: Maxime Bizon +Cc: Ralf Baechle +Suggested-by: Florian Fainelli +Acked-by: Florian Fainelli +Signed-off-by: Thomas Bogendoerfer +Signed-off-by: Sasha Levin +--- + arch/mips/Kconfig | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig +index cbbb302a460eb..a917d408d27d8 100644 +--- a/arch/mips/Kconfig ++++ b/arch/mips/Kconfig +@@ -332,6 +332,9 @@ config BCM63XX + select SYS_SUPPORTS_32BIT_KERNEL + select SYS_SUPPORTS_BIG_ENDIAN + select SYS_HAS_EARLY_PRINTK ++ select SYS_HAS_CPU_BMIPS32_3300 ++ select SYS_HAS_CPU_BMIPS4350 ++ select SYS_HAS_CPU_BMIPS4380 + select SWAP_IO_SPACE + select GPIOLIB + select MIPS_L1_CACHE_SHIFT_4 +-- +2.33.0 + diff --git a/queue-5.15/mips-boot-compressed-add-__bswapdi2-to-target-for-zs.patch b/queue-5.15/mips-boot-compressed-add-__bswapdi2-to-target-for-zs.patch new file mode 100644 index 00000000000..557288589fc --- /dev/null +++ b/queue-5.15/mips-boot-compressed-add-__bswapdi2-to-target-for-zs.patch @@ -0,0 +1,63 @@ +From a7ea8b229ff0d1b9cafd86246172d2dd5e0f28a9 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 9 Nov 2021 19:09:44 -0800 +Subject: MIPS: boot/compressed/: add __bswapdi2() to target for ZSTD + decompression + +From: Randy Dunlap + +[ Upstream commit e2f4b3be1d3c73176db734565b160250cc1300dd ] + +For MIPS pre-boot, when CONFIG_KERNEL_ZSTD=y, the decompressor +function uses __bswapdi2(), so this object file should be added to +the target object file. + +Fixes these build errors: + +mips-linux-ld: arch/mips/boot/compressed/decompress.o: in function `xxh64': +decompress.c:(.text+0x8be0): undefined reference to `__bswapdi2' +mips-linux-ld: decompress.c:(.text+0x8c78): undefined reference to `__bswapdi2' +mips-linux-ld: decompress.c:(.text+0x8d04): undefined reference to `__bswapdi2' +mips-linux-ld: arch/mips/boot/compressed/decompress.o:decompress.c:(.text+0xa010): more undefined references to `__bswapdi2' follow + +Fixes: 0652035a5794 ("asm-generic: unaligned: remove byteshift helpers") +Fixes: cddc40f5617e ("mips: always link byteswap helpers into decompressor") +Signed-off-by: Randy Dunlap +Reported-by: kernel test robot +Cc: Arnd Bergmann +Cc: Thomas Bogendoerfer +Cc: linux-mips@vger.kernel.org +Acked-by: Arnd Bergmann +Signed-off-by: Thomas Bogendoerfer +Signed-off-by: Sasha Levin +--- + arch/mips/boot/compressed/Makefile | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/arch/mips/boot/compressed/Makefile b/arch/mips/boot/compressed/Makefile +index 3548b3b452699..9112bdb86be45 100644 +--- a/arch/mips/boot/compressed/Makefile ++++ b/arch/mips/boot/compressed/Makefile +@@ -56,6 +56,8 @@ $(obj)/uart-ath79.c: $(srctree)/arch/mips/ath79/early_printk.c + + vmlinuzobjs-$(CONFIG_KERNEL_XZ) += $(obj)/ashldi3.o + ++vmlinuzobjs-$(CONFIG_KERNEL_ZSTD) += $(obj)/bswapdi.o ++ + extra-y += ashldi3.c + $(obj)/ashldi3.c: $(obj)/%.c: $(srctree)/lib/%.c FORCE + $(call if_changed,shipped) +@@ -64,6 +66,10 @@ extra-y += bswapsi.c + $(obj)/bswapsi.c: $(obj)/%.c: $(srctree)/arch/mips/lib/%.c FORCE + $(call if_changed,shipped) + ++extra-y += bswapdi.c ++$(obj)/bswapdi.c: $(obj)/%.c: $(srctree)/arch/mips/lib/%.c FORCE ++ $(call if_changed,shipped) ++ + targets := $(notdir $(vmlinuzobjs-y)) + + targets += vmlinux.bin +-- +2.33.0 + diff --git a/queue-5.15/mips-generic-yamon-dt-fix-uninitialized-variable-err.patch b/queue-5.15/mips-generic-yamon-dt-fix-uninitialized-variable-err.patch new file mode 100644 index 00000000000..a694ad78828 --- /dev/null +++ b/queue-5.15/mips-generic-yamon-dt-fix-uninitialized-variable-err.patch @@ -0,0 +1,41 @@ +From 1147ab1138c46074830ade715e3c4f99cf186f5b Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 10 Nov 2021 23:28:24 +0000 +Subject: MIPS: generic/yamon-dt: fix uninitialized variable error + +From: Colin Ian King + +[ Upstream commit 255e51da15baed47531beefd02f222e4dc01f1c1 ] + +In the case where fw_getenv returns an error when fetching values +for ememsizea and memsize then variable phys_memsize is not assigned +a variable and will be uninitialized on a zero check of phys_memsize. +Fix this by initializing phys_memsize to zero. + +Cleans up cppcheck error: +arch/mips/generic/yamon-dt.c:100:7: error: Uninitialized variable: phys_memsize [uninitvar] + +Fixes: f41d2430bbd6 ("MIPS: generic/yamon-dt: Support > 256MB of RAM") +Signed-off-by: Colin Ian King +Signed-off-by: Thomas Bogendoerfer +Signed-off-by: Sasha Levin +--- + arch/mips/generic/yamon-dt.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/arch/mips/generic/yamon-dt.c b/arch/mips/generic/yamon-dt.c +index a3aa22c77cadc..a07a5edbcda78 100644 +--- a/arch/mips/generic/yamon-dt.c ++++ b/arch/mips/generic/yamon-dt.c +@@ -75,7 +75,7 @@ static unsigned int __init gen_fdt_mem_array( + __init int yamon_dt_append_memory(void *fdt, + const struct yamon_mem_region *regions) + { +- unsigned long phys_memsize, memsize; ++ unsigned long phys_memsize = 0, memsize; + __be32 mem_array[2 * MAX_MEM_ARRAY_ENTRIES]; + unsigned int mem_entries; + int i, err, mem_off; +-- +2.33.0 + diff --git a/queue-5.15/mips-lantiq-add-support-for-clk_get_parent.patch b/queue-5.15/mips-lantiq-add-support-for-clk_get_parent.patch new file mode 100644 index 00000000000..0d727e5cb58 --- /dev/null +++ b/queue-5.15/mips-lantiq-add-support-for-clk_get_parent.patch @@ -0,0 +1,53 @@ +From e29f5833f614e73ad672f8b1c458d3e2fe767373 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 14 Nov 2021 17:20:51 -0800 +Subject: mips: lantiq: add support for clk_get_parent() + +From: Randy Dunlap + +[ Upstream commit fc1aabb088860d6cf9dd03612b7a6f0de91ccac2 ] + +Provide a simple implementation of clk_get_parent() in the +lantiq subarch so that callers of it will build without errors. + +Fixes this build error: +ERROR: modpost: "clk_get_parent" [drivers/iio/adc/ingenic-adc.ko] undefined! + +Fixes: 171bb2f19ed6 ("MIPS: Lantiq: Add initial support for Lantiq SoCs") +Signed-off-by: Randy Dunlap +Suggested-by: Russell King (Oracle) +Cc: linux-mips@vger.kernel.org +Cc: John Crispin +Cc: Thomas Bogendoerfer +Cc: Jonathan Cameron +Cc: linux-iio@vger.kernel.org +Cc: Russell King +Cc: Andy Shevchenko +Acked-by: Jonathan Cameron +Acked-by: John Crispin +Signed-off-by: Thomas Bogendoerfer +Signed-off-by: Sasha Levin +--- + arch/mips/lantiq/clk.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/arch/mips/lantiq/clk.c b/arch/mips/lantiq/clk.c +index dd819e31fcbbf..4916cccf378fd 100644 +--- a/arch/mips/lantiq/clk.c ++++ b/arch/mips/lantiq/clk.c +@@ -158,6 +158,12 @@ void clk_deactivate(struct clk *clk) + } + EXPORT_SYMBOL(clk_deactivate); + ++struct clk *clk_get_parent(struct clk *clk) ++{ ++ return NULL; ++} ++EXPORT_SYMBOL(clk_get_parent); ++ + static inline u32 get_counter_resolution(void) + { + u32 res; +-- +2.33.0 + diff --git a/queue-5.15/mips-sni-fix-the-build.patch b/queue-5.15/mips-sni-fix-the-build.patch new file mode 100644 index 00000000000..335b5f6c891 --- /dev/null +++ b/queue-5.15/mips-sni-fix-the-build.patch @@ -0,0 +1,54 @@ +From dd9fbe8753a9115dd80276a2de21a82049223d70 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 12 Oct 2021 15:23:12 -0700 +Subject: MIPS: sni: Fix the build +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Bart Van Assche + +[ Upstream commit c91cf42f61dc77b289784ea7b15a8531defa41c0 ] + +This patch fixes the following gcc 10 build error: + +arch/mips/sni/time.c: In function ‘a20r_set_periodic’: +arch/mips/sni/time.c:15:26: error: unsigned conversion from ‘int’ to ‘u8’ {aka ‘volatile unsigned char’} changes value from ‘576’ to ‘64’ [-Werror=overflow] + 15 | #define SNI_COUNTER0_DIV ((SNI_CLOCK_TICK_RATE / SNI_COUNTER2_DIV) / HZ) + | ^ +arch/mips/sni/time.c:21:45: note: in expansion of macro ‘SNI_COUNTER0_DIV’ + 21 | *(volatile u8 *)(A20R_PT_CLOCK_BASE + 0) = SNI_COUNTER0_DIV; + | ^~~~~~~~~~~~~~~~ + +Cc: linux-mips@vger.kernel.org +Signed-off-by: Bart Van Assche +Signed-off-by: Thomas Bogendoerfer +Signed-off-by: Sasha Levin +--- + arch/mips/sni/time.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/arch/mips/sni/time.c b/arch/mips/sni/time.c +index 240bb68ec2478..ff3ba7e778901 100644 +--- a/arch/mips/sni/time.c ++++ b/arch/mips/sni/time.c +@@ -18,14 +18,14 @@ static int a20r_set_periodic(struct clock_event_device *evt) + { + *(volatile u8 *)(A20R_PT_CLOCK_BASE + 12) = 0x34; + wmb(); +- *(volatile u8 *)(A20R_PT_CLOCK_BASE + 0) = SNI_COUNTER0_DIV; ++ *(volatile u8 *)(A20R_PT_CLOCK_BASE + 0) = SNI_COUNTER0_DIV & 0xff; + wmb(); + *(volatile u8 *)(A20R_PT_CLOCK_BASE + 0) = SNI_COUNTER0_DIV >> 8; + wmb(); + + *(volatile u8 *)(A20R_PT_CLOCK_BASE + 12) = 0xb4; + wmb(); +- *(volatile u8 *)(A20R_PT_CLOCK_BASE + 8) = SNI_COUNTER2_DIV; ++ *(volatile u8 *)(A20R_PT_CLOCK_BASE + 8) = SNI_COUNTER2_DIV & 0xff; + wmb(); + *(volatile u8 *)(A20R_PT_CLOCK_BASE + 8) = SNI_COUNTER2_DIV >> 8; + wmb(); +-- +2.33.0 + diff --git a/queue-5.15/net-bnx2x-fix-variable-dereferenced-before-check.patch b/queue-5.15/net-bnx2x-fix-variable-dereferenced-before-check.patch new file mode 100644 index 00000000000..d38ec3e7143 --- /dev/null +++ b/queue-5.15/net-bnx2x-fix-variable-dereferenced-before-check.patch @@ -0,0 +1,46 @@ +From 7843aa933a4334bc6108bd5dde817b8914467d6a Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 14 Nov 2021 01:36:36 +0300 +Subject: net: bnx2x: fix variable dereferenced before check + +From: Pavel Skripkin + +[ Upstream commit f8885ac89ce310570e5391fe0bf0ec9c7c9b4fdc ] + +Smatch says: + bnx2x_init_ops.h:640 bnx2x_ilt_client_mem_op() + warn: variable dereferenced before check 'ilt' (see line 638) + +Move ilt_cli variable initialization _after_ ilt validation, because +it's unsafe to deref the pointer before validation check. + +Fixes: 523224a3b3cd ("bnx2x, cnic, bnx2i: use new FW/HSI") +Signed-off-by: Pavel Skripkin +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h +index 1835d2e451c01..fc7fce642666c 100644 +--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h ++++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h +@@ -635,11 +635,13 @@ static int bnx2x_ilt_client_mem_op(struct bnx2x *bp, int cli_num, + { + int i, rc; + struct bnx2x_ilt *ilt = BP_ILT(bp); +- struct ilt_client_info *ilt_cli = &ilt->clients[cli_num]; ++ struct ilt_client_info *ilt_cli; + + if (!ilt || !ilt->lines) + return -1; + ++ ilt_cli = &ilt->clients[cli_num]; ++ + if (ilt_cli->flags & (ILT_CLIENT_SKIP_INIT | ILT_CLIENT_SKIP_MEM)) + return 0; + +-- +2.33.0 + diff --git a/queue-5.15/net-dpaa2-eth-fix-use-after-free-in-dpaa2_eth_remove.patch b/queue-5.15/net-dpaa2-eth-fix-use-after-free-in-dpaa2_eth_remove.patch new file mode 100644 index 00000000000..72453a9aac7 --- /dev/null +++ b/queue-5.15/net-dpaa2-eth-fix-use-after-free-in-dpaa2_eth_remove.patch @@ -0,0 +1,40 @@ +From 7f7a083410237cc85406549d2d134ad4af49496f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 16 Nov 2021 18:17:12 +0300 +Subject: net: dpaa2-eth: fix use-after-free in dpaa2_eth_remove + +From: Pavel Skripkin + +[ Upstream commit 9b5a333272a48c2f8b30add7a874e46e8b26129c ] + +Access to netdev after free_netdev() will cause use-after-free bug. +Move debug log before free_netdev() call to avoid it. + +Fixes: 7472dd9f6499 ("staging: fsl-dpaa2/eth: Move print message") +Signed-off-by: Pavel Skripkin +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +index 7065c71ed7b86..f3e443f2d9cf9 100644 +--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c ++++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +@@ -4538,10 +4538,10 @@ static int dpaa2_eth_remove(struct fsl_mc_device *ls_dev) + + fsl_mc_portal_free(priv->mc_io); + +- free_netdev(net_dev); +- + dev_dbg(net_dev->dev.parent, "Removed interface %s\n", net_dev->name); + ++ free_netdev(net_dev); ++ + return 0; + } + +-- +2.33.0 + diff --git a/queue-5.15/net-ipa-disable-holb-drop-when-updating-timer.patch b/queue-5.15/net-ipa-disable-holb-drop-when-updating-timer.patch new file mode 100644 index 00000000000..a01ba4adfab --- /dev/null +++ b/queue-5.15/net-ipa-disable-holb-drop-when-updating-timer.patch @@ -0,0 +1,48 @@ +From 7e44bf8163c2b3295a6720419f0d81b9bfe857e1 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 12 Nov 2021 16:22:10 -0600 +Subject: net: ipa: disable HOLB drop when updating timer + +From: Alex Elder + +[ Upstream commit 816316cacad2b5abd5b41423cf04e4845239abd4 ] + +The head-of-line blocking timer should only be modified when +head-of-line drop is disabled. + +One of the steps in recovering from a modem crash is to enable +dropping of packets with timeout of 0 (immediate). We don't know +how the modem configured its endpoints, so before we program the +timer, we need to ensure HOL_BLOCK is disabled. + +Fixes: 84f9bd12d46db ("soc: qcom: ipa: IPA endpoints") +Signed-off-by: Alex Elder +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + drivers/net/ipa/ipa_endpoint.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c +index 006da4642a0ba..ef790fd0ab56a 100644 +--- a/drivers/net/ipa/ipa_endpoint.c ++++ b/drivers/net/ipa/ipa_endpoint.c +@@ -853,6 +853,7 @@ static void ipa_endpoint_init_hol_block_timer(struct ipa_endpoint *endpoint, + u32 offset; + u32 val; + ++ /* This should only be changed when HOL_BLOCK_EN is disabled */ + offset = IPA_REG_ENDP_INIT_HOL_BLOCK_TIMER_N_OFFSET(endpoint_id); + val = hol_block_timer_val(ipa, microseconds); + iowrite32(val, ipa->reg_virt + offset); +@@ -883,6 +884,7 @@ void ipa_endpoint_modem_hol_block_clear_all(struct ipa *ipa) + if (endpoint->toward_ipa || endpoint->ee_id != GSI_EE_MODEM) + continue; + ++ ipa_endpoint_init_hol_block_enable(endpoint, false); + ipa_endpoint_init_hol_block_timer(endpoint, 0); + ipa_endpoint_init_hol_block_enable(endpoint, true); + } +-- +2.33.0 + diff --git a/queue-5.15/net-ipa-holb-register-sometimes-must-be-written-twic.patch b/queue-5.15/net-ipa-holb-register-sometimes-must-be-written-twic.patch new file mode 100644 index 00000000000..576c86454b1 --- /dev/null +++ b/queue-5.15/net-ipa-holb-register-sometimes-must-be-written-twic.patch @@ -0,0 +1,37 @@ +From 1bda8ecdd00612144872cf0267adfee7136b72b8 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 12 Nov 2021 16:22:09 -0600 +Subject: net: ipa: HOLB register sometimes must be written twice + +From: Alex Elder + +[ Upstream commit 6e228d8cbb1cc6ba78022d406340e901e08d26e0 ] + +Starting with IPA v4.5, the HOL_BLOCK_EN register must be written +twice when enabling head-of-line blocking avoidance. + +Fixes: 84f9bd12d46db ("soc: qcom: ipa: IPA endpoints") +Signed-off-by: Alex Elder +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + drivers/net/ipa/ipa_endpoint.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c +index 5528d97110d56..006da4642a0ba 100644 +--- a/drivers/net/ipa/ipa_endpoint.c ++++ b/drivers/net/ipa/ipa_endpoint.c +@@ -868,6 +868,9 @@ ipa_endpoint_init_hol_block_enable(struct ipa_endpoint *endpoint, bool enable) + val = enable ? HOL_BLOCK_EN_FMASK : 0; + offset = IPA_REG_ENDP_INIT_HOL_BLOCK_EN_N_OFFSET(endpoint_id); + iowrite32(val, endpoint->ipa->reg_virt + offset); ++ /* When enabling, the register must be written twice for IPA v4.5+ */ ++ if (enable && endpoint->ipa->version >= IPA_VERSION_4_5) ++ iowrite32(val, endpoint->ipa->reg_virt + offset); + } + + void ipa_endpoint_modem_hol_block_clear_all(struct ipa *ipa) +-- +2.33.0 + diff --git a/queue-5.15/net-ipa-ipa_resource-fix-wrong-for-loop-range.patch b/queue-5.15/net-ipa-ipa_resource-fix-wrong-for-loop-range.patch new file mode 100644 index 00000000000..bd3b4057674 --- /dev/null +++ b/queue-5.15/net-ipa-ipa_resource-fix-wrong-for-loop-range.patch @@ -0,0 +1,40 @@ +From d29b803d192b58fe8274f8de81932d4a5fefaa76 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 11 Nov 2021 19:37:24 +0100 +Subject: net/ipa: ipa_resource: Fix wrong for loop range + +From: Konrad Dybcio + +[ Upstream commit 27df68d579c67ef6c39a5047559b6a7c08c96219 ] + +The source group count was mistakenly assigned to both dst and src loops. +Fix it to make IPA probe and work again. + +Fixes: 4fd704b3608a ("net: ipa: record number of groups in data") +Acked-by: AngeloGioacchino Del Regno +Reviewed-by: Marijn Suijten +Signed-off-by: Konrad Dybcio +Reviewed-by: Alex Elder +Link: https://lore.kernel.org/r/20211111183724.593478-1-konrad.dybcio@somainline.org +Signed-off-by: Jakub Kicinski +Signed-off-by: Sasha Levin +--- + drivers/net/ipa/ipa_resource.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/ipa/ipa_resource.c b/drivers/net/ipa/ipa_resource.c +index e3da95d694099..06cec71993823 100644 +--- a/drivers/net/ipa/ipa_resource.c ++++ b/drivers/net/ipa/ipa_resource.c +@@ -52,7 +52,7 @@ static bool ipa_resource_limits_valid(struct ipa *ipa, + return false; + } + +- group_count = data->rsrc_group_src_count; ++ group_count = data->rsrc_group_dst_count; + if (!group_count || group_count > IPA_RESOURCE_GROUP_MAX) + return false; + +-- +2.33.0 + diff --git a/queue-5.15/net-mlx5-e-switch-fix-resetting-of-encap-mode-when-e.patch b/queue-5.15/net-mlx5-e-switch-fix-resetting-of-encap-mode-when-e.patch new file mode 100644 index 00000000000..948f6753745 --- /dev/null +++ b/queue-5.15/net-mlx5-e-switch-fix-resetting-of-encap-mode-when-e.patch @@ -0,0 +1,112 @@ +From 3ca94a1c73f3ef31b649c6935b5cbba151520d79 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 20 May 2021 17:09:58 +0300 +Subject: net/mlx5: E-Switch, Fix resetting of encap mode when entering + switchdev + +From: Paul Blakey + +[ Upstream commit d7751d6476185ff754b9dad2cba0c0a6e43ecadc ] + +E-Switch encap mode is relevant only when in switchdev mode. +The RDMA driver can query the encap configuration via +mlx5_eswitch_get_encap_mode(). Make sure it returns the currently +used mode and not the set one. + +This reverts the cited commit which reset the encap mode +on entering switchdev and fixes the original issue properly. + +Fixes: 9a64144d683a ("net/mlx5: E-Switch, Fix default encap mode") +Signed-off-by: Paul Blakey +Reviewed-by: Mark Bloch +Reviewed-by: Maor Dickman +Signed-off-by: Saeed Mahameed +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 9 +++++++-- + .../net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 7 ------- + include/linux/mlx5/eswitch.h | 4 ++-- + 3 files changed, 9 insertions(+), 11 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +index ec136b4992045..5872cc8bf9532 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +@@ -1572,6 +1572,11 @@ int mlx5_eswitch_init(struct mlx5_core_dev *dev) + esw->enabled_vports = 0; + esw->mode = MLX5_ESWITCH_NONE; + esw->offloads.inline_mode = MLX5_INLINE_MODE_NONE; ++ if (MLX5_CAP_ESW_FLOWTABLE_FDB(dev, reformat) && ++ MLX5_CAP_ESW_FLOWTABLE_FDB(dev, decap)) ++ esw->offloads.encap = DEVLINK_ESWITCH_ENCAP_MODE_BASIC; ++ else ++ esw->offloads.encap = DEVLINK_ESWITCH_ENCAP_MODE_NONE; + + dev->priv.eswitch = esw; + BLOCKING_INIT_NOTIFIER_HEAD(&esw->n_head); +@@ -1934,7 +1939,7 @@ free_out: + return err; + } + +-u8 mlx5_eswitch_mode(struct mlx5_core_dev *dev) ++u8 mlx5_eswitch_mode(const struct mlx5_core_dev *dev) + { + struct mlx5_eswitch *esw = dev->priv.eswitch; + +@@ -1948,7 +1953,7 @@ mlx5_eswitch_get_encap_mode(const struct mlx5_core_dev *dev) + struct mlx5_eswitch *esw; + + esw = dev->priv.eswitch; +- return mlx5_esw_allowed(esw) ? esw->offloads.encap : ++ return (mlx5_eswitch_mode(dev) == MLX5_ESWITCH_OFFLOADS) ? esw->offloads.encap : + DEVLINK_ESWITCH_ENCAP_MODE_NONE; + } + EXPORT_SYMBOL(mlx5_eswitch_get_encap_mode); +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +index 0d461e38add37..08534d562d5a9 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +@@ -3141,12 +3141,6 @@ int esw_offloads_enable(struct mlx5_eswitch *esw) + u64 mapping_id; + int err; + +- if (MLX5_CAP_ESW_FLOWTABLE_FDB(esw->dev, reformat) && +- MLX5_CAP_ESW_FLOWTABLE_FDB(esw->dev, decap)) +- esw->offloads.encap = DEVLINK_ESWITCH_ENCAP_MODE_BASIC; +- else +- esw->offloads.encap = DEVLINK_ESWITCH_ENCAP_MODE_NONE; +- + mutex_init(&esw->offloads.termtbl_mutex); + mlx5_rdma_enable_roce(esw->dev); + +@@ -3244,7 +3238,6 @@ void esw_offloads_disable(struct mlx5_eswitch *esw) + esw_offloads_metadata_uninit(esw); + mlx5_rdma_disable_roce(esw->dev); + mutex_destroy(&esw->offloads.termtbl_mutex); +- esw->offloads.encap = DEVLINK_ESWITCH_ENCAP_MODE_NONE; + } + + static int esw_mode_from_devlink(u16 mode, u16 *mlx5_mode) +diff --git a/include/linux/mlx5/eswitch.h b/include/linux/mlx5/eswitch.h +index 4ab5c1fc1270d..a09ed4c8361b6 100644 +--- a/include/linux/mlx5/eswitch.h ++++ b/include/linux/mlx5/eswitch.h +@@ -136,13 +136,13 @@ u32 mlx5_eswitch_get_vport_metadata_for_set(struct mlx5_eswitch *esw, + ESW_TUN_OPTS_SLOW_TABLE_GOTO_VPORT) + #define ESW_TUN_SLOW_TABLE_GOTO_VPORT_MARK ESW_TUN_OPTS_MASK + +-u8 mlx5_eswitch_mode(struct mlx5_core_dev *dev); ++u8 mlx5_eswitch_mode(const struct mlx5_core_dev *dev); + u16 mlx5_eswitch_get_total_vports(const struct mlx5_core_dev *dev); + struct mlx5_core_dev *mlx5_eswitch_get_core_dev(struct mlx5_eswitch *esw); + + #else /* CONFIG_MLX5_ESWITCH */ + +-static inline u8 mlx5_eswitch_mode(struct mlx5_core_dev *dev) ++static inline u8 mlx5_eswitch_mode(const struct mlx5_core_dev *dev) + { + return MLX5_ESWITCH_NONE; + } +-- +2.33.0 + diff --git a/queue-5.15/net-mlx5-e-switch-rebuild-lag-only-when-needed.patch b/queue-5.15/net-mlx5-e-switch-rebuild-lag-only-when-needed.patch new file mode 100644 index 00000000000..7455a50c9c8 --- /dev/null +++ b/queue-5.15/net-mlx5-e-switch-rebuild-lag-only-when-needed.patch @@ -0,0 +1,74 @@ +From 3d28261670ae5cc99741372a8b177ce6cc35481f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 10 Nov 2021 15:19:12 +0000 +Subject: net/mlx5: E-Switch, rebuild lag only when needed + +From: Mark Bloch + +[ Upstream commit 2eb0cb31bc4ce2ede5460cf3ef433b40cf5f040d ] + +A user can enable VFs without changing E-Switch mode, this can happen +when a user moves straight to switchdev mode and only once in switchdev +VFs are enabled via the sysfs interface. + +The cited commit assumed this isn't possible and exposed a single +API function where the E-switch calls into the lag code, breaks the lag +and prevents any other lag operations to take place until the +E-switch update has ended. + +Breaking the hardware lag when it isn't needed can make it such that +hardware lag can't be enabled again. + +In the sysfs call path check if the current E-Switch mode is NONE, +in the context of the function it can only mean the E-Switch is moving +out of NONE mode and the hardware lag should be disabled and enabled +once the mode change has ended. If the mode isn't NONE it means +VFs are about to be enabled and such operation doesn't require +toggling the hardware lag. + +Fixes: cac1eb2cf2e3 ("net/mlx5: Lag, properly lock eswitch if needed") +Signed-off-by: Mark Bloch +Signed-off-by: Saeed Mahameed +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 12 ++++++++++-- + 1 file changed, 10 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +index 5872cc8bf9532..51a8cecc4a7ce 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +@@ -1305,12 +1305,17 @@ abort: + */ + int mlx5_eswitch_enable(struct mlx5_eswitch *esw, int num_vfs) + { ++ bool toggle_lag; + int ret; + + if (!mlx5_esw_allowed(esw)) + return 0; + +- mlx5_lag_disable_change(esw->dev); ++ toggle_lag = esw->mode == MLX5_ESWITCH_NONE; ++ ++ if (toggle_lag) ++ mlx5_lag_disable_change(esw->dev); ++ + down_write(&esw->mode_lock); + if (esw->mode == MLX5_ESWITCH_NONE) { + ret = mlx5_eswitch_enable_locked(esw, MLX5_ESWITCH_LEGACY, num_vfs); +@@ -1324,7 +1329,10 @@ int mlx5_eswitch_enable(struct mlx5_eswitch *esw, int num_vfs) + esw->esw_funcs.num_vfs = num_vfs; + } + up_write(&esw->mode_lock); +- mlx5_lag_enable_change(esw->dev); ++ ++ if (toggle_lag) ++ mlx5_lag_enable_change(esw->dev); ++ + return ret; + } + +-- +2.33.0 + diff --git a/queue-5.15/net-mlx5-e-switch-return-error-if-encap-isn-t-suppor.patch b/queue-5.15/net-mlx5-e-switch-return-error-if-encap-isn-t-suppor.patch new file mode 100644 index 00000000000..9164eb969da --- /dev/null +++ b/queue-5.15/net-mlx5-e-switch-return-error-if-encap-isn-t-suppor.patch @@ -0,0 +1,41 @@ +From a034e3c014ee1e677387ba9209a3797d36c82800 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 1 Nov 2021 16:18:53 +0200 +Subject: net/mlx5: E-Switch, return error if encap isn't supported + +From: Raed Salem + +[ Upstream commit c4c3176739dfa6efcc5b1d1de4b3fd2b51b048c7 ] + +On regular ConnectX HCAs getting encap mode isn't supported when the +E-Switch is in NONE mode. Current code would return no error code when +trying to get encap mode in such case which is wrong. + +Fix by returning error value to indicate failure to caller in such case. + +Fixes: 8e0aa4bc959c ("net/mlx5: E-switch, Protect eswitch mode changes") +Signed-off-by: Raed Salem +Reviewed-by: Mark Bloch +Reviewed-by: Maor Dickman +Signed-off-by: Saeed Mahameed +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +index 08534d562d5a9..0c79e11339362 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +@@ -3581,7 +3581,7 @@ int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink, + *encap = esw->offloads.encap; + unlock: + up_write(&esw->mode_lock); +- return 0; ++ return err; + } + + static bool +-- +2.33.0 + diff --git a/queue-5.15/net-mlx5-lag-update-tracker-when-state-change-event-.patch b/queue-5.15/net-mlx5-lag-update-tracker-when-state-change-event-.patch new file mode 100644 index 00000000000..0b51437e899 --- /dev/null +++ b/queue-5.15/net-mlx5-lag-update-tracker-when-state-change-event-.patch @@ -0,0 +1,100 @@ +From db9653bea8cb8022b83f5ca43301cf3ee2b862b6 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 5 Nov 2021 11:19:48 +0200 +Subject: net/mlx5: Lag, update tracker when state change event received + +From: Maher Sanalla + +[ Upstream commit ae396d85c01c7bdc9eeceecde1f493d03f793465 ] + +Currently, In NETDEV_CHANGELOWERSTATE/NETDEV_CHANGEUPPERSTATE events +handling, tracking is not fully completed if the LAG device is not ready +at the time the events occur. But, we must keep track of the upper and +lower states after receiving the events because RoCE needs this info in +mlx5_lag_get_roce_netdev() - in order to return the corresponding port +that its running on. Returning the wrong (not most recent) port will lead +to gids table being incorrect. + +For example: If during the attachment of a slave to the bond, the other +non-attached port performs pci_reload, then the LAG device is not ready, +but that should not result in dismissing attached slave tracker update +automatically (which is performed in mlx5_handle_changelowerstate()), Since +these events might not come later, which can lead to both bond ports +having tx_enabled=0 - which is not a valid state of LAG bond. + +Fixes: 9b412cc35f00 ("net/mlx5e: Add LAG warning if bond slave is not lag master") +Signed-off-by: Maher Sanalla +Reviewed-by: Mark Bloch +Reviewed-by: Jianbo Liu +Reviewed-by: Roi Dayan +Signed-off-by: Saeed Mahameed +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/mellanox/mlx5/core/lag.c | 28 +++++++++---------- + 1 file changed, 13 insertions(+), 15 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag.c b/drivers/net/ethernet/mellanox/mlx5/core/lag.c +index d2105c1635c34..c19d9327095b2 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/lag.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/lag.c +@@ -565,6 +565,7 @@ static int mlx5_handle_changeupper_event(struct mlx5_lag *ldev, + bool is_bonded, is_in_lag, mode_supported; + int bond_status = 0; + int num_slaves = 0; ++ int changed = 0; + int idx; + + if (!netif_is_lag_master(upper)) +@@ -601,27 +602,27 @@ static int mlx5_handle_changeupper_event(struct mlx5_lag *ldev, + */ + is_in_lag = num_slaves == MLX5_MAX_PORTS && bond_status == 0x3; + +- if (!mlx5_lag_is_ready(ldev) && is_in_lag) { +- NL_SET_ERR_MSG_MOD(info->info.extack, +- "Can't activate LAG offload, PF is configured with more than 64 VFs"); +- return 0; +- } +- + /* Lag mode must be activebackup or hash. */ + mode_supported = tracker->tx_type == NETDEV_LAG_TX_TYPE_ACTIVEBACKUP || + tracker->tx_type == NETDEV_LAG_TX_TYPE_HASH; + +- if (is_in_lag && !mode_supported) +- NL_SET_ERR_MSG_MOD(info->info.extack, +- "Can't activate LAG offload, TX type isn't supported"); +- + is_bonded = is_in_lag && mode_supported; + if (tracker->is_bonded != is_bonded) { + tracker->is_bonded = is_bonded; +- return 1; ++ changed = 1; + } + +- return 0; ++ if (!is_in_lag) ++ return changed; ++ ++ if (!mlx5_lag_is_ready(ldev)) ++ NL_SET_ERR_MSG_MOD(info->info.extack, ++ "Can't activate LAG offload, PF is configured with more than 64 VFs"); ++ else if (!mode_supported) ++ NL_SET_ERR_MSG_MOD(info->info.extack, ++ "Can't activate LAG offload, TX type isn't supported"); ++ ++ return changed; + } + + static int mlx5_handle_changelowerstate_event(struct mlx5_lag *ldev, +@@ -664,9 +665,6 @@ static int mlx5_lag_netdev_event(struct notifier_block *this, + + ldev = container_of(this, struct mlx5_lag, nb); + +- if (!mlx5_lag_is_ready(ldev) && event == NETDEV_CHANGELOWERSTATE) +- return NOTIFY_DONE; +- + tracker = ldev->tracker; + + switch (event) { +-- +2.33.0 + diff --git a/queue-5.15/net-mlx5-update-error-handler-for-uctx-and-umem.patch b/queue-5.15/net-mlx5-update-error-handler-for-uctx-and-umem.patch new file mode 100644 index 00000000000..f02de3f69e4 --- /dev/null +++ b/queue-5.15/net-mlx5-update-error-handler-for-uctx-and-umem.patch @@ -0,0 +1,85 @@ +From ab3936707130309c023ba5e8c7c5f0e222fdb637 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 27 Oct 2021 15:16:14 +0300 +Subject: net/mlx5: Update error handler for UCTX and UMEM + +From: Neta Ostrovsky + +[ Upstream commit ba50cd9451f6c49cf0841c0a4a146ff6a2822699 ] + +In the fast unload flow, the device state is set to internal error, +which indicates that the driver started the destroy process. +In this case, when a destroy command is being executed, it should return +MLX5_CMD_STAT_OK. +Fix MLX5_CMD_OP_DESTROY_UCTX and MLX5_CMD_OP_DESTROY_UMEM to return OK +instead of EIO. + +This fixes a call trace in the umem release process - +[ 2633.536695] Call Trace: +[ 2633.537518] ib_uverbs_remove_one+0xc3/0x140 [ib_uverbs] +[ 2633.538596] remove_client_context+0x8b/0xd0 [ib_core] +[ 2633.539641] disable_device+0x8c/0x130 [ib_core] +[ 2633.540615] __ib_unregister_device+0x35/0xa0 [ib_core] +[ 2633.541640] ib_unregister_device+0x21/0x30 [ib_core] +[ 2633.542663] __mlx5_ib_remove+0x38/0x90 [mlx5_ib] +[ 2633.543640] auxiliary_bus_remove+0x1e/0x30 [auxiliary] +[ 2633.544661] device_release_driver_internal+0x103/0x1f0 +[ 2633.545679] bus_remove_device+0xf7/0x170 +[ 2633.546640] device_del+0x181/0x410 +[ 2633.547606] mlx5_rescan_drivers_locked.part.10+0x63/0x160 [mlx5_core] +[ 2633.548777] mlx5_unregister_device+0x27/0x40 [mlx5_core] +[ 2633.549841] mlx5_uninit_one+0x21/0xc0 [mlx5_core] +[ 2633.550864] remove_one+0x69/0xe0 [mlx5_core] +[ 2633.551819] pci_device_remove+0x3b/0xc0 +[ 2633.552731] device_release_driver_internal+0x103/0x1f0 +[ 2633.553746] unbind_store+0xf6/0x130 +[ 2633.554657] kernfs_fop_write+0x116/0x190 +[ 2633.555567] vfs_write+0xa5/0x1a0 +[ 2633.556407] ksys_write+0x4f/0xb0 +[ 2633.557233] do_syscall_64+0x5b/0x1a0 +[ 2633.558071] entry_SYSCALL_64_after_hwframe+0x65/0xca +[ 2633.559018] RIP: 0033:0x7f9977132648 +[ 2633.559821] Code: 89 02 48 c7 c0 ff ff ff ff eb b3 0f 1f 80 00 00 00 00 f3 0f 1e fa 48 8d 05 55 6f 2d 00 8b 00 85 c0 75 17 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 58 c3 0f 1f 80 00 00 00 00 41 54 49 89 d4 55 +[ 2633.562332] RSP: 002b:00007fffb1a83888 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 +[ 2633.563472] RAX: ffffffffffffffda RBX: 000000000000000c RCX: 00007f9977132648 +[ 2633.564541] RDX: 000000000000000c RSI: 000055b90546e230 RDI: 0000000000000001 +[ 2633.565596] RBP: 000055b90546e230 R08: 00007f9977406860 R09: 00007f9977a54740 +[ 2633.566653] R10: 0000000000000000 R11: 0000000000000246 R12: 00007f99774056e0 +[ 2633.567692] R13: 000000000000000c R14: 00007f9977400880 R15: 000000000000000c +[ 2633.568725] ---[ end trace 10b4fe52945e544d ]--- + +Fixes: 6a6fabbfa3e8 ("net/mlx5: Update pci error handler entries and command translation") +Signed-off-by: Neta Ostrovsky +Reviewed-by: Leon Romanovsky +Signed-off-by: Saeed Mahameed +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c +index db5dfff585c99..c698e4b5381d7 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c +@@ -334,6 +334,8 @@ static int mlx5_internal_err_ret_value(struct mlx5_core_dev *dev, u16 op, + case MLX5_CMD_OP_PAGE_FAULT_RESUME: + case MLX5_CMD_OP_QUERY_ESW_FUNCTIONS: + case MLX5_CMD_OP_DEALLOC_SF: ++ case MLX5_CMD_OP_DESTROY_UCTX: ++ case MLX5_CMD_OP_DESTROY_UMEM: + return MLX5_CMD_STAT_OK; + + case MLX5_CMD_OP_QUERY_HCA_CAP: +@@ -459,9 +461,7 @@ static int mlx5_internal_err_ret_value(struct mlx5_core_dev *dev, u16 op, + case MLX5_CMD_OP_MODIFY_GENERAL_OBJECT: + case MLX5_CMD_OP_QUERY_GENERAL_OBJECT: + case MLX5_CMD_OP_CREATE_UCTX: +- case MLX5_CMD_OP_DESTROY_UCTX: + case MLX5_CMD_OP_CREATE_UMEM: +- case MLX5_CMD_OP_DESTROY_UMEM: + case MLX5_CMD_OP_ALLOC_MEMIC: + case MLX5_CMD_OP_MODIFY_XRQ: + case MLX5_CMD_OP_RELEASE_XRQ_ERROR: +-- +2.33.0 + diff --git a/queue-5.15/net-mlx5e-ct-fix-multiple-allocations-and-memleak-of.patch b/queue-5.15/net-mlx5e-ct-fix-multiple-allocations-and-memleak-of.patch new file mode 100644 index 00000000000..6a844f6939d --- /dev/null +++ b/queue-5.15/net-mlx5e-ct-fix-multiple-allocations-and-memleak-of.patch @@ -0,0 +1,169 @@ +From c1d0fa23bcb9145d5eb1584c90e8b1b760949ed1 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 8 Nov 2021 16:41:05 +0200 +Subject: net/mlx5e: CT, Fix multiple allocations and memleak of mod acts + +From: Roi Dayan + +[ Upstream commit 806401c20a0f9c51b6c8fd7035671e6ca841f6c2 ] + +CT clear action offload adds additional mod hdr actions to the +flow's original mod actions in order to clear the registers which +hold ct_state. +When such flow also includes encap action, a neigh update event +can cause the driver to unoffload the flow and then reoffload it. + +Each time this happens, the ct clear handling adds that same set +of mod hdr actions to reset ct_state until the max of mod hdr +actions is reached. + +Also the driver never releases the allocated mod hdr actions and +causing a memleak. + +Fix above two issues by moving CT clear mod acts allocation +into the parsing actions phase and only use it when offloading the rule. +The release of mod acts will be done in the normal flow_put(). + + backtrace: + [<000000007316e2f3>] krealloc+0x83/0xd0 + [<00000000ef157de1>] mlx5e_mod_hdr_alloc+0x147/0x300 [mlx5_core] + [<00000000970ce4ae>] mlx5e_tc_match_to_reg_set_and_get_id+0xd7/0x240 [mlx5_core] + [<0000000067c5fa17>] mlx5e_tc_match_to_reg_set+0xa/0x20 [mlx5_core] + [<00000000d032eb98>] mlx5_tc_ct_entry_set_registers.isra.0+0x36/0xc0 [mlx5_core] + [<00000000fd23b869>] mlx5_tc_ct_flow_offload+0x272/0x1f10 [mlx5_core] + [<000000004fc24acc>] mlx5e_tc_offload_fdb_rules.part.0+0x150/0x620 [mlx5_core] + [<00000000dc741c17>] mlx5e_tc_encap_flows_add+0x489/0x690 [mlx5_core] + [<00000000e92e49d7>] mlx5e_rep_update_flows+0x6e4/0x9b0 [mlx5_core] + [<00000000f60f5602>] mlx5e_rep_neigh_update+0x39a/0x5d0 [mlx5_core] + +Fixes: 1ef3018f5af3 ("net/mlx5e: CT: Support clear action") +Signed-off-by: Roi Dayan +Reviewed-by: Paul Blakey +Reviewed-by: Maor Dickman +Signed-off-by: Saeed Mahameed +Signed-off-by: Sasha Levin +--- + .../ethernet/mellanox/mlx5/core/en/tc_ct.c | 26 ++++++++++++------- + .../ethernet/mellanox/mlx5/core/en/tc_ct.h | 2 ++ + .../net/ethernet/mellanox/mlx5/core/en_tc.c | 8 ++++-- + 3 files changed, 25 insertions(+), 11 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +index 6c949abcd2e14..bc65151321ec2 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +@@ -1356,9 +1356,13 @@ mlx5_tc_ct_match_add(struct mlx5_tc_ct_priv *priv, + int + mlx5_tc_ct_parse_action(struct mlx5_tc_ct_priv *priv, + struct mlx5_flow_attr *attr, ++ struct mlx5e_tc_mod_hdr_acts *mod_acts, + const struct flow_action_entry *act, + struct netlink_ext_ack *extack) + { ++ bool clear_action = act->ct.action & TCA_CT_ACT_CLEAR; ++ int err; ++ + if (!priv) { + NL_SET_ERR_MSG_MOD(extack, + "offload of ct action isn't available"); +@@ -1369,6 +1373,17 @@ mlx5_tc_ct_parse_action(struct mlx5_tc_ct_priv *priv, + attr->ct_attr.ct_action = act->ct.action; + attr->ct_attr.nf_ft = act->ct.flow_table; + ++ if (!clear_action) ++ goto out; ++ ++ err = mlx5_tc_ct_entry_set_registers(priv, mod_acts, 0, 0, 0, 0); ++ if (err) { ++ NL_SET_ERR_MSG_MOD(extack, "Failed to set registers for ct clear"); ++ return err; ++ } ++ attr->action |= MLX5_FLOW_CONTEXT_ACTION_MOD_HDR; ++ ++out: + return 0; + } + +@@ -1898,23 +1913,16 @@ __mlx5_tc_ct_flow_offload_clear(struct mlx5_tc_ct_priv *ct_priv, + + memcpy(pre_ct_attr, attr, attr_sz); + +- err = mlx5_tc_ct_entry_set_registers(ct_priv, mod_acts, 0, 0, 0, 0); +- if (err) { +- ct_dbg("Failed to set register for ct clear"); +- goto err_set_registers; +- } +- + mod_hdr = mlx5_modify_header_alloc(priv->mdev, ct_priv->ns_type, + mod_acts->num_actions, + mod_acts->actions); + if (IS_ERR(mod_hdr)) { + err = PTR_ERR(mod_hdr); + ct_dbg("Failed to add create ct clear mod hdr"); +- goto err_set_registers; ++ goto err_mod_hdr; + } + + pre_ct_attr->modify_hdr = mod_hdr; +- pre_ct_attr->action |= MLX5_FLOW_CONTEXT_ACTION_MOD_HDR; + + rule = mlx5_tc_rule_insert(priv, orig_spec, pre_ct_attr); + if (IS_ERR(rule)) { +@@ -1930,7 +1938,7 @@ __mlx5_tc_ct_flow_offload_clear(struct mlx5_tc_ct_priv *ct_priv, + + err_insert: + mlx5_modify_header_dealloc(priv->mdev, mod_hdr); +-err_set_registers: ++err_mod_hdr: + netdev_warn(priv->netdev, + "Failed to offload ct clear flow, err %d\n", err); + kfree(pre_ct_attr); +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.h b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.h +index 363329f4aac61..99662af1e41a7 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.h ++++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.h +@@ -110,6 +110,7 @@ int mlx5_tc_ct_add_no_trk_match(struct mlx5_flow_spec *spec); + int + mlx5_tc_ct_parse_action(struct mlx5_tc_ct_priv *priv, + struct mlx5_flow_attr *attr, ++ struct mlx5e_tc_mod_hdr_acts *mod_acts, + const struct flow_action_entry *act, + struct netlink_ext_ack *extack); + +@@ -172,6 +173,7 @@ mlx5_tc_ct_add_no_trk_match(struct mlx5_flow_spec *spec) + static inline int + mlx5_tc_ct_parse_action(struct mlx5_tc_ct_priv *priv, + struct mlx5_flow_attr *attr, ++ struct mlx5e_tc_mod_hdr_acts *mod_acts, + const struct flow_action_entry *act, + struct netlink_ext_ack *extack) + { +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +index d2e7b099b83ab..e3b320b6d85b9 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +@@ -3458,7 +3458,9 @@ static int parse_tc_nic_actions(struct mlx5e_priv *priv, + attr->dest_chain = act->chain_index; + break; + case FLOW_ACTION_CT: +- err = mlx5_tc_ct_parse_action(get_ct_priv(priv), attr, act, extack); ++ err = mlx5_tc_ct_parse_action(get_ct_priv(priv), attr, ++ &parse_attr->mod_hdr_acts, ++ act, extack); + if (err) + return err; + +@@ -4009,7 +4011,9 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv, + NL_SET_ERR_MSG_MOD(extack, "Sample action with connection tracking is not supported"); + return -EOPNOTSUPP; + } +- err = mlx5_tc_ct_parse_action(get_ct_priv(priv), attr, act, extack); ++ err = mlx5_tc_ct_parse_action(get_ct_priv(priv), attr, ++ &parse_attr->mod_hdr_acts, ++ act, extack); + if (err) + return err; + +-- +2.33.0 + diff --git a/queue-5.15/net-mlx5e-ktls-fix-crash-in-rx-resync-flow.patch b/queue-5.15/net-mlx5e-ktls-fix-crash-in-rx-resync-flow.patch new file mode 100644 index 00000000000..d5b2f0b79a7 --- /dev/null +++ b/queue-5.15/net-mlx5e-ktls-fix-crash-in-rx-resync-flow.patch @@ -0,0 +1,89 @@ +From 5c791605d1bec7f1e4c49df636bd5c0882ed2abb Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 15 Sep 2021 13:25:31 +0300 +Subject: net/mlx5e: kTLS, Fix crash in RX resync flow + +From: Tariq Toukan + +[ Upstream commit cc4a9cc03faa6d8db1a6954bb536f2c1e63bdff6 ] + +For the TLS RX resync flow, we maintain a list of TLS contexts +that require some attention, to communicate their resync information +to the HW. +Here we fix list corruptions, by protecting the entries against +movements coming from resync_handle_seq_match(), until their resync +handling in napi is fully completed. + +Fixes: e9ce991bce5b ("net/mlx5e: kTLS, Add resiliency to RX resync failures") +Signed-off-by: Tariq Toukan +Reviewed-by: Maxim Mikityanskiy +Signed-off-by: Saeed Mahameed +Signed-off-by: Sasha Levin +--- + .../mellanox/mlx5/core/en_accel/ktls_rx.c | 23 ++++++++++++++----- + 1 file changed, 17 insertions(+), 6 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c +index 62abce008c7b8..a2a9f68579dd8 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c +@@ -55,6 +55,7 @@ struct mlx5e_ktls_offload_context_rx { + DECLARE_BITMAP(flags, MLX5E_NUM_PRIV_RX_FLAGS); + + /* resync */ ++ spinlock_t lock; /* protects resync fields */ + struct mlx5e_ktls_rx_resync_ctx resync; + struct list_head list; + }; +@@ -386,14 +387,18 @@ static void resync_handle_seq_match(struct mlx5e_ktls_offload_context_rx *priv_r + struct mlx5e_icosq *sq; + bool trigger_poll; + +- memcpy(info->rec_seq, &priv_rx->resync.sw_rcd_sn_be, sizeof(info->rec_seq)); +- + sq = &c->async_icosq; + ktls_resync = sq->ktls_resync; ++ trigger_poll = false; + + spin_lock_bh(&ktls_resync->lock); +- list_add_tail(&priv_rx->list, &ktls_resync->list); +- trigger_poll = !test_and_set_bit(MLX5E_SQ_STATE_PENDING_TLS_RX_RESYNC, &sq->state); ++ spin_lock_bh(&priv_rx->lock); ++ memcpy(info->rec_seq, &priv_rx->resync.sw_rcd_sn_be, sizeof(info->rec_seq)); ++ if (list_empty(&priv_rx->list)) { ++ list_add_tail(&priv_rx->list, &ktls_resync->list); ++ trigger_poll = !test_and_set_bit(MLX5E_SQ_STATE_PENDING_TLS_RX_RESYNC, &sq->state); ++ } ++ spin_unlock_bh(&priv_rx->lock); + spin_unlock_bh(&ktls_resync->lock); + + if (!trigger_poll) +@@ -617,6 +622,8 @@ int mlx5e_ktls_add_rx(struct net_device *netdev, struct sock *sk, + if (err) + goto err_create_key; + ++ INIT_LIST_HEAD(&priv_rx->list); ++ spin_lock_init(&priv_rx->lock); + priv_rx->crypto_info = + *(struct tls12_crypto_info_aes_gcm_128 *)crypto_info; + +@@ -730,10 +737,14 @@ bool mlx5e_ktls_rx_handle_resync_list(struct mlx5e_channel *c, int budget) + priv_rx = list_first_entry(&local_list, + struct mlx5e_ktls_offload_context_rx, + list); ++ spin_lock(&priv_rx->lock); + cseg = post_static_params(sq, priv_rx); +- if (IS_ERR(cseg)) ++ if (IS_ERR(cseg)) { ++ spin_unlock(&priv_rx->lock); + break; +- list_del(&priv_rx->list); ++ } ++ list_del_init(&priv_rx->list); ++ spin_unlock(&priv_rx->lock); + db_cseg = cseg; + } + if (db_cseg) +-- +2.33.0 + diff --git a/queue-5.15/net-mlx5e-nullify-cq-dbg-pointer-in-mlx5_debug_cq_re.patch b/queue-5.15/net-mlx5e-nullify-cq-dbg-pointer-in-mlx5_debug_cq_re.patch new file mode 100644 index 00000000000..3cddcce4c38 --- /dev/null +++ b/queue-5.15/net-mlx5e-nullify-cq-dbg-pointer-in-mlx5_debug_cq_re.patch @@ -0,0 +1,102 @@ +From 69d88e8d35a25de5f6765f9e39de4f6ca10a725f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 26 Oct 2021 11:42:41 +0300 +Subject: net/mlx5e: nullify cq->dbg pointer in mlx5_debug_cq_remove() + +From: Valentine Fatiev + +[ Upstream commit 76ded29d3fcda4928da8849ffc446ea46871c1c2 ] + +Prior to this patch in case mlx5_core_destroy_cq() failed it proceeds +to rest of destroy operations. mlx5_core_destroy_cq() could be called again +by user and cause additional call of mlx5_debug_cq_remove(). +cq->dbg was not nullify in previous call and cause the crash. + +Fix it by nullify cq->dbg pointer after removal. + +Also proceed to destroy operations only if FW return 0 +for MLX5_CMD_OP_DESTROY_CQ command. + +general protection fault, probably for non-canonical address 0x2000300004058: 0000 [#1] SMP PTI +CPU: 5 PID: 1228 Comm: python Not tainted 5.15.0-rc5_for_upstream_min_debug_2021_10_14_11_06 #1 +Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014 +RIP: 0010:lockref_get+0x1/0x60 +Code: 5d e9 53 ff ff ff 48 8d 7f 70 e8 0a 2e 48 00 c7 85 d0 00 00 00 02 +00 00 00 c6 45 70 00 fb 5d c3 c3 cc cc cc cc cc cc cc cc 53 <48> 8b 17 +48 89 fb 85 d2 75 3d 48 89 d0 bf 64 00 00 00 48 89 c1 48 +RSP: 0018:ffff888137dd7a38 EFLAGS: 00010206 +RAX: 0000000000000000 RBX: ffff888107d5f458 RCX: 00000000fffffffe +RDX: 000000000002c2b0 RSI: ffffffff8155e2e0 RDI: 0002000300004058 +RBP: ffff888137dd7a88 R08: 0002000300004058 R09: ffff8881144a9f88 +R10: 0000000000000000 R11: 0000000000000000 R12: ffff8881141d4000 +R13: ffff888137dd7c68 R14: ffff888137dd7d58 R15: ffff888137dd7cc0 +FS: 00007f4644f2a4c0(0000) GS:ffff8887a2d40000(0000) +knlGS:0000000000000000 +CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 +CR2: 000055b4500f4380 CR3: 0000000114f7a003 CR4: 0000000000170ea0 +Call Trace: + simple_recursive_removal+0x33/0x2e0 + ? debugfs_remove+0x60/0x60 + debugfs_remove+0x40/0x60 + mlx5_debug_cq_remove+0x32/0x70 [mlx5_core] + mlx5_core_destroy_cq+0x41/0x1d0 [mlx5_core] + devx_obj_cleanup+0x151/0x330 [mlx5_ib] + ? __pollwait+0xd0/0xd0 + ? xas_load+0x5/0x70 + ? xa_load+0x62/0xa0 + destroy_hw_idr_uobject+0x20/0x80 [ib_uverbs] + uverbs_destroy_uobject+0x3b/0x360 [ib_uverbs] + uobj_destroy+0x54/0xa0 [ib_uverbs] + ib_uverbs_cmd_verbs+0xaf2/0x1160 [ib_uverbs] + ? uverbs_finalize_object+0xd0/0xd0 [ib_uverbs] + ib_uverbs_ioctl+0xc4/0x1b0 [ib_uverbs] + __x64_sys_ioctl+0x3e4/0x8e0 + +Fixes: 94b960b9deff ("net/mlx5e: Fix memory leak in mlx5_core_destroy_cq() error path") +Signed-off-by: Valentine Fatiev +Reviewed-by: Leon Romanovsky +Signed-off-by: Saeed Mahameed +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/mellanox/mlx5/core/cq.c | 5 +++-- + drivers/net/ethernet/mellanox/mlx5/core/debugfs.c | 4 +++- + 2 files changed, 6 insertions(+), 3 deletions(-) + +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cq.c b/drivers/net/ethernet/mellanox/mlx5/core/cq.c +index 02e77ffe5c3e4..5371ad0a12eb5 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/cq.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/cq.c +@@ -164,13 +164,14 @@ int mlx5_core_destroy_cq(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq) + MLX5_SET(destroy_cq_in, in, cqn, cq->cqn); + MLX5_SET(destroy_cq_in, in, uid, cq->uid); + err = mlx5_cmd_exec_in(dev, destroy_cq, in); ++ if (err) ++ return err; + + synchronize_irq(cq->irqn); +- + mlx5_cq_put(cq); + wait_for_completion(&cq->free); + +- return err; ++ return 0; + } + EXPORT_SYMBOL(mlx5_core_destroy_cq); + +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c b/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c +index 07c8d9811bc81..10d195042ab55 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c +@@ -507,6 +507,8 @@ void mlx5_debug_cq_remove(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq) + if (!mlx5_debugfs_root) + return; + +- if (cq->dbg) ++ if (cq->dbg) { + rem_res_tree(cq->dbg); ++ cq->dbg = NULL; ++ } + } +-- +2.33.0 + diff --git a/queue-5.15/net-mlx5e-wait-for-concurrent-flow-deletion-during-n.patch b/queue-5.15/net-mlx5e-wait-for-concurrent-flow-deletion-during-n.patch new file mode 100644 index 00000000000..2c60d9a1a8b --- /dev/null +++ b/queue-5.15/net-mlx5e-wait-for-concurrent-flow-deletion-during-n.patch @@ -0,0 +1,84 @@ +From 00ccb304547b39c0e8631083023e888d99deb6f4 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 21 Oct 2021 18:15:10 +0300 +Subject: net/mlx5e: Wait for concurrent flow deletion during neigh/fib events + +From: Vlad Buslov + +[ Upstream commit 362980eada85b5ea691e5e0d9257a991aa7ade47 ] + +Function mlx5e_take_tmp_flow() skips flows with zero reference count. This +can cause syndrome 0x179e84 when the called from neigh or route update code +and the skipped flow is not removed from the hardware by the time +underlying encap/decap resource is deleted. Add new completion +'del_hw_done' that is completed when flow is unoffloaded. This is safe to +do because flow with reference count zero needs to be detached from +encap/decap entry before its memory is deallocated, which requires taking +the encap_tbl_lock mutex that is held by the event handlers code. + +Fixes: 8914add2c9e5 ("net/mlx5e: Handle FIB events to update tunnel endpoint device") +Signed-off-by: Vlad Buslov +Reviewed-by: Roi Dayan +Signed-off-by: Saeed Mahameed +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/mellanox/mlx5/core/en/tc_priv.h | 1 + + drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c | 8 +++++++- + drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 2 ++ + 3 files changed, 10 insertions(+), 1 deletion(-) + +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_priv.h b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_priv.h +index d1599b7b944bf..c340bf90354a0 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_priv.h ++++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_priv.h +@@ -102,6 +102,7 @@ struct mlx5e_tc_flow { + refcount_t refcnt; + struct rcu_head rcu_head; + struct completion init_done; ++ struct completion del_hw_done; + int tunnel_id; /* the mapped tunnel id of this flow */ + struct mlx5_flow_attr *attr; + }; +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c +index 1c44c6c345f5d..ec0163d75dd25 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c +@@ -221,8 +221,14 @@ static void mlx5e_take_tmp_flow(struct mlx5e_tc_flow *flow, + struct list_head *flow_list, + int index) + { +- if (IS_ERR(mlx5e_flow_get(flow))) ++ if (IS_ERR(mlx5e_flow_get(flow))) { ++ /* Flow is being deleted concurrently. Wait for it to be ++ * unoffloaded from hardware, otherwise deleting encap will ++ * fail. ++ */ ++ wait_for_completion(&flow->del_hw_done); + return; ++ } + wait_for_completion(&flow->init_done); + + flow->tmp_entry_index = index; +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +index 129ff7e0d65cc..d2e7b099b83ab 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +@@ -1544,6 +1544,7 @@ static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv, + else + mlx5e_tc_unoffload_fdb_rules(esw, flow, attr); + } ++ complete_all(&flow->del_hw_done); + + if (mlx5_flow_has_geneve_opt(flow)) + mlx5_geneve_tlv_option_del(priv->mdev->geneve); +@@ -4222,6 +4223,7 @@ mlx5e_alloc_flow(struct mlx5e_priv *priv, int attr_size, + INIT_LIST_HEAD(&flow->l3_to_l2_reformat); + refcount_set(&flow->refcnt, 1); + init_completion(&flow->init_done); ++ init_completion(&flow->del_hw_done); + + *__flow = flow; + *__parse_attr = parse_attr; +-- +2.33.0 + diff --git a/queue-5.15/net-mvmdio-fix-compilation-warning.patch b/queue-5.15/net-mvmdio-fix-compilation-warning.patch new file mode 100644 index 00000000000..90863d4b961 --- /dev/null +++ b/queue-5.15/net-mvmdio-fix-compilation-warning.patch @@ -0,0 +1,52 @@ +From 152db9be213b4e4d914f5c120104e17c038f6054 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 15 Nov 2021 16:30:24 +0100 +Subject: net: mvmdio: fix compilation warning + +From: Marcin Wojtas + +[ Upstream commit 2460386bef0b9b98b71728d3c173e15558b78d82 ] + +The kernel test robot reported a following issue: + +>> drivers/net/ethernet/marvell/mvmdio.c:426:36: warning: +unused variable 'orion_mdio_acpi_match' [-Wunused-const-variable] + static const struct acpi_device_id orion_mdio_acpi_match[] = { + ^ + 1 warning generated. + +Fix that by surrounding the variable by appropriate ifdef. + +Fixes: c54da4c1acb1 ("net: mvmdio: add ACPI support") +Reported-by: kernel test robot +Signed-off-by: Marcin Wojtas +Reviewed-by: Andrew Lunn +Link: https://lore.kernel.org/r/20211115153024.209083-1-mw@semihalf.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Sasha Levin +--- + drivers/net/ethernet/marvell/mvmdio.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c +index 62a97c46fba05..ef878973b8597 100644 +--- a/drivers/net/ethernet/marvell/mvmdio.c ++++ b/drivers/net/ethernet/marvell/mvmdio.c +@@ -429,12 +429,14 @@ static const struct of_device_id orion_mdio_match[] = { + }; + MODULE_DEVICE_TABLE(of, orion_mdio_match); + ++#ifdef CONFIG_ACPI + static const struct acpi_device_id orion_mdio_acpi_match[] = { + { "MRVL0100", BUS_TYPE_SMI }, + { "MRVL0101", BUS_TYPE_XSMI }, + { }, + }; + MODULE_DEVICE_TABLE(acpi, orion_mdio_acpi_match); ++#endif + + static struct platform_driver orion_mdio_driver = { + .probe = orion_mdio_probe, +-- +2.33.0 + diff --git a/queue-5.15/net-sched-act_mirred-drop-dst-for-the-direction-from.patch b/queue-5.15/net-sched-act_mirred-drop-dst-for-the-direction-from.patch new file mode 100644 index 00000000000..2568502ad3b --- /dev/null +++ b/queue-5.15/net-sched-act_mirred-drop-dst-for-the-direction-from.patch @@ -0,0 +1,79 @@ +From e3cb240286cea7d1c4e6b95e22994cd88af6b95a Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 12 Nov 2021 11:33:11 -0500 +Subject: net: sched: act_mirred: drop dst for the direction from egress to + ingress + +From: Xin Long + +[ Upstream commit f799ada6bf2397c351220088b9b0980125c77280 ] + +Without dropping dst, the packets sent from local mirred/redirected +to ingress will may still use the old dst. ip_rcv() will drop it as +the old dst is for output and its .input is dst_discard. + +This patch is to fix by also dropping dst for those packets that are +mirred or redirected from egress to ingress in act_mirred. + +Note that we don't drop it for the direction change from ingress to +egress, as on which there might be a user case attaching a metadata +dst by act_tunnel_key that would be used later. + +Fixes: b57dc7c13ea9 ("net/sched: Introduce action ct") +Signed-off-by: Xin Long +Acked-by: Cong Wang +Reviewed-by: Marcelo Ricardo Leitner +Signed-off-by: Jakub Kicinski +Signed-off-by: Sasha Levin +--- + net/sched/act_mirred.c | 11 ++++++++--- + 1 file changed, 8 insertions(+), 3 deletions(-) + +diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c +index d64b0eeccbe4d..efc963ab995a3 100644 +--- a/net/sched/act_mirred.c ++++ b/net/sched/act_mirred.c +@@ -19,6 +19,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -228,6 +229,7 @@ static int tcf_mirred_act(struct sk_buff *skb, const struct tc_action *a, + bool want_ingress; + bool is_redirect; + bool expects_nh; ++ bool at_ingress; + int m_eaction; + int mac_len; + bool at_nh; +@@ -263,7 +265,8 @@ static int tcf_mirred_act(struct sk_buff *skb, const struct tc_action *a, + * ingress - that covers the TC S/W datapath. + */ + is_redirect = tcf_mirred_is_act_redirect(m_eaction); +- use_reinsert = skb_at_tc_ingress(skb) && is_redirect && ++ at_ingress = skb_at_tc_ingress(skb); ++ use_reinsert = at_ingress && is_redirect && + tcf_mirred_can_reinsert(retval); + if (!use_reinsert) { + skb2 = skb_clone(skb, GFP_ATOMIC); +@@ -271,10 +274,12 @@ static int tcf_mirred_act(struct sk_buff *skb, const struct tc_action *a, + goto out; + } + ++ want_ingress = tcf_mirred_act_wants_ingress(m_eaction); ++ + /* All mirred/redirected skbs should clear previous ct info */ + nf_reset_ct(skb2); +- +- want_ingress = tcf_mirred_act_wants_ingress(m_eaction); ++ if (want_ingress && !at_ingress) /* drop dst for egress -> ingress */ ++ skb_dst_drop(skb2); + + expects_nh = want_ingress || !m_mac_header_xmit; + at_nh = skb->data == skb_network_header(skb); +-- +2.33.0 + diff --git a/queue-5.15/net-smc-make-sure-the-link_id-is-unique.patch b/queue-5.15/net-smc-make-sure-the-link_id-is-unique.patch new file mode 100644 index 00000000000..ecdf97cf36b --- /dev/null +++ b/queue-5.15/net-smc-make-sure-the-link_id-is-unique.patch @@ -0,0 +1,45 @@ +From a5464e0745e0ede12559e54cbfde413af7a18723 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 15 Nov 2021 17:45:07 +0800 +Subject: net/smc: Make sure the link_id is unique + +From: Wen Gu + +[ Upstream commit cf4f5530bb55ef7d5a91036b26676643b80b1616 ] + +The link_id is supposed to be unique, but smcr_next_link_id() doesn't +skip the used link_id as expected. So the patch fixes this. + +Fixes: 026c381fb477 ("net/smc: introduce link_idx for link group array") +Signed-off-by: Wen Gu +Reviewed-by: Tony Lu +Acked-by: Karsten Graul +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + net/smc/smc_core.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c +index d2206743dc714..d672c0f0e247f 100644 +--- a/net/smc/smc_core.c ++++ b/net/smc/smc_core.c +@@ -665,13 +665,14 @@ static u8 smcr_next_link_id(struct smc_link_group *lgr) + int i; + + while (1) { ++again: + link_id = ++lgr->next_link_id; + if (!link_id) /* skip zero as link_id */ + link_id = ++lgr->next_link_id; + for (i = 0; i < SMC_LINKS_PER_LGR_MAX; i++) { + if (smc_link_usable(&lgr->lnk[i]) && + lgr->lnk[i].link_id == link_id) +- continue; ++ goto again; + } + break; + } +-- +2.33.0 + diff --git a/queue-5.15/net-virtio_net_hdr_to_skb-count-transport-header-in-.patch b/queue-5.15/net-virtio_net_hdr_to_skb-count-transport-header-in-.patch new file mode 100644 index 00000000000..643ede2f698 --- /dev/null +++ b/queue-5.15/net-virtio_net_hdr_to_skb-count-transport-header-in-.patch @@ -0,0 +1,75 @@ +From 993fdf29eb1bee8b0b72f381ff547a4294e8e914 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 16 Nov 2021 17:42:42 +0000 +Subject: net: virtio_net_hdr_to_skb: count transport header in UFO + +From: Jonathan Davies + +[ Upstream commit cf9acc90c80ecbee00334aa85d92f4e74014bcff ] + +virtio_net_hdr_to_skb does not set the skb's gso_size and gso_type +correctly for UFO packets received via virtio-net that are a little over +the GSO size. This can lead to problems elsewhere in the networking +stack, e.g. ovs_vport_send dropping over-sized packets if gso_size is +not set. + +This is due to the comparison + + if (skb->len - p_off > gso_size) + +not properly accounting for the transport layer header. + +p_off includes the size of the transport layer header (thlen), so +skb->len - p_off is the size of the TCP/UDP payload. + +gso_size is read from the virtio-net header. For UFO, fragmentation +happens at the IP level so does not need to include the UDP header. + +Hence the calculation could be comparing a TCP/UDP payload length with +an IP payload length, causing legitimate virtio-net packets to have +lack gso_type/gso_size information. + +Example: a UDP packet with payload size 1473 has IP payload size 1481. +If the guest used UFO, it is not fragmented and the virtio-net header's +flags indicate that it is a GSO frame (VIRTIO_NET_HDR_GSO_UDP), with +gso_size = 1480 for an MTU of 1500. skb->len will be 1515 and p_off +will be 42, so skb->len - p_off = 1473. Hence the comparison fails, and +shinfo->gso_size and gso_type are not set as they should be. + +Instead, add the UDP header length before comparing to gso_size when +using UFO. In this way, it is the size of the IP payload that is +compared to gso_size. + +Fixes: 6dd912f82680 ("net: check untrusted gso_size at kernel entry") +Signed-off-by: Jonathan Davies +Reviewed-by: Willem de Bruijn +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + include/linux/virtio_net.h | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h +index b465f8f3e554f..04e87f4b9417c 100644 +--- a/include/linux/virtio_net.h ++++ b/include/linux/virtio_net.h +@@ -120,10 +120,15 @@ retry: + + if (hdr->gso_type != VIRTIO_NET_HDR_GSO_NONE) { + u16 gso_size = __virtio16_to_cpu(little_endian, hdr->gso_size); ++ unsigned int nh_off = p_off; + struct skb_shared_info *shinfo = skb_shinfo(skb); + ++ /* UFO may not include transport header in gso_size. */ ++ if (gso_type & SKB_GSO_UDP) ++ nh_off -= thlen; ++ + /* Too small packets are not really GSO ones. */ +- if (skb->len - p_off > gso_size) { ++ if (skb->len - nh_off > gso_size) { + shinfo->gso_size = gso_size; + shinfo->gso_type = gso_type; + +-- +2.33.0 + diff --git a/queue-5.15/nfc-add-nci_unreg-flag-to-eliminate-the-race.patch b/queue-5.15/nfc-add-nci_unreg-flag-to-eliminate-the-race.patch new file mode 100644 index 00000000000..81968ba316f --- /dev/null +++ b/queue-5.15/nfc-add-nci_unreg-flag-to-eliminate-the-race.patch @@ -0,0 +1,123 @@ +From b0ea9801382e747aa449c8f71639e1ed4b85b2d4 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 16 Nov 2021 23:27:32 +0800 +Subject: NFC: add NCI_UNREG flag to eliminate the race + +From: Lin Ma + +[ Upstream commit 48b71a9e66c2eab60564b1b1c85f4928ed04e406 ] + +There are two sites that calls queue_work() after the +destroy_workqueue() and lead to possible UAF. + +The first site is nci_send_cmd(), which can happen after the +nci_close_device as below + +nfcmrvl_nci_unregister_dev | nfc_genl_dev_up + nci_close_device | + flush_workqueue | + del_timer_sync | + nci_unregister_device | nfc_get_device + destroy_workqueue | nfc_dev_up + nfc_unregister_device | nci_dev_up + device_del | nci_open_device + | __nci_request + | nci_send_cmd + | queue_work !!! + +Another site is nci_cmd_timer, awaked by the nci_cmd_work from the +nci_send_cmd. + + ... | ... + nci_unregister_device | queue_work + destroy_workqueue | + nfc_unregister_device | ... + device_del | nci_cmd_work + | mod_timer + | ... + | nci_cmd_timer + | queue_work !!! + +For the above two UAF, the root cause is that the nfc_dev_up can race +between the nci_unregister_device routine. Therefore, this patch +introduce NCI_UNREG flag to easily eliminate the possible race. In +addition, the mutex_lock in nci_close_device can act as a barrier. + +Signed-off-by: Lin Ma +Fixes: 6a2968aaf50c ("NFC: basic NCI protocol implementation") +Reviewed-by: Jakub Kicinski +Reviewed-by: Krzysztof Kozlowski +Link: https://lore.kernel.org/r/20211116152732.19238-1-linma@zju.edu.cn +Signed-off-by: Jakub Kicinski +Signed-off-by: Sasha Levin +--- + include/net/nfc/nci_core.h | 1 + + net/nfc/nci/core.c | 19 +++++++++++++++++-- + 2 files changed, 18 insertions(+), 2 deletions(-) + +diff --git a/include/net/nfc/nci_core.h b/include/net/nfc/nci_core.h +index a964daedc17b6..ea8595651c384 100644 +--- a/include/net/nfc/nci_core.h ++++ b/include/net/nfc/nci_core.h +@@ -30,6 +30,7 @@ enum nci_flag { + NCI_UP, + NCI_DATA_EXCHANGE, + NCI_DATA_EXCHANGE_TO, ++ NCI_UNREG, + }; + + /* NCI device states */ +diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c +index 39994dbb6a55b..e41e2e9e54984 100644 +--- a/net/nfc/nci/core.c ++++ b/net/nfc/nci/core.c +@@ -476,6 +476,11 @@ static int nci_open_device(struct nci_dev *ndev) + + mutex_lock(&ndev->req_lock); + ++ if (test_bit(NCI_UNREG, &ndev->flags)) { ++ rc = -ENODEV; ++ goto done; ++ } ++ + if (test_bit(NCI_UP, &ndev->flags)) { + rc = -EALREADY; + goto done; +@@ -548,6 +553,10 @@ done: + static int nci_close_device(struct nci_dev *ndev) + { + nci_req_cancel(ndev, ENODEV); ++ ++ /* This mutex needs to be held as a barrier for ++ * caller nci_unregister_device ++ */ + mutex_lock(&ndev->req_lock); + + if (!test_and_clear_bit(NCI_UP, &ndev->flags)) { +@@ -585,8 +594,8 @@ static int nci_close_device(struct nci_dev *ndev) + + del_timer_sync(&ndev->cmd_timer); + +- /* Clear flags */ +- ndev->flags = 0; ++ /* Clear flags except NCI_UNREG */ ++ ndev->flags &= BIT(NCI_UNREG); + + mutex_unlock(&ndev->req_lock); + +@@ -1273,6 +1282,12 @@ void nci_unregister_device(struct nci_dev *ndev) + { + struct nci_conn_info *conn_info, *n; + ++ /* This set_bit is not protected with specialized barrier, ++ * However, it is fine because the mutex_lock(&ndev->req_lock); ++ * in nci_close_device() will help to emit one. ++ */ ++ set_bit(NCI_UNREG, &ndev->flags); ++ + nci_close_device(ndev); + + destroy_workqueue(ndev->cmd_wq); +-- +2.33.0 + diff --git a/queue-5.15/nfc-reorder-the-logic-in-nfc_-un-register_device.patch b/queue-5.15/nfc-reorder-the-logic-in-nfc_-un-register_device.patch new file mode 100644 index 00000000000..c07415416bf --- /dev/null +++ b/queue-5.15/nfc-reorder-the-logic-in-nfc_-un-register_device.patch @@ -0,0 +1,129 @@ +From c3c1406e263061fd44e8d7a15d084b80061c1ebd Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 16 Nov 2021 23:26:52 +0800 +Subject: NFC: reorder the logic in nfc_{un,}register_device + +From: Lin Ma + +[ Upstream commit 3e3b5dfcd16a3e254aab61bd1e8c417dd4503102 ] + +There is a potential UAF between the unregistration routine and the NFC +netlink operations. + +The race that cause that UAF can be shown as below: + + (FREE) | (USE) +nfcmrvl_nci_unregister_dev | nfc_genl_dev_up + nci_close_device | + nci_unregister_device | nfc_get_device + nfc_unregister_device | nfc_dev_up + rfkill_destory | + device_del | rfkill_blocked + ... | ... + +The root cause for this race is concluded below: +1. The rfkill_blocked (USE) in nfc_dev_up is supposed to be placed after +the device_is_registered check. +2. Since the netlink operations are possible just after the device_add +in nfc_register_device, the nfc_dev_up() can happen anywhere during the +rfkill creation process, which leads to data race. + +This patch reorder these actions to permit +1. Once device_del is finished, the nfc_dev_up cannot dereference the +rfkill object. +2. The rfkill_register need to be placed after the device_add of nfc_dev +because the parent device need to be created first. So this patch keeps +the order but inject device_lock to prevent the data race. + +Signed-off-by: Lin Ma +Fixes: be055b2f89b5 ("NFC: RFKILL support") +Reviewed-by: Jakub Kicinski +Reviewed-by: Krzysztof Kozlowski +Link: https://lore.kernel.org/r/20211116152652.19217-1-linma@zju.edu.cn +Signed-off-by: Jakub Kicinski +Signed-off-by: Sasha Levin +--- + net/nfc/core.c | 32 ++++++++++++++++++-------------- + 1 file changed, 18 insertions(+), 14 deletions(-) + +diff --git a/net/nfc/core.c b/net/nfc/core.c +index 3c645c1d99c9b..dc7a2404efdf9 100644 +--- a/net/nfc/core.c ++++ b/net/nfc/core.c +@@ -94,13 +94,13 @@ int nfc_dev_up(struct nfc_dev *dev) + + device_lock(&dev->dev); + +- if (dev->rfkill && rfkill_blocked(dev->rfkill)) { +- rc = -ERFKILL; ++ if (!device_is_registered(&dev->dev)) { ++ rc = -ENODEV; + goto error; + } + +- if (!device_is_registered(&dev->dev)) { +- rc = -ENODEV; ++ if (dev->rfkill && rfkill_blocked(dev->rfkill)) { ++ rc = -ERFKILL; + goto error; + } + +@@ -1125,11 +1125,7 @@ int nfc_register_device(struct nfc_dev *dev) + if (rc) + pr_err("Could not register llcp device\n"); + +- rc = nfc_genl_device_added(dev); +- if (rc) +- pr_debug("The userspace won't be notified that the device %s was added\n", +- dev_name(&dev->dev)); +- ++ device_lock(&dev->dev); + dev->rfkill = rfkill_alloc(dev_name(&dev->dev), &dev->dev, + RFKILL_TYPE_NFC, &nfc_rfkill_ops, dev); + if (dev->rfkill) { +@@ -1138,6 +1134,12 @@ int nfc_register_device(struct nfc_dev *dev) + dev->rfkill = NULL; + } + } ++ device_unlock(&dev->dev); ++ ++ rc = nfc_genl_device_added(dev); ++ if (rc) ++ pr_debug("The userspace won't be notified that the device %s was added\n", ++ dev_name(&dev->dev)); + + return 0; + } +@@ -1154,10 +1156,17 @@ void nfc_unregister_device(struct nfc_dev *dev) + + pr_debug("dev_name=%s\n", dev_name(&dev->dev)); + ++ rc = nfc_genl_device_removed(dev); ++ if (rc) ++ pr_debug("The userspace won't be notified that the device %s " ++ "was removed\n", dev_name(&dev->dev)); ++ ++ device_lock(&dev->dev); + if (dev->rfkill) { + rfkill_unregister(dev->rfkill); + rfkill_destroy(dev->rfkill); + } ++ device_unlock(&dev->dev); + + if (dev->ops->check_presence) { + device_lock(&dev->dev); +@@ -1167,11 +1176,6 @@ void nfc_unregister_device(struct nfc_dev *dev) + cancel_work_sync(&dev->check_pres_work); + } + +- rc = nfc_genl_device_removed(dev); +- if (rc) +- pr_debug("The userspace won't be notified that the device %s " +- "was removed\n", dev_name(&dev->dev)); +- + nfc_llcp_unregister_device(dev); + + mutex_lock(&nfc_devlist_mutex); +-- +2.33.0 + diff --git a/queue-5.15/nfc-reorganize-the-functions-in-nci_request.patch b/queue-5.15/nfc-reorganize-the-functions-in-nci_request.patch new file mode 100644 index 00000000000..2cdfa063f35 --- /dev/null +++ b/queue-5.15/nfc-reorganize-the-functions-in-nci_request.patch @@ -0,0 +1,62 @@ +From c61ee6cc8bb4cbabae63010a5b18e90e88f1bafe Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 15 Nov 2021 22:56:00 +0800 +Subject: NFC: reorganize the functions in nci_request + +From: Lin Ma + +[ Upstream commit 86cdf8e38792545161dbe3350a7eced558ba4d15 ] + +There is a possible data race as shown below: + +thread-A in nci_request() | thread-B in nci_close_device() + | mutex_lock(&ndev->req_lock); +test_bit(NCI_UP, &ndev->flags); | +... | test_and_clear_bit(NCI_UP, &ndev->flags) +mutex_lock(&ndev->req_lock); | + | + +This race will allow __nci_request() to be awaked while the device is +getting removed. + +Similar to commit e2cb6b891ad2 ("bluetooth: eliminate the potential race +condition when removing the HCI controller"). this patch alters the +function sequence in nci_request() to prevent the data races between the +nci_close_device(). + +Signed-off-by: Lin Ma +Fixes: 6a2968aaf50c ("NFC: basic NCI protocol implementation") +Link: https://lore.kernel.org/r/20211115145600.8320-1-linma@zju.edu.cn +Signed-off-by: Jakub Kicinski +Signed-off-by: Sasha Levin +--- + net/nfc/nci/core.c | 11 +++++++---- + 1 file changed, 7 insertions(+), 4 deletions(-) + +diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c +index 82ab39d80726e..39994dbb6a55b 100644 +--- a/net/nfc/nci/core.c ++++ b/net/nfc/nci/core.c +@@ -144,12 +144,15 @@ inline int nci_request(struct nci_dev *ndev, + { + int rc; + +- if (!test_bit(NCI_UP, &ndev->flags)) +- return -ENETDOWN; +- + /* Serialize all requests */ + mutex_lock(&ndev->req_lock); +- rc = __nci_request(ndev, req, opt, timeout); ++ /* check the state after obtaing the lock against any races ++ * from nci_close_device when the device gets removed. ++ */ ++ if (test_bit(NCI_UP, &ndev->flags)) ++ rc = __nci_request(ndev, req, opt, timeout); ++ else ++ rc = -ENETDOWN; + mutex_unlock(&ndev->req_lock); + + return rc; +-- +2.33.0 + diff --git a/queue-5.15/nfsd-fix-exposure-in-nfsd4_decode_bitmap.patch b/queue-5.15/nfsd-fix-exposure-in-nfsd4_decode_bitmap.patch new file mode 100644 index 00000000000..3a1146e8236 --- /dev/null +++ b/queue-5.15/nfsd-fix-exposure-in-nfsd4_decode_bitmap.patch @@ -0,0 +1,49 @@ +From d16e5b1bb82bec70d2f5382f468a418de6a79c8b Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 14 Nov 2021 15:16:04 -0500 +Subject: NFSD: Fix exposure in nfsd4_decode_bitmap() + +From: Chuck Lever + +[ Upstream commit c0019b7db1d7ac62c711cda6b357a659d46428fe ] + +rtm@csail.mit.edu reports: +> nfsd4_decode_bitmap4() will write beyond bmval[bmlen-1] if the RPC +> directs it to do so. This can cause nfsd4_decode_state_protect4_a() +> to write client-supplied data beyond the end of +> nfsd4_exchange_id.spo_must_allow[] when called by +> nfsd4_decode_exchange_id(). + +Rewrite the loops so nfsd4_decode_bitmap() cannot iterate beyond +@bmlen. + +Reported by: rtm@csail.mit.edu +Fixes: d1c263a031e8 ("NFSD: Replace READ* macros in nfsd4_decode_fattr()") +Signed-off-by: Chuck Lever +Signed-off-by: J. Bruce Fields +Signed-off-by: Sasha Levin +--- + fs/nfsd/nfs4xdr.c | 7 ++----- + 1 file changed, 2 insertions(+), 5 deletions(-) + +diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c +index cf030ebe28275..266d5152c3216 100644 +--- a/fs/nfsd/nfs4xdr.c ++++ b/fs/nfsd/nfs4xdr.c +@@ -288,11 +288,8 @@ nfsd4_decode_bitmap4(struct nfsd4_compoundargs *argp, u32 *bmval, u32 bmlen) + p = xdr_inline_decode(argp->xdr, count << 2); + if (!p) + return nfserr_bad_xdr; +- i = 0; +- while (i < count) +- bmval[i++] = be32_to_cpup(p++); +- while (i < bmlen) +- bmval[i++] = 0; ++ for (i = 0; i < bmlen; i++) ++ bmval[i] = (i < count) ? be32_to_cpup(p++) : 0; + + return nfs_ok; + } +-- +2.33.0 + diff --git a/queue-5.15/nl80211-fix-radio-statistics-in-survey-dump.patch b/queue-5.15/nl80211-fix-radio-statistics-in-survey-dump.patch new file mode 100644 index 00000000000..968ae1a9e47 --- /dev/null +++ b/queue-5.15/nl80211-fix-radio-statistics-in-survey-dump.patch @@ -0,0 +1,156 @@ +From da13f56cea4b21b873836de2dca8bf1227a25e1a Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 29 Oct 2021 09:25:39 +0200 +Subject: nl80211: fix radio statistics in survey dump + +From: Johannes Berg + +[ Upstream commit ce6b69749961426c6d822215ded9e67154e1ad4f ] + +Even if userspace specifies the NL80211_ATTR_SURVEY_RADIO_STATS +attribute, we cannot get the statistics because we're not really +parsing the incoming attributes properly any more. + +Fix this by passing the attrbuf to nl80211_prepare_wdev_dump() +and filling it there, if given, and using a local version only +if no output is desired. + +Since I'm touching it anyway, make nl80211_prepare_wdev_dump() +static. + +Fixes: 50508d941c18 ("cfg80211: use parallel_ops for genl") +Reported-by: Jan Fuchs +Signed-off-by: Johannes Berg +Tested-by: Sven Eckelmann +Link: https://lore.kernel.org/r/20211029092539.2851b4799386.If9736d4575ee79420cbec1bd930181e1d53c7317@changeid +Signed-off-by: Johannes Berg +Signed-off-by: Sasha Levin +--- + net/wireless/nl80211.c | 34 +++++++++++++++++++--------------- + net/wireless/nl80211.h | 6 +----- + 2 files changed, 20 insertions(+), 20 deletions(-) + +diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c +index bf7cd47525472..16b3d0cc0bdb0 100644 +--- a/net/wireless/nl80211.c ++++ b/net/wireless/nl80211.c +@@ -922,33 +922,37 @@ nl80211_packet_pattern_policy[MAX_NL80211_PKTPAT + 1] = { + [NL80211_PKTPAT_OFFSET] = { .type = NLA_U32 }, + }; + +-int nl80211_prepare_wdev_dump(struct netlink_callback *cb, +- struct cfg80211_registered_device **rdev, +- struct wireless_dev **wdev) ++static int nl80211_prepare_wdev_dump(struct netlink_callback *cb, ++ struct cfg80211_registered_device **rdev, ++ struct wireless_dev **wdev, ++ struct nlattr **attrbuf) + { + int err; + + if (!cb->args[0]) { +- struct nlattr **attrbuf; ++ struct nlattr **attrbuf_free = NULL; + +- attrbuf = kcalloc(NUM_NL80211_ATTR, sizeof(*attrbuf), +- GFP_KERNEL); +- if (!attrbuf) +- return -ENOMEM; ++ if (!attrbuf) { ++ attrbuf = kcalloc(NUM_NL80211_ATTR, sizeof(*attrbuf), ++ GFP_KERNEL); ++ if (!attrbuf) ++ return -ENOMEM; ++ attrbuf_free = attrbuf; ++ } + + err = nlmsg_parse_deprecated(cb->nlh, + GENL_HDRLEN + nl80211_fam.hdrsize, + attrbuf, nl80211_fam.maxattr, + nl80211_policy, NULL); + if (err) { +- kfree(attrbuf); ++ kfree(attrbuf_free); + return err; + } + + rtnl_lock(); + *wdev = __cfg80211_wdev_from_attrs(NULL, sock_net(cb->skb->sk), + attrbuf); +- kfree(attrbuf); ++ kfree(attrbuf_free); + if (IS_ERR(*wdev)) { + rtnl_unlock(); + return PTR_ERR(*wdev); +@@ -6001,7 +6005,7 @@ static int nl80211_dump_station(struct sk_buff *skb, + int sta_idx = cb->args[2]; + int err; + +- err = nl80211_prepare_wdev_dump(cb, &rdev, &wdev); ++ err = nl80211_prepare_wdev_dump(cb, &rdev, &wdev, NULL); + if (err) + return err; + /* nl80211_prepare_wdev_dump acquired it in the successful case */ +@@ -6896,7 +6900,7 @@ static int nl80211_dump_mpath(struct sk_buff *skb, + int path_idx = cb->args[2]; + int err; + +- err = nl80211_prepare_wdev_dump(cb, &rdev, &wdev); ++ err = nl80211_prepare_wdev_dump(cb, &rdev, &wdev, NULL); + if (err) + return err; + /* nl80211_prepare_wdev_dump acquired it in the successful case */ +@@ -7096,7 +7100,7 @@ static int nl80211_dump_mpp(struct sk_buff *skb, + int path_idx = cb->args[2]; + int err; + +- err = nl80211_prepare_wdev_dump(cb, &rdev, &wdev); ++ err = nl80211_prepare_wdev_dump(cb, &rdev, &wdev, NULL); + if (err) + return err; + /* nl80211_prepare_wdev_dump acquired it in the successful case */ +@@ -9518,7 +9522,7 @@ static int nl80211_dump_scan(struct sk_buff *skb, struct netlink_callback *cb) + int start = cb->args[2], idx = 0; + int err; + +- err = nl80211_prepare_wdev_dump(cb, &rdev, &wdev); ++ err = nl80211_prepare_wdev_dump(cb, &rdev, &wdev, NULL); + if (err) + return err; + /* nl80211_prepare_wdev_dump acquired it in the successful case */ +@@ -9651,7 +9655,7 @@ static int nl80211_dump_survey(struct sk_buff *skb, struct netlink_callback *cb) + if (!attrbuf) + return -ENOMEM; + +- res = nl80211_prepare_wdev_dump(cb, &rdev, &wdev); ++ res = nl80211_prepare_wdev_dump(cb, &rdev, &wdev, attrbuf); + if (res) { + kfree(attrbuf); + return res; +diff --git a/net/wireless/nl80211.h b/net/wireless/nl80211.h +index a3f387770f1bf..d642e3be4ee78 100644 +--- a/net/wireless/nl80211.h ++++ b/net/wireless/nl80211.h +@@ -1,7 +1,7 @@ + /* SPDX-License-Identifier: GPL-2.0 */ + /* + * Portions of this file +- * Copyright (C) 2018, 2020 Intel Corporation ++ * Copyright (C) 2018, 2020-2021 Intel Corporation + */ + #ifndef __NET_WIRELESS_NL80211_H + #define __NET_WIRELESS_NL80211_H +@@ -22,10 +22,6 @@ static inline u64 wdev_id(struct wireless_dev *wdev) + ((u64)wiphy_to_rdev(wdev->wiphy)->wiphy_idx << 32); + } + +-int nl80211_prepare_wdev_dump(struct netlink_callback *cb, +- struct cfg80211_registered_device **rdev, +- struct wireless_dev **wdev); +- + int nl80211_parse_chandef(struct cfg80211_registered_device *rdev, + struct genl_info *info, + struct cfg80211_chan_def *chandef); +-- +2.33.0 + diff --git a/queue-5.15/perf-bench-fix-two-memory-leaks-detected-with-asan.patch b/queue-5.15/perf-bench-fix-two-memory-leaks-detected-with-asan.patch new file mode 100644 index 00000000000..84ef14ddf3e --- /dev/null +++ b/queue-5.15/perf-bench-fix-two-memory-leaks-detected-with-asan.patch @@ -0,0 +1,56 @@ +From e1dcd3f6713534890290c505165c237c0453962b Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 10 Nov 2021 04:20:11 +0200 +Subject: perf bench: Fix two memory leaks detected with ASan + +From: Sohaib Mohamed + +[ Upstream commit 92723ea0f11d92496687db8c9725248e9d1e5e1d ] + +ASan reports memory leaks while running: + + $ perf bench sched all + +Fixes: e27454cc6352c422 ("perf bench: Add sched-messaging.c: Benchmark for scheduler and IPC mechanisms based on hackbench") +Signed-off-by: Sohaib Mohamed +Acked-by: Ian Rogers +Cc: Alexander Shishkin +Cc: Hitoshi Mitake +Cc: Jiri Olsa +Cc: Mark Rutland +Cc: Namhyung Kim +Cc: Paul Russel +Cc: Peter Zijlstra +Cc: Pierre Gondois +Link: http://lore.kernel.org/lkml/20211110022012.16620-1-sohaib.amhmd@gmail.com +Signed-off-by: Arnaldo Carvalho de Melo +Signed-off-by: Sasha Levin +--- + tools/perf/bench/sched-messaging.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/tools/perf/bench/sched-messaging.c b/tools/perf/bench/sched-messaging.c +index 488f6e6ba1a55..fa0ff4ce2b749 100644 +--- a/tools/perf/bench/sched-messaging.c ++++ b/tools/perf/bench/sched-messaging.c +@@ -223,6 +223,8 @@ static unsigned int group(pthread_t *pth, + snd_ctx->out_fds[i] = fds[1]; + if (!thread_mode) + close(fds[0]); ++ ++ free(ctx); + } + + /* Now we have all the fds, fork the senders */ +@@ -239,6 +241,8 @@ static unsigned int group(pthread_t *pth, + for (i = 0; i < num_fds; i++) + close(snd_ctx->out_fds[i]); + ++ free(snd_ctx); ++ + /* Return number of children to reap */ + return num_fds * 2; + } +-- +2.33.0 + diff --git a/queue-5.15/perf-bench-futex-fix-memory-leak-of-perf_cpu_map__ne.patch b/queue-5.15/perf-bench-futex-fix-memory-leak-of-perf_cpu_map__ne.patch new file mode 100644 index 00000000000..23f67344ebc --- /dev/null +++ b/queue-5.15/perf-bench-futex-fix-memory-leak-of-perf_cpu_map__ne.patch @@ -0,0 +1,93 @@ +From 051267ce48afa736a7a42c783fc304fd444d98e1 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 12 Nov 2021 22:11:33 +0200 +Subject: perf bench futex: Fix memory leak of perf_cpu_map__new() +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Sohaib Mohamed + +[ Upstream commit 88e48238d53682281c9de2a0b65d24d3b64542a0 ] + +ASan reports memory leaks while running: + + $ sudo ./perf bench futex all + +The leaks are caused by perf_cpu_map__new not being freed. +This patch adds the missing perf_cpu_map__put since it calls +cpu_map_delete implicitly. + +Fixes: 9c3516d1b850ea93 ("libperf: Add perf_cpu_map__new()/perf_cpu_map__read() functions") +Signed-off-by: Sohaib Mohamed +Cc: Alexander Shishkin +Cc: André Almeida +Cc: Darren Hart +Cc: Davidlohr Bueso +Cc: Ian Rogers +Cc: Jiri Olsa +Cc: Mark Rutland +Cc: Namhyung Kim +Cc: Peter Zijlstra +Cc: Sohaib Mohamed +Cc: Thomas Gleixner +Link: http://lore.kernel.org/lkml/20211112201134.77892-1-sohaib.amhmd@gmail.com +Signed-off-by: Arnaldo Carvalho de Melo +Signed-off-by: Sasha Levin +--- + tools/perf/bench/futex-lock-pi.c | 1 + + tools/perf/bench/futex-requeue.c | 1 + + tools/perf/bench/futex-wake-parallel.c | 1 + + tools/perf/bench/futex-wake.c | 1 + + 4 files changed, 4 insertions(+) + +diff --git a/tools/perf/bench/futex-lock-pi.c b/tools/perf/bench/futex-lock-pi.c +index 5d1fe9c35807a..137890f78e17a 100644 +--- a/tools/perf/bench/futex-lock-pi.c ++++ b/tools/perf/bench/futex-lock-pi.c +@@ -233,6 +233,7 @@ int bench_futex_lock_pi(int argc, const char **argv) + print_summary(); + + free(worker); ++ perf_cpu_map__put(cpu); + return ret; + err: + usage_with_options(bench_futex_lock_pi_usage, options); +diff --git a/tools/perf/bench/futex-requeue.c b/tools/perf/bench/futex-requeue.c +index 97fe31fd3a236..f7a5ffebb9408 100644 +--- a/tools/perf/bench/futex-requeue.c ++++ b/tools/perf/bench/futex-requeue.c +@@ -294,6 +294,7 @@ int bench_futex_requeue(int argc, const char **argv) + print_summary(); + + free(worker); ++ perf_cpu_map__put(cpu); + return ret; + err: + usage_with_options(bench_futex_requeue_usage, options); +diff --git a/tools/perf/bench/futex-wake-parallel.c b/tools/perf/bench/futex-wake-parallel.c +index e970e6b9ad535..0983f40b4b408 100644 +--- a/tools/perf/bench/futex-wake-parallel.c ++++ b/tools/perf/bench/futex-wake-parallel.c +@@ -329,6 +329,7 @@ int bench_futex_wake_parallel(int argc, const char **argv) + print_summary(); + + free(blocked_worker); ++ perf_cpu_map__put(cpu); + return ret; + } + #endif /* HAVE_PTHREAD_BARRIER */ +diff --git a/tools/perf/bench/futex-wake.c b/tools/perf/bench/futex-wake.c +index 77f058a477903..2226a475e782b 100644 +--- a/tools/perf/bench/futex-wake.c ++++ b/tools/perf/bench/futex-wake.c +@@ -222,5 +222,6 @@ int bench_futex_wake(int argc, const char **argv) + print_summary(); + + free(worker); ++ perf_cpu_map__put(cpu); + return ret; + } +-- +2.33.0 + diff --git a/queue-5.15/perf-bpf-avoid-memory-leak-from-perf_env__insert_btf.patch b/queue-5.15/perf-bpf-avoid-memory-leak-from-perf_env__insert_btf.patch new file mode 100644 index 00000000000..5feb26166cc --- /dev/null +++ b/queue-5.15/perf-bpf-avoid-memory-leak-from-perf_env__insert_btf.patch @@ -0,0 +1,114 @@ +From 5da6a2b60f0673f6c12e465c93a615384e8f8ff5 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 11 Nov 2021 23:45:25 -0800 +Subject: perf bpf: Avoid memory leak from perf_env__insert_btf() + +From: Ian Rogers + +[ Upstream commit 4924b1f7c46711762fd0e65c135ccfbcfd6ded1f ] + +perf_env__insert_btf() doesn't insert if a duplicate BTF id is +encountered and this causes a memory leak. Modify the function to return +a success/error value and then free the memory if insertion didn't +happen. + +v2. Adds a return -1 when the insertion error occurs in + perf_env__fetch_btf. This doesn't affect anything as the result is + never checked. + +Fixes: 3792cb2ff43b1b19 ("perf bpf: Save BTF in a rbtree in perf_env") +Signed-off-by: Ian Rogers +Cc: Alexander Shishkin +Cc: Alexei Starovoitov +Cc: Andrii Nakryiko +Cc: Daniel Borkmann +Cc: Jiri Olsa +Cc: John Fastabend +Cc: KP Singh +Cc: Mark Rutland +Cc: Martin KaFai Lau +Cc: Namhyung Kim +Cc: Peter Zijlstra +Cc: Song Liu +Cc: Stephane Eranian +Cc: Tiezhu Yang +Cc: Yonghong Song +Cc: bpf@vger.kernel.org +Cc: netdev@vger.kernel.org +Link: http://lore.kernel.org/lkml/20211112074525.121633-1-irogers@google.com +Signed-off-by: Arnaldo Carvalho de Melo +Signed-off-by: Sasha Levin +--- + tools/perf/util/bpf-event.c | 6 +++++- + tools/perf/util/env.c | 5 ++++- + tools/perf/util/env.h | 2 +- + 3 files changed, 10 insertions(+), 3 deletions(-) + +diff --git a/tools/perf/util/bpf-event.c b/tools/perf/util/bpf-event.c +index a410b3968b3af..16ad0e6e9e9c5 100644 +--- a/tools/perf/util/bpf-event.c ++++ b/tools/perf/util/bpf-event.c +@@ -120,7 +120,11 @@ static int perf_env__fetch_btf(struct perf_env *env, + node->data_size = data_size; + memcpy(node->data, data, data_size); + +- perf_env__insert_btf(env, node); ++ if (!perf_env__insert_btf(env, node)) { ++ /* Insertion failed because of a duplicate. */ ++ free(node); ++ return -1; ++ } + return 0; + } + +diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c +index cf773f0dec384..5b24eb010336c 100644 +--- a/tools/perf/util/env.c ++++ b/tools/perf/util/env.c +@@ -74,12 +74,13 @@ out: + return node; + } + +-void perf_env__insert_btf(struct perf_env *env, struct btf_node *btf_node) ++bool perf_env__insert_btf(struct perf_env *env, struct btf_node *btf_node) + { + struct rb_node *parent = NULL; + __u32 btf_id = btf_node->id; + struct btf_node *node; + struct rb_node **p; ++ bool ret = true; + + down_write(&env->bpf_progs.lock); + p = &env->bpf_progs.btfs.rb_node; +@@ -93,6 +94,7 @@ void perf_env__insert_btf(struct perf_env *env, struct btf_node *btf_node) + p = &(*p)->rb_right; + } else { + pr_debug("duplicated btf %u\n", btf_id); ++ ret = false; + goto out; + } + } +@@ -102,6 +104,7 @@ void perf_env__insert_btf(struct perf_env *env, struct btf_node *btf_node) + env->bpf_progs.btfs_cnt++; + out: + up_write(&env->bpf_progs.lock); ++ return ret; + } + + struct btf_node *perf_env__find_btf(struct perf_env *env, __u32 btf_id) +diff --git a/tools/perf/util/env.h b/tools/perf/util/env.h +index 1383876f72b37..163e5ec503a26 100644 +--- a/tools/perf/util/env.h ++++ b/tools/perf/util/env.h +@@ -167,7 +167,7 @@ void perf_env__insert_bpf_prog_info(struct perf_env *env, + struct bpf_prog_info_node *info_node); + struct bpf_prog_info_node *perf_env__find_bpf_prog_info(struct perf_env *env, + __u32 prog_id); +-void perf_env__insert_btf(struct perf_env *env, struct btf_node *btf_node); ++bool perf_env__insert_btf(struct perf_env *env, struct btf_node *btf_node); + struct btf_node *perf_env__find_btf(struct perf_env *env, __u32 btf_id); + + int perf_env__numa_node(struct perf_env *env, int cpu); +-- +2.33.0 + diff --git a/queue-5.15/perf-tests-remove-bash-construct-from-record-zstd_co.patch b/queue-5.15/perf-tests-remove-bash-construct-from-record-zstd_co.patch new file mode 100644 index 00000000000..dc1f288d05e --- /dev/null +++ b/queue-5.15/perf-tests-remove-bash-construct-from-record-zstd_co.patch @@ -0,0 +1,62 @@ +From 78f094df539607338ad55b273f490377c7056ef3 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 28 Oct 2021 14:48:26 +0100 +Subject: perf tests: Remove bash construct from record+zstd_comp_decomp.sh + +From: James Clark + +[ Upstream commit a9cdc1c5e3700a5200e5ca1f90b6958b6483845b ] + +Commit 463538a383a2 ("perf tests: Fix test 68 zstd compression for +s390") inadvertently removed the -g flag from all platforms rather than +just s390, because the [[ ]] construct fails in sh. Changing to single +brackets restores testing of call graphs and removes the following error +from the output: + + $ ./perf test -v 85 + 85: Zstd perf.data compression/decompression : + --- start --- + test child forked, pid 50643 + Collecting compressed record file: + ./tests/shell/record+zstd_comp_decomp.sh: 15: [[: not found + +Fixes: 463538a383a2 ("perf tests: Fix test 68 zstd compression for s390") +Signed-off-by: James Clark +Cc: Alexander Shishkin +Cc: Florian Fainelli +Cc: Ian Rogers +Cc: Jiri Olsa +Cc: John Fastabend +Cc: KP Singh +Cc: Mark Rutland +Cc: Martin KaFai Lau +Cc: Namhyung Kim +Cc: Song Liu +Cc: Sumanth Korikkar +Cc: Thomas Richter +Cc: Yonghong Song +Cc: bpf@vger.kernel.org +Cc: netdev@vger.kernel.org +Link: https://lore.kernel.org/r/20211028134828.65774-3-james.clark@arm.com +Signed-off-by: Arnaldo Carvalho de Melo +Signed-off-by: Sasha Levin +--- + tools/perf/tests/shell/record+zstd_comp_decomp.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tools/perf/tests/shell/record+zstd_comp_decomp.sh b/tools/perf/tests/shell/record+zstd_comp_decomp.sh +index 8a168cf8bacca..49bd875d51227 100755 +--- a/tools/perf/tests/shell/record+zstd_comp_decomp.sh ++++ b/tools/perf/tests/shell/record+zstd_comp_decomp.sh +@@ -12,7 +12,7 @@ skip_if_no_z_record() { + + collect_z_record() { + echo "Collecting compressed record file:" +- [[ "$(uname -m)" != s390x ]] && gflag='-g' ++ [ "$(uname -m)" != s390x ] && gflag='-g' + $perf_tool record -o $trace_file $gflag -z -F 5000 -- \ + dd count=500 if=/dev/urandom of=/dev/null + } +-- +2.33.0 + diff --git a/queue-5.15/perf-x86-vlbr-add-c-flags-to-vlbr-event-constraints.patch b/queue-5.15/perf-x86-vlbr-add-c-flags-to-vlbr-event-constraints.patch new file mode 100644 index 00000000000..cc85b786f93 --- /dev/null +++ b/queue-5.15/perf-x86-vlbr-add-c-flags-to-vlbr-event-constraints.patch @@ -0,0 +1,44 @@ +From 441e7a4b3901be24fd5843d03f62917c3f099dd2 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 3 Nov 2021 17:17:16 +0800 +Subject: perf/x86/vlbr: Add c->flags to vlbr event constraints + +From: Like Xu + +[ Upstream commit 5863702561e625903ec678551cb056a4b19e0b8a ] + +Just like what we do in the x86_get_event_constraints(), the +PERF_X86_EVENT_LBR_SELECT flag should also be propagated +to event->hw.flags so that the host lbr driver can save/restore +MSR_LBR_SELECT for the special vlbr event created by KVM or BPF. + +Fixes: 097e4311cda9 ("perf/x86: Add constraint to create guest LBR event without hw counter") +Reported-by: Wanpeng Li +Signed-off-by: Like Xu +Signed-off-by: Peter Zijlstra (Intel) +Tested-by: Wanpeng Li +Link: https://lore.kernel.org/r/20211103091716.59906-1-likexu@tencent.com +Signed-off-by: Sasha Levin +--- + arch/x86/events/intel/core.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c +index bc3f97f834011..c7f1cc433a6aa 100644 +--- a/arch/x86/events/intel/core.c ++++ b/arch/x86/events/intel/core.c +@@ -2999,8 +2999,10 @@ intel_vlbr_constraints(struct perf_event *event) + { + struct event_constraint *c = &vlbr_constraint; + +- if (unlikely(constraint_match(c, event->hw.config))) ++ if (unlikely(constraint_match(c, event->hw.config))) { ++ event->hw.flags |= c->flags; + return c; ++ } + + return NULL; + } +-- +2.33.0 + diff --git a/queue-5.15/platform-x86-hp_accel-fix-an-error-handling-path-in-.patch b/queue-5.15/platform-x86-hp_accel-fix-an-error-handling-path-in-.patch new file mode 100644 index 00000000000..639110b673a --- /dev/null +++ b/queue-5.15/platform-x86-hp_accel-fix-an-error-handling-path-in-.patch @@ -0,0 +1,46 @@ +From 0ebba77eb127f05333d6372c3f607df641519cae Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 7 Nov 2021 20:57:07 +0100 +Subject: platform/x86: hp_accel: Fix an error handling path in + 'lis3lv02d_probe()' + +From: Christophe JAILLET + +[ Upstream commit c961a7d2aa23ae19e0099fbcdf1040fb760eea83 ] + +If 'led_classdev_register()' fails, some additional resources should be +released. + +Add the missing 'i8042_remove_filter()' and 'lis3lv02d_remove_fs()' calls +that are already in the remove function but are missing here. + +Fixes: a4c724d0723b ("platform: hp_accel: add a i8042 filter to remove HPQ6000 data from kb bus stream") +Fixes: 9e0c79782143 ("lis3lv02d: merge with leds hp disk") +Signed-off-by: Christophe JAILLET +Link: https://lore.kernel.org/r/5a4f218f8f16d2e3a7906b7ca3654ffa946895f8.1636314074.git.christophe.jaillet@wanadoo.fr +Reviewed-by: Hans de Goede +Signed-off-by: Hans de Goede +Signed-off-by: Sasha Levin +--- + drivers/platform/x86/hp_accel.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/drivers/platform/x86/hp_accel.c b/drivers/platform/x86/hp_accel.c +index cc53f725c0419..ef24f53753c6e 100644 +--- a/drivers/platform/x86/hp_accel.c ++++ b/drivers/platform/x86/hp_accel.c +@@ -331,9 +331,11 @@ static int lis3lv02d_probe(struct platform_device *device) + INIT_WORK(&hpled_led.work, delayed_set_status_worker); + ret = led_classdev_register(NULL, &hpled_led.led_classdev); + if (ret) { ++ i8042_remove_filter(hp_accel_i8042_filter); + lis3lv02d_joystick_disable(&lis3_dev); + lis3lv02d_poweroff(&lis3_dev); + flush_work(&hpled_led.work); ++ lis3lv02d_remove_fs(&lis3_dev); + return ret; + } + +-- +2.33.0 + diff --git a/queue-5.15/platform-x86-think-lmi-abort-probe-on-analyze-failur.patch b/queue-5.15/platform-x86-think-lmi-abort-probe-on-analyze-failur.patch new file mode 100644 index 00000000000..d7dda1103ba --- /dev/null +++ b/queue-5.15/platform-x86-think-lmi-abort-probe-on-analyze-failur.patch @@ -0,0 +1,95 @@ +From 8033bdca22bb51a17bee67b2c65df92dd35fc8e3 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 8 Nov 2021 11:03:57 -0700 +Subject: platform/x86: think-lmi: Abort probe on analyze failure + +From: Alex Williamson + +[ Upstream commit 812fcc609502096e98cc3918a4b807722dba8fd9 ] + +A Lenovo ThinkStation S20 (4157CTO BIOS 60KT41AUS) fails to boot on +recent kernels including the think-lmi driver, due to the fact that +errors returned by the tlmi_analyze() function are ignored by +tlmi_probe(), where tlmi_sysfs_init() is called unconditionally. +This results in making use of an array of already freed, non-null +pointers and other uninitialized globals, causing all sorts of nasty +kobject and memory faults. + +Make use of the analyze function return value, free a couple leaked +allocations, and remove the settings_count field, which is incremented +but never consumed. + +Fixes: a40cd7ef22fb ("platform/x86: think-lmi: Add WMI interface support on Lenovo platforms") +Signed-off-by: Alex Williamson +Reviewed-by: Mark Gross +Reviewed-by: Mark Pearson +Link: https://lore.kernel.org/r/163639463588.1330483.15850167112490200219.stgit@omen +Reviewed-by: Hans de Goede +Signed-off-by: Hans de Goede +Signed-off-by: Sasha Levin +--- + drivers/platform/x86/think-lmi.c | 13 ++++++++++--- + drivers/platform/x86/think-lmi.h | 1 - + 2 files changed, 10 insertions(+), 4 deletions(-) + +diff --git a/drivers/platform/x86/think-lmi.c b/drivers/platform/x86/think-lmi.c +index 9472aae72df29..c4d9c45350f7c 100644 +--- a/drivers/platform/x86/think-lmi.c ++++ b/drivers/platform/x86/think-lmi.c +@@ -888,8 +888,10 @@ static int tlmi_analyze(void) + break; + if (!item) + break; +- if (!*item) ++ if (!*item) { ++ kfree(item); + continue; ++ } + + /* It is not allowed to have '/' for file name. Convert it into '\'. */ + strreplace(item, '/', '\\'); +@@ -902,6 +904,7 @@ static int tlmi_analyze(void) + setting = kzalloc(sizeof(*setting), GFP_KERNEL); + if (!setting) { + ret = -ENOMEM; ++ kfree(item); + goto fail_clear_attr; + } + setting->index = i; +@@ -916,7 +919,6 @@ static int tlmi_analyze(void) + } + kobject_init(&setting->kobj, &tlmi_attr_setting_ktype); + tlmi_priv.setting[i] = setting; +- tlmi_priv.settings_count++; + kfree(item); + } + +@@ -983,7 +985,12 @@ static void tlmi_remove(struct wmi_device *wdev) + + static int tlmi_probe(struct wmi_device *wdev, const void *context) + { +- tlmi_analyze(); ++ int ret; ++ ++ ret = tlmi_analyze(); ++ if (ret) ++ return ret; ++ + return tlmi_sysfs_init(); + } + +diff --git a/drivers/platform/x86/think-lmi.h b/drivers/platform/x86/think-lmi.h +index f8e26823075fd..2ce5086a5af27 100644 +--- a/drivers/platform/x86/think-lmi.h ++++ b/drivers/platform/x86/think-lmi.h +@@ -55,7 +55,6 @@ struct tlmi_attr_setting { + struct think_lmi { + struct wmi_device *wmi_device; + +- int settings_count; + bool can_set_bios_settings; + bool can_get_bios_selections; + bool can_set_bios_password; +-- +2.33.0 + diff --git a/queue-5.15/powerpc-5200-dts-fix-memory-node-unit-name.patch b/queue-5.15/powerpc-5200-dts-fix-memory-node-unit-name.patch new file mode 100644 index 00000000000..d1ad4198b0d --- /dev/null +++ b/queue-5.15/powerpc-5200-dts-fix-memory-node-unit-name.patch @@ -0,0 +1,191 @@ +From 7f9e7ce23a5010ad12a149c4554fc79fc7d9ec1f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 14 Oct 2021 00:05:31 +0200 +Subject: powerpc/5200: dts: fix memory node unit name + +From: Anatolij Gustschin + +[ Upstream commit aed2886a5e9ffc8269a4220bff1e9e030d3d2eb1 ] + +Fixes build warnings: +Warning (unit_address_vs_reg): /memory: node has a reg or ranges property, but no unit name + +Signed-off-by: Anatolij Gustschin +Reviewed-by: Rob Herring +Signed-off-by: Michael Ellerman +Link: https://lore.kernel.org/r/20211013220532.24759-4-agust@denx.de +Signed-off-by: Sasha Levin +--- + arch/powerpc/boot/dts/charon.dts | 2 +- + arch/powerpc/boot/dts/digsy_mtc.dts | 2 +- + arch/powerpc/boot/dts/lite5200.dts | 2 +- + arch/powerpc/boot/dts/lite5200b.dts | 2 +- + arch/powerpc/boot/dts/media5200.dts | 2 +- + arch/powerpc/boot/dts/mpc5200b.dtsi | 2 +- + arch/powerpc/boot/dts/o2d.dts | 2 +- + arch/powerpc/boot/dts/o2d.dtsi | 2 +- + arch/powerpc/boot/dts/o2dnt2.dts | 2 +- + arch/powerpc/boot/dts/o3dnt.dts | 2 +- + arch/powerpc/boot/dts/pcm032.dts | 2 +- + arch/powerpc/boot/dts/tqm5200.dts | 2 +- + 12 files changed, 12 insertions(+), 12 deletions(-) + +diff --git a/arch/powerpc/boot/dts/charon.dts b/arch/powerpc/boot/dts/charon.dts +index 408b486b13dff..cd589539f313f 100644 +--- a/arch/powerpc/boot/dts/charon.dts ++++ b/arch/powerpc/boot/dts/charon.dts +@@ -35,7 +35,7 @@ + }; + }; + +- memory { ++ memory@0 { + device_type = "memory"; + reg = <0x00000000 0x08000000>; // 128MB + }; +diff --git a/arch/powerpc/boot/dts/digsy_mtc.dts b/arch/powerpc/boot/dts/digsy_mtc.dts +index 0e5e9d3acf79f..19a14e62e65f4 100644 +--- a/arch/powerpc/boot/dts/digsy_mtc.dts ++++ b/arch/powerpc/boot/dts/digsy_mtc.dts +@@ -16,7 +16,7 @@ + model = "intercontrol,digsy-mtc"; + compatible = "intercontrol,digsy-mtc"; + +- memory { ++ memory@0 { + reg = <0x00000000 0x02000000>; // 32MB + }; + +diff --git a/arch/powerpc/boot/dts/lite5200.dts b/arch/powerpc/boot/dts/lite5200.dts +index cb2782dd6132c..e7b194775d783 100644 +--- a/arch/powerpc/boot/dts/lite5200.dts ++++ b/arch/powerpc/boot/dts/lite5200.dts +@@ -32,7 +32,7 @@ + }; + }; + +- memory { ++ memory@0 { + device_type = "memory"; + reg = <0x00000000 0x04000000>; // 64MB + }; +diff --git a/arch/powerpc/boot/dts/lite5200b.dts b/arch/powerpc/boot/dts/lite5200b.dts +index 2b86c81f90485..547cbe726ff23 100644 +--- a/arch/powerpc/boot/dts/lite5200b.dts ++++ b/arch/powerpc/boot/dts/lite5200b.dts +@@ -31,7 +31,7 @@ + led4 { gpios = <&gpio_simple 2 1>; }; + }; + +- memory { ++ memory@0 { + reg = <0x00000000 0x10000000>; // 256MB + }; + +diff --git a/arch/powerpc/boot/dts/media5200.dts b/arch/powerpc/boot/dts/media5200.dts +index 61cae9dcddef4..f3188018faceb 100644 +--- a/arch/powerpc/boot/dts/media5200.dts ++++ b/arch/powerpc/boot/dts/media5200.dts +@@ -32,7 +32,7 @@ + }; + }; + +- memory { ++ memory@0 { + reg = <0x00000000 0x08000000>; // 128MB RAM + }; + +diff --git a/arch/powerpc/boot/dts/mpc5200b.dtsi b/arch/powerpc/boot/dts/mpc5200b.dtsi +index 648fe31795f49..8b796f3b11da7 100644 +--- a/arch/powerpc/boot/dts/mpc5200b.dtsi ++++ b/arch/powerpc/boot/dts/mpc5200b.dtsi +@@ -33,7 +33,7 @@ + }; + }; + +- memory: memory { ++ memory: memory@0 { + device_type = "memory"; + reg = <0x00000000 0x04000000>; // 64MB + }; +diff --git a/arch/powerpc/boot/dts/o2d.dts b/arch/powerpc/boot/dts/o2d.dts +index 24a46f65e5299..e0a8d3034417f 100644 +--- a/arch/powerpc/boot/dts/o2d.dts ++++ b/arch/powerpc/boot/dts/o2d.dts +@@ -12,7 +12,7 @@ + model = "ifm,o2d"; + compatible = "ifm,o2d"; + +- memory { ++ memory@0 { + reg = <0x00000000 0x08000000>; // 128MB + }; + +diff --git a/arch/powerpc/boot/dts/o2d.dtsi b/arch/powerpc/boot/dts/o2d.dtsi +index 6661955a2be47..b55a9e5bd828c 100644 +--- a/arch/powerpc/boot/dts/o2d.dtsi ++++ b/arch/powerpc/boot/dts/o2d.dtsi +@@ -19,7 +19,7 @@ + model = "ifm,o2d"; + compatible = "ifm,o2d"; + +- memory { ++ memory@0 { + reg = <0x00000000 0x04000000>; // 64MB + }; + +diff --git a/arch/powerpc/boot/dts/o2dnt2.dts b/arch/powerpc/boot/dts/o2dnt2.dts +index eeba7f5507d5d..c2eedbd1f5fcb 100644 +--- a/arch/powerpc/boot/dts/o2dnt2.dts ++++ b/arch/powerpc/boot/dts/o2dnt2.dts +@@ -12,7 +12,7 @@ + model = "ifm,o2dnt2"; + compatible = "ifm,o2d"; + +- memory { ++ memory@0 { + reg = <0x00000000 0x08000000>; // 128MB + }; + +diff --git a/arch/powerpc/boot/dts/o3dnt.dts b/arch/powerpc/boot/dts/o3dnt.dts +index fd00396b0593e..e4c1bdd412716 100644 +--- a/arch/powerpc/boot/dts/o3dnt.dts ++++ b/arch/powerpc/boot/dts/o3dnt.dts +@@ -12,7 +12,7 @@ + model = "ifm,o3dnt"; + compatible = "ifm,o2d"; + +- memory { ++ memory@0 { + reg = <0x00000000 0x04000000>; // 64MB + }; + +diff --git a/arch/powerpc/boot/dts/pcm032.dts b/arch/powerpc/boot/dts/pcm032.dts +index 780e13d99e7b8..1895bc95900cc 100644 +--- a/arch/powerpc/boot/dts/pcm032.dts ++++ b/arch/powerpc/boot/dts/pcm032.dts +@@ -20,7 +20,7 @@ + model = "phytec,pcm032"; + compatible = "phytec,pcm032"; + +- memory { ++ memory@0 { + reg = <0x00000000 0x08000000>; // 128MB + }; + +diff --git a/arch/powerpc/boot/dts/tqm5200.dts b/arch/powerpc/boot/dts/tqm5200.dts +index 9ed0bc78967e1..5bb25a9e40a01 100644 +--- a/arch/powerpc/boot/dts/tqm5200.dts ++++ b/arch/powerpc/boot/dts/tqm5200.dts +@@ -32,7 +32,7 @@ + }; + }; + +- memory { ++ memory@0 { + device_type = "memory"; + reg = <0x00000000 0x04000000>; // 64MB + }; +-- +2.33.0 + diff --git a/queue-5.15/powerpc-8xx-fix-oops-with-strict_kernel_rwx-without-.patch b/queue-5.15/powerpc-8xx-fix-oops-with-strict_kernel_rwx-without-.patch new file mode 100644 index 00000000000..8896cde9341 --- /dev/null +++ b/queue-5.15/powerpc-8xx-fix-oops-with-strict_kernel_rwx-without-.patch @@ -0,0 +1,69 @@ +From a48fdf69b2a19338783d77e552f9950bce770253 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 29 Oct 2021 17:10:45 +0200 +Subject: powerpc/8xx: Fix Oops with STRICT_KERNEL_RWX without + DEBUG_RODATA_TEST + +From: Christophe Leroy + +[ Upstream commit c12ab8dbc492b992e1ea717db933cee568780c47 ] + +Until now, all tests involving CONFIG_STRICT_KERNEL_RWX were done with +DEBUG_RODATA_TEST to check the result. But now that +CONFIG_STRICT_KERNEL_RWX is selected by default, it came without +CONFIG_DEBUG_RODATA_TEST and led to the following Oops + +[ 6.830908] Freeing unused kernel image (initmem) memory: 352K +[ 6.840077] BUG: Unable to handle kernel data access on write at 0xc1285200 +[ 6.846836] Faulting instruction address: 0xc0004b6c +[ 6.851745] Oops: Kernel access of bad area, sig: 11 [#1] +[ 6.857075] BE PAGE_SIZE=16K PREEMPT CMPC885 +[ 6.861348] SAF3000 DIE NOTIFICATION +[ 6.864830] CPU: 0 PID: 1 Comm: swapper Not tainted 5.15.0-rc5-s3k-dev-02255-g2747d7b7916f #451 +[ 6.873429] NIP: c0004b6c LR: c0004b60 CTR: 00000000 +[ 6.878419] REGS: c902be60 TRAP: 0300 Not tainted (5.15.0-rc5-s3k-dev-02255-g2747d7b7916f) +[ 6.886852] MSR: 00009032 CR: 53000335 XER: 8000ff40 +[ 6.893564] DAR: c1285200 DSISR: 82000000 +[ 6.893564] GPR00: 0c000000 c902bf20 c20f4000 08000000 00000001 04001f00 c1800000 00000035 +[ 6.893564] GPR08: ff0001ff c1280000 00000002 c0004b60 00001000 00000000 c0004b1c 00000000 +[ 6.893564] GPR16: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 +[ 6.893564] GPR24: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 c1060000 +[ 6.932034] NIP [c0004b6c] kernel_init+0x50/0x138 +[ 6.936682] LR [c0004b60] kernel_init+0x44/0x138 +[ 6.941245] Call Trace: +[ 6.943653] [c902bf20] [c0004b60] kernel_init+0x44/0x138 (unreliable) +[ 6.950022] [c902bf30] [c001122c] ret_from_kernel_thread+0x5c/0x64 +[ 6.956135] Instruction dump: +[ 6.959060] 48ffc521 48045469 4800d8cd 3d20c086 89295fa0 2c090000 41820058 480796c9 +[ 6.966890] 4800e48d 3d20c128 39400002 3fe0c106 <91495200> 3bff8000 4806fa1d 481f7d75 +[ 6.974902] ---[ end trace 1e397bacba4aa610 ]--- + +0xc1285200 corresponds to 'system_state' global var that the kernel is trying to set to +SYSTEM_RUNNING. This var is above the RO/RW limit so it shouldn't Oops. + +It oopses because the dirty bit is missing. + +Signed-off-by: Christophe Leroy +Signed-off-by: Michael Ellerman +Link: https://lore.kernel.org/r/3d5800b0bbcd7b19761b98f50421358667b45331.1635520232.git.christophe.leroy@csgroup.eu +Signed-off-by: Sasha Levin +--- + arch/powerpc/kernel/head_8xx.S | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/arch/powerpc/kernel/head_8xx.S b/arch/powerpc/kernel/head_8xx.S +index 9bdb95f5694f7..2d596881b70e7 100644 +--- a/arch/powerpc/kernel/head_8xx.S ++++ b/arch/powerpc/kernel/head_8xx.S +@@ -755,7 +755,7 @@ _GLOBAL(mmu_pin_tlb) + cmplw r6, r9 + bdnzt lt, 2b + +-4: LOAD_REG_IMMEDIATE(r8, 0xf0 | _PAGE_SPS | _PAGE_SH | _PAGE_PRESENT) ++4: LOAD_REG_IMMEDIATE(r8, 0xf0 | _PAGE_DIRTY | _PAGE_SPS | _PAGE_SH | _PAGE_PRESENT) + 2: ori r0, r6, MD_EVALID + mtspr SPRN_MD_CTR, r5 + mtspr SPRN_MD_EPN, r0 +-- +2.33.0 + diff --git a/queue-5.15/powerpc-dcr-use-cmplwi-instead-of-3-argument-cmpli.patch b/queue-5.15/powerpc-dcr-use-cmplwi-instead-of-3-argument-cmpli.patch new file mode 100644 index 00000000000..266ce4d1060 --- /dev/null +++ b/queue-5.15/powerpc-dcr-use-cmplwi-instead-of-3-argument-cmpli.patch @@ -0,0 +1,66 @@ +From d0d83e7048bd91f52f129207ec319d0f56711244 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 14 Oct 2021 13:44:24 +1100 +Subject: powerpc/dcr: Use cmplwi instead of 3-argument cmpli +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Michael Ellerman + +[ Upstream commit fef071be57dc43679a32d5b0e6ee176d6f12e9f2 ] + +In dcr-low.S we use cmpli with three arguments, instead of four +arguments as defined in the ISA: + + cmpli cr0,r3,1024 + +This appears to be a PPC440-ism, looking at the "PPC440x5 CPU Core +User’s Manual" it shows cmpli having no L field, but implied to be 0 due +to the core being 32-bit. It mentions that the ISA defines four +arguments and recommends using cmplwi. + +It also corresponds to the old POWER instruction set, which had no L +field there, a reserved bit instead. + +dcr-low.S is only built 32-bit, because it is only built when +DCR_NATIVE=y, which is only selected by 40x and 44x. Looking at the +generated code (with gcc/gas) we see cmplwi as expected. + +Although gas is happy with the 3-argument version when building for +32-bit, the LLVM assembler is not and errors out with: + + arch/powerpc/sysdev/dcr-low.S:27:10: error: invalid operand for instruction + cmpli 0,%r3,1024; ... + ^ + +Switch to the cmplwi extended opcode, which avoids any confusion when +reading the ISA, fixes the issue with the LLVM assembler, and also means +the code could be built 64-bit in future (though that's very unlikely). + +Reported-by: Nick Desaulniers +Reviewed-by: Nick Desaulniers +Signed-off-by: Michael Ellerman +BugLink: https://github.com/ClangBuiltLinux/linux/issues/1419 +Link: https://lore.kernel.org/r/20211014024424.528848-1-mpe@ellerman.id.au +Signed-off-by: Sasha Levin +--- + arch/powerpc/sysdev/dcr-low.S | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/arch/powerpc/sysdev/dcr-low.S b/arch/powerpc/sysdev/dcr-low.S +index efeeb1b885a17..329b9c4ae5429 100644 +--- a/arch/powerpc/sysdev/dcr-low.S ++++ b/arch/powerpc/sysdev/dcr-low.S +@@ -11,7 +11,7 @@ + #include + + #define DCR_ACCESS_PROLOG(table) \ +- cmpli cr0,r3,1024; \ ++ cmplwi cr0,r3,1024; \ + rlwinm r3,r3,4,18,27; \ + lis r5,table@h; \ + ori r5,r5,table@l; \ +-- +2.33.0 + diff --git a/queue-5.15/ptp-ocp-fix-a-couple-null-vs-is_err-checks.patch b/queue-5.15/ptp-ocp-fix-a-couple-null-vs-is_err-checks.patch new file mode 100644 index 00000000000..301fe15ef14 --- /dev/null +++ b/queue-5.15/ptp-ocp-fix-a-couple-null-vs-is_err-checks.patch @@ -0,0 +1,52 @@ +From 26dbad6e4e97dc0c9a90b6fe8cde9f8a1ada8e7e Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 18 Nov 2021 14:22:11 +0300 +Subject: ptp: ocp: Fix a couple NULL vs IS_ERR() checks + +From: Dan Carpenter + +[ Upstream commit c7521d3aa2fa7fc785682758c99b5bcae503f6be ] + +The ptp_ocp_get_mem() function does not return NULL, it returns error +pointers. + +Fixes: 773bda964921 ("ptp: ocp: Expose various resources on the timecard.") +Signed-off-by: Dan Carpenter +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + drivers/ptp/ptp_ocp.c | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c +index caf9b37c5eb1e..e238ae8e94709 100644 +--- a/drivers/ptp/ptp_ocp.c ++++ b/drivers/ptp/ptp_ocp.c +@@ -1049,10 +1049,11 @@ ptp_ocp_register_ext(struct ptp_ocp *bp, struct ocp_resource *r) + if (!ext) + return -ENOMEM; + +- err = -EINVAL; + ext->mem = ptp_ocp_get_mem(bp, r); +- if (!ext->mem) ++ if (IS_ERR(ext->mem)) { ++ err = PTR_ERR(ext->mem); + goto out; ++ } + + ext->bp = bp; + ext->info = r->extra; +@@ -1122,8 +1123,8 @@ ptp_ocp_register_mem(struct ptp_ocp *bp, struct ocp_resource *r) + void __iomem *mem; + + mem = ptp_ocp_get_mem(bp, r); +- if (!mem) +- return -EINVAL; ++ if (IS_ERR(mem)) ++ return PTR_ERR(mem); + + bp_assign_entry(bp, r, mem); + +-- +2.33.0 + diff --git a/queue-5.15/rdma-bnxt_re-check-if-the-vlan-is-valid-before-repor.patch b/queue-5.15/rdma-bnxt_re-check-if-the-vlan-is-valid-before-repor.patch new file mode 100644 index 00000000000..e6d7ee3986d --- /dev/null +++ b/queue-5.15/rdma-bnxt_re-check-if-the-vlan-is-valid-before-repor.patch @@ -0,0 +1,57 @@ +From 5994f3ece7380bd176c9fd5a7329699946875d0f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 15 Sep 2021 05:32:42 -0700 +Subject: RDMA/bnxt_re: Check if the vlan is valid before reporting + +From: Selvin Xavier + +[ Upstream commit 6bda39149d4b8920fdb8744090653aca3daa792d ] + +When VF is configured with default vlan, HW strips the vlan from the +packet and driver receives it in Rx completion. VLAN needs to be reported +for UD work completion only if the vlan is configured on the host. Add a +check for valid vlan in the UD receive path. + +Link: https://lore.kernel.org/r/1631709163-2287-12-git-send-email-selvin.xavier@broadcom.com +Signed-off-by: Selvin Xavier +Signed-off-by: Jason Gunthorpe +Signed-off-by: Sasha Levin +--- + drivers/infiniband/hw/bnxt_re/ib_verbs.c | 12 +++++++++--- + 1 file changed, 9 insertions(+), 3 deletions(-) + +diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c +index 408dfbcc47b5e..b7ec3a3926785 100644 +--- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c ++++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c +@@ -3354,8 +3354,11 @@ static void bnxt_re_process_res_ud_wc(struct bnxt_re_qp *qp, + struct ib_wc *wc, + struct bnxt_qplib_cqe *cqe) + { ++ struct bnxt_re_dev *rdev; ++ u16 vlan_id = 0; + u8 nw_type; + ++ rdev = qp->rdev; + wc->opcode = IB_WC_RECV; + wc->status = __rc_to_ib_wc_status(cqe->status); + +@@ -3367,9 +3370,12 @@ static void bnxt_re_process_res_ud_wc(struct bnxt_re_qp *qp, + memcpy(wc->smac, cqe->smac, ETH_ALEN); + wc->wc_flags |= IB_WC_WITH_SMAC; + if (cqe->flags & CQ_RES_UD_FLAGS_META_FORMAT_VLAN) { +- wc->vlan_id = (cqe->cfa_meta & 0xFFF); +- if (wc->vlan_id < 0x1000) +- wc->wc_flags |= IB_WC_WITH_VLAN; ++ vlan_id = (cqe->cfa_meta & 0xFFF); ++ } ++ /* Mark only if vlan_id is non zero */ ++ if (vlan_id && bnxt_re_check_if_vlan_valid(rdev, vlan_id)) { ++ wc->vlan_id = vlan_id; ++ wc->wc_flags |= IB_WC_WITH_VLAN; + } + nw_type = (cqe->flags & CQ_RES_UD_FLAGS_ROCE_IP_VER_MASK) >> + CQ_RES_UD_FLAGS_ROCE_IP_VER_SFT; +-- +2.33.0 + diff --git a/queue-5.15/rdma-core-set-send-and-receive-cq-before-forwarding-.patch b/queue-5.15/rdma-core-set-send-and-receive-cq-before-forwarding-.patch new file mode 100644 index 00000000000..d65ca6439f7 --- /dev/null +++ b/queue-5.15/rdma-core-set-send-and-receive-cq-before-forwarding-.patch @@ -0,0 +1,90 @@ +From 35bf4ab2e2ceaa4c8ebd935495586ee254466455 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 11 Nov 2021 13:45:00 +0200 +Subject: RDMA/core: Set send and receive CQ before forwarding to the driver + +From: Leon Romanovsky + +[ Upstream commit 6cd7397d01c4a3e09757840299e4f114f0aa5fa0 ] + +Preset both receive and send CQ pointers prior to call to the drivers and +overwrite it later again till the mlx4 is going to be changed do not +overwrite ibqp properties. + +This change is needed for mlx5, because in case of QP creation failure, it +will go to the path of QP destroy which relies on proper CQ pointers. + + BUG: KASAN: use-after-free in create_qp.cold+0x164/0x16e [mlx5_ib] + Write of size 8 at addr ffff8880064c55c0 by task a.out/246 + + CPU: 0 PID: 246 Comm: a.out Not tainted 5.15.0+ #291 + Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014 + Call Trace: + dump_stack_lvl+0x45/0x59 + print_address_description.constprop.0+0x1f/0x140 + kasan_report.cold+0x83/0xdf + create_qp.cold+0x164/0x16e [mlx5_ib] + mlx5_ib_create_qp+0x358/0x28a0 [mlx5_ib] + create_qp.part.0+0x45b/0x6a0 [ib_core] + ib_create_qp_user+0x97/0x150 [ib_core] + ib_uverbs_handler_UVERBS_METHOD_QP_CREATE+0x92c/0x1250 [ib_uverbs] + ib_uverbs_cmd_verbs+0x1c38/0x3150 [ib_uverbs] + ib_uverbs_ioctl+0x169/0x260 [ib_uverbs] + __x64_sys_ioctl+0x866/0x14d0 + do_syscall_64+0x3d/0x90 + entry_SYSCALL_64_after_hwframe+0x44/0xae + + Allocated by task 246: + kasan_save_stack+0x1b/0x40 + __kasan_kmalloc+0xa4/0xd0 + create_qp.part.0+0x92/0x6a0 [ib_core] + ib_create_qp_user+0x97/0x150 [ib_core] + ib_uverbs_handler_UVERBS_METHOD_QP_CREATE+0x92c/0x1250 [ib_uverbs] + ib_uverbs_cmd_verbs+0x1c38/0x3150 [ib_uverbs] + ib_uverbs_ioctl+0x169/0x260 [ib_uverbs] + __x64_sys_ioctl+0x866/0x14d0 + do_syscall_64+0x3d/0x90 + entry_SYSCALL_64_after_hwframe+0x44/0xae + + Freed by task 246: + kasan_save_stack+0x1b/0x40 + kasan_set_track+0x1c/0x30 + kasan_set_free_info+0x20/0x30 + __kasan_slab_free+0x10c/0x150 + slab_free_freelist_hook+0xb4/0x1b0 + kfree+0xe7/0x2a0 + create_qp.part.0+0x52b/0x6a0 [ib_core] + ib_create_qp_user+0x97/0x150 [ib_core] + ib_uverbs_handler_UVERBS_METHOD_QP_CREATE+0x92c/0x1250 [ib_uverbs] + ib_uverbs_cmd_verbs+0x1c38/0x3150 [ib_uverbs] + ib_uverbs_ioctl+0x169/0x260 [ib_uverbs] + __x64_sys_ioctl+0x866/0x14d0 + do_syscall_64+0x3d/0x90 + entry_SYSCALL_64_after_hwframe+0x44/0xae + +Fixes: 514aee660df4 ("RDMA: Globally allocate and release QP memory") +Link: https://lore.kernel.org/r/2dbb2e2cbb1efb188a500e5634be1d71956424ce.1636631035.git.leonro@nvidia.com +Signed-off-by: Leon Romanovsky +Signed-off-by: Jason Gunthorpe +Signed-off-by: Sasha Levin +--- + drivers/infiniband/core/verbs.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c +index 89a2b21976d63..20a46d8731455 100644 +--- a/drivers/infiniband/core/verbs.c ++++ b/drivers/infiniband/core/verbs.c +@@ -1232,6 +1232,9 @@ static struct ib_qp *create_qp(struct ib_device *dev, struct ib_pd *pd, + INIT_LIST_HEAD(&qp->rdma_mrs); + INIT_LIST_HEAD(&qp->sig_mrs); + ++ qp->send_cq = attr->send_cq; ++ qp->recv_cq = attr->recv_cq; ++ + rdma_restrack_new(&qp->res, RDMA_RESTRACK_QP); + WARN_ONCE(!udata && !caller, "Missing kernel QP owner"); + rdma_restrack_set_name(&qp->res, udata ? NULL : caller); +-- +2.33.0 + diff --git a/queue-5.15/rdma-core-use-kvzalloc-when-allocating-the-struct-ib.patch b/queue-5.15/rdma-core-use-kvzalloc-when-allocating-the-struct-ib.patch new file mode 100644 index 00000000000..75d239de8ff --- /dev/null +++ b/queue-5.15/rdma-core-use-kvzalloc-when-allocating-the-struct-ib.patch @@ -0,0 +1,56 @@ +From 437aed5a636ed30bb8c79be07f08b267dae2ade0 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 19 Oct 2021 08:26:56 +0800 +Subject: RDMA/core: Use kvzalloc when allocating the struct ib_port + +From: wangyugui + +[ Upstream commit 911a81c9c7092bfd75432ce79b2ef879127ea065 ] + +The 'struct attribute' flex array contains some struct lock_class_key's +which become big when lockdep is turned on. Big enough that some drivers +will not load when CONFIG_PROVE_LOCKING=y because they cannot allocate +enough memory: + + WARNING: CPU: 36 PID: 8 at mm/page_alloc.c:5350 __alloc_pages+0x27e/0x3e0 + Call Trace: + kmalloc_order+0x2a/0xb0 + kmalloc_order_trace+0x19/0xf0 + __kmalloc+0x231/0x270 + ib_setup_port_attrs+0xd8/0x870 [ib_core] + ib_register_device+0x419/0x4e0 [ib_core] + bnxt_re_task+0x208/0x2d0 [bnxt_re] + +Link: https://lore.kernel.org/r/20211019002656.17745-1-wangyugui@e16-tech.com +Signed-off-by: wangyugui +Signed-off-by: Jason Gunthorpe +Signed-off-by: Sasha Levin +--- + drivers/infiniband/core/sysfs.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c +index 6146c3c1cbe5c..8d709986b88c7 100644 +--- a/drivers/infiniband/core/sysfs.c ++++ b/drivers/infiniband/core/sysfs.c +@@ -757,7 +757,7 @@ static void ib_port_release(struct kobject *kobj) + if (port->hw_stats_data) + kfree(port->hw_stats_data->stats); + kfree(port->hw_stats_data); +- kfree(port); ++ kvfree(port); + } + + static void ib_port_gid_attr_release(struct kobject *kobj) +@@ -1189,7 +1189,7 @@ static struct ib_port *setup_port(struct ib_core_device *coredev, int port_num, + struct ib_port *p; + int ret; + +- p = kzalloc(struct_size(p, attrs_list, ++ p = kvzalloc(struct_size(p, attrs_list, + attr->gid_tbl_len + attr->pkey_tbl_len), + GFP_KERNEL); + if (!p) +-- +2.33.0 + diff --git a/queue-5.15/rdma-mlx4-do-not-fail-the-registration-on-port-stats.patch b/queue-5.15/rdma-mlx4-do-not-fail-the-registration-on-port-stats.patch new file mode 100644 index 00000000000..246f9f6d393 --- /dev/null +++ b/queue-5.15/rdma-mlx4-do-not-fail-the-registration-on-port-stats.patch @@ -0,0 +1,69 @@ +From 66509ec2362e6497b68dd57f9f942c9999097796 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 15 Nov 2021 11:15:19 +0100 +Subject: RDMA/mlx4: Do not fail the registration on port stats + +From: Jack Wang + +[ Upstream commit 378c67413de18b69fb3bb78d8c4f0f1192cfa973 ] + +If the FW doesn't support MLX4_DEV_CAP_FLAG2_DIAG_PER_PORT, mlx4 driver +will fail the ib_setup_port_attrs, which is called from +ib_register_device()/enable_device_and_get(), in the end leads to device +not detected[1][2] + +To fix it, add a new mlx4_ib_hw_stats_ops1, w/o alloc_hw_port_stats if FW +does not support MLX4_DEV_CAP_FLAG2_DIAG_PER_PORT. + +[1] https://bugzilla.redhat.com/show_bug.cgi?id=2014094 +[2] https://lore.kernel.org/linux-rdma/CAMGffEn2wvEnmzc0xe=xYiCLqpphiHDBxCxqAELrBofbUAMQxw@mail.gmail.com + +Fixes: 4b5f4d3fb408 ("RDMA: Split the alloc_hw_stats() ops to port and device variants") +Link: https://lore.kernel.org/r/20211115101519.27210-1-jinpu.wang@ionos.com +Signed-off-by: Jack Wang +Reviewed-by: Leon Romanovsky +Signed-off-by: Jason Gunthorpe +Signed-off-by: Sasha Levin +--- + drivers/infiniband/hw/mlx4/main.c | 18 +++++++++++++++--- + 1 file changed, 15 insertions(+), 3 deletions(-) + +diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c +index f367f4a4abffc..aec2e1851fa70 100644 +--- a/drivers/infiniband/hw/mlx4/main.c ++++ b/drivers/infiniband/hw/mlx4/main.c +@@ -2217,6 +2217,11 @@ static const struct ib_device_ops mlx4_ib_hw_stats_ops = { + .get_hw_stats = mlx4_ib_get_hw_stats, + }; + ++static const struct ib_device_ops mlx4_ib_hw_stats_ops1 = { ++ .alloc_hw_device_stats = mlx4_ib_alloc_hw_device_stats, ++ .get_hw_stats = mlx4_ib_get_hw_stats, ++}; ++ + static int mlx4_ib_alloc_diag_counters(struct mlx4_ib_dev *ibdev) + { + struct mlx4_ib_diag_counters *diag = ibdev->diag_counters; +@@ -2229,9 +2234,16 @@ static int mlx4_ib_alloc_diag_counters(struct mlx4_ib_dev *ibdev) + return 0; + + for (i = 0; i < MLX4_DIAG_COUNTERS_TYPES; i++) { +- /* i == 1 means we are building port counters */ +- if (i && !per_port) +- continue; ++ /* ++ * i == 1 means we are building port counters, set a different ++ * stats ops without port stats callback. ++ */ ++ if (i && !per_port) { ++ ib_set_device_ops(&ibdev->ib_dev, ++ &mlx4_ib_hw_stats_ops1); ++ ++ return 0; ++ } + + ret = __mlx4_ib_alloc_diag_counters(ibdev, &diag[i].name, + &diag[i].offset, +-- +2.33.0 + diff --git a/queue-5.15/rdma-rxe-separate-hw-and-sw-l-rkeys.patch b/queue-5.15/rdma-rxe-separate-hw-and-sw-l-rkeys.patch new file mode 100644 index 00000000000..061ac681c59 --- /dev/null +++ b/queue-5.15/rdma-rxe-separate-hw-and-sw-l-rkeys.patch @@ -0,0 +1,331 @@ +From e55b31960044b9b5e1f4b8cdb96f8322f375a1d5 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 14 Sep 2021 11:42:05 -0500 +Subject: RDMA/rxe: Separate HW and SW l/rkeys + +From: Bob Pearson + +[ Upstream commit 001345339f4ca85790a1644a74e33ae77ac116be ] + +Separate software and simulated hardware lkeys and rkeys for MRs and MWs. +This makes struct ib_mr and struct ib_mw isolated from hardware changes +triggered by executing work requests. + +This change fixes a bug seen in blktest. + +Link: https://lore.kernel.org/r/20210914164206.19768-4-rpearsonhpe@gmail.com +Signed-off-by: Bob Pearson +Signed-off-by: Jason Gunthorpe +Signed-off-by: Sasha Levin +--- + drivers/infiniband/sw/rxe/rxe_loc.h | 1 + + drivers/infiniband/sw/rxe/rxe_mr.c | 69 ++++++++++++++++++++++----- + drivers/infiniband/sw/rxe/rxe_mw.c | 30 ++++++------ + drivers/infiniband/sw/rxe/rxe_req.c | 14 ++---- + drivers/infiniband/sw/rxe/rxe_verbs.h | 18 ++----- + 5 files changed, 81 insertions(+), 51 deletions(-) + +diff --git a/drivers/infiniband/sw/rxe/rxe_loc.h b/drivers/infiniband/sw/rxe/rxe_loc.h +index f0c954575bdec..4fd73b51fabf2 100644 +--- a/drivers/infiniband/sw/rxe/rxe_loc.h ++++ b/drivers/infiniband/sw/rxe/rxe_loc.h +@@ -86,6 +86,7 @@ struct rxe_mr *lookup_mr(struct rxe_pd *pd, int access, u32 key, + int mr_check_range(struct rxe_mr *mr, u64 iova, size_t length); + int advance_dma_data(struct rxe_dma_info *dma, unsigned int length); + int rxe_invalidate_mr(struct rxe_qp *qp, u32 rkey); ++int rxe_reg_fast_mr(struct rxe_qp *qp, struct rxe_send_wqe *wqe); + int rxe_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata); + void rxe_mr_cleanup(struct rxe_pool_entry *arg); + +diff --git a/drivers/infiniband/sw/rxe/rxe_mr.c b/drivers/infiniband/sw/rxe/rxe_mr.c +index 5890a82462161..bedcf15aaea75 100644 +--- a/drivers/infiniband/sw/rxe/rxe_mr.c ++++ b/drivers/infiniband/sw/rxe/rxe_mr.c +@@ -48,8 +48,14 @@ static void rxe_mr_init(int access, struct rxe_mr *mr) + u32 lkey = mr->pelem.index << 8 | rxe_get_next_key(-1); + u32 rkey = (access & IB_ACCESS_REMOTE) ? lkey : 0; + +- mr->ibmr.lkey = lkey; +- mr->ibmr.rkey = rkey; ++ /* set ibmr->l/rkey and also copy into private l/rkey ++ * for user MRs these will always be the same ++ * for cases where caller 'owns' the key portion ++ * they may be different until REG_MR WQE is executed. ++ */ ++ mr->lkey = mr->ibmr.lkey = lkey; ++ mr->rkey = mr->ibmr.rkey = rkey; ++ + mr->state = RXE_MR_STATE_INVALID; + mr->type = RXE_MR_TYPE_NONE; + mr->map_shift = ilog2(RXE_BUF_PER_MAP); +@@ -191,10 +197,8 @@ int rxe_mr_init_fast(struct rxe_pd *pd, int max_pages, struct rxe_mr *mr) + { + int err; + +- rxe_mr_init(0, mr); +- +- /* In fastreg, we also set the rkey */ +- mr->ibmr.rkey = mr->ibmr.lkey; ++ /* always allow remote access for FMRs */ ++ rxe_mr_init(IB_ACCESS_REMOTE, mr); + + err = rxe_mr_alloc(mr, max_pages); + if (err) +@@ -507,8 +511,8 @@ struct rxe_mr *lookup_mr(struct rxe_pd *pd, int access, u32 key, + if (!mr) + return NULL; + +- if (unlikely((type == RXE_LOOKUP_LOCAL && mr_lkey(mr) != key) || +- (type == RXE_LOOKUP_REMOTE && mr_rkey(mr) != key) || ++ if (unlikely((type == RXE_LOOKUP_LOCAL && mr->lkey != key) || ++ (type == RXE_LOOKUP_REMOTE && mr->rkey != key) || + mr_pd(mr) != pd || (access && !(access & mr->access)) || + mr->state != RXE_MR_STATE_VALID)) { + rxe_drop_ref(mr); +@@ -531,9 +535,9 @@ int rxe_invalidate_mr(struct rxe_qp *qp, u32 rkey) + goto err; + } + +- if (rkey != mr->ibmr.rkey) { +- pr_err("%s: rkey (%#x) doesn't match mr->ibmr.rkey (%#x)\n", +- __func__, rkey, mr->ibmr.rkey); ++ if (rkey != mr->rkey) { ++ pr_err("%s: rkey (%#x) doesn't match mr->rkey (%#x)\n", ++ __func__, rkey, mr->rkey); + ret = -EINVAL; + goto err_drop_ref; + } +@@ -554,6 +558,49 @@ err: + return ret; + } + ++/* user can (re)register fast MR by executing a REG_MR WQE. ++ * user is expected to hold a reference on the ib mr until the ++ * WQE completes. ++ * Once a fast MR is created this is the only way to change the ++ * private keys. It is the responsibility of the user to maintain ++ * the ib mr keys in sync with rxe mr keys. ++ */ ++int rxe_reg_fast_mr(struct rxe_qp *qp, struct rxe_send_wqe *wqe) ++{ ++ struct rxe_mr *mr = to_rmr(wqe->wr.wr.reg.mr); ++ u32 key = wqe->wr.wr.reg.key; ++ u32 access = wqe->wr.wr.reg.access; ++ ++ /* user can only register MR in free state */ ++ if (unlikely(mr->state != RXE_MR_STATE_FREE)) { ++ pr_warn("%s: mr->lkey = 0x%x not free\n", ++ __func__, mr->lkey); ++ return -EINVAL; ++ } ++ ++ /* user can only register mr with qp in same protection domain */ ++ if (unlikely(qp->ibqp.pd != mr->ibmr.pd)) { ++ pr_warn("%s: qp->pd and mr->pd don't match\n", ++ __func__); ++ return -EINVAL; ++ } ++ ++ /* user is only allowed to change key portion of l/rkey */ ++ if (unlikely((mr->lkey & ~0xff) != (key & ~0xff))) { ++ pr_warn("%s: key = 0x%x has wrong index mr->lkey = 0x%x\n", ++ __func__, key, mr->lkey); ++ return -EINVAL; ++ } ++ ++ mr->access = access; ++ mr->lkey = key; ++ mr->rkey = (access & IB_ACCESS_REMOTE) ? key : 0; ++ mr->iova = wqe->wr.wr.reg.mr->iova; ++ mr->state = RXE_MR_STATE_VALID; ++ ++ return 0; ++} ++ + int rxe_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata) + { + struct rxe_mr *mr = to_rmr(ibmr); +diff --git a/drivers/infiniband/sw/rxe/rxe_mw.c b/drivers/infiniband/sw/rxe/rxe_mw.c +index 5ba77df7598ed..a5e2ea7d80f02 100644 +--- a/drivers/infiniband/sw/rxe/rxe_mw.c ++++ b/drivers/infiniband/sw/rxe/rxe_mw.c +@@ -21,7 +21,7 @@ int rxe_alloc_mw(struct ib_mw *ibmw, struct ib_udata *udata) + } + + rxe_add_index(mw); +- ibmw->rkey = (mw->pelem.index << 8) | rxe_get_next_key(-1); ++ mw->rkey = ibmw->rkey = (mw->pelem.index << 8) | rxe_get_next_key(-1); + mw->state = (mw->ibmw.type == IB_MW_TYPE_2) ? + RXE_MW_STATE_FREE : RXE_MW_STATE_VALID; + spin_lock_init(&mw->lock); +@@ -71,6 +71,8 @@ int rxe_dealloc_mw(struct ib_mw *ibmw) + static int rxe_check_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe, + struct rxe_mw *mw, struct rxe_mr *mr) + { ++ u32 key = wqe->wr.wr.mw.rkey & 0xff; ++ + if (mw->ibmw.type == IB_MW_TYPE_1) { + if (unlikely(mw->state != RXE_MW_STATE_VALID)) { + pr_err_once( +@@ -108,7 +110,7 @@ static int rxe_check_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe, + } + } + +- if (unlikely((wqe->wr.wr.mw.rkey & 0xff) == (mw->ibmw.rkey & 0xff))) { ++ if (unlikely(key == (mw->rkey & 0xff))) { + pr_err_once("attempt to bind MW with same key\n"); + return -EINVAL; + } +@@ -161,13 +163,9 @@ static int rxe_check_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe, + static void rxe_do_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe, + struct rxe_mw *mw, struct rxe_mr *mr) + { +- u32 rkey; +- u32 new_rkey; +- +- rkey = mw->ibmw.rkey; +- new_rkey = (rkey & 0xffffff00) | (wqe->wr.wr.mw.rkey & 0x000000ff); ++ u32 key = wqe->wr.wr.mw.rkey & 0xff; + +- mw->ibmw.rkey = new_rkey; ++ mw->rkey = (mw->rkey & ~0xff) | key; + mw->access = wqe->wr.wr.mw.access; + mw->state = RXE_MW_STATE_VALID; + mw->addr = wqe->wr.wr.mw.addr; +@@ -197,29 +195,29 @@ int rxe_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe) + struct rxe_mw *mw; + struct rxe_mr *mr; + struct rxe_dev *rxe = to_rdev(qp->ibqp.device); ++ u32 mw_rkey = wqe->wr.wr.mw.mw_rkey; ++ u32 mr_lkey = wqe->wr.wr.mw.mr_lkey; + unsigned long flags; + +- mw = rxe_pool_get_index(&rxe->mw_pool, +- wqe->wr.wr.mw.mw_rkey >> 8); ++ mw = rxe_pool_get_index(&rxe->mw_pool, mw_rkey >> 8); + if (unlikely(!mw)) { + ret = -EINVAL; + goto err; + } + +- if (unlikely(mw->ibmw.rkey != wqe->wr.wr.mw.mw_rkey)) { ++ if (unlikely(mw->rkey != mw_rkey)) { + ret = -EINVAL; + goto err_drop_mw; + } + + if (likely(wqe->wr.wr.mw.length)) { +- mr = rxe_pool_get_index(&rxe->mr_pool, +- wqe->wr.wr.mw.mr_lkey >> 8); ++ mr = rxe_pool_get_index(&rxe->mr_pool, mr_lkey >> 8); + if (unlikely(!mr)) { + ret = -EINVAL; + goto err_drop_mw; + } + +- if (unlikely(mr->ibmr.lkey != wqe->wr.wr.mw.mr_lkey)) { ++ if (unlikely(mr->lkey != mr_lkey)) { + ret = -EINVAL; + goto err_drop_mr; + } +@@ -292,7 +290,7 @@ int rxe_invalidate_mw(struct rxe_qp *qp, u32 rkey) + goto err; + } + +- if (rkey != mw->ibmw.rkey) { ++ if (rkey != mw->rkey) { + ret = -EINVAL; + goto err_drop_ref; + } +@@ -323,7 +321,7 @@ struct rxe_mw *rxe_lookup_mw(struct rxe_qp *qp, int access, u32 rkey) + if (!mw) + return NULL; + +- if (unlikely((rxe_mw_rkey(mw) != rkey) || rxe_mw_pd(mw) != pd || ++ if (unlikely((mw->rkey != rkey) || rxe_mw_pd(mw) != pd || + (mw->ibmw.type == IB_MW_TYPE_2 && mw->qp != qp) || + (mw->length == 0) || + (access && !(access & mw->access)) || +diff --git a/drivers/infiniband/sw/rxe/rxe_req.c b/drivers/infiniband/sw/rxe/rxe_req.c +index 3894197a82f62..fc996fd31e589 100644 +--- a/drivers/infiniband/sw/rxe/rxe_req.c ++++ b/drivers/infiniband/sw/rxe/rxe_req.c +@@ -572,7 +572,6 @@ static void update_state(struct rxe_qp *qp, struct rxe_send_wqe *wqe, + static int rxe_do_local_ops(struct rxe_qp *qp, struct rxe_send_wqe *wqe) + { + u8 opcode = wqe->wr.opcode; +- struct rxe_mr *mr; + u32 rkey; + int ret; + +@@ -590,14 +589,11 @@ static int rxe_do_local_ops(struct rxe_qp *qp, struct rxe_send_wqe *wqe) + } + break; + case IB_WR_REG_MR: +- mr = to_rmr(wqe->wr.wr.reg.mr); +- rxe_add_ref(mr); +- mr->state = RXE_MR_STATE_VALID; +- mr->access = wqe->wr.wr.reg.access; +- mr->ibmr.lkey = wqe->wr.wr.reg.key; +- mr->ibmr.rkey = wqe->wr.wr.reg.key; +- mr->iova = wqe->wr.wr.reg.mr->iova; +- rxe_drop_ref(mr); ++ ret = rxe_reg_fast_mr(qp, wqe); ++ if (unlikely(ret)) { ++ wqe->status = IB_WC_LOC_QP_OP_ERR; ++ return ret; ++ } + break; + case IB_WR_BIND_MW: + ret = rxe_bind_mw(qp, wqe); +diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.h b/drivers/infiniband/sw/rxe/rxe_verbs.h +index ac2a2148027f4..d90b1d77de347 100644 +--- a/drivers/infiniband/sw/rxe/rxe_verbs.h ++++ b/drivers/infiniband/sw/rxe/rxe_verbs.h +@@ -313,6 +313,8 @@ struct rxe_mr { + + struct ib_umem *umem; + ++ u32 lkey; ++ u32 rkey; + enum rxe_mr_state state; + enum rxe_mr_type type; + u64 va; +@@ -350,6 +352,7 @@ struct rxe_mw { + enum rxe_mw_state state; + struct rxe_qp *qp; /* Type 2 only */ + struct rxe_mr *mr; ++ u32 rkey; + int access; + u64 addr; + u64 length; +@@ -474,26 +477,11 @@ static inline struct rxe_pd *mr_pd(struct rxe_mr *mr) + return to_rpd(mr->ibmr.pd); + } + +-static inline u32 mr_lkey(struct rxe_mr *mr) +-{ +- return mr->ibmr.lkey; +-} +- +-static inline u32 mr_rkey(struct rxe_mr *mr) +-{ +- return mr->ibmr.rkey; +-} +- + static inline struct rxe_pd *rxe_mw_pd(struct rxe_mw *mw) + { + return to_rpd(mw->ibmw.pd); + } + +-static inline u32 rxe_mw_rkey(struct rxe_mw *mw) +-{ +- return mw->ibmw.rkey; +-} +- + int rxe_register_device(struct rxe_dev *rxe, const char *ibdev_name); + + void rxe_mc_cleanup(struct rxe_pool_entry *arg); +-- +2.33.0 + diff --git a/queue-5.15/riscv-fix-building-external-modules.patch b/queue-5.15/riscv-fix-building-external-modules.patch new file mode 100644 index 00000000000..a5b56cd83a5 --- /dev/null +++ b/queue-5.15/riscv-fix-building-external-modules.patch @@ -0,0 +1,43 @@ +From 47c65aee929d032b1d4e4c2cdfe13b695e4f3e0e Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 2 Nov 2021 16:51:43 +0100 +Subject: riscv: fix building external modules + +From: Andreas Schwab + +[ Upstream commit 5a19c7e06236a9c55dfc001bb4d1a8f1950d23e7 ] + +When building external modules, vdso_prepare should not be run. If the +kernel sources are read-only, it will fail. + +Fixes: fde9c59aebaf ("riscv: explicitly use symbol offsets for VDSO") +Signed-off-by: Andreas Schwab +Reviewed-by: Nathan Chancellor +Tested-by: Nathan Chancellor +Signed-off-by: Palmer Dabbelt +Signed-off-by: Sasha Levin +--- + arch/riscv/Makefile | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile +index 0eb4568fbd290..41f3a75fe2ec8 100644 +--- a/arch/riscv/Makefile ++++ b/arch/riscv/Makefile +@@ -108,11 +108,13 @@ PHONY += vdso_install + vdso_install: + $(Q)$(MAKE) $(build)=arch/riscv/kernel/vdso $@ + ++ifeq ($(KBUILD_EXTMOD),) + ifeq ($(CONFIG_MMU),y) + prepare: vdso_prepare + vdso_prepare: prepare0 + $(Q)$(MAKE) $(build)=arch/riscv/kernel/vdso include/generated/vdso-offsets.h + endif ++endif + + ifneq ($(CONFIG_XIP_KERNEL),y) + ifeq ($(CONFIG_RISCV_M_MODE)$(CONFIG_SOC_CANAAN),yy) +-- +2.33.0 + diff --git a/queue-5.15/samples-bpf-fix-incorrect-use-of-strlen-in-xdp_redir.patch b/queue-5.15/samples-bpf-fix-incorrect-use-of-strlen-in-xdp_redir.patch new file mode 100644 index 00000000000..94d5cdf2c00 --- /dev/null +++ b/queue-5.15/samples-bpf-fix-incorrect-use-of-strlen-in-xdp_redir.patch @@ -0,0 +1,56 @@ +From b90479d36d9296f5b3fba0a55238d59c3f9530ca Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 12 Nov 2021 07:33:01 +0530 +Subject: samples/bpf: Fix incorrect use of strlen in xdp_redirect_cpu + +From: Kumar Kartikeya Dwivedi + +[ Upstream commit 2453afe3845523d9dfe89dbfb3d71abfa095e260 ] + +Commit b599015f044d ("samples/bpf: Fix application of sizeof to pointer") +tried to fix a bug where sizeof was incorrectly applied to a pointer instead +of the array string was being copied to, to find the destination buffer size, +but ended up using strlen, which is still incorrect. However, on closer look +ifname_buf has no other use, hence directly use optarg. + +Fixes: b599015f044d ("samples/bpf: Fix application of sizeof to pointer") +Fixes: e531a220cc59 ("samples: bpf: Convert xdp_redirect_cpu to XDP samples helper") +Signed-off-by: Kumar Kartikeya Dwivedi +Signed-off-by: Daniel Borkmann +Reviewed-by: Alexander Lobakin +Tested-by: Alexander Lobakin +Link: https://lore.kernel.org/bpf/20211112020301.528357-1-memxor@gmail.com +Signed-off-by: Alexei Starovoitov +Signed-off-by: Sasha Levin +--- + samples/bpf/xdp_redirect_cpu_user.c | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +diff --git a/samples/bpf/xdp_redirect_cpu_user.c b/samples/bpf/xdp_redirect_cpu_user.c +index d84e6949007cc..a81704d3317ba 100644 +--- a/samples/bpf/xdp_redirect_cpu_user.c ++++ b/samples/bpf/xdp_redirect_cpu_user.c +@@ -309,7 +309,6 @@ int main(int argc, char **argv) + const char *mprog_filename = NULL, *mprog_name = NULL; + struct xdp_redirect_cpu *skel; + struct bpf_map_info info = {}; +- char ifname_buf[IF_NAMESIZE]; + struct bpf_cpumap_val value; + __u32 infosz = sizeof(info); + int ret = EXIT_FAIL_OPTION; +@@ -390,10 +389,10 @@ int main(int argc, char **argv) + case 'd': + if (strlen(optarg) >= IF_NAMESIZE) { + fprintf(stderr, "-d/--dev name too long\n"); ++ usage(argv, long_options, __doc__, mask, true, skel->obj); + goto end_cpu; + } +- safe_strncpy(ifname_buf, optarg, strlen(ifname_buf)); +- ifindex = if_nametoindex(ifname_buf); ++ ifindex = if_nametoindex(optarg); + if (!ifindex) + ifindex = strtoul(optarg, NULL, 0); + if (!ifindex) { +-- +2.33.0 + diff --git a/queue-5.15/samples-bpf-fix-summary-per-sec-stats-in-xdp_sample_.patch b/queue-5.15/samples-bpf-fix-summary-per-sec-stats-in-xdp_sample_.patch new file mode 100644 index 00000000000..152e10bf94b --- /dev/null +++ b/queue-5.15/samples-bpf-fix-summary-per-sec-stats-in-xdp_sample_.patch @@ -0,0 +1,173 @@ +From 39c23324dd78e812ef09847040d2a8f713621bd9 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 11 Nov 2021 22:57:03 +0100 +Subject: samples/bpf: Fix summary per-sec stats in xdp_sample_user + +From: Alexander Lobakin + +[ Upstream commit dc14ca4644f48b1cfa93631e35c28bdc011ad109 ] + +sample_summary_print() uses accumulated period to calculate and display +per-sec averages. This period gets incremented by sampling interval each +time a new sample is formed, and thus equals to the number of samples +collected multiplied by this interval. + +However, the totals are being calculated differently, they receive current +sample statistics already divided by the interval gotten as a difference +between sample timestamps for better precision -- in other words, they are +being incremented by the per-sec values each sample. + +This leads to the excessive division of summary per-secs when interval != 1 +sec. It is obvious pps couldn't become two times lower just from picking a +different sampling interval value: + + $ samples/bpf/xdp_redirect_cpu -p xdp_prognum_n1_inverse_qnum -c all + -s -d 6 -i 1 + < snip > + Packets received : 2,197,230,321 + Average packets/s : 22,887,816 + Packets redirected : 2,197,230,472 + Average redir/s : 22,887,817 + $ samples/bpf/xdp_redirect_cpu -p xdp_prognum_n1_inverse_qnum -c all + -s -d 6 -i 2 + < snip > + Packets received : 159,566,498 + Average packets/s : 11,397,607 + Packets redirected : 159,566,995 + Average redir/s : 11,397,642 + +This can be easily fixed by treating the divisor not as a period, but rather +as a total number of samples, and thus incrementing it by 1 instead of +interval. As a nice side effect, we can now remove so-named argument from a +couple of functions. Let us also create an "alias" for sample_output::rx_cnt::pps +named 'num' using a union since this field is used to store this number (period +previously) as well, and the resulting counter-intuitive code might've been a +reason for this bug. + +Fixes: 156f886cf697 ("samples: bpf: Add basic infrastructure for XDP samples") +Signed-off-by: Alexander Lobakin +Signed-off-by: Daniel Borkmann +Reviewed-by: Jesse Brandeburg +Reviewed-by: Kumar Kartikeya Dwivedi +Link: https://lore.kernel.org/bpf/20211111215703.690-1-alexandr.lobakin@intel.com +Signed-off-by: Alexei Starovoitov +Signed-off-by: Sasha Levin +--- + samples/bpf/xdp_sample_user.c | 28 +++++++++++++++------------- + 1 file changed, 15 insertions(+), 13 deletions(-) + +diff --git a/samples/bpf/xdp_sample_user.c b/samples/bpf/xdp_sample_user.c +index b32d821781990..8740838e77679 100644 +--- a/samples/bpf/xdp_sample_user.c ++++ b/samples/bpf/xdp_sample_user.c +@@ -120,7 +120,10 @@ struct sample_output { + __u64 xmit; + } totals; + struct { +- __u64 pps; ++ union { ++ __u64 pps; ++ __u64 num; ++ }; + __u64 drop; + __u64 err; + } rx_cnt; +@@ -1322,7 +1325,7 @@ int sample_install_xdp(struct bpf_program *xdp_prog, int ifindex, bool generic, + + static void sample_summary_print(void) + { +- double period = sample_out.rx_cnt.pps; ++ double num = sample_out.rx_cnt.num; + + if (sample_out.totals.rx) { + double pkts = sample_out.totals.rx; +@@ -1330,7 +1333,7 @@ static void sample_summary_print(void) + print_always(" Packets received : %'-10llu\n", + sample_out.totals.rx); + print_always(" Average packets/s : %'-10.0f\n", +- sample_round(pkts / period)); ++ sample_round(pkts / num)); + } + if (sample_out.totals.redir) { + double pkts = sample_out.totals.redir; +@@ -1338,7 +1341,7 @@ static void sample_summary_print(void) + print_always(" Packets redirected : %'-10llu\n", + sample_out.totals.redir); + print_always(" Average redir/s : %'-10.0f\n", +- sample_round(pkts / period)); ++ sample_round(pkts / num)); + } + if (sample_out.totals.drop) + print_always(" Rx dropped : %'-10llu\n", +@@ -1355,7 +1358,7 @@ static void sample_summary_print(void) + print_always(" Packets transmitted : %'-10llu\n", + sample_out.totals.xmit); + print_always(" Average transmit/s : %'-10.0f\n", +- sample_round(pkts / period)); ++ sample_round(pkts / num)); + } + } + +@@ -1422,7 +1425,7 @@ static int sample_stats_collect(struct stats_record *rec) + return 0; + } + +-static void sample_summary_update(struct sample_output *out, int interval) ++static void sample_summary_update(struct sample_output *out) + { + sample_out.totals.rx += out->totals.rx; + sample_out.totals.redir += out->totals.redir; +@@ -1430,12 +1433,11 @@ static void sample_summary_update(struct sample_output *out, int interval) + sample_out.totals.drop_xmit += out->totals.drop_xmit; + sample_out.totals.err += out->totals.err; + sample_out.totals.xmit += out->totals.xmit; +- sample_out.rx_cnt.pps += interval; ++ sample_out.rx_cnt.num++; + } + + static void sample_stats_print(int mask, struct stats_record *cur, +- struct stats_record *prev, char *prog_name, +- int interval) ++ struct stats_record *prev, char *prog_name) + { + struct sample_output out = {}; + +@@ -1452,7 +1454,7 @@ static void sample_stats_print(int mask, struct stats_record *cur, + else if (mask & SAMPLE_DEVMAP_XMIT_CNT_MULTI) + stats_get_devmap_xmit_multi(cur, prev, 0, &out, + mask & SAMPLE_DEVMAP_XMIT_CNT); +- sample_summary_update(&out, interval); ++ sample_summary_update(&out); + + stats_print(prog_name, mask, cur, prev, &out); + } +@@ -1495,7 +1497,7 @@ static void swap(struct stats_record **a, struct stats_record **b) + } + + static int sample_timer_cb(int timerfd, struct stats_record **rec, +- struct stats_record **prev, int interval) ++ struct stats_record **prev) + { + char line[64] = "Summary"; + int ret; +@@ -1524,7 +1526,7 @@ static int sample_timer_cb(int timerfd, struct stats_record **rec, + snprintf(line, sizeof(line), "%s->%s", f ?: "?", t ?: "?"); + } + +- sample_stats_print(sample_mask, *rec, *prev, line, interval); ++ sample_stats_print(sample_mask, *rec, *prev, line); + return 0; + } + +@@ -1579,7 +1581,7 @@ int sample_run(int interval, void (*post_cb)(void *), void *ctx) + if (pfd[0].revents & POLLIN) + ret = sample_signal_cb(); + else if (pfd[1].revents & POLLIN) +- ret = sample_timer_cb(timerfd, &rec, &prev, interval); ++ ret = sample_timer_cb(timerfd, &rec, &prev); + + if (ret) + break; +-- +2.33.0 + diff --git a/queue-5.15/sched-core-mitigate-race-cpus_share_cache-update_top.patch b/queue-5.15/sched-core-mitigate-race-cpus_share_cache-update_top.patch new file mode 100644 index 00000000000..c464d544d65 --- /dev/null +++ b/queue-5.15/sched-core-mitigate-race-cpus_share_cache-update_top.patch @@ -0,0 +1,61 @@ +From 7368d6b16f5768ac68e2aa7ab3692e4cc79c130c Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 4 Nov 2021 17:51:20 +0000 +Subject: sched/core: Mitigate race + cpus_share_cache()/update_top_cache_domain() + +From: Vincent Donnefort + +[ Upstream commit 42dc938a590c96eeb429e1830123fef2366d9c80 ] + +Nothing protects the access to the per_cpu variable sd_llc_id. When testing +the same CPU (i.e. this_cpu == that_cpu), a race condition exists with +update_top_cache_domain(). One scenario being: + + CPU1 CPU2 + ================================================================== + + per_cpu(sd_llc_id, CPUX) => 0 + partition_sched_domains_locked() + detach_destroy_domains() + cpus_share_cache(CPUX, CPUX) update_top_cache_domain(CPUX) + per_cpu(sd_llc_id, CPUX) => 0 + per_cpu(sd_llc_id, CPUX) = CPUX + per_cpu(sd_llc_id, CPUX) => CPUX + return false + +ttwu_queue_cond() wouldn't catch smp_processor_id() == cpu and the result +is a warning triggered from ttwu_queue_wakelist(). + +Avoid a such race in cpus_share_cache() by always returning true when +this_cpu == that_cpu. + +Fixes: 518cd6234178 ("sched: Only queue remote wakeups when crossing cache boundaries") +Reported-by: Jing-Ting Wu +Signed-off-by: Vincent Donnefort +Signed-off-by: Peter Zijlstra (Intel) +Reviewed-by: Valentin Schneider +Reviewed-by: Vincent Guittot +Link: https://lore.kernel.org/r/20211104175120.857087-1-vincent.donnefort@arm.com +Signed-off-by: Sasha Levin +--- + kernel/sched/core.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/kernel/sched/core.c b/kernel/sched/core.c +index aea60eae21a7f..2c34c7bd559f2 100644 +--- a/kernel/sched/core.c ++++ b/kernel/sched/core.c +@@ -3707,6 +3707,9 @@ out: + + bool cpus_share_cache(int this_cpu, int that_cpu) + { ++ if (this_cpu == that_cpu) ++ return true; ++ + return per_cpu(sd_llc_id, this_cpu) == per_cpu(sd_llc_id, that_cpu); + } + +-- +2.33.0 + diff --git a/queue-5.15/sched-fair-prevent-dead-task-groups-from-regaining-c.patch b/queue-5.15/sched-fair-prevent-dead-task-groups-from-regaining-c.patch new file mode 100644 index 00000000000..d4c0831ad1f --- /dev/null +++ b/queue-5.15/sched-fair-prevent-dead-task-groups-from-regaining-c.patch @@ -0,0 +1,297 @@ +From 88d9f588dc46d057ccb16d8756a9b7dc107a0201 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 3 Nov 2021 20:06:13 +0100 +Subject: sched/fair: Prevent dead task groups from regaining cfs_rq's +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Mathias Krause + +[ Upstream commit b027789e5e50494c2325cc70c8642e7fd6059479 ] + +Kevin is reporting crashes which point to a use-after-free of a cfs_rq +in update_blocked_averages(). Initial debugging revealed that we've +live cfs_rq's (on_list=1) in an about to be kfree()'d task group in +free_fair_sched_group(). However, it was unclear how that can happen. + +His kernel config happened to lead to a layout of struct sched_entity +that put the 'my_q' member directly into the middle of the object +which makes it incidentally overlap with SLUB's freelist pointer. +That, in combination with SLAB_FREELIST_HARDENED's freelist pointer +mangling, leads to a reliable access violation in form of a #GP which +made the UAF fail fast. + +Michal seems to have run into the same issue[1]. He already correctly +diagnosed that commit a7b359fc6a37 ("sched/fair: Correctly insert +cfs_rq's to list on unthrottle") is causing the preconditions for the +UAF to happen by re-adding cfs_rq's also to task groups that have no +more running tasks, i.e. also to dead ones. His analysis, however, +misses the real root cause and it cannot be seen from the crash +backtrace only, as the real offender is tg_unthrottle_up() getting +called via sched_cfs_period_timer() via the timer interrupt at an +inconvenient time. + +When unregister_fair_sched_group() unlinks all cfs_rq's from the dying +task group, it doesn't protect itself from getting interrupted. If the +timer interrupt triggers while we iterate over all CPUs or after +unregister_fair_sched_group() has finished but prior to unlinking the +task group, sched_cfs_period_timer() will execute and walk the list of +task groups, trying to unthrottle cfs_rq's, i.e. re-add them to the +dying task group. These will later -- in free_fair_sched_group() -- be +kfree()'ed while still being linked, leading to the fireworks Kevin +and Michal are seeing. + +To fix this race, ensure the dying task group gets unlinked first. +However, simply switching the order of unregistering and unlinking the +task group isn't sufficient, as concurrent RCU walkers might still see +it, as can be seen below: + + CPU1: CPU2: + : timer IRQ: + : do_sched_cfs_period_timer(): + : : + : distribute_cfs_runtime(): + : rcu_read_lock(); + : : + : unthrottle_cfs_rq(): + sched_offline_group(): : + : walk_tg_tree_from(…,tg_unthrottle_up,…): + list_del_rcu(&tg->list); : + (1) : list_for_each_entry_rcu(child, &parent->children, siblings) + : : + (2) list_del_rcu(&tg->siblings); : + : tg_unthrottle_up(): + unregister_fair_sched_group(): struct cfs_rq *cfs_rq = tg->cfs_rq[cpu_of(rq)]; + : : + list_del_leaf_cfs_rq(tg->cfs_rq[cpu]); : + : : + : if (!cfs_rq_is_decayed(cfs_rq) || cfs_rq->nr_running) + (3) : list_add_leaf_cfs_rq(cfs_rq); + : : + : : + : : + : : + : : + (4) : rcu_read_unlock(); + +CPU 2 walks the task group list in parallel to sched_offline_group(), +specifically, it'll read the soon to be unlinked task group entry at +(1). Unlinking it on CPU 1 at (2) therefore won't prevent CPU 2 from +still passing it on to tg_unthrottle_up(). CPU 1 now tries to unlink +all cfs_rq's via list_del_leaf_cfs_rq() in +unregister_fair_sched_group(). Meanwhile CPU 2 will re-add some of +these at (3), which is the cause of the UAF later on. + +To prevent this additional race from happening, we need to wait until +walk_tg_tree_from() has finished traversing the task groups, i.e. +after the RCU read critical section ends in (4). Afterwards we're safe +to call unregister_fair_sched_group(), as each new walk won't see the +dying task group any more. + +On top of that, we need to wait yet another RCU grace period after +unregister_fair_sched_group() to ensure print_cfs_stats(), which might +run concurrently, always sees valid objects, i.e. not already free'd +ones. + +This patch survives Michal's reproducer[2] for 8h+ now, which used to +trigger within minutes before. + + [1] https://lore.kernel.org/lkml/20211011172236.11223-1-mkoutny@suse.com/ + [2] https://lore.kernel.org/lkml/20211102160228.GA57072@blackbody.suse.cz/ + +Fixes: a7b359fc6a37 ("sched/fair: Correctly insert cfs_rq's to list on unthrottle") +[peterz: shuffle code around a bit] +Reported-by: Kevin Tanguy +Signed-off-by: Mathias Krause +Signed-off-by: Peter Zijlstra (Intel) +Signed-off-by: Sasha Levin +--- + kernel/sched/autogroup.c | 2 +- + kernel/sched/core.c | 44 ++++++++++++++++++++++++++++++++-------- + kernel/sched/fair.c | 4 ++-- + kernel/sched/rt.c | 12 ++++++++--- + kernel/sched/sched.h | 3 ++- + 5 files changed, 49 insertions(+), 16 deletions(-) + +diff --git a/kernel/sched/autogroup.c b/kernel/sched/autogroup.c +index 2067080bb2358..8629b37d118e7 100644 +--- a/kernel/sched/autogroup.c ++++ b/kernel/sched/autogroup.c +@@ -31,7 +31,7 @@ static inline void autogroup_destroy(struct kref *kref) + ag->tg->rt_se = NULL; + ag->tg->rt_rq = NULL; + #endif +- sched_offline_group(ag->tg); ++ sched_release_group(ag->tg); + sched_destroy_group(ag->tg); + } + +diff --git a/kernel/sched/core.c b/kernel/sched/core.c +index 2c34c7bd559f2..779f27a4b46ac 100644 +--- a/kernel/sched/core.c ++++ b/kernel/sched/core.c +@@ -9720,6 +9720,22 @@ static void sched_free_group(struct task_group *tg) + kmem_cache_free(task_group_cache, tg); + } + ++static void sched_free_group_rcu(struct rcu_head *rcu) ++{ ++ sched_free_group(container_of(rcu, struct task_group, rcu)); ++} ++ ++static void sched_unregister_group(struct task_group *tg) ++{ ++ unregister_fair_sched_group(tg); ++ unregister_rt_sched_group(tg); ++ /* ++ * We have to wait for yet another RCU grace period to expire, as ++ * print_cfs_stats() might run concurrently. ++ */ ++ call_rcu(&tg->rcu, sched_free_group_rcu); ++} ++ + /* allocate runqueue etc for a new task group */ + struct task_group *sched_create_group(struct task_group *parent) + { +@@ -9763,25 +9779,35 @@ void sched_online_group(struct task_group *tg, struct task_group *parent) + } + + /* rcu callback to free various structures associated with a task group */ +-static void sched_free_group_rcu(struct rcu_head *rhp) ++static void sched_unregister_group_rcu(struct rcu_head *rhp) + { + /* Now it should be safe to free those cfs_rqs: */ +- sched_free_group(container_of(rhp, struct task_group, rcu)); ++ sched_unregister_group(container_of(rhp, struct task_group, rcu)); + } + + void sched_destroy_group(struct task_group *tg) + { + /* Wait for possible concurrent references to cfs_rqs complete: */ +- call_rcu(&tg->rcu, sched_free_group_rcu); ++ call_rcu(&tg->rcu, sched_unregister_group_rcu); + } + +-void sched_offline_group(struct task_group *tg) ++void sched_release_group(struct task_group *tg) + { + unsigned long flags; + +- /* End participation in shares distribution: */ +- unregister_fair_sched_group(tg); +- ++ /* ++ * Unlink first, to avoid walk_tg_tree_from() from finding us (via ++ * sched_cfs_period_timer()). ++ * ++ * For this to be effective, we have to wait for all pending users of ++ * this task group to leave their RCU critical section to ensure no new ++ * user will see our dying task group any more. Specifically ensure ++ * that tg_unthrottle_up() won't add decayed cfs_rq's to it. ++ * ++ * We therefore defer calling unregister_fair_sched_group() to ++ * sched_unregister_group() which is guarantied to get called only after the ++ * current RCU grace period has expired. ++ */ + spin_lock_irqsave(&task_group_lock, flags); + list_del_rcu(&tg->list); + list_del_rcu(&tg->siblings); +@@ -9900,7 +9926,7 @@ static void cpu_cgroup_css_released(struct cgroup_subsys_state *css) + { + struct task_group *tg = css_tg(css); + +- sched_offline_group(tg); ++ sched_release_group(tg); + } + + static void cpu_cgroup_css_free(struct cgroup_subsys_state *css) +@@ -9910,7 +9936,7 @@ static void cpu_cgroup_css_free(struct cgroup_subsys_state *css) + /* + * Relies on the RCU grace period between css_released() and this. + */ +- sched_free_group(tg); ++ sched_unregister_group(tg); + } + + /* +diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c +index f6a05d9b54436..6f16dfb742462 100644 +--- a/kernel/sched/fair.c ++++ b/kernel/sched/fair.c +@@ -11358,8 +11358,6 @@ void free_fair_sched_group(struct task_group *tg) + { + int i; + +- destroy_cfs_bandwidth(tg_cfs_bandwidth(tg)); +- + for_each_possible_cpu(i) { + if (tg->cfs_rq) + kfree(tg->cfs_rq[i]); +@@ -11436,6 +11434,8 @@ void unregister_fair_sched_group(struct task_group *tg) + struct rq *rq; + int cpu; + ++ destroy_cfs_bandwidth(tg_cfs_bandwidth(tg)); ++ + for_each_possible_cpu(cpu) { + if (tg->se[cpu]) + remove_entity_load_avg(tg->se[cpu]); +diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c +index 3daf42a0f4623..bfef3f39b5552 100644 +--- a/kernel/sched/rt.c ++++ b/kernel/sched/rt.c +@@ -137,13 +137,17 @@ static inline struct rq *rq_of_rt_se(struct sched_rt_entity *rt_se) + return rt_rq->rq; + } + +-void free_rt_sched_group(struct task_group *tg) ++void unregister_rt_sched_group(struct task_group *tg) + { +- int i; +- + if (tg->rt_se) + destroy_rt_bandwidth(&tg->rt_bandwidth); + ++} ++ ++void free_rt_sched_group(struct task_group *tg) ++{ ++ int i; ++ + for_each_possible_cpu(i) { + if (tg->rt_rq) + kfree(tg->rt_rq[i]); +@@ -250,6 +254,8 @@ static inline struct rt_rq *rt_rq_of_se(struct sched_rt_entity *rt_se) + return &rq->rt; + } + ++void unregister_rt_sched_group(struct task_group *tg) { } ++ + void free_rt_sched_group(struct task_group *tg) { } + + int alloc_rt_sched_group(struct task_group *tg, struct task_group *parent) +diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h +index 3d3e5793e1172..4f432826933da 100644 +--- a/kernel/sched/sched.h ++++ b/kernel/sched/sched.h +@@ -486,6 +486,7 @@ extern void __refill_cfs_bandwidth_runtime(struct cfs_bandwidth *cfs_b); + extern void start_cfs_bandwidth(struct cfs_bandwidth *cfs_b); + extern void unthrottle_cfs_rq(struct cfs_rq *cfs_rq); + ++extern void unregister_rt_sched_group(struct task_group *tg); + extern void free_rt_sched_group(struct task_group *tg); + extern int alloc_rt_sched_group(struct task_group *tg, struct task_group *parent); + extern void init_tg_rt_entry(struct task_group *tg, struct rt_rq *rt_rq, +@@ -501,7 +502,7 @@ extern struct task_group *sched_create_group(struct task_group *parent); + extern void sched_online_group(struct task_group *tg, + struct task_group *parent); + extern void sched_destroy_group(struct task_group *tg); +-extern void sched_offline_group(struct task_group *tg); ++extern void sched_release_group(struct task_group *tg); + + extern void sched_move_task(struct task_struct *tsk); + +-- +2.33.0 + diff --git a/queue-5.15/scsi-advansys-fix-kernel-pointer-leak.patch b/queue-5.15/scsi-advansys-fix-kernel-pointer-leak.patch new file mode 100644 index 00000000000..ae96ce8b3d5 --- /dev/null +++ b/queue-5.15/scsi-advansys-fix-kernel-pointer-leak.patch @@ -0,0 +1,40 @@ +From 99db7e221ac6f953f6b470d7c544d3a583921fde Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 29 Sep 2021 20:25:37 +0800 +Subject: scsi: advansys: Fix kernel pointer leak + +From: Guo Zhi + +[ Upstream commit d4996c6eac4c81b8872043e9391563f67f13e406 ] + +Pointers should be printed with %p or %px rather than cast to 'unsigned +long' and printed with %lx. + +Change %lx to %p to print the hashed pointer. + +Link: https://lore.kernel.org/r/20210929122538.1158235-1-qtxuning1999@sjtu.edu.cn +Signed-off-by: Guo Zhi +Signed-off-by: Martin K. Petersen +Signed-off-by: Sasha Levin +--- + drivers/scsi/advansys.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c +index ffb3919675734..97be0765cb9bd 100644 +--- a/drivers/scsi/advansys.c ++++ b/drivers/scsi/advansys.c +@@ -3308,8 +3308,8 @@ static void asc_prt_adv_board_info(struct seq_file *m, struct Scsi_Host *shost) + shost->host_no); + + seq_printf(m, +- " iop_base 0x%lx, cable_detect: %X, err_code %u\n", +- (unsigned long)v->iop_base, ++ " iop_base 0x%p, cable_detect: %X, err_code %u\n", ++ v->iop_base, + AdvReadWordRegister(iop_base,IOPW_SCSI_CFG1) & CABLE_DETECT, + v->err_code); + +-- +2.33.0 + diff --git a/queue-5.15/scsi-core-fix-scsi_mode_sense-buffer-length-handling.patch b/queue-5.15/scsi-core-fix-scsi_mode_sense-buffer-length-handling.patch new file mode 100644 index 00000000000..2371c907cd1 --- /dev/null +++ b/queue-5.15/scsi-core-fix-scsi_mode_sense-buffer-length-handling.patch @@ -0,0 +1,124 @@ +From 872bf2a4db6aa585a21ef251a115bf27c525d14b Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 20 Aug 2021 16:02:53 +0900 +Subject: scsi: core: Fix scsi_mode_sense() buffer length handling + +From: Damien Le Moal + +[ Upstream commit 17b49bcbf8351d3dbe57204468ac34f033ed60bc ] + +Several problems exist with scsi_mode_sense() buffer length handling: + + 1) The allocation length field of the MODE SENSE(10) command is 16-bits, + occupying bytes 7 and 8 of the CDB. With this command, access to mode + pages larger than 255 bytes is thus possible. However, the CDB + allocation length field is set by assigning len to byte 8 only, thus + truncating buffer length larger than 255. + + 2) If scsi_mode_sense() is called with len smaller than 8 with + sdev->use_10_for_ms set, or smaller than 4 otherwise, the buffer length + is increased to 8 and 4 respectively, and the buffer is zero filled + with these increased values, thus corrupting the memory following the + buffer. + +Fix these 2 problems by using put_unaligned_be16() to set the allocation +length field of MODE SENSE(10) CDB and by returning an error when len is +too small. + +Furthermore, if len is larger than 255B, always try MODE SENSE(10) first, +even if the device driver did not set sdev->use_10_for_ms. In case of +invalid opcode error for MODE SENSE(10), access to mode pages larger than +255 bytes are not retried using MODE SENSE(6). To avoid buffer length +overflows for the MODE_SENSE(10) case, check that len is smaller than 65535 +bytes. + +While at it, also fix the folowing: + + * Use get_unaligned_be16() to retrieve the mode data length and block + descriptor length fields of the mode sense reply header instead of using + an open coded calculation. + + * Fix the kdoc dbd argument explanation: the DBD bit stands for Disable + Block Descriptor, which is the opposite of what the dbd argument + description was. + +Link: https://lore.kernel.org/r/20210820070255.682775-2-damien.lemoal@wdc.com +Signed-off-by: Damien Le Moal +Signed-off-by: Martin K. Petersen +Signed-off-by: Sasha Levin +--- + drivers/scsi/scsi_lib.c | 25 +++++++++++++++---------- + 1 file changed, 15 insertions(+), 10 deletions(-) + +diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c +index 0e023547ff15a..ef4361b2d1423 100644 +--- a/drivers/scsi/scsi_lib.c ++++ b/drivers/scsi/scsi_lib.c +@@ -2074,7 +2074,7 @@ EXPORT_SYMBOL_GPL(scsi_mode_select); + /** + * scsi_mode_sense - issue a mode sense, falling back from 10 to six bytes if necessary. + * @sdev: SCSI device to be queried +- * @dbd: set if mode sense will allow block descriptors to be returned ++ * @dbd: set to prevent mode sense from returning block descriptors + * @modepage: mode page being requested + * @buffer: request buffer (may not be smaller than eight bytes) + * @len: length of request buffer. +@@ -2109,18 +2109,18 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, + sshdr = &my_sshdr; + + retry: +- use_10_for_ms = sdev->use_10_for_ms; ++ use_10_for_ms = sdev->use_10_for_ms || len > 255; + + if (use_10_for_ms) { +- if (len < 8) +- len = 8; ++ if (len < 8 || len > 65535) ++ return -EINVAL; + + cmd[0] = MODE_SENSE_10; +- cmd[8] = len; ++ put_unaligned_be16(len, &cmd[7]); + header_length = 8; + } else { + if (len < 4) +- len = 4; ++ return -EINVAL; + + cmd[0] = MODE_SENSE; + cmd[4] = len; +@@ -2144,9 +2144,15 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, + if ((sshdr->sense_key == ILLEGAL_REQUEST) && + (sshdr->asc == 0x20) && (sshdr->ascq == 0)) { + /* +- * Invalid command operation code ++ * Invalid command operation code: retry using ++ * MODE SENSE(6) if this was a MODE SENSE(10) ++ * request, except if the request mode page is ++ * too large for MODE SENSE single byte ++ * allocation length field. + */ + if (use_10_for_ms) { ++ if (len > 255) ++ return -EIO; + sdev->use_10_for_ms = 0; + goto retry; + } +@@ -2170,12 +2176,11 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, + data->longlba = 0; + data->block_descriptor_length = 0; + } else if (use_10_for_ms) { +- data->length = buffer[0]*256 + buffer[1] + 2; ++ data->length = get_unaligned_be16(&buffer[0]) + 2; + data->medium_type = buffer[2]; + data->device_specific = buffer[3]; + data->longlba = buffer[4] & 0x01; +- data->block_descriptor_length = buffer[6]*256 +- + buffer[7]; ++ data->block_descriptor_length = get_unaligned_be16(&buffer[6]); + } else { + data->length = buffer[0] + 1; + data->medium_type = buffer[1]; +-- +2.33.0 + diff --git a/queue-5.15/scsi-core-sysfs-fix-hang-when-device-state-is-set-vi.patch b/queue-5.15/scsi-core-sysfs-fix-hang-when-device-state-is-set-vi.patch new file mode 100644 index 00000000000..e4da2c2834c --- /dev/null +++ b/queue-5.15/scsi-core-sysfs-fix-hang-when-device-state-is-set-vi.patch @@ -0,0 +1,102 @@ +From cea514ec0d558ed950d694dcbc4e551429b8c973 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 5 Nov 2021 17:10:48 -0500 +Subject: scsi: core: sysfs: Fix hang when device state is set via sysfs + +From: Mike Christie + +[ Upstream commit 4edd8cd4e86dd3047e5294bbefcc0a08f66a430f ] + +This fixes a regression added with: + +commit f0f82e2476f6 ("scsi: core: Fix capacity set to zero after +offlinining device") + +The problem is that after iSCSI recovery, iscsid will call into the kernel +to set the dev's state to running, and with that patch we now call +scsi_rescan_device() with the state_mutex held. If the SCSI error handler +thread is just starting to test the device in scsi_send_eh_cmnd() then it's +going to try to grab the state_mutex. + +We are then stuck, because when scsi_rescan_device() tries to send its I/O +scsi_queue_rq() calls -> scsi_host_queue_ready() -> scsi_host_in_recovery() +which will return true (the host state is still in recovery) and I/O will +just be requeued. scsi_send_eh_cmnd() will then never be able to grab the +state_mutex to finish error handling. + +To prevent the deadlock move the rescan-related code to after we drop the +state_mutex. + +This also adds a check for if we are already in the running state. This +prevents extra scans and helps the iscsid case where if the transport class +has already onlined the device during its recovery process then we don't +need userspace to do it again plus possibly block that daemon. + +Link: https://lore.kernel.org/r/20211105221048.6541-3-michael.christie@oracle.com +Fixes: f0f82e2476f6 ("scsi: core: Fix capacity set to zero after offlinining device") +Cc: Bart Van Assche +Cc: lijinlin +Cc: Wu Bo +Reviewed-by: Lee Duncan +Reviewed-by: Wu Bo +Signed-off-by: Mike Christie +Signed-off-by: Martin K. Petersen +Signed-off-by: Sasha Levin +--- + drivers/scsi/scsi_sysfs.c | 30 +++++++++++++++++++----------- + 1 file changed, 19 insertions(+), 11 deletions(-) + +diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c +index 8bb79ccc9a8b5..9527e734a999a 100644 +--- a/drivers/scsi/scsi_sysfs.c ++++ b/drivers/scsi/scsi_sysfs.c +@@ -797,6 +797,7 @@ store_state_field(struct device *dev, struct device_attribute *attr, + int i, ret; + struct scsi_device *sdev = to_scsi_device(dev); + enum scsi_device_state state = 0; ++ bool rescan_dev = false; + + for (i = 0; i < ARRAY_SIZE(sdev_states); i++) { + const int len = strlen(sdev_states[i].name); +@@ -815,20 +816,27 @@ store_state_field(struct device *dev, struct device_attribute *attr, + } + + mutex_lock(&sdev->state_mutex); +- ret = scsi_device_set_state(sdev, state); +- /* +- * If the device state changes to SDEV_RUNNING, we need to +- * run the queue to avoid I/O hang, and rescan the device +- * to revalidate it. Running the queue first is necessary +- * because another thread may be waiting inside +- * blk_mq_freeze_queue_wait() and because that call may be +- * waiting for pending I/O to finish. +- */ +- if (ret == 0 && state == SDEV_RUNNING) { ++ if (sdev->sdev_state == SDEV_RUNNING && state == SDEV_RUNNING) { ++ ret = count; ++ } else { ++ ret = scsi_device_set_state(sdev, state); ++ if (ret == 0 && state == SDEV_RUNNING) ++ rescan_dev = true; ++ } ++ mutex_unlock(&sdev->state_mutex); ++ ++ if (rescan_dev) { ++ /* ++ * If the device state changes to SDEV_RUNNING, we need to ++ * run the queue to avoid I/O hang, and rescan the device ++ * to revalidate it. Running the queue first is necessary ++ * because another thread may be waiting inside ++ * blk_mq_freeze_queue_wait() and because that call may be ++ * waiting for pending I/O to finish. ++ */ + blk_mq_run_hw_queues(sdev->request_queue, true); + scsi_rescan_device(dev); + } +- mutex_unlock(&sdev->state_mutex); + + return ret == 0 ? count : -EINVAL; + } +-- +2.33.0 + diff --git a/queue-5.15/scsi-lpfc-allow-fabric-node-recovery-if-recovery-is-.patch b/queue-5.15/scsi-lpfc-allow-fabric-node-recovery-if-recovery-is-.patch new file mode 100644 index 00000000000..0b7a6278354 --- /dev/null +++ b/queue-5.15/scsi-lpfc-allow-fabric-node-recovery-if-recovery-is-.patch @@ -0,0 +1,339 @@ +From 90235d930be3b8a28321dc92ff3de965778671c7 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 20 Oct 2021 14:14:16 -0700 +Subject: scsi: lpfc: Allow fabric node recovery if recovery is in progress + before devloss + +From: James Smart + +[ Upstream commit af984c87293b19dccbd0b16afc57c5c9a4a279c7 ] + +A link bounce to a slow fabric may observe FDISC response delays lasting +longer than devloss tmo. Current logic decrements the final fabric node +kref during a devloss tmo event. This results in a NULL ptr dereference +crash if the FDISC completes for that fabric node after devloss tmo. + +Fix by adding the NLP_IN_RECOV_POST_DEV_LOSS flag, which is set when +devloss tmo triggers and we've noticed that fabric node recovery has +already started or finished in between the time lpfc_dev_loss_tmo_callbk +queues lpfc_dev_loss_tmo_handler. If fabric node recovery succeeds, then +the driver reverses the devloss tmo marked kref put with a kref get. If +fabric node recovery fails, then the final kref put relies on the ELS +timing out or the REG_LOGIN cmpl routine. + +Link: https://lore.kernel.org/r/20211020211417.88754-8-jsmart2021@gmail.com +Co-developed-by: Justin Tee +Signed-off-by: Justin Tee +Signed-off-by: James Smart +Signed-off-by: Martin K. Petersen +Signed-off-by: Sasha Levin +--- + drivers/scsi/lpfc/lpfc_crtn.h | 2 + + drivers/scsi/lpfc/lpfc_disc.h | 12 +++- + drivers/scsi/lpfc/lpfc_els.c | 7 +- + drivers/scsi/lpfc/lpfc_hbadisc.c | 111 ++++++++++++++++++++++++++++++- + drivers/scsi/lpfc/lpfc_init.c | 12 ++-- + drivers/scsi/lpfc/lpfc_scsi.c | 10 +-- + 6 files changed, 139 insertions(+), 15 deletions(-) + +diff --git a/drivers/scsi/lpfc/lpfc_crtn.h b/drivers/scsi/lpfc/lpfc_crtn.h +index c512f41991429..c9770b1d2366a 100644 +--- a/drivers/scsi/lpfc/lpfc_crtn.h ++++ b/drivers/scsi/lpfc/lpfc_crtn.h +@@ -119,6 +119,8 @@ int lpfc_check_sli_ndlp(struct lpfc_hba *, struct lpfc_sli_ring *, + struct lpfc_nodelist *lpfc_nlp_init(struct lpfc_vport *vport, uint32_t did); + struct lpfc_nodelist *lpfc_nlp_get(struct lpfc_nodelist *); + int lpfc_nlp_put(struct lpfc_nodelist *); ++void lpfc_check_nlp_post_devloss(struct lpfc_vport *vport, ++ struct lpfc_nodelist *ndlp); + void lpfc_ignore_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, + struct lpfc_iocbq *rspiocb); + int lpfc_nlp_not_used(struct lpfc_nodelist *ndlp); +diff --git a/drivers/scsi/lpfc/lpfc_disc.h b/drivers/scsi/lpfc/lpfc_disc.h +index 871b665bd72e3..37a4b79010bfc 100644 +--- a/drivers/scsi/lpfc/lpfc_disc.h ++++ b/drivers/scsi/lpfc/lpfc_disc.h +@@ -85,6 +85,13 @@ enum lpfc_fc4_xpt_flags { + NLP_XPT_HAS_HH = 0x10 + }; + ++enum lpfc_nlp_save_flags { ++ /* devloss occurred during recovery */ ++ NLP_IN_RECOV_POST_DEV_LOSS = 0x1, ++ /* wait for outstanding LOGO to cmpl */ ++ NLP_WAIT_FOR_LOGO = 0x2, ++}; ++ + struct lpfc_nodelist { + struct list_head nlp_listp; + struct serv_parm fc_sparam; /* buffer for service params */ +@@ -144,8 +151,9 @@ struct lpfc_nodelist { + unsigned long *active_rrqs_xri_bitmap; + struct lpfc_scsicmd_bkt *lat_data; /* Latency data */ + uint32_t fc4_prli_sent; +- u32 upcall_flags; +-#define NLP_WAIT_FOR_LOGO 0x2 ++ ++ /* flags to keep ndlp alive until special conditions are met */ ++ enum lpfc_nlp_save_flags save_flags; + + enum lpfc_fc4_xpt_flags fc4_xpt_flags; + +diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c +index 666b0a1b558ac..1a406df251cbf 100644 +--- a/drivers/scsi/lpfc/lpfc_els.c ++++ b/drivers/scsi/lpfc/lpfc_els.c +@@ -2898,9 +2898,9 @@ lpfc_cmpl_els_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, + irsp = &(rspiocb->iocb); + spin_lock_irq(&ndlp->lock); + ndlp->nlp_flag &= ~NLP_LOGO_SND; +- if (ndlp->upcall_flags & NLP_WAIT_FOR_LOGO) { ++ if (ndlp->save_flags & NLP_WAIT_FOR_LOGO) { + wake_up_waiter = 1; +- ndlp->upcall_flags &= ~NLP_WAIT_FOR_LOGO; ++ ndlp->save_flags &= ~NLP_WAIT_FOR_LOGO; + } + spin_unlock_irq(&ndlp->lock); + +@@ -10713,6 +10713,9 @@ lpfc_cmpl_els_fdisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, + irsp->ulpStatus, irsp->un.ulpWord[4]); + goto fdisc_failed; + } ++ ++ lpfc_check_nlp_post_devloss(vport, ndlp); ++ + spin_lock_irq(shost->host_lock); + vport->fc_flag &= ~FC_VPORT_CVL_RCVD; + vport->fc_flag &= ~FC_VPORT_LOGO_RCVD; +diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c +index e1c02229c82d9..9ccb904e35fcf 100644 +--- a/drivers/scsi/lpfc/lpfc_hbadisc.c ++++ b/drivers/scsi/lpfc/lpfc_hbadisc.c +@@ -209,7 +209,12 @@ lpfc_dev_loss_tmo_callbk(struct fc_rport *rport) + + spin_lock_irqsave(&ndlp->lock, iflags); + ndlp->nlp_flag |= NLP_IN_DEV_LOSS; +- ndlp->nlp_flag &= ~NLP_NPR_2B_DISC; ++ ++ /* If there is a PLOGI in progress, and we are in a ++ * NLP_NPR_2B_DISC state, don't turn off the flag. ++ */ ++ if (ndlp->nlp_state != NLP_STE_PLOGI_ISSUE) ++ ndlp->nlp_flag &= ~NLP_NPR_2B_DISC; + + /* + * The backend does not expect any more calls associated with this +@@ -340,6 +345,37 @@ static void lpfc_check_inactive_vmid(struct lpfc_hba *phba) + lpfc_destroy_vport_work_array(phba, vports); + } + ++/** ++ * lpfc_check_nlp_post_devloss - Check to restore ndlp refcnt after devloss ++ * @vport: Pointer to vport object. ++ * @ndlp: Pointer to remote node object. ++ * ++ * If NLP_IN_RECOV_POST_DEV_LOSS flag was set due to outstanding recovery of ++ * node during dev_loss_tmo processing, then this function restores the nlp_put ++ * kref decrement from lpfc_dev_loss_tmo_handler. ++ **/ ++void ++lpfc_check_nlp_post_devloss(struct lpfc_vport *vport, ++ struct lpfc_nodelist *ndlp) ++{ ++ unsigned long iflags; ++ ++ spin_lock_irqsave(&ndlp->lock, iflags); ++ if (ndlp->save_flags & NLP_IN_RECOV_POST_DEV_LOSS) { ++ ndlp->save_flags &= ~NLP_IN_RECOV_POST_DEV_LOSS; ++ spin_unlock_irqrestore(&ndlp->lock, iflags); ++ lpfc_nlp_get(ndlp); ++ lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY | LOG_NODE, ++ "8438 Devloss timeout reversed on DID x%x " ++ "refcnt %d ndlp %p flag x%x " ++ "port_state = x%x\n", ++ ndlp->nlp_DID, kref_read(&ndlp->kref), ndlp, ++ ndlp->nlp_flag, vport->port_state); ++ spin_lock_irqsave(&ndlp->lock, iflags); ++ } ++ spin_unlock_irqrestore(&ndlp->lock, iflags); ++} ++ + /** + * lpfc_dev_loss_tmo_handler - Remote node devloss timeout handler + * @ndlp: Pointer to remote node object. +@@ -358,6 +394,8 @@ lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp) + uint8_t *name; + int warn_on = 0; + int fcf_inuse = 0; ++ bool recovering = false; ++ struct fc_vport *fc_vport = NULL; + unsigned long iflags; + + vport = ndlp->vport; +@@ -394,6 +432,64 @@ lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp) + + /* Fabric nodes are done. */ + if (ndlp->nlp_type & NLP_FABRIC) { ++ spin_lock_irqsave(&ndlp->lock, iflags); ++ /* In massive vport configuration settings, it's possible ++ * dev_loss_tmo fired during node recovery. So, check if ++ * fabric nodes are in discovery states outstanding. ++ */ ++ switch (ndlp->nlp_DID) { ++ case Fabric_DID: ++ fc_vport = vport->fc_vport; ++ if (fc_vport && ++ fc_vport->vport_state == FC_VPORT_INITIALIZING) ++ recovering = true; ++ break; ++ case Fabric_Cntl_DID: ++ if (ndlp->nlp_flag & NLP_REG_LOGIN_SEND) ++ recovering = true; ++ break; ++ case FDMI_DID: ++ fallthrough; ++ case NameServer_DID: ++ if (ndlp->nlp_state >= NLP_STE_PLOGI_ISSUE && ++ ndlp->nlp_state <= NLP_STE_REG_LOGIN_ISSUE) ++ recovering = true; ++ break; ++ } ++ spin_unlock_irqrestore(&ndlp->lock, iflags); ++ ++ /* Mark an NLP_IN_RECOV_POST_DEV_LOSS flag to know if reversing ++ * the following lpfc_nlp_put is necessary after fabric node is ++ * recovered. ++ */ ++ if (recovering) { ++ lpfc_printf_vlog(vport, KERN_INFO, ++ LOG_DISCOVERY | LOG_NODE, ++ "8436 Devloss timeout marked on " ++ "DID x%x refcnt %d ndlp %p " ++ "flag x%x port_state = x%x\n", ++ ndlp->nlp_DID, kref_read(&ndlp->kref), ++ ndlp, ndlp->nlp_flag, ++ vport->port_state); ++ spin_lock_irqsave(&ndlp->lock, iflags); ++ ndlp->save_flags |= NLP_IN_RECOV_POST_DEV_LOSS; ++ spin_unlock_irqrestore(&ndlp->lock, iflags); ++ } else if (ndlp->nlp_state == NLP_STE_UNMAPPED_NODE) { ++ /* Fabric node fully recovered before this dev_loss_tmo ++ * queue work is processed. Thus, ignore the ++ * dev_loss_tmo event. ++ */ ++ lpfc_printf_vlog(vport, KERN_INFO, ++ LOG_DISCOVERY | LOG_NODE, ++ "8437 Devloss timeout ignored on " ++ "DID x%x refcnt %d ndlp %p " ++ "flag x%x port_state = x%x\n", ++ ndlp->nlp_DID, kref_read(&ndlp->kref), ++ ndlp, ndlp->nlp_flag, ++ vport->port_state); ++ return fcf_inuse; ++ } ++ + lpfc_nlp_put(ndlp); + return fcf_inuse; + } +@@ -423,6 +519,14 @@ lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp) + ndlp->nlp_state, ndlp->nlp_rpi); + } + ++ /* If we are devloss, but we are in the process of rediscovering the ++ * ndlp, don't issue a NLP_EVT_DEVICE_RM event. ++ */ ++ if (ndlp->nlp_state >= NLP_STE_PLOGI_ISSUE && ++ ndlp->nlp_state <= NLP_STE_PRLI_ISSUE) { ++ return fcf_inuse; ++ } ++ + if (!(ndlp->fc4_xpt_flags & NVME_XPT_REGD)) + lpfc_disc_state_machine(vport, ndlp, NULL, NLP_EVT_DEVICE_RM); + +@@ -4351,6 +4455,8 @@ lpfc_mbx_cmpl_fc_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) + goto out; + } + ++ lpfc_check_nlp_post_devloss(vport, ndlp); ++ + if (phba->sli_rev < LPFC_SLI_REV4) + ndlp->nlp_rpi = mb->un.varWords[0]; + +@@ -4528,9 +4634,10 @@ lpfc_nlp_counters(struct lpfc_vport *vport, int state, int count) + void + lpfc_nlp_reg_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) + { +- + unsigned long iflags; + ++ lpfc_check_nlp_post_devloss(vport, ndlp); ++ + spin_lock_irqsave(&ndlp->lock, iflags); + if (ndlp->fc4_xpt_flags & NLP_XPT_REGD) { + /* Already registered with backend, trigger rescan */ +diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c +index 195169badb372..0fee8d590b0c4 100644 +--- a/drivers/scsi/lpfc/lpfc_init.c ++++ b/drivers/scsi/lpfc/lpfc_init.c +@@ -3694,12 +3694,16 @@ lpfc_offline_prep(struct lpfc_hba *phba, int mbx_action) + lpfc_disc_state_machine(vports[i], ndlp, + NULL, NLP_EVT_DEVICE_RECOVERY); + +- /* Don't remove the node unless the ++ /* Don't remove the node unless the node + * has been unregistered with the +- * transport. If so, let dev_loss +- * take care of the node. ++ * transport, and we're not in recovery ++ * before dev_loss_tmo triggered. ++ * Otherwise, let dev_loss take care of ++ * the node. + */ +- if (!(ndlp->fc4_xpt_flags & ++ if (!(ndlp->save_flags & ++ NLP_IN_RECOV_POST_DEV_LOSS) && ++ !(ndlp->fc4_xpt_flags & + (NVME_XPT_REGD | SCSI_XPT_REGD))) + lpfc_disc_state_machine + (vports[i], ndlp, +diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c +index 364c8a9b99095..3d9175f1b6787 100644 +--- a/drivers/scsi/lpfc/lpfc_scsi.c ++++ b/drivers/scsi/lpfc/lpfc_scsi.c +@@ -6455,28 +6455,28 @@ lpfc_target_reset_handler(struct scsi_cmnd *cmnd) + + /* Issue LOGO, if no LOGO is outstanding */ + spin_lock_irqsave(&pnode->lock, flags); +- if (!(pnode->upcall_flags & NLP_WAIT_FOR_LOGO) && ++ if (!(pnode->save_flags & NLP_WAIT_FOR_LOGO) && + !pnode->logo_waitq) { + pnode->logo_waitq = &waitq; + pnode->nlp_fcp_info &= ~NLP_FCP_2_DEVICE; + pnode->nlp_flag |= NLP_ISSUE_LOGO; +- pnode->upcall_flags |= NLP_WAIT_FOR_LOGO; ++ pnode->save_flags |= NLP_WAIT_FOR_LOGO; + spin_unlock_irqrestore(&pnode->lock, flags); + lpfc_unreg_rpi(vport, pnode); + wait_event_timeout(waitq, +- (!(pnode->upcall_flags & ++ (!(pnode->save_flags & + NLP_WAIT_FOR_LOGO)), + msecs_to_jiffies(dev_loss_tmo * + 1000)); + +- if (pnode->upcall_flags & NLP_WAIT_FOR_LOGO) { ++ if (pnode->save_flags & NLP_WAIT_FOR_LOGO) { + lpfc_printf_vlog(vport, KERN_ERR, logit, + "0725 SCSI layer TGTRST " + "failed & LOGO TMO (%d, %llu) " + "return x%x\n", + tgt_id, lun_id, status); + spin_lock_irqsave(&pnode->lock, flags); +- pnode->upcall_flags &= ~NLP_WAIT_FOR_LOGO; ++ pnode->save_flags &= ~NLP_WAIT_FOR_LOGO; + } else { + spin_lock_irqsave(&pnode->lock, flags); + } +-- +2.33.0 + diff --git a/queue-5.15/scsi-lpfc-fix-link-down-processing-to-address-null-p.patch b/queue-5.15/scsi-lpfc-fix-link-down-processing-to-address-null-p.patch new file mode 100644 index 00000000000..4acbfac0060 --- /dev/null +++ b/queue-5.15/scsi-lpfc-fix-link-down-processing-to-address-null-p.patch @@ -0,0 +1,68 @@ +From e94e99f7223193dda2e8c0bc80fef646d646dcb6 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 20 Oct 2021 14:14:15 -0700 +Subject: scsi: lpfc: Fix link down processing to address NULL pointer + dereference + +From: James Smart + +[ Upstream commit 1854f53ccd88ad4e7568ddfafafffe71f1ceb0a6 ] + +If an FC link down transition while PLOGIs are outstanding to fabric well +known addresses, outstanding ABTS requests may result in a NULL pointer +dereference. Driver unload requests may hang with repeated "2878" log +messages. + +The Link down processing results in ABTS requests for outstanding ELS +requests. The Abort WQEs are sent for the ELSs before the driver had set +the link state to down. Thus the driver is sending the Abort with the +expectation that an ABTS will be sent on the wire. The Abort request is +stalled waiting for the link to come up. In some conditions the driver may +auto-complete the ELSs thus if the link does come up, the Abort completions +may reference an invalid structure. + +Fix by ensuring that Abort set the flag to avoid link traffic if issued due +to conditions where the link failed. + +Link: https://lore.kernel.org/r/20211020211417.88754-7-jsmart2021@gmail.com +Co-developed-by: Justin Tee +Signed-off-by: Justin Tee +Signed-off-by: James Smart +Signed-off-by: Martin K. Petersen +Signed-off-by: Sasha Levin +--- + drivers/scsi/lpfc/lpfc_sli.c | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c +index 8e689f06afc92..9c1f485952ef7 100644 +--- a/drivers/scsi/lpfc/lpfc_sli.c ++++ b/drivers/scsi/lpfc/lpfc_sli.c +@@ -12404,17 +12404,17 @@ lpfc_sli_issue_abort_iotag(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, + + /* ABTS WQE must go to the same WQ as the WQE to be aborted */ + abtsiocbp->hba_wqidx = cmdiocb->hba_wqidx; +- if (cmdiocb->iocb_flag & LPFC_IO_FCP) { +- abtsiocbp->iocb_flag |= LPFC_IO_FCP; +- abtsiocbp->iocb_flag |= LPFC_USE_FCPWQIDX; +- } ++ if (cmdiocb->iocb_flag & LPFC_IO_FCP) ++ abtsiocbp->iocb_flag |= (LPFC_IO_FCP | LPFC_USE_FCPWQIDX); + if (cmdiocb->iocb_flag & LPFC_IO_FOF) + abtsiocbp->iocb_flag |= LPFC_IO_FOF; + +- if (phba->link_state >= LPFC_LINK_UP) +- iabt->ulpCommand = CMD_ABORT_XRI_CN; +- else ++ if (phba->link_state < LPFC_LINK_UP || ++ (phba->sli_rev == LPFC_SLI_REV4 && ++ phba->sli4_hba.link_state.status == LPFC_FC_LA_TYPE_LINK_DOWN)) + iabt->ulpCommand = CMD_CLOSE_XRI_CN; ++ else ++ iabt->ulpCommand = CMD_ABORT_XRI_CN; + + if (cmpl) + abtsiocbp->iocb_cmpl = cmpl; +-- +2.33.0 + diff --git a/queue-5.15/scsi-lpfc-fix-list_add-corruption-in-lpfc_drain_txq.patch b/queue-5.15/scsi-lpfc-fix-list_add-corruption-in-lpfc_drain_txq.patch new file mode 100644 index 00000000000..10414c497c3 --- /dev/null +++ b/queue-5.15/scsi-lpfc-fix-list_add-corruption-in-lpfc_drain_txq.patch @@ -0,0 +1,48 @@ +From 88fff47167eecea217ac19bfefac54b1eed3eb3c Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 10 Sep 2021 16:31:46 -0700 +Subject: scsi: lpfc: Fix list_add() corruption in lpfc_drain_txq() + +From: James Smart + +[ Upstream commit 99154581b05c8fb22607afb7c3d66c1bace6aa5d ] + +When parsing the txq list in lpfc_drain_txq(), the driver attempts to pass +the requests to the adapter. If such an attempt fails, a local "fail_msg" +string is set and a log message output. The job is then added to a +completions list for cancellation. + +Processing of any further jobs from the txq list continues, but since +"fail_msg" remains set, jobs are added to the completions list regardless +of whether a wqe was passed to the adapter. If successfully added to +txcmplq, jobs are added to both lists resulting in list corruption. + +Fix by clearing the fail_msg string after adding a job to the completions +list. This stops the subsequent jobs from being added to the completions +list unless they had an appropriate failure. + +Link: https://lore.kernel.org/r/20210910233159.115896-2-jsmart2021@gmail.com +Co-developed-by: Justin Tee +Signed-off-by: Justin Tee +Signed-off-by: James Smart +Signed-off-by: Martin K. Petersen +Signed-off-by: Sasha Levin +--- + drivers/scsi/lpfc/lpfc_sli.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c +index 2fc671c8a638c..8e689f06afc92 100644 +--- a/drivers/scsi/lpfc/lpfc_sli.c ++++ b/drivers/scsi/lpfc/lpfc_sli.c +@@ -21162,6 +21162,7 @@ lpfc_drain_txq(struct lpfc_hba *phba) + fail_msg, + piocbq->iotag, piocbq->sli4_xritag); + list_add_tail(&piocbq->list, &completions); ++ fail_msg = NULL; + } + spin_unlock_irqrestore(&pring->ring_lock, iflags); + } +-- +2.33.0 + diff --git a/queue-5.15/scsi-lpfc-fix-use-after-free-in-lpfc_unreg_rpi-routi.patch b/queue-5.15/scsi-lpfc-fix-use-after-free-in-lpfc_unreg_rpi-routi.patch new file mode 100644 index 00000000000..8e1151be954 --- /dev/null +++ b/queue-5.15/scsi-lpfc-fix-use-after-free-in-lpfc_unreg_rpi-routi.patch @@ -0,0 +1,47 @@ +From fdbfa328ccca83bddb45005d5a5a3726ffa64660 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 20 Oct 2021 14:14:13 -0700 +Subject: scsi: lpfc: Fix use-after-free in lpfc_unreg_rpi() routine + +From: James Smart + +[ Upstream commit 79b20beccea3a3938a8500acef4e6b9d7c66142f ] + +An error is detected with the following report when unloading the driver: + "KASAN: use-after-free in lpfc_unreg_rpi+0x1b1b" + +The NLP_REG_LOGIN_SEND nlp_flag is set in lpfc_reg_fab_ctrl_node(), but the +flag is not cleared upon completion of the login. + +This allows a second call to lpfc_unreg_rpi() to proceed with nlp_rpi set +to LPFC_RPI_ALLOW_ERROR. This results in a use after free access when used +as an rpi_ids array index. + +Fix by clearing the NLP_REG_LOGIN_SEND nlp_flag in +lpfc_mbx_cmpl_fc_reg_login(). + +Link: https://lore.kernel.org/r/20211020211417.88754-5-jsmart2021@gmail.com +Co-developed-by: Justin Tee +Signed-off-by: Justin Tee +Signed-off-by: James Smart +Signed-off-by: Martin K. Petersen +Signed-off-by: Sasha Levin +--- + drivers/scsi/lpfc/lpfc_hbadisc.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c +index 6f2e07c30f98f..e1c02229c82d9 100644 +--- a/drivers/scsi/lpfc/lpfc_hbadisc.c ++++ b/drivers/scsi/lpfc/lpfc_hbadisc.c +@@ -4360,6 +4360,7 @@ lpfc_mbx_cmpl_fc_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) + ndlp->nlp_state); + + ndlp->nlp_flag |= NLP_RPI_REGISTERED; ++ ndlp->nlp_flag &= ~NLP_REG_LOGIN_SEND; + ndlp->nlp_type |= NLP_FABRIC; + lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE); + +-- +2.33.0 + diff --git a/queue-5.15/scsi-pm80xx-fix-memory-leak-during-rmmod.patch b/queue-5.15/scsi-pm80xx-fix-memory-leak-during-rmmod.patch new file mode 100644 index 00000000000..1c01832f828 --- /dev/null +++ b/queue-5.15/scsi-pm80xx-fix-memory-leak-during-rmmod.patch @@ -0,0 +1,69 @@ +From ae59830be26aa69013f01c48d28707a4a3155bc9 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 6 Sep 2021 22:34:04 +0530 +Subject: scsi: pm80xx: Fix memory leak during rmmod + +From: Ajish Koshy + +[ Upstream commit 51e6ed83bb4ade7c360551fa4ae55c4eacea354b ] + +Driver failed to release all memory allocated. This would lead to memory +leak during driver removal. + +Properly free memory when the module is removed. + +Link: https://lore.kernel.org/r/20210906170404.5682-5-Ajish.Koshy@microchip.com +Acked-by: Jack Wang +Signed-off-by: Ajish Koshy +Signed-off-by: Viswas G +Signed-off-by: Martin K. Petersen +Signed-off-by: Sasha Levin +--- + drivers/scsi/pm8001/pm8001_init.c | 11 +++++++++++ + drivers/scsi/pm8001/pm8001_sas.h | 1 + + 2 files changed, 12 insertions(+) + +diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c +index 47db7e0beae6f..729d8252028e8 100644 +--- a/drivers/scsi/pm8001/pm8001_init.c ++++ b/drivers/scsi/pm8001/pm8001_init.c +@@ -1198,6 +1198,7 @@ pm8001_init_ccb_tag(struct pm8001_hba_info *pm8001_ha, struct Scsi_Host *shost, + goto err_out; + + /* Memory region for ccb_info*/ ++ pm8001_ha->ccb_count = ccb_count; + pm8001_ha->ccb_info = + kcalloc(ccb_count, sizeof(struct pm8001_ccb_info), GFP_KERNEL); + if (!pm8001_ha->ccb_info) { +@@ -1259,6 +1260,16 @@ static void pm8001_pci_remove(struct pci_dev *pdev) + tasklet_kill(&pm8001_ha->tasklet[j]); + #endif + scsi_host_put(pm8001_ha->shost); ++ ++ for (i = 0; i < pm8001_ha->ccb_count; i++) { ++ dma_free_coherent(&pm8001_ha->pdev->dev, ++ sizeof(struct pm8001_prd) * PM8001_MAX_DMA_SG, ++ pm8001_ha->ccb_info[i].buf_prd, ++ pm8001_ha->ccb_info[i].ccb_dma_handle); ++ } ++ kfree(pm8001_ha->ccb_info); ++ kfree(pm8001_ha->devices); ++ + pm8001_free(pm8001_ha); + kfree(sha->sas_phy); + kfree(sha->sas_port); +diff --git a/drivers/scsi/pm8001/pm8001_sas.h b/drivers/scsi/pm8001/pm8001_sas.h +index e18f2b60371db..f40a41f450d9b 100644 +--- a/drivers/scsi/pm8001/pm8001_sas.h ++++ b/drivers/scsi/pm8001/pm8001_sas.h +@@ -517,6 +517,7 @@ struct pm8001_hba_info { + u32 iomb_size; /* SPC and SPCV IOMB size */ + struct pm8001_device *devices; + struct pm8001_ccb_info *ccb_info; ++ u32 ccb_count; + #ifdef PM8001_USE_MSIX + int number_of_intr;/*will be used in remove()*/ + char intr_drvname[PM8001_MAX_MSIX_VEC] +-- +2.33.0 + diff --git a/queue-5.15/scsi-scsi_debug-fix-out-of-bound-read-in-resp_readca.patch b/queue-5.15/scsi-scsi_debug-fix-out-of-bound-read-in-resp_readca.patch new file mode 100644 index 00000000000..fa901ebe870 --- /dev/null +++ b/queue-5.15/scsi-scsi_debug-fix-out-of-bound-read-in-resp_readca.patch @@ -0,0 +1,89 @@ +From f7998da074a437a298247c6a0451b5e928cdca88 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 13 Oct 2021 11:39:12 +0800 +Subject: scsi: scsi_debug: Fix out-of-bound read in resp_readcap16() + +From: Ye Bin + +[ Upstream commit 4e3ace0051e7e504b55d239daab8789dd89b863c ] + +The following warning was observed running syzkaller: + +[ 3813.830724] sg_write: data in/out 65466/242 bytes for SCSI command 0x9e-- guessing data in; +[ 3813.830724] program syz-executor not setting count and/or reply_len properly +[ 3813.836956] ================================================================== +[ 3813.839465] BUG: KASAN: stack-out-of-bounds in sg_copy_buffer+0x157/0x1e0 +[ 3813.841773] Read of size 4096 at addr ffff8883cf80f540 by task syz-executor/1549 +[ 3813.846612] Call Trace: +[ 3813.846995] dump_stack+0x108/0x15f +[ 3813.847524] print_address_description+0xa5/0x372 +[ 3813.848243] kasan_report.cold+0x236/0x2a8 +[ 3813.849439] check_memory_region+0x240/0x270 +[ 3813.850094] memcpy+0x30/0x80 +[ 3813.850553] sg_copy_buffer+0x157/0x1e0 +[ 3813.853032] sg_copy_from_buffer+0x13/0x20 +[ 3813.853660] fill_from_dev_buffer+0x135/0x370 +[ 3813.854329] resp_readcap16+0x1ac/0x280 +[ 3813.856917] schedule_resp+0x41f/0x1630 +[ 3813.858203] scsi_debug_queuecommand+0xb32/0x17e0 +[ 3813.862699] scsi_dispatch_cmd+0x330/0x950 +[ 3813.863329] scsi_request_fn+0xd8e/0x1710 +[ 3813.863946] __blk_run_queue+0x10b/0x230 +[ 3813.864544] blk_execute_rq_nowait+0x1d8/0x400 +[ 3813.865220] sg_common_write.isra.0+0xe61/0x2420 +[ 3813.871637] sg_write+0x6c8/0xef0 +[ 3813.878853] __vfs_write+0xe4/0x800 +[ 3813.883487] vfs_write+0x17b/0x530 +[ 3813.884008] ksys_write+0x103/0x270 +[ 3813.886268] __x64_sys_write+0x77/0xc0 +[ 3813.886841] do_syscall_64+0x106/0x360 +[ 3813.887415] entry_SYSCALL_64_after_hwframe+0x44/0xa9 + +This issue can be reproduced with the following syzkaller log: + +r0 = openat(0xffffffffffffff9c, &(0x7f0000000040)='./file0\x00', 0x26e1, 0x0) +r1 = syz_open_procfs(0xffffffffffffffff, &(0x7f0000000000)='fd/3\x00') +open_by_handle_at(r1, &(0x7f00000003c0)=ANY=[@ANYRESHEX], 0x602000) +r2 = syz_open_dev$sg(&(0x7f0000000000), 0x0, 0x40782) +write$binfmt_aout(r2, &(0x7f0000000340)=ANY=[@ANYBLOB="00000000deff000000000000000000000000000000000000000000000000000047f007af9e107a41ec395f1bded7be24277a1501ff6196a83366f4e6362bc0ff2b247f68a972989b094b2da4fb3607fcf611a22dd04310d28c75039d"], 0x126) + +In resp_readcap16() we get "int alloc_len" value -1104926854, and then pass +the huge arr_len to fill_from_dev_buffer(), but arr is only 32 bytes. This +leads to OOB in sg_copy_buffer(). + +To solve this issue, define alloc_len as u32. + +Link: https://lore.kernel.org/r/20211013033913.2551004-2-yebin10@huawei.com +Acked-by: Douglas Gilbert +Signed-off-by: Ye Bin +Signed-off-by: Martin K. Petersen +Signed-off-by: Sasha Levin +--- + drivers/scsi/scsi_debug.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c +index 66f507469a31a..be04405457447 100644 +--- a/drivers/scsi/scsi_debug.c ++++ b/drivers/scsi/scsi_debug.c +@@ -1856,7 +1856,7 @@ static int resp_readcap16(struct scsi_cmnd *scp, + { + unsigned char *cmd = scp->cmnd; + unsigned char arr[SDEBUG_READCAP16_ARR_SZ]; +- int alloc_len; ++ u32 alloc_len; + + alloc_len = get_unaligned_be32(cmd + 10); + /* following just in case virtual_gb changed */ +@@ -1885,7 +1885,7 @@ static int resp_readcap16(struct scsi_cmnd *scp, + } + + return fill_from_dev_buffer(scp, arr, +- min_t(int, alloc_len, SDEBUG_READCAP16_ARR_SZ)); ++ min_t(u32, alloc_len, SDEBUG_READCAP16_ARR_SZ)); + } + + #define SDEBUG_MAX_TGTPGS_ARR_SZ 1412 +-- +2.33.0 + diff --git a/queue-5.15/scsi-scsi_debug-fix-out-of-bound-read-in-resp_report.patch b/queue-5.15/scsi-scsi_debug-fix-out-of-bound-read-in-resp_report.patch new file mode 100644 index 00000000000..439bcb7bc71 --- /dev/null +++ b/queue-5.15/scsi-scsi_debug-fix-out-of-bound-read-in-resp_report.patch @@ -0,0 +1,89 @@ +From dbb5050f0216f4e375a39d2a5405ad909bd3dfbc Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 13 Oct 2021 11:39:13 +0800 +Subject: scsi: scsi_debug: Fix out-of-bound read in resp_report_tgtpgs() + +From: Ye Bin + +[ Upstream commit f347c26836c270199de1599c3cd466bb7747caa9 ] + +The following issue was observed running syzkaller: + +BUG: KASAN: slab-out-of-bounds in memcpy include/linux/string.h:377 [inline] +BUG: KASAN: slab-out-of-bounds in sg_copy_buffer+0x150/0x1c0 lib/scatterlist.c:831 +Read of size 2132 at addr ffff8880aea95dc8 by task syz-executor.0/9815 + +CPU: 0 PID: 9815 Comm: syz-executor.0 Not tainted 4.19.202-00874-gfc0fe04215a9 #2 +Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014 +Call Trace: + __dump_stack lib/dump_stack.c:77 [inline] + dump_stack+0xe4/0x14a lib/dump_stack.c:118 + print_address_description+0x73/0x280 mm/kasan/report.c:253 + kasan_report_error mm/kasan/report.c:352 [inline] + kasan_report+0x272/0x370 mm/kasan/report.c:410 + memcpy+0x1f/0x50 mm/kasan/kasan.c:302 + memcpy include/linux/string.h:377 [inline] + sg_copy_buffer+0x150/0x1c0 lib/scatterlist.c:831 + fill_from_dev_buffer+0x14f/0x340 drivers/scsi/scsi_debug.c:1021 + resp_report_tgtpgs+0x5aa/0x770 drivers/scsi/scsi_debug.c:1772 + schedule_resp+0x464/0x12f0 drivers/scsi/scsi_debug.c:4429 + scsi_debug_queuecommand+0x467/0x1390 drivers/scsi/scsi_debug.c:5835 + scsi_dispatch_cmd+0x3fc/0x9b0 drivers/scsi/scsi_lib.c:1896 + scsi_request_fn+0x1042/0x1810 drivers/scsi/scsi_lib.c:2034 + __blk_run_queue_uncond block/blk-core.c:464 [inline] + __blk_run_queue+0x1a4/0x380 block/blk-core.c:484 + blk_execute_rq_nowait+0x1c2/0x2d0 block/blk-exec.c:78 + sg_common_write.isra.19+0xd74/0x1dc0 drivers/scsi/sg.c:847 + sg_write.part.23+0x6e0/0xd00 drivers/scsi/sg.c:716 + sg_write+0x64/0xa0 drivers/scsi/sg.c:622 + __vfs_write+0xed/0x690 fs/read_write.c:485 +kill_bdev:block_device:00000000e138492c + vfs_write+0x184/0x4c0 fs/read_write.c:549 + ksys_write+0x107/0x240 fs/read_write.c:599 + do_syscall_64+0xc2/0x560 arch/x86/entry/common.c:293 + entry_SYSCALL_64_after_hwframe+0x49/0xbe + +We get 'alen' from command its type is int. If userspace passes a large +length we will get a negative 'alen'. + +Switch n, alen, and rlen to u32. + +Link: https://lore.kernel.org/r/20211013033913.2551004-3-yebin10@huawei.com +Acked-by: Douglas Gilbert +Signed-off-by: Ye Bin +Signed-off-by: Martin K. Petersen +Signed-off-by: Sasha Levin +--- + drivers/scsi/scsi_debug.c | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c +index be04405457447..ead65cdfb522e 100644 +--- a/drivers/scsi/scsi_debug.c ++++ b/drivers/scsi/scsi_debug.c +@@ -1896,8 +1896,9 @@ static int resp_report_tgtpgs(struct scsi_cmnd *scp, + unsigned char *cmd = scp->cmnd; + unsigned char *arr; + int host_no = devip->sdbg_host->shost->host_no; +- int n, ret, alen, rlen; + int port_group_a, port_group_b, port_a, port_b; ++ u32 alen, n, rlen; ++ int ret; + + alen = get_unaligned_be32(cmd + 6); + arr = kzalloc(SDEBUG_MAX_TGTPGS_ARR_SZ, GFP_ATOMIC); +@@ -1959,9 +1960,9 @@ static int resp_report_tgtpgs(struct scsi_cmnd *scp, + * - The constructed command length + * - The maximum array size + */ +- rlen = min_t(int, alen, n); ++ rlen = min(alen, n); + ret = fill_from_dev_buffer(scp, arr, +- min_t(int, rlen, SDEBUG_MAX_TGTPGS_ARR_SZ)); ++ min_t(u32, rlen, SDEBUG_MAX_TGTPGS_ARR_SZ)); + kfree(arr); + return ret; + } +-- +2.33.0 + diff --git a/queue-5.15/scsi-smartpqi-add-controller-handshake-during-kdump.patch b/queue-5.15/scsi-smartpqi-add-controller-handshake-during-kdump.patch new file mode 100644 index 00000000000..c63c114e7a5 --- /dev/null +++ b/queue-5.15/scsi-smartpqi-add-controller-handshake-during-kdump.patch @@ -0,0 +1,218 @@ +From 8ff2b0d4826b48d33d32ea754773d7cd3b1d900d Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 28 Sep 2021 18:54:33 -0500 +Subject: scsi: smartpqi: Add controller handshake during kdump + +From: Mahesh Rajashekhara + +[ Upstream commit 9ee5d6e9ac52a3c8625697535f8e35864d9fd38c ] + +Correct kdump hangs when controller is locked up. + +There are occasions when a controller reboot (controller soft reset) is +issued when a controller firmware crash dump is in progress. + +This leads to incomplete controller firmware crash dump: + + - When the controller crash dump is in progress, and a kdump is initiated, + the driver issues inbound doorbell reset to bring back the controller in + SIS mode. + + - If the controller is in locked up state, the inbound doorbell reset does + not work causing controller initialization failures. This results in the + driver hanging waiting for SIS mode. + +To avoid an incomplete controller crash dump, add in a controller crash +dump handshake: + + - Controller will indicate start and end of the controller crash dump by + setting some register bits. + + - Driver will look these bits when a kdump is initiated. If a controller + crash dump is in progress, the driver will wait for the controller crash + dump to complete before issuing the controller soft reset then complete + driver initialization. + +Link: https://lore.kernel.org/r/20210928235442.201875-3-don.brace@microchip.com +Reviewed-by: Scott Benesh +Reviewed-by: Scott Teel +Reviewed-by: Mike McGowen +Acked-by: John Donnelly +Signed-off-by: Mahesh Rajashekhara +Signed-off-by: Don Brace +Signed-off-by: Martin K. Petersen +Signed-off-by: Sasha Levin +--- + drivers/scsi/smartpqi/smartpqi_init.c | 41 +++++++++++++++++++-- + drivers/scsi/smartpqi/smartpqi_sis.c | 51 +++++++++++++++++++++++++++ + drivers/scsi/smartpqi/smartpqi_sis.h | 1 + + 3 files changed, 91 insertions(+), 2 deletions(-) + +diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c +index ecb2af3f43ca3..a5453f5e87c3e 100644 +--- a/drivers/scsi/smartpqi/smartpqi_init.c ++++ b/drivers/scsi/smartpqi/smartpqi_init.c +@@ -234,15 +234,46 @@ static inline bool pqi_is_hba_lunid(u8 *scsi3addr) + return pqi_scsi3addr_equal(scsi3addr, RAID_CTLR_LUNID); + } + ++#define PQI_DRIVER_SCRATCH_PQI_MODE 0x1 ++#define PQI_DRIVER_SCRATCH_FW_TRIAGE_SUPPORTED 0x2 ++ + static inline enum pqi_ctrl_mode pqi_get_ctrl_mode(struct pqi_ctrl_info *ctrl_info) + { +- return sis_read_driver_scratch(ctrl_info); ++ return sis_read_driver_scratch(ctrl_info) & PQI_DRIVER_SCRATCH_PQI_MODE ? PQI_MODE : SIS_MODE; + } + + static inline void pqi_save_ctrl_mode(struct pqi_ctrl_info *ctrl_info, + enum pqi_ctrl_mode mode) + { +- sis_write_driver_scratch(ctrl_info, mode); ++ u32 driver_scratch; ++ ++ driver_scratch = sis_read_driver_scratch(ctrl_info); ++ ++ if (mode == PQI_MODE) ++ driver_scratch |= PQI_DRIVER_SCRATCH_PQI_MODE; ++ else ++ driver_scratch &= ~PQI_DRIVER_SCRATCH_PQI_MODE; ++ ++ sis_write_driver_scratch(ctrl_info, driver_scratch); ++} ++ ++static inline bool pqi_is_fw_triage_supported(struct pqi_ctrl_info *ctrl_info) ++{ ++ return (sis_read_driver_scratch(ctrl_info) & PQI_DRIVER_SCRATCH_FW_TRIAGE_SUPPORTED) != 0; ++} ++ ++static inline void pqi_save_fw_triage_setting(struct pqi_ctrl_info *ctrl_info, bool is_supported) ++{ ++ u32 driver_scratch; ++ ++ driver_scratch = sis_read_driver_scratch(ctrl_info); ++ ++ if (is_supported) ++ driver_scratch |= PQI_DRIVER_SCRATCH_FW_TRIAGE_SUPPORTED; ++ else ++ driver_scratch &= ~PQI_DRIVER_SCRATCH_FW_TRIAGE_SUPPORTED; ++ ++ sis_write_driver_scratch(ctrl_info, driver_scratch); + } + + static inline void pqi_ctrl_block_scan(struct pqi_ctrl_info *ctrl_info) +@@ -7301,6 +7332,7 @@ static void pqi_ctrl_update_feature_flags(struct pqi_ctrl_info *ctrl_info, + ctrl_info->unique_wwid_in_report_phys_lun_supported = + firmware_feature->enabled; + break; ++ pqi_save_fw_triage_setting(ctrl_info, firmware_feature->enabled); + } + + pqi_firmware_feature_status(ctrl_info, firmware_feature); +@@ -7627,6 +7659,11 @@ static int pqi_ctrl_init(struct pqi_ctrl_info *ctrl_info) + u32 product_id; + + if (reset_devices) { ++ if (pqi_is_fw_triage_supported(ctrl_info)) { ++ rc = sis_wait_for_fw_triage_completion(ctrl_info); ++ if (rc) ++ return rc; ++ } + sis_soft_reset(ctrl_info); + msleep(PQI_POST_RESET_DELAY_SECS * PQI_HZ); + } else { +diff --git a/drivers/scsi/smartpqi/smartpqi_sis.c b/drivers/scsi/smartpqi/smartpqi_sis.c +index d63c46a8e38bb..8acd3a80f5822 100644 +--- a/drivers/scsi/smartpqi/smartpqi_sis.c ++++ b/drivers/scsi/smartpqi/smartpqi_sis.c +@@ -51,12 +51,20 @@ + #define SIS_BASE_STRUCT_REVISION 9 + #define SIS_BASE_STRUCT_ALIGNMENT 16 + ++#define SIS_CTRL_KERNEL_FW_TRIAGE 0x3 + #define SIS_CTRL_KERNEL_UP 0x80 + #define SIS_CTRL_KERNEL_PANIC 0x100 + #define SIS_CTRL_READY_TIMEOUT_SECS 180 + #define SIS_CTRL_READY_RESUME_TIMEOUT_SECS 90 + #define SIS_CTRL_READY_POLL_INTERVAL_MSECS 10 + ++enum sis_fw_triage_status { ++ FW_TRIAGE_NOT_STARTED = 0, ++ FW_TRIAGE_STARTED, ++ FW_TRIAGE_COND_INVALID, ++ FW_TRIAGE_COMPLETED ++}; ++ + #pragma pack(1) + + /* for use with SIS_CMD_INIT_BASE_STRUCT_ADDRESS command */ +@@ -419,12 +427,55 @@ u32 sis_read_driver_scratch(struct pqi_ctrl_info *ctrl_info) + return readl(&ctrl_info->registers->sis_driver_scratch); + } + ++static inline enum sis_fw_triage_status ++ sis_read_firmware_triage_status(struct pqi_ctrl_info *ctrl_info) ++{ ++ return ((enum sis_fw_triage_status)(readl(&ctrl_info->registers->sis_firmware_status) & ++ SIS_CTRL_KERNEL_FW_TRIAGE)); ++} ++ + void sis_soft_reset(struct pqi_ctrl_info *ctrl_info) + { + writel(SIS_SOFT_RESET, + &ctrl_info->registers->sis_host_to_ctrl_doorbell); + } + ++#define SIS_FW_TRIAGE_STATUS_TIMEOUT_SECS 300 ++#define SIS_FW_TRIAGE_STATUS_POLL_INTERVAL_SECS 1 ++ ++int sis_wait_for_fw_triage_completion(struct pqi_ctrl_info *ctrl_info) ++{ ++ int rc; ++ enum sis_fw_triage_status status; ++ unsigned long timeout; ++ ++ timeout = (SIS_FW_TRIAGE_STATUS_TIMEOUT_SECS * PQI_HZ) + jiffies; ++ while (1) { ++ status = sis_read_firmware_triage_status(ctrl_info); ++ if (status == FW_TRIAGE_COND_INVALID) { ++ dev_err(&ctrl_info->pci_dev->dev, ++ "firmware triage condition invalid\n"); ++ rc = -EINVAL; ++ break; ++ } else if (status == FW_TRIAGE_NOT_STARTED || ++ status == FW_TRIAGE_COMPLETED) { ++ rc = 0; ++ break; ++ } ++ ++ if (time_after(jiffies, timeout)) { ++ dev_err(&ctrl_info->pci_dev->dev, ++ "timed out waiting for firmware triage status\n"); ++ rc = -ETIMEDOUT; ++ break; ++ } ++ ++ ssleep(SIS_FW_TRIAGE_STATUS_POLL_INTERVAL_SECS); ++ } ++ ++ return rc; ++} ++ + static void __attribute__((unused)) verify_structures(void) + { + BUILD_BUG_ON(offsetof(struct sis_base_struct, +diff --git a/drivers/scsi/smartpqi/smartpqi_sis.h b/drivers/scsi/smartpqi/smartpqi_sis.h +index d29c1352a826a..c1db93054c863 100644 +--- a/drivers/scsi/smartpqi/smartpqi_sis.h ++++ b/drivers/scsi/smartpqi/smartpqi_sis.h +@@ -28,5 +28,6 @@ void sis_write_driver_scratch(struct pqi_ctrl_info *ctrl_info, u32 value); + u32 sis_read_driver_scratch(struct pqi_ctrl_info *ctrl_info); + void sis_soft_reset(struct pqi_ctrl_info *ctrl_info); + u32 sis_get_product_id(struct pqi_ctrl_info *ctrl_info); ++int sis_wait_for_fw_triage_completion(struct pqi_ctrl_info *ctrl_info); + + #endif /* _SMARTPQI_SIS_H */ +-- +2.33.0 + diff --git a/queue-5.15/scsi-target-fix-alua_tg_pt_gps_count-tracking.patch b/queue-5.15/scsi-target-fix-alua_tg_pt_gps_count-tracking.patch new file mode 100644 index 00000000000..80334bc43bf --- /dev/null +++ b/queue-5.15/scsi-target-fix-alua_tg_pt_gps_count-tracking.patch @@ -0,0 +1,45 @@ +From cf8e57411b15526b35f677beee1fb880ffd0415a Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 29 Sep 2021 21:04:20 -0500 +Subject: scsi: target: Fix alua_tg_pt_gps_count tracking + +From: Mike Christie + +[ Upstream commit 1283c0d1a32bb924324481586b5d6e8e76f676ba ] + +We can't free the tg_pt_gp in core_alua_set_tg_pt_gp_id() because it's +still accessed via configfs. Its release must go through the normal +configfs/refcount process. + +The max alua_tg_pt_gps_count check should probably have been done in +core_alua_allocate_tg_pt_gp(), but with the current code userspace could +have created 0x0000ffff + 1 groups, but only set the id for 0x0000ffff. +Then it could have deleted a group with an ID set, and then set the ID for +that extra group and it would work ok. + +It's unlikely, but just in case this patch continues to allow that type of +behavior, and just fixes the kfree() while in use bug. + +Link: https://lore.kernel.org/r/20210930020422.92578-4-michael.christie@oracle.com +Signed-off-by: Mike Christie +Signed-off-by: Martin K. Petersen +Signed-off-by: Sasha Levin +--- + drivers/target/target_core_alua.c | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c +index cb1de1ecaaa61..bd0f2ce011dd7 100644 +--- a/drivers/target/target_core_alua.c ++++ b/drivers/target/target_core_alua.c +@@ -1674,7 +1674,6 @@ int core_alua_set_tg_pt_gp_id( + pr_err("Maximum ALUA alua_tg_pt_gps_count:" + " 0x0000ffff reached\n"); + spin_unlock(&dev->t10_alua.tg_pt_gps_lock); +- kmem_cache_free(t10_alua_tg_pt_gp_cache, tg_pt_gp); + return -ENOSPC; + } + again: +-- +2.33.0 + diff --git a/queue-5.15/scsi-target-fix-ordered-tag-handling.patch b/queue-5.15/scsi-target-fix-ordered-tag-handling.patch new file mode 100644 index 00000000000..7b064cbb28c --- /dev/null +++ b/queue-5.15/scsi-target-fix-ordered-tag-handling.patch @@ -0,0 +1,266 @@ +From 3e216ebb64c26d150ee25a850d74fdb6de964292 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 29 Sep 2021 21:04:19 -0500 +Subject: scsi: target: Fix ordered tag handling + +From: Mike Christie + +[ Upstream commit ed1227e080990ffec5bf39006ec8a57358e6689a ] + +This patch fixes the following bugs: + +1. If there are multiple ordered cmds queued and multiple simple cmds + completing, target_restart_delayed_cmds() could be called on different + CPUs and each instance could start a ordered cmd. They could then run in + different orders than they were queued. + +2. target_restart_delayed_cmds() and target_handle_task_attr() can race + where: + + 1. target_handle_task_attr() has passed the simple_cmds == 0 check. + + 2. transport_complete_task_attr() then decrements simple_cmds to 0. + + 3. transport_complete_task_attr() runs target_restart_delayed_cmds() and + it does not see any cmds on the delayed_cmd_list. + + 4. target_handle_task_attr() adds the cmd to the delayed_cmd_list. + + The cmd will then end up timing out. + +3. If we are sent > 1 ordered cmds and simple_cmds == 0, we can execute + them out of order, because target_handle_task_attr() will hit that + simple_cmds check first and return false for all ordered cmds sent. + +4. We run target_restart_delayed_cmds() after every cmd completion, so if + there is more than 1 simple cmd running, we start executing ordered cmds + after that first cmd instead of waiting for all of them to complete. + +5. Ordered cmds are not supposed to start until HEAD OF QUEUE and all older + cmds have completed, and not just simple. + +6. It's not a bug but it doesn't make sense to take the delayed_cmd_lock + for every cmd completion when ordered cmds are almost never used. Just + replacing that lock with an atomic increases IOPs by up to 10% when + completions are spread over multiple CPUs and there are multiple + sessions/ mqs/thread accessing the same device. + +This patch moves the queued delayed handling to a per device work to +serialze the cmd executions for each device and adds a new counter to track +HEAD_OF_QUEUE and SIMPLE cmds. We can then check the new counter to +determine when to run the work on the completion path. + +Link: https://lore.kernel.org/r/20210930020422.92578-3-michael.christie@oracle.com +Signed-off-by: Mike Christie +Signed-off-by: Martin K. Petersen +Signed-off-by: Sasha Levin +--- + drivers/target/target_core_device.c | 2 + + drivers/target/target_core_internal.h | 1 + + drivers/target/target_core_transport.c | 76 ++++++++++++++++++-------- + include/target/target_core_base.h | 6 +- + 4 files changed, 61 insertions(+), 24 deletions(-) + +diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c +index 8cb1fa0c05857..44bb380e7390c 100644 +--- a/drivers/target/target_core_device.c ++++ b/drivers/target/target_core_device.c +@@ -772,6 +772,8 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name) + INIT_LIST_HEAD(&dev->t10_alua.lba_map_list); + spin_lock_init(&dev->t10_alua.lba_map_lock); + ++ INIT_WORK(&dev->delayed_cmd_work, target_do_delayed_work); ++ + dev->t10_wwn.t10_dev = dev; + /* + * Use OpenFabrics IEEE Company ID: 00 14 05 +diff --git a/drivers/target/target_core_internal.h b/drivers/target/target_core_internal.h +index a343bcfa2180f..a889a6237d9c1 100644 +--- a/drivers/target/target_core_internal.h ++++ b/drivers/target/target_core_internal.h +@@ -151,6 +151,7 @@ int transport_dump_vpd_ident(struct t10_vpd *, unsigned char *, int); + void transport_clear_lun_ref(struct se_lun *); + sense_reason_t target_cmd_size_check(struct se_cmd *cmd, unsigned int size); + void target_qf_do_work(struct work_struct *work); ++void target_do_delayed_work(struct work_struct *work); + bool target_check_wce(struct se_device *dev); + bool target_check_fua(struct se_device *dev); + void __target_execute_cmd(struct se_cmd *, bool); +diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c +index e60abd230e90f..72edf5bd75ee6 100644 +--- a/drivers/target/target_core_transport.c ++++ b/drivers/target/target_core_transport.c +@@ -2189,32 +2189,35 @@ static bool target_handle_task_attr(struct se_cmd *cmd) + */ + switch (cmd->sam_task_attr) { + case TCM_HEAD_TAG: ++ atomic_inc_mb(&dev->non_ordered); + pr_debug("Added HEAD_OF_QUEUE for CDB: 0x%02x\n", + cmd->t_task_cdb[0]); + return false; + case TCM_ORDERED_TAG: +- atomic_inc_mb(&dev->dev_ordered_sync); ++ atomic_inc_mb(&dev->delayed_cmd_count); + + pr_debug("Added ORDERED for CDB: 0x%02x to ordered list\n", + cmd->t_task_cdb[0]); +- +- /* +- * Execute an ORDERED command if no other older commands +- * exist that need to be completed first. +- */ +- if (!atomic_read(&dev->simple_cmds)) +- return false; + break; + default: + /* + * For SIMPLE and UNTAGGED Task Attribute commands + */ +- atomic_inc_mb(&dev->simple_cmds); ++ atomic_inc_mb(&dev->non_ordered); ++ ++ if (atomic_read(&dev->delayed_cmd_count) == 0) ++ return false; + break; + } + +- if (atomic_read(&dev->dev_ordered_sync) == 0) +- return false; ++ if (cmd->sam_task_attr != TCM_ORDERED_TAG) { ++ atomic_inc_mb(&dev->delayed_cmd_count); ++ /* ++ * We will account for this when we dequeue from the delayed ++ * list. ++ */ ++ atomic_dec_mb(&dev->non_ordered); ++ } + + spin_lock(&dev->delayed_cmd_lock); + list_add_tail(&cmd->se_delayed_node, &dev->delayed_cmd_list); +@@ -2222,6 +2225,12 @@ static bool target_handle_task_attr(struct se_cmd *cmd) + + pr_debug("Added CDB: 0x%02x Task Attr: 0x%02x to delayed CMD listn", + cmd->t_task_cdb[0], cmd->sam_task_attr); ++ /* ++ * We may have no non ordered cmds when this function started or we ++ * could have raced with the last simple/head cmd completing, so kick ++ * the delayed handler here. ++ */ ++ schedule_work(&dev->delayed_cmd_work); + return true; + } + +@@ -2259,29 +2268,48 @@ EXPORT_SYMBOL(target_execute_cmd); + * Process all commands up to the last received ORDERED task attribute which + * requires another blocking boundary + */ +-static void target_restart_delayed_cmds(struct se_device *dev) ++void target_do_delayed_work(struct work_struct *work) + { +- for (;;) { ++ struct se_device *dev = container_of(work, struct se_device, ++ delayed_cmd_work); ++ ++ spin_lock(&dev->delayed_cmd_lock); ++ while (!dev->ordered_sync_in_progress) { + struct se_cmd *cmd; + +- spin_lock(&dev->delayed_cmd_lock); +- if (list_empty(&dev->delayed_cmd_list)) { +- spin_unlock(&dev->delayed_cmd_lock); ++ if (list_empty(&dev->delayed_cmd_list)) + break; +- } + + cmd = list_entry(dev->delayed_cmd_list.next, + struct se_cmd, se_delayed_node); ++ ++ if (cmd->sam_task_attr == TCM_ORDERED_TAG) { ++ /* ++ * Check if we started with: ++ * [ordered] [simple] [ordered] ++ * and we are now at the last ordered so we have to wait ++ * for the simple cmd. ++ */ ++ if (atomic_read(&dev->non_ordered) > 0) ++ break; ++ ++ dev->ordered_sync_in_progress = true; ++ } ++ + list_del(&cmd->se_delayed_node); ++ atomic_dec_mb(&dev->delayed_cmd_count); + spin_unlock(&dev->delayed_cmd_lock); + ++ if (cmd->sam_task_attr != TCM_ORDERED_TAG) ++ atomic_inc_mb(&dev->non_ordered); ++ + cmd->transport_state |= CMD_T_SENT; + + __target_execute_cmd(cmd, true); + +- if (cmd->sam_task_attr == TCM_ORDERED_TAG) +- break; ++ spin_lock(&dev->delayed_cmd_lock); + } ++ spin_unlock(&dev->delayed_cmd_lock); + } + + /* +@@ -2299,14 +2327,17 @@ static void transport_complete_task_attr(struct se_cmd *cmd) + goto restart; + + if (cmd->sam_task_attr == TCM_SIMPLE_TAG) { +- atomic_dec_mb(&dev->simple_cmds); ++ atomic_dec_mb(&dev->non_ordered); + dev->dev_cur_ordered_id++; + } else if (cmd->sam_task_attr == TCM_HEAD_TAG) { ++ atomic_dec_mb(&dev->non_ordered); + dev->dev_cur_ordered_id++; + pr_debug("Incremented dev_cur_ordered_id: %u for HEAD_OF_QUEUE\n", + dev->dev_cur_ordered_id); + } else if (cmd->sam_task_attr == TCM_ORDERED_TAG) { +- atomic_dec_mb(&dev->dev_ordered_sync); ++ spin_lock(&dev->delayed_cmd_lock); ++ dev->ordered_sync_in_progress = false; ++ spin_unlock(&dev->delayed_cmd_lock); + + dev->dev_cur_ordered_id++; + pr_debug("Incremented dev_cur_ordered_id: %u for ORDERED\n", +@@ -2315,7 +2346,8 @@ static void transport_complete_task_attr(struct se_cmd *cmd) + cmd->se_cmd_flags &= ~SCF_TASK_ATTR_SET; + + restart: +- target_restart_delayed_cmds(dev); ++ if (atomic_read(&dev->delayed_cmd_count) > 0) ++ schedule_work(&dev->delayed_cmd_work); + } + + static void transport_complete_qf(struct se_cmd *cmd) +diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h +index fb11c7693b257..2121a323fd6c3 100644 +--- a/include/target/target_core_base.h ++++ b/include/target/target_core_base.h +@@ -812,8 +812,9 @@ struct se_device { + atomic_long_t read_bytes; + atomic_long_t write_bytes; + /* Active commands on this virtual SE device */ +- atomic_t simple_cmds; +- atomic_t dev_ordered_sync; ++ atomic_t non_ordered; ++ bool ordered_sync_in_progress; ++ atomic_t delayed_cmd_count; + atomic_t dev_qf_count; + u32 export_count; + spinlock_t delayed_cmd_lock; +@@ -834,6 +835,7 @@ struct se_device { + struct list_head dev_sep_list; + struct list_head dev_tmr_list; + struct work_struct qf_work_queue; ++ struct work_struct delayed_cmd_work; + struct list_head delayed_cmd_list; + struct list_head qf_cmd_list; + /* Pointer to associated SE HBA */ +-- +2.33.0 + diff --git a/queue-5.15/scsi-ufs-core-fix-another-task-management-completion.patch b/queue-5.15/scsi-ufs-core-fix-another-task-management-completion.patch new file mode 100644 index 00000000000..398f4bfc437 --- /dev/null +++ b/queue-5.15/scsi-ufs-core-fix-another-task-management-completion.patch @@ -0,0 +1,48 @@ +From 7fa3f5a8a4f74da9b14620fa3ef689deaef3b687 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 8 Nov 2021 08:48:15 +0200 +Subject: scsi: ufs: core: Fix another task management completion race + +From: Adrian Hunter + +[ Upstream commit 5cb37a26355d79ab290220677b1b57d28e99a895 ] + +hba->outstanding_tasks, which is read under host_lock spinlock, tells the +interrupt handler what task management tags are in use by the driver. The +doorbell register bits indicate which tags are in use by the hardware. A +doorbell bit that is 0 is because the bit has yet to be set by the driver, +or because the task is complete. It is only possible to disambiguate the 2 +cases, if reading/writing the doorbell register is synchronized with +reading/writing hba->outstanding_tasks. + +For that reason, reading REG_UTP_TASK_REQ_DOOR_BELL must be done under +spinlock. + +Link: https://lore.kernel.org/r/20211108064815.569494-3-adrian.hunter@intel.com +Fixes: f5ef336fd2e4 ("scsi: ufs: core: Fix task management completion") +Reviewed-by: Bart Van Assche +Signed-off-by: Adrian Hunter +Signed-off-by: Martin K. Petersen +Signed-off-by: Sasha Levin +--- + drivers/scsi/ufs/ufshcd.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c +index 3d0da8b3fed8a..55f2e4d6f10b7 100644 +--- a/drivers/scsi/ufs/ufshcd.c ++++ b/drivers/scsi/ufs/ufshcd.c +@@ -6382,9 +6382,8 @@ static irqreturn_t ufshcd_tmc_handler(struct ufs_hba *hba) + irqreturn_t ret = IRQ_NONE; + int tag; + +- pending = ufshcd_readl(hba, REG_UTP_TASK_REQ_DOOR_BELL); +- + spin_lock_irqsave(hba->host->host_lock, flags); ++ pending = ufshcd_readl(hba, REG_UTP_TASK_REQ_DOOR_BELL); + issued = hba->outstanding_tasks & ~pending; + for_each_set_bit(tag, &issued, hba->nutmrs) { + struct request *req = hba->tmf_rqs[tag]; +-- +2.33.0 + diff --git a/queue-5.15/scsi-ufs-core-fix-task-management-completion-timeout.patch b/queue-5.15/scsi-ufs-core-fix-task-management-completion-timeout.patch new file mode 100644 index 00000000000..a624d91be9e --- /dev/null +++ b/queue-5.15/scsi-ufs-core-fix-task-management-completion-timeout.patch @@ -0,0 +1,52 @@ +From fe4f614785386c407a545f88018659be8075fc97 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 8 Nov 2021 08:48:14 +0200 +Subject: scsi: ufs: core: Fix task management completion timeout race + +From: Adrian Hunter + +[ Upstream commit 886fe2915cce6658b0fc19e64b82879325de61ea ] + +__ufshcd_issue_tm_cmd() clears req->end_io_data after timing out, which +races with the completion function ufshcd_tmc_handler() which expects +req->end_io_data to have a value. + +Note __ufshcd_issue_tm_cmd() and ufshcd_tmc_handler() are already +synchronized using hba->tmf_rqs and hba->outstanding_tasks under the +host_lock spinlock. + +It is also not necessary (nor typical) to clear req->end_io_data because +the block layer does it before allocating out requests e.g. via +blk_get_request(). + +So fix by not clearing it. + +Link: https://lore.kernel.org/r/20211108064815.569494-2-adrian.hunter@intel.com +Fixes: f5ef336fd2e4 ("scsi: ufs: core: Fix task management completion") +Reviewed-by: Bart Van Assche +Signed-off-by: Adrian Hunter +Signed-off-by: Martin K. Petersen +Signed-off-by: Sasha Levin +--- + drivers/scsi/ufs/ufshcd.c | 5 ----- + 1 file changed, 5 deletions(-) + +diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c +index 325a15186e950..3d0da8b3fed8a 100644 +--- a/drivers/scsi/ufs/ufshcd.c ++++ b/drivers/scsi/ufs/ufshcd.c +@@ -6541,11 +6541,6 @@ static int __ufshcd_issue_tm_cmd(struct ufs_hba *hba, + err = wait_for_completion_io_timeout(&wait, + msecs_to_jiffies(TM_CMD_TIMEOUT)); + if (!err) { +- /* +- * Make sure that ufshcd_compl_tm() does not trigger a +- * use-after-free. +- */ +- req->end_io_data = NULL; + ufshcd_add_tm_upiu_trace(hba, task_tag, UFS_TM_ERR); + dev_err(hba->dev, "%s: task management cmd 0x%.2x timed-out\n", + __func__, tm_function); +-- +2.33.0 + diff --git a/queue-5.15/scsi-ufs-core-improve-scsi-abort-handling.patch b/queue-5.15/scsi-ufs-core-improve-scsi-abort-handling.patch new file mode 100644 index 00000000000..31ed1b5b5a3 --- /dev/null +++ b/queue-5.15/scsi-ufs-core-improve-scsi-abort-handling.patch @@ -0,0 +1,53 @@ +From 7c2f84c0419fbf89be42ea6ff81d6cc0c77736e0 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 4 Nov 2021 11:10:53 -0700 +Subject: scsi: ufs: core: Improve SCSI abort handling + +From: Bart Van Assche + +[ Upstream commit 3ff1f6b6ba6f97f50862aa50e79959cc8ddc2566 ] + +The following has been observed on a test setup: + +WARNING: CPU: 4 PID: 250 at drivers/scsi/ufs/ufshcd.c:2737 ufshcd_queuecommand+0x468/0x65c +Call trace: + ufshcd_queuecommand+0x468/0x65c + scsi_send_eh_cmnd+0x224/0x6a0 + scsi_eh_test_devices+0x248/0x418 + scsi_eh_ready_devs+0xc34/0xe58 + scsi_error_handler+0x204/0x80c + kthread+0x150/0x1b4 + ret_from_fork+0x10/0x30 + +That warning is triggered by the following statement: + + WARN_ON(lrbp->cmd); + +Fix this warning by clearing lrbp->cmd from the abort handler. + +Link: https://lore.kernel.org/r/20211104181059.4129537-1-bvanassche@acm.org +Fixes: 7a3e97b0dc4b ("[SCSI] ufshcd: UFS Host controller driver") +Reviewed-by: Bean Huo +Reviewed-by: Stanley Chu +Signed-off-by: Bart Van Assche +Signed-off-by: Martin K. Petersen +Signed-off-by: Sasha Levin +--- + drivers/scsi/ufs/ufshcd.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c +index 20705cec83c55..325a15186e950 100644 +--- a/drivers/scsi/ufs/ufshcd.c ++++ b/drivers/scsi/ufs/ufshcd.c +@@ -7040,6 +7040,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd) + goto release; + } + ++ lrbp->cmd = NULL; + err = SUCCESS; + + release: +-- +2.33.0 + diff --git a/queue-5.15/selftests-gpio-fix-gpio-compiling-error.patch b/queue-5.15/selftests-gpio-fix-gpio-compiling-error.patch new file mode 100644 index 00000000000..97bfd473f91 --- /dev/null +++ b/queue-5.15/selftests-gpio-fix-gpio-compiling-error.patch @@ -0,0 +1,40 @@ +From 8d4a986d53c4469d45a4ba25ec3fa8d3acd27f7a Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 8 Nov 2021 09:28:49 +0800 +Subject: selftests: gpio: fix gpio compiling error + +From: Li Zhijian + +[ Upstream commit 92a59d7f381d2caf69385bfa00590028e32eea26 ] + +The gpio selftests build against the system includes rather than the +headers from the linux tree. This results in the compile failing if +the system includes are outdated. + +Prefer the headers from the linux tree, as per other selftests. + +Fixes: 8bc395a6a2e2 ("selftests: gpio: rework and simplify test implementation") +Reported-by: kernel test robot +Signed-off-by: Li Zhijian +[Kent: reworded commit comment and added Fixes:] +Signed-off-by: Kent Gibson +Signed-off-by: Bartosz Golaszewski +Signed-off-by: Sasha Levin +--- + tools/testing/selftests/gpio/Makefile | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/tools/testing/selftests/gpio/Makefile b/tools/testing/selftests/gpio/Makefile +index 39f2bbe8dd3df..42ea7d2aa8440 100644 +--- a/tools/testing/selftests/gpio/Makefile ++++ b/tools/testing/selftests/gpio/Makefile +@@ -3,5 +3,6 @@ + TEST_PROGS := gpio-mockup.sh + TEST_FILES := gpio-mockup-sysfs.sh + TEST_GEN_PROGS_EXTENDED := gpio-mockup-cdev ++CFLAGS += -I../../../../usr/include + + include ../lib.mk +-- +2.33.0 + diff --git a/queue-5.15/selftests-net-switch-to-socat-in-the-gso-gre-test.patch b/queue-5.15/selftests-net-switch-to-socat-in-the-gso-gre-test.patch new file mode 100644 index 00000000000..4d350f11fb8 --- /dev/null +++ b/queue-5.15/selftests-net-switch-to-socat-in-the-gso-gre-test.patch @@ -0,0 +1,81 @@ +From 506559458918c49fd7874e79bafecb40c206d59b Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 11 Nov 2021 08:29:29 -0800 +Subject: selftests: net: switch to socat in the GSO GRE test + +From: Jakub Kicinski + +[ Upstream commit 0cda7d4bac5fd29dceb13df26083333fa99d6bb4 ] + +Commit a985442fdecb ("selftests: net: properly support IPv6 in GSO GRE test") +is not compatible with: + + Ncat: Version 7.80 ( https://nmap.org/ncat ) + +(which is distributed with Fedora/Red Hat), tests fail with: + + nc: invalid option -- 'N' + +Let's switch to socat which is far more dependable. + +Fixes: 025efa0a82df ("selftests: add simple GSO GRE test") +Fixes: a985442fdecb ("selftests: net: properly support IPv6 in GSO GRE test") +Tested-by: Andrea Righi +Link: https://lore.kernel.org/r/20211111162929.530470-1-kuba@kernel.org +Signed-off-by: Jakub Kicinski +Signed-off-by: Sasha Levin +--- + tools/testing/selftests/net/gre_gso.sh | 16 +++++++++------- + 1 file changed, 9 insertions(+), 7 deletions(-) + +diff --git a/tools/testing/selftests/net/gre_gso.sh b/tools/testing/selftests/net/gre_gso.sh +index fdeb44d621eb9..3224651db97b8 100755 +--- a/tools/testing/selftests/net/gre_gso.sh ++++ b/tools/testing/selftests/net/gre_gso.sh +@@ -118,16 +118,18 @@ gre_gst_test_checks() + local addr=$2 + local proto=$3 + +- $NS_EXEC nc $proto -kl $port >/dev/null & ++ [ "$proto" == 6 ] && addr="[$addr]" ++ ++ $NS_EXEC socat - tcp${proto}-listen:$port,reuseaddr,fork >/dev/null & + PID=$! + while ! $NS_EXEC ss -ltn | grep -q $port; do ((i++)); sleep 0.01; done + +- cat $TMPFILE | timeout 1 nc $proto -N $addr $port ++ cat $TMPFILE | timeout 1 socat -u STDIN TCP:$addr:$port + log_test $? 0 "$name - copy file w/ TSO" + + ethtool -K veth0 tso off + +- cat $TMPFILE | timeout 1 nc $proto -N $addr $port ++ cat $TMPFILE | timeout 1 socat -u STDIN TCP:$addr:$port + log_test $? 0 "$name - copy file w/ GSO" + + ethtool -K veth0 tso on +@@ -155,8 +157,8 @@ gre6_gso_test() + + sleep 2 + +- gre_gst_test_checks GREv6/v4 172.16.2.2 +- gre_gst_test_checks GREv6/v6 2001:db8:1::2 -6 ++ gre_gst_test_checks GREv6/v4 172.16.2.2 4 ++ gre_gst_test_checks GREv6/v6 2001:db8:1::2 6 + + cleanup + } +@@ -212,8 +214,8 @@ if [ ! -x "$(command -v ip)" ]; then + exit $ksft_skip + fi + +-if [ ! -x "$(command -v nc)" ]; then +- echo "SKIP: Could not run test without nc tool" ++if [ ! -x "$(command -v socat)" ]; then ++ echo "SKIP: Could not run test without socat tool" + exit $ksft_skip + fi + +-- +2.33.0 + diff --git a/queue-5.15/series b/queue-5.15/series new file mode 100644 index 00000000000..d8e3b474667 --- /dev/null +++ b/queue-5.15/series @@ -0,0 +1,177 @@ +arm64-zynqmp-do-not-duplicate-flash-partition-label-.patch +arm64-zynqmp-fix-serial-compatible-string.patch +clk-sunxi-ng-unregister-clocks-resets-when-unbinding.patch +arm-dts-sunxi-fix-opps-node-name.patch +arm64-dts-allwinner-h5-fix-gpu-thermal-zone-node-nam.patch +arm64-dts-allwinner-a100-fix-thermal-zone-node-name.patch +staging-wfx-ensure-irq-is-ready-before-enabling-it.patch +arm-dts-bcm5301x-fix-nodes-names.patch +arm-dts-bcm5301x-fix-mdio-mux-binding.patch +arm-dts-nsp-fix-mpcore-mmc-node-names.patch +arm64-dts-broadcom-bcm4908-move-reboot-syscon-out-of.patch +scsi-pm80xx-fix-memory-leak-during-rmmod.patch +scsi-lpfc-fix-list_add-corruption-in-lpfc_drain_txq.patch +asoc-mediatek-mt8195-add-missing-of_node_put.patch +arm64-dts-rockchip-disable-cdn-dp-on-pinebook-pro.patch +arm64-dts-hisilicon-fix-arm-sp805-compatible-string.patch +rdma-bnxt_re-check-if-the-vlan-is-valid-before-repor.patch +bus-ti-sysc-add-quirk-handling-for-reinit-on-context.patch +bus-ti-sysc-use-context-lost-quirk-for-otg.patch +usb-musb-tusb6010-check-return-value-after-calling-p.patch +usb-typec-tipd-remove-warn_on-in-tps6598x_block_read.patch +arm-dts-ux500-skomer-regulator-fixes.patch +staging-rtl8723bs-remove-possible-deadlock-when-disc.patch +staging-rtl8723bs-remove-a-second-possible-deadlock.patch +staging-rtl8723bs-remove-a-third-possible-deadlock.patch +arm-bcm53016-specify-switch-ports-for-meraki-mr32.patch +arm64-dts-qcom-msm8998-fix-cpu-l2-idle-state-latency.patch +arm64-dts-qcom-ipq6018-fix-qcom-controlled-remotely-.patch +arm64-dts-qcom-ipq8074-fix-qcom-controlled-remotely-.patch +arm64-dts-qcom-sdm845-fix-qcom-controlled-remotely-p.patch +arm64-dts-qcom-msm8916-add-unit-name-for-soc-node.patch +arm64-dts-freescale-fix-arm-sp805-compatible-string.patch +arm64-dts-ls1012a-add-serial-alias-for-ls1012a-rdb.patch +rdma-rxe-separate-hw-and-sw-l-rkeys.patch +asoc-sof-intel-hda-dai-fix-potential-locking-issue.patch +scsi-core-fix-scsi_mode_sense-buffer-length-handling.patch +alsa-usb-audio-disable-implicit-feedback-sync-for-be.patch +clk-imx-imx6ul-move-csi_sel-mux-to-correct-base-regi.patch +asoc-es8316-use-irqf_no_autoen-when-requesting-the-i.patch +asoc-rt5651-use-irqf_no_autoen-when-requesting-the-i.patch +asoc-nau8824-add-dmi-quirk-mechanism-for-active-high.patch +scsi-advansys-fix-kernel-pointer-leak.patch +scsi-smartpqi-add-controller-handshake-during-kdump.patch +arm64-dts-imx8mm-kontron-fix-reset-delays-for-ethern.patch +alsa-intel-dsp-config-add-quirk-for-apl-glk-tgl-devi.patch +asoc-intel-soc-acpi-add-missing-quirk-for-tgl-sdca-s.patch +asoc-intel-sof_sdw-add-missing-quirk-for-dell-sku-0a.patch +firmware_loader-fix-pre-allocated-buf-built-in-firmw.patch +cpuidle-tegra-check-whether-pmc-is-ready.patch +hid-multitouch-disable-sticky-fingers-for-uperfect-y.patch +alsa-usb-audio-add-support-for-the-pioneer-djm-750mk.patch +arm-dts-omap-fix-gpmc-mux-add-data-type.patch +usb-host-ohci-tmio-check-return-value-after-calling-.patch +asoc-rt5682-fix-a-little-pop-while-playback.patch +arm-dts-ls1021a-move-thermal-zones-node-out-of-soc.patch +arm-dts-ls1021a-tsn-use-generic-jedec-spi-nor-compat.patch +alsa-isa-not-for-m68k.patch +iommu-vt-d-do-not-falsely-log-intel_iommu-is-unsuppo.patch +tty-tty_buffer-fix-the-softlockup-issue-in-flush_to_.patch +mips-sni-fix-the-build.patch +scsi-scsi_debug-fix-out-of-bound-read-in-resp_readca.patch +scsi-scsi_debug-fix-out-of-bound-read-in-resp_report.patch +scsi-target-fix-ordered-tag-handling.patch +scsi-target-fix-alua_tg_pt_gps_count-tracking.patch +iio-imu-st_lsm6dsx-avoid-potential-array-overflow-in.patch +rdma-core-use-kvzalloc-when-allocating-the-struct-ib.patch +scsi-lpfc-fix-use-after-free-in-lpfc_unreg_rpi-routi.patch +scsi-lpfc-fix-link-down-processing-to-address-null-p.patch +scsi-lpfc-allow-fabric-node-recovery-if-recovery-is-.patch +memory-tegra20-emc-add-runtime-dependency-on-devfreq.patch +powerpc-5200-dts-fix-memory-node-unit-name.patch +arm64-dts-qcom-msm8916-add-cpu-acc-and-saw-spm.patch +arm-dts-qcom-fix-memory-and-mdio-nodes-naming-for-rb.patch +arm64-dts-qcom-fix-node-name-of-rpm-msg-ram-device-n.patch +alsa-gus-fix-null-pointer-dereference-on-pointer-blo.patch +alsa-usb-audio-fix-null-pointer-dereference-on-point.patch +clk-at91-sama7g5-remove-prescaler-part-of-master-clo.patch +iommu-dart-initialize-dart_streams_enable.patch +powerpc-dcr-use-cmplwi-instead-of-3-argument-cmpli.patch +powerpc-8xx-fix-oops-with-strict_kernel_rwx-without-.patch +hid-playstation-require-multicolor-led-functionality.patch +sh-check-return-code-of-request_irq.patch +maple-fix-wrong-return-value-of-maple_bus_init.patch +f2fs-fix-up-f2fs_lookup-tracepoints.patch +f2fs-fix-to-use-whint_mode.patch +f2fs-fix-wrong-condition-to-trigger-background-check.patch +sh-fix-kconfig-unmet-dependency-warning-for-frame_po.patch +sh-math-emu-drop-unused-functions.patch +sh-define-__big_endian-for-math-emu.patch +f2fs-compress-disallow-disabling-compress-on-non-emp.patch +f2fs-fix-incorrect-return-value-in-f2fs_sanity_check.patch +clk-ingenic-fix-bugs-with-divided-dividers.patch +clk-ast2600-fix-soc-revision-for-ahb.patch +clk-qcom-gcc-msm8996-drop-again-gcc_aggre1_pnoc_ahb_.patch +kvm-arm64-fix-host-stage-2-finalization.patch +mips-bcm63xx-ensure-that-cpu_supports_32bit_kernel-i.patch +mips-boot-compressed-add-__bswapdi2-to-target-for-zs.patch +sched-core-mitigate-race-cpus_share_cache-update_top.patch +sched-fair-prevent-dead-task-groups-from-regaining-c.patch +perf-x86-vlbr-add-c-flags-to-vlbr-event-constraints.patch +blkcg-remove-extra-blkcg_bio_issue_init.patch +tracing-histogram-do-not-copy-the-fixed-size-char-ar.patch +perf-bpf-avoid-memory-leak-from-perf_env__insert_btf.patch +perf-bench-futex-fix-memory-leak-of-perf_cpu_map__ne.patch +perf-tests-remove-bash-construct-from-record-zstd_co.patch +drm-nouveau-hdmigv100.c-fix-corrupted-hdmi-vendor-in.patch +bpf-fix-inner-map-state-pruning-regression.patch +samples-bpf-fix-summary-per-sec-stats-in-xdp_sample_.patch +samples-bpf-fix-incorrect-use-of-strlen-in-xdp_redir.patch +selftests-net-switch-to-socat-in-the-gso-gre-test.patch +net-ipa-ipa_resource-fix-wrong-for-loop-range.patch +tcp-fix-uninitialized-access-in-skb-frags-array-for-.patch +tracing-add-length-protection-to-histogram-string-co.patch +nl80211-fix-radio-statistics-in-survey-dump.patch +mac80211-fix-monitor_sdata-rcu-locking-assertions.patch +net-ipa-holb-register-sometimes-must-be-written-twic.patch +net-ipa-disable-holb-drop-when-updating-timer.patch +selftests-gpio-fix-gpio-compiling-error.patch +net-bnx2x-fix-variable-dereferenced-before-check.patch +bnxt_en-reject-indirect-blk-offload-when-hw-tc-offlo.patch +tipc-only-accept-encrypted-msg_crypto-msgs.patch +sock-fix-proc-net-sockstat-underflow-in-sk_clone_loc.patch +net-smc-make-sure-the-link_id-is-unique.patch +nfsd-fix-exposure-in-nfsd4_decode_bitmap.patch +iavf-fix-return-of-set-the-new-channel-count.patch +iavf-check-for-null-in-iavf_fix_features.patch +iavf-free-q_vectors-before-queues-in-iavf_disable_vf.patch +iavf-don-t-clear-a-lock-we-don-t-hold.patch +iavf-fix-failure-to-exit-out-from-last-all-multicast.patch +iavf-prevent-accidental-free-of-filter-structure.patch +iavf-validate-pointers.patch +iavf-fix-for-the-false-positive-asq-arq-errors-while.patch +iavf-fix-for-setting-queues-to-0.patch +iavf-restore-vlan-filters-after-link-down.patch +bpf-fix-toctou-on-read-only-map-s-constant-scalar-tr.patch +mips-generic-yamon-dt-fix-uninitialized-variable-err.patch +mips-bcm63xx-add-support-for-clk_get_parent.patch +mips-lantiq-add-support-for-clk_get_parent.patch +gpio-rockchip-needs-generic_irq_chip-to-fix-build-er.patch +platform-x86-hp_accel-fix-an-error-handling-path-in-.patch +platform-x86-think-lmi-abort-probe-on-analyze-failur.patch +udp-validate-checksum-in-udp_read_sock.patch +btrfs-make-1-bit-bit-fields-of-scrub_page-unsigned-i.patch +rdma-core-set-send-and-receive-cq-before-forwarding-.patch +net-mlx5e-ktls-fix-crash-in-rx-resync-flow.patch +net-mlx5e-wait-for-concurrent-flow-deletion-during-n.patch +net-mlx5-e-switch-fix-resetting-of-encap-mode-when-e.patch +net-mlx5e-nullify-cq-dbg-pointer-in-mlx5_debug_cq_re.patch +net-mlx5-update-error-handler-for-uctx-and-umem.patch +net-mlx5-e-switch-rebuild-lag-only-when-needed.patch +net-mlx5e-ct-fix-multiple-allocations-and-memleak-of.patch +net-mlx5-lag-update-tracker-when-state-change-event-.patch +net-mlx5-e-switch-return-error-if-encap-isn-t-suppor.patch +scsi-ufs-core-improve-scsi-abort-handling.patch +scsi-core-sysfs-fix-hang-when-device-state-is-set-vi.patch +scsi-ufs-core-fix-task-management-completion-timeout.patch +scsi-ufs-core-fix-another-task-management-completion.patch +net-mvmdio-fix-compilation-warning.patch +net-sched-act_mirred-drop-dst-for-the-direction-from.patch +net-dpaa2-eth-fix-use-after-free-in-dpaa2_eth_remove.patch +net-virtio_net_hdr_to_skb-count-transport-header-in-.patch +i40e-fix-correct-max_pkt_size-on-vf-rx-queue.patch +i40e-fix-null-ptr-dereference-on-vsi-filter-sync.patch +i40e-fix-changing-previously-set-num_queue_pairs-for.patch +i40e-fix-ping-is-lost-after-configuring-adq-on-vf.patch +rdma-mlx4-do-not-fail-the-registration-on-port-stats.patch +i40e-fix-warning-message-and-call-stack-during-rmmod.patch +i40e-fix-creation-of-first-queue-by-omitting-it-if-i.patch +i40e-fix-display-error-code-in-dmesg.patch +nfc-reorganize-the-functions-in-nci_request.patch +nfc-reorder-the-logic-in-nfc_-un-register_device.patch +nfc-add-nci_unreg-flag-to-eliminate-the-race.patch +e100-fix-device-suspend-resume.patch +ptp-ocp-fix-a-couple-null-vs-is_err-checks.patch +perf-bench-fix-two-memory-leaks-detected-with-asan.patch +tools-build-fix-removal-of-feature-sync-compare-and-.patch +riscv-fix-building-external-modules.patch diff --git a/queue-5.15/sh-check-return-code-of-request_irq.patch b/queue-5.15/sh-check-return-code-of-request_irq.patch new file mode 100644 index 00000000000..3d327590e8e --- /dev/null +++ b/queue-5.15/sh-check-return-code-of-request_irq.patch @@ -0,0 +1,45 @@ +From 786093b79ee62228d340e5b6be301de088dfe676 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 22 Dec 2020 12:54:01 -0800 +Subject: sh: check return code of request_irq + +From: Nick Desaulniers + +[ Upstream commit 0e38225c92c7964482a8bb6b3e37fde4319e965c ] + +request_irq is marked __must_check, but the call in shx3_prepare_cpus +has a void return type, so it can't propagate failure to the caller. +Follow cues from hexagon and just print an error. + +Fixes: c7936b9abcf5 ("sh: smp: Hook in to the generic IPI handler for SH-X3 SMP.") +Cc: Miguel Ojeda +Cc: Paul Mundt +Reported-by: Guenter Roeck +Signed-off-by: Nick Desaulniers +Tested-by: John Paul Adrian Glaubitz +Reviewed-by: Miguel Ojeda +Signed-off-by: Rich Felker +Signed-off-by: Sasha Levin +--- + arch/sh/kernel/cpu/sh4a/smp-shx3.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/arch/sh/kernel/cpu/sh4a/smp-shx3.c b/arch/sh/kernel/cpu/sh4a/smp-shx3.c +index f8a2bec0f260b..1261dc7b84e8b 100644 +--- a/arch/sh/kernel/cpu/sh4a/smp-shx3.c ++++ b/arch/sh/kernel/cpu/sh4a/smp-shx3.c +@@ -73,8 +73,9 @@ static void shx3_prepare_cpus(unsigned int max_cpus) + BUILD_BUG_ON(SMP_MSG_NR >= 8); + + for (i = 0; i < SMP_MSG_NR; i++) +- request_irq(104 + i, ipi_interrupt_handler, +- IRQF_PERCPU, "IPI", (void *)(long)i); ++ if (request_irq(104 + i, ipi_interrupt_handler, ++ IRQF_PERCPU, "IPI", (void *)(long)i)) ++ pr_err("Failed to request irq %d\n", i); + + for (i = 0; i < max_cpus; i++) + set_cpu_present(i, true); +-- +2.33.0 + diff --git a/queue-5.15/sh-define-__big_endian-for-math-emu.patch b/queue-5.15/sh-define-__big_endian-for-math-emu.patch new file mode 100644 index 00000000000..0c4d8ba95c8 --- /dev/null +++ b/queue-5.15/sh-define-__big_endian-for-math-emu.patch @@ -0,0 +1,59 @@ +From 267e3df9e194d037eb76ff9126a4dd0ee32dd777 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 4 Oct 2021 17:19:13 -0700 +Subject: sh: define __BIG_ENDIAN for math-emu + +From: Randy Dunlap + +[ Upstream commit b929926f01f2d14635345d22eafcf60feed1085e ] + +Fix this by defining both ENDIAN macros in + so that they can be utilized in + according to the latter's comment: +/* Allow sfp-machine to have its own byte order definitions. */ + +(This is what is done in arch/nds32/include/asm/sfp-machine.h.) + +This placates these build warnings: + +In file included from ../arch/sh/math-emu/math.c:23: +.../include/math-emu/single.h:50:21: warning: "__BIG_ENDIAN" is not defined, evaluates to 0 [-Wundef] + 50 | #if __BYTE_ORDER == __BIG_ENDIAN +In file included from ../arch/sh/math-emu/math.c:24: +.../include/math-emu/double.h:59:21: warning: "__BIG_ENDIAN" is not defined, evaluates to 0 [-Wundef] + 59 | #if __BYTE_ORDER == __BIG_ENDIAN + +Fixes: 4b565680d163 ("sh: math-emu support") +Signed-off-by: Randy Dunlap +Cc: Yoshinori Sato +Cc: John Paul Adrian Glaubitz +Reviewed-by: Geert Uytterhoeven +Tested-by: John Paul Adrian Glaubitz +Signed-off-by: Rich Felker +Signed-off-by: Sasha Levin +--- + arch/sh/include/asm/sfp-machine.h | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/arch/sh/include/asm/sfp-machine.h b/arch/sh/include/asm/sfp-machine.h +index cbc7cf8c97ce6..2d2423478b71d 100644 +--- a/arch/sh/include/asm/sfp-machine.h ++++ b/arch/sh/include/asm/sfp-machine.h +@@ -13,6 +13,14 @@ + #ifndef _SFP_MACHINE_H + #define _SFP_MACHINE_H + ++#ifdef __BIG_ENDIAN__ ++#define __BYTE_ORDER __BIG_ENDIAN ++#define __LITTLE_ENDIAN 0 ++#else ++#define __BYTE_ORDER __LITTLE_ENDIAN ++#define __BIG_ENDIAN 0 ++#endif ++ + #define _FP_W_TYPE_SIZE 32 + #define _FP_W_TYPE unsigned long + #define _FP_WS_TYPE signed long +-- +2.33.0 + diff --git a/queue-5.15/sh-fix-kconfig-unmet-dependency-warning-for-frame_po.patch b/queue-5.15/sh-fix-kconfig-unmet-dependency-warning-for-frame_po.patch new file mode 100644 index 00000000000..86e564dc59d --- /dev/null +++ b/queue-5.15/sh-fix-kconfig-unmet-dependency-warning-for-frame_po.patch @@ -0,0 +1,47 @@ +From 6bb845e7fbdf37d58e65055c16ea129120bbe021 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 4 Oct 2021 17:19:10 -0700 +Subject: sh: fix kconfig unmet dependency warning for FRAME_POINTER + +From: Randy Dunlap + +[ Upstream commit fda1bc533094a7db68b11e7503d2c6c73993d12a ] + +FRAME_POINTER depends on DEBUG_KERNEL so DWARF_UNWINDER should +depend on DEBUG_KERNEL before selecting FRAME_POINTER. + +WARNING: unmet direct dependencies detected for FRAME_POINTER + Depends on [n]: DEBUG_KERNEL [=n] && (M68K || UML || SUPERH [=y]) || ARCH_WANT_FRAME_POINTERS [=n] + Selected by [y]: + - DWARF_UNWINDER [=y] + +Fixes: bd353861c735 ("sh: dwarf unwinder support.") +Signed-off-by: Randy Dunlap +Cc: Matt Fleming +Cc: Matt Fleming +Cc: Yoshinori Sato +Cc: John Paul Adrian Glaubitz +Cc: Geert Uytterhoeven +Reviewed-by: Geert Uytterhoeven +Tested-by: John Paul Adrian Glaubitz +Signed-off-by: Rich Felker +Signed-off-by: Sasha Levin +--- + arch/sh/Kconfig.debug | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/arch/sh/Kconfig.debug b/arch/sh/Kconfig.debug +index 958f790273ab9..10290e5c1f438 100644 +--- a/arch/sh/Kconfig.debug ++++ b/arch/sh/Kconfig.debug +@@ -54,6 +54,7 @@ config DUMP_CODE + + config DWARF_UNWINDER + bool "Enable the DWARF unwinder for stacktraces" ++ depends on DEBUG_KERNEL + select FRAME_POINTER + default n + help +-- +2.33.0 + diff --git a/queue-5.15/sh-math-emu-drop-unused-functions.patch b/queue-5.15/sh-math-emu-drop-unused-functions.patch new file mode 100644 index 00000000000..2c57cd8db87 --- /dev/null +++ b/queue-5.15/sh-math-emu-drop-unused-functions.patch @@ -0,0 +1,147 @@ +From acc24fda47e0c859c03dc09e144ac30f689839cf Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 4 Oct 2021 17:19:12 -0700 +Subject: sh: math-emu: drop unused functions + +From: Randy Dunlap + +[ Upstream commit e25c252a9b033523c626f039d4b9a304f12f6775 ] + +Delete ieee_fpe_handler() since it is not used. After that is done, +delete denormal_to_double() since it is not used: + +.../arch/sh/math-emu/math.c:505:12: error: 'ieee_fpe_handler' defined but not used [-Werror=unused-function] + 505 | static int ieee_fpe_handler(struct pt_regs *regs) + +.../arch/sh/math-emu/math.c:477:13: error: 'denormal_to_double' defined but not used [-Werror=unused-function] + 477 | static void denormal_to_double(struct sh_fpu_soft_struct *fpu, int n) + +Fixes: 7caf62de25554da3 ("sh: remove unused do_fpu_error") +Signed-off-by: Randy Dunlap +Cc: Takashi YOSHII +Cc: Yoshinori Sato +Cc: John Paul Adrian Glaubitz +Reviewed-by: Geert Uytterhoeven +Signed-off-by: Rich Felker +Signed-off-by: Sasha Levin +--- + arch/sh/math-emu/math.c | 103 ---------------------------------------- + 1 file changed, 103 deletions(-) + +diff --git a/arch/sh/math-emu/math.c b/arch/sh/math-emu/math.c +index e8be0eca0444a..615ba932c398e 100644 +--- a/arch/sh/math-emu/math.c ++++ b/arch/sh/math-emu/math.c +@@ -467,109 +467,6 @@ static int fpu_emulate(u16 code, struct sh_fpu_soft_struct *fregs, struct pt_reg + return id_sys(fregs, regs, code); + } + +-/** +- * denormal_to_double - Given denormalized float number, +- * store double float +- * +- * @fpu: Pointer to sh_fpu_soft structure +- * @n: Index to FP register +- */ +-static void denormal_to_double(struct sh_fpu_soft_struct *fpu, int n) +-{ +- unsigned long du, dl; +- unsigned long x = fpu->fpul; +- int exp = 1023 - 126; +- +- if (x != 0 && (x & 0x7f800000) == 0) { +- du = (x & 0x80000000); +- while ((x & 0x00800000) == 0) { +- x <<= 1; +- exp--; +- } +- x &= 0x007fffff; +- du |= (exp << 20) | (x >> 3); +- dl = x << 29; +- +- fpu->fp_regs[n] = du; +- fpu->fp_regs[n+1] = dl; +- } +-} +- +-/** +- * ieee_fpe_handler - Handle denormalized number exception +- * +- * @regs: Pointer to register structure +- * +- * Returns 1 when it's handled (should not cause exception). +- */ +-static int ieee_fpe_handler(struct pt_regs *regs) +-{ +- unsigned short insn = *(unsigned short *)regs->pc; +- unsigned short finsn; +- unsigned long nextpc; +- int nib[4] = { +- (insn >> 12) & 0xf, +- (insn >> 8) & 0xf, +- (insn >> 4) & 0xf, +- insn & 0xf}; +- +- if (nib[0] == 0xb || +- (nib[0] == 0x4 && nib[2] == 0x0 && nib[3] == 0xb)) /* bsr & jsr */ +- regs->pr = regs->pc + 4; +- +- if (nib[0] == 0xa || nib[0] == 0xb) { /* bra & bsr */ +- nextpc = regs->pc + 4 + ((short) ((insn & 0xfff) << 4) >> 3); +- finsn = *(unsigned short *) (regs->pc + 2); +- } else if (nib[0] == 0x8 && nib[1] == 0xd) { /* bt/s */ +- if (regs->sr & 1) +- nextpc = regs->pc + 4 + ((char) (insn & 0xff) << 1); +- else +- nextpc = regs->pc + 4; +- finsn = *(unsigned short *) (regs->pc + 2); +- } else if (nib[0] == 0x8 && nib[1] == 0xf) { /* bf/s */ +- if (regs->sr & 1) +- nextpc = regs->pc + 4; +- else +- nextpc = regs->pc + 4 + ((char) (insn & 0xff) << 1); +- finsn = *(unsigned short *) (regs->pc + 2); +- } else if (nib[0] == 0x4 && nib[3] == 0xb && +- (nib[2] == 0x0 || nib[2] == 0x2)) { /* jmp & jsr */ +- nextpc = regs->regs[nib[1]]; +- finsn = *(unsigned short *) (regs->pc + 2); +- } else if (nib[0] == 0x0 && nib[3] == 0x3 && +- (nib[2] == 0x0 || nib[2] == 0x2)) { /* braf & bsrf */ +- nextpc = regs->pc + 4 + regs->regs[nib[1]]; +- finsn = *(unsigned short *) (regs->pc + 2); +- } else if (insn == 0x000b) { /* rts */ +- nextpc = regs->pr; +- finsn = *(unsigned short *) (regs->pc + 2); +- } else { +- nextpc = regs->pc + 2; +- finsn = insn; +- } +- +- if ((finsn & 0xf1ff) == 0xf0ad) { /* fcnvsd */ +- struct task_struct *tsk = current; +- +- if ((tsk->thread.xstate->softfpu.fpscr & (1 << 17))) { +- /* FPU error */ +- denormal_to_double (&tsk->thread.xstate->softfpu, +- (finsn >> 8) & 0xf); +- tsk->thread.xstate->softfpu.fpscr &= +- ~(FPSCR_CAUSE_MASK | FPSCR_FLAG_MASK); +- task_thread_info(tsk)->status |= TS_USEDFPU; +- } else { +- force_sig_fault(SIGFPE, FPE_FLTINV, +- (void __user *)regs->pc); +- } +- +- regs->pc = nextpc; +- return 1; +- } +- +- return 0; +-} +- + /** + * fpu_init - Initialize FPU registers + * @fpu: Pointer to software emulated FPU registers. +-- +2.33.0 + diff --git a/queue-5.15/sock-fix-proc-net-sockstat-underflow-in-sk_clone_loc.patch b/queue-5.15/sock-fix-proc-net-sockstat-underflow-in-sk_clone_loc.patch new file mode 100644 index 00000000000..6d2b1635da5 --- /dev/null +++ b/queue-5.15/sock-fix-proc-net-sockstat-underflow-in-sk_clone_loc.patch @@ -0,0 +1,49 @@ +From 910006f55bf509c02d5f696549a2f262ffd4f9eb Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 15 Nov 2021 19:16:56 +0900 +Subject: sock: fix /proc/net/sockstat underflow in sk_clone_lock() + +From: Tetsuo Handa + +[ Upstream commit 938cca9e4109b30ee1d476904538225a825e54eb ] + +sk_clone_lock() needs to call sock_inuse_add(1) before entering the +sk_free_unlock_clone() error path, for __sk_free() from sk_free() from +sk_free_unlock_clone() calls sock_inuse_add(-1). + +Signed-off-by: Tetsuo Handa +Fixes: 648845ab7e200993 ("sock: Move the socket inuse to namespace.") +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + net/core/sock.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/net/core/sock.c b/net/core/sock.c +index c1601f75ec4b3..1b31e10181629 100644 +--- a/net/core/sock.c ++++ b/net/core/sock.c +@@ -2043,8 +2043,10 @@ struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority) + newsk->sk_prot_creator = prot; + + /* SANITY */ +- if (likely(newsk->sk_net_refcnt)) ++ if (likely(newsk->sk_net_refcnt)) { + get_net(sock_net(newsk)); ++ sock_inuse_add(sock_net(newsk), 1); ++ } + sk_node_init(&newsk->sk_node); + sock_lock_init(newsk); + bh_lock_sock(newsk); +@@ -2115,8 +2117,6 @@ struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority) + newsk->sk_err_soft = 0; + newsk->sk_priority = 0; + newsk->sk_incoming_cpu = raw_smp_processor_id(); +- if (likely(newsk->sk_net_refcnt)) +- sock_inuse_add(sock_net(newsk), 1); + + /* Before updating sk_refcnt, we must commit prior changes to memory + * (Documentation/RCU/rculist_nulls.rst for details) +-- +2.33.0 + diff --git a/queue-5.15/staging-rtl8723bs-remove-a-second-possible-deadlock.patch b/queue-5.15/staging-rtl8723bs-remove-a-second-possible-deadlock.patch new file mode 100644 index 00000000000..c5c12ad5e1c --- /dev/null +++ b/queue-5.15/staging-rtl8723bs-remove-a-second-possible-deadlock.patch @@ -0,0 +1,215 @@ +From 9447cfbaff6047b95ebc6a98faef96a8f28ff1ad Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 20 Sep 2021 16:55:01 +0200 +Subject: staging: rtl8723bs: remove a second possible deadlock + +From: Hans de Goede + +[ Upstream commit a7ac783c338bafc04d3259600646350dba989043 ] + +Lockdep complains about rtw_free_assoc_resources() taking the sta_hash_lock +followed by it calling rtw_free_stainfo() which takes xmitpriv->lock. +While the rtl8723bs_xmit_thread takes the sta_hash_lock while already +holding the xmitpriv->lock: + +[ 103.849756] ====================================================== +[ 103.849761] WARNING: possible circular locking dependency detected +[ 103.849767] 5.15.0-rc1+ #470 Tainted: G C E +[ 103.849773] ------------------------------------------------------ +[ 103.849776] wpa_supplicant/695 is trying to acquire lock: +[ 103.849781] ffffa5d0c0562b00 (&pxmitpriv->lock){+.-.}-{2:2}, at: rtw_free_stainfo+0x8a/0x510 [r8723bs] +[ 103.849840] + but task is already holding lock: +[ 103.849843] ffffa5d0c05636a8 (&pstapriv->sta_hash_lock){+.-.}-{2:2}, at: rtw_free_assoc_resources+0x48/0x110 [r8723bs] +[ 103.849881] + which lock already depends on the new lock. + +[ 103.849884] + the existing dependency chain (in reverse order) is: +[ 103.849887] + -> #1 (&pstapriv->sta_hash_lock){+.-.}-{2:2}: +[ 103.849898] _raw_spin_lock_bh+0x34/0x40 +[ 103.849913] rtw_get_stainfo+0x93/0x110 [r8723bs] +[ 103.849948] rtw_make_wlanhdr+0x14a/0x270 [r8723bs] +[ 103.849983] rtw_xmitframe_coalesce+0x5c/0x6c0 [r8723bs] +[ 103.850019] rtl8723bs_xmit_thread+0x4ac/0x620 [r8723bs] +[ 103.850050] kthread+0x143/0x160 +[ 103.850058] ret_from_fork+0x22/0x30 +[ 103.850067] + -> #0 (&pxmitpriv->lock){+.-.}-{2:2}: +[ 103.850077] __lock_acquire+0x1158/0x1de0 +[ 103.850084] lock_acquire+0xb5/0x2b0 +[ 103.850090] _raw_spin_lock_bh+0x34/0x40 +[ 103.850095] rtw_free_stainfo+0x8a/0x510 [r8723bs] +[ 103.850130] rtw_free_assoc_resources+0x53/0x110 [r8723bs] +[ 103.850159] PHY_IQCalibrate_8723B+0x122b/0x36a0 [r8723bs] +[ 103.850189] cfg80211_disconnect+0x173/0x320 [cfg80211] +[ 103.850331] nl80211_disconnect+0x6e/0xb0 [cfg80211] +[ 103.850422] genl_family_rcv_msg_doit+0xcd/0x110 +[ 103.850430] genl_rcv_msg+0xce/0x1c0 +[ 103.850435] netlink_rcv_skb+0x50/0xf0 +[ 103.850441] genl_rcv+0x24/0x40 +[ 103.850446] netlink_unicast+0x16d/0x230 +[ 103.850452] netlink_sendmsg+0x22b/0x450 +[ 103.850457] sock_sendmsg+0x5e/0x60 +[ 103.850465] ____sys_sendmsg+0x22f/0x270 +[ 103.850472] ___sys_sendmsg+0x81/0xc0 +[ 103.850479] __sys_sendmsg+0x49/0x80 +[ 103.850485] do_syscall_64+0x3b/0x90 +[ 103.850493] entry_SYSCALL_64_after_hwframe+0x44/0xae +[ 103.850500] + other info that might help us debug this: + +[ 103.850504] Possible unsafe locking scenario: + +[ 103.850507] CPU0 CPU1 +[ 103.850510] ---- ---- +[ 103.850512] lock(&pstapriv->sta_hash_lock); +[ 103.850518] lock(&pxmitpriv->lock); +[ 103.850524] lock(&pstapriv->sta_hash_lock); +[ 103.850530] lock(&pxmitpriv->lock); +[ 103.850535] + *** DEADLOCK *** + +Push the taking of sta_hash_lock down into rtw_free_stainfo(), +where the critical section is, this allows taking the lock after +rtw_free_stainfo() has released pxmitpriv->lock. + +This requires changing rtw_free_all_stainfo() so that it does its freeing +in 2 steps, first moving all stainfo-s to free to a local list while +holding the sta_hash_lock and then walking that list to call +rtw_free_stainfo() on them without holding the sta_hash_lock. + +Pushing the taking of sta_hash_lock down into rtw_free_stainfo(), +also fixes a whole bunch of callers of rtw_free_stainfo() which +were not holding that lock even though they should. + +Note that this also fixes the deadlock from the "remove possible +deadlock when disconnect" patch in a different way. But the +changes from that patch offer a nice locking cleanup regardless. + +Signed-off-by: Hans de Goede +Link: https://lore.kernel.org/r/20210920145502.155454-2-hdegoede@redhat.com +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Sasha Levin +--- + drivers/staging/rtl8723bs/core/rtw_mlme.c | 5 ----- + drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 4 ---- + drivers/staging/rtl8723bs/core/rtw_sta_mgt.c | 11 +++++++++-- + drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 2 -- + 4 files changed, 9 insertions(+), 13 deletions(-) + +diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c +index ab6a24d70cc96..1f49c49e10b45 100644 +--- a/drivers/staging/rtl8723bs/core/rtw_mlme.c ++++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c +@@ -897,7 +897,6 @@ void rtw_free_assoc_resources(struct adapter *adapter, int lock_scanned_queue) + { + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + struct wlan_network *tgt_network = &pmlmepriv->cur_network; +- struct sta_priv *pstapriv = &adapter->stapriv; + struct dvobj_priv *psdpriv = adapter->dvobj; + struct debug_priv *pdbgpriv = &psdpriv->drv_dbg; + +@@ -905,11 +904,7 @@ void rtw_free_assoc_resources(struct adapter *adapter, int lock_scanned_queue) + struct sta_info *psta; + + psta = rtw_get_stainfo(&adapter->stapriv, tgt_network->network.mac_address); +- spin_lock_bh(&(pstapriv->sta_hash_lock)); + rtw_free_stainfo(adapter, psta); +- +- spin_unlock_bh(&(pstapriv->sta_hash_lock)); +- + } + + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE|WIFI_AP_STATE)) { +diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +index a1ae16ec69eb6..ad9c237054c4b 100644 +--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c ++++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +@@ -1489,9 +1489,7 @@ unsigned int OnDeAuth(struct adapter *padapter, union recv_frame *precv_frame) + struct sta_info *psta; + struct sta_priv *pstapriv = &padapter->stapriv; + +- /* spin_lock_bh(&(pstapriv->sta_hash_lock)); */ + /* rtw_free_stainfo(padapter, psta); */ +- /* spin_unlock_bh(&(pstapriv->sta_hash_lock)); */ + + netdev_dbg(padapter->pnetdev, + "ap recv deauth reason code(%d) sta:%pM\n", reason, +@@ -1565,9 +1563,7 @@ unsigned int OnDisassoc(struct adapter *padapter, union recv_frame *precv_frame) + struct sta_info *psta; + struct sta_priv *pstapriv = &padapter->stapriv; + +- /* spin_lock_bh(&(pstapriv->sta_hash_lock)); */ + /* rtw_free_stainfo(padapter, psta); */ +- /* spin_unlock_bh(&(pstapriv->sta_hash_lock)); */ + + netdev_dbg(padapter->pnetdev, + "ap recv disassoc reason code(%d) sta:%pM\n", +diff --git a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c +index c23d0c833ecf8..3d269842677dd 100644 +--- a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c ++++ b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c +@@ -263,7 +263,6 @@ exit: + return psta; + } + +-/* using pstapriv->sta_hash_lock to protect */ + u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta) + { + int i; +@@ -334,8 +333,10 @@ u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta) + + spin_unlock_bh(&pxmitpriv->lock); + ++ spin_lock_bh(&pstapriv->sta_hash_lock); + list_del_init(&psta->hash_list); + pstapriv->asoc_sta_count--; ++ spin_unlock_bh(&pstapriv->sta_hash_lock); + + /* re-init sta_info; 20061114 will be init in alloc_stainfo */ + /* _rtw_init_sta_xmit_priv(&psta->sta_xmitpriv); */ +@@ -430,6 +431,7 @@ void rtw_free_all_stainfo(struct adapter *padapter) + struct sta_info *psta = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; + struct sta_info *pbcmc_stainfo = rtw_get_bcmc_stainfo(padapter); ++ LIST_HEAD(stainfo_free_list); + + if (pstapriv->asoc_sta_count == 1) + return; +@@ -442,11 +444,16 @@ void rtw_free_all_stainfo(struct adapter *padapter) + psta = list_entry(plist, struct sta_info, hash_list); + + if (pbcmc_stainfo != psta) +- rtw_free_stainfo(padapter, psta); ++ list_move(&psta->hash_list, &stainfo_free_list); + } + } + + spin_unlock_bh(&pstapriv->sta_hash_lock); ++ ++ list_for_each_safe(plist, tmp, &stainfo_free_list) { ++ psta = list_entry(plist, struct sta_info, hash_list); ++ rtw_free_stainfo(padapter, psta); ++ } + } + + /* any station allocated can be searched by hash list */ +diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +index 9d4a233a861e3..295121c268bd4 100644 +--- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c ++++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +@@ -835,9 +835,7 @@ static int rtw_add_sta(struct net_device *dev, struct ieee_param *param) + psta = rtw_get_stainfo(pstapriv, param->sta_addr); + if (psta) + { +- spin_lock_bh(&(pstapriv->sta_hash_lock)); + rtw_free_stainfo(padapter, psta); +- spin_unlock_bh(&(pstapriv->sta_hash_lock)); + + psta = NULL; + } +-- +2.33.0 + diff --git a/queue-5.15/staging-rtl8723bs-remove-a-third-possible-deadlock.patch b/queue-5.15/staging-rtl8723bs-remove-a-third-possible-deadlock.patch new file mode 100644 index 00000000000..e3f3a421ff8 --- /dev/null +++ b/queue-5.15/staging-rtl8723bs-remove-a-third-possible-deadlock.patch @@ -0,0 +1,158 @@ +From 4864b6c390d9aa87eee221b8f85bb269e6bdfaff Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 20 Sep 2021 16:55:02 +0200 +Subject: staging: rtl8723bs: remove a third possible deadlock + +From: Hans de Goede + +[ Upstream commit bdc1bbdbaa92df19a14d4c1902088c8432b46c6f ] + +The assoc_timer takes the pmlmepriv->lock and various functions which +take the pmlmepriv->scanned_queue.lock first take the pmlmepriv->lock, +this means that we cannot have code which waits for the timer +(timer_del_sync) while holding the pmlmepriv->scanned_queue.lock +to avoid a triangle deadlock: + +[ 363.139361] ====================================================== +[ 363.139377] WARNING: possible circular locking dependency detected +[ 363.139396] 5.15.0-rc1+ #470 Tainted: G C E +[ 363.139413] ------------------------------------------------------ +[ 363.139424] RTW_CMD_THREAD/2466 is trying to acquire lock: +[ 363.139441] ffffbacd00699038 (&pmlmepriv->lock){+.-.}-{2:2}, at: _rtw_join_timeout_handler+0x3c/0x160 [r8723bs] +[ 363.139598] + but task is already holding lock: +[ 363.139610] ffffbacd00128ea0 ((&pmlmepriv->assoc_timer)){+.-.}-{0:0}, at: call_timer_fn+0x5/0x260 +[ 363.139673] + which lock already depends on the new lock. + +[ 363.139684] + the existing dependency chain (in reverse order) is: +[ 363.139696] + -> #2 ((&pmlmepriv->assoc_timer)){+.-.}-{0:0}: +[ 363.139734] del_timer_sync+0x59/0x100 +[ 363.139762] rtw_joinbss_event_prehandle+0x342/0x640 [r8723bs] +[ 363.139870] report_join_res+0xdf/0x110 [r8723bs] +[ 363.139980] OnAssocRsp+0x17a/0x200 [r8723bs] +[ 363.140092] rtw_recv_entry+0x190/0x1120 [r8723bs] +[ 363.140209] rtl8723b_process_phy_info+0x3f9/0x750 [r8723bs] +[ 363.140318] tasklet_action_common.constprop.0+0xe8/0x110 +[ 363.140345] __do_softirq+0xde/0x485 +[ 363.140372] __irq_exit_rcu+0xd0/0x100 +[ 363.140393] irq_exit_rcu+0xa/0x20 +[ 363.140413] common_interrupt+0x83/0xa0 +[ 363.140440] asm_common_interrupt+0x1e/0x40 +[ 363.140463] finish_task_switch.isra.0+0x157/0x3d0 +[ 363.140492] __schedule+0x447/0x1880 +[ 363.140516] schedule+0x59/0xc0 +[ 363.140537] smpboot_thread_fn+0x161/0x1c0 +[ 363.140565] kthread+0x143/0x160 +[ 363.140585] ret_from_fork+0x22/0x30 +[ 363.140614] + -> #1 (&pmlmepriv->scanned_queue.lock){+.-.}-{2:2}: +[ 363.140653] _raw_spin_lock_bh+0x34/0x40 +[ 363.140675] rtw_free_network_queue+0x31/0x80 [r8723bs] +[ 363.140776] rtw_sitesurvey_cmd+0x79/0x1e0 [r8723bs] +[ 363.140869] rtw_cfg80211_surveydone_event_callback+0x3cf/0x470 [r8723bs] +[ 363.140973] rdev_scan+0x42/0x1a0 [cfg80211] +[ 363.141307] nl80211_trigger_scan+0x566/0x660 [cfg80211] +[ 363.141635] genl_family_rcv_msg_doit+0xcd/0x110 +[ 363.141661] genl_rcv_msg+0xce/0x1c0 +[ 363.141680] netlink_rcv_skb+0x50/0xf0 +[ 363.141699] genl_rcv+0x24/0x40 +[ 363.141717] netlink_unicast+0x16d/0x230 +[ 363.141736] netlink_sendmsg+0x22b/0x450 +[ 363.141755] sock_sendmsg+0x5e/0x60 +[ 363.141781] ____sys_sendmsg+0x22f/0x270 +[ 363.141803] ___sys_sendmsg+0x81/0xc0 +[ 363.141828] __sys_sendmsg+0x49/0x80 +[ 363.141851] do_syscall_64+0x3b/0x90 +[ 363.141873] entry_SYSCALL_64_after_hwframe+0x44/0xae +[ 363.141895] + -> #0 (&pmlmepriv->lock){+.-.}-{2:2}: +[ 363.141930] __lock_acquire+0x1158/0x1de0 +[ 363.141954] lock_acquire+0xb5/0x2b0 +[ 363.141974] _raw_spin_lock_bh+0x34/0x40 +[ 363.141993] _rtw_join_timeout_handler+0x3c/0x160 [r8723bs] +[ 363.142097] call_timer_fn+0x94/0x260 +[ 363.142122] __run_timers.part.0+0x1bf/0x290 +[ 363.142147] run_timer_softirq+0x26/0x50 +[ 363.142171] __do_softirq+0xde/0x485 +[ 363.142193] __irq_exit_rcu+0xd0/0x100 +[ 363.142215] irq_exit_rcu+0xa/0x20 +[ 363.142235] sysvec_apic_timer_interrupt+0x72/0x90 +[ 363.142260] asm_sysvec_apic_timer_interrupt+0x12/0x20 +[ 363.142283] __module_address.part.0+0x0/0xd0 +[ 363.142309] is_module_address+0x25/0x40 +[ 363.142334] static_obj+0x4f/0x60 +[ 363.142361] lockdep_init_map_type+0x47/0x220 +[ 363.142382] __init_swait_queue_head+0x45/0x60 +[ 363.142408] mmc_wait_for_req+0x4a/0xc0 [mmc_core] +[ 363.142504] mmc_wait_for_cmd+0x55/0x70 [mmc_core] +[ 363.142592] mmc_io_rw_direct+0x75/0xe0 [mmc_core] +[ 363.142691] sdio_writeb+0x2e/0x50 [mmc_core] +[ 363.142788] _sd_cmd52_write+0x62/0x80 [r8723bs] +[ 363.142885] sd_cmd52_write+0x6c/0xb0 [r8723bs] +[ 363.142981] rtl8723bs_set_hal_ops+0x982/0x9b0 [r8723bs] +[ 363.143089] rtw_write16+0x1e/0x30 [r8723bs] +[ 363.143184] SetHwReg8723B+0xcc9/0xd30 [r8723bs] +[ 363.143294] mlmeext_joinbss_event_callback+0x17a/0x1a0 [r8723bs] +[ 363.143405] rtw_joinbss_event_callback+0x11/0x20 [r8723bs] +[ 363.143507] mlme_evt_hdl+0x4d/0x70 [r8723bs] +[ 363.143620] rtw_cmd_thread+0x168/0x3c0 [r8723bs] +[ 363.143712] kthread+0x143/0x160 +[ 363.143732] ret_from_fork+0x22/0x30 +[ 363.143757] + other info that might help us debug this: + +[ 363.143768] Chain exists of: + &pmlmepriv->lock --> &pmlmepriv->scanned_queue.lock --> (&pmlmepriv->assoc_timer) + +[ 363.143809] Possible unsafe locking scenario: + +[ 363.143819] CPU0 CPU1 +[ 363.143831] ---- ---- +[ 363.143841] lock((&pmlmepriv->assoc_timer)); +[ 363.143862] lock(&pmlmepriv->scanned_queue.lock); +[ 363.143882] lock((&pmlmepriv->assoc_timer)); +[ 363.143902] lock(&pmlmepriv->lock); +[ 363.143921] + *** DEADLOCK *** + +Make rtw_joinbss_event_prehandle() release the scanned_queue.lock before +it deletes the timer to avoid this (it is still holding pmlmepriv->lock +protecting against racing the timer). + +Signed-off-by: Hans de Goede +Link: https://lore.kernel.org/r/20210920145502.155454-3-hdegoede@redhat.com +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Sasha Levin +--- + drivers/staging/rtl8723bs/core/rtw_mlme.c | 7 ++----- + 1 file changed, 2 insertions(+), 5 deletions(-) + +diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c +index 1f49c49e10b45..cf79bec916c51 100644 +--- a/drivers/staging/rtl8723bs/core/rtw_mlme.c ++++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c +@@ -1234,16 +1234,13 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) + rtw_indicate_connect(adapter); + } + ++ spin_unlock_bh(&pmlmepriv->scanned_queue.lock); ++ + /* s5. Cancel assoc_timer */ + del_timer_sync(&pmlmepriv->assoc_timer); +- + } else { + spin_unlock_bh(&(pmlmepriv->scanned_queue.lock)); +- goto ignore_joinbss_callback; + } +- +- spin_unlock_bh(&(pmlmepriv->scanned_queue.lock)); +- + } else if (pnetwork->join_res == -4) { + rtw_reset_securitypriv(adapter); + _set_timer(&pmlmepriv->assoc_timer, 1); +-- +2.33.0 + diff --git a/queue-5.15/staging-rtl8723bs-remove-possible-deadlock-when-disc.patch b/queue-5.15/staging-rtl8723bs-remove-possible-deadlock-when-disc.patch new file mode 100644 index 00000000000..d7c4696361d --- /dev/null +++ b/queue-5.15/staging-rtl8723bs-remove-possible-deadlock-when-disc.patch @@ -0,0 +1,443 @@ +From 725098830d5d562a71dd6a85d647b4927f101218 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 20 Sep 2021 16:55:00 +0200 +Subject: staging: rtl8723bs: remove possible deadlock when disconnect (v2) + +From: Fabio Aiuto + +[ Upstream commit 54659ca026e586bbb33a7e60daa6443a3ac6b5df ] + +when turning off a connection, lockdep complains with the +following warning (a modprobe has been done but the same +happens with a disconnection from NetworkManager, +it's enough to trigger a cfg80211_disconnect call): + +[ 682.855867] ====================================================== +[ 682.855877] WARNING: possible circular locking dependency detected +[ 682.855887] 5.14.0-rc6+ #16 Tainted: G C OE +[ 682.855898] ------------------------------------------------------ +[ 682.855906] modprobe/1770 is trying to acquire lock: +[ 682.855916] ffffb6d000332b00 (&pxmitpriv->lock){+.-.}-{2:2}, + at: rtw_free_stainfo+0x52/0x4a0 [r8723bs] +[ 682.856073] + but task is already holding lock: +[ 682.856081] ffffb6d0003336a8 (&pstapriv->sta_hash_lock){+.-.}-{2:2}, + at: rtw_free_assoc_resources+0x48/0x110 [r8723bs] +[ 682.856207] + which lock already depends on the new lock. + +[ 682.856215] + the existing dependency chain (in reverse order) is: +[ 682.856223] + -> #1 (&pstapriv->sta_hash_lock){+.-.}-{2:2}: +[ 682.856247] _raw_spin_lock_bh+0x34/0x40 +[ 682.856265] rtw_get_stainfo+0x9a/0x110 [r8723bs] +[ 682.856389] rtw_xmit_classifier+0x27/0x130 [r8723bs] +[ 682.856515] rtw_xmitframe_enqueue+0xa/0x20 [r8723bs] +[ 682.856642] rtl8723bs_hal_xmit+0x3b/0xb0 [r8723bs] +[ 682.856752] rtw_xmit+0x4ef/0x890 [r8723bs] +[ 682.856879] _rtw_xmit_entry+0xba/0x350 [r8723bs] +[ 682.856981] dev_hard_start_xmit+0xee/0x320 +[ 682.856999] sch_direct_xmit+0x8c/0x330 +[ 682.857014] __dev_queue_xmit+0xba5/0xf00 +[ 682.857030] packet_sendmsg+0x981/0x1b80 +[ 682.857047] sock_sendmsg+0x5b/0x60 +[ 682.857060] __sys_sendto+0xf1/0x160 +[ 682.857073] __x64_sys_sendto+0x24/0x30 +[ 682.857087] do_syscall_64+0x3a/0x80 +[ 682.857102] entry_SYSCALL_64_after_hwframe+0x44/0xae +[ 682.857117] + -> #0 (&pxmitpriv->lock){+.-.}-{2:2}: +[ 682.857142] __lock_acquire+0xfd9/0x1b50 +[ 682.857158] lock_acquire+0xb4/0x2c0 +[ 682.857172] _raw_spin_lock_bh+0x34/0x40 +[ 682.857185] rtw_free_stainfo+0x52/0x4a0 [r8723bs] +[ 682.857308] rtw_free_assoc_resources+0x53/0x110 [r8723bs] +[ 682.857415] cfg80211_rtw_disconnect+0x4b/0x70 [r8723bs] +[ 682.857522] cfg80211_disconnect+0x12e/0x2f0 [cfg80211] +[ 682.857759] cfg80211_leave+0x2b/0x40 [cfg80211] +[ 682.857961] cfg80211_netdev_notifier_call+0xa9/0x560 [cfg80211] +[ 682.858163] raw_notifier_call_chain+0x41/0x50 +[ 682.858180] __dev_close_many+0x62/0x100 +[ 682.858195] dev_close_many+0x7d/0x120 +[ 682.858209] unregister_netdevice_many+0x416/0x680 +[ 682.858225] unregister_netdevice_queue+0xab/0xf0 +[ 682.858240] unregister_netdev+0x18/0x20 +[ 682.858255] rtw_unregister_netdevs+0x28/0x40 [r8723bs] +[ 682.858360] rtw_dev_remove+0x24/0xd0 [r8723bs] +[ 682.858463] sdio_bus_remove+0x31/0xd0 [mmc_core] +[ 682.858532] device_release_driver_internal+0xf7/0x1d0 +[ 682.858550] driver_detach+0x47/0x90 +[ 682.858564] bus_remove_driver+0x77/0xd0 +[ 682.858579] rtw_drv_halt+0xc/0x678 [r8723bs] +[ 682.858685] __x64_sys_delete_module+0x13f/0x250 +[ 682.858699] do_syscall_64+0x3a/0x80 +[ 682.858715] entry_SYSCALL_64_after_hwframe+0x44/0xae +[ 682.858729] + other info that might help us debug this: + +[ 682.858737] Possible unsafe locking scenario: + +[ 682.858744] CPU0 CPU1 +[ 682.858751] ---- ---- +[ 682.858758] lock(&pstapriv->sta_hash_lock); +[ 682.858772] lock(&pxmitpriv->lock); +[ 682.858786] lock(&pstapriv->sta_hash_lock); +[ 682.858799] lock(&pxmitpriv->lock); +[ 682.858812] + *** DEADLOCK *** + +[ 682.858820] 5 locks held by modprobe/1770: +[ 682.858831] #0: ffff8d870697d980 (&dev->mutex){....}-{3:3}, + at: device_release_driver_internal+0x1a/0x1d0 +[ 682.858869] #1: ffffffffbdbbf1c8 (rtnl_mutex){+.+.}-{3:3}, + at: unregister_netdev+0xe/0x20 +[ 682.858906] #2: ffff8d87054ee5e8 (&rdev->wiphy.mtx){+.+.}-{3:3}, + at: cfg80211_netdev_notifier_call+0x9e/0x560 [cfg80211] +[ 682.859131] #3: ffff8d870f2bc8f0 (&wdev->mtx){+.+.}-{3:3}, + at: cfg80211_leave+0x20/0x40 [cfg80211] +[ 682.859354] #4: ffffb6d0003336a8 (&pstapriv->sta_hash_lock){+.-.}-{2:2}, + at: rtw_free_assoc_resources+0x48/0x110 [r8723bs] +[ 682.859482] + stack backtrace: +[ 682.859491] CPU: 1 PID: 1770 Comm: modprobe Tainted: G + C OE 5.14.0-rc6+ #16 +[ 682.859507] Hardware name: LENOVO 80NR/Madrid, BIOS DACN25WW 08/20/2015 +[ 682.859517] Call Trace: +[ 682.859531] dump_stack_lvl+0x56/0x6f +[ 682.859551] check_noncircular+0xdb/0xf0 +[ 682.859579] __lock_acquire+0xfd9/0x1b50 +[ 682.859606] lock_acquire+0xb4/0x2c0 +[ 682.859623] ? rtw_free_stainfo+0x52/0x4a0 [r8723bs] +[ 682.859752] ? mark_held_locks+0x48/0x70 +[ 682.859769] ? rtw_free_stainfo+0x4a/0x4a0 [r8723bs] +[ 682.859898] _raw_spin_lock_bh+0x34/0x40 +[ 682.859914] ? rtw_free_stainfo+0x52/0x4a0 [r8723bs] +[ 682.860039] rtw_free_stainfo+0x52/0x4a0 [r8723bs] +[ 682.860171] rtw_free_assoc_resources+0x53/0x110 [r8723bs] +[ 682.860286] cfg80211_rtw_disconnect+0x4b/0x70 [r8723bs] +[ 682.860397] cfg80211_disconnect+0x12e/0x2f0 [cfg80211] +[ 682.860629] cfg80211_leave+0x2b/0x40 [cfg80211] +[ 682.860836] cfg80211_netdev_notifier_call+0xa9/0x560 [cfg80211] +[ 682.861048] ? __lock_acquire+0x4dc/0x1b50 +[ 682.861070] ? lock_is_held_type+0xa8/0x110 +[ 682.861089] ? lock_is_held_type+0xa8/0x110 +[ 682.861104] ? find_held_lock+0x2d/0x90 +[ 682.861120] ? packet_notifier+0x173/0x300 +[ 682.861141] ? lock_release+0xb3/0x250 +[ 682.861160] ? packet_notifier+0x192/0x300 +[ 682.861184] raw_notifier_call_chain+0x41/0x50 +[ 682.861205] __dev_close_many+0x62/0x100 +[ 682.861224] dev_close_many+0x7d/0x120 +[ 682.861245] unregister_netdevice_many+0x416/0x680 +[ 682.861264] ? find_held_lock+0x2d/0x90 +[ 682.861284] unregister_netdevice_queue+0xab/0xf0 +[ 682.861306] unregister_netdev+0x18/0x20 +[ 682.861325] rtw_unregister_netdevs+0x28/0x40 [r8723bs] +[ 682.861434] rtw_dev_remove+0x24/0xd0 [r8723bs] +[ 682.861542] sdio_bus_remove+0x31/0xd0 [mmc_core] +[ 682.861615] device_release_driver_internal+0xf7/0x1d0 +[ 682.861637] driver_detach+0x47/0x90 +[ 682.861656] bus_remove_driver+0x77/0xd0 +[ 682.861674] rtw_drv_halt+0xc/0x678 [r8723bs] +[ 682.861782] __x64_sys_delete_module+0x13f/0x250 +[ 682.861801] ? lockdep_hardirqs_on_prepare+0xf3/0x170 +[ 682.861817] ? syscall_enter_from_user_mode+0x20/0x70 +[ 682.861836] do_syscall_64+0x3a/0x80 +[ 682.861855] entry_SYSCALL_64_after_hwframe+0x44/0xae +[ 682.861873] RIP: 0033:0x7f6dbe85400b +[ 682.861890] Code: 73 01 c3 48 8b 0d 6d 1e 0c 00 f7 d8 64 89 +01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa +b8 b0 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 3d +1e 0c 00 f7 d8 64 89 01 48 +[ 682.861906] RSP: 002b:00007ffe7a82f538 EFLAGS: 00000206 ORIG_RAX: 00000000000000b0 +[ 682.861923] RAX: ffffffffffffffda RBX: 000055a64693bd20 RCX: 00007f6dbe85400b +[ 682.861935] RDX: 0000000000000000 RSI: 0000000000000800 RDI: 000055a64693bd88 +[ 682.861946] RBP: 000055a64693bd20 R08: 0000000000000000 R09: 0000000000000000 +[ 682.861957] R10: 00007f6dbe8c7ac0 R11: 0000000000000206 R12: 000055a64693bd88 +[ 682.861967] R13: 0000000000000000 R14: 000055a64693bd88 R15: 00007ffe7a831848 + +This happens because when we enqueue a frame for +transmission we do it under xmit_priv lock, then calling +rtw_get_stainfo (needed for enqueuing) takes sta_hash_lock +and this leads to the following lock dependency: + +xmit_priv->lock -> sta_hash_lock + +Turning off a connection will bring to call +rtw_free_assoc_resources which will set up +the inverse dependency: + +sta_hash_lock -> xmit_priv_lock + +This could lead to a deadlock as lockdep complains. + +Fix it by removing the xmit_priv->lock around +rtw_xmitframe_enqueue call inside rtl8723bs_hal_xmit +and put it in a smaller critical section inside +rtw_xmit_classifier, the only place where +xmit_priv data are actually accessed. + +Replace spin_{lock,unlock}_bh(pxmitpriv->lock) +in other tx paths leading to rtw_xmitframe_enqueue +call with spin_{lock,unlock}_bh(psta->sleep_q.lock) +- it's not clear why accessing a sleep_q was protected +by a spinlock on xmitpriv->lock. + +This way is avoided the same faulty lock nesting +order. + +Extra changes in v2 by Hans de Goede: +-Lift the taking of the struct __queue.lock spinlock out of + rtw_free_xmitframe_queue() into the callers this allows also + protecting a bunch of related state in rtw_free_stainfo(): +-Protect psta->sleepq_len on rtw_free_xmitframe_queue(&psta->sleep_q); +-Protect struct tx_servq.tx_pending and tx_servq.qcnt when + calling rtw_free_xmitframe_queue(&tx_servq.sta_pending) +-This also allows moving the spin_lock_bh(&pxmitpriv->lock); to below + the sleep_q free-ing code, avoiding another ABBA locking issue + +CC: Larry Finger +Co-developed-by: Hans de Goede +Tested-on: Lenovo Ideapad MiiX 300-10IBY +Signed-off-by: Fabio Aiuto +Signed-off-by: Hans de Goede +Link: https://lore.kernel.org/r/20210920145502.155454-1-hdegoede@redhat.com +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Sasha Levin +--- + drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 7 ++---- + drivers/staging/rtl8723bs/core/rtw_recv.c | 10 +++------ + drivers/staging/rtl8723bs/core/rtw_sta_mgt.c | 22 ++++++++++--------- + drivers/staging/rtl8723bs/core/rtw_xmit.c | 16 ++++++-------- + .../staging/rtl8723bs/hal/rtl8723bs_xmit.c | 2 -- + 5 files changed, 24 insertions(+), 33 deletions(-) + +diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +index 375d2a742dd2d..a1ae16ec69eb6 100644 +--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c ++++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +@@ -5919,7 +5919,6 @@ u8 chk_bmc_sleepq_hdl(struct adapter *padapter, unsigned char *pbuf) + struct sta_info *psta_bmc; + struct list_head *xmitframe_plist, *xmitframe_phead, *tmp; + struct xmit_frame *pxmitframe = NULL; +- struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct sta_priv *pstapriv = &padapter->stapriv; + + /* for BC/MC Frames */ +@@ -5930,8 +5929,7 @@ u8 chk_bmc_sleepq_hdl(struct adapter *padapter, unsigned char *pbuf) + if ((pstapriv->tim_bitmap&BIT(0)) && (psta_bmc->sleepq_len > 0)) { + msleep(10);/* 10ms, ATIM(HIQ) Windows */ + +- /* spin_lock_bh(&psta_bmc->sleep_q.lock); */ +- spin_lock_bh(&pxmitpriv->lock); ++ spin_lock_bh(&psta_bmc->sleep_q.lock); + + xmitframe_phead = get_list_head(&psta_bmc->sleep_q); + list_for_each_safe(xmitframe_plist, tmp, xmitframe_phead) { +@@ -5954,8 +5952,7 @@ u8 chk_bmc_sleepq_hdl(struct adapter *padapter, unsigned char *pbuf) + rtw_hal_xmitframe_enqueue(padapter, pxmitframe); + } + +- /* spin_unlock_bh(&psta_bmc->sleep_q.lock); */ +- spin_unlock_bh(&pxmitpriv->lock); ++ spin_unlock_bh(&psta_bmc->sleep_q.lock); + + /* check hi queue and bmc_sleepq */ + rtw_chk_hi_queue_cmd(padapter); +diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c +index 5b0a596eefb77..3564e2af5741b 100644 +--- a/drivers/staging/rtl8723bs/core/rtw_recv.c ++++ b/drivers/staging/rtl8723bs/core/rtw_recv.c +@@ -953,10 +953,8 @@ static signed int validate_recv_ctrl_frame(struct adapter *padapter, union recv_ + if ((psta->state&WIFI_SLEEP_STATE) && (pstapriv->sta_dz_bitmap&BIT(psta->aid))) { + struct list_head *xmitframe_plist, *xmitframe_phead; + struct xmit_frame *pxmitframe = NULL; +- struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + +- /* spin_lock_bh(&psta->sleep_q.lock); */ +- spin_lock_bh(&pxmitpriv->lock); ++ spin_lock_bh(&psta->sleep_q.lock); + + xmitframe_phead = get_list_head(&psta->sleep_q); + xmitframe_plist = get_next(xmitframe_phead); +@@ -987,12 +985,10 @@ static signed int validate_recv_ctrl_frame(struct adapter *padapter, union recv_ + update_beacon(padapter, WLAN_EID_TIM, NULL, true); + } + +- /* spin_unlock_bh(&psta->sleep_q.lock); */ +- spin_unlock_bh(&pxmitpriv->lock); ++ spin_unlock_bh(&psta->sleep_q.lock); + + } else { +- /* spin_unlock_bh(&psta->sleep_q.lock); */ +- spin_unlock_bh(&pxmitpriv->lock); ++ spin_unlock_bh(&psta->sleep_q.lock); + + if (pstapriv->tim_bitmap&BIT(psta->aid)) { + if (psta->sleepq_len == 0) { +diff --git a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c +index 67ca219f95bf8..c23d0c833ecf8 100644 +--- a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c ++++ b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c +@@ -289,46 +289,48 @@ u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta) + + /* list_del_init(&psta->wakeup_list); */ + +- spin_lock_bh(&pxmitpriv->lock); +- ++ spin_lock_bh(&psta->sleep_q.lock); + rtw_free_xmitframe_queue(pxmitpriv, &psta->sleep_q); + psta->sleepq_len = 0; ++ spin_unlock_bh(&psta->sleep_q.lock); ++ ++ spin_lock_bh(&pxmitpriv->lock); + + /* vo */ +- /* spin_lock_bh(&(pxmitpriv->vo_pending.lock)); */ ++ spin_lock_bh(&pstaxmitpriv->vo_q.sta_pending.lock); + rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->vo_q.sta_pending); + list_del_init(&(pstaxmitpriv->vo_q.tx_pending)); + phwxmit = pxmitpriv->hwxmits; + phwxmit->accnt -= pstaxmitpriv->vo_q.qcnt; + pstaxmitpriv->vo_q.qcnt = 0; +- /* spin_unlock_bh(&(pxmitpriv->vo_pending.lock)); */ ++ spin_unlock_bh(&pstaxmitpriv->vo_q.sta_pending.lock); + + /* vi */ +- /* spin_lock_bh(&(pxmitpriv->vi_pending.lock)); */ ++ spin_lock_bh(&pstaxmitpriv->vi_q.sta_pending.lock); + rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->vi_q.sta_pending); + list_del_init(&(pstaxmitpriv->vi_q.tx_pending)); + phwxmit = pxmitpriv->hwxmits+1; + phwxmit->accnt -= pstaxmitpriv->vi_q.qcnt; + pstaxmitpriv->vi_q.qcnt = 0; +- /* spin_unlock_bh(&(pxmitpriv->vi_pending.lock)); */ ++ spin_unlock_bh(&pstaxmitpriv->vi_q.sta_pending.lock); + + /* be */ +- /* spin_lock_bh(&(pxmitpriv->be_pending.lock)); */ ++ spin_lock_bh(&pstaxmitpriv->be_q.sta_pending.lock); + rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->be_q.sta_pending); + list_del_init(&(pstaxmitpriv->be_q.tx_pending)); + phwxmit = pxmitpriv->hwxmits+2; + phwxmit->accnt -= pstaxmitpriv->be_q.qcnt; + pstaxmitpriv->be_q.qcnt = 0; +- /* spin_unlock_bh(&(pxmitpriv->be_pending.lock)); */ ++ spin_unlock_bh(&pstaxmitpriv->be_q.sta_pending.lock); + + /* bk */ +- /* spin_lock_bh(&(pxmitpriv->bk_pending.lock)); */ ++ spin_lock_bh(&pstaxmitpriv->bk_q.sta_pending.lock); + rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->bk_q.sta_pending); + list_del_init(&(pstaxmitpriv->bk_q.tx_pending)); + phwxmit = pxmitpriv->hwxmits+3; + phwxmit->accnt -= pstaxmitpriv->bk_q.qcnt; + pstaxmitpriv->bk_q.qcnt = 0; +- /* spin_unlock_bh(&(pxmitpriv->bk_pending.lock)); */ ++ spin_unlock_bh(&pstaxmitpriv->bk_q.sta_pending.lock); + + spin_unlock_bh(&pxmitpriv->lock); + +diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c +index 79e4d7df1ef57..6b37b42ec2266 100644 +--- a/drivers/staging/rtl8723bs/core/rtw_xmit.c ++++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c +@@ -1723,15 +1723,12 @@ void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv, struct __queue *pfram + struct list_head *plist, *phead, *tmp; + struct xmit_frame *pxmitframe; + +- spin_lock_bh(&pframequeue->lock); +- + phead = get_list_head(pframequeue); + list_for_each_safe(plist, tmp, phead) { + pxmitframe = list_entry(plist, struct xmit_frame, list); + + rtw_free_xmitframe(pxmitpriv, pxmitframe); + } +- spin_unlock_bh(&pframequeue->lock); + } + + s32 rtw_xmitframe_enqueue(struct adapter *padapter, struct xmit_frame *pxmitframe) +@@ -1786,6 +1783,7 @@ s32 rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmitframe) + struct sta_info *psta; + struct tx_servq *ptxservq; + struct pkt_attrib *pattrib = &pxmitframe->attrib; ++ struct xmit_priv *xmit_priv = &padapter->xmitpriv; + struct hw_xmit *phwxmits = padapter->xmitpriv.hwxmits; + signed int res = _SUCCESS; + +@@ -1803,12 +1801,14 @@ s32 rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmitframe) + + ptxservq = rtw_get_sta_pending(padapter, psta, pattrib->priority, (u8 *)(&ac_index)); + ++ spin_lock_bh(&xmit_priv->lock); + if (list_empty(&ptxservq->tx_pending)) + list_add_tail(&ptxservq->tx_pending, get_list_head(phwxmits[ac_index].sta_queue)); + + list_add_tail(&pxmitframe->list, get_list_head(&ptxservq->sta_pending)); + ptxservq->qcnt++; + phwxmits[ac_index].accnt++; ++ spin_unlock_bh(&xmit_priv->lock); + + exit: + +@@ -2191,11 +2191,10 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) + struct list_head *xmitframe_plist, *xmitframe_phead, *tmp; + struct xmit_frame *pxmitframe = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; +- struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + + psta_bmc = rtw_get_bcmc_stainfo(padapter); + +- spin_lock_bh(&pxmitpriv->lock); ++ spin_lock_bh(&psta->sleep_q.lock); + + xmitframe_phead = get_list_head(&psta->sleep_q); + list_for_each_safe(xmitframe_plist, tmp, xmitframe_phead) { +@@ -2296,7 +2295,7 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) + + _exit: + +- spin_unlock_bh(&pxmitpriv->lock); ++ spin_unlock_bh(&psta->sleep_q.lock); + + if (update_mask) + update_beacon(padapter, WLAN_EID_TIM, NULL, true); +@@ -2308,9 +2307,8 @@ void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *pst + struct list_head *xmitframe_plist, *xmitframe_phead, *tmp; + struct xmit_frame *pxmitframe = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; +- struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + +- spin_lock_bh(&pxmitpriv->lock); ++ spin_lock_bh(&psta->sleep_q.lock); + + xmitframe_phead = get_list_head(&psta->sleep_q); + list_for_each_safe(xmitframe_plist, tmp, xmitframe_phead) { +@@ -2363,7 +2361,7 @@ void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *pst + } + } + +- spin_unlock_bh(&pxmitpriv->lock); ++ spin_unlock_bh(&psta->sleep_q.lock); + } + + void enqueue_pending_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) +diff --git a/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c b/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c +index 156d6aba18ca1..5f5c4719b5868 100644 +--- a/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c ++++ b/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c +@@ -507,9 +507,7 @@ s32 rtl8723bs_hal_xmit( + rtw_issue_addbareq_cmd(padapter, pxmitframe); + } + +- spin_lock_bh(&pxmitpriv->lock); + err = rtw_xmitframe_enqueue(padapter, pxmitframe); +- spin_unlock_bh(&pxmitpriv->lock); + if (err != _SUCCESS) { + rtw_free_xmitframe(pxmitpriv, pxmitframe); + +-- +2.33.0 + diff --git a/queue-5.15/staging-wfx-ensure-irq-is-ready-before-enabling-it.patch b/queue-5.15/staging-wfx-ensure-irq-is-ready-before-enabling-it.patch new file mode 100644 index 00000000000..b1577ed1f75 --- /dev/null +++ b/queue-5.15/staging-wfx-ensure-irq-is-ready-before-enabling-it.patch @@ -0,0 +1,125 @@ +From 8fd15b86f55b9597243ab746f3493625e2bead5d Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 13 Sep 2021 15:02:03 +0200 +Subject: staging: wfx: ensure IRQ is ready before enabling it +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Jérôme Pouiller + +[ Upstream commit 5e57c668dc097c6c27c973504706edec53f79281 ] + +Since commit 5561770f80b1 ("staging: wfx: repair external IRQ for +SDIO"), wfx_sdio_irq_subscribe() enforce the device to use IRQs. +However, there is currently a race in this code. An IRQ may happen +before the IRQ has been registered. + +The problem has observed during debug session when the device crashes +before the IRQ set up: + + [ 1.546] wfx-sdio mmc0:0001:1: started firmware 3.12.2 "WF200_ASIC_WFM_(Jenkins)_FW3.12.2" (API: 3.7, keyset: C0, caps: 0x00000002) + [ 2.559] wfx-sdio mmc0:0001:1: time out while polling control register + [ 3.565] wfx-sdio mmc0:0001:1: chip is abnormally long to answer + [ 6.563] wfx-sdio mmc0:0001:1: chip did not answer + [ 6.568] wfx-sdio mmc0:0001:1: hardware request CONFIGURATION (0x09) on vif 2 returned error -110 + [ 6.577] wfx-sdio mmc0:0001:1: PDS bytes 0 to 12: chip didn't reply (corrupted file?) + [ 6.585] Unable to handle kernel NULL pointer dereference at virtual address 00000000 + [ 6.592] pgd = c0004000 + [ 6.595] [00000000] *pgd=00000000 + [ 6.598] Internal error: Oops - BUG: 17 [#1] THUMB2 + [ 6.603] Modules linked in: + [ 6.606] CPU: 0 PID: 23 Comm: kworker/u2:1 Not tainted 3.18.19 #78 + [ 6.612] Workqueue: kmmcd mmc_rescan + [ 6.616] task: c176d100 ti: c0e50000 task.ti: c0e50000 + [ 6.621] PC is at wake_up_process+0xa/0x14 + [ 6.625] LR is at sdio_irq+0x61/0x250 + [ 6.629] pc : [] lr : [] psr: 600001b3 + [ 6.629] sp : c0e51bd8 ip : c0e51cc8 fp : 00000001 + [ 6.640] r10: 00000003 r9 : 00000000 r8 : c0003c34 + [ 6.644] r7 : c0e51bd8 r6 : c0003c30 r5 : 00000001 r4 : c0e78c00 + [ 6.651] r3 : 00000000 r2 : 00000000 r1 : 00000003 r0 : 00000000 + [ 6.657] Flags: nZCv IRQs off FIQs on Mode SVC_32 ISA Thumb Segment kernel + [ 6.664] Control: 50c53c7d Table: 11fd8059 DAC: 00000015 + [ 6.670] Process kworker/u2:1 (pid: 23, stack limit = 0xc0e501b0) + [ 6.676] Stack: (0xc0e51bd8 to 0xc0e52000) + [...] + [ 6.949] [] (wake_up_process) from [] (sdio_irq+0x61/0x250) + [ 6.956] [] (sdio_irq) from [] (handle_irq_event_percpu+0x17/0x92) + [ 6.964] [] (handle_irq_event_percpu) from [] (handle_irq_event+0x1b/0x24) + [ 6.973] [] (handle_irq_event) from [] (handle_level_irq+0x5d/0x76) + [ 6.981] [] (handle_level_irq) from [] (generic_handle_irq+0x13/0x1c) + [ 6.989] [] (generic_handle_irq) from [] (__handle_domain_irq+0x31/0x48) + [ 6.997] [] (__handle_domain_irq) from [] (ov_handle_irq+0x31/0xe0) + [ 7.005] [] (ov_handle_irq) from [] (__irq_svc+0x3b/0x5c) + [ 7.013] Exception stack(0xc0e51c68 to 0xc0e51cb0) + [...] + [ 7.038] [] (__irq_svc) from [] (wait_for_common+0x9e/0xc4) + [ 7.045] [] (wait_for_common) from [] (mmc_wait_for_req+0x4b/0xdc) + [ 7.053] [] (mmc_wait_for_req) from [] (mmc_wait_for_cmd+0x2f/0x34) + [ 7.061] [] (mmc_wait_for_cmd) from [] (mmc_io_rw_direct_host+0x71/0xac) + [ 7.070] [] (mmc_io_rw_direct_host) from [] (sdio_claim_irq+0x6b/0x116) + [ 7.078] [] (sdio_claim_irq) from [] (wfx_sdio_irq_subscribe+0x19/0x94) + [ 7.086] [] (wfx_sdio_irq_subscribe) from [] (wfx_probe+0x189/0x2ac) + [ 7.095] [] (wfx_probe) from [] (wfx_sdio_probe+0x8f/0xcc) + [ 7.102] [] (wfx_sdio_probe) from [] (sdio_bus_probe+0x5f/0xa8) + [ 7.109] [] (sdio_bus_probe) from [] (driver_probe_device+0x59/0x134) + [ 7.118] [] (driver_probe_device) from [] (bus_for_each_drv+0x3f/0x4a) + [ 7.126] [] (bus_for_each_drv) from [] (device_attach+0x3b/0x52) + [ 7.134] [] (device_attach) from [] (bus_probe_device+0x17/0x4c) + [ 7.141] [] (bus_probe_device) from [] (device_add+0x2c5/0x334) + [ 7.149] [] (device_add) from [] (sdio_add_func+0x23/0x44) + [ 7.156] [] (sdio_add_func) from [] (mmc_attach_sdio+0x187/0x1ec) + [ 7.164] [] (mmc_attach_sdio) from [] (mmc_rescan+0x18d/0x1fc) + [ 7.172] [] (mmc_rescan) from [] (process_one_work+0xd7/0x170) + [ 7.179] [] (process_one_work) from [] (worker_thread+0x103/0x1bc) + [ 7.187] [] (worker_thread) from [] (kthread+0x7d/0x90) + [ 7.194] [] (kthread) from [] (ret_from_fork+0x11/0x30) + [ 7.201] Code: 2103 b580 2200 af00 (681b) 46bd + [ 7.206] ---[ end trace 3ab50aced42eedb4 ]--- + +Signed-off-by: Jérôme Pouiller +Link: https://lore.kernel.org/r/20210913130203.1903622-33-Jerome.Pouiller@silabs.com +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Sasha Levin +--- + drivers/staging/wfx/bus_sdio.c | 17 ++++++++++------- + 1 file changed, 10 insertions(+), 7 deletions(-) + +diff --git a/drivers/staging/wfx/bus_sdio.c b/drivers/staging/wfx/bus_sdio.c +index e06d7e1ebe9c3..61b8cc05f2935 100644 +--- a/drivers/staging/wfx/bus_sdio.c ++++ b/drivers/staging/wfx/bus_sdio.c +@@ -120,19 +120,22 @@ static int wfx_sdio_irq_subscribe(void *priv) + return ret; + } + ++ flags = irq_get_trigger_type(bus->of_irq); ++ if (!flags) ++ flags = IRQF_TRIGGER_HIGH; ++ flags |= IRQF_ONESHOT; ++ ret = devm_request_threaded_irq(&bus->func->dev, bus->of_irq, NULL, ++ wfx_sdio_irq_handler_ext, flags, ++ "wfx", bus); ++ if (ret) ++ return ret; + sdio_claim_host(bus->func); + cccr = sdio_f0_readb(bus->func, SDIO_CCCR_IENx, NULL); + cccr |= BIT(0); + cccr |= BIT(bus->func->num); + sdio_f0_writeb(bus->func, cccr, SDIO_CCCR_IENx, NULL); + sdio_release_host(bus->func); +- flags = irq_get_trigger_type(bus->of_irq); +- if (!flags) +- flags = IRQF_TRIGGER_HIGH; +- flags |= IRQF_ONESHOT; +- return devm_request_threaded_irq(&bus->func->dev, bus->of_irq, NULL, +- wfx_sdio_irq_handler_ext, flags, +- "wfx", bus); ++ return 0; + } + + static int wfx_sdio_irq_unsubscribe(void *priv) +-- +2.33.0 + diff --git a/queue-5.15/tcp-fix-uninitialized-access-in-skb-frags-array-for-.patch b/queue-5.15/tcp-fix-uninitialized-access-in-skb-frags-array-for-.patch new file mode 100644 index 00000000000..0ceeccaa19d --- /dev/null +++ b/queue-5.15/tcp-fix-uninitialized-access-in-skb-frags-array-for-.patch @@ -0,0 +1,80 @@ +From 2aabdfaa353e34caa8f9d8e6f0b8cce3b443b1d2 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 11 Nov 2021 15:52:15 -0800 +Subject: tcp: Fix uninitialized access in skb frags array for Rx 0cp. + +From: Arjun Roy + +[ Upstream commit 70701b83e208767f2720d8cd3e6a62cddafb3a30 ] + +TCP Receive zerocopy iterates through the SKB queue via +tcp_recv_skb(), acquiring a pointer to an SKB and an offset within +that SKB to read from. From there, it iterates the SKB frags array to +determine which offset to start remapping pages from. + +However, this is built on the assumption that the offset read so far +within the SKB is smaller than the SKB length. If this assumption is +violated, we can attempt to read an invalid frags array element, which +would cause a fault. + +tcp_recv_skb() can cause such an SKB to be returned when the TCP FIN +flag is set. Therefore, we must guard against this occurrence inside +skb_advance_frag(). + +One way that we can reproduce this error follows: +1) In a receiver program, call getsockopt(TCP_ZEROCOPY_RECEIVE) with: +char some_array[32 * 1024]; +struct tcp_zerocopy_receive zc = { + .copybuf_address = (__u64) &some_array[0], + .copybuf_len = 32 * 1024, +}; + +2) In a sender program, after a TCP handshake, send the following +sequence of packets: + i) Seq = [X, X+4000] + ii) Seq = [X+4000, X+5000] + iii) Seq = [X+4000, X+5000], Flags = FIN | URG, urgptr=1000 + +(This can happen without URG, if we have a signal pending, but URG is +a convenient way to reproduce the behaviour). + +In this case, the following event sequence will occur on the receiver: + +tcp_zerocopy_receive(): +-> receive_fallback_to_copy() // copybuf_len >= inq +-> tcp_recvmsg_locked() // reads 5000 bytes, then breaks due to URG +-> tcp_recv_skb() // yields skb with skb->len == offset +-> tcp_zerocopy_set_hint_for_skb() +-> skb_advance_to_frag() // will returns a frags ptr. >= nr_frags +-> find_next_mappable_frag() // will dereference this bad frags ptr. + +With this patch, skb_advance_to_frag() will no longer return an +invalid frags pointer, and will return NULL instead, fixing the issue. + +Signed-off-by: Arjun Roy +Signed-off-by: Eric Dumazet +Fixes: 05255b823a61 ("tcp: add TCP_ZEROCOPY_RECEIVE support for zerocopy receive") +Link: https://lore.kernel.org/r/20211111235215.2605384-1-arjunroy.kdev@gmail.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Sasha Levin +--- + net/ipv4/tcp.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c +index 8affba5909bdf..844c6e5a82891 100644 +--- a/net/ipv4/tcp.c ++++ b/net/ipv4/tcp.c +@@ -1776,6 +1776,9 @@ static skb_frag_t *skb_advance_to_frag(struct sk_buff *skb, u32 offset_skb, + { + skb_frag_t *frag; + ++ if (unlikely(offset_skb >= skb->len)) ++ return NULL; ++ + offset_skb -= skb_headlen(skb); + if ((int)offset_skb < 0 || skb_has_frag_list(skb)) + return NULL; +-- +2.33.0 + diff --git a/queue-5.15/tipc-only-accept-encrypted-msg_crypto-msgs.patch b/queue-5.15/tipc-only-accept-encrypted-msg_crypto-msgs.patch new file mode 100644 index 00000000000..91b5b4121aa --- /dev/null +++ b/queue-5.15/tipc-only-accept-encrypted-msg_crypto-msgs.patch @@ -0,0 +1,52 @@ +From c69b3b57db09c93d7c3e549d5e80b3fc902bd28a Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 15 Nov 2021 07:45:24 -0500 +Subject: tipc: only accept encrypted MSG_CRYPTO msgs + +From: Xin Long + +[ Upstream commit 271351d255b09e39c7f6437738cba595f9b235be ] + +The MSG_CRYPTO msgs are always encrypted and sent to other nodes +for keys' deployment. But when receiving in peers, if those nodes +do not validate it and make sure it's encrypted, one could craft +a malicious MSG_CRYPTO msg to deploy its key with no need to know +other nodes' keys. + +This patch is to do that by checking TIPC_SKB_CB(skb)->decrypted +and discard it if this packet never got decrypted. + +Note that this is also a supplementary fix to CVE-2021-43267 that +can be triggered by an unencrypted malicious MSG_CRYPTO msg. + +Fixes: 1ef6f7c9390f ("tipc: add automatic session key exchange") +Acked-by: Ying Xue +Acked-by: Jon Maloy +Signed-off-by: Xin Long +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + net/tipc/link.c | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/net/tipc/link.c b/net/tipc/link.c +index 1b7a487c88419..09ae8448f394f 100644 +--- a/net/tipc/link.c ++++ b/net/tipc/link.c +@@ -1298,8 +1298,11 @@ static bool tipc_data_input(struct tipc_link *l, struct sk_buff *skb, + return false; + #ifdef CONFIG_TIPC_CRYPTO + case MSG_CRYPTO: +- tipc_crypto_msg_rcv(l->net, skb); +- return true; ++ if (TIPC_SKB_CB(skb)->decrypted) { ++ tipc_crypto_msg_rcv(l->net, skb); ++ return true; ++ } ++ fallthrough; + #endif + default: + pr_warn("Dropping received illegal msg type\n"); +-- +2.33.0 + diff --git a/queue-5.15/tools-build-fix-removal-of-feature-sync-compare-and-.patch b/queue-5.15/tools-build-fix-removal-of-feature-sync-compare-and-.patch new file mode 100644 index 00000000000..b0daafe2ae4 --- /dev/null +++ b/queue-5.15/tools-build-fix-removal-of-feature-sync-compare-and-.patch @@ -0,0 +1,62 @@ +From faa4286bc2d03c6a9e7f2b34e36279416520333d Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 17 Nov 2021 14:29:31 -0300 +Subject: tools build: Fix removal of feature-sync-compare-and-swap feature + detection +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Arnaldo Carvalho de Melo + +[ Upstream commit e8c04ea0fef5731dbcaabac86d65254c227aedf4 ] + +The patch removing the feature-sync-compare-and-swap feature detection +didn't remove the call to main_test_sync_compare_and_swap(), making the +'test-all' case fail an all the feature tests to be performed +individually: + + $ cat /tmp/build/perf/feature/test-all.make.output + In file included from test-all.c:18: + test-libpython-version.c:5:10: error: #error + 5 | #error + | ^~~~~ + test-all.c: In function ‘main’: + test-all.c:203:9: error: implicit declaration of function ‘main_test_sync_compare_and_swap’ [-Werror=implicit-function-declaration] + 203 | main_test_sync_compare_and_swap(argc, argv); + | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + cc1: all warnings being treated as errors + $ + +Fix it, now to figure out what is that test-libpython-version.c +problem... + +Fixes: 60fa754b2a5a4e0c ("tools: Remove feature-sync-compare-and-swap feature detection") +Cc: Jiri Olsa +Cc: Leo Yan +Cc: Mark Rutland +Cc: Mathieu Poirier +Cc: Mike Leach +Cc: Namhyung Kim +Link: https://lore.kernel.org/lkml/YZU9Fe0sgkHSXeC2@kernel.org +Signed-off-by: Arnaldo Carvalho de Melo +Signed-off-by: Sasha Levin +--- + tools/build/feature/test-all.c | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c +index 9204395272912..0b243ce842be3 100644 +--- a/tools/build/feature/test-all.c ++++ b/tools/build/feature/test-all.c +@@ -200,7 +200,6 @@ int main(int argc, char *argv[]) + main_test_timerfd(); + main_test_stackprotector_all(); + main_test_libdw_dwarf_unwind(); +- main_test_sync_compare_and_swap(argc, argv); + main_test_zlib(); + main_test_pthread_attr_setaffinity_np(); + main_test_pthread_barrier(); +-- +2.33.0 + diff --git a/queue-5.15/tracing-add-length-protection-to-histogram-string-co.patch b/queue-5.15/tracing-add-length-protection-to-histogram-string-co.patch new file mode 100644 index 00000000000..c016e0f079e --- /dev/null +++ b/queue-5.15/tracing-add-length-protection-to-histogram-string-co.patch @@ -0,0 +1,87 @@ +From fbe2236476b3402415d04fa1114f9fc91aa5e9a0 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 14 Nov 2021 13:28:34 -0500 +Subject: tracing: Add length protection to histogram string copies + +From: Steven Rostedt (VMware) + +[ Upstream commit 938aa33f14657c9ed9deea348b7d6f14b6d69cb7 ] + +The string copies to the histogram storage has a max size of 256 bytes +(defined by MAX_FILTER_STR_VAL). Only the string size of the event field +needs to be copied to the event storage, but no more than what is in the +event storage. Although nothing should be bigger than 256 bytes, there's +no protection against overwriting of the storage if one day there is. + +Copy no more than the destination size, and enforce it. + +Also had to turn MAX_FILTER_STR_VAL into an unsigned int, to keep the +min() comparison of the string sizes of comparable types. + +Link: https://lore.kernel.org/all/CAHk-=wjREUihCGrtRBwfX47y_KrLCGjiq3t6QtoNJpmVrAEb1w@mail.gmail.com/ +Link: https://lkml.kernel.org/r/20211114132834.183429a4@rorschach.local.home + +Cc: Ingo Molnar +Cc: Andrew Morton +Cc: Tom Zanussi +Reported-by: Linus Torvalds +Reviewed-by: Masami Hiramatsu +Fixes: 63f84ae6b82b ("tracing/histogram: Do not copy the fixed-size char array field over the field size") +Signed-off-by: Steven Rostedt (VMware) +Signed-off-by: Sasha Levin +--- + include/linux/trace_events.h | 2 +- + kernel/trace/trace_events_hist.c | 9 +++++++-- + 2 files changed, 8 insertions(+), 3 deletions(-) + +diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h +index 3e475eeb5a995..57113190448c6 100644 +--- a/include/linux/trace_events.h ++++ b/include/linux/trace_events.h +@@ -673,7 +673,7 @@ struct trace_event_file { + + #define PERF_MAX_TRACE_SIZE 2048 + +-#define MAX_FILTER_STR_VAL 256 /* Should handle KSYM_SYMBOL_LEN */ ++#define MAX_FILTER_STR_VAL 256U /* Should handle KSYM_SYMBOL_LEN */ + + enum event_trigger_type { + ETT_NONE = (0), +diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c +index de37664ef0476..d860351b9dea6 100644 +--- a/kernel/trace/trace_events_hist.c ++++ b/kernel/trace/trace_events_hist.c +@@ -2691,8 +2691,10 @@ static inline void __update_field_vars(struct tracing_map_elt *elt, + if (val->flags & HIST_FIELD_FL_STRING) { + char *str = elt_data->field_var_str[j++]; + char *val_str = (char *)(uintptr_t)var_val; ++ unsigned int size; + +- strscpy(str, val_str, val->size); ++ size = min(val->size, STR_VAR_LEN_MAX); ++ strscpy(str, val_str, size); + var_val = (u64)(uintptr_t)str; + } + tracing_map_set_var(elt, var_idx, var_val); +@@ -4579,6 +4581,7 @@ static void hist_trigger_elt_update(struct hist_trigger_data *hist_data, + if (hist_field->flags & HIST_FIELD_FL_STRING) { + unsigned int str_start, var_str_idx, idx; + char *str, *val_str; ++ unsigned int size; + + str_start = hist_data->n_field_var_str + + hist_data->n_save_var_str; +@@ -4587,7 +4590,9 @@ static void hist_trigger_elt_update(struct hist_trigger_data *hist_data, + + str = elt_data->field_var_str[idx]; + val_str = (char *)(uintptr_t)hist_val; +- strscpy(str, val_str, hist_field->size); ++ ++ size = min(hist_field->size, STR_VAR_LEN_MAX); ++ strscpy(str, val_str, size); + + hist_val = (u64)(uintptr_t)str; + } +-- +2.33.0 + diff --git a/queue-5.15/tracing-histogram-do-not-copy-the-fixed-size-char-ar.patch b/queue-5.15/tracing-histogram-do-not-copy-the-fixed-size-char-ar.patch new file mode 100644 index 00000000000..154e1a4865e --- /dev/null +++ b/queue-5.15/tracing-histogram-do-not-copy-the-fixed-size-char-ar.patch @@ -0,0 +1,69 @@ +From e69a07ab58bb085d8a257a68e862993e00cd5c1e Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 13 Nov 2021 01:02:08 +0900 +Subject: tracing/histogram: Do not copy the fixed-size char array field over + the field size + +From: Masami Hiramatsu + +[ Upstream commit 63f84ae6b82bb4dff672f76f30c6fd7b9d3766bc ] + +Do not copy the fixed-size char array field of the events over +the field size. The histogram treats char array as a string and +there are 2 types of char array in the event, fixed-size and +dynamic string. The dynamic string (__data_loc) field must be +null terminated, but the fixed-size char array field may not +be null terminated (not a string, but just a data). +In that case, histogram can copy the data after the field. +This uses the original field size for fixed-size char array +field to restrict the histogram not to access over the original +field size. + +Link: https://lkml.kernel.org/r/163673292822.195747.3696966210526410250.stgit@devnote2 + +Fixes: 02205a6752f2 (tracing: Add support for 'field variables') +Signed-off-by: Masami Hiramatsu +Signed-off-by: Steven Rostedt (VMware) +Signed-off-by: Sasha Levin +--- + kernel/trace/trace_events_hist.c | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c +index f01e442716e2f..de37664ef0476 100644 +--- a/kernel/trace/trace_events_hist.c ++++ b/kernel/trace/trace_events_hist.c +@@ -1733,9 +1733,10 @@ static struct hist_field *create_hist_field(struct hist_trigger_data *hist_data, + if (!hist_field->type) + goto free; + +- if (field->filter_type == FILTER_STATIC_STRING) ++ if (field->filter_type == FILTER_STATIC_STRING) { + hist_field->fn = hist_field_string; +- else if (field->filter_type == FILTER_DYN_STRING) ++ hist_field->size = field->size; ++ } else if (field->filter_type == FILTER_DYN_STRING) + hist_field->fn = hist_field_dynstring; + else + hist_field->fn = hist_field_pstring; +@@ -2691,7 +2692,7 @@ static inline void __update_field_vars(struct tracing_map_elt *elt, + char *str = elt_data->field_var_str[j++]; + char *val_str = (char *)(uintptr_t)var_val; + +- strscpy(str, val_str, STR_VAR_LEN_MAX); ++ strscpy(str, val_str, val->size); + var_val = (u64)(uintptr_t)str; + } + tracing_map_set_var(elt, var_idx, var_val); +@@ -4586,7 +4587,7 @@ static void hist_trigger_elt_update(struct hist_trigger_data *hist_data, + + str = elt_data->field_var_str[idx]; + val_str = (char *)(uintptr_t)hist_val; +- strscpy(str, val_str, STR_VAR_LEN_MAX); ++ strscpy(str, val_str, hist_field->size); + + hist_val = (u64)(uintptr_t)str; + } +-- +2.33.0 + diff --git a/queue-5.15/tty-tty_buffer-fix-the-softlockup-issue-in-flush_to_.patch b/queue-5.15/tty-tty_buffer-fix-the-softlockup-issue-in-flush_to_.patch new file mode 100644 index 00000000000..837c5d925bd --- /dev/null +++ b/queue-5.15/tty-tty_buffer-fix-the-softlockup-issue-in-flush_to_.patch @@ -0,0 +1,69 @@ +From 96d333af4936015c3948a73025aadca46c8a3ac1 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 11 Oct 2021 22:08:24 +0800 +Subject: tty: tty_buffer: Fix the softlockup issue in flush_to_ldisc + +From: Guanghui Feng + +[ Upstream commit 3968ddcf05fb4b9409cd1859feb06a5b0550a1c1 ] + +When running ltp testcase(ltp/testcases/kernel/pty/pty04.c) with arm64, there is a soft lockup, +which look like this one: + + Workqueue: events_unbound flush_to_ldisc + Call trace: + dump_backtrace+0x0/0x1ec + show_stack+0x24/0x30 + dump_stack+0xd0/0x128 + panic+0x15c/0x374 + watchdog_timer_fn+0x2b8/0x304 + __run_hrtimer+0x88/0x2c0 + __hrtimer_run_queues+0xa4/0x120 + hrtimer_interrupt+0xfc/0x270 + arch_timer_handler_phys+0x40/0x50 + handle_percpu_devid_irq+0x94/0x220 + __handle_domain_irq+0x88/0xf0 + gic_handle_irq+0x84/0xfc + el1_irq+0xc8/0x180 + slip_unesc+0x80/0x214 [slip] + tty_ldisc_receive_buf+0x64/0x80 + tty_port_default_receive_buf+0x50/0x90 + flush_to_ldisc+0xbc/0x110 + process_one_work+0x1d4/0x4b0 + worker_thread+0x180/0x430 + kthread+0x11c/0x120 + +In the testcase pty04, The first process call the write syscall to send +data to the pty master. At the same time, the workqueue will do the +flush_to_ldisc to pop data in a loop until there is no more data left. +When the sender and workqueue running in different core, the sender sends +data fastly in full time which will result in workqueue doing work in loop +for a long time and occuring softlockup in flush_to_ldisc with kernel +configured without preempt. So I add need_resched check and cond_resched +in the flush_to_ldisc loop to avoid it. + +Signed-off-by: Guanghui Feng +Link: https://lore.kernel.org/r/1633961304-24759-1-git-send-email-guanghuifeng@linux.alibaba.com +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Sasha Levin +--- + drivers/tty/tty_buffer.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c +index 635d0af229b72..6c7e65b1d9a1c 100644 +--- a/drivers/tty/tty_buffer.c ++++ b/drivers/tty/tty_buffer.c +@@ -544,6 +544,9 @@ static void flush_to_ldisc(struct work_struct *work) + if (!count) + break; + head->read += count; ++ ++ if (need_resched()) ++ cond_resched(); + } + + mutex_unlock(&buf->lock); +-- +2.33.0 + diff --git a/queue-5.15/udp-validate-checksum-in-udp_read_sock.patch b/queue-5.15/udp-validate-checksum-in-udp_read_sock.patch new file mode 100644 index 00000000000..c796c2172ff --- /dev/null +++ b/queue-5.15/udp-validate-checksum-in-udp_read_sock.patch @@ -0,0 +1,49 @@ +From 631c42a4d99882ce396153f2343a77d6aa0738e0 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 14 Nov 2021 20:40:06 -0800 +Subject: udp: Validate checksum in udp_read_sock() + +From: Cong Wang + +[ Upstream commit 099f896f498a2b26d84f4ddae039b2c542c18b48 ] + +It turns out the skb's in sock receive queue could have bad checksums, as +both ->poll() and ->recvmsg() validate checksums. We have to do the same +for ->read_sock() path too before they are redirected in sockmap. + +Fixes: d7f571188ecf ("udp: Implement ->read_sock() for sockmap") +Reported-by: Daniel Borkmann +Signed-off-by: Cong Wang +Signed-off-by: Daniel Borkmann +Acked-by: John Fastabend +Link: https://lore.kernel.org/bpf/20211115044006.26068-1-xiyou.wangcong@gmail.com +Signed-off-by: Sasha Levin +--- + net/ipv4/udp.c | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c +index 2fffcf2b54f3f..2ce3fca545d37 100644 +--- a/net/ipv4/udp.c ++++ b/net/ipv4/udp.c +@@ -1808,6 +1808,17 @@ int udp_read_sock(struct sock *sk, read_descriptor_t *desc, + skb = skb_recv_udp(sk, 0, 1, &err); + if (!skb) + return err; ++ ++ if (udp_lib_checksum_complete(skb)) { ++ __UDP_INC_STATS(sock_net(sk), UDP_MIB_CSUMERRORS, ++ IS_UDPLITE(sk)); ++ __UDP_INC_STATS(sock_net(sk), UDP_MIB_INERRORS, ++ IS_UDPLITE(sk)); ++ atomic_inc(&sk->sk_drops); ++ kfree_skb(skb); ++ continue; ++ } ++ + used = recv_actor(desc, skb, 0, skb->len); + if (used <= 0) { + if (!copied) +-- +2.33.0 + diff --git a/queue-5.15/usb-host-ohci-tmio-check-return-value-after-calling-.patch b/queue-5.15/usb-host-ohci-tmio-check-return-value-after-calling-.patch new file mode 100644 index 00000000000..26a33ba0716 --- /dev/null +++ b/queue-5.15/usb-host-ohci-tmio-check-return-value-after-calling-.patch @@ -0,0 +1,38 @@ +From d5bbedfa6a6263ca2af01b0ee244872987e3f0c2 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 11 Oct 2021 21:49:20 +0800 +Subject: usb: host: ohci-tmio: check return value after calling + platform_get_resource() + +From: Yang Yingliang + +[ Upstream commit 9eff2b2e59fda25051ab36cd1cb5014661df657b ] + +It will cause null-ptr-deref if platform_get_resource() returns NULL, +we need check the return value. + +Acked-by: Alan Stern +Signed-off-by: Yang Yingliang +Link: https://lore.kernel.org/r/20211011134920.118477-1-yangyingliang@huawei.com +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Sasha Levin +--- + drivers/usb/host/ohci-tmio.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/usb/host/ohci-tmio.c b/drivers/usb/host/ohci-tmio.c +index 08ec2ab0d95a5..3f3d62dc06746 100644 +--- a/drivers/usb/host/ohci-tmio.c ++++ b/drivers/usb/host/ohci-tmio.c +@@ -199,7 +199,7 @@ static int ohci_hcd_tmio_drv_probe(struct platform_device *dev) + if (usb_disabled()) + return -ENODEV; + +- if (!cell) ++ if (!cell || !regs || !config || !sram) + return -EINVAL; + + if (irq < 0) +-- +2.33.0 + diff --git a/queue-5.15/usb-musb-tusb6010-check-return-value-after-calling-p.patch b/queue-5.15/usb-musb-tusb6010-check-return-value-after-calling-p.patch new file mode 100644 index 00000000000..c3057431f44 --- /dev/null +++ b/queue-5.15/usb-musb-tusb6010-check-return-value-after-calling-p.patch @@ -0,0 +1,40 @@ +From 453e4baa16a3b453b9a832f6ea980f132c50a2ca Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 15 Sep 2021 11:49:25 +0800 +Subject: usb: musb: tusb6010: check return value after calling + platform_get_resource() + +From: Yang Yingliang + +[ Upstream commit 14651496a3de6807a17c310f63c894ea0c5d858e ] + +It will cause null-ptr-deref if platform_get_resource() returns NULL, +we need check the return value. + +Signed-off-by: Yang Yingliang +Link: https://lore.kernel.org/r/20210915034925.2399823-1-yangyingliang@huawei.com +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Sasha Levin +--- + drivers/usb/musb/tusb6010.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c +index c968ecda42aa8..7ed4cc348d993 100644 +--- a/drivers/usb/musb/tusb6010.c ++++ b/drivers/usb/musb/tusb6010.c +@@ -1104,6 +1104,11 @@ static int tusb_musb_init(struct musb *musb) + + /* dma address for async dma */ + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); ++ if (!mem) { ++ pr_debug("no async dma resource?\n"); ++ ret = -ENODEV; ++ goto done; ++ } + musb->async = mem->start; + + /* dma address for sync dma */ +-- +2.33.0 + diff --git a/queue-5.15/usb-typec-tipd-remove-warn_on-in-tps6598x_block_read.patch b/queue-5.15/usb-typec-tipd-remove-warn_on-in-tps6598x_block_read.patch new file mode 100644 index 00000000000..b7a61a868bb --- /dev/null +++ b/queue-5.15/usb-typec-tipd-remove-warn_on-in-tps6598x_block_read.patch @@ -0,0 +1,38 @@ +From 96bacc3d809451b3b33c3213ac13693b2fd8461f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 14 Sep 2021 16:02:35 +0200 +Subject: usb: typec: tipd: Remove WARN_ON in tps6598x_block_read + +From: Sven Peter + +[ Upstream commit b7a0a63f3fed57d413bb857de164ea9c3984bc4e ] + +Calling tps6598x_block_read with a higher than allowed len can be +handled by just returning an error. There's no need to crash systems +with panic-on-warn enabled. + +Reviewed-by: Heikki Krogerus +Signed-off-by: Sven Peter +Link: https://lore.kernel.org/r/20210914140235.65955-3-sven@svenpeter.dev +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Sasha Levin +--- + drivers/usb/typec/tipd/core.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c +index ea4cc0a6e40cc..97f50f301f13b 100644 +--- a/drivers/usb/typec/tipd/core.c ++++ b/drivers/usb/typec/tipd/core.c +@@ -117,7 +117,7 @@ tps6598x_block_read(struct tps6598x *tps, u8 reg, void *val, size_t len) + u8 data[TPS_MAX_LEN + 1]; + int ret; + +- if (WARN_ON(len + 1 > sizeof(data))) ++ if (len + 1 > sizeof(data)) + return -EINVAL; + + if (!tps->i2c_protocol) +-- +2.33.0 +