ARM: OMAP: dts: N950/N9: fix onenand timings
Subsystems (18)
Sasha Levin
maintainerPATCH 1/81 ARM: OMAP: dts: N950/N9: fix onenand timings
From: Aaro Koskinen <[email protected]>
[ Upstream commit 8443e4843e1c2594bf5664e1d993a1be71d1befb ]
Commit a758f50f10cf ("mtd: onenand: omap2: Configure driver from DT") started using DT specified timings for GPMC, and as a result the OneNAND stopped working on N950/N9 as we had wrong values in the DT. Fix by updating the values to bootloader timings that have been tested to be working on both Nokia N950 and N9.
--- arch/arm/boot/dts/omap3-n950-n9.dtsi | 42 ++++++++++++++++++---------- 1 file changed, 28 insertions(+), 14 deletions(-)
arch/arm/boot/dts/omap3-n950-n9.dtsi +28 -14
@@ -370,6 +370,19 @@ compatible = "ti,omap2-onenand"; reg = <0 0 0x20000>; /* CS0, offset 0, IO size 128K */ + /* + * These timings are based on CONFIG_OMAP_GPMC_DEBUG=y reported + * bootloader set values when booted with v4.19 using both N950 + * and N9 devices (OneNAND Manufacturer: Samsung): + * + * gpmc cs0 before gpmc_cs_program_settings: + * cs0 GPMC_CS_CONFIG1: 0xfd001202 + * cs0 GPMC_CS_CONFIG2: 0x00181800 + * cs0 GPMC_CS_CONFIG3: 0x00030300 + * cs0 GPMC_CS_CONFIG4: 0x18001804 + * cs0 GPMC_CS_CONFIG5: 0x03171d1d + * cs0 GPMC_CS_CONFIG6: 0x97080000 + */ gpmc,sync-read; gpmc,sync-write; gpmc,burst-length = <16>;
@@ -379,26 +392,27 @@ gpmc,device-width = <2>; gpmc,mux-add-data = <2>; gpmc,cs-on-ns = <0>; - gpmc,cs-rd-off-ns = <87>; - gpmc,cs-wr-off-ns = <87>; + gpmc,cs-rd-off-ns = <122>; + gpmc,cs-wr-off-ns = <122>; gpmc,adv-on-ns = <0>; - gpmc,adv-rd-off-ns = <10>; - gpmc,adv-wr-off-ns = <10>; - gpmc,oe-on-ns = <15>; - gpmc,oe-off-ns = <87>; + gpmc,adv-rd-off-ns = <15>; + gpmc,adv-wr-off-ns = <15>; + gpmc,oe-on-ns = <20>; + gpmc,oe-off-ns = <122>; gpmc,we-on-ns = <0>; - gpmc,we-off-ns = <87>; - gpmc,rd-cycle-ns = <112>; - gpmc,wr-cycle-ns = <112>; - gpmc,access-ns = <81>; + gpmc,we-off-ns = <122>; + gpmc,rd-cycle-ns = <148>; + gpmc,wr-cycle-ns = <148>; + gpmc,access-ns = <117>; gpmc,page-burst-access-ns = <15>; gpmc,bus-turnaround-ns = <0>; gpmc,cycle2cycle-delay-ns = <0>; gpmc,wait-monitoring-ns = <0>; - gpmc,clk-activation-ns = <5>; - gpmc,wr-data-mux-bus-ns = <30>; - gpmc,wr-access-ns = <81>; - gpmc,sync-clk-ps = <15000>; + gpmc,clk-activation-ns = <10>; + gpmc,wr-data-mux-bus-ns = <40>; + gpmc,wr-access-ns = <117>; + + gpmc,sync-clk-ps = <15000>; /* TBC; Where this value came? */ /* * MTD partition table corresponding to Nokia's MeeGo 1.2
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 2/81 ARM: dts: omap4-droid4: Fix typo in cpcap IRQ flags
From: Tony Lindgren <[email protected]>
[ Upstream commit ef4a55b9197a8f844ea0663138e902dcce3e2f36 ]
We're now getting the following error:
genirq: Setting trigger mode 1 for irq 230 failed (regmap_irq_set_type+0x0/0x15c)
cpcap-usb-phy cpcap-usb-phy.0: could not get irq dp: -524
--- arch/arm/boot/dts/motorola-cpcap-mapphone.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/motorola-cpcap-mapphone.dtsi +1 -1
@@ -105,7 +105,7 @@ interrupts-extended = < &cpcap 15 0 &cpcap 14 0 &cpcap 28 0 &cpcap 19 0 &cpcap 18 0 &cpcap 17 0 &cpcap 16 0 &cpcap 49 0 - &cpcap 48 1 + &cpcap 48 0 >; interrupt-names = "id_ground", "id_float", "se0conn", "vbusvld",
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 3/81 ARM: dts: sun8i: h3: Add ethernet0 alias to Beelink X2
In reply to Sasha LevinFrom: Jernej Skrabec <[email protected]>
[ Upstream commit cc4bddade114b696ab27c1a77cfc7040151306da ]
Because "ethernet0" alias is missing, U-Boot doesn't generate board specific MAC address. Effect of this is random MAC address every boot and thus new IP address is assigned to the board.
Fix this by adding alias.
--- arch/arm/boot/dts/sun8i-h3-beelink-x2.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/sun8i-h3-beelink-x2.dts +1 -1
@@ -53,7 +53,7 @@ aliases { serial0 = &uart0; - /* ethernet0 is the H3 emac, defined in sun8i-h3.dtsi */ + ethernet0 = &emac; ethernet1 = &sdiowifi; };
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 4/81 arm: dts: meson: Fix IRQ trigger type for macirq
In reply to Sasha LevinFrom: Carlo Caione <[email protected]>
[ Upstream commit e35e26b26e955c53e61c154ba26b9bb15da6b858 ]
A long running stress test on a custom board shipping an AXG SoCs and a Realtek RTL8211F PHY revealed that after a few hours the connection speed would drop drastically, from ~1000Mbps to ~3Mbps. At the same time the 'macirq' (eth0) IRQ would stop being triggered at all and as consequence the GMAC IRQs never ACKed.
After a painful investigation the problem seemed to be due to a wrong defined IRQ type for the GMAC IRQ that should be LEVEL_HIGH instead of EDGE_RISING.
The change in the macirq IRQ type also solved another long standing issue affecting this SoC/PHY where EEE was causing the network connection to die after stressing it with iperf3 (even though much sooner). It's now possible to remove the 'eee-broken-1000t' quirk as well.
--- arch/arm/boot/dts/meson.dtsi | 2 +- arch/arm/boot/dts/meson8b-odroidc1.dts | 1 - 2 files changed, 1 insertion(+), 2 deletions(-)
arch/arm/boot/dts/meson.dtsi +1 -1
@@ -263,7 +263,7 @@ compatible = "amlogic,meson6-dwmac", "snps,dwmac"; reg = <0xc9410000 0x10000 0xc1108108 0x4>; - interrupts = <GIC_SPI 8 IRQ_TYPE_EDGE_RISING>; + interrupts = <GIC_SPI 8 IRQ_TYPE_LEVEL_HIGH>; interrupt-names = "macirq"; status = "disabled"; };
arch/arm/boot/dts/meson8b-odroidc1.dts +0 -1
@@ -221,7 +221,6 @@ /* Realtek RTL8211F (0x001cc916) */ eth_phy: ethernet-phy@0 { reg = <0>; - eee-broken-1000t; interrupt-parent = <&gpio_intc>; /* GPIOH_3 */ interrupts = <17 IRQ_TYPE_LEVEL_LOW>;
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 5/81 ARM: dts: meson8b: odroidc1: mark the SD card detection GPIO active-low
In reply to Sasha LevinFrom: Martin Blumenstingl <[email protected]>
[ Upstream commit 3fb348e030319f20ebbde082a449d4bf8a96f2fd ]
After commit 89a5e15bcba87d ("gpio/mmc/of: Respect polarity in the device tree") SD cards are not detected anymore.
The CD GPIO is "active low" on Odroid-C1. The MMC dt-bindings specify:
"[...] using the "cd-inverted" property means, that the CD line is active high, i.e. it is high, when a card is inserted".
Fix the description of the SD card by marking it as GPIO_ACTIVE_LOW and drop the "cd-inverted" property. This makes the definition consistent with the existing dt-bindings and fixes the check whether an SD card is inserted.
--- arch/arm/boot/dts/meson8b-odroidc1.dts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm/boot/dts/meson8b-odroidc1.dts +1 -2
@@ -272,8 +272,7 @@ cap-sd-highspeed; disable-wp; - cd-gpios = <&gpio CARD_6 GPIO_ACTIVE_HIGH>; - cd-inverted; + cd-gpios = <&gpio CARD_6 GPIO_ACTIVE_LOW>; vmmc-supply = <&tflash_vdd>; vqmmc-supply = <&tf_io>;
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 6/81 ARM: dts: meson8b: ec100: mark the SD card detection GPIO active-low
In reply to Sasha LevinFrom: Martin Blumenstingl <[email protected]>
[ Upstream commit c8bfe65fb1fb7a43d766df1dfa379406112cba61 ]
After commit 89a5e15bcba87d ("gpio/mmc/of: Respect polarity in the device tree") SD cards are not detected anymore.
The CD GPIO is "active low" on the EC-100. The MMC dt-bindings specify:
"[...] using the "cd-inverted" property means, that the CD line is active high, i.e. it is high, when a card is inserted".
Fix the description of the SD card by marking it as GPIO_ACTIVE_LOW and drop the "cd-inverted" property. This makes the definition consistent with the existing dt-bindings and fixes the check whether an SD card is inserted.
--- arch/arm/boot/dts/meson8b-ec100.dts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm/boot/dts/meson8b-ec100.dts +1 -2
@@ -205,8 +205,7 @@ cap-sd-highspeed; disable-wp; - cd-gpios = <&gpio CARD_6 GPIO_ACTIVE_HIGH>; - cd-inverted; + cd-gpios = <&gpio CARD_6 GPIO_ACTIVE_LOW>; vmmc-supply = <&vcc_3v3>; };
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 7/81 ARM: dts: meson8m2: mxiii-plus: mark the SD card detection GPIO active-low
In reply to Sasha LevinFrom: Martin Blumenstingl <[email protected]>
[ Upstream commit 8615f5596335db0978cea593dcd0070dc5f8b116 ]
After commit 89a5e15bcba87d ("gpio/mmc/of: Respect polarity in the device tree") SD cards are not detected anymore.
The CD GPIO is "active low" on the MXIII-Plus. The MMC dt-bindings
specify: "[...] using the "cd-inverted" property means, that the CD line is active high, i.e. it is high, when a card is inserted".
Fix the description of the SD card by marking it as GPIO_ACTIVE_LOW and drop the "cd-inverted" property. This makes the definition consistent with the existing dt-bindings and fixes the check whether an SD card is inserted.
--- arch/arm/boot/dts/meson8m2-mxiii-plus.dts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm/boot/dts/meson8m2-mxiii-plus.dts +1 -2
@@ -206,8 +206,7 @@ cap-sd-highspeed; disable-wp; - cd-gpios = <&gpio CARD_6 GPIO_ACTIVE_HIGH>; - cd-inverted; + cd-gpios = <&gpio CARD_6 GPIO_ACTIVE_LOW>; vmmc-supply = <&vcc_3v3>; };
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 8/81 signal: Make siginmask safe when passed a signal of 0
In reply to Sasha LevinFrom: "Eric W. Biederman" <[email protected]>
[ Upstream commit ee17e5d6201c66492a0e8053190fca2ed2b8457d ]
Eric Biggers reported:
Quoted 43 lines
The following commit, which went into v4.20, introduced undefined behavior when
sys_rt_sigqueueinfo()is called with sig=0:commit
4ce5f9c9e7546915c559ffae594e6d73f918db00Author: Eric W. Biederman <[email protected]> Date: Tue Sep 25 12:59:31 2018 +0200signal: Use a smaller struct siginfo in the kernel
In
sig_specific_sicodes(), used fromknown_siginfo_layout(), the expression '1ULL << ((sig)-1)' is undefined as it evaluates to 1ULL << 4294967295.Reproducer:
#include <
signal.h>
#include <sys/syscall.h>
#include <unistd.h>int main(void)
{ siginfo_t si = { .si_code = 1 }; syscall(__NR_rt_sigqueueinfo, 0, 0, &si); }UBSAN report for v5.0-rc1:
UBSAN: Undefined behaviour in kernel/signal.c:2946:7 shift exponent 4294967295 is too large for 64-bit type 'long unsigned int' CPU: 2 PID: 346 Comm: syz_signal Not tainted 5.0.0-rc1 #25 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x70/0xa5 lib/dump_stack.c:113 ubsan_epilogue+0xd/0x40 lib/ubsan.c:159 __ubsan_handle_shift_out_of_bounds+0x12c/0x170 lib/ubsan.c:425 known_siginfo_layout+0xae/0xe0 kernel/signal.c:2946 post_copy_siginfo_from_user kernel/signal.c:3009 [inline] __copy_siginfo_from_user+0x35/0x60 kernel/signal.c:3035 __do_sys_rt_sigqueueinfo kernel/signal.c:3553 [inline] __se_sys_rt_sigqueueinfo kernel/signal.c:3549 [inline] __x64_sys_rt_sigqueueinfo+0x31/0x70 kernel/signal.c:3549 do_syscall_64+0x4c/0x1b0 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x49/0xbe
Quoted 8 lines
RIP: 0033:0x433639 Code: c4 18 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 7b 27 00 00 c3 66 2e 0f 1f 84 00 00 00 00 RSP: 002b:00007fffcb289fc8 EFLAGS: 00000246 ORIG_RAX: 0000000000000081 RAX: ffffffffffffffda RBX: 00000000004002e0 RCX: 0000000000433639 RDX: 00007fffcb289fd0 RSI: 0000000000000000 RDI: 0000000000000000 RBP: 00000000006b2018 R08: 000000000000004d R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000401560 R13: 00000000004015f0 R14: 0000000000000000 R15: 0000000000000000
I have looked at the other callers of siginmask and they all appear to in locations where sig can not be zero.
I have looked at the code generation of adding an extra test against zero and gcc was able with a simple decrement instruction to combine the two tests together. So the at most adding this test cost a single cpu cycle. In practice that decrement instruction was already present as part of the mask comparison, so the only change was when the instruction was executed.
So given that it is cheap, and obviously correct to update siginmask to verify the signal is not zero. Fix this issue there to avoid any future problems.
--- include/linux/signal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/signal.h +1 -1
@@ -388,7 +388,7 @@ extern bool unhandled_signal(struct task_struct *tsk, int sig);#endif #define siginmask (sig, mask) \ - ((sig) < SIGRTMIN && (rt_sigmask(sig) & (mask))) + ((sig) > 0 && (sig) < SIGRTMIN && (rt_sigmask(sig) & (mask)))#define SIG_KERNEL_ONLY_MASK (\ rt_sigmask(SIGKILL) | rt_sigmask(SIGSTOP))
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 9/81 ARM: dts: imx6sx: correct backward compatible of gpt
In reply to Sasha LevinFrom: Anson Huang <[email protected]>
[ Upstream commit ba0f4560526ba19300c07ed5a3c1df7592815dc6 ]
i.MX6SX has same GPT type as i.MX6DL, in GPT driver, it uses below TIMER_OF_DECLARE, so the backward compatible should be "fsl,imx6dl-gpt", correct it.
TIMER_OF_DECLARE(imx6sx_timer, "fsl,imx6sx-gpt", imx6dl_timer_init_dt);
--- arch/arm/boot/dts/imx6sx.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/imx6sx.dtsi +1 -1
@@ -462,7 +462,7 @@ }; gpt: gpt@2098000 { - compatible = "fsl,imx6sx-gpt", "fsl,imx31-gpt"; + compatible = "fsl,imx6sx-gpt", "fsl,imx6dl-gpt"; reg = <0x02098000 0x4000>; interrupts = <GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH>; clocks = <&clks IMX6SX_CLK_GPT_BUS>,
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 10/81 arm64: dts: renesas: r8a7796: Enable DMA for SCIF2
In reply to Sasha LevinFrom: Geert Uytterhoeven <[email protected]>
[ Upstream commit 97f26702bc95b5c3a72671d5c6675e4d6ee0a2f4 ]
SCIF2 on R-Car M3-W can be used with both DMAC1 and DMAC2.
--- arch/arm64/boot/dts/renesas/r8a7796.dtsi | 3 +++ 1 file changed, 3 insertions(+)
arch/arm64/boot/dts/renesas/r8a7796.dtsi +3 -0
@@ -1160,6 +1160,9 @@ <&cpg CPG_CORE R8A7796_CLK_S3D1>, <&scif_clk>; clock-names = "fck", "brg_int", "scif_clk"; + dmas = <&dmac1 0x13>, <&dmac1 0x12>, + <&dmac2 0x13>, <&dmac2 0x12>; + dma-names = "tx", "rx", "tx", "rx"; power-domains = <&sysc R8A7796_PD_ALWAYS_ON>; resets = <&cpg 310>; status = "disabled";
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 11/81 arm64: dts: renesas: r8a77965: Enable DMA for SCIF2
In reply to Sasha LevinFrom: Geert Uytterhoeven <[email protected]>
[ Upstream commit 05c8478abd485507c25aa565afab604af8d8fe46 ]
SCIF2 on R-Car M3-N can be used with both DMAC1 and DMAC2.
--- arch/arm64/boot/dts/renesas/r8a77965.dtsi | 3 +++ 1 file changed, 3 insertions(+)
arch/arm64/boot/dts/renesas/r8a77965.dtsi +3 -0
@@ -1028,6 +1028,9 @@ <&cpg CPG_CORE R8A77965_CLK_S3D1>, <&scif_clk>; clock-names = "fck", "brg_int", "scif_clk"; + dmas = <&dmac1 0x13>, <&dmac1 0x12>, + <&dmac2 0x13>, <&dmac2 0x12>; + dma-names = "tx", "rx", "tx", "rx"; power-domains = <&sysc R8A77965_PD_ALWAYS_ON>; resets = <&cpg 310>; status = "disabled";
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 12/81 soc: fsl: qbman: avoid race in clearing QMan interrupt
In reply to Sasha LevinFrom: Madalin Bucur <[email protected]>
[ Upstream commit 89857a8a5c89a406b967ab2be7bd2ccdbe75e73d ]
By clearing all interrupt sources, not only those that already occurred, the existing code may acknowledge by mistake interrupts that occurred after the code checks for them.
--- drivers/soc/fsl/qbman/qman.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/soc/fsl/qbman/qman.c +5 -4
@@ -1124,18 +1124,19 @@ static void qm_mr_process_task(struct work_struct *work);static irqreturn_t portal_isr (int irq,void *ptr) {struct qman_portal *p = ptr; - -u32 clear =QM_DQAVAIL_MASK | p->irq_sources;u32 is =qm_in (&p->p,QM_REG_ISR ) & p->irq_sources; +u32 clear =0 ;if (unlikely (!is))return IRQ_NONE ;/* DQRR-handling if it's interrupt-driven */ -if (is &QM_PIRQ_DQRI ) +if (is &QM_PIRQ_DQRI ) {__poll_portal_fast (p,QMAN_POLL_LIMIT ); + clear =QM_DQAVAIL_MASK |QM_PIRQ_DQRI ; + }/* Handling of anything else that's interrupt-driven */ - clear |=__poll_portal_slow (p, is); + clear |=__poll_portal_slow (p, is) &QM_PIRQ_SLOW ;qm_out (&p->p,QM_REG_ISR , clear);return IRQ_HANDLED ; }
Signature · 7 lines
2.19.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 13/81 pinctrl: mcp23s08: spi: Fix regmap allocation for mcp23s18
In reply to Sasha LevinFrom: Jason Kridner <[email protected]>
[ Upstream commit f165988b77ef849eb0c1aebd94fe778024f88314 ]
Fixes issue created by 9b3e4207661e67f04c72af15e29f74cd944f5964.
It wasn't possible for one_regmap_config to be non-NULL at the point it was tested for mcp23s18 devices.
Applied the same pattern of allocating one_regmap_config using devm_kmemdump() and then initializing the local regmap structure from that.
--- drivers/pinctrl/pinctrl-mcp23s08.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/pinctrl/pinctrl-mcp23s08.c +6 -1
@@ -832,8 +832,13 @@ static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev,break ;case MCP_TYPE_S18 : + one_regmap_config = +devm_kmemdup (dev, &mcp23x17_regmap, +sizeof (struct regmap_config ),GFP_KERNEL ); +if (!one_regmap_config) +return -ENOMEM ; mcp->regmap =devm_regmap_init (dev, &mcp23sxx_spi_regmap, mcp, - &mcp23x17_regmap); + one_regmap_config); mcp->reg_shift =1 ; mcp->chip.ngpio =16 ; mcp->chip.label ="mcp23s18" ;
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 14/81 wlcore: sdio: Fixup power on/off sequence
In reply to Sasha LevinFrom: Ulf Hansson <[email protected]>
[ Upstream commit 13e62626c578d9889ebbda7c521be5adff9bef8e ]
During "wlan-up", we are programming the FW into the WiFi-chip. However, re-programming the FW doesn't work, unless a power cycle of the WiFi-chip is made in-between the programmings.
To conform to this requirement and to fix the regression in a simple way, let's start by allowing that the SDIO card (WiFi-chip) may stay powered on (runtime resumed) when wl12xx_sdio_power_off() returns. The intent with the current code is to treat this scenario as an error, but unfortunate this doesn't work as expected, so let's fix this.
The other part is to guarantee that a power cycle of the SDIO card has been completed when wl12xx_sdio_power_on() returns, as to allow the FW programming to succeed. However, relying solely on runtime PM to deal with this isn't sufficient. For example, userspace may prevent runtime suspend via sysfs for the device that represents the SDIO card, leading to that the mmc core also keeps it powered on. For this reason, let's instead do a brute force power cycle in wl12xx_sdio_power_on().
--- drivers/net/wireless/ti/wlcore/sdio.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/net/wireless/ti/wlcore/sdio.c +7 -8
@@ -164,6 +164,12 @@ static int wl12xx_sdio_power_on(struct wl12xx_sdio_glue *glue) }sdio_claim_host (func); +/* +* To guarantee that the SDIO card is power cycled, as required to make +* the FW programming to succeed, let's do a brute force HW reset. +*/ +mmc_hw_reset (card->host); +sdio_enable_func (func);sdio_release_host (func);
@@ -174,20 +180,13 @@ static int wl12xx_sdio_power_off(struct wl12xx_sdio_glue *glue) {struct sdio_func *func =dev_to_sdio_func (glue->dev);struct mmc_card *card = func->card; -int error;sdio_claim_host (func);sdio_disable_func (func);sdio_release_host (func);/* Let runtime PM know the card is powered off */ - error =pm_runtime_put (&card->dev); -if (error <0 && error != -EBUSY ) { -dev_err (&card->dev,"%s failed: %i\n" , __func__, error); - -return error; - } - +pm_runtime_put (&card->dev);return 0 ; }
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 15/81 bpftool: Fix prog dump by tag
In reply to Sasha LevinFrom: Jiri Olsa <[email protected]>
[ Upstream commit 752bcf80f5549c9901b2e8bc77b2138de55b1026 ]
Lance reported an issue with bpftool not being able to dump program if there are more programs loaded and you want to dump any but the first program, like:
# bpftool prog 28: kprobe name trace_req_start tag 1dfc28ba8b3dd597 gpl loaded_at 2019-01-18T17:02:40+1100 uid 0 xlated 112B jited 109B memlock 4096B map_ids 13 29: kprobe name trace_req_compl tag 5b6a5ecc6030a683 gpl loaded_at 2019-01-18T17:02:40+1100 uid 0 xlated 928B jited 575B memlock 4096B map_ids 13,14 # bpftool prog dum jited tag 1dfc28ba8b3dd597 0: push %rbp 1: mov %rsp,%rbp ...
# bpftool prog dum jited tag 5b6a5ecc6030a683
Error: can't get prog info (29): Bad address
The problem is in the prog_fd_by_tag function not cleaning the struct bpf_prog_info before another request, so the previous program length is still in there and kernel assumes it needs to dump the program, which fails because there's no user pointer set.
Moving the struct bpf_prog_info declaration into the loop, so it gets cleaned before each query.
--- tools/bpf/bpftool/prog.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
tools/bpf/bpftool/prog.c +3 -2
@@ -130,13 +130,14 @@ static void print_boot_time(__u64 nsecs, char *buf, unsigned int size)static int prog_fd_by_tag (unsigned char *tag) { -struct bpf_prog_info info = {}; -__u32 len =sizeof (info);unsigned int id =0 ;int err;int fd;while (true) { +struct bpf_prog_info info = {}; +__u32 len =sizeof (info); + err =bpf_prog_get_next_id (id, &id);if (err) {p_err ("%s" ,strerror (errno));
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 16/81 bpftool: fix percpu maps updating
In reply to Sasha LevinFrom: Paolo Abeni <[email protected]>
[ Upstream commit b0ca5ecb8e2279d706261f525f1bd0ba9e3fe800 ]
When updating a percpu map, bpftool currently copies the provided value only into the first per CPU copy of the specified value, all others instances are left zeroed.
This change explicitly copies the user-provided bytes to all the per CPU instances, keeping the sub-command syntax unchanged.
v2 -> v3:
- drop unused argument, as per Quentin's suggestion
v1 -> v2:
- rename the helper as per Quentin's suggestion
--- tools/bpf/bpftool/map.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
tools/bpf/bpftool/map.c +16 -0
@@ -439,6 +439,20 @@ static char **parse_bytes(char **argv, const char *name, unsigned char *val,return argv + i; } +/* on per cpu maps we must copy the provided value on all value instances */ +static void fill_per_cpu_value (struct bpf_map_info *info,void *value) +{ +unsigned int i, n, step; + +if (!map_is_per_cpu (info->type)) +return ; + + n =get_possible_cpus (); + step =round_up (info->value_size,8 ); +for (i =1 ; i < n; i++) +memcpy (value + i * step, value, info->value_size); +} +static int parse_elem (char **argv,struct bpf_map_info *info,void *key,void *value,__u32 key_size,__u32 value_size,__u32 *flags,__u32 **value_fd)
@@ -518,6 +532,8 @@ static int parse_elem(char **argv, struct bpf_map_info *info, argv =parse_bytes (argv,"value" , value, value_size);if (!argv)return -1 ; + +fill_per_cpu_value (info, value); } return parse_elem(argv, info, key, NULL, key_size, value_size,
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 17/81 bpf: sock recvbuff must be limited by rmem_max in bpf_setsockopt()
In reply to Sasha LevinFrom: Yafang Shao <[email protected]>
[ Upstream commit c9e4576743eeda8d24dedc164d65b78877f9a98c ]
When sock recvbuff is set by bpf_setsockopt(), the value must by limited by rmem_max. It is the same with sendbuff.
--- net/core/filter.c | 2 ++ 1 file changed, 2 insertions(+)
net/core/filter.c +2 -0
@@ -3927,10 +3927,12 @@ BPF_CALL_5(bpf_setsockopt, struct bpf_sock_ops_kern *, bpf_sock,/* Only some socketops are supported */ switch (optname) {case SO_RCVBUF : + val =min_t (u32, val, sysctl_rmem_max); sk->sk_userlocks |=SOCK_RCVBUF_LOCK ; sk->sk_rcvbuf =max_t (int, val *2 ,SOCK_MIN_RCVBUF );break ;case SO_SNDBUF : + val =min_t (u32, val, sysctl_wmem_max); sk->sk_userlocks |=SOCK_SNDBUF_LOCK ; sk->sk_sndbuf =max_t (int, val *2 ,SOCK_MIN_SNDBUF );break ;
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 18/81 ARM: pxa: ssp: unneeded to free devm_ allocated data
In reply to Sasha LevinFrom: Peng Hao <[email protected]>
[ Upstream commit ba16adeb346387eb2d1ada69003588be96f098fa ]
devm_ allocated data will be automatically freed. The free of devm_ allocated data is invalid.
--- arch/arm/plat-pxa/ssp.c | 3 --- 1 file changed, 3 deletions(-)
arch/arm/plat-pxa/ssp.c +0 -3
@@ -190,8 +190,6 @@ static int pxa_ssp_remove(struct platform_device *pdev)if (ssp ==NULL )return -ENODEV ; -iounmap (ssp->mmio_base); - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );release_mem_region (res->start,resource_size (res));
@@ -201,7 +199,6 @@ static int pxa_ssp_remove(struct platform_device *pdev)list_del (&ssp->node);mutex_unlock (&ssp_lock); -kfree (ssp);return 0 ; }
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 19/81 ARM: dts: omap3-gta04: Fix graph_port warning
In reply to Sasha LevinFrom: Tony Lindgren <[email protected]>
[ Upstream commit 5b90df44fd9b415d8c5d11b92746212a63d3c47f ]
We're currently getting a warning with make dtbs:
arch/arm/boot/dts/omap3-gta04.dtsi:720.7-727.4: Warning (graph_port):
/ocp@68000000/dss@48050000/encoder@48050c0 0/port: graph node unit address error, expected "0"
--- arch/arm/boot/dts/omap3-gta04.dtsi | 4 ---- 1 file changed, 4 deletions(-)
arch/arm/boot/dts/omap3-gta04.dtsi +0 -4
@@ -714,11 +714,7 @@ vdda-supply = <&vdac>; - #address-cells = <1>; - #size-cells = <0>; - port { - reg = <0>; venc_out: endpoint { remote-endpoint = <&opa_in>; ti,channels = <1>;
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 20/81 ARM: dts: n900: fix mmc1 card detect gpio polarity
In reply to Sasha LevinFrom: Arthur Demchenkov <[email protected]>
[ Upstream commit ac9c908eecde3ed252cb1d67fc79b3c1346f76bc ]
Wrong polarity of card detect GPIO pin leads to the system not booting from external mmc, if the back cover of N900 is closed. When the cover is open the system boots fine.
This wasn't noticed before, because of a bug, which was fixed by commit e63201f19 (mmc: omap_hsmmc: Delete platform data GPIO CD and WP).
Kernels up to 4.19 ignored the card detect GPIO from DT.
--- arch/arm/boot/dts/omap3-n900.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/omap3-n900.dts +1 -1
@@ -814,7 +814,7 @@ /* For debugging, it is often good idea to remove this GPIO. It means you can remove back cover (to reboot by removing battery) and still use the MMC card. */ - cd-gpios = <&gpio6 0 GPIO_ACTIVE_HIGH>; /* 160 */ + cd-gpios = <&gpio6 0 GPIO_ACTIVE_LOW>; /* 160 */ }; /* most boards use vaux3, only some old versions use vmmc2 instead */
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 21/81 ARM: dts: am335x-shc.dts: fix wrong cd pin level
In reply to Sasha LevinFrom: Heiko Schocher <[email protected]>
[ Upstream commit 063c20e12f8bbbc10cabc2413606b140085beb62 ]
cd pin on mmc1 is GPIO_ACTIVE_LOW not GPIO_ACTIVE_HIGH
--- arch/arm/boot/dts/am335x-shc.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/am335x-shc.dts +1 -1
@@ -215,7 +215,7 @@ pinctrl-names = "default"; pinctrl-0 = <&mmc1_pins>; bus-width = <0x4>; - cd-gpios = <&gpio0 6 GPIO_ACTIVE_HIGH>; + cd-gpios = <&gpio0 6 GPIO_ACTIVE_LOW>; cd-inverted; max-frequency = <26000000>; vmmc-supply = <&vmmcsd_fixed>;
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 22/81 arm64: dts: add msm8996 compatible to gicv3
In reply to Sasha LevinFrom: Srinivas Kandagatla <[email protected]>
[ Upstream commit 2a81efb0de0e33f2d2c83154af0bd3ce389b3269 ]
Add compatible to gicv3 node to enable quirk required to restrict writing to GICR_WAKER register which is restricted on msm8996 SoC in Hypervisor.
With this quirk MSM8996 can at least boot out of mainline, which can help community to work with boards based on MSM8996.
Without this patch Qualcomm DB820c board reboots on mainline.
--- arch/arm64/boot/dts/qcom/msm8996.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/qcom/msm8996.dtsi +1 -1
@@ -397,7 +397,7 @@ }; intc: interrupt-controller@9bc0000 { - compatible = "arm,gic-v3"; + compatible = "qcom,msm8996-gic-v3", "arm,gic-v3"; #interrupt-cells = <3>; interrupt-controller; #redistributor-regions = <1>;
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 23/81 batman-adv: release station info tidstats
In reply to Sasha LevinFrom: Felix Fietkau <[email protected]>
[ Upstream commit 7d652669b61d702c6e62a39579d17f6881670ab6 ]
With the addition of TXQ stats in the per-tid statistics the struct station_info grew significantly. This resulted in stack size warnings due to the structure itself being above the limit for the warnings.
To work around this, the TID array was allocated dynamically. Also a function to free this content was introduced with commit 7ea3e110f2f8 ("cfg80211: release station info tidstats where needed") but the necessary changes were not provided for batman-adv's B.A.T.M.A.N. V implementation.
--- net/batman-adv/bat_v_elp.c | 3 +++ 1 file changed, 3 insertions(+)
net/batman-adv/bat_v_elp.c +3 -0
@@ -104,6 +104,9 @@ static u32 batadv_v_elp_get_throughput(struct batadv_hardif_neigh_node *neigh) ret =cfg80211_get_station (real_netdev, neigh->addr, &sinfo); +/* free the TID stats immediately */ +cfg80211_sinfo_release_content (&sinfo); +dev_put (real_netdev);if (ret == -ENOENT ) {/* Node is not associated anymore! It would be
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 24/81 MIPS: DTS: jz4740: Correct interrupt number of DMA core
In reply to Sasha LevinFrom: Paul Cercueil <[email protected]>
[ Upstream commit 70999ec1c9d3f783a7232973cfc26971e5732758 ]
The interrupt number set in the devicetree node of the DMA driver was wrong.
--- arch/mips/boot/dts/ingenic/jz4740.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/boot/dts/ingenic/jz4740.dtsi +1 -1
@@ -161,7 +161,7 @@ #dma-cells = <2>; interrupt-parent = <&intc>; - interrupts = <29>; + interrupts = <20>; clocks = <&cgu JZ4740_CLK_DMA>;
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 25/81 DTS: CI20: Fix bugs in ci20's device tree.
In reply to Sasha LevinFrom: Zhou Yanjie <[email protected]>
[ Upstream commit 1ca1c87f91d9dc50d6a38e2177b2032996e7901c ]
According to the Schematic, the hardware of ci20 leads to uart3, but not to uart2. Uart2 is miswritten in the original code.
--- arch/mips/boot/dts/ingenic/ci20.dts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/mips/boot/dts/ingenic/ci20.dts +4 -4
@@ -76,7 +76,7 @@ status = "okay"; pinctrl-names = "default"; - pinctrl-0 = <&pins_uart2>; + pinctrl-0 = <&pins_uart3>; }; &uart4 {
@@ -196,9 +196,9 @@ bias-disable; }; - pins_uart2: uart2 { - function = "uart2"; - groups = "uart2-data", "uart2-hwflow"; + pins_uart3: uart3 { + function = "uart3"; + groups = "uart3-data", "uart3-hwflow"; bias-disable; };
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 26/81 usb: phy: fix link errors
In reply to Sasha LevinFrom: Anders Roxell <[email protected]>
[ Upstream commit f2105d42597f4d10e431b195d69e96dccaf9b012 ]
Fix link errors when CONFIG_FSL_USB2_OTG is enabled and USB_OTG_FSM is set to module then the following link error occurs.
aarch64-linux-gnu-ld: drivers/usb/phy/phy-fsl-usb.o: in function `fsl_otg_ioctl':drivers/usb/phy/phy-fsl-usb.c:1083: undefined reference to `otg_statemachine'
aarch64-linux-gnu-ld: drivers/usb/phy/phy-fsl-usb.c:1083:(.text+0x574): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `otg_statemachine'
aarch64-linux-gnu-ld: drivers/usb/phy/phy-fsl-usb.o: in function `fsl_otg_start_srp':drivers/usb/phy/phy-fsl-usb.c:674: undefined reference to `otg_statemachine'
aarch64-linux-gnu-ld: drivers/usb/phy/phy-fsl-usb.c:674:(.text+0x61c): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `otg_statemachine'
aarch64-linux-gnu-ld: drivers/usb/phy/phy-fsl-usb.o: in function `fsl_otg_set_host':drivers/usb/phy/phy-fsl-usb.c:593: undefined reference to `otg_statemachine'
aarch64-linux-gnu-ld: drivers/usb/phy/phy-fsl-usb.c:593:(.text+0x7a4): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `otg_statemachine'
aarch64-linux-gnu-ld: drivers/usb/phy/phy-fsl-usb.o: in function `fsl_otg_start_hnp':drivers/usb/phy/phy-fsl-usb.c:695: undefined reference to `otg_statemachine'
aarch64-linux-gnu-ld: drivers/usb/phy/phy-fsl-usb.c:695:(.text+0x858): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `otg_statemachine'
aarch64-linux-gnu-ld: drivers/usb/phy/phy-fsl-usb.o: in function `a_wait_enum':drivers/usb/phy/phy-fsl-usb.c:274: undefined reference to `otg_statemachine'
aarch64-linux-gnu-ld: drivers/usb/phy/phy-fsl-usb.c:274:(.text+0x16f0): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `otg_statemachine'
aarch64-linux-gnu-ld: drivers/usb/phy/phy-fsl-usb.o:drivers/usb/phy/phy-fsl-usb.c:619: more undefined references to `otg_statemachine' follow
aarch64-linux-gnu-ld: drivers/usb/phy/phy-fsl-usb.o: in function `fsl_otg_set_peripheral':
drivers/usb/phy/phy-fsl-usb.c:619:(.text+0x1fa0): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `otg_statemachine' make[1]: *** [Makefile:1020: vmlinux] Error 1
make[1]: Target 'Image' not remade because of errors.
make: *** [Makefile:152: sub-make] Error 2
make: Target 'Image' not remade because of errors.
Rework so that FSL_USB2_OTG depends on that the USB_OTG_FSM is builtin.
--- drivers/usb/phy/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/phy/Kconfig +1 -1
@@ -21,7 +21,7 @@ config AB8500_USB config FSL_USB2_OTG bool "Freescale USB OTG Transceiver Driver" - depends on USB_EHCI_FSL && USB_FSL_USB2 && USB_OTG_FSM && PM + depends on USB_EHCI_FSL && USB_FSL_USB2 && USB_OTG_FSM=y && PM depends on USB_GADGET || !USB_GADGET # if USB_GADGET=m, this can't be 'y' select USB_PHY help
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 27/81 usb: dwc3: exynos: Fix error handling of clk_prepare_enable
In reply to Sasha LevinFrom: Alexey Khoroshilov <[email protected]>
[ Upstream commit 512e6fb589bc18f9321457632e89b95017447db9 ]
If clk_prepare_enable() fails in dwc3_exynos_probe() or in dwc3_exynos_resume(), exynos->clks[0] is left undisabled because of usage preincrement in while condition.
Found by Linux Driver Verification project (linuxtesting.org).
--- drivers/usb/dwc3/dwc3-exynos.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/dwc3/dwc3-exynos.c +2 -2
@@ -78,7 +78,7 @@ static int dwc3_exynos_probe(struct platform_device *pdev)for (i =0 ; i < exynos->num_clks; i++) { ret =clk_prepare_enable (exynos->clks[i]);if (ret) { -while (--i >0 ) +while (i-- >0 )clk_disable_unprepare (exynos->clks[i]);return ret; }
@@ -223,7 +223,7 @@ static int dwc3_exynos_resume(struct device *dev)for (i =0 ; i < exynos->num_clks; i++) { ret =clk_prepare_enable (exynos->clks[i]);if (ret) { -while (--i >0 ) +while (i-- >0 )clk_disable_unprepare (exynos->clks[i]);return ret; }
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 28/81 irqchip/gic-v4: Fix occasional VLPI drop
In reply to Sasha LevinFrom: Heyi Guo <[email protected]>
[ Upstream commit 6479450f72c1391c03f08affe0d0110f41ae7ca0 ]
1. In current implementation, every VLPI will temporarily be mapped to the first CPU in system (normally CPU0) and then moved to the real scheduled CPU later.
2. So there is a time window and a VLPI may be sent to CPU0 instead of the real scheduled vCPU, in a multi-CPU virtual machine.
3. However, CPU0 may have not been scheduled as a virtual CPU after system boots up, so the value of its GICR_VPROPBASER is unknown at that moment.
4. If the INTID of VLPI is larger than 2^(GICR_VPROPBASER.IDbits+1), while IDbits is also in unknown state, GIC will behave as if the VLPI is out of range and simply drop it, which results in interrupt missing in Guest.
As no code will clear GICR_VPROPBASER at runtime, we can safely initialize the IDbits field at boot time for each CPU to get rid of this issue.
We also clear Valid bit of GICR_VPENDBASER in case any ancient programming gets left in and causes memory corrupting. A new function its_clear_vpend_valid() is added to reuse the code in its_vpe_deschedule().
--- drivers/irqchip/irq-gic-v3-its.c | 66 ++++++++++++++++++++++++-------- 1 file changed, 49 insertions(+), 17 deletions(-)
drivers/irqchip/irq-gic-v3-its.c +49 -17
@@ -2065,6 +2065,29 @@ static int __init allocate_lpi_tables(void)return 0 ; } +static u64 its_clear_vpend_valid (void __iomem *vlpi_base) +{ +u32 count =1000000 ;/* 1s! */ +bool clean; +u64 val; + + val =gits_read_vpendbaser (vlpi_base +GICR_VPENDBASER ); + val &= ~GICR_VPENDBASER_Valid; +gits_write_vpendbaser (val, vlpi_base +GICR_VPENDBASER ); + +do { + val =gits_read_vpendbaser (vlpi_base +GICR_VPENDBASER ); + clean = !(val & GICR_VPENDBASER_Dirty); +if (!clean) { + count--; +cpu_relax (); +udelay (1 ); + } + }while (!clean && count); + +return val; +} +static void its_cpu_init_lpis (void ) {void __iomem *rbase =gic_data_rdist_rd_base ();
@@ -2150,6 +2173,30 @@ static void its_cpu_init_lpis(void) val |=GICR_CTLR_ENABLE_LPIS ;writel_relaxed (val, rbase +GICR_CTLR ); +if (gic_rdists->has_vlpis) { +void __iomem *vlpi_base =gic_data_rdist_vlpi_base (); + +/* +* It's possible for CPU to receive VLPIs before it is +* sheduled as a vPE, especially for the first CPU, and the +* VLPI with INTID larger than 2^(IDbits+1) will be considered +* as out of range and dropped by GIC. +* So we initialize IDbits to known value to avoid VLPI drop. +*/ + val = (LPI_NRBITS -1 ) &GICR_VPROPBASER_IDBITS_MASK ; +pr_debug ("GICv4: CPU%d: Init IDbits to 0x%llx for GICR_VPROPBASER\n" , +smp_processor_id (), val); +gits_write_vpropbaser (val, vlpi_base +GICR_VPROPBASER ); + +/* +* Also clear Valid bit of GICR_VPENDBASER, in case some +* ancient programming gets left in and has possibility of +* corrupting memory. +*/ + val =its_clear_vpend_valid (vlpi_base); +WARN_ON (val & GICR_VPENDBASER_Dirty); + } +/* Make sure the GIC has seen the above */ dsb (sy); out:
@@ -2776,26 +2823,11 @@ static void its_vpe_schedule(struct its_vpe *vpe)static void its_vpe_deschedule (struct its_vpe *vpe) {void __iomem *vlpi_base =gic_data_rdist_vlpi_base (); -u32 count =1000000 ;/* 1s! */ -bool clean;u64 val; -/* We're being scheduled out */ - val =gits_read_vpendbaser (vlpi_base +GICR_VPENDBASER ); - val &= ~GICR_VPENDBASER_Valid; -gits_write_vpendbaser (val, vlpi_base +GICR_VPENDBASER ); - -do { - val =gits_read_vpendbaser (vlpi_base +GICR_VPENDBASER ); - clean = !(val & GICR_VPENDBASER_Dirty); -if (!clean) { - count--; -cpu_relax (); -udelay (1 ); - } - }while (!clean && count); + val =its_clear_vpend_valid (vlpi_base); -if (unlikely (!clean && !count)) { +if (unlikely (val & GICR_VPENDBASER_Dirty)) {pr_err_ratelimited ("ITS virtual pending table not cleaning\n" ); vpe->idai = false; vpe->pending_last = true;
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 29/81 sk_msg: Always cancel strp work before freeing the psock
In reply to Sasha LevinFrom: Jakub Sitnicki <[email protected]>
[ Upstream commit 1d79895aef18fa05789995d86d523c9b2ee58a02 ]
Despite having stopped the parser, we still need to deinitialize it by calling strp_done so that it cancels its work. Otherwise the worker thread can run after we have freed the parser, and attempt to access its workqueue resulting in a use-after-free:
==================================================================
BUG: KASAN: use-after-free in pwq_activate_delayed_work+0x1b/0x1d0
Read of size 8 at addr ffff888069975240 by task kworker/u2:2/93
CPU: 0 PID: 93 Comm: kworker/u2:2 Not tainted 5.0.0-rc2-00335-g28f9d1a3d4fe-dirty #14
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-2.fc27 04/01/2014
Workqueue: (null) (kstrp)
Call Trace:
print_address_description+0x6e/0x2b0
? pwq_activate_delayed_work+0x1b/0x1d0
kasan_report+0xfd/0x177
? pwq_activate_delayed_work+0x1b/0x1d0
? pwq_activate_delayed_work+0x1b/0x1d0
pwq_activate_delayed_work+0x1b/0x1d0
? process_one_work+0x4aa/0x660
pwq_dec_nr_in_flight+0x9b/0x100
worker_thread+0x82/0x680
? process_one_work+0x660/0x660
kthread+0x1b9/0x1e0
? __kthread_create_on_node+0x250/0x250
ret_from_fork+0x1f/0x30
Allocated by task 111:
sk_psock_init+0x3c/0x1b0
sock_map_link.isra.2+0x103/0x4b0
sock_map_update_common+0x94/0x270
sock_map_update_elem+0x145/0x160
__se_sys_bpf+0x152e/0x1e10
do_syscall_64+0xb2/0x3e0
entry_SYSCALL_64_after_hwframe+0x44/0xa9
Freed by task 112:
kfree+0x7f/0x140
process_one_work+0x40b/0x660
worker_thread+0x82/0x680
kthread+0x1b9/0x1e0
ret_from_fork+0x1f/0x30
The buggy address belongs to the object at ffff888069975180
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 192 bytes inside of
512-byte region [ffff888069975180, ffff888069975380)
The buggy address belongs to the page:
page:ffffea0001a65d00 count:1 mapcount:0 mapping:ffff88806d401280 index:0x0 compound_mapcount: 0
flags: 0x4000000000010200(slab|head)
raw: 4000000000010200 dead000000000100 dead000000000200 ffff88806d401280
raw: 0000000000000000 00000000800c000c 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff888069975100: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff888069975180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888069975200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888069975280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888069975300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================--- net/core/skmsg.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/core/skmsg.c +1 -2
@@ -545,8 +545,7 @@ static void sk_psock_destroy_deferred(struct work_struct *gc) struct sk_psock *psock = container_of(gc, struct sk_psock, gc);/* No sk_callback_lock since already detached. */ -if (psock->parser.enabled) -strp_done (&psock->parser.strp); +strp_done (&psock->parser.strp);cancel_work_sync (&psock->work);
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 30/81 irqchip/gic-v3-its: Gracefully fail on LPI exhaustion
In reply to Sasha LevinFrom: Marc Zyngier <[email protected]>
[ Upstream commit 45725e0fc3e7fe52fedb94f59806ec50e9618682 ]
In the unlikely event that we cannot find any available LPI in the system, we should gracefully return an error instead of carrying on with no LPI allocated at all.
--- drivers/irqchip/irq-gic-v3-its.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/irqchip/irq-gic-v3-its.c +3 -0
@@ -1586,6 +1586,9 @@ static unsigned long *its_lpi_alloc(int nr_irqs, u32 *base, int *nr_ids) nr_irqs /=2 ; }while (nr_irqs >0 ); +if (!nr_irqs) + err = -ENOSPC ; +if (err) goto out;
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 31/81 irqchip/mmp: Only touch the PJ4 IRQ & FIQ bits on enable/disable
In reply to Sasha LevinFrom: Lubomir Rintel <[email protected]>
[ Upstream commit 2380a22b60ce6f995eac806e69c66e397b59d045 ]
Resetting bit 4 disables the interrupt delivery to the "secure processor" core. This breaks the keyboard on a OLPC XO 1.75 laptop, where the firmware running on the "secure processor" bit-bangs the PS/2 protocol over the GPIO lines.
It is not clear what the rest of the bits are and Marvell was unhelpful when asked for documentation. Aside from the SP bit, there are probably priority bits.
Leaving the unknown bits as the firmware set them up seems to be a wiser course of action compared to just turning them off.
--- drivers/irqchip/irq-mmp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/irqchip/irq-mmp.c +5 -1
@@ -34,6 +34,9 @@#define SEL_INT_PENDING (1 << 6)#define SEL_INT_NUM_MASK 0x3f +#define MMP2_ICU_INT_ROUTE_PJ4_IRQ (1 << 5) +#define MMP2_ICU_INT_ROUTE_PJ4_FIQ (1 << 6) +struct icu_chip_data {int nr_irqs;unsigned int virq_base;
@@ -190,7 +193,8 @@ static const struct mmp_intc_conf mmp_conf = {static const struct mmp_intc_conf mmp2_conf = { .conf_enable =0x20 , .conf_disable =0x0 , - .conf_mask =0x7f , + .conf_mask =MMP2_ICU_INT_ROUTE_PJ4_IRQ | +MMP2_ICU_INT_ROUTE_PJ4_FIQ , }; static void __exception_irq_entry mmp_handle_irq(struct pt_regs *regs)
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 32/81 drm/amdgpu: Add missing power attribute to APU check
In reply to Sasha LevinFrom: Alex Deucher <[email protected]>
[ Upstream commit dc14eb12f6bb3e779c5461429c1889a339c67aab ]
Add missing power_average to visible check for power attributes for APUs. Was missed before.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +2 -1
@@ -1671,7 +1671,8 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj, effective_mode &= ~S_IWUSR ;if ((adev->flags &AMD_IS_APU ) && - (attr == &sensor_dev_attr_power1_cap_max.dev_attr.attr || + (attr == &sensor_dev_attr_power1_average.dev_attr.attr || + attr == &sensor_dev_attr_power1_cap_max.dev_attr.attr || attr == &sensor_dev_attr_power1_cap_min.dev_attr.attr|| attr == &sensor_dev_attr_power1_cap.dev_attr.attr))return 0 ;
Signature · 6 lines
2.19.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Sasha Levin
maintainerPATCH 33/81 drm/radeon: check if device is root before getting pci speed caps
In reply to Sasha LevinFrom: Alex Deucher <[email protected]>
[ Upstream commit afeff4c16edaa6275b903f82b0561406259aa3a3 ]
Check if the device is root rather before attempting to see what speeds the pcie port supports. Fixes a crash with pci passthrough in a VM.
--- drivers/gpu/drm/radeon/ci_dpm.c | 5 +++-- drivers/gpu/drm/radeon/si_dpm.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/radeon/ci_dpm.c +3 -2
@@ -5676,7 +5676,7 @@ int ci_dpm_init(struct radeon_device *rdev)u16 data_offset, size;u8 frev, crev;struct ci_power_info *pi; -enum pci_bus_speed speed_cap; +enum pci_bus_speed speed_cap =PCI_SPEED_UNKNOWN ;struct pci_dev *root = rdev->pdev->bus->self;int ret;
@@ -5685,7 +5685,8 @@ int ci_dpm_init(struct radeon_device *rdev)return -ENOMEM ; rdev->pm.dpm.priv = pi; - speed_cap =pcie_get_speed_cap (root); +if (!pci_is_root_bus (rdev->pdev->bus)) + speed_cap =pcie_get_speed_cap (root);if (speed_cap ==PCI_SPEED_UNKNOWN ) { pi->sys_pcie_mask =0 ; }else {
drivers/gpu/drm/radeon/si_dpm.c +3 -2
@@ -6899,7 +6899,7 @@ int si_dpm_init(struct radeon_device *rdev)struct ni_power_info *ni_pi;struct si_power_info *si_pi;struct atom_clock_dividers dividers; -enum pci_bus_speed speed_cap; +enum pci_bus_speed speed_cap =PCI_SPEED_UNKNOWN ;struct pci_dev *root = rdev->pdev->bus->self;int ret;
@@ -6911,7 +6911,8 @@ int si_dpm_init(struct radeon_device *rdev) eg_pi = &ni_pi->eg; pi = &eg_pi->rv7xx; - speed_cap =pcie_get_speed_cap (root); +if (!pci_is_root_bus (rdev->pdev->bus)) + speed_cap =pcie_get_speed_cap (root);if (speed_cap ==PCI_SPEED_UNKNOWN ) { si_pi->sys_pcie_mask =0 ; }else {
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 34/81 debugfs: return error values, not NULL
In reply to Sasha LevinFrom: Greg Kroah-Hartman <[email protected]>
[ Upstream commit ff9fb72bc07705c00795ca48631f7fffe24d2c6b ]
When an error happens, debugfs should return an error pointer value, not NULL. This will prevent the totally theoretical error where a debugfs call fails due to lack of memory, returning NULL, and that dentry value is then passed to another debugfs call, which would end up succeeding, creating a file at the root of the debugfs tree, but would then be impossible to remove (because you can not remove the directory NULL).
So, to make everyone happy, always return errors, this makes the users of debugfs much simpler (they do not have to ever check the return value), and everyone can rest easy.
--- fs/debugfs/inode.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-)
fs/debugfs/inode.c +22 -17
@@ -254,8 +254,8 @@ MODULE_ALIAS_FS("debugfs");* @parent: a pointer to the parent dentry of the file. * * This function will return a pointer to a dentry if it succeeds. If the file -* doesn't exist or an error occurs, %NULL will be returned. The returned -* dentry must be passed to dput() when it is no longer needed. +* doesn't exist or an error occurs, %ERR_PTR(-ERROR) will be returned. The +* returned dentry must be passed to dput() when it is no longer needed. * * If debugfs is not enabled in the kernel, the value -%ENODEV will be * returned.
@@ -265,17 +265,17 @@ struct dentry *debugfs_lookup(const char *name, struct dentry *parent)struct dentry *dentry;if (IS_ERR (parent)) -return NULL ; +return parent;if (!parent) parent = debugfs_mount->mnt_root; dentry =lookup_one_len_unlocked (name, parent,strlen (name));if (IS_ERR (dentry)) -return NULL ; +return dentry;if (!d_really_is_positive (dentry)) {dput (dentry); -return NULL ; +return ERR_PTR (-EINVAL ); }return dentry; }
@@ -324,7 +324,7 @@ static struct dentry *failed_creating(struct dentry *dentry)inode_unlock (d_inode (dentry->d_parent));dput (dentry);simple_release_fs (&debugfs_mount, &debugfs_mount_count); -return NULL ; +return ERR_PTR (-ENOMEM ); }static struct dentry *end_creating (struct dentry *dentry)
@@ -347,7 +347,7 @@ static struct dentry *__debugfs_create_file(const char *name, umode_t mode, dentry =start_creating (name, parent);if (IS_ERR (dentry)) -return NULL ; +return dentry; inode =debugfs_get_inode (dentry->d_sb);if (unlikely (!inode))
@@ -386,7 +386,8 @@ static struct dentry *__debugfs_create_file(const char *name, umode_t mode,* This function will return a pointer to a dentry if it succeeds. This * pointer must be passed to the debugfs_remove() function when the file is * to be removed (no automatic cleanup happens if your module is unloaded, -* you are responsible here.) If an error occurs, %NULL will be returned. +* you are responsible here.) If an error occurs, %ERR_PTR(-ERROR) will be +* returned. * * If debugfs is not enabled in the kernel, the value -%ENODEV will be * returned.
@@ -464,7 +465,8 @@ EXPORT_SYMBOL_GPL(debugfs_create_file_unsafe);* This function will return a pointer to a dentry if it succeeds. This * pointer must be passed to the debugfs_remove() function when the file is * to be removed (no automatic cleanup happens if your module is unloaded, -* you are responsible here.) If an error occurs, %NULL will be returned. +* you are responsible here.) If an error occurs, %ERR_PTR(-ERROR) will be +* returned. * * If debugfs is not enabled in the kernel, the value -%ENODEV will be * returned.
@@ -495,7 +497,8 @@ EXPORT_SYMBOL_GPL(debugfs_create_file_size);* This function will return a pointer to a dentry if it succeeds. This * pointer must be passed to the debugfs_remove() function when the file is * to be removed (no automatic cleanup happens if your module is unloaded, -* you are responsible here.) If an error occurs, %NULL will be returned. +* you are responsible here.) If an error occurs, %ERR_PTR(-ERROR) will be +* returned. * * If debugfs is not enabled in the kernel, the value -%ENODEV will be * returned.
@@ -506,7 +509,7 @@ struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)struct inode *inode;if (IS_ERR (dentry)) -return NULL ; +return dentry; inode =debugfs_get_inode (dentry->d_sb);if (unlikely (!inode))
@@ -545,7 +548,7 @@ struct dentry *debugfs_create_automount(const char *name,struct inode *inode;if (IS_ERR (dentry)) -return NULL ; +return dentry; inode =debugfs_get_inode (dentry->d_sb);if (unlikely (!inode))
@@ -581,8 +584,8 @@ EXPORT_SYMBOL(debugfs_create_automount);* This function will return a pointer to a dentry if it succeeds. This * pointer must be passed to the debugfs_remove() function when the symbolic * link is to be removed (no automatic cleanup happens if your module is -* unloaded, you are responsible here.) If an error occurs, %NULL will be -* returned. +* unloaded, you are responsible here.) If an error occurs, %ERR_PTR(-ERROR) +* will be returned. * * If debugfs is not enabled in the kernel, the value -%ENODEV will be * returned.
@@ -594,12 +597,12 @@ struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent,struct inode *inode;char *link =kstrdup (target,GFP_KERNEL );if (!link) -return NULL ; +return ERR_PTR (-ENOMEM ); dentry =start_creating (name, parent);if (IS_ERR (dentry)) {kfree (link); -return NULL ; +return dentry; } inode =debugfs_get_inode (dentry->d_sb);
@@ -827,7 +830,9 @@ struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,if (dentry && !IS_ERR (dentry))dput (dentry);unlock_rename (new_dir, old_dir); -return NULL ; +if (IS_ERR (dentry)) +return dentry; +return ERR_PTR (-EINVAL ); }EXPORT_SYMBOL_GPL (debugfs_rename);
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerRe: [PATCH AUTOSEL 4.20 34/81] debugfs: return error values, not NULL
Quoted 25 lines · Sasha Levin
From: Greg Kroah-Hartman <[email protected]>
[ Upstream commit
ff9fb72bc07705c00795ca48631f7fffe24d2c6b]When an error happens, debugfs should return an error pointer value, not NULL. This will prevent the totally theoretical error where a debugfs call fails due to lack of memory, returning NULL, and that dentry value is then passed to another debugfs call, which would end up succeeding, creating a file at the root of the debugfs tree, but would then be impossible to remove (because you can not remove the directory NULL).
So, to make everyone happy, always return errors, this makes the users of debugfs much simpler (they do not have to ever check the return value), and everyone can rest easy.
Reported-by Gary R Hook <[email protected]>Reported-by Heiko Carstens <[email protected]>Reported-by Masami Hiramatsu <[email protected]>Reported-by Michal Hocko <[email protected]>Reported-by Sebastian Andrzej Siewior <[email protected]>Reported-by Ulf Hansson <[email protected]>Reviewed-by Masami Hiramatsu <[email protected]>Reviewed-by Sebastian Andrzej Siewior <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Sasha Levin <[email protected]>
Quoted 3 lines
--- fs/debugfs/inode.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-)
As much as I would love to backport this patch, no, please do not, I did not mark it for stable on purpose. It can cause regressions with code that is not expecting this behavior (I have a fix that needs to go into 5.0 for this very reason.)
Please drop it from all queues.
thanks,
greg k-h
Sasha Levin
maintainerRe: [PATCH AUTOSEL 4.20 34/81] debugfs: return error values, not NULL
Quoted 30 lines · Greg Kroah-Hartman
Quoted 25 lines · Sasha Levin
From: Greg Kroah-Hartman <[email protected]>
[ Upstream commit
ff9fb72bc07705c00795ca48631f7fffe24d2c6b]When an error happens, debugfs should return an error pointer value, not NULL. This will prevent the totally theoretical error where a debugfs call fails due to lack of memory, returning NULL, and that dentry value is then passed to another debugfs call, which would end up succeeding, creating a file at the root of the debugfs tree, but would then be impossible to remove (because you can not remove the directory NULL).
So, to make everyone happy, always return errors, this makes the users of debugfs much simpler (they do not have to ever check the return value), and everyone can rest easy.
Reported-by Gary R Hook <[email protected]>Reported-by Heiko Carstens <[email protected]>Reported-by Masami Hiramatsu <[email protected]>Reported-by Michal Hocko <[email protected]>Reported-by Sebastian Andrzej Siewior <[email protected]>Reported-by Ulf Hansson <[email protected]>Reviewed-by Masami Hiramatsu <[email protected]>Reviewed-by Sebastian Andrzej Siewior <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Sasha Levin <[email protected]>Quoted 3 lines
--- fs/debugfs/inode.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-)
Quoted 6 lines
As much as I would love to backport this patch, no, please do not, I did not mark it for stable on purpose. It can cause regressions with code that is not expecting this behavior (I have a fix that needs to go into 5.0 for this very reason.)
Please drop it from all queues.
I've dropped this and the rest of the debugfs related patches you've pointed out, thank you.
--
Thanks,
Sasha
Sasha Levin
maintainerPATCH 35/81 debugfs: debugfs_lookup() should return NULL if not found
In reply to Sasha LevinFrom: Greg Kroah-Hartman <[email protected]>
[ Upstream commit 37ea7b630ae5cdea4e8ff381d9d23abfef5939e6 ]
Lots of callers of debugfs_lookup() were just checking NULL to see if the file/directory was found or not. By changing this in ff9fb72bc077 ("debugfs: return error values, not NULL") we caused some subsystems to easily crash.
--- fs/debugfs/inode.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
fs/debugfs/inode.c +5 -5
@@ -254,8 +254,8 @@ MODULE_ALIAS_FS("debugfs");* @parent: a pointer to the parent dentry of the file. * * This function will return a pointer to a dentry if it succeeds. If the file -* doesn't exist or an error occurs, %ERR_PTR(-ERROR) will be returned. The -* returned dentry must be passed to dput() when it is no longer needed. +* doesn't exist or an error occurs, %NULL will be returned. The returned +* dentry must be passed to dput() when it is no longer needed. * * If debugfs is not enabled in the kernel, the value -%ENODEV will be * returned.
@@ -265,17 +265,17 @@ struct dentry *debugfs_lookup(const char *name, struct dentry *parent)struct dentry *dentry;if (IS_ERR (parent)) -return parent; +return NULL ;if (!parent) parent = debugfs_mount->mnt_root; dentry =lookup_one_len_unlocked (name, parent,strlen (name));if (IS_ERR (dentry)) -return dentry; +return NULL ;if (!d_really_is_positive (dentry)) {dput (dentry); -return ERR_PTR (-EINVAL ); +return NULL ; }return dentry; }
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerRe: [PATCH AUTOSEL 4.20 35/81] debugfs: debugfs_lookup() should return NULL if not found
Quoted 45 lines · Sasha Levin
From: Greg Kroah-Hartman <[email protected]>
[ Upstream commit
37ea7b630ae5cdea4e8ff381d9d23abfef5939e6]Lots of callers of
debugfs_lookup()were just checking NULL to see if the file/directory was found or not. By changing this inff9fb72bc077("debugfs: return error values, not NULL") we caused some subsystems to easily crash.Fixes ff9fb72bc077 ("debugfs: return error values, not NULL")Reported-by [email protected]Reported-by Tetsuo Handa <[email protected]>Cc Omar Sandoval <[email protected]>Cc Jens Axboe <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- fs/debugfs/inode.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)fs/debugfs/inode.c +3
-3@@ -254,8 +254,8 @@ MODULE_ALIAS_FS("debugfs");* @parent: a pointer to the parent dentry of the file. * * This function will return a pointer to a dentry if it succeeds. If the file -* doesn't exist or an error occurs, %ERR_PTR(-ERROR) will be returned. The -* returned dentry must be passed to dput() when it is no longer needed. +* doesn't exist or an error occurs, %NULL will be returned. The returned +* dentry must be passed to dput() when it is no longer needed. * * If debugfs is not enabled in the kernel, the value -%ENODEV will be * returned. @@ -265,17 +265,17 @@ struct dentry *debugfs_lookup(const char *name, struct dentry *parent)struct dentry *dentry;if (IS_ERR (parent)) -return parent; +return NULL ;if (!parent) parent = debugfs_mount->mnt_root;
fs/debugfs/inode.c struct dentry *debugfs_lookup(const char *name, struct dentry *parent) · line 280
Quoted 10 lines
fs/debugfs/inode.c +2
-2dentry =lookup_one_len_unlocked (name, parent,strlen (name));if (IS_ERR (dentry)) -return dentry; +return NULL ;if (!d_really_is_positive (dentry)) {dput (dentry); -return ERR_PTR (-EINVAL ); +return NULL ; }return dentry;
As the "Fixes:" commit should not be backported, no need for this one either. Please drop from all queues.
thanks,
greg k-h
Sasha Levin
maintainerPATCH 36/81 binder: fix CONFIG_ANDROID_BINDER_DEVICES
In reply to Sasha LevinFrom: Christian Brauner <[email protected]>
[ Upstream commit 793c8232937610ae00bc174b87d7fc324346eaea ]
Several users have tried to only rely on binderfs to provide binder devices and set CONFIG_ANDROID_BINDER_DEVICES="" empty. This is a great use-case of binderfs and one that was always intended to work. However, this is currently not possible since setting CONFIG_ANDROID_BINDER_DEVICES="" emtpy will simply panic the kernel:
kobject: (00000000028c2f79): attempted to be registered with empty name!
WARNING: CPU: 7 PID: 1703 at lib/kobject.c:228 kobject_add_internal+0x288/0x2b0 Modules linked in: binder_linux(+) bridge stp llc ipmi_ssif gpio_ich dcdbas coretemp kvm_intel kvm irqbypass serio_raw input_leds lpc_ich i5100_edac mac_hid ipmi_si ipmi_devintf ipmi_msghandler sch_fq_codel ib_i CPU: 7 PID: 1703 Comm: modprobe Not tainted 5.0.0-rc2-brauner-binderfs #263 Hardware name: Dell DCS XS24-SC2 /XS24-SC2 , BIOS S59_3C20 04/07/2011 RIP: 0010:kobject_add_internal+0x288/0x2b0 Code: 12 95 48 c7 c7 78 63 3b 95 e8 77 35 71 ff e9 91 fe ff ff 0f 0b eb a7 0f 0b eb 9a 48 89 de 48 c7 c7 00 63 3b 95 e8 f8 95 6a ff <0f> 0b 41 bc ea ff ff ff e9 6d fe ff ff 41 bc fe ff ff ff e9 62 fe RSP: 0018:ffff973f84237a30 EFLAGS: 00010282 RAX: 0000000000000000 RBX: ffff8b53e2472010 RCX: 0000000000000006 RDX: 0000000000000007 RSI: 0000000000000086 RDI: ffff8b53edbd63a0 RBP: ffff973f84237a60 R08: 0000000000000342 R09: 0000000000000004 R10: ffff973f84237af0 R11: 0000000000000001 R12: 0000000000000000 R13: ffff8b53e9f1a1e0 R14: 00000000e9f1a1e0 R15: 0000000000a00037 FS: 00007fbac36f7540(0000) GS:ffff8b53edbc0000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fbac364cfa7 CR3: 00000004a6d48000 CR4: 00000000000406e0 Call Trace: kobject_add+0x71/0xd0 ? _cond_resched+0x19/0x40 ? mutex_lock+0x12/0x40 device_add+0x12e/0x6b0 device_create_groups_vargs+0xe4/0xf0 device_create_with_groups+0x3f/0x60 ? _cond_resched+0x19/0x40 misc_register+0x140/0x180 binder_init+0x1ed/0x2d4 [binder_linux] ? trace_event_define_fields_binder_transaction_fd_send+0x8e/0x8e [binder_linux] do_one_initcall+0x4a/0x1c9 ? _cond_resched+0x19/0x40 ? kmem_cache_alloc_trace+0x151/0x1c0 do_init_module+0x5f/0x216 load_module+0x223d/0x2b20 __do_sys_finit_module+0xfc/0x120 ? __do_sys_finit_module+0xfc/0x120 __x64_sys_finit_module+0x1a/0x20 do_syscall_64+0x5a/0x120 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x7fbac3202839 Code: 00 f3 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 1f f6 2c 00 f7 d8 64 89 01 48 RSP: 002b:00007ffd1494a908 EFLAGS: 00000246 ORIG_RAX: 0000000000000139 RAX: ffffffffffffffda RBX: 000055b629ebec60 RCX: 00007fbac3202839 RDX: 0000000000000000 RSI: 000055b629c20d2e RDI: 0000000000000003 RBP: 000055b629c20d2e R08: 0000000000000000 R09: 000055b629ec2310 R10: 0000000000000003 R11: 0000000000000246 R12: 0000000000000000 R13: 000055b629ebed70 R14: 0000000000040000 R15: 000055b629ebec60
So check for the empty string since strsep() will otherwise return the emtpy string which will cause kobject_add_internal() to panic when trying to add a kobject with an emtpy name.
--- drivers/android/binder.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-)
drivers/android/binder.c +16 -14
@@ -5877,21 +5877,23 @@ static int __init binder_init(void) &binder_transaction_log_fops); } -/* -* Copy the module_parameter string, because we don't want to -* tokenize it in-place. -*/ - device_names =kstrdup (binder_devices_param,GFP_KERNEL ); -if (!device_names) { - ret = -ENOMEM ; - goto err_alloc_device_names_failed; - } +if (strcmp (binder_devices_param,"" ) !=0 ) { +/* +* Copy the module_parameter string, because we don't want to +* tokenize it in-place. +*/ + device_names =kstrdup (binder_devices_param,GFP_KERNEL ); +if (!device_names) { + ret = -ENOMEM ; + goto err_alloc_device_names_failed; + } - device_tmp = device_names; -while ((device_name =strsep (&device_tmp,"," ))) { - ret =init_binder_device (device_name); -if (ret) - goto err_init_binder_device_failed; + device_tmp = device_names; +while ((device_name =strsep (&device_tmp,"," ))) { + ret =init_binder_device (device_name); +if (ret) + goto err_init_binder_device_failed; + } }return ret;
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerRe: [PATCH AUTOSEL 4.20 36/81] binder: fix CONFIG_ANDROID_BINDER_DEVICES
Quoted 9 lines · Sasha Levin
From: Christian Brauner <[email protected]>
[ Upstream commit
793c8232937610ae00bc174b87d7fc324346eaea]Several users have tried to only rely on binderfs to provide binder devices and set
CONFIG_ANDROID_BINDER_DEVICES="" empty. This is a great use-case of binderfs and one that was always intended to work. However, this is currently not possible since settingCONFIG_ANDROID_BINDER_DEVICES="" emtpy will simply panic the kernel:
There is no binderfs on 4.20, so this patch is not needed on anything older than 5.0.
Please drop it from your queues.
thanks,
greg k-h
Sasha Levin
maintainerRe: [PATCH AUTOSEL 4.20 36/81] binder: fix CONFIG_ANDROID_BINDER_DEVICES
Quoted 11 lines · Greg Kroah-Hartman
Quoted 9 lines · Sasha Levin
From: Christian Brauner <[email protected]>
[ Upstream commit
793c8232937610ae00bc174b87d7fc324346eaea]Several users have tried to only rely on binderfs to provide binder devices and set
CONFIG_ANDROID_BINDER_DEVICES="" empty. This is a great use-case of binderfs and one that was always intended to work. However, this is currently not possible since settingCONFIG_ANDROID_BINDER_DEVICES="" emtpy will simply panic the kernel:
Quoted 4 lines
There is no binderfs on 4.20, so this patch is not needed on anything older than 5.0.
Please drop it from your queues.
Heh, I knew binder was there for a while, didn't know binderfs is something new. Now dropped, thanks!
--
Thanks,
Sasha
Sasha Levin
maintainerPATCH 37/81 drm/amdgpu: Transfer fences to dmabuf importer
In reply to Sasha LevinFrom: Chris Wilson <[email protected]>
[ Upstream commit 6e11ea9de9576a644045ffdc2067c09bc2012eda ]
amdgpu only uses shared-fences internally, but dmabuf importers rely on implicit write hazard tracking via the reservation_object.fence_excl. For example, the importer use the write hazard for timing a page flip to only occur after the exporter has finished flushing its write into the surface. As such, on exporting a dmabuf, we must either flush all outstanding fences (for we do not know which are writes and should have been exclusive) or alternatively create a new exclusive fence that is the composite of all the existing shared fences, and so will only be signaled when all earlier fences are signaled (ensuring that we can not be signaled before the completion of any earlier write).
v2: reservation_object is already locked by amdgpu_bo_reserve()
v3: Replace looping with get_fences_rcu and special case the promotion of a single shared fence directly to an exclusive fence, bypassing the fence array.
v4: Drop the fence array ref after assigning to reservation_object
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107341
Testcase: igt/amd_prime/amd-to-i915
References: 8e94a46c1770 ("drm/amdgpu: Attach exclusive fence to prime exported bo's. (v5)")
--- drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c | 59 ++++++++++++++++++++--- 1 file changed, 51 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c +51 -8
@@ -38,6 +38,7 @@#include "amdgpu_gem.h" #include <drm/amdgpu_drm.h> #include <linux/dma-buf.h> +#include <linux/dma-fence-array.h> static const struct dma_buf_ops amdgpu_dmabuf_ops;
@@ -189,6 +190,48 @@ amdgpu_gem_prime_import_sg_table(struct drm_device *dev,return ERR_PTR (ret); } +static int +__reservation_object_make_exclusive (struct reservation_object *obj) +{ +struct dma_fence **fences; +unsigned int count; +int r; + +if (!reservation_object_get_list (obj))/* no shared fences to convert */ +return 0 ; + + r =reservation_object_get_fences_rcu (obj,NULL , &count, &fences); +if (r) +return r; + +if (count ==0 ) { +/* Now that was unexpected. */ + }else if (count ==1 ) { +reservation_object_add_excl_fence (obj, fences[0 ]); +dma_fence_put (fences[0 ]); +kfree (fences); + }else { +struct dma_fence_array *array; + + array =dma_fence_array_create (count, fences, +dma_fence_context_alloc (1 ),0 , + false); +if (!array) + goto err_fences_put; + +reservation_object_add_excl_fence (obj, &array->base); +dma_fence_put (&array->base); + } + +return 0 ; + +err_fences_put: +while (count--) +dma_fence_put (fences[count]); +kfree (fences); +return -ENOMEM ; +} +/** * amdgpu_gem_map_attach - &dma_buf_ops.attach implementation * @dma_buf: Shared DMA buffer
@@ -220,16 +263,16 @@ static int amdgpu_gem_map_attach(struct dma_buf *dma_buf,if (attach->dev->driver != adev->dev->driver) {/* -* Wait for all shared fences to complete before we switch to future -* use of exclusive fence on this prime shared bo. +* We only create shared fences for internal use, but importers +* of the dmabuf rely on exclusive fences for implicitly +* tracking write hazards. As any of the current fences may +* correspond to a write, we need to convert all existing +* fences on the reservation object into a single exclusive +* fence. */ - r =reservation_object_wait_timeout_rcu (bo->tbo.resv, - true, false, -MAX_SCHEDULE_TIMEOUT ); -if (unlikely (r <0 )) { -DRM_DEBUG_PRIME ("Fence wait failed: %li\n" , r); + r =__reservation_object_make_exclusive (bo->tbo.resv); +if (r) goto error_unreserve; - } }/* pin buffer into GTT */
Signature · 6 lines
2.19.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Sasha Levin
maintainerPATCH 38/81 net: stmmac: Fallback to Platform Data clock in Watchdog conversion
In reply to Sasha LevinFrom: Jose Abreu <[email protected]>
[ Upstream commit 4ec5302fa906ec9d86597b236f62315bacdb9622 ]
If we don't have DT then stmmac_clk will not be available. Let's add a new Platform Data field so that we can specify the refclk by this mean.
This way we can still use the coalesce command in PCI based setups.
--- .../net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 14 ++++++++++---- include/linux/stmmac.h | 1 + 2 files changed, 11 insertions(+), 4 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +10 -4
@@ -719,8 +719,11 @@ static u32 stmmac_usec2riwt(u32 usec, struct stmmac_priv *priv) {unsigned long clk =clk_get_rate (priv->plat->stmmac_clk); -if (!clk) -return 0 ; +if (!clk) { + clk = priv->plat->clk_ref_rate; +if (!clk) +return 0 ; + }return (usec * (clk /1000000 )) /256 ; }
@@ -729,8 +732,11 @@ static u32 stmmac_riwt2usec(u32 riwt, struct stmmac_priv *priv) {unsigned long clk =clk_get_rate (priv->plat->stmmac_clk); -if (!clk) -return 0 ; +if (!clk) { + clk = priv->plat->clk_ref_rate; +if (!clk) +return 0 ; + }return (riwt *256 ) / (clk /1000000 ); }
include/linux/stmmac.h +1 -0
@@ -184,6 +184,7 @@ struct plat_stmmacenet_data {struct clk *pclk;struct clk *clk_ptp_ref;unsigned int clk_ptp_rate; +unsigned int clk_ref_rate;struct reset_control *stmmac_rst;struct stmmac_axi *axi;int has_gmac4;
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 39/81 net: stmmac: Send TSO packets always from Queue 0
In reply to Sasha LevinFrom: Jose Abreu <[email protected]>
[ Upstream commit c5acdbee22a1b200dde07effd26fd1f649e9ab8a ]
The number of TSO enabled channels in HW can be different than the number of total channels. There is no way to determined, at runtime, the number of TSO capable channels and its safe to assume that if TSO is enabled then at least channel 0 will be TSO capable.
Lets always send TSO packets from Queue 0.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +10 -1
@@ -3033,8 +3033,17 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)/* Manage oversized TCP frames for GMAC4 device */ if (skb_is_gso (skb) && priv->tso) { -if (skb_shinfo (skb)->gso_type & (SKB_GSO_TCPV4 |SKB_GSO_TCPV6 )) +if (skb_shinfo (skb)->gso_type & (SKB_GSO_TCPV4 |SKB_GSO_TCPV6 )) { +/* +* There is no way to determine the number of TSO +* capable Queues. Let's use always the Queue 0 +* because if TSO is supported then at least this +* one will be capable. +*/ +skb_set_queue_mapping (skb,0 ); +return stmmac_tso_xmit (skb, dev); + } }if (unlikely (stmmac_tx_avail (priv, queue) < nfrags +1 )) {
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 40/81 net: stmmac: Disable EEE mode earlier in XMIT callback
In reply to Sasha LevinFrom: Jose Abreu <[email protected]>
[ Upstream commit e2cd682deb231ba6f80524bb84e57e7138261149 ]
In stmmac xmit callback we use a different flow for TSO packets but TSO xmit callback is not disabling the EEE mode.
Fix this by disabling earlier the EEE mode, i.e. before calling the TSO xmit callback.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +3 -3
@@ -3031,6 +3031,9 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev) tx_q = &priv->tx_queue[queue]; +if (priv->tx_path_in_lpi_mode) +stmmac_disable_eee_mode (priv); +/* Manage oversized TCP frames for GMAC4 device */ if (skb_is_gso (skb) && priv->tso) {if (skb_shinfo (skb)->gso_type & (SKB_GSO_TCPV4 |SKB_GSO_TCPV6 )) {
@@ -3058,9 +3061,6 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)return NETDEV_TX_BUSY ; } -if (priv->tx_path_in_lpi_mode) -stmmac_disable_eee_mode (priv); - entry = tx_q->cur_tx; first_entry = entry;WARN_ON (tx_q->tx_skbuff[first_entry]);
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 41/81 irqchip/gic-v3-its: Fix ITT_entry_size accessor
In reply to Sasha LevinFrom: Zenghui Yu <[email protected]>
[ Upstream commit 56841070ccc87b463ac037d2d1f2beb8e5e35f0c ]
According to ARM IHI 0069C (ID070116), we should use GITS_TYPER's bits [7:4] as ITT_entry_size instead of [8:4]. Although this is pretty annoying, it only results in a potential over-allocation of memory, and nothing bad happens.
--- include/linux/irqchip/arm-gic-v3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/irqchip/arm-gic-v3.h +1 -1
@@ -319,7 +319,7 @@#define GITS_TYPER_PLPIS (1UL << 0)#define GITS_TYPER_VLPIS (1UL << 1)#define GITS_TYPER_ITT_ENTRY_SIZE_SHIFT 4 -#define GITS_TYPER_ITT_ENTRY_SIZE (r) ((((r) >> GITS_TYPER_ITT_ENTRY_SIZE_SHIFT) & 0x1f) + 1) +#define GITS_TYPER_ITT_ENTRY_SIZE (r) ((((r) >> GITS_TYPER_ITT_ENTRY_SIZE_SHIFT) & 0xf) + 1)#define GITS_TYPER_IDBITS_SHIFT 8#define GITS_TYPER_DEVBITS_SHIFT 13#define GITS_TYPER_DEVBITS (r) ((((r) >> GITS_TYPER_DEVBITS_SHIFT) & 0x1f) + 1)
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 42/81 relay: check return of create_buf_file() properly
In reply to Sasha LevinFrom: Greg Kroah-Hartman <[email protected]>
[ Upstream commit 2c1cf00eeacb784781cf1c9896b8af001246d339 ]
If create_buf_file() returns an error, don't try to reference it later as a valid dentry pointer.
This problem was exposed when debugfs started to return errors instead of just NULL for some calls when they do not succeed properly.
Also, the check for WARN_ON(dentry) was just wrong :)
--- kernel/relay.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/relay.c +3 -1
@@ -428,6 +428,8 @@ static struct dentry *relay_create_buf_file(struct rchan *chan, dentry = chan->cb->create_buf_file (tmpname, chan->parent,S_IRUSR , buf, &chan->is_global); +if (IS_ERR (dentry)) + dentry =NULL ;kfree (tmpname);
@@ -461,7 +463,7 @@ static struct rchan_buf *relay_open_buf(struct rchan *chan, unsigned int cpu) dentry = chan->cb->create_buf_file (NULL ,NULL ,S_IRUSR , buf, &chan->is_global); -if (WARN_ON (dentry)) +if (IS_ERR_OR_NULL (dentry)) goto free_buf; }
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerRe: [PATCH AUTOSEL 4.20 42/81] relay: check return of create_buf_file() properly
Quoted 20 lines · Sasha Levin
From: Greg Kroah-Hartman <[email protected]>
[ Upstream commit
2c1cf00eeacb784781cf1c9896b8af001246d339]If
create_buf_file()returns an error, don't try to reference it later as a valid dentry pointer.This problem was exposed when debugfs started to return errors instead of just NULL for some calls when they do not succeed properly.
Also, the check for
WARN_ON(dentry)was just wrong :)Reported-by Kees Cook <[email protected]>Reported-and-tested-by [email protected]Reported-by Tetsuo Handa <[email protected]>Cc Andrew Morton <[email protected]>Cc David Rientjes <[email protected]>Fixes ff9fb72bc077 ("debugfs: return error values, not NULL")Signed-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Sasha Levin <[email protected]>
Quoted 3 lines
--- kernel/relay.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Same here as well, please drop this from all queues.
greg k-h
Sasha Levin
maintainerPATCH 43/81 blk-mq: protect debugfs_create_files() from failures
In reply to Sasha LevinFrom: Greg Kroah-Hartman <[email protected]>
[ Upstream commit 36991ca68db9dd43bac7f3519f080ee3939263ef ]
If debugfs were to return a non-NULL error for a debugfs call, using that pointer later in debugfs_create_files() would crash.
Fix that by properly checking the pointer before referencing it.
--- block/blk-mq-debugfs.c | 3 +++ 1 file changed, 3 insertions(+)
block/blk-mq-debugfs.c +3 -0
@@ -812,6 +812,9 @@ static const struct blk_mq_debugfs_attr blk_mq_debugfs_ctx_attrs[] = {static bool debugfs_create_files (struct dentry *parent,void *data,const struct blk_mq_debugfs_attr *attr) { +if (IS_ERR_OR_NULL (parent)) +return false; +d_inode (parent)->i_private = data;for (; attr->name; attr++) {
Signature · 1 line
2.19.1
Greg Kroah-Hartman
maintainerRe: [PATCH AUTOSEL 4.20 43/81] blk-mq: protect debugfs_create_files() from failures
Quoted 9 lines · Sasha Levin
From: Greg Kroah-Hartman <[email protected]>
[ Upstream commit
36991ca68db9dd43bac7f3519f080ee3939263ef]If debugfs were to return a non-NULL error for a debugfs call, using that pointer later in
debugfs_create_files()would crash.Fix that by properly checking the pointer before referencing it.
Quoted 9 lines
Reported-by Michal Hocko <[email protected]>Reported-and-tested-by [email protected]Reported-by Tetsuo Handa <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- block/blk-mq-debugfs.c | 3 +++ 1 file changed, 3 insertions(+)
As the commit this "fixes" should not be backported, no need for this patch in any stable kernel either. Please drop from all queues.
thanks,
greg k-h
Sasha Levin
maintainerPATCH 44/81 ath10k: correct bus type for WCN3990
In reply to Sasha LevinFrom: Brian Norris <[email protected]>
[ Upstream commit 2c2008a63e482654ab137c84d3c61c03b75e7df6 ]
WCN3990 is SNOC, not PCI. This prevents probing WCN3990.
--- drivers/net/wireless/ath/ath10k/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath10k/core.c +1 -1
@@ -548,7 +548,7 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { { .id = WCN3990_HW_1_0_DEV_VERSION, .dev_id = 0, - .bus = ATH10K_BUS_PCI, + .bus = ATH10K_BUS_SNOC, .name = "wcn3990 hw1.0", .continuous_frag_desc = true, .tx_chain_mask = 0x7,
Signature · 7 lines
2.19.1 _______________________________________________ ath10k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath10k
Sasha Levin
maintainerPATCH 45/81 bpf, selftests: fix handling of sparse CPU allocations
In reply to Sasha LevinFrom: Martynas Pumputis <[email protected]>
[ Upstream commit 1bb54c4071f585ebef56ce8fdfe6026fa2cbcddd ]
Previously, bpf_num_possible_cpus() had a bug when calculating a number of possible CPUs in the case of sparse CPU allocations, as it was considering only the first range or element of /sys/devices/system/cpu/possible.
E.g. in the case of "0,2-3" (CPU 1 is not available), the function returned 1 instead of 3.
This patch fixes the function by making it parse all CPU ranges and elements.
--- tools/testing/selftests/bpf/bpf_util.h | 30 +++++++++++++++++--------- 1 file changed, 20 insertions(+), 10 deletions(-)
tools/testing/selftests/bpf/bpf_util.h +20 -10
@@ -13,7 +13,7 @@ static inline unsigned int bpf_num_possible_cpus(void)unsigned int start, end, possible_cpus =0 ;char buff[128 ];FILE *fp; -int n; +int len, n, i, j =0 ; fp =fopen (fcpu,"r" );if (!fp) {
@@ -21,17 +21,27 @@ static inline unsigned int bpf_num_possible_cpus(void)exit (1 ); } -while (fgets (buff,sizeof (buff), fp)) { - n =sscanf (buff,"%u-%u" , &start, &end); -if (n ==0 ) { -printf ("Failed to retrieve # possible CPUs!\n" ); -exit (1 ); - }else if (n ==1 ) { - end = start; +if (!fgets (buff,sizeof (buff), fp)) { +printf ("Failed to read %s!\n" , fcpu); +exit (1 ); + } + + len =strlen (buff); +for (i =0 ; i <= len; i++) { +if (buff[i] ==',' || buff[i] =='\0' ) { + buff[i] ='\0' ; + n =sscanf (&buff[j],"%u-%u" , &start, &end); +if (n <=0 ) { +printf ("Failed to retrieve # possible CPUs!\n" ); +exit (1 ); + }else if (n ==1 ) { + end = start; + } + possible_cpus += end - start +1 ; + j = i +1 ; } - possible_cpus = start ==0 ? end +1 :0 ; -break ; } +fclose (fp);return possible_cpus;
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 46/81 bpf: run bpf programs with preemption disabled
In reply to Sasha LevinFrom: Alexei Starovoitov <[email protected]>
[ Upstream commit 6cab5e90ab2bd323c9f3811b6c70a4687df51e27 ]
Disabled preemption is necessary for proper access to per-cpu maps from BPF programs.
But the sender side of socket filters didn't have preemption disabled:unix_dgram_sendmsg->sk_filter->sk_filter_trim_cap->bpf_prog_run_save_cb->BPF_PROG_RUN
and a combination of af_packet with tun device didn't disable either:
tpacket_snd->packet_direct_xmit->packet_pick_tx_queue->ndo_select_queue->
tun_select_queue->tun_ebpf_select_queue->bpf_prog_run_clear_cb->BPF_PROG_RUN
Disable preemption before executing BPF programs (both classic and extended).
--- include/linux/filter.h | 21 ++++++++++++++++++--- kernel/bpf/cgroup.c | 2 +- 2 files changed, 19 insertions(+), 4 deletions(-)
include/linux/filter.h +18 -3
@@ -591,8 +591,8 @@ static inline u8 *bpf_skb_cb(struct sk_buff *skb)return qdisc_skb_cb (skb)->data; } -static inline u32 bpf_prog_run_save_cb (const struct bpf_prog *prog, -struct sk_buff *skb) +static inline u32 __bpf_prog_run_save_cb (const struct bpf_prog *prog, +struct sk_buff *skb) {u8 *cb_data =bpf_skb_cb (skb);u8 cb_saved[BPF_SKB_CB_LEN ];
@@ -611,15 +611,30 @@ static inline u32 bpf_prog_run_save_cb(const struct bpf_prog *prog,return res; } +static inline u32 bpf_prog_run_save_cb (const struct bpf_prog *prog, +struct sk_buff *skb) +{ +u32 res; + +preempt_disable (); + res =__bpf_prog_run_save_cb (prog, skb); +preempt_enable (); +return res; +} +static inline u32 bpf_prog_run_clear_cb (const struct bpf_prog *prog,struct sk_buff *skb) {u8 *cb_data =bpf_skb_cb (skb); +u32 res;if (unlikely (prog->cb_access))memset (cb_data,0 ,BPF_SKB_CB_LEN ); -return BPF_PROG_RUN (prog, skb); +preempt_disable (); + res =BPF_PROG_RUN (prog, skb); +preempt_enable (); +return res; } static __always_inline u32 bpf_prog_run_xdp(const struct bpf_prog *prog,
kernel/bpf/cgroup.c +1 -1
@@ -572,7 +572,7 @@ int __cgroup_bpf_run_filter_skb(struct sock *sk,bpf_compute_and_save_data_end (skb, &saved_data_end); ret =BPF_PROG_RUN_ARRAY (cgrp->bpf.effective[type], skb, - bpf_prog_run_save_cb); + __bpf_prog_run_save_cb);bpf_restore_data_end (skb, saved_data_end);__skb_pull (skb, offset); skb->sk = save_sk;
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 47/81 bpf: fix lockdep false positive in percpu_freelist
In reply to Sasha LevinFrom: Alexei Starovoitov <[email protected]>
[ Upstream commit a89fac57b5d080771efd4d71feaae19877cf68f0 ]
Lockdep warns about false positive:
[ 12.492084] 00000000e6b28347 (&head->lock){+...}, at: pcpu_freelist_push+0x2a/0x40
[ 12.492696] but this lock was taken by another, HARDIRQ-safe lock in the past:
[ 12.493275] (&rq->lock){-.-.}
[ 12.493276]
[ 12.493276]
[ 12.493276] and interrupts could create inverse lock ordering between them.
[ 12.493276]
[ 12.494435]
[ 12.494435] other info that might help us debug this:
[ 12.494979] Possible interrupt unsafe locking scenario:
[ 12.494979]
[ 12.495518] CPU0 CPU1
[ 12.495879] ---- ----
[ 12.496243] lock(&head->lock);
[ 12.496502] local_irq_disable();
[ 12.496969] lock(&rq->lock);
[ 12.497431] lock(&head->lock);
[ 12.497890] <Interrupt>
[ 12.498104] lock(&rq->lock);
[ 12.498368]
[ 12.498368] *** DEADLOCK ***
[ 12.498368]
[ 12.498837] 1 lock held by dd/276:
[ 12.499110] #0: 00000000c58cb2ee (rcu_read_lock){....}, at: trace_call_bpf+0x5e/0x240
[ 12.499747]
[ 12.499747] the shortest dependencies between 2nd lock and 1st lock:
[ 12.500389] -> (&rq->lock){-.-.} {
[ 12.500669] IN-HARDIRQ-W at:
[ 12.500934] _raw_spin_lock+0x2f/0x40
[ 12.501373] scheduler_tick+0x4c/0xf0
[ 12.501812] update_process_times+0x40/0x50
[ 12.502294] tick_periodic+0x27/0xb0
[ 12.502723] tick_handle_periodic+0x1f/0x60
[ 12.503203] timer_interrupt+0x11/0x20
[ 12.503651] __handle_irq_event_percpu+0x43/0x2c0
[ 12.504167] handle_irq_event_percpu+0x20/0x50
[ 12.504674] handle_irq_event+0x37/0x60
[ 12.505139] handle_level_irq+0xa7/0x120
[ 12.505601] handle_irq+0xa1/0x150
[ 12.506018] do_IRQ+0x77/0x140
[ 12.506411] ret_from_intr+0x0/0x1d
[ 12.506834] _raw_spin_unlock_irqrestore+0x53/0x60
[ 12.507362] __setup_irq+0x481/0x730
[ 12.507789] setup_irq+0x49/0x80
[ 12.508195] hpet_time_init+0x21/0x32
[ 12.508644] x86_late_time_init+0xb/0x16
[ 12.509106] start_kernel+0x390/0x42a
[ 12.509554] secondary_startup_64+0xa4/0xb0
[ 12.510034] IN-SOFTIRQ-W at:
[ 12.510305] _raw_spin_lock+0x2f/0x40
[ 12.510772] try_to_wake_up+0x1c7/0x4e0
[ 12.511220] swake_up_locked+0x20/0x40
[ 12.511657] swake_up_one+0x1a/0x30
[ 12.512070] rcu_process_callbacks+0xc5/0x650
[ 12.512553] __do_softirq+0xe6/0x47b
[ 12.512978] irq_exit+0xc3/0xd0
[ 12.513372] smp_apic_timer_interrupt+0xa9/0x250
[ 12.513876] apic_timer_interrupt+0xf/0x20
[ 12.514343] default_idle+0x1c/0x170
[ 12.514765] do_idle+0x199/0x240
[ 12.515159] cpu_startup_entry+0x19/0x20
[ 12.515614] start_kernel+0x422/0x42a
[ 12.516045] secondary_startup_64+0xa4/0xb0
[ 12.516521] INITIAL USE at:
[ 12.516774] _raw_spin_lock_irqsave+0x38/0x50
[ 12.517258] rq_attach_root+0x16/0xd0
[ 12.517685] sched_init+0x2f2/0x3eb
[ 12.518096] start_kernel+0x1fb/0x42a
[ 12.518525] secondary_startup_64+0xa4/0xb0
[ 12.518986] }
[ 12.519132] ... key at: [<ffffffff82b7bc28>] __key.71384+0x0/0x8
[ 12.519649] ... acquired at:
[ 12.519892] pcpu_freelist_pop+0x7b/0xd0
[ 12.520221] bpf_get_stackid+0x1d2/0x4d0
[ 12.520563] ___bpf_prog_run+0x8b4/0x11a0
[ 12.520887]
[ 12.521008] -> (&head->lock){+...} {
[ 12.521292] HARDIRQ-ON-W at:
[ 12.521539] _raw_spin_lock+0x2f/0x40
[ 12.521950] pcpu_freelist_push+0x2a/0x40
[ 12.522396] bpf_get_stackid+0x494/0x4d0
[ 12.522828] ___bpf_prog_run+0x8b4/0x11a0
[ 12.523296] INITIAL USE at:
[ 12.523537] _raw_spin_lock+0x2f/0x40
[ 12.523944] pcpu_freelist_populate+0xc0/0x120
[ 12.524417] htab_map_alloc+0x405/0x500
[ 12.524835] __do_sys_bpf+0x1a3/0x1a90
[ 12.525253] do_syscall_64+0x4a/0x180
[ 12.525659] entry_SYSCALL_64_after_hwframe+0x49/0xbe
[ 12.526167] }
[ 12.526311] ... key at: [<ffffffff838f7668>] __key.13130+0x0/0x8
[ 12.526812] ... acquired at:
[ 12.527047] __lock_acquire+0x521/0x1350
[ 12.527371] lock_acquire+0x98/0x190
[ 12.527680] _raw_spin_lock+0x2f/0x40
[ 12.527994] pcpu_freelist_push+0x2a/0x40
[ 12.528325] bpf_get_stackid+0x494/0x4d0
[ 12.528645] ___bpf_prog_run+0x8b4/0x11a0
[ 12.528970]
[ 12.529092]
[ 12.529092] stack backtrace:
[ 12.529444] CPU: 0 PID: 276 Comm: dd Not tainted 5.0.0-rc3-00018-g2fa53f892422 #475
[ 12.530043] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.11.0-2.el7 04/01/2014
[ 12.530750] Call Trace:
[ 12.530948] dump_stack+0x5f/0x8b
[ 12.531248] check_usage_backwards+0x10c/0x120
[ 12.531598] ? ___bpf_prog_run+0x8b4/0x11a0
[ 12.531935] ? mark_lock+0x382/0x560
[ 12.532229] mark_lock+0x382/0x560
[ 12.532496] ? print_shortest_lock_dependencies+0x180/0x180
[ 12.532928] __lock_acquire+0x521/0x1350
[ 12.533271] ? find_get_entry+0x17f/0x2e0
[ 12.533586] ? find_get_entry+0x19c/0x2e0
[ 12.533902] ? lock_acquire+0x98/0x190
[ 12.534196] lock_acquire+0x98/0x190
[ 12.534482] ? pcpu_freelist_push+0x2a/0x40
[ 12.534810] _raw_spin_lock+0x2f/0x40
[ 12.535099] ? pcpu_freelist_push+0x2a/0x40
[ 12.535432] pcpu_freelist_push+0x2a/0x40
[ 12.535750] bpf_get_stackid+0x494/0x4d0
[ 12.536062] ___bpf_prog_run+0x8b4/0x11a0It has been explained that is a false positive here:
https://lkml.org/lkml/2018/7/25/756
Recap:
- stackmap uses pcpu_freelist
- The lock in pcpu_freelist is a percpu lock
- stackmap is only used by tracing bpf_prog
- A tracing bpf_prog cannot be run if another bpf_prog
has already been running (ensured by the percpu bpf_prog_active counter).
Eric pointed out that this lockdep splats stops other legit lockdep splats in selftests/bpf/test_progs.c.
Fix this by calling local_irq_save/restore for stackmap.
Another false positive had also been worked around by calling local_irq_save in commit 89ad2fa3f043 ("bpf: fix lockdep splat"). That commit added unnecessary irq_save/restore to fast path of bpf hash map. irqs are already disabled at that point, since htab is holding per bucket spin_lock with irqsave.
Let's reduce overhead for htab by introducing __pcpu_freelist_push/pop function w/o irqsave and convert pcpu_freelist_push/pop to irqsave to be used elsewhere (right now only in stackmap).
It stops lockdep false positive in stackmap with a bit of acceptable overhead.
--- kernel/bpf/hashtab.c | 4 ++-- kernel/bpf/percpu_freelist.c | 41 +++++++++++++++++++++++++----------- kernel/bpf/percpu_freelist.h | 4 ++++ 3 files changed, 35 insertions(+), 14 deletions(-)
kernel/bpf/hashtab.c +2 -2
@@ -677,7 +677,7 @@ static void free_htab_elem(struct bpf_htab *htab, struct htab_elem *l) }if (htab_is_prealloc (htab)) { -pcpu_freelist_push (&htab->freelist, &l->fnode); +__pcpu_freelist_push (&htab->freelist, &l->fnode); }else {atomic_dec (&htab->count); l->htab = htab;
@@ -739,7 +739,7 @@ static struct htab_elem *alloc_htab_elem(struct bpf_htab *htab, void *key, }else {struct pcpu_freelist_node *l; - l =pcpu_freelist_pop (&htab->freelist); + l =__pcpu_freelist_pop (&htab->freelist);if (!l)return ERR_PTR (-E2BIG ); l_new = container_of(l, struct htab_elem, fnode);
kernel/bpf/percpu_freelist.c +29 -12
86 lines not on this page · raw message
kernel/bpf/percpu_freelist.h +4 -0
@@ -22,8 +22,12 @@ struct pcpu_freelist_node {struct pcpu_freelist_node *next; }; +/* pcpu_freelist_* do spin_lock_irqsave. */ void pcpu_freelist_push (struct pcpu_freelist *,struct pcpu_freelist_node *);struct pcpu_freelist_node *pcpu_freelist_pop (struct pcpu_freelist *); +/* __pcpu_freelist_* do spin_lock only. caller must disable irqs. */ +void __pcpu_freelist_push (struct pcpu_freelist *,struct pcpu_freelist_node *); +struct pcpu_freelist_node *__pcpu_freelist_pop (struct pcpu_freelist *);void pcpu_freelist_populate (struct pcpu_freelist *s,void *buf,u32 elem_size,u32 nr_elems);int pcpu_freelist_init (struct pcpu_freelist *);
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 48/81 bpf: fix potential deadlock in bpf_prog_register
In reply to Sasha LevinFrom: Alexei Starovoitov <[email protected]>
[ Upstream commit e16ec34039c701594d55d08a5aa49ee3e1abc821 ]
Lockdep found a potential deadlock between cpu_hotplug_lock, bpf_event_mutex, and cpuctx_mutex:
[ 13.007000] WARNING: possible circular locking dependency detected
[ 13.007587] 5.0.0-rc3-00018-g2fa53f892422-dirty #477 Not tainted
[ 13.008124] ------------------------------------------------------
[ 13.008624] test_progs/246 is trying to acquire lock:
[ 13.009030] 0000000094160d1d (tracepoints_mutex){+.+.}, at: tracepoint_probe_register_prio+0x2d/0x300
[ 13.009770]
[ 13.009770] but task is already holding lock:
[ 13.010239] 00000000d663ef86 (bpf_event_mutex){+.+.}, at: bpf_probe_register+0x1d/0x60
[ 13.010877]
[ 13.010877] which lock already depends on the new lock.
[ 13.010877]
[ 13.011532]
[ 13.011532] the existing dependency chain (in reverse order) is:
[ 13.012129]
[ 13.012129] -> #4 (bpf_event_mutex){+.+.}:
[ 13.012582] perf_event_query_prog_array+0x9b/0x130
[ 13.013016] _perf_ioctl+0x3aa/0x830
[ 13.013354] perf_ioctl+0x2e/0x50
[ 13.013668] do_vfs_ioctl+0x8f/0x6a0
[ 13.014003] ksys_ioctl+0x70/0x80
[ 13.014320] __x64_sys_ioctl+0x16/0x20
[ 13.014668] do_syscall_64+0x4a/0x180
[ 13.015007] entry_SYSCALL_64_after_hwframe+0x49/0xbe
[ 13.015469]
[ 13.015469] -> #3 (&cpuctx_mutex){+.+.}:
[ 13.015910] perf_event_init_cpu+0x5a/0x90
[ 13.016291] perf_event_init+0x1b2/0x1de
[ 13.016654] start_kernel+0x2b8/0x42a
[ 13.016995] secondary_startup_64+0xa4/0xb0
[ 13.017382]
[ 13.017382] -> #2 (pmus_lock){+.+.}:
[ 13.017794] perf_event_init_cpu+0x21/0x90
[ 13.018172] cpuhp_invoke_callback+0xb3/0x960
[ 13.018573] _cpu_up+0xa7/0x140
[ 13.018871] do_cpu_up+0xa4/0xc0
[ 13.019178] smp_init+0xcd/0xd2
[ 13.019483] kernel_init_freeable+0x123/0x24f
[ 13.019878] kernel_init+0xa/0x110
[ 13.020201] ret_from_fork+0x24/0x30
[ 13.020541]
[ 13.020541] -> #1 (cpu_hotplug_lock.rw_sem){++++}:
[ 13.021051] static_key_slow_inc+0xe/0x20
[ 13.021424] tracepoint_probe_register_prio+0x28c/0x300
[ 13.021891] perf_trace_event_init+0x11f/0x250
[ 13.022297] perf_trace_init+0x6b/0xa0
[ 13.022644] perf_tp_event_init+0x25/0x40
[ 13.023011] perf_try_init_event+0x6b/0x90
[ 13.023386] perf_event_alloc+0x9a8/0xc40
[ 13.023754] __do_sys_perf_event_open+0x1dd/0xd30
[ 13.024173] do_syscall_64+0x4a/0x180
[ 13.024519] entry_SYSCALL_64_after_hwframe+0x49/0xbe
[ 13.024968]
[ 13.024968] -> #0 (tracepoints_mutex){+.+.}:
[ 13.025434] __mutex_lock+0x86/0x970
[ 13.025764] tracepoint_probe_register_prio+0x2d/0x300
[ 13.026215] bpf_probe_register+0x40/0x60
[ 13.026584] bpf_raw_tracepoint_open.isra.34+0xa4/0x130
[ 13.027042] __do_sys_bpf+0x94f/0x1a90
[ 13.027389] do_syscall_64+0x4a/0x180
[ 13.027727] entry_SYSCALL_64_after_hwframe+0x49/0xbe
[ 13.028171]
[ 13.028171] other info that might help us debug this:
[ 13.028171]
[ 13.028807] Chain exists of:
[ 13.028807] tracepoints_mutex --> &cpuctx_mutex --> bpf_event_mutex
[ 13.028807]
[ 13.029666] Possible unsafe locking scenario:
[ 13.029666]
[ 13.030140] CPU0 CPU1
[ 13.030510] ---- ----
[ 13.030875] lock(bpf_event_mutex);
[ 13.031166] lock(&cpuctx_mutex);
[ 13.031645] lock(bpf_event_mutex);
[ 13.032135] lock(tracepoints_mutex);
[ 13.032441]
[ 13.032441] *** DEADLOCK ***
[ 13.032441]
[ 13.032911] 1 lock held by test_progs/246:
[ 13.033239] #0: 00000000d663ef86 (bpf_event_mutex){+.+.}, at: bpf_probe_register+0x1d/0x60
[ 13.033909]
[ 13.033909] stack backtrace:
[ 13.034258] CPU: 1 PID: 246 Comm: test_progs Not tainted 5.0.0-rc3-00018-g2fa53f892422-dirty #477
[ 13.034964] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.11.0-2.el7 04/01/2014
[ 13.035657] Call Trace:
[ 13.035859] dump_stack+0x5f/0x8b
[ 13.036130] print_circular_bug.isra.37+0x1ce/0x1db
[ 13.036526] __lock_acquire+0x1158/0x1350
[ 13.036852] ? lock_acquire+0x98/0x190
[ 13.037154] lock_acquire+0x98/0x190
[ 13.037447] ? tracepoint_probe_register_prio+0x2d/0x300
[ 13.037876] __mutex_lock+0x86/0x970
[ 13.038167] ? tracepoint_probe_register_prio+0x2d/0x300
[ 13.038600] ? tracepoint_probe_register_prio+0x2d/0x300
[ 13.039028] ? __mutex_lock+0x86/0x970
[ 13.039337] ? __mutex_lock+0x24a/0x970
[ 13.039649] ? bpf_probe_register+0x1d/0x60
[ 13.039992] ? __bpf_trace_sched_wake_idle_without_ipi+0x10/0x10
[ 13.040478] ? tracepoint_probe_register_prio+0x2d/0x300
[ 13.040906] tracepoint_probe_register_prio+0x2d/0x300
[ 13.041325] bpf_probe_register+0x40/0x60
[ 13.041649] bpf_raw_tracepoint_open.isra.34+0xa4/0x130
[ 13.042068] ? __might_fault+0x3e/0x90
[ 13.042374] __do_sys_bpf+0x94f/0x1a90
[ 13.042678] do_syscall_64+0x4a/0x180
[ 13.042975] entry_SYSCALL_64_after_hwframe+0x49/0xbe
[ 13.043382] RIP: 0033:0x7f23b10a07f9
[ 13.045155] RSP: 002b:00007ffdef42fdd8 EFLAGS: 00000202 ORIG_RAX: 0000000000000141
[ 13.045759] RAX: ffffffffffffffda RBX: 00007ffdef42ff70 RCX: 00007f23b10a07f9
[ 13.046326] RDX: 0000000000000070 RSI: 00007ffdef42fe10 RDI: 0000000000000011
[ 13.046893] RBP: 00007ffdef42fdf0 R08: 0000000000000038 R09: 00007ffdef42fe10
[ 13.047462] R10: 0000000000000000 R11: 0000000000000202 R12: 0000000000000000
[ 13.048029] R13: 0000000000000016 R14: 00007f23b1db4690 R15: 0000000000000000Since tracepoints_mutex will be taken in tracepoint_probe_register/unregister() there is no need to take bpf_event_mutex too.bpf_event_mutex is protecting modifications to prog array used in kprobe/perf bpf progs. bpf_raw_tracepoints don't need to take this mutex.
--- kernel/trace/bpf_trace.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-)
kernel/trace/bpf_trace.c +2 -12
@@ -1158,22 +1158,12 @@ static int __bpf_probe_register(struct bpf_raw_event_map *btp, struct bpf_prog *int bpf_probe_register (struct bpf_raw_event_map *btp,struct bpf_prog *prog) { -int err; - -mutex_lock (&bpf_event_mutex); - err =__bpf_probe_register (btp, prog); -mutex_unlock (&bpf_event_mutex); -return err; +return __bpf_probe_register (btp, prog); }int bpf_probe_unregister (struct bpf_raw_event_map *btp,struct bpf_prog *prog) { -int err; - -mutex_lock (&bpf_event_mutex); - err =tracepoint_probe_unregister (btp->tp, (void *)btp->bpf_func, prog); -mutex_unlock (&bpf_event_mutex); -return err; +return tracepoint_probe_unregister (btp->tp, (void *)btp->bpf_func, prog); } int bpf_get_perf_event_info(const struct perf_event *event, u32 *prog_id,
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 49/81 bpf: Fix syscall's stackmap lookup potential deadlock
In reply to Sasha LevinFrom: Martin KaFai Lau <[email protected]>
[ Upstream commit 7c4cd051add3d00bbff008a133c936c515eaa8fe ]
The map_lookup_elem used to not acquiring spinlock in order to optimize the reader.
It was true until commit 557c0c6e7df8 ("bpf: convert stackmap to pre-allocation") The syscall's map_lookup_elem(stackmap) calls bpf_stackmap_copy(). bpf_stackmap_copy() may find the elem no longer needed after the copy is done. If that is the case, pcpu_freelist_push() saves this elem for reuse later. This push requires a spinlock.
If a tracing bpf_prog got run in the middle of the syscall's map_lookup_elem(stackmap) and this tracing bpf_prog is calling bpf_get_stackid(stackmap) which also requires the same pcpu_freelist's spinlock, it may end up with a dead lock situation as reported by Eric Dumazet in https://patchwork.ozlabs.org/patch/1030266/
The situation is the same as the syscall's map_update_elem() which needs to acquire the pcpu_freelist's spinlock and could race with tracing bpf_prog. Hence, this patch fixes it by protecting bpf_stackmap_copy() with this_cpu_inc(bpf_prog_active) to prevent tracing bpf_prog from running.
A later syscall's map_lookup_elem commit f1a2e44a3aec ("bpf: add queue and stack maps") also acquires a spinlock and races with tracing bpf_prog similarly. Hence, this patch is forward looking and protects the majority
of the map lookups. bpf_map_offload_lookup_elem() is the exception
since it is for network bpf_prog only (i.e. never called by tracing bpf_prog).
--- kernel/bpf/syscall.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
kernel/bpf/syscall.c +10 -2
@@ -712,8 +712,13 @@ static int map_lookup_elem(union bpf_attr *attr)if (bpf_map_is_dev_bound (map)) { err =bpf_map_offload_lookup_elem (map, key, value); - }else if (map->map_type ==BPF_MAP_TYPE_PERCPU_HASH || - map->map_type ==BPF_MAP_TYPE_LRU_PERCPU_HASH ) { + goto done; + } + +preempt_disable (); +this_cpu_inc (bpf_prog_active); +if (map->map_type ==BPF_MAP_TYPE_PERCPU_HASH || + map->map_type ==BPF_MAP_TYPE_LRU_PERCPU_HASH ) { err =bpf_percpu_hash_copy (map, key, value); }else if (map->map_type ==BPF_MAP_TYPE_PERCPU_ARRAY ) { err =bpf_percpu_array_copy (map, key, value);
@@ -743,7 +748,10 @@ static int map_lookup_elem(union bpf_attr *attr) }rcu_read_unlock (); } +this_cpu_dec (bpf_prog_active); +preempt_enable (); +done:if (err) goto free_value;
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 50/81 drm/amdgpu: Implement doorbell self-ring for NBIO 7.4
In reply to Sasha LevinFrom: Jay Cornwall <[email protected]>
[ Upstream commit 12292519d919ecde92e7e7c8acbcdb9f0c7c6013 ]
Fixes doorbell reflection on Vega20.
--- drivers/gpu/drm/amd/amdgpu/nbio_v7_4.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/gpu/drm/amd/amdgpu/nbio_v7_4.c +13 -0
@@ -92,7 +92,20 @@ static void nbio_v7_4_enable_doorbell_aperture(struct amdgpu_device *adev,static void nbio_v7_4_enable_doorbell_selfring_aperture (struct amdgpu_device *adev,bool enable) { +u32 tmp =0 ; +if (enable) { + tmp =REG_SET_FIELD (tmp,DOORBELL_SELFRING_GPA_APER_CNTL ,DOORBELL_SELFRING_GPA_APER_EN ,1 ) | +REG_SET_FIELD (tmp,DOORBELL_SELFRING_GPA_APER_CNTL ,DOORBELL_SELFRING_GPA_APER_MODE ,1 ) | +REG_SET_FIELD (tmp,DOORBELL_SELFRING_GPA_APER_CNTL ,DOORBELL_SELFRING_GPA_APER_SIZE ,0 ); + +WREG32_SOC15 (NBIO ,0 , mmDOORBELL_SELFRING_GPA_APER_BASE_LOW, +lower_32_bits (adev->doorbell.base)); +WREG32_SOC15 (NBIO ,0 , mmDOORBELL_SELFRING_GPA_APER_BASE_HIGH, +upper_32_bits (adev->doorbell.base)); + } + +WREG32_SOC15 (NBIO ,0 , mmDOORBELL_SELFRING_GPA_APER_CNTL, tmp); } static void nbio_v7_4_ih_doorbell_range(struct amdgpu_device *adev,
Signature · 6 lines
2.19.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 51/81 drm/amdgpu: fix the incorrect external id for raven series
In reply to Sasha LevinFrom: Huang Rui <[email protected]>
[ Upstream commit 7e4545d372b560df10fa47281ef0783a479ce435 ]
This patch fixes the incorrect external id that kernel reports to user mode driver. Raven2's rev_id is starts from 0x8, so its external id (0x81) should start from rev_id + 0x79 (0x81 - 0x8). And Raven's rev_id should be 0x21 while rev_id == 1.
--- drivers/gpu/drm/amd/amdgpu/soc15.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/soc15.c +4 -2
@@ -705,11 +705,13 @@ static int soc15_common_early_init(void *handle)break ;case CHIP_RAVEN :if (adev->rev_id >=0x8 ) - adev->external_rev_id = adev->rev_id +0x81 ; + adev->external_rev_id = adev->rev_id +0x79 ;else if (adev->pdev->device ==0x15d8 ) adev->external_rev_id = adev->rev_id +0x41 ; +else if (adev->rev_id ==1 ) + adev->external_rev_id = adev->rev_id +0x20 ;else - adev->external_rev_id =0x1 ; + adev->external_rev_id = adev->rev_id +0x01 ;if (adev->rev_id >=0x8 ) { adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG |
Signature · 6 lines
2.19.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Sasha Levin
maintainerPATCH 52/81 drm/sun4i: tcon: Prepare and enable TCON channel 0 clock at init
In reply to Sasha LevinFrom: Paul Kocialkowski <[email protected]>
[ Upstream commit b14e945bda8ae227d1bf2b1837c0c4a61721cd1a ]
When initializing clocks, a reference to the TCON channel 0 clock is obtained. However, the clock is never prepared and enabled later. Switching from simplefb to DRM actually disables the clock (that was usually configured by U-Boot) because of that.
On the V3s, this results in a hang when writing to some mixer registers when switching over to DRM from simplefb.
Fix this by preparing and enabling the clock when initializing other clocks. Waiting for sun4i_tcon_channel_enable to enable the clock is apparently too late and results in the same mixer register access hang.
--- drivers/gpu/drm/sun4i/sun4i_tcon.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/sun4i/sun4i_tcon.c +2 -0
@@ -760,6 +760,7 @@ static int sun4i_tcon_init_clocks(struct device *dev,return PTR_ERR (tcon->sclk0); } } +clk_prepare_enable (tcon->sclk0);if (tcon->quirks->has_channel_1) { tcon->sclk1 =devm_clk_get (dev,"tcon-ch1" );
@@ -774,6 +775,7 @@ static int sun4i_tcon_init_clocks(struct device *dev,static void sun4i_tcon_free_clocks (struct sun4i_tcon *tcon) { +clk_disable_unprepare (tcon->sclk0);clk_disable_unprepare (tcon->clk); }
Signature · 6 lines
2.19.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 53/81 dmaengine: at_xdmac: Fix wrongfull report of a channel as in use
In reply to Sasha LevinFrom: Codrin Ciubotariu <[email protected]>
[ Upstream commit dc3f595b6617ebc0307e0ce151e8f2f2b2489b95 ]
atchan->status variable is used to store two different information:
- pass channel interrupts status from interrupt handler to tasklet;
- channel information like whether it is cyclic or paused;
This causes a bug when device_terminate_all() is called, (AT_XDMAC_CHAN_IS_CYCLIC cleared on atchan->status) and then a late End of Block interrupt arrives (AT_XDMAC_CIS_BIS), which sets bit 0 of atchan->status. Bit 0 is also used for AT_XDMAC_CHAN_IS_CYCLIC, so when a new descriptor for a cyclic transfer is created, the driver reports the channel as in use:
if (test_and_set_bit(AT_XDMAC_CHAN_IS_CYCLIC, &atchan->status)) {
dev_err(chan2dev(chan), "channel currently used\n");
return NULL;
}This patch fixes the bug by adding a different struct member to keep the interrupts status separated from the channel status bits.
--- drivers/dma/at_xdmac.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
drivers/dma/at_xdmac.c +10 -9
@@ -203,6 +203,7 @@ struct at_xdmac_chan {u32 save_cim;u32 save_cnda;u32 save_cndc; +u32 irq_status;unsigned long status;struct tasklet_struct tasklet;struct dma_slave_config sconfig;
@@ -1580,8 +1581,8 @@ static void at_xdmac_tasklet(unsigned long data)struct at_xdmac_desc *desc;u32 error_mask; -dev_dbg (chan2dev (&atchan->chan),"%s: status=0x%08lx\n" , - __func__, atchan->status); +dev_dbg (chan2dev (&atchan->chan),"%s: status=0x%08x\n" , + __func__, atchan->irq_status); error_mask =AT_XDMAC_CIS_RBEIS |AT_XDMAC_CIS_WBEIS
@@ -1589,15 +1590,15 @@ static void at_xdmac_tasklet(unsigned long data)if (at_xdmac_chan_is_cyclic (atchan)) {at_xdmac_handle_cyclic (atchan); - }else if ((atchan->status &AT_XDMAC_CIS_LIS ) - || (atchan->status & error_mask)) { + }else if ((atchan->irq_status &AT_XDMAC_CIS_LIS ) + || (atchan->irq_status & error_mask)) {struct dma_async_tx_descriptor *txd; -if (atchan->status &AT_XDMAC_CIS_RBEIS ) +if (atchan->irq_status &AT_XDMAC_CIS_RBEIS )dev_err (chan2dev (&atchan->chan),"read bus error!!!" ); -if (atchan->status &AT_XDMAC_CIS_WBEIS ) +if (atchan->irq_status &AT_XDMAC_CIS_WBEIS )dev_err (chan2dev (&atchan->chan),"write bus error!!!" ); -if (atchan->status &AT_XDMAC_CIS_ROIS ) +if (atchan->irq_status &AT_XDMAC_CIS_ROIS )dev_err (chan2dev (&atchan->chan),"request overflow error!!!" );spin_lock (&atchan->lock);
@@ -1652,7 +1653,7 @@ static irqreturn_t at_xdmac_interrupt(int irq, void *dev_id) atchan = &atxdmac->chan[i]; chan_imr =at_xdmac_chan_read (atchan,AT_XDMAC_CIM ); chan_status =at_xdmac_chan_read (atchan,AT_XDMAC_CIS ); - atchan->status = chan_status & chan_imr; + atchan->irq_status = chan_status & chan_imr;dev_vdbg (atxdmac->dma.dev,"%s: chan%d: imr=0x%x, status=0x%x\n" , __func__, i, chan_imr, chan_status);
@@ -1666,7 +1667,7 @@ static irqreturn_t at_xdmac_interrupt(int irq, void *dev_id)at_xdmac_chan_read (atchan,AT_XDMAC_CDA ), at_xdmac_chan_read(atchan, AT_XDMAC_CUBC)); -if (atchan->status & (AT_XDMAC_CIS_RBEIS |AT_XDMAC_CIS_WBEIS )) +if (atchan->irq_status & (AT_XDMAC_CIS_RBEIS |AT_XDMAC_CIS_WBEIS ))at_xdmac_write (atxdmac,AT_XDMAC_GD , atchan->mask);tasklet_schedule (&atchan->tasklet);
Signature · 7 lines
2.19.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 54/81 vsock/virtio: fix kernel panic after device hot-unplug
In reply to Sasha LevinFrom: Stefano Garzarella <[email protected]>
[ Upstream commit 22b5c0b63f32568e130fa2df4ba23efce3eb495b ]
virtio_vsock_remove() invokes the vsock_core_exit() also if there are opened sockets for the AF_VSOCK protocol family. In this way the vsock "transport" pointer is set to NULL, triggering the kernel panic at the first socket activity.
This patch move the vsock_core_init()/vsock_core_exit() in the virtio_vsock respectively in module_init and module_exit functions, that cannot be invoked until there are open sockets.
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1609699
--- net/vmw_vsock/virtio_transport.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-)
net/vmw_vsock/virtio_transport.c +18 -8
@@ -75,6 +75,9 @@ static u32 virtio_transport_get_local_cid(void) {struct virtio_vsock *vsock =virtio_vsock_get (); +if (!vsock) +return VMADDR_CID_ANY ; +return vsock->guest_cid; }
@@ -584,10 +587,6 @@ static int virtio_vsock_probe(struct virtio_device *vdev)virtio_vsock_update_guest_cid (vsock); - ret =vsock_core_init (&virtio_transport.transport); -if (ret <0 ) - goto out_vqs; - vsock->rx_buf_nr =0 ; vsock->rx_buf_max_nr =0 ;atomic_set (&vsock->queued_replies,0 );
@@ -618,8 +617,6 @@ static int virtio_vsock_probe(struct virtio_device *vdev)mutex_unlock (&the_virtio_vsock_mutex);return 0 ; -out_vqs: - vsock->vdev->config->del_vqs (vsock->vdev); out:kfree (vsock);mutex_unlock (&the_virtio_vsock_mutex);
@@ -669,7 +666,6 @@ static void virtio_vsock_remove(struct virtio_device *vdev)mutex_lock (&the_virtio_vsock_mutex); the_virtio_vsock =NULL ; -vsock_core_exit ();mutex_unlock (&the_virtio_vsock_mutex); vdev->config->del_vqs (vdev);
@@ -702,14 +698,28 @@ static int __init virtio_vsock_init(void) virtio_vsock_workqueue =alloc_workqueue ("virtio_vsock" ,0 ,0 );if (!virtio_vsock_workqueue)return -ENOMEM ; + ret =register_virtio_driver (&virtio_vsock_driver);if (ret) -destroy_workqueue (virtio_vsock_workqueue); + goto out_wq; + + ret =vsock_core_init (&virtio_transport.transport); +if (ret) + goto out_vdr; + +return 0 ; + +out_vdr: +unregister_virtio_driver (&virtio_vsock_driver); +out_wq: +destroy_workqueue (virtio_vsock_workqueue);return ret; + } static void __exit virtio_vsock_exit(void) { +vsock_core_exit ();unregister_virtio_driver (&virtio_vsock_driver);destroy_workqueue (virtio_vsock_workqueue); }
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 55/81 vsock/virtio: reset connected sockets on device removal
In reply to Sasha LevinFrom: Stefano Garzarella <[email protected]>
[ Upstream commit 85965487abc540368393a15491e6e7fcd230039d ]
When the virtio transport device disappear, we should reset all connected sockets in order to inform the users.
--- net/vmw_vsock/virtio_transport.c | 3 +++ 1 file changed, 3 insertions(+)
net/vmw_vsock/virtio_transport.c +3 -0
@@ -634,6 +634,9 @@ static void virtio_vsock_remove(struct virtio_device *vdev)flush_work (&vsock->event_work);flush_work (&vsock->send_pkt_work); +/* Reset all connected sockets when the device disappear */ +vsock_for_each_connected_socket (virtio_vsock_reset_sock); + vdev->config->reset (vdev);mutex_lock (&vsock->rx_lock);
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 56/81 dmaengine: dmatest: Abort test in case of mapping error
In reply to Sasha LevinFrom: Andy Shevchenko <[email protected]>
[ Upstream commit 6454368a804c4955ccd116236037536f81e5b1f1 ]
In case of mapping error the DMA addresses are invalid and continuing will screw system memory or potentially something else.
[ 222.480310] dmatest: dma0chan7-copy0: summary 1 tests, 3 failures 6 iops 349 KB/s (0) ... [ 240.912725] check: Corrupted low memory at 00000000c7c75ac9 (2940 phys) = 5656000000000000 [ 240.921998] check: Corrupted low memory at 000000005715a1cd (2948 phys) = 279f2aca5595ab2b [ 240.931280] check: Corrupted low memory at 000000002f4024c0 (2950 phys) = 5e5624f349e793cf
...
Abort any test if mapping failed.
--- drivers/dma/dmatest.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-)
drivers/dma/dmatest.c +12 -16
@@ -642,11 +642,9 @@ static int dmatest_func(void *data) srcs[i] = um->addr[i] + src_off; ret =dma_mapping_error (dev->dev, um->addr[i]);if (ret) { -dmaengine_unmap_put (um);result ("src mapping error" , total_tests, src_off, dst_off, len, ret); - failed_tests++; -continue ; + goto error_unmap_continue; } um->to_cnt++; }
@@ -661,11 +659,9 @@ static int dmatest_func(void *data) DMA_BIDIRECTIONAL); ret =dma_mapping_error (dev->dev, dsts[i]);if (ret) { -dmaengine_unmap_put (um);result ("dst mapping error" , total_tests, src_off, dst_off, len, ret); - failed_tests++; -continue ; + goto error_unmap_continue; } um->bidi_cnt++; }
@@ -693,12 +689,10 @@ static int dmatest_func(void *data) }if (!tx) { -dmaengine_unmap_put (um);result ("prep error" , total_tests, src_off, dst_off, len, ret);msleep (100 ); - failed_tests++; -continue ; + goto error_unmap_continue; } done->done = false;
@@ -707,12 +701,10 @@ static int dmatest_func(void *data) cookie = tx->tx_submit (tx);if (dma_submit_error (cookie)) { -dmaengine_unmap_put (um);result ("submit error" , total_tests, src_off, dst_off, len, ret);msleep (100 ); - failed_tests++; -continue ; + goto error_unmap_continue; }dma_async_issue_pending (chan);
@@ -725,16 +717,14 @@ static int dmatest_func(void *data)dmaengine_unmap_put (um);result ("test timed out" , total_tests, src_off, dst_off, len,0 ); - failed_tests++; -continue ; + goto error_unmap_continue; }else if (status !=DMA_COMPLETE ) {dmaengine_unmap_put (um);result (status ==DMA_ERROR ?"completion error status" :"completion busy status" , total_tests, src_off, dst_off, len, ret); - failed_tests++; -continue ; + goto error_unmap_continue; }dmaengine_unmap_put (um);
@@ -779,6 +769,12 @@ static int dmatest_func(void *data)verbose_result ("test passed" , total_tests, src_off, dst_off, len,0 ); } + +continue ; + +error_unmap_continue: +dmaengine_unmap_put (um); + failed_tests++; } ktime =ktime_sub (ktime_get (), ktime); ktime =ktime_sub (ktime, comparetime);
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 57/81 selftests: netfilter: fix config fragment CONFIG_NF_TABLES_INET
In reply to Sasha LevinFrom: Naresh Kamboju <naresh.kamboju at linaro.org>
[ Upstream commit 952b72f89ae23b316da8c1021b18d0c388ad6cc4 ]
In selftests the config fragment for netfilter was added as NF_TABLES_INET=y and this patch correct it as CONFIG_NF_TABLES_INET=y
--- tools/testing/selftests/netfilter/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/netfilter/config +1 -1
@@ -1,2 +1,2 @@ CONFIG_NET_NS=y -NF_TABLES_INET=y +CONFIG_NF_TABLES_INET=y
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 58/81 selftests: netfilter: add simple masq/redirect test cases
In reply to Sasha LevinFrom: Florian Westphal <[email protected]>
[ Upstream commit 98bfc3414bda335dbd7fec58bde6266f991801d7 ]
Check basic nat/redirect/masquerade for ipv4 and ipv6.
--- tools/testing/selftests/netfilter/Makefile | 2 +- tools/testing/selftests/netfilter/nft_nat.sh | 762 +++++++++++++++++++ 2 files changed, 763 insertions(+), 1 deletion(-) create mode 100755 tools/testing/selftests/netfilter/nft_nat.sh
tools/testing/selftests/netfilter/Makefile +1 -1
@@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 # Makefile for netfilter selftests -TEST_PROGS := nft_trans_stress.sh +TEST_PROGS := nft_trans_stress.sh nft_nat.sh include ../lib.mk
tools/testing/selftests/netfilter/nft_nat.sh new file +762 -0
762 lines not on this page · raw message
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 59/81 netfilter: nf_nat: skip nat clash resolution for same-origin entries
In reply to Sasha LevinFrom: Martynas Pumputis <[email protected]>
[ Upstream commit 4e35c1cb9460240e983a01745b5f29fe3a4d8e39 ]
It is possible that two concurrent packets originating from the same socket of a connection-less protocol (e.g. UDP) can end up having different IP_CT_DIR_REPLY tuples which results in one of the packets being dropped.
To illustrate this, consider the following simplified scenario:
1. Packet A and B are sent at the same time from two different threads by same UDP socket. No matching conntrack entry exists yet. Both packets cause allocation of a new conntrack entry.
2. get_unique_tuple gets called for A. No clashing entry found. conntrack entry for A is added to main conntrack table.
3. get_unique_tuple is called for B and will find that the reply tuple of B is already taken by A.
It will allocate a new UDP source port for B to resolve the clash.
4. conntrack entry for B cannot be added to main conntrack table because its ORIGINAL direction is clashing with A and the REPLY directions of A and B are not the same anymore due to UDP source port reallocation done in step 3.
This patch modifies nf_conntrack_tuple_taken so it doesn't consider colliding reply tuples if the IP_CT_DIR_ORIGINAL tuples are equal.
[ Florian: simplify patch to not use .allow_clash setting
and always ignore identical flows ]
--- net/netfilter/nf_conntrack_core.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
net/netfilter/nf_conntrack_core.c +16 -0
@@ -1007,6 +1007,22 @@ nf_conntrack_tuple_taken(const struct nf_conntrack_tuple *tuple, }if (nf_ct_key_equal (h, tuple, zone, net)) { +/* Tuple is taken already, so caller will need to find +* a new source port to use. +* +* Only exception: +* If the *original tuples* are identical, then both +* conntracks refer to the same flow. +* This is a rare situation, it can occur e.g. when +* more than one UDP packet is sent from same socket +* in different threads. +* +* Let nf_ct_resolve_clash() deal with this later. +*/ +if (nf_ct_tuple_equal (&ignored_conntrack->tuplehash[IP_CT_DIR_ORIGINAL ].tuple, + &ct->tuplehash[IP_CT_DIR_ORIGINAL ].tuple)) +continue ; +NF_CT_STAT_INC_ATOMIC (net, found);rcu_read_unlock ();return 1 ;
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 60/81 arm64: ptdump: Don't iterate kernel page tables using PTRS_PER_PXX
In reply to Sasha LevinFrom: Will Deacon <[email protected]>
[ Upstream commit d23c808c6fc6132e812690648e14c0d6b0cbe273 ]
When 52-bit virtual addressing is enabled for userspace (CONFIG_ARM64_USER_VA_BITS_52=y), the kernel continues to utilise 48-bit virtual addressing in TTBR1. Consequently, PTRS_PER_PGD reflects the larger page table size for userspace and the pgd pointer for kernel page tables is offset before being written to TTBR1.
This means that we can't use PTRS_PER_PGD to iterate over kernel page tables unless we apply the same offset, which is fiddly to get right and leads to some non-idiomatic walking code. Instead, just follow the usual pattern when walking page tables by using a while loop driven by pXd_offset() and pXd_addr_end().
--- arch/arm64/mm/dump.c | 59 ++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 30 deletions(-)
arch/arm64/mm/dump.c +29 -30
@@ -286,74 +286,73 @@ static void note_page(struct pg_state *st, unsigned long addr, unsigned level, } -static void walk_pte (struct pg_state *st,pmd_t *pmdp,unsigned long start) +static void walk_pte (struct pg_state *st,pmd_t *pmdp,unsigned long start, +unsigned long end) { -pte_t *ptep =pte_offset_kernel (pmdp,0UL ); -unsigned long addr; -unsigned i; +unsigned long addr = start; +pte_t *ptep =pte_offset_kernel (pmdp, start); -for (i =0 ; i <PTRS_PER_PTE ; i++, ptep++) { - addr = start + i *PAGE_SIZE ; +do {note_page (st, addr,4 ,READ_ONCE (pte_val (*ptep))); - } + }while (ptep++, addr +=PAGE_SIZE , addr != end); } -static void walk_pmd (struct pg_state *st,pud_t *pudp,unsigned long start) +static void walk_pmd (struct pg_state *st,pud_t *pudp,unsigned long start, +unsigned long end) { -pmd_t *pmdp =pmd_offset (pudp,0UL ); -unsigned long addr; -unsigned i; +unsigned long next, addr = start; +pmd_t *pmdp =pmd_offset (pudp, start); -for (i =0 ; i <PTRS_PER_PMD ; i++, pmdp++) { +do {pmd_t pmd =READ_ONCE (*pmdp); + next =pmd_addr_end (addr, end); - addr = start + i *PMD_SIZE ;if (pmd_none (pmd) ||pmd_sect (pmd)) {note_page (st, addr,3 ,pmd_val (pmd)); }else {BUG_ON (pmd_bad (pmd)); -walk_pte (st, pmdp, addr); +walk_pte (st, pmdp, addr, next); } - } + }while (pmdp++, addr = next, addr != end); } -static void walk_pud (struct pg_state *st,pgd_t *pgdp,unsigned long start) +static void walk_pud (struct pg_state *st,pgd_t *pgdp,unsigned long start, +unsigned long end) { -pud_t *pudp =pud_offset (pgdp,0UL ); -unsigned long addr; -unsigned i; +unsigned long next, addr = start; +pud_t *pudp =pud_offset (pgdp, start); -for (i =0 ; i <PTRS_PER_PUD ; i++, pudp++) { +do {pud_t pud =READ_ONCE (*pudp); + next =pud_addr_end (addr, end); - addr = start + i *PUD_SIZE ;if (pud_none (pud) ||pud_sect (pud)) {note_page (st, addr,2 ,pud_val (pud)); }else {BUG_ON (pud_bad (pud)); -walk_pmd (st, pudp, addr); +walk_pmd (st, pudp, addr, next); } - } + }while (pudp++, addr = next, addr != end); }static void walk_pgd (struct pg_state *st,struct mm_struct *mm,unsigned long start) { -pgd_t *pgdp =pgd_offset (mm,0UL ); -unsigned i; -unsigned long addr; +unsigned long end = (start <TASK_SIZE_64 ) ?TASK_SIZE_64 :0 ; +unsigned long next, addr = start; +pgd_t *pgdp =pgd_offset (mm, start); -for (i =0 ; i <PTRS_PER_PGD ; i++, pgdp++) { +do {pgd_t pgd =READ_ONCE (*pgdp); + next =pgd_addr_end (addr, end); - addr = start + i *PGDIR_SIZE ;if (pgd_none (pgd)) {note_page (st, addr,1 ,pgd_val (pgd)); }else {BUG_ON (pgd_bad (pgd)); -walk_pud (st, pgdp, addr); +walk_pud (st, pgdp, addr, next); } - } + }while (pgdp++, addr = next, addr != end); }void ptdump_walk_pgd (struct seq_file *m,struct ptdump_info *info)
Signature · 1 line
2.19.1
Re: [PATCH AUTOSEL 4.20 60/81] arm64: ptdump: Don't iterate kernel page tables using PTRS_PER_PXX
Quoted 22 lines · Sasha Levin
From: Will Deacon <[email protected]>
[ Upstream commit
d23c808c6fc6132e812690648e14c0d6b0cbe273]When 52-bit virtual addressing is enabled for userspace (
CONFIG_ARM64_USER_VA_BITS_52=y), the kernel continues to utilise 48-bit virtual addressing in TTBR1. Consequently,PTRS_PER_PGDreflects the larger page table size for userspace and the pgd pointer for kernel page tables is offset before being written to TTBR1.This means that we can't use
PTRS_PER_PGDto iterate over kernel page tables unless we apply the same offset, which is fiddly to get right and leads to some non-idiomatic walking code. Instead, just follow the usual pattern when walking page tables by using a while loop driven bypXd_offset()andpXd_addr_end().Reported-by Qian Cai <[email protected]>Tested-by Qian Cai <[email protected]>Acked-by Steve Capper <[email protected]>Tested-by Steve Capper <[email protected]>Signed-off-by Will Deacon <[email protected]>Signed-off-by Sasha Levin <[email protected]>
Quoted 3 lines
--- arch/arm64/mm/dump.c | 59 ++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 30 deletions(-)
4.20 doesn't support 52-bit VAs, so this isn't needed there afaict (and is why I didn't tag the commit for stable in the first place).
Will
Sasha Levin
maintainerPATCH 61/81 s390/qeth: release cmd buffer in error paths
In reply to Sasha LevinFrom: Julian Wiedmann <[email protected]>
[ Upstream commit 5065b2dd3e5f9247a6c9d67974bc0472bf561b9d ]
Whenever we fail before/while starting an IO, make sure to release the IO buffer. Usually qeth_irq() would do this for us, but if the IO doesn't even start we obviously won't get an interrupt for it either.
--- drivers/s390/net/qeth_core_main.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/s390/net/qeth_core_main.c +6 -0
@@ -568,6 +568,7 @@ static int __qeth_issue_next_read(struct qeth_card *card)QETH_DBF_MESSAGE (2 ,"error %i on device %x when starting next read ccw!\n" , rc,CARD_DEVID (card));atomic_set (&channel->irq_pending,0 ); +qeth_release_buffer (channel, iob); card->read_or_write_problem =1 ;qeth_schedule_recovery (card);wake_up (&card->wait_q);
@@ -1129,6 +1130,8 @@ static void qeth_irq(struct ccw_device *cdev, unsigned long intparm, rc =qeth_get_problem (card, cdev, irb);if (rc) { card->read_or_write_problem =1 ; +if (iob) +qeth_release_buffer (iob->channel, iob);qeth_clear_ipacmd_list (card);qeth_schedule_recovery (card); goto out;
@@ -1811,6 +1814,7 @@ static int qeth_idx_activate_get_answer(struct qeth_card *card,QETH_DBF_MESSAGE (2 ,"Error2 in activating channel rc=%d\n" , rc);QETH_DBF_TEXT_ (SETUP ,2 ,"2err%d" , rc);atomic_set (&channel->irq_pending,0 ); +qeth_release_buffer (channel, iob);wake_up (&card->wait_q);return rc; }
@@ -1880,6 +1884,7 @@ static int qeth_idx_activate_channel(struct qeth_card *card, rc);QETH_DBF_TEXT_ (SETUP ,2 ,"1err%d" , rc);atomic_set (&channel->irq_pending,0 ); +qeth_release_buffer (channel, iob);wake_up (&card->wait_q);return rc; }
@@ -2060,6 +2065,7 @@ int qeth_send_control_data(struct qeth_card *card, int len, } reply =qeth_alloc_reply (card);if (!reply) { +qeth_release_buffer (channel, iob);return -ENOMEM ; } reply->callback = reply_cb;
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 62/81 s390/qeth: fix use-after-free in error path
In reply to Sasha LevinFrom: Julian Wiedmann <[email protected]>
[ Upstream commit afa0c5904ba16d59b0454f7ee4c807dae350f432 ]
The error path in qeth_alloc_qdio_buffers() that takes care of cleaning up the Output Queues is buggy. It first frees the queue, but then calls qeth_clear_outq_buffers() with that very queue struct.
Make the call to qeth_clear_outq_buffers() part of the free action (in the correct order), and while at it fix the naming of the helper.
--- drivers/s390/net/qeth_core_main.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
drivers/s390/net/qeth_core_main.c +6 -9
@@ -2397,11 +2397,12 @@ static int qeth_init_qdio_out_buf(struct qeth_qdio_out_q *q, int bidx)return 0 ; } -static void qeth_free_qdio_out_buf (struct qeth_qdio_out_q *q) +static void qeth_free_output_queue (struct qeth_qdio_out_q *q) {if (!q)return ; +qeth_clear_outq_buffers (q,1 );qdio_free_buffers (q->qdio_bufs,QDIO_MAX_BUFFERS_PER_Q );kfree (q); }
@@ -2475,10 +2476,8 @@ static int qeth_alloc_qdio_buffers(struct qeth_card *card) card->qdio.out_qs[i]->bufs[j] =NULL ; } out_freeoutq: -while (i >0 ) { -qeth_free_qdio_out_buf (card->qdio.out_qs[--i]); -qeth_clear_outq_buffers (card->qdio.out_qs[i],1 ); - } +while (i >0 ) +qeth_free_output_queue (card->qdio.out_qs[--i]);kfree (card->qdio.out_qs); card->qdio.out_qs =NULL ; out_freepool:
@@ -2511,10 +2510,8 @@ static void qeth_free_qdio_buffers(struct qeth_card *card)qeth_free_buffer_pool (card);/* free outbound qdio_qs */ if (card->qdio.out_qs) { -for (i =0 ; i < card->qdio.no_out_queues; ++i) { -qeth_clear_outq_buffers (card->qdio.out_qs[i],1 ); -qeth_free_qdio_out_buf (card->qdio.out_qs[i]); - } +for (i =0 ; i < card->qdio.no_out_queues; i++) +qeth_free_output_queue (card->qdio.out_qs[i]);kfree (card->qdio.out_qs); card->qdio.out_qs =NULL ; }
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 63/81 s390/qeth: cancel close_dev work before removing a card
In reply to Sasha LevinFrom: Julian Wiedmann <[email protected]>
[ Upstream commit c2780c1a3fb724560b1d44f7976e0de17bf153c7 ]
A card's close_dev work is scheduled on a driver-wide workqueue. If the card is removed and freed while the work is still active, this causes a use-after-free.
So make sure that the work is completed before freeing the card.
--- drivers/s390/net/qeth_core.h | 1 + drivers/s390/net/qeth_l2_main.c | 2 ++ drivers/s390/net/qeth_l3_main.c | 1 + 3 files changed, 4 insertions(+)
drivers/s390/net/qeth_core.h +1 -0
@@ -22,6 +22,7 @@#include <linux/hashtable.h> #include <linux/ip.h> #include <linux/refcount.h> +#include <linux/workqueue.h> #include <net/ipv6.h> #include <net/if_inet6.h>
drivers/s390/net/qeth_l2_main.c +2 -0
@@ -823,6 +823,8 @@ static void qeth_l2_remove_device(struct ccwgroup_device *cgdev)if (cgdev->state ==CCWGROUP_ONLINE )qeth_l2_set_offline (cgdev); + +cancel_work_sync (&card->close_dev_work);if (qeth_netdev_is_registered (card->dev))unregister_netdev (card->dev); }
drivers/s390/net/qeth_l3_main.c +1 -0
@@ -2428,6 +2428,7 @@ static void qeth_l3_remove_device(struct ccwgroup_device *cgdev)if (cgdev->state ==CCWGROUP_ONLINE )qeth_l3_set_offline (cgdev); +cancel_work_sync (&card->close_dev_work);if (qeth_netdev_is_registered (card->dev))unregister_netdev (card->dev);qeth_l3_clear_ip_htable (card,0 );
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 64/81 s390/qeth: conclude all event processing before offlining a card
In reply to Sasha LevinFrom: Julian Wiedmann <[email protected]>
[ Upstream commit c0a2e4d10d9366ada133a8ae4ff2f32397f8b15b ]
Work for Bridgeport events is currently placed on a driver-wide workqueue. If the card is removed and freed while any such work is still active, this causes a use-after-free.
So put the events on a per-card queue, where we can control their lifetime. As we also don't want stale events to last beyond an offline & online cycle, flush this queue when setting the card offline.
--- drivers/s390/net/qeth_core.h | 2 +- drivers/s390/net/qeth_core_main.c | 10 ++++++++-- drivers/s390/net/qeth_l2_main.c | 6 ++++-- drivers/s390/net/qeth_l3_main.c | 2 ++ 4 files changed, 15 insertions(+), 5 deletions(-)
drivers/s390/net/qeth_core.h +1 -1
@@ -791,6 +791,7 @@ struct qeth_card {struct qeth_seqno seqno;struct qeth_card_options options; +struct workqueue_struct *event_wq;wait_queue_head_t wait_q;spinlock_t mclock;unsigned long active_vlans[BITS_TO_LONGS (VLAN_N_VID )];
@@ -969,7 +970,6 @@ extern const struct attribute_group *qeth_osn_attr_groups[];extern const struct attribute_group qeth_device_attr_group;extern const struct attribute_group qeth_device_blkt_group;extern const struct device_type qeth_generic_devtype; -extern struct workqueue_struct *qeth_wq;int qeth_card_hw_is_reachable (struct qeth_card *);const char *qeth_get_cardname_short (struct qeth_card *);
drivers/s390/net/qeth_core_main.c +8 -2
@@ -76,8 +76,7 @@ static void qeth_notify_skbs(struct qeth_qdio_out_q *queue,static void qeth_release_skbs (struct qeth_qdio_out_buffer *buf);static int qeth_init_qdio_out_buf (struct qeth_qdio_out_q *,int ); -struct workqueue_struct *qeth_wq; -EXPORT_SYMBOL_GPL (qeth_wq); +static struct workqueue_struct *qeth_wq;int qeth_card_hw_is_reachable (struct qeth_card *card) {
@@ -1471,6 +1470,10 @@ static struct qeth_card *qeth_alloc_card(struct ccwgroup_device *gdev)CARD_RDEV (card) = gdev->cdev[0 ];CARD_WDEV (card) = gdev->cdev[1 ];CARD_DDEV (card) = gdev->cdev[2 ]; + + card->event_wq =alloc_ordered_workqueue ("%s" ,0 ,dev_name (&gdev->dev)); +if (!card->event_wq) + goto out_wq;if (qeth_setup_channel (&card->read, true)) goto out_ip;if (qeth_setup_channel (&card->write, true))
@@ -1486,6 +1489,8 @@ static struct qeth_card *qeth_alloc_card(struct ccwgroup_device *gdev) out_channel:qeth_clean_channel (&card->read); out_ip: +destroy_workqueue (card->event_wq); +out_wq:dev_set_drvdata (&gdev->dev,NULL );kfree (card); out:
@@ -5038,6 +5043,7 @@ static void qeth_core_free_card(struct qeth_card *card)qeth_clean_channel (&card->read);qeth_clean_channel (&card->write);qeth_clean_channel (&card->data); +destroy_workqueue (card->event_wq);qeth_free_qdio_buffers (card);unregister_service_level (&card->qeth_service_level);dev_set_drvdata (&card->gdev->dev,NULL );
drivers/s390/net/qeth_l2_main.c +4 -2
@@ -391,6 +391,8 @@ static void qeth_l2_stop_card(struct qeth_card *card, int recovery_mode)qeth_clear_cmd_buffers (&card->read);qeth_clear_cmd_buffers (&card->write); } + +flush_workqueue (card->event_wq); } static int qeth_l2_process_inbound_buffer(struct qeth_card *card,
@@ -1455,7 +1457,7 @@ static void qeth_bridge_state_change(struct qeth_card *card, data->card = card;memcpy (&data->qports, qports,sizeof (struct qeth_sbp_state_change ) + extrasize); -queue_work (qeth_wq, &data->worker); +queue_work (card->event_wq, &data->worker); }struct qeth_bridge_host_data {
@@ -1527,7 +1529,7 @@ static void qeth_bridge_host_event(struct qeth_card *card, data->card = card;memcpy (&data->hostevs, hostevs,sizeof (struct qeth_ipacmd_addr_change ) + extrasize); -queue_work (qeth_wq, &data->worker); +queue_work (card->event_wq, &data->worker); }/* SETBRIDGEPORT support; sending commands */
drivers/s390/net/qeth_l3_main.c +2 -0
@@ -1436,6 +1436,8 @@ static void qeth_l3_stop_card(struct qeth_card *card, int recovery_mode)qeth_clear_cmd_buffers (&card->read);qeth_clear_cmd_buffers (&card->write); } + +flush_workqueue (card->event_wq); }/*
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 65/81 perf symbols: Filter out hidden symbols from labels
In reply to Sasha LevinFrom: Jiri Olsa <[email protected]>
[ Upstream commit 59a17706915fe5ea6f711e1f92d4fb706bce07fe ]
When perf is built with the annobin plugin (RHEL8 build) extra symbols are added to its binary:
# nm perf | grep annobin | head -10 0000000000241100 t .annobin_annotate.c 0000000000326490 t .annobin_annotate.c 0000000000249255 t .annobin_annotate.c_end 00000000003283a8 t .annobin_annotate.c_end 00000000001bce18 t .annobin_annotate.c_end.hot 00000000001bce18 t .annobin_annotate.c_end.hot 00000000001bc3e2 t .annobin_annotate.c_end.unlikely 00000000001bc400 t .annobin_annotate.c_end.unlikely 00000000001bce18 t .annobin_annotate.c.hot 00000000001bce18 t .annobin_annotate.c.hot ...
Those symbols have no use for report or annotation and should be skipped. Moreover they interfere with the DWARF unwind test on the PPC arch, where they are mixed with checked symbols and then the test fails:
# perf test dwarf -v 59: Test dwarf unwind : --- start --- test child forked, pid 8515 unwind: .annobin_dwarf_unwind.c:ip = 0x10dba40dc (0x2740dc) ... got: .annobin_dwarf_unwind.c 0x10dba40dc, expecting test__arch_unwind_sample unwind: failed with 'no error'
The annobin symbols are defined as NOTYPE/LOCAL/HIDDEN:
# readelf -s ./perf | grep annobin | head -1
40: 00000000001bce4f 0 NOTYPE LOCAL HIDDEN 13 .annobin_init.cThey can still pass the check for the label symbol. Adding check for HIDDEN and INTERNAL (as suggested by Nick below) visibility and filter out such symbols.
Quoted 4 lines
Just to be awkward, if you are going to ignore
STV_HIDDENsymbols then you should probably also ignoreSTV_INTERNALones as well... Annobin does not generate them, but you never know, one day some other tool might create some.
--- tools/perf/util/symbol-elf.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
tools/perf/util/symbol-elf.c +8 -1
@@ -87,6 +87,11 @@ static inline uint8_t elf_sym__type(const GElf_Sym *sym)return GELF_ST_TYPE (sym->st_info); } +static inline uint8_t elf_sym__visibility (const GElf_Sym *sym) +{ +return GELF_ST_VISIBILITY (sym->st_other); +} +#ifndef STT_GNU_IFUNC #define STT_GNU_IFUNC 10#endif
@@ -111,7 +116,9 @@ static inline int elf_sym__is_label(const GElf_Sym *sym)return elf_sym__type (sym) ==STT_NOTYPE && sym->st_name !=0 && sym->st_shndx !=SHN_UNDEF && - sym->st_shndx !=SHN_ABS ; + sym->st_shndx !=SHN_ABS && +elf_sym__visibility (sym) !=STV_HIDDEN && +elf_sym__visibility (sym) !=STV_INTERNAL ; }static bool elf_sym__filter (GElf_Sym *sym)
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 66/81 perf trace: Support multiple "vfs_getname" probes
In reply to Sasha LevinFrom: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit 6ab3bc240ade47a0f52bc16d97edd9accbe0024e ]
With a suitably defined "probe:vfs_getname" probe, 'perf trace' can "beautify" its output, so syscalls like open() or openat() can print the "filename" argument instead of just its hex address, like:
$ perf trace -e open -- touch /dev/null
[...]
0.590 ( 0.014 ms): touch/18063 open(filename: /dev/null, flags: CREAT|NOCTTY|NONBLOCK|WRONLY, mode: IRUGO|IWUGO) = 3
[...]The output without such beautifier looks like:
0.529 ( 0.011 ms): touch/18075 open(filename: 0xc78cf288, flags: CREAT|NOCTTY|NONBLOCK|WRONLY, mode: IRUGO|IWUGO) = 3
However, when the vfs_getname probe expands to multiple probes and it is not the first one that is hit, the beautifier fails, as following:
0.326 ( 0.010 ms): touch/18072 open(filename: , flags: CREAT|NOCTTY|NONBLOCK|WRONLY, mode: IRUGO|IWUGO) = 3
Fix it by hooking into all the expanded probes (inlines), now, for instance:
[root@quaco ~]# perf probe -l
probe:vfs_getname (on getname_flags:73@fs/namei.c with pathname)
probe:vfs_getname_1 (on getname_flags:73@fs/namei.c with pathname)
[root@quaco ~]# perf trace -e open* sleep 1
0.010 ( 0.005 ms): sleep/5588 openat(dfd: CWD, filename: /etc/ld.so.cache, flags: RDONLY|CLOEXEC) = 3
0.029 ( 0.006 ms): sleep/5588 openat(dfd: CWD, filename: /lib64/libc.so.6, flags: RDONLY|CLOEXEC) = 3
0.194 ( 0.008 ms): sleep/5588 openat(dfd: CWD, filename: /usr/lib/locale/locale-archive, flags: RDONLY|CLOEXEC) = 3[root@quaco ~]#
Works, further verified with:
[root@quaco ~]# perf test vfs
65: Use vfs_getname probe to get syscall args filenames : Ok
66: Add vfs_getname probe to get syscall args filenames : Ok
67: Check open filename arg using perf trace + vfs_getname: Ok [root@quaco ~]#
--- tools/perf/builtin-trace.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-)
tools/perf/builtin-trace.c +18 -7
@@ -2424,19 +2424,30 @@ static size_t trace__fprintf_thread_summary(struct trace *trace, FILE *fp);static bool perf_evlist__add_vfs_getname (struct perf_evlist *evlist) { -struct perf_evsel *evsel =perf_evsel__newtp ("probe" ,"vfs_getname" ); +bool found = false; +struct perf_evsel *evsel, *tmp; +struct parse_events_error err = { .idx =0 , }; +int ret =parse_events (evlist,"probe:vfs_getname*" , &err); -if (IS_ERR (evsel)) +if (ret)return false; -if (perf_evsel__field (evsel,"pathname" ) ==NULL ) { +evlist__for_each_entry_safe (evlist, evsel, tmp) { +if (!strstarts (perf_evsel__name (evsel),"probe:vfs_getname" )) +continue ; + +if (perf_evsel__field (evsel,"pathname" )) { + evsel->handler = trace__vfs_getname; + found = true; +continue ; + } + +list_del_init (&evsel->node); + evsel->evlist =NULL ;perf_evsel__delete (evsel); -return false; } - evsel->handler = trace__vfs_getname; -perf_evlist__add (evlist, evsel); -return true; +return found; }static struct perf_evsel *perf_evsel__new_pgfault (u64 config)
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 67/81 MIPS: Loongson: Introduce and use loongson_llsc_mb()
In reply to Sasha LevinFrom: Huacai Chen <[email protected]>
[ Upstream commit e02e07e3127d8aec1f4bcdfb2fc52a2d99b4859e ]
On the Loongson-2G/2H/3A/3B there is a hardware flaw that ll/sc and lld/scd is very weak ordering. We should add sync instructions "before each ll/lld" and "at the branch-target between ll/sc" to workaround. Otherwise, this flaw will cause deadlock occasionally (e.g. when doing heavy load test with LTP).
Below is the explaination of CPU designer:
"For Loongson 3 family, when a memory access instruction (load, store, or prefetch)'s executing occurs between the execution of LL and SC, the success or failure of SC is not predictable. Although programmer would not insert memory access instructions between LL and SC, the memory instructions before LL in program-order, may dynamically executed between the execution of LL/SC, so a memory fence (SYNC) is needed before LL/LLD to avoid this situation.
Since Loongson-3A R2 (3A2000), we have improved our hardware design to handle this case. But we later deduce a rarely circumstance that some speculatively executed memory instructions due to branch misprediction between LL/SC still fall into the above case, so a memory fence (SYNC) at branch-target (if its target is not between LL/SC) is needed for Loongson 3A1000, 3B1500, 3A2000 and 3A3000.
Our processor is continually evolving and we aim to to remove all these workaround-SYNCs around LL/SC for new-come processor."
Here is an example:
Both cpu1 and cpu2 simutaneously run atomic_add by 1 on same atomic var, this bug cause both 'sc' run by two cpus (in atomic_add) succeed at same time('sc' return 1), and the variable is only *added by 1*, sometimes, which is wrong and unacceptable(it should be added by 2).
Why disable fix-loongson3-llsc in compiler?
Because compiler fix will cause problems in kernel's __ex_table section.
This patch fix all the cases in kernel, but:
+. the fix at the end of futex_atomic_cmpxchg_inatomic is for branch-target of 'bne', there other cases which smp_mb__before_llsc() and smp_llsc_mb() fix the ll and branch-target coincidently such as atomic_sub_if_positive/ cmpxchg/xchg, just like this one.
+. Loongson 3 does support CONFIG_EDAC_ATOMIC_SCRUB, so no need to touch edac.h
+. local_ops and cmpxchg_local should not be affected by this bug since only the owner can write.
+. mips_atomic_set for syscall.c is deprecated and rarely used, just let it go
[[email protected]:
- Simplify the addition of -mno-fix-loongson3-llsc to cflags, and add a comment describing why it's there.
- Make loongson_llsc_mb() a no-op when CONFIG_CPU_LOONGSON3_WORKAROUNDS=n, rather than a compiler memory barrier.
- Add a comment describing the bug & how loongson_llsc_mb() helps in asm/barrier.h.]
--- arch/mips/Kconfig | 15 ++++++++++++++ arch/mips/include/asm/atomic.h | 6 ++++++ arch/mips/include/asm/barrier.h | 36 +++++++++++++++++++++++++++++++++ arch/mips/include/asm/bitops.h | 5 +++++ arch/mips/include/asm/futex.h | 3 +++ arch/mips/include/asm/pgtable.h | 2 ++ arch/mips/loongson64/Platform | 23 +++++++++++++++++++++ arch/mips/mm/tlbex.c | 10 +++++++++ 8 files changed, 100 insertions(+)
arch/mips/Kconfig +15 -0
@@ -1400,6 +1400,21 @@ config LOONGSON3_ENHANCEMENT please say 'N' here. If you want a high-performance kernel to run on new Loongson 3 machines only, please say 'Y' here. +config CPU_LOONGSON3_WORKAROUNDS + bool "Old Loongson 3 LLSC Workarounds" + default y if SMP + depends on CPU_LOONGSON3 + help + Loongson 3 processors have the llsc issues which require workarounds. + Without workarounds the system may hang unexpectedly. + + Newer Loongson 3 will fix these issues and no workarounds are needed. + The workarounds have no significant side effect on them but may + decrease the performance of the system so this option should be + disabled unless the kernel is intended to be run on old systems. + + If unsure, please say Y. + config CPU_LOONGSON2E bool "Loongson 2E" depends on SYS_HAS_CPU_LOONGSON2E
arch/mips/include/asm/atomic.h +6 -0
@@ -58,6 +58,7 @@ static __inline__ void atomic_##op(int i, atomic_t * v) \if (kernel_uses_llsc) { \int temp; \ \ +loongson_llsc_mb (); \ __asm__ __volatile__( \ " .set "MIPS_ISA_LEVEL" \n" \ "1: ll %0, %1 # atomic_" #op " \n" \
@@ -84,6 +85,7 @@ static __inline__ int atomic_##op##_return_relaxed(int i, atomic_t * v) \if (kernel_uses_llsc) { \int temp; \ \ +loongson_llsc_mb (); \ __asm__ __volatile__( \ " .set "MIPS_ISA_LEVEL" \n" \ "1: ll %1, %2 # atomic_" #op "_return \n" \
@@ -116,6 +118,7 @@ static __inline__ int atomic_fetch_##op##_relaxed(int i, atomic_t * v) \if (kernel_uses_llsc) { \int temp; \ \ +loongson_llsc_mb (); \ __asm__ __volatile__( \ " .set "MIPS_ISA_LEVEL" \n" \ "1: ll %1, %2 # atomic_fetch_" #op " \n" \
@@ -251,6 +254,7 @@ static __inline__ void atomic64_##op(long i, atomic64_t * v) \if (kernel_uses_llsc) { \long temp; \ \ +loongson_llsc_mb (); \ __asm__ __volatile__( \ " .set "MIPS_ISA_LEVEL" \n" \ "1: lld %0, %1 # atomic64_" #op " \n" \
@@ -277,6 +281,7 @@ static __inline__ long atomic64_##op##_return_relaxed(long i, atomic64_t * v) \if (kernel_uses_llsc) { \long temp; \ \ +loongson_llsc_mb (); \ __asm__ __volatile__( \ " .set "MIPS_ISA_LEVEL" \n" \ "1: lld %1, %2 # atomic64_" #op "_return\n" \
@@ -309,6 +314,7 @@ static __inline__ long atomic64_fetch_##op##_relaxed(long i, atomic64_t * v) \if (kernel_uses_llsc) { \long temp; \ \ +loongson_llsc_mb (); \ __asm__ __volatile__( \ " .set "MIPS_ISA_LEVEL" \n" \ "1: lld %1, %2 # atomic64_fetch_" #op "\n" \
arch/mips/include/asm/barrier.h +36 -0
@@ -222,6 +222,42 @@#define __smp_mb__before_atomic () __smp_mb__before_llsc()#define __smp_mb__after_atomic () smp_llsc_mb() +/* +* Some Loongson 3 CPUs have a bug wherein execution of a memory access (load, +* store or pref) in between an ll & sc can cause the sc instruction to +* erroneously succeed, breaking atomicity. Whilst it's unusual to write code +* containing such sequences, this bug bites harder than we might otherwise +* expect due to reordering & speculation: +* +* 1) A memory access appearing prior to the ll in program order may actually +* be executed after the ll - this is the reordering case. +* +* In order to avoid this we need to place a memory barrier (ie. a sync +* instruction) prior to every ll instruction, in between it & any earlier +* memory access instructions. Many of these cases are already covered by +* smp_mb__before_llsc() but for the remaining cases, typically ones in +* which multiple CPUs may operate on a memory location but ordering is not +* usually guaranteed, we use loongson_llsc_mb() below. +* +* This reordering case is fixed by 3A R2 CPUs, ie. 3A2000 models and later. +* +* 2) If a conditional branch exists between an ll & sc with a target outside +* of the ll-sc loop, for example an exit upon value mismatch in cmpxchg() +* or similar, then misprediction of the branch may allow speculative +* execution of memory accesses from outside of the ll-sc loop. +* +* In order to avoid this we need a memory barrier (ie. a sync instruction) +* at each affected branch target, for which we also use loongson_llsc_mb() +* defined below. +* +* This case affects all current Loongson 3 CPUs. +*/ +#ifdef CONFIG_CPU_LOONGSON3_WORKAROUNDS /* Loongson-3's LLSC workaround */ +#define loongson_llsc_mb () __asm__ __volatile__(__WEAK_LLSC_MB : : :"memory") +#else +#define loongson_llsc_mb () do { } while (0) +#endif +#include <asm-generic/barrier.h> #endif /* __ASM_BARRIER_H */
arch/mips/include/asm/bitops.h +5 -0
@@ -68,6 +68,7 @@ static inline void set_bit(unsigned long nr, volatile unsigned long *addr) : "ir" (1UL << bit), GCC_OFF_SMALL_ASM() (*m)); #if defined(CONFIG_CPU_MIPSR2) || defined(CONFIG_CPU_MIPSR6) }else if (kernel_uses_llsc &&__builtin_constant_p (bit)) { +loongson_llsc_mb (); do { __asm__ __volatile__( " " __LL "%0, %1 # set_bit \n"
@@ -78,6 +79,7 @@ static inline void set_bit(unsigned long nr, volatile unsigned long *addr) } while (unlikely(!temp));#endif /* CONFIG_CPU_MIPSR2 || CONFIG_CPU_MIPSR6 */ }else if (kernel_uses_llsc) { +loongson_llsc_mb (); do { __asm__ __volatile__( " .set "MIPS_ISA_ARCH_LEVEL" \n"
@@ -120,6 +122,7 @@ static inline void clear_bit(unsigned long nr, volatile unsigned long *addr) : "ir" (~(1UL << bit))); #if defined(CONFIG_CPU_MIPSR2) || defined(CONFIG_CPU_MIPSR6) }else if (kernel_uses_llsc &&__builtin_constant_p (bit)) { +loongson_llsc_mb (); do { __asm__ __volatile__( " " __LL "%0, %1 # clear_bit \n"
@@ -130,6 +133,7 @@ static inline void clear_bit(unsigned long nr, volatile unsigned long *addr) } while (unlikely(!temp));#endif /* CONFIG_CPU_MIPSR2 || CONFIG_CPU_MIPSR6 */ }else if (kernel_uses_llsc) { +loongson_llsc_mb (); do { __asm__ __volatile__( " .set "MIPS_ISA_ARCH_LEVEL" \n"
@@ -188,6 +192,7 @@ static inline void change_bit(unsigned long nr, volatile unsigned long *addr)unsigned long *m = ((unsigned long *) addr) + (nr >>SZLONG_LOG );unsigned long temp; +loongson_llsc_mb (); do { __asm__ __volatile__( " .set "MIPS_ISA_ARCH_LEVEL" \n"
arch/mips/include/asm/futex.h +3 -0
@@ -50,6 +50,7 @@ "i" (-EFAULT) \ : "memory"); \ } else if (cpu_has_llsc) { \ + loongson_llsc_mb(); \ __asm__ __volatile__( \ " .set push \n" \ " .set noat \n" \
@@ -162,6 +163,7 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr, "i" (-EFAULT) : "memory"); }else if (cpu_has_llsc) { +loongson_llsc_mb (); __asm__ __volatile__("# futex_atomic_cmpxchg_inatomic \n" " .set push \n"
@@ -190,6 +192,7 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr, : GCC_OFF_SMALL_ASM() (*uaddr), "Jr" (oldval), "Jr" (newval), "i" (-EFAULT) : "memory"); +loongson_llsc_mb (); }else return -ENOSYS ;
arch/mips/include/asm/pgtable.h +2 -0
@@ -229,6 +229,7 @@ static inline void set_pte(pte_t *ptep, pte_t pteval) : [buddy] "+m" (buddy->pte), [tmp] "=&r" (tmp) : [global] "r" (page_global)); } else if (kernel_uses_llsc) { +loongson_llsc_mb (); __asm__ __volatile__ (" .set " MIPS_ISA_ARCH_LEVEL " \n" " .set push \n"
@@ -244,6 +245,7 @@ static inline void set_pte(pte_t *ptep, pte_t pteval)" .set mips0 \n" : [buddy] "+m" (buddy->pte), [tmp] "=&r" (tmp) : [global] "r" (page_global)); + loongson_llsc_mb(); }#else /* !CONFIG_SMP */ if (pte_none (*buddy))
arch/mips/loongson64/Platform +23 -0
@@ -23,6 +23,29 @@ ifdef CONFIG_CPU_LOONGSON2F_WORKAROUNDS endif cflags-$(CONFIG_CPU_LOONGSON3) += -Wa,--trap + +# +# Some versions of binutils, not currently mainline as of 2019/02/04, support +# an -mfix-loongson3-llsc flag which emits a sync prior to each ll instruction +# to work around a CPU bug (see loongson_llsc_mb() in asm/barrier.h for a +# description). +# +# We disable this in order to prevent the assembler meddling with the +# instruction that labels refer to, ie. if we label an ll instruction: +# +# 1: ll v0, 0(a0) +# +# ...then with the assembler fix applied the label may actually point at a sync +# instruction inserted by the assembler, and if we were using the label in an +# exception table the table would no longer contain the address of the ll +# instruction. +# +# Avoid this by explicitly disabling that assembler behaviour. If upstream +# binutils does not merge support for the flag then we can revisit & remove +# this later - for now it ensures vendor toolchains don't cause problems. +# +cflags-$(CONFIG_CPU_LOONGSON3) += $(call as-option,-Wa$(comma)-mno-fix-loongson3-llsc,) + # # binutils from v2.25 on and gcc starting from v4.9.0 treat -march=loongson3a # as MIPS64 R2; older versions as just R1. This leaves the possibility open
arch/mips/mm/tlbex.c +10 -0
@@ -931,6 +931,8 @@ build_get_pgd_vmalloc64(u32 **p, struct uasm_label **l, struct uasm_reloc **r,* to mimic that here by taking a load/istream page * fault. */ +if (IS_ENABLED (CONFIG_CPU_LOONGSON3_WORKAROUNDS )) +uasm_i_sync (p,0 );UASM_i_LA (p, ptr, (unsigned long )tlb_do_page_fault_0);uasm_i_jr (p, ptr);
@@ -1645,6 +1647,8 @@ static void iPTE_LW(u32 **p, unsigned int pte, unsigned int ptr) {#ifdef CONFIG_SMP +if (IS_ENABLED (CONFIG_CPU_LOONGSON3_WORKAROUNDS )) +uasm_i_sync (p,0 );# ifdef CONFIG_PHYS_ADDR_T_64BIT if (cpu_has_64bits)uasm_i_lld (p, pte,0 , ptr);
@@ -2258,6 +2262,8 @@ static void build_r4000_tlb_load_handler(void)#endif uasm_l_nopage_tlbl (&l, p); +if (IS_ENABLED (CONFIG_CPU_LOONGSON3_WORKAROUNDS )) +uasm_i_sync (&p,0 );build_restore_work_registers (&p);#ifdef CONFIG_CPU_MICROMIPS if ((unsigned long )tlb_do_page_fault_0 &1 ) {
@@ -2312,6 +2318,8 @@ static void build_r4000_tlb_store_handler(void)#endif uasm_l_nopage_tlbs (&l, p); +if (IS_ENABLED (CONFIG_CPU_LOONGSON3_WORKAROUNDS )) +uasm_i_sync (&p,0 );build_restore_work_registers (&p);#ifdef CONFIG_CPU_MICROMIPS if ((unsigned long )tlb_do_page_fault_1 &1 ) {
@@ -2367,6 +2375,8 @@ static void build_r4000_tlb_modify_handler(void)#endif uasm_l_nopage_tlbm (&l, p); +if (IS_ENABLED (CONFIG_CPU_LOONGSON3_WORKAROUNDS )) +uasm_i_sync (&p,0 );build_restore_work_registers (&p);#ifdef CONFIG_CPU_MICROMIPS if ((unsigned long )tlb_do_page_fault_1 &1 ) {
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 68/81 MIPS: Remove function size check in get_frame_info()
In reply to Sasha LevinFrom: Jun-Ru Chang <[email protected]>
[ Upstream commit 2b424cfc69728224fcb5fad138ea7260728e0901 ]
Patch (b6c7a324df37b "MIPS: Fix get_frame_info() handling of microMIPS function size.") introduces additional function size check for microMIPS by only checking insn between ip and ip + func_size. However, func_size in get_frame_info() is always 0 if KALLSYMS is not enabled. This causes get_frame_info() to return immediately without calculating correct frame_size, which in turn causes "Can't analyze schedule() prologue" warning messages at boot time.
This patch removes func_size check, and let the frame_size check run up to 128 insns for both MIPS and microMIPS.
--- arch/mips/kernel/process.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
arch/mips/kernel/process.c +3 -4
@@ -371,7 +371,7 @@ static inline int is_sp_move_ins(union mips_instruction *ip, int *frame_size)static int get_frame_info (struct mips_frame_info *info) {bool is_mmips =IS_ENABLED (CONFIG_CPU_MICROMIPS ); -union mips_instruction insn, *ip, *ip_end; +union mips_instruction insn, *ip;const unsigned int max_insns =128 ;unsigned int last_insn_size =0 ;unsigned int i;
@@ -384,10 +384,9 @@ static int get_frame_info(struct mips_frame_info *info)if (!ip) goto err; - ip_end = (void *)ip + info->func_size; - -for (i =0 ; i < max_insns && ip < ip_end; i++) { +for (i =0 ; i < max_insns; i++) { ip = (void *)ip + last_insn_size; +if (is_mmips &&mm_insn_16bit (ip->halfword[0 ])) { insn.word = ip->halfword[0 ] <<16 ; last_insn_size =2 ;
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 69/81 Revert "scsi: libfc: Add WARN_ON() when deleting rports"
In reply to Sasha LevinFrom: Ross Lagerwall <[email protected]>
[ Upstream commit d8f6382a7d026989029e2e50c515df954488459b ]
This reverts commit bbc0f8bd88abefb0f27998f40a073634a3a2db89.
It added a warning whose intent was to check whether the rport was still linked into the peer list. It doesn't work as intended and gives false positive warnings for two reasons:
1) If the rport is never linked into the peer list it will not be considered empty since the list_head is never initialized.
2) If the rport is deleted from the peer list using list_del_rcu(), then the list_head is in an undefined state and it is not considered empty.
--- drivers/scsi/libfc/fc_rport.c | 1 - 1 file changed, 1 deletion(-)
drivers/scsi/libfc/fc_rport.c +0 -1
@@ -184,7 +184,6 @@ void fc_rport_destroy(struct kref *kref)struct fc_rport_priv *rdata; rdata = container_of(kref, struct fc_rport_priv, kref); -WARN_ON (!list_empty (&rdata->peers));kfree_rcu (rdata, rcu); }EXPORT_SYMBOL (fc_rport_destroy);
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 70/81 i2c: omap: Use noirq system sleep pm ops to idle device for suspend
In reply to Sasha LevinFrom: Tony Lindgren <[email protected]>
[ Upstream commit c6e2bd956936d925748581e4d0294f10f1d92f2c ]
We currently get the following error with pixcir_ts driver during a suspend resume cycle:
omap_i2c 4802a000.i2c: controller timed outpixcir_ts 1-005c: pixcir_int_enable: can't read reg 0x34 : -110 pixcir_ts 1-005c: Failed to disable interrupt generation: -110 pixcir_ts 1-005c: Failed to stopdpm_run_callback(): pixcir_i2c_ts_resume+0x0/0x98 [pixcir_i2c_ts] returns -110
PM: Device 1-005c failed to resume: error -110
And at least am437x based devices with pixcir_ts will fail to resume to a touchscreen that is configured as the wakeup-source in device tree for these devices.
This is because pixcir_ts tries to reconfigure it's registers for noirq suspend which fails. This also leaves i2c-omap in enabled state for suspend.
Let's fix the pixcir_ts issue and make sure i2c-omap is suspended by adding SET_NOIRQ_SYSTEM_SLEEP_PM_OPS.
Let's also get rid of some ifdefs while at it and replace them with __maybe_unused as SET_RUNTIME_PM_OPS and SET_NOIRQ_SYSTEM_SLEEP_PM_OPS already deal with the various PM Kconfig options.
--- drivers/i2c/busses/i2c-omap.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/i2c/busses/i2c-omap.c +5 -8
@@ -1500,8 +1500,7 @@ static int omap_i2c_remove(struct platform_device *pdev)return 0 ; } -#ifdef CONFIG_PM -static int omap_i2c_runtime_suspend (struct device *dev) +static int __maybe_unused omap_i2c_runtime_suspend (struct device *dev) {struct omap_i2c_dev *omap =dev_get_drvdata (dev);
@@ -1527,7 +1526,7 @@ static int omap_i2c_runtime_suspend(struct device *dev)return 0 ; } -static int omap_i2c_runtime_resume (struct device *dev) +static int __maybe_unused omap_i2c_runtime_resume (struct device *dev) {struct omap_i2c_dev *omap =dev_get_drvdata (dev);
@@ -1542,20 +1541,18 @@ static int omap_i2c_runtime_resume(struct device *dev) }static const struct dev_pm_ops omap_i2c_pm_ops = { + SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, + pm_runtime_force_resume)SET_RUNTIME_PM_OPS (omap_i2c_runtime_suspend, omap_i2c_runtime_resume,NULL ) }; -#define OMAP_I2C_PM_OPS (&omap_i2c_pm_ops) -#else -#define OMAP_I2C_PM_OPS NULL -#endif /* CONFIG_PM */ static struct platform_driver omap_i2c_driver = { .probe = omap_i2c_probe, .remove = omap_i2c_remove, .driver = { .name ="omap_i2c" , - .pm =OMAP_I2C_PM_OPS , + .pm = &omap_i2c_pm_ops, .of_match_table =of_match_ptr (omap_i2c_of_match), }, };
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 71/81 drm/amdgpu: use spin_lock_irqsave to protect vm_manager.pasid_idr
In reply to Sasha LevinFrom: Philip Yang <[email protected]>
[ Upstream commit 0a5f49cbf9d6ad3721c16f8a6d823363ea7a160f ]
amdgpu_vm_get_task_info is called from interrupt handler and sched timeout workqueue, we should use irq version spin_lock to avoid deadlock.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +3 -2
@@ -3405,14 +3405,15 @@ void amdgpu_vm_get_task_info(struct amdgpu_device *adev, unsigned int pasid, struct amdgpu_task_info *task_info) {struct amdgpu_vm *vm; +unsigned long flags; -spin_lock (&adev->vm_manager.pasid_lock); +spin_lock_irqsave (&adev->vm_manager.pasid_lock, flags); vm =idr_find (&adev->vm_manager.pasid_idr, pasid);if (vm) *task_info = vm->task_info; -spin_unlock (&adev->vm_manager.pasid_lock); +spin_unlock_irqrestore (&adev->vm_manager.pasid_lock, flags); }/**
Signature · 6 lines
2.19.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 72/81 drm/omap: dsi: Fix crash in DSI debug dumps
In reply to Sasha LevinFrom: Tomi Valkeinen <[email protected]>
[ Upstream commit 4df04ac9b37f278c48bb696289aff8f81226af4b ]
Reading any of the DSI debugfs files results in a crash, as wrong pointer is passed to the dump functions, and the dump functions use a wrong pointer. This patch fixes DSI debug dumps.
--- drivers/gpu/drm/omapdrm/dss/dsi.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/omapdrm/dss/dsi.c +6 -6
@@ -1406,7 +1406,7 @@ static void dsi_pll_disable(struct dss_pll *pll)static int dsi_dump_dsi_clocks (struct seq_file *s,void *p) { -struct dsi_data *dsi = p; +struct dsi_data *dsi = s->private;struct dss_pll_clock_info *cinfo = &dsi->pll.cinfo;enum dss_clk_source dispc_clk_src, dsi_clk_src;int dsi_module = dsi->module_id;
@@ -1467,7 +1467,7 @@ static int dsi_dump_dsi_clocks(struct seq_file *s, void *p)#ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS static int dsi_dump_dsi_irqs (struct seq_file *s,void *p) { -struct dsi_data *dsi = p; +struct dsi_data *dsi = s->private;unsigned long flags;struct dsi_irq_stats stats;
@@ -1558,7 +1558,7 @@ static int dsi_dump_dsi_irqs(struct seq_file *s, void *p)static int dsi_dump_dsi_regs (struct seq_file *s,void *p) { -struct dsi_data *dsi = p; +struct dsi_data *dsi = s->private;if (dsi_runtime_get (dsi))return 0 ;
@@ -5083,15 +5083,15 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)snprintf (name,sizeof (name),"dsi%u_regs" , dsi->module_id +1 ); dsi->debugfs.regs =dss_debugfs_create_file (dss, name, - dsi_dump_dsi_regs, &dsi); + dsi_dump_dsi_regs, dsi);#ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS snprintf (name,sizeof (name),"dsi%u_irqs" , dsi->module_id +1 ); dsi->debugfs.irqs =dss_debugfs_create_file (dss, name, - dsi_dump_dsi_irqs, &dsi); + dsi_dump_dsi_irqs, dsi);#endif snprintf (name,sizeof (name),"dsi%u_clks" , dsi->module_id +1 ); dsi->debugfs.clks =dss_debugfs_create_file (dss, name, - dsi_dump_dsi_clocks, &dsi); + dsi_dump_dsi_clocks, dsi);return 0 ; }
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 73/81 drm/omap: dsi: Fix OF platform depopulate
In reply to Sasha LevinFrom: Tomi Valkeinen <[email protected]>
[ Upstream commit 0940c52742de0d2f70ba687bfd5fe8aa38c5f27d ]
Commit edb715dffdee ("drm/omap: dss: dsi: Move initialization code from bind to probe") moved the of_platform_populate() call from dsi_bind() to dsi_probe(), but failed to move the corresponding of_platform_depopulate() from dsi_unbind() to dsi_remove(). This results in OF child devices being potentially removed multiple times. Fix it by placing the of_platform_depopulate() call where it belongs.
--- drivers/gpu/drm/omapdrm/dss/dsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/omapdrm/dss/dsi.c +2 -2
@@ -5104,8 +5104,6 @@ static void dsi_unbind(struct device *dev, struct device *master, void *data)dss_debugfs_remove_file (dsi->debugfs.irqs);dss_debugfs_remove_file (dsi->debugfs.regs); -of_platform_depopulate (dev); -WARN_ON (dsi->scp_clk_refcount >0 );dss_pll_unregister (&dsi->pll);
@@ -5457,6 +5455,8 @@ static int dsi_remove(struct platform_device *pdev)dsi_uninit_output (dsi); +of_platform_depopulate (&pdev->dev); +pm_runtime_disable (&pdev->dev);if (dsi->vdds_dsi_reg !=NULL && dsi->vdds_dsi_enabled) {
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 74/81 drm/omap: dsi: Hack-fix DSI bus flags
In reply to Sasha LevinFrom: Tomi Valkeinen <[email protected]>
[ Upstream commit 6297388e1eddd2f1345cea5892156223995bcf2d ]
Since commit b4935e3a3cfa ("drm/omap: Store bus flags in the omap_dss_device structure") video mode flags are managed by the omapdss (and later omapdrm) core based on bus flags stored in omap_dss_device. This works fine for all devices whose video modes are set by the omapdss and omapdrm core, but breaks DSI operation as the DSI still uses legacy code paths and sets the DISPC timings manually.
To fix the problem properly we should move the DSI encoder to the new encoder model. This will however require a considerable amount of work. Restore DSI operation by adding back video mode flags handling in the DSI encoder driver as a hack in the meantime.
--- drivers/gpu/drm/omapdrm/dss/dsi.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/gpu/drm/omapdrm/dss/dsi.c +11 -0
@@ -4751,6 +4751,17 @@ static int dsi_set_config(struct omap_dss_device *dssdev, dsi->vm.flags |=DISPLAY_FLAGS_HSYNC_HIGH ; dsi->vm.flags &= ~DISPLAY_FLAGS_VSYNC_LOW ; dsi->vm.flags |=DISPLAY_FLAGS_VSYNC_HIGH ; +/* +* HACK: These flags should be handled through the omap_dss_device bus +* flags, but this will only be possible when the DSI encoder will be +* converted to the omapdrm-managed encoder model. +*/ + dsi->vm.flags &= ~DISPLAY_FLAGS_PIXDATA_NEGEDGE ; + dsi->vm.flags |=DISPLAY_FLAGS_PIXDATA_POSEDGE ; + dsi->vm.flags &= ~DISPLAY_FLAGS_DE_LOW ; + dsi->vm.flags |=DISPLAY_FLAGS_DE_HIGH ; + dsi->vm.flags &= ~DISPLAY_FLAGS_SYNC_POSEDGE ; + dsi->vm.flags |=DISPLAY_FLAGS_SYNC_NEGEDGE ;dss_mgr_set_timings (&dsi->output, &dsi->vm);
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 75/81 nvme: lock NS list changes while handling command effects
In reply to Sasha LevinFrom: Keith Busch <[email protected]>
[ Upstream commit e7ad43c3eda6a1690c4c3c341f95dc1c6898da83 ]
If a controller supports the NS Change Notification, the namespace scan_work is automatically triggered after attaching a new namespace.
Occasionally the namespace scan_work may append the new namespace to the list before the admin command effects handling is completed. The effects handling unfreezes namespaces, but if it unfreezes the newly attached namespace, its request_queue freeze depth will be off and we'll hit the warning in blk_mq_unfreeze_queue().
On the next namespace add, we will fail to freeze that queue due to the previous bad accounting and deadlock waiting for frozen.
Fix that by preventing scan work from altering the namespace list while command effects handling needs to pair freeze with unfreeze.
--- drivers/nvme/host/core.c | 8 +++++++- drivers/nvme/host/nvme.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-)
drivers/nvme/host/core.c +7 -1
@@ -1182,6 +1182,7 @@ static u32 nvme_passthru_start(struct nvme_ctrl *ctrl, struct nvme_ns *ns,* effects say only one namespace is affected. */ if (effects & (NVME_CMD_EFFECTS_LBCC |NVME_CMD_EFFECTS_CSE_MASK )) { +mutex_lock (&ctrl->scan_lock);nvme_start_freeze (ctrl);nvme_wait_freeze (ctrl); }
@@ -1210,8 +1211,10 @@ static void nvme_passthru_end(struct nvme_ctrl *ctrl, u32 effects)*/ if (effects &NVME_CMD_EFFECTS_LBCC )nvme_update_formats (ctrl); -if (effects & (NVME_CMD_EFFECTS_LBCC |NVME_CMD_EFFECTS_CSE_MASK )) +if (effects & (NVME_CMD_EFFECTS_LBCC |NVME_CMD_EFFECTS_CSE_MASK )) {nvme_unfreeze (ctrl); +mutex_unlock (&ctrl->scan_lock); + }if (effects &NVME_CMD_EFFECTS_CCC )nvme_init_identify (ctrl);if (effects & (NVME_CMD_EFFECTS_NIC |NVME_CMD_EFFECTS_NCC ))
@@ -3300,6 +3303,7 @@ static void nvme_scan_work(struct work_struct *work)if (nvme_identify_ctrl (ctrl, &id))return ; +mutex_lock (&ctrl->scan_lock); nn =le32_to_cpu (id->nn);if (ctrl->vs >=NVME_VS (1 ,1 ,0 ) && !(ctrl->quirks &NVME_QUIRK_IDENTIFY_CNS )) {
@@ -3308,6 +3312,7 @@ static void nvme_scan_work(struct work_struct *work) }nvme_scan_ns_sequential (ctrl, nn); out_free_id: +mutex_unlock (&ctrl->scan_lock);kfree (id);down_write (&ctrl->namespaces_rwsem);list_sort (NULL , &ctrl->namespaces, ns_cmp);
@@ -3550,6 +3555,7 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev, ctrl->state =NVME_CTRL_NEW ;spin_lock_init (&ctrl->lock); +mutex_init (&ctrl->scan_lock);INIT_LIST_HEAD (&ctrl->namespaces);init_rwsem (&ctrl->namespaces_rwsem); ctrl->dev = dev;
drivers/nvme/host/nvme.h +1 -0
@@ -153,6 +153,7 @@ struct nvme_ctrl {enum nvme_ctrl_state state;bool identified;spinlock_t lock; +struct mutex scan_lock;const struct nvme_ctrl_ops *ops;struct request_queue *admin_q;struct request_queue *connect_q;
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 76/81 nvme-pci: fix rapid add remove sequence
In reply to Sasha LevinFrom: Keith Busch <[email protected]>
[ Upstream commit 5c959d73dba6495ec01d04c206ee679d61ccb2b0 ]
A surprise removal may fail to tear down request queues if it is racing with the initial asynchronous probe. If that happens, the remove path won't see the queue resources to tear down, and the controller reset path may create a new request queue on a removed device, but will not be able to make forward progress, deadlocking the pci removal.
Protect setting up non-blocking resources from a shutdown by holding the same mutex, and transition to the CONNECTING state after these resources are initialized so the probe path may see the dead controller state before dispatching new IO.
--- drivers/nvme/host/pci.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
drivers/nvme/host/pci.c +12 -10
@@ -2280,16 +2280,7 @@ static void nvme_reset_work(struct work_struct *work)if (dev->ctrl.ctrl_config &NVME_CC_ENABLE )nvme_dev_disable (dev, false); -/* -* Introduce CONNECTING state from nvme-fc/rdma transports to mark the -* initializing procedure here. -*/ -if (!nvme_change_ctrl_state (&dev->ctrl,NVME_CTRL_CONNECTING )) { -dev_warn (dev->ctrl.device, -"failed to mark controller CONNECTING\n" ); - goto out; - } - +mutex_lock (&dev->shutdown_lock); result =nvme_pci_enable (dev);if (result) goto out;
@@ -2308,6 +2299,17 @@ static void nvme_reset_work(struct work_struct *work)*/ dev->ctrl.max_hw_sectors =NVME_MAX_KB_SZ <<1 ; dev->ctrl.max_segments =NVME_MAX_SEGS ; +mutex_unlock (&dev->shutdown_lock); + +/* +* Introduce CONNECTING state from nvme-fc/rdma transports to mark the +* initializing procedure here. +*/ +if (!nvme_change_ctrl_state (&dev->ctrl,NVME_CTRL_CONNECTING )) { +dev_warn (dev->ctrl.device, +"failed to mark controller CONNECTING\n" ); + goto out; + } result =nvme_init_identify (&dev->ctrl);if (result)
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 77/81 fs: ratelimit __find_get_block_slow() failure message.
In reply to Sasha LevinFrom: Tetsuo Handa <[email protected]>
[ Upstream commit 43636c804df0126da669c261fc820fb22f62bfc2 ]
When something let __find_get_block_slow() hit all_mapped path, it calls printk() for 100+ times per a second. But there is no need to print same message with such high frequency; it is just asking for stall warning, or at least bloating log files.
[ 399.866302][T15342] __find_get_block_slow() failed. block=1, b_blocknr=8 [ 399.873324][T15342] b_state=0x00000029, b_size=512 [ 399.878403][T15342] device loop0 blocksize: 4096 [ 399.883296][T15342] __find_get_block_slow() failed. block=1, b_blocknr=8 [ 399.890400][T15342] b_state=0x00000029, b_size=512 [ 399.895595][T15342] device loop0 blocksize: 4096 [ 399.900556][T15342] __find_get_block_slow() failed. block=1, b_blocknr=8 [ 399.907471][T15342] b_state=0x00000029, b_size=512 [ 399.912506][T15342] device loop0 blocksize: 4096
This patch reduces frequency to up to once per a second, in addition to concatenating three lines into one.
[ 399.866302][T15342] __find_get_block_slow() failed. block=1, b_blocknr=8, b_state=0x00000029, b_size=512, device loop0 blocksize: 4096
--- fs/buffer.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
fs/buffer.c +10 -9
@@ -200,6 +200,7 @@ __find_get_block_slow(struct block_device *bdev, sector_t block)struct buffer_head *head;struct page *page;int all_mapped =1 ; + static DEFINE_RATELIMIT_STATE(last_warned, HZ, 1); index = block >> (PAGE_SHIFT - bd_inode->i_blkbits); page =find_get_page_flags (bd_mapping, index,FGP_ACCESSED );
@@ -227,15 +228,15 @@ __find_get_block_slow(struct block_device *bdev, sector_t block)* file io on the block device and getblk. It gets dealt with * elsewhere, don't buffer_error if we had some unmapped buffers */ -if (all_mapped) { -printk ("__find_get_block_slow() failed. " -"block=%llu, b_blocknr=%llu\n" , - (unsigned long long )block, - (unsigned long long )bh->b_blocknr); -printk ("b_state=0x%08lx, b_size=%zu\n" , - bh->b_state, bh->b_size); -printk ("device %pg blocksize: %d\n" , bdev, -1 << bd_inode->i_blkbits); +ratelimit_set_flags (&last_warned,RATELIMIT_MSG_ON_RELEASE ); +if (all_mapped &&__ratelimit (&last_warned)) { +printk ("__find_get_block_slow() failed. block=%llu, " +"b_blocknr=%llu, b_state=0x%08lx, b_size=%zu, " +"device %pg blocksize: %d\n" , + (unsigned long long )block, + (unsigned long long )bh->b_blocknr, + bh->b_state, bh->b_size, bdev, +1 << bd_inode->i_blkbits); } out_unlock:spin_unlock (&bd_mapping->private_lock);
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 78/81 qed: Fix EQ full firmware assert.
In reply to Sasha LevinFrom: Manish Chopra <[email protected]>
[ Upstream commit 660492bcf4a7561b5fdc13be0ae0b0c0a8c120be ]
When slowpath messages are sent with high rate, the resulting events can lead to a FW assert in case they are not handled fast enough (Event Queue Full assert). Attempt to send queued slowpath messages only after the newly evacuated entries in the EQ ring are indicated to FW.
--- drivers/net/ethernet/qlogic/qed/qed_sp.h | 1 + drivers/net/ethernet/qlogic/qed/qed_spq.c | 15 +++++++-------- 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/net/ethernet/qlogic/qed/qed_sp.h +1 -0
@@ -380,6 +380,7 @@ void qed_consq_setup(struct qed_hwfn *p_hwfn);* @param p_hwfn */ void qed_consq_free (struct qed_hwfn *p_hwfn); +int qed_spq_pend_post (struct qed_hwfn *p_hwfn);/** * @file
drivers/net/ethernet/qlogic/qed/qed_spq.c +7 -8
@@ -402,6 +402,11 @@ int qed_eq_completion(struct qed_hwfn *p_hwfn, void *cookie)qed_eq_prod_update (p_hwfn,qed_chain_get_prod_idx (p_chain)); +/* Attempt to post pending requests */ +spin_lock_bh (&p_hwfn->p_spq->lock); + rc =qed_spq_pend_post (p_hwfn); +spin_unlock_bh (&p_hwfn->p_spq->lock); +return rc; }
@@ -744,7 +749,7 @@ static int qed_spq_post_list(struct qed_hwfn *p_hwfn,return 0 ; } -static int qed_spq_pend_post (struct qed_hwfn *p_hwfn) +int qed_spq_pend_post (struct qed_hwfn *p_hwfn) {struct qed_spq *p_spq = p_hwfn->p_spq;struct qed_spq_entry *p_ent =NULL ;
@@ -882,7 +887,6 @@ int qed_spq_completion(struct qed_hwfn *p_hwfn,struct qed_spq_entry *p_ent =NULL ;struct qed_spq_entry *tmp;struct qed_spq_entry *found =NULL ; -int rc;if (!p_hwfn)return -EINVAL ;
@@ -940,12 +944,7 @@ int qed_spq_completion(struct qed_hwfn *p_hwfn,*/ qed_spq_return_entry (p_hwfn, found); -/* Attempt to post pending requests */ -spin_lock_bh (&p_spq->lock); - rc =qed_spq_pend_post (p_hwfn); -spin_unlock_bh (&p_spq->lock); - -return rc; +return 0 ; }int qed_consq_alloc (struct qed_hwfn *p_hwfn)
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 79/81 qed: Consider TX tcs while deriving the max num_queues for PF.
In reply to Sasha LevinFrom: Sudarsana Reddy Kalluru <[email protected]>
[ Upstream commit fb1faab74ddef9ec2d841d54e5d0912a097b3abe ]
Max supported queues is derived incorrectly in the case of multi-CoS. Need to consider TCs while calculating num_queues for PF.
--- drivers/net/ethernet/qlogic/qed/qed_l2.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/qlogic/qed/qed_l2.c +3 -2
@@ -2207,7 +2207,7 @@ static int qed_fill_eth_dev_info(struct qed_dev *cdev,u16 num_queues =0 ;/* Since the feature controls only queue-zones, -* make sure we have the contexts [rx, tx, xdp] to +* make sure we have the contexts [rx, xdp, tcs] to * match. */ for_each_hwfn (cdev, i) {
@@ -2217,7 +2217,8 @@ static int qed_fill_eth_dev_info(struct qed_dev *cdev,u16 cids; cids = hwfn->pf_params.eth_pf_params.num_cons; - num_queues +=min_t (u16, l2_queues, cids /3 ); + cids /= (2 + info->num_tc); + num_queues +=min_t (u16, l2_queues, cids); }/* queues might theoretically be >256, but interrupts'
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 80/81 qede: Fix system crash on configuring channels.
In reply to Sasha LevinFrom: Sudarsana Reddy Kalluru <[email protected]>
[ Upstream commit 0aa4febb420d91df5b56b1864a2465765da85f4b ]
Under heavy traffic load, when changing number of channels via ethtool (ethtool -L) which will cause interface to be reloaded, it was observed that some packets gets transmitted on old TX channel/queue id which doesn't really exist after the channel configuration leads to system crash.
Add a safeguard in the driver by validating queue id through ndo_select_queue() which is called before the ndo_start_xmit().
--- drivers/net/ethernet/qlogic/qede/qede.h | 3 +++ drivers/net/ethernet/qlogic/qede/qede_fp.c | 13 +++++++++++++ drivers/net/ethernet/qlogic/qede/qede_main.c | 3 +++ 3 files changed, 19 insertions(+)
drivers/net/ethernet/qlogic/qede/qede.h +3 -0
@@ -489,6 +489,9 @@ struct qede_reload_args {/* Datapath functions definition */ netdev_tx_t qede_start_xmit (struct sk_buff *skb,struct net_device *ndev); +u16 qede_select_queue (struct net_device *dev,struct sk_buff *skb, +struct net_device *sb_dev, +select_queue_fallback_t fallback);netdev_features_t qede_features_check (struct sk_buff *skb,struct net_device *dev,netdev_features_t features);
drivers/net/ethernet/qlogic/qede/qede_fp.c +13 -0
@@ -1695,6 +1695,19 @@ netdev_tx_t qede_start_xmit(struct sk_buff *skb, struct net_device *ndev)return NETDEV_TX_OK ; } +u16 qede_select_queue (struct net_device *dev,struct sk_buff *skb, +struct net_device *sb_dev, +select_queue_fallback_t fallback) +{ +struct qede_dev *edev =netdev_priv (dev); +int total_txq; + + total_txq =QEDE_TSS_COUNT (edev) * edev->dev_info.num_tc; + +return QEDE_TSS_COUNT (edev) ? +fallback (dev, skb,NULL ) % total_txq :0 ; +} +/* 8B udp header + 8B base tunnel header + 32B option length */ #define QEDE_MAX_TUN_HDR_LEN 48
drivers/net/ethernet/qlogic/qede/qede_main.c +3 -0
@@ -631,6 +631,7 @@ static const struct net_device_ops qede_netdev_ops = { .ndo_open = qede_open, .ndo_stop = qede_close, .ndo_start_xmit = qede_start_xmit, + .ndo_select_queue = qede_select_queue, .ndo_set_rx_mode = qede_set_rx_mode, .ndo_set_mac_address = qede_set_mac_addr, .ndo_validate_addr = eth_validate_addr,
@@ -666,6 +667,7 @@ static const struct net_device_ops qede_netdev_vf_ops = { .ndo_open = qede_open, .ndo_stop = qede_close, .ndo_start_xmit = qede_start_xmit, + .ndo_select_queue = qede_select_queue, .ndo_set_rx_mode = qede_set_rx_mode, .ndo_set_mac_address = qede_set_mac_addr, .ndo_validate_addr = eth_validate_addr,
@@ -684,6 +686,7 @@ static const struct net_device_ops qede_netdev_vf_xdp_ops = { .ndo_open = qede_open, .ndo_stop = qede_close, .ndo_start_xmit = qede_start_xmit, + .ndo_select_queue = qede_select_queue, .ndo_set_rx_mode = qede_set_rx_mode, .ndo_set_mac_address = qede_set_mac_addr, .ndo_validate_addr = eth_validate_addr,
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 81/81 blk-iolatency: fix IO hang due to negative inflight counter
In reply to Sasha LevinFrom: Liu Bo <[email protected]>
[ Upstream commit 8c772a9bfc7c07c76f4a58b58910452fbb20843b ]
Our test reported the following stack, and vmcore showed that ->inflight counter is -1.
[ffffc9003fcc38d0] __schedule at ffffffff8173d95d [ffffc9003fcc3958] schedule at ffffffff8173de26 [ffffc9003fcc3970] io_schedule at ffffffff810bb6b6 [ffffc9003fcc3988] blkcg_iolatency_throttle at ffffffff813911cb [ffffc9003fcc3a20] rq_qos_throttle at ffffffff813847f3 [ffffc9003fcc3a48] blk_mq_make_request at ffffffff8137468a [ffffc9003fcc3b08] generic_make_request at ffffffff81368b49 [ffffc9003fcc3b68] submit_bio at ffffffff81368d7d [ffffc9003fcc3bb8] ext4_io_submit at ffffffffa031be00 [ext4] [ffffc9003fcc3c00] ext4_writepages at ffffffffa03163de [ext4] [ffffc9003fcc3d68] do_writepages at ffffffff811c49ae [ffffc9003fcc3d78] __filemap_fdatawrite_range at ffffffff811b6188 [ffffc9003fcc3e30] filemap_write_and_wait_range at ffffffff811b6301 [ffffc9003fcc3e60] ext4_sync_file at ffffffffa030cee8 [ext4] [ffffc9003fcc3ea8] vfs_fsync_range at ffffffff8128594b [ffffc9003fcc3ee8] do_fsync at ffffffff81285abd [ffffc9003fcc3f18] sys_fsync at ffffffff81285d50 [ffffc9003fcc3f28] do_syscall_64 at ffffffff81003c04 [ffffc9003fcc3f50] entry_SYSCALL_64_after_swapgs at ffffffff81742b8e
The ->inflight counter may be negative (-1) if
1) blk-iolatency was disabled when the IO was issued,
2) blk-iolatency was enabled before this IO reached its endio,
3) the ->inflight counter is decreased from 0 to -1 in endio()
In fact the hang can be easily reproduced by the below script,
H=/sys/fs/cgroup/unified/
P=/sys/fs/cgroup/unified/test
echo "+io" > $H/cgroup.subtree_control
mkdir -p $P
echo $$ > $P/cgroup.procs
xfs_io -f -d -c "pwrite 0 4k" /dev/sdg
echo "cat /sys/block/sdg/dev target=1000000" > $P/io.latency
xfs_io -f -d -c "pwrite 0 4k" /dev/sdg
This fixes the problem by freezing the queue so that while enabling/disabling iolatency, there is no inflight rq running.
Note that quiesce_queue is not needed as this only updating iolatency configuration about which dispatching request_queue doesn't care.
--- block/blk-iolatency.c | 52 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 7 deletions(-)
block/blk-iolatency.c +45 -7
@@ -72,6 +72,7 @@#include <linux/sched/loadavg.h> #include <linux/sched/signal.h> #include <trace/events/block.h> +#include <linux/blk-mq.h> #include "blk-rq-qos.h" #include "blk-stat.h"
@@ -648,6 +649,9 @@ static void blkcg_iolatency_done_bio(struct rq_qos *rqos, struct bio *bio)return ; enabled =blk_iolatency_enabled (iolat->blkiolat); +if (!enabled) +return ; +while (blkg && blkg->parent) { iolat =blkg_to_lat (blkg);if (!iolat) {
@@ -657,7 +661,7 @@ static void blkcg_iolatency_done_bio(struct rq_qos *rqos, struct bio *bio) rqw = &iolat->rq_wait;atomic_dec (&rqw->inflight); -if (!enabled || iolat->min_lat_nsec ==0 ) +if (iolat->min_lat_nsec ==0 ) goto next;iolatency_record_time (iolat, &bio->bi_issue, now, issue_as_root);
@@ -801,10 +805,13 @@ int blk_iolatency_init(struct request_queue *q)return 0 ; } -static void iolatency_set_min_lat_nsec (struct blkcg_gq *blkg,u64 val) +/* +* return 1 for enabling iolatency, return -1 for disabling iolatency, otherwise +* return 0. +*/ +static int iolatency_set_min_lat_nsec (struct blkcg_gq *blkg,u64 val) {struct iolatency_grp *iolat =blkg_to_lat (blkg); -struct blk_iolatency *blkiolat = iolat->blkiolat;u64 oldval = iolat->min_lat_nsec; iolat->min_lat_nsec = val;
@@ -813,9 +820,10 @@ static void iolatency_set_min_lat_nsec(struct blkcg_gq *blkg, u64 val) BLKIOLATENCY_MAX_WIN_SIZE);if (!oldval && val) -atomic_inc (&blkiolat->enabled); +return 1 ;if (oldval && !val) -atomic_dec (&blkiolat->enabled); +return -1 ; +return 0 ; }static void iolatency_clear_scaling (struct blkcg_gq *blkg)
@@ -847,6 +855,7 @@ static ssize_t iolatency_set_limit(struct kernfs_open_file *of, char *buf,u64 lat_val =0 ;u64 oldval;int ret; +int enable =0 ; ret =blkg_conf_prep (blkcg, &blkcg_policy_iolatency, buf, &ctx);if (ret)
@@ -881,7 +890,12 @@ static ssize_t iolatency_set_limit(struct kernfs_open_file *of, char *buf, blkg = ctx.blkg; oldval = iolat->min_lat_nsec; -iolatency_set_min_lat_nsec (blkg, lat_val); + enable =iolatency_set_min_lat_nsec (blkg, lat_val); +if (enable) { +WARN_ON_ONCE (!blk_get_queue (blkg->q)); +blkg_get (blkg); + } +if (oldval != iolat->min_lat_nsec) {iolatency_clear_scaling (blkg); }
@@ -889,6 +903,24 @@ static ssize_t iolatency_set_limit(struct kernfs_open_file *of, char *buf, ret =0 ; out:blkg_conf_finish (&ctx); +if (ret ==0 && enable) { +struct iolatency_grp *tmp =blkg_to_lat (blkg); +struct blk_iolatency *blkiolat = tmp->blkiolat; + +blk_mq_freeze_queue (blkg->q); + +if (enable ==1 ) +atomic_inc (&blkiolat->enabled); +else if (enable ==-1 ) +atomic_dec (&blkiolat->enabled); +else +WARN_ON_ONCE (1 ); + +blk_mq_unfreeze_queue (blkg->q); + +blkg_put (blkg); +blk_put_queue (blkg->q); + }return ret ?: nbytes; }
@@ -1024,8 +1056,14 @@ static void iolatency_pd_offline(struct blkg_policy_data *pd) {struct iolatency_grp *iolat =pd_to_lat (pd);struct blkcg_gq *blkg =lat_to_blkg (iolat); +struct blk_iolatency *blkiolat = iolat->blkiolat; +int ret; -iolatency_set_min_lat_nsec (blkg,0 ); + ret =iolatency_set_min_lat_nsec (blkg,0 ); +if (ret ==1 ) +atomic_inc (&blkiolat->enabled); +if (ret ==-1 ) +atomic_dec (&blkiolat->enabled);iolatency_clear_scaling (blkg); }
Signature · 1 line
2.19.1