From b6b153c7547cd9f2bbdfbe0c5878bc14215c7a80 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 21 Jul 2023 08:36:17 +0200 Subject: [PATCH] 6.4-stable patches added patches: arm64-dts-mt7986-use-size-of-reserved-partition-for-bl2.patch arm64-dts-ti-k3-j721s2-fix-wkup-pinmux-range.patch dm-integrity-reduce-vmalloc-space-footprint-on-32-bit-architectures.patch ext2-dax-fix-ext2_setsize-when-len-is-page-aligned.patch ext4-avoid-updating-the-superblock-on-a-r-o-mount-if-not-needed.patch ext4-fix-reusing-stale-buffer-heads-from-last-failed-mounting.patch ext4-fix-to-check-return-value-of-freeze_bdev-in-ext4_shutdown.patch ext4-fix-wrong-unit-use-in-ext4_mb_clear_bb.patch ext4-fix-wrong-unit-use-in-ext4_mb_new_blocks.patch ext4-get-block-from-bh-in-ext4_free_blocks-for-fast-commit-replay.patch ext4-only-update-i_reserved_data_blocks-on-successful-block-allocation.patch ext4-turn-quotas-off-if-mount-failed-after-enabling-quotas.patch fs-dlm-revert-check-required-context-while-close.patch hwrng-imx-rngc-fix-the-timeout-for-init-and-self-check.patch jfs-jfs_dmap-validate-db_l2nbperpage-while-mounting.patch mm-mmap-fix-error-return-in-do_vmi_align_munmap.patch pci-acpiphp-reassign-resources-on-bridge-if-necessary.patch pci-add-function-1-dma-alias-quirk-for-marvell-88se9235.patch pci-epf-test-fix-dma-transfer-completion-detection.patch pci-epf-test-fix-dma-transfer-completion-initialization.patch pci-pm-avoid-putting-elopos-e2-s2-h2-pcie-ports-in-d3cold.patch pci-qcom-disable-write-access-to-read-only-registers-for-ip-v2.3.3.patch pci-release-resource-invalidated-by-coalescing.patch pci-rockchip-add-poll-and-timeout-to-wait-for-phy-plls-to-be-locked.patch pci-rockchip-assert-pci-configuration-enable-bit-after-probe.patch pci-rockchip-fix-legacy-irq-generation-for-rk3399-pcie-endpoint-core.patch pci-rockchip-set-address-alignment-for-endpoint-mode.patch pci-rockchip-use-u32-variable-to-access-32-bit-registers.patch pci-rockchip-write-pci-device-id-to-correct-register.patch s390-zcrypt-do-not-retry-administrative-requests.patch scsi-mpi3mr-propagate-sense-data-for-admin-queue-scsi-i-o.patch soc-qcom-mdt_loader-fix-unconditional-call-to-scm_pas_mem_setup.patch --- ...e-size-of-reserved-partition-for-bl2.patch | 55 ++++ ...s-ti-k3-j721s2-fix-wkup-pinmux-range.patch | 267 ++++++++++++++++++ ...ce-footprint-on-32-bit-architectures.patch | 42 +++ ...xt2_setsize-when-len-is-page-aligned.patch | 79 ++++++ ...erblock-on-a-r-o-mount-if-not-needed.patch | 72 +++++ ...ffer-heads-from-last-failed-mounting.patch | 121 ++++++++ ...alue-of-freeze_bdev-in-ext4_shutdown.patch | 43 +++ ...x-wrong-unit-use-in-ext4_mb_clear_bb.patch | 35 +++ ...wrong-unit-use-in-ext4_mb_new_blocks.patch | 34 +++ ...4_free_blocks-for-fast-commit-replay.patch | 52 ++++ ...locks-on-successful-block-allocation.patch | 92 ++++++ ...f-mount-failed-after-enabling-quotas.patch | 76 +++++ ...t-check-required-context-while-close.patch | 81 ++++++ ...-the-timeout-for-init-and-self-check.patch | 45 +++ ...lidate-db_l2nbperpage-while-mounting.patch | 66 +++++ ...-error-return-in-do_vmi_align_munmap.patch | 65 +++++ ...ign-resources-on-bridge-if-necessary.patch | 78 +++++ ...dma-alias-quirk-for-marvell-88se9235.patch | 36 +++ ...ix-dma-transfer-completion-detection.patch | 116 ++++++++ ...a-transfer-completion-initialization.patch | 40 +++ ...elopos-e2-s2-h2-pcie-ports-in-d3cold.patch | 46 +++ ...to-read-only-registers-for-ip-v2.3.3.patch | 34 +++ ...e-resource-invalidated-by-coalescing.patch | 55 ++++ ...ut-to-wait-for-phy-plls-to-be-locked.patch | 81 ++++++ ...configuration-enable-bit-after-probe.patch | 40 +++ ...ration-for-rk3399-pcie-endpoint-core.patch | 113 ++++++++ ...-address-alignment-for-endpoint-mode.patch | 35 +++ ...-variable-to-access-32-bit-registers.patch | 76 +++++ ...te-pci-device-id-to-correct-register.patch | 60 ++++ ...do-not-retry-administrative-requests.patch | 59 ++++ ...-sense-data-for-admin-queue-scsi-i-o.patch | 38 +++ queue-6.4/series | 32 +++ ...onditional-call-to-scm_pas_mem_setup.patch | 83 ++++++ 33 files changed, 2247 insertions(+) create mode 100644 queue-6.4/arm64-dts-mt7986-use-size-of-reserved-partition-for-bl2.patch create mode 100644 queue-6.4/arm64-dts-ti-k3-j721s2-fix-wkup-pinmux-range.patch create mode 100644 queue-6.4/dm-integrity-reduce-vmalloc-space-footprint-on-32-bit-architectures.patch create mode 100644 queue-6.4/ext2-dax-fix-ext2_setsize-when-len-is-page-aligned.patch create mode 100644 queue-6.4/ext4-avoid-updating-the-superblock-on-a-r-o-mount-if-not-needed.patch create mode 100644 queue-6.4/ext4-fix-reusing-stale-buffer-heads-from-last-failed-mounting.patch create mode 100644 queue-6.4/ext4-fix-to-check-return-value-of-freeze_bdev-in-ext4_shutdown.patch create mode 100644 queue-6.4/ext4-fix-wrong-unit-use-in-ext4_mb_clear_bb.patch create mode 100644 queue-6.4/ext4-fix-wrong-unit-use-in-ext4_mb_new_blocks.patch create mode 100644 queue-6.4/ext4-get-block-from-bh-in-ext4_free_blocks-for-fast-commit-replay.patch create mode 100644 queue-6.4/ext4-only-update-i_reserved_data_blocks-on-successful-block-allocation.patch create mode 100644 queue-6.4/ext4-turn-quotas-off-if-mount-failed-after-enabling-quotas.patch create mode 100644 queue-6.4/fs-dlm-revert-check-required-context-while-close.patch create mode 100644 queue-6.4/hwrng-imx-rngc-fix-the-timeout-for-init-and-self-check.patch create mode 100644 queue-6.4/jfs-jfs_dmap-validate-db_l2nbperpage-while-mounting.patch create mode 100644 queue-6.4/mm-mmap-fix-error-return-in-do_vmi_align_munmap.patch create mode 100644 queue-6.4/pci-acpiphp-reassign-resources-on-bridge-if-necessary.patch create mode 100644 queue-6.4/pci-add-function-1-dma-alias-quirk-for-marvell-88se9235.patch create mode 100644 queue-6.4/pci-epf-test-fix-dma-transfer-completion-detection.patch create mode 100644 queue-6.4/pci-epf-test-fix-dma-transfer-completion-initialization.patch create mode 100644 queue-6.4/pci-pm-avoid-putting-elopos-e2-s2-h2-pcie-ports-in-d3cold.patch create mode 100644 queue-6.4/pci-qcom-disable-write-access-to-read-only-registers-for-ip-v2.3.3.patch create mode 100644 queue-6.4/pci-release-resource-invalidated-by-coalescing.patch create mode 100644 queue-6.4/pci-rockchip-add-poll-and-timeout-to-wait-for-phy-plls-to-be-locked.patch create mode 100644 queue-6.4/pci-rockchip-assert-pci-configuration-enable-bit-after-probe.patch create mode 100644 queue-6.4/pci-rockchip-fix-legacy-irq-generation-for-rk3399-pcie-endpoint-core.patch create mode 100644 queue-6.4/pci-rockchip-set-address-alignment-for-endpoint-mode.patch create mode 100644 queue-6.4/pci-rockchip-use-u32-variable-to-access-32-bit-registers.patch create mode 100644 queue-6.4/pci-rockchip-write-pci-device-id-to-correct-register.patch create mode 100644 queue-6.4/s390-zcrypt-do-not-retry-administrative-requests.patch create mode 100644 queue-6.4/scsi-mpi3mr-propagate-sense-data-for-admin-queue-scsi-i-o.patch create mode 100644 queue-6.4/soc-qcom-mdt_loader-fix-unconditional-call-to-scm_pas_mem_setup.patch diff --git a/queue-6.4/arm64-dts-mt7986-use-size-of-reserved-partition-for-bl2.patch b/queue-6.4/arm64-dts-mt7986-use-size-of-reserved-partition-for-bl2.patch new file mode 100644 index 00000000000..9fd50b9ff5e --- /dev/null +++ b/queue-6.4/arm64-dts-mt7986-use-size-of-reserved-partition-for-bl2.patch @@ -0,0 +1,55 @@ +From 7afe7b5969329175ac4f55a6b9c13ba4f6dc267e Mon Sep 17 00:00:00 2001 +From: Frank Wunderlich +Date: Sun, 28 May 2023 13:33:42 +0200 +Subject: arm64: dts: mt7986: use size of reserved partition for bl2 + +From: Frank Wunderlich + +commit 7afe7b5969329175ac4f55a6b9c13ba4f6dc267e upstream. + +To store uncompressed bl2 more space is required than partition is +actually defined. + +There is currently no known usage of this reserved partition. +Openwrt uses same partition layout. + +We added same change to u-boot with commit d7bb1099 [1]. + +[1] https://source.denx.de/u-boot/u-boot/-/commit/d7bb109900c1ca754a0198b9afb50e3161ffc21e + +Cc: stable@vger.kernel.org +Fixes: 8e01fb15b815 ("arm64: dts: mt7986: add Bananapi R3") +Signed-off-by: Frank Wunderlich +Reviewed-by: AngeloGioacchino Del Regno +Reviewed-by: Daniel Golle +Link: https://lore.kernel.org/r/20230528113343.7649-1-linux@fw-web.de +Signed-off-by: Matthias Brugger +Signed-off-by: Greg Kroah-Hartman +--- + .../boot/dts/mediatek/mt7986a-bananapi-bpi-r3-nor.dtso | 7 +------ + 1 file changed, 1 insertion(+), 6 deletions(-) + +diff --git a/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-nor.dtso b/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-nor.dtso +index 84aa229e80f3..e48881be4ed6 100644 +--- a/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-nor.dtso ++++ b/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-nor.dtso +@@ -27,15 +27,10 @@ partitions { + + partition@0 { + label = "bl2"; +- reg = <0x0 0x20000>; ++ reg = <0x0 0x40000>; + read-only; + }; + +- partition@20000 { +- label = "reserved"; +- reg = <0x20000 0x20000>; +- }; +- + partition@40000 { + label = "u-boot-env"; + reg = <0x40000 0x40000>; +-- +2.41.0 + diff --git a/queue-6.4/arm64-dts-ti-k3-j721s2-fix-wkup-pinmux-range.patch b/queue-6.4/arm64-dts-ti-k3-j721s2-fix-wkup-pinmux-range.patch new file mode 100644 index 00000000000..6bea08180df --- /dev/null +++ b/queue-6.4/arm64-dts-ti-k3-j721s2-fix-wkup-pinmux-range.patch @@ -0,0 +1,267 @@ +From 6bc829ceea4158c7aeb3a9e73d5c52634d78fb6f Mon Sep 17 00:00:00 2001 +From: Sinthu Raja +Date: Fri, 2 Jun 2023 10:35:49 -0500 +Subject: arm64: dts: ti: k3-j721s2: Fix wkup pinmux range + +From: Sinthu Raja + +commit 6bc829ceea4158c7aeb3a9e73d5c52634d78fb6f upstream. + +The WKUP_PADCONFIG register region in J721S2 has multiple non-addressable +regions, accordingly split the existing wkup_pmx region as follows to avoid +the non-addressable regions and include the rest of valid WKUP_PADCONFIG +registers. Also update references to old nodes with new ones. + +wkup_pmx0 -> 13 pins (WKUP_PADCONFIG 0 - 12) +wkup_pmx1 -> 11 pins (WKUP_PADCONFIG 14 - 24) +wkup_pmx2 -> 72 pins (WKUP_PADCONFIG 26 - 97) +wkup_pmx3 -> 1 pin (WKUP_PADCONFIG 100) + +Fixes: b8545f9d3a54 ("arm64: dts: ti: Add initial support for J721S2 SoC") +Cc: # 6.3 +Signed-off-by: Sinthu Raja +Signed-off-by: Thejasvi Konduru +Signed-off-by: Nishanth Menon +Reviewed-by: Udit Kumar +Link: https://lore.kernel.org/r/20230602153554.1571128-2-nm@ti.com +Signed-off-by: Vignesh Raghavendra +Signed-off-by: Greg Kroah-Hartman +--- + arch/arm64/boot/dts/ti/k3-am68-sk-base-board.dts | 42 ++++----- + arch/arm64/boot/dts/ti/k3-j721s2-common-proc-board.dts | 76 ++++++++--------- + arch/arm64/boot/dts/ti/k3-j721s2-mcu-wakeup.dtsi | 29 ++++++ + 3 files changed, 87 insertions(+), 60 deletions(-) + +--- a/arch/arm64/boot/dts/ti/k3-am68-sk-base-board.dts ++++ b/arch/arm64/boot/dts/ti/k3-am68-sk-base-board.dts +@@ -175,49 +175,49 @@ + }; + }; + +-&wkup_pmx0 { ++&wkup_pmx2 { + mcu_cpsw_pins_default: mcu-cpsw-pins-default { + pinctrl-single,pins = < +- J721S2_WKUP_IOPAD(0x094, PIN_INPUT, 0) /* (B22) MCU_RGMII1_RD0 */ +- J721S2_WKUP_IOPAD(0x090, PIN_INPUT, 0) /* (B21) MCU_RGMII1_RD1 */ +- J721S2_WKUP_IOPAD(0x08c, PIN_INPUT, 0) /* (C22) MCU_RGMII1_RD2 */ +- J721S2_WKUP_IOPAD(0x088, PIN_INPUT, 0) /* (D23) MCU_RGMII1_RD3 */ +- J721S2_WKUP_IOPAD(0x084, PIN_INPUT, 0) /* (D22) MCU_RGMII1_RXC */ +- J721S2_WKUP_IOPAD(0x06c, PIN_INPUT, 0) /* (E23) MCU_RGMII1_RX_CTL */ +- J721S2_WKUP_IOPAD(0x07c, PIN_OUTPUT, 0) /* (F23) MCU_RGMII1_TD0 */ +- J721S2_WKUP_IOPAD(0x078, PIN_OUTPUT, 0) /* (G22) MCU_RGMII1_TD1 */ +- J721S2_WKUP_IOPAD(0x074, PIN_OUTPUT, 0) /* (E21) MCU_RGMII1_TD2 */ +- J721S2_WKUP_IOPAD(0x070, PIN_OUTPUT, 0) /* (E22) MCU_RGMII1_TD3 */ +- J721S2_WKUP_IOPAD(0x080, PIN_OUTPUT, 0) /* (F21) MCU_RGMII1_TXC */ +- J721S2_WKUP_IOPAD(0x068, PIN_OUTPUT, 0) /* (F22) MCU_RGMII1_TX_CTL */ ++ J721S2_WKUP_IOPAD(0x02C, PIN_INPUT, 0) /* (B22) MCU_RGMII1_RD0 */ ++ J721S2_WKUP_IOPAD(0x028, PIN_INPUT, 0) /* (B21) MCU_RGMII1_RD1 */ ++ J721S2_WKUP_IOPAD(0x024, PIN_INPUT, 0) /* (C22) MCU_RGMII1_RD2 */ ++ J721S2_WKUP_IOPAD(0x020, PIN_INPUT, 0) /* (D23) MCU_RGMII1_RD3 */ ++ J721S2_WKUP_IOPAD(0x01C, PIN_INPUT, 0) /* (D22) MCU_RGMII1_RXC */ ++ J721S2_WKUP_IOPAD(0x004, PIN_INPUT, 0) /* (E23) MCU_RGMII1_RX_CTL */ ++ J721S2_WKUP_IOPAD(0x014, PIN_OUTPUT, 0) /* (F23) MCU_RGMII1_TD0 */ ++ J721S2_WKUP_IOPAD(0x010, PIN_OUTPUT, 0) /* (G22) MCU_RGMII1_TD1 */ ++ J721S2_WKUP_IOPAD(0x00C, PIN_OUTPUT, 0) /* (E21) MCU_RGMII1_TD2 */ ++ J721S2_WKUP_IOPAD(0x008, PIN_OUTPUT, 0) /* (E22) MCU_RGMII1_TD3 */ ++ J721S2_WKUP_IOPAD(0x018, PIN_OUTPUT, 0) /* (F21) MCU_RGMII1_TXC */ ++ J721S2_WKUP_IOPAD(0x000, PIN_OUTPUT, 0) /* (F22) MCU_RGMII1_TX_CTL */ + >; + }; + + mcu_mdio_pins_default: mcu-mdio-pins-default { + pinctrl-single,pins = < +- J721S2_WKUP_IOPAD(0x09c, PIN_OUTPUT, 0) /* (A21) MCU_MDIO0_MDC */ +- J721S2_WKUP_IOPAD(0x098, PIN_INPUT, 0) /* (A22) MCU_MDIO0_MDIO */ ++ J721S2_WKUP_IOPAD(0x034, PIN_OUTPUT, 0) /* (A21) MCU_MDIO0_MDC */ ++ J721S2_WKUP_IOPAD(0x030, PIN_INPUT, 0) /* (A22) MCU_MDIO0_MDIO */ + >; + }; + + mcu_mcan0_pins_default: mcu-mcan0-pins-default { + pinctrl-single,pins = < +- J721S2_WKUP_IOPAD(0x0bc, PIN_INPUT, 0) /* (E28) MCU_MCAN0_RX */ +- J721S2_WKUP_IOPAD(0x0b8, PIN_OUTPUT, 0) /* (E27) MCU_MCAN0_TX */ ++ J721S2_WKUP_IOPAD(0x054, PIN_INPUT, 0) /* (E28) MCU_MCAN0_RX */ ++ J721S2_WKUP_IOPAD(0x050, PIN_OUTPUT, 0) /* (E27) MCU_MCAN0_TX */ + >; + }; + + mcu_mcan1_pins_default: mcu-mcan1-pins-default { + pinctrl-single,pins = < +- J721S2_WKUP_IOPAD(0x0d4, PIN_INPUT, 0) /* (F26) WKUP_GPIO0_5.MCU_MCAN1_RX */ +- J721S2_WKUP_IOPAD(0x0d0, PIN_OUTPUT, 0) /* (C23) WKUP_GPIO0_4.MCU_MCAN1_TX*/ ++ J721S2_WKUP_IOPAD(0x06C, PIN_INPUT, 0) /* (F26) WKUP_GPIO0_5.MCU_MCAN1_RX */ ++ J721S2_WKUP_IOPAD(0x068, PIN_OUTPUT, 0) /* (C23) WKUP_GPIO0_4.MCU_MCAN1_TX*/ + >; + }; + + mcu_i2c1_pins_default: mcu-i2c1-pins-default { + pinctrl-single,pins = < +- J721S2_WKUP_IOPAD(0x0e0, PIN_INPUT, 0) /* (F24) WKUP_GPIO0_8.MCU_I2C1_SCL */ +- J721S2_WKUP_IOPAD(0x0e4, PIN_INPUT, 0) /* (H26) WKUP_GPIO0_9.MCU_I2C1_SDA */ ++ J721S2_WKUP_IOPAD(0x078, PIN_INPUT, 0) /* (F24) WKUP_GPIO0_8.MCU_I2C1_SCL */ ++ J721S2_WKUP_IOPAD(0x07c, PIN_INPUT, 0) /* (H26) WKUP_GPIO0_9.MCU_I2C1_SDA */ + >; + }; + }; +--- a/arch/arm64/boot/dts/ti/k3-j721s2-common-proc-board.dts ++++ b/arch/arm64/boot/dts/ti/k3-j721s2-common-proc-board.dts +@@ -146,81 +146,81 @@ + }; + }; + +-&wkup_pmx0 { ++&wkup_pmx2 { + mcu_cpsw_pins_default: mcu-cpsw-pins-default { + pinctrl-single,pins = < +- J721S2_WKUP_IOPAD(0x094, PIN_INPUT, 0) /* (B22) MCU_RGMII1_RD0 */ +- J721S2_WKUP_IOPAD(0x090, PIN_INPUT, 0) /* (B21) MCU_RGMII1_RD1 */ +- J721S2_WKUP_IOPAD(0x08c, PIN_INPUT, 0) /* (C22) MCU_RGMII1_RD2 */ +- J721S2_WKUP_IOPAD(0x088, PIN_INPUT, 0) /* (D23) MCU_RGMII1_RD3 */ +- J721S2_WKUP_IOPAD(0x084, PIN_INPUT, 0) /* (D22) MCU_RGMII1_RXC */ +- J721S2_WKUP_IOPAD(0x06c, PIN_INPUT, 0) /* (E23) MCU_RGMII1_RX_CTL */ +- J721S2_WKUP_IOPAD(0x07c, PIN_OUTPUT, 0) /* (F23) MCU_RGMII1_TD0 */ +- J721S2_WKUP_IOPAD(0x078, PIN_OUTPUT, 0) /* (G22) MCU_RGMII1_TD1 */ +- J721S2_WKUP_IOPAD(0x074, PIN_OUTPUT, 0) /* (E21) MCU_RGMII1_TD2 */ +- J721S2_WKUP_IOPAD(0x070, PIN_OUTPUT, 0) /* (E22) MCU_RGMII1_TD3 */ +- J721S2_WKUP_IOPAD(0x080, PIN_OUTPUT, 0) /* (F21) MCU_RGMII1_TXC */ +- J721S2_WKUP_IOPAD(0x068, PIN_OUTPUT, 0) /* (F22) MCU_RGMII1_TX_CTL */ ++ J721S2_WKUP_IOPAD(0x02c, PIN_INPUT, 0) /* (B22) MCU_RGMII1_RD0 */ ++ J721S2_WKUP_IOPAD(0x028, PIN_INPUT, 0) /* (B21) MCU_RGMII1_RD1 */ ++ J721S2_WKUP_IOPAD(0x024, PIN_INPUT, 0) /* (C22) MCU_RGMII1_RD2 */ ++ J721S2_WKUP_IOPAD(0x020, PIN_INPUT, 0) /* (D23) MCU_RGMII1_RD3 */ ++ J721S2_WKUP_IOPAD(0x01c, PIN_INPUT, 0) /* (D22) MCU_RGMII1_RXC */ ++ J721S2_WKUP_IOPAD(0x004, PIN_INPUT, 0) /* (E23) MCU_RGMII1_RX_CTL */ ++ J721S2_WKUP_IOPAD(0x014, PIN_OUTPUT, 0) /* (F23) MCU_RGMII1_TD0 */ ++ J721S2_WKUP_IOPAD(0x010, PIN_OUTPUT, 0) /* (G22) MCU_RGMII1_TD1 */ ++ J721S2_WKUP_IOPAD(0x00c, PIN_OUTPUT, 0) /* (E21) MCU_RGMII1_TD2 */ ++ J721S2_WKUP_IOPAD(0x008, PIN_OUTPUT, 0) /* (E22) MCU_RGMII1_TD3 */ ++ J721S2_WKUP_IOPAD(0x018, PIN_OUTPUT, 0) /* (F21) MCU_RGMII1_TXC */ ++ J721S2_WKUP_IOPAD(0x000, PIN_OUTPUT, 0) /* (F22) MCU_RGMII1_TX_CTL */ + >; + }; + + mcu_mdio_pins_default: mcu-mdio-pins-default { + pinctrl-single,pins = < +- J721S2_WKUP_IOPAD(0x09c, PIN_OUTPUT, 0) /* (A21) MCU_MDIO0_MDC */ +- J721S2_WKUP_IOPAD(0x098, PIN_INPUT, 0) /* (A22) MCU_MDIO0_MDIO */ ++ J721S2_WKUP_IOPAD(0x034, PIN_OUTPUT, 0) /* (A21) MCU_MDIO0_MDC */ ++ J721S2_WKUP_IOPAD(0x030, PIN_INPUT, 0) /* (A22) MCU_MDIO0_MDIO */ + >; + }; + + mcu_mcan0_pins_default: mcu-mcan0-pins-default { + pinctrl-single,pins = < +- J721S2_WKUP_IOPAD(0x0bc, PIN_INPUT, 0) /* (E28) MCU_MCAN0_RX */ +- J721S2_WKUP_IOPAD(0x0b8, PIN_OUTPUT, 0) /* (E27) MCU_MCAN0_TX */ ++ J721S2_WKUP_IOPAD(0x054, PIN_INPUT, 0) /* (E28) MCU_MCAN0_RX */ ++ J721S2_WKUP_IOPAD(0x050, PIN_OUTPUT, 0) /* (E27) MCU_MCAN0_TX */ + >; + }; + + mcu_mcan1_pins_default: mcu-mcan1-pins-default { + pinctrl-single,pins = < +- J721S2_WKUP_IOPAD(0x0d4, PIN_INPUT, 0) /* (F26) WKUP_GPIO0_5.MCU_MCAN1_RX */ +- J721S2_WKUP_IOPAD(0x0d0, PIN_OUTPUT, 0) /* (C23) WKUP_GPIO0_4.MCU_MCAN1_TX */ ++ J721S2_WKUP_IOPAD(0x06c, PIN_INPUT, 0) /* (F26) WKUP_GPIO0_5.MCU_MCAN1_RX */ ++ J721S2_WKUP_IOPAD(0x068, PIN_OUTPUT, 0) /*(C23) WKUP_GPIO0_4.MCU_MCAN1_TX */ + >; + }; + + mcu_mcan0_gpio_pins_default: mcu-mcan0-gpio-pins-default { + pinctrl-single,pins = < +- J721S2_WKUP_IOPAD(0x0c0, PIN_INPUT, 7) /* (D26) WKUP_GPIO0_0 */ +- J721S2_WKUP_IOPAD(0x0a8, PIN_INPUT, 7) /* (B25) MCU_SPI0_D1.WKUP_GPIO0_69 */ ++ J721S2_WKUP_IOPAD(0x058, PIN_INPUT, 7) /* (D26) WKUP_GPIO0_0 */ ++ J721S2_WKUP_IOPAD(0x040, PIN_INPUT, 7) /* (B25) MCU_SPI0_D1.WKUP_GPIO0_69 */ + >; + }; + + mcu_mcan1_gpio_pins_default: mcu-mcan1-gpio-pins-default { + pinctrl-single,pins = < +- J721S2_WKUP_IOPAD(0x0c8, PIN_INPUT, 7) /* (C28) WKUP_GPIO0_2 */ ++ J721S2_WKUP_IOPAD(0x060, PIN_INPUT, 7) /* (C28) WKUP_GPIO0_2 */ + >; + }; + + mcu_adc0_pins_default: mcu-adc0-pins-default { + pinctrl-single,pins = < +- J721S2_WKUP_IOPAD(0x134, PIN_INPUT, 0) /* (L25) MCU_ADC0_AIN0 */ +- J721S2_WKUP_IOPAD(0x138, PIN_INPUT, 0) /* (K25) MCU_ADC0_AIN1 */ +- J721S2_WKUP_IOPAD(0x13c, PIN_INPUT, 0) /* (M24) MCU_ADC0_AIN2 */ +- J721S2_WKUP_IOPAD(0x140, PIN_INPUT, 0) /* (L24) MCU_ADC0_AIN3 */ +- J721S2_WKUP_IOPAD(0x144, PIN_INPUT, 0) /* (L27) MCU_ADC0_AIN4 */ +- J721S2_WKUP_IOPAD(0x148, PIN_INPUT, 0) /* (K24) MCU_ADC0_AIN5 */ +- J721S2_WKUP_IOPAD(0x14c, PIN_INPUT, 0) /* (M27) MCU_ADC0_AIN6 */ +- J721S2_WKUP_IOPAD(0x150, PIN_INPUT, 0) /* (M26) MCU_ADC0_AIN7 */ ++ J721S2_WKUP_IOPAD(0x0cc, PIN_INPUT, 0) /* (L25) MCU_ADC0_AIN0 */ ++ J721S2_WKUP_IOPAD(0x0d0, PIN_INPUT, 0) /* (K25) MCU_ADC0_AIN1 */ ++ J721S2_WKUP_IOPAD(0x0d4, PIN_INPUT, 0) /* (M24) MCU_ADC0_AIN2 */ ++ J721S2_WKUP_IOPAD(0x0d8, PIN_INPUT, 0) /* (L24) MCU_ADC0_AIN3 */ ++ J721S2_WKUP_IOPAD(0x0dc, PIN_INPUT, 0) /* (L27) MCU_ADC0_AIN4 */ ++ J721S2_WKUP_IOPAD(0x0e0, PIN_INPUT, 0) /* (K24) MCU_ADC0_AIN5 */ ++ J721S2_WKUP_IOPAD(0x0e4, PIN_INPUT, 0) /* (M27) MCU_ADC0_AIN6 */ ++ J721S2_WKUP_IOPAD(0x0e8, PIN_INPUT, 0) /* (M26) MCU_ADC0_AIN7 */ + >; + }; + + mcu_adc1_pins_default: mcu-adc1-pins-default { + pinctrl-single,pins = < +- J721S2_WKUP_IOPAD(0x154, PIN_INPUT, 0) /* (P25) MCU_ADC1_AIN0 */ +- J721S2_WKUP_IOPAD(0x158, PIN_INPUT, 0) /* (R25) MCU_ADC1_AIN1 */ +- J721S2_WKUP_IOPAD(0x15c, PIN_INPUT, 0) /* (P28) MCU_ADC1_AIN2 */ +- J721S2_WKUP_IOPAD(0x160, PIN_INPUT, 0) /* (P27) MCU_ADC1_AIN3 */ +- J721S2_WKUP_IOPAD(0x164, PIN_INPUT, 0) /* (N25) MCU_ADC1_AIN4 */ +- J721S2_WKUP_IOPAD(0x168, PIN_INPUT, 0) /* (P26) MCU_ADC1_AIN5 */ +- J721S2_WKUP_IOPAD(0x16c, PIN_INPUT, 0) /* (N26) MCU_ADC1_AIN6 */ +- J721S2_WKUP_IOPAD(0x170, PIN_INPUT, 0) /* (N27) MCU_ADC1_AIN7 */ ++ J721S2_WKUP_IOPAD(0x0ec, PIN_INPUT, 0) /* (P25) MCU_ADC1_AIN0 */ ++ J721S2_WKUP_IOPAD(0x0f0, PIN_INPUT, 0) /* (R25) MCU_ADC1_AIN1 */ ++ J721S2_WKUP_IOPAD(0x0f4, PIN_INPUT, 0) /* (P28) MCU_ADC1_AIN2 */ ++ J721S2_WKUP_IOPAD(0x0f8, PIN_INPUT, 0) /* (P27) MCU_ADC1_AIN3 */ ++ J721S2_WKUP_IOPAD(0x0fc, PIN_INPUT, 0) /* (N25) MCU_ADC1_AIN4 */ ++ J721S2_WKUP_IOPAD(0x100, PIN_INPUT, 0) /* (P26) MCU_ADC1_AIN5 */ ++ J721S2_WKUP_IOPAD(0x104, PIN_INPUT, 0) /* (N26) MCU_ADC1_AIN6 */ ++ J721S2_WKUP_IOPAD(0x108, PIN_INPUT, 0) /* (N27) MCU_ADC1_AIN7 */ + >; + }; + }; +--- a/arch/arm64/boot/dts/ti/k3-j721s2-mcu-wakeup.dtsi ++++ b/arch/arm64/boot/dts/ti/k3-j721s2-mcu-wakeup.dtsi +@@ -50,7 +50,34 @@ + wkup_pmx0: pinctrl@4301c000 { + compatible = "pinctrl-single"; + /* Proxy 0 addressing */ +- reg = <0x00 0x4301c000 0x00 0x178>; ++ reg = <0x00 0x4301c000 0x00 0x034>; ++ #pinctrl-cells = <1>; ++ pinctrl-single,register-width = <32>; ++ pinctrl-single,function-mask = <0xffffffff>; ++ }; ++ ++ wkup_pmx1: pinctrl@4301c038 { ++ compatible = "pinctrl-single"; ++ /* Proxy 0 addressing */ ++ reg = <0x00 0x4301c038 0x00 0x02C>; ++ #pinctrl-cells = <1>; ++ pinctrl-single,register-width = <32>; ++ pinctrl-single,function-mask = <0xffffffff>; ++ }; ++ ++ wkup_pmx2: pinctrl@4301c068 { ++ compatible = "pinctrl-single"; ++ /* Proxy 0 addressing */ ++ reg = <0x00 0x4301c068 0x00 0x120>; ++ #pinctrl-cells = <1>; ++ pinctrl-single,register-width = <32>; ++ pinctrl-single,function-mask = <0xffffffff>; ++ }; ++ ++ wkup_pmx3: pinctrl@4301c190 { ++ compatible = "pinctrl-single"; ++ /* Proxy 0 addressing */ ++ reg = <0x00 0x4301c190 0x00 0x004>; + #pinctrl-cells = <1>; + pinctrl-single,register-width = <32>; + pinctrl-single,function-mask = <0xffffffff>; diff --git a/queue-6.4/dm-integrity-reduce-vmalloc-space-footprint-on-32-bit-architectures.patch b/queue-6.4/dm-integrity-reduce-vmalloc-space-footprint-on-32-bit-architectures.patch new file mode 100644 index 00000000000..f17c1ca540c --- /dev/null +++ b/queue-6.4/dm-integrity-reduce-vmalloc-space-footprint-on-32-bit-architectures.patch @@ -0,0 +1,42 @@ +From 6d50eb4725934fd22f5eeccb401000687c790fd0 Mon Sep 17 00:00:00 2001 +From: Mikulas Patocka +Date: Mon, 26 Jun 2023 16:44:34 +0200 +Subject: dm integrity: reduce vmalloc space footprint on 32-bit architectures + +From: Mikulas Patocka + +commit 6d50eb4725934fd22f5eeccb401000687c790fd0 upstream. + +It was reported that dm-integrity runs out of vmalloc space on 32-bit +architectures. On x86, there is only 128MiB vmalloc space and dm-integrity +consumes it quickly because it has a 64MiB journal and 8MiB recalculate +buffer. + +Fix this by reducing the size of the journal to 4MiB and the size of +the recalculate buffer to 1MiB, so that multiple dm-integrity devices +can be created and activated on 32-bit architectures. + +Cc: stable@vger.kernel.org +Signed-off-by: Mikulas Patocka +Signed-off-by: Mike Snitzer +Signed-off-by: Greg Kroah-Hartman +--- + drivers/md/dm-integrity.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/drivers/md/dm-integrity.c ++++ b/drivers/md/dm-integrity.c +@@ -34,11 +34,11 @@ + #define DEFAULT_BUFFER_SECTORS 128 + #define DEFAULT_JOURNAL_WATERMARK 50 + #define DEFAULT_SYNC_MSEC 10000 +-#define DEFAULT_MAX_JOURNAL_SECTORS 131072 ++#define DEFAULT_MAX_JOURNAL_SECTORS (IS_ENABLED(CONFIG_64BIT) ? 131072 : 8192) + #define MIN_LOG2_INTERLEAVE_SECTORS 3 + #define MAX_LOG2_INTERLEAVE_SECTORS 31 + #define METADATA_WORKQUEUE_MAX_ACTIVE 16 +-#define RECALC_SECTORS 32768 ++#define RECALC_SECTORS (IS_ENABLED(CONFIG_64BIT) ? 32768 : 2048) + #define RECALC_WRITE_SUPER 16 + #define BITMAP_BLOCK_SIZE 4096 /* don't change it */ + #define BITMAP_FLUSH_INTERVAL (10 * HZ) diff --git a/queue-6.4/ext2-dax-fix-ext2_setsize-when-len-is-page-aligned.patch b/queue-6.4/ext2-dax-fix-ext2_setsize-when-len-is-page-aligned.patch new file mode 100644 index 00000000000..a1945c5413e --- /dev/null +++ b/queue-6.4/ext2-dax-fix-ext2_setsize-when-len-is-page-aligned.patch @@ -0,0 +1,79 @@ +From fcced95b6ba2a507a83b8b3e0358a8ac16b13e35 Mon Sep 17 00:00:00 2001 +From: "Ritesh Harjani (IBM)" +Date: Fri, 21 Apr 2023 15:16:11 +0530 +Subject: ext2/dax: Fix ext2_setsize when len is page aligned + +From: Ritesh Harjani (IBM) + +commit fcced95b6ba2a507a83b8b3e0358a8ac16b13e35 upstream. + +PAGE_ALIGN(x) macro gives the next highest value which is multiple of +pagesize. But if x is already page aligned then it simply returns x. +So, if x passed is 0 in dax_zero_range() function, that means the +length gets passed as 0 to ->iomap_begin(). + +In ext2 it then calls ext2_get_blocks -> max_blocks as 0 and hits bug_on +here in ext2_get_blocks(). + BUG_ON(maxblocks == 0); + +Instead we should be calling dax_truncate_page() here which takes +care of it. i.e. it only calls dax_zero_range if the offset is not +page/block aligned. + +This can be easily triggered with following on fsdax mounted pmem +device. + +dd if=/dev/zero of=file count=1 bs=512 +truncate -s 0 file + +[79.525838] EXT2-fs (pmem0): DAX enabled. Warning: EXPERIMENTAL, use at your own risk +[79.529376] ext2 filesystem being mounted at /mnt1/test supports timestamps until 2038 (0x7fffffff) +[93.793207] ------------[ cut here ]------------ +[93.795102] kernel BUG at fs/ext2/inode.c:637! +[93.796904] invalid opcode: 0000 [#1] PREEMPT SMP PTI +[93.798659] CPU: 0 PID: 1192 Comm: truncate Not tainted 6.3.0-rc2-xfstests-00056-g131086faa369 #139 +[93.806459] RIP: 0010:ext2_get_blocks.constprop.0+0x524/0x610 +<...> +[93.835298] Call Trace: +[93.836253] +[93.837103] ? lock_acquire+0xf8/0x110 +[93.838479] ? d_lookup+0x69/0xd0 +[93.839779] ext2_iomap_begin+0xa7/0x1c0 +[93.841154] iomap_iter+0xc7/0x150 +[93.842425] dax_zero_range+0x6e/0xa0 +[93.843813] ext2_setsize+0x176/0x1b0 +[93.845164] ext2_setattr+0x151/0x200 +[93.846467] notify_change+0x341/0x4e0 +[93.847805] ? lock_acquire+0xf8/0x110 +[93.849143] ? do_truncate+0x74/0xe0 +[93.850452] ? do_truncate+0x84/0xe0 +[93.851739] do_truncate+0x84/0xe0 +[93.852974] do_sys_ftruncate+0x2b4/0x2f0 +[93.854404] do_syscall_64+0x3f/0x90 +[93.855789] entry_SYSCALL_64_after_hwframe+0x72/0xdc + +CC: stable@vger.kernel.org +Fixes: 2aa3048e03d3 ("iomap: switch iomap_zero_range to use iomap_iter") +Reviewed-by: Darrick J. Wong +Signed-off-by: Ritesh Harjani (IBM) +Signed-off-by: Jan Kara +Message-Id: <046a58317f29d9603d1068b2bbae47c2332c17ae.1682069716.git.ritesh.list@gmail.com> +Signed-off-by: Greg Kroah-Hartman +--- + fs/ext2/inode.c | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +--- a/fs/ext2/inode.c ++++ b/fs/ext2/inode.c +@@ -1259,9 +1259,8 @@ static int ext2_setsize(struct inode *in + inode_dio_wait(inode); + + if (IS_DAX(inode)) +- error = dax_zero_range(inode, newsize, +- PAGE_ALIGN(newsize) - newsize, NULL, +- &ext2_iomap_ops); ++ error = dax_truncate_page(inode, newsize, NULL, ++ &ext2_iomap_ops); + else + error = block_truncate_page(inode->i_mapping, + newsize, ext2_get_block); diff --git a/queue-6.4/ext4-avoid-updating-the-superblock-on-a-r-o-mount-if-not-needed.patch b/queue-6.4/ext4-avoid-updating-the-superblock-on-a-r-o-mount-if-not-needed.patch new file mode 100644 index 00000000000..c7f394ed587 --- /dev/null +++ b/queue-6.4/ext4-avoid-updating-the-superblock-on-a-r-o-mount-if-not-needed.patch @@ -0,0 +1,72 @@ +From 2ef6c32a914b85217b44a0a2418e830e520b085e Mon Sep 17 00:00:00 2001 +From: Theodore Ts'o +Date: Fri, 23 Jun 2023 10:18:51 -0400 +Subject: ext4: avoid updating the superblock on a r/o mount if not needed + +From: Theodore Ts'o + +commit 2ef6c32a914b85217b44a0a2418e830e520b085e upstream. + +This was noticed by a user who noticied that the mtime of a file +backing a loopback device was getting bumped when the loopback device +is mounted read/only. Note: This doesn't show up when doing a +loopback mount of a file directly, via "mount -o ro /tmp/foo.img +/mnt", since the loop device is set read-only when mount automatically +creates loop device. However, this is noticeable for a LUKS loop +device like this: + +% cryptsetup luksOpen /tmp/foo.img test +% mount -o ro /dev/loop0 /mnt ; umount /mnt + +or, if LUKS is not in use, if the user manually creates the loop +device like this: + +% losetup /dev/loop0 /tmp/foo.img +% mount -o ro /dev/loop0 /mnt ; umount /mnt + +The modified mtime causes rsync to do a rolling checksum scan of the +file on the local and remote side, incrementally increasing the time +to rsync the not-modified-but-touched image file. + +Fixes: eee00237fa5e ("ext4: commit super block if fs record error when journal record without error") +Cc: stable@kernel.org +Link: https://lore.kernel.org/r/ZIauBR7YiV3rVAHL@glitch +Reported-by: Sean Greenslade +Signed-off-by: Theodore Ts'o +Signed-off-by: Greg Kroah-Hartman +--- + fs/ext4/super.c | 12 ++++++++++-- + 1 file changed, 10 insertions(+), 2 deletions(-) + +--- a/fs/ext4/super.c ++++ b/fs/ext4/super.c +@@ -5980,19 +5980,27 @@ static int ext4_load_journal(struct supe + err = jbd2_journal_wipe(journal, !really_read_only); + if (!err) { + char *save = kmalloc(EXT4_S_ERR_LEN, GFP_KERNEL); ++ __le16 orig_state; ++ bool changed = false; + + if (save) + memcpy(save, ((char *) es) + + EXT4_S_ERR_START, EXT4_S_ERR_LEN); + err = jbd2_journal_load(journal); +- if (save) ++ if (save && memcmp(((char *) es) + EXT4_S_ERR_START, ++ save, EXT4_S_ERR_LEN)) { + memcpy(((char *) es) + EXT4_S_ERR_START, + save, EXT4_S_ERR_LEN); ++ changed = true; ++ } + kfree(save); ++ orig_state = es->s_state; + es->s_state |= cpu_to_le16(EXT4_SB(sb)->s_mount_state & + EXT4_ERROR_FS); ++ if (orig_state != es->s_state) ++ changed = true; + /* Write out restored error information to the superblock */ +- if (!bdev_read_only(sb->s_bdev)) { ++ if (changed && !really_read_only) { + int err2; + err2 = ext4_commit_super(sb); + err = err ? : err2; diff --git a/queue-6.4/ext4-fix-reusing-stale-buffer-heads-from-last-failed-mounting.patch b/queue-6.4/ext4-fix-reusing-stale-buffer-heads-from-last-failed-mounting.patch new file mode 100644 index 00000000000..5db195d9a5e --- /dev/null +++ b/queue-6.4/ext4-fix-reusing-stale-buffer-heads-from-last-failed-mounting.patch @@ -0,0 +1,121 @@ +From 26fb5290240dc31cae99b8b4dd2af7f46dfcba6b Mon Sep 17 00:00:00 2001 +From: Zhihao Cheng +Date: Wed, 15 Mar 2023 09:31:23 +0800 +Subject: ext4: Fix reusing stale buffer heads from last failed mounting + +From: Zhihao Cheng + +commit 26fb5290240dc31cae99b8b4dd2af7f46dfcba6b upstream. + +Following process makes ext4 load stale buffer heads from last failed +mounting in a new mounting operation: +mount_bdev + ext4_fill_super + | ext4_load_and_init_journal + | ext4_load_journal + | jbd2_journal_load + | load_superblock + | journal_get_superblock + | set_buffer_verified(bh) // buffer head is verified + | jbd2_journal_recover // failed caused by EIO + | goto failed_mount3a // skip 'sb->s_root' initialization + deactivate_locked_super + kill_block_super + generic_shutdown_super + if (sb->s_root) + // false, skip ext4_put_super->invalidate_bdev-> + // invalidate_mapping_pages->mapping_evict_folio-> + // filemap_release_folio->try_to_free_buffers, which + // cannot drop buffer head. + blkdev_put + blkdev_put_whole + if (atomic_dec_and_test(&bdev->bd_openers)) + // false, systemd-udev happens to open the device. Then + // blkdev_flush_mapping->kill_bdev->truncate_inode_pages-> + // truncate_inode_folio->truncate_cleanup_folio-> + // folio_invalidate->block_invalidate_folio-> + // filemap_release_folio->try_to_free_buffers will be skipped, + // dropping buffer head is missed again. + +Second mount: +ext4_fill_super + ext4_load_and_init_journal + ext4_load_journal + ext4_get_journal + jbd2_journal_init_inode + journal_init_common + bh = getblk_unmovable + bh = __find_get_block // Found stale bh in last failed mounting + journal->j_sb_buffer = bh + jbd2_journal_load + load_superblock + journal_get_superblock + if (buffer_verified(bh)) + // true, skip journal->j_format_version = 2, value is 0 + jbd2_journal_recover + do_one_pass + next_log_block += count_tags(journal, bh) + // According to journal_tag_bytes(), 'tag_bytes' calculating is + // affected by jbd2_has_feature_csum3(), jbd2_has_feature_csum3() + // returns false because 'j->j_format_version >= 2' is not true, + // then we get wrong next_log_block. The do_one_pass may exit + // early whenoccuring non JBD2_MAGIC_NUMBER in 'next_log_block'. + +The filesystem is corrupted here, journal is partially replayed, and +new journal sequence number actually is already used by last mounting. + +The invalidate_bdev() can drop all buffer heads even racing with bare +reading block device(eg. systemd-udev), so we can fix it by invalidating +bdev in error handling path in __ext4_fill_super(). + +Fetch a reproducer in [Link]. + +Link: https://bugzilla.kernel.org/show_bug.cgi?id=217171 +Fixes: 25ed6e8a54df ("jbd2: enable journal clients to enable v2 checksumming") +Cc: stable@vger.kernel.org # v3.5 +Signed-off-by: Zhihao Cheng +Reviewed-by: Jan Kara +Link: https://lore.kernel.org/r/20230315013128.3911115-2-chengzhihao1@huawei.com +Signed-off-by: Theodore Ts'o +Signed-off-by: Greg Kroah-Hartman +--- + fs/ext4/super.c | 13 +++++++------ + 1 file changed, 7 insertions(+), 6 deletions(-) + +--- a/fs/ext4/super.c ++++ b/fs/ext4/super.c +@@ -1128,6 +1128,12 @@ static void ext4_blkdev_remove(struct ex + struct block_device *bdev; + bdev = sbi->s_journal_bdev; + if (bdev) { ++ /* ++ * Invalidate the journal device's buffers. We don't want them ++ * floating about in memory - the physical journal device may ++ * hotswapped, and it breaks the `ro-after' testing code. ++ */ ++ invalidate_bdev(bdev); + ext4_blkdev_put(bdev); + sbi->s_journal_bdev = NULL; + } +@@ -1328,13 +1334,7 @@ static void ext4_put_super(struct super_ + sync_blockdev(sb->s_bdev); + invalidate_bdev(sb->s_bdev); + if (sbi->s_journal_bdev && sbi->s_journal_bdev != sb->s_bdev) { +- /* +- * Invalidate the journal device's buffers. We don't want them +- * floating about in memory - the physical journal device may +- * hotswapped, and it breaks the `ro-after' testing code. +- */ + sync_blockdev(sbi->s_journal_bdev); +- invalidate_bdev(sbi->s_journal_bdev); + ext4_blkdev_remove(sbi); + } + +@@ -5645,6 +5645,7 @@ failed_mount: + brelse(sbi->s_sbh); + ext4_blkdev_remove(sbi); + out_fail: ++ invalidate_bdev(sb->s_bdev); + sb->s_fs_info = NULL; + return err; + } diff --git a/queue-6.4/ext4-fix-to-check-return-value-of-freeze_bdev-in-ext4_shutdown.patch b/queue-6.4/ext4-fix-to-check-return-value-of-freeze_bdev-in-ext4_shutdown.patch new file mode 100644 index 00000000000..647b9c11d46 --- /dev/null +++ b/queue-6.4/ext4-fix-to-check-return-value-of-freeze_bdev-in-ext4_shutdown.patch @@ -0,0 +1,43 @@ +From c4d13222afd8a64bf11bc7ec68645496ee8b54b9 Mon Sep 17 00:00:00 2001 +From: Chao Yu +Date: Tue, 6 Jun 2023 15:32:03 +0800 +Subject: ext4: fix to check return value of freeze_bdev() in ext4_shutdown() + +From: Chao Yu + +commit c4d13222afd8a64bf11bc7ec68645496ee8b54b9 upstream. + +freeze_bdev() can fail due to a lot of reasons, it needs to check its +reason before later process. + +Fixes: 783d94854499 ("ext4: add EXT4_IOC_GOINGDOWN ioctl") +Cc: stable@kernel.org +Signed-off-by: Chao Yu +Link: https://lore.kernel.org/r/20230606073203.1310389-1-chao@kernel.org +Signed-off-by: Theodore Ts'o +Signed-off-by: Greg Kroah-Hartman +--- + fs/ext4/ioctl.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +--- a/fs/ext4/ioctl.c ++++ b/fs/ext4/ioctl.c +@@ -797,6 +797,7 @@ static int ext4_shutdown(struct super_bl + { + struct ext4_sb_info *sbi = EXT4_SB(sb); + __u32 flags; ++ int ret; + + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; +@@ -815,7 +816,9 @@ static int ext4_shutdown(struct super_bl + + switch (flags) { + case EXT4_GOING_FLAGS_DEFAULT: +- freeze_bdev(sb->s_bdev); ++ ret = freeze_bdev(sb->s_bdev); ++ if (ret) ++ return ret; + set_bit(EXT4_FLAGS_SHUTDOWN, &sbi->s_ext4_flags); + thaw_bdev(sb->s_bdev); + break; diff --git a/queue-6.4/ext4-fix-wrong-unit-use-in-ext4_mb_clear_bb.patch b/queue-6.4/ext4-fix-wrong-unit-use-in-ext4_mb_clear_bb.patch new file mode 100644 index 00000000000..a0d3c6c6943 --- /dev/null +++ b/queue-6.4/ext4-fix-wrong-unit-use-in-ext4_mb_clear_bb.patch @@ -0,0 +1,35 @@ +From 247c3d214c23dfeeeb892e91a82ac1188bdaec9f Mon Sep 17 00:00:00 2001 +From: Kemeng Shi +Date: Sat, 3 Jun 2023 23:03:18 +0800 +Subject: ext4: fix wrong unit use in ext4_mb_clear_bb + +From: Kemeng Shi + +commit 247c3d214c23dfeeeb892e91a82ac1188bdaec9f upstream. + +Function ext4_issue_discard need count in cluster. Pass count_clusters +instead of count to fix the mismatch. + +Signed-off-by: Kemeng Shi +Cc: stable@kernel.org +Reviewed-by: Ojaswin Mujoo +Link: https://lore.kernel.org/r/20230603150327.3596033-11-shikemeng@huaweicloud.com +Signed-off-by: Theodore Ts'o +Signed-off-by: Greg Kroah-Hartman +--- + fs/ext4/mballoc.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/fs/ext4/mballoc.c ++++ b/fs/ext4/mballoc.c +@@ -6243,8 +6243,8 @@ do_more: + * them with group lock_held + */ + if (test_opt(sb, DISCARD)) { +- err = ext4_issue_discard(sb, block_group, bit, count, +- NULL); ++ err = ext4_issue_discard(sb, block_group, bit, ++ count_clusters, NULL); + if (err && err != -EOPNOTSUPP) + ext4_msg(sb, KERN_WARNING, "discard request in" + " group:%u block:%d count:%lu failed" diff --git a/queue-6.4/ext4-fix-wrong-unit-use-in-ext4_mb_new_blocks.patch b/queue-6.4/ext4-fix-wrong-unit-use-in-ext4_mb_new_blocks.patch new file mode 100644 index 00000000000..6b7c8b94281 --- /dev/null +++ b/queue-6.4/ext4-fix-wrong-unit-use-in-ext4_mb_new_blocks.patch @@ -0,0 +1,34 @@ +From 2ec6d0a5ea72689a79e6f725fd8b443a788ae279 Mon Sep 17 00:00:00 2001 +From: Kemeng Shi +Date: Sat, 3 Jun 2023 23:03:19 +0800 +Subject: ext4: fix wrong unit use in ext4_mb_new_blocks + +From: Kemeng Shi + +commit 2ec6d0a5ea72689a79e6f725fd8b443a788ae279 upstream. + +Function ext4_free_blocks_simple needs count in cluster. Function +ext4_free_blocks accepts count in block. Convert count to cluster +to fix the mismatch. + +Signed-off-by: Kemeng Shi +Cc: stable@kernel.org +Reviewed-by: Ojaswin Mujoo +Link: https://lore.kernel.org/r/20230603150327.3596033-12-shikemeng@huaweicloud.com +Signed-off-by: Theodore Ts'o +Signed-off-by: Greg Kroah-Hartman +--- + fs/ext4/mballoc.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/fs/ext4/mballoc.c ++++ b/fs/ext4/mballoc.c +@@ -6336,7 +6336,7 @@ void ext4_free_blocks(handle_t *handle, + } + + if (sbi->s_mount_state & EXT4_FC_REPLAY) { +- ext4_free_blocks_simple(inode, block, count); ++ ext4_free_blocks_simple(inode, block, EXT4_NUM_B2C(sbi, count)); + return; + } + diff --git a/queue-6.4/ext4-get-block-from-bh-in-ext4_free_blocks-for-fast-commit-replay.patch b/queue-6.4/ext4-get-block-from-bh-in-ext4_free_blocks-for-fast-commit-replay.patch new file mode 100644 index 00000000000..68a3038152d --- /dev/null +++ b/queue-6.4/ext4-get-block-from-bh-in-ext4_free_blocks-for-fast-commit-replay.patch @@ -0,0 +1,52 @@ +From 11b6890be0084ad4df0e06d89a9fdcc948472c65 Mon Sep 17 00:00:00 2001 +From: Kemeng Shi +Date: Sat, 3 Jun 2023 23:03:16 +0800 +Subject: ext4: get block from bh in ext4_free_blocks for fast commit replay + +From: Kemeng Shi + +commit 11b6890be0084ad4df0e06d89a9fdcc948472c65 upstream. + +ext4_free_blocks will retrieve block from bh if block parameter is zero. +Retrieve block before ext4_free_blocks_simple to avoid potentially +passing wrong block to ext4_free_blocks_simple. + +Signed-off-by: Kemeng Shi +Cc: stable@kernel.org +Reviewed-by: Ojaswin Mujoo +Link: https://lore.kernel.org/r/20230603150327.3596033-9-shikemeng@huaweicloud.com +Signed-off-by: Theodore Ts'o +Signed-off-by: Greg Kroah-Hartman +--- + fs/ext4/mballoc.c | 13 +++++++------ + 1 file changed, 7 insertions(+), 6 deletions(-) + +--- a/fs/ext4/mballoc.c ++++ b/fs/ext4/mballoc.c +@@ -6328,12 +6328,6 @@ void ext4_free_blocks(handle_t *handle, + + sbi = EXT4_SB(sb); + +- if (sbi->s_mount_state & EXT4_FC_REPLAY) { +- ext4_free_blocks_simple(inode, block, count); +- return; +- } +- +- might_sleep(); + if (bh) { + if (block) + BUG_ON(block != bh->b_blocknr); +@@ -6341,6 +6335,13 @@ void ext4_free_blocks(handle_t *handle, + block = bh->b_blocknr; + } + ++ if (sbi->s_mount_state & EXT4_FC_REPLAY) { ++ ext4_free_blocks_simple(inode, block, count); ++ return; ++ } ++ ++ might_sleep(); ++ + if (!(flags & EXT4_FREE_BLOCKS_VALIDATED) && + !ext4_inode_block_valid(inode, block, count)) { + ext4_error(sb, "Freeing blocks not in datazone - " diff --git a/queue-6.4/ext4-only-update-i_reserved_data_blocks-on-successful-block-allocation.patch b/queue-6.4/ext4-only-update-i_reserved_data_blocks-on-successful-block-allocation.patch new file mode 100644 index 00000000000..a99eb90060b --- /dev/null +++ b/queue-6.4/ext4-only-update-i_reserved_data_blocks-on-successful-block-allocation.patch @@ -0,0 +1,92 @@ +From de25d6e9610a8b30cce9bbb19b50615d02ebca02 Mon Sep 17 00:00:00 2001 +From: Baokun Li +Date: Mon, 24 Apr 2023 11:38:35 +0800 +Subject: ext4: only update i_reserved_data_blocks on successful block allocation + +From: Baokun Li + +commit de25d6e9610a8b30cce9bbb19b50615d02ebca02 upstream. + +In our fault injection test, we create an ext4 file, migrate it to +non-extent based file, then punch a hole and finally trigger a WARN_ON +in the ext4_da_update_reserve_space(): + +EXT4-fs warning (device sda): ext4_da_update_reserve_space:369: +ino 14, used 11 with only 10 reserved data blocks + +When writing back a non-extent based file, if we enable delalloc, the +number of reserved blocks will be subtracted from the number of blocks +mapped by ext4_ind_map_blocks(), and the extent status tree will be +updated. We update the extent status tree by first removing the old +extent_status and then inserting the new extent_status. If the block range +we remove happens to be in an extent, then we need to allocate another +extent_status with ext4_es_alloc_extent(). + + use old to remove to add new + |----------|------------|------------| + old extent_status + +The problem is that the allocation of a new extent_status failed due to a +fault injection, and __es_shrink() did not get free memory, resulting in +a return of -ENOMEM. Then do_writepages() retries after receiving -ENOMEM, +we map to the same extent again, and the number of reserved blocks is again +subtracted from the number of blocks in that extent. Since the blocks in +the same extent are subtracted twice, we end up triggering WARN_ON at +ext4_da_update_reserve_space() because used > ei->i_reserved_data_blocks. + +For non-extent based file, we update the number of reserved blocks after +ext4_ind_map_blocks() is executed, which causes a problem that when we call +ext4_ind_map_blocks() to create a block, it doesn't always create a block, +but we always reduce the number of reserved blocks. So we move the logic +for updating reserved blocks to ext4_ind_map_blocks() to ensure that the +number of reserved blocks is updated only after we do succeed in allocating +some new blocks. + +Fixes: 5f634d064c70 ("ext4: Fix quota accounting error with fallocate") +Cc: stable@kernel.org +Signed-off-by: Baokun Li +Reviewed-by: Jan Kara +Link: https://lore.kernel.org/r/20230424033846.4732-2-libaokun1@huawei.com +Signed-off-by: Theodore Ts'o +Signed-off-by: Greg Kroah-Hartman +--- + fs/ext4/indirect.c | 8 ++++++++ + fs/ext4/inode.c | 10 ---------- + 2 files changed, 8 insertions(+), 10 deletions(-) + +--- a/fs/ext4/indirect.c ++++ b/fs/ext4/indirect.c +@@ -651,6 +651,14 @@ int ext4_ind_map_blocks(handle_t *handle + + ext4_update_inode_fsync_trans(handle, inode, 1); + count = ar.len; ++ ++ /* ++ * Update reserved blocks/metadata blocks after successful block ++ * allocation which had been deferred till now. ++ */ ++ if (flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE) ++ ext4_da_update_reserve_space(inode, count, 1); ++ + got_it: + map->m_flags |= EXT4_MAP_MAPPED; + map->m_pblk = le32_to_cpu(chain[depth-1].key); +--- a/fs/ext4/inode.c ++++ b/fs/ext4/inode.c +@@ -632,16 +632,6 @@ found: + */ + ext4_clear_inode_state(inode, EXT4_STATE_EXT_MIGRATE); + } +- +- /* +- * Update reserved blocks/metadata blocks after successful +- * block allocation which had been deferred till now. We don't +- * support fallocate for non extent files. So we can update +- * reserve space here. +- */ +- if ((retval > 0) && +- (flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE)) +- ext4_da_update_reserve_space(inode, retval, 1); + } + + if (retval > 0) { diff --git a/queue-6.4/ext4-turn-quotas-off-if-mount-failed-after-enabling-quotas.patch b/queue-6.4/ext4-turn-quotas-off-if-mount-failed-after-enabling-quotas.patch new file mode 100644 index 00000000000..1ae676fbd0b --- /dev/null +++ b/queue-6.4/ext4-turn-quotas-off-if-mount-failed-after-enabling-quotas.patch @@ -0,0 +1,76 @@ +From d13f99632748462c32fc95d729f5e754bab06064 Mon Sep 17 00:00:00 2001 +From: Baokun Li +Date: Mon, 27 Mar 2023 22:16:29 +0800 +Subject: ext4: turn quotas off if mount failed after enabling quotas + +From: Baokun Li + +commit d13f99632748462c32fc95d729f5e754bab06064 upstream. + +Yi found during a review of the patch "ext4: don't BUG on inconsistent +journal feature" that when ext4_mark_recovery_complete() returns an error +value, the error handling path does not turn off the enabled quotas, +which triggers the following kmemleak: + +================================================================ +unreferenced object 0xffff8cf68678e7c0 (size 64): +comm "mount", pid 746, jiffies 4294871231 (age 11.540s) +hex dump (first 32 bytes): +00 90 ef 82 f6 8c ff ff 00 00 00 00 41 01 00 00 ............A... +c7 00 00 00 bd 00 00 00 0a 00 00 00 48 00 00 00 ............H... +backtrace: +[<00000000c561ef24>] __kmem_cache_alloc_node+0x4d4/0x880 +[<00000000d4e621d7>] kmalloc_trace+0x39/0x140 +[<00000000837eee74>] v2_read_file_info+0x18a/0x3a0 +[<0000000088f6c877>] dquot_load_quota_sb+0x2ed/0x770 +[<00000000340a4782>] dquot_load_quota_inode+0xc6/0x1c0 +[<0000000089a18bd5>] ext4_enable_quotas+0x17e/0x3a0 [ext4] +[<000000003a0268fa>] __ext4_fill_super+0x3448/0x3910 [ext4] +[<00000000b0f2a8a8>] ext4_fill_super+0x13d/0x340 [ext4] +[<000000004a9489c4>] get_tree_bdev+0x1dc/0x370 +[<000000006e723bf1>] ext4_get_tree+0x1d/0x30 [ext4] +[<00000000c7cb663d>] vfs_get_tree+0x31/0x160 +[<00000000320e1bed>] do_new_mount+0x1d5/0x480 +[<00000000c074654c>] path_mount+0x22e/0xbe0 +[<0000000003e97a8e>] do_mount+0x95/0xc0 +[<000000002f3d3736>] __x64_sys_mount+0xc4/0x160 +[<0000000027d2140c>] do_syscall_64+0x3f/0x90 +================================================================ + +To solve this problem, we add a "failed_mount10" tag, and call +ext4_quota_off_umount() in this tag to release the enabled qoutas. + +Fixes: 11215630aada ("ext4: don't BUG on inconsistent journal feature") +Cc: stable@kernel.org +Signed-off-by: Zhang Yi +Signed-off-by: Baokun Li +Reviewed-by: Jan Kara +Link: https://lore.kernel.org/r/20230327141630.156875-2-libaokun1@huawei.com +Signed-off-by: Theodore Ts'o +Signed-off-by: Greg Kroah-Hartman +--- + fs/ext4/super.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +--- a/fs/ext4/super.c ++++ b/fs/ext4/super.c +@@ -5567,7 +5567,7 @@ static int __ext4_fill_super(struct fs_c + ext4_msg(sb, KERN_INFO, "recovery complete"); + err = ext4_mark_recovery_complete(sb, es); + if (err) +- goto failed_mount9; ++ goto failed_mount10; + } + + if (test_opt(sb, DISCARD) && !bdev_max_discard_sectors(sb->s_bdev)) +@@ -5586,7 +5586,9 @@ static int __ext4_fill_super(struct fs_c + + return 0; + +-failed_mount9: ++failed_mount10: ++ ext4_quota_off_umount(sb); ++failed_mount9: __maybe_unused + ext4_release_orphan_info(sb); + failed_mount8: + ext4_unregister_sysfs(sb); diff --git a/queue-6.4/fs-dlm-revert-check-required-context-while-close.patch b/queue-6.4/fs-dlm-revert-check-required-context-while-close.patch new file mode 100644 index 00000000000..dd39bb93f06 --- /dev/null +++ b/queue-6.4/fs-dlm-revert-check-required-context-while-close.patch @@ -0,0 +1,81 @@ +From c6b6d6dcc7f32767d57740e0552337c8de40610b Mon Sep 17 00:00:00 2001 +From: Alexander Aring +Date: Mon, 29 May 2023 17:44:29 -0400 +Subject: fs: dlm: revert check required context while close + +From: Alexander Aring + +commit c6b6d6dcc7f32767d57740e0552337c8de40610b upstream. + +This patch reverts commit 2c3fa6ae4d52 ("dlm: check required context +while close"). The function dlm_midcomms_close(), which will call later +dlm_lowcomms_close(), is called when the cluster manager tells the node +got fenced which means on midcomms/lowcomms layer to disconnect the node +from the cluster communication. The node can rejoin the cluster later. +This patch was ensuring no new message were able to be triggered when we +are in the close() function context. This was done by checking if the +lockspace has been stopped. However there is a missing check that we +only need to check specific lockspaces where the fenced node is member +of. This is currently complicated because there is no way to easily +check if a node is part of a specific lockspace without stopping the +recovery. For now we just revert this commit as it is just a check to +finding possible leaks of stopping lockspaces before close() is called. + +Cc: stable@vger.kernel.org +Fixes: 2c3fa6ae4d52 ("dlm: check required context while close") +Signed-off-by: Alexander Aring +Signed-off-by: David Teigland +Signed-off-by: Greg Kroah-Hartman +--- + fs/dlm/lockspace.c | 12 ------------ + fs/dlm/lockspace.h | 1 - + fs/dlm/midcomms.c | 3 --- + 3 files changed, 16 deletions(-) + +--- a/fs/dlm/lockspace.c ++++ b/fs/dlm/lockspace.c +@@ -935,15 +935,3 @@ void dlm_stop_lockspaces(void) + log_print("dlm user daemon left %d lockspaces", count); + } + +-void dlm_stop_lockspaces_check(void) +-{ +- struct dlm_ls *ls; +- +- spin_lock(&lslist_lock); +- list_for_each_entry(ls, &lslist, ls_list) { +- if (WARN_ON(!rwsem_is_locked(&ls->ls_in_recovery) || +- !dlm_locking_stopped(ls))) +- break; +- } +- spin_unlock(&lslist_lock); +-} +--- a/fs/dlm/lockspace.h ++++ b/fs/dlm/lockspace.h +@@ -27,7 +27,6 @@ struct dlm_ls *dlm_find_lockspace_local( + struct dlm_ls *dlm_find_lockspace_device(int minor); + void dlm_put_lockspace(struct dlm_ls *ls); + void dlm_stop_lockspaces(void); +-void dlm_stop_lockspaces_check(void); + int dlm_new_user_lockspace(const char *name, const char *cluster, + uint32_t flags, int lvblen, + const struct dlm_lockspace_ops *ops, +--- a/fs/dlm/midcomms.c ++++ b/fs/dlm/midcomms.c +@@ -136,7 +136,6 @@ + #include + + #include "dlm_internal.h" +-#include "lockspace.h" + #include "lowcomms.h" + #include "config.h" + #include "memory.h" +@@ -1491,8 +1490,6 @@ int dlm_midcomms_close(int nodeid) + if (nodeid == dlm_our_nodeid()) + return 0; + +- dlm_stop_lockspaces_check(); +- + idx = srcu_read_lock(&nodes_srcu); + /* Abort pending close/remove operation */ + node = nodeid2node(nodeid, 0); diff --git a/queue-6.4/hwrng-imx-rngc-fix-the-timeout-for-init-and-self-check.patch b/queue-6.4/hwrng-imx-rngc-fix-the-timeout-for-init-and-self-check.patch new file mode 100644 index 00000000000..5b05790584c --- /dev/null +++ b/queue-6.4/hwrng-imx-rngc-fix-the-timeout-for-init-and-self-check.patch @@ -0,0 +1,45 @@ +From d744ae7477190967a3ddc289e2cd4ae59e8b1237 Mon Sep 17 00:00:00 2001 +From: Martin Kaiser +Date: Thu, 15 Jun 2023 15:49:59 +0100 +Subject: hwrng: imx-rngc - fix the timeout for init and self check + +From: Martin Kaiser + +commit d744ae7477190967a3ddc289e2cd4ae59e8b1237 upstream. + +Fix the timeout that is used for the initialisation and for the self +test. wait_for_completion_timeout expects a timeout in jiffies, but +RNGC_TIMEOUT is in milliseconds. Call msecs_to_jiffies to do the +conversion. + +Cc: stable@vger.kernel.org +Fixes: 1d5449445bd0 ("hwrng: mx-rngc - add a driver for Freescale RNGC") +Signed-off-by: Martin Kaiser +Signed-off-by: Herbert Xu +Signed-off-by: Greg Kroah-Hartman +--- + drivers/char/hw_random/imx-rngc.c | 6 ++---- + 1 file changed, 2 insertions(+), 4 deletions(-) + +--- a/drivers/char/hw_random/imx-rngc.c ++++ b/drivers/char/hw_random/imx-rngc.c +@@ -110,7 +110,7 @@ static int imx_rngc_self_test(struct imx + cmd = readl(rngc->base + RNGC_COMMAND); + writel(cmd | RNGC_CMD_SELF_TEST, rngc->base + RNGC_COMMAND); + +- ret = wait_for_completion_timeout(&rngc->rng_op_done, RNGC_TIMEOUT); ++ ret = wait_for_completion_timeout(&rngc->rng_op_done, msecs_to_jiffies(RNGC_TIMEOUT)); + imx_rngc_irq_mask_clear(rngc); + if (!ret) + return -ETIMEDOUT; +@@ -187,9 +187,7 @@ static int imx_rngc_init(struct hwrng *r + cmd = readl(rngc->base + RNGC_COMMAND); + writel(cmd | RNGC_CMD_SEED, rngc->base + RNGC_COMMAND); + +- ret = wait_for_completion_timeout(&rngc->rng_op_done, +- RNGC_TIMEOUT); +- ++ ret = wait_for_completion_timeout(&rngc->rng_op_done, msecs_to_jiffies(RNGC_TIMEOUT)); + if (!ret) { + ret = -ETIMEDOUT; + goto err; diff --git a/queue-6.4/jfs-jfs_dmap-validate-db_l2nbperpage-while-mounting.patch b/queue-6.4/jfs-jfs_dmap-validate-db_l2nbperpage-while-mounting.patch new file mode 100644 index 00000000000..00fec96e551 --- /dev/null +++ b/queue-6.4/jfs-jfs_dmap-validate-db_l2nbperpage-while-mounting.patch @@ -0,0 +1,66 @@ +From 11509910c599cbd04585ec35a6d5e1a0053d84c1 Mon Sep 17 00:00:00 2001 +From: Siddh Raman Pant +Date: Tue, 20 Jun 2023 22:17:00 +0530 +Subject: jfs: jfs_dmap: Validate db_l2nbperpage while mounting + +From: Siddh Raman Pant + +commit 11509910c599cbd04585ec35a6d5e1a0053d84c1 upstream. + +In jfs_dmap.c at line 381, BLKTODMAP is used to get a logical block +number inside dbFree(). db_l2nbperpage, which is the log2 number of +blocks per page, is passed as an argument to BLKTODMAP which uses it +for shifting. + +Syzbot reported a shift out-of-bounds crash because db_l2nbperpage is +too big. This happens because the large value is set without any +validation in dbMount() at line 181. + +Thus, make sure that db_l2nbperpage is correct while mounting. + +Max number of blocks per page = Page size / Min block size +=> log2(Max num_block per page) = log2(Page size / Min block size) + = log2(Page size) - log2(Min block size) + +=> Max db_l2nbperpage = L2PSIZE - L2MINBLOCKSIZE + +Reported-and-tested-by: syzbot+d2cd27dcf8e04b232eb2@syzkaller.appspotmail.com +Closes: https://syzkaller.appspot.com/bug?id=2a70a453331db32ed491f5cbb07e81bf2d225715 +Cc: stable@vger.kernel.org +Suggested-by: Dave Kleikamp +Signed-off-by: Siddh Raman Pant +Signed-off-by: Dave Kleikamp +Signed-off-by: Greg Kroah-Hartman +--- + fs/jfs/jfs_dmap.c | 6 ++++++ + fs/jfs/jfs_filsys.h | 2 ++ + 2 files changed, 8 insertions(+) + +--- a/fs/jfs/jfs_dmap.c ++++ b/fs/jfs/jfs_dmap.c +@@ -178,7 +178,13 @@ int dbMount(struct inode *ipbmap) + dbmp_le = (struct dbmap_disk *) mp->data; + bmp->db_mapsize = le64_to_cpu(dbmp_le->dn_mapsize); + bmp->db_nfree = le64_to_cpu(dbmp_le->dn_nfree); ++ + bmp->db_l2nbperpage = le32_to_cpu(dbmp_le->dn_l2nbperpage); ++ if (bmp->db_l2nbperpage > L2PSIZE - L2MINBLOCKSIZE) { ++ err = -EINVAL; ++ goto err_release_metapage; ++ } ++ + bmp->db_numag = le32_to_cpu(dbmp_le->dn_numag); + if (!bmp->db_numag) { + err = -EINVAL; +--- a/fs/jfs/jfs_filsys.h ++++ b/fs/jfs/jfs_filsys.h +@@ -122,7 +122,9 @@ + #define NUM_INODE_PER_IAG INOSPERIAG + + #define MINBLOCKSIZE 512 ++#define L2MINBLOCKSIZE 9 + #define MAXBLOCKSIZE 4096 ++#define L2MAXBLOCKSIZE 12 + #define MAXFILESIZE ((s64)1 << 52) + + #define JFS_LINK_MAX 0xffffffff diff --git a/queue-6.4/mm-mmap-fix-error-return-in-do_vmi_align_munmap.patch b/queue-6.4/mm-mmap-fix-error-return-in-do_vmi_align_munmap.patch new file mode 100644 index 00000000000..7a685eeaaf3 --- /dev/null +++ b/queue-6.4/mm-mmap-fix-error-return-in-do_vmi_align_munmap.patch @@ -0,0 +1,65 @@ +From 6c26bd4384da24841bac4f067741bbca18b0fb74 Mon Sep 17 00:00:00 2001 +From: David Woodhouse +Date: Wed, 28 Jun 2023 10:55:03 +0100 +Subject: mm/mmap: Fix error return in do_vmi_align_munmap() +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: David Woodhouse + +commit 6c26bd4384da24841bac4f067741bbca18b0fb74 upstream. + +If mas_store_gfp() in the gather loop failed, the 'error' variable that +ultimately gets returned was not being set. In many cases, its original +value of -ENOMEM was still in place, and that was fine. But if VMAs had +been split at the start or end of the range, then 'error' could be zero. + +Change to the 'error = foo(); if (error) goto …' idiom to fix the bug. + +Also clean up a later case which avoided the same bug by *explicitly* +setting error = -ENOMEM right before calling the function that might +return -ENOMEM. + +In a final cosmetic change, move the 'Point of no return' comment to +*after* the goto. That's been in the wrong place since the preallocation +was removed, and this new error path was added. + +Fixes: 606c812eb1d5 ("mm/mmap: Fix error path in do_vmi_align_munmap()") +Signed-off-by: David Woodhouse +Cc: stable@vger.kernel.org +Reviewed-by: Greg Kroah-Hartman +Reviewed-by: Liam R. Howlett +Signed-off-by: Greg Kroah-Hartman +--- + mm/mmap.c | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +--- a/mm/mmap.c ++++ b/mm/mmap.c +@@ -2480,7 +2480,8 @@ do_vmi_align_munmap(struct vma_iterator + } + vma_start_write(next); + mas_set_range(&mas_detach, next->vm_start, next->vm_end - 1); +- if (mas_store_gfp(&mas_detach, next, GFP_KERNEL)) ++ error = mas_store_gfp(&mas_detach, next, GFP_KERNEL); ++ if (error) + goto munmap_gather_failed; + vma_mark_detached(next, true); + if (next->vm_flags & VM_LOCKED) +@@ -2529,12 +2530,12 @@ do_vmi_align_munmap(struct vma_iterator + BUG_ON(count != test_count); + } + #endif +- /* Point of no return */ +- error = -ENOMEM; + vma_iter_set(vmi, start); +- if (vma_iter_clear_gfp(vmi, start, end, GFP_KERNEL)) ++ error = vma_iter_clear_gfp(vmi, start, end, GFP_KERNEL); ++ if (error) + goto clear_tree_failed; + ++ /* Point of no return */ + mm->locked_vm -= locked_vm; + mm->map_count -= count; + /* diff --git a/queue-6.4/pci-acpiphp-reassign-resources-on-bridge-if-necessary.patch b/queue-6.4/pci-acpiphp-reassign-resources-on-bridge-if-necessary.patch new file mode 100644 index 00000000000..c68d90eda33 --- /dev/null +++ b/queue-6.4/pci-acpiphp-reassign-resources-on-bridge-if-necessary.patch @@ -0,0 +1,78 @@ +From 40613da52b13fb21c5566f10b287e0ca8c12c4e9 Mon Sep 17 00:00:00 2001 +From: Igor Mammedov +Date: Mon, 24 Apr 2023 21:15:57 +0200 +Subject: PCI: acpiphp: Reassign resources on bridge if necessary + +From: Igor Mammedov + +commit 40613da52b13fb21c5566f10b287e0ca8c12c4e9 upstream. + +When using ACPI PCI hotplug, hotplugging a device with large BARs may fail +if bridge windows programmed by firmware are not large enough. + +Reproducer: + $ qemu-kvm -monitor stdio -M q35 -m 4G \ + -global ICH9-LPC.acpi-pci-hotplug-with-bridge-support=on \ + -device id=rp1,pcie-root-port,bus=pcie.0,chassis=4 \ + disk_image + + wait till linux guest boots, then hotplug device: + (qemu) device_add qxl,bus=rp1 + + hotplug on guest side fails with: + pci 0000:01:00.0: [1b36:0100] type 00 class 0x038000 + pci 0000:01:00.0: reg 0x10: [mem 0x00000000-0x03ffffff] + pci 0000:01:00.0: reg 0x14: [mem 0x00000000-0x03ffffff] + pci 0000:01:00.0: reg 0x18: [mem 0x00000000-0x00001fff] + pci 0000:01:00.0: reg 0x1c: [io 0x0000-0x001f] + pci 0000:01:00.0: BAR 0: no space for [mem size 0x04000000] + pci 0000:01:00.0: BAR 0: failed to assign [mem size 0x04000000] + pci 0000:01:00.0: BAR 1: no space for [mem size 0x04000000] + pci 0000:01:00.0: BAR 1: failed to assign [mem size 0x04000000] + pci 0000:01:00.0: BAR 2: assigned [mem 0xfe800000-0xfe801fff] + pci 0000:01:00.0: BAR 3: assigned [io 0x1000-0x101f] + qxl 0000:01:00.0: enabling device (0000 -> 0003) + Unable to create vram_mapping + qxl: probe of 0000:01:00.0 failed with error -12 + +However when using native PCIe hotplug + '-global ICH9-LPC.acpi-pci-hotplug-with-bridge-support=off' +it works fine, since kernel attempts to reassign unused resources. + +Use the same machinery as native PCIe hotplug to (re)assign resources. + +Link: https://lore.kernel.org/r/20230424191557.2464760-1-imammedo@redhat.com +Signed-off-by: Igor Mammedov +Signed-off-by: Bjorn Helgaas +Acked-by: Michael S. Tsirkin +Acked-by: Rafael J. Wysocki +Cc: stable@vger.kernel.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/pci/hotplug/acpiphp_glue.c | 5 +---- + 1 file changed, 1 insertion(+), 4 deletions(-) + +--- a/drivers/pci/hotplug/acpiphp_glue.c ++++ b/drivers/pci/hotplug/acpiphp_glue.c +@@ -498,7 +498,6 @@ static void enable_slot(struct acpiphp_s + acpiphp_native_scan_bridge(dev); + } + } else { +- LIST_HEAD(add_list); + int max, pass; + + acpiphp_rescan_slot(slot); +@@ -512,12 +511,10 @@ static void enable_slot(struct acpiphp_s + if (pass && dev->subordinate) { + check_hotplug_bridge(slot, dev); + pcibios_resource_survey_bus(dev->subordinate); +- __pci_bus_size_bridges(dev->subordinate, +- &add_list); + } + } + } +- __pci_bus_assign_resources(bus, &add_list, NULL); ++ pci_assign_unassigned_bridge_resources(bus->self); + } + + acpiphp_sanitize_bus(bus); diff --git a/queue-6.4/pci-add-function-1-dma-alias-quirk-for-marvell-88se9235.patch b/queue-6.4/pci-add-function-1-dma-alias-quirk-for-marvell-88se9235.patch new file mode 100644 index 00000000000..f80cf77ae43 --- /dev/null +++ b/queue-6.4/pci-add-function-1-dma-alias-quirk-for-marvell-88se9235.patch @@ -0,0 +1,36 @@ +From 88d341716b83abd355558523186ca488918627ee Mon Sep 17 00:00:00 2001 +From: Robin Murphy +Date: Wed, 7 Jun 2023 18:18:47 +0100 +Subject: PCI: Add function 1 DMA alias quirk for Marvell 88SE9235 + +From: Robin Murphy + +commit 88d341716b83abd355558523186ca488918627ee upstream. + +Marvell's own product brief implies the 92xx series are a closely related +family, and sure enough it turns out that 9235 seems to need the same quirk +as the other three, although possibly only when certain ports are used. + +Link: https://lore.kernel.org/linux-iommu/2a699a99-545c-1324-e052-7d2f41fed1ae@yahoo.co.uk/ +Link: https://lore.kernel.org/r/731507e05d70239aec96fcbfab6e65d8ce00edd2.1686157165.git.robin.murphy@arm.com +Reported-by: Jason Adriaanse +Signed-off-by: Robin Murphy +Signed-off-by: Bjorn Helgaas +Reviewed-by: Christoph Hellwig +Cc: stable@vger.kernel.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/pci/quirks.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/drivers/pci/quirks.c ++++ b/drivers/pci/quirks.c +@@ -4174,6 +4174,8 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_M + /* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c49 */ + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9230, + quirk_dma_func1_alias); ++DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9235, ++ quirk_dma_func1_alias); + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TTI, 0x0642, + quirk_dma_func1_alias); + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TTI, 0x0645, diff --git a/queue-6.4/pci-epf-test-fix-dma-transfer-completion-detection.patch b/queue-6.4/pci-epf-test-fix-dma-transfer-completion-detection.patch new file mode 100644 index 00000000000..c1d8e1f62ae --- /dev/null +++ b/queue-6.4/pci-epf-test-fix-dma-transfer-completion-detection.patch @@ -0,0 +1,116 @@ +From 933f31a2fe1f20e5b1ee065579f652cd1b317183 Mon Sep 17 00:00:00 2001 +From: Damien Le Moal +Date: Sat, 15 Apr 2023 11:35:29 +0900 +Subject: PCI: epf-test: Fix DMA transfer completion detection + +From: Damien Le Moal + +commit 933f31a2fe1f20e5b1ee065579f652cd1b317183 upstream. + +pci_epf_test_data_transfer() and pci_epf_test_dma_callback() are not +handling DMA transfer completion correctly, leading to completion +notifications to the RC side that are too early. This problem can be +detected when the RC side is running an IOMMU with messages such as: + + pci-endpoint-test 0000:0b:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x001c address=0xfff00000 flags=0x0000] + +When running the pcitest.sh tests: the address used for a previous +test transfer generates the above error while the next test transfer is +running. + +Fix this by testing the DMA transfer status in pci_epf_test_dma_callback() +and notifying the completion only when the transfer status is DMA_COMPLETE +or DMA_ERROR. Furthermore, in pci_epf_test_data_transfer(), be paranoid and +check again the transfer status and always call dmaengine_terminate_sync() +before returning. + +Link: https://lore.kernel.org/r/20230415023542.77601-5-dlemoal@kernel.org +Fixes: 8353813c88ef ("PCI: endpoint: Enable DMA tests for endpoints with DMA capabilities") +Signed-off-by: Damien Le Moal +Signed-off-by: Lorenzo Pieralisi +Signed-off-by: Bjorn Helgaas +Reviewed-by: Manivannan Sadhasivam +Cc: stable@vger.kernel.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/pci/endpoint/functions/pci-epf-test.c | 36 ++++++++++++++++++-------- + 1 file changed, 26 insertions(+), 10 deletions(-) + +--- a/drivers/pci/endpoint/functions/pci-epf-test.c ++++ b/drivers/pci/endpoint/functions/pci-epf-test.c +@@ -54,6 +54,9 @@ struct pci_epf_test { + struct delayed_work cmd_handler; + struct dma_chan *dma_chan_tx; + struct dma_chan *dma_chan_rx; ++ struct dma_chan *transfer_chan; ++ dma_cookie_t transfer_cookie; ++ enum dma_status transfer_status; + struct completion transfer_complete; + bool dma_supported; + bool dma_private; +@@ -85,8 +88,14 @@ static size_t bar_size[] = { 512, 512, 1 + static void pci_epf_test_dma_callback(void *param) + { + struct pci_epf_test *epf_test = param; ++ struct dma_tx_state state; + +- complete(&epf_test->transfer_complete); ++ epf_test->transfer_status = ++ dmaengine_tx_status(epf_test->transfer_chan, ++ epf_test->transfer_cookie, &state); ++ if (epf_test->transfer_status == DMA_COMPLETE || ++ epf_test->transfer_status == DMA_ERROR) ++ complete(&epf_test->transfer_complete); + } + + /** +@@ -120,7 +129,6 @@ static int pci_epf_test_data_transfer(st + struct dma_async_tx_descriptor *tx; + struct dma_slave_config sconf = {}; + struct device *dev = &epf->dev; +- dma_cookie_t cookie; + int ret; + + if (IS_ERR_OR_NULL(chan)) { +@@ -152,25 +160,33 @@ static int pci_epf_test_data_transfer(st + } + + reinit_completion(&epf_test->transfer_complete); ++ epf_test->transfer_chan = chan; + tx->callback = pci_epf_test_dma_callback; + tx->callback_param = epf_test; +- cookie = tx->tx_submit(tx); ++ epf_test->transfer_cookie = tx->tx_submit(tx); + +- ret = dma_submit_error(cookie); ++ ret = dma_submit_error(epf_test->transfer_cookie); + if (ret) { +- dev_err(dev, "Failed to do DMA tx_submit %d\n", cookie); +- return -EIO; ++ dev_err(dev, "Failed to do DMA tx_submit %d\n", ret); ++ goto terminate; + } + + dma_async_issue_pending(chan); + ret = wait_for_completion_interruptible(&epf_test->transfer_complete); + if (ret < 0) { +- dmaengine_terminate_sync(chan); +- dev_err(dev, "DMA wait_for_completion_timeout\n"); +- return -ETIMEDOUT; ++ dev_err(dev, "DMA wait_for_completion interrupted\n"); ++ goto terminate; ++ } ++ ++ if (epf_test->transfer_status == DMA_ERROR) { ++ dev_err(dev, "DMA transfer failed\n"); ++ ret = -EIO; + } + +- return 0; ++terminate: ++ dmaengine_terminate_sync(chan); ++ ++ return ret; + } + + struct epf_dma_filter { diff --git a/queue-6.4/pci-epf-test-fix-dma-transfer-completion-initialization.patch b/queue-6.4/pci-epf-test-fix-dma-transfer-completion-initialization.patch new file mode 100644 index 00000000000..ae009ebdcb4 --- /dev/null +++ b/queue-6.4/pci-epf-test-fix-dma-transfer-completion-initialization.patch @@ -0,0 +1,40 @@ +From 4aca56f8eae8aa44867ddd6aa107e06f7613226f Mon Sep 17 00:00:00 2001 +From: Damien Le Moal +Date: Sat, 15 Apr 2023 11:35:28 +0900 +Subject: PCI: epf-test: Fix DMA transfer completion initialization + +From: Damien Le Moal + +commit 4aca56f8eae8aa44867ddd6aa107e06f7613226f upstream. + +Reinitialize the transfer_complete DMA transfer completion before calling +tx_submit(), to avoid seeing the DMA transfer complete before the +completion is initialized, thus potentially losing the completion +notification. + +Link: https://lore.kernel.org/r/20230415023542.77601-4-dlemoal@kernel.org +Fixes: 8353813c88ef ("PCI: endpoint: Enable DMA tests for endpoints with DMA capabilities") +Signed-off-by: Damien Le Moal +Signed-off-by: Lorenzo Pieralisi +Signed-off-by: Bjorn Helgaas +Reviewed-by: Manivannan Sadhasivam +Cc: stable@vger.kernel.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/pci/endpoint/functions/pci-epf-test.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/pci/endpoint/functions/pci-epf-test.c ++++ b/drivers/pci/endpoint/functions/pci-epf-test.c +@@ -151,10 +151,10 @@ static int pci_epf_test_data_transfer(st + return -EIO; + } + ++ reinit_completion(&epf_test->transfer_complete); + tx->callback = pci_epf_test_dma_callback; + tx->callback_param = epf_test; + cookie = tx->tx_submit(tx); +- reinit_completion(&epf_test->transfer_complete); + + ret = dma_submit_error(cookie); + if (ret) { diff --git a/queue-6.4/pci-pm-avoid-putting-elopos-e2-s2-h2-pcie-ports-in-d3cold.patch b/queue-6.4/pci-pm-avoid-putting-elopos-e2-s2-h2-pcie-ports-in-d3cold.patch new file mode 100644 index 00000000000..fc3bbfefc55 --- /dev/null +++ b/queue-6.4/pci-pm-avoid-putting-elopos-e2-s2-h2-pcie-ports-in-d3cold.patch @@ -0,0 +1,46 @@ +From 9e30fd26f43b89cb6b4e850a86caa2e50dedb454 Mon Sep 17 00:00:00 2001 +From: Ondrej Zary +Date: Wed, 14 Jun 2023 09:42:53 +0200 +Subject: PCI/PM: Avoid putting EloPOS E2/S2/H2 PCIe Ports in D3cold + +From: Ondrej Zary + +commit 9e30fd26f43b89cb6b4e850a86caa2e50dedb454 upstream. + +The quirk for Elo i2 introduced in commit 92597f97a40b ("PCI/PM: Avoid +putting Elo i2 PCIe Ports in D3cold") is also needed by EloPOS E2/S2/H2 +which uses the same Continental Z2 board. + +Change the quirk to match the board instead of system. + +Link: https://bugzilla.kernel.org/show_bug.cgi?id=215715 +Link: https://lore.kernel.org/r/20230614074253.22318-1-linux@zary.sk +Signed-off-by: Ondrej Zary +Signed-off-by: Bjorn Helgaas +Cc: stable@vger.kernel.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/pci/pci.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +--- a/drivers/pci/pci.c ++++ b/drivers/pci/pci.c +@@ -2949,13 +2949,13 @@ static const struct dmi_system_id bridge + { + /* + * Downstream device is not accessible after putting a root port +- * into D3cold and back into D0 on Elo i2. ++ * into D3cold and back into D0 on Elo Continental Z2 board + */ +- .ident = "Elo i2", ++ .ident = "Elo Continental Z2", + .matches = { +- DMI_MATCH(DMI_SYS_VENDOR, "Elo Touch Solutions"), +- DMI_MATCH(DMI_PRODUCT_NAME, "Elo i2"), +- DMI_MATCH(DMI_PRODUCT_VERSION, "RevB"), ++ DMI_MATCH(DMI_BOARD_VENDOR, "Elo Touch Solutions"), ++ DMI_MATCH(DMI_BOARD_NAME, "Geminilake"), ++ DMI_MATCH(DMI_BOARD_VERSION, "Continental Z2"), + }, + }, + #endif diff --git a/queue-6.4/pci-qcom-disable-write-access-to-read-only-registers-for-ip-v2.3.3.patch b/queue-6.4/pci-qcom-disable-write-access-to-read-only-registers-for-ip-v2.3.3.patch new file mode 100644 index 00000000000..888d6852a73 --- /dev/null +++ b/queue-6.4/pci-qcom-disable-write-access-to-read-only-registers-for-ip-v2.3.3.patch @@ -0,0 +1,34 @@ +From a33d700e8eea76c62120cb3dbf5e01328f18319a Mon Sep 17 00:00:00 2001 +From: Manivannan Sadhasivam +Date: Mon, 19 Jun 2023 20:34:00 +0530 +Subject: PCI: qcom: Disable write access to read only registers for IP v2.3.3 + +From: Manivannan Sadhasivam + +commit a33d700e8eea76c62120cb3dbf5e01328f18319a upstream. + +In the post init sequence of v2.9.0, write access to read only registers +are not disabled after updating the registers. Fix it by disabling the +access after register update. + +Link: https://lore.kernel.org/r/20230619150408.8468-2-manivannan.sadhasivam@linaro.org +Fixes: 5d76117f070d ("PCI: qcom: Add support for IPQ8074 PCIe controller") +Signed-off-by: Manivannan Sadhasivam +Signed-off-by: Lorenzo Pieralisi +Cc: +Signed-off-by: Greg Kroah-Hartman +--- + drivers/pci/controller/dwc/pcie-qcom.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/drivers/pci/controller/dwc/pcie-qcom.c ++++ b/drivers/pci/controller/dwc/pcie-qcom.c +@@ -834,6 +834,8 @@ static int qcom_pcie_post_init_2_3_3(str + writel(PCI_EXP_DEVCTL2_COMP_TMOUT_DIS, pci->dbi_base + offset + + PCI_EXP_DEVCTL2); + ++ dw_pcie_dbi_ro_wr_dis(pci); ++ + return 0; + } + diff --git a/queue-6.4/pci-release-resource-invalidated-by-coalescing.patch b/queue-6.4/pci-release-resource-invalidated-by-coalescing.patch new file mode 100644 index 00000000000..0bb72e57163 --- /dev/null +++ b/queue-6.4/pci-release-resource-invalidated-by-coalescing.patch @@ -0,0 +1,55 @@ +From e54223275ba1bc6f704a6bab015fcd2ae4f72572 Mon Sep 17 00:00:00 2001 +From: Ross Lagerwall +Date: Thu, 25 May 2023 16:32:48 +0100 +Subject: PCI: Release resource invalidated by coalescing + +From: Ross Lagerwall + +commit e54223275ba1bc6f704a6bab015fcd2ae4f72572 upstream. + +When contiguous windows are coalesced by pci_register_host_bridge(), the +second resource is expanded to include the first, and the first is +invalidated and consequently not added to the bus. However, it remains in +the resource hierarchy. For example, these windows: + + fec00000-fec7ffff : PCI Bus 0000:00 + fec80000-fecbffff : PCI Bus 0000:00 + +are coalesced into this, where the first resource remains in the tree with +start/end zeroed out: + + 00000000-00000000 : PCI Bus 0000:00 + fec00000-fecbffff : PCI Bus 0000:00 + +In some cases (e.g. the Xen scratch region), this causes future calls to +allocate_resource() to choose an inappropriate location which the caller +cannot handle. + +Fix by releasing the zeroed-out resource and removing it from the resource +hierarchy. + +[bhelgaas: commit log] +Fixes: 7c3855c423b1 ("PCI: Coalesce host bridge contiguous apertures") +Link: https://lore.kernel.org/r/20230525153248.712779-1-ross.lagerwall@citrix.com +Signed-off-by: Ross Lagerwall +Signed-off-by: Bjorn Helgaas +Cc: stable@vger.kernel.org # v5.16+ +Signed-off-by: Greg Kroah-Hartman +--- + drivers/pci/probe.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +--- a/drivers/pci/probe.c ++++ b/drivers/pci/probe.c +@@ -997,8 +997,10 @@ static int pci_register_host_bridge(stru + resource_list_for_each_entry_safe(window, n, &resources) { + offset = window->offset; + res = window->res; +- if (!res->flags && !res->start && !res->end) ++ if (!res->flags && !res->start && !res->end) { ++ release_resource(res); + continue; ++ } + + list_move_tail(&window->node, &bridge->windows); + diff --git a/queue-6.4/pci-rockchip-add-poll-and-timeout-to-wait-for-phy-plls-to-be-locked.patch b/queue-6.4/pci-rockchip-add-poll-and-timeout-to-wait-for-phy-plls-to-be-locked.patch new file mode 100644 index 00000000000..3f599ebc133 --- /dev/null +++ b/queue-6.4/pci-rockchip-add-poll-and-timeout-to-wait-for-phy-plls-to-be-locked.patch @@ -0,0 +1,81 @@ +From 9dd3c7c4c8c3f7f010d9cdb7c3f42506d93c9527 Mon Sep 17 00:00:00 2001 +From: Rick Wertenbroek +Date: Tue, 18 Apr 2023 09:46:51 +0200 +Subject: PCI: rockchip: Add poll and timeout to wait for PHY PLLs to be locked + +From: Rick Wertenbroek + +commit 9dd3c7c4c8c3f7f010d9cdb7c3f42506d93c9527 upstream. + +The RK3399 PCIe controller should wait until the PHY PLLs are locked. +Add poll and timeout to wait for PHY PLLs to be locked. If they cannot +be locked generate error message and jump to error handler. Accessing +registers in the PHY clock domain when PLLs are not locked causes hang +The PHY PLLs status is checked through a side channel register. +This is documented in the TRM section 17.5.8.1 "PCIe Initialization +Sequence". + +Link: https://lore.kernel.org/r/20230418074700.1083505-5-rick.wertenbroek@gmail.com +Fixes: cf590b078391 ("PCI: rockchip: Add EP driver for Rockchip PCIe controller") +Tested-by: Damien Le Moal +Signed-off-by: Rick Wertenbroek +Signed-off-by: Lorenzo Pieralisi +Reviewed-by: Damien Le Moal +Cc: stable@vger.kernel.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/pci/controller/pcie-rockchip.c | 17 +++++++++++++++++ + drivers/pci/controller/pcie-rockchip.h | 2 ++ + 2 files changed, 19 insertions(+) + +--- a/drivers/pci/controller/pcie-rockchip.c ++++ b/drivers/pci/controller/pcie-rockchip.c +@@ -14,6 +14,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -153,6 +154,12 @@ int rockchip_pcie_parse_dt(struct rockch + } + EXPORT_SYMBOL_GPL(rockchip_pcie_parse_dt); + ++#define rockchip_pcie_read_addr(addr) rockchip_pcie_read(rockchip, addr) ++/* 100 ms max wait time for PHY PLLs to lock */ ++#define RK_PHY_PLL_LOCK_TIMEOUT_US 100000 ++/* Sleep should be less than 20ms */ ++#define RK_PHY_PLL_LOCK_SLEEP_US 1000 ++ + int rockchip_pcie_init_port(struct rockchip_pcie *rockchip) + { + struct device *dev = rockchip->dev; +@@ -254,6 +261,16 @@ int rockchip_pcie_init_port(struct rockc + } + } + ++ err = readx_poll_timeout(rockchip_pcie_read_addr, ++ PCIE_CLIENT_SIDE_BAND_STATUS, ++ regs, !(regs & PCIE_CLIENT_PHY_ST), ++ RK_PHY_PLL_LOCK_SLEEP_US, ++ RK_PHY_PLL_LOCK_TIMEOUT_US); ++ if (err) { ++ dev_err(dev, "PHY PLLs could not lock, %d\n", err); ++ goto err_power_off_phy; ++ } ++ + /* + * Please don't reorder the deassert sequence of the following + * four reset pins. +--- a/drivers/pci/controller/pcie-rockchip.h ++++ b/drivers/pci/controller/pcie-rockchip.h +@@ -38,6 +38,8 @@ + #define PCIE_CLIENT_MODE_EP HIWORD_UPDATE(0x0040, 0) + #define PCIE_CLIENT_GEN_SEL_1 HIWORD_UPDATE(0x0080, 0) + #define PCIE_CLIENT_GEN_SEL_2 HIWORD_UPDATE_BIT(0x0080) ++#define PCIE_CLIENT_SIDE_BAND_STATUS (PCIE_CLIENT_BASE + 0x20) ++#define PCIE_CLIENT_PHY_ST BIT(12) + #define PCIE_CLIENT_DEBUG_OUT_0 (PCIE_CLIENT_BASE + 0x3c) + #define PCIE_CLIENT_DEBUG_LTSSM_MASK GENMASK(5, 0) + #define PCIE_CLIENT_DEBUG_LTSSM_L1 0x18 diff --git a/queue-6.4/pci-rockchip-assert-pci-configuration-enable-bit-after-probe.patch b/queue-6.4/pci-rockchip-assert-pci-configuration-enable-bit-after-probe.patch new file mode 100644 index 00000000000..4efbbf440da --- /dev/null +++ b/queue-6.4/pci-rockchip-assert-pci-configuration-enable-bit-after-probe.patch @@ -0,0 +1,40 @@ +From f397fd4ac1fa3afcabd8cee030f953ccaed2a364 Mon Sep 17 00:00:00 2001 +From: Rick Wertenbroek +Date: Tue, 18 Apr 2023 09:46:50 +0200 +Subject: PCI: rockchip: Assert PCI Configuration Enable bit after probe + +From: Rick Wertenbroek + +commit f397fd4ac1fa3afcabd8cee030f953ccaed2a364 upstream. + +Assert PCI Configuration Enable bit after probe. When this bit is left to +0 in the endpoint mode, the RK3399 PCIe endpoint core will generate +configuration request retry status (CRS) messages back to the root complex. +Assert this bit after probe to allow the RK3399 PCIe endpoint core to reply +to configuration requests from the root complex. +This is documented in section 17.5.8.1.2 of the RK3399 TRM. + +Link: https://lore.kernel.org/r/20230418074700.1083505-4-rick.wertenbroek@gmail.com +Fixes: cf590b078391 ("PCI: rockchip: Add EP driver for Rockchip PCIe controller") +Tested-by: Damien Le Moal +Signed-off-by: Rick Wertenbroek +Signed-off-by: Lorenzo Pieralisi +Reviewed-by: Damien Le Moal +Cc: stable@vger.kernel.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/pci/controller/pcie-rockchip-ep.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/drivers/pci/controller/pcie-rockchip-ep.c ++++ b/drivers/pci/controller/pcie-rockchip-ep.c +@@ -631,6 +631,9 @@ static int rockchip_pcie_ep_probe(struct + + ep->irq_pci_addr = ROCKCHIP_PCIE_EP_DUMMY_IRQ_ADDR; + ++ rockchip_pcie_write(rockchip, PCIE_CLIENT_CONF_ENABLE, ++ PCIE_CLIENT_CONFIG); ++ + return 0; + err_epc_mem_exit: + pci_epc_mem_exit(epc); diff --git a/queue-6.4/pci-rockchip-fix-legacy-irq-generation-for-rk3399-pcie-endpoint-core.patch b/queue-6.4/pci-rockchip-fix-legacy-irq-generation-for-rk3399-pcie-endpoint-core.patch new file mode 100644 index 00000000000..14df9210d9e --- /dev/null +++ b/queue-6.4/pci-rockchip-fix-legacy-irq-generation-for-rk3399-pcie-endpoint-core.patch @@ -0,0 +1,113 @@ +From 166e89d99dd85a856343cca51eee781b793801f2 Mon Sep 17 00:00:00 2001 +From: Rick Wertenbroek +Date: Tue, 18 Apr 2023 09:46:54 +0200 +Subject: PCI: rockchip: Fix legacy IRQ generation for RK3399 PCIe endpoint core + +From: Rick Wertenbroek + +commit 166e89d99dd85a856343cca51eee781b793801f2 upstream. + +Fix legacy IRQ generation for RK3399 PCIe endpoint core according to +the technical reference manual (TRM). Assert and deassert legacy +interrupt (INTx) through the legacy interrupt control register +("PCIE_CLIENT_LEGACY_INT_CTRL") instead of manually generating a PCIe +message. The generation of the legacy interrupt was tested and validated +with the PCIe endpoint test driver. + +Link: https://lore.kernel.org/r/20230418074700.1083505-8-rick.wertenbroek@gmail.com +Fixes: cf590b078391 ("PCI: rockchip: Add EP driver for Rockchip PCIe controller") +Tested-by: Damien Le Moal +Signed-off-by: Rick Wertenbroek +Signed-off-by: Lorenzo Pieralisi +Reviewed-by: Damien Le Moal +Cc: stable@vger.kernel.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/pci/controller/pcie-rockchip-ep.c | 45 +++++++----------------------- + drivers/pci/controller/pcie-rockchip.h | 6 +++- + 2 files changed, 16 insertions(+), 35 deletions(-) + +--- a/drivers/pci/controller/pcie-rockchip-ep.c ++++ b/drivers/pci/controller/pcie-rockchip-ep.c +@@ -347,48 +347,25 @@ static int rockchip_pcie_ep_get_msi(stru + } + + static void rockchip_pcie_ep_assert_intx(struct rockchip_pcie_ep *ep, u8 fn, +- u8 intx, bool is_asserted) ++ u8 intx, bool do_assert) + { + struct rockchip_pcie *rockchip = &ep->rockchip; +- u32 r = ep->max_regions - 1; +- u32 offset; +- u32 status; +- u8 msg_code; +- +- if (unlikely(ep->irq_pci_addr != ROCKCHIP_PCIE_EP_PCI_LEGACY_IRQ_ADDR || +- ep->irq_pci_fn != fn)) { +- rockchip_pcie_prog_ep_ob_atu(rockchip, fn, r, +- AXI_WRAPPER_NOR_MSG, +- ep->irq_phys_addr, 0, 0); +- ep->irq_pci_addr = ROCKCHIP_PCIE_EP_PCI_LEGACY_IRQ_ADDR; +- ep->irq_pci_fn = fn; +- } + + intx &= 3; +- if (is_asserted) { ++ ++ if (do_assert) { + ep->irq_pending |= BIT(intx); +- msg_code = ROCKCHIP_PCIE_MSG_CODE_ASSERT_INTA + intx; ++ rockchip_pcie_write(rockchip, ++ PCIE_CLIENT_INT_IN_ASSERT | ++ PCIE_CLIENT_INT_PEND_ST_PEND, ++ PCIE_CLIENT_LEGACY_INT_CTRL); + } else { + ep->irq_pending &= ~BIT(intx); +- msg_code = ROCKCHIP_PCIE_MSG_CODE_DEASSERT_INTA + intx; ++ rockchip_pcie_write(rockchip, ++ PCIE_CLIENT_INT_IN_DEASSERT | ++ PCIE_CLIENT_INT_PEND_ST_NORMAL, ++ PCIE_CLIENT_LEGACY_INT_CTRL); + } +- +- status = rockchip_pcie_read(rockchip, +- ROCKCHIP_PCIE_EP_FUNC_BASE(fn) + +- ROCKCHIP_PCIE_EP_CMD_STATUS); +- status &= ROCKCHIP_PCIE_EP_CMD_STATUS_IS; +- +- if ((status != 0) ^ (ep->irq_pending != 0)) { +- status ^= ROCKCHIP_PCIE_EP_CMD_STATUS_IS; +- rockchip_pcie_write(rockchip, status, +- ROCKCHIP_PCIE_EP_FUNC_BASE(fn) + +- ROCKCHIP_PCIE_EP_CMD_STATUS); +- } +- +- offset = +- ROCKCHIP_PCIE_MSG_ROUTING(ROCKCHIP_PCIE_MSG_ROUTING_LOCAL_INTX) | +- ROCKCHIP_PCIE_MSG_CODE(msg_code) | ROCKCHIP_PCIE_MSG_NO_DATA; +- writel(0, ep->irq_cpu_addr + offset); + } + + static int rockchip_pcie_ep_send_legacy_irq(struct rockchip_pcie_ep *ep, u8 fn, +--- a/drivers/pci/controller/pcie-rockchip.h ++++ b/drivers/pci/controller/pcie-rockchip.h +@@ -38,6 +38,11 @@ + #define PCIE_CLIENT_MODE_EP HIWORD_UPDATE(0x0040, 0) + #define PCIE_CLIENT_GEN_SEL_1 HIWORD_UPDATE(0x0080, 0) + #define PCIE_CLIENT_GEN_SEL_2 HIWORD_UPDATE_BIT(0x0080) ++#define PCIE_CLIENT_LEGACY_INT_CTRL (PCIE_CLIENT_BASE + 0x0c) ++#define PCIE_CLIENT_INT_IN_ASSERT HIWORD_UPDATE_BIT(0x0002) ++#define PCIE_CLIENT_INT_IN_DEASSERT HIWORD_UPDATE(0x0002, 0) ++#define PCIE_CLIENT_INT_PEND_ST_PEND HIWORD_UPDATE_BIT(0x0001) ++#define PCIE_CLIENT_INT_PEND_ST_NORMAL HIWORD_UPDATE(0x0001, 0) + #define PCIE_CLIENT_SIDE_BAND_STATUS (PCIE_CLIENT_BASE + 0x20) + #define PCIE_CLIENT_PHY_ST BIT(12) + #define PCIE_CLIENT_DEBUG_OUT_0 (PCIE_CLIENT_BASE + 0x3c) +@@ -227,7 +232,6 @@ + #define ROCKCHIP_PCIE_EP_MSI_CTRL_ME BIT(16) + #define ROCKCHIP_PCIE_EP_MSI_CTRL_MASK_MSI_CAP BIT(24) + #define ROCKCHIP_PCIE_EP_DUMMY_IRQ_ADDR 0x1 +-#define ROCKCHIP_PCIE_EP_PCI_LEGACY_IRQ_ADDR 0x3 + #define ROCKCHIP_PCIE_EP_FUNC_BASE(fn) (((fn) << 12) & GENMASK(19, 12)) + #define ROCKCHIP_PCIE_AT_IB_EP_FUNC_BAR_ADDR0(fn, bar) \ + (PCIE_RC_RP_ATS_BASE + 0x0840 + (fn) * 0x0040 + (bar) * 0x0008) diff --git a/queue-6.4/pci-rockchip-set-address-alignment-for-endpoint-mode.patch b/queue-6.4/pci-rockchip-set-address-alignment-for-endpoint-mode.patch new file mode 100644 index 00000000000..9091d7598b9 --- /dev/null +++ b/queue-6.4/pci-rockchip-set-address-alignment-for-endpoint-mode.patch @@ -0,0 +1,35 @@ +From 7e6689b34a815bd379dfdbe9855d36f395ef056c Mon Sep 17 00:00:00 2001 +From: Damien Le Moal +Date: Tue, 18 Apr 2023 09:46:58 +0200 +Subject: PCI: rockchip: Set address alignment for endpoint mode + +From: Damien Le Moal + +commit 7e6689b34a815bd379dfdbe9855d36f395ef056c upstream. + +The address translation unit of the rockchip EP controller does not use +the lower 8 bits of a PCIe-space address to map local memory. Thus we +must set the align feature field to 256 to let the user know about this +constraint. + +Link: https://lore.kernel.org/r/20230418074700.1083505-12-rick.wertenbroek@gmail.com +Fixes: cf590b078391 ("PCI: rockchip: Add EP driver for Rockchip PCIe controller") +Signed-off-by: Damien Le Moal +Signed-off-by: Rick Wertenbroek +Signed-off-by: Lorenzo Pieralisi +Cc: stable@vger.kernel.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/pci/controller/pcie-rockchip-ep.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/pci/controller/pcie-rockchip-ep.c ++++ b/drivers/pci/controller/pcie-rockchip-ep.c +@@ -485,6 +485,7 @@ static const struct pci_epc_features roc + .linkup_notifier = false, + .msi_capable = true, + .msix_capable = false, ++ .align = 256, + }; + + static const struct pci_epc_features* diff --git a/queue-6.4/pci-rockchip-use-u32-variable-to-access-32-bit-registers.patch b/queue-6.4/pci-rockchip-use-u32-variable-to-access-32-bit-registers.patch new file mode 100644 index 00000000000..03c035a1b0d --- /dev/null +++ b/queue-6.4/pci-rockchip-use-u32-variable-to-access-32-bit-registers.patch @@ -0,0 +1,76 @@ +From 8962b2cb39119cbda4fc69a1f83957824f102f81 Mon Sep 17 00:00:00 2001 +From: Rick Wertenbroek +Date: Tue, 18 Apr 2023 09:46:56 +0200 +Subject: PCI: rockchip: Use u32 variable to access 32-bit registers + +From: Rick Wertenbroek + +commit 8962b2cb39119cbda4fc69a1f83957824f102f81 upstream. + +Previously u16 variables were used to access 32-bit registers, this +resulted in not all of the data being read from the registers. Also +the left shift of more than 16-bits would result in moving data out +of the variable. Use u32 variables to access 32-bit registers + +Link: https://lore.kernel.org/r/20230418074700.1083505-10-rick.wertenbroek@gmail.com +Fixes: cf590b078391 ("PCI: rockchip: Add EP driver for Rockchip PCIe controller") +Tested-by: Damien Le Moal +Signed-off-by: Rick Wertenbroek +Signed-off-by: Lorenzo Pieralisi +Reviewed-by: Damien Le Moal +Cc: stable@vger.kernel.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/pci/controller/pcie-rockchip-ep.c | 10 +++++----- + drivers/pci/controller/pcie-rockchip.h | 1 + + 2 files changed, 6 insertions(+), 5 deletions(-) + +--- a/drivers/pci/controller/pcie-rockchip-ep.c ++++ b/drivers/pci/controller/pcie-rockchip-ep.c +@@ -314,15 +314,15 @@ static int rockchip_pcie_ep_set_msi(stru + { + struct rockchip_pcie_ep *ep = epc_get_drvdata(epc); + struct rockchip_pcie *rockchip = &ep->rockchip; +- u16 flags; ++ u32 flags; + + flags = rockchip_pcie_read(rockchip, + ROCKCHIP_PCIE_EP_FUNC_BASE(fn) + + ROCKCHIP_PCIE_EP_MSI_CTRL_REG); + flags &= ~ROCKCHIP_PCIE_EP_MSI_CTRL_MMC_MASK; + flags |= +- ((multi_msg_cap << 1) << ROCKCHIP_PCIE_EP_MSI_CTRL_MMC_OFFSET) | +- PCI_MSI_FLAGS_64BIT; ++ (multi_msg_cap << ROCKCHIP_PCIE_EP_MSI_CTRL_MMC_OFFSET) | ++ (PCI_MSI_FLAGS_64BIT << ROCKCHIP_PCIE_EP_MSI_FLAGS_OFFSET); + flags &= ~ROCKCHIP_PCIE_EP_MSI_CTRL_MASK_MSI_CAP; + rockchip_pcie_write(rockchip, flags, + ROCKCHIP_PCIE_EP_FUNC_BASE(fn) + +@@ -334,7 +334,7 @@ static int rockchip_pcie_ep_get_msi(stru + { + struct rockchip_pcie_ep *ep = epc_get_drvdata(epc); + struct rockchip_pcie *rockchip = &ep->rockchip; +- u16 flags; ++ u32 flags; + + flags = rockchip_pcie_read(rockchip, + ROCKCHIP_PCIE_EP_FUNC_BASE(fn) + +@@ -395,7 +395,7 @@ static int rockchip_pcie_ep_send_msi_irq + u8 interrupt_num) + { + struct rockchip_pcie *rockchip = &ep->rockchip; +- u16 flags, mme, data, data_mask; ++ u32 flags, mme, data, data_mask; + u8 msi_count; + u64 pci_addr, pci_addr_mask = 0xff; + +--- a/drivers/pci/controller/pcie-rockchip.h ++++ b/drivers/pci/controller/pcie-rockchip.h +@@ -225,6 +225,7 @@ + #define ROCKCHIP_PCIE_EP_CMD_STATUS 0x4 + #define ROCKCHIP_PCIE_EP_CMD_STATUS_IS BIT(19) + #define ROCKCHIP_PCIE_EP_MSI_CTRL_REG 0x90 ++#define ROCKCHIP_PCIE_EP_MSI_FLAGS_OFFSET 16 + #define ROCKCHIP_PCIE_EP_MSI_CTRL_MMC_OFFSET 17 + #define ROCKCHIP_PCIE_EP_MSI_CTRL_MMC_MASK GENMASK(19, 17) + #define ROCKCHIP_PCIE_EP_MSI_CTRL_MME_OFFSET 20 diff --git a/queue-6.4/pci-rockchip-write-pci-device-id-to-correct-register.patch b/queue-6.4/pci-rockchip-write-pci-device-id-to-correct-register.patch new file mode 100644 index 00000000000..714a605dd1f --- /dev/null +++ b/queue-6.4/pci-rockchip-write-pci-device-id-to-correct-register.patch @@ -0,0 +1,60 @@ +From 1f1c42ece18de365c976a060f3c8eb481b038e3a Mon Sep 17 00:00:00 2001 +From: Rick Wertenbroek +Date: Tue, 18 Apr 2023 09:46:49 +0200 +Subject: PCI: rockchip: Write PCI Device ID to correct register + +From: Rick Wertenbroek + +commit 1f1c42ece18de365c976a060f3c8eb481b038e3a upstream. + +Write PCI Device ID (DID) to the correct register. The Device ID was not +updated through the correct register. Device ID was written to a read-only +register and therefore did not work. The Device ID is now set through the +correct register. This is documented in the RK3399 TRM section 17.6.6.1.1 + +Link: https://lore.kernel.org/r/20230418074700.1083505-3-rick.wertenbroek@gmail.com +Fixes: cf590b078391 ("PCI: rockchip: Add EP driver for Rockchip PCIe controller") +Tested-by: Damien Le Moal +Signed-off-by: Rick Wertenbroek +Signed-off-by: Lorenzo Pieralisi +Reviewed-by: Damien Le Moal +Cc: stable@vger.kernel.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/pci/controller/pcie-rockchip-ep.c | 6 ++++-- + drivers/pci/controller/pcie-rockchip.h | 2 ++ + 2 files changed, 6 insertions(+), 2 deletions(-) + +--- a/drivers/pci/controller/pcie-rockchip-ep.c ++++ b/drivers/pci/controller/pcie-rockchip-ep.c +@@ -125,6 +125,7 @@ static void rockchip_pcie_prog_ep_ob_atu + static int rockchip_pcie_ep_write_header(struct pci_epc *epc, u8 fn, u8 vfn, + struct pci_epf_header *hdr) + { ++ u32 reg; + struct rockchip_pcie_ep *ep = epc_get_drvdata(epc); + struct rockchip_pcie *rockchip = &ep->rockchip; + +@@ -137,8 +138,9 @@ static int rockchip_pcie_ep_write_header + PCIE_CORE_CONFIG_VENDOR); + } + +- rockchip_pcie_write(rockchip, hdr->deviceid << 16, +- ROCKCHIP_PCIE_EP_FUNC_BASE(fn) + PCI_VENDOR_ID); ++ reg = rockchip_pcie_read(rockchip, PCIE_EP_CONFIG_DID_VID); ++ reg = (reg & 0xFFFF) | (hdr->deviceid << 16); ++ rockchip_pcie_write(rockchip, reg, PCIE_EP_CONFIG_DID_VID); + + rockchip_pcie_write(rockchip, + hdr->revid | +--- a/drivers/pci/controller/pcie-rockchip.h ++++ b/drivers/pci/controller/pcie-rockchip.h +@@ -133,6 +133,8 @@ + #define PCIE_RC_RP_ATS_BASE 0x400000 + #define PCIE_RC_CONFIG_NORMAL_BASE 0x800000 + #define PCIE_RC_CONFIG_BASE 0xa00000 ++#define PCIE_EP_CONFIG_BASE 0xa00000 ++#define PCIE_EP_CONFIG_DID_VID (PCIE_EP_CONFIG_BASE + 0x00) + #define PCIE_RC_CONFIG_RID_CCR (PCIE_RC_CONFIG_BASE + 0x08) + #define PCIE_RC_CONFIG_DCR (PCIE_RC_CONFIG_BASE + 0xc4) + #define PCIE_RC_CONFIG_DCR_CSPL_SHIFT 18 diff --git a/queue-6.4/s390-zcrypt-do-not-retry-administrative-requests.patch b/queue-6.4/s390-zcrypt-do-not-retry-administrative-requests.patch new file mode 100644 index 00000000000..464530abd1a --- /dev/null +++ b/queue-6.4/s390-zcrypt-do-not-retry-administrative-requests.patch @@ -0,0 +1,59 @@ +From af40322e90d4e0093569eceb7d3a28ab635f3e75 Mon Sep 17 00:00:00 2001 +From: Harald Freudenberger +Date: Mon, 12 Jun 2023 11:13:39 +0200 +Subject: s390/zcrypt: do not retry administrative requests + +From: Harald Freudenberger + +commit af40322e90d4e0093569eceb7d3a28ab635f3e75 upstream. + +All kind of administrative requests should not been retried. Some card +firmware detects this and assumes a replay attack. This patch checks +on failure if the low level functions indicate a retry (EAGAIN) and +checks for the ADMIN flag set on the request message. If this both +are true, the response code for this message is changed to EIO to make +sure the zcrypt API layer does not attempt to retry the request. As of +now the ADMIN flag is set for a request message when +- for EP11 the field 'flags' of the EP11 CPRB struct has the leftmost + bit set. +- for CCA when the CPRB minor version is 'T3', 'T5', 'T6' or 'T7'. + +Please note that the do-not-retry only applies to a request +which has been sent to the card (= has been successfully enqueued) but +the reply indicates some kind of failure and by default it would be +replied. It is totally fine to retry a request if a previous attempt +to enqueue the msg into the firmware queue had some kind of failure +and thus the card has never seen this request. + +Reported-by: Frank Uhlig +Signed-off-by: Harald Freudenberger +Reviewed-by: Holger Dengler +Cc: stable@vger.kernel.org +Signed-off-by: Alexander Gordeev +Signed-off-by: Greg Kroah-Hartman +--- + drivers/s390/crypto/zcrypt_msgtype6.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +--- a/drivers/s390/crypto/zcrypt_msgtype6.c ++++ b/drivers/s390/crypto/zcrypt_msgtype6.c +@@ -1143,6 +1143,9 @@ static long zcrypt_msgtype6_send_cprb(bo + ap_cancel_message(zq->queue, ap_msg); + } + ++ if (rc == -EAGAIN && ap_msg->flags & AP_MSG_FLAG_ADMIN) ++ rc = -EIO; /* do not retry administrative requests */ ++ + out: + if (rc) + ZCRYPT_DBF_DBG("%s send cprb at dev=%02x.%04x rc=%d\n", +@@ -1263,6 +1266,9 @@ static long zcrypt_msgtype6_send_ep11_cp + ap_cancel_message(zq->queue, ap_msg); + } + ++ if (rc == -EAGAIN && ap_msg->flags & AP_MSG_FLAG_ADMIN) ++ rc = -EIO; /* do not retry administrative requests */ ++ + out: + if (rc) + ZCRYPT_DBF_DBG("%s send cprb at dev=%02x.%04x rc=%d\n", diff --git a/queue-6.4/scsi-mpi3mr-propagate-sense-data-for-admin-queue-scsi-i-o.patch b/queue-6.4/scsi-mpi3mr-propagate-sense-data-for-admin-queue-scsi-i-o.patch new file mode 100644 index 00000000000..e345b983294 --- /dev/null +++ b/queue-6.4/scsi-mpi3mr-propagate-sense-data-for-admin-queue-scsi-i-o.patch @@ -0,0 +1,38 @@ +From f762326b2baa86ae647e2ba6832bc87e238f68ad Mon Sep 17 00:00:00 2001 +From: Sathya Prakash +Date: Thu, 1 Jun 2023 00:10:25 +0530 +Subject: scsi: mpi3mr: Propagate sense data for admin queue SCSI I/O + +From: Sathya Prakash + +commit f762326b2baa86ae647e2ba6832bc87e238f68ad upstream. + +Copy the sense data to internal driver buffer when the firmware completes +any SCSI I/O command sent through admin queue with sense data for further +use. + +Fixes: 506bc1a0d6ba ("scsi: mpi3mr: Add support for MPT commands") +Cc: +Signed-off-by: Sathya Prakash +Signed-off-by: Sumit Saxena +Link: https://lore.kernel.org/r/20230531184025.3803-1-sumit.saxena@broadcom.com +Signed-off-by: Martin K. Petersen +Signed-off-by: Greg Kroah-Hartman +--- + drivers/scsi/mpi3mr/mpi3mr_fw.c | 5 +++++ + 1 file changed, 5 insertions(+) + +--- a/drivers/scsi/mpi3mr/mpi3mr_fw.c ++++ b/drivers/scsi/mpi3mr/mpi3mr_fw.c +@@ -402,6 +402,11 @@ static void mpi3mr_process_admin_reply_d + memcpy((u8 *)cmdptr->reply, (u8 *)def_reply, + mrioc->reply_sz); + } ++ if (sense_buf && cmdptr->sensebuf) { ++ cmdptr->is_sense = 1; ++ memcpy(cmdptr->sensebuf, sense_buf, ++ MPI3MR_SENSE_BUF_SZ); ++ } + if (cmdptr->is_waiting) { + complete(&cmdptr->done); + cmdptr->is_waiting = 0; diff --git a/queue-6.4/series b/queue-6.4/series index 12f6e01e500..4709a971b28 100644 --- a/queue-6.4/series +++ b/queue-6.4/series @@ -147,3 +147,35 @@ mips-cpu-features-use-boot_cpu_type-for-cpu-type-based-features.patch mips-loongson-fix-cpu_probe_loongson-again.patch mips-loongson-fix-build-error-when-make-modules_install.patch mips-kvm-fix-null-pointer-dereference.patch +ext4-fix-reusing-stale-buffer-heads-from-last-failed-mounting.patch +ext4-fix-wrong-unit-use-in-ext4_mb_clear_bb.patch +ext4-get-block-from-bh-in-ext4_free_blocks-for-fast-commit-replay.patch +ext4-fix-wrong-unit-use-in-ext4_mb_new_blocks.patch +ext4-avoid-updating-the-superblock-on-a-r-o-mount-if-not-needed.patch +ext4-fix-to-check-return-value-of-freeze_bdev-in-ext4_shutdown.patch +ext4-turn-quotas-off-if-mount-failed-after-enabling-quotas.patch +ext4-only-update-i_reserved_data_blocks-on-successful-block-allocation.patch +fs-dlm-revert-check-required-context-while-close.patch +mm-mmap-fix-error-return-in-do_vmi_align_munmap.patch +soc-qcom-mdt_loader-fix-unconditional-call-to-scm_pas_mem_setup.patch +ext2-dax-fix-ext2_setsize-when-len-is-page-aligned.patch +jfs-jfs_dmap-validate-db_l2nbperpage-while-mounting.patch +arm64-dts-mt7986-use-size-of-reserved-partition-for-bl2.patch +arm64-dts-ti-k3-j721s2-fix-wkup-pinmux-range.patch +hwrng-imx-rngc-fix-the-timeout-for-init-and-self-check.patch +dm-integrity-reduce-vmalloc-space-footprint-on-32-bit-architectures.patch +scsi-mpi3mr-propagate-sense-data-for-admin-queue-scsi-i-o.patch +s390-zcrypt-do-not-retry-administrative-requests.patch +pci-pm-avoid-putting-elopos-e2-s2-h2-pcie-ports-in-d3cold.patch +pci-release-resource-invalidated-by-coalescing.patch +pci-add-function-1-dma-alias-quirk-for-marvell-88se9235.patch +pci-acpiphp-reassign-resources-on-bridge-if-necessary.patch +pci-qcom-disable-write-access-to-read-only-registers-for-ip-v2.3.3.patch +pci-epf-test-fix-dma-transfer-completion-initialization.patch +pci-epf-test-fix-dma-transfer-completion-detection.patch +pci-rockchip-assert-pci-configuration-enable-bit-after-probe.patch +pci-rockchip-write-pci-device-id-to-correct-register.patch +pci-rockchip-add-poll-and-timeout-to-wait-for-phy-plls-to-be-locked.patch +pci-rockchip-fix-legacy-irq-generation-for-rk3399-pcie-endpoint-core.patch +pci-rockchip-use-u32-variable-to-access-32-bit-registers.patch +pci-rockchip-set-address-alignment-for-endpoint-mode.patch diff --git a/queue-6.4/soc-qcom-mdt_loader-fix-unconditional-call-to-scm_pas_mem_setup.patch b/queue-6.4/soc-qcom-mdt_loader-fix-unconditional-call-to-scm_pas_mem_setup.patch new file mode 100644 index 00000000000..c2018e9635b --- /dev/null +++ b/queue-6.4/soc-qcom-mdt_loader-fix-unconditional-call-to-scm_pas_mem_setup.patch @@ -0,0 +1,83 @@ +From bcb889891371c3cf767f2b9e8768cfe2fdd3810f Mon Sep 17 00:00:00 2001 +From: Christian Marangi +Date: Fri, 26 May 2023 13:55:11 +0200 +Subject: soc: qcom: mdt_loader: Fix unconditional call to scm_pas_mem_setup + +From: Christian Marangi + +commit bcb889891371c3cf767f2b9e8768cfe2fdd3810f upstream. + +Commit ebeb20a9cd3f ("soc: qcom: mdt_loader: Always invoke PAS +mem_setup") dropped the relocate check and made pas_mem_setup run +unconditionally. The code was later moved with commit f4e526ff7e38 +("soc: qcom: mdt_loader: Extract PAS operations") to +qcom_mdt_pas_init() effectively losing track of what was actually +done. + +The assumption that PAS mem_setup can be done anytime was effectively +wrong, with no good reason and this caused regression on some SoC +that use remoteproc to bringup ath11k. One example is IPQ8074 SoC that +effectively broke resulting in remoteproc silently die and ath11k not +working. + +On this SoC FW relocate is not enabled and PAS mem_setup was correctly +skipped in previous kernel version resulting in correct bringup and +function of remoteproc and ath11k. + +To fix the regression, reintroduce the relocate check in +qcom_mdt_pas_init() and correctly skip PAS mem_setup where relocate is +not enabled. + +Fixes: ebeb20a9cd3f ("soc: qcom: mdt_loader: Always invoke PAS mem_setup") +Tested-by: Robert Marko +Co-developed-by: Robert Marko +Signed-off-by: Robert Marko +Signed-off-by: Christian Marangi +Cc: stable@vger.kernel.org +Reviewed-by: Mukesh Ojha +Signed-off-by: Bjorn Andersson +Link: https://lore.kernel.org/r/20230526115511.3328-1-ansuelsmth@gmail.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/soc/qcom/mdt_loader.c | 16 +++++++++++----- + 1 file changed, 11 insertions(+), 5 deletions(-) + +--- a/drivers/soc/qcom/mdt_loader.c ++++ b/drivers/soc/qcom/mdt_loader.c +@@ -210,6 +210,7 @@ int qcom_mdt_pas_init(struct device *dev + const struct elf32_hdr *ehdr; + phys_addr_t min_addr = PHYS_ADDR_MAX; + phys_addr_t max_addr = 0; ++ bool relocate = false; + size_t metadata_len; + void *metadata; + int ret; +@@ -224,6 +225,9 @@ int qcom_mdt_pas_init(struct device *dev + if (!mdt_phdr_valid(phdr)) + continue; + ++ if (phdr->p_flags & QCOM_MDT_RELOCATABLE) ++ relocate = true; ++ + if (phdr->p_paddr < min_addr) + min_addr = phdr->p_paddr; + +@@ -246,11 +250,13 @@ int qcom_mdt_pas_init(struct device *dev + goto out; + } + +- ret = qcom_scm_pas_mem_setup(pas_id, mem_phys, max_addr - min_addr); +- if (ret) { +- /* Unable to set up relocation */ +- dev_err(dev, "error %d setting up firmware %s\n", ret, fw_name); +- goto out; ++ if (relocate) { ++ ret = qcom_scm_pas_mem_setup(pas_id, mem_phys, max_addr - min_addr); ++ if (ret) { ++ /* Unable to set up relocation */ ++ dev_err(dev, "error %d setting up firmware %s\n", ret, fw_name); ++ goto out; ++ } + } + + out: -- 2.47.3