Re: [PATCH v2] usb: dwc2: Enable RPi in ACPI mode

2021-04-09 Thread Greg KH
On Fri, Apr 09, 2021 at 03:38:09PM -0500, Jeremy Linton wrote:
> The dwc2 driver has everything we need to run
> in ACPI mode except for the ACPI module device table
> boilerplate. With that added and identified as "BCM2848",
> an id in use by other OSs for this device, the dw2
> controller on the BCM2711 will work.
> 
> Signed-off-by: Jeremy Linton 
> ---
>  drivers/usb/dwc2/core.h |  2 ++
>  drivers/usb/dwc2/params.c   | 18 +-
>  drivers/usb/dwc2/platform.c |  1 +
>  3 files changed, 20 insertions(+), 1 deletion(-)


Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- This looks like a new version of a previously submitted patch, but you
  did not list below the --- line any changes from the previous version.
  Please read the section entitled "The canonical patch format" in the
  kernel file, Documentation/SubmittingPatches for what needs to be done
  here to properly describe this.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot


Re: [PATCH] um: add 2 missing libs to fix various build errors

2021-04-09 Thread Anton Ivanov

On 10/04/2021 05:13, Randy Dunlap wrote:

On 4/4/21 11:20 AM, Randy Dunlap wrote:

Fix many build errors (at least 18 build error reports) for uml on i386
by adding 2 more library object files. All missing symbols are
either cmpxchg8b_emu or atomic*386.

Here are a few examples of the build errors that are eliminated:

/usr/bin/ld: core.c:(.text+0xd83): undefined reference to `cmpxchg8b_emu'
/usr/bin/ld: core.c:(.text+0x2bb2): undefined reference to 
`atomic64_add_386'
/usr/bin/ld: core.c:(.text+0x2c5d): undefined reference to 
`atomic64_xchg_386'
syscall.c:(.text+0x2f49): undefined reference to `atomic64_set_386'
/usr/bin/ld: syscall.c:(.text+0x2f54): undefined reference to 
`atomic64_set_386'
syscall.c:(.text+0x33a4): undefined reference to `atomic64_inc_386'
/usr/bin/ld: syscall.c:(.text+0x33ac): undefined reference to 
`atomic64_inc_386'
/usr/bin/ld: net/ipv4/inet_timewait_sock.o: in function `inet_twsk_alloc':
inet_timewait_sock.c:(.text+0x3d1): undefined reference to 
`atomic64_read_386'
/usr/bin/ld: inet_timewait_sock.c:(.text+0x3dd): undefined reference to 
`atomic64_set_386'
/usr/bin/ld: net/ipv4/inet_connection_sock.o: in function 
`inet_csk_clone_lock':
inet_connection_sock.c:(.text+0x1d74): undefined reference to 
`atomic64_read_386'
/usr/bin/ld: inet_connection_sock.c:(.text+0x1d80): undefined reference to 
`atomic64_set_386'
/usr/bin/ld: net/ipv4/tcp_input.o: in function `inet_reqsk_alloc':
tcp_input.c:(.text+0xa345): undefined reference to `atomic64_set_386'
/usr/bin/ld: net/mac80211/wpa.o: in function 
`ieee80211_crypto_tkip_encrypt':
wpa.c:(.text+0x739): undefined reference to `atomic64_inc_return_386'

Signed-off-by: Randy Dunlap 
Reported-by: kernel test robot 
Cc: Brendan Jackman 
Cc: Alexei Starovoitov 
Cc: kbuild-...@lists.01.org
Cc: Jeff Dike 
Cc: Richard Weinberger 
Cc: Anton Ivanov 
Cc: linux...@lists.infradead.org
Cc: Johannes Berg 
Cc: Johannes Berg 
---
My UML on i386 build environment is br0ken so this is not tested other
than to see that the .o files are built as expected.
If someone can test/verify it, please respond. Thanks.


Hi,
Instead of trying to build this on x86_64, I powered up my 32-bit x86
laptop and verified that this patch fixes the build errors of
undefined references to cmpxchg8b_emu() and atomic64_*_386() functions.

There are still some build errors in 2 object files:

/usr/lib/gcc/i586-suse-linux/10/../../../../i586-suse-linux/bin/ld: 
kernel/irq/generic-chip.o:(.altinstructions+0x8): undefined reference to 
`X86_FEATURE_XMM2'
/usr/lib/gcc/i586-suse-linux/10/../../../../i586-suse-linux/bin/ld: 
kernel/irq/generic-chip.o:(.altinstructions+0x15): undefined reference to 
`X86_FEATURE_XMM2'
/usr/lib/gcc/i586-suse-linux/10/../../../../i586-suse-linux/bin/ld: 
kernel/irq/generic-chip.o:(.altinstructions+0x22): undefined reference to 
`X86_FEATURE_XMM'
/usr/lib/gcc/i586-suse-linux/10/../../../../i586-suse-linux/bin/ld: 
kernel/irq/generic-chip.o:(.altinstructions+0x2f): undefined reference to 
`X86_FEATURE_XMM'
/usr/lib/gcc/i586-suse-linux/10/../../../../i586-suse-linux/bin/ld: 
kernel/irq/generic-chip.o:(.altinstructions+0x3c): undefined reference to 
`X86_FEATURE_XMM'
/usr/lib/gcc/i586-suse-linux/10/../../../../i586-suse-linux/bin/ld: 
kernel/irq/generic-chip.o:(.altinstructions+0x49): undefined reference to 
`X86_FEATURE_XMM'
/usr/lib/gcc/i586-suse-linux/10/../../../../i586-suse-linux/bin/ld: 
kernel/irq/generic-chip.o:(.altinstructions+0x56): undefined reference to 
`X86_FEATURE_XMM'
/usr/lib/gcc/i586-suse-linux/10/../../../../i586-suse-linux/bin/ld: 
kernel/irq/generic-chip.o:(.altinstructions+0x63): more undefined references to 
`X86_FEATURE_XMM' follow

and

/usr/lib/gcc/i586-suse-linux/10/../../../../i586-suse-linux/bin/ld: 
drivers/fpga/altera-pr-ip-core.o:(.altinstructions+0x8): undefined reference to 
`X86_FEATURE_XMM2'
/usr/lib/gcc/i586-suse-linux/10/../../../../i586-suse-linux/bin/ld: 
drivers/fpga/altera-pr-ip-core.o:(.altinstructions+0x15): undefined reference 
to `X86_FEATURE_XMM2'
/usr/lib/gcc/i586-suse-linux/10/../../../../i586-suse-linux/bin/ld: 
drivers/fpga/altera-pr-ip-core.o:(.altinstructions+0x22): undefined reference 
to `X86_FEATURE_XMM'
/usr/lib/gcc/i586-suse-linux/10/../../../../i586-suse-linux/bin/ld: 
drivers/fpga/altera-pr-ip-core.o:(.altinstructions+0x2f): undefined reference 
to `X86_FEATURE_XMM'
/usr/lib/gcc/i586-suse-linux/10/../../../../i586-suse-linux/bin/ld: 
drivers/fpga/altera-pr-ip-core.o:(.altinstructions+0x3c): undefined reference 
to `X86_FEATURE_XMM'
/usr/lib/gcc/i586-suse-linux/10/../../../../i586-suse-linux/bin/ld: 
drivers/fpga/altera-pr-ip-core.o:(.altinstructions+0x49): undefined reference 
to `X86_FEATURE_XMM'
/usr/lib/gcc/i586-suse-linux/10/../../../../i586-suse-linux/bin/ld: 
drivers/fpga/altera-pr-ip-core.o:(.altinstructions+0x56): undefined reference 
to `X86_FEATURE_XMM'
/usr/lib/gcc/i586-suse-linux/10/../../../../i586-suse-linux/bin/ld: 

[PATCH v13 3/4] staging: mt7621-dts: use valid vendor 'mediatek' instead of invalid 'mtk'

2021-04-09 Thread Sergio Paracuellos
Vendor listed for mediatek in kernel vendor file 'vendor-prefixes.yaml'
contains 'mediatek' as a valid vendor string. Some nodes in the device
tree are using an invalid vendor string vfor 'mtk' instead. Fix all of
them in dts file. Update also ralink mt7621 related code to properly
match new strings. Even there are used in the device tree there are
some strings that are not referred anywhere but have been also updated
with new vendor name. These are 'mtk,mt7621-wdt', 'mtk,mt7621-nand',
'mtk,mt7621-mc', and 'mtk,mt7621-cpc'.

Acked-by: Greg Kroah-Hartman 
Acked-by: Thomas Bogendoerfer 
Signed-off-by: Sergio Paracuellos 
---
 arch/mips/ralink/mt7621.c  |  6 +++---
 drivers/staging/mt7621-dts/mt7621.dtsi | 12 ++--
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/arch/mips/ralink/mt7621.c b/arch/mips/ralink/mt7621.c
index 6b3db98894cb..f82ad2a621f6 100644
--- a/arch/mips/ralink/mt7621.c
+++ b/arch/mips/ralink/mt7621.c
@@ -136,8 +136,8 @@ static void __init mt7621_memory_detect(void)
 
 void __init ralink_of_remap(void)
 {
-   rt_sysc_membase = plat_of_remap_node("mtk,mt7621-sysc");
-   rt_memc_membase = plat_of_remap_node("mtk,mt7621-memc");
+   rt_sysc_membase = plat_of_remap_node("mediatek,mt7621-sysc");
+   rt_memc_membase = plat_of_remap_node("mediatek,mt7621-memc");
 
if (!rt_sysc_membase || !rt_memc_membase)
panic("Failed to remap core resources");
@@ -205,7 +205,7 @@ void __init prom_soc_init(struct ralink_soc_info *soc_info)
 
if (n0 == MT7621_CHIP_NAME0 && n1 == MT7621_CHIP_NAME1) {
name = "MT7621";
-   soc_info->compatible = "mtk,mt7621-soc";
+   soc_info->compatible = "mediatek,mt7621-soc";
} else {
panic("mt7621: unknown SoC, n0:%08x n1:%08x\n", n0, n1);
}
diff --git a/drivers/staging/mt7621-dts/mt7621.dtsi 
b/drivers/staging/mt7621-dts/mt7621.dtsi
index b68183e7e6ad..f0c9ae757bcd 100644
--- a/drivers/staging/mt7621-dts/mt7621.dtsi
+++ b/drivers/staging/mt7621-dts/mt7621.dtsi
@@ -56,7 +56,7 @@ palmbus: palmbus@1E00 {
#size-cells = <1>;
 
sysc: sysc@0 {
-   compatible = "mtk,mt7621-sysc", "syscon";
+   compatible = "mediatek,mt7621-sysc", "syscon";
reg = <0x0 0x100>;
#clock-cells = <1>;
ralink,memctl = <>;
@@ -66,7 +66,7 @@ sysc: sysc@0 {
};
 
wdt: wdt@100 {
-   compatible = "mtk,mt7621-wdt";
+   compatible = "mediatek,mt7621-wdt";
reg = <0x100 0x100>;
};
 
@@ -123,17 +123,17 @@ i2s: i2s@a00 {
};
 
memc: memc@5000 {
-   compatible = "mtk,mt7621-memc", "syscon";
+   compatible = "mediatek,mt7621-memc", "syscon";
reg = <0x5000 0x1000>;
};
 
cpc: cpc@1fbf {
-compatible = "mtk,mt7621-cpc";
+compatible = "mediatek,mt7621-cpc";
 reg = <0x1fbf 0x8000>;
};
 
mc: mc@1fbf8000 {
-   compatible = "mtk,mt7621-mc";
+   compatible = "mediatek,mt7621-mc";
reg = <0x1fbf8000 0x8000>;
};
 
@@ -361,7 +361,7 @@ timer {
nand: nand@1e003000 {
status = "disabled";
 
-   compatible = "mtk,mt7621-nand";
+   compatible = "mediatek,mt7621-nand";
bank-width = <2>;
reg = <0x1e003000 0x800
0x1e003800 0x800>;
-- 
2.25.1



[PATCH v13 4/4] MAINTAINERS: add MT7621 CLOCK maintainer

2021-04-09 Thread Sergio Paracuellos
Adding myself as maintainer for mt7621 clock driver.

Signed-off-by: Sergio Paracuellos 
---
 MAINTAINERS | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 4d68184d3f76..02986055fdbc 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11484,6 +11484,12 @@ L: linux-wirel...@vger.kernel.org
 S: Maintained
 F: drivers/net/wireless/mediatek/mt7601u/
 
+MEDIATEK MT7621 CLOCK DRIVER
+M: Sergio Paracuellos 
+S: Maintained
+F: Documentation/devicetree/bindings/clock/mediatek,mt7621-sysc.yaml
+F: drivers/clk/ralink/clk-mt7621.c
+
 MEDIATEK MT7621/28/88 I2C DRIVER
 M: Stefan Roese 
 L: linux-...@vger.kernel.org
-- 
2.25.1



[PATCH v13 1/4] clk: ralink: add clock driver for mt7621 SoC

2021-04-09 Thread Sergio Paracuellos
The documentation for this SOC only talks about two
registers regarding to the clocks:
* SYSC_REG_CPLL_CLKCFG0 - provides some information about
boostrapped refclock. PLL and dividers used for CPU and some
sort of BUS.
* SYSC_REG_CPLL_CLKCFG1 - a banch of gates to enable/disable
clocks for all or some ip cores.

Looking into driver code, and some openWRT patched there are
another frequencies which are used in some drivers (uart, sd...).
According to all of this information the clock plan for this
SoC is set as follows:
- Main top clock "xtal" from where all the rest of the world is
derived.
- CPU clock "cpu" derived from "xtal" frequencies and a bunch of
register reads and predividers.
- BUS clock "bus" derived from "cpu" and with (cpu / 4) MHz.
- Fixed clocks from "xtal":
* "50m": 50 MHz.
* "125m": 125 MHz.
* "150m": 150 MHz.
* "250m": 250 MHz.
* "270m": 270 MHz.

We also have a buch of gate clocks with their parents:
  * "hsdma": "150m"
  * "fe": "250m"
  * "sp_divtx": "270m"
  * "timer": "50m"
  * "pcm": "270m"
  * "pio": "50m"
  * "gdma": "bus"
  * "nand": "125m"
  * "i2c": "50m"
  * "i2s": "270m"
  * "spi": "bus"
  * "uart1": "50m"
  * "uart2": "50m"
  * "uart3": "50m"
  * "eth": "50m"
  * "pcie0": "125m"
  * "pcie1": "125m"
  * "pcie2": "125m"
  * "crypto": "250m"
  * "shxc": "50m"

With this information the clk driver will provide clock and gates
functionality from a a set of hardcoded clocks allowing to define
a nice device tree without fixed clocks.

Signed-off-by: Sergio Paracuellos 
---
 drivers/clk/Kconfig |   1 +
 drivers/clk/Makefile|   1 +
 drivers/clk/ralink/Kconfig  |  11 +
 drivers/clk/ralink/Makefile |   2 +
 drivers/clk/ralink/clk-mt7621.c | 495 
 5 files changed, 510 insertions(+)
 create mode 100644 drivers/clk/ralink/Kconfig
 create mode 100644 drivers/clk/ralink/Makefile
 create mode 100644 drivers/clk/ralink/clk-mt7621.c

diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index 1d1891b9cad2..e80918be8e9c 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -390,6 +390,7 @@ source "drivers/clk/meson/Kconfig"
 source "drivers/clk/mstar/Kconfig"
 source "drivers/clk/mvebu/Kconfig"
 source "drivers/clk/qcom/Kconfig"
+source "drivers/clk/ralink/Kconfig"
 source "drivers/clk/renesas/Kconfig"
 source "drivers/clk/rockchip/Kconfig"
 source "drivers/clk/samsung/Kconfig"
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 9b582b3fca34..5f06879d7fe9 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -100,6 +100,7 @@ obj-$(CONFIG_COMMON_CLK_NXP)+= nxp/
 obj-$(CONFIG_MACH_PISTACHIO)   += pistachio/
 obj-$(CONFIG_COMMON_CLK_PXA)   += pxa/
 obj-$(CONFIG_COMMON_CLK_QCOM)  += qcom/
+obj-y  += ralink/
 obj-y  += renesas/
 obj-$(CONFIG_ARCH_ROCKCHIP)+= rockchip/
 obj-$(CONFIG_COMMON_CLK_SAMSUNG)   += samsung/
diff --git a/drivers/clk/ralink/Kconfig b/drivers/clk/ralink/Kconfig
new file mode 100644
index ..6580d5edc676
--- /dev/null
+++ b/drivers/clk/ralink/Kconfig
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# MediaTek Mt7621 Clock Driver
+#
+config CLK_MT7621
+   bool "Clock driver for MediaTek MT7621"
+   depends on SOC_MT7621 || COMPILE_TEST
+   default SOC_MT7621
+   select MFD_SYSCON
+   help
+ This driver supports MediaTek MT7621 basic clocks.
diff --git a/drivers/clk/ralink/Makefile b/drivers/clk/ralink/Makefile
new file mode 100644
index ..cf6f9216379d
--- /dev/null
+++ b/drivers/clk/ralink/Makefile
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0
+obj-$(CONFIG_CLK_MT7621) += clk-mt7621.o
diff --git a/drivers/clk/ralink/clk-mt7621.c b/drivers/clk/ralink/clk-mt7621.c
new file mode 100644
index ..857da1e274be
--- /dev/null
+++ b/drivers/clk/ralink/clk-mt7621.c
@@ -0,0 +1,495 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Mediatek MT7621 Clock Driver
+ * Author: Sergio Paracuellos 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Configuration registers */
+#define SYSC_REG_SYSTEM_CONFIG0 0x10
+#define SYSC_REG_SYSTEM_CONFIG1 0x14
+#define SYSC_REG_CLKCFG0   0x2c
+#define SYSC_REG_CLKCFG1   0x30
+#define SYSC_REG_CUR_CLK_STS   0x44
+#define MEMC_REG_CPU_PLL   0x648
+
+#define XTAL_MODE_SEL_MASK GENMASK(8, 6)
+#define CPU_CLK_SEL_MASK   GENMASK(31, 30)
+#define CUR_CPU_FDIV_MASK  GENMASK(12, 8)
+#define CUR_CPU_FFRAC_MASK GENMASK(4, 0)
+#define CPU_PLL_PREDIV_MASKGENMASK(13, 12)
+#define CPU_PLL_FBDIV_MASK GENMASK(10, 4)
+
+struct mt7621_clk_priv {
+   struct regmap *sysc;
+   struct regmap *memc;
+};
+
+struct mt7621_clk {
+   struct clk_hw hw;
+   struct 

[PATCH v13 2/4] staging: mt7621-dts: make use of new 'mt7621-clk'

2021-04-09 Thread Sergio Paracuellos
Clocks for SoC mt7621 have been properly integrated so there is
no need to declare fixed clocks at all in the device tree. Remove
all of them, add new device tree nodes for mt7621-clk and update
the rest of the nodes to use them.

Acked-by: Greg Kroah-Hartman 
Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-dts/gbpc1.dts   | 11 
 drivers/staging/mt7621-dts/mt7621.dtsi | 74 --
 2 files changed, 33 insertions(+), 52 deletions(-)

diff --git a/drivers/staging/mt7621-dts/gbpc1.dts 
b/drivers/staging/mt7621-dts/gbpc1.dts
index a7c0d3115d72..7716d0efe524 100644
--- a/drivers/staging/mt7621-dts/gbpc1.dts
+++ b/drivers/staging/mt7621-dts/gbpc1.dts
@@ -100,17 +100,6 @@ partition@5 {
};
 };
 
- {
-   compatible = "fixed-clock";
-   /* This is normally 1/4 of cpuclock */
-   clock-frequency = <22500>;
-};
-
- {
-   compatible = "fixed-clock";
-   clock-frequency = <9>;
-};
-
  {
pinctrl-names = "default";
pinctrl-0 = <_pins>;
diff --git a/drivers/staging/mt7621-dts/mt7621.dtsi 
b/drivers/staging/mt7621-dts/mt7621.dtsi
index 16fc94f65486..b68183e7e6ad 100644
--- a/drivers/staging/mt7621-dts/mt7621.dtsi
+++ b/drivers/staging/mt7621-dts/mt7621.dtsi
@@ -1,5 +1,6 @@
 #include 
 #include 
+#include 
 
 / {
#address-cells = <1>;
@@ -27,27 +28,6 @@ aliases {
serial0 = 
};
 
-   cpuclock: cpuclock@0 {
-   #clock-cells = <0>;
-   compatible = "fixed-clock";
-
-   /* FIXME: there should be way to detect this */
-   clock-frequency = <88000>;
-   };
-
-   sysclock: sysclock@0 {
-   #clock-cells = <0>;
-   compatible = "fixed-clock";
-
-   /* This is normally 1/4 of cpuclock */
-   clock-frequency = <22000>;
-   };
-
-   mmc_clock: mmc_clock@0 {
-   #clock-cells = <0>;
-   compatible = "fixed-clock";
-   clock-frequency = <4800>;
-   };
 
mmc_fixed_3v3: fixedregulator@0 {
compatible = "regulator-fixed";
@@ -76,8 +56,13 @@ palmbus: palmbus@1E00 {
#size-cells = <1>;
 
sysc: sysc@0 {
-   compatible = "mtk,mt7621-sysc";
+   compatible = "mtk,mt7621-sysc", "syscon";
reg = <0x0 0x100>;
+   #clock-cells = <1>;
+   ralink,memctl = <>;
+   clock-output-names = "xtal", "cpu", "bus",
+"50m", "125m", "150m",
+"250m", "270m";
};
 
wdt: wdt@100 {
@@ -101,8 +86,8 @@ i2c: i2c@900 {
compatible = "mediatek,mt7621-i2c";
reg = <0x900 0x100>;
 
-   clocks = <>;
-
+   clocks = < MT7621_CLK_I2C>;
+   clock-names = "i2c";
resets = < 16>;
reset-names = "i2c";
 
@@ -119,8 +104,8 @@ i2s: i2s@a00 {
compatible = "mediatek,mt7621-i2s";
reg = <0xa00 0x100>;
 
-   clocks = <>;
-
+   clocks = < MT7621_CLK_I2S>;
+   clock-names = "i2s";
resets = < 17>;
reset-names = "i2s";
 
@@ -138,7 +123,7 @@ i2s: i2s@a00 {
};
 
memc: memc@5000 {
-   compatible = "mtk,mt7621-memc";
+   compatible = "mtk,mt7621-memc", "syscon";
reg = <0x5000 0x1000>;
};
 
@@ -156,8 +141,8 @@ uartlite: uartlite@c00 {
compatible = "ns16550a";
reg = <0xc00 0x100>;
 
-   clocks = <>;
-   clock-frequency = <5000>;
+   clocks = < MT7621_CLK_UART1>;
+   clock-names = "uart1";
 
interrupt-parent = <>;
interrupts = ;
@@ -173,7 +158,8 @@ spi0: spi@b00 {
compatible = "ralink,mt7621-spi";
reg = <0xb00 0x100>;
 
-   clocks = <>;
+   clocks = < MT7621_CLK_SPI>;
+   clock-names = "spi";
 
resets = < 18>;
reset-names = "spi";
@@ -189,6 +175,8 @@ gdma: gdma@2800 {
compatible = "ralink,rt3883-gdma";
reg = <0x2800 0x800>;
 
+   clocks = < MT7621_CLK_GDMA>;
+   clock-names = "gdma";
resets = < 14>;
reset-names = "dma";
 
@@ -206,6 +194,8 @@ hsdma: hsdma@7000 {
  

[PATCH v13 0/4] MIPS: ralink: add CPU clock detection and clock driver for MT7621

2021-04-09 Thread Sergio Paracuellos
This patchset ports CPU clock detection for MT7621 from OpenWrt
and adds a complete clock plan for the mt7621 SOC.

The documentation for this SOC only talks about two registers
regarding to the clocks:
* SYSC_REG_CPLL_CLKCFG0 - provides some information about boostrapped
refclock. PLL and dividers used for CPU and some sort of BUS (AHB?).
* SYSC_REG_CPLL_CLKCFG1 - a banch of gates to enable/disable clocks for
all or some ip cores.

Registers needed for this driver to work are in two already mapped areas
in its platform's device tree. These are 'sysc' and 'memc' nodes. Most
of other drivers just make use of platform operations defined in
'asm/mach-ralink/ralink_regs.h' but this can be avoided declaring this
two nodes to be accesible through syscon. Main registers for the clocks
are in the sysc control node so this node is merged with clock properties
and will also be the clock provider for the SoC.

No documentation about a probably existent set of dividers for each ip
core is included in the datasheets. So we cannot make anything better,
AFAICT.

Looking into driver code, and some openWRT patched there are
another frequences which are used in some drivers (uart, sd...).
According to all of this information the clock plan for this
SoC is set as follows:
 - Main top clock "xtal" from where all the rest of the world is
   derived.
 - CPU clock "cpu" derived from "xtal" frequencies and a bunch of
   register reads and predividers.
 - BUS clock "bus" derived from "cpu" and with (cpu / 4) MHz.
 - Fixed clocks from "xtal":
* "50m": 50 MHz.
* "125m": 125 MHz.
* "150m": 150 MHz.
* "250m": 250 MHz.
* "270m": 270 MHz.

We also have a buch of gate clocks with their parents:
 - "hsdma": "150m"
 - "fe": "250m"
 - "sp_divtx": "270m"
 - "timer": "50m"
 - "pcm": "270m"
 - "pio": "50m"
 - "gdma": "bus"
 - "nand": "125m"
 - "i2c": "50m"
 - "i2s": "270m"
 - "spi": "bus"
 - "uart1": "50m"
 - "uart2": "50m"
 - "uart3": "50m"
 - "eth": "50m"
 - "pcie0": "125m"
 - "pcie1": "125m"
 - "pcie2": "125m"
 - "crypto": "250m"
 - "shxc": "50m"

There was a previous attempt of doing this here[0] but the author
(Chuanhong Guo) did not wanted to make assumptions of a clock plan
for the platform that time. It seems that now he has a better idea of
how the clocks are dispossed for this SoC so he share code[1] where
some frequencies and clock parents for the gates are coded from a
real mediatek private clock plan.

I do really want this to be upstreamed so according to the comments
in previous attempt[0] from Oleksij Rempel and the frequencies in
code[1] I have tried to do this by myself.

All of this patches have been tested in a GNUBee PC1 resulting in a
working platform.

Changes in v13:
 - Rebase this series on top of linux-next 'next-20210409'.
 - Drop empty line in Kconfig.
 - Directly return -ENOMEM 'mt7621_clk_probe' instead of assign to
   ret and return ret when devm_kzalloc fails.
 - Review functions and move all remaining 'sclk' declarations to the
   top to avoid to declare it twice for success and error paths.

Changes in v12:
 - First to patches of previous v11 series has already merged so this
   new seres only have remaining four patches.
 - Add Acked-by from Thomas Bogendoerfer for patch 3/4.
 - Drop menu from Kconfig and only maintain CLK_MT7621 option.
 - Remove comma from sentinel so it's a compile error if
   another element is added after.
 - Use CLK_IS_CRITICAL with a comment when gates are registered and
   drop 'mt7621_prepare_enable_clocks' function.
 - Move 'sclk' declaration to the top of the mt7621_register_early_clocks
   function to avoid to declare it twice for success and error paths.
 - Use devm_* APIs instead of directly use kzalloc and simplify error
   path.

Changes in v11:
 - Collect Rob's Reviewed-by in bindings documentation patch.
 - Fix MAINTAINERS patch using file 'mediatek,mt7621-sysc.yaml'
   for documentation bindings.

Changes in v10:
 - Merge clock properties into 'sysc' system control node making
   this node a clock provider.
 - Update driver to use 'mediatek,mt7621-sysc' as compatible string.
 - Update documentation bindings and its related filename to 
   'mediatek,mt7621-sysc.yaml'.
 - Make use of 'linux/bitfields.h' header to avoid some preprocesor
   shift definitions and just use bit masks decreasing a bit LOC.

Changes in v9:
 - Set two missing ret values to its related PTR_ERR in function
   'mt7621_clk_probe' (also 

Re: [PATCH v2] kconfig: nconf: stop endless search-up loops

2021-04-09 Thread Masahiro Yamada
On Sun, Mar 28, 2021 at 6:52 PM Mihai Moldovan  wrote:
>
> If the user selects the very first entry in a page and performs a
> search-up operation (e.g., via [/][a][Up Arrow]), nconf will never
> terminate searching the page.
>
> The reason is that in this case, the starting point will be set to -1,
> which is then translated into (n - 1) (i.e., the last entry of the
> page) and finally the search begins. This continues to work fine until
> the index reaches 0, at which point it will be decremented to -1, but
> not checked against the starting point right away. Instead, it's
> wrapped around to the bottom again, after which the starting point
> check occurs... and naturally fails.
>
> We can easily avoid it by checking against the starting point directly
> if the current index is -1 (which should be safe, since it's the only
> magic value that can occur) and terminate the matching function.
>
> Amazingly, nobody seems to have been hit by this for 11 years - or at
> the very least nobody bothered to debug and fix this.
>
> Signed-off-by: Mihai Moldovan 
> ---
> v2: swap constant in comparison to right side, as requested by
> Randy Dunlap 
>
>  scripts/kconfig/nconf.c | 9 +
>  1 file changed, 9 insertions(+)
>
> diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c
> index e0f965529166..db0dc46bc5ee 100644
> --- a/scripts/kconfig/nconf.c
> +++ b/scripts/kconfig/nconf.c
> @@ -515,6 +515,15 @@ static int get_mext_match(const char *match_str, match_f 
> flag)
> --index;
> else
> ++index;
> +   /*
> +* It's fine for index to become negative - think of an
> +* initial value for match_start of 0 with a match direction
> +* of up, eventually making it -1.
> +*
> +* Handle this as a special case.
> +*/
> +   if ((index == -1) && (index == match_start))
> +   return -1;

We know 'index' is -1 in the second comparison.
So, you can also write like this:

   if (match_start == -1 && index == -1)
return -1;



But, it is not the correct fix, either.

The root cause of the bug is match_start
becoming -1.


The following is the correct way to fix the bug
without increasing the number of lines.



diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c
index e0f965529166..af814b39b876 100644
--- a/scripts/kconfig/nconf.c
+++ b/scripts/kconfig/nconf.c
@@ -504,8 +504,8 @@ static int get_mext_match(const char *match_str,
match_f flag)
else if (flag == FIND_NEXT_MATCH_UP)
--match_start;

+   match_start = (match_start + items_num) % items_num;
index = match_start;
-   index = (index + items_num) % items_num;
while (true) {
char *str = k_menu_items[index].str;
if (strcasestr(str, match_str) != NULL)







-- 
Best Regards
Masahiro Yamada


Re: [PATCH] iommu/mediatek: always enable the clk on resume

2021-04-09 Thread Yong Wu
On Thu, 2021-04-08 at 14:28 +0200, Dafna Hirschfeld wrote:
> In mtk_iommu_runtime_resume always enable the clk, even
> if m4u_dom is null. Otherwise the 'suspend' cb might
> disable the clk which is already disabled causing the warning:

Hi Dafna,

Thanks very much for testing and report. I have reproduced this issue
locally. It happened when iommu probe before than smi-common(iommu is
the supplier in the dev-link).

I put clk_prepare_enable in the _hw_init since I have plan to remove the
pm_runtime_get/put in the _attach_device(This will turn off the display
power domain if we show fastlogo at that time.) May be we should keep
the smi-common probe always before than iommu.

Anyway, This patch makes code symmetrical and it is good for now.

Reviewed-by: Yong Wu 

> 
> [1.586104] infra_m4u already disabled
> [1.586133] WARNING: CPU: 0 PID: 121 at drivers/clk/clk.c:952 
> clk_core_disable+0xb0/0xb8
> [1.594391] mtk-iommu 10205000.iommu: bound 18001000.larb (ops 
> mtk_smi_larb_component_ops)
> [1.598108] Modules linked in:
> [1.598114] CPU: 0 PID: 121 Comm: kworker/0:2 Not tainted 5.12.0-rc5 #69
> [1.609246] mtk-iommu 10205000.iommu: bound 14027000.larb (ops 
> mtk_smi_larb_component_ops)
> [1.617487] Hardware name: Google Elm (DT)
> [1.617491] Workqueue: pm pm_runtime_work
> [1.620545] mtk-iommu 10205000.iommu: bound 19001000.larb (ops 
> mtk_smi_larb_component_ops)
> 
> [1.627229] pstate: 6085 (nZCv daIf -PAN -UAO -TCO BTYPE=--)
> [1.659297] pc : clk_core_disable+0xb0/0xb8
> [1.663475] lr : clk_core_disable+0xb0/0xb8
> [1.667652] sp : 800011b9bbe0
> [1.670959] x29: 800011b9bbe0 x28: 
> [1.676267] x27: 800011448000 x26: 8000100cfd98
> [1.681574] x25: 800011b9bd48 x24: 
> [1.686882] x23:  x22: 8000106fad90
> [1.692189] x21: 000a x20: c0048500
> [1.697496] x19: c0048500 x18: 
> [1.702804] x17:  x16: 
> [1.708112] x15: 800011460300 x14: fffe
> [1.713420] x13: 8000114602d8 x12: 0720072007200720
> [1.718727] x11: 0720072007200720 x10: 0720072007200720
> [1.724035] x9 : 800011b9bbe0 x8 : 800011b9bbe0
> [1.729342] x7 : 0009 x6 : 8000114b8328
> [1.734649] x5 :  x4 : 
> [1.739956] x3 :  x2 : 800011460298
> [1.745263] x1 : 1af1d7de276f4500 x0 : 
> [1.750572] Call trace:
> [1.753010]  clk_core_disable+0xb0/0xb8
> [1.756840]  clk_core_disable_lock+0x24/0x40
> [1.761105]  clk_disable+0x20/0x30
> [1.764501]  mtk_iommu_runtime_suspend+0x88/0xa8
> [1.769114]  pm_generic_runtime_suspend+0x2c/0x48
> [1.773815]  __rpm_callback+0xe0/0x178
> [1.777559]  rpm_callback+0x24/0x88
> [1.781041]  rpm_suspend+0xdc/0x470
> [1.784523]  rpm_idle+0x12c/0x170
> [1.787831]  pm_runtime_work+0xa8/0xc0
> [1.791573]  process_one_work+0x1e8/0x360
> [1.795580]  worker_thread+0x44/0x478
> [1.799237]  kthread+0x150/0x158
> [1.802460]  ret_from_fork+0x10/0x30
> [1.806034] ---[ end trace 82402920ef64573b ]---
> [1.810728] [ cut here ]
> 
> In addition, we now don't need to enable the clock from the
> function mtk_iommu_hw_init since it is already enabled by the resume.
> 
> Fixes: commit c0b57581b73b ("iommu/mediatek: Add power-domain operation")
> Signed-off-by: Dafna Hirschfeld 
> ---
>  drivers/iommu/mtk_iommu.c | 19 ---
>  1 file changed, 8 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
> index 6ecc007f07cd..e168a682806a 100644
> --- a/drivers/iommu/mtk_iommu.c
> +++ b/drivers/iommu/mtk_iommu.c
> @@ -688,13 +688,6 @@ static const struct iommu_ops mtk_iommu_ops = {
>  static int mtk_iommu_hw_init(const struct mtk_iommu_data *data)
>  {
>   u32 regval;
> - int ret;
> -
> - ret = clk_prepare_enable(data->bclk);
> - if (ret) {
> - dev_err(data->dev, "Failed to enable iommu bclk(%d)\n", ret);
> - return ret;
> - }
>  
>   if (data->plat_data->m4u_plat == M4U_MT8173) {
>   regval = F_MMU_PREFETCH_RT_REPLACE_MOD |
> @@ -760,7 +753,6 @@ static int mtk_iommu_hw_init(const struct mtk_iommu_data 
> *data)
>   if (devm_request_irq(data->dev, data->irq, mtk_iommu_isr, 0,
>dev_name(data->dev), (void *)data)) {
>   writel_relaxed(0, data->base + REG_MMU_PT_BASE_ADDR);
> - clk_disable_unprepare(data->bclk);
>   dev_err(data->dev, "Failed @ IRQ-%d Request\n", data->irq);
>   return -ENODEV;
>   }
> @@ -977,14 +969,19 @@ static int __maybe_unused 
> mtk_iommu_runtime_resume(struct device *dev)
>   void __iomem *base = data->base;
>   int ret;
>  
> - /* Avoid first resume to affect 

Re: [PATCH v2] arm64: dts: qcom: Update iommu property for simultaneous playback

2021-04-09 Thread Srinivasa Rao Mandadapu

Hi Stephen.

Thanks for your time!!!


On 4/9/2021 10:31 PM, Stephen Boyd wrote:

Quoting Srinivasa Rao Mandadapu (2021-04-06 09:33:30)

From: V Sujith Kumar Reddy 

Update iommu property in lpass cpu node for supporting
simultaneous playback on headset and speaker.

Signed-off-by: V Sujith Kumar Reddy 
Signed-off-by: Srinivasa Rao Mandadapu 
---
Changes since v1:
-- Commit messge header change

  arch/arm64/boot/dts/qcom/sc7180.dtsi | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/qcom/sc7180.dtsi 
b/arch/arm64/boot/dts/qcom/sc7180.dtsi
index a6da78d31fdd..6228ba2d8513 100644
--- a/arch/arm64/boot/dts/qcom/sc7180.dtsi
+++ b/arch/arm64/boot/dts/qcom/sc7180.dtsi
@@ -3566,7 +3566,8 @@ lpass_cpu: lpass@62f0 {
 reg = <0 0x62f0 0 0x29000>;
 reg-names = "lpass-lpaif";
  
-   iommus = <_smmu 0x1020 0>;

+   iommus = <_smmu 0x1020 0>,
+   <_smmu 0x1021 0>;

The stream ID 0x1032 was also dropped in this version but there's no
mention of that in the changelog. Why?

That is ID is for HDMI Stream, so as part of DP patches that will be added.


  
 power-domains = <_hm LPASS_CORE_HM_GDSCR>;



--
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc.,
is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.



[PATCH v2 2/5] dt-bindings: usb: mtk-xhci: add wakeup interrupt

2021-04-09 Thread Chunfeng Yun
Add an interrupt which is EINT usually to support runtime PM,
meanwhile add "interrupt-names" property, for backward
compatibility, it's optional and used when wakeup interrupt
exists

Reviewed-by: Rob Herring 
Signed-off-by: Chunfeng Yun 
---
v2: add Reviewed-by Rob
---
 .../devicetree/bindings/usb/mediatek,mtk-xhci.yaml  | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml 
b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
index 45bf4ea00c9e..4fe8a301d03f 100644
--- a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
+++ b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
@@ -46,7 +46,18 @@ properties:
   - const: ippc  # optional, only needed for case 1.
 
   interrupts:
-maxItems: 1
+description:
+  use "interrupts-extended" when the interrupts are connected to the
+  separate interrupt controllers
+minItems: 1
+items:
+  - description: xHCI host controller interrupt
+  - description: optional, wakeup interrupt used to support runtime PM
+
+  interrupt-names:
+items:
+  - const: host
+  - const: wakeup
 
   power-domains:
 description: A phandle to USB power domain node to control USB's MTCMOS
-- 
2.18.0



[PATCH v2 3/5] usb: xhci-mtk: add support runtime PM

2021-04-09 Thread Chunfeng Yun
A dedicated wakeup irq will be used to handle runtime suspend/resume,
we use dev_pm_set_dedicated_wake_irq API to take care of requesting
and attaching wakeup irq, then the suspend/resume framework will help
to enable/disable wakeup irq.

The runtime PM is default off since some platforms may not support it.
users can enable it via power/control (set "auto") in sysfs.

Signed-off-by: Chunfeng Yun 
---
v2: no changes, but abandon dependent patch [1], use falling edge type
interrupt

[1]
[1/6] PM: runtime: enable wake irq after runtime_suspend hook called

https://patchwork.kernel.org/project/linux-mediatek/patch/1617874514-12282-1-git-send-email-chunfeng@mediatek.com/
---
 drivers/usb/host/xhci-mtk.c | 140 +++-
 1 file changed, 124 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index a74764ab914a..30927f4064d4 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -358,7 +359,6 @@ static int usb_wakeup_of_property_parse(struct xhci_hcd_mtk 
*mtk,
mtk->uwk_reg_base, mtk->uwk_vers);
 
return PTR_ERR_OR_ZERO(mtk->uwk);
-
 }
 
 static void usb_wakeup_set(struct xhci_hcd_mtk *mtk, bool enable)
@@ -458,6 +458,7 @@ static int xhci_mtk_probe(struct platform_device *pdev)
struct resource *res;
struct usb_hcd *hcd;
int ret = -ENODEV;
+   int wakeup_irq;
int irq;
 
if (usb_disabled())
@@ -485,6 +486,21 @@ static int xhci_mtk_probe(struct platform_device *pdev)
if (ret)
return ret;
 
+   irq = platform_get_irq_byname_optional(pdev, "host");
+   if (irq < 0) {
+   if (irq == -EPROBE_DEFER)
+   return irq;
+
+   /* for backward compatibility */
+   irq = platform_get_irq(pdev, 0);
+   if (irq < 0)
+   return irq;
+   }
+
+   wakeup_irq = platform_get_irq_byname_optional(pdev, "wakeup");
+   if (wakeup_irq == -EPROBE_DEFER)
+   return wakeup_irq;
+
mtk->lpm_support = of_property_read_bool(node, "usb3-lpm-capable");
/* optional property, ignore the error if it does not exist */
of_property_read_u32(node, "mediatek,u3p-dis-msk",
@@ -496,9 +512,11 @@ static int xhci_mtk_probe(struct platform_device *pdev)
return ret;
}
 
+   pm_runtime_set_active(dev);
+   pm_runtime_use_autosuspend(dev);
+   pm_runtime_set_autosuspend_delay(dev, 4000);
pm_runtime_enable(dev);
pm_runtime_get_sync(dev);
-   device_enable_async_suspend(dev);
 
ret = xhci_mtk_ldos_enable(mtk);
if (ret)
@@ -508,12 +526,6 @@ static int xhci_mtk_probe(struct platform_device *pdev)
if (ret)
goto disable_ldos;
 
-   irq = platform_get_irq(pdev, 0);
-   if (irq < 0) {
-   ret = irq;
-   goto disable_clk;
-   }
-
hcd = usb_create_hcd(driver, dev, dev_name(dev));
if (!hcd) {
ret = -ENOMEM;
@@ -579,8 +591,26 @@ static int xhci_mtk_probe(struct platform_device *pdev)
if (ret)
goto dealloc_usb2_hcd;
 
+   if (wakeup_irq > 0) {
+   ret = dev_pm_set_dedicated_wake_irq(dev, wakeup_irq);
+   if (ret) {
+   dev_err(dev, "set wakeup irq %d failed\n", wakeup_irq);
+   goto dealloc_usb3_hcd;
+   }
+   dev_info(dev, "wakeup irq %d\n", wakeup_irq);
+   }
+
+   device_enable_async_suspend(dev);
+   pm_runtime_mark_last_busy(dev);
+   pm_runtime_put_autosuspend(dev);
+   pm_runtime_forbid(dev);
+
return 0;
 
+dealloc_usb3_hcd:
+   usb_remove_hcd(xhci->shared_hcd);
+   xhci->shared_hcd = NULL;
+
 dealloc_usb2_hcd:
usb_remove_hcd(hcd);
 
@@ -601,25 +631,26 @@ static int xhci_mtk_probe(struct platform_device *pdev)
xhci_mtk_ldos_disable(mtk);
 
 disable_pm:
-   pm_runtime_put_sync(dev);
+   pm_runtime_put_sync_autosuspend(dev);
pm_runtime_disable(dev);
return ret;
 }
 
-static int xhci_mtk_remove(struct platform_device *dev)
+static int xhci_mtk_remove(struct platform_device *pdev)
 {
-   struct xhci_hcd_mtk *mtk = platform_get_drvdata(dev);
+   struct xhci_hcd_mtk *mtk = platform_get_drvdata(pdev);
struct usb_hcd  *hcd = mtk->hcd;
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
struct usb_hcd  *shared_hcd = xhci->shared_hcd;
+   struct device *dev = >dev;
 
-   pm_runtime_put_noidle(>dev);
-   pm_runtime_disable(>dev);
+   pm_runtime_get_sync(dev);
+   xhci->xhc_state |= XHCI_STATE_REMOVING;
+   dev_pm_clear_wake_irq(dev);
+   device_init_wakeup(dev, false);
 
usb_remove_hcd(shared_hcd);
xhci->shared_hcd = NULL;
-   

[PATCH v2 4/5] usb: xhci-mtk: use clock bulk to get clocks

2021-04-09 Thread Chunfeng Yun
Use clock bulk helpers to get/enable/disable clocks, meanwhile
make sys_ck optional, then will be easier to handle clocks.

Signed-off-by: Chunfeng Yun 
---
v2: no changes
---
 drivers/usb/host/xhci-mtk.c | 109 +++-
 drivers/usb/host/xhci-mtk.h |  10 ++--
 2 files changed, 24 insertions(+), 95 deletions(-)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index 30927f4064d4..d4c455eecb8d 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -7,7 +7,6 @@
  *  Chunfeng Yun 
  */
 
-#include 
 #include 
 #include 
 #include 
@@ -220,89 +219,6 @@ static int xhci_mtk_ssusb_config(struct xhci_hcd_mtk *mtk)
return xhci_mtk_host_enable(mtk);
 }
 
-static int xhci_mtk_clks_get(struct xhci_hcd_mtk *mtk)
-{
-   struct device *dev = mtk->dev;
-
-   mtk->sys_clk = devm_clk_get(dev, "sys_ck");
-   if (IS_ERR(mtk->sys_clk)) {
-   dev_err(dev, "fail to get sys_ck\n");
-   return PTR_ERR(mtk->sys_clk);
-   }
-
-   mtk->xhci_clk = devm_clk_get_optional(dev, "xhci_ck");
-   if (IS_ERR(mtk->xhci_clk))
-   return PTR_ERR(mtk->xhci_clk);
-
-   mtk->ref_clk = devm_clk_get_optional(dev, "ref_ck");
-   if (IS_ERR(mtk->ref_clk))
-   return PTR_ERR(mtk->ref_clk);
-
-   mtk->mcu_clk = devm_clk_get_optional(dev, "mcu_ck");
-   if (IS_ERR(mtk->mcu_clk))
-   return PTR_ERR(mtk->mcu_clk);
-
-   mtk->dma_clk = devm_clk_get_optional(dev, "dma_ck");
-   return PTR_ERR_OR_ZERO(mtk->dma_clk);
-}
-
-static int xhci_mtk_clks_enable(struct xhci_hcd_mtk *mtk)
-{
-   int ret;
-
-   ret = clk_prepare_enable(mtk->ref_clk);
-   if (ret) {
-   dev_err(mtk->dev, "failed to enable ref_clk\n");
-   goto ref_clk_err;
-   }
-
-   ret = clk_prepare_enable(mtk->sys_clk);
-   if (ret) {
-   dev_err(mtk->dev, "failed to enable sys_clk\n");
-   goto sys_clk_err;
-   }
-
-   ret = clk_prepare_enable(mtk->xhci_clk);
-   if (ret) {
-   dev_err(mtk->dev, "failed to enable xhci_clk\n");
-   goto xhci_clk_err;
-   }
-
-   ret = clk_prepare_enable(mtk->mcu_clk);
-   if (ret) {
-   dev_err(mtk->dev, "failed to enable mcu_clk\n");
-   goto mcu_clk_err;
-   }
-
-   ret = clk_prepare_enable(mtk->dma_clk);
-   if (ret) {
-   dev_err(mtk->dev, "failed to enable dma_clk\n");
-   goto dma_clk_err;
-   }
-
-   return 0;
-
-dma_clk_err:
-   clk_disable_unprepare(mtk->mcu_clk);
-mcu_clk_err:
-   clk_disable_unprepare(mtk->xhci_clk);
-xhci_clk_err:
-   clk_disable_unprepare(mtk->sys_clk);
-sys_clk_err:
-   clk_disable_unprepare(mtk->ref_clk);
-ref_clk_err:
-   return ret;
-}
-
-static void xhci_mtk_clks_disable(struct xhci_hcd_mtk *mtk)
-{
-   clk_disable_unprepare(mtk->dma_clk);
-   clk_disable_unprepare(mtk->mcu_clk);
-   clk_disable_unprepare(mtk->xhci_clk);
-   clk_disable_unprepare(mtk->sys_clk);
-   clk_disable_unprepare(mtk->ref_clk);
-}
-
 /* only clocks can be turn off for ip-sleep wakeup mode */
 static void usb_wakeup_ip_sleep_set(struct xhci_hcd_mtk *mtk, bool enable)
 {
@@ -367,6 +283,19 @@ static void usb_wakeup_set(struct xhci_hcd_mtk *mtk, bool 
enable)
usb_wakeup_ip_sleep_set(mtk, enable);
 }
 
+static int xhci_mtk_clks_get(struct xhci_hcd_mtk *mtk)
+{
+   struct clk_bulk_data *clks = mtk->clks;
+
+   clks[0].id = "sys_ck";
+   clks[1].id = "xhci_ck";
+   clks[2].id = "ref_ck";
+   clks[3].id = "mcu_ck";
+   clks[4].id = "dma_ck";
+
+   return devm_clk_bulk_get_optional(mtk->dev, BULK_CLKS_NUM, clks);
+}
+
 static int xhci_mtk_ldos_enable(struct xhci_hcd_mtk *mtk)
 {
int ret;
@@ -522,7 +451,7 @@ static int xhci_mtk_probe(struct platform_device *pdev)
if (ret)
goto disable_pm;
 
-   ret = xhci_mtk_clks_enable(mtk);
+   ret = clk_bulk_prepare_enable(BULK_CLKS_NUM, mtk->clks);
if (ret)
goto disable_ldos;
 
@@ -625,7 +554,7 @@ static int xhci_mtk_probe(struct platform_device *pdev)
usb_put_hcd(hcd);
 
 disable_clk:
-   xhci_mtk_clks_disable(mtk);
+   clk_bulk_disable_unprepare(BULK_CLKS_NUM, mtk->clks);
 
 disable_ldos:
xhci_mtk_ldos_disable(mtk);
@@ -655,7 +584,7 @@ static int xhci_mtk_remove(struct platform_device *pdev)
usb_put_hcd(shared_hcd);
usb_put_hcd(hcd);
xhci_mtk_sch_exit(mtk);
-   xhci_mtk_clks_disable(mtk);
+   clk_bulk_disable_unprepare(BULK_CLKS_NUM, mtk->clks);
xhci_mtk_ldos_disable(mtk);
 
pm_runtime_disable(dev);
@@ -682,7 +611,7 @@ static int __maybe_unused xhci_mtk_suspend(struct device 
*dev)
if (ret)
goto restart_poll_rh;
 
-   xhci_mtk_clks_disable(mtk);
+   clk_bulk_disable_unprepare(BULK_CLKS_NUM, mtk->clks);

[PATCH v2 1/5] usb: xhci-mtk: check return value in suspend/resume hooks

2021-04-09 Thread Chunfeng Yun
Return error number if encounter errors during suspend and resume.

Signed-off-by: Chunfeng Yun 
---
v2: no changes
---
 drivers/usb/host/xhci-mtk.c | 37 +++--
 1 file changed, 27 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index c1bc40289833..a74764ab914a 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -630,18 +630,12 @@ static int xhci_mtk_remove(struct platform_device *dev)
return 0;
 }
 
-/*
- * if ip sleep fails, and all clocks are disabled, access register will hang
- * AHB bus, so stop polling roothubs to avoid regs access on bus suspend.
- * and no need to check whether ip sleep failed or not; this will cause SPM
- * to wake up system immediately after system suspend complete if ip sleep
- * fails, it is what we wanted.
- */
 static int __maybe_unused xhci_mtk_suspend(struct device *dev)
 {
struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev);
struct usb_hcd *hcd = mtk->hcd;
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+   int ret;
 
xhci_dbg(xhci, "%s: stop port polling\n", __func__);
clear_bit(HCD_FLAG_POLL_RH, >flags);
@@ -649,10 +643,21 @@ static int __maybe_unused xhci_mtk_suspend(struct device 
*dev)
clear_bit(HCD_FLAG_POLL_RH, >shared_hcd->flags);
del_timer_sync(>shared_hcd->rh_timer);
 
-   xhci_mtk_host_disable(mtk);
+   ret = xhci_mtk_host_disable(mtk);
+   if (ret)
+   goto restart_poll_rh;
+
xhci_mtk_clks_disable(mtk);
usb_wakeup_set(mtk, true);
return 0;
+
+restart_poll_rh:
+   xhci_dbg(xhci, "%s: restart port polling\n", __func__);
+   set_bit(HCD_FLAG_POLL_RH, >shared_hcd->flags);
+   usb_hcd_poll_rh_status(xhci->shared_hcd);
+   set_bit(HCD_FLAG_POLL_RH, >flags);
+   usb_hcd_poll_rh_status(hcd);
+   return ret;
 }
 
 static int __maybe_unused xhci_mtk_resume(struct device *dev)
@@ -660,10 +665,16 @@ static int __maybe_unused xhci_mtk_resume(struct device 
*dev)
struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev);
struct usb_hcd *hcd = mtk->hcd;
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+   int ret;
 
usb_wakeup_set(mtk, false);
-   xhci_mtk_clks_enable(mtk);
-   xhci_mtk_host_enable(mtk);
+   ret = xhci_mtk_clks_enable(mtk);
+   if (ret)
+   goto enable_wakeup;
+
+   ret = xhci_mtk_host_enable(mtk);
+   if (ret)
+   goto disable_clks;
 
xhci_dbg(xhci, "%s: restart port polling\n", __func__);
set_bit(HCD_FLAG_POLL_RH, >shared_hcd->flags);
@@ -671,6 +682,12 @@ static int __maybe_unused xhci_mtk_resume(struct device 
*dev)
set_bit(HCD_FLAG_POLL_RH, >flags);
usb_hcd_poll_rh_status(hcd);
return 0;
+
+disable_clks:
+   xhci_mtk_clks_disable(mtk);
+enable_wakeup:
+   usb_wakeup_set(mtk, true);
+   return ret;
 }
 
 static const struct dev_pm_ops xhci_mtk_pm_ops = {
-- 
2.18.0



[PATCH v2 5/5] usb: xhci-mtk: remove unused members

2021-04-09 Thread Chunfeng Yun
Now some members about phys and wakeup are not used anymore,
remove them.

Signed-off-by: Chunfeng Yun 
---
v2: no changes
---
 drivers/usb/host/xhci-mtk.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h
index 11996edc1967..7940593a3445 100644
--- a/drivers/usb/host/xhci-mtk.h
+++ b/drivers/usb/host/xhci-mtk.h
@@ -145,9 +145,6 @@ struct xhci_hcd_mtk {
struct regulator *vusb33;
struct regulator *vbus;
struct clk_bulk_data clks[BULK_CLKS_NUM];
-   struct regmap *pericfg;
-   struct phy **phys;
-   int num_phys;
bool lpm_support;
/* usb remote wakeup */
bool uwk_en;
-- 
2.18.0



[PATCH v3 6/6] perf arm-spe: Don't wait for PERF_RECORD_EXIT event

2021-04-09 Thread Leo Yan
When decode Arm SPE trace, it waits for PERF_RECORD_EXIT event (the last
perf event) for processing trace data, which is needless and even might
cause logic error, e.g. it might fail to correlate perf events with Arm
SPE events correctly.

So this patch removes the condition checking for PERF_RECORD_EXIT event.

Signed-off-by: Leo Yan 
---
 tools/perf/util/arm-spe.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c
index 8facda81a06c..5e98a29fcbdb 100644
--- a/tools/perf/util/arm-spe.c
+++ b/tools/perf/util/arm-spe.c
@@ -717,11 +717,7 @@ static int arm_spe_process_event(struct perf_session 
*session,
sample->time);
}
} else if (timestamp) {
-   if (event->header.type == PERF_RECORD_EXIT) {
-   err = arm_spe_process_queues(spe, timestamp);
-   if (err)
-   return err;
-   }
+   err = arm_spe_process_queues(spe, timestamp);
}
 
return err;
-- 
2.25.1



[PATCH v3 5/6] perf arm-spe: Bail out if the trace is later than perf event

2021-04-09 Thread Leo Yan
It's possible that record in Arm SPE trace is later than perf event and
vice versa.  This asks to correlate the perf events and Arm SPE
synthesized events to be processed in the manner of correct timing.

To achieve the time ordering, this patch reverses the flow, it firstly
calls arm_spe_sample() and then calls arm_spe_decode().  By comparing
the timestamp value and detect the perf event is coming earlier than Arm
SPE trace data, it bails out from the decoding loop, the last record is
pushed into auxtrace stack and is deferred to generate sample.  To track
the timestamp, everytime it updates timestamp for the latest record.

Signed-off-by: Leo Yan 
---
 tools/perf/util/arm-spe.c | 37 ++---
 1 file changed, 34 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c
index ec7df83b50fd..8facda81a06c 100644
--- a/tools/perf/util/arm-spe.c
+++ b/tools/perf/util/arm-spe.c
@@ -434,12 +434,36 @@ static int arm_spe_sample(struct arm_spe_queue *speq)
 static int arm_spe_run_decoder(struct arm_spe_queue *speq, u64 *timestamp)
 {
struct arm_spe *spe = speq->spe;
+   struct arm_spe_record *record;
int ret;
 
if (!spe->kernel_start)
spe->kernel_start = machine__kernel_start(spe->machine);
 
while (1) {
+   /*
+* The usual logic is firstly to decode the packets, and then
+* based the record to synthesize sample; but here the flow is
+* reversed: it calls arm_spe_sample() for synthesizing samples
+* prior to arm_spe_decode().
+*
+* Two reasons for this code logic:
+* 1. Firstly, when setup queue in arm_spe__setup_queue(), it
+* has decoded trace data and generated a record, but the record
+* is left to generate sample until run to here, so it's correct
+* to synthesize sample for the left record.
+* 2. After decoding trace data, it needs to compare the record
+* timestamp with the coming perf event, if the record timestamp
+* is later than the perf event, it needs bail out and pushs the
+* record into auxtrace heap, thus the record can be deferred to
+* synthesize sample until run to here at the next time; so this
+* can correlate samples between Arm SPE trace data and other
+* perf events with correct time ordering.
+*/
+   ret = arm_spe_sample(speq);
+   if (ret)
+   return ret;
+
ret = arm_spe_decode(speq->decoder);
if (!ret) {
pr_debug("No data or all data has been processed.\n");
@@ -453,10 +477,17 @@ static int arm_spe_run_decoder(struct arm_spe_queue 
*speq, u64 *timestamp)
if (ret < 0)
continue;
 
-   ret = arm_spe_sample(speq);
-   if (ret)
-   return ret;
+   record = >decoder->record;
 
+   /* Update timestamp for the last record */
+   if (record->timestamp > speq->timestamp)
+   speq->timestamp = record->timestamp;
+
+   /*
+* If the timestamp of the queue is later than timestamp of the
+* coming perf event, bail out so can allow the perf event to
+* be processed ahead.
+*/
if (!spe->timeless_decoding && speq->timestamp >= *timestamp) {
*timestamp = speq->timestamp;
return 0;
-- 
2.25.1



[PATCH v3 4/6] perf arm-spe: Assign kernel time to synthesized event

2021-04-09 Thread Leo Yan
In current code, it assigns the arch timer counter to the synthesized
samples Arm SPE trace, thus the samples don't contain the kernel time
but only contain the raw counter value.

To fix the issue, this patch converts the timer counter to kernel time
and assigns it to sample timestamp.

Signed-off-by: Leo Yan 
---
 tools/perf/util/arm-spe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c
index f66e10c62473..ec7df83b50fd 100644
--- a/tools/perf/util/arm-spe.c
+++ b/tools/perf/util/arm-spe.c
@@ -234,7 +234,7 @@ static void arm_spe_prep_sample(struct arm_spe *spe,
struct arm_spe_record *record = >decoder->record;
 
if (!spe->timeless_decoding)
-   sample->time = speq->timestamp;
+   sample->time = tsc_to_perf_time(record->timestamp, >tc);
 
sample->ip = record->from_ip;
sample->cpumode = arm_spe_cpumode(spe, sample->ip);
-- 
2.25.1



[PATCH v3 3/6] perf arm-spe: Convert event kernel time to counter value

2021-04-09 Thread Leo Yan
When handle a perf event, Arm SPE decoder needs to decide if this perf
event is earlier or later than the samples from Arm SPE trace data; to
do comparision, it needs to use the same unit for the time.

This patch converts the event kernel time to arch timer's counter value,
thus it can be used to compare with counter value contained in Arm SPE
Timestamp packet.

Signed-off-by: Leo Yan 
---
 tools/perf/util/arm-spe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c
index b48816d5c0b4..f66e10c62473 100644
--- a/tools/perf/util/arm-spe.c
+++ b/tools/perf/util/arm-spe.c
@@ -669,7 +669,7 @@ static int arm_spe_process_event(struct perf_session 
*session,
}
 
if (sample->time && (sample->time != (u64) -1))
-   timestamp = sample->time;
+   timestamp = perf_time_to_tsc(sample->time, >tc);
else
timestamp = 0;
 
-- 
2.25.1



[PATCH v3 2/6] perf arm-spe: Save clock parameters from TIME_CONV event

2021-04-09 Thread Leo Yan
During the recording phase, "perf record" tool synthesizes event
PERF_RECORD_TIME_CONV for the hardware clock parameters and saves the
event into the data file.

Afterwards, when processing the data file, the event TIME_CONV will be
processed at the very early time and is stored into session context.

This patch extracts these parameters from the session context and saves
into the structure "spe->tc" with the type perf_tsc_conversion, so that
the parameters are ready for conversion between clock counter and time
stamp.

Signed-off-by: Leo Yan 
---
 tools/perf/util/arm-spe.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c
index 2539d4baec44..b48816d5c0b4 100644
--- a/tools/perf/util/arm-spe.c
+++ b/tools/perf/util/arm-spe.c
@@ -26,6 +26,7 @@
 #include "symbol.h"
 #include "thread.h"
 #include "thread-stack.h"
+#include "tsc.h"
 #include "tool.h"
 #include "util/synthetic-events.h"
 
@@ -45,6 +46,8 @@ struct arm_spe {
struct machine  *machine;
u32 pmu_type;
 
+   struct perf_tsc_conversion  tc;
+
u8  timeless_decoding;
u8  data_queued;
 
@@ -1027,6 +1030,22 @@ int arm_spe_process_auxtrace_info(union perf_event 
*event,
spe->pmu_type = auxtrace_info->priv[ARM_SPE_PMU_TYPE];
 
spe->timeless_decoding = arm_spe__is_timeless_decoding(spe);
+
+   /*
+* The synthesized event PERF_RECORD_TIME_CONV has been handled
+* ahead and the parameters for hardware clock are stored in
+* the session context.  Passes these parameters to the structure
+* perf_tsc_conversion in "spe->tc", which is used for later
+* conversion between clock counter and timestamp.
+*/
+   spe->tc.time_shift = session->time_conv.time_shift;
+   spe->tc.time_mult = session->time_conv.time_mult;
+   spe->tc.time_zero = session->time_conv.time_zero;
+   spe->tc.time_cycles = session->time_conv.time_cycles;
+   spe->tc.time_mask = session->time_conv.time_mask;
+   spe->tc.cap_user_time_zero = session->time_conv.cap_user_time_zero;
+   spe->tc.cap_user_time_short = session->time_conv.cap_user_time_short;
+
spe->auxtrace.process_event = arm_spe_process_event;
spe->auxtrace.process_auxtrace_event = arm_spe_process_auxtrace_event;
spe->auxtrace.flush_events = arm_spe_flush;
-- 
2.25.1



[PATCH v3 1/6] perf arm-spe: Remove unused enum value ARM_SPE_PER_CPU_MMAPS

2021-04-09 Thread Leo Yan
The enum value 'ARM_SPE_PER_CPU_MMAPS' is never used so remove it.

Signed-off-by: Leo Yan 
---
 tools/perf/util/arm-spe.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tools/perf/util/arm-spe.h b/tools/perf/util/arm-spe.h
index 98d3235781c3..105ce0ea0a01 100644
--- a/tools/perf/util/arm-spe.h
+++ b/tools/perf/util/arm-spe.h
@@ -11,7 +11,6 @@
 
 enum {
ARM_SPE_PMU_TYPE,
-   ARM_SPE_PER_CPU_MMAPS,
ARM_SPE_AUXTRACE_PRIV_MAX,
 };
 
-- 
2.25.1



[PATCH v3 0/6] perf arm-spe: Enable timestamp

2021-04-09 Thread Leo Yan
This patch set is to enable timestamp for Arm SPE trace.  It reads out
TSC parameters from the TIME_CONV event, the parameters are used for
conversion between timer counter and kernel time and which is applied
for Arm SPE samples.

This version dropped the change for adding hardware clock parameters
into auxtrace info, alternatively, it utilizes the TIME_CONV event to
extract the clock parameters which is used for timestamp calculation.

This patch set can be clearly applied on perf/core branch with:

  commit 2c0cb9f56020 ("perf test: Add a shell test for 'perf stat 
--bpf-counters' new option")

Ths patch series has been tested on Hisilicon D06 platform.

Changes from v2:
* Changed to use TIME_CONV event for extracing clock parameters (Al).

Changes from v1:
* Rebased patch series on the latest perf/core branch;
* Fixed the patch for dumping TSC parameters to support both the
  older and new auxtrace info format.


Leo Yan (6):
  perf arm-spe: Remove unused enum value ARM_SPE_PER_CPU_MMAPS
  perf arm-spe: Save clock parameters from TIME_CONV event
  perf arm-spe: Convert event kernel time to counter value
  perf arm-spe: Assign kernel time to synthesized event
  perf arm-spe: Bail out if the trace is later than perf event
  perf arm-spe: Don't wait for PERF_RECORD_EXIT event

 tools/perf/util/arm-spe.c | 66 +--
 tools/perf/util/arm-spe.h |  1 -
 2 files changed, 56 insertions(+), 11 deletions(-)

-- 
2.25.1



Re: [PATCH v1] libnvdimm, dax: Fix a missing check in nd_dax_probe()

2021-04-09 Thread Dan Williams
On Fri, Apr 9, 2021 at 5:33 PM  wrote:
>
> From: Yingjie Wang 
>
> In nd_dax_probe(), nd_dax_alloc() may fail and return NULL.
> Check for NULL before attempting to
> use nd_dax to avoid a NULL pointer dereference.
>
> Fixes: c5ed9268643c ("libnvdimm, dax: autodetect support")
> Signed-off-by: Yingjie Wang 
> ---
>  drivers/nvdimm/dax_devs.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/nvdimm/dax_devs.c b/drivers/nvdimm/dax_devs.c
> index 99965077bac4..b1426ac03f01 100644
> --- a/drivers/nvdimm/dax_devs.c
> +++ b/drivers/nvdimm/dax_devs.c
> @@ -106,6 +106,8 @@ int nd_dax_probe(struct device *dev, struct 
> nd_namespace_common *ndns)
>
> nvdimm_bus_lock(>dev);

hmmm...

> nd_dax = nd_dax_alloc(nd_region);
> +   if (!nd_dax)
> +   return -ENOMEM;

Can you spot the bug this introduces? See the hint above.

> nd_pfn = _dax->nd_pfn;
> dax_dev = nd_pfn_devinit(nd_pfn, ndns);
> nvdimm_bus_unlock(>dev);
> --
> 2.7.4
>


Re: [PATCH 4.14 00/14] 4.14.230-rc1 review

2021-04-09 Thread Guenter Roeck
On Fri, Apr 09, 2021 at 01:13:06PM -0700, Guenter Roeck wrote:
> On Fri, Apr 09, 2021 at 11:53:25AM +0200, Greg Kroah-Hartman wrote:
> > This is the start of the stable review cycle for the 4.14.230 release.
> > There are 14 patches in this series, all will be posted as a response
> > to this one.  If anyone has any issues with these being applied, please
> > let me know.
> > 
> > Responses should be made by Sun, 11 Apr 2021 09:52:52 +.
> > Anything received after that time might be too late.
> > 
> 
> Build results:
>   total: 168 pass: 168 fail: 0
> Qemu test results:
>   total: 408 pass: 408 fail: 0
> 
> Tested-by: Guenter Roeck 
> 
> Having said this, I did see a spurious crash, and I see an unusual warning.
> I have seen the crash only once, but the warning happens with every boot.
> These are likely not new but exposed because I added network interface
> tests. This is all v4.14.y specific; I did not see it in other branches.
> See below for the tracebacks. Maybe someone has seen it before.
> 
> Thanks,
> Guenter
> 
> ---
> ftgmac100 1e66.ethernet eth0: NCSI interface down
> [ cut here ]
> WARNING: CPU: 0 PID: 477 at drivers/base/dma-mapping.c:325 
> remap_allocator_free+0x54/0x5c
> trying to free invalid coherent area: 909a1000
> Modules linked in:
> CPU: 0 PID: 477 Comm: ip Not tainted 4.14.230-rc1-00015-gbbc0ac1df344 #1
> Hardware name: Generic DT based system
> [<8000f8dc>] (unwind_backtrace) from [<8000d194>] (show_stack+0x10/0x14)
> [<8000d194>] (show_stack) from [<805a5a80>] (__warn+0xc0/0xf4)
> [<805a5a80>] (__warn) from [<800177b4>] (warn_slowpath_fmt+0x38/0x48)
> [<800177b4>] (warn_slowpath_fmt) from [<80010554>] 
> (remap_allocator_free+0x54/0x5c)
> [<80010554>] (remap_allocator_free) from [<80010e4c>] 
> (__arm_dma_free.constprop.0+0xec/0x13c)
> [<80010e4c>] (__arm_dma_free.constprop.0) from [<80429924>] 
> (ftgmac100_free_rings+0x17c/0x1f8)
> [<80429924>] (ftgmac100_free_rings) from [<80429a24>] 
> (ftgmac100_stop+0x84/0xa4)
> [<80429a24>] (ftgmac100_stop) from [<804e8a70>] (__dev_close_many+0xac/0x100)
> [<804e8a70>] (__dev_close_many) from [<804f0dc0>] 
> (__dev_change_flags+0xb4/0x1a0)
> [<804f0dc0>] (__dev_change_flags) from [<804f0ec4>] 
> (dev_change_flags+0x18/0x48)
> [<804f0ec4>] (dev_change_flags) from [<80561644>] (devinet_ioctl+0x6cc/0x808)
> [<80561644>] (devinet_ioctl) from [<804d1548>] (sock_ioctl+0x188/0x2e4)
> [<804d1548>] (sock_ioctl) from [<800eac80>] (do_vfs_ioctl+0x3a0/0x82c)
> [<800eac80>] (do_vfs_ioctl) from [<800eb140>] (SyS_ioctl+0x34/0x60)
> [<800eb140>] (SyS_ioctl) from [<8000a600>] (ret_fast_syscall+0x0/0x28)
> ---[ end trace c13f2f82f69274ad ]---
> 
> =
> 
> ftgmac100 1e66.ethernet eth0: NCSI interface up
> Unable to handle kernel NULL pointer dereference at virtual address 
> pgd = 9ec84000
> [] *pgd=9f7f6831, *pte=, *ppte=
> Internal error: Oops: 17 [#1] ARM
> Modules linked in:
> CPU: 0 PID: 397 Comm: default.script Not tainted 
> 4.14.230-rc1-00015-gbbc0ac1df344 #1
> Hardware name: Generic DT based system
> task: 9f5cc260 task.stack: 9ecee000
> PC is at anon_vma_clone+0x64/0x19c
> LR is at fs_reclaim_release+0x8/0x18
> pc : [<800c1ccc>]lr : [<80098b5c>]psr: a153
> sp : 9ecefe78  ip :   fp : 
> r10: 01000200  r9 : 9f7e6d10  r8 : 80cb9a44
> r7 : 9f7e0da0  r6 : 9f7e6d10  r5 : 9ed0f600  r4 : 9f5a562c
> r3 : 0030  r2 : 9fbdf618  r1 : 0034  r0 : 9ed0f600
> Flags: NzCv  IRQs on  FIQs off  Mode SVC_32  ISA ARM  Segment user
> Control: 00c5387d  Table: 9ec84008  DAC: 0055
> Process default.script (pid: 397, stack limit = 0x9ecee188)
> Stack: (0x9ecefe78 to 0x9ecf)
> fe60:   9f5a303c 9f5a3000
> fe80: 0002 9f7e0da0 9f7e0ab4 9f5a3000 9f77e600 9f7e0da0 9f5a3000 9f77e400
> fea0: 9f72dc64 800c1e28 9f7e0ab0 9f7e0ab4 0002 9f77e600 9f7e0da0 800161f8
> fec0: 9f5cc640 cacd966c 9f5cc260 cd397f94 80cb0afc  80016870 
> fee0:  9f69f2f8 9f7e0aa8 807ca224 9f7e0aa0 9f72dc70 9f69f100 0011
> ff00: 9f77e658 9f77e458 9eceff08 9eceff08 9f5cc650 0011 7eb26888 
> ff20:   9ecee000  76eff3a0 80016870  
> ff40:  7eb26888 9eceff78  9ecee000 76ec4a28 7eb26888 9eceff78
> ff60:  7eb26888 0008  0008 800245e4 76efdcd0 7eb26888
> ff80:  0002 8000a704 9ecee000  80016cd4  
> ffa0: 9ecee000 8000a520 76efdcd0 7eb26888 76efffcc 0001 76efe7ac 
> ffc0: 76efdcd0 7eb26888  0002 7eb26918 76efe000 76f00c60 76eff3a0
> ffe0: 000e0350 7eb26888 76e96b94 76e96b98 6150 76efffcc  
> [<800c1ccc>] (anon_vma_clone) from [<800c1e28>] (anon_vma_fork+0x24/0x138)
> [<800c1e28>] (anon_vma_fork) from [<800161f8>] 
> (copy_process.part.0+0x12a4/0x17dc)
> [<800161f8>] (copy_process.part.0) from [<80016870>] (_do_fork+0xa0/0x488)
> [<80016870>] 

[tip:sched/core] BUILD SUCCESS 4aed8aa41524a1fc6439171881c2bb7ace197528

2021-04-09 Thread kernel test robot
 defconfig
sh   allmodconfig
parisc  defconfig
s390 allyesconfig
s390 allmodconfig
parisc   allyesconfig
s390defconfig
sparcallyesconfig
sparc   defconfig
mips allyesconfig
mips allmodconfig
powerpc  allyesconfig
powerpc  allmodconfig
powerpc   allnoconfig
i386 randconfig-a006-20210409
i386 randconfig-a003-20210409
i386 randconfig-a001-20210409
i386 randconfig-a004-20210409
i386 randconfig-a002-20210409
i386 randconfig-a005-20210409
x86_64   randconfig-a014-20210409
x86_64   randconfig-a015-20210409
x86_64   randconfig-a012-20210409
x86_64   randconfig-a011-20210409
x86_64   randconfig-a013-20210409
x86_64   randconfig-a016-20210409
i386 randconfig-a014-20210409
i386 randconfig-a011-20210409
i386 randconfig-a016-20210409
i386 randconfig-a012-20210409
i386 randconfig-a013-20210409
i386 randconfig-a015-20210409
riscvnommu_virt_defconfig
riscv allnoconfig
riscv   defconfig
riscv  rv32_defconfig
um   allmodconfig
um   allyesconfig
um  defconfig
x86_64rhel-8.3-kselftests
x86_64  defconfig
x86_64   rhel-8.3
x86_64  rhel-8.3-kbuiltin
x86_64  kexec

clang tested configs:
x86_64   randconfig-a004-20210409
x86_64   randconfig-a005-20210409
x86_64   randconfig-a003-20210409
x86_64   randconfig-a001-20210409
x86_64   randconfig-a002-20210409
x86_64   randconfig-a006-20210409

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


Re: [PATCH] watchdog: mtk: support pre-timeout when the bark irq is available

2021-04-09 Thread Guenter Roeck
On 4/9/21 8:11 PM, 王擎 wrote:
> 
>> On 4/9/21 7:42 PM, 王擎 wrote:
>>>
 On 4/9/21 2:55 AM, Wang Qing wrote:
> Use the bark interrupt as the pretimeout notifier if available.
>
> By default, the pretimeout notification shall occur one second earlier
> than the timeout.
>
> Signed-off-by: Wang Qing 
> ---
>  drivers/watchdog/mtk_wdt.c | 47 
> +++---
>  1 file changed, 44 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/watchdog/mtk_wdt.c b/drivers/watchdog/mtk_wdt.c
> index 97ca993..8b919cc
> --- a/drivers/watchdog/mtk_wdt.c
> +++ b/drivers/watchdog/mtk_wdt.c
> @@ -25,6 +25,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #define WDT_MAX_TIMEOUT  31
>  #define WDT_MIN_TIMEOUT  1
> @@ -234,18 +235,35 @@ static int mtk_wdt_start(struct watchdog_device 
> *wdt_dev)
>   void __iomem *wdt_base = mtk_wdt->wdt_base;
>   int ret;
>  
> - ret = mtk_wdt_set_timeout(wdt_dev, wdt_dev->timeout);
> + ret = mtk_wdt_set_timeout(wdt_dev, wdt_dev->timeout - 
> wdt_dev->pretimeout);

 That looks suspiciously like the real watchdog won't happen at all.
 What will happen if the pretimeout governor is set to none ?

 Guenter

>>> The pretimeout governor is panic by default. If pretimeout is enabled and 
>>> the governor is
>>> set to none, it means the timeout behavior does not need to be processed, 
>>> only printing.
>>>
>>
>> That was not my question. My question was if the real timeout happens in 
>> that case.
>>
>> Guenter
>>
> Yes, the real timeout will happen. After WDT timeout, IRQ is sent out instead 
> of 
> reset signal first. In order to ensure that CPU does not get stuck after IRQ 
> is sent out, 
> WDT will time again and send reset signal to reset.
> 

When will that be, or in other words how does the chip know when to time out ?
After all, only a single timeout value is written into the chip. I don't see how
it would know to reset the chip after wdt_dev->timeout.

Guenter




Re: [External] Re: [RFC PATCH v2 09/18] mm: vmscan: remove noinline_for_stack

2021-04-09 Thread Muchun Song
On Sat, Apr 10, 2021 at 2:31 AM Johannes Weiner  wrote:
>
> On Fri, Apr 09, 2021 at 08:29:50PM +0800, Muchun Song wrote:
> > The noinline_for_stack is introduced by commit 666356297ec4 ("vmscan:
> > set up pagevec as late as possible in shrink_inactive_list()"), its
> > purpose is to delay the allocation of pagevec as late as possible to
> > save stack memory. But the commit 2bcf88796381 ("mm: take pagevecs off
> > reclaim stack") replace pagevecs by lists of pages_to_free. So we do
> > not need noinline_for_stack, just remove it (let the compiler decide
> > whether to inline).
> >
> > Signed-off-by: Muchun Song 
>
> Good catch.
>
> Acked-by: Johannes Weiner 
>
> Since this patch is somewhat independent of the rest of the series,
> you may want to put it in the very beginning, or even submit it
> separately, to keep the main series as compact as possible. Reviewers
> can be more hesitant to get involved with larger series ;)

OK. I will gather all the cleanup patches into a separate series.
Thanks for your suggestion.


Re: [PATCH] um: add 2 missing libs to fix various build errors

2021-04-09 Thread Randy Dunlap
On 4/4/21 11:20 AM, Randy Dunlap wrote:
> Fix many build errors (at least 18 build error reports) for uml on i386
> by adding 2 more library object files. All missing symbols are
> either cmpxchg8b_emu or atomic*386.
> 
> Here are a few examples of the build errors that are eliminated:
> 
>/usr/bin/ld: core.c:(.text+0xd83): undefined reference to `cmpxchg8b_emu'
>/usr/bin/ld: core.c:(.text+0x2bb2): undefined reference to 
> `atomic64_add_386'
>/usr/bin/ld: core.c:(.text+0x2c5d): undefined reference to 
> `atomic64_xchg_386'
>syscall.c:(.text+0x2f49): undefined reference to `atomic64_set_386'
>/usr/bin/ld: syscall.c:(.text+0x2f54): undefined reference to 
> `atomic64_set_386'
>syscall.c:(.text+0x33a4): undefined reference to `atomic64_inc_386'
>/usr/bin/ld: syscall.c:(.text+0x33ac): undefined reference to 
> `atomic64_inc_386'
>/usr/bin/ld: net/ipv4/inet_timewait_sock.o: in function `inet_twsk_alloc':
>inet_timewait_sock.c:(.text+0x3d1): undefined reference to 
> `atomic64_read_386'
>/usr/bin/ld: inet_timewait_sock.c:(.text+0x3dd): undefined reference to 
> `atomic64_set_386'
>/usr/bin/ld: net/ipv4/inet_connection_sock.o: in function 
> `inet_csk_clone_lock':
>inet_connection_sock.c:(.text+0x1d74): undefined reference to 
> `atomic64_read_386'
>/usr/bin/ld: inet_connection_sock.c:(.text+0x1d80): undefined reference to 
> `atomic64_set_386'
>/usr/bin/ld: net/ipv4/tcp_input.o: in function `inet_reqsk_alloc':
>tcp_input.c:(.text+0xa345): undefined reference to `atomic64_set_386'
>/usr/bin/ld: net/mac80211/wpa.o: in function 
> `ieee80211_crypto_tkip_encrypt':
>wpa.c:(.text+0x739): undefined reference to `atomic64_inc_return_386'
> 
> Signed-off-by: Randy Dunlap 
> Reported-by: kernel test robot 
> Cc: Brendan Jackman 
> Cc: Alexei Starovoitov 
> Cc: kbuild-...@lists.01.org
> Cc: Jeff Dike 
> Cc: Richard Weinberger 
> Cc: Anton Ivanov 
> Cc: linux...@lists.infradead.org
> Cc: Johannes Berg 
> Cc: Johannes Berg 
> ---
> My UML on i386 build environment is br0ken so this is not tested other
> than to see that the .o files are built as expected.
> If someone can test/verify it, please respond. Thanks.

Hi,
Instead of trying to build this on x86_64, I powered up my 32-bit x86
laptop and verified that this patch fixes the build errors of
undefined references to cmpxchg8b_emu() and atomic64_*_386() functions.

There are still some build errors in 2 object files:

/usr/lib/gcc/i586-suse-linux/10/../../../../i586-suse-linux/bin/ld: 
kernel/irq/generic-chip.o:(.altinstructions+0x8): undefined reference to 
`X86_FEATURE_XMM2'
/usr/lib/gcc/i586-suse-linux/10/../../../../i586-suse-linux/bin/ld: 
kernel/irq/generic-chip.o:(.altinstructions+0x15): undefined reference to 
`X86_FEATURE_XMM2'
/usr/lib/gcc/i586-suse-linux/10/../../../../i586-suse-linux/bin/ld: 
kernel/irq/generic-chip.o:(.altinstructions+0x22): undefined reference to 
`X86_FEATURE_XMM'
/usr/lib/gcc/i586-suse-linux/10/../../../../i586-suse-linux/bin/ld: 
kernel/irq/generic-chip.o:(.altinstructions+0x2f): undefined reference to 
`X86_FEATURE_XMM'
/usr/lib/gcc/i586-suse-linux/10/../../../../i586-suse-linux/bin/ld: 
kernel/irq/generic-chip.o:(.altinstructions+0x3c): undefined reference to 
`X86_FEATURE_XMM'
/usr/lib/gcc/i586-suse-linux/10/../../../../i586-suse-linux/bin/ld: 
kernel/irq/generic-chip.o:(.altinstructions+0x49): undefined reference to 
`X86_FEATURE_XMM'
/usr/lib/gcc/i586-suse-linux/10/../../../../i586-suse-linux/bin/ld: 
kernel/irq/generic-chip.o:(.altinstructions+0x56): undefined reference to 
`X86_FEATURE_XMM'
/usr/lib/gcc/i586-suse-linux/10/../../../../i586-suse-linux/bin/ld: 
kernel/irq/generic-chip.o:(.altinstructions+0x63): more undefined references to 
`X86_FEATURE_XMM' follow

and

/usr/lib/gcc/i586-suse-linux/10/../../../../i586-suse-linux/bin/ld: 
drivers/fpga/altera-pr-ip-core.o:(.altinstructions+0x8): undefined reference to 
`X86_FEATURE_XMM2'
/usr/lib/gcc/i586-suse-linux/10/../../../../i586-suse-linux/bin/ld: 
drivers/fpga/altera-pr-ip-core.o:(.altinstructions+0x15): undefined reference 
to `X86_FEATURE_XMM2'
/usr/lib/gcc/i586-suse-linux/10/../../../../i586-suse-linux/bin/ld: 
drivers/fpga/altera-pr-ip-core.o:(.altinstructions+0x22): undefined reference 
to `X86_FEATURE_XMM'
/usr/lib/gcc/i586-suse-linux/10/../../../../i586-suse-linux/bin/ld: 
drivers/fpga/altera-pr-ip-core.o:(.altinstructions+0x2f): undefined reference 
to `X86_FEATURE_XMM'
/usr/lib/gcc/i586-suse-linux/10/../../../../i586-suse-linux/bin/ld: 
drivers/fpga/altera-pr-ip-core.o:(.altinstructions+0x3c): undefined reference 
to `X86_FEATURE_XMM'
/usr/lib/gcc/i586-suse-linux/10/../../../../i586-suse-linux/bin/ld: 
drivers/fpga/altera-pr-ip-core.o:(.altinstructions+0x49): undefined reference 
to `X86_FEATURE_XMM'
/usr/lib/gcc/i586-suse-linux/10/../../../../i586-suse-linux/bin/ld: 
drivers/fpga/altera-pr-ip-core.o:(.altinstructions+0x56): undefined reference 
to `X86_FEATURE_XMM'

Re: [PATCH net-next 0/7] net: ipa: a few small fixes

2021-04-09 Thread patchwork-bot+netdevbpf
Hello:

This series was applied to netdev/net-next.git (refs/heads/master):

On Fri,  9 Apr 2021 13:07:15 -0500 you wrote:
> This series implements some minor bug fixes or improvements.
> 
> The first patch removes an apparently unnecessary restriction, which
> results in an error on a 32-bit ARM build.
> 
> The second makes a definition used for SDM845 match what is used in
> the downstream code.
> 
> [...]

Here is the summary with links:
  - [net-next,1/7] net: ipa: relax pool entry size requirement
https://git.kernel.org/netdev/net-next/c/7ad3bd52cbcb
  - [net-next,2/7] net: ipa: update sequence type for modem TX endpoint
https://git.kernel.org/netdev/net-next/c/49e76a418981
  - [net-next,3/7] net: ipa: only set endpoint netdev pointer when in use
https://git.kernel.org/netdev/net-next/c/57f63faf0562
  - [net-next,4/7] net: ipa: ipa_stop() does not return an error
https://git.kernel.org/netdev/net-next/c/077e770f2601
  - [net-next,5/7] net: ipa: get rid of empty IPA functions
https://git.kernel.org/netdev/net-next/c/74858b63c47c
  - [net-next,6/7] net: ipa: get rid of empty GSI functions
https://git.kernel.org/netdev/net-next/c/57ab8ca42fa0
  - [net-next,7/7] net: ipa: three small fixes
https://git.kernel.org/netdev/net-next/c/602a1c76f847

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html




Re: [PATCH 10/10] mm/migrate: new zone_reclaim_mode to enable reclaim migration

2021-04-09 Thread Wei Xu
On Thu, Apr 1, 2021 at 11:35 AM Dave Hansen  wrote:
> This proposes extending the existing "zone_reclaim_mode" (now
> now really node_reclaim_mode) as a method to enable it.

Nit: now now -> now

> We are open to any alternative that allows end users to enable
> this mechanism or disable it it workload harm is detected (just
> like traditional autonuma).

Nit: it it -> it if

> diff -puN mm/vmscan.c~RECLAIM_MIGRATE mm/vmscan.c
> --- a/mm/vmscan.c~RECLAIM_MIGRATE   2021-03-31 15:17:40.339000190 -0700
> +++ b/mm/vmscan.c   2021-03-31 15:17:40.357000190 -0700
> @@ -1074,6 +1074,9 @@ static bool migrate_demote_page_ok(struc
> VM_BUG_ON_PAGE(PageHuge(page), page);
> VM_BUG_ON_PAGE(PageLRU(page), page);
>
> +   if (!(node_reclaim_mode & RECLAIM_MIGRATE))
> +   return false;
> +

As I commented on an earlier patch in this series, the RECLAIM_MIGRATE check
needs to be added to other new callers of next_demotion_node() as well to avoid
unnecessarily splitting THP pages when neither swap nor RECLAIM_MIGRATE
is enabled.  It can be too late to check RECLAIM_MIGRATE only in
migrate_demote_page_ok().


Re: [PATCH] Documentation: kunit: add tips for running KUnit

2021-04-09 Thread David Gow
Thanks for writing this: it's good to have these things documented at last!

There are definitely a few things this document points out which still
need deciding, which does make this document lean a bit into "design
discussion" territory in a few of the notes. This doesn't bother me --
it's an accurate description of the state of things -- but I wouldn't
want this documentation held up too long because of these sorts of
TODOs (and can definitely see how having too many of them might
discourage KUnit use a bit). Particularly things like the
".kunitconfig" fragment file feature stuff: I feel that's something
better discussed on patches adding/using the feature than in the
documentation / reviews of the documentation, so I'd rather drop or
simplify those '..note:'s than bokeshed about it here (something I'm a
little guilty of below).

Otherwise, a few minor comments and nitpicks:

-- David

On Sat, Apr 10, 2021 at 2:01 AM Daniel Latypov  wrote:
>
> This is long overdue.
>
> There are several things that aren't nailed down (in-tree
> .kunitconfig's), or partially broken (GCOV on UML), but having them
> documented, warts and all, is better than having nothing.
>
> This covers a bunch of the more recent features
> * kunit_filter_glob
> * kunit.py run --kunitconfig
> * kunit.py run --alltests
> * slightly more detail on building tests as modules
> * CONFIG_KUNIT_DEBUGFS
>
> By my count, the only headline features now not mentioned are the KASAN
> integration and KernelCI json output support (kunit.py run --json).
>
> And then it also discusses how to get code coverage reports under UML
> and non-UML since this is a question people have repeatedly asked.
>
> Non-UML coverage collection is no differnt from normal, but we should
> probably explicitly call thsi out.

Nit: typos in 'different' and 'this'.

>
> As for UML, I was able to get it working again with two small hacks.*
> E.g. with CONFIG_KUNIT=y && CONFIG_KUNIT_ALL_TESTS=y
>   Overall coverage rate:
> lines..: 15.1% (18294 of 120776 lines)
> functions..: 16.8% (1860 of 11050 functions)
>
> *Switching to use gcc/gcov-6 and not using uml_abort().
> I've documented these hacks in "Notes" but left TODOs for
> brendanhigg...@google.com who tracked down the runtime issue in GCC.
> To be clear: these are not issues specific to KUnit, but rather to UML.

(We should probably note where uml_abort() needs to be replaced if
we're mentioning this, though doing so below in the more detailed
section may be more useful.)

>
> Signed-off-by: Daniel Latypov 
> ---
>  Documentation/dev-tools/kunit/index.rst   |   1 +
>  .../dev-tools/kunit/running_tips.rst  | 278 ++
>  Documentation/dev-tools/kunit/start.rst   |   2 +
>  3 files changed, 281 insertions(+)
>  create mode 100644 Documentation/dev-tools/kunit/running_tips.rst
>
> diff --git a/Documentation/dev-tools/kunit/index.rst 
> b/Documentation/dev-tools/kunit/index.rst
> index 848478838347..7f7cf8d2ab20 100644
> --- a/Documentation/dev-tools/kunit/index.rst
> +++ b/Documentation/dev-tools/kunit/index.rst
> @@ -14,6 +14,7 @@ KUnit - Unit Testing for the Linux Kernel
> style
> faq
> tips
> +   running_tips
>
>  What is KUnit?
>  ==
> diff --git a/Documentation/dev-tools/kunit/running_tips.rst 
> b/Documentation/dev-tools/kunit/running_tips.rst
> new file mode 100644
> index ..d38e665e530f
> --- /dev/null
> +++ b/Documentation/dev-tools/kunit/running_tips.rst
> @@ -0,0 +1,278 @@
> +.. SPDX-License-Identifier: GPL-2.0
> +
> +
> +Tips For Running KUnit Tests
> +
> +
> +Using ``kunit.py run`` ("kunit tool")
> +=
> +
> +Running from any directory
> +--
> +
> +It can be handy to create a bash function like:
> +
> +.. code-block:: bash
> +
> +   function run_kunit() {
> + ( cd "$(git rev-parse --show-toplevel)" && 
> ./tools/testing/kunit/kunit.py run $@ )
> +   }
> +
> +.. note::
> +   Early versions of ``kunit.py`` (before 5.6) didn't work unless run 
> from
> +   the kernel root, hence the use of a subshell and ``cd``.
> +
> +Running a subset of tests
> +-
> +
> +``kunit.py run`` accepts an optional glob argument to filter tests. Currently
> +this only matches against suite names, but this may change in the future.
> +
> +Say that we wanted to run the sysctl tests, we could do so via:
> +
> +.. code-block:: bash
> +
> +   $ echo -e 'CONFIG_KUNIT=y\nCONFIG_KUNIT_ALL_TESTS=y' > 
> .kunit/.kunitconfig
> +   $ ./tools/testing/kunit/kunit.py run 'sysctl*'
> +
> +We're paying the cost of building more tests than we need this way, but it's
> +easier than fiddling with ``.kunitconfig`` files or commenting out
> +``kunit_suite``'s.
> +
> +However, if we wanted to define a set of tests in a less ad hoc way, the next
> +tip is useful.
> +
> +Defining a set of tests
> 

Re: [PATCH 1/2] linux/kconfig.h: replace IF_ENABLED() with PTR_IF() in

2021-04-09 Thread Masahiro Yamada
On Fri, Apr 9, 2021 at 6:24 PM Andy Shevchenko
 wrote:
>
> On Fri, Apr 9, 2021 at 12:00 AM Masahiro Yamada  wrote:
> >
> >  is included from all the kernel-space source files,
> > including C, assembly, linker scripts. It is intended to contain minimal
>
> a minimal
>
> > set of macros to evaluate CONFIG options.
> >
> > IF_ENABLED() is an intruder here because (x ? y : z) is C code, which
> > should not be included from assembly files or linker scripts.
> >
> > Also,  is no longer self-contained because NULL is
> > defined in .
> >
> > Move IF_ENABLED() out to  as PTR_IF().
> >
> > PTR_IF(IS_ENABLED(CONFIG_FOO), ...) is slightly longer than
> > IF_ENABLED(CONFIG_FOO, ...), but it is not a big deal because
> > sub-systems often define dedicated macros such as of_match_ptr(),
> > pm_ptr() etc. for common use-cases.
>
> >  include/linux/kernel.h|  2 ++
>
> Why kernel.h? Shouldn't it belong to a particular domain with a
> respective header file?
>
> Really what we have in the kernel.h right now is a complete train
> wreck of something.
> We have to define what exactly is kernel.h for?


 contains random utility macros.

I did not find a good header to put it in otherwise.


>
> Arnd? Others? Shall we start a wider discussion on the topic?
>
> --
> With Best Regards,
> Andy Shevchenko


--
Best Regards
Masahiro Yamada


[PATCH -next] nvmem: sprd: Add missing MODULE_DEVICE_TABLE

2021-04-09 Thread Bixuan Cui
This patch adds missing MODULE_DEVICE_TABLE definition which generates
correct modalias for automatic loading of this driver when it is built
as an external module.

Reported-by: Hulk Robot 
Signed-off-by: Bixuan Cui 
---
 drivers/nvmem/sprd-efuse.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/nvmem/sprd-efuse.c b/drivers/nvmem/sprd-efuse.c
index 59523245db8a..5d394559edf2 100644
--- a/drivers/nvmem/sprd-efuse.c
+++ b/drivers/nvmem/sprd-efuse.c
@@ -425,6 +425,7 @@ static const struct of_device_id sprd_efuse_of_match[] = {
{ .compatible = "sprd,ums312-efuse", .data = _data },
{ }
 };
+MODULE_DEVICE_TABLE(of, sprd_efuse_of_match);
 
 static struct platform_driver sprd_efuse_driver = {
.probe = sprd_efuse_probe,



[PATCH -next] staging: ralink-gdma: Add missing MODULE_DEVICE_TABLE

2021-04-09 Thread Bixuan Cui
This patch adds missing MODULE_DEVICE_TABLE definition which generates
correct modalias for automatic loading of this driver when it is built
as an external module.

Reported-by: Hulk Robot 
Signed-off-by: Bixuan Cui 
---
 drivers/staging/ralink-gdma/ralink-gdma.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/ralink-gdma/ralink-gdma.c 
b/drivers/staging/ralink-gdma/ralink-gdma.c
index 3c26b665ee7c..33e28ccf4d85 100644
--- a/drivers/staging/ralink-gdma/ralink-gdma.c
+++ b/drivers/staging/ralink-gdma/ralink-gdma.c
@@ -788,6 +788,7 @@ static const struct of_device_id gdma_of_match_table[] = {
{ .compatible = "ralink,rt3883-gdma", .data = _gdma_data },
{ },
 };
+MODULE_DEVICE_TABLE(of, gdma_of_match_table);
 
 static int gdma_dma_probe(struct platform_device *pdev)
 {



[PATCH -next] usb: dwc3: qcom: Remove redundant dev_err call in dwc3_qcom_probe()

2021-04-09 Thread Bixuan Cui
There is a error message within devm_ioremap_resource
already, so remove the dev_err call to avoid redundant
error message.

Reported-by: Hulk Robot 
Signed-off-by: Bixuan Cui 
---
 drivers/usb/dwc3/dwc3-qcom.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
index e37cc58dfa55..726d5048d87c 100644
--- a/drivers/usb/dwc3/dwc3-qcom.c
+++ b/drivers/usb/dwc3/dwc3-qcom.c
@@ -774,7 +774,6 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
 
qcom->qscratch_base = devm_ioremap_resource(dev, parent_res);
if (IS_ERR(qcom->qscratch_base)) {
-   dev_err(dev, "failed to map qscratch, err=%d\n", ret);
ret = PTR_ERR(qcom->qscratch_base);
goto clk_disable;
}



Re: [PATCH 06/10] mm/vmscan: add page demotion counter

2021-04-09 Thread Wei Xu
On Thu, Apr 1, 2021 at 11:35 AM Dave Hansen  wrote:
>
>
> From: Yang Shi 
>
> Account the number of demoted pages into reclaim_state->nr_demoted.
>
> Add pgdemote_kswapd and pgdemote_direct VM counters showed in
> /proc/vmstat.
>
> [ daveh:
>- __count_vm_events() a bit, and made them look at the THP
>  size directly rather than getting data from migrate_pages()
> ]
>
> Signed-off-by: Yang Shi 
> Signed-off-by: Dave Hansen 
> Reviewed-by: Yang Shi 
> Cc: Wei Xu 
> Cc: David Rientjes 
> Cc: Huang Ying 
> Cc: Dan Williams 
> Cc: David Hildenbrand 
> Cc: osalvador 

These counters can be more useful if they are per-node.

Reviewed-by: Wei Xu 


Re: [PATCH 05/10] mm/migrate: demote pages during reclaim

2021-04-09 Thread Wei Xu
> +static unsigned int demote_page_list(struct list_head *demote_pages,
> +struct pglist_data *pgdat,
> +struct scan_control *sc)

sc is not needed and can be removed from demote_page_list().

Reviewed-by: Wei Xu 


[PATCH -next] drm/mediatek: Fix PM reference leak in mtk_crtc_ddp_hw_init()

2021-04-09 Thread Wang Li
pm_runtime_get_sync will increment pm usage counter even it failed.
Forgetting to putting operation will result in reference leak here.
Fix it by replacing it with pm_runtime_resume_and_get to keep usage
counter balanced.

Reported-by: Hulk Robot 
Signed-off-by: Wang Li 
---
 drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c 
b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
index 54ab3a324752..f1954242d8f6 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
@@ -259,7 +259,7 @@ static int mtk_crtc_ddp_hw_init(struct mtk_drm_crtc 
*mtk_crtc)
drm_connector_list_iter_end(_iter);
}
 
-   ret = pm_runtime_get_sync(crtc->dev->dev);
+   ret = pm_runtime_resume_and_get(crtc->dev->dev);
if (ret < 0) {
DRM_ERROR("Failed to enable power domain: %d\n", ret);
return ret;
-- 
2.17.1



Re: [PATCH] ext4: fix debug format string warning

2021-04-09 Thread tytso
On Fri, Apr 09, 2021 at 10:12:05PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann 
> 
> Using no_printk() for jbd_debug() revealed two warnings:
> 
> fs/jbd2/recovery.c: In function 'fc_do_one_pass':
> fs/jbd2/recovery.c:256:30: error: format '%d' expects a matching 'int' 
> argument [-Werror=format=]
>   256 | jbd_debug(3, "Processing fast commit blk with seq 
> %d");
>   |  ^~~~
> fs/ext4/fast_commit.c: In function 'ext4_fc_replay_add_range':
> fs/ext4/fast_commit.c:1732:30: error: format '%d' expects argument of type 
> 'int', but argument 2 has type 'long unsigned int' [-Werror=format=]
>  1732 | jbd_debug(1, "Converting from %d to %d %lld",
> 
> The first one was added incorrectly, and was also missing a few newlines
> in debug output, and the second one happened when the type of an
> argument changed.
> 
> Reported-by: kernel test robot 
> Fixes: d556435156b7 ("jbd2: avoid -Wempty-body warnings")
> Fixes: 6db074618969 ("ext4: use BIT() macro for BH_** state bits")
> Fixes: 5b849b5f96b4 ("jbd2: fast commit recovery path")
> Signed-off-by: Arnd Bergmann 

Thanks, applied, with one change.

> diff --git a/fs/jbd2/recovery.c b/fs/jbd2/recovery.c
> index 69f18fe20923..60601c5779f1 100644
> --- a/fs/jbd2/recovery.c
> +++ b/fs/jbd2/recovery.c
> @@ -245,15 +245,15 @@ static int fc_do_one_pass(journal_t *journal,
> 
>  
>   if (err) {
> - jbd_debug(3, "Fast commit replay: read error");
> + jbd_debug(3, "Fast commit replay: read error\n");
>   break;
>   }
>  
> - jbd_debug(3, "Processing fast commit blk with seq %d");
> + jbd_debug(3, "Processing fast commit blk with seq\n");

This debug statement isn't adding any real value, so I just removed
it.

- Ted


Re: [PATCH 0/8] EXT4: Trivial typo fixes

2021-04-09 Thread Theodore Ts'o
On Sat, Mar 27, 2021 at 04:00:04PM +0530, Bhaskar Chowdhury wrote:
> This patch series fixed few mundane typos in the below specific files.
> 
> Bhaskar Chowdhury (8):
>   EXT4: migrate.c: Fixed few typos
>   EXT4: namei.c: Fixed a typo
>   EXT4: inline.c: A typo fixed
>   Fix a typo
>   EXT4: indirect.c: A trivial typo fix
>   EXT4: xattr.c: Mundane typo fix
>   EXT4: fast_commit.c: A mere typo fix
>   EXT4: mballoc.h: Single typo fix
>
>  fs/ext4/fast_commit.c | 2 +-
>  fs/ext4/indirect.c| 2 +-
>  fs/ext4/inline.c  | 2 +-
>  fs/ext4/inode.c   | 2 +-
>  fs/ext4/mballoc.h | 2 +-
>  fs/ext4/migrate.c | 6 +++---
>  fs/ext4/namei.c   | 8 
>  fs/ext4/xattr.c   | 2 +-
>  8 files changed, 13 insertions(+), 13 deletions(-)

I've applied this patch series folded together into a single patch.

  - Ted


[PATCH] perf session: Dump PERF_RECORD_TIME_CONV event

2021-04-09 Thread Leo Yan
Now perf tool uses the common stub function process_event_op2_stub() for
dumping TIME_CONV event, thus it doesn't output the clock parameters
contained in the event.

This patch adds the callback function for dumping the hardware clock
parameters in TIME_CONV event.

Before:

  # perf report -D

  0x978 [0x38]: event: 79
  .
  . ... raw event: size 56 bytes
  .  :  4f 00 00 00 00 00 38 00 15 00 00 00 00 00 00 00  O.8.
  .  0010:  00 00 40 01 00 00 00 00 86 89 0b bf df ff ff ff  
..@
  .  0020:  d1 c1 b2 39 03 00 00 00 ff ff ff ff ff ff ff 00  
9.
  .  0030:  01 01 00 00 00 00 00 00  

  0 0 0x978 [0x38]: PERF_RECORD_TIME_CONV
  : unhandled!

  [...]

After:

  # perf report -D

  0x978 [0x38]: event: 79
  .
  . ... raw event: size 56 bytes
  .  :  4f 00 00 00 00 00 38 00 15 00 00 00 00 00 00 00  O.8.
  .  0010:  00 00 40 01 00 00 00 00 86 89 0b bf df ff ff ff  
..@
  .  0020:  d1 c1 b2 39 03 00 00 00 ff ff ff ff ff ff ff 00  
9.
  .  0030:  01 01 00 00 00 00 00 00  

  0 0 0x978 [0x38]: PERF_RECORD_TIME_CONV
  ... Time Shift  21
  ... Time Muliplier  20971520
  ... Time Zero   18446743935180835206
  ... Time Cycles 13852918225
  ... Time Mask   0xff
  ... Cap Time Zero   1
  ... Cap Time Short  1
  : unhandled!

  [...]

Signed-off-by: Leo Yan 
---
 tools/perf/util/session.c | 13 -
 tools/perf/util/tsc.c | 18 ++
 tools/perf/util/tsc.h |  4 
 3 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 9a8808507bd9..75931c8054aa 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -29,6 +29,7 @@
 #include "thread-stack.h"
 #include "sample-raw.h"
 #include "stat.h"
+#include "tsc.h"
 #include "ui/progress.h"
 #include "../perf.h"
 #include "arch/common.h"
@@ -451,6 +452,16 @@ static int process_stat_round_stub(struct perf_session 
*perf_session __maybe_unu
return 0;
 }
 
+static int process_event_time_conv_stub(struct perf_session *perf_session 
__maybe_unused,
+   union perf_event *event)
+{
+   if (dump_trace)
+   perf_event__fprintf_time_conv(event, stdout);
+
+   dump_printf(": unhandled!\n");
+   return 0;
+}
+
 static int perf_session__process_compressed_event_stub(struct perf_session 
*session __maybe_unused,
   union perf_event *event 
__maybe_unused,
   u64 file_offset 
__maybe_unused)
@@ -532,7 +543,7 @@ void perf_tool__fill_defaults(struct perf_tool *tool)
if (tool->stat_round == NULL)
tool->stat_round = process_stat_round_stub;
if (tool->time_conv == NULL)
-   tool->time_conv = process_event_op2_stub;
+   tool->time_conv = process_event_time_conv_stub;
if (tool->feature == NULL)
tool->feature = process_event_op2_stub;
if (tool->compressed == NULL)
diff --git a/tools/perf/util/tsc.c b/tools/perf/util/tsc.c
index 62b4c75c966c..4ac3cc72f3e1 100644
--- a/tools/perf/util/tsc.c
+++ b/tools/perf/util/tsc.c
@@ -1,5 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 #include 
+#include 
+#include 
 
 #include 
 #include 
@@ -110,3 +112,19 @@ u64 __weak rdtsc(void)
 {
return 0;
 }
+
+size_t perf_event__fprintf_time_conv(union perf_event *event, FILE *fp)
+{
+   struct perf_record_time_conv *tc = (struct perf_record_time_conv 
*)event;
+   size_t ret;
+
+   ret  = fprintf(fp, "\n... Time Shift  %" PRI_lu64 "\n", 
tc->time_shift);
+   ret += fprintf(fp, "... Time Muliplier  %" PRI_lu64 "\n", 
tc->time_mult);
+   ret += fprintf(fp, "... Time Zero   %" PRI_lu64 "\n", 
tc->time_zero);
+   ret += fprintf(fp, "... Time Cycles %" PRI_lu64 "\n", 
tc->time_cycles);
+   ret += fprintf(fp, "... Time Mask   %#" PRI_lx64 "\n", 
tc->time_mask);
+   ret += fprintf(fp, "... Cap Time Zero   %" PRId32 "\n", 
tc->cap_user_time_zero);
+   ret += fprintf(fp, "... Cap Time Short  %" PRId32 "\n", 
tc->cap_user_time_short);
+
+   return ret;
+}
diff --git a/tools/perf/util/tsc.h b/tools/perf/util/tsc.h
index 72a15419f3b3..7d83a31732a7 100644
--- a/tools/perf/util/tsc.h
+++ b/tools/perf/util/tsc.h
@@ -4,6 +4,8 @@
 
 #include 
 
+#include "event.h"
+
 struct perf_tsc_conversion {
u16 time_shift;
u32 time_mult;
@@ -24,4 +26,6 @@ u64 perf_time_to_tsc(u64 ns, struct perf_tsc_conversion *tc);
 u64 tsc_to_perf_time(u64 cyc, struct perf_tsc_conversion *tc);
 u64 rdtsc(void);
 
+size_t perf_event__fprintf_time_conv(union perf_event *event, FILE *fp);
+
 #endif // __PERF_TSC_H
-- 
2.25.1



Re: [PATCH v2] integrity: Add declarations to init_once void arguments.

2021-04-09 Thread Jiele Zhao

Okay, thank you. I'll keep an eye on that !

On 2021/4/10 2:55, Mimi Zohar wrote:

Hi Jiele,

On Wed, 2021-04-07 at 01:44 +, Jiele Zhao wrote:

init_once is a callback to kmem_cache_create. The parameter
type of this function is void *, so it's better to give a
explicit cast here.

Signed-off-by: Jiele Zhao 
---
  security/integrity/iint.c | 2 +-
  security/integrity/ima/ima_main.c | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/security/integrity/iint.c b/security/integrity/iint.c
index 0ba01847e836..fca8a9409e4a 100644
--- a/security/integrity/iint.c
+++ b/security/integrity/iint.c
@@ -160,7 +160,7 @@ void integrity_inode_free(struct inode *inode)
  
  static void init_once(void *foo)

  {
-   struct integrity_iint_cache *iint = foo;
+   struct integrity_iint_cache *iint = (struct integrity_iint_cache *) foo;
  
  	memset(iint, 0, sizeof(*iint));

iint->ima_file_status = INTEGRITY_UNKNOWN;
diff --git a/security/integrity/ima/ima_main.c 
b/security/integrity/ima/ima_main.c
index 9ef748ea829f..03bef720ab44 100644
--- a/security/integrity/ima/ima_main.c
+++ b/security/integrity/ima/ima_main.c
@@ -482,7 +482,7 @@ int ima_bprm_check(struct linux_binprm *bprm)
  }
  
  /**

- * ima_path_check - based on policy, collect/store measurement.
+ * ima_file_check - based on policy, collect/store measurement.
   * @file: pointer to the file to be measured
   * @mask: contains MAY_READ, MAY_WRITE, MAY_EXEC or MAY_APPEND
   *

This change was already posted as "ima: Fix function name error in
comment".  I've dropped this hunk.  In the future, please review your
patch line by line before posting.

Applied to
git://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity.git
next-integrity

thanks,

Mimi



Re: [PATCH 2/5] swap: fix do_swap_page() race with swapoff

2021-04-09 Thread Miaohe Lin
On 2021/4/10 1:17, Tim Chen wrote:
> 
> 
> On 4/9/21 1:42 AM, Miaohe Lin wrote:
>> On 2021/4/9 5:34, Tim Chen wrote:
>>>
>>>
>>> On 4/8/21 6:08 AM, Miaohe Lin wrote:
 When I was investigating the swap code, I found the below possible race
 window:

 CPU 1  CPU 2
 -  -
 do_swap_page
   synchronous swap_readpage
 alloc_page_vma
swapoff
  release swap_file, bdev, or ...
>>>
>>
>> Many thanks for quick review and reply!
>>
>>> Perhaps I'm missing something.  The release of swap_file, bdev etc
>>> happens after we have cleared the SWP_VALID bit in si->flags in 
>>> destroy_swap_extents
>>> if I read the swapoff code correctly.
>> Agree. Let's look this more close:
>> CPU1 CPU2
>> --
>> swap_readpage
>>   if (data_race(sis->flags & SWP_FS_OPS)) {
>>  swapoff
>>p->swap_file 
>> = NULL;
>> struct file *swap_file = sis->swap_file;
>> struct address_space *mapping = swap_file->f_mapping;[oops!]
>>...
>>p->flags = 0;
>> ...
>>
>> Does this make sense for you?
> 
> p->swapfile = NULL happens after the 
> p->flags &= ~SWP_VALID, synchronize_rcu(), destroy_swap_extents() sequence in 
> swapoff().
> 
> So I don't think the sequence you illustrated on CPU2 is in the right order.
> That said, without get_swap_device/put_swap_device in swap_readpage, you could
> potentially blow pass synchronize_rcu() on CPU2 and causes a problem.  so I 
> think
> the problematic race looks something like the following:
> 
> 
> CPU1  CPU2
> - -
> swap_readpage
>   if (data_race(sis->flags & SWP_FS_OPS)) {
>   swapoff
> p->flags = &= 
> ~SWP_VALID;
> ..
> 
> synchronize_rcu();
> ..
> p->swap_file 
> = NULL;
> struct file *swap_file = sis->swap_file;
> struct address_space *mapping = swap_file->f_mapping;[oops!]
> ...
> ...
> 

Agree. This is also what I meant to illustrate. And you provide a better one. 
Many thanks!

> By adding get_swap_device/put_swap_device, then the race is fixed.
> 
> 
> CPU1  CPU2
> - -
> swap_readpage
>   get_swap_device()
>   ..
>   if (data_race(sis->flags & SWP_FS_OPS)) {
>   swapoff
> p->flags = &= 
> ~SWP_VALID;
> ..
> struct file *swap_file = sis->swap_file;
> struct address_space *mapping = swap_file->f_mapping;[valid value]
>   ..
>   put_swap_device()
> 
> synchronize_rcu();
> ..
> p->swap_file 
> = NULL;
> 
> 
>>

   swap_readpage
check sis->flags is ok
  access swap_file, bdev...[oops!]
si->flags = 0
>>>
>>> This happens after we clear the si->flags
>>> synchronize_rcu()
>>> release swap_file, bdev, in 
>>> destroy_swap_extents()
>>>
>>> So I think if we have get_swap_device/put_swap_device in do_swap_page,
>>> it should fix the race you've pointed out here.  
>>> Then synchronize_rcu() will wait till we have completed do_swap_page and
>>> call put_swap_device.
>>
>> Right, get_swap_device/put_swap_device could fix this race. __But__ 
>> rcu_read_lock()
>> in get_swap_device() could disable preempt and do_swap_page() may take a 
>> really long
>> time because it involves I/O. It may not be acceptable to disable preempt 
>> for such a
>> long time. :(
> 
> I can see that it is not a good idea to hold rcu read lock for a long
> time over slow file I/O operation, which will be the side effect of
> introducing 

Re:Re: [PATCH] watchdog: mtk: support pre-timeout when the bark irq is available

2021-04-09 Thread 王擎

>On 4/9/21 7:42 PM, 王擎 wrote:
>> 
>>> On 4/9/21 2:55 AM, Wang Qing wrote:
 Use the bark interrupt as the pretimeout notifier if available.

 By default, the pretimeout notification shall occur one second earlier
 than the timeout.

 Signed-off-by: Wang Qing 
 ---
  drivers/watchdog/mtk_wdt.c | 47 
 +++---
  1 file changed, 44 insertions(+), 3 deletions(-)

 diff --git a/drivers/watchdog/mtk_wdt.c b/drivers/watchdog/mtk_wdt.c
 index 97ca993..8b919cc
 --- a/drivers/watchdog/mtk_wdt.c
 +++ b/drivers/watchdog/mtk_wdt.c
 @@ -25,6 +25,7 @@
  #include 
  #include 
  #include 
 +#include 
  
  #define WDT_MAX_TIMEOUT   31
  #define WDT_MIN_TIMEOUT   1
 @@ -234,18 +235,35 @@ static int mtk_wdt_start(struct watchdog_device 
 *wdt_dev)
void __iomem *wdt_base = mtk_wdt->wdt_base;
int ret;
  
 -  ret = mtk_wdt_set_timeout(wdt_dev, wdt_dev->timeout);
 +  ret = mtk_wdt_set_timeout(wdt_dev, wdt_dev->timeout - 
 wdt_dev->pretimeout);
>>>
>>> That looks suspiciously like the real watchdog won't happen at all.
>>> What will happen if the pretimeout governor is set to none ?
>>>
>>> Guenter
>>>
>> The pretimeout governor is panic by default. If pretimeout is enabled and 
>> the governor is
>> set to none, it means the timeout behavior does not need to be processed, 
>> only printing.
>> 
>
>That was not my question. My question was if the real timeout happens in that 
>case.
>
>Guenter
>
Yes, the real timeout will happen. After WDT timeout, IRQ is sent out instead 
of 
reset signal first. In order to ensure that CPU does not get stuck after IRQ is 
sent out, 
WDT will time again and send reset signal to reset.

Thanks.
Qing Wang.



Re: [PATCH 02/10] mm/numa: automatically generate node migration order

2021-04-09 Thread Wei Xu
On Thu, Apr 1, 2021 at 11:35 AM Dave Hansen  wrote:
> +/*
> + * node_demotion[] example:
> + *
> + * Consider a system with two sockets.  Each socket has
> + * three classes of memory attached: fast, medium and slow.
> + * Each memory class is placed in its own NUMA node.  The
> + * CPUs are placed in the node with the "fast" memory.  The
> + * 6 NUMA nodes (0-5) might be split among the sockets like
> + * this:
> + *
> + * Socket A: 0, 1, 2
> + * Socket B: 3, 4, 5
> + *
> + * When Node 0 fills up, its memory should be migrated to
> + * Node 1.  When Node 1 fills up, it should be migrated to
> + * Node 2.  The migration path start on the nodes with the
> + * processors (since allocations default to this node) and
> + * fast memory, progress through medium and end with the
> + * slow memory:
> + *
> + * 0 -> 1 -> 2 -> stop
> + * 3 -> 4 -> 5 -> stop
> + *
> + * This is represented in the node_demotion[] like this:
> + *
> + * {  1, // Node 0 migrates to 1
> + *2, // Node 1 migrates to 2
> + *   -1, // Node 2 does not migrate
> + *4, // Node 3 migrates to 4
> + *5, // Node 4 migrates to 5
> + *   -1} // Node 5 does not migrate
> + */

In this example, if we want to support multiple nodes as the demotion
target of a source node, we can group these nodes into three tiers
(classes):

fast class:
0 -> {1, 4}  // 1 is the preferred
3 -> {4, 1}  // 4 is the preferred

medium class:
1 -> {2, 5}  // 2 is the preferred
4 -> {5, 2}  // 5 is the preferred

slow class:
2 -> stop
5 -> stop

This can guarantee there are no cycles, either.  Does it sound sensible?

> +again:
> +   this_pass = next_pass;
> +   next_pass = NODE_MASK_NONE;
> +   /*
> +* To avoid cycles in the migration "graph", ensure
> +* that migration sources are not future targets by
> +* setting them in 'used_targets'.  Do this only
> +* once per pass so that multiple source nodes can
> +* share a target node.
> +*
> +* 'used_targets' will become unavailable in future
> +* passes.  This limits some opportunities for
> +* multiple source nodes to share a destination.
> +*/
> +   nodes_or(used_targets, used_targets, this_pass);
> +   for_each_node_mask(node, this_pass) {
> +   int target_node = establish_migrate_target(node, 
> _targets);
> +
> +   if (target_node == NUMA_NO_NODE)
> +   continue;
> +
> +   /* Visit targets from this pass in the next pass: */
> +   node_set(target_node, next_pass);
> +   }
> +   /* Is another pass necessary? */
> +   if (!nodes_empty(next_pass))
> +   goto again;

This goto seems like exactly a "do {} while" loop.  Any particular reason not to
use "do {} while" here?


Re: [GIT PULL] clk fixes for v5.12-rc6

2021-04-09 Thread pr-tracker-bot
The pull request you sent on Fri,  9 Apr 2021 18:46:03 -0700:

> https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git 
> tags/clk-fixes-for-linus

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/d4961772226de3b48a395a26c076d450d7044c76

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html


Re: [PATCH] fs: cifs: Fix spelling of 'security'

2021-04-09 Thread Steve French
Merged into cifs-2.6.git for-next

(strangely ... this patch was sent to my spam folder in gmail so
didn't notice it until today, and by accident).

On Wed, Apr 7, 2021 at 9:03 AM  wrote:
>
> From: "jack1.li_cp" 
>
> secuirty -> security
>
> Signed-off-by: jack1.li_cp 
> ---
>  fs/cifs/cifsacl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c
> index 562913e..d2d8e26 100644
> --- a/fs/cifs/cifsacl.c
> +++ b/fs/cifs/cifsacl.c
> @@ -1418,7 +1418,7 @@ int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
>  * Add three ACEs for owner, group, everyone getting rid of other ACEs
>  * as chmod disables ACEs and set the security descriptor. Allocate
>  * memory for the smb header, set security descriptor request security
> -* descriptor parameters, and secuirty descriptor itself
> +* descriptor parameters, and security descriptor itself
>  */
> secdesclen = max_t(u32, secdesclen, DEFAULT_SEC_DESC_LEN);
> pnntsd = kmalloc(secdesclen, GFP_KERNEL);
> --
> 1.9.1
>
>


-- 
Thanks,

Steve


Re: [PATCH] watchdog: mtk: support pre-timeout when the bark irq is available

2021-04-09 Thread Guenter Roeck
On 4/9/21 7:42 PM, 王擎 wrote:
> 
>> On 4/9/21 2:55 AM, Wang Qing wrote:
>>> Use the bark interrupt as the pretimeout notifier if available.
>>>
>>> By default, the pretimeout notification shall occur one second earlier
>>> than the timeout.
>>>
>>> Signed-off-by: Wang Qing 
>>> ---
>>>  drivers/watchdog/mtk_wdt.c | 47 
>>> +++---
>>>  1 file changed, 44 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/watchdog/mtk_wdt.c b/drivers/watchdog/mtk_wdt.c
>>> index 97ca993..8b919cc
>>> --- a/drivers/watchdog/mtk_wdt.c
>>> +++ b/drivers/watchdog/mtk_wdt.c
>>> @@ -25,6 +25,7 @@
>>>  #include 
>>>  #include 
>>>  #include 
>>> +#include 
>>>  
>>>  #define WDT_MAX_TIMEOUT31
>>>  #define WDT_MIN_TIMEOUT1
>>> @@ -234,18 +235,35 @@ static int mtk_wdt_start(struct watchdog_device 
>>> *wdt_dev)
>>> void __iomem *wdt_base = mtk_wdt->wdt_base;
>>> int ret;
>>>  
>>> -   ret = mtk_wdt_set_timeout(wdt_dev, wdt_dev->timeout);
>>> +   ret = mtk_wdt_set_timeout(wdt_dev, wdt_dev->timeout - 
>>> wdt_dev->pretimeout);
>>
>> That looks suspiciously like the real watchdog won't happen at all.
>> What will happen if the pretimeout governor is set to none ?
>>
>> Guenter
>>
> The pretimeout governor is panic by default. If pretimeout is enabled and the 
> governor is
> set to none, it means the timeout behavior does not need to be processed, 
> only printing.
> 

That was not my question. My question was if the real timeout happens in that 
case.

Guenter



Re: [PATCH] x86/efi: Do not release sub-1MB memory regions when the crashkernel option is specified

2021-04-09 Thread lijiang
Hi, Baoquan
Thank you for the comment.
在 2021年04月09日 20:44, Baoquan He 写道:
> On 04/07/21 at 10:03pm, Lianbo Jiang wrote:
>> Some sub-1MB memory regions may be reserved by EFI boot services, and the
>> memory regions will be released later in the efi_free_boot_services().
>>
>> Currently, always reserve all sub-1MB memory regions when the crashkernel
>> option is specified, but unfortunately EFI boot services may have already
>> reserved some sub-1MB memory regions before the crash_reserve_low_1M() is
>> called, which makes that the crash_reserve_low_1M() only own the
>> remaining sub-1MB memory regions, not all sub-1MB memory regions, because,
>> subsequently EFI boot services will free its own sub-1MB memory regions.
>> Eventually, DMA will be able to allocate memory from the sub-1MB area and
>> cause the following error:
>>
> 
> So this patch is fixing a problem found in crash utility. We ever met
> the similar issue, later fixed by always reserving low 1M in commit
> 6f599d84231fd27 ("x86/kdump: Always reserve the low 1M when the crashkernel
> option is specified"). Seems the commit is not fixing it completely.
> 
Maybe I should add the "Fixes: 6f599d84231f" in front of 'Signed-off-by' as 
below:

Fixes: 6f599d84231f ("x86/kdump: Always reserve the low 1M when the crashkernel 
option is specified")

>> crash> kmem -s |grep invalid
>> kmem: dma-kmalloc-512: slab: d52c40001900 invalid freepointer: 
>> 9403c0067300
>> kmem: dma-kmalloc-512: slab: d52c40001900 invalid freepointer: 
>> 9403c0067300
>> crash> vtop 9403c0067300
>> VIRTUAL   PHYSICAL
>> 9403c0067300  67300   --->The physical address falls into this range 
>> [0x00063000-0x0008efff]
>>
>> kernel debugging log:
>> ...
>> [0.008927] memblock_reserve: [0x0001-0x00013fff] 
>> efi_reserve_boot_services+0x85/0xd0
>> [0.008930] memblock_reserve: [0x00063000-0x0008efff] 
>> efi_reserve_boot_services+0x85/0xd0
>> ...
>> [0.009425] memblock_reserve: [0x-0x000f] 
>> crash_reserve_low_1M+0x2c/0x49
>> ...
>> [0.010586] Zone ranges:
>> [0.010587]   DMA  [mem 0x1000-0x00ff]
>> [0.010589]   DMA32[mem 0x0100-0x]
>> [0.010591]   Normal   [mem 0x0001-0x000c7fff]
>> [0.010593]   Device   empty
>> ...
>> [8.814894] __memblock_free_late: [0x00063000-0x0008efff] 
>> efi_free_boot_services+0x14b/0x23b
>> [8.815793] __memblock_free_late: [0x0001-0x00013fff] 
>> efi_free_boot_services+0x14b/0x23b
> 
> 
> In commit 6f599d84231fd27, we call crash_reserve_low_1M() to lock the
> whole low 1M area if crashkernel is specified in kernel cmdline.
> But earlier efi_reserve_boot_services() invokation will break the
> intention of the whole low 1M reserving. In efi_reserve_boot_services(),
> if any memory under low 1M hasn't been reserved, it will call
> memblock_reserve() to reserve it and leave it to
> efi_free_boot_services() to free.
> 

Good understanding.

> Hi Lianbo,
> 
> Please correct me if I am wrong or anything is missed. IIUC, can we move
> efi_reserve_boot_services() after reserve_real_mode() to fix this bug?

What do you think about the following changes?

patch [1]:

diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 5ecd69a48393..c343de3178ec 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -1064,12 +1064,6 @@ void __init setup_arch(char **cmdline_p)
efi_esrt_init();
efi_mokvar_table_init();
 
-   /*
-* The EFI specification says that boot service code won't be
-* called after ExitBootServices(). This is, in fact, a lie.
-*/
-   efi_reserve_boot_services();
-
/* preallocate 4k for mptable mpc */
e820__memblock_alloc_reserved_mpc_new();
 
@@ -1087,6 +1081,12 @@ void __init setup_arch(char **cmdline_p)
trim_platform_memory_ranges();
trim_low_memory_range();
 
+   /*
+* The EFI specification says that boot service code won't be
+* called after ExitBootServices(). This is, in fact, a lie.
+*/
+   efi_reserve_boot_services();
+
init_mem_mapping();
 
idt_setup_early_pf();

> Or move reserve_real_mode() before efi_reserve_boot_services() since
> those real mode regions are all under 1M? Assume efi boot code/data

Or patch [2]

diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 5ecd69a48393..ceec5af0dfab 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -1058,6 +1058,7 @@ void __init setup_arch(char **cmdline_p)
sev_setup_arch();
 
reserve_bios_regions();
+   reserve_real_mode();
 
efi_fake_memmap();
efi_find_mirror();
@@ -1082,8 +1083,6 @@ void __init setup_arch(char **cmdline_p)
(max_pfn_mapped< won't rely on low 1M area any more at this moment.
> 

Re:Re: [PATCH] softdog: make pretimeout available when SOFT_WATCHDOG_PRETIMEOUT enabled

2021-04-09 Thread 王擎

>On 4/6/21 2:44 AM, Wang Qing wrote:
>> Although softdog supports pretimeout, there is no way to set pretimeout, 
>> so pretimeout will never be processed in softdog_ping(). 
>> 
>This is wrong. The pretimeout can be set using WDIOC_SETPRETIMEOUT, as with
>every other driver supporting it. There is no need for a module parameter.
>
>Guenter
>
I saw it, but if I use softdog and enable pretimeout, I hope to get pre 
processing
by default instead of fire. Can we give pretimeout a minimum default value?

Thanks.
Qing wang.

>> Here add the configuration mechanism for pretimeout and the default value
>> is 1 second, so when CONFIG_SOFT_WATCHDOG_PRETIMEOUT is enabled, the 
>> pretimeout function defaults available.
>> 
>> Signed-off-by: Wang Qing 
>> ---
>>  drivers/watchdog/softdog.c | 11 +++
>>  1 file changed, 11 insertions(+)
>> 
>> diff --git a/drivers/watchdog/softdog.c b/drivers/watchdog/softdog.c
>> index 7a10962..79e52791
>> --- a/drivers/watchdog/softdog.c
>> +++ b/drivers/watchdog/softdog.c
>> @@ -35,6 +35,14 @@ MODULE_PARM_DESC(soft_margin,
>>  "Watchdog soft_margin in seconds. (0 < soft_margin < 65536, default="
>>  __MODULE_STRING(TIMER_MARGIN) ")");
>>  
>> +#ifdef CONFIG_SOFT_WATCHDOG_PRETIMEOUT
>> +#define PRE_TIMER_MARGIN1   /* Default is 1 seconds */
>> +static unsigned int soft_pretimeout = PRE_TIMER_MARGIN; /* in seconds */
>> +module_param(soft_pretimeout, uint, 0);
>> +MODULE_PARM_DESC(soft_pretimeout,
>> +"Watchdog soft_pretimeout in seconds. (0 < soft_pretimeout < 
>> soft_margin, default=1)");
>> +#endif
>> +
>>  static bool nowayout = WATCHDOG_NOWAYOUT;
>>  module_param(nowayout, bool, 0);
>>  MODULE_PARM_DESC(nowayout,
>> @@ -177,6 +185,9 @@ static struct watchdog_device softdog_dev = {
>>  .min_timeout = 1,
>>  .max_timeout = 65535,
>>  .timeout = TIMER_MARGIN,
>> +#ifdef CONFIG_SOFT_WATCHDOG_PRETIMEOUT
>> +.pretimeout = PRE_TIMER_MARGIN,
>> +#endif
>>  };
>>  
>>  static int __init softdog_init(void)
>> 
>




Re: [PATCH v7 02/28] mm: Introduce struct folio

2021-04-09 Thread kernel test robot
Hi "Matthew,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on next-20210409]
[also build test ERROR on v5.12-rc6]
[cannot apply to linux/master linus/master hnaz-linux-mm/master v5.12-rc6 
v5.12-rc5 v5.12-rc4]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:
https://github.com/0day-ci/linux/commits/Matthew-Wilcox-Oracle/Memory-Folios/20210410-031353
base:e99d8a8495175df8cb8b739f8cf9b0fc9d0cd3b5
config: mips-gpr_defconfig (attached as .config)
compiler: mipsel-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# 
https://github.com/0day-ci/linux/commit/5658a201516d2ed74a34c328e3b55f552d4861d8
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review 
Matthew-Wilcox-Oracle/Memory-Folios/20210410-031353
git checkout 5658a201516d2ed74a34c328e3b55f552d4861d8
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross 
ARCH=mips 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All errors (new ones prefixed by >>):

   In file included from include/linux/bits.h:22,
from include/linux/bitops.h:6,
from include/linux/log2.h:12,
from include/asm-generic/div64.h:53,
from arch/mips/include/asm/div64.h:12,
from include/linux/math64.h:7,
from include/linux/time.h:6,
from include/linux/compat.h:10,
from arch/mips/kernel/asm-offsets.c:12:
>> include/linux/build_bug.h:78:41: error: static assertion failed: 
>> "offsetof(struct page, lru) == offsetof(struct folio, lru)"
  78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
 | ^~
   include/linux/build_bug.h:77:34: note: in expansion of macro 
'__static_assert'
  77 | #define static_assert(expr, ...) __static_assert(expr, 
##__VA_ARGS__, #expr)
 |  ^~~
   include/linux/mm_types.h:272:2: note: in expansion of macro 'static_assert'
 272 |  static_assert(offsetof(struct page, pg) == offsetof(struct folio, 
fl))
 |  ^
   include/linux/mm_types.h:274:1: note: in expansion of macro 'FOLIO_MATCH'
 274 | FOLIO_MATCH(lru, lru);
 | ^~~
>> include/linux/build_bug.h:78:41: error: static assertion failed: 
>> "offsetof(struct page, compound_head) == offsetof(struct folio, lru)"
  78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
 | ^~
   include/linux/build_bug.h:77:34: note: in expansion of macro 
'__static_assert'
  77 | #define static_assert(expr, ...) __static_assert(expr, 
##__VA_ARGS__, #expr)
 |  ^~~
   include/linux/mm_types.h:272:2: note: in expansion of macro 'static_assert'
 272 |  static_assert(offsetof(struct page, pg) == offsetof(struct folio, 
fl))
 |  ^
   include/linux/mm_types.h:275:1: note: in expansion of macro 'FOLIO_MATCH'
 275 | FOLIO_MATCH(compound_head, lru);
 | ^~~
>> include/linux/build_bug.h:78:41: error: static assertion failed: 
>> "offsetof(struct page, index) == offsetof(struct folio, index)"
  78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
 | ^~
   include/linux/build_bug.h:77:34: note: in expansion of macro 
'__static_assert'
  77 | #define static_assert(expr, ...) __static_assert(expr, 
##__VA_ARGS__, #expr)
 |  ^~~
   include/linux/mm_types.h:272:2: note: in expansion of macro 'static_assert'
 272 |  static_assert(offsetof(struct page, pg) == offsetof(struct folio, 
fl))
 |  ^
   include/linux/mm_types.h:276:1: note: in expansion of macro 'FOLIO_MATCH'
 276 | FOLIO_MATCH(index, index);
 | ^~~
>> include/linux/build_bug.h:78:41: error: static assertion failed: 
>> "offsetof(struct page, private) == offsetof(struct folio, private)"
  78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
 | ^~
   include/linux/build_bug.h:77:34: note: in expansion of macro 
'__static_assert'
  77 | #define static_assert(expr, ...) __static_assert(expr, 
##__VA_ARGS__, #expr)
 |

Bogus struct page layout on 32-bit

2021-04-09 Thread Matthew Wilcox
On Sat, Apr 10, 2021 at 06:45:35AM +0800, kernel test robot wrote:
> >> include/linux/mm_types.h:274:1: error: static_assert failed due to 
> >> requirement '__builtin_offsetof(struct page, lru) == 
> >> __builtin_offsetof(struct folio, lru)' "offsetof(struct page, lru) == 
> >> offsetof(struct folio, lru)"
>FOLIO_MATCH(lru, lru);
>include/linux/mm_types.h:272:2: note: expanded from macro 'FOLIO_MATCH'
>static_assert(offsetof(struct page, pg) == offsetof(struct folio, 
> fl))

Well, this is interesting.  pahole reports:

struct page {
long unsigned int  flags;/* 0 4 */
/* XXX 4 bytes hole, try to pack */
union {
struct {
struct list_head lru;/* 8 8 */
...
struct folio {
union {
struct {
long unsigned int flags; /* 0 4 */
struct list_head lru;/* 4 8 */

so this assert has absolutely done its job.

But why has this assert triggered?  Why is struct page layout not what
we thought it was?  Turns out it's the dma_addr added in 2019 by commit
c25fff7171be ("mm: add dma_addr_t to struct page").  On this particular
config, it's 64-bit, and ppc32 requires alignment to 64-bit.  So
the whole union gets moved out by 4 bytes.

Unfortunately, we can't just fix this by putting an 'unsigned long pad'
in front of it.  It still aligns the entire union to 8 bytes, and then
it skips another 4 bytes after the pad.

We can fix it like this ...

+++ b/include/linux/mm_types.h
@@ -96,11 +96,12 @@ struct page {
unsigned long private;
};
struct {/* page_pool used by netstack */
+   unsigned long _page_pool_pad;
/**
 * @dma_addr: might require a 64-bit value even on
 * 32-bit architectures.
 */
-   dma_addr_t dma_addr;
+   dma_addr_t dma_addr __packed;
};
struct {/* slab, slob and slub */
union {

but I don't know if GCC is smart enough to realise that dma_addr is now
on an 8 byte boundary and it can use a normal instruction to access it,
or whether it'll do something daft like use byte loads to access it.

We could also do:

+   dma_addr_t dma_addr __packed __aligned(sizeof(void *));

and I see pahole, at least sees this correctly:

struct {
long unsigned int _page_pool_pad; /* 4 4 */
dma_addr_t dma_addr __attribute__((__aligned__(4))); /* 
8 8 */
} __attribute__((__packed__)) __attribute__((__aligned__(4)));  

This presumably affects any 32-bit architecture with a 64-bit phys_addr_t
/ dma_addr_t.  Advice, please?


Re:Re: [PATCH] watchdog: mtk: support pre-timeout when the bark irq is available

2021-04-09 Thread 王擎

>On 4/9/21 2:55 AM, Wang Qing wrote:
>> Use the bark interrupt as the pretimeout notifier if available.
>> 
>> By default, the pretimeout notification shall occur one second earlier
>> than the timeout.
>> 
>> Signed-off-by: Wang Qing 
>> ---
>>  drivers/watchdog/mtk_wdt.c | 47 
>> +++---
>>  1 file changed, 44 insertions(+), 3 deletions(-)
>> 
>> diff --git a/drivers/watchdog/mtk_wdt.c b/drivers/watchdog/mtk_wdt.c
>> index 97ca993..8b919cc
>> --- a/drivers/watchdog/mtk_wdt.c
>> +++ b/drivers/watchdog/mtk_wdt.c
>> @@ -25,6 +25,7 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>  
>>  #define WDT_MAX_TIMEOUT 31
>>  #define WDT_MIN_TIMEOUT 1
>> @@ -234,18 +235,35 @@ static int mtk_wdt_start(struct watchdog_device 
>> *wdt_dev)
>>  void __iomem *wdt_base = mtk_wdt->wdt_base;
>>  int ret;
>>  
>> -ret = mtk_wdt_set_timeout(wdt_dev, wdt_dev->timeout);
>> +ret = mtk_wdt_set_timeout(wdt_dev, wdt_dev->timeout - 
>> wdt_dev->pretimeout);
>
>That looks suspiciously like the real watchdog won't happen at all.
>What will happen if the pretimeout governor is set to none ?
>
>Guenter
>
The pretimeout governor is panic by default. If pretimeout is enabled and the 
governor is
set to none, it means the timeout behavior does not need to be processed, only 
printing.

Thanks.

Qing Wang.




Re: [PATCH 4/6] staging: rtl8192e: matched alignment with open parenthesis

2021-04-09 Thread Joe Perches
On Sat, 2021-04-10 at 07:55 +0530, Mitali Borkar wrote:
> On Fri, Apr 09, 2021 at 07:07:09PM -0700, Joe Perches wrote:
> > On Sat, 2021-04-10 at 07:05 +0530, Mitali Borkar wrote:
> > > Matched the alignment with open parenthesis to meet linux kernel coding
> > > style.
> > > Reported by checkpatch.
> > []
> > > diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c 
> > > b/drivers/staging/rtl8192e/rtl819x_HTProc.c
> > []
> > > @@ -154,7 +154,7 @@ bool IsHTHalfNmodeAPs(struct rtllib_device *ieee)
> > >   (net->ralink_cap_exist))
> > >   retValue = true;
> > >   else if (!memcmp(net->bssid, UNKNOWN_BORADCOM, 3) ||
> > > - !memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3) ||
> > > +  !memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3) ||
> > >   !memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3) ||
> > >   (net->broadcom_cap_exist))
> > 
> > checkpatch is a stupid script.
> > Look further at the code not just at what checkpatch reports.
> > Align all the contination lines, not just the first one.
> > 
> Sir, I have aligned them in last patch of this patchset.

This sort of change should not require an additional patch.




Re: [PATCH 4/6] staging: rtl8192e: matched alignment with open parenthesis

2021-04-09 Thread Mitali Borkar
On Fri, Apr 09, 2021 at 07:07:09PM -0700, Joe Perches wrote:
> On Sat, 2021-04-10 at 07:05 +0530, Mitali Borkar wrote:
> > Matched the alignment with open parenthesis to meet linux kernel coding
> > style.
> > Reported by checkpatch.
> []
> > diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c 
> > b/drivers/staging/rtl8192e/rtl819x_HTProc.c
> []
> > @@ -154,7 +154,7 @@ bool IsHTHalfNmodeAPs(struct rtllib_device *ieee)
> >     (net->ralink_cap_exist))
> >     retValue = true;
> >     else if (!memcmp(net->bssid, UNKNOWN_BORADCOM, 3) ||
> > -   !memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3) ||
> > +!memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3) ||
> >     !memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3) ||
> >     (net->broadcom_cap_exist))
> 
> checkpatch is a stupid script.
> Look further at the code not just at what checkpatch reports.
> Align all the contination lines, not just the first one.
>
Sir, I have aligned them in last patch of this patchset.

> It might be sensible to add a generic function like
> 
> static inline bool ether_oui_equal(const u8 *addr, const u8 *oui)
> {
>   return addr[0] == oui[0] && addr[1] == oui[1] && addr[2] == oui[2];
> } 
> 
> to include/linux/etherdevice.h
> 
> (Maybe use & instead of && if it's speed sensitive)
> 
> so this would read
> 
>   else if (ether_oui_equal(net->bssid, UNKNOWN_BORADCOM) ||
>ether_oui_equal(net->bssid, 
> LINKSYSWRT330_LINKSYSWRT300_BROADCOM) ||
>ether_oui_equal(net->bssid, 
> LINKSYSWRT350_LINKSYSWRT150_BROADCOM) ||
>net->broacom_cap_exist)
> 
> and it'd also be good to correct the typo of UNKNOWN_BORADCOM globally.
>
I will look into this.

> > @@ -654,13 +654,13 @@ void HTInitializeHTInfo(struct rtllib_device *ieee)
> >     pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor;
> >  
> > 
> >     memset((void *)(&(pHTInfo->SelfHTCap)), 0,
> > -   sizeof(pHTInfo->SelfHTCap));
> > +  sizeof(pHTInfo->SelfHTCap));
> 
> Doesn't need casts or parentheses.
> 
>   memset(>SelfHTCap, 0, sizeof(pHTInfo->SelfHCap));
> 
Ok Sir, i am on it.

> >     memset((void *)(&(pHTInfo->SelfHTInfo)), 0,
> > -   sizeof(pHTInfo->SelfHTInfo));
> > +  sizeof(pHTInfo->SelfHTInfo));
> 
> etc...
> 
> > @@ -815,7 +815,7 @@ void HTUseDefaultSetting(struct rtllib_device *ieee)
> >     HTFilterMCSRate(ieee, ieee->Regdot11TxHTOperationalRateSet,
> >     ieee->dot11HTOperationalRateSet);
> >     ieee->HTHighestOperaRate = HTGetHighestMCSRate(ieee,
> > -  ieee->dot11HTOperationalRateSet,
> > +  
> > ieee->dot11HTOperationalRateSet,
> >    MCS_FILTER_ALL);
> 
> multi line statement alignment etc...
>
Sir, I have aligned this patch 6/6
> 


[PATCH -next] Bluetooth: use flexible-array member instead of zero-length array

2021-04-09 Thread Qiheng Lin
Fix the following coccicheck warning:

net/bluetooth/msft.c:37:6-13: WARNING use flexible-array member instead
net/bluetooth/msft.c:42:6-10: WARNING use flexible-array member instead
net/bluetooth/msft.c:52:6-10: WARNING use flexible-array member instead

Signed-off-by: Qiheng Lin 
---
 net/bluetooth/msft.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/bluetooth/msft.c b/net/bluetooth/msft.c
index e28f15439ce4..37a394786a94 100644
--- a/net/bluetooth/msft.c
+++ b/net/bluetooth/msft.c
@@ -34,12 +34,12 @@ struct msft_le_monitor_advertisement_pattern {
__u8 length;
__u8 data_type;
__u8 start_byte;
-   __u8 pattern[0];
+   __u8 pattern[];
 };
 
 struct msft_le_monitor_advertisement_pattern_data {
__u8 count;
-   __u8 data[0];
+   __u8 data[];
 };
 
 struct msft_cp_le_monitor_advertisement {
@@ -49,7 +49,7 @@ struct msft_cp_le_monitor_advertisement {
__u8 rssi_low_interval;
__u8 rssi_sampling_period;
__u8 cond_type;
-   __u8 data[0];
+   __u8 data[];
 } __packed;
 
 struct msft_rp_le_monitor_advertisement {
-- 
2.31.1



Re: [PATCH v1 1/2] arm64: dts: qcom: sc7280: Add cpufreq hw node

2021-04-09 Thread Stephen Boyd
Quoting Taniya Das (2021-04-09 19:04:39)
> @@ -1116,6 +1124,17 @@
> #clock-cells = <1>;
> };
> };
> +
> +   cpufreq_hw: cpufreq@18591000 {
> +   compatible = "qcom,cpufreq-epss";
> +   reg = <0 0x18591000 0 0x1000>,
> + <0 0x18592000 0 0x1000>,
> + <0 0x18593000 0 0x1000>;
> +   reg-names = "freq-domain0", "freq-domain1", 
> "freq-domain2";

The reg-names provides practically no value. Can you drop it?

> +   clocks = < RPMH_CXO_CLK>, < GCC_GPLL0>;
> +   clock-names = "xo", "alternate";
> +   #freq-domain-cells = <1>;
> +   };
> };
>


[PATCH 3/3] staging: rtl8192e: remove unncessary parentheses

2021-04-09 Thread Mitali Borkar
Removed unnecessary parentheses because they must be used only when it
is necessary or they improve readability.
Reported by checkpatch.

Signed-off-by: Mitali Borkar 
---
 drivers/staging/rtl8192e/rtl819x_HTProc.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c 
b/drivers/staging/rtl8192e/rtl819x_HTProc.c
index 89d0e9ec188d..b1fa8e9a4f28 100644
--- a/drivers/staging/rtl8192e/rtl819x_HTProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c
@@ -287,7 +287,7 @@ void HTConstructCapabilityElement(struct rtllib_device 
*ieee, u8 *posHTCap,
u8  EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33};
 
memcpy(posHTCap, EWC11NHTCap, sizeof(EWC11NHTCap));
-   pCapELE = (struct ht_capab_ele *)&(posHTCap[4]);
+   pCapELE = (struct ht_capab_ele *)[4];
*len = 30 + 2;
} else {
pCapELE = (struct ht_capab_ele *)posHTCap;
@@ -646,13 +646,13 @@ void HTInitializeHTInfo(struct rtllib_device *ieee)
pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density;
pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor;
 
-   memset((void *)(&(pHTInfo->SelfHTCap)), 0,
+   memset((void *)(>SelfHTCap), 0,
   sizeof(pHTInfo->SelfHTCap));
-   memset((void *)(&(pHTInfo->SelfHTInfo)), 0,
+   memset((void *)(>SelfHTInfo), 0,
   sizeof(pHTInfo->SelfHTInfo));
-   memset((void *)(&(pHTInfo->PeerHTCapBuf)), 0,
+   memset((void *)(>PeerHTCapBuf), 0,
   sizeof(pHTInfo->PeerHTCapBuf));
-   memset((void *)(&(pHTInfo->PeerHTInfoBuf)), 0,
+   memset((void *)(>PeerHTInfoBuf), 0,
   sizeof(pHTInfo->PeerHTInfoBuf));
 
pHTInfo->bSwBwInProgress = false;
@@ -668,7 +668,7 @@ void HTInitializeHTInfo(struct rtllib_device *ieee)
pHTInfo->IOTRaFunc = 0;
 
{
-   u8 *RegHTSuppRateSets = &(ieee->RegHTSuppRateSet[0]);
+   u8 *RegHTSuppRateSets = >RegHTSuppRateSet[0];
 
RegHTSuppRateSets[0] = 0xFF;
RegHTSuppRateSets[1] = 0xFF;
-- 
2.30.2



[PATCH 0/3] staging: rtl8192e: cleanup patchset for style issues

2021-04-09 Thread Mitali Borkar
These patches fix the cleanup style issues identified by checkpatch

Mitali Borkar (3):
  staging: rtl8192e: replace comparison to NULL by boolean expression
  staging: rtl8192e: remove unnecessary ftrace-like logging
  staging: rtl8192e: remove unncessary parentheses

 drivers/staging/rtl8192e/rtl819x_HTProc.c | 26 ++-
 1 file changed, 11 insertions(+), 15 deletions(-)

-- 
2.30.2



[PATCH 2/3] staging: rtl8192e: remove unnecessary ftrace-like logging

2021-04-09 Thread Mitali Borkar
Removed unncessary ftrace-like logging by simply deleting that statement
as we have other modes of logging like ftrace.
Reported by checkpatch.

Signed-off-by: Mitali Borkar 
---
 drivers/staging/rtl8192e/rtl819x_HTProc.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c 
b/drivers/staging/rtl8192e/rtl819x_HTProc.c
index 0b1e92f17805..89d0e9ec188d 100644
--- a/drivers/staging/rtl8192e/rtl819x_HTProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c
@@ -630,7 +630,6 @@ void HTInitializeHTInfo(struct rtllib_device *ieee)
 {
struct rt_hi_throughput *pHTInfo = ieee->pHTInfo;
 
-   netdev_vdbg(ieee->dev, "%s()\n", __func__);
pHTInfo->bCurrentHTSupport = false;
 
pHTInfo->bCurBW40MHz = false;
@@ -698,7 +697,6 @@ void HTResetSelfAndSavePeerSetting(struct rtllib_device 
*ieee,
struct rt_hi_throughput *pHTInfo = ieee->pHTInfo;
u8  bIOTAction = 0;
 
-   netdev_vdbg(ieee->dev, "%s()\n", __func__);
/* unmark bEnableHT flag here is the same reason why unmarked in
 * function rtllib_softmac_new_net. WB 2008.09.10
 */
@@ -832,8 +830,6 @@ static void HTSetConnectBwModeCallback(struct rtllib_device 
*ieee)
 {
struct rt_hi_throughput *pHTInfo = ieee->pHTInfo;
 
-   netdev_vdbg(ieee->dev, "%s()\n", __func__);
-
if (pHTInfo->bCurBW40MHz) {
if (pHTInfo->CurSTAExtChnlOffset == HT_EXTCHNL_OFFSET_UPPER)
ieee->set_chan(ieee->dev,
-- 
2.30.2



[PATCH 1/3] staging: rtl8192e: replace comparison to NULL by boolean

2021-04-09 Thread Mitali Borkar
Replaced comparison to NULL by boolean expressions
(here used boolean negations). This improves readability of code.
Reported by checkpatch.

Signed-off-by: Mitali Borkar 
---
 drivers/staging/rtl8192e/rtl819x_HTProc.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c 
b/drivers/staging/rtl8192e/rtl819x_HTProc.c
index 65202dd53447..0b1e92f17805 100644
--- a/drivers/staging/rtl8192e/rtl819x_HTProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c
@@ -276,7 +276,7 @@ void HTConstructCapabilityElement(struct rtllib_device 
*ieee, u8 *posHTCap,
struct rt_hi_throughput *pHT = ieee->pHTInfo;
struct ht_capab_ele *pCapELE = NULL;
 
-   if ((posHTCap == NULL) || (pHT == NULL)) {
+   if ((!posHTCap) || (!pHT)) {
netdev_warn(ieee->dev,
"%s(): posHTCap and pHTInfo are null\n", __func__);
return;
@@ -357,7 +357,7 @@ void HTConstructInfoElement(struct rtllib_device *ieee, u8 
*posHTInfo,
struct rt_hi_throughput *pHT = ieee->pHTInfo;
struct ht_info_ele *pHTInfoEle = (struct ht_info_ele *)posHTInfo;
 
-   if ((posHTInfo == NULL) || (pHTInfoEle == NULL)) {
+   if ((!posHTInfo) || (!pHTInfoEle)) {
netdev_warn(ieee->dev,
"%s(): posHTInfo and pHTInfoEle are null\n",
__func__);
@@ -397,7 +397,7 @@ void HTConstructInfoElement(struct rtllib_device *ieee, u8 
*posHTInfo,
 void HTConstructRT2RTAggElement(struct rtllib_device *ieee, u8 *posRT2RTAgg,
u8 *len)
 {
-   if (posRT2RTAgg == NULL) {
+   if (!posRT2RTAgg) {
netdev_warn(ieee->dev, "%s(): posRT2RTAgg is null\n", __func__);
return;
}
@@ -420,7 +420,7 @@ static u8 HT_PickMCSRate(struct rtllib_device *ieee, u8 
*pOperateMCS)
 {
u8 i;
 
-   if (pOperateMCS == NULL) {
+   if (!pOperateMCS) {
netdev_warn(ieee->dev, "%s(): pOperateMCS is null\n", __func__);
return false;
}
@@ -453,7 +453,7 @@ u8 HTGetHighestMCSRate(struct rtllib_device *ieee, u8 
*pMCSRateSet,
u8  mcsRate = 0;
u8  availableMcsRate[16];
 
-   if (pMCSRateSet == NULL || pMCSFilter == NULL) {
+   if (!pMCSRateSet || !pMCSFilter) {
netdev_warn(ieee->dev,
"%s(): pMCSRateSet and pMCSFilter are null\n",
__func__);
-- 
2.30.2



Re: [PATCH v2 4/6] usb: typec: tcpm: Honour pSnkStdby requirement during negotiation

2021-04-09 Thread Guenter Roeck
On 4/7/21 1:07 PM, Badhri Jagan Sridharan wrote:
>>From PD Spec:
> The Sink Shall transition to Sink Standby before a positive or
> negative voltage transition of VBUS. During Sink Standby
> the Sink Shall reduce its power draw to pSnkStdby. This allows
> the Source to manage the voltage transition as well as
> supply sufficient operating current to the Sink to maintain PD
> operation during the transition. The Sink Shall
> complete this transition to Sink Standby within tSnkStdby
> after evaluating the Accept Message from the Source. The
> transition when returning to Sink operation from Sink Standby
> Shall be completed within tSnkNewPower. The
> pSnkStdby requirement Shall only apply if the Sink power draw
> is higher than this level.
> 
> The above requirement needs to be met to prevent hard resets
> from port partner.
> 
> Without the patch: (5V/3A during SNK_DISCOVERY all the way through
> explicit contract)
> [   95.711984] CC1: 0 -> 0, CC2: 0 -> 5 [state TOGGLING, polarity 0, 
> connected]
> [   95.712007] state change TOGGLING -> SNK_ATTACH_WAIT [rev3 NONE_AMS]
> [   95.712017] pending state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED @ 170 ms 
> [rev3 NONE_AMS]
> [   95.837190] VBUS on
> [   95.882075] state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED [delayed 170 ms]
> [   95.882082] state change SNK_DEBOUNCED -> SNK_ATTACHED [rev3 NONE_AMS]
> [   95.882086] polarity 1
> [   95.883151] set_auto_vbus_discharge_threshold mode:0 pps_active:n 
> vbus:5000 ret:0
> [   95.883441] enable vbus discharge ret:0
> [   95.883445] Requesting mux state 1, usb-role 2, orientation 2
> [   95.883776] state change SNK_ATTACHED -> SNK_STARTUP [rev3 NONE_AMS]
> [   95.883879] pending state change SNK_STARTUP -> SNK_DISCOVERY @ 500 ms 
> [rev3 NONE_AMS]
> [   96.038960] VBUS on
> [   96.383939] state change SNK_STARTUP -> SNK_DISCOVERY [delayed 500 ms]
> [   96.383946] Setting voltage/current limit 5000 mV 3000 mA
> [   96.383961] vbus=0 charge:=1
> [   96.386044] state change SNK_DISCOVERY -> SNK_WAIT_CAPABILITIES [rev3 
> NONE_AMS]
> [   96.386309] pending state change SNK_WAIT_CAPABILITIES -> HARD_RESET_SEND 
> @ 450 ms [rev3 NONE_AMS]
> [   96.394404] PD RX, header: 0x2161 [1]
> [   96.394408]  PDO 0: type 0, 5000 mV, 3000 mA [E]
> [   96.394410]  PDO 1: type 0, 9000 mV, 2000 mA []
> [   96.394412] state change SNK_WAIT_CAPABILITIES -> 
> SNK_NEGOTIATE_CAPABILITIES [rev2 POWER_NEGOTIATION]
> [   96.394416] Setting usb_comm capable false
> [   96.395083] cc=0 cc1=0 cc2=5 vbus=0 vconn=sink polarity=1
> [   96.395089] Requesting PDO 1: 9000 mV, 2000 mA
> [   96.395093] PD TX, header: 0x1042
> [   96.397404] PD TX complete, status: 0
> [   96.397424] pending state change SNK_NEGOTIATE_CAPABILITIES -> 
> HARD_RESET_SEND @ 60 ms [rev2 POWER_NEGOTIATION]
> [   96.400826] PD RX, header: 0x363 [1]
> [   96.400829] state change SNK_NEGOTIATE_CAPABILITIES -> SNK_TRANSITION_SINK 
> [rev2 POWER_NEGOTIATION]
> [   96.400832] pending state change SNK_TRANSITION_SINK -> HARD_RESET_SEND @ 
> 500 ms [rev2 POWER_NEGOTIATION]
> [   96.577315] PD RX, header: 0x566 [1]
> [   96.577321] Setting voltage/current limit 9000 mV 2000 mA
> [   96.578363] set_auto_vbus_discharge_threshold mode:3 pps_active:n 
> vbus:9000 ret:0
> [   96.578370] state change SNK_TRANSITION_SINK -> SNK_READY [rev2 
> POWER_NEGOTIATION]
> 
> With the patch:
> [  168.398573] CC1: 0 -> 0, CC2: 0 -> 5 [state TOGGLING, polarity 0, 
> connected]
> [  168.398605] state change TOGGLING -> SNK_ATTACH_WAIT [rev3 NONE_AMS]
> [  168.398619] pending state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED @ 170 ms 
> [rev3 NONE_AMS]
> [  168.522348] VBUS on
> [  168.568676] state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED [delayed 170 ms]
> [  168.568684] state change SNK_DEBOUNCED -> SNK_ATTACHED [rev3 NONE_AMS]
> [  168.568688] polarity 1
> [  168.569867] set_auto_vbus_discharge_threshold mode:0 pps_active:n 
> vbus:5000 ret:0
> [  168.570158] enable vbus discharge ret:0
> [  168.570161] Requesting mux state 1, usb-role 2, orientation 2
> [  168.570504] state change SNK_ATTACHED -> SNK_STARTUP [rev3 NONE_AMS]
> [  168.570634] pending state change SNK_STARTUP -> SNK_DISCOVERY @ 500 ms 
> [rev3 NONE_AMS]
> [  169.070689] state change SNK_STARTUP -> SNK_DISCOVERY [delayed 500 ms]
> [  169.070695] Setting voltage/current limit 5000 mV 3000 mA
> [  169.070702] vbus=0 charge:=1
> [  169.072719] state change SNK_DISCOVERY -> SNK_WAIT_CAPABILITIES [rev3 
> NONE_AMS]
> [  169.073145] pending state change SNK_WAIT_CAPABILITIES -> HARD_RESET_SEND 
> @ 450 ms [rev3 NONE_AMS]
> [  169.077162] PD RX, header: 0x2161 [1]
> [  169.077172]  PDO 0: type 0, 5000 mV, 3000 mA [E]
> [  169.077178]  PDO 1: type 0, 9000 mV, 2000 mA []
> [  169.077183] state change SNK_WAIT_CAPABILITIES -> 
> SNK_NEGOTIATE_CAPABILITIES [rev2 POWER_NEGOTIATION]
> [  169.077191] Setting usb_comm capable false
> [  169.077753] cc=0 cc1=0 cc2=5 vbus=0 vconn=sink polarity=1
> [  169.077759] Requesting PDO 1: 9000 mV, 2000 mA
> [  

Re: [PATCH v2 3/6] usb: typec: tcpm: update power supply once partner accepts

2021-04-09 Thread Guenter Roeck
On 4/7/21 1:07 PM, Badhri Jagan Sridharan wrote:
> power_supply_changed needs to be called to notify clients
> after the partner accepts the requested values for the pps
> case.
> 
> Also, remove the redundant power_supply_changed at the end
> of the tcpm_reset_port as power_supply_changed is already
> called right after usb_type is changed.
> 
> Fixes: f2a8aa053c176 ("typec: tcpm: Represent source supply through 
> power_supply")
> Signed-off-by: Badhri Jagan Sridharan 
> Reviewed-by: Adam Thomson 

Reviewed-by: Guenter Roeck 

> ---
> Changes since V1:
> * Updated commit description to clarify Guenter Roeck's concern.
> * Added Reviewed-by tags
> ---
>  drivers/usb/typec/tcpm/tcpm.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index b4a40099d7e9..d1d03ee90d8f 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -2568,6 +2568,7 @@ static void tcpm_pd_ctrl_request(struct tcpm_port *port,
>   port->pps_data.max_curr = port->pps_data.req_max_curr;
>   port->req_supply_voltage = port->pps_data.req_out_volt;
>   port->req_current_limit = port->pps_data.req_op_curr;
> + power_supply_changed(port->psy);
>   tcpm_set_state(port, SNK_TRANSITION_SINK, 0);
>   break;
>   case SOFT_RESET_SEND:
> @@ -3136,7 +3137,6 @@ static unsigned int tcpm_pd_select_pps_apdo(struct 
> tcpm_port *port)
> 
> port->pps_data.req_out_volt));
>   port->pps_data.req_op_curr = min(port->pps_data.max_curr,
>port->pps_data.req_op_curr);
> - power_supply_changed(port->psy);
>   }
>  
>   return src_pdo;
> @@ -3561,8 +3561,6 @@ static void tcpm_reset_port(struct tcpm_port *port)
>   port->sink_cap_done = false;
>   if (port->tcpc->enable_frs)
>   port->tcpc->enable_frs(port->tcpc, false);
> -
> - power_supply_changed(port->psy);
>  }
>  
>  static void tcpm_detach(struct tcpm_port *port)
> 



Re: [PATCH v2 2/6] usb: typec: tcpm: Address incorrect values of tcpm psy for pps supply

2021-04-09 Thread Guenter Roeck
On 4/7/21 1:07 PM, Badhri Jagan Sridharan wrote:
> tcpm_pd_select_pps_apdo overwrites port->pps_data.min_volt,
> port->pps_data.max_volt, port->pps_data.max_curr even before
> port partner accepts the requests. This leaves incorrect values
> in current_limit and supply_voltage that get exported by
> "tcpm-source-psy-". Solving this problem by caching the request
> values in req_min_volt, req_max_volt, req_max_curr, req_out_volt,
> req_op_curr. min_volt, max_volt, max_curr gets updated once the
> partner accepts the request. current_limit, supply_voltage gets updated
> once local port's tcpm enters SNK_TRANSITION_SINK when the accepted
> current_limit and supply_voltage is enforced.
> 
> Fixes: f2a8aa053c176 ("typec: tcpm: Represent source supply through 
> power_supply")
> Signed-off-by: Badhri Jagan Sridharan 
> Reviewed-by: Adam Thomson 

Reviewed-by: Guenter Roeck 

> ---
> Changes since V1:
> * Moved to kerneldoc header as suggested by Greg KH.
> * Added reviewed by tags.
> ---
>  drivers/usb/typec/tcpm/tcpm.c | 88 +--
>  1 file changed, 53 insertions(+), 35 deletions(-)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index 4ea4b30ae885..b4a40099d7e9 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -268,12 +268,27 @@ struct pd_mode_data {
>   struct typec_altmode_desc altmode_desc[ALTMODE_DISCOVERY_MAX];
>  };
>  
> +/*
> + * @min_volt: Actual min voltage at the local port
> + * @req_min_volt: Requested min voltage to the port partner
> + * @max_volt: Actual max voltage at the local port
> + * @req_max_volt: Requested max voltage to the port partner
> + * @max_curr: Actual max current at the local port
> + * @req_max_curr: Requested max current of the port partner
> + * @req_out_volt: Requested output voltage to the port partner
> + * @req_op_curr: Requested operating current to the port partner
> + * @supported: Parter has atleast one APDO hence supports PPS
> + * @active: PPS mode is active
> + */
>  struct pd_pps_data {
>   u32 min_volt;
> + u32 req_min_volt;
>   u32 max_volt;
> + u32 req_max_volt;
>   u32 max_curr;
> - u32 out_volt;
> - u32 op_curr;
> + u32 req_max_curr;
> + u32 req_out_volt;
> + u32 req_op_curr;
>   bool supported;
>   bool active;
>  };
> @@ -2498,8 +2513,8 @@ static void tcpm_pd_ctrl_request(struct tcpm_port *port,
>   break;
>   case SNK_NEGOTIATE_PPS_CAPABILITIES:
>   /* Revert data back from any requested PPS updates */
> - port->pps_data.out_volt = port->supply_voltage;
> - port->pps_data.op_curr = port->current_limit;
> + port->pps_data.req_out_volt = port->supply_voltage;
> + port->pps_data.req_op_curr = port->current_limit;
>   port->pps_status = (type == PD_CTRL_WAIT ?
>   -EAGAIN : -EOPNOTSUPP);
>  
> @@ -2548,8 +2563,11 @@ static void tcpm_pd_ctrl_request(struct tcpm_port 
> *port,
>   break;
>   case SNK_NEGOTIATE_PPS_CAPABILITIES:
>   port->pps_data.active = true;
> - port->req_supply_voltage = port->pps_data.out_volt;
> - port->req_current_limit = port->pps_data.op_curr;
> + port->pps_data.min_volt = port->pps_data.req_min_volt;
> + port->pps_data.max_volt = port->pps_data.req_max_volt;
> + port->pps_data.max_curr = port->pps_data.req_max_curr;
> + port->req_supply_voltage = port->pps_data.req_out_volt;
> + port->req_current_limit = port->pps_data.req_op_curr;
>   tcpm_set_state(port, SNK_TRANSITION_SINK, 0);
>   break;
>   case SOFT_RESET_SEND:
> @@ -3108,16 +3126,16 @@ static unsigned int tcpm_pd_select_pps_apdo(struct 
> tcpm_port *port)
>   src = port->source_caps[src_pdo];
>   snk = port->snk_pdo[snk_pdo];
>  
> - port->pps_data.min_volt = max(pdo_pps_apdo_min_voltage(src),
> -   pdo_pps_apdo_min_voltage(snk));
> - port->pps_data.max_volt = min(pdo_pps_apdo_max_voltage(src),
> -   pdo_pps_apdo_max_voltage(snk));
> - port->pps_data.max_curr = min_pps_apdo_current(src, snk);
> - port->pps_data.out_volt = min(port->pps_data.max_volt,
> -   max(port->pps_data.min_volt,
> -   port->pps_data.out_volt));
> - port->pps_data.op_curr = min(port->pps_data.max_curr,
> -  port->pps_data.op_curr);
> + port->pps_data.req_min_volt = max(pdo_pps_apdo_min_voltage(src),
> +   

Re: [PATCH 4/6] staging: rtl8192e: matched alignment with open parenthesis

2021-04-09 Thread Joe Perches
On Sat, 2021-04-10 at 07:05 +0530, Mitali Borkar wrote:
> Matched the alignment with open parenthesis to meet linux kernel coding
> style.
> Reported by checkpatch.
[]
> diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c 
> b/drivers/staging/rtl8192e/rtl819x_HTProc.c
[]
> @@ -154,7 +154,7 @@ bool IsHTHalfNmodeAPs(struct rtllib_device *ieee)
>   (net->ralink_cap_exist))
>   retValue = true;
>   else if (!memcmp(net->bssid, UNKNOWN_BORADCOM, 3) ||
> - !memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3) ||
> +  !memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3) ||
>   !memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3) ||
>   (net->broadcom_cap_exist))

checkpatch is a stupid script.
Look further at the code not just at what checkpatch reports.
Align all the contination lines, not just the first one.

It might be sensible to add a generic function like

static inline bool ether_oui_equal(const u8 *addr, const u8 *oui)
{
return addr[0] == oui[0] && addr[1] == oui[1] && addr[2] == oui[2];
}   

to include/linux/etherdevice.h

(Maybe use & instead of && if it's speed sensitive)

so this would read

else if (ether_oui_equal(net->bssid, UNKNOWN_BORADCOM) ||
 ether_oui_equal(net->bssid, 
LINKSYSWRT330_LINKSYSWRT300_BROADCOM) ||
 ether_oui_equal(net->bssid, 
LINKSYSWRT350_LINKSYSWRT150_BROADCOM) ||
 net->broacom_cap_exist)

and it'd also be good to correct the typo of UNKNOWN_BORADCOM globally.

> @@ -654,13 +654,13 @@ void HTInitializeHTInfo(struct rtllib_device *ieee)
>   pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor;
>  
> 
>   memset((void *)(&(pHTInfo->SelfHTCap)), 0,
> - sizeof(pHTInfo->SelfHTCap));
> +sizeof(pHTInfo->SelfHTCap));

Doesn't need casts or parentheses.

memset(>SelfHTCap, 0, sizeof(pHTInfo->SelfHCap));

>   memset((void *)(&(pHTInfo->SelfHTInfo)), 0,
> - sizeof(pHTInfo->SelfHTInfo));
> +sizeof(pHTInfo->SelfHTInfo));

etc...

> @@ -815,7 +815,7 @@ void HTUseDefaultSetting(struct rtllib_device *ieee)
>   HTFilterMCSRate(ieee, ieee->Regdot11TxHTOperationalRateSet,
>   ieee->dot11HTOperationalRateSet);
>   ieee->HTHighestOperaRate = HTGetHighestMCSRate(ieee,
> -ieee->dot11HTOperationalRateSet,
> +
> ieee->dot11HTOperationalRateSet,
>  MCS_FILTER_ALL);

multi line statement alignment etc...




[PATCH v1 2/2] arm64: dts: qcom: sc7280: Add clock controller nodes

2021-04-09 Thread Taniya Das
Add support for the video, gpu, display, lpass clock controller
device nodes for SC7280 SoC.

Signed-off-by: Taniya Das 
---
 arch/arm64/boot/dts/qcom/sc7280.dtsi | 58 
 1 file changed, 58 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/sc7280.dtsi 
b/arch/arm64/boot/dts/qcom/sc7280.dtsi
index cda3f2a..b59 100644
--- a/arch/arm64/boot/dts/qcom/sc7280.dtsi
+++ b/arch/arm64/boot/dts/qcom/sc7280.dtsi
@@ -5,8 +5,12 @@
  * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
  */

+#include 
 #include 
+#include 
+#include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -324,6 +328,31 @@
};
};

+   lpasscc: lpasscc@300 {
+   compatible = "qcom,sc7280-lpasscc";
+   reg = <0 0x0300 0 0x40>,
+ <0 0x03c04000 0 0x4>,
+ <0 0x03389000 0 0x24>;
+   reg-names = "qdsp6ss", "top_cc", "cc";
+   clocks = < GCC_CFG_NOC_LPASS_CLK>;
+   clock-names = "iface";
+   #clock-cells = <1>;
+   };
+
+   gpucc: clock-controller@3d9 {
+   compatible = "qcom,sc7280-gpucc";
+   reg = <0 0x03d9 0 0x9000>;
+   clocks = < RPMH_CXO_CLK>,
+< GCC_GPU_GPLL0_CLK_SRC>,
+< GCC_GPU_GPLL0_DIV_CLK_SRC>;
+   clock-names = "bi_tcxo",
+ "gcc_gpu_gpll0_clk_src",
+ "gcc_gpu_gpll0_div_clk_src";
+   #clock-cells = <1>;
+   #reset-cells = <1>;
+   #power-domain-cells = <1>;
+   };
+
stm@6002000 {
compatible = "arm,coresight-stm", "arm,primecell";
reg = <0 0x06002000 0 0x1000>,
@@ -820,6 +849,35 @@
interrupts = ;
};

+   videocc: clock-controller@aaf {
+   compatible = "qcom,sc7280-videocc";
+   reg = <0 0xaaf 0 0x1>;
+   clocks = < RPMH_CXO_CLK>,
+   < RPMH_CXO_CLK_A>;
+   clock-names = "bi_tcxo", "bi_tcxo_ao";
+   #clock-cells = <1>;
+   #reset-cells = <1>;
+   #power-domain-cells = <1>;
+   };
+
+   dispcc: clock-controller@af0 {
+   compatible = "qcom,sc7280-dispcc";
+   reg = <0 0xaf0 0 0x2>;
+   clocks = < RPMH_CXO_CLK>,
+< GCC_DISP_GPLL0_CLK_SRC>,
+<0>, <0>, <0>, <0>, <0>, <0>;
+   clock-names = "bi_tcxo", "gcc_disp_gpll0_clk",
+ "dsi0_phy_pll_out_byteclk",
+ "dsi0_phy_pll_out_dsiclk",
+ "dp_phy_pll_link_clk",
+ "dp_phy_pll_vco_div_clk",
+ "edp_phy_pll_link_clk",
+ "edp_phy_pll_vco_div_clk";
+   #clock-cells = <1>;
+   #reset-cells = <1>;
+   #power-domain-cells = <1>;
+   };
+
pdc: interrupt-controller@b22 {
compatible = "qcom,sc7280-pdc", "qcom,pdc";
reg = <0 0x0b22 0 0x3>;
--
Qualcomm INDIA, on behalf of Qualcomm Innovation Center, Inc.is a member
of the Code Aurora Forum, hosted by the  Linux Foundation.



[PATCH v1 0/2] Add device nodes for SC7280 SoCs

2021-04-09 Thread Taniya Das
Add device node for cpufreq HW and clock controllers of GPU, DISP, VIDEO, LPASS.
The clock controller nodes are dependent on the following

VIDEO/DISP/GPU: https://lkml.org/lkml/2021/3/16/1624
LPASS: https://lkml.org/lkml/2021/4/9/812

Taniya Das (2):
  arm64: dts: qcom: sc7280: Add cpufreq hw node
  arm64: dts: qcom: sc7280: Add clock controller nodes

 arch/arm64/boot/dts/qcom/sc7280.dtsi | 78 
 1 file changed, 78 insertions(+)

--
Qualcomm INDIA, on behalf of Qualcomm Innovation Center, Inc.is a member
of the Code Aurora Forum, hosted by the  Linux Foundation.



[PATCH v1 1/2] arm64: dts: qcom: sc7280: Add cpufreq hw node

2021-04-09 Thread Taniya Das
Add cpufreq HW device node to scale 4-Silver/3-Gold/1-Gold+
cores on SC7280 SoCs.

Signed-off-by: Taniya Das 
---
 arch/arm64/boot/dts/qcom/sc7280.dtsi | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/sc7280.dtsi 
b/arch/arm64/boot/dts/qcom/sc7280.dtsi
index 2cc4785..cda3f2a 100644
--- a/arch/arm64/boot/dts/qcom/sc7280.dtsi
+++ b/arch/arm64/boot/dts/qcom/sc7280.dtsi
@@ -70,6 +70,7 @@
   _CPU_SLEEP_1
   _SLEEP_0>;
next-level-cache = <_0>;
+   qcom,freq-domain = <_hw 0>;
L2_0: l2-cache {
compatible = "cache";
next-level-cache = <_0>;
@@ -88,6 +89,7 @@
   _CPU_SLEEP_1
   _SLEEP_0>;
next-level-cache = <_100>;
+   qcom,freq-domain = <_hw 0>;
L2_100: l2-cache {
compatible = "cache";
next-level-cache = <_0>;
@@ -103,6 +105,7 @@
   _CPU_SLEEP_1
   _SLEEP_0>;
next-level-cache = <_200>;
+   qcom,freq-domain = <_hw 0>;
L2_200: l2-cache {
compatible = "cache";
next-level-cache = <_0>;
@@ -118,6 +121,7 @@
   _CPU_SLEEP_1
   _SLEEP_0>;
next-level-cache = <_300>;
+   qcom,freq-domain = <_hw 0>;
L2_300: l2-cache {
compatible = "cache";
next-level-cache = <_0>;
@@ -133,6 +137,7 @@
   _CPU_SLEEP_1
   _SLEEP_0>;
next-level-cache = <_400>;
+   qcom,freq-domain = <_hw 1>;
L2_400: l2-cache {
compatible = "cache";
next-level-cache = <_0>;
@@ -148,6 +153,7 @@
   _CPU_SLEEP_1
   _SLEEP_0>;
next-level-cache = <_500>;
+   qcom,freq-domain = <_hw 1>;
L2_500: l2-cache {
compatible = "cache";
next-level-cache = <_0>;
@@ -163,6 +169,7 @@
   _CPU_SLEEP_1
   _SLEEP_0>;
next-level-cache = <_600>;
+   qcom,freq-domain = <_hw 1>;
L2_600: l2-cache {
compatible = "cache";
next-level-cache = <_0>;
@@ -178,6 +185,7 @@
   _CPU_SLEEP_1
   _SLEEP_0>;
next-level-cache = <_700>;
+   qcom,freq-domain = <_hw 2>;
L2_700: l2-cache {
compatible = "cache";
next-level-cache = <_0>;
@@ -1116,6 +1124,17 @@
#clock-cells = <1>;
};
};
+
+   cpufreq_hw: cpufreq@18591000 {
+   compatible = "qcom,cpufreq-epss";
+   reg = <0 0x18591000 0 0x1000>,
+ <0 0x18592000 0 0x1000>,
+ <0 0x18593000 0 0x1000>;
+   reg-names = "freq-domain0", "freq-domain1", 
"freq-domain2";
+   clocks = < RPMH_CXO_CLK>, < GCC_GPLL0>;
+   clock-names = "xo", "alternate";
+   #freq-domain-cells = <1>;
+   };
};

timer {
--
Qualcomm INDIA, on behalf of Qualcomm Innovation Center, Inc.is a member
of the Code Aurora Forum, hosted by the  Linux Foundation.



Re: [PATCH v2] platform/chrome: Don't populate lightbar device if it isn't there

2021-04-09 Thread Stephen Boyd
Quoting Stephen Boyd (2020-09-10 17:53:07)
> Quoting Enric Balletbo i Serra (2020-09-10 08:49:42)
> > On 10/9/20 16:52, Guenter Roeck wrote:
> > > On Thu, Sep 10, 2020 at 7:32 AM Enric Balletbo i Serra
> > >  wrote:
> > >> On 10/9/20 16:18, Guenter Roeck wrote:
> > >>> On Wed, Sep 9, 2020 at 3:42 PM Stephen Boyd  wrote:
> >  @@ -206,6 +209,17 @@ static int ec_device_probe(struct platform_device 
> >  *pdev)
> >  }
> >  }
> > 
> >  +   if (!strcmp(ec_platform->ec_name, CROS_EC_DEV_NAME) &&
> >  +   !cros_ec_get_lightbar_version(ec, NULL, NULL)) {
> > >>>
> > >>> Any idea why the lightbar code doesn't use cros_ec_check_features() ?
> > >>> There is a definition for EC_FEATURE_LIGHTBAR, but it doesn't seem to
> > >>> be used. It would be much more convenient if that feature check could
> > >>> be used instead of moving the get_lightbar_version command and its
> > >>> helper function around.
> > >>>
> > >>
> > >> IIRC it was to support a very old device, the Pixel Chromebook (Link). 
> > >> This flag
> > >> is not set in this device but has a lightbar, hence we had this 'weird' 
> > >> way to
> > >> detect the lightbar.
> > >>
> > > 
> > > If that is the only reason, wouldn't it be better to use something
> > > else (eg dmi_match) to determine if the system in question is a  Pixel
> > > Chromebook (Link) ?
> > > 
> > >  if (!strcmp(ec_platform->ec_name, CROS_EC_DEV_NAME) &&
> > >  (cros_ec_check_features(ec, EC_FEATURE_LIGHTBAR) ||
> > >   dmi_match(DMI_PRODUCT_NAME, "Link")) {
> > > 
> > 
> > That looks a better solution, indeed. And definetely I'd prefer use the 
> > check
> > features way.
> > 
> > Gwendal, can you confirm that the Pixel Chromebook (Link) is the _only_ one
> > affected? This one is the only that comes to my mind but I might miss 
> > others.
> > 
> > I think that Samus has this flag (I can double check) and this was discussed
> > with you (long, long time ago :-) )
> > 
> 
> Sounds fine by me. I'll wait for Gwendal to inform us.

Anything come of this? I haven't seen any updates.


Re: [PATCH] usb: dwc3: qcom: Fixed an issue that the ret value is incorrect in dwc3_qcom_probe()

2021-04-09 Thread Bixuan Cui



On 2021/4/9 18:00, Manivannan Sadhasivam wrote:
> But this error message can be removed altogether as devm_ioremap_resource()
> reports it already.
Thank you for your reply. I'll revise it.

Thanks,
Bixuan Cui


[PATCH v4 13/13] kdump: Use vmlinux_build_id to simplify

2021-04-09 Thread Stephen Boyd
We can use the vmlinux_build_id array here now instead of open coding
it. This mostly consolidates code.

Cc: Jiri Olsa 
Cc: Alexei Starovoitov 
Cc: Jessica Yu 
Cc: Evan Green 
Cc: Hsin-Yi Wang 
Cc: Dave Young 
Cc: Baoquan He 
Cc: Vivek Goyal 
Cc: 
Signed-off-by: Stephen Boyd 
---
 include/linux/crash_core.h |  7 ++
 kernel/crash_core.c| 50 ++
 2 files changed, 4 insertions(+), 53 deletions(-)

diff --git a/include/linux/crash_core.h b/include/linux/crash_core.h
index 206bde8308b2..2174dab16ba9 100644
--- a/include/linux/crash_core.h
+++ b/include/linux/crash_core.h
@@ -39,7 +39,8 @@ phys_addr_t paddr_vmcoreinfo_note(void);
 #define VMCOREINFO_OSRELEASE(value) \
vmcoreinfo_append_str("OSRELEASE=%s\n", value)
 #define VMCOREINFO_BUILD_ID(value) \
-   vmcoreinfo_append_str("BUILD-ID=%s\n", value)
+   BUILD_BUG_ON(ARRAY_SIZE(value) != BUILD_ID_SIZE_MAX); \
+   vmcoreinfo_append_str("BUILD-ID=%20phN\n", value)
 #define VMCOREINFO_PAGESIZE(value) \
vmcoreinfo_append_str("PAGESIZE=%ld\n", value)
 #define VMCOREINFO_SYMBOL(name) \
@@ -69,10 +70,6 @@ extern unsigned char *vmcoreinfo_data;
 extern size_t vmcoreinfo_size;
 extern u32 *vmcoreinfo_note;
 
-/* raw contents of kernel .notes section */
-extern const void __start_notes __weak;
-extern const void __stop_notes __weak;
-
 Elf_Word *append_elf_note(Elf_Word *buf, char *name, unsigned int type,
  void *data, size_t data_len);
 void final_note(Elf_Word *buf);
diff --git a/kernel/crash_core.c b/kernel/crash_core.c
index 825284baaf46..f7eb752560f1 100644
--- a/kernel/crash_core.c
+++ b/kernel/crash_core.c
@@ -4,6 +4,7 @@
  * Copyright (C) 2002-2004 Eric Biederman  
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -378,53 +379,6 @@ phys_addr_t __weak paddr_vmcoreinfo_note(void)
 }
 EXPORT_SYMBOL(paddr_vmcoreinfo_note);
 
-#define NOTES_SIZE (&__stop_notes - &__start_notes)
-#define BUILD_ID_MAX SHA1_DIGEST_SIZE
-#define NT_GNU_BUILD_ID 3
-
-struct elf_note_section {
-   struct elf_note n_hdr;
-   u8 n_data[];
-};
-
-/*
- * Add build ID from .notes section as generated by the GNU ld(1)
- * or LLVM lld(1) --build-id option.
- */
-static void add_build_id_vmcoreinfo(void)
-{
-   char build_id[BUILD_ID_MAX * 2 + 1];
-   int n_remain = NOTES_SIZE;
-
-   while (n_remain >= sizeof(struct elf_note)) {
-   const struct elf_note_section *note_sec =
-   &__start_notes + NOTES_SIZE - n_remain;
-   const u32 n_namesz = note_sec->n_hdr.n_namesz;
-
-   if (note_sec->n_hdr.n_type == NT_GNU_BUILD_ID &&
-   n_namesz != 0 &&
-   !strcmp((char *)_sec->n_data[0], "GNU")) {
-   if (note_sec->n_hdr.n_descsz <= BUILD_ID_MAX) {
-   const u32 n_descsz = note_sec->n_hdr.n_descsz;
-   const u8 *s = _sec->n_data[n_namesz];
-
-   s = PTR_ALIGN(s, 4);
-   bin2hex(build_id, s, n_descsz);
-   build_id[2 * n_descsz] = '\0';
-   VMCOREINFO_BUILD_ID(build_id);
-   return;
-   }
-   pr_warn("Build ID is too large to include in 
vmcoreinfo: %u > %u\n",
-   note_sec->n_hdr.n_descsz,
-   BUILD_ID_MAX);
-   return;
-   }
-   n_remain -= sizeof(struct elf_note) +
-   ALIGN(note_sec->n_hdr.n_namesz, 4) +
-   ALIGN(note_sec->n_hdr.n_descsz, 4);
-   }
-}
-
 static int __init crash_save_vmcoreinfo_init(void)
 {
vmcoreinfo_data = (unsigned char *)get_zeroed_page(GFP_KERNEL);
@@ -443,7 +397,7 @@ static int __init crash_save_vmcoreinfo_init(void)
}
 
VMCOREINFO_OSRELEASE(init_uts_ns.name.release);
-   add_build_id_vmcoreinfo();
+   VMCOREINFO_BUILD_ID(vmlinux_build_id);
VMCOREINFO_PAGESIZE(PAGE_SIZE);
 
VMCOREINFO_SYMBOL(init_uts_ns);
-- 
https://chromeos.dev



[PATCH v4 09/13] scripts/decode_stacktrace.sh: Silence stderr messages from addr2line/nm

2021-04-09 Thread Stephen Boyd
Sometimes if you're using tools that have linked things improperly or
have new features/sections that older tools don't expect you'll see
warnings printed to stderr. We don't really care about these warnings,
so let's just silence these messages to cleanup output of this script.

Cc: Jiri Olsa 
Cc: Alexei Starovoitov 
Cc: Jessica Yu 
Cc: Evan Green 
Cc: Hsin-Yi Wang 
Cc: Konstantin Khlebnikov 
Cc: Sasha Levin 
Signed-off-by: Stephen Boyd 
---
 scripts/decode_stacktrace.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/scripts/decode_stacktrace.sh b/scripts/decode_stacktrace.sh
index ca21f8bdf5f2..20b5af1ebe5e 100755
--- a/scripts/decode_stacktrace.sh
+++ b/scripts/decode_stacktrace.sh
@@ -74,7 +74,7 @@ find_module() {
find_module && return
 
if [[ $release == "" ]] ; then
-   release=$(gdb -ex 'print init_uts_ns.name.release' -ex 'quit' 
-quiet -batch "$vmlinux" | sed -n 's/\$1 = "\(.*\)".*/\1/p')
+   release=$(gdb -ex 'print init_uts_ns.name.release' -ex 'quit' 
-quiet -batch "$vmlinux" 2>/dev/null | sed -n 's/\$1 = "\(.*\)".*/\1/p')
fi
 
for dn in {/usr/lib/debug,}/lib/modules/$release ; do
@@ -128,7 +128,7 @@ parse_symbol() {
if [[ "${cache[$module,$name]+isset}" == "isset" ]]; then
local base_addr=${cache[$module,$name]}
else
-   local base_addr=$(nm "$objfile" | awk '$3 == "'$name'" && ($2 
== "t" || $2 == "T") {print $1; exit}')
+   local base_addr=$(nm "$objfile" 2>/dev/null | awk '$3 == 
"'$name'" && ($2 == "t" || $2 == "T") {print $1; exit}')
if [[ $base_addr == "" ]] ; then
# address not found
return
@@ -152,7 +152,7 @@ parse_symbol() {
if [[ "${cache[$module,$address]+isset}" == "isset" ]]; then
local code=${cache[$module,$address]}
else
-   local code=$(${CROSS_COMPILE}addr2line -i -e "$objfile" 
"$address")
+   local code=$(${CROSS_COMPILE}addr2line -i -e "$objfile" 
"$address" 2>/dev/null)
cache[$module,$address]=$code
fi
 
-- 
https://chromeos.dev



[PATCH v4 12/13] buildid: Fix kernel-doc notation

2021-04-09 Thread Stephen Boyd
Kernel doc should use "Return:" instead of "Returns" to properly reflect
the return values.

Cc: Jiri Olsa 
Cc: Alexei Starovoitov 
Cc: Jessica Yu 
Cc: Evan Green 
Cc: Hsin-Yi Wang 
Signed-off-by: Stephen Boyd 
---
 lib/buildid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/buildid.c b/lib/buildid.c
index df42282b36ff..ce88133f8dc4 100644
--- a/lib/buildid.c
+++ b/lib/buildid.c
@@ -121,7 +121,7 @@ static int get_build_id_64(const void *page_addr, unsigned 
char *build_id,
  * @build_id: buffer to store build id, at least BUILD_ID_SIZE long
  * @size: returns actual build id size in case of success
  *
- * Returns 0 on success, otherwise error (< 0).
+ * Return: 0 on success, -EINVAL otherwise
  */
 int build_id_parse(struct vm_area_struct *vma, unsigned char *build_id,
   __u32 *size)
-- 
https://chromeos.dev



[PATCH v4 11/13] buildid: Mark some arguments const

2021-04-09 Thread Stephen Boyd
These arguments are never modified so they can be marked const to
indicate as such.

Cc: Jiri Olsa 
Cc: Alexei Starovoitov 
Cc: Jessica Yu 
Cc: Evan Green 
Cc: Hsin-Yi Wang 
Signed-off-by: Stephen Boyd 
---
 lib/buildid.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/buildid.c b/lib/buildid.c
index 1103ed46214f..df42282b36ff 100644
--- a/lib/buildid.c
+++ b/lib/buildid.c
@@ -48,10 +48,10 @@ static int parse_build_id_buf(unsigned char *build_id,
return -EINVAL;
 }
 
-static inline int parse_build_id(void *page_addr,
+static inline int parse_build_id(const void *page_addr,
 unsigned char *build_id,
 __u32 *size,
-void *note_start,
+const void *note_start,
 Elf32_Word note_size)
 {
/* check for overflow */
@@ -66,7 +66,7 @@ static inline int parse_build_id(void *page_addr,
 }
 
 /* Parse build ID from 32-bit ELF */
-static int get_build_id_32(void *page_addr, unsigned char *build_id,
+static int get_build_id_32(const void *page_addr, unsigned char *build_id,
   __u32 *size)
 {
Elf32_Ehdr *ehdr = (Elf32_Ehdr *)page_addr;
@@ -91,7 +91,7 @@ static int get_build_id_32(void *page_addr, unsigned char 
*build_id,
 }
 
 /* Parse build ID from 64-bit ELF */
-static int get_build_id_64(void *page_addr, unsigned char *build_id,
+static int get_build_id_64(const void *page_addr, unsigned char *build_id,
   __u32 *size)
 {
Elf64_Ehdr *ehdr = (Elf64_Ehdr *)page_addr;
-- 
https://chromeos.dev



[PATCH v4 10/13] scripts/decode_stacktrace.sh: Indicate 'auto' can be used for base path

2021-04-09 Thread Stephen Boyd
Add "auto" to the usage message so that it's a little clearer that you
can pass "auto" as the second argument. When passing "auto" the script
tries to find the base path automatically instead of requiring it be
passed on the commandline. Also use [] to indicate the
variable argument and that it is optional so that we can differentiate
from the literal "auto" that should be passed.

Cc: Jiri Olsa 
Cc: Alexei Starovoitov 
Cc: Jessica Yu 
Cc: Evan Green 
Cc: Hsin-Yi Wang 
Cc: Konstantin Khlebnikov 
Cc: Sasha Levin 
Signed-off-by: Stephen Boyd 
---
 scripts/decode_stacktrace.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/decode_stacktrace.sh b/scripts/decode_stacktrace.sh
index 20b5af1ebe5e..5fbad61fe490 100755
--- a/scripts/decode_stacktrace.sh
+++ b/scripts/decode_stacktrace.sh
@@ -5,7 +5,7 @@
 
 usage() {
echo "Usage:"
-   echo "  $0 -r  |  [base path] [modules path]"
+   echo "  $0 -r  |  [|auto] []"
 }
 
 if [[ $1 == "-r" ]] ; then
-- 
https://chromeos.dev



[PATCH v4 08/13] scripts/decode_stacktrace.sh: Support debuginfod

2021-04-09 Thread Stephen Boyd
Now that stacktraces contain the build ID information we can update this
script to use debuginfod-find to locate the debuginfo for the vmlinux
and modules automatically. This can replace the existing code that
requires specifying a path to vmlinux or tries to find the vmlinux and
modules automatically by using the release number. Work it into the
script as a fallback option if the vmlinux isn't specified on the
commandline.

Cc: Jiri Olsa 
Cc: Alexei Starovoitov 
Cc: Jessica Yu 
Cc: Evan Green 
Cc: Hsin-Yi Wang 
Cc: Konstantin Khlebnikov 
Cc: Sasha Levin 
Cc: Petr Mladek 
Cc: Steven Rostedt 
Cc: Andy Shevchenko 
Cc: Matthew Wilcox 
Signed-off-by: Stephen Boyd 
---
 scripts/decode_stacktrace.sh | 81 +++-
 1 file changed, 70 insertions(+), 11 deletions(-)

diff --git a/scripts/decode_stacktrace.sh b/scripts/decode_stacktrace.sh
index 90398347e366..ca21f8bdf5f2 100755
--- a/scripts/decode_stacktrace.sh
+++ b/scripts/decode_stacktrace.sh
@@ -3,11 +3,10 @@
 # (c) 2014, Sasha Levin 
 #set -x
 
-if [[ $# < 1 ]]; then
+usage() {
echo "Usage:"
echo "  $0 -r  |  [base path] [modules path]"
-   exit 1
-fi
+}
 
 if [[ $1 == "-r" ]] ; then
vmlinux=""
@@ -24,6 +23,7 @@ if [[ $1 == "-r" ]] ; then
 
if [[ $vmlinux == "" ]] ; then
echo "ERROR! vmlinux image for release $release is not found" 
>&2
+   usage
exit 2
fi
 else
@@ -31,12 +31,35 @@ else
basepath=${2-auto}
modpath=$3
release=""
+   debuginfod=
+
+   # Can we use debuginfod-find?
+   if type debuginfod-find >/dev/null 2>&1 ; then
+   debuginfod=${1-only}
+   fi
+
+   if [[ $vmlinux == "" && -z $debuginfod ]] ; then
+   echo "ERROR! vmlinux image must be specified" >&2
+   usage
+   exit 1
+   fi
 fi
 
 declare -A cache
 declare -A modcache
 
 find_module() {
+   if [[ -n $debuginfod ]] ; then
+   if [[ -n $modbuildid ]] ; then
+   debuginfod-find debuginfo $modbuildid && return
+   fi
+
+   # Only using debuginfod so don't try to find vmlinux module path
+   if [[ $debuginfod == "only" ]] ; then
+   return
+   fi
+   fi
+
if [[ "$modpath" != "" ]] ; then
for fn in $(find "$modpath" -name "${module//_/[-_]}.ko*") ; do
if readelf -WS "$fn" | grep -qwF .debug_line ; then
@@ -150,6 +173,27 @@ parse_symbol() {
symbol="$segment$name ($code)"
 }
 
+debuginfod_get_vmlinux() {
+   local vmlinux_buildid=${1##* }
+
+   if [[ $vmlinux != "" ]]; then
+   return
+   fi
+
+   if [[ $vmlinux_buildid =~ ^[0-9a-f]+ ]]; then
+   vmlinux=$(debuginfod-find debuginfo $vmlinux_buildid)
+   if [[ $? -ne 0 ]] ; then
+   echo "ERROR! vmlinux image not found via 
debuginfod-find" >&2
+   usage
+   exit 2
+   fi
+   return
+   fi
+   echo "ERROR! Build ID for vmlinux not found. Try passing -r or 
specifying vmlinux" >&2
+   usage
+   exit 2
+}
+
 decode_code() {
local scripts=`dirname "${BASH_SOURCE[0]}"`
 
@@ -157,6 +201,14 @@ decode_code() {
 }
 
 handle_line() {
+   if [[ $basepath == "auto" && $vmlinux != "" ]] ; then
+   module=""
+   symbol="kernel_init+0x0/0x0"
+   parse_symbol
+   basepath=${symbol#kernel_init (}
+   basepath=${basepath%/init/main.c:*)}
+   fi
+
local words
 
# Tokenize
@@ -182,16 +234,28 @@ handle_line() {
fi
done
 
+   if [[ ${words[$last]} =~ ^[0-9a-f]+\] ]]; then
+   words[$last-1]="${words[$last-1]} ${words[$last]}"
+   unset words[$last]
+   last=$(( $last - 1 ))
+   fi
+
if [[ ${words[$last]} =~ \[([^]]+)\] ]]; then
module=${words[$last]}
module=${module#\[}
module=${module%\]}
+   modbuildid=${module#* }
+   module=${module% *}
+   if [[ $modbuildid == $module ]]; then
+   modbuildid=
+   fi
symbol=${words[$last-1]}
unset words[$last-1]
else
# The symbol is the last element, process it
symbol=${words[$last]}
module=
+   modbuildid=
fi
 
unset words[$last]
@@ -201,14 +265,6 @@ handle_line() {
echo "${words[@]}" "$symbol $module"
 }
 
-if [[ $basepath == "auto" ]] ; then
-   module=""
-   symbol="kernel_init+0x0/0x0"
-   parse_symbol
-   basepath=${symbol#kernel_init (}
-   basepath=${basepath%/init/main.c:*)}
-fi
-
 while read line; do
# Let's see if we have an address in the line
if [[ $line =~ 

[PATCH v4 07/13] x86/dumpstack: Use %pSb/%pBb for backtrace printing

2021-04-09 Thread Stephen Boyd
Let's use the new printk formats to print the stacktrace entries when
printing a backtrace to the kernel logs. This will include any module's
build ID[1] in it so that offline/crash debugging can easily locate the
debuginfo for a module via something like debuginfod[2].

Cc: Thomas Gleixner 
Cc: Ingo Molnar 
Cc: Borislav Petkov 
Cc: 
Cc: Jiri Olsa 
Cc: Alexei Starovoitov 
Cc: Jessica Yu 
Cc: Evan Green 
Cc: Hsin-Yi Wang 
Cc: Petr Mladek 
Cc: Steven Rostedt 
Cc: Andy Shevchenko 
Cc: Matthew Wilcox 
Link: https://fedoraproject.org/wiki/Releases/FeatureBuildId [1]
Link: https://sourceware.org/elfutils/Debuginfod.html [2]
Signed-off-by: Stephen Boyd 
---
 arch/x86/kernel/dumpstack.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
index 299c20f0a38b..be2de39bf16f 100644
--- a/arch/x86/kernel/dumpstack.c
+++ b/arch/x86/kernel/dumpstack.c
@@ -69,7 +69,7 @@ static void printk_stack_address(unsigned long address, int 
reliable,
 const char *log_lvl)
 {
touch_nmi_watchdog();
-   printk("%s %s%pB\n", log_lvl, reliable ? "" : "? ", (void *)address);
+   printk("%s %s%pBb\n", log_lvl, reliable ? "" : "? ", (void *)address);
 }
 
 static int copy_code(struct pt_regs *regs, u8 *buf, unsigned long src,
@@ -143,9 +143,9 @@ void show_opcodes(struct pt_regs *regs, const char *loglvl)
 void show_ip(struct pt_regs *regs, const char *loglvl)
 {
 #ifdef CONFIG_X86_32
-   printk("%sEIP: %pS\n", loglvl, (void *)regs->ip);
+   printk("%sEIP: %pSb\n", loglvl, (void *)regs->ip);
 #else
-   printk("%sRIP: %04x:%pS\n", loglvl, (int)regs->cs, (void *)regs->ip);
+   printk("%sRIP: %04x:%pSb\n", loglvl, (int)regs->cs, (void *)regs->ip);
 #endif
show_opcodes(regs, loglvl);
 }
-- 
https://chromeos.dev



[PATCH v4 05/13] module: Add printk formats to add module build ID to stacktraces

2021-04-09 Thread Stephen Boyd
Let's make kernel stacktraces easier to identify by including the build
ID[1] of a module if the stacktrace is printing a symbol from a module.
This makes it simpler for developers to locate a kernel module's full
debuginfo for a particular stacktrace. Combined with
scripts/decode_stracktrace.sh, a developer can download the matching
debuginfo from a debuginfod[2] server and find the exact file and line
number for the functions plus offsets in a stacktrace that match the
module. This is especially useful for pstore crash debugging where the
kernel crashes are recorded in something like console-ramoops and the
recovery kernel/modules are different or the debuginfo doesn't exist on
the device due to space concerns (the debuginfo can be too large for
space limited devices).

Originally, I put this on the %pS format, but that was quickly rejected
given that %pS is used in other places such as ftrace where build IDs
aren't meaningful. There was some discussions on the list to put every
module build ID into the "Modules linked in:" section of the stacktrace
message but that quickly becomes very hard to read once you have more
than three or four modules linked in. It also provides too much
information when we don't expect each module to be traversed in a
stacktrace. Having the build ID for modules that aren't important just
makes things messy. Splitting it to multiple lines for each module
quickly explodes the number of lines printed in an oops too, possibly
wrapping the warning off the console. And finally, trying to stash away
each module used in a callstack to provide the ID of each symbol printed
is cumbersome and would require changes to each architecture to stash
away modules and return their build IDs once unwinding has completed.

Instead, we opt for the simpler approach of introducing new printk
formats '%pS[R]b' for "pointer symbolic backtrace with module build ID"
and '%pBb' for "pointer backtrace with module build ID" and then
updating the few places in the architecture layer where the stacktrace
is printed to use this new format.

Example:

 WARNING: CPU: 3 PID: 3373 at drivers/misc/lkdtm/bugs.c:83 
lkdtm_WARNING+0x28/0x30 [lkdtm]
 Modules linked in: lkdtm rfcomm algif_hash algif_skcipher af_alg xt_cgroup 
uinput xt_MASQUERADE hci_uart 
 CPU: 3 PID: 3373 Comm: bash Not tainted 5.11 #12 
a8c0d47f7051f3e6670ceaea724af66a39c6cec8
 Hardware name: Google Lazor (rev3+) with KB Backlight (DT)
 pstate: 0049 (nzcv daif +PAN -UAO -TCO BTYPE=--)
 pc : lkdtm_WARNING+0x28/0x30 [lkdtm]
 lr : lkdtm_do_action+0x24/0x40 [lkdtm]
 sp : ffc013febca0
 x29: ffc013febca0 x28: ff88d9438040
 x27:  x26: 
 x25:  x24: ffdd0e9772c0
 x23: 0020 x22: ffdd0e975366
 x21: ffdd0e9772e0 x20: ffc013febde0
 x19: 0008 x18: 
 x17:  x16: 0037
 x15: ffdd102ab174 x14: 0003
 x13: 0004 x12: 
 x11:  x10: 
 x9 : 0001 x8 : ffdd0e979000
 x7 :  x6 : ffdd10ff6b54
 x5 :  x4 : 
 x3 : ffc013feb938 x2 : ff89fef05a70
 x1 : ff89feef5788 x0 : ffdd0e9772e0
 Call trace:
  lkdtm_WARNING+0x28/0x30 [lkdtm 6c2215028606bda50de823490723dc4bc5bf46f9]
  direct_entry+0x16c/0x1b4 [lkdtm 6c2215028606bda50de823490723dc4bc5bf46f9]
  full_proxy_write+0x74/0xa4
  vfs_write+0xec/0x2e8
  ksys_write+0x84/0xf0
  __arm64_sys_write+0x24/0x30
  el0_svc_common+0xf4/0x1c0
  do_el0_svc_compat+0x28/0x3c
  el0_svc_compat+0x10/0x1c
  el0_sync_compat_handler+0xa8/0xcc
  el0_sync_compat+0x178/0x180
 ---[ end trace f89bc7f5417cbcc6 ]---

Cc: Jiri Olsa 
Cc: Alexei Starovoitov 
Cc: Jessica Yu 
Cc: Evan Green 
Cc: Hsin-Yi Wang 
Cc: Petr Mladek 
Cc: Steven Rostedt 
Cc: Sergey Senozhatsky 
Cc: Andy Shevchenko 
Cc: Rasmus Villemoes 
Cc: 
Cc: Matthew Wilcox 
Link: https://fedoraproject.org/wiki/Releases/FeatureBuildId [1]
Link: https://sourceware.org/elfutils/Debuginfod.html [2]
Signed-off-by: Stephen Boyd 
---
 Documentation/core-api/printk-formats.rst | 11 +++
 include/linux/kallsyms.h  | 20 -
 include/linux/module.h|  6 +-
 kernel/kallsyms.c | 95 ++-
 kernel/module.c   | 24 +-
 lib/vsprintf.c|  8 +-
 6 files changed, 139 insertions(+), 25 deletions(-)

diff --git a/Documentation/core-api/printk-formats.rst 
b/Documentation/core-api/printk-formats.rst
index 160e710d992f..5f60533f2a56 100644
--- a/Documentation/core-api/printk-formats.rst
+++ b/Documentation/core-api/printk-formats.rst
@@ -114,6 +114,17 @@ used when printing stack backtraces. The specifier takes 
into
 consideration the effect of compiler optimisations which may occur
 when tail-calls are used and marked with the noreturn GCC attribute.
 
+If the pointer is within a module, the module name 

[PATCH v4 06/13] arm64: stacktrace: Use %pSb for backtrace printing

2021-04-09 Thread Stephen Boyd
Let's use the new printk format to print the stacktrace entry when
printing a backtrace to the kernel logs. This will include any module's
build ID[1] in it so that offline/crash debugging can easily locate the
debuginfo for a module via something like debuginfod[2].

Cc: Catalin Marinas 
Cc: Will Deacon 
Cc: 
Cc: Jiri Olsa 
Cc: Alexei Starovoitov 
Cc: Jessica Yu 
Cc: Evan Green 
Cc: Hsin-Yi Wang 
Cc: Petr Mladek 
Cc: Steven Rostedt 
Cc: Andy Shevchenko 
Cc: Matthew Wilcox 
Link: https://fedoraproject.org/wiki/Releases/FeatureBuildId [1]
Link: https://sourceware.org/elfutils/Debuginfod.html [2]
Signed-off-by: Stephen Boyd 
---
 arch/arm64/kernel/stacktrace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c
index ad20981dfda4..9d38da01ff98 100644
--- a/arch/arm64/kernel/stacktrace.c
+++ b/arch/arm64/kernel/stacktrace.c
@@ -129,7 +129,7 @@ NOKPROBE_SYMBOL(walk_stackframe);
 
 static void dump_backtrace_entry(unsigned long where, const char *loglvl)
 {
-   printk("%s %pS\n", loglvl, (void *)where);
+   printk("%s %pSb\n", loglvl, (void *)where);
 }
 
 void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk,
-- 
https://chromeos.dev



[PATCH v4 03/13] buildid: Stash away kernels build ID on init

2021-04-09 Thread Stephen Boyd
Parse the kernel's build ID at initialization so that other code can
print a hex format string representation of the running kernel's build
ID. This will be used in the kdump and dump_stack code so that
developers can easily locate the vmlinux debug symbols for a
crash/stacktrace.

Cc: Jiri Olsa 
Cc: Alexei Starovoitov 
Cc: Jessica Yu 
Cc: Evan Green 
Cc: Hsin-Yi Wang 
Cc: Dave Young 
Cc: Baoquan He 
Cc: Vivek Goyal 
Cc: 
Signed-off-by: Stephen Boyd 
---
 include/linux/buildid.h |  3 +++
 init/main.c |  1 +
 lib/buildid.c   | 15 +++
 3 files changed, 19 insertions(+)

diff --git a/include/linux/buildid.h b/include/linux/buildid.h
index ebce93f26d06..f375900cf9ed 100644
--- a/include/linux/buildid.h
+++ b/include/linux/buildid.h
@@ -10,4 +10,7 @@ int build_id_parse(struct vm_area_struct *vma, unsigned char 
*build_id,
   __u32 *size);
 int build_id_parse_buf(const void *buf, unsigned char *build_id, u32 buf_size);
 
+extern unsigned char vmlinux_build_id[BUILD_ID_SIZE_MAX];
+void init_vmlinux_build_id(void);
+
 #endif
diff --git a/init/main.c b/init/main.c
index 53b278845b88..eaede2f41327 100644
--- a/init/main.c
+++ b/init/main.c
@@ -857,6 +857,7 @@ asmlinkage __visible void __init __no_sanitize_address 
start_kernel(void)
set_task_stack_end_magic(_task);
smp_setup_processor_id();
debug_objects_early_init();
+   init_vmlinux_build_id();
 
cgroup_init_early();
 
diff --git a/lib/buildid.c b/lib/buildid.c
index 6aea1c4e5e85..1103ed46214f 100644
--- a/lib/buildid.c
+++ b/lib/buildid.c
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -172,3 +173,17 @@ int build_id_parse_buf(const void *buf, unsigned char 
*build_id, u32 buf_size)
 {
return parse_build_id_buf(build_id, NULL, buf, buf_size);
 }
+
+unsigned char vmlinux_build_id[BUILD_ID_SIZE_MAX] __ro_after_init;
+
+/**
+ * init_vmlinux_build_id - Compute and stash the running kernel's build ID
+ */
+void __init init_vmlinux_build_id(void)
+{
+   extern const void __start_notes __weak;
+   extern const void __stop_notes __weak;
+   unsigned int size = &__stop_notes - &__start_notes;
+
+   build_id_parse_buf(&__start_notes, vmlinux_build_id, size);
+}
-- 
https://chromeos.dev



[PATCH v4 04/13] dump_stack: Add vmlinux build ID to stack traces

2021-04-09 Thread Stephen Boyd
Add the running kernel's build ID[1] to the stacktrace information
header.  This makes it simpler for developers to locate the vmlinux with
full debuginfo for a particular kernel stacktrace. Combined with
scripts/decode_stracktrace.sh, a developer can download the correct
vmlinux from a debuginfod[2] server and find the exact file and line
number for the functions plus offsets in a stacktrace.

This is especially useful for pstore crash debugging where the kernel
crashes are recorded in the pstore logs and the recovery kernel is
different or the debuginfo doesn't exist on the device due to space
concerns (the data can be large and a security concern). The stacktrace
can be analyzed after the crash by using the build ID to find the
matching vmlinux and understand where in the function something went
wrong.

Example stacktrace from lkdtm:

 WARNING: CPU: 4 PID: 3255 at drivers/misc/lkdtm/bugs.c:83 
lkdtm_WARNING+0x28/0x30 [lkdtm]
 Modules linked in: lkdtm rfcomm algif_hash algif_skcipher af_alg xt_cgroup 
uinput xt_MASQUERADE
 CPU: 4 PID: 3255 Comm: bash Not tainted 5.11 #3 
aa23f7a1231c229de205662d5a9e0d4c580f19a1
 Hardware name: Google Lazor (rev3+) with KB Backlight (DT)
 pstate: 0049 (nzcv daif +PAN -UAO -TCO BTYPE=--)
 pc : lkdtm_WARNING+0x28/0x30 [lkdtm]

The hex string aa23f7a1231c229de205662d5a9e0d4c580f19a1 is the build ID,
following the kernel version number. Put it all behind a config option,
STACKTRACE_BUILD_ID, so that kernel developers can remove this
information if they decide it is too much.

Cc: Jiri Olsa 
Cc: Alexei Starovoitov 
Cc: Jessica Yu 
Cc: Evan Green 
Cc: Hsin-Yi Wang 
Cc: Petr Mladek 
Cc: Steven Rostedt 
Cc: Andy Shevchenko 
Cc: Matthew Wilcox 
Link: https://fedoraproject.org/wiki/Releases/FeatureBuildId [1]
Link: https://sourceware.org/elfutils/Debuginfod.html [2]
Signed-off-by: Stephen Boyd 
---
 lib/Kconfig.debug | 11 +++
 lib/dump_stack.c  | 13 +++--
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 2779c29d9981..5f883e50f406 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -35,6 +35,17 @@ config PRINTK_CALLER
  no option to enable/disable at the kernel command line parameter or
  sysfs interface.
 
+config STACKTRACE_BUILD_ID
+   bool "Show build ID information in stacktraces"
+   depends on PRINTK
+   help
+ Selecting this option adds build ID information for symbols in
+ stacktraces printed with the printk format '%p[SR]b'.
+
+ This option is intended for distros where debuginfo is not easily
+ accessible but can be downloaded given the build ID of the vmlinux or
+ kernel module where the function is located.
+
 config CONSOLE_LOGLEVEL_DEFAULT
int "Default console loglevel (1-15)"
range 1 15
diff --git a/lib/dump_stack.c b/lib/dump_stack.c
index f5a33b6f773f..d685331b065f 100644
--- a/lib/dump_stack.c
+++ b/lib/dump_stack.c
@@ -5,6 +5,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -36,6 +37,14 @@ void __init dump_stack_set_arch_desc(const char *fmt, ...)
va_end(args);
 }
 
+#if IS_ENABLED(CONFIG_STACKTRACE_BUILD_ID)
+#define BUILD_ID_FMT " %20phN"
+#define BUILD_ID_VAL vmlinux_build_id
+#else
+#define BUILD_ID_FMT "%s"
+#define BUILD_ID_VAL ""
+#endif
+
 /**
  * dump_stack_print_info - print generic debug info for dump_stack()
  * @log_lvl: log level
@@ -45,13 +54,13 @@ void __init dump_stack_set_arch_desc(const char *fmt, ...)
  */
 void dump_stack_print_info(const char *log_lvl)
 {
-   printk("%sCPU: %d PID: %d Comm: %.20s %s%s %s %.*s\n",
+   printk("%sCPU: %d PID: %d Comm: %.20s %s%s %s %.*s" BUILD_ID_FMT "\n",
   log_lvl, raw_smp_processor_id(), current->pid, current->comm,
   kexec_crash_loaded() ? "Kdump: loaded " : "",
   print_tainted(),
   init_utsname()->release,
   (int)strcspn(init_utsname()->version, " "),
-  init_utsname()->version);
+  init_utsname()->version, BUILD_ID_VAL);
 
if (dump_stack_arch_desc_str[0] != '\0')
printk("%sHardware name: %s\n",
-- 
https://chromeos.dev



[PATCH v4 02/13] buildid: Add API to parse build ID out of buffer

2021-04-09 Thread Stephen Boyd
Add an API that can parse the build ID out of a buffer, instead of a
vma, to support printing a kernel module's build ID for stack traces.

Cc: Jiri Olsa 
Cc: Alexei Starovoitov 
Cc: Jessica Yu 
Cc: Evan Green 
Cc: Hsin-Yi Wang 
Signed-off-by: Stephen Boyd 
---
 include/linux/buildid.h |  1 +
 lib/buildid.c   | 50 ++---
 2 files changed, 38 insertions(+), 13 deletions(-)

diff --git a/include/linux/buildid.h b/include/linux/buildid.h
index 40232f90db6e..ebce93f26d06 100644
--- a/include/linux/buildid.h
+++ b/include/linux/buildid.h
@@ -8,5 +8,6 @@
 
 int build_id_parse(struct vm_area_struct *vma, unsigned char *build_id,
   __u32 *size);
+int build_id_parse_buf(const void *buf, unsigned char *build_id, u32 buf_size);
 
 #endif
diff --git a/lib/buildid.c b/lib/buildid.c
index e014636ec3eb..6aea1c4e5e85 100644
--- a/lib/buildid.c
+++ b/lib/buildid.c
@@ -2,30 +2,23 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #define BUILD_ID 3
+
 /*
  * Parse build id from the note segment. This logic can be shared between
  * 32-bit and 64-bit system, because Elf32_Nhdr and Elf64_Nhdr are
  * identical.
  */
-static inline int parse_build_id(void *page_addr,
-unsigned char *build_id,
-__u32 *size,
-void *note_start,
-Elf32_Word note_size)
+static int parse_build_id_buf(unsigned char *build_id,
+ __u32 *size,
+ const void *note_start,
+ Elf32_Word note_size)
 {
Elf32_Word note_offs = 0, new_offs;
 
-   /* check for overflow */
-   if (note_start < page_addr || note_start + note_size < note_start)
-   return -EINVAL;
-
-   /* only supports note that fits in the first page */
-   if (note_start + note_size > page_addr + PAGE_SIZE)
-   return -EINVAL;
-
while (note_offs + sizeof(Elf32_Nhdr) < note_size) {
Elf32_Nhdr *nhdr = (Elf32_Nhdr *)(note_start + note_offs);
 
@@ -50,9 +43,27 @@ static inline int parse_build_id(void *page_addr,
break;
note_offs = new_offs;
}
+
return -EINVAL;
 }
 
+static inline int parse_build_id(void *page_addr,
+unsigned char *build_id,
+__u32 *size,
+void *note_start,
+Elf32_Word note_size)
+{
+   /* check for overflow */
+   if (note_start < page_addr || note_start + note_size < note_start)
+   return -EINVAL;
+
+   /* only supports note that fits in the first page */
+   if (note_start + note_size > page_addr + PAGE_SIZE)
+   return -EINVAL;
+
+   return parse_build_id_buf(build_id, size, note_start, note_size);
+}
+
 /* Parse build ID from 32-bit ELF */
 static int get_build_id_32(void *page_addr, unsigned char *build_id,
   __u32 *size)
@@ -148,3 +159,16 @@ int build_id_parse(struct vm_area_struct *vma, unsigned 
char *build_id,
put_page(page);
return ret;
 }
+
+/**
+ * build_id_parse_buf - Get build ID from a buffer
+ * @buf:  Elf note section(s) to parse
+ * @buf_size: Size of @buf in bytes
+ * @build_id: Build ID parsed from @buf, at least BUILD_ID_SIZE_MAX long
+ *
+ * Return: 0 on success, -EINVAL otherwise
+ */
+int build_id_parse_buf(const void *buf, unsigned char *build_id, u32 buf_size)
+{
+   return parse_build_id_buf(build_id, NULL, buf, buf_size);
+}
-- 
https://chromeos.dev



[PATCH v4 01/13] buildid: Only consider GNU notes for build ID parsing

2021-04-09 Thread Stephen Boyd
Some kernel elf files have various notes that also happen to have an elf
note type of '3', which matches NT_GNU_BUILD_ID but the note name isn't
"GNU". For example, this note trips up the existing logic:

 Owner  Data size   Description
 Xen0x0008  Unknown note type: (0x0003) description data: 00 00 00 
ff80    

Let's make sure that it is a GNU note when parsing the build ID so that
we can use this function to parse a vmlinux's build ID too.

Reported-by: Petr Mladek 
Cc: Jiri Olsa 
Cc: Alexei Starovoitov 
Cc: Jessica Yu 
Cc: Evan Green 
Cc: Hsin-Yi Wang 
Fixes: bd7525dacd7e ("bpf: Move stack_map_get_build_id into lib")
Signed-off-by: Stephen Boyd 
---
 lib/buildid.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/buildid.c b/lib/buildid.c
index 6156997c3895..e014636ec3eb 100644
--- a/lib/buildid.c
+++ b/lib/buildid.c
@@ -31,6 +31,7 @@ static inline int parse_build_id(void *page_addr,
 
if (nhdr->n_type == BUILD_ID &&
nhdr->n_namesz == sizeof("GNU") &&
+   !strcmp((char *)(nhdr + 1), "GNU") &&
nhdr->n_descsz > 0 &&
nhdr->n_descsz <= BUILD_ID_SIZE_MAX) {
memcpy(build_id,
-- 
https://chromeos.dev



[PATCH v4 00/13] Add build ID to stacktraces

2021-04-09 Thread Stephen Boyd
This series adds the kernel's build ID[1] to the stacktrace header printed
in oops messages, warnings, etc. and the build ID for any module that
appears in the stacktrace after the module name. The goal is to make the
stacktrace more self-contained and descriptive by including the relevant
build IDs in the kernel logs when something goes wrong. This can be used
by post processing tools like script/decode_stacktrace.sh and kernel
developers to easily locate the debug info associated with a kernel
crash and line up what line and file things started falling apart at.

To show how this can be used I've included a patch to
decode_stacktrace.sh that downloads the debuginfo from a debuginfod
server.

This also includes some patches to make the buildid.c file use more
const arguments and consolidate logic into buildid.c from kdump. These
are left to the end as they were mostly cleanup patches. I don't know
who exactly maintains this so I guess Andrew is the best option to merge
all this code.

Here's an example lkdtm stacktrace on arm64.

 WARNING: CPU: 4 PID: 3255 at drivers/misc/lkdtm/bugs.c:83 
lkdtm_WARNING+0x28/0x30 [lkdtm]
 Modules linked in: lkdtm rfcomm algif_hash algif_skcipher af_alg xt_cgroup 
uinput xt_MASQUERADE
 CPU: 4 PID: 3255 Comm: bash Not tainted 5.11 #3 
aa23f7a1231c229de205662d5a9e0d4c580f19a1
 Hardware name: Google Lazor (rev3+) with KB Backlight (DT)
 pstate: 0049 (nzcv daif +PAN -UAO -TCO BTYPE=--)
 pc : lkdtm_WARNING+0x28/0x30 [lkdtm]
 lr : lkdtm_do_action+0x24/0x40 [lkdtm]
 sp : ffc0134fbca0
 x29: ffc0134fbca0 x28: ff92d53ba240
 x27:  x26: 
 x25:  x24: ffe3622352c0
 x23: 0020 x22: ffe362233366
 x21: ffe3622352e0 x20: ffc0134fbde0
 x19: 0008 x18: 
 x17: ff929b6536fc x16: 
 x15:  x14: 0012
 x13: ffe380ed892c x12: ffe381d05068
 x11:  x10: 
 x9 : 0001 x8 : ffe362237000
 x7 :  x6 : 
 x5 :  x4 : 0001
 x3 : 0008 x2 : ff93fef25a70
 x1 : ff93fef15788 x0 : ffe3622352e0
 Call trace:
  lkdtm_WARNING+0x28/0x30 [lkdtm ed5019fdf5e53be37cb1ba7899292d7e143b259e]
  direct_entry+0x16c/0x1b4 [lkdtm ed5019fdf5e53be37cb1ba7899292d7e143b259e]
  full_proxy_write+0x74/0xa4
  vfs_write+0xec/0x2e8
  ksys_write+0x84/0xf0
  __arm64_sys_write+0x24/0x30
  el0_svc_common+0xf4/0x1c0
  do_el0_svc_compat+0x28/0x3c
  el0_svc_compat+0x10/0x1c
  el0_sync_compat_handler+0xa8/0xcc
  el0_sync_compat+0x178/0x180
 ---[ end trace 3d95032303e59e68 ]---

Changes from v3 
(https://lore.kernel.org/r/20210331030520.3816265-1-swb...@chromium.org):
 * Fixed compilation warnings due to config changes
 * Fixed kernel-doc on init_vmlinx_build_id()
 * Totally removed add_build_id_vmcoreinfo()
 * Added another printk format %pBb to help x86 print backtraces
 * Some BUILD_BUG_ON() checks to make sure the buildid doesn't get bigger or 
smaller

Changes from v2 
(https://lore.kernel.org/r/20210324020443.1815557-1-swb...@chromium.org):
 * Renamed symbol printing function to indicate build IDness
 * Put build ID information behind Kconfig knob
 * Build ID for vmlinux is calculated in early init instead of on demand
 * printk format is %pS[R]b

Changes from v1 
(https://lore.kernel.org/r/20210301174749.1269154-1-swb...@chromium.org):
 * New printk format %pSb and %pSr
 * Return binary format instead of hex format string from build ID APIs
 * Some new patches to cleanup buildid/decode_stacktrace.sh
 * A new patch to decode_stacktrace.sh to parse output

[1] https://fedoraproject.org/wiki/Releases/FeatureBuildId

Cc: Alexei Starovoitov 
Cc: Andy Shevchenko 
Cc: Baoquan He 
Cc: Borislav Petkov 
Cc: Catalin Marinas 
Cc: Dave Young 
Cc: Evan Green 
Cc: Hsin-Yi Wang 
Cc: Ingo Molnar 
Cc: Jessica Yu 
Cc: Jiri Olsa 
Cc: 
Cc: Konstantin Khlebnikov 
Cc: 
Cc: 
Cc: 
Cc: Matthew Wilcox 
Cc: Petr Mladek 
Cc: Rasmus Villemoes 
Cc: Sasha Levin 
Cc: Sergey Senozhatsky 
Cc: Steven Rostedt 
Cc: Thomas Gleixner 
Cc: Vivek Goyal 
Cc: Will Deacon 
Cc: 
Cc: Christoph Hellwig 
Cc: peter enderborg 


Stephen Boyd (13):
  buildid: Only consider GNU notes for build ID parsing
  buildid: Add API to parse build ID out of buffer
  buildid: Stash away kernels build ID on init
  dump_stack: Add vmlinux build ID to stack traces
  module: Add printk formats to add module build ID to stacktraces
  arm64: stacktrace: Use %pSb for backtrace printing
  x86/dumpstack: Use %pSb/%pBb for backtrace printing
  scripts/decode_stacktrace.sh: Support debuginfod
  scripts/decode_stacktrace.sh: Silence stderr messages from
addr2line/nm
  scripts/decode_stacktrace.sh: Indicate 'auto' can be used for base
path
  buildid: Mark some arguments const
  buildid: Fix kernel-doc notation
  kdump: Use vmlinux_build_id to simplify

 Documentation/core-api/printk-formats.rst | 11 +++
 

Re: [PATCH 0/5] mm/memcg: Reduce kmemcache memory accounting overhead

2021-04-09 Thread Roman Gushchin
On Fri, Apr 09, 2021 at 07:18:37PM -0400, Waiman Long wrote:
> With the recent introduction of the new slab memory controller, we
> eliminate the need for having separate kmemcaches for each memory
> cgroup and reduce overall kernel memory usage. However, we also add
> additional memory accounting overhead to each call of kmem_cache_alloc()
> and kmem_cache_free().
> 
> For workloads that require a lot of kmemcache allocations and
> de-allocations, they may experience performance regression as illustrated
> in [1].
> 
> With a simple kernel module that performs repeated loop of 100,000,000
> kmem_cache_alloc() and kmem_cache_free() of 64-byte object at module
> init. The execution time to load the kernel module with and without
> memory accounting were:
> 
>   with accounting = 6.798s
>   w/o  accounting = 1.758s
> 
> That is an increase of 5.04s (287%). With this patchset applied, the
> execution time became 4.254s. So the memory accounting overhead is now
> 2.496s which is a 50% reduction.

Hi Waiman!

Thank you for working on it, it's indeed very useful!
A couple of questions:
1) did your config included lockdep or not?
2) do you have a (rough) estimation how much each change contributes
   to the overall reduction?

Thanks!

> 
> It was found that a major part of the memory accounting overhead
> is caused by the local_irq_save()/local_irq_restore() sequences in
> updating local stock charge bytes and vmstat array, at least in x86
> systems. There are two such sequences in kmem_cache_alloc() and two
> in kmem_cache_free(). This patchset tries to reduce the use of such
> sequences as much as possible. In fact, it eliminates them in the common
> case. Another part of this patchset to cache the vmstat data update in
> the local stock as well which also helps.
> 
> [1] 
> https://lore.kernel.org/linux-mm/20210408193948.vfktg3azh2wrt56t@gabell/T/#u
> 
> Waiman Long (5):
>   mm/memcg: Pass both memcg and lruvec to mod_memcg_lruvec_state()
>   mm/memcg: Introduce obj_cgroup_uncharge_mod_state()
>   mm/memcg: Cache vmstat data in percpu memcg_stock_pcp
>   mm/memcg: Separate out object stock data into its own struct
>   mm/memcg: Optimize user context object stock access
> 
>  include/linux/memcontrol.h |  14 ++-
>  mm/memcontrol.c| 198 -
>  mm/percpu.c|   9 +-
>  mm/slab.h  |  32 +++---
>  4 files changed, 195 insertions(+), 58 deletions(-)
> 
> -- 
> 2.18.1
> 


[GIT PULL] clk fixes for v5.12-rc6

2021-04-09 Thread Stephen Boyd
The following changes since commit 148ddaa89d4a0a927c4353398096cc33687755c1:

  clk: qcom: gcc-sc7180: Use floor ops for the correct sdcc1 clk (2021-03-13 
13:00:05 -0800)

are available in the Git repository at:

  https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git 
tags/clk-fixes-for-linus

for you to fetch changes up to 50ce6826a48f119baf2794fa384a64efe9bd84a5:

  clk: fixed: fix double free in resource managed fixed-factor clock 
(2021-04-07 16:01:25 -0700)


Here's the latest pile of clk driver and clk framework fixes for this
release.

 - Two clk framework fixes for a long standing issue in
   clk_notifier_{register,unregister}() where we used a
   pointer that was for a struct containing a list head
   when there was no container struct

 - A compile warning fix for socfpga that's good to have

 - A double free problem with devm registered fixed factor clks

 - One last fix to the Qualcomm camera clk driver to use the
   right clk ops so clks don't get stuck and stop working
   because the firmware takes them for a ride.


Dmitry Baryshkov (1):
  clk: fixed: fix double free in resource managed fixed-factor clock

Krzysztof Kozlowski (1):
  clk: socfpga: fix iomem pointer cast on 64-bit

Lukasz Bartosik (2):
  clk: fix invalid usage of list cursor in register
  clk: fix invalid usage of list cursor in unregister

Taniya Das (1):
  clk: qcom: camcc: Update the clock ops for the SC7180

 drivers/clk/clk-fixed-factor.c  |  9 +++-
 drivers/clk/clk.c   | 47 +-
 drivers/clk/qcom/camcc-sc7180.c | 50 -
 drivers/clk/socfpga/clk-gate.c  |  2 +-
 4 files changed, 55 insertions(+), 53 deletions(-)

-- 
https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git/
https://git.kernel.org/pub/scm/linux/kernel/git/sboyd/spmi.git


Re: [PATCH 1/6] PM: runtime: enable wake irq after runtime_suspend hook called

2021-04-09 Thread Chunfeng Yun
On Fri, 2021-04-09 at 13:14 +0200, Rafael J. Wysocki wrote:
> On Fri, Apr 9, 2021 at 10:36 AM Chunfeng Yun  
> wrote:
> >
> > On Fri, 2021-04-09 at 08:39 +0300, Tony Lindgren wrote:
> > > * Chunfeng Yun  [210409 01:54]:
> > > > On Thu, 2021-04-08 at 19:41 +0200, Rafael J. Wysocki wrote:
> > > > > On Thu, Apr 8, 2021 at 11:35 AM Chunfeng Yun 
> > > > >  wrote:
> > > > > >
> > > > > > When the dedicated wake irq is level trigger, enable it before
> > > > > > calling runtime_suspend, will trigger an interrupt.
> > > > > >
> > > > > > e.g.
> > > > > > for a low level trigger type, it's low level at running time (0),
> > > > > > and becomes high level when enters suspend (runtime_suspend (1) is
> > > > > > called), a wakeup signal at (2) make it become low level, wake irq
> > > > > > will be triggered.
> > > > > >
> > > > > > --
> > > > > >|   ^ ^|
> > > > > >    | | --
> > > > > >  |<---(0)--->|<--(1)--|   (3)   (2)(4)
> > > > > >
> > > > > > if we enable the wake irq before calling runtime_suspend during (0),
> > > > > > an interrupt will arise, it causes resume immediately;
> > > > >
> > > > > But that's necessary to avoid missing a wakeup interrupt, isn't it?
> > > > That's also what I worry about.
> > >
> > > Yeah sounds like this patch will lead into missed wakeirqs.
> > If miss level trigger wakeirqs, that means HW doesn't latch it? is it HW
> > limitation?
> 
> If it's level-triggered, it won't be missed, but then it is just
> pointless to suspend the device when wakeup is being signaled in the
> first place.
Got it
> 
> I'm not sure if I understand the underlying problem correctly.  Is it
> about addressing spurious wakeups?
In fact, it's default value is the same as the wakeup signal, maybe the
above case, using level trigger, should be avoided, it is not clear and
causes confusion, as Ikjoon and Tony suggested, using falling edge type
is better.

Thanks a lot





[PATCH 6/6] staging: rtl8192e: align statements properly

2021-04-09 Thread Mitali Borkar
Aligned the statements properly in one line to make code neater and to
improve readability.

Signed-off-by: Mitali Borkar 
---
 drivers/staging/rtl8192e/rtl819x_HTProc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c 
b/drivers/staging/rtl8192e/rtl819x_HTProc.c
index 2b9e275f42bb..65202dd53447 100644
--- a/drivers/staging/rtl8192e/rtl819x_HTProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c
@@ -155,8 +155,8 @@ bool IsHTHalfNmodeAPs(struct rtllib_device *ieee)
retValue = true;
else if (!memcmp(net->bssid, UNKNOWN_BORADCOM, 3) ||
 !memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3) ||
-   !memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3) ||
-   (net->broadcom_cap_exist))
+!memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3) ||
+(net->broadcom_cap_exist))
retValue = true;
else if (net->bssht.bd_rt2rt_aggregation)
retValue = true;
@@ -809,7 +809,7 @@ void HTUseDefaultSetting(struct rtllib_device *ieee)
ieee->dot11HTOperationalRateSet);
ieee->HTHighestOperaRate = HTGetHighestMCSRate(ieee,
   
ieee->dot11HTOperationalRateSet,
-  MCS_FILTER_ALL);
+  MCS_FILTER_ALL);
ieee->HTCurrentOperaRate = ieee->HTHighestOperaRate;
 
} else {
-- 
2.30.2



[PATCH 5/6] staging: rtl8192e: removed multiple blank lines

2021-04-09 Thread Mitali Borkar
Removed multiple blank lines to make code better and neater.
Reported by checkpatch.

Signed-off-by: Mitali Borkar 
---
 drivers/staging/rtl8192e/rtl819x_HTProc.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c 
b/drivers/staging/rtl8192e/rtl819x_HTProc.c
index 12f31ba9aa13..2b9e275f42bb 100644
--- a/drivers/staging/rtl8192e/rtl819x_HTProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c
@@ -214,7 +214,6 @@ static u8 HTIOTActIsDisableMCS14(struct rtllib_device 
*ieee, u8 *PeerMacAddr)
return 0;
 }
 
-
 static bool HTIOTActIsDisableMCS15(struct rtllib_device *ieee)
 {
return false;
@@ -236,7 +235,6 @@ static u8 HTIOTActIsMgntUseCCK6M(struct rtllib_device *ieee,
 {
u8  retValue = 0;
 
-
if (ieee->pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM)
retValue = 1;
 
@@ -315,7 +313,6 @@ void HTConstructCapabilityElement(struct rtllib_device 
*ieee, u8 *posHTCap,
pCapELE->PSMP = 0;
pCapELE->LSigTxopProtect = 0;
 
-
netdev_dbg(ieee->dev,
   "TX HT cap/info ele BW=%d MaxAMSDUSize:%d DssCCk:%d\n",
   pCapELE->ChlWidth, pCapELE->MaxAMSDUSize, pCapELE->DssCCk);
@@ -390,7 +387,6 @@ void HTConstructInfoElement(struct rtllib_device *ieee, u8 
*posHTInfo,
 
memset(pHTInfoEle->BasicMSC, 0, 16);
 
-
*len = 22 + 2;
 
} else {
@@ -541,7 +537,6 @@ void HTOnAssocRsp(struct rtllib_device *ieee)
else
pPeerHTInfo = (struct ht_info_ele *)(pHTInfo->PeerHTInfoBuf);
 
-
 #ifdef VERBOSE_DEBUG
print_hex_dump_bytes("%s: ", __func__, DUMP_PREFIX_NONE,
 pPeerHTCap, sizeof(struct ht_capab_ele));
@@ -562,7 +557,6 @@ void HTOnAssocRsp(struct rtllib_device *ieee)
   ((pPeerHTCap->DssCCk == 1) ? true :
   false) : false);
 
-
pHTInfo->bCurrent_AMSDU_Support = pHTInfo->bAMSDU_Support;
 
nMaxAMSDUSize = (pPeerHTCap->MaxAMSDUSize == 0) ? 3839 : 7935;
@@ -752,7 +746,6 @@ void HTResetSelfAndSavePeerSetting(struct rtllib_device 
*ieee,
if (bIOTAction)
pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_ALL_2SS;
 
-
bIOTAction = HTIOTActIsDisableEDCATurbo(ieee, pNetwork->bssid);
if (bIOTAction)
pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_EDCA_TURBO;
-- 
2.30.2



[PATCH 4/6] staging: rtl8192e: matched alignment with open parenthesis

2021-04-09 Thread Mitali Borkar
Matched the alignment with open parenthesis to meet linux kernel coding
style.
Reported by checkpatch.

Signed-off-by: Mitali Borkar 
---
 drivers/staging/rtl8192e/rtl819x_HTProc.c | 20 ++--
 drivers/staging/rtl8192e/rtl819x_TSProc.c | 18 +-
 2 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c 
b/drivers/staging/rtl8192e/rtl819x_HTProc.c
index 0ded86da1562..12f31ba9aa13 100644
--- a/drivers/staging/rtl8192e/rtl819x_HTProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c
@@ -154,7 +154,7 @@ bool IsHTHalfNmodeAPs(struct rtllib_device *ieee)
(net->ralink_cap_exist))
retValue = true;
else if (!memcmp(net->bssid, UNKNOWN_BORADCOM, 3) ||
-   !memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3) ||
+!memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3) ||
!memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3) ||
(net->broadcom_cap_exist))
retValue = true;
@@ -547,7 +547,7 @@ void HTOnAssocRsp(struct rtllib_device *ieee)
 pPeerHTCap, sizeof(struct ht_capab_ele));
 #endif
HTSetConnectBwMode(ieee, (enum ht_channel_width)(pPeerHTCap->ChlWidth),
- (enum ht_extchnl_offset)(pPeerHTInfo->ExtChlOffset));
+  (enum ht_extchnl_offset)(pPeerHTInfo->ExtChlOffset));
pHTInfo->bCurTxBW40MHz = ((pPeerHTInfo->RecommemdedTxWidth == 1) ?
 true : false);
 
@@ -574,9 +574,9 @@ void HTOnAssocRsp(struct rtllib_device *ieee)
 
pHTInfo->bCurrentAMPDUEnable = pHTInfo->bAMPDUEnable;
if (ieee->rtllib_ap_sec_type &&
-  (ieee->rtllib_ap_sec_type(ieee) & (SEC_ALG_WEP | SEC_ALG_TKIP))) {
+   (ieee->rtllib_ap_sec_type(ieee) & (SEC_ALG_WEP | SEC_ALG_TKIP))) {
if ((pHTInfo->IOTPeer == HT_IOT_PEER_ATHEROS) ||
-   (pHTInfo->IOTPeer == HT_IOT_PEER_UNKNOWN))
+   (pHTInfo->IOTPeer == HT_IOT_PEER_UNKNOWN))
pHTInfo->bCurrentAMPDUEnable = false;
}
 
@@ -626,7 +626,7 @@ void HTOnAssocRsp(struct rtllib_device *ieee)
else
pMcsFilter = MCS_FILTER_ALL;
ieee->HTHighestOperaRate = HTGetHighestMCSRate(ieee,
-  ieee->dot11HTOperationalRateSet, pMcsFilter);
+  
ieee->dot11HTOperationalRateSet, pMcsFilter);
ieee->HTCurrentOperaRate = ieee->HTHighestOperaRate;
 
pHTInfo->CurrentOpMode = pPeerHTInfo->OptMode;
@@ -654,13 +654,13 @@ void HTInitializeHTInfo(struct rtllib_device *ieee)
pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor;
 
memset((void *)(&(pHTInfo->SelfHTCap)), 0,
-   sizeof(pHTInfo->SelfHTCap));
+  sizeof(pHTInfo->SelfHTCap));
memset((void *)(&(pHTInfo->SelfHTInfo)), 0,
-   sizeof(pHTInfo->SelfHTInfo));
+  sizeof(pHTInfo->SelfHTInfo));
memset((void *)(&(pHTInfo->PeerHTCapBuf)), 0,
-   sizeof(pHTInfo->PeerHTCapBuf));
+  sizeof(pHTInfo->PeerHTCapBuf));
memset((void *)(&(pHTInfo->PeerHTInfoBuf)), 0,
-   sizeof(pHTInfo->PeerHTInfoBuf));
+  sizeof(pHTInfo->PeerHTInfoBuf));
 
pHTInfo->bSwBwInProgress = false;
 
@@ -815,7 +815,7 @@ void HTUseDefaultSetting(struct rtllib_device *ieee)
HTFilterMCSRate(ieee, ieee->Regdot11TxHTOperationalRateSet,
ieee->dot11HTOperationalRateSet);
ieee->HTHighestOperaRate = HTGetHighestMCSRate(ieee,
-  ieee->dot11HTOperationalRateSet,
+  
ieee->dot11HTOperationalRateSet,
   MCS_FILTER_ALL);
ieee->HTCurrentOperaRate = ieee->HTHighestOperaRate;
 
diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c 
b/drivers/staging/rtl8192e/rtl819x_TSProc.c
index 1b994a57633f..65eac33aaa5b 100644
--- a/drivers/staging/rtl8192e/rtl819x_TSProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c
@@ -34,7 +34,7 @@ static void RxPktPendingTimeout(struct timer_list *t)
while (!list_empty(>rx_pending_pkt_list)) {
pReorderEntry = (struct rx_reorder_entry *)

list_entry(pRxTs->rx_pending_pkt_list.prev,
-   struct rx_reorder_entry, List);
+  struct rx_reorder_entry, 
List);
if (index == 0)
pRxTs->rx_indicate_seq = pReorderEntry->SeqNum;
 
@@ -45,7 +45,7 @@ static void RxPktPendingTimeout(struct timer_list *t)
list_del_init(>List);
 
if 

[PATCH 3/6] staging: rtl8192e: remove unncessary blank line after brace

2021-04-09 Thread Mitali Borkar
Removed an exra blank line after close brace '{' as it was not
necessary.
Reported by checkpatch

Signed-off-by: Mitali Borkar 
---
 drivers/staging/rtl8192e/rtl819x_HTProc.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c 
b/drivers/staging/rtl8192e/rtl819x_HTProc.c
index e188e9e6b11e..0ded86da1562 100644
--- a/drivers/staging/rtl8192e/rtl819x_HTProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c
@@ -492,7 +492,6 @@ u8 HTGetHighestMCSRate(struct rtllib_device *ieee, u8 
*pMCSRateSet,
 static u8 HTFilterMCSRate(struct rtllib_device *ieee, u8 *pSupportMCS,
  u8 *pOperateMCS)
 {
-
u8 i;
 
for (i = 0; i <= 15; i++)
@@ -686,7 +685,6 @@ void HTInitializeHTInfo(struct rtllib_device *ieee)
 
 void HTInitializeBssDesc(struct bss_ht *pBssHT)
 {
-
pBssHT->bd_support_ht = false;
memset(pBssHT->bd_ht_cap_buf, 0, sizeof(pBssHT->bd_ht_cap_buf));
pBssHT->bd_ht_cap_len = 0;
-- 
2.30.2



[PATCH 2/6] staging: rtl8192e: remove unnecessary blank line before brace

2021-04-09 Thread Mitali Borkar
Removed an extra blank line before close brace as it was not necessary.
Reported by checkpatch.

Signed-off-by: Mitali Borkar 
---
 drivers/staging/rtl8192e/rtl819x_HTProc.c | 2 --
 drivers/staging/rtl8192e/rtl819x_TSProc.c | 2 --
 2 files changed, 4 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c 
b/drivers/staging/rtl8192e/rtl819x_HTProc.c
index 7ed2ed9e63f6..e188e9e6b11e 100644
--- a/drivers/staging/rtl8192e/rtl819x_HTProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c
@@ -263,7 +263,6 @@ static void HTIOTActDetermineRaFunc(struct rtllib_device 
*ieee, bool bPeerRx2ss)
 
if (pHTInfo->IOTAction & HT_IOT_ACT_AMSDU_ENABLE)
pHTInfo->IOTRaFunc |= HT_IOT_RAFUNC_TX_AMSDU;
-
 }
 
 void HTResetIOTSetting(struct rt_hi_throughput *pHTInfo)
@@ -445,7 +444,6 @@ static u8 HT_PickMCSRate(struct rtllib_device *ieee, u8 
*pOperateMCS)
break;
default:
break;
-
}
 
return true;
diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c 
b/drivers/staging/rtl8192e/rtl819x_TSProc.c
index afcdb4b6a18e..1b994a57633f 100644
--- a/drivers/staging/rtl8192e/rtl819x_TSProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c
@@ -193,7 +193,6 @@ void TSInitialize(struct rtllib_device *ieee)
break;
pRxReorderEntry = >RxReorderEntry[count + 1];
}
-
 }
 
 static void AdmitTS(struct rtllib_device *ieee,
@@ -254,7 +253,6 @@ static struct ts_common_info *SearchAdmitTRStream(struct 
rtllib_device *ieee,
pRet->TSpec.f.TSInfo.field.ucTSID == TID &&
pRet->TSpec.f.TSInfo.field.ucDirection == dir)
break;
-
}
if (>List  != psearch_list)
break;
-- 
2.30.2



[PATCH 1/6] staging: rtl8192e: add spaces around binary operators

2021-04-09 Thread Mitali Borkar
Added spaces around binary operators like '+', '*', '|', '-', '&',
to improve readability and to meet linux kernel coding style.

Signed-off-by: Mitali Borkar 
---
 drivers/staging/rtl8192e/rtl819x_HTProc.c | 8 
 drivers/staging/rtl8192e/rtl819x_TSProc.c | 8 
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c 
b/drivers/staging/rtl8192e/rtl819x_HTProc.c
index cc761d965b1d..7ed2ed9e63f6 100644
--- a/drivers/staging/rtl8192e/rtl819x_HTProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c
@@ -138,7 +138,7 @@ u16  TxCountToDataRate(struct rtllib_device *ieee, u8 
nDataRate)
is40MHz = 1;
isShortGI = 1;
}
-   return MCS_DATA_RATE[is40MHz][isShortGI][nDataRate&0xf];
+   return MCS_DATA_RATE[is40MHz][isShortGI][nDataRate & 0xf];
 }
 
 bool IsHTHalfNmodeAPs(struct rtllib_device *ieee)
@@ -479,8 +479,8 @@ u8 HTGetHighestMCSRate(struct rtllib_device *ieee, u8 
*pMCSRateSet,
if (availableMcsRate[i] != 0) {
bitMap = availableMcsRate[i];
for (j = 0; j < 8; j++) {
-   if ((bitMap%2) != 0) {
-   if (HTMcsToDataRate(ieee, (8*i+j)) >
+   if ((bitMap % 2) != 0) {
+   if (HTMcsToDataRate(ieee, (8 * i + j)) >
HTMcsToDataRate(ieee, mcsRate))
mcsRate = 8 * i + j;
}
@@ -577,7 +577,7 @@ void HTOnAssocRsp(struct rtllib_device *ieee)
 
pHTInfo->bCurrentAMPDUEnable = pHTInfo->bAMPDUEnable;
if (ieee->rtllib_ap_sec_type &&
-  (ieee->rtllib_ap_sec_type(ieee)&(SEC_ALG_WEP|SEC_ALG_TKIP))) {
+  (ieee->rtllib_ap_sec_type(ieee) & (SEC_ALG_WEP | SEC_ALG_TKIP))) {
if ((pHTInfo->IOTPeer == HT_IOT_PEER_ATHEROS) ||
(pHTInfo->IOTPeer == HT_IOT_PEER_UNKNOWN))
pHTInfo->bCurrentAMPDUEnable = false;
diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c 
b/drivers/staging/rtl8192e/rtl819x_TSProc.c
index c294a6543e12..afcdb4b6a18e 100644
--- a/drivers/staging/rtl8192e/rtl819x_TSProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c
@@ -104,7 +104,7 @@ static void ResetTsCommonInfo(struct ts_common_info 
*pTsCommonInfo)
 {
eth_zero_addr(pTsCommonInfo->Addr);
memset(>TSpec, 0, sizeof(union tspec_body));
-   memset(>TClass, 0, sizeof(union qos_tclas)*TCLAS_NUM);
+   memset(>TClass, 0, sizeof(union qos_tclas) * TCLAS_NUM);
pTsCommonInfo->TClasProc = 0;
pTsCommonInfo->TClasNum = 0;
 }
@@ -189,9 +189,9 @@ void TSInitialize(struct rtllib_device *ieee)
for (count = 0; count < REORDER_ENTRY_NUM; count++) {
list_add_tail(>List,
  >RxReorder_Unused_List);
-   if (count == (REORDER_ENTRY_NUM-1))
+   if (count == (REORDER_ENTRY_NUM - 1))
break;
-   pRxReorderEntry = >RxReorderEntry[count+1];
+   pRxReorderEntry = >RxReorderEntry[count + 1];
}
 
 }
@@ -518,7 +518,7 @@ void TsStartAddBaProcess(struct rtllib_device *ieee, struct 
tx_ts_record *pTxTS)
  msecs_to_jiffies(TS_ADDBA_DELAY));
} else {
netdev_dbg(ieee->dev, "Immediately Start ADDBA\n");
-   mod_timer(>TsAddBaTimer, jiffies+10);
+   mod_timer(>TsAddBaTimer, jiffies + 10);
}
} else
netdev_dbg(ieee->dev, "BA timer is already added\n");
-- 
2.30.2



[PATCH 0/6] staging: rtl8192e: cleanup patchset for style issues

2021-04-09 Thread Mitali Borkar
This patches fix the cleanup style issues.

Mitali Borkar (6):
  staging: rtl8192e: add spaces around binary operators
  staging: rtl8192e: remove unnecessary blank line before brace
  staging: rtl8192e: remove unncessary blank line after brace
  staging: rtl8192e: matched alignment with open parenthesis
  staging: rtl8192e: removed multiple blank lines
  staging: rtl8192e: align statements properly

 drivers/staging/rtl8192e/rtl819x_HTProc.c | 43 +--
 drivers/staging/rtl8192e/rtl819x_TSProc.c | 28 +++
 2 files changed, 29 insertions(+), 42 deletions(-)

-- 
2.30.2



Re: [RFC PATCH v2 00/18] Use obj_cgroup APIs to charge the LRU pages

2021-04-09 Thread Roman Gushchin
On Fri, Apr 09, 2021 at 08:29:41PM +0800, Muchun Song wrote:
> Since the following patchsets applied. All the kernel memory are charged
> with the new APIs of obj_cgroup.
> 
>   [v17,00/19] The new cgroup slab memory controller
>   [v5,0/7] Use obj_cgroup APIs to charge kmem pages
> 
> But user memory allocations (LRU pages) pinning memcgs for a long time -
> it exists at a larger scale and is causing recurring problems in the real
> world: page cache doesn't get reclaimed for a long time, or is used by the
> second, third, fourth, ... instance of the same job that was restarted into
> a new cgroup every time. Unreclaimable dying cgroups pile up, waste memory,
> and make page reclaim very inefficient.
> 
> We can convert LRU pages and most other raw memcg pins to the objcg direction
> to fix this problem, and then the LRU pages will not pin the memcgs.
> 
> This patchset aims to make the LRU pages to drop the reference to memory
> cgroup by using the APIs of obj_cgroup. Finally, we can see that the number
> of the dying cgroups will not increase if we run the following test script.
> 
> ```bash
> #!/bin/bash
> 
> cat /proc/cgroups | grep memory
> 
> cd /sys/fs/cgroup/memory
> 
> for i in range{1..500}
> do
>   mkdir test
>   echo $$ > test/cgroup.procs
>   sleep 60 &
>   echo $$ > cgroup.procs
>   echo `cat test/cgroup.procs` > cgroup.procs
>   rmdir test
> done
> 
> cat /proc/cgroups | grep memory
> ```
> 
> Patch 1 aims to fix page charging in page replacement.
> Patch 2-5 are code cleanup and simplification.
> Patch 6-18 convert LRU pages pin to the objcg direction.
> 
> Any comments are welcome. Thanks.

Indeed the problem exists for a long time and it would be nice to fix it.
However I'm against merging the patchset in the current form (there are some
nice fixes/clean-ups, which can/must be applied independently). Let me explain
my concerns:

Back to the new slab controller discussion obj_cgroup was suggested by Johannes
as a union of two concepts:
1) reparenting (basically an auto-pointer to a memcg in c++ terms)
2) byte-sized accounting

I was initially against this union because I anticipated that the reparenting
part will be useful separately. And the time told it was true.

I still think obj_cgroup API must be significantly reworked before being
applied outside of the kmem area: reparenting part must be separated
and moved to the cgroup core level to be used not only in the memcg
context but also for other controllers, which are facing similar problems.
Spilling obj_cgroup API in the current form over all memcg code will
make it more complicated and will delay it, given the amount of changes
and the number of potential code conflicts.

I'm working on the generalization of obj_cgroup API (as described above)
and expect to have some patches next week.

Thanks!


Re: [PATCH -next] ext4: fix error return code in ext4_fc_perform_commit()

2021-04-09 Thread Theodore Ts'o
On Thu, Apr 08, 2021 at 03:00:33PM +0800, Xu Yihang wrote:
> In case of if not ext4_fc_add_tlv branch, an error return code is missing.
> 
> Fixes: aa75f4d3daae ("ext4: main fast-commit commit path")
> Reported-by: Hulk Robot 
> Signed-off-by: Xu Yihang 

Thanks, applied.

- Ted


Re: [PATCH v2] usb: cdnsp: Fixes issue with Configure Endpoint command

2021-04-09 Thread Peter Chen
On 21-04-07 08:36:29, Pawel Laszczak wrote:
> From: Pawel Laszczak 
> 
> Patch adds flag EP_UNCONFIGURED to detect whether endpoint was
> unconfigured. This flag is set in cdnsp_reset_device after Reset Device
> command. Among others this command disables all non control endpoints.
> Flag is used in cdnsp_gadget_ep_disable to protect controller against
> invoking Configure Endpoint command on disabled endpoint. Lack of this
> protection in some cases caused that Configure Endpoint command completed
> with Context State Error code completion.
> 
> Fixes: 3d82904559f4 ("usb: cdnsp: cdns3 Add main part of Cadence USBSSP DRD 
> Driver")
> Signed-off-by: Pawel Laszczak 

Pawel, it is a little late for v5.12, I apply it to v5.13-rc1 if you
don't mind.

Peter
> 
> ---
> Changelog:
> v2:
> - removed useless blank line
> - changed the EP_UNCONFIGURED to limit changes in patch
> 
>  drivers/usb/cdns3/cdnsp-gadget.c | 17 -
>  drivers/usb/cdns3/cdnsp-gadget.h |  1 +
>  2 files changed, 13 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/usb/cdns3/cdnsp-gadget.c 
> b/drivers/usb/cdns3/cdnsp-gadget.c
> index d7d4bdd57f46..56707b6b0f57 100644
> --- a/drivers/usb/cdns3/cdnsp-gadget.c
> +++ b/drivers/usb/cdns3/cdnsp-gadget.c
> @@ -727,7 +727,7 @@ int cdnsp_reset_device(struct cdnsp_device *pdev)
>* are in Disabled state.
>*/
>   for (i = 1; i < CDNSP_ENDPOINTS_NUM; ++i)
> - pdev->eps[i].ep_state |= EP_STOPPED;
> + pdev->eps[i].ep_state |= EP_STOPPED | EP_UNCONFIGURED;
>  
>   trace_cdnsp_handle_cmd_reset_dev(slot_ctx);
>  
> @@ -942,6 +942,7 @@ static int cdnsp_gadget_ep_enable(struct usb_ep *ep,
>  
>   pep = to_cdnsp_ep(ep);
>   pdev = pep->pdev;
> + pep->ep_state &= ~EP_UNCONFIGURED;
>  
>   if (dev_WARN_ONCE(pdev->dev, pep->ep_state & EP_ENABLED,
> "%s is already enabled\n", pep->name))
> @@ -1023,9 +1024,13 @@ static int cdnsp_gadget_ep_disable(struct usb_ep *ep)
>   goto finish;
>   }
>  
> - cdnsp_cmd_stop_ep(pdev, pep);
>   pep->ep_state |= EP_DIS_IN_RROGRESS;
> - cdnsp_cmd_flush_ep(pdev, pep);
> +
> + /* Endpoint was unconfigured by Reset Device command. */
> + if (!(pep->ep_state & EP_UNCONFIGURED)) {
> + cdnsp_cmd_stop_ep(pdev, pep);
> + cdnsp_cmd_flush_ep(pdev, pep);
> + }
>  
>   /* Remove all queued USB requests. */
>   while (!list_empty(>pending_list)) {
> @@ -1043,10 +1048,12 @@ static int cdnsp_gadget_ep_disable(struct usb_ep *ep)
>  
>   cdnsp_endpoint_zero(pdev, pep);
>  
> - ret = cdnsp_update_eps_configuration(pdev, pep);
> + if (!(pep->ep_state & EP_UNCONFIGURED))
> + ret = cdnsp_update_eps_configuration(pdev, pep);
> +
>   cdnsp_free_endpoint_rings(pdev, pep);
>  
> - pep->ep_state &= ~EP_ENABLED;
> + pep->ep_state &= ~(EP_ENABLED | EP_UNCONFIGURED);
>   pep->ep_state |= EP_STOPPED;
>  
>  finish:
> diff --git a/drivers/usb/cdns3/cdnsp-gadget.h 
> b/drivers/usb/cdns3/cdnsp-gadget.h
> index 6bbb26548c04..783ca8ffde00 100644
> --- a/drivers/usb/cdns3/cdnsp-gadget.h
> +++ b/drivers/usb/cdns3/cdnsp-gadget.h
> @@ -835,6 +835,7 @@ struct cdnsp_ep {
>  #define EP_WEDGE BIT(4)
>  #define EP0_HALTED_STATUSBIT(5)
>  #define EP_HAS_STREAMS   BIT(6)
> +#define EP_UNCONFIGURED  BIT(7)
>  
>   bool skip;
>  };
> -- 
> 2.25.1
> 

-- 

Thanks,
Peter Chen



[PATCH v2] usb: core: reduce power-on-good delay time of root hub

2021-04-09 Thread Chunfeng Yun
Return the exactly delay time given by root hub descriptor,
this helps to reduce resume time etc.

Due to the root hub descriptor is usually provided by the host
controller driver, if there is compatibility for a root hub,
we can fix it easily without affect other root hub

Acked-by: Alan Stern 
Signed-off-by: Chunfeng Yun 
---
v2: remove RFC tag, and add acked-by Alan
---
 drivers/usb/core/hub.h | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h
index 73f4482d833a..22ea1f4f2d66 100644
--- a/drivers/usb/core/hub.h
+++ b/drivers/usb/core/hub.h
@@ -148,8 +148,10 @@ static inline unsigned hub_power_on_good_delay(struct 
usb_hub *hub)
 {
unsigned delay = hub->descriptor->bPwrOn2PwrGood * 2;
 
-   /* Wait at least 100 msec for power to become stable */
-   return max(delay, 100U);
+   if (!hub->hdev->parent) /* root hub */
+   return delay;
+   else /* Wait at least 100 msec for power to become stable */
+   return max(delay, 100U);
 }
 
 static inline int hub_port_debounce_be_connected(struct usb_hub *hub,
-- 
2.18.0



Re:Re: [PATCH v1] drm/radeon: Fix a missing check bug in radeon_dp_mst_detect()

2021-04-09 Thread Yingjie Wang
My pleasure!
At 2021-04-09 04:17:36, "Alex Deucher"  wrote:
>Applied.  Thanks!
>
>Alex
>
>On Wed, Apr 7, 2021 at 2:23 AM  wrote:
>>
>> From: Yingjie Wang 
>>
>> In radeon_dp_mst_detect(), We should check whether or not @connector
>> has been unregistered from userspace. If the connector is unregistered,
>> we should return disconnected status.
>>
>> Fixes: 9843ead08f18 ("drm/radeon: add DisplayPort MST support (v2)")
>> Signed-off-by: Yingjie Wang 
>> ---
>>  drivers/gpu/drm/radeon/radeon_dp_mst.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/radeon/radeon_dp_mst.c 
>> b/drivers/gpu/drm/radeon/radeon_dp_mst.c
>> index 2c32186c4acd..4e4c937c36c6 100644
>> --- a/drivers/gpu/drm/radeon/radeon_dp_mst.c
>> +++ b/drivers/gpu/drm/radeon/radeon_dp_mst.c
>> @@ -242,6 +242,9 @@ radeon_dp_mst_detect(struct drm_connector *connector,
>> to_radeon_connector(connector);
>> struct radeon_connector *master = radeon_connector->mst_port;
>>
>> +   if (drm_connector_is_unregistered(connector))
>> +   return connector_status_disconnected;
>> +
>> return drm_dp_mst_detect_port(connector, ctx, >mst_mgr,
>>   radeon_connector->port);
>>  }
>> --
>> 2.7.4
>>
>> ___
>> dri-devel mailing list
>> dri-de...@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/dri-devel


RE: [PATCH v7 06/11] scsi: ufshpb: Region inactivation in host mode

2021-04-09 Thread Avri Altman


> > >> On 2021-04-06 13:20, Avri Altman wrote:
> > >> >> > -static void __ufshpb_evict_region(struct ufshpb_lu *hpb,
> > >> >> > -   struct ufshpb_region *rgn)
> > >> >> > +static int __ufshpb_evict_region(struct ufshpb_lu *hpb,
> > >> >> > +  struct ufshpb_region *rgn)
> > >> >> >  {
> > >> >> >   struct victim_select_info *lru_info;
> > >> >> >   struct ufshpb_subregion *srgn;
> > >> >> >   int srgn_idx;
> > >> >> >
> > >> >> > + lockdep_assert_held(>rgn_state_lock);
> > >> >> > +
> > >> >> > + if (hpb->is_hcm) {
> > >> >> > + unsigned long flags;
> > >> >> > + int ret;
> > >> >> > +
> > >> >> > + spin_unlock_irqrestore(>rgn_state_lock, flags);
> > >> >>
> > >> >> Never seen a usage like this... Here flags is used without being
> > >> >> intialized.
> > >> >> The flag is needed when spin_unlock_irqrestore ->
> > >> >> local_irq_restore(flags) to
> > >> >> restore the DAIF register (in terms of ARM).
> > >> > OK.
> > >>
> > >> Hi Avri,
> > >>
> > >> Checked on my setup, this lead to compilation error. Will you fix it
> > >> in
> > >> next version?
> > >>
> > >> warning: variable 'flags' is uninitialized when used here
> > >> [-Wuninitialized]
> > > Yeah - I will pass it to __ufshpb_evict_region and drop the
> > > lockdep_assert call.
Please ignore it.  This of course won't do.
Will fix it in v8.

Thanks,
Avri


  1   2   3   4   5   6   7   8   9   10   >