Re: [PATCH v2 2/2] mmc: Add support for the ASPEED SD controller
On 26/07/19 3:52 AM, Andrew Jeffery wrote: > On Thu, 25 Jul 2019, at 22:49, Adrian Hunter wrote: >> On 12/07/19 6:32 AM, Andrew Jeffery wrote: >>> +static int aspeed_sdhci_probe(struct platform_device *pdev) >>> +{ >>> + struct sdhci_pltfm_host *pltfm_host; >>> + struct aspeed_sdhci *dev; >>> + struct sdhci_host *host; >>> + struct resource *res; >>> + int slot; >>> + int ret; >>> + >>> + host = sdhci_pltfm_init(pdev, _sdc_pdata, sizeof(*dev)); >>> + if (IS_ERR(host)) >>> + return PTR_ERR(host); >>> + >>> + pltfm_host = sdhci_priv(host); >>> + dev = sdhci_pltfm_priv(pltfm_host); >>> + dev->parent = dev_get_drvdata(pdev->dev.parent); >>> + >>> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); >>> + slot = aspeed_sdhci_calculate_slot(dev, res); >>> + if (slot < 0) >>> + return slot; >>> + dev_info(>dev, "Configuring for slot %d\n", slot); >>> + dev->width_mask = !slot ? ASPEED_SDC_S0MMC8 : ASPEED_SDC_S1MMC8; >> >> That implies that you only support 2 slots which begs the question why >> you don't validate slot. > > I'm not sure what you mean here, but I'll dig into it. I just meant, if you only support 2 slots: if (slot > 1) return -EINVAL;
Re: [alsa-devel] [RFC PATCH 26/40] soundwire: cadence_master: fix divider setting in clock register
在 7/26/2019 1:19 PM, Bard liao 写道: On 7/26/2019 7:40 AM, Pierre-Louis Bossart wrote: From: Rander Wang The existing code uses an OR operation which would mix the original divider setting with the new one, resulting in an invalid configuration that can make codecs hang. Add the mask definition and use cdns_updatel to update divider Signed-off-by: Rander Wang Signed-off-by: Pierre-Louis Bossart --- drivers/soundwire/cadence_master.c | 12 +++- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/soundwire/cadence_master.c b/drivers/soundwire/cadence_master.c index 10ebcef2e84e..18c6ac026e85 100644 --- a/drivers/soundwire/cadence_master.c +++ b/drivers/soundwire/cadence_master.c @@ -57,6 +57,7 @@ #define CDNS_MCP_SSP_CTRL1 0x28 #define CDNS_MCP_CLK_CTRL0 0x30 #define CDNS_MCP_CLK_CTRL1 0x38 +#define CDNS_MCP_CLK_MCLKD_MASK GENMASK(7, 0) #define CDNS_MCP_STAT 0x40 @@ -988,9 +989,11 @@ int sdw_cdns_init(struct sdw_cdns *cdns) /* Set clock divider */ divider = (prop->mclk_freq / prop->max_clk_freq) - 1; val = cdns_readl(cdns, CDNS_MCP_CLK_CTRL0); Do we still need to read cdns_readl(cdns, CDNS_MCP_CLK_CTRL0) after this change? The val is used to print debug message, and my opinion is to change the log from pr_err("plb: ") to dev_dbg(bus->dev, "") to follow the dev_dbg usage in this file. - val |= divider; - cdns_writel(cdns, CDNS_MCP_CLK_CTRL0, val); - cdns_writel(cdns, CDNS_MCP_CLK_CTRL1, val); + + cdns_updatel(cdns, CDNS_MCP_CLK_CTRL0, + CDNS_MCP_CLK_MCLKD_MASK, divider); + cdns_updatel(cdns, CDNS_MCP_CLK_CTRL1, + CDNS_MCP_CLK_MCLKD_MASK, divider); pr_err("plb: mclk %d max_freq %d divider %d register %x\n", prop->mclk_freq, @@ -1064,8 +1067,7 @@ int cdns_bus_conf(struct sdw_bus *bus, struct sdw_bus_params *params) mcp_clkctrl_off = CDNS_MCP_CLK_CTRL0; mcp_clkctrl = cdns_readl(cdns, mcp_clkctrl_off); Same here. Also refine the debug log. - mcp_clkctrl |= divider; - cdns_writel(cdns, mcp_clkctrl_off, mcp_clkctrl); + cdns_updatel(cdns, mcp_clkctrl_off, CDNS_MCP_CLK_MCLKD_MASK, divider); pr_err("plb: mclk * 2 %d curr_dr_freq %d divider %d register %x\n", prop->mclk_freq * SDW_DOUBLE_RATE_FACTOR,
Re: [PATCH] rbtree: sync up the tools/ copy of the code with the main one
On Thu, Jul 25, 2019 at 8:19 PM Andrew Morton wrote: > On Tue, 2 Jul 2019 20:48:12 -0700 Michel Lespinasse > wrote: > > > I should probably have done this in the same commit that changed the > > main rbtree code to avoid generating code twice for the cached rbtree > > versions. > > > > Not copying the reviewers of the previous change as tools/ is just another > > copy of it. Copying LKML anyway because the additional noise > > won't make as much of a difference there :) > > That isn't really a changelog. Could we please have a few words > describing the change? Was it a simple `cp'? Hmmm, sorry about that. Here is what I propose as a changelog: --- rbtree: avoid generating code twice for the cached versions (tools copy) As was already noted in rbtree.h, the logic to cache rb_first (or rb_last) can easily be implemented externally to the core rbtree api. This commit takes the changes applied to the include/linux/ and lib/ rbtree files in commit 9f973cb38088, and applies these to the tools/include/linux/ and tools/lib/ files as well to keep them synchronized. Signed-off-by: Michel Lespinasse --- The files are not a straight copy, but are very close. I opened the tools/include/linux rbtree files, cut out the parts that were modified in commit 9f973cb38088, then pasted the corresponding replacements from that commit. Then I diffed the exported commits against each other for a sanity check - they differ only in their context and in irrelevant detail (for example whether some removed function had some EXPORT_SYMBOL on them). -- Michel "Walken" Lespinasse A program is never fully debugged until the last user dies.
Re: linux-next: build warning after merge of the tip tree
Hi Josh, On Thu, 25 Jul 2019 23:49:09 -0500 Josh Poimboeuf wrote: > > This will be fixed by: > > > https://lkml.kernel.org/r/51a4155c5bc2ca847a9cbe85c1c11918bb193141.1564086017.git.jpoim...@redhat.com Thanks -- Cheers, Stephen Rothwell pgpIcuqnFnGu_.pgp Description: OpenPGP digital signature
[PATCH 07/17] ARM: dts: witherspoon: Cleanup gpio-keys-polled properties
dtbs_check gave the following warning: Warning (avoid_unnecessary_addr_size): /gpio-keys-polled: unnecessary #address-cells/#size-cells without "ranges" or child "reg" property Cc: Joel Stanley Signed-off-by: Andrew Jeffery --- arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts b/arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts index 08facb2120b2..06319c6771ca 100644 --- a/arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +++ b/arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts @@ -77,8 +77,6 @@ gpio-keys-polled { compatible = "gpio-keys-polled"; - #address-cells = <1>; - #size-cells = <0>; poll-interval = <1000>; fan0-presence { -- 2.20.1
[RFC PATCH 16/17] ARM: dts: aspeed-g5: Change KCS nodes to v2 binding
Fixes the following warnings: arch/arm/boot/dts/aspeed-g5.dtsi:376.19-381.8: Warning (unit_address_vs_reg): /ahb/apb/lpc@1e789000/lpc-bmc@0/kcs1@0: node has a unit name, but no reg property arch/arm/boot/dts/aspeed-g5.dtsi:382.19-387.8: Warning (unit_address_vs_reg): /ahb/apb/lpc@1e789000/lpc-bmc@0/kcs2@0: node has a unit name, but no reg property arch/arm/boot/dts/aspeed-g5.dtsi:388.19-393.8: Warning (unit_address_vs_reg): /ahb/apb/lpc@1e789000/lpc-bmc@0/kcs3@0: node has a unit name, but no reg property arch/arm/boot/dts/aspeed-g5.dtsi:405.19-410.8: Warning (unit_address_vs_reg): /ahb/apb/lpc@1e789000/lpc-host@80/kcs4@0: node has a unit name, but no reg property arch/arm/boot/dts/aspeed-g5.dtsi:376.19-381.8: Warning (unique_unit_address): /ahb/apb/lpc@1e789000/lpc-bmc@0/kcs1@0: duplicate unit-address (also used in node /ahb/apb/lpc@1e789000/lpc-bmc@0/kcs2@0) arch/arm/boot/dts/aspeed-g5.dtsi:376.19-381.8: Warning (unique_unit_address): /ahb/apb/lpc@1e789000/lpc-bmc@0/kcs1@0: duplicate unit-address (also used in node /ahb/apb/lpc@1e789000/lpc-bmc@0/kcs3@0) arch/arm/boot/dts/aspeed-g5.dtsi:382.19-387.8: Warning (unique_unit_address): /ahb/apb/lpc@1e789000/lpc-bmc@0/kcs2@0: duplicate unit-address (also used in node /ahb/apb/lpc@1e789000/lpc-bmc@0/kcs3@0) arch/arm/boot/dts/aspeed-g5.dtsi:405.19-410.8: Warning (unique_unit_address): /ahb/apb/lpc@1e789000/lpc-host@80/kcs4@0: duplicate unit-address (also used in node /ahb/apb/lpc@1e789000/lpc-host@80/lpc-ctrl@0) Cc: Haiyue Wang Signed-off-by: Andrew Jeffery --- arch/arm/boot/dts/aspeed-g5.dtsi | 24 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/arch/arm/boot/dts/aspeed-g5.dtsi b/arch/arm/boot/dts/aspeed-g5.dtsi index 92c659c50b4c..50ba58dc5093 100644 --- a/arch/arm/boot/dts/aspeed-g5.dtsi +++ b/arch/arm/boot/dts/aspeed-g5.dtsi @@ -373,22 +373,22 @@ #size-cells = <1>; ranges = <0x0 0x0 0x80>; - kcs1: kcs1@0 { - compatible = "aspeed,ast2500-kcs-bmc"; + kcs1: kcs@24 { + compatible = "aspeed,ast2500-kcs-bmc-v2"; + reg = <0x24 0x1>, <0x30 0x1>, <0x3c 0x1>; interrupts = <8>; - kcs_chan = <1>; status = "disabled"; }; - kcs2: kcs2@0 { - compatible = "aspeed,ast2500-kcs-bmc"; + kcs2: kcs@28 { + compatible = "aspeed,ast2500-kcs-bmc-v2"; + reg = <0x28 0x1>, <0x34 0x1>, <0x40 0x1>; interrupts = <8>; - kcs_chan = <2>; status = "disabled"; }; - kcs3: kcs3@0 { - compatible = "aspeed,ast2500-kcs-bmc"; + kcs3: kcs@2c { + compatible = "aspeed,ast2500-kcs-bmc-v2"; + reg = <0x2c 0x1>, <0x38 0x1>, <0x44 0x1>; interrupts = <8>; - kcs_chan = <3>; status = "disabled"; }; }; @@ -402,10 +402,10 @@ #size-cells = <1>; ranges = <0x0 0x80 0x1e0>; - kcs4: kcs4@0 { - compatible = "aspeed,ast2500-kcs-bmc"; + kcs4: kcs@94 { + compatible = "aspeed,ast2500-kcs-bmc-v2"; + reg = <0x94 0x1>, <0x98 0x1>, <0x9c 0x1>; interrupts = <8>; - kcs_chan = <4>; status = "disabled"; }; -- 2.20.1
[RFC PATCH 17/17] ARM: dts: aspeed-g5: Sort LPC child nodes by unit address
Lets try to maintain some sort of sanity. Signed-off-by: Andrew Jeffery --- arch/arm/boot/dts/aspeed-g5.dtsi | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/arm/boot/dts/aspeed-g5.dtsi b/arch/arm/boot/dts/aspeed-g5.dtsi index 50ba58dc5093..99d2995a43db 100644 --- a/arch/arm/boot/dts/aspeed-g5.dtsi +++ b/arch/arm/boot/dts/aspeed-g5.dtsi @@ -423,17 +423,18 @@ status = "disabled"; }; - lhc: lhc@20 { - compatible = "aspeed,ast2500-lhc"; - reg = <0x20 0x24 0x48 0x8>; - }; - lpc_reset: reset-controller@18 { compatible = "aspeed,ast2500-lpc-reset"; reg = <0x18 0x4>; #reset-cells = <1>; }; + lhc: lhc@20 { + compatible = "aspeed,ast2500-lhc"; + reg = <0x20 0x24 0x48 0x8>; + }; + + ibt: ibt@c0 { compatible = "aspeed,ast2500-ibt-bmc"; reg = <0xc0 0x18>; -- 2.20.1
[RFC PATCH 15/17] ipmi: kcs: aspeed: Implement v2 bindings
The v2 bindings allow us to extract the resources from the devicetree. The table in the driver is retained to derive the channel index, which removes the need for kcs_chan property from the v1 bindings. The v2 bindings allow us to reduce the number of warnings generated by the existing devicetree nodes. Cc: Haiyue Wang Cc: Corey Minyard Cc: Arnd Bergmann Cc: Greg Kroah-Hartman Cc: openipmi-develo...@lists.sourceforge.net Signed-off-by: Andrew Jeffery --- drivers/char/ipmi/kcs_bmc_aspeed.c | 156 +++-- 1 file changed, 127 insertions(+), 29 deletions(-) diff --git a/drivers/char/ipmi/kcs_bmc_aspeed.c b/drivers/char/ipmi/kcs_bmc_aspeed.c index e3dd09022589..509e0d3c6eb1 100644 --- a/drivers/char/ipmi/kcs_bmc_aspeed.c +++ b/drivers/char/ipmi/kcs_bmc_aspeed.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -233,38 +234,133 @@ static const struct kcs_ioreg ast_kcs_bmc_ioregs[KCS_CHANNEL_MAX] = { { .idr = LPC_IDR4, .odr = LPC_ODR4, .str = LPC_STR4 }, }; +static struct kcs_bmc *aspeed_kcs_probe_of_v1(struct platform_device *pdev) +{ + struct aspeed_kcs_bmc *priv; + struct device_node *np; + struct kcs_bmc *kcs; + u32 channel; + u32 slave; + int rc; + + np = pdev->dev.of_node; + + rc = of_property_read_u32(np, "kcs_chan", ); + if ((rc != 0) || (channel == 0 || channel > KCS_CHANNEL_MAX)) { + dev_err(>dev, "no valid 'kcs_chan' configured\n"); + return ERR_PTR(-EINVAL); + } + + kcs = kcs_bmc_alloc(>dev, sizeof(struct aspeed_kcs_bmc), channel); + if (!kcs) + return ERR_PTR(-ENOMEM); + + priv = kcs_bmc_priv(kcs); + priv->map = syscon_node_to_regmap(pdev->dev.parent->of_node); + if (IS_ERR(priv->map)) { + dev_err(>dev, "Couldn't get regmap\n"); + return ERR_PTR(-ENODEV); + } + + rc = of_property_read_u32(np, "kcs_addr", ); + if (rc) { + dev_err(>dev, "no valid 'kcs_addr' configured\n"); + return ERR_PTR(-EINVAL); + } + + kcs->ioreg = ast_kcs_bmc_ioregs[channel - 1]; + aspeed_kcs_set_address(kcs, slave); + + return 0; +} + +static int aspeed_kcs_calculate_channel(const struct kcs_ioreg *regs) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(ast_kcs_bmc_ioregs); i++) { + if (!memcmp(_kcs_bmc_ioregs[i], regs, sizeof(*regs))) + return i + 1; + } + + return -EINVAL; +} + +static struct kcs_bmc *aspeed_kcs_probe_of_v2(struct platform_device *pdev) +{ + struct aspeed_kcs_bmc *priv; + struct device_node *np; + struct kcs_ioreg ioreg; + struct kcs_bmc *kcs; + const __be32 *reg; + int channel; + u32 slave; + int rc; + + np = pdev->dev.of_node; + + /* Don't translate addresses, we want offsets for the regmaps */ + reg = of_get_address(np, 0, NULL, NULL); + if (!reg) + return ERR_PTR(-EINVAL); + ioreg.idr = be32_to_cpup(reg); + + reg = of_get_address(np, 1, NULL, NULL); + if (!reg) + return ERR_PTR(-EINVAL); + ioreg.odr = be32_to_cpup(reg); + + reg = of_get_address(np, 2, NULL, NULL); + if (!reg) + return ERR_PTR(-EINVAL); + ioreg.str = be32_to_cpup(reg); + + channel = aspeed_kcs_calculate_channel(); + if (channel < 0) + return ERR_PTR(channel); + + kcs = kcs_bmc_alloc(>dev, sizeof(struct aspeed_kcs_bmc), channel); + if (!kcs) + return ERR_PTR(-ENOMEM); + + kcs->ioreg = ioreg; + + priv = kcs_bmc_priv(kcs); + priv->map = syscon_node_to_regmap(pdev->dev.parent->of_node); + if (IS_ERR(priv->map)) { + dev_err(>dev, "Couldn't get regmap\n"); + return ERR_PTR(-ENODEV); + } + + rc = of_property_read_u32(np, "slave-reg", ); + if (rc) + return ERR_PTR(rc); + + aspeed_kcs_set_address(kcs, slave); + + return kcs; +} + static int aspeed_kcs_probe(struct platform_device *pdev) { struct device *dev = >dev; - struct aspeed_kcs_bmc *priv; struct kcs_bmc *kcs_bmc; - u32 chan, addr; + struct device_node *np; int rc; - rc = of_property_read_u32(dev->of_node, "kcs_chan", ); - if ((rc != 0) || (chan == 0 || chan > KCS_CHANNEL_MAX)) { - dev_err(dev, "no valid 'kcs_chan' configured\n"); - return -ENODEV; - } + np = pdev->dev.of_node; + if (of_device_is_compatible(np, "aspeed,ast2400-kcs-bmc") || + of_device_is_compatible(np, "aspeed,ast2500-kcs-bmc")) + kcs_bmc = aspeed_kcs_probe_of_v1(pdev); + else if (of_device_is_compatible(np, "aspeed,ast2400-kcs-bmc-v2") || + of_device_is_compatible(np,
[PATCH 06/17] ARM: dts: swift: Cleanup gpio-keys-polled properties
dtbs_check gave the following warning: Warning (avoid_unnecessary_addr_size): /gpio-keys-polled: unnecessary #address-cells/#size-cells without "ranges" or child "reg" property Cc: Adriana Kobylak Signed-off-by: Andrew Jeffery --- arch/arm/boot/dts/aspeed-bmc-opp-swift.dts | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/arm/boot/dts/aspeed-bmc-opp-swift.dts b/arch/arm/boot/dts/aspeed-bmc-opp-swift.dts index 2077e8d0e096..9f934509ca1b 100644 --- a/arch/arm/boot/dts/aspeed-bmc-opp-swift.dts +++ b/arch/arm/boot/dts/aspeed-bmc-opp-swift.dts @@ -82,8 +82,6 @@ gpio-keys-polled { compatible = "gpio-keys-polled"; - #address-cells = <1>; - #size-cells = <0>; poll-interval = <1000>; scm0-presence { -- 2.20.1
[RFC PATCH 12/17] ARM: dts: aspeed: Add reg hints to syscon children
Fixes the following warnings: arch/arm/boot/dts/aspeed-g5.dtsi:209.28-226.6: Warning (avoid_unnecessary_addr_size): /ahb/apb/syscon@1e6e2000: unnecessary #address-cells/#size-cells without "ranges" or child "reg" property arch/arm/boot/dts/aspeed-g4.dtsi:156.28-172.6: Warning (avoid_unnecessary_addr_size): /ahb/apb/syscon@1e6e2000: unnecessary #address-cells/#size-cells without "ranges" or child "reg" property Cc: Patrick Venture Signed-off-by: Andrew Jeffery --- arch/arm/boot/dts/aspeed-g4.dtsi | 15 +-- arch/arm/boot/dts/aspeed-g5.dtsi | 17 ++--- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/arch/arm/boot/dts/aspeed-g4.dtsi b/arch/arm/boot/dts/aspeed-g4.dtsi index ed78020f6269..1515b56a1487 100644 --- a/arch/arm/boot/dts/aspeed-g4.dtsi +++ b/arch/arm/boot/dts/aspeed-g4.dtsi @@ -157,18 +157,21 @@ compatible = "aspeed,ast2400-scu", "syscon", "simple-mfd"; reg = <0x1e6e2000 0x1a8>; #address-cells = <1>; - #size-cells = <0>; + #size-cells = <1>; + ranges = <0 0x1e6e2000 0x1000>; #clock-cells = <1>; #reset-cells = <1>; - pinctrl: pinctrl { - compatible = "aspeed,g4-pinctrl"; - }; - - p2a: p2a-control { + p2a: p2a-control@2c { + reg = <0x2c 0x4>; compatible = "aspeed,ast2400-p2a-ctrl"; status = "disabled"; }; + + pinctrl: pinctrl@80 { + reg = <0x80 0x18>, <0xa0 0x10>; + compatible = "aspeed,g4-pinctrl"; + }; }; rng: hwrng@1e6e2078 { diff --git a/arch/arm/boot/dts/aspeed-g5.dtsi b/arch/arm/boot/dts/aspeed-g5.dtsi index a8a593dd2240..92c659c50b4c 100644 --- a/arch/arm/boot/dts/aspeed-g5.dtsi +++ b/arch/arm/boot/dts/aspeed-g5.dtsi @@ -210,19 +210,22 @@ compatible = "aspeed,ast2500-scu", "syscon", "simple-mfd"; reg = <0x1e6e2000 0x1a8>; #address-cells = <1>; - #size-cells = <0>; + #size-cells = <1>; + ranges = <0 0x1e6e2000 0x1000>; #clock-cells = <1>; #reset-cells = <1>; - pinctrl: pinctrl { - compatible = "aspeed,g5-pinctrl"; - aspeed,external-nodes = <>, <>; - }; - - p2a: p2a-control { + p2a: p2a-control@2c { compatible = "aspeed,ast2500-p2a-ctrl"; + reg = <0x2c 0x4>; status = "disabled"; }; + + pinctrl: pinctrl@80 { + compatible = "aspeed,g5-pinctrl"; + reg = <0x80 0x18>, <0xa0 0x10>; + aspeed,external-nodes = <>, <>; + }; }; rng: hwrng@1e6e2078 { -- 2.20.1
[PATCH 09/17] ARM: dts: ibm-power9-dual: Add a unit address for OCC nodes
These temporarily have a unit address until userspace is fixed up as noted in comments elsewhere in the dtsi. Fixes the following warning: arch/arm/boot/dts/ibm-power9-dual.dtsi:89.18-91.6: Warning (unit_address_vs_reg): /gpio-fsi/cfam@0,0/sbefifo@2400/occ: node has a reg or ranges property, but no unit name arch/arm/boot/dts/ibm-power9-dual.dtsi:190.18-192.6: Warning (unit_address_vs_reg): /gpio-fsi/cfam@0,0/hub@3400/cfam@1,0/sbefifo@2400/occ: node has a reg or ranges property, but no unit name Signed-off-by: Andrew Jeffery --- arch/arm/boot/dts/ibm-power9-dual.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/boot/dts/ibm-power9-dual.dtsi b/arch/arm/boot/dts/ibm-power9-dual.dtsi index 2abc42eda7b0..a0fa65b44b0f 100644 --- a/arch/arm/boot/dts/ibm-power9-dual.dtsi +++ b/arch/arm/boot/dts/ibm-power9-dual.dtsi @@ -86,7 +86,7 @@ #address-cells = <1>; #size-cells = <0>; - fsi_occ0: occ { + fsi_occ0: occ@1 { compatible = "ibm,p9-occ"; }; }; @@ -187,7 +187,7 @@ #address-cells = <1>; #size-cells = <0>; - fsi_occ1: occ { + fsi_occ1: occ@2 { compatible = "ibm,p9-occ"; }; }; -- 2.20.1
[PATCH 08/17] ARM: dts: aspeed: Cleanup lpc-ctrl and snoop regs
Fix the following warning: arch/arm/boot/dts/aspeed-g5.dtsi:409.27-414.8: Warning (unique_unit_address): /ahb/apb/lpc@1e789000/lpc-host@80/lpc-ctrl@0: duplicate unit-address (also used in node /ahb/apb/lpc@1e789000/lpc-host@80/lpc-snoop@0) Signed-off-by: Andrew Jeffery --- arch/arm/boot/dts/aspeed-g4.dtsi | 6 +++--- arch/arm/boot/dts/aspeed-g5.dtsi | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/arm/boot/dts/aspeed-g4.dtsi b/arch/arm/boot/dts/aspeed-g4.dtsi index dd4b0b15afcf..ed78020f6269 100644 --- a/arch/arm/boot/dts/aspeed-g4.dtsi +++ b/arch/arm/boot/dts/aspeed-g4.dtsi @@ -296,14 +296,14 @@ lpc_ctrl: lpc-ctrl@0 { compatible = "aspeed,ast2400-lpc-ctrl"; - reg = <0x0 0x80>; + reg = <0x0 0x10>; clocks = < ASPEED_CLK_GATE_LCLK>; status = "disabled"; }; - lpc_snoop: lpc-snoop@0 { + lpc_snoop: lpc-snoop@10 { compatible = "aspeed,ast2400-lpc-snoop"; - reg = <0x0 0x80>; + reg = <0x10 0x8>; interrupts = <8>; status = "disabled"; }; diff --git a/arch/arm/boot/dts/aspeed-g5.dtsi b/arch/arm/boot/dts/aspeed-g5.dtsi index 3b4af88f9b80..a8a593dd2240 100644 --- a/arch/arm/boot/dts/aspeed-g5.dtsi +++ b/arch/arm/boot/dts/aspeed-g5.dtsi @@ -408,14 +408,14 @@ lpc_ctrl: lpc-ctrl@0 { compatible = "aspeed,ast2500-lpc-ctrl"; - reg = <0x0 0x80>; + reg = <0x0 0x10>; clocks = < ASPEED_CLK_GATE_LCLK>; status = "disabled"; }; - lpc_snoop: lpc-snoop@0 { + lpc_snoop: lpc-snoop@10 { compatible = "aspeed,ast2500-lpc-snoop"; - reg = <0x0 0x80>; + reg = <0x10 0x8>; interrupts = <8>; status = "disabled"; }; -- 2.20.1
[PATCH 04/17] ARM: dts: vesnin: Add unit address for memory node
Fixes the following warnings: arch/arm/boot/dts/aspeed-bmc-opp-vesnin.dt.yaml: /: memory: False schema does not allow {'reg': [[1073741824, 536870912]]} arch/arm/boot/dts/aspeed-bmc-opp-vesnin.dt.yaml: memory: 'device_type' is a required property Cc: Alexander Filippov Signed-off-by: Andrew Jeffery --- arch/arm/boot/dts/aspeed-bmc-opp-vesnin.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/boot/dts/aspeed-bmc-opp-vesnin.dts b/arch/arm/boot/dts/aspeed-bmc-opp-vesnin.dts index 0b9e29c3212e..81d9dcb752a0 100644 --- a/arch/arm/boot/dts/aspeed-bmc-opp-vesnin.dts +++ b/arch/arm/boot/dts/aspeed-bmc-opp-vesnin.dts @@ -14,7 +14,7 @@ bootargs = "console=ttyS4,115200 earlyprintk"; }; - memory { + memory@4000 { reg = <0x4000 0x2000>; }; -- 2.20.1
[RFC PATCH 11/17] dt-bindings: misc: Document reg for aspeed,p2a-ctrl nodes
The P2A controller node sits under a syscon device, and can assume offsets from the base of the syscon based on the compatible. However, for devicetree correctness allow a reg property to be specified, which an associated driver may choose to use to discover associated resources. Cc: Patrick Venture Cc: Greg Kroah-Hartman Signed-off-by: Andrew Jeffery --- Documentation/devicetree/bindings/misc/aspeed-p2a-ctrl.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/misc/aspeed-p2a-ctrl.txt b/Documentation/devicetree/bindings/misc/aspeed-p2a-ctrl.txt index 854bd67ffec6..091d1c5ec58f 100644 --- a/Documentation/devicetree/bindings/misc/aspeed-p2a-ctrl.txt +++ b/Documentation/devicetree/bindings/misc/aspeed-p2a-ctrl.txt @@ -18,6 +18,7 @@ Required properties: Optional properties: === +- reg: A hint for the memory regions associated with the P2A controller - memory-region: A phandle to a reserved_memory region to be used for the PCI to AHB mapping -- 2.20.1
[RFC PATCH 10/17] dt-bindings: pinctrl: aspeed: Add reg property as a hint
The pinctrl node sits under a syscon device, and can assume offsets from the base of the syscon based on the compatible. However, for devicetree correctness allow a reg property to be specified, which an associated driver may choose to use to discover associated resources. Cc: Linus Walleij Cc: linux-g...@vger.kernel.org Signed-off-by: Andrew Jeffery --- .../devicetree/bindings/pinctrl/aspeed,ast2400-pinctrl.yaml| 3 +++ .../devicetree/bindings/pinctrl/aspeed,ast2500-pinctrl.yaml| 3 +++ 2 files changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/pinctrl/aspeed,ast2400-pinctrl.yaml b/Documentation/devicetree/bindings/pinctrl/aspeed,ast2400-pinctrl.yaml index 125599a2dc5e..629a55c167ae 100644 --- a/Documentation/devicetree/bindings/pinctrl/aspeed,ast2400-pinctrl.yaml +++ b/Documentation/devicetree/bindings/pinctrl/aspeed,ast2400-pinctrl.yaml @@ -25,6 +25,9 @@ properties: enum: - aspeed,ast2400-pinctrl - aspeed,g4-pinctrl + reg: +description: | + A hint for the memory regions associated with the pin-controller patternProperties: '^.*$': diff --git a/Documentation/devicetree/bindings/pinctrl/aspeed,ast2500-pinctrl.yaml b/Documentation/devicetree/bindings/pinctrl/aspeed,ast2500-pinctrl.yaml index 3e6d85318577..2e8971e23a02 100644 --- a/Documentation/devicetree/bindings/pinctrl/aspeed,ast2500-pinctrl.yaml +++ b/Documentation/devicetree/bindings/pinctrl/aspeed,ast2500-pinctrl.yaml @@ -25,6 +25,9 @@ properties: enum: - aspeed,ast2500-pinctrl - aspeed,g5-pinctrl + reg: +description: | + A hint for the memory regions associated with the pin-controller aspeed,external-nodes: minItems: 2 maxItems: 2 -- 2.20.1
[PATCH 01/17] ARM: dts: aspeed-g5: Move EDAC node to APB
Previously the register interface was not attached to any internal bus, which is not correct - it lives on the APB. Cc: Stefan M Schaeckeler Signed-off-by: Andrew Jeffery --- arch/arm/boot/dts/aspeed-g5.dtsi | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/arm/boot/dts/aspeed-g5.dtsi b/arch/arm/boot/dts/aspeed-g5.dtsi index 5b1ca265c2ce..7723afc7c249 100644 --- a/arch/arm/boot/dts/aspeed-g5.dtsi +++ b/arch/arm/boot/dts/aspeed-g5.dtsi @@ -47,13 +47,6 @@ reg = <0x8000 0>; }; - edac: sdram@1e6e { - compatible = "aspeed,ast2500-sdram-edac"; - reg = <0x1e6e 0x174>; - interrupts = <0>; - status = "disabled"; - }; - ahb { compatible = "simple-bus"; #address-cells = <1>; @@ -206,6 +199,13 @@ #size-cells = <1>; ranges; + edac: sdram@1e6e { + compatible = "aspeed,ast2500-sdram-edac"; + reg = <0x1e6e 0x174>; + interrupts = <0>; + status = "disabled"; + }; + syscon: syscon@1e6e2000 { compatible = "aspeed,ast2500-scu", "syscon", "simple-mfd"; reg = <0x1e6e2000 0x1a8>; -- 2.20.1
[PATCH 02/17] ARM: dts: aspeed-g5: Use recommended generic node name for SDMC
The EDAC is a sub-function of the SDRAM Memory Controller. Rename the node to the appropriate generic node name. Cc: Stefan M Schaeckeler Signed-off-by: Andrew Jeffery --- arch/arm/boot/dts/aspeed-g5.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/boot/dts/aspeed-g5.dtsi b/arch/arm/boot/dts/aspeed-g5.dtsi index 7723afc7c249..6e5b0c493f16 100644 --- a/arch/arm/boot/dts/aspeed-g5.dtsi +++ b/arch/arm/boot/dts/aspeed-g5.dtsi @@ -199,7 +199,7 @@ #size-cells = <1>; ranges; - edac: sdram@1e6e { + edac: memory-controller@1e6e { compatible = "aspeed,ast2500-sdram-edac"; reg = <0x1e6e 0x174>; interrupts = <0>; -- 2.20.1
[PATCH 03/17] ARM: dts: aspeed-g5: Fix aspeed,external-nodes description
The existing approach lead to an error from the dtbs_check: pinctrl: aspeed,external-nodes: [[8, 9]] is too short Cc: Adriana Kobylak Cc: Brian Yang Cc: Joel Stanley Cc: John Wang Cc: Ken Chen Cc: Tao Ren Cc: Xo Wang Cc: Yuan Yao Signed-off-by: Andrew Jeffery --- arch/arm/boot/dts/aspeed-bmc-arm-centriq2400-rep.dts | 4 arch/arm/boot/dts/aspeed-bmc-arm-stardragon4800-rep2.dts | 4 arch/arm/boot/dts/aspeed-bmc-facebook-cmm.dts| 4 arch/arm/boot/dts/aspeed-bmc-facebook-yamp.dts | 4 arch/arm/boot/dts/aspeed-bmc-inspur-fp5280g2.dts | 4 arch/arm/boot/dts/aspeed-bmc-intel-s2600wf.dts | 4 arch/arm/boot/dts/aspeed-bmc-opp-lanyang.dts | 4 arch/arm/boot/dts/aspeed-bmc-opp-romulus.dts | 4 arch/arm/boot/dts/aspeed-bmc-opp-swift.dts | 4 arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts | 4 arch/arm/boot/dts/aspeed-bmc-opp-zaius.dts | 2 -- arch/arm/boot/dts/aspeed-g5.dtsi | 3 +-- 12 files changed, 1 insertion(+), 44 deletions(-) diff --git a/arch/arm/boot/dts/aspeed-bmc-arm-centriq2400-rep.dts b/arch/arm/boot/dts/aspeed-bmc-arm-centriq2400-rep.dts index c2ece0b91885..de9612e49c69 100644 --- a/arch/arm/boot/dts/aspeed-bmc-arm-centriq2400-rep.dts +++ b/arch/arm/boot/dts/aspeed-bmc-arm-centriq2400-rep.dts @@ -211,10 +211,6 @@ status = "okay"; }; - { - aspeed,external-nodes = < >; -}; - { pin_gpio_c7 { gpio-hog; diff --git a/arch/arm/boot/dts/aspeed-bmc-arm-stardragon4800-rep2.dts b/arch/arm/boot/dts/aspeed-bmc-arm-stardragon4800-rep2.dts index 521afbea2c5b..d122a8efcc66 100644 --- a/arch/arm/boot/dts/aspeed-bmc-arm-stardragon4800-rep2.dts +++ b/arch/arm/boot/dts/aspeed-bmc-arm-stardragon4800-rep2.dts @@ -197,10 +197,6 @@ status = "okay"; }; - { - aspeed,external-nodes = < >; -}; - { pin_gpio_c7 { gpio-hog; diff --git a/arch/arm/boot/dts/aspeed-bmc-facebook-cmm.dts b/arch/arm/boot/dts/aspeed-bmc-facebook-cmm.dts index d519d307aa2a..dd2be50112a4 100644 --- a/arch/arm/boot/dts/aspeed-bmc-facebook-cmm.dts +++ b/arch/arm/boot/dts/aspeed-bmc-facebook-cmm.dts @@ -64,10 +64,6 @@ }; }; - { - aspeed,external-nodes = < >; -}; - /* * Update reset type to "system" (full chip) to fix warm reboot hang issue * when reset type is set to default ("soc", gated by reset mask registers). diff --git a/arch/arm/boot/dts/aspeed-bmc-facebook-yamp.dts b/arch/arm/boot/dts/aspeed-bmc-facebook-yamp.dts index 4e09a9cf32b7..d4d2d0b48f83 100644 --- a/arch/arm/boot/dts/aspeed-bmc-facebook-yamp.dts +++ b/arch/arm/boot/dts/aspeed-bmc-facebook-yamp.dts @@ -29,10 +29,6 @@ }; }; - { - aspeed,external-nodes = < >; -}; - /* * Update reset type to "system" (full chip) to fix warm reboot hang issue * when reset type is set to default ("soc", gated by reset mask registers). diff --git a/arch/arm/boot/dts/aspeed-bmc-inspur-fp5280g2.dts b/arch/arm/boot/dts/aspeed-bmc-inspur-fp5280g2.dts index 628195b66d46..2dd664bff928 100644 --- a/arch/arm/boot/dts/aspeed-bmc-inspur-fp5280g2.dts +++ b/arch/arm/boot/dts/aspeed-bmc-inspur-fp5280g2.dts @@ -745,10 +745,6 @@ memory-region = <_memory>; }; - { - aspeed,external-nodes = < >; -}; - { pin_gpio_b7 { gpio-hog; diff --git a/arch/arm/boot/dts/aspeed-bmc-intel-s2600wf.dts b/arch/arm/boot/dts/aspeed-bmc-intel-s2600wf.dts index 22dade6393d0..4e9c03d5e5a3 100644 --- a/arch/arm/boot/dts/aspeed-bmc-intel-s2600wf.dts +++ b/arch/arm/boot/dts/aspeed-bmc-intel-s2600wf.dts @@ -115,10 +115,6 @@ status = "okay"; }; - { - aspeed,external-nodes = < >; -}; - _tacho { status = "okay"; pinctrl-names = "default"; diff --git a/arch/arm/boot/dts/aspeed-bmc-opp-lanyang.dts b/arch/arm/boot/dts/aspeed-bmc-opp-lanyang.dts index de95112e2a04..fe7965366f4a 100644 --- a/arch/arm/boot/dts/aspeed-bmc-opp-lanyang.dts +++ b/arch/arm/boot/dts/aspeed-bmc-opp-lanyang.dts @@ -260,10 +260,6 @@ status = "okay"; }; - { - aspeed,external-nodes = < >; -}; - { pin_gpio_b0 { gpio-hog; diff --git a/arch/arm/boot/dts/aspeed-bmc-opp-romulus.dts b/arch/arm/boot/dts/aspeed-bmc-opp-romulus.dts index 9628ecb879cf..2fa4f361ac6a 100644 --- a/arch/arm/boot/dts/aspeed-bmc-opp-romulus.dts +++ b/arch/arm/boot/dts/aspeed-bmc-opp-romulus.dts @@ -255,10 +255,6 @@ memory-region = <_memory>; }; - { - aspeed,external-nodes = < >; -}; - _tacho { status = "okay"; pinctrl-names = "default"; diff --git a/arch/arm/boot/dts/aspeed-bmc-opp-swift.dts b/arch/arm/boot/dts/aspeed-bmc-opp-swift.dts index caac895c60b4..2077e8d0e096 100644 --- a/arch/arm/boot/dts/aspeed-bmc-opp-swift.dts +++ b/arch/arm/boot/dts/aspeed-bmc-opp-swift.dts @@ -937,10 +937,6 @@ memory-region = <_memory>; }; - { -
[PATCH 05/17] ARM: dts: fp5280g2: Cleanup gpio-keys-polled properties
dtbs_check gave the following warning: Warning (avoid_unnecessary_addr_size): /gpio-keys-polled: unnecessary #address-cells/#size-cells without "ranges" or child "reg" property Cc: John Wang Signed-off-by: Andrew Jeffery --- arch/arm/boot/dts/aspeed-bmc-inspur-fp5280g2.dts | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/arm/boot/dts/aspeed-bmc-inspur-fp5280g2.dts b/arch/arm/boot/dts/aspeed-bmc-inspur-fp5280g2.dts index 2dd664bff928..aa5efd1dfa70 100644 --- a/arch/arm/boot/dts/aspeed-bmc-inspur-fp5280g2.dts +++ b/arch/arm/boot/dts/aspeed-bmc-inspur-fp5280g2.dts @@ -94,8 +94,6 @@ gpio-keys-polled { compatible = "gpio-keys-polled"; - #address-cells = <1>; - #size-cells = <0>; poll-interval = <1000>; fan0-presence { -- 2.20.1
Re: [PATCH] staging:iio:adc:ad7280a: add of_match_table entry
On Fri, 2019-07-26 at 01:38 +0530, Kartik Kulkarni wrote: > Add the of_device_id struct and the respective > of_match_device entry to complete device tree support. > This would be a [V2] I suppose. This change also does the rename of the driver name in a single go. Since it's a trivial change, it's fine from my side. Reviewed-by: Alexandru Ardelean > Signed-off-by: Kartik Kulkarni > Reviewed-by: Matheus Tavares > --- > drivers/staging/iio/adc/ad7280a.c | 9 - > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/drivers/staging/iio/adc/ad7280a.c > b/drivers/staging/iio/adc/ad7280a.c > index 19a5f244dcae..ded0ba093a28 100644 > --- a/drivers/staging/iio/adc/ad7280a.c > +++ b/drivers/staging/iio/adc/ad7280a.c > @@ -1027,9 +1027,16 @@ static const struct spi_device_id ad7280_id[] = { > }; > MODULE_DEVICE_TABLE(spi, ad7280_id); > > +static const struct of_device_id ad7280_of_match[] = { > + { .compatible = "adi,ad7280a", }, > + { } > +}; > +MODULE_DEVICE_TABLE(of, ad7280_of_match); > + > static struct spi_driver ad7280_driver = { > .driver = { > - .name = "ad7280", > + .name = "ad7280a", > + .of_match_table = ad7280_of_match, > }, > .probe = ad7280_probe, > .id_table = ad7280_id,
linux-next: Tree for Jul 26
Hi all, Changes since 20190725: New tree: edac Removed tree: edac-amd The vfs-fixes tree's BUG is gone (it was in interaction with the vfs tree). The leds tree lost its build failure. The akpm-current tree gained a build failure so I reverted 5 commits. Non-merge commits (relative to Linus' tree): 2477 2799 files changed, 172606 insertions(+), 60972 deletions(-) I have created today's linux-next tree at git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git (patches at http://www.kernel.org/pub/linux/kernel/next/ ). If you are tracking the linux-next tree using git, you should not use "git pull" to do so as that will try to merge the new linux-next release with the old one. You should use "git fetch" and checkout or reset to the new master. You can see which trees have been included by looking in the Next/Trees file in the source. There are also quilt-import.log and merge.log files in the Next directory. Between each merge, the tree was built with a ppc64_defconfig for powerpc, an allmodconfig for x86_64, a multi_v7_defconfig for arm and a native build of tools/perf. After the final fixups (if any), I do an x86_64 modules_install followed by builds for x86_64 allnoconfig, powerpc allnoconfig (32 and 64 bit), ppc44x_defconfig, allyesconfig and pseries_le_defconfig and i386, sparc and sparc64 defconfig. And finally, a simple boot test of the powerpc pseries_le_defconfig kernel in qemu (with and without kvm enabled). Below is a summary of the state of the merge. I am currently merging 300 trees (counting Linus' and 72 trees of bug fix patches pending for the current merge release). Stats about the size of the tree over time can be seen at http://neuling.org/linux-next-size.html . Status of my local build tests will be at http://kisskb.ellerman.id.au/linux-next . If maintainers want to give advice about cross compilers/configs that work, we are always open to add more builds. Thanks to Randy Dunlap for doing many randconfig builds. And to Paul Gortmaker for triage and bug fixes. -- Cheers, Stephen Rothwell $ git checkout master $ git reset --hard stable Merging origin/master (6789f873ed37 Merge tag 'pm-5.3-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm) Merging fixes/master (c309b6f24222 Merge tag 'docs/v5.3-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media) Merging kbuild-current/fixes (5f9e832c1370 Linus 5.3-rc1) Merging arc-current/for-curr (24a20b0a443f ARC: [plat-hsdk]: Enable AXI DW DMAC in defconfig) Merging arm-current/fixes (c5d0e49e8d8f ARM: 8867/1: vdso: pass --be8 to linker if necessary) Merging arm-soc-fixes/arm/fixes (7bd9d465140a Merge tag 'imx-fixes-5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/shawnguo/linux into arm/fixes) Merging arm64-fixes/for-next/fixes (5a46d3f71d5e ACPI/IORT: Fix off-by-one check in iort_dev_find_its_id()) Merging m68k-current/for-linus (f28a1f16135c m68k: Don't select ARCH_HAS_DMA_PREP_COHERENT for nommu or coldfire) Merging powerpc-fixes/fixes (3a855b7ac7d5 powerpc/papr_scm: Force a scm-unbind if initial scm-bind fails) Merging s390-fixes/fixes (9779048d71b1 s390/kasan: add bitops instrumentation) Merging sparc/master (038029c03e21 sparc: remove unneeded uapi/asm/statfs.h) Merging fscrypt-current/for-stable (ae64f9bd1d36 Linux 4.15-rc2) Merging net/master (83fbae60fd38 fsl/fman: Remove comment referring to non-existent function) Merging bpf/master (cb8ffde5694a libbpf: silence GCC8 warning about string truncation) Merging ipsec/master (22d6552f827e xfrm interface: fix management of phydev) Merging netfilter/master (67d86835840a netfilter: nft_meta_bridge: Eliminate 'out' label) Merging ipvs/master (58e8b37069ff Merge branch 'net-phy-dp83867-add-some-fixes') Merging wireless-drivers/master (5f9e832c1370 Linus 5.3-rc1) Merging mac80211/master (d2b3fe42bc62 mac80211: don't warn about CW params when not using them) Merging rdma-fixes/for-rc (5f9e832c1370 Linus 5.3-rc1) Merging sound-current/for-linus (3f8809499bf0 ALSA: hda - Add a conexant codec entry to let mute led work) Merging sound-asoc-fixes/for-linus (b57709004455 Merge branch 'asoc-5.3' into asoc-linus) Merging regmap-fixes/for-linus (5f9e832c1370 Linus 5.3-rc1) Merging regulator-fixes/for-linus (a853c0a0b013 regulator: lp87565: Fix probe failure for "ti,lp87565") Merging spi-fixes/for-linus (cc3af187d8b8 Merge branch 'spi-5.3' into spi-linus) Merging pci-current/for-linus (5f9e832c1370 Linus 5.3-rc1) Merging driver-core.current/driver-core-linus (5f9e832c1370 Linus 5.3-rc1) Merging tty.current/tty-linus (61d51456f357 vt: Grab console_lock around con_is_bound in show_bind) Merging usb.current/usb-linus (d39b5bad8658 xhci: Fix crash if scatter gather is used with Immediate Data Transfer (IDT).) Merging usb-gadget-fixes/fixes (42de8afc40c9 usb: dwc2: Use generic PHY width in params setup) Merg
Re: [alsa-devel] [RFC PATCH 26/40] soundwire: cadence_master: fix divider setting in clock register
On 7/26/2019 7:40 AM, Pierre-Louis Bossart wrote: From: Rander Wang The existing code uses an OR operation which would mix the original divider setting with the new one, resulting in an invalid configuration that can make codecs hang. Add the mask definition and use cdns_updatel to update divider Signed-off-by: Rander Wang Signed-off-by: Pierre-Louis Bossart --- drivers/soundwire/cadence_master.c | 12 +++- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/soundwire/cadence_master.c b/drivers/soundwire/cadence_master.c index 10ebcef2e84e..18c6ac026e85 100644 --- a/drivers/soundwire/cadence_master.c +++ b/drivers/soundwire/cadence_master.c @@ -57,6 +57,7 @@ #define CDNS_MCP_SSP_CTRL10x28 #define CDNS_MCP_CLK_CTRL00x30 #define CDNS_MCP_CLK_CTRL10x38 +#define CDNS_MCP_CLK_MCLKD_MASKGENMASK(7, 0) #define CDNS_MCP_STAT0x40 @@ -988,9 +989,11 @@ int sdw_cdns_init(struct sdw_cdns *cdns) /* Set clock divider */ divider = (prop->mclk_freq / prop->max_clk_freq) - 1; val = cdns_readl(cdns, CDNS_MCP_CLK_CTRL0); Do we still need to read cdns_readl(cdns, CDNS_MCP_CLK_CTRL0) after this change? - val |= divider; - cdns_writel(cdns, CDNS_MCP_CLK_CTRL0, val); - cdns_writel(cdns, CDNS_MCP_CLK_CTRL1, val); + + cdns_updatel(cdns, CDNS_MCP_CLK_CTRL0, +CDNS_MCP_CLK_MCLKD_MASK, divider); + cdns_updatel(cdns, CDNS_MCP_CLK_CTRL1, +CDNS_MCP_CLK_MCLKD_MASK, divider); pr_err("plb: mclk %d max_freq %d divider %d register %x\n", prop->mclk_freq, @@ -1064,8 +1067,7 @@ int cdns_bus_conf(struct sdw_bus *bus, struct sdw_bus_params *params) mcp_clkctrl_off = CDNS_MCP_CLK_CTRL0; mcp_clkctrl = cdns_readl(cdns, mcp_clkctrl_off); Same here. - mcp_clkctrl |= divider; - cdns_writel(cdns, mcp_clkctrl_off, mcp_clkctrl); + cdns_updatel(cdns, mcp_clkctrl_off, CDNS_MCP_CLK_MCLKD_MASK, divider); pr_err("plb: mclk * 2 %d curr_dr_freq %d divider %d register %x\n", prop->mclk_freq * SDW_DOUBLE_RATE_FACTOR,
Re: [PATCH v7 21/25] mips: Add clock_gettime64 entry point
Hello, Vincenzo Frascino wrote: > With the release of Linux 5.1 has been added a new syscall, > clock_gettime64, that provided a 64 bit time value for a specified > clock_ID to make the kernel Y2038 safe on 32 bit architectures. > > Update the mips32 specific vDSO library accordingly with what it has > been done for the kernel syscall exposing the clock_gettime64 entry > point. > > Cc: Ralf Baechle > Cc: Paul Burton > Signed-off-by: Vincenzo Frascino Applied to mips-next. Thanks, Paul [ This message was auto-generated; if you believe anything is incorrect then please email paul.bur...@mips.com to report it. ]
Re: [PATCH v7 20/25] mips: Add clock_getres entry point
Hello, Vincenzo Frascino wrote: > The generic vDSO library provides an implementation of clock_getres() > that can be leveraged by each architecture. > > Add clock_getres() entry point on mips. > > Cc: Ralf Baechle > Cc: Paul Burton > Signed-off-by: Vincenzo Frascino Applied to mips-next. Thanks, Paul [ This message was auto-generated; if you believe anything is incorrect then please email paul.bur...@mips.com to report it. ]
Re: [PATCH v7 19/25] mips: Add support for generic vDSO
Hello, Vincenzo Frascino wrote: > The mips vDSO library requires some adaptations to take advantage of the > newly introduced generic vDSO library. > > Introduce the following changes: > - Modification of vdso.c to be compliant with the common vdso datapage > - Use of lib/vdso for gettimeofday > > Cc: Ralf Baechle > Cc: Paul Burton > Signed-off-by: Vincenzo Frascino Applied to mips-next. Thanks, Paul [ This message was auto-generated; if you believe anything is incorrect then please email paul.bur...@mips.com to report it. ]
Re: [RFC] mm/pgtable/debug: Add test validating architecture page table helpers
On 07/26/2019 03:24 AM, Russell King - ARM Linux admin wrote: > On Thu, Jul 25, 2019 at 12:25:23PM +0530, Anshuman Khandual wrote: >> This adds a test module which will validate architecture page table helpers >> and accessors regarding compliance with generic MM semantics expectations. >> This will help various architectures in validating changes to the existing >> page table helpers or addition of new ones. >> >> Cc: Andrew Morton >> Cc: Michal Hocko >> Cc: Mark Rutland >> Cc: Mark Brown >> Cc: Steven Price >> Cc: Ard Biesheuvel >> Cc: Masahiro Yamada >> Cc: Kees Cook >> Cc: Tetsuo Handa >> Cc: Matthew Wilcox >> Cc: Sri Krishna chowdary >> Cc: Dave Hansen >> Cc: linux-arm-ker...@lists.infradead.org >> Cc: x...@kernel.org >> Cc: linux-kernel@vger.kernel.org >> >> Suggested-by: Catalin Marinas >> Signed-off-by: Anshuman Khandual >> --- >> lib/Kconfig.debug | 14 +++ >> lib/Makefile| 1 + >> lib/test_arch_pgtable.c | 290 >> >> 3 files changed, 305 insertions(+) >> create mode 100644 lib/test_arch_pgtable.c >> >> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug >> index 5960e29..a27fe8d 100644 >> --- a/lib/Kconfig.debug >> +++ b/lib/Kconfig.debug >> @@ -1719,6 +1719,20 @@ config TEST_SORT >> >>If unsure, say N. >> >> +config TEST_ARCH_PGTABLE >> +tristate "Test arch page table helpers for semantics compliance" >> +depends on MMUpte/pmd/pud/p4d/pgd >> +depends on DEBUG_KERNEL || m >> +help >> + This options provides a kernel module which can be used to test >> + architecture page table helper functions on various platform in >> + verifing if they comply with expected generic MM semantics. This >> + will help architectures code in making sure that any changes or >> + new additions of these helpers will still conform to generic MM >> + expeted semantics. >> + >> + If unsure, say N. >> + >> config KPROBES_SANITY_TEST >> bool "Kprobes sanity tests" >> depends on DEBUG_KERNEL >> diff --git a/lib/Makefile b/lib/Makefile >> index 095601c..0806d61 100644 >> --- a/lib/Makefile >> +++ b/lib/Makefile >> @@ -76,6 +76,7 @@ obj-$(CONFIG_TEST_VMALLOC) += test_vmalloc.o >> obj-$(CONFIG_TEST_OVERFLOW) += test_overflow.o >> obj-$(CONFIG_TEST_RHASHTABLE) += test_rhashtable.o >> obj-$(CONFIG_TEST_SORT) += test_sort.o >> +obj-$(CONFIG_TEST_ARCH_PGTABLE) += test_arch_pgtable.o >> obj-$(CONFIG_TEST_USER_COPY) += test_user_copy.o >> obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_keys.o >> obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_key_base.o >> diff --git a/lib/test_arch_pgtable.c b/lib/test_arch_pgtable.c >> new file mode 100644 >> index 000..1396664 >> --- /dev/null >> +++ b/lib/test_arch_pgtable.c >> @@ -0,0 +1,290 @@ >> +// SPDX-License-Identifier: GPL-2.0-only >> +/* >> + * This kernel module validates architecture page table helpers & >> + * accessors and helps in verifying their continued compliance with >> + * generic MM semantics. >> + * >> + * Copyright (C) 2019 ARM Ltd. >> + * >> + * Author: Anshuman Khandual >> + */ >> +#define pr_fmt(fmt) "test_arch_pgtable: %s " fmt, __func__ >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +/* >> + * Basic operations >> + * >> + * mkold(entry) = An old and not an young entry >> + * mkyoung(entry) = An young and not an old entry >> + * mkdirty(entry) = A dirty and not a clean entry >> + * mkclean(entry) = A clean and not a dirty entry >> + * mkwrite(entry) = An write and not an write protected entry >> + * wrprotect(entry) = An write protected and not an write entry >> + * pxx_bad(entry) = A mapped and non-table entry >> + * pxx_same(entry1, entry2) = Both entries hold the exact same value >> + */ >> +#define VMA_TEST_FLAGS (VM_READ|VM_WRITE|VM_EXEC) >> + >> +static struct vm_area_struct vma; >> +static struct mm_struct mm; >> +static struct page *page; >> +static pgprot_t prot; >> +static unsigned long pfn, addr; >> + >> +static void pte_basic_tests(void) >> +{ >> +pte_t pte; >> + >> +pte = mk_pte(page, prot); >> +WARN_ON(!pte_same(pte, pte)); >> +WARN_ON(!pte_young(pte_mkyoung(pte))); >> +WARN_ON(!pte_dirty(pte_mkdirty(pte))); >> +WARN_ON(!pte_write(pte_mkwrite(pte))); >> +WARN_ON(pte_young(pte_mkold(pte))); >> +WARN_ON(pte_dirty(pte_mkclean(pte))); >> +WARN_ON(pte_write(pte_wrprotect(pte))); >> +} >> + >> +#ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE >> +static void pmd_basic_tests(void) >> +{ >> +pmd_t pmd; >> + >> +pmd = mk_pmd(page, prot); > > mk_pmd() is provided on 32-bit ARM LPAE, which also sets > HAVE_ARCH_TRANSPARENT_HUGEPAGE, so this should be fine. Okay. > >> +WARN_ON(!pmd_same(pmd, pmd)); >> +
Re: linux-next: build warning after merge of the tip tree
On Fri, Jul 26, 2019 at 01:05:49PM +1000, Stephen Rothwell wrote: > Hi all, > > After merging the tip tree, today's linux-next build (x86_64 allmodconfig) > produced this warning: > > drivers/gpu/drm/i915/gem/i915_gem_execbuffer.o: warning: objtool: > .altinstr_replacement+0x1c: redundant UACCESS disable > > Presuambly introduced/uncovered by commit > > 882a0db9d143 ("objtool: Improve UACCESS coverage") This will be fixed by: https://lkml.kernel.org/r/51a4155c5bc2ca847a9cbe85c1c11918bb193141.1564086017.git.jpoim...@redhat.com -- Josh
Re: [RFC] mm/pgtable/debug: Add test validating architecture page table helpers
On 07/25/2019 08:09 PM, Matthew Wilcox wrote: > On Thu, Jul 25, 2019 at 12:25:23PM +0530, Anshuman Khandual wrote: >> This adds a test module which will validate architecture page table helpers >> and accessors regarding compliance with generic MM semantics expectations. >> This will help various architectures in validating changes to the existing >> page table helpers or addition of new ones. > > I think this is a really good idea. > >> lib/Kconfig.debug | 14 +++ >> lib/Makefile| 1 + >> lib/test_arch_pgtable.c | 290 >> > > Is this the right place for it? I worry that lib/ is going to get overloaded > with test code, and this feels more like mm/ test code. Sure this can be moved to mm/ but unlike existing test configs there (following) lets keep some config description in mm/Kconfig. Will probably rename this as CONFIG_DEBUG_ARCH_PGTABLE_TEST to match other tests. CONFIG_DEBUG_KMEMLEAK_TEST CONFIG_DEBUG_RODATA_TEST CONFIG_MEMTEST After moving to mm/ directory I guess it does not need a loadable module option. > >> +#ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE >> +static void pmd_basic_tests(void) >> +{ >> +pmd_t pmd; >> + >> +pmd = mk_pmd(page, prot); > > But 'page' isn't necessarily PMD-aligned. I don't think we can rely on > architectures doing the right thing if asked to make a PMD for a randomly > aligned page. > > How about finding the physical address of something like kernel_init(), Physical address corresponding to the symbol in the kernel text segment ? > and using the corresponding pte/pmd/pud/p4d/pgd that encompasses that So I guess this will help us use pte/pmd/pud/p4d/pgd entries from a real and present mapping rather then making them up for test purpose. Although we are not creating real page tables here just wondering if this could some how affect these real mapping in anyway from some accessors. The current proposal stays clear from anything real - allocates, evaluates and releases. Also table entries at pmd/pud/p4d/pgd cannot be operated with accessors in the test. THP and PUD THP will operate on leaf entries at pmd or pud levels. We need them as leaf entries created from allocated (aligned) pfns. While determining pte/pmd/pud/p4d/pgd for kernel_init() some of them will be table entries. > address? It's also better to pass in the pfn/page rather than using global > variables to communicate to the test functions. Sure those can be allocated and passed from the main function. Just wanted to avoid page allocation in each individual tests. > >> +/* >> + * A huge page does not point to next level page table >> + * entry. Hence this must qualify as pmd_bad(). >> + */ >> +WARN_ON(!pmd_bad(pmd_mkhuge(pmd))); > > I didn't know that rule. This is helpful because it gives us somewhere > to document all these tricksy little rules. That is another objective this test has which will help settle semantics in a clear and documented manner. > >> +#ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD >> +static void pud_basic_tests(void) > > Is this the right ifdef? IIUC THP at PUD is where the pud_t entries are directly operated upon and the corresponding accessors are present only when HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD is enabled. Am I missing something here ?
Re: [PATCH V6 01/21] irqchip: tegra: Do not disable COP IRQ during suspend
В Wed, 24 Jul 2019 16:09:53 -0700 Sowjanya Komatineni пишет: > On 7/22/19 4:35 PM, Dmitry Osipenko wrote: > > 22.07.2019 21:38, Marc Zyngier пишет: > >> On Mon, 22 Jul 2019 09:21:21 -0700 > >> Sowjanya Komatineni wrote: > >> > >>> On 7/22/19 3:57 AM, Dmitry Osipenko wrote: > 22.07.2019 13:13, Marc Zyngier пишет: > > On 22/07/2019 10:54, Dmitry Osipenko wrote: > >> 21.07.2019 22:40, Sowjanya Komatineni пишет: > >>> Tegra210 platforms use sc7 entry firmware to program Tegra > >>> LP0/SC7 entry sequence and sc7 entry firmware is run from > >>> COP/BPMP-Lite. > >>> > >>> So, COP/BPMP-Lite still need IRQ function to finish SC7 > >>> suspend sequence for Tegra210. > >>> > >>> This patch has fix for leaving the COP IRQ enabled for > >>> Tegra210 during interrupt controller suspend operation. > >>> > >>> Acked-by: Thierry Reding > >>> Signed-off-by: Sowjanya Komatineni > >>> --- > >>>drivers/irqchip/irq-tegra.c | 20 ++-- > >>>1 file changed, 18 insertions(+), 2 deletions(-) > >>> > >>> diff --git a/drivers/irqchip/irq-tegra.c > >>> b/drivers/irqchip/irq-tegra.c index > >>> e1f771c72fc4..851f88cef508 100644 --- > >>> a/drivers/irqchip/irq-tegra.c +++ > >>> b/drivers/irqchip/irq-tegra.c @@ -44,6 +44,7 @@ static > >>> unsigned int num_ictlrs; > >>>struct tegra_ictlr_soc { > >>> unsigned int num_ictlrs; > >>> + bool supports_sc7; > >>>}; > >>> > >>>static const struct tegra_ictlr_soc tegra20_ictlr_soc = { > >>> @@ -56,6 +57,7 @@ static const struct tegra_ictlr_soc > >>> tegra30_ictlr_soc = { > >>>static const struct tegra_ictlr_soc tegra210_ictlr_soc = { > >>> .num_ictlrs = 6, > >>> + .supports_sc7 = true, > >>>}; > >>> > >>>static const struct of_device_id ictlr_matches[] = { > >>> @@ -67,6 +69,7 @@ static const struct of_device_id > >>> ictlr_matches[] = { > >>>struct tegra_ictlr_info { > >>> void __iomem *base[TEGRA_MAX_NUM_ICTLRS]; > >>> + const struct tegra_ictlr_soc *soc; > >>>#ifdef CONFIG_PM_SLEEP > >>> u32 cop_ier[TEGRA_MAX_NUM_ICTLRS]; > >>> u32 cop_iep[TEGRA_MAX_NUM_ICTLRS]; > >>> @@ -147,8 +150,20 @@ static int tegra_ictlr_suspend(void) > >>> lic->cop_ier[i] = readl_relaxed(ictlr + > >>> ICTLR_COP_IER); lic->cop_iep[i] = readl_relaxed(ictlr + > >>> ICTLR_COP_IEP_CLASS); > >>> - /* Disable COP interrupts */ > >>> - writel_relaxed(~0ul, ictlr + > >>> ICTLR_COP_IER_CLR); > >>> + /* > >>> + * AVP/COP/BPMP-Lite is the Tegra boot > >>> processor. > >>> + * > >>> + * Tegra210 system suspend flow uses > >>> sc7entry firmware which > >>> + * is executed by COP/BPMP and it includes > >>> disabling COP IRQ, > >>> + * clamping CPU rail, turning off VDD_CPU, > >>> and preparing the > >>> + * system to go to SC7/LP0. > >>> + * > >>> + * COP/BPMP wakes up when COP IRQ is > >>> triggered and runs > >>> + * sc7entry-firmware. So need to keep COP > >>> interrupt enabled. > >>> + */ > >>> + if (!lic->soc->supports_sc7) > >>> + /* Disable COP interrupts if SC7 is > >>> not supported */ > >> All Tegra SoCs support SC7, hence the 'supports_sc7' and the > >> comment doesn't sound correct to me. Something like > >> 'firmware_sc7' should suit better here. > > If what you're saying is true, then the whole patch is wrong, > > and the SC7 property should come from DT. > It should be safe to assume that all of existing Tegra210 > devices use the firmware for SC7, hence I wouldn't say that the > patch is entirely wrong. To me it's not entirely correct. > >>> Yes, all existing Tegra210 platforms uses sc7 entry firmware for > >>> SC7 and AVP/COP IRQ need to be kept enabled as during suspend ATF > >>> triggers IRQ to COP for SC7 entry fw execution. > > Okay, as I already wrote before, it looks to me that a more proper > > solution should be to just remove everything related to COP from > > this driver instead of adding custom quirks for T210. > > > > The disabling / restoring of COP interrupts should be relevant only > > for the multimedia firmware on older Tegra SoCs. That firmware > > won't be ever supported in the upstream simply because NVIDIA > > abandoned the support for older hardware in the downstream and > > because it is not possible due to some legal weirdness (IIUC). The > > only variant for upstream is reverse-engineering of hardware (not > > the firmware BLOB) and writing proper opensource drivers for the > > upstream kernel, which we're already doing and
[PATCH] Revert "ASoC: rockchip: i2s: Support mono capture"
This reverts commit db51707b9c9aeedd310ebce60f15d5bb006567e0. Previous discussion in https://patchwork.kernel.org/patch/10147153/ explains the issue of the patch. While device is configured as 1-ch, hardware is still generating a 2-ch stream. When user space reads the data and assumes it is a 1-ch stream, the rate will be slower by 2x. Revert the change so 1-ch is not supported. User space can selectively take one channel data out of two channel if 1-ch is preferred. Currently, both channels record identical data. Signed-off-by: Cheng-Yi Chiang --- sound/soc/rockchip/rockchip_i2s.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c index 0a34d0eb8dba..88ebaf6e1880 100644 --- a/sound/soc/rockchip/rockchip_i2s.c +++ b/sound/soc/rockchip/rockchip_i2s.c @@ -326,7 +326,6 @@ static int rockchip_i2s_hw_params(struct snd_pcm_substream *substream, val |= I2S_CHN_4; break; case 2: - case 1: val |= I2S_CHN_2; break; default: @@ -459,7 +458,7 @@ static struct snd_soc_dai_driver rockchip_i2s_dai = { }, .capture = { .stream_name = "Capture", - .channels_min = 1, + .channels_min = 2, .channels_max = 2, .rates = SNDRV_PCM_RATE_8000_192000, .formats = (SNDRV_PCM_FMTBIT_S8 | @@ -659,7 +658,7 @@ static int rockchip_i2s_probe(struct platform_device *pdev) } if (!of_property_read_u32(node, "rockchip,capture-channels", )) { - if (val >= 1 && val <= 8) + if (val >= 2 && val <= 8) soc_dai->capture.channels_max = val; } -- 2.22.0.709.g102302147b-goog
Re: [PATCH 4/5] IMA: use obj-y for non-modular objects
On Fri, Jul 26, 2019 at 11:10:57AM +0900, Masahiro Yamada wrote: > CONFIG_IMA is a boolean option, so none of these objects is linked > into a module. > > All the objects in this directory are compiled only when CONFIG_IMA=y > since this directory is guarded by the parent Makefile: > > obj-$(CONFIG_IMA) += ima/ > > So, there is no point in creating the composite object, ima.o > > Flatten the code into the obj-$(CONFIG_...) form. > > Signed-off-by: Masahiro Yamada > --- > > security/integrity/ima/Makefile | 8 +++- > 1 file changed, 3 insertions(+), 5 deletions(-) > > diff --git a/security/integrity/ima/Makefile b/security/integrity/ima/Makefile > index d921dc4f9eb0..5517486c9154 100644 > --- a/security/integrity/ima/Makefile > +++ b/security/integrity/ima/Makefile > @@ -4,10 +4,8 @@ > # Measurement Architecture(IMA). > # > > -obj-$(CONFIG_IMA) += ima.o > - > -ima-y := ima_fs.o ima_queue.o ima_init.o ima_main.o ima_crypto.o ima_api.o \ > +obj-y := ima_fs.o ima_queue.o ima_init.o ima_main.o ima_crypto.o ima_api.o \ >ima_policy.o ima_template.o ima_template_lib.o > -ima-$(CONFIG_IMA_APPRAISE) += ima_appraise.o > -ima-$(CONFIG_HAVE_IMA_KEXEC) += ima_kexec.o > +obj-$(CONFIG_IMA_APPRAISE) += ima_appraise.o > +obj-$(CONFIG_HAVE_IMA_KEXEC) += ima_kexec.o > obj-$(CONFIG_IMA_BLACKLIST_KEYRING) += ima_mok.o > -- This patch changes the kernel command line options ima.ahash_minsize ima.ahash_bufsize to ima_crypto.ahash_minsize ima_crypto.ahash_bufsize Intentional? Note that these are documented in Documentation/admin-guide/kernel-parameters.txt. - Eric
Re: [RFC] mm/pgtable/debug: Add test validating architecture page table helpers
On 07/25/2019 10:37 PM, Catalin Marinas wrote: > On Thu, Jul 25, 2019 at 12:25:23PM +0530, Anshuman Khandual wrote: >> +#if !defined(__PAGETABLE_PMD_FOLDED) && !defined(__ARCH_HAS_4LEVEL_HACK) >> +static void pud_clear_tests(void) >> +{ >> +pud_t pud; >> + >> +pud_clear(); >> +WARN_ON(!pud_none(pud)); >> +} > > For the clear tests, I think you should initialise the local variable to > something non-zero rather than rely on whatever was on the stack. In > case it fails, you have a more deterministic behaviour. Sure, it makes sense, will change.
linux-next: build failure after merge of the akpm-current tree
Hi all, After merging the akpm-current tree, today's linux-next build (arm multi_v7_defconfig) failed like this: mm/madvise.c: In function 'madvise_cold_or_pageout_pte_range': mm/madvise.c:346:7: error: implicit declaration of function 'is_huge_zero_pmd'; did you mean 'is_huge_zero_pud'? [-Werror=implicit-function-declaration] if (is_huge_zero_pmd(orig_pmd)) ^~~~ is_huge_zero_pud mm/madvise.c:373:7: error: implicit declaration of function 'pmd_young'; did you mean 'pte_young'? [-Werror=implicit-function-declaration] if (pmd_young(orig_pmd)) { ^ pte_young mm/madvise.c:375:15: error: implicit declaration of function 'pmd_mkold'; did you mean 'pte_mkold'? [-Werror=implicit-function-declaration] orig_pmd = pmd_mkold(orig_pmd); ^ pte_mkold mm/madvise.c:377:4: error: implicit declaration of function 'set_pmd_at'; did you mean 'set_pte_at'? [-Werror=implicit-function-declaration] set_pmd_at(mm, addr, pmd, orig_pmd); ^~ set_pte_at Caused by commit d6d92199f211 ("mm, madvise: introduce MADV_COLD") I have reverted (I assume the first four depend on the last): 674db9810e45 ("mm, madvise: factor out common parts between MADV_COLD and MADV_PAGEOUT") 5bd341efe8f1 ("mm, madvise: introduce MADV_PAGEOUT") c487c618dcf1 ("mm, madvise: account nr_isolated_xxx in [isolate|putback]_lru_page") 1ef762b1c799 ("mm, madvise: change PAGEREF_RECLAIM_CLEAN with PAGE_REFRECLAIM") d6d92199f211 ("mm, madvise: introduce MADV_COLD") for today (as - I just noticed - is suggested in another email). -- Cheers, Stephen Rothwell pgpKDVvsTj1xV.pgp Description: OpenPGP digital signature
Re: [PATCH V2 net-next 00/11] net: hns3: some code optimizations & bugfixes & features
Sorry, please ignore this patchset. Will resend it later:) On 2019/7/26 11:24, Huazhong Tan wrote: This patch-set includes code optimizations, bugfixes and features for the HNS3 ethernet controller driver. [patch 1/11] checks reset status before setting channel. [patch 2/11] adds a NULL pointer checking. [patch 3/11] removes reset level upgrading when current reset fails. [patch 4/11] fixes a bug related to IRQ vector number initialization. [patch 5/11] fixes a GFP flags errors when holding spin_lock. [patch 6/11] modifies firmware version format. [patch 7/11] adds some print information which is off by default. [patch 8/11 - 9/11] adds two code optimizations about interrupt handler and work task. [patch 10/11] adds support for using order 1 pages with a 4K buffer. [patch 11/11] modifies messages prints with dev_info() instead of pr_info(). Change log: V1->V2: fixes comments from Saeed Mahameed and removes previous [patch 11/11] which needs further discussion, adds a new patch [11/11] suggested by Saeed Mahameed. Guangbin Huang (1): net: hns3: add a check for get_reset_level Huazhong Tan (2): net: hns3: remove upgrade reset level when reset fail net: hns3: use dev_info() instead of pr_info() Jian Shen (1): net: hns3: add reset checking before set channels Yonglong Liu (2): net: hns3: fix mis-counting IRQ vector numbers issue net: hns3: adds debug messages to identify eth down cause Yufeng Mo (2): net: hns3: change GFP flag during lock period net: hns3: modify firmware version display format Yunsheng Lin (3): net: hns3: make hclge_service use delayed workqueue net: hns3: add interrupt affinity support for misc interrupt net: hns3: Add support for using order 1 pages with a 4K buffer drivers/net/ethernet/hisilicon/hns3/hnae3.h| 9 ++ drivers/net/ethernet/hisilicon/hns3/hns3_enet.c| 39 +- drivers/net/ethernet/hisilicon/hns3/hns3_enet.h| 15 ++- drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 41 +- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c | 10 +- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c | 14 +++ .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c| 137 - .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h| 7 +- .../ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.c | 10 +- .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 15 ++- 10 files changed, 223 insertions(+), 74 deletions(-)
Re: [PATCH] tools/lib/traceevent, tools/perf: Move struct tep_handler definition in a local header file
Hi, On 2018-10-05 12:22:25 -0400, Steven Rostedt wrote: > From: Tzvetomir Stoyanov > > As traceevent is going to be transferred into a proper library, > its local data should be protected from the library users. > This patch encapsulates struct tep_handler into a local header, > not visible outside of the library. It implements also a bunch > of new APIs, which library users can use to access tep_handler members. This commit appears to have broken perf script --gen-script / trace_find_next_event(). As far as I can tell: @ -192,25 +193,29 @@ struct tep_event_format *trace_find_next_event(struct tep_handle *pevent, > struct tep_event_format *event) > { > static int idx; > + int events_count; > + struct tep_event_format *all_events; > > - if (!pevent || !pevent->events) > + all_events = tep_get_first_event(pevent); > + events_count = tep_get_events_count(pevent); > + if (!pevent || !all_events || events_count < 1) > return NULL; > > if (!event) { > idx = 0; > - return pevent->events[0]; > + return all_events; > } > > - if (idx < pevent->nr_events && event == pevent->events[idx]) { > + if (idx < events_count && event == (all_events + idx)) { > idx++; > - if (idx == pevent->nr_events) > + if (idx == events_count) > return NULL; > - return pevent->events[idx]; > + return (all_events + idx); > } > > - for (idx = 1; idx < pevent->nr_events; idx++) { > - if (event == pevent->events[idx - 1]) > - return pevent->events[idx]; > + for (idx = 1; idx < events_count; idx++) { > + if (event == (all_events + (idx - 1))) > + return (all_events + idx); > } > return NULL; > } Is just plain wrong, as: > - return pevent->events[idx]; > + return (all_events + idx); that's not a valid conversion. ->events isn't an array of tep_handle, it's an array of tep_handle* (and even if it were, the previous notation would have needed to dereference the value to make it comparable). What this does is look idx behind the individually allocated event. Which is incorrect. To reproduce the crash, just generating a trace file with at least two events suffices: perf record -e raw_syscalls:sys_enter,raw_syscalls:sys_exit sleep 1 gdb --args perf script -g py Program received signal SIGSEGV, Segmentation fault. __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:96 96 ../sysdeps/x86_64/multiarch/strlen-avx2.S: No such file or directory. (gdb) bt #0 __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:96 #1 0x7726f9ef in _IO_vfprintf_internal (s=s@entry=0x55c23970, format=format@entry=0x558fed76 "def %s__%s(", ap=ap@entry=0x7fffb900) at vfprintf.c:1638 #2 0x77326536 in ___fprintf_chk (fp=fp@entry=0x55c23970, flag=flag@entry=1, format=format@entry=0x558fed76 "def %s__%s(") at fprintf_chk.c:35 #3 0x5587065c in fprintf (__fmt=0x558fed76 "def %s__%s(", __stream=0x55c23970) at /usr/include/x86_64-linux-gnu/bits/stdio2.h:100 #4 python_generate_script (pevent=0x55c2e620, outfile=) at util/scripting-engines/trace-event-python.c:1651 #5 0x55745762 in cmd_script (argc=, argv=0x7fffe4d0) at builtin-script.c:3743 #6 0x5579821d in run_builtin (p=0x55abeb38 , argc=3, argv=0x7fffe4d0) at perf.c:303 #7 0x55712b7a in handle_internal_command (argv=0x7fffe4d0, argc=3) at perf.c:355 #8 run_argv (argcp=, argv=) at perf.c:399 #9 main (argc=3, argv=0x7fffe4d0) at perf.c:521 The fix (in recent kernel versions) appears to just bee to use tep_get_event(), instead of the old pevent->events[...]. But it appears to me that commit 80c5526c8544ae76cba31fb9702ab8accac1f0f3 Author: Tzvetomir Stoyanov Date: 2019-04-01 12:43:12 -0400 tools lib traceevent: Implement new traceevent APIs for accessing struct tep_handler fields ommitted adding it to event-parse.h. It appears to be intended as public API however, given that it got documented in commit 747e942c3925bb85e2865371664499a98fca83b0 Author: Tzvetomir Stoyanov Date: 2019-05-10 15:56:23 -0400 tools lib traceevent: Man pages for libtraceevent event get APIs The following patch fixes this for me. I can polish it up, but I'm wondering if I'm missing something here? diff --git i/tools/lib/traceevent/event-parse.h w/tools/lib/traceevent/event-parse.h index 642f68ab5fb2..7ebc9b5308d4 100644 --- i/tools/lib/traceevent/event-parse.h +++ w/tools/lib/traceevent/event-parse.h @@ -517,6 +517,7 @@ int tep_read_number_field(struct tep_format_field *field, const void *data, unsigned long long *value); struct tep_event *tep_get_first_event(struct tep_handle *tep); +struct tep_event
Re: [PATCH v2] .gitignore: Add compilation database file
On Tue, Jul 23, 2019 at 5:22 PM Toru Komatsu wrote: > > This file is used by clangd to use language server protocol. > It can be generated at each compile using scripts/gen_compile_commands.py. > Therefore it is different depending on the environment and should be > ignored. > > Signed-off-by: Toru Komatsu Thank you again for this patch. We're working on adding clang-tidy checks for the Linux kernel, which will make use of this file soon. Keep yours eyes out for it! https://reviews.llvm.org/D59963 Reviewed-by: Nick Desaulniers > --- > .gitignore | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/.gitignore b/.gitignore > index 8f5422cba6e2..2030c7a4d2f8 100644 > --- a/.gitignore > +++ b/.gitignore > @@ -142,3 +142,6 @@ x509.genkey > > # Kdevelop4 > *.kdev4 > + > +# Clang's compilation database file > +/compile_commands.json > -- > 2.17.1 > -- Thanks, ~Nick Desaulniers
[PATCH 2/3] fs: ocfs2: Fix a possible null-pointer dereference in ocfs2_write_end_nolock()
In ocfs2_write_end_nolock(), there are an if statement on lines 1976, 2047 and 2058, to check whether handle is NULL: if (handle) When handle is NULL, it is used on line 2045: ocfs2_update_inode_fsync_trans(handle, inode, 1); oi->i_sync_tid = handle->h_transaction->t_tid; Thus, a possible null-pointer dereference may occur. To fix this bug, handle is checked before calling ocfs2_update_inode_fsync_trans(). This bug is found by a static analysis tool STCheck written by us. Signed-off-by: Jia-Ju Bai --- fs/ocfs2/aops.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index a4c905d6b575..5473bd99043e 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c @@ -2042,7 +2042,8 @@ int ocfs2_write_end_nolock(struct address_space *mapping, inode->i_mtime = inode->i_ctime = current_time(inode); di->i_mtime = di->i_ctime = cpu_to_le64(inode->i_mtime.tv_sec); di->i_mtime_nsec = di->i_ctime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec); - ocfs2_update_inode_fsync_trans(handle, inode, 1); + if (handle) + ocfs2_update_inode_fsync_trans(handle, inode, 1); } if (handle) ocfs2_journal_dirty(handle, wc->w_di_bh); -- 2.17.0
[PATCH 1/3] fs: ocfs2: Fix possible null-pointer dereferences in ocfs2_xa_prepare_entry()
In ocfs2_xa_prepare_entry(), there is an if statement on line 2136 to check whether loc->xl_entry is NULL: if (loc->xl_entry) When loc->xl_entry is NULL, it is used on line 2158: ocfs2_xa_add_entry(loc, name_hash); loc->xl_entry->xe_name_hash = cpu_to_le32(name_hash); loc->xl_entry->xe_name_offset = cpu_to_le16(loc->xl_size); and line 2164: ocfs2_xa_add_namevalue(loc, xi); loc->xl_entry->xe_value_size = cpu_to_le64(xi->xi_value_len); loc->xl_entry->xe_name_len = xi->xi_name_len; Thus, possible null-pointer dereferences may occur. To fix these bugs, if loc-xl_entry is NULL, ocfs2_xa_prepare_entry() abnormally returns with -EINVAL. These bugs are found by a static analysis tool STCheck written by us. Signed-off-by: Jia-Ju Bai --- fs/ocfs2/xattr.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c index 385f3aaa2448..f690502daf3c 100644 --- a/fs/ocfs2/xattr.c +++ b/fs/ocfs2/xattr.c @@ -2154,8 +2154,10 @@ static int ocfs2_xa_prepare_entry(struct ocfs2_xa_loc *loc, } } ocfs2_xa_wipe_namevalue(loc); - } else - ocfs2_xa_add_entry(loc, name_hash); + } else { + rc = -EINVAL; + goto out; + } /* * If we get here, we have a blank entry. Fill it. We grow our -- 2.17.0
[PATCH 3/3] fs: ocfs2: Fix a possible null-pointer dereference in ocfs2_info_scan_inode_alloc()
In ocfs2_info_scan_inode_alloc(), there is an if statement on line 283 to check whether inode_alloc is NULL: if (inode_alloc) When inode_alloc is NULL, it is used on line 287: ocfs2_inode_lock(inode_alloc, , 0); ocfs2_inode_lock_full_nested(inode, ...) struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); Thus, a possible null-pointer dereference may occur. To fix this bug, inode_alloc is checked on line 286. This bug is found by a static analysis tool STCheck written by us. Signed-off-by: Jia-Ju Bai --- fs/ocfs2/ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ocfs2/ioctl.c b/fs/ocfs2/ioctl.c index d6f7b299eb23..efeea208fdeb 100644 --- a/fs/ocfs2/ioctl.c +++ b/fs/ocfs2/ioctl.c @@ -283,7 +283,7 @@ static int ocfs2_info_scan_inode_alloc(struct ocfs2_super *osb, if (inode_alloc) inode_lock(inode_alloc); - if (o2info_coherent(>ifi_req)) { + if (inode_alloc && o2info_coherent(>ifi_req)) { status = ocfs2_inode_lock(inode_alloc, , 0); if (status < 0) { mlog_errno(status); -- 2.17.0
Re: [BUG] fs: f2fs: Possible null-pointer dereferences in update_general_status()
Hi Jiaju, Thanks for the report, I checked the code, and found it doesn't need to check SM_I(sbi) pointer, this is because in fill_super() and put_super(), we will call f2fs_destroy_stats() in prior to f2fs_destroy_segment_manager(), so if current sbi can still be visited in global stat list, SM_I(sbi) should be released yet. So anyway, let's remove unneeded check in line 70/78. :) Thanks, On 2019/7/25 17:49, Jia-Ju Bai wrote: > In update_general_status(), there are two if statements to > check whether SM_I(sbi) is NULL: > LINE 70: if (SM_I(sbi) && SM_I(sbi)->fcc_info) > LINE 78: if (SM_I(sbi) && SM_I(sbi)->dcc_info) > > When SM_I(sbi) is NULL, it is used at some places, such as: > LINE 88: reserved_segments(sbi) > return SM_I(sbi)->reserved_segments; > LINE 89: overprovision_segments(sbi) > return SM_I(sbi)->ovp_segments; > LINE 112: MAIN_SEGS(sbi) > (SM_I(sbi)->main_segments) > > Thus, possible null-pointer dereferences may occur. > > These bugs are found by a static analysis tool STCheck written by us. > > I do not know how to correctly fix these bugs, so I only report them. > > > Best wishes, > Jia-Ju Bai > . >
[PATCH] [ASoC][soc-dapm] : memory leak in the func snd_soc_dapm_new_dai
In the func snd_soc_dapm_new_dai, if the inner func snd_soc_dapm_alloc_kcontrol fails, there will be memory leak. The label param_fail wont free memory which is allocated by the func devm_kcalloc. Hence new label is created for this purpose. Signed-off-by: Satendra Singh Thakur --- sound/soc/soc-dapm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index f013b24c050a..f62d41ee6d68 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -4095,7 +4095,7 @@ snd_soc_dapm_new_dai(struct snd_soc_card *card, struct snd_soc_pcm_runtime *rtd, w_param_text, _value); if (!template.kcontrol_news) { ret = -ENOMEM; - goto param_fail; + goto outfree_w_param; } } else { w_param_text = NULL; @@ -4114,6 +4114,7 @@ snd_soc_dapm_new_dai(struct snd_soc_card *card, struct snd_soc_pcm_runtime *rtd, outfree_kcontrol_news: devm_kfree(card->dev, (void *)template.kcontrol_news); +outfree_w_param: snd_soc_dapm_free_kcontrol(card, _value, rtd->dai_link->num_params, w_param_text); param_fail: -- 2.17.1
[PATCH V2 net-next 09/11] net: hns3: add interrupt affinity support for misc interrupt
From: Yunsheng Lin The misc interrupt is used to schedule the reset and mailbox subtask, and a 1 sec timer is used to schedule the service subtask, which does periodic work. This patch sets the above three subtask's affinity using the misc interrupt' affinity. Also this patch setups a affinity notify for misc interrupt to allow user to change the above three subtask's affinity. Signed-off-by: Yunsheng Lin Signed-off-by: Peng Li Signed-off-by: Huazhong Tan --- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c| 53 -- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h| 4 ++ 2 files changed, 53 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index e804a19..3e43dff 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -1270,6 +1270,12 @@ static int hclge_configure(struct hclge_dev *hdev) hclge_init_kdump_kernel_config(hdev); + /* Set the init affinity based on pci func number */ + i = cpumask_weight(cpumask_of_node(dev_to_node(>pdev->dev))); + i = i ? PCI_FUNC(hdev->pdev->devfn) % i : 0; + cpumask_set_cpu(cpumask_local_spread(i, dev_to_node(>pdev->dev)), + >affinity_mask); + return ret; } @@ -2501,14 +2507,16 @@ static void hclge_mbx_task_schedule(struct hclge_dev *hdev) { if (!test_bit(HCLGE_STATE_CMD_DISABLE, >state) && !test_and_set_bit(HCLGE_STATE_MBX_SERVICE_SCHED, >state)) - schedule_work(>mbx_service_task); + queue_work_on(cpumask_first(>affinity_mask), system_wq, + >mbx_service_task); } static void hclge_reset_task_schedule(struct hclge_dev *hdev) { if (!test_bit(HCLGE_STATE_REMOVING, >state) && !test_and_set_bit(HCLGE_STATE_RST_SERVICE_SCHED, >state)) - schedule_work(>rst_service_task); + queue_work_on(cpumask_first(>affinity_mask), system_wq, + >rst_service_task); } static void hclge_task_schedule(struct hclge_dev *hdev) @@ -2518,8 +2526,9 @@ static void hclge_task_schedule(struct hclge_dev *hdev) !test_and_set_bit(HCLGE_STATE_SERVICE_SCHED, >state)) { hdev->hw_stats.stats_timer++; hdev->fd_arfs_expire_timer++; - mod_delayed_work(system_wq, >service_task, -round_jiffies_relative(HZ)); + mod_delayed_work_on(cpumask_first(>affinity_mask), + system_wq, >service_task, + round_jiffies_relative(HZ)); } } @@ -2905,6 +2914,36 @@ static void hclge_get_misc_vector(struct hclge_dev *hdev) hdev->num_msi_used += 1; } +static void hclge_irq_affinity_notify(struct irq_affinity_notify *notify, + const cpumask_t *mask) +{ + struct hclge_dev *hdev = container_of(notify, struct hclge_dev, + affinity_notify); + + cpumask_copy(>affinity_mask, mask); +} + +static void hclge_irq_affinity_release(struct kref *ref) +{ +} + +static void hclge_misc_affinity_setup(struct hclge_dev *hdev) +{ + irq_set_affinity_hint(hdev->misc_vector.vector_irq, + >affinity_mask); + + hdev->affinity_notify.notify = hclge_irq_affinity_notify; + hdev->affinity_notify.release = hclge_irq_affinity_release; + irq_set_affinity_notifier(hdev->misc_vector.vector_irq, + >affinity_notify); +} + +static void hclge_misc_affinity_teardown(struct hclge_dev *hdev) +{ + irq_set_affinity_notifier(hdev->misc_vector.vector_irq, NULL); + irq_set_affinity_hint(hdev->misc_vector.vector_irq, NULL); +} + static int hclge_misc_irq_init(struct hclge_dev *hdev) { int ret; @@ -8796,6 +8835,11 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) INIT_WORK(>rst_service_task, hclge_reset_service_task); INIT_WORK(>mbx_service_task, hclge_mailbox_service_task); + /* Setup affinity after service timer setup because add_timer_on +* is called in affinity notify. +*/ + hclge_misc_affinity_setup(hdev); + hclge_clear_all_event_cause(hdev); hclge_clear_resetting_state(hdev); @@ -8957,6 +9001,7 @@ static void hclge_uninit_ae_dev(struct hnae3_ae_dev *ae_dev) struct hclge_dev *hdev = ae_dev->priv; struct hclge_mac *mac = >hw.mac; + hclge_misc_affinity_teardown(hdev); hclge_state_uninit(hdev); if (mac->phydev) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index dde8f22..688e425 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +++
[PATCH V2 net-next 03/11] net: hns3: remove upgrade reset level when reset fail
Currently, hclge_reset_err_handle() will assert a global reset when the failing count is smaller than MAX_RESET_FAIL_CNT, which will affect other running functions. So this patch removes this upgrading, and uses re-scheduling reset task to do it. Signed-off-by: Huazhong Tan Reviewed-by: Yunsheng Lin --- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c| 28 +++--- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 3fde5471..3c64d70 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -3305,7 +3305,7 @@ static int hclge_reset_prepare_wait(struct hclge_dev *hdev) return ret; } -static bool hclge_reset_err_handle(struct hclge_dev *hdev, bool is_timeout) +static bool hclge_reset_err_handle(struct hclge_dev *hdev) { #define MAX_RESET_FAIL_CNT 5 @@ -3322,20 +3322,11 @@ static bool hclge_reset_err_handle(struct hclge_dev *hdev, bool is_timeout) return false; } else if (hdev->reset_fail_cnt < MAX_RESET_FAIL_CNT) { hdev->reset_fail_cnt++; - if (is_timeout) { - set_bit(hdev->reset_type, >reset_pending); - dev_info(>pdev->dev, -"re-schedule to wait for hw reset done\n"); - return true; - } - - dev_info(>pdev->dev, "Upgrade reset level\n"); - hclge_clear_reset_cause(hdev); - set_bit(HNAE3_GLOBAL_RESET, >default_reset_request); - mod_timer(>reset_timer, - jiffies + HCLGE_RESET_INTERVAL); - - return false; + set_bit(hdev->reset_type, >reset_pending); + dev_info(>pdev->dev, +"re-schedule reset task(%d)\n", +hdev->reset_fail_cnt); + return true; } hclge_clear_reset_cause(hdev); @@ -3382,7 +3373,6 @@ static int hclge_reset_stack(struct hclge_dev *hdev) static void hclge_reset(struct hclge_dev *hdev) { struct hnae3_ae_dev *ae_dev = pci_get_drvdata(hdev->pdev); - bool is_timeout = false; int ret; /* Initialize ae_dev reset status as well, in case enet layer wants to @@ -3410,10 +3400,8 @@ static void hclge_reset(struct hclge_dev *hdev) if (ret) goto err_reset; - if (hclge_reset_wait(hdev)) { - is_timeout = true; + if (hclge_reset_wait(hdev)) goto err_reset; - } hdev->rst_stats.hw_reset_done_cnt++; @@ -3465,7 +3453,7 @@ static void hclge_reset(struct hclge_dev *hdev) err_reset_lock: rtnl_unlock(); err_reset: - if (hclge_reset_err_handle(hdev, is_timeout)) + if (hclge_reset_err_handle(hdev)) hclge_reset_task_schedule(hdev); } -- 2.7.4
[PATCH V2 net-next 00/11] net: hns3: some code optimizations & bugfixes & features
This patch-set includes code optimizations, bugfixes and features for the HNS3 ethernet controller driver. [patch 1/11] checks reset status before setting channel. [patch 2/11] adds a NULL pointer checking. [patch 3/11] removes reset level upgrading when current reset fails. [patch 4/11] fixes a bug related to IRQ vector number initialization. [patch 5/11] fixes a GFP flags errors when holding spin_lock. [patch 6/11] modifies firmware version format. [patch 7/11] adds some print information which is off by default. [patch 8/11 - 9/11] adds two code optimizations about interrupt handler and work task. [patch 10/11] adds support for using order 1 pages with a 4K buffer. [patch 11/11] modifies messages prints with dev_info() instead of pr_info(). Change log: V1->V2: fixes comments from Saeed Mahameed and removes previous [patch 11/11] which needs further discussion, adds a new patch [11/11] suggested by Saeed Mahameed. Guangbin Huang (1): net: hns3: add a check for get_reset_level Huazhong Tan (2): net: hns3: remove upgrade reset level when reset fail net: hns3: use dev_info() instead of pr_info() Jian Shen (1): net: hns3: add reset checking before set channels Yonglong Liu (2): net: hns3: fix mis-counting IRQ vector numbers issue net: hns3: adds debug messages to identify eth down cause Yufeng Mo (2): net: hns3: change GFP flag during lock period net: hns3: modify firmware version display format Yunsheng Lin (3): net: hns3: make hclge_service use delayed workqueue net: hns3: add interrupt affinity support for misc interrupt net: hns3: Add support for using order 1 pages with a 4K buffer drivers/net/ethernet/hisilicon/hns3/hnae3.h| 9 ++ drivers/net/ethernet/hisilicon/hns3/hns3_enet.c| 39 +- drivers/net/ethernet/hisilicon/hns3/hns3_enet.h| 15 ++- drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 41 +- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c | 10 +- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c | 14 +++ .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c| 137 - .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h| 7 +- .../ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.c | 10 +- .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 15 ++- 10 files changed, 223 insertions(+), 74 deletions(-) -- 2.7.4
[PATCH V2 net-next 02/11] net: hns3: add a check for get_reset_level
From: Guangbin Huang For some cases, ops->get_reset_level may not be implemented, so we should check whether it is NULL before calling get_reset_level. Signed-off-by: Guangbin Huang Signed-off-by: Huazhong Tan --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 08af782..4d58c53 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -1963,7 +1963,7 @@ static pci_ers_result_t hns3_slot_reset(struct pci_dev *pdev) ops = ae_dev->ops; /* request the reset */ - if (ops->reset_event) { + if (ops->reset_event && ops->get_reset_level) { if (ae_dev->hw_err_reset_req) { reset_type = ops->get_reset_level(ae_dev, _dev->hw_err_reset_req); -- 2.7.4
[PATCH V2 net-next 05/11] net: hns3: change GFP flag during lock period
From: Yufeng Mo When allocating memory, the GFP_KERNEL cannot be used during the spin_lock period. This is because it may cause scheduling when holding spin_lock. This patch changes GFP flag to GFP_ATOMIC in this case. Fixes: dd74f815dd41 ("net: hns3: Add support for rule add/delete for flow director") Signed-off-by: Yufeng Mo Signed-off-by: lipeng 00277521 Signed-off-by: Huazhong Tan --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 9329aab..faf60b4 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -5798,7 +5798,7 @@ static int hclge_add_fd_entry_by_arfs(struct hnae3_handle *handle, u16 queue_id, return -ENOSPC; } - rule = kzalloc(sizeof(*rule), GFP_KERNEL); + rule = kzalloc(sizeof(*rule), GFP_ATOMIC); if (!rule) { spin_unlock_bh(>fd_rule_lock); -- 2.7.4
[PATCH V2 net-next 01/11] net: hns3: add reset checking before set channels
From: Jian Shen hns3_set_channels() should check the resetting status firstly, since the device will reinitialize when resetting. If the reset has not completed, the hns3_set_channels() may access invalid memory. Signed-off-by: Jian Shen Signed-off-by: Huazhong Tan --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 69f7ef8..08af782 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -4378,6 +4378,9 @@ int hns3_set_channels(struct net_device *netdev, u16 org_tqp_num; int ret; + if (hns3_nic_resetting(netdev)) + return -EBUSY; + if (ch->rx_count || ch->tx_count) return -EINVAL; -- 2.7.4
[PATCH V2 net-next 04/11] net: hns3: fix mis-counting IRQ vector numbers issue
From: Yonglong Liu The num_msi_left means the vector numbers of NIC, but if the PF supported RoCE, it contains the vector numbers of NIC and RoCE(Not expected). This may cause interrupts lost in some case, because of the NIC module used the vector resources which belongs to RoCE. This patch corrects the value of num_msi_left to be equals to the vector numbers of NIC, and adjust the default tqp numbers according to the value of num_msi_left. Also, adds a little cleanup about checking whether the device is supporting RoCE before allocating IRQ vector. Fixes: 46a3df9f9718 ("net: hns3: Add HNS3 Acceleration Engine & Compatibility Layer Support") Signed-off-by: Yonglong Liu Signed-off-by: Peng Li Signed-off-by: Huazhong Tan --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 2 ++ drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 12 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 3c64d70..9329aab 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -1476,6 +1476,8 @@ static int hclge_vport_setup(struct hclge_vport *vport, u16 num_tqps) nic->ae_algo = _algo; nic->numa_node_mask = hdev->numa_node_mask; + num_tqps = min_t(u16, hdev->roce_base_msix_offset - 1, num_tqps); + ret = hclge_knic_setup(vport, num_tqps, hdev->num_tx_desc, hdev->num_rx_desc); if (ret) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c index a13a0e1..db84782 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c @@ -287,6 +287,14 @@ static int hclgevf_get_queue_info(struct hclgevf_dev *hdev) memcpy(>rss_size_max, _msg[2], sizeof(u16)); memcpy(>rx_buf_len, _msg[4], sizeof(u16)); + /* if irq is not enough, let tqps have the same value of irqs, +* to make sure one irq just bind to one tqp, this can improve +* the performance +*/ + hdev->num_tqps = min_t(u16, hdev->roce_base_msix_offset - 1, + hdev->num_tqps); + hdev->rss_size_max = min_t(u16, hdev->rss_size_max, hdev->num_tqps); + return 0; } @@ -2208,7 +2216,7 @@ static int hclgevf_init_msi(struct hclgevf_dev *hdev) int vectors; int i; - if (hnae3_get_bit(hdev->ae_dev->flag, HNAE3_DEV_SUPPORT_ROCE_B)) + if (hnae3_dev_roce_supported(hdev)) vectors = pci_alloc_irq_vectors(pdev, hdev->roce_base_msix_offset + 1, hdev->num_msi, @@ -2495,7 +2503,7 @@ static int hclgevf_query_vf_resource(struct hclgevf_dev *hdev) req = (struct hclgevf_query_res_cmd *)desc.data; - if (hnae3_get_bit(hdev->ae_dev->flag, HNAE3_DEV_SUPPORT_ROCE_B)) { + if (hnae3_dev_roce_supported(hdev)) { hdev->roce_base_msix_offset = hnae3_get_field(__le16_to_cpu(req->msixcap_localid_ba_rocee), HCLGEVF_MSIX_OFT_ROCEE_M, -- 2.7.4
[PATCH V2 net-next 07/11] net: hns3: adds debug messages to identify eth down cause
From: Yonglong Liu Some times just see the eth interface have been down/up via dmesg, but can not know why the eth down. So adds some debug messages to identify the cause for this. Signed-off-by: Yonglong Liu Signed-off-by: Peng Li Signed-off-by: Huazhong Tan --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c| 24 drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 26 ++ .../net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c | 14 3 files changed, 64 insertions(+) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 4d58c53..2e30cfa 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -459,6 +459,10 @@ static int hns3_nic_net_open(struct net_device *netdev) h->ae_algo->ops->set_timer_task(priv->ae_handle, true); hns3_config_xps(priv); + + if (netif_msg_drv(h)) + netdev_info(netdev, "net open\n"); + return 0; } @@ -519,6 +523,9 @@ static int hns3_nic_net_stop(struct net_device *netdev) if (test_and_set_bit(HNS3_NIC_STATE_DOWN, >state)) return 0; + if (netif_msg_drv(h)) + netdev_info(netdev, "net stop\n"); + if (h->ae_algo->ops->set_timer_task) h->ae_algo->ops->set_timer_task(priv->ae_handle, false); @@ -1550,6 +1557,9 @@ static int hns3_setup_tc(struct net_device *netdev, void *type_data) h = hns3_get_handle(netdev); kinfo = >kinfo; + if (netif_msg_drv(h)) + netdev_info(netdev, "setup tc: num_tc=%d\n", tc); + return (kinfo->dcb_ops && kinfo->dcb_ops->setup_tc) ? kinfo->dcb_ops->setup_tc(h, tc, prio_tc) : -EOPNOTSUPP; } @@ -1593,6 +1603,11 @@ static int hns3_ndo_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, struct hnae3_handle *h = hns3_get_handle(netdev); int ret = -EIO; + if (netif_msg_drv(h)) + netdev_info(netdev, + "set vf vlan: vf=%d, vlan=%d, qos=%d, vlan_proto=%d\n", + vf, vlan, qos, vlan_proto); + if (h->ae_algo->ops->set_vf_vlan_filter) ret = h->ae_algo->ops->set_vf_vlan_filter(h, vf, vlan, qos, vlan_proto); @@ -1611,6 +1626,10 @@ static int hns3_nic_change_mtu(struct net_device *netdev, int new_mtu) if (!h->ae_algo->ops->set_mtu) return -EOPNOTSUPP; + if (netif_msg_drv(h)) + netdev_info(netdev, "change mtu from %d to %d\n", + netdev->mtu, new_mtu); + ret = h->ae_algo->ops->set_mtu(h, new_mtu); if (ret) netdev_err(netdev, "failed to change MTU in hardware %d\n", @@ -4395,6 +4414,11 @@ int hns3_set_channels(struct net_device *netdev, if (kinfo->rss_size == new_tqp_num) return 0; + if (netif_msg_drv(h)) + netdev_info(netdev, + "set channels: tqp_num=%d, rxfh=%d\n", + new_tqp_num, rxfh_configured); + ret = hns3_reset_notify(h, HNAE3_DOWN_CLIENT); if (ret) return ret; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c index e71c92b..08334d7 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c @@ -311,6 +311,9 @@ static void hns3_self_test(struct net_device *ndev, if (eth_test->flags != ETH_TEST_FL_OFFLINE) return; + if (netif_msg_drv(h)) + netdev_info(ndev, "self test start\n"); + st_param[HNAE3_LOOP_APP][0] = HNAE3_LOOP_APP; st_param[HNAE3_LOOP_APP][1] = h->flags & HNAE3_SUPPORT_APP_LOOPBACK; @@ -374,6 +377,9 @@ static void hns3_self_test(struct net_device *ndev, if (if_running) ndev->netdev_ops->ndo_open(ndev); + + if (netif_msg_drv(h)) + netdev_info(ndev, "self test end\n"); } static int hns3_get_sset_count(struct net_device *netdev, int stringset) @@ -604,6 +610,11 @@ static int hns3_set_pauseparam(struct net_device *netdev, { struct hnae3_handle *h = hns3_get_handle(netdev); + if (netif_msg_drv(h)) + netdev_info(netdev, + "set pauseparam: autoneg=%d, rx:%d, tx:%d\n", + param->autoneg, param->rx_pause, param->tx_pause); + if (h->ae_algo->ops->set_pauseparam) return h->ae_algo->ops->set_pauseparam(h, param->autoneg, param->rx_pause, @@ -743,6 +754,13 @@ static int hns3_set_link_ksettings(struct net_device *netdev, if (cmd->base.speed == SPEED_1000 && cmd->base.duplex ==
[PATCH V2 net-next 10/11] net: hns3: Add support for using order 1 pages with a 4K buffer
From: Yunsheng Lin Hardware supports 0.5K, 1K, 2K, 4K RX buffer size, the RX buffer can not be reused because the hns3_page_order return 0 when page size and RX buffer size are both 4096. So this patch changes the hns3_page_order to return 1 when RX buffer is greater than half of the page size and page size is less the 8192, and dev_alloc_pages has already been used to allocate the compound page for RX buffer. This patch also changes hnae3_* to hns3_* for page order and RX buffer size calculation because they are used in hns3 module. Signed-off-by: Yunsheng Lin Reviewed-by: Peng Li Signed-off-by: Huazhong Tan --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 10 +- drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | 15 --- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 2e30cfa..3a93bef 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -2086,7 +2086,7 @@ static void hns3_set_default_feature(struct net_device *netdev) static int hns3_alloc_buffer(struct hns3_enet_ring *ring, struct hns3_desc_cb *cb) { - unsigned int order = hnae3_page_order(ring); + unsigned int order = hns3_page_order(ring); struct page *p; p = dev_alloc_pages(order); @@ -2097,7 +2097,7 @@ static int hns3_alloc_buffer(struct hns3_enet_ring *ring, cb->page_offset = 0; cb->reuse_flag = 0; cb->buf = page_address(p); - cb->length = hnae3_page_size(ring); + cb->length = hns3_page_size(ring); cb->type = DESC_TYPE_PAGE; return 0; @@ -2400,7 +2400,7 @@ static void hns3_nic_reuse_page(struct sk_buff *skb, int i, { struct hns3_desc *desc = >desc[ring->next_to_clean]; int size = le16_to_cpu(desc->rx.size); - u32 truesize = hnae3_buf_size(ring); + u32 truesize = hns3_buf_size(ring); skb_add_rx_frag(skb, i, desc_cb->priv, desc_cb->page_offset + pull_len, size - pull_len, truesize); @@ -2415,7 +2415,7 @@ static void hns3_nic_reuse_page(struct sk_buff *skb, int i, /* Move offset up to the next cache line */ desc_cb->page_offset += truesize; - if (desc_cb->page_offset + truesize <= hnae3_page_size(ring)) { + if (desc_cb->page_offset + truesize <= hns3_page_size(ring)) { desc_cb->reuse_flag = 1; /* Bump ref count on page before it is given */ get_page(desc_cb->priv); @@ -2697,7 +2697,7 @@ static int hns3_add_frag(struct hns3_enet_ring *ring, struct hns3_desc *desc, } if (ring->tail_skb) { - head_skb->truesize += hnae3_buf_size(ring); + head_skb->truesize += hns3_buf_size(ring); head_skb->data_len += le16_to_cpu(desc->rx.size); head_skb->len += le16_to_cpu(desc->rx.size); skb = ring->tail_skb; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h index 848b866..1a17856 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h @@ -608,9 +608,18 @@ static inline bool hns3_nic_resetting(struct net_device *netdev) #define tx_ring_data(priv, idx) ((priv)->ring_data[idx]) -#define hnae3_buf_size(_ring) ((_ring)->buf_size) -#define hnae3_page_order(_ring) (get_order(hnae3_buf_size(_ring))) -#define hnae3_page_size(_ring) (PAGE_SIZE << (u32)hnae3_page_order(_ring)) +#define hns3_buf_size(_ring) ((_ring)->buf_size) + +static inline unsigned int hns3_page_order(struct hns3_enet_ring *ring) +{ +#if (PAGE_SIZE < 8192) + if (ring->buf_size > (PAGE_SIZE / 2)) + return 1; +#endif + return 0; +} + +#define hns3_page_size(_ring) (PAGE_SIZE << hns3_page_order(_ring)) /* iterator for handling rings in ring group */ #define hns3_for_each_ring(pos, head) \ -- 2.7.4
[PATCH V2 net-next 08/11] net: hns3: make hclge_service use delayed workqueue
From: Yunsheng Lin Use delayed work instead of using timers to trigger the hclge_serive. Simplify the code with one less middle function and in order to support misc irq affinity. Signed-off-by: Yunsheng Lin Reviewed-by: Peng Li Signed-off-by: Huazhong Tan --- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c| 52 +- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h| 3 +- 2 files changed, 21 insertions(+), 34 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index faf60b4..e804a19 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -2515,8 +2515,12 @@ static void hclge_task_schedule(struct hclge_dev *hdev) { if (!test_bit(HCLGE_STATE_DOWN, >state) && !test_bit(HCLGE_STATE_REMOVING, >state) && - !test_and_set_bit(HCLGE_STATE_SERVICE_SCHED, >state)) - (void)schedule_work(>service_task); + !test_and_set_bit(HCLGE_STATE_SERVICE_SCHED, >state)) { + hdev->hw_stats.stats_timer++; + hdev->fd_arfs_expire_timer++; + mod_delayed_work(system_wq, >service_task, +round_jiffies_relative(HZ)); + } } static int hclge_get_mac_link_status(struct hclge_dev *hdev) @@ -2731,25 +2735,6 @@ static int hclge_get_status(struct hnae3_handle *handle) return hdev->hw.mac.link; } -static void hclge_service_timer(struct timer_list *t) -{ - struct hclge_dev *hdev = from_timer(hdev, t, service_timer); - - mod_timer(>service_timer, jiffies + HZ); - hdev->hw_stats.stats_timer++; - hdev->fd_arfs_expire_timer++; - hclge_task_schedule(hdev); -} - -static void hclge_service_complete(struct hclge_dev *hdev) -{ - WARN_ON(!test_bit(HCLGE_STATE_SERVICE_SCHED, >state)); - - /* Flush memory before next watchdog */ - smp_mb__before_atomic(); - clear_bit(HCLGE_STATE_SERVICE_SCHED, >state); -} - static u32 hclge_check_event_cause(struct hclge_dev *hdev, u32 *clearval) { u32 rst_src_reg, cmdq_src_reg, msix_src_reg; @@ -3596,7 +3581,9 @@ static void hclge_update_vport_alive(struct hclge_dev *hdev) static void hclge_service_task(struct work_struct *work) { struct hclge_dev *hdev = - container_of(work, struct hclge_dev, service_task); + container_of(work, struct hclge_dev, service_task.work); + + clear_bit(HCLGE_STATE_SERVICE_SCHED, >state); if (hdev->hw_stats.stats_timer >= HCLGE_STATS_TIMER_INTERVAL) { hclge_update_stats_for_all(hdev); @@ -3611,7 +3598,8 @@ static void hclge_service_task(struct work_struct *work) hclge_rfs_filter_expire(hdev); hdev->fd_arfs_expire_timer = 0; } - hclge_service_complete(hdev); + + hclge_task_schedule(hdev); } struct hclge_vport *hclge_get_vport(struct hnae3_handle *handle) @@ -6150,10 +6138,13 @@ static void hclge_set_timer_task(struct hnae3_handle *handle, bool enable) struct hclge_dev *hdev = vport->back; if (enable) { - mod_timer(>service_timer, jiffies + HZ); + hclge_task_schedule(hdev); } else { - del_timer_sync(>service_timer); - cancel_work_sync(>service_task); + /* Set the DOWN flag here to disable the service to be +* scheduled again +*/ + set_bit(HCLGE_STATE_DOWN, >state); + cancel_delayed_work_sync(>service_task); clear_bit(HCLGE_STATE_SERVICE_SCHED, >state); } } @@ -8592,12 +8583,10 @@ static void hclge_state_uninit(struct hclge_dev *hdev) set_bit(HCLGE_STATE_DOWN, >state); set_bit(HCLGE_STATE_REMOVING, >state); - if (hdev->service_timer.function) - del_timer_sync(>service_timer); if (hdev->reset_timer.function) del_timer_sync(>reset_timer); - if (hdev->service_task.func) - cancel_work_sync(>service_task); + if (hdev->service_task.work.func) + cancel_delayed_work_sync(>service_task); if (hdev->rst_service_task.func) cancel_work_sync(>rst_service_task); if (hdev->mbx_service_task.func) @@ -8802,9 +8791,8 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) hclge_dcb_ops_set(hdev); - timer_setup(>service_timer, hclge_service_timer, 0); timer_setup(>reset_timer, hclge_reset_timer, 0); - INIT_WORK(>service_task, hclge_service_task); + INIT_DELAYED_WORK(>service_task, hclge_service_task); INIT_WORK(>rst_service_task, hclge_reset_service_task); INIT_WORK(>mbx_service_task, hclge_mailbox_service_task); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
[PATCH V2 net-next 06/11] net: hns3: modify firmware version display format
From: Yufeng Mo This patch modifies firmware version display format in hclge(vf)_cmd_init() and hns3_get_drvinfo(). Also, adds some optimizations for firmware version display format. Signed-off-by: Yufeng Mo Signed-off-by: Peng Li Signed-off-by: Huazhong Tan --- drivers/net/ethernet/hisilicon/hns3/hnae3.h | 9 + drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 15 +-- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c | 10 +- drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.c | 10 +- 4 files changed, 40 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h index 48c7b70..a4624db 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h @@ -179,6 +179,15 @@ struct hnae3_vector_info { #define HNAE3_RING_GL_RX 0 #define HNAE3_RING_GL_TX 1 +#define HNAE3_FW_VERSION_BYTE3_SHIFT 24 +#define HNAE3_FW_VERSION_BYTE3_MASKGENMASK(31, 24) +#define HNAE3_FW_VERSION_BYTE2_SHIFT 16 +#define HNAE3_FW_VERSION_BYTE2_MASKGENMASK(23, 16) +#define HNAE3_FW_VERSION_BYTE1_SHIFT 8 +#define HNAE3_FW_VERSION_BYTE1_MASKGENMASK(15, 8) +#define HNAE3_FW_VERSION_BYTE0_SHIFT 0 +#define HNAE3_FW_VERSION_BYTE0_MASKGENMASK(7, 0) + struct hnae3_ring_chain_node { struct hnae3_ring_chain_node *next; u32 tqp_index; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c index 5bff98a..e71c92b 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c @@ -527,6 +527,7 @@ static void hns3_get_drvinfo(struct net_device *netdev, { struct hns3_nic_priv *priv = netdev_priv(netdev); struct hnae3_handle *h = priv->ae_handle; + u32 fw_version; if (!h->ae_algo->ops->get_fw_version) { netdev_err(netdev, "could not get fw version!\n"); @@ -545,8 +546,18 @@ static void hns3_get_drvinfo(struct net_device *netdev, sizeof(drvinfo->bus_info)); drvinfo->bus_info[ETHTOOL_BUSINFO_LEN - 1] = '\0'; - snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), "0x%08x", -priv->ae_handle->ae_algo->ops->get_fw_version(h)); + fw_version = priv->ae_handle->ae_algo->ops->get_fw_version(h); + + snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), +"%lu.%lu.%lu.%lu", +hnae3_get_field(fw_version, HNAE3_FW_VERSION_BYTE3_MASK, +HNAE3_FW_VERSION_BYTE3_SHIFT), +hnae3_get_field(fw_version, HNAE3_FW_VERSION_BYTE2_MASK, +HNAE3_FW_VERSION_BYTE2_SHIFT), +hnae3_get_field(fw_version, HNAE3_FW_VERSION_BYTE1_MASK, +HNAE3_FW_VERSION_BYTE1_SHIFT), +hnae3_get_field(fw_version, HNAE3_FW_VERSION_BYTE0_MASK, +HNAE3_FW_VERSION_BYTE0_SHIFT)); } static u32 hns3_get_link(struct net_device *netdev) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c index 22f6acd..d9858f2 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c @@ -419,7 +419,15 @@ int hclge_cmd_init(struct hclge_dev *hdev) } hdev->fw_version = version; - dev_info(>pdev->dev, "The firmware version is %08x\n", version); + dev_info(>pdev->dev, "The firmware version is %lu.%lu.%lu.%lu\n", +hnae3_get_field(version, HNAE3_FW_VERSION_BYTE3_MASK, +HNAE3_FW_VERSION_BYTE3_SHIFT), +hnae3_get_field(version, HNAE3_FW_VERSION_BYTE2_MASK, +HNAE3_FW_VERSION_BYTE2_SHIFT), +hnae3_get_field(version, HNAE3_FW_VERSION_BYTE1_MASK, +HNAE3_FW_VERSION_BYTE1_SHIFT), +hnae3_get_field(version, HNAE3_FW_VERSION_BYTE0_MASK, +HNAE3_FW_VERSION_BYTE0_SHIFT)); return 0; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.c index 652b796..8f21eb3 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.c @@ -405,7 +405,15 @@ int hclgevf_cmd_init(struct hclgevf_dev *hdev) } hdev->fw_version = version; - dev_info(>pdev->dev, "The firmware version is %08x\n", version); + dev_info(>pdev->dev, "The firmware version is %lu.%lu.%lu.%lu\n", +hnae3_get_field(version, HNAE3_FW_VERSION_BYTE3_MASK, +HNAE3_FW_VERSION_BYTE3_SHIFT), +hnae3_get_field(version,
[PATCH V2 net-next 11/11] net: hns3: use dev_info() instead of pr_info()
dev_info() is more appropriate for printing messages when driver initialization done, so switch to dev_info(). Signed-off-by: Huazhong Tan --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 4 +++- drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 3e43dff..588fb42 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -8864,7 +8864,9 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) hclge_state_init(hdev); hdev->last_reset_time = jiffies; - pr_info("%s driver initialization finished.\n", HCLGE_DRIVER_NAME); + dev_info(>pdev->dev, "%s driver initialization finished.\n", +HCLGE_DRIVER_NAME); + return 0; err_mdiobus_unreg: diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c index db84782..218fd5d 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c @@ -2703,7 +2703,8 @@ static int hclgevf_init_hdev(struct hclgevf_dev *hdev) } hdev->last_reset_time = jiffies; - pr_info("finished initializing %s driver\n", HCLGEVF_DRIVER_NAME); + dev_info(>pdev->dev, "finished initializing %s driver\n", +HCLGEVF_DRIVER_NAME); return 0; -- 2.7.4
Re: [PATCH] cpufreq: schedutil: Don't skip freq update when limits change
On 25-07-19, 08:20, Doug Smythies wrote: > I tried the patch ("patch2"). It did not fix the issue. > > To summarize, all kernel 5.2 based, all intel_cpufreq driver and schedutil > governor: > > Test: Does a busy system respond to maximum CPU clock frequency reduction? > > stock, unaltered: No. > revert ecd2884291261e3fddbc7651ee11a20d596bb514: Yes > viresh patch: No. > fast_switch edit: No. You tried this fast-switch thing with my patch applied, right ? > viresh patch2: No. > > References (and procedures used): > https://marc.info/?l=linux-pm=156346478429147=2 > https://marc.info/?l=linux-kernel=156343125319461=2 > > ... Doug > -- viresh
Re: kernel BUG at mm/swap_state.c:170!
Matthew Wilcox writes: > On Tue, Jul 23, 2019 at 01:08:42PM +0800, Huang, Ying wrote: >> @@ -2489,6 +2491,14 @@ static void __split_huge_page(struct page *page, >> struct list_head *list, >> /* complete memcg works before add pages to LRU */ >> mem_cgroup_split_huge_fixup(head); >> >> +if (PageAnon(head) && PageSwapCache(head)) { >> +swp_entry_t entry = { .val = page_private(head) }; >> + >> +offset = swp_offset(entry); >> +swap_cache = swap_address_space(entry); >> +xa_lock(_cache->i_pages); >> +} >> + >> for (i = HPAGE_PMD_NR - 1; i >= 1; i--) { >> __split_huge_page_tail(head, i, lruvec, list); >> /* Some pages can be beyond i_size: drop them from page cache */ >> @@ -2501,6 +2511,9 @@ static void __split_huge_page(struct page *page, >> struct list_head *list, >> } else if (!PageAnon(page)) { >> __xa_store(>mapping->i_pages, head[i].index, >> head + i, 0); >> +} else if (swap_cache) { >> +__xa_store(_cache->i_pages, offset + i, >> + head + i, 0); > > I tried something along these lines (though I think I messed up the offset > calculation which is why it wasn't working for me). My other concern > was with the case where SWAPFILE_CLUSTER was less than HPAGE_PMD_NR. > Don't we need to drop the lock and look up a new swap_cache if offset >= > SWAPFILE_CLUSTER? In swapfile.c, there is #ifdef CONFIG_THP_SWAP #define SWAPFILE_CLUSTERHPAGE_PMD_NR ... #else #define SWAPFILE_CLUSTER256 ... #endif So, if a THP is in swap cache, then SWAPFILE_CLUSTER equals HPAGE_PMD_NR. And there is one swap address space for each 64M swap space. So one THP will be in one swap address space. In swap.h, there is /* One swap address space for each 64M swap space */ #define SWAP_ADDRESS_SPACE_SHIFT14 #define SWAP_ADDRESS_SPACE_PAGES(1 << SWAP_ADDRESS_SPACE_SHIFT) Best Regards, Huang, Ying
Re: [PATCH] rbtree: sync up the tools/ copy of the code with the main one
On Tue, 2 Jul 2019 20:48:12 -0700 Michel Lespinasse wrote: > I should probably have done this in the same commit that changed the > main rbtree code to avoid generating code twice for the cached rbtree > versions. > > Not copying the reviewers of the previous change as tools/ is just another > copy of it. Copying LKML anyway because the additional noise > won't make as much of a difference there :) That isn't really a changelog. Could we please have a few words describing the change? Was it a simple `cp'?
linux-next: build warning after merge of the tip tree
Hi all, After merging the tip tree, today's linux-next build (x86_64 allmodconfig) produced this warning: drivers/gpu/drm/i915/gem/i915_gem_execbuffer.o: warning: objtool: .altinstr_replacement+0x1c: redundant UACCESS disable Presuambly introduced/uncovered by commit 882a0db9d143 ("objtool: Improve UACCESS coverage") -- Cheers, Stephen Rothwell pgpQkkmosgJGE.pgp Description: OpenPGP digital signature
[GIT PULL] Wimplicit-fallthrough patches for 5.3-rc2
Hi Linus, Kees let me know about the problems you had with my previous pull-request. Apologies for the inconvenience. Here is a new pull-request that includes a fix for those warnings you were seeing with the dcn20_dccg driver. Just for you to know, I'm building allmodconfig. Please, let me know if you have any trouble and I'll address it ASAP. Thanks! -- Gustavo The following changes since commit 5f9e832c137075045d15cd6899ab0505cfb2ca4b: Linus 5.3-rc1 (2019-07-21 14:05:38 -0700) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux.git tags/Wimplicit-fallthrough-5.3-rc2 for you to fetch changes up to a035d552a93bb9ef6048733bb9f2a0dc857ff869: Makefile: Globally enable fall-through warning (2019-07-25 20:13:54 -0500) Wimplicit-fallthrough patches for 5.3-rc2 Hi Linus, Please, pull the following patches that mark switch cases where we are expecting to fall through. These patches are part of the ongoing efforts to enable -Wimplicit-fallthrough. Most of them have been baking in linux-next for a whole development cycle. Also, pull the Makefile patch that globally enables the -Wimplicit-fallthrough option. Finally, some missing-break fixes that have been tagged for -stable: - drm/amdkfd: Fix missing break in switch statement - drm/amdgpu/gfx10: Fix missing break in switch statement Notice that with these changes, we completely get rid of all the fall-through warnings in the kernel. Thanks Signed-off-by: Gustavo A. R. Silva Gustavo A. R. Silva (12): firewire: mark expected switch fall-throughs can: mark expected switch fall-throughs afs: yfsclient: Mark expected switch fall-throughs afs: fsclient: Mark expected switch fall-throughs mtd: onenand_base: Mark expected switch fall-through perf/x86/intel: Mark expected switch fall-throughs drm/amdkfd: Fix missing break in switch statement drm/amdgpu/gfx10: Fix missing break in switch statement drm/amdkfd/kfd_mqd_manager_v10: Avoid fall-through warning drm/amd/display: Mark expected switch fall-throughs drm/i915: Mark expected switch fall-throughs Makefile: Globally enable fall-through warning Documentation/process/deprecated.rst | 14 ++ Makefile | 3 ++ arch/x86/events/intel/core.c | 2 + drivers/firewire/core-device.c| 2 +- drivers/firewire/core-iso.c | 2 +- drivers/firewire/core-topology.c | 1 + drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c| 1 + drivers/gpu/drm/amd/amdkfd/kfd_crat.c | 1 + drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c | 1 - drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dccg.c | 5 +++ drivers/gpu/drm/i915/Makefile | 1 - drivers/gpu/drm/i915/display/intel_display.c | 2 +- drivers/gpu/drm/i915/display/intel_dp.c | 1 + drivers/gpu/drm/i915/gem/i915_gem_mman.c | 2 +- drivers/gpu/drm/i915/gem/i915_gem_pages.c | 2 +- drivers/gpu/drm/i915/i915_gpu_error.c | 1 + drivers/mtd/nand/onenand/onenand_base.c | 1 + drivers/net/can/at91_can.c| 6 ++- drivers/net/can/peak_canfd/peak_pciefd_main.c | 2 +- drivers/net/can/spi/mcp251x.c | 3 +- drivers/net/can/usb/peak_usb/pcan_usb.c | 2 +- fs/afs/fsclient.c | 51 + fs/afs/yfsclient.c| 54 +++ 23 files changed, 111 insertions(+), 49 deletions(-)
Re: [PATCH v7 0/5] Introduce MADV_COLD and MADV_PAGEOUT
Hi Andrew, It's the resend with fixing build errors kbuildbot reported. Please take it this version to get more test coverage. Thanks. On Fri, Jul 26, 2019 at 11:34:30AM +0900, Minchan Kim wrote: > This patch is part of previous series: > https://lore.kernel.org/lkml/20190531064313.193437-1-minc...@kernel.org/ > Originally, it was created for external madvise hinting feature. > > https://lkml.org/lkml/2019/5/31/463 > Michal wanted to separte the discussion from external hinting interface > so this patchset includes only first part of my entire patchset > > - introduce MADV_COLD and MADV_PAGEOUT hint to madvise. > > However, I keep entire description for others for easier understanding > why this kinds of hint was born. > > Thanks. > > This patchset is against on mmotm-mmotm-2019-07-24-21-39. > > Below is description of previous entire patchset. > > = &< = > > - Background > > The Android terminology used for forking a new process and starting an app > from scratch is a cold start, while resuming an existing app is a hot start. > While we continually try to improve the performance of cold starts, hot > starts will always be significantly less power hungry as well as faster so > we are trying to make hot start more likely than cold start. > > To increase hot start, Android userspace manages the order that apps should > be killed in a process called ActivityManagerService. ActivityManagerService > tracks every Android app or service that the user could be interacting with > at any time and translates that into a ranked list for lmkd(low memory > killer daemon). They are likely to be killed by lmkd if the system has to > reclaim memory. In that sense they are similar to entries in any other cache. > Those apps are kept alive for opportunistic performance improvements but > those performance improvements will vary based on the memory requirements of > individual workloads. > > - Problem > > Naturally, cached apps were dominant consumers of memory on the system. > However, they were not significant consumers of swap even though they are > good candidate for swap. Under investigation, swapping out only begins > once the low zone watermark is hit and kswapd wakes up, but the overall > allocation rate in the system might trip lmkd thresholds and cause a cached > process to be killed(we measured performance swapping out vs. zapping the > memory by killing a process. Unsurprisingly, zapping is 10x times faster > even though we use zram which is much faster than real storage) so kill > from lmkd will often satisfy the high zone watermark, resulting in very > few pages actually being moved to swap. > > - Approach > > The approach we chose was to use a new interface to allow userspace to > proactively reclaim entire processes by leveraging platform information. > This allowed us to bypass the inaccuracy of the kernel’s LRUs for pages > that are known to be cold from userspace and to avoid races with lmkd > by reclaiming apps as soon as they entered the cached state. Additionally, > it could provide many chances for platform to use much information to > optimize memory efficiency. > > To achieve the goal, the patchset introduce two new options for madvise. > One is MADV_COLD which will deactivate activated pages and the other is > MADV_PAGEOUT which will reclaim private pages instantly. These new options > complement MADV_DONTNEED and MADV_FREE by adding non-destructive ways to > gain some free memory space. MADV_PAGEOUT is similar to MADV_DONTNEED in a way > that it hints the kernel that memory region is not currently needed and > should be reclaimed immediately; MADV_COLD is similar to MADV_FREE in a way > that it hints the kernel that memory region is not currently needed and > should be reclaimed when memory pressure rises. > > * v6 - http://lore.kernel.org/lkml/20190723062539.198697-1-minc...@kernel.org > * v5 - http://lore.kernel.org/lkml/20190714233401.36909-1-minc...@kernel.org > * v4 - http://lore.kernel.org/lkml/20190711012528.176050-1-minc...@kernel.org > * v3 - http://lore.kernel.org/lkml/20190627115405.255259-1-minc...@kernel.org > * v2 - http://lore.kernel.org/lkml/20190610111252.239156-1-minc...@kernel.org > * v1 - http://lore.kernel.org/lkml/20190603053655.127730-1-minc...@kernel.org > > Minchan Kim (5): > mm: introduce MADV_COLD > mm: change PAGEREF_RECLAIM_CLEAN with PAGE_REFRECLAIM > mm: account nr_isolated_xxx in [isolate|putback]_lru_page > mm: introduce MADV_PAGEOUT > mm: factor out common parts between MADV_COLD and MADV_PAGEOUT > > arch/alpha/include/uapi/asm/mman.h | 3 + > arch/mips/include/uapi/asm/mman.h | 3 + > arch/parisc/include/uapi/asm/mman.h| 3 + > arch/xtensa/include/uapi/asm/mman.h| 3 + > include/linux/swap.h | 2 + > include/uapi/asm-generic/mman-common.h | 3 + > mm/compaction.c| 2 - > mm/gup.c | 7 +- >
Re: memory leak in dma_buf_ioctl
On Thu, 25 Jul 2019 19:34:01 -0700 syzbot wrote: > syzbot has bisected this bug to: > > commit 04cf31a759ef575f750a63777cee95500e410994 > Author: Michael Ellerman > Date: Thu Mar 24 11:04:01 2016 + > > ftrace: Make ftrace_location_range() global It's sad that I have yet to find a single syzbot bisect useful. Really? setting a function from static to global will cause a memory leak in a completely unrelated area of the kernel? I'm about to set these to my /dev/null folder. -- Steve > > bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=154293f460 > start commit: abdfd52a Merge tag 'armsoc-defconfig' of git://git.kernel... > git tree: upstream > final crash:https://syzkaller.appspot.com/x/report.txt?x=174293f460 > console output: https://syzkaller.appspot.com/x/log.txt?x=134293f460 > kernel config: https://syzkaller.appspot.com/x/.config?x=d31de3d88059b7fa > dashboard link: https://syzkaller.appspot.com/bug?extid=b2098bc44728a4efb3e9 > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12526e5860 > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=161784f060 > > Reported-by: syzbot+b2098bc44728a4efb...@syzkaller.appspotmail.com > Fixes: 04cf31a759ef ("ftrace: Make ftrace_location_range() global") > > For information about bisection process see: https://goo.gl/tpsmEJ#bisection
Re: [PATCH 1/2] string: Add stracpy and stracpy_pad mechanisms
On Thu, 2019-07-25 at 13:03 -0700, Kees Cook wrote: > On Wed, Jul 24, 2019 at 10:08:57AM -0700, Linus Torvalds wrote: > > On Wed, Jul 24, 2019 at 6:09 AM Rasmus Villemoes > > wrote: > > > The kernel's snprintf() does not behave in a non-standard way, at least > > > not with respect to its return value. > > > > Note that the kernels snprintf() *does* very much protect against the > > overflow case - not by changing the return value, but simply by having > > > > /* Reject out-of-range values early. Large positive sizes are > >used for unknown buffer sizes. */ > > if (WARN_ON_ONCE(size > INT_MAX)) > > return 0; > > > > at the very top. > > > > So you can't actually overflow in the kernel by using the repeated > > > > offset += vsnprintf( .. size - offset ..); > > > > model. > > > > Yes, it's the wrong thing to do, but it is still _safe_. > > Actually, perhaps we should add this test to strscpy() too? Doesn't seem to have a reason not to be added but maybe it's better to add another WARN_ON_ONCE. > diff --git a/lib/string.c b/lib/string.c [] > @@ -182,7 +182,7 @@ ssize_t strscpy(char *dest, const char *src, size_t count) > size_t max = count; > long res = 0; > > - if (count == 0) > + if (count == 0 || count > INT_MAX) > return -E2BIG; > > #ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS >
Re: [PATCH 1/1] power/supply/powersupply_sysfs: Add of_node name to uevent message if available
Hi David That it would be. I wasn't aware of that call. I'll give it a crack and send in a new version of the patch. Cheers Richard Tresidder Richard Tresidder On 25/07/2019 10:08 pm, David Lechner wrote: On 7/25/19 2:47 AM, Richard Tresidder wrote: If the of_node name of the supply is available from the devicetree binding then include it under the var POWER_SUPPLY_OF_NODE_NAME. This helps where a consistent name is known via the device tree binding but it is hard to identify based on the usual enumeration process. Would it be possible to use of_device_uevent() instead of introducing a new property?
Re: [PATCH 1/1] power/supply/sbs-battery: Fix confusing battery status when idle or empty
Hi Guenter Yep sorry there was a merge that I missed during that initial send of the patch. I sent a version 2 shortly after. Regards Richard Tresidder On 25/07/2019 9:39 pm, Guenter Roeck wrote: On Thu, Jul 25, 2019 at 1:25 AM Richard Tresidder wrote: When a battery or batteries in a system are in parallel then one or more may not be providing any current to the system. This fixes an incorrect status indication of FULL for the battery simply because it wasn't discharging at that point in time. The battery will now be flagged as IDLE. Have also added the additional check for the battery FULL DISCHARGED flag which will now flag a status of EMPTY. Signed-off-by: Richard Tresidder --- Notes: power/supply/sbs-battery: Fix confusing battery status when idle or empty When a battery or batteries in a system are in parallel then one or more may not be providing any current to the system. This fixes an incorrect status indication of FULL for the battery simply because it wasn't discharging at that point in time. The battery will now be flagged as IDLE. Have also added the additional check for the battery FULL DISCHARGED flag which will now flag a status of EMPTY. drivers/power/supply/power_supply_sysfs.c | 3 ++- drivers/power/supply/sbs-battery.c| 28 ++-- include/linux/power_supply.h | 2 ++ 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c index ce6671c..68ec49d 100644 --- a/drivers/power/supply/power_supply_sysfs.c +++ b/drivers/power/supply/power_supply_sysfs.c @@ -51,7 +51,8 @@ }; static const char * const power_supply_status_text[] = { - "Unknown", "Charging", "Discharging", "Not charging", "Full" + "Unknown", "Charging", "Discharging", "Not charging", "Full", + "Empty", "Idle" }; static const char * const power_supply_charge_type_text[] = { diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c index ea8ba3e..e6c636c 100644 --- a/drivers/power/supply/sbs-battery.c +++ b/drivers/power/supply/sbs-battery.c @@ -294,14 +294,10 @@ static int sbs_status_correct(struct i2c_client *client, int *intval) ret = (s16)ret; - /* Not drawing current means full (cannot be not charging) */ - if (ret == 0) - *intval = POWER_SUPPLY_STATUS_FULL; - - if (*intval == POWER_SUPPLY_STATUS_FULL) { - /* Drawing or providing current when full */ - if (ret > 0) - *intval = POWER_SUPPLY_STATUS_CHARGING; + if (*intval == POWER_SUPPLY_STATUS_DISCHARGING) { + /* Charging indicator not set in battery */ + if (ret == 0) + *intval = POWER_SUPPLY_STATUS_IDLE; But doesn't the above already indicate that it _is_ discharging ? else if (ret < 0) *intval = POWER_SUPPLY_STATUS_DISCHARGING; This doesn't make sense. *intval is already set to POWER_SUPPLY_STATUS_DISCHARGING in this situation. } @@ -424,10 +420,12 @@ static int sbs_get_battery_property(struct i2c_client *client, if (ret & BATTERY_FULL_CHARGED) val->intval = POWER_SUPPLY_STATUS_FULL; - else if (ret & BATTERY_DISCHARGING) - val->intval = POWER_SUPPLY_STATUS_DISCHARGING; - else + else if (ret & BATTERY_FULL_DISCHARGED) + val->intval = POWER_SUPPLY_STATUS_EMPTY; + else if (!(ret & BATTERY_DISCHARGING)) val->intval = POWER_SUPPLY_STATUS_CHARGING; + else + val->intval = POWER_SUPPLY_STATUS_DISCHARGING; sbs_status_correct(client, >intval); @@ -781,10 +779,12 @@ static void sbs_delayed_work(struct work_struct *work) if (ret & BATTERY_FULL_CHARGED) ret = POWER_SUPPLY_STATUS_FULL; - else if (ret & BATTERY_DISCHARGING) - ret = POWER_SUPPLY_STATUS_DISCHARGING; - else + else if (ret & BATTERY_FULL_DISCHARGED) + ret = POWER_SUPPLY_STATUS_EMPTY; + else if (!(ret & BATTERY_DISCHARGING)) ret = POWER_SUPPLY_STATUS_CHARGING; + else + ret = POWER_SUPPLY_STATUS_DISCHARGING; sbs_status_correct(chip->client, ); diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index 28413f7..c9f3347 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -37,6 +37,8 @@ enum { POWER_SUPPLY_STATUS_DISCHARGING, POWER_SUPPLY_STATUS_NOT_CHARGING, POWER_SUPPLY_STATUS_FULL, + POWER_SUPPLY_STATUS_EMPTY, + POWER_SUPPLY_STATUS_IDLE, }; /* What algorithm is the charger using? */ -- 1.8.3.1
RE: Re: [PATCH v4] serial/8250: Add support for NI-Serial PXI/PXIe+485 devices
> Subject: [EXTERNAL] Re: [PATCH v4] serial/8250: Add support for NI-Serial > PXI/PXIe+485 devices > > On Fri, Jul 05, 2019 at 06:15:28AM -0700, jeyentam wrote: > > Add support for NI-Serial PXIe-RS232, PXI-RS485 and PXIe-RS485 devices. > > > > Signed-off-by: Je Yen Tam > > --- > > v3 -> v4: > > - Add changes description. > > > > v2 -> v3: > > - Add "full" name for author > > - Use BIT() macro for bits definition > > - Remove unnecessary WARN_ON() > > - Change debugging interface to ftrace > > - Fix indentation > > - Add NI PXIe-RS232 and PXI/PXIe-RS485 device IDs #defines > > > > v1 -> v2: > > - Fix unintended indentation > > > > v1: > > - Add and rename #defines for 16550 UART Port Control Register > > - Add configuration for RS485 port. > > - Add device setup for NI PXI/PXIe-RS485 family. > > - Add PCI board attributes for NI PXIe-RS232 and PXI/PXIe-RS485 devices. > > > > drivers/tty/serial/8250/8250_pci.c | 298 - > > 1 file changed, 294 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/tty/serial/8250/8250_pci.c > > b/drivers/tty/serial/8250/8250_pci.c > > index df41397de478..23fe3b7197ad 100644 > > --- a/drivers/tty/serial/8250/8250_pci.c > > +++ b/drivers/tty/serial/8250/8250_pci.c > > @@ -730,8 +730,16 @@ static int pci_ni8430_init(struct pci_dev *dev) > > } > > > > /* UART Port Control Register */ > > -#define NI8430_PORTCON 0x0f > > -#define NI8430_PORTCON_TXVR_ENABLE (1 << 3) > > +#define NI16550_PCR_OFFSET 0x0f > > +#define NI16550_PCR_RS422 0x00 > > +#define NI16550_PCR_ECHO_RS485 0x01 > > +#define NI16550_PCR_DTR_RS485 0x02 > > +#define NI16550_PCR_AUTO_RS485 0x03 > > +#define NI16550_PCR_WIRE_MODE_MASK 0x03 > > +#define NI16550_PCR_TXVR_ENABLE_BITBIT(3) > > +#define NI16550_PCR_RS485_TERMINATION_BIT BIT(6) > > +#define NI16550_ACR_DTR_AUTO_DTR (0x2 << 3) > > +#define NI16550_ACR_DTR_MANUAL_DTR (0x0 << 3) > > > > static int > > pci_ni8430_setup(struct serial_private *priv, > > @@ -753,14 +761,123 @@ pci_ni8430_setup(struct serial_private *priv, > > return -ENOMEM; > > > > /* enable the transceiver */ > > - writeb(readb(p + offset + NI8430_PORTCON) | > NI8430_PORTCON_TXVR_ENABLE, > > - p + offset + NI8430_PORTCON); > > + writeb(readb(p + offset + NI16550_PCR_OFFSET) | > NI16550_PCR_TXVR_ENABLE_BIT, > > + p + offset + NI16550_PCR_OFFSET); > > > > iounmap(p); > > > > return setup_port(priv, port, bar, offset, board->reg_shift); > > } > > > > +static int pci_ni8431_config_rs485(struct uart_port *port, > > + struct serial_rs485 *rs485) > > +{ > > + u8 pcr, acr; > > + > > + struct uart_8250_port *up; > > No blank lines between variable definitions please. Removed those lines in v5. > > > + > > + up = container_of(port, struct uart_8250_port, port); > > + > > + acr = up->acr; > > + > > + trace_printk("start ni16550_config_rs485\n"); > > This line is not needed, right? Removed in v5. > > > + > > + pcr = port->serial_in(port, NI16550_PCR_OFFSET); > > + pcr &= ~NI16550_PCR_WIRE_MODE_MASK; > > + > > + if (rs485->flags & SER_RS485_ENABLED) { > > + /* RS-485 */ > > + if ((rs485->flags & SER_RS485_RX_DURING_TX) && > > + (rs485->flags & SER_RS485_RTS_ON_SEND)) { > > + dev_dbg(port->dev, "Invalid 2-wire mode\n"); > > + return -EINVAL; > > + } > > + > > + if (rs485->flags & SER_RS485_RX_DURING_TX) { > > + /* Echo */ > > + dev_vdbg(port->dev, "2-wire DTR with echo\n"); > > + pcr |= NI16550_PCR_ECHO_RS485; > > + acr |= NI16550_ACR_DTR_MANUAL_DTR; > > + } else { > > + /* Auto or DTR */ > > + if (rs485->flags & SER_RS485_RTS_ON_SEND) { > > + /* Auto */ > > + dev_vdbg(port->dev, "2-wire Auto\n"); > > + pcr |= NI16550_PCR_AUTO_RS485; > > + acr |= NI16550_ACR_DTR_AUTO_DTR; > > + } else { > > + /* DTR-controlled */ > > + /* No Echo */ > > + dev_vdbg(port->dev, "2-wire DTR no echo\n"); > > + pcr |= NI16550_PCR_DTR_RS485; > > + acr |= NI16550_ACR_DTR_MANUAL_DTR; > > + } > > + } > > + } else { > > + /* RS-422 */ > > + dev_vdbg(port->dev, "4-wire\n"); > > + pcr |= NI16550_PCR_RS422; > > + acr |= NI16550_ACR_DTR_MANUAL_DTR; > > + } > > + > > + dev_dbg(port->dev, "write pcr: 0x%08x\n", pcr); > > + port->serial_out(port, NI16550_PCR_OFFSET, pcr); > > + > > + up->acr = acr; > > + port->serial_out(port, UART_SCR, UART_ACR); > > + port->serial_out(port, UART_ICR, up->acr); > > + > > + /* Update the cache. */ > > + port->rs485 = *rs485; > > +
[PATCH v5] serial/8250: Add support for NI-Serial PXI/PXIe+485 devices
Add support for NI-Serial PXIe-RS232, PXI-RS485 and PXIe-RS485 devices. Signed-off-by: jeyentam --- v4 -> v5 - Remove blank lines between variable definitions. - Remove trace_printk(). v3 -> v4: - Add changes description. v2 -> v3: - Add "full" name for author - Use BIT() macro for bits definition - Remove unnecessary WARN_ON() - Change debugging interface to ftrace - Fix indentation - Add NI PXIe-RS232 and PXI/PXIe-RS485 device IDs #defines v1 -> v2: - Fix unintended indentation v1: - Add and rename #defines for 16550 UART Port Control Register - Add configuration for RS485 port. - Add device setup for NI PXI/PXIe-RS485 family. - Add PCI board attributes for NI PXIe-RS232 and PXI/PXIe-RS485 devices. drivers/tty/serial/8250/8250_pci.c | 292 - 1 file changed, 288 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c index df41397de478..a675069571b2 100644 --- a/drivers/tty/serial/8250/8250_pci.c +++ b/drivers/tty/serial/8250/8250_pci.c @@ -730,8 +730,16 @@ static int pci_ni8430_init(struct pci_dev *dev) } /* UART Port Control Register */ -#define NI8430_PORTCON 0x0f -#define NI8430_PORTCON_TXVR_ENABLE (1 << 3) +#define NI16550_PCR_OFFSET 0x0f +#define NI16550_PCR_RS422 0x00 +#define NI16550_PCR_ECHO_RS485 0x01 +#define NI16550_PCR_DTR_RS485 0x02 +#define NI16550_PCR_AUTO_RS485 0x03 +#define NI16550_PCR_WIRE_MODE_MASK 0x03 +#define NI16550_PCR_TXVR_ENABLE_BITBIT(3) +#define NI16550_PCR_RS485_TERMINATION_BIT BIT(6) +#define NI16550_ACR_DTR_AUTO_DTR (0x2 << 3) +#define NI16550_ACR_DTR_MANUAL_DTR (0x0 << 3) static int pci_ni8430_setup(struct serial_private *priv, @@ -753,14 +761,117 @@ pci_ni8430_setup(struct serial_private *priv, return -ENOMEM; /* enable the transceiver */ - writeb(readb(p + offset + NI8430_PORTCON) | NI8430_PORTCON_TXVR_ENABLE, - p + offset + NI8430_PORTCON); + writeb(readb(p + offset + NI16550_PCR_OFFSET) | NI16550_PCR_TXVR_ENABLE_BIT, + p + offset + NI16550_PCR_OFFSET); iounmap(p); return setup_port(priv, port, bar, offset, board->reg_shift); } +static int pci_ni8431_config_rs485(struct uart_port *port, + struct serial_rs485 *rs485) +{ + u8 pcr, acr; + struct uart_8250_port *up; + + up = container_of(port, struct uart_8250_port, port); + acr = up->acr; + pcr = port->serial_in(port, NI16550_PCR_OFFSET); + pcr &= ~NI16550_PCR_WIRE_MODE_MASK; + + if (rs485->flags & SER_RS485_ENABLED) { + /* RS-485 */ + if ((rs485->flags & SER_RS485_RX_DURING_TX) && + (rs485->flags & SER_RS485_RTS_ON_SEND)) { + dev_dbg(port->dev, "Invalid 2-wire mode\n"); + return -EINVAL; + } + + if (rs485->flags & SER_RS485_RX_DURING_TX) { + /* Echo */ + dev_vdbg(port->dev, "2-wire DTR with echo\n"); + pcr |= NI16550_PCR_ECHO_RS485; + acr |= NI16550_ACR_DTR_MANUAL_DTR; + } else { + /* Auto or DTR */ + if (rs485->flags & SER_RS485_RTS_ON_SEND) { + /* Auto */ + dev_vdbg(port->dev, "2-wire Auto\n"); + pcr |= NI16550_PCR_AUTO_RS485; + acr |= NI16550_ACR_DTR_AUTO_DTR; + } else { + /* DTR-controlled */ + /* No Echo */ + dev_vdbg(port->dev, "2-wire DTR no echo\n"); + pcr |= NI16550_PCR_DTR_RS485; + acr |= NI16550_ACR_DTR_MANUAL_DTR; + } + } + } else { + /* RS-422 */ + dev_vdbg(port->dev, "4-wire\n"); + pcr |= NI16550_PCR_RS422; + acr |= NI16550_ACR_DTR_MANUAL_DTR; + } + + dev_dbg(port->dev, "write pcr: 0x%08x\n", pcr); + port->serial_out(port, NI16550_PCR_OFFSET, pcr); + + up->acr = acr; + port->serial_out(port, UART_SCR, UART_ACR); + port->serial_out(port, UART_ICR, up->acr); + + /* Update the cache. */ + port->rs485 = *rs485; + + return 0; +} + +static int pci_ni8431_setup(struct serial_private *priv, +const struct pciserial_board *board, +struct uart_8250_port *uart, int idx) +{ + u8 pcr, acr; + struct pci_dev *dev = priv->dev; + void __iomem *addr; + unsigned int bar, offset = board->first_offset; + + if (idx >= board->num_ports) + return 1; + + bar = FL_GET_BASE(board->flags); + offset += idx * board->uart_offset; + + addr = pci_ioremap_bar(dev, bar); +
Re: [PATCH] ext4: Fix deadlock on page reclaim
On 2019/07/25 20:54, Christoph Hellwig wrote: > On Thu, Jul 25, 2019 at 06:33:58PM +0900, Damien Le Moal wrote: >> +gfp_t gfp_mask; >> + >> switch (ext4_inode_journal_mode(inode)) { >> case EXT4_INODE_ORDERED_DATA_MODE: >> case EXT4_INODE_WRITEBACK_DATA_MODE: >> @@ -4019,6 +4019,14 @@ void ext4_set_aops(struct inode *inode) >> inode->i_mapping->a_ops = _da_aops; >> else >> inode->i_mapping->a_ops = _aops; >> + >> +/* >> + * Ensure all page cache allocations are done from GFP_NOFS context to >> + * prevent direct reclaim recursion back into the filesystem and blowing >> + * stacks or deadlocking. >> + */ >> +gfp_mask = mapping_gfp_mask(inode->i_mapping); >> +mapping_set_gfp_mask(inode->i_mapping, (gfp_mask & ~(__GFP_FS))); > > This looks like something that could hit every file systems, so > shouldn't we fix this in common code? We could also look into > just using memalloc_nofs_save for the page cache allocation path > instead of the per-mapping gfp_mask. I agree. I did a quick scan and it looks to me like not all file systems are using GFP_NOFS when grabbing pages for read or write. XFS, btrfs, f2fs, jfs, gfs2 and ramfs seem OK, but I did not dig very deep for others where the use of GFP_NOFS is not obvious. I am not sure though how to approach a global fix. At the very least, it may be good to have GFP_NOFS set by default in the inode mapping flags in __address_space_init_once() which is called from inode_init_once(). But I am not sure if that is enough nor if all file systems are using this function. The other method as you suggest would be to add calls to memalloc_nofs_save/restore() in functions like grab_cache_page_write_begin(), but since that would cover writes only, we may want to do that at a higher level in the various generic_xxx() and mpage_xxx() helper functions to cover more ground. But that would still not be enough for the files systems not using these helpers (plenty of examples for that for the write path). Or do we go as high to VFS layer to add memalloc_nofs_save/restore() calls ? That would be a big hammer fix... I personally think this would be OK though, but I may be missing some points here. Thoughts on the best approach ? Best regards. -- Damien Le Moal Western Digital Research
Re: [PATCH v5 09/10] iommu/vt-d: Add trace events for device dma map/unmap
Hi, On 7/25/19 8:26 PM, Steven Rostedt wrote: On Thu, 25 Jul 2019 11:17:16 +0800 Lu Baolu wrote: This adds trace support for the Intel IOMMU driver. It also declares some events which could be used to trace the events when an IOVA is being mapped or unmapped in a domain. Cc: Ashok Raj Cc: Jacob Pan Cc: Kevin Tian Signed-off-by: Mika Westerberg Signed-off-by: Lu Baolu --- drivers/iommu/Makefile | 1 + drivers/iommu/intel-trace.c| 14 + include/trace/events/intel_iommu.h | 95 ++ 3 files changed, 110 insertions(+) create mode 100644 drivers/iommu/intel-trace.c create mode 100644 include/trace/events/intel_iommu.h This patch looks fine, but I don't see the use cases for anything but trace_bounce_map_single() and trace_bounce_unmap_single() used. This only adds trace event/point for this case. We will add more later. Other than that. Reviewed-by: Steven Rostedt (VMware) Thank you! Best regards, Baolu -- Steve diff --git a/drivers/iommu/Makefile b/drivers/iommu/Makefile index f13f36ae1af6..bfe27b2755bd 100644 --- a/drivers/iommu/Makefile +++ b/drivers/iommu/Makefile @@ -17,6 +17,7 @@ obj-$(CONFIG_ARM_SMMU) += arm-smmu.o obj-$(CONFIG_ARM_SMMU_V3) += arm-smmu-v3.o obj-$(CONFIG_DMAR_TABLE) += dmar.o obj-$(CONFIG_INTEL_IOMMU) += intel-iommu.o intel-pasid.o +obj-$(CONFIG_INTEL_IOMMU) += intel-trace.o obj-$(CONFIG_INTEL_IOMMU_DEBUGFS) += intel-iommu-debugfs.o obj-$(CONFIG_INTEL_IOMMU_SVM) += intel-svm.o obj-$(CONFIG_IPMMU_VMSA) += ipmmu-vmsa.o diff --git a/drivers/iommu/intel-trace.c b/drivers/iommu/intel-trace.c new file mode 100644 index ..bfb6a6e37a88 --- /dev/null +++ b/drivers/iommu/intel-trace.c @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Intel IOMMU trace support + * + * Copyright (C) 2019 Intel Corporation + * + * Author: Lu Baolu + */ + +#include +#include + +#define CREATE_TRACE_POINTS +#include diff --git a/include/trace/events/intel_iommu.h b/include/trace/events/intel_iommu.h new file mode 100644 index ..3fdeaad93b2e --- /dev/null +++ b/include/trace/events/intel_iommu.h @@ -0,0 +1,95 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Intel IOMMU trace support + * + * Copyright (C) 2019 Intel Corporation + * + * Author: Lu Baolu + */ +#ifdef CONFIG_INTEL_IOMMU +#undef TRACE_SYSTEM +#define TRACE_SYSTEM intel_iommu + +#if !defined(_TRACE_INTEL_IOMMU_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_INTEL_IOMMU_H + +#include +#include + +DECLARE_EVENT_CLASS(dma_map, + TP_PROTO(struct device *dev, dma_addr_t dev_addr, phys_addr_t phys_addr, +size_t size), + + TP_ARGS(dev, dev_addr, phys_addr, size), + + TP_STRUCT__entry( + __string(dev_name, dev_name(dev)) + __field(dma_addr_t, dev_addr) + __field(phys_addr_t, phys_addr) + __field(size_t, size) + ), + + TP_fast_assign( + __assign_str(dev_name, dev_name(dev)); + __entry->dev_addr = dev_addr; + __entry->phys_addr = phys_addr; + __entry->size = size; + ), + + TP_printk("dev=%s dev_addr=0x%llx phys_addr=0x%llx size=%zu", + __get_str(dev_name), + (unsigned long long)__entry->dev_addr, + (unsigned long long)__entry->phys_addr, + __entry->size) +); + +DEFINE_EVENT(dma_map, bounce_map_single, + TP_PROTO(struct device *dev, dma_addr_t dev_addr, phys_addr_t phys_addr, +size_t size), + TP_ARGS(dev, dev_addr, phys_addr, size) +); + +DEFINE_EVENT(dma_map, bounce_map_sg, + TP_PROTO(struct device *dev, dma_addr_t dev_addr, phys_addr_t phys_addr, +size_t size), + TP_ARGS(dev, dev_addr, phys_addr, size) +); + +DECLARE_EVENT_CLASS(dma_unmap, + TP_PROTO(struct device *dev, dma_addr_t dev_addr, size_t size), + + TP_ARGS(dev, dev_addr, size), + + TP_STRUCT__entry( + __string(dev_name, dev_name(dev)) + __field(dma_addr_t, dev_addr) + __field(size_t, size) + ), + + TP_fast_assign( + __assign_str(dev_name, dev_name(dev)); + __entry->dev_addr = dev_addr; + __entry->size = size; + ), + + TP_printk("dev=%s dev_addr=0x%llx size=%zu", + __get_str(dev_name), + (unsigned long long)__entry->dev_addr, + __entry->size) +); + +DEFINE_EVENT(dma_unmap, bounce_unmap_single, + TP_PROTO(struct device *dev, dma_addr_t dev_addr, size_t size), + TP_ARGS(dev, dev_addr, size) +); + +DEFINE_EVENT(dma_unmap, bounce_unmap_sg, + TP_PROTO(struct device *dev, dma_addr_t dev_addr, size_t size), + TP_ARGS(dev, dev_addr, size) +); + +#endif /* _TRACE_INTEL_IOMMU_H */ + +/* This part must be outside protection */ +#include +#endif /* CONFIG_INTEL_IOMMU */
[PATCH v7 0/5] Introduce MADV_COLD and MADV_PAGEOUT
This patch is part of previous series: https://lore.kernel.org/lkml/20190531064313.193437-1-minc...@kernel.org/ Originally, it was created for external madvise hinting feature. https://lkml.org/lkml/2019/5/31/463 Michal wanted to separte the discussion from external hinting interface so this patchset includes only first part of my entire patchset - introduce MADV_COLD and MADV_PAGEOUT hint to madvise. However, I keep entire description for others for easier understanding why this kinds of hint was born. Thanks. This patchset is against on mmotm-mmotm-2019-07-24-21-39. Below is description of previous entire patchset. = &< = - Background The Android terminology used for forking a new process and starting an app from scratch is a cold start, while resuming an existing app is a hot start. While we continually try to improve the performance of cold starts, hot starts will always be significantly less power hungry as well as faster so we are trying to make hot start more likely than cold start. To increase hot start, Android userspace manages the order that apps should be killed in a process called ActivityManagerService. ActivityManagerService tracks every Android app or service that the user could be interacting with at any time and translates that into a ranked list for lmkd(low memory killer daemon). They are likely to be killed by lmkd if the system has to reclaim memory. In that sense they are similar to entries in any other cache. Those apps are kept alive for opportunistic performance improvements but those performance improvements will vary based on the memory requirements of individual workloads. - Problem Naturally, cached apps were dominant consumers of memory on the system. However, they were not significant consumers of swap even though they are good candidate for swap. Under investigation, swapping out only begins once the low zone watermark is hit and kswapd wakes up, but the overall allocation rate in the system might trip lmkd thresholds and cause a cached process to be killed(we measured performance swapping out vs. zapping the memory by killing a process. Unsurprisingly, zapping is 10x times faster even though we use zram which is much faster than real storage) so kill from lmkd will often satisfy the high zone watermark, resulting in very few pages actually being moved to swap. - Approach The approach we chose was to use a new interface to allow userspace to proactively reclaim entire processes by leveraging platform information. This allowed us to bypass the inaccuracy of the kernel’s LRUs for pages that are known to be cold from userspace and to avoid races with lmkd by reclaiming apps as soon as they entered the cached state. Additionally, it could provide many chances for platform to use much information to optimize memory efficiency. To achieve the goal, the patchset introduce two new options for madvise. One is MADV_COLD which will deactivate activated pages and the other is MADV_PAGEOUT which will reclaim private pages instantly. These new options complement MADV_DONTNEED and MADV_FREE by adding non-destructive ways to gain some free memory space. MADV_PAGEOUT is similar to MADV_DONTNEED in a way that it hints the kernel that memory region is not currently needed and should be reclaimed immediately; MADV_COLD is similar to MADV_FREE in a way that it hints the kernel that memory region is not currently needed and should be reclaimed when memory pressure rises. * v6 - http://lore.kernel.org/lkml/20190723062539.198697-1-minc...@kernel.org * v5 - http://lore.kernel.org/lkml/20190714233401.36909-1-minc...@kernel.org * v4 - http://lore.kernel.org/lkml/20190711012528.176050-1-minc...@kernel.org * v3 - http://lore.kernel.org/lkml/20190627115405.255259-1-minc...@kernel.org * v2 - http://lore.kernel.org/lkml/20190610111252.239156-1-minc...@kernel.org * v1 - http://lore.kernel.org/lkml/20190603053655.127730-1-minc...@kernel.org Minchan Kim (5): mm: introduce MADV_COLD mm: change PAGEREF_RECLAIM_CLEAN with PAGE_REFRECLAIM mm: account nr_isolated_xxx in [isolate|putback]_lru_page mm: introduce MADV_PAGEOUT mm: factor out common parts between MADV_COLD and MADV_PAGEOUT arch/alpha/include/uapi/asm/mman.h | 3 + arch/mips/include/uapi/asm/mman.h | 3 + arch/parisc/include/uapi/asm/mman.h| 3 + arch/xtensa/include/uapi/asm/mman.h| 3 + include/linux/swap.h | 2 + include/uapi/asm-generic/mman-common.h | 3 + mm/compaction.c| 2 - mm/gup.c | 7 +- mm/internal.h | 2 +- mm/khugepaged.c| 3 - mm/madvise.c | 274 - mm/memory-failure.c| 3 - mm/memory_hotplug.c| 4 - mm/mempolicy.c | 3 - mm/migrate.c | 37 +--- mm/oom_kill.c
[PATCH v7 5/5] mm: factor out common parts between MADV_COLD and MADV_PAGEOUT
There are many common parts between MADV_COLD and MADV_PAGEOUT. This patch factor them out to save code duplication. Suggested-by: Johannes Weiner Acked-by: Michal Hocko Signed-off-by: Minchan Kim --- mm/madvise.c | 194 --- 1 file changed, 46 insertions(+), 148 deletions(-) diff --git a/mm/madvise.c b/mm/madvise.c index 78aa6802b95ad..52f9bddbab19c 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -30,6 +30,11 @@ #include "internal.h" +struct madvise_walk_private { + struct mmu_gather *tlb; + bool pageout; +}; + /* * Any behaviour which results in changes to the vma->vm_flags needs to * take mmap_sem for writing. Others, which simply traverse vmas, need @@ -310,15 +315,22 @@ static long madvise_willneed(struct vm_area_struct *vma, return 0; } -static int madvise_cold_pte_range(pmd_t *pmd, unsigned long addr, - unsigned long end, struct mm_walk *walk) +static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, + unsigned long addr, unsigned long end, + struct mm_walk *walk) { - struct mmu_gather *tlb = walk->private; + struct madvise_walk_private *private = walk->private; + struct mmu_gather *tlb = private->tlb; + bool pageout = private->pageout; struct mm_struct *mm = tlb->mm; struct vm_area_struct *vma = walk->vma; pte_t *orig_pte, *pte, ptent; spinlock_t *ptl; - struct page *page; + struct page *page = NULL; + LIST_HEAD(page_list); + + if (fatal_signal_pending(current)) + return -EINTR; #ifdef CONFIG_TRANSPARENT_HUGEPAGE if (pmd_trans_huge(*pmd)) { @@ -366,10 +378,17 @@ static int madvise_cold_pte_range(pmd_t *pmd, unsigned long addr, tlb_remove_pmd_tlb_entry(tlb, pmd, addr); } + ClearPageReferenced(page); test_and_clear_page_young(page); - deactivate_page(page); + if (pageout) { + if (!isolate_lru_page(page)) + list_add(>lru, _list); + } else + deactivate_page(page); huge_unlock: spin_unlock(ptl); + if (pageout) + reclaim_pages(_list); return 0; } @@ -437,12 +456,19 @@ static int madvise_cold_pte_range(pmd_t *pmd, unsigned long addr, * As a side effect, it makes confuse idle-page tracking * because they will miss recent referenced history. */ + ClearPageReferenced(page); test_and_clear_page_young(page); - deactivate_page(page); + if (pageout) { + if (!isolate_lru_page(page)) + list_add(>lru, _list); + } else + deactivate_page(page); } arch_leave_lazy_mmu_mode(); pte_unmap_unlock(orig_pte, ptl); + if (pageout) + reclaim_pages(_list); cond_resched(); return 0; @@ -452,10 +478,15 @@ static void madvise_cold_page_range(struct mmu_gather *tlb, struct vm_area_struct *vma, unsigned long addr, unsigned long end) { + struct madvise_walk_private walk_private = { + .tlb = tlb, + .pageout = false, + }; + struct mm_walk cold_walk = { - .pmd_entry = madvise_cold_pte_range, + .pmd_entry = madvise_cold_or_pageout_pte_range, .mm = vma->vm_mm, - .private = tlb, + .private = _private, }; tlb_start_vma(tlb, vma); @@ -482,152 +513,19 @@ static long madvise_cold(struct vm_area_struct *vma, return 0; } -static int madvise_pageout_pte_range(pmd_t *pmd, unsigned long addr, - unsigned long end, struct mm_walk *walk) -{ - struct mmu_gather *tlb = walk->private; - struct mm_struct *mm = tlb->mm; - struct vm_area_struct *vma = walk->vma; - pte_t *orig_pte, *pte, ptent; - spinlock_t *ptl; - LIST_HEAD(page_list); - struct page *page; - - if (fatal_signal_pending(current)) - return -EINTR; - -#ifdef CONFIG_TRANSPARENT_HUGEPAGE - if (pmd_trans_huge(*pmd)) { - pmd_t orig_pmd; - unsigned long next = pmd_addr_end(addr, end); - - tlb_change_page_size(tlb, HPAGE_PMD_SIZE); - ptl = pmd_trans_huge_lock(pmd, vma); - if (!ptl) - return 0; - - orig_pmd = *pmd; - if (is_huge_zero_pmd(orig_pmd)) - goto huge_unlock; - - if (unlikely(!pmd_present(orig_pmd))) { -
[PATCH 2/2] net: ipv4: Fix a possible null-pointer dereference in fib4_rule_suppress()
In fib4_rule_suppress(), there is an if statement on line 145 to check whether result->fi is NULL: if (result->fi) When result->fi is NULL, it is used on line 167: fib_info_put(result->fi); In fib_info_put(), the argument fi is used: if (refcount_dec_and_test(>fib_clntref)) Thus, a possible null-pointer dereference may occur. To fix this bug, result->fi is checked before calling fib_info_put(). This bug is found by a static analysis tool STCheck written by us. Signed-off-by: Jia-Ju Bai --- net/ipv4/fib_rules.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c index b43a7ba5c6a4..daedce293aab 100644 --- a/net/ipv4/fib_rules.c +++ b/net/ipv4/fib_rules.c @@ -163,7 +163,7 @@ static bool fib4_rule_suppress(struct fib_rule *rule, struct fib_lookup_arg *arg return false; suppress_route: - if (!(arg->flags & FIB_LOOKUP_NOREF)) + if (!(arg->flags & FIB_LOOKUP_NOREF) && result->fi) fib_info_put(result->fi); return true; } -- 2.17.0
[PATCH v7 2/5] mm: change PAGEREF_RECLAIM_CLEAN with PAGE_REFRECLAIM
The local variable references in shrink_page_list is PAGEREF_RECLAIM_CLEAN as default. It is for preventing to reclaim dirty pages when CMA try to migrate pages. Strictly speaking, we don't need it because CMA didn't allow to write out by .may_writepage = 0 in reclaim_clean_pages_from_list. Moreover, it has a problem to prevent anonymous pages's swap out even though force_reclaim = true in shrink_page_list on upcoming patch. So this patch makes references's default value to PAGEREF_RECLAIM and rename force_reclaim with ignore_references to make it more clear. This is a preparatory work for next patch. * RFCv1 * use ignore_referecnes as parameter name - hannes Acked-by: Michal Hocko Acked-by: Johannes Weiner Signed-off-by: Minchan Kim --- mm/vmscan.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 82e1e229eef21..436577236dd3e 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1124,7 +1124,7 @@ static unsigned long shrink_page_list(struct list_head *page_list, struct scan_control *sc, enum ttu_flags ttu_flags, struct reclaim_stat *stat, - bool force_reclaim) + bool ignore_references) { LIST_HEAD(ret_pages); LIST_HEAD(free_pages); @@ -1138,7 +1138,7 @@ static unsigned long shrink_page_list(struct list_head *page_list, struct address_space *mapping; struct page *page; int may_enter_fs; - enum page_references references = PAGEREF_RECLAIM_CLEAN; + enum page_references references = PAGEREF_RECLAIM; bool dirty, writeback; unsigned int nr_pages; @@ -1269,7 +1269,7 @@ static unsigned long shrink_page_list(struct list_head *page_list, } } - if (!force_reclaim) + if (!ignore_references) references = page_check_references(page, sc); switch (references) { -- 2.22.0.709.g102302147b-goog
[PATCH v7 4/5] mm: introduce MADV_PAGEOUT
When a process expects no accesses to a certain memory range for a long time, it could hint kernel that the pages can be reclaimed instantly but data should be preserved for future use. This could reduce workingset eviction so it ends up increasing performance. This patch introduces the new MADV_PAGEOUT hint to madvise(2) syscall. MADV_PAGEOUT can be used by a process to mark a memory range as not expected to be used for a long time so that kernel reclaims *any LRU* pages instantly. The hint can help kernel in deciding which pages to evict proactively. A note: It doesn't apply SWAP_CLUSTER_MAX LRU page isolation limit intentionally because it's automatically bounded by PMD size. If PMD size(e.g., 256) makes some trouble, we could fix it later by limit it to SWAP_CLUSTER_MAX[1]. - man-page material MADV_PAGEOUT (since Linux x.x) Do not expect access in the near future so pages in the specified regions could be reclaimed instantly regardless of memory pressure. Thus, access in the range after successful operation could cause major page fault but never lose the up-to-date contents unlike MADV_DONTNEED. Pages belonging to a shared mapping are only processed if a write access is allowed for the calling process. MADV_PAGEOUT cannot be applied to locked pages, Huge TLB pages, or VM_PFNMAP pages. * v6 * Fix build error kbuildbot reported * https://lore.kernel.org/linux-mm/201907251759.zsy10dlw%25...@intel.com/ * v4 * clear young bit regardless of success of page isolation - hannes * v3 * man page material modification - mhocko * remove using SWAP_CLUSTER_MAX - mhocko * v2 * add comment about SWAP_CLUSTER_MAX - mhocko * add permission check to prevent sidechannel attack - mhocko * add man page stuff - dave * v1 * change pte to old and rely on the other's reference - hannes * remove page_mapcount to check shared page - mhocko * RFC v2 * make reclaim_pages simple via factoring out isolate logic - hannes * RFCv1 * rename from MADV_COLD to MADV_PAGEOUT - hannes * bail out if process is being killed - Hillf * fix reclaim_pages bugs - Hillf [1] https://lore.kernel.org/lkml/20190710194719.gs29...@dhcp22.suse.cz/ Cc: linux-a...@vger.kernel.org Cc: James E.J. Bottomley Cc: Richard Henderson Cc: Ralf Baechle Cc: Chris Zankel Reported-by: kbuild test robot Acked-by: Michal Hocko Signed-off-by: Minchan Kim --- arch/alpha/include/uapi/asm/mman.h | 1 + arch/mips/include/uapi/asm/mman.h | 1 + arch/parisc/include/uapi/asm/mman.h| 1 + arch/xtensa/include/uapi/asm/mman.h| 1 + include/linux/swap.h | 1 + include/uapi/asm-generic/mman-common.h | 1 + mm/madvise.c | 195 + mm/vmscan.c| 55 +++ 8 files changed, 256 insertions(+) diff --git a/arch/alpha/include/uapi/asm/mman.h b/arch/alpha/include/uapi/asm/mman.h index f3258fbf03d03..a18ec7f638880 100644 --- a/arch/alpha/include/uapi/asm/mman.h +++ b/arch/alpha/include/uapi/asm/mman.h @@ -69,6 +69,7 @@ #define MADV_KEEPONFORK 19 /* Undo MADV_WIPEONFORK */ #define MADV_COLD 20 /* deactivate these pages */ +#define MADV_PAGEOUT 21 /* reclaim these pages */ /* compatibility flags */ #define MAP_FILE 0 diff --git a/arch/mips/include/uapi/asm/mman.h b/arch/mips/include/uapi/asm/mman.h index 00ad09fc5eb16..57dc2ac4f8bda 100644 --- a/arch/mips/include/uapi/asm/mman.h +++ b/arch/mips/include/uapi/asm/mman.h @@ -96,6 +96,7 @@ #define MADV_KEEPONFORK 19 /* Undo MADV_WIPEONFORK */ #define MADV_COLD 20 /* deactivate these pages */ +#define MADV_PAGEOUT 21 /* reclaim these pages */ /* compatibility flags */ #define MAP_FILE 0 diff --git a/arch/parisc/include/uapi/asm/mman.h b/arch/parisc/include/uapi/asm/mman.h index eb14e3a7b8f37..6fd8871e4081e 100644 --- a/arch/parisc/include/uapi/asm/mman.h +++ b/arch/parisc/include/uapi/asm/mman.h @@ -49,6 +49,7 @@ #define MADV_DOFORK11 /* do inherit across fork */ #define MADV_COLD 20 /* deactivate these pages */ +#define MADV_PAGEOUT 21 /* reclaim these pages */ #define MADV_MERGEABLE 65/* KSM may merge identical pages */ #define MADV_UNMERGEABLE 66/* KSM may not merge identical pages */ diff --git a/arch/xtensa/include/uapi/asm/mman.h b/arch/xtensa/include/uapi/asm/mman.h index f926b00ff11f9..e5e6437529475 100644 --- a/arch/xtensa/include/uapi/asm/mman.h +++ b/arch/xtensa/include/uapi/asm/mman.h @@ -104,6 +104,7 @@ #define MADV_KEEPONFORK 19 /* Undo MADV_WIPEONFORK */ #define MADV_COLD 20 /* deactivate these pages */ +#define MADV_PAGEOUT 21 /* reclaim these pages */ /* compatibility flags */ #define MAP_FILE 0 diff --git a/include/linux/swap.h b/include/linux/swap.h index 0ce997edb8bbc..063c0c1e112bd 100644 ---
[PATCH v7 3/5] mm: account nr_isolated_xxx in [isolate|putback]_lru_page
The isolate counting is pecpu counter so it would be not huge gain to work them by batch. Rather than complicating to make them batch, let's make it more stright-foward via adding the counting logic into [isolate|putback]_lru_page API. * v1 * fix accounting bug - Hillf Link: http://lkml.kernel.org/r/20190531165927.ga20...@cmpxchg.org Suggested-by: Johannes Weiner Acked-by: Johannes Weiner Acked-by: Michal Hocko Signed-off-by: Minchan Kim --- mm/compaction.c | 2 -- mm/gup.c| 7 +-- mm/khugepaged.c | 3 --- mm/memory-failure.c | 3 --- mm/memory_hotplug.c | 4 mm/mempolicy.c | 3 --- mm/migrate.c| 37 - mm/vmscan.c | 22 -- 8 files changed, 25 insertions(+), 56 deletions(-) diff --git a/mm/compaction.c b/mm/compaction.c index d99d59412c755..ac4ead029b4a1 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -984,8 +984,6 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, /* Successfully isolated */ del_page_from_lru_list(page, lruvec, page_lru(page)); - inc_node_page_state(page, - NR_ISOLATED_ANON + page_is_file_cache(page)); isolate_success: list_add(>lru, >migratepages); diff --git a/mm/gup.c b/mm/gup.c index 012060efddf18..357cfc1ca37d1 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -1460,13 +1460,8 @@ static long check_and_migrate_cma_pages(struct task_struct *tsk, drain_allow = false; } - if (!isolate_lru_page(head)) { + if (!isolate_lru_page(head)) list_add_tail(>lru, _page_list); - mod_node_page_state(page_pgdat(head), - NR_ISOLATED_ANON + - page_is_file_cache(head), - hpage_nr_pages(head)); - } } } diff --git a/mm/khugepaged.c b/mm/khugepaged.c index eaaa21b232156..a8b517d6df4ab 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -503,7 +503,6 @@ void __khugepaged_exit(struct mm_struct *mm) static void release_pte_page(struct page *page) { - dec_node_page_state(page, NR_ISOLATED_ANON + page_is_file_cache(page)); unlock_page(page); putback_lru_page(page); } @@ -602,8 +601,6 @@ static int __collapse_huge_page_isolate(struct vm_area_struct *vma, result = SCAN_DEL_PAGE_LRU; goto out; } - inc_node_page_state(page, - NR_ISOLATED_ANON + page_is_file_cache(page)); VM_BUG_ON_PAGE(!PageLocked(page), page); VM_BUG_ON_PAGE(PageLRU(page), page); diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 7ef849da8278c..9900bb95d7740 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1791,9 +1791,6 @@ static int __soft_offline_page(struct page *page, int flags) * so use !__PageMovable instead for LRU page's mapping * cannot have PAGE_MAPPING_MOVABLE. */ - if (!__PageMovable(page)) - inc_node_page_state(page, NR_ISOLATED_ANON + - page_is_file_cache(page)); list_add(>lru, ); ret = migrate_pages(, new_page, NULL, MPOL_MF_MOVE_ALL, MIGRATE_SYNC, MR_MEMORY_FAILURE); diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 5b8811945bbba..9a82e12bd0e73 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1373,10 +1373,6 @@ do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) ret = isolate_movable_page(page, ISOLATE_UNEVICTABLE); if (!ret) { /* Success */ list_add_tail(>lru, ); - if (!__PageMovable(page)) - inc_node_page_state(page, NR_ISOLATED_ANON + - page_is_file_cache(page)); - } else { pr_warn("failed to isolate pfn %lx\n", pfn); dump_page(page, "isolation failed"); diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 547cd403ed020..e8bbec6148dfe 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -977,9 +977,6 @@ static int migrate_page_add(struct page *page, struct list_head *pagelist, if ((flags & MPOL_MF_MOVE_ALL) || page_mapcount(head) == 1) { if (!isolate_lru_page(head)) { list_add_tail(>lru, pagelist); -
[PATCH v7 1/5] mm: introduce MADV_COLD
When a process expects no accesses to a certain memory range, it could give a hint to kernel that the pages can be reclaimed when memory pressure happens but data should be preserved for future use. This could reduce workingset eviction so it ends up increasing performance. This patch introduces the new MADV_COLD hint to madvise(2) syscall. MADV_COLD can be used by a process to mark a memory range as not expected to be used in the near future. The hint can help kernel in deciding which pages to evict early during memory pressure. It works for every LRU pages like MADV_[DONTNEED|FREE]. IOW, It moves active file page -> inactive file LRU active anon page -> inacdtive anon LRU Unlike MADV_FREE, it doesn't move active anonymous pages to inactive file LRU's head because MADV_COLD is a little bit different symantic. MADV_FREE means it's okay to discard when the memory pressure because the content of the page is *garbage* so freeing such pages is almost zero overhead since we don't need to swap out and access afterward causes just minor fault. Thus, it would make sense to put those freeable pages in inactive file LRU to compete other used-once pages. It makes sense for implmentaion point of view, too because it's not swapbacked memory any longer until it would be re-dirtied. Even, it could give a bonus to make them be reclaimed on swapless system. However, MADV_COLD doesn't mean garbage so reclaiming them requires swap-out/in in the end so it's bigger cost. Since we have designed VM LRU aging based on cost-model, anonymous cold pages would be better to position inactive anon's LRU list, not file LRU. Furthermore, it would help to avoid unnecessary scanning if system doesn't have a swap device. Let's start simpler way without adding complexity at this moment. However, keep in mind, too that it's a caveat that workloads with a lot of pages cache are likely to ignore MADV_COLD on anonymous memory because we rarely age anonymous LRU lists. * man-page material MADV_COLD (since Linux x.x) Pages in the specified regions will be treated as less-recently-accessed compared to pages in the system with similar access frequencies. In contrast to MADV_FREE, the contents of the region are preserved regardless of subsequent writes to pages. MADV_COLD cannot be applied to locked pages, Huge TLB pages, or VM_PFNMAP pages. * v6 * Fix build error kbuildbot reported * https://lore.kernel.org/linux-mm/201907251647.fhj6xzda%25...@intel.com/ * https://lore.kernel.org/linux-mm/201907251529.ktj2fpcl%25...@intel.com/ * v5 * Fix typo and correct wrong lazy_mmu_mode pair use - surenb * v2 * add up the warn with lots of page cache workload - mhocko * add man page stuff - dave * v1 * remove page_mapcount filter - hannes, mhocko * remove idle page handling - joelaf * RFCv2 * add more description - mhocko * RFCv1 * renaming from MADV_COOL to MADV_COLD - hannes * internal review * use clear_page_youn in deactivate_page - joelaf * Revise the description - surenb * Renaming from MADV_WARM to MADV_COOL - surenb Cc: linux-a...@vger.kernel.org Cc: James E.J. Bottomley Cc: Richard Henderson Cc: Ralf Baechle Cc: Chris Zankel Reported-by: kbuild test robot Acked-by: Michal Hocko Acked-by: Johannes Weiner Signed-off-by: Minchan Kim --- arch/alpha/include/uapi/asm/mman.h | 2 + arch/mips/include/uapi/asm/mman.h | 2 + arch/parisc/include/uapi/asm/mman.h| 2 + arch/xtensa/include/uapi/asm/mman.h| 2 + include/linux/swap.h | 1 + include/uapi/asm-generic/mman-common.h | 2 + mm/internal.h | 2 +- mm/madvise.c | 181 - mm/oom_kill.c | 2 +- mm/swap.c | 42 ++ 10 files changed, 234 insertions(+), 4 deletions(-) diff --git a/arch/alpha/include/uapi/asm/mman.h b/arch/alpha/include/uapi/asm/mman.h index ac23379b7a876..f3258fbf03d03 100644 --- a/arch/alpha/include/uapi/asm/mman.h +++ b/arch/alpha/include/uapi/asm/mman.h @@ -68,6 +68,8 @@ #define MADV_WIPEONFORK 18 /* Zero memory on fork, child only */ #define MADV_KEEPONFORK 19 /* Undo MADV_WIPEONFORK */ +#define MADV_COLD 20 /* deactivate these pages */ + /* compatibility flags */ #define MAP_FILE 0 diff --git a/arch/mips/include/uapi/asm/mman.h b/arch/mips/include/uapi/asm/mman.h index c2b40969eb1fa..00ad09fc5eb16 100644 --- a/arch/mips/include/uapi/asm/mman.h +++ b/arch/mips/include/uapi/asm/mman.h @@ -95,6 +95,8 @@ #define MADV_WIPEONFORK 18 /* Zero memory on fork, child only */ #define MADV_KEEPONFORK 19 /* Undo MADV_WIPEONFORK */ +#define MADV_COLD 20 /* deactivate these pages */ + /* compatibility flags */ #define MAP_FILE 0 diff --git a/arch/parisc/include/uapi/asm/mman.h b/arch/parisc/include/uapi/asm/mman.h index c98162f494dbb..eb14e3a7b8f37 100644
Re: [PATCH net-next 07/11] net: hns3: adds debug messages to identify eth down cause
As Saeed said, we will use netif_msg_drv() which is default off, this can be easily open with ethtool. Thanks for your reply! On 2019/7/26 9:28, Jakub Kicinski wrote: > On Thu, 25 Jul 2019 21:59:08 +, Saeed Mahameed wrote: >> I couldn't find any rules regarding what to put in kernel log, Maybe >> someone can share ?. but i vaguely remember that the recommendation >> for device drivers is to put nothing, only error/warning messages. > > FWIW my understanding is also that only error/warning messages should > be printed. IOW things which should "never happen". > > There are some historical exceptions. Probe logs for instance may be > useful, because its not trivial to get to the device if probe fails. > > Another one is ethtool flashing, if it takes time we used to print into > logs some message like "please wait patiently". But since Jiri added > the progress messages in devlink that's no longer necessary. > > For the messages which are basically printing the name of the function > or name of the function and their args - we have ftrace. > > That's my $0.02 :) > > . >
[PATCH v2] counter/ftm-quaddec: Use device-managed registration API
Make use of devm_counter_register. Then we can remove redundant unregistration API usage to make code simpler. Signed-off-by: Chuhong Yuan --- Changes in v2: - Use devm_add_action_or_reset to keep resource release order. - _remove() function is redundant now, delete it. drivers/counter/ftm-quaddec.c | 31 +++ 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/drivers/counter/ftm-quaddec.c b/drivers/counter/ftm-quaddec.c index 68a9b7393457..76c70a6c3593 100644 --- a/drivers/counter/ftm-quaddec.c +++ b/drivers/counter/ftm-quaddec.c @@ -100,16 +100,17 @@ static void ftm_quaddec_init(struct ftm_quaddec *ftm) ftm_set_write_protection(ftm); } -static void ftm_quaddec_disable(struct ftm_quaddec *ftm) +static void ftm_quaddec_disable(void *ftm) { - ftm_clear_write_protection(ftm); - ftm_write(ftm, FTM_MODE, 0); - ftm_write(ftm, FTM_QDCTRL, 0); + struct ftm_quaddec *ftm_qua = ftm; + ftm_clear_write_protection(ftm_qua); + ftm_write(ftm_qua, FTM_MODE, 0); + ftm_write(ftm_qua, FTM_QDCTRL, 0); /* * This is enough to disable the counter. No clock has been * selected by writing to FTM_SC in init() */ - ftm_set_write_protection(ftm); + ftm_set_write_protection(ftm_qua); } static int ftm_quaddec_get_prescaler(struct counter_device *counter, @@ -316,22 +317,13 @@ static int ftm_quaddec_probe(struct platform_device *pdev) mutex_init(>ftm_quaddec_mutex); ftm_quaddec_init(ftm); - - ret = counter_register(>counter); + ret = devm_add_action_or_reset(>dev, ftm_quaddec_disable, ftm); if (ret) - ftm_quaddec_disable(ftm); - - return ret; -} - -static int ftm_quaddec_remove(struct platform_device *pdev) -{ - struct ftm_quaddec *ftm = platform_get_drvdata(pdev); - - counter_unregister(>counter); - - ftm_quaddec_disable(ftm); + return ret; + ret = devm_counter_register(>dev, >counter); + if (ret) + return ret; return 0; } @@ -346,7 +338,6 @@ static struct platform_driver ftm_quaddec_driver = { .of_match_table = ftm_quaddec_match, }, .probe = ftm_quaddec_probe, - .remove = ftm_quaddec_remove, }; module_platform_driver(ftm_quaddec_driver); -- 2.20.1
[PATCH 1/2] net: ipv4: Fix a possible null-pointer dereference in inet_csk_rebuild_route()
In inet_csk_rebuild_route(), rt is assigned to NULL on line 1071. On line 1076, rt is used: return >dst; Thus, a possible null-pointer dereference may occur. To fix this bug, rt is checked before being used. This bug is found by a static analysis tool STCheck written by us. Signed-off-by: Jia-Ju Bai --- net/ipv4/inet_connection_sock.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c index f5c163d4771b..27d9d80f3401 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c @@ -1073,7 +1073,10 @@ static struct dst_entry *inet_csk_rebuild_route(struct sock *sk, struct flowi *f sk_setup_caps(sk, >dst); rcu_read_unlock(); - return >dst; + if (rt) + return >dst; + else + return NULL; } struct dst_entry *inet_csk_update_pmtu(struct sock *sk, u32 mtu) -- 2.17.0
Re: [PATCH net-next 07/11] net: hns3: adds debug messages to identify eth down cause
We will change all of them to netif_msg_drv() which is default off Thanks for your reply! On 2019/7/26 5:59, Saeed Mahameed wrote: > On Thu, 2019-07-25 at 20:28 +0800, liuyonglong wrote: >> >> On 2019/7/25 3:12, Saeed Mahameed wrote: >>> On Wed, 2019-07-24 at 11:18 +0800, Huazhong Tan wrote: From: Yonglong Liu Some times just see the eth interface have been down/up via dmesg, but can not know why the eth down. So adds some debug messages to identify the cause for this. >>> >>> I really don't like this. your default msg lvl has NETIF_MSG_IFDOWN >>> turned on .. dumping every single operation that happens on your >>> device >>> by default to kernel log is too much ! >>> >>> We should really consider using trace buffers with well defined >>> structures for vendor specific events. so we can use bpf filters >>> and >>> state of the art tools for netdev debugging. >>> >> >> We do this because we can just see a link down message in dmesg, and >> had >> take a long time to found the cause of link down, just because >> another >> user changed the settings. >> >> We can change the net_open/net_stop/dcbnl_ops to msg_drv (not default >> turned on), and want to keep the others default print to kernel log, >> is it acceptable? >> > > acceptable as long as debug information are kept off by default and > your driver doens't spam the kernel log. > > you should use dynamic debug [1] and/or "off by default" msg lvls for > debugging information.. > > I couldn't find any rules regarding what to put in kernel log, Maybe > someone can share ?. but i vaguely remember that the recommendation > for device drivers is to put nothing, only error/warning messages. > > [1] > https://www.kernel.org/doc/html/v4.15/admin-guide/dynamic-debug-howto.html > @@ -1593,6 +1603,11 @@ static int hns3_ndo_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, struct hnae3_handle *h = hns3_get_handle(netdev); int ret = -EIO; + if (netif_msg_ifdown(h)) >>> >>> why msg_ifdown ? looks like netif_msg_drv is more appropriate, for >>> many >>> of the cases in this patch. >>> >> >> This operation may cause link down, so we use msg_ifdown. >> > > ifdown isn't link down.. > > to be honest, I couldn't find any documentation explaining how/when to > use msg lvls, (i didn't look too deep though), by looking at other > drivers, my interpretations is: > > ifdup (open/boot up flow) > ifdwon (close/teardown flow) > drv (driver based or dynamic flows) > etc .. > > -Saeed. >
[PATCH v15 2/2] dt-bindings: spi: Document Renesas R-Car Gen3 RPC-IF controller bindings
Dcument the bindings used by the Renesas R-Car Gen3 RPC-IF controller. Signed-off-by: Mason Yang Reviewed-by: Rob Herring --- .../devicetree/bindings/spi/spi-renesas-rpc.txt| 46 ++ 1 file changed, 46 insertions(+) create mode 100644 Documentation/devicetree/bindings/spi/spi-renesas-rpc.txt diff --git a/Documentation/devicetree/bindings/spi/spi-renesas-rpc.txt b/Documentation/devicetree/bindings/spi/spi-renesas-rpc.txt new file mode 100644 index 000..d929850 --- /dev/null +++ b/Documentation/devicetree/bindings/spi/spi-renesas-rpc.txt @@ -0,0 +1,46 @@ +Renesas R-Car Gen3 RPC-IF controller Device Tree Bindings +- + +Required properties: +- compatible: should be an SoC-specific compatible value, followed by + "renesas,rcar-gen3-rpc" as a fallback. + supported SoC-specific values are: + "renesas,r8a77980-rpc" (R-Car V3H) + "renesas,r8a77995-rpc" (R-Car D3) +- reg: should contain three register areas: + first for the base address of RPC-IF registers, + second for the direct mapping read mode and + third for the write buffer area. +- reg-names: should contain "regs", "dirmap" and "wbuf" +- clocks: should contain the clock phandle/specifier pair for the module clock. +- clock-names: should contain "rpc" +- power-domains: should contain the power domain phandle/secifier pair. +- resets: should contain the reset controller phandle/specifier pair. +- #address-cells: should be 1 +- #size-cells: should be 0 +- flash: should be represented by a subnode of the RPC-IF node, +which "compatible" property contains "jedec,spi-nor", it presents +SPI is used. + +Example: + + rpc: spi@ee20 { + compatible = "renesas,r8a77995-rpc", "renesas,rcar-gen3-rpc"; + reg = <0 0xee20 0 0x200>, <0 0x0800 0 0x400>, + <0 0xee208000 0 0x100>; + reg-names = "regs", "dirmap", "wbuf"; + clocks = < CPG_MOD 917>; + clock-names = "rpc"; + power-domains = < R8A77995_PD_ALWAYS_ON>; + resets = < 917>; + #address-cells = <1>; + #size-cells = <0>; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <4000>; + spi-tx-bus-width = <1>; + spi-rx-bus-width = <1>; + }; + }; -- 1.9.1
[PATCH 2/5] integrity: remove pointless subdir-$(CONFIG_...)
The ima/ and evm/ sub-directories contain built-in objects, so obj-$(CONFIG_...) is the correct way to descend into them. subdir-$(CONFIG_...) is redundant. Signed-off-by: Masahiro Yamada --- security/integrity/Makefile | 2 -- 1 file changed, 2 deletions(-) diff --git a/security/integrity/Makefile b/security/integrity/Makefile index b6d6273a4176..35e6ca773734 100644 --- a/security/integrity/Makefile +++ b/security/integrity/Makefile @@ -14,7 +14,5 @@ integrity-$(CONFIG_LOAD_UEFI_KEYS) += platform_certs/efi_parser.o \ platform_certs/load_uefi.o integrity-$(CONFIG_LOAD_IPL_KEYS) += platform_certs/load_ipl_s390.o -subdir-$(CONFIG_IMA) += ima obj-$(CONFIG_IMA) += ima/ -subdir-$(CONFIG_EVM) += evm obj-$(CONFIG_EVM) += evm/ -- 2.17.1
Re: [PATCH v6 14/14] arm64: dts: Add power controller device node of MT8183
Hi, Weiyi: On Tue, 2019-07-23 at 12:06 +0800, Weiyi Lu wrote: > On Tue, 2019-07-16 at 09:50 +0800, CK Hu wrote: > > Hi, Weiyi: > > > > On Mon, 2019-07-15 at 17:07 +0800, Weiyi Lu wrote: > > > On Mon, 2019-07-15 at 16:07 +0800, CK Hu wrote: > > > > Hi, Weiyi: > > > > > > > > On Mon, 2019-07-01 at 16:57 +0800, CK Hu wrote: > > > > > Hi, Weiyi: > > > > > > > > > > On Thu, 2019-06-20 at 10:38 +0800, Weiyi Lu wrote: > > > > > > Add power controller node and smi-common node for MT8183 > > > > > > In scpsys node, it contains clocks and regmapping of > > > > > > infracfg and smi-common for bus protection. > > > > > > > > > > > > Signed-off-by: Weiyi Lu > > > > > > --- > > > > > > arch/arm64/boot/dts/mediatek/mt8183.dtsi | 62 > > > > > > > > > > > > 1 file changed, 62 insertions(+) > > > > > > > > > > > > diff --git a/arch/arm64/boot/dts/mediatek/mt8183.dtsi > > > > > > b/arch/arm64/boot/dts/mediatek/mt8183.dtsi > > > > > > index 08274bf..75c4881 100644 > > > > > > --- a/arch/arm64/boot/dts/mediatek/mt8183.dtsi > > > > > > +++ b/arch/arm64/boot/dts/mediatek/mt8183.dtsi > > > > > > @@ -8,6 +8,7 @@ > > > > > > #include > > > > > > #include > > > > > > #include > > > > > > +#include > > > > > > > > > > > > / { > > > > > > compatible = "mediatek,mt8183"; > > > > > > @@ -196,6 +197,62 @@ > > > > > > #clock-cells = <1>; > > > > > > }; > > > > > > > > > > > > + scpsys: syscon@10006000 { > > > > > > + compatible = "mediatek,mt8183-scpsys", "syscon"; > > > > > > + #power-domain-cells = <1>; > > > > > > + reg = <0 0x10006000 0 0x1000>; > > > > > > + clocks = < CLK_TOP_MUX_AUD_INTBUS>, > > > > > > +< CLK_INFRA_AUDIO>, > > > > > > +< CLK_INFRA_AUDIO_26M_BCLK>, > > > > > > +< CLK_TOP_MUX_MFG>, > > > > > > +< CLK_TOP_MUX_MM>, > > > > > > +< CLK_TOP_MUX_CAM>, > > > > > > +< CLK_TOP_MUX_IMG>, > > > > > > +< CLK_TOP_MUX_IPU_IF>, > > > > > > +< CLK_TOP_MUX_DSP>, > > > > > > +< CLK_TOP_MUX_DSP1>, > > > > > > +< CLK_TOP_MUX_DSP2>, > > > > > > +< CLK_MM_SMI_COMMON>, > > > > > > +< CLK_MM_SMI_LARB0>, > > > > > > +< CLK_MM_SMI_LARB1>, > > > > > > +< CLK_MM_GALS_COMM0>, > > > > > > +< CLK_MM_GALS_COMM1>, > > > > > > +< CLK_MM_GALS_CCU2MM>, > > > > > > +< CLK_MM_GALS_IPU12MM>, > > > > > > +< CLK_MM_GALS_IMG2MM>, > > > > > > +< CLK_MM_GALS_CAM2MM>, > > > > > > +< CLK_MM_GALS_IPU2MM>, > > > > > > > > I've removed all mmsys clock in scpsys node and display still works, so > > > > I think these subsys clock could be removed from scpsys node. It's > > > > reasonable that subsys clock is controlled by subsys device or the > > > > device use it. In MT2712 [1], the scpsys does not control subsys clock > > > > and it works, so I think you should remove subsys clock in scpsys device > > > > node. > > > > > > > > [1] > > > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/boot/dts/mediatek/mt2712e.dtsi?h=v5.2 > > > > > > > > Regards, > > > > CK > > > > > > > > > > Hello CK, > > > > > > Sorry, I can't agree with you at all. > > > I thought you just created an environment where the MM (DISP) power > > > domain could not be turned on and off properly. > > > If you delete those mmsys clocks listed, bus protection will not work. > > > These clocks are used for bus protection that I mentioned in patch [2]. > > > I guess you are now trying to solve the problem that mmsys blocks are > > > used for probing two drivers. One for the display and another for the > > > clock. Right? > > > In the previous test you mentioned, you have affected the registration > > > of mmsys clock first. This is why you saw the boot failure. I think boot > > > failure is the real problem I should avoid if mmsys clock cannot probe. > > > > > > [2] https://patchwork.kernel.org/patch/11005747/ > > > > > > > OK, I'll try another way to fix the probe problem, but I still have > > question about bus protection. I'm not sure how bus protection works, > > but I think that what mtk_scpsys_ext_clear_bus_protection() do could be > > moved in mtk_smi_clk_enable(). How do you think? > > > > Regards, > > CK > > > > I think we need to consider the disable case as well. > And SMI may not be the only DISP power domain user. As far as I know and > being requested, bus protection should only be set when DISP power > domain is going to
[PATCH v15 0/2] spi: Add Renesas R-Car Gen3 RPC-IF SPI driver
Hi Mark, v15 patch including: 1) A typo in dt-bindings and add flash subnode description 2) v14 dt-binding file has reviewed by Rob Herring. v14 patch including: 1) Patch RPC-IF back to SPI mode only instead of MFD & SPI by MFD maintainer, Lee Jones comments. 2) Patch pm_runtime control in spi transfer. v13 patch including: 1) rename mfd to ddata for SPI driver. 2) Patch RPC-IF devicetree for SPI and HyperFlash. v12 patch including: 1) add back "wbuf" in dts example. 2) RPC-IF replace rpc-if in dts. v11 patch including: 1) Patch mfd include header file. 2) mfd coding style. 3) add back wbuf description in dts. v10 patch including: 1) Address range for > 64M byte flash. 2) Removed dirmap_write due to WBUF 256 bytes transfer issue. 3) Dummy bytes setting according to spi-nor.c layer. v9 patch is for RPC MFD driver and RPC SPI driver. v8 patch including: 1) Supported SoC-specific values in DTS. 2) Rename device node name as flash. v7 patch is according to Geert and Sergei's comments: 1) Add all R-Car Gen3 model in dts. 2) patch rpc-if child node search. 3) minror coding style. v6 patch is accroding to Geert, Marek and Sergei's comments: 1) spi_controller for new code. 2) "renesas,rcar-gen3-rpc" instead of "renesas,r8a77995-rpc." 3) patch external address read mode w/o u64 readq(). 4) patch dts for write buffer & drop "renesas,rpc-mode". 5) coding style and so on. v5 patch is accroding to Sergei's comments: 1) Read 6 bytes ID from Sergei's patch. 2) regmap_update_bits(). 3) C++ style comment. v4 patch is according to Sergei's comments including: 1) Drop soc_device_match(). 2) Drop unused RPC registers. 3) Use ilog2() instead of fls(). 4) Patch read 6 bytes ID w/ one command. 5) Coding style and so on. v3 patch is according to Marek and Geert's comments including: 1) soc_device_mach() to set up RPC_PHYCNT_STRTIM. 2) get_unaligned(). 3) rpc-mode for rpi-spi-flash or rpc-hyperflash. 4) coding style and so on. v2 patch including: 1) remove RPC clock enable/dis-able control, 2) patch run time PM. 3) add RPC module software reset, 4) add regmap. 5) other coding style and so on. thanks for your review. best regards, Mason Mason Yang (2): spi: Add Renesas R-Car Gen3 RPC-IF SPI controller driver dt-bindings: spi: Document Renesas R-Car Gen3 RPC-IF controller bindings .../devicetree/bindings/spi/spi-renesas-rpc.txt| 46 ++ drivers/spi/Kconfig| 6 + drivers/spi/Makefile | 1 + drivers/spi/spi-renesas-rpc.c | 754 + 4 files changed, 807 insertions(+) create mode 100644 Documentation/devicetree/bindings/spi/spi-renesas-rpc.txt create mode 100644 drivers/spi/spi-renesas-rpc.c -- 1.9.1
Re: [PATCH 2/5] sched/fair: rename sum_nr_running to sum_h_nr_running
* Vincent Guittot [2019-07-19 09:58:22]: > sum_nr_running will track rq->nr_running task and sum_h_nr_running > will track cfs->h_nr_running so we can use both to detect when other > scheduling class are running and preempt CFS. > > There is no functional changes. > > Signed-off-by: Vincent Guittot > --- > > ld_moved = 0; > - if (busiest->nr_running > 1) { > + if (busiest->cfs.h_nr_running > 1) { We should be looking for nr_running here. There could be only one cfs task but that may not be the current running task, so it could be a good one to be picked for load balancing. No? > /* >* Attempt to move tasks. If find_busiest_group has found >* an imbalance but busiest->nr_running <= 1, the group is > -- > 2.7.4 > -- Thanks and Regards Srikar Dronamraju
[PATCH v2 1/2] mmc: sdhci: Add PLL Enable support to internal clock setup
The GL9750 and GL9755 chipsets, and possibly others, require PLL Enable setup as part of the internal clock setup as described in 3.2.1 Internal Clock Setup Sequence of SD Host Controller Simplified Specification Version 4.20. This changes the timeouts to the new specification of 150ms for each step and is documented as safe for "prior versions which do not support PLL Enable." Signed-off-by: Ben Chuang Co-developed-by: Michael K Johnson Signed-off-by: Michael K Johnson diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 59acf8e3331e..14957578bf2e 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1636,8 +1636,8 @@ void sdhci_enable_clk(struct sdhci_host *host, u16 clk) clk |= SDHCI_CLOCK_INT_EN; sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL); - /* Wait max 20 ms */ - timeout = ktime_add_ms(ktime_get(), 20); + /* Wait max 150 ms */ + timeout = ktime_add_ms(ktime_get(), 150); while (1) { bool timedout = ktime_after(ktime_get(), timeout); @@ -1650,7 +1650,28 @@ void sdhci_enable_clk(struct sdhci_host *host, u16 clk) sdhci_dumpregs(host); return; } - udelay(10); + usleep_range(10,15); + } + + clk |= SDHCI_CLOCK_PLL_EN; + clk &= ~SDHCI_CLOCK_INT_STABLE; + sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL); + + /* Wait max 150 ms */ + timeout = ktime_add_ms(ktime_get(), 150); + while (1) { + bool timedout = ktime_after(ktime_get(), timeout); + + clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL); + if (clk & SDHCI_CLOCK_INT_STABLE) + break; + if (timedout) { + pr_err("%s: PLL clock never stabilised.\n", + mmc_hostname(host->mmc)); + sdhci_dumpregs(host); + return; + } + usleep_range(10,15); } clk |= SDHCI_CLOCK_CARD_EN; diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index 199712e7adbb..72601a4d2e95 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -114,6 +114,7 @@ #define SDHCI_DIV_HI_MASK 0x300 #define SDHCI_PROG_CLOCK_MODE 0x0020 #define SDHCI_CLOCK_CARD_EN 0x0004 +#define SDHCI_CLOCK_PLL_EN0x0008 #define SDHCI_CLOCK_INT_STABLE0x0002 #define SDHCI_CLOCK_INT_EN0x0001
Re: [alsa-devel] [RFC PATCH 09/40] soundwire: cadence_master: fix usage of CONFIG_UPDATE
On 7/26/2019 7:40 AM, Pierre-Louis Bossart wrote: Per the hardware documentation, all changes to MCP_CONFIG, MCP_CONTROL, MCP_CMDCTRL and MCP_PHYCTRL need to be validated with a self-clearing write to MCP_CONFIG_UPDATE. For some reason, the existing code only does this write to CONFIG_UPDATE when enabling interrupts. Add a helper and do the update when the CONFIG is changed. Signed-off-by: Pierre-Louis Bossart --- drivers/soundwire/cadence_master.c | 29 + 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/drivers/soundwire/cadence_master.c b/drivers/soundwire/cadence_master.c index 9f611a1fff0a..eb46cf651d62 100644 --- a/drivers/soundwire/cadence_master.c +++ b/drivers/soundwire/cadence_master.c @@ -224,6 +224,22 @@ static int cdns_clear_bit(struct sdw_cdns *cdns, int offset, u32 value) return -EAGAIN; } +/* + * all changes to the MCP_CONFIG, MCP_CONTROL, MCP_CMDCTRL and MCP_PHYCTRL + * need to be confirmed with a write to MCP_CONFIG_UPDATE + */ +static int cdns_update_config(struct sdw_cdns *cdns) +{ + int ret; + + ret = cdns_clear_bit(cdns, CDNS_MCP_CONFIG_UPDATE, +CDNS_MCP_CONFIG_UPDATE_BIT); + if (ret < 0) + dev_err(cdns->dev, "Config update timedout\n"); + + return ret; +} + /* * debugfs */ @@ -758,15 +774,9 @@ static int _cdns_enable_interrupt(struct sdw_cdns *cdns) */ int sdw_cdns_enable_interrupt(struct sdw_cdns *cdns) { - int ret; - _cdns_enable_interrupt(cdns); - ret = cdns_clear_bit(cdns, CDNS_MCP_CONFIG_UPDATE, -CDNS_MCP_CONFIG_UPDATE_BIT); - if (ret < 0) - dev_err(cdns->dev, "Config update timedout\n"); - return ret; Should we add cdns_update_config() here? + return 0; } EXPORT_SYMBOL(sdw_cdns_enable_interrupt); @@ -943,7 +953,10 @@ int sdw_cdns_init(struct sdw_cdns *cdns) cdns_writel(cdns, CDNS_MCP_CONFIG, val); - return 0; + /* commit changes */ + ret = cdns_update_config(cdns); + + return ret; } EXPORT_SYMBOL(sdw_cdns_init);
Re: [PATCH] kprobes: Allow kprobes coexist with livepatch
On Thu, Jul 25, 2019 at 03:24:37PM +0900, Masami Hiramatsu wrote: > Allow kprobes which do not modify regs->ip, coexist with livepatch > by dropping FTRACE_OPS_FL_IPMODIFY from ftrace_ops. > > User who wants to modify regs->ip (e.g. function fault injection) > must set a dummy post_handler to its kprobes when registering. > However, if such regs->ip modifying kprobes is set on a function, > that function can not be livepatched. > > Signed-off-by: Masami Hiramatsu > --- > kernel/kprobes.c | 56 > +++--- > 1 file changed, 40 insertions(+), 16 deletions(-) > > diff --git a/kernel/kprobes.c b/kernel/kprobes.c > index 9873fc627d61..29065380dad0 100644 > --- a/kernel/kprobes.c > +++ b/kernel/kprobes.c > @@ -961,9 +961,16 @@ static struct kprobe *alloc_aggr_kprobe(struct kprobe *p) > > #ifdef CONFIG_KPROBES_ON_FTRACE > static struct ftrace_ops kprobe_ftrace_ops __read_mostly = { > + .func = kprobe_ftrace_handler, > + .flags = FTRACE_OPS_FL_SAVE_REGS, > +}; > + > +static struct ftrace_ops kprobe_ipmodify_ops __read_mostly = { > .func = kprobe_ftrace_handler, > .flags = FTRACE_OPS_FL_SAVE_REGS | FTRACE_OPS_FL_IPMODIFY, > }; > + > +static int kprobe_ipmodify_enabled; > static int kprobe_ftrace_enabled; > > /* Must ensure p->addr is really on ftrace */ > @@ -976,58 +983,75 @@ static int prepare_kprobe(struct kprobe *p) > } > > /* Caller must lock kprobe_mutex */ > -static int arm_kprobe_ftrace(struct kprobe *p) > +static int __arm_kprobe_ftrace(struct kprobe *p, struct ftrace_ops *ops, > +int *cnt) > { > int ret = 0; > > - ret = ftrace_set_filter_ip(_ftrace_ops, > -(unsigned long)p->addr, 0, 0); > + ret = ftrace_set_filter_ip(ops, (unsigned long)p->addr, 0, 0); > if (ret) { > pr_debug("Failed to arm kprobe-ftrace at %pS (%d)\n", >p->addr, ret); > return ret; > } > > - if (kprobe_ftrace_enabled == 0) { > - ret = register_ftrace_function(_ftrace_ops); > + if (*cnt == 0) { > + ret = register_ftrace_function(ops); > if (ret) { > pr_debug("Failed to init kprobe-ftrace (%d)\n", ret); > goto err_ftrace; > } > } > > - kprobe_ftrace_enabled++; > + (*cnt)++; > return ret; > > err_ftrace: > /* > - * Note: Since kprobe_ftrace_ops has IPMODIFY set, and ftrace requires a > - * non-empty filter_hash for IPMODIFY ops, we're safe from an accidental > - * empty filter_hash which would undesirably trace all functions. > + * At this point, sinec ops is not registered, we should be sefe from > + * registering empty filter. >*/ > - ftrace_set_filter_ip(_ftrace_ops, (unsigned long)p->addr, 1, 0); > + ftrace_set_filter_ip(ops, (unsigned long)p->addr, 1, 0); > return ret; > } > > +static int arm_kprobe_ftrace(struct kprobe *p) > +{ > + bool ipmodify = (p->post_handler != NULL); > + > + return __arm_kprobe_ftrace(p, > + ipmodify ? _ipmodify_ops : _ftrace_ops, > + ipmodify ? _ipmodify_enabled : _ftrace_enabled); > +} > + > /* Caller must lock kprobe_mutex */ > -static int disarm_kprobe_ftrace(struct kprobe *p) > +static int __disarm_kprobe_ftrace(struct kprobe *p, struct ftrace_ops *ops, > + int *cnt) > { > int ret = 0; > > - if (kprobe_ftrace_enabled == 1) { > - ret = unregister_ftrace_function(_ftrace_ops); > + if (*cnt == 1) { > + ret = unregister_ftrace_function(ops); > if (WARN(ret < 0, "Failed to unregister kprobe-ftrace (%d)\n", > ret)) > return ret; > } > > - kprobe_ftrace_enabled--; > + (*cnt)--; > > - ret = ftrace_set_filter_ip(_ftrace_ops, > -(unsigned long)p->addr, 1, 0); > + ret = ftrace_set_filter_ip(ops, (unsigned long)p->addr, 1, 0); > WARN_ONCE(ret < 0, "Failed to disarm kprobe-ftrace at %pS (%d)\n", > p->addr, ret); > return ret; > } > + > +static int disarm_kprobe_ftrace(struct kprobe *p) > +{ > + bool ipmodify = (p->post_handler != NULL); > + > + return __disarm_kprobe_ftrace(p, > + ipmodify ? _ipmodify_ops : _ftrace_ops, > + ipmodify ? _ipmodify_enabled : _ftrace_enabled); > +} > #else/* !CONFIG_KPROBES_ON_FTRACE */ > #define prepare_kprobe(p)arch_prepare_kprobe(p) > #define arm_kprobe_ftrace(p) (-ENODEV) > Thanks for the quick patch, Masami! I gave it a spin and here are my new testing results: perf probe, then livepatch -- % perf probe --add cmdline_proc_show Added new event: probe:cmdline_proc_show (on cmdline_proc_show) You can now use it in all perf tools, such as: perf record -e probe:cmdline_proc_show
[PATCH 5/5] EVM: use obj-y for non-modular objects
CONFIG_EVM is a boolean option, so none of these objects is linked into a module. All the objects in this directory are compiled only when CONFIG_EVM=y since this directory is guarded by the parent Makefile: obj-$(CONFIG_EVM) += evm/ So, there is no point in creating the composite object, evm.o Flatten the code into the obj-$(CONFIG_...) form. Signed-off-by: Masahiro Yamada --- security/integrity/evm/Makefile | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/security/integrity/evm/Makefile b/security/integrity/evm/Makefile index a56f5613be79..ace8e4ef5a96 100644 --- a/security/integrity/evm/Makefile +++ b/security/integrity/evm/Makefile @@ -2,7 +2,5 @@ # # Makefile for building the Extended Verification Module(EVM) # -obj-$(CONFIG_EVM) += evm.o - -evm-y := evm_main.o evm_crypto.o evm_secfs.o -evm-$(CONFIG_FS_POSIX_ACL) += evm_posix_acl.o +obj-y := evm_main.o evm_crypto.o evm_secfs.o +obj-$(CONFIG_FS_POSIX_ACL) += evm_posix_acl.o -- 2.17.1
[PATCH v15 1/2] spi: Add Renesas R-Car Gen3 RPC-IF SPI controller driver
Add a driver for Renesas R-Car Gen3 RPC-IF SPI controller. Signed-off-by: Mason Yang Signed-off-by: Sergei Shtylyov --- drivers/spi/Kconfig | 6 + drivers/spi/Makefile | 1 + drivers/spi/spi-renesas-rpc.c | 754 ++ 3 files changed, 761 insertions(+) create mode 100644 drivers/spi/spi-renesas-rpc.c diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig index 3a1d8f1..88e28de 100644 --- a/drivers/spi/Kconfig +++ b/drivers/spi/Kconfig @@ -571,6 +571,12 @@ config SPI_RSPI help SPI driver for Renesas RSPI and QSPI blocks. +config SPI_RENESAS_RPC + tristate "Renesas R-Car Gen3 RPC-IF SPI controller" + depends on ARCH_RENESAS || COMPILE_TEST + help + SPI driver for Renesas R-Car Gen3 RPC-IF. + config SPI_QCOM_QSPI tristate "QTI QSPI controller" depends on ARCH_QCOM diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile index 63dcab5..d858e4c 100644 --- a/drivers/spi/Makefile +++ b/drivers/spi/Makefile @@ -87,6 +87,7 @@ obj-$(CONFIG_SPI_QUP) += spi-qup.o obj-$(CONFIG_SPI_ROCKCHIP) += spi-rockchip.o obj-$(CONFIG_SPI_RB4XX)+= spi-rb4xx.o obj-$(CONFIG_SPI_RSPI) += spi-rspi.o +obj-$(CONFIG_SPI_RENESAS_RPC) += spi-renesas-rpc.o obj-$(CONFIG_SPI_S3C24XX) += spi-s3c24xx-hw.o spi-s3c24xx-hw-y := spi-s3c24xx.o spi-s3c24xx-hw-$(CONFIG_SPI_S3C24XX_FIQ) += spi-s3c24xx-fiq.o diff --git a/drivers/spi/spi-renesas-rpc.c b/drivers/spi/spi-renesas-rpc.c new file mode 100644 index 000..648d14e --- /dev/null +++ b/drivers/spi/spi-renesas-rpc.c @@ -0,0 +1,754 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Copyright (C) 2018 ~ 2019 Renesas Solutions Corp. +// Copyright (C) 2019 Macronix International Co., Ltd. +// +// R-Car Gen3 RPC-IF SPI/QSPI/Octa driver +// +// Author: +// Mason Yang +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define RPC_CMNCR 0x // R/W +#define RPC_CMNCR_MD BIT(31) +#define RPC_CMNCR_SFDE BIT(24) // undocumented bit but must be set +#define RPC_CMNCR_MOIIO3(val) (((val) & 0x3) << 22) +#define RPC_CMNCR_MOIIO2(val) (((val) & 0x3) << 20) +#define RPC_CMNCR_MOIIO1(val) (((val) & 0x3) << 18) +#define RPC_CMNCR_MOIIO0(val) (((val) & 0x3) << 16) +#define RPC_CMNCR_MOIIO_HIZ(RPC_CMNCR_MOIIO0(3) | RPC_CMNCR_MOIIO1(3) | \ +RPC_CMNCR_MOIIO2(3) | RPC_CMNCR_MOIIO3(3)) +#define RPC_CMNCR_IO3FV(val) (((val) & 0x3) << 14) // undocumented +#define RPC_CMNCR_IO2FV(val) (((val) & 0x3) << 12) // undocumented +#define RPC_CMNCR_IO0FV(val) (((val) & 0x3) << 8) +#define RPC_CMNCR_IOFV_HIZ (RPC_CMNCR_IO0FV(3) | RPC_CMNCR_IO2FV(3) | \ +RPC_CMNCR_IO3FV(3)) +#define RPC_CMNCR_BSZ(val) (((val) & 0x3) << 0) + +#define RPC_SSLDR 0x0004 // R/W +#define RPC_SSLDR_SPNDL(d) (((d) & 0x7) << 16) +#define RPC_SSLDR_SLNDL(d) (((d) & 0x7) << 8) +#define RPC_SSLDR_SCKDL(d) (((d) & 0x7) << 0) + +#define RPC_DRCR 0x000C // R/W +#define RPC_DRCR_SSLN BIT(24) +#define RPC_DRCR_RBURST(v) v) - 1) & 0x1F) << 16) +#define RPC_DRCR_RCF BIT(9) +#define RPC_DRCR_RBE BIT(8) +#define RPC_DRCR_SSLE BIT(0) + +#define RPC_DRCMR 0x0010 // R/W +#define RPC_DRCMR_CMD(c) (((c) & 0xFF) << 16) +#define RPC_DRCMR_OCMD(c) (((c) & 0xFF) << 0) + +#define RPC_DREAR 0x0014 // R/W +#define RPC_DREAR_EAV(c) (((c) & 0xf) << 16) +#define RPC_DREAR_EAC(c) (((c) & 0x7) << 0) + +#define RPC_DROPR 0x0018 // R/W + +#define RPC_DRENR 0x001C // R/W +#define RPC_DRENR_CDB(o) (u32)o) & 0x3) << 30)) +#define RPC_DRENR_OCDB(o) (((o) & 0x3) << 28) +#define RPC_DRENR_ADB(o) (((o) & 0x3) << 24) +#define RPC_DRENR_OPDB(o) (((o) & 0x3) << 20) +#define RPC_DRENR_DRDB(o) (((o) & 0x3) << 16) +#define RPC_DRENR_DME BIT(15) +#define RPC_DRENR_CDE BIT(14) +#define RPC_DRENR_OCDE BIT(12) +#define RPC_DRENR_ADE(v) (((v) & 0xF) << 8) +#define RPC_DRENR_OPDE(v) (((v) & 0xF) << 4) + +#define RPC_SMCR 0x0020 // R/W +#define RPC_SMCR_SSLKP BIT(8) +#define RPC_SMCR_SPIRE BIT(2) +#define RPC_SMCR_SPIWE BIT(1) +#define RPC_SMCR_SPIE BIT(0) + +#define RPC_SMCMR 0x0024 // R/W +#define RPC_SMCMR_CMD(c) (((c) & 0xFF) << 16) +#define RPC_SMCMR_OCMD(c) (((c) & 0xFF) << 0) + +#define RPC_SMADR 0x0028 // R/W +#define RPC_SMOPR 0x002C // R/W +#define RPC_SMOPR_OPD3(o) (((o) & 0xFF) << 24) +#define RPC_SMOPR_OPD2(o) (((o) & 0xFF) << 16) +#define RPC_SMOPR_OPD1(o) (((o) & 0xFF) << 8) +#define
[PATCH] kbuild: clean-up subdir-ym computation
The intermediate variables __subdir-{y,m} are unneeded. Signed-off-by: Masahiro Yamada --- scripts/Makefile.lib | 17 + 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 41c50f9461e5..444574963cb5 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -20,27 +20,20 @@ obj-m := $(filter-out $(obj-y),$(obj-m)) # Filter out objects already built-in lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m))) +# Subdirectories we need to descend into +subdir-ym := $(sort $(subdir-y) $(subdir-m) $(patsubst %/,%, $(filter %/, $(obj-y) $(obj-m + # Determine modorder. # Unfortunately, we don't have information about ordering between -y # and -m subdirs. Just put -y's first. modorder := $(patsubst %/,%/modules.order, $(filter %/, $(obj-y)) $(obj-m:.o=.ko)) # Handle objects in subdirs -# --- -# o if we encounter foo/ in $(obj-y), replace it by foo/built-in.a -# and add the directory to the list of dirs to descend into: $(subdir-y) -# o if we encounter foo/ in $(obj-m), remove it from $(obj-m) -# and add the directory to the list of dirs to descend into: $(subdir-m) -__subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y))) -subdir-y += $(__subdir-y) -__subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m))) -subdir-m += $(__subdir-m) +# When we encounter foo/ in $(obj-y), link foo/built-in.a into vmlinux, +# but we do not do that for $(obj-m) obj-y := $(patsubst %/, %/built-in.a, $(obj-y)) obj-m := $(filter-out %/, $(obj-m)) -# Subdirectories we need to descend into -subdir-ym := $(sort $(subdir-y) $(subdir-m)) - # if $(foo-objs), $(foo-y), or $(foo-m) exists, foo.o is a composite object multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))), $(m -- 2.17.1
[PATCH] kbuild: remove unused single-used-m
This is unused since commit 9f69a496f100 ("kbuild: split out *.mod out of {single,multi}-used-m rules"). Signed-off-by: Masahiro Yamada --- scripts/Makefile.lib | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 5241d0751eb0..41c50f9461e5 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -45,7 +45,6 @@ subdir-ym := $(sort $(subdir-y) $(subdir-m)) multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))), $(m multi-used := $(multi-used-y) $(multi-used-m) -single-used-m := $(sort $(filter-out $(multi-used-m),$(obj-m))) # $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to # tell kbuild to descend @@ -91,7 +90,6 @@ lib-y := $(addprefix $(obj)/,$(lib-y)) subdir-obj-y := $(addprefix $(obj)/,$(subdir-obj-y)) real-obj-y := $(addprefix $(obj)/,$(real-obj-y)) real-obj-m := $(addprefix $(obj)/,$(real-obj-m)) -single-used-m := $(addprefix $(obj)/,$(single-used-m)) multi-used-m := $(addprefix $(obj)/,$(multi-used-m)) subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) -- 2.17.1
Re: [PATCH v1 2/2] extcon: axp288: Use for_each_set_bit() in axp288_extcon_log_rsi()
On 19. 7. 26. 오전 5:34, Andy Shevchenko wrote: > This simplifies and standardizes axp288_extcon_log_rsi() > by using for_each_set_bit() library function. > > Signed-off-by: Andy Shevchenko > --- > drivers/extcon/extcon-axp288.c | 13 + > 1 file changed, 5 insertions(+), 8 deletions(-) > > diff --git a/drivers/extcon/extcon-axp288.c b/drivers/extcon/extcon-axp288.c > index 4cbcc3b1aa6b..670334c362ac 100644 > --- a/drivers/extcon/extcon-axp288.c > +++ b/drivers/extcon/extcon-axp288.c > @@ -121,7 +121,6 @@ static const char * const axp288_pwr_up_down_info[] = { > "Last shutdown caused by PMIC UVLO threshold", > "Last shutdown caused by SOC initiated cold off", > "Last shutdown caused by user pressing the power button", > - NULL, > }; > > /* > @@ -130,20 +129,18 @@ static const char * const axp288_pwr_up_down_info[] = { > */ > static void axp288_extcon_log_rsi(struct axp288_extcon_info *info) > { > - const char * const *rsi; > unsigned int val, i, clear_mask = 0; > + unsigned long bits; > int ret; > > ret = regmap_read(info->regmap, AXP288_PS_BOOT_REASON_REG, ); > if (ret < 0) > return; > > - for (i = 0, rsi = axp288_pwr_up_down_info; *rsi; rsi++, i++) { > - if (val & BIT(i)) { > - dev_dbg(info->dev, "%s\n", *rsi); > - clear_mask |= BIT(i); > - } > - } > + bits = val & GENMASK(ARRAY_SIZE(axp288_pwr_up_down_info) - 1, 0); > + for_each_set_bit(i, , ARRAY_SIZE(axp288_pwr_up_down_info)) > + dev_dbg(info->dev, "%s\n", axp288_pwr_up_down_info[i]); > + clear_mask = bits; > > /* Clear the register value for next reboot (write 1 to clear bit) */ > regmap_write(info->regmap, AXP288_PS_BOOT_REASON_REG, clear_mask); > Acked-by: Chanwoo Choi -- Best Regards, Chanwoo Choi Samsung Electronics
[PATCH v2] ALSA: i2c: ak4xxx-adda: Fix a possible null pointer dereference in build_adc_controls()
In build_adc_controls(), there is an if statement on line 773 to check whether ak->adc_info is NULL: if (! ak->adc_info || ! ak->adc_info[mixer_ch].switch_name) When ak->adc_info is NULL, it is used on line 792: knew.name = ak->adc_info[mixer_ch].selector_name; Thus, a possible null-pointer dereference may occur. To fix this bug, referring to lines 773 and 774, ak->adc_info and ak->adc_info[mixer_ch].selector_name are checked before being used. This bug is found by a static analysis tool STCheck written by us. Signed-off-by: Jia-Ju Bai --- v2: * Fix the errors reported by checkpatch.pl. Thank Takashi for helpful advice. --- sound/i2c/other/ak4xxx-adda.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sound/i2c/other/ak4xxx-adda.c b/sound/i2c/other/ak4xxx-adda.c index 5f59316f982a..b03e6d1be656 100644 --- a/sound/i2c/other/ak4xxx-adda.c +++ b/sound/i2c/other/ak4xxx-adda.c @@ -775,11 +775,12 @@ static int build_adc_controls(struct snd_akm4xxx *ak) return err; memset(, 0, sizeof(knew)); - knew.name = ak->adc_info[mixer_ch].selector_name; - if (!knew.name) { + if (!ak->adc_info || + !ak->adc_info[mixer_ch].selector_name) { knew.name = "Capture Channel"; knew.index = mixer_ch + ak->idx_offset * 2; - } + } else + knew.name = ak->adc_info[mixer_ch].selector_name; knew.iface = SNDRV_CTL_ELEM_IFACE_MIXER; knew.info = ak4xxx_capture_source_info; -- 2.17.0
[PATCH v2] mm: memcontrol: fix use after free in mem_cgroup_iter()
This patch is sent to report an use after free in mem_cgroup_iter() after merging commit: be2657752e9e "mm: memcg: fix use after free in mem_cgroup_iter()". I work with android kernel tree (4.9 & 4.14), and the commit: be2657752e9e "mm: memcg: fix use after free in mem_cgroup_iter()" has been merged to the trees. However, I can still observe use after free issues addressed in the commit be2657752e9e. (on low-end devices, a few times this month) backtrace: css_tryget <- crash here mem_cgroup_iter shrink_node shrink_zones do_try_to_free_pages try_to_free_pages __perform_reclaim __alloc_pages_direct_reclaim __alloc_pages_slowpath __alloc_pages_nodemask To debug, I poisoned mem_cgroup before freeing it: static void __mem_cgroup_free(struct mem_cgroup *memcg) for_each_node(node) free_mem_cgroup_per_node_info(memcg, node); free_percpu(memcg->stat); + /* poison memcg before freeing it */ + memset(memcg, 0x78, sizeof(struct mem_cgroup)); kfree(memcg); } The coredump shows the position=0xdbbc2a00 is freed. (gdb) p/x ((struct mem_cgroup_per_node *)0xe5009e00)->iter[8] $13 = {position = 0xdbbc2a00, generation = 0x2efd} 0xdbbc2a00: 0xdbbc2e00 0x 0xdbbc2800 0x0100 0xdbbc2a10: 0x0200 0x78787878 0x00026218 0x 0xdbbc2a20: 0xdcad6000 0x0001 0x78787800 0x 0xdbbc2a30: 0x7878 0x 0x0068fb84 0x78787878 0xdbbc2a40: 0x78787878 0x78787878 0x78787878 0xe3fa5cc0 0xdbbc2a50: 0x78787878 0x78787878 0x 0x 0xdbbc2a60: 0x 0x 0x 0x 0xdbbc2a70: 0x 0x 0x 0x 0xdbbc2a80: 0x 0x 0x 0x 0xdbbc2a90: 0x0001 0x 0x 0x0010 0xdbbc2aa0: 0x0001 0xdbbc2ac8 0x 0x 0xdbbc2ab0: 0x 0x 0x 0x 0xdbbc2ac0: 0x 0x 0xe5b02618 0x1000 0xdbbc2ad0: 0x 0x78787878 0x78787878 0x78787878 0xdbbc2ae0: 0x78787878 0x78787878 0x78787878 0x78787878 0xdbbc2af0: 0x78787878 0x78787878 0x78787878 0x78787878 0xdbbc2b00: 0x78787878 0x78787878 0x78787878 0x78787878 0xdbbc2b10: 0x78787878 0x78787878 0x78787878 0x78787878 0xdbbc2b20: 0x78787878 0x78787878 0x78787878 0x78787878 0xdbbc2b30: 0x78787878 0x78787878 0x78787878 0x78787878 0xdbbc2b40: 0x78787878 0x78787878 0x78787878 0x78787878 0xdbbc2b50: 0x78787878 0x78787878 0x78787878 0x78787878 0xdbbc2b60: 0x78787878 0x78787878 0x78787878 0x78787878 0xdbbc2b70: 0x78787878 0x78787878 0x78787878 0x78787878 0xdbbc2b80: 0x78787878 0x78787878 0x 0x78787878 0xdbbc2b90: 0x78787878 0x78787878 0x78787878 0x78787878 0xdbbc2ba0: 0x78787878 0x78787878 0x78787878 0x78787878 In the reclaim path, try_to_free_pages() does not setup sc.target_mem_cgroup and sc is passed to do_try_to_free_pages(), ..., shrink_node(). In mem_cgroup_iter(), root is set to root_mem_cgroup because sc->target_mem_cgroup is NULL. It is possible to assign a memcg to root_mem_cgroup.nodeinfo.iter in mem_cgroup_iter(). try_to_free_pages struct scan_control sc = {...}, target_mem_cgroup is 0x0; do_try_to_free_pages shrink_zones shrink_node mem_cgroup *root = sc->target_mem_cgroup; memcg = mem_cgroup_iter(root, NULL, ); mem_cgroup_iter() if (!root) root = root_mem_cgroup; ... css = css_next_descendant_pre(css, >css); memcg = mem_cgroup_from_css(css); cmpxchg(>position, pos, memcg); My device uses memcg non-hierarchical mode. When we release a memcg: invalidate_reclaim_iterators() reaches only dead_memcg and its parents. If non-hierarchical mode is used, invalidate_reclaim_iterators() never reaches root_mem_cgroup. static void invalidate_reclaim_iterators(struct mem_cgroup *dead_memcg) { struct mem_cgroup *memcg = dead_memcg; for (; memcg; memcg = parent_mem_cgroup(memcg) ... } So the use after free scenario looks like: CPU1CPU2 try_to_free_pages do_try_to_free_pages shrink_zones shrink_node mem_cgroup_iter() if (!root) root = root_mem_cgroup; ... css = css_next_descendant_pre(css, >css); memcg = mem_cgroup_from_css(css); cmpxchg(>position, pos, memcg);
[PATCH 1/5] integrity: remove unneeded, broken attempt to add -fshort-wchar
I guess commit 15ea0e1e3e18 ("efi: Import certificates from UEFI Secure Boot") attempted to add -fshort-wchar for building load_uefi.o, but it has never worked as intended. load_uefi.o is created in the platform_certs/ sub-directory. If you really want to add -fshort-wchar, the correct code is: $(obj)/platform_certs/load_uefi.o: KBUILD_CFLAGS += -fshort-wchar or, in a more Kbuild-ish way: CFLAGS_load_uefi.o := -fshort-wchar But, you do not need to fix it. Commit 8c97023cf051 ("Kbuild: use -fshort-wchar globally") had already added -fshort-wchar globally. This code was unneeded in the first place. Signed-off-by: Masahiro Yamada --- security/integrity/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/security/integrity/Makefile b/security/integrity/Makefile index 19faace69644..b6d6273a4176 100644 --- a/security/integrity/Makefile +++ b/security/integrity/Makefile @@ -13,7 +13,6 @@ integrity-$(CONFIG_INTEGRITY_PLATFORM_KEYRING) += platform_certs/platform_keyrin integrity-$(CONFIG_LOAD_UEFI_KEYS) += platform_certs/efi_parser.o \ platform_certs/load_uefi.o integrity-$(CONFIG_LOAD_IPL_KEYS) += platform_certs/load_ipl_s390.o -$(obj)/load_uefi.o: KBUILD_CFLAGS += -fshort-wchar subdir-$(CONFIG_IMA) += ima obj-$(CONFIG_IMA) += ima/ -- 2.17.1
[PATCH 4/5] IMA: use obj-y for non-modular objects
CONFIG_IMA is a boolean option, so none of these objects is linked into a module. All the objects in this directory are compiled only when CONFIG_IMA=y since this directory is guarded by the parent Makefile: obj-$(CONFIG_IMA) += ima/ So, there is no point in creating the composite object, ima.o Flatten the code into the obj-$(CONFIG_...) form. Signed-off-by: Masahiro Yamada --- security/integrity/ima/Makefile | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/security/integrity/ima/Makefile b/security/integrity/ima/Makefile index d921dc4f9eb0..5517486c9154 100644 --- a/security/integrity/ima/Makefile +++ b/security/integrity/ima/Makefile @@ -4,10 +4,8 @@ # Measurement Architecture(IMA). # -obj-$(CONFIG_IMA) += ima.o - -ima-y := ima_fs.o ima_queue.o ima_init.o ima_main.o ima_crypto.o ima_api.o \ +obj-y := ima_fs.o ima_queue.o ima_init.o ima_main.o ima_crypto.o ima_api.o \ ima_policy.o ima_template.o ima_template_lib.o -ima-$(CONFIG_IMA_APPRAISE) += ima_appraise.o -ima-$(CONFIG_HAVE_IMA_KEXEC) += ima_kexec.o +obj-$(CONFIG_IMA_APPRAISE) += ima_appraise.o +obj-$(CONFIG_HAVE_IMA_KEXEC) += ima_kexec.o obj-$(CONFIG_IMA_BLACKLIST_KEYRING) += ima_mok.o -- 2.17.1
[PATCH 0/5] security: integrity: Makefile cleanups
Masahiro Yamada (5): integrity: remove unneeded, broken attempt to add -fshort-wchar integrity: remove pointless subdir-$(CONFIG_...) integrity: use obj-y for non-modular objects IMA: use obj-y for non-modular objects EVM: use obj-y for non-modular objects security/integrity/Makefile | 19 +++ security/integrity/evm/Makefile | 6 ++ security/integrity/ima/Makefile | 8 +++- 3 files changed, 12 insertions(+), 21 deletions(-) -- 2.17.1
[PATCH 3/5] integrity: use obj-y for non-modular objects
CONFIG_INTEGRITY is a boolean option, so none of these objects is linked into a module. All of the other CONFIG options here depend on CONFIG_INTEGRITY, so there is no point in creating the composite object, integirity.o Flatten the code into the obj-$(CONFIG_...) form. Signed-off-by: Masahiro Yamada --- security/integrity/Makefile | 16 +++- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/security/integrity/Makefile b/security/integrity/Makefile index 35e6ca773734..53bb1d70e631 100644 --- a/security/integrity/Makefile +++ b/security/integrity/Makefile @@ -3,16 +3,14 @@ # Makefile for caching inode integrity data (iint) # -obj-$(CONFIG_INTEGRITY) += integrity.o - -integrity-y := iint.o -integrity-$(CONFIG_INTEGRITY_AUDIT) += integrity_audit.o -integrity-$(CONFIG_INTEGRITY_SIGNATURE) += digsig.o -integrity-$(CONFIG_INTEGRITY_ASYMMETRIC_KEYS) += digsig_asymmetric.o -integrity-$(CONFIG_INTEGRITY_PLATFORM_KEYRING) += platform_certs/platform_keyring.o -integrity-$(CONFIG_LOAD_UEFI_KEYS) += platform_certs/efi_parser.o \ +obj-$(CONFIG_INTEGRITY) += iint.o +obj-$(CONFIG_INTEGRITY_AUDIT) += integrity_audit.o +obj-$(CONFIG_INTEGRITY_SIGNATURE) += digsig.o +obj-$(CONFIG_INTEGRITY_ASYMMETRIC_KEYS) += digsig_asymmetric.o +obj-$(CONFIG_INTEGRITY_PLATFORM_KEYRING) += platform_certs/platform_keyring.o +obj-$(CONFIG_LOAD_UEFI_KEYS) += platform_certs/efi_parser.o \ platform_certs/load_uefi.o -integrity-$(CONFIG_LOAD_IPL_KEYS) += platform_certs/load_ipl_s390.o +obj-$(CONFIG_LOAD_IPL_KEYS) += platform_certs/load_ipl_s390.o obj-$(CONFIG_IMA) += ima/ obj-$(CONFIG_EVM) += evm/ -- 2.17.1
[PATCH v2 2/2] mmc: sdhci: sdhci-pci-core: Add Genesis Logic GL975x support
Add support for the GL9750 and GL9755 chipsets. Signed-off-by: Ben Chuang Co-developed-by: Michael K Johnson Signed-off-by: Michael K Johnson diff --git a/drivers/mmc/host/sdhci-gli.h b/drivers/mmc/host/sdhci-gli.h new file mode 100644 index ..0acd35b6d3e2 --- /dev/null +++ b/drivers/mmc/host/sdhci-gli.h @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +#ifndef __SDHCI_GLI_H +#define __SDHCI_GLI_H + +/* the define PCI_VENDOR_ID_GLI may put in kernel/include/linux/pci_ids.h */ +#ifndef PCI_VENDOR_ID_GLI +#define PCI_VENDOR_ID_GLI 0x17a0 +#endif + +/* Genesys Logic extra registers */ +#define SDHCI_GLI_9750_WT 0x800 +#define SDHCI_GLI_9750_DRIVING0x860 +#define SDHCI_GLI_9750_PLL0x864 +#define SDHCI_GLI_9750_SW_CTRL0x874 +#define SDHCI_GLI_9750_MISC 0x878 + +#define SDHCI_GLI_9750_TUNING_CONTROL 0x540 +#define SDHCI_GLI_9750_TUNING_PARAMETERS 0x544 + +#define GLI_9755_DRIVER_VER "Genesys Logic (GL9755 v0.9.0-y190703)" +#define GLI_9750_DRIVER_VER "Genesys Logic (GL9750 v0.9.0-y190703)" + +#define GLI_MAX_TUNING_LOOP 40 + +void gli_set_9750(struct sdhci_host *host); + +#endif /* __SDHCI_GLI_H */ diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c index 4154ee11b47d..b5c28df39de1 100644 --- a/drivers/mmc/host/sdhci-pci-core.c +++ b/drivers/mmc/host/sdhci-pci-core.c @@ -35,6 +35,7 @@ #include "sdhci.h" #include "sdhci-pci.h" +#include "sdhci-gli.h" static void sdhci_pci_hw_reset(struct sdhci_host *host); @@ -1453,6 +1454,223 @@ static const struct sdhci_pci_fixes sdhci_rtsx = { .probe_slot = rtsx_probe_slot, }; +/* Genesys Logic chipset */ +static int gli_probe_slot_gl9755(struct sdhci_pci_slot *slot) +{ + struct sdhci_host *host = slot->host; + + slot->host->mmc->caps2 |= MMC_CAP2_NO_SDIO; + dev_info(>chip->pdev->dev, "%s\n", GLI_9755_DRIVER_VER); + sdhci_enable_v4_mode(host); + + return 0; +} + +static void gli_set_9750_rx_inv(struct sdhci_host *host, bool b) +{ + u32 wt_value = sdhci_readl(host, SDHCI_GLI_9750_WT); + u32 misc_value = sdhci_readl(host, SDHCI_GLI_9750_MISC); + + if ((wt_value & 0x1) == 0) { + wt_value |= 0x1; + sdhci_writel(host, wt_value, SDHCI_GLI_9750_WT); + } + + misc_value = sdhci_readl(host, SDHCI_GLI_9750_MISC); + if (b) { + misc_value |= 0x8; + sdhci_writel(host, misc_value, SDHCI_GLI_9750_MISC); + } else { + misc_value &= ~0x8; + sdhci_writel(host, misc_value, SDHCI_GLI_9750_MISC); + } + + wt_value = sdhci_readl(host, SDHCI_GLI_9750_WT); + wt_value &= ~0x1; + sdhci_writel(host, wt_value, SDHCI_GLI_9750_WT); +} + +static int __sdhci_execute_tuning_9750(struct sdhci_host *host, u32 opcode) +{ + int i; + int rx_inv = 0; + + for (rx_inv = 0; rx_inv < 2; rx_inv++) { + if (rx_inv & 0x1) + gli_set_9750_rx_inv(host, true); + else + gli_set_9750_rx_inv(host, false); + + sdhci_start_tuning(host); + + for (i = 0; i < GLI_MAX_TUNING_LOOP; i++) { + u16 ctrl; + + sdhci_send_tuning(host, opcode); + + if (!host->tuning_done) { + if (rx_inv == 1) { + pr_info("%s: Tuning timeout, falling back to fixed sampling clock\n", + mmc_hostname(host->mmc)); + sdhci_abort_tuning(host, opcode); + return -ETIMEDOUT; + } + pr_info("%s: Tuning timeout, try next tuning\n", + mmc_hostname(host->mmc)); + sdhci_abort_tuning(host, opcode); + break; + } + + ctrl = sdhci_readw(host, SDHCI_HOST_CONTROL2); + if (!(ctrl & SDHCI_CTRL_EXEC_TUNING)) { + if (ctrl & SDHCI_CTRL_TUNED_CLK) { + pr_info("%s: Tuning successful\n", + mmc_hostname(host->mmc)); + return 0; /* Success! */ + } + break; + } + } + } + + pr_info("%s: Tuning failed, falling back to fixed sampling clock\n", + mmc_hostname(host->mmc)); + sdhci_reset_tuning(host); + return -EAGAIN; +} + +static int gl9750_execute_tuning(struct mmc_host *mmc, u32 opcode) +{ + struct sdhci_host *host = mmc_priv(mmc); + int err = 0; + unsigned int tuning_count = 0; +
Re: [PATCH] ALSA: i2c: ak4xxx-adda: Fix a possible null pointer dereference in build_adc_controls()
On 2019/7/25 23:52, Takashi Iwai wrote: On Thu, 25 Jul 2019 10:27:33 +0200, Jia-Ju Bai wrote: In build_adc_controls(), there is an if statement on line 773 to check whether ak->adc_info is NULL: if (! ak->adc_info || ! ak->adc_info[mixer_ch].switch_name) When ak->adc_info is NULL, it is used on line 792: knew.name = ak->adc_info[mixer_ch].selector_name; Thus, a possible null-pointer dereference may occur. To fix this bug, referring to lines 773 and 774, ak->adc_info and ak->adc_info[mixer_ch].selector_name are checked before being used. This bug is found by a static analysis tool STCheck written by us. Signed-off-by: Jia-Ju Bai --- sound/i2c/other/ak4xxx-adda.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sound/i2c/other/ak4xxx-adda.c b/sound/i2c/other/ak4xxx-adda.c index 5f59316f982a..9a891470e84a 100644 --- a/sound/i2c/other/ak4xxx-adda.c +++ b/sound/i2c/other/ak4xxx-adda.c @@ -775,11 +775,13 @@ static int build_adc_controls(struct snd_akm4xxx *ak) return err; memset(, 0, sizeof(knew)); - knew.name = ak->adc_info[mixer_ch].selector_name; - if (!knew.name) { + if (! ak->adc_info || + ! ak->adc_info[mixer_ch].selector_name) { knew.name = "Capture Channel"; knew.index = mixer_ch + ak->idx_offset * 2; } + else + knew.name = ak->adc_info[mixer_ch].selector_name; knew.iface = SNDRV_CTL_ELEM_IFACE_MIXER; knew.info = ak4xxx_capture_source_info; The code change itself looks good, but please follow the standard coding style. In short: please run checkpatch.pl, fix errors (some warnings may be ignored) and resubmit. Okay, thanks for the advice. I will send a v2 patch. Best wishes, Jia-Ju Bai
Re: [PATCH v4 0/5] Add required-opps support to devfreq passive gov
On Wed, Jul 24, 2019 at 10:22 PM Viresh Kumar wrote: > > On 24-07-19, 20:40, Saravana Kannan wrote: > > On Wed, Jul 24, 2019 at 7:30 PM Viresh Kumar > > wrote: > > > > > > On 23-07-19, 18:42, Saravana Kannan wrote: > > > > The devfreq passive governor scales the frequency of a "child" device > > > > based > > > > on the current frequency of a "parent" device (not parent/child in the > > > > sense of device hierarchy). As of today, the passive governor requires > > > > one > > > > of the following to work correctly: > > > > 1. The parent and child device have the same number of frequencies > > > > 2. The child device driver passes a mapping function to translate from > > > >parent frequency to child frequency. > > > > > > > v3 -> v4: > > > > - Fixed documentation comments > > > > - Fixed order of functions in .h file > > > > - Renamed the new xlate API > > > > - Caused _set_required_opps() to fail if all required opps tables aren't > > > > linked. > > > > > > We are already in the middle of a discussion for your previous version > > > and I haven't said yet that I am happy with what you suggested just 2 > > > days back. Why send another version so soon ? > > > > I wanted you to see how I addressed your comments. > > Sure, but that is just half the comments. > > > It didn't look like > > you were going to make more comments on the code. > > I posted some queries and you posted your opinions on them. Now > shouldn't I get a chance to reply again to see if I agree with your > replies or if we can settle to something else ? I only got one day in > between where I was busy with other stuff and so couldn't come back to > it. Please wait a little longer specially when the comments aren't > minor in nature. Sorry if it came off as trying to rush you. That wasn't the intention. Just some misunderstanding on my part. > Anyway, lets get over it now. Lets continue our discussion on V3 and > then we can have a V5 :) > > Have a good day Saravana. Sounds good. You too Viresh! :) -Saravana