arm64: dts: qcom: sdm845: narrow LLCC address space
Subsystems (6)
Sasha Levin
maintainerPATCH 1/26 arm64: dts: qcom: sdm845: narrow LLCC address space
From: Krzysztof Kozlowski <[email protected]>
[ Upstream commit 300b5f661eebefb8571841b78091343eb87eca54 ]
The Last Level Cache Controller (LLCC) device does not need to access entire LLCC address space. Currently driver uses only hardware info and status registers which both reside in LLCC0_COMMON range (offset 0x30000, size 0x1000). Narrow the address space to allow binding other drivers to rest of LLCC address space.
--- arch/arm64/boot/dts/qcom/sdm845.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/qcom/sdm845.dtsi +1 -1
@@ -1968,7 +1968,7 @@ uart15: serial@a9c000 { system-cache-controller@1100000 { compatible = "qcom,sdm845-llcc"; - reg = <0 0x01100000 0 0x200000>, <0 0x01300000 0 0x50000>; + reg = <0 0x01100000 0 0x31000>, <0 0x01300000 0 0x50000>; reg-names = "llcc_base", "llcc_broadcast_base"; interrupts = <GIC_SPI 582 IRQ_TYPE_LEVEL_HIGH>; };
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 5/26 ARM: dts: imx6q: add missing properties for sram
From: Alexander Stein <[email protected]>
[ Upstream commit b11d083c5dcec7c42fe982c854706d404ddd3a5f ]
All 3 properties are required by sram.yaml. Fixes the dtbs_check warning:
sram@900000: '#address-cells' is a required property sram@900000: '#size-cells' is a required property sram@900000: 'ranges' is a required property
--- arch/arm/boot/dts/imx6q.dtsi | 3 +++ 1 file changed, 3 insertions(+)
arch/arm/boot/dts/imx6q.dtsi +3 -0
@@ -163,6 +163,9 @@ soc { ocram: sram@900000 { compatible = "mmio-sram"; reg = <0x00900000 0x40000>; + ranges = <0 0x00900000 0x40000>; + #address-cells = <1>; + #size-cells = <1>; clocks = <&clks IMX6QDL_CLK_OCRAM>; };
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 7/26 ARM: dts: imx6qp: add missing properties for sram
In reply to Sasha LevinFrom: Alexander Stein <[email protected]>
[ Upstream commit 088fe5237435ee2f7ed4450519b2ef58b94c832f ]
All 3 properties are required by sram.yaml. Fixes the dtbs_check warning:
sram@940000: '#address-cells' is a required property sram@940000: '#size-cells' is a required property sram@940000: 'ranges' is a required property
--- arch/arm/boot/dts/imx6qp.dtsi | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm/boot/dts/imx6qp.dtsi +6 -0
@@ -9,12 +9,18 @@ soc { ocram2: sram@940000 { compatible = "mmio-sram"; reg = <0x00940000 0x20000>; + ranges = <0 0x00940000 0x20000>; + #address-cells = <1>; + #size-cells = <1>; clocks = <&clks IMX6QDL_CLK_OCRAM>; }; ocram3: sram@960000 { compatible = "mmio-sram"; reg = <0x00960000 0x20000>; + ranges = <0 0x00960000 0x20000>; + #address-cells = <1>; + #size-cells = <1>; clocks = <&clks IMX6QDL_CLK_OCRAM>; };
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 4/26 arm64: dts: qcom: sc7280-idp: correct ADC channel node name and unit address
In reply to Sasha LevinFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit 5589ffb2da2a66988ab3a68334dad3e68b42e3a9 ]
Correct SPMI PMIC VADC channel node name:
1. Use hyphens instead of underscores,
2. Add missing unit address.
This fixes make dtbs_check warnings like:
qcom/sc7280-idp.dtb: pmic@0: adc@3100: 'pmk8350_die_temp', 'pmr735a_die_temp' do not match any of the regexes: '^.*@[0-9a-f]+$', 'pinctrl-[0-9]+'
--- arch/arm64/boot/dts/qcom/sc7280-idp.dts | 2 +- arch/arm64/boot/dts/qcom/sc7280-idp.dtsi | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/qcom/sc7280-idp.dts +1 -1
@@ -62,7 +62,7 @@ &ipa { }; &pmk8350_vadc { - pmr735a_die_temp { + pmr735a-die-temp@403 { reg = <PMR735A_ADC7_DIE_TEMP>; label = "pmr735a_die_temp"; qcom,pre-scaling = <1 1>;
arch/arm64/boot/dts/qcom/sc7280-idp.dtsi +1 -1
@@ -200,7 +200,7 @@ &ipa { }; &pmk8350_vadc { - pmk8350_die_temp { + pmk8350-die-temp@3 { reg = <PMK8350_ADC7_DIE_TEMP>; label = "pmk8350_die_temp"; qcom,pre-scaling = <1 1>;
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 14/26 arm64: dts: imx8mq-librem5: Add bq25895 as max17055's power supply
In reply to Sasha LevinFrom: Sebastian Krzyszkowiak <[email protected]>
[ Upstream commit 6effe295e1a87408033c29dbcea9d5a5c8b937d5 ]
This allows the userspace to notice that there's not enough current provided to charge the battery, and also fixes issues with 0% SOC values being considered invalid.
--- arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi | 1 + 1 file changed, 1 insertion(+)
arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi +1 -0
@@ -967,6 +967,7 @@ bat: fuel-gauge@36 { interrupts = <20 IRQ_TYPE_LEVEL_LOW>; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_gauge>; + power-supplies = <&bq25895>; maxim,over-heat-temp = <700>; maxim,over-volt = <4500>; maxim,rsns-microohm = <5000>;
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 2/26 ARM: dts: imx7d-sdb: config the max pressure for tsc2046
In reply to Sasha LevinFrom: Haibo Chen <[email protected]>
[ Upstream commit e7c4ebe2f9cd68588eb24ba4ed122e696e2d5272 ]
Use the general touchscreen method to config the max pressure for touch tsc2046(data sheet suggest 8 bit pressure), otherwise, for ABS_PRESSURE, when config the same max and min value, weston will meet the following issue,
[17:19:39.183] event1 - ADS7846 Touchscreen: is tagged by udev as: Touchscreen [17:19:39.183] event1 - ADS7846 Touchscreen: kernel bug: device has min == max on ABS_PRESSURE [17:19:39.183] event1 - ADS7846 Touchscreen: was rejected [17:19:39.183] event1 - not using input device '/dev/input/event1'
This will then cause the APP weston-touch-calibrator can't list touch devices.
root@imx6ul7d:~# weston-touch-calibrator could not load cursor 'dnd-move' could not load cursor 'dnd-copy' could not load cursor 'dnd-none' No devices listed.
And accroding to binding Doc, "ti,x-max", "ti,y-max", "ti,pressure-max" belong to the deprecated properties, so remove them. Also for "ti,x-min", "ti,y-min", "ti,x-plate-ohms", the value set in dts equal to the default value in driver, so are redundant, also remove here.
--- arch/arm/boot/dts/imx7d-sdb.dts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
arch/arm/boot/dts/imx7d-sdb.dts +1 -6
@@ -206,12 +206,7 @@ tsc2046@0 { interrupt-parent = <&gpio2>; interrupts = <29 0>; pendown-gpio = <&gpio2 29 GPIO_ACTIVE_HIGH>; - ti,x-min = /bits/ 16 <0>; - ti,x-max = /bits/ 16 <0>; - ti,y-min = /bits/ 16 <0>; - ti,y-max = /bits/ 16 <0>; - ti,pressure-max = /bits/ 16 <0>; - ti,x-plate-ohms = /bits/ 16 <400>; + touchscreen-max-pressure = <255>; wakeup-source; }; };
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 16/26 btrfs: dump extra info if one free space cache has more bitmaps than it should
In reply to Sasha LevinFrom: Qu Wenruo <[email protected]>
[ Upstream commit 62cd9d4474282a1eb84f945955c56cbfc42e1ffe ]
There is an internal report on hitting the following ASSERT() in recalculate_thresholds():
ASSERT(ctl->total_bitmaps <= max_bitmaps);
Above @max_bitmaps is calculated using the following variables:
- bytes_per_bg
8 * 4096 * 4096 (128M) for x86_64/x86.
- block_group->length
The length of the block group.
@max_bitmaps is the rounded up value of block_group->length / 128M.
Normally one free space cache should not have more bitmaps than above value, but when it happens the ASSERT() can be triggered if CONFIG_BTRFS_ASSERT is also enabled.
But the ASSERT() itself won't provide enough info to know which is going wrong.
Is the bg too small thus it only allows one bitmap?
Or is there something else wrong?
So although I haven't found extra reports or crash dump to do further investigation, add the extra info to make it more helpful to debug.
--- fs/btrfs/free-space-cache.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/btrfs/free-space-cache.c +6 -0
@@ -672,6 +672,12 @@ static void recalculate_thresholds(struct btrfs_free_space_ctl *ctl) max_bitmaps =max_t (u64, max_bitmaps,1 ); +if (ctl->total_bitmaps > max_bitmaps) +btrfs_err (block_group->fs_info, +"invalid free space control: bg start=%llu len=%llu total_bitmaps=%u unit=%u max_bitmaps=%llu bytes_per_bg=%llu" , + block_group->start, block_group->length, + ctl->total_bitmaps, ctl->unit, max_bitmaps, + bytes_per_bg);ASSERT (ctl->total_bitmaps <= max_bitmaps);/*
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 6/26 ARM: dts: imx6dl: add missing properties for sram
In reply to Sasha LevinFrom: Alexander Stein <[email protected]>
[ Upstream commit f5848b95633d598bacf0500e0108dc5961af88c0 ]
All 3 properties are required by sram.yaml. Fixes the dtbs_check warning:
sram@900000: '#address-cells' is a required property sram@900000: '#size-cells' is a required property sram@900000: 'ranges' is a required property
--- arch/arm/boot/dts/imx6dl.dtsi | 3 +++ 1 file changed, 3 insertions(+)
arch/arm/boot/dts/imx6dl.dtsi +3 -0
@@ -84,6 +84,9 @@ soc { ocram: sram@900000 { compatible = "mmio-sram"; reg = <0x00900000 0x20000>; + ranges = <0 0x00900000 0x20000>; + #address-cells = <1>; + #size-cells = <1>; clocks = <&clks IMX6QDL_CLK_OCRAM>; };
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 24/26 arm64: dts: uniphier: Add USB-device support for PXs3 reference board
In reply to Sasha LevinFrom: Kunihiko Hayashi <[email protected]>
[ Upstream commit 19fee1a1096d21ab1f1e712148b5417bda2939a2 ]
PXs3 reference board can change each USB port 0 and 1 to device mode with jumpers. Prepare devicetree sources for USB port 0 and 1.
This specifies dr_mode, pinctrl, and some quirks and removes nodes for unused phys and vbus-supply properties.
--- arch/arm/boot/dts/uniphier-pinctrl.dtsi | 10 +++++ arch/arm64/boot/dts/socionext/Makefile | 4 +- .../socionext/uniphier-pxs3-ref-gadget0.dts | 41 +++++++++++++++++++ .../socionext/uniphier-pxs3-ref-gadget1.dts | 40 ++++++++++++++++++ 4 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 arch/arm64/boot/dts/socionext/uniphier-pxs3-ref-gadget0.dts create mode 100644 arch/arm64/boot/dts/socionext/uniphier-pxs3-ref-gadget1.dts
arch/arm/boot/dts/uniphier-pinctrl.dtsi +10 -0
@@ -196,11 +196,21 @@ pinctrl_usb0: usb0 { function = "usb0"; }; + pinctrl_usb0_device: usb0-device { + groups = "usb0_device"; + function = "usb0"; + }; + pinctrl_usb1: usb1 { groups = "usb1"; function = "usb1"; }; + pinctrl_usb1_device: usb1-device { + groups = "usb1_device"; + function = "usb1"; + }; + pinctrl_usb2: usb2 { groups = "usb2"; function = "usb2";
arch/arm64/boot/dts/socionext/Makefile +3 -1
@@ -5,4 +5,6 @@ dtb-$(CONFIG_ARCH_UNIPHIER) += \ uniphier-ld20-akebi96.dtb \ uniphier-ld20-global.dtb \ uniphier-ld20-ref.dtb \ - uniphier-pxs3-ref.dtb + uniphier-pxs3-ref.dtb \ + uniphier-pxs3-ref-gadget0.dtb \ + uniphier-pxs3-ref-gadget1.dtb
arch/arm64/boot/dts/socionext/uniphier-pxs3-ref-gadget0.dts new file +41 -0
41 lines not on this page · raw message
arch/arm64/boot/dts/socionext/uniphier-pxs3-ref-gadget1.dts new file +40 -0
@@ -0,0 +1,40 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +// +// Device Tree Source for UniPhier PXs3 Reference Board (for USB-Device #1) +// +// Copyright (C) 2021 Socionext Inc. +// Author: Kunihiko Hayashi <[email protected]> + +/dts-v1/; +#include "uniphier-pxs3-ref.dts" + +/ { + model = "UniPhier PXs3 Reference Board (USB-Device #1)"; +}; + +/* I2C3 pinctrl is shared with USB*VBUSIN */ +&i2c3 { + status = "disabled"; +}; + +&usb1 { + status = "okay"; + dr_mode = "peripheral"; + pinctrl-0 = <&pinctrl_usb1_device>; + snps,dis_enblslpm_quirk; + snps,dis_u2_susphy_quirk; + snps,dis_u3_susphy_quirk; + snps,usb2_gadget_lpm_disable; + phy-names = "usb2-phy", "usb3-phy"; + phys = <&usb1_hsphy0>, <&usb1_ssphy0>; +}; + +&usb1_hsphy0 { + /delete-property/ vbus-supply; +}; + +&usb1_ssphy0 { + /delete-property/ vbus-supply; +}; + +/delete-node/ &usb1_hsphy1;
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 8/26 ARM: dts: imx6sl: add missing properties for sram
In reply to Sasha LevinFrom: Alexander Stein <[email protected]>
[ Upstream commit 60c9213a1d9941a8b33db570796c3f9be8984974 ]
All 3 properties are required by sram.yaml. Fixes the dtbs_check warning:
sram@900000: '#address-cells' is a required property sram@900000: '#size-cells' is a required property sram@900000: 'ranges' is a required property
--- arch/arm/boot/dts/imx6sl.dtsi | 3 +++ 1 file changed, 3 insertions(+)
arch/arm/boot/dts/imx6sl.dtsi +3 -0
@@ -117,6 +117,9 @@ soc { ocram: sram@900000 { compatible = "mmio-sram"; reg = <0x00900000 0x20000>; + ranges = <0 0x00900000 0x20000>; + #address-cells = <1>; + #size-cells = <1>; clocks = <&clks IMX6SL_CLK_OCRAM>; };
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 3/26 soc: mediatek: Let PMIC Wrapper and SCPSYS depend on OF
In reply to Sasha LevinFrom: Jean Delvare <[email protected]>
[ Upstream commit 2778caedb5667239823a29148dfc48b26a8b3c2a ]
With the following configuration options:CONFIG_OF is not setCONFIG_MTK_PMIC_WRAP=yCONFIG_MTK_SCPSYS=y
we get the following build warnings:
CC drivers/soc/mediatek/mtk-pmic-wrap.odrivers/soc/mediatek/mtk-pmic-wrap.c:2138:34: warning: ‘of_pwrap_match_tbl’ defined but not used [-Wunused-const-variable=] drivers/soc/mediatek/mtk-pmic-wrap.c:1953:34: warning: ‘of_slave_match_tbl’ defined but not used [-Wunused-const-variable=]
CC drivers/soc/mediatek/mtk-scpsys.odrivers/soc/mediatek/mtk-scpsys.c:1084:34: warning: ‘of_scpsys_match_tbl’ defined but not used [-Wunused-const-variable=]
Looking at the code, both drivers can only bind to OF-defined device nodes, so these drivers are useless without OF and should therefore depend on it.
Also drop of_match_ptr() from both drivers. We already know what it will resolve to, so we might as well save cpp some work.
Developers or QA teams who wish to test-build the code can still do so by enabling CONFIG_OF, which is available on all architectures and has no dependencies.
--- drivers/soc/mediatek/Kconfig | 2 ++ drivers/soc/mediatek/mtk-pmic-wrap.c | 2 +- drivers/soc/mediatek/mtk-scpsys.c | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-)
drivers/soc/mediatek/Kconfig +2 -0
@@ -37,6 +37,7 @@ config MTK_INFRACFG config MTK_PMIC_WRAP tristate "MediaTek PMIC Wrapper Support" depends on RESET_CONTROLLER + depends on OF select REGMAP help Say yes here to add support for MediaTek PMIC Wrapper found
@@ -46,6 +47,7 @@ config MTK_PMIC_WRAP config MTK_SCPSYS bool "MediaTek SCPSYS Support" default ARCH_MEDIATEK + depends on OF select REGMAP select MTK_INFRACFG select PM_GENERIC_DOMAINS if PM
drivers/soc/mediatek/mtk-pmic-wrap.c +1 -1
@@ -2276,7 +2276,7 @@ static int pwrap_probe(struct platform_device *pdev)static struct platform_driver pwrap_drv = { .driver = { .name ="mt-pmic-pwrap" , - .of_match_table =of_match_ptr (of_pwrap_match_tbl), + .of_match_table = of_pwrap_match_tbl, }, .probe = pwrap_probe, };
drivers/soc/mediatek/mtk-scpsys.c +1 -1
@@ -1141,7 +1141,7 @@ static struct platform_driver scpsys_drv = { .name = "mtk-scpsys", .suppress_bind_attrs = true, .owner = THIS_MODULE, - .of_match_table = of_match_ptr(of_scpsys_match_tbl), + .of_match_table = of_scpsys_match_tbl, }, };builtin_platform_driver (scpsys_drv);
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 9/26 ARM: dts: imx6sll: add missing properties for sram
In reply to Sasha LevinFrom: Alexander Stein <[email protected]>
[ Upstream commit 7492a83ed9b7a151e2dd11d64b06da7a7f0fa7f9 ]
All 3 properties are required by sram.yaml. Fixes the dtbs_check warning:
sram@900000: '#address-cells' is a required property sram@900000: '#size-cells' is a required property sram@900000: 'ranges' is a required property
--- arch/arm/boot/dts/imx6sll.dtsi | 3 +++ 1 file changed, 3 insertions(+)
arch/arm/boot/dts/imx6sll.dtsi +3 -0
@@ -117,6 +117,9 @@ soc { ocram: sram@900000 { compatible = "mmio-sram"; reg = <0x00900000 0x20000>; + ranges = <0 0x00900000 0x20000>; + #address-cells = <1>; + #size-cells = <1>; }; intc: interrupt-controller@a01000 {
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 10/26 ARM: dts: imx6sx: add missing properties for sram
In reply to Sasha LevinFrom: Alexander Stein <[email protected]>
[ Upstream commit 415432c008b2bce8138841356ba444631cabaa50 ]
All 3 properties are required by sram.yaml. Fixes the dtbs_check warning:
sram@900000: '#address-cells' is a required property sram@900000: '#size-cells' is a required property sram@900000: 'ranges' is a required property
--- arch/arm/boot/dts/imx6sx.dtsi | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm/boot/dts/imx6sx.dtsi +6 -0
@@ -164,12 +164,18 @@ soc { ocram_s: sram@8f8000 { compatible = "mmio-sram"; reg = <0x008f8000 0x4000>; + ranges = <0 0x008f8000 0x4000>; + #address-cells = <1>; + #size-cells = <1>; clocks = <&clks IMX6SX_CLK_OCRAM_S>; }; ocram: sram@900000 { compatible = "mmio-sram"; reg = <0x00900000 0x20000>; + ranges = <0 0x00900000 0x20000>; + #address-cells = <1>; + #size-cells = <1>; clocks = <&clks IMX6SX_CLK_OCRAM>; };
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 11/26 kselftest/arm64: Fix validatation termination record after EXTRA_CONTEXT
In reply to Sasha LevinFrom: Mark Brown <[email protected]>
[ Upstream commit 5c152c2f66f9368394b89ac90dc7483476ef7b88 ]
When arm64 signal context data overflows the base struct sigcontext it gets placed in an extra buffer pointed to by a record of type EXTRA_CONTEXT in the base struct sigcontext which is required to be the last record in the base struct sigframe. The current validation code attempts to check this by using GET_RESV_NEXT_HEAD() to step forward from the current record to the next but that is a macro which assumes it is being provided with a struct _aarch64_ctx and uses the size there to skip forward to the next record. Instead validate_extra_context() passes it a struct extra_context which has a separate size field. This compiles but results in us trying to validate a termination record in completely the wrong place, at best failing validation and at worst just segfaulting. Fix this by passing the struct _aarch64_ctx we meant to into the macro.
--- tools/testing/selftests/arm64/signal/testcases/testcases.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/arm64/signal/testcases/testcases.c +1 -1
@@ -33,7 +33,7 @@ bool validate_extra_context(struct extra_context *extra, char **err)return false;fprintf (stderr,"Validating EXTRA...\n" ); - term =GET_RESV_NEXT_HEAD (extra); + term =GET_RESV_NEXT_HEAD (&extra->head);if (!term || term->magic || term->size) { *err ="Missing terminator after EXTRA context" ;return false;
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 12/26 sparc: Fix the generic IO helpers
In reply to Sasha LevinFrom: Linus Walleij <[email protected]>
[ Upstream commit 2c230431e1e809270178905974f57cf3878939f5 ]
This enables the Sparc to use <asm-generic/io.h> to fill in the missing (undefined) [read|write]sq I/O accessor functions.
This is needed if Sparc[64] ever wants to uses CONFIG_REGMAP_MMIO which has been patches to use accelerated _noinc accessors such as readsq/writesq that Sparc64, while being a 64bit platform, as of now not yet provide.
This comes with the requirement that everything the architecture already provides needs to be defined, rather than just being, say, static inline functions.
Bite the bullet and just provide the definitions and make it work. Compile-tested on sparc32 and sparc64.
--- arch/sparc/include/asm/io.h | 2 ++ arch/sparc/include/asm/io_64.h | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+)
arch/sparc/include/asm/io.h +2 -0
@@ -19,4 +19,6 @@#define writel_be (__w, __addr) __raw_writel(__w, __addr)#define writew_be (__l, __addr) __raw_writew(__l, __addr) +#include <asm-generic/io.h> +#endif
arch/sparc/include/asm/io_64.h +22 -0
@@ -9,6 +9,7 @@#include <asm/page.h> /* IO address mapping routines need this */ #include <asm/asi.h> #include <asm-generic/pci_iomap.h> +#define pci_iomap pci_iomap/* BIO layer definitions. */ extern unsigned long kern_base, kern_size;
@@ -239,38 +240,51 @@ static inline void outl(u32 l, unsigned long addr)void outsb (unsigned long ,const void *,unsigned long );void outsw (unsigned long ,const void *,unsigned long );void outsl (unsigned long ,const void *,unsigned long ); +#define outsb outsb +#define outsw outsw +#define outsl outslvoid insb (unsigned long ,void *,unsigned long );void insw (unsigned long ,void *,unsigned long );void insl (unsigned long ,void *,unsigned long ); +#define insb insb +#define insw insw +#define insl inslstatic inline void readsb (void __iomem *port,void *buf,unsigned long count) {insb ((unsigned long __force )port, buf, count); } +#define readsb readsb +static inline void readsw (void __iomem *port,void *buf,unsigned long count) {insw ((unsigned long __force )port, buf, count); } +#define readsw readswstatic inline void readsl (void __iomem *port,void *buf,unsigned long count) {insl ((unsigned long __force )port, buf, count); } +#define readsl readslstatic inline void writesb (void __iomem *port,const void *buf,unsigned long count) {outsb ((unsigned long __force )port, buf, count); } +#define writesb writesbstatic inline void writesw (void __iomem *port,const void *buf,unsigned long count) {outsw ((unsigned long __force )port, buf, count); } +#define writesw writeswstatic inline void writesl (void __iomem *port,const void *buf,unsigned long count) {outsl ((unsigned long __force )port, buf, count); } +#define writesl writesl#define ioread8_rep (p,d,l) readsb(p,d,l)#define ioread16_rep (p,d,l) readsw(p,d,l)
@@ -344,6 +358,7 @@ static inline void memset_io(volatile void __iomem *dst, int c, __kernel_size_t d++; } } +#define memset_io memset_iostatic inline void sbus_memcpy_fromio (void *dst,const volatile void __iomem *src,__kernel_size_t n)
@@ -369,6 +384,7 @@ static inline void memcpy_fromio(void *dst, const volatile void __iomem *src, src++; } } +#define memcpy_fromio memcpy_fromiostatic inline void sbus_memcpy_toio (volatile void __iomem *dst,const void *src,__kernel_size_t n)
@@ -395,6 +411,7 @@ static inline void memcpy_toio(volatile void __iomem *dst, const void *src, d++; } } +#define memcpy_toio memcpy_toio#ifdef __KERNEL__
@@ -412,7 +429,9 @@ static inline void __iomem *ioremap(unsigned long offset, unsigned long size)static inline void __iomem *ioremap_np (unsigned long offset,unsigned long size) {return NULL ; + } +#define ioremap_np ioremap_npstatic inline void iounmap (volatile void __iomem *addr) {
@@ -432,10 +451,13 @@ static inline void iounmap(volatile void __iomem *addr)/* Create a virtual mapping cookie for an IO port range */ void __iomem *ioport_map (unsigned long port,unsigned int nr);void ioport_unmap (void __iomem *); +#define ioport_map ioport_map +#define ioport_unmap ioport_unmap/* Create a virtual mapping cookie for a PCI BAR (memory or IO) */ struct pci_dev ;void pci_iounmap (struct pci_dev *dev,void __iomem *); +#define pci_iounmap pci_iounmapstatic inline int sbus_can_dma_64bit (void ) {
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 13/26 arm64: run softirqs on the per-CPU IRQ stack
In reply to Sasha LevinFrom: Qi Zheng <[email protected]>
[ Upstream commit 8eb858c44b98e0326bb32fca34ae671995cd73bb ]
Currently arm64 supports per-CPU IRQ stack, but softirqs are still handled in the task context.
Since any call to local_bh_enable() at any level in the task's call stack may trigger a softirq processing run, which could potentially cause a task stack overflow if the combined stack footprints exceed the stack's size, let's run these softirqs on the IRQ stack as well.
--- arch/arm64/Kconfig | 1 + arch/arm64/kernel/irq.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+)
arch/arm64/Kconfig +1 -0
@@ -221,6 +221,7 @@ config ARM64 select HAVE_ARCH_USERFAULTFD_MINOR if USERFAULTFD select TRACE_IRQFLAGS_SUPPORT select TRACE_IRQFLAGS_NMI_SUPPORT + select HAVE_SOFTIRQ_ON_OWN_STACK help ARM 64-bit (AArch64) Linux support.
arch/arm64/kernel/irq.c +14 -0
@@ -21,7 +21,9 @@#include <linux/seq_file.h> #include <linux/vmalloc.h> #include <asm/daifflags.h> +#include <asm/exception.h> #include <asm/vmap_stack.h> +#include <asm/softirq_stack.h> /* Only access this in an NMI enter/exit */ DEFINE_PER_CPU(struct nmi_ctx, nmi_contexts);
@@ -71,6 +73,18 @@ static void init_irq_stacks(void) }#endif +#ifndef CONFIG_PREEMPT_RT +static void ____do_softirq (struct pt_regs *regs) +{ +__do_softirq (); +} + +void do_softirq_own_stack (void ) +{ +call_on_irq_stack (NULL , ____do_softirq); +} +#endif +static void default_handle_irq (struct pt_regs *regs) {panic ("IRQ taken without a root IRQ handler\n" );
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 22/26 btrfs: add KCSAN annotations for unlocked access to block_rsv->full
In reply to Sasha LevinFrom: David Sterba <[email protected]>
[ Upstream commit 748f553c3c4c4f175c6c834358632aff802d72cf ]
KCSAN reports that there's unlocked access mixed with locked access, which is technically correct but is not a bug. To avoid false alerts at least from KCSAN, add annotation and use a wrapper whenever ->full is accessed for read outside of lock.
It is used as a fast check and only advisory. In the worst case the block reserve is found !full and becomes full in the meantime, but properly handled.
Depending on the value of ->full, btrfs_block_rsv_release decides where to return the reservation, and block_rsv_release_bytes handles a NULL pointer for block_rsv and if it's not NULL then it double checks the full status under a lock.
--- fs/btrfs/block-rsv.c | 2 +- fs/btrfs/block-rsv.h | 9 +++++++++ fs/btrfs/transaction.c | 4 ++-- 3 files changed, 12 insertions(+), 3 deletions(-)
fs/btrfs/block-rsv.c +1 -1
@@ -285,7 +285,7 @@ u64 btrfs_block_rsv_release(struct btrfs_fs_info *fs_info,*/ if (block_rsv == delayed_rsv) target = global_rsv; -else if (block_rsv != global_rsv && !delayed_rsv->full) +else if (block_rsv != global_rsv && !btrfs_block_rsv_full (delayed_rsv)) target = delayed_rsv;if (target && block_rsv->space_info != target->space_info)
fs/btrfs/block-rsv.h +9 -0
@@ -90,4 +90,13 @@ static inline void btrfs_unuse_block_rsv(struct btrfs_fs_info *fs_info, btrfs_block_rsv_release(fs_info, block_rsv, 0, NULL); } +/* +* Fast path to check if the reserve is full, may be carefully used outside of +* locks. +*/ +static inline bool btrfs_block_rsv_full (const struct btrfs_block_rsv *rsv) +{ +return data_race (rsv->full); +} +#endif /* BTRFS_BLOCK_RSV_H */
fs/btrfs/transaction.c +2 -2
@@ -619,7 +619,7 @@ start_transaction(struct btrfs_root *root, unsigned int num_items,*/ num_bytes =btrfs_calc_insert_metadata_size (fs_info, num_items);if (flush ==BTRFS_RESERVE_FLUSH_ALL && - delayed_refs_rsv->full ==0 ) { +btrfs_block_rsv_full (delayed_refs_rsv) ==0 ) { delayed_refs_bytes = num_bytes; num_bytes <<=1 ; }
@@ -644,7 +644,7 @@ start_transaction(struct btrfs_root *root, unsigned int num_items,if (rsv->space_info->force_alloc) do_chunk_alloc = true; }else if (num_items ==0 && flush ==BTRFS_RESERVE_FLUSH_ALL && - !delayed_refs_rsv->full) { + !btrfs_block_rsv_full (delayed_refs_rsv)) {/* * Some people call with btrfs_start_transaction(root, 0) * because they can be throttled, but have some other mechanism
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 25/26 ARM: 9242/1: kasan: Only map modules if CONFIG_KASAN_VMALLOC=n
In reply to Sasha LevinFrom: Alex Sverdlin <[email protected]>
[ Upstream commit 823f606ab6b4759a1faf0388abcf4fb0776710d2 ]
In case CONFIG_KASAN_VMALLOC=y kasan_populate_vmalloc() allocates the shadow pages dynamically. But even worse is that kasan_release_vmalloc() releases them, which is not compatible with create_mapping() of MODULES_VADDR..MODULES_END range:
BUG: Bad page state in process kworker/9:1 pfn:2068b page:e5e06160 refcount:0 mapcount:0 mapping:00000000 index:0x0 flags: 0x1000(reserved) raw: 00001000 e5e06164 e5e06164 00000000 00000000 00000000 ffffffff 00000000 page dumped because: PAGE_FLAGS_CHECK_AT_FREE flag(s) set bad because of flags: 0x1000(reserved) Modules linked in: ip_tables CPU: 9 PID: 154 Comm: kworker/9:1 Not tainted 5.4.188-... #1 Hardware name: LSI Axxia AXM55XX Workqueue: events do_free_init
unwind_backtraceshow_stackdump_stackbad_pagefree_pcp_preparefree_unref_pagekasan_depopulate_vmalloc_pte__apply_to_page_rangeapply_to_existing_page_rangekasan_release_vmalloc__purge_vmap_area_lazy
_vm_unmap_aliases.part.0__vunmapdo_free_initprocess_one_workworker_thread
kthread
--- arch/arm/mm/kasan_init.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/arm/mm/kasan_init.c +7 -2
@@ -264,12 +264,17 @@ void __init kasan_init(void)/* * 1. The module global variables are in MODULES_VADDR ~ MODULES_END, -* so we need to map this area. +* so we need to map this area if CONFIG_KASAN_VMALLOC=n. With +* VMALLOC support KASAN will manage this region dynamically, +* refer to kasan_populate_vmalloc() and ARM's implementation of +* module_alloc(). * 2. PKMAP_BASE ~ PKMAP_BASE+PMD_SIZE's shadow and MODULES_VADDR * ~ MODULES_END's shadow is in the same PMD_SIZE, so we can't * use kasan_populate_zero_shadow. */ -create_mapping ((void *)MODULES_VADDR , (void *)(PKMAP_BASE +PMD_SIZE )); +if (!IS_ENABLED (CONFIG_KASAN_VMALLOC ) &&IS_ENABLED (CONFIG_MODULES )) +create_mapping ((void *)MODULES_VADDR , (void *)(MODULES_END )); +create_mapping ((void *)PKMAP_BASE , (void *)(PKMAP_BASE +PMD_SIZE ));/* * KAsan may reuse the contents of kasan_early_shadow_pte directly, so
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 20/26 btrfs: don't print information about space cache or tree every remount
In reply to Sasha LevinFrom: "Maciej S. Szmigiero" <[email protected]>
[ Upstream commit dbecac26630014d336a8e5ea67096ff18210fb9c ]
btrfs currently prints information about space cache or free space tree being in use on every remount, regardless whether such remount actually enabled or disabled one of these features.
This is actually unnecessary since providing remount options changing the state of these features will explicitly print the appropriate notice.
Let's instead print such unconditional information just on an initial mount to avoid filling the kernel log when, for example, laptop-mode-tools remount the fs on some events.
--- fs/btrfs/super.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
fs/btrfs/super.c +7 -4
@@ -574,6 +574,7 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,int saved_compress_level;bool saved_compress_force;int no_compress =0 ; +const bool remounting =test_bit (BTRFS_FS_STATE_REMOUNTING , &info->fs_state);if (btrfs_fs_compat_ro (info,FREE_SPACE_TREE ))btrfs_set_opt (info->mount_opt,FREE_SPACE_TREE );
@@ -1065,10 +1066,12 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options, }if (!ret) ret =btrfs_check_mountopts_zoned (info); -if (!ret &&btrfs_test_opt (info,SPACE_CACHE )) -btrfs_info (info,"disk space caching is enabled" ); -if (!ret &&btrfs_test_opt (info,FREE_SPACE_TREE )) -btrfs_info (info,"using free space tree" ); +if (!ret && !remounting) { +if (btrfs_test_opt (info,SPACE_CACHE )) +btrfs_info (info,"disk space caching is enabled" ); +if (btrfs_test_opt (info,FREE_SPACE_TREE )) +btrfs_info (info,"using free space tree" ); + }return ret; }
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 19/26 btrfs: scrub: try to fix super block errors
In reply to Sasha LevinFrom: Qu Wenruo <[email protected]>
[ Upstream commit f9eab5f0bba76742af654f33d517bf62a0db8f12 ]
[BUG]
The following script shows that, although scrub can detect super block errors, it never tries to fix it:
mkfs.btrfs -f -d raid1 -m raid1 $dev1 $dev2 xfs_io -c "pwrite 67108864 4k" $dev2
mount $dev1 $mnt
btrfs scrub start -B $dev2
btrfs scrub start -Br $dev2
umount $mnt
The first scrub reports the super error correctly:
scrub done for f3289218-abd3-41ac-a630-202f766c0859
Scrub started: Tue Aug 2 14:44:11 2022
Status: finished
Duration: 0:00:00
Total to scrub: 1.26GiB
Rate: 0.00B/s
Error summary: super=1
Corrected: 0
Uncorrectable: 0
Unverified: 0But the second read-only scrub still reports the same super error:
Scrub started: Tue Aug 2 14:44:11 2022
Status: finished
Duration: 0:00:00
Total to scrub: 1.26GiB
Rate: 0.00B/s
Error summary: super=1
Corrected: 0
Uncorrectable: 0
Unverified: 0[CAUSE]
The comments already shows that super block can be easily fixed by committing a transaction:
/*
* If we find an error in a super block, we just report it.
* They will get written with the next transaction commit
* anyway
*/
But the truth is, such assumption is not always true, and since scrub should try to repair every error it found (except for read-only scrub), we should really actively commit a transaction to fix this.
[FIX]
Just commit a transaction if we found any super block errors, after everything else is done.
We cannot do this just after scrub_supers(), as btrfs_commit_transaction() will try to pause and wait for the running scrub, thus we can not call it with scrub_lock hold.
--- fs/btrfs/scrub.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
fs/btrfs/scrub.c +36 -0
@@ -4072,6 +4072,7 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,int ret;struct btrfs_device *dev;unsigned int nofs_flag; +bool need_commit = false;if (btrfs_fs_closing (fs_info))return -EAGAIN ;
@@ -4177,6 +4178,12 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,*/ nofs_flag =memalloc_nofs_save ();if (!is_dev_replace) { +u64 old_super_errors; + +spin_lock (&sctx->stat_lock); + old_super_errors = sctx->stat.super_errors; +spin_unlock (&sctx->stat_lock); +btrfs_info (fs_info,"scrub: started on devid %llu" , devid);/* * by holding device list mutex, we can
@@ -4185,6 +4192,16 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,mutex_lock (&fs_info->fs_devices->device_list_mutex); ret =scrub_supers (sctx, dev);mutex_unlock (&fs_info->fs_devices->device_list_mutex); + +spin_lock (&sctx->stat_lock); +/* +* Super block errors found, but we can not commit transaction +* at current context, since btrfs_commit_transaction() needs +* to pause the current running scrub (hold by ourselves). +*/ +if (sctx->stat.super_errors > old_super_errors && !sctx->readonly) + need_commit = true; +spin_unlock (&sctx->stat_lock); }if (!ret)
@@ -4211,6 +4228,25 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,scrub_workers_put (fs_info);scrub_put_ctx (sctx); +/* +* We found some super block errors before, now try to force a +* transaction commit, as scrub has finished. +*/ +if (need_commit) { +struct btrfs_trans_handle *trans; + + trans =btrfs_start_transaction (fs_info->tree_root,0 ); +if (IS_ERR (trans)) { + ret =PTR_ERR (trans); +btrfs_err (fs_info, +"scrub: failed to start transaction to fix super block errors: %d" , ret); +return ret; + } + ret =btrfs_commit_transaction (trans); +if (ret <0 ) +btrfs_err (fs_info, +"scrub: failed to commit transaction to fix super block errors: %d" , ret); + }return ret; out:scrub_workers_put (fs_info);
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 26/26 selftests/cpu-hotplug: Use return instead of exit
In reply to Sasha LevinFrom: Zhao Gongyi <[email protected]>
[ Upstream commit 972cf4ce51ef5532d56822af17defb148aac0ccb ]
Some cpus will be left in offline state when online function exits in some error conditions. Use return instead of exit to fix it.
--- .../selftests/cpu-hotplug/cpu-on-off-test.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh +8 -5
@@ -4,6 +4,7 @@ SYSFS= # Kselftest framework requirement - SKIP code is 4. ksft_skip=4 +retval=0 prerequisite() {
@@ -102,10 +103,10 @@ online_cpu_expect_success() if ! online_cpu $cpu; then echo $FUNCNAME $cpu: unexpected fail >&2 - exit 1 + retval=1 elif ! cpu_is_online $cpu; then echo $FUNCNAME $cpu: unexpected offline >&2 - exit 1 + retval=1 fi }
@@ -128,10 +129,10 @@ offline_cpu_expect_success() if ! offline_cpu $cpu; then echo $FUNCNAME $cpu: unexpected fail >&2 - exit 1 + retval=1 elif ! cpu_is_offline $cpu; then echo $FUNCNAME $cpu: unexpected offline >&2 - exit 1 + retval=1 fi }
@@ -201,7 +202,7 @@ if [ $allcpus -eq 0 ]; then offline_cpu_expect_success $present_max online_cpu $present_max fi - exit 0 + exit $retval else echo "Full scope test: all hotplug cpus" echo -e "\t online all offline cpus"
@@ -291,3 +292,5 @@ done echo 0 > $NOTIFIER_ERR_INJECT_DIR/actions/CPU_DOWN_PREPARE/error /sbin/modprobe -q -r cpu-notifier-error-inject + +exit $retval
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 21/26 btrfs: check superblock to ensure the fs was not modified at thaw time
In reply to Sasha LevinFrom: Qu Wenruo <[email protected]>
[ Upstream commit a05d3c9153145283ce9c58a1d7a9056fbb85f6a1 ]
[BACKGROUND]
There is an incident report that, one user hibernated the system, with one btrfs on removable device still mounted.
Then by some incident, the btrfs got mounted and modified by another system/OS, then back to the hibernated system.
After resuming from the hibernation, new write happened into the victim btrfs.
Now the fs is completely broken, since the underlying btrfs is no longer the same one before the hibernation, and the user lost their data due to various transid mismatch.
[REPRODUCER]
We can emulate the situation using the following small script:
truncate -s 1G $dev
mkfs.btrfs -f $dev
mount $dev $mnt
fsstress -w -d $mnt -n 500
sync
xfs_freeze -f $mnt
cp $dev $dev.backup
# There is no way to mount the same cloned fs on the same system,
# as the conflicting fsid will be rejected by btrfs. # Thus here we have to wipe the fs using a different btrfs. mkfs.btrfs -f $dev.backup
dd if=$dev.backup of=$dev bs=1M
xfs_freeze -u $mnt
fsstress -w -d $mnt -n 20
umount $mnt
btrfs check $dev
The final fsck will fail due to some tree blocks has incorrect fsid.
This is enough to emulate the problem hit by the unfortunate user.
[ENHANCEMENT]
Although such case should not be that common, it can still happen from time to time.
From the view of btrfs, we can detect any unexpected super block change, and if there is any unexpected change, we just mark the fs read-only, and thaw the fs.
By this we can limit the damage to minimal, and I hope no one would lose their data by this anymore.
--- fs/btrfs/disk-io.c | 25 ++++++++++++++----- fs/btrfs/disk-io.h | 4 +++- fs/btrfs/super.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++ fs/btrfs/volumes.c | 2 +- 4 files changed, 83 insertions(+), 8 deletions(-)
fs/btrfs/disk-io.c +19 -6
@@ -2489,8 +2489,8 @@ static int btrfs_read_roots(struct btrfs_fs_info *fs_info)* 1, 2 2nd and 3rd backup copy * -1 skip bytenr check */ -static int validate_super (struct btrfs_fs_info *fs_info, -struct btrfs_super_block *sb,int mirror_num) +int btrfs_validate_super (struct btrfs_fs_info *fs_info, +struct btrfs_super_block *sb,int mirror_num) {u64 nodesize =btrfs_super_nodesize (sb);u64 sectorsize =btrfs_super_sectorsize (sb);
@@ -2673,7 +2673,7 @@ static int validate_super(struct btrfs_fs_info *fs_info,*/ static int btrfs_validate_mount_super (struct btrfs_fs_info *fs_info) { -return validate_super (fs_info, fs_info->super_copy,0 ); +return btrfs_validate_super (fs_info, fs_info->super_copy,0 ); }/*
@@ -2687,7 +2687,7 @@ static int btrfs_validate_write_super(struct btrfs_fs_info *fs_info, {int ret; - ret =validate_super (fs_info, sb,-1 ); + ret =btrfs_validate_super (fs_info, sb,-1 );if (ret <0 ) goto out;if (!btrfs_supported_super_csum (btrfs_super_csum_type (sb))) {
@@ -3701,7 +3701,7 @@ static void btrfs_end_super_write(struct bio *bio) }struct btrfs_super_block *btrfs_read_dev_one_super (struct block_device *bdev, -int copy_num) +int copy_num,bool drop_cache) {struct btrfs_super_block *super;struct page *page;
@@ -3719,6 +3719,19 @@ struct btrfs_super_block *btrfs_read_dev_one_super(struct block_device *bdev,if (bytenr +BTRFS_SUPER_INFO_SIZE >=i_size_read (bdev->bd_inode))return ERR_PTR (-EINVAL ); +if (drop_cache) { +/* This should only be called with the primary sb. */ +ASSERT (copy_num ==0 ); + +/* +* Drop the page of the primary superblock, so later read will +* always read from the device. +*/ +invalidate_inode_pages2_range (mapping, + bytenr >>PAGE_SHIFT , + (bytenr +BTRFS_SUPER_INFO_SIZE ) >>PAGE_SHIFT ); + } + page =read_cache_page_gfp (mapping, bytenr >>PAGE_SHIFT ,GFP_NOFS );if (IS_ERR (page))return ERR_CAST (page);
@@ -3750,7 +3763,7 @@ struct btrfs_super_block *btrfs_read_dev_super(struct block_device *bdev)* later supers, using BTRFS_SUPER_MIRROR_MAX instead */ for (i =0 ; i <1 ; i++) { - super =btrfs_read_dev_one_super (bdev, i); + super =btrfs_read_dev_one_super (bdev, i, false);if (IS_ERR (super))continue ;
fs/btrfs/disk-io.h +3 -1
@@ -56,10 +56,12 @@ int __cold open_ctree(struct super_block *sb,struct btrfs_fs_devices *fs_devices, char *options);void __cold close_ctree (struct btrfs_fs_info *fs_info); +int btrfs_validate_super (struct btrfs_fs_info *fs_info, +struct btrfs_super_block *sb,int mirror_num);int write_all_supers (struct btrfs_fs_info *fs_info,int max_mirrors);struct btrfs_super_block *btrfs_read_dev_super (struct block_device *bdev);struct btrfs_super_block *btrfs_read_dev_one_super (struct block_device *bdev, -int copy_num); +int copy_num,bool drop_cache);int btrfs_commit_super (struct btrfs_fs_info *fs_info);struct btrfs_root *btrfs_read_tree_root (struct btrfs_root *tree_root,struct btrfs_key *key);
fs/btrfs/super.c +60 -0
71 lines not on this page · raw message
fs/btrfs/volumes.c +1 -1
@@ -2074,7 +2074,7 @@ void btrfs_scratch_superblocks(struct btrfs_fs_info *fs_info,struct page *page;int ret; - disk_super =btrfs_read_dev_one_super (bdev, copy_num); + disk_super =btrfs_read_dev_one_super (bdev, copy_num, false);if (IS_ERR (disk_super))continue ;
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 15/26 ARM: orion: fix include path
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 63872304bdb3decd5454f4dd210c25395278ed13 ]
Now that CONFIG_ARCH_MULTIPLATFORM can be disabled anywhere, there is a build failure for plat-orion:
arch/arm/plat-orion/irq.c:19:10: fatal error: plat/irq.h: No such file or directory
Make the include path unconditional.
--- arch/arm/plat-orion/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/plat-orion/Makefile +1 -1
@@ -2,7 +2,7 @@ # # Makefile for the linux kernel. # -ccflags-$(CONFIG_ARCH_MULTIPLATFORM) := -I$(srctree)/$(src)/include +ccflags-y := -I$(srctree)/$(src)/include orion-gpio-$(CONFIG_GPIOLIB) += gpio.o obj-$(CONFIG_PLAT_ORION_LEGACY) += irq.o pcie.o time.o common.o mpp.o
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 18/26 btrfs: change the lockdep class of free space inode's invalidate_lock
In reply to Sasha LevinFrom: Ioannis Angelakopoulos <[email protected]>
[ Upstream commit 9d7464c87b159bbf763c24faeb7a2dcaac96e4a1 ]
Reinitialize the class of the lockdep map for struct inode's mapping->invalidate_lock in load_free_space_cache() function in fs/btrfs/free-space-cache.c. This will prevent lockdep from producing false positives related to execution paths that make use of free space inodes and paths that make use of normal inodes.
Specifically, with this change lockdep will create separate lock dependencies that include the invalidate_lock, in the case that free space inodes are used and in the case that normal inodes are used.
The lockdep class for this lock was first initialized in inode_init_always() in fs/inode.c.
--- fs/btrfs/free-space-cache.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
fs/btrfs/free-space-cache.c +10 -0
@@ -899,6 +899,8 @@ static int copy_free_space_cache(struct btrfs_block_group *block_group,return ret; } +static struct lock_class_key btrfs_free_space_inode_key; +int load_free_space_cache (struct btrfs_block_group *block_group) {struct btrfs_fs_info *fs_info = block_group->fs_info;
@@ -968,6 +970,14 @@ int load_free_space_cache(struct btrfs_block_group *block_group) }spin_unlock (&block_group->lock); +/* +* Reinitialize the class of struct inode's mapping->invalidate_lock for +* free space inodes to prevent false positives related to locks for normal +* inodes. +*/ +lockdep_set_class (&(&inode->i_data)->invalidate_lock, + &btrfs_free_space_inode_key); + ret =__load_free_space_cache (fs_info->tree_root, inode, &tmp_ctl, path, block_group->start);btrfs_free_path (path);
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 17/26 btrfs: add macros for annotating wait events with lockdep
In reply to Sasha LevinFrom: Ioannis Angelakopoulos <[email protected]>
[ Upstream commit ab9a323f9ab576000795285dd7ac6afeedf29e32 ]
Introduce four macros that are used to annotate wait events in btrfs code with lockdep;
1) the btrfs_lockdep_init_map
2) the btrfs_lockdep_acquire,
3) the btrfs_lockdep_release
4) the btrfs_might_wait_for_event macros.
The btrfs_lockdep_init_map macro is used to initialize a lockdep map.
The btrfs_lockdep_<acquire,release> macros are used by threads to take the lockdep map as readers (shared lock) and release it, respectively.
The btrfs_might_wait_for_event macro is used by threads to take the lockdep map as writers (exclusive lock) and release it.
In general, the lockdep annotation for wait events work as follows:
The condition for a wait event can be modified and signaled at the same time by multiple threads. These threads hold the lockdep map as readers when they enter a context in which blocking would prevent signaling the condition. Frequently, this occurs when a thread violates a condition (lockdep map acquire), before restoring it and signaling it at a later point (lockdep map release).
The threads that block on the wait event take the lockdep map as writers (exclusive lock). These threads have to block until all the threads that hold the lockdep map as readers signal the condition for the wait event and release the lockdep map.
The lockdep annotation is used to warn about potential deadlock scenarios that involve the threads that modify and signal the wait event condition and threads that block on the wait event. A simple example is illustrated below:
Without lockdep:
TA TB
cond = false
lock(A)
wait_event(w, cond)
unlock(A)lock(A)
cond = true
signal(w)
unlock(A)
With lockdep:
TA TBrwsem_acquire_read(lockdep_map)
cond = false
lock(A)
rwsem_acquire(lockdep_map)
rwsem_release(lockdep_map)
wait_event(w, cond)
unlock(A)lock(A)
cond = true
signal(w)
unlock(A)rwsem_release(lockdep_map)
In the second case, with the lockdep annotation, lockdep would warn about an ABBA deadlock, while the first case would just deadlock at some point.
--- fs/btrfs/ctree.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+)
fs/btrfs/ctree.h +45 -0
@@ -1108,6 +1108,51 @@ enum { BTRFS_ROOT_RESET_LOCKDEP_CLASS, }; +/* +* Lockdep annotation for wait events. +* +* @owner: The struct where the lockdep map is defined +* @lock: The lockdep map corresponding to a wait event +* +* This macro is used to annotate a wait event. In this case a thread acquires +* the lockdep map as writer (exclusive lock) because it has to block until all +* the threads that hold the lock as readers signal the condition for the wait +* event and release their locks. +*/ +#define btrfs_might_wait_for_event (owner, lock) \ + do { \ + rwsem_acquire(&owner->lock##_map, 0, 0, _THIS_IP_); \ + rwsem_release(&owner->lock##_map, _THIS_IP_); \ + } while (0) + +/* +* Protection for the resource/condition of a wait event. +* +* @owner: The struct where the lockdep map is defined +* @lock: The lockdep map corresponding to a wait event +* +* Many threads can modify the condition for the wait event at the same time +* and signal the threads that block on the wait event. The threads that modify +* the condition and do the signaling acquire the lock as readers (shared +* lock). +*/ +#define btrfs_lockdep_acquire (owner, lock) \ + rwsem_acquire_read(&owner->lock##_map, 0, 0, _THIS_IP_) + +/* +* Used after signaling the condition for a wait event to release the lockdep +* map held by a reader thread. +*/ +#define btrfs_lockdep_release (owner, lock) \ + rwsem_release(&owner->lock##_map, _THIS_IP_) + +/* Initialization of the lockdep map */ +#define btrfs_lockdep_init_map (owner, lock) \ + do { \ + static struct lock_class_key lock##_key; \ + lockdep_init_map(&owner->lock##_map, #lock, &lock##_key, 0); \ + } while (0) +static inline void btrfs_wake_unfinished_drop (struct btrfs_fs_info *fs_info) {clear_and_wake_up_bit (BTRFS_FS_UNFINISHED_DROPS , &fs_info->flags);
Signature · 1 line
2.35.1
Sasha Levin
maintainerPATCH 23/26 btrfs: separate out the eb and extent state leak helpers
In reply to Sasha LevinFrom: Josef Bacik <[email protected]>
[ Upstream commit a40246e8afc0af3ffdee21854fb755c9364b8346 ]
Currently we have the add/del functions generic so that we can use them for both extent buffers and extent states. We want to separate this code however, so separate these helpers into per-object helpers in anticipation of the split.
--- fs/btrfs/extent_io.c | 58 +++++++++++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 20 deletions(-)
fs/btrfs/extent_io.c +38 -20
@@ -43,25 +43,42 @@ static inline bool extent_state_in_tree(const struct extent_state *state)static LIST_HEAD (states);static DEFINE_SPINLOCK (leak_lock); -static inline void btrfs_leak_debug_add (spinlock_t *lock, -struct list_head *new, -struct list_head *head) +static inline void btrfs_leak_debug_add_eb (struct extent_buffer *eb) +{ +struct btrfs_fs_info *fs_info = eb->fs_info; +unsigned long flags; + +spin_lock_irqsave (&fs_info->eb_leak_lock, flags); +list_add (&eb->leak_list, &fs_info->allocated_ebs); +spin_unlock_irqrestore (&fs_info->eb_leak_lock, flags); +} + +static inline void btrfs_leak_debug_add_state (struct extent_state *state) {unsigned long flags; -spin_lock_irqsave (lock, flags); -list_add (new, head); -spin_unlock_irqrestore (lock, flags); +spin_lock_irqsave (&leak_lock, flags); +list_add (&state->leak_list, &states); +spin_unlock_irqrestore (&leak_lock, flags); +} + +static inline void btrfs_leak_debug_del_eb (struct extent_buffer *eb) +{ +struct btrfs_fs_info *fs_info = eb->fs_info; +unsigned long flags; + +spin_lock_irqsave (&fs_info->eb_leak_lock, flags); +list_del (&eb->leak_list); +spin_unlock_irqrestore (&fs_info->eb_leak_lock, flags); } -static inline void btrfs_leak_debug_del (spinlock_t *lock, -struct list_head *entry) +static inline void btrfs_leak_debug_del_state (struct extent_state *state) {unsigned long flags; -spin_lock_irqsave (lock, flags); -list_del (entry); -spin_unlock_irqrestore (lock, flags); +spin_lock_irqsave (&leak_lock, flags); +list_del (&state->leak_list); +spin_unlock_irqrestore (&leak_lock, flags); }void btrfs_extent_buffer_leak_debug_check (struct btrfs_fs_info *fs_info)
@@ -124,9 +141,11 @@ static inline void __btrfs_debug_check_extent_io_range(const char *caller, } }#else -#define btrfs_leak_debug_add (lock, new, head) do {} while (0) -#define btrfs_leak_debug_del (lock, entry) do {} while (0) -#define btrfs_extent_state_leak_debug_check () do {} while (0) +#define btrfs_leak_debug_add_eb (eb) do {} while (0) +#define btrfs_leak_debug_add_state (state) do {} while (0) +#define btrfs_leak_debug_del_eb (eb) do {} while (0) +#define btrfs_leak_debug_del_state (state) do {} while (0) +#define btrfs_extent_state_leak_debug_check () do {} while (0)#define btrfs_debug_check_extent_io_range (c, s, e) do {} while (0)#endif
@@ -343,7 +362,7 @@ static struct extent_state *alloc_extent_state(gfp_t mask) state->state =0 ; state->failrec =NULL ;RB_CLEAR_NODE (&state->rb_node); -btrfs_leak_debug_add (&leak_lock, &state->leak_list, &states); +btrfs_leak_debug_add_state (state);refcount_set (&state->refs,1 );init_waitqueue_head (&state->wq);trace_alloc_extent_state (state, mask, _RET_IP_);
@@ -356,7 +375,7 @@ void free_extent_state(struct extent_state *state)return ;if (refcount_dec_and_test (&state->refs)) {WARN_ON (extent_state_in_tree (state)); -btrfs_leak_debug_del (&leak_lock, &state->leak_list); +btrfs_leak_debug_del_state (state);trace_free_extent_state (state, _RET_IP_);kmem_cache_free (extent_state_cache, state); }
@@ -5830,7 +5849,7 @@ static void btrfs_release_extent_buffer_pages(struct extent_buffer *eb)static inline void btrfs_release_extent_buffer (struct extent_buffer *eb) {btrfs_release_extent_buffer_pages (eb); -btrfs_leak_debug_del (&eb->fs_info->eb_leak_lock, &eb->leak_list); +btrfs_leak_debug_del_eb (eb);__free_extent_buffer (eb); }
@@ -5847,8 +5866,7 @@ __alloc_extent_buffer(struct btrfs_fs_info *fs_info, u64 start, eb->bflags =0 ;init_rwsem (&eb->lock); -btrfs_leak_debug_add (&fs_info->eb_leak_lock, &eb->leak_list, - &fs_info->allocated_ebs); +btrfs_leak_debug_add_eb (eb);INIT_LIST_HEAD (&eb->release_list);spin_lock_init (&eb->refs_lock);
@@ -6294,7 +6312,7 @@ static int release_extent_buffer(struct extent_buffer *eb)spin_unlock (&eb->refs_lock); } -btrfs_leak_debug_del (&eb->fs_info->eb_leak_lock, &eb->leak_list); +btrfs_leak_debug_del_eb (eb);/* Should be safe to release our pages at this point */ btrfs_release_extent_buffer_pages (eb);#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
Signature · 1 line
2.35.1